1import{r as l}from"./db-Dgd9zlNH.js";import{h}from"./attachments-0D7dZ0Hd.js";import{i as p,r as d,t as c}from"./intelligence-inputs-DojPSZCC.js";function f(e){return new Promise((t,o)=>{const n=new FileReader;n.onload=()=>{const i=String(n.result||"");t(i.includes(",")?i.slice(i.indexOf(",")+1):i)},n.onerror=()=>o(n.error||new Error("Unable to read the selected input.")),n.readAsDataURL(e)})}async function y(e,t={}){if(!e)throw new Error("A file is required.");if(Number(e.size||0)>c.maxPartBytes)throw new Error("Each intelligence input must be 4 MB or smaller.");const o=String(e.type||t.mimeType||"application/octet-stream").split(";")[0].toLowerCase(),n=d(o),i={type:n,name:e.name||t.name||"input",mimeType:o,attachmentId:t.attachmentId,checksum:t.checksum};return n==="text"?p([{...i,type:"text",text:await e.text()}])[0]:p([{...i,data:await f(e)}])[0]}async function w(e){if(!e?.id)throw new Error("An attachment is required.");const t=await h(e.id);if(!t?.blob)throw new Error(`${e.name||"Attachment"} is not available on this device.`);return y(new File([t.blob],t.name||e.name||"input",{type:t.mimeType||e.mimeType||t.blob.type}),{attachmentId:e.id,checksum:e.checksum,mimeType:e.mimeType,name:e.name})}function T(e){return{attachmentId:e.attachmentId||"",checksum:e.checksum||"",name:e.name||"input",type:e.type,mimeType:e.mimeType||(e.type==="text"?"text/plain":"application/octet-stream"),size:Number(e.size||(e.type==="text"?new TextEncoder().encode(e.text||"").byteLength:0))}}async function g(e,{limit:t=3,database:o=l}={}){const n=[...new Set((e||[]).filter(Boolean))];if(!n.length||t<=0)return[];let i=[];try{i=await o.attachments.where("notePath").anyOf(n).toArray()}catch{await o.attachments.each(r=>{n.includes(r.notePath)&&i.push(r)})}i.sort((r,a)=>Number(a.createdAt||0)-Number(r.createdAt||0));const s=[];let m=0;for(const r of i){if(s.length>=Math.min(t,c.maxParts))break;if(!(Number(r.size||0)+m>c.maxTotalBytes))try{const a=await w(r),u=Number(a.size||0);if(u+m>c.maxTotalBytes)continue;s.push(a),m+=u}catch{}}return s}function A(){return"image/*,audio/*,video/*,text/*,application/pdf,application/json,application/rtf,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.presentation"}export{w as attachmentToIntelligenceInput,y as fileToIntelligenceInput,A as inputAcceptAttribute,T as intelligenceInputReference,g as intelligenceInputsForNotePaths};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.