1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5115],{63330:(e,t,r)=>{"use strict";r.d(t,{A:()=>u});var l=r(74848),a=r(96540),s=r(78885),i=r(60373),o=r(47719),n=r(76835),d=r(84061),c=r(39745);let g=a.forwardRef(function(e,t){return(0,l.jsx)(n.A,{direction:"up",ref:t,...e})});function u(e){let{onUpload:t,folder:r,size:n,userId:u}=e,[x,p]=(0,a.useState)(!1),{lang:m}=(0,o.A)(),h=()=>{p(!1)};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(i.A,{title:m.upload_image,arrow:!0,children:(0,l.jsxs)("div",{className:"flex flex-row items-center gap-4 bg-white dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 border border-gray-300 rounded-xl p-2 cursor-pointer w-[250px]",onClick:()=>{p(!0)},children:[(0,l.jsx)(s.qlq,{size:n}),(0,l.jsxs)("div",{className:"flex flex-col",children:[(0,l.jsx)("span",{className:"font-bold text-orange-500",children:m.upload_image}),(0,l.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:m.upload_image_desc})]})]})}),(0,l.jsx)(d.A,{open:x,onClose:h,TransitionComponent:g,children:(0,l.jsx)(c.A,{handleCloseForm:h,setFiles:t,folder:r,userId:u})})]})}},95115:(e,t,r)=>{"use strict";r.d(t,{Z:()=>eG});var l=r(74848),a=r(96540),s=r(29965),i=r.n(s),o=r(4589);r(51082),r(39194);var n=r(45290),d=r.n(n),c=r(47719),g=r(86715),u=r(63330),x=r(78885),p=r(79219),m=r(71884);function h(e){let{description:t,setDescription:r,images:s,setImages:o,autoPlay:n,setAutoPlay:d,autoPlaySpeed:g,setAutoPlaySpeed:h,language:b,setLanguage:y,setEditMode:f,handleSubmit:v}=e,[j,w]=(0,a.useState)([]),[k,N]=(0,a.useState)(""),{t:C,lang:S}=(0,c.A)();(0,a.useEffect)(()=>{(async()=>{try{let e=(0,m.rJ)(p.db,"sections"),t=(0,m.P)(e,(0,m._M)("component","==","carousel")),r=(await (0,m.GG)(t)).docs.map(e=>({id:e.id,...e.data()}));w(r)}catch(e){console.error("Error fetching section data:",e)}})()},[]),console.log("sectionData",j);let E=e=>{o(t=>t.filter((t,r)=>r!==e))},_=(e,t)=>{let r=[...s];r[e]={...r[e],link:t},o(r)},A=e=>{let t=j.find(t=>t.id===e);t&&(r(t.description||{th:"",en:""}),o(t.images||[]),d(t.autoPlay||!0),h(t.autoPlaySpeed||3e3))};return(0,l.jsx)("div",{className:"w-full",children:(0,l.jsxs)("div",{className:"flex flex-col border border-gray-300 rounded-md p-4 gap-2 shadow-lg",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"duplicate",children:"Duplicate Data"}),(0,l.jsxs)("select",{name:"duplicate",id:"duplicate",value:k,onChange:e=>{let t=e.target.value;N(t),t&&A(t)},className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-2/3 p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",children:[(0,l.jsx)("option",{value:"",children:"Select Data"}),j.map(e=>(0,l.jsx)("option",{value:e.id,children:C(e.description)},e.id))]})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"description",children:S.description}),(0,l.jsx)("textarea",{type:"text",id:"description-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.th,onChange:e=>r({...t,th:e.target.value}),placeholder:"TH",rows:4}),(0,l.jsx)("textarea",{type:"text",id:"description-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.en,onChange:e=>r({...t,en:e.target.value}),placeholder:"EN",rows:4})]}),(0,l.jsxs)("div",{className:"flex flex-row items-center gap-16",children:[(0,l.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[(0,l.jsx)("label",{htmlFor:"autoPlay",children:"AutoPlay"}),(0,l.jsx)("input",{type:"checkbox",id:"autoPlay",checked:n,onChange:e=>d(e.target.checked)})]}),(0,l.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[(0,l.jsx)("label",{htmlFor:"autoPlaySpeed",children:"PlaySpeed"}),(0,l.jsx)("input",{type:"number",id:"autoPlaySpeed",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-20 p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:g/1e3,onChange:e=>h(1e3*e.target.value)}),(0,l.jsx)("span",{children:"วิà¸à¸²à¸à¸µ"})]})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[(0,l.jsx)("div",{className:"relative",children:s&&s.length>0&&s.map((e,t)=>(0,l.jsxs)("div",{className:"flex flex-row gap-2 items-start w-full",children:[(0,l.jsxs)("div",{className:"relative flex flex-row shrink-0",children:[(0,l.jsx)(i(),{src:e.url,alt:"image-".concat(t),width:120,height:120,className:"object-cover rounded-md border"}),(0,l.jsx)("button",{type:"button",className:"flex items-center justify-center absolute top-0 right-0 bg-red-500 text-white rounded-full p-1 hover:bg-red-600",onClick:()=>E(t),children:(0,l.jsx)(x.$8F,{size:14})})]}),(0,l.jsxs)("div",{className:"flex flex-col w-full gap-1",children:[(0,l.jsx)("label",{htmlFor:"url-".concat(t),className:"text-sm font-medium",children:"URL:"}),(0,l.jsx)("input",{type:"text",id:"url-".concat(t),className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-[calc(100%-200px)] p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:e.link||"",onChange:e=>_(t,e.target.value),placeholder:"URL"})]})]},t))}),(0,l.jsx)(u.A,{size:24,onUpload:e=>{let t=e.map(e=>({...e,link:""}));o(e=>[...e||[],...t])},folder:"sections"})]}),(0,l.jsxs)("div",{className:"flex justify-center items-center gap-4 w-full mt-5",children:[(0,l.jsx)("button",{onClick:v,className:"bg-orange-500 hover:bg-orange-600 p-2 rounded-md text-white font-bold",children:S.save}),(0,l.jsx)("button",{onClick:()=>{r({}),o([]),y("th"),f(!1)},className:"bg-red-500 hover:bg-red-600 p-2 rounded-md text-white font-bold",children:S.cancel})]})]})})}var b=r(61409);let y={description:{th:"à¸à¸³à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},image:[{url:"/images/sections/sample-bg-1000x412.png"},{url:"/images/sections/sample-bg-1000x412.png"}]};var f=r(91106),v=r.n(f),j=r(16047);
1function w(e){let{title:t,setTitle:r,description:a,setDescription:s,language:i,setLanguage:o,setEditMode:n,handleSubmit:d}=e,{t:g,lang:u}=(0,c.A)();return(0,l.jsx)("div",{className:"w-full",children:(0,l.jsxs)("div",{className:"flex flex-col border border-gray-300 rounded-md p-4 gap-2 shadow-lg",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"title",children:u.title}),(0,l.jsx)("input",{type:"text",id:"title-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.th,onChange:e=>r({...t,th:e.target.value}),placeholder:"TH"}),(0,l.jsx)("input",{type:"text",id:"title-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.en,onChange:e=>r({...t,en:e.target.value}),placeholder:"EN"})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"description",children:u.description}),(0,l.jsx)("textarea",{type:"text",id:"description-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:a.th,onChange:e=>s({...a,th:e.target.value}),placeholder:"TH",rows:4}),(0,l.jsx)("textarea",{type:"text",id:"description-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:a.en,onChange:e=>s({...a,en:e.target.value}),placeholder:"EN",rows:4})]}),(0,l.jsxs)("div",{className:"flex justify-center items-center gap-4 w-full mt-5",children:[(0,l.jsx)("button",{onClick:d,className:"bg-orange-500 hover:bg-orange-600 p-2 rounded-md text-white font-bold",children:u.save}),(0,l.jsx)("button",{onClick:()=>{r({}),s({}),o("th"),n(!1)},className:"bg-red-500 hover:bg-red-600 p-2 rounded-md text-white font-bold",children:u.cancel})]})]})})}let k={title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¸³à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"}};function N(e){let{title:t,setTitle:r,description:s,setDescription:o,image:n,setImage:d,style:g,setStyle:x,contents:p,setContents:m,language:h,setLanguage:b,setEditMode:y,handleSubmit:f}=e,[v,j]=(0,a.useState)(!1),[w,k]=(0,a.useState)((null==g?void 0:g.color)||"#000000"),{t:N,lang:C}=(0,c.A)();return(0,l.jsx)("div",{className:"w-full",children:(0,l.jsxs)("div",{className:"flex flex-col border border-gray-300 rounded-md p-4 gap-2 shadow-lg",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"title",children:C.title}),(0,l.jsx)("input",{type:"text",id:"title-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.th,onChange:e=>r({...t,th:e.target.value}),placeholder:"TH"}),(0,l.jsx)("input",{type:"text",id:"title-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.en,onChange:e=>r({...t,en:e.target.value}),placeholder:"EN"})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"description",children:C.description}),(0,l.jsx)("textarea",{type:"text",id:"description-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:s.th,onChange:e=>o({...s,th:e.target.value}),placeholder:"TH",rows:4}),(0,l.jsx)("textarea",{type:"text",id:"description-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:s.en,onChange:e=>o({...s,en:e.target.value}),placeholder:"EN",rows:4})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[(0,l.jsx)("div",{className:"relative",children:n&&n.url&&(0,l.jsx)(i(),{src:n.url,alt:"image",width:200,height:200,className:"object-cover",priority:!0})}),(0,l.jsx)(u.A,{size:24,onUpload:e=>{d(e[0])},folder:"sections"})]}),(0,l.jsxs)("div",{className:"flex flex-col w-full",children:[(0,l.jsxs)("div",{className:"flex flex-row items-center justify-between gap-2 w-full",children:[(0,l.jsxs)("div",{className:"flex flex-row items-center gap-8",children:[(0,l.jsxs)("div",{className:"flex flex-row items-center gap-2 relative",children:[(0,l.jsx)("label",{htmlFor:"color",children:C.color}),(0,l.jsx)("div",{className:"h-8 w-20 border border-gray-300 rounded-xl cursor-pointer",style:{backgroundColor:null==g?void 0:g.color},onClick:()=>{k((null==g?void 0:g.color)||"#000000"),j(!v)}}),v&&(0,l.jsxs)("div",{className:"absolute z-50 top-full mt-2 left-0 bg-white dark:bg-gray-800 shadow-md border border-gray-300 p-3 rounded-md flex flex-col gap-2",children:[(0,l.jsx)("input",{type:"color",value:w,onChange:e=>k(e.target.value),className:"w-10 h-10 cursor-pointer"}),(0,l.jsx)("input",{type:"text",value:w,onChange:e=>k(e.target.value.startsWith("#")?e.target.value:"#".concat(e.target.value)),className:"border border-gray-300 rounded-md p-1 w-[100px] text-sm dark:bg-gray-700 dark:text-white",placeholder:"#000000"}),(0,l.jsx)("button",{onClick:()=>{x({...g,color:w}),j(!1)},className:"px-3 py-1 bg-blue-500 hover:bg-blue-600 text-white rounded-md text-sm",children:"à¹à¸¥à¸·à¸à¸"})]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("label",{htmlFor:"fontSize",children:C.fontSize}),(0,l.jsxs)("select",{name:"fontSize",id:"fontSize",className:"border border-gray-200 bg-white p-1 px-4 py-2 rounded-xl",value:null==g?void 0:g.fontSize,onChange:e=>x({...g,fontSize:e.target.value}),children:[(0,l.jsx)("option",{value:"12px",children:"12px"}),(0,l.jsx)("option",{value:"16px",children:"16px"}),(0,l.jsx)("option",{value:"18px",children:"18px"}),(0,l.jsx)("option",{value:"20px",children:"20px"}),(0,l.jsx)("option",{value:"22px",children:"22px"}),(0,l.jsx)("option",{value:"24px",children:"24px"}),(0,l.jsx)("option",{value:"26px",children:"26px"}),(0,l.jsx)("option",{value:"28px",children:"28px"}),(0,l.jsx)("option",{value:"30px",children:"30px"}),(0,l.jsx)("option",{value:"32px",children:"32px"}),(0,l.jsx)("option",{value:"38px",children:"38px"}),(0,l.jsx)("option",{value:"40px",children:"40px"})]})]})]}),(0,l.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[(0,l.jsx)("button",{className:"px-4 py-1 rounded-md font-bold transition ".concat("th"===h?"bg-blue-500 text-white":"bg-gray-300 dark:bg-gray-700"),onClick:()=>
1b("th"),children:"TH"}),(0,l.jsx)("button",{className:"px-4 py-1 rounded-md font-bold transition ".concat("en"===h?"bg-blue-500 text-white":"bg-gray-300 dark:bg-gray-700"),onClick:()=>b("en"),children:"EN"})]})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"contents",children:C.contents}),(0,l.jsx)("textarea",{type:"text",id:"contents-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:p.th,onChange:e=>m({...p,th:e.target.value}),placeholder:"TH",rows:4}),(0,l.jsx)("textarea",{type:"text",id:"contents-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:p.en,onChange:e=>m({...p,en:e.target.value}),placeholder:"EN",rows:4})]})]}),(0,l.jsxs)("div",{className:"flex justify-center items-center gap-4 w-full mt-5",children:[(0,l.jsx)("button",{onClick:f,className:"bg-orange-500 hover:bg-orange-600 p-2 rounded-md text-white font-bold",children:C.save}),(0,l.jsx)("button",{onClick:()=>{r({}),o({}),d({}),m({}),b("th"),y(!1)},className:"bg-red-500 hover:bg-red-600 p-2 rounded-md text-white font-bold",children:C.cancel})]})]})})}let C={title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¸³à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},image:{url:"/images/sections/sample-image-500x500.png"},style:{position:"left",color:"white",fontSize:"20px"},contents:{th:"à¹à¸à¸·à¹à¸à¸«à¸²à¸ าษาà¹à¸à¸¢",en:"English contents"}};var S=r(24973);function E(e){let{title:t,setTitle:r,description:a,setDescription:s,image:o,setImage:n,contents:d,setContents:g,language:x,setLanguage:p,setEditMode:m,handleSubmit:h}=e,{t:b,lang:y}=(0,c.A)();return(0,l.jsx)("div",{className:"w-full",children:(0,l.jsxs)("div",{className:"flex flex-col border border-gray-300 rounded-md p-4 gap-2 shadow-lg",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"title",children:y.title}),(0,l.jsx)("input",{type:"text",id:"title-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.th,onChange:e=>r({...t,th:e.target.value}),placeholder:"TH"}),(0,l.jsx)("input",{type:"text",id:"title-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.en,onChange:e=>r({...t,en:e.target.value}),placeholder:"EN"})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"description",children:y.description}),(0,l.jsx)("textarea",{type:"text",id:"description-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:a.th,onChange:e=>s({...a,th:e.target.value}),placeholder:"TH",rows:4}),(0,l.jsx)("textarea",{type:"text",id:"description-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:a.en,onChange:e=>s({...a,en:e.target.value}),placeholder:"EN",rows:4})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[(0,l.jsx)("div",{className:"relative",children:o&&o.url&&(0,l.jsx)(i(),{src:o.url,alt:"image",width:200,height:200,className:"object-cover",priority:!0})}),(0,l.jsx)(u.A,{size:24,onUpload:e=>{n(e[0])},folder:"sections"})]}),(0,l.jsxs)("div",{className:" w-full",children:[(0,l.jsxs)("div",{className:"flex flex-row items-center justify-end gap-2 w-full",children:[(0,l.jsx)("button",{className:"px-4 py-1 rounded-md font-bold transition ".concat("th"===x?"bg-blue-500 text-white":"bg-gray-300 dark:bg-gray-700"),onClick:()=>p("th"),children:"TH"}),(0,l.jsx)("button",{className:"px-4 py-1 rounded-md font-bold transition ".concat("en"===x?"bg-blue-500 text-white":"bg-gray-300 dark:bg-gray-700"),onClick:()=>p("en"),children:"EN"})]}),(0,l.jsx)(S.default,{content:d[x],onChange:e=>{g(t=>({...t,[x]:e}))}})]}),(0,l.jsxs)("div",{className:"flex justify-center items-center gap-4 w-full mt-5",children:[(0,l.jsx)("button",{onClick:h,className:"bg-orange-500 hover:bg-orange-600 p-2 rounded-md text-white font-bold",children:y.save}),(0,l.jsx)("button",{onClick:()=>{r({}),s({}),n({}),g({}),p("th"),m(!1)},className:"bg-red-500 hover:bg-red-600 p-2 rounded-md text-white font-bold",children:y.cancel})]})]})})}let _={title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¸³à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},image:{url:"/images/sections/sample-image-500x500.png"},contents:{th:"à¹à¸à¸·à¹à¸à¸«à¸²à¸ าษาà¹à¸à¸¢",en:"English contents"}},A={title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¸³à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},image:{url:"/images/sections/sample-image-500x500.png"},contents:{th:"à¹à¸à¸·à¹à¸à¸«à¸²à¸ าษาà¹à¸à¸¢",en:"English contents"}};
1function F(e){let{contentsData:t,contents:r,setContents:a,contentCollection:s}=e,{t:i,lang:o}=(0,c.A)(),n=e=>{r.find(t=>t.id===e.id)||a(t=>[...t,{...e,page:s}])},d=e=>{a(t=>t.filter(t=>t.id!==e))};return t.length>0&&(0,l.jsxs)("div",{className:"grid grid-cols-2 bg-gray-50 rounded-lg w-full",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2 px-4 py-2",children:[(0,l.jsxs)("span",{children:[o.content,":"]}),t.map(e=>(0,l.jsx)("div",{className:"flex items-center px-2 py-1 bg-gray-200 hover:bg-gray-300 cursor-pointer w-1/2 rounded-full",onClick:()=>n(e),children:(0,l.jsx)("span",{children:i(e.name)})},e.id))]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2 px-4 py-2",children:[(0,l.jsxs)("span",{children:[o.select_content,":"]}),r&&r.map((e,t)=>(0,l.jsxs)("div",{className:"flex flex-row items-center justify-between px-2 py-1 bg-white rounded-md shadow-sm w-1/2",children:[(0,l.jsx)("span",{children:i(e.name)}),(0,l.jsx)(x.$8F,{size:18,className:"text-red-500 cursor-pointer",onClick:()=>d(e.id)})]},t))]})]})}function z(e){let{title:t,setTitle:r,description:s,setDescription:o,image:n,setImage:d,imageEng:g,setImageEng:h,contents:b,setContents:y,contentCollection:f,setContentCollection:v,style:j,setStyle:w,type:k,setType:N,language:C,setLanguage:S,setEditMode:E,handleSubmit:_}=e,[A,z]=(0,a.useState)([]),{t:H,lang:R}=(0,c.A)();(0,a.useEffect)(()=>{f?(async()=>{try{let e=(0,m.P)((0,m.rJ)(p.db,f),(0,m._M)("active","==",!0)),t=(await (0,m.GG)(e)).docs.map(e=>({id:e.id,...e.data()}));z(t)}catch(e){console.error("Error fetching contents:",e),z([])}})():z([])},[f]);let T=e=>{d(t=>t.filter((t,r)=>r!==e))},D=e=>{h(t=>t.filter((t,r)=>r!==e))};return(0,l.jsx)("div",{className:"w-full",children:(0,l.jsxs)("div",{className:"flex flex-col border border-gray-300 rounded-md p-4 gap-2 shadow-lg",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"title",children:R.title}),(0,l.jsx)("input",{type:"text",id:"title-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.th,onChange:e=>r({...t,th:e.target.value}),placeholder:"TH"}),(0,l.jsx)("input",{type:"text",id:"title-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.en,onChange:e=>r({...t,en:e.target.value}),placeholder:"EN"})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"description",children:R.description}),(0,l.jsx)("textarea",{type:"text",id:"description-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:s.th,onChange:e=>o({...s,th:e.target.value}),placeholder:"TH",rows:4}),(0,l.jsx)("textarea",{type:"text",id:"description-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:s.en,onChange:e=>o({...s,en:e.target.value}),placeholder:"EN",rows:4})]}),(0,l.jsxs)("div",{className:"flex flex-row items-center gap-8",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"gap",children:R.gap}),(0,l.jsx)("input",{type:"number",name:"gap",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:j.gap,onChange:e=>w({...j,gap:e.target.value})})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"cols",children:R.cols}),(0,l.jsx)("input",{type:"number",name:"cols",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:j.cols,onChange:e=>w({...j,cols:e.target.value})})]})]}),(0,l.jsxs)("div",{className:"flex flex-row items-center gap-4 w-full",children:[(0,l.jsxs)("div",{className:"flex flex-col",children:[(0,l.jsx)("label",{htmlFor:"type",children:R.select_type}),(0,l.jsxs)("select",{name:"type",id:"type",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-32 p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:k,onChange:e=>N(e.target.value),children:[(0,l.jsx)("option",{value:"",children:R.select_type}),(0,l.jsx)("option",{value:"images",children:R.images}),(0,l.jsx)("option",{value:"contents",children:R.content})]})]}),"contents"===k&&(0,l.jsx)("div",{className:"flex flex-col",children:(0,l.jsxs)("label",{htmlFor:"selectContent",children:[R.select_content,(0,l.jsxs)("select",{name:"selectContent",id:"selectContent",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-32 p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:f,onChange:e=>v(e.target.value),children:[(0,l.jsx)("option",{value:"",children:R.select_content}),(0,l.jsx)("option",{value:"courses",children:R.courses}),(0,l.jsx)("option",{value:"blogs",children:R.blog}),(0,l.jsx)("option",{value:"articles",children:R.articles}),(0,l.jsx)("option",{value:"news",children:R.news})]})]})})]}),(0,l.jsx)("div",{children:(0,l.jsx)(F,{contents:b,setContents:y,contentsData:A,contentCollection:f})}),"images"===k&&(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[(0,l.jsxs)("h3",{className:"text-lg font-semibold",children:[R.image," TH"]}),(0,l.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:n&&n.length>0&&n.map((e,t)=>(0,l.jsxs)("div",{className:"relative m-1",children:[(0,l.jsx)(i(),{src:e.url,alt:"image-".concat(t),width:120,height:120,className:"object-cover rounded-md border"}),(0,l.jsx)("button",{className:"absolute top-1 right-1 bg-red-500 text-white rounded-full p-1 hover:bg-red-600",onClick:()=>T(t),children:(0,l.jsx)(x.$8F,{size:14})})]},t))}),(0,l.jsx)(u.A,{size:24,onUpload:e=>{d(t=>[...t||[],...e])},folder:"sections"})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[(0,l.jsxs)("h3",{className:"text-lg font-semibold",children:[R.image," EN"]}),(0,l.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:g&&g.length>0&&g.map((e,t)=>(0,l.jsxs)("div",{className:"relative m-1",children:[(0,l.jsx)(i(),{src:e.url,alt:"image-".concat(t),width:120,height:120,className:"object-cover rounded-md border"}),(0,l.jsx)("button",{className:"absolute top-1 right-1 bg-red-500 text-white rounded-full p-1 hover:bg-red-600",onClick:()=>D(t),children:(0,l.jsx)(x.$8F,{size:14})})]},t))}),(0,l.jsx)(u.A,{size:24,onUpload:e=>{h(t=>[...t||[],...e])},folder:"sections"})]})]}),(0,l.jsxs)("div",{className:"flex justify-center items-center gap-4 w-full mt-5",children:[(0,l.jsx)("button",{onClick:_,className:"bg-orange-500 hover:bg-orange-600 p-2 rounded-md text-white font-bold",children:R.save}),(0,l.jsx)("button",{onClick:()=>{r({}),o({}),d([]),h([]),S("th"),E(!1)},className:"bg-red-500 hover:bg-red-600 p-2 rounded-md text-white font-bold",children:R.cancel})]})]})})}let H={title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¸³à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},image:[{url:"/images/sections/sample-image-500x210.png"},{url:"/images/sections/sample-image-500x210.png"}],style:{gap:2,cols:2},contents:{th:"à¹à¸à¸·à¹à¸à¸«à¸²à¸ าษาà¹à¸à¸¢",en:"English contents"}};var R=r(63972);function T(e){let{handleClose:t,contents:r,handleContents:s,newcontent:o}=e,[n,d]=(0,a.useState)({th:"",en:""}),[g,p]=(0,a.useState)({th:"",en:""}),[m,h]=(0,a.useState)({}),[b,y]=(0,a.useState)(""),{lang:f}=(0,c.A)();(0,a.useEffect)(()=>{r?(d(r.title||{th:"",en:""}),p(r.description||{th:"",en:""}),h(r.image||{}),y(r.url||"")):(d({th:"",en:""}),p({th:"",en:""}),h({}),y(""))},[r]);let v=async e=>{await (0,R.W)(e),h({})};return(0,l.jsxs)("div",{className:"flex flex-col w-full",children:[(0,l.jsxs)("div",{className:"flex flex-row justify-between items-center bg-orange-500 text-white p-4",children:[(0,l.jsx)("h2",{children:o?f.create+f.content:f.edit+f.content}),(0,l.jsx)("button",{onClick:t,className:"flex flex-row justify-center items-center",children:(0,l.jsx)(x.$8F,{size:24})})]}),(0,l.jsxs)("div",{className:"flex flex-col p-4 gap-2",children:[m&&m.url&&(0,l.jsxs)("div",{className:"relative shrink-0 w-[200px]",children:[(0,l.jsx)(i(),{src:m.url,alt:"mockup",width:500,height:500,className:"w-full h-[200px] object-contain",priority:!0}),(0,l.jsx)("button",{onClick:()=>v(m.file_id),className:"absolute top-2 right-2 bg-red-500 p-1 rounded-full text-white",children:(0,l.jsx)(x.$8F,{size:24})})]}),(0,l.jsx)("div",{children:(0,l.jsx)(u.A,{size:24,onUpload:e=>{h(e[0])},folder:"sections"})}),(0,l.jsxs)("div",{className:"flex flex-col",children:[(0,l.jsx)("label",{htmlFor:"title",children:f.title}),(0,l.jsxs)("div",{className:"flex flex-row gap-2",children:[(0,l.jsx)("span",{children:"TH:"}),(0,l.jsx)("input",{type:"text",id:"title-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:n.th,onChange:e=>d({...n,th:e.target.value}),placeholder:"TH"})]}),(0,l.jsxs)("div",{className:"flex flex-row gap-2",children:[(0,l.jsx)("span",{children:"EN:"}),(0,l.jsx)("input",{type:"text",id:"description-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:n.en,onChange:e=>d({...n,en:e.target.value}),placeholder:"EN"})]})]}),(0,l.jsxs)("div",{className:"flex flex-col",children:[(0,l.jsx)("label",{htmlFor:"description",children:f.description}),(0,l.jsxs)("div",{className:"flex flex-row gap-2",children:[(0,l.jsx)("span",{children:"TH:"}),(0,l.jsx)("textarea",{type:"text",id:"description-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:g.th,onChange:e=>p({...g,th:e.target.value}),placeholder:"TH",rows:4})]}),(0,l.jsxs)("div",{className:"flex flex-row gap-2",children:[(0,l.jsx)("span",{children:"EN:"}),(0,l.jsx)("textarea",{type:"text",id:"description-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:g.en,onChange:e=>p({...g,en:e.target.value}),placeholder:"EN",rows:4})]})]}),(0,l.jsxs)("div",{className:"flex flex-col",children:[(0,l.jsx)("label",{htmlFor:"url",children:f.url}),(0,l.jsx)("input",{type:"text",id:"url",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:b,onChange:e=>y(e.target.value),placeholder:"URL"})]}),(0,l.jsxs)("div",{className:"flex flex-row items-center justify-center w-full gap-4",children:[(0,l.jsx)("button",{onClick:()=>{s({title:n,description:g,image:m||{url:"/images/sections/sample-image-500x210.png"},url:b})},className:"bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 roun
1ded focus:outline-none focus:shadow-outline",children:o?f.save:f.edit}),(0,l.jsx)("button",{onClick:()=>{d({th:"",en:""}),p({th:"",en:""}),h({}),y(""),t()},className:"bg-red-500 hover:bg-red-800 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline",children:f.cencel})]})]})]})}var D=r(76835),M=r(94191),I=r(60373),L=r(84061),P=r(11583),G=r(48714),J=r(84961);let U=a.forwardRef(function(e,t){return(0,l.jsx)(D.A,{direction:"up",ref:t,...e})});function B(e){let{title:t,setTitle:r,description:s,setDescription:o,contents:n,setContents:d,style:g,setStyle:u,language:x,setLanguage:h,editMode:b,setEditMode:y,handleSubmit:f}=e,[v,j]=(0,a.useState)([{title:{th:"",en:""},description:{th:"",en:""},image:{url:""},url:""}]),[w,k]=(0,a.useState)(null),[N,C]=(0,a.useState)(null),[S,E]=(0,a.useState)(!1),[_,A]=(0,a.useState)([]),[F,z]=(0,a.useState)(""),{t:H,lang:R}=(0,c.A)();(0,a.useEffect)(()=>{n&&j(n)},[]),(0,a.useEffect)(()=>{d(v)},[v]),(0,a.useEffect)(()=>{(async()=>{try{let e=(0,m.rJ)(p.db,"sections"),t=(0,m.P)(e,(0,m._M)("component","==","layout5")),r=(await (0,m.GG)(t)).docs.map(e=>({id:e.id,...e.data()}));A(r)}catch(e){console.error("Error fetching section data:",e)}})()},[]);let D=()=>{k(null),E(!1)},B=(e,t)=>{C(e),k(t),E(!0)},O=e=>{j(t=>t.filter((t,r)=>r!==e))},Y=e=>{let t=_.find(t=>t.id===e);t&&(r(t.title||{th:"",en:""}),o(t.description||{th:"",en:""}),u(t.style||{}),j(t.contents||[]),d(t.contents||[]))};return(0,l.jsxs)("div",{className:"w-full",children:[(0,l.jsxs)("div",{className:"flex flex-col border border-gray-300 rounded-md p-4 gap-2 shadow-lg",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"duplicate",children:"Duplicate Data"}),(0,l.jsxs)("select",{name:"duplicate",id:"duplicate",value:F,onChange:e=>{let t=e.target.value;z(t),t&&Y(t)},className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-2/3 p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",children:[(0,l.jsx)("option",{value:"",children:"Select Data"}),_.map(e=>(0,l.jsx)("option",{value:e.id,children:H(e.title)},e.id))]})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"title",children:R.title}),(0,l.jsx)("input",{type:"text",id:"title-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.th,onChange:e=>r({...t,th:e.target.value}),placeholder:"TH"}),(0,l.jsx)("input",{type:"text",id:"title-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.en,onChange:e=>r({...t,en:e.target.value}),placeholder:"EN"})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"description",children:R.description}),(0,l.jsx)("textarea",{type:"text",id:"description-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:s.th,onChange:e=>o({...s,th:e.target.value}),placeholder:"TH",rows:4}),(0,l.jsx)("textarea",{type:"text",id:"description-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:s.en,onChange:e=>o({...s,en:e.target.value}),placeholder:"EN",rows:4})]}),(0,l.jsxs)("div",{className:"flex flex-row items-center gap-8",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"gap",children:R.gap}),(0,l.jsx)("input",{type:"number",name:"gap",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:g.gap,onChange:e=>u({...g,gap:e.target.value})})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"cols",children:R.cols}),(0,l.jsx)("input",{type:"number",name:"cols",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:g.cols,onChange:e=>u({...g,cols:e.target.value})})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"size",children:R.size}),(0,l.jsx)("input",{type:"number",name:"size",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:g.size,onChange:e=>u({...g,size:e.target.value})})]})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[(0,l.jsx)(M.A,{flexItem:!0,orientation:"horizontal",textAlign:"left",style:{padding:"10px 0px",gap:"10px"},children:(0,l.jsxs)("div",{className:"flex flex-row items-center gap-4",children:[(0,l.jsx)("span",{children:R.content}),(0,l.jsx)(I.A,{title:R.add_new_content,placement:"top",arrow:!0,children:(0,l.jsx)(P.n2u,{size:30,onClick:()=>{C(null),E(!0)}})})]})}),!S&&(0,l.jsx)("div",{className:"flex flex-row flex-wrap gap-8",children:v.map((e,t)=>(0,l.jsxs)("div",{className:"flex flex-col",children:[(0,l.jsx)("div",{className:"relative max-w-[200px] h-auto",children:(0,l.jsx)(i(),{src:e.image.url,alt:"mockup",width:200,height:200,className:"object-contain",priority:!0})}),(0,l.jsx)("h4",{children:H(e.title)}),(0,l.jsx)(M.A,{}),(0,l.jsxs)("div",{className:"flex flex-row items-center justify-end gap-2",children:[(0,l.jsx)("div",{className:"bg-gray-200 hover:bg-gray-500 hover:text-white p-1 rounded-md text-black cursor-pointer",onClick:()=>B(t,e),children:(0,l.jsx)(G.h06,{})},t),(0,l.jsx)("div",{className:"bg-gray-200 hover:bg-gray-500 hover:text-white p-1 rounded-md text-black cursor-pointer",onClick:()=>O(t),children:(0,l.jsx)(J.tqC,{})},t)]})]},t))})]}),(0,l.jsxs)("div",{className:"flex justify-center items-center gap-4 w-full mt-5",children:[(0,l.jsx)("button",{onClick:f,className:"bg-orange-500 hover:bg-orange-600 p-2 rounded-md text-white font-bold",children:R.save}),(0,l.jsx)("button",{onClick:()=>{j([{title:{th:"",en:""},description:{th:"",en:""},image:{url:""},url:""}]),r({}),o({}),h("th"),y(!1)},className:"bg-red-500 hover:bg-red-600 p-2 rounded-md text-white font-bold",children:R.cancel})]})]}),(0,l.jsx)(L.A,{fullScreen:!0,open:S,TransitionComponent:U,onClose:D,"aria-describedby":"alert-dialog-slide-description",children:(0,l.jsx)(T,{handleClose:D,contents:null!==N?v[N]:null,newcontent:null===N,handleContents:e=>{if(null!==N){let t=[...v];t[N]=e,j(t)}else j(t=>[...t,e]);C(null),E(!1)}})})]})}let O={title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¸³à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},contents:[{id:1,image:{url:"/images/sections/sample-image-500x210.png"},title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},url:"https://www.thenewyou.co.th"},{id:2,image:{url:"/images/sections/sample-image-500x210.png"},title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},url:"https://www.thenewyou.co.th"},{id:3,image:{url:"/images/sections/sample-image-500x210.png"},title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},url:"https://www.thenewyou.co.th"}],style:{gap:2,cols:3,size:200}};
1function Y(e){let{title:t,setTitle:r,description:s,setDescription:o,image:n,setImage:d,style:g,setStyle:x,language:h,setLanguage:b,setEditMode:y,handleSubmit:f}=e,[v,j]=(0,a.useState)([]),[w,k]=(0,a.useState)(""),[N,C]=(0,a.useState)(null),[S,E]=(0,a.useState)((null==g?void 0:g.bgColor)||"#757474"),[_,A]=(0,a.useState)((null==g?void 0:g.titleColor)||"#f5f2f2"),[F,z]=(0,a.useState)((null==g?void 0:g.descriptionColor)||"#f5f2f2"),{t:H,lang:R}=(0,c.A)();(0,a.useEffect)(()=>{(async()=>{try{let e=(0,m.rJ)(p.db,"sections"),t=(0,m.P)(e,(0,m._M)("component","==","header")),r=(await (0,m.GG)(t)).docs.map(e=>({id:e.id,...e.data()}));j(r)}catch(e){console.error("Error fetching section data:",e)}})()},[]);let T=e=>{let t=v.find(t=>t.id===e);t&&(r(t.title||{th:"",en:""}),o(t.description||{th:"",en:""}),x(t.style||{}),setContentsForm(t.contents||[]),setContents(t.contents||[]))};return(0,l.jsx)("div",{className:"w-full",children:(0,l.jsxs)("div",{className:"flex flex-col border border-gray-300 rounded-md p-4 gap-2 shadow-lg",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"duplicate",children:"Duplicate Data"}),(0,l.jsxs)("select",{name:"duplicate",id:"duplicate",value:w,onChange:e=>{let t=e.target.value;k(t),t&&T(t)},className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-2/3 p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",children:[(0,l.jsx)("option",{value:"",children:"Select Data"}),v.map(e=>(0,l.jsx)("option",{value:e.id,children:H(e.title)},e.id))]})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"bgColor",children:"Backgroup Color"}),(0,l.jsxs)("div",{className:"flex flex-row items-center gap-2 relative",children:[(0,l.jsx)("label",{htmlFor:"color",children:R.color}),(0,l.jsx)("div",{className:"h-8 w-20 border border-gray-300 rounded-xl cursor-pointer",style:{backgroundColor:null==g?void 0:g.bgColor},onClick:()=>{E((null==g?void 0:g.bgColor)||"#000000"),C("bgColor"===N?null:"bgColor")}}),"bgColor"===N&&(0,l.jsxs)("div",{className:"absolute z-50 top-full mt-2 left-0 bg-white dark:bg-gray-800 shadow-md border border-gray-300 p-3 rounded-md flex flex-col gap-2",children:[(0,l.jsx)("input",{type:"color",value:S,onChange:e=>E(e.target.value),className:"w-10 h-10 cursor-pointer"}),(0,l.jsx)("input",{type:"text",value:S,onChange:e=>E(e.target.value.startsWith("#")?e.target.value:"#".concat(e.target.value)),className:"border border-gray-300 rounded-md p-1 w-[100px] text-sm dark:bg-gray-700 dark:text-white",placeholder:"#000000"}),(0,l.jsx)("button",{onClick:()=>{x({...g,bgColor:S}),C(null)},className:"px-3 py-1 bg-blue-500 hover:bg-blue-600 text-white rounded-md text-sm",children:"à¹à¸¥à¸·à¸à¸"})]})]})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"title",children:R.title}),(0,l.jsx)("div",{className:"flex flex-row items-center justify-between gap-2 w-full",children:(0,l.jsxs)("div",{className:"flex flex-row items-center gap-8",children:[(0,l.jsxs)("div",{className:"flex flex-row items-center gap-2 relative",children:[(0,l.jsx)("label",{htmlFor:"color",children:R.color}),(0,l.jsx)("div",{className:"h-8 w-20 border border-gray-300 rounded-xl cursor-pointer",style:{backgroundColor:null==g?void 0:g.titleColor},onClick:()=>{A((null==g?void 0:g.titleColor)||"#000000"),C("titleColor"===N?null:"titleColor")}}),"titleColor"===N&&(0,l.jsxs)("div",{className:"absolute z-50 top-full mt-2 left-0 bg-white dark:bg-gray-800 shadow-md border border-gray-300 p-3 rounded-md flex flex-col gap-2",children:[(0,l.jsx)("input",{type:"color",value:_,onChange:e=>A(e.target.value),className:"w-10 h-10 cursor-pointer"}),(0,l.jsx)("input",{type:"text",value:_,onChange:e=>A(e.target.value.startsWith("#")?e.target.value:"#".concat(e.target.value)),className:"border border-gray-300 rounded-md p-1 w-[100px] text-sm dark:bg-gray-700 dark:text-white",placeholder:"#000000"}),(0,l.jsx)("button",{onClick:()=>{x({...g,titleColor:_}),C(null)},className:"px-3 py-1 bg-blue-500 hover:bg-blue-600 text-white rounded-md text-sm",children:"à¹à¸¥à¸·à¸à¸"})]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("label",{htmlFor:"fontSize",children:R.fontSize}),(0,l.jsxs)("select",{name:"fontSize",id:"fontSize",className:"border border-gray-200 bg-white p-1 px-4 py-2 rounded-xl",value:null==g?void 0:g.titleFontSize,onChange:e=>x({...g,titleFontSize:e.target.value}),children:[(0,l.jsx)("option",{value:"12px",children:"12px"}),(0,l.jsx)("option",{value:"14px",children:"14px"}),(0,l.jsx)("option",{value:"16px",children:"16px"}),(0,l.jsx)("option",{value:"18px",children:"18px"}),(0,l.jsx)("option",{value:"20px",children:"20px"}),(0,l.jsx)("option",{value:"22px",children:"22px"}),(0,l.jsx)("option",{value:"24px",children:"24px"}),(0,l.jsx)("option",{value:"26px",children:"26px"}),(0,l.jsx)("option",{value:"28px",children:"28px"}),(0,l.jsx)("option",{value:"30px",children:"30px"}),(0,l.jsx)("option",{value:"32px",children:"32px"}),(0,l.jsx)("option",{value:"38px",children:"38px"}),(0,l.jsx)("option",{value:"40px",children:"40px"})]})]})]})}),(0,l.jsx)("input",{type:"text",id:"title-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.th,onChange:e=>r({...t,th:e.target.value}),placeholder:"TH"}),(0,l.jsx)("input",{type:"text",id:"title-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.en,onChange:e=>r({...t,en:e.target.value}),placeholder:"EN"})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"description",children:R.description}),(0,l.jsx)("div",{className:"flex flex-row items-center justify-between gap-2 w-full",children:(0,l.jsxs)("div",{className:"flex flex-row items-center gap-8",children:[(0,l.jsxs)("div",{className:"flex flex-row items-center gap-2 relative",children:[(0,l.jsx)("label",{htmlFor:"color",children:R.color}),(0,l.jsx)("div",{className:"h-8 w-20 border border-gray-300 rounded-xl cursor-pointer",style:{backgroundColor:null==g?void 0:g.descriptionColor},onClick:()=>{z((null==g?void 0:g.descriptionColor)||"#000000"),C("descriptionColor"===N?null:"descriptionColor")}}),"descriptionColor"===N&&(0,l.jsxs)("div",{className:"absolute z-50 top-full mt-2 left-0 bg-white dark:bg-gray-800 shadow-md border border-gray-300 p-3 rounded-md flex flex-col gap-2",children:[(0,l.jsx)("input",{type:"color",value:F,onChange:e=>z(e.target.value),className:"w-10 h-10 cursor-pointer"}),(0,l.jsx)("input",{type:"text",value:F,onChange:e=>z(e.target.value.startsWith("#")?e.target.value:"#".concat(e.target.value)),className:"border border-gray-300 rounded-md p-1 w-[100px] text-sm dark:bg-gray-700 dark:text-white",placeholder:"#000000"}),(0,l.jsx)("button",{onClick:()=>{x({...g,desecriptionColor:F}),C(null)},className:"px-3 py-1 bg-blue-500 hover:bg-blue-600 text-white rounded-md text-sm",children:"à¹à¸¥à¸·à¸à¸"})]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("label",{htmlFor:"fontSize",children:R.fontSize}),(0,l.jsxs)("select",{name:"fontSize",id:"fontSize",className:"border border-gray-200 bg-white p-1 px-4 py-2 rounded-xl",value:null==g?void 0:g.descriptionFontSize,onChange:e=>x({...g,descriptionFontSize:e.target.value}),children:[(0,l.jsx)("option",{value:"12px",children:"12px"}),(0,l.jsx)("option",{value:"14px",children:"14px"}),(0,l.jsx)("option",{value:"16px",children:"16px"}),(0,l.jsx)("option",{value:"18px",children:"18px"}),(0,l.jsx)("option",{value:"20px",children:"20px"}),(0,l.jsx)("option",{value:"22px",children:"22px"}),(0,l.jsx)("option",{value:"24px",children:"24px"}),(0,l.jsx)("option",{value:"26px",children:"26px"}),(0,l.jsx)("option",{value:"28px",children:"28px"}),(0,l.jsx)("option",{value:"30px",children:"30px"}),(0,l.jsx)("option",{value:"32px",children:"32px"}),(0,l.jsx)("option",{value:"38px",children:"38px"}),(0,l.jsx)("option",{value:"40px",children:"40px"})]})]})]})}),(0,l.jsx)("textarea",{type:"text",id:"description-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:s.th,onChange:e=>o({...s,th:e.target.value}),placeholder:"TH",rows:4}),(0,l.jsx)("textarea",{type:"text",id:"description-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:s.en,onChange:e=>o({...s,en:e.target.value}),placeholder:"EN",rows:4})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[(0,l.jsx)("div",{className:"relative",children:n&&n.url&&(0,l.jsx)(i(),{src:n.url,alt:"image",width:200,height:200,className:"object-cover",priority:!0})}),(0,l.jsx)(u.A,{size:24,onUpload:e=>{d(e[0])},folder:"sections"})]}),(0,l.jsxs)("div",{className:"flex justify-center items-center gap-4 w-full mt-5",children:[(0,l.jsx)("button",{onClick:f,className:"bg-orange-500 hover:bg-orange-600 p-2 rounded-md text-white font-bold",children:R.save}),(0,l.jsx)("button",{onClick:()=>{r({}),o({}),d({}),setContents({}),b("th"),y(!1)},className:"bg-red-500 hover:bg-red-600 p-2 rounded-md text-white font-bold",children:R.cancel})]})]})})}let W={title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¸³à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},image:{url:"/images/sections/sample-image-500x210.png"},style:{bgColor:"#757474",titleColor:"#f5f2f2",titleFontSize:"40px",desecriptionColor:"#f5f2f2",descriptionFontSize:"20px"}};
1function $(e){let{title:t,setTitle:r,description:a,setDescription:s,contents:i,setContents:o,style:n,setStyle:d,language:g,setLanguage:u,setEditMode:x,handleSubmit:p}=e,{t:m,lang:h}=(0,c.A)();return(0,l.jsx)("div",{className:"w-full",children:(0,l.jsxs)("div",{className:"flex flex-col border border-gray-300 rounded-md p-4 gap-2 shadow-lg",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"title",children:h.title}),(0,l.jsx)("input",{type:"text",id:"title-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:null==t?void 0:t.th,onChange:e=>r({...t,th:e.target.value}),placeholder:"TH"}),(0,l.jsx)("input",{type:"text",id:"title-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:null==t?void 0:t.en,onChange:e=>r({...t,en:e.target.value}),placeholder:"EN"})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"description",children:h.description}),(0,l.jsx)("textarea",{type:"text",id:"description-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:null==a?void 0:a.th,onChange:e=>s({...a,th:e.target.value}),placeholder:"TH",rows:4}),(0,l.jsx)("textarea",{type:"text",id:"description-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:null==a?void 0:a.en,onChange:e=>s({...a,en:e.target.value}),placeholder:"EN",rows:4})]}),(0,l.jsxs)("div",{className:"flex flex-row items-center gap-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"gap",children:h.gap}),(0,l.jsx)("input",{type:"number",id:"gap",name:"gap",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-1/4 p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:null==n?void 0:n.gap,onChange:e=>d({...n,gap:e.target.value})})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"cols",children:h.cols}),(0,l.jsx)("input",{type:"number",id:"cols",name:"cols",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-1/4 p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:null==n?void 0:n.cols,onChange:e=>d({...n,cols:e.target.value})})]})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"contents",children:h.content}),(0,l.jsxs)("select",{name:"contents",id:"contents",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-1/2 p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:i,onChange:e=>o(e.target.value),children:[(0,l.jsxs)("option",{value:"",children:["à¹à¸¥à¸·à¸à¸ ",h.content]}),(0,l.jsx)("option",{value:"courses",children:"Courses"}),(0,l.jsx)("option",{value:"online-courses",children:"Online Courses"}),(0,l.jsx)("option",{value:"articles",children:"Articles"}),(0,l.jsx)("option",{value:"blog",children:"Blog"})]})]}),(0,l.jsxs)("div",{className:"flex justify-center items-center gap-4 w-full mt-5",children:[(0,l.jsx)("button",{onClick:p,className:"bg-orange-500 hover:bg-orange-600 p-2 rounded-md text-white font-bold",children:h.save}),(0,l.jsx)("button",{onClick:()=>{r({}),s({}),o({}),u("th"),x(!1)},className:"bg-red-500 hover:bg-red-600 p-2 rounded-md text-white font-bold",children:h.cancel})]})]})})}function q(e){var t,r,a;let{item:s,pathname:o}=e,{t:n,lang:d}=(0,c.A)(),u=(0,g.useRouter)();return(0,l.jsxs)("div",{className:"bg-gray-100 rounded-lg overflow-hidden shadow-sm flex flex-col h-[400px] w-full cursor-pointer",children:[(0,l.jsx)("div",{className:"flex relative w-full h-[210px] bg-white hover:scale-105 transition-all duration-500 ease-in-out ",onClick:()=>u.push("/".concat(o,"/").concat(null==s?void 0:s.slug)),children:(0,l.jsx)(i(),{src:(null==s?void 0:null===(t=s.image)||void 0===t?void 0:t.url)?null==s?void 0:null===(r=s.image)||void 0===r?void 0:r.url:"/images/sample-content.png",alt:null==s?void 0:null===(a=s.name)||void 0===a?void 0:a.en,width:700,height:700,className:"object-cover"})}),(0,l.jsxs)("div",{className:"p-2 flex flex-col justify-between flex-1",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-lg text-orange-500 font-semibold line-clamp-3 leading-tight text-left",children:n(null==s?void 0:s.name)}),(0,l.jsx)("span",{className:"text-sm text-gray-600 font-light line-clamp-3 leading-tight text-left mt-2",children:n(null==s?void 0:s.description)})]}),(0,l.jsx)("div",{className:"flex justify-center items-center mt-2 mb-2",children:(0,l.jsx)("button",{className:"bg-orange-500 px-6 py-2 font-bold text-white rounded-md hover:bg-orange-600",onClick:()=>u.push((null==s?void 0:s.group)?"/".concat(o,"/").concat(null==s?void 0:s.group,"/").concat(null==s?void 0:s.slug):"/".concat(o,"/").concat(null==s?void 0:s.slug)),children:d.read_more})})]})]})}let X={title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¸³à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},contents:[{id:1,image:{url:"/images/sections/sample-image-500x210.png"},title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},slug:"1"},{id:2,image:{url:"/images/sections/sample-image-500x210.png"},title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},slug:"2"},{id:3,image:{url:"/images/sections/sample-image-500x210.png"},title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},slug:"3"},{id:4,image:{url:"/images/sections/sample-image-500x210.png"},title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},slug:"3"}],style:{bgColor:"#757474",titleColor:"#f5f2f2",titleFontSize:"40px",desecriptionColor:"#f5f2f2",descriptionFontSize:"20px",gap:8,cols:3}};
1function Z(e){let{title:t,setTitle:r,description:a,setDescription:s,contents:i,setContents:o,style:n,setStyle:d,language:g,setLanguage:u,setEditMode:x,handleSubmit:p}=e,{t:m,lang:h}=(0,c.A)();return(0,l.jsx)("div",{className:"w-full",children:(0,l.jsxs)("div",{className:"flex flex-col border border-gray-300 rounded-md p-4 gap-2 shadow-lg",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"title",children:h.title}),(0,l.jsx)("input",{type:"text",id:"title-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.th,onChange:e=>r({...t,th:e.target.value}),placeholder:"TH"}),(0,l.jsx)("input",{type:"text",id:"title-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.en,onChange:e=>r({...t,en:e.target.value}),placeholder:"EN"})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"description",children:h.description}),(0,l.jsx)("textarea",{type:"text",id:"description-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:a.th,onChange:e=>s({...a,th:e.target.value}),placeholder:"TH",rows:4}),(0,l.jsx)("textarea",{type:"text",id:"description-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:a.en,onChange:e=>s({...a,en:e.target.value}),placeholder:"EN",rows:4})]}),(0,l.jsxs)("div",{className:"flex flex-row items-center gap-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"gap",children:h.gap}),(0,l.jsx)("input",{type:"number",id:"gap",name:"gap",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-1/4 p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:n.gap,onChange:e=>d({...n,gap:e.target.value})})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"cols",children:h.cols}),(0,l.jsx)("input",{type:"number",id:"cols",name:"cols",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-1/4 p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:n.cols,onChange:e=>d({...n,cols:e.target.value})})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"limit",children:h.limit_data}),(0,l.jsx)("input",{type:"number",id:"limit",name:"limit",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-1/4 p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:n.limited,onChange:e=>d({...n,limited:e.target.value})})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"showMore",children:h.show_more}),(0,l.jsx)("input",{type:"checkbox",id:"showMore",name:"showMore",value:n.showMore,onChange:e=>d({...n,showMore:e.target.checked})})]})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"contents",children:h.content}),(0,l.jsxs)("select",{name:"contents",id:"contents",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-1/2 p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:i,onChange:e=>o(e.target.value),children:[(0,l.jsxs)("option",{value:"",children:["à¹à¸¥à¸·à¸à¸ ",h.content]}
1),(0,l.jsx)("option",{value:"courses",children:"Courses"}),(0,l.jsx)("option",{value:"articles",children:"Articles"}),(0,l.jsx)("option",{value:"blog",children:"Blog"})]})]}),(0,l.jsxs)("div",{className:"flex justify-center items-center gap-4 w-full mt-5",children:[(0,l.jsx)("button",{onClick:p,className:"bg-orange-500 hover:bg-orange-600 p-2 rounded-md text-white font-bold",children:h.save}),(0,l.jsx)("button",{onClick:()=>{r({}),s({}),o({}),u("th"),x(!1)},className:"bg-red-500 hover:bg-red-600 p-2 rounded-md text-white font-bold",children:h.cancel})]})]})})}var K=r(95093),V=r.n(K);r(55802),V().locale("th");let Q={title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¸³à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},contents:"courses",path:"public_courses",style:{gap:2,cols:2,limited:5,showMore:!0}};var ee=r(46942),et=r.n(ee);let er=[{id:1,image:{url:"/images/sections/sample-image-500x210.png"},title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},url:"https://www.thenewyou.co.th"},{id:2,image:{url:"/images/sections/sample-image-500x210.png"},title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},url:"https://www.thenewyou.co.th"},{id:3,image:{url:"/images/sections/sample-image-500x210.png"},title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},url:"https://www.thenewyou.co.th"},{id:4,image:{url:"/images/sections/sample-image-500x210.png"},title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},url:"https://www.thenewyou.co.th"}];var el=r(13554),ea=r.n(el),es=r(94335),ei=r(77037);function eo(e){let{title:t,setTitle:r,description:s,setDescription:o,contents:n,setContents:d,style:g,setStyle:u,language:x,setLanguage:p,setEditMode:m,handleSubmit:h}=e,[b,y]=(0,a.useState)(!1),[f,v]=(0,a.useState)(null),[j,w]=(0,a.useState)(""),[k,N]=(0,a.useState)({}),{t:C,lang:S}=(0,c.A)();(0,a.useEffect)(()=>{j?(async()=>{try{let e=await es.A.post("/api/get-youtube",{youtubeUrl:j});N(e.data)}catch(t){var e;console.error("Error fetching YouTube data:",(null===(e=t.response)||void 0===e?void 0:e.data)||t.message)}})():N({})},[j]),console.log("youtube",k);let E=e=>{var t;v(e),w((null===(t=e.video)||void 0===t?void 0:t.url)||e.videoUrl||""),N(e.video||{}),y(!0)},_=e=>{d(n.filter((t,r)=>r!==e))},A=()=>{w(""),N({}),v(null),y(!1)},F=e=>{if(e<=0)return;let t=[...n];[t[e-1],t[e]]=[t[e],t[e-1]],d(t)},z=e=>{if(e>=n.length-1)return;let t=[...n];[t[e+1],t[e]]=[t[e],t[e+1]],d(t)};return(0,l.jsx)("div",{className:"w-full",children:(0,l.jsxs)("div",{className:"flex flex-col border border-gray-300 rounded-md p-4 gap-2 shadow-lg",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"title",children:S.title}),(0,l.jsx)("input",{type:"text",id:"title-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.th,onChange:e=>r({...t,th:e.target.value}),placeholder:"TH"}),(0,l.jsx)("input",{type:"text",id:"title-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.en,onChange:e=>r({...t,en:e.target.value}),placeholder:"EN"})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"description",children:S.description}),(0,l.jsx)("textarea",{type:"text",id:"description-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:s.th,onChange:e=>o({...s,th:e.target.value}),placeholder:"TH",rows:4}),(0,l.jsx)("textarea",{type:"text",id:"description-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:s.en,onChange:e=>o({...s,en:e.target.value}),placeholder:"EN",rows:4})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("h2",{className:"font-bold mb-1",children:"Youtube Link"}),(0,l.jsx)(M.A,{sx:{mb:2}}),(0,l.jsx)("button",{onClick:()=>y(!0),className:"bg-blue-500 text-white px-4 py-2 rounded-md",children:"à¹à¸à¸´à¹à¸¡à¸§à¸´à¸à¸µà¹à¸"}),(0,l.jsx)("div",{className:"flex flex-col mt-2",children:n.map((e,t)=>(0,l.jsxs)("div",{className:"flex flex-row items-center justify-between border p-2 rounded-xl mb-1 w-1/2 bg-gray-100",children:[(0,l.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[(0,l.jsxs)("div",{className:"flex items-center",children:[(0,l.jsx)("button",{onClick:()=>F(t),title:"Move Up",children:"â¬ï¸"}),(0,l.jsx)("button",{onClick:()=>z(t),title:"Move Down",children:"â¬ï¸"})]}),(0,l.jsx)("h5",{className:"flex-1",children:e.title})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(ei.uO9,{size:20,className:"text-blue-500 cursor-pointer",onClick:()=>E(e)}),(0,l.jsx)(ei.RCe,{size:20,className:"text-red-500 cursor-pointer",onClick:()=>_(t)})]})]},t))}),b&&(0,l.jsxs)("div",{className:"flex flex-col bg-gray-100 border rounded-md p-4 mt-4",children:[(0,l.jsx)("h3",{className:"font-bold",children:"สรà¹à¸²à¸à¸§à¸´à¸à¸µà¹à¸"}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"url",children:"URL"}),(0,l.jsx)("input",{type:"text",id:"url",name:"url",value:j,className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",onChange:e=>w(e.target.value),placeholder:"https://www.youtube.com/watch?v=..."})]}),k&&k.thumbnailUrl&&(0,l.jsx)("div",{children:(0,l.jsx)(i(),{src:k.thumbnailUrl,alt:"Thumbn
1ail",width:200,height:200})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"videoTitle",children:S.title}),(0,l.jsx)("input",{type:"text",id:"videoTitle",name:"videoTitle",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:null==k?void 0:k.title,onChange:e=>N({...k,title:e.target.value})})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"videoDescription",children:S.description}),(0,l.jsx)("textarea",{type:"text",id:"videoDescription",name:"videoDescription",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:null==k?void 0:k.description,onChange:e=>N({...k,description:e.target.value}),rows:4})]}),(0,l.jsxs)("div",{className:"flex justify-center gap-4",children:[(0,l.jsx)("button",{onClick:()=>{if(!(null==k?void 0:k.videoId)){alert("à¸à¸£à¸¸à¸à¸²à¸à¸£à¸à¸à¸¥à¸´à¸à¸à¹ YouTube à¹à¸«à¹à¸à¸¹à¸à¸à¹à¸à¸");return}let e={video:k,title:k.title,description:k.description};f?d(n.map(t=>t.video.videoId===f.video.videoId?e:t)):d([...n,e]),A()},className:"bg-orange-500 hover:bg-orange-600 p-2 rounded-md text-white font-bold",children:S.save}),(0,l.jsx)("button",{onClick:A,className:"bg-red-500 hover:bg-red-600 p-2 rounded-md text-white font-bold",children:S.cancel})]})]})]})]}),(0,l.jsxs)("div",{className:"flex justify-center items-center gap-4 w-full mt-5",children:[(0,l.jsx)("button",{onClick:h,className:"bg-orange-500 hover:bg-orange-600 p-2 rounded-md text-white font-bold",children:S.save}),(0,l.jsx)("button",{onClick:()=>{p("th"),m(!1)},className:"bg-red-500 hover:bg-red-600 p-2 rounded-md text-white font-bold",children:S.cancel})]})]})})}let en={title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},contents:[{id:1,video:{url:"https://www.youtube.com/watch?v=X8gIsliON6E",title:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",description:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢"},title:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",description:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢"},{id:2,video:{url:"https://www.youtube.com/watch?v=wdFbQNeGMeE",title:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",description:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢"},title:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",description:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢"},{id:3,video:{url:"https://www.youtube.com/watch?v=7hHGArlI7g4",title:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",description:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢"},title:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",description:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢"},{id:4,video:{url:"https://www.youtube.com/watch?v=U-0WbD3DbZg",title:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",description:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢"},title:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",description:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢"}],style:{color:"#ff0000",backgroundColor:"#00ff00",fontSize:"24px",fontWeight:"bold"}};function ed(e){let{url:t,onPlay:r}=e,[s,i]=(0,a.useState)(!1);return(0,l.jsx)("div",{onMouseEnter:()=>{i(!0),null==r||r(!0)},onMouseLeave:()=>{i(!1),null==r||r(!1)},className:"w-full h-full",children:(0,l.jsx)(ea(),{url:t,playing:s,controls:!0,loop:!0,muted:!0,width:"100%",height:"100%"})})}var ec=r(82790),eg=r(43627),eu=r(74979);function ex(e){let{id:t,children:r}=e,{attributes:a,listeners:s,setNodeRef:i,transform:o,transition:n}=(0,eg.gl)({id:t}),d={transform:eu.Ks.Transform.toString(o),transition:n};return(0,l.jsx)("div",{ref:i,style:d,...a,...s,children:r})}
1function ep(e){let{title:t,setTitle:r,description:s,setDescription:i,contents:o,setContents:n,language:d,setLanguage:g,setEditMode:u,handleSubmit:h}=e,[y,f]=(0,a.useState)(""),[v,j]=(0,a.useState)({}),{t:w,lang:k}=(0,c.A)(),N=(0,ec.FR)((0,ec.MS)(ec.AN));(0,a.useEffect)(()=>{(async()=>{if(y){let e=(0,m.P)((0,m.rJ)(p.db,y),(0,m._M)("active","==",!0));j((await (0,m.GG)(e)).docs.map(e=>({id:e.id,...e.data()})))}})()},[y]);let C=e=>(null==e?void 0:e[d])||"",S=e=>{o.find(t=>t.id===e.id)?n(t=>t.filter(t=>t.id!==e.id)):o.length<5?n(t=>[...t,e]):b.oR.error("สามารà¸à¹à¸¥à¸·à¸à¸à¹à¸à¹à¸ªà¸¹à¸à¸ªà¸¸à¸ 4 รายà¸à¸²à¸£")},E=e=>{n(t=>t.filter(t=>t.id!==e.id))};return(0,l.jsx)("div",{className:"w-full",children:(0,l.jsxs)("div",{className:"flex flex-col border border-gray-300 rounded-md p-4 gap-2 shadow-lg",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"title",children:k.title}),(0,l.jsx)("input",{type:"text",id:"title-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:null==t?void 0:t.th,onChange:e=>r({...t,th:e.target.value}),placeholder:"TH"}),(0,l.jsx)("input",{type:"text",id:"title-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:null==t?void 0:t.en,onChange:e=>r({...t,en:e.target.value}),placeholder:"EN"})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"description",children:k.description}),(0,l.jsx)("textarea",{type:"text",id:"description-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:null==s?void 0:s.th,onChange:e=>i({...s,th:e.target.value}),placeholder:"TH",rows:4}),(0,l.jsx)("textarea",{type:"text",id:"description-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:null==s?void 0:s.en,onChange:e=>i({...s,en:e.target.value}),placeholder:"EN",rows:4})]}),(0,l.jsx)("div",{className:"flex flex-col gap-2",children:(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,l.jsxs)("div",{className:"flex flex-col border rounded-xl p-2",children:[(0,l.jsx)("h3",{children:"Contents"}),(0,l.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[(0,l.jsx)("label",{htmlFor:"data",children:"Data:"}),(0,l.jsxs)("select",{id:"data",value:y,onChange:e=>f(e.target.value),className:"border rounded-md p-1",children:[(0,l.jsx)("option",{value:"",children:"Select Data"}),(0,l.jsx)("option",{value:"courses",children:"Courses"}),(0,l.jsx)("option",{value:"blogs",children:"Blog"}),(0,l.jsx)("option",{value:"articles",children:"Article"}),(0,l.jsx)("option",{value:"news",children:"News"})]})]}),(0,l.jsx)("div",{className:"flex flex-col gap-2 mt-2",children:v&&v.length>0?v.filter(e=>!o.find(t=>t.id===e.id)).map(e=>(0,l.jsx)("div",{className:"flex flex-row items-center gap-2 cursor-pointer border rounded-xl px-2 py-1 bg-gray-100 hover:bg-gray-200",onClick:()=>S(e),children:(0,l.jsx)("span",{className:"text-sm",children:C(e.name)})},e.id)):(0,l.jsx)("span",{className:"text-sm",children:"No data"})})]}),(0,l.jsxs)("div",{className:"border rounded-xl p-2",children:[(0,l.jsx)("h3",{children:"Select Contents"}),(0,l.jsx)(ec.Mp,{sensors:N,collisionDetection:ec.fp,onDragEnd:e=>{let{active:t,over:r}=e;if(t.id!==(null==r?void 0:r.id)){let e=o.findIndex(e=>e.id===t.id),l=o.findIndex(e=>e.id===r.id);n(t=>(0,eg.be)(t,e,l))}},children:(0,l.jsx)(eg.gB,{items:o.map(e=>e.id),strategy:eg._G,children:(0,l.jsx)("div",{className:"flex flex-col gap-2 mt-2",children:o.length>0?o.map(e=>(0,l.jsx)(ex,{item:e,renderLabel:C,handleRemoveContent:E,children:(0,l.jsxs)("div",{className:"flex flex-row items-center justify-between gap-2 cursor-pointer border rounded-xl px-2 py-1 bg-gray-100 hover:bg-gray-200",children:[(0,l.jsx)("span",{className:"text-sm",children:C(e.name)}),(0,l.jsx)(x.$8F,{size:20,className:"cursor-pointer text-red-500",onClick:t=>{t.stopPropagation(),E(e)}})]})},e.id)):(0,l.jsx)("span",{className:"text-sm",children:"No data"})})})})]})]})}),(0,l.jsxs)("div",{className:"flex justify-center items-center gap-4 w-full mt-5",children:[(0,l.jsx)("button",{onClick:h,className:"bg-orange-500 hover:bg-orange-600 p-2 rounded-md text-white font-bold",children:k.save}),(0,l.jsx)("button",{onClick:()=>{g("th"),u(!1)},className:"bg-red-500 hover:bg-red-600 p-2 rounded-md text-white font-bold",children:k.cancel})]})]})})}V().locale("th");let em={title:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},contents:[{id:1,image:{url:"/images/sections/sample-image-500x210.png"},name:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},url:"https://www.thenewyou.co.th",createdAt:new Date},{id:2,image:{url:"/images/sections/sample-image-500x210.png"},name:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},url:"https://www.thenewyou.co.th",createdAt:new Date},{id:3,image:{url:"/images/sections/sample-image-500x210.png"},name:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},url:"https://www.thenewyou.co.th",createdAt:new Date},{id:4,image:{url:"/images/sections/sample-image-500x210.png"},name:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},url:"https://www.thenewyou.co.th",createdAt:new Date},{id:5,image:{url:"/images/sections/sample-image-500x210.png"},name:{th:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",en:"Sample title"},description:{th:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢",en:"English description"},url:"https://www.thenewyou.co.th",createdAt:new Date}],style:{color:"#ff0000",backgroundColor:"#00ff00",fontSize:"24px",fontWeight:"bold"}};
1function eh(e){let{contents:t,setContents:r,style:s,setStyle:o,language:n,setLanguage:d,setEditMode:g,handleSubmit:u}=e,[x,p]=(0,a.useState)(!1),[m,h]=(0,a.useState)(null),[b,y]=(0,a.useState)(""),[f,v]=(0,a.useState)({}),{t:j,lang:w}=(0,c.A)();(0,a.useEffect)(()=>{b?(async()=>{try{let e=await es.A.post("/api/get-youtube",{youtubeUrl:b});v(e.data)}catch(t){var e;console.error("Error fetching YouTube data:",(null===(e=t.response)||void 0===e?void 0:e.data)||t.message)}})():v({})},[b]);let k=e=>{var t;h(e),y((null===(t=e.video)||void 0===t?void 0:t.url)||e.videoUrl||""),v(e.video||{}),p(!0)},N=e=>{r(t.filter((t,r)=>r!==e))},C=()=>{y(""),v({}),h(null),p(!1)},S=e=>{if(e<=0)return;let l=[...t];[l[e-1],l[e]]=[l[e],l[e-1]],r(l)},E=e=>{if(e>=t.length-1)return;let l=[...t];[l[e+1],l[e]]=[l[e],l[e+1]],r(l)};return(0,l.jsx)("div",{className:"w-full",children:(0,l.jsxs)("div",{className:"flex flex-col border border-gray-300 rounded-md p-4 gap-2 shadow-lg",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("h2",{className:"font-bold mb-1",children:"Youtube Link"}),(0,l.jsx)(M.A,{sx:{mb:2}}),(0,l.jsx)("button",{onClick:()=>p(!0),className:"bg-blue-500 text-white px-4 py-2 rounded-md",children:"à¹à¸à¸´à¹à¸¡à¸§à¸´à¸à¸µà¹à¸"}),(0,l.jsx)("div",{className:"flex flex-col mt-2",children:t.map((e,t)=>(0,l.jsxs)("div",{className:"flex flex-row items-center justify-between border p-2 rounded-xl mb-1 w-1/2 bg-gray-100",children:[(0,l.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[(0,l.jsxs)("div",{className:"flex items-center",children:[(0,l.jsx)("button",{onClick:()=>S(t),title:"Move Up",children:"â¬ï¸"}),(0,l.jsx)("button",{onClick:()=>E(t),title:"Move Down",children:"â¬ï¸"})]}),(0,l.jsx)("h5",{className:"flex-1",children:e.title})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(ei.uO9,{size:20,className:"text-blue-500 cursor-pointer",onClick:()=>k(e)}),(0,l.jsx)(ei.RCe,{size:20,className:"text-red-500 cursor-pointer",onClick:()=>N(t)})]})]},t))}),x&&(0,l.jsxs)("div",{className:"flex flex-col bg-gray-100 border rounded-md p-4 mt-4",children:[(0,l.jsx)("h3",{className:"font-bold",children:"สรà¹à¸²à¸à¸§à¸´à¸à¸µà¹à¸"}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"url",children:"URL"}),(0,l.jsx)("input",{type:"text",id:"url",name:"url",value:b,className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",onChange:e=>y(e.target.value),placeholder:"https://www.youtube.com/watch?v=..."})]}),f&&f.thumbnailUrl&&(0,l.jsx)("div",{children:(0,l.jsx)(i(),{src:f.thumbnailUrl,alt:"Thumbnail",width:200,height:200})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"videoTitle",children:w.title}),(0,l.jsx)("input",{type:"text",id:"videoTitle",name:"videoTitle",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:null==f?void 0:f.title,onChange:e=>v({...f,title:e.target.value})})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"videoDescription",children:w.description}),(0,l.jsx)("textarea",{type:"text",id:"videoDescription",name:"videoDescription",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:null==f?void 0:f.description,onChange:e=>v({...f,description:e.target.value}),rows:4})]}),(0,l.jsxs)("div",{className:"flex justify-center gap-4",children:[(0,l.jsx)("button",{onClick:()=>{if(!(null==f?void 0:f.videoId)){alert("à¸à¸£à¸¸à¸à¸²à¸à¸£à¸à¸à¸¥à¸´à¸à¸à¹ YouTube à¹à¸«à¹à¸à¸¹à¸à¸à¹à¸à¸");return}
1let e={video:f,title:f.title,description:f.description};m?r(t.map(t=>t.video.videoId===m.video.videoId?e:t)):r([...t,e]),C()},className:"bg-orange-500 hover:bg-orange-600 p-2 rounded-md text-white font-bold",children:w.save}),(0,l.jsx)("button",{onClick:C,className:"bg-red-500 hover:bg-red-600 p-2 rounded-md text-white font-bold",children:w.cancel})]})]})]})]}),(0,l.jsxs)("div",{className:"flex justify-center items-center gap-4 w-full mt-5",children:[(0,l.jsx)("button",{onClick:u,className:"bg-orange-500 hover:bg-orange-600 p-2 rounded-md text-white font-bold",children:w.save}),(0,l.jsx)("button",{onClick:()=>{d("th"),g(!1)},className:"bg-red-500 hover:bg-red-600 p-2 rounded-md text-white font-bold",children:w.cancel})]})]})})}let eb={contents:[{id:1,video:{url:"https://www.youtube.com/shorts/hBTxCzXanV0",type:"short",title:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",description:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢"},title:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",description:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢"},{id:2,video:{url:"https://www.youtube.com/shorts/y5NKozzDpOA",type:"short",title:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",description:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢"},title:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",description:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢"},{id:3,video:{url:"https://www.youtube.com/shorts/U5hhH--Z-yo",type:"short",title:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",description:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢"},title:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",description:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢"},{id:4,video:{url:"https://www.youtube.com/shorts/LT-tEVu_PMc",type:"short",title:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",description:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢"},title:"à¸à¸à¸ªà¸à¸à¸«à¸±à¸§à¹à¸£à¸·à¹à¸à¸",description:"à¸à¹à¸²à¸à¸à¸´à¸à¸²à¸¢à¸ าษาà¹à¸à¸¢"}]};function ey(e){let{url:t}=e,[r,s]=(0,a.useState)(!1);return(0,l.jsx)("div",{onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),className:"w-full h-full",children:(0,l.jsx)(ea(),{url:t,playing:r,loop:!0,muted:!0,controls:!1,width:"100%",height:"100%",style:{pointerEvents:"none"}})})}var ef=r(94650),ev=r(31420);let ej=a.forwardRef(function(e,t){return(0,l.jsx)(D.A,{direction:"up",ref:t,...e})});function ew(e){let{title:t,setTitle:r,description:s,setDescription:i,contents:o,setContents:n,style:d,setStyle:g,language:u,setLanguage:p,setEditMode:m,handleSubmit:h}=e,[b,y]=(0,a.useState)([]),[f,v]=(0,a.useState)(!1),{t:j,lang:w}=(0,c.A)(),k=()=>v(!1);return(0,l.jsxs)("div",{className:"w-full",children:[(0,l.jsxs)("div",{className:"flex flex-col border border-gray-300 rounded-md p-4 gap-2 shadow-lg",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"title",children:w.title}),(0,l.jsx)("input",{type:"text",id:"title-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.th,onChange:e=>r({...t,th:e.target.value}),placeholder:"TH"}),(0,l.jsx)("input",{type:"text",id:"title-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:t.en,onChange:e=>r({...t,en:e.target.value}),placeholder:"EN"})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"description",children:w.description}),(0,l.jsx)("textarea",{type:"text",id:"description-th",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:s.th,onChange:e=>i({...s,th:e.target.value}),placeholder:"TH",rows:4}),(0,l.jsx)("textarea",{type:"text",id:"description-en",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:s.en,onChange:e=>i({...s,en:e.target.value}),placeholder:"EN",rows:4})]}),(0,l.jsxs)("div",{className:"flex flex-row items-center gap-8",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"gap",children:w.gap}),(0,l.jsx)("input",{type:"number",name:"gap",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:d.gap,onChange:e=>g({...d,gap:e.target.value})})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"cols",children:w.
1cols}),(0,l.jsx)("input",{type:"number",name:"cols",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:d.cols,onChange:e=>g({...d,cols:e.target.value})})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"size",children:w.size}),(0,l.jsx)("input",{type:"number",name:"size",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:d.size,onChange:e=>g({...d,size:e.target.value})})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{htmlFor:"limit",children:w.limit_data}),(0,l.jsx)("input",{type:"number",name:"limit",className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-1.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500",value:d.limited,onChange:e=>g({...d,limited:e.target.value})})]})]}),(0,l.jsx)(M.A,{}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsx)("label",{htmlFor:"",className:"font-bold",children:"Youtube"}),(0,l.jsx)("div",{className:"flex flex-col gap-2 mb-2",children:(0,l.jsx)("div",{children:o.length>0&&o.map(e=>(0,l.jsxs)("div",{className:"flex items-center justify-between gap-2 border bg-gray-300 hover:bg-gray-400 py-2 px-6 rounded-xl text-black w-1/2 cursor-pointer",children:[(0,l.jsx)("span",{children:e.title}),(0,l.jsx)("div",{className:"bg-red-500 hover:bg-red-600 p-1 rounded-full text-white cursor-pointer",children:(0,l.jsx)(x.$8F,{size:15})})]},e.id))})}),(0,l.jsx)("button",{className:"flex items-center gap-2 border border-gray-300 hover:bg-gray-400 p-2 rounded-xl text-black font-bold w-56",onClick:()=>v(!0),children:(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(ef.Jvf,{size:40,className:"text-red-500"}),(0,l.jsx)("span",{children:"Youtube Managements"})]})})]}),(0,l.jsxs)("div",{className:"flex justify-center items-center gap-4 w-full mt-5",children:[(0,l.jsx)("button",{onClick:h,className:"bg-orange-500 hover:bg-orange-600 p-2 rounded-md text-white font-bold",children:w.save}),(0,l.jsx)("button",{onClick:()=>{r({}),i({}),n([]),g({}),y([]),p("th"),m(!1)},className:"bg-red-500 hover:bg-red-600 p-2 rounded-md text-white font-bold",children:w.cancel})]})]}),(0,l.jsx)(L.A,{fullScreen:!0,open:f,onClose:k,TransitionComponent:ej,"aria-labelledby":"alert-dialog-title",children:(0,l.jsx)(ev.A,{onClose:k,contents:o,setContents:n})})]})}var ek=r(14953),eN=r.n(ek);let eC=eN()(()=>r.e(2795).then(r.t.bind(r,22795,23)),{loadableGenerated:{webpack:()=>[22795]},ssr:!1}),eS={title:{th:"",en:""},description:{th:"",en:""},style:{gap:2,cols:1,limited:1,size:600},contents:[{title:"รูà¹à¸à¸±à¸à¸à¸²à¸à¸²à¸£à¸¢à¹à¹à¸à¹à¹à¸à¸´à¹à¸¡à¹à¸à¸´à¸¡à¹à¸à¹à¸à¸µà¹à¸à¸µà¹",url:"https://www.youtube.com/watch?v=4_aUnD3b0_g"},{title:"Miracle of You l MOU à¹à¸à¹à¸à¸µà¸§à¸´à¸à¹à¸à¸à¹à¸¡à¹à¸à¸±à¸à¸à¹à¸à¸ สูà¹à¹à¸à¸§à¸±à¸à¹ - EP.1",url:"https://www.youtube.com/watch?v=X8gIsliON6E"}]};var eE=r(50039);r(56195);var e_=r(33013),eA=r(78465),eF=r.n(eA),ez=r(71468),eH=r(56103);function eR(e){let{course:t}=e,[r,s]=(0,a.useState)(!1),i=(0,ez.wA)(),o=(0,g.useRouter)(),{subscribe:n,getById:d,update:u}=(0,j.A)("appdata"),{t:x,lang:p}=(0,c.A)();return(0,a.useEffect)(()=>{let e=d("app",e=>{e&&s(e.isUsePayment)});return()=>e()},[]),r?(0,l.jsxs)("div",{className:"flex gap-4",children:[(0,l.jsx)(I.A,{title:p.add_cart,placement:"top",children:(0,l.jsxs)("button",{onClick:()=>{i((0,eH.bE)({courseId:t.id,title:t.name,price:t.price,image:t.image||"",type:t.type||"offline"}))},className:"flex items-center justify-center gap-2 bg-green-500 text-white px-4 py-2 rounded hover:bg-green-600 h-10",children:[(0,l.jsx)(P._xK,{size:20})," ",p.add_cart]})}),(0,l.jsx)(I.A,{title:p.buy_now,placement:"top",children:(0,l.jsxs)("button",{onClick:()=>{i((0,eH.sX)()),i((0,eH.bE)({courseId:t.id,title:t.name,price:t.price,image:t.image||"",type:t.type||"offline"})),o.push("/payments/checkout")},className:"flex items-center justify-center gap-2 bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-500 h-10",children:[(0,l.jsx)(P.AI$,{})," ",p.buy_now]})})]}):null}eN()(()=>r.e(5922).then(r.bind(r,35922)),{loadableGenerated:{webpack:()=>[35922]},ssr:!1});var eT=r(47091);let eD=eN()(()=>r.e(5922).then(r.bind(r,35922)),{loadableGenerated:{webpack:()=>[35922]},ssr:!1});
1function eM(e){let{contents:t,setContents:r,language:a,setLanguage:s,setEditMode:i,handleSubmit:o}=e,{t:n,lang:d}=(0,c.A)(),g=e=>{r(t=>({...t,[a]:e}))};return(0,l.jsx)("div",{className:"w-full",children:(0,l.jsxs)("div",{className:"flex flex-col border border-gray-300 rounded-md p-4 gap-2 shadow-lg",children:[(0,l.jsxs)("div",{className:" w-full",children:[(0,l.jsxs)("div",{className:"flex flex-row items-center justify-end gap-2 w-full",children:[(0,l.jsx)("button",{className:"px-4 py-1 rounded-md font-bold transition ".concat("th"===a?"bg-blue-500 text-white":"bg-gray-300 dark:bg-gray-700"),onClick:()=>s("th"),children:"TH"}),(0,l.jsx)("button",{className:"px-4 py-1 rounded-md font-bold transition ".concat("en"===a?"bg-blue-500 text-white":"bg-gray-300 dark:bg-gray-700"),onClick:()=>s("en"),children:"EN"})]}),(0,l.jsx)(S.default,{content:t[a],onChange:e=>g(e)})]}),(0,l.jsxs)("div",{className:"flex justify-center items-center gap-4 w-full mt-5",children:[(0,l.jsx)("button",{onClick:o,className:"bg-orange-500 hover:bg-orange-600 p-2 rounded-md text-white font-bold",children:d.save}),(0,l.jsx)("button",{onClick:()=>{s("th"),i(!1),setTiptapContent({})},className:"bg-red-500 hover:bg-red-600 p-2 rounded-md text-white font-bold",children:d.cancel})]})]})})}V().locale("th"),V().locale("th"),r(78119);let eI=eN()(()=>r.e(5922).then(r.bind(r,35922)),{loadableGenerated:{webpack:()=>[35922]},ssr:!1}),eL={contents:{th:"<p>à¹à¸à¸·à¹à¸à¸«à¸²....</p>",en:"<p>Contents...</p>"}};function eP(e){let{course:t}=e,[r,s]=(0,a.useState)(!0),i=(0,ez.wA)(),o=(0,g.useRouter)(),{subscribe:n,getById:d,update:u}=(0,j.A)("appdata"),{t:x,lang:p}=(0,c.A)();return r?(0,l.jsxs)("div",{className:"flex gap-4",children:[(0,l.jsx)(I.A,{title:p.add_cart,placement:"top",children:(0,l.jsxs)("button",{onClick:()=>{i((0,eH.bE)({courseId:t.id,title:t.name,price:t.price,image:t.image||"",type:t.type||"offline"}))},className:"flex items-center justify-center gap-2 bg-green-500 text-white px-4 py-2 rounded hover:bg-green-600 h-10",children:[(0,l.jsx)(P._xK,{size:20})," ",p.add_cart]})}),(0,l.jsx)(I.A,{title:p.buy_now,placement:"top",children:(0,l.jsxs)("button",{onClick:()=>{i((0,eH.sX)()),i((0,eH.bE)({courseId:t.id,title:t.name,price:t.price,image:t.image||"",type:t.type||"offline"})),o.push("/payments/checkout")},className:"flex items-center justify-center gap-2 bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-500 h-10",children:[(0,l.jsx)(P.AI$,{})," ",p.buy_now]})})]}):null}V().locale("th"),eN()(()=>r.e(7288).then(r.bind(r,87288)),{loadableGenerated:{webpack:()=>[87288]},ssr:!1}),eN()(()=>r.e(7288).then(r.bind(r,87288)),{loadableGenerated:{webpack:()=>[87288]},ssr:!1});let eG=[{name:"carousel",description:{en:"slide show",th:"สà¹à¸¥à¸à¹à¹à¸à¸§à¹"},thumbnail:"/images/sections/previews/carousel.png",component:function(e){let{contentId:t,editMode:r,language:s,setLanguage:n,setEditMode:c}=e,[u,x]=(0,a.useState)({}),[f,v]=(0,a.useState)([]),[j,w]=(0,a.useState)(!0),[k,N]=(0,a.useState)(3e3);(0,a.useRef)(null);let C=(0,g.useRouter)();(0,a.useEffect)(()=>{(async()=>{if(!t){x(y.description),v(y.image),w(j),N(k);return}try{let e=(0,m.H9)(p.db,"sections",t),r=await (0,m.x7)(e);if(r.exists()){let e=r.data();x((null==e?void 0:e.description)||y.description),v((null==e?void 0:e.images)||y.image),w((null==e?void 0:e.autoPlay)||!0),N((null==e?void 0:e.autoPlaySpeed)||3e3)}else x(y.description),v(y.image),w(j),N(k)}catch(e){console.error("à¹à¸«à¸¥à¸ section à¸à¸´à¸à¸à¸¥à¸²à¸:",e)}})()},[t]);let S=async()=>{let e={description:u,images:f,autoPlay:j,autoPlaySpeed:k,component:"carousel"};try{if(t){let r=(0,m.H9)(p.db,"sections",t);await (0,m.BN)(r,e,{merge:!0}),b.oR.success("à¸à¸±à¸à¹à¸à¸à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢")}else{let t=await (0,m.gS)((0,m.rJ)(p.db,"sections"),e);b.oR.success("สรà¹à¸²à¸ section à¹à¸«à¸¡à¹à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢: "+t.id)}c(!1)}catch(e){console.error("à¹à¸à¸´à¸à¸à¹à¸à¸à¸´à¸à¸à¸¥à¸²à¸à¹à¸à¸à¸²à¸£à¸à¸±à¸à¸à¸¶à¸:",e),b.oR.error("à¸à¸±à¸à¸à¸¶à¸à¹à¸¡à¹à¸ªà¸³à¹à¸£à¹à¸")}};return console.log(f),(0,l.jsxs)("div",{className:"relative w-full",children:[(0,l.jsx)(o.A,{accessibility:!0,autoplay:j,autoplaySpeed:k,arrows:!1,dots:!0,infinite:!1,speed:500,slidesToShow:1,slidesToScroll:1,className:d().slider,children:f.map(e=>(0,l.jsx)("div",{className:"w-full bg-gray-900",onClick:(null==e?void 0:e.link)?()=>C.push(e.link):null,children:(0,l.jsx)(i(),{src:e.url,alt:"Slide ".concat(e.id),width:1500,height:1500,className:"relative w-full object-contain",loading:"lazy",style:{width:"100%",height:"100%",maxHeight:"900px"}},e.id)},e.id))}),r&&(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(h,{description:u,setDescription:x,images:f,setImages:v,setEditMode:c,autoPlay:j,setAutoPlay:w,autoPlaySpeed:k,setAutoPlaySpeed:N,language:s,setLanguage:n,handleSubmit:S})})]})},group:"slideshow"},{name:"layout1",description:{en:"image and text",th:"รูà¸à¹à¸¥à¸°à¸à¹à¸à¸à¸§à¸²à¸¡"},thumbnail:"/images/sections/previews/layout1.png",component:function(e){let{c
1ontentId:t,editMode:r,language:s,setLanguage:o,setEditMode:n}=e,[d,g]=(0,a.useState)({}),[u,x]=(0,a.useState)({}),[h,y]=(0,a.useState)(null),[f,v]=(0,a.useState)({}),{t:j}=(0,c.A)();(0,a.useEffect)(()=>{(async()=>{if(!t){g(_.title),x(_.description),y(_.image),v(_.contents);return}try{let e=(0,m.H9)(p.db,"sections",t),r=await (0,m.x7)(e);if(r.exists()){let e=r.data();g((null==e?void 0:e.title)||_.title),x((null==e?void 0:e.description)||_.description),y((null==e?void 0:e.image)||_.image),v((null==e?void 0:e.contents)||_.contents)}else g(_.title),x(_.description),y(_.image),v(_.contents)}catch(e){console.error("à¹à¸«à¸¥à¸ section à¸à¸´à¸à¸à¸¥à¸²à¸:",e)}})()},[t]);let w=e=>(null==e?void 0:e[s])||"",k=async()=>{let e={title:d,description:u,image:h,contents:f,component:"layout1"};try{if(t){let r=(0,m.H9)(p.db,"sections",t);await (0,m.BN)(r,e,{merge:!0}),b.oR.success("à¸à¸±à¸à¹à¸à¸à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢")}else{let t=await (0,m.gS)((0,m.rJ)(p.db,"sections"),e);b.oR.success("สรà¹à¸²à¸ section à¹à¸«à¸¡à¹à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢: "+t.id)}n(!1)}catch(e){console.error("à¹à¸à¸´à¸à¸à¹à¸à¸à¸´à¸à¸à¸¥à¸²à¸à¹à¸à¸à¸²à¸£à¸à¸±à¸à¸à¸¶à¸:",e),b.oR.error("à¸à¸±à¸à¸à¸¶à¸à¹à¸¡à¹à¸ªà¸³à¹à¸£à¹à¸")}};return(0,l.jsxs)("section",{className:"bg-white dark:bg-gray-800",children:[(0,l.jsx)("div",{className:"py-4 px-4 w-full lg:py-6 lg:px-6",children:(0,l.jsxs)("div",{className:"mx-auto max-w-screen-sm text-center lg:mb-1 ",children:[(0,l.jsx)("h2",{className:"text-2xl lg:text-4xl font-extrabold text-gray-900 dark:text-orange-500",children:r?w(d):j(d)}),(0,l.jsx)("p",{className:"font-light text-gray-500 sm:text-xl dark:text-gray-400",children:r?w(u):j(u)})]})}),(0,l.jsxs)("div",{className:"grid max-w-screen-xl mx-auto px-4 py-8 lg:grid-cols-2 gap-6",children:[(0,l.jsx)("div",{className:"flex justify-center",children:(0,l.jsx)(i(),{src:null==h?void 0:h.url,alt:"mockup",width:500,height:500,className:"object-contain",priority:!0})}),(0,l.jsx)("div",{className:"mt-6 dark:text-white",children:(0,l.jsx)("div",{dangerouslySetInnerHTML:{__html:r?w(f):j(f)}})})]}),r&&(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(E,{title:d,setTitle:g,description:u,setDescription:x,image:h,setImage:y,contents:f,setContents:v,language:s,setLanguage:o,handleSubmit:k})})]})},group:"layout"},{name:"layout2",description:{en:"text and image",th:"à¸à¹à¸à¸à¸§à¸²à¸¡à¹à¸¥à¸°à¸£à¸¹à¸"},thumbnail:"/images/sections/previews/layout2.png",component:function(e){let{contentId:t,editMode:r,language:s,setLanguage:o,setEditMode:n}=e,[d,g]=(0,a.useState)({}),[u,x]=(0,a.useState)({}),[h,y]=(0,a.useState)(null),[f,v]=(0,a.useState)({}),{t:j}=(0,c.A)();(0,a.useEffect)(()=>{(async()=>{if(!t){g(A.title),x(A.description),y(A.image),v(A.contents);return}try{let e=(0,m.H9)(p.db,"sections",t),r=await (0,m.x7)(e);if(r.exists()){let e=r.data();g((null==e?void 0:e.title)||A.title),x((null==e?void 0:e.description)||A.description),y((null==e?void 0:e.image)||A.image),v((null==e?void 0:e.contents)||A.contents)}else g(A.title),x(A.description),y(A.image),v(A.contents)}catch(e){console.error("à¹à¸«à¸¥à¸ section à¸à¸´à¸à¸à¸¥à¸²à¸:",e)}})()},[t]);let w=e=>(null==e?void 0:e[s])||"",k=async()=>{let e={title:d,description:u,image:h,contents:f,component:"layout2"};try{if(t){let r=(0,m.H9)(p.db,"sections",t);await (0,m.BN)(r,e,{merge:!0}),b.oR.success("à¸à¸±à¸à¹à¸à¸à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢")}else{let t=await (0,m.gS)((0,m.rJ)(p.db,"sections"),e);b.oR.success("สรà¹à¸²à¸ section à¹à¸«à¸¡à¹à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢: "+t.id)}n(!1)}catch(e){console.error("à¹à¸à¸´à¸à¸à¹à¸à¸à¸´à¸à¸à¸¥à¸²à¸à¹à¸à¸à¸²à¸£à¸à¸±à¸à¸à¸¶à¸:",e),b.oR.error("à¸à¸±à¸à¸à¸¶à¸à¹à¸¡à¹à¸ªà¸³à¹à¸£à¹à¸")}};return(0,l.jsxs)("section",{className:"bg-white dark:bg-gray-800",children:[(0,l.jsx)("div",{className:"py-4 px-4 w-full lg:py-6 lg:px-6",children:(0,l.jsxs)("div",{className:"mx-auto max-w-screen-sm text-center lg:mb-1 ",children:[(0,l.jsx)("h2",{className:"text-2xl lg:text-4xl tracking-tight font-extrabold text-gray-900 dark:text-orange-500",children:r?w(d):j(d)}),(0,l.jsx)("p",{className:"font-light text-gray-500 text-sm lg:text-md dark:text-gray-400",children:r?w(u):j(u)})]})}),(0,l.jsxs)("div",{className:"grid max-w-screen-xl mx-auto px-4 lg:gap-12 xl:gap-4 lg:py-2 lg:grid-cols-2",children:[(0,l.jsx)("div",{className:"flex flex-col items-start mt-1 lg:w-full lg:ml-12 lg:mt-0",children:(0,l.jsx)("div",{className:"max-w-2xl mb-4 tracking-tight leading-5 md:text-lg xl:text-xl sm:text-md dark:text-white",children:(0,l.jsx)("div",{dangerouslySetInnerHTML:{__html:r?w(f):j(f)}})})}),(0,l.jsx)("div",{className:"flex justify-center w-full pb-4 lg:max-w-[500px] mx-auto",children:(0,l.jsx)(i(),{src:null==h?void 0:h.url,alt:"mockup",width:500,height:500,className:"object-contain",priority:!0})})]}),r&&(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(E,{title:d,setTitle:g,description:u,setDescription:x,image:h,setImage:y,contents:f,setContents:v,language:s,setLanguage:o,handleSubmit:k})})]})},group:"layout"},{name:"layout3",description:{en:"image background and text",th:"à¸à¸·à¹à¸à¸«à¸¥à¸±à¸à¹à¸¥à¸°à¸à¹à¸à¸à¸§à¸²à¸¡"},thumbnail:"/images/sections/previews/layout3.png",component:function(e){let{c
1ontentId:t,editMode:r,language:s,setLanguage:i,setEditMode:o}=e,[n,d]=(0,a.useState)({}),[g,u]=(0,a.useState)({}),[x,h]=(0,a.useState)(null),[y,f]=(0,a.useState)({}),[v,j]=(0,a.useState)({}),{t:w}=(0,c.A)();(0,a.useEffect)(()=>{(async()=>{if(!t){d(C.title),u(C.description),h(C.image),f(C.style),j(C.contents);return}try{let e=(0,m.H9)(p.db,"sections",t),r=await (0,m.x7)(e);if(r.exists()){let e=r.data();d((null==e?void 0:e.title)||C.title),u((null==e?void 0:e.description)||C.description),h((null==e?void 0:e.image)||C.image),f((null==e?void 0:e.style)||C.style),j((null==e?void 0:e.contents)||C.contents)}else d(C.title),u(C.description),h(C.image),f(C.style),j(C.contents)}catch(e){console.error("à¹à¸«à¸¥à¸ section à¸à¸´à¸à¸à¸¥à¸²à¸:",e)}})()},[t]);let k=e=>(null==e?void 0:e[s])||"",S=async()=>{let e={title:n,description:g,image:x,style:y,contents:v,component:"layout3"};try{if(t){let r=(0,m.H9)(p.db,"sections",t);await (0,m.BN)(r,e,{merge:!0}),b.oR.success("à¸à¸±à¸à¹à¸à¸à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢")}else{let t=await (0,m.gS)((0,m.rJ)(p.db,"sections"),e);b.oR.success("สรà¹à¸²à¸ section à¹à¸«à¸¡à¹à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢: "+t.id)}o(!1)}catch(e){console.error("à¹à¸à¸´à¸à¸à¹à¸à¸à¸´à¸à¸à¸¥à¸²à¸à¹à¸à¸à¸²à¸£à¸à¸±à¸à¸à¸¶à¸:",e),b.oR.error("à¸à¸±à¸à¸à¸¶à¸à¹à¸¡à¹à¸ªà¸³à¹à¸£à¹à¸")}};return(0,l.jsxs)("section",{class:"bg-white dark:bg-gray-800 w-full",children:[(0,l.jsx)("div",{className:"py-4 px-4 w-full lg:py-6 lg:px-6",children:(0,l.jsxs)("div",{className:"mx-auto max-w-screen-sm text-center lg:mb-1 ",children:[(0,l.jsx)("h2",{className:"text-2xl lg:text-4xl tracking-tight font-extrabold text-gray-900 dark:text-orange-500",children:r?k(n):w(n)}),(0,l.jsx)("p",{className:"font-light text-gray-500 text-sm lg:text-md dark:text-gray-400",children:r?k(g):w(g)})]})}),(0,l.jsx)("div",{className:"flex items-center justify-center bg-gray-300 dark:bg-gray-900 w-full lg:h-[550px] xl:h-[550px] sm:h-full",style:{backgroundImage:"url(".concat(null==x?void 0:x.url,")"),backgroundSize:"cover",backgroundPosition:null==y?void 0:y.position,backgroundRepeat:"no-repeat",height:"550px"},children:(0,l.jsx)("div",{className:"max-w-screen-xl px-4 py-8 mx-auto text-center lg:py-40 lg:px-6",children:(0,l.jsx)("div",{className:"flex justify-center max-w-screen-lg mx-auto",children:(0,l.jsx)("div",{className:"max-w-2xl mb-4 tracking-tight leading-4 text-gray-200 md:text-lg xl:text-2xl sm:text-md dark:text-white",children:(0,l.jsx)("div",{style:{color:null==y?void 0:y.color,fontSize:null==y?void 0:y.fontSize},children:r?k(v):w(v)})})})})}),r&&(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(N,{title:n,setTitle:d,description:g,setDescription:u,image:x,setImage:h,style:y,setStyle:f,contents:v,setContents:j,language:s,setLanguage:i,handleSubmit:S})})]})},group:"layout"},{name:"layout4",description:{en:"image",th:"รูà¸à¸ าà¸"},thumbnail:"/images/sections/previews/layout4.png",component:function(e){let{contentId:t,editMode:r,language:s,setLanguage:o,setEditMode:n}=e,[d,u]=(0,a.useState)({}),[x,h]=(0,a.useState)({}),[y,f]=(0,a.useState)([]),[v,j]=(0,a.useState)([]),[w,k]=(0,a.useState)([]),[N,C]=(0,a.useState)(""),[S,E]=(0,a.useState)({}),[_,A]=(0,a.useState)(""),{t:F,selectedLang:R}=(0,c.A)(),T=(0,g.useRouter)();(0,a.useEffect)(()=>{(async()=>{if(!t)return;let e=(0,m.H9)(p.db,"sections",t),r=await (0,m.x7)(e);if(r.exists()){let e=r.data();u((null==e?void 0:e.title)||H.title),h((null==e?void 0:e.description)||H.description),f((null==e?void 0:e.image)||H.image),j(null==e?void 0:e.imageEng),k((null==e?void 0:e.contents)||[]),C((null==e?void 0:e.contentCollection)||""),E((null==e?void 0:e.style)||H.style),A((null==e?void 0:e.type)||"")}else u(H.title),h(H.description),f(H.image),E(H.style),A(H.type||"")})()},[t]);let D=e=>(null==e?void 0:e[s])||"",M=async()=>{let e={title:d,description:x,image:y,contents:w,contentCollection:null!=N?N:null,style:S,type:_,component:"layout4"};try{if(t){let r=(0,m.H9)(p.db,"sections",t);await (0,m.BN)(r,e,{merge:!0}),b.oR.success("à¸à¸±à¸à¹à¸à¸à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢")}else{let t=await (0,m.gS)((0,m.rJ)(p.db,"sections"),e);b.oR.success("สรà¹à¸²à¸ section à¹à¸«à¸¡à¹à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢: "+t.id)}n(!1)}catch(e){console.error("à¹à¸à¸´à¸à¸à¹à¸à¸à¸´à¸à¸à¸¥à¸²à¸à¹à¸à¸à¸²à¸£à¸à¸±à¸à¸à¸¶à¸:",e),b.oR.error("à¸à¸±à¸à¸à¸¶à¸à¹à¸¡à¹à¸ªà¸³à¹à¸£à¹à¸")}};return(0,l.jsxs)("section",{class:"bg-white dark:bg-gray-800 w-full",children:[(0,l.jsx)("div",{className:"py-4 px-4 w-full lg:py-6 lg:px-6",children:(0,l.jsxs)("div",{className:"mx-auto max-w-screen-sm text-center lg:mb-1 ",children:[(0,l.jsx)("h2",{className:"text-2xl lg:text-4xl tracking-tight font-extrabold text-gray-900 dark:text-orange-500",children:r?D(d):F(d)}),(0,l.jsx)("p",{className:"font-light text-gray-500 text-sm lg:text-md dark:text-gray-400",children:r?D(x):F(x)})]})}),(0,l.jsx)("div",{className:"grid max-w-screen-xl px-4 py-4 mx-auto lg:gap-".concat(S.gap," xl:gap-").concat(S.gap," lg:py-2 lg:grid-cols-").concat(S.cols),children:"images"===_?"th"===R?y&&y.map((e,t)=>(0,l.jsx)("div",{className:"relative hover:scale-105 transition-all duration-500 ease-in-out hover:z-50 active:z-50",children:(0,l.jsx)(i(),{src:e.url,alt:"image-".concat(t),width:700,height:700,loading:"lazy",className:"w-full h-full object-contain cursor-pointer"})},t)):v&&v.map((e,t)=>(0,l.jsx)("div",{className:"relative hover:scale-105 transition-all duration-500 ease-in-out hover:z-50 active:z-50",children:(0,l.jsx)(i(),{src:e.url,alt:"image-".concat(t),width:400,height:400,loading:"lazy",className:"w-full h-full object-contain cursor-pointer"})},t)):w.map((e,t)=>{var r;return(0,l.jsx)("div",{className:"relative hover:scale-105 transition-all duration-500 ease-in-out hover:z-50 active:z-50",onClick:()=>
1{if(!(null==e?void 0:e.slug))return;let t=e.group?"/".concat(e.page,"/").concat(e.group,"/").concat(e.slug):"/".concat(e.page,"/").concat(e.slug);T.push(t)},children:(0,l.jsx)(i(),{src:(null==e?void 0:null===(r=e.image)||void 0===r?void 0:r.url)||"/default-image.png",alt:"image-".concat(t),width:700,height:700,loading:"lazy",className:"w-full h-full object-contain cursor-pointer"})},t)})}),r&&(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(z,{title:d,setTitle:u,description:x,setDescription:h,image:y,setImage:f,imageEng:v,setImageEng:j,contents:w,setContents:k,contentCollection:N,setContentCollection:C,style:S,setStyle:E,type:_,setType:A,language:s,setLanguage:o,handleSubmit:M})})]})},group:"layout"},{name:"layout5",description:{en:"image",th:"รูà¸à¸ าà¸"},thumbnail:"/images/sections/previews/layout5.png",component:function(e){let{contentId:t,editMode:r,language:s,setLanguage:o,setEditMode:n}=e,[d,g]=(0,a.useState)({}),[u,x]=(0,a.useState)({}),[h,y]=(0,a.useState)([]),[f,v]=(0,a.useState)({}),{t:j,lang:w}=(0,c.A)();(0,a.useEffect)(()=>{(async()=>{if(!t)return;let e=(0,m.H9)(p.db,"sections",t),r=await (0,m.x7)(e);if(r.exists()){let e=r.data();g((null==e?void 0:e.title)||O.title),x((null==e?void 0:e.description)||O.description),y((null==e?void 0:e.contents)||O.contents),v((null==e?void 0:e.style)||O.style)}else g(O.title),x(O.description),y(O.contents),v(O.style)})()},[t]);let k=e=>(null==e?void 0:e[s])||"",N=async()=>{let e={title:d,description:u,contents:h,style:f,component:"layout5"};try{if(t){let r=(0,m.H9)(p.db,"sections",t);await (0,m.BN)(r,e,{merge:!0}),b.oR.success("à¸à¸±à¸à¹à¸à¸à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢")}else{let t=await (0,m.gS)((0,m.rJ)(p.db,"sections"),e);b.oR.success("สรà¹à¸²à¸ section à¹à¸«à¸¡à¹à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢: "+t.id)}n(!1)}catch(e){console.error("à¹à¸à¸´à¸à¸à¹à¸à¸à¸´à¸à¸à¸¥à¸²à¸à¹à¸à¸à¸²à¸£à¸à¸±à¸à¸à¸¶à¸:",e),b.oR.error("à¸à¸±à¸à¸à¸¶à¸à¹à¸¡à¹à¸ªà¸³à¹à¸£à¹à¸")}};return(0,l.jsxs)("section",{class:"bg-white dark:bg-gray-800 w-full mt-8 mb-8 py-8",children:[(0,l.jsx)("div",{className:"py-4 px-4 w-full lg:py-6 lg:px-6",children:(0,l.jsxs)("div",{className:"mx-auto max-w-screen-sm text-center lg:mb-1 ",children:[(0,l.jsx)("h2",{className:"text-2xl lg:text-4xl tracking-tight font-extrabold text-gray-900 dark:text-orange-500",children:r?k(d):j(d)}),(0,l.jsx)("p",{className:"font-light text-gray-500 text-sm lg:text-md dark:text-gray-400",children:r?k(u):j(u)})]})}),(0,l.jsx)("div",{className:"grid max-w-screen-xl px-4 py-4 mx-auto grid-cols-1 gap-16 lg:gap-".concat(f.gap," xl:gap-").concat(f.gap," lg:py-2 lg:grid-cols-").concat(f.cols),children:h&&h.length>0&&h.map((e,t)=>{var r,a;return(0,l.jsxs)("div",{className:"flex flex-col items-center w-full gap-2 cursor-pointer",children:[(0,l.jsx)("div",{className:"relative hover:scale-105 transition-all duration-500 ease-in-out hover:z-50 active:z-50",style:{height:"".concat(f.size,"px"),width:"auto",maxWidth:"100%"},children:(0,l.jsx)(i(),{src:null===(r=e.image)||void 0===r?void 0:r.url,alt:"image-".concat((null==e?void 0:null===(a=e.image)||void 0===a?void 0:a.title)||t),width:500,height:500,loading:"lazy",className:"h-full w-auto object-contain cursor-pointer",onClick:()=>e.url?window.open(e.url,"_blank"):null})}),(0,l.jsx)("h2",{className:"text-2xl font-bold",children:j(e.title)}),(0,l.jsx)("span",{className:"text-md text-gray-500 text-center",style:{whiteSpace:"pre-line"},children:j(e.description)}),e.url&&(0,l.jsx)("span",{className:"text-md text-center cursor-pointer hover:text-orange-500",onClick:()=>e.url?window.open(e.url,"_blank"):null,children:w.details_courses})]},t)})}),r&&(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(B,{title:d,setTitle:g,description:u,setDescription:x,contents:h,setContents:y,style:f,setStyle:v,language:s,setLanguage:o,handleSubmit:N})})]})},group:"layout"},{name:"team",description:{en:"show team",th:"à¹à¸ªà¸à¸à¸à¸µà¸¡"},thumbnail:"/images/sections/previews/team.png",component:function(e){let{contentId:t,editMode:r,language:s,setLanguage:o,setEditMode:n}=e,[d,g]=(0,a.useState)([]),[u,x]=(0,a.useState)({}),[h,y]=(0,a.useState)({}),[f,N]=(0,a.useState)(6),[C,S]=(0,a.useState)(!1),{lang:E,t:_}=(0,c.A)(),{subscribe:A}=(0,j.A)("teams");(0,a.useEffect)(()=>{let e=A(e=>{g([...e].slice().sort((e,t)=>
1e.order-t.order))});return()=>e()},[]),(0,a.useEffect)(()=>{(async()=>{if(!t){x(k.title),y(k.description);return}try{let e=(0,m.H9)(p.db,"sections",t),r=await (0,m.x7)(e);if(r.exists()){let e=r.data();x((null==e?void 0:e.title)||k.title),y((null==e?void 0:e.description)||k.description)}else x(k.title),y(k.description)}catch(e){console.error("à¹à¸«à¸¥à¸ section à¸à¸´à¸à¸à¸¥à¸²à¸:",e)}})()},[t]);let F=e=>(null==e?void 0:e[s])||"",z=async()=>{let e={title:u,description:h,component:"team"};try{if(t){let r=(0,m.H9)(p.db,"sections",t);await (0,m.BN)(r,e,{merge:!0}),b.oR.success("à¸à¸±à¸à¹à¸à¸à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢")}else{let t=await (0,m.gS)((0,m.rJ)(p.db,"sections"),e);b.oR.success("สรà¹à¸²à¸ section à¹à¸«à¸¡à¹à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢: "+t.id)}n(!1)}catch(e){console.error("à¹à¸à¸´à¸à¸à¹à¸à¸à¸´à¸à¸à¸¥à¸²à¸à¹à¸à¸à¸²à¸£à¸à¸±à¸à¸à¸¶à¸:",e),b.oR.error("à¸à¸±à¸à¸à¸¶à¸à¹à¸¡à¹à¸ªà¸³à¹à¸£à¹à¸")}};return(0,l.jsxs)("section",{className:"bg-white dark:bg-gray-800",children:[(0,l.jsxs)("div",{className:"py-8 px-4 mx-auto max-w-screen-xl lg:py-16 lg:px-6",children:[(0,l.jsxs)("div",{className:"mx-auto max-w-screen-sm text-center mb-8 lg:mb-16",children:[(0,l.jsx)("h2",{className:"mb-4 text-2xl md:text-3xl font-extrabold text-gray-900 dark:text-orange-500",children:r?F(u):_(u)}),(0,l.jsx)("p",{className:"font-light text-gray-500 text-sm lg:text-md dark:text-gray-400",children:r?F(h):_(h)})]}),(0,l.jsx)("div",{className:"hidden lg:grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 lg:gap-10 place-items-center",children:d.slice(0,f).map((e,t)=>(0,l.jsxs)("div",{className:"flex flex-col items-center justify-center w-full max-w-[300px] p-4 transition-transform transform hover:scale-105",children:[(0,l.jsx)(v(),{href:"/team/".concat(e.slug),children:(0,l.jsx)(i(),{className:"w-32 h-32 rounded-full",src:e.image.url,alt:_(e.name),width:200,height:200,loading:"lazy"})}),(0,l.jsxs)("div",{className:"p-5 text-center",children:[(0,l.jsx)("h3",{className:"text-md font-bold tracking-tight text-gray-900 dark:text-white",children:(0,l.jsx)(v(),{href:"/team/".concat(e.slug),children:_(e.name)})}),(0,l.jsx)("span",{className:"text-sm text-gray-500 dark:text-gray-400 line-clamp-2",children:_(e.bio)})]})]},t))}),d.length>6&&(0,l.jsx)("div",{className:"flex justify-center mt sm-hidden",children:(0,l.jsx)("button",{className:"px-4 py-2 bg-orange-500 text-white font-semibold text-md rounded-2xl hover:bg-orange-600",onClick:()=>{C?N(6):N(d.length),S(!C)},children:C?E.show_less:E.show_more})}),(0,l.jsx)("div",{className:"lg:hidden team flex overflow-x-auto gap-2 pb-4 snap-x snap-mandatory touch-pan-x scrollbar-hide",children:d.map((e,t)=>(0,l.jsxs)("div",{className:"flex flex-col items-center justify-center min-w-[250px] sm:min-w-[300px] snap-start p-2 transition-transform transform hover:scale-105",children:[(0,l.jsx)(v(),{href:"/team/".concat(e.slug),children:(0,l.jsx)(i(),{className:"w-32 h-32 rounded-full",src:e.image.url,alt:_(e.name),width:200,height:200,loading:"lazy"})}),(0,l.jsxs)("div",{className:"p-2 text-center",children:[(0,l.jsx)("h3",{className:"text-md font-bold tracking-tight text-gray-900 dark:text-white line-clamp-1",children:(0,l.jsx)(v(),{href:"/team/".concat(e.slug),children:_(e.name)})}),(0,l.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400 line-clamp-2",children:_(e.bio)})]})]},t))})]}),r&&(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(w,{title:u,setTitle:x,description:h,setDescription:y,language:s,setLanguage:o,handleSubmit:z})})]})},group:"layout"},{name:"header",description:{en:"show header",th:"à¹à¸ªà¸à¸à¸«à¸±à¸§à¸à¹à¸"},thumbnail:"/images/sections/previews/header.png",component:function(e){let{contentId:t,editMode:r,language:s,setLanguage:o,setEditMode:n}=e,[d,g]=(0,a.useState)({}),[u,x]=(0,a.useState)({}),[h,y]=(0,a.useState)([]),[f,v]=(0,a.useState)(2),[j,w]=(0,a.useState)({}),{t:k}=(0,c.A)();(0,a.useEffect)(()=>{(async()=>{if(!t){g(W.title),x(W.description),y(W.image),w(W.style);return}try{let e=(0,m.H9)(p.db,"sections",t),r=await (0,m.x7)(e);if(r.exists()){let e=r.data();g((null==e?void 0:e.title)||W.title),x((null==e?void 0:e.description)||W.description),y((null==e?void 0:e.image)||W.image),w((null==e?void 0:e.style)||W.style)}
1else g(W.title),x(W.description),y(W.image),w(W.style)}catch(e){console.error("à¹à¸«à¸¥à¸ section à¸à¸´à¸à¸à¸¥à¸²à¸:",e)}})()},[t]);let N=e=>(null==e?void 0:e[s])||"",C=async()=>{let e={title:d,description:u,image:h,style:j,component:"header"};try{if(t){let r=(0,m.H9)(p.db,"sections",t);await (0,m.BN)(r,e,{merge:!0}),b.oR.success("à¸à¸±à¸à¹à¸à¸à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢")}else{let t=await (0,m.gS)((0,m.rJ)(p.db,"sections"),e);b.oR.success("สรà¹à¸²à¸ section à¹à¸«à¸¡à¹à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢: "+t.id)}n(!1)}catch(e){console.error("à¹à¸à¸´à¸à¸à¹à¸à¸à¸´à¸à¸à¸¥à¸²à¸à¹à¸à¸à¸²à¸£à¸à¸±à¸à¸à¸¶à¸:",e),b.oR.error("à¸à¸±à¸à¸à¸¶à¸à¹à¸¡à¹à¸ªà¸³à¹à¸£à¹à¸")}};return(0,l.jsxs)("section",{className:"bg-white dark:bg-gray-800",children:[(0,l.jsx)("div",{className:"",style:{backgroundColor:j.bgColor,width:"100%"},children:(0,l.jsxs)("div",{className:"grid mx-auto max-w-screen-xl px-4 py-6 w-full lg:gap-12 xl:gap-4 lg:py-10 lg:grid-cols-2",children:[(0,l.jsxs)("div",{className:"flex flex-col items-center justify-center mx-auto max-w-screen-sm text-center lg:mt-10 ",children:[(0,l.jsx)("h2",{className:"text-2xl lg:text-4xl font-extrabold",style:{color:j.titleColor,fontSize:j.titleFontSize},children:r?N(d):k(d)}),(0,l.jsx)("p",{className:"font-light",style:{color:j.desecriptionColor,fontSize:j.descriptionFontSize},children:r?N(u):k(u)})]}),(0,l.jsx)("div",{className:"flex justify-center w-full mt-6 lg:mt-0 lg:max-w-[500px] mx-auto",children:(0,l.jsx)(i(),{src:h.url,alt:"mockup",width:500,height:500,className:"object-contain",priority:!0})})]})}),r&&(0,l.jsx)(Y,{contentId:t,title:d,setTitle:g,description:u,setDescription:x,image:h,setImage:y,style:j,setStyle:w,language:s,setLanguage:o,setEditMode:n,handleSubmit:C})]})},group:"header"},{name:"hightlight",description:{en:"content hightlight",th:"à¹à¸à¸·à¹à¸à¸«à¸²à¸ªà¹à¸²à¸à¸±à¸"},thumbnail:"/images/sections/previews/hightlight.png",component:function(e){var t,r;let{contentId:s,editMode:o,language:n,setLanguage:d,setEditMode:g}=e,[u,x]=(0,a.useState)({}),[h,b]=(0,a.useState)(0),{t:y,lang:f}=(0,c.A)();(0,a.useEffect)(()=>{(async()=>{if(!s)return;let e=(0,m.H9)(p.db,"sections",s),t=await (0,m.x7)(e);if(t.exists()){let e=t.data();x((null==e?void 0:e.contents)||er)}else x(er)})()},[s]),(0,a.useEffect)(()=>{let e=setInterval(()=>{b(e=>e===u.length-1?0:e+1)},5e3);return()=>clearInterval(e)},[h,u]);let v=e=>{b(e)},j=u[h];return(0,l.jsx)("section",{className:"bg-white dark:bg-gray-900",children:(0,l.jsx)("div",{className:"max-w-screen-xl px-4 py-4 mx-auto",children:(0,l.jsxs)("div",{className:"flex flex-col md:flex-row gap-4 items-start h-[450px]",children:[(0,l.jsxs)("div",{className:"relative w-full md:w-3/4 h-full overflow-hidden rounded-lg shadow-md",children:[(0,l.jsx)(i(),{src:null==j?void 0:null===(t=j.image)||void 0===t?void 0:t.url,alt:null==j?void 0:null===(r=j.title)||void 0===r?void 0:r.en,layout:"fill",className:"object-cover",priority:!0}),(0,l.jsxs)("div",{className:"absolute bottom-0 left-0 w-full bg-gradient-to-t from-black/70 to-transparent p-4 text-white",children:[(0,l.jsx)("h2",{className:"text-xl font-semibold line-clamp-2",children:y(null==j?void 0:j.title)}),(0,l.jsx)("p",{className:"text-sm line-clamp-2",children:y(null==j?void 0:j.description)})]})]}),(0,l.jsx)("div",{className:"flex md:flex-col gap-2 w-full md:w-1/4 h-full overflow-x-hidden md:overflow-y-auto",children:u.length>0&&u.map((e,t)=>(0,l.jsxs)("div",{onClick:()=>v(t),className:et()("relative w-[33.33%] md:w-full aspect-[4/3] cursor-pointer rounded-md overflow-hidden border transition-all duration-300",{"border-orange-500 ring-2 ring-orange-400":t===h,"hover:scale-105":t!==h}),children:[(0,l.jsx)(i(),{src:e.image.url,alt:e.title.en,layout:"fill",className:"object-cover"}),(0,l.jsx)("div",{className:"absolute bottom-0 left-0 w-full bg-white/70 p-1 text-xs text-black line-clamp-1",children:y(e.title)})]},e.id))})]})})})},group:"hightlight"},{name:"fixHightlight",description:{en:"content hightlight",th:"à¹à¸à¸·à¹à¸à¸«à¸²à¸ªà¹à¸²à¸à¸±à¸"},thumbnail:"/images/sections/previews/hightlight.png",component:function(e){var t,r,s,o,n;
1let{contentId:d,editMode:u,language:x,setLanguage:h,setEditMode:y}=e,[f,v]=(0,a.useState)({}),[j,w]=(0,a.useState)({}),[k,N]=(0,a.useState)([]),[C,S]=(0,a.useState)({}),[E,_]=(0,a.useState)(!1);(0,g.useRouter)();let{t:A,lang:F}=(0,c.A)(),z=e=>{e&&window.open(e,"_blank")};(0,a.useEffect)(()=>{(async()=>{if(!d){v(en.title),w(en.description),N(en.contents),S(en.style);return}try{let e=(0,m.H9)(p.db,"sections",d),t=await (0,m.x7)(e);if(t.exists()){let e=t.data();v(null==e?void 0:e.title),w(null==e?void 0:e.description),N((null==e?void 0:e.contents)||en.contents),S((null==e?void 0:e.style)||en.style)}else v(en.title),w(en.description),N(en.contents),S(en.style)}catch(e){console.error("à¹à¸«à¸¥à¸ section à¸à¸´à¸à¸à¸¥à¸²à¸:",e)}})()},[d]);let H=async()=>{let e={title:f,description:j,contents:k,style:C,component:"fixHightLight"};try{if(d){let t=(0,m.H9)(p.db,"sections",d);await (0,m.BN)(t,e,{merge:!0}),b.oR.success("à¸à¸±à¸à¹à¸à¸à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢")}else{let t=await (0,m.gS)((0,m.rJ)(p.db,"sections"),e);b.oR.success("สรà¹à¸²à¸ section à¹à¸«à¸¡à¹à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢: "+t.id)}y(!1)}catch(e){console.error("à¹à¸à¸´à¸à¸à¹à¸à¸à¸´à¸à¸à¸¥à¸²à¸à¹à¸à¸à¸²à¸£à¸à¸±à¸à¸à¸¶à¸:",e),b.oR.error("à¸à¸±à¸à¸à¸¶à¸à¹à¸¡à¹à¸ªà¸³à¹à¸£à¹à¸")}};return(0,l.jsxs)("section",{className:"bg-white dark:bg-gray-900",children:[(0,l.jsx)("div",{className:"py-4 px-4 w-full lg:py-6 lg:px-6",children:(0,l.jsxs)("div",{className:"mx-auto max-w-screen-sm text-center lg:mb-1 ",children:[(0,l.jsx)("h2",{className:"text-2xl lg:text-4xl tracking-tight font-extrabold text-gray-900 dark:text-orange-500",children:u?null==f?void 0:f[x]:A(f)}),(0,l.jsx)("p",{className:"font-light text-gray-500 text-sm lg:text-md dark:text-gray-400",children:u?null==j?void 0:j[x]:A(j)})]})}),(0,l.jsxs)("div",{className:"max-w-screen-xl mx-auto flex flex-col md:flex-row gap-6",style:{maxHeight:"calc(4 * 160px)"},children:[(0,l.jsxs)("div",{className:"w-full md:w-[70%] aspect-video rounded-lg overflow-hidden shadow-lg cursor-pointer relative",onClick:()=>{var e;return z(null===(e=k[0])||void 0===e?void 0:e.url)},children:[(null===(t=k[0])||void 0===t?void 0:t.video)?(0,l.jsx)(ed,{url:k[0].video.url,onPlay:_}):(0,l.jsx)(i(),{src:null===(r=k[0])||void 0===r?void 0:r.image.url,alt:"thumbnail",width:1280,height:720,className:"w-full h-full object-cover"}),(null===(s=k[0])||void 0===s?void 0:s.image)&&(0,l.jsxs)("div",{className:"absolute bottom-0 left-0 w-full p-4 transition-all duration-300 opacity-50 bg-white",children:[(0,l.jsx)("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:null===(o=k[0])||void 0===o?void 0:o.title}),(0,l.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-300 line-clamp-2",children:null===(n=k[0])||void 0===n?void 0:n.description})]})]}),(0,l.jsx)("div",{className:"w-full md:w-1/4 flex md:flex-col flex-row gap-3 md:overflow-y-auto overflow-x-auto",style:{maxHeight:"540px"},children:k.slice(1).map(e=>{var t;return(0,l.jsxs)("div",{onClick:()=>{var t;return z((null===(t=e.video)||void 0===t?void 0:t.url)||e.url)},className:"w-full h-[130px] rounded-lg overflow-hidden shadow cursor-pointer hover:ring-2 hover:ring-orange-400 transition-all",children:[e.video?(0,l.jsx)(ed,{url:e.video.url}):(0,l.jsx)(i(),{src:null===(t=e.image)||void 0===t?void 0:t.url,alt:"thumbnail",width:1280,height:720,className:"w-full h-full object-cover"}),(0,l.jsx)("div",{className:"p-2 bg-white text-sm font-medium truncate text-black",children:e.title})]},e.id)})})]}),u&&(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(eo,{title:f,setTitle:v,description:j,setDescription:w,contents:k,setContents:N,style:C,setStyle:S,language:x,setLanguage:h,handleSubmit:H,setEditMode:y})})]})},group:"hightlight"},{name:"contentHightlight",description:{en:"content hightlight",th:"à¹à¸à¸·à¹à¸à¸«à¸²à¸ªà¹à¸²à¸à¸±à¸"},thumbnail:"/images/sections/previews/contentHightlight.png",component:function(e){var t,r,s,o,n,d,u,x;let{contentId:h,editMode:y,language:f,setLanguage:v,setEditMode:j}=e,[w,k]=(0,a.useState)(null),[N,C]=(0,a.useState)(null),[S,E]=(0,a.useState)([]);(0,g.useRouter)();let{t:_,lang:A}=(0,c.A)();(0,a.useEffect)(()=>{(async()=>
1{if(!h)return;let e=(0,m.H9)(p.db,"sections",h),t=await (0,m.x7)(e);if(t.exists()){let e=t.data();k(null==e?void 0:e.title),C(null==e?void 0:e.description),E(null==e?void 0:e.contents)}else k(em.title),C(em.description),E(em.contents)})()},[h]);let F=e=>{e&&window.open(e,"_blank")},z=e=>(null==e?void 0:e[f])||"",H=async()=>{let e={title:w,description:N,contents:S,component:"contentHightLight"};try{if(h){let t=(0,m.H9)(p.db,"sections",h);await (0,m.BN)(t,e,{merge:!0}),b.oR.success("à¸à¸±à¸à¹à¸à¸à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢")}else{let t=await (0,m.gS)((0,m.rJ)(p.db,"sections"),e);b.oR.success("สรà¹à¸²à¸ section à¹à¸«à¸¡à¹à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢: "+t.id)}j(!1)}catch(e){console.error("à¹à¸à¸´à¸à¸à¹à¸à¸à¸´à¸à¸à¸¥à¸²à¸à¹à¸à¸à¸²à¸£à¸à¸±à¸à¸à¸¶à¸:",e),b.oR.error("à¸à¸±à¸à¸à¸¶à¸à¹à¸¡à¹à¸ªà¸³à¹à¸£à¹à¸")}};return(0,l.jsxs)("section",{className:"bg-white dark:bg-gray-900",children:[w&&(0,l.jsx)("div",{className:"py-4 px-4 w-full lg:py-6 lg:px-6",children:(0,l.jsxs)("div",{className:"mx-auto max-w-screen-sm text-center lg:mb-1 ",children:[(0,l.jsx)("h2",{className:"text-2xl lg:text-4xl tracking-tight font-extrabold text-gray-900 dark:text-orange-500",children:y?z(w):_(w)}),(0,l.jsx)("p",{className:"font-light text-gray-500 text-sm lg:text-md dark:text-gray-400",children:y?z(N):_(N)})]})}),(0,l.jsxs)("div",{className:"max-w-screen-xl mx-auto px-4 py-8 grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,l.jsxs)("div",{onClick:()=>{var e;return F(null===(e=S[0])||void 0===e?void 0:e.url)},className:"col-span-1 md:col-span-2 cursor-pointer rounded-xl overflow-hidden shadow-lg bg-white hover:scale-105 transition-all",children:[(0,l.jsx)(i(),{src:null===(r=S[0])||void 0===r?void 0:null===(t=r.image)||void 0===t?void 0:t.url,alt:null===(o=S[0])||void 0===o?void 0:null===(s=o.name)||void 0===s?void 0:s.en,width:1280,height:720,className:"w-full h-[260px] object-cover"}),(0,l.jsxs)("div",{className:"p-4",children:[(0,l.jsx)("p",{className:"text-sm text-blue-700 font-semibold mb-1",children:_(null===(n=S[0])||void 0===n?void 0:n.tag)||"หมวà¸à¸«à¸¡à¸¹à¹"}),(0,l.jsx)("h3",{className:"text-xl font-bold text-orange-500 mb-2 line-clamp-3",children:_(null===(d=S[0])||void 0===d?void 0:d.name)}),(0,l.jsx)("p",{className:"text-sm text-gray-600 mb-3 line-clamp-2",children:_(null===(u=S[0])||void 0===u?void 0:u.description)}),(0,l.jsx)("span",{className:"text-xs text-gray-500",children:V()(null===(x=S[0])||void 0===x?void 0:x.createdAt).format("LL")})]})]}),(0,l.jsx)("div",{className:"grid grid-cols-2 gap-4",children:S.slice(1).map(e=>{var t,r;return(0,l.jsxs)("div",{onClick:()=>F(e.url),className:"flex flex-col cursor-pointer rounded-xl overflow-hidden bg-white shadow-lg hover:scale-105 transition-all",children:[(0,l.jsx)(i(),{src:null==e?void 0:null===(t=e.image)||void 0===t?void 0:t.url,alt:null==e?void 0:null===(r=e.name)||void 0===r?void 0:r.en,width:600,height:300,className:"w-full h-[120px] object-cover"}),(0,l.jsxs)("div",{className:"p-3",children:[(0,l.jsx)("h4",{className:"text-sm font-semibold text-orange-500 mb-1 line-clamp-2",children:_(null==e?void 0:e.name)}),(0,l.jsx)("p",{className:"text-xs text-gray-600 line-clamp-2",children:_(null==e?void 0:e.description)}),(0,l.jsx)("span",{className:"text-xs text-gray-400 block mt-1",children:V()(null==e?void 0:e.createdAt).format("LL")})]})]},e.id)})})]}),y&&(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(ep,{title:w,setTitle:k,description:N,setDescription:C,contents:S,setContents:E,language:f,setLanguage:v,setEditMode:j,handleSubmit:H})})]})},group:"hightlight"},{name:"shortHightlight",description:{en:"content hightlight",th:"à¹à¸à¸·à¹à¸à¸«à¸²à¸ªà¹à¸²à¸à¸±à¸"},thumbnail:"/images/sections/previews/shortHightlight.png",component:function(e){let{contentId:t,editMode:r,language:s,setLanguage:i,setEditMode:o}=e,[n,d]=(0,a.useState)(eb.contents);(0,g.useRouter)();let{t:u,lang:x}=(0,c.A)();(0,a.useEffect)(()=>{(async()=>{if(!t){d(eb.contents);return}try{let e=(0,m.H9)(p.db,"sections",t),r=await (0,m.x7)(e);if(r.exists()){let e=r.data();d((null==e?void 0:e.contents)||eb.contents)}else d(eb.contents)}catch(e){console.error("à¹à¸«à¸¥à¸ section à¸à¸´à¸à¸à¸¥à¸²à¸:",e)}})()},[t]);let h=async()=>{let e={contents:n,component:"shortHightLight"};try{if(t){let r=(0,m.H9)(p.db,"sections",t);await (0,m.BN)(r,e,{merge:!0}),b.oR.success("à¸à¸±à¸à¹à¸à¸à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢")}else{let t=await (0,m.gS)((0,m.rJ)(p.db,"sections"),e);b.oR.success("สรà¹à¸²à¸ section à¹à¸«à¸¡à¹à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢: "+t.id)}o(!1)}catch(e){console.error("à¹à¸à¸´à¸à¸à¹à¸à¸à¸´à¸à¸à¸¥à¸²à¸à¹à¸à¸à¸²à¸£à¸à¸±à¸à¸à¸¶à¸:",e),b.oR.error("à¸à¸±à¸à¸à¸¶à¸à¹à¸¡à¹à¸ªà¸³à¹à¸£à¹à¸")}};return(0,l.jsxs)("section",{className:"bg-white dark:bg-gray-900 py-6 px-4 overflow-x-auto",children:[(0,l.jsx)("div",{className:"max-w-screen-xl mx-auto flex justify-between gap-6 items-stretch ",children:n.map(e=>(0,l.jsx)("div",{className:"rounded-2xl shadow-md overflow-hidden cursor-pointer transition-transform hover:scale-[1.02] flex-none",onClick:()=>window.open("https://www.youtube.com/shorts/".concat(e.video.url.split("/").pop()),"_blank"),style:{width:"300px",aspectRatio:"9/16"},children:(0,l.jsx)(ey,{url:e.video.url})},e.id))}),r&&(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)(eh,{contents:n,setContents:d,language:s,setLanguage:i,handleSubmit:h,setEditMode:o})})]})},group:"hightlight"},{name:"contentList",description:{en:"show content list",th:"à¹à¸ªà¸à¸à¸£à¸²à¸¢à¸à¸²à¸£à¹à¸à¸·à¹à¸à¸«à¸²"},thumbnail:"/images/sections/previews/contentList.png",component:function(e){let{c
1ontentId:t,editMode:r,language:s,setLanguage:i,setEditMode:o}=e,[n,d]=(0,a.useState)(null),[u,h]=(0,a.useState)(null),[y,f]=(0,a.useState)(""),[v,j]=(0,a.useState)([]),[w,k]=(0,a.useState)({}),N=(0,g.useRouter)(),{t:C,lang:S}=(0,c.A)();(0,a.useEffect)(()=>{(async()=>{if(!t)return;let e=(0,m.H9)(p.db,"sections",t),r=await (0,m.x7)(e);if(r.exists()){let e=r.data();d((null==e?void 0:e.title)||X.title),h((null==e?void 0:e.description)||X.description),f(null==e?void 0:e.contents),k((null==e?void 0:e.style)||X.style)}else d(X.title),h(X.description),k(X.style)})()},[t]),(0,a.useEffect)(()=>{(async()=>{if(y){let e=(0,m.P)((0,m.rJ)(p.db,y),(0,m._M)("active","==",!0));j((await (0,m.GG)(e)).docs.map(e=>({id:e.id,...e.data()})))}else{j(X.contents);return}})()},[y]);let E=async()=>{let e={title:n,description:u,contents:y,style:w,component:"contentList"};try{if(t){let r=(0,m.H9)(p.db,"sections",t);await (0,m.BN)(r,e,{merge:!0}),b.oR.success("à¸à¸±à¸à¹à¸à¸à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢")}else{let t=await (0,m.gS)((0,m.rJ)(p.db,"sections"),e);b.oR.success("สรà¹à¸²à¸ section à¹à¸«à¸¡à¹à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢: "+t.id)}o(!1)}catch(e){console.error("à¹à¸à¸´à¸à¸à¹à¸à¸à¸´à¸à¸à¸¥à¸²à¸à¹à¸à¸à¸²à¸£à¸à¸±à¸à¸à¸¶à¸:",e),b.oR.error("à¸à¸±à¸à¸à¸¶à¸à¹à¸¡à¹à¸ªà¸³à¹à¸£à¹à¸")}};return(0,l.jsxs)("section",{children:[(0,l.jsx)("div",{className:"py-4 px-4 w-full lg:py-8 lg:px-6",children:n&&(0,l.jsxs)("div",{className:"mx-auto max-w-screen-sm text-center ",children:[(0,l.jsx)("h2",{className:"text-2xl lg:text-4xl tracking-tight font-extrabold text-gray-900 dark:text-orange-500",children:C(n)}),u&&(0,l.jsx)("p",{className:"font-light text-gray-500 text-sm lg:text-md dark:text-gray-400",children:C(u)})]})}),(0,l.jsxs)("div",{className:"max-w-screen-xl px-4 pb-4 mx-auto",children:[(0,l.jsxs)("div",{className:"flex items-center justify-end group gap-1 mb-2 cursor-pointer ",children:[(0,l.jsx)("span",{className:"text-sm text-gray-500 dark:text-gray-200 hover:text-orange-700",onClick:()=>N.push(y?"/".concat(y):null),children:S.content_All}),(0,l.jsx)(x.Fx8,{className:"text-sm text-gray-500 dark:text-gray-200 hover:text-orange-700"})]}),(0,l.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-".concat(w.cols," gap-").concat(w.gap),children:v.map(e=>(0,l.jsx)(q,{item:e,pathname:y},e.id))})]}),r&&(0,l.jsx)("div",{className:"flex justify-center p-4",children:(0,l.jsx)($,{title:n,setTitle:d,description:u,setDescription:h,contents:y,setContents:f,style:w,setStyle:k,contentId:t,editMode:r,language:s,setLanguage:i,setEditMode:o,handleSubmit:E})})]})},group:"content"},{name:"contentListImage",description:{en:"show content list",th:"à¹à¸ªà¸à¸à¸£à¸²à¸¢à¸à¸²à¸£à¹à¸à¸·à¹à¸à¸«à¸²"},thumbnail:"/images/sections/previews/contentListImage.png",component:function(e){let{contentId:t,editMode:r,language:s,setLanguage:o,setEditMode:n}=e,[d,u]=(0,a.useState)({}),[x,h]=(0,a.useState)({}),[y,f]=(0,a.useState)(""),[v,j]=(0,a.useState)(""),[w,k]=(0,a.useState)([]),[N,C]=(0,a.useState)([]),[S,E]=(0,a.useState)(!1),[_,A]=(0,a.useState)({});(0,g.useRouter)().query.group;let{t:F,lang:z}=(0,c.A)();(0,a.useEffect)(()=>{(async()=>{if(!t){u(Q.title),h(Q.description),f(Q.contents),j(Q.path),A(Q.style);return}try{let e=(0,m.H9)(p.db,"sections",t),r=await (0,m.x7)(e);if(r.exists()){let e=r.data();u((null==e?void 0:e.title)||Q.title),h((null==e?void 0:e.description)||Q.description),f((null==e?void 0:e.contents)||Q.contents),j((null==e?void 0:e.path)||Q.path),A((null==e?void 0:e.style)||Q.style)}else u(Q.title),h(Q.description),f(Q.contents),j(Q.path),A(Q.style)}catch(e){console.error("à¹à¸«à¸¥à¸ section à¸à¸´à¸à¸à¸¥à¸²à¸:",e)}})()},[t]),(0,a.useEffect)(()=>{y&&(async()=>{try{let e=(0,m.P)((0,m.rJ)(p.db,y),(0,m._M)("active","==",!0),(0,m.My)("order","asc")),t=(await (0,m.GG)(e)).docs.map(e=>({id:e.id,...e.data()}));C(t),!S&&(null==_?void 0:_.limited)?k(t.slice(0,_.limited)):k(t)}catch(e){console.error("à¹à¸«à¸¥à¸ collection à¸à¸´à¸à¸à¸¥à¸²à¸:",e),C([]),k([])}})()},[y,null==_?void 0:_.limited,S]);let H=e=>(null==e?void 0:e[s])||"",R=async()=>{let e={title:d,description:x,contents:y,style:_,component:"header"};try{if(t){let r=(0,m.H9)(p.db,"sections",t);await (0,m.BN)(r,e,{merge:!0}),b.oR.success("à¸à¸±à¸à¹à¸à¸à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢")}else{let t=await (0,m.gS)((0,m.rJ)(p.db,"sections"),e);b.oR.success("สรà¹à¸²à¸ section à¹à¸«à¸¡à¹à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢: "+t.id)}n(!1)}catch(e){console.error("à¹à¸à¸´à¸à¸à¹à¸à¸à¸´à¸à¸à¸¥à¸²à¸à¹à¸à¸à¸²à¸£à¸à¸±à¸à¸à¸¶à¸:",e),b.oR.error("à¸à¸±à¸à¸à¸¶à¸à¹à¸¡à¹à¸ªà¸³à¹à¸£à¹à¸")}};return(0,l.jsxs)("section",{className:"bg-white dark:bg-gray-800",children:[(0,l.jsxs)("div",{className:"py-4 px-4 max-w-screen-xl mx-auto lg:py-6 lg:px-6",children:[(0,l.jsxs)("div",{className:"mx-auto max-w-screen-sm text-center lg:mb-1 ",children:[(0,l.jsx)("h2",{className:"text-2xl lg:text-4xl tracking-tight font-extrabold text-gray-900 dark:text-orange-500",children:r?H(d):F(d)}),(0,l.jsx)("p",{className:"font-light text-gray-500 text-sm lg:text-md dark:text-gray-400",children:r?H(x):F(x)})]}),(0,l.jsx)("div",{className:"grid grid-cols-1 py-6 gap-".concat(_.gap," lg:grid-cols-").concat(_.cols),children:w.length>0?w.map(e=>{var t;return(0,l.jsxs)("div",{className:"flex flex-col items-center gap-2 mb-4 p-4",children:[(null===(t=e.image)||void 0===t?void 0:t.url)&&(0,l.jsx)(i(),{src:e.image.url,width:500,height:500,alt:"item",className:"object-contain w-full h-[120px] hover:scale-105 transition-all duration-300 ease-in-out cursor-pointer",onClick:()=>window.open("/".concat(y,"/").concat(e.group,"/").concat(e.slug),"_blank")}),(0,l.jsx)("h3",{className:"text-3xl font-semibold",children:H(e.name)}),(null==e?void 0:e.start_date)?(0,l.jsxs)("div",{className:"flex gap-4",children:[(0,l.jsx)(i(),{src:"/images/date_icon.png",width:30,height:30,alt:"date_icon"}),(0,l.jsxs)("span",{className:"text-orange-500 text-2xl",children:[V()(e.start_date).format("DD")," -"," ",V()(e.end_date).format("ll")]})]}):(0,l.jsxs)("div",{className:"hidden lg:flex gap-4 opacity-0",children:[(0,l.jsx)(i(),{src:"/images/date_icon.png",width:30,height:30,alt:"date_icon"}),(0,l.jsxs)("span",{className:"text-orange-500 text-2xl",children:[V()(e.start_date).format("DD")," -"," ",V()(e.end_date).format("ll")]})]}),(0,l.jsx)("p",{className:"inline-block text-sm lg:text-md text-gray-500",onClick:()=>window.open("/".concat(y,"/").concat(e.group,"/").concat(e.slug),"_blank"),children:F(e.description)}),(0,l.jsx)("span",{className:"font-semibold hover:text-orange-500 cursor-pointer",children:z.details_courses})]},e.id)}):(0,l.jsx)("p",{className:"text-center text-gray-400 col-span-full",children:"à¹à¸¡à¹à¸¡à¸µà¸à¹à¸à¸¡à¸¹à¸¥"})}),(null==_?void 0:_.showMore)&&N.length>_.limited&&(0,l.jsx)("div",{className:"text-center mt-4",children:(0,l.jsx)("button",{onClick:()=>{E(!S),k(S?N.slice(0,_.limited):N)},className:"text-lg px-4 py-2 bg-orange-500 text-white rounded-lg hover:bg-orange-600",children:S?z.show_less:z.show_more})})]}),r&&(0,l.jsx)(Z,{title:d,setTitle:u,description:x,setDescription:h,contents:y,setContents:f,style:_,setStyle:A,language:s,setLanguage:o,setEditMode:n,handleSubmit:R})]})},group:"content"},{name:"youtubeShow",description:{en:"show content list",th:"à¹à¸ªà¸à¸à¸£à¸²à¸¢à¸à¸²à¸£à¹à¸à¸·à¹à¸à¸«à¸²"},thumbnail:"/images/sections/previews/youtubeShow.png",component:function(e){let{c
1ontentId:t,editMode:r,language:s,setLanguage:i,setEditMode:o,youtube:n}=e,[d,g]=(0,a.useState)({}),[u,x]=(0,a.useState)({}),[h,y]=(0,a.useState)([]),[f,v]=(0,a.useState)({}),{t:j}=(0,c.A)();(0,a.useEffect)(()=>{(async()=>{if(!t)return;let e=(0,m.H9)(p.db,"sections",t),r=await (0,m.x7)(e);if(r.exists()){let e=r.data();g((null==e?void 0:e.title)||eS.title),x((null==e?void 0:e.description)||eS.description),y((null==e?void 0:e.contents)||eS.contents),v((null==e?void 0:e.style)||eS.style)}else g(eS.title),x(eS.description),y(eS.contents),v(eS.style)})()},[t]),(0,a.useEffect)(()=>{let e=console.warn;return console.warn=function(){for(var t=arguments.length,r=Array(t),l=0;l<t;l++)r[l]=arguments[l];"string"==typeof r[0]&&r[0].includes("ReactPlayer")||e(...r)},()=>{console.warn=e}},[]);let w=e=>(null==e?void 0:e[s])||"",k=async()=>{let e={title:d,description:u,contents:h,style:f,component:"youtubeShow"};try{if(t){let r=(0,m.H9)(p.db,"sections",t);await (0,m.BN)(r,e,{merge:!0}),b.oR.success("à¸à¸±à¸à¹à¸à¸à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢")}else{let t=await (0,m.gS)((0,m.rJ)(p.db,"sections"),e);b.oR.success("สรà¹à¸²à¸ section à¹à¸«à¸¡à¹à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢: "+t.id)}o(!1)}catch(e){console.error("à¹à¸à¸´à¸à¸à¹à¸à¸à¸´à¸à¸à¸¥à¸²à¸à¹à¸à¸à¸²à¸£à¸à¸±à¸à¸à¸¶à¸:",e),b.oR.error("à¸à¸±à¸à¸à¸¶à¸à¹à¸¡à¹à¸ªà¸³à¹à¸£à¹à¸")}},N=e=>/^https?:\/\/(www\.)?youtube\.com\/watch\?v=/.test(e)||/^https?:\/\/youtu\.be\//.test(e);return(0,l.jsxs)("section",{class:"bg-white dark:bg-gray-800 w-full",children:[(0,l.jsx)("div",{className:"py-4 px-4 w-full lg:py-6 lg:px-6",children:(0,l.jsxs)("div",{className:"mx-auto max-w-screen-sm text-center lg:mb-1 ",children:[(0,l.jsx)("h2",{className:"text-2xl lg:text-4xl tracking-tight font-extrabold text-gray-900 dark:text-orange-500",children:r?w(d):j(d)}),(0,l.jsx)("p",{className:"font-light text-gray-500 text-sm lg:text-md dark:text-gray-400",children:r?w(u):j(u)})]})}),(0,l.jsx)("div",{className:"grid max-w-screen-xl mx-auto px-4 py-6 gap-".concat(f.gap||2," grid-cols-1 lg:grid-cols-").concat(f.cols||1),children:h.slice(0,Number(null==f?void 0:f.limited)||h.length).map((e,t)=>(0,l.jsx)("div",{style:{maxWidth:"".concat((null==f?void 0:f.size)||600,"px"),width:"100%",height:"100%",margin:"0 auto",aspectRatio:"16/9"},children:N(n||e.url)&&(0,l.jsx)(eC,{url:n||e.url,controls:!0,width:"100%",height:"100%"})},t))}),r&&(0,l.jsx)(ew,{title:d,setTitle:g,description:u,setDescription:x,contents:h,setContents:y,style:f,setStyle:v,language:s,setLanguage:i,setEditMode:o,handleSubmit:k})]})},group:"media"},{name:"headerCourses",description:{en:"Header for Courses",th:"สà¹à¸§à¸à¸«à¸±à¸§à¹à¸à¸ courses"},thumbnail:"/images/sections/previews/headerCourses.png",component:function(e){var t,r,s,o,n,d,u,x,h,y,f,j,w,k,N,C,S;let{pageData:E}=e,[_,A]=(0,a.useState)(null),[F,z]=(0,a.useState)(!1),{data:H,status:R}=(0,e_.useSession)(),T=null==H?void 0:null===(t=H.user)||void 0===t?void 0:t.userId;(0,g.useRouter)();
1let{t:D,lang:M,selectedLang:I}=(0,c.A)();(0,a.useEffect)(()=>{if("loading"===R)return},[R]),(0,a.useEffect)(()=>{E&&A(E)},[E]),(0,a.useEffect)(()=>{(async()=>{if(!T||!(null==_?void 0:_.id))return;let e=(0,m.P)((0,m.rJ)(p.db,"interested"),(0,m._M)("courseId","==",_.id),(0,m._M)("userId","==",T)),t=await (0,m.GG)(e);t.empty||"interested"!==t.docs[0].data().status||z(!0)})()},[T,null==_?void 0:_.id]);let L=(null==_?void 0:_.schedules.length)<0,P=!(null==_?void 0:_.location),G=async()=>{if(!T||!(null==_?void 0:_.id)){alert("à¸à¸£à¸¸à¸à¸²à¹à¸à¹à¸²à¸ªà¸¹à¹à¸£à¸°à¸à¸à¸à¹à¸à¸à¹à¸ªà¸à¸à¸à¸§à¸²à¸¡à¸ªà¸à¹à¸");return}let e=(0,m.P)((0,m.rJ)(p.db,"interested"),(0,m._M)("courseId","==",_.id),(0,m._M)("userId","==",T)),t=await (0,m.GG)(e);if(t.empty)await (0,m.BN)((0,m.H9)((0,m.rJ)(p.db,"interested")),{courseId:_.id,userId:T,status:"interested",createdAt:new Date().toISOString()}),z(!0),b.oR.success("à¹à¸ªà¸à¸à¸à¸§à¸²à¸¡à¸ªà¸à¹à¸à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢à¹à¸¥à¹à¸§");else{let e=t.docs[0].ref;"interested"===t.docs[0].data().status?(await eF().fire({title:"ยà¸à¹à¸¥à¸´à¸à¸à¸§à¸²à¸¡à¸ªà¸à¹à¸?",text:"à¸à¸¸à¸à¸à¹à¸à¸à¸à¸²à¸£à¸¢à¸à¹à¸¥à¸´à¸à¸à¸§à¸²à¸¡à¸ªà¸à¹à¸à¸à¸à¸£à¹à¸ªà¸à¸µà¹à¸«à¸£à¸·à¸à¹à¸¡à¹",icon:"warning",showCancelButton:!0,confirmButtonText:"à¹à¸à¹, ยà¸à¹à¸¥à¸´à¸",cancelButtonText:"ยà¸à¹à¸¥à¸´à¸"})).isConfirmed&&(await (0,m.mZ)(e,{status:"not_interested",updatedAt:new Date().toISOString()}),z(!1),b.oR.success("ยà¸à¹à¸¥à¸´à¸à¸à¸§à¸²à¸¡à¸ªà¸à¹à¸à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢à¹à¸¥à¹à¸§")):(await (0,m.mZ)(e,{status:"interested",updatedAt:new Date().toISOString()}),z(!0),b.oR.success("à¹à¸ªà¸à¸à¸à¸§à¸²à¸¡à¸ªà¸à¹à¸à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢à¹à¸¥à¹à¸§"))}};return(0,l.jsxs)("div",{className:"bg-white dark:bg-gray-800",children:[(0,l.jsxs)("div",{className:"max-w-screen-lg mx-auto px-4",children:["th"===I?(0,l.jsx)(i(),{src:(null==_?void 0:_.image)?null==_?void 0:_.image.url:null==_?void 0:_.imageEng.url,alt:null==_?void 0:null===(r=_.name)||void 0===r?void 0:r.en,width:700,height:700,style:{width:"100%",height:"auto"}}):(0,l.jsx)(i(),{src:(null==_?void 0:_.imageEng)?null==_?void 0:_.imageEng.url:null==_?void 0:null===(s=_.image)||void 0===s?void 0:s.url,alt:null==_?void 0:null===(o=_.name)||void 0===o?void 0:o.en,width:700,height:700,style:{width:"100%",height:"auto"}}),(0,l.jsxs)(eE.A,{"aria-label":"breadcrumb",className:"my-2 text-xs text-gray-500 dark:text-gray-400",children:[(0,l.jsx)(v(),{underline:"hover",color:"inherit",href:"/",children:"Home"}),(0,l.jsx)(v(),{underline:"hover",color:"inherit",href:"/courses",children:"Courses"}),(0,l.jsx)("span",{className:"font-bold text-orange-500",children:null==_?void 0:null===(n=_.name)||void 0===n?void 0:n.en})]}),(0,l.jsxs)("div",{className:"flex flex-col mt-4 mx-auto justify-center items-center text-center gap-1",children:[(0,l.jsxs)("h1",{className:"text-3xl font-semibold text-orange-500",children:[D(null==_?void 0:_.name)," ",(null==_?void 0:_.gen)>0?(0,l.jsxs)("span",{className:"text-xl",children:[M.gen," ",null==_?void 0:_.gen]}):null]}),(0,l.jsx)("p",{className:"text-gray-500",children:D(null==_?void 0:_.description)}),(null==_?void 0:_.price)&&(null==_?void 0:_.price)>0&&(0,l.jsxs)("p",{className:"text-orange-500 font-bold text-3xl my-2",children:[Number(null==_?void 0:_.price).toLocaleString("th-TH")," ฿"]}),(0,l.jsxs)("div",{className:"flex items-center gap-4 mb-4",children:[(null==_?void 0:_.registration_url)&&(0,l.jsx)("button",{onClick:()=>window.open(null==_?void 0:_.registration_url,"_blank"),className:"bg-orange-500 hover:bg-orange-600 text-white font-bold py-2 px-4 rounded",children:M.register_now}),(null==_?void 0:_.download_url)&&(0,l.jsx)("button",{onClick:()=>window.open(null==_?void 0:_.download_url,"_blank"),className:"bg-orange-500 hover:bg-orange-600 text-white font-bold py-2 px-4 rounded",children:M.download_now}),(0,l.jsx)(eR,{course:_})]})]})]}),(0,l.jsx)("div",{className:"p-2 bg-gray-200 mt-4",children:(0,l.jsx)("div",{className:"max-w-screen-lg mx-auto items-center justify-center",children:(0,l.jsxs)("div",{className:"grid ".concat(L?"grid-cols-1 min-h-[100px]":"grid-cols-1 md:grid-cols-3"," items-center gap-4"),children:[!L&&(null==_?void 0:null===(d=_.sc
1hedules)||void 0===d?void 0:d.length)>0&&(0,l.jsxs)("div",{className:"flex items-center text-orange-500 gap-2",children:[(0,l.jsx)(i(),{src:"/images/date_icon.png",width:30,height:30,alt:"date_icon",className:"object-contain"}),(null==_?void 0:null===(u=_.schedules)||void 0===u?void 0:u.length)>1?(0,l.jsx)("select",{name:"schedules",id:"schedules",children:null==_?void 0:null===(x=_.schedules)||void 0===x?void 0:x.map((e,t)=>(0,l.jsx)("option",{value:t,children:(0,l.jsx)("span",{children:"en"===I?(0,l.jsxs)("span",{children:[V()(null==e?void 0:e.start_date).locale("en").format("DD")," - ".concat(V()(null==e?void 0:e.end_date).locale("en").format("ll"))]}):(0,l.jsxs)("span",{children:[V()(null==e?void 0:e.start_date).locale("th").format("DD")," - ".concat(V()(null==e?void 0:e.end_date).locale("th").format("ll"))]})})},t))}):(0,l.jsx)("span",{className:"text-orange-500 text-sm lg:text-xl",children:"en"===I?(0,l.jsxs)("span",{children:[V()(null==_?void 0:null===(h=_.schedules[0])||void 0===h?void 0:h.start_date).locale("en").format("DD")," - ".concat(V()(null==_?void 0:null===(y=_.schedules[0])||void 0===y?void 0:y.end_date).locale("en").format("DD MMMM YYYY"))]}):(0,l.jsxs)("span",{children:[V()(null==_?void 0:null===(f=_.schedules[0])||void 0===f?void 0:f.start_date).locale("th").format("DD")," - ".concat(V()(null==_?void 0:null===(j=_.schedules[0])||void 0===j?void 0:j.end_date).locale("th").format("ll"))]})})]}),!L&&(null==_?void 0:null===(w=_.schedules)||void 0===w?void 0:w.length)>0&&(0,l.jsxs)("div",{className:"flex items-center text-orange-500 gap-2",children:[(0,l.jsx)(i(),{src:"/images/time-icon.png",width:30,height:30,alt:"time-icon",className:"object-contain"}),(null==_?void 0:null===(k=_.schedules)||void 0===k?void 0:k.length)>1?(0,l.jsx)("select",{name:"schedules",id:"schedules",children:null==_?void 0:null===(N=_.schedules)||void 0===N?void 0:N.map((e,t)=>(0,l.jsx)("option",{value:t,children:(null==e?void 0:e.start_time)+" - ".concat(null==e?void 0:e.end_time)},t))}):(0,l.jsxs)("span",{className:"text-orange-500 text-sm lg:text-xl",children:[null==_?void 0:null===(C=_.schedules[0])||void 0===C?void 0:C.start_time," -"," ",null==_?void 0:null===(S=_.schedules[0])||void 0===S?void 0:S.end_time]})]}),!L&&(null==_?void 0:_.location)&&(0,l.jsxs)("div",{className:"flex items-center text-orange-500 gap-2",children:[(0,l.jsx)(i(),{src:"/images/place-icon.png",width:30,height:30,alt:"place-icon",className:"object-contain"}),(0,l.jsx)("span",{className:"text-orange-500 text-sm lg:text-xl
1cursor-pointer",onClick:()=>window.open(null==_?void 0:_.location_url,"_blank"),children:null==_?void 0:_.location})]}),L&&(0,l.jsx)("div",{className:"".concat(P?"flex justify-center items-center col-span-full":""),children:(0,l.jsx)("button",{onClick:G,className:"font-bold py-2 px-4 rounded ".concat(F?"bg-blue-500 text-white hover:bg-blue-700":"bg-orange-500 hover:bg-orange-600 text-white"),children:F?M.interested_in_course:M.interested_course})})]})})})]})},group:"courses"},{name:"contents",description:{en:"show content",th:"à¹à¸ªà¸à¸à¹à¸à¸·à¹à¸à¸«à¸²"},thumbnail:"/images/sections/previews/contents.png",component:function(e){let{pageData:t}=e,[r,s]=(0,a.useState)({});(0,g.useRouter)();let{t:i,lang:o}=(0,c.A)();return(0,a.useEffect)(()=>{if(t){s(t.content);return}s({})},[t]),r&&(0,l.jsx)("div",{className:"px-4 py-6 mb-4",children:(0,l.jsx)("div",{className:"mx-auto max-w-screen-sm lg:max-w-screen-lg",children:(0,l.jsx)(eD,{className:"preview-box",html:i(r)})})})},group:"content"},{name:"customs",description:{en:"show content",th:"à¹à¸ªà¸à¸à¹à¸à¸·à¹à¸à¸«à¸²"},thumbnail:"/images/sections/previews/contents.png",component:function(e){let{contentId:t,editMode:r,language:s,setLanguage:i,setEditMode:o}=e,[n,d]=(0,a.useState)({th:"<p>à¹à¸à¸·à¹à¸à¸«à¸²....</p>",en:"<p>Contents...</p>"});(0,g.useRouter)();let{t:u,lang:x}=(0,c.A)();(0,a.useEffect)(()=>{(async()=>{if(!t){d(eL.contents);return}try{let e=(0,m.H9)(p.db,"sections",t),r=await (0,m.x7)(e);if(r.exists()){let e=r.data();d((null==e?void 0:e.contents)||eL.contents)}else d(eL.contents)}catch(e){console.error("à¹à¸«à¸¥à¸ section à¸à¸´à¸à¸à¸¥à¸²à¸:",e)}})()},[t]);let h=async()=>{let e={contents:n,component:"customs"};try{if(t){let r=(0,m.H9)(p.db,"sections",t);await (0,m.BN)(r,e,{merge:!0}),b.oR.success("à¸à¸±à¸à¹à¸à¸à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢")}else{let t=await (0,m.gS)((0,m.rJ)(p.db,"sections"),e);b.oR.success("สรà¹à¸²à¸ section à¹à¸«à¸¡à¹à¹à¸£à¸µà¸¢à¸à¸£à¹à¸à¸¢: "+t.id)}o(!1)}catch(e){console.error("à¹à¸à¸´à¸à¸à¹à¸à¸à¸´à¸à¸à¸¥à¸²à¸à¹à¸à¸à¸²à¸£à¸à¸±à¸à¸à¸¶à¸:",e),b.oR.error("à¸à¸±à¸à¸à¸¶à¸à¹à¸¡à¹à¸ªà¸³à¹à¸£à¹à¸")}};return(0,l.jsxs)("div",{children:[n&&(0,l.jsx)("div",{className:"max-w-screen-xl mx-auto px-4 py-6 mb-4",children:(0,l.jsx)(eI,{className:"preview-box",html:u(n)})}),r&&(0,l.jsx)(eM,{contents:n,setContents:d,handleSubmit:h,language:s,setLanguage:i,setEditMode:o})]})},group:"content"},{name:"footerCourses",description:{en:"Footer for Courses",th:"สà¹à¸§à¸à¸à¹à¸²à¸¢à¹à¸à¸ Courses"},thumbnail:"/images/sections/previews/headerCourses.png",component:function(e){var t,r;let{pageData:s}=e,[o,n]=(0,a.useState)({}),[d,u]=(0,a.useState)(!0);(0,g.useRouter)();let{t:x,lang:p}=(0,c.A)();return((0,a.useEffect)(()=>{s&&(n(s),u(!1))},[s]),d||!o)?(0,l.jsx)(eT.A,{}):(0,l.jsxs)("div",{className:"max-w-screen-lg mx-auto px-4 py-6",children:[(0,l.jsx)("div",{className:"flex justify-center items-center w-full",children:(0,l.jsx)(i(),{src:null==o?void 0:null===(t=o.image)||void 0===t?void 0:t.url,alt:null==o?void 0:null===(r=o.name)||void 0===r?void 0:r.en,width:300,height:300,style:{width:"500px",height:"auto"}})}),(0,l.jsxs)("div",{className:"flex flex-col mt-4 mx-auto justify-center items-center text-center gap-1",children:[(0,l.jsxs)("h1",{className:"text-3xl font-semibold text-orange-500",children:[x(null==o?void 0:o.name)," ",(null==o?void 0:o.gen)>0?(0,l.jsxs)("span",{className:"text-xl",children:[p.gen," ",null==o?void 0:o.gen]}):null]}),(0,l.jsx)("p",{className:"text-gray-500",children:x(null==o?void 0:o.description)}),(null==o?void 0:o.price)&&(null==o?void 0:o.price)>0&&(0,l.jsxs)("p",{className:"text-orange-500 font-bold text-3xl my-2",children:[Number(null==o?void 0:o.price).toLocaleString("th-TH")," ฿"]}),(null==o?void 0:o.registration_url)&&(0,l.jsxs)("div",{className:"flex gap-4 mb-4",children:[(0,l.jsx)("button",{onClick:()=>window.open(null==o?void 0:o.registration_url,"_blank"),className:"bg-orange-500 hover:bg-orange-600 text-white font-bold py-2 px-4 rounded",children:p.register_now}),(0,l.jsx)("button",{onClick:()=>window.open(null==o?void 0:o.download_url,"_blank"),className:"bg-orange-500 hover:bg-orange-600 text-white font-bold py-2 px-4 roun
1ded",children:p.download_now})]})]})]})},group:"courses"},{name:"headerTeam",description:{en:"Header for Team",th:"สà¹à¸§à¸à¸«à¸±à¸§à¹à¸à¸ Team"},thumbnail:"/images/sections/previews/headerTeam.png",component:function(e){var t,r;let{pageData:a}=e,{t:s,language:o}=(0,c.A)();return(0,l.jsx)("section",{className:"max-w-screen-lg mx-auto px-4 py-8",children:(0,l.jsxs)("div",{className:"flex flex-col items-center",children:[(0,l.jsx)("div",{children:(0,l.jsx)(i(),{className:"object-contain",src:null==a?void 0:null===(t=a.image)||void 0===t?void 0:t.url,alt:(null==a?void 0:null===(r=a.name)||void 0===r?void 0:r.en)+"- image",width:200,height:200})}),(0,l.jsx)("h2",{className:"text-2xl lg:text-4xl tracking-tight font-extrabold text-gray-900 dark:text-orange-500",children:s(null==a?void 0:a.name)}),(0,l.jsx)("p",{className:"font-light text-gray-500 sm:text-xl dark:text-gray-400",children:s(null==a?void 0:a.position)}),(0,l.jsx)("div",{className:"flex tracking-tight mx-auto mt-8",children:s(null==a?void 0:a.bio)})]})})},group:"team"},{name:"button",description:{en:"show button",th:"à¹à¸ªà¸à¸à¸à¸¸à¹à¸¡"},thumbnail:"/images/sections/previews/button.png",component:function(e){let{contentId:t,pageData:r,editMode:s,language:i,setLanguage:o,setEditMode:n}=e,[d,g]=(0,a.useState)([]),[u,x]=(0,a.useState)("#000000"),[p,m]=(0,a.useState)("#ffffff"),[h,b]=(0,a.useState)({th:"",en:""}),[y,f]=(0,a.useState)({th:"",en:""}),{lang:j,t:w,selectedLang:k}=(0,c.A)();return console.log("pageData",r),(null==r?void 0:r.useButton)&&(0,l.jsx)("div",{className:" text-center",children:(0,l.jsx)(v(),{href:r.button.url,target:"_blank",children:(0,l.jsx)("button",{className:"px-4 py-2 text-white rounded-lg",style:{backgroundColor:r.button.color||"#000000"},children:"th"===k?r.button.text.th:r.button.text.en})})})},group:"elements"},{name:"headerOnline",description:{en:"Header for Online Courses",th:"สà¹à¸§à¸à¸«à¸±à¸§à¹à¸à¸ Online Courses"},thumbnail:"/images/sections/previews/headerCourses.png",component:function(e){var t,r,s,o,n,d,u;let{pageData:x}=e,[h,b]=(0,a.useState)(null),[y,f]=(0,a.useState)(!1),{data:j,status:w}=(0,e_.useSession)(),k=null==j?void 0:null===(t=j.user)||void 0===t?void 0:t.userId;(0,g.useRouter)();let{t:N,lang:C,selectedLang:S}=(0,c.A)();return(0,a.useEffect)(()=>{if("loading"===w)return},[w]),(0,a.useEffect)(()=>{x&&b(x)},[x]),(0,a.useEffect)(()=>{(async()=>{if(!k||!(null==h?void 0:h.id))return;let e=(0,m.P)((0,m.rJ)(p.db,"interested"),(0,m._M)("courseId","==",h.id),(0,m._M)("userId","==",k)),t=await (0,m.GG)(e);t.empty||"interested"!==t.docs[0].data().status||f(!0)})()},[k,null==h?void 0:h.id]),(0,l.jsx)("div",{className:"bg-white dark:bg-gray-800",children:(0,l.jsxs)("div",{className:"max-w-screen-lg mx-auto px-4",children:["th"===S?(0,l.jsx)(i(),{src:(null==h?void 0:null===(r=h.image)||void 0===r?void 0:r.url)?null==h?void 0:h.image.url:(null==h?void 0:h.imageEng.url)?null==h?void 0:h.imageEng.url:"/images/sample-content.png",alt:null==h?void 0:null===(s=h.name)||void 0===s?void 0:s.en,width:700,height:700,style:{width:"100%",height:"auto"}}):(0,l.jsx)(i(),{src:(null==h?void 0:null===(o=h.imageEng)||void 0===o?void 0:o.url)?null==h?void 0:h.imageEng.url:(null==h?void 0:null===(n=h.image)||void 0===n?void 0:n.url)?null==h?void 0:h.image.url:"/images/sample-content.png",alt:null==h?void 0:null===(d=h.name)||void 0===d?void 0:d.en,width:700,height:700,style:{width:"100%",height:"auto"}}),(0,l.jsxs)(eE.A,{"aria-label":"breadcrumb",className:"my-2 text-xs text-gray-500 dark:text-gray-400",children:[(0,l.jsx)(v(),{underline:"hover",color:"inherit",href:"/",children:"Home"}),(0,l.jsx)(v(),{underline:"hover",color:"inherit",href:"/online-courses",children:"Online-Courses"}),(0,l.jsx)("span",{className:"font-bold text-orange-500",children:null==h?void 0:null===(u=h.name)||void 0===u?void 0:u.en})]})]})})},group:"courses"},{name:"onlineContents",description:{en:"show online course contents",th:"à¹à¸ªà¸à¸à¹à¸à¸·à¹à¸à¸«à¸² à¸à¸à¸£à¹à¸ªà¸à¸à¸à¹à¸¥à¸à¹"},thumbnail:"/images/sections/previews/contents.png",component:function(e){var t,r,s,i;let{pageData:o}=e,[n,d]=(0,a.useState)(null),{data:u,status:x}=(0,e_.useSession)();null==u||null===(t=u.user)||void 0===t||t.userId,(0,g.useRouter)();let{t:p,lang:m,selectedLang:h}=(0,c.A)();return(0,a.useEffect)(()=>
1{if("loading"===x)return},[x]),(0,a.useEffect)(()=>{o&&d(o)},[o]),console.log("data",n),(0,l.jsx)("div",{className:"bg-white dark:bg-gray-800",children:(0,l.jsxs)("div",{className:"max-w-screen-lg mx-auto px-4",children:[(0,l.jsxs)("div",{className:"flex flex-col mt-4 mx-auto justify-center items-center text-center gap-1",children:[(0,l.jsxs)("h1",{className:"text-3xl font-semibold text-orange-500 mt-2",children:[p(null==n?void 0:n.name)," "]}),(0,l.jsx)("p",{className:"text-gray-500",children:p(null==n?void 0:n.description)}),u&&(null==u?void 0:null===(r=u.user)||void 0===r?void 0:r.role)==="admin"&&(0,l.jsx)(eP,{course:n})]}),(0,l.jsx)("div",{className:"mt-4",children:(0,l.jsx)("div",{children:(0,l.jsx)("video",{src:null==n?void 0:null===(s=n.preview)||void 0===s?void 0:s.url,autoPlay:!0,controls:!0,className:"w-full h-auto rounded-lg",poster:null==n?void 0:null===(i=n.preview)||void 0===i?void 0:i.thumbnail,style:{aspectRatio:"16/9"}})})})]})})},group:"courses"}]},45290:e=>{e.exports={slider:"slide_slider__xr496","slick-dots":"slide_slick-dots__q4k_c","slick-active":"slide_slick-active__t3cnV"}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.