import{r as g,j as s,bm as f,T as w}from"./vendor-BKmmeuxg.js";import{I as v}from"./input-error-LaPr_4wd.js";import{B as m}from"./button-BpNwv2aE.js";import{I as h}from"./input-DM0goJrn.js";import{L as o}from"./label-HmIcv5Yx.js";import"./utils-DxSsnXxD.js";import"./index-WW_1X1qx.js";const E=({data:d,setData:n,errors:x})=>{var l;const i=((l=d.options)==null?void 0:l.matches)||[];g.useEffect(()=>{i.length===0&&n("options",{matches:[{id:1,question:"",answer:""},{id:2,question:"",answer:""},{id:3,question:"",answer:""}]})},[]);const p=()=>{const e=[...i,{id:Date.now(),question:"",answer:""}];n("options",{matches:e})},u=e=>{const t=i.filter(a=>a.id!==e);n("options",{matches:t})},c=(e,t,a)=>{const j=i.map(r=>r.id===e?{...r,[t]:a}:r);n("options",{matches:j})};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(o,{children:"Matching Pairs *"}),s.jsxs(m,{type:"button",variant:"outline",size:"sm",onClick:p,children:[s.jsx(f,{className:"h-4 w-4"}),"Add Pair"]})]}),s.jsx("p",{className:"text-sm text-gray-600",children:"Students will match items from the left column with items on the right"}),s.jsx("div",{className:"space-y-3",children:i.map((e,t)=>s.jsxs("div",{className:"grid grid-cols-2 gap-3 items-start",children:[s.jsxs("div",{children:[t===0&&s.jsx(o,{className:"text-xs text-gray-500 mb-1",children:"Question/Item"}),s.jsx(h,{placeholder:`Item ${t+1}`,value:e.question,onChange:a=>c(e.id,"question",a.target.value)})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"flex-1",children:[t===0&&s.jsx(o,{className:"text-xs text-gray-500 mb-1",children:"Correct Match"}),s.jsx(h,{placeholder:`Match ${t+1}`,value:e.answer,onChange:a=>c(e.id,"answer",a.target.value)})]}),i.length>2&&s.jsx(m,{type:"button",variant:"ghost",size:"sm",onClick:()=>u(e.id),className:"text-red-600 mt-5",children:s.jsx(w,{className:"h-4 w-4"})})]})]},e.id))}),s.jsx(v,{message:x.options})]})};export{E as default};