1import{e as Re,c as y,u as Ue,r as d,w as Ie,f as Ve,a,h as p,i as ge,b as s,p as se,k as u,q as $,n as f,t as c,v as be,F as A,l as W,A as g,T as qe,C as ke,s as Le,K as Fe,o as l}from"./vendor-C671BQZa.js";import{u as Pe,_ as Oe,i as We}from"./PaywallModal.vue_vue_type_script_setup_true_lang-CDCTXbhL.js";import{u as ze,p as H,V as De,ac as Ye,a as _e,_ as Ge}from"./index-B67ahr15.js";import{M as He}from"./MainLayout-Cdx8A-pa.js";import{s as Ke,a as we,_ as Je}from"./comingSoon-Cdb2Rxqh.js";import{d as Qe}from"./subscription-BDQr15jU.js";import{r as Xe}from"./ArrowLeftIcon-D59_kBR3.js";import{r as Ze}from"./ChevronDownIcon-CpAeWPUf.js";import"./CurrencyDollarIcon-DyIljpX7.js";const et={class:"chat-story-details flex flex-col h-screen bg-chat-bg"},tt={class:"flex-shrink-0 flex items-center gap-3 px-4 py-3 bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800 shadow-sm"},st={class:"flex-1 min-w-0"},lt={class:"text-lg font-semibold text-gray-900 dark:text-white truncate"},at={key:0,class:"text-xs text-gray-500 dark:text-gray-400"},ot={key:0,class:"flex-1 flex items-center justify-center p-6"},rt={key:1,class:"flex-1 flex items-center justify-center p-6"},nt={class:"text-center"},it={class:"text-red-500 dark:text-red-400"},ut={key:2,class:"flex-1 overflow-y-auto"},ct={class:"max-w-2xl mx-auto px-4 py-6"},dt={key:0,class:"relative rounded-xl overflow-hidden mb-6 aspect-video bg-gray-900"},vt=["src","alt"],xt={class:"text-xl font-bold text-gray-900 dark:text-white mb-2"},ft={key:1,class:"text-sm text-gray-600 dark:text-gray-400 mb-6"},mt={class:"space-y-3"},yt=["onClick"],pt={key:0,class:"w-24 h-24 flex-shrink-0 bg-gray-200 dark:bg-gray-700 relative"},ht=["src","alt"],gt={key:0,class:"absolute inset-0 bg-black/40 flex items-center justify-center"},bt={key:1,class:"w-24 h-24 flex-shrink-0 bg-gray-100 dark:bg-gray-700 flex items-center justify-center relative"},kt={class:"text-2xl text-gray-400 dark:text-gray-500"},_t={key:0,class:"absolute inset-0 bg-black/40 flex items-center justify-center rounded-l-xl"},wt={class:"flex-1 min-w-0 py-3 pr-3 flex items-center"},Ct={class:"flex-1 min-w-0"},St={class:"font-semibold text-gray-900 dark:text-white line-clamp-2"},Et={key:0,class:"text-xs text-gray-500 dark:text-gray-400 mt-1 line-clamp-2"},At={key:3,class:"flex-1 flex items-center justify-center p-6"},Bt={key:4,class:"flex-1 flex items-center justify-center p-6"},Tt={class:"text-center"},$t={class:"text-red-500 dark:text-red-400"},jt={key:5,class:"flex-1 flex items-center justify-center p-6"},Mt={key:6,class:"flex-1 min-h-0 bg-black flex flex-col"},Nt={class:"flex-1 min-h-0 flex items-center justify-center"},Rt=["src"],Ut={key:1,class:"px-8 text-center"},It={class:"flex items-center gap-3 px-4 py-3 bg-black text-white"},Vt={class:"min-w-0 flex-1"},qt={class:"text-sm font-semibold truncate"},Lt={class:"text-xs text-white/50"},Ft={key:7,class:"chat-area-wrapper flex-1 min-h-0 relative"},Pt=["src"],Ot={key:0,class:"w-full space-y-2"},Wt=["src","onClick"],zt={key:1,class:"w-full flex flex-col items-center"},Dt={class:"text-[11px] font-medium text-gray-500 dark:text-gray-400 mb-1 uppercase tracking-wide"},Yt={class:"w-full rounded-xl px-4 py-2.5 chat-bubble-system text-center"},Gt=["src","onClick"],Ht={class:"flex-shrink-0 w-8 h-8 rounded-full chat-avatar flex items-center justify-center text-sm font-semibold text-gray-600 dark:text-gray-200"},Kt=["src","onClick"],Jt={key:0,class:"w-full flex flex-col items-center mt-6 mb-4"},Qt={class:"chat-end-indicator rounded-xl px-6 py-4 text-center max-w-md"},Xt={class:"text-xs text-gray-500 dark:text-gray-500 mt-1"},Zt={key:8,class:"chat-story-floating-actions"},es={class:"relative bg-white dark:bg-gray-900 rounded-2xl shadow-2xl w-full max-w-sm p-6 z-10 text-center"},ts={class:"w-14 h-14 rounded-full bg-[#026B63]/10 flex items-center justify-center mx-auto mb-4"},ss={class:"flex flex-col gap-3"},ls=Re({__name:"ChatStoryDetailView",props:{showCode:{}},setup(Ce){const M=Pe("post"),le=ze(),V=Ce,ae=Le(),oe=Ue(),v=y(()=>oe.path.startsWith("/nirctoons")),q=y(()=>oe.path.startsWith("/nircreels")),K=y(()=>{var e,r;const t=((e=B.value)==null?void 0:e.media_url)||((r=m.value)==null?void 0:r.media_url)||"";return typeof t!="string"||!t.trim()?"":t.split(",")[0].trim()}),J=y(()=>b.value.findIndex(t=>{var e;return String((t==null?void 0:t.unique_code)??"")===String(((e=m.value)==null?void 0:e.unique_code)??"")}));function re(){const t=J.value+1;t<=0||t>=b.value.length||ne(b.value[t])}const z=d(!0),N=d(null),h=d(null),b=d([]),m=d(null),B=d(null),R=d(!0),k=d(null),_=d(0),Q=d(null),X=d(!1),D=d(!1),U=d(!1);function L(t){return X.value?!1:We(t)}async function ne(t){if(!L(t)){me(t);return}const e=String((t==null?void 0:t.unique_code)??(t==null?void 0:t.id)??"");if(!e)return;await M.open(e)&&(await P(),me(t))}async function Se(){M.resolveUnlocked(),await P()}const F=y(()=>!!m.value),ie=y(()=>{var e,r;const t=q.value?"NircReel":v.value?"NircToon":"Chat Story";return m.value?((e=B.value)==null?void 0:e.title)??m.value.title??t:((r=h.value)==null?void 0:r.title)??t}),ue=y(()=>m.value&&w.value.length>0?`${w.value.length} message${w.value.length===1?"":"s"}`:""),Y=d(!1),Z=y(()=>Ke(h.value)),ee=y(()=>{var e,r;const t=((e=h.value)==null?void 0:e.banner_img_url)||((r=h.value)==null?void 0:r.icon_img_url);return!t||typeof t!="string"?"":t.split(",")[0].trim()}),ce=y(()=>{var e;const t=(e=B.value)==null?void 0:e.img_url;return!t||typeof t!="string"?"":t.split(",")[0].trim()});function de(t){const e=t==null?void 0:t.img_url;return!e||typeof e!="string"?"":e.split(",")[0].trim()}function I(t){t.target.style.display="none"}const te=d(!1),ve=d([]);function G(t){t&&(ve.value=[t],te.value=!0)}const w=y(()=>{const t=B.value;if(!t)return[];const e=t.chat_stories||t.chat_story_chats||t.chat_story_chat||[];return[...Array.isArray(e)?e:[]].sort((i,n)=>{const C=parseInt(i.msg_order??i.id??"0",10),S=parseInt(n.msg_order??n.id??"0",10);return C-S})}),Ee=y(()=>v.value?w.value:w.value.slice(0,_.value)),Ae=y(()=>{const t=Ee.value;if(t.length===0)return[];const e=[];let r=null;for(const i of t){const n=i.sender??"Unknown";r&&r.sender===n?r.messages.push(i):(r={sender:n,messages:[i]},e.push(r))}return e});function Be(t){return t?t.charAt(0).toUpperCase():"?"}
1const xe=["text-teal-600 dark:text-teal-400","text-pink-600 dark:text-pink-400","text-orange-700 dark:text-orange-400","text-emerald-600 dark:text-emerald-400","text-violet-600 dark:text-violet-400","text-rose-600 dark:text-rose-400"];function Te(t){if(!t)return"text-gray-500 dark:text-gray-400";let e=0;for(let r=0;r<t.length;r++)e+=t.charCodeAt(r);return xe[Math.abs(e)%xe.length]}function $e(t){if(!t||typeof t!="string")return!1;const e=t.toUpperCase().trim();return e==="SYSTEM NOTICE"||e==="SYSTEM"||e.startsWith("SYSTEM ")}async function P(){z.value=!0,N.value=null,h.value=null,b.value=[],m.value=null;try{const t=await _e.getTvShows({uniqueCode:V.showCode,isChatStory:!v.value&&!q.value||void 0,isToonStory:v.value||void 0,isReelStory:q.value||void 0});if(t.success){const e=Array.isArray(t.payload)?t.payload:[],r=e.find(n=>(n.unique_code||n.id)===V.showCode)||e[0]||null;h.value=r;const i=(r==null?void 0:r.episodes)??[];b.value=[...i].sort((n,C)=>{const S=parseInt(n.id??"0",10),E=parseInt(C.id??"0",10);return S-E})}else N.value=t.error??"Failed to load."}catch(t){N.value=(t==null?void 0:t.message)??"Failed to load episodes."}finally{z.value=!1}}async function fe(t){var e,r,i;R.value=!0,k.value=null,_.value=0,B.value=null;try{const n=await _e.getFeedPosts({postCode:t,postType:"post_details",recordsPerPage:1,isChatStory:!0});if(n.success&&n.data){const C=(r=(e=n.data)==null?void 0:e.results)==null?void 0:r[0],S=(C==null?void 0:C.payload)||((i=n.data)==null?void 0:i.payload)||[],E=Array.isArray(S)?S:[S];if(E.length>0)if(B.value=E[0],v.value){const O=E[0].chat_stories??E[0].chat_story_chats??E[0].chat_story_chat??[];_.value=Array.isArray(O)?O.length:1}else _.value=1;else k.value="Content not found."}else k.value=n.error||"Failed to load."}catch(n){k.value=(n==null?void 0:n.message)||"Failed to load."}finally{R.value=!1}}function je(){var e;const t=((e=m.value)==null?void 0:e.unique_code)??V.showCode;fe(t)}async function me(t){m.value=t;const e=t.unique_code??V.showCode;await fe(e)}function Me(){U.value=!1,ae.push("/pricing")}function Ne(){if(m.value){m.value=null,B.value=null,k.value=null,_.value=0;return}ae.push(q.value?"/nircreels":v.value?"/nirctoons":"/chat-stories")}function ye(){v.value||_.value<w.value.length&&(_.value++,Fe(()=>{var t;(t=Q.value)==null||t.scrollTo({top:Q.value.scrollHeight,behavior:"smooth"})}))}async function pe(){if(!le.isAuthenticated){D.value=!0;return}try{const t=await Qe();X.value=t.active}catch{X.value=!1}finally{D.value=!0}}return Ie(()=>V.showCode,()=>{D.value=!1,P(),pe()},{immediate:!1}),Ve(()=>{P(),pe()}),(t,e)=>{var r;return l(),a(A,null,[p(He,{"show-category-tabs":!1,"show-floating-actions":!1,"show-bottom-nav":!1,"force-login":!f(le).isAuthenticated},{default:ge(()=>{var i,n,C,S,E,O;return[s("div",et,[s("header",tt,[s("button",{type:"button",class:"p-2 -ml-2 rounded-full text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",onClick:$(Ne,["stop"])},[p(f(Xe),{class:"w-6 h-6"})]),s("div",st,[s("h1",lt,c(ie.value),1),ue.value?(l(),a("p",at,c(ue.value),1)):u("",!0)])]),z.value?(l(),a("div",ot,[...e[10]||(e[10]=[s("div",{class:"text-center"},[s("div",{class:"inline-block w-10 h-10 border-4 border-[#026B63] border-r-transparent rounded-full animate-spin"}),s("p",{class:"mt-3 text-sm text-gray-500 dark:text-gray-400"},"Loading episodesâ¦")],-1)])])):N.value?(l(),a("div",rt,[s("div",nt,[s("p",it,c(N.value),1),s("button",{type:"button",class:"mt-3 px-4 py-2 rounded-full bg-[#026B63] text-white font-medium text-sm",onClick:P}," Retry ")])])):b.value.length>0&&!m.value&&D.value?(l(),a("div",ut,[s("div",ct,[ee.value?(l(),a("div",dt,[s("img",{src:ee.value,alt:(i=h.value)==null?void 0:i.title,class:"w-full h-full object-cover",onError:I},null,40,vt),Z.value?(l(),a("button",{key:0,type:"button",class:"absolute top-3 right-3 inline-flex items-center gap-1.5 rounded-full bg-black/60 px-3.5 py-2 text-xs font-bold text-white transition-colors hover:bg-black/80",onClick:e[0]||(e[0]=$(o=>Y.value=!0,["stop"]))},[p(f(we),{class:"w-4 h-4"}),e[11]||(e[11]=be(" Watch trailer ",-1))])):u("",!0)])):u("",!0),s("h2",xt,c(((n=h.value)==null?void 0:n.title)||(v.value?"NircToon":"Chat Story")),1),(C=h.value)!=null&&C.description?(l(),a("p",ft,c(h.value.description),1)):u("",!0),Z.value&&!ee.value?(l(),a("button",{key:2,type:"button",class:"mb-6 inline-flex items-center gap-2 rounded-full border-[1.5px] border-[#026B63] px-5 py-2.5 text-sm font-bold text-[#02
16B63] transition-colors hover:bg-[#026B63]/5",onClick:e[1]||(e[1]=o=>Y.value=!0)},[p(f(we),{class:"w-4 h-4"}),e[12]||(e[12]=be(" Watch trailer ",-1))])):u("",!0),e[13]||(e[13]=s("h3",{class:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3"},"Episodes",-1)),s("div",mt,[(l(!0),a(A,null,W(b.value,(o,T)=>(l(),a("button",{key:o.id||o.unique_code||T,type:"button",class:g(["w-full flex gap-4 rounded-xl overflow-hidden bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 transition-colors text-left",L(o)?"opacity-75":"hover:border-[#026B63]/50"]),onClick:x=>ne(o)},[de(o)?(l(),a("div",pt,[s("img",{src:de(o),alt:o.title,class:"w-full h-full object-cover",onError:I},null,40,ht),L(o)?(l(),a("div",gt,[p(f(H),{class:"w-6 h-6 text-white"})])):u("",!0)])):(l(),a("div",bt,[s("span",kt,"E"+c(T+1),1),L(o)?(l(),a("div",_t,[p(f(H),{class:"w-6 h-6 text-white"})])):u("",!0)])),s("div",wt,[s("div",Ct,[s("p",St,c(o.title||`Episode ${T+1}`),1),o.sub_title||o.content_summary||o.content?(l(),a("p",Et,c(o.sub_title||o.content_summary||o.content),1)):u("",!0)]),L(o)?(l(),se(f(H),{key:0,class:"w-5 h-5 text-gray-400 dark:text-gray-500 flex-shrink-0 ml-2"})):u("",!0)])],10,yt))),128))])])])):F.value&&R.value?(l(),a("div",At,[...e[14]||(e[14]=[s("div",{class:"text-center"},[s("div",{class:"inline-block w-10 h-10 border-4 border-[#026B63] border-r-transparent rounded-full animate-spin"}),s("p",{class:"mt-3 text-sm text-gray-500 dark:text-gray-400"},"Loading conversationâ¦")],-1)])])):F.value&&k.value?(l(),a("div",Bt,[s("div",Tt,[s("p",$t,c(k.value),1),s("button",{type:"button",class:"mt-3 px-4 py-2 rounded-full bg-[#026B63] text-white font-medium text-sm",onClick:je}," Retry ")])])):b.value.length===0&&!z.value&&!N.value?(l(),a("div",jt,[...e[15]||(e[15]=[s("div",{class:"text-center text-gray-500 dark:text-gray-400"},[s("p",null,"No episodes found.")],-1)])])):F.value&&q.value&&!R.value&&!k.value?(l(),a("div",Mt,[s("div",Nt,[K.value?(l(),a("video",{key:K.value,src:K.value,class:"max-h-full max-w-full",controls:"",autoplay:"",playsinline:"",onEnded:re},null,40,Rt)):(l(),a("div",Ut,[p(f(De),{class:"w-14 h-14 mx-auto text-white/30"}),e[16]||(e[16]=s("p",{class:"mt-3 text-sm text-white/60"},"This episode has no video yet.",-1))]))]),s("div",It,[s("div",Vt,[s("p",qt,c(((S=B.value)==null?void 0:S.title)||((E=m.value)==null?void 0:E.title)),1),s("p",Lt," Episode "+c(J.value+1)+" of "+c(b.value.length),1)]),J.value<b.value.length-1?(l(),a("button",{key:0,class:"rounded-full bg-white/15 px-4 py-2 text-xs font-semibold",onClick:re}," Next ")):u("",!0)])])):F.value&&!R.value&&!k.value?(l(),a("div",Ft,[e[18]||(e[18]=s("div",{class:"chat-area-bg-layer","aria-hidden":"true"},null,-1)),s("div",{ref_key:"chatAreaRef",ref:Q,class:g(["chat-area-scroll flex-1 overflow-y-auto px-4 py-4 pb-28 min-h-0 relative z-10",{"cursor-pointer":!v.value}]),onClick:ye},[(O=B.value)!=null&&O.img_url&&_.value>0?(l(),a("div",{key:0,class:g(["rounded-xl overflow-hidden mb-4 cursor-pointer",v.value?"w-[95%] mx-auto":"mx-auto max-w-sm"]),onClick:e[2]||(e[2]=$(o=>G(ce.value),["stop"]))},[s("img",{src:ce.value,alt:"",class:g(["w-full object-cover",v.value?"h-52 md:h-72":"h-40"]),onError:I},null,42,Pt)],2)):u("",!0),s("div",{class:g(["space-y-3 mx-auto",v.value?"toon-strip-container w-full max-w-[800px] min-w-0":"max-w-2xl"])},[(l(!0),a(A,null,W(Ae.value,(o,T)=>(l(),a(A,{key:T},[v.value?(l(),a("div",Ot,[(l(!0),a(A,null,W(o.messages,(x,j)=>(l(),a(A,{key:j},[x.img_url?(l(),a("img",{key:0,src:x.img_url,alt:"",class:"toon-strip-image w-full rounded-lg object-contain object-left-top cursor-pointer block",onClick:$(he=>G(x.img_url),["stop"]),onError:I},null,40,Wt)):u("",!0)],64))),128))])):$e(o.sender)?(l(),a("div",zt,[s("p",Dt,c(o.sender),1),s("div",Yt,[(l(!0),a(A,null,W(o.messages,(x,j)=>(l(),a(A,{key:j},[s("p",{class:g(["text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap break-words",j>0?"mt-2":""])},c(x.content),3),x.img_url?(l(),a("img",{key:0,src:x.img_url,alt:"",class:"mt-2 rounded-lg max-w-full max-h-48 object-contain mx-auto cursor-pointer",onClick:$(he=>G(x.img_url),["stop"]),onError:I},null,40,Gt)):u("",!0)],64))),128))])])):(l(),a("div",{key:2,class:g(["flex gap-2 items-start",T%2===1?"flex-row-reverse":""])},[s("div",Ht,c(Be(o.sender)),1),s("div",{class:g(["min-w-0 flex flex-col max-w-[85%]",T%2===1?"items-end":"items-start"])},[s("p",{class:g(["text-xs font-medium mb-0.5 px-1",Te(o.sender)])},c(o.sender),3),s("div",{class:g(["rounded-2xl px-4 py-2.5 shadow-sm w-max max-w-full chat-bubble",[T%2===0?"chat-bubble-incoming":"chat-bubble-outgoing",T%2===0?"rounded-tl-md":"rounded-tr-md"]])},[(l(!0),a(A,null,W(o.messages,(x,j)=>(l(),a(A,{key:j},[s("p",{class:g(["text-sm text-gray-900 dark:text-white whitespace-pre-wrap break-words",j>0?"mt-2":""])},c(x.content),3),x.img_url?(l(),a("img",{key:0,src:x.img_url,alt:"",class:"mt-2 rounded-lg max-w-full max-h-48 object-contain cursor-pointer",onClick:$(he=>G(x.img_url),["stop"]),onError:I}
1,null,40,Kt)):u("",!0)],64))),128))],2)],2)],2))],64))),128)),_.value>=w.value.length&&w.value.length>0?(l(),a("div",Jt,[s("div",Qt,[e[17]||(e[17]=s("p",{class:"text-sm font-medium text-gray-600 dark:text-gray-400"},"End of conversation",-1)),s("p",Xt,"You've reached the end of this "+c(v.value?"toon":"chat story"),1)])])):u("",!0)],2)],2)])):u("",!0),!v.value&&F.value&&!R.value&&!k.value&&w.value.length>0&&_.value<w.value.length?(l(),a("div",Zt,[s("button",{type:"button",class:"flex items-center gap-2 px-6 py-3 rounded-full bg-[#026B63] text-white font-semibold shadow-xl hover:bg-[#025A54] transition-colors",onClick:$(ye,["stop"])},[e[19]||(e[19]=s("span",null,"Next",-1)),p(f(Ze),{class:"w-5 h-5"})]),e[20]||(e[20]=s("p",{class:"text-[10px] text-gray-500 dark:text-gray-400 mt-2 text-center"},"Tap anywhere for next",-1))])):u("",!0)]),(l(),se(ke,{to:"body"},[p(qe,{name:"emoticon-backdrop"},{default:ge(()=>[U.value?(l(),a("div",{key:0,class:"fixed inset-0 z-[999] flex items-center justify-center p-4",onClick:e[5]||(e[5]=$(o=>U.value=!1,["self"]))},[s("div",{class:"absolute inset-0 bg-black/50",onClick:e[3]||(e[3]=o=>U.value=!1)}),s("div",es,[s("div",ts,[p(f(H),{class:"w-7 h-7 text-[#026B63]"})]),e[21]||(e[21]=s("h3",{class:"text-lg font-bold text-gray-900 dark:text-white mb-2"},"Subscription Required",-1)),e[22]||(e[22]=s("p",{class:"text-sm text-gray-600 dark:text-gray-400 mb-6"}," Subscribe to unlock all episodes. ",-1)),s("div",ss,[s("button",{type:"button",class:"w-full py-3 rounded-full bg-[#026B63] text-white font-semibold text-sm hover:bg-[#025A54] transition-colors",onClick:Me}," View Plans "),s("button",{type:"button",class:"w-full py-3 rounded-full border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 font-medium text-sm hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",onClick:e[4]||(e[4]=o=>U.value=!1)}," Maybe Later ")])])])):u("",!0)]),_:1})])),(l(),se(ke,{to:"body"},[p(Ye,{open:te.value,"onUpdate:open":e[6]||(e[6]=o=>te.value=o),images:ve.value,"initial-index":0},null,8,["open","images"])]))]}),_:1},8,["force-login"]),p(Je,{open:Y.value,"onUpdate:open":e[7]||(e[7]=i=>Y.value=i),src:Z.value,title:((r=h.value)==null?void 0:r.title)||ie.value},null,8,["open","src","title"]),p(Oe,{open:f(M).paywallOpen.value,"onUpdate:open":e[8]||(e[8]=i=>f(M).paywallOpen.value=i),entitlement:f(M).entitlement.value,"content-type":"post","content-code":f(M).pendingCode.value,onUnlocked:Se,onBuySeries:e[9]||(e[9]=i=>U.value=!0)},null,8,["open","entitlement","content-code"])],64)}}}),xs=Ge(ls,[["__scopeId","data-v-cdcfa545"]]);export{xs as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.