import { _ as __nuxt_component_0$2 } from './Card-BkfpdQZ7.mjs';
import { a as __nuxt_component_1, _ as __nuxt_component_0$4 } from './Button-Dgqz5RR8.mjs';
import { _ as __nuxt_component_2, u as useApi } from './useApi-CFWxoIea.mjs';
import { _ as __nuxt_component_0$3 } from './nuxt-link-B3UD8izG.mjs';
import { defineComponent, mergeProps, withCtx, unref, createTextVNode, openBlock, createBlock, createCommentVNode, createVNode, toDisplayString, computed, ref, watch, reactive, withModifiers, Fragment, renderList, toRef, nextTick, useSSRContext } from 'vue';
import { ssrRenderAttrs, ssrRenderComponent, ssrInterpolate, ssrRenderList, ssrRenderClass, ssrRenderAttr, ssrRenderSlot, ssrIncludeBooleanAttr } from 'vue/server-renderer';
import { _ as _export_sfc } from './_plugin-vue_export-helper-1tPrXgE0.mjs';
import { _ as __nuxt_component_7$1 } from './Modal-KQ_hNOLI.mjs';
import { _ as __nuxt_component_5$1, u as useFormGroup } from './Input-ckU7qZlb.mjs';
import { twJoin } from 'tailwind-merge';
import { k as defu } from '../nitro/nitro.mjs';
import { u as useUI, t as textarea } from './selectMenu-B2FUotwL.mjs';
import { k as useRuntimeConfig, t as twMerge, a as appConfig, m as mergeConfig, l as looseToNumber } from './server.mjs';
import { _ as __nuxt_component_4$2 } from './Select-ByGZz9s4.mjs';
import { marked } from 'marked';
import DOMPurify from 'isomorphic-dompurify';
import { s as setInterval, _ as __nuxt_component_10 } from './interval-Dye37XM9.mjs';
import './index-Dy4Tu7MB.mjs';
import '@iconify/vue';
import '@iconify/utils/lib/css/icon';
import 'perfect-debounce';
import '@vueuse/core';
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';
import 'vue-router';
import '../routes/renderer.mjs';
import 'vue-bundle-renderer/runtime';
import 'unhead/server';
import 'devalue';
import 'unhead/utils';
import 'unhead/plugins';

const _sfc_main$9 = /* @__PURE__ */ defineComponent({
  __name: "TasksTaskCard",
  __ssrInlineRender: true,
  props: {
    task: {},
    active: { type: Boolean },
    running: { type: Boolean }
  },
  emits: ["select"],
  setup(__props, { emit: __emit }) {
    return (_ctx, _push, _parent, _attrs) => {
      _push(`<article${ssrRenderAttrs(mergeProps({
        class: ["card", {
          "card--active": __props.active,
          "card--running": __props.running
        }]
      }, _attrs))} data-v-75f8701c><div class="card-id" data-v-75f8701c>${ssrInterpolate(__props.task.id)}</div><div class="card-title" data-v-75f8701c>${ssrInterpolate(__props.task.name)}</div><div class="card-meta" data-v-75f8701c>`);
      if (__props.running) {
        _push(`<span class="badge badge--run" title="Being implemented by aidev in this working tree" data-v-75f8701c> running here </span>`);
      } else {
        _push(`<!---->`);
      }
      _push(`<span class="badge"${ssrRenderAttr("title", `status: ${__props.task.status}`)} data-v-75f8701c>${ssrInterpolate(__props.task.status)}</span>`);
      if (__props.task.priority) {
        _push(`<span class="badge badge--p" data-v-75f8701c>P${ssrInterpolate(__props.task.priority)}</span>`);
      } else {
        _push(`<!---->`);
      }
      _push(`<!--[-->`);
      ssrRenderList(__props.task.tags.slice(0, 3), (tag) => {
        _push(`<span class="badge badge--tag" data-v-75f8701c>${ssrInterpolate(tag)}</span>`);
      });
      _push(`<!--]--></div></article>`);
    };
  }
});
const _sfc_setup$9 = _sfc_main$9.setup;
_sfc_main$9.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/tasks/TasksTaskCard.vue");
  return _sfc_setup$9 ? _sfc_setup$9(props, ctx) : void 0;
};
const __nuxt_component_0$1 = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-75f8701c"]]);
const _sfc_main$8 = /* @__PURE__ */ defineComponent({
  __name: "TasksBoardColumn",
  __ssrInlineRender: true,
  props: {
    column: {},
    loading: { type: Boolean },
    loaded: { type: Boolean },
    activeId: {},
    runningTaskId: {}
  },
  emits: ["select"],
  setup(__props, { emit: __emit }) {
    const emit = __emit;
    return (_ctx, _push, _parent, _attrs) => {
      const _component_TasksTaskCard = __nuxt_component_0$1;
      _push(`<div${ssrRenderAttrs(mergeProps({ class: "column" }, _attrs))} data-v-b3a5d2f7><header class="col-head" data-v-b3a5d2f7><span class="${ssrRenderClass([`col-title--${__props.column.key}`, "col-title"])}" data-v-b3a5d2f7>${ssrInterpolate(__props.column.title)}</span><span class="col-count" data-v-b3a5d2f7>${ssrInterpolate(__props.column.tasks.length)}</span></header><div class="col-body" data-v-b3a5d2f7>`);
      if (__props.loading && !__props.loaded) {
        _push(`<p class="col-empty" data-v-b3a5d2f7>Loading\u2026</p>`);
      } else {
        _push(`<!--[--><!--[-->`);
        ssrRenderList(__props.column.tasks, (task) => {
          _push(ssrRenderComponent(_component_TasksTaskCard, {
            key: task.id,
            task,
            active: __props.activeId === task.id,
            running: __props.runningTaskId === task.id,
            onSelect: ($event) => emit("select", task)
          }, null, _parent));
        });
        _push(`<!--]-->`);
        if (__props.column.tasks.length === 0) {
          _push(`<p class="col-empty" data-v-b3a5d2f7>empty</p>`);
        } else {
          _push(`<!---->`);
        }
        _push(`<!--]-->`);
      }
      _push(`</div></div>`);
    };
  }
});
const _sfc_setup$8 = _sfc_main$8.setup;
_sfc_main$8.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/tasks/TasksBoardColumn.vue");
  return _sfc_setup$8 ? _sfc_setup$8(props, ctx) : void 0;
};
const __nuxt_component_0 = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-b3a5d2f7"]]);
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
  __name: "TasksBoard",
  __ssrInlineRender: true,
  props: {
    columns: {},
    loading: { type: Boolean },
    loaded: { type: Boolean },
    activeId: {},
    runningTaskId: {}
  },
  emits: ["select"],
  setup(__props, { emit: __emit }) {
    const emit = __emit;
    return (_ctx, _push, _parent, _attrs) => {
      const _component_TasksBoardColumn = __nuxt_component_0;
      _push(`<div${ssrRenderAttrs(mergeProps({ class: "board-scroll" }, _attrs))} data-v-3c3c8dd8><div class="board" data-v-3c3c8dd8><!--[-->`);
      ssrRenderList(__props.columns, (col) => {
        _push(ssrRenderComponent(_component_TasksBoardColumn, {
          key: col.key,
          column: col,
          loading: __props.loading,
          loaded: __props.loaded,
          "active-id": __props.activeId,
          "running-task-id": __props.runningTaskId,
          onSelect: ($event) => emit("select", $event)
        }, null, _parent));
      });
      _push(`<!--]--></div></div>`);
    };
  }
});
const _sfc_setup$7 = _sfc_main$7.setup;
_sfc_main$7.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/tasks/TasksBoard.vue");
  return _sfc_setup$7 ? _sfc_setup$7(props, ctx) : void 0;
};
const __nuxt_component_4$1 = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-3c3c8dd8"]]);
const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.textarea, textarea);
const _sfc_main$6 = defineComponent({
  inheritAttrs: false,
  props: {
    modelValue: {
      type: [String, Number],
      default: ""
    },
    id: {
      type: String,
      default: null
    },
    name: {
      type: String,
      default: null
    },
    placeholder: {
      type: String,
      default: null
    },
    required: {
      type: Boolean,
      default: false
    },
    disabled: {
      type: Boolean,
      default: false
    },
    rows: {
      type: Number,
      default: 3
    },
    maxrows: {
      type: Number,
      default: 0
    },
    autoresize: {
      type: Boolean,
      default: false
    },
    autofocus: {
      type: Boolean,
      default: false
    },
    autofocusDelay: {
      type: Number,
      default: 100
    },
    resize: {
      type: Boolean,
      default: false
    },
    padded: {
      type: Boolean,
      default: true
    },
    size: {
      type: String,
      default: null,
      validator(value) {
        return Object.keys(config.size).includes(value);
      }
    },
    color: {
      type: String,
      default: () => config.default.color,
      validator(value) {
        return [...appConfig.ui.colors, ...Object.keys(config.color)].includes(value);
      }
    },
    variant: {
      type: String,
      default: () => config.default.variant,
      validator(value) {
        return [
          ...Object.keys(config.variant),
          ...Object.values(config.color).flatMap((value2) => Object.keys(value2))
        ].includes(value);
      }
    },
    textareaClass: {
      type: String,
      default: null
    },
    class: {
      type: [String, Object, Array],
      default: () => ""
    },
    ui: {
      type: Object,
      default: () => ({})
    },
    modelModifiers: {
      type: Object,
      default: () => ({})
    }
  },
  emits: ["update:modelValue", "blur", "change"],
  setup(props, { emit }) {
    const { ui, attrs } = useUI("textarea", toRef(props, "ui"), config, toRef(props, "class"));
    const { emitFormBlur, emitFormInput, inputId, color, size, name } = useFormGroup(props, config);
    const modelModifiers = ref(defu({}, props.modelModifiers, { trim: false, lazy: false, number: false, nullify: false }));
    const textarea2 = ref(null);
    const autoResize = () => {
      if (props.autoresize) {
        if (!textarea2.value) {
          return;
        }
        textarea2.value.rows = props.rows;
        const overflow = textarea2.value.style.overflow;
        textarea2.value.style.overflow = "hidden";
        const styles = (void 0).getComputedStyle(textarea2.value);
        const paddingTop = Number.parseInt(styles.paddingTop);
        const paddingBottom = Number.parseInt(styles.paddingBottom);
        const padding = paddingTop + paddingBottom;
        const lineHeight = Number.parseInt(styles.lineHeight);
        const { scrollHeight } = textarea2.value;
        const newRows = (scrollHeight - padding) / lineHeight;
        if (newRows > props.rows) {
          textarea2.value.rows = props.maxrows ? Math.min(newRows, props.maxrows) : newRows;
        }
        textarea2.value.style.overflow = overflow;
      }
    };
    const updateInput = (value) => {
      if (modelModifiers.value.trim) {
        value = value.trim();
      }
      if (modelModifiers.value.number) {
        value = looseToNumber(value);
      }
      if (modelModifiers.value.nullify) {
        value || (value = null);
      }
      emit("update:modelValue", value);
      emitFormInput();
    };
    const onInput = (event) => {
      autoResize();
      if (!modelModifiers.value.lazy) {
        updateInput(event.target.value);
      }
    };
    const onChange = (event) => {
      const value = event.target.value;
      emit("change", value);
      if (modelModifiers.value.lazy) {
        updateInput(value);
      }
      if (modelModifiers.value.trim) {
        event.target.value = value.trim();
      }
    };
    const onBlur = (event) => {
      emit("blur", event);
      emitFormBlur();
    };
    watch(() => props.modelValue, () => {
      nextTick(autoResize);
    });
    const textareaClass = computed(() => {
      var _a, _b;
      const variant = ((_b = (_a = ui.value.color) == null ? void 0 : _a[color.value]) == null ? void 0 : _b[props.variant]) || ui.value.variant[props.variant];
      return twMerge(twJoin(
        ui.value.base,
        ui.value.form,
        ui.value.rounded,
        ui.value.placeholder,
        ui.value.size[size.value],
        props.padded ? ui.value.padding[size.value] : "p-0",
        variant == null ? void 0 : variant.replaceAll("{color}", color.value),
        !props.resize && "resize-none"
      ), props.textareaClass);
    });
    return {
      // eslint-disable-next-line vue/no-dupe-keys
      ui,
      attrs,
      // eslint-disable-next-line vue/no-dupe-keys
      name,
      inputId,
      textarea: textarea2,
      // eslint-disable-next-line vue/no-dupe-keys
      textareaClass,
      onInput,
      onChange,
      onBlur
    };
  }
});
function _sfc_ssrRender(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
  let _temp0;
  _push(`<div${ssrRenderAttrs(mergeProps({
    class: _ctx.ui.wrapper
  }, _attrs))}><textarea${ssrRenderAttrs(_temp0 = mergeProps({
    id: _ctx.inputId,
    ref: "textarea",
    value: _ctx.modelValue,
    name: _ctx.name,
    rows: _ctx.rows,
    required: _ctx.required,
    disabled: _ctx.disabled,
    placeholder: _ctx.placeholder,
    class: _ctx.textareaClass
  }, _ctx.attrs), "textarea")}>${ssrInterpolate("value" in _temp0 ? _temp0.value : "")}</textarea>`);
  ssrRenderSlot(_ctx.$slots, "default", {}, null, _push, _parent);
  _push(`</div>`);
}
const _sfc_setup$6 = _sfc_main$6.setup;
_sfc_main$6.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("node_modules/@nuxt/ui/dist/runtime/components/forms/Textarea.vue");
  return _sfc_setup$6 ? _sfc_setup$6(props, ctx) : void 0;
};
const __nuxt_component_9 = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["ssrRender", _sfc_ssrRender]]);
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
  __name: "TagsBar",
  __ssrInlineRender: true,
  props: {
    modelValue: {},
    suggestedTags: {},
    otherTags: {},
    saving: { type: Boolean }
  },
  emits: ["update:modelValue", "removeOther"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const MUTEX_GROUPS = [
      /* @__PURE__ */ new Set(["code", "non-code"]),
      /* @__PURE__ */ new Set(["planning", "thinking"])
    ];
    function mutexGroup(label) {
      return MUTEX_GROUPS.find((g) => g.has(label));
    }
    const mutexGroups = computed(() => {
      const result = [];
      const placed = /* @__PURE__ */ new Set();
      for (const s of props.suggestedTags) {
        if (placed.has(s.label)) continue;
        const group = MUTEX_GROUPS.find((g) => g.has(s.label));
        if (group) {
          const members = props.suggestedTags.filter((t) => group.has(t.label));
          members.forEach((m) => placed.add(m.label));
          result.push(members);
        }
      }
      return result;
    });
    const singletonList = computed(
      () => props.suggestedTags.filter((s) => !mutexGroup(s.label))
    );
    return (_ctx, _push, _parent, _attrs) => {
      var _a;
      const _component_UIcon = __nuxt_component_0$4;
      _push(`<div${ssrRenderAttrs(mergeProps({
        class: ["tags-bar", { "tags-bar--saving": __props.saving }]
      }, _attrs))} data-v-3f5621e5><!--[-->`);
      ssrRenderList(unref(mutexGroups), (group, gi) => {
        _push(`<div class="btn-group" data-v-3f5621e5><!--[-->`);
        ssrRenderList(group, (st) => {
          _push(`<button type="button" class="${ssrRenderClass([{ "btn-seg--on": __props.modelValue.includes(st.tag) }, "btn-seg"])}"${ssrIncludeBooleanAttr(__props.saving) ? " disabled" : ""} data-v-3f5621e5>${ssrInterpolate(st.label)}</button>`);
        });
        _push(`<!--]--></div>`);
      });
      _push(`<!--]--><!--[-->`);
      ssrRenderList(unref(singletonList), (st) => {
        _push(`<button type="button" class="${ssrRenderClass([{ "tag-chip--on": __props.modelValue.includes(st.tag) }, "tag-chip"])}"${ssrIncludeBooleanAttr(__props.saving) ? " disabled" : ""} data-v-3f5621e5>${ssrInterpolate(st.label)}</button>`);
      });
      _push(`<!--]-->`);
      if (__props.otherTags && __props.otherTags.length > 0) {
        _push(`<!--[-->`);
        ssrRenderList(__props.otherTags, (tag) => {
          _push(`<span class="tag-chip tag-chip--on tag-chip--other" data-v-3f5621e5>${ssrInterpolate(tag)} <button type="button" class="tag-chip-remove"${ssrIncludeBooleanAttr(__props.saving) ? " disabled" : ""}${ssrRenderAttr("aria-label", `Remove tag ${tag}`)} data-v-3f5621e5>`);
          _push(ssrRenderComponent(_component_UIcon, { name: "i-heroicons-x-mark" }, null, _parent));
          _push(`</button></span>`);
        });
        _push(`<!--]-->`);
      } else {
        _push(`<!---->`);
      }
      if (__props.suggestedTags.length === 0 && !((_a = __props.otherTags) == null ? void 0 : _a.length)) {
        _push(`<span class="muted-empty" data-v-3f5621e5> No tags. </span>`);
      } else {
        _push(`<!---->`);
      }
      _push(`</div>`);
    };
  }
});
const _sfc_setup$5 = _sfc_main$5.setup;
_sfc_main$5.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/tasks/TagsBar.vue");
  return _sfc_setup$5 ? _sfc_setup$5(props, ctx) : void 0;
};
const __nuxt_component_7 = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-3f5621e5"]]);
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
  __name: "TaskCreateModal",
  __ssrInlineRender: true,
  props: {
    open: { type: Boolean },
    saving: { type: Boolean },
    error: {},
    suggestedTags: {}
  },
  emits: ["update:open", "close", "submit"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const priorityOptions = [
      { label: "\u2014 none \u2014", value: "" },
      { label: "Urgent", value: "1" },
      { label: "High", value: "2" },
      { label: "Medium", value: "3" },
      { label: "Low", value: "4" }
    ];
    const defaultCodeTag = computed(() => {
      var _a;
      const code = props.suggestedTags.find((t) => t.label === "code");
      return (_a = code == null ? void 0 : code.tag) != null ? _a : "";
    });
    const form = reactive({
      title: "",
      description: "",
      tags: [],
      priority: ""
    });
    watch(
      () => props.open,
      (open) => {
        if (open) {
          form.title = "";
          form.description = "";
          form.tags = defaultCodeTag.value ? [defaultCodeTag.value] : [];
          form.priority = "";
        }
      }
    );
    function submit() {
      if (!form.title.trim()) return;
      const priority = form.priority ? parseInt(form.priority, 10) : void 0;
      emit("submit", {
        title: form.title.trim(),
        description: form.description.trim(),
        tags: [...form.tags],
        priority
      });
    }
    return (_ctx, _push, _parent, _attrs) => {
      const _component_UModal = __nuxt_component_7$1;
      const _component_UCard = __nuxt_component_0$2;
      const _component_UButton = __nuxt_component_1;
      const _component_UAlert = __nuxt_component_2;
      const _component_UInput = __nuxt_component_5$1;
      const _component_UTextarea = __nuxt_component_9;
      const _component_TasksTagsBar = __nuxt_component_7;
      const _component_USelect = __nuxt_component_4$2;
      _push(ssrRenderComponent(_component_UModal, mergeProps({
        "model-value": __props.open,
        ui: { width: "sm:max-w-xl" },
        "onUpdate:modelValue": ($event) => emit("update:open", $event)
      }, _attrs), {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(ssrRenderComponent(_component_UCard, null, {
              header: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(`<div class="flex items-center justify-between gap-3" data-v-2ed4cf80${_scopeId2}><h2 class="text-base font-semibold" data-v-2ed4cf80${_scopeId2}>New Task</h2>`);
                  _push3(ssrRenderComponent(_component_UButton, {
                    size: "xs",
                    color: "gray",
                    variant: "ghost",
                    onClick: ($event) => emit("close")
                  }, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(`Close`);
                      } else {
                        return [
                          createTextVNode("Close")
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                  _push3(`</div>`);
                } else {
                  return [
                    createVNode("div", { class: "flex items-center justify-between gap-3" }, [
                      createVNode("h2", { class: "text-base font-semibold" }, "New Task"),
                      createVNode(_component_UButton, {
                        size: "xs",
                        color: "gray",
                        variant: "ghost",
                        onClick: ($event) => emit("close")
                      }, {
                        default: withCtx(() => [
                          createTextVNode("Close")
                        ]),
                        _: 1
                      }, 8, ["onClick"])
                    ])
                  ];
                }
              }),
              default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  if (__props.error) {
                    _push3(ssrRenderComponent(_component_UAlert, {
                      color: "red",
                      variant: "soft",
                      title: __props.error,
                      class: "mb-4"
                    }, null, _parent3, _scopeId2));
                  } else {
                    _push3(`<!---->`);
                  }
                  _push3(`<form class="create-form" data-v-2ed4cf80${_scopeId2}><div class="field" data-v-2ed4cf80${_scopeId2}><label class="field-label" data-v-2ed4cf80${_scopeId2}>Title <span class="required" data-v-2ed4cf80${_scopeId2}>*</span></label>`);
                  _push3(ssrRenderComponent(_component_UInput, {
                    modelValue: unref(form).title,
                    "onUpdate:modelValue": ($event) => unref(form).title = $event,
                    placeholder: "Task title",
                    autofocus: "",
                    disabled: __props.saving
                  }, null, _parent3, _scopeId2));
                  _push3(`</div><div class="field" data-v-2ed4cf80${_scopeId2}><label class="field-label" data-v-2ed4cf80${_scopeId2}>Description</label>`);
                  _push3(ssrRenderComponent(_component_UTextarea, {
                    modelValue: unref(form).description,
                    "onUpdate:modelValue": ($event) => unref(form).description = $event,
                    placeholder: "Optional description\u2026",
                    rows: 4,
                    disabled: __props.saving
                  }, null, _parent3, _scopeId2));
                  _push3(`</div>`);
                  if (__props.suggestedTags.length > 0) {
                    _push3(`<div class="field" data-v-2ed4cf80${_scopeId2}><label class="field-label" data-v-2ed4cf80${_scopeId2}>Tags</label>`);
                    _push3(ssrRenderComponent(_component_TasksTagsBar, {
                      modelValue: unref(form).tags,
                      "onUpdate:modelValue": ($event) => unref(form).tags = $event,
                      "suggested-tags": __props.suggestedTags,
                      saving: __props.saving
                    }, null, _parent3, _scopeId2));
                    _push3(`</div>`);
                  } else {
                    _push3(`<!---->`);
                  }
                  _push3(`<div class="field" data-v-2ed4cf80${_scopeId2}><label class="field-label" data-v-2ed4cf80${_scopeId2}>Priority</label>`);
                  _push3(ssrRenderComponent(_component_USelect, {
                    modelValue: unref(form).priority,
                    "onUpdate:modelValue": ($event) => unref(form).priority = $event,
                    options: priorityOptions,
                    "value-attribute": "value",
                    "option-attribute": "label",
                    disabled: __props.saving
                  }, null, _parent3, _scopeId2));
                  _push3(`</div><div class="actions" data-v-2ed4cf80${_scopeId2}>`);
                  _push3(ssrRenderComponent(_component_UButton, {
                    color: "gray",
                    variant: "ghost",
                    disabled: __props.saving,
                    onClick: ($event) => emit("close")
                  }, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(` Cancel `);
                      } else {
                        return [
                          createTextVNode(" Cancel ")
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                  _push3(ssrRenderComponent(_component_UButton, {
                    type: "submit",
                    color: "primary",
                    loading: __props.saving,
                    disabled: !unref(form).title.trim() || __props.saving
                  }, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(` Create Task `);
                      } else {
                        return [
                          createTextVNode(" Create Task ")
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                  _push3(`</div></form>`);
                } else {
                  return [
                    __props.error ? (openBlock(), createBlock(_component_UAlert, {
                      key: 0,
                      color: "red",
                      variant: "soft",
                      title: __props.error,
                      class: "mb-4"
                    }, null, 8, ["title"])) : createCommentVNode("", true),
                    createVNode("form", {
                      class: "create-form",
                      onSubmit: withModifiers(submit, ["prevent"])
                    }, [
                      createVNode("div", { class: "field" }, [
                        createVNode("label", { class: "field-label" }, [
                          createTextVNode("Title "),
                          createVNode("span", { class: "required" }, "*")
                        ]),
                        createVNode(_component_UInput, {
                          modelValue: unref(form).title,
                          "onUpdate:modelValue": ($event) => unref(form).title = $event,
                          placeholder: "Task title",
                          autofocus: "",
                          disabled: __props.saving
                        }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled"])
                      ]),
                      createVNode("div", { class: "field" }, [
                        createVNode("label", { class: "field-label" }, "Description"),
                        createVNode(_component_UTextarea, {
                          modelValue: unref(form).description,
                          "onUpdate:modelValue": ($event) => unref(form).description = $event,
                          placeholder: "Optional description\u2026",
                          rows: 4,
                          disabled: __props.saving
                        }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled"])
                      ]),
                      __props.suggestedTags.length > 0 ? (openBlock(), createBlock("div", {
                        key: 0,
                        class: "field"
                      }, [
                        createVNode("label", { class: "field-label" }, "Tags"),
                        createVNode(_component_TasksTagsBar, {
                          modelValue: unref(form).tags,
                          "onUpdate:modelValue": ($event) => unref(form).tags = $event,
                          "suggested-tags": __props.suggestedTags,
                          saving: __props.saving
                        }, null, 8, ["modelValue", "onUpdate:modelValue", "suggested-tags", "saving"])
                      ])) : createCommentVNode("", true),
                      createVNode("div", { class: "field" }, [
                        createVNode("label", { class: "field-label" }, "Priority"),
                        createVNode(_component_USelect, {
                          modelValue: unref(form).priority,
                          "onUpdate:modelValue": ($event) => unref(form).priority = $event,
                          options: priorityOptions,
                          "value-attribute": "value",
                          "option-attribute": "label",
                          disabled: __props.saving
                        }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled"])
                      ]),
                      createVNode("div", { class: "actions" }, [
                        createVNode(_component_UButton, {
                          color: "gray",
                          variant: "ghost",
                          disabled: __props.saving,
                          onClick: ($event) => emit("close")
                        }, {
                          default: withCtx(() => [
                            createTextVNode(" Cancel ")
                          ]),
                          _: 1
                        }, 8, ["disabled", "onClick"]),
                        createVNode(_component_UButton, {
                          type: "submit",
                          color: "primary",
                          loading: __props.saving,
                          disabled: !unref(form).title.trim() || __props.saving
                        }, {
                          default: withCtx(() => [
                            createTextVNode(" Create Task ")
                          ]),
                          _: 1
                        }, 8, ["loading", "disabled"])
                      ])
                    ], 32)
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
          } else {
            return [
              createVNode(_component_UCard, null, {
                header: withCtx(() => [
                  createVNode("div", { class: "flex items-center justify-between gap-3" }, [
                    createVNode("h2", { class: "text-base font-semibold" }, "New Task"),
                    createVNode(_component_UButton, {
                      size: "xs",
                      color: "gray",
                      variant: "ghost",
                      onClick: ($event) => emit("close")
                    }, {
                      default: withCtx(() => [
                        createTextVNode("Close")
                      ]),
                      _: 1
                    }, 8, ["onClick"])
                  ])
                ]),
                default: withCtx(() => [
                  __props.error ? (openBlock(), createBlock(_component_UAlert, {
                    key: 0,
                    color: "red",
                    variant: "soft",
                    title: __props.error,
                    class: "mb-4"
                  }, null, 8, ["title"])) : createCommentVNode("", true),
                  createVNode("form", {
                    class: "create-form",
                    onSubmit: withModifiers(submit, ["prevent"])
                  }, [
                    createVNode("div", { class: "field" }, [
                      createVNode("label", { class: "field-label" }, [
                        createTextVNode("Title "),
                        createVNode("span", { class: "required" }, "*")
                      ]),
                      createVNode(_component_UInput, {
                        modelValue: unref(form).title,
                        "onUpdate:modelValue": ($event) => unref(form).title = $event,
                        placeholder: "Task title",
                        autofocus: "",
                        disabled: __props.saving
                      }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled"])
                    ]),
                    createVNode("div", { class: "field" }, [
                      createVNode("label", { class: "field-label" }, "Description"),
                      createVNode(_component_UTextarea, {
                        modelValue: unref(form).description,
                        "onUpdate:modelValue": ($event) => unref(form).description = $event,
                        placeholder: "Optional description\u2026",
                        rows: 4,
                        disabled: __props.saving
                      }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled"])
                    ]),
                    __props.suggestedTags.length > 0 ? (openBlock(), createBlock("div", {
                      key: 0,
                      class: "field"
                    }, [
                      createVNode("label", { class: "field-label" }, "Tags"),
                      createVNode(_component_TasksTagsBar, {
                        modelValue: unref(form).tags,
                        "onUpdate:modelValue": ($event) => unref(form).tags = $event,
                        "suggested-tags": __props.suggestedTags,
                        saving: __props.saving
                      }, null, 8, ["modelValue", "onUpdate:modelValue", "suggested-tags", "saving"])
                    ])) : createCommentVNode("", true),
                    createVNode("div", { class: "field" }, [
                      createVNode("label", { class: "field-label" }, "Priority"),
                      createVNode(_component_USelect, {
                        modelValue: unref(form).priority,
                        "onUpdate:modelValue": ($event) => unref(form).priority = $event,
                        options: priorityOptions,
                        "value-attribute": "value",
                        "option-attribute": "label",
                        disabled: __props.saving
                      }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled"])
                    ]),
                    createVNode("div", { class: "actions" }, [
                      createVNode(_component_UButton, {
                        color: "gray",
                        variant: "ghost",
                        disabled: __props.saving,
                        onClick: ($event) => emit("close")
                      }, {
                        default: withCtx(() => [
                          createTextVNode(" Cancel ")
                        ]),
                        _: 1
                      }, 8, ["disabled", "onClick"]),
                      createVNode(_component_UButton, {
                        type: "submit",
                        color: "primary",
                        loading: __props.saving,
                        disabled: !unref(form).title.trim() || __props.saving
                      }, {
                        default: withCtx(() => [
                          createTextVNode(" Create Task ")
                        ]),
                        _: 1
                      }, 8, ["loading", "disabled"])
                    ])
                  ], 32)
                ]),
                _: 1
              })
            ];
          }
        }),
        _: 1
      }, _parent));
    };
  }
});
const _sfc_setup$4 = _sfc_main$4.setup;
_sfc_main$4.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/tasks/TaskCreateModal.vue");
  return _sfc_setup$4 ? _sfc_setup$4(props, ctx) : void 0;
};
const __nuxt_component_5 = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-2ed4cf80"]]);
marked.setOptions({
  gfm: true,
  breaks: true
});
const PURIFY_OPTS = {
  USE_PROFILES: { html: true }
};
function renderMarkdown(source) {
  const text = source.trim();
  if (!text) return "";
  const raw = marked.parse(text, { async: false });
  return DOMPurify.sanitize(raw, PURIFY_OPTS);
}
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
  __name: "MarkdownContent",
  __ssrInlineRender: true,
  props: {
    content: {}
  },
  setup(__props) {
    const props = __props;
    const html = computed(() => renderMarkdown(props.content));
    return (_ctx, _push, _parent, _attrs) => {
      var _a;
      if (unref(html)) {
        _push(`<div${ssrRenderAttrs(mergeProps({ class: "md-content" }, _attrs))} data-v-14f3b300>${(_a = unref(html)) != null ? _a : ""}</div>`);
      } else {
        _push(`<!---->`);
      }
    };
  }
});
const _sfc_setup$3 = _sfc_main$3.setup;
_sfc_main$3.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/MarkdownContent.vue");
  return _sfc_setup$3 ? _sfc_setup$3(props, ctx) : void 0;
};
const __nuxt_component_4 = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-14f3b300"]]);
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
  __name: "TaskDetailExecute",
  __ssrInlineRender: true,
  props: {
    taskId: {},
    cwd: {},
    running: { type: Boolean },
    lines: {},
    text: {}
  },
  emits: ["run", "stop", "clear"],
  setup(__props, { expose: __expose, emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const viewerRef = ref(null);
    __expose({ viewerRef });
    watch(
      () => props.lines.length,
      () => {
        nextTick(() => {
          const el = viewerRef.value;
          if (el) el.scrollTop = el.scrollHeight;
        });
      }
    );
    return (_ctx, _push, _parent, _attrs) => {
      const _component_UButton = __nuxt_component_1;
      _push(`<section${ssrRenderAttrs(mergeProps({ class: "drawer-section" }, _attrs))} data-v-a2f9ad74><h3 class="section-title" data-v-a2f9ad74>Execute</h3><p class="muted" data-v-a2f9ad74> Runs <code data-v-a2f9ad74>aidev run --task ${ssrInterpolate(__props.taskId)}</code> in <code data-v-a2f9ad74>${ssrInterpolate(__props.cwd)}</code>. Streams stdout/stderr live below. </p><div class="exec-row" data-v-a2f9ad74>`);
      _push(ssrRenderComponent(_component_UButton, {
        size: "sm",
        color: "primary",
        disabled: __props.running,
        onClick: ($event) => emit("run")
      }, {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(`${ssrInterpolate(__props.running ? "Running\u2026" : "Execute task")}`);
          } else {
            return [
              createTextVNode(toDisplayString(__props.running ? "Running\u2026" : "Execute task"), 1)
            ];
          }
        }),
        _: 1
      }, _parent));
      if (__props.running) {
        _push(ssrRenderComponent(_component_UButton, {
          size: "sm",
          color: "red",
          variant: "soft",
          onClick: ($event) => emit("stop")
        }, {
          default: withCtx((_, _push2, _parent2, _scopeId) => {
            if (_push2) {
              _push2(` Cancel `);
            } else {
              return [
                createTextVNode(" Cancel ")
              ];
            }
          }),
          _: 1
        }, _parent));
      } else {
        _push(`<!---->`);
      }
      if (__props.lines.length > 0 && !__props.running) {
        _push(ssrRenderComponent(_component_UButton, {
          size: "xs",
          color: "gray",
          variant: "ghost",
          onClick: ($event) => emit("clear")
        }, {
          default: withCtx((_, _push2, _parent2, _scopeId) => {
            if (_push2) {
              _push2(` Clear output `);
            } else {
              return [
                createTextVNode(" Clear output ")
              ];
            }
          }),
          _: 1
        }, _parent));
      } else {
        _push(`<!---->`);
      }
      _push(`</div>`);
      if (__props.lines.length > 0) {
        _push(`<pre class="exec-viewer" data-v-a2f9ad74><code data-v-a2f9ad74>${ssrInterpolate(__props.text)}</code></pre>`);
      } else {
        _push(`<!---->`);
      }
      _push(`</section>`);
    };
  }
});
const _sfc_setup$2 = _sfc_main$2.setup;
_sfc_main$2.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/tasks/TaskDetailExecute.vue");
  return _sfc_setup$2 ? _sfc_setup$2(props, ctx) : void 0;
};
const __nuxt_component_8 = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-a2f9ad74"]]);
const DEFAULT_TASK_FILTERS = {
  open: ["open"],
  pending: ["pending"],
  inProgress: ["in progress"],
  review: ["review"],
  done: ["done"]
};
function buildBoardColumns(tasks2, filters, loaded) {
  const lc = (xs) => xs.map((s) => s.toLowerCase());
  const open = new Set(lc(filters.open));
  const pending = new Set(lc(filters.pending));
  const inProgress = new Set(lc(filters.inProgress));
  const review = new Set(lc(filters.review));
  const done = new Set(lc(filters.done));
  const cols = [
    { key: "open", title: "Open", tasks: [] },
    { key: "pending", title: "Pending", tasks: [] },
    { key: "inprogress", title: "In Progress", tasks: [] },
    { key: "review", title: "In Review", tasks: [] },
    { key: "done", title: "Done", tasks: [] },
    { key: "other", title: "Other", tasks: [] }
  ];
  for (const task of tasks2) {
    const status = task.status.toLowerCase();
    if (open.has(status)) cols[0].tasks.push(task);
    else if (pending.has(status)) cols[1].tasks.push(task);
    else if (inProgress.has(status)) cols[2].tasks.push(task);
    else if (review.has(status)) cols[3].tasks.push(task);
    else if (done.has(status)) cols[4].tasks.push(task);
    else cols[5].tasks.push(task);
  }
  for (const col of cols) {
    col.tasks.sort((a, b) => {
      var _a, _b;
      const pa = (_a = a.priority) != null ? _a : Number.MAX_SAFE_INTEGER;
      const pb = (_b = b.priority) != null ? _b : Number.MAX_SAFE_INTEGER;
      if (pa !== pb) return pa - pb;
      return a.id.localeCompare(b.id);
    });
  }
  if (!loaded) {
    return cols.filter((c) => c.key !== "other");
  }
  return cols.filter((c) => c.tasks.length > 0 || c.key !== "other");
}
function buildStatusOptions(filters, providerStatuses) {
  if (providerStatuses.length > 0) {
    return providerStatuses.map((s) => ({ label: s, value: s }));
  }
  const all = [...filters.open, ...filters.pending, ...filters.inProgress, ...filters.review, ...filters.done];
  const seen = /* @__PURE__ */ new Set();
  const opts = [];
  for (const s of all) {
    if (!s || seen.has(s)) continue;
    seen.add(s);
    opts.push({ label: s, value: s });
  }
  return opts;
}
function formatTaskDate(epochMs) {
  if (!epochMs) return "";
  try {
    return new Date(epochMs).toLocaleString();
  } catch {
    return "";
  }
}
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  __name: "TaskDetailModal",
  __ssrInlineRender: true,
  props: {
    open: { type: Boolean },
    detail: {},
    providerName: {},
    error: {},
    statusDraft: {},
    statusSaving: { type: Boolean },
    statusOptions: {},
    commentDraft: {},
    commentAsAidev: { type: Boolean },
    commentSaving: { type: Boolean },
    cwd: {},
    execRunning: { type: Boolean },
    execLines: {},
    execText: {},
    suggestedTags: {},
    tagSaving: { type: Boolean }
  },
  emits: ["update:open", "close", "update:statusDraft", "changeStatus", "update:commentDraft", "update:commentAsAidev", "postComment", "run", "stop", "clearExec", "saveTags"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const otherTags = computed(() => {
      if (!props.detail) return [];
      const suggested = new Set(props.suggestedTags.map((s) => s.tag));
      return props.detail.task.tags.filter((tag) => !suggested.has(tag));
    });
    function onTagsChanged(next) {
      if (!props.detail) return;
      const prev = props.detail.task.tags;
      const prevSet = new Set(prev);
      const nextSet = new Set(next);
      const add = next.filter((t) => !prevSet.has(t));
      const remove = prev.filter((t) => !nextSet.has(t));
      if (add.length || remove.length) emit("saveTags", add, remove);
    }
    const emit = __emit;
    return (_ctx, _push, _parent, _attrs) => {
      const _component_UModal = __nuxt_component_7$1;
      const _component_UCard = __nuxt_component_0$2;
      const _component_UButton = __nuxt_component_1;
      const _component_UAlert = __nuxt_component_2;
      const _component_MarkdownContent = __nuxt_component_4;
      const _component_USelect = __nuxt_component_4$2;
      const _component_UInput = __nuxt_component_5$1;
      const _component_TasksTagsBar = __nuxt_component_7;
      const _component_TasksTaskDetailExecute = __nuxt_component_8;
      const _component_UTextarea = __nuxt_component_9;
      const _component_UCheckbox = __nuxt_component_10;
      _push(ssrRenderComponent(_component_UModal, mergeProps({
        "model-value": __props.open,
        ui: { width: "sm:max-w-6xl" },
        "onUpdate:modelValue": ($event) => emit("update:open", $event)
      }, _attrs), {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            if (__props.detail) {
              _push2(ssrRenderComponent(_component_UCard, { class: "task-drawer-card" }, {
                header: withCtx((_2, _push3, _parent3, _scopeId2) => {
                  if (_push3) {
                    _push3(`<div class="flex items-start justify-between gap-3" data-v-f7c8f271${_scopeId2}><div class="min-w-0" data-v-f7c8f271${_scopeId2}><p class="text-xs text-gray-500" data-v-f7c8f271${_scopeId2}><code data-v-f7c8f271${_scopeId2}>${ssrInterpolate(__props.detail.task.id)}</code></p><h2 class="text-base font-semibold truncate"${ssrRenderAttr("title", __props.detail.task.name)} data-v-f7c8f271${_scopeId2}>${ssrInterpolate(__props.detail.task.name)}</h2><p class="text-xs text-gray-500 mt-0.5" data-v-f7c8f271${_scopeId2}>`);
                    if (__props.detail.task.url) {
                      _push3(`<a${ssrRenderAttr("href", __props.detail.task.url)} target="_blank" rel="noopener" class="link" data-v-f7c8f271${_scopeId2}> Open in ${ssrInterpolate(__props.providerName)} \u2197 </a>`);
                    } else {
                      _push3(`<!---->`);
                    }
                    _push3(`</p></div>`);
                    _push3(ssrRenderComponent(_component_UButton, {
                      size: "xs",
                      color: "gray",
                      variant: "ghost",
                      onClick: ($event) => emit("close")
                    }, {
                      default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                        if (_push4) {
                          _push4(`Close`);
                        } else {
                          return [
                            createTextVNode("Close")
                          ];
                        }
                      }),
                      _: 1
                    }, _parent3, _scopeId2));
                    _push3(`</div>`);
                  } else {
                    return [
                      createVNode("div", { class: "flex items-start justify-between gap-3" }, [
                        createVNode("div", { class: "min-w-0" }, [
                          createVNode("p", { class: "text-xs text-gray-500" }, [
                            createVNode("code", null, toDisplayString(__props.detail.task.id), 1)
                          ]),
                          createVNode("h2", {
                            class: "text-base font-semibold truncate",
                            title: __props.detail.task.name
                          }, toDisplayString(__props.detail.task.name), 9, ["title"]),
                          createVNode("p", { class: "text-xs text-gray-500 mt-0.5" }, [
                            __props.detail.task.url ? (openBlock(), createBlock("a", {
                              key: 0,
                              href: __props.detail.task.url,
                              target: "_blank",
                              rel: "noopener",
                              class: "link"
                            }, " Open in " + toDisplayString(__props.providerName) + " \u2197 ", 9, ["href"])) : createCommentVNode("", true)
                          ])
                        ]),
                        createVNode(_component_UButton, {
                          size: "xs",
                          color: "gray",
                          variant: "ghost",
                          onClick: ($event) => emit("close")
                        }, {
                          default: withCtx(() => [
                            createTextVNode("Close")
                          ]),
                          _: 1
                        }, 8, ["onClick"])
                      ])
                    ];
                  }
                }),
                default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                  if (_push3) {
                    if (__props.error) {
                      _push3(ssrRenderComponent(_component_UAlert, {
                        color: "red",
                        variant: "soft",
                        title: __props.error,
                        class: "mb-3"
                      }, null, _parent3, _scopeId2));
                    } else {
                      _push3(`<!---->`);
                    }
                    _push3(`<div class="modal-body" data-v-f7c8f271${_scopeId2}><div class="left-col" data-v-f7c8f271${_scopeId2}><section class="drawer-section" data-v-f7c8f271${_scopeId2}><h3 class="section-title" data-v-f7c8f271${_scopeId2}>Description</h3>`);
                    if (__props.detail.task.description) {
                      _push3(`<div class="desc" data-v-f7c8f271${_scopeId2}>`);
                      _push3(ssrRenderComponent(_component_MarkdownContent, {
                        content: __props.detail.task.description
                      }, null, _parent3, _scopeId2));
                      _push3(`</div>`);
                    } else {
                      _push3(`<p class="muted" data-v-f7c8f271${_scopeId2}>No description.</p>`);
                    }
                    _push3(`</section><section class="drawer-section" data-v-f7c8f271${_scopeId2}><h3 class="section-title" data-v-f7c8f271${_scopeId2}>Status</h3><div class="status-row" data-v-f7c8f271${_scopeId2}>`);
                    if (__props.statusOptions.length > 0) {
                      _push3(ssrRenderComponent(_component_USelect, {
                        "model-value": __props.statusDraft,
                        options: __props.statusOptions,
                        size: "sm",
                        "onUpdate:modelValue": ($event) => emit("update:statusDraft", $event)
                      }, null, _parent3, _scopeId2));
                    } else {
                      _push3(ssrRenderComponent(_component_UInput, {
                        "model-value": __props.statusDraft,
                        placeholder: "status name",
                        size: "sm",
                        "onUpdate:modelValue": ($event) => emit("update:statusDraft", $event)
                      }, null, _parent3, _scopeId2));
                    }
                    _push3(ssrRenderComponent(_component_UButton, {
                      size: "sm",
                      color: "primary",
                      loading: __props.statusSaving,
                      disabled: __props.statusSaving || !__props.statusDraft || __props.statusDraft === __props.detail.task.status,
                      onClick: ($event) => emit("changeStatus")
                    }, {
                      default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                        if (_push4) {
                          _push4(` Update status `);
                        } else {
                          return [
                            createTextVNode(" Update status ")
                          ];
                        }
                      }),
                      _: 1
                    }, _parent3, _scopeId2));
                    _push3(`</div></section><section class="drawer-section" data-v-f7c8f271${_scopeId2}><div class="tags-header" data-v-f7c8f271${_scopeId2}><h3 class="section-title" data-v-f7c8f271${_scopeId2}>Tags</h3>`);
                    if (__props.detail.task.tags.length > 0) {
                      _push3(`<span class="tags-count" data-v-f7c8f271${_scopeId2}>${ssrInterpolate(__props.detail.task.tags.length)} applied </span>`);
                    } else {
                      _push3(`<!---->`);
                    }
                    _push3(`</div><div class="${ssrRenderClass([{ "tags-panel--saving": __props.tagSaving }, "tags-panel"])}" data-v-f7c8f271${_scopeId2}>`);
                    _push3(ssrRenderComponent(_component_TasksTagsBar, {
                      "model-value": __props.detail.task.tags,
                      "suggested-tags": __props.suggestedTags,
                      "other-tags": unref(otherTags),
                      saving: __props.tagSaving,
                      "onUpdate:modelValue": onTagsChanged,
                      onRemoveOther: (tag) => emit("saveTags", [], [tag])
                    }, null, _parent3, _scopeId2));
                    _push3(`</div></section>`);
                    _push3(ssrRenderComponent(_component_TasksTaskDetailExecute, {
                      "task-id": __props.detail.task.id,
                      cwd: __props.cwd,
                      running: __props.execRunning,
                      lines: __props.execLines,
                      text: __props.execText,
                      onRun: ($event) => emit("run"),
                      onStop: ($event) => emit("stop"),
                      onClear: ($event) => emit("clearExec")
                    }, null, _parent3, _scopeId2));
                    _push3(`</div><div class="right-col" data-v-f7c8f271${_scopeId2}><h3 class="section-title" data-v-f7c8f271${_scopeId2}>Comments (${ssrInterpolate(__props.detail.comments.length)})</h3><div class="comments-list" data-v-f7c8f271${_scopeId2}>`);
                    if (__props.detail.comments.length > 0) {
                      _push3(`<!--[-->`);
                      ssrRenderList(__props.detail.comments, (c) => {
                        _push3(`<article class="comment" data-v-f7c8f271${_scopeId2}><header class="comment-head" data-v-f7c8f271${_scopeId2}><span class="comment-author" data-v-f7c8f271${_scopeId2}>${ssrInterpolate(c.author || "unknown")}</span><span class="comment-date" data-v-f7c8f271${_scopeId2}>${ssrInterpolate(unref(formatTaskDate)(c.date))}</span></header><div class="comment-body" data-v-f7c8f271${_scopeId2}>`);
                        _push3(ssrRenderComponent(_component_MarkdownContent, {
                          content: c.text
                        }, null, _parent3, _scopeId2));
                        _push3(`</div></article>`);
                      });
                      _push3(`<!--]-->`);
                    } else {
                      _push3(`<p class="muted" data-v-f7c8f271${_scopeId2}>No comments yet.</p>`);
                    }
                    _push3(`</div><div class="comment-form" data-v-f7c8f271${_scopeId2}>`);
                    _push3(ssrRenderComponent(_component_UTextarea, {
                      "model-value": __props.commentDraft,
                      placeholder: "Write a comment\u2026",
                      rows: 3,
                      "onUpdate:modelValue": ($event) => emit("update:commentDraft", $event)
                    }, null, _parent3, _scopeId2));
                    _push3(`<div class="comment-actions" data-v-f7c8f271${_scopeId2}>`);
                    _push3(ssrRenderComponent(_component_UCheckbox, {
                      "model-value": __props.commentAsAidev,
                      label: "Send as [aidev] comment",
                      "onUpdate:modelValue": ($event) => emit("update:commentAsAidev", $event)
                    }, null, _parent3, _scopeId2));
                    _push3(ssrRenderComponent(_component_UButton, {
                      size: "sm",
                      color: "primary",
                      loading: __props.commentSaving,
                      disabled: __props.commentSaving || !__props.commentDraft.trim(),
                      onClick: ($event) => emit("postComment")
                    }, {
                      default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                        if (_push4) {
                          _push4(` Add comment `);
                        } else {
                          return [
                            createTextVNode(" Add comment ")
                          ];
                        }
                      }),
                      _: 1
                    }, _parent3, _scopeId2));
                    _push3(`</div></div></div></div>`);
                  } else {
                    return [
                      __props.error ? (openBlock(), createBlock(_component_UAlert, {
                        key: 0,
                        color: "red",
                        variant: "soft",
                        title: __props.error,
                        class: "mb-3"
                      }, null, 8, ["title"])) : createCommentVNode("", true),
                      createVNode("div", { class: "modal-body" }, [
                        createVNode("div", { class: "left-col" }, [
                          createVNode("section", { class: "drawer-section" }, [
                            createVNode("h3", { class: "section-title" }, "Description"),
                            __props.detail.task.description ? (openBlock(), createBlock("div", {
                              key: 0,
                              class: "desc"
                            }, [
                              createVNode(_component_MarkdownContent, {
                                content: __props.detail.task.description
                              }, null, 8, ["content"])
                            ])) : (openBlock(), createBlock("p", {
                              key: 1,
                              class: "muted"
                            }, "No description."))
                          ]),
                          createVNode("section", { class: "drawer-section" }, [
                            createVNode("h3", { class: "section-title" }, "Status"),
                            createVNode("div", { class: "status-row" }, [
                              __props.statusOptions.length > 0 ? (openBlock(), createBlock(_component_USelect, {
                                key: 0,
                                "model-value": __props.statusDraft,
                                options: __props.statusOptions,
                                size: "sm",
                                "onUpdate:modelValue": ($event) => emit("update:statusDraft", $event)
                              }, null, 8, ["model-value", "options", "onUpdate:modelValue"])) : (openBlock(), createBlock(_component_UInput, {
                                key: 1,
                                "model-value": __props.statusDraft,
                                placeholder: "status name",
                                size: "sm",
                                "onUpdate:modelValue": ($event) => emit("update:statusDraft", $event)
                              }, null, 8, ["model-value", "onUpdate:modelValue"])),
                              createVNode(_component_UButton, {
                                size: "sm",
                                color: "primary",
                                loading: __props.statusSaving,
                                disabled: __props.statusSaving || !__props.statusDraft || __props.statusDraft === __props.detail.task.status,
                                onClick: ($event) => emit("changeStatus")
                              }, {
                                default: withCtx(() => [
                                  createTextVNode(" Update status ")
                                ]),
                                _: 1
                              }, 8, ["loading", "disabled", "onClick"])
                            ])
                          ]),
                          createVNode("section", { class: "drawer-section" }, [
                            createVNode("div", { class: "tags-header" }, [
                              createVNode("h3", { class: "section-title" }, "Tags"),
                              __props.detail.task.tags.length > 0 ? (openBlock(), createBlock("span", {
                                key: 0,
                                class: "tags-count"
                              }, toDisplayString(__props.detail.task.tags.length) + " applied ", 1)) : createCommentVNode("", true)
                            ]),
                            createVNode("div", {
                              class: ["tags-panel", { "tags-panel--saving": __props.tagSaving }]
                            }, [
                              createVNode(_component_TasksTagsBar, {
                                "model-value": __props.detail.task.tags,
                                "suggested-tags": __props.suggestedTags,
                                "other-tags": unref(otherTags),
                                saving: __props.tagSaving,
                                "onUpdate:modelValue": onTagsChanged,
                                onRemoveOther: (tag) => emit("saveTags", [], [tag])
                              }, null, 8, ["model-value", "suggested-tags", "other-tags", "saving", "onRemoveOther"])
                            ], 2)
                          ]),
                          createVNode(_component_TasksTaskDetailExecute, {
                            "task-id": __props.detail.task.id,
                            cwd: __props.cwd,
                            running: __props.execRunning,
                            lines: __props.execLines,
                            text: __props.execText,
                            onRun: ($event) => emit("run"),
                            onStop: ($event) => emit("stop"),
                            onClear: ($event) => emit("clearExec")
                          }, null, 8, ["task-id", "cwd", "running", "lines", "text", "onRun", "onStop", "onClear"])
                        ]),
                        createVNode("div", { class: "right-col" }, [
                          createVNode("h3", { class: "section-title" }, "Comments (" + toDisplayString(__props.detail.comments.length) + ")", 1),
                          createVNode("div", { class: "comments-list" }, [
                            __props.detail.comments.length > 0 ? (openBlock(true), createBlock(Fragment, { key: 0 }, renderList(__props.detail.comments, (c) => {
                              return openBlock(), createBlock("article", {
                                key: c.id,
                                class: "comment"
                              }, [
                                createVNode("header", { class: "comment-head" }, [
                                  createVNode("span", { class: "comment-author" }, toDisplayString(c.author || "unknown"), 1),
                                  createVNode("span", { class: "comment-date" }, toDisplayString(unref(formatTaskDate)(c.date)), 1)
                                ]),
                                createVNode("div", { class: "comment-body" }, [
                                  createVNode(_component_MarkdownContent, {
                                    content: c.text
                                  }, null, 8, ["content"])
                                ])
                              ]);
                            }), 128)) : (openBlock(), createBlock("p", {
                              key: 1,
                              class: "muted"
                            }, "No comments yet."))
                          ]),
                          createVNode("div", { class: "comment-form" }, [
                            createVNode(_component_UTextarea, {
                              "model-value": __props.commentDraft,
                              placeholder: "Write a comment\u2026",
                              rows: 3,
                              "onUpdate:modelValue": ($event) => emit("update:commentDraft", $event)
                            }, null, 8, ["model-value", "onUpdate:modelValue"]),
                            createVNode("div", { class: "comment-actions" }, [
                              createVNode(_component_UCheckbox, {
                                "model-value": __props.commentAsAidev,
                                label: "Send as [aidev] comment",
                                "onUpdate:modelValue": ($event) => emit("update:commentAsAidev", $event)
                              }, null, 8, ["model-value", "onUpdate:modelValue"]),
                              createVNode(_component_UButton, {
                                size: "sm",
                                color: "primary",
                                loading: __props.commentSaving,
                                disabled: __props.commentSaving || !__props.commentDraft.trim(),
                                onClick: ($event) => emit("postComment")
                              }, {
                                default: withCtx(() => [
                                  createTextVNode(" Add comment ")
                                ]),
                                _: 1
                              }, 8, ["loading", "disabled", "onClick"])
                            ])
                          ])
                        ])
                      ])
                    ];
                  }
                }),
                _: 1
              }, _parent2, _scopeId));
            } else {
              _push2(`<!---->`);
            }
          } else {
            return [
              __props.detail ? (openBlock(), createBlock(_component_UCard, {
                key: 0,
                class: "task-drawer-card"
              }, {
                header: withCtx(() => [
                  createVNode("div", { class: "flex items-start justify-between gap-3" }, [
                    createVNode("div", { class: "min-w-0" }, [
                      createVNode("p", { class: "text-xs text-gray-500" }, [
                        createVNode("code", null, toDisplayString(__props.detail.task.id), 1)
                      ]),
                      createVNode("h2", {
                        class: "text-base font-semibold truncate",
                        title: __props.detail.task.name
                      }, toDisplayString(__props.detail.task.name), 9, ["title"]),
                      createVNode("p", { class: "text-xs text-gray-500 mt-0.5" }, [
                        __props.detail.task.url ? (openBlock(), createBlock("a", {
                          key: 0,
                          href: __props.detail.task.url,
                          target: "_blank",
                          rel: "noopener",
                          class: "link"
                        }, " Open in " + toDisplayString(__props.providerName) + " \u2197 ", 9, ["href"])) : createCommentVNode("", true)
                      ])
                    ]),
                    createVNode(_component_UButton, {
                      size: "xs",
                      color: "gray",
                      variant: "ghost",
                      onClick: ($event) => emit("close")
                    }, {
                      default: withCtx(() => [
                        createTextVNode("Close")
                      ]),
                      _: 1
                    }, 8, ["onClick"])
                  ])
                ]),
                default: withCtx(() => [
                  __props.error ? (openBlock(), createBlock(_component_UAlert, {
                    key: 0,
                    color: "red",
                    variant: "soft",
                    title: __props.error,
                    class: "mb-3"
                  }, null, 8, ["title"])) : createCommentVNode("", true),
                  createVNode("div", { class: "modal-body" }, [
                    createVNode("div", { class: "left-col" }, [
                      createVNode("section", { class: "drawer-section" }, [
                        createVNode("h3", { class: "section-title" }, "Description"),
                        __props.detail.task.description ? (openBlock(), createBlock("div", {
                          key: 0,
                          class: "desc"
                        }, [
                          createVNode(_component_MarkdownContent, {
                            content: __props.detail.task.description
                          }, null, 8, ["content"])
                        ])) : (openBlock(), createBlock("p", {
                          key: 1,
                          class: "muted"
                        }, "No description."))
                      ]),
                      createVNode("section", { class: "drawer-section" }, [
                        createVNode("h3", { class: "section-title" }, "Status"),
                        createVNode("div", { class: "status-row" }, [
                          __props.statusOptions.length > 0 ? (openBlock(), createBlock(_component_USelect, {
                            key: 0,
                            "model-value": __props.statusDraft,
                            options: __props.statusOptions,
                            size: "sm",
                            "onUpdate:modelValue": ($event) => emit("update:statusDraft", $event)
                          }, null, 8, ["model-value", "options", "onUpdate:modelValue"])) : (openBlock(), createBlock(_component_UInput, {
                            key: 1,
                            "model-value": __props.statusDraft,
                            placeholder: "status name",
                            size: "sm",
                            "onUpdate:modelValue": ($event) => emit("update:statusDraft", $event)
                          }, null, 8, ["model-value", "onUpdate:modelValue"])),
                          createVNode(_component_UButton, {
                            size: "sm",
                            color: "primary",
                            loading: __props.statusSaving,
                            disabled: __props.statusSaving || !__props.statusDraft || __props.statusDraft === __props.detail.task.status,
                            onClick: ($event) => emit("changeStatus")
                          }, {
                            default: withCtx(() => [
                              createTextVNode(" Update status ")
                            ]),
                            _: 1
                          }, 8, ["loading", "disabled", "onClick"])
                        ])
                      ]),
                      createVNode("section", { class: "drawer-section" }, [
                        createVNode("div", { class: "tags-header" }, [
                          createVNode("h3", { class: "section-title" }, "Tags"),
                          __props.detail.task.tags.length > 0 ? (openBlock(), createBlock("span", {
                            key: 0,
                            class: "tags-count"
                          }, toDisplayString(__props.detail.task.tags.length) + " applied ", 1)) : createCommentVNode("", true)
                        ]),
                        createVNode("div", {
                          class: ["tags-panel", { "tags-panel--saving": __props.tagSaving }]
                        }, [
                          createVNode(_component_TasksTagsBar, {
                            "model-value": __props.detail.task.tags,
                            "suggested-tags": __props.suggestedTags,
                            "other-tags": unref(otherTags),
                            saving: __props.tagSaving,
                            "onUpdate:modelValue": onTagsChanged,
                            onRemoveOther: (tag) => emit("saveTags", [], [tag])
                          }, null, 8, ["model-value", "suggested-tags", "other-tags", "saving", "onRemoveOther"])
                        ], 2)
                      ]),
                      createVNode(_component_TasksTaskDetailExecute, {
                        "task-id": __props.detail.task.id,
                        cwd: __props.cwd,
                        running: __props.execRunning,
                        lines: __props.execLines,
                        text: __props.execText,
                        onRun: ($event) => emit("run"),
                        onStop: ($event) => emit("stop"),
                        onClear: ($event) => emit("clearExec")
                      }, null, 8, ["task-id", "cwd", "running", "lines", "text", "onRun", "onStop", "onClear"])
                    ]),
                    createVNode("div", { class: "right-col" }, [
                      createVNode("h3", { class: "section-title" }, "Comments (" + toDisplayString(__props.detail.comments.length) + ")", 1),
                      createVNode("div", { class: "comments-list" }, [
                        __props.detail.comments.length > 0 ? (openBlock(true), createBlock(Fragment, { key: 0 }, renderList(__props.detail.comments, (c) => {
                          return openBlock(), createBlock("article", {
                            key: c.id,
                            class: "comment"
                          }, [
                            createVNode("header", { class: "comment-head" }, [
                              createVNode("span", { class: "comment-author" }, toDisplayString(c.author || "unknown"), 1),
                              createVNode("span", { class: "comment-date" }, toDisplayString(unref(formatTaskDate)(c.date)), 1)
                            ]),
                            createVNode("div", { class: "comment-body" }, [
                              createVNode(_component_MarkdownContent, {
                                content: c.text
                              }, null, 8, ["content"])
                            ])
                          ]);
                        }), 128)) : (openBlock(), createBlock("p", {
                          key: 1,
                          class: "muted"
                        }, "No comments yet."))
                      ]),
                      createVNode("div", { class: "comment-form" }, [
                        createVNode(_component_UTextarea, {
                          "model-value": __props.commentDraft,
                          placeholder: "Write a comment\u2026",
                          rows: 3,
                          "onUpdate:modelValue": ($event) => emit("update:commentDraft", $event)
                        }, null, 8, ["model-value", "onUpdate:modelValue"]),
                        createVNode("div", { class: "comment-actions" }, [
                          createVNode(_component_UCheckbox, {
                            "model-value": __props.commentAsAidev,
                            label: "Send as [aidev] comment",
                            "onUpdate:modelValue": ($event) => emit("update:commentAsAidev", $event)
                          }, null, 8, ["model-value", "onUpdate:modelValue"]),
                          createVNode(_component_UButton, {
                            size: "sm",
                            color: "primary",
                            loading: __props.commentSaving,
                            disabled: __props.commentSaving || !__props.commentDraft.trim(),
                            onClick: ($event) => emit("postComment")
                          }, {
                            default: withCtx(() => [
                              createTextVNode(" Add comment ")
                            ]),
                            _: 1
                          }, 8, ["loading", "disabled", "onClick"])
                        ])
                      ])
                    ])
                  ])
                ]),
                _: 1
              })) : createCommentVNode("", true)
            ];
          }
        }),
        _: 1
      }, _parent));
    };
  }
});
const _sfc_setup$1 = _sfc_main$1.setup;
_sfc_main$1.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/tasks/TaskDetailModal.vue");
  return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
};
const __nuxt_component_6 = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-f7c8f271"]]);
function useTaskExecute(onError) {
  const execLines = ref([]);
  const execRunning = ref(false);
  const execText = computed(() => execLines.value.join("\n"));
  function resetExecute() {
    execLines.value = [];
    execRunning.value = false;
  }
  function appendExecLine(prefix, line) {
    execLines.value.push(line);
  }
  async function startExecute(taskId) {
    if (execRunning.value) return;
    {
      onError("Not authenticated \u2014 refresh and log in again.");
      return;
    }
  }
  function stopExecute() {
    if (execRunning.value) {
      appendExecLine("", "--- cancelled by user ---");
      execRunning.value = false;
    }
  }
  function clearExecLines() {
    execLines.value = [];
  }
  return {
    execLines,
    execRunning,
    execText,
    resetExecute,
    startExecute,
    stopExecute,
    clearExecLines
  };
}
function useTasksPage() {
  const api = useApi();
  const runtime = useRuntimeConfig();
  const cwd = computed(() => runtime.public.aidevCwd);
  const data = ref(null);
  const providerStatuses = ref([]);
  const loading = ref(false);
  const loadError = ref("");
  const drawerOpen = ref(false);
  const activeId = ref(null);
  const detail = ref(null);
  const detailError = ref("");
  const statusDraft = ref("");
  const statusSaving = ref(false);
  const commentDraft = ref("");
  const commentAsAidev = ref(false);
  const commentSaving = ref(false);
  const tagSaving = ref(false);
  const createModalOpen = ref(false);
  const createSaving = ref(false);
  const createError = ref("");
  const {
    execLines,
    execRunning,
    execText,
    resetExecute,
    startExecute,
    stopExecute,
    clearExecLines
  } = useTaskExecute((msg) => {
    detailError.value = msg;
  });
  let pollTimer = null;
  const columns = computed(
    () => {
      var _a, _b, _c, _d;
      return buildBoardColumns(
        (_b = (_a = data.value) == null ? void 0 : _a.tasks) != null ? _b : [],
        (_d = (_c = data.value) == null ? void 0 : _c.filters) != null ? _d : DEFAULT_TASK_FILTERS,
        Boolean(data.value)
      );
    }
  );
  const statusOptions = computed(() => {
    if (!data.value) return [];
    return buildStatusOptions(data.value.filters, providerStatuses.value);
  });
  const runningTaskId = computed(() => {
    var _a, _b;
    if (execRunning.value && detail.value) return detail.value.task.id;
    return (_b = (_a = data.value) == null ? void 0 : _a.activeTaskId) != null ? _b : null;
  });
  function syncPollTimer() {
    var _a;
    const shouldPoll = execRunning.value || Boolean((_a = data.value) == null ? void 0 : _a.activeTaskId);
    if (shouldPoll && !pollTimer) {
      pollTimer = setInterval();
    } else if (!shouldPoll && pollTimer) {
      clearInterval(pollTimer);
      pollTimer = null;
    }
  }
  async function fetchTasks(showSpinner = false) {
    if (showSpinner) loading.value = true;
    loadError.value = "";
    try {
      data.value = await api("/api/tasks");
    } catch (err) {
      loadError.value = err instanceof Error ? err.message : String(err);
    } finally {
      if (showSpinner) loading.value = false;
      syncPollTimer();
    }
  }
  async function reload() {
    return fetchTasks(true);
  }
  async function loadProviderStatuses() {
    if (providerStatuses.value.length > 0) return;
    try {
      const res = await api("/api/tasks/statuses");
      providerStatuses.value = res.statuses;
    } catch {
    }
  }
  async function openTask(task) {
    activeId.value = task.id;
    drawerOpen.value = true;
    detail.value = { task: { ...task, description: "" }, comments: [] };
    detailError.value = "";
    statusDraft.value = task.status;
    commentDraft.value = "";
    commentAsAidev.value = false;
    resetExecute();
    void loadProviderStatuses();
    try {
      detail.value = await api(`/api/tasks/${encodeURIComponent(task.id)}`);
      statusDraft.value = detail.value.task.status;
    } catch (err) {
      detailError.value = err instanceof Error ? err.message : String(err);
    }
  }
  function closeDrawer() {
    drawerOpen.value = false;
    activeId.value = null;
    resetExecute();
  }
  async function changeStatus() {
    var _a;
    if (!detail.value || !statusDraft.value) return;
    statusSaving.value = true;
    detailError.value = "";
    try {
      await api(`/api/tasks/${encodeURIComponent(detail.value.task.id)}/status`, {
        method: "POST",
        body: { status: statusDraft.value }
      });
      detail.value.task.status = statusDraft.value;
      const board = (_a = data.value) == null ? void 0 : _a.tasks.find((t) => t.id === detail.value.task.id);
      if (board) board.status = statusDraft.value;
    } catch (err) {
      detailError.value = err instanceof Error ? err.message : String(err);
    } finally {
      statusSaving.value = false;
    }
  }
  async function postComment() {
    if (!detail.value || !commentDraft.value.trim()) return;
    commentSaving.value = true;
    detailError.value = "";
    try {
      await api(`/api/tasks/${encodeURIComponent(detail.value.task.id)}/comment`, {
        method: "POST",
        body: { text: commentDraft.value, asAidev: commentAsAidev.value }
      });
      detail.value = await api(
        `/api/tasks/${encodeURIComponent(detail.value.task.id)}`
      );
      commentDraft.value = "";
    } catch (err) {
      detailError.value = err instanceof Error ? err.message : String(err);
    } finally {
      commentSaving.value = false;
    }
  }
  const suggestedTags = computed(() => {
    var _a, _b;
    return (_b = (_a = data.value) == null ? void 0 : _a.suggestedTags) != null ? _b : [];
  });
  async function saveTags(addTags, removeTags) {
    var _a;
    if (!detail.value) return;
    if (addTags.length === 0 && removeTags.length === 0) return;
    tagSaving.value = true;
    detailError.value = "";
    try {
      await api(`/api/tasks/${encodeURIComponent(detail.value.task.id)}`, {
        method: "PATCH",
        body: { addTags, removeTags }
      });
      const t = detail.value.task;
      const next = new Set(t.tags);
      for (const tag of removeTags) next.delete(tag);
      for (const tag of addTags) next.add(tag);
      t.tags = [...next];
      const board = (_a = data.value) == null ? void 0 : _a.tasks.find((b) => b.id === t.id);
      if (board) board.tags = t.tags;
    } catch (err) {
      detailError.value = err instanceof Error ? err.message : String(err);
    } finally {
      tagSaving.value = false;
    }
  }
  function openCreateModal() {
    createModalOpen.value = true;
    createError.value = "";
  }
  function closeCreateModal() {
    createModalOpen.value = false;
    createError.value = "";
  }
  async function createTask(params) {
    createSaving.value = true;
    createError.value = "";
    try {
      await api("/api/tasks", { method: "POST", body: params });
      createModalOpen.value = false;
      await fetchTasks(false);
    } catch (err) {
      createError.value = err instanceof Error ? err.message : String(err);
    } finally {
      createSaving.value = false;
    }
  }
  function runExecute() {
    if (!detail.value) return;
    void startExecute(detail.value.task.id);
  }
  watch(drawerOpen, (open) => {
    if (!open) {
      activeId.value = null;
      resetExecute();
    }
  });
  watch([execRunning, () => {
    var _a;
    return (_a = data.value) == null ? void 0 : _a.activeTaskId;
  }], syncPollTimer);
  return {
    data,
    loading,
    loadError,
    columns,
    runningTaskId,
    reload,
    drawerOpen,
    activeId,
    detail,
    detailError,
    openTask,
    closeDrawer,
    statusDraft,
    statusSaving,
    statusOptions,
    changeStatus,
    commentDraft,
    commentAsAidev,
    commentSaving,
    postComment,
    cwd,
    execLines,
    execRunning,
    execText,
    runExecute,
    stopExecute,
    clearExecLines,
    suggestedTags,
    tagSaving,
    saveTags,
    createModalOpen,
    createSaving,
    createError,
    openCreateModal,
    closeCreateModal,
    createTask
  };
}
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "tasks",
  __ssrInlineRender: true,
  setup(__props) {
    const {
      data,
      loading,
      loadError,
      columns,
      runningTaskId,
      reload,
      drawerOpen,
      activeId,
      detail,
      detailError,
      openTask,
      closeDrawer,
      statusDraft,
      statusSaving,
      statusOptions,
      changeStatus,
      commentDraft,
      commentAsAidev,
      commentSaving,
      postComment,
      cwd,
      execLines,
      execRunning,
      execText,
      runExecute,
      stopExecute,
      clearExecLines,
      suggestedTags,
      tagSaving,
      saveTags,
      createModalOpen,
      createSaving,
      createError,
      openCreateModal,
      closeCreateModal,
      createTask
    } = useTasksPage();
    return (_ctx, _push, _parent, _attrs) => {
      var _a;
      const _component_UCard = __nuxt_component_0$2;
      const _component_UButton = __nuxt_component_1;
      const _component_UAlert = __nuxt_component_2;
      const _component_NuxtLink = __nuxt_component_0$3;
      const _component_TasksBoard = __nuxt_component_4$1;
      const _component_TasksTaskCreateModal = __nuxt_component_5;
      const _component_TasksTaskDetailModal = __nuxt_component_6;
      _push(`<div${ssrRenderAttrs(mergeProps({ class: "tasks-page" }, _attrs))} data-v-c666eefa>`);
      _push(ssrRenderComponent(_component_UCard, null, {
        header: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(`<div class="flex items-center justify-between gap-3 flex-wrap" data-v-c666eefa${_scopeId}><div data-v-c666eefa${_scopeId}><h1 class="text-lg font-semibold" data-v-c666eefa${_scopeId}>Tasks</h1><p class="text-xs text-gray-500 mt-1" data-v-c666eefa${_scopeId}>`);
            if (unref(data)) {
              _push2(`<span data-v-c666eefa${_scopeId}> Provider: <code data-v-c666eefa${_scopeId}>${ssrInterpolate(unref(data).provider)}</code> \xB7 ${ssrInterpolate(unref(data).tasks.length)} task(s) </span>`);
            } else {
              _push2(`<span data-v-c666eefa${_scopeId}>\u2014</span>`);
            }
            _push2(`</p></div><div class="flex items-center gap-2" data-v-c666eefa${_scopeId}>`);
            _push2(ssrRenderComponent(_component_UButton, {
              color: "primary",
              size: "sm",
              disabled: !unref(data),
              onClick: unref(openCreateModal)
            }, {
              default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(` New Task `);
                } else {
                  return [
                    createTextVNode(" New Task ")
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
            _push2(ssrRenderComponent(_component_UButton, {
              color: "gray",
              variant: "ghost",
              size: "sm",
              loading: unref(loading),
              disabled: unref(loading),
              onClick: unref(reload)
            }, {
              default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(` Refresh `);
                } else {
                  return [
                    createTextVNode(" Refresh ")
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
            _push2(`</div></div>`);
          } else {
            return [
              createVNode("div", { class: "flex items-center justify-between gap-3 flex-wrap" }, [
                createVNode("div", null, [
                  createVNode("h1", { class: "text-lg font-semibold" }, "Tasks"),
                  createVNode("p", { class: "text-xs text-gray-500 mt-1" }, [
                    unref(data) ? (openBlock(), createBlock("span", { key: 0 }, [
                      createTextVNode(" Provider: "),
                      createVNode("code", null, toDisplayString(unref(data).provider), 1),
                      createTextVNode(" \xB7 " + toDisplayString(unref(data).tasks.length) + " task(s) ", 1)
                    ])) : (openBlock(), createBlock("span", { key: 1 }, "\u2014"))
                  ])
                ]),
                createVNode("div", { class: "flex items-center gap-2" }, [
                  createVNode(_component_UButton, {
                    color: "primary",
                    size: "sm",
                    disabled: !unref(data),
                    onClick: unref(openCreateModal)
                  }, {
                    default: withCtx(() => [
                      createTextVNode(" New Task ")
                    ]),
                    _: 1
                  }, 8, ["disabled", "onClick"]),
                  createVNode(_component_UButton, {
                    color: "gray",
                    variant: "ghost",
                    size: "sm",
                    loading: unref(loading),
                    disabled: unref(loading),
                    onClick: unref(reload)
                  }, {
                    default: withCtx(() => [
                      createTextVNode(" Refresh ")
                    ]),
                    _: 1
                  }, 8, ["loading", "disabled", "onClick"])
                ])
              ])
            ];
          }
        }),
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            if (unref(loadError)) {
              _push2(ssrRenderComponent(_component_UAlert, {
                color: "red",
                variant: "soft",
                title: unref(loadError),
                class: "mb-3"
              }, null, _parent2, _scopeId));
            } else {
              _push2(`<!---->`);
            }
            if (unref(data) && unref(data).tasks.length === 0 && !unref(loading)) {
              _push2(`<p class="empty-banner" data-v-c666eefa${_scopeId}> No tasks \u2014 check `);
              _push2(ssrRenderComponent(_component_NuxtLink, {
                to: "/config",
                class: "link"
              }, {
                default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                  if (_push3) {
                    _push3(`Config`);
                  } else {
                    return [
                      createTextVNode("Config")
                    ];
                  }
                }),
                _: 1
              }, _parent2, _scopeId));
              _push2(` for provider keys, list ids, and tag filter. </p>`);
            } else {
              _push2(`<!---->`);
            }
            if (!unref(loadError)) {
              _push2(ssrRenderComponent(_component_TasksBoard, {
                columns: unref(columns),
                loading: unref(loading),
                loaded: Boolean(unref(data)),
                "active-id": unref(activeId),
                "running-task-id": unref(runningTaskId),
                onSelect: unref(openTask)
              }, null, _parent2, _scopeId));
            } else {
              _push2(`<!---->`);
            }
          } else {
            return [
              unref(loadError) ? (openBlock(), createBlock(_component_UAlert, {
                key: 0,
                color: "red",
                variant: "soft",
                title: unref(loadError),
                class: "mb-3"
              }, null, 8, ["title"])) : createCommentVNode("", true),
              unref(data) && unref(data).tasks.length === 0 && !unref(loading) ? (openBlock(), createBlock("p", {
                key: 1,
                class: "empty-banner"
              }, [
                createTextVNode(" No tasks \u2014 check "),
                createVNode(_component_NuxtLink, {
                  to: "/config",
                  class: "link"
                }, {
                  default: withCtx(() => [
                    createTextVNode("Config")
                  ]),
                  _: 1
                }),
                createTextVNode(" for provider keys, list ids, and tag filter. ")
              ])) : createCommentVNode("", true),
              !unref(loadError) ? (openBlock(), createBlock(_component_TasksBoard, {
                key: 2,
                columns: unref(columns),
                loading: unref(loading),
                loaded: Boolean(unref(data)),
                "active-id": unref(activeId),
                "running-task-id": unref(runningTaskId),
                onSelect: unref(openTask)
              }, null, 8, ["columns", "loading", "loaded", "active-id", "running-task-id", "onSelect"])) : createCommentVNode("", true)
            ];
          }
        }),
        _: 1
      }, _parent));
      _push(ssrRenderComponent(_component_TasksTaskCreateModal, {
        open: unref(createModalOpen),
        saving: unref(createSaving),
        error: unref(createError),
        "suggested-tags": unref(suggestedTags),
        "onUpdate:open": ($event) => createModalOpen.value = $event,
        onClose: unref(closeCreateModal),
        onSubmit: unref(createTask)
      }, null, _parent));
      _push(ssrRenderComponent(_component_TasksTaskDetailModal, {
        open: unref(drawerOpen),
        detail: unref(detail),
        "provider-name": ((_a = unref(data)) == null ? void 0 : _a.provider) || "provider",
        error: unref(detailError),
        "status-draft": unref(statusDraft),
        "status-saving": unref(statusSaving),
        "status-options": unref(statusOptions),
        "comment-draft": unref(commentDraft),
        "comment-as-aidev": unref(commentAsAidev),
        "comment-saving": unref(commentSaving),
        cwd: unref(cwd),
        "exec-running": unref(execRunning),
        "exec-lines": unref(execLines),
        "exec-text": unref(execText),
        "suggested-tags": unref(suggestedTags),
        "tag-saving": unref(tagSaving),
        "onUpdate:open": ($event) => drawerOpen.value = $event,
        onClose: unref(closeDrawer),
        "onUpdate:statusDraft": ($event) => statusDraft.value = $event,
        onChangeStatus: unref(changeStatus),
        "onUpdate:commentDraft": ($event) => commentDraft.value = $event,
        "onUpdate:commentAsAidev": ($event) => commentAsAidev.value = $event,
        onPostComment: unref(postComment),
        onRun: unref(runExecute),
        onStop: unref(stopExecute),
        onClearExec: unref(clearExecLines),
        onSaveTags: unref(saveTags)
      }, null, _parent));
      _push(`</div>`);
    };
  }
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/tasks.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const tasks = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c666eefa"]]);

export { tasks as default };
//# sourceMappingURL=tasks-Bc5VRFpY.mjs.map
