1var ge=Object.defineProperty,he=Object.defineProperties;var ue=Object.getOwnPropertyDescriptors;var Z=Object.getOwnPropertySymbols;var pe=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var ee=(i,d,l)=>d in i?ge(i,d,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[d]=l,x=(i,d)=>{for(var l in d||(d={}))pe.call(d,l)&&ee(i,l,d[l]);if(Z)for(var l of Z(d))fe.call(d,l)&&ee(i,l,d[l]);return i},g=(i,d)=>he(i,ue(d));var w=(i,d,l)=>new Promise((y,k)=>{var T=p=>{try{A(l.next(p))}catch(u){k(u)}},E=p=>{try{A(l.throw(p))}catch(u){k(u)}},A=p=>p.done?y(p.value):Promise.resolve(p.value).then(T,E);A((l=l.apply(i,d)).next())});import{Q as je,u as be,j as e,C as z,n as H,o as M,q as $,ah as C,v as o,br as R,X as B,bd as te}from"./index-B6cfMRgy.js";import{r as h}from"./vendor-DliuPpH9.js";import{L as v}from"./label-CfNCq9ha.js";import{U as ve}from"./upload-COeFv-bA.js";import{P as ye}from"./plus-Bl-fUG-l.js";import{S as Ne}from"./square-pen-C8F00g_M.js";import{E as we}from"./eye-oTUC4pEi.js";import{T as Ce}from"./trash-2-DfQt0PUK.js";const Pe=()=>{var X;const{user:i,loading:d}=je();be();const[l,y]=h.useState({title:"",subtitle:"",content:"",tags:[],readTime:0}),[k,T]=h.useState(""),[E,A]=h.useState(!1),[p,u]=h.useState(null),[F,D]=h.useState([]),[L,O]=h.useState(!1),[_,q]=h.useState(null),[S,K]=h.useState(null),[c,f]=h.useState({title:"",subtitle:"",content:"",tags:[],readTime:0,likes:0,views:0}),[se,Y]=h.useState(!1),[J,V]=h.useState(!1);h.useEffect(()=>{let t=!1;function s(){return w(this,null,function*(){if((i==null?void 0:i.email)==="[email protected]"){u(!0);return}if(!(i!=null&&i.email)){u(!1);return}try{const n=yield(yield fetch("/api/admin/me/permissions",{headers:{"x-user-email":i.email}})).json();if(t)return;!(n!=null&&n.success)||n.isAdmin===!1?u(!1):n.isSuperAdmin?u(!0):Array.isArray(n.pages)?u(n.pages.includes("/admin-upload-articles")):u(!1)}catch(a){t||u(!1)}})}return s(),()=>{t=!0}},[i==null?void 0:i.email]);const W=(t,s)=>{y(a=>g(x({},a),{[t]:s}))},G=()=>{k.trim()&&!l.tags.includes(k.trim())&&(y(t=>g(x({},t),{tags:[...t.tags,k.trim()]})),T(""))},ae=t=>{y(s=>g(x({},s),{tags:s.tags.filter(a=>a!==t)}))},ie=t=>w(void 0,null,function*(){const s=new FormData;s.append("image",t);const a=yield fetch("/api/upload-article-image",{method:"POST",body:s});if(!a.ok)throw new Error("Failed to upload image");return(yield a.json()).imageUrl}),Q=(t,s=!1)=>w(void 0,null,function*(){var n;const a=(n=t.target.files)==null?void 0:n[0];if(a)try{const r=yield ie(a);s?f(m=>g(x({},m),{imageUrl:r})):y(m=>g(x({},m),{imageUrl:r}))}catch(r){console.error("Error uploading image:",r),alert("Failed to upload image. Please try again.")}}),P=()=>w(void 0,null,function*(){try{O(!0);const s=yield(yield fetch("/api/articles")).json();s.success&&D(s.articles||[])}catch(t){console.error("Error fetching articles:",t)}finally{O(!1)}}),le=t=>w(void 0,null,function*(){if(confirm("Are you sure you want to delete this article? This action cannot be undone."))try{q(t),(yield fetch(`/api/articles/${t}`,{method:"DELETE",headers:{"admin-email":i.email||""}})).ok?(D(a=>a.filter(n=>n.id!==t)),alert("Article deleted successfully!")):alert("Failed to delete article. Please try again.")}catch(s){console.error("Error deleting article:",s),alert("Error deleting article. Please try again.")}finally{q(null)}}),re=t=>{K(t),f({title:t.title,subtitle:t.subtitle||"",content:t.content,tags:t.tags||[],readTime:t.readTime,likes:t.likes||0,views:t.views||0,imageUrl:t.imageUrl||"",imageFile:void 0}),Y(!0)},I=()=>{Y(!1),K(null),f({title:"",subtitle:"",content:"",tags:[],readTime:0,likes:0,views:0,imageUrl:"",imageFile:void 0})},ne=()=>w(void 0,null,function*(){if(S)try{V(!0);const t=new FormData;t.append("title",c.title||""),t.append("subtitle",c.subtitle||""),t.append("content",c.content||""),t.append("tags",JSON.stringify(c.tags||[])),t.append("readTime",(c.readTime||0).toString()),t.append("likes",(c.likes||0).toString()),t.append("views",(c.views||0).toString()),!c.imageFile&&c.imageUrl&&t.append("imageUrl",c.imageUrl),c.imageFile&&t.append("image",c.imageFile);const s=yield fetch(`/api/articles/${S.id}`,{method:"PUT",headers:{"admin-email":(i==null?void 0:i.email)||""},body:t});if(s.ok){const a=yield s.json();console.log("â
Article update response:",a),D(n=>n.map(r=>r.id===S.id?a.article:r)),P(),alert("Article updated successfully!"),I()}else{const a=yield s.json();console.error("â Article update failed:",a),alert(`Failed to update article: ${a.error||"Unknown error"}`)}}catch(t){console.error("Error updating article:",t),alert("Error updating article")}finally{V(!1)}});if(h.useEffect(()=>{P()},[]),d||p===null)return e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 border-4 border-purple-600 border-t-transparent roun
1ded-full animate-spin mx-auto mb-6"}),e.jsx("p",{className:"text-gray-600",children:"Loading..."})]})});if(!i)return e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Login Required"}),e.jsx("p",{className:"text-gray-600 mb-4",children:"You need to log in to access this admin page."}),e.jsx("a",{href:"/auth",className:"inline-flex items-center px-4 py-2 rounded-md bg-purple-600 text-white text-sm font-medium hover:bg-purple-700 transition-colors",children:"Go to Login"})]})});if(!p)return e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-red-600 text-lg font-semibold mb-2",children:"Access Denied"}),e.jsx("p",{className:"text-gray-600",children:"You don't have permission to access this page."})]})});const ce=t=>w(void 0,null,function*(){var s,a,n;t.preventDefault(),A(!0);try{const r=x({},l);if(!(i!=null&&i.email))throw new Error("User email not available. Please log in again.");console.log("User email:",i.email),console.log("Article data being sent:",r);const m=Date.now(),j=yield fetch(`/api/articles?v=${m}`,{method:"POST",headers:{"Content-Type":"application/json","admin-email":i.email,Authorization:`Bearer ${i.email}`,"Cache-Control":"no-cache",Pragma:"no-cache"},body:JSON.stringify(r)});console.log("Response status:",j.status),console.log("Response headers:",j.headers);const b=yield j.json();console.log("Response data:",b),b.success?(y({title:"",subtitle:"",content:"",tags:[],readTime:0}),alert("Article uploaded successfully!")):alert(`Error: ${b.error||"Failed to upload article"}`)}catch(r){console.error("Error uploading article:",r),(s=r.message)!=null&&s.includes("User email not available")?alert("Authentication error: Please log in again as admin."):(a=r.message)!=null&&a.includes("401")?alert("Access denied: You are not authorized to upload articles."):(n=r.message)!=null&&n.includes("403")?alert("Forbidden: Admin access required."):alert(`Error uploading article: ${r.message||"Please try again."}`)}finally{A(!1)}}),oe=t=>{const a=t.trim().split(/\s+/).length;return Math.ceil(a/200)},U=t=>{y(s=>g(x({},s),{content:t,readTime:oe(t.replace(/<[^>]*>/g,""))}))},N=t=>{const s=document.getElementById("rich-editor");if(!s)return;const a=window.getSelection();if(!a||a.rangeCount===0)return;const n=a.getRangeAt(0),r=a.toString();if(!r){alert("Please select some text first to apply formatting.");return}let m="";switch(t){case"bold":m=`<strong>${r}</strong>`;break;case"italic":m=`<em>${r}</em>`;break;case"underline":m=`<u>${r}</u>`;break;case"h1":m=`<h1 style="font-size: 2rem; font-weight: bold; margin: 1rem 0;">${r}</h1>`;break;case"h2":m=`<h2 style="font-size: 1.5rem; font-weight: 600; margin: 0.75rem 0;">${r}</h2>`;break;default:return}n.deleteContents();const j=document.createElement("div");j.innerHTML=m;const b=document.createDocumentFragment();for(;j.firstChild;)b.appendChild(j.firstChild);n.insertNode(b),U(s.innerHTML),s.focus()},de=()=>{const t=prompt("Enter URL:");if(!t)return;const s=window.getSelection();if(!s||s.rangeCount===0)return;const a=s.getRangeAt(0),n=s.toString()||t,r=`<a href="${t}" target="_blank" rel="noopener noreferrer" style="color: #2563eb; text-decoration: underline;">${n}</a>`;a.deleteContents();const m=document.createElement("div");m.innerHTML=r;const j=document.createDocumentFragment();for(;m.firstChild;)j.appendChild(m.firstChild);a.insertNode(j);const b=document.getElementById("rich-editor");
1b&&(U(b.innerHTML),b.focus())},me=()=>{const t=document.getElementById("rich-editor");if(!t)return;const s=window.getSelection();if(!s||s.rangeCount===0)return;const a=s.getRangeAt(0),n=s.toString();if(!n){alert("Please select some text first to clear formatting.");return}const r=n.replace(/<[^>]*>/g,"");a.deleteContents(),a.insertNode(document.createTextNode(r)),U(t.innerHTML),t.focus()},xe=t=>{if(t.ctrlKey||t.metaKey)switch(t.key.toLowerCase()){case"b":t.preventDefault(),N("bold");break;case"i":t.preventDefault(),N("italic");break;case"u":t.preventDefault(),N("underline");break}};return e.jsxs("div",{className:"min-h-screen bg-gray-50 py-4 sm:py-8",children:[e.jsxs("div",{className:"max-w-4xl mx-auto px-3 sm:px-4",children:[e.jsxs("div",{className:"mb-6 sm:mb-8",children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-gray-900 mb-2",children:"Upload Articles"}),e.jsx("p",{className:"text-sm sm:text-base text-gray-600",children:"Share your poetry knowledge and insights with the community"})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-4 lg:gap-8",children:[e.jsx("div",{className:"xl:col-span-2",children:e.jsxs(z,{children:[e.jsx(H,{children:e.jsxs(M,{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-5 h-5"}),"Article Details"]})}),e.jsx($,{children:e.jsxs("form",{onSubmit:ce,className:"space-y-4 sm:space-y-6",children:[e.jsxs("div",{children:[e.jsxs(v,{htmlFor:"title",children:["Article Title ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(C,{id:"title",value:l.title,onChange:t=>W("title",t.target.value),placeholder:"Enter article title...",required:!0,className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(v,{htmlFor:"subtitle",children:"Subtitle (Optional)"}),e.jsx(C,{id:"subtitle",value:l.subtitle,onChange:t=>W("subtitle",t.target.value),placeholder:"Enter subtitle...",className:"mt-2"})]}),e.jsxs("div",{children:[e.jsxs(v,{htmlFor:"content",children:["Article Content ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"mt-2 mb-3 border border-gray-200 rounded-lg p-2 bg-white",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1 sm:gap-2",children:[e.jsx(o,{type:"button",variant:"outline",size:"sm",onClick:()=>N("bold"),className:"h-8 px-2 sm:px-3 text-xs sm:text-sm font-semibold",title:"Bold (Ctrl+B)",children:e.jsx("strong",{children:"B"})}),e.jsx(o,{type:"button",variant:"outline",size:"sm",onClick:()=>N("italic"),className:"h-8 px-2 sm:px-3 text-xs sm:text-sm italic",title:"Italic (Ctrl+I)",children:e.jsx("em",{children:"I"})}),e.jsx(o,{type:"button",variant:"outline",size:"sm",onClick:()=>N("underline"),className:"h-8 px-2 sm:px-3 text-xs sm:text-sm underline",title:"Underline (Ctrl+U)",children:e.jsx("u",{children:"U"})}),e.jsx("div",{className:"w-px h-6 bg-gray-300 hidden sm:block"}),e.jsx(o,{type:"button",variant:"outline",size:"sm",onClick:()=>N("h1"),className:"h-8 px-2 sm:px-3 text-xs sm:text-sm font-bold",title:"Heading 1",children:"H1"}),e.jsx(o,{type:"button",variant:"outline",size:"sm",onClick:()=>N("h2"),className:"h-8 px-2 sm:px-3 text-xs sm:text-sm font-semibold",title:"Heading 2",children:"H2"}),e.jsx("div",{className:"w-px h-6 bg-gray-300 hidden sm:block"}),e.jsx(o,{type:"button",variant:"outline",size:"sm",onClick:de,className:"h-8 px-2 sm:px-3 text-xs sm:text-sm text-blue-600",title:"Insert Link",children:"ð"}),e.jsx("div",{className:"w-px h-6 bg-gray-300 hidden sm:block"}),e.jsx(o,{type:"button",variant:"outline",size:"sm",onClick:me,className:"h-8 px-2 sm:px-3 text-xs sm:text-sm text-red-600",title:"Clear Formatting",children:"ð§¹"})]})}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{id:"rich-editor",contentEditable:!0,dangerouslySetInnerHTML:{__html:l.content},onInput:t=>U(t.currentTarget.innerHTML),onKeyDown:xe,className:"min-h-[250px] sm:min-h-[300px] p-3 sm:p-4 border border-gray-200 rounded-lg bg-white focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-none overflow-y-auto",style:{fontFamily:"Inter, system-ui, sans-serif",lineHeight:"1.6",fontSize:"16px"}}),!l.content&&e.jsx("div",{className:"absolute top-3 sm:top-4 left-3 sm:left-4 text-gray-400 pointer-events-none text-sm sm:text-base",children:"Write your article content here... Use the toolbar above for formatting!"})]}),e.jsxs("div",{className:"mt-2 text-xs sm:text-sm text-gray-500",children:["Estimated read time: ",l.readTime," minutes"]}),e.jsxs("div",{className:"mt-2 text-xs text-gray-500 bg-gray-50 p-2 rounded",children:["ð¡ ",e.jsx("strong",{children:"Formatting Tips:"})," Select text and use toolbar buttons.",e.jsx("span",{className:"hidden sm:inline",children:" Use Ctrl+B for bold, Ctrl+I for italic, Ctrl+U for underline."})]})]}),e.jsxs("div",{children:[e.jsx(v,{htmlFor:"image",children:"Article Image (Optional)"}),e.jsxs("div",{className:"mt-2",children:[e.jsx(C,{id:"image",type:"file",accept:"image/*",onChange:t=>Q(t,!1),className:"mt-2"}),l.imageUrl&&e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"relative w-32 h-24 rounded-lg overflow-hidden border border-gray-200",children:[e.jsx("img",{src:l.imageUrl,alt:"Preview",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",onClick:()=>y(t=>g(x({},t),{imageUrl:""})),className:"absolute top-1 right-1 bg-red-500 text-white rounded-full w-6 h-6 flex items-center justify-center text-xs hover:bg-red-600",children:"Ã"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Image will appear in the article card"})]})]})]}),e.jsxs("div",{children:[e.jsx(v,{children:"Tags"}),e.jsxs("div",{className:"mt-2 flex flex-col sm:flex-row gap-2",children:[e.jsx(C,{value:k,onChange:t=>T(t.target.value),placeholder:"Add a tag...",onKeyPress:t=>t.key==="Enter"&&(t.preventDefault(),G()),className:"flex-1"}),e.jsx(o,{type:"button",onClick:G,variant:"outline",size:"sm",className:"w-full sm:w-auto",children:e.jsx(ye,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:l.tags.map(t=>e.jsxs(R,{variant:"secondary",className:"flex items-center gap-1 text-xs sm:text-sm",children:[t,e.jsx("button",{type:"button",onClick:()=>ae(t),className:"ml-1 hover:text-red-600",children:e.jsx(B,{className:"w-3 h-3"})})]},t))})]}),e.jsx("div",{className:"flex gap-4",children:e.jsx(o,{type:"submit",disabled:E,className:"w-full bg-gradient-to-r from-purple-600 to-blue-600 hover:from-purple-700 hover:to-blue-700",children:E?"Uploading...":"Upload Article"})})]})})]})}),e.jsx("div",{className:"xl:col-span-1",children:e.jsxs(z,{children:[e.jsx(H,{children:e.jsx(M,{children:"Article Preview"})}),e.jsx($,{children:l.title?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900",children:l.title}),l.subtitle&&e.jsx("p",{className:"text-sm text-gray-600 mt-1",children:l.subt
1itle})]}),l.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:l.tags.map(t=>e.jsx(R,{variant:"outline",className:"text-xs",children:t},t))})]}):e.jsx("p",{className:"text-gray-500 text-sm",children:"Start writing to see a preview..."})})]})})]}),e.jsx("div",{className:"mt-12",children:e.jsxs(z,{children:[e.jsx(H,{children:e.jsxs(M,{className:"flex flex-col sm:flex-row items-start sm:items-center gap-2 sm:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"w-5 h-5"}),e.jsxs("span",{children:["Existing Articles (",F.length,")"]})]}),e.jsx(o,{onClick:P,variant:"outline",size:"sm",disabled:L,className:"w-full sm:w-auto sm:ml-auto",children:L?"Loading...":"Refresh"})]})}),e.jsx($,{children:L?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-8 h-8 border-4 border-purple-600 border-t-transparent rounded-full animate-spin mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600",children:"Loading articles..."})]}):F.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(te,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600",children:"No articles found"})]}):e.jsx("div",{className:"space-y-4",children:F.map(t=>{var s,a;return e.jsx("div",{className:"border border-gray-200 rounded-lg p-4 hover:bg-gray-50",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-1 text-base sm:text-lg",children:t.title}),t.subtitle&&e.jsx("p",{className:"text-sm text-gray-600",children:t.subtitle})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 sm:gap-4 text-xs sm:text-sm text-gray-500",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium text-gray-600",children:"Tags"}),e.jsx("span",{children:((s=t.tags)==null?void 0:s.length)||0})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium text-gray-600",children:"Views"}),e.jsx("span",{children:((a=t.views)==null?void 0:a.toLocaleString())||"0"})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium text-gray-600",children:"Likes"}),e.jsx("span",{children:t.likes||0})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium text-gray-600",children:"Created"}),e.jsx("span",{children:new Date(t.publishedAt).toLocaleDateString()})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-2 pt-2 border-t border-gray-100",children:[e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>re(t),className:"text-green-600 hover:text-green-700 flex-1 sm:flex-none",children:[e.jsx(Ne,{className:"w-4 h-4 mr-1"}),"Edit"]}),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>window.open("/articles","_blank"),className:"text-blue-600 hover:text-blue-700 flex-1 sm:flex-none",children:[e.jsx(we,{className:"w-4 h-4 mr-1"}),"View"]}
1),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>le(t.id),disabled:_===t.id,className:"text-red-600 hover:text-red-700 flex-1 sm:flex-none",children:[_===t.id?e.jsx("div",{className:"w-4 h-4 border-2 border-red-600 border-t-transparent rounded-full animate-spin mr-1"}):e.jsx(Ce,{className:"w-4 h-4 mr-1"}),"Delete"]})]})]})},t.id)})})})]})})]}),se&&S&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-2 sm:p-4",children:e.jsx("div",{className:"bg-white rounded-lg max-w-2xl w-full max-h-[90vh] overflow-y-auto",children:e.jsxs("div",{className:"p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 sm:mb-6",children:[e.jsx("h2",{className:"text-xl sm:text-2xl font-bold text-gray-900",children:"Edit Article"}),e.jsx(o,{variant:"ghost",size:"sm",onClick:I,className:"text-gray-500 hover:text-gray-700",children:e.jsx(B,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(v,{htmlFor:"edit-title",children:"Article Title"}),e.jsx(C,{id:"edit-title",value:c.title||"",onChange:t=>f(s=>g(x({},s),{title:t.target.value})),className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(v,{htmlFor:"edit-subtitle",children:"Subtitle (Optional)"}),e.jsx(C,{id:"edit-subtitle",value:c.subtitle||"",onChange:t=>f(s=>g(x({},s),{subtitle:t.target.value})),className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(v,{htmlFor:"edit-image",children:"Article Image (Optional)"}),e.jsxs("div",{className:"mt-2",children:[e.jsx(C,{id:"edit-image",type:"file",accept:"image/*",onChange:t=>Q(t,!0),className:"mt-2"}),c.imageUrl&&e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"relative w-32 h-24 rounded-lg overflow-hidden border border-gray-200",children:[e.jsx("img",{src:c.imageUrl,alt:"Preview",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",onClick:()=>f(t=>g(x({},t),{imageUrl:""})),className:"absolute top-1 right-1 bg-red-500 text-white rounded-full w-6 h-6 flex items-center justify-center text-xs hover:bg-red-600",children:"Ã"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Image will appear in the article card"})]})]})]}),e.jsxs("div",{children:[e.jsx(v,{children:"Tags"}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:(X=c.tags)==null?void 0:X.map((t,s)=>e.jsxs(R,{variant:"secondary",className:"bg-gray-100 text-gray-700",children:[t,e.jsx("button",{type:"button",onClick:()=>f(a=>g(x({},a),{tags:a.tags.filter((n,r)=>r!==s)})),className:"ml-2 text-gray-500 hover:text-gray-700",children:e.jsx(B,{className:"w-3 h-3"})})]},s))}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(C,{placeholder:"Add a tag...",value:c.newTag||"",onChange:t=>f(s=>g(x({},s),{newTag:t.target.value})),className:"flex-1"}),e.jsx(o,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=c.newTag;t!=null&&t.trim()&&f(s=>g(x({},s),{tags:[...s.tags||[],t.trim()],newTag:""}))},children:"Add"})]})]}),e.jsxs("div",{children:[e.jsx(v,{children:"Content (Edit)"}),e.jsx("div",{id:"edit-rich-editor",contentEditable:!0,suppressContentEditableWarning:!0,dangerouslySetInnerHTML:{__html:c.content||""},onInput:t=>f(s=>g(x({},s),{content:t.currentTarget.innerHTML})),className:"min-h-[200px] p-3 border border-gray-200 rounded-lg bg-white focus:ring-2 focus:ring-blue-500 focus:border-transparent overflow-y-auto text-sm text-gray-800",style:{fontFamily:"Inter, system-ui, sans-serif",lineHeight:"1.6"}})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[e.jsx(o,{onClick:ne,disabled:J,className:"w-full sm:flex-1 bg-green-600 hover:bg-green-700",children:J?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin mr-2"}),"Updating..."]}):"Save Changes"}),e.jsx(o,{variant:"outline",onClick:I,className:"w-full sm:flex-1",children:"Cancel"})]})]})})})]})};export{Pe as default};
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.