var to=Object.defineProperty;var po=(o)=>o;function mo(o,r){this[o]=po.bind(null,r)}var so=(o,r)=>{for(var d in r)to(o,d,{get:r[d],enumerable:!0,configurable:!0,set:mo.bind(r,d)})};var or=(o,r)=>()=>(o&&(r=o(o=0)),r);import{gql as bo}from"@apollo/client";import{useQuery as uo}from"@apollo/client/react";import{useTemplateRuntime as eo}from"@contractspec/lib.example-shared-ui";import{MessageCircle as fo,Users as No}from"lucide-react";import{useMemo as yo}from"react";import{jsx as P,jsxs as B}from"react/jsx-runtime";var ho=bo`
  query Conversations($projectId: ID!) {
    conversations(projectId: $projectId) {
      id
      name
      isGroup
      updatedAt
      participants {
        id
        userId
        displayName
      }
    }
  }
`;function q({selectedId:o,onSelect:r}){let{projectId:d}=eo(),{data:t,loading:l}=uo(ho,{variables:{projectId:d},fetchPolicy:"cache-and-network"}),u=yo(()=>t?.conversations??[],[t]);return B("aside",{className:"h-full overflow-y-auto rounded-2xl border border-border bg-card",children:[B("header",{className:"px -4 flex items-center justify-between border-border border-b px-4 py-3",children:[B("div",{children:[P("p",{className:"font-semibold text-sm",children:"Conversations"}),P("p",{className:"text-muted-foreground text-xs",children:l?"Loading…":`${u.length} active`})]}),P(No,{className:"h-4 w-4 text-muted-foreground"})]}),B("div",{className:"divide-y divide-border/70",children:[u.map((e)=>{let y=o===e.id;return B("button",{type:"button",className:`flex w-full flex-col items-start gap-1 px-4 py-3 text-left transition ${y?"bg-violet-500/10 text-foreground":"hover:bg-muted/40"}`,onClick:()=>r?.(e.id),children:[B("div",{className:"flex items-center gap-2",children:[P(fo,{className:"h-4 w-4 text-muted-foreground"}),P("span",{className:"font-medium text-sm",children:e.name||"Untitled conversation"})]}),P("p",{className:"text-muted-foreground text-xs",children:e.participants.map((N)=>N.displayName||N.userId).join(" · ")})]},e.id)}),!l&&u.length===0?P("p",{className:"p-4 text-center text-muted-foreground text-xs",children:"No conversations yet."}):null]})]})}import{gql as _}from"@apollo/client";import{useMutation as ao,useQuery as io}from"@apollo/client/react";import{useTemplateRuntime as no}from"@contractspec/lib.example-shared-ui";import{useEffect as v,useRef as go}from"react";import{jsx as F,jsxs as Q}from"react/jsx-runtime";var Z=_`
  query Messages($conversationId: ID!) {
    messages(conversationId: $conversationId, limit: 50) {
      id
      content
      senderId
      senderName
      createdAt
      status
    }
  }
`,wo=_`
  mutation SetMessagesRead($conversationId: ID!, $userId: String!) {
    setMessagesRead(conversationId: $conversationId, userId: $userId)
  }
`;function G({conversationId:o,viewerId:r="local-user"}){let d=go(null),t=Boolean(o),{data:l,loading:u}=io(Z,{variables:{conversationId:o},skip:!t,fetchPolicy:"cache-and-network"}),[e]=ao(wo),{projectId:y}=no(),N=l?.messages??[];if(v(()=>{if(!t||!o)return;e({variables:{conversationId:o,userId:r}}).catch(()=>{})},[o,t,e,r]),v(()=>{let p=d.current;if(!p)return;p.scrollTop=p.scrollHeight},[N]),!o)return F("div",{className:"flex flex-1 items-center justify-center rounded-2xl border border-border border-dashed",children:F("p",{className:"text-muted-foreground text-sm",children:"Select a conversation"})});return F("div",{className:"flex flex-1 flex-col rounded-2xl border border-border bg-card",children:F("div",{ref:d,className:"flex-1 space-y-3 overflow-y-auto p-4",children:u?F("p",{className:"text-center text-muted-foreground text-sm",children:"Loading…"}):N.slice().reverse().map((p)=>Q("div",{className:`flex flex-col ${p.senderId===r?"items-end":"items-start"}`,children:[F("div",{className:`max-w-xs rounded-2xl px-3 py-2 text-sm ${p.senderId===r?"bg-violet-500 text-white":"bg-muted text-foreground"}`,children:F("p",{children:p.content})}),Q("span",{className:"mt-1 text-muted-foreground text-xs",children:[p.senderName||p.senderId," ·"," ",new Date(p.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]},p.id))})})}import{gql as Po}from"@apollo/client";import{useMutation as Fo}from"@apollo/client/react";import{useTemplateRuntime as Ho}from"@contractspec/lib.example-shared-ui";import{Send as $o}from"lucide-react";import{useState as Co}from"react";import{jsx as R,jsxs as M}from"react/jsx-runtime";var Bo=Po`
  mutation SendMessage($input: SendMessageInput!) {
    sendMessage(input: $input) {
      id
    }
  }
`;function O({conversationId:o,viewerId:r="local-user",viewerName:d="You"}){let{projectId:t}=Ho(),[l,u]=Co(""),[e,{loading:y}]=Fo(Bo);return M("form",{onSubmit:async(p)=>{if(p.preventDefault(),!o||!l.trim())return;await e({variables:{input:{projectId:t,conversationId:o,senderId:r,senderName:d,content:l.trim()}},refetchQueries:[{query:Z,variables:{conversationId:o}}]}),u("")},className:"mt-3 flex items-center gap-2 rounded-2xl border border-border bg-card px-4 py-3",children:[R("input",{type:"text",className:"flex-1 bg-transparent text-foreground text-sm outline-none",placeholder:o?"Type a message…":"Select a conversation to start",disabled:!o||y,value:l,onChange:(p)=>u(p.target.value)}),M("button",{type:"submit",className:"btn-primary inline-flex items-center gap-1 text-sm",disabled:!o||y||!l.trim(),children:[R($o,{className:"h-4 w-4"}),"Send"]})]})}import{registerTemplateComponents as Do}from"@contractspec/lib.example-shared-ui";import{useState as Wo}from"react";import{jsx as U,jsxs as x}from"react/jsx-runtime";function zo(){let[o,r]=Wo();return x("div",{className:"grid gap-4 md:grid-cols-[280px,1fr]",children:[U(q,{selectedId:o,onSelect:r}),x("div",{className:"flex flex-col gap-3",children:[U(G,{conversationId:o}),U(O,{conversationId:o})]})]})}Do("messaging-app",{list:zo,detail:G,form:O});import{jsx as T}from"react/jsx-runtime";function k({locale:o,onChange:r}){return T("div",{className:"inline-flex rounded-full border border-border bg-card p-1 font-semibold text-muted-foreground text-xs",children:["EN","FR"].map((d)=>T("button",{type:"button",className:`rounded-full px-3 py-1 transition ${o===d?"bg-violet-500 text-white":"hover:text-foreground"}`,onClick:()=>r(d),children:d==="EN"?"English":"Français"},d))})}import{Heart as Jo}from"lucide-react";import{jsx as D,jsxs as H}from"react/jsx-runtime";function E({recipe:o,onSelect:r,onToggleFavorite:d}){return H("button",{type:"button",onClick:()=>r?.(o),className:"flex flex-col gap-3 rounded-2xl border border-border bg-card text-left transition hover:border-violet-400",children:[o.heroImageUrl?D("img",{src:o.heroImageUrl,alt:o.name,className:"h-40 w-full rounded-t-2xl object-cover"}):D("div",{className:"h-40 rounded-t-2xl bg-muted"}),H("div",{className:"space-y-2 p-4",children:[H("div",{className:"flex items-center justify-between",children:[D("p",{className:"font-semibold text-base",children:o.name}),D("button",{type:"button",className:`inline-flex items-center justify-center rounded-full border border-transparent p-2 ${o.isFavorite?"text-red-400":"text-muted-foreground hover:text-red-400"}`,onClick:(t)=>{t.stopPropagation(),d?.(o)},children:D(Jo,{className:`h-4 w-4 ${o.isFavorite?"fill-red-400":""}`})})]}),D("p",{className:"line-clamp-2 text-muted-foreground text-sm",children:o.description}),H("div",{className:"flex flex-wrap gap-3 text-muted-foreground text-xs",children:[o.prepTimeMinutes?H("span",{children:["Prep ",o.prepTimeMinutes,"m"]}):null,o.cookTimeMinutes?H("span",{children:["Cook ",o.cookTimeMinutes,"m"]}):null,o.servings?H("span",{children:[o.servings," servings"]}):null]})]})]})}import{BookOpen as Vo}from"lucide-react";import{jsx as i,jsxs as W}from"react/jsx-runtime";function K({recipe:o}){if(!o)return i("div",{className:"flex flex-1 items-center justify-center rounded-2xl border border-border border-dashed",children:i("p",{className:"text-muted-foreground text-sm",children:"Select a recipe to view details."})});return W("article",{className:"space-y-4 rounded-2xl border border-border bg-card p-6",children:[W("header",{className:"flex flex-wrap items-center gap-3",children:[i(Vo,{className:"h-5 w-5 text-muted-foreground"}),W("div",{children:[i("h2",{className:"font-semibold text-xl",children:o.name}),i("p",{className:"text-muted-foreground text-sm",children:o.description})]})]}),W("section",{children:[i("h3",{className:"font-semibold text-muted-foreground text-sm uppercase tracking-wide",children:"Ingredients"}),i("ul",{className:"mt-2 list-disc space-y-1 pl-6 text-foreground text-sm",children:o.ingredients.map((r)=>W("li",{children:[r.name," – ",r.quantity]},r.id))})]}),W("section",{children:[i("h3",{className:"font-semibold text-muted-foreground text-sm uppercase tracking-wide",children:"Instructions"}),i("ol",{className:"mt-2 list-decimal space-y-2 pl-6 text-foreground text-sm",children:o.instructions.map((r)=>i("li",{children:r.content},r.id))})]})]})}import{gql as I}from"@apollo/client";import{useMutation as Xo,useQuery as Zo}from"@apollo/client/react";import{registerTemplateComponents as Go,useTemplateRuntime as Oo}from"@contractspec/lib.example-shared-ui";import{useState as L}from"react";import{jsx as z,jsxs as S}from"react/jsx-runtime";var Uo=I`
  query Recipes($projectId: ID!, $locale: RecipeLocale!) {
    recipes(projectId: $projectId, locale: $locale) {
      id
      name
      description
      heroImageUrl
      prepTimeMinutes
      cookTimeMinutes
      servings
      isFavorite
      locale
      category {
        id
        nameEn
        nameFr
      }
      ingredients {
        id
        name
        quantity
      }
      instructions {
        id
        content
        ordering
      }
    }
  }
`,Ko=I`
  mutation FavoriteRecipe($id: ID!, $isFavorite: Boolean!) {
    favoriteRecipe(id: $id, isFavorite: $isFavorite) {
      id
      isFavorite
    }
  }
`;function Lo(){let{projectId:o}=Oo(),[r,d]=L("EN"),[t,l]=L(),[u,e]=L(""),{data:y,loading:N}=Zo(Uo,{variables:{projectId:o,locale:r},fetchPolicy:"cache-and-network"}),[p]=Xo(Ko),C=(y?.recipes??[]).filter((f)=>f.name.toLowerCase().includes(u.toLowerCase())),m=async(f)=>{await p({variables:{id:f.id,isFavorite:!f.isFavorite},optimisticResponse:{favoriteRecipe:{__typename:"Recipe",id:f.id,isFavorite:!f.isFavorite}}})};return S("div",{className:"space-y-4",children:[S("div",{className:"flex flex-wrap items-center gap-3",children:[z(k,{locale:r,onChange:d}),z("input",{type:"search",placeholder:r==="EN"?"Search recipes":"Rechercher des recettes",className:"flex-1 rounded-full border border-border bg-card px-4 py-2 text-sm",value:u,onChange:(f)=>e(f.target.value)})]}),N?z("p",{className:"text-muted-foreground text-sm",children:"Loading recipes…"}):z("div",{className:"grid gap-4 md:grid-cols-3",children:C.map((f)=>z(E,{recipe:f,onSelect:l,onToggleFavorite:m},f.id))}),z(K,{recipe:t})]})}Go("recipe-app-i18n",{list:Lo,detail:K});import{jsx as a,jsxs as w}from"react/jsx-runtime";function j({value:o,onChange:r,categories:d}){let t=(l,u)=>{r({...o,[l]:u})};return w("div",{className:"grid gap-3 rounded-2xl border border-border bg-card p-4 md:grid-cols-4",children:[w("label",{className:"flex flex-col text-muted-foreground text-xs uppercase tracking-wide",children:["Status",w("select",{className:"mt-1 rounded-md border border-border bg-background px-3 py-2 text-foreground text-sm",value:o.status,onChange:(l)=>t("status",l.target.value),children:[a("option",{value:"all",children:"All tasks"}),a("option",{value:"active",children:"Active"}),a("option",{value:"completed",children:"Completed"})]})]}),w("label",{className:"flex flex-col text-muted-foreground text-xs uppercase tracking-wide",children:["Priority",w("select",{className:"mt-1 rounded-md border border-border bg-background px-3 py-2 text-foreground text-sm",value:o.priority,onChange:(l)=>t("priority",l.target.value),children:[a("option",{value:"all",children:"All"}),a("option",{value:"LOW",children:"Low"}),a("option",{value:"MEDIUM",children:"Medium"}),a("option",{value:"HIGH",children:"High"}),a("option",{value:"URGENT",children:"Urgent"})]})]}),w("label",{className:"flex flex-col text-muted-foreground text-xs uppercase tracking-wide",children:["Category",w("select",{className:"mt-1 rounded-md border border-border bg-background px-3 py-2 text-foreground text-sm",value:o.categoryId,onChange:(l)=>t("categoryId",l.target.value),children:[a("option",{value:"all",children:"All categories"}),d.map((l)=>a("option",{value:l.id,children:l.name},l.id))]})]}),w("label",{className:"flex flex-col text-muted-foreground text-xs uppercase tracking-wide",children:["Search",a("input",{type:"search",className:"mt-1 rounded-md border border-border bg-background px-3 py-2 text-foreground text-sm",placeholder:"Search by title",value:o.search,onChange:(l)=>t("search",l.target.value)})]})]})}import{gql as Yo}from"@apollo/client";import{useMutation as Ao}from"@apollo/client/react";import{useTemplateRuntime as co}from"@contractspec/lib.example-shared-ui";import{useState as V}from"react";import{jsx as h,jsxs as g}from"react/jsx-runtime";var qo=Yo`
  mutation CreateTask($input: CreateTaskInput!) {
    createTask(input: $input) {
      id
      title
    }
  }
`;function Y({categories:o}){let{projectId:r}=co(),[d,t]=V(""),[l,u]=V(""),[e,y]=V("MEDIUM"),[N,p]=V("none"),[J,C]=V(""),[m,{loading:f}]=Ao(qo);return g("form",{onSubmit:async(b)=>{if(b.preventDefault(),!d.trim())return;await m({variables:{input:{projectId:r,title:d.trim(),description:l.trim()||void 0,priority:e,categoryId:N==="none"?void 0:N,tags:vo(J)}},refetchQueries:["Tasks"],awaitRefetchQueries:!0}),t(""),u(""),y("MEDIUM"),p("none"),C("")},className:"space-y-3 rounded-2xl border border-border bg-background/60 p-4",children:[h("div",{children:g("label",{className:"font-semibold text-muted-foreground text-xs uppercase",children:["Title",h("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:d,onChange:(b)=>t(b.target.value),required:!0})]})}),h("div",{children:g("label",{className:"font-semibold text-muted-foreground text-xs uppercase",children:["Description",h("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:l,onChange:(b)=>u(b.target.value)})]})}),g("div",{className:"grid gap-3 md:grid-cols-3",children:[g("label",{className:"font-semibold text-muted-foreground text-xs uppercase",children:["Priority",g("select",{className:"mt-1 w-full rounded-md border border-border bg-card px-3 py-2 text-sm",value:e,onChange:(b)=>y(b.target.value),children:[h("option",{value:"LOW",children:"Low"}),h("option",{value:"MEDIUM",children:"Medium"}),h("option",{value:"HIGH",children:"High"}),h("option",{value:"URGENT",children:"Urgent"})]})]}),g("label",{className:"font-semibold text-muted-foreground text-xs uppercase",children:["Category",g("select",{className:"mt-1 w-full rounded-md border border-border bg-card px-3 py-2 text-sm",value:N,onChange:(b)=>p(b.target.value),children:[h("option",{value:"none",children:"None"}),o.map((b)=>h("option",{value:b.id,children:b.name},b.id))]})]}),g("label",{className:"font-semibold text-muted-foreground text-xs uppercase",children:["Tags",h("input",{className:"mt-1 w-full rounded-md border border-border bg-card px-3 py-2 text-sm",placeholder:"Comma separated (optional)",value:J,onChange:(b)=>C(b.target.value)})]})]}),h("button",{type:"submit",className:"btn-primary w-full py-2 font-semibold text-sm",disabled:f,children:f?"Saving...":"Add task"})]})}function vo(o){return o.split(",").map((r)=>r.trim()).filter(Boolean)}import{Check as Qo,Circle as _o,Trash2 as Ro}from"lucide-react";import{jsx as n,jsxs as X}from"react/jsx-runtime";function s({task:o,onToggle:r,onDelete:d}){let t=o.priority==="URGENT"?"text-red-200 bg-red-500/10 border-red-500/40":o.priority==="HIGH"?"text-amber-200 bg-amber-500/10 border-amber-500/40":o.priority==="LOW"?"text-emerald-200 bg-emerald-500/10 border-emerald-500/40":"text-violet-200 bg-violet-500/10 border-violet-500/40";return X("div",{className:"flex items-start gap-4 rounded-2xl border border-border/70 bg-card/60 p-4 transition hover:border-border",children:[n("button",{type:"button",className:"rounded-full border border-border p-2 text-muted-foreground hover:bg-muted/40","aria-pressed":o.completed,onClick:()=>r?.(o),children:o.completed?n(Qo,{className:"h-4 w-4 text-emerald-400"}):n(_o,{className:"h-4 w-4"})}),X("div",{className:"flex-1 space-y-2",children:[X("div",{className:"flex flex-wrap items-center gap-2",children:[n("p",{className:`font-medium ${o.completed?"text-muted-foreground line-through":"text-foreground"}`,children:o.title}),n("span",{className:`rounded-full border px-2 py-0.5 text-xs ${t}`,children:o.priority.charAt(0)+o.priority.slice(1).toLowerCase()}),o.category?n("span",{className:"rounded-full bg-muted/40 px-2 py-0.5 text-muted-foreground text-xs",children:o.category.name}):null,o.dueDate?X("span",{className:"text-muted-foreground text-xs",children:["Due ",new Date(o.dueDate).toLocaleDateString()]}):null]}),o.description?n("p",{className:"text-muted-foreground text-sm",children:o.description}):null,o.tags.length?n("div",{className:"flex flex-wrap gap-1",children:o.tags.map((l)=>X("span",{className:"rounded-full bg-muted/40 px-2 py-0.5 text-muted-foreground text-xs",children:["#",l]},l))}):null]}),n("button",{type:"button",className:"text-muted-foreground hover:text-destructive","aria-label":`Delete ${o.title}`,onClick:()=>d?.(o),children:n(Ro,{className:"h-4 w-4"})})]})}import{gql as A}from"@apollo/client";import{useMutation as oo,useQuery as Mo}from"@apollo/client/react";import{registerTemplateComponents as xo,useTemplateRuntime as To}from"@contractspec/lib.example-shared-ui";import{useMemo as ko,useState as Eo}from"react";import{jsx as $,jsxs as jo}from"react/jsx-runtime";var ro=A`
  query Tasks($projectId: ID!) {
    taskCategories(projectId: $projectId) {
      id
      name
      color
    }
    tasks(projectId: $projectId) {
      id
      title
      description
      completed
      priority
      dueDate
      tags
      category {
        id
        name
        color
      }
    }
  }
`,So=A`
  mutation ToggleTask($id: ID!, $completed: Boolean!) {
    toggleTask(id: $id, completed: $completed) {
      id
      completed
    }
  }
`,Io=A`
  mutation DeleteTask($id: ID!) {
    deleteTask(id: $id)
  }
`;function lo(){let{projectId:o}=To(),[r,d]=Eo({status:"all",priority:"all",categoryId:"all",search:""}),{data:t,loading:l}=Mo(ro,{variables:{projectId:o},fetchPolicy:"cache-and-network"}),[u]=oo(So),[e]=oo(Io),y=t?.taskCategories??[],N=t?.tasks??[],p=ko(()=>{return N.filter((m)=>{if(r.status==="active"&&m.completed)return!1;if(r.status==="completed"&&!m.completed)return!1;if(r.priority!=="all"&&m.priority!==r.priority)return!1;if(r.categoryId!=="all"&&m.category?.id!==r.categoryId)return!1;if(r.search&&!m.title.toLowerCase().includes(r.search.toLowerCase()))return!1;return!0})},[N,r]),J=async(m)=>{await u({variables:{id:m.id,completed:!m.completed},optimisticResponse:{toggleTask:{__typename:"Task",id:m.id,completed:!m.completed}},update(f){f.modify({fields:{tasks(c=[]){return c.map((b)=>b.__ref?.endsWith(m.id)?{...b,completed:!m.completed}:b)}}})}})},C=async(m)=>{await e({variables:{id:m.id},refetchQueries:[{query:ro,variables:{projectId:o}}]})};return jo("div",{className:"space-y-6",children:[$(j,{value:r,onChange:d,categories:y}),$(Y,{categories:y}),l?$("p",{className:"text-muted-foreground text-sm",children:"Loading tasks…"}):p.length?$("div",{className:"space-y-3",children:p.map((m)=>$(s,{task:m,onToggle:J,onDelete:C},m.id))}):$("div",{className:"rounded-2xl border border-border border-dashed p-8 text-center",children:$("p",{className:"text-muted-foreground",children:"No tasks match your filters. Create one above."})})]})}xo("todos-app",{list:lo,detail:lo,form:Y});export{lo as TaskList,s as TaskItem,Y as TaskForm,Lo as RecipeList,K as RecipeDetail,E as RecipeCard,zo as MessagingWorkspace,G as MessageThread,O as MessageComposer,Z as MESSAGES_QUERY,k as LanguageSwitcher,j as FilterBar,q as ConversationList};
