@apollosproject/canvas-embeds 2.1.2049 → 2.1.2051
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/widget/index.js +1 -1
package/package.json
CHANGED
package/widget/index.js
CHANGED
|
@@ -619,7 +619,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
621
|
}
|
|
622
|
-
`);const Ct1=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M79.51,144.49a12,12,0,1,1,17-17L112,143l47.51-47.52a12,12,0,0,1,17,17l-56,56a12,12,0,0,1-17,0ZM228,48V208a20,20,0,0,1-20,20H48a20,20,0,0,1-20-20V48A20,20,0,0,1,48,28H208A20,20,0,0,1,228,48Zm-24,4H52V204H204Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,48V208a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V48a8,8,0,0,1,8-8H208A8,8,0,0,1,216,48Z",opacity:"0.2"}),e.createElement("path",{d:"M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM224,48V208a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48ZM208,208V48H48V208H208Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Zm-34.34,77.66-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35a8,8,0,0,1,11.32,11.32Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M172.24,99.76a6,6,0,0,1,0,8.48l-56,56a6,6,0,0,1-8.48,0l-24-24a6,6,0,0,1,8.48-8.48L112,151.51l51.76-51.75A6,6,0,0,1,172.24,99.76ZM222,48V208a14,14,0,0,1-14,14H48a14,14,0,0,1-14-14V48A14,14,0,0,1,48,34H208A14,14,0,0,1,222,48Zm-12,0a2,2,0,0,0-2-2H48a2,2,0,0,0-2,2V208a2,2,0,0,0,2,2H208a2,2,0,0,0,2-2Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM224,48V208a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48ZM208,208V48H48V208H208Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M170.83,101.17a4,4,0,0,1,0,5.66l-56,56a4,4,0,0,1-5.66,0l-24-24a4,4,0,0,1,5.66-5.66L112,154.34l53.17-53.17A4,4,0,0,1,170.83,101.17ZM220,48V208a12,12,0,0,1-12,12H48a12,12,0,0,1-12-12V48A12,12,0,0,1,48,36H208A12,12,0,0,1,220,48Zm-8,0a4,4,0,0,0-4-4H48a4,4,0,0,0-4,4V208a4,4,0,0,0,4,4H208a4,4,0,0,0,4-4Z"}))]]),U_=e.forwardRef((a,t)=>e.createElement(k,{ref:t,...a,weights:Ct1}));U_.displayName="CheckSquareIcon";const fv0=U_,Tt1=Object.freeze(Object.defineProperty({__proto__:null,CheckSquare:fv0,CheckSquareIcon:U_},Symbol.toStringTag,{value:"Module"})),It1=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M232,128A104,104,0,1,1,128,24,104.13,104.13,0,0,1,232,128Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Z"}))]]),q_=e.forwardRef((a,t)=>e.createElement(k,{ref:t,...a,weights:It1}));q_.displayName="CircleIcon";const gv0=q_,xt1=Object.freeze(Object.defineProperty({__proto__:null,Circle:gv0,CircleIcon:q_},Symbol.toStringTag,{value:"Module"})),Pt1=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208,28H48A20,20,0,0,0,28,48V208a20,20,0,0,0,20,20H208a20,20,0,0,0,20-20V48A20,20,0,0,0,208,28Zm-4,176H52V52H204Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,48V208a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V48a8,8,0,0,1,8-8H208A8,8,0,0,1,216,48Z",opacity:"0.2"}),e.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Zm0,176H48V48H208V208Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,48V208a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208,34H48A14,14,0,0,0,34,48V208a14,14,0,0,0,14,14H208a14,14,0,0,0,14-14V48A14,14,0,0,0,208,34Zm2,174a2,2,0,0,1-2,2H48a2,2,0,0,1-2-2V48a2,2,0,0,1,2-2H208a2,2,0,0,1,2,2Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Zm0,176H48V48H208V208Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208,36H48A12,12,0,0,0,36,48V208a12,12,0,0,0,12,12H208a12,12,0,0,0,12-12V48A12,12,0,0,0,208,36Zm4,172a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V48a4,4,0,0,1,4-4H208a4,4,0,0,1,4,4Z"}))]]),G_=e.forwardRef((a,t)=>e.createElement(k,{ref:t,...a,weights:Pt1}));G_.displayName="SquareIcon";const vv0=G_,Ot1=Object.freeze(Object.defineProperty({__proto__:null,Square:vv0,SquareIcon:G_},Symbol.toStringTag,{value:"Module"})),Rt1=(a,t,n)=>a.includes(t)?{ids:a.filter(l=>l!==t),action:"deselected"}:{ids:[...n>0&&a.length>=n?a.slice(Math.max(0,a.length-n+1)):a,t],action:"selected"},$t1=({poll:a,userProfile:t})=>{const n=zv(),[r,l]=e.useState([]),[i,o]=e.useState(!1),[s,c]=e.useState(void 0),d=!!t?.id,h=a?.maxSelections??1,p=h===1?"SingleChoice":"MultiChoice",f=p==="MultiChoice",v=h===0?a?.options?.length??0:h,Z=f&&v>1,E=f?fv0:$_,M=f?vv0:gv0,V=a?.totalOptionVotes||0,L=a?.currentUserVotes||[],b=L.length>0,N=e.useMemo(()=>{if(typeof window>"u")return;const[,e0]=window.location.pathname.split("/c/");return e0||void 0},[]),F=new Set(L.map(e0=>e0?.option?.id).filter(Boolean));e.useEffect(()=>{a&&n.track("Poll Viewed",{pollId:a.id,pollTitle:a.title,pollStatus:a.status,optionCount:a.options?.length||0,hasExistingVote:b,contentId:N})},[n,N,b,a]);const w=t?.firstName&&t?.lastName?`${t.firstName.charAt(0)}${t.lastName.charAt(0)}`.toUpperCase():t?.firstName?t.firstName.charAt(0).toUpperCase():"?",P=e0=>{if(!a||a.status!=="Active"||i||b)return;const W=a.options?.find(g0=>g0?.id===e0),{ids:q,action:s0}=Rt1(r,e0,h);l(q),n.track("Poll Option Selected",{pollId:a.id,optionId:e0,optionValue:W?.value,action:s0})},x=async()=>{if(!(r.length===0||!a))if(d)await j();else{const e0=window.location.pathname,W=Wu(e0);if(!W){c("Unable to proceed. Please try again.");return}const q=uv0(W,e0,{type:"pollVote",pollId:a.id,optionIds:r});window.location.href=q}},j=async()=>{if(a){o(!0),c(void 0);try{const e0=Wu(window.location.pathname)||"",W=new FormData;W.append("_action","submitVote"),W.append("pollId",a.id),W.append("optionIds",JSON.stringify(r)),W.append("church",e0);const q=await fetch("/api/poll-vote",{method:"POST",body:W});if(!q.ok)throw new Error("Failed to save your selection");const s0=await q.json();if(s0.success){const g0=a.options?.filter(o0=>o0?.id?r.includes(o0.id):!1)||[];n.track("Poll Vote Submitted",{pollId:a.id,pollTitle:a.title,optionIds:r,optionValues:g0.map(o0=>o0?.value||""),optionCount:r.length,mode:p,isChangeVote:b,contentId:N}),window.location.reload()}else n.track("Poll Vote Failed",{pollId:a.id,error:s0.message||"Failed to save your selection"}),c(s0.message||"Failed to save your selection")}catch(e0){const W=e0 instanceof Error?e0.message:"Failed to save your selection";n.track("Poll Vote Failed",{pollId:a.id,error:W}),c("Failed to save your selection. Please try again."),console.error("PollView: Error in submitVoteDirectly",e0)}finally{o(!1)}}},R=a?.status==="Active"&&r.length>0&&!b,G=a?.showResults??!0,J=G&&(a?.status!=="Active"||b);return a?C.jsx(C.Fragment,{children:C.jsxs("div",{className:"bg-system-chrome shadow-sm dark:bg-material-regular-dark rounded-xl backdrop-blur-md p-4 my-4 dark:border-white/5 dark:border",children:[C.jsxs("div",{className:"mt-0 flex flex-col gap-1",children:[C.jsx("div",{className:"font-semibold text-2xl",children:a.title}),Z?C.jsxs("div",{className:"text-sm text-fg-secondary dark:text-fg-secondary-dark",children:["Max of ",v]}):null]}),C.jsx("div",{className:"mt-5 flex flex-col gap-3",children:a.options?.map((e0,W)=>{const q=r.includes(e0?.id||""),s0=e0?.value||"",g0=e0?.id||"",o0=e0?.totalVotes||0,l0=V>0?o0/V*100:0,U=F.has(g0),X=a.status==="Active"&&!i&&!b;return C.jsxs("div",{className:`flex flex-row gap-2 items-center border rounded-3xl transition-colors relative overflow-hidden ${X?q?"bg-action/10 border-action dark:border-action-dark cursor-pointer":"text-fg-secondary dark:text-fg-primary-dark border-system-thin dark:border-system-regular-dark hover:bg-system-regular dark:hover:bg-system-regular-dark cursor-pointer":"text-fg-secondary dark:text-fg-primary-dark border-system-thin dark:border-system-regular-dark cursor-not-allowed"}`,onClick:()=>P(g0),children:[J?C.jsx("div",{className:`absolute left-0 top-0 bottom-0 transition-all duration-300 ${U?"bg-action/20 dark:bg-action-dark/20":"bg-system-regular/40 dark:bg-system-regular-dark/40"}`,style:{width:`${l0}%`}}):null,C.jsxs("div",{className:"relative flex flex-row gap-2 items-center p-2 flex-1",children:[J&&U&&t?C.jsx(E7,{src:t.photo?.uri,initials:w,alt:"Your selection",className:"w-8 h-8",noBorder:!0}):q?C.jsx(E,{weight:"fill",size:24,className:"text-action"}):C.jsx(M,{weight:"thin",size:24,className:J?"opacity-0":""}),C.jsx("span",{className:`flex-1 ${U?"font-semibold":""}`,children:s0}),J?C.jsxs("div",{className:"flex flex-row gap-3 items-center",children:[C.jsxs("span",{className:`text-sm ${U?"font-semibold":"text-fg-secondary dark:text-fg-secondary-dark"}`,children:[l0.toFixed(0),"%"]}),C.jsx("span",{className:"text-xs text-fg-secondary dark:text-fg-secondary-dark min-w-[24px] text-right",children:o0})]}):null]})]},`option-${g0||W}`)})}),R?C.jsx("div",{className:"mt-4",children:C.jsx(Z2,{onClick:x,disabled:i,surface:"solid",className:"w-full",children:i?"Saving...":"Submit"})}):null,s?C.jsx("div",{className:"mt-2 text-red-500 text-sm",children:s}):null,G?C.jsx("div",{className:"mt-3 flex flex-row gap-4 items-center justify-between px-1",children:C.jsxs("div",{className:"text-fg-secondary dark:text-fg-secondary-dark text-sm text-action",children:[V," ",V===1?"response":"responses"]})}):null]})}):null},Dt1=({feature:a,church:t,userProfile:n,isInteractionEnabled:r,theme:l})=>a.poll?.status&&a.poll.status!=="Inactive"?C.jsx($t1,{poll:a.poll,church:t,userProfile:n,isInteractionEnabled:r,theme:l}):null;xe(`
|
|
622
|
+
`);const Ct1=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M79.51,144.49a12,12,0,1,1,17-17L112,143l47.51-47.52a12,12,0,0,1,17,17l-56,56a12,12,0,0,1-17,0ZM228,48V208a20,20,0,0,1-20,20H48a20,20,0,0,1-20-20V48A20,20,0,0,1,48,28H208A20,20,0,0,1,228,48Zm-24,4H52V204H204Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,48V208a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V48a8,8,0,0,1,8-8H208A8,8,0,0,1,216,48Z",opacity:"0.2"}),e.createElement("path",{d:"M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM224,48V208a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48ZM208,208V48H48V208H208Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Zm-34.34,77.66-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35a8,8,0,0,1,11.32,11.32Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M172.24,99.76a6,6,0,0,1,0,8.48l-56,56a6,6,0,0,1-8.48,0l-24-24a6,6,0,0,1,8.48-8.48L112,151.51l51.76-51.75A6,6,0,0,1,172.24,99.76ZM222,48V208a14,14,0,0,1-14,14H48a14,14,0,0,1-14-14V48A14,14,0,0,1,48,34H208A14,14,0,0,1,222,48Zm-12,0a2,2,0,0,0-2-2H48a2,2,0,0,0-2,2V208a2,2,0,0,0,2,2H208a2,2,0,0,0,2-2Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM224,48V208a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48ZM208,208V48H48V208H208Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M170.83,101.17a4,4,0,0,1,0,5.66l-56,56a4,4,0,0,1-5.66,0l-24-24a4,4,0,0,1,5.66-5.66L112,154.34l53.17-53.17A4,4,0,0,1,170.83,101.17ZM220,48V208a12,12,0,0,1-12,12H48a12,12,0,0,1-12-12V48A12,12,0,0,1,48,36H208A12,12,0,0,1,220,48Zm-8,0a4,4,0,0,0-4-4H48a4,4,0,0,0-4,4V208a4,4,0,0,0,4,4H208a4,4,0,0,0,4-4Z"}))]]),U_=e.forwardRef((a,t)=>e.createElement(k,{ref:t,...a,weights:Ct1}));U_.displayName="CheckSquareIcon";const fv0=U_,Tt1=Object.freeze(Object.defineProperty({__proto__:null,CheckSquare:fv0,CheckSquareIcon:U_},Symbol.toStringTag,{value:"Module"})),It1=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M232,128A104,104,0,1,1,128,24,104.13,104.13,0,0,1,232,128Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Z"}))]]),q_=e.forwardRef((a,t)=>e.createElement(k,{ref:t,...a,weights:It1}));q_.displayName="CircleIcon";const gv0=q_,xt1=Object.freeze(Object.defineProperty({__proto__:null,Circle:gv0,CircleIcon:q_},Symbol.toStringTag,{value:"Module"})),Pt1=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208,28H48A20,20,0,0,0,28,48V208a20,20,0,0,0,20,20H208a20,20,0,0,0,20-20V48A20,20,0,0,0,208,28Zm-4,176H52V52H204Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,48V208a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V48a8,8,0,0,1,8-8H208A8,8,0,0,1,216,48Z",opacity:"0.2"}),e.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Zm0,176H48V48H208V208Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,48V208a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208,34H48A14,14,0,0,0,34,48V208a14,14,0,0,0,14,14H208a14,14,0,0,0,14-14V48A14,14,0,0,0,208,34Zm2,174a2,2,0,0,1-2,2H48a2,2,0,0,1-2-2V48a2,2,0,0,1,2-2H208a2,2,0,0,1,2,2Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Zm0,176H48V48H208V208Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208,36H48A12,12,0,0,0,36,48V208a12,12,0,0,0,12,12H208a12,12,0,0,0,12-12V48A12,12,0,0,0,208,36Zm4,172a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V48a4,4,0,0,1,4-4H208a4,4,0,0,1,4,4Z"}))]]),G_=e.forwardRef((a,t)=>e.createElement(k,{ref:t,...a,weights:Pt1}));G_.displayName="SquareIcon";const vv0=G_,Ot1=Object.freeze(Object.defineProperty({__proto__:null,Square:vv0,SquareIcon:G_},Symbol.toStringTag,{value:"Module"})),Rt1=(a,t,n)=>a.includes(t)?{ids:a.filter(l=>l!==t),action:"deselected"}:{ids:[...n>0&&a.length>=n?a.slice(Math.max(0,a.length-n+1)):a,t],action:"selected"},$t1=({poll:a,userProfile:t})=>{const n=zv(),[r,l]=e.useState([]),[i,o]=e.useState(!1),[s,c]=e.useState(void 0),d=!!t?.id,h=a?.maxSelections??1,p=h===1?"SingleChoice":"MultiChoice",f=p==="MultiChoice",v=h===0?a?.options?.length??0:h,Z=f&&v>1,E=f?fv0:$_,M=f?vv0:gv0,V=a?.totalOptionVotes||0,L=a?.currentUserVotes||[],b=L.length>0,N=e.useMemo(()=>{if(typeof window>"u")return;const[,e0]=window.location.pathname.split("/c/");return e0||void 0},[]),F=new Set(L.map(e0=>e0?.option?.id).filter(Boolean));e.useEffect(()=>{a&&n.track("Poll Viewed",{pollId:a.id,pollTitle:a.title,pollStatus:a.status,optionCount:a.options?.length||0,hasExistingVote:b,contentId:N})},[n,N,b,a]);const w=t?.firstName&&t?.lastName?`${t.firstName.charAt(0)}${t.lastName.charAt(0)}`.toUpperCase():t?.firstName?t.firstName.charAt(0).toUpperCase():"?",P=e0=>{if(!a||a.status!=="Active"||i||b)return;const W=a.options?.find(g0=>g0?.id===e0),{ids:q,action:s0}=Rt1(r,e0,h);l(q),n.track("Poll Option Selected",{pollId:a.id,optionId:e0,optionValue:W?.value,action:s0})},x=async()=>{if(!(r.length===0||!a))if(d)await j();else{const e0=window.location.pathname,W=Wu(e0);if(!W){c("Unable to proceed. Please try again.");return}const q=uv0(W,e0,{type:"pollVote",pollId:a.id,optionIds:r});window.location.href=q}},j=async()=>{if(a){o(!0),c(void 0);try{const e0=Wu(window.location.pathname)||"",W=new FormData;W.append("_action","submitVote"),W.append("pollId",a.id),W.append("optionIds",JSON.stringify(r)),W.append("church",e0);const q=await fetch("/api/poll-vote",{method:"POST",body:W});if(!q.ok)throw new Error("Failed to save your selection");const s0=await q.json();if(s0.success){const g0=a.options?.filter(o0=>o0?.id?r.includes(o0.id):!1)||[];n.track("Poll Vote Submitted",{pollId:a.id,pollTitle:a.title,optionIds:r,optionValues:g0.map(o0=>o0?.value||""),optionCount:r.length,mode:p,isChangeVote:b,contentId:N}),window.location.reload()}else n.track("Poll Vote Failed",{pollId:a.id,error:s0.message||"Failed to save your selection"}),c(s0.message||"Failed to save your selection")}catch(e0){const W=e0 instanceof Error?e0.message:"Failed to save your selection";n.track("Poll Vote Failed",{pollId:a.id,error:W}),c("Failed to save your selection. Please try again."),console.error("PollView: Error in submitVoteDirectly",e0)}finally{o(!1)}}},R=a?.status==="Active"&&r.length>0&&!b,G=a?.showResults??!0,J=G&&(a?.status!=="Active"||b);return a?C.jsx(C.Fragment,{children:C.jsxs("div",{className:"bg-system-chrome shadow-sm dark:bg-material-regular-dark rounded-xl backdrop-blur-md p-4 my-4 dark:border-white/5 dark:border",children:[C.jsxs("div",{className:"mt-0 flex flex-col gap-1",children:[C.jsx("div",{className:"font-semibold text-2xl",children:a.title}),Z?C.jsxs("div",{className:"text-sm text-fg-secondary dark:text-fg-secondary-dark",children:["Max of ",v]}):null]}),C.jsx("div",{className:"mt-5 flex flex-col gap-3",children:a.options?.map((e0,W)=>{const q=r.includes(e0?.id||""),s0=e0?.value||"",g0=e0?.id||"",o0=e0?.totalVotes||0,l0=V>0?o0/V*100:0,U=F.has(g0),X=a.status==="Active"&&!i&&!b;return C.jsxs("div",{className:`flex flex-row gap-2 items-center border rounded-3xl transition-colors relative overflow-hidden ${X?q?"bg-action/10 border-action dark:border-action-dark cursor-pointer":"text-fg-secondary dark:text-fg-primary-dark border-system-thin dark:border-system-regular-dark hover:bg-system-regular dark:hover:bg-system-regular-dark cursor-pointer":"text-fg-secondary dark:text-fg-primary-dark border-system-thin dark:border-system-regular-dark cursor-not-allowed"}`,onClick:()=>P(g0),children:[J?C.jsx("div",{className:`absolute left-0 top-0 bottom-0 transition-all duration-300 ${U?"bg-action/20 dark:bg-action-dark/20":"bg-system-regular/40 dark:bg-system-regular-dark/40"}`,style:{width:`${l0}%`}}):null,C.jsxs("div",{className:"relative flex flex-row gap-2 items-center p-2 flex-1",children:[J&&U&&t?C.jsx(E7,{src:t.photo?.uri,initials:w,alt:"Your selection",className:"w-8 h-8",noBorder:!0}):q||U?C.jsx(E,{weight:"fill",size:24,className:"text-action"}):C.jsx(M,{weight:"thin",size:24,className:J?"opacity-0":""}),C.jsx("span",{className:`flex-1 ${U?"font-semibold":""}`,children:s0}),J?C.jsxs("div",{className:"flex flex-row gap-3 items-center",children:[C.jsxs("span",{className:`text-sm ${U?"font-semibold":"text-fg-secondary dark:text-fg-secondary-dark"}`,children:[l0.toFixed(0),"%"]}),C.jsx("span",{className:"text-xs text-fg-secondary dark:text-fg-secondary-dark min-w-[24px] text-right",children:o0})]}):null]})]},`option-${g0||W}`)})}),R?C.jsx("div",{className:"mt-4",children:C.jsx(Z2,{onClick:x,disabled:i,surface:"solid",className:"w-full",children:i?"Saving...":"Submit"})}):null,s?C.jsx("div",{className:"mt-2 text-red-500 text-sm",children:s}):null,G?C.jsx("div",{className:"mt-3 flex flex-row gap-4 items-center justify-between px-1",children:C.jsxs("div",{className:"text-fg-secondary dark:text-fg-secondary-dark text-sm text-action",children:[V," ",V===1?"response":"responses"]})}):null]})}):null},Dt1=({feature:a,church:t,userProfile:n,isInteractionEnabled:r,theme:l})=>a.poll?.status&&a.poll.status!=="Inactive"?C.jsx($t1,{poll:a.poll,church:t,userProfile:n,isInteractionEnabled:r,theme:l}):null;xe(`
|
|
623
623
|
fragment PollFeatureFragment on PollFeature {
|
|
624
624
|
poll {
|
|
625
625
|
id
|