1import{r as l,j as e,S as C,d as _,A as F,h as E}from"./app-vjiAmbD7.js";import{D as R}from"./dashboardLayout-C5e_Sh5d.js";import{C as S}from"./calendar.esm-Cz8YBDGo.js";import{C as L}from"./chips.esm-CgE0xOSL.js";import{F as U}from"./fileupload.esm-DKCezSU2.js";import{T as O}from"./tiptap-B3K1uHn5.js";import{C as v}from"./checkbox.esm-Ct0pw4k8.js";import{u as D}from"./queries-DzkT-wXg.js";import{T as A}from"./toast.esm-CDzm59SD.js";import{f as I}from"./formatRussianDate-6aHWsuE9.js";import"./ScrollToTopButton--FoKvnl3.js";import"./useAuth-k1BkeSQG.js";import"./logo-BO4ZkFZy.js";/* empty css */import"./roles.types-CcPEwc3b.js";import"./index.esm-Bq3QXLRZ.js";import"./index.esm-xdUromFW.js";import"./overlayservice.esm-DDj4nrlw.js";import"./inputtext.esm-CzYhL0nZ.js";import"./keyfilter.esm-BaTlbvln.js";import"./csstransition.esm-pa3sXKLA.js";import"./setPrototypeOf-SZTCiYDs.js";import"./index.esm-jNN1BPik.js";import"./index.esm-DB_vBYbq.js";import"./index.esm-CTJTJ3r3.js";import"./index.esm-BjQWSvAl.js";import"./index.esm-rfespoh0.js";import"./TransitionGroup-BAy4Mf9_.js";import"./assertThisInitialized-B9jnkVVz.js";import"./react-select.esm-ToJ0n-Cb.js";import"./floating-ui.dom-bOIXkmBX.js";function be(){const[s,n]=l.useState({title:"",description:"",seo_description:"",is_published:!1,is_important:!1,publication_at:null,seo_keywords:[],image_file:null}),[a,b]=l.useState(null),x=l.useRef(null),[j,N]=l.useState(),h=D(),f=l.useRef(null),[i,c]=l.useState({});l.useEffect(()=>()=>{a&&URL.revokeObjectURL(a)},[a]);const p=r=>{c(t=>{if(!t[r])return t;const o={...t};return delete o[r],o})},m=r=>{const{name:t,value:o,type:d,checked:u}=r.target;n(g=>({...g,[t]:d==="checkbox"?u:o})),p(t)},k=r=>{const t=r.files[0];if(a&&(URL.revokeObjectURL(a),b(null)),t){const o=URL.createObjectURL(t);b(o),n(d=>({...d,image_file:t}))}else n(o=>({...o,image_file:null}));p("image_file")},y=()=>{a&&(URL.revokeObjectURL(a),b(null)),n(r=>({...r,image_file:null})),x.current&&x.current.clear(),p("image_file")},w=async r=>{var u;r.preventDefault(),c({});const t={};(u=s.description)!=null&&u.trim()||(t.description="ÐаполниÑе опиÑание");let o=null;if(s.publication_at?o=I(s.publication_at):t.publication_at="ÐаполниÑе даÑÑ Ð¿ÑбликаÑии",Object.keys(t).length>0){c(t);return}const d={title:s.title,description:s.description,content:j,image_file:s.image_file,is_published:s.is_published?1:0,is_important:s.is_important?1:0,publication_at:o,seo_description:s.seo_description,seo_keyword:s.seo_keywords.join(", ")};try{await h.mutateAsync({body:d}),f.current.show({severity:"success",summary:"УÑпеÑ
",detail:"ÐеÑопÑиÑÑие ÑÑпеÑно Ñоздано!",life:3e3}),F.visit("/dashboard/events")}catch(g){E(g,c)||f.current.show({severity:"error",summary:"ÐÑибка",detail:"ÐÑибка пÑи Ñоздании меÑопÑиÑÑиÑ",life:3e3})}};return e.jsxs(R,{children:[e.jsx(C,{children:e.jsx("title",{children:"Ðовое меÑопÑиÑÑие"})}),e.jsx(A,{ref:f}),e.jsxs("form",{onSubmit:w,className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h2",{className:"font-medium text-lg text-gray-800",children:"Ðовое меÑопÑиÑÑие"}),e.jsx("button",{type:"submit",disabled:h.isPending,className:"px-5 py-2 bg-orange-500 hover:bg-orange-600 text-white text-sm font-medium rounded-md shadow transition-colors disabled:bg-orange-300",children:h.isPending?"Создание...":"СоздаÑÑ Ð¼ÐµÑопÑиÑÑие"})]}),e.jsxs("div",{className:"grid grid-cols- md:grid-cols-2 gap-6 mb-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"title",className:"block text-sm text-gray-700 mb-2 font-medium",children:"Ðаголовок *"}),e.jsx("input",{type:"text",id:"title",name:"title",value:s.title,onChange:m,className:`w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-orange-300 focus:border-transparent text-sm ${_(!!i.title)}`,placeholder:"ÐведиÑе заголовок меÑопÑиÑÑиÑ",required:!0}),i.title&&e.jsx("small",{className:"text-red-500 mt-1 block",children:i.title})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"description",className:"block text-sm text-gray-700 mb-2 font-medium",children:"ÐпиÑание *"}),e.jsx("textarea",{id:"description",name:"description",value:s.description,onChange:m,rows:4,className:`w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-orange-300 focus:border-transparent text-sm ${_(!!i.description)}`,placeholder:"ÐодÑобное опиÑание меÑопÑиÑÑиÑ"}),i.description&&e.jsx("small",{className:"text-red-500 mt-1 block",children:i.description})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"seo_description",className:"block text-sm text-gray-700 mb-2 font-medium",children:"SEO ÐпиÑание"}
1),e.jsx("textarea",{id:"seo_description",name:"seo_description",value:s.seo_description,onChange:m,rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-orange-300 focus:border-transparent text-sm",placeholder:"ÐпиÑание Ð´Ð»Ñ Ð¿Ð¾Ð¸ÑковÑÑ ÑиÑÑем"})]})]}),e.jsx("div",{children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mb-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"publication_at",className:"block text-sm text-gray-700 mb-2 font-medium",children:"ÐаÑа пÑбликаÑии"}),e.jsx(S,{id:"publication_at",name:"publication_at",value:s.publication_at,onChange:r=>{n(t=>({...t,publication_at:r.value})),p("publication_at")},dateFormat:"dd.mm.yy",placeholder:"ÐведиÑе даÑÑ Ð¿ÑбликаÑии",className:"[&_.p-datepicker]:text-sm [&_.p-calendar]:w-full",inputClassName:`w-full px-3 py-2 border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-orange-300 focus:border-transparent ${_(!!i.publication_at)}`}),i.publication_at&&e.jsx("small",{className:"text-red-500 mt-1 block",children:i.publication_at})]}),a&&e.jsxs("div",{className:"mb-4 relative inline-block",children:[e.jsx("img",{src:a,alt:"ÐÑедпÑоÑмоÑÑ",className:"max-w-full h-auto rounded-md border border-gray-200 max-h-40"}),e.jsx("button",{type:"button",onClick:y,className:`absolute top-2 right-2 bg-red-500 text-white rounded-full 2 w-6 h-6 flex items-center justify-center shadow-md hover:bg-red-600`,"aria-label":"УдалиÑÑ Ð¸Ð·Ð¾Ð±Ñажение",children:"Ã"})]}),e.jsx("label",{className:"block text-sm text-gray-700 mb-2 font-medium",children:"ÐзобÑажение меÑопÑиÑÑиÑ"}),e.jsx(U,{ref:x,name:"image_file",mode:"basic",accept:"image/*",maxFileSize:2e6,onSelect:k,onClear:y,onValidationFail:()=>{c(r=>({...r,image_file:"Файл ÑлиÑком болÑÑой. ÐакÑималÑнÑй ÑÐ°Ð·Ð¼ÐµÑ â 2 ÐÐ"}))},chooseLabel:"ÐÑбÑаÑÑ Ñайл",className:"[&_.p-button]:text-sm [&_.p-button]:px-4 [&_.p-button]:py-2 [&_.p-button]:bg-orange-500 [&_.p-button]:border-orange-500 [&_.p-button]:hover:bg-orange-600"}),i.image_file&&e.jsx("small",{className:"text-red-500 mt-1 block",children:i.image_file}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"РекомендÑемÑй ÑазмеÑ: 1280Ã720 пикÑелей (16:9)"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"seo_keywords",className:"block text-sm text-gray-700 mb-2 font-medium",children:"SEO ÐлÑÑевÑе Ñлова"}),e.jsx(L,{id:"seo_keywords",name:"seo_keywords",value:s.seo_keywords,onChange:r=>n(t=>({...t,seo_keywords:r.value})),placeholder:"ÐведиÑе клÑÑевÑе Ñлова",className:"w-full [&_.p-chips]:w-full [&_.p-inputtext]:text-sm [&_.p-inputtext]:border [&_.p-inputtext]:ps-2 [&_.p-inputtext]:py-1 [&_.p-chips-token]:text-xs",inputClassName:"px-3 py-1 text-sm border border-gray-300 rounded-md"})]}),e.jsxs("div",{className:"flex items-center mb-3",children:[e.jsx(v,{inputId:"is_published",name:"is_published",onChange:m,checked:s.is_published,className:"[&_.p-checkbox-box]:border [&_.p-checkbox-box]:border-gray-300"}),e.jsx("label",{htmlFor:"is_published",className:"ml-2 text-sm text-gray-700",children:"ÐпÑбликовано"})]}),e.jsxs("div",{className:"flex items-center",children:[e.jsx(v,{inputId:"is_important",name:"is_important",onChange:m,checked:s.is_important,className:"[&_.p-checkbox-box]:border [&_.p-checkbox-box]:border-gray-300"}),e.jsx("label",{htmlFor:"is_important",className:"ml-2 text-sm text-gray-700",children:"Ðажное меÑопÑиÑÑие"})]})]})]})})]}),e.jsxs("div",{className:"container",children:[e.jsx("label",{htmlFor:"description",className:"block text-sm text-gray-700 mb-2 font-medium",children:"ÐонÑенÑ"}),e.jsx(O,{onChange:N,initialContent:j})]})]})]})}export{be 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.