!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="da5e3827-1437-4550-b56f-e02b719cdc26",e._sentryDebugIdIdentifier="sentry-dbid-da5e3827-1437-4550-b56f-e02b719cdc26")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6503],{57029:function(e,t,a){a.d(t,{Z:function(){return m}});var r=a(57437),n=a(42706),s=a(2265),i=a(18009),o=a(58714),d=a(47907),l=a(7908),c=a(50693),u=a(17494),f=a(49842),p=a(23444);function m(e){let{open:t,setOpen:a,domainName:m,domainData:g,dataDescription:b}=e,[h,x]=(0,s.useState)(""),[y,v]=(0,s.useState)(""),[w,k]=(0,s.useState)(""),[j,N]=(0,s.useState)(""),_=(0,o.createClientComponentClient)(),[z,C]=(0,s.useState)(!1),[P,S]=(0,s.useState)(!1),[Z,R]=(0,s.useState)(!1),[O,I]=(0,s.useState)(""),[D,T]=(0,s.useState)(""),[E,V]=(0,s.useState)(""),[Y,A]=(0,s.useState)(""),B=(0,d.useRouter)();(0,s.useEffect)(()=>{b&&k(b)},[b]);let F=(0,s.useCallback)(()=>{if(!j){let e=(0,c.v4)();return N(e),e}return j},[j]),q=async(e,t)=>{e.preventDefault(),C(!0);try{let{type:e}=t;if("otp_code"===e&&(S(!0),g)){let{error:e}=await _.auth.signInWithOtp({email:h,options:{}});e?(console.log(e),i.ZP.error("Failed to send OTP. Please try again.")):(i.ZP.success("Check your emails!",{duration:2e4}),R(!0),S(!0),F())}}catch(e){console.log(e),A("otp_code"),T("An error occurred while sending the OTP. Please try again.")}finally{C(!1)}},U=async()=>{C(!0),V("Verifying email");try{let{error:e}=await _.auth.verifyOtp({email:h,token:O,type:"email"});if(e)throw Error("OTP verification failed");V("Checking onboarding status");let{data:t}=await l.Z.get("/api/user-data/onboard-check");if(t.hasOnboarded){B.push("/dashboard");return}if(!g)throw Error("Domain data is missing");V("Identifying key keywords");let a=g.potential_keywords.map(e=>e.replace(/_/g," ")),{data:{data:{cleanedData:r}}}=await l.Z.post("api/search-keywords/batch",{keywords:a,sessionId:j});V("Searching the web");let{data:{data:n}}=await l.Z.post("api/create-titles/onboard",{description:w,keywords:r});V("Saving onboarding data"),await l.Z.post("api/auth/onboard",{name:y,domainData:{...g,description:w},cleanedKeywords:a,titleData:n,domainName:m,sessionId:j}),B.push("/dashboard")}catch(e){console.error("Error in handleVerifyOtp:",e),T(L(e)),A(K(e))}},L=e=>"OTP verification failed"===e.message?"The code you entered is incorrect. Please try again.":"An error occurred. Please try again.",K=e=>"OTP verification failed"===e.message?"verify_otp":"onboard_check",W=async()=>{C(!0);try{switch(Y){case"otp_code":await q({},{type:"otp_code"});break;case"verify_otp":await U();break;case"onboard_check":{let{data:e}=await l.Z.get("/api/user-data/onboard-check");if(e.hasOnboarded)B.push("/dashboard");else if(g){V("Identifying key keywords");let e=g.potential_keywords.map(e=>e.replace(/_/g," ")),{cleanedData:t}=(await l.Z.post("api/search-keywords/batch",{keywords:e,email:h,sessionId:j})).data;V("Searching the web");let a=(await l.Z.post("api/create-titles/onboard",{description:w,keywords:t})).data;await l.Z.post("/auth/onboard",{domainData:{...g,description:w},cleanedKeywords:e,cleanedData:t,titleData:a,domainName:m}),B.push("/dashboard")}}}}catch(e){console.error("Retry error:",e),T("An unexpected error occurred. Please try again later.")}finally{C(!1)}};return(0,r.jsx)(n.Vq,{open:t,onOpenChange:a,children:(0,r.jsxs)(n.cZ,{className:"sm:max-w-md",children:[(0,r.jsxs)(n.fK,{children:[(0,r.jsxs)(n.$N,{children:["Set Up Your ",m," Blog"]}),(0,r.jsx)(n.Be,{children:"Let's personalize your blog. Enter your details to get started."})]}),Z?(0,r.jsxs)("div",{className:"flex flex-col items-center space-y-4",children:[(0,r.jsx)("label",{htmlFor:"otp",className:"text-lg font-medium",children:"Enter the code from your email:"}),(0,r.jsx)(u.Zn,{maxLength:6,value:O,onChange:e=>I(e),children:(0,r.jsxs)(u.hf,{children:[(0,r.jsx)(u.cY,{index:0}),(0,r.jsx)(u.cY,{index:1}),(0,r.jsx)(u.cY,{index:2}),(0,r.jsx)(u.cY,{index:3}),(0,r.jsx)(u.cY,{index:4}),(0,r.jsx)(u.cY,{index:5})]})}),D&&(0,r.jsx)("p",{className:"text-red-500",children:D}),(0,r.jsx)("button",{className:"btn bg-blue-600 text-white btn-block",disabled:z,onClick:U,children:z?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"loading loading-spinner loading-xs mr-2 text-blue-600"}),(0,r.jsx)("p",{className:"text-black",children:E})]}):"Verify OTP & claim free blog"}),z&&(0,r.jsx)("p",{className:"text-sm text-gray-500 mt-2",children:"Please don't close this while we're processing."}),D&&(0,r.jsx)("button",{className:"btn btn-secondary btn-block",disabled:z,onClick:W,children:"Retry"})]}):(0,r.jsxs)("form",{className:"form-control w-full space-y-4",onSubmit:e=>q(e,{type:"otp_code"}),children:[(0,r.jsx)(f._,{children:"Name"}),(0,r.jsx)("input",{required:!0,type:"name",value:y,autoComplete:"name",placeholder:"Tom Cruise",className:"input input-bordered w-full placeholder:opacity-60 bg-white",onChange:e=>v(e.target.value)}),(0,r.jsx)(f._,{children:"Email"}),(0,r.jsx)("input",{required:!0,type:"email",value:h,autoComplete:"email",placeholder:"tom@cruise.com",className:"input input-bordered w-full placeholder:opacity-60 bg-white",onChange:e=>x(e.target.value)}),(0,r.jsx)(f._,{children:"Description"}),(0,r.jsx)(p.g,{value:w,onChange:e=>k(e.target.value),placeholder:"Briefly describe your blog or website",className:"resize-none"}),(0,r.jsx)("button",{className:"btn bg-blue-600 text-white btn-block",disabled:z||P,type:"submit",children:z?(0,r.jsx)("span",{className:"loading loading-spinner loading-xs text-black"}):"Continue & claim free blog"}),D&&(0,r.jsx)("button",{className:"btn btn-secondary btn-block",disabled:z,onClick:W,children:"Retry"})]})]})})}},85754:function(e,t,a){a.d(t,{d:function(){return d},z:function(){return l}});var r=a(57437),n=a(2265),s=a(59143),i=a(57742),o=a(1657);let d=(0,i.j)("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 text-primary-foreground 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"}}),l=n.forwardRef((e,t)=>{let{className:a,variant:n,size:i,asChild:l=!1,...c}=e,u=l?s.g7:"button";return(0,r.jsx)(u,{className:(0,o.cn)(d({variant:n,size:i,className:a})),ref:t,...c})});l.displayName="Button"},42706:function(e,t,a){a.d(t,{$N:function(){return g},Be:function(){return b},Vq:function(){return d},cN:function(){return m},cZ:function(){return f},fK:function(){return p},hg:function(){return l}});var r=a(57437),n=a(2265),s=a(72936),i=a(52235),o=a(1657);let d=s.fC,l=s.xz,c=s.h_;s.x8;let u=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,r.jsx)(s.aV,{ref:t,className:(0,o.cn)("fixed inset-0 z-50 bg-black/80  data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...n})});u.displayName=s.aV.displayName;let f=n.forwardRef((e,t)=>{let{className:a,children:n,...d}=e;return(0,r.jsxs)(c,{children:[(0,r.jsx)(u,{}),(0,r.jsxs)(s.VY,{ref:t,className:(0,o.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",a),...d,children:[n,(0,r.jsxs)(s.x8,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,r.jsx)(i.Z,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});f.displayName=s.VY.displayName;let p=e=>{let{className:t,...a}=e;return(0,r.jsx)("div",{className:(0,o.cn)("flex flex-col space-y-1.5 text-center sm:text-left",t),...a})};p.displayName="DialogHeader";let m=e=>{let{className:t,...a}=e;return(0,r.jsx)("div",{className:(0,o.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a})};m.displayName="DialogFooter";let g=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,r.jsx)(s.Dx,{ref:t,className:(0,o.cn)("text-lg font-semibold leading-none tracking-tight",a),...n})});g.displayName=s.Dx.displayName;let b=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,r.jsx)(s.dk,{ref:t,className:(0,o.cn)("text-sm text-muted-foreground",a),...n})});b.displayName=s.dk.displayName},17494:function(e,t,a){a.d(t,{Zn:function(){return d},cY:function(){return c},hf:function(){return l}});var r=a(57437),n=a(2265),s=a(5542),i=a(58350),o=a(1657);let d=n.forwardRef((e,t)=>{let{className:a,containerClassName:n,...i}=e;return(0,r.jsx)(s.uZ,{ref:t,containerClassName:(0,o.cn)("flex items-center gap-2 has-[:disabled]:opacity-50",n),className:(0,o.cn)("disabled:cursor-not-allowed",a),...i})});d.displayName="InputOTP";let l=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,r.jsx)("div",{ref:t,className:(0,o.cn)("flex items-center",a),...n})});l.displayName="InputOTPGroup";let c=n.forwardRef((e,t)=>{let{index:a,className:i,...d}=e,{char:l,hasFakeCaret:c,isActive:u}=n.useContext(s.VM).slots[a];return(0,r.jsxs)("div",{ref:t,className:(0,o.cn)("relative flex h-10 w-10 items-center justify-center border-y border-r border-input text-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md",u&&"z-10 ring-2 ring-ring ring-offset-background",i),...d,children:[l,c&&(0,r.jsx)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:(0,r.jsx)("div",{className:"h-4 w-px animate-caret-blink bg-foreground duration-1000"})})]})});c.displayName="InputOTPSlot",n.forwardRef((e,t)=>{let{...a}=e;return(0,r.jsx)("div",{ref:t,role:"separator",...a,children:(0,r.jsx)(i.Z,{})})}).displayName="InputOTPSeparator"},49842:function(e,t,a){a.d(t,{_:function(){return l}});var r=a(57437),n=a(2265),s=a(24602),i=a(57742),o=a(1657);let d=(0,i.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),l=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,r.jsx)(s.f,{ref:t,className:(0,o.cn)(d(),a),...n})});l.displayName=s.f.displayName},23444:function(e,t,a){a.d(t,{g:function(){return i}});var r=a(57437),n=a(2265),s=a(1657);let i=n.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,r.jsx)("textarea",{className:(0,s.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),ref:t,...n})});i.displayName="Textarea"},97869:function(e,t,a){var r=a(6244);let n={appName:"Buzzkit AI",appDescription:"Let AI generate your blogs.",domainName:"buzzkit.ai",crisp:{id:"",onlyShowOnRoutes:["/"]},lemonsqueezy:{plans:[{variantId:"470196",name:"Starter",description:"Perfect for small projects",price:29,credits:{title_generation_credits:3e3,blog_generation_credits:30,keyword_search_credits:10,domain:1}},{variantId:"470202",isFeatured:!0,name:"Pro",description:"Perfect for growing projects",price:129,credits:{title_generation_credits:1500,blog_generation_credits:150,keyword_search_credits:50,domain:5}},{variantId:"479909",isFeatured:!0,name:"Business",description:"Perfect for businesses",price:479,credits:{title_generation_credits:5e3,blog_generation_credits:1e3,keyword_search_credits:250,domain:50}}]},mailgun:{subdomain:"",fromNoReply:"Buzzkit <noreply@buzzkit.ai>",fromAdmin:"Clara at Buzzkit <clara@buzzkit.ai>",supportEmail:"kevin@buzzkit.ai",forwardRepliesTo:"kevin@buzzkit.ai"},colors:{theme:"light",main:a.n(r)().light.primary},auth:{loginUrl:"/signin",callbackUrl:"/dashboard"}};t.Z=n},1657:function(e,t,a){a.d(t,{cn:function(){return s}});var r=a(75504),n=a(51367);function s(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return(0,n.m6)((0,r.W)(t))}},59895:function(e,t,a){var r=a(7908),n=a(18009),s=a(47907),i=a(97869);let o=r.Z.create({baseURL:"/api"});o.interceptors.response.use(function(e){return e.data},function(e){var t,a,r,o;let d="";return(null===(t=e.response)||void 0===t?void 0:t.status)===401?(0,s.redirect)(i.Z.auth.loginUrl):d=(null===(a=e.response)||void 0===a?void 0:a.status)===403?"Pick a plan to use this feature":(null==e?void 0:null===(o=e.response)||void 0===o?void 0:null===(r=o.data)||void 0===r?void 0:r.error)||e.message||e.toString(),e.message="string"==typeof d?d:JSON.stringify(d),console.error(e.message),e.message?n.Am.error(e.message):n.Am.error("something went wrong..."),Promise.reject(e)}),t.Z=o}}]);