@deepcitation/deepcitation-js 1.1.26 → 1.1.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +253 -253
  3. package/lib/chunk-2IZXUOQR.js +66 -0
  4. package/lib/chunk-4FGOHQFP.cjs +66 -0
  5. package/lib/chunk-CFXDRAJL.cjs +1 -0
  6. package/lib/chunk-DEUSSEFH.js +2 -0
  7. package/lib/chunk-F2MMVEVC.cjs +1 -0
  8. package/lib/chunk-J7U6YFOI.cjs +2 -0
  9. package/lib/chunk-O2XFH626.js +1 -0
  10. package/lib/chunk-RQPZSRID.js +1 -0
  11. package/lib/client/index.cjs +1 -0
  12. package/lib/client/{DeepCitation.d.ts → index.d.cts} +159 -3
  13. package/lib/client/index.d.ts +342 -2
  14. package/lib/client/index.js +1 -1
  15. package/lib/index.cjs +1 -0
  16. package/lib/index.d.cts +127 -0
  17. package/lib/index.d.ts +126 -23
  18. package/lib/index.js +1 -22
  19. package/lib/prompts/index.cjs +1 -0
  20. package/lib/prompts/index.d.cts +196 -0
  21. package/lib/prompts/index.d.ts +196 -3
  22. package/lib/prompts/index.js +1 -3
  23. package/lib/react/index.cjs +4 -0
  24. package/lib/react/index.js +4 -18
  25. package/lib/types/index.cjs +1 -0
  26. package/lib/types/index.d.cts +96 -0
  27. package/lib/types/index.d.ts +96 -11
  28. package/lib/types/index.js +1 -7
  29. package/package.json +62 -10
  30. package/lib/client/DeepCitation.js +0 -374
  31. package/lib/client/types.d.ts +0 -154
  32. package/lib/client/types.js +0 -1
  33. package/lib/parsing/normalizeCitation.d.ts +0 -5
  34. package/lib/parsing/normalizeCitation.js +0 -198
  35. package/lib/parsing/parseCitation.d.ts +0 -79
  36. package/lib/parsing/parseCitation.js +0 -431
  37. package/lib/parsing/parseWorkAround.d.ts +0 -2
  38. package/lib/parsing/parseWorkAround.js +0 -73
  39. package/lib/prompts/citationPrompts.d.ts +0 -138
  40. package/lib/prompts/citationPrompts.js +0 -168
  41. package/lib/prompts/promptCompression.d.ts +0 -14
  42. package/lib/prompts/promptCompression.js +0 -127
  43. package/lib/prompts/types.d.ts +0 -4
  44. package/lib/prompts/types.js +0 -1
  45. package/lib/react/CitationComponent.d.ts +0 -93
  46. package/lib/react/CitationComponent.js +0 -371
  47. package/lib/react/CitationVariants.d.ts +0 -132
  48. package/lib/react/CitationVariants.js +0 -284
  49. package/lib/react/DiffDisplay.d.ts +0 -10
  50. package/lib/react/DiffDisplay.js +0 -33
  51. package/lib/react/Popover.d.ts +0 -15
  52. package/lib/react/Popover.js +0 -20
  53. package/lib/react/UrlCitationComponent.d.ts +0 -83
  54. package/lib/react/UrlCitationComponent.js +0 -224
  55. package/lib/react/VerificationTabs.d.ts +0 -10
  56. package/lib/react/VerificationTabs.js +0 -36
  57. package/lib/react/icons.d.ts +0 -18
  58. package/lib/react/icons.js +0 -16
  59. package/lib/react/index.d.ts +0 -16
  60. package/lib/react/primitives.d.ts +0 -101
  61. package/lib/react/primitives.js +0 -193
  62. package/lib/react/types.d.ts +0 -283
  63. package/lib/react/types.js +0 -1
  64. package/lib/react/useSmartDiff.d.ts +0 -16
  65. package/lib/react/useSmartDiff.js +0 -64
  66. package/lib/react/utils.d.ts +0 -43
  67. package/lib/react/utils.js +0 -89
  68. package/lib/types/boxes.d.ts +0 -11
  69. package/lib/types/boxes.js +0 -1
  70. package/lib/types/citation.d.ts +0 -39
  71. package/lib/types/citation.js +0 -1
  72. package/lib/types/search.d.ts +0 -19
  73. package/lib/types/search.js +0 -1
  74. package/lib/types/verification.d.ts +0 -27
  75. package/lib/types/verification.js +0 -11
  76. package/lib/utils/diff.d.ts +0 -60
  77. package/lib/utils/diff.js +0 -414
  78. package/lib/utils/sha.d.ts +0 -10
  79. package/lib/utils/sha.js +0 -108
@@ -0,0 +1,66 @@
1
+ 'use strict';var y=`
2
+ <citation-instructions priority="critical">
3
+ ## REQUIRED: Citation Format
4
+
5
+ You MUST cite sources using this exact syntax:
6
+
7
+ <cite attachment_id='ID' reasoning='why this supports the claim' key_span='1-3 key words' full_phrase='verbatim quote' start_page_key='page_number_N_index_I' line_ids='X-Y' />
8
+
9
+ ### Syntax Rules (MUST follow)
10
+
11
+ 1. **attachment_id**: Use the exact ID from the source document
12
+ 2. **reasoning**: Brief explanation of why this citation supports your claim (think first!)
13
+ 3. **key_span**: The 1-3 most important words from full_phrase
14
+ 4. **full_phrase**: Copy text VERBATIM from source. Escape quotes (\\') and newlines (\\n).
15
+ 5. **start_page_key**: ONLY use format \`page_number_N_index_I\` from page tags (e.g., \`<page_number_1_index_0>\`). Never extract page numbers from document content.
16
+ 6. **line_ids**: Inclusive range (e.g., '2-6' or '4'). Infer intermediate lines since only every 5th line is shown.
17
+
18
+ ### Placement Rules
19
+
20
+ - Place <cite /> inline, typically at the end of a claim
21
+ - One citation per distinct idea, concept, or value (a sentence citing 3 different values needs 3 citations)
22
+ - Do NOT group citations at the end of the document
23
+ - The <cite /> tag is self-closing - never use <cite>...</cite>
24
+
25
+ ### Example
26
+
27
+ The company reported strong growth<cite attachment_id='abc123' reasoning='directly states revenue growth percentage' key_span='increased 45%' full_phrase='Revenue increased 45% year-over-year to $2.3 billion' start_page_key='page_number_2_index_1' line_ids='12-14' />
28
+
29
+ </citation-instructions>
30
+ `,T=`
31
+ <citation-instructions priority="critical">
32
+ ## REQUIRED: Audio/Video Citation Format
33
+
34
+ You MUST cite sources using this exact syntax:
35
+
36
+ <cite attachment_id='ID' reasoning='why this supports the claim' key_span='1-3 key words' full_phrase='verbatim transcript quote' timestamps='HH:MM:SS.SSS-HH:MM:SS.SSS' />
37
+
38
+ ### Syntax Rules (MUST follow)
39
+
40
+ 1. **attachment_id**: Use the exact ID from the source
41
+ 2. **reasoning**: Brief explanation of why this citation supports your claim (think first!)
42
+ 3. **key_span**: The 1-3 most important words from full_phrase
43
+ 4. **full_phrase**: Copy transcript text VERBATIM. Escape quotes (\\') and newlines (\\n).
44
+ 5. **timestamps**: Start and end time with milliseconds (e.g., '00:01:23.456-00:01:45.789')
45
+
46
+ ### Placement Rules
47
+
48
+ - Place <cite /> inline, typically at the end of a claim
49
+ - One citation per distinct idea, concept, or value (a sentence citing 3 different values needs 3 citations)
50
+ - Do NOT group citations at the end of the document
51
+ - The <cite /> tag is self-closing - never use <cite>...</cite>
52
+
53
+ </citation-instructions>
54
+ `,u="<citation-reminder>Remember: You MUST use <cite /> tags with all required attributes for every claim from source documents.</citation-reminder>",f="<citation-reminder>Remember: You MUST use <cite /> tags with timestamps for every claim from source media.</citation-reminder>";function x(i){let{systemPrompt:r,isAudioVideo:s=false}=i,e=s?T:y,t=s?f:u;return `${e.trim()}
55
+
56
+ ${r.trim()}
57
+
58
+ ${t}`}function S(i){let{systemPrompt:r,userPrompt:s,deepTextPromptPortion:e,isAudioVideo:t=false,addUserReminder:o=false}=i,c=x({systemPrompt:r,isAudioVideo:t}),n=s;if(e){let a=Array.isArray(e)?e:[e];n=`${a.map((l,m)=>a.length===1?`
59
+ ${l}`:`
60
+ ${l}`).join(`
61
+
62
+ `)}
63
+
64
+ ${s}`;}return o&&(n=`${n}
65
+
66
+ ${t?f:u}`),{enhancedSystemPrompt:c,enhancedUserPrompt:n}}var O={type:"object",properties:{attachmentId:{type:"string"},reasoning:{type:"string",description:"The logic connecting the form section requirements to the supporting source citation (think first!)"},keySpan:{type:"string",description:"The verbatim 1-3 words within fullPhrase that best support the citation"},fullPhrase:{type:"string",description:"The verbatim text of the terse phrase inside <attachment_text /> to support the citation (if there is a detected OCR correction, use the corrected text)"},startPageKey:{type:"string",description:'Only return a result like "page_number_PAGE_index_INDEX" from the provided page keys (e.g. <page_number_1_index_0>) and never from the contents inside the page.'},lineIds:{type:"array",items:{type:"number"},description:"Infer lineIds, as we only provide the first, last, and every 5th line. Provide inclusive lineIds for the fullPhrase."}},required:["attachmentId","reasoning","keySpan","fullPhrase","startPageKey","lineIds"]},A={type:"object",properties:{attachmentId:{type:"string"},startPageKey:{type:"string",description:'Only return a result like "page_number_PAGE_index_INDEX" from the provided page keys (e.g. <page_number_1_index_0>) and never from the contents inside the page.'},fullPhrase:{type:"string",description:"The exact verbatim text of the phrase or paragraph from the source document to support the citation (if there is a detected OCR correction, use the verbatim corrected text)"},timestamps:{type:"object",properties:{startTime:{type:"string"},endTime:{type:"string"}},required:["startTime","endTime"],description:"The timestamp of the audio or video frame including milliseconds formatted as: HH:MM:SS.SSS"}},required:["attachmentId","startPageKey","fullPhrase","timestamps"]};var d=4,I=3,P=5;function R(i,r){let s={};for(let e of i){for(let t=d;t<=e.length;t++){let o=e.slice(0,t),c=(o.match(/\d/g)||[]).length,n=(o.match(/[a-zA-Z]/g)||[]).length;if(o.length<d||c>0&&n<I||c===0&&n<P||i.some(m=>m!==e&&m.startsWith(o)))continue;let a=m=>m.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),p=(r.match(new RegExp(a(o),"g"))||[]).length,l=(r.match(new RegExp(a(e),"g"))||[]).length;if(p===l){s[o]=e;break}}if(!Object.values(s).includes(e))throw new Error(`Cannot find a safe unique prefix for ID "${e}" that meets the minimum requirements (length: ${d})`)}return s}function E(i,r){if(!r||r.length===0)return {compressed:i,prefixMap:{}};let s=Array.from(new Set(r)),e=JSON.stringify(i),t=R(s,e),o=Object.keys(t).sort((n,a)=>a.length-n.length),c=e;for(let n of o){let p=t[n].replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");c=c.replace(new RegExp(p,"g"),n);}return {compressed:JSON.parse(c),prefixMap:t}}function b(i,r){if(!r||Object.keys(r).length===0)return i;let s=Object.entries(r).sort((p,l)=>l[0].length-p[0].length),e,t=false;typeof i=="string"?e=i:(e=JSON.stringify(i),t=true);let o=e?.length;for(let[p,l]of s){let m=p.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");e=e.replace(new RegExp(m,"g"),l);}let c=["attachmentId","attachment_id","attachment_ID","attachmentID","fileId","file_id","file_ID","fileID","fileid"];for(let[p,l]of s){let m=p.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),g=c.join("|"),h="([\"'`])",_=new RegExp(`(${g})(\\s*=\\s*)${h}${m}\\3`,"g");e=e.replace(_,`$1$2$3${l}$3`);}let n=e?.length,a=o-n;if(a>0)throw new Error(`[decompressedPromptIds] diff ${a} originalLength ${o} newLength ${n}`);return t?JSON.parse(e):e}exports.a=y;exports.b=T;exports.c=u;exports.d=f;exports.e=x;exports.f=S;exports.g=O;exports.h=A;exports.i=E;exports.j=b;
@@ -0,0 +1 @@
1
+ 'use strict';var e="avif";var t=-1,n=-2,r={attachmentId:null,verifiedPageNumber:t,verifiedMatchSnippet:null,citation:{pageNumber:t},status:"not_found"};exports.a=e;exports.b=t;exports.c=n;exports.d=r;
@@ -0,0 +1,2 @@
1
+ import {a}from'./chunk-O2XFH626.js';var H=(t,e)=>{let n=/<cite\s+(?:fileId|attachmentId)='(\w{0,25})'\s+start_page[\_a-zA-Z]*='page[\_a-zA-Z]*(\d+)_index_(\d+)'\s+full_phrase='((?:[^'\\]|\\.)*)'\s+key_span='((?:[^'\\]|\\.)*)'\s+line(?:_ids|Ids)='([^']+)'(?:\s+(value|reasoning)='((?:[^'\\]|\\.)*)')?\s*\/>/g;return t.replace(n,(o,r,s,l,i,p,c,a)=>e&&p?.replace(/key_span=['"]|['"]/g,"")||"")},G=t=>t.replace(/<page_number_\d+_index_\d+>/g,"").replace(/<\/page_number_\d+_index_\d+>/g,"").trim(),X=t=>{let e=/<line id="[^"]*">|<\/line>/g;return t.replace(e,"")},U=t=>{if(!t)return null;let e=t.match(/\d+/)?.[0];return e?parseInt(e):null},K=t=>{let e=t?.trim()||"",n=e.split(/(<cite[\s\S]*?(?:\/>|<\/cite>))/gm);return n.length<=1?T(e):(e=n.map(o=>o.startsWith("<cite")?T(o):o).join(""),e)},T=t=>{let e=t;e=e.replace(/><\/cite>/g,"/>");let n=l=>{let i=l.toLowerCase();return i==="fullphrase"||i==="full_phrase"?"full_phrase":i==="lineids"||i==="line_ids"?"line_ids":i==="startpagekey"||i==="start_pagekey"||i==="start_page_key"?"start_page_key":i==="fileid"||i==="file_id"||i==="attachmentid"||i==="attachment_id"?"attachment_id":i==="keyspan"||i==="key_span"?"key_span":i==="reasoning"||i==="value"?i:i==="timestamps"||i==="timestamp"||i==="timestamps"?"timestamps":i},o=l=>l.replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),r=/(fullPhrase|full_phrase|keySpan|key_span|reasoning|value)\s*=\s*(['"])([\s\S]*?)(?=\s+(?:line_ids|lineIds|timestamps|fileId|file_id|attachmentId|attachment_id|start_page_key|start_pageKey|startPageKey|keySpan|key_span|reasoning|value|full_phrase)|\s*\/?>)/gm;e=e.replace(r,(l,i,p,c)=>{let a=c;return a.endsWith(p)&&(a=a.slice(0,-1)),a=a.replace(/(\r?\n)+/g," "),a=o(a),a=a.replace(/(\*|_){2,}/g,""),a=a.replace(/\\\\'/g,"'"),a=a.replace(/\\'/g,"'"),a=a.replace(/'/g,"\\'"),a=a.replace(/\\\\"/g,'"'),a=a.replace(/\\"/g,'"'),a=a.replace(/"/g,'\\"'),a=a.replace(/\*/g,""),`${n(i)}='${a}'`}),e=e.replace(/(line_ids|lineIds|timestamps)=['"]?([\[\]\(\){}A-Za-z0-9_\-, ]+)['"]?(\s*\/?>|\s+)/gm,(l,i,p,c)=>{let a=p.replace(/[A-Za-z\[\]\(\){}]/g,"");return a=a.replace(/(\d+)-(\d+)/g,(_,h,f)=>{let y=parseInt(h,10),I=parseInt(f,10),u=[];if(y<=I)for(let g=y;g<=I;g++)u.push(g);else u.push(y);return u.join(",")}),a=a.replace(/,+/g,",").replace(/^,|,$/g,""),`${n(i)}='${a}'${c}`});let s=l=>{let i=/([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(['"])((?:[^'"\\\n]|\\.)*)(?:\2)/g,p={},c;for(;c=i.exec(l);){let u=c[1],g=c[3],C=n(u);p[C]=g;}let a=Object.keys(p);if(a.length===0)return l;let _=typeof p.timestamps=="string"&&p.timestamps.length>0,h=a.filter(u=>u.startsWith("start_page")),f=[];p.attachment_id&&f.push("attachment_id"),_?(p.full_phrase&&f.push("full_phrase"),f.push("timestamps")):(h.includes("start_page_key")&&f.push("start_page_key"),h.filter(u=>u!=="start_page_key").sort().forEach(u=>f.push(u)),p.full_phrase&&f.push("full_phrase"),p.key_span&&f.push("key_span"),p.line_ids&&f.push("line_ids")),p.reasoning&&f.push("reasoning"),p.value&&f.push("value");let y=new Set(f);return a.filter(u=>!y.has(u)).sort().forEach(u=>f.push(u)),`<cite ${f.map(u=>`${u}='${p[u]}'`).join(" ")} />`};return e=e.replace(/<cite\b[\s\S]*?\/>/gm,l=>s(l)),e};function L(t){return new TextEncoder().encode(t)}function j(t){let e=1732584193,n=4023233417,o=2562383102,r=271733878,s=3285377520,l=t.length,i=l*8,p=l+1+8,c=Math.ceil(p/64)*64,a=new ArrayBuffer(c),_=new Uint8Array(a),h=new DataView(a);_.set(t),_[l]=128,h.setUint32(c-8,Math.floor(i/4294967296),false),h.setUint32(c-4,i>>>0,false);let f=new Uint32Array(80);for(let I=0;I<c;I+=64){for(let d=0;d<16;d++)f[d]=h.getUint32(I+d*4,false);for(let d=16;d<80;d++){let x=f[d-3]^f[d-8]^f[d-14]^f[d-16];f[d]=x<<1|x>>>31;}let u=e,g=n,C=o,b=r,w=s;for(let d=0;d<80;d++){let x,m;d<20?(x=g&C|~g&b,m=1518500249):d<40?(x=g^C^b,m=1859775393):d<60?(x=g&C|g&b|C&b,m=2400959708):(x=g^C^b,m=3395469782);let P=(u<<5|u>>>27)+x+w+m+f[d]>>>0;w=b,b=C,C=(g<<30|g>>>2)>>>0,g=u,u=P;}e=e+u>>>0,n=n+g>>>0,o=o+C>>>0,r=r+b>>>0,s=s+w>>>0;}let y=I=>I.toString(16).padStart(8,"0");return y(e)+y(n)+y(o)+y(r)+y(s)}function v(t){try{if(!t)return "";let e=typeof t=="string"?t:JSON.stringify(t);return j(L(e))}catch(e){console.error("Error in making the hash:",e);}return ""}function k(t){let e=t.pageNumber||U(t.startPageKey),n=[t.attachmentId||"",e?.toString()||"",t.fullPhrase||"",t.keySpan?.toString()||"",t.lineIds?.join(",")||"",t.timestamps?.startTime||"",t.timestamps?.endTime||""];return v(n.join("|")).slice(0,16)}function nt(t){let e=[t.attachmentId||"",t.label||"",t.verifiedFullPhrase||"",t.verifiedKeySpan||"",t.verifiedLineIds?.join(",")||"",t.verifiedPageNumber?.toString()||"",t.verifiedTimestamps?.startTime||"",t.verifiedTimestamps?.endTime||"",t.verifiedMatchSnippet||"",t.hitIndexWithinPage?.toString()||""];return v(e.join("|")).slice(0,16)}function it(t){let e=Math.random().toString(36).slice(2,11);return `${t}-${e}`}var rt=4,st=1;function J(t){if(!t)return;let e=[],n=t.split(",");for(let o of n){let r=o.trim();if(r)if(r.includes("-")){let[s,l]=r.split("-"),i=parseInt(s,10),p=parseInt(l,10);if(!isNaN(i)&&!isNaN(p)&&i<=p)for(let c=i;c<=p;c++)e.push(c);else isNaN(i)||e.push(i);}else {let s=parseInt(r,10);isNaN(s)||e.push(s);}}if(e.length!==0)return [...new Set(e)].sort((o,r)=>o-r)}function ct(t){let e=t?.status,n=e==="not_found",o=e==="found_phrase_missed_value",r=e==="found_key_span_only",s=e==="partial_text_found"||e==="found_on_other_page"||e==="found_on_other_line"||e==="first_word_found";return {isVerified:e==="found"||r||s||o,isMiss:n,isPartialMatch:s,isPending:e==="pending"||e==="loading"||!e}}var Z=(t,e,n,o)=>{let r=m=>m?m.replace(/^['"]|['"]$/g,"").replace(/\\'/g,"'"):void 0,s=n?.current?n.current++:void 0,l=t.substring(0,t.indexOf("<cite")),i=t.includes("/>")?t.slice(t.indexOf("/>")+2):"",p=t.substring(t.indexOf("<cite"),t.indexOf("/>")+2),c=(m,P)=>{for(let M of P){let z=new RegExp(`${M}='((?:[^'\\\\]|\\\\.)*)'`),N=m.match(z);if(N)return N[1]}},a=c(p,["attachment_id","attachmentId","file_id","fileId"]),_=a?.length===20?a:e||a,h=c(p,["start_page_key","startPageKey","start_page"]),f,y;if(h){let m=h.match(/page[\_a-zA-Z]*(\d+)_index_(\d+)/);m&&(f=parseInt(m[1]),y=parseInt(m[2]));}let I=r(c(p,["full_phrase","fullPhrase"])),u=r(c(p,["key_span","keySpan"])),g=r(c(p,["reasoning"])),C=r(c(p,["value"])),b;try{let P=c(p,["line_ids","lineIds"])?.replace(/[A-Za-z_[\](){}:]/g,"");b=P?J(P):void 0;}catch(m){o&&console.error("Error parsing lineIds",m);}let w=c(p,["timestamps"]),d;if(w){let[m,P]=w.split("-")||[];d={startTime:m,endTime:P};}let x={attachmentId:_,pageNumber:f,startPageKey:`page_number_${f||1}_index_${y||0}`,fullPhrase:I,keySpan:u||C,citationNumber:s,lineIds:b,beforeCite:l,timestamps:d,reasoning:g};return {beforeCite:l,afterCite:i,citation:x}},W=(t,e)=>{if(!t)return null;let n=t.fullPhrase??t.full_phrase,o=t.startPageKey??t.start_page_key,r=t.keySpan??t.key_span,s=t.lineIds??t.line_ids,l=t.attachmentId??t.attachment_id??t.fileId??t.file_id,i=t.reasoning,p=t.value;if(!n)return null;let c;if(o){let h=o.match(/page[_a-zA-Z]*(\d+)_index_(\d+)/i);if(h)c=parseInt(h[1],10);else {let f=o.match(/^(\d+)_(\d+)$/);f&&(c=parseInt(f[1],10));}}let a=s?.length?[...s].sort((h,f)=>h-f):void 0;return {attachmentId:l,pageNumber:c,fullPhrase:n,citationNumber:e,lineIds:a,keySpan:r||p,reasoning:i}},$=t=>typeof t=="object"&&t!==null&&("fullPhrase"in t||"full_phrase"in t||"startPageKey"in t||"start_page_key"in t||"keySpan"in t||"key_span"in t||"lineIds"in t||"line_ids"in t),S=t=>Array.isArray(t)?t.length>0&&t.some($):typeof t=="object"&&t!==null?$(t):false,V=t=>{let e={},n=Array.isArray(t)?t:[t],o=1;for(let r of n){let s=W(r,o++);if(s&&s.fullPhrase){let l=k(s);e[l]=s;}}return e},O=(t,e)=>{if(!(!t||typeof t!="object")){if(t.citation&&S(t.citation)){let n=Array.isArray(t.citation)?t.citation:[t.citation];e.push(...n);}if(t.citations&&S(t.citations)){let n=Array.isArray(t.citations)?t.citations:[t.citations];e.push(...n);}if(Array.isArray(t))for(let n of t)O(n,e);else for(let n of Object.keys(t))n!=="citation"&&n!=="citations"&&O(t[n],e);}},B=t=>{let e=K(t),n=/<cite\s+[^>]*\/>/g,o=e.match(n);if(!o||o.length===0)return {};let r={},s={current:1};for(let l of o){let{citation:i}=Z(l,void 0,s);if(i&&i.fullPhrase){let p=k(i);r[p]=i;}}return r},D=t=>{if(!t)return {};let e={};if(typeof t=="object"){if(S(t)){let r=V(t);Object.assign(e,r);}else {let r=[];if(O(t,r),r.length>0){let s=V(r);Object.assign(e,s);}}let n=JSON.stringify(t),o=B(n);Object.assign(e,o);}else if(typeof t=="string"){let n=B(t);Object.assign(e,n);}return e};function pt(t){let e=new Map,n=Array.isArray(t)?t.map((o,r)=>[k(o)||String(r+1),o]):Object.entries(t);for(let[o,r]of n){let s=r.attachmentId||"";e.has(s)||e.set(s,{}),e.get(s)[o]=r;}return e}function ft(t){let e={},n=Array.isArray(t)?t.map((o,r)=>[k(o)||String(r+1),o]):Object.entries(t);for(let[o,r]of n){let s=r.attachmentId||"";e[s]||(e[s]={}),e[s][o]=r;}return e}var q="https://api.deepcitation.com";function E(t,e){if(typeof Buffer<"u"&&Buffer.isBuffer(t)){let n=Uint8Array.from(t);return {blob:new Blob([n]),name:e||"document"}}if(t instanceof Blob)return {blob:t,name:e||(t instanceof File?t.name:"document")};throw new Error("Invalid file type. Expected File, Blob, or Buffer.")}async function F(t,e){return (await t.json().catch(()=>({})))?.error?.message||`${e} failed with status ${t.status}`}var R=class{constructor(e){a(this,"apiKey");a(this,"apiUrl");if(!e.apiKey)throw new Error("DeepCitation API key is required. Get one at https://deepcitation.com/dashboard");this.apiKey=e.apiKey,this.apiUrl=e.apiUrl?.replace(/\/$/,"")||q;}async uploadFile(e,n){let{blob:o,name:r}=E(e,n?.filename),s=new FormData;s.append("file",o,r),n?.attachmentId&&s.append("attachmentId",n.attachmentId),n?.filename&&s.append("filename",n.filename);let l=await fetch(`${this.apiUrl}/prepareFile`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:s});if(!l.ok)throw new Error(await F(l,"Upload"));return await l.json()}async convertToPdf(e){let n=typeof e=="string"?{url:e}:e,{url:o,file:r,filename:s,attachmentId:l}=n;if(!o&&!r)throw new Error("Either url or file must be provided");let i;if(o)i=await fetch(`${this.apiUrl}/convertFile`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({url:o,filename:s,attachmentId:l})});else {let{blob:p,name:c}=E(r,s),a=new FormData;a.append("file",p,c),l&&a.append("attachmentId",l),s&&a.append("filename",s),i=await fetch(`${this.apiUrl}/convertFile`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:a});}if(!i.ok)throw new Error(await F(i,"Conversion"));return await i.json()}async prepareConvertedFile(e){let n=await fetch(`${this.apiUrl}/prepareFile`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({attachmentId:e.attachmentId})});if(!n.ok)throw new Error(await F(n,"Prepare"));return await n.json()}async prepareFiles(e){if(e.length===0)return {fileDataParts:[],deepTextPromptPortion:[]};let n=e.map(({file:l,filename:i,attachmentId:p})=>this.uploadFile(l,{filename:i,attachmentId:p}).then(c=>({result:c,filename:i}))),r=(await Promise.all(n)).map(({result:l,filename:i})=>({attachmentId:l.attachmentId,deepTextPromptPortion:l.deepTextPromptPortion,filename:i||l.metadata?.filename})),s=r.map(l=>l.deepTextPromptPortion);return {fileDataParts:r,deepTextPromptPortion:s}}async verifyCitations(e,n,o){let r={};if(Array.isArray(n))for(let c of n){let a=k(c);r[a]=c;}else if(typeof n=="object"&&n!==null)if("fullPhrase"in n||"value"in n){let c=k(n);r[c]=n;}else Object.assign(r,n);else throw new Error("Invalid citations format");let s=`${this.apiUrl}/verifyCitations`,l={data:{attachmentId:e,citations:r,outputImageFormat:o?.outputImageFormat||"avif"}},i=await fetch(s,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify(l)});if(!i.ok)throw new Error(await F(i,"Verification"));return await i.json()}async verifyCitationsFromLlmOutput(e,n){let{llmOutput:o,outputImageFormat:r="avif"}=e;if(n||(n=D(o)),Object.keys(n).length===0)return {verifications:{}};let s=new Map;for(let[c,a]of Object.entries(n)){let _=a.attachmentId||"";s.has(_)||s.set(_,{}),s.get(_)[c]=a;}let l=[];for(let[c,a]of s)c&&l.push(this.verifyCitations(c,a,{outputImageFormat:r}));let i=await Promise.all(l),p={};for(let c of i)Object.assign(p,c.verifications);return {verifications:p}}};
2
+ export{H as a,G as b,X as c,U as d,K as e,v as f,k as g,nt as h,it as i,rt as j,st as k,ct as l,Z as m,D as n,pt as o,ft as p,R as q};
@@ -0,0 +1 @@
1
+ 'use strict';var d=Object.defineProperty;var e=(b,a,c)=>a in b?d(b,a,{enumerable:true,configurable:true,writable:true,value:c}):b[a]=c;var f=(b,a,c)=>e(b,typeof a!="symbol"?a+"":a,c);exports.a=f;
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunkF2MMVEVC_cjs=require('./chunk-F2MMVEVC.cjs');var H=(t,e)=>{let n=/<cite\s+(?:fileId|attachmentId)='(\w{0,25})'\s+start_page[\_a-zA-Z]*='page[\_a-zA-Z]*(\d+)_index_(\d+)'\s+full_phrase='((?:[^'\\]|\\.)*)'\s+key_span='((?:[^'\\]|\\.)*)'\s+line(?:_ids|Ids)='([^']+)'(?:\s+(value|reasoning)='((?:[^'\\]|\\.)*)')?\s*\/>/g;return t.replace(n,(o,r,s,l,i,p,c,a)=>e&&p?.replace(/key_span=['"]|['"]/g,"")||"")},G=t=>t.replace(/<page_number_\d+_index_\d+>/g,"").replace(/<\/page_number_\d+_index_\d+>/g,"").trim(),X=t=>{let e=/<line id="[^"]*">|<\/line>/g;return t.replace(e,"")},U=t=>{if(!t)return null;let e=t.match(/\d+/)?.[0];return e?parseInt(e):null},K=t=>{let e=t?.trim()||"",n=e.split(/(<cite[\s\S]*?(?:\/>|<\/cite>))/gm);return n.length<=1?T(e):(e=n.map(o=>o.startsWith("<cite")?T(o):o).join(""),e)},T=t=>{let e=t;e=e.replace(/><\/cite>/g,"/>");let n=l=>{let i=l.toLowerCase();return i==="fullphrase"||i==="full_phrase"?"full_phrase":i==="lineids"||i==="line_ids"?"line_ids":i==="startpagekey"||i==="start_pagekey"||i==="start_page_key"?"start_page_key":i==="fileid"||i==="file_id"||i==="attachmentid"||i==="attachment_id"?"attachment_id":i==="keyspan"||i==="key_span"?"key_span":i==="reasoning"||i==="value"?i:i==="timestamps"||i==="timestamp"||i==="timestamps"?"timestamps":i},o=l=>l.replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),r=/(fullPhrase|full_phrase|keySpan|key_span|reasoning|value)\s*=\s*(['"])([\s\S]*?)(?=\s+(?:line_ids|lineIds|timestamps|fileId|file_id|attachmentId|attachment_id|start_page_key|start_pageKey|startPageKey|keySpan|key_span|reasoning|value|full_phrase)|\s*\/?>)/gm;e=e.replace(r,(l,i,p,c)=>{let a=c;return a.endsWith(p)&&(a=a.slice(0,-1)),a=a.replace(/(\r?\n)+/g," "),a=o(a),a=a.replace(/(\*|_){2,}/g,""),a=a.replace(/\\\\'/g,"'"),a=a.replace(/\\'/g,"'"),a=a.replace(/'/g,"\\'"),a=a.replace(/\\\\"/g,'"'),a=a.replace(/\\"/g,'"'),a=a.replace(/"/g,'\\"'),a=a.replace(/\*/g,""),`${n(i)}='${a}'`}),e=e.replace(/(line_ids|lineIds|timestamps)=['"]?([\[\]\(\){}A-Za-z0-9_\-, ]+)['"]?(\s*\/?>|\s+)/gm,(l,i,p,c)=>{let a=p.replace(/[A-Za-z\[\]\(\){}]/g,"");return a=a.replace(/(\d+)-(\d+)/g,(_,h,f)=>{let y=parseInt(h,10),I=parseInt(f,10),u=[];if(y<=I)for(let g=y;g<=I;g++)u.push(g);else u.push(y);return u.join(",")}),a=a.replace(/,+/g,",").replace(/^,|,$/g,""),`${n(i)}='${a}'${c}`});let s=l=>{let i=/([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(['"])((?:[^'"\\\n]|\\.)*)(?:\2)/g,p={},c;for(;c=i.exec(l);){let u=c[1],g=c[3],C=n(u);p[C]=g;}let a=Object.keys(p);if(a.length===0)return l;let _=typeof p.timestamps=="string"&&p.timestamps.length>0,h=a.filter(u=>u.startsWith("start_page")),f=[];p.attachment_id&&f.push("attachment_id"),_?(p.full_phrase&&f.push("full_phrase"),f.push("timestamps")):(h.includes("start_page_key")&&f.push("start_page_key"),h.filter(u=>u!=="start_page_key").sort().forEach(u=>f.push(u)),p.full_phrase&&f.push("full_phrase"),p.key_span&&f.push("key_span"),p.line_ids&&f.push("line_ids")),p.reasoning&&f.push("reasoning"),p.value&&f.push("value");let y=new Set(f);return a.filter(u=>!y.has(u)).sort().forEach(u=>f.push(u)),`<cite ${f.map(u=>`${u}='${p[u]}'`).join(" ")} />`};return e=e.replace(/<cite\b[\s\S]*?\/>/gm,l=>s(l)),e};function L(t){return new TextEncoder().encode(t)}function j(t){let e=1732584193,n=4023233417,o=2562383102,r=271733878,s=3285377520,l=t.length,i=l*8,p=l+1+8,c=Math.ceil(p/64)*64,a=new ArrayBuffer(c),_=new Uint8Array(a),h=new DataView(a);_.set(t),_[l]=128,h.setUint32(c-8,Math.floor(i/4294967296),false),h.setUint32(c-4,i>>>0,false);let f=new Uint32Array(80);for(let I=0;I<c;I+=64){for(let d=0;d<16;d++)f[d]=h.getUint32(I+d*4,false);for(let d=16;d<80;d++){let x=f[d-3]^f[d-8]^f[d-14]^f[d-16];f[d]=x<<1|x>>>31;}let u=e,g=n,C=o,b=r,w=s;for(let d=0;d<80;d++){let x,m;d<20?(x=g&C|~g&b,m=1518500249):d<40?(x=g^C^b,m=1859775393):d<60?(x=g&C|g&b|C&b,m=2400959708):(x=g^C^b,m=3395469782);let P=(u<<5|u>>>27)+x+w+m+f[d]>>>0;w=b,b=C,C=(g<<30|g>>>2)>>>0,g=u,u=P;}e=e+u>>>0,n=n+g>>>0,o=o+C>>>0,r=r+b>>>0,s=s+w>>>0;}let y=I=>I.toString(16).padStart(8,"0");return y(e)+y(n)+y(o)+y(r)+y(s)}function v(t){try{if(!t)return "";let e=typeof t=="string"?t:JSON.stringify(t);return j(L(e))}catch(e){console.error("Error in making the hash:",e);}return ""}function k(t){let e=t.pageNumber||U(t.startPageKey),n=[t.attachmentId||"",e?.toString()||"",t.fullPhrase||"",t.keySpan?.toString()||"",t.lineIds?.join(",")||"",t.timestamps?.startTime||"",t.timestamps?.endTime||""];return v(n.join("|")).slice(0,16)}function nt(t){let e=[t.attachmentId||"",t.label||"",t.verifiedFullPhrase||"",t.verifiedKeySpan||"",t.verifiedLineIds?.join(",")||"",t.verifiedPageNumber?.toString()||"",t.verifiedTimestamps?.startTime||"",t.verifiedTimestamps?.endTime||"",t.verifiedMatchSnippet||"",t.hitIndexWithinPage?.toString()||""];return v(e.join("|")).slice(0,16)}function it(t){let e=Math.random().toString(36).slice(2,11);return `${t}-${e}`}var rt=4,st=1;function J(t){if(!t)return;let e=[],n=t.split(",");for(let o of n){let r=o.trim();if(r)if(r.includes("-")){let[s,l]=r.split("-"),i=parseInt(s,10),p=parseInt(l,10);if(!isNaN(i)&&!isNaN(p)&&i<=p)for(let c=i;c<=p;c++)e.push(c);else isNaN(i)||e.push(i);}else {let s=parseInt(r,10);isNaN(s)||e.push(s);}}if(e.length!==0)return [...new Set(e)].sort((o,r)=>o-r)}function ct(t){let e=t?.status,n=e==="not_found",o=e==="found_phrase_missed_value",r=e==="found_key_span_only",s=e==="partial_text_found"||e==="found_on_other_page"||e==="found_on_other_line"||e==="first_word_found";return {isVerified:e==="found"||r||s||o,isMiss:n,isPartialMatch:s,isPending:e==="pending"||e==="loading"||!e}}var Z=(t,e,n,o)=>{let r=m=>m?m.replace(/^['"]|['"]$/g,"").replace(/\\'/g,"'"):void 0,s=n?.current?n.current++:void 0,l=t.substring(0,t.indexOf("<cite")),i=t.includes("/>")?t.slice(t.indexOf("/>")+2):"",p=t.substring(t.indexOf("<cite"),t.indexOf("/>")+2),c=(m,P)=>{for(let M of P){let z=new RegExp(`${M}='((?:[^'\\\\]|\\\\.)*)'`),N=m.match(z);if(N)return N[1]}},a=c(p,["attachment_id","attachmentId","file_id","fileId"]),_=a?.length===20?a:e||a,h=c(p,["start_page_key","startPageKey","start_page"]),f,y;if(h){let m=h.match(/page[\_a-zA-Z]*(\d+)_index_(\d+)/);m&&(f=parseInt(m[1]),y=parseInt(m[2]));}let I=r(c(p,["full_phrase","fullPhrase"])),u=r(c(p,["key_span","keySpan"])),g=r(c(p,["reasoning"])),C=r(c(p,["value"])),b;try{let P=c(p,["line_ids","lineIds"])?.replace(/[A-Za-z_[\](){}:]/g,"");b=P?J(P):void 0;}catch(m){o&&console.error("Error parsing lineIds",m);}let w=c(p,["timestamps"]),d;if(w){let[m,P]=w.split("-")||[];d={startTime:m,endTime:P};}let x={attachmentId:_,pageNumber:f,startPageKey:`page_number_${f||1}_index_${y||0}`,fullPhrase:I,keySpan:u||C,citationNumber:s,lineIds:b,beforeCite:l,timestamps:d,reasoning:g};return {beforeCite:l,afterCite:i,citation:x}},W=(t,e)=>{if(!t)return null;let n=t.fullPhrase??t.full_phrase,o=t.startPageKey??t.start_page_key,r=t.keySpan??t.key_span,s=t.lineIds??t.line_ids,l=t.attachmentId??t.attachment_id??t.fileId??t.file_id,i=t.reasoning,p=t.value;if(!n)return null;let c;if(o){let h=o.match(/page[_a-zA-Z]*(\d+)_index_(\d+)/i);if(h)c=parseInt(h[1],10);else {let f=o.match(/^(\d+)_(\d+)$/);f&&(c=parseInt(f[1],10));}}let a=s?.length?[...s].sort((h,f)=>h-f):void 0;return {attachmentId:l,pageNumber:c,fullPhrase:n,citationNumber:e,lineIds:a,keySpan:r||p,reasoning:i}},$=t=>typeof t=="object"&&t!==null&&("fullPhrase"in t||"full_phrase"in t||"startPageKey"in t||"start_page_key"in t||"keySpan"in t||"key_span"in t||"lineIds"in t||"line_ids"in t),S=t=>Array.isArray(t)?t.length>0&&t.some($):typeof t=="object"&&t!==null?$(t):false,V=t=>{let e={},n=Array.isArray(t)?t:[t],o=1;for(let r of n){let s=W(r,o++);if(s&&s.fullPhrase){let l=k(s);e[l]=s;}}return e},O=(t,e)=>{if(!(!t||typeof t!="object")){if(t.citation&&S(t.citation)){let n=Array.isArray(t.citation)?t.citation:[t.citation];e.push(...n);}if(t.citations&&S(t.citations)){let n=Array.isArray(t.citations)?t.citations:[t.citations];e.push(...n);}if(Array.isArray(t))for(let n of t)O(n,e);else for(let n of Object.keys(t))n!=="citation"&&n!=="citations"&&O(t[n],e);}},B=t=>{let e=K(t),n=/<cite\s+[^>]*\/>/g,o=e.match(n);if(!o||o.length===0)return {};let r={},s={current:1};for(let l of o){let{citation:i}=Z(l,void 0,s);if(i&&i.fullPhrase){let p=k(i);r[p]=i;}}return r},D=t=>{if(!t)return {};let e={};if(typeof t=="object"){if(S(t)){let r=V(t);Object.assign(e,r);}else {let r=[];if(O(t,r),r.length>0){let s=V(r);Object.assign(e,s);}}let n=JSON.stringify(t),o=B(n);Object.assign(e,o);}else if(typeof t=="string"){let n=B(t);Object.assign(e,n);}return e};function pt(t){let e=new Map,n=Array.isArray(t)?t.map((o,r)=>[k(o)||String(r+1),o]):Object.entries(t);for(let[o,r]of n){let s=r.attachmentId||"";e.has(s)||e.set(s,{}),e.get(s)[o]=r;}return e}function ft(t){let e={},n=Array.isArray(t)?t.map((o,r)=>[k(o)||String(r+1),o]):Object.entries(t);for(let[o,r]of n){let s=r.attachmentId||"";e[s]||(e[s]={}),e[s][o]=r;}return e}var q="https://api.deepcitation.com";function E(t,e){if(typeof Buffer<"u"&&Buffer.isBuffer(t)){let n=Uint8Array.from(t);return {blob:new Blob([n]),name:e||"document"}}if(t instanceof Blob)return {blob:t,name:e||(t instanceof File?t.name:"document")};throw new Error("Invalid file type. Expected File, Blob, or Buffer.")}async function F(t,e){return (await t.json().catch(()=>({})))?.error?.message||`${e} failed with status ${t.status}`}var R=class{constructor(e){chunkF2MMVEVC_cjs.a(this,"apiKey");chunkF2MMVEVC_cjs.a(this,"apiUrl");if(!e.apiKey)throw new Error("DeepCitation API key is required. Get one at https://deepcitation.com/dashboard");this.apiKey=e.apiKey,this.apiUrl=e.apiUrl?.replace(/\/$/,"")||q;}async uploadFile(e,n){let{blob:o,name:r}=E(e,n?.filename),s=new FormData;s.append("file",o,r),n?.attachmentId&&s.append("attachmentId",n.attachmentId),n?.filename&&s.append("filename",n.filename);let l=await fetch(`${this.apiUrl}/prepareFile`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:s});if(!l.ok)throw new Error(await F(l,"Upload"));return await l.json()}async convertToPdf(e){let n=typeof e=="string"?{url:e}:e,{url:o,file:r,filename:s,attachmentId:l}=n;if(!o&&!r)throw new Error("Either url or file must be provided");let i;if(o)i=await fetch(`${this.apiUrl}/convertFile`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({url:o,filename:s,attachmentId:l})});else {let{blob:p,name:c}=E(r,s),a=new FormData;a.append("file",p,c),l&&a.append("attachmentId",l),s&&a.append("filename",s),i=await fetch(`${this.apiUrl}/convertFile`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:a});}if(!i.ok)throw new Error(await F(i,"Conversion"));return await i.json()}async prepareConvertedFile(e){let n=await fetch(`${this.apiUrl}/prepareFile`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({attachmentId:e.attachmentId})});if(!n.ok)throw new Error(await F(n,"Prepare"));return await n.json()}async prepareFiles(e){if(e.length===0)return {fileDataParts:[],deepTextPromptPortion:[]};let n=e.map(({file:l,filename:i,attachmentId:p})=>this.uploadFile(l,{filename:i,attachmentId:p}).then(c=>({result:c,filename:i}))),r=(await Promise.all(n)).map(({result:l,filename:i})=>({attachmentId:l.attachmentId,deepTextPromptPortion:l.deepTextPromptPortion,filename:i||l.metadata?.filename})),s=r.map(l=>l.deepTextPromptPortion);return {fileDataParts:r,deepTextPromptPortion:s}}async verifyCitations(e,n,o){let r={};if(Array.isArray(n))for(let c of n){let a=k(c);r[a]=c;}else if(typeof n=="object"&&n!==null)if("fullPhrase"in n||"value"in n){let c=k(n);r[c]=n;}else Object.assign(r,n);else throw new Error("Invalid citations format");let s=`${this.apiUrl}/verifyCitations`,l={data:{attachmentId:e,citations:r,outputImageFormat:o?.outputImageFormat||"avif"}},i=await fetch(s,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify(l)});if(!i.ok)throw new Error(await F(i,"Verification"));return await i.json()}async verifyCitationsFromLlmOutput(e,n){let{llmOutput:o,outputImageFormat:r="avif"}=e;if(n||(n=D(o)),Object.keys(n).length===0)return {verifications:{}};let s=new Map;for(let[c,a]of Object.entries(n)){let _=a.attachmentId||"";s.has(_)||s.set(_,{}),s.get(_)[c]=a;}let l=[];for(let[c,a]of s)c&&l.push(this.verifyCitations(c,a,{outputImageFormat:r}));let i=await Promise.all(l),p={};for(let c of i)Object.assign(p,c.verifications);return {verifications:p}}};
2
+ exports.a=H;exports.b=G;exports.c=X;exports.d=U;exports.e=K;exports.f=v;exports.g=k;exports.h=nt;exports.i=it;exports.j=rt;exports.k=st;exports.l=ct;exports.m=Z;exports.n=D;exports.o=pt;exports.p=ft;exports.q=R;
@@ -0,0 +1 @@
1
+ var d=Object.defineProperty;var e=(b,a,c)=>a in b?d(b,a,{enumerable:true,configurable:true,writable:true,value:c}):b[a]=c;var f=(b,a,c)=>e(b,typeof a!="symbol"?a+"":a,c);export{f as a};
@@ -0,0 +1 @@
1
+ var e="avif";var t=-1,n=-2,r={attachmentId:null,verifiedPageNumber:t,verifiedMatchSnippet:null,citation:{pageNumber:t},status:"not_found"};export{e as a,t as b,n as c,r as d};
@@ -0,0 +1 @@
1
+ 'use strict';var chunkJ7U6YFOI_cjs=require('../chunk-J7U6YFOI.cjs');require('../chunk-F2MMVEVC.cjs');Object.defineProperty(exports,"DeepCitation",{enumerable:true,get:function(){return chunkJ7U6YFOI_cjs.q}});
@@ -1,5 +1,159 @@
1
- import type { Citation } from "../types/index.js";
2
- import type { CitationInput, ConvertFileInput, ConvertFileResponse, DeepCitationConfig, FileInput, PrepareConvertedFileOptions, PrepareFilesResult, UploadFileOptions, UploadFileResponse, VerifyCitationsFromLlmOutput, VerifyCitationsOptions, VerifyCitationsResponse } from "./types.js";
1
+ import { Citation, Verification } from '../types/index.cjs';
2
+
3
+ /**
4
+ * Configuration options for the DeepCitation client
5
+ */
6
+ interface DeepCitationConfig {
7
+ /** Your DeepCitation API key (starts with sk-dc-) */
8
+ apiKey: string;
9
+ /** Optional custom API base URL. Defaults to https://api.deepcitation.com */
10
+ apiUrl?: string;
11
+ }
12
+ /**
13
+ * Response from uploading a file for citation verification
14
+ */
15
+ interface UploadFileResponse {
16
+ /** The attachment ID assigned by DeepCitation (custom or auto-generated) */
17
+ attachmentId: string;
18
+ /** The full text content formatted for LLM prompts with page markers and line IDs. Use this in your user prompts. */
19
+ deepTextPromptPortion: string;
20
+ /** Form fields extracted from PDF forms */
21
+ formFields?: Array<{
22
+ name: string;
23
+ value?: string;
24
+ pageIndex?: number;
25
+ type?: string;
26
+ }>;
27
+ /** Metadata about the processed file */
28
+ metadata: {
29
+ filename: string;
30
+ mimeType: string;
31
+ pageCount: number;
32
+ textByteSize: number;
33
+ };
34
+ /** Processing status */
35
+ status: "ready" | "error";
36
+ /** Time taken to process the file in milliseconds */
37
+ processingTimeMs?: number;
38
+ /** Error message if status is "error" */
39
+ error?: string;
40
+ }
41
+ /**
42
+ * Options for file upload
43
+ */
44
+ interface UploadFileOptions {
45
+ /** Optional custom attachment ID to use instead of auto-generated one */
46
+ attachmentId?: string;
47
+ /** Optional custom filename (uses File.name if not provided) */
48
+ filename?: string;
49
+ }
50
+ /**
51
+ * Response from verifying citations
52
+ */
53
+ interface VerifyCitationsResponse {
54
+ /** Map of citation keys to their verification results */
55
+ verifications: Record<string, Verification>;
56
+ }
57
+ /**
58
+ * Options for citation verification
59
+ */
60
+ interface VerifyCitationsOptions {
61
+ /** Output image format for verification screenshots */
62
+ outputImageFormat?: "jpeg" | "png" | "avif";
63
+ }
64
+ /**
65
+ * Simplified citation input for verification
66
+ */
67
+ type CitationInput = Citation | Record<string, Citation>;
68
+ /**
69
+ * Input for file upload in prepareFiles
70
+ */
71
+ interface FileInput {
72
+ /** The file content (File, Blob, or Buffer) */
73
+ file: File | Blob | Buffer;
74
+ /** Optional filename */
75
+ filename?: string;
76
+ /** Optional custom attachment ID */
77
+ attachmentId?: string;
78
+ }
79
+ /**
80
+ * File reference returned from prepareFiles
81
+ */
82
+ interface FileDataPart {
83
+ /** The attachment ID assigned by DeepCitation */
84
+ attachmentId: string;
85
+ /** The formatted text content for LLM prompts (with page markers and line IDs) */
86
+ deepTextPromptPortion: string;
87
+ /** Optional filename for display purposes */
88
+ filename?: string;
89
+ }
90
+ /**
91
+ * Result from prepareFiles
92
+ */
93
+ interface PrepareFilesResult {
94
+ /** Array of file references for verification (includes deepTextPromptPortion for each file) */
95
+ fileDataParts: FileDataPart[];
96
+ /**
97
+ * Array of formatted text content for LLM prompts (with page markers and line IDs).
98
+ * @deprecated Use fileDataParts[].deepTextPromptPortion instead for single source of truth.
99
+ * This is kept for backwards compatibility but will be removed in a future version.
100
+ */
101
+ deepTextPromptPortion: string[];
102
+ }
103
+ /**
104
+ * Input for verifyCitationsFromLlmOutput
105
+ */
106
+ interface VerifyCitationsFromLlmOutput {
107
+ /** The LLM response containing citations */
108
+ llmOutput: string;
109
+ /** Optional file references (required for Zero Data Retention or after storage expires) */
110
+ fileDataParts?: FileDataPart[];
111
+ /** Output image format for verification screenshots */
112
+ outputImageFormat?: "jpeg" | "png" | "avif";
113
+ }
114
+ /**
115
+ * Input for convertFile - convert URL or Office file to PDF
116
+ */
117
+ interface ConvertFileInput {
118
+ /** URL to convert to PDF (for web pages or direct PDF links) */
119
+ url?: string;
120
+ /** Office file to convert (doc, docx, xls, xlsx, ppt, pptx, odt, ods, odp) */
121
+ file?: File | Blob | Buffer;
122
+ /** Optional custom filename for the converted PDF */
123
+ filename?: string;
124
+ /** Optional custom attachment ID */
125
+ attachmentId?: string;
126
+ }
127
+ /**
128
+ * Response from convertFile
129
+ */
130
+ interface ConvertFileResponse {
131
+ /** The attachment ID assigned by DeepCitation. Pass this to prepareConvertedFile(). */
132
+ attachmentId: string;
133
+ /** Metadata about the conversion */
134
+ metadata: {
135
+ /** Original filename before conversion */
136
+ originalFilename: string;
137
+ /** Original MIME type before conversion */
138
+ originalMimeType: string;
139
+ /** MIME type after conversion (always application/pdf) */
140
+ convertedMimeType: string;
141
+ /** Time taken for conversion in milliseconds */
142
+ conversionTimeMs: number;
143
+ };
144
+ /** Conversion status */
145
+ status: "converted" | "error";
146
+ /** Error message if status is "error" */
147
+ error?: string;
148
+ }
149
+ /**
150
+ * Options for processing a converted file
151
+ */
152
+ interface PrepareConvertedFileOptions {
153
+ /** The attachment ID from a previous convertFile call */
154
+ attachmentId: string;
155
+ }
156
+
3
157
  /**
4
158
  * DeepCitation client for file upload and citation verification.
5
159
  *
@@ -25,7 +179,7 @@ import type { CitationInput, ConvertFileInput, ConvertFileResponse, DeepCitation
25
179
  * const verified = await dc.verifyCitations(attachmentId, citations);
26
180
  * ```
27
181
  */
28
- export declare class DeepCitation {
182
+ declare class DeepCitation {
29
183
  private readonly apiKey;
30
184
  private readonly apiUrl;
31
185
  /**
@@ -184,3 +338,5 @@ export declare class DeepCitation {
184
338
  [key: string]: Citation;
185
339
  }): Promise<VerifyCitationsResponse>;
186
340
  }
341
+
342
+ export { type CitationInput, type ConvertFileInput, type ConvertFileResponse, DeepCitation, type DeepCitationConfig, type FileDataPart, type FileInput, type PrepareConvertedFileOptions, type PrepareFilesResult, type UploadFileOptions, type UploadFileResponse, type VerifyCitationsFromLlmOutput, type VerifyCitationsOptions, type VerifyCitationsResponse };