import{r as o,j as e,u as Wt,R as tt,h as Xt,a as K}from"./app-BwDemWQz.js";import{a as Kt,E as Qt,S as rt}from"./emoji-picker-react.esm-C2auypZg.js";import{X as Q,I as Oe,F as He,o as he,P as st,D as Jt,j as Zt,k as _t,l as Ue,f as er}from"./AppLayout-3zbhnyYw.js";import{S as Ie}from"./search-sQ0SJSXK.js";import{C as ze,S as ot,a as lt,b as nt,c as it,d as dt}from"./Select-CfDsuz_M.js";import{s as Y,C as tr}from"./index-CkDmAPFS.js";import{S as De}from"./sparkles-BNcnDUCn.js";import{c as Ee}from"./createLucideIcon-BASx8f0E.js";import{A as at}from"./arrow-right-Ctvx1a-x.js";import{S as rr}from"./save-efCvtXyR.js";import{D as ar}from"./download-Bp5_-seZ.js";import{B as sr}from"./Button-B-KWyoQR.js";import{I as or}from"./info-CEE4pHon.js";import{U as lr}from"./upload-B-3i7Erd.js";import{L as nr}from"./link-BuvjkyeI.js";import{C as ir}from"./clock-BJENbNTm.js";import{C as dr}from"./chevron-left-BxYqeqJW.js";/**
 * @license lucide-react v0.539.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const cr=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],mr=Ee("grip-vertical",cr);/**
 * @license lucide-react v0.539.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const gr=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],ur=Ee("hash",gr);/**
 * @license lucide-react v0.539.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const xr=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],$e=Ee("video",xr);function hr({isOpen:T,onClose:S,onApply:L,t:s,platforms:m,templates:D=[]}){var O;const[u,I]=o.useState(""),[j,y]=o.useState(""),[d,b]=o.useState(!1),A=o.useRef(null),h=D.filter(g=>{var i,c;const n=((i=g==null?void 0:g.name)==null?void 0:i.toLowerCase().includes(u.toLowerCase()))||((c=g==null?void 0:g.prompt)==null?void 0:c.toLowerCase().includes(u.toLowerCase())),k=j===""||g.platform_id===j;return n&&k});o.useEffect(()=>{const g=n=>{A.current&&!A.current.contains(n.target)&&b(!1)};return d&&document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[d]);const G=g=>{L&&L(g),S()},f=g=>{y(g),b(!1)},U=g=>{g.stopPropagation(),S()},$=g=>{g.stopPropagation()};return T?e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:U}),e.jsxs("div",{className:"relative w-full max-w-4xl mx-4 bg-white dark:bg-zinc-900 rounded-2xl shadow-2xl max-h-[90vh] overflow-hidden",onClick:$,"data-template-browser-modal":!0,children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-zinc-800",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:s("Browse AI Template")}),e.jsx("button",{onClick:()=>{S()},className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:e.jsx(Q,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"p-6 border-b border-gray-200 dark:border-zinc-800",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Ie,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",value:u,onChange:g=>I(g.target.value),placeholder:s("Search"),className:"w-full pl-10 pr-4 py-2 bg-gray-50 dark:bg-zinc-800 border border-gray-200 dark:border-gray-600 rounded-lg text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 focus:ring-2 focus:ring-cyan-500 focus:border-transparent"})]}),e.jsxs("div",{className:"relative",ref:A,children:[e.jsxs("button",{onClick:()=>{b(!d)},className:"flex items-center gap-2 px-4 py-2 bg-gray-50 dark:bg-zinc-800 border border-gray-200 dark:border-gray-600 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-600 transition-colors min-w-[140px] justify-between",children:[e.jsx("span",{children:j===""?"All Platforms":(O=m.find(g=>g.id===j))==null?void 0:O.name}),e.jsx(ze,{className:`w-4 h-4 transition-transform ${d?"rotate-180":""}`})]}),d&&e.jsxs("div",{className:"absolute top-full right-0 mt-1 w-40 bg-white dark:bg-zinc-900 border border-gray-200 dark:border-zinc-800 rounded-lg shadow-lg z-[70]",children:[e.jsx("button",{onClick:()=>f(""),className:`w-full text-left px-4 py-2 text-sm hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors rounded-t-lg ${j===""?"bg-primary/10 dark:bg-primary/20 text-primary dark:text-primary":"text-gray-700 dark:text-gray-300"}`,children:"All Platforms"}),m.map(g=>e.jsx("button",{onClick:()=>f(g.id),className:`w-full text-left px-4 py-2 text-sm hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors last:rounded-b-lg ${j===g.id?"bg-primary/10 dark:bg-primary/20 text-primary dark:text-primary":"text-gray-700 dark:text-gray-300"}`,children:g.name},g.id))]})]})]})}),e.jsxs("div",{className:"p-6 overflow-y-auto max-h-[60vh]",children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:h.map(g=>e.jsxs("button",{onClick:()=>G(g),className:"p-4 text-left bg-gray-50 dark:bg-zinc-800 hover:bg-cyan-500 dark:hover:bg-cyan-600 rounded-lg border border-gray-200 dark:border-gray-600 hover:border-primary dark:hover:border-cyan-600 transition-all duration-200 group",children:[e.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100 mb-2 group-hover:text-white",children:g.name}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 group-hover:text-cyan-100",children:g.prompt})]},g.id))}),h.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6",children:[e.jsx("div",{className:"w-16 h-16 bg-gray-100 dark:bg-gray-700 rounded-full flex items-center justify-center mb-4",children:e.jsx(Ie,{className:"w-8 h-8 text-gray-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2",children:"No templates found"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 text-center max-w-sm",children:u||j?"Try adjusting your search criteria or browse all platforms to find more templates.":"No AI templates are available at the moment. Templates will appear here once they are created."}),(u||j)&&e.jsx("button",{onClick:()=>{I(""),y("")},className:"mt-4 px-4 py-2 text-sm font-medium text-primary hover:text-primary-dark dark:text-primary-light dark:hover:text-primary transition-colors",children:"Clear filters"})]})]})]})]}):null}function pr({isOpen:T,onClose:S,onApply:L,t:s,ai_modules:m,platforms:D=[],templates:u=[]}){var ee,we,ce,Ne,te,W,re,me,ge;const{props:I}=Wt(),j=(ee=I.auth)==null?void 0:ee.user,[y,d]=o.useState(""),[b,A]=o.useState(!1),[h,G]=o.useState("text"),[f,U]=o.useState(!1),[$,O]=o.useState(null),[g,n]=o.useState(null),[k,i]=o.useState([]),[c,F]=o.useState(!0),M=o.useRef(null),R=o.useRef(null),[pe,q]=o.useState(!1),[Ae,ye]=o.useState(""),[oe,J]=o.useState(((we=D.find(r=>r.slug==="facebook"))==null?void 0:we.id)||null),[V,be]=o.useState(""),[Z,le]=o.useState(!1),C={text:{name:((ce=m==null?void 0:m.text)==null?void 0:ce.name)||"Text",...m==null?void 0:m.text,icon:He},image:{name:((Ne=m==null?void 0:m.image)==null?void 0:Ne.name)||"Images",...m==null?void 0:m.image,icon:Oe},video:{name:((te=m==null?void 0:m.video)==null?void 0:te.name)||"Videos",...m==null?void 0:m.video,icon:$e}};u.slice(0,4).map(r=>r.prompt);const Ce=r=>{r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),_())},Pe=()=>{A(!0)},_=async()=>{if(!y.trim())return;F(!1);const r={id:Date.now(),type:"user",content:y,module:h,timestamp:new Date};i(x=>[...x,r]);const w=y;d(""),U(!0),n(null),O(null);try{const x=k.filter(v=>v.type==="user"||v.type==="ai").slice(-6).map(v=>{var P,H;return{role:v.type==="user"?"user":"assistant",content:v.type==="user"?v.content:((P=v.content)==null?void 0:P.content)||((H=v.content)==null?void 0:H.message)||""}}).filter(v=>v.content&&v.content.trim()!==""),{data:p}=await Xt.post(Y("user.ai.generate"),{prompt:w,module:h,conversation_history:x});if(p.status==="success"){const v={id:Date.now()+1,type:"ai",content:p,module:h,timestamp:new Date};i(P=>[...P,v]),O(p);return}if(p.status==="error"){const v=p.message||"AI generation failed";n(v);const P={id:Date.now()+1,type:"error",content:{message:v},module:h,timestamp:new Date};i(H=>[...H,P]);return}n("Unexpected response format from server")}catch(x){console.error("AI Generation Error:",x);let p="Failed to generate content";if(x.response){const P=x.response.status,H=x.response.data;switch(P){case 422:p=H.message||"Invalid request parameters";break;case 500:p="AI service is temporarily unavailable. Please check your AI configuration.";break;case 404:p="AI generation service not found";break;default:p=H.message||`Server error (${P})`}}else x.request&&(p="Unable to reach AI service. Please check your connection.");n(p);const v={id:Date.now()+1,type:"error",content:{message:p},module:h,timestamp:new Date};i(P=>[...P,v])}finally{U(!1)}},fe=r=>{q(!0),ye(r)},ne=r=>{r.preventDefault(),le(!0),K.post(Y("user.template.ai.store"),{name:V??"Ai Template",prompt:Ae,platform_id:oe},{onSuccess:()=>{le(!1),q(!1)},onError:()=>{le(!1),q(!1)}})},ve=r=>{d(r)},ie=r=>{try{if(r.module==="text"){const w=new Blob([r.content.content],{type:"text/plain"});ke(w,r.title||"ai-generated-content.txt");return}(r.module==="image"||r.module==="video")&&fetch(r.content.url||r.thumbnail).then(w=>w.blob()).then(w=>{const x=r.module==="image"?"png":"mp4";ke(w,(r.title||`ai-generated-${r.module}`)+`.${x}`)}).catch(()=>alert("Download failed"))}catch(w){console.error("Download error:",w),alert("Download failed")}},ke=(r,w)=>{const x=window.URL.createObjectURL(r),p=document.createElement("a");p.href=x,p.download=w,document.body.appendChild(p),p.click(),document.body.removeChild(p),window.URL.revokeObjectURL(x)},de=()=>{if(h==="text")return e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"}),e.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-3/4"}),e.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse w-1/2"})]});if(h==="image")return e.jsx("div",{className:"grid grid-cols-2 gap-3",children:[1,2,3,4].map(r=>e.jsx("div",{className:"aspect-square bg-gray-200 dark:bg-gray-700 rounded-lg animate-pulse"},r))});if(h==="video")return e.jsx("div",{className:"aspect-video bg-gray-200 dark:bg-gray-700 rounded-lg animate-pulse flex items-center justify-center",children:e.jsx($e,{className:"w-12 h-12 text-gray-400 animate-pulse"})})},Le=()=>e.jsx("div",{className:"space-y-4 mb-6",children:k.map(r=>{var w;return e.jsx("div",{children:r.type==="user"?e.jsx("div",{className:"flex justify-end",children:e.jsxs("div",{className:"max-w-[80%] bg-gradient-to-r from-primary to-secondary text-white rounded-2xl rounded-br-md px-4 py-3 relative group shadow-sm",children:[e.jsx("p",{className:"text-sm leading-relaxed",children:r.content}),e.jsxs("div",{className:"flex items-center justify-between mt-2 pt-2 border-t border-white/20",children:[e.jsxs("span",{className:"text-xs text-white/80 capitalize flex items-center gap-1",children:[((w=C[r.module])==null?void 0:w.icon)&&e.jsx("span",{className:"inline-block w-3 h-3",children:tt.createElement(C[r.module].icon,{className:"w-3 h-3"})}),r.module]}),e.jsxs("div",{className:"flex items-center space-x-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>ve(r.content),className:"p-1 text-white/80 hover:text-white hover:bg-white/20 rounded transition-all",title:"Reuse prompt",children:e.jsx(at,{className:"w-3 h-3"})}),e.jsx("button",{onClick:()=>fe(r.content),className:"p-1 text-white/80 hover:text-white hover:bg-white/20 rounded transition-all",title:"Save as template",children:e.jsx(rr,{className:"w-3 h-3"})})]})]})]})}):r.type==="error"?e.jsx("div",{className:"flex justify-start",children:e.jsxs("div",{className:"max-w-[80%] bg-red-50 dark:bg-red-900/20 rounded-2xl rounded-bl-md px-4 py-3 border border-red-200 dark:border-red-800 shadow-sm",children:[e.jsxs("div",{className:"flex items-center mb-2",children:[e.jsx("div",{className:"w-5 h-5 bg-red-500 rounded-full flex items-center justify-center mr-2 shadow-sm",children:e.jsx(Q,{className:"w-3 h-3 text-white"})}),e.jsx("span",{className:"text-xs font-medium text-red-600 dark:text-red-400",children:"Configuration Error"})]}),e.jsx("p",{className:"text-sm text-red-700 dark:text-red-300 leading-relaxed",children:r.content.message}),e.jsx("div",{className:"mt-2 pt-2 border-t border-red-200 dark:border-red-800",children:e.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:"💡 Please configure your AI settings in the admin panel to use this feature."})})]})}):e.jsx("div",{className:"flex justify-start",children:e.jsxs("div",{className:"max-w-[80%] bg-gray-50 dark:bg-zinc-800 rounded-2xl rounded-bl-md px-4 py-3 border border-gray-200 dark:border-gray-600 shadow-sm",children:[e.jsxs("div",{className:"flex items-center mb-2",children:[e.jsx("div",{className:"w-5 h-5 bg-gradient-to-r from-primary to-secondary rounded-full flex items-center justify-center mr-2 shadow-sm",children:e.jsx(De,{className:"w-3 h-3 text-white"})}),e.jsxs("span",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 capitalize",children:["AI ",r.module," Response"]})]}),r.module==="text"&&e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 leading-relaxed whitespace-pre-wrap",children:r.content.content}),r.module==="image"&&r.content.urls&&e.jsx("div",{className:"grid grid-cols-2 gap-2",children:r.content.urls.map((x,p)=>e.jsx("img",{src:x||"/placeholder.svg",alt:`Generated image ${p+1}`,className:"w-full aspect-square object-cover rounded-lg"},p))}),r.module==="video"&&r.content.url&&e.jsx("video",{src:r.content.url,controls:!0,className:"w-full aspect-video rounded-lg",poster:"/video-placeholder.png"}),e.jsxs("div",{className:"flex items-center justify-end mt-3 pt-2 border-t border-gray-200 dark:border-gray-600 space-x-1",children:[e.jsx("button",{onClick:()=>{L&&(L(r.content),S())},className:"p-1 text-gray-500 hover:text-cyan-600 hover:bg-gray-200 dark:hover:bg-gray-600 rounded transition-colors",title:"Insert into composer",children:e.jsx(st,{className:"w-3 h-3"})}),e.jsx("button",{onClick:()=>ie(r),className:"p-1 text-gray-500 hover:text-cyan-600 hover:bg-gray-200 dark:hover:bg-gray-600 rounded transition-colors",title:"Download",children:e.jsx(ar,{className:"w-3 h-3"})})]})]})})},r.id)})}),je=r=>{G(r)},Me=r=>{d(r.description),A(!1)};return o.useEffect(()=>{R.current&&(R.current.scrollTop=R.current.scrollHeight)},[k,f]),o.useEffect(()=>{T&&k.length===0&&F(!0)},[T,k.length]),T?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[e.jsx("div",{className:"flex-1 backdrop-blur-sm bg-black/20",onClick:S}),e.jsx("div",{ref:M,className:`w-96 bg-white dark:bg-zinc-900 shadow-2xl transform transition-transform duration-300 ease-out ${T?"translate-x-0":"translate-x-full"}`,children:e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"p-6 text-center border-b border-gray-200 dark:border-zinc-800",children:[e.jsx("button",{onClick:S,className:"absolute top-4 right-4 p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:e.jsx(Q,{className:"w-5 h-5"})}),e.jsx("div",{className:"w-16 h-16 bg-gradient-to-r from-primary to-secondary rounded-full flex items-center justify-center mx-auto mb-4 shadow-lg",children:e.jsx(De,{className:"w-8 h-8 text-white animate-bounce"})}),e.jsx("h2",{className:"text-2xl font-bold bg-gradient-to-r from-gray-900 to-gray-700 dark:from-white dark:to-gray-200 bg-clip-text text-transparent mb-2",children:"AI Content Assistant"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:"Generate professional content with AI"}),e.jsx("div",{className:"bg-gradient-to-r from-primary/10 to-secondary/10 dark:from-primary/20 dark:to-secondary/20 rounded-lg p-3 border border-primary/20 mb-4",children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[((W=C[h])==null?void 0:W.icon)&&tt.createElement(C[h].icon,{className:"w-5 h-5 text-primary"}),e.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200",children:f?`Generating ${((re=C[h])==null?void 0:re.name)||h}...`:`You are generating ${((me=C[h])==null?void 0:me.name)||h}`})]})})]}),e.jsxs("div",{ref:R,className:"flex-1 p-6 overflow-y-auto scroll-smooth",children:[k.length>0&&Le(),k.length===0&&c&&e.jsxs("div",{className:"flex flex-col items-center justify-center text-center py-8 px-4",children:[e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xl font-bold text-gray-900 dark:text-white animate-fade-in",children:["Good to see you here, ",(j==null?void 0:j.name)||"there","! 👋"]}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 animate-fade-in-delay max-w-xs mx-auto leading-relaxed",children:"I'm your AI assistant, ready to help you create amazing content. What would you like to generate today?"})]})}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 w-full max-w-sm",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gradient-to-r from-blue-50 to-indigo-50 dark:from-blue-900/20 dark:to-indigo-900/20 rounded-lg border border-blue-200 dark:border-blue-800 animate-slide-up",children:[e.jsx(He,{className:"w-5 h-5 text-blue-600 dark:text-blue-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-blue-700 dark:text-blue-300",children:"Generate text content"})]}),e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gradient-to-r from-emerald-50 to-green-50 dark:from-emerald-900/20 dark:to-green-900/20 rounded-lg border border-emerald-200 dark:border-emerald-800 animate-slide-up-delay",children:[e.jsx(Oe,{className:"w-5 h-5 text-emerald-600 dark:text-emerald-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-emerald-700 dark:text-emerald-300",children:"Create images"})]}),e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gradient-to-r from-purple-50 to-pink-50 dark:from-purple-900/20 dark:to-pink-900/20 rounded-lg border border-purple-200 dark:border-purple-800 animate-slide-up-delay-2",children:[e.jsx($e,{className:"w-5 h-5 text-purple-600 dark:text-purple-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-purple-700 dark:text-purple-300",children:"Generate videos"})]})]})]}),f&&e.jsx("div",{className:"flex justify-start mb-4",children:e.jsxs("div",{className:"max-w-[80%] bg-gray-100 dark:bg-gray-700 rounded-2xl rounded-bl-md px-4 py-3",children:[e.jsxs("div",{className:"flex items-center mb-2",children:[e.jsx("div",{className:"w-2 h-2 bg-gradient-to-r from-primary to-secondary rounded-full animate-pulse mr-2"}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Generating ",((ge=C[h])==null?void 0:ge.name)||h,"..."]})]}),de()]})})]}),e.jsxs("div",{className:"p-6 border-t border-gray-200 dark:border-zinc-800",children:[e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{value:y,onChange:r=>d(r.target.value),onKeyPress:Ce,placeholder:s("Write something..."),rows:3,className:"w-full px-4 py-3 pr-16 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-zinc-800 text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 focus:ring-2 focus:ring-cyan-500 focus:border-transparent resize-none"}),e.jsx("button",{onClick:_,disabled:!y.trim()||f,className:"absolute bottom-3 right-3 px-3 py-1.5 bg-gradient-to-r from-primary to-secondary hover:from-secondary hover:to-primary disabled:from-gray-300 disabled:to-gray-400 disabled:cursor-not-allowed text-white rounded-lg flex items-center justify-center transition-all shadow-sm hover:shadow-md",children:f?e.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):e.jsx(at,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex items-center justify-between mt-4",children:[e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("button",{onClick:Pe,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:"Browse templates",children:e.jsx(De,{className:"w-4 h-4"})})}),e.jsx("div",{className:"flex items-center space-x-2",children:Object.entries(C).map(([r,w])=>{const x=w.icon,p=h===r;return e.jsx("button",{onClick:()=>je(r),className:`p-2 rounded-lg transition-all ${p?"bg-gradient-to-r from-primary to-secondary text-white shadow-sm":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:w.name||r,children:e.jsx(x,{className:"w-5 h-5"})},r)})})]})]})]})})]}),e.jsx(he,{isOpen:pe,onClose:()=>{q(!1),be(""),ye(""),setSaveAsTemplate(!1)},title:s("Save Ai Template"),onSubmit:ne,submitText:s("Save Template"),showSubmit:!0,isDataSubmitting:Z,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("Template Name")}),e.jsx("input",{type:"text",value:V,onChange:r=>be(r.target.value),placeholder:s("Enter template name"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-zinc-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-cyan-500 focus:border-transparent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("Prompt")}),e.jsx("textarea",{value:Ae,onChange:r=>ye(r.target.value),placeholder:s("Describe what this template is for"),rows:3,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-zinc-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-cyan-500 focus:border-transparent resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Select Platform"}),e.jsxs(ot,{value:oe,onValueChange:r=>J(r),children:[e.jsx(lt,{className:"w-full min-w-[180px] bg-gray-50 border-gray-200 dark:bg-zinc-800 dark:border-none dark:text-neutral-200",children:e.jsx(nt,{placeholder:"Choose a platform"})}),e.jsx(it,{children:D.map(r=>e.jsx(dt,{value:r.id,children:r.name},r.id))})]})]})]})}),e.jsx(hr,{isOpen:b,onClose:()=>A(!1),onApply:Me,t:s,templates:u,platforms:D})]}):null}function yr({isOpen:T,onClose:S,onApply:L,t:s,media:m}){var k;const[D,u]=o.useState("all"),[I,j]=o.useState("all"),[y,d]=o.useState(""),[b,A]=o.useState([]),[h,G]=o.useState(!1),f=o.useRef(null),U=m.filter(i=>{const c=D==="all"||i.type===D,F=I==="all"||i.platform===I,M=i.alt.toLowerCase().includes(y.toLowerCase());return c&&F&&M}),$=i=>{A(c=>c.includes(i)?c.filter(F=>F!==i):[...c,i])},O=()=>{const i=m.filter(c=>b.includes(c.id));L(i),A([]),S()};o.useEffect(()=>{const i=c=>{f.current&&!f.current.contains(c.target)&&S()};return T&&(document.addEventListener("mousedown",i),document.addEventListener("touchstart",i)),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("touchstart",i)}},[T,S]);const g=[{id:"all",name:"All Platform"},{id:"facebook",name:"Facebook"},{id:"instagram",name:"Instagram"},{id:"x",name:"X"},{id:"youtube",name:"YouTube"},{id:"linkedin",name:"LinkedIn"},{id:"tiktok",name:"TikTok"},{id:"threads",name:"Threads"}],n=i=>{j(i),G(!1)};return T?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 bg-black/20 backdrop-blur-sm z-40"}),e.jsxs("div",{ref:f,className:"fixed top-0 right-0 h-full w-96 bg-white dark:bg-zinc-900 shadow-2xl z-50 transform transition-transform duration-300 ease-out flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-zinc-800 flex-shrink-0",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:s("Gallery")}),e.jsx("button",{onClick:S,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:e.jsx(Q,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-4 space-y-4 border-b border-gray-200 dark:border-zinc-800 flex-shrink-0",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ie,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",value:y,onChange:i=>d(i.target.value),placeholder:s("Search media"),className:"w-full pl-10 pr-4 py-2 bg-gray-100 dark:bg-gray-700 border-0 rounded-lg text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 focus:ring-2 focus:ring-cyan-500 focus:bg-white dark:focus:bg-gray-600 transition-colors"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>G(!h),className:"w-full flex items-center justify-between px-4 py-2 bg-gray-100 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-gray-100 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:[e.jsx("span",{children:(k=g.find(i=>i.id===I))==null?void 0:k.name}),e.jsx(ze,{className:"w-4 h-4"})]}),h&&e.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white dark:bg-zinc-800 border border-gray-200 dark:border-gray-600 rounded-lg shadow-lg z-10",children:g.map(i=>e.jsx("button",{onClick:()=>n(i.id),className:"w-full text-left px-4 py-2 text-gray-900 dark:text-gray-100 hover:bg-gray-100 dark:hover:bg-gray-600 first:rounded-t-lg last:rounded-b-lg transition-colors",children:i.name},i.id))})]})]}),e.jsxs("div",{className:"flex items-center space-x-1 p-4 pb-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>u("all"),className:`px-4 py-2 text-sm font-medium rounded-lg transition-colors ${D==="all"?"bg-gradient-to-r from-primary to-secondary text-white hover:from-secondary hover:to-primary":"text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:s("All")}),e.jsx("button",{onClick:()=>u("image"),className:`px-4 py-2 text-sm font-medium rounded-lg transition-colors ${D==="image"?"bg-gradient-to-r from-primary to-secondary text-white hover:from-secondary hover:to-primary":"text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:s("Image")}),e.jsx("button",{onClick:()=>u("video"),className:`px-4 py-2 text-sm font-medium rounded-lg transition-colors ${D==="video"?"bg-gradient-to-r from-primary to-secondary text-white hover:from-secondary hover:to-primary":"text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:s("Video")})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-4 min-h-0",children:e.jsx("div",{className:"grid grid-cols-2 gap-3 pb-4",children:U.map(i=>e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden cursor-pointer group",onClick:()=>$(i.id),children:[i.isVideo?e.jsx("video",{src:i.thumbnail,muted:!0,playsInline:!0,loop:!0,autoPlay:!0,className:"w-full h-full object-cover rounded-lg"}):e.jsx("img",{src:i.thumbnail||"/placeholder.svg",alt:i.alt,className:"w-full h-full object-cover transition-transform group-hover:scale-105 rounded-lg"}),e.jsx("div",{className:"absolute bottom-2 right-2",children:e.jsx("div",{className:`w-6 h-6 rounded border-2 flex items-center justify-center transition-colors ${b.includes(i.id)?"bg-cyan-500 border-primary":"bg-white/80 border-white/80 hover:bg-white hover:border-white"}`,children:b.includes(i.id)&&e.jsx(tr,{className:"w-4 h-4 text-white"})})}),i.type==="video"&&e.jsx("div",{className:"absolute top-2 left-2 bg-black/60 text-white text-xs px-2 py-1 rounded",children:"Video"}),e.jsx("div",{className:"absolute top-2 right-2 bg-black/60 text-white text-xs px-2 py-1 rounded capitalize",children:i.platform})]},i.id))})}),e.jsx("div",{className:"p-4 bg-white dark:bg-zinc-900 border-t border-gray-200 dark:border-zinc-800 flex-shrink-0",children:e.jsxs(sr,{variant:"default",onClick:O,disabled:b.length===0,className:"w-full py-3 disabled:bg-gray-300 disabled:cursor-not-allowed",children:[s("Apply")," ",b.length>0&&`(${b.length})`]})})]})]}):null}function br({isOpen:T,onClose:S,onApply:L,t:s,templates:m,platforms:D}){var g;const[u,I]=o.useState(""),[j,y]=o.useState(""),[d,b]=o.useState(null),[A,h]=o.useState(!1),G=m.filter(n=>{var c,F,M;const k=((c=n.platform)==null?void 0:c.id)===u,i=((F=n==null?void 0:n.title)==null?void 0:F.toLowerCase().includes(j.toLowerCase()))||((M=n==null?void 0:n.description)==null?void 0:M.toLowerCase().includes(j.toLowerCase()));return k&&i});o.useEffect(()=>{var n;m.length>0&&!u&&I((n=m[0].platform)==null?void 0:n.id)},[m,u]);const f=n=>{b(k=>k&&k.id===n.id?null:n)},U=()=>{d&&(L([d]),b(null),S())},$=n=>{n.stopPropagation(),S()},O=n=>{I(n),h(!1)};return T?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 bg-black/20 z-40",onClick:$,"data-post-template-modal":"true"}),e.jsxs("div",{className:"fixed top-0 right-0 h-full w-96 bg-white dark:bg-zinc-900 shadow-2xl z-50 transform transition-transform duration-300 ease-in-out flex flex-col","data-post-template-modal":"true",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-zinc-800",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Templates"}),e.jsx("button",{onClick:$,className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:e.jsx(Q,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-4 space-y-4 border-b border-gray-200 dark:border-zinc-800",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ie,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",placeholder:"Search",value:j,onChange:n=>y(n.target.value),className:"w-full pl-10 pr-4 py-2 bg-gray-100 dark:bg-gray-700 border-0 rounded-lg text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 focus:ring-2 focus:ring-cyan-500"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>h(!A),className:"w-full flex items-center justify-between px-4 py-2 bg-gray-100 dark:bg-gray-700 rounded-lg text-gray-900 dark:text-gray-100 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:[e.jsx("span",{children:(g=D.find(n=>n.id===u))==null?void 0:g.name}),e.jsx(ze,{className:"w-4 h-4"})]}),A&&e.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white dark:bg-zinc-800 border border-gray-200 dark:border-gray-600 rounded-lg shadow-lg z-10",children:D.map(n=>e.jsx("button",{onClick:()=>O(n.id),className:"w-full text-left px-4 py-2 text-gray-900 dark:text-gray-100 hover:bg-gray-100 dark:hover:bg-gray-600 first:rounded-t-lg last:rounded-b-lg transition-colors",children:n.name},n.id))})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:e.jsx("div",{className:"grid grid-cols-2 gap-3",children:G.map(n=>{var i;const k=d&&d.id===n.id;return e.jsxs("div",{onClick:()=>f(n),className:`p-4 rounded-lg cursor-pointer transition-all h-36 flex flex-col justify-betwee hover:shadow-md ${k?"bg-gradient-to-br from-primary to-secondary text-white":"bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600"}`,children:[e.jsxs("div",{children:[e.jsx("h3",{className:`font-semibold text-base mb-1 ${k?"text-white":"text-gray-900 dark:text-gray-100"}`,children:n.title}),e.jsx("p",{className:`text-sm line-clamp-1 ${k?"text-white/90":"text-gray-600 dark:text-gray-400"}`,title:n.description,children:n.description})]}),n.images.length>0&&e.jsxs("div",{className:"mt-2 flex gap-2",children:[n.images.slice(0,2).map(c=>c.isVideo?e.jsx("video",{src:c.thumbnail||"/placeholder.mp4",className:"w-1/2 h-18 object-cover rounded-md",muted:!0,playsInline:!0,loop:!0,autoPlay:!0},c.id):e.jsx("img",{src:c.thumbnail||"/placeholder.svg",alt:c.alt,className:"w-1/2 h-18 object-cover rounded-md"},c.id)),n.images.length>2&&e.jsxs("div",{className:"w-1/2 h-18 flex items-center justify-center bg-gray-200 dark:bg-gray-800 rounded-md text-sm font-medium text-gray-700 dark:text-gray-300",children:["+",n.images.length-2," more"]})]}),e.jsx("div",{className:"mt-3 flex items-center justify-between",children:e.jsx("span",{className:"text-xs text-gray-500",children:(i=n.platform)==null?void 0:i.name})})]},n.id)})})}),d&&e.jsx("div",{className:"p-4 border-t border-gray-200 dark:border-zinc-800",children:e.jsx("button",{onClick:U,className:"w-full bg-gradient-to-br from-primary to-secondary hover:from-emerald-500 hover:to-sky-500 text-white font-medium py-3 rounded-lg transition-colors",children:s("Apply")})})]})]}):null}const fr=({isOpen:T,onClose:S,t:L})=>{var d;const[s,m]=o.useState("facebook"),[D,u]=o.useState(!1),I=[{id:"facebook",name:"Facebook"},{id:"instagram",name:"Instagram"},{id:"twitter",name:"X (Twitter)"},{id:"linkedin",name:"LinkedIn"},{id:"youtube",name:"YouTube"},{id:"tiktok",name:"TikTok"},{id:"threads",name:"Threads"}],y={facebook:{title:"Facebook Posting Guidelines",content:["• Posts must comply with Facebook Community Standards","• Avoid misleading or false information","• Respect intellectual property rights","• No spam or repetitive content","• Images should be high quality (1200x630px recommended)","• Videos should be under 4GB and less than 240 minutes","• Use relevant hashtags but avoid overuse"],warning:"Facebook may reduce reach for posts that violate community guidelines or appear spammy."},instagram:{title:"Instagram Posting Guidelines",content:["• Follow Instagram Community Guidelines","• Use high-quality images (1080x1080px for feed posts)","• Stories should be 1080x1920px","• Videos should be under 4GB","• Use relevant hashtags (up to 30 per post)","• Avoid shadowbanned hashtags","• Engage authentically with your audience"],warning:"Instagram's algorithm favors authentic engagement and may limit reach for inauthentic activity."},twitter:{title:"X (Twitter) Posting Guidelines",content:["• Follow X Rules and Terms of Service","• Character limit: 280 characters per tweet","• Images should be 1200x675px for optimal display","• Videos should be under 512MB","• Use relevant hashtags (2-3 recommended)","• Avoid excessive self-promotion","• Respect others and avoid harassment"],warning:"X may limit visibility or suspend accounts that violate platform rules."},linkedin:{title:"LinkedIn Posting Guidelines",content:["• Maintain professional tone and content","• Follow LinkedIn Professional Community Policies","• Images should be 1200x627px for articles","• Videos should be under 5GB","• Focus on industry-relevant content","• Avoid overly promotional content","• Engage meaningfully with professional network"],warning:"LinkedIn prioritizes professional, valuable content and may reduce reach for overly promotional posts."},youtube:{title:"YouTube Posting Guidelines",content:["• Follow YouTube Community Guidelines","• Thumbnails should be 1280x720px","• Videos can be up to 12 hours long","• Use relevant tags and descriptions","• Avoid copyright infringement","• Create original, valuable content","• Follow monetization policies if applicable"],warning:"YouTube may demonetize or remove content that violates community guidelines."},tiktok:{title:"TikTok Posting Guidelines",content:["• Follow TikTok Community Guidelines","• Videos should be 9:16 aspect ratio","• Maximum video length: 10 minutes","• Use trending sounds and hashtags","• Create engaging, authentic content","• Avoid copyrighted music without permission","• Respect privacy and safety of others"],warning:"TikTok's algorithm favors engaging, original content and may limit reach for violations."},threads:{title:"Threads Posting Guidelines",content:["• Follow Threads Community Guidelines","• Character limit: 500 characters per post","• Images should be high quality","• Videos should be under 5 minutes","• Use relevant hashtags sparingly","• Engage authentically with community","• Avoid spam and repetitive content"],warning:"Threads prioritizes meaningful conversations and may limit reach for spammy content."}}[s];return e.jsx(he,{isOpen:T,onClose:S,title:"Platform Information & Guidelines",showSubmit:!1,size:"2xl",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Select Platform"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>u(!D),className:"w-full flex items-center justify-between px-4 py-3 bg-white dark:bg-zinc-800 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:[e.jsx("span",{children:(d=I.find(b=>b.id===s))==null?void 0:d.name}),e.jsx(ze,{className:`w-4 h-4 transition-transform ${D?"rotate-180":""}`})]}),D&&e.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white dark:bg-zinc-800 border border-gray-300 dark:border-gray-600 rounded-lg shadow-lg z-10",children:I.map(b=>e.jsx("button",{onClick:()=>{m(b.id),u(!1)},className:`w-full text-left px-4 py-3 hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors first:rounded-t-lg last:rounded-b-lg ${s===b.id?"bg-cyan-50 dark:bg-cyan-900/20 text-cyan-600 dark:text-cyan-400":"text-gray-900 dark:text-gray-100"}`,children:b.name},b.id))})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:y.title}),e.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-3",children:"Guidelines:"}),e.jsx("ul",{className:"space-y-2 text-sm text-gray-700 dark:text-gray-300",children:y.content.map((b,A)=>e.jsx("li",{className:"leading-relaxed",children:b},A))})]}),e.jsxs("div",{className:"bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg p-4",children:[e.jsxs("h4",{className:"font-medium text-amber-800 dark:text-amber-200 mb-2 flex items-center",children:[e.jsx("span",{className:"w-2 h-2 bg-amber-500 rounded-full mr-2"}),"Important Notice"]}),e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300 leading-relaxed",children:y.warning})]}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-blue-800 dark:text-blue-200 mb-2",children:"General Recommendations:"}),e.jsxs("ul",{className:"text-sm text-blue-700 dark:text-blue-300 space-y-1",children:[e.jsx("li",{children:"• Always review platform-specific policies before posting"}),e.jsx("li",{children:"• Test your content with a small audience first"}),e.jsx("li",{children:"• Monitor engagement and adjust strategy accordingly"}),e.jsx("li",{children:"• Keep content authentic and valuable to your audience"})]})]})]}),e.jsx("div",{className:"flex justify-end pt-4 border-t border-gray-200 dark:border-zinc-800",children:e.jsx("button",{onClick:S,className:"px-6 py-2 bg-cyan-500 hover:bg-cyan-600 text-white font-medium rounded-lg transition-colors",children:"Got it"})})]})})};function $r({isCampaign:T=!1,isTemplate:S=!1,isEdit:L=!1,t:s,platform:m="facebook",selectedAccounts:D=[],onPostContentChange:u,onPostTypeChange:I,platformPostTypes:j={},selectedMedia:y=[],onSelectedMediaChange:d,mediaCaptions:b={},onMediaCaptionChange:A,links:h=[],onLinksChange:G,onPost:f,media:U,onSchedulingChange:$,isScheduled:O=!1,scheduledTime:g=null,platforms:n,postTemplateList:k,aiTemplateList:i,exisitngDataOnEdit:c=[],ai_modules:F=[]}){var Je,Ze;const[M,R]=o.useState(""),[pe,q]=o.useState(!1),[Ae,ye]=o.useState(!1),[oe,J]=o.useState(!1),[V,be]=o.useState(()=>{if(T&&(c!=null&&c.startDate))return new Date(c.startDate);const t=new Date;return t.setDate(t.getDate()+1),t}),[Z,le]=o.useState(()=>{const t=new Date;return t.setHours(t.getHours()+2),`${t.getHours().toString().padStart(2,"0")}:00`}),[C,Ce]=o.useState(()=>T&&(c!=null&&c.startDate)?new Date(c.startDate):new Date),[Pe,_]=o.useState(!1),[fe,ne]=o.useState(""),[ve,ie]=o.useState(""),[ke,de]=o.useState(!1),[Le,je]=o.useState(!1),[Me,ee]=o.useState(!1),[we,ce]=o.useState(!1),[Ne,te]=o.useState(!1),[W,re]=o.useState(""),[me,ge]=o.useState(!1),[r,w]=o.useState(!1),[x,p]=o.useState(""),[v,P]=o.useState(null),H=o.useRef(null),Ve=o.useRef(null),[Be,ct]=o.useState(((Je=n.find(t=>t.slug==="facebook"))==null?void 0:Je.id)||null),[vr,kr]=o.useState(!1),mt=["#trending","#viral","#love","#instagood","#photooftheday","#beautiful","#happy","#cute","#tbt","#like4like","#followme","#picoftheday","#follow","#me","#selfie","#summer","#art","#instadaily","#friends","#nature"],Ye={facebook:[{id:"feed",label:s("Feed")},{id:"reels",label:s("Reels")},{id:"story",label:s("Story")}],instagram:[{id:"feed",label:s("Feed")},{id:"reels",label:s("Reels")}],twitter:[{id:"feed",label:s("Feed")}],youtube:[{id:"feed",label:s("Feed")},{id:"shorts",label:s("Shorts")}],linkedin:[{id:"feed",label:s("Feed")}],tiktok:[{id:"feed",label:s("Feed")}],threads:[{id:"feed",label:s("Feed")}]},Re=D.filter(t=>{var l;return((l=t==null?void 0:t.platform)==null?void 0:l.slug)===m}),qe=j[m],X=Array.isArray(qe)?qe:Ye[m]||Ye.facebook,ue=j[m]||(X.length>0?X[0]:{id:"feed",label:"Feed"}),gt=()=>typeof ue=="object"&&ue.id?ue.id:typeof ue=="string"?ue:"feed",[We,Xe]=o.useState(gt());o.useEffect(()=>{X.length>0&&(Xe(X[0].id),I&&I(m,X[0].id))},[m]),o.useEffect(()=>{c.content&&R(c.content)},[c]);const Se=t=>{const l=H.current;if(!l)return;const a=l.selectionStart,N=l.selectionEnd,z=M.substring(0,a)+t+M.substring(N);R(z),u&&u(z),setTimeout(()=>{l.focus(),l.setSelectionRange(a+t.length,a+t.length)},0)},ut=()=>{W&&(Se(W),re(""),te(!1))},xt=t=>{const l=/(https?:\/\/[^\s]+)/g,a=[];let N;for(;(N=l.exec(t))!==null;)a.push({url:N[1],id:Date.now()+Math.random()});a.length!==h.length&&G(a)},ht=t=>{Se(t.emoji),ge(!1)},pt=()=>{w(!0)},yt=t=>{Se(t+" "),w(!1)},Ke=()=>{if(x.trim()){const t=x.startsWith("#")?x:`#${x}`;Se(t+" "),p(""),w(!1)}},bt=()=>{if(f){const l={...f(),is_draft:"0"};K.post(Y("user.post.store"),l)}},ft=()=>{if(f){const t=f();({...t},S?K.post(Y("user.template.update"),t):K.post(Y("user.post.update"),t))}},vt=()=>{if(f){const l={...f(),is_draft:"1"};K.post(Y("user.post.store"),l)}},kt=()=>{de(!0)},jt=()=>{ee(!0)},wt=()=>{je(!0)},Nt=t=>{const l=[...y,...t];d&&d(l)},St=t=>{const l=y.filter(a=>a.id!==t);d&&d(l)},E=new Date(V),[Tt,Dt]=Z.split(":");E.setHours(Number.parseInt(Tt),Number.parseInt(Dt),0,0);const ae=new Date;if(E<=ae)if(T&&(c!=null&&c.startDate)){const t=new Date(c.startDate),l=new Date(c.endDate);ae<t?(E.setTime(t.getTime()),E.setHours(Math.max(12,ae.getHours()+1),0,0,0)):ae<=l?(E.setTime(ae.getTime()),E.setHours(ae.getHours()+1,0,0,0)):console.warn("Scheduled time is after campaign end date")}else E.setDate(E.getDate()+1);o.useEffect(()=>{$&&$(!0,E.toISOString())},[V,Z]);const It=()=>{if(J(!1),f){const l={...f(),is_scheduled:"1",scheduled_time:E.toISOString().slice(0,19).replace("T"," "),is_draft:"0"};K.post(Y("user.post.store"),l)}},Qe=t=>{Ce(l=>{const a=new Date(l);return a.setMonth(l.getMonth()+t),a})},zt=t=>new Date(t.getFullYear(),t.getMonth()+1,0).getDate(),At=t=>new Date(t.getFullYear(),t.getMonth(),1).getDay(),Ct=t=>t.toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"}),Pt=t=>{const l=new Date(C.getFullYear(),C.getMonth(),t);be(l)},Lt=()=>{const t=f(),{accounts:l,postTypes:a,is_scheduled:N,scheduled_time:z,is_draft:xe,...se}=t,Fe={...se,platform_id:Be,name:fe,description:ve};K.post(Y("user.template.store"),Fe),_(!1),ne(""),ie(""),q(!0)},Mt=t=>{t?_(!0):q(!1)},Rt=()=>{var t;(t=Ve.current)==null||t.click()},Ft=async t=>{var N;const l=Array.from(t.target.files);let a=[...y];for(const z of l){const xe=z.type.startsWith("video/"),se=Date.now()+Math.random(),Fe={id:se,type:xe?"video":"image",title:z.name,caption:"",isVideo:xe,thumbnail:URL.createObjectURL(z),isUploading:!0};a=[...a,Fe],d&&d(a);try{const Te=new FormData;Te.append("file",z);const B=await(await fetch(Y("user.gallery.quick-upload"),{method:"POST",body:Te,headers:{"X-CSRF-TOKEN":(N=document.querySelector('meta[name="csrf-token"]'))==null?void 0:N.getAttribute("content"),Accept:"application/json"}})).json();if(B.success&&B.file){const Ge={id:B.file.id,type:B.file.type,title:B.file.title,caption:"",isVideo:B.file.isVideo,thumbnail:B.file.thumbnail,alt:B.file.alt};a=a.map(et=>et.id===se?Ge:et),d&&d(a)}else a=a.filter(Ge=>Ge.id!==se),d&&d(a),console.error("Upload failed:",B)}catch(Te){a=a.filter(_e=>_e.id!==se),d&&d(a),console.error("Upload error:",Te)}}t.target.value=""},Gt=(t,l)=>{P(l),t.dataTransfer.effectAllowed="move"},Ut=t=>{t.preventDefault(),t.dataTransfer.dropEffect="move"},$t=(t,l)=>{if(t.preventDefault(),v===null||v===l){P(null);return}const a=[...y],N=a[v];a.splice(v,1),a.splice(l,0,N),d&&d(a),P(null)},Ot=()=>{P(null)},Ht=t=>{try{if(!t||t.length===0){console.warn("No templates provided to apply");return}const l=t[0];if(l.content){const N=l.content;R(N),u&&u(N)}if(l.images&&Array.isArray(l.images)&&l.images.length>0){const N=l.images.filter(z=>z&&(z.url||z.thumbnail));if(N.length>0){const z=[...y,...N];d&&d(z)}}const a=document.createElement("div");a.className="fixed bottom-4 right-4 bg-green-500 text-white px-6 py-3 rounded-lg shadow-lg z-50 animate-in slide-in-from-bottom-4 duration-300",a.innerHTML=`
        <div class="flex items-center gap-2">
          <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
          </svg>
          <span>Template applied successfully!</span>
        </div>
      `,document.body.appendChild(a),setTimeout(()=>{a.classList.add("animate-out","fade-out","slide-out-to-bottom-4"),setTimeout(()=>document.body.removeChild(a),300)},3e3),ee(!1)}catch(l){console.error("Error applying template:",l);const a=document.createElement("div");a.className="fixed bottom-4 right-4 bg-red-500 text-white px-6 py-3 rounded-lg shadow-lg z-50 animate-in slide-in-from-bottom-4 duration-300",a.innerHTML=`
        <div class="flex items-center gap-2">
          <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
          </svg>
          <span>Failed to apply template. Please try again.</span>
        </div>
      `,document.body.appendChild(a),setTimeout(()=>{a.classList.add("animate-out","fade-out","slide-out-to-bottom-4"),setTimeout(()=>document.body.removeChild(a),300)},3e3)}},Et=t=>{try{if(!t){console.warn("No AI content provided");return}if(typeof t=="string")R(t),u==null||u(t);else if(t.content){const a=t.content;R(a),u==null||u(a)}else if(t.description){const a=t.description;R(a),u==null||u(a)}if(t.urls&&Array.isArray(t.urls)&&t.urls.length>0){const a=t.urls.map((z,xe)=>({id:`ai-image-${Date.now()}-${xe}`,url:z,thumbnail:z,type:"image",isAiGenerated:!0})),N=[...y,...a];d&&d(N)}else if(t.url){const a={id:`ai-media-${Date.now()}`,url:t.url,thumbnail:t.thumbnail||t.url,type:t.type||"image",isAiGenerated:!0},N=[...y,a];d&&d(N)}de(!1);const l=document.createElement("div");l.className="fixed bottom-4 right-4 bg-gradient-to-r from-primary to-secondary text-white px-6 py-3 rounded-lg shadow-lg z-50 animate-in slide-in-from-bottom-4 duration-300",l.innerHTML=`
        <div class="flex items-center gap-2">
          <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"></path>
          </svg>
          <span>AI content applied successfully!</span>
        </div>
      `,document.body.appendChild(l),setTimeout(()=>{l.classList.add("animate-out","fade-out","slide-out-to-bottom-4"),setTimeout(()=>document.body.removeChild(l),300)},3e3)}catch(l){console.error("Error applying AI content:",l);const a=document.createElement("div");a.className="fixed bottom-4 right-4 bg-red-500 text-white px-6 py-3 rounded-lg shadow-lg z-50 animate-in slide-in-from-bottom-4 duration-300",a.innerHTML=`
        <div class="flex items-center gap-2">
          <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
          </svg>
          <span>Failed to apply AI content. Please try again.</span>
        </div>
      `,document.body.appendChild(a),setTimeout(()=>{a.classList.add("animate-out","fade-out","slide-out-to-bottom-4"),setTimeout(()=>document.body.removeChild(a),300)},3e3)}},Vt=()=>{ce(!0)},Bt=t=>{Xe(t),I&&I(m,t)},Yt=t=>{R(t),u&&u(t),xt(t)},qt=(t,l)=>{A&&A(t,l)};return e.jsxs("div",{className:"bg-white dark:bg-zinc-900 rounded-xl border border-gray-200 dark:border-zinc-800 shadow-sm",children:[e.jsx("input",{ref:Ve,type:"file",multiple:!0,accept:"image/*,video/*",onChange:Ft,className:"hidden"}),e.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-zinc-800",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"flex items-center space-x-1 bg-gray-100 dark:bg-gray-700 rounded-lg p-1",children:X.map(t=>e.jsx("button",{onClick:()=>Bt(t.id),className:`px-4 py-2 text-sm font-medium rounded-md transition-colors ${We===t.id?"bg-cyan-500 text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200"}`,children:t.label},t.id))}),e.jsx("button",{onClick:Vt,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:e.jsx(or,{className:"w-5 h-5"})})]}),e.jsx("textarea",{ref:H,value:M,onChange:t=>Yt(t.target.value),placeholder:s("Write Here"),className:"w-full h-48 resize-none border-none outline-none text-gray-700 dark:text-gray-300 placeholder-gray-400 dark:placeholder-gray-500 bg-transparent text-base leading-relaxed p-2"}),y.length>0&&e.jsx("div",{className:"mt-4 grid grid-cols-3 gap-2",children:y.map((t,l)=>e.jsxs("div",{draggable:!0,onDragStart:a=>Gt(a,l),onDragOver:Ut,onDrop:a=>$t(a,l),onDragEnd:Ot,className:`relative group cursor-move ${v===l?"opacity-50":""}`,children:[e.jsx("div",{className:"absolute top-1 left-1 w-5 h-5 bg-black/60 text-white rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10",children:e.jsx(mr,{className:"w-3 h-3"})}),t.isVideo?e.jsx("video",{src:t.thumbnail||(t.upload?URL.createObjectURL(t.upload):t.url),muted:!0,playsInline:!0,loop:!0,autoPlay:!0,className:"w-full h-20 object-cover rounded-lg"}):e.jsx("img",{src:t.thumbnail||(t.upload?URL.createObjectURL(t.upload):t.url)||"/placeholder.svg",alt:t.title||t.alt,className:"w-full h-20 object-cover rounded-lg"}),e.jsx("button",{onClick:()=>St(t.id),className:"absolute top-1 right-1 w-5 h-5 bg-black/60 hover:bg-black/80 text-white rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10",children:e.jsx(Q,{className:"w-3 h-3"})}),e.jsx("div",{className:"mt-1",children:e.jsx("input",{type:"text",placeholder:s("Add caption..."),value:b[t.id]||t.caption||"",onChange:a=>qt(t.id,a.target.value),className:"w-full px-2 py-1 text-xs bg-gray-100 dark:bg-gray-700 border-0 rounded text-gray-700 dark:text-gray-300 placeholder-gray-400 dark:placeholder-gray-500 focus:ring-1 focus:ring-cyan-500"})})]},t.id))})]}),Re.length>0&&e.jsx("div",{className:"px-4 py-2 bg-blue-50 dark:bg-blue-900/20 border-b border-gray-200 dark:border-zinc-800",children:e.jsxs("div",{className:"text-xs text-blue-700 dark:text-blue-300",children:["Posting to ",Re.length," ",m," account",Re.length>1?"s":""," as ",((Ze=X.find(t=>t.id===We))==null?void 0:Ze.label)||"Feed"]})}),e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4 p-4 border-t border-gray-200 dark:border-zinc-800",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsxs(Jt,{children:[e.jsx(Zt,{asChild:!0,children:e.jsx("button",{className:"p-2 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:e.jsx(st,{className:"w-5 h-5"})})}),e.jsxs(_t,{align:"start",className:"w-48",children:[e.jsxs(Ue,{onClick:jt,className:"flex items-center space-x-3 px-3 py-2",children:[e.jsx(He,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{children:s("Post Template")})]}),e.jsxs(Ue,{onClick:wt,className:"flex items-center space-x-3 px-3 py-2",children:[e.jsx(Oe,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{children:s("Open Gallery")})]}),e.jsxs(Ue,{onClick:Rt,className:"flex items-center space-x-3 px-3 py-2",children:[e.jsx(lr,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{children:s("Upload Media")})]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:()=>ge(!me),className:"p-2 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:e.jsx(Kt,{className:"w-5 h-5"})}),me&&e.jsx("div",{className:"absolute bottom-full left-0 mb-2 z-50",children:e.jsx(Qt,{onEmojiClick:ht,width:350,height:400,theme:"auto",searchDisabled:!1,skinTonesDisabled:!1,previewConfig:{showPreview:!1}})})]}),e.jsx("button",{onClick:pt,className:"p-2 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:e.jsx(ur,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>te(!0),className:"p-2 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:e.jsx(nr,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsxs("button",{onClick:kt,className:"flex items-center space-x-2 px-3 py-2 text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg border border-gray-300 dark:border-gray-600 transition-colors",children:[e.jsx(De,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:s("AI Assistance")})]}),!T&&(L?e.jsxs("button",{onClick:ft,disabled:!M.trim(),className:"flex items-center space-x-2 px-3 py-2 bg-emerald-500 hover:bg-emerald-600 disabled:bg-gray-300 disabled:cursor-not-allowed text-white font-medium rounded-lg transition-colors",children:[e.jsx(rt,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:s("Update")})]}):e.jsxs("button",{onClick:bt,disabled:!M.trim(),className:"flex items-center space-x-2 px-3 py-2 bg-cyan-500 hover:bg-cyan-600 disabled:bg-gray-300 disabled:cursor-not-allowed text-white font-medium rounded-lg transition-colors",children:[e.jsx(rt,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:s("Post")})]}))]})]}),!T&&!S&&e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4 p-4 bg-gray-50 dark:bg-gray-900/50 rounded-b-xl",children:[e.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:pe,onChange:t=>Mt(t.target.checked),className:"w-4 h-4 text-primary border-gray-300 dark:border-gray-600 rounded focus:ring-cyan-500 dark:focus:ring-cyan-400 focus:ring-2"}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 font-medium",children:s(pe?"Saved":"Save This Template")})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("button",{onClick:vt,className:"flex items-center space-x-2 px-3 py-2 text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg border border-gray-300 dark:border-gray-600 transition-colors",children:e.jsx("span",{className:"text-sm font-medium",children:s("Save draft")})}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:()=>J(!oe),className:"p-2 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:e.jsx(ir,{className:"w-5 h-5"})}),oe&&e.jsxs("div",{className:"absolute bottom-full right-0 mb-2 bg-white dark:bg-zinc-900 border border-gray-200 dark:border-zinc-800 rounded-lg shadow-lg p-4 w-80 z-50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Schedule Post"}),e.jsx("button",{onClick:()=>J(!1),className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(Q,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("button",{onClick:()=>Qe(-1),className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(dr,{className:"w-4 h-4"})}),e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:C.toLocaleDateString("en-US",{month:"long",year:"numeric"})}),e.jsx("button",{onClick:()=>Qe(1),className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(er,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"grid grid-cols-7 gap-1 mb-4",children:[["Su","Mo","Tu","We","Th","Fr","Sa"].map(t=>e.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 text-center p-2",children:t},t)),Array.from({length:At(C)}).map((t,l)=>e.jsx("div",{className:"p-2"},`empty-${l}`)),Array.from({length:zt(C)}).map((t,l)=>{const a=l+1,N=V.getDate()===a&&V.getMonth()===C.getMonth()&&V.getFullYear()===C.getFullYear(),z=new Date().toDateString()===new Date(C.getFullYear(),C.getMonth(),a).toDateString();return e.jsx("button",{onClick:()=>Pt(a),className:`p-2 text-sm rounded-md transition-colors ${N?"bg-cyan-500 text-white":z?"bg-cyan-100 dark:bg-cyan-900 text-cyan-600 dark:text-cyan-400":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:a},a)})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Time"}),e.jsx("input",{type:"time",value:Z,onChange:t=>le(t.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-zinc-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-cyan-500 focus:border-transparent"})]}),e.jsx("div",{className:"mb-4 p-3 bg-gray-50 dark:bg-zinc-800 rounded-md",children:e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Scheduled for:"," ",e.jsxs("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:[Ct(V)," at ",Z]})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("button",{onClick:()=>J(!1),className:"flex-1 px-3 py-2 text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 border border-gray-300 dark:border-gray-600 rounded-md transition-colors",children:"Cancel"}),e.jsx("button",{onClick:It,className:"flex-1 px-3 py-2 bg-cyan-500 hover:bg-cyan-600 text-white font-medium rounded-md transition-colors",children:"Schedule"})]})]})]})]})]}),e.jsx(he,{isOpen:Ne,onClose:()=>{te(!1),re("")},title:s("Insert Link"),onSubmit:ut,submitText:s("Insert Link"),showSubmit:!0,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("URL")}),e.jsx("input",{type:"url",value:W,onChange:t=>re(t.target.value),placeholder:s("https://example.com"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-zinc-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-cyan-500 focus:border-transparent"})]}),W&&e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-zinc-800 rounded-md",children:[e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-1",children:[s("Preview"),":"]}),e.jsx("p",{className:"text-sm text-blue-600 dark:text-blue-400",children:W})]})]})}),e.jsx(he,{isOpen:Pe,onClose:()=>{_(!1),ne(""),ie(""),q(!1)},title:s("Save Template"),onSubmit:Lt,submitText:s("Save Template"),showSubmit:!0,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("Template Name")}),e.jsx("input",{type:"text",value:fe,onChange:t=>ne(t.target.value),placeholder:s("Enter template name"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-zinc-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-cyan-500 focus:border-transparent"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[s("Description")," (",s("Optional"),")"]}),e.jsx("textarea",{value:ve,onChange:t=>ie(t.target.value),placeholder:s("Describe what this template is for"),rows:3,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-zinc-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-cyan-500 focus:border-transparent resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Select Platform"}),e.jsxs(ot,{value:Be,onValueChange:t=>ct(t),children:[e.jsx(lt,{className:"w-full min-w-[180px] bg-gray-50 border-gray-200 dark:bg-zinc-800 dark:border-none dark:text-neutral-200",children:e.jsx(nt,{placeholder:"Choose a platform"})}),e.jsx(it,{children:n.map(t=>e.jsx(dt,{value:t.id,children:t.name},t.id))})]})]})]})}),e.jsx(he,{isOpen:r,onClose:()=>{w(!1),p("")},title:s("Add Hashtag"),onSubmit:Ke,submitText:s("Add Custom Hashtag"),showSubmit:x.trim().length>0,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("Popular Hashtags")}),e.jsx("div",{className:"grid grid-cols-3 gap-2 max-h-48 overflow-y-auto",children:mt.map(t=>e.jsx("button",{onClick:()=>yt(t),className:"px-3 py-2 text-sm bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg transition-colors text-left",children:t},t))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("Custom Hashtag")}),e.jsx("input",{type:"text",value:x,onChange:t=>p(t.target.value),placeholder:s("Enter custom hashtag"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-zinc-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-cyan-500 focus:border-transparent",onKeyPress:t=>{t.key==="Enter"&&Ke()}}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:s("Don't include the # symbol - it will be added automatically")})]}),x&&e.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-zinc-800 rounded-md",children:[e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-1",children:[s("Preview"),":"]}),e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:x.startsWith("#")?x:`#${x}`})]})]})}),e.jsx(pr,{isOpen:ke,onClose:()=>de(!1),onApply:Et,t:s,ai_modules:F,platforms:n,templates:i}),e.jsx(yr,{isOpen:Le,onClose:()=>je(!1),onApply:Nt,t:s,media:U}),e.jsx(br,{isOpen:Me,onClose:()=>ee(!1),onApply:Ht,t:s,templates:k,platforms:n}),e.jsx(fr,{isOpen:we,onClose:()=>ce(!1),t:s})]})}export{$r as C};
