@e-llm-studio/citation 0.0.163 → 0.0.164

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("lucide-react");exports.default=function(r){var o=r.children,s=r.uploadListTopContent,a=r.defaultHeight,d=void 0===a?300:a,l=r.minHeight,u=void 0===l?150:l,c=r.maxHeight,g=r.isExpanded,p=void 0!==g&&g,x=r.onToggle,f=r.onHeightChange,h=r.styles,m=void 0===h?{}:h,v=t.useState(!1),_=v[0],y=v[1],b=t.useState(d),w=b[0],j=b[1],H=t.useRef(0),S=t.useRef(d),k="string"==typeof c?parseFloat(c)/100*window.innerHeight:null!=c?c:.4*window.innerHeight;return t.useEffect(function(){if(_){var e=function(e){e.preventDefault();var n=e.clientY-H.current,t=Math.max(u,Math.min(k,S.current+n));j(t),null==f||f(t)},n=function(){y(!1),document.body.style.userSelect=""};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",n),function(){document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",n)}}},[_]),n.jsxs("div",e.__assign({style:e.__assign({display:"flex",flexDirection:"column",backgroundColor:"#fff",borderRadius:20,border:"1px solid #BDB4FE",boxShadow:"0 4px 8px -2px rgba(16, 24, 40, 0.05), 0 2px 4px -2px rgba(16, 24, 40, 0.06)",height:p?"".concat(w,"px"):"auto",minHeight:p?"".concat(u,"px"):"auto",maxHeight:p?"".concat(w,"px"):"auto",overflow:"hidden",width:"100%"},m.container)},{children:[n.jsx("div",e.__assign({style:e.__assign({display:"flex",alignItems:"center",width:"100%",marginBottom:12,flexShrink:0,padding:"12px 20px 0 20px"},m.header)},{children:n.jsxs("button",e.__assign({onClick:x,style:{display:"flex",alignItems:"center",gap:8,background:"none",border:"none",cursor:"pointer",padding:0}},{children:[n.jsx("span",e.__assign({style:e.__assign({display:"inline-block",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:16,fontWeight:500,lineHeight:"24px",color:"#101828",fontFamily:"Inter, sans-serif"},m.title)},{children:(null==s?void 0:s.trim())?s:"Data uploaded for your context"})),n.jsx("span",e.__assign({style:{display:"flex",alignItems:"center",width:16,height:16,transform:p?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"}},{children:n.jsx(i.ChevronDown,{})}))]}))})),p&&n.jsx("div",e.__assign({style:e.__assign({flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,padding:"0 20px"},m.body)},{children:o})),p&&n.jsx("div",e.__assign({onMouseDown:function(e){e.preventDefault(),y(!0),H.current=e.clientY,S.current=w,document.body.style.userSelect="none"},style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"8px 20px",cursor:"ns-resize",userSelect:"none",flexShrink:0}},{children:n.jsx("div",{style:e.__assign({width:48,height:4,borderRadius:4,background:_?"#a78bfa":"#d1d5db"},m.dragPill)})}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),i=require("lucide-react");exports.default=function(o){var r=o.children,s=o.uploadListTopContent,a=o.defaultHeight,d=void 0===a?300:a,l=o.minHeight,u=void 0===l?150:l,c=o.maxHeight,p=o.isExpanded,f=void 0!==p&&p,x=o.onToggle,g=o.onHeightChange,h=o.styles,m=void 0===h?{}:h,v=n.useState(!1),y=v[0],_=v[1],b=n.useState(d),w=b[0],j=b[1],C=n.useRef(0),H=n.useRef(d),R=n.useRef(null),S=n.useRef(0),E="string"==typeof c?parseFloat(c)/100*window.innerHeight:null!=c?c:.4*window.innerHeight;n.useEffect(function(){!f&&R.current&&(S.current=R.current.getBoundingClientRect().height)},[f]);return n.useEffect(function(){if(y){var e=function(e){e.preventDefault();var t=e.clientY-C.current,n=Math.max(u,Math.min(E,H.current+t));j(n),null==g||g(n)},t=function(){_(!1),document.body.style.userSelect=""};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),function(){document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}}},[y]),t.jsxs("div",e.__assign({ref:R,style:{position:"relative",width:"100%",minHeight:f?S.current:"auto"}},{children:[t.jsxs("div",e.__assign({style:e.__assign({position:f?"absolute":"relative",zIndex:f?10:"auto",left:0,right:0,top:0,display:"flex",flexDirection:"column",backgroundColor:"#fff",borderRadius:20,border:"1px solid #BDB4FE",boxShadow:"0 4px 8px -2px rgba(16, 24, 40, 0.05), 0 2px 4px -2px rgba(16, 24, 40, 0.06)",height:f?"".concat(w,"px"):"auto",minHeight:f?"".concat(u,"px"):"auto",maxHeight:f?"".concat(w,"px"):"auto",overflow:"hidden",width:"100%"},m.container)},{children:[t.jsx("div",e.__assign({style:e.__assign({display:"flex",alignItems:"center",width:"100%",marginBottom:12,flexShrink:0,padding:"12px 20px 0 20px"},m.header)},{children:t.jsx("span",e.__assign({style:e.__assign({display:"inline-block",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:16,fontWeight:500,lineHeight:"24px",color:"#101828",fontFamily:"Inter, sans-serif"},m.title)},{children:(null==s?void 0:s.trim())?s:"Data uploaded for your context"}))})),f&&t.jsx("div",e.__assign({style:e.__assign({flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,padding:"0 20px"},m.body)},{children:r})),f&&t.jsx("div",e.__assign({onMouseDown:function(e){e.preventDefault(),_(!0),C.current=e.clientY,H.current=w,document.body.style.userSelect="none"},style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"8px 20px",cursor:"ns-resize",userSelect:"none",flexShrink:0}},{children:t.jsx("div",{style:e.__assign({width:48,height:4,borderRadius:4,background:y?"#a78bfa":"#d1d5db"},m.dragPill)})}))]})),t.jsx("div",e.__assign({style:{position:f?"absolute":"relative",top:f?"".concat(w,"px"):"auto",width:"100%",display:"flex",justifyContent:"center",height:18,zIndex:f?10:"auto"}},{children:t.jsx("button",e.__assign({onClick:x,"aria-label":f?"Collapse":"Expand",style:{position:"absolute",width:"52px",height:"18px",borderBottomLeftRadius:"10px",borderBottomRightRadius:"10px",border:"1px solid rgb(189, 180, 254)",borderTop:"none",backgroundColor:"#fff",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0}},{children:t.jsx(i.ChevronDown,{size:14,color:"#6d28d9",style:{transform:f?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})}))}))]}))};
2
2
  //# sourceMappingURL=ChatDrawer.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react"),r=require("@react-pdf-viewer/search"),n=require("@react-pdf-viewer/page-navigation"),o=require("@react-pdf-viewer/zoom");exports.PdfHighlightControls=function(i,a,u,l){var c=t.useState(0),s=c[0],p=c[1],f=t.useRef(!1),h=t.useState(0),g=h[0],v=h[1],d=function(e){if(!e)return[];return e.replace(/\]\s*\n\s*\(/g,"](").split(/\n+/).map(function(e){var t=e.trim(),r=(t=(t=t.replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\u00A0\u2009\u202F]/g," ")).replace(/^[-•]\s+/,"")).match(/^((\d+(?:\.\d+)*[.)]?)|[A-Za-z][.)]|\([A-Za-z0-9]+\)|(?:i|ii|iii|iv|v|vi|vii|viii|ix|x)[.)])\s*/i);return r?t.slice(r[0].length).trim():t}).flatMap(function(e){var t=e.match(/^\s*\|(.+)\|\s*$/);return t?t[1].split("|").map(function(e){return e.trim()}).filter(Boolean):[e]}).map(function(e){return e.replace(/&[#\w]+;/g,function(e){return t=e,(r=document.createElement("textarea")).innerHTML=t,r.value;var t,r}).replace(/<br\s*\/?>/gi,"\n").replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/[^\S\n]+/g," ").trim()}).flatMap(function(e){return e.split(/\n+/)}).flatMap(function(e){for(var t,r=[],n=/([*_]{1,3})([^*_]+)\1|([*_]{1,3})/g,o=0;null!==(t=n.exec(e));){var i=e.slice(o,t.index).trim();i&&r.push(i),t[2]&&r.push(t[2].trim()),o=t.index+t[0].length}var a=e.slice(o).trim();return a&&r.push(a),r.flatMap(function(e){return e.split(/[\u2013\u2014-]/g)}).flatMap(function(e){return e.split(/\n+/)}).map(function(e){return e.replace(/[*_]+/g,"").replace(/`([^`]+)`/g,"$1").replace(/[^\S\n]+/g," ").trim()})})},m=Object.keys(a).map(Number).sort(function(e,t){return e-t}),_=Object.values(a).filter(function(e){return e>0}).length,y=function(t){if(u.current){var r=u.current.querySelectorAll(".rpv-search__highlights"),n=new Set,o=new Set,a=new Map;r.forEach(function(r){var u=r.getAttribute("data-testid"),l=parseInt((null==u?void 0:u.replace("search__highlights-",""))||"-1"),c=r.querySelectorAll(".rpv-search__highlight");if(l===t){var s=new Set;c.forEach(function(t){var r=t,i=(r.getAttribute("title")||"").toLowerCase(),u=r.style.top,l="".concat(i,"_#$_").concat(u);if(r.style.display="none",n.has(l))if(a.has(l)){var c=a.get(l);a.set(l,e.__spreadArray(e.__spreadArray([],c,!0),[r],!1))}else a.set(l,[r]);else{if(n.add(l),a.has(l)){c=a.get(l);a.set(l,e.__spreadArray(e.__spreadArray([],c,!0),[r],!1))}else a.set(l,[r]);o.has(i)?s.add(l):o.add(i)}});var p=A(b,a);p.forEach(function(e){var t=new Set;e.elements.forEach(function(e){var r=e.style.left,n=e.style.width,o="".concat(r,"_").concat(n);t.has(o)?e.style.display="none":(t.add(o),e.style.display="")})}),console.groupCollapsed("[debug: PDF highlight text]"),console.log("input->",i),console.log("processed text->",b),console.log("dom->processed elements->",p),console.groupEnd()}})}},A=function(e,t){for(var r=Array.from(t.entries()),n=0,o=[],i=function(e){return e.toLowerCase().replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim()},a=0,u=e;a<u.length;a++)for(var l=u[a],c=i(l);n<r.length;){var s=r[n],p=s[0],f=s[1];if(n++,c===i(p.split("_#$_")[0])){o.push({chunk:l,matchedKey:p,elements:f});break}}return o},T=function(e){u.current&&u.current.querySelectorAll(".rpv-search__highlights").forEach(function(t){var r=t.getAttribute("data-testid"),n=parseInt((null==r?void 0:r.replace(/search__highlights-/g,""))||"-1"),o=t.querySelectorAll(".rpv-search__highlight");e.has(n)||o.forEach(function(e){e.style.display="none"})})},b=i.map(function(e){return d(e)}).flat(),x=r.searchPlugin({keyword:b}),S=n.pageNavigationPlugin(),w=o.zoomPlugin(),q=x.jumpToMatch,P=S.jumpToPage,j=w.zoomTo,E=w.ZoomInButton,M=w.ZoomOutButton,B=w.ZoomPopover,I=function(){if(!f.current)try{q(0),f.current=!0}catch(e){requestAnimationFrame(I)}},O=function(e,t){if(u.current&&u.current.querySelector(".rpv-core__viewer")){var r=-1,n=function(){var o,i,a=null===(o=u.current)||void 0===o?void 0:o.querySelector(".rpv-core__inner-pages");if(a){if(a.scrollTop!==r)return r=a.scrollTop,void setTimeout(n,100);var l=null===(i=u.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var c=l.querySelectorAll(".rpv-search__highlight")[t];if(c){var s=a.getBoundingClientRect(),p=c.getBoundingClientRect(),f=a.scrollTop+(p.top-s.top)-a.clientHeight/2+p.height/2;a.scrollTo({top:f,behavior:"smooth"})}}}};setTimeout(n,300)}},Z=t.useMemo(function(){var e={};return m.forEach(function(t,r){var n=a[t];n>0&&(e[n]||(e[n]=[]),e[n].push(r))}),e},[m,a]),C=function(e){var t=a[m[e]];return(Z[t]||[]).indexOf(e)};return{setHighlightIndex:p,highlightIndex:s,cursorIndex:g,setCursorIndex:v,orderedKeys:m,totalHighlights:_,getValidPosition:function(e){for(var t=0,r=0;r<=e;r++){var n=m[r];a[n]>0&&t++}return t},tryJump:I,jumpToPage:P,zoomTo:j,hideNonTargetHighlights:T,deduplicateHighlights:y,plugins:[x,S,w],controls:{ZoomInButton:E,ZoomOutButton:M,ZoomPopover:B,goToNext:function(){for(var e=function(e){var t=m[e];if(a[t]>0){var r=a[t]-1,n=C(e);return v(e),P(a[t]-1),O(r,n),setTimeout(function(){y(r)},500),1===Object.keys(a).length&&T(l),{value:void 0}}},t=g+1;t<m.length;t++){var r=e(t);if("object"==typeof r)return r.value}},goToPrevious:function(){for(var e=function(e){var t=m[e];if(a[t]>0){var r=a[t]-1,n=C(e);return v(e),P(a[t]-1),O(r,n),setTimeout(function(){y(r)},500),1===Object.keys(a).length&&T(l),{value:void 0}}},t=g-1;t>=0;t--){var r=e(t);if("object"==typeof r)return r.value}}}}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react"),r=require("@react-pdf-viewer/search"),n=require("@react-pdf-viewer/page-navigation"),o=require("@react-pdf-viewer/zoom");exports.PdfHighlightControls=function(i,a,u,l){var c=t.useState(0),s=c[0],p=c[1],f=t.useRef(!1),h=t.useState(0),g=h[0],v=h[1],d=function(e){if(!e)return[];return e.replace(/\]\s*\n\s*\(/g,"](").split(/\n+/).map(function(e){var t=e.trim(),r=(t=(t=t.replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\u00A0\u2009\u202F]/g," ")).replace(/^[-•]\s+/,"")).match(/^((\d+(?:\.\d+)*[.)]?)|[A-Za-z][.)]|\([A-Za-z0-9]+\)|(?:i|ii|iii|iv|v|vi|vii|viii|ix|x)[.)])\s*/i);return r?t.slice(r[0].length).trim():t}).flatMap(function(e){var t=e.match(/^\s*\|(.+)\|\s*$/);return t?t[1].split("|").map(function(e){return e.trim()}).filter(Boolean):[e]}).map(function(e){return e.replace(/&[#\w]+;/g,function(e){return t=e,(r=document.createElement("textarea")).innerHTML=t,r.value;var t,r}).replace(/<br\s*\/?>/gi,"\n").replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/[^\S\n]+/g," ").trim()}).flatMap(function(e){return e.split(/\n+/)}).flatMap(function(e){for(var t,r=[],n=/([*_]{1,3})([^*_]+)\1|([*_]{1,3})/g,o=0;null!==(t=n.exec(e));){var i=e.slice(o,t.index).trim();i&&r.push(i),t[2]&&r.push(t[2].trim()),o=t.index+t[0].length}var a=e.slice(o).trim();return a&&r.push(a),r.flatMap(function(e){return e.split(/[\u2013\u2014-]/g)}).flatMap(function(e){return e.split(/\n+/)}).map(function(e){return e.replace(/[*_]+/g,"").replace(/`([^`]+)`/g,"$1").replace(/[^\S\n]+/g," ").trim()})})},m=Object.keys(a).map(Number).sort(function(e,t){return e-t}),_=Object.values(a).filter(function(e){return e>0}).length,y=function(t){if(u.current){var r=u.current.querySelectorAll(".rpv-search__highlights"),n=new Set,o=new Set,a=new Map;r.forEach(function(r){var u=r.getAttribute("data-testid"),l=parseInt((null==u?void 0:u.replace("search__highlights-",""))||"-1"),c=r.querySelectorAll(".rpv-search__highlight");if(l===t){var s=new Set;c.forEach(function(t){var r=t,i=(r.getAttribute("title")||"").toLowerCase(),u=r.style.top,l="".concat(i,"_#$_").concat(u);if(r.style.display="none",n.has(l))if(a.has(l)){var c=a.get(l);a.set(l,e.__spreadArray(e.__spreadArray([],c,!0),[r],!1))}else a.set(l,[r]);else{if(n.add(l),a.has(l)){c=a.get(l);a.set(l,e.__spreadArray(e.__spreadArray([],c,!0),[r],!1))}else a.set(l,[r]);o.has(i)?s.add(l):o.add(i)}});var p=A(b,a);p.forEach(function(e){var t=new Set;e.elements.forEach(function(e){var r=e.style.left,n=e.style.width,o="".concat(r,"_").concat(n);t.has(o)?e.style.display="none":(t.add(o),e.style.display="")})}),console.groupCollapsed("[debug: PDF highlight text]"),console.log("input->",i),console.log("processed text->",b),console.log("dom->processed elements->",p),console.groupEnd()}})}},A=function(e,t){for(var r=Array.from(t.entries()),n=0,o=[],i=function(e){return e.toLowerCase().replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim()},a=0;a<e.length;a++)for(var u=e[a],l=i(u);n<r.length;){var c=r[n],s=c[0],p=c[1],f=i(s.split("_#$_")[0]),h=e[a+1],g=r[n+1],v=h?i(h):null,d=g?i(g[0].split("_#$_")[0]):null,m=l===f,_=n+1<r.length&&f===i(r[n+1][0].split("_#$_")[0]),y=m;if(m&&_&&v&&(y=v===d),y){o.push({chunk:u,matchedKey:s,elements:p}),n++;break}n++}return o},T=function(e){u.current&&u.current.querySelectorAll(".rpv-search__highlights").forEach(function(t){var r=t.getAttribute("data-testid"),n=parseInt((null==r?void 0:r.replace(/search__highlights-/g,""))||"-1"),o=t.querySelectorAll(".rpv-search__highlight");e.has(n)||o.forEach(function(e){e.style.display="none"})})},b=i.map(function(e){return d(e)}).flat(),x=r.searchPlugin({keyword:b}),S=n.pageNavigationPlugin(),w=o.zoomPlugin(),q=x.jumpToMatch,P=S.jumpToPage,j=w.zoomTo,E=w.ZoomInButton,M=w.ZoomOutButton,B=w.ZoomPopover,I=function(){if(!f.current)try{q(0),f.current=!0}catch(e){requestAnimationFrame(I)}},O=function(e,t){if(u.current&&u.current.querySelector(".rpv-core__viewer")){var r=-1,n=function(){var o,i,a=null===(o=u.current)||void 0===o?void 0:o.querySelector(".rpv-core__inner-pages");if(a){if(a.scrollTop!==r)return r=a.scrollTop,void setTimeout(n,100);var l=null===(i=u.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var c=l.querySelectorAll(".rpv-search__highlight")[t];if(c){var s=a.getBoundingClientRect(),p=c.getBoundingClientRect(),f=a.scrollTop+(p.top-s.top)-a.clientHeight/2+p.height/2;a.scrollTo({top:f,behavior:"smooth"})}}}};setTimeout(n,300)}},Z=t.useMemo(function(){var e={};return m.forEach(function(t,r){var n=a[t];n>0&&(e[n]||(e[n]=[]),e[n].push(r))}),e},[m,a]),C=function(e){var t=a[m[e]];return(Z[t]||[]).indexOf(e)};return{setHighlightIndex:p,highlightIndex:s,cursorIndex:g,setCursorIndex:v,orderedKeys:m,totalHighlights:_,getValidPosition:function(e){for(var t=0,r=0;r<=e;r++){var n=m[r];a[n]>0&&t++}return t},tryJump:I,jumpToPage:P,zoomTo:j,hideNonTargetHighlights:T,deduplicateHighlights:y,plugins:[x,S,w],controls:{ZoomInButton:E,ZoomOutButton:M,ZoomPopover:B,goToNext:function(){for(var e=function(e){var t=m[e];if(a[t]>0){var r=a[t]-1,n=C(e);return v(e),P(a[t]-1),O(r,n),setTimeout(function(){y(r)},500),1===Object.keys(a).length&&T(l),{value:void 0}}},t=g+1;t<m.length;t++){var r=e(t);if("object"==typeof r)return r.value}},goToPrevious:function(){for(var e=function(e){var t=m[e];if(a[t]>0){var r=a[t]-1,n=C(e);return v(e),P(a[t]-1),O(r,n),setTimeout(function(){y(r)},500),1===Object.keys(a).length&&T(l),{value:void 0}}},t=g-1;t>=0;t--){var r=e(t);if("object"==typeof r)return r.value}}}}};
2
2
  //# sourceMappingURL=usePdfHighlight.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"tslib";import{jsxs as t,jsx as n}from"react/jsx-runtime";import{useState as i,useRef as o,useEffect as r}from"react";import{ChevronDown as d}from"lucide-react";var l=function(l){var a=l.children,s=l.uploadListTopContent,c=l.defaultHeight,u=void 0===c?300:c,p=l.minHeight,f=void 0===p?150:p,m=l.maxHeight,h=l.isExpanded,g=void 0!==h&&h,x=l.onToggle,v=l.onHeightChange,y=l.styles,b=void 0===y?{}:y,w=i(!1),H=w[0],S=w[1],k=i(u),D=k[0],E=k[1],C=o(0),I=o(u),L="string"==typeof m?parseFloat(m)/100*window.innerHeight:null!=m?m:.4*window.innerHeight;return r(function(){if(H){var e=function(e){e.preventDefault();var t=e.clientY-C.current,n=Math.max(f,Math.min(L,I.current+t));E(n),null==v||v(n)},t=function(){S(!1),document.body.style.userSelect=""};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),function(){document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}}},[H]),t("div",e({style:e({display:"flex",flexDirection:"column",backgroundColor:"#fff",borderRadius:20,border:"1px solid #BDB4FE",boxShadow:"0 4px 8px -2px rgba(16, 24, 40, 0.05), 0 2px 4px -2px rgba(16, 24, 40, 0.06)",height:g?"".concat(D,"px"):"auto",minHeight:g?"".concat(f,"px"):"auto",maxHeight:g?"".concat(D,"px"):"auto",overflow:"hidden",width:"100%"},b.container)},{children:[n("div",e({style:e({display:"flex",alignItems:"center",width:"100%",marginBottom:12,flexShrink:0,padding:"12px 20px 0 20px"},b.header)},{children:t("button",e({onClick:x,style:{display:"flex",alignItems:"center",gap:8,background:"none",border:"none",cursor:"pointer",padding:0}},{children:[n("span",e({style:e({display:"inline-block",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:16,fontWeight:500,lineHeight:"24px",color:"#101828",fontFamily:"Inter, sans-serif"},b.title)},{children:(null==s?void 0:s.trim())?s:"Data uploaded for your context"})),n("span",e({style:{display:"flex",alignItems:"center",width:16,height:16,transform:g?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"}},{children:n(d,{})}))]}))})),g&&n("div",e({style:e({flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,padding:"0 20px"},b.body)},{children:a})),g&&n("div",e({onMouseDown:function(e){e.preventDefault(),S(!0),C.current=e.clientY,I.current=D,document.body.style.userSelect="none"},style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"8px 20px",cursor:"ns-resize",userSelect:"none",flexShrink:0}},{children:n("div",{style:e({width:48,height:4,borderRadius:4,background:H?"#a78bfa":"#d1d5db"},b.dragPill)})}))]}))};export{l as default};
1
+ import{__assign as e}from"tslib";import{jsxs as t,jsx as n}from"react/jsx-runtime";import{useState as o,useRef as i,useEffect as r}from"react";import{ChevronDown as d}from"lucide-react";var l=function(l){var a=l.children,s=l.uploadListTopContent,u=l.defaultHeight,c=void 0===u?300:u,p=l.minHeight,f=void 0===p?150:p,h=l.maxHeight,x=l.isExpanded,m=void 0!==x&&x,g=l.onToggle,v=l.onHeightChange,y=l.styles,b=void 0===y?{}:y,w=o(!1),H=w[0],C=w[1],S=o(c),k=S[0],E=S[1],B=i(0),D=i(c),I=i(null),L=i(0),R="string"==typeof h?parseFloat(h)/100*window.innerHeight:null!=h?h:.4*window.innerHeight;r(function(){!m&&I.current&&(L.current=I.current.getBoundingClientRect().height)},[m]);return r(function(){if(H){var e=function(e){e.preventDefault();var t=e.clientY-B.current,n=Math.max(f,Math.min(R,D.current+t));E(n),null==v||v(n)},t=function(){C(!1),document.body.style.userSelect=""};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),function(){document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}}},[H]),t("div",e({ref:I,style:{position:"relative",width:"100%",minHeight:m?L.current:"auto"}},{children:[t("div",e({style:e({position:m?"absolute":"relative",zIndex:m?10:"auto",left:0,right:0,top:0,display:"flex",flexDirection:"column",backgroundColor:"#fff",borderRadius:20,border:"1px solid #BDB4FE",boxShadow:"0 4px 8px -2px rgba(16, 24, 40, 0.05), 0 2px 4px -2px rgba(16, 24, 40, 0.06)",height:m?"".concat(k,"px"):"auto",minHeight:m?"".concat(f,"px"):"auto",maxHeight:m?"".concat(k,"px"):"auto",overflow:"hidden",width:"100%"},b.container)},{children:[n("div",e({style:e({display:"flex",alignItems:"center",width:"100%",marginBottom:12,flexShrink:0,padding:"12px 20px 0 20px"},b.header)},{children:n("span",e({style:e({display:"inline-block",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:16,fontWeight:500,lineHeight:"24px",color:"#101828",fontFamily:"Inter, sans-serif"},b.title)},{children:(null==s?void 0:s.trim())?s:"Data uploaded for your context"}))})),m&&n("div",e({style:e({flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,padding:"0 20px"},b.body)},{children:a})),m&&n("div",e({onMouseDown:function(e){e.preventDefault(),C(!0),B.current=e.clientY,D.current=k,document.body.style.userSelect="none"},style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"8px 20px",cursor:"ns-resize",userSelect:"none",flexShrink:0}},{children:n("div",{style:e({width:48,height:4,borderRadius:4,background:H?"#a78bfa":"#d1d5db"},b.dragPill)})}))]})),n("div",e({style:{position:m?"absolute":"relative",top:m?"".concat(k,"px"):"auto",width:"100%",display:"flex",justifyContent:"center",height:18,zIndex:m?10:"auto"}},{children:n("button",e({onClick:g,"aria-label":m?"Collapse":"Expand",style:{position:"absolute",width:"52px",height:"18px",borderBottomLeftRadius:"10px",borderBottomRightRadius:"10px",border:"1px solid rgb(189, 180, 254)",borderTop:"none",backgroundColor:"#fff",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0}},{children:n(d,{size:14,color:"#6d28d9",style:{transform:m?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})}))}))]}))};export{l as default};
2
2
  //# sourceMappingURL=ChatDrawer.js.map
@@ -1,2 +1,2 @@
1
- import{__spreadArray as e}from"tslib";import{useState as t,useRef as r,useMemo as n}from"react";import{searchPlugin as o}from"@react-pdf-viewer/search";import{pageNavigationPlugin as i}from"@react-pdf-viewer/page-navigation";import{zoomPlugin as a}from"@react-pdf-viewer/zoom";var c=function(c,u,l,s){var f=t(0),p=f[0],h=f[1],g=r(!1),v=t(0),d=v[0],m=v[1],y=function(e){if(!e)return[];return e.replace(/\]\s*\n\s*\(/g,"](").split(/\n+/).map(function(e){var t=e.trim(),r=(t=(t=t.replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\u00A0\u2009\u202F]/g," ")).replace(/^[-•]\s+/,"")).match(/^((\d+(?:\.\d+)*[.)]?)|[A-Za-z][.)]|\([A-Za-z0-9]+\)|(?:i|ii|iii|iv|v|vi|vii|viii|ix|x)[.)])\s*/i);return r?t.slice(r[0].length).trim():t}).flatMap(function(e){var t=e.match(/^\s*\|(.+)\|\s*$/);return t?t[1].split("|").map(function(e){return e.trim()}).filter(Boolean):[e]}).map(function(e){return e.replace(/&[#\w]+;/g,function(e){return t=e,(r=document.createElement("textarea")).innerHTML=t,r.value;var t,r}).replace(/<br\s*\/?>/gi,"\n").replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/[^\S\n]+/g," ").trim()}).flatMap(function(e){return e.split(/\n+/)}).flatMap(function(e){for(var t,r=[],n=/([*_]{1,3})([^*_]+)\1|([*_]{1,3})/g,o=0;null!==(t=n.exec(e));){var i=e.slice(o,t.index).trim();i&&r.push(i),t[2]&&r.push(t[2].trim()),o=t.index+t[0].length}var a=e.slice(o).trim();return a&&r.push(a),r.flatMap(function(e){return e.split(/[\u2013\u2014-]/g)}).flatMap(function(e){return e.split(/\n+/)}).map(function(e){return e.replace(/[*_]+/g,"").replace(/`([^`]+)`/g,"$1").replace(/[^\S\n]+/g," ").trim()})})},_=Object.keys(u).map(Number).sort(function(e,t){return e-t}),T=Object.values(u).filter(function(e){return e>0}).length,b=function(t){if(l.current){var r=l.current.querySelectorAll(".rpv-search__highlights"),n=new Set,o=new Set,i=new Map;r.forEach(function(r){var a=r.getAttribute("data-testid"),u=parseInt((null==a?void 0:a.replace("search__highlights-",""))||"-1"),l=r.querySelectorAll(".rpv-search__highlight");if(u===t){var s=new Set;l.forEach(function(t){var r=t,a=(r.getAttribute("title")||"").toLowerCase(),c=r.style.top,u="".concat(a,"_#$_").concat(c);if(r.style.display="none",n.has(u))if(i.has(u)){var l=i.get(u);i.set(u,e(e([],l,!0),[r],!1))}else i.set(u,[r]);else{if(n.add(u),i.has(u)){l=i.get(u);i.set(u,e(e([],l,!0),[r],!1))}else i.set(u,[r]);o.has(a)?s.add(u):o.add(a)}});var f=w(S,i);f.forEach(function(e){var t=new Set;e.elements.forEach(function(e){var r=e.style.left,n=e.style.width,o="".concat(r,"_").concat(n);t.has(o)?e.style.display="none":(t.add(o),e.style.display="")})}),console.groupCollapsed("[debug: PDF highlight text]"),console.log("input->",c),console.log("processed text->",S),console.log("dom->processed elements->",f),console.groupEnd()}})}},w=function(e,t){for(var r=Array.from(t.entries()),n=0,o=[],i=function(e){return e.toLowerCase().replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim()},a=0,c=e;a<c.length;a++)for(var u=c[a],l=i(u);n<r.length;){var s=r[n],f=s[0],p=s[1];if(n++,l===i(f.split("_#$_")[0])){o.push({chunk:u,matchedKey:f,elements:p});break}}return o},x=function(e){l.current&&l.current.querySelectorAll(".rpv-search__highlights").forEach(function(t){var r=t.getAttribute("data-testid"),n=parseInt((null==r?void 0:r.replace(/search__highlights-/g,""))||"-1"),o=t.querySelectorAll(".rpv-search__highlight");e.has(n)||o.forEach(function(e){e.style.display="none"})})},S=c.map(function(e){return y(e)}).flat(),A=o({keyword:S}),E=i(),j=a(),q=A.jumpToMatch,B=E.jumpToPage,I=j.zoomTo,M=j.ZoomInButton,Z=j.ZoomOutButton,O=j.ZoomPopover,P=function(){if(!g.current)try{q(0),g.current=!0}catch(e){requestAnimationFrame(P)}},k=function(e,t){if(l.current&&l.current.querySelector(".rpv-core__viewer")){var r=-1,n=function(){var o,i,a=null===(o=l.current)||void 0===o?void 0:o.querySelector(".rpv-core__inner-pages");if(a){if(a.scrollTop!==r)return r=a.scrollTop,void setTimeout(n,100);var c=null===(i=l.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(c){var u=c.querySelectorAll(".rpv-search__highlight")[t];if(u){var s=a.getBoundingClientRect(),f=u.getBoundingClientRect(),p=a.scrollTop+(f.top-s.top)-a.clientHeight/2+f.height/2;a.scrollTo({top:p,behavior:"smooth"})}}}};setTimeout(n,300)}},C=n(function(){var e={};return _.forEach(function(t,r){var n=u[t];n>0&&(e[n]||(e[n]=[]),e[n].push(r))}),e},[_,u]),F=function(e){var t=u[_[e]];return(C[t]||[]).indexOf(e)};return{setHighlightIndex:h,highlightIndex:p,cursorIndex:d,setCursorIndex:m,orderedKeys:_,totalHighlights:T,getValidPosition:function(e){for(var t=0,r=0;r<=e;r++){var n=_[r];u[n]>0&&t++}return t},tryJump:P,jumpToPage:B,zoomTo:I,hideNonTargetHighlights:x,deduplicateHighlights:b,plugins:[A,E,j],controls:{ZoomInButton:M,ZoomOutButton:Z,ZoomPopover:O,goToNext:function(){for(var e=function(e){var t=_[e];if(u[t]>0){var r=u[t]-1,n=F(e);return m(e),B(u[t]-1),k(r,n),setTimeout(function(){b(r)},500),1===Object.keys(u).length&&x(s),{value:void 0}}},t=d+1;t<_.length;t++){var r=e(t);if("object"==typeof r)return r.value}},goToPrevious:function(){for(var e=function(e){var t=_[e];if(u[t]>0){var r=u[t]-1,n=F(e);return m(e),B(u[t]-1),k(r,n),setTimeout(function(){b(r)},500),1===Object.keys(u).length&&x(s),{value:void 0}}},t=d-1;t>=0;t--){var r=e(t);if("object"==typeof r)return r.value}}}}};export{c as PdfHighlightControls};
1
+ import{__spreadArray as e}from"tslib";import{useState as t,useRef as r,useMemo as n}from"react";import{searchPlugin as o}from"@react-pdf-viewer/search";import{pageNavigationPlugin as i}from"@react-pdf-viewer/page-navigation";import{zoomPlugin as a}from"@react-pdf-viewer/zoom";var l=function(l,u,c,s){var f=t(0),p=f[0],h=f[1],g=r(!1),v=t(0),d=v[0],m=v[1],_=function(e){if(!e)return[];return e.replace(/\]\s*\n\s*\(/g,"](").split(/\n+/).map(function(e){var t=e.trim(),r=(t=(t=t.replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/[\u00A0\u2009\u202F]/g," ")).replace(/^[-•]\s+/,"")).match(/^((\d+(?:\.\d+)*[.)]?)|[A-Za-z][.)]|\([A-Za-z0-9]+\)|(?:i|ii|iii|iv|v|vi|vii|viii|ix|x)[.)])\s*/i);return r?t.slice(r[0].length).trim():t}).flatMap(function(e){var t=e.match(/^\s*\|(.+)\|\s*$/);return t?t[1].split("|").map(function(e){return e.trim()}).filter(Boolean):[e]}).map(function(e){return e.replace(/&[#\w]+;/g,function(e){return t=e,(r=document.createElement("textarea")).innerHTML=t,r.value;var t,r}).replace(/<br\s*\/?>/gi,"\n").replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/[^\S\n]+/g," ").trim()}).flatMap(function(e){return e.split(/\n+/)}).flatMap(function(e){for(var t,r=[],n=/([*_]{1,3})([^*_]+)\1|([*_]{1,3})/g,o=0;null!==(t=n.exec(e));){var i=e.slice(o,t.index).trim();i&&r.push(i),t[2]&&r.push(t[2].trim()),o=t.index+t[0].length}var a=e.slice(o).trim();return a&&r.push(a),r.flatMap(function(e){return e.split(/[\u2013\u2014-]/g)}).flatMap(function(e){return e.split(/\n+/)}).map(function(e){return e.replace(/[*_]+/g,"").replace(/`([^`]+)`/g,"$1").replace(/[^\S\n]+/g," ").trim()})})},y=Object.keys(u).map(Number).sort(function(e,t){return e-t}),T=Object.values(u).filter(function(e){return e>0}).length,b=function(t){if(c.current){var r=c.current.querySelectorAll(".rpv-search__highlights"),n=new Set,o=new Set,i=new Map;r.forEach(function(r){var a=r.getAttribute("data-testid"),u=parseInt((null==a?void 0:a.replace("search__highlights-",""))||"-1"),c=r.querySelectorAll(".rpv-search__highlight");if(u===t){var s=new Set;c.forEach(function(t){var r=t,a=(r.getAttribute("title")||"").toLowerCase(),l=r.style.top,u="".concat(a,"_#$_").concat(l);if(r.style.display="none",n.has(u))if(i.has(u)){var c=i.get(u);i.set(u,e(e([],c,!0),[r],!1))}else i.set(u,[r]);else{if(n.add(u),i.has(u)){c=i.get(u);i.set(u,e(e([],c,!0),[r],!1))}else i.set(u,[r]);o.has(a)?s.add(u):o.add(a)}});var f=w(S,i);f.forEach(function(e){var t=new Set;e.elements.forEach(function(e){var r=e.style.left,n=e.style.width,o="".concat(r,"_").concat(n);t.has(o)?e.style.display="none":(t.add(o),e.style.display="")})}),console.groupCollapsed("[debug: PDF highlight text]"),console.log("input->",l),console.log("processed text->",S),console.log("dom->processed elements->",f),console.groupEnd()}})}},w=function(e,t){for(var r=Array.from(t.entries()),n=0,o=[],i=function(e){return e.toLowerCase().replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim()},a=0;a<e.length;a++)for(var l=e[a],u=i(l);n<r.length;){var c=r[n],s=c[0],f=c[1],p=i(s.split("_#$_")[0]),h=e[a+1],g=r[n+1],v=h?i(h):null,d=g?i(g[0].split("_#$_")[0]):null,m=u===p,_=n+1<r.length&&p===i(r[n+1][0].split("_#$_")[0]),y=m;if(m&&_&&v&&(y=v===d),y){o.push({chunk:l,matchedKey:s,elements:f}),n++;break}n++}return o},x=function(e){c.current&&c.current.querySelectorAll(".rpv-search__highlights").forEach(function(t){var r=t.getAttribute("data-testid"),n=parseInt((null==r?void 0:r.replace(/search__highlights-/g,""))||"-1"),o=t.querySelectorAll(".rpv-search__highlight");e.has(n)||o.forEach(function(e){e.style.display="none"})})},S=l.map(function(e){return _(e)}).flat(),A=o({keyword:S}),E=i(),j=a(),q=A.jumpToMatch,B=E.jumpToPage,I=j.zoomTo,M=j.ZoomInButton,Z=j.ZoomOutButton,O=j.ZoomPopover,P=function(){if(!g.current)try{q(0),g.current=!0}catch(e){requestAnimationFrame(P)}},$=function(e,t){if(c.current&&c.current.querySelector(".rpv-core__viewer")){var r=-1,n=function(){var o,i,a=null===(o=c.current)||void 0===o?void 0:o.querySelector(".rpv-core__inner-pages");if(a){if(a.scrollTop!==r)return r=a.scrollTop,void setTimeout(n,100);var l=null===(i=c.current)||void 0===i?void 0:i.querySelector('[data-testid="core__page-layer-'.concat(e,'"]'));if(l){var u=l.querySelectorAll(".rpv-search__highlight")[t];if(u){var s=a.getBoundingClientRect(),f=u.getBoundingClientRect(),p=a.scrollTop+(f.top-s.top)-a.clientHeight/2+f.height/2;a.scrollTo({top:p,behavior:"smooth"})}}}};setTimeout(n,300)}},k=n(function(){var e={};return y.forEach(function(t,r){var n=u[t];n>0&&(e[n]||(e[n]=[]),e[n].push(r))}),e},[y,u]),C=function(e){var t=u[y[e]];return(k[t]||[]).indexOf(e)};return{setHighlightIndex:h,highlightIndex:p,cursorIndex:d,setCursorIndex:m,orderedKeys:y,totalHighlights:T,getValidPosition:function(e){for(var t=0,r=0;r<=e;r++){var n=y[r];u[n]>0&&t++}return t},tryJump:P,jumpToPage:B,zoomTo:I,hideNonTargetHighlights:x,deduplicateHighlights:b,plugins:[A,E,j],controls:{ZoomInButton:M,ZoomOutButton:Z,ZoomPopover:O,goToNext:function(){for(var e=function(e){var t=y[e];if(u[t]>0){var r=u[t]-1,n=C(e);return m(e),B(u[t]-1),$(r,n),setTimeout(function(){b(r)},500),1===Object.keys(u).length&&x(s),{value:void 0}}},t=d+1;t<y.length;t++){var r=e(t);if("object"==typeof r)return r.value}},goToPrevious:function(){for(var e=function(e){var t=y[e];if(u[t]>0){var r=u[t]-1,n=C(e);return m(e),B(u[t]-1),$(r,n),setTimeout(function(){b(r)},500),1===Object.keys(u).length&&x(s),{value:void 0}}},t=d-1;t>=0;t--){var r=e(t);if("object"==typeof r)return r.value}}}}};export{l as PdfHighlightControls};
2
2
  //# sourceMappingURL=usePdfHighlight.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChatDrawer.d.ts","sourceRoot":"","sources":["../../../../../src/features/ChatDrawer/ChatDrawer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA2GzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"ChatDrawer.d.ts","sourceRoot":"","sources":["../../../../../src/features/ChatDrawer/ChatDrawer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAoLzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"usePdfHighlight.d.ts","sourceRoot":"","sources":["../../../../../src/features/PdfViewer/usePdfHighlight.tsx"],"names":[],"mappings":";AAKA,eAAO,MAAM,oBAAoB,kBAChB,MAAM,EAAE,kBACP,OAAO,MAAM,EAAE,MAAM,CAAC,aAC3B,MAAM,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,oBAC9B,IAAI,MAAM,CAAC;;;;;;;+BAyHI,MAAM;;;;2CAmNM,IAAI,MAAM,CAAC;wCAlId,MAAM;;;;;;;;;CA4TlD,CAAC"}
1
+ {"version":3,"file":"usePdfHighlight.d.ts","sourceRoot":"","sources":["../../../../../src/features/PdfViewer/usePdfHighlight.tsx"],"names":[],"mappings":";AAKA,eAAO,MAAM,oBAAoB,kBAChB,MAAM,EAAE,kBACP,OAAO,MAAM,EAAE,MAAM,CAAC,aAC3B,MAAM,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,oBAC9B,IAAI,MAAM,CAAC;;;;;;;+BAyHI,MAAM;;;;2CA0OM,IAAI,MAAM,CAAC;wCAzJd,MAAM;;;;;;;;;CAmVlD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-llm-studio/citation",
3
- "version": "0.0.163",
3
+ "version": "0.0.164",
4
4
  "author": "Devesh Patel",
5
5
  "description": "",
6
6
  "license": "MIT",