@deepcitation/deepcitation-js 1.1.39 → 1.1.41
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.
- package/lib/{chunk-HAYHSRVD.cjs → chunk-4G7LE6P4.cjs} +9 -9
- package/lib/{chunk-YZ6QJQP5.js → chunk-KSQJNKLA.js} +9 -9
- package/lib/chunk-OT5T6R53.js +1 -0
- package/lib/chunk-QDDCYCBV.cjs +1 -0
- package/lib/{chunk-TBG42N5V.cjs → chunk-W5BUHPRT.cjs} +1 -1
- package/lib/{chunk-L3IBEKR4.js → chunk-WIWLCVJK.js} +1 -1
- package/lib/client/index.cjs +1 -1
- package/lib/client/index.js +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.cts +9 -1
- package/lib/index.d.ts +9 -1
- package/lib/index.js +1 -1
- package/lib/prompts/index.cjs +1 -1
- package/lib/prompts/index.d.cts +12 -6
- package/lib/prompts/index.d.ts +12 -6
- package/lib/prompts/index.js +1 -1
- package/lib/react/index.cjs +5 -5
- package/lib/react/index.d.cts +179 -3
- package/lib/react/index.d.ts +179 -3
- package/lib/react/index.js +5 -5
- package/lib/styles.css +2 -0
- package/package.json +13 -7
- package/src/tailwind.css +5 -0
- package/lib/chunk-6VPT3IIK.cjs +0 -1
- package/lib/chunk-UC6YB63U.js +0 -1
package/lib/react/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use strict';var chunk6VPT3IIK_cjs=require('../chunk-6VPT3IIK.cjs');require('../chunk-F2MMVEVC.cjs');var He=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),$=require('@radix-ui/react-popover');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var He__namespace=/*#__PURE__*/_interopNamespace(He);var $__namespace=/*#__PURE__*/_interopNamespace($);function O(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e.replace(/^https?:\/\/(www\.)?/,"").split("/")[0]}}function Ve(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}function bt(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 We(e){return e.startsWith("blocked_")}function je(e){return e.startsWith("error_")}function kt(e){return e==="verified"||e==="partial"||e==="accessible"||e==="redirected_valid"}function Ct(e){return e==="redirected"||e==="redirected_valid"}function Nt(e){return e==="verified"||e==="partial"||e==="redirected_valid"}var wt=({status:e,errorMessage:t})=>{let r=ze[e];return jsxRuntime.jsx("span",{className:chunk6VPT3IIK_cjs.p("inline-flex items-center gap-1",r.className),title:t||r.label,"aria-label":r.label,children:jsxRuntime.jsx("span",{className:"text-[0.9em]","aria-hidden":"true",children:r.icon})})},he=({url:e,faviconUrl:t})=>{let r=O(e),a=t||`https://www.google.com/s2/favicons?domain=${r}&sz=16`;return jsxRuntime.jsx("img",{src:a,alt:"",className:"w-3.5 h-3.5 rounded-sm",width:14,height:14,loading:"lazy",onError:n=>{n.target.style.display="none";}})},Ae=He.forwardRef(({urlMeta:e,citation:t,children:r,className:a,variant:n="chip",showFullUrlOnHover:o=true,showFavicon:s=true,showTitle:d=false,maxDisplayLength:i=30,renderBlockedIndicator:l,onUrlClick:u,eventHandlers:c,preventTooltips:x=false},v)=>{let{url:p,domain:B,title:M,fetchStatus:b,faviconUrl:I,errorMessage:k}=e,C=He.useMemo(()=>t||{value:p,fullPhrase:M||p},[t,p,M]),D=He.useMemo(()=>chunk6VPT3IIK_cjs.j(C),[C]),j=He.useMemo(()=>chunk6VPT3IIK_cjs.l(D),[D]),y=He.useMemo(()=>B||O(p),[B,p]),U=He.useMemo(()=>bt(p),[p]),T=He.useMemo(()=>{if(d&&M)return Ve(M,i);let N=U?Ve(U,i-y.length-1):"";return N?`${y}${N}`:y},[d,M,y,U,i]),w=ze[b],A=We(b),h=je(b),L=b==="verified",V=b==="partial",K=b==="pending",Y=He.useCallback(N=>{N.preventDefault(),N.stopPropagation(),u?u(p,N):window.open(p,"_blank","noopener,noreferrer"),c?.onClick?.(C,D,N);},[u,p,c,C,D]),H=He.useCallback(()=>{c?.onMouseEnter?.(C,D);},[c,C,D]),Z=He.useCallback(()=>{c?.onMouseLeave?.(C,D);},[c,C,D]),E=()=>A||h?l?l(b,k):jsxRuntime.jsx(wt,{status:b,errorMessage:k}):L?jsxRuntime.jsx("span",{className:"text-[0.85em] text-green-600 dark:text-green-500","aria-hidden":"true",title:"Verified",children:"\u2713"}):V?jsxRuntime.jsx("span",{className:"text-[0.85em] text-amber-600 dark:text-amber-500","aria-hidden":"true",title:"Partial match",children:"~"}):K?jsxRuntime.jsx("span",{className:"opacity-70","aria-hidden":"true",children:"\u2026"}):null;return n==="chip"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r,jsxRuntime.jsxs("span",{ref:v,"data-citation-id":D,"data-citation-instance":j,"data-url":p,"data-fetch-status":b,"data-variant":"chip",className:chunk6VPT3IIK_cjs.p("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",w.className,a),title:o?p:void 0,onMouseEnter:x?void 0:H,onMouseLeave:x?void 0:Z,onMouseDown:Y,onClick:N=>N.stopPropagation(),role:"link","aria-label":`Link to ${y}: ${w.label}`,children:[s&&jsxRuntime.jsx(he,{url:p,faviconUrl:I}),jsxRuntime.jsx("span",{className:"max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap",children:T}),E()]})]}):n==="inline"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r,jsxRuntime.jsxs("a",{ref:v,href:p,"data-citation-id":D,"data-citation-instance":j,"data-fetch-status":b,"data-variant":"inline",className:chunk6VPT3IIK_cjs.p("inline-flex items-center gap-1 cursor-pointer transition-colors no-underline border-b border-dotted border-current",w.className,a),title:o?p:void 0,onMouseEnter:x?void 0:H,onMouseLeave:x?void 0:Z,onClick:N=>{N.preventDefault(),Y(N);},target:"_blank",rel:"noopener noreferrer","aria-label":`Link to ${y}: ${w.label}`,children:[s&&jsxRuntime.jsx(he,{url:p,faviconUrl:I}),jsxRuntime.jsx("span",{children:T}),E()]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r,jsxRuntime.jsxs("span",{ref:v,"data-citation-id":D,"data-citation-instance":j,"data-url":p,"data-fetch-status":b,"data-variant":"bracket",className:chunk6VPT3IIK_cjs.p("cursor-pointer transition-colors",w.className,a),title:o?p:void 0,onMouseEnter:x?void 0:H,onMouseLeave:x?void 0:Z,onMouseDown:Y,onClick:N=>N.stopPropagation(),role:"link","aria-label":`Link to ${y}: ${w.label}`,children:["[",s&&jsxRuntime.jsx(he,{url:p,faviconUrl:I}),jsxRuntime.jsx("span",{className:"max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap",children:T}),E(),"]"]})]})});Ae.displayName="UrlCitationComponent";He.memo(Ae);var Pt=({className:e})=>jsxRuntime.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:[jsxRuntime.jsx("path",{d:"M7 3 L3 3 L3 21 L7 21"}),jsxRuntime.jsx("path",{d:"M17 3 L21 3 L21 21 L17 21"})]}),ue=({className:e})=>jsxRuntime.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:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})}),me=({className:e})=>jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 256 256",fill:"currentColor","aria-hidden":"true",style:{width:"100%",height:"100%"},children:jsxRuntime.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"})}),pe=({className:e})=>jsxRuntime.jsxs("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",style:{width:"100%",height:"100%"},children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",style:{opacity:.25}}),jsxRuntime.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}})]}),St=({className:e})=>jsxRuntime.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:[jsxRuntime.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"}),jsxRuntime.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"})]}),Lt=({className:e})=>jsxRuntime.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:[jsxRuntime.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),jsxRuntime.jsx("polyline",{points:"15 3 21 3 21 9"}),jsxRuntime.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),Mt=({className:e})=>jsxRuntime.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:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]});function It(...e){return e.filter(Boolean).join(" ")}var $e=$__namespace.Root,Fe=$__namespace.Trigger;var ye=He__namespace.forwardRef(({className:e,align:t="center",sideOffset:r=8,...a},n)=>jsxRuntime.jsx($__namespace.Portal,{children:jsxRuntime.jsx($__namespace.Content,{ref:n,align:t,sideOffset:r,className:It("z-[9998] rounded-lg border bg-white shadow-xl outline-none","w-fit max-w-[min(600px,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),...a})}));ye.displayName=$__namespace.Content.displayName;function Ye(e,t,r=(a,n)=>a===n){let a=e.length,n=t.length;if(a===0&&n===0)return [];if(a===0)return [{value:t.join(""),added:true,count:t.length}];if(n===0)return [{value:e.join(""),removed:true,count:e.length}];let o=0;for(;o<a&&o<n&&r(e[o],t[o]);)o++;let s=0;for(;s<a-o&&s<n-o&&r(e[a-1-s],t[n-1-s]);)s++;let d=e.slice(o,a-s),i=t.slice(o,n-s);if(d.length===0&&i.length===0)return [{value:e.join(""),count:e.length}];let l=Et(d,i,r),u=[];return o>0&&u.push({value:e.slice(0,o).join(""),count:o}),u.push(...l),s>0&&u.push({value:e.slice(a-s).join(""),count:s}),Ze(u)}function Et(e,t,r){let a=e.length,n=t.length,o=a+n,s={1:0},d=[];e:for(let i=0;i<=o;i++){d.push({...s});for(let l=-i;l<=i;l+=2){let u;l===-i||l!==i&&s[l-1]<s[l+1]?u=s[l+1]:u=s[l-1]+1;let c=u-l;for(;u<a&&c<n&&r(e[u],t[c]);)u++,c++;if(s[l]=u,u>=a&&c>=n)break e}}return _t(d,e,t)}function _t(e,t,r){let a=[],n=t.length,o=r.length;for(let s=e.length-1;s>=0;s--){let d=e[s],i=n-o,l;i===-s||i!==s&&d[i-1]<d[i+1]?l=i+1:l=i-1;let u=d[l]??0,c=u-l;for(;n>u&&o>c;)n--,o--,a.unshift({value:t[n],count:1});s>0&&(n===u?(o--,a.unshift({value:r[o],added:true,count:1})):(n--,a.unshift({value:t[n],removed:true,count:1})));}return a}function Ze(e){if(e.length===0)return [];let t=[];for(let r of e){let a=t[t.length-1];a&&a.added===r.added&&a.removed===r.removed?(a.value+=r.value,a.count=(a.count||1)+(r.count||1)):t.push({...r});}return t}function Oe(e){if(!e)return [];let t=[],r="";for(let a=0;a<e.length;a++){let n=e[a];r+=n,n===`
|
|
2
|
-
`&&(t.push(r),r="");}return r.length>0&&t.push(r),t}var
|
|
3
|
-
`),
|
|
4
|
-
`),n=Je(r,a),o=[],s=false,d=0;for(let u=0;u<n.length;u++){let c=n[u],x=n[u+1];if(c.removed&&x&&x.added){let v=qe(c.value,x.value);o.push({type:"modified",parts:v}),s=true,d+=Math.abs(c.value.length-x.value.length),u++;}else c.added||c.removed?(o.push({type:c.added?"added":"removed",parts:[{value:c.value,added:c.added,removed:c.removed}]}),s=true,d+=c.value.length):o.push({type:"unchanged",parts:[{value:c.value}]});}let i=Math.max(r.length,a.length),l=i===0?1:1-d/i;return {diffResult:o,hasDiff:s,similarity:l,isHighVariance:l<.6}},[e,t]);function Wt(e){switch(e){case "chip":case "text":case "brackets":return "keySpan";default:return "number"}}function jt(e){return e.replace(/^\[+\s*/,"").replace(/\s*\]+$/,"")}function At(e,t,r){if(t==="indicator")return "";if(t==="keySpan"){let a=e.keySpan?.toString()||e.citationNumber?.toString()||r||"1";return jt(a)}return e.citationNumber?.toString()||"1"}function Ut(e){return e.isVerified&&!e.isPartialMatch?"Verified":e.isPartialMatch?"Partial Match":e.isMiss?"Not Found":e.isPending?"Verifying...":""}function Ht(e){let t=e?.status;if(!e||!t)return {isVerified:false,isMiss:false,isPartialMatch:false,isPending:false};let r=t==="not_found",a=t==="pending"||t==="loading",n=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"||n,isMiss:r,isPartialMatch:n,isPending:a}}function $t({src:e,alt:t,onClose:r}){return He.useEffect(()=>{let a=n=>{n.key==="Escape"&&r();};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[r]),reactDom.createPortal(jsxRuntime.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:jsxRuntime.jsx("div",{className:"relative max-w-[95vw] max-h-[95vh] cursor-zoom-out animate-in zoom-in-95 duration-[50ms]",children:jsxRuntime.jsx("img",{src:e,alt:t,className:"max-w-full max-h-[95vh] object-contain rounded-lg shadow-2xl",draggable:false})})}),document.body)}var Ft=()=>jsxRuntime.jsx("span",{className:"inline-flex relative ml-0.5 size-2 text-green-600 dark:text-green-500","aria-hidden":"true",children:jsxRuntime.jsx(ue,{})}),Ot=()=>jsxRuntime.jsx("span",{className:"inline-flex relative ml-0.5 size-2 text-amber-600 dark:text-amber-500","aria-hidden":"true",children:jsxRuntime.jsx(ue,{})}),Kt=()=>jsxRuntime.jsx("span",{className:"inline-flex ml-1 size-2 animate-spin text-gray-400 dark:text-gray-500","aria-hidden":"true",children:jsxRuntime.jsx(pe,{})}),Gt=()=>jsxRuntime.jsx("span",{className:"inline-flex relative ml-0.5 size-2 text-amber-500 dark:text-amber-400","aria-hidden":"true",children:jsxRuntime.jsx(me,{})});function Xt({citation:e,verification:t,isExpanded:r,onExpandChange:a}){let n=He.useMemo(()=>{let c=new Set;if(t?.searchAttempts){for(let x of t.searchAttempts)if(x.searchPhrases)for(let v of x.searchPhrases)v&&c.add(v);}return c.size===0&&(e.fullPhrase&&c.add(e.fullPhrase),e.keySpan&&c.add(e.keySpan.toString())),Array.from(c)},[e,t]),[o,s]=He.useState(false),d=r??o,i=He.useCallback(c=>{a?a(c):s(c);},[a]);if(n.length===0)return null;let l=d?n.length:1,u=n.length-1;return jsxRuntime.jsxs("div",{className:"mt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-gray-500 dark:text-gray-400 uppercase font-medium",children:[jsxRuntime.jsxs("span",{children:["Searched ",n.length," phrase",n.length!==1?"s":""]}),u>0&&!d&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>i(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&&jsxRuntime.jsx("button",{type:"button",onClick:()=>i(false),className:"text-blue-500 hover:text-blue-600 dark:text-blue-400 dark:hover:text-blue-300 lowercase",children:"collapse"})]}),jsxRuntime.jsx("div",{className:"mt-1 space-y-1",children:n.slice(0,l).map((c,x)=>jsxRuntime.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:['"',c.length>80?c.slice(0,80)+"\u2026":c,'"']},x))})]})}function Yt({citation:e,verification:t,status:r,onImageClick:a,isLoading:n=false,isPhrasesExpanded:o,onPhrasesExpandChange:s}){let d=t?.verificationImageBase64,{isMiss:i,isPartialMatch:l,isPending:u}=r;if(d)return jsxRuntime.jsxs("div",{className:"p-2",children:[jsxRuntime.jsxs("button",{type:"button",className:"group block cursor-zoom-in relative",onClick:p=>{p.preventDefault(),p.stopPropagation(),a?.();},"aria-label":"Click to view full size",children:[jsxRuntime.jsx("img",{src:t.verificationImageBase64,alt:"Citation verification",className:"max-w-full h-auto object-contain rounded-md bg-gray-50 dark:bg-gray-800",loading:"lazy"}),jsxRuntime.jsx("span",{className:"absolute inset-0 flex items-center justify-center bg-black/0 group-hover:bg-black/5 dark:group-hover:bg-white/5 transition-colors rounded-md",children:jsxRuntime.jsx("span",{className:"opacity-0 group-hover:opacity-100 transition-opacity text-xs text-gray-600 dark:text-gray-300 bg-white/90 dark:bg-gray-800/90 px-2 py-1 rounded shadow-sm",children:"Click to expand"})})]}),(i||l)&&jsxRuntime.jsx(et,{citation:e,verification:t,status:r})]});if(n||u){let p=e.fullPhrase||e.keySpan?.toString();return jsxRuntime.jsxs("div",{className:"p-3 flex flex-col gap-2 min-w-[200px] max-w-[400px]",children:[jsxRuntime.jsxs("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:[jsxRuntime.jsx("span",{className:"inline-block relative top-[0.1em] mr-1.5 size-2 animate-spin",children:jsxRuntime.jsx(pe,{})}),"Searching..."]}),p&&jsxRuntime.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&&jsxRuntime.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Looking on page ",e.pageNumber]})]})}if(i)return jsxRuntime.jsxs("div",{className:"p-3 flex flex-col gap-2 min-w-[200px] max-w-[400px]",children:[jsxRuntime.jsxs("span",{className:"text-xs font-medium text-red-600 dark:text-red-500",children:[jsxRuntime.jsx("span",{className:"inline-block relative top-[0.1em] mr-1.5 size-3 text-amber-500 dark:text-amber-400",children:jsxRuntime.jsx(me,{})}),"Not found: ",e.keySpan||e.fullPhrase]}),jsxRuntime.jsx(Xt,{citation:e,verification:t,isExpanded:o,onExpandChange:s})]});let c=Ut(r),x=t?.verifiedMatchSnippet,v=t?.verifiedPageNumber;return !x&&!c?null:jsxRuntime.jsxs("div",{className:"p-3 flex flex-col gap-2 min-w-[180px] max-w-full",children:[c&&jsxRuntime.jsx("span",{className:chunk6VPT3IIK_cjs.h("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:c}),x&&jsxRuntime.jsxs("span",{className:"text-sm text-gray-700 dark:text-gray-300 italic",children:['"',t.verifiedMatchSnippet,'"']}),v&&v>0&&jsxRuntime.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Page ",v]}),(i||l)&&jsxRuntime.jsx(et,{citation:e,verification:t,status:r})]})}function et({citation:e,verification:t,status:r}){let{isMiss:a,isPartialMatch:n}=r,o=e.fullPhrase||e.keySpan?.toString()||"",s=t?.verifiedMatchSnippet||"",{diffResult:d,hasDiff:i,isHighVariance:l}=Qe(o,s);if(!a&&!n)return null;let u=e.lineIds,c=t?.verifiedLineIds,x=u&&c&&JSON.stringify(u)!==JSON.stringify(c),v=e.pageNumber,p=t?.verifiedPageNumber,B=v!=null&&p!=null&&v!==p;return a?jsxRuntime.jsxs("div",{className:"mt-2 pt-2 border-t border-gray-200 dark:border-gray-700 text-xs space-y-2",children:[o&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Expected"}),jsxRuntime.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})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Found"}),jsxRuntime.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,'"']})]})]}):jsxRuntime.jsxs("div",{className:"mt-2 pt-2 border-t border-gray-200 dark:border-gray-700 text-xs space-y-2",children:[o&&s&&i?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Diff"}),jsxRuntime.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:l?jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("span",{className:"text-gray-500 dark:text-gray-400 text-[10px]",children:["Expected:"," "]}),jsxRuntime.jsx("span",{className:"text-red-600 dark:text-red-400 line-through opacity-70",children:o.length>100?o.slice(0,100)+"\u2026":o})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("span",{className:"text-gray-500 dark:text-gray-400 text-[10px]",children:["Found:"," "]}),jsxRuntime.jsx("span",{className:"text-green-600 dark:text-green-400",children:s.length>100?s.slice(0,100)+"\u2026":s})]})]}):d.map((M,b)=>jsxRuntime.jsx("span",{children:M.parts.map((I,k)=>{let C=`p-${b}-${k}`;return I.removed?jsxRuntime.jsx("span",{className:"bg-red-200 dark:bg-red-900/50 text-red-700 dark:text-red-300 line-through",title:"Expected text",children:I.value},C):I.added?jsxRuntime.jsx("span",{className:"bg-green-200 dark:bg-green-900/50 text-green-700 dark:text-green-300",title:"Actual text found",children:I.value},C):jsxRuntime.jsx("span",{children:I.value},C)})},`block-${b}`))})]}):o&&!i?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Text"}),jsxRuntime.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,B&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Page"}),jsxRuntime.jsxs("p",{className:"mt-1 font-mono text-[11px] text-gray-700 dark:text-gray-300",children:[jsxRuntime.jsx("span",{className:"text-red-600 dark:text-red-400 line-through opacity-70",children:v})," \u2192 ",p]})]}),x&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Line"}),jsxRuntime.jsxs("p",{className:"mt-1 font-mono text-[11px] text-gray-700 dark:text-gray-300",children:[jsxRuntime.jsx("span",{className:"text-red-600 dark:text-red-400 line-through opacity-70",children:u?.join(", ")})," \u2192 ",c?.join(", ")]})]})]})}var Ne=He.forwardRef(({citation:e,children:t,className:r,fallbackDisplay:a,verification:n,isLoading:o=false,variant:s="brackets",content:d,eventHandlers:i,behaviorConfig:l,isMobile:u=false,renderIndicator:c,renderContent:x,popoverPosition:v="top",renderPopoverContent:p},B)=>{let M=He.useMemo(()=>d||Wt(s),[d,s]),[b,I]=He.useState(false),[k,C]=He.useState(null),[D,j]=He.useState(false),y=He.useMemo(()=>chunk6VPT3IIK_cjs.j(e),[e]),U=He.useMemo(()=>chunk6VPT3IIK_cjs.l(y),[y]),T=He.useMemo(()=>Ht(n),[n]),{isMiss:w,isPartialMatch:A,isVerified:h,isPending:L}=T,V=5e3,[K,Y]=He.useState(false),H=He.useRef(null),Z=n?.verificationImageBase64||n?.status==="found"||n?.status==="found_key_span_only"||n?.status==="found_phrase_missed_value"||n?.status==="not_found"||n?.status==="partial_text_found"||n?.status==="found_on_other_page"||n?.status==="found_on_other_line"||n?.status==="first_word_found",E=(o||L)&&!Z&&!K;He.useEffect(()=>(H.current&&(clearTimeout(H.current),H.current=null),(o||L)&&!Z?(Y(false),H.current=setTimeout(()=>{Y(true);},V)):Y(false),()=>{H.current&&clearTimeout(H.current);}),[o,L,Z]);let N=He.useMemo(()=>At(e,M,a),[e,M,a]),G=He.useCallback(()=>({citation:e,citationKey:y,verification:n??null,isTooltipExpanded:b,isImageExpanded:!!k,hasImage:!!n?.verificationImageBase64}),[e,y,n,b,k]),_e=He.useCallback(P=>{P.setImageExpanded!==void 0&&(typeof P.setImageExpanded=="string"?C(P.setImageExpanded):P.setImageExpanded===true&&n?.verificationImageBase64?C(n.verificationImageBase64):P.setImageExpanded===false&&C(null));},[n?.verificationImageBase64]),at=He.useCallback(P=>{P.preventDefault(),P.stopPropagation();let ne=G();if(l?.onClick){let ae=l.onClick(ne,P);ae&&typeof ae=="object"&&_e(ae),i?.onClick?.(e,y,P);return}if(i?.onClick){i.onClick(e,y,P);return}n?.verificationImageBase64?C(n.verificationImageBase64):w&&j(ae=>!ae);},[l,i,e,y,n?.verificationImageBase64,w,G,_e]),De=150,J=He.useRef(null),ge=He.useRef(false),X=He.useCallback(()=>{J.current&&(clearTimeout(J.current),J.current=null);},[]),ot=He.useCallback(()=>{X(),I(true),l?.onHover?.onEnter&&l.onHover.onEnter(G()),i?.onMouseEnter?.(e,y);},[i,l,e,y,G,X]),st=He.useCallback(()=>{X(),J.current=setTimeout(()=>{ge.current||(I(false),l?.onHover?.onLeave&&l.onHover.onLeave(G()),i?.onMouseLeave?.(e,y));},De);},[i,l,e,y,G,X]),it=He.useCallback(()=>{X(),ge.current=true;},[X]),lt=He.useCallback(()=>{ge.current=false,X(),J.current=setTimeout(()=>{I(false),l?.onHover?.onLeave&&l.onHover.onLeave(G()),i?.onMouseLeave?.(e,y);},De);},[i,l,e,y,G,X]);He.useEffect(()=>()=>{J.current&&clearTimeout(J.current);},[]);let ct=He.useCallback(P=>{u&&(P.preventDefault(),P.stopPropagation(),i?.onTouchEnd?.(e,y,P));},[i,e,y,u]);if(a!=null&&M==="keySpan"&&w)return jsxRuntime.jsx("span",{className:chunk6VPT3IIK_cjs.h("text-gray-400 dark:text-gray-500",r),children:a});let fe=chunk6VPT3IIK_cjs.h((h||A)&&s==="brackets"&&"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:underline",w&&"opacity-70 line-through text-gray-400 dark:text-gray-500",E&&"text-gray-500 dark:text-gray-400"),q=()=>c?c(T):E?jsxRuntime.jsx(Kt,{}):h&&!A?jsxRuntime.jsx(Ft,{}):A?jsxRuntime.jsx(Ot,{}):w?jsxRuntime.jsx(Gt,{}):null,Re=()=>{if(x)return x({citation:e,status:T,citationKey:y,displayText:N,isMergedDisplay:M==="keySpan"});if(M==="indicator")return jsxRuntime.jsx("span",{children:q()});if(s==="chip"){let P=chunk6VPT3IIK_cjs.h(h&&!A&&!E&&"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",A&&!E&&"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400",w&&!E&&"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400 line-through",E&&"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400",!h&&!w&&!E&&"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400");return jsxRuntime.jsxs("span",{className:chunk6VPT3IIK_cjs.h("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-sm font-medium",P),children:[jsxRuntime.jsx("span",{className:"max-w-60 overflow-hidden text-ellipsis whitespace-nowrap",children:N}),q()]})}if(s==="superscript"){let P=chunk6VPT3IIK_cjs.h(h&&!A&&!E&&"text-green-600 dark:text-green-500",A&&!E&&"text-amber-600 dark:text-amber-500",w&&!E&&"text-red-500 dark:text-red-400 line-through",E&&"text-gray-400 dark:text-gray-500",!h&&!w&&!E&&"text-blue-600 dark:text-blue-400");return jsxRuntime.jsxs("sup",{className:chunk6VPT3IIK_cjs.h("text-xs font-medium transition-colors hover:underline",P),children:["[",N,q(),"]"]})}return s==="text"?jsxRuntime.jsxs("span",{className:fe,children:[N,q()]}):s==="minimal"?jsxRuntime.jsxs("span",{className:chunk6VPT3IIK_cjs.h("max-w-80 overflow-hidden text-ellipsis",fe),children:[N,q()]}):jsxRuntime.jsxs("span",{className:chunk6VPT3IIK_cjs.h("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:["[",jsxRuntime.jsxs("span",{className:chunk6VPT3IIK_cjs.h("max-w-80 overflow-hidden text-ellipsis",fe),children:[N,q()]}),"]"]})},dt=!(v==="hidden")&&(n&&(n.verificationImageBase64||n.verifiedMatchSnippet)||E||L||o||w),ut=!!n?.verificationImageBase64,Te=k?jsxRuntime.jsx($t,{src:k,alt:"Citation verification - full size",onClose:()=>C(null)}):null,Be={"data-citation-id":y,"data-citation-instance":U,className:chunk6VPT3IIK_cjs.h("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",ut&&"cursor-zoom-in",r),onMouseEnter:ot,onMouseLeave:st,onClick:at,onTouchEndCapture:u?ct:void 0,"aria-label":N?`[${N}]`:void 0};if(dt){let P=p?p({citation:e,verification:n??null,status:T}):jsxRuntime.jsx(Yt,{citation:e,verification:n??null,status:T,isLoading:o||E,isPhrasesExpanded:D,onPhrasesExpandChange:j,onImageClick:()=>{n?.verificationImageBase64&&C(n.verificationImageBase64);}});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t,jsxRuntime.jsxs($e,{open:b,children:[jsxRuntime.jsx(Fe,{asChild:true,children:jsxRuntime.jsx("span",{ref:B,...Be,children:Re()})}),jsxRuntime.jsx(ye,{side:v==="bottom"?"bottom":"top",onPointerDownOutside:ne=>ne.preventDefault(),onInteractOutside:ne=>ne.preventDefault(),onMouseEnter:it,onMouseLeave:lt,children:P})]}),Te]})}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t,jsxRuntime.jsx("span",{ref:B,...Be,children:Re()}),Te]})});Ne.displayName="CitationComponent";var Zt=He.memo(Ne);function nt(e,t){return t||`https://www.google.com/s2/favicons?domain=${O(e)}&sz=32`}function Le(e){if(!e.startsWith("http://")&&!e.startsWith("https://"))return "unknown";try{let t=O(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 Me(e,t){let r=(t||O(e)).toLowerCase(),a={"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(a[r])return a[r];for(let[n,o]of Object.entries(a))if(r===n||r.endsWith("."+n))return o;return r.charAt(0).toUpperCase()+r.slice(1)}var Qt=()=>jsxRuntime.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:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),er=()=>jsxRuntime.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:jsxRuntime.jsx("polyline",{points:"9 18 15 12 9 6"})}),tr=()=>jsxRuntime.jsxs("svg",{className:"animate-spin",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.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"})]}),de=He.forwardRef(({id:e,url:t,title:r,domain:a,sourceType:n,faviconUrl:o,citationNumbers:s,verificationStatus:d,onClick:i,className:l,showVerificationIndicator:u=false,showCitationBadges:c=false,renderFavicon:x},v)=>{let p=He.useCallback(k=>{i?i({id:e,url:t,title:r,domain:a,sourceType:n,faviconUrl:o,citationNumbers:s,verificationStatus:d},k):window.open(t,"_blank","noopener,noreferrer");},[i,e,t,r,a,n,o,s,d]),B=He.useMemo(()=>Me(t,a),[t,a]),M=He.useMemo(()=>nt(t,o),[t,o]),b=He.useMemo(()=>n||Le(t),[n,t]),I=()=>{if(!u||!d)return null;let C={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 jsxRuntime.jsx("span",{className:chunk6VPT3IIK_cjs.p("text-sm ml-1",C.className),"aria-label":d,children:C.icon})};return jsxRuntime.jsxs("div",{ref:v,"data-source-id":e,"data-source-type":b,className:chunk6VPT3IIK_cjs.p("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",l),onClick:p,role:"link",tabIndex:0,onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),p(k));},"aria-label":`${r} from ${B}`,children:[jsxRuntime.jsx("div",{className:"flex-shrink-0 mt-0.5",children:x?x({id:e,url:t,title:r,domain:a,sourceType:n,faviconUrl:o,citationNumbers:s,verificationStatus:d}):jsxRuntime.jsx("img",{src:M,alt:"",className:"w-5 h-5 rounded",width:20,height:20,loading:"lazy",onError:k=>{k.target.style.display="none";}})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("span",{className:"text-gray-900 dark:text-gray-100 font-medium text-sm leading-tight line-clamp-2",children:r}),I()]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[jsxRuntime.jsx("span",{className:"text-gray-500 dark:text-gray-400 text-xs",children:B}),c&&s&&s.length>0&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[s.slice(0,3).map(k=>jsxRuntime.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:k},k)),s.length>3&&jsxRuntime.jsxs("span",{className:"text-xs text-gray-400",children:["+",s.length-3]})]})]})]}),jsxRuntime.jsx("div",{className:"flex-shrink-0 text-gray-400 dark:text-gray-500 mt-1",children:jsxRuntime.jsx(er,{})})]})});de.displayName="SourcesListItem";var Ie=He.forwardRef(({sources:e,maxIcons:t=3,onClick:r,label:a="Sources",className:n,isOpen:o},s)=>{let d=He.useMemo(()=>e.slice(0,t),[e,t]),i=e.length>t;return jsxRuntime.jsxs("button",{ref:s,type:"button",onClick:r,className:chunk6VPT3IIK_cjs.p("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",n),"aria-expanded":o,"aria-haspopup":"dialog",children:[jsxRuntime.jsx("span",{className:"font-medium",children:a}),jsxRuntime.jsxs("div",{className:"flex items-center -space-x-1",children:[d.map((l,u)=>jsxRuntime.jsx("img",{src:nt(l.url,l.faviconUrl),alt:"",className:chunk6VPT3IIK_cjs.p("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:c=>{c.target.style.opacity="0";}},l.id)),i&&jsxRuntime.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]})]})]})});Ie.displayName="SourcesTrigger";var Ee=He.forwardRef(({sources:e,variant:t="drawer",isOpen:r=true,onOpenChange:a,header:n={},isLoading:o=false,emptyMessage:s="No sources available",maxHeight:d,className:i,listClassName:l,onSourceClick:u,showVerificationIndicators:c=false,showCitationBadges:x=false,groupByDomain:v=false,renderItem:p,renderEmpty:B,renderLoading:M},b)=>{let I=He.useRef(null),[k,C]=He.useState(false);He.useEffect(()=>{if(!r||t==="inline")return;let h=L=>{L.key==="Escape"&&a?.(false);};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[r,a,t]),He.useEffect(()=>{C(true);},[]);let D=He.useMemo(()=>{if(!v)return null;let h={};for(let L of e){let V=L.domain||O(L.url);h[V]||(h[V]=[]),h[V].push(L);}return h},[e,v]),j=He.useCallback(()=>{a?.(false);},[a]),y=He.useCallback(h=>{h.target===h.currentTarget&&j();},[j]),U=()=>{let{title:h="Sources",showCloseButton:L=true,showCount:V=true,renderHeader:K}=n;return K?K({title:h,count:e.length,onClose:j}):jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:[L&&t!=="inline"&&jsxRuntime.jsx("button",{type:"button",onClick:j,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:jsxRuntime.jsx(Qt,{})}),jsxRuntime.jsxs("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100 flex-1 text-center",children:[h,V&&jsxRuntime.jsxs("span",{className:"ml-2 text-sm font-normal text-gray-500 dark:text-gray-400",children:["(",e.length,")"]})]}),L&&t!=="inline"&&jsxRuntime.jsx("div",{className:"w-8"})]})},T=()=>o?M?M():jsxRuntime.jsxs("div",{className:"flex items-center justify-center py-8 text-gray-500 dark:text-gray-400",children:[jsxRuntime.jsx(tr,{}),jsxRuntime.jsx("span",{className:"ml-2 text-sm",children:"Loading sources..."})]}):e.length===0?B?B():jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8 text-gray-500 dark:text-gray-400 text-sm",children:s}):v&&D?jsxRuntime.jsx("div",{className:l,children:Object.entries(D).map(([h,L])=>jsxRuntime.jsxs("div",{children:[jsxRuntime.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:Me(L[0].url,h)}),L.map((V,K)=>p?p(V,K):jsxRuntime.jsx(de,{...V,onClick:u,showVerificationIndicator:c,showCitationBadges:x},V.id))]},h))}):jsxRuntime.jsx("div",{className:l,children:e.map((h,L)=>p?p(h,L):jsxRuntime.jsx(de,{...h,onClick:u,showVerificationIndicator:c,showCitationBadges:x},h.id))}),w=d?{maxHeight:typeof d=="number"?`${d}px`:d}:void 0;if(t==="inline")return r?jsxRuntime.jsxs("div",{ref:b,className:chunk6VPT3IIK_cjs.p("bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700",i),style:w,children:[U(),jsxRuntime.jsx("div",{className:"overflow-y-auto",style:w,children:T()})]}):null;if(t==="panel")return r?jsxRuntime.jsxs("div",{ref:b,className:chunk6VPT3IIK_cjs.p("bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700 shadow-lg",i),children:[U(),jsxRuntime.jsx("div",{className:"overflow-y-auto",style:w||{maxHeight:"400px"},children:T()})]}):null;if(!k||!r)return null;let A=jsxRuntime.jsxs("div",{ref:b,className:chunk6VPT3IIK_cjs.p("fixed inset-0 z-50",t==="modal"&&"flex items-center justify-center"),role:"dialog","aria-modal":"true","aria-labelledby":"sources-title",children:[jsxRuntime.jsx("div",{className:chunk6VPT3IIK_cjs.p("absolute inset-0 bg-black/40 dark:bg-black/60 transition-opacity",r?"opacity-100":"opacity-0"),onClick:y,"aria-hidden":"true"}),t==="drawer"?jsxRuntime.jsxs("div",{ref:I,className:chunk6VPT3IIK_cjs.p("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",i),children:[jsxRuntime.jsx("div",{className:"flex justify-center py-2",children:jsxRuntime.jsx("div",{className:"w-10 h-1 bg-gray-300 dark:bg-gray-600 rounded-full"})}),U(),jsxRuntime.jsx("div",{className:"overflow-y-auto flex-1",children:T()})]}):jsxRuntime.jsxs("div",{ref:I,className:chunk6VPT3IIK_cjs.p("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",i),children:[U(),jsxRuntime.jsx("div",{className:"overflow-y-auto flex-1",children:T()})]})]});return reactDom.createPortal(A,document.body)});Ee.displayName="SourcesListComponent";var rr=He.memo(de),nr=He.memo(Ie),ar=He.memo(Ee);function or(e){let t=new Map;for(let r of e){if(!r.url)continue;let a=r.domain||O(r.url),n=r.url;if(t.has(n)){let o=t.get(n);r.citationNumber&&!o.citationNumbers?.includes(r.citationNumber)&&(o.citationNumbers=[...o.citationNumbers||[],r.citationNumber]);}else t.set(n,{id:n,url:r.url,title:r.title||a,domain:a,sourceType:r.sourceType||Le(r.url),faviconUrl:r.faviconUrl,citationNumbers:r.citationNumber?[r.citationNumber]:[]});}return Array.from(t.values())}function sr(e=[]){let[t,r]=He.useState(e),[a,n]=He.useState(false),o=He.useCallback(i=>{r(l=>l.some(c=>c.url===i.url)?l:[...l,i]);},[]),s=He.useCallback(i=>{r(l=>l.filter(u=>u.id!==i));},[]),d=He.useCallback(()=>{r([]);},[]);return {sources:t,setSources:r,addSource:o,removeSource:s,clearSources:d,isOpen:a,setIsOpen:n,open:()=>n(true),close:()=>n(false),toggle:()=>n(i=>!i)}}
|
|
5
|
-
Object.defineProperty(exports,"CITATION_X_PADDING",{enumerable:true,get:function(){return
|
|
1
|
+
'use strict';var chunkQDDCYCBV_cjs=require('../chunk-QDDCYCBV.cjs');require('../chunk-F2MMVEVC.cjs');var ze=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),F=require('@radix-ui/react-popover');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var ze__namespace=/*#__PURE__*/_interopNamespace(ze);var F__namespace=/*#__PURE__*/_interopNamespace(F);function X(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e.replace(/^https?:\/\/(www\.)?/,"").split("/")[0]}}function Oe(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}function _t(e){try{let t=new URL(e),r=t.pathname+t.search;return r==="/"?"":r}catch{return ""}}var Ge={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 Xe(e){return e.startsWith("blocked_")}function Ye(e){return e.startsWith("error_")}function Rt(e){return e==="verified"||e==="partial"||e==="accessible"||e==="redirected_valid"}function Bt(e){return e==="redirected"||e==="redirected_valid"}function Tt(e){return e==="verified"||e==="partial"||e==="redirected_valid"}var jt=({status:e,errorMessage:t})=>{let r=Ge[e];return jsxRuntime.jsx("span",{className:chunkQDDCYCBV_cjs.q("inline-flex items-center gap-1",r.className),title:t||r.label,"aria-label":r.label,children:jsxRuntime.jsx("span",{className:"text-[0.9em]","aria-hidden":"true",children:r.icon})})},we=({url:e,faviconUrl:t})=>{let r=X(e),n=t||`https://www.google.com/s2/favicons?domain=${r}&sz=16`;return jsxRuntime.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";}})},Ze=ze.forwardRef(({urlMeta:e,citation:t,children:r,className:n,variant:a="chip",showFullUrlOnHover:o=true,showFavicon:i=true,showTitle:d=false,maxDisplayLength:s=30,renderBlockedIndicator:c,onUrlClick:u,eventHandlers:l,preventTooltips:g=false},x)=>{let{url:m,domain:I,title:B,fetchStatus:h,faviconUrl:k,errorMessage:N}=e,S=ze.useMemo(()=>t||{value:m,fullPhrase:B||m},[t,m,B]),M=ze.useMemo(()=>chunkQDDCYCBV_cjs.k(S),[S]),T=ze.useMemo(()=>chunkQDDCYCBV_cjs.m(M),[M]),W=ze.useMemo(()=>I||X(m),[I,m]),A=ze.useMemo(()=>_t(m),[m]),C=ze.useMemo(()=>{if(d&&B)return Oe(B,s);let D=A?Oe(A,s-W.length-1):"";return D?`${W}${D}`:W},[d,B,W,A,s]),U=Ge[h],O=Xe(h),v=Ye(h),P=h==="verified",E=h==="partial",H=h==="pending",de=ze.useCallback(D=>{D.preventDefault(),D.stopPropagation(),u?u(m,D):window.open(m,"_blank","noopener,noreferrer"),l?.onClick?.(S,M,D);},[u,m,l,S,M]),ue=ze.useCallback(()=>{l?.onMouseEnter?.(S,M);},[l,S,M]),Q=ze.useCallback(()=>{l?.onMouseLeave?.(S,M);},[l,S,M]),$=()=>O||v?c?c(h,N):jsxRuntime.jsx(jt,{status:h,errorMessage:N}):P?jsxRuntime.jsx("span",{className:"text-[0.85em] text-green-600 dark:text-green-500","aria-hidden":"true",title:"Verified",children:"\u2713"}):E?jsxRuntime.jsx("span",{className:"text-[0.85em] text-amber-600 dark:text-amber-500","aria-hidden":"true",title:"Partial match",children:"~"}):H?jsxRuntime.jsx("span",{className:"opacity-70","aria-hidden":"true",children:"\u2026"}):null;return a==="chip"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r,jsxRuntime.jsxs("span",{ref:x,"data-citation-id":M,"data-citation-instance":T,"data-url":m,"data-fetch-status":h,"data-variant":"chip",className:chunkQDDCYCBV_cjs.q("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",U.className,n),title:o?m:void 0,onMouseEnter:g?void 0:ue,onMouseLeave:g?void 0:Q,onMouseDown:de,onClick:D=>D.stopPropagation(),role:"link","aria-label":`Link to ${W}: ${U.label}`,children:[i&&jsxRuntime.jsx(we,{url:m,faviconUrl:k}),jsxRuntime.jsx("span",{className:"max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap",children:C}),$()]})]}):a==="inline"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r,jsxRuntime.jsxs("a",{ref:x,href:m,"data-citation-id":M,"data-citation-instance":T,"data-fetch-status":h,"data-variant":"inline",className:chunkQDDCYCBV_cjs.q("inline-flex items-center gap-1 cursor-pointer transition-colors no-underline border-b border-dotted border-current",U.className,n),title:o?m:void 0,onMouseEnter:g?void 0:ue,onMouseLeave:g?void 0:Q,onClick:D=>{D.preventDefault(),de(D);},target:"_blank",rel:"noopener noreferrer","aria-label":`Link to ${W}: ${U.label}`,children:[i&&jsxRuntime.jsx(we,{url:m,faviconUrl:k}),jsxRuntime.jsx("span",{children:C}),$()]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r,jsxRuntime.jsxs("span",{ref:x,"data-citation-id":M,"data-citation-instance":T,"data-url":m,"data-fetch-status":h,"data-variant":"bracket",className:chunkQDDCYCBV_cjs.q("cursor-pointer transition-colors",U.className,n),title:o?m:void 0,onMouseEnter:g?void 0:ue,onMouseLeave:g?void 0:Q,onMouseDown:de,onClick:D=>D.stopPropagation(),role:"link","aria-label":`Link to ${W}: ${U.label}`,children:["[",i&&jsxRuntime.jsx(we,{url:m,faviconUrl:k}),jsxRuntime.jsx("span",{className:"max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap",children:C}),$(),"]"]})]})});Ze.displayName="UrlCitationComponent";ze.memo(Ze);var zt=({className:e})=>jsxRuntime.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:[jsxRuntime.jsx("path",{d:"M7 3 L3 3 L3 21 L7 21"}),jsxRuntime.jsx("path",{d:"M17 3 L21 3 L21 21 L17 21"})]}),re=({className:e})=>jsxRuntime.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:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})}),ie=({className:e})=>jsxRuntime.jsx("svg",{className:e,viewBox:"0 0 256 256",fill:"currentColor","aria-hidden":"true",style:{width:"100%",height:"100%"},children:jsxRuntime.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"})}),se=({className:e})=>jsxRuntime.jsxs("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",style:{width:"100%",height:"100%"},children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",style:{opacity:.25}}),jsxRuntime.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}})]}),Vt=({className:e})=>jsxRuntime.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:[jsxRuntime.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"}),jsxRuntime.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"})]}),Ut=({className:e})=>jsxRuntime.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:[jsxRuntime.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),jsxRuntime.jsx("polyline",{points:"15 3 21 3 21 9"}),jsxRuntime.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),Wt=({className:e})=>jsxRuntime.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:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]});function At(...e){return e.filter(Boolean).join(" ")}var Qe=F__namespace.Root,et=F__namespace.Trigger;var Pe=ze__namespace.forwardRef(({className:e,align:t="center",sideOffset:r=8,...n},a)=>jsxRuntime.jsx(F__namespace.Portal,{children:jsxRuntime.jsx(F__namespace.Content,{ref:a,align:t,sideOffset:r,className:At("z-[9998] rounded-lg border bg-white shadow-xl outline-none","w-fit max-w-[min(600px,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})}));Pe.displayName=F__namespace.Content.displayName;function ot(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=Ht(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}),it(u)}function Ht(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 $t(d,e,t)}function $t(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.unshift({value:t[a],count:1});i>0&&(a===u?(o--,n.unshift({value:r[o],added:true,count:1})):(a--,n.unshift({value:t[a],removed:true,count:1})));}return n}function it(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 tt(e){if(!e)return [];let t=[],r="";for(let n=0;n<e.length;n++){let a=e[n];r+=a,a===`
|
|
2
|
+
`&&(t.push(r),r="");}return r.length>0&&t.push(r),t}var rt="a-zA-Z0-9_\\u00AD\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C6\\u02C8-\\u02D7\\u02DE-\\u02FF\\u1E00-\\u1EFF",Ft=new RegExp(`[${rt}]+|\\s+|[^${rt}]`,"gu");function at(e){return e?e.match(Ft)||[]:[]}function nt(e,t){let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];)r++;return e.slice(0,r)}function Se(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 Kt(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=nt(a.value,o.value).match(/^\s*/)?.[0]||"",s=a.value.slice(d.length),c=o.value.slice(d.length),l=Se(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=Se(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&&Se(s,i).length===i.length){t.push({value:n.value.slice(i.length),removed:true,count:1});continue}if(d&&c&&nt(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 it(t)}function st(e,t){let r=tt(e),n=tt(t);return ot(r,n)}function lt(e,t){let r=at(e),n=at(t),a=ot(r,n);return Kt(a)}var ct=(e="",t="")=>ze.useMemo(()=>{let r=(e||"").trim().replace(/\r\n/g,`
|
|
3
|
+
`),n=(t||"").trim().replace(/\r\n/g,`
|
|
4
|
+
`),a=st(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=lt(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]);function Zt(e){switch(e){case "chip":case "text":case "brackets":return "keySpan";case "source":return "source";default:return "number"}}function Jt(e){return e.replace(/^\[+\s*/,"").replace(/\s*\]+$/,"")}function qt(e,t,r){if(t==="indicator")return "";if(t==="keySpan"){let n=e.keySpan?.toString()||e.citationNumber?.toString()||r||"1";return Jt(n)}return t==="source"?e.siteName||e.domain||e.keySpan?.toString()||"Source":e.citationNumber?.toString()||"1"}function Qt(e){return e.isVerified&&!e.isPartialMatch?"Verified":e.isPartialMatch?"Partial Match":e.isMiss?"Not Found":e.isPending?"Verifying...":""}function er(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 tr({src:e,alt:t,onClose:r}){return ze.useEffect(()=>{let n=a=>{a.key==="Escape"&&r();};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[r]),reactDom.createPortal(jsxRuntime.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:jsxRuntime.jsx("div",{className:"relative max-w-[95vw] max-h-[95vh] cursor-zoom-out animate-in zoom-in-95 duration-[50ms]",children:jsxRuntime.jsx("img",{src:e,alt:t,className:"max-w-full max-h-[95vh] object-contain rounded-lg shadow-2xl",draggable:false})})}),document.body)}var rr=()=>jsxRuntime.jsx("span",{className:"inline-flex relative ml-0.5 size-2 text-green-600 dark:text-green-500","aria-hidden":"true",children:jsxRuntime.jsx(re,{})}),ar=()=>jsxRuntime.jsx("span",{className:"inline-flex relative ml-0.5 size-2 text-amber-600 dark:text-amber-500","aria-hidden":"true",children:jsxRuntime.jsx(re,{})}),nr=()=>jsxRuntime.jsx("span",{className:"inline-flex ml-1 size-2 animate-spin text-gray-400 dark:text-gray-500","aria-hidden":"true",children:jsxRuntime.jsx(se,{})}),or=()=>jsxRuntime.jsx("span",{className:"inline-flex relative ml-0.5 size-2 text-amber-500 dark:text-amber-400","aria-hidden":"true",children:jsxRuntime.jsx(ie,{})});function ir({citation:e,verification:t,isExpanded:r,onExpandChange:n}){let a=ze.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]=ze.useState(false),d=r??o,s=ze.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 jsxRuntime.jsxs("div",{className:"mt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-gray-500 dark:text-gray-400 uppercase font-medium",children:[jsxRuntime.jsxs("span",{children:["Searched ",a.length," phrase",a.length!==1?"s":""]}),u>0&&!d&&jsxRuntime.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&&jsxRuntime.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"})]}),jsxRuntime.jsx("div",{className:"mt-1 space-y-1",children:a.slice(0,c).map((l,g)=>jsxRuntime.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 sr({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)return jsxRuntime.jsxs("div",{className:"p-2",children:[jsxRuntime.jsxs("button",{type:"button",className:"group block cursor-zoom-in relative",onClick:m=>{m.preventDefault(),m.stopPropagation(),n?.();},"aria-label":"Click to view full size",children:[jsxRuntime.jsx("img",{src:t.verificationImageBase64,alt:"Citation verification",className:"max-w-full h-auto object-contain rounded-md bg-gray-50 dark:bg-gray-800",loading:"lazy"}),jsxRuntime.jsx("span",{className:"absolute inset-0 flex items-center justify-center bg-black/0 group-hover:bg-black/5 dark:group-hover:bg-white/5 transition-colors rounded-md",children:jsxRuntime.jsx("span",{className:"opacity-0 group-hover:opacity-100 transition-opacity text-xs text-gray-600 dark:text-gray-300 bg-white/90 dark:bg-gray-800/90 px-2 py-1 rounded shadow-sm",children:"Click to expand"})})]}),(s||c)&&jsxRuntime.jsx(dt,{citation:e,verification:t,status:r})]});if(a||u){let m=e.fullPhrase||e.keySpan?.toString();return jsxRuntime.jsxs("div",{className:"p-3 flex flex-col gap-2 min-w-[200px] max-w-[400px]",children:[jsxRuntime.jsxs("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:[jsxRuntime.jsx("span",{className:"inline-block relative top-[0.1em] mr-1.5 size-2 animate-spin",children:jsxRuntime.jsx(se,{})}),"Searching..."]}),m&&jsxRuntime.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:['"',m.length>80?m.slice(0,80)+"\u2026":m,'"']}),e.pageNumber&&e.pageNumber>0&&jsxRuntime.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Looking on page ",e.pageNumber]})]})}if(s)return jsxRuntime.jsxs("div",{className:"p-3 flex flex-col gap-2 min-w-[200px] max-w-[400px]",children:[jsxRuntime.jsxs("span",{className:"text-xs font-medium text-red-600 dark:text-red-500",children:[jsxRuntime.jsx("span",{className:"inline-block relative top-[0.1em] mr-1.5 size-3 text-amber-500 dark:text-amber-400",children:jsxRuntime.jsx(ie,{})}),"Not found: ",e.keySpan||e.fullPhrase]}),jsxRuntime.jsx(ir,{citation:e,verification:t,isExpanded:o,onExpandChange:i})]});let l=Qt(r),g=t?.verifiedMatchSnippet,x=t?.verifiedPageNumber;return !g&&!l?null:jsxRuntime.jsxs("div",{className:"p-3 flex flex-col gap-2 min-w-[180px] max-w-full",children:[l&&jsxRuntime.jsx("span",{className:chunkQDDCYCBV_cjs.i("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&&jsxRuntime.jsxs("span",{className:"text-sm text-gray-700 dark:text-gray-300 italic",children:['"',t.verifiedMatchSnippet,'"']}),x&&x>0&&jsxRuntime.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Page ",x]}),(s||c)&&jsxRuntime.jsx(dt,{citation:e,verification:t,status:r})]})}function dt({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}=ct(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,m=t?.verifiedPageNumber,I=x!=null&&m!=null&&x!==m;return n?jsxRuntime.jsxs("div",{className:"mt-2 pt-2 border-t border-gray-200 dark:border-gray-700 text-xs space-y-2",children:[o&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Expected"}),jsxRuntime.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})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Found"}),jsxRuntime.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,'"']})]})]}):jsxRuntime.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?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Diff"}),jsxRuntime.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?jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("span",{className:"text-gray-500 dark:text-gray-400 text-[10px]",children:["Expected:"," "]}),jsxRuntime.jsx("span",{className:"text-red-600 dark:text-red-400 line-through opacity-70",children:o.length>100?o.slice(0,100)+"\u2026":o})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("span",{className:"text-gray-500 dark:text-gray-400 text-[10px]",children:["Found:"," "]}),jsxRuntime.jsx("span",{className:"text-green-600 dark:text-green-400",children:i.length>100?i.slice(0,100)+"\u2026":i})]})]}):d.map((B,h)=>jsxRuntime.jsx("span",{children:B.parts.map((k,N)=>{let S=`p-${h}-${N}`;return k.removed?jsxRuntime.jsx("span",{className:"bg-red-200 dark:bg-red-900/50 text-red-700 dark:text-red-300 line-through",title:"Expected text",children:k.value},S):k.added?jsxRuntime.jsx("span",{className:"bg-green-200 dark:bg-green-900/50 text-green-700 dark:text-green-300",title:"Actual text found",children:k.value},S):jsxRuntime.jsx("span",{children:k.value},S)})},`block-${h}`))})]}):o&&!s?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Text"}),jsxRuntime.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,I&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Page"}),jsxRuntime.jsxs("p",{className:"mt-1 font-mono text-[11px] text-gray-700 dark:text-gray-300",children:[jsxRuntime.jsx("span",{className:"text-red-600 dark:text-red-400 line-through opacity-70",children:x})," \u2192 ",m]})]}),g&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{className:"text-gray-500 dark:text-gray-400 font-medium uppercase text-[10px]",children:"Line"}),jsxRuntime.jsxs("p",{className:"mt-1 font-mono text-[11px] text-gray-700 dark:text-gray-300",children:[jsxRuntime.jsx("span",{className:"text-red-600 dark:text-red-400 line-through opacity-70",children:u?.join(", ")})," \u2192 ",l?.join(", ")]})]})]})}var Me=ze.forwardRef(({citation:e,children:t,className:r,fallbackDisplay:n,verification:a,isLoading:o=false,variant:i="brackets",content:d,eventHandlers:s,behaviorConfig:c,isMobile:u=false,renderIndicator:l,renderContent:g,popoverPosition:x="top",renderPopoverContent:m,additionalCount:I,faviconUrl:B},h)=>{let k=ze.useMemo(()=>d||Zt(i),[d,i]),[N,S]=ze.useState(false),[M,T]=ze.useState(null),[W,A]=ze.useState(false),C=ze.useMemo(()=>chunkQDDCYCBV_cjs.k(e),[e]),U=ze.useMemo(()=>chunkQDDCYCBV_cjs.m(C),[C]),O=ze.useMemo(()=>er(a),[a]),{isMiss:v,isPartialMatch:P,isVerified:E,isPending:H}=O,de=5e3,[ue,Q]=ze.useState(false),$=ze.useRef(null),D=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",z=(o||H)&&!D&&!ue;ze.useEffect(()=>($.current&&(clearTimeout($.current),$.current=null),(o||H)&&!D?(Q(false),$.current=setTimeout(()=>{Q(true);},de)):Q(false),()=>{$.current&&clearTimeout($.current);}),[o,H,D]);let G=ze.useMemo(()=>qt(e,k,n),[e,k,n]),J=ze.useCallback(()=>({citation:e,citationKey:C,verification:a??null,isTooltipExpanded:N,isImageExpanded:!!M,hasImage:!!a?.verificationImageBase64}),[e,C,a,N,M]),Ae=ze.useCallback(w=>{w.setImageExpanded!==void 0&&(typeof w.setImageExpanded=="string"?T(w.setImageExpanded):w.setImageExpanded===true&&a?.verificationImageBase64?T(a.verificationImageBase64):w.setImageExpanded===false&&T(null));},[a?.verificationImageBase64]),xt=ze.useCallback(w=>{w.preventDefault(),w.stopPropagation();let te=J();if(c?.onClick){let me=c.onClick(te,w);me&&typeof me=="object"&&Ae(me),s?.onClick?.(e,C,w);return}if(s?.onClick){s.onClick(e,C,w);return}a?.verificationImageBase64?T(a.verificationImageBase64):v&&A(me=>!me);},[c,s,e,C,a?.verificationImageBase64,v,J,Ae]),He=150,ee=ze.useRef(null),be=ze.useRef(false),q=ze.useCallback(()=>{ee.current&&(clearTimeout(ee.current),ee.current=null);},[]),ht=ze.useCallback(()=>{q(),S(true),c?.onHover?.onEnter&&c.onHover.onEnter(J()),s?.onMouseEnter?.(e,C);},[s,c,e,C,J,q]),yt=ze.useCallback(()=>{q(),ee.current=setTimeout(()=>{be.current||(S(false),c?.onHover?.onLeave&&c.onHover.onLeave(J()),s?.onMouseLeave?.(e,C));},He);},[s,c,e,C,J,q]),vt=ze.useCallback(()=>{q(),be.current=true;},[q]),bt=ze.useCallback(()=>{be.current=false,q(),ee.current=setTimeout(()=>{S(false),c?.onHover?.onLeave&&c.onHover.onLeave(J()),s?.onMouseLeave?.(e,C);},He);},[s,c,e,C,J,q]);ze.useEffect(()=>()=>{ee.current&&clearTimeout(ee.current);},[]);let kt=ze.useCallback(w=>{u&&(w.preventDefault(),w.stopPropagation(),s?.onTouchEnd?.(e,C,w));},[s,e,C,u]);if(n!=null&&k==="keySpan"&&v)return jsxRuntime.jsx("span",{className:chunkQDDCYCBV_cjs.i("text-gray-400 dark:text-gray-500",r),children:n});let ke=chunkQDDCYCBV_cjs.i((E||P)&&i==="brackets"&&"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:underline",v&&"opacity-70 line-through text-gray-400 dark:text-gray-500",z&&"text-gray-500 dark:text-gray-400"),ae=()=>l?l(O):z?jsxRuntime.jsx(nr,{}):E&&!P?jsxRuntime.jsx(rr,{}):P?jsxRuntime.jsx(ar,{}):v?jsxRuntime.jsx(or,{}):null,$e=()=>{if(g)return g({citation:e,status:O,citationKey:C,displayText:G,isMergedDisplay:k==="keySpan"});if(k==="indicator")return jsxRuntime.jsx("span",{children:ae()});if(i==="chip"){let w=chunkQDDCYCBV_cjs.i(E&&!P&&!z&&"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",P&&!z&&"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400",v&&!z&&"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400 line-through",z&&"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400",!E&&!v&&!z&&"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400");return jsxRuntime.jsxs("span",{className:chunkQDDCYCBV_cjs.i("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-sm font-medium",w),children:[jsxRuntime.jsx("span",{className:"max-w-60 overflow-hidden text-ellipsis whitespace-nowrap",children:G}),ae()]})}if(i==="superscript"){let w=chunkQDDCYCBV_cjs.i(E&&!P&&!z&&"text-green-600 dark:text-green-500",P&&!z&&"text-amber-600 dark:text-amber-500",v&&!z&&"text-red-500 dark:text-red-400 line-through",z&&"text-gray-400 dark:text-gray-500",!E&&!v&&!z&&"text-blue-600 dark:text-blue-400");return jsxRuntime.jsxs("sup",{className:chunkQDDCYCBV_cjs.i("text-xs font-medium transition-colors hover:underline",w),children:["[",G,ae(),"]"]})}if(i==="text")return jsxRuntime.jsxs("span",{className:ke,children:[G,ae()]});if(i==="minimal")return jsxRuntime.jsxs("span",{className:chunkQDDCYCBV_cjs.i("max-w-80 overflow-hidden text-ellipsis",ke),children:[G,ae()]});if(i==="source"){let w=B||e.faviconUrl;return jsxRuntime.jsxs("span",{className:chunkQDDCYCBV_cjs.i("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:[w&&jsxRuntime.jsx("img",{src:w,alt:"",className:"w-4 h-4 rounded-sm object-contain",loading:"lazy",onError:te=>{te.target.style.display="none";}}),jsxRuntime.jsx("span",{className:"max-w-40 overflow-hidden text-ellipsis whitespace-nowrap",children:G}),I!==void 0&&I>0&&jsxRuntime.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["+",I]})]})}return jsxRuntime.jsxs("span",{className:chunkQDDCYCBV_cjs.i("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:["[",jsxRuntime.jsxs("span",{className:chunkQDDCYCBV_cjs.i("max-w-80 overflow-hidden text-ellipsis",ke),children:[G,ae()]}),"]"]})},Ct=!(x==="hidden")&&(a&&(a.verificationImageBase64||a.verifiedMatchSnippet)||z||H||o||v),wt=!!a?.verificationImageBase64,Fe=M?jsxRuntime.jsx(tr,{src:M,alt:"Citation verification - full size",onClose:()=>T(null)}):null,Ke={"data-citation-id":C,"data-citation-instance":U,className:chunkQDDCYCBV_cjs.i("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",wt&&"cursor-zoom-in",r),onMouseEnter:ht,onMouseLeave:yt,onClick:xt,onTouchEndCapture:u?kt:void 0,"aria-label":G?`[${G}]`:void 0};if(Ct){let w=m?m({citation:e,verification:a??null,status:O}):jsxRuntime.jsx(sr,{citation:e,verification:a??null,status:O,isLoading:o||z,isPhrasesExpanded:W,onPhrasesExpandChange:A,onImageClick:()=>{a?.verificationImageBase64&&T(a.verificationImageBase64);}});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t,jsxRuntime.jsxs(Qe,{open:N,children:[jsxRuntime.jsx(et,{asChild:true,children:jsxRuntime.jsx("span",{ref:h,...Ke,children:$e()})}),jsxRuntime.jsx(Pe,{side:x==="bottom"?"bottom":"top",onPointerDownOutside:te=>te.preventDefault(),onInteractOutside:te=>te.preventDefault(),onMouseEnter:vt,onMouseLeave:bt,children:w})]}),Fe]})}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t,jsxRuntime.jsx("span",{ref:h,...Ke,children:$e()}),Fe]})});Me.displayName="CitationComponent";var lr=ze.memo(Me);function pt(e,t){return t||`https://www.google.com/s2/favicons?domain=${X(e)}&sz=32`}function Re(e){if(!e.startsWith("http://")&&!e.startsWith("https://"))return "unknown";try{let t=X(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 Be(e,t){let r=(t||X(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 ur=()=>jsxRuntime.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:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),mr=()=>jsxRuntime.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:jsxRuntime.jsx("polyline",{points:"9 18 15 12 9 6"})}),pr=()=>jsxRuntime.jsxs("svg",{className:"animate-spin",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[jsxRuntime.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntime.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=ze.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 m=ze.useCallback(N=>{s?s({id:e,url:t,title:r,domain:n,sourceType:a,faviconUrl:o,citationNumbers:i,verificationStatus:d},N):window.open(t,"_blank","noopener,noreferrer");},[s,e,t,r,n,a,o,i,d]),I=ze.useMemo(()=>Be(t,n),[t,n]),B=ze.useMemo(()=>pt(t,o),[t,o]),h=ze.useMemo(()=>a||Re(t),[a,t]),k=()=>{if(!u||!d)return null;let S={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 jsxRuntime.jsx("span",{className:chunkQDDCYCBV_cjs.q("text-sm ml-1",S.className),"aria-label":d,children:S.icon})};return jsxRuntime.jsxs("div",{ref:x,"data-source-id":e,"data-source-type":h,className:chunkQDDCYCBV_cjs.q("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:m,role:"link",tabIndex:0,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),m(N));},"aria-label":`${r} from ${I}`,children:[jsxRuntime.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}):jsxRuntime.jsx("img",{src:B,alt:"",className:"w-5 h-5 rounded",width:20,height:20,loading:"lazy",onError:N=>{N.target.style.display="none";}})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("span",{className:"text-gray-900 dark:text-gray-100 font-medium text-sm leading-tight line-clamp-2",children:r}),k()]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[jsxRuntime.jsx("span",{className:"text-gray-500 dark:text-gray-400 text-xs",children:I}),l&&i&&i.length>0&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[i.slice(0,3).map(N=>jsxRuntime.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:N},N)),i.length>3&&jsxRuntime.jsxs("span",{className:"text-xs text-gray-400",children:["+",i.length-3]})]})]})]}),jsxRuntime.jsx("div",{className:"flex-shrink-0 text-gray-400 dark:text-gray-500 mt-1",children:jsxRuntime.jsx(mr,{})})]})});ye.displayName="SourcesListItem";var Te=ze.forwardRef(({sources:e,maxIcons:t=3,onClick:r,label:n="Sources",className:a,isOpen:o},i)=>{let d=ze.useMemo(()=>e.slice(0,t),[e,t]),s=e.length>t;return jsxRuntime.jsxs("button",{ref:i,type:"button",onClick:r,className:chunkQDDCYCBV_cjs.q("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:[jsxRuntime.jsx("span",{className:"font-medium",children:n}),jsxRuntime.jsxs("div",{className:"flex items-center -space-x-1",children:[d.map((c,u)=>jsxRuntime.jsx("img",{src:pt(c.url,c.faviconUrl),alt:"",className:chunkQDDCYCBV_cjs.q("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&&jsxRuntime.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]})]})]})});Te.displayName="SourcesTrigger";var je=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:m,renderEmpty:I,renderLoading:B},h)=>{let k=ze.useRef(null),[N,S]=ze.useState(false);ze.useEffect(()=>{if(!r||t==="inline")return;let v=P=>{P.key==="Escape"&&n?.(false);};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[r,n,t]),ze.useEffect(()=>{S(true);},[]);let M=ze.useMemo(()=>{if(!x)return null;let v={};for(let P of e){let E=P.domain||X(P.url);v[E]||(v[E]=[]),v[E].push(P);}return v},[e,x]),T=ze.useCallback(()=>{n?.(false);},[n]),W=ze.useCallback(v=>{v.target===v.currentTarget&&T();},[T]),A=()=>{let{title:v="Sources",showCloseButton:P=true,showCount:E=true,renderHeader:H}=a;return H?H({title:v,count:e.length,onClose:T}):jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:[P&&t!=="inline"&&jsxRuntime.jsx("button",{type:"button",onClick:T,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:jsxRuntime.jsx(ur,{})}),jsxRuntime.jsxs("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100 flex-1 text-center",children:[v,E&&jsxRuntime.jsxs("span",{className:"ml-2 text-sm font-normal text-gray-500 dark:text-gray-400",children:["(",e.length,")"]})]}),P&&t!=="inline"&&jsxRuntime.jsx("div",{className:"w-8"})]})},C=()=>o?B?B():jsxRuntime.jsxs("div",{className:"flex items-center justify-center py-8 text-gray-500 dark:text-gray-400",children:[jsxRuntime.jsx(pr,{}),jsxRuntime.jsx("span",{className:"ml-2 text-sm",children:"Loading sources..."})]}):e.length===0?I?I():jsxRuntime.jsx("div",{className:"flex items-center justify-center py-8 text-gray-500 dark:text-gray-400 text-sm",children:i}):x&&M?jsxRuntime.jsx("div",{className:c,children:Object.entries(M).map(([v,P])=>jsxRuntime.jsxs("div",{children:[jsxRuntime.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:Be(P[0].url,v)}),P.map((E,H)=>m?m(E,H):jsxRuntime.jsx(ye,{...E,onClick:u,showVerificationIndicator:l,showCitationBadges:g},E.id))]},v))}):jsxRuntime.jsx("div",{className:c,children:e.map((v,P)=>m?m(v,P):jsxRuntime.jsx(ye,{...v,onClick:u,showVerificationIndicator:l,showCitationBadges:g},v.id))}),U=d?{maxHeight:typeof d=="number"?`${d}px`:d}:void 0;if(t==="inline")return r?jsxRuntime.jsxs("div",{ref:h,className:chunkQDDCYCBV_cjs.q("bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700",s),style:U,children:[A(),jsxRuntime.jsx("div",{className:"overflow-y-auto",style:U,children:C()})]}):null;if(t==="panel")return r?jsxRuntime.jsxs("div",{ref:h,className:chunkQDDCYCBV_cjs.q("bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700 shadow-lg",s),children:[A(),jsxRuntime.jsx("div",{className:"overflow-y-auto",style:U||{maxHeight:"400px"},children:C()})]}):null;if(!N||!r)return null;let O=jsxRuntime.jsxs("div",{ref:h,className:chunkQDDCYCBV_cjs.q("fixed inset-0 z-50",t==="modal"&&"flex items-center justify-center"),role:"dialog","aria-modal":"true","aria-labelledby":"sources-title",children:[jsxRuntime.jsx("div",{className:chunkQDDCYCBV_cjs.q("absolute inset-0 bg-black/40 dark:bg-black/60 transition-opacity",r?"opacity-100":"opacity-0"),onClick:W,"aria-hidden":"true"}),t==="drawer"?jsxRuntime.jsxs("div",{ref:k,className:chunkQDDCYCBV_cjs.q("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:[jsxRuntime.jsx("div",{className:"flex justify-center py-2",children:jsxRuntime.jsx("div",{className:"w-10 h-1 bg-gray-300 dark:bg-gray-600 rounded-full"})}),A(),jsxRuntime.jsx("div",{className:"overflow-y-auto flex-1",children:C()})]}):jsxRuntime.jsxs("div",{ref:k,className:chunkQDDCYCBV_cjs.q("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(),jsxRuntime.jsx("div",{className:"overflow-y-auto flex-1",children:C()})]})]});return reactDom.createPortal(O,document.body)});je.displayName="SourcesListComponent";var gr=ze.memo(ye),fr=ze.memo(Te),xr=ze.memo(je);function hr(e){let t=new Map;for(let r of e){if(!r.url)continue;let n=r.domain||X(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||Re(r.url),faviconUrl:r.faviconUrl,citationNumbers:r.citationNumber?[r.citationNumber]:[]});}return Array.from(t.values())}function yr(e=[]){let[t,r]=ze.useState(e),[n,a]=ze.useState(false),o=ze.useCallback(s=>{r(c=>c.some(l=>l.url===s.url)?c:[...c,s]);},[]),i=ze.useCallback(s=>{r(c=>c.filter(u=>u.id!==s));},[]),d=ze.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 ft(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||Ue(a.url)||"Unknown Source",sourceDomain:a.domain||Ue(a.url),sourceFavicon:a.faviconUrl||void 0,citations:n,additionalCount:n.length-1}})}function Ue(e){if(e)try{return new URL(e).hostname.replace(/^www\./,"")}catch{return}}function br(e){let t=e?.status;return !t||t==="pending"||t==="loading"?{color:"text-gray-400",icon:jsxRuntime.jsx(se,{}),label:"Verifying"}:t==="not_found"?{color:"text-amber-500",icon:jsxRuntime.jsx(ie,{}),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:jsxRuntime.jsx(re,{}),label:"Partial match"}:{color:"text-green-500",icon:jsxRuntime.jsx(re,{}),label:"Verified"}}function We({item:e,isLast:t=false,onClick:r,onReadMore:n,className:a}){let{citation:o,verification:i}=e,d=br(i),s=o.siteName||o.domain||Ue(o.url)||"Source",c=o.title||o.keySpan||o.fullPhrase,u=o.description||i?.actualContentSnippet||i?.verifiedMatchSnippet,l=o.faviconUrl,g=ze.useCallback(()=>{r?.(e);},[e,r]),x=ze.useCallback(m=>{m.stopPropagation(),n?.(e);},[e,n]);return jsxRuntime.jsx("div",{className:chunkQDDCYCBV_cjs.i("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:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),g());},children:jsxRuntime.jsxs("div",{className:"flex items-start gap-3",children:[jsxRuntime.jsx("div",{className:"flex-shrink-0 mt-0.5",children:l?jsxRuntime.jsx("img",{src:l,alt:"",className:"w-5 h-5 rounded object-contain",loading:"lazy",onError:m=>{m.target.style.display="none";}}):jsxRuntime.jsx("div",{className:"w-5 h-5 rounded bg-gray-200 dark:bg-gray-700 flex items-center justify-center",children:jsxRuntime.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.charAt(0).toUpperCase()})})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:s}),jsxRuntime.jsx("span",{className:chunkQDDCYCBV_cjs.i("inline-flex w-3 h-3",d.color,i?.status==="pending"||i?.status==="loading"?"animate-spin":""),title:d.label,children:d.icon})]}),c&&jsxRuntime.jsx("h4",{className:"mt-1 text-sm font-medium text-gray-900 dark:text-gray-100 line-clamp-2",children:c}),u&&jsxRuntime.jsxs("p",{className:"mt-1 text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:[u,n&&u.length>100&&jsxRuntime.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 kr({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]=ze.useState(false),x=ze.useMemo(()=>r.flatMap(h=>h.citations),[r]),m=ze.useMemo(()=>!a||l?x:x.slice(0,o),[x,a,l,o]),I=ze.useMemo(()=>!a||l?[]:x.slice(o),[x,a,l,o]);if(ze__namespace.default.useEffect(()=>{if(!e)return;let h=k=>{k.key==="Escape"&&t();};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[e,t]),!e)return null;let B=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"fixed inset-0 bg-black/40 z-[9998] animate-in fade-in-0 duration-150",onClick:t,"aria-hidden":"true"}),jsxRuntime.jsxs("div",{className:chunkQDDCYCBV_cjs.i("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"&&jsxRuntime.jsx("div",{className:"flex justify-center pt-3 pb-1",children:jsxRuntime.jsx("div",{className:"w-10 h-1 rounded-full bg-gray-300 dark:bg-gray-600"})}),jsxRuntime.jsxs("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[jsxRuntime.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:n}),jsxRuntime.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:jsxRuntime.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:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),jsxRuntime.jsx("div",{className:"overflow-y-auto max-h-[calc(80vh-100px)]",children:m.length===0?jsxRuntime.jsx("div",{className:"px-4 py-8 text-center text-gray-500 dark:text-gray-400",children:"No citations to display"}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[m.map((h,k)=>u?jsxRuntime.jsx(ze__namespace.default.Fragment,{children:u(h)},h.citationKey):jsxRuntime.jsx(We,{item:h,isLast:k===m.length-1&&I.length===0,onClick:i,onReadMore:d},h.citationKey)),I.length>0&&!l&&jsxRuntime.jsx("div",{className:"px-4 py-3 border-t border-gray-200 dark:border-gray-700",children:jsxRuntime.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 (",I.length,")"]})}),l&&I.map((h,k)=>u?jsxRuntime.jsx(ze__namespace.default.Fragment,{children:u(h)},h.citationKey):jsxRuntime.jsx(We,{item:h,isLast:k===I.length-1,onClick:i,onReadMore:d},h.citationKey))]})})]})]});return reactDom.createPortal(B,document.body)}function Cr(){let[e,t]=ze.useState(false),[r,n]=ze.useState([]),a=ze.useCallback(()=>t(true),[]),o=ze.useCallback(()=>t(false),[]),i=ze.useCallback(()=>t(g=>!g),[]),d=ze.useCallback(g=>{n(x=>x.some(m=>m.citationKey===g.citationKey)?x:[...x,g]);},[]),s=ze.useCallback(g=>{n(x=>x.filter(m=>m.citationKey!==g));},[]),c=ze.useCallback(()=>{n([]);},[]),u=ze.useCallback(g=>{n(g);},[]),l=ze.useMemo(()=>ft(r),[r]);return {isOpen:e,openDrawer:a,closeDrawer:o,toggleDrawer:i,citations:r,citationGroups:l,addCitation:d,removeCitation:s,clearCitations:c,setCitations:u}}
|
|
5
|
+
Object.defineProperty(exports,"CITATION_X_PADDING",{enumerable:true,get:function(){return chunkQDDCYCBV_cjs.r}});Object.defineProperty(exports,"CITATION_Y_PADDING",{enumerable:true,get:function(){return chunkQDDCYCBV_cjs.s}});Object.defineProperty(exports,"classNames",{enumerable:true,get:function(){return chunkQDDCYCBV_cjs.q}});Object.defineProperty(exports,"generateCitationInstanceId",{enumerable:true,get:function(){return chunkQDDCYCBV_cjs.m}});Object.defineProperty(exports,"generateCitationKey",{enumerable:true,get:function(){return chunkQDDCYCBV_cjs.k}});Object.defineProperty(exports,"getCitationDisplayText",{enumerable:true,get:function(){return chunkQDDCYCBV_cjs.n}});Object.defineProperty(exports,"getCitationKeySpanText",{enumerable:true,get:function(){return chunkQDDCYCBV_cjs.p}});Object.defineProperty(exports,"getCitationNumber",{enumerable:true,get:function(){return chunkQDDCYCBV_cjs.o}});Object.defineProperty(exports,"isUrlCitation",{enumerable:true,get:function(){return chunkQDDCYCBV_cjs.j}});exports.CheckIcon=re;exports.CitationComponent=Me;exports.CitationDrawer=kr;exports.CitationDrawerItemComponent=We;exports.CloseIcon=Wt;exports.DeepCitationIcon=zt;exports.ExternalLinkIcon=Ut;exports.LinkIcon=Vt;exports.MemoizedCitationComponent=lr;exports.MemoizedSourcesListComponent=xr;exports.MemoizedSourcesListItem=gr;exports.MemoizedSourcesTrigger=fr;exports.SourcesListComponent=je;exports.SourcesListItem=ye;exports.SourcesTrigger=Te;exports.SpinnerIcon=se;exports.WarningIcon=ie;exports.detectSourceType=Re;exports.extractDomain=X;exports.getPlatformName=Be;exports.groupCitationsBySource=ft;exports.isAccessibleStatus=Rt;exports.isBlockedStatus=Xe;exports.isErrorStatus=Ye;exports.isRedirectedStatus=Bt;exports.isVerifiedStatus=Tt;exports.sourceCitationsToListItems=hr;exports.useCitationDrawer=Cr;exports.useSourcesList=yr;
|
package/lib/react/index.d.cts
CHANGED
|
@@ -13,8 +13,9 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
13
13
|
* | `text` | Plain text, inherits parent styling |
|
|
14
14
|
* | `superscript` | Small raised text like footnotes¹ |
|
|
15
15
|
* | `minimal` | Compact text with indicator, truncated |
|
|
16
|
+
* | `source` | Source chip showing name + count (ChatGPT-style) |
|
|
16
17
|
*/
|
|
17
|
-
type CitationVariant = "chip" | "brackets" | "text" | "superscript" | "minimal";
|
|
18
|
+
type CitationVariant = "chip" | "brackets" | "text" | "superscript" | "minimal" | "source";
|
|
18
19
|
/**
|
|
19
20
|
* Content to display in the citation.
|
|
20
21
|
*
|
|
@@ -23,6 +24,7 @@ type CitationVariant = "chip" | "brackets" | "text" | "superscript" | "minimal";
|
|
|
23
24
|
* | `keySpan` | Descriptive text (e.g., "Revenue Growth") |
|
|
24
25
|
* | `number` | Citation number (e.g., "1", "2", "3") |
|
|
25
26
|
* | `indicator` | Only the status icon (✓/⚠), no text |
|
|
27
|
+
* | `source` | Source name with count (e.g., "Wikipedia +2") |
|
|
26
28
|
*
|
|
27
29
|
* Default content per variant:
|
|
28
30
|
* - `chip` → `keySpan`
|
|
@@ -30,8 +32,9 @@ type CitationVariant = "chip" | "brackets" | "text" | "superscript" | "minimal";
|
|
|
30
32
|
* - `text` → `keySpan`
|
|
31
33
|
* - `superscript` → `number`
|
|
32
34
|
* - `minimal` → `number`
|
|
35
|
+
* - `source` → `source`
|
|
33
36
|
*/
|
|
34
|
-
type CitationContent = "keySpan" | "number" | "indicator";
|
|
37
|
+
type CitationContent = "keySpan" | "number" | "indicator" | "source";
|
|
35
38
|
/**
|
|
36
39
|
* URL fetch/access status for URL citations.
|
|
37
40
|
* Covers HTTP accessibility and redirect scenarios.
|
|
@@ -473,6 +476,94 @@ interface SourcesTriggerProps {
|
|
|
473
476
|
/** Whether the sources list is currently open */
|
|
474
477
|
isOpen?: boolean;
|
|
475
478
|
}
|
|
479
|
+
/**
|
|
480
|
+
* A single citation item with its verification result for the drawer.
|
|
481
|
+
*/
|
|
482
|
+
interface CitationDrawerItem {
|
|
483
|
+
/** Unique key for this citation */
|
|
484
|
+
citationKey: string;
|
|
485
|
+
/** The citation data */
|
|
486
|
+
citation: Citation;
|
|
487
|
+
/** Verification result if available */
|
|
488
|
+
verification: Verification | null;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Group of citations from the same source (for "+N" display).
|
|
492
|
+
* Used when multiple citations reference the same source domain.
|
|
493
|
+
*/
|
|
494
|
+
interface SourceCitationGroup {
|
|
495
|
+
/** Primary source name to display (e.g., "Delaware Corporations") */
|
|
496
|
+
sourceName: string;
|
|
497
|
+
/** Source domain (e.g., "delaware.gov") */
|
|
498
|
+
sourceDomain?: string;
|
|
499
|
+
/** Favicon URL for the source */
|
|
500
|
+
sourceFavicon?: string;
|
|
501
|
+
/** All citations in this group */
|
|
502
|
+
citations: CitationDrawerItem[];
|
|
503
|
+
/** Count of additional citations beyond the first */
|
|
504
|
+
additionalCount: number;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Props for the source chip variant (ChatGPT-style inline citation).
|
|
508
|
+
*/
|
|
509
|
+
interface SourceChipProps {
|
|
510
|
+
/** Primary citation to display */
|
|
511
|
+
citation: Citation;
|
|
512
|
+
/** Verification result */
|
|
513
|
+
verification?: Verification | null;
|
|
514
|
+
/** Additional citations grouped with this one */
|
|
515
|
+
additionalCitations?: CitationDrawerItem[];
|
|
516
|
+
/** Callback when chip is clicked (typically opens drawer) */
|
|
517
|
+
onClick?: (group: SourceCitationGroup, event: React.MouseEvent) => void;
|
|
518
|
+
/** Additional class name */
|
|
519
|
+
className?: string;
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Props for the CitationDrawer component.
|
|
523
|
+
*/
|
|
524
|
+
interface CitationDrawerProps {
|
|
525
|
+
/** Whether the drawer is open */
|
|
526
|
+
isOpen: boolean;
|
|
527
|
+
/** Callback to close the drawer */
|
|
528
|
+
onClose: () => void;
|
|
529
|
+
/** Citation groups to display */
|
|
530
|
+
citationGroups: SourceCitationGroup[];
|
|
531
|
+
/** Title for the drawer header */
|
|
532
|
+
title?: string;
|
|
533
|
+
/** Whether to show "More" section for additional sources */
|
|
534
|
+
showMoreSection?: boolean;
|
|
535
|
+
/** Maximum items to show before "More" section */
|
|
536
|
+
maxVisibleItems?: number;
|
|
537
|
+
/** Callback when a citation item is clicked */
|
|
538
|
+
onCitationClick?: (item: CitationDrawerItem) => void;
|
|
539
|
+
/** Callback when "Read more" is clicked for a citation */
|
|
540
|
+
onReadMore?: (item: CitationDrawerItem) => void;
|
|
541
|
+
/** Additional class name for the drawer container */
|
|
542
|
+
className?: string;
|
|
543
|
+
/** Render position: 'bottom' for mobile sheet, 'right' for side panel */
|
|
544
|
+
position?: "bottom" | "right";
|
|
545
|
+
/** Custom render for citation items */
|
|
546
|
+
renderCitationItem?: (item: CitationDrawerItem) => React.ReactNode;
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Props for the CitationDrawerItem component.
|
|
550
|
+
*/
|
|
551
|
+
interface CitationDrawerItemProps {
|
|
552
|
+
/** The citation item to display */
|
|
553
|
+
item: CitationDrawerItem;
|
|
554
|
+
/** Whether this is the last item (no bottom border) */
|
|
555
|
+
isLast?: boolean;
|
|
556
|
+
/** Callback when item is clicked */
|
|
557
|
+
onClick?: (item: CitationDrawerItem) => void;
|
|
558
|
+
/** Callback when "Read more" is clicked */
|
|
559
|
+
onReadMore?: (item: CitationDrawerItem) => void;
|
|
560
|
+
/** Additional class name */
|
|
561
|
+
className?: string;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Helper function type for grouping citations by source.
|
|
565
|
+
*/
|
|
566
|
+
type GroupCitationsBySource = (citations: CitationDrawerItem[]) => SourceCitationGroup[];
|
|
476
567
|
|
|
477
568
|
/**
|
|
478
569
|
* Extracts domain from URL for compact display.
|
|
@@ -551,6 +642,7 @@ interface CitationComponentProps extends BaseCitationProps {
|
|
|
551
642
|
* - `text`: Plain text, inherits parent styling
|
|
552
643
|
* - `superscript`: Small raised text like footnotes¹
|
|
553
644
|
* - `minimal`: Compact text with indicator, truncated
|
|
645
|
+
* - `source`: ChatGPT-style source chip with name + count
|
|
554
646
|
*/
|
|
555
647
|
variant?: CitationVariant;
|
|
556
648
|
/**
|
|
@@ -558,6 +650,7 @@ interface CitationComponentProps extends BaseCitationProps {
|
|
|
558
650
|
* - `keySpan`: Descriptive text (e.g., "Revenue Growth")
|
|
559
651
|
* - `number`: Citation number (e.g., "1", "2", "3")
|
|
560
652
|
* - `indicator`: Only the status icon, no text
|
|
653
|
+
* - `source`: Source name (e.g., "Wikipedia")
|
|
561
654
|
*
|
|
562
655
|
* Defaults based on variant:
|
|
563
656
|
* - `chip` → `keySpan`
|
|
@@ -565,6 +658,7 @@ interface CitationComponentProps extends BaseCitationProps {
|
|
|
565
658
|
* - `text` → `keySpan`
|
|
566
659
|
* - `superscript` → `number`
|
|
567
660
|
* - `minimal` → `number`
|
|
661
|
+
* - `source` → `source`
|
|
568
662
|
*/
|
|
569
663
|
content?: CitationContent;
|
|
570
664
|
/** Event handlers for citation interactions */
|
|
@@ -588,6 +682,16 @@ interface CitationComponentProps extends BaseCitationProps {
|
|
|
588
682
|
verification: Verification | null;
|
|
589
683
|
status: CitationStatus;
|
|
590
684
|
}) => React$1.ReactNode;
|
|
685
|
+
/**
|
|
686
|
+
* Number of additional citations grouped with this one (for source variant).
|
|
687
|
+
* Shows as "+N" suffix (e.g., "Wikipedia +2")
|
|
688
|
+
*/
|
|
689
|
+
additionalCount?: number;
|
|
690
|
+
/**
|
|
691
|
+
* Favicon URL to display (for source variant).
|
|
692
|
+
* Falls back to citation.faviconUrl if not provided.
|
|
693
|
+
*/
|
|
694
|
+
faviconUrl?: string;
|
|
591
695
|
}
|
|
592
696
|
/**
|
|
593
697
|
* CitationComponent displays a citation with verification status.
|
|
@@ -733,4 +837,76 @@ declare function useSourcesList(initialSources?: SourcesListItemProps[]): {
|
|
|
733
837
|
toggle: () => void;
|
|
734
838
|
};
|
|
735
839
|
|
|
736
|
-
|
|
840
|
+
/**
|
|
841
|
+
* Groups citations by their source domain/name.
|
|
842
|
+
* Returns an array of SourceCitationGroup objects.
|
|
843
|
+
*/
|
|
844
|
+
declare function groupCitationsBySource(citations: CitationDrawerItem[]): SourceCitationGroup[];
|
|
845
|
+
/**
|
|
846
|
+
* Individual citation item displayed in the drawer.
|
|
847
|
+
* Shows favicon, source name, article title, and snippet.
|
|
848
|
+
*/
|
|
849
|
+
declare function CitationDrawerItemComponent({ item, isLast, onClick, onReadMore, className, }: CitationDrawerItemProps): react_jsx_runtime.JSX.Element;
|
|
850
|
+
/**
|
|
851
|
+
* CitationDrawer displays a collection of citations in a drawer/bottom sheet.
|
|
852
|
+
* Similar to ChatGPT's citation drawer UI.
|
|
853
|
+
*
|
|
854
|
+
* @example Basic usage
|
|
855
|
+
* ```tsx
|
|
856
|
+
* const [isOpen, setIsOpen] = useState(false);
|
|
857
|
+
* const citationGroups = groupCitationsBySource(citations);
|
|
858
|
+
*
|
|
859
|
+
* <CitationDrawer
|
|
860
|
+
* isOpen={isOpen}
|
|
861
|
+
* onClose={() => setIsOpen(false)}
|
|
862
|
+
* citationGroups={citationGroups}
|
|
863
|
+
* />
|
|
864
|
+
* ```
|
|
865
|
+
*
|
|
866
|
+
* @example With click handlers
|
|
867
|
+
* ```tsx
|
|
868
|
+
* <CitationDrawer
|
|
869
|
+
* isOpen={isOpen}
|
|
870
|
+
* onClose={() => setIsOpen(false)}
|
|
871
|
+
* citationGroups={citationGroups}
|
|
872
|
+
* onCitationClick={(item) => window.open(item.citation.sourceUrl, '_blank')}
|
|
873
|
+
* onReadMore={(item) => console.log('Read more:', item)}
|
|
874
|
+
* />
|
|
875
|
+
* ```
|
|
876
|
+
*/
|
|
877
|
+
declare function CitationDrawer({ isOpen, onClose, citationGroups, title, showMoreSection, maxVisibleItems, onCitationClick, onReadMore, className, position, renderCitationItem, }: CitationDrawerProps): React$1.ReactPortal | null;
|
|
878
|
+
/**
|
|
879
|
+
* Hook for managing citation drawer state.
|
|
880
|
+
*
|
|
881
|
+
* @example
|
|
882
|
+
* ```tsx
|
|
883
|
+
* const { isOpen, openDrawer, closeDrawer, citationGroups, addCitation } = useCitationDrawer();
|
|
884
|
+
*
|
|
885
|
+
* // Add citations
|
|
886
|
+
* addCitation({ citationKey: "1", citation, verification });
|
|
887
|
+
*
|
|
888
|
+
* // Open drawer
|
|
889
|
+
* <button onClick={openDrawer}>View Citations</button>
|
|
890
|
+
*
|
|
891
|
+
* // Render drawer
|
|
892
|
+
* <CitationDrawer
|
|
893
|
+
* isOpen={isOpen}
|
|
894
|
+
* onClose={closeDrawer}
|
|
895
|
+
* citationGroups={citationGroups}
|
|
896
|
+
* />
|
|
897
|
+
* ```
|
|
898
|
+
*/
|
|
899
|
+
declare function useCitationDrawer(): {
|
|
900
|
+
isOpen: boolean;
|
|
901
|
+
openDrawer: () => void;
|
|
902
|
+
closeDrawer: () => void;
|
|
903
|
+
toggleDrawer: () => void;
|
|
904
|
+
citations: CitationDrawerItem[];
|
|
905
|
+
citationGroups: SourceCitationGroup[];
|
|
906
|
+
addCitation: (item: CitationDrawerItem) => void;
|
|
907
|
+
removeCitation: (citationKey: string) => void;
|
|
908
|
+
clearCitations: () => void;
|
|
909
|
+
setCitations: (items: CitationDrawerItem[]) => void;
|
|
910
|
+
};
|
|
911
|
+
|
|
912
|
+
export { CheckIcon, type CitationBehaviorActions, type CitationBehaviorConfig, type CitationBehaviorContext, type CitationClickBehavior, CitationComponent, type CitationComponentProps, type CitationContent, type CitationContentProps, type CitationCursorClasses, CitationDrawer, type CitationDrawerItem, CitationDrawerItemComponent, type CitationDrawerItemProps, type CitationDrawerProps, type CitationEventHandlers, type CitationHoverBehavior, type CitationRenderProps, type CitationStateClasses, type CitationStyles, type CitationTooltipProps, type CitationVariant, type CitationVariant as CitationVariantType, CloseIcon, type ContentMatchStatus, DeepCitationIcon, ExternalLinkIcon, type GroupCitationsBySource, LinkIcon, MemoizedCitationComponent, MemoizedSourcesListComponent, MemoizedSourcesListItem, MemoizedSourcesTrigger, type SourceChipProps, type SourceCitationGroup, SourcesListComponent, type SourcesListHeaderConfig, SourcesListItem, type SourcesListItemProps, type SourcesListProps, type SourcesListVariant, SourcesTrigger, type SourcesTriggerProps, SpinnerIcon, type UrlCitationMeta, type UrlCitationProps, type UrlCitationVariant, type UrlFetchStatus, type UrlVerificationMeta, WarningIcon, detectSourceType, extractDomain, getPlatformName, groupCitationsBySource, isAccessibleStatus, isBlockedStatus, isErrorStatus, isRedirectedStatus, isVerifiedStatus, sourceCitationsToListItems, useCitationDrawer, useSourcesList };
|