(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,56909,e=>{"use strict";let a=(0,e.i(75254).default)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);e.s(["Save",()=>a],56909)},81204,e=>{"use strict";var a=e.i(43476),r=e.i(71645),t=e.i(7471),s=e.i(56909);function l(){let[e,l]=(0,r.useState)([]),[i,d]=(0,r.useState)(!0),[o,n]=(0,r.useState)(!1),[c,m]=(0,r.useState)("");(0,r.useEffect)(()=>{!async function(){let{data:e}=await t.supabase.from("carousel_slides").select("*").order("order"),a=e||[];l([0,1,2,3].map(e=>a[e]||{title:"",image_url:"",link:"/catalog",order:e+1})),d(!1)}()},[]);let u=async()=>{for(let a of(n(!0),e)){let e={title:a.title,image_url:a.image_url,link:a.link,order:a.order};a.id?await t.supabase.from("carousel_slides").update(e).eq("id",a.id):await t.supabase.from("carousel_slides").insert(e)}m("Carousel saved successfully!"),n(!1),setTimeout(()=>m(""),3e3)},x=(e,a,r)=>{l(t=>t.map((t,s)=>s===e?{...t,[a]:r}:t))};return(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"text-2xl font-bold text-gray-900 tracking-tight",children:"Hero Carousel"}),(0,a.jsx)("p",{className:"text-gray-500 text-sm mt-1",children:"Manage the 4 homepage hero slides"})]}),(0,a.jsx)("button",{onClick:u,disabled:o,className:"flex items-center justify-center gap-2 bg-brand-primary hover:bg-brand-primary/90 text-white font-semibold px-5 py-2.5 rounded-xl text-sm transition-all shadow-sm hover:shadow-md hover:scale-105 disabled:opacity-50 w-full sm:w-auto",children:o?(0,a.jsx)("div",{className:"w-5 h-5 border-2 border-white/30 border-t-white rounded-full animate-spin"}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.Save,{className:"w-5 h-5"})," Save Changes"]})})]}),c&&(0,a.jsxs)("div",{className:"bg-green-50 border border-green-200 rounded-xl px-5 py-4 text-green-700 font-medium text-sm flex items-center gap-2",children:[(0,a.jsx)("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),c]}),i?(0,a.jsx)("p",{className:"text-gray-500",children:"Loading carousel data..."}):(0,a.jsx)("div",{className:"flex flex-col gap-6",children:e.map((e,r)=>(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-2xl p-6 sm:p-8 shadow-sm",children:[(0,a.jsxs)("h3",{className:"text-sm font-bold mb-5 text-gray-900 uppercase tracking-wider flex items-center gap-2",children:[(0,a.jsx)("span",{className:"w-6 h-6 rounded-full bg-brand-primary/10 text-brand-primary flex items-center justify-center text-xs",children:r+1}),"Slide ",r+1]}),(0,a.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-5",children:[{label:"Title",key:"title",placeholder:"Modern.\nConvenient.\nPractical"},{label:"Image URL",key:"image_url",placeholder:"https://..."},{label:"Button Link",key:"link",placeholder:"/catalog"}].map(({label:t,key:s,placeholder:l})=>(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium text-gray-700 block mb-1.5",children:t}),"title"===s?(0,a.jsx)("textarea",{value:e[s],onChange:e=>x(r,s,e.target.value),placeholder:l,rows:2,className:"w-full bg-white border border-gray-200 rounded-xl px-4 py-3 text-sm text-gray-900 outline-none focus:border-brand-primary focus:ring-1 focus:ring-brand-primary transition-all placeholder:text-gray-400 resize-none h-[46px]"}):(0,a.jsx)("input",{type:"text",value:e[s],onChange:e=>x(r,s,e.target.value),placeholder:l,className:"w-full bg-white border border-gray-200 rounded-xl px-4 py-3 text-sm text-gray-900 outline-none focus:border-brand-primary focus:ring-1 focus:ring-brand-primary transition-all placeholder:text-gray-400"})]},s))}),e.image_url&&(0,a.jsxs)("div",{className:"mt-6 relative h-40 sm:h-48 rounded-xl overflow-hidden border border-gray-200 group",children:[(0,a.jsx)("img",{src:e.image_url,alt:"preview",className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105",onError:e=>e.currentTarget.style.display="none"}),(0,a.jsx)("div",{className:"absolute inset-0 bg-gradient-to-t from-black/60 to-transparent flex items-end p-4",children:(0,a.jsx)("span",{className:"text-white text-xs font-medium uppercase tracking-wider backdrop-blur-md bg-white/20 px-3 py-1 rounded-full border border-white/20",children:"Preview Live"})})]})]},r))})]})}e.s(["default",()=>l])}]);