PageSourceSearch

https://app.thewiseotter.com/assets/useDirectGpMarking-BfTPyhbr.js

js thewiseotter.com collected 2026-10-05 02:41:40 UTC 39,405 bytes, 12 lines download raw bytes

1import{l as St,S as na}from"./telegramApi-BOeRAl6M.js";import{d as oa,Z as It,a0 as sa,m as Re,w as J,i as y,l as Q,f as k,ab as j,a1 as X,c as R,e as Y,t as ee,g as se,F as We,am as rt,ac as ia,a2 as b,v as $,W as ua,a as la,$ as ca,ak as da,o as pa,as as nt,ca as fa,bQ as va,bO as ga}from"./application-runtime-CsSlWGmB.js";import ya from"./markdown-runtime-KbBUGRCl.js";import{D as ha}from"./SubscriptionDashboard-BXOyxcm8.js";import{b as me,j as _a,e as Le,u as ma,ad as ba,ae as ka,af as wa,D as Sa}from"./studyModeService-BvbZidkN.js";import{_ as Ia,s as Ta}from"./TelePaymentCancel-Dj7b227c.js";import{E as xa}from"./index-Bm0fSe-_.js";import{a as Tt}from"./account-http-runtime-C_rydiGO.js";import{E as we,F as de,G as ot,H as Ea,I as st,J as Ue,K as Ye,L as Ae,M as it,N as ut,O as lt,e as ct,Q as dt,j as pt,q as ft,R as Ca,T as qa,U as Da,V as Ra,W as Aa,X as Ga,Y as Ma}from"./fsrsStudyModeStore-DU5rADG_.js";import{u as Na,r as Oa,c as Pa}from"./GpEssayStore-CjzewyOt.js";/**
2 * @license lucide-vue-next v0.506.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Yr=St("lock-keyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);/**
7 * @license lucide-vue-next v0.506.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Vr=St("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),$a={class:"container mx-auto px-4 py-6 max-w-5xl space-y-6"},Wa={class:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between"},La={key:0,class:"flex flex-wrap gap-x-6 gap-y-3 border-y py-3 text-sm"},Ua={class:"mt-1 font-semibold"},Ya={class:"mt-1 font-semibold"},Va={class:"mt-1 font-semibold"},ja={key:1,class:"relative"},Ba={key:2,role:"alert",class:"space-y-3 rounded-xl border border-destructive/25 p-5 text-sm"},Fa={key:3,role:"status","aria-label":"Loading saved study items",class:"space-y-3"},Ka={key:4,class:"space-y-4 rounded-xl border border-dashed p-6 text-sm"},za={key:5,class:"space-y-3 rounded-xl border p-6 text-sm"},Ja={key:6,class:"space-y-3"},Qa=["onClick"],Ha={class:"flex items-start justify-between gap-3"},Za={class:"space-y-2 min-w-0"},Xa={class:"flex flex-wrap items-center gap-2"},er={class:"font-semibold text-sm sm:text-base"},tr=["innerHTML"],ar={class:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground"},rr=oa({__name:"NotesHomePage",setup(a){const t=It(),s=b(""),o=new ya({html:!1,linkify:!0,breaks:!0}),{items:d,isLoading:v,error:h,loadItems:T}=ma(),S=$(()=>{const f=s.value.trim().toLowerCase();return f?d.value.filter(l=>l.title.toLowerCase().includes(f)||l.subject.toLowerCase().includes(f)||l.memory_type.toLowerCase().includes(f)||l.tags.some(p=>p.toLowerCase().includes(f))||l.summary.toLowerCase().includes(f)):d.value}),A=$(()=>({all:d.value.length,activeWeak:d.value.filter(f=>f.memory_type==="weak-topic"&&f.status!=="resolved").length,materials:d.value.filter(f=>f.memory_type==="material").length}));function q(f){return f.replace(/-/g," ").replace(/\b\w/g,l=>l.toUpperCase())}function N(f){return new Date(f).toLocaleDateString("en-SG",{year:"numeric",month:"short",day:"numeric"})}function w(f){return o.renderInline(f)}function m(f){t.push({name:j.STUDENT_MEMORY_DETAIL,params:{id:f}})}function E(f){window.open(f,"_blank","noopener,noreferrer")}function I(){return T({limit:200})}return sa(I),(f,l)=>(R(),Re(ha,null,{default:J(()=>[y("div",$a,[y("div",Wa,[l[5]||(l[5]=y("div",{class:"min-w-0 space-y-2"},[y("h1",{class:"text-2xl font-bold"}," Study Memory "),y("p",{class:"text-sm text-muted-foreground"}," Your saved explanations, weak topics, and important materials stay together here for revision. ")],-1)),Q(k(me),{variant:"outline",class:"min-h-11 shrink-0 self-start",onClick:l[0]||(l[0]=p=>k(t).push({name:k(j).DOCUMENTS_LIST}))},{default:J(()=>[...l[4]||(l[4]=[X(" Open My Notes ",-1)])]),_:1})]),k(d).length?(R(),Y("dl",La,[y("div",null,[l[6]||(l[6]=y("dt",{class:"text-muted-foreground"},"Saved items",-1)),y("dd",Ua,ee(A.value.all),1)]),y("div",null,[l[7]||(l[7]=y("dt",{class:"text-muted-foreground"}
11,"Active weak topics",-1)),y("dd",Ya,ee(A.value.activeWeak),1)]),y("div",null,[l[8]||(l[8]=y("dt",{class:"text-muted-foreground"},"Saved materials",-1)),y("dd",Va,ee(A.value.materials),1)])])):se("",!0),k(d).length?(R(),Y("div",ja,[l[9]||(l[9]=y("label",{for:"study-memory-search",class:"sr-only"},"Search saved study items",-1)),Q(k(na),{class:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),Q(k(_a),{id:"study-memory-search",modelValue:s.value,"onUpdate:modelValue":l[1]||(l[1]=p=>s.value=p),class:"min-h-11 pl-9",placeholder:"Search titles, subjects, tags, or note types..."},null,8,["modelValue"])])):se("",!0),k(h)?(R(),Y("div",Ba,[l[11]||(l[11]=y("p",null,"Your saved study items could not be loaded. Try again to see them.",-1)),Q(k(me),{variant:"outline",class:"min-h-11",disabled:k(v),onClick:I},{default:J(()=>[...l[10]||(l[10]=[X(" Try again ",-1)])]),_:1},8,["disabled"])])):se("",!0),k(v)?(R(),Y("div",Fa,[(R(),Y(We,null,rt(4,p=>Q(k(Ia),{key:p,class:"h-24 w-full rounded-xl"})),64))])):!k(h)&&k(d).length===0?(R(),Y("div",Ka,[l[13]||(l[13]=y("div",{class:"space-y-2"},[y("h2",{class:"font-semibold"},"Save something useful for your next revision."),y("p",{class:"leading-6 text-muted-foreground"},"Ask Study chat to save an explanation or a topic you want to revisit. It will appear here.")],-1)),Q(k(me),{class:"min-h-11",onClick:l[2]||(l[2]=p=>k(t).push({name:k(j).CHAT_DASHBOARD}))},{default:J(()=>[...l[12]||(l[12]=[X("Open Study chat",-1)])]),_:1})])):!k(h)&&S.value.length===0?(R(),Y("div",za,[l[15]||(l[15]=y("p",null,"No saved study items match your search.",-1)),Q(k(me),{variant:"outline",class:"min-h-11",onClick:l[3]||(l[3]=p=>s.value="")},{default:J(()=>[...l[14]||(l[14]=[X("Clear search",-1)])]),_:1})])):S.value.length?(R(),Y("div",Ja,[(R(!0),Y(We,null,rt(S.value,p=>(R(),Y("button",{key:p.id,class:"w-full rounded-xl border bg-card p-4 text-left transition-colors hover:bg-accent/40",onClick:pe=>m(p.id)},[y("div",Ha,[y("div",Za,[y("div",Xa,[y("span",er,ee(p.title),1),Q(k(Le),{variant:"secondary",class:"text-[11px]"},{default:J(()=>[X(ee(q(p.memory_type)),1)]),_:2},1024),p.status==="resolved"?(R(),Re(k(Le),{key:0,variant:"outline",class:"text-[11px] border-green-600 text-green-700"},{default:J(()=>[...l[16]||(l[16]=[X(" Resolved ",-1)])]),_:1})):p.status==="active"?(R(),Re(k(Le),{key:1,variant:"outline",class:"text-[11px] border-amber-600 text-amber-700"},{default:J(()=>[...l[17]||(l[17]=[X(" Active ",-1)])]),_:1})):se("",!0)]),y("div",{class:"text-sm text-muted-foreground line-clamp-2 prose prose-sm max-w-none dark:prose-invert",innerHTML:w(p.summary||"Open this note to read the full saved explanation.")},null,8,tr),y("div",ar,[y("span",null,ee(q(p.subject)),1),l[19]||(l[19]=y("span",null,"•",-1)),y("span",null,ee(N(p.updated_at)),1),p.tags.length?(R(),Y(We,{key:0},[l[18]||(l[18]=y("span",null,"•",-1)),y("span",null,ee(p.tags.slice(0,3).join(" • ")),1)],64)):se("",!0)])]),p.asset_url?(R(),Re(k(me),{key:0,type:"button",variant:"outline",size:"sm",class:"shrink-0",onClick:ia(pe=>E(p.asset_url),["stop"])},{default:J(()=>[Q(k(xa),{class:"mr-2 h-4 w-4"}),l[20]||(l[20]=X(" Open ",-1))]),_:1},8,["onClick"])):se("",!0)])],8,Qa))),128))])):se("",!0)])]),_:1}))}}),jr=Object.freeze(Object.defineProperty({__proto__:null,default:rr},Symbol.toStringTag,{value:"Module"})),Ge=80,vt=6e3,gt=500,yt=800,nr=3,xt=/[\p{L}\p{N}_]+(?:['\u2019-][\p{L}\p{N}_]+)*/gu;function je(a){var t;return((t=we(a).match(xt))==null?void 0:t.length)??0}function or(a,t){if(t<Ge)return!1;const s=we(a).toLocaleLowerCase("en-SG").match(xt)??[];return new Set(s).size<=Math.max(3,Math.floor(s.length*.04))}function sr(a){const t=we(a).split(`
12`).map(d=>d.trim()).filter(Boolean);if(t.length<4)return!1;const s=t.filter(d=>/^(?:[-*+]|\d+[.)]|[ivxlcdm]+[.)])\s+/i.test(d)||/^(?:intro(?:duction)?|thesis|point(?:\s+\d+)?|argument(?:\s+\d+)?|example(?:\s+\d+)?|evaluation|counter(?:argument)?|rebuttal|conclusion)\s*:/i.test(d)).length,o=t.filter(d=>je(d)>=18).length;return s/t.length>=.6&&o/t.length<.4}function ir(a){const t=we(a.questionText),s=we(a.responseText),o=je(s);let d=null,v="";je(t)<nr?(d="missing-question",v="Add a meaningful essay question, including its key wording."):o<Ge?(d="too-short",v=`Add at least ${Ge} words of developed prose. This is a Wise Otter processing minimum, not an exam rule.`):or(s,o)?(d="repeated-filler",v="This looks like repeated filler. Add one coherent passage in y
12our own words."):sr(s)?(d="plan-like",v="This looks like notes or a plan. Paste developed prose, or practise step by step."):o>vt&&(d="too-long",v=`Wise Otter can process up to ${vt.toLocaleString("en-SG")} words here. Shorten the response or submit a passage.`);const h=a.feedbackScope==="full_essay"&&o>=Ge&&(o<gt||o>yt)?`GP Paper 1 publishes a ${gt}-${yt} word range. Yours has approximately ${o.toLocaleString("en-SG")} words. Being outside that range is not an automatic penalty.`:"";return Object.freeze({wordCount:o,canSubmit:d===null,blockingReason:d,blockingMessage:v,officialRangeWarning:h,societyContextHint:/\byour society\b/i.test(t)?"Make the society clear in your response. This preview will not assume Singapore.":""})}function ur(a){return a==="full_essay"?"Get essay feedback":"Get passage feedback"}const ht=1,lr=["student_home","question_browse","question_detail","practice_set","mark_intake","work_write","work_report","work_revision","tutor","tutor_thread","progress","library","library_item"],cr=/^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;function ie(a,t){throw new TypeError(`${a}: ${t}`)}function _t(a,t){return a===null||typeof a!="object"||Array.isArray(a)?ie(t,"expected object"):a}function te(a,t,s){const o=Object.keys(a).sort(),d=[...t].sort();(o.length!==d.length||o.some((v,h)=>v!==d[h]))&&ie(s,`expected exact keys ${d.join(",")}`)}function Be(a,t){return typeof a!="string"?ie(t,"expected string"):a}function dr(a,t,s){const o=Be(a,s);return t.includes(o)?o:ie(s,"unsupported value")}function pr(a,t,s){const o=Be(a,s);return t.test(o)?o:ie(s,"invalid format")}function be(a,t){const s=Be(a,t);if(s.length<1||s.length>256)return ie(t,"expected 1 to 256 characters");for(const o of s){const d=o.charCodeAt(0);if(d<33||d>126||"/?#\\".includes(o))return ie(t,"invalid route parameter")}return s}function mt(a,t){return pr(a,cr,t)}function fr(a){const t=_t(a,"route");te(t,["route_name","route_params"],"route");const s=dr(t.route_name,lr,"route.route_name"),o=_t(t.route_params,"route.route_params");switch(s){case"student_home":case"question_browse":case"mark_intake":case"tutor":case"progress":case"library":te(o,[],"route.route_params");break;case"question_detail":te(o,["question_id"],"route.route_params"),be(o.question_id,"route.route_params.question_id");break;case"practice_set":te(o,["set_id"],"route.route_params"),be(o.set_id,"route.route_params.set_id");break;case"work_write":case"work_report":te(o,["work_id"],"route.route_params"),mt(o.work_id,"route.route_params.work_id");break;case"work_revision":te(o,["work_id","item_id"],"route.route_params"),mt(o.work_id,"route.route_params.work_id"),be(o.item_id,"route.route_params.item_id");break;case"tutor_thread":te(o,["conversation_id"],"route.route_params"),be(o.conversation_id,"route.route_params.conversation_id");break;case"library_item":te(o,["item_id"],"route.route_params"),be(o.item_id,"route.route_params.item_id");break}return t}const vr=["full_essay","general_paragraph"],gr=["draft_saved","result_ready","outcome_unknown"],Et=/^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,yr=/^v2\.[A-Za-z0-9][A-Za-z0-9_:-]{15,59}$/,hr=/^sha256:[0-9a-f]{64}$/,Ve=/^[0-9a-f]{64}$/,_r=/^[A-Za-z0-9_-]{16,128}$/,mr=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|[+-]\d{2}:\d{2})$/,br=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,6}))?(Z|[+-]\d{2}:\d{2})$/;function M(a,t){throw new TypeError(`${a}: ${t}`)}function Ct(a,t){return a===null||typeof a!="object"||Array.isArray(a)?M(t,"expected object"):a}function qt(a,t,s){const o=Object.keys(a).sort(),d=[...t].sort();(o.length!==d.length||o.some((v,h)=>v!==d[h]))&&M(s,`expected exact keys ${d.join(",")}`)}function Dt(a,t,s=1,o=8192){if(typeof a!="string")return M(t,`expected ${s} to ${o} characters`);let d=0;for(const v of a)if(d+=1,d>o)return M(t,`expected ${s} to ${o} characters`);return d<s?M(t,`expected ${s} to ${o} characters`):a}function H(a,t,s){const o=Dt(a,s,1,256);return t.test(o)?o:M(s,"invalid format")}function bt(a,t,s){const o=Dt(a,s,1,128);return t.includes(o)?o:M(s,"unsupported value")}function Rt(a,t){const s=H(a,mr,t),o=br.exec(s);
12if(o===null)return M(t,"invalid timestamp");const d=Number(o[1]),v=Number(o[2]),h=Number(o[3]),T=Number(o[4]),S=Number(o[5]),A=Number(o[6]),N=[31,d%4===0&&(d%100!==0||d%400===0)?29:28,31,30,31,30,31,31,30,31,30,31],w=o[8];if(d<1||v<1||v>12||h<1||h>N[v-1]||T>23||S>59||A>59)return M(t,"invalid timestamp");if(w!=="Z"){const m=Number(w.slice(1,3)),E=Number(w.slice(4,6));if(m>23||E>59)return M(t,"invalid timestamp offset")}return Number.isNaN(Date.parse(s))?M(t,"invalid timestamp"):s}function kr(a,t){const s=Ct(a,"envelope");return qt(s,["schema_version","request_id","generated_at","data"],"envelope"),s.schema_version!==ht?M("envelope.schema_version","unsupported schema version"):{schema_version:ht,request_id:H(s.request_id,_r,"envelope.request_id"),generated_at:Rt(s.generated_at,"envelope.generated_at"),data:t(s.data)}}function wr(a,t){return`sha256:${Ta(`gp-ai:${a}:${encodeURIComponent(t)}`)}`}function Sr(a){const t=Ct(a,"data");qt(t,["work_id","practice_type","question_sha256","response_sha256","input_sha256","state","report_route","receipt_at","evidence_reference_digest"],"data");const s=H(t.work_id,Et,"data.work_id"),o=bt(t.state,gr,"data.state"),d=bt(t.practice_type,vr,"data.practice_type"),v=H(t.question_sha256,Ve,"data.question_sha256"),h=H(t.response_sha256,Ve,"data.response_sha256"),T=H(t.input_sha256,Ve,"data.input_sha256");if(o==="result_ready"){const S=fr(t.report_route);return S.route_name!=="work_report"||S.route_params.work_id!==s?M("data.report_route","expected matching work report route"):{work_id:s,practice_type:d,question_sha256:v,response_sha256:h,input_sha256:T,state:o,report_route:S,receipt_at:Rt(t.receipt_at,"data.receipt_at"),evidence_reference_digest:H(t.evidence_reference_digest,hr,"data.evidence_reference_digest")}}return t.report_route!==null||t.receipt_at!==null||t.evidence_reference_digest!==null?M("data","non-ready status cannot contain report metadata"):{work_id:s,practice_type:d,question_sha256:v,response_sha256:h,input_sha256:T,state:o,report_route:null,receipt_at:null,evidence_reference_digest:null}}function Ir(a){return kr(a,Sr)}function Tr(a){const t=H(a,yr,"feedback_id");return wr("gp-feedback",t)}function xr(a){return H(a,Et,"work_id")}async function Er(a,t={}){const s=xr(a),o=await ua.get(`/api/learning/v1/works/${encodeURIComponent(s)}/status`,{signal:t.signal}),d=Ir(o.data);if(d.data.work_id!==s)throw new TypeError("work_id: response does not match the requested status");return d}const Cr=400,qr=/^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;class ke extends Error{constructor(){super("The canonical saved-work status could not be verified."),this.name="CanonicalWorkStatusVerificationError"}}class kt extends Error{constructor(){super("The canonical saved-work recovery record could not be verified."),this.name="WorkBindingVerificationError"}}function wt(a){if(typeof window>"u")return null;try{return window[a]||null}catch{return null}}function Dr(a){var s,o;if(!Tt.isAxiosError(a)||((s=a.response)==null?void 0:s.status)!==409)return!1;const t=(o=a.response.data)==null?void 0:o.detail;return typeof t=="object"&&t!==null&&t.error_type==="direct_intake_conflict"}function At(a){var t;return Tt.isAxiosError(a)?((t=a.response)==null?void 0:t.status)??null:null}function Rr(a){return At(a)===404}function Br(){const a=la(),t=It(),s=a.name===j.QUICK_ESSAY_MARKING?j.QUICK_ESSAY_MARKING:j.WISE_MARK,o=()=>({stage:"jc",...s===j.QUICK_ESSAY_MARKING&&typeof a.query.studyRequest=="string"?{studyRequest:a.query.studyRequest}:{}}),d=ca(),v=Na(),h=b(""),T=b(""),S=b("full_essay"),A=b("typed"),q=b(de({source:"custom",text:""})),N=b(null),w=b(null),m=b(null),E=b(null),I=b("not-read"),f=b("idle"),l=b("Start typing to save a recovery copy in this browser."),p=b("editing"),pe=b(""),g=b(""),ae=b(""),ue=b(!1),Se=b(!1),Ie=b(!0),re=b(!1),W=b(!1),B=b(!1),O=b(!1),Fe=b(!1),P=b(!1),F=b(null);let V,K=null;const fe=new Set;let Te=!1,z=da(),Ke=!0;const xe=$(()=>ir({questionText:h.value,responseText:T.value,feedbackScope:S.value})),Gt=$(()=>ur(S.value)),Ee=$(()=>p.value==="checking"||p.value==="saving"||p.value==="preparing"||p.value==="saving-report"),Mt=$(()=>xe.value.canSubmit&&!Ie.value&&!Ee.value&&!re.value&&!P.value&&(!O.value||B.value)),Me=$(()=>q.value.source==="catalog"&&h.value===q.value.text),ze=$(()=>!!(h.value.trim()||T.value.trim())),Nt=$(()=>s!==j.QUICK_ESSAY_MARKING&&a.query.stage!==void 0&&a.query.stage!=="jc"),Ne=$(()=>{var e;return!!((e=w.value)!=null&&e.operation)}),le=$(()=>Ee.value||Ne.value),Ot=$(()=>F.value!==null);function ve(){const e=d.currentUser;if(!e||!Number.isInteger(e.id))throw new Error("Sign in to get GP essay feedback.");
12if(!nt(z,e.firebase_uid))throw new Error("The signed-in account changed while this work was open.")}function Z(){const e=d.currentUser;if(!e||!Number.isInteger(e.id))throw new Error("Your profile is not ready. Try again in a moment.");return e}function ne(){return wt("localStorage")}function ce(){return wt("sessionStorage")}function Je(){return Me.value?q.value:de({source:"custom",text:h.value})}function ge(e){E.value=null,w.value=e,N.value=Object.freeze({draftId:e.draftId,writerTabId:e.writerTabId}),q.value=e.task,h.value=e.task.text,T.value=e.responseText,S.value=e.feedbackScope,A.value=e.inputMode,W.value=!1,f.value="saved",l.value="Your saved draft has been restored."}function Qe(e){const n=e.operation,r=ne();if(!n)return E.value=null,I.value="empty",{status:"empty"};if(I.value!=="not-read"&&I.value!=="empty"&&I.value!=="restored")return E.value=null,{status:I.value};if(!r)return E.value=null,I.value="storage-unavailable",{status:"storage-unavailable"};const u=dt(r,n.operationId,{ownerUserId:e.ownerUserId,authGeneration:e.authGeneration});return I.value=u.status,u.status!=="restored"?(E.value=null,u):pt(u.binding,e)?(E.value=u.binding,u):(P.value=!0,E.value=null,I.value="draft-mismatch",{status:"draft-mismatch"})}function Pt(e,n){const r=e.operation,u=ne();if(!r)return null;if(!u)return I.value="storage-unavailable",null;const i=dt(u,r.operationId,{ownerUserId:e.ownerUserId,authGeneration:e.authGeneration});if(i.status==="restored")return i.binding.workId!==n||!pt(i.binding,e)?(P.value=!0,I.value="draft-mismatch",null):(E.value=i.binding,I.value="restored",i.binding);if(i.status!=="empty")return I.value=i.status,null;const c=Aa({draft:e,workId:n,nowMs:Date.now()}),_=Ga(u,c,null);return _.ok?(E.value=_.binding,I.value="restored",_.binding):(I.value=`write-${_.reason}`,null)}function He(){return I.value==="storage-unavailable"||I.value==="write-storage-unavailable"?"The saved request could not be reopened. Keep this tab open and copy your writing before clearing the draft to start again.":"The saved request could not be reopened. Copy your writing before clearing the draft to start again."}async function Oe(e,n){let r;try{r=await Er(n.workId)}catch{throw new ke}ve();const u=r.data;if(u.work_id!==n.workId||u.practice_type!==e.practiceType||u.question_sha256!==e.questionSha256||u.response_sha256!==e.responseSha256||u.input_sha256!==e.inputSha256||u.state==="result_ready"&&u.evidence_reference_digest!==Tr(e.operation.feedbackId))throw new ke;return u}function Ce(e){return e==="conflict"?"This draft changed in another tab. Reload the saved copy before requesting feedback.":e==="too-large"?"This draft is too large to save in your browser. Copy your writing before leaving.":e==="readback-failed"?"Your latest changes could not be saved. Keep this tab open and copy your writing before leaving.":e==="corrupt-existing"?"The saved draft could not be updated. Keep this tab open and copy your writing before leaving.":"Your draft could not be saved in this browser. Keep this tab open."}function ye(e={}){var u;if(!W.value&&!e.force||re.value)return w.value;const n=Z(),r=ne();if(!r||!N.value)return f.value="error",O.value=!0,l.value=Ce("storage-unavailable"),null;f.value="saving";try{const i=ot({ownerUserId:n.id,authGeneration:z.generation,identity:N.value,task:Je(),responseText:T.value,feedbackScope:S.value,inputMode:A.value,previous:w.value,...Object.prototype.hasOwnProperty.call(e,"operation")?{operation:e.operation}:{},nowMs:Date.now()}
12),c=Ea(r,i,((u=w.value)==null?void 0:u.payloadSha256)??null);return c.ok?(w.value=c.envelope,q.value=c.envelope.task,h.value=c.envelope.task.text,T.value=c.envelope.responseText,W.value=!1,P.value=!1,O.value=!1,f.value="saved",l.value="Saved in this browser for this signed-in account.",c.envelope):(f.value="error",l.value=Ce(c.reason),P.value=c.reason==="conflict",O.value=c.reason!=="conflict",null)}catch{return f.value="error",O.value=!0,l.value=Ce("storage-unavailable"),null}}function he(e={}){return V&&(clearTimeout(V),V=void 0),W.value=!0,ye({...e,force:!0})}function _e(){if(Ne.value){g.value="This writing has already been submitted. Retry the request or clear the draft to start again.";return}W.value=!0,g.value="",f.value="unsaved",l.value="Saving your latest change in this browser...",V&&clearTimeout(V),!re.value&&(V=setTimeout(()=>{V=void 0,ye()},Cr))}function $t(){Me.value||le.value||_e()}function Wt(){le.value||_e()}function Lt(){le.value||(A.value="pasted",_e())}function Ut(e){le.value||(S.value=e,_e())}function Yt(){re.value=!0}function Vt(){re.value=!1,_e(),he()}function x(e,n){p.value=e,pe.value=n}function Ze(e){var u;const n=ce();if(!n)return m.value=e,O.value=!0,!1;const r=Ma(n,e,((u=m.value)==null?void 0:u.journalSha256)??null);return r.ok?(m.value=r.entry,!0):r.reason==="conflict"?(P.value=!0,!1):(m.value=e,O.value=!0,!1)}function oe(e){if(!m.value)return!1;if(m.value.stage===e)return!0;try{return Ze(qa(m.value,e,Date.now()))}catch{return O.value=!0,!1}}function jt(e={}){var _;Te=!1;const n=he();if(!n&&!B.value)return null;const r=n!=null&&n.operation?{operationId:n.operation.operationId,sessionId:n.operation.sessionId,attemptId:n.operation.attemptId,feedbackId:n.operation.feedbackId}:Da(),u=he({operation:r});if(!u){if(!B.value)return null;const D=Z(),C=N.value??Ae();N.value=C;const L=ot({ownerUserId:D.id,authGeneration:z.generation,identity:C,task:Je(),responseText:T.value,feedbackScope:S.value,inputMode:A.value,previous:w.value,operation:r,nowMs:Date.now()});w.value=L}const i=u??w.value;if(!(i!=null&&i.operation))return null;const c=ce();if(((_=m.value)==null?void 0:_.operationId)!==r.operationId&&(m.value=null),c){const D=lt(c,r.operationId,{ownerUserId:i.ownerUserId,authGeneration:i.authGeneration});if(D.status==="restored"){if(!ct(D.entry,i))return P.value=!0,g.value="A different draft was submitted from this browser. Copy your writing before clearing this draft to start again.",null;m.value=D.entry}else if(e.requireExistingJournal)return m.value=null,Te=!0,null}else if(e.requireExistingJournal)return m.value=null,Te=!0,null;if(!m.value){const D=Ra({draft:i,nowMs:Date.now()});if(!Ze(D)&&!B.value)return null;m.value||(m.value=D)}return{draft:i,identity:r}}function Bt(e,n,r){if(e.session_id!==r.sessionId||e.attempt_id!==r.attemptId||!qr.test(e.work_id)||e.assessment_adapter!=="gp_8881_2026"||e.practice_type!==n.practiceType||e.question_sha256!==n.questionSha256||e.response_sha256!==n.responseSha256||e.input_sha256!==n.inputSha256||e.status!=="draft")throw new Error("The saved response did not match this feedback request.")}async function Pe(e,n,r=["draft"]){const u=await v.loadEssaySession(n.sessionId,{force:!0});if(ve(),!u||v.currentSessionId!==n.sessionId)throw new Error("The saved writing session could not be verified.");v.setEssayPracticeActiveAttempt(n.attemptId,{loadSavedFeedback:!1});const i=v.getActivePracticeAttempt,c=v.getPracticeSession,_=ut(v.getQuestionString??"",(i==null?void 0:i.written_content)??"",e.feedbackScope);if(!i||!c||i.attempt_id!==n.attemptId||i.session_id!==n.sessionId||!r.includes(i.status)||i.practice_type!==e.practiceType||c.session_id!==n.sessionId||c.essay_question!==e.task.text||_.questionSha256!==e.questionSha256||_.responseSha256!==e.responseSha256||_.inputSha256!==e.inputSha256)throw new Error("The exact saved response could not be verified.")}async function Xe(e,n){var u;let r;try{r=await ft(n.attemptId,n.feedbackId)}catch(i){if(Rr(i))return!1;throw i}return ve(),$e(r,e,n),await Pe(e,n,["feedback_received"]),((u=m.value)==null?void 0:u.stage)!=="report_ready"&&oe("report_ready"),await qe(n),!0}function $e(e,n,r){if(e.feedback_id!==r.feedbackId||e.attempt_id!==r.attemptId||e.feedback_type!=="detailed"||e.input_sha256!==n.inputSha256||!Array.isArray(e.feedback_items)||e.feedback_items.length===0)throw new Error("No trustworthy exact report could be verified.")}async function qe(e){if(!Ke||a.name!==s)return;const n=E.value;if(n&&n.operationId===e.operationId&&n.attemptId===e.attemptId&&n.feedbackId===e.feedbackId){await t.replace({name:j.STUDENT_WORK_REPORT,params:{workId:n.workId}});return}await t.replace({name:j.PRACTICE_GP_ESSAY_REVIEW,params:{attemptId:e.attemptId},query:{feedbackId:e.feedbackId}})}function Ft(e,n){if(Dr(e))return"The saved response changed, so this request was stopped. Your browser copy is still here.";const r=At(e);return r===401?"Your session needs to be refreshed. Your browser copy is still here.":r===429?"Feedback is unavailable for this account right now. Your response is still here.":r===422?"This response could not be prepared safely. Your browser copy is still here.":n==="prepared"||n==="saving_session"?"Nothing was sent for feedback. Your browser copy is still here.":n==="saved_attempt"?"Your response is saved privately, but feedback did not start. Try again when you are ready.":"We could not confirm whether feedback finished. Your saved response is still here. Retry only when you are ready."}async function Kt(){var _,D;
12if(g.value="",!xe.value.canSubmit){g.value=xe.value.blockingMessage;return}ve(),x("checking","Checking your response...");const e=!!((_=w.value)!=null&&_.operation),n=jt({requireExistingJournal:e});if(!n){if(e&&Te){x("interrupted",""),g.value="We could not check the previous request. Your writing is still here. Check again later or clear the draft to start a new request.";return}x("editing",""),g.value=O.value?"Your browser backup could not be saved. Choose whether to continue without it.":"Your draft could not be saved. Check the save message and try again.";return}const{draft:r,identity:u}=n,i=va(z);let c=((D=m.value)==null?void 0:D.stage)??"prepared";try{if(e){x("checking","Looking for your saved report...");const G=Qe(r);if(G.status==="restored"){const De=await Oe(r,G.binding);if(De.state==="result_ready"){await qe(u);return}if(De.state==="outcome_unknown"||c==="provider_pending"||c==="receipt_ambiguous"){x("interrupted",""),g.value="We could not safely restart this feedback request. Your response is saved; check again later or clear it to start a new request.";return}if(c!=="saving_session"&&c!=="saved_attempt"){x("interrupted",""),g.value="Your response is saved, but the request status is unknown. Check again later or clear the draft to start a new request.";return}}else if(G.status==="empty"){if(await Xe(r,u))return}else{x("interrupted",""),g.value=He();return}if(c==="provider_pending"||c==="receipt_ambiguous"){x("interrupted",""),g.value="We could not safely restart this feedback request. Your response is saved; check again later or clear it to start a new request.";return}if(c==="report_ready")throw new Error("The completed report record could not be read back.")}if(c==="prepared"||c==="saving_session"){if(c==="prepared"){if(!oe("saving_session")&&!B.value)throw new Error("The recovery journal could not be verified.");c="saving_session"}x("saving","Saving your response... Keep this tab open.");const G=await Ca(u.sessionId,{assessment_adapter:"gp_8881_2026",attempt_id:u.attemptId,practice_type:r.practiceType,question_text:r.task.text,question_type:[],question_topics:[],question_source:r.task.source==="catalog"?"curated":"custom",written_content:r.responseText,question_sha256:r.questionSha256,response_sha256:r.responseSha256,input_sha256:r.inputSha256});if(i.throwIfStale(Z().firebase_uid),Bt(G,r,u),await Pe(r,u),!Pt(r,G.work_id))throw new kt;if(v.markActivePracticeAttemptPersisted(),!oe("saved_attempt")&&!B.value)throw new Error("The saved response recovery state could not be verified.");c="saved_attempt"}else await Pe(r,u),v.markActivePracticeAttemptPersisted();if(c==="saved_attempt"||c==="receipt_ambiguous"){if(!oe("provider_pending")&&!B.value)throw new Error("The provider recovery state could not be verified.");c="provider_pending"}else if(c!=="provider_pending")throw new Error("The saved request is not in a recoverable state.");x("preparing","Preparing feedback... Keep this tab open.");const C=await v.fetchEssayPracticeAIFeedback("detailed",void 0,{feedbackId:u.feedbackId,allowRestartAfterGrace:!0});i.throwIfStale(Z().firebase_uid),$e(C,r,u),x("saving-report","Saving your report... Keep this tab open.");const L=await ft(u.attemptId,u.feedbackId);i.throwIfStale(Z().firebase_uid),$e(L,r,u);const U=E.value;if(U)try{if((await Oe(r,U)).state!=="result_ready")throw new ke}catch(G){throw G instanceof ke&&(oe("receipt_ambiguous"),c="receipt_ambiguous"),G}oe("report_ready"),c="report_ready",await qe(u)}catch(C){if(ga(C)||!i.isCurrent())return;if(C instanceof ke){x("interrupted",""),g.value="We could not check your saved report. Your response is still here.";return}if(C instanceof kt){x("interrupted",""),g.value="Your response is saved, but feedback could not start. Please try again.";return}c==="provider_pending"&&(oe("receipt_ambiguous"),c="receipt_ambiguous"),x(c==="receipt_ambiguous"?"interrupted":"editing",""),g.value=Ft(C,c)}finally{i.release(),p.value!=="interrupted"&&p.value!=="editing"&&x("editing","")}}function zt(){if(typeof navigator>"u")return null;try{const e=navigator.locks;return e&&typeof e.request=="function"?e:null}catch{return null}}async function Jt(e){const n=zt();if(!n||typeof AbortController>"u"){x("editing",""),g.value="This browser does not support submitting feedback. Update your browser and try again. Your writing is still here.";return}const r=new AbortController;let u=!1;fe.add(r),x("checking","Preparing your request...");try{await n.request(`wiseotter:direct-gp-feedback:v2:account:${e}:direct-draft`,{mode:"exclusive",signal:r.signal}
12,async i=>{if(u=!0,fe.delete(r),!r.signal.aborted){if(!i){x("editing",""),g.value="Your request could not be submitted. Please try again.";return}await Kt()}})}catch(i){if(fe.delete(r),r.signal.aborted)return;if(u)throw i;x("editing",""),g.value="Your request could not be submitted. Please try again."}}function Qt(){let e,n;try{const i=ut(h.value,T.value,S.value);n=Z().id,e=`${n}:${i.inputSha256}`}catch{return g.value="This exact response could not be prepared safely. Your text is still here.",Promise.resolve()}if((K==null?void 0:K.key)===e)return K.promise;const u=Jt(n).finally(()=>{(K==null?void 0:K.promise)===u&&(K=null)});return K={key:e,promise:u},u}async function Ht(e=!1){const n=typeof a.query.catalogTask=="string"?a.query.catalogTask:null,r=typeof a.query.catalogVersion=="string"?a.query.catalogVersion:null;if(!(a.query.catalogTask!==void 0||a.query.catalogVersion!==void 0))return null;if(!ba(n)||!ka(r))return ae.value="This question link is incomplete or invalid. No blank task was substituted.",null;try{const i=e?await wa():await Sa();if(i.catalogVersion!==r)return ae.value="The question bank changed after this link was created, so the task was not substituted silently.",ue.value=!0,null;const c=i.items.find(_=>_.id===n);return!c||c.action.kind!=="gp-essay"?(ae.value="That exact GP question is no longer available in this question bank.",ue.value=!0,null):de({source:"catalog",text:c.prompt,catalogTaskId:c.id,catalogVersion:r})}catch{return ae.value="The exact question could not be checked. Try again when the question bank is available.",ue.value=!0,null}}async function et(e=!1){var n;Ie.value=!0,ae.value="",ue.value=!1,F.value=null,m.value=null,E.value=null,P.value=!1,O.value=!1,g.value="";try{const r=Z();z=fa(r.firebase_uid);const u=ne(),i=u?it(u,{ownerUserId:r.id,authGeneration:z.generation}):{status:"storage-unavailable"},c=await Ht(e);if(ve(),c)if(c.source==="catalog"&&i.status==="restored"&&i.envelope.task.source==="catalog"&&i.envelope.task.catalogTaskId===c.catalogTaskId&&i.envelope.task.catalogVersion===c.catalogVersion)ge(i.envelope);else if(i.status==="restored"&&(i.envelope.responseText.trim()||i.envelope.task.source==="custom"&&i.envelope.task.text.trim()))ge(i.envelope),F.value=c;else{if(i.status==="restored"){const C=ce(),L=(n=i.envelope.operation)==null?void 0:n.operationId;if(C&&L&&!Ue(C,L))throw new Error("The previous recovery record could not be cleared safely.");if(u&&L&&Ye(u,L),u&&!st(u))throw new Error("The previous browser draft could not be cleared safely.")}N.value=Ae(),w.value=null,q.value=c,h.value=c.text,T.value="",S.value="full_essay",A.value="typed",W.value=!0,ye({force:!0,operation:null})}else i.status==="restored"?ge(i.envelope):(N.value=Ae(),w.value=null,q.value=de({source:"custom",text:""}),h.value="",T.value="",S.value="full_essay",A.value="typed",i.status==="storage-unavailable"&&(O.value=!0,f.value="error",l.value=Ce("storage-unavailable")));const _=w.value;if(_!=null&&_.operation){const D={operationId:_.operation.operationId,sessionId:_.operation.sessionId,attemptId:_.operation.attemptId,feedbackId:_.operation.feedbackId},C=Qe(_);if(C.status==="empty")try{if(await Xe(_,D))return}catch{p.value="interrupted",g.value="We could not open your saved report. Your response is still here; please try again.";return}else if(C.status!=="restored"){p.value="interrupted",g.value=He();return}const L=ce(),U=L?lt(L,_.operation.operationId,{ownerUserId:r.id,authGeneration:z.generation}):{status:"storage-unavailable"};if(U.status==="restored"&&ct(U.entry,_)?(m.value=U.entry,U.entry.stage==="provider_pending"||U.entry.stage==="receipt_ambiguous"||U.entry.stage==="report_ready"?(p.value="interrupted",g.value=U.entry.stage==="report_ready"?"The saved report could not be opened. Your response is still here; please try again.":"Feedback was interrupted. Your response is still here. Try again only when you are ready."):g.value="Your writing is saved, but feedback did not start. Try again when you are ready."):U.status==="restored"?(P.value=!0,g.value="A different draft was submitted from this browser. Copy your writing before clearing this draft to start again."):g.value="Your writing is saved, but feedback did not start. Try again when you are ready.",C.status==="restored")try{const G=await Oe(_,C.binding);if(G.state==="result_ready"){await qe(D);return}G.state==="draft_saved"&&m.value!==null&&(m.value.stage==="saving_session"||m.value.stage==="saved_attempt")?g.value="Your response is saved privately. Feedback did not start; continue only when you are ready.":(p.value="interrupted",g.value=G.state==="outcome_unknown"?"Your response is saved, but the previous feedback outcome is not known. Check again later or clear it to start a new request.":"Your response is saved, but the request status is unknown. Check again later or clear the draft to start a new request.")}catch{p.value="interrupted",g.value="We could not check your saved report. Your response is still here."}}}catch(r){ae.value=r instanceof Error?r.message:"The direct GP feedback space could not be prepared."}finally{Ie.value=!1}}async function Zt(){if(!(!ue.value||Se.value)){Se.value=!0;try{await et(!0)}finally{Se.value=!1}}}async function Xt(){le.value||(q.value=de({source:"custom",text:""}),h.value="",Fe.value=!1,W.value=!0,he({operation:null}),await t.replace({name:s,query:o()}))}async function ea(){const e=Z(),n=ne();if(!n)return!1;const r=it(n,{ownerUserId:e.id,authGeneration:z.generation});return r.status==="restored"?(ge(r.envelope),P.value=!1,!0):!1}function tt(e=(n=>(n=w.value)==null?void 0:n.operation)()??null){const r=Oa();r&&e&&r.attempt_id===e.attemptId&&r.feedback_id===e.feedbackId&&Pa()}async function ta(){F.value=null,await t.replace({name:s,query:o()})}async function aa(){const e=F.value,n=w.value;if(!e||!n||!N.value)return!1;const r=n.operation;
12if(q.value=e,h.value=e.text,T.value="",S.value="full_essay",A.value="typed",W.value=!0,!ye({force:!0,operation:null}))return ge(n),F.value=e,!1;tt(r);const i=ce();i&&r&&Ue(i,r.operationId);const c=ne();return c&&r&&Ye(c,r.operationId),m.value=null,E.value=null,I.value="not-read",F.value=null,g.value="",!0}async function ra(){var u,i;const e=ne(),n=ce(),r=(i=(u=w.value)==null?void 0:u.operation)==null?void 0:i.operationId;return!e||!st(e)?!1:(n&&r&&Ue(n,r),e&&r&&Ye(e,r),tt(),w.value=null,m.value=null,E.value=null,I.value="not-read",N.value=Ae(),q.value=de({source:"custom",text:""}),h.value="",T.value="",S.value="full_essay",A.value="typed",f.value="idle",l.value="This draft was cleared. Start typing to save a new recovery copy.",p.value="editing",pe.value="",g.value="",F.value=null,P.value=!1,O.value=!1,B.value=!1,W.value=!1,await t.replace({name:s,query:o()}),!0)}function at(e){!ze.value||!W.value&&!Ee.value||(e.preventDefault(),e.returnValue="")}return typeof window<"u"&&window.addEventListener("beforeunload",at),pa(()=>{var n;Ke=!1;for(const r of fe)r.abort();fe.clear(),typeof window<"u"&&window.removeEventListener("beforeunload",at),V&&(clearTimeout(V),V=void 0);const e=(n=d.currentUser)==null?void 0:n.firebase_uid;if(W.value&&!re.value&&typeof e=="string"&&nt(z,e))try{ye({force:!0})}catch{}}),{taskText:h,responseText:T,feedbackScope:S,taskSnapshot:q,workBindingRecoveryStatus:I,saveState:f,saveMessage:l,submissionStage:p,submissionMessage:pe,submissionError:g,handoffError:ae,handoffRetryAvailable:ue,handoffRetrying:Se,loading:Ie,isComposing:re,allowWithoutRecovery:B,recoveryPersistenceUnavailable:O,catalogTaskExpanded:Fe,draftChangedElsewhere:P,pendingCatalogTask:F,assessment:xe,submitLabel:Gt,isBusy:Ee,canSubmit:Mt,isCatalogTask:Me,hasMeaningfulDraft:ze,hasStageMismatch:Nt,hasFrozenOperation:Ne,inputLocked:le,incomingTaskConflict:Ot,initialize:et,requestFeedback:Qt,retryCatalogHandoff:Zt,useOwnQuestion:Xt,reloadSavedDraft:ea,keepSavedDraft:ta,useIncomingCatalogTask:aa,clearDraft:ra,handleTaskInput:$t,handleResponseInput:Wt,handleResponsePaste:Lt,handleScopeChange:Ut,handleCompositionStart:Yt,handleCompositionEnd:Vt,flushDraft:he}}export{Yr as L,jr as N,Vr as S,Br as u};

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.