proofmarks 0.1.0__py3-none-win_amd64.whl
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.
- proofmarks/__init__.py +3 -0
- proofmarks/__main__.py +3 -0
- proofmarks/_run.py +15 -0
- proofmarks/standalone/CHANGELOG.md +22 -0
- proofmarks/standalone/LICENSE.md +105 -0
- proofmarks/standalone/README.md +117 -0
- proofmarks/standalone/SECURITY.md +15 -0
- proofmarks/standalone/TELEMETRY.md +64 -0
- proofmarks/standalone/dist/OFL.txt +93 -0
- proofmarks/standalone/dist/chunk-FIVQWTE5.js +2 -0
- proofmarks/standalone/dist/chunk-GMJHTMKC.js +1 -0
- proofmarks/standalone/dist/companion/proofmarks.exe +4 -0
- proofmarks/standalone/dist/config/index.d.mts +4 -0
- proofmarks/standalone/dist/config/index.mjs +160 -0
- proofmarks/standalone/dist/index.js +1 -0
- proofmarks/standalone/dist/next/index.js +2 -0
- proofmarks/standalone/dist/overlay/react.js +1 -0
- proofmarks/standalone/dist/pi/extension.js +3 -0
- proofmarks/standalone/dist/proofmarks-font.js +1 -0
- proofmarks/standalone/dist/script-entry.js +1 -0
- proofmarks/standalone/dist/script.js +1 -0
- proofmarks/standalone/dist/shared/node-2IMCJYUI.js +20 -0
- proofmarks/standalone/dist/shared/node-6KSUNIF7.js +3 -0
- proofmarks/standalone/dist/shared/node-KSPBKQI5.js +2 -0
- proofmarks/standalone/dist/shared/node-VICV4ZWL.js +22 -0
- proofmarks/standalone/dist/shared/node-VRDN4HYM.js +10 -0
- proofmarks/standalone/dist/sizes.json +37 -0
- proofmarks/standalone/rules/calibration/jev-jev-1.14.0.json +210 -0
- proofmarks/standalone/rules/rules.v3.json +390 -0
- proofmarks-0.1.0.dist-info/METADATA +127 -0
- proofmarks-0.1.0.dist-info/RECORD +33 -0
- proofmarks-0.1.0.dist-info/WHEEL +4 -0
- proofmarks-0.1.0.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Built by Proofmarks.
|
|
2
|
+
import{readFile as at,realpath as he,lstat as U}from"node:fs/promises";import E from"node:path";import{z as w}from"zod";var k=class extends Error{constructor(t){super(t),this.name="ConfigError"}},st=w.object({version:w.literal(1),documents:w.array(w.object({id:w.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/),source:w.string().min(1),review:w.string().min(1),write:w.boolean().default(!1),url:w.string().startsWith("/").optional(),format:w.enum(["markdown","mdx","html","jinja"]).optional()}).strict()),rebuild:w.string().min(1).optional(),devServer:w.string().url().refine(e=>/^https?:/.test(e),"Expected an HTTP(S) URL").optional(),origins:w.array(w.string().url().refine(e=>{try{let t=new URL(e);return/^https?:$/.test(t.protocol)&&t.origin===e}catch{return!1}},"Expected an HTTP(S) origin")).default([]),tailnetHosts:w.array(w.string().regex(/^[a-zA-Z0-9.-]+(?::[0-9]+)?$/)).default([]),tailscaleUsers:w.array(w.string().min(1)).default([]),roots:w.array(w.string().min(1)).min(1),rules:w.record(w.string().regex(/^[a-z][a-z0-9-]*$/),w.boolean()).optional(),judge:w.object({provider:w.enum(["jev","fake"]),model:w.string().min(1)}).strict()}).strict(),_=(e,t)=>{let r=E.relative(e,t);return r!==".."&&!r.startsWith(".."+E.sep)&&!E.isAbsolute(r)};async function I(e,t){if(E.isAbsolute(t))throw new k("Config paths must be relative to the project root");let r=E.resolve(e,t);if(!_(e,r))throw new k("Config path escapes the project root");let n=r,s=[];for(;;)try{let a=await he(n);if(!_(e,a)||a!==n)throw new k("Config path resolves through a symlink or outside the project root");return E.join(a,...s.reverse())}catch(a){if(a.code!=="ENOENT")throw a;try{if((await U(n)).isSymbolicLink())throw new k("Config path contains a broken symlink")}catch(i){if(i.code!=="ENOENT")throw i}s.push(E.basename(n)),n=E.dirname(n)}}async function Z(e){let t;try{t=await he(e)}catch{throw new k("Project root is not an accessible directory")}let r=await I(t,"proofmarks.config.json"),n;try{n=await at(r,"utf8")}catch(d){throw d.code==="ENOENT"?new k("No proofmarks.config.json found; run proofmarks init or pass --root"):d}let s;try{s=JSON.parse(n)}catch{throw new k("proofmarks.config.json is not valid JSON")}let a=st.safeParse(s);if(!a.success)throw new k("Invalid proofmarks.config.json: "+a.error.issues.map(d=>d.path.join(".")+" "+d.message).join("; "));let i=a.data,u=new Set,c=new Set,l=await Promise.all(i.roots.map(d=>I(t,d)));for(let d of l)try{if(!(await U(d)).isDirectory())throw new Error}catch{throw new k("Configured root must be an accessible directory")}let o=[];for(let d of i.documents){if(u.has(d.id)||c.has(d.review))throw new k("Duplicate document identity or review path");u.add(d.id),c.add(d.review);let p=await I(t,d.source),f=await I(t,d.review);if(!/\.(?:md|mdx|html?|jinja2?|j2|njk|nunjucks|twig|liquid)$/.test(p)||!/\.json$/.test(f)||!l.some(y=>_(y,p)))throw new k("Document source or review path is invalid");try{if(!(await U(p)).isFile())throw new Error}catch{throw new k("Document source must be an accessible file")}try{if(!(await U(f)).isFile())throw new k("Document review must be a file")}catch(y){if(y.code!=="ENOENT")throw y}let g=await I(t,d.review.replace(/\.json$/,".log.jsonl")),b=d.format??(/\.mdx$/.test(p)?"mdx":/\.md$/.test(p)?"markdown":/\.html?$/.test(p)?"html":"jinja");o.push({...d,format:b,sourcePath:p,reviewPath:f,logPath:g})}return{...i,projectRoot:t,roots:l,documents:o}}import{access as it}from"node:fs/promises";import Y from"node:path";async function be(e){let t=Y.resolve(e);for(;;){try{return await it(Y.join(t,"proofmarks.config.json")),await Z(t)}catch(n){if(n.code!=="ENOENT")throw n}let r=Y.dirname(t);if(r===t)return;t=r}}var we={AElig:"\xC6",AMP:"&",Aacute:"\xC1",Abreve:"\u0102",Acirc:"\xC2",Acy:"\u0410",Afr:"\u{1D504}",Agrave:"\xC0",Alpha:"\u0391",Amacr:"\u0100",And:"\u2A53",Aogon:"\u0104",Aopf:"\u{1D538}",ApplyFunction:"\u2061",Aring:"\xC5",Ascr:"\u{1D49C}",Assign:"\u2254",Atilde:"\xC3",Auml:"\xC4",Backslash:"\u2216",Barv:"\u2AE7",Barwed:"\u2306",Bcy:"\u0411",Because:"\u2235",Bernoullis:"\u212C",Beta:"\u0392",Bfr:"\u{1D505}",Bopf:"\u{1D539}",Breve:"\u02D8",Bscr:"\u212C",Bumpeq:"\u224E",CHcy:"\u0427",COPY:"\xA9",Cacute:"\u0106",Cap:"\u22D2",CapitalDifferentialD:"\u2145",Cayleys:"\u212D",Ccaron:"\u010C",Ccedil:"\xC7",Ccirc:"\u0108",Cconint:"\u2230",Cdot:"\u010A",Cedilla:"\xB8",CenterDot:"\xB7",Cfr:"\u212D",Chi:"\u03A7",CircleDot:"\u2299",CircleMinus:"\u2296",CirclePlus:"\u2295",CircleTimes:"\u2297",ClockwiseContourIntegral:"\u2232",CloseCurlyDoubleQuote:"\u201D",CloseCurlyQuote:"\u2019",Colon:"\u2237",Colone:"\u2A74",Congruent:"\u2261",Conint:"\u222F",ContourIntegral:"\u222E",Copf:"\u2102",Coproduct:"\u2210",CounterClockwiseContourIntegral:"\u2233",Cross:"\u2A2F",Cscr:"\u{1D49E}",Cup:"\u22D3",CupCap:"\u224D",DD:"\u2145",DDotrahd:"\u2911",DJcy:"\u0402",DScy:"\u0405",DZcy:"\u040F",Dagger:"\u2021",Darr:"\u21A1",Dashv:"\u2AE4",Dcaron:"\u010E",Dcy:"\u0414",Del:"\u2207",Delta:"\u0394",Dfr:"\u{1D507}",DiacriticalAcute:"\xB4",DiacriticalDot:"\u02D9",DiacriticalDoubleAcute:"\u02DD",DiacriticalGrave:"`",DiacriticalTilde:"\u02DC",Diamond:"\u22C4",DifferentialD:"\u2146",Dopf:"\u{1D53B}",Dot:"\xA8",DotDot:"\u20DC",DotEqual:"\u2250",DoubleContourIntegral:"\u222F",DoubleDot:"\xA8",DoubleDownArrow:"\u21D3",DoubleLeftArrow:"\u21D0",DoubleLeftRightArrow:"\u21D4",DoubleLeftTee:"\u2AE4",DoubleLongLeftArrow:"\u27F8",DoubleLongLeftRightArrow:"\u27FA",DoubleLongRightArrow:"\u27F9",DoubleRightArrow:"\u21D2",DoubleRightTee:"\u22A8",DoubleUpArrow:"\u21D1",DoubleUpDownArrow:"\u21D5",DoubleVerticalBar:"\u2225",DownArrow:"\u2193",DownArrowBar:"\u2913",DownArrowUpArrow:"\u21F5",DownBreve:"\u0311",DownLeftRightVector:"\u2950",DownLeftTeeVector:"\u295E",DownLeftVector:"\u21BD",DownLeftVectorBar:"\u2956",DownRightTeeVector:"\u295F",DownRightVector:"\u21C1",DownRightVectorBar:"\u2957",DownTee:"\u22A4",DownTeeArrow:"\u21A7",Downarrow:"\u21D3",Dscr:"\u{1D49F}",Dstrok:"\u0110",ENG:"\u014A",ETH:"\xD0",Eacute:"\xC9",Ecaron:"\u011A",Ecirc:"\xCA",Ecy:"\u042D",Edot:"\u0116",Efr:"\u{1D508}",Egrave:"\xC8",Element:"\u2208",Emacr:"\u0112",EmptySmallSquare:"\u25FB",EmptyVerySmallSquare:"\u25AB",Eogon:"\u0118",Eopf:"\u{1D53C}",Epsilon:"\u0395",Equal:"\u2A75",EqualTilde:"\u2242",Equilibrium:"\u21CC",Escr:"\u2130",Esim:"\u2A73",Eta:"\u0397",Euml:"\xCB",Exists:"\u2203",ExponentialE:"\u2147",Fcy:"\u0424",Ffr:"\u{1D509}",FilledSmallSquare:"\u25FC",FilledVerySmallSquare:"\u25AA",Fopf:"\u{1D53D}",ForAll:"\u2200",Fouriertrf:"\u2131",Fscr:"\u2131",GJcy:"\u0403",GT:">",Gamma:"\u0393",Gammad:"\u03DC",Gbreve:"\u011E",Gcedil:"\u0122",Gcirc:"\u011C",Gcy:"\u0413",Gdot:"\u0120",Gfr:"\u{1D50A}",Gg:"\u22D9",Gopf:"\u{1D53E}",GreaterEqual:"\u2265",GreaterEqualLess:"\u22DB",GreaterFullEqual:"\u2267",GreaterGreater:"\u2AA2",GreaterLess:"\u2277",GreaterSlantEqual:"\u2A7E",GreaterTilde:"\u2273",Gscr:"\u{1D4A2}",Gt:"\u226B",HARDcy:"\u042A",Hacek:"\u02C7",Hat:"^",Hcirc:"\u0124",Hfr:"\u210C",HilbertSpace:"\u210B",Hopf:"\u210D",HorizontalLine:"\u2500",Hscr:"\u210B",Hstrok:"\u0126",HumpDownHump:"\u224E",HumpEqual:"\u224F",IEcy:"\u0415",IJlig:"\u0132",IOcy:"\u0401",Iacute:"\xCD",Icirc:"\xCE",Icy:"\u0418",Idot:"\u0130",Ifr:"\u2111",Igrave:"\xCC",Im:"\u2111",Imacr:"\u012A",ImaginaryI:"\u2148",Implies:"\u21D2",Int:"\u222C",Integral:"\u222B",Intersection:"\u22C2",InvisibleComma:"\u2063",InvisibleTimes:"\u2062",Iogon:"\u012E",Iopf:"\u{1D540}",Iota:"\u0399",Iscr:"\u2110",Itilde:"\u0128",Iukcy:"\u0406",Iuml:"\xCF",Jcirc:"\u0134",Jcy:"\u0419",Jfr:"\u{1D50D}",Jopf:"\u{1D541}",Jscr:"\u{1D4A5}",Jsercy:"\u0408",Jukcy:"\u0404",KHcy:"\u0425",KJcy:"\u040C",Kappa:"\u039A",Kcedil:"\u0136",Kcy:"\u041A",Kfr:"\u{1D50E}",Kopf:"\u{1D542}",Kscr:"\u{1D4A6}",LJcy:"\u0409",LT:"<",Lacute:"\u0139",Lambda:"\u039B",Lang:"\u27EA",Laplacetrf:"\u2112",Larr:"\u219E",Lcaron:"\u013D",Lcedil:"\u013B",Lcy:"\u041B",LeftAngleBracket:"\u27E8",LeftArrow:"\u2190",LeftArrowBar:"\u21E4",LeftArrowRightArrow:"\u21C6",LeftCeiling:"\u2308",LeftDoubleBracket:"\u27E6",LeftDownTeeVector:"\u2961",LeftDownVector:"\u21C3",LeftDownVectorBar:"\u2959",LeftFloor:"\u230A",LeftRightArrow:"\u2194",LeftRightVector:"\u294E",LeftTee:"\u22A3",LeftTeeArrow:"\u21A4",LeftTeeVector:"\u295A",LeftTriangle:"\u22B2",LeftTriangleBar:"\u29CF",LeftTriangleEqual:"\u22B4",LeftUpDownVector:"\u2951",LeftUpTeeVector:"\u2960",LeftUpVector:"\u21BF",LeftUpVectorBar:"\u2958",LeftVector:"\u21BC",LeftVectorBar:"\u2952",Leftarrow:"\u21D0",Leftrightarrow:"\u21D4",LessEqualGreater:"\u22DA",LessFullEqual:"\u2266",LessGreater:"\u2276",LessLess:"\u2AA1",LessSlantEqual:"\u2A7D",LessTilde:"\u2272",Lfr:"\u{1D50F}",Ll:"\u22D8",Lleftarrow:"\u21DA",Lmidot:"\u013F",LongLeftArrow:"\u27F5",LongLeftRightArrow:"\u27F7",LongRightArrow:"\u27F6",Longleftarrow:"\u27F8",Longleftrightarrow:"\u27FA",Longrightarrow:"\u27F9",Lopf:"\u{1D543}",LowerLeftArrow:"\u2199",LowerRightArrow:"\u2198",Lscr:"\u2112",Lsh:"\u21B0",Lstrok:"\u0141",Lt:"\u226A",Map:"\u2905",Mcy:"\u041C",MediumSpace:"\u205F",Mellintrf:"\u2133",Mfr:"\u{1D510}",MinusPlus:"\u2213",Mopf:"\u{1D544}",Mscr:"\u2133",Mu:"\u039C",NJcy:"\u040A",Nacute:"\u0143",Ncaron:"\u0147",Ncedil:"\u0145",Ncy:"\u041D",NegativeMediumSpace:"\u200B",NegativeThickSpace:"\u200B",NegativeThinSpace:"\u200B",NegativeVeryThinSpace:"\u200B",NestedGreaterGreater:"\u226B",NestedLessLess:"\u226A",NewLine:`
|
|
3
|
+
`,Nfr:"\u{1D511}",NoBreak:"\u2060",NonBreakingSpace:"\xA0",Nopf:"\u2115",Not:"\u2AEC",NotCongruent:"\u2262",NotCupCap:"\u226D",NotDoubleVerticalBar:"\u2226",NotElement:"\u2209",NotEqual:"\u2260",NotEqualTilde:"\u2242\u0338",NotExists:"\u2204",NotGreater:"\u226F",NotGreaterEqual:"\u2271",NotGreaterFullEqual:"\u2267\u0338",NotGreaterGreater:"\u226B\u0338",NotGreaterLess:"\u2279",NotGreaterSlantEqual:"\u2A7E\u0338",NotGreaterTilde:"\u2275",NotHumpDownHump:"\u224E\u0338",NotHumpEqual:"\u224F\u0338",NotLeftTriangle:"\u22EA",NotLeftTriangleBar:"\u29CF\u0338",NotLeftTriangleEqual:"\u22EC",NotLess:"\u226E",NotLessEqual:"\u2270",NotLessGreater:"\u2278",NotLessLess:"\u226A\u0338",NotLessSlantEqual:"\u2A7D\u0338",NotLessTilde:"\u2274",NotNestedGreaterGreater:"\u2AA2\u0338",NotNestedLessLess:"\u2AA1\u0338",NotPrecedes:"\u2280",NotPrecedesEqual:"\u2AAF\u0338",NotPrecedesSlantEqual:"\u22E0",NotReverseElement:"\u220C",NotRightTriangle:"\u22EB",NotRightTriangleBar:"\u29D0\u0338",NotRightTriangleEqual:"\u22ED",NotSquareSubset:"\u228F\u0338",NotSquareSubsetEqual:"\u22E2",NotSquareSuperset:"\u2290\u0338",NotSquareSupersetEqual:"\u22E3",NotSubset:"\u2282\u20D2",NotSubsetEqual:"\u2288",NotSucceeds:"\u2281",NotSucceedsEqual:"\u2AB0\u0338",NotSucceedsSlantEqual:"\u22E1",NotSucceedsTilde:"\u227F\u0338",NotSuperset:"\u2283\u20D2",NotSupersetEqual:"\u2289",NotTilde:"\u2241",NotTildeEqual:"\u2244",NotTildeFullEqual:"\u2247",NotTildeTilde:"\u2249",NotVerticalBar:"\u2224",Nscr:"\u{1D4A9}",Ntilde:"\xD1",Nu:"\u039D",OElig:"\u0152",Oacute:"\xD3",Ocirc:"\xD4",Ocy:"\u041E",Odblac:"\u0150",Ofr:"\u{1D512}",Ograve:"\xD2",Omacr:"\u014C",Omega:"\u03A9",Omicron:"\u039F",Oopf:"\u{1D546}",OpenCurlyDoubleQuote:"\u201C",OpenCurlyQuote:"\u2018",Or:"\u2A54",Oscr:"\u{1D4AA}",Oslash:"\xD8",Otilde:"\xD5",Otimes:"\u2A37",Ouml:"\xD6",OverBar:"\u203E",OverBrace:"\u23DE",OverBracket:"\u23B4",OverParenthesis:"\u23DC",PartialD:"\u2202",Pcy:"\u041F",Pfr:"\u{1D513}",Phi:"\u03A6",Pi:"\u03A0",PlusMinus:"\xB1",Poincareplane:"\u210C",Popf:"\u2119",Pr:"\u2ABB",Precedes:"\u227A",PrecedesEqual:"\u2AAF",PrecedesSlantEqual:"\u227C",PrecedesTilde:"\u227E",Prime:"\u2033",Product:"\u220F",Proportion:"\u2237",Proportional:"\u221D",Pscr:"\u{1D4AB}",Psi:"\u03A8",QUOT:'"',Qfr:"\u{1D514}",Qopf:"\u211A",Qscr:"\u{1D4AC}",RBarr:"\u2910",REG:"\xAE",Racute:"\u0154",Rang:"\u27EB",Rarr:"\u21A0",Rarrtl:"\u2916",Rcaron:"\u0158",Rcedil:"\u0156",Rcy:"\u0420",Re:"\u211C",ReverseElement:"\u220B",ReverseEquilibrium:"\u21CB",ReverseUpEquilibrium:"\u296F",Rfr:"\u211C",Rho:"\u03A1",RightAngleBracket:"\u27E9",RightArrow:"\u2192",RightArrowBar:"\u21E5",RightArrowLeftArrow:"\u21C4",RightCeiling:"\u2309",RightDoubleBracket:"\u27E7",RightDownTeeVector:"\u295D",RightDownVector:"\u21C2",RightDownVectorBar:"\u2955",RightFloor:"\u230B",RightTee:"\u22A2",RightTeeArrow:"\u21A6",RightTeeVector:"\u295B",RightTriangle:"\u22B3",RightTriangleBar:"\u29D0",RightTriangleEqual:"\u22B5",RightUpDownVector:"\u294F",RightUpTeeVector:"\u295C",RightUpVector:"\u21BE",RightUpVectorBar:"\u2954",RightVector:"\u21C0",RightVectorBar:"\u2953",Rightarrow:"\u21D2",Ropf:"\u211D",RoundImplies:"\u2970",Rrightarrow:"\u21DB",Rscr:"\u211B",Rsh:"\u21B1",RuleDelayed:"\u29F4",SHCHcy:"\u0429",SHcy:"\u0428",SOFTcy:"\u042C",Sacute:"\u015A",Sc:"\u2ABC",Scaron:"\u0160",Scedil:"\u015E",Scirc:"\u015C",Scy:"\u0421",Sfr:"\u{1D516}",ShortDownArrow:"\u2193",ShortLeftArrow:"\u2190",ShortRightArrow:"\u2192",ShortUpArrow:"\u2191",Sigma:"\u03A3",SmallCircle:"\u2218",Sopf:"\u{1D54A}",Sqrt:"\u221A",Square:"\u25A1",SquareIntersection:"\u2293",SquareSubset:"\u228F",SquareSubsetEqual:"\u2291",SquareSuperset:"\u2290",SquareSupersetEqual:"\u2292",SquareUnion:"\u2294",Sscr:"\u{1D4AE}",Star:"\u22C6",Sub:"\u22D0",Subset:"\u22D0",SubsetEqual:"\u2286",Succeeds:"\u227B",SucceedsEqual:"\u2AB0",SucceedsSlantEqual:"\u227D",SucceedsTilde:"\u227F",SuchThat:"\u220B",Sum:"\u2211",Sup:"\u22D1",Superset:"\u2283",SupersetEqual:"\u2287",Supset:"\u22D1",THORN:"\xDE",TRADE:"\u2122",TSHcy:"\u040B",TScy:"\u0426",Tab:" ",Tau:"\u03A4",Tcaron:"\u0164",Tcedil:"\u0162",Tcy:"\u0422",Tfr:"\u{1D517}",Therefore:"\u2234",Theta:"\u0398",ThickSpace:"\u205F\u200A",ThinSpace:"\u2009",Tilde:"\u223C",TildeEqual:"\u2243",TildeFullEqual:"\u2245",TildeTilde:"\u2248",Topf:"\u{1D54B}",TripleDot:"\u20DB",Tscr:"\u{1D4AF}",Tstrok:"\u0166",Uacute:"\xDA",Uarr:"\u219F",Uarrocir:"\u2949",Ubrcy:"\u040E",Ubreve:"\u016C",Ucirc:"\xDB",Ucy:"\u0423",Udblac:"\u0170",Ufr:"\u{1D518}",Ugrave:"\xD9",Umacr:"\u016A",UnderBar:"_",UnderBrace:"\u23DF",UnderBracket:"\u23B5",UnderParenthesis:"\u23DD",Union:"\u22C3",UnionPlus:"\u228E",Uogon:"\u0172",Uopf:"\u{1D54C}",UpArrow:"\u2191",UpArrowBar:"\u2912",UpArrowDownArrow:"\u21C5",UpDownArrow:"\u2195",UpEquilibrium:"\u296E",UpTee:"\u22A5",UpTeeArrow:"\u21A5",Uparrow:"\u21D1",Updownarrow:"\u21D5",UpperLeftArrow:"\u2196",UpperRightArrow:"\u2197",Upsi:"\u03D2",Upsilon:"\u03A5",Uring:"\u016E",Uscr:"\u{1D4B0}",Utilde:"\u0168",Uuml:"\xDC",VDash:"\u22AB",Vbar:"\u2AEB",Vcy:"\u0412",Vdash:"\u22A9",Vdashl:"\u2AE6",Vee:"\u22C1",Verbar:"\u2016",Vert:"\u2016",VerticalBar:"\u2223",VerticalLine:"|",VerticalSeparator:"\u2758",VerticalTilde:"\u2240",VeryThinSpace:"\u200A",Vfr:"\u{1D519}",Vopf:"\u{1D54D}",Vscr:"\u{1D4B1}",Vvdash:"\u22AA",Wcirc:"\u0174",Wedge:"\u22C0",Wfr:"\u{1D51A}",Wopf:"\u{1D54E}",Wscr:"\u{1D4B2}",Xfr:"\u{1D51B}",Xi:"\u039E",Xopf:"\u{1D54F}",Xscr:"\u{1D4B3}",YAcy:"\u042F",YIcy:"\u0407",YUcy:"\u042E",Yacute:"\xDD",Ycirc:"\u0176",Ycy:"\u042B",Yfr:"\u{1D51C}",Yopf:"\u{1D550}",Yscr:"\u{1D4B4}",Yuml:"\u0178",ZHcy:"\u0416",Zacute:"\u0179",Zcaron:"\u017D",Zcy:"\u0417",Zdot:"\u017B",ZeroWidthSpace:"\u200B",Zeta:"\u0396",Zfr:"\u2128",Zopf:"\u2124",Zscr:"\u{1D4B5}",aacute:"\xE1",abreve:"\u0103",ac:"\u223E",acE:"\u223E\u0333",acd:"\u223F",acirc:"\xE2",acute:"\xB4",acy:"\u0430",aelig:"\xE6",af:"\u2061",afr:"\u{1D51E}",agrave:"\xE0",alefsym:"\u2135",aleph:"\u2135",alpha:"\u03B1",amacr:"\u0101",amalg:"\u2A3F",amp:"&",and:"\u2227",andand:"\u2A55",andd:"\u2A5C",andslope:"\u2A58",andv:"\u2A5A",ang:"\u2220",ange:"\u29A4",angle:"\u2220",angmsd:"\u2221",angmsdaa:"\u29A8",angmsdab:"\u29A9",angmsdac:"\u29AA",angmsdad:"\u29AB",angmsdae:"\u29AC",angmsdaf:"\u29AD",angmsdag:"\u29AE",angmsdah:"\u29AF",angrt:"\u221F",angrtvb:"\u22BE",angrtvbd:"\u299D",angsph:"\u2222",angst:"\xC5",angzarr:"\u237C",aogon:"\u0105",aopf:"\u{1D552}",ap:"\u2248",apE:"\u2A70",apacir:"\u2A6F",ape:"\u224A",apid:"\u224B",apos:"'",approx:"\u2248",approxeq:"\u224A",aring:"\xE5",ascr:"\u{1D4B6}",ast:"*",asymp:"\u2248",asympeq:"\u224D",atilde:"\xE3",auml:"\xE4",awconint:"\u2233",awint:"\u2A11",bNot:"\u2AED",backcong:"\u224C",backepsilon:"\u03F6",backprime:"\u2035",backsim:"\u223D",backsimeq:"\u22CD",barvee:"\u22BD",barwed:"\u2305",barwedge:"\u2305",bbrk:"\u23B5",bbrktbrk:"\u23B6",bcong:"\u224C",bcy:"\u0431",bdquo:"\u201E",becaus:"\u2235",because:"\u2235",bemptyv:"\u29B0",bepsi:"\u03F6",bernou:"\u212C",beta:"\u03B2",beth:"\u2136",between:"\u226C",bfr:"\u{1D51F}",bigcap:"\u22C2",bigcirc:"\u25EF",bigcup:"\u22C3",bigodot:"\u2A00",bigoplus:"\u2A01",bigotimes:"\u2A02",bigsqcup:"\u2A06",bigstar:"\u2605",bigtriangledown:"\u25BD",bigtriangleup:"\u25B3",biguplus:"\u2A04",bigvee:"\u22C1",bigwedge:"\u22C0",bkarow:"\u290D",blacklozenge:"\u29EB",blacksquare:"\u25AA",blacktriangle:"\u25B4",blacktriangledown:"\u25BE",blacktriangleleft:"\u25C2",blacktriangleright:"\u25B8",blank:"\u2423",blk12:"\u2592",blk14:"\u2591",blk34:"\u2593",block:"\u2588",bne:"=\u20E5",bnequiv:"\u2261\u20E5",bnot:"\u2310",bopf:"\u{1D553}",bot:"\u22A5",bottom:"\u22A5",bowtie:"\u22C8",boxDL:"\u2557",boxDR:"\u2554",boxDl:"\u2556",boxDr:"\u2553",boxH:"\u2550",boxHD:"\u2566",boxHU:"\u2569",boxHd:"\u2564",boxHu:"\u2567",boxUL:"\u255D",boxUR:"\u255A",boxUl:"\u255C",boxUr:"\u2559",boxV:"\u2551",boxVH:"\u256C",boxVL:"\u2563",boxVR:"\u2560",boxVh:"\u256B",boxVl:"\u2562",boxVr:"\u255F",boxbox:"\u29C9",boxdL:"\u2555",boxdR:"\u2552",boxdl:"\u2510",boxdr:"\u250C",boxh:"\u2500",boxhD:"\u2565",boxhU:"\u2568",boxhd:"\u252C",boxhu:"\u2534",boxminus:"\u229F",boxplus:"\u229E",boxtimes:"\u22A0",boxuL:"\u255B",boxuR:"\u2558",boxul:"\u2518",boxur:"\u2514",boxv:"\u2502",boxvH:"\u256A",boxvL:"\u2561",boxvR:"\u255E",boxvh:"\u253C",boxvl:"\u2524",boxvr:"\u251C",bprime:"\u2035",breve:"\u02D8",brvbar:"\xA6",bscr:"\u{1D4B7}",bsemi:"\u204F",bsim:"\u223D",bsime:"\u22CD",bsol:"\\",bsolb:"\u29C5",bsolhsub:"\u27C8",bull:"\u2022",bullet:"\u2022",bump:"\u224E",bumpE:"\u2AAE",bumpe:"\u224F",bumpeq:"\u224F",cacute:"\u0107",cap:"\u2229",capand:"\u2A44",capbrcup:"\u2A49",capcap:"\u2A4B",capcup:"\u2A47",capdot:"\u2A40",caps:"\u2229\uFE00",caret:"\u2041",caron:"\u02C7",ccaps:"\u2A4D",ccaron:"\u010D",ccedil:"\xE7",ccirc:"\u0109",ccups:"\u2A4C",ccupssm:"\u2A50",cdot:"\u010B",cedil:"\xB8",cemptyv:"\u29B2",cent:"\xA2",centerdot:"\xB7",cfr:"\u{1D520}",chcy:"\u0447",check:"\u2713",checkmark:"\u2713",chi:"\u03C7",cir:"\u25CB",cirE:"\u29C3",circ:"\u02C6",circeq:"\u2257",circlearrowleft:"\u21BA",circlearrowright:"\u21BB",circledR:"\xAE",circledS:"\u24C8",circledast:"\u229B",circledcirc:"\u229A",circleddash:"\u229D",cire:"\u2257",cirfnint:"\u2A10",cirmid:"\u2AEF",cirscir:"\u29C2",clubs:"\u2663",clubsuit:"\u2663",colon:":",colone:"\u2254",coloneq:"\u2254",comma:",",commat:"@",comp:"\u2201",compfn:"\u2218",complement:"\u2201",complexes:"\u2102",cong:"\u2245",congdot:"\u2A6D",conint:"\u222E",copf:"\u{1D554}",coprod:"\u2210",copy:"\xA9",copysr:"\u2117",crarr:"\u21B5",cross:"\u2717",cscr:"\u{1D4B8}",csub:"\u2ACF",csube:"\u2AD1",csup:"\u2AD0",csupe:"\u2AD2",ctdot:"\u22EF",cudarrl:"\u2938",cudarrr:"\u2935",cuepr:"\u22DE",cuesc:"\u22DF",cularr:"\u21B6",cularrp:"\u293D",cup:"\u222A",cupbrcap:"\u2A48",cupcap:"\u2A46",cupcup:"\u2A4A",cupdot:"\u228D",cupor:"\u2A45",cups:"\u222A\uFE00",curarr:"\u21B7",curarrm:"\u293C",curlyeqprec:"\u22DE",curlyeqsucc:"\u22DF",curlyvee:"\u22CE",curlywedge:"\u22CF",curren:"\xA4",curvearrowleft:"\u21B6",curvearrowright:"\u21B7",cuvee:"\u22CE",cuwed:"\u22CF",cwconint:"\u2232",cwint:"\u2231",cylcty:"\u232D",dArr:"\u21D3",dHar:"\u2965",dagger:"\u2020",daleth:"\u2138",darr:"\u2193",dash:"\u2010",dashv:"\u22A3",dbkarow:"\u290F",dblac:"\u02DD",dcaron:"\u010F",dcy:"\u0434",dd:"\u2146",ddagger:"\u2021",ddarr:"\u21CA",ddotseq:"\u2A77",deg:"\xB0",delta:"\u03B4",demptyv:"\u29B1",dfisht:"\u297F",dfr:"\u{1D521}",dharl:"\u21C3",dharr:"\u21C2",diam:"\u22C4",diamond:"\u22C4",diamondsuit:"\u2666",diams:"\u2666",die:"\xA8",digamma:"\u03DD",disin:"\u22F2",div:"\xF7",divide:"\xF7",divideontimes:"\u22C7",divonx:"\u22C7",djcy:"\u0452",dlcorn:"\u231E",dlcrop:"\u230D",dollar:"$",dopf:"\u{1D555}",dot:"\u02D9",doteq:"\u2250",doteqdot:"\u2251",dotminus:"\u2238",dotplus:"\u2214",dotsquare:"\u22A1",doublebarwedge:"\u2306",downarrow:"\u2193",downdownarrows:"\u21CA",downharpoonleft:"\u21C3",downharpoonright:"\u21C2",drbkarow:"\u2910",drcorn:"\u231F",drcrop:"\u230C",dscr:"\u{1D4B9}",dscy:"\u0455",dsol:"\u29F6",dstrok:"\u0111",dtdot:"\u22F1",dtri:"\u25BF",dtrif:"\u25BE",duarr:"\u21F5",duhar:"\u296F",dwangle:"\u29A6",dzcy:"\u045F",dzigrarr:"\u27FF",eDDot:"\u2A77",eDot:"\u2251",eacute:"\xE9",easter:"\u2A6E",ecaron:"\u011B",ecir:"\u2256",ecirc:"\xEA",ecolon:"\u2255",ecy:"\u044D",edot:"\u0117",ee:"\u2147",efDot:"\u2252",efr:"\u{1D522}",eg:"\u2A9A",egrave:"\xE8",egs:"\u2A96",egsdot:"\u2A98",el:"\u2A99",elinters:"\u23E7",ell:"\u2113",els:"\u2A95",elsdot:"\u2A97",emacr:"\u0113",empty:"\u2205",emptyset:"\u2205",emptyv:"\u2205",emsp:"\u2003",emsp13:"\u2004",emsp14:"\u2005",eng:"\u014B",ensp:"\u2002",eogon:"\u0119",eopf:"\u{1D556}",epar:"\u22D5",eparsl:"\u29E3",eplus:"\u2A71",epsi:"\u03B5",epsilon:"\u03B5",epsiv:"\u03F5",eqcirc:"\u2256",eqcolon:"\u2255",eqsim:"\u2242",eqslantgtr:"\u2A96",eqslantless:"\u2A95",equals:"=",equest:"\u225F",equiv:"\u2261",equivDD:"\u2A78",eqvparsl:"\u29E5",erDot:"\u2253",erarr:"\u2971",escr:"\u212F",esdot:"\u2250",esim:"\u2242",eta:"\u03B7",eth:"\xF0",euml:"\xEB",euro:"\u20AC",excl:"!",exist:"\u2203",expectation:"\u2130",exponentiale:"\u2147",fallingdotseq:"\u2252",fcy:"\u0444",female:"\u2640",ffilig:"\uFB03",fflig:"\uFB00",ffllig:"\uFB04",ffr:"\u{1D523}",filig:"\uFB01",fjlig:"fj",flat:"\u266D",fllig:"\uFB02",fltns:"\u25B1",fnof:"\u0192",fopf:"\u{1D557}",forall:"\u2200",fork:"\u22D4",forkv:"\u2AD9",fpartint:"\u2A0D",frac12:"\xBD",frac13:"\u2153",frac14:"\xBC",frac15:"\u2155",frac16:"\u2159",frac18:"\u215B",frac23:"\u2154",frac25:"\u2156",frac34:"\xBE",frac35:"\u2157",frac38:"\u215C",frac45:"\u2158",frac56:"\u215A",frac58:"\u215D",frac78:"\u215E",frasl:"\u2044",frown:"\u2322",fscr:"\u{1D4BB}",gE:"\u2267",gEl:"\u2A8C",gacute:"\u01F5",gamma:"\u03B3",gammad:"\u03DD",gap:"\u2A86",gbreve:"\u011F",gcirc:"\u011D",gcy:"\u0433",gdot:"\u0121",ge:"\u2265",gel:"\u22DB",geq:"\u2265",geqq:"\u2267",geqslant:"\u2A7E",ges:"\u2A7E",gescc:"\u2AA9",gesdot:"\u2A80",gesdoto:"\u2A82",gesdotol:"\u2A84",gesl:"\u22DB\uFE00",gesles:"\u2A94",gfr:"\u{1D524}",gg:"\u226B",ggg:"\u22D9",gimel:"\u2137",gjcy:"\u0453",gl:"\u2277",glE:"\u2A92",gla:"\u2AA5",glj:"\u2AA4",gnE:"\u2269",gnap:"\u2A8A",gnapprox:"\u2A8A",gne:"\u2A88",gneq:"\u2A88",gneqq:"\u2269",gnsim:"\u22E7",gopf:"\u{1D558}",grave:"`",gscr:"\u210A",gsim:"\u2273",gsime:"\u2A8E",gsiml:"\u2A90",gt:">",gtcc:"\u2AA7",gtcir:"\u2A7A",gtdot:"\u22D7",gtlPar:"\u2995",gtquest:"\u2A7C",gtrapprox:"\u2A86",gtrarr:"\u2978",gtrdot:"\u22D7",gtreqless:"\u22DB",gtreqqless:"\u2A8C",gtrless:"\u2277",gtrsim:"\u2273",gvertneqq:"\u2269\uFE00",gvnE:"\u2269\uFE00",hArr:"\u21D4",hairsp:"\u200A",half:"\xBD",hamilt:"\u210B",hardcy:"\u044A",harr:"\u2194",harrcir:"\u2948",harrw:"\u21AD",hbar:"\u210F",hcirc:"\u0125",hearts:"\u2665",heartsuit:"\u2665",hellip:"\u2026",hercon:"\u22B9",hfr:"\u{1D525}",hksearow:"\u2925",hkswarow:"\u2926",hoarr:"\u21FF",homtht:"\u223B",hookleftarrow:"\u21A9",hookrightarrow:"\u21AA",hopf:"\u{1D559}",horbar:"\u2015",hscr:"\u{1D4BD}",hslash:"\u210F",hstrok:"\u0127",hybull:"\u2043",hyphen:"\u2010",iacute:"\xED",ic:"\u2063",icirc:"\xEE",icy:"\u0438",iecy:"\u0435",iexcl:"\xA1",iff:"\u21D4",ifr:"\u{1D526}",igrave:"\xEC",ii:"\u2148",iiiint:"\u2A0C",iiint:"\u222D",iinfin:"\u29DC",iiota:"\u2129",ijlig:"\u0133",imacr:"\u012B",image:"\u2111",imagline:"\u2110",imagpart:"\u2111",imath:"\u0131",imof:"\u22B7",imped:"\u01B5",in:"\u2208",incare:"\u2105",infin:"\u221E",infintie:"\u29DD",inodot:"\u0131",int:"\u222B",intcal:"\u22BA",integers:"\u2124",intercal:"\u22BA",intlarhk:"\u2A17",intprod:"\u2A3C",iocy:"\u0451",iogon:"\u012F",iopf:"\u{1D55A}",iota:"\u03B9",iprod:"\u2A3C",iquest:"\xBF",iscr:"\u{1D4BE}",isin:"\u2208",isinE:"\u22F9",isindot:"\u22F5",isins:"\u22F4",isinsv:"\u22F3",isinv:"\u2208",it:"\u2062",itilde:"\u0129",iukcy:"\u0456",iuml:"\xEF",jcirc:"\u0135",jcy:"\u0439",jfr:"\u{1D527}",jmath:"\u0237",jopf:"\u{1D55B}",jscr:"\u{1D4BF}",jsercy:"\u0458",jukcy:"\u0454",kappa:"\u03BA",kappav:"\u03F0",kcedil:"\u0137",kcy:"\u043A",kfr:"\u{1D528}",kgreen:"\u0138",khcy:"\u0445",kjcy:"\u045C",kopf:"\u{1D55C}",kscr:"\u{1D4C0}",lAarr:"\u21DA",lArr:"\u21D0",lAtail:"\u291B",lBarr:"\u290E",lE:"\u2266",lEg:"\u2A8B",lHar:"\u2962",lacute:"\u013A",laemptyv:"\u29B4",lagran:"\u2112",lambda:"\u03BB",lang:"\u27E8",langd:"\u2991",langle:"\u27E8",lap:"\u2A85",laquo:"\xAB",larr:"\u2190",larrb:"\u21E4",larrbfs:"\u291F",larrfs:"\u291D",larrhk:"\u21A9",larrlp:"\u21AB",larrpl:"\u2939",larrsim:"\u2973",larrtl:"\u21A2",lat:"\u2AAB",latail:"\u2919",late:"\u2AAD",lates:"\u2AAD\uFE00",lbarr:"\u290C",lbbrk:"\u2772",lbrace:"{",lbrack:"[",lbrke:"\u298B",lbrksld:"\u298F",lbrkslu:"\u298D",lcaron:"\u013E",lcedil:"\u013C",lceil:"\u2308",lcub:"{",lcy:"\u043B",ldca:"\u2936",ldquo:"\u201C",ldquor:"\u201E",ldrdhar:"\u2967",ldrushar:"\u294B",ldsh:"\u21B2",le:"\u2264",leftarrow:"\u2190",leftarrowtail:"\u21A2",leftharpoondown:"\u21BD",leftharpoonup:"\u21BC",leftleftarrows:"\u21C7",leftrightarrow:"\u2194",leftrightarrows:"\u21C6",leftrightharpoons:"\u21CB",leftrightsquigarrow:"\u21AD",leftthreetimes:"\u22CB",leg:"\u22DA",leq:"\u2264",leqq:"\u2266",leqslant:"\u2A7D",les:"\u2A7D",lescc:"\u2AA8",lesdot:"\u2A7F",lesdoto:"\u2A81",lesdotor:"\u2A83",lesg:"\u22DA\uFE00",lesges:"\u2A93",lessapprox:"\u2A85",lessdot:"\u22D6",lesseqgtr:"\u22DA",lesseqqgtr:"\u2A8B",lessgtr:"\u2276",lesssim:"\u2272",lfisht:"\u297C",lfloor:"\u230A",lfr:"\u{1D529}",lg:"\u2276",lgE:"\u2A91",lhard:"\u21BD",lharu:"\u21BC",lharul:"\u296A",lhblk:"\u2584",ljcy:"\u0459",ll:"\u226A",llarr:"\u21C7",llcorner:"\u231E",llhard:"\u296B",lltri:"\u25FA",lmidot:"\u0140",lmoust:"\u23B0",lmoustache:"\u23B0",lnE:"\u2268",lnap:"\u2A89",lnapprox:"\u2A89",lne:"\u2A87",lneq:"\u2A87",lneqq:"\u2268",lnsim:"\u22E6",loang:"\u27EC",loarr:"\u21FD",lobrk:"\u27E6",longleftarrow:"\u27F5",longleftrightarrow:"\u27F7",longmapsto:"\u27FC",longrightarrow:"\u27F6",looparrowleft:"\u21AB",looparrowright:"\u21AC",lopar:"\u2985",lopf:"\u{1D55D}",loplus:"\u2A2D",lotimes:"\u2A34",lowast:"\u2217",lowbar:"_",loz:"\u25CA",lozenge:"\u25CA",lozf:"\u29EB",lpar:"(",lparlt:"\u2993",lrarr:"\u21C6",lrcorner:"\u231F",lrhar:"\u21CB",lrhard:"\u296D",lrm:"\u200E",lrtri:"\u22BF",lsaquo:"\u2039",lscr:"\u{1D4C1}",lsh:"\u21B0",lsim:"\u2272",lsime:"\u2A8D",lsimg:"\u2A8F",lsqb:"[",lsquo:"\u2018",lsquor:"\u201A",lstrok:"\u0142",lt:"<",ltcc:"\u2AA6",ltcir:"\u2A79",ltdot:"\u22D6",lthree:"\u22CB",ltimes:"\u22C9",ltlarr:"\u2976",ltquest:"\u2A7B",ltrPar:"\u2996",ltri:"\u25C3",ltrie:"\u22B4",ltrif:"\u25C2",lurdshar:"\u294A",luruhar:"\u2966",lvertneqq:"\u2268\uFE00",lvnE:"\u2268\uFE00",mDDot:"\u223A",macr:"\xAF",male:"\u2642",malt:"\u2720",maltese:"\u2720",map:"\u21A6",mapsto:"\u21A6",mapstodown:"\u21A7",mapstoleft:"\u21A4",mapstoup:"\u21A5",marker:"\u25AE",mcomma:"\u2A29",mcy:"\u043C",mdash:"\u2014",measuredangle:"\u2221",mfr:"\u{1D52A}",mho:"\u2127",micro:"\xB5",mid:"\u2223",midast:"*",midcir:"\u2AF0",middot:"\xB7",minus:"\u2212",minusb:"\u229F",minusd:"\u2238",minusdu:"\u2A2A",mlcp:"\u2ADB",mldr:"\u2026",mnplus:"\u2213",models:"\u22A7",mopf:"\u{1D55E}",mp:"\u2213",mscr:"\u{1D4C2}",mstpos:"\u223E",mu:"\u03BC",multimap:"\u22B8",mumap:"\u22B8",nGg:"\u22D9\u0338",nGt:"\u226B\u20D2",nGtv:"\u226B\u0338",nLeftarrow:"\u21CD",nLeftrightarrow:"\u21CE",nLl:"\u22D8\u0338",nLt:"\u226A\u20D2",nLtv:"\u226A\u0338",nRightarrow:"\u21CF",nVDash:"\u22AF",nVdash:"\u22AE",nabla:"\u2207",nacute:"\u0144",nang:"\u2220\u20D2",nap:"\u2249",napE:"\u2A70\u0338",napid:"\u224B\u0338",napos:"\u0149",napprox:"\u2249",natur:"\u266E",natural:"\u266E",naturals:"\u2115",nbsp:"\xA0",nbump:"\u224E\u0338",nbumpe:"\u224F\u0338",ncap:"\u2A43",ncaron:"\u0148",ncedil:"\u0146",ncong:"\u2247",ncongdot:"\u2A6D\u0338",ncup:"\u2A42",ncy:"\u043D",ndash:"\u2013",ne:"\u2260",neArr:"\u21D7",nearhk:"\u2924",nearr:"\u2197",nearrow:"\u2197",nedot:"\u2250\u0338",nequiv:"\u2262",nesear:"\u2928",nesim:"\u2242\u0338",nexist:"\u2204",nexists:"\u2204",nfr:"\u{1D52B}",ngE:"\u2267\u0338",nge:"\u2271",ngeq:"\u2271",ngeqq:"\u2267\u0338",ngeqslant:"\u2A7E\u0338",nges:"\u2A7E\u0338",ngsim:"\u2275",ngt:"\u226F",ngtr:"\u226F",nhArr:"\u21CE",nharr:"\u21AE",nhpar:"\u2AF2",ni:"\u220B",nis:"\u22FC",nisd:"\u22FA",niv:"\u220B",njcy:"\u045A",nlArr:"\u21CD",nlE:"\u2266\u0338",nlarr:"\u219A",nldr:"\u2025",nle:"\u2270",nleftarrow:"\u219A",nleftrightarrow:"\u21AE",nleq:"\u2270",nleqq:"\u2266\u0338",nleqslant:"\u2A7D\u0338",nles:"\u2A7D\u0338",nless:"\u226E",nlsim:"\u2274",nlt:"\u226E",nltri:"\u22EA",nltrie:"\u22EC",nmid:"\u2224",nopf:"\u{1D55F}",not:"\xAC",notin:"\u2209",notinE:"\u22F9\u0338",notindot:"\u22F5\u0338",notinva:"\u2209",notinvb:"\u22F7",notinvc:"\u22F6",notni:"\u220C",notniva:"\u220C",notnivb:"\u22FE",notnivc:"\u22FD",npar:"\u2226",nparallel:"\u2226",nparsl:"\u2AFD\u20E5",npart:"\u2202\u0338",npolint:"\u2A14",npr:"\u2280",nprcue:"\u22E0",npre:"\u2AAF\u0338",nprec:"\u2280",npreceq:"\u2AAF\u0338",nrArr:"\u21CF",nrarr:"\u219B",nrarrc:"\u2933\u0338",nrarrw:"\u219D\u0338",nrightarrow:"\u219B",nrtri:"\u22EB",nrtrie:"\u22ED",nsc:"\u2281",nsccue:"\u22E1",nsce:"\u2AB0\u0338",nscr:"\u{1D4C3}",nshortmid:"\u2224",nshortparallel:"\u2226",nsim:"\u2241",nsime:"\u2244",nsimeq:"\u2244",nsmid:"\u2224",nspar:"\u2226",nsqsube:"\u22E2",nsqsupe:"\u22E3",nsub:"\u2284",nsubE:"\u2AC5\u0338",nsube:"\u2288",nsubset:"\u2282\u20D2",nsubseteq:"\u2288",nsubseteqq:"\u2AC5\u0338",nsucc:"\u2281",nsucceq:"\u2AB0\u0338",nsup:"\u2285",nsupE:"\u2AC6\u0338",nsupe:"\u2289",nsupset:"\u2283\u20D2",nsupseteq:"\u2289",nsupseteqq:"\u2AC6\u0338",ntgl:"\u2279",ntilde:"\xF1",ntlg:"\u2278",ntriangleleft:"\u22EA",ntrianglelefteq:"\u22EC",ntriangleright:"\u22EB",ntrianglerighteq:"\u22ED",nu:"\u03BD",num:"#",numero:"\u2116",numsp:"\u2007",nvDash:"\u22AD",nvHarr:"\u2904",nvap:"\u224D\u20D2",nvdash:"\u22AC",nvge:"\u2265\u20D2",nvgt:">\u20D2",nvinfin:"\u29DE",nvlArr:"\u2902",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvltrie:"\u22B4\u20D2",nvrArr:"\u2903",nvrtrie:"\u22B5\u20D2",nvsim:"\u223C\u20D2",nwArr:"\u21D6",nwarhk:"\u2923",nwarr:"\u2196",nwarrow:"\u2196",nwnear:"\u2927",oS:"\u24C8",oacute:"\xF3",oast:"\u229B",ocir:"\u229A",ocirc:"\xF4",ocy:"\u043E",odash:"\u229D",odblac:"\u0151",odiv:"\u2A38",odot:"\u2299",odsold:"\u29BC",oelig:"\u0153",ofcir:"\u29BF",ofr:"\u{1D52C}",ogon:"\u02DB",ograve:"\xF2",ogt:"\u29C1",ohbar:"\u29B5",ohm:"\u03A9",oint:"\u222E",olarr:"\u21BA",olcir:"\u29BE",olcross:"\u29BB",oline:"\u203E",olt:"\u29C0",omacr:"\u014D",omega:"\u03C9",omicron:"\u03BF",omid:"\u29B6",ominus:"\u2296",oopf:"\u{1D560}",opar:"\u29B7",operp:"\u29B9",oplus:"\u2295",or:"\u2228",orarr:"\u21BB",ord:"\u2A5D",order:"\u2134",orderof:"\u2134",ordf:"\xAA",ordm:"\xBA",origof:"\u22B6",oror:"\u2A56",orslope:"\u2A57",orv:"\u2A5B",oscr:"\u2134",oslash:"\xF8",osol:"\u2298",otilde:"\xF5",otimes:"\u2297",otimesas:"\u2A36",ouml:"\xF6",ovbar:"\u233D",par:"\u2225",para:"\xB6",parallel:"\u2225",parsim:"\u2AF3",parsl:"\u2AFD",part:"\u2202",pcy:"\u043F",percnt:"%",period:".",permil:"\u2030",perp:"\u22A5",pertenk:"\u2031",pfr:"\u{1D52D}",phi:"\u03C6",phiv:"\u03D5",phmmat:"\u2133",phone:"\u260E",pi:"\u03C0",pitchfork:"\u22D4",piv:"\u03D6",planck:"\u210F",planckh:"\u210E",plankv:"\u210F",plus:"+",plusacir:"\u2A23",plusb:"\u229E",pluscir:"\u2A22",plusdo:"\u2214",plusdu:"\u2A25",pluse:"\u2A72",plusmn:"\xB1",plussim:"\u2A26",plustwo:"\u2A27",pm:"\xB1",pointint:"\u2A15",popf:"\u{1D561}",pound:"\xA3",pr:"\u227A",prE:"\u2AB3",prap:"\u2AB7",prcue:"\u227C",pre:"\u2AAF",prec:"\u227A",precapprox:"\u2AB7",preccurlyeq:"\u227C",preceq:"\u2AAF",precnapprox:"\u2AB9",precneqq:"\u2AB5",precnsim:"\u22E8",precsim:"\u227E",prime:"\u2032",primes:"\u2119",prnE:"\u2AB5",prnap:"\u2AB9",prnsim:"\u22E8",prod:"\u220F",profalar:"\u232E",profline:"\u2312",profsurf:"\u2313",prop:"\u221D",propto:"\u221D",prsim:"\u227E",prurel:"\u22B0",pscr:"\u{1D4C5}",psi:"\u03C8",puncsp:"\u2008",qfr:"\u{1D52E}",qint:"\u2A0C",qopf:"\u{1D562}",qprime:"\u2057",qscr:"\u{1D4C6}",quaternions:"\u210D",quatint:"\u2A16",quest:"?",questeq:"\u225F",quot:'"',rAarr:"\u21DB",rArr:"\u21D2",rAtail:"\u291C",rBarr:"\u290F",rHar:"\u2964",race:"\u223D\u0331",racute:"\u0155",radic:"\u221A",raemptyv:"\u29B3",rang:"\u27E9",rangd:"\u2992",range:"\u29A5",rangle:"\u27E9",raquo:"\xBB",rarr:"\u2192",rarrap:"\u2975",rarrb:"\u21E5",rarrbfs:"\u2920",rarrc:"\u2933",rarrfs:"\u291E",rarrhk:"\u21AA",rarrlp:"\u21AC",rarrpl:"\u2945",rarrsim:"\u2974",rarrtl:"\u21A3",rarrw:"\u219D",ratail:"\u291A",ratio:"\u2236",rationals:"\u211A",rbarr:"\u290D",rbbrk:"\u2773",rbrace:"}",rbrack:"]",rbrke:"\u298C",rbrksld:"\u298E",rbrkslu:"\u2990",rcaron:"\u0159",rcedil:"\u0157",rceil:"\u2309",rcub:"}",rcy:"\u0440",rdca:"\u2937",rdldhar:"\u2969",rdquo:"\u201D",rdquor:"\u201D",rdsh:"\u21B3",real:"\u211C",realine:"\u211B",realpart:"\u211C",reals:"\u211D",rect:"\u25AD",reg:"\xAE",rfisht:"\u297D",rfloor:"\u230B",rfr:"\u{1D52F}",rhard:"\u21C1",rharu:"\u21C0",rharul:"\u296C",rho:"\u03C1",rhov:"\u03F1",rightarrow:"\u2192",rightarrowtail:"\u21A3",rightharpoondown:"\u21C1",rightharpoonup:"\u21C0",rightleftarrows:"\u21C4",rightleftharpoons:"\u21CC",rightrightarrows:"\u21C9",rightsquigarrow:"\u219D",rightthreetimes:"\u22CC",ring:"\u02DA",risingdotseq:"\u2253",rlarr:"\u21C4",rlhar:"\u21CC",rlm:"\u200F",rmoust:"\u23B1",rmoustache:"\u23B1",rnmid:"\u2AEE",roang:"\u27ED",roarr:"\u21FE",robrk:"\u27E7",ropar:"\u2986",ropf:"\u{1D563}",roplus:"\u2A2E",rotimes:"\u2A35",rpar:")",rpargt:"\u2994",rppolint:"\u2A12",rrarr:"\u21C9",rsaquo:"\u203A",rscr:"\u{1D4C7}",rsh:"\u21B1",rsqb:"]",rsquo:"\u2019",rsquor:"\u2019",rthree:"\u22CC",rtimes:"\u22CA",rtri:"\u25B9",rtrie:"\u22B5",rtrif:"\u25B8",rtriltri:"\u29CE",ruluhar:"\u2968",rx:"\u211E",sacute:"\u015B",sbquo:"\u201A",sc:"\u227B",scE:"\u2AB4",scap:"\u2AB8",scaron:"\u0161",sccue:"\u227D",sce:"\u2AB0",scedil:"\u015F",scirc:"\u015D",scnE:"\u2AB6",scnap:"\u2ABA",scnsim:"\u22E9",scpolint:"\u2A13",scsim:"\u227F",scy:"\u0441",sdot:"\u22C5",sdotb:"\u22A1",sdote:"\u2A66",seArr:"\u21D8",searhk:"\u2925",searr:"\u2198",searrow:"\u2198",sect:"\xA7",semi:";",seswar:"\u2929",setminus:"\u2216",setmn:"\u2216",sext:"\u2736",sfr:"\u{1D530}",sfrown:"\u2322",sharp:"\u266F",shchcy:"\u0449",shcy:"\u0448",shortmid:"\u2223",shortparallel:"\u2225",shy:"\xAD",sigma:"\u03C3",sigmaf:"\u03C2",sigmav:"\u03C2",sim:"\u223C",simdot:"\u2A6A",sime:"\u2243",simeq:"\u2243",simg:"\u2A9E",simgE:"\u2AA0",siml:"\u2A9D",simlE:"\u2A9F",simne:"\u2246",simplus:"\u2A24",simrarr:"\u2972",slarr:"\u2190",smallsetminus:"\u2216",smashp:"\u2A33",smeparsl:"\u29E4",smid:"\u2223",smile:"\u2323",smt:"\u2AAA",smte:"\u2AAC",smtes:"\u2AAC\uFE00",softcy:"\u044C",sol:"/",solb:"\u29C4",solbar:"\u233F",sopf:"\u{1D564}",spades:"\u2660",spadesuit:"\u2660",spar:"\u2225",sqcap:"\u2293",sqcaps:"\u2293\uFE00",sqcup:"\u2294",sqcups:"\u2294\uFE00",sqsub:"\u228F",sqsube:"\u2291",sqsubset:"\u228F",sqsubseteq:"\u2291",sqsup:"\u2290",sqsupe:"\u2292",sqsupset:"\u2290",sqsupseteq:"\u2292",squ:"\u25A1",square:"\u25A1",squarf:"\u25AA",squf:"\u25AA",srarr:"\u2192",sscr:"\u{1D4C8}",ssetmn:"\u2216",ssmile:"\u2323",sstarf:"\u22C6",star:"\u2606",starf:"\u2605",straightepsilon:"\u03F5",straightphi:"\u03D5",strns:"\xAF",sub:"\u2282",subE:"\u2AC5",subdot:"\u2ABD",sube:"\u2286",subedot:"\u2AC3",submult:"\u2AC1",subnE:"\u2ACB",subne:"\u228A",subplus:"\u2ABF",subrarr:"\u2979",subset:"\u2282",subseteq:"\u2286",subseteqq:"\u2AC5",subsetneq:"\u228A",subsetneqq:"\u2ACB",subsim:"\u2AC7",subsub:"\u2AD5",subsup:"\u2AD3",succ:"\u227B",succapprox:"\u2AB8",succcurlyeq:"\u227D",succeq:"\u2AB0",succnapprox:"\u2ABA",succneqq:"\u2AB6",succnsim:"\u22E9",succsim:"\u227F",sum:"\u2211",sung:"\u266A",sup:"\u2283",sup1:"\xB9",sup2:"\xB2",sup3:"\xB3",supE:"\u2AC6",supdot:"\u2ABE",supdsub:"\u2AD8",supe:"\u2287",supedot:"\u2AC4",suphsol:"\u27C9",suphsub:"\u2AD7",suplarr:"\u297B",supmult:"\u2AC2",supnE:"\u2ACC",supne:"\u228B",supplus:"\u2AC0",supset:"\u2283",supseteq:"\u2287",supseteqq:"\u2AC6",supsetneq:"\u228B",supsetneqq:"\u2ACC",supsim:"\u2AC8",supsub:"\u2AD4",supsup:"\u2AD6",swArr:"\u21D9",swarhk:"\u2926",swarr:"\u2199",swarrow:"\u2199",swnwar:"\u292A",szlig:"\xDF",target:"\u2316",tau:"\u03C4",tbrk:"\u23B4",tcaron:"\u0165",tcedil:"\u0163",tcy:"\u0442",tdot:"\u20DB",telrec:"\u2315",tfr:"\u{1D531}",there4:"\u2234",therefore:"\u2234",theta:"\u03B8",thetasym:"\u03D1",thetav:"\u03D1",thickapprox:"\u2248",thicksim:"\u223C",thinsp:"\u2009",thkap:"\u2248",thksim:"\u223C",thorn:"\xFE",tilde:"\u02DC",times:"\xD7",timesb:"\u22A0",timesbar:"\u2A31",timesd:"\u2A30",tint:"\u222D",toea:"\u2928",top:"\u22A4",topbot:"\u2336",topcir:"\u2AF1",topf:"\u{1D565}",topfork:"\u2ADA",tosa:"\u2929",tprime:"\u2034",trade:"\u2122",triangle:"\u25B5",triangledown:"\u25BF",triangleleft:"\u25C3",trianglelefteq:"\u22B4",triangleq:"\u225C",triangleright:"\u25B9",trianglerighteq:"\u22B5",tridot:"\u25EC",trie:"\u225C",triminus:"\u2A3A",triplus:"\u2A39",trisb:"\u29CD",tritime:"\u2A3B",trpezium:"\u23E2",tscr:"\u{1D4C9}",tscy:"\u0446",tshcy:"\u045B",tstrok:"\u0167",twixt:"\u226C",twoheadleftarrow:"\u219E",twoheadrightarrow:"\u21A0",uArr:"\u21D1",uHar:"\u2963",uacute:"\xFA",uarr:"\u2191",ubrcy:"\u045E",ubreve:"\u016D",ucirc:"\xFB",ucy:"\u0443",udarr:"\u21C5",udblac:"\u0171",udhar:"\u296E",ufisht:"\u297E",ufr:"\u{1D532}",ugrave:"\xF9",uharl:"\u21BF",uharr:"\u21BE",uhblk:"\u2580",ulcorn:"\u231C",ulcorner:"\u231C",ulcrop:"\u230F",ultri:"\u25F8",umacr:"\u016B",uml:"\xA8",uogon:"\u0173",uopf:"\u{1D566}",uparrow:"\u2191",updownarrow:"\u2195",upharpoonleft:"\u21BF",upharpoonright:"\u21BE",uplus:"\u228E",upsi:"\u03C5",upsih:"\u03D2",upsilon:"\u03C5",upuparrows:"\u21C8",urcorn:"\u231D",urcorner:"\u231D",urcrop:"\u230E",uring:"\u016F",urtri:"\u25F9",uscr:"\u{1D4CA}",utdot:"\u22F0",utilde:"\u0169",utri:"\u25B5",utrif:"\u25B4",uuarr:"\u21C8",uuml:"\xFC",uwangle:"\u29A7",vArr:"\u21D5",vBar:"\u2AE8",vBarv:"\u2AE9",vDash:"\u22A8",vangrt:"\u299C",varepsilon:"\u03F5",varkappa:"\u03F0",varnothing:"\u2205",varphi:"\u03D5",varpi:"\u03D6",varpropto:"\u221D",varr:"\u2195",varrho:"\u03F1",varsigma:"\u03C2",varsubsetneq:"\u228A\uFE00",varsubsetneqq:"\u2ACB\uFE00",varsupsetneq:"\u228B\uFE00",varsupsetneqq:"\u2ACC\uFE00",vartheta:"\u03D1",vartriangleleft:"\u22B2",vartriangleright:"\u22B3",vcy:"\u0432",vdash:"\u22A2",vee:"\u2228",veebar:"\u22BB",veeeq:"\u225A",vellip:"\u22EE",verbar:"|",vert:"|",vfr:"\u{1D533}",vltri:"\u22B2",vnsub:"\u2282\u20D2",vnsup:"\u2283\u20D2",vopf:"\u{1D567}",vprop:"\u221D",vrtri:"\u22B3",vscr:"\u{1D4CB}",vsubnE:"\u2ACB\uFE00",vsubne:"\u228A\uFE00",vsupnE:"\u2ACC\uFE00",vsupne:"\u228B\uFE00",vzigzag:"\u299A",wcirc:"\u0175",wedbar:"\u2A5F",wedge:"\u2227",wedgeq:"\u2259",weierp:"\u2118",wfr:"\u{1D534}",wopf:"\u{1D568}",wp:"\u2118",wr:"\u2240",wreath:"\u2240",wscr:"\u{1D4CC}",xcap:"\u22C2",xcirc:"\u25EF",xcup:"\u22C3",xdtri:"\u25BD",xfr:"\u{1D535}",xhArr:"\u27FA",xharr:"\u27F7",xi:"\u03BE",xlArr:"\u27F8",xlarr:"\u27F5",xmap:"\u27FC",xnis:"\u22FB",xodot:"\u2A00",xopf:"\u{1D569}",xoplus:"\u2A01",xotime:"\u2A02",xrArr:"\u27F9",xrarr:"\u27F6",xscr:"\u{1D4CD}",xsqcup:"\u2A06",xuplus:"\u2A04",xutri:"\u25B3",xvee:"\u22C1",xwedge:"\u22C0",yacute:"\xFD",yacy:"\u044F",ycirc:"\u0177",ycy:"\u044B",yen:"\xA5",yfr:"\u{1D536}",yicy:"\u0457",yopf:"\u{1D56A}",yscr:"\u{1D4CE}",yucy:"\u044E",yuml:"\xFF",zacute:"\u017A",zcaron:"\u017E",zcy:"\u0437",zdot:"\u017C",zeetrf:"\u2128",zeta:"\u03B6",zfr:"\u{1D537}",zhcy:"\u0436",zigrarr:"\u21DD",zopf:"\u{1D56B}",zscr:"\u{1D4CF}",zwj:"\u200D",zwnj:"\u200C"};function T(e){let t=/^\uFEFF?---[^\S\r\n]*\r?\n/.exec(e);if(!t)return[{text:e,offset:0}];let r=e.slice(t[0].length),n=/^---[^\S\r\n]*(?:\r?\n|$)/m.exec(r);if(!n)return[{text:e,offset:0}];let s=t[0].length+n.index,a=s+n[0].length;return[{text:e.slice(a),offset:a},{text:e.slice(t[0].length,s),offset:t[0].length}]}var X=e=>e.replace(/[‘’]/g,"'").replace(/[“”]/g,'"').replace(/\s+/g," ").trim();function ut(e,t,r=!1){let n=T(e),s=r?a=>a:X;return n.find(a=>t.some(i=>i&&s(i)&&s(a.text).includes(s(i))))??n[0]??{text:e,offset:0}}function ye(e,t){let r=X(t??"");if(!r)return 0;let n=X(e),s=0,a=n.indexOf(r);for(;a>=0;)s++,a=n.indexOf(r,a+1);return s}function $(e){let t=T(e)[1];if(!t)return[];let r=[...t.text.matchAll(/[^\r\n]*(?:\r?\n|$)/g)],n=[],s,a=0;for(let i of r){let u=i[0].replace(/\r?\n$/,""),c=/^(description|summary|takeaways):\s*(.*)$/.exec(u);c?(s=c[1],a=0):/^\S/.test(u)&&!u.startsWith("#")&&(s=void 0);let l,o,d;if(c&&s!=="takeaways")l=c[2],o=u.length-l.length,d={kind:"meta",field:s};else if(s==="takeaways"){let f=/^\s+-\s+(.*)$/.exec(u);if(!f)continue;l=f[1],o=u.length-l.length,d={kind:"meta",field:s,index:a++}}else continue;if(!l||/^[>|&*!\[{]/.test(l))continue;let p="";if(l[0]==='"'||l[0]==="'"){p=l[0];let f=p==='"'?/^"(?:[^"\\]|\\.)*"/.exec(l)?.[0].length:/^'(?:[^']|'')*'/.exec(l)?.[0].length;if(!f||!/^\s*(?:#.*)?$/.test(l.slice(f)))continue;l=l.slice(1,f-1),o++}else l=l.replace(/\s+#.*$/,"").trimEnd();n.push({target:d,text:l,offset:t.offset+i.index+o,quote:p})}return n}var ot=(e,t)=>e?.kind===t?.kind&&e?.field===t?.field&&e?.index===t?.index;function ct(e,t){let r=$(e).filter(n=>ot(n.target,t));if(r.length!==1||!r[0])throw Error("Metadata field is missing or ambiguous.");return r[0]}function ve(e,t){if(t.target)return t.target;let r=[t.match,t.before,t.after,t.proposed].filter(Boolean),n=T(e);if(!n[1]||r.some(a=>ye(n[0].text,a)))return;let s=$(e).filter(a=>a.target.field==="description"&&r.some(i=>ye(a.text,i)));return s.length===1?s[0].target:void 0}function Wr(e,t,r=!1){let n=ve(e,t);return n?ct(e,n):t.edits?.length?T(e)[0]??{text:e,offset:0}:ut(e,[t.match,t.before,t.proposed,t.after],r)}function Kr(e,t){if(ve(e,t))return[];let r=t.before??t.match;return r?$(e).filter(n=>{let s=n.text.indexOf(r);return s>=0&&n.text.indexOf(r,s+1)<0}).map(n=>n.target):[]}var xe=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");function dt(e,t){let r="",n=[],s=[];for(let a=0;a<e.length;){let i=/^&(#x[\da-f]+|#\d+|[a-z][\da-z]+);/i.exec(e.slice(a)),u;if(i){let l=i[1],o=l[0]==="#"?l[1]?.toLowerCase()==="x"?parseInt(l.slice(2),16):parseInt(l.slice(1),10):NaN;u=Number.isFinite(o)&&o>0&&o<=1114111?String.fromCodePoint(o):we[l]}let c=u&&i?i[0].length:1;u??=e[a],r+=u;for(let l=0;l<u.length;l++)n.push(t+a),s.push(t+a+c);a+=c}return{text:r,starts:n,ends:s}}function lt(e,t){let r=[],n=/<!--[\s\S]*?(?:-->|$)|<(script|style|template)\b[^>]*>[\s\S]*?(?:<\/\1\s*>|$)|<![^>]*>|<\/?[a-z][^>"']*(?:(?:"[^"]*"|'[^']*')[^>"']*)*>|{{[\s\S]*?}}|{%[\s\S]*?%}|{#[\s\S]*?#}/gi,s=0,a=(i,u,c)=>{u>i&&r.push({start:i,end:u,...dt(e.slice(i,u),i),kind:"body",editable:c})};for(let i of e.matchAll(n)){let u=i.index;!t&&/^\{/.test(i[0])||(a(s,u,!0),/^\{/.test(i[0])&&a(u,u+i[0].length,!1),s=u+i[0].length)}return a(s,e.length,!0),r}var ke={regions(e){let t=T(e)[0];return[{start:t.offset,end:t.offset+t.text.length,text:t.text,kind:"body",editable:!0},...$(e).map(r=>({start:r.offset,end:r.offset+r.text.length,text:r.text,kind:"meta",field:r.target.field,editable:!0}))]},apply(e,t,r){if(!this.regions(e).some(n=>n.editable&&t.start>=n.start&&t.end<=n.end))throw new Error("This source span is not editable.");return e.slice(0,t.start)+r+e.slice(t.end)}};function Se(e){return{regions:t=>lt(t,e),apply(t,r,n,s){if(!this.regions(t).some(i=>i.editable&&r.start>=i.start&&r.end<=i.end))throw new Error("This match crosses markup or a template expression and cannot be edited.");let a=s?.sourceText?n:e?xe(n).replace(/\{/g,"{").replace(/\}/g,"}"):xe(n);return t.slice(0,r.start)+a+t.slice(r.end)}}}var pt={markdown:ke,mdx:ke,html:Se(!1),jinja:Se(!0)};function ft(e){return pt[e]}function qe(e){return/\.mdx$/i.test(e)?"mdx":/\.md$/i.test(e)?"markdown":/\.html?$/i.test(e)?"html":"jinja"}function Re(e,t,r){let s=(i=>i.replace(/[‘’]/g,"'").replace(/[“”]/g,'"').replace(/\s+/g," ").trim())(t);if(!s)throw new Error("The match is empty.");let a=[];for(let i of ft(r).regions(e).filter(u=>u.editable&&u.kind==="body")){let u="",c=[],l=[];for(let d=0;d<i.text.length;d++){let p=i.text[d].replace(/[‘’]/g,"'").replace(/[“”]/g,'"');if(/\s/.test(p)&&(p=" "),p===" "&&u.endsWith(" ")){l[l.length-1]=i.ends?.[d]??i.start+d+1;continue}u+=p,c.push(i.starts?.[d]??i.start+d),l.push(i.ends?.[d]??i.start+d+1)}let o=u.indexOf(s);for(;o>=0;)a.push({start:c[o],end:l[o+s.length-1]}),o=u.indexOf(s,o+1)}if(a.length!==1)throw new Error(a.length?"The source match is ambiguous (more than once).":"This match is unavailable or crosses markup or a template expression and cannot be edited.");return a[0]}var Ee=/(?:s|x|z|ch|sh)$/,V=/[^aeiou]y$/;function mt(e){let t=Ee.test(e)?e+"es":V.test(e)?e.slice(0,-1)+"ies":e+"s",r=e.endsWith("e")?e+"d":V.test(e)?e.slice(0,-1)+"ied":e+"ed",n=e.endsWith("ie")?e.slice(0,-2)+"ying":/(?:ee|ye|oe)$/.test(e)?e+"ing":e.endsWith("e")?e.slice(0,-1)+"ing":e+"ing";return[e,t,r,n]}var gt=e=>[e,Ee.test(e)?e+"es":V.test(e)?e.slice(0,-1)+"ies":e+"s"];function ht(e){let t=e.endsWith("le")?e.slice(0,-1)+"y":e.endsWith("ic")?e+"ally":V.test(e)?e.slice(0,-1)+"ily":e+"ly";return[e,t]}function De(e){let t=e.term.split(" "),r;return e.pos==="verb"?r=mt(t[0]).map(n=>[n,...t.slice(1)].join(" ")):e.pos==="noun"?r=gt(t.at(-1)).map(n=>[...t.slice(0,-1),n].join(" ")):e.pos==="adj"?r=ht(e.term):r=[e.term],[...new Set([...r,...e.forms??[]])]}var bt=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),wt=e=>bt(e).replace(/'/g,"['\u2019]").replace(/ /g,"[-\\s]+"),je=e=>e.toLowerCase().replace(/[’]/g,"'").replace(/[-\s]+/g," ");function Q(e){let t=new Map;for(let s of e)for(let a of De(s))t.set(je(a),s);let n=[...t.keys()].sort((s,a)=>a.length-s.length).map(wt).join("|");return{regex:new RegExp(`(?<![\\p{L}\\p{N}'\u2019-])(?:${n})(?![\\p{L}\\p{N}-])`,"giu"),lookup:t}}function ee(e,t){let r=[];for(let n of e.matchAll(t.regex)){let s=t.lookup.get(je(n[0]));s&&r.push({start:n.index,end:n.index+n[0].length,text:n[0],term:s})}return r}function N(e){if(!e.startsWith(`---
|
|
4
|
+
`))return 0;let t=e.indexOf(`
|
|
5
|
+
---`,3);if(t<0)return 0;let r=e.indexOf(`
|
|
6
|
+
`,t+4);return r<0?e.length:r+1}var H=/^(\s*)(?:[-*+]|\d+[.)])\s+/,Ae=/^(#{1,6})\s+/,Le=/^\s*>\s?/;function yt(e,t){let r=[],n=t;for(;n<e.length;){let s=e.indexOf(`
|
|
7
|
+
`,n),a=s<0?e.length:s;r.push({start:n,end:a,text:e.slice(n,a)}),n=a+1}return r}function vt(e,t,r,n,s){let a="",i=[],u=e.slice(t,r),c=new Set(s),l=(o,d)=>{for(let p=o;p<d;p++)c.add(t+p)};for(let o of u.matchAll(/!\[[^\]]*\]\([^)]*\)/g))l(o.index,o.index+o[0].length);for(let o of u.matchAll(/\[\^[^\]]+\]/g))l(o.index,o.index+o[0].length);for(let o of u.matchAll(/<\/?[A-Za-z][^<>]*>/g))l(o.index,o.index+o[0].length);for(let o of u.matchAll(/\{[^{}\n]*\}/g))l(o.index,o.index+o[0].length);for(let o of u.matchAll(/\[((?:[^\[\]]|\[[^\]]*\])*)\]\(((?:[^()\s]|\([^()]*\))*)\)/g))l(o.index,o.index+1),l(o.index+1+o[1].length,o.index+o[0].length);for(let o=0;o<u.length;o++){let d=t+o,p=u[o];if(!c.has(d)){if(p==="\\"&&o+1<u.length&&/[!-/:-@[-`{-~]/.test(u[o+1])){c.add(d);continue}if(p==="`"||p==="*"||p==="~"){c.add(d);continue}if(p==="_"&&!(/[\p{L}\p{N}]/u.test(u[o-1]??"")&&/[\p{L}\p{N}]/u.test(u[o+1]??""))){c.add(d);continue}a+=p===`
|
|
8
|
+
`||p===" "?" ":p,i.push(d)}}return{kind:n,text:a,map:i,start:t,end:r,excluded:c}}function z(e){let t=[],r,n,s=[],a=()=>{let i=s;if(s=[],!i.length)return;let u=i[0].text.trim();if(n){i.some(d=>d.text.includes(`</${n}>`)||/^\s*\/>/.test(d.text)||/\/>\s*$/.test(d.text))&&(n=void 0);return}if(/^(import|export)\s/.test(u)||u.startsWith("|")||/^[\[\]{}()]/.test(u))return;if(u.startsWith("<")||u.startsWith("{")){let d=/^<([A-Z][\w.]*)/.exec(u)?.[1],p=i.map(f=>f.text).join(`
|
|
9
|
+
`);d&&!p.includes(`</${d}>`)&&!/\/>\s*$/.test(p.trim())&&(n=d);return}let c=[],l="paragraph",o=()=>{if(!c.length)return;let d=new Set;for(let f of c){let g=(l==="heading"?Ae:l==="list-item"?H:l==="quote"?Le:/^\s*/).exec(f.text)?.[0]??"";for(let b=0;b<g.length;b++)d.add(f.start+b);if(l==="list-item"&&f!==c[0]){let b=/^\s*/.exec(f.text)[0];for(let y=0;y<b.length;y++)d.add(f.start+y)}}let p=vt(e,c[0].start,c.at(-1).end,l,d);p.text.trim()&&t.push(p),c=[]};for(let d of i){let p=Ae.test(d.text)?"heading":H.test(d.text)?"list-item":Le.test(d.text)?"quote":void 0;p==="heading"||p==="list-item"||p&&p!==l?(o(),l=p):!p&&l==="heading"&&(o(),l="paragraph"),c.push(d),p==="heading"&&o()}o()};for(let i of yt(e,N(e))){let u=i.text.trim();if(r){u.startsWith(r)&&(r=void 0);continue}if(/^(```|~~~)/.test(u)){a(),r=u.slice(0,3);continue}if(!u){a();continue}s.push(i)}return a(),t}function Te(e){let t=[];for(let r of e.matchAll(/[^\n]+(?:\n(?!\s*\n)[^\n]+)*/g)){let n=r[0],s=r.index;if(!n.trim())continue;let a=n.trim().split(/\s+/).length,i=H.test(n)?"list-item":!/[.!?:;"”’)…]$/.test(n.trim())&&a<=12?"heading":"paragraph",u=i==="list-item"?H.exec(n)[0].length:0,c=[],l="";for(let o=u;o<n.length;o++)l+=n[o]===`
|
|
10
|
+
`?" ":n[o],c.push(s+o);t.push({kind:i,text:l,map:c,start:s,end:s+n.length,excluded:new Set})}return t}var M=e=>e.kind==="mdx"?z(e.source):Te(e.source),xt=/(?:^|[\s(])(?:mr|mrs|ms|dr|prof|st|jr|sr|vs|etc|e\.g|i\.e|cf|approx|no|inc|ltd|co|corp|dept|fig|vol|al|ca|est|gen|gov|lt|sgt|capt|rev|hon|a\.m|p\.m|u\.s|u\.k)\.\s*$/i,kt=/(?:^|[\s(‘'"“])(?:[A-Z]\.){2,}\s*$/,St=/(?:^|[\s(])[A-HJ-Z]\.\s*$/,qt=/^\s*["“‘']?(?:the|this|that|these|those|it|its|he|she|they|we|i|you|but|and|so|then|a|an|in|on|at|for|if|when|while|after|before|our|their|his|her|my|there|here|what|why|how|now|today)\b/i;function te(e){let t=[...new Intl.Segmenter("en",{granularity:"sentence"}).segment(e.text)].map(s=>({start:s.index,end:s.index+s.segment.length})),r=[];for(let s of t){let a=r.at(-1),i=a?e.text.slice(a.start,a.end):"",u=e.text.slice(s.start,s.end);a&&(xt.test(i)||kt.test(i)&&!qt.test(u)||St.test(i)||/^\s*[a-z]/.test(u)||/\d\.\s*$/.test(i)&&/^\d/.test(u))?a.end=s.end:r.push({...s})}let n=[];for(let s of r){let a=s.start,i=s.end;for(;a<i&&/\s/.test(e.text[a]);)a++;for(;i>a&&/\s/.test(e.text[i-1]);)i--;i>a&&n.push({start:a,end:i,text:e.text.slice(a,i)})}return n}var Rt=new Set(["*","_","~","`","["]),Et=new Set(["*","_","~","`"]);function re(e,t,r,n){let s=e.map[t],a=e.map[r-1]+1;for(;s>e.start&&e.excluded.has(s-1)&&Rt.has(n[s-1]);)s--;for(;;){if(a<e.end&&e.excluded.has(a)&&Et.has(n[a])){a++;continue}if(a<e.end&&e.excluded.has(a)&&n[a]==="]"&&n[a+1]==="("){let i=a+2;for(let u=1;i<e.end&&u;i++)u+=n[i]==="("?1:n[i]===")"?-1:0;if(i<=e.end){a=i;continue}}break}return{start:s,end:a}}var A=e=>(e.match(/[\p{L}\p{N}][\p{L}\p{N}'’-]*/gu)??[]).length;var Ne=String.raw`[\p{L}\p{N}][\p{L}\p{N}'’-]*`,ne=String.raw`(?:not|never|no longer|cannot|(?:is|are|was|were|do|does|did|ca|wo|would|should|could|has|have|had|ai|must)n['’]t)`,Dt=String.raw`(?:it|they|we|you|he|she|that|this|these|those|it['’]s|they['’]re|we['’]re|you['’]re|that['’]s|instead|rather|but)`,jt=new RegExp(String.raw`\b${ne}\b`,"i"),At=[new RegExp(String.raw`\b${ne}\b[^.;:—–!?]*?(?:[,;:]|\s[—–-]{1,2}\s|[—–])\s*${Dt}\b`,"i"),new RegExp(String.raw`\b${ne}\b[^.;!?]*?\bbut\b`,"i"),/\bless about\b[^.;!?]*?\bmore about\b/i,/\bmore about\b[^.;!?]*?\bthan about\b/i,/\bnot so much\b[^.;!?]*?\bas\b/i],Lt=/^["“‘']?(?:it|they|we|you|he|she|this|that|these|those|instead|rather|just|only|because|it['’]s|they['’]re|we['’]re|you['’]re|that['’]s|there['’]s)\b/i,ae=e=>/[\p{L}\p{N}'’]+/u.exec(e)?.[0].toLowerCase(),Tt=/^["“‘']?(?:if|when|whenever|unless|whether|although|though|because|since|while|until|once|as long as)\b/i;function Nt({sentences:e}){let t=[];for(let[r,n]of e.entries()){let s=Tt.test(n.text),a=At.map((c,l)=>l===0&&s?null:c.exec(n.text)).find(Boolean);if(a){t.push({start:n.start,end:n.end,focusStart:n.start+a.index,focusEnd:n.start+a.index+a[0].length});continue}let i=e[r+1],u=/^not because\b/i.test(n.text)&&i&&/^because\b/i.test(i.text);!i||!jt.test(n.text)&&!u||A(n.text)>20||(u||Lt.test(i.text)||ae(i.text)===ae(n.text))&&t.push({start:n.start,end:i.end})}return t}var L=String.raw`${Ne}(?:\s+${Ne}){0,4}`,Ce=new RegExp(String.raw`(${L}),\s+(${L}),?\s+(?:and|or|nor)\s+(${L})`,"gu"),Pe=new RegExp(String.raw`(?:(${L}),\s+)?\b(no|every|each|new|more|less|zero|any|fewer|better|faster)\s+(${L}),\s+\2\s+(${L})(?:,?\s+(?:and\s+|or\s+)?\2\s+(${L}))?`,"giu");function Ct({sentences:e}){let t=[];for(let a of e)for(let i of[Ce,Pe]){i.lastIndex=0;for(let u of a.text.matchAll(i)){let c=a.text.slice(0,u.index);if(!(i===Ce&&/,\s*$/.test(c))&&!(i===Pe&&!u[1]&&!u[5])){t.push({start:a.start,end:a.end,focusStart:a.start+u.index,focusEnd:a.start+u.index+u[0].length});break}}}let r=(a,i)=>!!a&&A(a.text)<=i,n=a=>a.text.toLowerCase().match(/[\p{L}\p{N}'’-]+/gu)??[],s=(...a)=>[i=>i[0],i=>i.at(-1),i=>i.at(-2)].some(i=>new Set(a.map(u=>i(n(u)))).size===1);for(let a=0;a+2<e.length;a++){let[i,u,c]=[e[a],e[a+1],e[a+2]];(r(i,4)&&r(u,4)&&r(c,4)||r(i,3)&&r(u,3)||r(i,6)&&r(u,6)&&r(c,6)&&s(i,u,c))&&!r(e[a-1],3)&&!r(e[a+3],3)&&t.push({start:i.start,end:c.end})}return Zt(t)}var Pt=/\b(?:could|might|may|perhaps|possibly|potentially|arguably|somewhat|relatively|likely|probably|seemingly|apparently|generally|typically|usually|tends? to|in some cases|in certain (?:cases|situations)|to some extent|to a certain extent|sort of|kind of|more or less|it seems|it appears|seems to|appears to)\b/gi;function It({sentences:e}){let t=[];for(let r of e){let n=[...r.text.matchAll(Pt)];if(n.length<2)continue;let s=n[0],a=n.at(-1);t.push({start:r.start,end:r.end,focusStart:r.start+s.index,focusEnd:r.start+a.index+a[0].length})}return t}var $t=/\b(?:experts?\s+(?:agree|say|believe|warn|predict|recommend|suggest|argue)|studies\s+(?:show|suggest|have shown|find|found|indicate)|research(?:ers)?\s+(?:shows?|suggests?|has shown|have found|finds?|found|indicates?)|(?:many|some|most)\s+(?:(?:people|experts|analysts|observers|critics|leaders)\s+)?(?:believe|say|argue|agree|think|feel)|it is (?:widely|generally|commonly) (?:believed|accepted|known|agreed)|according to (?:some|many|experts|studies|research)|data (?:shows|suggests)|surveys? (?:shows?|suggests?)|reports? (?:shows?|suggests?)|science (?:says|shows)|everyone knows|industry (?:leaders|experts|insiders))\b/i;function Ot({sentences:e}){return e.flatMap(t=>{let r=$t.exec(t.text);return r?[{start:t.start,end:t.end,focusStart:t.start+r.index,focusEnd:t.start+r.index+r[0].length}]:[]})}var Ft=new Set(["including","according","during","regarding","concerning","following","something","nothing","anything","everything","thing","things","morning","evening","spring","string","ring","king","wing","bring","sing","ceiling","building","meeting","wedding","being","pending","notwithstanding","considering","excluding","beginning","ending","setting","feeling","interesting","amazing","exciting","boring"]),Bt=/,\s+((?:thereby\s+|further\s+|ultimately\s+)?([a-z][a-z-]*ing)\b[^,;:]*?)[.!?]?["”’)]*$/i,Ut=/,\s+(which\s+(?:highlights|underscores|showcases|reflects|demonstrates|signals|cements|reinforces|speaks to|shows)\b[^,;:]*?)[.!?]?["”’)]*$/i;function Vt({sentences:e}){let t=[];for(let r of e){if((r.text.match(/,\s+[a-z][a-z-]*ing\b/gi)??[]).length>=2)continue;let n=Bt.exec(r.text),s=Ut.exec(r.text),a=n&&!Ft.has(n[2].toLowerCase())?n:s;if(!a)continue;let i=r.start+a.index+a[0].indexOf(a[1]);t.push({start:r.start,end:r.end,focusStart:i,focusEnd:i+a[1].length})}return t}var Ht=new RegExp("\\b(?:everything\\s+|anything\\s+)?from\\s+(?![\\d$])((?:the\\s+|a\\s+|an\\s+)?\\p{L}[\\p{L}\\p{N}'\u2019-]*(?:\\s+[\\p{L}\\p{N}][\\p{L}\\p{N}'\u2019-]*){0,3}?)\\s+to\\s+(?![\\d$])((?:the\\s+|a\\s+|an\\s+)?[\\p{L}\\p{N}][\\p{L}\\p{N}'\u2019-]*(?:\\s+[\\p{L}\\p{N}][\\p{L}\\p{N}'\u2019-]*){0,3})","giu");function zt({sentences:e}){let t=[];for(let r of e)for(let n of r.text.matchAll(Ht))n[1].toLowerCase()!==n[2].toLowerCase()&&t.push({start:r.start,end:r.end,focusStart:r.start+n.index,focusEnd:r.start+n.index+n[0].length});return t}function Mt({block:e,sentences:t}){if(e.kind!=="paragraph"||t.length<4)return[];let r=t.map(u=>A(u.text)),n=r.reduce((u,c)=>u+c,0)/r.length,s=Math.sqrt(r.reduce((u,c)=>u+(c-n)**2,0)/r.length)/n,a=new Map;for(let u of t){let c=ae(u.text);c&&a.set(c,(a.get(c)??0)+1)}let i=Math.max(...a.values())>=3;return s<=.35||i?[{start:0,end:e.text.length}]:[]}function Jt({block:e}){return[...e.text.matchAll(/—|\s–\s|\s?--\s?/g)].map(t=>{let r=t.index+t[0].search(/[—–-]/),n=r+t[0].trim().length,s=/^\s?[\p{L}\p{N}][\p{L}\p{N}'’]*/u.exec(e.text.slice(n))?.[0].length??0;return{start:r,end:n+s,focusStart:r,focusEnd:n}})}function Gt({block:e,sentences:t,source:r}){if(e.kind==="heading")return[];let n=Ie(e,r)?.end??-1,s=[];for(let a of t){let i=a.text.indexOf(":",Math.max(0,n-a.start));i<0||i===a.text.length-1||/^\s*["“\d]/.test(a.text.slice(i+1))||/\d:\d/.test(a.text.slice(i-1,i+2))||s.push({start:a.start,end:a.end,focusStart:a.start+i,focusEnd:a.start+i+1})}return s}var Wt=new Set(["a","an","the","and","or","but","for","nor","of","on","in","to","at","by","with","vs","via","as","up","is","from","into"]);function Kt({block:e}){if(e.kind!=="heading")return[];let t=(e.text.match(/[\p{L}][\p{L}'’-]*/gu)??[]).slice(1).filter(n=>!Wt.has(n.toLowerCase())&&n!==n.toUpperCase()&&!new RegExp("\\p{Ll}\\p{Lu}","u").test(n)),r=t.filter(n=>new RegExp("^\\p{Lu}","u").test(n)).length;return r>=2&&r/t.length>=.6?[{start:0,end:e.text.length}]:[]}function Ie(e,t){let r=/^\s*(?:(?:[-*+]|\d+[.)])\s+)?\*\*([^*]+)\*\*(:?)/.exec(t.slice(e.start,e.end));if(!r||!(e.kind==="list-item"||r[2]||r[1].endsWith(":")))return;let n=e.map.indexOf(e.start+r[0].length-(r[2]?1:3));return n<0?void 0:{at:r[0].length-r[1].length-r[2].length-4,end:n+1}}function _t({block:e,source:t}){let r=Ie(e,t),n=[...t.slice(e.start,e.end).matchAll(/\*\*([^*]+)\*\*/g)].filter(a=>a.index!==r?.at);if(!n.length||n.length===1&&e.kind==="heading")return[];let s=new Map(e.map.map((a,i)=>[a,i]));return n.flatMap(a=>{let i=s.get(e.start+a.index+2),u=s.get(e.start+a.index+a[0].length-3);return i!==void 0&&u!==void 0?[{start:i,end:u+1}]:[]})}function Zt(e){let t=new Set;return e.filter(r=>{let n=`${r.start}:${r.end}`;return t.has(n)?!1:(t.add(n),!0)})}var O={contrast:Nt,three:Ct,hedging:It,attribution:Ot,trailing:Vt,"false-range":zt,rhythm:Mt,"em-dash":Jt,colon:Gt,"title-case":Kt,bold:_t};var Oe="Evaluate only the target; the context, when given, is background. ",ue={lexicon:.2,pattern:.6,judge:.7},Yt=new Set(["title-case","bold","em-dash"]),se=(e,t)=>t?e.replaceAll("{term}",t):e,Xt=e=>e.toLowerCase().replace(/[’]/g,"'").replace(/\s+/g," "),$e=e=>Xt(e).replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,""),ie=e=>$e(e.rule)+(e.term?`__${$e(e.term)}`:"");function Qt(e,t,r,n,s){let a=[],i=r.kind!=="heading",u=t.judge?.context==="paragraph"?r.text:void 0,c=(p,f)=>re(r,p,f,e.source),l=(p,f)=>({start:r.map[p],end:r.map[f-1]+1}),o=p=>n.find(f=>p>=f.start&&p<f.end)??{start:0,end:r.text.length,text:r.text},{detector:d}=t;if(d.kind==="lexicon"){if(t.level!=="word"&&!i)return a;for(let p of ee(r.text,s)){let f=o(p.start);if(p.term.start&&r.text.slice(f.start,p.start).replace(/["“‘'(\s]/g,""))continue;let g=l(p.start,p.end),b=t.level==="word"?g:c(f.start,f.end);a.push({rule:t.id,level:t.level,...b,focus:t.level==="word"?void 0:g,term:p.text,plain:p.term.plain,target:f.text,context:u})}}else if(d.kind==="pattern"){if(!i&&!Yt.has(d.pattern))return a;for(let p of O[d.pattern]({block:r,sentences:n,source:e.source})){let f=c(p.start,p.end),g=p.focusStart!==void 0&&p.focusEnd!==void 0&&p.focusEnd>p.focusStart?l(p.focusStart,p.focusEnd):void 0,b=t.level==="paragraph"?r.text:t.level==="word"?o(p.start).text:r.text.slice(p.start,p.end);a.push({rule:t.id,level:t.level,...f,focus:g,...t.level==="word"&&t.judge?.ask.includes("{term}")?{term:r.text.slice(p.start,p.end)}:{},target:b,context:b===r.text?void 0:u})}}else if(t.level==="sentence"&&i)for(let p of n)A(p.text)>=4&&a.push({rule:t.id,level:"sentence",...c(p.start,p.end),target:p.text,context:u});else t.level==="paragraph"&&(r.kind==="paragraph"||r.kind==="quote")&&n.length>=2&&A(r.text)>=30&&a.push({rule:t.id,level:"paragraph",...c(0,r.text.length),target:r.text});return a}function er(e){let t=[],r=/(?<code>[={]\s*"[^"\n]*")|“(?:[^“”\n]|\n(?!\s*\n))*”|(?<![\p{L}\p{N}])"(?:[^"\n]|\n(?!\s*\n))*"/gu;for(let n of e.matchAll(r))n.groups?.code||t.push({start:n.index,end:n.index+n[0].length});return t}function tr(e,t){let r=er(e.source);return r.length?t.filter(n=>{let{start:s,end:a}=n.focus??n;return r.reduce((u,c)=>u+Math.max(0,Math.min(a,c.end)-Math.max(s,c.start)),0)*2<a-s}):t}function rr(e,t){let r=new Set(t.rules.filter(s=>s.detector.kind==="lexicon"&&s.level==="word").map(s=>s.id)),n=e.filter(s=>r.has(s.rule));return e.filter(s=>!r.has(s.rule)||!n.some(a=>a!==s&&a.start<=s.start&&a.end>=s.end&&a.end-a.start>s.end-s.start))}async function nr(e,t,r,n){let s=0;await Promise.all(Array.from({length:Math.min(t,e.length)},async()=>{for(;s<e.length;)n?.throwIfAborted(),await r(e[s++])}))}async function Fe(e,t,r,n={}){let s=t.rules.filter(d=>n.rules?n.rules.includes(d.id):d.default),a=new Map(s.flatMap(d=>d.detector.kind==="lexicon"?[[d.id,Q(d.detector.terms)]]:[])),i=M(e),u=[];for(let d of i){let p=d.kind==="heading"?[{start:0,end:d.text.length,text:d.text}]:te(d);for(let f of s)u.push(...Qt(e,f,d,p,a.get(f.id)))}u=tr(e,rr(u,t));let c={calls:0,inputTokens:0,dollars:0,groups:0,cachedCalls:0},l=new Map(t.rules.map((d,p)=>[d.id,{rule:d,order:p}])),o=u.filter(d=>l.get(d.rule).rule.judge);if(r&&o.length){let d=new Map;for(let g of o){let b=JSON.stringify([g.target,g.context??""]),y=d.get(b)??{target:g.target,context:g.context,members:[]};y.members.push(g),d.set(b,y)}let p=g=>typeof n.repeats=="function"?n.repeats(g):n.repeats??1,f=[];for(let g of d.values()){let b=new Map;for(let v of g.members){let S=l.get(v.rule),P=ie(v);b.has(P)||b.set(P,{order:S.order,rule:v.rule,question:{id:P,kind:"yes-no",ask:Oe+se(S.rule.judge.ask,v.term),yes:se(S.rule.judge.yes,v.term),no:se(S.rule.judge.no,v.term)}})}let y=[...b.values()].sort((v,S)=>v.order-S.order||v.question.id.localeCompare(S.question.id)),x=Math.max(1,r.capabilities.maxQuestionsPerCall);for(let v=0;v<y.length;v+=x){let S=y.slice(v,v+x),P=new Set(S.map(j=>j.question.id));f.push({input:g.context?{target:g.target,context:g.context}:{target:g.target},questions:S.map(j=>j.question),repeats:Math.max(...S.map(j=>p(j.rule))),members:g.members.filter(j=>P.has(ie(j)))})}}c.groups=d.size,await nr(f,n.concurrency??4,async g=>{let b=new Map;for(let y=0;y<g.repeats;y++){let x=await r.judge(g.input,g.questions,{signal:n.signal});c.calls+=x.usage.calls,c.inputTokens+=x.usage.inputTokens??0,c.dollars+=x.usage.dollars,x.cached&&(c.cachedCalls+=1);for(let v of x.answers)b.set(v.id,[...b.get(v.id)??[],v.probability])}for(let y of g.members){let x=b.get(ie(y));x?.length&&(y.probabilities=x,y.probability=x.reduce((v,S)=>v+S,0)/x.length)}},n.signal)}return{blocks:i,candidates:u,usage:c}}var Be=e=>e.replace(/[‘’]/g,"'").replace(/[“”]/g,'"').replace(/\s+/g," ").trim();function ar(e,t){if(!t)return 0;let r=0;for(let n=e.indexOf(t);n>=0;n=e.indexOf(t,n+1))r++;return r}function sr(e,t,r,n,s){let a=s?.start??0,i=s?.end??e.length;for(let u=0;u<16;u++){if(ar(t,Be(e.slice(r,n)))<=1)return{start:r,end:n,unique:!0};let c=/^\s*\S+/.exec(e.slice(n,i)),l=/\S+\s*$/.exec(e.slice(a,r));if(!c&&!l)break;c&&(u%2===0||!l)?n+=c[0].length:l&&(r-=l[0].length)}return{start:r,end:n,unique:!1}}function Ue(e,t,r,n,s={provider:n?.provider??"none",model:n?.model??"none"},a=M(e)){let i=Be(e.source.slice(N(e.source))),u=new Map(r.rules.map(o=>[o.id,o])),c=new Set;return t.filter(o=>{let d=u.get(o.rule);if(!d)return!1;let p=`${o.rule}:${o.start}:${o.end}:${o.focus?.start??""}`;return c.has(p)?!1:(c.add(p),d.judge?o.probability===void 0?!1:o.probability>=(n?.rules[o.rule]?.threshold??ue[d.detector.kind]):!0)}).sort((o,d)=>o.start-d.start||d.end-o.end).map((o,d)=>{let p=u.get(o.rule),f=a.find(v=>o.start>=v.start&&o.start<v.end),g=sr(e.source,i,o.start,o.end,f),b=o.focus??(g.start!==o.start||g.end!==o.end?{start:o.start,end:o.end}:void 0),y=n?.rules[o.rule]?.threshold??ue[p.detector.kind],x={id:`D${String(d+1).padStart(3,"0")}`,rule:o.rule,level:o.level,edit:p.edit,match:e.source.slice(g.start,g.end),span:{start:g.start,end:g.end},note:p.fix+(o.plain?` Try \u201C${o.plain}\u201D.`:""),severity:p.severity??"flag",status:"open"};return b&&(x.focus={start:b.start-g.start,end:b.end-g.start}),g.unique||(x.ambiguous=!0),p.judge&&o.probability!==void 0&&(x.judge={provider:s.provider,model:s.model,probability:Math.round(o.probability*1e3)/1e3,threshold:y,rulesVersion:r.version}),x})}async function ir(e,t,r,n,s={}){let{blocks:a,candidates:i}=await Fe(e,t,r,{...s,repeats:u=>n?.rules[u]?.repeats??1});return Ue(e,i,t,n,{provider:r.id,model:r.model},a)}import{readFileSync as or}from"node:fs";import{dirname as cr,resolve as dr,sep as lr}from"node:path";import{fileURLToPath as pr,pathToFileURL as fr}from"node:url";var Ve={version:"3",rules:[{id:"inflated",color:"#875f45",mark:"underline",label:"Inflated word",level:"word",why:"A fancy word stands in for a plain one.",fix:"Use the plain word.",edit:"replace",detector:{kind:"lexicon",terms:[{term:"delve",pos:"verb",plain:"dig into"},{term:"leverage",pos:"verb",plain:"use"},{term:"utilize",pos:"verb",plain:"use"},{term:"utilise",pos:"verb",plain:"use"},{term:"utilization",pos:"noun",plain:"use"},{term:"facilitate",pos:"verb",plain:"help"},{term:"foster",pos:"verb",plain:"build"},{term:"cultivate",pos:"verb",plain:"build"},{term:"enhance",pos:"verb",plain:"improve"},{term:"showcase",pos:"verb",plain:"show"},{term:"underscore",pos:"verb",plain:"show"},{term:"garner",pos:"verb",plain:"get"},{term:"empower",pos:"verb",plain:"let"},{term:"streamline",pos:"verb",plain:"simplify"},{term:"elevate",pos:"verb",plain:"improve"},{term:"unlock",pos:"verb",plain:"open"},{term:"harness",pos:"verb",plain:"use"},{term:"harness the power of",pos:"verb",plain:"use"},{term:"navigate",pos:"verb",plain:"handle"},{term:"embark",pos:"verb",plain:"start"},{term:"spearhead",pos:"verb",plain:"lead"},{term:"bolster",pos:"verb",plain:"support"},{term:"revolutionize",pos:"verb",plain:"change"},{term:"reimagine",pos:"verb",plain:"redesign"},{term:"commence",pos:"verb",plain:"start"},{term:"ascertain",pos:"verb",plain:"find out"},{term:"endeavor",pos:"noun",plain:"effort"},{term:"crucial",pos:"adj",plain:"important"},{term:"pivotal",pos:"adj",plain:"key"},{term:"paramount",pos:"adj",plain:"most important"},{term:"multifaceted",pos:"adj",plain:"complex"},{term:"holistic",pos:"adj",plain:"whole"},{term:"meticulous",pos:"adj",plain:"careful"},{term:"numerous",pos:"adj",plain:"many"},{term:"a myriad of",pos:"phrase",plain:"many"},{term:"myriad",pos:"adj",plain:"many"},{term:"a plethora of",pos:"phrase",plain:"many"},{term:"additionally",pos:"phrase",plain:"also"},{term:"landscape",pos:"noun",plain:"field"},{term:"tapestry",pos:"noun",plain:"mix"},{term:"realm",pos:"noun",plain:"area"},{term:"ecosystem",pos:"noun",plain:"network"},{term:"synergy",pos:"noun",plain:"combined effect"},{term:"paradigm",pos:"noun",plain:"model"},{term:"paradigm shift",pos:"noun",plain:"big change"},{term:"north star",pos:"noun",plain:"goal"},{term:"substrate",pos:"noun",plain:"base"},{term:"nexus",pos:"phrase",plain:"link"},{term:"a testament to",pos:"phrase",plain:"shows"},{term:"indelible mark",pos:"noun",plain:"lasting effect"},{term:"play a key role",pos:"verb",forms:["played a key role","plays a key role"],plain:"matters"},{term:"play a vital role",pos:"verb",forms:["played a vital role","plays a vital role"],plain:"matters"},{term:"play a crucial role",pos:"verb",forms:["played a crucial role","plays a crucial role"],plain:"matters"},{term:"play a pivotal role",pos:"verb",forms:["played a pivotal role","plays a pivotal role"],plain:"matters"},{term:"play an important role",pos:"verb",forms:["played an important role","plays an important role"],plain:"matters"}]},judge:{ask:"Is \u201C{term}\u201D in the target an inflated or buzzword choice where a plainer word would say the same thing?",yes:"\u201C{term}\u201D dresses up a plain idea, as in leverage a tool, foster a culture, a pivotal moment, navigate challenges.",no:"\u201C{term}\u201D is literal or a necessary technical term, as in a mountain landscape, foster care, financial leverage, navigating a ship.",context:"paragraph"},default:!0},{id:"filler",color:"#5e6b38",mark:"box",label:"Filler",level:"word",why:"Words that delay the point without adding to it.",fix:"Delete the phrase.",edit:"delete",detector:{kind:"lexicon",terms:[{term:"in order to",plain:"to"},{term:"due to the fact that",plain:"because"},{term:"owing to the fact that",plain:"because"},{term:"in spite of the fact that",plain:"although"},{term:"it is important to note that"},{term:"it is important to note"},{term:"it's important to note that"},{term:"it's important to note"},{term:"it is worth noting that"},{term:"it is worth noting"},{term:"it's worth noting that"},{term:"it's worth noting"},{term:"it should be noted that"},{term:"it goes without saying that"},{term:"it goes without saying"},{term:"needless to say"},{term:"at the end of the day"},{term:"the fact of the matter is"},{term:"in the event that",plain:"if"},{term:"for all intents and purposes"},{term:"at this point in time",plain:"now"},{term:"each and every",plain:"every"},{term:"first and foremost",plain:"first"},{term:"when it comes to",plain:"for"},{term:"in terms of"},{term:"in a timely manner",plain:"promptly"},{term:"on a daily basis",plain:"daily"},{term:"has the ability to",plain:"can"},{term:"meet your needs",pos:"verb",forms:["met your needs"]},{term:"meet their needs",pos:"verb",forms:["met their needs"]}]},judge:{ask:"Can \u201C{term}\u201D be deleted or shortened in the target without losing any meaning?",yes:"Empty framing, as in in order to (to), it is important to note that, at the end of the day.",no:"The words carry meaning here, such as the literal end of a working day or a real condition.",context:"paragraph"},default:!0},{id:"brochure-verb",color:"#3f6b67",mark:"underline",label:"Brochure verb",level:"word",why:"A costume for \u201Cis\u201D or \u201Chas\u201D.",fix:"Say \u201Cis\u201D or \u201Chas\u201D.",edit:"replace",detector:{kind:"lexicon",terms:[{term:"serve as",pos:"verb",plain:"is"},{term:"stand as",pos:"verb",forms:["stood as"],plain:"is"},{term:"act as",pos:"verb",plain:"is"},{term:"function as",pos:"verb",plain:"is"},{term:"boast",pos:"verb",plain:"has"},{term:"it features",pos:"phrase",forms:["also features","which features","that features","it also features"],plain:"has"},{term:"it offers",pos:"phrase",forms:["also offers","which offers","it also offers"],plain:"has"},{term:"is home to",pos:"phrase",plain:"has"}]},judge:{ask:"Does \u201C{term}\u201D in the target stand in for a plain \u201Cis\u201D or \u201Chas\u201D?",yes:"The library boasts full support; the inn stands as a landmark; it features a plugin system.",no:"A literal action, as in a person boasting about a win, a film featuring an actor, a server acting as a proxy.",context:"paragraph"},default:!0},{id:"promo-adjective",color:"#835b70",mark:"strike-through",label:"Promotional adjective",level:"word",why:"Praise instead of description.",fix:"Describe the thing and let the reader judge.",edit:"delete",detector:{kind:"lexicon",terms:[{term:"vibrant",pos:"adj"},{term:"stunning",pos:"adj"},{term:"breathtaking",pos:"adj"},{term:"groundbreaking",pos:"adj"},{term:"renowned",pos:"adj"},{term:"seamless",pos:"adj"},{term:"robust",pos:"adj"},{term:"nestled",pos:"phrase"},{term:"cutting-edge",pos:"phrase"},{term:"state-of-the-art",pos:"phrase"},{term:"world-class",pos:"phrase"},{term:"best-in-class",pos:"phrase"},{term:"innovative",pos:"adj"},{term:"revolutionary",pos:"adj"},{term:"game-changing",pos:"phrase"},{term:"game-changer",pos:"noun"},{term:"unparalleled",pos:"adj"},{term:"unmatched",pos:"adj"},{term:"unrivaled",pos:"adj"},{term:"transformative",pos:"adj"},{term:"effortless",pos:"adj"},{term:"intuitive",pos:"adj"},{term:"next-level",pos:"phrase"},{term:"top-notch",pos:"phrase"},{term:"must-have",pos:"phrase"},{term:"awe-inspiring",pos:"phrase"},{term:"captivating",pos:"adj"}]},judge:{ask:"Is \u201C{term}\u201D in the target promotional praise rather than a checkable description?",yes:"Breathtaking views, a vibrant scene, seamless integration, a robust platform, an intuitive interface.",no:"A measurable or technical use, as in a robust statistical estimator or an innovative method the text then describes in detail.",context:"paragraph"},default:!0},{id:"signpost",color:"#75642f",mark:"strike-through",label:"Signposting",level:"word",why:"Announces a point instead of making it.",fix:"Cut the opener and start with the point.",edit:"delete",detector:{kind:"lexicon",terms:[{term:"here's the thing"},{term:"here's why"},{term:"here's how"},{term:"here's what"},{term:"here's the kicker"},{term:"let's dive in"},{term:"let's dive into"},{term:"let's delve into"},{term:"let's break it down"},{term:"let's take a closer look"},{term:"let's explore"},{term:"the bottom line is"},{term:"the truth is"},{term:"the reality is"},{term:"make no mistake"},{term:"simply put"},{term:"put simply"},{term:"in conclusion"},{term:"in summary"},{term:"to sum up"},{term:"all in all"},{term:"at its core"},{term:"ultimately",start:!0},{term:"and the best part?"},{term:"the best part?"},{term:"the result?"},{term:"the catch?"},{term:"spoiler alert"},{term:"let that sink in"},{term:"now more than ever"},{term:"it's no secret that"},{term:"in today's fast-paced world"},{term:"in today's fast-paced digital landscape"},{term:"in today's digital age"},{term:"in today's rapidly evolving landscape"},{term:"in today's ever-changing world"},{term:"in today's competitive landscape"},{term:"in an era of"}]},judge:{ask:"Is \u201C{term}\u201D in the target an empty opener or hook that announces a point instead of making it?",yes:"Here's the thing:, Let's dive in, Simply put, And the best part?, In conclusion, In today's fast-paced world.",no:"The words do real work, as in a genuine question the text answers next, or a summary that adds information.",context:"paragraph"},default:!0},{id:"contrast",color:"#994b52",mark:"circle",label:"Not X, but Y",level:"sentence",why:"Sets up a claim just to knock it down.",fix:"State the second half on its own.",edit:"replace",detector:{kind:"pattern",pattern:"contrast"},judge:{ask:"Is the target a punchy not-X-but-Y reveal (\u201CX isn't A; it's B\u201D, \u201Cnot just A, it's B\u201D, \u201Cit's not about A, it's about B\u201D) used for effect, whether or not it's true?",yes:"It's not a tool, it's a movement; Design isn't decoration. It's how it works; Not just faster, but smarter; Success isn't luck. It's practice.",no:"Concessions (They aren't finished, but they're usable); not only X but also Y; plain explanations and descriptions (The table isn't solid wood; it's veneer); contrasts inside longer reasoning; a story's narration.",context:"paragraph"},default:!0},{id:"three",color:"#87532f",mark:"underline",label:"List of three",level:"sentence",why:"Three items for rhythm, not because there are three.",fix:"Keep the items that carry meaning.",edit:"replace",detector:{kind:"pattern",pattern:"three"},judge:{ask:"Does the target use a decorative list or parallel sequence of three that substitutes rhythm for substance?",yes:"Three interchangeable qualities or audiences: fast, reliable, and secure; plan smarter, ship faster, grow bigger; a founder, a marketer, or an engineer; Speed matters. Focus matters. Clarity matters.",no:"A necessary inventory of three real fields, steps or named items; not every list of three is bad.",context:"paragraph"},default:!0},{id:"hedging",color:"#596b86",mark:"underline",label:"Stacked hedges",level:"sentence",why:"Several hedges in one claim dodge commitment.",fix:"Keep one hedge, or commit.",edit:"replace",detector:{kind:"pattern",pattern:"hedging"},judge:{ask:"Does the target stack several hedges (could, potentially, possibly, some, generally, tend to) so the claim avoids committing?",yes:"Could potentially possibly help some teams in certain cases; people generally tend to prefer.",no:"One justified hedge, or an explicit limit on the evidence.",context:"paragraph"},default:!0},{id:"attribution",color:"#416c8d",mark:"caret",label:"Vague attribution",level:"sentence",why:"Cites authority nobody can check.",fix:"Name the source, or cut the claim.",edit:"insert",detector:{kind:"pattern",pattern:"attribution"},judge:{ask:"Does the target appeal to vague authority or imply evidence without a checkable source?",yes:"Experts agree; studies show; many believe; research suggests, with no named study or person.",no:"A named source, a quoted person, an explicit opinion, or a claim that does not invoke outside authority.",context:"paragraph"},default:!0},{id:"trailing",color:"#786348",mark:"strike-through",label:"Trailing -ing clause",level:"sentence",why:"Bolts an unsupported conclusion onto a fact.",fix:"Cut the clause, or give it its own evidence.",edit:"delete",detector:{kind:"pattern",pattern:"trailing"},judge:{ask:"Does the target bolt an unsupported interpretation onto a fact using a trailing -ing clause?",yes:"The feature shipped, highlighting our commitment to excellence; revenue doubled, cementing its position as a leader.",no:"A clause describing a real action or a direct, supported consequence.",context:"paragraph"},default:!0},{id:"residue",color:"#816044",mark:"strike-through",label:"Chatbot residue",level:"sentence",why:"A conversational leftover that addresses no real reader.",fix:"Delete it.",edit:"delete",detector:{kind:"lexicon",terms:[{term:"i hope this helps"},{term:"hope this helps"},{term:"let me know if you have any questions"},{term:"let me know if you have questions"},{term:"let me know if you need"},{term:"feel free to reach out"},{term:"feel free to ask"},{term:"great question"},{term:"certainly!"},{term:"absolutely!"},{term:"as an ai"},{term:"i'd be happy to"},{term:"happy to help"},{term:"i hope you found this"},{term:"stay tuned"},{term:"happy coding"},{term:"without further ado"},{term:"in this article, we"},{term:"in this post, we'll"}]},judge:{ask:"Is \u201C{term}\u201D in the target chatbot or newsletter residue, a conversational leftover that addresses no real reader?",yes:"I hope this helps!, Let me know if you have any questions., Great question!, Without further ado.",no:"Direct address that fits the document, such as a real sign-off in a personal letter.",context:"paragraph"},default:!0},{id:"false-range",color:"#6f5f86",mark:"underline",label:"False range",level:"sentence",why:"\u201CFrom X to Y\u201D with no real scale between them.",fix:"Name the things, or the one that matters.",edit:"replace",detector:{kind:"pattern",pattern:"false-range"},judge:{ask:"Does the target use a \u201Cfrom X to Y\u201D phrase (or \u201Crange from X to Y to Z\u201D, \u201Cfrom X through Y and beyond\u201D) to gesture at breadth instead of naming what matters?",yes:"From startups to enterprises; from ideas to impact; from the first sketch through launch and beyond; ranging from corner shops to global brands to city governments.",no:"A literal change from one thing to another (moving from tables to a document store); a real numeric, time, size or step range (from 2019 to 2024, from 10 ms to 200 ms, from the first call to the tenth).",context:"paragraph"},default:!0},{id:"puffery",color:"#8a565e",mark:"underline",label:"Puffery",level:"sentence",why:"Asserts importance instead of showing it.",fix:"Say what happened and let the reader judge.",edit:"replace",detector:{kind:"judge"},judge:{ask:"Does the target assert importance, success or a bright future without showing the event or evidence?",yes:"A pivotal moment; a true game-changer; the results speak for themselves; the future is bright; the backbone of modern commerce.",no:"A concrete result, a measured number, or an opinion clearly framed as the writer's own.",context:"paragraph"},default:!0},{id:"generic-voice",color:"#655b82",mark:"bracket",label:"Generic voice",level:"paragraph",why:"Could describe any company; no specific detail or stance.",fix:"Add a specific fact, example or opinion.",edit:"paragraph",detector:{kind:"judge"},judge:{ask:"Is the target filler a reader could skip: general claims or advice that any piece on the topic could make, with nothing specific in it (an example, number, name, firsthand detail, analogy, or a stance someone could disagree with)?",yes:"Communication is key to any successful team, and great teams invest in it; focusing on what matters most helps teams deliver value; at the end of the day it's about creating an environment where people can do their best work.",no:"A paragraph that carries the argument forward with a specific claim, example, analogy or firsthand detail; one that names or defines specific things; a short lead-in to specifics that follow; neutral technical instructions.",context:"none"},default:!0},{id:"repetition",color:"#4f705e",mark:"bracket",label:"Repetition",level:"paragraph",why:"Says the same thing again without adding to it.",fix:"Say it once, then move on.",edit:"paragraph",detector:{kind:"judge"},judge:{ask:"Does the target repeat the same point in different words without adding new information?",yes:"Consistency matters because a consistent brand is memorable, and memorable brands are consistent.",no:"Each sentence adds a new fact, step, example or turn of argument.",context:"none"},default:!0},{id:"over-explaining",color:"#76614d",mark:"bracket",label:"Over-explaining",level:"paragraph",why:"Explains what the reader already knows.",fix:"Cut to what's new to the reader.",edit:"paragraph",detector:{kind:"judge"},judge:{ask:"Does the target explain something obvious or familiar step by step, as if the reader lacked basics they already have?",yes:"Explaining what email or a password is to people who use them daily; defining a common term and then restating the definition.",no:"New, technical or surprising information explained once at the level the reader needs.",context:"none"},default:!0},{id:"rhythm",color:"#4c6a79",mark:"bracket",label:"Uniform rhythm",level:"paragraph",why:"Every sentence has the same length and shape.",fix:"Vary the sentence lengths; combine or split some.",edit:"paragraph",detector:{kind:"pattern",pattern:"rhythm"},judge:{ask:"Do the sentences in the target have nearly uniform length and structure, so the paragraph reads with a mechanical, repetitive rhythm?",yes:"Six short sentences that all start with \u201CWe\u201D and run five to seven words.",no:"Sentence lengths and shapes vary, or repetition is a deliberate, effective device.",context:"none"},default:!0},{id:"em-dash",color:"#7a584c",mark:"underline",label:"Em dash",level:"word",why:"A dramatic pause before a reveal.",fix:"Use a period or a comma.",edit:"replace",detector:{kind:"pattern",pattern:"em-dash"},judge:{ask:"Does the dash in the target set up a reveal for effect (a dramatic pause before a twist, a punchline, a summary or a restatement), the way machine-written prose uses it, where a period or comma would read as well?",yes:"They weren't bigger\u2014they were just better; The update is small \u2014 but it changes everything; One tool \u2014 endless possibilities; We tried everything \u2014 and then we tried one more thing.",no:"A pair of dashes around an aside (The results\u2014three studies in all\u2014point the same way); a dash before an attribution or a list; a speaker breaking off; a range of numbers or dates.",context:"paragraph"},default:!0},{id:"colon",color:"#63733f",mark:"box",label:"Connecting colon",level:"sentence",why:"A colon used as a hinge between claims, not to introduce a list.",fix:"Split it into two sentences.",edit:"replace",detector:{kind:"pattern",pattern:"colon"},judge:{ask:"Does the colon in the target hinge a setup to its payoff for effect, where a period would do as well, rather than introduce a list, an example, a quotation, a definition, a label or a time?",yes:"The answer was simple: we stopped holding meetings; Here's the truth: nobody reads the docs; One thing became clear: speed wins; The result: happier customers.",no:"Three things matter: speed, cost and focus; Note: the API is in beta; a ratio like 3:1; a colon before a quotation, an explanation the reader needs, or the items that follow.",context:"paragraph"},default:!0},{id:"title-case",color:"#755e73",mark:"underline",label:"Title case heading",level:"sentence",why:"Title Case headings read like marketing copy.",fix:"Use sentence case.",edit:"replace",detector:{kind:"pattern",pattern:"title-case"},default:!1,severity:"warning"},{id:"bold",color:"#586b68",mark:"underline",label:"Bold inflation",level:"word",why:"Bold used for emphasis instead of scanning.",fix:"Keep bold for labels a reader scans for.",edit:"replace",detector:{kind:"pattern",pattern:"bold"},judge:{ask:"Is the bold on \u201C{term}\u201D in the target hype: emphasis that makes ordinary words sound important, rather than a key term, warning or point a reader scans for?",yes:"This is **really** important; Every plan includes **unlimited** projects; We **never** compromise on quality; a **game-changing** feature.",no:"A term defined where it's introduced; a section's main point stated plainly for a reader who skims; a warning the reader must not miss; a button or menu name in instructions; a person's name after a quotation.",context:"paragraph"},default:!0}]};var oe=["word","sentence","paragraph"],ce=["replace","delete","insert","paragraph"],de=["lexicon","pattern","judge"],le=["underline","box","circle","strike-through","crossed-off","caret","bracket"],pe=["none","paragraph"];var J=fr(dr(cr(pr(import.meta.url)),"../../rules")+lr),C=e=>typeof e=="string"&&e.trim().length>0,F=(e,t)=>typeof t=="string"&&e.includes(t);function He(e){let t=[],r=e;if(!r||typeof r!="object")return["Registry must be an object."];if(r.version!=="3"&&t.push('version must be "3".'),!Array.isArray(r.rules)||!r.rules.length)return[...t,"rules must be a non-empty array."];let n=new Set;for(let[s,a]of r.rules.entries()){let i=a,u=`rules[${s}]${i?.id?` (${i.id})`:""}`;!C(i.id)||!/^[a-z][a-z0-9-]*$/.test(i.id)?t.push(`${u}: id must be kebab-case.`):n.has(i.id)?t.push(`${u}: duplicate id.`):n.add(i.id);for(let o of["label","why","fix"])C(i[o])||t.push(`${u}: ${o} is required.`);for(let o of["why","fix"])C(i[o])&&(i[o].length>90||/\n/.test(i[o]))&&t.push(`${u}: ${o} must be one short line.`);F(oe,i.level)||t.push(`${u}: level must be one of ${oe.join(", ")}.`),F(ce,i.edit)||t.push(`${u}: edit must be one of ${ce.join(", ")}.`),i.edit==="paragraph"&&i.level!=="paragraph"&&t.push(`${u}: edit "paragraph" needs level "paragraph".`),i.color!==void 0&&(typeof i.color!="string"||!/^#[0-9a-f]{6}$/i.test(i.color))&&t.push(`${u}: color must be a six-digit hex ink.`),i.mark!==void 0&&!F(le,i.mark)&&t.push(`${u}: mark must be one of ${le.join(", ")}.`),typeof i.default!="boolean"&&t.push(`${u}: default must be true or false.`),i.severity!==void 0&&!["flag","warning"].includes(i.severity)&&t.push(`${u}: severity must be flag or warning.`);let c=i.detector;if(!c||!F(de,c.kind)){t.push(`${u}: detector.kind must be one of ${de.join(", ")}.`);continue}if(c.kind==="lexicon")if(!Array.isArray(c.terms)||!c.terms.length)t.push(`${u}: lexicon needs terms.`);else for(let o of c.terms)C(o.term)||t.push(`${u}: every term needs text.`),o.pos&&!["verb","noun","adj","phrase"].includes(o.pos)&&t.push(`${u}: term "${o.term}" has an unknown pos.`);c.kind==="pattern"&&!(c.pattern in O)&&t.push(`${u}: unknown pattern "${c.pattern}".`);let l=i.judge;if(c.kind==="judge"&&!l&&t.push(`${u}: judge rules need a judge question.`),c.kind==="lexicon"&&!l&&t.push(`${u}: lexicon rules need a veto question.`),l){for(let o of["ask","yes","no"])C(l[o])||t.push(`${u}: judge.${o} is required.`);F(pe,l.context)||t.push(`${u}: judge.context must be one of ${pe.join(", ")}.`),c.kind==="lexicon"&&C(l.ask)&&!l.ask.includes("{term}")&&t.push(`${u}: a lexicon veto question must name {term}.`)}}return t}function ze(e){let t=He(e);if(t.length)throw new Error(`Invalid rule registry:
|
|
11
|
+
- ${t.join(`
|
|
12
|
+
- `)}`);return e}var fe=e=>ze(e?JSON.parse(or(e,"utf8")):structuredClone(Ve));var wn=new URL("labeled/",J);import mr from"node:path";var Me=(e,t,r=mr)=>r.relative(e,t).split(r.sep).join("/");function Je(e,t){return+!!e.target-+!!t.target||(e.span?.start??1/0)-(t.span?.start??1/0)||(t.span?.end??1/0)-(e.span?.end??1/0)||0}function me(e,t,r){let n=qe(r),s=N(t),a=new Map(e.findings.map(i=>{let u=i.span,c=i.status==="accepted"||i.status==="accepted-unrecorded"?i.proposed??(typeof i.after=="string"?i.after:i.match):i.match;if(!u||t.slice(u.start,u.end)!==c)try{if(n==="html"||n==="jinja")u=Re(t,c,n);else{let l=t.indexOf(c,s);l>=0&&(u={start:l,end:l+c.length})}}catch{}return[i,{span:u,target:i.target}]}));return{...e,findings:[...e.findings].sort((i,u)=>Je(a.get(i),a.get(u)))}}import{readFile as gr,realpath as hr}from"node:fs/promises";import{createHash as Ge}from"node:crypto";async function We(e,t,r,n){let s="";try{if(await hr(n)!==n)throw new Error("Decision log must not be a symlink");s=await gr(n,"utf8")}catch(d){if(d.code==="ENOENT")return e;throw d}if(s&&!s.endsWith(`
|
|
13
|
+
`))throw new Error("Decision log is incomplete");let a=d=>Ge("sha256").update(d).digest("hex"),i=s.split(`
|
|
14
|
+
`).filter(Boolean).map(d=>JSON.parse(d)),u=i.filter(d=>d.reviewAfter&&d.reviewShaBefore===a(r)&&d.sourceShaAfter===a(t)).at(-1),c=u?u.reviewAfter:e,l=Ge("sha256").update(t).update("\0").update(r).digest("hex"),o=new Map;for(let d of i){if(d.beforeRevision!==l||!String(d.action).startsWith("rewrite."))continue;let p=d.after?.finding;p&&o.set(p.id,p)}return o.size?{...c,findings:c.findings.map(d=>{let p=o.get(d.id);return p&&p.rule===d.rule&&p.match===d.match?p:d})}:c}import{createHash as Ye,randomUUID as wr}from"node:crypto";import{mkdir as W,open as yr,readFile as vr,realpath as D,rename as xr,unlink as Xe,readdir as Ke,lstat as kr}from"node:fs/promises";import h from"node:path";import{open as br}from"node:fs/promises";async function G(e,t=384,r=3e3){let n=Date.now()+r;for(let s=5;;s=Math.min(s*2,50)){try{return await br(e,"wx",t)}catch(a){if(a.code!=="EEXIST"||Date.now()>=n)throw a}await new Promise(a=>setTimeout(a,s))}}var m=class extends Error{constructor(t){super(t),this.name="ReviewError"}},Qe=e=>e.normalize("NFKC").replace(/[‘’]/g,"'").replace(/[“”]/g,'"').replace(/\s+/g," ").trim().toLowerCase(),R=e=>e.rule+"\0"+Qe(e.match),_e=(e,t)=>Ye("sha256").update(e).update("\0").update(t).digest("hex"),Sr=(e,t)=>{let r=h.relative(e,t);return r!==".."&&!r.startsWith(".."+h.sep)&&!h.isAbsolute(r)};async function q(e,t=!1){try{if(await D(e)!==e)throw new m("Symlink paths are not allowed");return await vr(e,"utf8")}catch(r){if(t&&r.code==="ENOENT")return"";throw r}}async function B(e,t){let r=e+"."+wr()+".tmp";try{let n=await yr(r,"wx",384);try{await n.writeFile(JSON.stringify(t,null,2)+`
|
|
15
|
+
`),await n.sync()}finally{await n.close()}await xr(r,e)}finally{await Xe(r).catch(()=>{})}}async function ge(e,t){let r;try{r=await G(e)}catch(n){throw n.code==="EEXIST"?new m("Review is busy; retry after the current action"):n}try{return await t()}finally{await r.close(),await Xe(e)}}var Ze=class e{constructor(t,r,n){this.root=t;this.config=r;this.reviewsDir=n??h.resolve(t,"../reviews"),this.projectBase=r?.projectRoot??h.resolve(t,"../..")}root;config;reviewsDir;projectBase;static async create(t,r={}){let n=await D(t);if(!(await kr(n)).isDirectory())throw new m("Document root must be a directory");return new e(n,await be(n),r.reviewsDir)}async storage(){if(await W(this.reviewsDir,{recursive:!0}),await D(this.reviewsDir)!==this.reviewsDir)throw new m("Review directory must not be a symlink")}async document(t){let r=await D(h.resolve(this.root,t));if(!(this.config?.roots??[this.root]).some(n=>Sr(n,r))||!/\.(?:md|mdx|html?|jinja2?|j2|njk|nunjucks|twig|liquid)$/.test(r))throw new m("Document is outside the allowed root");return r}sourceReference(t){return Me(this.projectBase,t)}output(t,r){if(this.config){let a=this.config.documents.find(i=>i.sourcePath===t&&(r?i.reviewPath===h.resolve(r):i.write));if(!a?.write)throw new m("Document review is not listed as writable in proofmarks.config.json");return a.reviewPath}let n=h.basename(t).replace(/\.mdx?$/,""),s=r?h.resolve(r):h.join(this.reviewsDir,n+".json");if(h.dirname(s)!==this.reviewsDir||!/^[a-zA-Z0-9][a-zA-Z0-9._-]*\.json$/.test(h.basename(s)))throw new m("Review output is outside the allowed directory");if(!h.basename(s).startsWith(n+"."))throw new m("Review output does not match the document");return s}id(t){if(this.config){let r=this.config.documents.find(n=>n.reviewPath===h.resolve(this.reviewsDir,t));if(!r)throw new m("Review is not listed in proofmarks.config.json");return r.id}return h.basename(t,".json")}file(t){if(this.config){let n=this.config.documents.find(s=>s.id===t);if(!n)throw new m("Review is not listed in proofmarks.config.json");return n.reviewPath}if(!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(t)||t.includes(".."))throw new m("Invalid review identity");let r=t;return h.join(this.reviewsDir,r+".json")}async capture(t,r,n=!1){let s=await this.document(t),a=n&&r?h.resolve(r):this.output(s,r);if(this.config?!this.config.documents.some(o=>o.reviewPath===a&&o.sourcePath===s):h.dirname(a)!==this.reviewsDir)throw new m("Review is outside the allowed directory");if(!n)if(this.config){if(await W(h.dirname(a),{recursive:!0}),await D(h.dirname(a))!==h.dirname(a))throw new m("Review directory must not be a symlink")}else await this.storage();let[i,u]=await Promise.all([q(s),q(a,!0)]),c=u?this.parseReview(u):void 0,l=c?await We(c,i,u,a.replace(/\.json$/,".log.jsonl")):void 0;if(l&&l.source.replaceAll("\\","/")!==this.sourceReference(s))throw new m("Review source does not match the document");return{reviewId:this.id(a),file:a,log:a.replace(/\.json$/,".log.jsonl"),sourceFile:s,source:i,raw:u,review:l?me(l,i,s):void 0,revision:_e(i,u)}}parseReview(t){let r;try{r=JSON.parse(t)}catch{throw new m("Review JSON is invalid")}if(typeof r.source!="string"||!Array.isArray(r.findings)||!Array.isArray(r.rules)||r.findings.some(n=>!n||typeof n.id!="string"||typeof n.rule!="string"||typeof n.match!="string"))throw new m("Review JSON is invalid");if(new Set(r.findings.map(n=>n.id)).size!==r.findings.length)throw new m("Review finding identities are duplicated");return r}async read(t){let r=this.file(t),n=await q(r),s=this.parseReview(n),a=await this.document(h.resolve(this.projectBase,s.source));return this.capture(a,r,!0)}assertMutable(t){this.output(t.sourceFile,t.file)}async list(){let t;try{if(await D(this.reviewsDir)!==this.reviewsDir)throw new m("Review directory must not be a symlink");t=await Ke(this.reviewsDir)}catch(n){if(n.code==="ENOENT"){if(!this.config)return[];t=[]}else throw n}this.config&&(t=this.config.documents.map(n=>n.reviewPath));let r=[];for(let n of t.filter(s=>s.endsWith(".json")&&(!this.config||this.config.documents.some(a=>a.reviewPath===h.resolve(this.reviewsDir,s)))).sort()){let s;try{s=await this.read(this.id(n))}catch(u){if(u.code==="ENOENT")continue;throw u}let a=!0;try{this.assertMutable(s)}catch{a=!1}let i={};for(let u of s.review.findings){let c=u.status??"open";i[c]=(i[c]??0)+1}r.push({reviewId:s.reviewId,source:s.review.source,revision:s.revision,writable:a,counts:i})}return r}async decisions(t,r){let n=await q(t.log,!0);if(n&&!n.endsWith(`
|
|
16
|
+
`))throw new m("Decision log is incomplete");let s;try{s=n.split(`
|
|
17
|
+
`).filter(Boolean).map(u=>JSON.parse(u))}catch{throw new m("Decision log is invalid")}if(s=s.filter(u=>!u.action?.startsWith("rewrite.")),s.some(u=>!u||!["accept","dismiss","revert","restore","supersede","unsupersede","carry","uncarry"].includes(u.action)||typeof u.timestamp!="string"))throw new m("Decision log is invalid");if(!r)return s;let a=s.findIndex(u=>u.eventId===r);if(a>=0)return s.slice(a+1);let i=Date.parse(r);if(!Number.isFinite(i))throw new m("Unknown decision cursor");return s.filter(u=>Date.parse(u.timestamp)>i)}async siteDecisions(){let t=this.config?this.config.documents.map(n=>n.reviewPath):(await Ke(this.reviewsDir).catch(()=>[])).filter(n=>n.endsWith(".json")).map(n=>h.join(this.reviewsDir,n)),r=[];for(let n of t)r.push(...await this.decisions({log:n.replace(/\.json$/,".log.jsonl")}).catch(()=>[]));return r}async strictnessResets(){let t=await q(h.join(this.root,".proofmarks/strictness.json"),!0);try{let r=t?JSON.parse(t).resets:void 0;return r&&typeof r=="object"?Object.fromEntries(Object.entries(r).filter(([,n])=>typeof n=="string"&&Number.isFinite(Date.parse(n)))):{}}catch{return{}}}async resetStrictness(t){let r=h.join(this.root,".proofmarks");if(await W(r,{recursive:!0,mode:448}),await D(r)!==r)throw new m("Proofmarks directory must not be a symlink");await ge(h.join(r,"strictness.json.lock"),async()=>{let n={...await this.strictnessResets(),[t]:new Date().toISOString()};await B(h.join(r,"strictness.json"),{version:1,resets:n})})}async commit(t,r){return this.assertMutable(t),ge(t.log+".lock",async()=>{let[n,s]=await Promise.all([q(t.sourceFile),q(t.file,!0)]);if(_e(n,s)!==t.revision)throw new m("Source or review changed; reload before proposing or refreshing");let a=me(await r(),n,t.sourceFile);if(await q(t.sourceFile)!==n||await q(t.file,!0)!==s)throw new m("Source or review changed while preparing the update");return await B(t.file,a),a})}async dismissalKeys(t){let r=await this.readMemory(),n=new Set(r.map(a=>R({rule:a.rule,match:a.text}))),s=this.dismissals(await this.decisions(t));for(let[a,i]of s)i.dismissed?n.add(a):r.some(u=>u.reviewId!==t.reviewId&&R({rule:u.rule,match:u.text})===a)||n.delete(a);return n}dismissals(t){let r=new Map;for(let n of t){let s=n.before?.finding??n.after?.finding;s&&(n.action==="dismiss"&&r.set(R(s),{finding:s,dismissed:!0}),(n.action==="restore"||n.action==="revert"&&n.before?.finding?.status==="dismissed")&&r.set(R(s),{finding:s,dismissed:!1}))}return r}async readMemory(){let t=h.join(this.root,".proofmarks/dismissed.json"),r=await q(t,!0);if(!r)return[];let n;try{let s=JSON.parse(r);n=Array.isArray(s)?s:s.entries}catch{throw new m("Dismiss memory is invalid")}if(!Array.isArray(n)||n.some(s=>!s||typeof s.rule!="string"||typeof s.text!="string"||s.reviewId!==void 0&&typeof s.reviewId!="string"))throw new m("Dismiss memory is invalid");return n}async saveDismissals(t){let r=h.join(this.root,".proofmarks");if(await W(r,{recursive:!0,mode:448}),await D(r)!==r)throw new m("Dismiss memory directory must not be a symlink");await ge(h.join(r,"dismissed.json.lock"),async()=>{let n=await this.readMemory(),s=this.dismissals(await this.decisions(t)),a=n.filter(i=>i.reviewId!==t.reviewId||!s.has(R({rule:i.rule,match:i.text})));for(let i of s.values())i.dismissed&&a.push({rule:i.finding.rule,text:Qe(i.finding.match),reviewId:t.reviewId});(a.length||n.length)&&await B(h.join(r,"dismissed.json"),{version:1,entries:a})})}};function ra(e,t,r){let n=new Map(e?.findings.map(u=>[R(u),u])??[]),s=new Set(e?.findings.map(u=>u.id)),a=new Set,i=[];for(let u of t.findings){let c=R(u),l=n.get(c);if(r.has(c)||l?.status==="dismissed")continue;let o=l?.id??u.id;(!l&&s.has(o)||a.has(o))&&(o="F"+Ye("sha256").update(c).digest("hex").slice(0,16)),!a.has(o)&&(a.add(o),i.push({...l,...u,id:o,...l?{status:l.status??u.status,proposed:l.proposed,proposals:l.proposals,rewriteRequest:l.rewriteRequest,judge:{...u.judge,...l.judge?.after?{after:l.judge.after}:{}}}:{}}))}for(let u of e?.findings??[])!a.has(u.id)&&(u.status&&u.status!=="open"||!r.has(R(u))&&(u.proposed!==void 0||u.rewriteRequest))&&(i.push(u),a.add(u.id));return{...e,...t,findings:i}}function na(e,t){if(!e)return e;let r=new Map;for(let n of t)n.after?.finding&&r.set(n.after.finding.id,n.after.finding);return{...e,findings:e.findings.map(n=>{let s=r.get(n.id);return!s||R(s)!==R(n)||(s.status??"open")===(n.status??"open")?n:{...n,...s}})}}function K(e){if(e.proposals?.length)return e.proposals;if(e.proposed===void 0)return[];let t=e.rewriteRequest;return[{version:1,text:e.proposed,...t?.by?{by:t.by}:{},...t?.proposedAt?{proposedAt:t.proposedAt}:{},...t?.stillFlagged?{stillFlagged:!0}:{}}]}var et=e=>Math.max(0,...K(e).map(t=>t.version))+1;import{randomUUID as qr}from"node:crypto";import{open as Rr,readFile as rt,realpath as Er}from"node:fs/promises";import{watch as Dr,watchFile as jr,unwatchFile as Ar}from"node:fs";function Lr(e,t){let r=z(e).filter(n=>n.text.includes(t.match));return r.length===1?r[0].text:t.match}function Tr(e,t){let r=e.before,s=e.after?.finding??r?.finding;if(!s)return;let a=typeof e.action=="string"&&(e.action.startsWith("rewrite.")||e.action.startsWith("decision."))?e.action:{accept:"decision.accepted",dismiss:"decision.dismissed",revert:"decision.undone",restore:"decision.undone"}[String(e.action)];if(!["rewrite.requested","rewrite.claimed","rewrite.proposed","rewrite.failed","decision.accepted","decision.dismissed","decision.undone"].includes(a??"")||typeof e.eventId!="string"||typeof e.timestamp!="string")return;let i=s.rewriteRequest,u=a==="rewrite.requested"?K(s).map(c=>c.text):[];return{v:1,id:e.eventId,type:a,at:e.timestamp,reviewId:t,findingId:s.id,rule:s.rule,...i?.target?{target:i.target}:{},...a.startsWith("rewrite.")?{version:i?.version??(a==="rewrite.proposed"?K(s).length:et(s))}:{},...u.length?{previous:u}:{},...a==="rewrite.requested"?{original:s.match,paragraph:String(e.paragraph??s.match),why:String(e.why??"")}:{},...a==="rewrite.claimed"?{by:i?.claimedBy}:{},...a==="rewrite.proposed"?{by:i?.by,text:s.proposed??"",stillFlagged:!!i?.stillFlagged}:{},...a==="rewrite.failed"?{by:i?.claimedBy??i?.target,reason:i?.error??"Rewrite failed"}:{}}}async function tt(e,t={}){let r=[],n={...t};for(let s of await e.list()){let a=await e.read(s.reviewId),i="";try{i=await rt(a.log,"utf8")}catch(o){if(o.code!=="ENOENT")throw o}if(i&&!i.endsWith(`
|
|
18
|
+
`))throw new m("Decision log is incomplete");let u=i.split(`
|
|
19
|
+
`).filter(Boolean).map(o=>JSON.parse(o)),c=t[s.reviewId]?u.findIndex(o=>o.eventId===t[s.reviewId])+1:0;if(t[s.reviewId]&&c===0)throw new m("Unknown event cursor");for(let o of u.slice(c)){let d=Tr(o,s.reviewId);d&&r.push(d)}let l=u.at(-1);typeof l?.eventId=="string"&&(n[s.reviewId]=l.eventId)}return{events:r,cursor:n}}async function Nr(e,t,r,n){let s=fe().rules.find(c=>c.id===t.rule),a={eventId:qr(),timestamp:new Date().toISOString(),id:e.reviewId,beforeRevision:e.revision,action:n,finding:t.id,before:{finding:t},after:{finding:r},paragraph:Lr(e.source,t),why:s?.why??""},i="";try{if(await Er(e.log)!==e.log)throw new m("Decision log must not be a symlink");i=await rt(e.log,"utf8")}catch(c){if(c.code!=="ENOENT")throw c}if(i&&!i.endsWith(`
|
|
20
|
+
`))throw new m("Decision log is incomplete");for(let c of i.split(`
|
|
21
|
+
`).filter(Boolean))JSON.parse(c);let u=await Rr(e.log,"a",384);try{await u.writeFile(JSON.stringify(a)+`
|
|
22
|
+
`),await u.sync()}finally{await u.close()}return a.eventId}async function nt(e,t,r,n,s){let a=await e.read(t);e.assertMutable(a);let i=await G(a.log+".lock").catch(()=>{throw new m("Review is busy; retry after the current action")});try{let u=await e.read(t),c=u.review.findings.find(d=>d.id===r);if(!c)throw new m("Finding does not exist");let l=n(c,u);if(!l)return c;let o=s?await Nr(u,c,l,s):void 0;return await B(u.file,{...u.review,...o?{proofmarksEventCursor:o}:{},findings:u.review.findings.map(d=>d.id===r?l:d)}),l}finally{await i.close();let{unlink:u}=await import("node:fs/promises");await u(a.log+".lock")}}async function Cr(e,t=Date.now()){let r=n=>n.rewriteRequest?.status==="claimed"&&t-Date.parse(n.rewriteRequest.claimedAt??"")>=12e4;for(let n of await e.list()){if(!n.writable)continue;let s=await e.read(n.reviewId);for(let a of s.review.findings)r(a)&&await nt(e,n.reviewId,a.id,i=>r(i)?{...i,rewriteRequest:{...i.rewriteRequest,status:"pending",claimedBy:void 0,claimedAt:void 0}}:void 0,"rewrite.requested")}}async function fa(e,t,r,n){return await Cr(e),nt(e,t,r,s=>{if((s.status??"open")!=="open"||s.rewriteRequest?.status!=="pending")throw new m("This rewrite is not pending or is already claimed");if(s.rewriteRequest.target&&s.rewriteRequest.target!==n)throw new m("This rewrite is targeted at another agent");return{...s,rewriteRequest:{...s.rewriteRequest,status:"claimed",claimedBy:n,claimedAt:new Date().toISOString()}}},"rewrite.claimed")}async function Pr(e,t,r){let n=[];for(let s of t)if(s.target===r){if(s.type.startsWith("rewrite.")){let a=(await e.read(s.reviewId)).review.findings.find(i=>i.id===s.findingId);if(!a||(a.status??"open")!=="open"||s.type==="rewrite.requested"&&a.rewriteRequest?.requestedBy===r)continue}n.push(s)}return n}async function ma(e,t,r){let n=(await tt(e)).cursor,s=!1,a=!1,i=!1,u=async()=>{if(!s){if(a){i=!0;return}a=!0;try{let l=await tt(e,n);for(let o of await Pr(e,l.events,t))s||r(o);n=l.cursor}catch{}finally{a=!1,i&&!s&&(i=!1,u())}}},c=Ir(e,()=>{u()});return{close(){s=!0,c()}}}function Ir(e,t){let r=!1,n=[],s=!1,a=c=>{let l=()=>t();jr(c,{interval:200,persistent:!1},l),n.push(()=>Ar(c,l))},i=()=>{if(!(s||r))if(s=!0,e.config)for(let c of e.config.documents)a(c.logPath),a(c.reviewPath);else e.list().then(async c=>{for(let l of c){if(r)break;let o=await e.read(l.reviewId);a(o.log),a(o.file)}}).catch(()=>{})},u=new Set(e.config?.documents.map(c=>c.reviewPath.slice(0,c.reviewPath.lastIndexOf("/")))??[e.reviewsDir]);for(let c of u)try{let l=Dr(c,(o,d)=>{(d?.toString().endsWith(".log.jsonl")||d?.toString().endsWith(".json"))&&t()});l.on("error",()=>{l.close(),i()}),n.push(()=>l.close())}catch{i()}return()=>{r=!0,n.forEach(c=>c())}}export{k as a,Z as b,be as c,T as d,ut as e,ye as f,ot as g,ct as h,ve as i,Wr as j,Kr as k,ft as l,qe as m,Re as n,Q as o,ee as p,N as q,z as r,Te as s,te as t,O as u,Oe as v,ir as w,Ve as x,fe as y,Je as z,me as A,We as B,G as C,Me as D,m as E,R as F,B as G,Ze as H,ra as I,na as J,K,et as L,Lr as M,tt as N,nt as O,Cr as P,fa as Q,Pr as R,ma as S,Ir as T};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Built by Proofmarks.
|
|
2
|
+
import{c as X,d as Y,r as ee}from"./node-6KSUNIF7.js";import{D as de,E as x,F as le,H as $,I as ue,J as ge,K as T,L as P,O as B,P as me,Q as fe,a as W,l as M,m as F,n as C,o as te,p as re,q as ie,r as N,s as ne,t as Q,u as se,v as oe,w as ae,y as A,z as ce}from"./node-VICV4ZWL.js";import{readFile as Ye}from"node:fs/promises";import{homedir as et}from"node:os";import Ne from"node:path";import{readFile as Me}from"node:fs/promises";async function L(n,e,r=new URL("../../rules/calibration/",import.meta.url)){if(!/^[a-zA-Z0-9._-]+$/.test(n)||!/^[a-zA-Z0-9._-]+$/.test(e))throw new Error("Invalid calibration identifier");let t=JSON.parse(await Me(new URL(`${n}-${e}.json`,r),"utf8")),i=t.rules??t;for(let s of Object.values(i))if(s.reviewBand??=s.band,typeof s.threshold!="number"||s.threshold<0||s.threshold>1||!Array.isArray(s.reviewBand)||s.reviewBand.length!==2||s.reviewBand.some(o=>typeof o!="number"||o<0||o>1)||s.reviewBand[0]>s.reviewBand[1]||!Number.isInteger(s.repeats)||s.repeats<1)throw new Error("Invalid calibration");return{rules:i,rulesVersion:t.rulesVersion}}function Ce(n){if(!n.length||n.some(e=>!Number.isFinite(e)||e<0||e>1))throw new Error("Invalid probabilities");return n.reduce((e,r)=>e+r,0)/n.length}function pe(n,e){let r=Ce(n);return{probability:r,threshold:e?.threshold,decision:e?r>=e.reviewBand[0]&&r<=e.reviewBand[1]?"review":r>=e.threshold?"flag":"clear":"review"}}import{createHash as $e}from"node:crypto";import{mkdir as Te,readFile as Be,writeFile as Le,appendFile as he}from"node:fs/promises";import z from"node:path";async function V(n,e,r,t){let i=n.capabilities.maxQuestionsPerCall;if(!Number.isInteger(i)||i<1)throw new Error("Invalid question limit");if(new Set(r.map(c=>c.id)).size!==r.length)throw new Error("Duplicate question id");let s=[],o=c=>t.calibration?.rules[c.id]?.repeats??t.repeats??1,a=Math.max(1,...r.map(o));if(!Number.isInteger(a)||a>20)throw new Error("Invalid repeat count");for(let c=0;c<a;c++){let w=r.filter(d=>c<o(d));for(let d=0;d<w.length;d+=i)s.push({questions:w.slice(d,d+i),repeat:c+(t.replicateOffset??0)})}let u={calls:s.length,dollars:s.length*(n.capabilities.pricing==="per-call"?.001:65536*X/1e6)};t.onEstimate?.(u),await Te(t.cacheDir,{recursive:!0,mode:448});let l=new Array(s.length),g=0,m=Math.max(1,Math.min(16,t.concurrency??4));await Promise.all(Array.from({length:m},async()=>{for(;g<s.length;){t.signal?.throwIfAborted();let c=g++,w=s[c],d=$e("sha256").update(JSON.stringify({provider:n.id,model:n.model,rulesVersion:t.rulesVersion,input:e,...w})).digest("hex"),b=z.join(t.cacheDir,d+".json"),y;try{y=JSON.parse(await Be(b,"utf8"))}catch(v){if(v.code!=="ENOENT")throw new Error("Invalid judge cache")}if(y)y={...y,cached:!0,usage:{calls:0,dollars:0}};else try{let v=await n.judge(e,w.questions,{signal:t.signal}),D=w.questions.map(k=>{let R=v.answers.find(h=>h.id===k.id)?.probability;if(typeof R!="number"||!Number.isFinite(R)||R<0||R>1)throw new Error("Invalid answer");return{id:k.id,probability:R}});if(!Number.isFinite(v.usage.dollars)||v.usage.dollars<0)throw new Error("Invalid usage");y={answers:D,provider:n.id,model:n.model,latencyMs:v.latencyMs,cached:!1,usage:{calls:v.usage.calls,dollars:v.usage.dollars,...v.usage.inputTokens===void 0?{}:{inputTokens:v.usage.inputTokens}}},await Le(b,JSON.stringify(y),{mode:384})}catch(v){throw await he(z.join(t.cacheDir,"ledger.jsonl"),JSON.stringify({key:d,status:"failed",unknownUsage:!0})+`
|
|
3
|
+
`,{mode:384}),Y(v)}l[c]=y,await he(z.join(t.cacheDir,"ledger.jsonl"),JSON.stringify({key:d,cached:y.cached,...y.usage})+`
|
|
4
|
+
`,{mode:384})}}));let p=r.map(c=>({id:c.id,...pe(l.flatMap(w=>w.answers.filter(d=>d.id===c.id).map(d=>d.probability)),t.calibration?.rules[c.id])})),f=l.reduce((c,w)=>({calls:c.calls+w.usage.calls,dollars:c.dollars+w.usage.dollars,cached:c.cached+Number(w.cached)}),{calls:0,dollars:0,cached:0});return{answers:p,estimate:u,ledger:f,results:l}}import xe from"node:path";import{readFile as ye}from"node:fs/promises";import{createHash as Qe}from"node:crypto";import{homedir as ze}from"node:os";import H from"node:path";var I={minimum:8,step:.05,reach:.15,gain:3,edge:.1,edgeMinimum:5,keptShare:.9};function Ve(n){let e=new Map;for(let r of n){let t=r.before?.finding??r.after?.finding;if(!t)continue;let i=le(t);if(r.action==="revert"||r.action==="restore"){e.delete(i);continue}if(r.action!=="accept"&&r.action!=="dismiss")continue;let s=t.judge?.probability??t.judge?.score,o=t.judge?.threshold;typeof s!="number"||typeof o!="number"||typeof r.timestamp!="string"||(e.delete(i),e.set(i,{rule:t.rule,score:s,line:o,kept:r.action==="accept",at:r.timestamp}))}return[...e.values()]}var O=n=>Math.round(n*100)/100;function Ue(n,e){let r=e.filter(g=>g.kept).length,t={line:n,base:n,kept:r,dismissed:e.length-r};if(e.length<I.minimum)return t;let i=Math.max(.05,O(n-I.reach)),s=Math.min(.95,O(n+I.reach)),o=Math.min(...e.map(g=>g.line)),a=n;for(;O(a-I.step)>=i&&a>=o-1e-9;){let g=e.filter(m=>m.score>=a-1e-9&&m.score<a+I.edge);if(g.length<I.edgeMinimum||g.filter(m=>m.kept).length<I.keptShare*g.length)break;a=O(a-I.step)}let u=g=>e.filter(m=>m.score>=g-1e-9===m.kept).length,l=a;for(let g=O(a+I.step);g<=s+1e-9;g=O(g+I.step))u(g)>u(l)&&(l=g);return u(l)-u(a)>=I.gain&&(a=l),{...t,line:a}}function _e(n,e,r={}){return Object.entries(n).map(([t,i])=>({rule:t,...Ue(i,e.filter(s=>s.rule===t&&(!r[t]||Date.parse(s.at)>Date.parse(r[t]))))}))}async function U(n,e){return _e(e,Ve(await n.siteDecisions()),await n.strictnessResets())}var we=n=>n.filter(e=>e.line!==e.base),be=n=>n.filter(e=>e.kept+e.dismissed>0);async function ve(n,e,r,t,i){let s=JSON.parse(await ye(new URL("../../rules/rules.v3.json",import.meta.url),"utf8")),o,a=t.id==="fake"?"fixture":"calibrated";try{let d=await L(t.id,t.model),b=JSON.parse(await ye(new URL(`../../rules/calibration/${t.id}-${t.model}.json`,import.meta.url),"utf8"));if(b.rulesVersion!==s.version)throw new Error("Calibration rules version mismatch");o={...b,rules:Object.fromEntries(Object.entries(d.rules).map(([y,v])=>[y,{...v,band:v.reviewBand}]))}}catch(d){if(d.code!=="ENOENT")throw d;t.id!=="fake"&&(a="suggest-only"),o={provider:t.id,model:t.model,rulesVersion:s.version,labeledSetHash:"uncalibrated",fitted:"November 5, 2026",rules:Object.fromEntries(s.rules.map(b=>[b.id,{threshold:t.id==="fake"?.8:0,band:[0,1],repeats:1}]))}}let u=i.strictness&&a!=="suggest-only"?await i.strictness(Object.fromEntries(Object.entries(o.rules).map(([d,b])=>[d,b.threshold]))):[];for(let d of we(u))o.rules[d.rule]={...o.rules[d.rule],threshold:d.line};let l={calls:0,dollars:0,cached:0},g=new Map,m=0,p=[],f={...t,async judge(d,b,y){y?.signal?.throwIfAborted(),m>=4?await new Promise(v=>p.push(v)):m++;try{return y?.signal?.throwIfAborted(),await t.judge(d,b,y)}finally{let v=p.shift();v?v():m--}}},c={...t,async judge(d,b,y){let v=Qe("sha256").update(JSON.stringify({input:d,questions:b})).digest("hex"),D=g.get(v)??0;g.set(v,D+1);let k=performance.now(),R=await V(f,d,b,{cacheDir:i.cacheDir??H.join(ze(),".proofmarks/cache"),rulesVersion:s.version,signal:y?.signal??i.signal,onEstimate:i.onEstimate,replicateOffset:D});return l.calls+=R.ledger.calls,l.dollars+=R.ledger.dollars,l.cached+=R.ledger.cached,{answers:R.answers.map(({id:h,probability:S})=>({id:h,probability:S})),provider:t.id,model:t.model,latencyMs:performance.now()-k,cached:R.results.every(h=>h.cached),usage:{calls:R.ledger.calls,dollars:R.ledger.dollars,inputTokens:R.results.reduce((h,S)=>h+(S.usage.inputTokens??0),0)}}}},w=(await n({id:H.basename(r,H.extname(r)),kind:i.kind??"mdx",source:e},s,c,o,{signal:i.signal,concurrency:4,rules:He(s,i.rules)})).sort(ce);return{source:r,usage:l,reviewMode:a,strictness:be(u),rules:s.rules.map(d=>({id:d.id,label:d.label,color:d.color??"#87532f",mark:d.mark??"underline",rubric:{checks:d.why,looksLike:"",notLike:"",fix:d.fix}})),findings:w.map(({judge:d,...b})=>({...b,...a==="suggest-only"?{severity:"warning",note:"Uncalibrated suggestion. "+b.note}:{},...d?{judge:{...d,score:d.probability,candidate:b.match,scope:b.level==="word"?"phrase":"sentence"}}:{}})),judge:{provider:t.id,model:t.model,rulesVersion:s.version,generatedAt:new Date().toISOString()}}}function He(n,e={}){let r=Object.keys(e).filter(t=>!n.rules.some(i=>i.id===t));if(r.length)throw new W(`proofmarks.config.json turns on or off rules that don't exist: ${r.join(", ")}. See docs/configuration.md for the rule names.`);return n.rules.filter(t=>e[t.id]??t.default).map(t=>t.id)}var Dt="3";async function Re(n,e,r={}){let t=xe.resolve(n),i=await $.create(r.root??xe.dirname(t),{reviewsDir:r.reviewsDir}),s=await i.capture(t,r.out);r.signal?.throwIfAborted();let o=i.config?.documents.find(l=>l.sourcePath===s.sourceFile)?.format??F(s.sourceFile),a=o==="html"||o==="jinja"?M(o).regions(s.source).filter(l=>l.editable).map(l=>l.text).join(`
|
|
5
|
+
|
|
6
|
+
`):s.source,u=await ve(ae,a,i.sourceReference(s.sourceFile),e,{...r,kind:o==="html"||o==="jinja"?"text":"mdx",strictness:l=>U(i,l),rules:i.config?.rules});if(o==="html"||o==="jinja")for(let l of u.findings)try{l.span=C(s.source,l.match,o)}catch{Object.assign(l,{actionReason:"This match crosses markup or a template expression and cannot be edited."})}return i.commit(s,async()=>{r.signal?.throwIfAborted();let l=await i.dismissalKeys(s),g=ge(s.review,await i.decisions(s)),m=ue(g,u,l);return await i.saveDismissals(s),m})}import{spawn as Z}from"node:child_process";import{mkdir as je,open as Ze,readFile as G,rm as ke,writeFile as Fe}from"node:fs/promises";import j from"node:path";var J=n=>j.join(n,".proofmarks","dev.json"),q=n=>{try{return process.kill(n,0),!0}catch{return!1}};async function qt(n,e){await je(j.dirname(J(n)),{recursive:!0,mode:448}),await Fe(J(n),JSON.stringify(e)+`
|
|
7
|
+
`,{mode:384})}async function Se(n){await ke(J(n),{force:!0})}async function Ge(n){try{let e=JSON.parse(await G(J(n),"utf8"));return!Number.isInteger(e.port)||!Number.isInteger(e.pid)||!q(e.pid)?void 0:e}catch{return}}async function Ke(n){let e=await Ge(n);return e&&{address:`http://127.0.0.1:${e.port}`,pid:e.pid}}async function Oe(n){return(await Ke(n))?.address}var We=n=>new RegExp("^"+n.split("*").map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*")+"$"),Xe=n=>n.replace(/<(script|style)\b[\s\S]*?<\/\1>/gi," ").replace(/<[^>]+>/g," ").replace(/\s+/g," ");async function De(n,e,r,t,i=fetch){if(!n)return"/";if(!n.includes("*"))return n;let s=j.basename(e,j.extname(e)),o=j.dirname(e).split(/[\\/]/).filter(f=>f&&f!=="."),a=["",...o.map((f,c)=>"/"+o.slice(c).join("/")),...o.map(f=>"/"+f)],u=We(n),l=[...new Set(a.flatMap(f=>[`${f}/${s}/`,`${f}/${s}`,`${f}/${s}.html`]))].filter(f=>u.test(f)),g=[...r.replace(/^---[\s\S]*?\n---\n/,"").matchAll(/(?<![\w'’-])(?:[A-Za-z]{2,}[ \t]+){2,}[A-Za-z]{2,}(?![\w'’-])/g)].map(f=>f[0].replace(/\s+/g," ")).sort((f,c)=>c.length-f.length)[0],m=async f=>{try{let c=await i(new URL(f,t),{headers:{accept:"text/html"},redirect:"manual",signal:AbortSignal.timeout(5e3)});return c.ok?Xe(await c.text()):void 0}catch{return}},p=g?void 0:await m("/");for(let f of l){let c=await m(f);if(c!==void 0&&(g?c.includes(g):c!==p))return f}}async function Mt(n){let e;try{e=JSON.parse(await G(J(n),"utf8"))}catch{return!1}if(!Number.isInteger(e.pid)||!q(e.pid))return await Se(n),!1;process.kill(e.pid,"SIGTERM");for(let r=0;r<100&&q(e.pid);r++)await K(50);return await Se(n),!0}var _=n=>j.join(n,".proofmarks","site.json"),K=n=>new Promise(e=>setTimeout(e,n));async function Ie(n,e=fetch){try{return await e(n,{redirect:"manual",signal:AbortSignal.timeout(2e3)}),!0}catch{return!1}}async function Ct(n,e,r){await je(j.dirname(_(n)),{recursive:!0,mode:448});let t=await Ze(j.join(n,".proofmarks","site.log"),"a",384);try{let i=Z(r,{cwd:n,shell:!0,detached:!0,stdio:["ignore",t.fd,t.fd],env:ee()});i.unref(),await Fe(_(n),JSON.stringify({pid:i.pid})+`
|
|
8
|
+
`,{mode:384});for(let s=0;s<600&&i.exitCode===null;s++){if(await Ie(e))return!0;await K(100)}return Ie(e)}finally{await t.close()}}async function $t(n){let e;try{e=JSON.parse(await G(_(n),"utf8")).pid}catch{return!1}if(await ke(_(n),{force:!0}),typeof e!="number"||!Number.isInteger(e)||!q(e))return!1;process.platform==="win32"?Z("taskkill",["/pid",String(e),"/T","/F"],{stdio:"ignore"}):process.kill(-e,"SIGTERM");for(let r=0;r<100&&q(e);r++)await K(50);return!0}function Ee(n){let e=Z(process.platform==="darwin"?"open":process.platform==="win32"?"cmd":"xdg-open",process.platform==="win32"?["/c","start","",n]:[n],{stdio:"ignore",detached:!0});e.on("error",()=>{}),e.unref()}function Ae(n,e,r){let t=-1;for(let i=n.indexOf(e);i>=0;i=n.indexOf(e,i+1))(t<0||Math.abs(i-r)<Math.abs(t-r))&&(t=i);return t}function Pe(n,e){let r=n.source,t=F(n.sourceFile);if(t==="html"||t==="jinja"){let o=C(r,e.match,t),a=M(t).regions(r).find(u=>u.editable&&u.start<=o.start&&u.end>=o.end);if(!a)throw new x("Finding paragraph is no longer available");return{paragraph:a.text,start:o.start,offset:Ae(a.text,e.match,o.start-a.start)}}let i=e.span?.start;if((i===void 0||r.slice(i,i+e.match.length)!==e.match)&&(i=r.indexOf(e.match,ie(r)),i<0||r.indexOf(e.match,i+1)>=0))throw new x("Finding no longer has an exact unique source match");let s=N(r).find(o=>o.start<=i&&o.end>=i+e.match.length);if(!s)throw new x("Finding paragraph is no longer available");return{paragraph:s.text,start:i,offset:Ae(s.text,e.match,i-s.start)}}function tt(n,e,r,t){if(e<0)return;let i=Q({text:n}).find(o=>o.start<=e&&o.end>=e+r.length);if(!i)return;let s=n.slice(i.start,e).trimStart();return{sentence:(s+t+n.slice(e+r.length,i.end)).trimEnd(),start:s.length,end:s.length+t.length}}function rt(n,{paragraph:e,start:r,offset:t},i,s,o){let a=F(n.sourceFile),u,l,g;if(a==="html"||a==="jinja")[u,l,g]=[e,t,ne];else{let p=N(n.source).find(f=>f.start<=r&&f.end>=r+i.length);if(!p)return;[u,l,g]=[n.source.slice(p.start,p.end),r-p.start,N]}if(l<0)return;let m=u.slice(0,l)+s+u.slice(l+i.length);return g(m).flatMap(p=>{let f=Q(p);return se[o]({block:p,sentences:f,source:m}).filter(c=>p.map[c.start]<l+s.length&&p.map[c.end-1]>=l).map(c=>({term:p.text.slice(c.start,c.end),sentence:f.find(w=>w.start<=c.start&&w.end>=c.end)?.text??p.text}))})}var Je=class n{constructor(e,r){this.store=e;this.options=r}store;options;static async create(e){return new n(await $.create(e.root),e)}async listReviews(){return{reviews:await this.store.list()}}async pendingRewrites(){await me(this.store);let e=A(),r=[],t=[];for(let i of await this.store.list()){if(!i.writable)continue;let s=await this.store.read(i.reviewId);for(let o of s.review.findings)if(!(o.rewriteRequest?.status!=="pending"||o.rewriteRequest.target&&o.rewriteRequest.target!==this.options.agent||(o.status??"open")!=="open"))try{let a=e.rules.find(l=>l.id===o.rule);if(!a)throw new x("Finding rule is not registered");let u=T(o).map(l=>l.text);r.push({reviewId:i.reviewId,findingId:o.id,version:o.rewriteRequest.version??P(o),...u.length?{previous:u}:{},revision:s.revision,source:s.review.source,path:s.sourceFile,match:o.match,paragraph:Pe(s,o).paragraph,rule:{id:a.id,label:a.label,why:a.why,fix:a.fix,edit:a.edit,level:a.level}})}catch(a){t.push({reviewId:i.reviewId,findingId:o.id,reason:a instanceof x?a.message:"This proof could not be located in the source"})}}return{pending:r,skipped:t}}async proposeRewrite(e,r){let t=await this.store.read(e.reviewId);this.store.assertMutable(t);let i=t.review.findings.find(c=>c.id===e.findingId);if(!i)throw new x("Finding does not exist");if((i.status??"open")!=="open")throw new x("Finding is already resolved");let s=i.rewriteRequest,o=this.options.agent??"agent";if(!s||s.target&&s.target!==o||!(s.status==="pending"||s.status==="claimed"&&s.claimedBy===o&&Date.now()-Date.parse(s.claimedAt??"")<12e4))throw new x("No pending rewrite request. Accept, Undo and Dismiss are decisions, not requests; wait for a new rewrite request.");let u=A().rules.find(c=>c.id===i.rule);if(!u)throw new x("Finding rule is not registered");if(!e.text.trim()&&u.edit!=="delete")throw new x("Rewrite must not be empty");if(e.text.trim()===i.match.trim())throw new x("Rewrite must differ from the original");if(T(i).some(c=>c.text.trim()===e.text.trim()))throw new x("Rewrite must differ from every earlier version");let{after:g,stillFlagged:m}=await this.score(t,i,u,e.text,r),p=s.version??P(i),f=new Date().toISOString();return await B(this.store,e.reviewId,e.findingId,(c,w)=>{let d=c.rewriteRequest;if(w.source!==t.source)throw new x("Source changed while the rewrite was judged; ask again");if((c.status??"open")!=="open"||!d||d.requestedAt!==s.requestedAt||(d.version??P(c))!==p||!(d.status==="pending"||d.status==="claimed"&&d.claimedBy===o))throw new x("No pending rewrite request. Accept, Undo and Dismiss are decisions, not requests; wait for a new rewrite request.");let{stillFlagged:b,...y}=d;return{...c,proposed:e.text,proposals:[...T(c),{version:p,text:e.text,by:o,proposedAt:f,...m?{stillFlagged:!0}:{}}],rewriteRequest:{...y,status:"proposed",version:p,proposedAt:f,by:o,...m?{stillFlagged:!0}:{}},judge:{...c.judge,after:g}}},"rewrite.proposed"),{after:g,stillFlagged:m,version:p}}async checkRewrite(e,r){let t=await this.store.read(e.reviewId),i=t.review.findings.find(l=>l.id===e.findingId);if(!i)throw new x("Finding does not exist");if((i.status??"open")!=="open")throw new x("Finding is already resolved");let s=A().rules.find(l=>l.id===i.rule);if(!s)throw new x("Finding rule is not registered");if(!e.text.trim()&&s.edit!=="delete")throw new x("Rewrite must not be empty");if(e.text.trim()===i.match.trim())throw new x("Rewrite must differ from the original");let{after:o,threshold:a,stillFlagged:u}=await this.score(t,i,s,e.text,r);return{probability:o.probability,threshold:a,clears:!u}}async requestRewrites(e){let r=this.options.agent??"agent",t=await this.store.read(e.reviewId);this.store.assertMutable(t);let i=a=>(a.status??"open")!=="open"?"Already decided":a.proposed!==void 0?"Already has a rewrite":["pending","claimed"].includes(a.rewriteRequest?.status??"")?"A rewrite is already on the way":void 0,s=[],o=[];for(let a of e.findingIds??[])t.review.findings.some(u=>u.id===a)||o.push({findingId:a,reason:"No such proof"});for(let a of t.review.findings){if(e.findingIds&&!e.findingIds.includes(a.id))continue;let u=i(a);if(u){e.findingIds&&o.push({findingId:a.id,reason:u});continue}let l=new Date().toISOString(),g=await B(this.store,e.reviewId,a.id,m=>i(m)?void 0:{...m,rewriteRequest:{status:"pending",version:P(m),requestedAt:l,target:r,requestedBy:r}},"rewrite.requested");g.rewriteRequest?.requestedAt===l?s.push(a.id):o.push({findingId:a.id,reason:i(g)??"Changed while requesting"})}return{requested:s,skipped:o}}async openPage(e){let r=this.store.config,t=r?.documents.find(a=>a.id===e);if(!r||!t)throw new x("Review is not in this project");let i=await Oe(r.projectRoot);if(!i)return{opened:!1,reason:"The page isn't being served. Start it with `proofmarks dev --background` in the project, then call this again."};let s=await De(t.url,de(r.projectRoot,t.sourcePath),await Ye(t.sourcePath,"utf8").catch(()=>""),i,this.options.request);if(!s)return{opened:!1,reason:`Couldn't find this page on the site: its url in proofmarks.config.json, ${t.url}, is a pattern. Open ${i}, go to the page, and set that url to its path.`};let o=new URL(s,i);return o.searchParams.set("proof","1"),(this.options.openUrl??Ee)(o.href),{opened:!0,url:o.href}}async score(e,r,t,i,s){let o=A(),a=Pe(e,r),{paragraph:u,offset:l}=a,g=(h,S)=>{let E=qe=>qe.replaceAll("{term}",h);return{id:S,kind:"yes-no",ask:oe+E(t.judge?.ask??`Does target still have this problem: ${t.why}`),yes:E(t.judge?.yes??t.why),no:E(t.judge?.no??t.fix)}},m=this.options.provider,p=r.judge?.threshold,f=1;try{let h=await L(m.id,m.model);if(h.rulesVersion!==o.version)throw new x("Calibration rules version mismatch");p=h.rules[t.id]?.threshold??p,f=h.rules[t.id]?.repeats??1}catch(h){if(h.code!=="ENOENT")throw h}if(p===void 0||!Number.isFinite(p))throw new x("A calibrated threshold is required to score a rewrite");p=(await U(this.store,{[t.id]:p}))[0].line;let c={after:{probability:0,provider:m.id,model:m.model},threshold:p,stillFlagged:!1};if(!i.trim())return c;let w,d,b,y=t.detector.kind==="lexicon"&&t.level==="word"?tt(u,l,r.match,i):void 0;if(t.detector.kind==="lexicon"&&y){let h=re(y.sentence,te(t.detector.terms)).filter(S=>S.start<y.end&&S.end>y.start);if(!h.length)return c;w=y.sentence,d=h.map((S,E)=>g(S.text,`${t.id}__${E}`))}else if(t.detector.kind==="pattern"&&t.level==="word"&&(b=rt(e,a,r.match,i,t.detector.pattern))){if(!b.length)return c;w=b[0].sentence,d=b.map((h,S)=>g(h.term,`${t.id}__${S}`))}else{let h=F(e.sourceFile);if(w=h==="html"||h==="jinja"?i:N(i).map(S=>S.text).join(`
|
|
9
|
+
|
|
10
|
+
`),!w.trim())return c;d=[g(r.focus?r.match.slice(r.focus.start,r.focus.end):r.match,t.id)]}let v=await V(m,{target:w,...t.judge?.context==="paragraph"?{context:u}:{}},d,{cacheDir:this.options.cacheDir??Ne.join(et(),".proofmarks/cache"),rulesVersion:o.version,repeats:f,signal:s}),k={probability:Math.max(...v.answers.map(h=>h.probability)),provider:m.id,model:m.model},R=k.probability>=p;return{after:k,threshold:p,stillFlagged:R}}async reportFailure(e){let r=e.reason.trim();if(!r||r.length>1e3||/[\u0000-\u001f\u007f]/.test(r))throw new x("Use one plain sentence explaining why the rewrite failed");return{finding:await B(this.store,e.reviewId,e.findingId,i=>{let s=i.rewriteRequest;if((i.status??"open")!=="open"||s?.status!=="claimed"||s.claimedBy!==this.options.agent||!(Date.now()-Date.parse(s.claimedAt??"")<12e4))throw new x("Only the agent holding this claim may report failure");return{...i,rewriteRequest:{...s,status:"failed",error:r}}},"rewrite.failed")}}async claim(e,r){return{finding:await fe(this.store,e,r,this.options.agent??"agent")}}async decisions(e,r){let t=await this.store.read(e);return{decisions:await this.store.decisions(t,r)}}async review(e,r){let t=await this.store.document(Ne.resolve(this.store.projectBase,e)).catch(()=>this.store.document(e)),i=await Re(t,this.options.provider,{root:this.store.root,cacheDir:this.options.cacheDir,signal:r}),s=await this.store.capture(t);return{reviewId:s.reviewId,revision:s.revision,review:i}}};export{U as a,ve as b,Dt as c,Re as d,qt as e,Se as f,Ke as g,Oe as h,Mt as i,Ie as j,Ct as k,$t as l,Ee as m,Je as n};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"file": "index.js",
|
|
4
|
+
"bytes": 70,
|
|
5
|
+
"gzip": 85
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"file": "overlay/react.js",
|
|
9
|
+
"bytes": 3046,
|
|
10
|
+
"gzip": 1423
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"file": "script-entry.js",
|
|
14
|
+
"bytes": 3151,
|
|
15
|
+
"gzip": 1507
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"file": "chunk-FIVQWTE5.js",
|
|
19
|
+
"bytes": 205038,
|
|
20
|
+
"gzip": 66668
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"file": "chunk-GMJHTMKC.js",
|
|
24
|
+
"bytes": 2320,
|
|
25
|
+
"gzip": 1110
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"file": "proofmarks-font.js",
|
|
29
|
+
"bytes": 100406,
|
|
30
|
+
"gzip": 75666
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"file": "script.js",
|
|
34
|
+
"bytes": 249,
|
|
35
|
+
"gzip": 195
|
|
36
|
+
}
|
|
37
|
+
]
|