(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5943],{31817:function(e,t,r){Promise.resolve().then(r.bind(r,72043))},16022:function(e,t,r){"use strict";var n=r(89108);r.o(n,"useRouter")&&r.d(t,{useRouter:function(){return n.useRouter}}),r.o(n,"useSearchParams")&&r.d(t,{useSearchParams:function(){return n.useSearchParams}})},21354:function(e,t,r){"use strict";/**
 * @license React
 * use-sync-external-store-shim.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var n=r(79385),s="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=n.useState,i=n.useEffect,a=n.useLayoutEffect,l=n.useDebugValue;function c(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!s(e,r)}catch(e){return!0}}var u="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var r=t(),n=o({inst:{value:r,getSnapshot:t}}),s=n[0].inst,u=n[1];return a(function(){s.value=r,s.getSnapshot=t,c(s)&&u({inst:s})},[e,r,t]),i(function(){return c(s)&&u({inst:s}),e(function(){c(s)&&u({inst:s})})},[e]),l(r),r};t.useSyncExternalStore=void 0!==n.useSyncExternalStore?n.useSyncExternalStore:u},79569:function(e,t,r){"use strict";/**
 * @license React
 * use-sync-external-store-shim/with-selector.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var n=r(79385),s=r(70708),o="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},i=s.useSyncExternalStore,a=n.useRef,l=n.useEffect,c=n.useMemo,u=n.useDebugValue;t.useSyncExternalStoreWithSelector=function(e,t,r,n,s){var d=a(null);if(null===d.current){var f={hasValue:!1,value:null};d.current=f}else f=d.current;var m=i(e,(d=c(function(){function e(e){if(!l){if(l=!0,i=e,e=n(e),void 0!==s&&f.hasValue){var t=f.value;if(s(t,e))return a=t}return a=e}if(t=a,o(i,e))return t;var r=n(e);return void 0!==s&&s(t,r)?t:(i=e,a=r)}var i,a,l=!1,c=void 0===r?null:r;return[function(){return e(t())},null===c?void 0:function(){return e(c())}]},[t,r,n,s]))[0],d[1]);return l(function(){f.hasValue=!0,f.value=m},[m]),u(m),m}},70708:function(e,t,r){"use strict";e.exports=r(21354)},64253:function(e,t,r){"use strict";e.exports=r(79569)},72043:function(e,t,r){"use strict";r.r(t);var n=r(99394),s=r(79385),o=r(99277),i=r(16022),a=r(60249),l=r(84381),c=r(85547),u=r(57342),d=r(16688),f=r(15435),m=r(59577),x=r(59986),h=r(11211),p=r(85991),v=r(22469);let g=e=>({"ai-cat-video-generator":0,"popular-science-video":1,"minecraft-video":2,"history-video":3,"fairy-tale-video":4,"gta-video":5,"horror-story-video":6,"product-introduction-video":7})[e];t.default=e=>{let{params:t}=e,r=(0,s.useRef)(null),b=(0,s.useRef)(null),[w,y]=(0,s.useState)(""),[j,S]=(0,s.useState)(!1),[E,N]=(0,s.useState)(null),[C,F]=(0,s.useState)(!1),P=t.templateName,D=(0,i.useRouter)(),{setSelectedStyle:A,setSelectedBGM:k}=(0,m.N)(),{updatePrePromptAndAfterPrompt:I,updateBackgroundMusic:O}=(0,x.useStoryCardListStore)(e=>e),[R,T]=(0,s.useState)(""),[z,V]=(0,s.useState)(""),[_,B]=(0,s.useState)("");(0,s.useEffect)(()=>{var e,t,r;if(!P){a.Am.error("Template name is required");return}let n=g(P);if(void 0===n){a.Am.error("Invalid template name");return}let s=d.G[n];B(s.story),T(s.storyPrompt),V(s.title),k(s.bgmIndex),O(null!==(r=null===(t=h.Qr[s.bgmIndex])||void 0===t?void 0:null===(e=t.path)||void 0===e?void 0:e.split("/").pop())&&void 0!==r?r:""),A(s.styleIndex),I(f.P[s.styleIndex].prePrompt.trim(),f.P[s.styleIndex].afterPrompt.trim()),H()},[t.templateName]);let G=async e=>{if(!C)try{let t=await fetch("/api/v1/prompt_script",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:e.trim()})}),r=await t.json();r.id?(N(r.id),F(!0)):a.Am.error("Failed to initiate script generation")}catch(e){console.error("Error initiating script generation",e),a.Am.error("Error initiating script generation")}},L=async()=>{S(!0),await G(R)};(0,p.Y)(async()=>{if(E)try{let e=await fetch("/api/v1/textscriptpoll?id=".concat(E)),t=await e.json();200===e.status?(B(t.content),F(!1),S(!1)):404!==e.status&&(a.Am.error("".concat(t.message),{position:"top-center"}),F(!1),N(null),S(!1))}catch(e){console.error("Error polling initial scene JSON",e),a.Am.error("Error polling initial scene JSON"),F(!1),N(null),S(!1)}},C?2e3:null),(0,s.useEffect)(()=>{r.current&&H()},[w]),(0,s.useEffect)(()=>{_&&r.current&&(r.current.value=_,y(_))},[_]);let H=()=>{r.current&&(r.current.style.height="auto",r.current.style.height="".concat(r.current.scrollHeight+14,"px"),z&&(r.current.style.height="".concat(r.current.scrollHeight+18,"px")))};return(0,n.jsxs)(n.Fragment,{children:[j&&(0,n.jsxs)("div",{className:"fixed inset-0 bg-gray-900 bg-opacity-75 flex items-center justify-center z-50",children:[(0,n.jsx)("div",{className:"text-white text-lg",children:"Loading, please wait..."}),(0,n.jsxs)("svg",{className:"animate-spin h-8 w-8 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,n.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8H4z"})]})]}),(0,n.jsx)(a.x7,{toastOptions:{style:{background:"#2563EB",color:"#FFFFFF"}}}),(0,n.jsxs)("div",{className:"flex flex-col items-center p-8 bg-gradient-to-b from-[#FEDFE1] via-[#FFD7D9] to-[#FFEFF0]",ref:b,children:[(0,n.jsxs)("a",{href:"/",className:"self-start text-black font-bold py-1.5 px-4 rounded shadow-sm bg-white flex items-center text-sm hover:text-blue-500 md:ml-[-1.2em] md:mt-[-1.2em]",children:[(0,n.jsx)("svg",{"aria-hidden":"true",focusable:"false","data-prefix":"far","data-icon":"arrow-left",className:"svg-inline--fa fa-arrow-left fa-fw mr-2",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"12",height:"12",children:(0,n.jsx)("path",{fill:"currentColor",d:"M7.4 273.4C2.7 268.8 0 262.6 0 256s2.7-12.8 7.4-17.4l176-168c9.6-9.2 24.8-8.8 33.9 .8s8.8 24.8-.8 33.9L83.9 232 424 232c13.3 0 24 10.7 24 24s-10.7 24-24 24L83.9 280 216.6 406.6c9.6 9.2 9.9 24.3 .8 33.9s-24.3 9.9-33.9 .8l-176-168z"})}),"Back"]}),(0,n.jsx)("h1",{className:"text-[32px] md:text-[48px] font-bold mb-4 text-[#3C3838] font-p22-mackinac-pro mt-8 md:mt-28",children:"Video Generate"}),(0,n.jsx)("p",{className:"text-[16px] md:text-[20px] mb-8 text-[#000000A3] font-sans",children:"What video would you like to create today?"}),(0,n.jsxs)("div",{className:"flex flex-col justify-start space-y-3 md:w-2/3 w-full md:mt-10 mt-3",children:[(0,n.jsxs)("div",{className:"flex space-x-4",children:[(0,n.jsx)(l.Z,{}),(0,n.jsx)(c.Z,{})]}),(0,n.jsxs)("div",{className:"w-full flex flex-col md:flex-row md:space-y-0 md:space-x-2 space-y-4",children:[(0,n.jsxs)("form",{className:"relative flex flex-col md:flex-row items-center bg-white rounded-lg shadow-2xl p-1 md:p-2 flex-grow md:w-auto h-auto md:text-base md:flex-grow-0 md:flex-auto focus-within:border-blue-500 focus-within:border",style:{boxShadow:"0 10px 20px rgba(0, 0, 0, 0.1), 0 6px 6px rgba(0, 0, 0, 0.1)",width:"100%",height:"auto"},children:[(0,n.jsxs)("div",{className:"relative flex items-center flex-grow h-full w-full md:w-auto",children:[(0,n.jsx)("textarea",{ref:r,rows:1,placeholder:"Describe what video you'd like to make",className:"bg-transparent text-gray-700 text-left outline-none flex-grow border-none focus:ring-0 focus:border-none resize-none h-auto w-full p-2 md:p-4 text-base md:text-xl overflow-hidden",style:{height:"auto",minHeight:"1em",overflow:"hidden",fontFamily:"Arial, Helvetica, sans-serif"},onInput:()=>{var e;let t=(null===(e=r.current)||void 0===e?void 0:e.value)||"";t.length<=1e3&&y(t),H()},maxLength:1e3}),(0,n.jsxs)("div",{className:"absolute bottom-0 right-2 left-2 flex justify-between p-2 text-sm text-gray-600",children:[z&&(0,n.jsxs)("div",{className:"flex items-center cursor-pointer",onClick:L,children:[(0,n.jsx)("span",{className:"text-2xl",children:"\uD83C\uDFB2"}),(0,n.jsxs)("span",{className:"font-bold",children:["Create a similar ",z]})]}),(0,n.jsxs)("div",{className:"ml-auto",children:[w.length," / ",1e3]})]})]}),(0,n.jsx)("button",{type:"button",onClick:()=>{w&&w.trim()?D.push("/ai-video-generate/result?prompt="+encodeURIComponent(w)):a.Am.error("Please enter some text in the prompt.")},className:"bg-[#2E03D0] bg-gradient-to-r from-[#2E03D0] to-[#5A3FDC] hover:bg-gradient-to-r hover:from-[#1B0199] hover:to-[#4A32C2] text-white flex items-center justify-center gap-2 md:h-14 h-10 md:px-8 px-4 rounded cursor-pointer text-center text-sm md:text-sm md:w-36 w-full",style:{height:"auto",padding:"0.5rem 1rem",margin:0},children:(0,n.jsx)("div",{className:"flex flex-col items-center font-semibold",children:"AI-Generated Storyboard"})})]}),(0,n.jsxs)("div",{className:"flex flex-col md:flex-row items-center md:space-x-2 space-y-4 md:space-y-0 w-full md:w-auto",children:[(0,n.jsx)("span",{className:"text-xs md:text-base",children:"or"}),(0,n.jsx)(v.default,{className:"bg-[#005CAF] bg-gradient-to-r from-[#005CAF] to-[#0074D9] hover:bg-gradient-to-r hover:from-[#004080] hover:to-[#006699] text-white flex items-center justify-center gap-2 md:h-14 h-10 md:px-8 px-4 rounded cursor-pointer text-center text-sm md:text-sm md:w-36 w-full",href:"/ai-video-generate/result",children:(0,n.jsx)("div",{className:"flex flex-col items-center font-semibold",children:"Custom Storyboard"})})]})]})]}),(0,n.jsx)("div",{className:"mt-12"}),(0,n.jsx)(u.Z,{onChoose:e=>{r.current&&(r.current.value=d.G[e].story,y(d.G[e].story));for(let t=0;t<f.P.length;t++)if(d.G[e].imageStyle===f.P[t].name){A(t),I(f.P[t].prePrompt,f.P[t].afterPrompt);break}b.current&&b.current.scrollIntoView({behavior:"smooth"})}})]}),(0,n.jsx)(o.default,{})]})}},22842:function(e,t,r){"use strict";r.d(t,{Ue:function(){return f},oR:function(){return u}});var n=r(32896),s=r(79385),o=r(64253);let{useDebugValue:i}=s,{useSyncExternalStoreWithSelector:a}=o,l=!1,c=e=>e;function u(e,t=c,r){r&&!l&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),l=!0);let n=a(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,r);return i(n),n}let d=e=>{"function"!=typeof e&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");let t="function"==typeof e?(0,n.M)(e):e,r=(e,r)=>u(t,e,r);return Object.assign(r,t),r},f=e=>e?d(e):d},32896:function(e,t,r){"use strict";r.d(t,{M:function(){return s}});let n=e=>{let t;let r=new Set,n=(e,n)=>{let s="function"==typeof e?e(t):e;if(!Object.is(s,t)){let e=t;t=(null!=n?n:"object"!=typeof s||null===s)?s:Object.assign({},t,s),r.forEach(r=>r(t,e))}},s=()=>t,o={setState:n,getState:s,getInitialState:()=>i,subscribe:e=>(r.add(e),()=>r.delete(e)),destroy:()=>{console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}},i=t=e(n,s,o);return o},s=e=>e?n(e):n}},function(e){e.O(0,[5195,2469,9846,249,9105,8102,1354,1035,2474,1744],function(){return e(e.s=31817)}),_N_E=e.O()}]);