1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[76680],{13967:(e,s,l)=>{l.d(s,{E:()=>a,gm:()=>r});var t=l(31530);let n=e=>{try{return JSON.parse(e),!0}catch(e){return!1}},a=e=>{try{var s,l,a,r,o;if(n(e)){let n=JSON.parse(e),r=null==n||null==(s=n.map(e=>e[0]))?void 0:s.join("\n");null==(a=navigator)||null==(l=a.clipboard)||l.writeText(r),t.Ay.success("Copied to Clipboard")}else null==(o=navigator)||null==(r=o.clipboard)||r.writeText(e),t.Ay.success("Copied to Clipboard")}catch(e){}},r=e=>e?e.split("-").map(e=>String.fromCodePoint(parseInt(e,16))).join(""):""},17351:(e,s,l)=>{l.d(s,{A:()=>o});var t=l(95155),n=l(71026),a=l(27731);l(12115);var r=l(52596);let o=function(e){let{checked:s,option:l,onClick:o,isRadio:i=!1}=e;return(0,t.jsxs)(n.A,{onClick:o,className:(0,r.A)("flex items-center justify-between p-1 px-2 pr-8 w-full text-left hover:bg-stone-100"),children:[(0,t.jsx)("p",{className:"text-[13px] font-medium truncate",children:l}),(0,t.jsx)("div",{className:"absolute right-0 px-2 py-1 pointer-events-none",children:(0,t.jsx)(a.A,{checked:s,isRadio:i})})]},l)}},17622:(e,s,l)=>{l.d(s,{A:()=>n});var t=l(12115);let n=e=>{let{minWidth:s,maxWidth:l,defaultWidth:n,direction:a="left",unit:r="%"}=e,[o,i]=(0,t.useState)(n),d=(0,t.useRef)(!1),c=(0,t.useRef)(null),u=(0,t.useCallback)(e=>{e.preventDefault(),d.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";let t=e=>{let t;if(!d.current||!c.current)return;let n=c.current.getBoundingClientRect();if("right"===a){let s=n.right-e.clientX;t="px"===r?s:s/n.width*100}else{let s=e.clientX-n.left;t="px"===r?s:s/n.width*100}i(Math.min(l,Math.max(s,t)))},n=()=>{d.current=!1,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",n)};document.addEventListener("mousemove",t),document.addEventListener("mouseup",n)},[s,l,a,r]);return{panelWidth:o,setPanelWidth:i,containerRef:c,handleResizeMouseDown:u}}},17979:(e,s,l)=>{l.d(s,{Fg:()=>i,dZ:()=>d,uX:()=>r});var t=l(95155),n=l(53714);let a=()=>(0,t.jsxs)("div",{className:"h-12 border-b border-stone-200 flex items-center justify-between px-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(n.E,{className:"h-5 w-5 rounded"}),(0,t.jsx)(n.E,{className:"h-4 w-32"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(n.E,{className:"h-8 w-8 rounded-full"}),(0,t.jsx)(n.E,{className:"h-8 w-8 rounded-full"})]})]}),r=()=>(0,t.jsxs)("div",{className:"h-full flex flex-col bg-white",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 pt-3 pb-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(n.E,{className:"h-4 w-4"}),(0,t.jsx)(n.E,{className:"h-4 w-16"}),(0,t.jsx)(n.E,{className:"h-4 w-12"})]}),(0,t.jsx)(n.E,{className:"h-8 w-20 rounded-md"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-4 px-4 border-b border-stone-200 pb-2",children:[(0,t.jsx)(n.E,{className:"h-4 w-28"}),(0,t.jsx)(n.E,{className:"h-4 w-20"})]}),(0,t.jsx)("div",{className:"flex-1 overflow-hidden p-4 space-y-4",children:[1,2,3,4].map(e=>(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(n.E,{className:"h-4 w-4 mt-1 rounded"}),(0,t.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,t.jsx)(n.E,{className:"h-4 w-full"}),(0,t.jsx)(n.E,{className:"h-3 w-3/4"}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(n.E,{className:"h-6 w-14 rounded"}),(0,t.jsx)(n.E,{className:"h-6 w-16 rounded"})]})]})]},e))})]}),o=()=>(0,t.jsxs)("div",{className:"h-full flex flex-col bg-white",children:[(0,t.jsxs)("div",{className:"flex-1 overflow-hidden p-4 space-y-6",children:[(0,t.jsxs)("div",{className:"flex gap-3",children:[(0,t.jsx)(n.E,{className:"h-8 w-8 rounded-full flex-shrink-0"}),(0,t.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,t.jsx)(n.E,{className:"h-4 w-3/4"}),(0,t.jsx)(n.E,{className:"h-4 w-full"}),(0,t.jsx)(n.E,{className:"h-4 w-2/3"})]})]}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)("div",{className:"space-y-2 max-w-[70%]",children:(0,t.jsx)(n.E,{className:"h-10 w-48 rounded-2xl"})})}),(0,t.jsxs)("div",{className:"flex gap-3",children:[(0,t.jsx)(n.E,{className:"h-8 w-8 rounded-full flex-shrink-0"}),(0,t.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,t.jsx)(n.E,{className:"h-4 w-full"}),(0,t.jsx)(n.E,{className:"h-4 w-5/6"}),(0,t.jsx)(n.E,{className:"h-4 w-4/5"}),(0,t.jsx)(n.E,{className:"h-4 w-2/3"})]})]})]}),(0,t.jsx)("div",{className:"p-4 border-t border-stone-100",children:(0,t.jsxs)("div",{className:"rounded-2xl border border-stone-200 p-3",children:[(0,t.jsx)(n.E,{className:"h-6 w-full mb-3"}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)(n.E,{className:"h-6 w-6 rounded"}),(0,t.jsx)(n.E,{className:"h-8 w-8 rounded-lg"})]})]})})]}),i=()=>(0,t.jsx)("div",{className:"relative h-screen w-full overflow-hidden",children:(0,t.jsxs)("div",{className:"h-screen",children:[(0,t.jsx)(a,{}),(0,t.jsx)("div",{className:"h-[calc(100%-48px)]",children:(0,t.jsx)(o,{})})]})}),d=()=>(0,t.jsxs)("div",{className:"relative h-screen w-full overflow-hidden flex flex-col",children:[(0,t.jsx)(a,{}),(0,t.jsxs)("div",{className:"flex-1 flex overflow-hidden min-h-0",children:[(0,t.jsx)("div",{className:"w-1/2 h-full border-r border-stone-200",children:(0,t.jsx)(r,{})}),(0,t.jsx)("div",{className:"w-1/2 h-full",children:(0,t.jsx)(o,{})})]})]})},31740:(e,s,l)=>{l.d(s,{A:()=>D});var t=l(95155),n=l(589),a=l(12115),r=l(98501),o=l(39440),i=l(43372),d=l(56932),c=l(52596),u=l(71026),x=l(16075),h=l(17485),m=l(9739),p=l(78046),f=l(27043);let v=function(){let e=(0,f.useTranslations)();return(0,t.jsxs)("div",{className:"min-h-[40vh] flex flex-col justify-center items-center gap-3",children:[(0,t.jsx)(p.A,{className:"w-7 h-7 text-stone-400"}),(0,t.jsx)("p",{className:"text-stone-400 text-sm font-medium",children:e("referenceManager.sessionExists.addPapers.searchPapers.searchPapersModal.noResults","N
1o results found")})]})};var g=l(56740),j=l(98561);l(35760);var w=l(31530),b=l(46004),N=l(68140),y=l(82759),_=l(85037),A=l(52726);l(6874);let S=(0,a.memo)(function(e){let{item:s,handleAddPaper:l}=e,[n,r]=(0,a.useState)(!1),[o,i]=(0,a.useState)(!1),{description:d,year:c,sourceUrl:x,doi:h,authors:m}=(0,a.useMemo)(()=>({description:(null==s?void 0:s.summary)||(null==s?void 0:s.abstract),year:(null==s?void 0:s.publication_date)?new Date(s.publication_date).getFullYear():(null==s?void 0:s.year)||"",sourceUrl:null==s?void 0:s.downloadable_link,doi:null==s?void 0:s.doi_url,authors:null==s?void 0:s.authors}),[s]),p=(0,a.useMemo)(()=>{let e=null==s?void 0:s.authors;if(!e||0===e.length)return"No authors listed";let l=e.slice(0,3).map(e=>{var s;return null==e||null==(s=e.name)?void 0:s.trim()}).join(", "),t=e.length-3;return l+(t>0?" + ".concat(t," more"):"")},[null==s?void 0:s.authors]),f=async()=>{try{r(!0),await l(null==s?void 0:s.citation,s),r(!1),i(!0)}catch(e){console.log(e),r(!1)}};return(0,t.jsxs)("div",{className:"p-3 space-y-1 rounded-md border-[1px] border-stone-200",children:[(0,t.jsx)("p",{className:"text-sm font-medium leading-7 text-stone-950 line-clamp-2",children:null==s?void 0:s.title}),d?(0,t.jsx)("p",{className:"text-[13px] text-stone-600 truncate",children:d}):null,p?(0,t.jsxs)("p",{className:"text-[13px]/6 text-stone-600 truncate",children:[m>1?"Authors -":"Author -"," ",p]}):null,(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[c?(0,t.jsx)("p",{className:"text-stone-600 text-[13px] ",children:c}):null,h?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"w-[1px] h-3 rounded-md bg-stone-400"}),(0,t.jsxs)(N.A,{href:h,target:"_blank",className:"flex items-center gap-1 text-stone-600 text-[13px]",children:[(0,t.jsx)("p",{className:"text-stone-600 text-[13px]",children:"DOI"})," ",(0,t.jsx)(y.A,{className:"w-3 h-3 mt-[2px]"})]})]}):null,x?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"w-[1px] h-3 rounded-md bg-stone-400"}),(0,t.jsxs)(N.A,{href:x,target:"_blank",className:"flex items-center gap-1 text-stone-600 text-[13px]",children:[(0,t.jsx)("p",{className:"text-stone-600 text-[13px]",children:"Source"})," ",(0,t.jsx)(y.A,{className:"w-3 h-3 mt-[2px]"})]})]}):null]}),(0,t.jsx)("div",{className:"w-24 h-5 flex justify-end items-center",children:o?(0,t.jsxs)("div",{className:"flex items-center gap-1 cursor-default",children:[(0,t.jsx)(A.A,{className:"w-4 h-4 text-green-600 stroke-2"}),(0,t.jsx)("p",{className:"text-[13px] text-green-600 font-medium whitespace-nowrap",children:"Added"})]}):(0,t.jsx)(u.A,{onClick:()=>f(null==s?void 0:s.citation),isLoading:n,loaderColor:"#ea580c",loaderSize:15,loaderType:"spinner",loaderText:(0,t.jsx)("p",{className:"text-[13px] text-orange-600 font-medium whitespace-nowrap",children:"Adding"}),children:(0,t.jsx)(b.A,{id:null==s?void 0:s.paper_id,content:"Add paper to my references",children:(0,t.jsxs)("div",{className:"flex items-center gap-1 ",children:[(0,t.jsx)(_.A,{className:"w-4 h-4 text-orange-600 stroke-2"}),(0,t.jsx)("p",{className:"text-[13px] text-orange-600 font-medium whitespace-nowrap",children:"Add Paper"})]})})})})]})]})});l(18648);var k=l(45334),E=l(19389),C=l(47396),F=l(98625);let I=function(e){let{data:s,handleClose:l,addingPapersInLR:n,handleAddPapersOnlineToWorkbook:r}=e,o=(0,E.A)(),{selectedFolderId:i,loadReferences:d,selectedSharedRootFolderId:c}=(0,C.G)(),[u,x]=(0,a.useState)(!1),h=(0,a.useCallback)(async(e,s)=>{if(x(!0),n){await r(s),x(!1);return}if(!e)return void w.Ay.error("Invalid BibTeX data. Please try again.");try{var l,t,a,u,h,m,p,f,v,b;let n=(null==s?void 0:s.doi_url)?(0,F.Tx)(null==s?void 0:s.doi_url):null;console.log({doi:null==s?void 0:s.doi_url});let r=null,x={paper_id:null==s?void 0:s.paper_id,doi_url:null==s?void 0:s.doi_url,paper_isbn:null==s?void 0:s.isbn,...(null==s?void 0:s.abstract)?{abstract:s.abstract}:{},...(null==s||null==(l=s.tldr)?void 0:l.text)?{tldr:null==s||null==(t=s.tldr)?void 0:t.text}:{},...(null==s?void 0:s.bib_text)?{bib_text:s.bib_text}:{},...(null==s?void 0:s.citation_count)?{citation_count:s.citation_count}:{},...(null==s?void 0:s.fields_of_study)?{fields_of_study:s.fields_of_study}:{},...(null==s?void 0:s.reference_count)?{reference_count:s.reference_count}:{},...(null==s?void 0:s.is_open_access)!==void 0?{is_open_access:s.is_open_access}:{},...(null==s?void 0:s.journal_name)?{journal_name:s.journal_name}:{}};if(n)try{r=await (0,g.Dv)(null==s?void 0:s.doi_url);let l=(0,g.uB)((null==r?void 0:r.type)||"report"),t=(0,g.fS)(l||"report");if((null==r||null==(h=r.author)?void 0:h.length)===1&&""===r.author[0].given&&""===r.author[0].family&&""===r.author[0].literal){console.log("hasEmptyAuthor");let s=await (0,g.PP)(e);console.log({bibData:s}
1),r={...r,author:null==s||null==(m=s[0])?void 0:m.author}}r=[{...r,...x,type:l,source_code:t}]}catch(e){console.error("Error getting CSL data from DOI:",e),r=null}r||(r=null==(r=await (0,g.PP)(e))?void 0:r.map(e=>{let s=(0,g.uB)((null==e?void 0:e.type)||"report"),l=(0,g.fS)(s||"report");return{...e,type:s,source_code:l,...x}}));let N=(null==s?void 0:s.downloadable_link)||(null==s?void 0:s.doi_url)?[{url:(null==s?void 0:s.downloadable_link)||(null==s?void 0:s.doi_url),content_type:"url",index:1}]:void 0,y=await (0,j.JS)(r,"citations",N,void 0,i,c);if((null==y||null==(u=y.response)||null==(a=u.references[0])?void 0:a.status)==="success")await d(),(0,k.ho)(o,{import_type:"search paper",reference_id:(null==y||null==(f=y.response)||null==(p=f.references[0])?void 0:p.reference_uuid)||null}),w.Ay.success("Reference added successfully \uD83C\uDF89");else{let e=(null==y||null==(b=y.response)||null==(v=b.references[0])?void 0:v.message)||"Failed to add reference";throw Error(e)}}catch(e){throw console.error("Error adding paper:",e),w.Ay.error(e.message||"Something went wrong! Please try again."),e}finally{x(!1)}},[i,d,o,c]);return(0,t.jsx)("div",{className:"space-y-2",children:(null==s?void 0:s.length)?s.map(e=>(0,t.jsx)(S,{item:e,handleAddPaper:h,isAddingPaper:u},null==e?void 0:e.id)):(0,t.jsx)(v,{})})};var P=l(25260),R=l(65417),T=l(30303),M=l(40427);let D=function(e){let{open:s,setOpen:l,handleAddPapersOnlineToWorkbook:p,addingPapersInLR:v=!1,...j}=e,{handleStorageLimit:b}=(0,T.A)(),N=(0,f.useTranslations)(),[y,_]=(0,a.useState)(""),[A,S]=(0,a.useState)(!1),[k,E]=(0,a.useState)([]),C=()=>{_(""),E([])},D=()=>{l(!1),C()},O=async e=>{_(e.target.value)},L=async e=>{var s,l,t,n,a,r;null==e||e.preventDefault(),S(!0);try{if(v){let e=await (0,M.lb)(y,!1,!1,[],"","",{type:"all"},"custom",20,0);E(null==e||null==(s=e.data)?void 0:s.data)}else{if(await b())return;let e=(0,F.Tx)(y);if(console.log(e,"isDOI"),e){let e=await (0,R.V)(y),s=null==e?void 0:e.data;if((null==e?void 0:e.status)==="success"){let e=await (0,g.PP)(s),l=(null==e?void 0:e[0])||{},a="https://doi.org/"+(null==l?void 0:l.DOI),r=(0,F.Tx)(a),o={citation:s,downloadable_link:(null==l?void 0:l.URL)||"",doi_url:r?a:"",ISSN:(null==l?void 0:l.ISSN)||"",authors:null==l||null==(t=l.author)?void 0:t.map(e=>({name:(null==e?void 0:e.family)+" "+(null==e?void 0:e.given)})),year:(null==l||null==(n=l.issued)?void 0:n.year)||"",title:(null==l?void 0:l.title)||"",description:(null==l?void 0:l.note)||"",journal:(null==l?void 0:l.container_title)||"",volume:(null==l?void 0:l.volume)||"",issue:(null==l?void 0:l.issue)||"",pages:(null==l?void 0:l.page)||"",type:(null==l?void 0:l.type)||"",url:(null==l?void 0:l.URL)||"",publisher:(null==l?void 0:l.publisher)||""};console.log(o,"from get search paper"),E([o])}else console.log(e,"from get search paper"),w.Ay.error((null==e?void 0:e.message)||"Something went wrong! Please try again"),E([])}else{let e=await (0,m.Mu)(y,10,0);if((null==e?void 0:e.status)==="success"){let s=null==e||null==(l=e.results)?void 0:l.data;E(s)}else E([])}console.log(k,"from get search paper"),S(!1)}}catch(e){w.Ay.error((null==e||null==(r=e.response)||null==(a=r.data)?void 0:a.message)||"Something went wrong! Please try again."),console.log(e,"from get search paper")}finally{S(!1)}};return(0,t.jsx)(n.A,{open:s,setOpen:l,showCloseButton:!1,...j,children:(0,t.jsxs)("div",{className:"min-h-[70vh] sm:h-[70vh] overflow-scroll bg-white rounded-xl space-y-4 p-4 pt-0 sm:px-9 sm:py-8 sm:pt-0 w-[95vw] max-w-xl",children:[(0,t.jsx)("form",{onSubmit:L,className:"sticky top-0 bg-white pt-4 sm:pt-8 z-10",children:(0,t.jsx)(r.L,{className:"space-y-3",children:(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)(u.A,{className:"flex items-center gap-2 text-[13px] font-medium text-orange-600",onClick:D,children:[(0,t.jsx)(x.A,{className:"w-5 h-5"}),N("referenceManager.sessionExists.addPapers.back","Back")]}),(0,t.jsxs)(o.D,{className:"space-y-2",children:[(0,t.jsx)("div",{className:"flex justify-between items-center",children:(0,t.jsx)(i.s,{className:"text-base/7 font-semibold text-stone-950",children:N("referenceManager.sessionExists.addPapers.searchPapers.searchPapersModal.heading","Search Papers Online")})}),(0,t.jsxs)("div",{className:" flex items-center h-10 justify-between relative w-full rounded-md border-[1px] border-stone-200 py-2 px-3 text-stone-950",children:[(0,t.jsx)(d.p,{autoFocus:!0,placeholder:N("referenceManager.sessionExists.addPapers.searchPapers.searchPapersModal.placeholder","Enter name, question, keywords or DOI"),onChange:O,value:y,className:(0,
1c.A)("focus:outline-none w-[calc(100%-50px)] text-sm/6 data-[focus]:outline-2 data-[focus]:-outline-offset-2 ")}),(0,t.jsx)("div",{className:"absolute right-0 px-4 flex items-center w-12 justify-center h-8 bg-stone-100 py-2 mr-1 rounded-sm",children:(0,t.jsx)(u.A,{type:"submit",isLoading:A,loaderColor:"#030712",loaderSize:4,children:(0,t.jsx)(h.HfP,{className:"w-4 h-4 text-stone-600"})})})]})]})]})})}),A?(0,t.jsx)(P.A,{}):(0,t.jsx)(I,{data:k,handleClose:D,addingPapersInLR:v,handleAddPapersOnlineToWorkbook:p})]})})}},40427:(e,s,l)=>{l.d(s,{bO:()=>d,lb:()=>o,oW:()=>i,s5:()=>c});var t=l(50004),n=l(23464),a=l(86834);let r=n.A.create({baseURL:t.TT,timeout:3e4,headers:{"Content-Type":"application/json"}});(0,a.n4)(r);let o=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],l=arguments.length>2&&void 0!==arguments[2]&&arguments[2],t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=(arguments.length>4&&void 0!==arguments[4]&&arguments[4],arguments.length>5&&void 0!==arguments[5]?arguments[5]:""),r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{type:"all"},o=(arguments.length>7&&void 0!==arguments[7]&&arguments[7],arguments.length>8&&void 0!==arguments[8]?arguments[8]:20),i=arguments.length>9&&void 0!==arguments[9]?arguments[9]:0,d={limit:o,offset:i};if(e&&(d.query=e),s&&(d.open_access=!0),l&&(d.has_pdf=!0),(null==t?void 0:t.length)>0&&(d.fields=t.join(",")),a&&(d.min_citations=a),(null==r?void 0:r.type)==="last"){let e=new Date().getFullYear();d.year_min=e-r.lastYears+1,d.year_max=e}else(null==r?void 0:r.type)==="custom"&&(d.year_min=r.customRange.from,d.year_max=r.customRange.to);return(await n.A.post("".concat("","/api/papers/search/"),d,{timeout:3e4})).data},i=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"",o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"sjr_rank",i=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"asc",d={offset:s,limit:l,sort_by:o,sort_order:i||"asc"};return e&&(d.query=e),(null==t?void 0:t.length)>0&&(d.subject_areas=t),a&&(d.sjr_best_quartile=a),(null==r?void 0:r.length)>0&&(d.country_name=r),(await n.A.post("".concat("","/api/journals/search/"),d,{timeout:3e4})).data},d=async e=>(await r.get("/conference/papers/".concat(e))).data,c=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],l=arguments.length>2&&void 0!==arguments[2]&&arguments[2],t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"",o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{type:"all"},i=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"custom",d=arguments.length>8&&void 0!==arguments[8]?arguments[8]:20,c=arguments.length>9&&void 0!==arguments[9]?arguments[9]:[],u=new URLSearchParams;if(u.set("slug",e),u.set("limit",d),(null==c?void 0:c.length)>
10&&u.set("exclude_ids",c.join(",")),s&&u.set("is_open_access",s),l&&u.set("has_pdf",l),(null==t?void 0:t.length)>0&&u.set("fields_of_study",t.join(",")),n&&u.set("sjr_best_quartile",n),a&&u.set("citation_count",a),"custom"!==i&&null!==i&&u.set("sort_by",i),(null==o?void 0:o.type)!=="all")if("last"===o.type){let e=new Date().getFullYear(),s=e-o.lastYears+1;u.set("year_range","".concat(s,"-").concat(e))}else"custom"===o.type&&u.set("year_range","".concat(o.customRange.from,"-").concat(o.customRange.to));return(await r.get("/paper/top/papers?".concat(u.toString()))).data}},47396:(e,s,l)=>{l.d(s,{G:()=>u});var t=l(18648),n=l(31530),a=l(921),r=l(35695),o=l(12115),i=l(98561),d=l(28929),c=l(50529);let u=()=>{let e=(0,t.wA)();(0,r.useRouter)();let s=(0,r.usePathname)(),l=(0,r.useSearchParams)(),{list:u,status:x,error:h,isSharedWithMe:m,allReferences:p}=(0,t.d4)(e=>e.references),{foldersList:f,sharedFoldersList:v,defaultFolderId:g}=(0,t.d4)(e=>e.referenceFilesList),j=(0,o.useMemo)(()=>{let e=s.split("/").filter(Boolean),l=e.indexOf("references");return -1!==l&&e[l+1]?e.slice(l+1):[]}
1,[s]),w=l.get("code"),b=(e,s)=>{let l="",t=null;return s.includes("/references")&&"string"==typeof e&&e.length>=36&&(l=e.substring(0,36),e.length>=72&&(t=e.substring(36,72))),{folderId:l,sharedRootFolderId:t}},{folderId:N,sharedRootFolderId:y}=(0,o.useMemo)(()=>b(null==j?void 0:j[0],s),[j,s]),_=(0,o.useMemo)(()=>(null==j?void 0:j[1])==="invite"&&w||null,[j,w]),A=(0,o.useCallback)(async function(){let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:N,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:y,t=!(arguments.length>2)||void 0===arguments[2]||arguments[2];try{e((0,d.R2)("")),await e((0,a.HJ)({folderId:s,rootFolderId:l,isBackground:t})).unwrap()}catch(e){console.log(e,"error?.response?.data?.message "),n.Ay.error((null==e?void 0:e.message)||(s?"Failed to fetch references for the folder":"Failed to fetch references"))}},[e,N,y]),S=async s=>{try{await e((0,a.bA)(s)).unwrap(),n.Ay.success("Reference deleted successfully")}catch(e){n.Ay.error("Failed to delete reference")}},k=async(s,l,t)=>{try{await e((0,a.Bb)({referenceIds:s,folderId:l,rootFolderId:t})).unwrap()}catch(e){throw n.Ay.error("Failed to remove references from folder"),e}},E=(0,o.useCallback)(async(s,l,t)=>{try{await e((0,a.Bb)({referenceIds:[s],folderId:l,rootFolderId:t})).unwrap()}catch(e){n.Ay.error("Failed to remove reference from folder")}},[e]),C=(0,o.useCallback)(async e=>{try{let s=await (0,i.pj)(e);return null==s?void 0:s.data}catch(e){var s,l,t;if((null==e||null==(s=e.response)?void 0:s.status)===422)return console.log(null==e||null==(l=e.response)?void 0:l.data),null==e||null==(t=e.response)?void 0:t.data;return{status:"error",message:"Something unexpected happened"}}},[]),F=(0,o.useMemo)(()=>{var e;return m?(null==v||null==(e=v.find(e=>(null==e?void 0:e.folder_uuid)===y))?void 0:e.children)||[]:(null==f?void 0:f.filter(e=>!e.is_default))||[]},[m,v,y,f]),I=(0,o.useCallback)(async e=>{let s=await (0,i.J4)(e);return null==s?void 0:s.data},[]),P=(0,o.useCallback)(async e=>{try{let s=await (0,i.l$)(e);return null==s?void 0:s.data}catch(e){var s,l;throw console.log(e),n.Ay.error((null==e?void 0:e.message)||(null==e||null==(l=e.response)||null==(s=l.data)?void 0:s.message)||"Failed to trigger reference indexing"),e}},[]),R=async(e,s,l)=>{try{let l=await (0,i.uF)(s,e);return null==l?void 0:l.data}catch(e){console.log(e)}},T=async(s,l,t,n)=>{await e((0,c.fw)({sourceFolderId:s,destinationFolderId:l,sortOrder:t,position:n}))},M=(0,o.useCallback)(e=>{let s=0,l=(e,s)=>{for(let t of e){if(t.folder_uuid===s)return t;if(t.children&&t.children.length>0){let e=l(t.children,s);if(e)return e}}return null};for(let[t,n]of Object.entries(e||{}))if(0===n.length){let e=l(f,t);e&&e.references_count&&(s+=e.references_count)}else s+=n.length;return s},[f]);return{references:u,foldersList:f,allReferences:p,defaultFolderId:g,status:x,error:h,loadReferences:A,deleteReferencePermanently:S,selectedFolderId:N,selectedSharedRootFolderId:y,removeReference:E,removeReferences:k,inviteCode:_,getFolderInvitationByCode:C,getFoldersForReferenceAction:F,getReferencesIndexingStatus:I,handleUpdateReferenceSortOrder:R,handleUpdateFolderPosition:T,handleTriggerReferenceIndexing:P,calculateReferenceCountFromFolders:M}}},62890:(e,s,l)=>{l.d(s,{A:()=>u});var t=l(95155),n=l(589);l(35760);var a=l(12115);l(31530);var r=l(98501),o=l(43372),i=l(71026),d=l(54078),c=l(27043);let u=function(e){let{title:s,subTitle:l,btnTitle:u,action:x,open:h,setOpen:m,...p}=e,[f,v]=(0,a.useState)(!1),g=(0,c.useTranslations)(),j=async e=>{null==e||e.preventDefault(),v(!0);try{await x(),v(!1),w()}catch(e){console.log(e,"error at deleting reference folder"),v(!1)}},w=()=>{m(!1)};return(0,t.jsx)(n.A,{open:h,setOpen:m,showCloseButton:!1,...p,children:(0,t.jsx)("form",{onSubmit:j,children:(0,t.jsx)(r.L,{className:"space-y-3 bg-white w-[95vw] max-w-md rounded-xl p-6 sm:px-8 sm:py-8",children:(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("div",{className:"space-y-2 w-5/6",children:[(0,t.jsx)("div",{className:"flex justify-between items-center",children:(0,t.jsx)(o.s,{className:"text-base/7 font-semibold text-stone-950",children:s})}),l?(0,t.jsx)(o.s,{className:"text-sm/5 font-medium text-stone-500",children:l}):null]}),(0,t.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,t.jsxs)(i.A,{type:"submit",isLoading:f,className:"py-1.5 px-4 h-8 min-w-20 flex items-center gap-2 hover:gap-4 transition-all rounded-md bg-stone-950 text-white text-sm font-semibold",children:[u,(0,t.jsx)(d.A,{className:"h-4 w-4"})]}),(0,t.jsx)(i.A,{onClick:w,isLoading:f,className:"py-1.5 px-4 h-8 min-w-20 flex items-center gap-2 hover:gap-4 transition-all rounded-md text-stone-950 text-sm font-semibold",children:g("common.close","Close")})]})]})})})})}},69503:(e,s,l)=>{l.d(s,{A:()=>M});var t=l(95155),n=l(12115),a=l(18648),r=l(35695),o=l(42355),i=l(54264),d=l(94214),c=l(46014);let u=e=>{let{file:s,totalFiles:l,onBack:a,showBackButton:r=!0}
1=e,[u,x]=(0,n.useState)(!1),h=(null==s?void 0:s.type)==="reference"||(null==s?void 0:s.isInReferenceManager)===!0,m=null==s?void 0:s.referenceUuid;return(0,t.jsxs)("div",{className:"h-full flex flex-col bg-white overflow-hidden",children:[r&&(0,t.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 -ml-[3px] border-b border-stone-200 flex-shrink-0",children:[(0,t.jsxs)("div",{onClick:a,className:"flex items-center gap-1 cursor-pointer text-stone-600 hover:text-stone-900",children:[(0,t.jsx)(o.A,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:"View all files"})]}),(0,t.jsxs)("span",{className:"text-sm text-stone-500",children:["(",l," files)"]})]}),(0,t.jsx)("div",{className:"px-4 py-2 border-b border-stone-100 flex-shrink-0",children:(0,t.jsx)("p",{className:"text-sm text-stone-700 truncate",children:null==s?void 0:s.name})}),(0,t.jsx)("div",{className:"flex-1 overflow-hidden min-h-0 px-1",children:h&&m?(0,t.jsx)(d.A,{showCloseButton:!1,showSnapSelection:u,setShowSnapSelection:x,defaultTabIndex:3,showDocMenu:!0,docId:null==s?void 0:s.doc_id,referenceId:m}):(0,t.jsx)(i.A,{doc_storage_url:(0,c.Og)(null==s?void 0:s.storage_url,null==s?void 0:s.doc_id),showSnapSelection:!1,setShowSnapSelection:()=>{},showMenu:!1})})]})};var x=l(94631),h=l(49103),m=l(50183),p=l(67181),f=l(17351),v=l(14395),g=l(84616),j=l(27043);let w=e=>{let{totalFiles:s,onAddFile:l,className:n=""}=e,a=(0,j.useTranslations)();return(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 flex-shrink-0 ".concat(n),children:[(0,t.jsxs)("div",{className:"flex items-center gap-[6px] min-w-0",children:[(0,t.jsx)(v.A,{className:"w-4 h-4 flex-shrink-0 text-stone-600"}),(0,t.jsx)("span",{className:"text-sm font-medium text-stone-900 whitespace-nowrap",children:a("agent.sources")}),(0,t.jsxs)("span",{className:"text-sm text-stone-500 whitespace-nowrap",children:["(",s," files)"]})]}),l&&(0,t.jsxs)(m.$,{variant:"ghost",size:"sm",className:"text-stone-600 hover:text-stone-900 flex-shrink-0",onClick:l,children:[(0,t.jsx)(g.A,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"text-[13px]",children:a("agent.addFile")})]})]})};var b=l(48401),N=l(46004);let y=e=>{let{uploads:s,selectedFile:l,onSelectFile:a,onAddFile:r}
1=e,[o,u]=(0,n.useState)(!1),v=(0,j.useTranslations)(),{addDocumentToReferenceManager:g,isAddingToReferences:y}=(0,b.t)(),_=(null==l?void 0:l.type)==="reference",A=async()=>{if(!(null==l?void 0:l.doc_id)||y)return;let e=(0,c.Og)(null==l?void 0:l.storage_url,l.doc_id);await g(e,l.doc_id)},S=_||(null==l?void 0:l.isInReferenceManager)===!0&&(null==l?void 0:l.referenceUuid),k=(0,t.jsx)("div",{className:"space-y-1 max-h-80 overflow-auto p-1",children:s.map(e=>(0,t.jsx)(f.A,{checked:(null==l?void 0:l.id)===(null==e?void 0:e.id),isRadio:!0,onClick:()=>a(e),option:null==e?void 0:e.name,className:"px-2.5 py-1.5 cursor-pointer text-sm rounded-md ".concat((null==l?void 0:l.id)===(null==e?void 0:e.id)?"bg-stone-100 text-stone-900":"hover:bg-stone-50 text-stone-600")},e.id))});return(0,t.jsxs)("div",{className:"h-full flex flex-col bg-white overflow-x-hidden overflow-y-visible",children:[(0,t.jsx)(w,{totalFiles:s.length,onAddFile:r,className:"pt-2"}),(0,t.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2.5 flex-shrink-0 relative z-10",children:[(0,t.jsx)("div",{className:"flex-1 min-w-0 relative",children:(0,t.jsx)(p.A,{dropdownComponent:k,className:"flex items-center w-full justify-between rounded-md border text-stone-600 border-stone-300 h-9 px-2.5 gap-2 text-sm font-medium bg-white",showArrowIcon:!0,initialPosition:"bottom",dropdownDim:"w-full",gap:"mt-1",noAnimation:!0,children:(0,t.jsx)("span",{className:"truncate block",children:null==l?void 0:l.name})})}),!_&&!(null==l?void 0:l.isInReferenceManager)&&(0,t.jsx)(N.A,{place:"right",id:"added-reference-d}",content:"Add document to reference manager",children:(0,t.jsxs)(m.$,{variant:"outline",size:"sm",className:"h-9 px-3 text-sm font-medium text-stone-600 border-stone-300 flex-shrink-0 whitespace-nowrap",onClick:A,disabled:y,children:[y?(0,t.jsx)(x.A,{className:"w-4 h-4 animate-spin"}):(0,t.jsx)(h.A,{className:"w-4 h-4"}),v("agent.myReferences")]})})]}),(0,t.jsx)("div",{className:"flex-1 overflow-hidden min-h-0 relative z-0 px-1",children:S?(0,t.jsx)(d.A,{showCloseButton:!1,showSnapSelection:o,setShowSnapSelection:u,defaultTabIndex:3,showDocMenu:!0,docId:null==l?void 0:l.doc_id,referenceId:null==l?void 0:l.referenceUuid}):(0,t.jsx)(i.A,{doc_storage_url:(0,c.Og)(null==l?void 0:l.storage_url,null==l?void 0:l.doc_id),showSnapSelection:!1,setShowSnapSelection:()=>{},showMenu:!0})})]})};var _=l(70339),A=l(9770),S=l(94162);let k=e=>{let{references:s,uploads:l,activeTab:n,onTabChange:a,onSelectFile:r,onAddFile:o}=e,{hasReferences:i,hasUploads:d,totalFiles:c}=(0,b.A)(),u=(0,j.useTranslations)();return i&&!d?(0,t.jsxs)("div",{className:"h-full flex flex-col bg-white overflow-hidden",children:[(0,t.jsx)(w,{totalFiles:c,onAddFile:o,className:"pt-3 pb-1"}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",children:s.map(e=>(0,t.jsx)(A.A,{file:e,onSelect:r},e.id))})]}):d&&!i?(0,t.jsxs)("div",{className:"h-full flex flex-col bg-white overflow-hidden",children:[(0,t.jsx)(w,{totalFiles:c,onAddFile:o,className:"pt-3 pb-1"}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",children:l.map(e=>(0,t.jsx)(S.A,{file:e,onSelect:r},e.id))})]}):(0,t.jsxs)("div",{className:"h-full flex flex-col bg-white overflow-hidden",children:[(0,t.jsx)(w,{totalFiles:c,onAddFile:o,className:"pt-3 pb-2"}),(0,t.jsxs)(_.tU,{value:n,onValueChange:a,className:"flex-1 flex flex-col overflow-hidden",children:[(0,t.jsx)("div",{className:"border-b border-stone-200 px-4",children:(0,t.jsxs)(_.j7,{className:"h-auto bg-transparent p-0 rounded-none justify-start gap-4 -mb-px",children:[(0,t.jsxs)(_.Xi,{value:"references",className:"px-0 pb-2 pt-0 rounded-none bg-transparent shadow-none text-sm font-medium text-stone-500 border-0 border-b-2 border-b-transparent data-[state=active]:text-stone-900 data-[state=active]:border-b-stone-900 data-[state=active]:bg-transparent data-[state=active]:shadow-none hover:text-stone-700",children:[u("agent.myReferences")," (",s.length,")"]}),(0,t.jsxs)(_.Xi,{value:"uploads",className:"px-0 pb-2 pt-0 rounded-none bg-transparent shadow-none text-sm font-medium text-stone-500 border-0 border-b-2 border-b-transparent data-[state=active]:text-stone-900 data-[state=active]:border-b-stone-900 data-[state=active]:bg-transparent data-[state=active]:shadow-none hover:text-stone-700",children:[u("agent.uploads")," (",l.length,")"]})]})}),(0,t.jsx)(_.av,{value:"references",className:"flex-1 overflow-y-auto mt-0",children:s.map(e=>(0,t.jsx)(A.A,{file:e,onSelect:r},e.id))}),(0,t.jsx)(_.av,{value:"uploads",className:"flex-1 overflow-y-auto mt-0",children:l.map(e=>(0,t.jsx)(S.A,{file:e,onSelect:r},e.id))})]})]})};var E=l(17979),C=l(93645),F=l(59449);l(83165);var I=l(589),P=l(75755),R=l(54416),T=l(29308);let M=e=>{let{isHistoryLoading:s,chatId:l}=e,o=(0,a.wA)(),{slug:i}
1=(0,r.useParams)(),d=(0,j.useTranslations)(),c=l||(Array.isArray(i)?i[0]:i),{appendDocuments:x,selectedFiles:h,selectedReferenceDocIds:p,uploads:f,references:v,hasReferences:g,hasUploads:w,hasBoth:N,totalFiles:_}=(0,b.t)(),[A,S]=(0,n.useState)(!1),M=(0,a.d4)(e=>e.pageSelect),D=(0,a.d4)(e=>{var s;return null==(s=e.searchAgent)?void 0:s.isChatOwner}),[O,L]=(0,n.useState)("references"),[B,z]=(0,n.useState)(null),[U,X]=(0,n.useState)(null),[Y,q]=(0,n.useState)(!1),J=(0,n.useRef)(!1),H=(0,n.useRef)(!1),$=(0,n.useMemo)(()=>h.filter(e=>e.docId).map(e=>e.docId),[h]);(0,n.useEffect)(()=>{if(s)return;let e=$.length>0&&!J.current,l=p.length>0&&!H.current;(e||l)&&(e&&(J.current=!0),l&&(H.current=!0),(async()=>{S(!0);try{if(e){let e=await (0,C.vn)($);e.success&&e.documents&&o((0,F.uY)(e.documents))}if(l){let e=await (0,C.dR)(p);e.success&&e.references&&o((0,F.ic)(e.references))}}catch(e){}finally{S(!1)}})())},[$,p,o,s]);let V=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!(null==M?void 0:M.docId)||!(null==M?void 0:M.pageNo))return;V.current={docId:M.docId,pageNo:M.pageNo,sentenceTexts:M.sentenceTexts};let e=[...f,...v].find(e=>e.doc_id===M.docId);e&&(!N&&w&&1===f.length||!N&&g&&1===v.length?X(e):z(e),V.current=null)},[M,f,v,N,w,g]),(0,n.useEffect)(()=>{let e=V.current;if(!(null==e?void 0:e.docId)||!(null==e?void 0:e.pageNo))return;let s=[...f,...v].find(s=>s.doc_id===e.docId);s&&(!N&&w&&1===f.length||!N&&g&&1===v.length?X(s):z(s),V.current=null)},[f,v,N,w,g]);let W=()=>{q(!0)},G=(0,n.useCallback)(async e=>{let{uploadDocIds:s,referenceDocIds:l}=e;(await x(c,s,l)).success&&q(!1)},[x,c]),K=(0,t.jsx)(I.A,{open:Y,setOpen:q,showCloseButton:!1,children:(0,t.jsxs)("div",{className:"w-[600px] max-w-[90vw] bg-white rounded-2xl p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-stone-900 ",children:d("agent.addFilesToChat")}),(0,t.jsx)(m.$,{variant:"ghost",size:"icon",onClick:()=>q(!1),children:(0,t.jsx)(R.A,{className:"w-6 h-6"})})]}),(0,t.jsx)(P.Dashboard2CreationForm,{showParticularAgent:T.KQ.CHAT_WITH_PDF,formMode:"append",onSuccess:G,isLockedAgent:!0})]})});if((s||A)&&0===f.length&&0===v.length)return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(E.uX,{}),K]});if(B)return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u,{file:B,totalFiles:_,onBack:()=>{z(null)},showBackButton:!0}),K]});if(!N&&w&&1===f.length||!N&&g&&1===v.length){let e=w?f:v,s=U||e[0];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(y,{uploads:e,selectedFile:s,onSelectFile:X,onAddFile:D?W:void 0}),K]})}return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(k,{references:v,uploads:f,activeTab:O,onTabChange:L,onSelectFile:e=>{z(e)},onAddFile:D?W:void 0}),K]})}}}]);
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.