// @bun
var $=Object.defineProperty;var b=(w)=>w;function h(w,z){this[w]=b.bind(null,z)}var D=(w,z)=>{for(var G in z)$(w,G,{get:z[G],enumerable:!0,configurable:!0,set:h.bind(z,G)})};var E=(w,z)=>()=>(w&&(z=w(w=0)),z);import{gql as k}from"@apollo/client";import{useMutation as q}from"@apollo/client/react";import{useTemplateRuntime as K}from"@contractspec/lib.example-shared-ui";import{useState as H}from"react";import{jsx as B,jsxs as F}from"react/jsx-runtime";var M=k`
  mutation CreateTask($input: CreateTaskInput!) {
    createTask(input: $input) {
      id
      title
    }
  }
`;function T({categories:w}){let{projectId:z}=K(),[G,L]=H(""),[N,O]=H(""),[Q,U]=H("MEDIUM"),[J,V]=H("none"),[W,X]=H(""),[Z,{loading:Y}]=q(M);return F("form",{onSubmit:async(f)=>{if(f.preventDefault(),!G.trim())return;await Z({variables:{input:{projectId:z,title:G.trim(),description:N.trim()||void 0,priority:Q,categoryId:J==="none"?void 0:J,tags:_(W)}},refetchQueries:["Tasks"],awaitRefetchQueries:!0}),L(""),O(""),U("MEDIUM"),V("none"),X("")},className:"space-y-3 rounded-2xl border border-border bg-background/60 p-4",children:[B("div",{children:F("label",{className:"font-semibold text-muted-foreground text-xs uppercase",children:["Title",B("input",{type:"text",className:"mt-1 w-full rounded-md border border-border bg-card px-3 py-2 text-sm",placeholder:"What needs to get done?",value:G,onChange:(f)=>L(f.target.value),required:!0})]})}),B("div",{children:F("label",{className:"font-semibold text-muted-foreground text-xs uppercase",children:["Description",B("textarea",{className:"mt-1 w-full rounded-md border border-border bg-card px-3 py-2 text-sm",rows:3,placeholder:"Add context or policy notes",value:N,onChange:(f)=>O(f.target.value)})]})}),F("div",{className:"grid gap-3 md:grid-cols-3",children:[F("label",{className:"font-semibold text-muted-foreground text-xs uppercase",children:["Priority",F("select",{className:"mt-1 w-full rounded-md border border-border bg-card px-3 py-2 text-sm",value:Q,onChange:(f)=>U(f.target.value),children:[B("option",{value:"LOW",children:"Low"}),B("option",{value:"MEDIUM",children:"Medium"}),B("option",{value:"HIGH",children:"High"}),B("option",{value:"URGENT",children:"Urgent"})]})]}),F("label",{className:"font-semibold text-muted-foreground text-xs uppercase",children:["Category",F("select",{className:"mt-1 w-full rounded-md border border-border bg-card px-3 py-2 text-sm",value:J,onChange:(f)=>V(f.target.value),children:[B("option",{value:"none",children:"None"}),w.map((f)=>B("option",{value:f.id,children:f.name},f.id))]})]}),F("label",{className:"font-semibold text-muted-foreground text-xs uppercase",children:["Tags",B("input",{className:"mt-1 w-full rounded-md border border-border bg-card px-3 py-2 text-sm",placeholder:"Comma separated (optional)",value:W,onChange:(f)=>X(f.target.value)})]})]}),B("button",{type:"submit",className:"btn-primary w-full py-2 font-semibold text-sm",disabled:Y,children:Y?"Saving...":"Add task"})]})}function _(w){return w.split(",").map((z)=>z.trim()).filter(Boolean)}export{T as TaskForm};
