@deepcitation/deepcitation-js 1.1.49 → 1.1.50

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.
Files changed (45) hide show
  1. package/README.md +156 -157
  2. package/lib/{chunk-D2TKEF6D.cjs → chunk-4ILSZKAP.cjs} +3 -2
  3. package/lib/chunk-4ILSZKAP.cjs.map +1 -0
  4. package/lib/chunk-5XGN7UAV.js +2 -0
  5. package/lib/chunk-5XGN7UAV.js.map +1 -0
  6. package/lib/{chunk-2PRW5PVT.cjs → chunk-ALJ2ZQ2S.cjs} +2 -1
  7. package/lib/chunk-ALJ2ZQ2S.cjs.map +1 -0
  8. package/lib/{chunk-F2MMVEVC.cjs → chunk-BYLIBOAU.cjs} +2 -1
  9. package/lib/chunk-BYLIBOAU.cjs.map +1 -0
  10. package/lib/{chunk-ND6LFDGK.js → chunk-KBDVUQEE.js} +2 -1
  11. package/lib/chunk-KBDVUQEE.js.map +1 -0
  12. package/lib/{chunk-PKXMJNRX.js → chunk-LLLVZOXB.js} +2 -1
  13. package/lib/chunk-LLLVZOXB.js.map +1 -0
  14. package/lib/{chunk-DHVODVIA.cjs → chunk-PJWAX2VG.cjs} +2 -1
  15. package/lib/chunk-PJWAX2VG.cjs.map +1 -0
  16. package/lib/{chunk-UUR2SQKU.cjs → chunk-QUW3L3UU.cjs} +2 -1
  17. package/lib/chunk-QUW3L3UU.cjs.map +1 -0
  18. package/lib/chunk-R57DQBOT.js +2 -0
  19. package/lib/chunk-R57DQBOT.js.map +1 -0
  20. package/lib/{chunk-3XSZLKJW.js → chunk-TDGYSF3B.js} +3 -2
  21. package/lib/chunk-TDGYSF3B.js.map +1 -0
  22. package/lib/client/index.cjs +2 -1
  23. package/lib/client/index.cjs.map +1 -0
  24. package/lib/client/index.js +2 -1
  25. package/lib/client/index.js.map +1 -0
  26. package/lib/index.cjs +2 -1
  27. package/lib/index.cjs.map +1 -0
  28. package/lib/index.js +2 -1
  29. package/lib/index.js.map +1 -0
  30. package/lib/prompts/index.cjs +2 -1
  31. package/lib/prompts/index.cjs.map +1 -0
  32. package/lib/prompts/index.js +2 -1
  33. package/lib/prompts/index.js.map +1 -0
  34. package/lib/react/index.cjs +4 -3
  35. package/lib/react/index.cjs.map +1 -0
  36. package/lib/react/index.js +3 -2
  37. package/lib/react/index.js.map +1 -0
  38. package/lib/types/index.cjs +2 -1
  39. package/lib/types/index.cjs.map +1 -0
  40. package/lib/types/index.js +2 -1
  41. package/lib/types/index.js.map +1 -0
  42. package/package.json +161 -152
  43. package/src/tailwind.css +5 -5
  44. package/lib/chunk-HRCAI3NV.js +0 -1
  45. package/lib/chunk-O2XFH626.js +0 -1
@@ -1,5 +1,6 @@
1
- import {d,f,j,b}from'../chunk-PKXMJNRX.js';export{k as CITATION_X_PADDING,l as CITATION_Y_PADDING,j as classNames,f as generateCitationInstanceId,d as generateCitationKey,g as getCitationDisplayText,i as getCitationKeySpanText,h as getCitationNumber,c as isUrlCitation}from'../chunk-PKXMJNRX.js';import'../chunk-O2XFH626.js';import*as We from'react';import We__default,{forwardRef,useMemo,useCallback,memo,createContext,useState,useRef,useEffect,useContext}from'react';import {jsxs,Fragment,jsx}from'react/jsx-runtime';import {createPortal}from'react-dom';import*as H from'@radix-ui/react-popover';function K(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e.replace(/^https?:\/\/(www\.)?/,"").split("/")[0]}}function Ye(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}function Vt(e){try{let t=new URL(e),r=t.pathname+t.search;return r==="/"?"":r}catch{return ""}}var Ze={verified:{icon:"\u2713",label:"Verified",className:"text-green-600 dark:text-green-500"},partial:{icon:"~",label:"Partial match",className:"text-amber-600 dark:text-amber-500"},pending:{icon:"\u2026",label:"Verifying",className:"text-gray-400 dark:text-gray-500"},accessible:{icon:"\u25CB",label:"Accessible",className:"text-blue-500 dark:text-blue-400"},redirected:{icon:"\u21AA",label:"Redirected",className:"text-amber-600 dark:text-amber-500"},redirected_valid:{icon:"\u21AA\u2713",label:"Redirected (valid)",className:"text-green-600 dark:text-green-500"},blocked_antibot:{icon:"\u{1F6E1}",label:"Blocked by anti-bot",className:"text-amber-600 dark:text-amber-500"},blocked_login:{icon:"\u{1F512}",label:"Login required",className:"text-amber-600 dark:text-amber-500"},blocked_paywall:{icon:"\u{1F4B3}",label:"Paywall",className:"text-amber-600 dark:text-amber-500"},blocked_geo:{icon:"\u{1F30D}",label:"Geo-restricted",className:"text-amber-600 dark:text-amber-500"},blocked_rate_limit:{icon:"\u23F1",label:"Rate limited",className:"text-amber-600 dark:text-amber-500"},error_timeout:{icon:"\u23F0",label:"Timed out",className:"text-red-500 dark:text-red-400"},error_not_found:{icon:"404",label:"Not found",className:"text-red-500 dark:text-red-400"},error_server:{icon:"\u26A0",label:"Server error",className:"text-red-500 dark:text-red-400"},error_network:{icon:"\u26A1",label:"Network error",className:"text-red-500 dark:text-red-400"},unknown:{icon:"?",label:"Unknown status",className:"text-gray-400 dark:text-gray-500"}};function Je(e){return e.startsWith("blocked_")}function qe(e){return e.startsWith("error_")}function jt(e){return e==="verified"||e==="partial"||e==="accessible"||e==="redirected_valid"}function zt(e){return e==="redirected"||e==="redirected_valid"}function Wt(e){return e==="verified"||e==="partial"||e==="redirected_valid"}var Ut=({status:e,errorMessage:t})=>{let r=Ze[e];return jsx("span",{className:j("inline-flex items-center gap-1",r.className),title:t||r.label,"aria-label":r.label,children:jsx("span",{className:"text-[0.9em]","aria-hidden":"true",children:r.icon})})},Se=({url:e,faviconUrl:t})=>{let r=K(e),n=t||`https://www.google.com/s2/favicons?domain=${r}&sz=16`;return jsx("img",{src:n,alt:"",className:"w-3.5 h-3.5 rounded-sm",width:14,height:14,loading:"lazy",onError:a=>{a.target.style.display="none";}})},Qe=forwardRef(({urlMeta:e,citation:t,children:r,className:n,variant:a="chip",showFullUrlOnHover:o=true,showFavicon:i=true,showTitle:d$1=false,maxDisplayLength:s=30,renderBlockedIndicator:c,onUrlClick:u,eventHandlers:l,preventTooltips:g=false},x)=>{let{url:p,domain:S,title:E,fetchStatus:h,faviconUrl:P,errorMessage:w}=e,L=useMemo(()=>t||{value:p,fullPhrase:E||p},[t,p,E]),_=useMemo(()=>d(L),[L]),j$1=useMemo(()=>f(_),[_]),T=useMemo(()=>S||K(p),[S,p]),A=useMemo(()=>Vt(p),[p]),U=useMemo(()=>{if(d$1&&E)return Ye(E,s);let M=A?Ye(A,s-T.length-1):"";return M?`${T}${M}`:T},[d$1,E,T,A,s]),v=Ze[h],ce=Je(h),b=qe(h),C=h==="verified",D=h==="partial",z=h==="pending",Y=useCallback(M=>{M.preventDefault(),M.stopPropagation(),u?u(p,M):window.open(p,"_blank","noopener,noreferrer"),l?.onClick?.(L,_,M);},[u,p,l,L,_]),de=useCallback(()=>{l?.onMouseEnter?.(L,_);},[l,L,_]),ue=useCallback(()=>{l?.onMouseLeave?.(L,_);},[l,L,_]),Q=()=>ce||b?c?c(h,w):jsx(Ut,{status:h,errorMessage:w}):C?jsx("span",{className:"text-[0.85em] text-green-600 dark:text-green-500","aria-hidden":"true",title:"Verified",children:"\u2713"}):D?jsx("span",{className:"text-[0.85em] text-amber-600 dark:text-amber-500","aria-hidden":"true",title:"Partial match",children:"~"}):z?jsx("span",{className:"opacity-70","aria-hidden":"true",children:"\u2026"}):null;return a==="chip"?jsxs(Fragment,{children:[r,jsxs("span",{ref:x,"data-citation-id":_,"data-citation-instance":j$1,"data-url":p,"data-fetch-status":h,"data-variant":"chip",className:j("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-sm cursor-pointer transition-colors no-underline","bg-blue-100 dark:bg-blue-900/30",v.className,n),title:o?p:void 0,onMouseEnter:g?void 0:de,onMouseLeave:g?void 0:ue,onMouseDown:Y,onClick:M=>M.stopPropagation(),role:"link","aria-label":`Link to ${T}: ${v.label}`,children:[i&&jsx(Se,{url:p,faviconUrl:P}),jsx("span",{className:"max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap",children:U}),Q()]})]}):a==="inline"?jsxs(Fragment,{children:[r,jsxs("a",{ref:x,href:p,"data-citation-id":_,"data-citation-instance":j$1,"data-fetch-status":h,"data-variant":"inline",className:j("inline-flex items-center gap-1 cursor-pointer transition-colors no-underline border-b border-dotted border-current",v.className,n),title:o?p:void 0,onMouseEnter:g?void 0:de,onMouseLeave:g?void 0:ue,onClick:M=>{M.preventDefault(),Y(M);},target:"_blank",rel:"noopener noreferrer","aria-label":`Link to ${T}: ${v.label}`,children:[i&&jsx(Se,{url:p,faviconUrl:P}),jsx("span",{children:U}),Q()]})]}):jsxs(Fragment,{children:[r,jsxs("span",{ref:x,"data-citation-id":_,"data-citation-instance":j$1,"data-url":p,"data-fetch-status":h,"data-variant":"bracket",className:j("cursor-pointer transition-colors",v.className,n),title:o?p:void 0,onMouseEnter:g?void 0:de,onMouseLeave:g?void 0:ue,onMouseDown:Y,onClick:M=>M.stopPropagation(),role:"link","aria-label":`Link to ${T}: ${v.label}`,children:["[",i&&jsx(Se,{url:p,faviconUrl:P}),jsx("span",{className:"max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap",children:U}),Q(),"]"]})]})});Qe.displayName="UrlCitationComponent";memo(Qe);var At=({className:e})=>jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"square",shapeRendering:"crispEdges",className:e,width:"1em",height:"1em",children:[jsx("path",{d:"M7 3 L3 3 L3 21 L7 21"}),jsx("path",{d:"M17 3 L21 3 L21 21 L17 21"})]}),q=({className:e})=>jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{width:"100%",height:"100%"},children:jsx("polyline",{points:"20 6 9 17 4 12"})}),re=({className:e})=>jsx("svg",{className:e,viewBox:"0 0 256 256",fill:"currentColor","aria-hidden":"true",style:{width:"100%",height:"100%"},children:jsx("path",{d:"M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM120,104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm8,88a12,12,0,1,1,12-12A12,12,0,0,1,128,192Z"})}),ie=({className:e})=>jsxs("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",style:{width:"100%",height:"100%"},children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",style:{opacity:.25}}),jsx("path",{fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z",style:{opacity:.75}})]}),Ht=({className:e})=>jsxs("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{width:"100%",height:"100%"},children:[jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),$t=({className:e})=>jsxs("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{width:"100%",height:"100%"},children:[jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),jsx("polyline",{points:"15 3 21 3 21 9"}),jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),Ft=({className:e})=>jsxs("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{width:"100%",height:"100%"},children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]});function Kt(...e){return e.filter(Boolean).join(" ")}var rt=H.Root,at=H.Trigger;var Me=We.forwardRef(({className:e,align:t="center",sideOffset:r=8,...n},a)=>jsx(H.Portal,{children:jsx(H.Content,{ref:a,align:t,sideOffset:r,className:Kt("z-[9998] rounded-lg border bg-white shadow-xl outline-none","w-fit max-w-[min(400px,calc(100vw-2rem))]","border-gray-200 dark:border-gray-700 dark:bg-gray-900","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2","data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2","data-[side=top]:slide-in-from-bottom-2",e),...n})}));Me.displayName=H.Content.displayName;function lt(e,t,r=(n,a)=>n===a){let n=e.length,a=t.length;if(n===0&&a===0)return [];if(n===0)return [{value:t.join(""),added:true,count:t.length}];if(a===0)return [{value:e.join(""),removed:true,count:e.length}];let o=0;for(;o<n&&o<a&&r(e[o],t[o]);)o++;let i=0;for(;i<n-o&&i<a-o&&r(e[n-1-i],t[a-1-i]);)i++;let d=e.slice(o,n-i),s=t.slice(o,a-i);if(d.length===0&&s.length===0)return [{value:e.join(""),count:e.length}];let c=Gt(d,s,r),u=[];return o>0&&u.push({value:e.slice(0,o).join(""),count:o}),u.push(...c),i>0&&u.push({value:e.slice(n-i).join(""),count:i}),ct(u)}function Gt(e,t,r){let n=e.length,a=t.length,o=n+a,i={1:0},d=[];e:for(let s=0;s<=o;s++){d.push({...i});for(let c=-s;c<=s;c+=2){let u;c===-s||c!==s&&i[c-1]<i[c+1]?u=i[c+1]:u=i[c-1]+1;let l=u-c;for(;u<n&&l<a&&r(e[u],t[l]);)u++,l++;if(i[c]=u,u>=n&&l>=a)break e}}return Xt(d,e,t)}function Xt(e,t,r){let n=[],a=t.length,o=r.length;for(let i=e.length-1;i>=0;i--){let d=e[i],s=a-o,c;s===-i||s!==i&&d[s-1]<d[s+1]?c=s+1:c=s-1;let u=d[c]??0,l=u-c;for(;a>u&&o>l;)a--,o--,n.push({value:t[a],count:1});i>0&&(a===u?(o--,n.push({value:r[o],added:true,count:1})):(a--,n.push({value:t[a],removed:true,count:1})));}return n.reverse()}function ct(e){if(e.length===0)return [];let t=[];for(let r of e){let n=t[t.length-1];n&&n.added===r.added&&n.removed===r.removed?(n.value+=r.value,n.count=(n.count||1)+(r.count||1)):t.push({...r});}return t}function nt(e){if(!e)return [];let t=[],r=0;for(let n=0;n<e.length;n++)e[n]===`
1
+ import {d,f,j,b}from'../chunk-LLLVZOXB.js';export{k as CITATION_X_PADDING,l as CITATION_Y_PADDING,j as classNames,f as generateCitationInstanceId,d as generateCitationKey,g as getCitationDisplayText,i as getCitationKeySpanText,h as getCitationNumber,c as isUrlCitation}from'../chunk-LLLVZOXB.js';import'../chunk-5XGN7UAV.js';import*as We from'react';import We__default,{forwardRef,useMemo,useCallback,memo,createContext,useState,useRef,useEffect,useContext}from'react';import {jsxs,Fragment,jsx}from'react/jsx-runtime';import {createPortal}from'react-dom';import*as H from'@radix-ui/react-popover';function K(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e.replace(/^https?:\/\/(www\.)?/,"").split("/")[0]}}function Ye(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}function Vt(e){try{let t=new URL(e),r=t.pathname+t.search;return r==="/"?"":r}catch{return ""}}var Ze={verified:{icon:"\u2713",label:"Verified",className:"text-green-600 dark:text-green-500"},partial:{icon:"~",label:"Partial match",className:"text-amber-600 dark:text-amber-500"},pending:{icon:"\u2026",label:"Verifying",className:"text-gray-400 dark:text-gray-500"},accessible:{icon:"\u25CB",label:"Accessible",className:"text-blue-500 dark:text-blue-400"},redirected:{icon:"\u21AA",label:"Redirected",className:"text-amber-600 dark:text-amber-500"},redirected_valid:{icon:"\u21AA\u2713",label:"Redirected (valid)",className:"text-green-600 dark:text-green-500"},blocked_antibot:{icon:"\u{1F6E1}",label:"Blocked by anti-bot",className:"text-amber-600 dark:text-amber-500"},blocked_login:{icon:"\u{1F512}",label:"Login required",className:"text-amber-600 dark:text-amber-500"},blocked_paywall:{icon:"\u{1F4B3}",label:"Paywall",className:"text-amber-600 dark:text-amber-500"},blocked_geo:{icon:"\u{1F30D}",label:"Geo-restricted",className:"text-amber-600 dark:text-amber-500"},blocked_rate_limit:{icon:"\u23F1",label:"Rate limited",className:"text-amber-600 dark:text-amber-500"},error_timeout:{icon:"\u23F0",label:"Timed out",className:"text-red-500 dark:text-red-400"},error_not_found:{icon:"404",label:"Not found",className:"text-red-500 dark:text-red-400"},error_server:{icon:"\u26A0",label:"Server error",className:"text-red-500 dark:text-red-400"},error_network:{icon:"\u26A1",label:"Network error",className:"text-red-500 dark:text-red-400"},unknown:{icon:"?",label:"Unknown status",className:"text-gray-400 dark:text-gray-500"}};function Je(e){return e.startsWith("blocked_")}function qe(e){return e.startsWith("error_")}function jt(e){return e==="verified"||e==="partial"||e==="accessible"||e==="redirected_valid"}function zt(e){return e==="redirected"||e==="redirected_valid"}function Wt(e){return e==="verified"||e==="partial"||e==="redirected_valid"}var Ut=({status:e,errorMessage:t})=>{let r=Ze[e];return jsx("span",{className:j("inline-flex items-center gap-1",r.className),title:t||r.label,"aria-label":r.label,children:jsx("span",{className:"text-[0.9em]","aria-hidden":"true",children:r.icon})})},Se=({url:e,faviconUrl:t})=>{let r=K(e),n=t||`https://www.google.com/s2/favicons?domain=${r}&sz=16`;return jsx("img",{src:n,alt:"",className:"w-3.5 h-3.5 rounded-sm",width:14,height:14,loading:"lazy",onError:a=>{a.target.style.display="none";}})},Qe=forwardRef(({urlMeta:e,citation:t,children:r,className:n,variant:a="chip",showFullUrlOnHover:o=true,showFavicon:i=true,showTitle:d$1=false,maxDisplayLength:s=30,renderBlockedIndicator:c,onUrlClick:u,eventHandlers:l,preventTooltips:g=false},x)=>{let{url:p,domain:S,title:E,fetchStatus:h,faviconUrl:P,errorMessage:w}=e,L=useMemo(()=>t||{value:p,fullPhrase:E||p},[t,p,E]),_=useMemo(()=>d(L),[L]),j$1=useMemo(()=>f(_),[_]),T=useMemo(()=>S||K(p),[S,p]),A=useMemo(()=>Vt(p),[p]),U=useMemo(()=>{if(d$1&&E)return Ye(E,s);let M=A?Ye(A,s-T.length-1):"";return M?`${T}${M}`:T},[d$1,E,T,A,s]),v=Ze[h],ce=Je(h),b=qe(h),C=h==="verified",D=h==="partial",z=h==="pending",Y=useCallback(M=>{M.preventDefault(),M.stopPropagation(),u?u(p,M):window.open(p,"_blank","noopener,noreferrer"),l?.onClick?.(L,_,M);},[u,p,l,L,_]),de=useCallback(()=>{l?.onMouseEnter?.(L,_);},[l,L,_]),ue=useCallback(()=>{l?.onMouseLeave?.(L,_);},[l,L,_]),Q=()=>ce||b?c?c(h,w):jsx(Ut,{status:h,errorMessage:w}):C?jsx("span",{className:"text-[0.85em] text-green-600 dark:text-green-500","aria-hidden":"true",title:"Verified",children:"\u2713"}):D?jsx("span",{className:"text-[0.85em] text-amber-600 dark:text-amber-500","aria-hidden":"true",title:"Partial match",children:"~"}):z?jsx("span",{className:"opacity-70","aria-hidden":"true",children:"\u2026"}):null;return a==="chip"?jsxs(Fragment,{children:[r,jsxs("span",{ref:x,"data-citation-id":_,"data-citation-instance":j$1,"data-url":p,"data-fetch-status":h,"data-variant":"chip",className:j("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-sm cursor-pointer transition-colors no-underline","bg-blue-100 dark:bg-blue-900/30",v.className,n),title:o?p:void 0,onMouseEnter:g?void 0:de,onMouseLeave:g?void 0:ue,onMouseDown:Y,onClick:M=>M.stopPropagation(),role:"link","aria-label":`Link to ${T}: ${v.label}`,children:[i&&jsx(Se,{url:p,faviconUrl:P}),jsx("span",{className:"max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap",children:U}),Q()]})]}):a==="inline"?jsxs(Fragment,{children:[r,jsxs("a",{ref:x,href:p,"data-citation-id":_,"data-citation-instance":j$1,"data-fetch-status":h,"data-variant":"inline",className:j("inline-flex items-center gap-1 cursor-pointer transition-colors no-underline border-b border-dotted border-current",v.className,n),title:o?p:void 0,onMouseEnter:g?void 0:de,onMouseLeave:g?void 0:ue,onClick:M=>{M.preventDefault(),Y(M);},target:"_blank",rel:"noopener noreferrer","aria-label":`Link to ${T}: ${v.label}`,children:[i&&jsx(Se,{url:p,faviconUrl:P}),jsx("span",{children:U}),Q()]})]}):jsxs(Fragment,{children:[r,jsxs("span",{ref:x,"data-citation-id":_,"data-citation-instance":j$1,"data-url":p,"data-fetch-status":h,"data-variant":"bracket",className:j("cursor-pointer transition-colors",v.className,n),title:o?p:void 0,onMouseEnter:g?void 0:de,onMouseLeave:g?void 0:ue,onMouseDown:Y,onClick:M=>M.stopPropagation(),role:"link","aria-label":`Link to ${T}: ${v.label}`,children:["[",i&&jsx(Se,{url:p,faviconUrl:P}),jsx("span",{className:"max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap",children:U}),Q(),"]"]})]})});Qe.displayName="UrlCitationComponent";memo(Qe);var At=({className:e})=>jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"square",shapeRendering:"crispEdges",className:e,width:"1em",height:"1em",children:[jsx("path",{d:"M7 3 L3 3 L3 21 L7 21"}),jsx("path",{d:"M17 3 L21 3 L21 21 L17 21"})]}),q=({className:e})=>jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{width:"100%",height:"100%"},children:jsx("polyline",{points:"20 6 9 17 4 12"})}),re=({className:e})=>jsx("svg",{className:e,viewBox:"0 0 256 256",fill:"currentColor","aria-hidden":"true",style:{width:"100%",height:"100%"},children:jsx("path",{d:"M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM120,104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm8,88a12,12,0,1,1,12-12A12,12,0,0,1,128,192Z"})}),ie=({className:e})=>jsxs("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",style:{width:"100%",height:"100%"},children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",style:{opacity:.25}}),jsx("path",{fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z",style:{opacity:.75}})]}),Ht=({className:e})=>jsxs("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{width:"100%",height:"100%"},children:[jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),$t=({className:e})=>jsxs("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{width:"100%",height:"100%"},children:[jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),jsx("polyline",{points:"15 3 21 3 21 9"}),jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),Ft=({className:e})=>jsxs("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{width:"100%",height:"100%"},children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]});function Kt(...e){return e.filter(Boolean).join(" ")}var rt=H.Root,at=H.Trigger;var Me=We.forwardRef(({className:e,align:t="center",sideOffset:r=8,...n},a)=>jsx(H.Portal,{children:jsx(H.Content,{ref:a,align:t,sideOffset:r,className:Kt("z-[9998] rounded-lg border bg-white shadow-xl outline-none","w-fit max-w-[min(400px,calc(100vw-2rem))]","border-gray-200 dark:border-gray-700 dark:bg-gray-900","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2","data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2","data-[side=top]:slide-in-from-bottom-2",e),...n})}));Me.displayName=H.Content.displayName;function lt(e,t,r=(n,a)=>n===a){let n=e.length,a=t.length;if(n===0&&a===0)return [];if(n===0)return [{value:t.join(""),added:true,count:t.length}];if(a===0)return [{value:e.join(""),removed:true,count:e.length}];let o=0;for(;o<n&&o<a&&r(e[o],t[o]);)o++;let i=0;for(;i<n-o&&i<a-o&&r(e[n-1-i],t[a-1-i]);)i++;let d=e.slice(o,n-i),s=t.slice(o,a-i);if(d.length===0&&s.length===0)return [{value:e.join(""),count:e.length}];let c=Gt(d,s,r),u=[];return o>0&&u.push({value:e.slice(0,o).join(""),count:o}),u.push(...c),i>0&&u.push({value:e.slice(n-i).join(""),count:i}),ct(u)}function Gt(e,t,r){let n=e.length,a=t.length,o=n+a,i={1:0},d=[];e:for(let s=0;s<=o;s++){d.push({...i});for(let c=-s;c<=s;c+=2){let u;c===-s||c!==s&&i[c-1]<i[c+1]?u=i[c+1]:u=i[c-1]+1;let l=u-c;for(;u<n&&l<a&&r(e[u],t[l]);)u++,l++;if(i[c]=u,u>=n&&l>=a)break e}}return Xt(d,e,t)}function Xt(e,t,r){let n=[],a=t.length,o=r.length;for(let i=e.length-1;i>=0;i--){let d=e[i],s=a-o,c;s===-i||s!==i&&d[s-1]<d[s+1]?c=s+1:c=s-1;let u=d[c]??0,l=u-c;for(;a>u&&o>l;)a--,o--,n.push({value:t[a],count:1});i>0&&(a===u?(o--,n.push({value:r[o],added:true,count:1})):(a--,n.push({value:t[a],removed:true,count:1})));}return n.reverse()}function ct(e){if(e.length===0)return [];let t=[];for(let r of e){let n=t[t.length-1];n&&n.added===r.added&&n.removed===r.removed?(n.value+=r.value,n.count=(n.count||1)+(r.count||1)):t.push({...r});}return t}function nt(e){if(!e)return [];let t=[],r=0;for(let n=0;n<e.length;n++)e[n]===`
2
2
  `&&(t.push(e.substring(r,n+1)),r=n+1);return r<e.length&&t.push(e.substring(r)),t}var ot="a-zA-Z0-9_\\u00AD\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C6\\u02C8-\\u02D7\\u02DE-\\u02FF\\u1E00-\\u1EFF",Yt=new RegExp(`[${ot}]+|\\s+|[^${ot}]`,"gu");function it(e){return e?e.match(Yt)||[]:[]}function st(e,t){let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];)r++;return e.slice(0,r)}function Ie(e,t){let r=0;for(;r<e.length&&r<t.length&&e[e.length-1-r]===t[t.length-1-r];)r++;return e.slice(e.length-r)}function Zt(e){let t=[];for(let r=0;r<e.length;r++){let n=e[r];if(n.removed&&e[r+1]?.added){let a=n,o=e[r+1],d=st(a.value,o.value).match(/^\s*/)?.[0]||"",s=a.value.slice(d.length),c=o.value.slice(d.length),l=Ie(s,c).match(/\s*$/)?.[0]||"";d&&t.push({value:d,count:1});let g=a.value.slice(d.length,a.value.length-l.length),x=o.value.slice(d.length,o.value.length-l.length);g&&t.push({value:g,removed:true,count:1}),x&&t.push({value:x,added:true,count:1}),l&&t.push({value:l,count:1}),r++;continue}if(n.added&&r>0&&!e[r-1].added&&!e[r-1].removed){let a=t[t.length-1];if(a&&!a.added&&!a.removed){let o=n.value.match(/^\s*/)?.[0]||"",i=a.value.match(/\s*$/)?.[0]||"";if(o&&i){let d=Ie(i,o);if(d){t.push({value:n.value.slice(d.length),added:true,count:1});continue}}}}if(n.removed&&!e[r+1]?.added&&r>0&&!e[r-1]?.added&&!e[r-1]?.removed){let a=t[t.length-1],o=e[r+1];if(a&&o&&!o.added&&!o.removed){let i=n.value.match(/^\s*/)?.[0]||"",d=n.value.match(/\s*$/)?.[0]||"",s=a.value.match(/\s*$/)?.[0]||"",c=o.value.match(/^\s*/)?.[0]||"";if(i&&s&&Ie(s,i).length===i.length){t.push({value:n.value.slice(i.length),removed:true,count:1});continue}if(d&&c&&st(d,c).length===d.length){t.push({value:n.value.slice(0,-d.length)||n.value,removed:true,count:1});continue}}}t.push({...n});}return ct(t)}function dt(e,t){let r=nt(e),n=nt(t);return lt(r,n)}function ut(e,t){let r=it(e),n=it(t),a=lt(r,n);return Zt(a)}var mt=(e="",t="")=>useMemo(()=>{let r=(e||"").trim().replace(/\r\n/g,`
3
3
  `),n=(t||"").trim().replace(/\r\n/g,`
4
4
  `),a=dt(r,n),o=[],i=false,d=0;for(let u=0;u<a.length;u++){let l=a[u],g=a[u+1];if(l.removed&&g&&g.added){let x=ut(l.value,g.value);o.push({type:"modified",parts:x}),i=true,d+=Math.abs(l.value.length-g.value.length),u++;}else l.added||l.removed?(o.push({type:l.added?"added":"removed",parts:[{value:l.value,added:l.added,removed:l.removed}]}),i=true,d+=l.value.length):o.push({type:"unchanged",parts:[{value:l.value}]});}let s=Math.max(r.length,n.length),c=s===0?1:1-d/s;return {diffResult:o,hasDiff:i,similarity:c,isHighVariance:c<.6}},[e,t]);var Ee=createContext(null);function tr({children:e}){let[t,r]=useState(0),n=useCallback(()=>{r(i=>i+1);},[]),a=useCallback(()=>{r(i=>Math.max(0,i-1));},[]),o=useMemo(()=>({isAnyOverlayOpen:t>0,registerOverlay:n,unregisterOverlay:a}),[t,n,a]);return jsx(Ee.Provider,{value:o,children:e})}function ve(){let e=useContext(Ee);return e||{isAnyOverlayOpen:false,registerOverlay:()=>{},unregisterOverlay:()=>{}}}function rr(){return useContext(Ee)!==null}function sr(e){switch(e){case "chip":case "text":case "brackets":return "keySpan";case "source":return "source";default:return "number"}}function lr(e){return e.replace(/^\[+\s*/,"").replace(/\s*\]+$/,"")}function cr(e,t,r){if(t==="indicator")return "";if(t==="keySpan"){let n=e.keySpan?.toString()||e.citationNumber?.toString()||r||"1";return lr(n)}return t==="source"?e.siteName||e.domain||e.keySpan?.toString()||"Source":e.citationNumber?.toString()||"1"}function dr(e){return e.isVerified&&!e.isPartialMatch?"Verified":e.isPartialMatch?"Partial Match":e.isMiss?"Not Found":e.isPending?"Verifying...":""}function ur(e){let t=e?.status;if(!e||!t)return {isVerified:false,isMiss:false,isPartialMatch:false,isPending:false};let r=t==="not_found",n=t==="pending"||t==="loading",a=t==="partial_text_found"||t==="found_on_other_page"||t==="found_on_other_line"||t==="first_word_found";return {isVerified:t==="found"||t==="found_key_span_only"||t==="found_phrase_missed_value"||a,isMiss:r,isPartialMatch:a,isPending:n}}function mr({src:e,alt:t,onClose:r}){let{registerOverlay:n,unregisterOverlay:a}=ve();return useEffect(()=>(n(),()=>a()),[n,a]),useEffect(()=>{let o=i=>{i.key==="Escape"&&r();};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[r]),createPortal(jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm animate-in fade-in-0 duration-[50ms]",onClick:r,role:"dialog","aria-modal":"true","aria-label":"Full size verification image",children:jsx("div",{className:"relative max-w-[95vw] max-h-[95vh] cursor-zoom-out animate-in zoom-in-95 duration-[50ms]",children:jsx("img",{src:e,alt:t,className:"max-w-full max-h-[95vh] object-contain rounded-lg shadow-2xl",draggable:false})})}),document.body)}var pr=()=>jsx("span",{className:"inline-flex relative ml-0.5 size-2 text-green-600 dark:text-green-500","aria-hidden":"true",children:jsx(q,{})}),gr=()=>jsx("span",{className:"inline-flex relative ml-0.5 size-2 text-amber-600 dark:text-amber-500","aria-hidden":"true",children:jsx(q,{})}),fr=()=>jsx("span",{className:"inline-flex ml-1 size-2 animate-spin text-gray-400 dark:text-gray-500","aria-hidden":"true",children:jsx(ie,{})}),xr=()=>jsx("span",{className:"inline-flex relative ml-0.5 size-2 text-amber-500 dark:text-amber-400","aria-hidden":"true",children:jsx(re,{})});function hr({citation:e,verification:t,isExpanded:r,onExpandChange:n}){let a=useMemo(()=>{let l=new Set;if(t?.searchAttempts){for(let g of t.searchAttempts)if(g.searchPhrases)for(let x of g.searchPhrases)x&&l.add(x);}return l.size===0&&(e.fullPhrase&&l.add(e.fullPhrase),e.keySpan&&l.add(e.keySpan.toString())),Array.from(l)},[e,t]),[o,i]=useState(false),d=r??o,s=useCallback(l=>{n?n(l):i(l);},[n]);if(a.length===0)return null;let c=d?a.length:1,u=a.length-1;return jsxs("div",{className:"mt-2",children:[jsxs("div",{className:"flex items-center gap-2 text-[10px] text-gray-500 dark:text-gray-400 uppercase font-medium",children:[jsxs("span",{children:["Searched ",a.length," phrase",a.length!==1?"s":""]}),u>0&&!d&&jsxs("button",{type:"button",onClick:()=>s(true),className:"text-blue-500 hover:text-blue-600 dark:text-blue-400 dark:hover:text-blue-300 lowercase",children:["+",u," more"]}),d&&u>0&&jsx("button",{type:"button",onClick:()=>s(false),className:"text-blue-500 hover:text-blue-600 dark:text-blue-400 dark:hover:text-blue-300 lowercase",children:"collapse"})]}),jsx("div",{className:"mt-1 space-y-1",children:a.slice(0,c).map((l,g)=>jsxs("p",{className:"pl-2 py-1 font-mono text-[11px] break-words text-gray-700 dark:text-gray-300 border-l-2 border-red-400 dark:border-red-500",children:['"',l.length>80?l.slice(0,80)+"\u2026":l,'"']},g))})]})}function yr({citation:e,verification:t,status:r,onImageClick:n,isLoading:a=false,isPhrasesExpanded:o,onPhrasesExpandChange:i}){let d=t?.verificationImageBase64,{isMiss:s,isPartialMatch:c,isPending:u}=r;if(d){let p=r.isVerified&&!r.isPartialMatch,S=p||r.isPartialMatch;return jsxs("div",{className:"p-2",style:{maxWidth:"100%",overflow:"hidden"},children:[jsxs("button",{type:"button",className:"group block cursor-zoom-in relative overflow-hidden rounded-md bg-gray-50 dark:bg-gray-800",style:{width:"100%",maxWidth:"384px",height:"200px"},onClick:E=>{E.preventDefault(),E.stopPropagation(),n?.();},"aria-label":"Click to view full size",children:[jsx("img",{src:t.verificationImageBase64,alt:"Citation verification",className:"block rounded-md",style:{width:"100%",height:"100%",objectFit:"cover",objectPosition:"left top"},loading:"lazy"}),jsxs("span",{className:"absolute left-0 right-0 bottom-0 flex items-center justify-between px-2 pb-1.5 pt-4 bg-gradient-to-t from-black/30 to-transparent rounded-b-md",children:[jsxs("span",{className:`inline-flex items-center gap-1 ${p?"text-green-400":r.isPartialMatch?"text-amber-400":r.isMiss?"text-red-400":"text-gray-400"}`,children:[S&&jsx("span",{className:"w-3 h-3",children:jsx(q,{})}),r.isMiss&&jsx("span",{className:"w-3 h-3",children:jsx(re,{})})]}),jsx("span",{className:"text-xs text-white/80 opacity-0 group-hover:opacity-100 transition-opacity",children:"Click to expand"})]})]}),(s||c)&&jsx(ft,{citation:e,verification:t,status:r})]})}if(a||u){let p=e.fullPhrase||e.keySpan?.toString();return jsxs("div",{className:"p-3 flex flex-col gap-2 min-w-[200px] max-w-[400px]",children:[jsxs("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:[jsx("span",{className:"inline-block relative top-[0.1em] mr-1.5 size-2 animate-spin",children:jsx(ie,{})}),"Searching..."]}),p&&jsxs("p",{className:"p-2 bg-gray-100 dark:bg-gray-800 rounded font-mono text-[11px] break-words text-gray-600 dark:text-gray-400 italic",children:['"',p.length>80?p.slice(0,80)+"\u2026":p,'"']}),e.pageNumber&&e.pageNumber>0&&jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Looking on page ",e.pageNumber]})]})}if(s)return jsxs("div",{className:"p-3 flex flex-col gap-2 min-w-[200px] max-w-[400px]",children:[jsxs("span",{className:"text-xs font-medium text-red-600 dark:text-red-500",children:[jsx("span",{className:"inline-block relative top-[0.1em] mr-1.5 size-3 text-amber-500 dark:text-amber-400",children:jsx(re,{})}),"Not found: ",e.keySpan||e.fullPhrase]}),jsx(hr,{citation:e,verification:t,isExpanded:o,onExpandChange:i})]});let l=dr(r),g=t?.verifiedMatchSnippet,x=t?.verifiedPageNumber;return !g&&!l?null:jsxs("div",{className:"p-3 flex flex-col gap-2 min-w-[180px] max-w-full",children:[l&&jsx("span",{className:b("text-xs font-medium",r.isVerified&&!r.isPartialMatch&&"text-green-600 dark:text-green-500",r.isPartialMatch&&"text-amber-600 dark:text-amber-500",r.isMiss&&"text-red-600 dark:text-red-500",r.isPending&&"text-gray-500 dark:text-gray-400"),children:l}),g&&jsxs("span",{className:"text-sm text-gray-700 dark:text-gray-300 italic",children:['"',t.verifiedMatchSnippet,'"']}),x&&x>0&&jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Page ",x]}),(s||c)&&jsx(ft,{citation:e,verification:t,status:r})]})}function ft({citation:e,verification:t,status:r}){let{isMiss:n,isPartialMatch:a}=r,o=e.fullPhrase||e.keySpan?.toString()||"",i=t?.verifiedMatchSnippet||"",{diffResult:d,hasDiff:s,isHighVariance:c}=mt(o,i);if(!n&&!a)return null;let u=e.lineIds,l=t?.verifiedLineIds,g=u&&l&&JSON.stringify(u)!==JSON.stringify(l),x=e.pageNumber,p=t?.verifiedPageNumber,S=x!=null&&p!=null&&x!==p;return n?jsxs("div",{className:"mt-2 pt-2 border-t border-gray-200 dark:border-gray-700 text-xs space-y-2",children:[o&&jsxs("div",{children:[jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Expected"}),jsx("p",{className:"mt-1 p-2 bg-gray-100 dark:bg-gray-800 rounded font-mono text-[11px] break-words text-red-600 dark:text-red-400 line-through opacity-70",children:o.length>100?o.slice(0,100)+"\u2026":o})]}),jsxs("div",{children:[jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Found"}),jsxs("p",{className:"mt-1 p-2 bg-gray-100 dark:bg-gray-800 rounded font-mono text-[11px] text-amber-600 dark:text-amber-500 italic",children:['Not found: "',e.keySpan||e.fullPhrase,'"']})]})]}):jsxs("div",{className:"mt-2 pt-2 border-t border-gray-200 dark:border-gray-700 text-xs space-y-2",children:[o&&i&&s?jsxs("div",{children:[jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Diff"}),jsx("div",{className:"mt-1 p-2 bg-gray-100 dark:bg-gray-800 rounded font-mono text-[11px] break-words text-gray-700 dark:text-gray-300",children:c?jsxs("div",{className:"space-y-2",children:[jsxs("div",{children:[jsxs("span",{className:"text-gray-500 dark:text-gray-400 text-[10px]",children:["Expected:"," "]}),jsx("span",{className:"text-red-600 dark:text-red-400 line-through opacity-70",children:o.length>100?o.slice(0,100)+"\u2026":o})]}),jsxs("div",{children:[jsxs("span",{className:"text-gray-500 dark:text-gray-400 text-[10px]",children:["Found:"," "]}),jsx("span",{className:"text-green-600 dark:text-green-400",children:i.length>100?i.slice(0,100)+"\u2026":i})]})]}):d.map((E,h)=>jsx("span",{children:E.parts.map((P,w)=>{let L=`p-${h}-${w}`;return P.removed?jsx("span",{className:"bg-red-200 dark:bg-red-900/50 text-red-700 dark:text-red-300 line-through",title:"Expected text",children:P.value},L):P.added?jsx("span",{className:"bg-green-200 dark:bg-green-900/50 text-green-700 dark:text-green-300",title:"Actual text found",children:P.value},L):jsx("span",{children:P.value},L)})},`block-${h}`))})]}):o&&!s?jsxs("div",{children:[jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Text"}),jsx("p",{className:"mt-1 p-2 bg-gray-100 dark:bg-gray-800 rounded font-mono text-[11px] break-words text-gray-700 dark:text-gray-300",children:o.length>100?o.slice(0,100)+"\u2026":o})]}):null,S&&jsxs("div",{children:[jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Page"}),jsxs("p",{className:"mt-1 font-mono text-[11px] text-gray-700 dark:text-gray-300",children:[jsx("span",{className:"text-red-600 dark:text-red-400 line-through opacity-70",children:x})," \u2192 ",p]})]}),g&&jsxs("div",{children:[jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Line"}),jsxs("p",{className:"mt-1 font-mono text-[11px] text-gray-700 dark:text-gray-300",children:[jsx("span",{className:"text-red-600 dark:text-red-400 line-through opacity-70",children:u?.join(", ")})," \u2192 ",l?.join(", ")]})]})]})}var _e=forwardRef(({citation:e,children:t,className:r,fallbackDisplay:n,verification:a,isLoading:o=false,variant:i="brackets",content:d$1,eventHandlers:s,behaviorConfig:c,isMobile:u=false,renderIndicator:l,renderContent:g,popoverPosition:x="top",renderPopoverContent:p,additionalCount:S,faviconUrl:E},h)=>{let{isAnyOverlayOpen:P}=ve(),w=useMemo(()=>d$1||sr(i),[d$1,i]),[L,_]=useState(false),[j,T]=useState(null),[A,U]=useState(false),v=useMemo(()=>d(e),[e]),ce=useMemo(()=>f(v),[v]),b$1=useMemo(()=>ur(a),[a]),{isMiss:C,isPartialMatch:D,isVerified:z,isPending:Y}=b$1,de=5e3,[ue,Q]=useState(false),M=useRef(null),Ce=a?.verificationImageBase64||a?.status==="found"||a?.status==="found_key_span_only"||a?.status==="found_phrase_missed_value"||a?.status==="not_found"||a?.status==="partial_text_found"||a?.status==="found_on_other_page"||a?.status==="found_on_other_line"||a?.status==="first_word_found",V=(o||Y)&&!Ce&&!ue;useEffect(()=>(M.current&&(clearTimeout(M.current),M.current=null),(o||Y)&&!Ce?(Q(false),M.current=setTimeout(()=>{Q(true);},de)):Q(false),()=>{M.current&&clearTimeout(M.current);}),[o,Y,Ce]);let F=useMemo(()=>cr(e,w,n),[e,w,n]),Z=useCallback(()=>({citation:e,citationKey:v,verification:a??null,isTooltipExpanded:L,isImageExpanded:!!j,hasImage:!!a?.verificationImageBase64}),[e,v,a,L,j]),$e=useCallback(N=>{N.setImageExpanded!==void 0&&(typeof N.setImageExpanded=="string"?T(N.setImageExpanded):N.setImageExpanded===true&&a?.verificationImageBase64?T(a.verificationImageBase64):N.setImageExpanded===false&&T(null));},[a?.verificationImageBase64]),kt=useCallback(N=>{N.preventDefault(),N.stopPropagation();let te=Z();if(c?.onClick){let me=c.onClick(te,N);me&&typeof me=="object"&&$e(me),s?.onClick?.(e,v,N);return}if(s?.onClick){s.onClick(e,v,N);return}a?.verificationImageBase64?T(a.verificationImageBase64):C&&U(me=>!me);},[c,s,e,v,a?.verificationImageBase64,C,Z,$e]),Fe=150,ee=useRef(null),we=useRef(false),J=useCallback(()=>{ee.current&&(clearTimeout(ee.current),ee.current=null);},[]),Ct=useCallback(()=>{P||(J(),_(true),c?.onHover?.onEnter&&c.onHover.onEnter(Z()),s?.onMouseEnter?.(e,v));},[s,c,e,v,Z,J,P]),wt=useCallback(()=>{J(),ee.current=setTimeout(()=>{we.current||(_(false),c?.onHover?.onLeave&&c.onHover.onLeave(Z()),s?.onMouseLeave?.(e,v));},Fe);},[s,c,e,v,Z,J]),Nt=useCallback(()=>{J(),we.current=true;},[J]),Pt=useCallback(()=>{we.current=false,J(),ee.current=setTimeout(()=>{_(false),c?.onHover?.onLeave&&c.onHover.onLeave(Z()),s?.onMouseLeave?.(e,v);},Fe);},[s,c,e,v,Z,J]);useEffect(()=>()=>{ee.current&&clearTimeout(ee.current);},[]);let St=useCallback(N=>{u&&(N.preventDefault(),N.stopPropagation(),s?.onTouchEnd?.(e,v,N));},[s,e,v,u]);if(n!=null&&w==="keySpan"&&C)return jsx("span",{className:b("text-gray-400 dark:text-gray-500",r),children:n});let Ne=b((z||D)&&i==="brackets"&&"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:underline",C&&"opacity-70 line-through text-gray-400 dark:text-gray-500",V&&"text-gray-500 dark:text-gray-400"),ae=()=>l?l(b$1):V?jsx(fr,{}):z&&!D?jsx(pr,{}):D?jsx(gr,{}):C?jsx(xr,{}):null,Ke=()=>{if(g)return g({citation:e,status:b$1,citationKey:v,displayText:F,isMergedDisplay:w==="keySpan"});if(w==="indicator")return jsx("span",{children:ae()});if(i==="chip"){let N=b(z&&!D&&!V&&"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",D&&!V&&"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400",C&&!V&&"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400 line-through",V&&"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400",!z&&!C&&!V&&"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400");return jsxs("span",{className:b("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-sm font-medium",N),children:[jsx("span",{className:"max-w-60 overflow-hidden text-ellipsis whitespace-nowrap",children:F}),ae()]})}if(i==="superscript"){let N=b(z&&!D&&!V&&"text-green-600 dark:text-green-500",D&&!V&&"text-amber-600 dark:text-amber-500",C&&!V&&"text-red-500 dark:text-red-400 line-through",V&&"text-gray-400 dark:text-gray-500",!z&&!C&&!V&&"text-blue-600 dark:text-blue-400");return jsxs("sup",{className:b("text-xs font-medium transition-colors hover:underline",N),children:["[",F,ae(),"]"]})}if(i==="text")return jsxs("span",{className:Ne,children:[F,ae()]});if(i==="minimal")return jsxs("span",{className:b("max-w-80 overflow-hidden text-ellipsis",Ne),children:[F,ae()]});if(i==="source"){let N=E||e.faviconUrl;return jsxs("span",{className:b("inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-sm font-medium","bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300","hover:bg-gray-200 dark:hover:bg-gray-700","transition-colors cursor-pointer"),children:[N&&jsx("img",{src:N,alt:"",className:"w-4 h-4 rounded-sm object-contain",loading:"lazy",onError:te=>{te.target.style.display="none";}}),jsx("span",{className:"max-w-40 overflow-hidden text-ellipsis whitespace-nowrap",children:F}),S!==void 0&&S>0&&jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["+",S]})]})}return jsxs("span",{className:b("inline-flex items-baseline gap-0.5 whitespace-nowrap","font-mono text-xs leading-tight","text-gray-500 dark:text-gray-400","transition-colors"),"aria-hidden":"true",children:["[",jsxs("span",{className:b("max-w-80 overflow-hidden text-ellipsis",Ne),children:[F,ae()]}),"]"]})},Lt=!(x==="hidden")&&(a&&(a.verificationImageBase64||a.verifiedMatchSnippet)||V||Y||o||C),Mt=!!a?.verificationImageBase64,Ge=j?jsx(mr,{src:j,alt:"Citation verification - full size",onClose:()=>T(null)}):null,Xe={"data-citation-id":v,"data-citation-instance":ce,className:b("relative inline-flex items-baseline cursor-pointer","px-0.5 -mx-0.5 rounded-sm","transition-all duration-[50ms]","hover:bg-blue-500/10 dark:hover:bg-blue-400/10",Mt&&"cursor-zoom-in",r),onMouseEnter:Ct,onMouseLeave:wt,onClick:kt,onTouchEndCapture:u?St:void 0,"aria-label":F?`[${F}]`:void 0};if(Lt){let N=p?p({citation:e,verification:a??null,status:b$1}):jsx(yr,{citation:e,verification:a??null,status:b$1,isLoading:o||V,isPhrasesExpanded:A,onPhrasesExpandChange:U,onImageClick:()=>{a?.verificationImageBase64&&T(a.verificationImageBase64);}});return jsxs(Fragment,{children:[t,jsxs(rt,{open:L,children:[jsx(at,{asChild:true,children:jsx("span",{ref:h,...Xe,children:Ke()})}),jsx(Me,{side:x==="bottom"?"bottom":"top",onPointerDownOutside:te=>te.preventDefault(),onInteractOutside:te=>te.preventDefault(),onMouseEnter:Nt,onMouseLeave:Pt,children:N})]}),Ge]})}return jsxs(Fragment,{children:[t,jsx("span",{ref:h,...Xe,children:Ke()}),Ge]})});_e.displayName="CitationComponent";var vr=memo(_e);function yt(e,t){return t||`https://www.google.com/s2/favicons?domain=${K(e)}&sz=32`}function Oe(e){if(!e.startsWith("http://")&&!e.startsWith("https://"))return "unknown";try{let t=K(e).toLowerCase();return t.includes("twitter.com")||t==="x.com"||t.endsWith(".x.com")||t.includes("facebook.com")||t.includes("instagram.com")||t.includes("linkedin.com")||t.includes("threads.net")||t.includes("mastodon")?"social":t.includes("youtube.com")||t.includes("youtu.be")||t.includes("twitch.tv")||t.includes("vimeo.com")||t.includes("tiktok.com")?"video":t.includes("github.com")||t.includes("gitlab.com")||t.includes("bitbucket.org")||t.includes("stackoverflow.com")?"code":t.includes("arxiv.org")||t.includes("scholar.google")||t.includes("pubmed")||t.includes("doi.org")||t.includes("researchgate.net")||t.includes("academia.edu")?"academic":t.includes("news.")||t.includes("reuters.com")||t.includes("bbc.com")||t.includes("cnn.com")||t.includes("nytimes.com")||t.includes("wsj.com")||t.includes("theguardian.com")||t.includes("washingtonpost.com")?"news":t.includes("wikipedia.org")||t.includes("britannica.com")||t.includes("merriam-webster.com")||t.includes("dictionary.com")?"reference":t.includes("reddit.com")||t.includes("quora.com")||t.includes("discourse")||t.includes("forum")?"forum":t.includes("amazon.")||t.includes("ebay.")||t.includes("shopify")||t.includes("etsy.com")?"commerce":e.toLowerCase().endsWith(".pdf")?"pdf":"web"}catch{return "unknown"}}function Ve(e,t){let r=(t||K(e)).toLowerCase(),n={"twitter.com":"X","x.com":"X","facebook.com":"Facebook","instagram.com":"Instagram","linkedin.com":"LinkedIn","youtube.com":"YouTube","youtu.be":"YouTube","twitch.tv":"Twitch","github.com":"GitHub","gitlab.com":"GitLab","stackoverflow.com":"Stack Overflow","reddit.com":"Reddit","wikipedia.org":"Wikipedia","arxiv.org":"arXiv","medium.com":"Medium","substack.com":"Substack","notion.so":"Notion","docs.google.com":"Google Docs","drive.google.com":"Google Drive","figma.com":"Figma","streamscharts.com":"Streams Charts","dexerto.com":"Dexerto"};if(n[r])return n[r];for(let[a,o]of Object.entries(n))if(r===a||r.endsWith("."+a))return o;return r.charAt(0).toUpperCase()+r.slice(1)}var Cr=()=>jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),wr=()=>jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:jsx("polyline",{points:"9 18 15 12 9 6"})}),Nr=()=>jsxs("svg",{className:"animate-spin",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),ye=forwardRef(({id:e,url:t,title:r,domain:n,sourceType:a,faviconUrl:o,citationNumbers:i,verificationStatus:d,onClick:s,className:c,showVerificationIndicator:u=false,showCitationBadges:l=false,renderFavicon:g},x)=>{let p=useCallback(w=>{s?s({id:e,url:t,title:r,domain:n,sourceType:a,faviconUrl:o,citationNumbers:i,verificationStatus:d},w):window.open(t,"_blank","noopener,noreferrer");},[s,e,t,r,n,a,o,i,d]),S=useMemo(()=>Ve(t,n),[t,n]),E=useMemo(()=>yt(t,o),[t,o]),h=useMemo(()=>a||Oe(t),[a,t]),P=()=>{if(!u||!d)return null;let L={verified:{icon:"\u2713",className:"text-green-600 dark:text-green-500"},partial:{icon:"~",className:"text-amber-600 dark:text-amber-500"},pending:{icon:"\u2026",className:"text-gray-400 dark:text-gray-500"},failed:{icon:"\u2717",className:"text-red-500 dark:text-red-400"},unknown:{icon:"?",className:"text-gray-400 dark:text-gray-500"}}[d];return jsx("span",{className:j("text-sm ml-1",L.className),"aria-label":d,children:L.icon})};return jsxs("div",{ref:x,"data-source-id":e,"data-source-type":h,className:j("flex items-start gap-3 p-3 cursor-pointer transition-colors","hover:bg-gray-50 dark:hover:bg-gray-800/50","border-b border-gray-100 dark:border-gray-800 last:border-b-0",c),onClick:p,role:"link",tabIndex:0,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),p(w));},"aria-label":`${r} from ${S}`,children:[jsx("div",{className:"flex-shrink-0 mt-0.5",children:g?g({id:e,url:t,title:r,domain:n,sourceType:a,faviconUrl:o,citationNumbers:i,verificationStatus:d}):jsx("img",{src:E,alt:"",className:"w-5 h-5 rounded",width:20,height:20,loading:"lazy",onError:w=>{w.target.style.display="none";}})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-1",children:[jsx("span",{className:"text-gray-900 dark:text-gray-100 font-medium text-sm leading-tight line-clamp-2",children:r}),P()]}),jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[jsx("span",{className:"text-gray-500 dark:text-gray-400 text-xs",children:S}),l&&i&&i.length>0&&jsxs("div",{className:"flex items-center gap-1",children:[i.slice(0,3).map(w=>jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-[10px] font-medium bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-300 rounded",children:w},w)),i.length>3&&jsxs("span",{className:"text-xs text-gray-400",children:["+",i.length-3]})]})]})]}),jsx("div",{className:"flex-shrink-0 text-gray-400 dark:text-gray-500 mt-1",children:jsx(wr,{})})]})});ye.displayName="SourcesListItem";var je=forwardRef(({sources:e,maxIcons:t=3,onClick:r,label:n="Sources",className:a,isOpen:o},i)=>{let d=useMemo(()=>e.slice(0,t),[e,t]),s=e.length>t;return jsxs("button",{ref:i,type:"button",onClick:r,className:j("inline-flex items-center gap-2 px-3 py-1.5 rounded-full text-sm","bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300","hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors","focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2",a),"aria-expanded":o,"aria-haspopup":"dialog",children:[jsx("span",{className:"font-medium",children:n}),jsxs("div",{className:"flex items-center -space-x-1",children:[d.map((c,u)=>jsx("img",{src:yt(c.url,c.faviconUrl),alt:"",className:j("w-4 h-4 rounded-full ring-2 ring-gray-100 dark:ring-gray-800",u>0&&"-ml-1"),width:16,height:16,loading:"lazy",onError:l=>{l.target.style.opacity="0";}},c.id)),s&&jsxs("span",{className:"w-4 h-4 rounded-full bg-gray-300 dark:bg-gray-600 ring-2 ring-gray-100 dark:ring-gray-800 flex items-center justify-center text-[9px] font-medium text-gray-600 dark:text-gray-300",children:["+",e.length-t]})]})]})});je.displayName="SourcesTrigger";var ze=forwardRef(({sources:e,variant:t="drawer",isOpen:r=true,onOpenChange:n,header:a={},isLoading:o=false,emptyMessage:i="No sources available",maxHeight:d,className:s,listClassName:c,onSourceClick:u,showVerificationIndicators:l=false,showCitationBadges:g=false,groupByDomain:x=false,renderItem:p,renderEmpty:S,renderLoading:E},h)=>{let P=useRef(null),[w,L]=useState(false);useEffect(()=>{if(!r||t==="inline")return;let b=C=>{C.key==="Escape"&&n?.(false);};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[r,n,t]),useEffect(()=>{L(true);},[]);let _=useMemo(()=>{if(!x)return null;let b={};for(let C of e){let D=C.domain||K(C.url);b[D]||(b[D]=[]),b[D].push(C);}return b},[e,x]),j$1=useCallback(()=>{n?.(false);},[n]),T=useCallback(b=>{b.target===b.currentTarget&&j$1();},[j$1]),A=()=>{let{title:b="Sources",showCloseButton:C=true,showCount:D=true,renderHeader:z}=a;return z?z({title:b,count:e.length,onClose:j$1}):jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:[C&&t!=="inline"&&jsx("button",{type:"button",onClick:j$1,className:"p-1 -ml-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 transition-colors","aria-label":"Close sources",children:jsx(Cr,{})}),jsxs("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100 flex-1 text-center",children:[b,D&&jsxs("span",{className:"ml-2 text-sm font-normal text-gray-500 dark:text-gray-400",children:["(",e.length,")"]})]}),C&&t!=="inline"&&jsx("div",{className:"w-8"})]})},U=()=>o?E?E():jsxs("div",{className:"flex items-center justify-center py-8 text-gray-500 dark:text-gray-400",children:[jsx(Nr,{}),jsx("span",{className:"ml-2 text-sm",children:"Loading sources..."})]}):e.length===0?S?S():jsx("div",{className:"flex items-center justify-center py-8 text-gray-500 dark:text-gray-400 text-sm",children:i}):x&&_?jsx("div",{className:c,children:Object.entries(_).map(([b,C])=>jsxs("div",{children:[jsx("div",{className:"px-4 py-2 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider bg-gray-50 dark:bg-gray-800/50",children:Ve(C[0].url,b)}),C.map((D,z)=>p?p(D,z):jsx(ye,{...D,onClick:u,showVerificationIndicator:l,showCitationBadges:g},D.id))]},b))}):jsx("div",{className:c,children:e.map((b,C)=>p?p(b,C):jsx(ye,{...b,onClick:u,showVerificationIndicator:l,showCitationBadges:g},b.id))}),v=d?{maxHeight:typeof d=="number"?`${d}px`:d}:void 0;if(t==="inline")return r?jsxs("div",{ref:h,className:j("bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700",s),style:v,children:[A(),jsx("div",{className:"overflow-y-auto",style:v,children:U()})]}):null;if(t==="panel")return r?jsxs("div",{ref:h,className:j("bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700 shadow-lg",s),children:[A(),jsx("div",{className:"overflow-y-auto",style:v||{maxHeight:"400px"},children:U()})]}):null;if(!w||!r)return null;let ce=jsxs("div",{ref:h,className:j("fixed inset-0 z-50",t==="modal"&&"flex items-center justify-center"),role:"dialog","aria-modal":"true","aria-labelledby":"sources-title",children:[jsx("div",{className:j("absolute inset-0 bg-black/40 dark:bg-black/60 transition-opacity",r?"opacity-100":"opacity-0"),onClick:T,"aria-hidden":"true"}),t==="drawer"?jsxs("div",{ref:P,className:j("absolute bottom-0 left-0 right-0 bg-white dark:bg-gray-900 rounded-t-2xl shadow-2xl","transform transition-transform duration-300 ease-out",r?"translate-y-0":"translate-y-full","max-h-[80vh] flex flex-col",s),children:[jsx("div",{className:"flex justify-center py-2",children:jsx("div",{className:"w-10 h-1 bg-gray-300 dark:bg-gray-600 rounded-full"})}),A(),jsx("div",{className:"overflow-y-auto flex-1",children:U()})]}):jsxs("div",{ref:P,className:j("relative bg-white dark:bg-gray-900 rounded-xl shadow-2xl","transform transition-all duration-200",r?"opacity-100 scale-100":"opacity-0 scale-95","w-full max-w-md max-h-[80vh] flex flex-col mx-4",s),children:[A(),jsx("div",{className:"overflow-y-auto flex-1",children:U()})]})]});return createPortal(ce,document.body)});ze.displayName="SourcesListComponent";var Pr=memo(ye),Sr=memo(je),Lr=memo(ze);function Mr(e){let t=new Map;for(let r of e){if(!r.url)continue;let n=r.domain||K(r.url),a=r.url;if(t.has(a)){let o=t.get(a);r.citationNumber&&!o.citationNumbers?.includes(r.citationNumber)&&(o.citationNumbers=[...o.citationNumbers||[],r.citationNumber]);}else t.set(a,{id:a,url:r.url,title:r.title||n,domain:n,sourceType:r.sourceType||Oe(r.url),faviconUrl:r.faviconUrl,citationNumbers:r.citationNumber?[r.citationNumber]:[]});}return Array.from(t.values())}function Ir(e=[]){let[t,r]=useState(e),[n,a]=useState(false),o=useCallback(s=>{r(c=>c.some(l=>l.url===s.url)?c:[...c,s]);},[]),i=useCallback(s=>{r(c=>c.filter(u=>u.id!==s));},[]),d=useCallback(()=>{r([]);},[]);return {sources:t,setSources:r,addSource:o,removeSource:i,clearSources:d,isOpen:n,setIsOpen:a,open:()=>a(true),close:()=>a(false),toggle:()=>a(s=>!s)}}function bt(e){let t=new Map;for(let r of e){let n=r.citation.domain||r.citation.siteName||r.citation.url||"unknown";t.has(n)||t.set(n,[]),t.get(n).push(r);}return Array.from(t.entries()).map(([r,n])=>{let a=n[0].citation;return {sourceName:a.siteName||a.domain||Ae(a.url)||"Unknown Source",sourceDomain:a.domain||Ae(a.url),sourceFavicon:a.faviconUrl||void 0,citations:n,additionalCount:n.length-1}})}function Ae(e){if(e)try{return new URL(e).hostname.replace(/^www\./,"")}catch{return}}function Dr(e){let t=e?.status;return !t||t==="pending"||t==="loading"?{color:"text-gray-400",icon:jsx(ie,{}),label:"Verifying"}:t==="not_found"?{color:"text-amber-500",icon:jsx(re,{}),label:"Not found"}:t==="partial_text_found"||t==="found_on_other_page"||t==="found_on_other_line"||t==="first_word_found"?{color:"text-amber-500",icon:jsx(q,{}),label:"Partial match"}:{color:"text-green-500",icon:jsx(q,{}),label:"Verified"}}function He({item:e,isLast:t=false,onClick:r,onReadMore:n,className:a}){let{citation:o,verification:i}=e,d=Dr(i),s=o.siteName||o.domain||Ae(o.url)||"Source",c=o.title||o.keySpan||o.fullPhrase,u=o.description||i?.actualContentSnippet||i?.verifiedMatchSnippet,l=o.faviconUrl,g=useCallback(()=>{r?.(e);},[e,r]),x=useCallback(p=>{p.stopPropagation(),n?.(e);},[e,n]);return jsx("div",{className:b("px-4 py-3 hover:bg-gray-50 dark:hover:bg-gray-800/50 cursor-pointer transition-colors",!t&&"border-b border-gray-200 dark:border-gray-700",a),onClick:g,role:"button",tabIndex:0,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),g());},children:jsxs("div",{className:"flex items-start gap-3",children:[jsx("div",{className:"flex-shrink-0 mt-0.5",children:l?jsx("img",{src:l,alt:"",className:"w-5 h-5 rounded object-contain",loading:"lazy",onError:p=>{p.target.style.display="none";}}):jsx("div",{className:"w-5 h-5 rounded bg-gray-200 dark:bg-gray-700 flex items-center justify-center",children:jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.charAt(0).toUpperCase()})})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:s}),jsx("span",{className:b("inline-flex w-3 h-3",d.color,i?.status==="pending"||i?.status==="loading"?"animate-spin":""),title:d.label,children:d.icon})]}),c&&jsx("h4",{className:"mt-1 text-sm font-medium text-gray-900 dark:text-gray-100 line-clamp-2",children:c}),u&&jsxs("p",{className:"mt-1 text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:[u,n&&u.length>100&&jsx("button",{onClick:x,className:"ml-1 text-blue-500 hover:text-blue-600 dark:text-blue-400 dark:hover:text-blue-300",children:"Read more"})]})]})]})})}function _r({isOpen:e,onClose:t,citationGroups:r,title:n="Citations",showMoreSection:a=true,maxVisibleItems:o=3,onCitationClick:i,onReadMore:d,className:s,position:c="bottom",renderCitationItem:u}){let[l,g]=useState(false),x=useMemo(()=>r.flatMap(h=>h.citations),[r]),p=useMemo(()=>!a||l?x:x.slice(0,o),[x,a,l,o]),S=useMemo(()=>!a||l?[]:x.slice(o),[x,a,l,o]);if(We__default.useEffect(()=>{if(!e)return;let h=P=>{P.key==="Escape"&&t();};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[e,t]),!e)return null;let E=jsxs(Fragment,{children:[jsx("div",{className:"fixed inset-0 bg-black/40 z-[9998] animate-in fade-in-0 duration-150",onClick:t,"aria-hidden":"true"}),jsxs("div",{className:b("fixed z-[9999] bg-white dark:bg-gray-900 shadow-xl","animate-in duration-200",c==="bottom"&&"inset-x-0 bottom-0 max-h-[80vh] rounded-t-2xl slide-in-from-bottom-4",c==="right"&&"inset-y-0 right-0 w-full max-w-md slide-in-from-right-4",s),role:"dialog","aria-modal":"true","aria-label":n,children:[c==="bottom"&&jsx("div",{className:"flex justify-center pt-3 pb-1",children:jsx("div",{className:"w-10 h-1 rounded-full bg-gray-300 dark:bg-gray-600"})}),jsxs("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:n}),jsx("button",{onClick:t,className:"p-1.5 rounded-full hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors","aria-label":"Close",children:jsx("svg",{className:"w-5 h-5 text-gray-500 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),jsx("div",{className:"overflow-y-auto max-h-[calc(80vh-100px)]",children:p.length===0?jsx("div",{className:"px-4 py-8 text-center text-gray-500 dark:text-gray-400",children:"No citations to display"}):jsxs(Fragment,{children:[p.map((h,P)=>u?jsx(We__default.Fragment,{children:u(h)},h.citationKey):jsx(He,{item:h,isLast:P===p.length-1&&S.length===0,onClick:i,onReadMore:d},h.citationKey)),S.length>0&&!l&&jsx("div",{className:"px-4 py-3 border-t border-gray-200 dark:border-gray-700",children:jsxs("button",{onClick:()=>g(true),className:"text-sm font-medium text-blue-500 hover:text-blue-600 dark:text-blue-400 dark:hover:text-blue-300",children:["More (",S.length,")"]})}),l&&S.map((h,P)=>u?jsx(We__default.Fragment,{children:u(h)},h.citationKey):jsx(He,{item:h,isLast:P===S.length-1,onClick:i,onReadMore:d},h.citationKey))]})})]})]});return createPortal(E,document.body)}function Rr(){let[e,t]=useState(false),[r,n]=useState([]),a=useCallback(()=>t(true),[]),o=useCallback(()=>t(false),[]),i=useCallback(()=>t(g=>!g),[]),d=useCallback(g=>{n(x=>x.some(p=>p.citationKey===g.citationKey)?x:[...x,g]);},[]),s=useCallback(g=>{n(x=>x.filter(p=>p.citationKey!==g));},[]),c=useCallback(()=>{n([]);},[]),u=useCallback(g=>{n(g);},[]),l=useMemo(()=>bt(r),[r]);return {isOpen:e,openDrawer:a,closeDrawer:o,toggleDrawer:i,citations:r,citationGroups:l,addCitation:d,removeCitation:s,clearCitations:c,setCitations:u}}
5
- export{q as CheckIcon,_e as CitationComponent,_r as CitationDrawer,He as CitationDrawerItemComponent,tr as CitationOverlayProvider,Ft as CloseIcon,At as DeepCitationIcon,$t as ExternalLinkIcon,Ht as LinkIcon,vr as MemoizedCitationComponent,Lr as MemoizedSourcesListComponent,Pr as MemoizedSourcesListItem,Sr as MemoizedSourcesTrigger,ze as SourcesListComponent,ye as SourcesListItem,je as SourcesTrigger,ie as SpinnerIcon,re as WarningIcon,Oe as detectSourceType,K as extractDomain,Ve as getPlatformName,bt as groupCitationsBySource,jt as isAccessibleStatus,Je as isBlockedStatus,qe as isErrorStatus,zt as isRedirectedStatus,Wt as isVerifiedStatus,Mr as sourceCitationsToListItems,Rr as useCitationDrawer,ve as useCitationOverlay,rr as useHasCitationOverlayProvider,Ir as useSourcesList};
5
+ export{q as CheckIcon,_e as CitationComponent,_r as CitationDrawer,He as CitationDrawerItemComponent,tr as CitationOverlayProvider,Ft as CloseIcon,At as DeepCitationIcon,$t as ExternalLinkIcon,Ht as LinkIcon,vr as MemoizedCitationComponent,Lr as MemoizedSourcesListComponent,Pr as MemoizedSourcesListItem,Sr as MemoizedSourcesTrigger,ze as SourcesListComponent,ye as SourcesListItem,je as SourcesTrigger,ie as SpinnerIcon,re as WarningIcon,Oe as detectSourceType,K as extractDomain,Ve as getPlatformName,bt as groupCitationsBySource,jt as isAccessibleStatus,Je as isBlockedStatus,qe as isErrorStatus,zt as isRedirectedStatus,Wt as isVerifiedStatus,Mr as sourceCitationsToListItems,Rr as useCitationDrawer,ve as useCitationOverlay,rr as useHasCitationOverlayProvider,Ir as useSourcesList};//# sourceMappingURL=index.js.map
6
+ //# sourceMappingURL=index.js.map