Files
web-alterflixhub/assets/admin-B3qgG4aa.js
T
Bkk1234 e6c4ebff48 chore(publish): replace source tree with static export at repo root
Publish the prerendered static export (index.html, 404.html, cinema/,
c/, about/, for-cinemas/, for-film-lovers/, assets/, images/, og/,
sitemap.xml, robots.txt) as the site root and remove the React Router
+ Nitro source tree from this branch. Source remains available in
history at 0548772.

Note: public/sw.js here reports VERSION v2.0.5 while the removed source
tree (v2.1.0) was newer, and .gitignore was not carried over.
2026-11-22 22:24:36 +07:00

5 lines
66 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{i as e,t}from"./react-B8IZ02wI.js";import{a as n,f as r}from"./components-LggAOTeO.js";import{t as i}from"./jsx-runtime-fBfwind-.js";import{r as a,t as o}from"./messages-nFlHChGW.js";import{t as s}from"./createReactComponent-C-DRqPhY.js";import{t as c}from"./footer-icons-kTf1LTdH.js";import{n as l,t as u}from"./contact-link-BLAvkJkh.js";import{a as d}from"./seo-CukKNP_H.js";import{a as f,f as p,t as m,y as h}from"./cinemas-CTA3vCte.js";var g=s(`outline`,`arrow-down`,`ArrowDown`,[[`path`,{d:`M12 5l0 14`,key:`svg-0`}],[`path`,{d:`M18 13l-6 6`,key:`svg-1`}],[`path`,{d:`M6 13l6 6`,key:`svg-2`}]]),_=s(`outline`,`arrow-up`,`ArrowUp`,[[`path`,{d:`M12 5l0 14`,key:`svg-0`}],[`path`,{d:`M18 11l-6 -6`,key:`svg-1`}],[`path`,{d:`M6 11l6 -6`,key:`svg-2`}]]),v=s(`outline`,`grip-vertical`,`GripVertical`,[[`path`,{d:`M8 5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-0`}],[`path`,{d:`M8 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-1`}],[`path`,{d:`M8 19a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-2`}],[`path`,{d:`M14 5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-3`}],[`path`,{d:`M14 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-4`}],[`path`,{d:`M14 19a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-5`}]]),y=s(`outline`,`photo-up`,`PhotoUp`,[[`path`,{d:`M15 8h.01`,key:`svg-0`}],[`path`,{d:`M12.5 21h-6.5a3 3 0 0 1 -3 -3v-12a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v6.5`,key:`svg-1`}],[`path`,{d:`M3 16l5 -5c.928 -.893 2.072 -.893 3 0l3.5 3.5`,key:`svg-2`}],[`path`,{d:`M14 14l1 -1c.679 -.653 1.473 -.829 2.214 -.526`,key:`svg-3`}],[`path`,{d:`M19 22v-6`,key:`svg-4`}],[`path`,{d:`M22 19l-3 -3l-3 3`,key:`svg-5`}]]),b=s(`outline`,`plus`,`Plus`,[[`path`,{d:`M12 5l0 14`,key:`svg-0`}],[`path`,{d:`M5 12l14 0`,key:`svg-1`}]]),x=s(`outline`,`sort-ascending-letters`,`SortAscendingLetters`,[[`path`,{d:`M15 10v-5c0 -1.38 .62 -2 2 -2s2 .62 2 2v5m0 -3h-4`,key:`svg-0`}],[`path`,{d:`M19 21h-4l4 -7h-4`,key:`svg-1`}],[`path`,{d:`M4 15l3 3l3 -3`,key:`svg-2`}],[`path`,{d:`M7 6v12`,key:`svg-3`}]]),S=s(`outline`,`trash`,`Trash`,[[`path`,{d:`M4 7l16 0`,key:`svg-0`}],[`path`,{d:`M10 11l0 6`,key:`svg-1`}],[`path`,{d:`M14 11l0 6`,key:`svg-2`}],[`path`,{d:`M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12`,key:`svg-3`}],[`path`,{d:`M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3`,key:`svg-4`}]]),C=e(t(),1),w=`w-full rounded-lg border border-[#303030] bg-[#141414] px-3 py-2 text-base text-white outline-none transition focus:border-[#A92626] focus-visible:ring-2 focus-visible:ring-[#A92626]/40 sm:text-sm`,T=`flex flex-col gap-1.5 text-xs text-[#999]`,E=`min-h-11 rounded-lg bg-[#8F0808] px-4 text-sm font-medium transition hover:bg-[#a30a0a] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[#D47272]`,D=`min-h-11 rounded-lg border border-[#303030] px-3 text-sm transition hover:border-[#A92626] hover:text-[#D47272] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[#A92626]`,O=`min-h-9 rounded-lg border border-[#303030] px-2.5 text-sm text-[#B3B3B3] transition hover:border-[#A92626] hover:text-[#D47272] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[#A92626] disabled:opacity-40`,k=i(),A=[{code:`th`,label:`ไทย`},{code:`en`,label:`English`}];function j({value:e,defaults:t,onChange:n,onSave:r,saving:i}){let[a,o]=(0,C.useState)(`th`),s=e[a];function c(t){n({...e,[a]:{...s,...t}})}function l(e,t){c({sections:s.sections.map((n,r)=>r===e?{...n,...t}:n)})}function u(e,t){let n=e+t;if(n<0||n>=s.sections.length)return;let r=[...s.sections],[i]=r.splice(e,1);r.splice(n,0,i),c({sections:r})}function d(){c({sections:[...s.sections,{heading:`หัวข้อที่ ${s.sections.length+1}`,body:``}]})}function f(e){c({sections:s.sections.filter((t,n)=>n!==e)})}function p(){n({...e,[a]:t[a]})}let m=s.title.trim()===``,h=s.lead.length>400;return(0,k.jsxs)(`div`,{className:`px-6 py-5`,children:[(0,k.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-3`,children:[(0,k.jsx)(`div`,{role:`tablist`,"aria-label":`ภาษา`,className:`flex items-center gap-1 rounded-lg border border-[#242424] bg-[#141414] p-1`,children:A.map(e=>(0,k.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":a===e.code,onClick:()=>o(e.code),className:`min-h-9 rounded-md px-4 text-sm transition ${a===e.code?`bg-[#242424] font-semibold text-[#D47272]`:`text-[#999] hover:text-white`}`,children:e.label},e.code))}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsxs)(`button`,{type:`button`,className:D,onClick:p,children:[`คืนค่าตั้งต้น (`,a.toUpperCase(),`)`]}),(0,k.jsx)(`button`,{type:`button`,className:E,onClick:r,disabled:i,children:i?`กำลังบันทึก…`:`บันทึกหน้าเกี่ยวกับเรา`})]})]}),(0,k.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,k.jsxs)(`label`,{className:T,children:[`หัวข้อหลัก (H1)`,(0,k.jsx)(`input`,{className:w,value:s.title,onChange:e=>c({title:e.target.value}),"aria-describedby":`about-title-help`,"aria-invalid":m}),(0,k.jsx)(`span`,{id:`about-title-help`,className:m?`text-[#D47272]`:`text-[#8A8A8A]`,children:m?`ต้องมีหัวข้อ — ถ้าเว้นว่าง ระบบจะใช้ข้อความตั้งต้น`:`แสดงบนสุดของหน้า · ${s.title.length}/80 ตัวอักษร`})]}),(0,k.jsxs)(`label`,{className:T,children:[`ย่อหน้าแนะนำ (ใต้หัวข้อ)`,(0,k.jsx)(`textarea`,{className:`${w} min-h-24 leading-[1.7]`,value:s.lead,onChange:e=>c({lead:e.target.value}),"aria-describedby":`about-lead-help`,"aria-invalid":h}),(0,k.jsx)(`span`,{id:`about-lead-help`,className:h?`text-[#D47272]`:`text-[#8A8A8A]`,children:h?`ยาวเกิน 400 ตัวอักษร — บนมือถือจะอ่านยาก`:`${s.lead.length}/400 ตัวอักษร`})]}),(0,k.jsxs)(`fieldset`,{className:`flex flex-col gap-3`,children:[(0,k.jsxs)(`legend`,{className:`mb-1 text-xs text-[#999]`,children:[`ส่วนย่อย (`,s.sections.length,` ส่วน)`]}),s.sections.map((e,t)=>(0,k.jsxs)(`div`,{className:`rounded-xl border border-[#242424] bg-[#141414] p-4`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,k.jsxs)(`span`,{className:`text-xs text-[#8A8A8A]`,children:[`ส่วนที่ `,t+1]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,k.jsx)(`button`,{type:`button`,className:`size-8 rounded-md text-[#999] transition hover:bg-[#242424] hover:text-white disabled:opacity-40`,onClick:()=>u(t,-1),disabled:t===0,"aria-label":`เลื่อนส่วนที่ ${t+1} ขึ้น`,children:`↑`}),(0,k.jsx)(`button`,{type:`button`,className:`size-8 rounded-md text-[#999] transition hover:bg-[#242424] hover:text-white disabled:opacity-40`,onClick:()=>u(t,1),disabled:t===s.sections.length-1,"aria-label":`เลื่อนส่วนที่ ${t+1} ลง`,children:`↓`}),(0,k.jsx)(`button`,{type:`button`,className:`min-h-8 rounded-md px-2 text-xs text-[#D47272] transition hover:bg-[#242424]`,onClick:()=>f(t),children:`ลบ`})]})]}),(0,k.jsxs)(`label`,{className:T,children:[`หัวข้อย่อย`,(0,k.jsx)(`input`,{className:w,value:e.heading,onChange:e=>l(t,{heading:e.target.value})})]}),(0,k.jsxs)(`label`,{className:`${T} mt-2`,children:[`เนื้อหา`,(0,k.jsx)(`textarea`,{className:`${w} min-h-24 leading-[1.75]`,value:e.body,onChange:e=>l(t,{body:e.target.value})})]})]},t)),(0,k.jsx)(`button`,{type:`button`,className:`${D} self-start`,onClick:d,children:`+ เพิ่มส่วน`})]}),(0,k.jsxs)(`div`,{className:`rounded-xl border border-[#A92626]/40 bg-[#141414] p-4`,children:[(0,k.jsx)(`p`,{className:`mb-3 text-xs text-[#999]`,children:`กล่องติดต่อ (ท้ายหน้า)`}),(0,k.jsxs)(`label`,{className:T,children:[`หัวข้อ`,(0,k.jsx)(`input`,{className:w,value:s.contactHeading,onChange:e=>c({contactHeading:e.target.value})})]}),(0,k.jsxs)(`label`,{className:`${T} mt-2`,children:[`ข้อความ`,(0,k.jsx)(`textarea`,{className:`${w} min-h-20 leading-[1.75]`,value:s.contactNote,onChange:e=>c({contactNote:e.target.value})})]})]})]}),(0,k.jsxs)(`aside`,{className:`lg:sticky lg:top-24 lg:self-start`,children:[(0,k.jsx)(`p`,{className:`mb-2 text-xs text-[#8A8A8A]`,children:`ตัวอย่างหน้าเว็บ (สด)`}),(0,k.jsxs)(`div`,{className:`rounded-xl border border-[#242424] bg-[#0D0D0D] p-4`,children:[(0,k.jsx)(`h3`,{className:`text-xl font-bold leading-[1.3]`,children:s.title||`—`}),(0,k.jsx)(`p`,{className:`mt-2 text-sm leading-[1.7] text-[#B3B3B3]`,children:s.lead||`—`}),(0,k.jsx)(`div`,{className:`mt-3 flex flex-col gap-2`,children:s.sections.map((e,t)=>(0,k.jsxs)(`div`,{className:`rounded-lg border border-[#242424] bg-[#141414] p-3`,children:[(0,k.jsx)(`p`,{className:`text-sm font-semibold`,children:e.heading}),(0,k.jsx)(`p`,{className:`mt-1 text-xs leading-[1.7] text-[#B3B3B3]`,children:e.body})]},t))}),(0,k.jsxs)(`div`,{className:`mt-3 rounded-lg border border-[#A92626]/50 bg-gradient-to-b from-[#8F0808]/20 to-transparent p-3`,children:[(0,k.jsx)(`p`,{className:`text-sm font-semibold`,children:s.contactHeading}),(0,k.jsx)(`p`,{className:`mt-1 text-xs leading-[1.7] text-[#B3B3B3]`,children:s.contactNote})]})]}),(0,k.jsxs)(`a`,{href:`/about?lang=${a}`,target:`_blank`,rel:`noreferrer`,className:`mt-3 inline-flex min-h-11 items-center text-xs text-[#D47272] underline-offset-4 hover:underline`,children:[`เปิดหน้า /about?lang=`,a,` ↗`]})]})]})]})}function M({title:e,description:t,badge:n,defaultOpen:r=!1,children:i}){return(0,k.jsxs)(`details`,{open:r,className:`group overflow-hidden rounded-xl border border-[#242424] bg-[#111111]`,children:[(0,k.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 transition hover:bg-[#171717] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-[#A92626] [&::-webkit-details-marker]:hidden`,children:[(0,k.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,k.jsx)(l,{size:16,className:`shrink-0 text-[#8F8F8F] transition-transform group-open:rotate-90`}),(0,k.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e}),n?(0,k.jsx)(`span`,{className:`shrink-0 rounded-full bg-[#242424] px-2 py-0.5 text-[11px] text-[#B3B3B3]`,children:n}):null]}),t?(0,k.jsx)(`span`,{className:`hidden shrink-0 text-[11px] text-[#777] sm:block`,children:t}):null]}),(0,k.jsx)(`div`,{className:`border-t border-[#242424] px-4 py-4`,children:i})]})}function N({block:e,index:t,total:n,onChange:r,onMove:i,onRemove:a}){return(0,k.jsxs)(`div`,{className:`rounded-xl border border-[#242424] bg-[#141414] p-4`,children:[(0,k.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:`text-xs uppercase tracking-wide text-[#999]`,children:e.type===`image`?`รูปที่ ${t+1}`:`ย่อหน้าที่ ${t+1}`}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,k.jsx)(`button`,{type:`button`,className:O,"aria-label":`เลื่อนขึ้น (บล็อกที่ ${t+1})`,onClick:()=>i(-1),disabled:t===0,children:`↑`}),(0,k.jsx)(`button`,{type:`button`,className:O,"aria-label":`เลื่อนลง (บล็อกที่ ${t+1})`,onClick:()=>i(1),disabled:t===n-1,children:`↓`}),(0,k.jsx)(`button`,{type:`button`,className:O,"aria-label":`ลบบล็อกที่ ${t+1}`,onClick:a,children:`ลบ`})]})]}),e.type===`paragraph`?(0,k.jsx)(`textarea`,{value:e.text,onChange:e=>r({type:`paragraph`,text:e.target.value}),rows:4,placeholder:`พิมพ์ย่อหน้าที่นี่ — เว้นบรรทัดใหม่ได้ ระบบจะแสดงตามที่พิมพ์`,className:w}):(0,k.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(0,1fr)_180px]`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,k.jsxs)(`label`,{className:T,children:[`ลิงก์รูป (URL หรือ /images/…)`,(0,k.jsx)(`input`,{value:e.src,onChange:t=>r({...e,src:t.target.value}),placeholder:`/images/house-cinema.jpg`,className:w})]}),(0,k.jsxs)(`label`,{className:T,children:[`คำอธิบายรูป (alt) — จำเป็นต่อการเข้าถึง`,(0,k.jsx)(`input`,{value:e.alt,onChange:t=>r({...e,alt:t.target.value}),placeholder:`บรรยากาศภายในโรงหนัง`,className:w})]}),(0,k.jsxs)(`label`,{className:T,children:[`คำบรรยายใต้รูป (ไม่ใส่ก็ได้)`,(0,k.jsx)(`input`,{value:e.caption,onChange:t=>r({...e,caption:t.target.value}),className:w})]})]}),(0,k.jsx)(`div`,{className:`flex items-start justify-center rounded-lg border border-[#242424] bg-[#0D0D0D] p-2`,children:e.src.trim()===``?(0,k.jsx)(`span`,{className:`py-8 text-xs text-[#666]`,children:`ยังไม่ได้ใส่ลิงก์รูป`}):(0,k.jsx)(`img`,{src:e.src,alt:``,className:`max-h-[140px] w-full rounded-md object-cover`})})]})]})}function P(e=``){return{type:`paragraph`,text:e}}function F(){return{type:`image`,src:``,alt:``,caption:``}}function ee(e,t,n){let r=t+n;if(t<0||t>=e.length||r<0||r>=e.length)return e;let i=[...e],[a]=i.splice(t,1);return i.splice(r,0,a),i}function te(e,t){return t<0||t>=e.length?e:e.filter((e,n)=>n!==t)}function ne(e){return e.filter(e=>e.type===`image`).length}var I=[{code:`th`,label:`ไทย`},{code:`en`,label:`English`}];function re({value:e,defaults:t,onChange:n,onSave:r,saving:i,saveLabel:a}){let[o,s]=(0,C.useState)(`th`),c=e[o];function l(t){n({...e,[o]:{...c,...t}})}function u(e,t){l({blocks:c.blocks.map((n,r)=>r===e?t:n)})}function d(){n({...e,[o]:t[o]})}let f=ne(c.blocks),p=c.blocks.length-f;return(0,k.jsxs)(`div`,{className:`px-6 py-5`,children:[(0,k.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-3`,children:[(0,k.jsx)(`div`,{role:`tablist`,"aria-label":`ภาษา`,className:`flex items-center gap-1 rounded-lg border border-[#242424] bg-[#141414] p-1`,children:I.map(e=>(0,k.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":o===e.code,onClick:()=>s(e.code),className:`min-h-9 rounded-md px-4 text-sm transition ${o===e.code?`bg-[#242424] font-semibold text-[#D47272]`:`text-[#999] hover:text-white`}`,children:e.label},e.code))}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsxs)(`span`,{className:`text-xs text-[#999]`,children:[p,` ย่อหน้า · `,f,` รูป`]}),(0,k.jsxs)(`button`,{type:`button`,className:D,onClick:d,children:[`คืนค่าตั้งต้น (`,o.toUpperCase(),`)`]}),(0,k.jsx)(`button`,{type:`button`,className:E,onClick:r,disabled:i,children:i?`กำลังบันทึก…`:a})]})]}),(0,k.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,k.jsxs)(`label`,{className:T,children:[`หัวเรื่อง (H1)`,(0,k.jsx)(`input`,{value:c.title,onChange:e=>l({title:e.target.value}),placeholder:`สำหรับคนทำโรงหนัง`,className:w}),c.title.trim()===``?(0,k.jsx)(`span`,{className:`text-[#D47272]`,children:`เว้นว่างไม่ได้ — ระบบจะใช้ค่าเดิม`}):null]}),(0,k.jsxs)(`label`,{className:T,children:[`คำเกริ่นนำ (แสดงใต้หัวเรื่อง)`,(0,k.jsx)(`textarea`,{value:c.lead,onChange:e=>l({lead:e.target.value}),rows:3,className:w})]})]}),(0,k.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,k.jsx)(`h3`,{className:`text-sm font-semibold text-white`,children:`เนื้อหาบทความ`}),(0,k.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,className:D,onClick:()=>l({blocks:[...c.blocks,P()]}),children:`+ เพิ่มย่อหน้า`}),(0,k.jsx)(`button`,{type:`button`,className:D,onClick:()=>l({blocks:[...c.blocks,F()]}),children:`+ เพิ่มรูปภาพ`})]})]}),c.blocks.length===0?(0,k.jsx)(`p`,{className:`rounded-lg border border-dashed border-[#303030] p-6 text-center text-sm text-[#999]`,children:`ยังไม่มีเนื้อหา — กด “เพิ่มย่อหน้า” หรือ “เพิ่มรูปภาพ” เพื่อเริ่มเขียน`}):null,c.blocks.map((e,t)=>(0,k.jsx)(N,{block:e,index:t,total:c.blocks.length,onChange:e=>u(t,e),onMove:e=>l({blocks:ee(c.blocks,t,e)}),onRemove:()=>l({blocks:te(c.blocks,t)})},`${e.type}-${t}`))]}),(0,k.jsxs)(`div`,{className:`mt-6 grid gap-4 lg:grid-cols-2`,children:[(0,k.jsxs)(`label`,{className:T,children:[`หัวข้อการ์ดติดต่อ`,(0,k.jsx)(`input`,{value:c.contactHeading,onChange:e=>l({contactHeading:e.target.value}),className:w})]}),(0,k.jsxs)(`label`,{className:T,children:[`ข้อความในการ์ดติดต่อ`,(0,k.jsx)(`textarea`,{value:c.contactNote,onChange:e=>l({contactNote:e.target.value}),rows:3,className:w})]})]})]})}function ie({options:e,selected:t,onToggle:n,emptyHint:r}){let i=new Set(t),a=new Set(e.map(e=>e.value)),o=t.filter(e=>!a.has(e));return(0,k.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.map(e=>{let t=i.has(e.value);return(0,k.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>n(e.value),className:`rounded-full border px-3 py-1 text-xs transition ${t?`border-[#A92626] bg-[rgba(143,8,8,0.18)] text-[#D47272]`:`border-[#303030] text-[#999] hover:border-[#A92626] hover:text-white`}`,children:e.label},e.value)}),o.map(e=>(0,k.jsx)(`button`,{type:`button`,"aria-pressed":!0,onClick:()=>n(e),className:`rounded-full border border-[#A92626] bg-[rgba(143,8,8,0.18)] px-3 py-1 text-xs text-[#D47272] transition hover:border-[#D47272]`,children:e},e)),e.length===0&&o.length===0&&r?(0,k.jsx)(`span`,{className:`text-xs text-[#777]`,children:r}):null]})}function ae(e,t,n){let r=e.includes(t)?e.filter(e=>e!==t):[...e,t],i=e=>{let t=n.indexOf(e);return t<0?n.length+1:t};return[...r].sort((e,t)=>i(e)-i(t))}var oe=a.th;function se({facilities:e,details:t,hasDescriptions:n,onChange:r,inputClass:i,labelClass:o}){if(e.length===0)return(0,k.jsx)(`span`,{className:`text-[11px] text-[#777]`,children:`เลือกหัวข้อด้านบนก่อน แล้วค่อยใส่ชื่อที่ต้องการ`});function s(e,n){let i={...t[e]??{},...n},a={};i.label?.trim()&&(a.label=i.label),i.sub_th?.trim()&&(a.sub_th=i.sub_th),i.sub_en?.trim()&&(a.sub_en=i.sub_en),r({...t,[e]:a})}return(0,k.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.map(e=>{let r=oe.facilities[e],c=t[e]??{};return(0,k.jsxs)(`div`,{className:`grid gap-2 rounded-lg border border-[#242424] p-2 sm:grid-cols-2`,children:[(0,k.jsxs)(`label`,{className:o,children:[`ชื่อหัวข้อ`,(0,k.jsx)(`input`,{className:i,value:c.label??``,placeholder:r.title,onChange:t=>s(e,{label:t.target.value})})]}),n?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`label`,{className:o,children:[`คำอธิบาย (TH)`,(0,k.jsx)(`input`,{className:i,value:c.sub_th??``,placeholder:r.sub,onChange:t=>s(e,{sub_th:t.target.value})})]}),(0,k.jsxs)(`label`,{className:o,children:[`คำอธิบาย (EN)`,(0,k.jsx)(`input`,{className:i,value:c.sub_en??``,placeholder:a.en.facilities[e].sub,onChange:t=>s(e,{sub_en:t.target.value})})]})]}):null]},e)})})}var L={โรงภาพยนตร์ท้องถิ่น:`ท้องถิ่น`,โรงภาพยนตร์อินดี้:`อินดี้`,กลุ่มคนฉายหนัง:`กลุ่ม`},R=new Intl.Collator(`th`,{sensitivity:`base`,numeric:!0});function z(e){return(e.name_th?.trim()||e.name||``).trim()}function B(e){return[...e].sort((e,t)=>R.compare(z(e),z(t)))}function ce(e,t){return e.length===t.length&&e.every((e,n)=>e.slug===t[n]?.slug)}function le(e,t,n,r=`before`){if(t===n)return e;let i=e.findIndex(e=>e.slug===t),a=e.findIndex(e=>e.slug===n);if(i<0||a<0)return e;let o=[...e],[s]=o.splice(i,1),c=o.findIndex(e=>e.slug===n);return c<0?e:(o.splice(r===`after`?c+1:c,0,s),o)}function V(e,t,n){let r=e.findIndex(e=>e.slug===t),i=r+n;if(r<0||i<0||i>=e.length)return e;let a=[...e],[o]=a.splice(r,1);return a.splice(i,0,o),a}var H=e=>`flex-1 rounded-md px-2 py-1 text-[11px] transition ${e?`bg-[#242424] text-[#D47272]`:`text-[#999] hover:text-white`}`,U=`flex size-6 items-center justify-center rounded text-[#777] transition hover:bg-[#242424] hover:text-white disabled:pointer-events-none disabled:opacity-30`;function ue({cinemas:e,selected:t,dirty:n,saving:r,onSelect:i,onReorder:a,onSaveOrder:o,onBulkVenue:s}){let[c,l]=(0,C.useState)(`manual`),[u,d]=(0,C.useState)(`all`),[m,y]=(0,C.useState)(``),[b,S]=(0,C.useState)(f[0]),[w,T]=(0,C.useState)(null),[E,D]=(0,C.useState)(null),O=(0,C.useMemo)(()=>h(e),[e]),A=(0,C.useMemo)(()=>p(e,{venue:u,query:m}),[e,u,m]),j=u!==`all`||m.trim()!==``,M=(0,C.useMemo)(()=>c===`thai`?B(A):A,[A,c]);function N(t,n){t.preventDefault();let r=w??t.dataTransfer.getData(`text/plain`);D(null),T(null),!(!r||r===n)&&a(le(e,r,n))}return(0,k.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1 rounded-lg border border-[#303030] p-1`,children:[(0,k.jsx)(`button`,{type:`button`,className:H(c===`manual`),"aria-pressed":c===`manual`,onClick:()=>l(`manual`),children:`ลำดับที่จัดไว้`}),(0,k.jsx)(`button`,{type:`button`,className:H(c===`thai`),"aria-pressed":c===`thai`,onClick:()=>l(`thai`),children:(0,k.jsxs)(`span`,{className:`inline-flex items-center justify-center gap-1`,children:[(0,k.jsx)(x,{size:13}),` ก-ฮ`]})})]}),(0,k.jsx)(`input`,{type:`search`,value:m,onChange:e=>y(e.target.value),placeholder:`ค้นชื่อหรือ slug…`,"aria-label":`ค้นหาโรงหนัง`,className:`w-full rounded-lg border border-[#303030] bg-[#141414] px-2 py-1.5 text-[12px] text-[#E5E5E5] placeholder:text-[#666] focus:border-[#A92626] focus:outline-none`}),(0,k.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[[`all`,`ทั้งหมด`,e.length],...f.map(e=>[e,L[e],O[e]]),[`unset`,`ยังไม่จัด`,O.unset]].map(([e,t,n])=>{let r=u===e;return(0,k.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>d(e),className:`rounded-md border px-1.5 py-0.5 text-[10px] transition ${r?`border-[#A92626] bg-[#242424] text-[#D47272]`:`border-[#303030] text-[#999] hover:border-[#A92626]/60 hover:text-white`}`,children:[t,` `,n]},e)})}),s&&j?(0,k.jsxs)(`div`,{className:`rounded-lg border border-[#303030] bg-[#141414] p-2`,children:[(0,k.jsxs)(`p`,{className:`text-[11px] leading-[1.6] text-[#999]`,children:[`ตั้งประเภทให้ `,M.length,` โรงที่กรองอยู่`]}),(0,k.jsxs)(`div`,{className:`mt-1 flex items-center gap-1`,children:[(0,k.jsx)(`select`,{value:b,"aria-label":`เลือกประเภทที่จะตั้งให้ทั้งกลุ่ม`,onChange:e=>S(e.target.value),className:`min-w-0 flex-1 rounded-md border border-[#303030] bg-[#1B1B1B] px-1.5 py-1 text-[11px] text-[#E5E5E5] focus:border-[#A92626] focus:outline-none`,children:f.map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))}),(0,k.jsx)(`button`,{type:`button`,disabled:M.length===0,onClick:()=>s(M.map(e=>e.slug),b),className:`rounded-md bg-[#8F0808] px-2 py-1 text-[11px] transition hover:bg-[#a30a0a] disabled:opacity-50`,children:`ใช้`})]}),(0,k.jsx)(`p`,{className:`mt-1 text-[10px] leading-[1.5] text-[#777]`,children:`ต้องกด "บันทึกทั้งหมด" อีกครั้งเพื่อบันทึกลงไฟล์`})]}):null,c===`thai`?(0,k.jsxs)(`div`,{className:`rounded-lg border border-[#303030] bg-[#141414] p-2 text-[11px] leading-[1.7] text-[#999]`,children:[`เรียงตามชื่อไทย ก-ฮ · โหมดนี้ลากสลับไม่ได้`,(0,k.jsx)(`button`,{type:`button`,className:`mt-1 block w-full rounded-md border border-[#303030] px-2 py-1 text-[11px] text-[#D47272] transition hover:border-[#A92626]`,onClick:()=>{a(B(e)),l(`manual`)},children:`ใช้ลำดับ ก-ฮ นี้ (แล้วกดบันทึก)`})]}):(0,k.jsx)(`p`,{className:`px-1 text-[11px] leading-[1.6] text-[#777]`,children:j?`กำลังกรองอยู่ — ล้างตัวกรองก่อนจึงจะลาก/เลื่อนลำดับได้`:`ลากชื่อเพื่อสลับตำแหน่ง หรือกด ↑ ↓ ทีละขั้น`}),n?(0,k.jsx)(`button`,{type:`button`,disabled:r,className:`rounded-lg bg-[#8F0808] px-3 py-1.5 text-[11px] font-medium transition hover:bg-[#a30a0a] disabled:opacity-60`,onClick:o,children:r?`กำลังบันทึก…`:`บันทึกลำดับใหม่`}):null,(0,k.jsxs)(`ul`,{className:`flex max-h-[62vh] flex-col gap-1 overflow-y-auto pr-1`,children:[M.map((n,r)=>{let o=n.slug===t,s=w===n.slug,l=E===n.slug&&w!==n.slug;return(0,k.jsxs)(`li`,{draggable:c===`manual`&&!j,onDragStart:e=>{T(n.slug),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,n.slug)},onDragOver:e=>{c===`manual`&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,D(n.slug))},onDragLeave:()=>{D(e=>e===n.slug?null:e)},onDrop:e=>N(e,n.slug),onDragEnd:()=>{T(null),D(null)},className:`group flex items-center gap-1 rounded-lg pr-1 transition ${o?`bg-[#242424]`:`hover:bg-[#1B1B1B]`} ${s?`opacity-40`:``} ${l?`outline outline-2 outline-offset-[-2px] outline-[#A92626]`:``} ${c===`manual`?`cursor-grab active:cursor-grabbing`:``}`,children:[(0,k.jsx)(`span`,{"aria-hidden":`true`,className:`pl-1 ${c===`manual`?`text-[#555] group-hover:text-[#999]`:`text-transparent`}`,children:(0,k.jsx)(v,{size:14})}),(0,k.jsxs)(`button`,{type:`button`,onClick:()=>i(n.slug),className:`min-w-0 flex-1 py-2 text-left text-sm transition ${o?`text-[#D47272]`:`text-[#B3B3B3] hover:text-white`}`,children:[(0,k.jsx)(`span`,{className:`block truncate`,children:n.name_th||n.name}),(0,k.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,k.jsx)(`span`,{className:`block min-w-0 flex-1 truncate text-[10px] text-[#777]`,children:n.slug}),(0,k.jsx)(`span`,{className:`shrink-0 rounded border px-1 text-[9px] ${n.venue_type?`border-[#303030] text-[#999]`:`border-[#8F0808]/60 text-[#D47272]`}`,children:n.venue_type?L[n.venue_type]:`ยังไม่จัด`})]})]}),c===`manual`&&!j?(0,k.jsxs)(`span`,{className:`flex flex-col`,children:[(0,k.jsx)(`button`,{type:`button`,className:U,"aria-label":`เลื่อน ${n.name_th||n.name} ขึ้น`,disabled:r===0,onClick:()=>a(V(e,n.slug,-1)),children:(0,k.jsx)(_,{size:13})}),(0,k.jsx)(`button`,{type:`button`,className:U,"aria-label":`เลื่อน ${n.name_th||n.name} ลง`,disabled:r===M.length-1,onClick:()=>a(V(e,n.slug,1)),children:(0,k.jsx)(g,{size:13})})]}):null]},n.slug)}),M.length===0?(0,k.jsx)(`li`,{className:`px-2 py-3 text-center text-[11px] text-[#777]`,children:`ไม่พบโรงหนังตามตัวกรองนี้`}):null]})]})}function W(e){return e.replace(/[,、]/g,`,`).split(/[,\n]/).map(e=>e.trim()).filter(e=>e!==``)}function G(e){return e.join(`, `)}function K({value:e,onChangeValue:t,className:n,placeholder:r,id:i}){let a=G(e),[o,s]=(0,C.useState)(null);return(0,C.useEffect)(()=>{o!==null&&G(W(o))!==a&&s(null)},[a,o]),(0,k.jsx)(`input`,{id:i,className:n,placeholder:r,value:o??a,spellCheck:!1,onChange:e=>{let n=e.target.value;s(n),t(W(n))},onBlur:()=>s(null)})}var de=[`Website`,`Facebook`,`Instagram`,`Line`,`Call`,`อีเมล`,`จองตั๋ว`],fe=`flex min-h-9 items-center gap-1 rounded-lg border border-[#303030] px-2 text-xs text-[#999] transition hover:border-[#A92626] hover:text-[#D47272]`;function pe({contacts:e,onChange:t,inputClass:n,labelClass:r}){function i(n,r){t(e.map((e,t)=>t===n?{...e,...r}:e))}return(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsx)(`span`,{className:`text-xs text-[#999]`,children:`ช่องทางติดต่อ / จองตั๋ว`}),e.length===0?(0,k.jsx)(`span`,{className:`text-[11px] text-[#777]`,children:`ยังไม่มีช่องทางติดต่อ — หน้าเว็บจะขึ้น “ยังไม่ระบุช่องทางติดต่อ”`}):null,e.map((a,o)=>(0,k.jsxs)(`div`,{className:`grid gap-2 rounded-lg border border-[#242424] p-2 sm:grid-cols-[130px_minmax(0,1fr)_minmax(0,1fr)_auto]`,children:[(0,k.jsxs)(`label`,{className:r,children:[`ป้ายชื่อ`,(0,k.jsx)(`input`,{className:n,value:a.label,placeholder:`Website`,list:`contact-label-options`,onChange:e=>i(o,{label:e.target.value})})]}),(0,k.jsxs)(`label`,{className:r,children:[`ข้อความที่แสดง`,(0,k.jsx)(`input`,{className:n,value:a.value,placeholder:`www.housesamyan.com`,onChange:e=>i(o,{value:e.target.value})})]}),(0,k.jsxs)(`label`,{className:r,children:[`ลิงก์ (ไม่บังคับ — ระบบเติมให้อัตโนมัติ)`,(0,k.jsx)(`input`,{className:n,value:a.href??``,placeholder:`https://… หรือ tel:+66…`,onChange:e=>i(o,{href:e.target.value.trim()===``?null:e.target.value}),onBlur:()=>{let e=u(a);e.href!==(a.href??null)&&i(o,{href:e.href})}})]}),(0,k.jsx)(`div`,{className:`flex items-end`,children:(0,k.jsx)(`button`,{type:`button`,className:fe,"aria-label":`ลบช่องทางที่ ${o+1}`,onClick:()=>t(e.filter((e,t)=>t!==o)),children:(0,k.jsx)(S,{size:14})})}),(0,k.jsx)(`span`,{className:`text-[11px] text-[#777] sm:col-span-4`,children:(()=>{let e=u(a);return e.href?`✓ ${e.kind===`tel`?`กดโทรได้`:e.kind===`mailto`?`เปิดอีเมล`:`เปิดเว็บ (แท็บใหม่)`} → ${e.href}`:a.value.trim()===``?`ใส่ข้อความหรือเบอร์ก่อน — ระบบจะสร้างลิงก์ให้`:`⚠ ค่านี้ยังใช้เป็นลิงก์ไม่ได้ (ต้องเป็นเบอร์ / อีเมล / โดเมน / URL)`})()})]},o)),(0,k.jsx)(`datalist`,{id:`contact-label-options`,children:de.map(e=>(0,k.jsx)(`option`,{value:e},e))}),(0,k.jsxs)(`button`,{type:`button`,className:`${fe} w-fit`,onClick:()=>t([...e,{label:``,value:``,href:null}]),children:[(0,k.jsx)(b,{size:14}),`เพิ่มช่องทางติดต่อ`]})]})}var q=8*1024*1024,J=`flex min-h-9 items-center gap-1 rounded-lg border border-[#303030] px-2 text-xs text-[#999] transition hover:border-[#A92626] hover:text-[#D47272] disabled:opacity-50`,me=`flex min-h-10 w-fit items-center gap-2 rounded-lg border border-[#A92626]/60 bg-[#1B1B1B] px-3 text-sm text-white transition hover:border-[#A92626] hover:text-[#D47272] disabled:opacity-50`;function he({photos:e,onChange:t,inputClass:n,labelClass:r,cinemaSlug:i}){let a=(0,C.useRef)(null),[o,s]=(0,C.useState)(!1),[c,l]=(0,C.useState)(null),[u,d]=(0,C.useState)(!1);function f(n,r){t(e.map((e,t)=>t===n?r:e))}async function p(n){let r=Array.from(n).filter(e=>e.size>0);if(r.length===0)return;let o=r.find(e=>e.size>q);if(o){l(`ไฟล์ "${o.name}" ใหญ่เกิน ${Math.round(q/1024/1024)} MB`);return}s(!0),l(null);let c=[];try{for(let e of r){let t=new FormData;t.append(`file`,e),i&&t.append(`slug`,i);let n=await fetch(`/api/admin/uploads`,{method:`POST`,body:t});if(!n.ok){let e=await n.text();throw Error(e||`อัปโหลดไม่สำเร็จ (${n.status})`)}let r=await n.json();if(!r.url)throw Error(`เซิร์ฟเวอร์ไม่ได้คืน URL ของรูป`);c.push(r.url)}c.length>0&&t([...e,...c])}catch(e){l(e instanceof Error?e.message:`อัปโหลดไม่สำเร็จ`)}finally{s(!1),a.current&&(a.current.value=``)}}return(0,k.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-dashed p-2 transition ${u?`border-[#A92626] bg-[#1B1B1B]/60`:`border-transparent`}`,onDragOver:e=>{e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),d(!0))},onDragLeave:()=>d(!1),onDrop:e=>{e.dataTransfer?.files?.length&&(e.preventDefault(),d(!1),p(e.dataTransfer.files))},onPaste:e=>{let t=Array.from(e.clipboardData?.files??[]);t.length!==0&&(e.preventDefault(),p(t))},children:[(0,k.jsx)(`span`,{className:`text-xs text-[#999]`,children:`รูปภาพโรงหนัง`}),e.length===0?(0,k.jsx)(`span`,{className:`text-[11px] text-[#777]`,children:`ยังไม่มีรูป — อัปโหลดจากเครื่อง หรือวาง URL ด้านล่าง (ภาพที่ 1/2/3)`}):null,e.map((i,a)=>(0,k.jsxs)(`div`,{className:`grid items-center gap-2 rounded-lg border border-[#242424] p-2 sm:grid-cols-[64px_minmax(0,1fr)_auto_auto]`,children:[(0,k.jsx)(`div`,{className:`size-16 overflow-hidden rounded-md border border-[#303030] bg-[#141414]`,children:i?(0,k.jsx)(`img`,{src:i,alt:``,className:`size-full object-cover`,loading:`lazy`}):null}),(0,k.jsxs)(`label`,{className:r,children:[a===0?`รูปหลัก (URL หรือ /images/...)`:`รูปที่ ${a+1}`,(0,k.jsx)(`input`,{className:n,value:i,placeholder:`/images/hero.png หรือ https://…/photo.jpg`,onChange:e=>f(a,e.target.value)})]}),(0,k.jsxs)(`div`,{className:`flex gap-1`,children:[(0,k.jsx)(`button`,{type:`button`,className:J,"aria-label":`เลื่อนรูปที่ ${a+1} ขึ้น`,disabled:a===0,onClick:()=>{let n=[...e];[n[a-1],n[a]]=[n[a],n[a-1]],t(n)},children:`↑`}),(0,k.jsx)(`button`,{type:`button`,className:J,"aria-label":`เลื่อนรูปที่ ${a+1} ลง`,disabled:a===e.length-1,onClick:()=>{let n=[...e];[n[a+1],n[a]]=[n[a],n[a+1]],t(n)},children:`↓`})]}),(0,k.jsx)(`button`,{type:`button`,className:J,"aria-label":`ลบรูปที่ ${a+1}`,onClick:()=>t(e.filter((e,t)=>t!==a)),children:(0,k.jsx)(S,{size:14})})]},a)),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsxs)(`button`,{type:`button`,className:me,disabled:o,onClick:()=>a.current?.click(),children:[(0,k.jsx)(y,{size:16}),o?`กำลังอัปโหลด…`:`อัปโหลดรูปจากเครื่อง`]}),(0,k.jsxs)(`button`,{type:`button`,className:`${J} w-fit`,onClick:()=>t([...e,``]),children:[(0,k.jsx)(b,{size:14}),`เพิ่มช่อง URL`]}),(0,k.jsxs)(`span`,{className:`text-[11px] text-[#777]`,children:[`ลากไฟล์มาวาง หรือ Ctrl+V ในกล่องนี้ · JPG/PNG/WebP/AVIF ≤`,` `,Math.round(q/1024/1024),` MB`]})]}),(0,k.jsx)(`input`,{ref:a,type:`file`,accept:`image/jpeg,image/png,image/webp,image/avif`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&p(e.target.files)}}),c?(0,k.jsx)(`span`,{role:`alert`,className:`text-[11px] text-[#D47272]`,children:c}):null]})}var ge=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function Y(e){return e.trim().toLowerCase().replace(/[\s_]+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-{2,}/g,`-`).replace(/^-+|-+$/g,``)}function _e(e){return Y(e.normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).replace(/&/g,` and `).replace(/['’]/g,``))}function ve(e,t){return e===``?`slug ว่างไม่ได้`:ge.test(e)?t.others.some(n=>n===e&&n!==t.self)?`slug นี้มีโรงอื่นใช้อยู่`:null:`ใช้ได้เฉพาะ a-z, 0-9 และ - (ห้ามขีดติดกัน/หัวท้าย)`}function ye({value:e,others:t,onChange:n,className:r}){let[i,a]=(0,C.useState)(null),[o,s]=(0,C.useState)(null),c=(0,C.useRef)(e);(0,C.useEffect)(()=>{c.current!==e&&(c.current=e,a(null))},[e]);let l=i??e,u=Y(l),d=ve(u,{others:t,self:e}),f=u!==e;return(0,k.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,k.jsx)(`input`,{className:r,value:l,spellCheck:!1,placeholder:`house-cinema-samyan`,onChange:e=>{a(e.target.value),s(null)},onBlur:()=>{let r=Y(i??e);r!==``&&ve(r,{others:t,self:e})===null?r!==e&&(n(r),s(`เปลี่ยน slug แล้ว — ลิงก์เดิมของโรงนี้จะใช้ไม่ได้ (ต้องกดบันทึก)`)):r!==e&&s(`slug ไม่ถูกบันทึก (ว่าง/ซ้ำ/รูปแบบไม่ถูก) — คงค่าเดิมไว้`),a(null)}}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,k.jsxs)(`code`,{className:`text-[#777]`,children:[`/cinema/`,u||`…`]}),d&&f?(0,k.jsx)(`span`,{className:`text-[#D47272]`,children:d}):null,!d&&f?(0,k.jsx)(`span`,{className:`text-[#B3B3B3]`,children:`กด Tab/คลิกออกเพื่อยืนยัน slug ใหม่`}):null]}),o?(0,k.jsx)(`span`,{className:`text-[11px] text-[#D47272]`,children:o}):null]})}var be=a.th,xe=[`private_car`,`metro`,`bus`],Se=`flex min-h-9 items-center gap-1 rounded-lg border border-[#303030] px-2 text-xs text-[#999] transition hover:border-[#A92626] hover:text-[#D47272]`;function Ce({value:e,onChange:t,inputClass:n,labelClass:r}){function i(n,r){t(e.map((e,t)=>t===n?{...e,...r}:e))}return(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsx)(`span`,{className:`text-xs text-[#999]`,children:`การเดินทาง`}),e.length===0?(0,k.jsx)(`span`,{className:`text-[11px] text-[#777]`,children:`ยังไม่มีข้อมูล — หน้าเว็บจะซ่อนบล็อกการเดินทาง`}):null,e.map((a,o)=>(0,k.jsxs)(`div`,{className:`grid gap-2 rounded-lg border border-[#242424] p-2 sm:grid-cols-[130px_minmax(0,1fr)_minmax(0,1fr)_auto]`,children:[(0,k.jsxs)(`label`,{className:r,children:[`วิธีเดินทาง`,(0,k.jsx)(`select`,{className:n,value:a.icon_name,onChange:e=>i(o,{icon_name:e.target.value}),children:xe.map(e=>(0,k.jsx)(`option`,{value:e,children:be.transport[e]},e))})]}),(0,k.jsxs)(`label`,{className:r,children:[`รายละเอียด (TH)`,(0,k.jsx)(`input`,{className:n,value:a.value,placeholder:`MRT สถานีสามย่าน`,onChange:e=>i(o,{value:e.target.value})})]}),(0,k.jsxs)(`label`,{className:r,children:[`รายละเอียด (EN)`,(0,k.jsx)(`input`,{className:n,value:a.value_en??``,placeholder:`MRT Sam Yan station`,onChange:e=>i(o,{value_en:e.target.value})})]}),(0,k.jsx)(`div`,{className:`flex items-end`,children:(0,k.jsx)(`button`,{type:`button`,className:Se,"aria-label":`ลบวิธีเดินทางลำดับที่ ${o+1}`,onClick:()=>t(e.filter((e,t)=>t!==o)),children:(0,k.jsx)(S,{size:14})})})]},o)),(0,k.jsxs)(`button`,{type:`button`,className:`${Se} w-fit`,onClick:()=>t([...e,{icon_name:`bus`,value:``,value_en:``}]),children:[(0,k.jsx)(b,{size:14}),`เพิ่มวิธีเดินทาง`]})]})}function we(){return{th:Te(a.th.about),en:Te(a.en.about)}}function Te(e){return{title:e.title,lead:e.lead,sections:e.sections.map(e=>({heading:e.heading,body:e.body})),contactHeading:e.contactHeading,contactNote:e.contactNote}}function Ee(){return Oe(a.th.forCinemas,a.en.forCinemas)}function De(){return Oe(a.th.forFilmLovers,a.en.forFilmLovers)}function Oe(e,t){return{th:ke(e),en:ke(t)}}function ke(e){return{title:e.title,lead:e.lead,blocks:e.paragraphs.map(e=>({type:`paragraph`,text:e})),contactHeading:e.contactHeading,contactNote:e.contactNote}}function Ae({loaderData:e}){return d({origin:e?.origin??``,title:`หลังบ้าน — AlterFlixHub`,description:`หน้าจัดการเนื้อหาและข้อมูลโรงหนังสำหรับผู้ดูแลเว็บไซต์`,path:`/admin`,noIndex:!0})}var je=a.th,Me=[...m],Ne=m.map(e=>({value:e,label:je.categories[e]})),Pe=o.map(e=>({value:e,label:je.facilities[e].title})),X=`w-full rounded-lg border border-[#303030] bg-[#141414] px-3 py-2 text-sm text-white outline-none focus:border-[#A92626]`,Z=`flex flex-col gap-1 text-xs text-[#999]`,Q=`rounded-lg border border-[#303030] px-3 py-2 text-sm transition hover:border-[#A92626] hover:text-[#D47272]`,$=`rounded-lg bg-[#8F0808] px-4 py-2 text-sm font-medium transition hover:bg-[#a30a0a]`;function Fe(){return{slug:`cinema-${Date.now()}`,name:`โรงหนังใหม่`,tags:[],location_label:``,location_label_en:``,coordinates:null,description:``,description_en:``,map_url:null,address_lines:[],address_lines_en:[],transport:[],contacts:[],payments:[`เงินสด`],facilities:[],photos:[]}}var Ie=n(function(){let e=r(),[t,n]=(0,C.useState)(`cinemas`),[i,a]=(0,C.useState)(null),[s,l]=(0,C.useState)([]),[u,d]=(0,C.useState)(null),[p,m]=(0,C.useState)(null),[h,g]=(0,C.useState)(``),[_,v]=(0,C.useState)(``),[y,b]=(0,C.useState)(null),[x,S]=(0,C.useState)(7),[w,T]=(0,C.useState)(!1);(0,C.useEffect)(()=>{(async()=>{let t=await fetch(`/api/admin/content`);if(t.status===401){e(`/admin/login`);return}let n=await t.json();a(n),l(n.cinemas),m(n.cinemas[0]?.slug??null)})()},[e]);let E=(0,C.useMemo)(()=>i?.cinemas.find(e=>e.slug===p)??null,[i,p]);(0,C.useEffect)(()=>{g(E?JSON.stringify(E,null,2):``)},[E]),(0,C.useEffect)(()=>{t===`stats`&&(async()=>{let e=await fetch(`/api/admin/analytics?days=${x}`);e.ok&&b(await e.json())})()},[t,x]);function D(e){d(e),setTimeout(()=>d(null),2500)}async function O(e){T(!0);try{let t=await fetch(`/api/admin/content`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({}));return D(e.statusMessage??e.message??`บันทึกไม่สำเร็จ`),!1}let n=await t.json();return a(n),l(n.cinemas),D(`บันทึกแล้ว`),!0}finally{T(!1)}}function A(e){i&&a({...i,cinemas:i.cinemas.map(t=>t.slug===e.slug?e:t)})}function N(e){i&&a({...i,cinemas:e})}function P(e,t){a(n=>n&&{...n,cinemas:n.cinemas.map(n=>n.slug===e?t(n):n)})}function F(e){i&&a({...i,site:e})}function ee(e){i&&a({...i,about:e})}function te(e){i&&a({...i,forCinemas:e})}function ne(e){i&&a({...i,forFilmLovers:e})}let I=(0,C.useMemo)(()=>we(),[]),oe=(0,C.useMemo)(()=>Ee(),[]),L=(0,C.useMemo)(()=>De(),[]);if(!i)return(0,k.jsx)(`div`,{className:`flex min-h-dvh items-center justify-center bg-[#0D0D0D] text-sm text-[#999]`,children:`กำลังโหลดข้อมูลหลังบ้าน…`});let R=i.site.terms,z=i.site.locales;return(0,k.jsxs)(`div`,{className:`min-h-dvh bg-[#0D0D0D] text-white`,children:[(0,k.jsxs)(`header`,{className:`sticky top-0 z-10 flex flex-wrap items-center justify-between gap-3 border-b border-[#242424] bg-[#0D0D0D]/95 px-6 py-4`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h1`,{className:`text-xl font-semibold`,children:`หลังบ้าน AlterFlixHub`}),(0,k.jsxs)(`p`,{className:`text-xs text-[#999]`,children:[i.cinemas.length,` โรงหนัง · `,R.length,` คำศัพท์ ·`,` `,i.site.footer.length,` ไอคอน footer`,` · `,f.map(e=>`${i.cinemas.filter(t=>t.venue_type===e).length} ${e.replace(`โรงภาพยนตร์`,``)}${e===f[f.length-1]?``:` · `}`).join(``),` · `,i.cinemas.filter(e=>!e.venue_type).length,` `,`ยังไม่จัดประเภท`]})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[u?(0,k.jsx)(`span`,{className:`text-xs text-[#D47272]`,children:u}):null,(0,k.jsx)(`a`,{href:`/`,className:Q,target:`_blank`,rel:`noreferrer`,children:`ดูหน้าเว็บ`}),(0,k.jsx)(`button`,{type:`button`,className:Q,onClick:async()=>{await fetch(`/api/admin/logout`,{method:`POST`}),e(`/admin/login`)},children:`ออกจากระบบ`})]})]}),(0,k.jsx)(`nav`,{className:`flex gap-2 px-6 pt-4`,children:[[`cinemas`,`โรงหนัง`],[`about`,`หน้าเกี่ยวกับเรา`],[`forCinemas`,`สำหรับคนทำโรงหนัง`],[`forFilmLovers`,`สำหรับคนรักหนัง`],[`terms`,`คำศัพท์หลายภาษา`],[`footer`,`Footer / ไอคอน`],[`stats`,`สถิติการค้นหา`]].map(([e,r])=>(0,k.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:`rounded-lg px-4 py-2 text-sm transition ${t===e?`bg-[#242424] text-white`:`text-[#999] hover:text-white`}`,children:r},e))}),t===`cinemas`?(0,k.jsxs)(`div`,{className:`grid gap-6 px-6 py-5 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,k.jsxs)(`aside`,{className:`flex flex-col gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,className:$,onClick:()=>{let e=Fe();N([...i.cinemas,e]),m(e.slug)},children:`+ เพิ่มโรงหนัง`}),(0,k.jsx)(ue,{cinemas:i.cinemas,selected:p,dirty:!ce(i.cinemas,s),saving:w,onSelect:m,onReorder:N,onSaveOrder:()=>void O({cinemas:i.cinemas}),onBulkVenue:(e,t)=>{let n=new Set(e);N(i.cinemas.map(e=>n.has(e.slug)?{...e,venue_type:t}:e))}})]}),(0,k.jsx)(`section`,{className:`flex flex-col gap-4`,children:E?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(M,{title:`ข้อมูลหลัก`,description:`ชื่อ · slug · การแสดงบนหน้าเว็บ`,defaultOpen:!0,children:(0,k.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,k.jsxs)(`label`,{className:Z,children:[`ชื่อโรงหนัง (EN)`,(0,k.jsx)(`input`,{className:X,value:E.name,onChange:e=>{let t=e.target.value,n=_e(E.name),r=(E.slug===``||E.slug===n||/^cinema-\d+$/.test(E.slug))&&_e(t)||E.slug;P(E.slug,e=>({...e,name:t,slug:r})),r!==E.slug&&m(r)}})]}),(0,k.jsxs)(`label`,{className:Z,children:[`ชื่อโรงหนัง (TH)`,(0,k.jsx)(`input`,{className:X,value:E.name_th??``,onChange:e=>A({...E,name_th:e.target.value})})]}),(0,k.jsxs)(`label`,{className:Z,children:[`ประเภทโรงหนัง (ตัวกรองชั้นแรกบนหน้าแรก)`,(0,k.jsxs)(`select`,{className:X,value:E.venue_type??``,onChange:e=>A({...E,venue_type:e.target.value===``?null:e.target.value}),children:[(0,k.jsx)(`option`,{value:``,children:`— ยังไม่จัดประเภท —`}),f.map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))]})]}),(0,k.jsxs)(`label`,{className:Z,children:[`slug (ใช้ใน URL)`,(0,k.jsx)(ye,{className:X,value:E.slug,others:i.cinemas.map(e=>e.slug),onChange:e=>{P(E.slug,t=>({...t,slug:e})),m(e)}}),(0,k.jsx)(`span`,{className:`text-[11px] text-[#777]`,children:`ดึงจากชื่ออังกฤษอัตโนมัติ · แก้เองได้ตลอด (แก้แล้วจะไม่ถูกทับ)`}),(0,k.jsxs)(`label`,{className:`mt-1 flex items-center gap-2 text-xs text-[#B3B3B3]`,children:[(0,k.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-[#8F0808]`,checked:E.hidden===!0,onChange:e=>P(E.slug,t=>({...t,hidden:e.target.checked}))}),`ซ่อนโรงนี้จากหน้าเว็บ (ไม่ขึ้นในรายการ/ค้นหา — เข้า URL ตรงยังได้)`]})]})]})}),(0,k.jsx)(M,{title:`หมวดหมู่ & สิ่งอำนวยความสะดวก`,description:`ชิปที่เลือก = แสดงบนหน้าโรงหนัง`,badge:`${E.tags.length} หมวด · ${(E.facilities??[]).length} หัวข้อ`,children:(0,k.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col gap-2 sm:col-span-2`,children:[(0,k.jsx)(`span`,{className:`text-xs text-[#999]`,children:`หมวดหมู่`}),(0,k.jsx)(ie,{options:Ne,selected:E.tags,onToggle:e=>P(E.slug,t=>({...t,tags:ae(t.tags,e,Me)}))}),(0,k.jsx)(K,{className:X,value:E.tags,onChangeValue:e=>P(E.slug,t=>({...t,tags:e})),placeholder:`หรือพิมพ์เอง (คั่นด้วย ,)`})]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-2 sm:col-span-2`,children:[(0,k.jsx)(`span`,{className:`text-xs text-[#999]`,children:`สิ่งอำนวยความสะดวก`}),(0,k.jsx)(ie,{options:Pe,selected:E.facilities??[],onToggle:e=>P(E.slug,t=>({...t,facilities:ae(t.facilities??[],e,o)}))}),(0,k.jsx)(`span`,{className:`text-[11px] text-[#777]`,children:`ไม่เลือกเลย = หน้าเว็บแสดง “ไม่มีข้อมูล”`}),(0,k.jsx)(se,{facilities:E.facilities??[],details:E.facility_details??{},hasDescriptions:E.slug===`house-cinema-samyan`,onChange:e=>P(E.slug,t=>({...t,facility_details:e})),inputClass:X,labelClass:Z})]})]})}),(0,k.jsx)(M,{title:`การเดินทาง & การติดต่อ`,description:`รวมรูปภาพและช่องทางชำระเงิน`,badge:`${E.transport.length} เส้นทาง · ${E.photos.length} รูป`,children:(0,k.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,k.jsx)(`div`,{className:`sm:col-span-2`,children:(0,k.jsx)(Ce,{value:E.transport,onChange:e=>P(E.slug,t=>({...t,transport:e})),inputClass:X,labelClass:Z})}),(0,k.jsxs)(`label`,{className:`sm:col-span-2 flex flex-col gap-1 text-xs text-[#999]`,children:[`หัวข้อ “สอบถามข้อมูลและจองตั๋ว” (เฉพาะโรงนี้)`,(0,k.jsx)(`input`,{className:X,value:E.contact_heading??``,placeholder:`สอบถามข้อมูลและจองตั๋ว`,onChange:e=>P(E.slug,t=>({...t,contact_heading:e.target.value}))}),(0,k.jsx)(`span`,{className:`text-[11px] text-[#777]`,children:`เว้นว่าง = ใช้ค่ากลาง (แก้ได้ที่แท็บ “คำศัพท์หลายภาษา” → detail.contactTitle)`})]}),(0,k.jsx)(`div`,{className:`sm:col-span-2`,children:(0,k.jsx)(pe,{contacts:E.contacts,onChange:e=>P(E.slug,t=>({...t,contacts:e})),inputClass:X,labelClass:Z})}),(0,k.jsx)(`div`,{className:`sm:col-span-2`,children:(0,k.jsx)(he,{photos:E.photos,cinemaSlug:E.slug,onChange:e=>P(E.slug,t=>({...t,photos:e})),inputClass:X,labelClass:Z})}),(0,k.jsxs)(`label`,{className:Z,children:[`ชำระเงิน (คั่นด้วย ,)`,(0,k.jsx)(K,{className:X,value:E.payments,onChangeValue:e=>P(E.slug,t=>({...t,payments:e})),placeholder:`เงินสด, โอน, บัตรเครดิต`})]})]})}),(0,k.jsx)(M,{title:`ที่ตั้ง & แผนที่`,description:`ที่อยู่ พิกัด และลิงก์ Google Maps`,badge:E.coordinates?`มีพิกัด`:`ยังไม่มีพิกัด`,children:(0,k.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,k.jsxs)(`label`,{className:Z,children:[`ที่ตั้ง (TH)`,(0,k.jsx)(`input`,{className:X,value:E.location_label,onChange:e=>A({...E,location_label:e.target.value})})]}),(0,k.jsxs)(`label`,{className:Z,children:[`ที่ตั้ง (EN)`,(0,k.jsx)(`input`,{className:X,value:E.location_label_en??``,onChange:e=>A({...E,location_label_en:e.target.value})})]}),(0,k.jsxs)(`label`,{className:Z,children:[`ละติจูด (คำนวณระยะทาง)`,(0,k.jsx)(`input`,{className:X,value:E.coordinates?.latitude??``,onChange:e=>{let t=e.target.value.trim();if(t===``){A({...E,coordinates:null});return}let n=Number(t);A({...E,coordinates:Number.isFinite(n)?{latitude:n,longitude:E.coordinates?.longitude??0}:null})}})]}),(0,k.jsxs)(`label`,{className:Z,children:[`ลองจิจูด`,(0,k.jsx)(`input`,{className:X,value:E.coordinates?.longitude??``,onChange:e=>{let t=e.target.value.trim();if(t===``){A({...E,coordinates:null});return}let n=Number(t);A({...E,coordinates:Number.isFinite(n)?{latitude:E.coordinates?.latitude??0,longitude:n}:null})}})]}),(0,k.jsxs)(`label`,{className:Z,children:[`Google map URL`,(0,k.jsx)(`input`,{className:X,value:E.map_url??``,onChange:e=>A({...E,map_url:e.target.value||null})})]}),(0,k.jsxs)(`label`,{className:Z,children:[`ที่อยู่ (บรรทัดละรายการ)`,(0,k.jsx)(`textarea`,{className:`${X} h-20`,value:E.address_lines.join(`
`),onChange:e=>A({...E,address_lines:e.target.value.split(`
`)})})]})]})}),(0,k.jsx)(M,{title:`คำอธิบายโรงหนัง`,description:`ข้อความที่แสดงใต้ชื่อโรง`,badge:E.description?`มีคำอธิบาย`:`ยังไม่มี`,children:(0,k.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,k.jsxs)(`label`,{className:Z,children:[`คำอธิบาย (TH)`,(0,k.jsx)(`textarea`,{className:`${X} h-20`,value:E.description,onChange:e=>A({...E,description:e.target.value})})]}),(0,k.jsxs)(`label`,{className:Z,children:[`คำอธิบาย (EN)`,(0,k.jsx)(`textarea`,{className:`${X} h-20`,value:E.description_en??``,onChange:e=>A({...E,description_en:e.target.value})})]})]})}),(0,k.jsxs)(`div`,{className:`sticky bottom-0 z-10 -mx-1 flex flex-wrap gap-2 rounded-xl border-t border-[#242424] bg-[#0D0D0D]/95 px-1 py-3 backdrop-blur`,children:[(0,k.jsx)(`button`,{type:`button`,className:$,onClick:()=>void O({cinemas:i.cinemas}),children:`บันทึกทั้งหมด`}),(0,k.jsx)(`button`,{type:`button`,className:Q,onClick:()=>{let e={...E,slug:`${E.slug}-copy-${Date.now().toString().slice(-4)}`,name:`${E.name} (สำเนา)`};N([...i.cinemas,e]),m(e.slug),D(`สร้างสำเนาแล้ว — กดบันทึกเพื่อยืนยัน`)},children:`ทำสำเนา`}),(0,k.jsx)(`button`,{type:`button`,className:Q,onClick:()=>{navigator.clipboard.writeText(h),D(`คัดลอก JSON แล้ว`)},children:`คัดลอก JSON`}),(0,k.jsx)(`button`,{type:`button`,className:`${Q} text-[#D47272]`,onClick:()=>{let e=i.cinemas.filter(e=>e.slug!==E.slug);N(e),m(e[0]?.slug??null)},children:`ลบโรงหนังนี้`})]}),(0,k.jsxs)(`details`,{className:`rounded-xl border border-[#242424] p-3`,children:[(0,k.jsx)(`summary`,{className:`cursor-pointer text-sm text-[#B3B3B3]`,children:`แก้ไขดิบเป็น JSON (คัดลอก/วางได้)`}),(0,k.jsx)(`textarea`,{className:`${X} mt-3 h-72 font-mono text-xs`,value:h,onChange:e=>g(e.target.value),spellCheck:!1}),(0,k.jsx)(`button`,{type:`button`,className:`${Q} mt-2`,onClick:()=>{try{A(JSON.parse(h)),D(`ใช้ JSON แล้ว — กดบันทึกเพื่อยืนยัน`)}catch{D(`JSON ไม่ถูกต้อง`)}},children:`ใช้ JSON นี้`})]}),(0,k.jsxs)(`details`,{className:`rounded-xl border border-[#242424] p-3`,children:[(0,k.jsx)(`summary`,{className:`cursor-pointer text-sm text-[#B3B3B3]`,children:`วาง JSON เพื่อเพิ่มโรงหนัง (ทับ slug ที่ซ้ำ)`}),(0,k.jsx)(`textarea`,{className:`${X} mt-3 h-40 font-mono text-xs`,value:_,onChange:e=>v(e.target.value),placeholder:`{"slug":"new-cinema","name":"NEW CINEMA","tags":[]}`,spellCheck:!1}),(0,k.jsx)(`button`,{type:`button`,className:`${Q} mt-2`,onClick:async()=>{let e=await fetch(`/api/admin/cinemas/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({raw:_})});if(!e.ok){D((await e.json().catch(()=>({}))).statusMessage??`นำเข้าไม่สำเร็จ`);return}let t=await e.json();a(t.store),v(``),D(`นำเข้า ${t.imported} รายการแล้ว`)},children:`นำเข้า / วางทับ`})]})]}):(0,k.jsx)(`p`,{className:`text-sm text-[#999]`,children:`เลือกโรงหนังหรือเพิ่มใหม่ก่อน`})})]}):null,t===`about`?(0,k.jsx)(j,{value:i.about,defaults:I,onChange:ee,onSave:()=>void O({about:i.about}),saving:w}):null,t===`forCinemas`?(0,k.jsx)(re,{value:i.forCinemas,defaults:oe,onChange:te,onSave:()=>void O({forCinemas:i.forCinemas}),saving:w,saveLabel:`บันทึกหน้าสำหรับคนทำโรงหนัง`}):null,t===`forFilmLovers`?(0,k.jsx)(re,{value:i.forFilmLovers,defaults:L,onChange:ne,onSave:()=>void O({forFilmLovers:i.forFilmLovers}),saving:w,saveLabel:`บันทึกหน้าสำหรับคนรักหนัง`}):null,t===`terms`?(0,k.jsxs)(`div`,{className:`px-6 py-5`,children:[(0,k.jsxs)(`p`,{className:`mb-3 text-sm text-[#999]`,children:[`แก้คำศัพท์ตามภาษา — key เป็นตำแหน่งข้อความในหน้าเว็บ (เช่น`,` `,(0,k.jsx)(`code`,{children:`hero.subtitle`}),`) เว้นว่างไว้แปลว่าใช้ค่าเดิม`]}),(0,k.jsxs)(`div`,{className:`mb-3 flex flex-wrap gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,className:$,onClick:()=>void O({site:i.site}),children:`บันทึกคำศัพท์`}),(0,k.jsx)(`button`,{type:`button`,className:Q,onClick:()=>F({...i.site,terms:[...i.site.terms,{key:`custom.term${i.site.terms.length+1}`,values:Object.fromEntries(z.map(e=>[e.code,``]))}]}),children:`+ เพิ่มคำศัพท์`}),f.map(e=>{let t=`venues.${e}`,n=i.site.terms.some(e=>e.key===t);return(0,k.jsxs)(`button`,{type:`button`,disabled:n,className:`${Q} disabled:opacity-40`,onClick:()=>F({...i.site,terms:[...i.site.terms,{key:t,values:Object.fromEntries(z.map(t=>[t.code,t.code===`th`?e:``]))}]}),children:[n?`มีแล้ว`:`+ คำแปลตัวกรอง`,`: `,e]},t)})]}),(0,k.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-[#242424]`,children:(0,k.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,k.jsx)(`thead`,{className:`bg-[#141414] text-xs text-[#999]`,children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{className:`px-3 py-2`,children:`key`}),z.map(e=>(0,k.jsxs)(`th`,{className:`px-3 py-2`,children:[e.label,` (`,e.code,`)`]},e.code)),(0,k.jsx)(`th`,{className:`px-3 py-2`})]})}),(0,k.jsx)(`tbody`,{children:R.map((e,t)=>(0,k.jsxs)(`tr`,{className:`border-t border-[#242424]`,children:[(0,k.jsx)(`td`,{className:`px-3 py-2 font-mono text-xs text-[#D47272]`,children:e.key}),z.map(n=>(0,k.jsx)(`td`,{className:`px-3 py-2`,children:(0,k.jsx)(`input`,{className:X,value:e.values[n.code]??``,onChange:e=>{let r=R.map((r,i)=>i===t?{...r,values:{...r.values,[n.code]:e.target.value}}:r);F({...i.site,terms:r})}})},n.code)),(0,k.jsx)(`td`,{className:`px-3 py-2`,children:(0,k.jsx)(`button`,{type:`button`,className:`text-xs text-[#D47272]`,onClick:()=>F({...i.site,terms:R.filter((e,n)=>n!==t)}),children:`ลบ`})})]},`${e.key}-${t}`))})]})})]}):null,t===`stats`?(0,k.jsxs)(`div`,{className:`px-6 py-5`,children:[(0,k.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(`span`,{className:`text-sm text-[#999]`,children:`ช่วงเวลา`}),[1,7,30,90].map(e=>(0,k.jsxs)(`button`,{type:`button`,onClick:()=>S(e),className:`rounded-lg px-3 py-1.5 text-sm transition ${x===e?`bg-[#242424] text-[#D47272]`:`text-[#999] hover:text-white`}`,children:[e,` วัน`]},e))]}),y?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[[`ค้นหาทั้งหมด`,y.total_searches],[`ผู้เข้าชม (ไม่ระบุตัวตน)`,y.unique_visitors],[`ค้นแล้วไม่พบผล`,y.zero_result_searches],[`กดใช้ ใกล้ฉัน`,y.near_me_uses],[`ผลลัพธ์เฉลี่ย/ครั้ง`,y.average_results],[`คลิกการ์ด / การค้นหา`,`${y.click_through_rate}%`]].map(([e,t])=>(0,k.jsxs)(`div`,{className:`rounded-xl border border-[#242424] p-4`,children:[(0,k.jsx)(`div`,{className:`text-xs text-[#999]`,children:e}),(0,k.jsx)(`div`,{className:`mt-1 text-2xl font-semibold`,children:t})]},String(e)))}),(0,k.jsxs)(`div`,{className:`mt-6 grid gap-6 lg:grid-cols-2`,children:[(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h2`,{className:`mb-2 text-sm font-semibold`,children:`คำค้นยอดนิยม`}),(0,k.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,k.jsx)(`thead`,{className:`text-xs text-[#999]`,children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{className:`py-1`,children:`คำค้น`}),(0,k.jsx)(`th`,{className:`py-1`,children:`ครั้ง`}),(0,k.jsx)(`th`,{className:`py-1`,children:`ไม่พบผล`}),(0,k.jsx)(`th`,{className:`py-1`,children:`คลิก`})]})}),(0,k.jsx)(`tbody`,{children:y.top_queries.length===0?(0,k.jsx)(`tr`,{children:(0,k.jsx)(`td`,{className:`py-2 text-[#999]`,colSpan:4,children:`ยังไม่มีข้อมูลการค้นหา`})}):y.top_queries.map(e=>(0,k.jsxs)(`tr`,{className:`border-t border-[#242424]`,children:[(0,k.jsx)(`td`,{className:`py-1.5 pr-2`,children:e.query}),(0,k.jsx)(`td`,{className:`py-1.5`,children:e.count}),(0,k.jsx)(`td`,{className:`py-1.5 text-[#D47272]`,children:e.zero_result_count}),(0,k.jsx)(`td`,{className:`py-1.5`,children:e.click_count})]},e.query))})]})]}),(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h2`,{className:`mb-2 text-sm font-semibold`,children:`คำค้นที่ค้นแล้วไม่พบผล`}),(0,k.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:y.zero_result_queries.length===0?(0,k.jsx)(`li`,{className:`text-[#999]`,children:`ไม่มี — ทุกคำค้นมีผลลัพธ์`}):y.zero_result_queries.map(e=>(0,k.jsxs)(`li`,{className:`flex justify-between border-t border-[#242424] py-1.5`,children:[(0,k.jsx)(`span`,{children:e.query}),(0,k.jsxs)(`span`,{className:`text-[#D47272]`,children:[e.zero_result_count,` ครั้ง`]})]},e.query))}),(0,k.jsx)(`h2`,{className:`mb-2 mt-6 text-sm font-semibold`,children:`หมวดที่ถูกใช้`}),(0,k.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:y.top_categories.length===0?(0,k.jsx)(`li`,{className:`text-[#999]`,children:`ยังไม่มีข้อมูล`}):y.top_categories.map(e=>(0,k.jsxs)(`li`,{className:`flex justify-between border-t border-[#242424] py-1.5`,children:[(0,k.jsx)(`span`,{children:e.category}),(0,k.jsx)(`span`,{children:e.count})]},e.category))})]}),(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h2`,{className:`mb-2 text-sm font-semibold`,children:`โรงหนังที่ถูกเปิด/คลิก`}),(0,k.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,k.jsx)(`thead`,{className:`text-xs text-[#999]`,children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{className:`py-1`,children:`slug`}),(0,k.jsx)(`th`,{className:`py-1`,children:`เปิดดู`}),(0,k.jsx)(`th`,{className:`py-1`,children:`คลิกการ์ด`})]})}),(0,k.jsx)(`tbody`,{children:y.top_cinemas.length===0?(0,k.jsx)(`tr`,{children:(0,k.jsx)(`td`,{className:`py-2 text-[#999]`,colSpan:3,children:`ยังไม่มีข้อมูล`})}):y.top_cinemas.map(e=>(0,k.jsxs)(`tr`,{className:`border-t border-[#242424]`,children:[(0,k.jsx)(`td`,{className:`py-1.5 pr-2`,children:e.slug}),(0,k.jsx)(`td`,{className:`py-1.5`,children:e.views}),(0,k.jsx)(`td`,{className:`py-1.5`,children:e.selects})]},e.slug))})]})]}),(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h2`,{className:`mb-2 text-sm font-semibold`,children:`การค้นหารายวัน`}),y.daily_searches.length===0?(0,k.jsx)(`p`,{className:`text-sm text-[#999]`,children:`ยังไม่มีข้อมูล`}):(()=>{let e=Math.max(...y.daily_searches.map(e=>e.count),1);return(0,k.jsx)(`ul`,{className:`flex flex-col gap-2`,children:y.daily_searches.map(t=>(0,k.jsxs)(`li`,{className:`flex items-center gap-3 text-xs`,children:[(0,k.jsx)(`span`,{className:`w-20 shrink-0 text-[#999]`,children:t.date}),(0,k.jsx)(`span`,{className:`h-4 rounded-sm bg-[#8F0808]`,style:{width:`${Math.max(t.count/e*100,4)}%`}}),(0,k.jsx)(`span`,{children:t.count})]},t.date))})})()]}),(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h2`,{className:`mb-2 text-sm font-semibold`,children:`คำค้นล่าสุด`}),y.recent_searches.length===0?(0,k.jsx)(`p`,{className:`text-sm text-[#999]`,children:`ยังไม่มีข้อมูล`}):(0,k.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:y.recent_searches.map((e,t)=>(0,k.jsxs)(`li`,{className:`flex items-center justify-between gap-2 border-t border-[#242424] py-1.5`,children:[(0,k.jsx)(`span`,{className:`truncate`,children:e.query}),(0,k.jsxs)(`span`,{className:`shrink-0 text-xs text-[#999]`,children:[e.at.slice(11,16),` · `,e.result_count,` ผล`]})]},`${e.at}-${t}`))}),(0,k.jsx)(`button`,{type:`button`,className:`${Q} mt-4`,onClick:()=>{let e=y.top_queries.map(e=>`"${e.query.replace(/"/g,`""`)}",${e.count},${e.zero_result_count},${e.click_count}`).join(`
`),t=new Blob([`query,count,zero_result_count,click_count
`+e],{type:`text/csv;charset=utf-8`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`search-stats-${y.range_days}d.csv`,r.click(),URL.revokeObjectURL(n)},children:`ดาวน์โหลด CSV (คำค้นยอดนิยม)`})]})]}),(0,k.jsx)(`p`,{className:`mt-6 text-xs text-[#777]`,children:`เก็บแบบไม่ใช้คุกกี้: ไม่เก็บ IP/User-Agent ดิบ ระบุผู้เข้าชมด้วย hash ที่หมุนเกลือทุกวัน (แนวเดียวกับ Umami)`})]}):(0,k.jsx)(`p`,{className:`text-sm text-[#999]`,children:`กำลังโหลดสถิติ…`})]}):null,t===`footer`?(0,k.jsxs)(`div`,{className:`px-6 py-5`,children:[(0,k.jsx)(`p`,{className:`mb-3 text-sm text-[#999]`,children:`เลือกไอคอนและใส่ลิงก์ของแต่ละอัน — ลำดับตามรายการนี้`}),(0,k.jsxs)(`div`,{className:`mb-3 flex flex-wrap gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,className:$,onClick:()=>void O({site:i.site}),children:`บันทึก Footer`}),(0,k.jsx)(`button`,{type:`button`,className:Q,onClick:()=>F({...i.site,footer:[...i.site.footer,{id:`footer-${Date.now()}`,icon_name:`IconLink`,label:`ลิงก์ใหม่`,href:`https://`}]}),children:`+ เพิ่มไอคอน`})]}),(0,k.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.site.footer.map((e,t)=>(0,k.jsxs)(`div`,{className:`grid gap-2 rounded-xl border border-[#242424] p-3 sm:grid-cols-[180px_1fr_1fr_auto]`,children:[(0,k.jsx)(`select`,{className:X,value:e.icon_name,onChange:e=>{let n=i.site.footer.map((n,r)=>r===t?{...n,icon_name:e.target.value}:n);F({...i.site,footer:n})},children:c.map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))}),(0,k.jsx)(`input`,{className:X,placeholder:`ชื่อที่แสดง`,value:e.label,onChange:e=>{let n=i.site.footer.map((n,r)=>r===t?{...n,label:e.target.value}:n);F({...i.site,footer:n})}}),(0,k.jsx)(`input`,{className:X,placeholder:`https://…`,value:e.href,onChange:e=>{let n=i.site.footer.map((n,r)=>r===t?{...n,href:e.target.value}:n);F({...i.site,footer:n})}}),(0,k.jsx)(`button`,{type:`button`,className:`text-xs text-[#D47272]`,onClick:()=>F({...i.site,footer:i.site.footer.filter((e,n)=>n!==t)}),children:`ลบ`})]},e.id))})]}):null]})});export{Ie as default,Ae as meta};