1import{c as ys,t as Ie,r as i,j as e,y as m,B as A,m as ne,I as $,s as y,w as te,K as ie,N as re,x as ae,a8 as Ns,a9 as ks,aa as ws,ab as zs,ac as Cs,ad as Ss,ae as qs,af as As,E as Ts,a as Ds,o as Ps,M as Es,T as Xe,X as Os}from"./index-MoAbC8_9.js";import{A as Ye}from"./AdminPageLayout-DL0avA2R.js";import{T as ce}from"./textarea-4z16PwID.js";import{S as je}from"./switch-BHj3-8MN.js";import{S as de,a as me,b as ue,c as pe,d as _}from"./select-ChAxOmxm.js";import{T as Ve,a as $e,c as J,b as oe}from"./tabs-5EVsfllK.js";import{R as Vs,a as Be}from"./radio-group-BtSPrM_8.js";import{A as $s,a as Fs}from"./alert-B1M6s1_G.js";import{P as Ls}from"./PollEmailHistory-CWoBpO6Y.js";import{B as Ae}from"./badge-BHbYeRgi.js";import{l as qe,j as Fe,f as es,d as Me,h as Is,i as Rs}from"./exportPollFaqDocx-6VkwoY8h.js";import{D as Us,a as Zs,b as Bs,c as Ms,e as Hs}from"./dialog-DrI7Oddz.js";import{L as ts}from"./languages-DJ80weRR.js";import{E as Ks}from"./eye-DKrvAixa.js";import{S as as}from"./save-DWdLHugL.js";import{C as Gs}from"./checkbox-D2A7tWS7.js";import{A as Qs,a as Ws,b as Js,c as Xs}from"./accordion-CatLYK39.js";import{L as Ys}from"./lock-BEcuk4Jx.js";import{P as et}from"./paperclip-I8ctU5eK.js";import{T as Le}from"./trash-2-DRJ_nWSl.js";import{U as ns}from"./upload-BH1HltYO.js";import{F as st}from"./file-down-D9u4xV4V.js";import{P as ls}from"./plus-CkJQv7GY.js";import{S as tt}from"./search-_fcwEKN-.js";import{A as at,a as nt}from"./arrow-up-D486G_0n.js";import{E as lt}from"./eye-off-D1RUMkPr.js";import{P as it}from"./pencil-C_0Cp3wi.js";import{d as rt}from"./pollDates-DP2VfLei.js";import{C as ot}from"./chart-column-Bo5i9GGE.js";import{C as ct}from"./circle-help-BFmb_2uk.js";import{S as dt}from"./scale-CfsuUh1a.js";import{F as mt}from"./file-text-Bif0RP8Y.js";import"./Layout-jB2m3rBw.js";import"./Header-CnJGZ8vQ.js";import"./mountain-BHfTfCFy.js";import"./user-Cvsz7Lm_.js";import"./collapsible-BIxz44zB.js";import"./breadcrumb-CmKLwRya.js";import"./AdminSidebar-B1OFksO6.js";import"./scroll-area-CoT3wSM0.js";import"./index-BdQq_4o_.js";import"./bell-CKHJStUz.js";import"./clipboard-list-CzdQdj9P.js";import"./users-xui-UtA1.js";import"./building-crte1H4H.js";import"./calculator-GhS8BFwe.js";import"./wallet-e9E2tgeo.js";import"./calendar-CnsXUgOr.js";import"./trending-up-Cg9WFJWB.js";import"./trending-down-EHPUNHPt.js";import"./settings-BUFFH3UG.js";import"./database-yc2noHJi.js";import"./file-search-B2CpYcS_.js";import"./chevron-down-BDe4YKQW.js";import"./house-DjS1WMqx.js";import"./index-D9-GACGG.js";import"./chevron-up-JyGCcpt9.js";import"./format-Beid_ZIk.js";import"./en-US-CQ3IMwMG.js";import"./endOfMonth-D_4h-ZFk.js";import"./chevron-left-BrISfdwW.js";import"./popover-BsQ559UC.js";import"./table-BNHSYido.js";import"./circle-check-7w5_oQMu.js";import"./index-BRuSZtGQ.js";import"./FileSaver.min-CENiJ7oA.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const ut=ys("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]),ss=()=>({question_cs:"",question_de:"",question_en:"",answer_cs:"",answer_de:"",answer_en:"",asked_by:"",asked_by_de:"",asked_by_en:"",asked_on:"",question_source:"",answer_source:"",status:"pending",is_published:!1}),pt=({pollId:p,item:f,open:g,onOpenChange:b,onSaved:z,nextSortOrder:he})=>{const{toast:U}=Ie(),[o,B]=i.useState(ss()),[D,P]=i.useState(!1),[k,F]=i.useState(!1),[w,E]=i.useState("cs"),[h,L]=i.useState("de");i.useEffect(()=>{g&&B(f?{question_cs:f.question_cs||"",question_de:f.question_de||"",question_en:f.question_en||"",answer_
6cs:f.answer_cs||"",answer_de:f.answer_de||"",answer_en:f.answer_en||"",asked_by:f.asked_by||"",asked_by_de:f.asked_by_de||"",asked_by_en:f.asked_by_en||"",asked_on:f.asked_on||"",question_source:f.question_source||"",answer_source:f.answer_source||"",status:f.status,is_published:f.is_published}:ss())},[f,g]);const C=(s,n)=>B(a=>({...a,[s]:n})),Y=async()=>{const s=o[`question_${w}`],n=o[`answer_${w}`];if(!s.trim()){U({variant:"destructive",title:"Nejprve vyplÅte otázku ve zdrojovém jazyce"});return}F(!0);try{const{data:a,error:S}=await y.functions.invoke("translate-poll",{body:{mode:"faq",source_language:w,question:s,answer:n}});if(S)throw S;const j=(a==null?void 0:a.translations)||{};B(d=>{const V={...d};return["cs","de","en"].forEach(O=>{O!==w&&(j[`question_${O}`]&&(V[`question_${O}`]=j[`question_${O}`]),j[`answer_${O}`]&&(V[`answer_${O}`]=j[`answer_${O}`]))}),V}),U({title:"PÅeloženo",description:"Texty zůstávajà plnÄ editovatelné."})}catch(a){U({variant:"destructive",title:"PÅeklad selhal",description:a instanceof Error?a.message:void 0})}finally{F(!1)}},I=async()=>{P(!0);const s={poll_id:p,question_cs:o.question_cs||null,question_de:o.question_de||null,question_en:o.question_en||null,answer_cs:o.answer_cs||null,answer_de:o.answer_de||null,answer_en:o.answer_en||null,asked_by:o.asked_by||null,asked_by_de:o.asked_by_de||null,asked_by_en:o.asked_by_en||null,asked_on:o.asked_on||null,question_source:o.question_source||null,answer_source:o.answer_source||null,status:o.status,is_published:o.is_published},{error:n}=f?await y.from("poll_faq_items").update(s).eq("id",f.id):await y.from("poll_faq_items").insert({...s,sort_order:he});if(P(!1),n){U({variant:"destructive",title:"Uloženà selhalo",description:n.message});return}U({title:f?"Dotaz upraven":"Dotaz pÅidán"}),b(!1),z()},X={...o};return e.jsx(Us,{open:g,onOpenChange:b,children:e.jsxs(Zs,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Bs,{children:e.jsx(Ms,{children:f?"Upravit dotaz":"Nový dotaz"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(m,{className:"text-xs",children:"Zdrojový jazyk"}),e.jsxs(de,{value:w,onValueChange:s=>E(s),children:[e.jsx(me,{className:"w-32 h-9",children:e.jsx(ue,{})}),e.jsxs(pe,{children:[e.jsx(_,{value:"cs",children:"ÄeÅ¡tina"}),e.jsx(_,{value:"de",children:"NÄmÄina"}),e.jsx(_,{value:"en",children:"AngliÄtina"})]})]})]}),e.jsxs(A,{variant:"outline",size:"sm",className:"gap-1.5",onClick:Y,disabled:k,children:[k?e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ts,{className:"h-3.5 w-3.5"}),"PÅeložit"]})]}),e.jsxs(Ve,{defaultValue:"cs",children:[e.jsxs($e,{className:"grid w-full max-w-sm grid-cols-3 h-9",children:[e.jsx(J,{value:"cs",children:"CS"}),e.jsx(J,{value:"de",children:"DE"}),e.jsx(J,{value:"en",children:"EN"})]}),["cs","de","en"].map(s=>e.jsxs(oe,{value:s,className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(m,{className:"text-xs",children:["Otázka (",s.toUpperCase(),")"]}),e.jsx(ce,{rows:2,value:o[`question_${s}`],onChange:n=>C(`question_${s}`,n.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(m,{className:"text-xs",children:["OdpovÄÄ (",s.toUpperCase(),")"]}),e.jsx(ce,{rows:7,value:o[`answer_${s}`],onChange:n=>C(`answer_${s}`,n.target.value)})]})]},s))]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(m,{className:"text-xs",children:"Tazatel (CZ)"}),e.jsx($,{value:o.asked_by,onChange:s=>C("asked_by",s.target.value),className:"h-9"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(m,{className:"text-xs",children:"Tazatel (DE)"}),e.jsx($,{value:o.asked_by_de,onChange:s=>C("asked_by_de",s.target.value),className:"h-9"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(m,{className:"text-xs",children:"Tazatel (EN)"}),e.jsx($,{value:o.asked_by_en,onChange:s=>C("asked_by_en",s.target.value),className:"h-9"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(m,{className:"text-xs",children:"Datum dotazu"}),e.jsx($,{type:"date",value:o.asked_on,onChange:s=>C("asked_on",s.target.value),className:"h-9"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(m,{className:"text-xs",children:"Zdroj dotazu (internÃ, nezobrazuje se vlastnÃkům)"}
6),e.jsx($,{value:o.question_source,onChange:s=>C("question_source",s.target.value),placeholder:"E-mail / Eigentümerforum / telefonicky",className:"h-9"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(m,{className:"text-xs",children:"Zdroj informace (veÅejný)"}),e.jsx($,{value:o.answer_source,onChange:s=>C("answer_source",s.target.value),placeholder:"E-mail Hausverwaltung z 18. 8. 2026",className:"h-9"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(m,{className:"text-xs",children:"Stav"}),e.jsxs(de,{value:o.status,onValueChange:s=>C("status",s),children:[e.jsx(me,{className:"h-9",children:e.jsx(ue,{})}),e.jsxs(pe,{children:[e.jsx(_,{value:"answered",children:qe("cs","answered")}),e.jsx(_,{value:"pending",children:qe("cs","pending")}),e.jsx(_,{value:"clarification",children:qe("cs","clarification")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[e.jsx(je,{checked:o.is_published,onCheckedChange:s=>C("is_published",s)}),e.jsx(m,{className:"text-sm",children:"ZveÅejnit vlastnÃkům"})]})]}),e.jsxs("div",{className:"rounded-md border border-border/60 bg-muted/30 p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[e.jsx(Ks,{className:"h-3.5 w-3.5"})," Náhled oÄima vlastnÃka"]}),e.jsxs(de,{value:h,onValueChange:s=>L(s),children:[e.jsx(me,{className:"w-24 h-8 text-xs",children:e.jsx(ue,{})}),e.jsxs(pe,{children:[e.jsx(_,{value:"cs",children:"CS"}),e.jsx(_,{value:"de",children:"DE"}),e.jsx(_,{value:"en",children:"EN"})]})]})]}),e.jsx("p",{className:"text-sm font-medium",children:Fe(X,"question",h)||"â"}),e.jsx("p",{className:"text-sm whitespace-pre-line",children:Fe(X,"answer",h)||"â"}),e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[(h==="de"?o.asked_by_de||o.asked_by:h==="en"&&o.asked_by_en||o.asked_by)&&`${es(h,"askedBy")}: ${h==="de"?o.asked_by_de||o.asked_by:h==="en"&&o.asked_by_en||o.asked_by} `,o.answer_source&&`· ${es(h,"answerSource")}: ${o.answer_source} `,"· ",qe(h,o.status)]})]})]}),e.jsxs(Hs,{children:[e.jsx(A,{variant:"outline",onClick:()=>b(!1),children:"ZruÅ¡it"}),e.jsxs(A,{onClick:I,disabled:D,className:"gap-1.5",children:[D?e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(as,{className:"h-3.5 w-3.5"}),"Uložit"]})]})]})})},ht=p=>p==="resolved"?"bg-emerald-100 text-emerald-800":p==="rejected"?"bg-rose-100 text-rose-800":"bg-amber-100 text-amber-900",xt=p=>p==="resolved"?"VyÅÃzeno":p==="rejected"?"NepÅijato":"Ke zpracovánÃ",He=p=>p?new Date(p).toLocaleString("cs-CZ",{timeZone:"Europe/Vienna"}):"â",vt=({pollId:p,onFaqChanged:f})=>{const{toast:g}=Ie(),[b,z]=i.useState([]),[he,U]=i.useState(!0),[o,B]=i.useState({}),[D,P]=i.useState(null),[k,F]=i.useState({}),w=i.useCallback(async()=>{U(!0);const{data:s,error:n}=await y.rpc("admin_get_poll_faq_objections",{p_poll_id:p});if(U(!1),n){g({variant:"destructive",title:"NaÄtenà námitek selhalo",description:n.message});return}const a=s||[];
6z(a),B(S=>{const j={...S};return a.forEach(d=>{j[d.id]||(j[d.id]={status:d.status,resolutionType:d.resolution_type||"",internalNote:d.admin_internal_note||"",rejectionReason:d.rejection_reason_public||"",publish:d.is_published,publicText:d.public_text??d.objection_text,publicResponse:d.public_response||""})}),j})},[p,g]);i.useEffect(()=>{w()},[w]);const E=(s,n)=>B(a=>({...a,[s]:{...a[s],...n}})),h=async s=>{const{data:n,error:a}=await y.storage.from(Me).createSignedUrl(s,300);if(a||!(n!=null&&n.signedUrl)){g({variant:"destructive",title:"Soubor se nepodaÅilo otevÅÃt",description:a==null?void 0:a.message});return}window.open(n.signedUrl,"_blank","noopener,noreferrer")},L=async s=>{const n=o[s.id];if(!n)return;P(s.id);const{error:a}=await y.rpc("admin_resolve_poll_faq_objection",{p_objection_id:s.id,p_status:n.status,p_resolution_type:n.resolutionType||null,p_admin_internal_note:n.internalNote||null,p_rejection_reason_public:n.rejectionReason||null,p_related_faq_item_id:s.related_faq_item_id,p_publish:n.publish&&n.status==="resolved",p_public_text:n.publicText||null,p_public_response:n.publicResponse||null});if(P(null),a){g({variant:"destructive",title:"Uloženà se nezdaÅilo",description:a.message});return}g({title:"Námitka uložena"}),w()},C=async s=>{P(s.id);const{error:n}=await y.rpc("admin_set_objection_attachments_unlocked",{p_objection_id:s.id,p_unlocked:!s.attachments_unlocked});if(P(null),n){g({variant:"destructive",title:"ZmÄna se nezdaÅila",description:n.message});return}w()},Y=async s=>{P(s.id);const{data:n}=await y.from("poll_faq_items").select("sort_order").eq("poll_id",p).order("sort_order",{ascending:!1}).limit(1),a=n!=null&&n.length?(n[0].sort_order??0)+1:0,{data:S,error:j}=await y.from("poll_faq_items").insert({poll_id:p,question_cs:s.objection_text.slice(0,500),status:"pending",sort_order:a,is_published:!1,question_source:"VÄcná námitka vlastnÃka"}).select("id").single();if(j||!S){P(null),g({variant:"destructive",title:"VytvoÅenà dotazu selhalo",description:j==null?void 0:j.message});return}const d=o[s.id],{error:V}=await y.rpc("admin_resolve_poll_faq_objection",{p_objection_id:s.id,p_status:"resolved",p_resolution_type:"new_faq_created",p_admin_internal_note:(d==null?void 0:d.internalNote)||null,p_rejection_reason_public:null,p_related_faq_item_id:S.id,p_publish:(d==null?void 0:d.publish)??!1,p_public_text:(d==null?void 0:d.publicText)||s.objection_text,p_public_response:(d==null?void 0:d.publicResponse)||null});if(P(null),V){g({variant:"destructive",title:"Propojenà selhalo",description:V.message});return}g({title:"VytvoÅen nový (nezveÅejnÄný) dotaz",description:"DoplÅte znÄnà a pÅeklady v záložce Dotazy."}),f(),w()},I=async(s,n)=>{var S;const a=(k[s.id]||n.name).trim();P(s.id);try{const j=((S=n.name.split(".").pop())==null?void 0:S.toLowerCase())||"bin",d=`public/${s.id}/${crypto.randomUUID()}.${j}`,{error:V}=await y.storage.from(Me).upload(d,n,{upsert:!1,contentType:n.type||void 0});if(V)throw V;const{error:O}=await y.rpc("admin_publish_objection_attachment",{p_objection_id:s.id,p_public_display_name:a,p_public_storage_path:d,p_source_attachment_id:null});if(O)throw O;F(M=>({...M,[s.id]:""})),g({title:"VeÅejná pÅÃloha pÅidána"}),w()}catch(j){g({variant:"destructive",title:"ZveÅejnÄnà pÅÃlohy selhalo",description:j instanceof Error?j.message:String(j)})}finally{P(null)}},X=async s=>{const{data:n,error:a}=await y.rpc("admin_unpublish_objection_attachment",{p_id:s});if(a){g({variant:"destructive",title:"Odebránà selhalo",description:a.message});return}n&&await y.storage.from(Me).remove([n]),w()};return he?e.jsxs("div",{className:"flex items-center gap-2 py-6 text-sm text-muted-foreground",children:[e.jsx(ne,{className:"h-4 w-4 animate-spin"}),"NaÄÃtámâ¦"]}):b.length?e.jsx(Qs,{type:"single",collapsible:!0,className:"w-full",children:b.map(s=>{const n=o[s.id];return e.jsxs(Ws,{value:s.id,children:[e.jsx(Js,{className:"text-left hover:no-underline",children:e.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-2 pr-2",children:[e.jsx(Ae,{variant:"secondary",className:`text-[10px] ${ht(s.status)}`,children:xt(s.status)}),s.is_published&&e.jsx(Ae,{variant:"outline",className:"text-[10px]",children:"ZveÅejnÄno"}),e.jsxs("span",{className:"truncate text-sm font-medium",children:[s.author_name||"â"," · ",s.faq_question_cs||s.faq_question_de||"â"]}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:He(s.submitted_at)})]})}),e.jsxs(Xs,{className:"space-y-3 pt-1",children:[e.jsxs("div",{className:"rounded-md bg-muted/40 p-3 text-xs text-muted-foreground",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold",children:"Autor:"})," ",s.author_name||"â"," (",s.author_email||"â",")"]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold",children:"Podáno:"})," ",He(s.submitted_at)]}),s.resolved_at&&e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold",children:"VyÅÃzeno:"})," ",He(s.resolved_at)]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold",children:"Původnà text námitky"}),e.jsx("p",{className:"mt-1 whitespace-pre-line rounded-md border border-border p-3 text-sm",children:s.objection_text})]}),s.supporting_basis&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold",children:"Podklady a zdroje"}),e.jsx("p",{className:"mt-1 whitespace-pre-line rounded-md border border-border p-3 text-sm",children:s.supporting_basis})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-xs font-semibold",children:"PÅÃlohy autora (neveÅejné)"}),e.jsxs(A,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-xs",disabled:D===s.id,onClick:()=>void C(s),children:[s.attachments_unlocked?e.jsx(Ys,{className:"h-3 w-3"}):e.jsx(ut,{className:"h-3 w-3"}),s.attachments_unlocked?"Uzamknout doplÅovánÃ":"Povolit doplnÄnà pÅÃloh"]})]}),s.attachments.length?e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.attachments.map(a=>e.jsxs(A,{variant:"outline",size:"sm",className:"h-7 gap-1.5 text-xs",onClick:()=>void h(a.storage_path),children:[e.jsx(et,{className:"h-3 w-3"}),a.original_filename]},a.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Bez pÅÃloh."})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{className:"text-xs",children:"Stav"}),e.jsxs(de,{value:n==null?void 0:n.status,onValueChange:a=>E(s.id,{status:a}),children:[e.jsx(me,{className:"h-9",children:e.jsx(ue,{})}),e.jsxs(pe,{children:[e.jsx(_,{value:"pending",children:"Ke zpracovánÃ"}),e.jsx(_,{value:"resolved",children:"VyÅÃzeno"}),e.jsx(_,{value:"rejected",children:"NepÅijato"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{className:"text-xs",children:"Způsob vyÅÃzenÃ"}),e.jsxs(de,{value:(n==null?void 0:n.resolutionType)||"none",onValueChange:a=>E(s.id,{resolutionType:a==="none"?"":a}),children:[e.jsx(me,{className:"h-9",children:e.jsx(ue,{})}),e.jsxs(pe,{children:[e.jsx(_,{value:"none",children:"â"}),e.jsx(_,{value:"answered",children:"ZodpovÄzeno bez zmÄny FAQ"}
6),e.jsx(_,{value:"faq_updated",children:"OdpovÄÄ FAQ upravena"}),e.jsx(_,{value:"new_faq_created",children:"PÅevedeno na nový dotaz"}),e.jsx(_,{value:"rejected",children:"NepÅijato"})]})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{className:"text-xs",children:"Internà poznámka (nikdy se nezveÅejÅuje)"}),e.jsx(ce,{rows:2,value:(n==null?void 0:n.internalNote)||"",onChange:a=>E(s.id,{internalNote:a.target.value})})]}),(n==null?void 0:n.status)==="rejected"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{className:"text-xs",children:"Důvod nepÅijetà (vidà pouze autor)"}),e.jsx(ce,{rows:2,value:(n==null?void 0:n.rejectionReason)||"",onChange:a=>E(s.id,{rejectionReason:a.target.value})})]}),e.jsxs("div",{className:"rounded-md border border-border p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Gs,{id:`publish-${s.id}`,checked:(n==null?void 0:n.publish)||!1,disabled:(n==null?void 0:n.status)!=="resolved",onCheckedChange:a=>E(s.id,{publish:a===!0})}),e.jsx(m,{htmlFor:`publish-${s.id}`,className:"text-xs",children:"ZveÅejnit ve veÅejné historii (jen u vyÅÃzených, bez identity autora)"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{className:"text-xs",children:"VeÅejné znÄnà námitky"}),e.jsx(ce,{rows:4,value:(n==null?void 0:n.publicText)||"",onChange:a=>E(s.id,{publicText:a.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{className:"text-xs",children:"VeÅejná reakce správy"}),e.jsx(ce,{rows:3,value:(n==null?void 0:n.publicResponse)||"",onChange:a=>E(s.id,{publicResponse:a.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{className:"text-xs",children:"VeÅejné pÅÃlohy (samostatnÄ nahrané sanitizované soubory)"}),s.public_attachments.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.public_attachments.map(a=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs",children:[e.jsx("button",{type:"button",className:"underline-offset-2 hover:underline",onClick:()=>void h(a.path),children:a.name}),e.jsx("button",{type:"button",className:"text-destructive",onClick:()=>void X(a.id),children:e.jsx(Le,{className:"h-3 w-3"})})]},a.id))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx($,{className:"h-8 max-w-xs text-xs",placeholder:"Zobrazovaný název veÅejné pÅÃlohy",value:k[s.id]||"",onChange:a=>F(S=>({...S,[s.id]:a.target.value}))}),e.jsxs("label",{className:"inline-flex cursor-pointer items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs",children:[e.jsx(ns,{className:"h-3 w-3"}),"Nahrát veÅejnou verzi",e.jsx("input",{type:"file",className:"hidden",onChange:a=>{var j;const S=(j=a.target.files)==null?void 0:j[0];a.target.value="",S&&I(s,S)}})]})]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(A,{size:"sm",disabled:D===s.id,onClick:()=>void L(s),children:[D===s.id&&e.jsx(ne,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Uložit"]}),e.jsx(A,{size:"sm",variant:"outline",disabled:D===s.id||!!s.related_faq_item_id,onClick:()=>void Y(s),children:"PÅevést na nový dotaz"})]})]})]},s.id)})}):e.jsx("p",{className:"py-6 text-sm text-muted-foreground",children:"ZatÃm nebyla podána žádná námitka."})},jt=({pollId:p,pollTitle:f})=>{const{toast:g}=Ie(),[b,z]=i.useState([]),[he,U]=i.useState(!0),[o,B]=i.useState(""),[D,P]=i.useState(""),[k,F]=i.useState(!1),[w,E]=i.useState(null),[h,L]=i.useState(null),[C,Y]=i.useState("de"),[I,X]=i.useState("published"),[s,n]=i.useState("items"),[a,S]=i.useState(0),j=i.useCallback(async()=>{const{data:r}=await y.rpc("admin_count_pending_faq_objections",{p_poll_id:p});S(Number(r??0))},[p]);i.useEffect(()=>{j()},[j,s]);const d=i.useCallback(async()=>{U(!0);const{data:r,error:q}=D?await y.rpc("admin_search_poll_faq",{p_poll_id:p,p_query:D}):await y.rpc("admin_get_poll_faq",{p_poll_id:p});if(U(!1),q){g({variant:"destructive",title:"NaÄtenà FAQ selhalo",description:q.message});return}z(r||[])},[p,D,g]);i.useEffect(()=>{const r=setTimeout(()=>P(o.trim()),250);return()=>clearTimeout(r)},[o]),i.useEffect(()=>{d()},[d]);const V=i.useMemo(()=>b.length?Math.max(...b.map(r=>r.sort_order))+1:0,[b]),O=async(r,q)=>{const se=[...b].sort((R,ke)=>R.sort_order-ke.sort_order),Ne=se.findIndex(R=>R.id===r.id),fe=se[Ne+q];fe&&(await Promise.all([y.from("poll_faq_items").update({sort_order:fe.sort_order}).eq("id",r.id),y.from("poll_faq_items").update({sort_order:r.sort_order}).eq("id",fe.id)]),d())},M=async r=>{const{error:q}=await y.from("poll_faq_items").update({is_published:!r.is_published}).eq("id",r.id);if(q){g({variant:"destructive",title:"ZmÄna se nezdaÅila",description:q.message});return}d()},ee=async()=>
6{if(!h)return;const{error:r}=await y.from("poll_faq_items").delete().eq("id",h);if(L(null),r){g({variant:"destructive",title:"Smazánà se nezdaÅilo",description:r.message});return}g({title:"Dotaz smazán"}),d()},ye=()=>{const r=I==="published"?b.filter(q=>q.is_published):b;if(!r.length){g({variant:"destructive",title:"Nenà co exportovat"});return}Rs({pollTitle:f,lang:C,items:[...r].sort((q,se)=>q.sort_order-se.sort_order),includeQuestionSource:I==="all"})};return e.jsxs(te,{children:[e.jsx(ie,{className:"pb-3",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx(re,{className:"text-base",children:"Äasté dotazy k hlasovánÃ"}),e.jsxs("div",{className:`flex flex-wrap items-center gap-2 ${s==="objections"?"hidden":""}`,children:[e.jsxs(de,{value:C,onValueChange:r=>Y(r),children:[e.jsx(me,{className:"h-9 w-24",children:e.jsx(ue,{})}),e.jsxs(pe,{children:[e.jsx(_,{value:"cs",children:"CS"}),e.jsx(_,{value:"de",children:"DE"}),e.jsx(_,{value:"en",children:"EN"})]})]}),e.jsxs(de,{value:I,onValueChange:r=>X(r),children:[e.jsx(me,{className:"h-9 w-40",children:e.jsx(ue,{})}),e.jsxs(pe,{children:[e.jsx(_,{value:"published",children:"Jen zveÅejnÄné"}),e.jsx(_,{value:"all",children:"VÅ¡e (i internÃ)"})]})]}),e.jsxs(A,{variant:"outline",size:"sm",className:"gap-1.5",onClick:ye,children:[e.jsx(st,{className:"h-3.5 w-3.5"}),"Word"]}),e.jsxs(A,{size:"sm",className:"gap-1.5",onClick:()=>{E(null),F(!0)},children:[e.jsx(ls,{className:"h-3.5 w-3.5"}),"PÅidat dotaz"]})]})]})}),e.jsx(ae,{className:"space-y-3",children:e.jsxs(Ve,{value:s,onValueChange:r=>n(r),children:[e.jsxs($e,{children:[e.jsx(J,{value:"items",children:"Dotazy"}),e.jsxs(J,{value:"objections",className:"gap-1.5",children:["Námitky",a>0&&e.jsx(Ae,{className:"h-5 min-w-5 justify-center bg-amber-500 px-1 text-[10px] text-white hover:bg-amber-500",children:a})]})]}),e.jsx(oe,{value:"objections",className:"mt-3",children:e.jsx(vt,{pollId:p,onFaqChanged:d})}),e.jsxs(oe,{value:"items",className:"mt-3 space-y-3",children:[e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(tt,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx($,{value:o,onChange:r=>B(r.target.value),placeholder:"Hledat (i v nezveÅejnÄných a ve zdroji dotazu)â¦",className:"pl-8 h-9"})]}),he?e.jsxs("div",{className:"flex items-center gap-2 py-6 text-sm text-muted-foreground",children:[e.jsx(ne,{className:"h-4 w-4 animate-spin"}),"NaÄÃtámâ¦"]}):b.length===0?e.jsx("p",{className:"py-6 text-sm text-muted-foreground",children:D?"Nebyly nalezeny žádné odpovÃdajÃcà dotazy.":"ZatÃm nebyl pÅidán žádný dotaz."}):e.jsx("div",{className:"divide-y divide-border rounded-md border border-border",children:[...b].sort((r,q)=>r.sort_order-q.sort_order).map((r,q,se)=>e.jsxs("div",{className:"flex items-start gap-3 p-3",children:[e.jsxs("div",{className:"flex flex-col gap-0.5 pt-0.5",children:[e.jsx(A,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:q===0||!!D,onClick:()=>O(r,-1),children:e.jsx(at,{className:"h-3.5 w-3.5"})}),e.jsx(A,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:q===se.length-1||!!D,onClick:()=>O(r,1),children:e.jsx(nt,{className:"h-3.5 w-3.5"})})]}),e.jsx("span",{className:"mt-1 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-semibold text-muted-foreground",children:q+1}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:Fe(r,"question","de")||"â"}),e.jsx("p",{className:"line-clamp-2 text-xs text-muted-foreground",children:Fe(r,"answer","de")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 pt-0.5 text-[11px] text-muted-foreground",children:[e.jsx(Ae,{variant:"secondary",className:"text-[10px]",children:qe("cs",r.status)}),!r.is_published&&e.jsxs(Ae,{variant:"outline",className:"gap-1 text-[10px]",children:[e.jsx(lt,{className:"h-3 w-3"}),"NezveÅejnÄno"]}),r.asked_by&&e.jsx("span",{children:r.asked_by}),r.asked_on&&e.jsx("span",{children:Is(r.asked_on,"cs")}),r.question_source&&e.jsxs("span",{children:["internà zdroj: ",r.question_source]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(A,{variant:"ghost",size:"sm",className:"h-8 text-xs",onClick:()=>M(r),children:r.is_published?"Skrýt":"ZveÅejnit"}),e.jsx(A,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{E(r),F(!0)},children:e.jsx(it,{className:"h-3.5 w-3.5"})}),e.jsx(A,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>L(r.id),children:e.jsx(Le,{className:"h-3.5 w-3.5"})})]})]},r.id))})]})]})}),e.jsx(pt,{pollId:p,item:w,open:k,onOpenChange:F,onSaved:d,nextSortOrder:V}),e.jsx(Ns,{open:!!h,onOpenChange:r=>!r&&L(null),children:e.jsxs(ks,{children:[e.jsxs(ws,{children:[e.jsx(zs,{children:"Smazat dotaz?"}),e.jsx(Cs,{children:"Tuto akci nelze vrátit zpÄt."})]}),e.jsxs(Ss,{children:[e.jsx(qs,{children:"ZruÅ¡it"}),e.jsx(As,{onClick:ee,children:"Smazat"})]})]})})]})},Aa=()=>{const{id:p}=Ts(),f=Ds(),{user:g}=Ps(),{toast:b}=Ie(),z=p==="new",[he,U]=i.useState(!z),[o,B]=i.useState(!1),[D,P]=i.useState(!1),[k,F]=i.useState(""),[w,E]=i.useState(""),[h,L]=i.useState(["",""]),[C,Y]=i.useState(""),[I,X]=i.useState(""),[s,n]=i.useState(!0),[a,S]=i.useState("cs"),[j,d]=i.useState(!1),[V,O]=i.useState(!1),[M,ee]=i.useState([]),[ye,r]=i.useState(!1),[q,se]=i.useState("automatic"),[Ne,fe]=i.useState("yes_no"),[R,ke]=i.useState("aggregate"),[we,Re]=i.useState(!0),[_e,Ue]=i.useState(!1),[Ke,Ge]=i.useState(!1),[ge,Te]=i.useState(""),[H,De]=i.useState(""),[K,Pe]=i.useState(""),[xe,Ee]=i.useState(""),[ve,Oe]=i.useState(""),[G,ze]=i.useState([]),[Q,Ce]=i.useState([]),Se=`poll-edit-draft-${p||"new"}`,[Qe,is]=i.useState(!1),[rs,We]=i.useState(!1);i.useEffect(()=>{!z&&p&&cs(p)}
6,[p]),i.useEffect(()=>{if(z)try{const l=localStorage.getItem(Se);if(l){const t=JSON.parse(l);t.title&&F(t.title),t.description&&E(t.description),Array.isArray(t.options)&&t.options.length>=2&&L(t.options),t.startsAt&&Y(t.startsAt),t.endsAt&&X(t.endsAt),typeof t.isActive=="boolean"&&n(t.isActive),t.sourceLanguage&&S(t.sourceLanguage),typeof t.allowMultiple=="boolean"&&d(t.allowMultiple),typeof t.allowComments=="boolean"&&O(t.allowComments),Array.isArray(t.attachments)?ee(t.attachments):t.attachmentUrl&&ee([{url:t.attachmentUrl,name:t.attachmentName||"PÅÃloha"}]),t.votingType&&se(t.votingType),t.resultsVisibility&&ke(t.resultsVisibility),typeof t.autoClose=="boolean"&&Re(t.autoClose),typeof t.autoSendResults=="boolean"&&Ue(t.autoSendResults),t.resultsSendAt&&Te(t.resultsSendAt),t.titleCs&&De(t.titleCs),t.titleEn&&Pe(t.titleEn),t.descriptionCs&&Ee(t.descriptionCs),t.descriptionEn&&Oe(t.descriptionEn),Array.isArray(t.optionsCs)&&ze(t.optionsCs),Array.isArray(t.optionsEn)&&Ce(t.optionsEn),We(!0),b({title:"Rozpracovaný koncept obnoven",description:"Váš rozepsaný obsah byl obnoven z prohlÞeÄe."})}}catch(l){console.error("Failed to load draft:",l)}is(!0)},[]),i.useEffect(()=>{if(!(!z||!Qe||!(k.trim()||w.trim()||H.trim()||K.trim()||xe.trim()||ve.trim()||h.some(t=>t.trim())||G.some(t=>t.trim())||Q.some(t=>t.trim()))))try{localStorage.setItem(Se,JSON.stringify({title:k,description:w,options:h,startsAt:C,endsAt:I,isActive:s,sourceLanguage:a,allowMultiple:j,allowComments:V,attachments:M,votingType:q,resultsVisibility:R,autoClose:we,autoSendResults:_e,resultsSendAt:ge,titleCs:H,titleEn:K,descriptionCs:xe,descriptionEn:ve,optionsCs:G,optionsEn:Q,savedAt:new Date().toISOString()}))}catch(t){console.error("Failed to save draft:",t)}},[z,Qe,Se,k,w,h,C,I,s,a,j,V,M,q,R,we,_e,ge,H,K,xe,ve,G,Q]);const os=()=>{try{localStorage.removeItem(Se)}catch{}We(!1)},cs=async l=>{const{data:t,error:c}=await y.from("polls").select("*").eq("id",l).maybeSingle();if(c||!t){b({variant:"destructive",title:"Chyba",description:"Hlasovánà nebylo nalezeno."}),f("/admin?section=polls");return}F(t.title),E(t.description||"");const v=Array.isArray(t.options)?t.options:[];L(v.length>=2?v:["",""]),Y(t.starts_at?new Date(t.starts_at).toISOString().split("T")[0]:""),X(t.ends_at?new Date(t.ends_at).toISOString().split("T")[0]:""),n(t.is_active),De(t.title_cs||""),Pe(t.title_en||""),Ee(t.description_cs||""),Oe(t.description_en||"");const x=Array.isArray(t.options_cs)?t.options_cs:[],W=Array.isArray(t.options_en)?t.options_en:[];ze(x),Ce(W),S(t.source_language||"cs"),d(t.allow_multiple||!1),O(t.allow_comments||!1);const Z=t.attachments;Array.isArray(Z)&&Z.length>0?ee(Z.filter(T=>T==null?void 0:T.url).map(T=>({url:T.url,name:T.name||"PÅÃloha"}))):t.attachment_url?ee([{url:t.attachment_url,name:t.attachment_name||"PÅÃloha"}]):ee([]),se(t.voting_type||"automatic"),fe(t.ballot_kind||"yes_no"),ke(t.results_visibility||"after_close"),Re(t.auto_close??!0),Ue(t.auto_send_results??!1),Ge(t.requires_delivery_decision??!1);const le=t.results_send_at;if(le){const T=new Date(le),be=u=>String(u).padStart(2,"0");Te(`${T.getFullYear()}-${be(T.getMonth()+1)}-${be(T.getDate())}T${be(T.getHours())}:${be(T.getMinutes())}`)}else Te("");U(!1)},ds=async l=>{const t=Array.from(l.target.files||[]);if(t.length!==0){r(!0);try{const c=[];for(const v of t){const x=v.name.split(".").pop(),W=`poll-attachments/${Date.now()}-${Math.random().toString(36).slice(2,8)}.${x}`,{error:Z}=await y.storage.from("documents").upload(W,v);if(Z)throw Z;c.push({url:W,name:v.name})}ee(v=>[...v,...c]),b({title:c.length>1?`Nahráno ${c.length} souborů`:"Soubor nahrán"})}catch(c){b({variant:"destructive",title:"Chyba",description:c.message||"NepodaÅilo se nahrát soubor."})}finally{r(!1),l.target.value=""}}},ms=l=>{ee(t=>t.filter((c,v)=>v!==l))},us=()=>L([...h,""]),ps=l=>{h.length<=2||(L(h.filter((t,c)=>c!==l)),ze(G.filter((t,c)=>c!==l)),Ce(Q.filter((t,c)=>c!==l)))},hs=(l,t)=>{const c=[...h];c[l]=t,L(c)},xs=(l,t)=>{const c=[...G];for(;c.length<=l;)c.push("");c[l]=t,ze(c)},vs=(l,t)=>{const c=[...Q];for(;c.length<=l;)c.push("");c[l]=t,Ce(c)},js=async()=>
6{if(!(a==="cs"?H:a==="en"?K:k).trim()){b({variant:"destructive",title:"Chyba",description:"Zadejte nejprve název hlasovánà ve zdrojovém jazyce."});return}P(!0);try{const t={source_language:a,title:k,description:w,options:h.filter(x=>x.trim()),title_cs:H,title_en:K,description_cs:xe,description_en:ve,options_cs:G,options_en:Q};p&&!z&&(t.poll_id=p);const{data:c,error:v}=await y.functions.invoke("translate-poll",{body:t});if(v)throw v;if(c!=null&&c.translations){const x=c.translations;x.title_cs&&De(x.title_cs),x.title_en&&Pe(x.title_en),x.title&&F(x.title),x.description_cs!==void 0&&Ee(x.description_cs||""),x.description_en!==void 0&&Oe(x.description_en||""),x.description!==void 0&&E(x.description||""),x.options_cs&&ze(x.options_cs),x.options_en&&Ce(x.options_en),x.options&&L(x.options)}b({title:"PÅeklad dokonÄen"})}catch(t){console.error("Translation error:",t),b({variant:"destructive",title:"Chyba pÅekladu",description:t.message||"NepodaÅilo se pÅeložit."})}finally{P(!1)}},fs=()=>a==="cs"?H:a==="en"?K:k,_s=()=>a==="cs"?G:a==="en"?Q:h,gs=async()=>{var Z,le;if(!fs().trim()){b({variant:"destructive",title:"Chyba",description:"Zadejte název hlasovánà ve zdrojovém jazyce."});return}const t=_s().filter(T=>T.trim()!=="");if(t.length<2){b({variant:"destructive",title:"Chyba",description:"Zadejte alespoÅ 2 možnosti ve zdrojovém jazyce."});return}B(!0);const c=k.trim()||H.trim()||K.trim(),v=h.filter(T=>T.trim()).length>=2?h.filter(T=>T.trim()):t,x={title:c,description:w.trim()||xe.trim()||ve.trim()||null,options:v,starts_at:C?new Date(C).toISOString():new Date().toISOString(),ends_at:I?rt(I):null,is_active:s,created_by:g==null?void 0:g.id,title_cs:H.trim()||null,title_en:K.trim()||null,description_cs:xe.trim()||null,description_en:ve.trim()||null,options_cs:G.length>0?G:[],options_en:Q.length>0?Q:[],source_language:a,allow_multiple:j,allow_comments:V,attachments:M,attachment_url:((Z=M[0])==null?void 0:Z.url)||null,attachment_name:((le=M[0])==null?void 0:le.name)||null,voting_type:q,ballot_kind:Ne,results_visibility:R,auto_close:we,auto_send_results:_e,requires_delivery_decision:Ke,results_send_at:_e&&ge?new Date(ge).toISOString():null},{error:W}=z?await y.from("polls").insert([x]):await y.from("polls").update(x).eq("id",p);if(W){b({variant:"destructive",title:"Chyba",description:"NepodaÅilo se uložit hlasovánÃ."}),B(!1);return}try{localStorage.removeItem(Se)}catch{}b({title:z?"Hlasovánà vytvoÅeno":"Hlasovánà upraveno"}),f("/admin?section=polls")};if(he)return e.jsx(Ye,{title:"Detail hlasovánÃ",activeSection:"polls",breadcrumbs:[{label:"Administrace",href:"/admin"},{label:"HlasovánÃ",href:"/admin?section=polls"},{label:"Detail"}],children:e.jsx("div",{className:"flex items-center justify-center py-24",children:e.jsx(ne,{className:"h-8 w-8 animate-spin text-primary"})})});const Je=()=>e.jsxs(e.Fragment,{children:[e.jsx(te,{children:e.jsxs(ae,{className:"pt-4 pb-3",children:[e.jsx(m,{className:"text-sm font-medium text-muted-foreground mb-3 block",children:"Zdrojový jazyk pÅekladu"}),e.jsxs(Vs,{value:a,onValueChange:S,className:"flex gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{value:"cs",id:"src-cs"}),e.jsx(m,{htmlFor:"src-cs",className:"cursor-pointer text-sm",children:"ð¨ð¿ ÄeÅ¡tina"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{value:"de",id:"src-de"}),e.jsx(m,{htmlFor:"src-de",className:"cursor-pointer text-sm",children:"ð©ðª NÄmÄina"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{value:"en",id:"src-en"}),e.jsx(m,{htmlFor:"src-en",className:"cursor-pointer text-sm",children:"ð¬ð§ AngliÄtina"})]})]})]})}),e.jsxs(Ve,{defaultValue:a,className:"w-full",children:[e.jsxs("div",{className:"flex items-end justify-between gap-4 flex-wrap",children:[e.jsxs($e,{className:"grid w-full max-w-sm grid-cols-3 h-10",children:[e.jsxs(J,{value:"cs",className:"text-sm font-semibold",children:["ð¨ð¿ Äesky ",a==="cs"&&"(zdroj)"]}),e.jsxs(J,{value:"de",className:"text-sm font-semibold",children:["ð©ðª Deutsch ",a==="de"&&"(zdroj)"]}),e.jsxs(J,{value:"en",className:"text-sm font-semibold",children:["ð¬ð§ English ",a==="en"&&"(zdroj)"]})]}),(()=>{const l=[],t={cs:"ÄeÅ¡tina",de:"Deutsch",en:"English"};return k.trim()||l.push("de"),H.trim()||l.push("cs"),K.trim()||l.push("en"),l.length>0?e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-destructive pb-1",children:[e.jsx(Xe,{className:"h-3.5 w-3.5"}),e.jsxs("span",{children:["Chybà pÅeklad: ",l.map(c=>
6t[c]).join(", ")]})]}):null})()]}),["cs","de","en"].map(l=>{const t=a===l,v={cs:{title:"Otázka / Název",desc:"Popis",opts:"Možnosti",addBtn:"PÅidat možnost",optPlaceholder:u=>`Možnost ${u+1}`,titlePlaceholder:"NapÅ. SouhlasÃte s rekonstrukcÃ?",descPlaceholder:"Podrobný popis...",infoTitle:"Základnà informace (zdroj)",transTitle:"Äeský pÅeklad",transOpts:"Možnosti (Äesky)",transOptPlaceholder:u=>`Možnost ${u+1} Äesky`,titleTransPlaceholder:"Äeský pÅeklad názvu...",descTransPlaceholder:"Äeský pÅeklad popisu..."},de:{title:"Frage / Titel",desc:"Beschreibung",opts:"Abstimmungsoptionen",addBtn:"Option hinzufügen",optPlaceholder:u=>`Option ${u+1}`,titlePlaceholder:"z.B. Stimmen Sie der Renovierung zu?",descPlaceholder:"Detaillierte Beschreibung...",infoTitle:"Grundinformationen (Quelle)",transTitle:"Deutsche Ãbersetzung",transOpts:"Optionen (Deutsch)",transOptPlaceholder:u=>`Option ${u+1} auf Deutsch`,titleTransPlaceholder:"Deutsche Ãbersetzung des Titels...",descTransPlaceholder:"Deutsche Ãbersetzung der Beschreibung..."},en:{title:"Question / Title",desc:"Description",opts:"Voting Options",addBtn:"Add option",optPlaceholder:u=>`Option ${u+1}`,titlePlaceholder:"e.g. Do you agree with the renovation?",descPlaceholder:"Detailed description...",infoTitle:"Basic Information (Source)",transTitle:"English Translation",transOpts:"Options (English)",transOptPlaceholder:u=>`Option ${u+1} in English`,titleTransPlaceholder:"English translation of the title...",descTransPlaceholder:"English translation of the description..."}}[l],x=u=>l==="de"?u==="title"?k:w:l==="cs"?u==="title"?H:xe:u==="title"?K:ve,W=(u,N)=>{l==="de"?u==="title"?F(N):E(N):l==="cs"?u==="title"?De(N):Ee(N):u==="title"?Pe(N):Oe(N)},Z=()=>l==="de"?h:l==="cs"?G:Q,le=(u,N)=>{l==="de"?hs(u,N):l==="cs"?xs(u,N):vs(u,N)},T=a==="de"?"DE":a==="cs"?"CZ":"EN",be=u=>a==="de"?h[u]||"":a==="cs"?G[u]||"":Q[u]||"";return t?e.jsxs(oe,{value:l,className:"space-y-6 mt-4",children:[e.jsxs(te,{children:[e.jsx(ie,{children:e.jsx(re,{className:"text-base",children:v.infoTitle})}),e.jsxs(ae,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(m,{children:[v.title," *"]}),e.jsx($,{value:x("title"),onChange:u=>W("title",u.target.value),placeholder:v.titlePlaceholder})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:v.desc}),e.jsx(ce,{value:x("description"),onChange:u=>W("description",u.target.value),rows:3,placeholder:v.descPlaceholder})]})]})]}),e.jsxs(te,{children:[e.jsxs(ie,{className:"flex flex-row items-center justify-between",children:[e.jsx(re,{className:"text-base",children:v.opts}),e.jsxs(A,{type:"button",variant:"outline",size:"sm",onClick:us,className:"gap-1.5",children:[e.jsx(ls,{className:"h-3.5 w-3.5"}),v.addBtn]})]}),e.jsx(ae,{className:"space-y-3",children:h.map((u,N)=>{const Ze=Z()[N]||"";return e.jsxs("div",{className:"flex gap-2",children:[e.jsx($,{value:Ze,onChange:bs=>le(N,bs.target.value),placeholder:v.optPlaceholder(N)}),h.length>2&&e.jsx(A,{type:"button",variant:"ghost",size:"icon",onClick:()=>ps(N),className:"shrink-0",children:e.jsx(Os,{className:"h-4 w-4"})})]},N)})})]})]},l):e.jsxs(oe,{value:l,className:"space-y-6 mt-4",children:[e.jsxs(te,{children:[e.jsx(ie,{children:e.jsx(re,{className:"text-base",children:v.transTitle})}),e.jsxs(ae,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:v.title}),e.jsx($,{value:x("title"),onChange:u=>W("title",u.target.value),placeholder:v.titleTransPlaceholder})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:v.desc}),e.jsx(ce,{value:x("description"),onChange:u=>W("description",u.target.value),rows:3,placeholder:v.descTransPlaceholder})]})]})]}),e.jsxs(te,{children:[e.jsx(ie,{children:e.jsx(re,{className:"text-base",children:v.transOpts})}),e.jsx(ae,{className:"space-y-3",children:h.map((u,N)=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs(m,{className:"text-xs text-muted-foreground",children:[T,": ",be(N)||`Option ${N+1}`]}),e.jsx($,{value:Z()[N]||"",onChange:Ze=>le(N,Ze.target.value),placeholder:v.transOptPlaceholder(N)})]},N))})]})]},l)})]}),e.jsxs(te,{children:[e.jsx(ie,{children:e.jsx(re,{className:"text-base",children:"Pravidla hlasovánÃ"})}),e.jsxs(ae,{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-lg border border-primary/20 bg-primary/5 p-4 text-sm space-y-3",children:[e.jsx("p",{className:"font-medium text-foreground",children:"§ 24 odst. 4 WEG 2002 â automatické vyhodnocenÃ"}),e.jsx("p",{className:"text-muted-foreground",children:"Systém automaticky vyhodnotà výsledky hlasovánà podle obou zákonných cest a zobrazÃ, které podmÃnky byly splnÄny:"}),e.jsxs("div",{className:"grid gap-2 pl-1",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-green-500 mt-1.5 shrink-0"}),e.jsxs("p",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-foreground",children:"Absolutnà vÄtÅ¡ina vÅ
6¡ech WEG podÃlů:"}),' Hlasy âpro" musà pÅesáhnout 50 % vÅ¡ech WEG podÃlů.']})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-500 mt-1.5 shrink-0"}),e.jsxs("p",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-foreground",children:"Kvalifikovaná vÄtÅ¡ina:"}),' â¥2/3 odevzdaných hlasů + hlasy âpro" ⥠1/3 celkových WEG podÃlů.']})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Druh hlasovánÃ"}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:[{key:"yes_no",title:"Ano / ne (návrh usnesenÃ)",desc:"Usnesenà může pÅijmout pouze prvnà možnost (âproâ). Druhá možnost je âprotiâ."},{key:"variants",title:"VýbÄr z variant",desc:"Každá varianta se posuzuje samostatnÄ; usnesenà může pÅijmout kterákoli z nich."}].map(l=>e.jsxs("label",{className:`cursor-pointer rounded-lg border p-3 text-xs transition-colors ${Ne===l.key?"border-primary/40 bg-primary/5":"hover:bg-muted/30"}`,children:[e.jsx("input",{type:"radio",name:"ballot_kind",className:"sr-only",checked:Ne===l.key,onChange:()=>fe(l.key)}),e.jsx("span",{className:"block font-medium text-foreground",children:l.title}),e.jsx("span",{className:"mt-1 block text-muted-foreground",children:l.desc})]},l.key))})]})]})]}),e.jsxs(te,{children:[e.jsx(ie,{children:e.jsx(re,{className:"text-base",children:"NastavenÃ"})}),e.jsxs(ae,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"starts_at",children:"Datum zahájenÃ"}),e.jsx($,{id:"starts_at",type:"date",value:C,onChange:l=>Y(l.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"ends_at",children:"Datum ukonÄenÃ"}),e.jsx($,{id:"ends_at",type:"date",value:I,onChange:l=>X(l.target.value)})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-6",children:[e.jsx(je,{id:"is_active",checked:s,onCheckedChange:n}),e.jsx(m,{htmlFor:"is_active",className:"cursor-pointer",children:"AktivnÃ"})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-6",children:[e.jsx(je,{id:"allow_multiple",checked:j,onCheckedChange:d}),e.jsx(m,{htmlFor:"allow_multiple",className:"cursor-pointer",children:"VÃce možnostÃ"})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-6",children:[e.jsx(je,{id:"allow_comments",checked:V,onCheckedChange:O}),e.jsx(m,{htmlFor:"allow_comments",className:"cursor-pointer",children:"KomentáÅe k hlasovánÃ"})]}),e.jsxs("div",{className:"flex items-start gap-3 pt-6",children:[e.jsx(je,{id:"requires_delivery_decision",checked:Ke,onCheckedChange:Ge,className:"mt-1"}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(m,{htmlFor:"requires_delivery_decision",className:"cursor-pointer",children:"Vyžadovat volbu komunikaÄnÃho režimu pÅed hlasovánÃm"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PÅed elektronickým lÃstkem zvolà vlastnÃk Elektronicky nebo PoÅ¡tou. ObÄ volby vedou k hlasovánÃ."})]})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-6",children:[e.jsx(je,{id:"auto_close",checked:we,onCheckedChange:Re}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(m,{htmlFor:"auto_close",className:"cursor-pointer",children:"Automaticky uzavÅÃt v den ukonÄenÃ"}),we&&!I&&e.jsxs("p",{className:"text-xs text-destructive flex items-center gap-1",children:[e.jsx(Xe,{className:"h-3 w-3"}),"Nastavte datum ukonÄenÃ"]})]})]}),e.jsxs("div",{className:"flex items-start gap-3 pt-6",children:[e.jsx(je,{id:"auto_send_results",checked:_e,onCheckedChange:Ue,className:"mt-1"}),e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx(m,{htmlFor:"auto_send_results",className:"cursor-pointer",children:"Automaticky rozeslat výsledek po ukonÄenÃ"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"E-mail s výsledkem hlasovánà (WEG § 24 Abs 6, lhůta 1 mÄsÃc) obdržà vÅ¡ichni vlastnÃci."}),_e&&e.jsxs("div",{className:"space-y-1.5 pt-1",children:[e.jsx(m,{htmlFor:"results_send_at",className:"text-xs",children:"Datum a Äas odeslánà (nepovinné)"}),e.jsx($,{id:"results_send_at",type:"datetime-local",value:ge,onChange:l=>Te(l.target.value),className:"max-w-[240px]"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:ge?"Výsledky se rozeÅ¡lou až po tomto termÃnu (nej
6dÅÃv vÅ¡ak po ukonÄenà hlasovánÃ).":"Bez termÃnu se výsledky rozeÅ¡lou ihned po ukonÄenà hlasovánÃ."})]})]})]})]}),e.jsxs("div",{className:"mt-6 pt-4 border-t space-y-2",children:[e.jsx(m,{children:"Viditelnost výsledků pro vlastnÃky"}),e.jsxs(de,{value:R,onValueChange:ke,children:[e.jsx(me,{className:"max-w-sm",children:e.jsx(ue,{})}),e.jsxs(pe,{children:[e.jsx(_,{value:"always",children:"Vždy viditelné (průbÄžné výsledky)"}),e.jsx(_,{value:"aggregate",children:"PrůbÄžnÄ jen souhrnná úÄast (bez rozpadu hlasů)"}),e.jsx(_,{value:"tallies",children:"PrůbÄžnÄ souhrnné výsledky otázek (bez bytů)"}),e.jsx(_,{value:"after_voting",children:"Po odhlasovánà (vlastnÃk vidà po svém hlasu)"}),e.jsx(_,{value:"after_close",children:"Až po uzavÅenà hlasovánÃ"}),e.jsx(_,{value:"never",children:"Nikdy (pouze admin)"})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[R==="always"&&"VlastnÃci mohou zobrazit průbÄžné výsledky kdykoliv.",R==="aggregate"&&"BÄhem hlasovánà vlastnÃci vidà pouze celkovou úÄast (poÄet jednotek a podÃlů). Rozpad hlasů po bytech se odemkne až po uzavÅenÃ.",R==="tallies"&&"BÄhem hlasovánà vlastnÃci vidà souhrnný stav každé otázky (poÄty jednotek a podÃlů pro jednotlivé možnosti), ale bez rozpisu po bytech. Rozpad hlasů po bytech se odemkne až po uzavÅenÃ.",R==="after_voting"&&"VlastnÃk uvidà výsledky až poté, co odhlasuje za vÅ¡echny své byty.",R==="after_close"&&"Výsledky se zobrazà vlastnÃkům až po uzavÅenà hlasovánÃ.",R==="never"&&"Výsledky jsou viditelné pouze v administraci."]}),e.jsxs($s,{className:"mt-3 bg-muted/30 border-border/60",children:[e.jsx(dt,{className:"h-4 w-4 text-primary"}),e.jsx(Fs,{className:"text-xs text-muted-foreground",children:"Právnà upozornÄnà k WEG 2002: Zákon neukládá povinnost zveÅejÅovat průbÄžné výsledky bÄhem hlasovánÃ. Po uzavÅenà hlasovánà musà být vÅ¡em vlastnÃkům zpÅÃstupnÄn výsledek vÄetnÄ rozpadu hlasů po jednotlivých bytech (§ 24 odst. 5)."})]})]})]})]}),e.jsxs(te,{children:[e.jsx(ie,{children:e.jsx(re,{className:"text-base",children:"PÅÃlohy dokumentů"})}),e.jsxs(ae,{className:"space-y-3",children:[M.length>0&&e.jsx("div",{className:"space-y-2",children:M.map((l,t)=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-md border bg-muted/50",children:[e.jsx(mt,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("button",{type:"button",onClick:async()=>{const{data:c}=await y.storage.from("documents").createSignedUrl(l.url,3600);c!=null&&c.signedUrl&&window.open(c.signedUrl,"_blank")},className:"text-sm font-medium text-primary hover:underline truncate flex-1 text-left",children:l.name||"PÅÃloha"}),e.jsx(A,{type:"button",variant:"ghost",size:"icon",onClick:()=>ms(t),className:"shrink-0",children:e.jsx(Le,{className:"h-4 w-4 text-destructive"})})]},`${l.url}-${t}`))}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(m,{htmlFor:"poll-attachment",className:"cursor-pointer",children:e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-md border border-dashed hover:bg-muted/50 transition-colors",children:[ye?e.jsx(ne,{className:"h-4 w-4 animate-spin"}):e.jsx(ns,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:ye?"Nahrávám...":"Nahrát PDF nebo dokumenty"})]})}),e.jsx($,{id:"poll-attachment",type:"file",multiple:!0,accept:".pdf,.doc,.docx,.xls,.xlsx",onChange:ds,disabled:ye,className:"hidden"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Můžete nahrát vÃce dokumentů najednou."})]})]})]});return e.jsx(Ye,{title:z?"Nové hlasovánÃ":k,activeSection:"polls",breadcrumbs:[{label:"Administrace",href:"/admin"},{label:"HlasovánÃ",href:"/admin?section=polls"},{label:z?"Nové":k}],children:e.jsxs("div",{className:"max-w-6xl space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsx("h2",{className:"font-serif text-2xl font-bold text-foreground",children:z?"Nové hlasovánÃ":k}),e.jsxs("div",{className:"flex gap-2",children:[!z&&p&&e.jsxs(A,{onClick:()=>f(`/admin/poll/${p}/results`),variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(ot,{className:"h-3.5 w-3.5"}),"Výsledky"]}),e.jsxs(A,{onClick:js,disabled:D||!(a==="cs"?H.trim():a==="en"?K.trim():k.trim()),variant:"outline",size:"sm",className:"gap-1.5",children:[D?e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ts,{className:"h-3.5 w-3.5"}),D?"PÅekládám...":"PÅeložit"]}),e.jsxs(A,{onClick:gs,disabled:o,size:"sm",className:"gap-1.5",children:[o?e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(as,{className:"h-3.5 w-3.5"}),z?"VytvoÅit":"Uložit zmÄny"]})]})]}),z&&rs&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-900 px-3 py-2 text-sm",children:[e.jsx("span",{className:"text-amber-900 dark:text-amber-200",children:"Obnoven rozpracovaný koncept z vaÅ¡eho prohlÞeÄe."}),e.jsxs(A,{variant:"ghost",size:"sm",onClick:()=>{os(),window.location.reload()},className:"gap-1.5 text-amber-900 dark:text-amber-200 hover:bg-amber-100 dar
6k:hover:bg-amber-900/40",children:[e.jsx(Le,{className:"h-3.5 w-3.5"}),"Zahodit koncept"]})]}),z?e.jsx("div",{className:"space-y-6",children:Je()}):e.jsxs(Ve,{defaultValue:"edit",className:"w-full",children:[e.jsxs($e,{children:[e.jsx(J,{value:"edit",children:"NastavenÃ"}),e.jsxs(J,{value:"faq",className:"gap-1.5",children:[e.jsx(ct,{className:"h-3.5 w-3.5"}),"FAQ"]}),e.jsxs(J,{value:"emails",className:"gap-1.5",children:[e.jsx(Es,{className:"h-3.5 w-3.5"}),"E-maily"]})]}),e.jsx(oe,{value:"edit",className:"space-y-6 mt-4",children:Je()}),e.jsx(oe,{value:"faq",className:"mt-4",children:e.jsx(jt,{pollId:p,pollTitle:k})}),e.jsx(oe,{value:"emails",className:"mt-4",children:e.jsx(Ls,{pollId:p})})]})]})})};export{Aa 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.