(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9154],{1984:(e,t,l)=>{"use strict";l.d(t,{ObjectListEditor:()=>i});var a=l(5155),n=l(2115),s=l(2641);function r(e){let{value:t,onChange:l}=e,[r,i]=(0,n.useState)(!1);async function d(e){var t;let a=null==(t=e.target.files)?void 0:t[0];if(a){i(!0);try{l(await (0,s.Q)(a))}catch(e){alert(e instanceof Error?e.message:"Y\xfckleme başarısız.")}finally{i(!1)}}}return(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[t?(0,a.jsx)("img",{src:t,alt:"",className:"h-14 w-14 rounded-lg border border-brand-100 object-cover"}):(0,a.jsx)("div",{className:"flex h-14 w-14 items-center justify-center rounded-lg border border-dashed border-brand-200 text-[10px] text-ink-mute",children:"yok"}),(0,a.jsx)("input",{type:"file",accept:"image/*",onChange:d,disabled:r,className:"text-xs file:mr-2 file:rounded-full file:border-0 file:bg-brand-600 file:px-3 file:py-1.5 file:text-xs file:font-semibold file:text-cream-50"}),t&&(0,a.jsx)("button",{type:"button",onClick:()=>l(""),className:"text-xs text-red-600 hover:underline",children:"kaldır"})]})}function i(e){let{name:t,label:l,fields:s,defaultValue:i=[],itemTitle:d="\xd6ğe",addLabel:o="Yeni ekle"}=e,c=()=>Object.fromEntries(s.map(e=>[e.key,""])),[u,m]=(0,n.useState)(i.length?i:[c()]),b=(e,t,l)=>m(a=>a.map((a,n)=>n===e?{...a,[t]:l}:a)),x=(e,t)=>m(l=>{let a=e+t;if(a<0||a>=l.length)return l;let n=[...l];return[n[e],n[a]]=[n[a],n[e]],n}),p=u.filter(e=>Object.values(e).some(e=>""!==String(e).trim()));return(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"mb-1.5 block text-sm font-medium text-ink-soft",children:l}),(0,a.jsx)("input",{type:"hidden",name:t,value:JSON.stringify(p),readOnly:!0}),(0,a.jsx)("div",{className:"space-y-3",children:u.map((e,t)=>(0,a.jsxs)("div",{className:"rounded-xl border border-brand-100 bg-cream-100 p-4",children:[(0,a.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,a.jsxs)("span",{className:"text-xs font-semibold uppercase tracking-wider text-ink-mute",children:[d," ",t+1]}),(0,a.jsxs)("div",{className:"flex gap-1",children:[(0,a.jsx)("button",{type:"button",onClick:()=>x(t,-1),title:"Yukarı",className:"admin-icon-btn",children:"↑"}),(0,a.jsx)("button",{type:"button",onClick:()=>x(t,1),title:"Aşağı",className:"admin-icon-btn",children:"↓"}),(0,a.jsx)("button",{type:"button",onClick:()=>m(e=>e.filter((e,l)=>l!==t)),title:"Sil",className:"admin-icon-btn text-red-600",children:"✕"})]})]}),(0,a.jsx)("div",{className:"grid gap-3 sm:grid-cols-2",children:s.map(l=>{var n,s,i,d,o;return(0,a.jsxs)("div",{className:"textarea"===l.type||"image"===l.type?"sm:col-span-2":"",children:[(0,a.jsx)("span",{className:"mb-1 block text-xs font-medium text-ink-mute",children:l.label}),"textarea"===l.type?(0,a.jsx)("textarea",{value:null!=(n=e[l.key])?n:"",onChange:e=>b(t,l.key,e.target.value),rows:2,placeholder:l.placeholder,className:"admin-input w-full"}):"image"===l.type?(0,a.jsx)(r,{value:null!=(s=e[l.key])?s:"",onChange:e=>b(t,l.key,e)}):"select"===l.type?(0,a.jsx)("select",{value:null!=(i=e[l.key])?i:"",onChange:e=>b(t,l.key,e.target.value),className:"admin-input w-full",children:(null!=(d=l.options)?d:[]).map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))}):(0,a.jsx)("input",{value:null!=(o=e[l.key])?o:"",onChange:e=>b(t,l.key,e.target.value),placeholder:l.placeholder,className:"admin-input w-full"})]},l.key)})})]},t))}),(0,a.jsxs)("button",{type:"button",onClick:()=>m(e=>[...e,c()]),className:"mt-3 rounded-full border border-brand-300 px-4 py-2 text-sm font-semibold text-brand-700 hover:bg-brand-50",children:["+ ",o]})]})}},2641:(e,t,l)=>{"use strict";async function a(e){let t=new FormData;t.append("file",e);let l=await fetch("/api/admin/upload",{method:"POST",body:t}),a=await l.json();if(!l.ok)throw Error((null==a?void 0:a.error)||"Y\xfckleme başarısız.");return a.url}l.d(t,{Q:()=>a})},6275:(e,t,l)=>{Promise.resolve().then(l.bind(l,1984)),Promise.resolve().then(l.bind(l,9662))},9662:(e,t,l)=>{"use strict";l.d(t,{SubmitButton:()=>s});var a=l(5155),n=l(7650);function s(e){let{children:t="Kaydet"}=e,{pending:l}=(0,n.useFormStatus)();return(0,a.jsx)("button",{type:"submit",disabled:l,className:"inline-flex items-center justify-center gap-2 rounded-full bg-brand-600 px-7 py-3 text-sm font-semibold text-cream-50 transition-colors hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-60",children:l?"Kaydediliyor…":t})}}},e=>{e.O(0,[8441,1255,7358],()=>e(e.s=6275)),_N_E=e.O()}]);