1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[748],{1010:(e,t,s)=>{Promise.resolve().then(s.t.bind(s,2619,23)),Promise.resolve().then(s.bind(s,7873))},7873:(e,t,s)=>{"use strict";s.d(t,{EssayEditorTool:()=>j});var a=s(5155),n=s(2115),r=s(212),l=s(3630),i=s(2033),d=s(3807),o=s(8788),c=s(9795),x=s(2593),h=s(406),m=s(1432),u=s(5327);let g=new Set(["the","a","an","and","or","but","if","then","so","because","as","of","at","by","for","with","about","into","to","from","in","on","is","are","was","were","be","been","being","have","has","had","do","does","did","will","would","can","could","should","may","might","must","that","this","these","those","it","its","they","them","their","we","our","you","your","i","my","he","she","his","her","not","no","there","which","who","what","when","where","how","more","most","some","any","all","also","than","too","very","just","only","other","such","one","two","up","out","over"]),p=/\b(?:is|are|was|were|be|been|being|am)\b/gi;var b=s(5910),f=s(7616);let w=[250,500,750,1e3,1500,2e3];function j(){var e;let[t,s]=(0,n.useState)(""),[h,j]=(0,n.useState)(500),[y,S]=(0,n.useState)("stats"),[M,C]=(0,n.useState)(null),[L,A]=(0,n.use
1State)(""),E=(0,f._G)(),P=(0,n.useCallback)(e=>{E.reset(),s(e)},[E]);(0,f.Te)("edit",t,P),(0,f.OJ)("edit",P),(0,n.useEffect)(()=>{let e=setTimeout(()=>A(t),200);return()=>clearTimeout(e)},[t]);let{metrics:R,paragraphs:T,flags:_,overused:W}=(0,n.useMemo)(()=>(function(e){var t;let s=(0,u.PC)(e),a=null!=(t=e.match(RegExp("[\\p{L}'-]+","gu")))?t:[],n=a.length,r=a.reduce((e,t)=>e+function(e){let t=e.toLowerCase().replace(/[^a-z]/g,"");if(!t)return 0;if(t.length<=3)return 1;let s=t.replace(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/,"").replace(/^y/,"").match(/[aeiouy]{1,2}/g);return Math.max(1,s?s.length:1)}(t),0),l=[],i=0,d=0;for(let e of s){let t=(0,u.rj)(e.text);for(let s of(t>i&&(i=t),t>=30&&l.push({start:e.start,end:e.end,kind:"long-sentence",note:t>=45?"".concat(t," words. This one needs splitting."):"".concat(t," words. Consider splitting it.")}),function(e){let t,s=[],a=e.text;for(p.lastIndex=0;null!==(t=p.exec(a));){let n=a.slice(t.index+t[0].length).match(RegExp("^\\s+(\\w+ly\\s+)?([\\p{L}'-]+)","u"));if(!n||!function(e){let t=e.toLowerCase();return!!/(ed|en)$/.test(t)&&t.length>4||["made","done","given","taken","seen","known","shown","held","found","built","brought","told","kept","left","sent","put","set","won","lost","written","driven"].includes(t)}(n[2]))continue;let r=e.start+t.index,l=r+t[0].length+n[0].length;s.push({start:r,end:l,kind:"passive",note:"Passive voice. Say who did it and the sentence gets shorter."})}return s}(e)))d++,l.push(s)}let o=function(e){let t=[],s=0,a=0;for(let n of e.split(/\n\s*\n/)){let r=e.indexOf(n,s),l=r+(n.length-n.trimStart().length),i=n.trim();s=r+n.length,i&&t.push({index:a++,start:l,end:l+i.length,text:i,words:(0,u.rj)(i),sentences:(0,u.PC)(i).length})}return t}(e),c=n&&s.length?206.835-1.015*(n/s.length)-r/n*84.6:0,x=n&&s.length?.39*(n/s.length)+r/n*11.8-15.59:0;return{metrics:{words:n,sentences:s.length,paragraphs:o.length,characters:e.length,avgSentenceLength:s.length?Math.round(n/s.length):0,longestSentence:i,readingSeconds:Math.round(n/225*60),readingEase:Math.max(0,Math.min(100,Math.round(c))),gradeLevel:Math.max(1,Math.round(10*x)/10),passiveCount:d},paragraphs:o,flags:l.sort((e,t)=>e.start-t.start),overused:function(e,t){var s,a;if(t<80)return[];let n=new Map;for(let t of null!=(s=e.toLowerCase().match(RegExp("[\\p{L}'-]+","gu")))?s:[])t.length<4||g.has(t)||n.set(t,(null!=(a=n.get(t))?a:0)+1);let r=Math.max(4,Math.ceil(t/120));return[...n.entries()].filter(e=>{let[,t]=e;return t>=r}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(e=>{let[t,s]=e;return{word:t,count:s}})}(e,n)}})(L),[L]),F=(0,n.useMemo)(()=>({"long-sentence":_.filter(e=>"long-sentence"===e.kind).length,passive:_.filter(e=>"passive"===e.kind).length}),[_]),O=(0,n.useMemo)(()=>M?_.filter(e=>e.kind===M).map(e=>({start:e.start,end:e.end,variant:"ai"})):[],[M,_]),I=(0,n.useCallback)(async()=>{let e=t.trim();e&&(S("structure"),await E.run("/api/structure",{text:e})&&(0,m.Gs)({kind:"edit",text:e,words:(0,u.rj)(e)}))},[t,E]),V=Math.min(100,Math.round(R.words/h*100)),D=(e=R.readingEase)>=60?{label:"Plain and readable",tone:"good"}:e>=45?{label:"Fairly dense",tone:"warn"}:e>=30?{label:"Dense",tone:"warn"}:{label:"Very dense",tone:"bad"};return(0,a.jsxs)("div",{className:"grid items-start gap-5 lg:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]",children:[(0,a.jsxs)("div",{className:"rounded-2xl border border-line bg-surface",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-line px-4 py-2.5 sm:px-5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(r.A,{className:"h-3.5 w-3.5 text-ink-faint"}),(0,a.jsx)("select",{value:h,onChange:e=>j(Number(e.target.value)),className:"rounded-lg bg-canvas px-2 py-1 text-xs font-semibold text-ink-soft outline-none transition hover:bg-brand-50","aria-label":"Target word count",children:w.map(e=>(0,a.jsxs)("option",{value:e,children:[e.toLocaleString()," words"]},e))}),(0,a.jsxs)("span",{className:"text-xs text-ink-faint",children:[R.words.toLocaleString()," written"]})]}),t.length>0&&(0,a.jsxs)("button",{type:"button",onClick:()=>{s(""),E.reset(),C(null)},className:"flex items-center gap-1.5 rounded-lg px-2 py-1.5 text-xs font-semibold text-ink-faint transition hover:bg-red-50 hover:text-red-600",children:[(0,a.jsx)(l.A,{className:"h-3.5 w-3.5"}),"Clear"]})]}),(0,a.jsx)("div",{className:"h-1 w-full bg-canvas",children:(0,a.jsx)("div",{className:"h-full transition-all ".concat(V>=100?"bg-brand-500":"bg-brand-400"),style:{width:"".concat(V,"%")}})}),(0,a.jsx)(b.k,{value:t,onChange:e=>{s(e),C(null)},highlights:O,readOnly:null!==M,height:540,placeholder:"Start writing, or paste a draft you want to reshape."}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-t border-line px-4 py-3 sm:px-5",children:[(0,a.jsx)("button",{type:"button",onClick:I,disabled:E.loading||R.words<80,className:"flex items-center gap-2 rounded-lg bg-brand-700 px-4 py-2 text-sm font-semibold text-white transition hover:bg-brand-800 disabled:cursor-not-allowed disabled:bg-ink-faint/40",children:E.loading?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.A,{className:"h-4 w-4 animate-spin"}),"Reading"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.A,{className:"h-4 w-4"}),"Read my structure"]})}),R.words>0&&R.words<80&&(0,a.jsxs)("span",{className:"text-xs text-ink-faint",children:[80-R.words," more words to read"]})]})]}),(0,a.jsxs)("div",{className:"space-y-4 lg:sticky lg:top-[4.5rem] lg:max-h-[calc(100vh-6rem)] lg:overflow-y-auto lg:pr-1",children:[(0,a.jsx)("div",{className:"flex gap-1 rounded-xl border border-line bg-surface p-1",children:[["stats","As you write",o.A],["structure","Structure",c.A]].map(e=>{let[t,s,n]=e;return(0,a.jsxs)("button",{type:"button",onClick:()=>S(t),className:"flex flex-1 items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-xs font-semibold transition ".concat(y===t?"bg-brand-700 text-white":"text-ink-soft hover:bg-brand-50"),children:[(0,a.jsx)(n,{className:"h-3.5 w-3.5"}),s]},t)})}),"stats"===y&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("section",{className:"rounded-xl border border-line bg-surface p-5",children:[(0,a.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wide text-ink-faint",children:"As you write"}),(0,a.jsxs)("dl",{className:"mt-3 grid grid-cols-2 gap-x-4 gap-y-3",children:[(0,a.jsx)(N,{label:"Words",value:R.words.toLocaleStr
1ing()}),(0,a.jsx)(N,{label:"Sentences",value:R.sentences.toLocaleString()}),(0,a.jsx)(N,{label:"Paragraphs",value:R.paragraphs.toLocaleString()}),(0,a.jsx)(N,{label:"Avg sentence",value:"".concat(R.avgSentenceLength," words")})]}),R.words>=25?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"mt-4 border-t border-line pt-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,a.jsx)("span",{className:"text-ink-soft",children:"Readability"}),(0,a.jsx)("span",{className:"font-semibold ".concat("good"===D.tone?"text-brand-700":"warn"===D.tone?"text-amber-700":"text-red-700"),children:D.label})]}),(0,a.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-ink-faint",children:["Reads at about grade ",R.gradeLevel,". Most essay writing lands between 10 and 14, and much higher usually means the sentences are doing too much at once."]})]}),(0,a.jsxs)("p",{className:"mt-3 flex items-center gap-1.5 border-t border-line pt-3 text-xs text-ink-faint",children:[(0,a.jsx)(x.A,{className:"h-3 w-3"}),Math.max(1,Math.round(R.readingSeconds/60))," min to read aloud"]})]}):(0,a.jsx)("p",{className:"mt-4 border-t border-line pt-3 text-xs leading-relaxed text-ink-faint",children:"Readability and pacing appear once there are a couple of sentences to measure."})]}),(0,a.jsxs)("section",{className:"rounded-xl border border-line bg-surface p-5",children:[(0,a.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wide text-ink-faint",children:"Worth a look"}),(0,a.jsxs)("div",{className:"mt-3 space-y-2",children:[(0,a.jsx)(v,{label:"Sentences over 30 words",count:F["long-sentence"],active:"long-sentence"===M,onClick:()=>C(e=>"long-sentence"===e?null:"long-sentence")}),(0,a.jsx)(v,{label:"Passive voice",count:F.passive,active:"passive"===M,onClick:()=>C(e=>"passive"===e?null:"passive")})]}),W.length>0&&(0,a.jsxs)("div",{className:"mt-4 border-t border-line pt-3",children:[(0,a.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wide text-ink-faint",children:"Words you lean on"}),(0,a.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:W.map(e=>(0,a.jsxs)("span",{className:"rounded-md bg-canvas px-2 py-1 text-xs text-ink-soft",children:[e.word," ",(0,a.jsx)("span",{className:"font-semibold text-ink",children:e.count})]},e.word))})]}),R.words>0&&0===F["long-sentence"]&&0===F.passive&&0===W.length&&(0,a.jsx)("p",{className:"mt-2 text-sm text-brand-700",children:"Nothing standing out. Keep going."})]}),T.length>0&&(0,a.jsxs)("section",{className:"rounded-xl border border-line bg-surface p-5",children:[(0,a.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wide text-ink-faint",children:"Paragraph balance"}),(0,a.jsx)("ul",{className:"mt-3 space-y-2.5",children:T.map(e=>{let t=e.words<40?{note:"Short. Is this developed enough to stand alone?",tone:"warn"}:e.words>200?{note:"Long. There may be two ideas in here.",tone:"warn"}:1===e.sentences?{note:"A single sentence paragraph.",tone:"warn"}:{note:"Reasonable length.",tone:"good"};return(0,a.jsxs)("li",{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 text-sm",children:[(0,a.jsxs)("span",{className:"text-ink-soft",children:["Paragraph ",e.index+1]}),(0,a.jsxs)("span",{className:"shrink-0 text-xs text-ink-faint",children:[e.words," words"]})]}),(0,a.jsx)("div",{className:"mt-1 h-1 w-full overflow-hidden rounded-full bg-canvas",children:(0,a.jsx)("div",{className:"h-full rounded-full ".concat("good"===t.tone?"bg-brand-400":"bg-amber-400"),style:{width:"".concat(Math.min(100,e.words/200*100),"%")}})}),"warn"===t.tone&&(0,a.jsx)("p",{className:"mt-1 text-xs text-amber-700",children:t.note})]},e.index)})})]})]}),"structure"===y&&(0,a.jsx)(k,{data:E.data,loading:E.loading,error:E.error,words:R.words})]})]})}function N(e){let{label:t,value:s}=e;return(0,a.jsxs)("div",{children:[(0,a.jsx)("dt",{className:"text-xs text-ink-faint",children:t}),(0,a.jsx)("dd",{className:"mt-0.5 text-lg font-semibold leading-none text-ink",children:s})]})}function v(e){let{label:t,count:s,active:n,onClick:r}=e;return(0,a.jsxs)("button",{type:"button",onClick:r,disabled:0===s,className:"flex w-full items-center justify-between rounded-lg px-3 py-2 text-sm transition ".concat(0===s?"cursor-default text-ink-faint":n?"bg-amber-50 text-amber-900":"text-ink-soft hover:bg-canvas"),children:[(0,a.jsx)("span",{children:t}),(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"font-semibold ".concat(s>0?"text-ink":""),children:s}),s>0&&(0,a.jsx)("span",{className:"text-xs text-ink-faint",children:n?"hide":"show"})]})]})}function k(e){let t,{data:s,loading:n,error:r,words:l}=e;return n?(0,a.jsx)("div",{className:"space-y-4",children:[0,1].map(e=>(0,a.jsxs)("div",{className:"rounded-xl border border-line bg-surface p-5",children:[(0,a.jsx)("div",{className:"shimmer h-3 w-28 rounded"}),(0,a.jsx)("div",{className:"shimmer mt-3 h-3 w-full rounded"}),(0,a.jsx)("div",{className:"shimmer mt-2 h-3 w-4/5 rounded"})]},e))}):r?(0,a.jsx)("div",{className:"rounded-xl border border-red-200 bg-red-50 p-4",children:(0,a.jsx)("p",{className:"text-sm leading-relaxed text-red-800",children:r})}):s?(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("section",{className:"rounded-xl border border-line bg-surface p-5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wide text-ink-faint",children:"Thesis"}),(0,a.jsx)("span",{className:"text-xs font-bold uppercase ".concat("clear"===(t=s.thesisStrength)?"text-brand-700":"vague"===t?"text-amber-700":"text-red-700"),children:s.thesisStrength})]}),s.thesis?(0,a.jsx)("p",{className:"mt-2.5 border-l-2 border-brand-300 pl-3 text-sm italic leading-relaxed text-ink",children:s.thesis}):(0,a.jsxs)("p",{className:"mt-2.5 flex items-start gap-2 text-sm leading-relaxed text-red-700",children:[(0,a.jsx)(h.A,{className:"mt-0.5 h-4 w-4 shrink-0"}),"No sentence in this essay is doing the work of a thesis."]}),s.thesisVerdict&&(0,a.jsx)("p",{className:"mt-2.5 text-sm leading-relaxed text-ink-soft",children:s.thesisVerdict})]}),s.paragraphs.length>0&&(0,a.jsxs)("section",{className:"rounded-xl border border-line bg-surface",children:[(0,a.jsx)("h3",{className:"border-b border-line px-5 py-3.5 text-xs font-semibold uppercase tracking-wide text-ink-faint",children:"What each paragraph does"}),(0,a.jsx)("ol",{className:"divide-y divide-line",children:s.paragraphs.map(e=>(0,a.jsxs)("li",{className:"px-5 py-3.5",children:[(0,a.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-bold text-ink-faint",children:e.index+1}),(0,a.jsx)("span",{className:"text-sm font-semibold text-ink",children:e.role||"Unclear"})]}),e.working&&(0,a.jsx)("p",{className:"mt-1.5 text-sm leading-relaxed text-ink-soft",children:e.working}),e.fix&&(0,a.jsxs)("p",{className:"mt-1.5 rounded-lg bg-brand-50 px-3 py-2 text-sm leading-relaxed text-brand-800",children:[(0,a.jsx)("span",{className:"font-semibold",children:"Do this: "}),e.fix]})]},e.index))})]}),s.flow&&(0,a.jsxs)("section",{className:"rounded-xl border border-line bg-surface p-5",children:[(0,a.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wide text-ink-faint",children:"How it reads end to end"}),(0,a.jsx)("p",{className:"mt-2.5 text-sm leading-relaxed text-ink-soft",children:s.flow})]}),s.missing.length>0&&(0,a.jsxs)("section",{className:"rounded-xl border border-amber-200 bg-amber-50 p-5",children:[(0,a.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wide text-amber-800",children:"What is missing"}),(0,a.jsx)("ul",{className:"mt-2.5 space-y-2",children:s.missing.map((e,t)=>(0,a.jsxs)("li",{className:"flex gap-2 text-sm leading-relaxed text-amber-900",children:[(0,a.jsx)("span",{className:"mt-[7px] h-1.5 w-1.5 shrink-0 rounded-full bg-amber-500"}),e]},t))})]})]}):(0,a.jsxs)("div",{className:"rounded-xl border border-dashed border-line bg-surface p-6",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-ink",children:"What the structure read does"}),(0,a.jsx)("p",{className:"mt-2 text-sm leading-relaxed text-ink-soft",children:"It finds your thesis and tells you whether it takes a real position, names what each paragraph is actually doing, and says where a reader would lose the thread. This is the part that moves a grade, and it is the part spellcheck cannot see."}),(0,a.jsx)("p",{className:"mt-3 text-xs text-ink-faint",children:l<80?"Write at least 80 words, then press Read my structure.":"Press Read my structure when you are ready."})]})}}},e=>{e.O(0,[360,420,85,15,441,255,358],()=>e(e.s=1010)),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.