import{au as a,at as i,aW as o,n as s,U as c,Y as l}from"./chunk-B8Q4vgLh.js";const p=a({selector:o(),text:o().min(1),problem:o().min(1),suggestion:o().min(1),confidence:i().min(0).max(1)}),f=a({issues:s(p),treatedAsNames:s(o())}),u=["You are proofreading the visible text of a software product page.","Report only genuine errors: misspellings, grammatical mistakes, wrong or missing words, doubled words,","and broken punctuation that changes meaning.","Do NOT report: product names, brand names, feature names, technical terms, acronyms, identifiers,","deliberate stylistic choices, British vs American spelling, sentence fragments used as labels or headings,","or missing terminal punctuation on a button or a heading.",'Placeholder or template text that was clearly never replaced ("Lorem ipsum", "TODO", "{{name}}") IS an',"error worth reporting.","Return an empty issues array when the text is fine. Never invent an error to have something to report.",c].join(" ");function m(t){return["Proofread the text blocks below, taken from a page in a software product.","",`Page: ${t.url}`,"",...t.blocks.map((e,r)=>l(`Block ${String(r+1)} · selector ${e.selector}`,e.text)),"","Respond with ONLY a JSON object, no prose, with exactly these keys:","{",'  "issues": [',"    {",'      "selector": string,      // the selector of the block the error is in, copied exactly','      "text": string,          // the offending phrase, verbatim from the block','      "problem": string,       // e.g. "Spelling: recieve", "Missing word"','      "suggestion": string,    // the corrected phrase','      "confidence": number     // 0..1',"    }","  ],",'  "treatedAsNames": string[]   // terms you judged to be product or brand vocabulary, not errors',"}"].filter(e=>e!=="").join(`
`)}const d=40,g=6e3;function y(t){const e=[];let r=0;for(const n of t){if(e.length>=d||r+n.text.length>g)break;e.push(n),r+=n.text.length}return{blocks:e,skipped:t.length-e.length}}const h=.6;function x(t){return t.issues.filter(e=>e.confidence>=h)}async function k(t,e,r){return(await e.complete({system:u,prompt:m(t),schema:f,label:"page.proofread",maxOutputTokens:2e3},r)).value}function w(t){return typeof t=="object"&&t!==null&&t.type==="tcr.agent.proofread"}function N(t){if(typeof t!="object"||t===null)return!1;const e=t;return typeof e.url!="string"||!Array.isArray(e.blocks)||e.blocks.length===0?!1:e.blocks.every(r=>typeof r=="object"&&r!==null&&typeof r.selector=="string"&&typeof r.text=="string")}export{N as a,y as b,x as f,w as i,k as p};
//# sourceMappingURL=chunk-Cbf1OwgQ.js.map
