File: /home/u1694298/www/wp-content/plugins/yop-poll/build/admin.js
(()=>{"use strict";var e,l={999(e,l,o){var t={};o.r(t),o.d(t,{addElement:()=>Al,addElementAndSelect:()=>Tl,addElementAt:()=>Rl,addElementAtAndSelect:()=>El,addSubelement:()=>Il,addTemplate:()=>ql,clearTemplateOptions:()=>Ul,fetchPoll:()=>Jl,fetchTemplates:()=>Zl,removeElement:()=>Dl,removeSubelement:()=>Ol,reorderElements:()=>Pl,resetStore:()=>Yl,saveAsCustomTemplate:()=>Wl,savePoll:()=>Kl,setActiveTab:()=>Vl,setDefaultSubelement:()=>zl,setElements:()=>kl,setMetaField:()=>Sl,setOptionsSection:()=>Hl,setPoll:()=>Cl,setPollField:()=>Nl,setSelectedElementId:()=>Bl,setSidebarMode:()=>$l,setTemplates:()=>Fl,setUI:()=>Gl,updateElement:()=>Ll,updateSubelement:()=>Ml});var s={};o.r(s),o.d(s,{getActiveTab:()=>oo,getElements:()=>Xl,getOptionsSection:()=>no,getPoll:()=>Ql,getSelectedElement:()=>lo,getSelectedElementId:()=>eo,getSidebarMode:()=>ao,getTemplateByBase:()=>so,getTemplates:()=>to,getUI:()=>io,hasElementOfType:()=>uo,isDirty:()=>co,isLoading:()=>po,isSaving:()=>ro});var a={};o.r(a),o.d(a,{getTemplates:()=>_o});const n=window.wp.element,i=window.wp.data,r="yop-poll/builder",p="questions",d="standard",c="advanced",u="design",_="elements",m="options",y="layout",h="properties",x=window.wp.components,b=window.wp.i18n,g=window.ReactJSXRuntime;function v(){const{poll:e,activeTab:l,ui:o}=(0,i.useSelect)(e=>({poll:e(r).getPoll(),activeTab:e(r).getActiveTab(),ui:e(r).getUI()})),{setPollField:t,setActiveTab:s,savePoll:a}=(0,i.useDispatch)(r),[p,d]=(0,n.useState)([]),[c,y]=(0,n.useState)(""),[h,v]=(0,n.useState)("");(0,n.useEffect)(()=>{(p.length>0||h)&&window.scrollTo({top:0,behavior:"smooth"})},[p,h]);const f=0!==e.template,j=[{key:u,label:(0,b.__)("Design","yop-poll"),disabled:!1},{key:_,label:(0,b.__)("Elements","yop-poll"),disabled:!f},{key:m,label:(0,b.__)("Options","yop-poll"),disabled:!f}];return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"yop-poll-sticky-header",children:[(0,g.jsx)("div",{className:"yop-poll-sticky-header__left",children:(0,g.jsx)("input",{type:"text",value:e.name,onChange:e=>t("name",e.target.value),placeholder:(0,b.__)("Enter poll name…","yop-poll")})}),(0,g.jsx)("div",{className:"yop-poll-sticky-header__center",children:j.map(e=>(0,g.jsx)("button",{className:["yop-poll-sticky-header__tab",l===e.key&&"yop-poll-sticky-header__tab--active",e.disabled&&"yop-poll-sticky-header__tab--disabled"].filter(Boolean).join(" "),onClick:()=>!e.disabled&&s(e.key),disabled:e.disabled,title:e.disabled?(0,b.__)("Please select a template first","yop-poll"):void 0,children:e.label},e.key))}),(0,g.jsx)("div",{className:"yop-poll-sticky-header__right",children:(0,g.jsx)(x.Button,{variant:"primary",onClick:async()=>{const l=!e.id;d([]),y(""),v("");try{await a();const o="string"==typeof e.meta_data?JSON.parse(e.meta_data):e.meta_data,t=o?.options?.poll?.useCaptcha||"no",s=window.yopPoll?.captchaKeys||{};"no"===t||"built_in"===t||s[t]||v((0,b.__)("The selected captcha type does not have its API keys configured. Please add them in YOP Poll → Settings → Integrations, otherwise the captcha will not work on the frontend.","yop-poll")),l?window.location.href=window.yopPoll.adminUrl+"admin.php?page=yop-poll&saved=1":y((0,b.__)("Poll saved successfully.","yop-poll"))}catch(e){e.validationErrors?d(e.validationErrors):e?.data?.errors&&d(e.data.errors)}},isBusy:o.saving,disabled:o.saving,children:o.saving?(0,b.__)("Saving…","yop-poll"):(0,b.__)("Save Poll","yop-poll")})})]}),(0,g.jsx)("div",{className:"yop-poll-sticky-header-spacer"}),p.length>0&&(0,g.jsxs)("div",{className:"notice notice-error is-dismissible yop-poll-validation-notice",children:[(0,g.jsx)("ul",{children:p.map((e,l)=>(0,g.jsx)("li",{children:e},l))}),(0,g.jsx)("button",{type:"button",className:"notice-dismiss",onClick:()=>d([]),children:(0,g.jsx)("span",{className:"screen-reader-text",children:(0,b.__)("Dismiss this notice.","yop-poll")})})]}),c&&(0,g.jsxs)("div",{className:"notice notice-success is-dismissible yop-poll-validation-notice",children:[(0,g.jsx)("p",{children:c}),(0,g.jsx)("button",{type:"button",className:"notice-dismiss",onClick:()=>y(""),children:(0,g.jsx)("span",{className:"screen-reader-text",children:(0,b.__)("Dismiss this notice.","yop-poll")})})]}),h&&(0,g.jsxs)("div",{className:"notice notice-warning is-dismissible yop-poll-validation-notice",children:[(0,g.jsx)("p",{children:h}),(0,g.jsx)("button",{type:"button",className:"notice-dismiss",onClick:()=>v(""),children:(0,g.jsx)("span",{className:"screen-reader-text",children:(0,b.__)("Dismiss this notice.","yop-poll")})})]})]})}function f({template:e,isSelected:l,onClick:o,isPro:t}){return(0,g.jsxs)("div",{className:"yop-poll-template-card "+(l?"yop-poll-template-card--selected":""),children:[(0,g.jsx)("div",{className:"yop-poll-template-card__preview",children:(0,g.jsx)(j,{template:e})}),(0,g.jsxs)("div",{className:"yop-poll-template-card__footer",children:[(0,g.jsx)("span",{className:"yop-poll-template-card__name",children:e.name}),t&&(0,g.jsx)("span",{className:"yop-poll-pro-badge",children:"PRO"}),l&&(0,g.jsx)("span",{className:"yop-poll-template-card__badge",children:(0,b.__)("Selected","yop-poll")})]}),(0,g.jsx)("div",{className:"yop-poll-template-card__overlay",children:(0,g.jsx)("button",{type:"button",className:"yop-poll-template-card__use-btn",onClick:o,children:(0,b.__)("Use Template","yop-poll")})})]})}function j({template:e}){const l=e.rendering_base||e.base,o=function(e,l={}){const o=l.poll||{},t=l.buttons||{},s=l.answers||{},a=o.borderSize>0?`${o.borderSize}px ${o.borderStyle||"solid"} ${o.borderColor||"#000"}`:"none";return"material"===e?{bg:o.backgroundColor||"#fff",color:"#333",border:Object.keys(o).length?a:"none",borderRadius:null!=o.borderRadius?o.borderRadius+"px":"8px",radioBorder:"#757575",radioFill:s.colorScheme||"#f44336",radioSize:"22px",radioDotSize:"10px",checkedIndex:1,btnBg:t.backgroundColor||"#f44336",btnColor:t.textColor||"#fff",btnBorder:t.borderColor||"transparent",boxShadow:"0 2px 6px rgba(0,0,0,0.15)"}:"bootstrap"===e?{bg:o.backgroundColor||"#fff",color:"#333",border:Object.keys(o).length?a:"none",borderRadius:null!=o.borderRadius?o.borderRadius+"px":"8px",radioBorder:"#dee2e6",radioFill:s.colorScheme||"#f44336",radioSize:"22px",checkedIndex:1,btnBg:t.backgroundColor||"#f44336",btnColor:t.textColor||"#fff",btnBorder:t.borderColor||"transparent",boxShadow:"0 2px 6px rgba(0,0,0,0.15)"}:{bg:o.backgroundColor||"#fff",color:"#333",border:Object.keys(o).length?a:"none",borderRadius:null!=o.borderRadius?o.borderRadius+"px":"8px",radioBorder:"#999",radioFill:s.colorScheme||null,radioSize:"14px",radioDotSize:"6px",checkedIndex:1,btnBg:t.backgroundColor||"#fff",btnColor:t.textColor||"#333",btnBorder:t.borderColor||"#999",boxShadow:"0 2px 6px rgba(0,0,0,0.15)"}}(l,e.options||{}),t="material"===l,s="bootstrap"===l;return(0,g.jsxs)("div",{style:{background:o.bg,color:o.color,border:o.border,borderRadius:o.borderRadius,padding:"20px 16px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',boxShadow:o.boxShadow||"none"},children:[(0,g.jsx)("div",{style:{textAlign:t?"start":"center",fontWeight:t||s?500:600,marginBottom:"12px",fontSize:"13px"},children:(0,b.__)("Question Text Here","yop-poll")}),["Answer 1","Answer 2","Answer 3","Answer 4","Answer 5"].map((e,l)=>{const a=l===o.checkedIndex,n=a&&o.radioFill?o.radioFill:o.radioBorder;return(0,g.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px",fontSize:"12px",padding:"4px 2px"},children:[t?(0,g.jsx)("span",{style:{width:o.radioSize,height:o.radioSize,border:`2px solid ${n}`,borderRadius:"50%",flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:a&&o.radioFill&&(0,g.jsx)("span",{style:{width:o.radioDotSize,height:o.radioDotSize,borderRadius:"50%",background:o.radioFill,display:"block"}})}):s?(0,g.jsx)("span",{style:{width:o.radioSize,height:o.radioSize,border:a?`2px solid ${o.radioFill}`:`2px solid ${o.radioBorder}`,borderRadius:"50%",flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center",background:a?o.radioFill:"transparent",boxSizing:"border-box"},children:a&&(0,g.jsx)("svg",{viewBox:"0 0 12 12",fill:"none",style:{width:"12px",height:"12px"},children:(0,g.jsx)("polyline",{points:"1.5,6 5,9.5 10.5,2.5",stroke:"#fff",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})})}):(0,g.jsx)("input",{type:"radio",checked:a,onChange:()=>{},style:{margin:0,flexShrink:0,cursor:"default"}}),(0,g.jsx)("span",{children:e})]},l)}),(0,g.jsx)("div",{style:{marginTop:"14px",textAlign:"center"},children:(0,g.jsx)("span",{style:{display:"inline-block",padding:"6px 16px",background:o.btnBg,color:o.btnColor,border:`1px solid ${o.btnBorder}`,borderRadius:"4px",fontSize:"12px",fontWeight:500,cursor:"default",textTransform:t||s?"uppercase":"none",letterSpacing:t||s?"0.5px":"normal"},children:(0,b.__)("Vote Now","yop-poll")})})]})}var w=(0,n.forwardRef)(({icon:e,size:l=24,...o},t)=>(0,n.cloneElement)(e,{width:l,height:l,...o,ref:t}));const C=window.wp.primitives;var N=(0,g.jsx)(C.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(C.Path,{d:"M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"})}),S=(0,g.jsx)(C.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(C.Path,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})});function k({title:e,defaultOpen:l=!0,children:o}){const[t,s]=(0,n.useState)(l);return(0,g.jsxs)("div",{className:"yop-poll-collapsible",children:[(0,g.jsxs)("div",{className:"yop-poll-collapsible__header",onClick:()=>s(!t),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||s(!t)},children:[(0,g.jsx)("span",{className:"yop-poll-collapsible__title",children:e}),(0,g.jsx)(w,{icon:t?N:S,size:20})]}),t&&(0,g.jsx)("div",{className:"yop-poll-collapsible__body",children:o})]})}const A={poll:{backgroundColor:"#ffffff",borderSize:0,borderStyle:"none",borderColor:"#ffffff",borderRadius:0,paddingLeftRight:10,paddingTopBottom:10},questions:{paddingLeftRight:0,paddingTopBottom:10,textColor:"#000000",textSize:16,textWeight:"normal",textAlign:"center",labelGap:12},answers:{paddingLeftRight:0,paddingTopBottom:4,textColor:"#000000",textSize:14,textWeight:"normal"},buttons:{backgroundColor:"#ffffff",borderSize:1,borderStyle:"solid",borderColor:"#000000",borderRadius:5,paddingLeftRight:16,paddingTopBottom:6,textColor:"#000000",textSize:14,textWeight:"normal",align:"center"},errors:{borderLeftColorForSuccess:"#008000",borderLeftColorForError:"#ff0000",borderLeftSize:10,paddingTopBottom:0,textColor:"#000000",textSize:14,textWeight:"normal"}};function R({label:e,value:l,defaultValue:o,onChange:t}){const[s,a]=(0,n.useState)(!1),i=l||o;return(0,g.jsxs)("div",{className:"yop-poll-template-opt__field",children:[(0,g.jsx)("label",{className:"yop-poll-template-opt__label",children:e}),(0,g.jsxs)("div",{className:"yop-poll-properties__color-input-wrap",children:[(0,g.jsx)("button",{type:"button",className:"yop-poll-properties__color-preview",style:{background:i},onClick:()=>a(!s)}),(0,g.jsx)("input",{type:"text",className:"yop-poll-properties__color-input",value:l,placeholder:o,onChange:e=>t(e.target.value)}),s&&(0,g.jsx)(x.Popover,{position:"bottom left",onClose:()=>a(!1),children:(0,g.jsx)("div",{style:{padding:"10px"},children:(0,g.jsx)(x.ColorPicker,{color:i,onChange:t,enableAlpha:!1})})})]})]})}function T({label:e,value:l,defaultValue:o,onChange:t}){return(0,g.jsxs)("div",{className:"yop-poll-template-opt__field",children:[(0,g.jsx)("label",{className:"yop-poll-template-opt__label",children:e}),(0,g.jsxs)("div",{className:"yop-poll-template-opt__px-wrap",children:[(0,g.jsx)("input",{type:"number",className:"yop-poll-template-opt__px-input",value:void 0!==l&&""!==l?l:o,onChange:e=>t(Number(e.target.value))}),(0,g.jsx)("span",{className:"yop-poll-template-opt__px-unit",children:"px"})]})]})}function E({leftRight:e,topBottom:l,onChange:o}){const t=[{key:"paddingLeftRight",label:(0,b.__)("Left/Right","yop-poll"),value:e},{key:"paddingTopBottom",label:(0,b.__)("Top/Bottom","yop-poll"),value:l}];return(0,g.jsxs)("div",{className:"yop-poll-template-opt__padding-field",children:[(0,g.jsx)("span",{className:"yop-poll-template-opt__padding-label",children:(0,b.__)("Padding","yop-poll")}),(0,g.jsx)("div",{className:"yop-poll-template-opt__padding-row",children:t.map(({key:t,label:s,value:a})=>(0,g.jsxs)("div",{className:"yop-poll-template-opt__padding-side",children:[(0,g.jsx)("input",{type:"number",className:"yop-poll-template-opt__padding-input",value:a,onChange:s=>((t,s)=>{o({paddingLeftRight:e,paddingTopBottom:l,[t]:s})})(t,Number(s.target.value))}),(0,g.jsx)("span",{className:"yop-poll-template-opt__padding-side-label",children:s})]},t))})]})}function L({label:e,value:l,defaultValue:o,min:t=0,max:s=20,step:a=1,onChange:n}){const i=void 0!==l&&""!==l?l:o;return(0,g.jsxs)("div",{className:"yop-poll-template-opt__field",children:[(0,g.jsx)("label",{className:"yop-poll-template-opt__label",children:e}),(0,g.jsxs)("div",{className:"yop-poll-template-opt__slider-wrap",children:[(0,g.jsx)("input",{type:"range",className:"yop-poll-template-opt__slider",min:t,max:s,step:a,value:i,onChange:e=>n(Number(e.target.value))}),(0,g.jsxs)("span",{className:"yop-poll-template-opt__slider-value",children:[i,"px"]})]})]})}function D({label:e,value:l,defaultValue:o,options:t,onChange:s}){return(0,g.jsxs)("div",{className:"yop-poll-template-opt__field",children:[(0,g.jsx)("label",{className:"yop-poll-template-opt__label",children:e}),(0,g.jsx)("select",{className:"yop-poll-template-opt__select",value:l||o,onChange:e=>s(e.target.value),children:t.map(e=>(0,g.jsx)("option",{value:e.value,children:e.label},e.value))})]})}const P=[{value:"solid",label:(0,b.__)("Solid","yop-poll")},{value:"dashed",label:(0,b.__)("Dashed","yop-poll")},{value:"dotted",label:(0,b.__)("Dotted","yop-poll")},{value:"double",label:(0,b.__)("Double","yop-poll")},{value:"none",label:(0,b.__)("None","yop-poll")}],B=[{value:"normal",label:(0,b.__)("Normal","yop-poll")},{value:"bold",label:(0,b.__)("Bold","yop-poll")}],I=[{value:"left",label:(0,b.__)("Left","yop-poll")},{value:"center",label:(0,b.__)("Center","yop-poll")},{value:"right",label:(0,b.__)("Right","yop-poll")}];function M({onChangeTemplate:e}){const l=(0,i.useSelect)(e=>e(r).getPoll()),o=(0,i.useSelect)(e=>e(r).getTemplates()),{setMetaField:t,saveAsCustomTemplate:s}=(0,i.useDispatch)(r),[a,p]=(0,n.useState)(!1),[d,c]=(0,n.useState)(""),[u,_]=(0,n.useState)(!1),m="material"===l.template_base,y="bootstrap"===l.template_base,h=o.find(e=>e.id===l.template)||o.find(e=>e.base===l.template_base)||null,v=h?.options||{},f=("string"==typeof l.meta_data?JSON.parse(l.meta_data):l.meta_data||{}).style||{},j=(e,l,o)=>{const s=f[e]||{};t("style",e,{...s,[l]:o})},w=(e,l)=>{const o=f[e]||{};t("style",e,{...o,...l})},C=e=>({...A[e]||{},...v[e]||{},...f[e]||{}}),N=C("poll"),S=C("questions"),M=C("answers"),O=C("buttons"),z=C("errors");return(0,g.jsxs)("div",{className:"yop-poll-template-opt",children:[e&&(0,g.jsx)("button",{type:"button",className:"yop-poll-properties__change-template-btn",onClick:e,children:(0,b.__)("Change Template","yop-poll")}),(0,g.jsxs)(k,{title:(0,b.__)("Poll Container","yop-poll"),defaultOpen:!0,children:[(0,g.jsx)(R,{label:(0,b.__)("Background Color","yop-poll"),value:f.poll?.backgroundColor||"",defaultValue:A.poll.backgroundColor,onChange:e=>j("poll","backgroundColor",e)}),(0,g.jsx)(D,{label:(0,b.__)("Border Style","yop-poll"),value:N.borderStyle,defaultValue:A.poll.borderStyle,options:P,onChange:e=>j("poll","borderStyle",e)}),(0,g.jsx)(L,{label:(0,b.__)("Border Thickness","yop-poll"),value:N.borderSize,defaultValue:A.poll.borderSize,max:20,onChange:e=>j("poll","borderSize",e)}),(0,g.jsx)(R,{label:(0,b.__)("Border Color","yop-poll"),value:f.poll?.borderColor||"",defaultValue:A.poll.borderColor,onChange:e=>j("poll","borderColor",e)}),(0,g.jsx)(L,{label:(0,b.__)("Border Radius","yop-poll"),value:N.borderRadius,defaultValue:A.poll.borderRadius,max:50,onChange:e=>j("poll","borderRadius",e)}),(0,g.jsx)(E,{leftRight:N.paddingLeftRight,topBottom:N.paddingTopBottom,onChange:e=>w("poll",e)})]}),(0,g.jsxs)(k,{title:(0,b.__)("Elements","yop-poll"),defaultOpen:!0,children:[(0,g.jsx)(E,{leftRight:S.paddingLeftRight,topBottom:S.paddingTopBottom,onChange:e=>w("questions",e)}),(0,g.jsx)(R,{label:(0,b.__)("Text Color","yop-poll"),value:f.questions?.textColor||"",defaultValue:A.questions.textColor,onChange:e=>j("questions","textColor",e)}),(0,g.jsx)(T,{label:(0,b.__)("Text Size","yop-poll"),value:S.textSize,defaultValue:A.questions.textSize,onChange:e=>j("questions","textSize",e)}),(0,g.jsx)(D,{label:(0,b.__)("Text Weight","yop-poll"),value:S.textWeight,defaultValue:A.questions.textWeight,options:B,onChange:e=>j("questions","textWeight",e)}),(0,g.jsx)(D,{label:(0,b.__)("Text Align","yop-poll"),value:S.textAlign,defaultValue:A.questions.textAlign,options:I,onChange:e=>j("questions","textAlign",e)}),(0,g.jsx)(T,{label:(0,b.__)("Label Gap","yop-poll"),value:S.labelGap,defaultValue:A.questions.labelGap,onChange:e=>j("questions","labelGap",e)})]}),(0,g.jsxs)(k,{title:(0,b.__)("Answers","yop-poll"),defaultOpen:!0,children:[(0,g.jsx)(E,{leftRight:M.paddingLeftRight,topBottom:M.paddingTopBottom,onChange:e=>w("answers",e)}),(0,g.jsx)(R,{label:(0,b.__)("Text Color","yop-poll"),value:f.answers?.textColor||"",defaultValue:A.answers.textColor,onChange:e=>j("answers","textColor",e)}),(0,g.jsx)(T,{label:(0,b.__)("Text Size","yop-poll"),value:M.textSize,defaultValue:A.answers.textSize,onChange:e=>j("answers","textSize",e)}),(0,g.jsx)(D,{label:(0,b.__)("Text Weight","yop-poll"),value:M.textWeight,defaultValue:A.answers.textWeight,options:B,onChange:e=>j("answers","textWeight",e)}),(m||y)&&(0,g.jsx)(R,{label:(0,b.__)("Indicator Color","yop-poll"),value:f.answers?.colorScheme||"",defaultValue:v.answers?.colorScheme||"#f44336",onChange:e=>j("answers","colorScheme",e)})]}),(0,g.jsxs)(k,{title:(0,b.__)("Buttons","yop-poll"),defaultOpen:!0,children:[(0,g.jsx)(R,{label:(0,b.__)("Background Color","yop-poll"),value:f.buttons?.backgroundColor||"",defaultValue:O.backgroundColor,onChange:e=>j("buttons","backgroundColor",e)}),(0,g.jsx)(D,{label:(0,b.__)("Border Style","yop-poll"),value:O.borderStyle,defaultValue:A.buttons.borderStyle,options:P,onChange:e=>j("buttons","borderStyle",e)}),(0,g.jsx)(L,{label:(0,b.__)("Border Thickness","yop-poll"),value:O.borderSize,defaultValue:A.buttons.borderSize,max:20,onChange:e=>j("buttons","borderSize",e)}),(0,g.jsx)(R,{label:(0,b.__)("Border Color","yop-poll"),value:f.buttons?.borderColor||"",defaultValue:O.borderColor,onChange:e=>j("buttons","borderColor",e)}),(0,g.jsx)(L,{label:(0,b.__)("Border Radius","yop-poll"),value:O.borderRadius,defaultValue:A.buttons.borderRadius,max:50,onChange:e=>j("buttons","borderRadius",e)}),(0,g.jsx)(E,{leftRight:O.paddingLeftRight,topBottom:O.paddingTopBottom,onChange:e=>w("buttons",e)}),(0,g.jsx)(R,{label:(0,b.__)("Text Color","yop-poll"),value:f.buttons?.textColor||"",defaultValue:O.textColor,onChange:e=>j("buttons","textColor",e)}),(0,g.jsx)(T,{label:(0,b.__)("Text Size","yop-poll"),value:O.textSize,defaultValue:A.buttons.textSize,onChange:e=>j("buttons","textSize",e)}),(0,g.jsx)(D,{label:(0,b.__)("Text Weight","yop-poll"),value:O.textWeight,defaultValue:A.buttons.textWeight,options:B,onChange:e=>j("buttons","textWeight",e)}),(0,g.jsx)(D,{label:(0,b.__)("Align","yop-poll"),value:O.align,defaultValue:A.buttons.align,options:I,onChange:e=>j("buttons","align",e)})]}),(0,g.jsxs)(k,{title:(0,b.__)("Messages","yop-poll"),defaultOpen:!0,children:[(0,g.jsx)(R,{label:(0,b.__)("Border color for success","yop-poll"),value:f.errors?.borderLeftColorForSuccess||"",defaultValue:A.errors.borderLeftColorForSuccess,onChange:e=>j("errors","borderLeftColorForSuccess",e)}),(0,g.jsx)(R,{label:(0,b.__)("Border color for error","yop-poll"),value:f.errors?.borderLeftColorForError||"",defaultValue:A.errors.borderLeftColorForError,onChange:e=>j("errors","borderLeftColorForError",e)}),(0,g.jsx)(L,{label:(0,b.__)("Border Left Thickness","yop-poll"),value:z.borderLeftSize,defaultValue:A.errors.borderLeftSize,max:20,onChange:e=>j("errors","borderLeftSize",e)}),(0,g.jsx)(T,{label:(0,b.__)("Padding Top/Bottom","yop-poll"),value:z.paddingTopBottom,defaultValue:A.errors.paddingTopBottom,onChange:e=>j("errors","paddingTopBottom",e)}),(0,g.jsx)(R,{label:(0,b.__)("Text color","yop-poll"),value:f.errors?.textColor||"",defaultValue:A.errors.textColor,onChange:e=>j("errors","textColor",e)}),(0,g.jsx)(T,{label:(0,b.__)("Text size","yop-poll"),value:z.textSize,defaultValue:A.errors.textSize,onChange:e=>j("errors","textSize",e)}),(0,g.jsx)(D,{label:(0,b.__)("Text Weight","yop-poll"),value:z.textWeight,defaultValue:A.errors.textWeight,options:B,onChange:e=>j("errors","textWeight",e)})]}),a?(0,g.jsxs)("div",{className:"yop-poll-template-opt__save-custom",children:[(0,g.jsx)(x.TextControl,{placeholder:(0,b.__)("Template name…","yop-poll"),value:d,onChange:e=>c(e),__nextHasNoMarginBottom:!0}),(0,g.jsx)(x.Button,{variant:"primary",onClick:async()=>{if(d.trim()){_(!0);try{const e={poll:N,questions:S,answers:M,buttons:O,errors:z};await s(d.trim(),l.template_base,e),p(!1),c("")}finally{_(!1)}}},disabled:u||!d.trim(),isBusy:u,children:u?(0,b.__)("Saving…","yop-poll"):(0,b.__)("Save","yop-poll")}),(0,g.jsx)(x.Button,{variant:"tertiary",onClick:()=>{p(!1),c("")},children:(0,b.__)("Cancel","yop-poll")})]}):(0,g.jsx)(x.Button,{variant:"secondary",className:"yop-poll-template-opt__save-custom-btn",onClick:()=>p(!0),children:(0,b.__)("Save as Custom Template","yop-poll")})]})}var O=(0,g.jsx)(C.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(C.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})}),z=(0,g.jsx)(C.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(C.Path,{d:"M8 7h2V5H8v2zm0 6h2v-2H8v2zm0 6h2v-2H8v2zm6-14v2h2V5h-2zm0 8h2v-2h-2v2zm0 6h2v-2h-2v2z"})}),V=(0,g.jsx)(C.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(C.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M5 4.5h11a.5.5 0 0 1 .5.5v11a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V5a.5.5 0 0 1 .5-.5ZM3 5a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm17 3v10.75c0 .69-.56 1.25-1.25 1.25H6v1.5h12.75a2.75 2.75 0 0 0 2.75-2.75V8H20Z"})}),F=(0,g.jsx)(C.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(C.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"})});const q={"question-text":{type:"question-text",label:"Text Question",group:p,icon:"editor-ul",hasSubelements:!0,singleton:!0},"question-dropdown":{type:"question-dropdown",label:"Dropdown Question",group:p,icon:"arrow-down-alt2",hasSubelements:!0,pro:!0},"question-image":{type:"question-image",label:"Images Question",group:p,icon:"format-image",hasSubelements:!0,pro:!0},"question-video":{type:"question-video",label:"Videos Question",group:p,icon:"format-video",hasSubelements:!0,pro:!0},"question-audio":{type:"question-audio",label:"Audios Question",group:p,icon:"format-audio",hasSubelements:!0,pro:!0},"question-text-slider":{type:"question-text-slider",label:"Text Slider Question",group:p,icon:"slides",hasSubelements:!0,pro:!0},"standard-single-line-text":{type:"standard-single-line-text",label:"Single Line Text",group:d,icon:"editor-textcolor",hasSubelements:!1},"standard-multi-line-text":{type:"standard-multi-line-text",label:"Multi Line Text",group:d,icon:"editor-paragraph",hasSubelements:!1,pro:!0},"standard-text-block":{type:"standard-text-block",label:"Text Block",group:d,icon:"text",hasSubelements:!1,pro:!0},"standard-space-separator":{type:"standard-space-separator",label:"Space Separator",group:d,icon:"sort",hasSubelements:!1,pro:!0},"standard-divider":{type:"standard-divider",label:"Divider",group:d,icon:"minus",hasSubelements:!1,pro:!0},"standard-image":{type:"standard-image",label:"Image",group:d,icon:"format-image",hasSubelements:!1,pro:!0},"advanced-page-break":{type:"advanced-page-break",label:"Page Break",group:c,icon:"editor-break",hasSubelements:!1,pro:!0},"advanced-email":{type:"advanced-email",label:"Email",group:c,icon:"email",hasSubelements:!1,singleton:!0,pro:!0},"advanced-progress-steps":{type:"advanced-progress-steps",label:"Progress Steps",group:c,icon:"editor-ol",hasSubelements:!1,pro:!0}};function W(e){return Object.values(q).filter(l=>l.group===e)}function U(e){return q[e]||null}const $="SET_POLL_FIELD",H="SET_POLL",G="SET_ELEMENTS",Y="ADD_ELEMENT",K="UPDATE_ELEMENT",J="REMOVE_ELEMENT",Z="REORDER_ELEMENTS",Q="SET_SELECTED_ELEMENT_ID",X="ADD_SUBELEMENT",ee="UPDATE_SUBELEMENT",le="REMOVE_SUBELEMENT",oe="SET_ACTIVE_TAB",te="SET_TEMPLATES",se="SET_SIDEBAR_MODE",ae="SET_UI",ne="SET_OPTIONS_SECTION",ie="SET_DEFAULT_SUBELEMENT",re="RESET_STORE",pe="ADD_TEMPLATE",de="ADD_ELEMENT_AT",ce=[{id:1,name:"Classic",base:"classic",rendering_base:"classic",status:"active",options:{poll:{backgroundColor:"#ffffff",borderSize:0,borderStyle:"none",borderColor:"#ffffff",borderRadius:8,paddingLeftRight:10,paddingTopBottom:10},questions:{paddingLeftRight:0,paddingTopBottom:10,textColor:"#000000",textSize:16,textWeight:"normal",textAlign:"center",labelGap:12},answers:{paddingLeftRight:0,paddingTopBottom:4,textColor:"#000000",textSize:14,textWeight:"normal"},buttons:{backgroundColor:"#ffffff",borderSize:1,borderStyle:"solid",borderColor:"#000000",borderRadius:5,paddingLeftRight:16,paddingTopBottom:6,textColor:"#000000",textSize:14,textWeight:"normal",align:"center"},errors:{borderLeftColorForSuccess:"#008000",borderLeftColorForError:"#ff0000",borderLeftSize:10,paddingTopBottom:0,textColor:"#000000",textSize:14,textWeight:"normal"},captcha:{}}},{id:2,name:"Material",base:"material",rendering_base:"material",status:"active",pro:!0,options:{poll:{backgroundColor:"#ffffff",borderSize:0,borderStyle:"none",borderColor:"transparent",borderRadius:8,paddingLeftRight:10,paddingTopBottom:10},questions:{paddingLeftRight:0,paddingTopBottom:10,textColor:"#000000",textSize:16,textWeight:"normal",textAlign:"center",labelGap:16},answers:{paddingLeftRight:8,paddingTopBottom:10,textColor:"#424242",textSize:14,textWeight:"normal",colorScheme:"#f44336"},buttons:{backgroundColor:"#f44336",borderSize:0,borderStyle:"none",borderColor:"transparent",borderRadius:4,paddingLeftRight:16,paddingTopBottom:6,textColor:"#ffffff",textSize:14,textWeight:"500",align:"center"},errors:{borderLeftColorForSuccess:"#008000",borderLeftColorForError:"#ff0000",borderLeftSize:10,paddingTopBottom:0,textColor:"#000000",textSize:14,textWeight:"normal"},captcha:{}}},{id:3,name:"Bootstrap",base:"bootstrap",rendering_base:"bootstrap",status:"active",pro:!0,options:{poll:{backgroundColor:"#ffffff",borderSize:0,borderStyle:"none",borderColor:"transparent",borderRadius:8,paddingLeftRight:10,paddingTopBottom:10},questions:{paddingLeftRight:0,paddingTopBottom:10,textColor:"#000000",textSize:16,textWeight:"normal",textAlign:"center",labelGap:12},answers:{paddingLeftRight:4,paddingTopBottom:8,textColor:"#212529",textSize:14,textWeight:"normal",colorScheme:"#0d6efd"},buttons:{backgroundColor:"#0d6efd",borderSize:0,borderStyle:"none",borderColor:"transparent",borderRadius:4,paddingLeftRight:16,paddingTopBottom:6,textColor:"#ffffff",textSize:14,textWeight:"500",align:"center"},errors:{borderLeftColorForSuccess:"#008000",borderLeftColorForError:"#ff0000",borderLeftSize:10,paddingTopBottom:0,textColor:"#000000",textSize:14,textWeight:"normal"},captcha:{}}}],ue={poll:{id:0,name:"",template:0,template_base:"classic",skin_base:"",stype:"poll",status:"published",meta_data:{options:{poll:{status:"published",enableAutoRefresh:"no",redirectAfterVote:"no",redirectUrl:"",redirectAfter:"",resetPollStatsAutomatically:"no",resetPollStatsOn:"",resetPollStatsEvery:"",resetPollStatsEveryPeriod:"hours",emailResultsBeforeReset:"no",emailResultsFromName:"",emailResultsFromEmail:"",emailResultsRecipients:"",emailResultsSubject:"",emailResultsMessage:"",autoGeneratePollPage:"no",notificationMessageLocation:"top",startDateOption:"now",startDateCustom:"",endDateOption:"never",endDateCustom:"",endDateDisplay:"no",endDateText:"",endDateCountdownText:"",showTotalVotes:"no",showTotalAnswers:"no",useCaptcha:"no",enableGdpr:"no",gdprSolution:"ask_consent",gdprConsentText:"",sendEmailNotifications:"no",emailNotificationsFromName:"",emailNotificationsFromEmail:"",emailNotificationsRecipients:"",emailNotificationsSubject:"",emailNotificationsMessage:"",voteButtonLabel:"Vote",showResultsLink:"no",resultsLabelText:"Results"},access:{votePermissions:["guest"],enableAnonymousVoting:"no",limitVotesPerUser:"no",votesPerUserAllowed:"1",allowChangeVote:"no",enableCustomVotingWeight:"no",votingWeights:{},blockVoters:["no-block"],blockLengthType:"forever",blockForValue:"",blockForPeriod:"minutes"},results:{showResultsMoment:["after-vote"],customDateResults:"",showResultsTo:["guest"],resultsDetails:["votes-number"],backToVoteOption:"no",backToVoteCaption:"",sortResults:"as-defined",sortResultsRule:"ascending",displayResultsAs:"bar"}},style:{custom:{css:""}}}},elements:[],selectedElementId:null,activeTab:u,templates:ce,sidebarMode:y,optionsSection:"poll",ui:{saving:!1,loading:!1,dirty:!1}};let _e=-1;function me(){return _e--}function ye(e){const l=q[e];if(!l)return{etype:e,etext:"",status:"active",meta_data:{},subelements:[]};const o={etype:e,etext:l.label,status:"active",meta_data:"question-text-slider"===e?{range_start:1,range_end:5,default_value:3,range_step:1,display_labels:!1,display_steps:!1}:"advanced-page-break"===e?{next_label:"Next",prev_label:"Previous",display_prev_btn:!1,btn_size:"small",btn_align:"center"}:{},subelements:[]};return l.hasSubelements&&"question-text-slider"!==e&&(o.subelements=[{stext:"Answer 1",stype:"text",status:"active",meta_data:{}},{stext:"Answer 2",stype:"text",status:"active",meta_data:{}},{stext:"Answer 3",stype:"text",status:"active",meta_data:{}}]),o}function he(e){const l=(e||"#000000").replace("#",""),o=3===l.length?l.split("").map(e=>e+e).join(""):l;return(299*parseInt(o.substring(0,2),16)+587*parseInt(o.substring(2,4),16)+114*parseInt(o.substring(4,6),16))/1e3<128?"#ffffff":"#000000"}const xe="__vote-button__";function be({showMessagePreview:e=!1,previewFirstAnswer:l=!1}){const{elements:o,selectedElementId:t,poll:s,activeTab:a,templates:p}=(0,i.useSelect)(e=>({elements:e(r).getElements(),selectedElementId:e(r).getSelectedElementId(),poll:e(r).getPoll(),activeTab:e(r).getActiveTab(),templates:e(r).getTemplates()})),{setSelectedElementId:d,removeElement:c,addElement:u,addElementAt:m,addElementAtAndSelect:y,reorderElements:h}=(0,i.useDispatch)(r),x="string"==typeof s.meta_data?JSON.parse(s.meta_data):s.meta_data||{},v=x.style||{},f=p.find(e=>e.id===s.template)||p.find(e=>e.base===s.template_base)||null,j=f?.options||{},C=x.options?.poll||{},N=C.voteButtonLabel||(0,b.__)("Vote Now","yop-poll"),S="material"===s.template_base,k="bootstrap"===s.template_base,A=v.answers?.colorScheme||"#f44336",R=v.buttons?.align||"center",T="yes"===C.showResultsLink,E=void 0!==C.resultsLabelText?C.resultsLabelText:(0,b.__)("Results","yop-poll"),[L,D]=(0,n.useState)(null),[P,B]=(0,n.useState)(null),I=(0,n.useRef)(!1),M=(0,n.useCallback)((e,l)=>{I.current?(D(l),e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",String(l))):e.preventDefault()},[]),q=(0,n.useCallback)((e,l)=>{e.preventDefault(),B(l)},[]),W=(0,n.useCallback)(()=>{D(null),B(null),I.current=!1},[]),$=(0,n.useCallback)((e,l)=>{e.preventDefault();const t=L;if(null===t){const t=e.dataTransfer.getData("text/plain");if(t.startsWith("etype:")){const e=t.slice(6),s=U(e);if(s?.singleton&&o.some(l=>l.etype===e))return void W();y(ye(e),l+1)}return void W()}const s=t<l?l:l+1;if(s===t)return void W();const a=[...o],[n]=a.splice(t,1);a.splice(s,0,n),h(a),W()},[L,o,h,y,W]),H=t===xe,G=(0,g.jsxs)("div",{className:["yop-poll-poll-preview__element",a===_&&H&&"yop-poll-poll-preview__element--selected"].filter(Boolean).join(" "),onClick:a===_?()=>d(H?null:xe):void 0,children:[a===_&&(0,g.jsx)("div",{className:"yop-poll-poll-preview__toolbar",children:(0,g.jsx)("button",{className:"yop-poll-poll-preview__tool-btn",title:(0,b.__)("Edit","yop-poll"),onClick:e=>{e.stopPropagation(),d(H?null:xe)},children:(0,g.jsx)(w,{icon:O,size:18})})}),(0,g.jsx)("div",{style:{textAlign:R},children:(0,g.jsxs)("div",{className:"yop-poll-poll-preview__vote-btn-row",children:[(0,g.jsx)("span",{className:"yop-poll-poll-preview__vote-btn",children:N}),T&&(0,g.jsx)("span",{className:"yop-poll-poll-preview__vote-btn yop-poll-poll-preview__vote-btn--results",children:E})]})})]});return 0===o.length?(0,g.jsxs)("div",{className:"yop-poll-canvas",onDragOver:e=>e.preventDefault(),onDrop:e=>{const l=e.dataTransfer.getData("text/plain");l.startsWith("etype:")&&y(ye(l.slice(6)),0)},children:[(0,g.jsx)("div",{className:"yop-poll-canvas__empty",children:(0,b.__)("Click elements in the sidebar to add them to your poll.","yop-poll")}),G]}):(0,g.jsx)("div",{className:"yop-poll-canvas",children:(0,g.jsxs)("div",{className:`yop-poll-poll-preview ${S?"yop-poll-poll-preview--material":k?"yop-poll-poll-preview--bootstrap":"yop-poll-poll-preview--basic"}${a!==_?" yop-poll-poll-preview--no-hover":""}`,style:(()=>{const e={paddingLeftRight:10,paddingTopBottom:10,backgroundColor:"#ffffff",borderSize:0,borderStyle:"none",borderColor:"#ffffff",borderRadius:0,...j.poll||{},...v.poll||{}},l={paddingLeftRight:0,paddingTopBottom:10,textColor:"#000000",textSize:16,textWeight:"normal",textAlign:"center",labelGap:12,...j.questions||{},...v.questions||{}},o={paddingLeftRight:0,paddingTopBottom:4,textColor:"#000000",textSize:14,textWeight:"normal",...j.answers||{},...v.answers||{}},t={backgroundColor:"#ffffff",borderSize:1,borderStyle:"solid",borderColor:"#000000",borderRadius:5,paddingLeftRight:16,paddingTopBottom:6,textColor:"#000000",textSize:14,textWeight:"normal",align:"center",...j.buttons||{},...v.buttons||{}},s={borderLeftColorForSuccess:"#008000",borderLeftColorForError:"#ff0000",borderLeftSize:10,paddingTopBottom:0,textColor:"#000000",textSize:14,textWeight:"normal",...j.errors||{},...v.errors||{}};return{background:e.backgroundColor,borderWidth:e.borderSize+"px",borderStyle:e.borderStyle,borderColor:e.borderColor,borderRadius:e.borderRadius+"px",paddingTop:e.paddingTopBottom+"px",paddingRight:e.paddingLeftRight+"px",paddingBottom:e.paddingTopBottom+"px",paddingLeft:e.paddingLeftRight+"px","--yop-c-bg":e.backgroundColor,"--yop-c-bw":e.borderSize+"px","--yop-c-bs":e.borderStyle,"--yop-c-bc":e.borderColor,"--yop-c-br":e.borderRadius+"px","--yop-c-pl":e.paddingLeftRight+"px","--yop-c-pr":e.paddingLeftRight+"px","--yop-c-pt":e.paddingTopBottom+"px","--yop-c-pb":e.paddingTopBottom+"px","--yop-el-pl":l.paddingLeftRight+"px","--yop-el-pr":l.paddingLeftRight+"px","--yop-el-pt":l.paddingTopBottom+"px","--yop-el-pb":l.paddingTopBottom+"px","--yop-el-tc":l.textColor,"--yop-el-ts":l.textSize+"px","--yop-el-tw":l.textWeight,"--yop-el-ta":l.textAlign,"--yop-q-gap":l.labelGap+"px","--yop-ans-pl":o.paddingLeftRight+"px","--yop-ans-pr":o.paddingLeftRight+"px","--yop-ans-pt":o.paddingTopBottom+"px","--yop-ans-pb":o.paddingTopBottom+"px","--yop-ans-tc":o.textColor,"--yop-ans-ts":o.textSize+"px","--yop-ans-tw":o.textWeight,...S||k?{"--yop-radio-color":o.colorScheme||"#f44336"}:{},"--yop-btn-bg":t.backgroundColor,"--yop-btn-bw":t.borderSize+"px","--yop-btn-bs":t.borderStyle,"--yop-btn-bc":t.borderColor,"--yop-btn-br":t.borderRadius+"px","--yop-btn-pl":t.paddingLeftRight+"px","--yop-btn-pr":t.paddingLeftRight+"px","--yop-btn-pt":t.paddingTopBottom+"px","--yop-btn-pb":t.paddingTopBottom+"px","--yop-btn-tc":t.textColor,"--yop-btn-ts":t.textSize+"px","--yop-btn-tw":t.textWeight,"--yop-btn-align":t.align,"--yop-msg-bcs":s.borderLeftColorForSuccess,"--yop-msg-bce":s.borderLeftColorForError,"--yop-msg-blw":s.borderLeftSize+"px","--yop-msg-pt":s.paddingTopBottom+"px","--yop-msg-pb":s.paddingTopBottom+"px","--yop-msg-tc":s.textColor,"--yop-msg-ts":s.textSize+"px","--yop-msg-tw":s.textWeight}})(),children:[e&&(0,g.jsx)("div",{className:"yop-poll-poll-preview__message yop-poll-poll-preview__message--success",children:(0,b.__)("Thank you for your vote","yop-poll")}),o.map(e=>{const n=o.indexOf(e),i=e.id||e._tempId,r=U(e.etype),p=t===i,m=L===n,y=P===n&&L!==n;return(0,g.jsxs)("div",{className:["yop-poll-poll-preview__element",a===_&&p&&"yop-poll-poll-preview__element--selected",m&&"yop-poll-poll-preview__element--dragging",y&&"yop-poll-poll-preview__element--dragover"].filter(Boolean).join(" "),draggable:!0,onDragStart:e=>M(e,n),onDragOver:e=>q(e,n),onDragLeave:()=>B(null),onDrop:e=>$(e,n),onDragEnd:W,onClick:a===_?()=>d(t===i?null:i):void 0,children:[a===_&&(0,g.jsxs)("div",{className:"yop-poll-poll-preview__toolbar",children:[(0,g.jsx)("button",{className:"yop-poll-poll-preview__tool-btn",title:(0,b.__)("Drag","yop-poll"),onMouseDown:e=>{e.stopPropagation(),I.current=!0},style:{cursor:"grab"},children:(0,g.jsx)(w,{icon:z,size:18})}),(0,g.jsx)("button",{className:"yop-poll-poll-preview__tool-btn",title:(0,b.__)("Edit","yop-poll"),onClick:e=>((e,l)=>{e.stopPropagation(),d(t===l?null:l)})(e,i),children:(0,g.jsx)(w,{icon:O,size:18})}),!r?.singleton&&(0,g.jsx)("button",{className:"yop-poll-poll-preview__tool-btn",title:(0,b.__)("Clone","yop-poll"),onClick:l=>((e,l)=>{e.stopPropagation();const o={...l,id:void 0,_tempId:me(),etext:l.etext,subelements:(l.subelements||[]).map(e=>({...e,id:void 0,_tempId:me()}))};u(o)})(l,e),children:(0,g.jsx)(w,{icon:V,size:18})}),(0,g.jsx)("button",{className:"yop-poll-poll-preview__tool-btn yop-poll-poll-preview__tool-btn--danger",title:(0,b.__)("Delete","yop-poll"),onClick:e=>((e,l)=>{e.stopPropagation(),c(l)})(e,i),children:(0,g.jsx)(w,{icon:F,size:18})})]}),(0,g.jsx)(ge,{element:e,config:r,elements:o,templateBase:s.template_base,indicatorColor:A,previewFirstAnswer:l})]},i)}),G]})})}function ge({element:e,config:l,elements:o,templateBase:t,indicatorColor:s,previewFirstAnswer:a}){if(!l)return(0,g.jsx)("div",{className:"yop-poll-poll-preview__unknown",children:e.etype});if(l.hasSubelements){const l=e.meta_data&&"object"==typeof e.meta_data?e.meta_data:{},o="yes"===l.allowMultipleAnswers?"yop-poll-poll-preview__checkbox":"yop-poll-poll-preview__radio",n="yes"===l.allowOtherAnswers,i=n?"number"==typeof l.otherAnswersCount?l.otherAnswersCount:1:0,r=l.otherAnswersLabel||(0,b.__)("Other","yop-poll"),p=l.otherFieldType||"single-line",d=l.otherFieldSize||"small",c=l.answersDisplay||"vertical",u=l.answersColumns||"2",_=["yop-poll-poll-preview__answers","horizontal"===c&&"yop-poll-poll-preview__answers--horizontal","columns"===c&&"yop-poll-poll-preview__answers--columns"].filter(Boolean).join(" "),m="columns"===c?{columnCount:Number(u)}:void 0;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"yop-poll-poll-preview__question",dangerouslySetInnerHTML:{__html:e.etext||(0,b.__)("Question Text Here","yop-poll")}}),(0,g.jsxs)("div",{className:_,style:m,children:[(()=>{const l=(e.subelements||[]).some(e=>"1"===(e.meta_data||{}).makeDefault);return function(e,l){const o=[...e];return"alphabetical-asc"===l?o.sort((e,l)=>(e.stext||"").localeCompare(l.stext||"")):"alphabetical-desc"===l&&o.sort((e,l)=>(l.stext||"").localeCompare(e.stext||"")),o}(e.subelements||[],(e.meta_data||{}).answersSort||"as-defined").map((e,n)=>{const i=e.meta_data||{},r="1"===i.makeDefault||a&&("bootstrap"===t||"material"===t)&&!l&&0===n;return(0,g.jsxs)("div",{className:"yop-poll-poll-preview__answer",children:["bootstrap"===t?(0,g.jsx)("span",{style:{display:"inline-flex",width:"22px",height:"22px",borderRadius:"50%",border:r?"2px solid var(--yop-radio-color, #f44336)":"2px solid #dee2e6",background:r?"var(--yop-radio-color, #f44336)":"transparent",flexShrink:0,alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r&&(0,g.jsx)("svg",{viewBox:"0 0 12 12",fill:"none",style:{width:"10px",height:"10px",flexShrink:0},children:(0,g.jsx)("polyline",{points:"1.5,6 5,9.5 10.5,2.5",stroke:he(s),strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})})}):(0,g.jsx)("span",{className:[o,r&&`${o}--checked`].filter(Boolean).join(" ")}),"1"===i.makeLink&&i.link?(0,g.jsx)("a",{href:i.link,className:"yop-poll-poll-preview__answer-link",onClick:e=>e.preventDefault(),dangerouslySetInnerHTML:{__html:e.stext||""}}):(0,g.jsx)("span",{dangerouslySetInnerHTML:{__html:e.stext||""}})]},e.id||e._tempId)})})(),n&&(0,g.jsxs)("div",{className:"yop-poll-poll-preview__answer yop-poll-poll-preview__answer--other",children:[(0,g.jsx)("span",{className:o}),(0,g.jsx)("span",{className:"yop-poll-poll-preview__other-label",dangerouslySetInnerHTML:{__html:r}}),Array.from({length:i}).map((e,l)=>(0,g.jsx)("div",{className:"yop-poll-poll-preview__other-field-wrap",children:"multi-line"===p?(0,g.jsx)("textarea",{className:`yop-poll-poll-preview__other-field yop-poll-poll-preview__other-field--${d}`,disabled:!0}):(0,g.jsx)("input",{type:"text",className:`yop-poll-poll-preview__other-field yop-poll-poll-preview__other-field--${d}`,disabled:!0})},`other-${l}`))]})]})]})}if("standard-single-line-text"===e.etype){const l=e.meta_data&&"object"==typeof e.meta_data?e.meta_data:{},o=l.size||"small",t=l.align||"left",s=parseInt(l.max_chars||0,10),a=["yop-poll-poll-preview__single-line-input",`yop-poll-poll-preview__single-line-input--${o}`,`yop-poll-poll-preview__single-line-input--${t}`].filter(Boolean).join(" ");return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"yop-poll-poll-preview__label",dangerouslySetInnerHTML:{__html:e.etext||(0,b.__)("Label Text Here","yop-poll")}}),(0,g.jsx)("div",{style:{textAlign:t},children:(0,g.jsx)("input",{type:"text",className:a,placeholder:s>0?`${(0,b.__)("Max","yop-poll")} ${s} ${(0,b.__)("chars","yop-poll")}`:"",maxLength:s>0?s:void 0,disabled:!0})})]})}if("standard-captcha"===e.etype){const l=e.meta_data&&"object"==typeof e.meta_data?e.meta_data:{},o={built_in:(0,b.__)("Built In","yop-poll"),recaptcha_v2_checkbox:(0,b.__)("reCaptcha v2 Checkbox","yop-poll"),recaptcha_v2_invisible:(0,b.__)("reCaptcha v2 Invisible","yop-poll"),recaptcha_v3:(0,b.__)("reCaptcha v3","yop-poll"),hcaptcha:(0,b.__)("hCaptcha","yop-poll"),turnstile:(0,b.__)("Cloudflare Turnstile","yop-poll")},t=l.captcha_type||"built_in",s=o[t]||o.built_in;if("built_in"===t){const e=l.question_align||"left",o={left:"flex-start",center:"center",right:"flex-end"},t=l.question_template||"";return(0,g.jsxs)("div",{className:"yop-poll-poll-preview__captcha",children:[t?(0,g.jsx)("div",{className:"yop-poll-poll-preview__captcha-question",style:"left"!==e?{textAlign:e}:void 0,dangerouslySetInnerHTML:{__html:t}}):(0,g.jsx)("div",{className:"yop-poll-poll-preview__captcha-question",style:"left"!==e?{textAlign:e}:void 0,children:(0,b.__)("Click on the [image]","yop-poll")}),(0,g.jsx)("div",{className:"yop-poll-poll-preview__captcha-images",style:"left"!==e?{justifyContent:o[e]}:void 0,children:Array.from({length:5}).map((e,l)=>(0,g.jsx)("div",{className:"yop-poll-poll-preview__captcha-image-placeholder"},l))})]})}return(0,g.jsxs)("div",{className:"yop-poll-poll-preview__captcha",children:[(0,g.jsx)("span",{className:"yop-poll-poll-preview__captcha-label",children:(0,b.__)("Captcha:","yop-poll")}),(0,g.jsx)("span",{className:"yop-poll-poll-preview__captcha-type",children:s})]})}if("standard-gdpr"===e.etype){const l=e.meta_data&&"object"==typeof e.meta_data?e.meta_data:{},o=l.solution||"anonymize";if("ask_consent"===o){const e=(l.consent_text||"<p>"+(0,b.__)("I agree with the terms and conditions","yop-poll")+"</p>").replace(/^\s*<p[^>]*>/i,"").replace(/<\/p>\s*$/i,""),o=l.consent_align||"left",s="material"===t,a="bootstrap"===t,n=a?(0,g.jsx)("span",{style:{display:"inline-flex",width:"22px",height:"22px",borderRadius:"50%",border:"2px solid #dee2e6",background:"transparent",flexShrink:0,boxSizing:"border-box"}}):s?(0,g.jsx)("span",{className:"yop-poll-poll-preview__checkbox"}):(0,g.jsx)("input",{type:"checkbox",style:{margin:0,flexShrink:0}});return(0,g.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:s?"12px":a?"10px":"8px",padding:"4px 0",justifyContent:"center"===o?"center":"right"===o?"flex-end":"flex-start"},children:[n,(0,g.jsx)("span",{style:{textAlign:o},dangerouslySetInnerHTML:{__html:e}})]})}const s={anonymize:(0,b.__)("Anonymize IP Addresses","yop-poll"),do_not_store:(0,b.__)("Do Not Store IP Addresses","yop-poll")};return(0,g.jsx)("div",{className:"yop-poll-poll-preview__gdpr-info",children:s[o]||s.anonymize})}return(0,g.jsx)("div",{className:"yop-poll-poll-preview__text-element",children:e.etext||l.label})}function ve({open:e,onClose:l}){return e?(0,g.jsx)("div",{className:"yop-pro-modal-backdrop",onClick:l,children:(0,g.jsxs)("div",{className:"yop-pro-modal",onClick:e=>e.stopPropagation(),children:[(0,g.jsx)("button",{className:"yop-pro-modal__close",onClick:l,children:"✕"}),(0,g.jsx)("span",{className:"yop-pro-modal__lock",children:"🔒"}),(0,g.jsx)("h2",{children:(0,b.__)("This is a PRO feature","yop-poll")}),(0,g.jsx)("p",{children:(0,b.__)("We are sorry, this feature is not available on your plan.","yop-poll")}),(0,g.jsx)("p",{children:(0,b.__)("Upgrade to PRO to unlock these awesome features","yop-poll")}),(0,g.jsxs)("div",{className:"yop-pro-modal__features",children:[(0,g.jsx)("span",{children:(0,b.__)("2 Exclusive Designs","yop-poll")}),(0,g.jsx)("span",{children:(0,b.__)("Multiple Questions","yop-poll")}),(0,g.jsx)("span",{children:(0,b.__)("Images Questions","yop-poll")}),(0,g.jsx)("span",{children:(0,b.__)("Videos Questions","yop-poll")}),(0,g.jsx)("span",{children:(0,b.__)("Text Slider Questions","yop-poll")}),(0,g.jsx)("span",{children:(0,b.__)("Facebook Integration","yop-poll")}),(0,g.jsx)("span",{children:(0,b.__)("Google Integration","yop-poll")}),(0,g.jsx)("span",{children:(0,b.__)("Pie Chart Results","yop-poll")}),(0,g.jsx)("span",{children:(0,b.__)("Countdown Timer","yop-poll")}),(0,g.jsx)("span",{children:(0,b.__)("Anonymous Voting","yop-poll")})]}),(0,g.jsx)("a",{className:"yop-pro-modal__upgrade-btn",href:"https://yop-poll.com/upgrade/?utm_source=wordpress&utm_campaign=yoplite&utm_medium=short-blue",target:"_blank",rel:"noreferrer",children:(0,b.__)("Upgrade To Pro","yop-poll")})]})}):null}function fe(){const[e,l]=(0,n.useState)("all"),[o,t]=(0,n.useState)(""),[s,a]=(0,n.useState)(!1),[p,d]=(0,n.useState)(!1),{templates:c,poll:u,elements:_}=(0,i.useSelect)(e=>({templates:e(r).getTemplates(),poll:e(r).getPoll(),elements:e(r).getElements()})),{setPollField:m,addElement:y,clearTemplateOptions:h,setMetaField:x}=(0,i.useDispatch)(r),v=0!==u.template;let j=c;if("free"===e?j=j.filter(e=>!e.pro):"pro"===e&&(j=j.filter(e=>!!e.pro)),o){const e=o.toLowerCase();j=j.filter(l=>l.name.toLowerCase().includes(e))}return!v||s?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:v?"yop-poll-two-panel":void 0,children:[(0,g.jsx)("div",{className:v?"yop-poll-two-panel__main":void 0,children:(w=e=>{if(m("template",e.id),m("template_base",e.base),h(),!u.meta_data?.options?.poll?.voteButtonLabel)try{const l="string"==typeof e.options?JSON.parse(e.options):e.options||{};l?.voteButton?.label&&x("options.poll","voteButtonLabel",l.voteButton.label)}catch(e){}0===_.length&&y(ye("question-text")),a(!1)},(0,g.jsxs)("div",{className:"yop-poll-design-tab",children:[(0,g.jsxs)("div",{className:"yop-poll-template-filters",children:[["Free","Pro","All"].map(o=>(0,g.jsx)("button",{className:"yop-poll-template-filters__btn "+(e===o.toLowerCase()?"yop-poll-template-filters__btn--active":""),onClick:()=>l(o.toLowerCase()),children:o},o)),(0,g.jsx)("input",{type:"text",className:"yop-poll-template-filters__search",placeholder:(0,b.__)("Search","yop-poll"),value:o,onChange:e=>t(e.target.value)})]}),(0,g.jsxs)("div",{className:"yop-poll-template-grid",children:[j.map(e=>(0,g.jsx)(f,{template:e,isSelected:u.template===e.id,isPro:!!e.pro,onClick:()=>e.pro?d(!0):w(e)},e.id)),0===j.length&&(0,g.jsx)("p",{style:{color:"#888",gridColumn:"1 / -1"},children:(0,b.__)("No templates found.","yop-poll")})]})]}))}),v&&(0,g.jsx)("div",{className:"yop-poll-two-panel__sidebar",children:(0,g.jsx)("div",{className:"yop-poll-sidebar__content",children:(0,g.jsx)(M,{onChangeTemplate:()=>a(!0)})})})]}),(0,g.jsx)(ve,{open:p,onClose:()=>d(!1)})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"yop-poll-two-panel",children:[(0,g.jsx)("div",{className:"yop-poll-two-panel__main",children:(0,g.jsx)(be,{showMessagePreview:!0,previewFirstAnswer:!0})}),(0,g.jsx)("div",{className:"yop-poll-two-panel__sidebar",children:(0,g.jsx)("div",{className:"yop-poll-sidebar__content",children:(0,g.jsx)(M,{onChangeTemplate:()=>a(!0)})})})]}),(0,g.jsx)(ve,{open:p,onClose:()=>d(!1)})]});var w}function je({elementType:e,onProClick:l}){const{addElementAndSelect:o}=(0,i.useDispatch)(r),t=(0,i.useSelect)(l=>!!e.singleton&&l(r).hasElementOfType(e.type)),s=e.singleton&&t,a=!!e.pro,n=()=>{s||a?l?.():o(ye(e.type))};return(0,g.jsxs)("div",{className:`yop-poll-element-card${s?" yop-poll-element-card--disabled":""}${a?" yop-poll-element-card--pro":""}`,draggable:!s&&!a,onDragStart:s||a?void 0:l=>{l.dataTransfer.effectAllowed="copy",l.dataTransfer.setData("text/plain","etype:"+e.type)},onClick:n,role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||n()},children:[a&&(0,g.jsx)("span",{className:"yop-poll-pro-badge yop-element-card__pro-badge",children:"PRO"}),(0,g.jsx)(x.Dashicon,{icon:e.icon}),(0,g.jsx)("span",{children:e.label})]})}var we=(0,g.jsx)(C.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(C.Path,{d:"M6 4a2 2 0 0 0-2 2v3h1.5V6a.5.5 0 0 1 .5-.5h3V4H6Zm3 14.5H6a.5.5 0 0 1-.5-.5v-3H4v3a2 2 0 0 0 2 2h3v-1.5Zm6 1.5v-1.5h3a.5.5 0 0 0 .5-.5v-3H20v3a2 2 0 0 1-2 2h-3Zm3-16a2 2 0 0 1 2 2v3h-1.5V6a.5.5 0 0 0-.5-.5h-3V4h3Z"})}),Ce=(0,g.jsx)(C.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(C.Path,{d:"M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z"})}),Ne=(0,g.jsx)(C.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(C.Path,{d:"M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"})}),Se=(0,g.jsx)(C.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(C.Path,{d:"m8.6 7 3.9 10.8h-1.7l-1-2.8H5.7l-1 2.8H3L6.9 7h1.7Zm-2.4 6.6h3L7.7 9.3l-1.5 4.3ZM17.691 8.879c.473 0 .88.055 1.221.165.352.1.643.264.875.495.274.253.456.572.544.957.088.374.132.83.132 1.37v4.554c0 .274.033.472.099.593.077.11.198.166.363.166.11 0 .215-.028.313-.083.11-.055.237-.137.38-.247l.165.28a3.304 3.304 0 0 1-.71.446c-.23.11-.527.165-.89.165-.352 0-.639-.055-.858-.165-.22-.11-.386-.27-.495-.479-.1-.209-.149-.468-.149-.775-.286.462-.627.814-1.023 1.056-.396.242-.858.363-1.386.363-.462 0-.858-.088-1.188-.264a1.752 1.752 0 0 1-.742-.726 2.201 2.201 0 0 1-.248-1.056c0-.484.11-.875.33-1.172.22-.308.5-.556.841-.742.352-.187.721-.341 1.106-.462.396-.132.765-.253 1.106-.363.351-.121.637-.259.857-.413.232-.154.347-.357.347-.61V10.81c0-.396-.066-.71-.198-.941a1.05 1.05 0 0 0-.511-.511 1.763 1.763 0 0 0-.76-.149c-.253 0-.522.039-.808.116a1.165 1.165 0 0 0-.677.412 1.1 1.1 0 0 1 .595.396c.165.187.247.424.247.71 0 .307-.104.55-.313.726-.198.176-.451.263-.76.263-.34 0-.594-.104-.758-.313a1.231 1.231 0 0 1-.248-.759c0-.297.072-.539.214-.726.154-.187.352-.363.595-.528.264-.176.6-.324 1.006-.445.418-.121.88-.182 1.386-.182Zm.99 3.729a1.57 1.57 0 0 1-.528.462c-.231.121-.479.248-.742.38a5.377 5.377 0 0 0-.76.462c-.23.165-.423.38-.577.643-.154.264-.231.6-.231 1.007 0 .429.11.77.33 1.023.22.242.517.363.891.363.308 0 .594-.088.858-.264.275-.176.528-.44.759-.792v-3.284Z"})});function ke({title:e,onClick:l,children:o,active:t}){return(0,g.jsx)("button",{type:"button",className:["yop-poll-rte__btn",t&&"yop-poll-rte__btn--active"].filter(Boolean).join(" "),title:e,onMouseDown:e=>{e.preventDefault(),l()},children:o})}function Ae({title:e,children:l,onApply:o,editorRef:t}){const[s,a]=(0,n.useState)(!1),[i,r]=(0,n.useState)("#000000"),p=(0,n.useRef)(null),d=(0,n.useRef)(null),c=(0,n.useRef)(null),u=(0,n.useRef)(!1),_=(0,n.useCallback)(()=>{const e=window.getSelection();e.rangeCount>0&&(c.current=e.getRangeAt(0).cloneRange())},[]),m=(0,n.useCallback)(()=>{if(c.current){const e=window.getSelection();e.removeAllRanges(),e.addRange(c.current)}},[]),y=(0,n.useCallback)(e=>{u.current=!0,t.current?.focus(),m(),o(e);const l=window.getSelection();l.rangeCount>0&&(c.current=l.getRangeAt(0).cloneRange()),requestAnimationFrame(()=>{u.current=!1})},[o,m,t]),h=(0,n.useCallback)(e=>{r(e),y(e)},[y]),b=(0,n.useCallback)(()=>{s?a(!1):(_(),a(!0))},[s,_]);return(0,n.useEffect)(()=>{if(!s)return;const e=e=>{u.current||p.current?.contains(e.target)||d.current?.contains(e.target)||a(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[s]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("button",{ref:p,type:"button",className:"yop-poll-rte__btn",title:e,onMouseDown:e=>{e.preventDefault(),b()},children:l}),s&&(0,g.jsx)(x.Popover,{anchor:p.current,placement:"bottom-start",onFocusOutside:e=>e.preventDefault(),onClose:()=>{},shift:!0,focusOnMount:!1,children:(0,g.jsx)("div",{ref:d,className:"yop-poll-rte__color-popover",children:(0,g.jsx)(x.ColorPicker,{color:i,onChange:h,enableAlpha:!1})})})]})}const Re=[8,9,10,11,12,13,14,15,16,17,18];function Te({editorRef:e,onInput:l}){const[o,t]=(0,n.useState)(!1),[s,a]=(0,n.useState)(null),i=(0,n.useRef)(null),r=(0,n.useRef)(null),p=(0,n.useRef)(null),d=(0,n.useCallback)(()=>{const l=window.getSelection();if(!l||0===l.rangeCount||!e.current)return;let o=l.getRangeAt(0).startContainer;if(o.nodeType===Node.TEXT_NODE&&(o=o.parentElement),!e.current.contains(o))return;const t=Math.round(parseFloat(window.getComputedStyle(o).fontSize));isNaN(t)||a(t)},[e]);(0,n.useEffect)(()=>(document.addEventListener("selectionchange",d),()=>{document.removeEventListener("selectionchange",d)}),[d]);const c=(0,n.useCallback)(()=>{const e=window.getSelection();e.rangeCount>0&&(p.current=e.getRangeAt(0).cloneRange())},[]),u=(0,n.useCallback)(()=>{o?t(!1):(c(),t(!0))},[o,c]),_=(0,n.useCallback)(o=>{if(p.current){e.current?.focus();const l=window.getSelection();l.removeAllRanges(),l.addRange(p.current)}document.execCommand("fontSize",!1,"7"),e.current&&e.current.querySelectorAll('font[size="7"]').forEach(e=>{e.removeAttribute("size"),e.style.fontSize=o+"px"}),a(o),t(!1),p.current=null,l&&l()},[e,l]);return(0,n.useEffect)(()=>{if(!o)return;const e=e=>{i.current?.contains(e.target)||r.current?.contains(e.target)||t(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[o]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("button",{ref:i,type:"button",className:"yop-poll-rte__btn yop-poll-rte__btn--fontsize",title:(0,b.__)("Font Size","yop-poll"),onMouseDown:e=>{e.preventDefault(),u()},children:[(0,g.jsx)(w,{icon:Se,size:18}),s&&(0,g.jsx)("span",{className:"yop-poll-rte__fontsize-indicator",children:s})]}),o&&(0,g.jsx)(x.Popover,{anchor:i.current,placement:"bottom-start",onFocusOutside:e=>e.preventDefault(),onClose:()=>{},shift:!0,focusOnMount:!1,children:(0,g.jsx)("div",{ref:r,className:"yop-poll-rte__fontsize-dropdown",children:Re.map(e=>(0,g.jsxs)("button",{type:"button",className:["yop-poll-rte__fontsize-option",e===s&&"yop-poll-rte__fontsize-option--active"].filter(Boolean).join(" "),onMouseDown:l=>{l.preventDefault(),_(e)},children:[e,"px"]},e))})})]})}function Ee({value:e,onChange:l,placeholder:o,leftSlot:t,rightSlot:s,footerSlot:a,belowToolbarSlot:i,hideAlign:r,hideLink:p,editorStyle:d}){const c=(0,n.useRef)(null),u=(0,n.useRef)(!1),[_,m]=(0,n.useState)(!1),[y,h]=(0,n.useState)("https://"),v=(0,n.useRef)(null),[f,j]=(0,n.useState)(null),[w,C]=(0,n.useState)({bold:!1,italic:!1,underline:!1,align:null});(0,n.useEffect)(()=>{const e=()=>{const e=window.getSelection();if(!e||0===e.rangeCount||!c.current)return;let l=e.getRangeAt(0).startContainer;if(l.nodeType===Node.TEXT_NODE&&(l=l.parentElement),!c.current.contains(l))return;const o=window.getComputedStyle(l).textAlign;C({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),align:o.includes("center")?"center":o.includes("right")||"end"===o?"right":"left"})};return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)},[]),(0,n.useEffect)(()=>{c.current&&!u.current&&c.current.innerHTML!==(e||"")&&(c.current.innerHTML=e||""),u.current=!1},[e]);const N=(0,n.useCallback)(()=>{c.current&&(u.current=!0,l(c.current.innerHTML))},[l]),S=(0,n.useCallback)((e,l)=>{c.current?.focus(),document.execCommand(e,!1,l||null)},[]),k=(0,n.useCallback)(e=>{e.stopPropagation();const l=e.target.closest("a");l&&c.current?.contains(l)?(e.preventDefault(),j(l)):j(null)},[]),A=(0,n.useCallback)(()=>{if(!f)return;const e=document.createRange();e.selectNodeContents(f);const l=window.getSelection();l.removeAllRanges(),l.addRange(e),v.current=e.cloneRange(),h(f.getAttribute("href")||"https://"),j(null),m(!0)},[f]),R=(0,n.useCallback)(()=>{if(!f)return;const e=document.createRange();e.selectNodeContents(f);const o=window.getSelection();o.removeAllRanges(),o.addRange(e),document.execCommand("unlink",!1,null),j(null),c.current&&(u.current=!0,l(c.current.innerHTML))},[f,l]),T=(0,n.useCallback)(()=>{const e=window.getSelection();e.rangeCount>0&&(v.current=e.getRangeAt(0).cloneRange()),h("https://"),m(!0)},[]),E=(0,n.useCallback)(()=>{if(v.current){c.current?.focus();const e=window.getSelection();e.removeAllRanges(),e.addRange(v.current)}y&&"https://"!==y&&document.execCommand("createLink",!1,y),m(!1),v.current=null,c.current&&(u.current=!0,l(c.current.innerHTML))},[y,l]),L=(0,n.useCallback)(()=>{m(!1),v.current=null},[]),D=(0,n.useCallback)(e=>{e.stopPropagation()},[]),P=null!==w.align?w.align:"center"===d?.textAlign?"center":"right"===d?.textAlign?"right":"left";return(0,g.jsxs)("div",{className:"yop-poll-rte",onClick:D,children:[(0,g.jsxs)("div",{className:"yop-poll-rte__toolbar",children:[t,(0,g.jsx)(Te,{editorRef:c,onInput:N}),(0,g.jsx)("span",{className:"yop-poll-rte__separator"}),(0,g.jsx)(Ae,{title:(0,b.__)("Font Color","yop-poll"),editorRef:c,onApply:e=>S("foreColor",e),children:(0,g.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",children:[(0,g.jsx)("text",{x:"3",y:"11",fontSize:"12",fontWeight:"bold",fontFamily:"sans-serif",fill:"currentColor",children:"A"}),(0,g.jsx)("rect",{x:"2",y:"13",width:"12",height:"2",fill:"currentColor"})]})}),(0,g.jsx)(Ae,{title:(0,b.__)("Background Color","yop-poll"),editorRef:c,onApply:e=>S("hiliteColor",e),children:(0,g.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",children:[(0,g.jsx)("rect",{x:"0",y:"0",width:"16",height:"16",rx:"2",fill:"#ffff00"}),(0,g.jsx)("text",{x:"3",y:"12",fontSize:"12",fontWeight:"bold",fontFamily:"sans-serif",fill:"#333",children:"A"})]})}),(0,g.jsx)("span",{className:"yop-poll-rte__separator"}),(0,g.jsx)(ke,{title:(0,b.__)("Bold","yop-poll"),onClick:()=>S("bold"),active:w.bold,children:(0,g.jsx)("strong",{children:"B"})}),(0,g.jsx)(ke,{title:(0,b.__)("Italic","yop-poll"),onClick:()=>S("italic"),active:w.italic,children:(0,g.jsx)("em",{children:"I"})}),(0,g.jsx)(ke,{title:(0,b.__)("Underline","yop-poll"),onClick:()=>S("underline"),active:w.underline,children:(0,g.jsx)("span",{style:{textDecoration:"underline"},children:"U"})}),!r&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("span",{className:"yop-poll-rte__separator"}),(0,g.jsx)(ke,{title:(0,b.__)("Align Left","yop-poll"),onClick:()=>S("justifyLeft"),active:"left"===P,children:(0,g.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,g.jsx)("rect",{x:"3",y:"4",width:"18",height:"2"}),(0,g.jsx)("rect",{x:"3",y:"9",width:"12",height:"2"}),(0,g.jsx)("rect",{x:"3",y:"14",width:"18",height:"2"}),(0,g.jsx)("rect",{x:"3",y:"19",width:"12",height:"2"})]})}),(0,g.jsx)(ke,{title:(0,b.__)("Align Center","yop-poll"),onClick:()=>S("justifyCenter"),active:"center"===P,children:(0,g.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,g.jsx)("rect",{x:"3",y:"4",width:"18",height:"2"}),(0,g.jsx)("rect",{x:"6",y:"9",width:"12",height:"2"}),(0,g.jsx)("rect",{x:"3",y:"14",width:"18",height:"2"}),(0,g.jsx)("rect",{x:"6",y:"19",width:"12",height:"2"})]})}),(0,g.jsx)(ke,{title:(0,b.__)("Align Right","yop-poll"),onClick:()=>S("justifyRight"),active:"right"===P,children:(0,g.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,g.jsx)("rect",{x:"3",y:"4",width:"18",height:"2"}),(0,g.jsx)("rect",{x:"9",y:"9",width:"12",height:"2"}),(0,g.jsx)("rect",{x:"3",y:"14",width:"18",height:"2"}),(0,g.jsx)("rect",{x:"9",y:"19",width:"12",height:"2"})]})})]}),!p&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("span",{className:"yop-poll-rte__separator"}),(0,g.jsx)(ke,{title:(0,b.__)("Link","yop-poll"),onClick:T,active:_,children:(0,g.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,g.jsx)("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),(0,g.jsx)("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})]}),s&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("span",{className:"yop-poll-rte__toolbar-spacer"}),s]})]}),_&&(0,g.jsxs)("div",{className:"yop-poll-rte__link-row",children:[(0,g.jsx)("input",{type:"text",className:"yop-poll-rte__link-input",value:y,onChange:e=>h(e.target.value),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),E()):"Escape"===e.key&&L()},placeholder:"https://...",autoFocus:!0}),(0,g.jsx)("button",{type:"button",className:"yop-poll-rte__link-btn yop-poll-rte__link-btn--apply",onMouseDown:e=>{e.preventDefault(),E()},title:(0,b.__)("Apply","yop-poll"),children:"✓"}),(0,g.jsx)("button",{type:"button",className:"yop-poll-rte__link-btn yop-poll-rte__link-btn--cancel",onMouseDown:e=>{e.preventDefault(),L()},title:(0,b.__)("Cancel","yop-poll"),children:"✕"})]}),i,(0,g.jsx)("div",{ref:c,className:"yop-poll-rte__editor",contentEditable:!0,suppressContentEditableWarning:!0,onInput:N,onClick:k,style:d,"data-placeholder":o||(0,b.__)("Start typing here...","yop-poll")}),f&&(0,g.jsx)(x.Popover,{anchor:f,placement:"bottom",onClose:()=>j(null),shift:!0,focusOnMount:!1,children:(0,g.jsxs)("div",{className:"yop-poll-rte__link-tooltip",onMouseDown:e=>e.preventDefault(),children:[(0,g.jsx)("span",{className:"yop-poll-rte__link-tooltip-url",children:f.getAttribute("href")}),(0,g.jsx)("span",{className:"yop-poll-rte__link-tooltip-sep"}),(0,g.jsx)("button",{type:"button",className:"yop-poll-rte__link-tooltip-action",onMouseDown:e=>{e.preventDefault(),A()},children:(0,b.__)("Edit","yop-poll")}),(0,g.jsx)("span",{className:"yop-poll-rte__link-tooltip-sep"}),(0,g.jsx)("button",{type:"button",className:"yop-poll-rte__link-tooltip-action",onMouseDown:e=>{e.preventDefault(),R()},children:(0,b.__)("Unlink","yop-poll")})]})}),a]})}const Le=[(0,b.__)("January","yop-poll"),(0,b.__)("February","yop-poll"),(0,b.__)("March","yop-poll"),(0,b.__)("April","yop-poll"),(0,b.__)("May","yop-poll"),(0,b.__)("June","yop-poll"),(0,b.__)("July","yop-poll"),(0,b.__)("August","yop-poll"),(0,b.__)("September","yop-poll"),(0,b.__)("October","yop-poll"),(0,b.__)("November","yop-poll"),(0,b.__)("December","yop-poll")],De=["M","T","W","T","F","S","S"];function Pe(e){if(!e)return"";const l=new Date(e);if(isNaN(l.getTime()))return"";const o=l.getHours(),t=l.getMinutes(),s=o>=12?"pm":"am";return`${o%12||12}:${String(t).padStart(2,"0")} ${s} ${Le[l.getMonth()]} ${l.getDate()}, ${l.getFullYear()}`}function Be({value:e,onApply:l,onClose:o}){const t=(()=>{const l=e?new Date(e):new Date;return isNaN(l.getTime())?new Date:l})(),[s,a]=(0,n.useState)(t.getFullYear()),[i,r]=(0,n.useState)(t.getMonth()),[p,d]=(0,n.useState)(t.getFullYear()),[c,u]=(0,n.useState)(t.getMonth()),[_,m]=(0,n.useState)(t.getDate()),[y,h]=(0,n.useState)(t.getHours()),[x,v]=(0,n.useState)(t.getMinutes()),f=new Date,j=(0,n.useCallback)(()=>{0===i?(r(11),a(e=>e-1)):r(e=>e-1)},[i]),w=(0,n.useCallback)(()=>{11===i?(r(0),a(e=>e+1)):r(e=>e+1)},[i]),C=(0,n.useCallback)(e=>{m(e),u(i),d(s)},[i,s]),N=(0,n.useCallback)(()=>{const e=new Date;a(e.getFullYear()),r(e.getMonth()),d(e.getFullYear()),u(e.getMonth()),m(e.getDate()),h(e.getHours()),v(e.getMinutes())},[]),S=(0,n.useCallback)(()=>{const e=new Date(p,c,_,y,x);l(e.toISOString()),o()},[p,c,_,y,x,l,o]),k=new Date(s,i+1,0).getDate(),A=new Date(s,i,1).getDay(),R=0===A?6:A-1,T=[];for(let e=0;e<R;e++)T.push(null);for(let e=1;e<=k;e++)T.push(e);const E=e=>e===f.getDate()&&i===f.getMonth()&&s===f.getFullYear(),L=e=>e===_&&i===c&&s===p,D=`${String(y).padStart(2,"0")}:${String(x).padStart(2,"0")}`;return(0,g.jsxs)("div",{className:"yop-poll-datepicker",children:[(0,g.jsxs)("div",{className:"yop-poll-datepicker__header",children:[(0,g.jsx)("button",{type:"button",className:"yop-poll-datepicker__nav-btn",onMouseDown:e=>{e.preventDefault(),j()},children:"◀"}),(0,g.jsxs)("span",{className:"yop-poll-datepicker__month-label",children:[Le[i]," ",s]}),(0,g.jsx)("button",{type:"button",className:"yop-poll-datepicker__nav-btn",onMouseDown:e=>{e.preventDefault(),w()},children:"▶"})]}),(0,g.jsxs)("div",{className:"yop-poll-datepicker__grid",children:[De.map((e,l)=>(0,g.jsx)("div",{className:"yop-poll-datepicker__day-header",children:e},l)),T.map((e,l)=>(0,g.jsx)("div",{className:["yop-poll-datepicker__cell",!e&&"yop-poll-datepicker__cell--empty",e&&E(e)&&!L(e)&&"yop-poll-datepicker__cell--today",e&&L(e)&&"yop-poll-datepicker__cell--selected"].filter(Boolean).join(" "),onMouseDown:l=>{l.preventDefault(),e&&C(e)},children:e},l))]}),(0,g.jsxs)("div",{className:"yop-poll-datepicker__time-section",children:[(0,g.jsxs)("div",{className:"yop-poll-datepicker__time-display",children:[(0,g.jsx)("span",{children:(0,b.__)("Time","yop-poll")}),(0,g.jsx)("span",{className:"yop-poll-datepicker__time-value",children:D})]}),(0,g.jsxs)("div",{className:"yop-poll-datepicker__time-row",children:[(0,g.jsx)("label",{className:"yop-poll-datepicker__time-label",children:(0,b.__)("Hour","yop-poll")}),(0,g.jsx)("input",{type:"range",className:"yop-poll-datepicker__time-slider",min:"0",max:"23",value:y,onChange:e=>h(Number(e.target.value))})]}),(0,g.jsxs)("div",{className:"yop-poll-datepicker__time-row",children:[(0,g.jsx)("label",{className:"yop-poll-datepicker__time-label",children:(0,b.__)("Minute","yop-poll")}),(0,g.jsx)("input",{type:"range",className:"yop-poll-datepicker__time-slider",min:"0",max:"59",value:x,onChange:e=>v(Number(e.target.value))})]})]}),(0,g.jsxs)("div",{className:"yop-poll-datepicker__footer",children:[(0,g.jsx)("button",{type:"button",className:"yop-poll-datepicker__btn yop-poll-datepicker__btn--secondary",onMouseDown:e=>{e.preventDefault(),N()},children:(0,b.__)("Now","yop-poll")}),(0,g.jsx)("button",{type:"button",className:"yop-poll-datepicker__btn yop-poll-datepicker__btn--primary",onMouseDown:e=>{e.preventDefault(),S()},children:(0,b.__)("Done","yop-poll")})]})]})}function Ie({label:e,value:l,onChange:o}){const[t,s]=(0,n.useState)(!1),a=(0,n.useRef)(null);return(0,g.jsxs)("div",{className:"yop-poll-options-form__field",children:[e&&(0,g.jsx)("label",{className:"yop-poll-options-form__label",children:e}),(0,g.jsxs)("div",{className:"yop-poll-properties__date-input-wrap",children:[(0,g.jsx)("input",{type:"text",className:"yop-poll-properties__date-input",value:Pe(l),readOnly:!0,placeholder:(0,b.__)("Click to choose a date","yop-poll")}),(0,g.jsx)("button",{ref:a,type:"button",className:"yop-poll-properties__date-btn",onClick:()=>s(e=>!e),children:(0,g.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,g.jsx)("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),(0,g.jsx)("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),(0,g.jsx)("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),(0,g.jsx)("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]})})]}),t&&(0,g.jsx)(x.Popover,{anchor:a.current,placement:"bottom-end",onClose:()=>s(!1),shift:!0,focusOnMount:!1,children:(0,g.jsx)(Be,{value:l,onApply:o,onClose:()=>s(!1)})})]})}function Me({sub:e,subKey:l,onUpdate:o,onSetDefault:t,isMultiple:s}){const a=e.meta_data||{},[i,r]=(0,n.useState)(!1),p=a.resultsColor||"#058dc7",d=(0,n.useCallback)((e,n)=>{"makeDefault"!==e?o(l,{meta_data:{...a,[e]:n?"1":"0"}}):s?o(l,{meta_data:{...a,makeDefault:n?"1":"0"}}):t(n?l:null)},[l,a,o,t,s]),c=(0,n.useCallback)(e=>{o(l,{meta_data:{...a,resultsColor:e}})},[l,a,o]);return(0,g.jsxs)("div",{className:"yop-poll-answer-expand",children:[(0,g.jsxs)("label",{className:"yop-poll-answer-expand__checkbox",children:[(0,g.jsx)("input",{type:"checkbox",checked:"1"===a.makeDefault,onChange:e=>d("makeDefault",e.target.checked)}),(0,b.__)("Set As Default","yop-poll")]}),(0,g.jsxs)("label",{className:"yop-poll-answer-expand__checkbox",children:[(0,g.jsx)("input",{type:"checkbox",checked:"1"===a.makeLink,onChange:e=>d("makeLink",e.target.checked)}),(0,b.__)("Make it a link","yop-poll")]}),"1"===a.makeLink&&(0,g.jsxs)("div",{children:[(0,g.jsx)("span",{className:"yop-poll-answer-expand__color-label",children:(0,b.__)("Link","yop-poll")}),(0,g.jsx)("input",{type:"text",className:"yop-poll-answer-expand__link-input",value:a.link||"",onChange:e=>o(l,{meta_data:{...a,link:e.target.value}}),placeholder:(0,b.__)("https://...","yop-poll")})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("span",{className:"yop-poll-answer-expand__color-label",children:(0,b.__)("Results Color","yop-poll")}),(0,g.jsxs)("div",{className:"yop-poll-answer-expand__color-field",children:[(0,g.jsx)("button",{type:"button",className:"yop-poll-answer-expand__color-swatch",style:{background:p},onClick:()=>r(!i)}),(0,g.jsx)("input",{type:"text",className:"yop-poll-answer-expand__color-input",value:p,onChange:e=>c(e.target.value)})]}),i&&(0,g.jsx)(x.Popover,{placement:"bottom-start",onClose:()=>r(!1),shift:!0,focusOnMount:!1,children:(0,g.jsx)("div",{style:{padding:0},children:(0,g.jsx)(x.ColorPicker,{color:p,onChange:c,enableAlpha:!1})})})]})]})}function Oe({sub:e,subKey:l,onAnswerChange:o,onRemoveAnswer:t,onUpdateMeta:s,onSetDefault:a,isMultiple:i,ansStyle:r}){const[p,d]=(0,n.useState)(!1);return(0,g.jsx)(Ee,{value:e.stext||"",onChange:e=>o(l,e),placeholder:(0,b.__)("Answer Text Here","yop-poll"),hideAlign:!0,hideLink:!0,editorStyle:{minHeight:"40px",padding:"8px 12px",...r?.color?{color:r.color}:{},...r?.backgroundColor?{backgroundColor:r.backgroundColor}:{},...r?.fontSize?{fontSize:r.fontSize}:{},...r?.fontWeight?{fontWeight:r.fontWeight}:{}},leftSlot:(0,g.jsx)("button",{type:"button",className:"yop-poll-rte__action-btn",title:(0,b.__)("Drag to reorder","yop-poll"),style:{cursor:"grab"},children:(0,g.jsx)(w,{icon:z,size:18})}),rightSlot:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("button",{type:"button",className:"yop-poll-rte__action-btn"+(p?" yop-poll-rte__action-btn--active":""),title:(0,b.__)("Expand options","yop-poll"),onClick:()=>d(!p),children:(0,g.jsx)(w,{icon:we,size:18})}),(0,g.jsx)("button",{type:"button",className:"yop-poll-rte__action-btn yop-poll-rte__action-btn--danger",onClick:()=>t(l),title:(0,b.__)("Delete","yop-poll"),children:(0,g.jsx)(w,{icon:F,size:18})})]}),footerSlot:p?(0,g.jsx)(Me,{sub:e,subKey:l,onUpdate:s,onSetDefault:a,isMultiple:i}):null})}function ze({element:e}){const{updateElement:l,addSubelement:o,updateSubelement:t,removeSubelement:s,setDefaultSubelement:a}=(0,i.useDispatch)(r),{elStyle:p,ansStyle:d}=(0,i.useSelect)(e=>{const l=e(r).getPoll(),o="string"==typeof l.meta_data?JSON.parse(l.meta_data):l.meta_data||{},t=o.style?.questions||{},s=o.style?.answers||{},a=o.style?.poll?.backgroundColor||"";return{elStyle:{color:t.textColor||"",backgroundColor:t.textColor?a:"",fontSize:t.textSize?t.textSize+"px":"",fontWeight:t.textWeight||"",textAlign:t.textAlign||""},ansStyle:{color:s.textColor||"",backgroundColor:s.textColor?a:"",fontSize:s.textSize?s.textSize+"px":"",fontWeight:s.textWeight||""}}}),[c,u]=(0,n.useState)(!1);if(!e)return(0,g.jsx)("div",{className:"yop-poll-properties",children:(0,g.jsx)("p",{style:{color:"#888",fontSize:"13px"},children:(0,b.__)("Select an element on the canvas to edit its properties.","yop-poll")})});const _=U(e.etype),m=e.id||e._tempId,y=(e,l)=>{t(m,e,{stext:l})},h=e=>{s(m,e)},x=(e,l)=>{t(m,e,l)},v=e=>{a(m,e)};return(0,g.jsxs)("div",{className:"yop-poll-properties",children:[(0,g.jsx)("div",{className:"yop-poll-properties__title",children:_?.label||e.etype}),"standard-captcha"!==e.etype&&"standard-gdpr"!==e.etype&&(0,g.jsxs)("div",{className:"yop-poll-properties__field",children:[(0,g.jsx)("label",{className:"yop-poll-properties__label",children:(0,b.__)("Element Text","yop-poll")}),(0,g.jsx)(Ee,{value:e.etext||"",onChange:e=>{l(m,{etext:e})},placeholder:(0,b.__)("Enter element text…","yop-poll"),editorStyle:{textAlign:p.textAlign||(_?.hasSubelements?"center":void 0),...p.color?{color:p.color}:{},...p.backgroundColor?{backgroundColor:p.backgroundColor}:{},...p.fontSize?{fontSize:p.fontSize}:{},...p.fontWeight?{fontWeight:p.fontWeight}:{}}})]}),_?.hasSubelements&&(0,g.jsxs)("div",{className:"yop-poll-properties__field",children:[(0,g.jsxs)("div",{className:"yop-poll-properties__answers-header",children:[(0,g.jsx)("label",{className:"yop-poll-properties__label",children:(0,b.__)("Answers","yop-poll")}),(0,g.jsxs)("div",{className:"yop-poll-properties__answers-actions",children:[(0,g.jsx)("button",{type:"button",className:"yop-poll-properties__add-btn",onClick:()=>u(!0),title:(0,b.__)("Import from CSV","yop-poll"),children:(0,g.jsx)(w,{icon:Ce,size:20})}),(0,g.jsx)("button",{type:"button",className:"yop-poll-properties__add-btn",onClick:()=>{const l=(e.subelements||[]).length;o(m,{stext:`Answer ${l+1}`,stype:"text",status:"active",meta_data:{}})},title:(0,b.__)("Add Answer","yop-poll"),children:(0,g.jsx)(w,{icon:Ne,size:20})})]})]}),(e.subelements||[]).map(l=>{const o=l.id||l._tempId,t=e.meta_data&&"object"==typeof e.meta_data?e.meta_data:{};return(0,g.jsx)(Oe,{sub:l,subKey:o,onAnswerChange:y,onRemoveAnswer:h,onUpdateMeta:x,onSetDefault:v,isMultiple:"yes"===t.allowMultipleAnswers,ansStyle:d},o)})]}),_?.hasSubelements&&(0,g.jsx)(Ve,{element:e,elementKey:m,onUpdate:l}),"standard-single-line-text"===e.etype&&(0,g.jsx)(qe,{element:e,elementKey:m,onUpdate:l}),"standard-captcha"===e.etype&&(0,g.jsx)(We,{element:e,elementKey:m,onUpdate:l}),c&&(0,g.jsx)(ve,{open:c,onClose:()=>u(!1)})]})}function Ve({element:e,elementKey:l,onUpdate:o}){const t=e.meta_data&&"object"==typeof e.meta_data?e.meta_data:{},[s,a]=(0,n.useState)(!1),i=(e,s)=>{o(l,{meta_data:{...t,[e]:s}})};return(0,n.useEffect)(()=>{if("yes"!==t.allowOtherAnswers)return;const e={};t.otherAnswersLabel||(e.otherAnswersLabel="Other"),void 0===t.otherAnswersCount&&(e.otherAnswersCount=1),t.otherFieldType||(e.otherFieldType="single-line"),t.otherFieldSize||(e.otherFieldSize="small"),void 0===t.otherMaxCharsAllowed&&(e.otherMaxCharsAllowed="0"),t.addOtherAnswers||(e.addOtherAnswers="no"),t.displayOtherAnswersInResults||(e.displayOtherAnswersInResults="no"),t.resultsColorForOtherAnswers||(e.resultsColorForOtherAnswers="#058dc7"),0!==Object.keys(e).length&&o(l,{meta_data:{...t,...e}})},[l]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"yop-poll-properties__field",children:[(0,g.jsx)("div",{className:"yop-poll-properties__options-title",children:(0,b.__)("Options","yop-poll")}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Required","yop-poll")}),(0,g.jsxs)("select",{className:"yop-poll-properties__option-select",value:t.makeRequired||"yes",onChange:e=>i("makeRequired",e.target.value),children:[(0,g.jsx)("option",{value:"yes",children:(0,b.__)("Yes","yop-poll")}),(0,g.jsx)("option",{value:"no",children:(0,b.__)("No","yop-poll")})]})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Allow other answers","yop-poll")}),(0,g.jsxs)("select",{className:"yop-poll-properties__option-select",value:t.allowOtherAnswers||"no",onChange:e=>{const s=e.target.value,a="yes"===s?{...t.otherAnswersLabel?{}:{otherAnswersLabel:"Other"},...void 0===t.otherAnswersCount?{otherAnswersCount:1}:{},...t.otherFieldType?{}:{otherFieldType:"single-line"},...t.otherFieldSize?{}:{otherFieldSize:"small"},...void 0===t.otherMaxCharsAllowed?{otherMaxCharsAllowed:"0"}:{},...t.addOtherAnswers?{}:{addOtherAnswers:"no"},...t.displayOtherAnswersInResults?{}:{displayOtherAnswersInResults:"no"},...t.resultsColorForOtherAnswers?{}:{other_resultsColor:"#058dc7"}}:{};o(l,{meta_data:{...t,allowOtherAnswers:s,...a}})},children:[(0,g.jsx)("option",{value:"yes",children:(0,b.__)("Yes","yop-poll")}),(0,g.jsx)("option",{value:"no",children:(0,b.__)("No","yop-poll")})]})]}),"yes"===t.allowOtherAnswers&&(0,g.jsx)(Fe,{meta:t,onChange:i,onProClick:()=>a(!0)}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Allow multiple answers","yop-poll")}),(0,g.jsxs)("select",{className:"yop-poll-properties__option-select",value:t.allowMultipleAnswers||"no",onChange:e=>i("allowMultipleAnswers",e.target.value),children:[(0,g.jsx)("option",{value:"yes",children:(0,b.__)("Yes","yop-poll")}),(0,g.jsx)("option",{value:"no",children:(0,b.__)("No","yop-poll")})]})]}),"question-text"===e.etype&&"yes"===t.allowMultipleAnswers&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Minimum answers required","yop-poll")}),(0,g.jsx)("input",{type:"number",className:"yop-poll-properties__option-input",value:void 0!==t.multipleAnswersMinim?t.multipleAnswersMinim:"",onChange:e=>i("multipleAnswersMinim",e.target.value),min:"1"})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Maximum answers allowed","yop-poll")}),(0,g.jsx)("input",{type:"number",className:"yop-poll-properties__option-input",value:void 0!==t.multipleAnswersMaxim?t.multipleAnswersMaxim:"",onChange:e=>i("multipleAnswersMaxim",e.target.value),min:"1"})]})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Display answers","yop-poll")}),(0,g.jsxs)("select",{className:"yop-poll-properties__option-select",value:t.answersDisplay||"vertical",onChange:e=>i("answersDisplay",e.target.value),children:[(0,g.jsx)("option",{value:"vertical",children:(0,b.__)("Vertical","yop-poll")}),(0,g.jsx)("option",{value:"horizontal",children:(0,b.__)("Horizontal","yop-poll")}),(0,g.jsx)("option",{value:"columns",children:(0,b.__)("Columns","yop-poll")})]})]}),"columns"===t.answersDisplay&&(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Number of columns","yop-poll")}),(0,g.jsxs)("select",{className:"yop-poll-properties__option-select",value:t.answersColumns||"2",onChange:e=>i("answersColumns",e.target.value),children:[(0,g.jsx)("option",{value:"2",children:"2"}),(0,g.jsx)("option",{value:"3",children:"3"}),(0,g.jsx)("option",{value:"4",children:"4"})]})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsxs)("label",{className:"yop-poll-properties__option-label",style:{display:"flex",alignItems:"center",gap:"6px"},children:[(0,g.jsx)("span",{className:"yop-poll-pro-badge",children:"PRO"}),(0,b.__)("Sort Answers","yop-poll")]}),(0,g.jsxs)("select",{className:"yop-poll-properties__option-select",value:t.answersSort||"as-defined",onChange:e=>{"as-defined"!==e.target.value?a(!0):i("answersSort",e.target.value)},children:[(0,g.jsx)("option",{value:"as-defined",children:(0,b.__)("As Defined","yop-poll")}),(0,g.jsx)("option",{value:"alphabetical-asc",children:(0,b.__)("Alphabetically Ascending","yop-poll")}),(0,g.jsx)("option",{value:"alphabetical-desc",children:(0,b.__)("Alphabetically Descending","yop-poll")}),(0,g.jsx)("option",{value:"votes-asc",children:(0,b.__)("By Number Of Votes Ascending","yop-poll")}),(0,g.jsx)("option",{value:"votes-desc",children:(0,b.__)("By Number Of Votes Descending","yop-poll")}),(0,g.jsx)("option",{value:"random",children:(0,b.__)("Randomly","yop-poll")})]})]})]}),s&&(0,g.jsx)(ve,{open:s,onClose:()=>a(!1)})]})}function Fe({meta:e,onChange:l,onProClick:o}){const[t,s]=(0,n.useState)(!1),a=e.resultsColorForOtherAnswers||"#058dc7",i="number"==typeof e.otherAnswersCount?e.otherAnswersCount:1;return(0,g.jsxs)("div",{className:"yop-poll-properties__other-answers",children:[(0,g.jsxs)("div",{className:"yop-poll-properties__other-answers-header",children:[(0,g.jsxs)("span",{className:"yop-poll-properties__option-label",children:[(0,b.__)("Other Answers","yop-poll"),(0,g.jsxs)("span",{className:"yop-poll-properties__other-count",children:["(",i,")"]})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__answers-actions",children:[(0,g.jsx)("button",{type:"button",className:"yop-poll-properties__add-btn",onClick:()=>{i>1&&l("otherAnswersCount",i-1)},title:(0,b.__)("Remove Other Answer","yop-poll"),disabled:i<=1,children:(0,g.jsx)("span",{className:"yop-poll-properties__plus-minus",children:"−"})}),(0,g.jsx)("button",{type:"button",className:"yop-poll-properties__add-btn",onClick:()=>{i>=1?o?.():l("otherAnswersCount",i+1)},title:(0,b.__)("Add Other Answer","yop-poll"),children:(0,g.jsx)("span",{className:"yop-poll-properties__plus-minus",children:"+"})})]})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Label for Other Answers","yop-poll")}),(0,g.jsx)(Ee,{value:e.otherAnswersLabel||"Other",onChange:e=>l("otherAnswersLabel",e),placeholder:(0,b.__)("Other","yop-poll"),hideAlign:!0,hideLink:!0,editorStyle:{minHeight:"40px",padding:"8px 12px"}})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsxs)("label",{className:"yop-poll-properties__option-label",style:{display:"flex",alignItems:"center",gap:"6px"},children:[(0,g.jsx)("span",{className:"yop-poll-pro-badge",children:"PRO"}),(0,b.__)("Field Type","yop-poll")]}),(0,g.jsxs)("select",{className:"yop-poll-properties__option-select",value:e.otherFieldType||"single-line",onChange:e=>{"multi-line"===e.target.value?o?.():l("otherFieldType",e.target.value)},children:[(0,g.jsx)("option",{value:"single-line",children:(0,b.__)("Single Line Text","yop-poll")}),(0,g.jsx)("option",{value:"multi-line",children:(0,b.__)("Multi Line Text","yop-poll")})]})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Size","yop-poll")}),(0,g.jsxs)("select",{className:"yop-poll-properties__option-select",value:e.otherFieldSize||"small",onChange:e=>l("otherFieldSize",e.target.value),children:[(0,g.jsx)("option",{value:"small",children:(0,b.__)("Small","yop-poll")}),(0,g.jsx)("option",{value:"medium",children:(0,b.__)("Medium","yop-poll")}),(0,g.jsx)("option",{value:"large",children:(0,b.__)("Large","yop-poll")})]})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Number of chars allowed ( set to 0 for unlimited )","yop-poll")}),(0,g.jsx)("input",{type:"number",className:"yop-poll-properties__option-select",value:e.otherMaxCharsAllowed||"0",onChange:e=>l("otherMaxCharsAllowed",e.target.value),min:"0"})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Add other answers in answers list","yop-poll")}),(0,g.jsxs)("select",{className:"yop-poll-properties__option-select",value:e.addOtherAnswers||"no",onChange:e=>l("addOtherAnswers",e.target.value),children:[(0,g.jsx)("option",{value:"yes",children:(0,b.__)("Yes","yop-poll")}),(0,g.jsx)("option",{value:"no",children:(0,b.__)("No","yop-poll")})]})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Display other answers in results list","yop-poll")}),(0,g.jsxs)("select",{className:"yop-poll-properties__option-select",value:e.displayOtherAnswersInResults||"no",onChange:e=>l("displayOtherAnswersInResults",e.target.value),children:[(0,g.jsx)("option",{value:"yes",children:(0,b.__)("Yes","yop-poll")}),(0,g.jsx)("option",{value:"no",children:(0,b.__)("No","yop-poll")})]})]}),"yes"===e.displayOtherAnswersInResults&&(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Results Color","yop-poll")}),(0,g.jsxs)("div",{className:"yop-poll-answer-expand__color-field",children:[(0,g.jsx)("button",{type:"button",className:"yop-poll-answer-expand__color-swatch",style:{background:a},onClick:()=>s(!t)}),(0,g.jsx)("input",{type:"text",className:"yop-poll-answer-expand__color-input",value:a,onChange:e=>l("resultsColorForOtherAnswers",e.target.value)})]}),t&&(0,g.jsx)(x.Popover,{placement:"bottom-start",onClose:()=>s(!1),shift:!0,focusOnMount:!1,children:(0,g.jsx)("div",{style:{padding:0},children:(0,g.jsx)(x.ColorPicker,{color:a,onChange:e=>l("resultsColorForOtherAnswers",e),enableAlpha:!1})})})]})]})}function qe({element:e,elementKey:l,onUpdate:o}){const t=e.meta_data&&"object"==typeof e.meta_data?e.meta_data:{},s=(0,n.useCallback)((e,s)=>{o(l,{meta_data:{...t,[e]:s}})},[l,t,o]);return(0,g.jsxs)("div",{className:"yop-poll-properties__field",children:[(0,g.jsx)("div",{className:"yop-poll-properties__options-title",children:(0,b.__)("Options","yop-poll")}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Required","yop-poll")}),(0,g.jsxs)("select",{className:"yop-poll-properties__option-select",value:t.makeRequired||"no",onChange:e=>s("makeRequired",e.target.value),children:[(0,g.jsx)("option",{value:"yes",children:(0,b.__)("Yes","yop-poll")}),(0,g.jsx)("option",{value:"no",children:(0,b.__)("No","yop-poll")})]})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Size","yop-poll")}),(0,g.jsxs)("select",{className:"yop-poll-properties__option-select",value:t.size||"small",onChange:e=>s("size",e.target.value),children:[(0,g.jsx)("option",{value:"small",children:(0,b.__)("Small","yop-poll")}),(0,g.jsx)("option",{value:"medium",children:(0,b.__)("Medium","yop-poll")}),(0,g.jsx)("option",{value:"large",children:(0,b.__)("Large","yop-poll")})]})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Align","yop-poll")}),(0,g.jsxs)("select",{className:"yop-poll-properties__option-select",value:t.align||"left",onChange:e=>s("align",e.target.value),children:[(0,g.jsx)("option",{value:"left",children:(0,b.__)("Left","yop-poll")}),(0,g.jsx)("option",{value:"center",children:(0,b.__)("Center","yop-poll")}),(0,g.jsx)("option",{value:"right",children:(0,b.__)("Right","yop-poll")})]})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Number of chars allowed ( set to 0 for unlimited )","yop-poll")}),(0,g.jsx)("input",{type:"number",className:"yop-poll-properties__option-input",value:t.maxCharsAllowed||0,onChange:e=>s("maxCharsAllowed",e.target.value),min:"0"})]})]})}function We({element:e,elementKey:l,onUpdate:o}){const t=e.meta_data&&"object"==typeof e.meta_data?e.meta_data:{},s=(0,n.useCallback)((e,s)=>{o(l,{meta_data:{...t,[e]:s}})},[l,t,o]),a=(0,n.useRef)(null),i=[{value:"built_in",label:(0,b.__)("Built In","yop-poll")},{value:"recaptcha_v2_checkbox",label:(0,b.__)("reCaptcha v2 Checkbox","yop-poll")},{value:"recaptcha_v2_invisible",label:(0,b.__)("reCaptcha v2 Invisible","yop-poll")},{value:"recaptcha_v3",label:(0,b.__)("reCaptcha v3","yop-poll")},{value:"hcaptcha",label:(0,b.__)("hCaptcha","yop-poll")},{value:"turnstile",label:(0,b.__)("Cloudflare Turnstile","yop-poll")}],r=t.captcha_type||"built_in";return(0,g.jsxs)("div",{className:"yop-poll-properties__field",children:[(0,g.jsx)("div",{className:"yop-poll-properties__options-title",children:(0,b.__)("Captcha Section","yop-poll")}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Type","yop-poll")}),(0,g.jsx)("select",{className:"yop-poll-properties__option-select",value:r,onChange:e=>s("captcha_type",e.target.value),children:i.map(({value:e,label:l})=>(0,g.jsx)("option",{value:e,children:l},e))})]}),"built_in"===r&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"yop-poll-properties__option yop-poll-properties__option--column",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Question","yop-poll")}),(0,g.jsx)(Ee,{value:t.question_template||"",onChange:e=>s("question_template",e),placeholder:(0,b.__)("Click or touch the %ANSWER%","yop-poll"),hideAlign:!0,belowToolbarSlot:(0,g.jsx)("div",{className:"yop-poll-rte__insert-row",children:(0,g.jsx)("button",{type:"button",className:"yop-poll-rte__insert-btn",title:(0,b.__)("Insert answer token","yop-poll"),onMouseOver:()=>{const e=window.getSelection();e.rangeCount>0&&(a.current=e.getRangeAt(0).cloneRange())},onMouseDown:e=>{e.preventDefault();const l=window.getSelection();a.current&&(l.removeAllRanges(),l.addRange(a.current)),document.execCommand("insertText",!1,"%ANSWER%")},children:(0,b.__)("%ANSWER%","yop-poll")})})})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Align","yop-poll")}),(0,g.jsxs)("select",{className:"yop-poll-properties__option-select",value:t.question_align||"left",onChange:e=>s("question_align",e.target.value),children:[(0,g.jsx)("option",{value:"left",children:(0,b.__)("Left","yop-poll")}),(0,g.jsx)("option",{value:"center",children:(0,b.__)("Center","yop-poll")}),(0,g.jsx)("option",{value:"right",children:(0,b.__)("Right","yop-poll")})]})]})]})]})}function Ue(){const e=(0,i.useSelect)(e=>e(r).getPoll()),{setMetaField:l}=(0,i.useDispatch)(r),[o,t]=(0,n.useState)(!1),[s,a]=(0,n.useState)(!1),p="string"==typeof e.meta_data?JSON.parse(e.meta_data):e.meta_data||{},d=p.options?.poll||{},c=p.style?.buttons||{},u=(e,o)=>l("options.poll",e,o),_=(e,o)=>{const t=p.style?.buttons||{};l("style","buttons",{...t,[e]:o})},m="material"===e.template_base,y=m?"#ffffff":"#000000",h=m?"#f44336":"#ffffff",v=c.textColor||"",f=c.backgroundColor||"",j=c.align||"center",w=v||y,C=f||h;return(0,g.jsxs)("div",{className:"yop-poll-properties",children:[(0,g.jsx)("div",{className:"yop-poll-properties__title",children:(0,b.__)("Vote Button","yop-poll")}),(0,g.jsxs)("div",{className:"yop-poll-properties__field",children:[(0,g.jsx)("label",{className:"yop-poll-properties__label",children:(0,b.__)("Label","yop-poll")}),(0,g.jsx)("input",{type:"text",className:"yop-poll-properties__option-input",value:d.voteButtonLabel||"",placeholder:(0,b.__)("Vote Now","yop-poll"),onChange:e=>u("voteButtonLabel",e.target.value)})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__field",children:[(0,g.jsx)("div",{className:"yop-poll-properties__options-title",children:(0,b.__)("Options","yop-poll")}),(0,g.jsxs)("div",{className:"yop-poll-template-opt__padding-field",style:{padding:0},children:[(0,g.jsx)("span",{className:"yop-poll-template-opt__padding-label",children:(0,b.__)("Padding","yop-poll")}),(0,g.jsx)("div",{className:"yop-poll-template-opt__padding-row",children:[{key:"paddingLeftRight",label:(0,b.__)("Left/Right","yop-poll"),value:c.paddingLeftRight??16},{key:"paddingTopBottom",label:(0,b.__)("Top/Bottom","yop-poll"),value:c.paddingTopBottom??6}].map(({key:e,label:o,value:t})=>(0,g.jsxs)("div",{className:"yop-poll-template-opt__padding-side",children:[(0,g.jsx)("input",{type:"number",className:"yop-poll-template-opt__padding-input",value:t,onChange:o=>{(e=>{const o=p.style?.buttons||{};l("style","buttons",{...o,...e})})({paddingLeftRight:c.paddingLeftRight??16,paddingTopBottom:c.paddingTopBottom??6,[e]:Number(o.target.value)})}}),(0,g.jsx)("span",{className:"yop-poll-template-opt__padding-side-label",children:o})]},e))})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Align","yop-poll")}),(0,g.jsxs)("select",{className:"yop-poll-properties__option-select",value:j,onChange:e=>_("align",e.target.value),children:[(0,g.jsx)("option",{value:"left",children:(0,b.__)("Left","yop-poll")}),(0,g.jsx)("option",{value:"center",children:(0,b.__)("Center","yop-poll")}),(0,g.jsx)("option",{value:"right",children:(0,b.__)("Right","yop-poll")})]})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Text Color","yop-poll")}),(0,g.jsxs)("div",{className:"yop-poll-properties__color-input-wrap",children:[(0,g.jsx)("button",{type:"button",className:"yop-poll-properties__color-preview",style:{background:w},onClick:()=>t(!o)}),(0,g.jsx)("input",{type:"text",className:"yop-poll-properties__color-input",value:v,placeholder:y,onChange:e=>_("textColor",e.target.value)}),o&&(0,g.jsx)(x.Popover,{position:"bottom left",onClose:()=>t(!1),children:(0,g.jsx)("div",{style:{padding:"10px"},children:(0,g.jsx)(x.ColorPicker,{color:w,onChange:e=>_("textColor",e),enableAlpha:!1})})})]})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Background Color","yop-poll")}),(0,g.jsxs)("div",{className:"yop-poll-properties__color-input-wrap",children:[(0,g.jsx)("button",{type:"button",className:"yop-poll-properties__color-preview",style:{background:C},onClick:()=>a(!s)}),(0,g.jsx)("input",{type:"text",className:"yop-poll-properties__color-input",value:f,placeholder:h,onChange:e=>_("backgroundColor",e.target.value)}),s&&(0,g.jsx)(x.Popover,{position:"bottom left",onClose:()=>a(!1),children:(0,g.jsx)("div",{style:{padding:"10px"},children:(0,g.jsx)(x.ColorPicker,{color:"transparent"===C?"#ffffff":C,onChange:e=>_("backgroundColor",e),enableAlpha:!1})})})]})]}),(0,g.jsxs)("div",{className:"yop-poll-properties__option",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Show Results Button","yop-poll")}),(0,g.jsxs)("select",{className:"yop-poll-properties__option-select",value:d.showResultsLink||"no",onChange:e=>u("showResultsLink",e.target.value),children:[(0,g.jsx)("option",{value:"no",children:(0,b.__)("No","yop-poll")}),(0,g.jsx)("option",{value:"yes",children:(0,b.__)("Yes","yop-poll")})]})]}),"yes"===(d.showResultsLink||"no")&&(0,g.jsxs)("div",{className:"yop-poll-properties__option yop-poll-properties__option--indented",children:[(0,g.jsx)("label",{className:"yop-poll-properties__option-label",children:(0,b.__)("Label","yop-poll")}),(0,g.jsx)("input",{type:"text",className:"yop-poll-properties__option-input",value:void 0!==d.resultsLabelText?d.resultsLabelText:(0,b.__)("Results","yop-poll"),onChange:e=>u("resultsLabelText",e.target.value)})]})]})]})}function $e(){const{sidebarMode:e,selectedElement:l,selectedElementId:o}=(0,i.useSelect)(e=>({sidebarMode:e(r).getSidebarMode(),selectedElement:e(r).getSelectedElement(),selectedElementId:e(r).getSelectedElementId()})),{setSidebarMode:t}=(0,i.useDispatch)(r);return(0,g.jsxs)("div",{className:"yop-poll-two-panel__sidebar",children:[(0,g.jsxs)("div",{className:"yop-poll-sidebar-toggle",children:[(0,g.jsx)("button",{className:"yop-poll-sidebar-toggle__btn "+(e===y?"yop-poll-sidebar-toggle__btn--active":""),onClick:()=>t(y),children:(0,b.__)("Layout","yop-poll")}),(0,g.jsx)("button",{className:"yop-poll-sidebar-toggle__btn "+(e===h?"yop-poll-sidebar-toggle__btn--active":""),onClick:()=>t(h),children:(0,b.__)("Properties","yop-poll")})]}),(0,g.jsx)("div",{className:"yop-poll-sidebar__content",children:e===y?(0,g.jsx)(He,{}):"__vote-button__"===o?(0,g.jsx)(Ue,{}):(0,g.jsx)(ze,{element:l})})]})}function He(){const e=W(p),l=W(d),o=W(c),[t,s]=(0,n.useState)(!1);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(k,{title:(0,b.__)("Questions","yop-poll"),defaultOpen:!0,children:(0,g.jsx)("div",{className:"yop-poll-element-grid",children:e.map(e=>(0,g.jsx)(je,{elementType:e,onProClick:()=>s(!0)},e.type))})}),(0,g.jsx)(k,{title:(0,b.__)("Standard Elements","yop-poll"),defaultOpen:!0,children:(0,g.jsx)("div",{className:"yop-poll-element-grid",children:l.map(e=>(0,g.jsx)(je,{elementType:e,onProClick:()=>s(!0)},e.type))})}),(0,g.jsx)(k,{title:(0,b.__)("Advanced Elements","yop-poll"),defaultOpen:!0,children:(0,g.jsx)("div",{className:"yop-poll-element-grid",children:o.map(e=>(0,g.jsx)(je,{elementType:e,onProClick:()=>s(!0)},e.type))})}),(0,g.jsx)(ve,{open:t,onClose:()=>s(!1)})]})}function Ge(){return(0,g.jsxs)("div",{className:"yop-poll-two-panel",children:[(0,g.jsx)("div",{className:"yop-poll-two-panel__main",children:(0,g.jsx)(be,{})}),(0,g.jsx)($e,{})]})}var Ye=(0,g.jsx)(C.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,g.jsx)(C.Path,{d:"M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"})});function Ke(){const{poll:e,optionsSection:l}=(0,i.useSelect)(e=>({poll:e(r).getPoll(),optionsSection:e(r).getOptionsSection()})),{setMetaField:o,setOptionsSection:t}=(0,i.useDispatch)(r),s="string"==typeof e.meta_data?JSON.parse(e.meta_data):e.meta_data||{},a=(e,l,t)=>{o(e,l,t)},n=[{key:"poll",label:(0,b.__)("Poll","yop-poll")},{key:"access",label:(0,b.__)("Access","yop-poll")},{key:"results",label:(0,b.__)("Results","yop-poll")}];return(0,g.jsxs)("div",{className:"yop-poll-two-panel",children:[(0,g.jsxs)("div",{className:"yop-poll-two-panel__main",children:["poll"===l&&(0,g.jsx)(Ze,{meta:s,updateMeta:a}),"access"===l&&(0,g.jsx)(Qe,{meta:s,updateMeta:a}),"results"===l&&(0,g.jsx)(Xe,{meta:s,updateMeta:a})]}),(0,g.jsx)("div",{className:"yop-poll-two-panel__sidebar",children:n.map(e=>(0,g.jsxs)("div",{className:"yop-poll-options-sidebar-item "+(l===e.key?"yop-poll-options-sidebar-item--active":""),onClick:()=>t(e.key),role:"button",tabIndex:0,onKeyDown:l=>{"Enter"!==l.key&&" "!==l.key||t(e.key)},children:[(0,g.jsx)("span",{children:e.label}),(0,g.jsx)(w,{icon:l===e.key?S:Ye,size:18})]},e.key))})]})}function Je({title:e,children:l}){return(0,g.jsxs)("div",{className:"yop-poll-options-section",children:[(0,g.jsx)("div",{className:"yop-poll-options-section__header",children:(0,g.jsx)("h2",{className:"yop-poll-options-section__title",children:e})}),(0,g.jsx)("div",{className:"yop-poll-options-section__body",children:l})]})}function Ze({meta:e,updateMeta:l}){const o=e.options?.poll||{},t=e.style?.custom||{},[s,a]=(0,n.useState)(!1);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(Je,{title:(0,b.__)("Preferences","yop-poll"),children:[(0,g.jsx)(ll,{label:(0,b.__)("Status","yop-poll"),value:o.status||"published",onChange:e=>l("options.poll","status",e),options:[{value:"published",label:(0,b.__)("Published","yop-poll")},{value:"draft",label:(0,b.__)("Draft","yop-poll")}]}),(0,g.jsx)(ll,{label:(0,g.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[(0,g.jsx)("span",{className:"yop-poll-pro-badge",children:"PRO"}),(0,b.__)("Enable Auto-Refresh","yop-poll")]}),value:o.enableAutoRefresh||"no",onChange:e=>{"yes"===e?a(!0):l("options.poll","enableAutoRefresh",e)},options:[{value:"no",label:(0,b.__)("No","yop-poll")},{value:"yes",label:(0,b.__)("Yes","yop-poll")}],disabled:"yes"!==window.yopPoll?.settings?.enableAutoRefresh,disabledNotice:(0,b.__)("Auto-Refresh must be enabled globally in Settings → General","yop-poll")}),(0,g.jsx)(ll,{label:(0,b.__)("Redirect after vote","yop-poll"),value:o.redirectAfterVote||"no",onChange:e=>l("options.poll","redirectAfterVote",e),options:[{value:"no",label:(0,b.__)("No","yop-poll")},{value:"yes",label:(0,b.__)("Yes","yop-poll")}]}),"yes"===o.redirectAfterVote&&(0,g.jsxs)("div",{className:"yop-poll-options-form__indented",children:[(0,g.jsx)(tl,{label:(0,b.__)("Redirect Link","yop-poll"),value:o.redirectUrl||"",onChange:e=>l("options.poll","redirectUrl",e)}),(0,g.jsx)(tl,{label:(0,b.__)("Redirect After (in seconds)","yop-poll"),value:o.redirectAfter||"",onChange:e=>l("options.poll","redirectAfter",e)})]}),(0,g.jsx)(ll,{label:(0,b.__)("Reset Poll Stats Automatically","yop-poll"),value:o.resetPollStatsAutomatically||"no",onChange:e=>l("options.poll","resetPollStatsAutomatically",e),options:[{value:"no",label:(0,b.__)("No","yop-poll")},{value:"yes",label:(0,b.__)("Yes","yop-poll")}]}),"yes"===o.resetPollStatsAutomatically&&(0,g.jsxs)("div",{className:"yop-poll-options-form__indented",children:[(0,g.jsx)(Ie,{label:(0,b.__)("Reset On","yop-poll"),value:o.resetPollStatsOn||"",onChange:e=>l("options.poll","resetPollStatsOn",e)}),(0,g.jsx)(ol,{label:(0,b.__)("Reset Every","yop-poll"),numberValue:o.resetPollStatsEvery||"",unitValue:o.resetPollStatsEveryPeriod||"hours",onNumberChange:e=>l("options.poll","resetPollStatsEvery",e),onUnitChange:e=>l("options.poll","resetPollStatsEveryPeriod",e),unitOptions:[{value:"hours",label:(0,b.__)("Hours","yop-poll")},{value:"days",label:(0,b.__)("Days","yop-poll")}]}),(0,g.jsx)(ll,{label:(0,g.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[(0,g.jsx)("span",{className:"yop-poll-pro-badge",children:"PRO"}),(0,b.__)("Email results before reset","yop-poll")]}),value:o.emailResultsBeforeReset||"no",onChange:e=>{"yes"!==e?l("options.poll","emailResultsBeforeReset",e):a(!0)},options:[{value:"no",label:(0,b.__)("No","yop-poll")},{value:"yes",label:(0,b.__)("Yes","yop-poll")}]}),"yes"===o.emailResultsBeforeReset&&(0,g.jsxs)("div",{className:"yop-poll-options-form__indented",children:[(0,g.jsx)(tl,{label:(0,b.__)("From Name","yop-poll"),value:o.emailResultsFromName||"",onChange:e=>l("options.poll","emailResultsFromName",e)}),(0,g.jsx)(tl,{label:(0,b.__)("From Email","yop-poll"),value:o.emailResultsFromEmail||"",onChange:e=>l("options.poll","emailResultsFromEmail",e)}),(0,g.jsx)(tl,{label:(0,b.__)("Recipients","yop-poll"),value:o.emailResultsRecipients||"",onChange:e=>l("options.poll","emailResultsRecipients",e)}),(0,g.jsx)(tl,{label:(0,b.__)("Subject","yop-poll"),value:o.emailResultsSubject||"",onChange:e=>l("options.poll","emailResultsSubject",e)}),(0,g.jsx)(sl,{label:(0,b.__)("Message","yop-poll"),value:o.emailResultsMessage||"",onChange:e=>l("options.poll","emailResultsMessage",e)})]})]}),(0,g.jsx)(ll,{label:(0,b.__)("Auto Generate Poll Page","yop-poll"),value:o.autoGeneratePollPage||"no",onChange:e=>l("options.poll","autoGeneratePollPage",e),options:[{value:"no",label:(0,b.__)("No","yop-poll")},{value:"yes",label:(0,b.__)("Yes","yop-poll")}]}),(0,g.jsx)(ll,{label:(0,b.__)("Location for Notification","yop-poll"),value:o.notificationMessageLocation||"top",onChange:e=>l("options.poll","notificationMessageLocation",e),options:[{value:"top",label:(0,b.__)("Top","yop-poll")},{value:"bottom",label:(0,b.__)("Bottom","yop-poll")}]})]}),(0,g.jsxs)(Je,{title:(0,b.__)("Statistics","yop-poll"),children:[(0,g.jsx)(ll,{label:(0,b.__)("Show Total Votes","yop-poll"),value:o.showTotalVotes||"no",onChange:e=>l("options.poll","showTotalVotes",e),options:[{value:"no",label:(0,b.__)("No","yop-poll")},{value:"yes",label:(0,b.__)("Yes","yop-poll")}]}),(0,g.jsx)(ll,{label:(0,b.__)("Show Total Answers","yop-poll"),value:o.showTotalAnswers||"no",onChange:e=>l("options.poll","showTotalAnswers",e),options:[{value:"no",label:(0,b.__)("No","yop-poll")},{value:"yes",label:(0,b.__)("Yes","yop-poll")}]})]}),(0,g.jsxs)(Je,{title:(0,b.__)("Scheduling","yop-poll"),children:[(0,g.jsx)(ll,{label:(0,b.__)("Start Date","yop-poll"),value:o.startDateOption||"now",onChange:e=>l("options.poll","startDateOption",e),options:[{value:"now",label:(0,b.__)("Now","yop-poll")},{value:"custom",label:(0,b.__)("Custom Date","yop-poll")}]}),"custom"===(o.startDateOption||"now")&&(0,g.jsx)("div",{className:"yop-poll-options-form__indented",children:(0,g.jsx)(Ie,{label:(0,b.__)("Custom Date","yop-poll"),value:o.startDateCustom||"",onChange:e=>l("options.poll","startDateCustom",e)})}),(0,g.jsx)(ll,{label:(0,b.__)("End Date","yop-poll"),value:o.endDateOption||"never",onChange:e=>l("options.poll","endDateOption",e),options:[{value:"never",label:(0,b.__)("Never","yop-poll")},{value:"custom",label:(0,b.__)("Custom Date","yop-poll")}]}),"custom"===(o.endDateOption||"never")&&(0,g.jsxs)("div",{className:"yop-poll-options-form__indented",children:[(0,g.jsx)(Ie,{label:(0,b.__)("Custom Date","yop-poll"),value:o.endDateCustom||"",onChange:e=>l("options.poll","endDateCustom",e)}),(0,g.jsx)(ll,{label:(0,g.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[(0,g.jsx)("span",{className:"yop-poll-pro-badge",children:"PRO"}),(0,b.__)("Display End Date On Poll","yop-poll")]}),value:o.endDateDisplay||"no",onChange:e=>{"as_defined"!==e&&"countdown"!==e?l("options.poll","endDateDisplay",e):a(!0)},options:[{value:"no",label:(0,b.__)("No","yop-poll")},{value:"as_defined",label:(0,b.__)("As defined","yop-poll")},{value:"countdown",label:(0,b.__)("As a countdown","yop-poll")}]})]})]}),(0,g.jsx)(Je,{title:(0,b.__)("Captcha","yop-poll"),children:(0,g.jsx)(ll,{label:(0,b.__)("Use Captcha","yop-poll"),value:o.useCaptcha||"no",onChange:e=>l("options.poll","useCaptcha",e),options:[{value:"no",label:(0,b.__)("No","yop-poll")}],groups:[{label:(0,b.__)("Yes","yop-poll"),options:[{value:"built_in",label:(0,b.__)("Use built in Captcha","yop-poll")},{value:"recaptcha_v2_checkbox",label:(0,b.__)("Use reCaptcha v2 Checkbox","yop-poll")},{value:"recaptcha_v2_invisible",label:(0,b.__)("Use reCaptcha v2 Invisible","yop-poll")},{value:"recaptcha_v3",label:(0,b.__)("Use reCaptcha v3","yop-poll")},{value:"hcaptcha",label:(0,b.__)("Use hCaptcha","yop-poll")},{value:"turnstile",label:(0,b.__)("Use Cloudflare Turnstile","yop-poll")}]}]})}),(0,g.jsxs)(Je,{title:(0,b.__)("GDPR / CCPA","yop-poll"),children:[(0,g.jsx)(ll,{label:(0,b.__)("Enable GDPR","yop-poll"),value:o.enableGdpr||"no",onChange:e=>l("options.poll","enableGdpr",e),options:[{value:"no",label:(0,b.__)("No","yop-poll")},{value:"yes",label:(0,b.__)("Yes","yop-poll")}]}),"yes"===o.enableGdpr&&(0,g.jsxs)("div",{className:"yop-poll-options-form__indented",children:[(0,g.jsx)(ll,{label:(0,b.__)("GDPR Solution","yop-poll"),value:o.gdprSolution||"ask_consent",onChange:e=>l("options.poll","gdprSolution",e),options:[{value:"ask_consent",label:(0,b.__)("Ask for consent ( Ip Addresses will be stored and cookies will be enabled )","yop-poll")},{value:"anonymize",label:(0,b.__)("Anonymize Ip Addresses ( Cookies will be disabled )","yop-poll")},{value:"do_not_store",label:(0,b.__)("Do not store Ip Addresses ( Cookies will be disabled )","yop-poll")}]}),"ask_consent"===(o.gdprSolution||"ask_consent")&&(0,g.jsx)(sl,{label:(0,b.__)("Consent Text","yop-poll"),value:o.gdprConsentText||"",onChange:e=>l("options.poll","gdprConsentText",e)})]})]}),(0,g.jsxs)(Je,{title:(0,b.__)("Notifications","yop-poll"),children:[(0,g.jsx)(ll,{label:(0,b.__)("Send Email Notifications","yop-poll"),value:o.sendEmailNotifications||"no",onChange:e=>{if(l("options.poll","sendEmailNotifications",e),"yes"===e){const e=window.yopPoll?.settings?.newVoteNotification||{};o.emailNotificationsFromName||l("options.poll","emailNotificationsFromName",e.fromName||""),o.emailNotificationsFromEmail||l("options.poll","emailNotificationsFromEmail",e.fromEmail||""),o.emailNotificationsRecipients||l("options.poll","emailNotificationsRecipients",e.recipients||""),o.emailNotificationsSubject||l("options.poll","emailNotificationsSubject",e.subject||""),o.emailNotificationsMessage||l("options.poll","emailNotificationsMessage",e.message||"")}},options:[{value:"no",label:(0,b.__)("No","yop-poll")},{value:"yes",label:(0,b.__)("Yes","yop-poll")}]}),"yes"===o.sendEmailNotifications&&(0,g.jsxs)("div",{className:"yop-poll-options-form__indented",children:[(0,g.jsx)(tl,{label:(0,b.__)("From Name","yop-poll"),value:o.emailNotificationsFromName||"",onChange:e=>l("options.poll","emailNotificationsFromName",e)}),(0,g.jsx)(tl,{label:(0,b.__)("From Email","yop-poll"),value:o.emailNotificationsFromEmail||"",onChange:e=>l("options.poll","emailNotificationsFromEmail",e)}),(0,g.jsx)(tl,{label:(0,b.__)("Recipients","yop-poll"),value:o.emailNotificationsRecipients||"",onChange:e=>l("options.poll","emailNotificationsRecipients",e)}),(0,g.jsx)(tl,{label:(0,b.__)("Subject","yop-poll"),value:o.emailNotificationsSubject||"",onChange:e=>l("options.poll","emailNotificationsSubject",e)}),(0,g.jsx)(sl,{label:(0,b.__)("Message","yop-poll"),value:o.emailNotificationsMessage||"",onChange:e=>l("options.poll","emailNotificationsMessage",e)})]})]}),(0,g.jsx)(Je,{title:(0,b.__)("Custom Code","yop-poll"),children:(0,g.jsx)(sl,{label:(0,b.__)("Css","yop-poll"),value:t.css||"",onChange:e=>l("style.custom","css",e)})}),s&&(0,g.jsx)(ve,{open:s,onClose:()=>a(!1)})]})}function Qe({meta:e,updateMeta:l}){const o=e.options?.access||{},[t,s]=((0,i.useSelect)(e=>e(r).getElements()).some(e=>"advanced-email"===e.etype),(0,n.useState)(!1)),a=o.votePermissions||["guest"],p=o.blockVoters||["no-block"],d=["wordpress","facebook","google","email"],c=!a.includes("guest")&&a.some(e=>d.includes(e)),u=("no"===(o.enableAnonymousVoting||"no")&&"yes"===(o.limitVotesPerUser||"no")&&o.votesPerUserAllowed,(0,g.jsx)("span",{className:"yop-poll-pro-badge",children:"PRO"}));return(0,g.jsxs)(Je,{title:(0,b.__)("Access","yop-poll"),children:[(0,g.jsx)(el,{label:(0,b.__)("Vote Permissions","yop-poll"),options:[{value:"guest",label:(0,b.__)("Guest","yop-poll")},{value:"wordpress",label:(0,b.__)("WordPress","yop-poll")},{value:"facebook",label:(0,g.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:[u,(0,b.__)("Facebook","yop-poll")]})},{value:"google",label:(0,g.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:[u,(0,b.__)("Google","yop-poll")]})},{value:"email",label:(0,g.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:[u,(0,b.__)("Email","yop-poll")]})}],values:a,onChange:e=>{if(["facebook","google","email"].includes(e))return void s(!0);const o=a.includes(e)?a.filter(l=>l!==e):[...a,e];l("options.access","votePermissions",o.length?o:[e])}}),c&&(0,g.jsxs)("div",{className:"yop-poll-options-form__indented",children:[(0,g.jsx)(ll,{label:(0,g.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[u,(0,b.__)("Enable Anonymous Voting","yop-poll")]}),value:o.enableAnonymousVoting||"no",onChange:e=>{"yes"!==e?l("options.access","enableAnonymousVoting",e):s(!0)},options:[{value:"no",label:(0,b.__)("No","yop-poll")},{value:"yes",label:(0,b.__)("Yes","yop-poll")}]}),(0,g.jsx)(ll,{label:(0,b.__)("Limit Number Of Votes per User","yop-poll"),value:o.limitVotesPerUser||"no",onChange:e=>l("options.access","limitVotesPerUser",e),options:[{value:"no",label:(0,b.__)("No","yop-poll")},{value:"yes",label:(0,b.__)("Yes","yop-poll")}]}),"yes"===(o.limitVotesPerUser||"no")&&(0,g.jsx)("div",{className:"yop-poll-options-form__indented",children:(0,g.jsx)(tl,{label:(0,b.__)("Votes Per User","yop-poll"),value:o.votesPerUserAllowed||"1",onChange:e=>l("options.access","votesPerUserAllowed",e),type:"number"})})]}),1===a.length&&"wordpress"===a[0]&&(0,g.jsxs)("div",{className:"yop-poll-options-form__indented",children:[(0,g.jsx)(ll,{label:(0,g.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[u,(0,b.__)("Allow voters to change their vote","yop-poll")]}),value:o.allowChangeVote||"no",onChange:e=>{"yes"!==e?l("options.access","allowChangeVote",e):s(!0)},options:[{value:"no",label:(0,b.__)("No","yop-poll")},{value:"yes",label:(0,b.__)("Yes","yop-poll")}]}),(0,g.jsx)(ll,{label:(0,g.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[u,(0,b.__)("Enable Custom Voting Weight","yop-poll")]}),value:o.enableCustomVotingWeight||"no",onChange:e=>{"yes"!==e?l("options.access","enableCustomVotingWeight",e):s(!0)},options:[{value:"no",label:(0,b.__)("No","yop-poll")},{value:"yes",label:(0,b.__)("Yes","yop-poll")}]}),"yes"===(o.enableCustomVotingWeight||"no")&&(0,g.jsx)("div",{className:"yop-poll-options-form__indented",children:(window.yopPoll?.roles||[]).map(e=>(0,g.jsx)(tl,{label:e.label,type:"number",value:(o.votingWeights||{})[e.slug]??"1",onChange:t=>l("options.access","votingWeights",{...o.votingWeights||{},[e.slug]:t})},e.slug))})]}),(0,g.jsx)(el,{label:(0,b.__)("Block Voters","yop-poll"),options:[{value:"no-block",label:(0,b.__)("Don't Block","yop-poll")},{value:"by-cookie",label:(0,b.__)("By Cookie","yop-poll")},{value:"by-ip",label:(0,b.__)("By Ip","yop-poll")},{value:"by-user-id",label:(0,b.__)("By User Id","yop-poll")},{value:"by-fingerprint",label:(0,g.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:[u,(0,b.__)("By Fingerprint","yop-poll")]})},{value:"by-email",label:(0,g.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:[u,(0,b.__)("By Email","yop-poll")]})}],values:p,onChange:e=>{if("by-fingerprint"!==e&&"by-email"!==e)if("no-block"===e)l("options.access","blockVoters",["no-block"]);else if(p.includes(e)){const o=p.filter(l=>l!==e);l("options.access","blockVoters",o.length?o:["no-block"])}else l("options.access","blockVoters",[...p.filter(e=>"no-block"!==e),e]);else s(!0)}}),p.length>0&&!p.includes("no-block")&&(0,g.jsxs)("div",{className:"yop-poll-options-form__indented",children:[(0,g.jsx)(ll,{label:(0,b.__)("Block Period","yop-poll"),value:o.blockLengthType||"forever",onChange:e=>l("options.access","blockLengthType",e),options:[{value:"forever",label:(0,b.__)("Forever","yop-poll")},{value:"limited-time",label:(0,b.__)("Limited Time","yop-poll")}]}),"limited-time"===(o.blockLengthType||"forever")&&(0,g.jsx)(ol,{label:(0,b.__)("Period","yop-poll"),numberValue:o.blockForValue||"",unitValue:o.blockForPeriod||"minutes",onNumberChange:e=>l("options.access","blockForValue",e),onUnitChange:e=>l("options.access","blockForPeriod",e),unitOptions:[{value:"minutes",label:(0,b.__)("Minutes","yop-poll")},{value:"hours",label:(0,b.__)("Hours","yop-poll")},{value:"days",label:(0,b.__)("Days","yop-poll")}]})]}),t&&(0,g.jsx)(ve,{open:t,onClose:()=>s(!1)})]})}function Xe({meta:e,updateMeta:l}){const o=e.options?.results||{},t=(0,g.jsx)("span",{className:"yop-poll-pro-badge",children:"PRO"}),[s,a]=(0,n.useState)(!1),i=o.showResultsMoment||["after-vote"];return(0,g.jsxs)(Je,{title:(0,b.__)("Display","yop-poll"),children:[(0,g.jsx)(el,{label:(0,b.__)("Show Results","yop-poll"),options:[{value:"before-vote",label:(0,b.__)("Before Vote","yop-poll")},{value:"after-vote",label:(0,b.__)("After Vote","yop-poll")},{value:"after-poll-end-date",label:(0,b.__)("After poll end date","yop-poll")},{value:"custom-date",label:(0,b.__)("Custom date","yop-poll")},{value:"never",label:(0,b.__)("Never","yop-poll")}],values:i,onChange:e=>{if("never"===e)l("options.results","showResultsMoment",["never"]);else if(i.includes(e)){const o=i.filter(l=>l!==e);l("options.results","showResultsMoment",o.length?o:[e])}else l("options.results","showResultsMoment",[...i.filter(e=>"never"!==e),e])}}),i.includes("custom-date")&&(0,g.jsx)("div",{className:"yop-poll-options-form__indented",children:(0,g.jsx)(Ie,{label:(0,b.__)("Custom Date","yop-poll"),value:o.customDateResults||"",onChange:e=>l("options.results","customDateResults",e)})}),!i.includes("never")&&(0,g.jsxs)("div",{className:"yop-poll-options-form__indented",children:[(0,g.jsx)(el,{label:(0,b.__)("Show results to","yop-poll"),options:[{value:"guest",label:(0,b.__)("Guest","yop-poll")},{value:"registered",label:(0,b.__)("Registered","yop-poll")}],values:o.showResultsTo||["guest"],onChange:e=>{const t=o.showResultsTo||["guest"],s=t.includes(e)?t.filter(l=>l!==e):[...t,e];l("options.results","showResultsTo",s.length?s:[e])}}),(0,g.jsx)(el,{label:(0,b.__)("Show details as","yop-poll"),options:[{value:"votes-number",label:(0,b.__)("Votes Number","yop-poll")},{value:"percentages",label:(0,b.__)("Percentages","yop-poll")}],values:o.resultsDetails||["votes-number"],onChange:e=>{const t=o.resultsDetails||["votes-number"],s=t.includes(e)?t.filter(l=>l!==e):[...t,e];l("options.results","resultsDetails",s.length?s:[e])}})]}),(0,g.jsx)(ll,{label:(0,b.__)("Display [Back to vote] link","yop-poll"),value:o.backToVoteOption||"no",onChange:e=>l("options.results","backToVoteOption",e),options:[{value:"no",label:(0,b.__)("No","yop-poll")},{value:"yes",label:(0,b.__)("Yes","yop-poll")}]}),"yes"===(o.backToVoteOption||"no")&&(0,g.jsx)("div",{className:"yop-poll-options-form__indented",children:(0,g.jsx)(tl,{label:(0,b.__)("[Back to vote] caption","yop-poll"),value:o.backToVoteCaption||(0,b.__)("Back to vote","yop-poll"),onChange:e=>l("options.results","backToVoteCaption",e)})}),(0,g.jsx)(ll,{label:(0,b.__)("Sort Results","yop-poll"),value:o.sortResults||"as-defined",onChange:e=>l("options.results","sortResults",e),options:[{value:"as-defined",label:(0,b.__)("As Defined","yop-poll")},{value:"alphabetical",label:(0,b.__)("Alphabetical Order","yop-poll")},{value:"number-of-votes",label:(0,b.__)("Number of Votes","yop-poll")}]}),["alphabetical","number-of-votes"].includes(o.sortResults||"as-defined")&&(0,g.jsx)("div",{className:"yop-poll-options-form__indented",children:(0,g.jsx)(ll,{label:(0,b.__)("Sort Rule","yop-poll"),value:o.sortResultsRule||"ascending",onChange:e=>l("options.results","sortResultsRule",e),options:[{value:"ascending",label:(0,b.__)("Ascending","yop-poll")},{value:"descending",label:(0,b.__)("Descending","yop-poll")}]})}),(0,g.jsx)(ll,{label:(0,g.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:[t,(0,b.__)("Display Results As","yop-poll")]}),value:o.displayResultsAs||"bar",onChange:e=>{"pie"!==e?l("options.results","displayResultsAs",e):a(!0)},options:[{value:"bar",label:(0,b.__)("Bars","yop-poll")},{value:"pie",label:(0,b.__)("Pie","yop-poll")}]}),s&&(0,g.jsx)(ve,{open:s,onClose:()=>a(!1)})]})}function el({label:e,options:l,values:o,onChange:t}){return(0,g.jsxs)("div",{className:"yop-poll-options-form__field",children:[(0,g.jsx)("label",{className:"yop-poll-options-form__label",children:e}),(0,g.jsx)("div",{className:"yop-poll-options-form__checkbox-group",children:l.map(e=>(0,g.jsxs)("label",{className:["yop-poll-options-form__checkbox-label",e.disabled&&"yop-poll-options-form__checkbox-label--disabled"].filter(Boolean).join(" "),title:e.disabled&&e.disabledNotice?e.disabledNotice:void 0,children:[(0,g.jsx)("input",{type:"checkbox",checked:o.includes(e.value),disabled:e.disabled,onChange:()=>!e.disabled&&t(e.value)}),e.label]},e.value))})]})}function ll({label:e,value:l,onChange:o,options:t,groups:s,disabled:a,disabledNotice:n}){return(0,g.jsxs)("div",{className:"yop-poll-options-form__field",title:a&&n?n:void 0,children:[(0,g.jsx)("label",{className:["yop-poll-options-form__label",a&&"yop-poll-options-form__label--disabled"].filter(Boolean).join(" "),children:e}),(0,g.jsxs)("select",{className:"yop-poll-options-form__select",value:a?"no":l,onChange:e=>!a&&o(e.target.value),disabled:a,children:[t?.map(e=>(0,g.jsx)("option",{value:e.value,children:e.label},e.value)),s?.map(e=>(0,g.jsx)("optgroup",{label:e.label,children:e.options.map(e=>(0,g.jsx)("option",{value:e.value,children:e.label},e.value))},e.label))]})]})}function ol({label:e,numberValue:l,unitValue:o,onNumberChange:t,onUnitChange:s,unitOptions:a}){return(0,g.jsxs)("div",{className:"yop-poll-options-form__field",children:[(0,g.jsx)("label",{className:"yop-poll-options-form__label",children:e}),(0,g.jsxs)("div",{className:"yop-poll-options-form__row",children:[(0,g.jsx)("input",{type:"number",className:"yop-poll-options-form__input yop-poll-options-form__input--number",value:l,min:"1",onChange:e=>t(e.target.value)}),(0,g.jsx)("select",{className:"yop-poll-options-form__select yop-poll-options-form__select--unit",value:o,onChange:e=>s(e.target.value),children:a.map(e=>(0,g.jsx)("option",{value:e.value,children:e.label},e.value))})]})]})}function tl({label:e,value:l,onChange:o,type:t="text"}){return(0,g.jsxs)("div",{className:"yop-poll-options-form__field",children:[(0,g.jsx)("label",{className:"yop-poll-options-form__label",children:e}),(0,g.jsx)("input",{type:t,className:"yop-poll-options-form__input",value:l,onChange:e=>o(e.target.value)})]})}function sl({label:e,value:l,onChange:o}){return(0,g.jsxs)("div",{className:"yop-poll-options-form__field",children:[(0,g.jsx)("label",{className:"yop-poll-options-form__label",children:e}),(0,g.jsx)("textarea",{className:"yop-poll-options-form__textarea",value:l,onChange:e=>o(e.target.value),rows:8})]})}function al({pollId:e}){const{activeTab:l,isLoading:o}=(0,i.useSelect)(e=>({activeTab:e(r).getActiveTab(),isLoading:e(r).isLoading()}));return o?(0,g.jsx)("div",{className:"yop-poll-loading",children:(0,g.jsx)(x.Spinner,{})}):(0,g.jsxs)("div",{children:[(0,g.jsx)(v,{}),l===u&&(0,g.jsx)(fe,{}),l===_&&(0,g.jsx)(Ge,{}),l===m&&(0,g.jsx)(Ke,{})]})}const nl=window.wp.apiFetch;var il=o.n(nl);const rl="yop-poll/v1";function pl(){const[e,l]=(0,n.useState)([]),[o,t]=(0,n.useState)(0),[s,a]=(0,n.useState)(1),[i,r]=(0,n.useState)({b_by:"ip",b_value:"",poll_id:0}),[p,d]=(0,n.useState)(!1),[c,u]=(0,n.useState)(""),_=async()=>{d(!0);try{const e=await function(e={}){const l=new URLSearchParams(e).toString();return il()({path:`${rl}/bans${l?"?"+l:""}`})}({page:s,per_page:20});l(e.items||[]),t(e.total||0)}catch(e){}d(!1)};(0,n.useEffect)(()=>{_()},[s]);const m=Math.ceil(o/20);return(0,g.jsxs)("div",{className:"yop-poll-admin-page",children:[(0,g.jsx)("h1",{children:(0,b.__)("Bans","yop-poll")}),(0,g.jsxs)("div",{className:"yop-poll-add-form",children:[(0,g.jsxs)("div",{className:"yop-poll-add-form__field",children:[(0,g.jsx)("label",{children:(0,b.__)("Ban Type","yop-poll")}),(0,g.jsxs)("select",{value:i.b_by,onChange:e=>r({...i,b_by:e.target.value}),children:[(0,g.jsx)("option",{value:"ip",children:(0,b.__)("IP Address","yop-poll")}),(0,g.jsx)("option",{value:"email",children:(0,b.__)("Email","yop-poll")}),(0,g.jsx)("option",{value:"username",children:(0,b.__)("Username","yop-poll")})]})]}),(0,g.jsxs)("div",{className:"yop-poll-add-form__field",children:[(0,g.jsx)("label",{children:(0,b.__)("Value","yop-poll")}),(0,g.jsx)("input",{type:"text",value:i.b_value,onChange:e=>r({...i,b_value:e.target.value}),placeholder:(0,b.__)("Enter value…","yop-poll")})]}),(0,g.jsx)(x.Button,{variant:"primary",onClick:async()=>{const e=(()=>{const e=i.b_value.trim();if(!e)return(0,b.__)("Value is required.","yop-poll");if("ip"===i.b_by){const l=/^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$/;if(!/^(\d{1,3}\.){3}\d{1,3}$/.test(e)&&!l.test(e))return(0,b.__)("Please enter a valid IP address.","yop-poll")}return"email"!==i.b_by||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)?"username"!==i.b_by||e?"":(0,b.__)("Please enter a valid username.","yop-poll"):(0,b.__)("Please enter a valid email address.","yop-poll")})();if(e)u(e);else{u("");try{await(l=i,il()({path:`${rl}/bans`,method:"POST",data:l})),r({b_by:"ip",b_value:"",poll_id:0}),_()}catch(e){u(e.message||(0,b.__)("Failed to add ban.","yop-poll"))}var l}},children:(0,b.__)("Add Ban","yop-poll")}),c&&(0,g.jsx)("div",{className:"yop-poll-add-form__error",style:{color:"#d63638",marginTop:"8px"},children:c})]}),(0,g.jsxs)("table",{className:"yop-poll-table",children:[(0,g.jsx)("thead",{children:(0,g.jsxs)("tr",{children:[(0,g.jsx)("th",{children:(0,b.__)("ID","yop-poll")}),(0,g.jsx)("th",{children:(0,b.__)("Type","yop-poll")}),(0,g.jsx)("th",{children:(0,b.__)("Value","yop-poll")}),(0,g.jsx)("th",{children:(0,b.__)("Poll ID","yop-poll")}),(0,g.jsx)("th",{children:(0,b.__)("Date","yop-poll")}),(0,g.jsx)("th",{children:(0,b.__)("Actions","yop-poll")})]})}),(0,g.jsxs)("tbody",{children:[e.map(e=>(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{children:e.id}),(0,g.jsx)("td",{children:e.b_by}),(0,g.jsx)("td",{children:e.b_value}),(0,g.jsx)("td",{children:e.poll_id||(0,b.__)("All","yop-poll")}),(0,g.jsx)("td",{children:e.added_date}),(0,g.jsx)("td",{children:(0,g.jsx)(x.Button,{variant:"link",isDestructive:!0,onClick:()=>(async e=>{await function(e){return il()({path:`${rl}/bans/${e}`,method:"DELETE"})}(e),_()})(e.id),children:(0,b.__)("Delete","yop-poll")})})]},e.id)),0===e.length&&(0,g.jsx)("tr",{children:(0,g.jsx)("td",{colSpan:"6",style:{textAlign:"center",color:"#888"},children:p?(0,b.__)("Loading…","yop-poll"):(0,b.__)("No bans found.","yop-poll")})})]})]}),m>1&&(0,g.jsxs)("div",{className:"yop-poll-pagination",children:[(0,g.jsxs)("button",{className:"yop-poll-pagination__btn",disabled:s<=1,onClick:()=>a(s-1),children:["« ",(0,b.__)("Prev","yop-poll")]}),(0,g.jsxs)("span",{children:[s," / ",m]}),(0,g.jsxs)("button",{className:"yop-poll-pagination__btn",disabled:s>=m,onClick:()=>a(s+1),children:[(0,b.__)("Next","yop-poll")," »"]})]})]})}function dl(){const[e,l]=(0,n.useState)([]),[o,t]=(0,n.useState)(0),[s,a]=(0,n.useState)(1),[i,r]=(0,n.useState)(!1);(0,n.useEffect)(()=>{(async()=>{r(!0);try{const e=await function(e={}){const l=new URLSearchParams(e).toString();return il()({path:`${rl}/logs${l?"?"+l:""}`})}({page:s,per_page:20});l(e.items||[]),t(e.total||0)}catch(e){}r(!1)})()},[s]);const p=Math.ceil(o/20);return(0,g.jsxs)("div",{className:"yop-poll-admin-page",children:[(0,g.jsx)("h1",{children:(0,b.__)("Logs","yop-poll")}),(0,g.jsxs)("table",{className:"yop-poll-table",children:[(0,g.jsx)("thead",{children:(0,g.jsxs)("tr",{children:[(0,g.jsx)("th",{children:(0,b.__)("ID","yop-poll")}),(0,g.jsx)("th",{children:(0,b.__)("Poll ID","yop-poll")}),(0,g.jsx)("th",{children:(0,b.__)("User","yop-poll")}),(0,g.jsx)("th",{children:(0,b.__)("IP Address","yop-poll")}),(0,g.jsx)("th",{children:(0,b.__)("Message","yop-poll")}),(0,g.jsx)("th",{children:(0,b.__)("Date","yop-poll")})]})}),(0,g.jsxs)("tbody",{children:[e.map(e=>(0,g.jsxs)("tr",{children:[(0,g.jsx)("td",{children:e.id}),(0,g.jsx)("td",{children:e.poll_id}),(0,g.jsx)("td",{children:e.user_email||`User #${e.user_id}`}),(0,g.jsx)("td",{children:e.ipaddress}),(0,g.jsx)("td",{children:e.vote_message}),(0,g.jsx)("td",{children:e.added_date})]},e.id)),0===e.length&&(0,g.jsx)("tr",{children:(0,g.jsx)("td",{colSpan:"6",style:{textAlign:"center",color:"#888"},children:i?(0,b.__)("Loading…","yop-poll"):(0,b.__)("No logs found.","yop-poll")})})]})]}),p>1&&(0,g.jsxs)("div",{className:"yop-poll-pagination",children:[(0,g.jsxs)("button",{className:"yop-poll-pagination__btn",disabled:s<=1,onClick:()=>a(s-1),children:["« ",(0,b.__)("Prev","yop-poll")]}),(0,g.jsxs)("span",{children:[s," / ",p]}),(0,g.jsxs)("button",{className:"yop-poll-pagination__btn",disabled:s>=p,onClick:()=>a(s+1),children:[(0,b.__)("Next","yop-poll")," »"]})]})]})}function cl({pollId:e}){const[l,o]=(0,n.useState)(null),[t,s]=(0,n.useState)(!0),[a,i]=(0,n.useState)(null);if((0,n.useEffect)(()=>{var l;(l=e,il()({path:`${rl}/polls/${l}/admin-results`})).then(e=>o(e)).catch(()=>i((0,b.__)("Failed to load results.","yop-poll"))).finally(()=>s(!1))},[e]),t)return(0,g.jsx)("p",{children:(0,b.__)("Loading…","yop-poll")});if(a)return(0,g.jsx)("p",{style:{color:"red"},children:a});if(!l)return null;const r=(l.elements||[]).filter(e=>e.etype&&e.etype.startsWith("question-"));return(0,g.jsxs)("div",{children:[(0,g.jsx)("h1",{children:l.poll?.name}),0===r.length&&(0,g.jsx)("p",{children:(0,b.__)("No question elements found.","yop-poll")}),r.map(l=>{const o=l.subelements||[],t=l.other_votes_count||0,s=o.reduce((e,l)=>e+(parseInt(l.total_submits,10)||0),0)+t,a=l.meta_data||{},n="yes"===a.allowOtherAnswers,i=l.other_answers_list||[];return(0,g.jsxs)("div",{className:"yop-poll-results-question",children:[(0,g.jsx)("h2",{className:"yop-poll-results-question__title",dangerouslySetInnerHTML:{__html:l.etext}}),(0,g.jsx)("p",{className:"yop-poll-results-question__total",children:1===s?(0,b.__)("1 vote","yop-poll"):`${s} ${(0,b.__)("votes","yop-poll")}`}),o.map((l,o)=>{const t=parseInt(l.total_submits,10)||0,a=s>0?(t/s*100).toFixed(2):"0.00",n=l.meta_data?.resultsColor||"#2271b1",i=l.stext||`${(0,b.__)("Answer","yop-poll")} ${o+1}`;return(0,g.jsxs)("div",{className:"yop-poll-results-answer",children:[(0,g.jsx)("div",{className:"yop-poll-results-answer__label",dangerouslySetInnerHTML:{__html:i}}),(0,g.jsx)("div",{className:"yop-poll-results-answer__bar-wrap",children:(0,g.jsx)("div",{className:"yop-poll-results-answer__bar",style:{width:`${a}%`,backgroundColor:n}})}),(0,g.jsxs)("div",{className:"yop-poll-results-answer__stat",children:[a,"% (",t," ",(0,b.__)("votes","yop-poll"),")",t>0&&(0,g.jsx)("a",{href:`?page=yop-poll&action=votes&poll_id=${e}&answer_id=${l.id}&answer_label=${encodeURIComponent(i)}`,className:"button-link",style:{marginLeft:"8px"},children:(0,b.__)("View Votes","yop-poll")})]})]},l.id)}),n&&(0,g.jsxs)("div",{className:"yop-poll-results-answer",children:[(0,g.jsx)("div",{className:"yop-poll-results-answer__label",dangerouslySetInnerHTML:{__html:a.otherAnswersLabel||(0,b.__)("Other","yop-poll")}}),(0,g.jsx)("div",{className:"yop-poll-results-answer__bar-wrap",children:(0,g.jsx)("div",{className:"yop-poll-results-answer__bar",style:{width:`${s>0?(t/s*100).toFixed(2):"0.00"}%`,backgroundColor:a.resultsColorForOtherAnswers||"#058dc7"}})}),(0,g.jsxs)("div",{className:"yop-poll-results-answer__stat",children:[s>0?(t/s*100).toFixed(2):"0.00","% (",t," ",(0,b.__)("votes","yop-poll"),")"]}),i.length>0&&(0,g.jsx)("div",{style:{marginTop:"4px",paddingLeft:"8px",borderLeft:"3px solid #eee"},children:i.map((e,l)=>(0,g.jsxs)("div",{style:{fontSize:"13px",color:"#555",padding:"2px 0"},children:[e.answer," (",e.count,")"]},l))})]})]},l.id)})]})}function ul({pollId:e}){return(0,g.jsx)(cl,{pollId:e})}const _l=[{key:"general",label:"General"},{key:"notifications",label:"Notifications"},{key:"integrations",label:"Integrations"},{key:"messages",label:"Messages"}],ml=[{key:"new-vote",label:"New Vote"},{key:"automatically-reset-votes",label:"Automatically Reset Votes"}],yl=[{key:"reCaptcha",label:"Google reCaptcha",fields:[{k:"site-key",l:"Site Key"},{k:"secret-key",l:"Secret Key"}]},{key:"reCaptchaV2Invisible",label:"Invisible reCaptcha v2",fields:[{k:"site-key",l:"Site Key"},{k:"secret-key",l:"Secret Key"}]},{key:"reCaptchaV3",label:"reCaptcha v3",fields:[{k:"site-key",l:"Site Key"},{k:"secret-key",l:"Secret Key"},{k:"min-allowed-score",l:"Min Allowed Score"}]},{key:"hCaptcha",label:"hCaptcha",fields:[{k:"site-key",l:"Site Key"},{k:"secret-key",l:"Secret Key"}]},{key:"cloudflare-turnstile",label:"Cloudflare Turnstile",fields:[{k:"site-key",l:"Site Key"},{k:"secret-key",l:"Secret Key"}]},{key:"facebook",label:"Facebook",pro:!0,fields:[{k:"app-id",l:"App ID"},{k:"app-secret",l:"App Secret"}]},{key:"google",label:"Google",pro:!0,fields:[{k:"app-id",l:"App ID"},{k:"app-secret",l:"App Secret"}]}],hl=[{key:"buttons",label:"Vote Buttons"},{key:"voting",label:"Voting"},{key:"results",label:"Results"},{key:"captcha",label:"Captcha"}],xl={buttons:[{k:"anonymous",l:"Anonymous Vote Button"},{k:"wordpress",l:"Sign in with WordPress Button"},{k:"facebook",l:"Sign in with Facebook Button"},{k:"google",l:"Sign in with Google Button"}],voting:[{k:"poll-ended",l:"Poll Ended"},{k:"poll-not-started",l:"Poll Not Started"},{k:"already-voted-on-poll",l:"Already Voted"},{k:"invalid-poll",l:"Invalid Poll"},{k:"no-answers-selected",l:"No Answer Selected"},{k:"min-answers-required",l:"Min Answers Required"},{k:"max-answers-required",l:"Max Answers Required"},{k:"no-answer-for-other",l:"No Answer for Other"},{k:"answer-for-other-too-long",l:"Answer for Other Too Long"},{k:"no-value-for-custom-field",l:"No Value for Custom Field"},{k:"too-many-chars-for-custom-field",l:"Too Many Chars for Custom Field"},{k:"invalid-value-for-email",l:"Invalid Email"},{k:"consent-not-checked",l:"Consent Not Checked"},{k:"no-captcha-selected",l:"No Captcha Selected"},{k:"not-allowed-by-ban",l:"Not Allowed (Ban)"},{k:"not-allowed-by-block",l:"Not Allowed (Block)"},{k:"not-allowed-by-limit",l:"Not Allowed (Limit)"},{k:"thank-you",l:"Thank You"}],results:[{k:"single-vote",l:"Single Vote Label"},{k:"multiple-votes",l:"Multiple Votes Label"},{k:"single-answer",l:"Single Answer Label"},{k:"multiple-answers",l:"Multiple Answers Label"}],captcha:[{k:"accessibility-alt",l:"Accessibility Alt"},{k:"accessibility-title",l:"Accessibility Title"},{k:"accessibility-description",l:"Accessibility Description"},{k:"explanation",l:"Explanation"},{k:"refresh-alt",l:"Refresh Alt"},{k:"refresh-title",l:"Refresh Title"}]};function bl(){const[e,l]=(0,n.useState)(null),[o,t]=(0,n.useState)("general"),[s,a]=(0,n.useState)("new-vote"),[i,r]=(0,n.useState)("reCaptcha"),[p,d]=(0,n.useState)("buttons"),[c,u]=(0,n.useState)(!1),[_,m]=(0,n.useState)(""),[y,h]=(0,n.useState)(""),[v,f]=(0,n.useState)({}),[j,w]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{il()({path:`${rl}/settings`}).then(l)},[]),!e)return(0,g.jsx)("div",{className:"yop-poll-loading",children:(0,g.jsx)(x.Spinner,{})});const C=(e,o)=>{l(l=>{const t=JSON.parse(JSON.stringify(l));let s=t;for(let l=0;l<e.length-1;l++)s=s[e[l]];return s[e[e.length-1]]=o,t})},N=["site-key","secret-key","app-id","app-secret","api-key"],S=(e,l)=>(0,g.jsxs)("div",{className:"yop-poll-settings-form__field",children:[(0,g.jsx)("label",{className:"yop-poll-settings-form__label",children:e}),l]},e),k=(l,o=!1)=>(0,g.jsx)("input",{className:"yop-poll-settings-form__input",type:"text",value:l.reduce((e,l)=>e?.[l]??"",e),onChange:e=>C(l,e.target.value),disabled:o}),A=(e,l=!1)=>(0,g.jsxs)("span",{style:{display:"flex",flexDirection:l?"column":"row",alignItems:"center",gap:l?"4px":"6px"},children:[(0,g.jsx)("span",{className:"yop-poll-pro-badge",children:"PRO"}),e]}),R=l=>(0,g.jsxs)("select",{className:"yop-poll-settings-form__select",value:l.reduce((e,l)=>e?.[l]??"no",e),onChange:e=>C(l,e.target.value),children:[(0,g.jsx)("option",{value:"yes",children:(0,b.__)("Yes","yop-poll")}),(0,g.jsx)("option",{value:"no",children:(0,b.__)("No","yop-poll")})]}),T=(0,g.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"12px",marginTop:"24px"},children:[(0,g.jsx)(x.Button,{variant:"primary",onClick:async()=>{if(u(!0),m(""),h(""),f({}),"integrations"===o){const l=(()=>{const l=yl.find(e=>e.key===i);if(!l||l.pro)return null;const o=e.integrations?.[l.key];if("yes"!==o?.enabled)return null;const t={};return l.fields.forEach(e=>{N.includes(e.k)&&!(o[e.k]??"").trim()&&(t[l.key+"."+e.k]=e.l+" "+(0,b.__)("is required when the integration is enabled.","yop-poll"))}),Object.keys(t).length>0?t:null})();if(l)return f(l),m(Object.values(l).join("\n")),h("error"),void u(!1)}try{await(l=e,il()({path:`${rl}/settings`,method:"PUT",data:l})),m((0,b.__)("Settings saved.","yop-poll")),h("success")}catch(e){m((0,b.__)("Failed to save settings.","yop-poll")),h("error")}var l;u(!1)},isBusy:c,disabled:c,children:c?(0,b.__)("Saving…","yop-poll"):(0,b.__)("Update Settings","yop-poll")}),_&&"success"===y&&(0,g.jsx)("span",{style:{color:"#00a32a",fontSize:"13px"},children:_})]}),E=l=>{const o=["integrations",l.key],t="yes"!==(e.integrations?.[l.key]?.enabled??"no");return(0,g.jsxs)("div",{className:"yop-poll-settings-form",children:[S((0,b.__)("Enable","yop-poll"),R([...o,"enabled"])),l.fields.map(e=>S((0,b.__)(e.l,"yop-poll"),k([...o,e.k],t))),T]})},L={general:()=>{return(0,g.jsxs)("div",{className:"yop-poll-settings-form",children:[S((0,b.__)("Remove Plugin Data When Uninstalling","yop-poll"),R(["general","remove-data"])),S((0,b.__)("Use Custom Headers When Retrieving IPs","yop-poll"),R(["general","use-custom-headers-for-ip"])),S(A((0,b.__)("Enable Auto-Refresh","yop-poll")),(l=["general","enable-auto-refresh"],(0,g.jsxs)("select",{className:"yop-poll-settings-form__select",value:l.reduce((e,l)=>e?.[l]??"no",e),onChange:e=>{"yes"===e.target.value?w(!0):C(l,e.target.value)},children:[(0,g.jsx)("option",{value:"yes",children:(0,b.__)("Yes","yop-poll")}),(0,g.jsx)("option",{value:"no",children:(0,b.__)("No","yop-poll")})]}))),S(A((0,b.__)("Refresh Time (in seconds)","yop-poll")),(0,g.jsx)("select",{className:"yop-poll-settings-form__select",value:e.general?.["auto-refresh-time"]??"60",onChange:e=>C(["general","auto-refresh-time"],e.target.value),disabled:!0,children:["5","10","15","30","60","120"].map(e=>(0,g.jsx)("option",{value:e,children:e},e))})),T]});var l},notifications:()=>{return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"yop-settings-integ-bar",children:ml.map(e=>{const l="automatically-reset-votes"===e.key;return(0,g.jsx)("button",{className:"yop-settings-integ-card"+(s===e.key?" is-active":""),onClick:()=>l?w(!0):a(e.key),children:l?A(e.label,!0):e.label},e.key)})}),(l=s,(0,g.jsxs)("div",{className:"yop-poll-settings-form",children:[S((0,b.__)("From Name","yop-poll"),k(["notifications",l,"from-name"])),S((0,b.__)("From Email","yop-poll"),k(["notifications",l,"from-email"])),S((0,b.__)("Recipients","yop-poll"),k(["notifications",l,"recipients"])),S((0,b.__)("Subject","yop-poll"),k(["notifications",l,"subject"])),S((0,b.__)("Body","yop-poll"),(0,g.jsx)("textarea",{className:"yop-poll-settings-form__input",rows:6,value:e.notifications?.[l]?.message??"",onChange:e=>C(["notifications",l,"message"],e.target.value)})),T]}))]});var l},integrations:()=>(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"yop-settings-integ-bar",children:yl.map(e=>(0,g.jsx)("button",{className:"yop-settings-integ-card"+(i===e.key?" is-active":""),onClick:()=>{e.pro?w(!0):(r(e.key),m(""),h(""),f({}))},children:e.pro?A(e.label,!0):e.label},e.key))}),E(yl.find(e=>e.key===i))]}),messages:()=>{return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:"yop-settings-integ-bar",children:hl.map(e=>(0,g.jsx)("button",{className:"yop-settings-integ-card"+(p===e.key?" is-active":""),onClick:()=>d(e.key),children:e.label},e.key))}),(e=p,(0,g.jsxs)("div",{className:"yop-poll-settings-form",children:[xl[e].map(l=>S((0,b.__)(l.l,"yop-poll"),k(["messages",e,l.k]))),T]}))]});var e}};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)("div",{className:"yop-poll-admin-page",children:[(0,g.jsx)("h1",{children:(0,b.__)("Settings","yop-poll")}),(0,g.jsx)("div",{className:"yop-settings-tab-bar",children:_l.map(e=>(0,g.jsx)("button",{className:"yop-settings-tab"+(o===e.key?" is-active":""),onClick:()=>{t(e.key),m(""),h(""),f({})},children:e.label},e.key))}),_&&"error"===y&&(0,g.jsxs)("div",{className:"notice notice-error is-dismissible yop-poll-validation-notice",children:[(0,g.jsx)("p",{children:_}),(0,g.jsx)("button",{type:"button",className:"notice-dismiss",onClick:()=>{m(""),h("")},children:(0,g.jsx)("span",{className:"screen-reader-text",children:(0,b.__)("Dismiss this notice.","yop-poll")})})]}),L[o]()]}),(0,g.jsx)(ve,{open:j,onClose:()=>w(!1)})]})}function gl({pollId:e,page:l}){const{fetchPoll:o}=(0,i.useDispatch)(r);return(0,n.useEffect)(()=>{e&&o(e)},[e]),"results"===l?(0,g.jsx)(ul,{pollId:e}):"bans"===l?(0,g.jsx)(pl,{}):"logs"===l?(0,g.jsx)(dl,{}):"settings"===l?(0,g.jsx)(bl,{}):(0,g.jsx)(al,{pollId:e})}class vl extends n.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,l){console.error("YOP Poll: builder crashed",e,l)}render(){return this.state.hasError?(0,g.jsxs)("div",{style:{padding:"20px"},children:[(0,g.jsx)("h2",{children:(0,b.__)("Something went wrong.","yop-poll")}),(0,g.jsx)("p",{children:(0,b.__)("The poll builder encountered an error. Please reload the page.","yop-poll")}),this.state.error&&(0,g.jsx)("pre",{style:{fontSize:"12px",color:"#777"},children:this.state.error.message}),(0,g.jsx)("button",{className:"button button-primary",onClick:()=>window.location.reload(),children:(0,b.__)("Reload Page","yop-poll")})]}):this.props.children}}function fl(e){return!e||""===e.replace(/<[^>]*>/g,"").trim()}const jl=["#058dc7","#ed561b","#50b432","#990000","#2f7ed8","#f28f43"],wl={"question-text":{makeRequired:"yes",allowMultipleAnswers:"no",allowOtherAnswers:"no",answersDisplay:"vertical",answersColumns:"2",answersSort:"as-defined",multipleAnswersMinim:"",multipleAnswersMaxim:"",otherAnswersLabel:"Other",otherAnswersCount:1,otherFieldType:"single-line",otherFieldSize:"small",otherMaxCharsAllowed:"0",addOtherAnswers:"no",displayOtherAnswersInResults:"no",resultsColorForOtherAnswers:"#058dc7"},"standard-single-line-text":{required:"no",size:"small",align:"left",maxCharsAllowed:0}};function Cl(e){return{type:H,poll:e}}function Nl(e,l){return{type:$,field:e,value:l}}function Sl(e,l,o){return({select:t,dispatch:s})=>{const a=t.getPoll(),n="string"==typeof a.meta_data?JSON.parse(a.meta_data):a.meta_data||{};let i;if(e.includes(".")){const t=e.split("."),[s,a]=t;i={...n,[s]:{...n[s]||{},[a]:{...n[s]?.[a]||{},[l]:o}}}}else i={...n,[e]:{...n[e]||{},[l]:o}};s(Nl("meta_data",i))}}function kl(e){return{type:G,elements:e}}function Al(e){return{type:Y,element:{...e,_tempId:me()}}}function Rl(e,l){return{type:de,element:{...e,_tempId:me()},index:l}}function Tl(e){return({dispatch:l})=>{const o=me();l({type:Y,element:{...e,_tempId:o}}),l(Bl(o))}}function El(e,l){return({dispatch:o})=>{const t=me();o({type:de,element:{...e,_tempId:t},index:l}),o(Bl(t))}}function Ll(e,l){return{type:K,elementId:e,data:l}}function Dl(e){return{type:J,elementId:e}}function Pl(e){return{type:Z,elements:e}}function Bl(e){return{type:Q,elementId:e}}function Il(e,l){return{type:X,elementId:e,subelement:{...l,_tempId:me()}}}function Ml(e,l,o){return{type:ee,elementId:e,subelementId:l,data:o}}function Ol(e,l){return{type:le,elementId:e,subelementId:l}}function zl(e,l){return{type:ie,elementId:e,subelementId:l}}function Vl(e){return{type:oe,tab:e}}function Fl(e){return{type:te,templates:e}}function ql(e){return{type:pe,template:e}}function Wl(e,l,o){return async({dispatch:t})=>{const s=await il()({path:"yop-poll/v1/templates",method:"POST",data:{name:e,base:"custom",rendering_base:l,options:o}});return t(ql(s)),t(Nl("template",s.id)),t(Nl("template_base",l)),s}}function Ul(){return({select:e,dispatch:l})=>{const o=e.getPoll();l(Nl("meta_data",{..."string"==typeof o.meta_data?JSON.parse(o.meta_data):o.meta_data||{},style:{}}))}}function $l(e){return{type:se,mode:e}}function Hl(e){return{type:ne,section:e}}function Gl(e){return{type:ae,ui:e}}function Yl(){return{type:re}}function Kl(){return async({select:e,dispatch:l})=>{l(Gl({saving:!0}));try{const o=e.getPoll(),t=e.getElements(),s=function(e,l){const o=[],t=("string"==typeof e.meta_data?JSON.parse(e.meta_data):e.meta_data)||{},s=t.options?.poll||{},a=t.options?.access||{},n=t.options?.results||{};if(e.template&&0!==e.template||o.push((0,b.__)("Please select a template.","yop-poll")),e.name&&""!==e.name.trim()||o.push((0,b.__)("Poll name is required.","yop-poll")),0===l.length)return o.push((0,b.__)("At least one element is required.","yop-poll")),o;const i=["question-text"];return l.forEach(e=>{const l=("string"==typeof e.meta_data?JSON.parse(e.meta_data):e.meta_data)||{},t=e.subelements||[],s=e.etype||"",a=e.etext||s;if((i.includes(s)||"standard-single-line-text"===s)&&fl(e.etext))o.push((0,b.__)("All questions and custom fields must have a label.","yop-poll"));else{if(i.includes(s)){if(0===t.length)return void o.push((0,b.sprintf)(/* translators: %s: question label */ /* translators: %s: question label */
(0,b.__)('Question "%s" has no answers.',"yop-poll"),a));t.forEach(e=>{fl(e.stext)&&o.push((0,b.sprintf)((0,b.__)('All answers in question "%s" must have text.',"yop-poll"),a))}),"yes"===(l.allowOtherAnswers||"no")&&(fl(l.otherAnswersLabel)&&o.push((0,b.sprintf)((0,b.__)('Other answers label is required for question "%s".',"yop-poll"),a)),""===String(l.otherMaxCharsAllowed??"0").trim()&&o.push((0,b.sprintf)((0,b.__)('Max chars for other answers is required for question "%s".',"yop-poll"),a))),"yes"===(l.allowMultipleAnswers||"no")&&(void 0!==l.multipleAnswersMinim&&""!==String(l.multipleAnswersMinim).trim()||o.push((0,b.sprintf)((0,b.__)('Minimum answers required is required for question "%s".',"yop-poll"),a)),void 0!==l.multipleAnswersMaxim&&""!==String(l.multipleAnswersMaxim).trim()||o.push((0,b.sprintf)((0,b.__)('Maximum answers allowed is required for question "%s".',"yop-poll"),a)))}"standard-single-line-text"===s&&""===String(l.maxCharsAllowed??"0").trim()&&o.push((0,b.sprintf)((0,b.__)('Max chars is required for "%s".',"yop-poll"),a))}}),"yes"===(s.redirectAfterVote||"no")&&(s.redirectUrl&&""!==s.redirectUrl.trim()||o.push((0,b.__)("Redirect link is required when redirect after vote is enabled.","yop-poll")),void 0!==s.redirectAfter&&""!==String(s.redirectAfter).trim()||o.push((0,b.__)("Redirect delay (seconds) is required when redirect after vote is enabled.","yop-poll"))),"custom"===(s.startDateOption||"now")&&(s.startDateCustom&&""!==s.startDateCustom||o.push((0,b.__)("Custom start date is required.","yop-poll"))),"custom"===(s.endDateOption||"never")&&(s.endDateCustom&&""!==s.endDateCustom||o.push((0,b.__)("Custom end date is required.","yop-poll"))),"yes"===(s.resetPollStatsAutomatically||"no")&&(s.resetPollStatsOn&&""!==s.resetPollStatsOn||o.push((0,b.__)("Reset date is required when automatic stats reset is enabled.","yop-poll"))),"yes"===(s.sendEmailNotifications||"no")&&(s.emailNotificationsFromName&&""!==s.emailNotificationsFromName.trim()||o.push((0,b.__)("From Name is required for Email Notifications.","yop-poll")),s.emailNotificationsFromEmail&&""!==s.emailNotificationsFromEmail.trim()||o.push((0,b.__)("From Email is required for Email Notifications.","yop-poll")),s.emailNotificationsRecipients&&""!==s.emailNotificationsRecipients.trim()||o.push((0,b.__)("Recipients are required for Email Notifications.","yop-poll")),s.emailNotificationsSubject&&""!==s.emailNotificationsSubject.trim()||o.push((0,b.__)("Subject is required for Email Notifications.","yop-poll")),s.emailNotificationsMessage&&""!==s.emailNotificationsMessage.trim()||o.push((0,b.__)("Message is required for Email Notifications.","yop-poll"))),"yes"===(a.limitVotesPerUser||"no")&&(void 0!==a.votesPerUserAllowed&&""!==String(a.votesPerUserAllowed).trim()||o.push((0,b.__)('Votes per user is required when "Limit Votes Per User" is enabled.',"yop-poll"))),(a.blockVoters||["no-block"]).includes("no-block")||"limited-time"!==(a.blockLengthType||"forever")||void 0!==a.blockForValue&&""!==String(a.blockForValue).trim()||o.push((0,b.__)("Block period length is required when using limited-time blocking.","yop-poll")),!(n.showResultsMoment||["after-vote"]).includes("custom-date")||n.customDateResults&&""!==n.customDateResults||o.push((0,b.__)('Custom date is required when "Custom date" is selected for Show Results.',"yop-poll")),o}(o,t);if(s.length>0){l(Gl({saving:!1}));const e=new Error("Validation failed");throw e.validationErrors=s,e}const a="string"==typeof o.meta_data?JSON.parse(o.meta_data):o.meta_data,n={...o,status:a?.options?.poll?.status??o.status,meta_data:a,elements:t.map((e,l)=>{return{...e.id?{id:e.id}:{},etext:e.etext||"",etype:e.etype,status:e.status||"active",sorder:l,meta_data:{...(o=e.etype,wl[o]||{}),..."string"==typeof e.meta_data?JSON.parse(e.meta_data):e.meta_data||{}},subelements:(e.subelements||[]).map((e,l)=>{const o="string"==typeof e.meta_data?JSON.parse(e.meta_data):{...e.meta_data||{}};return{...e.id?{id:e.id}:{},stext:e.stext||"",stype:e.stype||"text",status:e.status||"active",sorder:l,meta_data:{...(e.stype,t=l,{makeDefault:"0",makeLink:"0",link:"",resultsColor:jl[t%jl.length]}),...o}};var t})};var o})};let i;i=o.id?await il()({path:`yop-poll/v1/polls/${o.id}`,method:"PUT",data:n}):await il()({path:"yop-poll/v1/polls",method:"POST",data:n}),l(Cl({...i,meta_data:"string"==typeof i.meta_data?JSON.parse(i.meta_data):i.meta_data}));const r=e.getSelectedElementId();return l(kl(i.elements||[])),r&&(i.elements||[]).some(e=>e.id===r)&&l(Bl(r)),l(Gl({saving:!1,dirty:!1})),i}catch(e){throw l(Gl({saving:!1})),e}}}function Jl(e){return async({dispatch:l})=>{l(Gl({loading:!0}));try{const o=await il()({path:`yop-poll/v1/polls/${e}`});let t={...o,meta_data:"string"==typeof o.meta_data?JSON.parse(o.meta_data):o.meta_data};const s="object"==typeof t.meta_data?t.meta_data:{};s?.options?.poll?.voteButtonLabel||(t={...t,meta_data:{...s,options:{...s.options||{},poll:{...s.options?.poll||{},voteButtonLabel:"Vote"}}}}),l(Cl(t)),l(kl(o.elements||[])),l(Gl({loading:!1}))}catch(e){throw l(Gl({loading:!1})),e}}}function Zl(){return async({dispatch:e})=>{try{const l=await il()({path:"yop-poll/v1/templates"});l.items&&l.items.length&&e(Fl(l.items))}catch(e){console.error("YOP Poll: failed to fetch templates",e)}}}function Ql(e){return e.poll}function Xl(e){return e.elements}function eo(e){return e.selectedElementId}function lo(e){return e.selectedElementId&&e.elements.find(l=>(l.id||l._tempId)===e.selectedElementId)||null}function oo(e){return e.activeTab}function to(e){return e.templates}function so(e,l){return e.templates.find(e=>e.base===l)||null}function ao(e){return e.sidebarMode}function no(e){return e.optionsSection}function io(e){return e.ui}function ro(e){return e.ui.saving}function po(e){return e.ui.loading}function co(e){return e.ui.dirty}function uo(e,l){return e.elements.some(e=>e.etype===l)}function _o(){return async({dispatch:e})=>{await e(Zl())}}const mo=(0,i.createReduxStore)(r,{reducer:function(e=ue,l){switch(l.type){case H:return{...e,poll:l.poll,ui:{...e.ui,dirty:!1}};case $:return{...e,poll:{...e.poll,[l.field]:l.value},ui:{...e.ui,dirty:!0}};case G:return{...e,elements:l.elements,selectedElementId:null,sidebarMode:y};case Y:{const o={...l.element,_tempId:l.element._tempId||me(),sorder:e.elements.length,subelements:(l.element.subelements||[]).map(e=>({...e,_tempId:e._tempId||me()}))};return{...e,elements:[...e.elements,o],ui:{...e.ui,dirty:!0}}}case de:{const o={...l.element,_tempId:l.element._tempId||me(),sorder:l.index,subelements:(l.element.subelements||[]).map(e=>({...e,_tempId:e._tempId||me()}))},t=Math.min(Math.max(l.index,0),e.elements.length),s=[...e.elements.slice(0,t),o,...e.elements.slice(t)].map((e,l)=>({...e,sorder:l}));return{...e,elements:s,ui:{...e.ui,dirty:!0}}}case K:return{...e,elements:e.elements.map(e=>(e.id||e._tempId)===l.elementId?{...e,...l.data}:e),ui:{...e.ui,dirty:!0}};case J:{const o=e.elements.filter(e=>(e.id||e._tempId)!==l.elementId),t=o.some(e=>"advanced-email"===e.etype),s=e.poll.meta_data||{},a=s.options?.access||{},n=t?e.poll:{...e.poll,meta_data:{...s,options:{...s.options||{},access:{...a,votePermissions:(a.votePermissions||[]).filter(e=>"email"!==e),blockVoters:(a.blockVoters||[]).filter(e=>"by-email"!==e)}}}};return{...e,poll:n,elements:o,selectedElementId:e.selectedElementId===l.elementId?null:e.selectedElementId,sidebarMode:e.selectedElementId===l.elementId?y:e.sidebarMode,ui:{...e.ui,dirty:!0}}}case Z:{const o=l.elements.map((e,l)=>({...e,sorder:l}));return{...e,elements:o,ui:{...e.ui,dirty:!0}}}case Q:return{...e,selectedElementId:l.elementId,sidebarMode:l.elementId?h:y};case X:return{...e,elements:e.elements.map(e=>{if((e.id||e._tempId)===l.elementId){const o=e.subelements||[];return{...e,subelements:[...o,{...l.subelement,_tempId:l.subelement._tempId||me(),sorder:o.length}]}}return e}),ui:{...e.ui,dirty:!0}};case ee:return{...e,elements:e.elements.map(e=>(e.id||e._tempId)===l.elementId?{...e,subelements:(e.subelements||[]).map(e=>(e.id||e._tempId)===l.subelementId?{...e,...l.data}:e)}:e),ui:{...e.ui,dirty:!0}};case ie:return{...e,elements:e.elements.map(e=>(e.id||e._tempId)===l.elementId?{...e,subelements:(e.subelements||[]).map(e=>{const o=e.id||e._tempId,t=e.meta_data&&"object"==typeof e.meta_data?e.meta_data:{};return{...e,meta_data:{...t,makeDefault:l.subelementId&&o===l.subelementId?"1":"0"}}})}:e),ui:{...e.ui,dirty:!0}};case le:return{...e,elements:e.elements.map(e=>(e.id||e._tempId)===l.elementId?{...e,subelements:(e.subelements||[]).filter(e=>(e.id||e._tempId)!==l.subelementId)}:e),ui:{...e.ui,dirty:!0}};case oe:return{...e,activeTab:l.tab};case te:return{...e,templates:l.templates.map(e=>{const l=ce.find(l=>l.base===e.base);return l?.pro?{...e,pro:l.pro}:e})};case pe:return{...e,templates:[...e.templates,l.template]};case se:return{...e,sidebarMode:l.mode,selectedElementId:l.mode===y?null:e.selectedElementId};case ne:return{...e,optionsSection:l.section};case ae:return{...e,ui:{...e.ui,...l.ui}};case re:return{...ue};default:return e}},actions:t,selectors:s,resolvers:a,__experimentalUseThunks:!0});(0,i.register)(mo);const yo=document.getElementById("yop-poll-admin");if(yo){const e=(0,n.createRoot)(yo),l=parseInt(yo.dataset.pollId,10)||0,o=yo.dataset.page||"";e.render((0,g.jsx)(vl,{children:(0,g.jsx)(gl,{pollId:l,page:o})}))}}},o={};function t(e){var s=o[e];if(void 0!==s)return s.exports;var a=o[e]={exports:{}};return l[e](a,a.exports,t),a.exports}t.m=l,e=[],t.O=(l,o,s,a)=>{if(!o){var n=1/0;for(d=0;d<e.length;d++){for(var[o,s,a]=e[d],i=!0,r=0;r<o.length;r++)(!1&a||n>=a)&&Object.keys(t.O).every(e=>t.O[e](o[r]))?o.splice(r--,1):(i=!1,a<n&&(n=a));if(i){e.splice(d--,1);var p=s();void 0!==p&&(l=p)}}return l}a=a||0;for(var d=e.length;d>0&&e[d-1][2]>a;d--)e[d]=e[d-1];e[d]=[o,s,a]},t.n=e=>{var l=e&&e.__esModule?()=>e.default:()=>e;return t.d(l,{a:l}),l},t.d=(e,l)=>{for(var o in l)t.o(l,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:l[o]})},t.o=(e,l)=>Object.prototype.hasOwnProperty.call(e,l),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e={884:0,15:0};t.O.j=l=>0===e[l];var l=(l,o)=>{var s,a,[n,i,r]=o,p=0;if(n.some(l=>0!==e[l])){for(s in i)t.o(i,s)&&(t.m[s]=i[s]);if(r)var d=r(t)}for(l&&l(o);p<n.length;p++)a=n[p],t.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return t.O(d)},o=globalThis.webpackChunkyop_poll=globalThis.webpackChunkyop_poll||[];o.forEach(l.bind(null,0)),o.push=l.bind(null,o.push.bind(o))})();var s=t.O(void 0,[15],()=>t(999));s=t.O(s)})();