<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1333],{3617:(e,t,r)=&gt;{r.d(t,{U:()=&gt;n});var i=r(90156);function n(){return(0,i.createBrowserClient)("https://nucemdibxcedfhwghida.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im51Y2VtZGlieGNlZGZod2doaWRhIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Mzg2MDU3NjMsImV4cCI6MjA1NDE4MTc2M30.kkPyWIWLeEDqao_sBFVGI9Y-6bakEQXAwL0LPSgNDhs",{auth:{detectSessionInUrl:!0,flowType:"pkce",storage:a}})}let s=()=&gt;window.localStorage,a={getItem:e=&gt;s()?globalThis.localStorage.getItem(e):null,setItem:(e,t)=&gt;{s()&amp;&amp;globalThis.localStorage.setItem(e,t)},removeItem:e=&gt;{s()&amp;&amp;globalThis.localStorage.removeItem(e)}}},30285:(e,t,r)=&gt;{r.d(t,{$:()=&gt;d,r:()=&gt;o});var i=r(95155),n=r(12115),s=r(99708),a=r(74466),l=r(59434);let o=(0,a.F)("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary/80 text-black hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),d=n.forwardRef((e,t)=&gt;{let{className:r,variant:n,size:a,asChild:d=!1,...u}=e,c=d?s.DX:"button";return(0,i.jsx)(c,{className:(0,l.cn)(o({variant:n,size:a,className:r})),ref:t,...u})});d.displayName="Button"},39969:(e,t,r)=&gt;{r.d(t,{vu:()=&gt;v,Ay:()=&gt;f,Jd:()=&gt;p});var i=r(95155),n=r(12115),s=r(26715),a=r(95838),l=r(3617),o=r(83964),d=r(35695);let u={CREATE_CAMPAIGN:2,SEND_LETTER_PER_PAGE:1,SPONSOR_CAMPAIGN:20},c=(0,n.createContext)({user:null,profile:null,isLoadingUser:!0,isLoadingRepresentatives:!0,isLoadingStateRepresentatives:!0,isLoadingContacts:!0,isSignedIn:!1,invalidateUser:async()=&gt;{throw Error("Invalidate user function not implemented")},clearAuthState:async()=&gt;{throw Error("Clear auth state function not implemented")},representatives:null,stateRepresentatives:null,contacts:null,stripe_customer:null,isLoadingStripeCustomer:!0,subscription:null,isLoadingSubscription:!0,credits:0,optimisticDeductCredits:()=&gt;{throw Error("Optimistic deduct credits function not implemented")}}),p=()=&gt;{let e=(0,n.useContext)(c);if(void 0===e)throw Error("useUser must be used within a UserProvider");return e};function v(e){var t,r,p,v,f;let{children:g}=e;(0,d.useRouter)();let[m,h]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),_=(0,l.U)(),w=(0,s.jE)(),[S,I]=(0,n.useState)(0);(0,n.useEffect)(()=&gt;{let{data:{subscription:e}}=_.auth.onAuthStateChange(async(e,t)=&gt;{"SIGNED_OUT"===e?(h(null),await w.resetQueries(),w.removeQueries()):t?h(t.user):h(null)});return _.auth.getSession().then(e=&gt;{let{data:{session:t}}=e;t&amp;&amp;h(t.user)}).catch(e=&gt;{console.error("Error getting initial session:",e)}),()=&gt;{e.unsubscribe()}},[_.auth,w]);let{data:C,isLoading:E}=(0,a.I)({queryKey:["profile",null==m?void 0:m.id],queryFn:async()=&gt;{if(!(null==m?void 0:m.id))return null;let{data:e,error:t}=await _.from("profiles").select("*").eq("id",m.id).single();if(t)throw console.error("Profile fetch error:",t),t;return e},enabled:!!(null==m?void 0:m.id),staleTime:0}),{data:A,isLoading:x}=o.F.congress.getAllRepresentatives.useQuery({stateCode:null!==(t=null==C?void 0:C.state)&amp;&amp;void 0!==t?t:"",district:null!==(r=null==C?void 0:C.district_code)&amp;&amp;void 0!==r?r:""},{enabled:!!(null==C?void 0:C.state)&amp;&amp;!!(null==C?void 0:C.district_code),staleTime:864e5}),{data:L}=o.F.congress.getOfficeAddresses.useQuery({names:A?[...A.senators,...A.houseReps].map(e=&gt;{let t=e.name.split(", ");return 2===t.length?"".concat(t[1]," ").concat(t[0]):e.name}):[]},{enabled:!!A&amp;&amp;A.senators.length+A.houseReps.length&gt;0&amp;&amp;!!(null==m?void 0:m.id)});(0,n.useEffect)(()=&gt;{if(A&amp;&amp;L)b({senators:A.senators.map(e=&gt;{var t;return{...e,officeAddress:null===(t=L.find(t=&gt;{let r=e.name.split(", "),i=2===r.length?"".concat(r[1]," ").concat(r[0]):e.name;return t.name===i}))||void 0===t?void 0:t.officeAddress}}),houseReps:A.houseReps.map(e=&gt;{var t;return{...e,officeAddress:null===(t=L.find(t=&gt;{let r=e.name.split(", "),i=2===r.length?"".concat(r[1]," ").concat(r[0]):e.name;return t.name===i}))||void 0===t?void 0:t.officeAddress}})})},[A,L]);let{data:k,isLoading:R}=o.F.contacts.getAll.useQuery(void 0,{enabled:!!(null==m?void 0:m.id)}),{data:q,isLoading:U}=(0,a.I)({queryKey:["stripe_customer",null==m?void 0:m.id],queryFn:async()=&gt;{if(!(null==m?void 0:m.id))return null;let{data:e,error:t}=await _.from("stripe_customers").select("*").eq("user_id",m.id).maybeSingle();if(t)throw console.error("Stripe customer fetch error:",t),t;return e},enabled:!!(null==m?void 0:m.id),staleTime:0}),{data:Q,isLoading:T}=(0,a.I)({queryKey:["subscription",null==q?void 0:q.id],queryFn:async()=&gt;{if(!(null==q?void 0:q.id))return null;let{data:e,error:t}=await _.from("stripe_subscriptions").select("*").eq("customer_id",q.id).order("created_at",{ascending:!1}).limit(1).single();if(t)throw console.error("Subscription fetch error:",t),t;return e},enabled:!!(null==q?void 0:q.id),staleTime:0}),{data:N,isLoading:D}=o.F.state.getKansasStateRepresentative.useQuery({senateDistrictNumber:null!==(p=null==C?void 0:C.district_code_state_senate)&amp;&amp;void 0!==p?p:"",houseDistrictNumber:null!==(v=null==C?void 0:C.district_code_state_house)&amp;&amp;void 0!==v?v:""},{enabled:!!(null==C?void 0:C.state)&amp;&amp;"KS"===C.state.toUpperCase()&amp;&amp;(!!C.district_code_state_senate||!!C.district_code_state_house),staleTime:864e5}),P=async()=&gt;{await Promise.all([w.invalidateQueries({queryKey:["profile"]}),w.invalidateQueries({queryKey:["stripe_customer"]}),w.invalidateQueries({queryKey:["subscription"]}),w.invalidateQueries({predicate:e=&gt;"user"===e.queryKey[0]||"profile"===e.queryKey[0]}),w.invalidateQueries({predicate:e=&gt;"congress"===e.queryKey[0]}),w.invalidateQueries({predicate:e=&gt;"state"===e.queryKey[0]})]),b(null)},F=async()=&gt;{await w.resetQueries(),w.removeQueries(),h(null),localStorage.clear(),document.cookie.split(";").forEach(e=&gt;{document.cookie=e.replace(/^ +/,"").replace(/=.*/,"=;expires="+new Date().toUTCString()+";path=/")})};(0,n.useEffect)(()=&gt;{C&amp;&amp;I(C.credits)},[null==C?void 0:C.credits]);let K={user:m,profile:null!=C?C:null,isLoadingUser:E,isLoadingRepresentatives:x,isLoadingStateRepresentatives:D,isLoadingContacts:R,isSignedIn:!!m,invalidateUser:P,clearAuthState:F,representatives:null!==(f=null!=y?y:A)&amp;&amp;void 0!==f?f:null,stateRepresentatives:(null==N?void 0:N.found)&amp;&amp;N.representative?N.representative:null,contacts:null!=k?k:null,stripe_customer:null!=q?q:null,isLoadingStripeCustomer:U,subscription:null!=Q?Q:null,isLoadingSubscription:T,credits:S,optimisticDeductCredits:(e,t)=&gt;{let r=u[e],i=null!=t?t:1;I(e=&gt;Math.max(0,e-r*i))}};return(0,i.jsx)(c.Provider,{value:K,children:g})}let f=p},59434:(e,t,r)=&gt;{r.d(t,{cn:()=&gt;s,o:()=&gt;a});var i=r(52596),n=r(39688);function s(){for(var e=arguments.length,t=Array(e),r=0;r&lt;e;r++)t[r]=arguments[r];return(0,n.QP)((0,i.$)(t))}function a(e){try{var t;e=e.replace(/,?\s*USA\s*$/,"").trim();let r=/([A-Z]{2})\s*(\d{5}(?:-\d{4})?)\s*$/.exec(e);if(!r||!r[1]||!r[2])return{address_1:e,city:"Unknown",state:"Unknown",postal_code:"00000"};let i=r[1],n=r[2],s=e.slice(0,r.index).replace(/,?\s*$/,"").trim().split(",").map(e=&gt;e.trim()).filter(Boolean),a=null!==(t=s[s.length-1])&amp;&amp;void 0!==t?t:"Unknown",l=s.slice(0,-1);return{address_1:l.length&gt;0?l.join(", "):a,city:a,state:i,postal_code:n}}catch(t){return console.error("Address parsing error:",t),{address_1:e,city:"Unknown",state:"Unknown",postal_code:"00000"}}}},83964:(e,t,r)=&gt;{let i;r.d(t,{TRPCReactProvider:()=&gt;g,F:()=&gt;f});var n=r(95155),s=r(26715),a=r(49929),l=r(86092),o=r(12115),d=r(99177),u=r(52775),c=r(81451);let p=()=&gt;new u.E({defaultOptions:{queries:{staleTime:3e4},dehydrate:{serializeData:d.Ay.serialize,shouldDehydrateQuery:e=&gt;(0,c.XS)(e)||"pending"===e.state.status},hydrate:{deserializeData:d.Ay.deserialize}}});r(49509);let v=()=&gt;null!=i?i:i=p(),f=(0,l.pY)();function g(e){let t=v(),[r]=(0,o.useState)(()=&gt;f.createClient({links:[(0,a.$H)({enabled:e=&gt;"down"===e.direction&amp;&amp;e.result instanceof Error}),(0,a.kM)({transformer:d.Ay,url:window.location.origin+"/api/trpc",headers:()=&gt;{let e=new Headers;return e.set("x-trpc-source","nextjs-react"),e}})]}));return(0,n.jsx)(s.Ht,{client:t,children:(0,n.jsx)(f.Provider,{client:r,queryClient:t,children:e.children})})}}}]);</pre></body></html>