import{r as j,j as s,cO as g,ds as f,a$ as v}from"./react-vendor-xYZnmIII.js";import{I as w}from"./input-error-_LAmvivg.js";import{L as c,B as m,I}from"./ui-components-CQM92IK3.js";import"./inertia-vendor-cBbDTmhJ.js";import"./ui-vendor-Ds9iwIxa.js";import"./interactive-vendor-B1OgcAgP.js";const E=({data:h,setData:n,errors:p})=>{var l;const o=((l=h.options)==null?void 0:l.items)||[];j.useEffect(()=>{o.length===0&&n("options",{items:["","",""]})},[]);const d=()=>{const t=[...o,""];n("options",{items:t})},u=t=>{const e=o.filter((r,a)=>a!==t);n("options",{items:e})},x=(t,e)=>{const r=[...o];r[t]=e,n("options",{items:r})},i=(t,e)=>{if(e==="up"&&t===0||e==="down"&&t===o.length-1)return;const r=[...o],a=e==="up"?t-1:t+1;[r[t],r[a]]=[r[a],r[t]],n("options",{items:r})};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx(c,{children:"Instructions"}),s.jsxs("div",{className:"p-3 bg-blue-50 rounded-md text-sm text-blue-900",children:[s.jsx("p",{className:"font-medium mb-1",children:"How ordering questions work:"}),s.jsx("p",{children:"1. List the items in the correct order below"}),s.jsx("p",{children:"2. The system will shuffle them for students"}),s.jsx("p",{children:"3. Students must arrange them in the correct order"})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(c,{children:"Items (in correct order) *"}),s.jsxs(m,{type:"button",variant:"outline",size:"sm",onClick:d,children:[s.jsx(g,{className:"h-4 w-4"}),"Add Item"]})]}),o.map((t,e)=>s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(m,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(e,"up"),disabled:e===0,className:"h-5 w-8 p-0 text-gray-400 hover:text-gray-600",children:"▲"}),s.jsx(m,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(e,"down"),disabled:e===o.length-1,className:"h-5 w-8 p-0 text-gray-400 hover:text-gray-600",children:"▼"})]}),s.jsx(f,{className:"h-5 w-5 text-gray-400"}),s.jsxs("span",{className:"text-sm font-medium text-gray-500 w-8",children:[e+1,"."]}),s.jsx("div",{className:"flex-1",children:s.jsx(I,{placeholder:`Item ${e+1}`,value:t,onChange:r=>x(e,r.target.value)})}),o.length>2&&s.jsx(m,{type:"button",variant:"ghost",size:"sm",onClick:()=>u(e),className:"text-red-600",children:s.jsx(v,{className:"h-4 w-4"})})]},e))]}),s.jsx(w,{message:p.options})]})};export{E as default};
