PageSourceSearch

https://build-assets.static.wrtn.ai/web2/prod/main-arm64-3d96ac1/_next/static/chunks/3273-0f2ddeedfbe8c79f.js

js wrtn.ai collected 2026-09-24 11:52:58 UTC 176,235 bytes, 2 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="defae630-09b1-4bf6-9005-88be9f1f9d69",e._sentryDebugIdIdentifier="sentry-dbid-defae630-09b1-4bf6-9005-88be9f1f9d69")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3273],{2186:(e,t,n)=>{n.d(t,{X:()=>a});var r=n(94539);let l=e=>["v1","chats",e,"attachments"],i=e=>{let{chatId:t}=e;return r.FA.default.get("/v1/chats/".concat(t,"/attachments"))},a=()=>({key:l,fetcher:i})},3273:(e,t,n)=>{n.d(t,{B:()=>eK,c:()=>eV});var r=n(36868),l=n(48290),i=n(71676),a=n(34223),o=n(53239),s=n(12693),c=n(27645);let d=e=>{let{children:t,chatId:n}=e,{data:r}=(0,c.m)({chatId:n}),{trackEvent:l}=(0,s.jt)(),i=(0,o.useRef)(!1),a=(0,o.useMemo)(()=>{switch(null==r?void 0:r.type){case"interest-talk":return"coupon";case"churn":return"churn_message";case"gmail-briefing":return"gmail";default:return"chat"}},[null==r?void 0:r.type]);return(0,o.useEffect)(()=>{var e,t;r&&!i.current&&(i.current=!0,l("view_chat_screen",{service_detail:"chat",feature_name:a,chat_id:n,interest_talk_id:"interest-talk"===r.type?null==(e=r.interestTalk)?void 0:e.id:void 0,role_name:null==(t=r.supporterRole)?void 0:t.role}))},[n,r,a,l]),t};var u=n(76440),p=n(14144),h=n(26268),g=n(5946),m=n(94539),f=n(8109),v=n(99104),y=n(19334);let x=e=>{let{chatId:t,generate:n,children:r}=e,{value:l,removeItem:i}=(0,f.N)(),{input:s,updateInput:c}=(0,v.q)(),d=(0,o.useRef)(!1),{updateChatRoomStatus:u}=(0,a.P)(),p=!!s.message.length,{emitWithAck:h,connected:g}=(0,y.t)(),x=(0,o.useCallback)(async e=>{var r,l,i,a;let o=null==e||null==(r=e.attachments)?void 0:r.map(e=>{let{id:t}=e;return t}),s=["file","url"].includes(null!=(a=null==e||null==(i=e.attachments)||null==(l=i[0])?void 0:l.type)?a:"")?"file":"text";await h("enterChat",{chatId:t,clientHeaders:m.H1}),n({forceSearch:!!(null==e?void 0:e.forceSearch)||!!(null==e?void 0:e.trendId),trendId:null==e?void 0:e.trendId,message:e.message,type:s,originalAttachmentIds:(null==o?void 0:o.length)?o:void 0})},[t,h,n]);return(0,o.useEffect)(()=>{var e;s.message||(null==(e=s.attachments)?void 0:e.length)||null==l||!l.message||c({input:l})},[s.message,s.attachments,l,c]),(0,o.useEffect)(()=>{p&&!d.current&&s.message.length&&g&&(d.current=!0,x(s),u("streaming"),i(),c({input:{message:"",attachments:[]}}))},[i,g,s,p,x,u,c]),r({isChatInitiation:p})};var b=n(84568),_=n(34616),Y=n(59717),w=n(12279),k=n(20033),C=n(34307);let A=e=>{let{navigationId:t}=e;return m.FA.default.patch("/v1/chat-agent/messages?navigationId=".concat(t),{status:"read"})},F=()=>({key:e=>["/v1/chat-agent/messages?navigationId=".concat(e)],fetcher:A}),I=e=>["/v1/chats",e],D=e=>{let{chatId:t,...n}=e;return m.FA.default.put("/v1/chats/".concat(t),{...n})},S=()=>({key:I,fetcher:D});var R=n(28740);let M=e=>{let{chatId:t,children:n}=e,r=(0,_.jE)(),{isAuth:l}=(0,k.A)(),i=(0,Y.n)({mutationKey:F().key(t),mutationFn:F().fetcher}),a=(0,Y.n)({mutationKey:S().key(t),mutationFn:S().fetcher,onSuccess:()=>{r.setQueryData((0,R.P)().key(t),e=>e?{...e,unreadCount:null}:e),r.invalidateQueries({queryKey:["chats","count"]}),r.invalidateQueries({queryKey:[...C.R,""]})}}),{data:s}=(0,w.I)({queryKey:(0,R.P)().key(t),queryFn:()=>(0,R.P)().fetcher({chatId:t})});return(0,o.useEffect)(()=>{var e,n;let r=null!=(e=null==s?void 0:s.unreadCount)?e:0;s&&!(r<=0)&&a.mutate({chatId:t,topic:null!=(n=s.topic)?n:"",unreadCount:null,pinnedAt:(null==s?void 0:s.pinnedAt)||null})},[t,s]),(0,o.useEffect)(()=>{!i.isPending&&l&&i.mutate({navigationId:t})},[l]),n};var T=n(7109),E=n(48253),j=n(23380),z=n(20915);let B=e=>{let{chatId:t,children:n}=e,{data:r}=(0,c.m)({chatId:t}),{on:l,off:i}=(0,y.t)(),{syncMessage:a}=(0,z.t)({chatId:t});return(0,o.useEffect)(()=>{if(!r)return;let e=[];
1if("interest-talk"===r.type){let n=e=>{a({assistantMessage:e,key:(0,T.$)(t)})};l("interestTalkMessage",n),e.push(()=>i("interestTalkMessage",n))}if("churn"===r.type){let n=e=>{a({assistantMessage:e,key:(0,E.v)(t)})};l("churnMessage",n),e.push(()=>i("churnMessage",n))}if("gmail-briefing"===r.type){let n=e=>{a({assistantMessage:e,key:(0,j.TND)({path:{chatId:t}})})};l("gmailBriefingMessage",n),e.push(()=>i("gmailBriefingMessage",n))}return()=>{e.forEach(e=>e())}},[r,t,i,l,a]),n};var L=n(22078),H=n(47427),P=n(21257),q=n(84494),Z=n(85607),N=n(97220),O=n(64297);let K=e=>{let{children:t,generate:n}=e,r=(0,O.rd)(),{isEnterChatRoom:l}=(0,b.g)(),{updateChatRoomStatus:i}=(0,a.P)(),s=r.query,c=(0,N._g)(()=>{var e;let t=null==(e=s.id)?void 0:e[0];n({message:s.q}),i("streaming"),r.replace("/c/".concat(t),void 0,{shallow:!0})},1800);return(0,o.useEffect)(()=>{var e;let t,n;return l&&s.q&&(null==(e=s.id)?void 0:e[0])&&(t=window.setTimeout(()=>{c()},1e3),n=window.setTimeout(()=>{i("streaming")},1200)),()=>{window.clearTimeout(t),window.clearTimeout(n)}},[s.q,r,l]),t};var V=n(54924),W=n(95633),Q=n(8665);let $={message:"",trendId:void 0,attachments:void 0,toolAttachment:void 0},U=e=>{let{children:t}=e,n=(0,W.md)(V.M),r=(0,Q.mN)({defaultValues:$});return(0,o.useEffect)(()=>{r.reset(n)},[n,r]),t({formMethods:r})};var X=n(61844),G=n(54065),J=n(13181),ee=n(63216),et=n(25495),en=n(65615),er=n(35977);let el="wrtn2_suppress_suggest_using_app",ei=(0,en.tG)(el,(0,er.X)(el,!1,()=>sessionStorage),(0,en.KU)(()=>sessionStorage));ei.debugLabel="@/src/shared/web2/utils-web2-atoms/isSupressedSuggestUsingAppAtom";var ea=n(47219),eo=n(65833),es=n(5603),ec=n.n(es);let ed=()=>{let[e,t]=(0,o.useState)(!1),[n,l]=(0,W.fp)(ei),{trackEvent:i}=(0,s.jt)();return((0,o.useEffect)(()=>{t(ep())},[]),e)?(0,r.Y)(ea.N,{initial:!1,children:!n&&(0,r.FD)(eo.P.div,{css:eu.container,animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},children:[(0,r.Y)(s.Yn,{name:"expose_app_install_recommend_modal",children:(0,r.Y)(G.Z,{typo:"Body7",children:"앱에서 더 편리하게 사용할 수 있어요"})}),(0,r.FD)("div",{css:eu.buttonGroup,children:[(0,r.Y)(ec(),{href:"https://agent.wrtn.ai/zhoxyo",target:"_blank",rel:"noopener noreferrer",css:eu.installButton,onClick:()=>{i("click_app_install_recommend_btn")},children:(0,r.Y)(G.Z,{typo:"Body7",as:"span",color:"text_primary_inverted",children:"앱 사용하기"})}),(0,r.Y)("button",{type:"button",onClick:()=>{l(!0),i("close_app_install_recommend_btn")},css:eu.closeButton,children:(0,r.Y)(ee.N,{})})]})]})}):null},eu={container:(0,X.AH)({display:"none",alignItems:"center",justifyContent:"space-between",backgroundColor:(0,J.V)("surface_elevated"),padding:"8px 12px 8px 16px",borderRadius:20,border:"1px solid ".concat((0,J.V)("outline_secondary")),[et.mq.tablet]:{display:"flex"}}),buttonGroup:(0,X.AH)({display:"flex",alignItems:"center",gap:4}),installButton:(0,X.AH)({backgroundColor:(0,J.V)("surface_primary_invert"),color:(0,J.V)("text_primary_inverted"),padding:"8px 16px",borderRadius:999,border:"none",cursor:"pointer",transition:"all 0.2s ease",height:34,span:{display:"block",height:20}}),closeButton:(0,X.AH)({backgroundColor:"transparent",border:"none",width:28,height:28,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",svg:{width:18,height:18,path:{fill:(0,J.V)("text_tertiary")}}})},ep=()=>{var e;let t=null==(e=window.navigator.userAgent)?void 0:e.toLowerCase();if(t){let e=/iphone|ipad|ipod/.test(t),n=/android/.test(t);if(e||n)return!0}return!1};var eh=n(45979),eg=n(53280),em=n(21339),ef=n(74766);let ev=e=>{let{chatId:t}=e,{data:n}=(0,c.m)({chatId:t}),{data:l}=(0,w.I)({...(0,j.Uyz)({path:{chatId:t}}),enabled:!!t,retry:0}),i=(0,W.md)(ef._);return(null==l?void 0:l.type)==="interest-talk"||(null==l?void 0:l.type)==="gmail-briefing"||(null==l?void 0:l.disabledInputBox)?null:(0,r.Y)("div",{suppressHydrationWarning:!0,className:i?"__input-focused":"",css:[et.tR,{flexShrink:0,height:40,width:"100%"}],children:(0,r.Y)(em.t,{p:"3px 8px",children:(0,r.Y)(G.Z,{color:"text_quaternary",typo:"Text7",children:(null==n?void 0:n.isGpt5)?"GPT-5는 아직 불안정하거나 느릴 수 있어요":"AI 서포터가 제공하는 답변은 완벽하지 않을 수 있어요"})})})};var ey=n(27181),ex=n.n(ey),eb=n(3517),e_=n(51882),eY=n(60651);let ew=()=>(0,r.Y)(eY.d,{src:"https://fe-web-assets.static.wrtn.ai/wrtn2/chat/gpt_5_badge.png",alt:"gpt5 badge",he
1ight:22,width:53,style:{objectFit:"cover"}}),ek=()=>{let{id:e}=(0,eb.useParams)(),{title:t}=(()=>{let{chatId:e}=(0,e_.W)(),{data:t,isLoading:n}=(0,c.m)({chatId:null!=e?e:""});return{title:(0,o.useMemo)(()=>{var e,r,l;return n?"":(null==t?void 0:t.type)==="interest-talk"?null!=(r=null==(e=t.interestTalk)?void 0:e.name)?r:"새로운 채팅":null!=(l=null==t?void 0:t.topic)?l:"새로운 채팅"},[t,n]),isLoading:n}})(),{data:n}=(0,c.m)({chatId:e});return(0,r.FD)(r.FK,{children:[t?(0,r.Y)(ex(),{children:(0,r.Y)("title",{children:t})}):null,(0,r.Y)("div",{css:eC.wrapper,children:(0,r.FD)("div",{css:[et.XF,{gap:8,alignItems:"center"}],children:[(0,r.Y)("div",{css:eC.title,children:t}),(null==n?void 0:n.isGpt5)&&(0,r.Y)(ew,{})]})})]})},eC={wrapper:(0,X.AH)({[et.mq.mobile]:{display:"none"}}),title:(0,X.AH)({color:(0,J.V)("text_primary"),fontSize:16,fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"})};var eA=n(30763),eF=n(70715),eI=n(64046),eD=n(59704);let eS=()=>{let{push:e}=(0,O.rd)(),{isAuth:t}=(0,k.A)(),{open:n,ModalComponent:l}=(0,eD.G)({variant:"chat"});return(0,r.FD)(r.FK,{children:[(0,r.Y)(eA.R,{content:"새 채팅방",children:(0,r.Y)(eF.K,{buttonStyle:"ghost",icon:(0,r.Y)(eI.N,{}),onClick:()=>{if(!t)return void n();e("/")}})}),l]})};var eR=n(34721),eM=n(46239),eT=n(63586),eE=n(1332),ej=n(51372),ez=n(46617),eB=n(53948),eL=n(3617),eH=n(43313),eP=n(90664),eq=n(99854),eZ=n(37185),eN=n(14634),eO=n(80902);let eK=()=>{var e;let{query:t}=(0,O.rd)(),n=null==(e=t.id)?void 0:e[0];return n?(0,r.Y)(i.k,{chatId:n,children:e=>{let{role:t}=e;return(0,r.Y)(a.g,{chatId:n,children:(0,r.Y)(d,{chatId:n,children:(0,r.Y)(u.A,{chatId:n,role:t,children:(0,r.Y)(p.b,{children:e=>{let{generate:i,stopGenerate:a,generatingStatus:o,messageQueue:s}=e;return(0,r.Y)(h.$,{chatId:n,generatingStatus:o,stopGenerate:a,children:(0,r.Y)(g.P,{chatId:n,children:(0,r.Y)(x,{chatId:n,generate:i,children:e=>{let{isChatInitiation:c}=e;return(0,r.Y)(b.B,{chatId:n,isChatInitiation:c,children:(0,r.Y)(M,{chatId:n,children:(0,r.Y)(B,{chatId:n,children:(0,r.FD)(L.n,{chatId:n,children:[(0,r.Y)(H.R,{chatId:n}),(0,r.Y)(P.m,{chatId:n,children:(0,r.Y)(q.l,{chatId:n,children:e=>{let{fixedAttachments:c,resetFixedAttachments:d}=e;return(0,r.Y)(Z.M,{generate:i,chatId:n,children:e=>{let{submitMessage:u}=e;return(0,r.Y)(K,{generate:u,children:(0,r.Y)(U,{children:e=>{let{formMethods:p}=e;return(0,r.Y)("div",{css:{width:"100%",maxWidth:768,maxHeight:"266px",[et.mq.mobile]:{maxWidth:"100%",width:"100%"}},children:(0,r.Y)(l.a,{disabled:"streaming"===o||!!s,hiddenRoleSettingButton:!0,resetFixedAttachments:d,formMethods:p,topArea:(0,r.FD)(r.FK,{children:[(0,r.Y)(ed,{}),(0,r.Y)(eh.N,{generate:i,chatId:n,isStreaming:"streaming"===o||!!s})]}),placeholder:null==t?void 0:t.placeholder,currentRole:t,fixedAttachments:c,onSubmit:u,renderSubmitButton:"streaming"===o||s?()=>(0,r.Y)(eg.A,{onClick:a}):void 0})})}})})}})}})}),(0,r.Y)(ev,{chatId:n})]})})})})}})})})}})})})})}}):null};eK.getLayout=e=>(0,r.Y)(eP.d,{children:(0,r.Y)(eL.D,{noPadding:!0,bgColor:"background_primary",lnb:(0,r.Y)(eE.j,{}),header:(0,r.Y)(eH.Q,{wrapperCSS:{borderBottom:"1px solid ".concat((0,J.V)("outline_primary"))},left:(0,r.FD)(eZ.zt,{gap:"8px",children:[(0,r.Y)(eM.p,{}),(0,r.Y)(eN.a,{display:["flex","flex","flex","flex","none"],children:(0,r.Y)(eO.g,{})})]}),center:(0,r.Y)(ek,{}),right:(0,r.FD)(eZ.zt,{gap:"8px",children:[(0,r.Y)("div",{css:{[et.mq.mobile]:{display:"none"}},children:(0,r.Y)(eS,{})}),(0,r.Y)(eT.Y.UtilityBar,{isHideSignupButtonOnMobileDevice:!0})]})}),renderSideBar:()=>(0,r.Y)(eq.F,{}),...e.props,children:e})});let eV=(0,eR.B1)({gsspFunctions:[ez.$,async e=>{var t,n,r;let l=await (0,eB.E)(e);if(l)return{redirect:{destination:l.destination,permanent:l.permanent}};let i=(0,s.W3)(e).distinct_id;return(null==(t=e.query)?void 0:t.q)==="뤼튼은 왜 무료인가요?"&&await (0,s.ui)({ctx:e,event:"generate_done_server",data:{service_type:"companion",service_detail:"chat",feature_name:"chat",chat_id:(null==(r=e.params)||null==(n=r.id)?void 0:n[0])||"",open_time:Date.now(),force_search:!1,is_tool_recommend:!1,regenerate:!1,is_minichat_re:!1,attachment_count:0,is_
1webview:!1,platform_type:"web"},fallbackDistinctId:i}),await (0,ej.y)(e),(0,eR.m4)(e,()=>[])}]})},5946:(e,t,n)=>{n.d(t,{P:()=>o});var r=n(36868),l=n(53239),i=n(91365);let a=(0,l.createContext)({attachments:[]}),o=e=>{let{children:t,chatId:n}=e,{attachments:o}=(0,i.i)({chatId:n}),s=(0,l.useMemo)(()=>({attachments:o}),[o]);return(0,r.Y)(a.Provider,{value:s,children:t})}},7109:(e,t,n)=>{n.d(t,{$:()=>r});let r=e=>["v1","interest-talks",e,"messages"]},13034:(e,t,n)=>{n.d(t,{I:()=>c});var r,l=n(36868),i=n(87267),a=n(53239);function o(){return(o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}let s=function(e){return a.createElement("svg",o({xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 24 24"},e),r||(r=a.createElement("path",{fillRule:"evenodd",d:"m7.05 12.842-1.414 1.415 4.95 4.95.353.353a1.5 1.5 0 0 0 2.122 0l.353-.354 4.95-4.95-1.414-1.414-3.95 3.95V4.001h-2v12.791z",clipRule:"evenodd"})))},c=e=>{var t;let{width:n="24px",height:r="24px",...a}=e;return(0,l.Y)(s,{width:n,height:r,...a,...(0,i.u$)()({fill:null!=(t=null==a?void 0:a.fill)?t:"icon_primary"})})}},13037:(e,t,n)=>{n.d(t,{p:()=>r});let r=e=>["v1","chats",e,"messages"]},14144:(e,t,n)=>{n.d(t,{b:()=>l});var r=n(76440);let l=e=>{let{children:t}=e,{generate:n,stopGenerate:l,generatingStatus:i,messageQueue:a}=(0,r.d)();return t({generate:n,generatingStatus:i,stopGenerate:l,messageQueue:a})}},20915:(e,t,n)=>{n.d(t,{t:()=>o});var r=n(34616),l=n(23380),i=n(34307),a=n(2186);let o=e=>{let{chatId:t}=e,n=(0,r.jE)(),{key:o}=(0,a.X)();return{invalidateAttachmentCache:()=>{n.invalidateQueries({queryKey:o(t)})},invalidateChatCache:()=>{n.invalidateQueries({queryKey:(0,l.NXs)({path:{chatId:t}})}),n.invalidateQueries({queryKey:[...i.R,""]})},syncMessage:e=>{let{assistantMessage:t,userMessage:r,key:l}=e,i=[t,r].filter(Boolean);n.setQueryData(l,e=>{if(!e)return{pages:[{list:i}],pageParams:[""]};let t=[...e.pages],n=t[0],r=n.list,l=r.map(e=>e.id),a=r.map(e=>{let t=i.find(t=>t.id===e.id);return t?{...e,...t}:e}),o=i.filter(e=>!l.includes(e.id));return t[0]={...n,list:[...o,...a]},{...e,pages:t}})}}}},21257:(e,t,n)=>{n.d(t,{m:()=>_});var r=n(36868),l=n(53239),i=n(12279),a=n(23380),o=n(20033),s=n(89498),c=n(29365),d=n(95633),u=n(27645),p=n(21339),h=n(48533),g=n(34616),m=n(59717),f=n(12693),v=n(94539);let y=e=>{let{interestTalkId:t}=e;return v.kJ.default.get("/v1/interest-talks/".concat(t,"/subscription"))},x=e=>{let{interestTalkId:t,subscriptionType:n,isHidden:r}=e;return v.FA.default.post("/v1/interest-talks/".concat(t),{subscriptionType:n,isHidden:r})},b=e=>{let{subscribe:t,isSubscribed:n,updateInterestTalkLoading:l,getSubscriptionInterestTalkLoading:a}=(e=>{let{interestTalkId:t}=e,{fetcher:n,key:r}={key:e=>["getSubscriptionInterestTalk",e],fetcher:y},{data:l,isFetching:a}=(0,i.I)({queryKey:r(t),queryFn:()=>n({interestTalkId:t})}),{trackEvent:o}=(0,f.jt)(),{fetcher:c,key:d}={key:e=>["updateInterestTalk",e],fetcher:x},u=(0,g.jE)(),{mutate:p,isPending:h}=(0,m.n)({mutationKey:d(t),mutationFn:()=>c({interestTalkId:t,subscriptionType:"subscribed"}),onSuccess:()=>{s.oR.alert("다시 관심톡을 보내드릴게요"),u.invalidateQueries({queryKey:["/v2/missions","WRTN_NEWS"]}
1),u.invalidateQueries({queryKey:["/v2/missions/recommended"]}),u.invalidateQueries({queryKey:["getInterestTalkList"]}),u.invalidateQueries({queryKey:r(t)})}});return{subscribe:()=>{o("click_interesttalk_resubscribe_btn",{service_detail:"chat",feature_name:"coupon",interest_talk_id:t}),p()},isSubscribed:l,getSubscriptionInterestTalkLoading:a,updateInterestTalkLoading:h}})(e);return a||n?null:(0,r.Y)(p.t,{pt:"8px",children:(0,r.Y)(h.$,{onClick:t,isLoading:l,width:"200px",height:"40px",typo:"Subtitle6",color:"text_white",backgroundColor:"tint_accent_primary",p:"10px 24px",children:"다시 추가하고 관심톡 받기"})})},_=e=>{var t;let{children:n,chatId:p}=e,h=(0,d.Xr)(c.xj),g=(0,d.Xr)(c.qU),{isAuth:m}=(0,o.A)(),{data:f,isLoading:v}=(0,i.I)({...(0,a.Kw3)(),enabled:m,retry:!1}),{data:y,isLoading:x}=(0,i.I)({...(0,a.HKr)(),enabled:!!(m&&(null==f?void 0:f.isConnected))}),{data:_}=(0,u.m)({chatId:p});return((0,l.useEffect)(()=>{if(!v&&(null==_?void 0:_.type)==="gmail-briefing")return(null==f?void 0:f.isConnected)||(0,s.VV)("현재 Gmail 연동이 해제된 상태예요",void 0,"계정 연동하기",{style:{top:14,boxShadow:"none"},bodyStyle:{width:"344px",margin:0,padding:0,borderRadius:0,flexShrink:0},closeOnClick:!1,autoClose:!1},()=>{h(!0),g(c.pM.CONNECTOR)}),()=>{s.oR.customToast.dismiss()}},[null==_?void 0:_.type,null==f?void 0:f.isConnected,v,h,g]),(0,l.useEffect)(()=>{x||(null==_?void 0:_.type)==="gmail-briefing"&&(null==y?void 0:y.status)==="in_progress"&&(0,s.ft)("Gmail 계정을 연동했어요",void 0,{style:{top:14,boxShadow:"none",margin:"0px auto",width:"fit-content"}})},[null==_?void 0:_.type,null==y?void 0:y.status,x]),(null==_?void 0:_.type)&&(null==_?void 0:_.type)!=="churn"&&(null==_?void 0:_.type)!=="gmail-briefing")?(null==_?void 0:_.type)==="interest-talk"&&(null==_||null==(t=_.interestTalk)?void 0:t.id)?(0,r.Y)(b,{interestTalkId:_.interestTalk.id}):(null==_?void 0:_.type)==="counseling"||_.disabledInputBox?null:n:null}},22078:(e,t,n)=>{n.d(t,{n:()=>f});var r=n(36868),l=n(10709),i=n(25495),a=n(53239),o=n(12279),s=n(64208),c=n(23380),d=n(21339),u=n(37185),p=n(54065),h=n(69471),g=n(63216);function m(e){var t;let{chatId:n}=e,[l,i]=(0,a.useState)(!0),{flag:m}=(0,s._P)("supporter-role"),{data:f}=(0,o.I)({...(0,c.Uyz)({path:{chatId:null!=n?n:""}})});return l&&(null==f||null==(t=f.supporterRole)?void 0:t.caution)&&m?(0,r.Y)(d.t,{backgroundColor:"surface_elevated",border:"1px solid",borderColor:"outline_primary",px:"16px",py:"8px",borderRadius:"9999px",width:"fit-content",children:(0,r.FD)(u.zt,{gap:"4px",alignItems:"center",children:[(0,r.Y)(p.Z,{typo:"Text6",color:"text_secondary",textAlign:"center",children:f.supporterRole.caution}),(0,r.Y)(h.o,{onClick:()=>i(!1),children:(0,r.Y)(d.t,{p:"2px",display:"flex",children:(0,r.Y)(g.N,{width:"16px",height:"16px",fill:"icon_tertiary"})})})]})}):null}let f=e=>{let{children:t,chatId:n}=e,a=(0,l.H)();return(0,r.Y)("div",{css:{width:"100%",height:"100%",[i.mq.tablet]:{padding:"0 12px"}},children:(0,r.FD)("div",{css:[i.BL,{width:"100%",height:"100%",alignItems:"center",position:"relative"}],children:[(0,r.Y)("div",{css:[i.tR,{position:"absolute",top:a?56:5,padding:"0 12px",width:"100%",zIndex:1}],children:(0,r.Y)(m,{chatId:n}
1)}),t]})})}},26268:(e,t,n)=>{n.d(t,{$:()=>u});var r=n(53239),l=n(93957),i=n(64297),a=n(19334),o=n(89498),s=n(54924),c=n(95633),d=n(27645);let u=e=>{let{chatId:t,children:n,stopGenerate:u,generatingStatus:p}=e,h=(0,c.Xr)(s.M),{removeAllListeners:g}=(0,a.t)(),{isError:m}=(0,d.m)({chatId:t}),{replace:f,events:v}=(0,i.rd)(),{messageQueue:y}=(0,l.q)();return(0,r.useEffect)(()=>{m&&(o.oR.alert("삭제됐거나 찾을 수 없는 채팅방이에요"),f("/"))},[m,f]),(0,r.useEffect)(()=>{let e=()=>{h({message:"",attachments:void 0,toolAttachment:void 0}),("streaming"===p||y)&&(u(),g())};return v.on("routeChangeStart",e),()=>{v.off("routeChangeStart",e)}},[v,u,p,g,h]),n}},27349:(e,t,n)=>{n.d(t,{Z:()=>m});var r=n(86739),l=n(36868),i=n(53239),a=n(61844),o=n(69471),s=n(21339),c=n(37185),d=n(54065),u=n(65072),p=n(70488);function h(){let e=(0,r._)(["\n          &:last-child {\n            border-bottom: none;\n          }\n\n          &:hover {\n            p {\n              text-decoration: underline;\n            }\n          }\n        "]);return h=function(){return e},e}function g(){let e=(0,r._)(["\n                display: flex;\n                align-items: center;\n                justify-content: center;\n              "]);return g=function(){return e},e}let m=e=>{var t;let{webSearchResult:n}=e,[r,m]=(0,i.useState)(!1);return(0,l.Y)(o.o,{onClick:()=>(t=>{var n;null==(n=e.onClick)||n.call(e),window.open(t,"_blank")})(n.link),children:(0,l.Y)(s.t,{p:"16px 8px",borderBottom:"1px solid",borderColor:"outline_primary",css:(0,a.AH)(h()),children:(0,l.FD)(c.zt,{width:"100%",justifyContent:"space-between",gap:"4px",children:[(0,l.FD)(c.Tk,{gap:"4px",children:[(0,l.FD)(c.zt,{gap:"4px",alignItems:"center",children:[(0,l.Y)(p.d,{size:16,url:null!=(t=n.favicon)?t:""}),(0,l.Y)(d.Z,{typo:"Body7",color:"text_secondary",children:n.source})]}),(0,l.Y)(d.Z,{typo:"Subtitle6",ellipsis:!0,lineClamp:1,children:n.title}),(0,l.Y)(d.Z,{typo:"Body7",color:"text_secondary",ellipsis:!0,lineClamp:2,children:n.snippet})]}),n.thumbnail&&(0,l.Y)(s.t,{width:"82px",height:"82px",borderRadius:"8px",overflow:"hidden",flexShrink:0,backgroundColor:"surface_secondary",css:(0,a.AH)(g()),children:r?(0,l.Y)(u.X,{width:"32px",height:"32px",fill:"icon_quaternary"}):(0,l.Y)("img",{width:"100%",height:"100%",src:n.thumbnail,alt:"web-search-thumbnail",style:{objectFit:"cover"},referrerPolicy:"no-referrer",onError:()=>m(!0)})})]})})})}},27645:(e,t,n)=>{n.d(t,{m:()=>i});var r=n(12279),l=n(28740);let i=e=>{let{chatId:t,skip:n}=e,{fetcher:i,key:a}=(0,l.P)(),{data:o,isLoading:s,isError:c}=(0,r.I)({queryKey:a(t),queryFn:()=>i({chatId:null!=t?t:""}),enabled:!!t&&!n,retry:0});return{data:o,isLoading:s,isError:c}}},28740:(e,t,n)=>{n.d(t,{P:()=>a});var r=n(23380);let l=e=>(0,r.NXs)({path:{chatId:e}}),i=e=>(0,r.uCK)({path:{chatId:e.chatId},throwOnError:!0}).then(e=>e.data),a=()=>({key:l,fetcher:i})},30135:(e,t,n)=>{n.d(t,{Q:()=>i,S:()=>l});var r=n(51837);let l=(0,r.eU)(!1);l.debugLabel="@/src/shared/web2/utils-web2-atoms/isMinichatOpenedAtom";let i=(0,r.eU)("right");i.debugLabel="@/src/shared/web2/utils-web2-atoms/minichatPositionAtom"}
1,34223:(e,t,n)=>{n.d(t,{g:()=>s,P:()=>c});var r=n(36868),l=n(53239),i=n(19334),a=n(94539);let o=(0,l.createContext)(null),s=e=>{let{chatId:t,children:n}=e,{on:s,off:c}=(0,i.t)(),[d,u]=(0,l.useState)("ready"),{getChatStatus:p}=(()=>{let{emitWithAck:e}=(0,i.t)();return{getChatStatus:async t=>{let{status:n}=await e("chatStatus",{chatId:t,clientHeaders:a.H1});return n}}})(),h=(0,l.useRef)(!1),g=(0,l.useCallback)(e=>{u(e)},[]),m=(0,l.useCallback)(async()=>{h.current||(u(await p(t)),h.current=!1)},[t,p]);(0,l.useEffect)(()=>(s("disconnectServer",m),()=>{c("disconnectServer",m)}),[m,c,s]);let f=(0,l.useMemo)(()=>({chatRoomStatus:d,updateChatRoomStatus:g,chatId:t}),[t,d,g]);return(0,r.Y)(o.Provider,{value:f,children:n})},c=()=>{let e=(0,l.useContext)(o);if(!e)throw Error("ChatStatusProvider 초기화 되지 않았습니다.");return e}},34568:(e,t,n)=>{n.d(t,{H:()=>c});var r=n(12903),l=n(13037),i=n(94539);let a=e=>(0,l.p)(e),o=e=>{let{chatId:t,cursor:n}=e;return i.FA.default.get("/v1/chats/".concat(t,"/messages"),{params:{limit:20,cursor:n}})};var s=n(76440);let c=e=>{let{chatId:t,skip:n}=e,{fetcher:i}={key:a,fetcher:o},{generatingStatus:c}=(0,s.d)();return(0,r.q)({queryKey:(0,l.p)(t),queryFn:e=>{let{pageParam:n=""}=e;return i({chatId:t,cursor:n})},initialPageParam:"",retry:!1,getNextPageParam:e=>{var t;return null!=(t=null==e?void 0:e.nextCursor)?t:void 0},enabled:"streaming"!==c&&!n})}},35279:(e,t,n)=>{n.d(t,{Y:()=>m});var r=n(36868),l=n(37185),i=n(14634),a=n(54065),o=n(69006);let s="12px 20px 8px";var c=n(70715),d=n(44369),u=n(63216);let p=Object.assign(function(e){let{title:t,renderCloseButton:n,renderPreviousButton:c}=e,{isMiniChat:d}=(0,o.p)(),u=d?"8px 20px":"0 20px";return(0,r.FD)(l.Tk,{p:[u,u,u,s,s],backgroundColor:"surface_elevated",position:"sticky",top:0,children:[!d&&(0,r.Y)(i.a,{width:"40px",height:"4px",backgroundColor:"icon_quaternary",borderRadius:"40px",m:"8px auto",display:["block","block","block","none","none"]}),(0,r.FD)(l.zt,{width:"100%",justifyContent:"space-between",alignItems:"center",children:[c,(0,r.Y)(a.Z,{typo:"Subtitle4",children:t}),(0,r.Y)(i.a,{display:d?"flex":["none","none","none","flex","flex"],children:n})]})]})},{Back:e=>{let{onClick:t}=e;return(0,r.Y)(c.K,{icon:(0,r.Y)(d.R,{}),onClick:t})},Close:function(e){let{onClick:t}=e;return(0,r.Y)(c.K,{icon:(0,r.Y)(u.N,{}),onClick:t})}});var h=n(53239),g=n(21339);let m=Object.assign((0,h.forwardRef)(function(e,t){return(0,r.Y)(g.t,{backgroundColor:"surface_elevated",width:"100%",height:"100%",borderRadius:"12px",boxShadow:"shadow_soft",position:"relative",overflow:"auto",flex:1,ref:t,children:e.children})}),{Header:p})},35977:(e,t,n)=>{n.d(t,{X:()=>l});let r={true:!0,false:!1},l=function(e,t){let n,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:()=>{try{return window.localStorage}catch(e){return}};try{n=l()}catch(e){n=void 0}if(void 0===n)return t;let i=n.getItem(e);return i&&i in r?r[i]:t}},36936:(e,t,n)=>{n.d(t,{P:()=>c});var r,l=n(36868),i=n(87267),a=n(53239);function o(){return(o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}let s=function(e){return a.createElement("svg",o({xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 25 25"},e),r||(r=a.createElement("path",{fillRule:"evenodd",d:"M12.5 2.437a1 1 0 0 1 .89.543l2.603 5.077 5.663.89a1 1 0 0 1 .795.675.99.99 0 0 1-.244 1.01l-4.055 4.028.898 5.628a.99.99 0 0 1-.4.96c-.303.219-.706.25-1.041.08l-5.11-2.587-5.108 2.588c-.335.17-.737.138-1.042-.082a.99.99 0 0 1-.4-.96l.899-5.627-4.055-4.029a.99.99 0 0 1-.244-1.01 1 1 0 0 1 .795-.674l5.662-.89 2.602-5.077a1 1 0 0 1 .891-.543m0 3.183-1.944 3.79a1 1 0 0 1-.734.531l-4.226.664 3.026 3.007a.99.99 0 0 1 .281.858l-.67 4.202 3.812-1.932c.285-.144.623-.144.908 0l3.815 1.932-.671-4.202a.99.99 0 0 1 .28-.858l3.027-3.007-4.227-.664a1 1 0 0 1-.735-.53z",clipRule:"evenodd"})))},c=e=>{var t;let{width:n="24px",height:r="24px",...a}=e;return(0,l.Y)(s,{width:n,height:r,...a,...(0,i.u$)()({fill:null!=(t=null==a?void 0:a.fill)?t:"icon_primary"})})}}
1,37352:(e,t,n)=>{n.d(t,{DE:()=>l});let r=/[\s,:.!?\u3001\u3002\uff0c\u06d4]+/gi;function l(e){var t,n;let l=null!=(t=e.split(r))?t:[],i=null!=(n=e.match(r))?n:[],a=[];for(let e=0;e<l.length;e++){let t=l[e];e<i.length&&(t+=i[e]),a.push(t)}return a}},44739:(e,t,n)=>{n.d(t,{R:()=>i});var r=n(53239),l=n(83080);function i(){let{closeOnUnmount:e=!0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{mount:t,unmount:n}=(0,l.w)(),i=(0,r.useCallback)(()=>n(),[n]),a=(0,r.useCallback)(e=>{t(e({open:t,close:i}))},[t,i]);return(0,r.useEffect)(()=>{if(e)return()=>i()},[e,i]),(0,r.useMemo)(()=>({open:a,close:i}),[a,i])}},45979:(e,t,n)=>{n.d(t,{N:()=>x});var r=n(36868),l=n(53239),i=n(61844),a=n(62205),o=n(12693),s=n(65126),c=n(68645),d=n(89498),u=n(1223),p=n(13181),h=n(54065),g=n(63216),m=n(69342),f=n(15708),v=n(25495),y=n(71357);let x=e=>{var t;let{chatId:n,generate:x,isStreaming:Y}=e,[w,k]=(0,l.useState)("left"),{data:C}=(0,s.jK)(),{trackEvent:A}=(0,o.jt)(),{mutateChatSetting:F}=(0,s.YZ)(),I=(0,l.useRef)(null),D=null==(t=(0,y.V)({chatId:n}).getLastMessage())?void 0:t.followUpQuestions;(0,l.useEffect)(()=>{D&&!(D.length<1)&&A("expose_recommend_questions_chip",{service_detail:"chat",feature_name:"chat",chip_type:"recommend_chip",content:D.map(e=>e).join(","),chat_id:n})},[D,n]);let S=Y||!D||D.length<1||(null==C?void 0:C.enableSuggestions)!==!0;return((0,l.useEffect)(()=>{k("left")},[S]),S)?null:(0,r.FD)(r.FK,{children:[(0,r.Y)(i.mL,{styles:(0,i.AH)({".hide-followup-questions .followup-wrapper":{display:"none"},[".".concat(c.D)]:{".scroll-button":{display:"flex"},".followup-scroll":{gridTemplateColumns:"28px repeat(3, 185px)",overflow:"auto"}}})}),(0,r.FD)("div",{css:{position:"relative",padding:"8px 0",[v.mq.mobile]:{margin:"0 -12px"}},className:"followup-wrapper",children:[(0,r.FD)("div",{ref:I,css:[{height:52,display:"grid",gridTemplateColumns:"28px 1fr 1fr 1fr",gap:8,position:"relative",padding:"0 8px",[v.mq.mobile]:{gridTemplateColumns:"28px repeat(3, 185px)",overflow:"auto",padding:"0 20px"}}],className:"followup-scroll",onScroll:e=>{let{currentTarget:{scrollLeft:t,clientWidth:n,scrollWidth:r}}=e;return t<=0?void k("left"):Math.floor(t)>=r-n-8?void k("right"):void k(null)},children:[(0,r.FD)(u.Jb,{placement:"top",children:[(0,r.Y)(u.Jb.Trigger,{type:"button",css:b,onClick:()=>{A("click_hide_recommend_questions_chip",{service_detail:"chat",feature_name:"chat"}),d.oR.confirm("설정에서 추천 질문을 다시 켤 수 있어요",void 0,"확인"),F({enableSuggestions:!1})},children:(0,r.Y)(g.N,{width:16,height:16})}),(0,r.Y)(u.Jb.Content,{css:{fontWeight:500},children:"추천 질문 끄기"})]}),(0,r.Y)(a.T3,{delay:1e3,children:D.map((e,t)=>(0,r.FD)(u.Jb,{clipping:!0,placement:"top",children:[(0,r.Y)(u.Jb.Trigger,{asChild:!0,children:(0,r.Y)("button",{css:[v.OB,{padding:"6px 8px",backgroundColor:(0,p.V)("surface_secondary"),borderRadius:12,display:"inline-flex",alignItems:"flex-start"}],onClick:()=>(e=>{A("click_recommend_questions_chip",{service_detail:"chat",feature_name:"chat",chip_type:"recommend_chip",chip_name:e,chat_id:n}),x({type:"text",message:e})})(e),children:(0,r.Y)(h.Z,{as:"span",typo:"Text6",color:"text_primary",lineClamp:2,ellipsis:!0,"data-clipping":!0,children:e})})}),(0,r.Y)(u.Jb.Content,{css:{fontSize:12},children:e})]},t))})]}),(0,r.Y)("button",{type:"button",css:[_,{left:8}],className:"scroll-button ".concat(w&&"right"!==w?"":"show"),onClick:()=>{var e;null==(e=I.current)||e.scroll({left:0,behavior:"smooth"})},children:(0,r.Y)(m.a,{width:16,height:16})}),(0,r.Y)("button",{type:"button",css:[_,{right:8}],className:"scroll-button ".concat(w&&"left"!==w?"":"show"),onClick:()=>{let e=I.current;e&&e.scroll({left:e.scrollWidth-e.clientWidth,behavior:"smooth"})},children:(0,r.Y)(f.T,{width:16,height:16})})]})]})},b=(0,i.AH)(v.OB,v.tR,{width:28,height:28,backgroundColor:(0,p.V)("surface_secondary"),borderRadius:999,alignSelf:"center"}),_=(0,i.AH)(v.OB,v.tR,{display:"none",width:28,height:28,backgroundColor:(0,p.V)("surface_elevated"),border:"1px solid ".concat((0,p.V)("outline_primary")),borderRadius:999,position:"absolute",top:"50%",transform:"translateY(-50%)",svg:{fill:(0,p.V)("icon_tertiary")},transition:"opacity 0.2s ease-in-out",opacity:0,pointerEvents:"none","&.show":{opacity:1,pointerEvents:"all"},[v.mq.mobile]:{display:"flex"}})},47427:(e,t,n)=>{n.d(t,{R:()=>iy});var r,l,i,a,o,s,c,d,u,p,h=n(36868),g=n(53239),m=n(61844),f=n(10709),v=n(25495),y=n(20033),x=n(27645),b=n(12903),_=n(48253),Y=n(94539);let w=e=>(0,_.v)(e),k=e=>{let{chatId:t,cursor:n}=e;return Y.FA.default.get("/v1/churn/".concat(t,"/messages"),{params:{limit:20,cursor:n}})},C=()=>({key:w,fetcher:k}),A=e=>
1["v1","counseling","chat",e,"messages"],F=e=>{let{chatId:t,cursor:n}=e;return Y.FA.default.get("/v1/counseling/chat/".concat(t,"/messages"),{params:{limit:20,cursor:n}})};var I=n(23380),D=n(7109);let S=e=>(0,D.$)(e),R=e=>{let{chatId:t,cursor:n}=e;return Y.FA.default.get("/v1/interest-talks/".concat(t,"/messages"),{params:{limit:20,cursor:n}})};var M=n(34568);let T=e=>{let{children:t,messages:n,isLoading:r,isFetchingNextPage:l,fetchNextPage:i,hasNextPage:a}=(e=>{let{chatId:t,children:n}=e,{isAuth:r}=(0,y.A)(),{data:l,isLoading:i}=(0,x.m)({chatId:t}),{data:a,fetchNextPage:o,hasNextPage:s,isFetchingNextPage:c,isLoading:d}=(0,M.H)({chatId:t,skip:i||(null==l?void 0:l.type)!=="chat"||!r}),{data:u,isFetchingNextPage:p,fetchNextPage:h,hasNextPage:m,isLoading:f}=(e=>{let{chatId:t,skip:n}=e,{fetcher:r,key:l}={key:S,fetcher:R};return(0,b.q)({queryKey:l(t),queryFn:e=>{let{pageParam:n=""}=e;return r({chatId:t,cursor:n})},initialPageParam:"",retry:!1,getNextPageParam:e=>{var t;return null!=(t=null==e?void 0:e.nextCursor)?t:void 0},enabled:!n})})({chatId:t,skip:!r||i||(null==l?void 0:l.type)!=="interest-talk"}),{data:v,isFetchingNextPage:_,fetchNextPage:Y,hasNextPage:w,isLoading:k}=(e=>{let{chatId:t,skip:n}=e,{fetcher:r,key:l}={key:A,fetcher:F};return(0,b.q)({queryKey:l(t),queryFn:e=>{let{pageParam:n=""}=e;return r({chatId:t,cursor:n})},initialPageParam:"",retry:!1,getNextPageParam:e=>{var t;return null!=(t=null==e?void 0:e.nextCursor)?t:void 0},enabled:!n})})({chatId:t,skip:!r||i||(null==l?void 0:l.type)!=="counseling"}),{data:D,isFetchingNextPage:T,fetchNextPage:E,hasNextPage:j,isLoading:z}=(e=>{let{chatId:t,skip:n}=e;return(0,b.q)({...(0,I.OEk)({path:{chatId:t}}),initialPageParam:"",retry:!1,getNextPageParam:e=>{var t;return null!=(t=null==e?void 0:e.nextCursor)?t:void 0},enabled:!n})})({chatId:t,skip:!r||i||(null==l?void 0:l.type)!=="gmail-briefing"}),{data:B,isFetchingNextPage:L,fetchNextPage:H,hasNextPage:P,isLoading:q}=(e=>{let{chatId:t,skip:n}=e,{fetcher:r,key:l}=C();return(0,b.q)({queryKey:l(t),queryFn:e=>{let{pageParam:n=""}=e;return r({chatId:t,cursor:n})},initialPageParam:"",retry:!1,getNextPageParam:e=>{var t;return null!=(t=null==e?void 0:e.nextCursor)?t:void 0},enabled:!n})})({chatId:t,skip:i||(null==l?void 0:l.type)!=="churn"||!r}),Z=(0,g.useMemo)(()=>{var e,t,n,r,i,o,s,c,d,p,h,g,m,f,y,x,b,_,Y,w;switch(null==l?void 0:l.type){case"interest-talk":return null!=(r=null==u||null==(n=u.pages)||null==(t=n.flatMap)||null==(e=t.call(n,e=>e.list))?void 0:e.reverse())?r:[];case"counseling":return null!=(c=null==v||null==(o=(s=v.pages).flatMap)||null==(i=o.call(s,e=>e.list))?void 0:i.reverse())?c:[];case"churn":return null!=(g=null==B||null==(h=B.pages)||null==(p=h.flatMap)||null==(d=p.call(h,e=>e.list))?void 0:d.reverse())?g:[];case"gmail-briefing":return null!=(x=null==D||null==(y=D.pages)||null==(f=y.flatMap)||null==(m
1=f.call(y,e=>e.list))?void 0:m.reverse())?x:[];default:return null!=(w=null==a||null==(Y=a.pages)||null==(_=Y.flatMap)||null==(b=_.call(Y,e=>e.list))?void 0:b.reverse())?w:[]}},[null==l?void 0:l.type,null==B?void 0:B.pages,null==v?void 0:v.pages,null==u?void 0:u.pages,null==a?void 0:a.pages,null==D?void 0:D.pages]),N=(0,g.useMemo)(()=>{if(i)return!1;switch(null==l?void 0:l.type){case"interest-talk":return m;case"counseling":return w;case"churn":return P;case"gmail-briefing":return j;default:return s}},[null==l?void 0:l.type,P,w,m,i,s,j]),O=(0,g.useMemo)(()=>{if(i)return!1;switch(null==l?void 0:l.type){case"interest-talk":return p;case"counseling":return _;case"churn":return L;case"gmail-briefing":return T;default:return c}},[i,null==l?void 0:l.type,p,_,L,c,T]);return{messages:Z,hasNextPage:N,isFetchingNextPage:O,fetchNextPage:(0,g.useMemo)(()=>{if(i)return()=>Promise.resolve();switch(null==l?void 0:l.type){case"interest-talk":return h;case"counseling":return Y;case"churn":return H;case"gmail-briefing":return E;default:return o}},[i,null==l?void 0:l.type,h,Y,H,o,E]),isLoading:(0,g.useMemo)(()=>d||f||k||q||i||z,[d,f,k,q,i,z]),children:n}})(e);return t({messageList:n,isLoading:r,loadMore:(0,g.useCallback)(async()=>{a&&!l&&await i()},[a,l,i]),hasNextPage:a})};var E=n(98424),j=n(97220),z=n(64297),B=n(93957),L=n(12693),H=n(37185),P=n(21339),q=n(68645),Z=n(86739),N=n(54065),O=n(48533),K=n(65072),V=n(66760),W=n(54924),Q=n(95633),$=n(71357),U=n(22897),X=n(76440),G=n(34616),J=n(13037);let ee=e=>{let{chatId:t}=e,n=(0,G.jE)();return{getPreviousMessage:e=>{var r,l;let i=n.getQueryData((0,J.p)(t));if(!i)return;let a=null==i||null==(l=i.pages)||null==(r=l.flatMap(e=>e.list))?void 0:r.reverse(),o=null==a?void 0:a.findIndex(t=>t.id===e);if(-1!==o&&0!==o)return null==a?void 0:a[o-1]}}},et=e=>{let{assistantMessage:t}=e,{getPreviousMessage:n}=ee({chatId:t.chatId}),{generate:r}=(0,X.d)(),{deleteMessage:l}=(e=>{let{chatId:t}=e,n=(0,G.jE)();return{deleteMessage:(0,g.useCallback)(e=>{n.setQueryData((0,J.p)(t),t=>{if(!t)return t;let n=t.pages.map(t=>({...t,list:t.list.filter(t=>t.id!==e)}));return{...t,pages:n}})},[t,n])}})({chatId:t.chatId});return{reGenerateMessage:()=>{let e=n(t.id);if(e){let n=e.content,i=n.text,a=n.type,o=[],s=[];"file"===a&&(s=(0,U.A)([...n.originalAttachmentIds,...n.referenceAttachmentIds])),"image"===a&&(o=[...o,...n.originalAttachmentIds]),l(t.id),r({type:a,message:i,reroll:!0,toolId:"paraphrase"===e.content.type?e.content.toolId:void 0,toolReferenceId:"paraphrase"===e.content.type?e.content.toolReferenceId:void 0,originalAttachmentIds:o.length?o:void 0,referenceAttachmentIds:s.length?s:void 0})}}}};function en(){let e=(0,Z._)(["\n              flex-shrink: 0;\n            "]);return en=function(){return e},e}let er=e=>{let{isLastMessage:t,reGenerateMessage:n}=(e=>{var t;let{assistantMessage:n}=e,{reGenerateMessage:r}=et({assistantMessage:n}),l=(0,Q.Xr)(W.M),{getLastMessage:i}=(0,$.V)({chatId:n.chatId});return{isLastMessage:(null==(t=i())?void 0:t.id)===n.id,reGenerateMessage:()=>{l({message:"",attachments:void 0,toolAttachment:void 0}),r()}}})(e);return(0,h.Y)(P.t,{p:"8px",width:"100%",border:"1px solid",borderColor:"error_3",backgroundColor:"error_1",borderRadius:"12px",children:(0,h.FD)(H.zt,{justifyContent:"space-between",alignItems:"center",gap:"4px",children:[(0,h.FD)(H.zt,{gap:"4px",children:[(0,h.Y)(K.X,{fill:"error_3",width:"16px",height:"16px"}),(0,h.Y)(N.Z,{typo:"Body6",ellipsis:!0,lineClamp:1,children:"일시적인 오류가 발생했어요"})]}),t&&(0,h.Y)(P.t,{css:(0,m.AH)(en()),children:(0,h.Y)(O.$,{onClick:n,p:"4px 8px",typo:"Body7",backgroundColor:"surface_primary_invert",color:"text_primary_inverted",right:(0,h.Y)(V.s,{fill:"icon_primary_invert"}),children:"다시 시도"})})]})})},el="_assistant-message",ei="_focus-message",ea="_assistant-message_content";var eo=n(12279),es=n(64208),ec=n(14634),ed=n(34223);function eu(){let{flag:e}=(0,es._P)("supporter-role"),{chatId:t}=(0,ed.P)(),{data:n}=(0,eo.I)({...(0,I.Uyz)({path:{chatId:t}})});return e&&(null==n?void 0:n.supporterRole)?(0,h.Y)(P.t,{py:"2px",px:"8px",borderRadius:"9999px",backgroundColor:"surface_secondary",children:(0,h.FD)(H.zt,{gap:"4px",alignItems:"center",children:[(0,h.Y)(ec.a,{width:12,height:12,backgroundColor:"icon_tertiary",css:{mask:"url(".concat(n.supporterRole.iconUrl,") no-repeat center / contain")}}),(0,h.Y)(N.Z,{typo:"Text7",color:"text_secondary",children:n.supporterRole.name})]})}):null}var ep=n(49624),eh=n(55158);let eg=()=>{var e,t,n,r,l,i;let{isAuth:a}=(0,y.A)(),{supporterData:o}=(0,ep.$)(),{supporterData:s}=(0,eh.z)(),c=(0,g.useMemo)(()=>{var e,t,n,r;return a?null==o||null==(t=o.skin)||null==(e=t.source)?void 0:e.thumbnail:null==s||null==(r=s.skin)||null==(n=r.source)?void 0:n.thumbnail},[null==s||null==(t=s.skin)||null==(e=t.source)?void 0:e.thumbnail,a,null==o||null==(r=o.skin)||null==(n=r.source)?void 0:n.thumbnail]),d=null==o||null==(i=o.face)||null==(l=i.source)?void 0:l.origin;return(0,h.FD)(h.FK,{children:[(0,h.Y)(m.mL,{styles:(0,m.AH)({[".".concat(q.D," .supp
1orter-image")]:{transform:"none"}})}),(0,h.FD)(P.t,{width:"32px",height:"32px",borderRadius:"8px",backgroundColor:"background_elevated_70p",overflow:"hidden",position:"relative",className:"supporter-image",css:(0,m.AH)({flexShrink:0,transform:"translateY(-6px)",[v.mq.mobile]:{transform:"none"}}),children:[c&&(0,h.Y)("img",{width:"100%",height:"100%",src:c,alt:"supporterProfile",style:{display:"block",borderRadius:"50%",overflow:"hidden"}}),d&&(0,h.Y)("img",{width:"100%",height:"100%",src:d,alt:"face profile image",style:{position:"absolute",top:0,left:0}})]})]})},em=()=>{var e;let{supporterData:t}=(0,ep.$)(),n=null!=(e=null==t?void 0:t.name)?e:"뤼튼";return(0,h.Y)(N.Z,{typo:"Body6",color:"text_secondary",children:n})};function ef(e){var t;let{assistantMessage:n,children:r}=e;return(0,h.FD)(H.zt,{justifyContent:"flex-start",alignItems:"flex-start",width:"100%",flexShrink:0,className:el,"data-message-id":n.id,children:[(0,h.Y)(m.mL,{styles:(0,m.AH)({[".".concat(q.D)]:{[".".concat(ea)]:[(0,v.Cz)(0),(0,v.qQ)(8),{flexDirection:"column"}],".AssistantMessageDefaultLayout_supporter-name-mobile":{display:"flex"},".AssistantMessageDefaultLayout_supporter-name":{display:"none"}}})}),(0,h.FD)("div",{css:[(0,v.Cz)(8),{display:"flex",alignItems:"flex-start",width:"100%",[v.mq.mobile]:[(0,v.Cz)(0),(0,v.qQ)(8),{flexDirection:"column"}]}],className:ea,children:[(0,h.FD)("div",{css:[v.XF,(0,v.Cz)(8),{alignItems:"center"}],children:[(0,h.Y)(eg,{}),(0,h.Y)(ev,{className:"AssistantMessageDefaultLayout_supporter-name-mobile",css:{display:"none",[v.mq.mobile]:{display:"flex"}}})]}),(0,h.FD)(H.Tk,{gap:"4px",width:"100%",flex:1,children:[(0,h.Y)(ev,{className:"AssistantMessageDefaultLayout_supporter-name",css:{display:"flex",[v.mq.mobile]:{display:"none"}}}),(null==(t=n.error)?void 0:t.message)?(0,h.Y)(er,{assistantMessage:n}):r]})]})]})}let ev=e=>(0,h.FD)("div",{...e,css:[v.XF,(0,v.Cz)(4),{alignItems:"center"}],children:[(0,h.Y)(em,{}),(0,h.Y)(eu,{})]});var ey=n(21778),ex=n(87328),eb=n(77336),e_=n(58082),eY=n(5358),ew=n(48352),ek=n(74685);let{attributes:eC}=e_.j,eA={...e_.j,attributes:{...eC,a:[...null!=(r=null==eC?void 0:eC.a)?r:[],"dataLinkCard","dataFavicon"],div:[...null!=(l=null==eC?void 0:eC.div)?l:[],["className","math","math-display"]],span:[...null!=(i=null==eC?void 0:eC.span)?i:[],["className","math","math-inline"],"dataBrokenLink"],code:[...null!=(a=null==eC?void 0:eC.code)?a:[],["className",/^language-./,"math-inline","math-display"]]}},eF=[[ew.A,{singleTilde:!1}],ek.A],eI=[eb.A,[eY.A,eA],ex.A];var eD=n(6053),eS=n(37352);let eR=e=>{let{children:t,containerElement:n="p"}=e,r=e=>"string"==typeof e?(0,eS.DE)(e).map((e,t)=>(0,h.Y)("span",{className:"animate",children:e},"".concat(t,"-streaming"))):(0,g.isValidElement)(e)?"ul"===e.type||"ol"===e.type?e:(0,g.cloneElement)(e,{...e.props,className:(0,eD.cx)(e.props.className,"animate")},e.props.children):Array.isArray(e)?e.map((e,t)=>(0,h.Y)(g.Fragment,{children:r(e)},t)):null;return(0,g.createElement)(n,{},r(t))},eM=(0,g.memo)(e=>{let{children:t}=e;return(0,h.Y)(eR,{containerElement:"p",children:t})});eM.displayName="StreamingParagraph";let eT=(0,g.memo)(e=>{let{children:t}=e;return(0,h.Y)(eR,{containerElement:"li",children:t})});eT.displayName="StreamingListItem";let eE=(0,g.memo)(e=>{let{children:t}=e;return(0,h.Y)(eR,{containerElement:"td",children:t})});eE.displayName="StreamingTableCell";let ej=(0,g.memo)(e=>{let{children:t}=e;return(0,h.Y)(eR,{containerElement:"h1",children:t})});ej.displayName="StreamingHeading1";let ez=(0,g.memo)(e=>{let{children:t}=e;return(0,h.Y)(eR,{containerElement:"h2",children:t})});ez.displayName="StreamingHeading2";let eB=(0,g.memo)(e=>{let{children:t}=e;return(0,h.Y)(eR,{containerElement:"h3",children:t})});eB.displayName="StreamingHeading3";let eL=(0,g.memo)(e=>{let{children:t}=e;return(0,h.Y)(eR,{containerElement:"h4",children:t})});eL.displayName="StreamingHeading4";let eH=(0,g.memo)(e=>{let{children:t}=e;return(0,h.Y)(eR,{containerElement:"h5",children:t})});eH.displayName="StreamingHeading5";var eP=n(29506),eq=n(75531),eZ=n(74292),eN=n(9912);let eO=/(\[$|\[[^\]]+$|\[[^\]]+\]$|\[[^\]]+\]\(.*$)/,eK=e=>{let t=e.lastIndexOf("\n");return e.slice(t+1)},eV=new Set(["paragraph","listItem","tableCell"]),eW=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=null;if(eV.has(e.type)&&"children"in e){let l=e.children;for(let i=l.length-1;i>=0;i--){let a=l[i];
1if("text"===a.type&&eO.test(eK(a.value))){r={node:e,parent:t,index:n,textNode:a,textIndex:i};break}}}if("table"===e.type&&"children"in e){let t=e.children;if(t.length>0){let e=t[t.length-1];if("children"in e){let t=e.children;if(t.length>0){let n=eW(t[t.length-1],e,t.length-1);n&&(r=n)}}}}if("children"in e){let t=e.children;for(let n=t.length-1;n>=0;n--){let l=eW(t[n],e,n);if(l){r=l;break}}}return r};var eQ=n(70715),e$=n(8843),eU=n(71342),eX=n(32875),eG=n(49569),eJ=n(24422),e0=n(6253),e1=n(11872),e2=n(79980),e4=n(37584),e3=n(32320),e8=n(33798),e6=n(68769),e5=n(24024),e7=n(99177),e9=n(30395),te=n(90277),tt=n(28531),tn=n(49107),tr=n(13299),tl=n(93048),ti=n(67793),ta=n(52024),to=n(68226),ts=n(88366),tc=n(72847),td=n(83279),tu=n(80082),tp=n(19485),th=n(17951),tg=n(24046),tm=n(66797),tf=n(91366),tv=n(90690),ty=n(63205),tx=n(22563),tb=n(87659),t_=n(24853),tY=n(57867),tw=n(23879),tk=n(90876),tC=n(77565),tA=n(23998),tF=n(92992),tI=n(85826),tD=n(33252),tS=n(79308);let tR={apache:eG.A,armasm:eJ.A,bash:e0.A,c:e1.A,coffeescript:e2.A,cpp:e4.A,csharp:e3.A,css:e8.A,d:e6.A,diff:e5.A,go:e7.A,handlebars:e9.A,haskell:te.A,http:tt.A,ini:tn.A,java:tr.A,javascript:tl.A,json:ti.A,julia:ta.A,kotlin:to.A,less:ts.A,lua:tc.A,makefile:td.A,markdown:tu.A,nginx:tp.A,objectivec:th.A,perl:tg.A,php:tm.A,plaintext:tf.A,properties:tv.A,python:ty.A,r:tx.A,ruby:tb.A,rust:t_.A,scala:tY.A,scss:tw.A,shell:tk.A,sql:tC.A,swift:tA.A,typescript:tF.A,x86asm:tI.A,xml:tD.A,yaml:tS.A,jsx:tl.A,tsx:tF.A},tM=new Set,tT=e=>{let{children:t,language:n,onClickCode:r}=e,[,l]=(0,g.useState)(!n);return(0,g.useEffect)(()=>{let e=async()=>{if(n){if(tR[n]){var e;let t=null!=(e=tR[n])?e:tR.plaintext;eU.A.registerLanguage(n,t),l(!0)}else l(!1);tM.add(n)}};n&&(tM.has(n)||e())},[n]),(0,h.FD)(ec.a,{width:"100%",borderRadius:"8px",overflow:"hidden",mt:"4px",mb:"12px",children:[(0,h.Y)(ec.a,{backgroundColor:"surface_tertiary",p:"6px 12px 6px 16px",children:(0,h.FD)(H.zt,{justifyContent:"space-between",alignItems:"center",children:[(0,h.Y)(N.Z,{typo:"Body7",color:"text_tertiary",children:n}),(0,h.Y)(eQ.K,{icon:(0,h.Y)(e$.Q,{}),size:"small",buttonStyle:"ghost",onClick:e=>(e=>{var t,n,l,i;let a=null!=(i=null==(l=e.currentTarget.parentElement)||null==(n=l.parentElement)||null==(t=n.nextElementSibling)?void 0:t.textContent)?i:"";window.navigator.clipboard.writeText(a),null==r||r()})(e)})]})}),(0,h.Y)(eU.A,{wrapLongLines:!0,language:n,style:eX.A,highlighter:"hljs",customStyle:{width:"100%",whiteSpace:"pre-wrap",padding:"10px 16px"},children:t})]})},tE=e=>{let{isStreaming:t,output:n,componentOverrides:r,remarkPlugins:l,rehypePlugins:i,onCodeCopyClick:a,...o}=e,s=function(e,t){let n=(0,g.useState)(()=>({inputs:t,result:e()}))[0],r=(0,g.useRef)(!0),l=(0,g.useRef)(n),i=r.current||t&&l.current.inputs&&function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(t,l.current.inputs)?l.current:{inputs:t,result:e()};return(0,g.useEffect)(()=>{r.current=!1,l.current=i},[i]),i.result}(()=>{if(!n)return[];let e=n.replace(/,?\s?\[\[\d+\]\]([^(])/g,"$1");return(e=>{let{markdown:t,isStreaming:n}=e,r=(0,eP.Y)(t,{extensions:[(0,eN.x)()],mdastExtensions:[(0,eq.c)()]});return n&&(e=>{if(0===e.children.length)return;let t=eW(e);t&&(e=>{var t;let{node:n,textNode:r,textIndex:l,parent:i,index:a}=e,o=r.value,s=eO.exec(o),c=null!=(t=null==s?void 0:s.index)?t:-1,[,d]=null!=s?s:["",""],u={type:"html",value:'<span data-broken-link="'.concat(encodeURIComponent(d),'" />')};if(c>0)r.value=o.slice(0,c),"children"in n&&n.children.splice(l+1,1,u);else if("children"in n){let e=n.children;e.splice(l,1,u),0===e.length&&i&&"children"in i&&i.children.splice(a,1)}})(t)})(r),(e=>{let t=[],n=[],r=()=>{if(n.length>0){let e,r=(e={type:"root",children:n},(0,eZ.l)(e,{extensions:[(0,eq.d)()]})).trim();r&&t.push({type:"text",content:r}),n=[]}};for(let l of e.children)"code"===l.type?(r(),t.push({type:"code",content:l.value,language:l.lang||void 0})):n.push(l);return r(),t})(r)})({markdown:e=e.replace(/\[\[(\d+)\]\]/g,"[".concat("【","$1").concat("】","]")),isStreaming:!!t})},[n,t]),c=(e=>{let{componentOverrides:t,isStreaming:n}=e;return(0,g.useMemo)(()=>{let e=n?{p:eM,li:eT,td:eE,h1:ej,h2:ez,h3:eB,h4:eL,h5:eH}:{};return t?t(e):e},[t,n])})({componentOverrides:r,isStreaming:t});return(0,h.Y)("div",{style:{width:"100%"},children:s.map((e,t)=>"code"===e.type?(0,h.Y)(tT,{language:e.language,onClickCode:a,children:e.content},"".concat(t,":code")):(0,h.Y)("div",{className:"chat-markdown",children:(0,h.Y)(ey.oz,{remarkPlugins:null!=l?l:eF,rehypePlugins:null!=i?i:eI,components:c,...o,children:e.content})},"".concat(t,":text")))})};var tj=n(19334);let tz=e=>{let[t,n]=(0,g.useState)(""),{on:r,off:l}=(0,tj.t)(),{messageQueue:i}=(0,B.q)();return(0,g.useEffect)(()=>{r("generateMessage",e=>{let{content:{text:t}}=e;null==i||i.addMessage(t)}),r("refreshOutput",()=>{null==i||i.reset(),n("")})},[i]),(0,g.useEffect)(()=>{i&&i.on("message",e=>{n(e)})},[i]),(0,h.Y)(tE,{...e,output:t,isStreaming:!0})};var tB=n(70925),tL=n(1378);let tH=new RegExp("".concat("【","(\\d+)").concat("】"));function tP(e){return e&&"text"===e.type&&tH.test(e.value)}function tq(e){var t;let n=null==e||null==(t=e.children)?void 0:t[0];return e&&"link"===e.type&&n&&(null==n?void 0:n.type)==="text"&&tH.test(null==n?void 0:n.value)}var tZ=n(18151),tN=n(5603),tO=n.n(tN),tK=n(62205),tV=n(67707),tW=n(19278),tQ=n(70488),t$=n(81590);function tU(){let e=(0,Z._)(["\n              &:hover {\n                color: ",";\n              }\n            "]);return tU=function(){return e},e}let tX=e=>{var t;let{result:n}=e,{theme:r}=(0,t$.Z)(),{trackEvent:l}=(0,L.jt)(),i=(0,f.H)();return(0,h.Y)(ec.a,{width:292,className:"not-chat-markdown",padding:"10px 12px",backgroundColor:"surface_elevated",borderRadius:"12px",borderWidth:1,borderStyle:"solid",borderColor:"outline_primary",style:{boxShadow:"0px 0px 15px 0px #0000001A"},children:(0,h.FD)(H.Tk,{gap:"4px",children:[(0,h.FD)(H.zt,{gap:"4px",alignItems:"center",children:[(0,h.Y)(tQ.d,{size:16,url:null!=(t=n.favicon)?t:""}),(0,h.Y)(N.Z,{as:"span",typo:"Body7",color:"text_secondary",children:n.source})]}),(0,h.Y)(tO(),{href:n.link,target:"_blank",rel:"noopener noreferrer",onClick:()=>{l("click_search_source_chip",{service_type:"companion",service_detail:"chat",feature_name:i?"minichat":"chat",source_type:"website"})},children:(0,h.Y)(N.Z,{as:"span",typo:"Body7",color:"text_primary",ellipsis:!0,lineClamp:2,css:(0,m.AH)(tU(),r.color.accent_ui),children:n.title})})]})})},tG=e=>{let{order:t="\\00a0",item:n,disabled:r,onMouseEnter:l,onMouseLeave:i,onClick:a}=e,[o,s]=(0,g.useState)(!1),{refs:c,floatingStyles:d,context:u}=(0,tK.we)({placement:"top",open:o,onOpenChange:s,middleware:[(0,tV.cY)(8),(0,tV.BN)()],whileElementsMounted:tW.ll}),p=(0,tK.Mk)(u,{mouseOnly:!0,handleClose:(0,tK.iB)()}),m=(0,tK.iQ)(u),f=(0,tK.s9)(u),v=(0,tK.It)(u,{role:"tooltip"}),{getReferenceProps:y,getFloatingProps:x}=(0,tK.bv)([p,m,f,v]);return(0,h.FD)(h.FK,{children:[(0,h.Y)(tO(),{target:"_blank",rel:"noopener noreferrer",href:n.link,"aria-disabled":r,onMouseEnter:l,onMouseLeave:i,onClick:a,ref:c.setReference,...y(),children:(0,h.Y)(t8,{"data-order":t})}),o&&(0,h.Y)("div",{ref:c.setFloating,style:d,...x(),children:(0,h.Y)("div",{css:t0.tooltip,children:(0,h.Y)(tX,{result:n})})})]})},tJ=(0,m.i7)({"0%":{opacity:0,transform:"scale(0.9)"},"100%":{opacity:1,transform:"scale(1)"}}),t0={tooltip:(0,m.AH)({animation:"".concat(tJ," 0.25s cubic-bezier(0.22, 1, 0.36, 1)")})};function t1(){let e=(0,Z._)(["\n  0% {\n    background-position: 0% 0%;\n  }\n\n  100% {\n    background-position: 200% 0%;\n  }\n"]);return t1=function(){return e},e}function t2(){let e=(0,Z._)(["\n  display: inline-flex;\n  width: 18px;\n  height: 18px;\n  border: 1px solid var(--outline_primary);\n  border-radius: 20px;\n  background-color: var(--surface_elevated);\n  color: var(--accent_ui);\n  justify-content: center;\n  align-items: center;\n  transform: translateY(-1px);\n\n  &.no-link {\n    pointer-events: none;\n    border: 1px solid var(--outline_primary);\n    color: var(--text_quaternary);\n    background: linear-gradient(\n      90deg,\n      var(--surface_secondary) 0%,\n      var(--surface_secondary) 25%,\n      var(--surface_tertiary) 50%,\n      var(--surface_secondary) 75%,\n      var(--surface_secondary) 100%\n    );\n    background-size: 200% 100%;\n    animation: "," 1.5s infinite linear;\n  }\n\n  &:after {\n    display: block;\n    width: fit-content;\n    content: attr(data-order);\n    text-align: center;\n    font-size: 12px;\n    font-family: Pretendard;\n    font-weight: 500;\n    line-height: 150%;\n  }\n"]);return t2=function(){return e},e}let t4=e=>{let{order:t="\\00a0",item:n,link:r,disabled:l}=e,{trackEvent:i}=(0,L.jt)(),a=(0,f.H)(),o=(0,g.useRef)(),s={service_type:"companion",service_detail:"chat",feature_name:a?"minichat":"chat",source_type:"website"},c=()=>{o.current=window.setTimeout(()=>{i("hover_search_source_chip",s)},200)},d=()=>{o.current&&(window.clearTimeout(o.current),o.current=void 0)},u=()=>{i("click_search_source_chip",s)};return l?(0,h.Y)(t8,{"data-order":t,className:"no-link"}):n?(0,h.Y)(tG,{...e,item:n,onMouseEnter:c,onMouseLeave:d,onClick:u}):r?(0,h.Y)(tO(),{target:"_blank",rel:"noopener noreferrer",href:r,"aria-disabled":l,onMouseEnter:c,onMouseLeave:d,onClick:u,className:"not-chat-markdown _citation",children:(0,h.Y)(t8,{"data-order":t})}):(0,h.Y)(t8,{"data-order":t,className:"no-link _citation"})},t3=(0,m.i7)(t1()),t8=tZ.A.span(t2(),t3);var t6=n(13181);let t5=e=>{let{link:t,favicon:n,children:r}=e,l=(0,f.H)(),{trackEvent:i}=(0,L.jt)(),a={service_detail:"chat",feature_name:l?"minichat":"chat",source_type:"BC"};return(0,h.Y)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"not-chat-markdown",css:(0,m.AH)({display:"inline-flex",border:"1px solid",borderRadius:"16px",padding:"2px 4px",backgroundColor:(0,t6.V)("surface_elevated"),borderColor:(0,t6.V)("outline_secondary"),textDecoration:"none",cursor:t?"pointer":"default"}),onClick:()=>{i("click_search_source_chip",a)},children:(0,h.FD)(H.zt,{alignItems:"center",gap:"2px",as:"span",display:"inline-flex",children:[n&&(0,h.Y)("img",{src:n,width:"8px",height:"8px",alt:"favicon",css:(0,m.AH)({margin:0})}),(0,h.Y)(N.Z,{as:"span",typo:"Label5",color:"accent_ui",children:r})]})})},t7=new RegExp("".concat("【","(\\d+)").concat("】"));var t9=n(47219),ne=n(65833),nt=n(65615),nn=n(35977);let nr=(0,nt.tG)("wrtn2_show_thinking_bubbles",(0,nn.X)("wrtn2_show_thinking_bubbles",!0));function nl(){let e=(0,Z._)(["\n  display: flex;\n  justify-content: center;\n  align-items: center;\n  width: 26px;\n  height: 6px;\n  gap: 4px;\n\n  div {\n    width: 6px;\n    height: 6px;\n    border-radius: 50%;\n    background-color: ",";\n    opacity: 1;\n    animation: "," 0.6s infinite alternate;\n  }\n\n  div:nth-of-type(2) {\n    animation-delay: 0.2s;\n  }\n\n  div:nth-of-type(3) {\n    margin-right: 0px;\n    animation-delay: 0.4s;\n  }\n"]);return nl=function(){return e},e}
1nr.debugLabel="@/src/shared/web2/utils-web2-atoms/isShowThinkingBubblesAtom";let ni=()=>(0,h.FD)(no,{children:[(0,h.Y)("div",{}),(0,h.Y)("div",{}),(0,h.Y)("div",{})]}),na=(0,m.i7)({to:{opacity:.1,transform:"translateY(-6px)"}}),no=tZ.A.div(nl(),(0,t6.V)("text_quaternary"),na),ns=e=>{let{children:t,style:n,delay:r,icon:l,iconType:i="general",...a}=e;return(0,h.Y)(nc,{viewport:{once:!0},initial:{y:5,opacity:0,scale:.9},whileInView:{y:0,opacity:1,scale:1},transition:{type:"spring",stiffness:1e3,damping:40,mass:1,duration:.25,delay:r},style:n,...a,children:(0,h.FD)(h.FK,{children:[l&&"string"==typeof l?(0,h.Y)(nd,{style:{backgroundImage:'url("'.concat(l,'")'),..."general"===i?{backgroundColor:"transparent",border:"none"}:{borderRadius:999}}}):null,t]})})},nc=(0,tZ.A)(ne.P.div)({minWidth:50,minHeight:36,marginRight:"4px",padding:"6px 12px",borderRadius:"16px",backgroundColor:(0,t6.V)("surface_secondary"),"&:last-of-type":{marginRight:0}}),nd=tZ.A.span({display:"inline-block",verticalAlign:"text-top",width:18,height:18,marginRight:4,border:"1px solid ".concat((0,t6.V)("outline_primary")),backgroundSize:"contain"}),nu=e=>{let{generateStepSocketEventName:t="generateStep",generateMessageSocketEventName:n="generateMessage"}=e,[r,l]=(0,g.useState)([]),[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(!1),c=(0,g.useRef)(0),{on:d,off:u}=(0,tj.t)(),p=(0,f.H)(),{trackEvent:m}=(0,L.jt)(),v=(0,Q.md)(nr),y={service_type:"companion",service_detail:"chat",feature_name:p?"minichat":"chat",source_type:"website"};return((0,g.useEffect)(()=>{m("expose_chat_thinking_bubble",{...y,index:0})},[]),(0,g.useEffect)(()=>{let e=()=>{a(!0),u(n,e)};return d(n,e),()=>{u(n,e)}},[n]),(0,g.useEffect)(()=>{if(!1===v)return;let e=e=>{var t,n;let{message:r}=e,i="icon"in e?e.icon:null,a="links"in e&&null!=(n=null==(t=e.links)?void 0:t.slice(0,3))?n:[],o=++c.current;m("expose_chat_thinking_bubble",{...y,index:o}),l(e=>[...e,(0,h.FD)("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 4px"},children:[(0,h.Y)(ns,{icon:i,iconType:"general",children:(0,h.Y)(N.Z,{as:"span",typo:"Text4",color:"text_quaternary",children:r})},"base"),null==a?void 0:a.map((e,t)=>(0,h.Y)(tO(),{href:e.url,target:"_blank",rel:"noopener noreferrer",children:(0,h.Y)(ns,{icon:e.favicon,iconType:"link",delay:(t+1)*.1,children:(0,h.Y)(N.Z,{as:"span",typo:"Text4",color:"text_quaternary",children:e.title})})},"link:".concat(t)))]},"msg-".concat(o))])};return d(t,e),()=>{u(t,e)}},[t,v]),o)?null:(0,h.Y)(t9.N,{children:i?null:(0,h.FD)(ne.P.div,{...np,onAnimationComplete:()=>{s(!0)},children:[r,(0,h.Y)(ns,{...nh,children:(0,h.Y)(ni,{})},"loader")]})})},np={initial:{height:"auto"},exit:{position:"absolute",height:0},transition:{duration:.1,ease:"easeIn"},style:{overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"start",alignItems:"start",gap:"8px"}},nh={layout:"position",initial:!1,transition:{type:"spring",stiffness:1e3,damping:40,mass:1,duration:.2},style:{display:"flex",alignItems:"center",justifyContent:"center"}};function ng(){let e=(0,Z._)(["\n        ._citation + ._citation {\n          margin-left: 2px;\n        }\n      "]);return ng=function(){return e},e}let nm=e=>{let{assistantMessage:t,isLast:n}=e,{status:r,content:{text:l}}=t,i=(e=>{let{assistantMessage:t}=e;return(0,g.useCallback)(e=>({a:n=>{let{children:r,href:l}=n,i=Array.isArray(r)?r[0]:r;if("true"===n["data-link-card"]){let e=n["data-favicon"];return(0,h.Y)(t5,{link:l,favicon:e,children:i})}if("string"==typeof i){var a,o;let[,e]=null!=(a=i.match(t7))?a:[];if(e){let n=Number(e)-1,r=null==t||null==(o=t.webSearchResults)?void 0:o[n];return(0,h.Y)(t4,{link:l,order:e,item:r})}}return"function"==typeof(null==e?void 0:e.a)?(0,h.Y)(e.a,{...n}):(0,h.Y)("a",{target:"_blank",rel:"noreferrer noopener",...n})},span:e=>{if("data-broken-link"in e){let n=e["data-broken-link"];if(n){var t;let[,e]=null!=(t=decodeURIComponent(n).match(t7))?t:[];if(e)return(0,h.Y)(t4,{order:e,disabled:!0})}}return(0,h.Y)("span",{...e})}}),[null==t?void 0:t.webSearchResults])})({assistantMessage:t}),{messageQueue:a}=(0,B.q)(),o=!!a;return(0,h.Y)(H.Tk,{gap:"8px",alignItems:"flex-start",position:"relative",css:(0,m.AH)(ng()),children:n&&"cancel"!==r&&"error"!==r&&o&&("streaming"===r||o||"end"===r&&o)?(0,h.FD)(h.FK,{children:[(0,h.Y)(nu,{}),(0,h.Y)(tz,{componentOverrides:i,remarkPlugins:nf})]}):(0,h.Y)(tE,{output:l,componentOverrides:i,remarkPlugins:nf})})},nf=[...eF,()=>e=>{(0,tB.YR)(e,(e,t,n)=>{if(n&&"number"==typeof t&&n.children&&"text"===e.type&&", "===e.value){let e=n.children,r=e[t-1],l=e[t+1],i=tP(r)||tq(r),a=tP(l)||tq(l);if(i&&a)return e.splice(t,1),[tL._Z,t]}})}];var nv=n(48247),ny=n(69471),nx=n(48154),nb=n(63216);function n_(){let e=(0,Z._)(["\n                  &:first-of-type {\n                    padding-top: 0;\n                  }\n\n                  &:last-child {\n                    border-bottom: none;\n                  }\n                "]);return n_=function(){return e},e}let nY=e=>{let{sourceData:t}=(e=>{let{assistantMessage:t}=e;return{sourceData:t.fileSearchResults}})(e);return(null==t?void 0:t.length)?(0,h.Y)(nv.Y,{renderOpener:e=>{let{openModal:t}=e;return(0,h.Y)(ny.o,{onClick:t,children:(0,h.Y)(P.t,{width:"fit-content",backgroundColor:"surface_elevated",p:"6px 12px",borderRadius:"12px",border:"1px solid",borderColor:"outline_primary",position:"relative",children:(0,h.FD)(H.zt,{gap:"4px",alignItems:"center",children:[(0,h.Y)(nx.f,{width:"16px",height:"16px"}),(0,h.Y)(N.Z,{typo:"Body6",children:"답변 출처"})]})})})},renderContent:e=>{let{closeModal:n}=e;return(0,h.FD)(P.t,{width:["100%","100%","100%","537px"],height:"508px",borderRadius:"12px",border:"1px solid",borderColor:"outline_primary",boxShadow:"shadow_soft",backgroundColor:"background_elevated",position:"relative",overflowY:"auto",children:[(0,h.Y)(ec.a,{width:"40px",height:"4px",backgroundColor:"icon_quaternary",borderRadius:"40px",m:"8px auto",display:["block","block","block","none","none"]}),(0,h.FD)(H.zt,{justifyContent:"space-between",alignItems:"center",p:"12px 20px",position:"sticky",top:0,backgroundColor:"background_elevated",children:[(0,h.Y)(N.Z,{typo:"Subtitle4",children:"답변 출처"}),(0,h.Y)(P.t,{display:["none","none","none","flex","flex"],children:(0,h.Y)(eQ.K,{icon:(0,h.Y)(nb.N,{}),onClick:n})})]}),(0,h.Y)(H.Tk,{gap:"8px",height:"100%",p:"12px 20px",children:null==t?void 0:t.map((e,t)=>(0,h.Y)(P.t,{borderBottom:"1px solid",borderColor:"outline_secondary",pb:"12px",pt:"8px",css:(0,m.AH)(n_()),children:(0,h.FD)(H.Tk,{gap:"4px",children:[(0,h.Y)(N.Z,{typo:"Body7",color:"text_secondary",ellipsis:!0,lineClamp:1,children:e.snippet}),(0,h.Y)(N.Z,{typo:"Body6",ellipsis:!0,lineClamp:3,children:e.content})]})},t))})]})}}):null};var nw=n(13145);function nk(e){return void 0!==e.role}var nC=n(85135);let nA=e=>{let{tooltipText:t,children:n}=e;return(0,h.Y)(nC.m,{delay:0,renderContent:()=>(0,h.Y)(P.t,{p:"3px 7px",backgroundColor:"surface_primary_inverted",border:"1px solid",borderColor:"outline_secondary",borderRadius:"3px",children:(0,h.Y)(N.Z,{typo:"Body6",color:"text_primary_inverted",children:t})}),position:"bottom",children:n})},nF=e=>{let{copyMessage:t}=(e=>{let{assistantMessage:t}=e,{trackEvent:n}=(0,L.jt)(),r=nk(t),{data:l}=(0,eo.I)({...(0,I.Uyz)({path:{chatId:t.chatId}}),enabled:!1}),i="commerce-product-v1"===t.content.type?t.content.name:t.content.text,a=r?t.webSearchResults:[],{sendAirbridgeEvent:o}=(0,nw.rT)();return{copyMessage:()=>{var e;let r="";if(i&&(r=i.replace(/\[\[(.+?)\]\]\((.+?)\)/g,"[$1]")),null==a?void 0:a.length){let e=a.map((e,t)=>{let{source:n,title:r,link:l}=e;return r||l?"[".concat(t+1,"]").concat(n?" ".concat(n):"").concat(r?" - ".concat(r):"").concat(l?" (".concat(l,")"):""):null}
1).filter(Boolean).join("\n");r="".concat(r," \n\n참고 자료 \n\n").concat(e)}n("click_function_btn",{service_detail:"chat",feature_name:"chat",button_type:"copy",msg_id:t.id,chat_id:t.chatId,role_name:null==l||null==(e=l.supporterRole)?void 0:e.role}),o("click_function_btn",{customAttributes:{service_detail:"chat",feature_name:"chat",button_type:"copy",msg_id:t.id,chat_id:t.chatId}}),r&&window.navigator.clipboard.writeText(r)}}})(e);return(0,h.Y)(nA,{tooltipText:"복사하기",children:(0,h.Y)(eQ.K,{icon:(0,h.Y)(e$.Q,{width:"14px",height:"14px"}),size:"xs",buttonStyle:"ghost",onClick:t})})},nI=e=>{let{date:t}=e,n=(0,E.Yq)(new Date(t),"a h:mm");return(0,h.Y)(P.t,{display:"flex",flexShrink:0,children:(0,h.Y)(N.Z,{typo:"Text7",color:"text_tertiary",children:n})})},nD=e=>["/v1/chats/".concat(e.chatId,"/messages/").concat(e.messageId)],nS=e=>{let{chatId:t,messageId:n,reaction:r}=e;return Y.FA.default.put("/v1/chats/".concat(t,"/messages/").concat(n),{reaction:r})},nR=()=>({key:nD,fetcher:nS});var nM=n(59717);let nT=e=>{var t;let{assistantMessage:n,queryKey:r,mutationKey:l,mutationFn:i,extractMessages:a,updateMessages:o}=e,[s,c]=(0,g.useState)(null!=(t=n.reaction)?t:null),[d,u]=(0,g.useState)(!1),p=(0,G.jE)(),{trackEvent:h}=(0,L.jt)(),{sendAirbridgeEvent:m}=(0,nw.rT)(),{mutateAsync:f,isPending:v}=(0,nM.n)({mutationKey:l({chatId:n.chatId,messageId:n.id}),mutationFn:i}),y=async e=>{let t=e===s?null:e,l=r(n.chatId),i=p.getQueryData(l);c(t),h("click_emotion_btn",{service_detail:"chat",feature_name:"chat",chat_id:n.chatId,msg_id:n.id,button_type:t}),m("click_emotion_btn",{customAttributes:{service_detail:"chat",feature_name:"chat",chat_id:n.chatId,msg_id:n.id,button_type:t}}),p.setQueryData(l,e=>{if(!e)return e;let r=o(a(e),n.id,t);return{...e,list:r}});try{await f({chatId:n.chatId,messageId:n.id,reaction:t})}catch(e){var d;throw p.setQueryData(l,i),c(null!=(d=n.reaction)?d:null),e}};return{reaction:s,toggleReaction:y,isLoading:v,setOpenedReactionBar:u,openedReactionBar:d}},nE=["heart","check","sad","like","dislike"];var nj=n(1223),nz=n(22097),nB=n(94206);let nL=e=>{switch(e.reaction){case"heart":return(0,h.Y)("img",{src:"https://fe-web-assets.static.wrtn.ai/wrtn2/chat/emotion_love.svg",alt:"emotion_love"});case"check":return(0,h.Y)("img",{src:"https://fe-web-assets.static.wrtn.ai/wrtn2/chat/emotion_check.svg",alt:"emotion_check"});case"sad":return(0,h.Y)("img",{src:"https://fe-web-assets.static.wrtn.ai/wrtn2/chat/emotion_sad.svg",alt:"emotion_sad"});case"like":return(0,h.Y)("img",{src:"https://fe-web-assets.static.wrtn.ai/wrtn2/chat/emotion_good.svg",alt:"emotion_good"});case"dislike":return(0,h.Y)("img",{src:"https://fe-web-assets.static.wrtn.ai/wrtn2/chat/emotion_bad.svg",alt:"emotion_bad"});default:return(0,h.Y)(nB.z,{width:"14px",height:"14px"})}},nH=e=>{let{reactionList:t,onClick:n}=e;return(0,h.Y)(H.zt,{gap:"4px",children:t.map(e=>(0,h.Y)(eQ.K,{onClick:()=>n(e),icon:(0,h.Y)(nL,{reaction:e}),size:"xs",buttonStyle:"ghost"},e))})},nP=["heart","check","sad","like","dislike"],nq=e=>{let{opened:t,setOpened:n,toggleReaction:r,reaction:l}=e,i=(0,g.useRef)(null);return(0,j.Ls)(i,"click",()=>{n(!1)}),(0,h.Y)(P.t,{position:"relative",children:(0,h.FD)(nj.Jb,{open:t,placement:"bottom",children:[(0,h.Y)(nj.Jb.Trigger,{children:(0,h.Y)(ny.o,{onClick:()=>n(!t),children:(0,h.Y)(eQ.K,{icon:(0,h.Y)(nL,{reaction:l}),size:"xs",buttonStyle:"ghost"})})}),(0,h.Y)(nj.Jb.Content,{ref:i,css:{backgroundColor:(0,t6.V)("surface_elevated"),borderRadius:"12px",boxShadow:nz.E.dark.shadow_soft,padding:"4px 12px"},children:(0,h.Y)(nH,{reactionList:nP,onClick:e=>{r(e),n(!1)}})})]})})},nZ=e=>{let{toggleReaction:t,reaction:n,setOpenedReactionBar:r,openedReactionBar:l}=(e=>{let{assistantMessage:t}=e,{toggleReaction:n,reaction:r,setOpenedReactionBar:l,openedReactionBar:i,isLoading:a}=nT({assistantMessage:t,queryKey:J.p,mutationKey:nR().key,mutationFn:nR().fetcher,extractMessages:e=>e.pages.flatMap(e=>e.list),updateMessages:(e,t,n)=>e.map(e=>e.id===t?{...e,reaction:n}:e)});return{reaction:r,toggleReaction:n,REACTION_LIST:nE,isLoading:a,setOpenedReactionBar:l,openedReactionBar:i}})(e);return(0,h.Y)(nq,{reaction:n,toggleReaction:t,opened:l,setOpened:e=>r(e)})};var nN=n(13846);function nO(e){let{button:t,onClick:n}=e,r=(0,nN.useRouter)();return(0,h.Y)(O.$,{style:"solid",backgroundColor:"surface_primary_invert",color:"text_primary_inverted",width:"100%",onClick:()=>{null==n||n(),t.webLink&&r.push(t.webLink)},disabled:!t.webLink,children:t.webLink?t.label:"모바일 앱에서 확인해 주세요"})}function nK(e){let{assistantMessage:t,isLast:n,content:r}=e,{messageQueue:l}=(0,B.q)(),{isAuth:i}=(0,y.A)(),a=n&&("end"!==t.status||!!l);return(0,h.FD)(ef,{assistantMessage:t,children:[(0,h.FD)(H.Tk,{gap:"8px",width:"100%",maxWidth:"490px",children:[(0,h.Y)(nm,{assistantMessage:t,isLast:n}),(0,h.Y)(L.Wg,{name:"click_message_btn",properties:{btn_type:r.featureType},children:(0,h.Y)(nO,{button:r.button})})]}),!a&&(0,h.FD)(h.FK,{children:[(0,h.Y)(H.Tk,{gap:"12px",children:(0,h.Y)(nY,{assistantMessage:t})}),(0,h.FD)(H.zt,{gap:"4px",py:"8px",children:[(0,h.Y)(nF,{assistantMessage:t}),i&&(0,h.Y)(nZ,{assistantMessage:t}),(0,h.Y)(P.t,{width:"2px",height:"2px",backgroundColor:"icon_secondary",borderRadius:"100%"}),(0,h.Y)(nI,{date:t.updatedAt})]})]})]})}function nV(e){let{product:t,featureType:n}=e,{brandName:r,bestPrice:l,button:i,image:a,name:o,originalPrice
1:s}=t,c=Math.floor((s-l)/s*100),d=(0,nN.useRouter)(),{data:u,isLoading:p}=(0,eo.I)({...(0,I.eJj)({path:{productId:t.id}})});return(0,h.Y)(P.t,{backgroundColor:"surface_elevated",borderRadius:"12px",p:"12px",width:"100%",maxWidth:"514px",border:"1px solid ".concat((0,t6.V)("outline_primary")),children:(0,h.FD)(H.Tk,{gap:"8px",children:[(0,h.Y)(P.t,{borderRadius:"8px",overflow:"hidden",width:"100%",children:(0,h.Y)(ec.a,{width:"100%",backgroundImage:"url('".concat(a,"')"),backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat",css:{aspectRatio:"16/9"}})}),(0,h.Y)(H.Tk,{gap:"6px",alignItems:"flex-start",width:"100%",children:(0,h.FD)(H.Tk,{gap:"8px",alignItems:"flex-start",width:"100%",children:[(0,h.FD)(H.Tk,{alignItems:"flex-start",width:"100%",children:[(0,h.Y)(N.Z,{typo:"Body7",color:"text_quaternary",children:r}),(0,h.Y)(N.Z,{typo:"Body4",color:"text_primary",children:o})]}),(0,h.FD)(H.zt,{gap:"8px",alignItems:"center",width:"100%",children:[(0,h.FD)(H.zt,{gap:"4px",alignItems:"center",children:[(0,h.FD)(N.Z,{typo:"Subtitle3",color:"function_red_3",children:[c,"%"]}),(0,h.FD)(N.Z,{typo:"Subtitle3",color:"text_primary",children:[l.toLocaleString(),"원"]})]}),(0,h.FD)(N.Z,{typo:"Body6",color:"text_tertiary",textDecoration:"line-through",children:[s.toLocaleString(),"원"]})]})]})}),(0,h.Y)(L.Wg,{name:"click_message_btn",properties:{btn_type:n},children:(0,h.Y)(O.$,{style:"solid",backgroundColor:"surface_primary_invert",color:"text_primary_inverted",width:"100%",onClick:()=>{d.push("/commerce/c/".concat(t.id))},isLoading:p,disabled:(null==u?void 0:u.status)!=="active",children:i.label})})]})})}function nW(e){let{assistantMessage:t,isLast:n,content:r}=e,{messageQueue:l}=(0,B.q)(),{isAuth:i}=(0,y.A)(),a=n&&("end"!==t.status||!!l);return(0,h.FD)(ef,{assistantMessage:t,children:[(0,h.Y)(nm,{assistantMessage:t,isLast:n}),(0,h.Y)(nV,{product:r.product,featureType:r.featureType}),!a&&(0,h.FD)(h.FK,{children:[(0,h.Y)(H.Tk,{gap:"12px",children:(0,h.Y)(nY,{assistantMessage:t})}),(0,h.FD)(H.zt,{gap:"4px",py:"8px",children:[(0,h.Y)(nF,{assistantMessage:t}),i&&(0,h.Y)(nZ,{assistantMessage:t}),(0,h.Y)(P.t,{width:"2px",height:"2px",backgroundColor:"icon_secondary",borderRadius:"100%"}),(0,h.Y)(nI,{date:t.updatedAt})]})]})]})}function nQ(e){let{assistantMessage:t,isLast:n,content:r}=e,{messageQueue:l}=(0,B.q)(),{isAuth:i}=(0,y.A)(),a=n&&("end"!==t.status||!!l);return(0,h.FD)(ef,{assistantMessage:t,children:[(0,h.FD)(H.Tk,{gap:"8px",width:"100%",maxWidth:"490px",children:[(0,h.Y)(ec.a,{width:"100%",backgroundImage:"url('".concat(r.imageUrl,"')"),backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat",borderRadius:"8px",css:{aspectRatio:"16/9"}}),(0,h.Y)(nm,{assistantMessage:t,isLast:n}),(0,h.Y)(L.Wg,{name:"click_message_btn",properties:{btn_type:r.featureType},children:(0,h.Y)(nO,{button:r.button})})]}),!a&&(0,h.FD)(h.FK,{children:[(0,h.Y)(H.Tk,{gap:"12px",children:(0,h.Y)(nY,{assistantMessage:t})}),(0,h.FD)(H.zt,{gap:"4px",py:"8px",children:[(0,h.Y)(nF,{assistantMessage:t}),i&&(0,h.Y)(nZ,{assistantMessage:t}),(0,h.Y)(P.t,{width:"2px",height:"2px",backgroundColor:"icon_secondary",borderRadius:"100%"}),(0,h.Y)(nI,{date:t.updatedAt})]})]})]})}var n$=n(87958),nU=n(63208);let nX=["/v1/bookmark"],nG=async e=>Y.FA.default.post("/v1/bookmark",{...e}),nJ=e=>{let{targetId:t}=e;return Y.FA.default.delete("/v1/bookmark",{params:{targetId:t}})},n0=e=>{let{toggleBookmark:t,isLoading:n,saved:r}=(e=>{let{assistantMessage:t}=e,{key:n,fetcher:r}={key:nX,fetcher:nG},{key:l,fetcher:i}={key:["/v1/bookmark","delete"],fetcher:nJ},a=(0,G.jE)(),{trackEvent:o}=(0,L.jt)(),{sendAirbridgeEvent:s}=(0,nw.rT)(),{mutateAsync:c,isPending:d}=(0,nM.n)({mutationKey:n,mutationFn:r}),{data:u}=(0,eo.I)({...(0,I.Uyz)({path:{chatId:t.chatId}}),enabled:!1}),{mutateAsync:p,isPending:h}=(0,nM.n)({mutationKey:l,mutationFn:i}),g=async()=>{var e;o("click_function_btn",{service_detail:"chat",feature_name:"chat",button_type:"saved",msg_id:t.id,chat_id:t.chatId,role_name:null==u||null==(e=u.supporterRole)?void 0:e.role}),s("click_function_btn",{customAttributes:{service_detail:"chat",feature_name:"chat",button_type:"saved",msg_id:t.id,chat_id:t.chatId}});
1let n=(0,J.p)(t.chatId),r=a.getQueryData(n);a.setQueryData(n,e=>{if(!e)return e;let n=e.pages.map(e=>({...e,list:e.list.map(e=>e.id===t.id&&"assistant"===e.role?{...e,saved:!e.saved}:e)}));return{...e,pages:n}});try{t.saved?await p({targetId:t.id}):await c({category:"chat",contentId:t.id})}catch(e){a.setQueryData(n,r)}};return{saved:t.saved,toggleBookmark:g,isLoading:d||h}})(e);return(0,h.Y)(nA,{tooltipText:"저장하기",children:(0,h.Y)(eQ.K,{onClick:t,disabled:n,icon:r?(0,h.Y)(n$.O,{width:"14px",height:"14px"}):(0,h.Y)(nU.t,{width:"14px",height:"14px"}),size:"xs",buttonStyle:"ghost"})})},n1=e=>{let{reGenMessage:t}=(e=>{let{assistantMessage:t}=e,{reGenerateMessage:n}=et({assistantMessage:t}),{trackEvent:r}=(0,L.jt)(),{sendAirbridgeEvent:l}=(0,nw.rT)(),{data:i}=(0,eo.I)({...(0,I.Uyz)({path:{chatId:t.chatId}}),enabled:!1});return{reGenMessage:()=>{var e;r("click_function_btn",{service_detail:"chat",feature_name:"chat",button_type:"regenerate",msg_id:t.id,chat_id:t.chatId,role_name:null==i||null==(e=i.supporterRole)?void 0:e.role}),l("click_function_btn",{customAttributes:{service_detail:"chat",feature_name:"chat",button_type:"regenerate",msg_id:t.id,chat_id:t.chatId}}),n()}}})(e);return(0,h.Y)(nA,{tooltipText:"다시생성",children:(0,h.Y)(eQ.K,{"data-test-id":"regenerate_btn",icon:(0,h.Y)(V.s,{width:"14px",height:"14px"}),size:"xs",buttonStyle:"ghost",onClick:t})})},n2=e=>{let{assistantMessage:t,isLast:n}=e,{isAuth:r}=(0,y.A)(),{getPreviousMessage:l}=ee({chatId:t.chatId}),i=l(t.id);return(0,h.FD)(H.zt,{gap:"4px",children:[(0,h.Y)(nF,{assistantMessage:t}),r&&(0,h.Y)(n0,{assistantMessage:t}),r&&(0,h.Y)(nZ,{assistantMessage:t}),n&&i&&(0,h.Y)(n1,{assistantMessage:t})]})};var n4=n(44739);function n3(e){let{children:t,favicons:n,onClick:r}=e,l=(0,f.H)();return(0,h.Y)(ny.o,{onClick:r,children:(0,h.Y)(P.t,{width:"fit-content",p:"6px 12px",backgroundColor:"surface_elevated",borderRadius:"999px",border:"1px solid",borderColor:"outline_secondary",flexShrink:0,children:(0,h.FD)(H.zt,{gap:"4px",children:[l||n.length<=0?null:(0,h.Y)(H.zt,{children:n.slice(0,3).map((e,t)=>(0,h.Y)(P.t,{width:"20px",height:"20px",overflow:"hidden",borderRadius:"20px",ml:"-4px",backgroundColor:"surface_elevated",border:"1px solid",borderColor:"outline_primary",children:(0,h.Y)("img",{width:"100%",height:"100%",loading:"lazy",src:null!=e?e:void 0,alt:"favicon-".concat(t)})},"".concat(t,":").concat(e)))}),(0,h.Y)(N.Z,{typo:"Body6",children:t})]})})})}var n8=n(35279),n6=n(51882);function n5(){let e=(0,Z._)(["\n            display: flex;\n            align-items: center;\n            justify-content: center;\n          "]);return n5=function(){return e},e}function n7(){let e=(0,Z._)(["\n  &:hover {\n    p {\n      text-decoration: underline;\n    }\n  }\n"]);return n7=function(){return e},e}let n9=e=>{var t;let{imageSearchResult:n,onClick:r}=e,[l,i]=(0,g.useState)(!1);return(0,h.Y)(ny.o,{onClick:r,children:(0,h.FD)(re,{p:"8px 0",gap:"8px",children:[(0,h.Y)(P.t,{width:"100%",height:"154px",borderRadius:"8px",overflowY:"hidden",css:(0,m.AH)(n5()),backgroundColor:"surface_secondary",children:l?(0,h.Y)(K.X,{width:"32px",height:"32px",fill:"icon_quaternary"}):(0,h.Y)("img",{width:"100%",height:"100%",src:n.thumbnail,alt:n.title,style:{objectFit:"cover"},onError:()=>{i(!0)}})}),(0,h.FD)(H.Tk,{gap:"4px",children:[(0,h.FD)(H.zt,{gap:"4px",alignItems:"center",children:[(0,h.Y)(tQ.d,{size:16,url:null!=(t=n.source_logo)?t:""}),(0,h.Y)(N.Z,{typo:"Body7",color:"text_secondary",ellipsis:!0,lineClamp:1,children:n.source})]}),(0,h.Y)(N.Z,{typo:"Subtitle6",ellipsis:!0,lineClamp:2,children:n.title})]})]})})},re=(0,tZ.A)(H.Tk)(n7()),rt=e=>{let{imageSearchResults:t,selectImage:n}=e;return(0,h.Y)(ec.a,{display:"grid",gridTemplateColumns:["repeat(2, calc(50% - 4px))","repeat(2, calc(50% - 4px))","repeat(2, calc(50% - 4px))","repeat(4, calc(25% - 6px))","repeat(4, calc(25% - 6px))"],gap:"8px",children:t.map((e,t)=>(0,h.Y)(n9,{imageSearchResult:e,onClick:n?()=>n(t):()=>{var t;return t=e.link,void window.open(t,"_blank")}},e.link))})};function rn(){let e=(0,Z._)(["\n            display: flex;\n            justify-content: center;\n            align-items: center;\n          "]);return rn=function(){return e},e}function rr(){let e=(0,Z._)(["\n  &:hover {\n    p {\n      text-decoration: underline;\n    }\n  }\n"]);return rr=function(){return e},e}let rl=e=>{var t,n;let{mainImage:r,onClick:l}=e,i=(0,g.useRef)(null),[a,o]=(0,g.useState)(!1);return(0,h.Y)(ny.o,{onClick:l,children:(0,h.FD)(ri,{gap:"8px",children:[(0,h.Y)(P.t,{width:"100%",css:(0,m.AH)(rn()),backgroundColor:"surface_secondary",maxWidth:"576px",height:"423px",borderRadius:"8px",overflow:"hidden",children:a?(0,h.FD)(H.Tk,{gap:"14px",alignItems:"center",children:[(0,h.Y)(K.X,{width:"56px",height:"56px",fill:"icon_quaternary"}),(0,h.FD)(N.Z,{typo:"Body6",color:"text_quaternary",textAlign:"center",children:["일시적인 오류로 이미지를 ",(0,h.Y)("br",{})," 불러오지 못했어요"]})]}):(0,h.Y)("img",{ref:i,src:null!=(t=r.original)?t:"",width:"100%",height:"100%",alt:"".concat(r.title),style:{objectFit:"cover"},onError:()=>{i.current&&r.thumbnail?i.current.src=r.thumbnail:o(!0)}},r.original)}),(0,h.FD)(H.Tk,{gap:"4px",children:[(0,h.FD)(H.zt,{gap:"4px",alignItems:"center",children:[(0,h.Y)(tQ.d,{size:14,url:null!=(n=r.source_logo)?n:""}),(0,h.Y)(N.Z,{typo:"Body7",color:"text_secondary",ellipsis:!0,lineClamp:1,children:r.source})]}),(0,h.Y)(N.Z,{typo:"Subtitle6",ellipsis:!0,lineClamp:2,children:r.title})]})]})})},ri=(0,tZ.A)(H.Tk)(rr()),ra=e=>{let{images:t,select:n,mainImage:r,openPage:l}=(e=>{let{scrollRef:t,imageSearchResults:n}=e,r=(0,g.useMemo)(()=>null!=n?n:[],[n]),[l,i]=(0,g.useState)(r[0]);return{mainImage:l,images:r,select:e=>{var n;i(r[e]),null==(n=t.current)||n.scrollTo({top:0})},openPage:()=>{window.open(l.link,"_blank")}}})(e),{trackEvent:i}=(0,L.jt)(),{chatId:a}=(0,n6.W)();return(0,g.useEffect)(()=>{i("view_detailed_search_source_image",{chat_id:a,service_detail:"chat",feature_name:"chat",source_type:"image",button_type:"detailed_search_source_image_btn"})},[]),(0,h.FD)(H.Tk,{p:"0 20px 12px",gap:"8px",children:[(0,h.Y)(rl,{mainImage:r,onClick:l},r.original),(0,h.Y)(P.t,{width:"100%",height:"1px",backgroundColor:"outline_primary"}),(0,h.Y)(rt,{imageSearchResults:t,selectImage:n})]})};var ro=n(27349);let rs=e=>{let{webSearchList:t}=e;return(0,h.Y)(H.Tk,{children:t.map((e,t)=>(0,h.Y)(ro.Z,{webSearchResult:e},"".concat(t,"}").concat(e.link)))})};var rc=n(37874),rd=n(30881);let ru=e=>{let{title:t,renderList:n,renderBottom:r}=e;return(0,h.FD)(H.Tk,{children:[t&&(0,h.Y)(H.zt,{width:"100%",justifyContent:"space-between",alignItems:"center",backgroundColor:"surface_elevated",top:0,py:"12px 8px",children:(0,h.Y)(N.Z,{typo:"Subtitle4",children:t})}),n,(0,h.Y)(rd.h,{height:"8px"}),r,(0,h.Y)(rd.h,{height:"12px"})]})};function rp(){let e=(0,Z._)(["\n  &:hover {\n    p {\n      text-decoration: underline;\n    }\n  }\n"]);return rp=function(){return e},e}let rh=e=>{let{videoSearchResult:t,select:n}=e;return(0,h.Y)(H.Tk,{gap:"8px",py:"8px",children:t.map((e,t)=>{var r;return(0,h.Y)(ny.o,{onClick:()=>null==n?void 0:n(t),children:(0,h.FD)(rg,{gap:"10px",alignItems:"flex-start",children:[(0,h.Y)(P.t,{width:"184px",height:"104px",overflow:"hidden",borderRadius:"8px",flexShrink:0,children:(0,h.Y)("img",{width:"100%",height:"100%",src:null!=(r=e.thumbnail)?r:"",alt:"video-search-thumbn
1ail",style:{objectFit:"cover"}})}),(0,h.FD)(H.Tk,{gap:"4px",children:[(0,h.Y)(N.Z,{typo:"Subtitle6",ellipsis:!0,lineClamp:1,children:e.title}),(0,h.FD)(N.Z,{typo:"Body7",color:"text_secondary",ellipsis:!0,lineClamp:1,children:[e.snippet," \xb7 ",e.channel]}),(0,h.FD)(N.Z,{typo:"Body7",color:"text_secondary",ellipsis:!0,lineClamp:1,children:[e.date," \xb7 ",e.views]})]})]})},e.link)})})},rg=(0,tZ.A)(H.zt)(rp()),rm=e=>{var t,n,r,l,i,a,o,s,c;let{searchResult:d,moveToImageDetail:u,selectVideoDetail:p}=(e=>{let{changeSelectedDetail:t,scrollRef:n,searchResult:r}=e;return{searchResult:r,moveToImageDetail:()=>{var e;t({category:"image",index:0}),null==n||null==(e=n.current)||e.scrollTo({top:0})},selectVideoDetail:e=>{var r;t({category:"video",index:e.index}),null==n||null==(r=n.current)||r.scrollTo({top:0})}}})(e),{trackEvent:g}=(0,L.jt)(),{chatId:m}=(0,n6.W)(),f={service_detail:"chat",feature_name:"chat",source_type:[(null==d||null==(t=d.imageSearchResults)?void 0:t.length)?"image":void 0,(null==d||null==(n=d.videoSearchResults)?void 0:n.length)?"video":void 0,(null==d||null==(r=d.webSearchResults)?void 0:r.length)?"website":void 0].filter(Boolean).join(", ")};return(0,h.FD)(H.Tk,{p:"0 20px 12px",children:[!!(null==d||null==(l=d.webSearchResults)?void 0:l.length)&&(0,h.Y)(ru,{renderList:(0,h.Y)(rs,{webSearchList:null!=(o=null==d?void 0:d.webSearchResults)?o:[]})}),!!(null==d||null==(i=d.imageSearchResults)?void 0:i.length)&&(0,h.Y)(ru,{title:"이미지",renderList:(0,h.Y)(rt,{imageSearchResults:null!=(s=null==d?void 0:d.imageSearchResults.slice(0,4))?s:[]}),renderBottom:(0,h.Y)(H.zt,{justifyContent:"center",children:(0,h.Y)(O.$,{onClick:()=>{g("click_search_source_image_more_btn",{...f,chat_id:m,button_type:"search_source_image_more_btn"}),u()},width:"fit-content",p:"8px 20px",borderColor:"outline_primary",border:"1px solid",borderRadius:"300px",backgroundColor:"surface_elevated",typo:"Subtitle6",style:"line",right:(0,h.Y)(rc.m,{width:"16px",height:"16px"}),children:"이미지 더 보기"})})}),!!(null==d||null==(a=d.videoSearchResults)?void 0:a.length)&&(0,h.Y)(ru,{title:"동영상",renderList:(0,h.Y)(rh,{videoSearchResult:null!=(c=null==d?void 0:d.videoSearchResults.slice(0,3))?c:[],select:e=>{p({index:e})}})})]})},rf=e=>{let{children:t}=e,[n,r]=(0,g.useState)();return t({selectedDetail:n,changeSelectedDetail:e=>{r(e)},clearSelectedDetail:()=>{r(void 0)}})};var rv=n(70021);let ry=e=>{var t,n,r;let{mainVideo:l}=e,[i,a]=(0,g.useState)("loading"),{trackEvent:o}=(0,L.jt)(),s=null!=(r=null==l||null==(n=l.link)||null==(t=n.split("v="))?void 0:t[1])?r:"";return((0,g.useEffect)(()=>{s&&a("loading")},[s]),s)?"error"===i?(0,h.Y)("div",{css:[{width:"100%",aspectRatio:"16/9",position:"relative",backgroundColor:"black"},l.thumbnail&&{background:"url(".concat(l.thumbnail,")"),backgroundColor:"black",backgroundSize:"contain",backgroundRepeat:"no-repeat",backgroundPosition:"center center"}],children:(0,h.Y)("div",{css:[v.tR,{position:"absolute",top:0,right:0,bottom:0,left:0,backgroundColor:(0,t6.V)("dim_primary")}],children:(0,h.FD)(H.Tk,{width:"100%",height:"100%",justifyContent:"center",alignItems:"center",gap:"20px",children:[(0,h.Y)(N.Z,{typo:"Subtitle4",color:"text_white",children:"이 동영상은 유튜브에서 볼 수 있어요"}),(0,h.Y)(O.$,{onClick:()=>{o("click_search_source_video_watch_btn",{service_detail:"chat",feature_name:"chat",source_type:"video",button_type:"search_source_video_watch_btn"}),window.open(l.link,"_blank")},border:"none",p:"0 16px 0 20px",width:"fit-content",height:"36px",typo:"Subtitle6",color:"text_white",backgroundColor:"tint_accent_primary",right:(0,h.Y)(rc.m,{width:"16px",height:"16px",fill:"icon_white"}),children:"보러가기"})]})})}):(0,h.Y)("div",{css:{".youtube-player-wrapper":[v.tR,{width:"100%",aspectRatio:"16/9",visibility:"ready"===i?"visible":"hidden",position:"relative",backgroundColor:"black"}],".youtube-player-frame":{width:"100%",height:"100%",objectFit:"contain",border:"none"}},children:(0,h.Y)(rv.A,{videoId:s,className:"youtube-player-wrapper",iframeClassName:"youtube-player-frame",onReady:()=>a("ready"),onError:()=>a("error")})}):null},rx=e=>{let{mainVideo:t,videoList:n,select:r}=(e=>{let{scrollRef:t,videoSearchResults:n}=e,r=(0,g.useMemo)(()=>null!=n?n:[],[n]),{trackEvent:l}=(0,L.jt)(),{chatId:i}=(0,n6.W)(),[a,o]=(0,g.useState)(r[0]),s={chat_id:i,service_detail:"chat",feature_name:"chat",source_type:"video"};return(0,g.useEffect)(()=>
1{l("view_detailed_search_source_video",{...s})},[]),{mainVideo:a,videoList:r,select:e=>{l("click_search_source_video_btn",{button_type:"detailed_search_source_image_btn",source_type:"video",index:e}),o(r[e]),(null==t?void 0:t.current)&&t.current.scrollTo({top:0})}}})(e);return(0,h.FD)(H.Tk,{gap:"4px",children:[(0,h.FD)(H.Tk,{gap:"8px",children:[(0,h.Y)(ry,{mainVideo:t}),(0,h.FD)(H.Tk,{gap:"4px",px:"20px",children:[(0,h.Y)(N.Z,{typo:"Subtitle6",ellipsis:!0,lineClamp:1,children:t.title}),(0,h.FD)(N.Z,{typo:"Body7",color:"text_secondary",ellipsis:!0,lineClamp:1,children:[t.snippet," \xb7 ",t.channel]}),(0,h.FD)(N.Z,{typo:"Body7",color:"text_secondary",ellipsis:!0,lineClamp:1,children:[t.date," \xb7 ",t.views]})]})]}),(0,h.Y)(H.Tk,{p:"0 20px 12px",children:(0,h.Y)(rh,{videoSearchResult:n,select:r})})]})},rb=e=>{let{close:t,searchResult:n}=e,r=(0,g.useRef)(null);return(0,h.Y)(n8.Y,{ref:r,children:(0,h.Y)(H.Tk,{width:"100%",height:"100%",children:(0,h.Y)(rf,{children:e=>{let{selectedDetail:l,changeSelectedDetail:i,clearSelectedDetail:a}=e;return l?(0,h.FD)(h.FK,{children:["image"===l.category&&(0,h.FD)(h.FK,{children:[(0,h.Y)(n8.Y.Header,{title:"이미지",renderPreviousButton:(0,h.Y)(n8.Y.Header.Back,{onClick:a}),renderCloseButton:(0,h.Y)(n8.Y.Header.Close,{onClick:t})}),(0,h.Y)(ra,{scrollRef:r,imageSearchResults:n.imageSearchResults})]}),"video"===l.category&&(0,h.FD)(h.FK,{children:[(0,h.Y)(n8.Y.Header,{title:"동영상",renderPreviousButton:(0,h.Y)(n8.Y.Header.Back,{onClick:a}),renderCloseButton:(0,h.Y)(n8.Y.Header.Close,{onClick:t})}),(0,h.Y)(rx,{scrollRef:r,videoSearchResults:n.videoSearchResults})]})]}):(0,h.FD)(h.FK,{children:[(0,h.Y)(n8.Y.Header,{title:"답변 출처",renderCloseButton:(0,h.Y)(n8.Y.Header.Close,{onClick:t})}),(0,h.Y)(rm,{scrollRef:r,changeSelectedDetail:i,searchResult:n})]})}})})})},r_=e=>{var t,n,r,l,i,a,o,s,c;let{assistantMessage:d}=e,{open:u}=(0,n4.R)(),p=(0,f.H)(),{trackEvent:m}=(0,L.jt)(),v={webSearchResults:"webSearchResults"in d&&null!=(o=null==d?void 0:d.webSearchResults)?o:[],imageSearchResults:"imageSearchResults"in d&&null!=(s=null==d?void 0:d.imageSearchResults)?s:[],videoSearchResults:"videoSearchResults"in d&&null!=(c=null==d?void 0:d.videoSearchResults)?c:[]},y={service_detail:"chat",feature_name:"chat",source_type:[(null==v||null==(t=v.imageSearchResults)?void 0:t.length)?"image":void 0,(null==v||null==(n=v.videoSearchResults)?void 0:n.length)?"video":void 0,(null==v||null==(r=v.webSearchResults)?void 0:r.length)?"website":void 0].filter(Boolean).join(", ")},x=(0,g.useMemo)(()=>{var e;if(p)return[];let t=null==v||null==(e=v.webSearchResults)?void 0:e.map(e=>null==e?void 0:e.favicon);return(null!=t?t:[]).slice(0,3).filter(e=>!!e)},[p,null==v?void 0:v.webSearchResults]);return(null==(l=v.webSearchResults)?void 0:l.length)||(null==(i=v.imageSearchResults)?void 0:i.length)||(null==(a=v.videoSearchResults)?void 0:a.length)?(0,h.FD)(n3,{favicons:x,onClick:()=>{u(e=>{let{close:t}=e;return(0,h.Y)(rb,{searchResult:v,close:t})}),m("click_search_source",y)},children:[(0,h.Y)(L.L0,{name:"expose_search_source",properties:y,watch:!1}),e.children]}):null};function rY(e){var t,n,r;let{assistantMessage:l,isLast:i}=e,{messageQueue:a}=(0,B.q)(),o=i&&("end"!==l.status||!!a),s=!!(null==(t=l.webSearchResults)?void 0:t.length)||!!(null==(n=l.imageSearchResults)?void 0:n.length)||!!(null==(r=l.videoSearchResults)?void 0:r.length);return(0,h.FD)(ef,{assistantMessage:l,children:[(0,h.Y)(nm,{assistantMessage:l,isLast:i}),!o&&(0,h.FD)(h.FK,{children:[(0,h.Y)(nY,{assistantMessage:l}),(0,h.FD)(H.zt,{gap:"4px",py:"8px",children:[s?(0,h.Y)(r_,{assistantMessage:l,children:"답변 출처"}):null,(0,h.Y)(n2,{assistantMessage:l,isLast:i}),(0,h.Y)(P.t,{width:"2px",height:"2px",backgroundColor:"icon_secondary",borderRadius:"100%"}),(0,h.Y)(nI,{date:l.updatedAt})]})]})]})}var rw=n(87267);function rk(){return(rk=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}let rC=function(e){return g.createElement("svg",rk({xmlns:"http://www.w3.org/2000/svg",fill:"
1currentColor",viewBox:"0 0 24 25"},e),o||(o=g.createElement("path",{fillRule:"evenodd",d:"m7.164 3.582.808 2.827 2.827.808c.193.055.193.33 0 .384l-2.827.808-.808 2.827c-.055.193-.329.193-.384 0l-.808-2.827-2.827-.808c-.193-.055-.193-.329 0-.384l2.827-.808.808-2.827c.055-.193.329-.193.384 0m7.28 4.164a.473.473 0 0 0-.887 0l-1.612 4.356a.47.47 0 0 1-.28.28L7.31 13.994a.473.473 0 0 0 0 .886l4.357 1.612c.129.048.23.15.279.28l1.612 4.357a.473.473 0 0 0 .886 0l1.612-4.358a.47.47 0 0 1 .28-.279l4.357-1.612a.473.473 0 0 0 0-.886l-4.358-1.612a.47.47 0 0 1-.279-.28z",clipRule:"evenodd"})))},rA=e=>{var t;let{width:n="24px",height:r="24px",...l}=e;return(0,h.Y)(rC,{width:n,height:r,...l,...(0,rw.u$)()({fill:null!=(t=null==l?void 0:l.fill)?t:"icon_primary"})})};function rF(){let e=(0,Z._)(["\n                  justify-content: center;\n                  align-items: center;\n                "]);return rF=function(){return e},e}let rI=e=>{let{tools:t,messageId:n}=e,{push:r}=(0,z.rd)(),{trackEvent:l}=(0,L.jt)(),{chatId:i}=(0,n6.W)();return(0,h.Y)(H.Tk,{children:t.map((e,a)=>(0,h.Y)(ny.o,{onClick:()=>((e,a)=>{l("click_tool_recommendation_btn",{service_detail:"chat",feature_name:"chat",button_type:"도구 제안",tool_index:a,tool_count:t.length,tool_id:e,chat_id:i,msg_id:n}),r("/tools/".concat(e))})(e.toolId,a),children:(0,h.Y)(P.t,{width:"100%",p:"8px 12px",children:(0,h.FD)(H.zt,{gap:"12px",alignItems:"start",children:[(0,h.Y)(P.t,{width:"50px",height:"50px",p:"11px",backgroundColor:"surface_secondary",borderRadius:"12px",display:"flex",css:(0,m.AH)(rF()),children:(0,h.Y)("img",{src:e.lightIcon,width:"28px",height:"28px",alt:"".concat(e.title,"-icon")})}),(0,h.FD)(H.Tk,{gap:"2px",children:[(0,h.Y)(N.Z,{typo:"Subtitle4",children:e.title}),(0,h.Y)(N.Z,{typo:"Body6",color:"text_tertiary",children:e.description})]})]})})},e.toolId))})},rD=e=>{let{tools:t,messageId:n,moveToToolHome:r}=(e=>{let{assistantMessage:t}=e,{push:n}=(0,z.rd)(),{trackEvent:r}=(0,L.jt)(),l="tool_recommendation"===t.content.type?t.content.tools:[],i={service_detail:"chat",feature_name:"chat",msg_id:t.id,tool_count:l.length,chat_id:t.chatId};return(0,g.useEffect)(()=>{l.length&&r("expose_tool_recommendation",{...i})},[l]),{messageId:t.id,tools:l,moveToToolHome:()=>{r("click_tool_recommendation_more_btn",{...i}),n("/tools")}}})(e);return t.length?(0,h.FD)(P.t,{width:"100%",borderRadius:"12px",backgroundColor:"surface_elevated",overflow:"hidden",border:"1px solid",borderColor:"outline_primary",children:[(0,h.Y)(P.t,{width:"100%",p:"8px 12px",backgroundColor:"surface_secondary",children:(0,h.FD)(H.zt,{justifyContent:"space-between",alignItems:"center",children:[(0,h.FD)(H.zt,{gap:"4px",children:[(0,h.Y)(rA,{width:"20px",height:"20px"}),(0,h.Y)(N.Z,{typo:"Body6",color:"text_secondary",children:"도구 제안"})]}),(0,h.Y)(ny.o,{onClick:r,children:(0,h.FD)(H.zt,{gap:"4px",alignItems:"center",children:[(0,h.Y)(N.Z,{typo:["Body7","Body7","Body6","Body6","Body6"],color:"text_secondary",children:"더보기"}),(0,h.Y)(rc.m,{width:"16px",height:"16px",fill:"icon_secondary"})]})})]})}),(0,h.Y)(rd.h,{height:"4px"}),(0,h.Y)(rI,{tools:t,messageId:n}),(0,h.Y)(rd.h,{height:"4px"})]}):[]};function rS(e){var t,n,r;let{assistantMessage:l,isLast:i}=e,{messageQueue:a}=(0,B.q)(),o=i&&("end"!==l.status||!!a),s=!!(null==(t=l.webSearchResults)?void 0:t.length)||!!(null==(n=l.imageSearchResults)?void 0:n.length)||!!(null==(r=l.videoSearchResults)?void 0:r.length);return(0,h.FD)(ef,{assistantMessage:l,children:[(0,h.Y)(nm,{assistantMessage:l,isLast:i}),!o&&(0,h.FD)(h.FK,{children:[(0,h.FD)(H.Tk,{gap:"12px",children:[(0,h.Y)(rD,{assistantMessage:l}),(0,h.Y)(nY,{assistantMessage:l})]}),(0,h.FD)(H.zt,{gap:"4px",py:"8px",children:[s?(0,h.Y)(r_,{assistantMessage:l,children:"답변 출처"}):null,(0,h.Y)(n2,{assistantMessage:l,isLast:i}),(0,h.Y)(P.t,{width:"2px",height:"2px",backgroundColor:"icon_secondary",borderRadius:"100%"}),(0,h.Y)(nI,{date:l.updatedAt})]})]})]})}function rR(e){let t=e.assistantMessage.content,n=e.assistantMessage.openingContent;if(n)switch(n.type){case"text":return(0,h.Y)(rY,{...e,content:n});case"button":return(0,h.Y)(nK,{...e,content:n});case"image":return(0,h.Y)(nQ,{...e,content:n});case"commerce-product":return(0,h.Y)(nW,{...e,content:n})}switch(t.type){case"text":return(0,h.Y)(rY,{...e,content:t});case"tool_recommendation":return(0,h.Y)(rS,{...e,content:t});default:return console.warn("AssistantContent: unknown content type",t),null}}let rM=e=>(0,h.Y)(rR,{...e});function rT(){let e=(0,Z._)(["\n        white-space: pre-wrap;\n        word-break: break-all;\n        display: block;\n\n        font-weight: 400;\n        font-size: 16px;\n        line-height: 150%;\n      "]);return rT=function(){return e},e}let rE=e=>{let{message:t}=e,n=t.trim();return(0,h.Y)(ec.a,{as:"pre",backgroundColor:"surface_secondary",borderRadius:"16px",p:"6px 12px",maxWidth:["71.4285714%","71.4285714%","71.4285714%","71.4285714%","514px"],width:"auto",flexShrink:0,css:(0,m.AH)(rT()),children:n})};var rj=n(86413),rz=n(60552);function rB(){let e=(0,Z._)(["\n                display: flex;\n                align-items: center;\n                justify-content: center;\n                flex-shrink: 0;\n              "]);return rB=function(){return e},e}let rL=e=>{let{title:t,description:n,icon:r,type:l,onClick:i}=e;return(0,h.Y)(ny.o,{onClick:i,children:(0,h.Y)(P.t,{width:"240px",p:"8px",borderRadius:"12px",backgroundColor:"surface_secondary",border:"1px solid",borderColor:"outline_primary",position:"relative",children:(0,h.Y)(H.zt,{gap:"8px",height:"100%",alignItems:"self-start",justifyContent:"space-between",children:(0,h.FD)(H.zt,{gap:"8px",children:[(0,h.Y)(P.t,{width:"40px",height:"40px",borderRadius:"8px",backgroundColor:"surface_tertiary",css:(0,m.AH)(rB()),children:"file"===l?(0,h.Y)(rj.D,{fill:"icon_tertiary"}):r?(0,h.Y)("img",{width:"24px",height:"24px",src:r,alt:"icon"}):(0,h.Y)(rz.s,{fill:"icon_tertiary"})}),(0,h.FD)(H.Tk,{gap:"2px",children:[(0,h.Y)(N.Z,{typo:"Body6",color:"text_primary",ellipsis:!0,lineClamp:1,children:t}),(0,h.Y)(N.Z,{typo:"Body7",color:"text_primary",ellipsis:!0,lineClamp:1,children:n})]})]})})})})};var rH=n(91365);let rP=e=>{let{files:t,urls:n,openFile:r}=(e=>{let{userMessage:t}=e,{chatId:n}=(0,n6.W)(),{attachments:r}=(0,rH.i)({chatId:null!=n?n:""}),[l,i]=(0,g.useState)([]),[a,o]=(0,g.useState)([]),{trackEvent:s}=(0,L.jt)(),c=(0,g.useMemo)(()=>{var e,n;return"file"===t.content.type&&null!=(n=null==t||null==(e=t.content)?void 0:e.originalAttachmentIds)?n:[]},[t]);return(0,g.useEffect)(()=>{(null==r?void 0:r.length)&&(i(r.filter(e=>"file"===e.type&&c.includes(e.id))),o(r.filter(e=>"url"===e.type&&c.includes(e.id))))},[r,c]),{files:l,urls:a,openFile:e=>{s("click_link_new_tab_btn",{service_detail:"chat",feature_name:"chat",button_type:"",attachment_count:a.length,chat_id:t.chatId,msg_id:t.id}),window.open(e,"_blank")}}})(e);return(0,h.FD)(H.Tk,{gap:"10px",children:[t.map(e=>{let{id:t,title:n,extension:r,type:l}=e;return(0,h.Y)(rL,{title:n,description:r,type:l},t)}),n.map(e=>{let{id:t,title:n,favicon:l,url:i,type:a}=e;return(0,h.Y)(rL,{title:n,description:i,icon:l,type:a,onClick:()=>r(i)},t)})]})};function rq(){let e=(0,Z._)(["\n                  background-image: url(",");\n                  background-size: cover;\n                  background-repeat: no-repeat;\n                "]);return rq=function(){return e},e}let rZ=e=>{let{images:t,trackClickImageEvent:n}=(e=>{let{userMessage:t}=e,{chatId:n}=(0,n6.W)(),{attachments:r}=(0,rH.i)({chatId:null!=n?n:""}),{trackEvent:l}=(0,L.jt)(),i=new Map(("image"===t.content.type?[...t.content.originalAttachmentIds]:[]).map((e,t)=>[e,t]));return{images:r.filter(e=>"image"===e.type&&i.has(e.id)).sort((e,t)=>
1i.get(e.id)-i.get(t.id)),trackClickImageEvent:()=>{l("click_image_attached_zoom",{service_detail:"chat",feature_name:"chat",button_type:"image_attached_zoom_btn",msg_id:t.id,chat_id:t.chatId})}}})(e);return(0,h.Y)(H.zt,{display:"flex",gap:"8px",flexWrap:"wrap",justifyContent:"flex-end",children:t.map(e=>(0,h.Y)(nv.Y,{renderOpener:t=>{let{openModal:r}=t;return(0,h.Y)(ny.o,{onClick:()=>{n(),r()},children:(0,h.Y)(P.t,{width:["96px","96px","96px","96px","200px"],height:["96px","96px","96px","96px","200px"],overflow:"hidden",borderRadius:"20px",css:(0,m.AH)(rq(),e.url)})})},renderContent:t=>{let{closeModal:n}=t;return(0,h.FD)(P.t,{position:"fixed",top:"165px",bottom:"165px",left:"100px",right:"100px",children:[(0,h.Y)(P.t,{position:"fixed",top:"24px",right:"24px",children:(0,h.Y)(ny.o,{onClick:n,children:(0,h.Y)(nb.N,{fill:"icon_white"})})}),(0,h.Y)("img",{width:"100%",height:"100%",src:e.url,style:{objectFit:"contain"},alt:"attachment"})]})}},e.id))})},rN=e=>{let{userMessage:t}=e;return"paraphrase"!==t.content.type?null:(0,h.Y)(P.t,{width:"100%",maxWidth:"240px",height:"56px",p:"8px",borderRadius:"12px",border:"1px solid",borderColor:"outline_primary",backgroundColor:"surface_elevated",children:(0,h.FD)(H.zt,{gap:"8px",height:"100%",children:[(0,h.Y)(P.t,{width:"40px",height:"40px",backgroundColor:"surface_secondary",borderRadius:"8px",p:"9px",children:(0,h.Y)("img",{src:t.content.lightIcon,width:"22px",height:"22px",alt:"tool-icon"})}),(0,h.FD)(H.Tk,{gap:"2px",minWidth:"144px",children:[(0,h.Y)(N.Z,{typo:"Body6",ellipsis:!0,lineClamp:1,children:t.content.title}),(0,h.Y)(N.Z,{typo:"Body7",ellipsis:!0,lineClamp:1,children:t.content.toolName})]})]})})},rO=e=>{let{userMessage:t}=e;switch(t.content.type){case"image":return(0,h.Y)(rZ,{userMessage:t});case"file":return(0,h.Y)(rP,{userMessage:t});case"paraphrase":return(0,h.Y)(rN,{userMessage:t});default:return null}},rK=e=>{let{userMessage:t}=(e=>{let{userMessage:t}=e;return{userMessage:t}})(e);return(0,h.FD)(H.Tk,{gap:"10px",alignItems:"flex-end",width:"100%",children:[(0,h.Y)(rO,{userMessage:t}),(0,h.FD)(H.zt,{gap:"6px",alignItems:"flex-end",justifyContent:"flex-end",children:[(0,h.Y)(nI,{date:t.updatedAt}),(0,h.Y)(rE,{message:t.content.text})]})]})},rV=e=>{let{userMessage:t}=(e=>{let{userMessage:t}=e;return{userMessage:t}})(e);return(0,h.Y)(H.zt,{justifyContent:"flex-end",children:(0,h.Y)(rK,{userMessage:t})})},rW=(0,g.memo)(e=>{let{message:t,isLast:n}=e;switch(t.role){case"user":return(0,h.Y)(rV,{userMessage:t});case"assistant":return(0,h.Y)(rM,{assistantMessage:t,isLast:n});default:return null}},(e,t)=>{let{message:n}=e,{message:r}=t,l=n.id===r.id&&e.isLast===t.isLast;if("status"in n&&"status"in r){var i,a,o,s,c,d,u,p;l&&(l=n.status===r.status&&(null==(i=n.webSearchResults)?void 0:i.length)===(null==(a=r.webSearchResults)?void 0:a.length)&&(null==(o=n.imageSearchResults)?void 0:o.length)===(null==(s=r.imageSearchResults)?void 0:s.length)&&(null==(c=n.videoSearchResults)?void 0:c.length)===(null==(d=r.videoSearchResults)?void 0:d.length)&&(null==(u=n.fileSearchResults)?void 0:u.length)===(null==(p=r.fileSearchResults)?void 0:p.length)&&n.content.type===r.content.type&&n.saved===r.saved),"tool_recommendation"===n.content.type&&"tool_recommendation"===r.content.type&&l&&(l=n.content.tools.join(":")===r.content.tools.join(":"))}return l});rW.displayName="MessageRenderer";var rQ=n(94085),r$=n(82803);let rU=e=>{let{cash:t,closeModal:n}=e,r=(0,g.useRef)(null),l=()=>{setTimeout(()=>{n()},1700)};return(0,g.useEffect)(()=>{let e=r.current;e&&(e.complete?l():e.onload=()=>l())},[]),(0,h.FD)(H.Tk,{alignItems:"center",gap:"17px",children:[(0,h.FD)(H.Tk,{alignItems:"center",children:[(0,h.FD)(H.zt,{gap:"8px",children:[(0,h.Y)(N.Z,{color:"#FFC75F",as:"span",style:{fontSize:60,fontWeight:"800",lineHeight:"140%"},children:null!=t?t:100}),(0,h.Y)(N.Z,{color:"text_white",as:"span",style:{fontSize:32,fontWeight:"800",lineHeight:"140%"},children:"캐시"})]}),(0,h.Y)(N.Z,{color:"text_white",style:{fontSize:27,fontWeight:"600",lineHeight:"140%"},children:"받았어요!"})]}),(0,h.Y)("img",{ref:r,width:"106px",src:"https://fe-web-assets.static.wrtn.ai/wrtn2/common/get_cash.png",alt:"coin"})]})};var rX=n(89498);let rG=e=>{let{chatId:t,messageId:n}=e;return Y.FA.default.put("/v1/churn/".concat(t,"/messages/").concat(n,"/cash"))},rJ=e=>{let{getCash:t,isLoading:n,disabled:r,modalOpened:l,closeModal:i,buttonText:a,cash:o}=(e=>{let{assistantMessage:t}=e,[n,r]=(0,g.useState)(!1),[l,i]=(0,g.useState)(t.content.status),{key:a,fetcher:o}={key:e=>["getChurnUserCash",...Object.values(e)],fetcher:rG},s=(0,G.jE)(),{trackEvent:c}=(0,L.jt)(),{chatId:d,id:u}=t,p=e=>{s.setQueryData((0,_.v)(d),t=>{var n;if(!t)return t;let r=null==t||null==(n=t.pages[0])?void 0:n.list.map(t=>
1t.id===u?{...t,content:{...t.content,status:e}}:t);return{...t,list:r}})},{mutate:h,isPending:m,data:f}=(0,nM.n)({mutationKey:a({chatId:d,messageId:u}),mutationFn:()=>o({chatId:d,messageId:u}),onSuccess:()=>{r(!0),i("received"),p("received")},onError:e=>{if((0,Y.F0)(e)){var t,n,r,l,a;(null==e||null==(t=e.response)?void 0:t.status)!==500&&(null==e||null==(n=e.response)?void 0:n.status)!==404?(rX.oR.alert(null!=(a=null==e||null==(l=e.response)||null==(r=l.data)?void 0:r.message)?a:"캐시 수령에 실패했어요."),i("expired"),p("expired")):rX.oR.alert("캐시 수령에 실패했어요.")}}});return{getCash:()=>{"cash"===t.content.type&&(c("click_churn_message_btn",{btn_type:"cash",feature_name:"churn-message",churnGroupId:t.content.churnGroupId}),h())},closeModal:()=>{r(!1)},modalOpened:n,isLoading:m,disabled:"active"!==l,cash:null!=f?f:0,buttonText:(0,g.useMemo)(()=>"received"===l?"캐시 받기 완료":"캐시 받기",[l])}})(e);return(0,h.Y)(r$.a,{opened:l,backdropFilter:"blur(2px)",renderOpener:()=>(0,h.Y)(O.$,{width:"100%",height:"48px",backgroundColor:"accent_primary",borderRadius:"12px",color:r?"text_placeholder_disable":"text_white",isLoading:n,disabled:r,onClick:t,children:a}),renderContent:()=>(0,h.Y)(rU,{cash:o,closeModal:i})})},r0=e=>["/v1/churn/".concat(e.chatId,"/messages/").concat(e.messageId)],r1=e=>{let{chatId:t,messageId:n,reaction:r}=e;return Y.FA.default.put("/v1/churn/".concat(t,"/messages/").concat(n),{reaction:r})},r2=()=>({key:r0,fetcher:r1}),r4=e=>{let{toggleReaction:t,reaction:n,setOpenedReactionBar:r,openedReactionBar:l}=(e=>{let{assistantMessage:t}=e,{key:n}=C(),{toggleReaction:r,reaction:l,setOpenedReactionBar:i,openedReactionBar:a,isLoading:o}=nT({assistantMessage:t,queryKey:n,mutationKey:r2().key,mutationFn:r2().fetcher,extractMessages:e=>e.pages.flatMap(e=>e.list),updateMessages:(e,t,n)=>e.map(e=>e.id===t?{...e,reaction:n}:e)});return{reaction:l,toggleReaction:r,isLoading:o,setOpenedReactionBar:i,openedReactionBar:a}})(e);return(0,h.Y)(nq,{reaction:n,toggleReaction:t,opened:l,setOpened:e=>r(e)})},r3=e=>{let{coupon:t,closeModal:n}=(e=>{let{coupon:t,closeModal:n}=e;return{coupon:t,closeModal:n}})(e),{trackEvent:r}=(0,L.jt)(),{ref:l,isInView:i}=(0,j.Wx)(!1);return(0,g.useEffect)(()=>{i&&r("view_coupon_detail")},[i]),(0,h.FD)(P.t,{width:["100%","100%","100%","360px","360px"],overflowY:"auto",maxHeight:"445px",backgroundColor:"surface_elevated",borderRadius:"16px",position:"relative",ref:l,children:[(0,h.FD)(H.zt,{pt:"20px",px:"20px",pb:"12px",justifyContent:"space-between",gap:"8px",position:"sticky",top:0,backgroundColor:"surface_elevated",children:[(0,h.Y)(N.Z,{typo:"Title3",children:t.title}),(0,h.Y)(P.t,{position:"absolute",top:"12px",right:"12px",children:(0,h.Y)(eQ.K,{size:"small",icon:(0,h.Y)(nb.N,{width:"20px",height:"20px"}),onClick:n})})]}),(0,h.FD)(H.Tk,{gap:"16px",px:"20px",pb:"26px",children:[(0,h.Y)(P.t,{height:"320px",borderRadius:"12px",border:"1px solid",borderColor:"outline_primary",overflow:"hidden",children:(0,h.Y)("img",{src:t.couponImageUrl,width:"auto",height:"320px",alt:"쿠폰 이미지",style:{objectFit:"contain",display:"block"}})}),(0,h.Y)(N.Z,{typo:"Subtitle4",color:"text_primary",children:t.text})]})]})},r8=e=>{let{type:t,chatId:n,messageId:r}=e;return["getAlarmTalkCoupon",t,n,r]},r6=e=>{let{type:t,messageId:n,chatId:r}=e;return"churn"===t?Y.FA.default.put("/v1/churn/".concat(r,"/messages/").concat(n,"/coupon")):Y.FA.default.put("/v1/interest-talks/".concat(r,"/messages/").concat(n,"/coupon"))},r5=()=>({key:r8,fetcher:r6}),r7=e=>{let{coupon:t,closeModal:n,openedModal:r,openModal:l,isLoading:i,isActive:a}=(e=>{let{chatId:t,messageId:n,type:r,disabled:l}=e,{trackEvent:i}=(0,L.jt)(),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(!l),d=(0,G.jE)(),u="interest-talk"===r?D.$:_.v,{mutate:p,data:h,isPending:m}=(0,nM.n)({mutationKey:r5().key({type:r,messageId:n,chatId:t}),mutationFn:()=>r5().fetcher({type:r,messageId:n,chatId:t}),onSuccess:()=>{o(!0)},onError:e=>{if((0,Y.F0)(e)){var r,l,i,a,o;(null==e||null==(r=e.response)?void 0:r.status)!==500&&(null==e||null==(l=e.response)?void 0:l.status)!==404?(rX.oR.alert(null!=(o=null==e||null==(a=e.response)||null==(i=a.data)?void 0:i.message)?o:"쿠폰 받기에 실패했어요."),d.setQueryData(u(t),e=>{var t;if(!e)return e;let r=null==e||null==(t=e.pages[0])?void 0:t.list.map(e=>e.id===n?{...e,content:{...e.content,status:"expired"}}:e);return{...e,list:r}}
1),c(!1)):rX.oR.alert("일시적으로 쿠폰 받기에 실패했어요. 잠시 후 다시시도 해주세요.")}}});return{coupon:h,isActive:s,isLoading:m,openedModal:a,openModal:()=>{i("click_message_btn",{feature_name:"interest-talk"===r?"coupon":"churn-message",btn_type:"coupon"}),p()},closeModal:()=>{o(!1)}}})(e);return(0,h.Y)(r$.a,{opened:r,onClose:n,renderOpener:()=>(0,h.Y)(O.$,{width:"100%",height:"48px",backgroundColor:"accent_primary",borderRadius:"12px",color:a?"text_white":"text_placeholder_disable",isLoading:i,disabled:!a,onClick:l,children:"쿠폰 받기"}),renderContent:e=>{let{closeModal:n}=e;return(0,h.Y)(h.FK,{children:t?(0,h.Y)(r3,{coupon:t,closeModal:n}):null})}})},r9=e=>{var t,n;let{assistantMessage:r}=(e=>{let{assistantMessage:t}=e;return{assistantMessage:t}})(e);return(0,h.Y)(H.zt,{justifyContent:"flex-start",width:"100%",flexShrink:0,children:(0,h.FD)(H.zt,{gap:"8px",alignItems:"flex-start",width:"100%",children:[(0,h.Y)(eg,{}),(0,h.FD)(H.Tk,{gap:"4px",width:["calc(100% - 36px)","calc(100% - 36px)","100%","100%","100%"],maxWidth:"474px",children:[(0,h.Y)(em,{}),(0,h.Y)(P.t,{borderRadius:"12px",border:"1px solid",borderColor:"outline_primary",backgroundColor:"surface_elevated",overflow:"hidden",children:(0,h.FD)(H.Tk,{p:"12px",gap:"8px",children:[(null==(t=r.content)?void 0:t.image)&&(0,h.Y)("img",{width:"100%",src:r.content.image,alt:"content image",style:{objectFit:"cover",borderRadius:"8px"}}),(null==(n=r.content)?void 0:n.text)&&(0,h.Y)(rQ.o,{content:r.content.text,typo:"Body5",noPaddingBottom:!0}),"cash"===r.content.type&&(0,h.Y)(rJ,{assistantMessage:r}),"giftishow-coupon"===r.content.type&&(0,h.Y)(r7,{chatId:r.chatId,type:"churn",disabled:"expired"===r.content.status,messageId:r.id})]})}),(0,h.FD)(H.zt,{gap:"4px",children:[(0,h.FD)(H.zt,{gap:"4px",children:[(0,h.Y)(nF,{assistantMessage:r}),(0,h.Y)(r4,{assistantMessage:r})]}),(0,h.Y)(P.t,{width:"2px",height:"2px",backgroundColor:"icon_secondary",borderRadius:"100%"}),(0,h.Y)(nI,{date:r.updatedAt})]})]})]})})},le=e=>{let{message:t}=e;return(0,h.Y)(r9,{assistantMessage:t})},lt=()=>(0,h.Y)(H.Tk,{width:"100%",children:(0,h.FD)(N.Z,{typo:"Text7",color:"text_secondary",textAlign:"center",children:["이 내용은 AI가 생성한 참고용 정보이므로, 정확성이나 완전성을 보장하지 않아요.",(0,h.Y)("br",{}),"의료 또는 금융과 관련된 판단은 반드시 전문가와 상담해 주세요."]})});function ln(){let e=(0,Z._)(["\n                ._citation + ._citation {\n                  margin-left: 2px;\n                }\n              "]);return ln=function(){return e},e}let lr=e=>{let{message:t}=e;return"assistant"===t.role?(0,h.Y)(H.zt,{justifyContent:"flex-start",alignItems:"flex-start",width:"100%",flexShrink:0,className:el,"data-message-id":t.id,children:(0,h.FD)(H.zt,{gap:"8px",alignItems:"flex-start",width:"100%",children:[(0,h.Y)(eg,{}),(0,h.FD)(H.Tk,{gap:"4px",width:["calc(100% - 36px)","calc(100% - 36px)","100%","100%","100%"],children:[(0,h.Y)(em,{}),(0,h.Y)(H.Tk,{gap:"8px",alignItems:"flex-start",position:"relative",css:(0,m.AH)(ln()),children:(0,h.Y)(tE,{output:t.content})})]})]})}):(0,h.Y)(H.zt,{alignItems:"flex-end",children:(0,h.Y)(H.Tk,{gap:"10px",alignItems:"flex-end",width:"100%",children:(0,h.Y)(H.zt,{gap:"6px",alignItems:"flex-end",justifyContent:"flex-end",children:(0,h.Y)(rE,{message:t.content})})})})};function ll(){return(ll=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}let li=function(e){return g.createElement("svg",ll({xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 24 24"},e),s||(s=g.createElement("path",{fillRule:"evenodd",d:"M3 19a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5.007a2 2 0 0 0-2-2h-1V1h-2v2.007H8V1H6v2.007H5a2 2 0 0 0-2 2zm16-.007H5V8.963h14zm0-11.971H5V5.014h14zM12 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2m-3-1a1 1 0 1 1-2 0 1 1 0 0 1 2 0m7 1a1 1 0 1 0 0-2 1 1 0 0 0 0 2",clipRule:"evenodd"})))},la=e=>{var t;let{width:n="24px",height:r="24px",...l}=e;return(0,h.Y)(li,{width:n,height:r,...l,...(0,rw.u$)()({fill:null!=(t=null==l?void 0:l.fill)?t:"icon_primary"})})},lo=(0,g.memo)(e=>{let{date:t}
1=e,n=(0,E.Yq)(t,"yyyy년 MM월 dd일");return(0,h.FD)(H.zt,{width:"100%",gap:"10px",justifyContent:"space-between",alignItems:"center",py:"12px",children:[(0,h.Y)(P.t,{width:"100%",height:"1px",backgroundColor:"outline_active"}),(0,h.FD)(H.zt,{alignItems:"center",gap:"4px",p:"2px 8px",flexShrink:0,children:[(0,h.Y)(la,{width:"16px",height:"16px",fill:"icon_secondary"}),(0,h.Y)(N.Z,{typo:"Text7",color:"text_secondary",children:n})]}),(0,h.Y)(P.t,{width:"100%",height:"1px",backgroundColor:"outline_active"})]})});lo.displayName="DateDivider";var ls=n(85204),lc=n(36936);function ld(){return(ld=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}let lu=function(e){return g.createElement("svg",ld({xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 24 24"},e),c||(c=g.createElement("path",{fillRule:"evenodd",d:"M11 1a3 3 0 0 1 3 3v5h4a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1v3a5 5 0 0 1-5 5H2a1 1 0 0 1-1-1c0-.552.46-.984.982-1.164A3 3 0 0 0 4 18v-3a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h4V4a3 3 0 0 1 3-3M6 15v3c0 .93-.282 2.374-1 2.845V21h.026C6.12 20.986 13 21 13 21a3 3 0 0 0 3-3v-3zm16 6.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0m1-2.5a1 1 0 1 0 0-2 1 1 0 0 0 0 2",clipRule:"evenodd"})))},lp=e=>{var t;let{width:n="24px",height:r="24px",...l}=e;return(0,h.Y)(lu,{width:n,height:r,...l,...(0,rw.u$)()({fill:null!=(t=null==l?void 0:l.fill)?t:"icon_primary"})})};function lh(){return(lh=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}let lg=function(e){return g.createElement("svg",lh({xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 24 25"},e),d||(d=g.createElement("path",{fillRule:"evenodd",d:"M4 4.437a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8.373c-.108-.62.078-1.28.556-1.757l1.414-1.415a2 2 0 0 1 2.829 0l.707.707 2.828-2.828c.36-.36.822-.554 1.293-.582V6.437a2 2 0 0 0-2-2zm14.243 16L22 16.68l.121-.122 1.415 1.415-4.95 4.95a1 1 0 0 1-1.414 0l-2.486-2.486-.343-.343 1.414-1.414 1.758 1.757.364.364zM3.376 7.605l7.376 5.89a2 2 0 0 0 2.496 0l7.376-5.89-1.248-1.563L12 11.932l-7.376-5.89z",clipRule:"evenodd"})))},lm=e=>{var t;let{width:n="24px",height:r="24px",...l}=e;return(0,h.Y)(lg,{width:n,height:r,...l,...(0,rw.u$)()({fill:null!=(t=null==l?void 0:l.fill)?t:"icon_primary"})})};function lf(){return(lf=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}let lv=function(e){return g.createElement("svg",lf({xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 24 25"},e),u||(u=g.createElement("path",{fillRule:"evenodd",d:"M3 5.437a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2zm13.596 5.536-4.95 4.95a1 1 0 0 1-1.414 0l-2.828-2.83 1.414-1.413 2.121 2.121 4.243-4.243z",clipRule:"evenodd"})))},ly=e=>{var t;let{width:n="24px",height:r="24px",...l}=e;return(0,h.Y)(lv,{width:n,height:r,...l,...(0,rw.u$)()({fill:null!=(t=null==l?void 0:l.fill)?t:"icon_primary"})})},lx=e=>{let{children:t}=e;return(0,h.FD)(P.t,{width:["100%","100%","100%","514px","514px"],borderRadius:"12px",border:"1px solid",borderColor:"outline_primary",overflow:"hidden",children:[(0,h.Y)(P.t,{width:"100%",backgroundColor:"surface_secondary",p:"8px 12px",children:(0,h.FD)(H.zt,{gap:"4px",children:[(0,h.Y)("img",{width:"14px",height:"10px",src:"https://fe-web-assets.static.wrtn.ai/wrtn2/connector/gmail.svg",alt:"gmail 아이콘"}),(0,h.Y)(N.Z,{typo:"Body7",color:"text_secondary",children:"메일 브리핑"})]})}),t]})},lb=e=>{let{children:t,date:n}=e;return(0,h.Y)(H.Tk,{gap:"4px",children:(0,h.FD)(H.zt,{width:"100%",gap:"8px",alignItems:"start",children:[(0,h.Y)(eg,{}),(0,h.FD)(H.Tk,{gap:"4px",children:[(0,h.Y)(em,{}),t,n&&(0,h.Y)(P.t,{py:"4px",children:(0,h.Y)(nI,{date:n})})]})]})})};var l_=n(73761);function lY(){return(lY=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}let lw=function(e){return g.createElement("svg",lY({xmlns:"http://www.w3.org/2000/svg",fill:"
1currentColor",viewBox:"0 0 24 25"},e),p||(p=g.createElement("path",{d:"M11 17.437H7q-2.074 0-3.537-1.463Q2 14.513 2 12.438T3.463 8.9Q4.925 7.437 7 7.437h4v2H7q-1.25 0-2.125.875A2.9 2.9 0 0 0 4 12.437q0 1.25.875 2.125A2.9 2.9 0 0 0 7 15.437h4zm-3-4v-2h8v2zm5 4v-2h4q1.25 0 2.125-.875A2.9 2.9 0 0 0 20 12.437q0-1.25-.875-2.125A2.9 2.9 0 0 0 17 9.437h-4v-2h4q2.075 0 3.538 1.463Q22 10.362 22 12.437t-1.462 3.538Q19.074 17.437 17 17.437z"})))},lk=e=>{var t;let{width:n="24px",height:r="24px",...l}=e;return(0,h.Y)(lw,{width:n,height:r,...l,...(0,rw.u$)()({fill:null!=(t=null==l?void 0:l.fill)?t:"icon_primary"})})};function lC(){let e=(0,Z._)(['\n            &::marker {\n              content: "•  ";\n              color: ',";\n            }\n          "]);return lC=function(){return e},e}let lA=e=>{let{summaryList:t}=e;return(0,h.Y)(ec.a,{as:"ul",ml:"20px",style:{listStylePosition:"outside"},children:t.map((e,t)=>(0,h.Y)(ec.a,{as:"li",css:(0,m.AH)(lC(),(0,t6.V)("text_secondary")),children:(0,h.Y)(N.Z,{typo:"Body6",color:"text_secondary",children:e})},t))})};function lF(){let e=(0,Z._)(["\n            border-bottom: 1px solid ",";\n\n            &:last-of-type {\n              border-bottom: none;\n            }\n          "]);return lF=function(){return e},e}let lI=e=>{let{content:t,messageId:n}=e,{trackEvent:r}=(0,L.jt)();return(0,h.FD)(H.Tk,{p:"16px",gap:"20px",overflowY:"auto",height:"calc(100% - 56px)",children:[!(null==t?void 0:t.list.length)&&(0,h.Y)(H.Tk,{height:"100%",justifyContent:"center",alignItems:"center",children:(0,h.Y)(N.Z,{typo:"Body4",color:"text_quaternary",children:"오늘은 브리핑할 메일이 없어요."})}),null==t?void 0:t.list.map(e=>(0,h.FD)(H.Tk,{gap:"8px",pb:"20px",css:(0,m.AH)(lF(),(0,t6.V)("outline_primary")),children:[(0,h.Y)(P.t,{children:(0,h.Y)(N.Z,{as:"span",typo:"Body6",color:"text_tertiary",css:{padding:"1.5px 4px",backgroundColor:(0,t6.V)("surface_secondary"),borderRadius:"4px"},children:e.sender})}),(0,h.FD)(H.Tk,{gap:"8px",children:[(0,h.FD)(H.zt,{alignItems:"center",gap:"4px",children:[(0,h.Y)(N.Z,{typo:"Subtitle6",children:e.topic}),(0,h.Y)(ny.o,{onClick:()=>(e=>{e&&(r("click_detail_mail_link",{feature_name:"gmail",service_detail:"connector",briefing_id:n}),window.open(e,"_blank","noopener,noreferrer"))})(e.link),children:(0,h.Y)("div",{css:{display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:(0,t6.V)("background_tint"),width:"24px",height:"24px",borderRadius:"100px"},children:(0,h.Y)(lk,{width:"20px",height:"20px",fill:"icon_tint"})})})]}),(0,h.Y)(lA,{summaryList:e.summary})]})]},e.id))]})},lD=e=>{let{messageId:t,detailList:n,defaultTabId:r,close:l}=e,[i,a]=(0,g.useState)(null!=r?r:"highly_important"),o=n.find(e=>{let{id:t}=e;return"highly_important"===t}),s=n.find(e=>{let{id:t}=e;return"important"===t});return(0,g.useEffect)(()=>{a(null!=r?r:"highly_important")},[r]),(0,h.FD)(h.FK,{children:[(0,h.Y)(L.L0,{name:"view_briefing_detail",properties:{briefing_id:t,feature_name:"gmail",service_detail:"connector"},watch:!1}),(0,h.FD)(P.t,{backgroundColor:"surface_elevated",borderRadius:"12px",height:"100%",overflow:"hidden",children:[(0,h.FD)(H.zt,{p:"12px 20px",alignItems:"center",justifyContent:"space-between",children:[(0,h.Y)(N.Z,{typo:"Subtitle4",children:"브리핑 상세보기"}),(0,h.Y)(O.$,{width:"32px",height:"32px",p:"4px",onClick:l,children:(0,h.Y)(nb.N,{width:"24px",height:"24px"})})]}),(0,h.FD)(l_.t,{value:i,onChange:e=>{a(e)},fullHeight:!0,children:[(0,h.Y)(l_.t.Item,{value:"highly_important",panel:(0,h.Y)(lI,{messageId:t,content:o}),title:"매우 중요"}),(0,h.Y)(l_.t.Item,{value:"important",panel:(0,h.Y)(lI,{messageId:t,content:s}),title:"중요"})]})]})]})},lS=e=>{let{detailList:t,defaultTabId:n,messageId:r}=e,{open:l,close:i}=(0,n4.R)(),{trackEvent:a}=(0,L.jt)();return(0,h.Y)(O.$,{width:"82px",height:"23px",p:"2.5px 8px 2.5px 12px",border:"none",typo:"Body7",borderRadius:"8px",backgroundColor:"surface_primary_invert",color:"text_primary_inverted",right:(0,h.Y)(rc.m,{width:"16px",height:"16px",fill:"icon_primary_invert"}),onClick:()=>{a("click_briefing_detail",{feature_name:"gmail",briefing_id:r,importance_field:n}),l(()=>(0,h.Y)(lD,{messageId:r,defaultTabId:n,detailList:t,close:i}))},children:"상세보기"})};function lR(){let e=(0,Z._)(["\n              display: flex;\n              flex-direction: column;\n              gap: 8px;\n\n              .mail_list_item {\n                border-bottom: 1px solid ",";\n                padding-bottom: 8px;\n\n                &:last-of-type {\n                  border-bottom: none;\n                  padding-bottom: 0;\n                }\n              }\n            "]);return lR=function(){return e},e}let lM=e=>
1{let{date:t,mailList:n,checkList:r,detailList:l,messageId:i}=(e=>{let{content:t,date:n,messageId:r}=e,l=[{id:"highly_important",name:"매우 중요",list:t.briefing.mailTopics.highly_important},{id:"important",name:"중요",list:t.briefing.mailTopics.important},{id:"not_important",name:"기타",text:t.briefing.mailTopicSummaries.not_important}].filter(e=>"list"in e?e.list&&e.list.length>0:"text"in e&&e.text&&""!==e.text.trim()),i=t.briefing.todoItems,a=l.filter(e=>"not_important"!==e.id);return{messageId:r,date:n,mailList:l,detailList:a,checkList:i}})(e);return(0,h.Y)(lb,{date:t,children:(0,h.Y)(lx,{children:(0,h.FD)(H.Tk,{p:"12px",gap:"8px",children:[(0,h.FD)(N.Z,{typo:"Body5",children:["오늘의 메일 요약 브리핑이 도착했어요! ",(0,h.Y)("br",{})," 상세보기를 클릭하면 자세한 요약을 확인하실 수 있어요."]}),(0,h.Y)(rd.h,{height:8}),(0,h.Y)(P.t,{backgroundColor:"surface_secondary",borderRadius:"12px",py:"6px",px:"14px",css:(0,m.AH)(lR(),(0,t6.V)("outline_secondary")),children:n.map(e=>{var t;return(0,h.FD)(H.Tk,{className:"mail_list_item",children:[(0,h.FD)(H.zt,{justifyContent:"space-between",alignItems:"center",children:[(0,h.FD)(H.zt,{p:"8px 0",gap:"4px",alignItems:"center",children:[(e=>{switch(e){case"highly_important":return(0,h.Y)(ls.e,{width:"16px",height:"16px",fill:"icon_quaternary"});case"important":return(0,h.Y)(lc.P,{width:"16px",height:"16px",fill:"icon_quaternary"});case"not_important":return(0,h.Y)(lp,{width:"16px",height:"16px",fill:"icon_quaternary"});default:return null}})(e.id),(0,h.Y)(N.Z,{typo:"Subtitle6",color:"text_quaternary",children:e.name})]}),"not_important"!==e.id&&(0,h.Y)(lS,{messageId:i,defaultTabId:e.id,detailList:l})]}),"list"in e&&(null==e||null==(t=e.list)?void 0:t.map(e=>(0,h.FD)(H.zt,{justifyContent:"space-between",alignItems:"center",p:"4px 0 8px",children:[(0,h.FD)(H.zt,{gap:"4px",alignItems:"center",children:[(0,h.Y)(N.Z,{typo:"Subtitle4",ellipsis:!0,lineClamp:1,css:{maxWidth:"308px"},children:e.topic}),(0,h.FD)(N.Z,{typo:"Text7",children:["\xb7 \xa0",(0,h.Y)(N.Z,{as:"span",typo:"Text7",color:e.isRead?"text_tertiary":"brand_primary",children:e.isRead?"읽음":"안읽음"})]})]}),(0,h.Y)(N.Z,{typo:"Body6",color:"text_tertiary",ellipsis:!0,lineClamp:1,css:{maxWidth:"92px"},children:e.sender})]},e.id))),"text"in e&&(0,h.Y)(N.Z,{typo:"Body5",color:"text_tertiary",px:"14px",pb:"8px",css:{padding:"4px 0 8px"},children:e.text})]},e.id)})}),r.length>0&&(0,h.FD)(H.Tk,{gap:"12px",p:"12px",children:[(0,h.FD)(H.zt,{gap:"4px",alignItems:"center",children:[(0,h.Y)(lm,{width:"16px",height:"16px",fill:"icon_tertiary"}),(0,h.Y)(N.Z,{typo:"Subtitle6",color:"icon_quaternary",children:"체크리스트"})]}),(0,h.Y)(H.Tk,{gap:"8px",children:r.map(e=>(0,h.FD)(H.zt,{alignItems:"center",gap:"8px",children:[(0,h.Y)(ly,{width:"16px",height:"16px",fill:"icon_quaternary"}),(0,h.Y)(N.Z,{typo:"Body5",color:"text_tertiary",ellipsis:!0,lineClamp:1,children:e})]},e))})]})]})})})},lT=e=>{let{date:t,showGenerateStep:n}=(e=>{let{date:t}=e,{isAuth:n}=(0,y.A)(),{data:r,isLoading:l}=(0,eo.I)({...(0,I.Kw3)(),enabled:n,retry:!1}),{data:i,isLoading:a}=(0,eo.I)({...(0,I.HKr)(),enabled:!!(n&&(null==r?void 0:r.isConnected))});return{date:t,showGenerateStep:!(l||a)&&(null==i?void 0:i.status)==="in_progress"}})(e);return n?(0,h.Y)(lb,{date:t,children:(0,h.Y)(nu,{generateMessageSocketEventName:"gmailBriefingMessage",generateStepSocketEventName:"gmailBriefingGenerateStep"})}):null};var lE=n(67302);let lj=e=>{let{onClick:t}=e,{trackEvent:n}=(0,L.jt)();return(0,h.Y)(ny.o,{onClick:()=>{n("click_briefing_setting_chat_btn",{feature_name:"gmail",service_detail:"connector"}),t()},children:(0,h.Y)(P.t,{width:"100%",p:"8px 12px",backgroundColor:"surface_secondary",borderRadius:"8px",children:(0,h.FD)(H.zt,{gap:"12px",width:"100%",children:[(0,h.Y)(ec.a,{flexShrink:0,width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid",borderColor:"outline_active",borderRadius:"12px",my:"4px",children:(0,h.Y)("img",{width:"25px",height:"20px",src:"https://fe-web-assets.static.wrtn.ai/wrtn2/connector/gmail.svg",alt:"gmail 아이콘"})}),(0,h.FD)(H.zt,{width:"100%",justifyContent:"space-between",alignItems:"center",children:[(0,h.FD)(H.Tk,{gap:"4px",children:[(0,h.Y)(N.Z,{typo:"Body6",height:"20px",children:"중요도 기준 설정하기"}),(0,h.FD)(N.Z,{typo:"Body7",color:"text_secondary",children:["설정 ",">"," 커넥터 설정 탭에서 브리핑 기준을 수정할 수 있어요"]})]}),(0,h.Y)(rc.m,{width:"24px",height:"24px",fill:"icon_secondary"})]})]})})})},lz={mon:"월",tue:"화",wed:"수",thu:"목",fri:"금",sat:"토",sun:"일"},lB=[{id:"email",label:"계정",value:""},{id:"isSubscribed",label:"자동 브리핑",value:""},{id:"schedule",label:"브리핑 주기",value:""},{id:"importanceFilter",label:"중요도 기준",value:""}],lL=e=>{let{settingList:t,date:n,title:r}=(e=>{let{content:t,date:n,title:r}=e,l=(0,G.jE)(),i=t.settings.schedule.days.map(e=>lz[e]||e).join(""),a=(()=>{let{min:e,hour:n,meridiem:r}=(e=>{let t=(0,E.qg)(e,"HH:mm",new Date);
1return{meridiem:(0,E.Yq)(t,"a"),hour:parseInt((0,E.Yq)(t,"hh")),min:(0,E.Yq)(t,"mm")}})(t.settings.schedule.time);return"".concat(r," ").concat(n,"시 ").concat(e,"분")})(),o=lB.map(e=>{switch(e.id){case"email":return{...e,value:t.settings.email};case"isSubscribed":return{...e,value:t.settings.isSubscribed?"켜짐":"꺼짐"};case"schedule":return{...e,value:"".concat(i," ").concat(a)};case"importanceFilter":var n,r;return{...e,value:null!=(r=null==(n=t.settings.importanceFilter)?void 0:n.prompt)?r:""};default:return e}}).filter(e=>!!e.value);return(0,g.useEffect)(()=>{l.invalidateQueries((0,I.HKr)())},[]),{title:r,date:n,settingList:o}})(e);return(0,h.Y)(lb,{date:n,children:(0,h.Y)(lx,{children:(0,h.FD)(P.t,{p:"12px",children:[(0,h.Y)(N.Z,{typo:"Subtitle4",children:r}),(0,h.Y)(ec.a,{width:"100%",height:"1px",backgroundColor:"outline_primary",my:"12px"}),(0,h.Y)(H.Tk,{gap:"8px",children:t.map(e=>(0,h.FD)(H.zt,{gap:"8px",alignItems:"center",children:[(0,h.Y)(N.Z,{style:{width:"92px"},typo:"Body5",color:"text_quaternary",children:e.label}),(0,h.Y)(N.Z,{color:"text_secondary",typo:"Body5",children:e.value})]},e.id))}),(0,h.Y)(rd.h,{height:"16px"}),(0,h.Y)(lE.K,{renderOpener:e=>{let{openModal:t}=e;return(0,h.Y)(lj,{onClick:t})}})]})})})};function lH(){let e=(0,Z._)(["\n          .markdown-container {\n            & p:last-of-type {\n              padding-bottom: 0;\n            }\n          }\n        "]);return lH=function(){return e},e}let lP=e=>{let{content:t,date:n}=e;return(0,h.Y)(lb,{date:n,children:(0,h.Y)("div",{css:(0,m.AH)(lH()),children:(0,h.Y)(rQ.o,{content:t.text,typo:"Body5"})})})},lq=e=>{let{assistantMessage:t,needOnboarding:n}=(e=>{let{assistantMessage:t,needOnboarding:n}=e;return{assistantMessage:t,needOnboarding:n}})(e);switch(t.content.type){case"briefing":return(0,h.Y)(lM,{messageId:t.id,content:t.content,date:t.createdAt});case"setting":return(0,h.Y)(lL,{title:t.content.text,content:t.content,date:t.createdAt});case"text":return(0,h.FD)(h.FK,{children:[(0,h.Y)(lP,{content:t.content,date:t.createdAt}),n&&(0,h.Y)(lT,{date:t.createdAt})]});default:return t.content,null}},lZ=e=>{let{message:t,needOnboarding:n}=e;return(0,h.Y)(lq,{assistantMessage:t,needOnboarding:n})},lN=e=>["/v1/interest-talks/".concat(e.chatId,"/messages/").concat(e.messageId)],lO=e=>{let{chatId:t,messageId:n,reaction:r}=e;return Y.FA.default.put("/v1/interest-talks/".concat(t,"/messages/").concat(n),{reaction:r})},lK=()=>({key:lN,fetcher:lO}),lV=Object.assign(function(e){let{children:t}=e;return(0,h.Y)(H.zt,{gap:"4px",children:t})},{Dot:function(){return(0,h.Y)(P.t,{width:"2px",height:"2px",backgroundColor:"icon_secondary",borderRadius:"100%"})},CopyButton:nF,ReactionButton:e=>{let{toggleReaction:t,reaction:n,setOpenedReactionBar:r,openedReactionBar:l}=(e=>{let{assistantMessage:t}=e,{toggleReaction:n,reaction:r,setOpenedReactionBar:l,openedReactionBar:i,isLoading:a}=nT({assistantMessage:t,queryKey:D.$,mutationKey:lK().key,mutationFn:lK().fetcher,extractMessages:e=>e.pages.flatMap(e=>e.list),updateMessages:(e,t,n)=>e.map(e=>e.id===t?{...e,reaction:n}:e)});return{reaction:r,toggleReaction:n,isLoading:a,setOpenedReactionBar:l,openedReactionBar:i}})(e);return(0,h.Y)(nq,{reaction:n,toggleReaction:t,opened:l,setOpened:e=>r(e)})},MessageDateLabel:nI}),lW=Object.assign((0,g.forwardRef)(function(e,t){let{children:n,icon:r,name:l,controller:i,extraContent:a,id:o,isFocusMessage:s}=e;return(0,h.Y)(H.zt,{justifyContent:"flex-start",width:"100%",flexShrink:0,ref:t,"data-message-id":o,className:"".concat(el," ").concat(s?ei:""),children:(0,h.FD)(H.zt,{gap:"8px",alignItems:"flex-start",width:"100%",children:[(0,h.Y)(eg,{}),(0,h.FD)(H.Tk,{gap:"4px",width:["calc(100% - 36px)","calc(100% - 36px)","100%","100%","100%"],maxWidth:"474px",children:[(0,h.Y)("div",{css:{paddingBottom:4},children:(0,h.Y)(em,{})}),(0,h.FD)(P.t,{borderRadius:"12px",border:"1px solid",borderColor:"outline_primary",backgroundColor:"surface_elevated",overflow:"hidden",children:[(0,h.Y)(P.t,{backgroundColor:"surface_secondary",children:(0,h.FD)(H.zt,{alignItems:"center",gap:"4px",p:"8px 12px",children:[(0,h.Y)("img",{src:r,width:"16px",height:"16px",alt:"interest talk icon"}),(0,h.Y)(N.Z,{typo:"Body7",color:"text_secondary",children:l})]})}),(0,h.Y)(P.t,{p:"12px",children:n})]}),a,(0,h.Y)(H.zt,{gap:"4px",children:i})]})]})})}
1),{Thumbnail:function(e){let{image:t,style:n}=e;return null==t?null:(0,h.Y)("img",{width:"100%",src:t,alt:"content image",style:{objectFit:"cover",borderRadius:"8px",...n}})},MessageText:function(e){let{children:t}=e;return null==t?null:(0,h.Y)(rQ.o,{content:t,typo:"Body5",noPaddingBottom:!0})},Controller:lV});var lQ=n(59681);function l$(){let e=(0,Z._)(["\n        > * + * {\n          border-top: 1px solid ",";\n        }\n      "]);return l$=function(){return e},e}function lU(){let e=(0,Z._)(["\n                transform: rotate(",");\n                transition: transform 0.2s;\n              "]);return lU=function(){return e},e}function lX(e){let{guidelines:t,productId:n}=e;return(0,h.Y)(P.t,{border:"1px solid",borderColor:"outline_primary",backgroundColor:"surface_elevated",borderRadius:"12px",py:"4px",px:"12px",css:(0,m.AH)(l$(),(0,t6.V)("outline_primary")),children:t.map((e,t)=>{let{details:r,title:l}=e;return(0,h.Y)(L.Wg,{name:"click_shop_message_notice",properties:{index:t+1,product_id:n},children:(0,h.Y)(lG,{title:l,details:r})},t)})})}function lG(e){let{title:t,details:n}=e,[r,l]=(0,g.useState)(!0);return(0,h.Y)(P.t,{width:"100%",children:(0,h.FD)(H.Tk,{children:[(0,h.Y)(ny.o,{onClick:()=>l(e=>!e),children:(0,h.FD)(H.zt,{width:"100%",justifyContent:"space-between",alignItems:"center",py:"8px",children:[(0,h.Y)(N.Z,{typo:"Body7",color:"text_secondary",children:t}),(0,h.Y)(ec.a,{display:"flex",css:(0,m.AH)(lU(),r?"-180deg":"0deg"),children:(0,h.Y)(lQ.P,{width:"16px",height:"16px",fill:"icon_secondary"})})]})}),(0,h.Y)(lJ,{overflow:"hidden",initial:r?{height:0,opacity:.5}:{height:"auto",opacity:1},animate:{transition:{type:"tween"},height:r?0:"auto",opacity:r?.5:1},exit:{height:0,opacity:1},children:(0,h.Y)(ec.a,{width:"100%",pb:"8px",pl:"18px",as:"ul",style:{listStylePosition:"outside"},children:null==n?void 0:n.map((e,t)=>(0,h.Y)(N.Z,{typo:"Text7",color:"text_secondary",as:"li",children:e},t))})})]})})}let lJ=ne.P.create(P.t);function l0(e){let{ballSize:t,ballCount:n,...r}=e;return(0,h.Y)(l8,{variants:l2,initial:"start",animate:"end",...r,children:Array.from({length:n}).map((e,n)=>(0,h.Y)(l3,{variants:l1,transition:l4,width:t,height:t,borderRadius:"50%",backgroundColor:"icon_disable"},n))})}let l1={start:{y:"100%"},end:{y:"0%"}},l2={start:{transition:{staggerChildren:.3}},end:{transition:{staggerChildren:.3}}},l4={duration:1,ease:"easeInOut",repeat:1/0,repeatType:"reverse"},l3=(0,ne.P)(P.t),l8=(0,ne.P)(H.zt);function l6(e){let{endDate:t,isEnded:n,setIsEnded:r}=e,[l,i]=(0,g.useState)(l5(t));(0,j.$$)(e=>{let n=l5(t);n<=0&&(i(0),r(!0),e()),i(n)},1e3);let a=(()=>{var e,t,n;let r=(0,E.FM)({start:new Date,end:new Date(new Date().getTime()+l)}),i=[];return r.days&&i.push("".concat(r.days,"일")),(r.hours||r.days)&&i.push("".concat(null!=(e=r.hours)?e:0,"시간")),(r.minutes||r.hours||r.days)&&i.push("".concat(null!=(t=r.minutes)?t:0,"분")),(r.seconds||r.minutes||r.hours||r.days)&&i.push("".concat(null!=(n=r.seconds)?n:0,"초")),0===i.length&&i.push("0초"),i.join(" ")})();return n?(0,h.FD)(N.Z,{color:"text_secondary",typo:"Subtitle7",textAlign:"center",children:["초특가 할인 판매가 마감되었어요",(0,h.Y)("br",{}),"배송 관련 문의는 뤼튼 고객센터를 통해 진행해 주세요"]}):(0,h.FD)(N.Z,{color:"brand_primary",typo:"Subtitle7",style:{fontVariantNumeric:"tabular-nums"},children:["판매 마감까지 ",a," 남았어요"]})}let l5=e=>{if(!e)return 0;let t=new Date(e),n=new Date,r=(0,E.wB)(t,n,"milliseconds");return r>0?r:0};function l7(e){var t,n;let{assistantMessage:r}=e,{open:l}=(0,n4.R)(),{trackEvent:i}=(0,L.jt)(),a=null==(t=r.webSearchResults)?void 0:t.map(e=>e.favicon).filter(e=>!!e),o=(0,g.useCallback)(()=>{i("click_shop_product_review_btn",{product_id:e.productId}),l(t=>{let{close:n}=t;return(0,h.FD)(n8.Y,{children:[(0,h.Y)(n8.Y.Header,{title:"제품 후기",renderCloseButton:(0,h.Y)(n8.Y.Header.Close,{onClick:n})}),(0,h.Y)(H.Tk,{p:"0 20px 12px",maxWidth:["100%","100%","100%","552px","624px"],width:"100%",children:r.webSearchResults.map((t,n)=>(0,h.Y)(ro.Z,{webSearchResult:t,onClick:()=>{i("click_shop_product_review_link",{product_id:e.productId,index:n})}},t.link))})]})})},[i,e.productId,l,r.webSearchResults]);return(null==(n=r.webSearchResults)?void 0:n.length)?(0,h.Y)(n3,{favicons:a,onClick:o,children:"제품 후기"}):null}function l9(e){let{icon:t,name:n,assistantMessage:r,content:l,isLast:i}=e,{discountRate:a,isEnded:o,product:s,isLoading:c,handlePurchaseButtonClick:d,setIsEnded:u}=function(e){var t,n;let[r,l]=(0,g.useState)(!1),{data:i,isLoading:a}=(0,eo.I)({...(0,I.juv)({path:{productId:e.productId}}),select:e=>{var t;let n=(0,E.wB)(new Date(null!=(t=null==e?void 0:e.endDate)?t:""),new Date,"milliseconds");return{...e,isInitialEnded:n<=0}}}),o=(0,g.useMemo)(()=>Math.floor((e.originalPrice-e.price)/e.originalPrice*100),[e.originalPrice,e.price]),s=null!=(t=null==i?void 0:i.purchaseCount)?t:0;return{discountRate:o,isEnded:null!=(n=null==i?void 0:i.isInitialEnded)?n:r,purchaseCount:s,product:i,isLoading:a||!i,handlePurchaseButtonClick:()=>{window.open(e.purchaseUrl,"_blank")},setIsEnded:l}}(l);return(0,h.Y)(L.Yn,{name:"expose_shop_message",properties:{product_id:l.productId},observer:{threshold:.6},children:(0,h.Y)(lW,{icon:t,name:n,controller:(0,h.FD)(lW.Controller,{children:[(0,h.Y)(l7,{assistantMessage:r,productId:l.productId}),(0,h.Y)(lW.Controller.CopyButton,{assistantMessage:r}),(0,h.Y)(lW.Controller.ReactionButton,{assistantMessage:r}),(0,h.Y)(lW.Controller.Dot,{}),(0,h.Y)(lW.Controller.MessageDateLabel,{date:r.createdAt})]}),extraContent:(0,h.Y)(lX,{guidelines:l.guidelines,productId:l.productId}),id:r.id,isFocusMessage:i,children:(0,h.FD)(H.Tk,{gap:"12px",children:[(0,h.Y)(ie,{image:l.image}),(0,h.FD)(H.Tk,{gap:"10px",children:[(0,h.FD)(H.Tk,{gap:"2px",children:[(0,h.Y)(N.Z,{typo:"Body7",color:"text_secondary_invert",children:l.brandName}),(0,h.Y)(N.Z,{typo:"Body4",color:"text_primary",children:l.name})]}),(0,h.FD)(H.Tk,{gap:"4px",children:[(0,h.FD)(N.Z,{as:"s",typo:"Body6",color:"text_tertiary",py:"2px",children:[l.originalPrice.toLocaleStr
1ing(),"원"]}),(0,h.Y)(H.zt,{gap:"8px",alignItems:"flex-end",children:(0,h.FD)(H.zt,{gap:"4px",children:[(0,h.FD)(N.Z,{typo:"Subtitle3",color:"brand_primary",children:[a,"%"]}),(0,h.FD)(N.Z,{typo:"Subtitle3",color:"text_primary",children:[l.price.toLocaleString(),"원"]})]})})]})]}),(0,h.Y)(P.t,{p:"14px",width:"100%",backgroundColor:"surface_secondary",borderRadius:"8px",children:(0,h.Y)(H.Tk,{gap:"10px",children:l.comparisons.map((e,t)=>{var n;return(0,h.FD)(H.zt,{justifyContent:"space-between",children:[(0,h.FD)(H.zt,{alignItems:"center",gap:"8px",children:[(0,h.Y)("img",{width:16,height:16,style:{borderRadius:"50%"},src:e.icon,alt:""}),(0,h.Y)(N.Z,{typo:"Body6",color:"text_secondary",children:e.name})]}),(0,h.FD)(N.Z,{color:"text_tertiary",typo:"Body6",children:[null==(n=e.price)?void 0:n.toLocaleString(),"원"]})]},t)})})}),(0,h.Y)(H.zt,{width:"100%",justifyContent:"center",children:c?(0,h.Y)(l0,{ballSize:6,ballCount:5,gap:6,height:"18px"}):(0,h.Y)(l6,{isEnded:o,endDate:null==s?void 0:s.endDate,setIsEnded:u})}),(0,h.FD)(H.zt,{gap:"10px",children:[(0,h.Y)(L.Wg,{name:"click_shop_message_detail_btn",properties:{product_id:l.productId},children:(0,h.Y)(tO(),{href:l.detailUrl,target:"_blank",children:(0,h.Y)(O.$,{borderColor:"outline_secondary",backgroundColor:"surface_elevated",width:"134px",style:"line",children:"제품 상세"})})}),(0,h.Y)(P.t,{flex:1,children:(0,h.Y)(L.Wg,{name:"click_shop_message_purchase_btn",properties:{product_id:l.productId},children:(0,h.Y)(O.$,{width:"100%",backgroundColor:"surface_primary_invert",color:"text_primary_inverted",disabled:o,isLoading:c,onClick:d,children:o?"판매 종료":"구매하기"})})})]})]})})})}function ie(e){let{image:t}=e;return(0,h.Y)(H.zt,{position:"relative",justifyContent:"center",children:(0,h.Y)(lW.Thumbnail,{image:t,style:{aspectRatio:"16/9"}})})}function it(e){let{icon:t,name:n,content:r,assistantMessage:l}=e;return(0,h.Y)(lW,{icon:t,name:n,controller:(0,h.FD)(lW.Controller,{children:[(0,h.Y)(lW.Controller.CopyButton,{assistantMessage:l}),(0,h.Y)(lW.Controller.ReactionButton,{assistantMessage:l}),(0,h.Y)(lW.Controller.Dot,{}),(0,h.Y)(lW.Controller.MessageDateLabel,{date:l.createdAt})]}),children:(0,h.FD)(H.Tk,{gap:"8px",children:[(0,h.Y)(lW.Thumbnail,{image:r.image}),(0,h.Y)(lW.MessageText,{children:r.text}),(0,h.Y)(r7,{chatId:l.chatId,type:"interest-talk",disabled:"expired"===r.status,messageId:l.id})]})})}function ir(e){let{icon:t,name:n,assistantMessage:r,content:l}=e;return(0,h.Y)(lW,{icon:t,name:n,controller:(0,h.FD)(lW.Controller,{children:[(0,h.Y)(lW.Controller.CopyButton,{assistantMessage:r}),(0,h.Y)(lW.Controller.ReactionButton,{assistantMessage:r}),(0,h.Y)(lW.Controller.Dot,{}),(0,h.Y)(lW.Controller.MessageDateLabel,{date:r.createdAt})]}),children:(0,h.FD)(H.Tk,{gap:"8px",children:[(0,h.Y)(lW.Thumbnail,{image:l.image}),(0,h.Y)(lW.MessageText,{children:l.text})]})})}function il(e){let{icon:t,name:n,assistantMessage:r,content:l}=e;return(0,h.Y)(lW,{icon:t,name:n,controller:(0,h.FD)(lW.Controller,{children:[(0,h.Y)(lW.Controller.CopyButton,{assistantMessage:r}),(0,h.Y)(lW.Controller.ReactionButton,{assistantMessage:r}),(0,h.Y)(lW.Controller.Dot,{}),(0,h.Y)(lW.Controller.MessageDateLabel,{date:r.createdAt})]}),children:(0,h.Y)(H.Tk,{gap:"8px",children:(0,h.Y)(lW.MessageText,{children:l.text})})})}let ii=e=>{let{assistantMessage:t,name:n,icon:r,isLast:l}=(e=>{var t,n;let{assistantMessage:r,isLast:l}=e,{data:i}=(0,x.m)({chatId:r.chatId}),a=null==i?void 0:i.interestTalk;return{icon:null!=(t=null==i?void 0:i.icon)?t:"",name:null!=(n=null==a?void 0:a.name)?n:"",assistantMessage:r,isLast:l}})(e);switch(t.content.type){case"image":return(0,h.Y)(ir,{name:n,icon:r,assistantMessage:t,content:t.content,isLast:l});case"giftishow-coupon":return(0,h.Y)(it,{name:n,icon:r,assistantMessage:t,content:t.content,isLast:l});case"commerce-product-v1":return(0,h.Y)(l9,{name:n,icon:r,assistantMessage:t,content:t.content,isLast:l});case"text":return(0,h.Y)(il,{name:n,icon:r,assistantMessage:t,content:t.content,isLast:l});default:return t.content,null}},ia=e=>{let{message:t,isLast:n}=e;return(0,h.Y)(ii,{assistantMessage:t,isLast:n})};function io(e){return"counseling"===e.chatType}let is=e=>{let{events:t}=(0,z.rd)(),{list:n}=(e=>{let{list:t,isLoading:n}=e;return{list:t,isLoading:n}})(e),r=(0,g.useRef)(null);return(0,g.useEffect)(()=>{let e=()=>{var e;null==(e=r.current)||e.classList.remove("_message-sent")};return t.on("routeChangeComplete",e),()=>{t.off("routeChangeComplete",e)}},[t]),(0,j.Es)(()=>{let e=n.at(-1);if(e&&"role"in e&&"assistant"===e.role&&"status"in e&&"streaming"===e.status){var t;null==(t=r.current)||t.classList.add("_message-sent")}},[n]),(0,h.Y)("div",{css:ic.wrapper,ref:r,children:n.flatMap((e,t,r)=>{let l,i,a=[],o=t+1>=r.length;return(0!==t&&(l=n[t-1].createdAt,i=e.createdAt,(0,E.ro)(new Date(l),new Date(i)))||a.push((0,h.Y)(lo,{date:e.createdAt},"".concat(e.id,"-date"))),0===t&&io(e)&&a.push((0,h.Y)(lt,{},"counseling-description")),io(e))?(a.push((0,h.Y)(lr,{message:e},e.id)),a):(nk(e)&&a.push((0,h.Y)(rW,{message:e,isLast:o},e.id)),"gmail-briefing"===e.chatType&&a.push((0,h.Y)(lZ,{message:e,needOnboarding:1===n.length},e.id)),"interest-talk"===e.chatType&&a.push((0,h.Y)(ia,{message:e,isLast:o},e.id)),"churn"===e.chatType&&a.push((0,h.Y)(le,{message:e},e.id)),a)})})},ic={wrapper:(0,m.AH)(v.BL,{gap:20,width:"100%",maxWidth:768,[v.mq.mobile]:{maxWidth:"100%"},"&._message-sent":{[".".concat(el,":last-of-type")]:{minHeight:"calc(-340px + 100dvh)"}}})},id=e=>{let{loadMore:t,scrollRef:n,skip:r,setReady:l}=e,{ref:i,isInView:a}=(0,j.Wx)(!1),{chatId:o}=(0,n6.W)(),s=(0,g.useRef)(!1);(0,g.useEffect)(()=>
1{l(!1),s.current=!1},[o]);let c=(0,g.useCallback)(async()=>{if(s.current)return;s.current=!0;let e=n.current;if(e){l(!1);let t=e.scrollHeight,n=null,r=0;(n=new MutationObserver(()=>{null==n||n.disconnect(),s.current=!1;let i=e.scrollHeight;e.scrollTop+=i-t;let a=((e,t)=>{let n=new AbortController;return e.addEventListener("wheel",()=>{t()},{signal:n.signal}),window.addEventListener("keydown",e=>{["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(e.key)&&t()},{signal:n.signal}),()=>{n.abort()}})(e,()=>{window.clearTimeout(r),l(!0),a()})})).observe(e,{subtree:!0,childList:!0,attributes:!1}),r=window.setTimeout(()=>{null==n||n.disconnect(),s.current=!1,l(!0)},1e3)}await t()},[t]);return(0,g.useEffect)(()=>{!r&&a&&c()},[a,r,c]),(0,h.Y)("div",{ref:i})},iu=e=>{var t;let{children:n,messageList:r,setReady:l,ready:i}=e,{length:a}=r,o=(0,g.useRef)(null),s=(0,g.useRef)(null);(e=>{let{scrollRef:t,bottomRef:n,messageListLength:r,setReady:l,isFirstConversation:i}=e,a=(0,g.useRef)(!1),{events:o}=(0,z.rd)(),{chatId:s}=(0,n6.W)();(0,g.useEffect)(()=>{let e=()=>{l(!1),a.current=!1};return o.on("routeChangeStart",e),()=>{o.off("routeChangeStart",e)}},[o,l]);let c=r>0;(0,g.useEffect)(()=>{let e=t.current;if(!e||!c||a.current)return;let r=()=>{if(i)return;let t=e.querySelector(".".concat(ei));if(!t){var r;return null==n||null==(r=n.current)?void 0:r.scrollIntoView({behavior:"instant"})}t.scrollIntoView({behavior:"instant"})};r();let o=()=>{r(),a.current=!0,requestAnimationFrame(()=>{l(!0)})},s=requestAnimationFrame(()=>{let t=(()=>{let t=e.querySelectorAll("img:not([loading=lazy])");if(0===t.length)return void o();let n=Array.from(t).filter(e=>!e.complete);if(0===n.length)return void o();let r=0,l=()=>{(r+=1)>=n.length&&o()};return n.forEach(e=>{e.addEventListener("load",l),e.addEventListener("error",l)}),()=>{n.forEach(e=>{e.removeEventListener("load",l),e.removeEventListener("error",l)})}})();"function"==typeof t&&(d.current=t)}),d={current:null};return()=>{cancelAnimationFrame(s),d.current&&d.current()}},[n,s,c,t,l])})({scrollRef:o,bottomRef:s,messageListLength:a,setReady:l,isFirstConversation:!(r.filter(e=>!nk(e)||"assistant"===e.role).length>1)});let c=(0,g.useRef)(!0),d=(0,g.useRef)(null==(t=r.at(-1))?void 0:t.createdAt);return(0,g.useEffect)(()=>{var e,t,n;if(!i)return;if(!0===c.current){c.current=!1;return}let l=r.at(-1);if(!l||d.current&&!(new Date(d.current)<new Date(l.createdAt))||(d.current=l.createdAt,"status"in l&&"streaming"!==l.status))return;let a=null==(e=o.current)?void 0:e.querySelector(".".concat(el,'[data-message-id="').concat(l.id,'"]'));if(!a){null==(n=s.current)||n.scrollIntoView({behavior:"smooth"});return}null==(t=o.current)||t.scrollTo({behavior:"smooth",top:a.offsetTop-56})},[r,i]),(0,g.useEffect)(()=>{var e;d.current=null==r||null==(e=r.at(-1))?void 0:e.createdAt},[r]),n({scrollRef:o,bottomRef:s})};var ip=n(13034);function ih(){let e=(0,Z._)(["\n  position: relative;\n  animation-timing-function: linear(\n    0,\n    0.01942 1.83%,\n    0.07956 4.02%,\n    0.47488 13.851%,\n    0.65981 19.572%,\n    0.79653 25.733%,\n    0.84834 29.083%,\n    0.89048 32.693%,\n    0.9246 36.734%,\n    0.95081 41.254%,\n    0.97012 46.425%,\n    0.98361 52.535%,\n    0.99665 68.277%,\n    0.99988\n  );\n  animation-duration: 0.7s;\n  animation-name: ",";\n\n  button {\n    width: 32px;\n    height: 32px;\n    border-radius: 32px;\n    border: 1px solid var(--outline_primary);\n    background-color: var(--surface_elevated);\n    position: absolute;\n    left: 50%;\n    bottom: calc(1rem / 2);\n    transform: translateX(-50%);\n    display: flex;\n    justify-content: center;
1\n    align-items: center;\n  }\n"]);return ih=function(){return e},e}let ig=e=>{let{bottomRef:t,isSupportMiniChat:n}=e,[r,l]=(0,g.useState)(!1),{trackEvent:i}=(0,L.jt)(),{chatId:a}=(0,n6.W)();return((0,g.useEffect)(()=>{if(!t.current)return;let e=new IntersectionObserver(e=>{let[t]=e;l(!t.isIntersecting)},{threshold:0});return e.observe(t.current),()=>{e.disconnect()}},[a]),r)?(0,h.Y)(ec.a,{css:iv,children:(0,h.Y)("button",{onClick:()=>{var e;null==(e=t.current)||e.scrollIntoView({behavior:"smooth"}),i("click_chat_drop_btn",{service_type:"companion",service_detail:"chat",feature_name:n?"minichat":"chat",source_type:"website"})},title:"scroll to bottom",children:(0,h.Y)(ip.I,{width:"16px"})})}):null},im=(0,m.i7)({"0%":{opacity:.25}}),iv=(0,m.AH)(ih(),im),iy=e=>{let{chatId:t}=e,n=(0,f.H)();return(0,h.Y)(T,{chatId:t,children:e=>{let{messageList:r,isLoading:l,loadMore:i,hasNextPage:a}=e;return(0,h.Y)(ix,{messageList:r,isLoading:l,loadMore:i,hasNextPage:a,isSupportMiniChat:n},t)}})},ix=(0,g.memo)(e=>{let{messageList:t,isLoading:n,loadMore:r,hasNextPage:l,isSupportMiniChat:i}=e,[a,o]=(0,g.useState)(!1);return(0,h.Y)(iu,{messageList:t,setReady:o,ready:a,children:e=>{let{scrollRef:s,bottomRef:c}=e;return(0,h.FD)(h.FK,{children:[(0,h.FD)("div",{css:ib.scrollContainer,ref:s,children:[(0,h.Y)(id,{skip:n||!a||!l,setReady:o,loadMore:r,scrollRef:s}),(0,h.Y)(is,{isLoading:n,list:t}),(0,h.Y)("div",{css:ib.bottom,ref:c})]}),(0,h.Y)(ig,{bottomRef:c,isSupportMiniChat:i})]})}})});ix.displayName="InnerMessageArea";let ib={scrollContainer:(0,m.AH)({width:"100%",display:"flex",flexDirection:"column",flexGrow:1,height:"100%",overflowY:"auto",padding:"0 12px",alignItems:"center","::-webkit-scrollbar-thumb":{backgroundColor:"var(--outline_active)",borderRadius:"999px"},"::-webkit-scrollbar-track":{backgroundColor:"transparent"},"::-webkit-scrollbar-corner":{backgroundColor:"transparent"},"::-webkit-scrollbar":{width:"6px",height:"6px",display:"block"},msOverflowStyle:"auto",scrollbarColor:"var(--outline_active) transparent",scrollbarWidth:"thin","@supports (hanging-punctuation: first) and (font: -apple-system-body) and (-webkit-appearance: none)":{scrollbarWidth:"auto"},[v.mq.mobile]:{overflowX:"hidden"}}),bottom:(0,m.AH)({width:"100%",height:"60px",flexShrink:0,marginBottom:1})}},48154:(e,t,n)=>{n.d(t,{f:()=>c});var r,l=n(36868),i=n(87267),a=n(53239);function o(){return(o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}let s=function(e){return a.createElement("svg",o({xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 24 24"},e),r||(r=a.createElement("path",{fillRule:"evenodd",d:"M3.987 5.998a3 3 0 0 1 3-3H12.6a2 2 0 0 1 1.414.586l5.414 5.414a2 2 0 0 1 .586 1.414v3.59H20V18a3 3 0 0 1-3 3H9.013v.002H6.987a3 3 0 0 1-3-3zm10.02.408v3.58h3.58zM18 11.986h-3.994a2 2 0 0 1-2-2V5H7a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1z",clipRule:"evenodd"})))},c=e=>{var t;let{width:n="24px",height:r="24px",...a}=e;return(0,l.Y)(s,{width:n,height:r,...a,...(0,i.u$)()({fill:null!=(t=null==a?void 0:a.fill)?t:"icon_primary"})})}},48253:(e,t,n)=>{n.d(t,{v:()=>r});let r=e=>["v1","churn",e,"messages"]},53280:(e,t,n)=>{n.d(t,{A:()=>m});var r,l=n(86739),i=n(36868),a=n(61844),o=n(21339),s=n(70715),c=n(87267),d=n(53239);function u(){return(u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}let p=function(e){return d.createElement("svg",u({xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 24 24"},e),r||(r=d.createElement("path",{fillRule:"evenodd",d:"M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10m-6-4H8v8h8z",clipRule:"evenodd"})))},h=e=>{var t;let{width:n="24px",height:r="24px",...l}=e;return(0,i.Y)(p,{width:n,height:r,...l,...(0,c.u$)()({fill:null!=(t=null==l?void 0:l.fill)?t:"icon_primary"})})};function g(){let e=(0,l._)(["\n        button {\n          width: 32px;\n          height: 32px;\n        }\n      "]);return g=function(){return e},e}let m=e=>{let{onClick:t}=e;return(0,i.Y)(o.t,{width:"32px",height:"32px",css:(0,a.AH)(g()),children:(0,i.Y)(s.K,{type:"button",onClick:t,shape:"circle",size:"medium",color:"icon_primary_invert",backgroundColor:"icon_primary",icon:(0,i.Y)(h,{})})})}},54924:(e,t,n)=>{n.d(t,{M:()=>r});let r=(0,n(51837).eU)({message:""});r.debugLabel="@/src/shared/web2/utils-web2-atoms/messageFormStateAtom"}
1,60552:(e,t,n)=>{n.d(t,{s:()=>c});var r,l=n(36868),i=n(87267),a=n(53239);function o(){return(o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}let s=function(e){return a.createElement("svg",o({xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 25 25"},e),r||(r=a.createElement("path",{fillRule:"evenodd",d:"M8.58 14.437a25 25 0 0 1 0-4H4.752a8 8 0 0 0-.252 2c0 .69.088 1.36.252 2zm.253 2H5.57a8.02 8.02 0 0 0 4.313 3.562c-.449-.97-.81-2.185-1.05-3.562m2.034 0h3.266c-.173.889-.4 1.675-.661 2.328-.307.766-.621 1.25-.868 1.512q-.06.063-.104.1a2 2 0 0 1-.104-.1c-.247-.261-.561-.746-.868-1.512a13 13 0 0 1-.661-2.328m3.546-2h-3.826a23 23 0 0 1-.087-2q0-1.043.087-2h3.826q.085.957.087 2 0 1.043-.087 2m1.754 2c-.24 1.377-.601 2.592-1.05 3.562a8.02 8.02 0 0 0 4.313-3.562zm4.081-2H16.42a25 25 0 0 0 0-4h3.828c.165.64.252 1.31.252 2a8 8 0 0 1-.252 2m-8.72-8.328c-.26.653-.488 1.44-.661 2.328h3.266c-.173-.888-.4-1.675-.661-2.328-.307-.766-.621-1.25-.868-1.512a2 2 0 0 0-.104-.1 2 2 0 0 0-.104.1c-.247.261-.561.746-.868 1.512m4.64 2.328h3.262a8.03 8.03 0 0 0-4.312-3.562c.448.97.809 2.185 1.05 3.562m-10.598 0h3.263c.24-1.377.601-2.592 1.05-3.562A8.03 8.03 0 0 0 5.57 8.437m6.93-6c5.523 0 10 4.477 10 10s-4.477 10-10 10-10-4.477-10-10 4.477-10 10-10",clipRule:"evenodd"})))},c=e=>{var t;let{width:n="24px",height:r="24px",...a}=e;return(0,l.Y)(s,{width:n,height:r,...a,...(0,i.u$)()({fill:null!=(t=null==a?void 0:a.fill)?t:"icon_primary"})})}},60651:(e,t,n)=>{n.d(t,{d:()=>s});var r=n(36868),l=n(53239),i=n(14634),a=n(35015),o=n(51207);let s=e=>{let{as:t,placeholder:n,error:s,...c}=e,d=(0,l.useRef)(null),u=null!=n?n:(0,r.Y)(o.E,{position:"absolute",top:0,right:0,borderRadius:"0"}),p=null!=s?s:(0,r.Y)(a.C,{width:c.width,height:c.height,borderRadius:"0"}),[h,g]=(0,l.useState)(!0),[m,f]=(0,l.useState)(!1),v=(0,l.useCallback)(e=>{var t;f(!0),g(!1),null==(t=c.onError)||t.call(c,e)},[c]),y=(0,l.useCallback)(e=>{var t;g(!1),null==(t=c.onLoad)||t.call(c,e)},[c]);return((0,l.useEffect)(()=>{if(d.current&&d.current.complete)return 0===d.current.naturalWidth?f(!0):g(!1)},[]),m)?p:(0,r.FD)(i.a,{position:"relative",width:c.width,height:c.height,overflow:"hidden",style:c.style,children:[(0,r.Y)(t||"img",{onError:v,onLoad:y,...c,src:c.src,alt:c.alt,ref:d}),h&&u]})}},64046:(e,t,n)=>{n.d(t,{N:()=>c});var r,l=n(36868),i=n(87267),a=n(53239);function o(){return(o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}let s=function(e){return a.createElement("svg",o({xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 24 24"},e),r||(r=a.createElement("path",{fillRule:"evenodd",d:"M14 5h-4a6 6 0 0 0-3.642 10.77q-.002 0-.135.524c-.128.508-.349 1.38-.664 2.6L8.712 17H14a6 6 0 0 0 0-12M2 11c0 2.093.803 3.997 2.117 5.423L3.03 20.757a1 1 0 0 0 1.486 1.1l4.792-2.855H14A8 8 0 0 0 22 11a8 8 0 0 0-8-8h-4a8 8 0 0 0-8 8m11-1V7h-2v3H8v2h3v3h2v-3h3v-2z",clipRule:"evenodd"})))},c=e=>{var t;let{width:n="24px",height:r="24px",...a}=e;return(0,l.Y)(s,{width:n,height:r,...a,...(0,i.u$)()({fill:null!=(t=null==a?void 0:a.fill)?t:"icon_primary"})})}},66760:(e,t,n)=>{n.d(t,{s:()=>c});var r,l=n(36868),i=n(87267),a=n(53239);function o(){return(o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}let s=function(e){return a.createElement("svg",o({xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 25 25"},e),r||(r=a.createElement("path",{fillRule:"evenodd",d:"M19.5 6.78V4.437h2v4.5a1.5 1.5 0 0 1-1.5 1.5h-4.5v-2h2.745a7 7 0 1 0 1.255 4h2a9 9 0 1 1-2-5.657",clipRule:"evenodd"})))},c=e=>{var t;let{width:n="24px",height:r="24px",...a}=e;return(0,l.Y)(s,{width:n,height:r,...a,...(0,i.u$)()({fill:null!=(t=null==a?void 0:a.fill)?t:"icon_primary"})})}},69006:(e,t,n)=>{n.d(t,{I:()=>l,p:()=>r});let[r,l]=(0,n(97220).FF)("ChatSidePanelInfoContext")}
1,70488:(e,t,n)=>{n.d(t,{d:()=>s});var r=n(86739),l=n(36868),i=n(61844),a=n(21339);function o(){let e=(0,r._)(["\n        display: flex;\n        justify-content: center;\n        align-items: center;\n      "]);return o=function(){return e},e}let s=e=>{let{size:t=20,url:n}=e;return(0,l.Y)(a.t,{width:"".concat(t,"px"),height:"".concat(t,"px"),overflow:"hidden",borderRadius:"".concat(t,"px"),backgroundColor:"surface_elevated",flexShrink:0,border:"1px solid",borderColor:"outline_primary",css:(0,i.AH)(o()),children:(0,l.Y)("img",{width:"100%",height:"100%",src:n,alt:"search-favicon",style:{objectFit:"cover"}})})}},71357:(e,t,n)=>{n.d(t,{V:()=>i});var r=n(53239),l=n(34568);let i=e=>{let{chatId:t}=e,{data:n}=(0,l.H)({chatId:t});return{getLastMessage:(0,r.useCallback)(()=>{if(!n)return;let e=n.pages.flatMap(e=>e.list);return e.length>0?e[0]:void 0},[n])}}},71676:(e,t,n)=>{n.d(t,{k:()=>s});var r=n(12279),l=n(64208),i=n(23380),a=n(14112),o=n(95633);function s(e){var t;let{chatId:n,children:s}=e,c=(0,o.md)(a.Q),{flag:d}=(0,l._P)("supporter-role"),{data:u}=(0,r.I)({...(0,i.Uyz)({path:{chatId:null!=n?n:""}}),enabled:d});return s({role:null!=(t=null==u?void 0:u.supporterRole)?t:c})}},73761:(e,t,n)=>{n.d(t,{t:()=>u});var r=n(86739),l=n(36868),i=n(53239),a=n(61844),o=n(14634),s=n(37185),c=n(54065);function d(){let e=(0,r._)(["\n          transition: transform 0.3s ease;\n          transform: translateX(-","%);\n        "]);return d=function(){return e},e}let u=e=>{let{value:t,type:n="fullWidth",onChange:r,children:u,fullHeight:p}=e,h=(0,i.useRef)([]),[g,m]=(0,i.useState)({left:0,width:0}),f=i.Children.toArray(u).filter(i.isValidElement),v=f.findIndex(e=>e.props.value===t);return(0,i.useEffect)(()=>{let e=h.current[v];if(e){let{offsetLeft:t,offsetWidth:n}=e;m({left:t,width:n})}},[t,v,u]),(0,l.Y)(o.a,{width:"100%",overflow:"hidden",height:p?"100%":void 0,children:(0,l.FD)(s.Tk,{height:p?"100%":void 0,children:[(0,l.FD)(o.a,{position:"relative",borderBottom:"1px solid",borderColor:"outline_primary",children:[(0,l.Y)(s.zt,{width:"100%",children:f.map((e,t)=>{let{value:i,title:a}=e.props;return(0,l.Y)(o.a,{as:"button",ref:e=>h.current[t]=e,onClick:()=>r(i),position:"relative",display:"flex",justifyContent:"center",alignItems:"center",p:"8px 12px",..."fullWidth"===n?{flex:1}:{width:"fit-content"},children:"string"==typeof a?(0,l.Y)(c.Z,{typo:"Subtitle4",children:a}):a},i)})}),(0,l.Y)(o.a,{position:"absolute",bottom:0,height:"2px",backgroundColor:"icon_primary",style:{transition:"left 0.3s ease, width 0.3s ease",left:g.left,width:g.width}})]}),(0,l.Y)(o.a,{width:"100%",overflow:"hidden",height:p?"100%":void 0,children:(0,l.Y)(o.a,{display:"flex",width:"".concat(100*f.length,"%"),height:p?"100%":void 0,css:(0,a.AH)(d(),100*v/f.length),children:f.map(e=>(0,l.Y)(o.a,{flex:"0 0 auto",width:"".concat(100/f.length,"%"),children:e.props.panel},e.props.value))})})]})})};u.Item=e=>null},76440:(e,t,n)=>{n.d(t,{A:()=>y,d:()=>x});var r=n(36868),l=n(53239),i=n(13037),a=n(93957),o=n(13145),s=n(94539),c=n(12693),d=n(19334),u=n(89498),p=n(54924),h=n(95633),g=n(64088),m=n(34223),f=n(20915);let v=(0,l.createContext)({generatingStatus:"end",generate:async()=>void 0,stopGenerate:()=>void 0,endGenerate:()=>void 0,messageQueue:null}),y=e=>{let{chatId:t,role:n}=e,{connected:y,connect:x,disconnect:b,emitWithAck:_,on:Y,off:w,removeAllListeners:k}=(0,d.t)(),C=(0,l.useRef)(!1),[A,F]=(0,l.useState)("end"),{invalidateChatCache:I,invalidateAttachmentCache:D,syncMessage:S}=(0,f.t)({chatId:t}),R=(0,h.Xr)(p.M),{trackEvent:M}=(0,c.jt)(),{sendAirbridgeEvent:T}=(0,o.rT)(),{updateChatRoomStatus:E}=(0,m.P)(),{messageQueue:j,createMessageQueue:z,destroyMessageQueue:B,getMessageQueue:L}=(0,a.q)(),H=(0,l.useCallback)(function(){var e;let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(F("end"),E("ready"),I(),w("endChat"),t)return void B();null==(e=L())||e.scheduleDestroy()},[I,E]),P=(0,l.useCallback)(async e=>{C.current&&k();try{var r,l,a,o;if(y||(b(),x()),"streaming"===A)return;let d=(0,g.A)(),{referenceAttachmentIds:p,originalAttachmentIds:h,message:m,toolId:f,toolReferenceId:v,reroll:w=!1,trendId:k,forceSearch:C}=e,I=!!(C||k),j=!!f,B=null!=(l=null==h?void 0:h.length)?l:Number(null!=(r=null==p?void 0:p.length)?r:0)+ +!!f,L={chatId:t,content:m,clientHeaders:s.H1,referenceAttachmentIds:p,originalAttachmentIds:h,toolId:f,trendId:k,toolReferenceId:v,reroll:w,forceSearch:I,requestId:d},P={service_detail:"chat",feature_name:"chat",chat_id:t,is_minichat_re:j,fe_request_id:d,open_time:Date.now(),regenerate:w,attachment_count:B,force_search:I,role_name:null!=(a=null==n?void 0:n.role)?a:"DEFAULT",custom_role_id:(null==n?void 0:n.role)==="CUSTOM"?n.id:void 0};M("click_generate_btn",{service_detail:"chat",feature_name:"chat",chat_id:t,force_search:I,fe_request_id:d,role_name:null!=(o=null==n?void 0:n.role)?o:"DEFAULT",custom_role_id:(null==n?void 0:n.role)==="CUSTOM"?n.id:void 0}),F("streaming"),E("streaming");let q=await _("startChat",L);if(z(),function(e){return"userMessage"in e&&"assistantMessage"in e}(q)){let{userMessage:e,assistantMessage:n}=q;w?S({assistantMessage:n,key:(0,i.p)(t)}):S({assistantMessage:n,userMessage:e,key:(0,i.p)(t)}),D(),M("generate_open",{...P,msg_id:null==n?void 0:n.id}),Y("disconnectServer",()=>{M("generate_fail",{...P,msg_id:n.id}),H(!0)}),Y("generationError",()=>{var t;u.oR.alert("일시적으로 메시지 생성에 실패했어요. 잠시 후 다시 시도해주세요."),R({message:null!=(t=null==e?void 0:e.content.text.trim())?t:"",attachments:void 0,toolAttachment:void 0}),M("generate_fail",{...P,msg_id:n.id}),H(!0)}),Y("endChat",e=>{let n={...P,is_tool_recommend:"tool_recommendation"===e.content.type,msg_id:e.id};
1M("generate_done",n),(0,c.UQ)({event:"generate_done",...n}),T("generate_done",{customAttributes:n}),S({assistantMessage:e,key:(0,i.p)(t)}),H()})}else(403===q.status||401===q.status)&&await _("enterChat",{chatId:t,clientHeaders:s.H1}),u.oR.alert("일시적으로 메시지 생성에 실패했어요. 잠시 후 다시 시도해주세요."),R({message:e.message,attachments:void 0,toolAttachment:void 0}),H(!0)}catch(t){u.oR.alert("일시적으로 메시지 생성에 실패했어요. 잠시 후 다시 시도해주세요."),R({message:e.message,attachments:void 0,toolAttachment:void 0}),H(!0)}finally{"streaming"===A&&F("end"),C.current=!0}},[k,y,A,t,null==n?void 0:n.role,M,E,_,z,b,x,D,Y,S,H,R,c.UQ,T]),q=(0,l.useCallback)(async()=>{H(!0),M("stop_generate",{service_detail:"chat",feature_name:"chat",chat_id:t,role_name:null==n?void 0:n.role}),await _("abortChat",{chatId:t,clientHeaders:s.H1}),I()},[t,_,H,I]),Z=(0,l.useMemo)(()=>({generatingStatus:A,generate:P,stopGenerate:q,endGenerate:H,messageQueue:j}),[H,P,A,q,j]);return(0,r.Y)(v.Provider,{value:Z,children:e.children})},x=()=>{let e=(0,l.useContext)(v);if(!e)throw Error("GenerateMessageContext 초기화 되지 않았습니다.");return e}},83080:(e,t,n)=>{n.d(t,{Z:()=>l,w:()=>r});let[r,l]=(0,n(97220).FF)("ChatSidePanelActionContext")},84494:(e,t,n)=>{n.d(t,{l:()=>a});var r=n(53239),l=n(91365),i=n(34568);let a=e=>{let{chatId:t,children:n}=e,[a,o]=(0,r.useState)(),s=(0,l.i)({chatId:t}),c=(0,r.useMemo)(()=>{var e;return null!=(e=null==s?void 0:s.attachments)?e:[]},[s]),{currentUserMessage:d}=(e=>{let{chatId:t}=e,{data:n}=(0,i.H)({chatId:t});return{currentUserMessage:(0,r.useMemo)(()=>{var e,t;if(!n||0===n.pages.length)return;let r=(n?null==n||null==(t=n.pages)||null==(e=t.flatMap)?void 0:e.call(t,e=>e.list):[]).filter(e=>(null==e?void 0:e.role)==="user");if(r.length)return r[0]},[n])}})({chatId:t});return(0,r.useEffect)(()=>{var e,t;if(!d)return;let n="file"===d.content.type?d.content:void 0,r=[...null!=(e=null==n?void 0:n.referenceAttachmentIds)?e:[],...null!=(t=null==n?void 0:n.originalAttachmentIds)?t:[]];(null==c?void 0:c.length)?o(c.filter(e=>null==r?void 0:r.includes(e.id)).map(e=>({type:e.type,id:e.id,fileName:"file"===e.type?e.title:e.url}))):o(void 0)},[c,d]),n({fixedAttachments:a,resetFixedAttachments:()=>{o([])}})}},84568:(e,t,n)=>{n.d(t,{B:()=>s,g:()=>c});var r=n(36868),l=n(53239),i=n(94539),a=n(19334);let o=(0,l.createContext)(null),s=e=>{let{chatId:t,isChatInitiation:n=!1,children:s}=e,[c,d]=(0,l.useState)(n),u=(0,l.useRef)(!1),{connected:p,emitWithAck:h,connect:g}=(0,a.t)(),m=(0,l.useRef)(t),f=(0,l.useCallback)(async()=>{if(u.current||c)return;u.current=!0,p||g();let e=await h("enterChat",{chatId:t,clientHeaders:i.H1});u.current=!1,e.chatId&&d(!0)},[t,h,g,p,c]);(0,l.useEffect)(()=>{d(p)},[p]),(0,l.useEffect)(()=>{p&&f()},[p,f]),(0,l.useEffect)(()=>{if(m.current!==t){d(!1),f(),m.current=t;return}},[t,f]);let v=(0,l.useCallback)(()=>{h("enterChat",{chatId:t,clientHeaders:i.H1})},[t,h]);(0,l.useEffect)(()=>(window.addEventListener("focus",v),c||f(),()=>{window.removeEventListener("focus",v)}),[v,f,c]);let y=(0,l.useMemo)(()=>({isEnterChatRoom:c}),[c]);return(0,r.Y)(o.Provider,{value:y,children:s})},c=()=>{let e=(0,l.useContext)(o);if(!e)throw Error("ChatRoomStatusContext 초기화 되지 않았습니다.");return e}},85204:(e,t,n)=>{n.d(t,{e:()=>c});var r,l=n(36868),i=n(87267),a=n(53239);function o(){return(o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}let s=function(e){return a.createElement("svg",o({xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 24 25"},e),r||(r=a.createElement("path",{fillRule:"evenodd",d:"M12 2.437a1 1 0 0 1 .89.543l2.603 5.077 5.663.89a1 1 0 0 1 .795.675.99.99 0 0 1-.244 1.01l-4.055 4.028.898 5.628a.99.99 0 0 1-.4.96c-.303.219-.706.25-1.041.08l-5.11-2.587-5.108 2.588c-.335.17-.737.138-1.042-.082a.99.99 0 0 1-.4-.96l.899-5.627-4.055-4.029a.99.99 0 0 1-.244-1.01 1 1 0 0 1 .795-.674l5.662-.89 2.602-5.077A1 1 0 0 1 12 2.437",clipRule:"evenodd"})))},c=e=>{var t;let{width:n="24px",height:r="24px",...a}=e;return(0,l.Y)(s,{width:n,height:r,...a,...(0,i.u$)()({fill:null!=(t=null==a?void 0:a.fill)?t:"icon_primary"})})}},85607:(e,t,n)=>{n.d(t,{M:()=>i});var r=n(34616),l=n(2186);let i=e=>{let{children:t,generate:n,chatId:i}=e,{attachments:a}=(e=>{var t;let{chatId:n}=e,i=(0,r.jE)(),{key:a}=(0,l.X)(),o=i.getQueryData(a(n));return{attachments:null!=(t=null==o?void 0:o.attachments)?t:[]}})({chatId:i}),o=null==a?void 0:a.map(e=>{let{id:t}=e;return t});return t({submitMessage:e=>{var t,r;let{message:l,attachments:i,toolAttachment:a,trendId:s,forceSearch:c}=e,d=null==i?void 0:i.map(e=>e.id),u=null==d?void 0:d.filter(e=>null==o?void 0:o.includes(e)),p=null==d?void 0:d.filter(e=>!(null==o?void 0:o.includes(e)));n({message:l,type:["file","url"].includes(null!=(r=null==i||null==(t=i[0])?void 0:t.type)?r:"")?"file":"text",trendId:s,referenceAttachmentIds:(null==u?void 0:u.length)?u:void 0,originalAttachmentIds:(null==p?void 0:p.length)?p:void 0,toolId:null==a?void 0:a.toolId,toolReferenceId:null==a?void 0:a.toolReferenceId,forceSearch:c})}})}}
1,90664:(e,t,n)=>{n.d(t,{d:()=>o});var r=n(36868),l=n(53239),i=n(83080),a=n(69006);function o(e){let{isMiniChat:t,children:n}=e,[o,s]=(0,l.useState)(!1),[c,d]=(0,l.useState)(null),u=(0,l.useCallback)(e=>{d(e),s(!0)},[]),p=(0,l.useCallback)(()=>{d(null),s(!1)},[]),h=(0,l.useMemo)(()=>({mount:u,unmount:p,opened:o,content:c}),[u,p,o,c]);return(0,r.Y)(a.I,{value:{isMiniChat:t},children:(0,r.Y)(i.Z,{value:h,children:n})})}},91365:(e,t,n)=>{n.d(t,{i:()=>a});var r=n(12279),l=n(20033),i=n(2186);let a=e=>{var t;let{isAuth:n}=(0,l.A)(),{chatId:a,skip:o=!1}=e,s=!o&&n,{key:c,fetcher:d}=(0,i.X)(),{data:u,isLoading:p,refetch:h}=(0,r.I)({queryKey:s?c(a):[],queryFn:()=>d({chatId:a}),enabled:s,refetchOnMount:!1});return{attachments:null!=(t=null==u?void 0:u.attachments)?t:[],refetch:h,isLoading:p}}},93957:(e,t,n)=>{n.d(t,{q:()=>d});var r=n(53239),l=n(37352);class i{on(e,t){let n=this.eventListeners.get(e)||[];n.push(t),this.eventListeners.set(e,n)}off(e,t){let n=this.eventListeners.get(e)||[],r=n.indexOf(t);r>-1&&n.splice(r,1)}emit(e,t){(this.eventListeners.get(e)||[]).forEach(n=>{try{n(t)}catch(t){console.error("Error in MessageQueue event listener for ".concat(e,":"),t)}})}addMessage(e){if(!e)return;let t=(0,l.DE)(e);t.length>this.tokens.length&&(this.tokens=t,this.isActive||this.start())}start(){this.isActive||(this.isActive=!0,this.intervalId=window.setInterval(()=>{this.processQueue()},i.INTERVAL))}processQueue(){if(this.displayedTokenCount<this.tokens.length){this.displayedTokenCount++;let e=this.tokens.slice(0,this.displayedTokenCount).join("");this.emit("message",e)}else this.isDestroyScheduled&&(this.stop(),this.emit("queueEnd",void 0))}stop(){window.clearInterval(this.intervalId),this.isActive=!1}reset(){this.stop(),this.tokens=[],this.displayedTokenCount=0}flushQueue(){if(this.displayedTokenCount<this.tokens.length){this.displayedTokenCount=this.tokens.length;let e=this.tokens.join("");this.emit("message",e),this.isDestroyScheduled&&(this.stop(),this.emit("queueEnd",void 0))}}getStatus(){return{isActive:this.isActive,totalTokens:this.tokens.length,displayedTokens:this.displayedTokenCount}}destroy(){this.stop(),this.eventListeners.clear(),"undefined"!=typeof document&&this.visibilityChangeHandler&&document.removeEventListener("visibilitychange",this.visibilityChangeHandler)}scheduleDestroy(){this.isDestroyScheduled=!0}constructor(){this.tokens=[],this.displayedTokenCount=0,this.intervalId=0,this.isActive=!1,this.isDestroyScheduled=!1,this.eventListeners=new Map,this.eventListeners.set("message",[]),this.eventListeners.set("queueEnd",[]),this.visibilityChangeHandler=()=>{!document.hidden&&this.isActive&&this.flushQueue()},"undefined"!=typeof document&&document.addEventListener("visibilitychange",this.visibilityChangeHandler)}}i.INTERVAL=20;var a=n(51837),o=n(95633),s=n(72195);let c=(0,a.eU)(null);c.debugLabel="@/src/shared/chat-wrtn/utils-atoms/messageQueueAtom";let d=()=>{let[e,t]=(0,o.fp)(c),n=(0,s.yF)(e=>e(c));return{messageQueue:e,createMessageQueue:(0,r.useCallback)(()=>{let e=new i;e.on("queueEnd",()=>{e.destroy(),t(null)}),t(e)},[]),destroyMessageQueue:(0,r.useCallback)(()=>{let e=n();null==e||e.flushQueue(),null==e||e.destroy(),t(null)},[]),getMessageQueue:n}}},94085:(e,t,n)=>{n.d(t,{o:()=>e_});var r,l,i,a=n(36868),o=n(53239),s=n(14634),c=n(21778),d=n(87328),u=n(77336),p=n(5358),h=n(48352),g=n(74685),m=n(86739),f=n(61844),v=n(54065),y=n(69471),x=n(37185),b=n(70715),_=n(8843),Y=n(71342),w=n(32875),k=n(49569),C=n(24422),A=n(6253),F=n(11872),I=n(79980),D=n(37584),S=n(32320),R=n(33798),M=n(68769),T=n(24024),E=n(99177),j=n(30395),z=n(90277),B=n(28531),L=n(49107),H=n(13299),P=n(93048),q=n(67793),Z=n(52024),N=n(68226),O=n(88366),K=n(72847),V=n(83279),W=n(80082),Q=n(19485),$=n(17951),U=n(24046),X=n(66797),G=n(91366),J=n(90690),ee=n(63205),et=n(22563),en=n(87659),er=n(24853),el=n(57867),ei=n(23879),ea=n(90876),eo=n(77565),es=n(23998),ec=n(92992),ed=n(85826),eu=n(33252),ep=n(79308);[{key:"apache",language:k.A},{key:"armasm",language:C.A},{key:"bash",language:A.A},{key:"c",language:F.A},{key:"coffeescript",language:I.A},{key:"cpp",language:D.A},{key:"csharp",language:S.A},{key:"css",language:R.A},{key:"d",language:M.A},{key:"diff",language:T.A},{key:"go",language:E.A},{key:"handlebars",language:j.A},{key:"haskell",language:z.A},{key:"http",language:B.A},{key:"ini",language:L.A},{key:"java",language:H.A},{key:"javascript",language:P.A},{key:"json",language:q.A},{key:"julia",language:Z.A},{key:"kotlin",language:N.A},{key:"less",language:O.A},{key:"lua",language:K.A},{key:"makefile",language:V.A},{key:"markdown",language:W.A},{key:"nginx",language:Q.A},{key:"objectivec",language:$.A},{key:"perl",language:U.A},{key:"php",language:X.A},{key:"plaintext",language:G.A},{key:"properties",language:J.A},{key:"python",language:ee.A},{key:"r",language:et.A},{key:"ruby",language:en.A},{key:"rust",language:er.A},{key:"scala",language:el.A},{key:"scss",language:ei.A},{key:"shell",language:ea.A},{key:"sql",language:eo.A},{key:"swift",language:es.A},{key:"typescript",language:ec.A},{key:"x86asm",language:ed.A},{key:"xml",language:eu.A},{key:"yaml",language:ep.A}
1].forEach(e=>{Y.A.registerLanguage(e.key,e.language)});let eh=e=>{let{onClickCode:t,className:n,...r}=e,l=/language-(\w+)/.exec(n||"");return l?(0,a.FD)(s.a,{width:"100%",borderRadius:"8px",overflow:"hidden",children:[(0,a.Y)(s.a,{backgroundColor:"surface_tertiary",p:"6px 12px 6px 16px",children:(0,a.FD)(x.zt,{justifyContent:"space-between",alignItems:"center",children:[(0,a.Y)(v.Z,{typo:"Body7",color:"text_tertiary",children:l&&(null==l?void 0:l.length)>1?l[1]:""}),(0,a.Y)(b.K,{onClick:e=>(e=>{var n,r,l,i;let a=null!=(i=null==(l=e.currentTarget.parentElement)||null==(r=l.parentElement)||null==(n=r.nextElementSibling)?void 0:n.textContent)?i:"";window.navigator.clipboard.writeText(a),null==t||t()})(e),icon:(0,a.Y)(_.Q,{}),size:"small",buttonStyle:"ghost"})]})}),(0,a.Y)(Y.A,{lineProps:{style:{wordBreak:"break-all",whiteSpace:"pre-wrap"}},style:w.A,language:l&&(null==l?void 0:l.length)>1?l[1]:"javascript",highlighter:"hljs",wrapLongLines:!0,customStyle:{whiteSpace:"pre-wrap",padding:"10px 16px"},children:r.children})]}):(0,a.Y)("code",{className:n,style:{whiteSpace:"break-spaces"},...r})};function eg(){let e=(0,m._)(["\n        list-style-position: outside;\n        list-style-type: disc;\n        @media (max-width: 768px) {\n          font-size: 14px;\n        }\n      "]);return eg=function(){return e},e}function em(){let e=(0,m._)(["\n        list-style-position: outside;\n        list-style-type: decimal;\n        @media (max-width: 768px) {\n          font-size: 14px;\n        }\n      "]);return em=function(){return e},e}function ef(){let e=(0,m._)(["\n        line-height: 160%;\n\n        ::marker {\n          position: absolute;\n          left: -5px;\n          margin-right: 5px;\n        }\n\n        @media (max-width: 768px) {\n          font-size: 14px;\n        }\n      "]);return ef=function(){return e},e}function ev(){let e=(0,m._)(["\n        //margin: 12px 0;\n        border-collapse: collapse;\n        box-shadow: 0 0 0 1px ",";\n        @media (max-width: 768px) {\n          font-size: 14px;\n        }\n      "]);return ev=function(){return e},e}function ey(){let e=(0,m._)(["\n        td:first-of-type {\n          text-align: center;\n          vertical-align: top;\n        }\n      "]);return ey=function(){return e},e}var ex=n(58082);let eb={...ex.j,attributes:{...ex.j.attributes,div:[...(null==(r=ex.j.attributes)?void 0:r.div)||[],["className","math","math-display"]],span:[...(null==(l=ex.j.attributes)?void 0:l.span)||[],["className","math","math-inline"]],code:[...(null==(i=ex.j.attributes)?void 0:i.code)||[],["className",/^language-./,"math-inline","math-display"]]}},e_=e=>{let{content:t,typo:n,onClickCode:r,noPaddingBottom:l=!1,maxLinkHighlight:i,...m}=e,x=(0,o.useRef)(0);return(0,a.Y)(s.a,{className:"markdown-container","data-test-id":null==m?void 0:m["data-test-id"],children:(0,a.Y)(c.oz,{remarkPlugins:[[h.A,{singleTilde:!1}],g.A],rehypePlugins:[u.A,[p.A,eb],d.A],components:{...(e=>{let{typo:t="Body4",linkCount:n=0,maxLinkHighlight:r,noPaddingBottom:l}=e;return{div:e=>{let{...n}=e;return(0,a.Y)(s.a,{...n,typo:t,color:"text_primary"})},p:e=>{let{...n}=e,{children:r}=n;return r&&r[0]&&1===r.length&&r[0].props&&r[0].props.src?r:(0,a.Y)(v.Z,{...n,typo:t,whiteSpace:"pre-line",color:"text_primary",css:{paddingBottom:l?0:"16px"}})},span:e=>{let{...t}=e;return(0,a.Y)(s.a,{as:"span",...t,color:"text_primary"})},ul:e=>{let{...n}=e;return(0,a.Y)(s.a,{...n,as:"ul",typo:t,color:"text_primary",paddingLeft:"20px",paddingY:"4px",css:(0,f.AH)(eg())})},ol:e=>{let{...n}=e;return(0,a.Y)(s.a,{...n,as:"ol",typo:t,color:"text_primary",paddingLeft:"20px",paddingY:"8px",css:(0,f.AH)(em())})},li:e=>{let{...n}=e;return(0,a.Y)(s.a,{...n,as:"li",typo:t,color:"text_primary",css:(0,f.AH)(ef())})},table:e=>{let{...t}=e;return(0,a.Y)(s.a,{...t,as:"table",borderRadius:"5px",borderStyle:"hidden",css:e=>(0,f.AH)(ev(),e.color.outline_secondary)})},thead:e=>{let{...n}=e;return(0,a.Y)(s.a,{...n,as:"thead",typo:t,color:"text_primary",backgroundColor:"surface_tertiary"})},tbody:e=>{let{...n}=e;return(0,a.Y)(s.a,{...n,as:"tbody",typo:t,color:"text_primary",css:(0,f.AH)(ey())})},img:e=>{let{...t}=e;return(0,a.Y)("img",{...t,width:"100%",height:"auto",style:{objectFit:"cover"},alt:"markdown-image"})},tr:e=>{let{...t}=e;return(0,a.Y)(s.a,{...t,as:"tr"})},th:e=>{let{...t}=e;return(0,a.Y)(s.a,{...t,as:"th",padding:"6px 10px",border:"1px solid",borderColor:"outline_secondary"})},td:e=>{let{...t}=e;return(0,a.Y)(s.a,{...t,as:"td",padding:"6px 10px",border:"1px solid",borderColor:"outline_secondary"})},h1:e=>{let{...t}=e;return(0,a.Y)(v.Z,{...t,as:"h1",color:"text_primary",typo:"Subtitle1",pb:"16px"})},h2:e=>{let{...t}=e;return(0,a.Y)(v.Z,{...t,as:"h2",color:"text_primary",typo:"Subtitle2",pb:"16px"})},h3:e=>{let{...t}=e;return(0,a.Y)(v.Z,{...t,as:"h3",color:"text_primary",typo:"Subtitle3",pb:"16px"})},h4:e=>{let{...t}=e;return(0,a.Y)(v.Z,{...t,as:"h4",color:"text_primary",typo:"Subtitle4"})},h5:e=>{let{...t}=e;return(0,a.Y)(v.Z,{...t,as:"h5",color:"text_primary",typo:"Subtitle6"})},h6:e=>{let{...t}=e;return(0,a.Y)(v.Z,{...t,as:"h6",color:"text_primary",typo:"Subtitle7"})},strong:e=>{let{...n}=e;return(0,a.Y)(v.Z,{...n,as:"strong",typo:t,color:"text_primary",style:{fontWeight:"600"}})},blockquote:e=>{let{...t}=e;return(0,a.Y)(s.a,{...t,as:"blockquote",color:"text_secondary",paddingLeft:"16px",borderLeft:"2px s
1olid",borderColor:"outline_secondary"})},a:e=>{let{...l}=e,{href:i}=l;return r&&n>r?(0,a.Y)(v.Z,{...l,as:"span",typo:t,color:"text_primary"}):(0,a.Y)(y.o,{onClick:()=>{i&&window.open(i,"_blank","noopener noreferrer")},children:(0,a.Y)(v.Z,{...l,as:"span",typo:t,color:"accent_primary"})})},code:e=>{let{...t}=e;return(0,a.Y)(eh,{...t})},description:e=>{let{...t}=e;return(0,a.Y)(s.a,{as:"dl",width:"100%",...t})}}})({typo:n,noPaddingBottom:l,maxLinkHighlight:i,linkCount:x.current}),strong:e=>{let{...t}=e;return(0,a.Y)("strong",{style:{fontWeight:700},...t})},code:e=>{let{...t}=e;return(0,a.Y)(eh,{...t,onClickCode:()=>null==r?void 0:r()})}},children:t})})}},94206:(e,t,n)=>{n.d(t,{z:()=>d});var r,l,i=n(36868),a=n(87267),o=n(53239);function s(){return(s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}let c=function(e){return o.createElement("svg",s({xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 25 25"},e),r||(r=o.createElement("g",{clipPath:"url(#Heart_Stroke_svg__a)"},o.createElement("path",{fillRule:"evenodd",d:"m12.5 9.086-1.556-1.555a3.667 3.667 0 0 0-5.185 5.185l6.741 6.741 6.741-6.741a3.667 3.667 0 1 0-5.185-5.185zm8.297-3.111a5.867 5.867 0 0 1 0 8.297l-7.52 7.519a1.1 1.1 0 0 1-1.555 0l-7.519-7.52A5.867 5.867 0 0 1 12.5 5.976a5.867 5.867 0 0 1 8.297 0",clipRule:"evenodd"}))),l||(l=o.createElement("defs",null,o.createElement("clipPath",{id:"Heart_Stroke_svg__a"},o.createElement("path",{d:"M.5.437h24v24H.5z"})))))},d=e=>{var t;let{width:n="24px",height:r="24px",...l}=e;return(0,i.Y)(c,{width:n,height:r,...l,...(0,a.u$)()({fill:null!=(t=null==l?void 0:l.fill)?t:"icon_primary"})})}},99854:(e,t,n)=>{n.d(t,{F:()=>h});var r=n(36868),l=n(79800),i=n(48247),a=n(25495),o=n(30135),s=n(47219),c=n(65833),d=n(95633),u=n(83080),p=n(69006);function h(){let e=(0,l.Ub)("(max-width: 991px)"),{opened:t,content:n,unmount:h}=(0,u.w)(),{isMiniChat:f}=(0,p.p)(),v=(0,d.md)(o.Q);return e&&!f?(0,r.Y)(i.Y,{opened:t,onClose:h,renderContent:()=>(0,r.Y)("div",{css:{width:"100%"},children:(0,r.Y)("div",{css:{width:"100%",maxWidth:552,overflowY:"auto",margin:"0 auto",height:"92dvh",[a.mq.tablet]:{height:"75dvh"}},children:n})})}):f?(0,r.Y)(s.N,{children:t&&(0,r.Y)("div",{css:[{position:"absolute"},(0,a.C5)()],children:(0,r.Y)(c.P.div,{..."left"===v?g:m,transition:{damping:5,duration:.2},css:{width:"100%",height:"100%"},children:n})})}):(0,r.Y)(s.N,{children:t&&(0,r.Y)(c.P.div,{initial:{width:"0%"},animate:{width:"40%"},exit:{width:"0%"},transition:{damping:5,duration:.2},css:{height:"100%"},children:(0,r.Y)(c.P.div,{initial:{x:"100%"},animate:{x:"0%"},exit:{x:"100%"},transition:{damping:5,duration:.2},css:{width:"40vw",height:"100%",padding:"8px 8px 8px 0"},children:n})})})}let g={initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0}},m={initial:{x:"100%"},animate:{x:"0%"},exit:{x:"100%"}}}}]);
2//# sourceMappingURL=3273-0f2ddeedfbe8c79f.js.map

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.