import{r as a,j as e,u as s}from"./router.chunk.YsRm4bSN.js";import{aE as n,u as i,l,J as t,av as o,A as r,R as d,$ as u,L as c,N as m,aC as p,aD as f,az as g,K as v,aN as h}from"./main.chunk.N-eZ2ybB.js";import{aE as w,aF as x,f as j,aG as k}from"./icons.chunk.BwnSC3zE.js";import{_ as __}from"./wordpress.chunk.BVds2GcU.js";import{k as b}from"./forms.chunk.Bz8aaTWe.js";import{S}from"./campaign.chunk.Bl3EV_wc.js";import{C}from"./campaign-context.chunk.BmsJZ0pE.js";import{a as E}from"./campaign.chunk.BU0ryCmb.js";import{l as M}from"./campaign.chunk.DLkjF6XJ.js";import{u as N}from"./use-wp-layout.chunk.BWIP3R_N.js";const L=e=>a.createElement("svg",{viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.333 3.267a.4.4 0 0 0-.4.4v8.666a.4.4 0 0 0 .4.4H8a.6.6 0 1 1 0 1.2H2.333a1.6 1.6 0 0 1-1.6-1.6V3.667a1.6 1.6 0 0 1 1.6-1.6h11.334a1.6 1.6 0 0 1 1.6 1.6v4.02a.6.6 0 0 1-1.2 0v-4.02a.4.4 0 0 0-.4-.4H2.333Z",fill:"#18181B"}),a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.333 3.167a.5.5 0 0 0-.5.5v2.5h12.334v-2.5a.5.5 0 0 0-.5-.5H2.333Zm-1.06-.561a1.5 1.5 0 0 1 1.06-.44h11.334a1.5 1.5 0 0 1 1.5 1.5v3.5H.833v-3.5c0-.397.158-.779.44-1.06Z",fill:"#18181B"}),a.createElement("path",{d:"M2.667 4.667a.667.667 0 1 1 1.333 0 .667.667 0 0 1-1.333 0ZM4.667 4.667a.667.667 0 1 1 1.333 0 .667.667 0 0 1-1.333 0Z",fill:"#18181B"}),a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.333 11a.333.333 0 1 0 0 .667.333.333 0 0 0 0-.667Zm-1.666.333a1.667 1.667 0 1 1 3.333 0 1.667 1.667 0 0 1-3.333 0Z",fill:"#18181B"}),a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.333 8.4a.6.6 0 0 1 .6.6v1.294l1.121-.647a.6.6 0 1 1 .6 1.04l-1.12.646 1.12.647a.6.6 0 1 1-.6 1.04l-1.12-.647v1.294a.6.6 0 0 1-1.2 0v-1.294l-1.121.647a.6.6 0 1 1-.6-1.04l1.12-.647-1.12-.647a.6.6 0 1 1 .6-1.039l1.12.647V9a.6.6 0 0 1 .6-.6Zm-.267 2.47a.598.598 0 0 1-.267.463.598.598 0 0 1 .267.463.598.598 0 0 1 .534 0 .597.597 0 0 1 .268-.463.599.599 0 0 1-.268-.462.598.598 0 0 1-.534 0Z",fill:"#18181B"})),R=a.createContext({campaignId:void 0,activeStep:"basic",steps:[],navigateNextStep:h,navigatePreviousStep:h,isFirstStep:!0,isLastStep:!1,navigateToStep:h,errorOn:[],setErrorOn:h}),Z=()=>a.useContext(R),B=[{value:"basic",label:__("Basic","growfund"),icon:e.jsx(w,{className:"!growfund-size-5"})},{value:"goal",label:__("Goal","growfund"),icon:e.jsx(x,{className:"!growfund-size-5"})},{value:"rewards",label:__("Rewards","growfund"),icon:e.jsx(j,{className:"!growfund-size-5"})},{value:"additional",label:__("Additional","growfund"),icon:e.jsx(k,{className:"!growfund-size-5"})},{value:"settings",label:__("Options","growfund"),icon:e.jsx(L,{className:"!growfund-size-5"})}],z=({children:h})=>{const w=n(),{appConfig:x}=i(),{isDonationMode:j}=i(),{hideWordpressLayout:k,showWordpressLayout:L}=N(),{id:Z}=l(),[z,I]=a.useState([]),_=M(Z),H=b({resolver:t(E)}),O=a.useMemo(()=>_.data,[_.data]);a.useEffect(()=>{O&&H.reset.call(null,{...O,fundraiser_id:O.fundraiser?.id})},[O,H.reset]),a.useEffect(()=>(k(),()=>{L()}),[]);const y=a.useMemo(()=>B.filter(a=>j?(o.has_growfund_pro&&x[r.Campaign]&&(x[r.Campaign].allow_fund||x[r.Campaign].allow_tribute)||"additional"!==a.value)&&"rewards"!==a.value:"additional"!==a.value),[j,x]),[A,F]=a.useState(()=>y.map(a=>a.value).includes(w)?w:"basic"),G=s(),D=a.useCallback(a=>{switch(F(a),a){case"basic":G(d.CampaignStepBasic.buildLink());break;case"goal":G(d.CampaignStepGoal.buildLink());break;case"rewards":G(d.CampaignStepRewards.buildLink());break;case"additional":G(d.CampaignStepAdditional.buildLink());break;case"settings":G(d.CampaignStepSettings.buildLink())}},[G]),P=a.useCallback(()=>{const a=y.length,e=y.findIndex(a=>a.value===A),s=Math.min(a-1,e+1);D(y[s].value)},[A,D,y]),T=a.useCallback(()=>{const a=y.findIndex(a=>a.value===A),e=Math.max(0,a-1);D(y[e].value)},[A,D,y]),V=a.useMemo(()=>0===y.findIndex(a=>a.value===A),[A,y]),W=a.useMemo(()=>y.findIndex(a=>a.value===A)===y.length-1,[A,y]);a.useEffect(()=>{I(a=>a.filter(a=>a!==A))},[A]);const J=a.useMemo(()=>({activeStep:A,steps:y,navigateNextStep:P,navigatePreviousStep:T,isFirstStep:V,isLastStep:W,navigateToStep:D,errorOn:z,setErrorOn:I,campaignId:Z}),[A,V,W,P,T,D,y,z,I,Z]);return u(_,{Loading:e.jsx(g,{}),Error:e.jsx(p,{className:"growfund-mt-10",children:e.jsxs(f,{children:[e.jsx(S,{}),e.jsx("div",{children:__("Campaign not found.","growfund")})]})}),Empty:e.jsx(c,{className:"growfund-mt-10",children:e.jsxs(m,{className:"growfund-flex growfund-flex-col growfund-items-center",children:[e.jsx(S,{}),e.jsx("div",{children:__("Campaign not found.","growfund")})]})}),Success:a=>e.jsx(R,{value:J,children:e.jsx(C,{campaign:a.data,children:e.jsx(v,{...H,children:h})})})})};export{z as C,Z as u};
