@fabrika/builder 0.9.0-dev.4 → 0.9.0-dev.6
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.
- package/cli/src/inject-skills.ts +2 -2
- package/cli/src/skeletons.ts +2 -2
- package/daemon/src/handlers.ts +1 -1
- package/daemon/src/platform-remote.ts +1 -1
- package/decisions/technologies/zerops-fabrika-auth.md +1 -1
- package/decisions/technologies/zerops-platform.md +1 -1
- package/package.json +8 -8
- package/types/daemon/src/platform-remote.d.ts +96 -0
- package/types/shared/index.d.ts +55 -55
- package/ui/dist/assets/client.99x2d68y.js +214 -0
- package/ui/dist/index.html +1 -1
- package/ui/dist/assets/client.j37h210g.js +0 -214
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
var I4=Object.defineProperty;var V4=($)=>$;function D4($,f){this[$]=V4.bind(null,f)}var E4=($,f)=>{for(var w in f)I4($,w,{get:f[w],enumerable:!0,configurable:!0,set:D4.bind(f,w)})};import{createRoot as EJ}from"react-dom/client";import{useEffect as T4,useMemo as v5,useRef as m5,useState as P1}from"react";import{useState as a6}from"react";import{AnnotationCtx as o8,AnnotationHostContext as n8,SessionContext as t8,useAnnotationHost as a8,useAnnotations as s8}from"@fabrika/annotations/runtime";function T2($,f){let w=[],X=C5($);for(let J of X){let W=document.createRange();if(W.selectNodeContents(J),J===$.startContainer)W.setStart(J,$.startOffset);if(J===$.endContainer)W.setEnd(J,$.endOffset);let q=W.toString();if(!q||!q.trim())continue;let Y=document.createElement("mark");Y.setAttribute("data-annotation-id",f);try{W.surroundContents(Y)}catch{let Q=W.extractContents();Y.appendChild(Q),W.insertNode(Y)}w.push(Y)}return w}function q2($){let f=$.parentElement;if(f?.classList.contains("select-none"))return!1;if(f?.closest("[data-annotation-id]"))return!1;return!0}function C5($){let f=[],w=$.commonAncestorContainer;if(w.nodeType===Node.TEXT_NODE)return f.push(w),f;let X=document.createTreeWalker(w,NodeFilter.SHOW_TEXT),J;while(J=X.nextNode()){if(!q2(J))continue;if($.intersectsNode(J))f.push(J)}return f}function Z4($,f){let w=document.createRange();if(w.selectNodeContents($),$===f.startContainer)w.setStart($,f.startOffset);if($===f.endContainer)w.setEnd($,f.endOffset);return w.toString()}function y5($){let f="";for(let w of C5($))f+=Z4(w,$);return f}function v1($,f){let w=document.querySelectorAll(`[data-annotation-id="${$}"]`);for(let X of w)X.classList.toggle("mark-active",f)}function K$($,f){if(f!=null&&f!==$)v1(f,!1);if($!=null)v1($,!0)}function F$($,f){let w=document.querySelectorAll(`[data-annotation-id="${$}"]`);for(let X of w)X.setAttribute("data-annotation-id",f)}function S$($,f){for(let w of f){if($.querySelector(`[data-annotation-id="${w.id}"]`))continue;let X=w.snippet;if(!X)continue;let{fullText:J,textNodes:W}=x4($),q=[],Y=0;while(!0){let b=J.indexOf(X,Y);if(b===-1)break;q.push(b),Y=b+1}let[Q]=q;if(Q===void 0)continue;let _=Q;if(q.length>1&&w.context){let b=-1;for(let z of q){let L=0;if(w.context.before){let R=J.slice(Math.max(0,z-80),z);if(R.includes(w.context.before))L+=2;else if(w.context.before.length>10&&R.includes(w.context.before.slice(-10)))L+=1}if(w.context.after){let R=J.slice(z+X.length,z+X.length+80);if(R.includes(w.context.after))L+=2;else if(w.context.after.length>10&&R.includes(w.context.after.slice(0,10)))L+=1}if(L>b)b=L,_=z}}let N=_,U=_+X.length,B=k5(W,N),H=k5(W,U);if(!B||!H)continue;try{let b=document.createRange();b.setStart(B.node,B.offset),b.setEnd(H.node,H.offset),T2(b,w.id)}catch{}}}function x4($){let f=[],w="",X=document.createTreeWalker($,NodeFilter.SHOW_TEXT),J;while(J=X.nextNode()){if(!q2(J))continue;f.push({node:J,start:w.length}),w+=J.textContent||""}return{fullText:w,textNodes:f}}function k5($,f){for(let w=$.length-1;w>=0;w--){let X=$[w];if(!X||X.start>f)continue;let J=f-X.start,W=X.node.textContent?.length??0;if(J<=W)return{node:X.node,offset:J}}return null}function z$($){let f=document.querySelectorAll(`[data-annotation-id="${$}"]`);for(let w of f){let X=w.parentNode;if(!X)continue;if(w.tagName!=="MARK"){X.removeChild(w);continue}while(w.firstChild)X.insertBefore(w.firstChild,w);X.removeChild(w),X.normalize()}}function A$($,f){let w=T5($,"before",60),X=T5($,"after",60),J=u4($.startContainer,f);return{before:w,after:X,hierarchy:J}}function T5($,f,w){let X=c4(f==="before"?$.startContainer:$.endContainer);if(!X)return"";let J="";if(f==="before"){let W=document.createTreeWalker(X,NodeFilter.SHOW_TEXT),q;while(q=W.nextNode()){if(q===$.startContainer){J+=(q.textContent||"").slice(0,$.startOffset);break}if(!q2(q))continue;J+=q.textContent||""}if(J.length>w){J=J.slice(-w);let Y=J.indexOf(" ");if(Y>0)J=J.slice(Y+1)}}else{let W=document.createTreeWalker(X,NodeFilter.SHOW_TEXT),q=!1,Y;while(Y=W.nextNode()){if(Y===$.endContainer){J+=(Y.textContent||"").slice($.endOffset),q=!0;continue}if(q){if(!q2(Y))continue;J+=Y.textContent||""}}if(J.length>w){J=J.slice(0,w);let Q=J.lastIndexOf(" ");if(Q>0)J=J.slice(0,Q)}}return J.trim()}function c4($){let f=new Set(["DIV","P","LI","PRE","BLOCKQUOTE","SECTION","ARTICLE"]),w=$.parentElement;while(w){if(f.has(w.tagName))return w;w=w.parentElement}return null}function u4($,f){let w=[],X=$ instanceof Element?$:$.parentElement;while(X&&X!==f){let J=X.getAttribute?.("data-task-id");if(J){let q=X.querySelector(".font-semibold");if(q)w.unshift(q.textContent?.trim()||J)}let W=l4(X);if(W)w.unshift(W);X=X.parentElement}return w}function l4($){if($.getAttribute("data-md")==="section"){let w=$.getAttribute("data-md-title");if(w)return w}if($.tagName!=="DIV")return null;return $.querySelector(":scope > button > .font-heading, :scope > div > .font-heading")?.textContent?.trim()||null}function g2($){let f=$.snippet.trim(),w=$.context,X=f.length<30;if(w&&X&&(w.before||w.after)){let J=[];if(w.before)J.push(`...${w.before} `);if(J.push(`**${f}**`),w.after)J.push(` ${w.after}...`);return J.join("")}return f}function W2($){return{kind:$.kind,owns:(f)=>$.parse(f)!==null,find:(f,w)=>{let X=$.parse(f);return X===null?null:$.find(X,w)},restore:(f,w)=>{let X=$.parse(w.snippet);if(X===null)return;$.restore?.(X,f,w)},describe:(f)=>{let w=$.parse(f);if(w===null||!$.describe)return null;return $.describe(w)}}}function g5($){let f=document.createTreeWalker($,NodeFilter.SHOW_TEXT),w="";for(let X=f.nextNode();X;X=f.nextNode()){let J=X.parentElement?.closest("[aria-hidden='true']");if(J&&$.contains(J))continue;w+=X.textContent??""}return w.trim()}function h2($,f,w){return{selector:$,snippet:(X)=>{let J=X.getAttribute(w);return J?`${f} ${J}`:null}}}var R$=[h2("[data-md='item']","[Item]","data-md-label"),h2("[data-md='section']","[Section]","data-md-title"),h2("[data-md='checklist-item']","[Checklist]","data-md-label"),h2("[data-md='image']","[Image]","data-md-src"),{selector:"[data-md='callout']",snippet:($)=>{return`[Callout:${$.getAttribute("data-md-type")||"info"}] ${g5($).slice(0,60)||"Callout"}`}},{selector:"[data-md='note']",snippet:($)=>`[Note] ${g5($).slice(0,60)||"Note"}`},{selector:"[data-md='table'] tbody tr",snippet:($)=>{let f=Array.from($.querySelectorAll("td")).map((w)=>w.textContent?.trim()).filter(Boolean);return f.length?`[Row] ${f.join(" | ")}`:null}}],p4=["[data-md='choice-option']","[data-md='multichoice-option']","[data-md='userinput']","[data-md='rangeinput']"],a0=R$.map(($)=>$.selector).join(", "),m1=[...R$.map(($)=>$.selector),...p4].join(", ");function E0($){for(let f of R$)if($.matches(f.selector))return f.snippet($);return null}var P$={kind:"block",parse:($)=>$.startsWith("[")?{snippet:$}:null,format:($)=>$.snippet,find:($,f)=>{for(let w of f.querySelectorAll(a0)){if(!(w instanceof HTMLElement))continue;if(E0(w)===$.snippet)return w}return null}};var m$="data-annotation-image",r4=/^\[Region:(rect|ellipse)\] ([\s\S]+) @(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*)$/;function i4($){if($==="rect")return"rect";if($==="ellipse")return"ellipse";return null}function j2($){if($===void 0)return null;let f=Number($);if(!Number.isInteger(f)||f<0||f>1e4)return null;return f}function h5($){return Math.min(1e4,Math.max(0,$))}function k$($,f,w){if(!($.width>0)||!($.height>0))return null;return{x:h5(Math.round(f/$.width*1e4)),y:h5(Math.round(w/$.height*1e4))}}function V2($,f){let w=Math.min($.x,f.x),X=Math.min($.y,f.y);return{x:w,y:X,w:Math.min(1e4-w,Math.abs($.x-f.x)),h:Math.min(1e4-X,Math.abs($.y-f.y))}}function C$($){return $.w>=30&&$.h>=30}function j5($){return{left:`${$.x/100}%`,top:`${$.y/100}%`,width:`${$.w/100}%`,height:`${$.h/100}%`}}function I2($){return`${($/100).toFixed(1).replace(/\.0$/,"")}%`}function D2($){let f=`${I2($.x)}-${I2($.x+$.w)}`,w=`${I2($.y)}-${I2($.y+$.h)}`;return`[Region] ${$.src} — ${$.shape} x ${f}, y ${w} of the image`}function v$($,f){for(let w of f.querySelectorAll("[data-md='image']")){if(!(w instanceof HTMLElement))continue;if(w.getAttribute("data-md-src")!==$)continue;let X=w.querySelector("[data-annotation-image]");if(X instanceof HTMLElement)return X}return null}function E2($,f){let w=j5(f);$.style.left=w.left,$.style.top=w.top,$.style.width=w.width,$.style.height=w.height}function Z2($,f,w){let X=document.createElement("div");return X.className="ann-region",X.setAttribute("data-annotation-id",w),X.setAttribute("data-annotation-region",f),E2(X,$),X}var Q2={kind:"region",parse:($)=>{let f=r4.exec($);if(!f)return null;let w=i4(f[1]),X=f[2],J=j2(f[3]),W=j2(f[4]),q=j2(f[5]),Y=j2(f[6]);if(w===null||X===void 0)return null;if(J===null||W===null||q===null||Y===null)return null;if(q<1||Y<1)return null;return{src:X,shape:w,x:J,y:W,w:q,h:Y}},format:($)=>`[Region:${$.shape}] ${$.src} @${$.x},${$.y},${$.w},${$.h}`,find:($,f)=>v$($.src,f),restore:($,f,w)=>{if(f.querySelector(`[data-annotation-id="${w.id}"]`))return;let X=v$($.src,f);if(!X)return;X.appendChild(Z2($,$.shape,w.id))},describe:D2};var y$={kind:"text",parse:($)=>$?{text:$}:null,format:($)=>$.text,find:()=>null,restore:($,f,w)=>{S$(f,[w])}};var x2=[W2(Q2),W2(P$),W2(y$)];function T$($,f){for(let w of x2){let X=w.find($,f);if(X)return X}return null}function g$($,f){for(let w of f){if(!w.snippet)continue;for(let X of x2)X.restore($,w)}}function Y2($){for(let f of x2){let w=f.describe($);if(w!==null)return w}return $}import{AnnotationCtx as jX,SessionContext as IX,useAnnotationHost as VX}from"@fabrika/annotations/runtime";import{useEffect as ZX,useRef as xX,useState as cX}from"react";var G={};E4(G,{void:()=>y3,util:()=>n,unknown:()=>k3,union:()=>j3,undefined:()=>P3,tuple:()=>D3,transformer:()=>d3,symbol:()=>R3,string:()=>l5,strictObject:()=>h3,setErrorMap:()=>n4,set:()=>x3,record:()=>E3,quotelessJson:()=>d4,promise:()=>i3,preprocess:()=>t3,pipeline:()=>a3,ostring:()=>s3,optional:()=>o3,onumber:()=>e3,oboolean:()=>$w,objectUtil:()=>h$,object:()=>g3,number:()=>p5,nullable:()=>n3,null:()=>v3,never:()=>C3,nativeEnum:()=>r3,nan:()=>S3,map:()=>Z3,makeIssue:()=>G2,literal:()=>l3,lazy:()=>u3,late:()=>K3,isValid:()=>s0,isDirty:()=>u2,isAsync:()=>C1,isAborted:()=>c2,intersection:()=>V3,instanceof:()=>F3,getParsedType:()=>Z0,getErrorMap:()=>k1,function:()=>c3,enum:()=>p3,effect:()=>d3,discriminatedUnion:()=>I3,defaultErrorMap:()=>p0,datetimeRegex:()=>x5,date:()=>A3,custom:()=>u5,coerce:()=>fw,boolean:()=>r5,bigint:()=>z3,array:()=>T3,any:()=>m3,addIssueToContext:()=>A,ZodVoid:()=>N2,ZodUnknown:()=>e0,ZodUnion:()=>I1,ZodUndefined:()=>h1,ZodType:()=>d,ZodTuple:()=>c0,ZodTransformer:()=>h0,ZodSymbol:()=>_2,ZodString:()=>C0,ZodSet:()=>N1,ZodSchema:()=>d,ZodRecord:()=>H2,ZodReadonly:()=>u1,ZodPromise:()=>H1,ZodPipeline:()=>B2,ZodParsedType:()=>S,ZodOptional:()=>T0,ZodObject:()=>N0,ZodNumber:()=>$1,ZodNullable:()=>i0,ZodNull:()=>j1,ZodNever:()=>x0,ZodNativeEnum:()=>Z1,ZodNaN:()=>U2,ZodMap:()=>b2,ZodLiteral:()=>E1,ZodLazy:()=>D1,ZodIssueCode:()=>K,ZodIntersection:()=>V1,ZodFunction:()=>T1,ZodFirstPartyTypeKind:()=>D,ZodError:()=>R0,ZodEnum:()=>w1,ZodEffects:()=>h0,ZodDiscriminatedUnion:()=>l2,ZodDefault:()=>x1,ZodDate:()=>G1,ZodCatch:()=>c1,ZodBranded:()=>p2,ZodBoolean:()=>g1,ZodBigInt:()=>f1,ZodArray:()=>y0,ZodAny:()=>_1,Schema:()=>d,ParseStatus:()=>K0,OK:()=>F0,NEVER:()=>ww,INVALID:()=>I,EMPTY_PATH:()=>t4,DIRTY:()=>Y1,BRAND:()=>O3});var n;(function($){$.assertEqual=(J)=>{};function f(J){}$.assertIs=f;function w(J){throw Error()}$.assertNever=w,$.arrayToEnum=(J)=>{let W={};for(let q of J)W[q]=q;return W},$.getValidEnumValues=(J)=>{let W=$.objectKeys(J).filter((Y)=>typeof J[J[Y]]!=="number"),q={};for(let Y of W)q[Y]=J[Y];return $.objectValues(q)},$.objectValues=(J)=>{return $.objectKeys(J).map(function(W){return J[W]})},$.objectKeys=typeof Object.keys==="function"?(J)=>Object.keys(J):(J)=>{let W=[];for(let q in J)if(Object.prototype.hasOwnProperty.call(J,q))W.push(q);return W},$.find=(J,W)=>{for(let q of J)if(W(q))return q;return},$.isInteger=typeof Number.isInteger==="function"?(J)=>Number.isInteger(J):(J)=>typeof J==="number"&&Number.isFinite(J)&&Math.floor(J)===J;function X(J,W=" | "){return J.map((q)=>typeof q==="string"?`'${q}'`:q).join(W)}$.joinValues=X,$.jsonStringifyReplacer=(J,W)=>{if(typeof W==="bigint")return W.toString();return W}})(n||(n={}));var h$;(function($){$.mergeShapes=(f,w)=>{return{...f,...w}}})(h$||(h$={}));var S=n.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Z0=($)=>{switch(typeof $){case"undefined":return S.undefined;case"string":return S.string;case"number":return Number.isNaN($)?S.nan:S.number;case"boolean":return S.boolean;case"function":return S.function;case"bigint":return S.bigint;case"symbol":return S.symbol;case"object":if(Array.isArray($))return S.array;if($===null)return S.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return S.promise;if(typeof Map<"u"&&$ instanceof Map)return S.map;if(typeof Set<"u"&&$ instanceof Set)return S.set;if(typeof Date<"u"&&$ instanceof Date)return S.date;return S.object;default:return S.unknown}};var K=n.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),d4=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class R0 extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(w)=>{this.issues=[...this.issues,w]},this.addIssues=(w=[])=>{this.issues=[...this.issues,...w]};let f=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,f);else this.__proto__=f;this.name="ZodError",this.issues=$}format($){let f=$||function(J){return J.message},w={_errors:[]},X=(J)=>{for(let W of J.issues)if(W.code==="invalid_union")W.unionErrors.map(X);else if(W.code==="invalid_return_type")X(W.returnTypeError);else if(W.code==="invalid_arguments")X(W.argumentsError);else if(W.path.length===0)w._errors.push(f(W));else{let q=w,Y=0;while(Y<W.path.length){let Q=W.path[Y];if(Y!==W.path.length-1)q[Q]=q[Q]||{_errors:[]};else q[Q]=q[Q]||{_errors:[]},q[Q]._errors.push(f(W));q=q[Q],Y++}}};return X(this),w}static assert($){if(!($ instanceof R0))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,n.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(f)=>f.message){let f={},w=[];for(let X of this.issues)if(X.path.length>0){let J=X.path[0];f[J]=f[J]||[],f[J].push($(X))}else w.push($(X));return{formErrors:w,fieldErrors:f}}get formErrors(){return this.flatten()}}R0.create=($)=>{return new R0($)};var o4=($,f)=>{let w;switch($.code){case K.invalid_type:if($.received===S.undefined)w="Required";else w=`Expected ${$.expected}, received ${$.received}`;break;case K.invalid_literal:w=`Invalid literal value, expected ${JSON.stringify($.expected,n.jsonStringifyReplacer)}`;break;case K.unrecognized_keys:w=`Unrecognized key(s) in object: ${n.joinValues($.keys,", ")}`;break;case K.invalid_union:w="Invalid input";break;case K.invalid_union_discriminator:w=`Invalid discriminator value. Expected ${n.joinValues($.options)}`;break;case K.invalid_enum_value:w=`Invalid enum value. Expected ${n.joinValues($.options)}, received '${$.received}'`;break;case K.invalid_arguments:w="Invalid function arguments";break;case K.invalid_return_type:w="Invalid function return type";break;case K.invalid_date:w="Invalid date";break;case K.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(w=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")w=`${w} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)w=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)w=`Invalid input: must end with "${$.validation.endsWith}"`;else n.assertNever($.validation);else if($.validation!=="regex")w=`Invalid ${$.validation}`;else w="Invalid";break;case K.too_small:if($.type==="array")w=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")w=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")w=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")w=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")w=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else w="Invalid input";break;case K.too_big:if($.type==="array")w=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")w=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")w=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")w=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")w=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else w="Invalid input";break;case K.custom:w="Invalid input";break;case K.invalid_intersection_types:w="Intersection results could not be merged";break;case K.not_multiple_of:w=`Number must be a multiple of ${$.multipleOf}`;break;case K.not_finite:w="Number must be finite";break;default:w=f.defaultError,n.assertNever($)}return{message:w}},p0=o4;var I5=p0;function n4($){I5=$}function k1(){return I5}var G2=($)=>{let{data:f,path:w,errorMaps:X,issueData:J}=$,W=[...w,...J.path||[]],q={...J,path:W};if(J.message!==void 0)return{...J,path:W,message:J.message};let Y="",Q=X.filter((_)=>!!_).slice().reverse();for(let _ of Q)Y=_(q,{data:f,defaultError:Y}).message;return{...J,path:W,message:Y}},t4=[];function A($,f){let w=k1(),X=G2({issueData:f,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,w,w===p0?void 0:p0].filter((J)=>!!J)});$.common.issues.push(X)}class K0{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,f){let w=[];for(let X of f){if(X.status==="aborted")return I;if(X.status==="dirty")$.dirty();w.push(X.value)}return{status:$.value,value:w}}static async mergeObjectAsync($,f){let w=[];for(let X of f){let J=await X.key,W=await X.value;w.push({key:J,value:W})}return K0.mergeObjectSync($,w)}static mergeObjectSync($,f){let w={};for(let X of f){let{key:J,value:W}=X;if(J.status==="aborted")return I;if(W.status==="aborted")return I;if(J.status==="dirty")$.dirty();if(W.status==="dirty")$.dirty();if(J.value!=="__proto__"&&(typeof W.value<"u"||X.alwaysSet))w[J.value]=W.value}return{status:$.value,value:w}}}var I=Object.freeze({status:"aborted"}),Y1=($)=>({status:"dirty",value:$}),F0=($)=>({status:"valid",value:$}),c2=($)=>$.status==="aborted",u2=($)=>$.status==="dirty",s0=($)=>$.status==="valid",C1=($)=>typeof Promise<"u"&&$ instanceof Promise;var C;(function($){$.errToObj=(f)=>typeof f==="string"?{message:f}:f||{},$.toString=(f)=>typeof f==="string"?f:f?.message})(C||(C={}));class g0{constructor($,f,w,X){this._cachedPath=[],this.parent=$,this.data=f,this._path=w,this._key=X}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var V5=($,f)=>{if(s0(f))return{success:!0,data:f.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let w=new R0($.common.issues);return this._error=w,this._error}}}};function l($){if(!$)return{};let{errorMap:f,invalid_type_error:w,required_error:X,description:J}=$;if(f&&(w||X))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(f)return{errorMap:f,description:J};return{errorMap:(q,Y)=>{let{message:Q}=$;if(q.code==="invalid_enum_value")return{message:Q??Y.defaultError};if(typeof Y.data>"u")return{message:Q??X??Y.defaultError};if(q.code!=="invalid_type")return{message:Y.defaultError};return{message:Q??w??Y.defaultError}},description:J}}class d{get description(){return this._def.description}_getType($){return Z0($.data)}_getOrReturnCtx($,f){return f||{common:$.parent.common,data:$.data,parsedType:Z0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new K0,ctx:{common:$.parent.common,data:$.data,parsedType:Z0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let f=this._parse($);if(C1(f))throw Error("Synchronous parse encountered promise.");return f}_parseAsync($){let f=this._parse($);return Promise.resolve(f)}parse($,f){let w=this.safeParse($,f);if(w.success)return w.data;throw w.error}safeParse($,f){let w={common:{issues:[],async:f?.async??!1,contextualErrorMap:f?.errorMap},path:f?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:Z0($)},X=this._parseSync({data:$,path:w.path,parent:w});return V5(w,X)}"~validate"($){let f={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:Z0($)};if(!this["~standard"].async)try{let w=this._parseSync({data:$,path:[],parent:f});return s0(w)?{value:w.value}:{issues:f.common.issues}}catch(w){if(w?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;f.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:f}).then((w)=>s0(w)?{value:w.value}:{issues:f.common.issues})}async parseAsync($,f){let w=await this.safeParseAsync($,f);if(w.success)return w.data;throw w.error}async safeParseAsync($,f){let w={common:{issues:[],contextualErrorMap:f?.errorMap,async:!0},path:f?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:Z0($)},X=this._parse({data:$,path:w.path,parent:w}),J=await(C1(X)?X:Promise.resolve(X));return V5(w,J)}refine($,f){let w=(X)=>{if(typeof f==="string"||typeof f>"u")return{message:f};else if(typeof f==="function")return f(X);else return f};return this._refinement((X,J)=>{let W=$(X),q=()=>J.addIssue({code:K.custom,...w(X)});if(typeof Promise<"u"&&W instanceof Promise)return W.then((Y)=>{if(!Y)return q(),!1;else return!0});if(!W)return q(),!1;else return!0})}refinement($,f){return this._refinement((w,X)=>{if(!$(w))return X.addIssue(typeof f==="function"?f(w,X):f),!1;else return!0})}_refinement($){return new h0({schema:this,typeName:D.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(f)=>this["~validate"](f)}}optional(){return T0.create(this,this._def)}nullable(){return i0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return y0.create(this)}promise(){return H1.create(this,this._def)}or($){return I1.create([this,$],this._def)}and($){return V1.create(this,$,this._def)}transform($){return new h0({...l(this._def),schema:this,typeName:D.ZodEffects,effect:{type:"transform",transform:$}})}default($){let f=typeof $==="function"?$:()=>$;return new x1({...l(this._def),innerType:this,defaultValue:f,typeName:D.ZodDefault})}brand(){return new p2({typeName:D.ZodBranded,type:this,...l(this._def)})}catch($){let f=typeof $==="function"?$:()=>$;return new c1({...l(this._def),innerType:this,catchValue:f,typeName:D.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return B2.create(this,$)}readonly(){return u1.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var a4=/^c[^\s-]{8,}$/i,s4=/^[0-9a-z]+$/,e4=/^[0-9A-HJKMNP-TV-Z]{26}$/i,$3=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,f3=/^[a-z0-9_-]{21}$/i,w3=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,J3=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,X3=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,q3="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",j$,W3=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Q3=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Y3=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,G3=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,_3=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,N3=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,E5="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",H3=new RegExp(`^${E5}$`);function Z5($){let f="[0-5]\\d";if($.precision)f=`${f}\\.\\d{${$.precision}}`;else if($.precision==null)f=`${f}(\\.\\d+)?`;let w=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${f})${w}`}function b3($){return new RegExp(`^${Z5($)}$`)}function x5($){let f=`${E5}T${Z5($)}`,w=[];if(w.push($.local?"Z?":"Z"),$.offset)w.push("([+-]\\d{2}:?\\d{2})");return f=`${f}(${w.join("|")})`,new RegExp(`^${f}$`)}function U3($,f){if((f==="v4"||!f)&&W3.test($))return!0;if((f==="v6"||!f)&&Y3.test($))return!0;return!1}function B3($,f){if(!w3.test($))return!1;try{let[w]=$.split(".");if(!w)return!1;let X=w.replace(/-/g,"+").replace(/_/g,"/").padEnd(w.length+(4-w.length%4)%4,"="),J=JSON.parse(atob(X));if(typeof J!=="object"||J===null)return!1;if("typ"in J&&J?.typ!=="JWT")return!1;if(!J.alg)return!1;if(f&&J.alg!==f)return!1;return!0}catch{return!1}}function M3($,f){if((f==="v4"||!f)&&Q3.test($))return!0;if((f==="v6"||!f)&&G3.test($))return!0;return!1}class C0 extends d{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==S.string){let J=this._getOrReturnCtx($);return A(J,{code:K.invalid_type,expected:S.string,received:J.parsedType}),I}let w=new K0,X=void 0;for(let J of this._def.checks)if(J.kind==="min"){if($.data.length<J.value)X=this._getOrReturnCtx($,X),A(X,{code:K.too_small,minimum:J.value,type:"string",inclusive:!0,exact:!1,message:J.message}),w.dirty()}else if(J.kind==="max"){if($.data.length>J.value)X=this._getOrReturnCtx($,X),A(X,{code:K.too_big,maximum:J.value,type:"string",inclusive:!0,exact:!1,message:J.message}),w.dirty()}else if(J.kind==="length"){let W=$.data.length>J.value,q=$.data.length<J.value;if(W||q){if(X=this._getOrReturnCtx($,X),W)A(X,{code:K.too_big,maximum:J.value,type:"string",inclusive:!0,exact:!0,message:J.message});else if(q)A(X,{code:K.too_small,minimum:J.value,type:"string",inclusive:!0,exact:!0,message:J.message});w.dirty()}}else if(J.kind==="email"){if(!X3.test($.data))X=this._getOrReturnCtx($,X),A(X,{validation:"email",code:K.invalid_string,message:J.message}),w.dirty()}else if(J.kind==="emoji"){if(!j$)j$=new RegExp(q3,"u");if(!j$.test($.data))X=this._getOrReturnCtx($,X),A(X,{validation:"emoji",code:K.invalid_string,message:J.message}),w.dirty()}else if(J.kind==="uuid"){if(!$3.test($.data))X=this._getOrReturnCtx($,X),A(X,{validation:"uuid",code:K.invalid_string,message:J.message}),w.dirty()}else if(J.kind==="nanoid"){if(!f3.test($.data))X=this._getOrReturnCtx($,X),A(X,{validation:"nanoid",code:K.invalid_string,message:J.message}),w.dirty()}else if(J.kind==="cuid"){if(!a4.test($.data))X=this._getOrReturnCtx($,X),A(X,{validation:"cuid",code:K.invalid_string,message:J.message}),w.dirty()}else if(J.kind==="cuid2"){if(!s4.test($.data))X=this._getOrReturnCtx($,X),A(X,{validation:"cuid2",code:K.invalid_string,message:J.message}),w.dirty()}else if(J.kind==="ulid"){if(!e4.test($.data))X=this._getOrReturnCtx($,X),A(X,{validation:"ulid",code:K.invalid_string,message:J.message}),w.dirty()}else if(J.kind==="url")try{new URL($.data)}catch{X=this._getOrReturnCtx($,X),A(X,{validation:"url",code:K.invalid_string,message:J.message}),w.dirty()}else if(J.kind==="regex"){if(J.regex.lastIndex=0,!J.regex.test($.data))X=this._getOrReturnCtx($,X),A(X,{validation:"regex",code:K.invalid_string,message:J.message}),w.dirty()}else if(J.kind==="trim")$.data=$.data.trim();else if(J.kind==="includes"){if(!$.data.includes(J.value,J.position))X=this._getOrReturnCtx($,X),A(X,{code:K.invalid_string,validation:{includes:J.value,position:J.position},message:J.message}),w.dirty()}else if(J.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(J.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(J.kind==="startsWith"){if(!$.data.startsWith(J.value))X=this._getOrReturnCtx($,X),A(X,{code:K.invalid_string,validation:{startsWith:J.value},message:J.message}),w.dirty()}else if(J.kind==="endsWith"){if(!$.data.endsWith(J.value))X=this._getOrReturnCtx($,X),A(X,{code:K.invalid_string,validation:{endsWith:J.value},message:J.message}),w.dirty()}else if(J.kind==="datetime"){if(!x5(J).test($.data))X=this._getOrReturnCtx($,X),A(X,{code:K.invalid_string,validation:"datetime",message:J.message}),w.dirty()}else if(J.kind==="date"){if(!H3.test($.data))X=this._getOrReturnCtx($,X),A(X,{code:K.invalid_string,validation:"date",message:J.message}),w.dirty()}else if(J.kind==="time"){if(!b3(J).test($.data))X=this._getOrReturnCtx($,X),A(X,{code:K.invalid_string,validation:"time",message:J.message}),w.dirty()}else if(J.kind==="duration"){if(!J3.test($.data))X=this._getOrReturnCtx($,X),A(X,{validation:"duration",code:K.invalid_string,message:J.message}),w.dirty()}else if(J.kind==="ip"){if(!U3($.data,J.version))X=this._getOrReturnCtx($,X),A(X,{validation:"ip",code:K.invalid_string,message:J.message}),w.dirty()}else if(J.kind==="jwt"){if(!B3($.data,J.alg))X=this._getOrReturnCtx($,X),A(X,{validation:"jwt",code:K.invalid_string,message:J.message}),w.dirty()}else if(J.kind==="cidr"){if(!M3($.data,J.version))X=this._getOrReturnCtx($,X),A(X,{validation:"cidr",code:K.invalid_string,message:J.message}),w.dirty()}else if(J.kind==="base64"){if(!_3.test($.data))X=this._getOrReturnCtx($,X),A(X,{validation:"base64",code:K.invalid_string,message:J.message}),w.dirty()}else if(J.kind==="base64url"){if(!N3.test($.data))X=this._getOrReturnCtx($,X),A(X,{validation:"base64url",code:K.invalid_string,message:J.message}),w.dirty()}else n.assertNever(J);return{status:w.value,value:$.data}}_regex($,f,w){return this.refinement((X)=>$.test(X),{validation:f,code:K.invalid_string,...C.errToObj(w)})}_addCheck($){return new C0({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...C.errToObj($)})}url($){return this._addCheck({kind:"url",...C.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...C.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...C.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...C.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...C.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...C.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...C.errToObj($)})}base64($){return this._addCheck({kind:"base64",...C.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...C.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...C.errToObj($)})}ip($){return this._addCheck({kind:"ip",...C.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...C.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision>"u"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...C.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision>"u"?null:$?.precision,...C.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...C.errToObj($)})}regex($,f){return this._addCheck({kind:"regex",regex:$,...C.errToObj(f)})}includes($,f){return this._addCheck({kind:"includes",value:$,position:f?.position,...C.errToObj(f?.message)})}startsWith($,f){return this._addCheck({kind:"startsWith",value:$,...C.errToObj(f)})}endsWith($,f){return this._addCheck({kind:"endsWith",value:$,...C.errToObj(f)})}min($,f){return this._addCheck({kind:"min",value:$,...C.errToObj(f)})}max($,f){return this._addCheck({kind:"max",value:$,...C.errToObj(f)})}length($,f){return this._addCheck({kind:"length",value:$,...C.errToObj(f)})}nonempty($){return this.min(1,C.errToObj($))}trim(){return new C0({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new C0({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new C0({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let f of this._def.checks)if(f.kind==="min"){if($===null||f.value>$)$=f.value}return $}get maxLength(){let $=null;for(let f of this._def.checks)if(f.kind==="max"){if($===null||f.value<$)$=f.value}return $}}C0.create=($)=>{return new C0({checks:[],typeName:D.ZodString,coerce:$?.coerce??!1,...l($)})};function L3($,f){let w=($.toString().split(".")[1]||"").length,X=(f.toString().split(".")[1]||"").length,J=w>X?w:X,W=Number.parseInt($.toFixed(J).replace(".","")),q=Number.parseInt(f.toFixed(J).replace(".",""));return W%q/10**J}class $1 extends d{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==S.number){let J=this._getOrReturnCtx($);return A(J,{code:K.invalid_type,expected:S.number,received:J.parsedType}),I}let w=void 0,X=new K0;for(let J of this._def.checks)if(J.kind==="int"){if(!n.isInteger($.data))w=this._getOrReturnCtx($,w),A(w,{code:K.invalid_type,expected:"integer",received:"float",message:J.message}),X.dirty()}else if(J.kind==="min"){if(J.inclusive?$.data<J.value:$.data<=J.value)w=this._getOrReturnCtx($,w),A(w,{code:K.too_small,minimum:J.value,type:"number",inclusive:J.inclusive,exact:!1,message:J.message}),X.dirty()}else if(J.kind==="max"){if(J.inclusive?$.data>J.value:$.data>=J.value)w=this._getOrReturnCtx($,w),A(w,{code:K.too_big,maximum:J.value,type:"number",inclusive:J.inclusive,exact:!1,message:J.message}),X.dirty()}else if(J.kind==="multipleOf"){if(L3($.data,J.value)!==0)w=this._getOrReturnCtx($,w),A(w,{code:K.not_multiple_of,multipleOf:J.value,message:J.message}),X.dirty()}else if(J.kind==="finite"){if(!Number.isFinite($.data))w=this._getOrReturnCtx($,w),A(w,{code:K.not_finite,message:J.message}),X.dirty()}else n.assertNever(J);return{status:X.value,value:$.data}}gte($,f){return this.setLimit("min",$,!0,C.toString(f))}gt($,f){return this.setLimit("min",$,!1,C.toString(f))}lte($,f){return this.setLimit("max",$,!0,C.toString(f))}lt($,f){return this.setLimit("max",$,!1,C.toString(f))}setLimit($,f,w,X){return new $1({...this._def,checks:[...this._def.checks,{kind:$,value:f,inclusive:w,message:C.toString(X)}]})}_addCheck($){return new $1({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:C.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:C.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:C.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:C.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:C.toString($)})}multipleOf($,f){return this._addCheck({kind:"multipleOf",value:$,message:C.toString(f)})}finite($){return this._addCheck({kind:"finite",message:C.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:C.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:C.toString($)})}get minValue(){let $=null;for(let f of this._def.checks)if(f.kind==="min"){if($===null||f.value>$)$=f.value}return $}get maxValue(){let $=null;for(let f of this._def.checks)if(f.kind==="max"){if($===null||f.value<$)$=f.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&n.isInteger($.value))}get isFinite(){let $=null,f=null;for(let w of this._def.checks)if(w.kind==="finite"||w.kind==="int"||w.kind==="multipleOf")return!0;else if(w.kind==="min"){if(f===null||w.value>f)f=w.value}else if(w.kind==="max"){if($===null||w.value<$)$=w.value}return Number.isFinite(f)&&Number.isFinite($)}}$1.create=($)=>{return new $1({checks:[],typeName:D.ZodNumber,coerce:$?.coerce||!1,...l($)})};class f1 extends d{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==S.bigint)return this._getInvalidInput($);let w=void 0,X=new K0;for(let J of this._def.checks)if(J.kind==="min"){if(J.inclusive?$.data<J.value:$.data<=J.value)w=this._getOrReturnCtx($,w),A(w,{code:K.too_small,type:"bigint",minimum:J.value,inclusive:J.inclusive,message:J.message}),X.dirty()}else if(J.kind==="max"){if(J.inclusive?$.data>J.value:$.data>=J.value)w=this._getOrReturnCtx($,w),A(w,{code:K.too_big,type:"bigint",maximum:J.value,inclusive:J.inclusive,message:J.message}),X.dirty()}else if(J.kind==="multipleOf"){if($.data%J.value!==BigInt(0))w=this._getOrReturnCtx($,w),A(w,{code:K.not_multiple_of,multipleOf:J.value,message:J.message}),X.dirty()}else n.assertNever(J);return{status:X.value,value:$.data}}_getInvalidInput($){let f=this._getOrReturnCtx($);return A(f,{code:K.invalid_type,expected:S.bigint,received:f.parsedType}),I}gte($,f){return this.setLimit("min",$,!0,C.toString(f))}gt($,f){return this.setLimit("min",$,!1,C.toString(f))}lte($,f){return this.setLimit("max",$,!0,C.toString(f))}lt($,f){return this.setLimit("max",$,!1,C.toString(f))}setLimit($,f,w,X){return new f1({...this._def,checks:[...this._def.checks,{kind:$,value:f,inclusive:w,message:C.toString(X)}]})}_addCheck($){return new f1({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:C.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:C.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:C.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:C.toString($)})}multipleOf($,f){return this._addCheck({kind:"multipleOf",value:$,message:C.toString(f)})}get minValue(){let $=null;for(let f of this._def.checks)if(f.kind==="min"){if($===null||f.value>$)$=f.value}return $}get maxValue(){let $=null;for(let f of this._def.checks)if(f.kind==="max"){if($===null||f.value<$)$=f.value}return $}}f1.create=($)=>{return new f1({checks:[],typeName:D.ZodBigInt,coerce:$?.coerce??!1,...l($)})};class g1 extends d{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==S.boolean){let w=this._getOrReturnCtx($);return A(w,{code:K.invalid_type,expected:S.boolean,received:w.parsedType}),I}return F0($.data)}}g1.create=($)=>{return new g1({typeName:D.ZodBoolean,coerce:$?.coerce||!1,...l($)})};class G1 extends d{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==S.date){let J=this._getOrReturnCtx($);return A(J,{code:K.invalid_type,expected:S.date,received:J.parsedType}),I}if(Number.isNaN($.data.getTime())){let J=this._getOrReturnCtx($);return A(J,{code:K.invalid_date}),I}let w=new K0,X=void 0;for(let J of this._def.checks)if(J.kind==="min"){if($.data.getTime()<J.value)X=this._getOrReturnCtx($,X),A(X,{code:K.too_small,message:J.message,inclusive:!0,exact:!1,minimum:J.value,type:"date"}),w.dirty()}else if(J.kind==="max"){if($.data.getTime()>J.value)X=this._getOrReturnCtx($,X),A(X,{code:K.too_big,message:J.message,inclusive:!0,exact:!1,maximum:J.value,type:"date"}),w.dirty()}else n.assertNever(J);return{status:w.value,value:new Date($.data.getTime())}}_addCheck($){return new G1({...this._def,checks:[...this._def.checks,$]})}min($,f){return this._addCheck({kind:"min",value:$.getTime(),message:C.toString(f)})}max($,f){return this._addCheck({kind:"max",value:$.getTime(),message:C.toString(f)})}get minDate(){let $=null;for(let f of this._def.checks)if(f.kind==="min"){if($===null||f.value>$)$=f.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let f of this._def.checks)if(f.kind==="max"){if($===null||f.value<$)$=f.value}return $!=null?new Date($):null}}G1.create=($)=>{return new G1({checks:[],coerce:$?.coerce||!1,typeName:D.ZodDate,...l($)})};class _2 extends d{_parse($){if(this._getType($)!==S.symbol){let w=this._getOrReturnCtx($);return A(w,{code:K.invalid_type,expected:S.symbol,received:w.parsedType}),I}return F0($.data)}}_2.create=($)=>{return new _2({typeName:D.ZodSymbol,...l($)})};class h1 extends d{_parse($){if(this._getType($)!==S.undefined){let w=this._getOrReturnCtx($);return A(w,{code:K.invalid_type,expected:S.undefined,received:w.parsedType}),I}return F0($.data)}}h1.create=($)=>{return new h1({typeName:D.ZodUndefined,...l($)})};class j1 extends d{_parse($){if(this._getType($)!==S.null){let w=this._getOrReturnCtx($);return A(w,{code:K.invalid_type,expected:S.null,received:w.parsedType}),I}return F0($.data)}}j1.create=($)=>{return new j1({typeName:D.ZodNull,...l($)})};class _1 extends d{constructor(){super(...arguments);this._any=!0}_parse($){return F0($.data)}}_1.create=($)=>{return new _1({typeName:D.ZodAny,...l($)})};class e0 extends d{constructor(){super(...arguments);this._unknown=!0}_parse($){return F0($.data)}}e0.create=($)=>{return new e0({typeName:D.ZodUnknown,...l($)})};class x0 extends d{_parse($){let f=this._getOrReturnCtx($);return A(f,{code:K.invalid_type,expected:S.never,received:f.parsedType}),I}}x0.create=($)=>{return new x0({typeName:D.ZodNever,...l($)})};class N2 extends d{_parse($){if(this._getType($)!==S.undefined){let w=this._getOrReturnCtx($);return A(w,{code:K.invalid_type,expected:S.void,received:w.parsedType}),I}return F0($.data)}}N2.create=($)=>{return new N2({typeName:D.ZodVoid,...l($)})};class y0 extends d{_parse($){let{ctx:f,status:w}=this._processInputParams($),X=this._def;if(f.parsedType!==S.array)return A(f,{code:K.invalid_type,expected:S.array,received:f.parsedType}),I;if(X.exactLength!==null){let W=f.data.length>X.exactLength.value,q=f.data.length<X.exactLength.value;if(W||q)A(f,{code:W?K.too_big:K.too_small,minimum:q?X.exactLength.value:void 0,maximum:W?X.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:X.exactLength.message}),w.dirty()}if(X.minLength!==null){if(f.data.length<X.minLength.value)A(f,{code:K.too_small,minimum:X.minLength.value,type:"array",inclusive:!0,exact:!1,message:X.minLength.message}),w.dirty()}if(X.maxLength!==null){if(f.data.length>X.maxLength.value)A(f,{code:K.too_big,maximum:X.maxLength.value,type:"array",inclusive:!0,exact:!1,message:X.maxLength.message}),w.dirty()}if(f.common.async)return Promise.all([...f.data].map((W,q)=>{return X.type._parseAsync(new g0(f,W,f.path,q))})).then((W)=>{return K0.mergeArray(w,W)});let J=[...f.data].map((W,q)=>{return X.type._parseSync(new g0(f,W,f.path,q))});return K0.mergeArray(w,J)}get element(){return this._def.type}min($,f){return new y0({...this._def,minLength:{value:$,message:C.toString(f)}})}max($,f){return new y0({...this._def,maxLength:{value:$,message:C.toString(f)}})}length($,f){return new y0({...this._def,exactLength:{value:$,message:C.toString(f)}})}nonempty($){return this.min(1,$)}}y0.create=($,f)=>{return new y0({type:$,minLength:null,maxLength:null,exactLength:null,typeName:D.ZodArray,...l(f)})};function y1($){if($ instanceof N0){let f={};for(let w in $.shape){let X=$.shape[w];f[w]=T0.create(y1(X))}return new N0({...$._def,shape:()=>f})}else if($ instanceof y0)return new y0({...$._def,type:y1($.element)});else if($ instanceof T0)return T0.create(y1($.unwrap()));else if($ instanceof i0)return i0.create(y1($.unwrap()));else if($ instanceof c0)return c0.create($.items.map((f)=>y1(f)));else return $}class N0 extends d{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),f=n.objectKeys($);return this._cached={shape:$,keys:f},this._cached}_parse($){if(this._getType($)!==S.object){let Q=this._getOrReturnCtx($);return A(Q,{code:K.invalid_type,expected:S.object,received:Q.parsedType}),I}let{status:w,ctx:X}=this._processInputParams($),{shape:J,keys:W}=this._getCached(),q=[];if(!(this._def.catchall instanceof x0&&this._def.unknownKeys==="strip")){for(let Q in X.data)if(!W.includes(Q))q.push(Q)}let Y=[];for(let Q of W){let _=J[Q],N=X.data[Q];Y.push({key:{status:"valid",value:Q},value:_._parse(new g0(X,N,X.path,Q)),alwaysSet:Q in X.data})}if(this._def.catchall instanceof x0){let Q=this._def.unknownKeys;if(Q==="passthrough")for(let _ of q)Y.push({key:{status:"valid",value:_},value:{status:"valid",value:X.data[_]}});else if(Q==="strict"){if(q.length>0)A(X,{code:K.unrecognized_keys,keys:q}),w.dirty()}else if(Q==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let Q=this._def.catchall;for(let _ of q){let N=X.data[_];Y.push({key:{status:"valid",value:_},value:Q._parse(new g0(X,N,X.path,_)),alwaysSet:_ in X.data})}}if(X.common.async)return Promise.resolve().then(async()=>{let Q=[];for(let _ of Y){let N=await _.key,U=await _.value;Q.push({key:N,value:U,alwaysSet:_.alwaysSet})}return Q}).then((Q)=>{return K0.mergeObjectSync(w,Q)});else return K0.mergeObjectSync(w,Y)}get shape(){return this._def.shape()}strict($){return C.errToObj,new N0({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(f,w)=>{let X=this._def.errorMap?.(f,w).message??w.defaultError;if(f.code==="unrecognized_keys")return{message:C.errToObj($).message??X};return{message:X}}}:{}})}strip(){return new N0({...this._def,unknownKeys:"strip"})}passthrough(){return new N0({...this._def,unknownKeys:"passthrough"})}extend($){return new N0({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new N0({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:D.ZodObject})}setKey($,f){return this.augment({[$]:f})}catchall($){return new N0({...this._def,catchall:$})}pick($){let f={};for(let w of n.objectKeys($))if($[w]&&this.shape[w])f[w]=this.shape[w];return new N0({...this._def,shape:()=>f})}omit($){let f={};for(let w of n.objectKeys(this.shape))if(!$[w])f[w]=this.shape[w];return new N0({...this._def,shape:()=>f})}deepPartial(){return y1(this)}partial($){let f={};for(let w of n.objectKeys(this.shape)){let X=this.shape[w];if($&&!$[w])f[w]=X;else f[w]=X.optional()}return new N0({...this._def,shape:()=>f})}required($){let f={};for(let w of n.objectKeys(this.shape))if($&&!$[w])f[w]=this.shape[w];else{let J=this.shape[w];while(J instanceof T0)J=J._def.innerType;f[w]=J}return new N0({...this._def,shape:()=>f})}keyof(){return c5(n.objectKeys(this.shape))}}N0.create=($,f)=>{return new N0({shape:()=>$,unknownKeys:"strip",catchall:x0.create(),typeName:D.ZodObject,...l(f)})};N0.strictCreate=($,f)=>{return new N0({shape:()=>$,unknownKeys:"strict",catchall:x0.create(),typeName:D.ZodObject,...l(f)})};N0.lazycreate=($,f)=>{return new N0({shape:$,unknownKeys:"strip",catchall:x0.create(),typeName:D.ZodObject,...l(f)})};class I1 extends d{_parse($){let{ctx:f}=this._processInputParams($),w=this._def.options;function X(J){for(let q of J)if(q.result.status==="valid")return q.result;for(let q of J)if(q.result.status==="dirty")return f.common.issues.push(...q.ctx.common.issues),q.result;let W=J.map((q)=>new R0(q.ctx.common.issues));return A(f,{code:K.invalid_union,unionErrors:W}),I}if(f.common.async)return Promise.all(w.map(async(J)=>{let W={...f,common:{...f.common,issues:[]},parent:null};return{result:await J._parseAsync({data:f.data,path:f.path,parent:W}),ctx:W}})).then(X);else{let J=void 0,W=[];for(let Y of w){let Q={...f,common:{...f.common,issues:[]},parent:null},_=Y._parseSync({data:f.data,path:f.path,parent:Q});if(_.status==="valid")return _;else if(_.status==="dirty"&&!J)J={result:_,ctx:Q};if(Q.common.issues.length)W.push(Q.common.issues)}if(J)return f.common.issues.push(...J.ctx.common.issues),J.result;let q=W.map((Y)=>new R0(Y));return A(f,{code:K.invalid_union,unionErrors:q}),I}}get options(){return this._def.options}}I1.create=($,f)=>{return new I1({options:$,typeName:D.ZodUnion,...l(f)})};var r0=($)=>{if($ instanceof D1)return r0($.schema);else if($ instanceof h0)return r0($.innerType());else if($ instanceof E1)return[$.value];else if($ instanceof w1)return $.options;else if($ instanceof Z1)return n.objectValues($.enum);else if($ instanceof x1)return r0($._def.innerType);else if($ instanceof h1)return[void 0];else if($ instanceof j1)return[null];else if($ instanceof T0)return[void 0,...r0($.unwrap())];else if($ instanceof i0)return[null,...r0($.unwrap())];else if($ instanceof p2)return r0($.unwrap());else if($ instanceof u1)return r0($.unwrap());else if($ instanceof c1)return r0($._def.innerType);else return[]};class l2 extends d{_parse($){let{ctx:f}=this._processInputParams($);if(f.parsedType!==S.object)return A(f,{code:K.invalid_type,expected:S.object,received:f.parsedType}),I;let w=this.discriminator,X=f.data[w],J=this.optionsMap.get(X);if(!J)return A(f,{code:K.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[w]}),I;if(f.common.async)return J._parseAsync({data:f.data,path:f.path,parent:f});else return J._parseSync({data:f.data,path:f.path,parent:f})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,f,w){let X=new Map;for(let J of f){let W=r0(J.shape[$]);if(!W.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let q of W){if(X.has(q))throw Error(`Discriminator property ${String($)} has duplicate value ${String(q)}`);X.set(q,J)}}return new l2({typeName:D.ZodDiscriminatedUnion,discriminator:$,options:f,optionsMap:X,...l(w)})}}function I$($,f){let w=Z0($),X=Z0(f);if($===f)return{valid:!0,data:$};else if(w===S.object&&X===S.object){let J=n.objectKeys(f),W=n.objectKeys($).filter((Y)=>J.indexOf(Y)!==-1),q={...$,...f};for(let Y of W){let Q=I$($[Y],f[Y]);if(!Q.valid)return{valid:!1};q[Y]=Q.data}return{valid:!0,data:q}}else if(w===S.array&&X===S.array){if($.length!==f.length)return{valid:!1};let J=[];for(let W=0;W<$.length;W++){let q=$[W],Y=f[W],Q=I$(q,Y);if(!Q.valid)return{valid:!1};J.push(Q.data)}return{valid:!0,data:J}}else if(w===S.date&&X===S.date&&+$===+f)return{valid:!0,data:$};else return{valid:!1}}class V1 extends d{_parse($){let{status:f,ctx:w}=this._processInputParams($),X=(J,W)=>{if(c2(J)||c2(W))return I;let q=I$(J.value,W.value);if(!q.valid)return A(w,{code:K.invalid_intersection_types}),I;if(u2(J)||u2(W))f.dirty();return{status:f.value,value:q.data}};if(w.common.async)return Promise.all([this._def.left._parseAsync({data:w.data,path:w.path,parent:w}),this._def.right._parseAsync({data:w.data,path:w.path,parent:w})]).then(([J,W])=>X(J,W));else return X(this._def.left._parseSync({data:w.data,path:w.path,parent:w}),this._def.right._parseSync({data:w.data,path:w.path,parent:w}))}}V1.create=($,f,w)=>{return new V1({left:$,right:f,typeName:D.ZodIntersection,...l(w)})};class c0 extends d{_parse($){let{status:f,ctx:w}=this._processInputParams($);if(w.parsedType!==S.array)return A(w,{code:K.invalid_type,expected:S.array,received:w.parsedType}),I;if(w.data.length<this._def.items.length)return A(w,{code:K.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),I;if(!this._def.rest&&w.data.length>this._def.items.length)A(w,{code:K.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),f.dirty();let J=[...w.data].map((W,q)=>{let Y=this._def.items[q]||this._def.rest;if(!Y)return null;return Y._parse(new g0(w,W,w.path,q))}).filter((W)=>!!W);if(w.common.async)return Promise.all(J).then((W)=>{return K0.mergeArray(f,W)});else return K0.mergeArray(f,J)}get items(){return this._def.items}rest($){return new c0({...this._def,rest:$})}}c0.create=($,f)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new c0({items:$,typeName:D.ZodTuple,rest:null,...l(f)})};class H2 extends d{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:f,ctx:w}=this._processInputParams($);if(w.parsedType!==S.object)return A(w,{code:K.invalid_type,expected:S.object,received:w.parsedType}),I;let X=[],J=this._def.keyType,W=this._def.valueType;for(let q in w.data)X.push({key:J._parse(new g0(w,q,w.path,q)),value:W._parse(new g0(w,w.data[q],w.path,q)),alwaysSet:q in w.data});if(w.common.async)return K0.mergeObjectAsync(f,X);else return K0.mergeObjectSync(f,X)}get element(){return this._def.valueType}static create($,f,w){if(f instanceof d)return new H2({keyType:$,valueType:f,typeName:D.ZodRecord,...l(w)});return new H2({keyType:C0.create(),valueType:$,typeName:D.ZodRecord,...l(f)})}}class b2 extends d{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:f,ctx:w}=this._processInputParams($);if(w.parsedType!==S.map)return A(w,{code:K.invalid_type,expected:S.map,received:w.parsedType}),I;let X=this._def.keyType,J=this._def.valueType,W=[...w.data.entries()].map(([q,Y],Q)=>{return{key:X._parse(new g0(w,q,w.path,[Q,"key"])),value:J._parse(new g0(w,Y,w.path,[Q,"value"]))}});if(w.common.async){let q=new Map;return Promise.resolve().then(async()=>{for(let Y of W){let Q=await Y.key,_=await Y.value;if(Q.status==="aborted"||_.status==="aborted")return I;if(Q.status==="dirty"||_.status==="dirty")f.dirty();q.set(Q.value,_.value)}return{status:f.value,value:q}})}else{let q=new Map;for(let Y of W){let{key:Q,value:_}=Y;if(Q.status==="aborted"||_.status==="aborted")return I;if(Q.status==="dirty"||_.status==="dirty")f.dirty();q.set(Q.value,_.value)}return{status:f.value,value:q}}}}b2.create=($,f,w)=>{return new b2({valueType:f,keyType:$,typeName:D.ZodMap,...l(w)})};class N1 extends d{_parse($){let{status:f,ctx:w}=this._processInputParams($);if(w.parsedType!==S.set)return A(w,{code:K.invalid_type,expected:S.set,received:w.parsedType}),I;let X=this._def;if(X.minSize!==null){if(w.data.size<X.minSize.value)A(w,{code:K.too_small,minimum:X.minSize.value,type:"set",inclusive:!0,exact:!1,message:X.minSize.message}),f.dirty()}if(X.maxSize!==null){if(w.data.size>X.maxSize.value)A(w,{code:K.too_big,maximum:X.maxSize.value,type:"set",inclusive:!0,exact:!1,message:X.maxSize.message}),f.dirty()}let J=this._def.valueType;function W(Y){let Q=new Set;for(let _ of Y){if(_.status==="aborted")return I;if(_.status==="dirty")f.dirty();Q.add(_.value)}return{status:f.value,value:Q}}let q=[...w.data.values()].map((Y,Q)=>J._parse(new g0(w,Y,w.path,Q)));if(w.common.async)return Promise.all(q).then((Y)=>W(Y));else return W(q)}min($,f){return new N1({...this._def,minSize:{value:$,message:C.toString(f)}})}max($,f){return new N1({...this._def,maxSize:{value:$,message:C.toString(f)}})}size($,f){return this.min($,f).max($,f)}nonempty($){return this.min(1,$)}}N1.create=($,f)=>{return new N1({valueType:$,minSize:null,maxSize:null,typeName:D.ZodSet,...l(f)})};class T1 extends d{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:f}=this._processInputParams($);if(f.parsedType!==S.function)return A(f,{code:K.invalid_type,expected:S.function,received:f.parsedType}),I;function w(q,Y){return G2({data:q,path:f.path,errorMaps:[f.common.contextualErrorMap,f.schemaErrorMap,k1(),p0].filter((Q)=>!!Q),issueData:{code:K.invalid_arguments,argumentsError:Y}})}function X(q,Y){return G2({data:q,path:f.path,errorMaps:[f.common.contextualErrorMap,f.schemaErrorMap,k1(),p0].filter((Q)=>!!Q),issueData:{code:K.invalid_return_type,returnTypeError:Y}})}let J={errorMap:f.common.contextualErrorMap},W=f.data;if(this._def.returns instanceof H1){let q=this;return F0(async function(...Y){let Q=new R0([]),_=await q._def.args.parseAsync(Y,J).catch((B)=>{throw Q.addIssue(w(Y,B)),Q}),N=await Reflect.apply(W,this,_);return await q._def.returns._def.type.parseAsync(N,J).catch((B)=>{throw Q.addIssue(X(N,B)),Q})})}else{let q=this;return F0(function(...Y){let Q=q._def.args.safeParse(Y,J);if(!Q.success)throw new R0([w(Y,Q.error)]);let _=Reflect.apply(W,this,Q.data),N=q._def.returns.safeParse(_,J);if(!N.success)throw new R0([X(_,N.error)]);return N.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new T1({...this._def,args:c0.create($).rest(e0.create())})}returns($){return new T1({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,f,w){return new T1({args:$?$:c0.create([]).rest(e0.create()),returns:f||e0.create(),typeName:D.ZodFunction,...l(w)})}}class D1 extends d{get schema(){return this._def.getter()}_parse($){let{ctx:f}=this._processInputParams($);return this._def.getter()._parse({data:f.data,path:f.path,parent:f})}}D1.create=($,f)=>{return new D1({getter:$,typeName:D.ZodLazy,...l(f)})};class E1 extends d{_parse($){if($.data!==this._def.value){let f=this._getOrReturnCtx($);return A(f,{received:f.data,code:K.invalid_literal,expected:this._def.value}),I}return{status:"valid",value:$.data}}get value(){return this._def.value}}E1.create=($,f)=>{return new E1({value:$,typeName:D.ZodLiteral,...l(f)})};function c5($,f){return new w1({values:$,typeName:D.ZodEnum,...l(f)})}class w1 extends d{_parse($){if(typeof $.data!=="string"){let f=this._getOrReturnCtx($),w=this._def.values;return A(f,{expected:n.joinValues(w),received:f.parsedType,code:K.invalid_type}),I}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let f=this._getOrReturnCtx($),w=this._def.values;return A(f,{received:f.data,code:K.invalid_enum_value,options:w}),I}return F0($.data)}get options(){return this._def.values}get enum(){let $={};for(let f of this._def.values)$[f]=f;return $}get Values(){let $={};for(let f of this._def.values)$[f]=f;return $}get Enum(){let $={};for(let f of this._def.values)$[f]=f;return $}extract($,f=this._def){return w1.create($,{...this._def,...f})}exclude($,f=this._def){return w1.create(this.options.filter((w)=>!$.includes(w)),{...this._def,...f})}}w1.create=c5;class Z1 extends d{_parse($){let f=n.getValidEnumValues(this._def.values),w=this._getOrReturnCtx($);if(w.parsedType!==S.string&&w.parsedType!==S.number){let X=n.objectValues(f);return A(w,{expected:n.joinValues(X),received:w.parsedType,code:K.invalid_type}),I}if(!this._cache)this._cache=new Set(n.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let X=n.objectValues(f);return A(w,{received:w.data,code:K.invalid_enum_value,options:X}),I}return F0($.data)}get enum(){return this._def.values}}Z1.create=($,f)=>{return new Z1({values:$,typeName:D.ZodNativeEnum,...l(f)})};class H1 extends d{unwrap(){return this._def.type}_parse($){let{ctx:f}=this._processInputParams($);if(f.parsedType!==S.promise&&f.common.async===!1)return A(f,{code:K.invalid_type,expected:S.promise,received:f.parsedType}),I;let w=f.parsedType===S.promise?f.data:Promise.resolve(f.data);return F0(w.then((X)=>{return this._def.type.parseAsync(X,{path:f.path,errorMap:f.common.contextualErrorMap})}))}}H1.create=($,f)=>{return new H1({type:$,typeName:D.ZodPromise,...l(f)})};class h0 extends d{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===D.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:f,ctx:w}=this._processInputParams($),X=this._def.effect||null,J={addIssue:(W)=>{if(A(w,W),W.fatal)f.abort();else f.dirty()},get path(){return w.path}};if(J.addIssue=J.addIssue.bind(J),X.type==="preprocess"){let W=X.transform(w.data,J);if(w.common.async)return Promise.resolve(W).then(async(q)=>{if(f.value==="aborted")return I;let Y=await this._def.schema._parseAsync({data:q,path:w.path,parent:w});if(Y.status==="aborted")return I;if(Y.status==="dirty")return Y1(Y.value);if(f.value==="dirty")return Y1(Y.value);return Y});else{if(f.value==="aborted")return I;let q=this._def.schema._parseSync({data:W,path:w.path,parent:w});if(q.status==="aborted")return I;if(q.status==="dirty")return Y1(q.value);if(f.value==="dirty")return Y1(q.value);return q}}if(X.type==="refinement"){let W=(q)=>{let Y=X.refinement(q,J);if(w.common.async)return Promise.resolve(Y);if(Y instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return q};if(w.common.async===!1){let q=this._def.schema._parseSync({data:w.data,path:w.path,parent:w});if(q.status==="aborted")return I;if(q.status==="dirty")f.dirty();return W(q.value),{status:f.value,value:q.value}}else return this._def.schema._parseAsync({data:w.data,path:w.path,parent:w}).then((q)=>{if(q.status==="aborted")return I;if(q.status==="dirty")f.dirty();return W(q.value).then(()=>{return{status:f.value,value:q.value}})})}if(X.type==="transform")if(w.common.async===!1){let W=this._def.schema._parseSync({data:w.data,path:w.path,parent:w});if(!s0(W))return I;let q=X.transform(W.value,J);if(q instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:f.value,value:q}}else return this._def.schema._parseAsync({data:w.data,path:w.path,parent:w}).then((W)=>{if(!s0(W))return I;return Promise.resolve(X.transform(W.value,J)).then((q)=>({status:f.value,value:q}))});n.assertNever(X)}}h0.create=($,f,w)=>{return new h0({schema:$,typeName:D.ZodEffects,effect:f,...l(w)})};h0.createWithPreprocess=($,f,w)=>{return new h0({schema:f,effect:{type:"preprocess",transform:$},typeName:D.ZodEffects,...l(w)})};class T0 extends d{_parse($){if(this._getType($)===S.undefined)return F0(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}T0.create=($,f)=>{return new T0({innerType:$,typeName:D.ZodOptional,...l(f)})};class i0 extends d{_parse($){if(this._getType($)===S.null)return F0(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}i0.create=($,f)=>{return new i0({innerType:$,typeName:D.ZodNullable,...l(f)})};class x1 extends d{_parse($){let{ctx:f}=this._processInputParams($),w=f.data;if(f.parsedType===S.undefined)w=this._def.defaultValue();return this._def.innerType._parse({data:w,path:f.path,parent:f})}removeDefault(){return this._def.innerType}}x1.create=($,f)=>{return new x1({innerType:$,typeName:D.ZodDefault,defaultValue:typeof f.default==="function"?f.default:()=>f.default,...l(f)})};class c1 extends d{_parse($){let{ctx:f}=this._processInputParams($),w={...f,common:{...f.common,issues:[]}},X=this._def.innerType._parse({data:w.data,path:w.path,parent:{...w}});if(C1(X))return X.then((J)=>{return{status:"valid",value:J.status==="valid"?J.value:this._def.catchValue({get error(){return new R0(w.common.issues)},input:w.data})}});else return{status:"valid",value:X.status==="valid"?X.value:this._def.catchValue({get error(){return new R0(w.common.issues)},input:w.data})}}removeCatch(){return this._def.innerType}}c1.create=($,f)=>{return new c1({innerType:$,typeName:D.ZodCatch,catchValue:typeof f.catch==="function"?f.catch:()=>f.catch,...l(f)})};class U2 extends d{_parse($){if(this._getType($)!==S.nan){let w=this._getOrReturnCtx($);return A(w,{code:K.invalid_type,expected:S.nan,received:w.parsedType}),I}return{status:"valid",value:$.data}}}U2.create=($)=>{return new U2({typeName:D.ZodNaN,...l($)})};var O3=Symbol("zod_brand");class p2 extends d{_parse($){let{ctx:f}=this._processInputParams($),w=f.data;return this._def.type._parse({data:w,path:f.path,parent:f})}unwrap(){return this._def.type}}class B2 extends d{_parse($){let{status:f,ctx:w}=this._processInputParams($);if(w.common.async)return(async()=>{let J=await this._def.in._parseAsync({data:w.data,path:w.path,parent:w});if(J.status==="aborted")return I;if(J.status==="dirty")return f.dirty(),Y1(J.value);else return this._def.out._parseAsync({data:J.value,path:w.path,parent:w})})();else{let X=this._def.in._parseSync({data:w.data,path:w.path,parent:w});if(X.status==="aborted")return I;if(X.status==="dirty")return f.dirty(),{status:"dirty",value:X.value};else return this._def.out._parseSync({data:X.value,path:w.path,parent:w})}}static create($,f){return new B2({in:$,out:f,typeName:D.ZodPipeline})}}class u1 extends d{_parse($){let f=this._def.innerType._parse($),w=(X)=>{if(s0(X))X.value=Object.freeze(X.value);return X};return C1(f)?f.then((X)=>w(X)):w(f)}unwrap(){return this._def.innerType}}u1.create=($,f)=>{return new u1({innerType:$,typeName:D.ZodReadonly,...l(f)})};function D5($,f){let w=typeof $==="function"?$(f):typeof $==="string"?{message:$}:$;return typeof w==="string"?{message:w}:w}function u5($,f={},w){if($)return _1.create().superRefine((X,J)=>{let W=$(X);if(W instanceof Promise)return W.then((q)=>{if(!q){let Y=D5(f,X),Q=Y.fatal??w??!0;J.addIssue({code:"custom",...Y,fatal:Q})}});if(!W){let q=D5(f,X),Y=q.fatal??w??!0;J.addIssue({code:"custom",...q,fatal:Y})}return});return _1.create()}var K3={object:N0.lazycreate},D;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(D||(D={}));var F3=($,f={message:`Input not instance of ${$.name}`})=>u5((w)=>w instanceof $,f),l5=C0.create,p5=$1.create,S3=U2.create,z3=f1.create,r5=g1.create,A3=G1.create,R3=_2.create,P3=h1.create,v3=j1.create,m3=_1.create,k3=e0.create,C3=x0.create,y3=N2.create,T3=y0.create,g3=N0.create,h3=N0.strictCreate,j3=I1.create,I3=l2.create,V3=V1.create,D3=c0.create,E3=H2.create,Z3=b2.create,x3=N1.create,c3=T1.create,u3=D1.create,l3=E1.create,p3=w1.create,r3=Z1.create,i3=H1.create,d3=h0.create,o3=T0.create,n3=i0.create,t3=h0.createWithPreprocess,a3=B2.create,s3=()=>l5().optional(),e3=()=>p5().optional(),$w=()=>r5().optional(),fw={string:($)=>C0.create({...$,coerce:!0}),number:($)=>$1.create({...$,coerce:!0}),boolean:($)=>g1.create({...$,coerce:!0}),bigint:($)=>f1.create({...$,coerce:!0}),date:($)=>G1.create({...$,coerce:!0})};var ww=I;var Jw=G.object({before:G.string(),after:G.string(),hierarchy:G.array(G.string()),lineStart:G.number().optional(),lineEnd:G.number().optional()}).passthrough(),Xw=G.object({id:G.string(),name:G.string()}).passthrough(),qw=G.object({url:G.string(),mime:G.string().optional()}).passthrough(),V$=G.object({id:G.string(),snippet:G.string(),note:G.string(),createdAt:G.string(),filePath:G.string().optional(),canvasFile:G.string().optional(),context:Jw.optional(),images:G.array(G.string()).optional(),attachments:G.array(qw).optional(),source:G.enum(["local","remote"]).optional(),author:Xw.optional()}).passthrough(),Ww=G.array(V$.optional().catch(void 0)).transform(($)=>$.filter((f)=>f!==void 0)).catch([]),D$=G.object({annotations:Ww,generalNote:G.string().catch("")}).passthrough(),i5=G.object({path:G.string()}),d5=G.object({url:G.string()});import{useCallback as U1,useMemo as Qw,useState as Yw}from"react";var l1="__agent-response__";function b1($){return $.filePath&&$.filePath!=="__agent-response__"?$.filePath:void 0}function M2($){return $.uploadUrl!==null}function d0(){return`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}function J1($,f){$.style.height="auto",$.style.height=(f?Math.max(f,$.scrollHeight):$.scrollHeight)+"px"}function o5($){let f=$?`[data-annotation-id="${CSS.escape($)}"]`:"[data-annotation-id]";for(let w of document.querySelectorAll(f))if(w.tagName==="MARK"){let X=w.parentNode;w.replaceWith(document.createTextNode(w.textContent||"")),X?.normalize()}else w.remove()}function r2({annotations:$,setAnnotations:f,generalNote:w,setGeneralNote:X,remoteAnnotations:J,isReadOnly:W,onClear:q}){let[Y,Q]=Yw(null),_=Qw(()=>{if(!J?.length)return $;let R=new Set($.map((M)=>M.id)),F=J.filter((M)=>!R.has(M.id));return[...$,...F.map((M)=>({...M,source:"remote"}))]},[$,J]),N=U1((R,F,M,T,h,Z,j)=>{f((E)=>[...E,{id:R,snippet:F,note:M,createdAt:new Date().toISOString(),filePath:T,context:h,...Z?.length?{images:Z}:{},...j?{canvasFile:j}:{}}])},[f]),U=U1((R,F,M)=>{N(d0(),R,F,M)},[N]),B=U1((R,F)=>{f((M)=>M.map((T)=>T.id===R?{...T,note:F}:T))},[f]),H=U1((R)=>{if(!$.some((F)=>F.id===R))return;o5(R),f((F)=>F.filter((M)=>M.id!==R)),Q((F)=>F===R?null:F)},[$,f]),b=U1((R,F)=>{f((M)=>M.map((T)=>T.id===R?{...T,images:[...T.images||[],F]}:T))},[f]),z=U1((R,F)=>{f((M)=>M.map((T)=>T.id===R?{...T,images:(T.images||[]).filter((h)=>h!==F)}:T))},[f]),L=U1(()=>{o5(),f([]),X(""),Q(null),q?.()},[f,X,q]);return{annotations:_,generalNote:w,setGeneralNote:X,activeAnnotationId:Y,setActiveAnnotationId:Q,addAnnotation:U,addAnnotationWithId:N,updateAnnotation:B,removeAnnotation:H,addAnnotationImage:b,removeAnnotationImage:z,clearAll:L,isReadOnly:W}}import{useAnnotations as X1}from"@fabrika/annotations/runtime";import{jsxDEV as iX}from"react/jsx-dev-runtime";import{jsxDEV as B1,Fragment as Gw}from"react/jsx-dev-runtime";function E$({hasContent:$,onSubmit:f,onSubmitEmpty:w,notice:X,secondaryAction:J,placeholder:W="General notes...",submitLabel:q="Submit",emptyLabel:Y="Submit without feedback"}){let{generalNote:Q,setGeneralNote:_}=X1();return B1(Gw,{children:[B1("div",{className:"border-t border-border-subtle px-4 py-3 flex-shrink-0",children:B1("textarea",{value:Q,onChange:(N)=>_(N.currentTarget.value),className:"w-full bg-transparent text-[13px] font-body text-text-primary resize-none leading-relaxed p-0 border-none ring-0 shadow-none outline-none focus:outline-none focus:ring-0 focus:border-none placeholder:text-text-disabled min-h-[40px]",placeholder:W,onInput:(N)=>J1(N.currentTarget,40),ref:(N)=>{if(N)J1(N,40)}},void 0,!1,void 0,this)},void 0,!1,void 0,this),X,B1("div",{className:"px-4 py-3 border-t border-border-subtle flex-shrink-0",children:$?B1("div",{className:"flex gap-2",children:[J,B1("button",{onClick:f,className:"flex-1 py-2 rounded-lg font-body text-[13px] font-medium transition-all bg-btn-primary text-btn-primary-text hover:opacity-90 hover:-translate-y-px shadow-sm",children:q},void 0,!1,void 0,this)]},void 0,!0,void 0,this):B1("button",{onClick:w,className:"w-full py-2 rounded-lg font-body text-[13px] font-medium border border-border-medium text-text-secondary hover:text-text-primary hover:border-border-hover hover:bg-bg-input transition-all",children:Y},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useAnnotationHost as _w}from"@fabrika/annotations/runtime";import{useCallback as o0,useEffect as Nw,useRef as Z$,useState as x$}from"react";import{jsxDEV as M0}from"react/jsx-dev-runtime";function c$($){if($.startsWith("/s/")||$.startsWith("http://")||$.startsWith("https://"))return $;return`/api/uploads/${$.split("/").pop()}`}async function Hw($,f){let w=$.uploadUrl;if(!w)return null;let X=new FormData;X.append("image",f);try{let W=await(await fetch(w(),{method:"POST",body:X})).json();if($.isShared)return d5.parse(W).url||null;return i5.parse(W).path||null}catch{return null}}function p1({note:$,onNoteChange:f,images:w,onAddImage:X,onRemoveImage:J,sessionId:W,placeholder:q="Add your note...",autoFocus:Y=!1,autoResize:Q=!1,readOnly:_=!1,onKeyDown:N,onTextareaClick:U,textareaRef:B,textareaClassName:H,textareaStyle:b,minHeight:z,attachButton:L="always",openFilePickerRef:R}){let F=_w(),M=!_&&M2(F),[T,h]=x$(!1),[Z,j]=x$(!1),[E,u]=x$(!1),x=Z$(0),e=Z$(null),J0=Z$(null),W0=o0(()=>J0.current?.click(),[]);if(R)R.current=W0;let O0=o0((O)=>{if(e.current=O,B)B.current=O;if(O&&Q)J1(O,z)},[B,Q,z]);Nw(()=>{if(Y&&e.current){let O=e.current;if(O.focus(),O.value)O.setSelectionRange(O.value.length,O.value.length)}},[Y]);let c=o0(async(O)=>{if(!O.type.startsWith("image/"))return;j(!0);try{let v=await Hw(F,O);if(v)X(v)}finally{j(!1)}},[F,X]),$0=o0((O)=>{for(let v of O.clipboardData?.items??[])if(v.type.startsWith("image/")){O.preventDefault();let o=v.getAsFile();if(o)c(o);return}},[c]),f0=o0((O)=>{if(O.preventDefault(),x.current++,x.current===1)h(!0)},[]),Q0=o0((O)=>{O.preventDefault()},[]),s=o0((O)=>{if(O.preventDefault(),x.current--,x.current===0)h(!1)},[]),w0=o0((O)=>{O.preventDefault(),x.current=0,h(!1);for(let v of O.dataTransfer?.files??[])if(v.type.startsWith("image/"))c(v)},[c]),_0=o0((O)=>{if(f(O.currentTarget.value),Q)O.currentTarget.style.height="auto",O.currentTarget.style.height=(z?Math.max(z,O.currentTarget.scrollHeight):O.currentTarget.scrollHeight)+"px"},[f,Q,z]),P="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",g={width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",outline:"none",...Q?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},p=M&&(L==="always"||L==="on-focus"&&E);return M0("div",{style:{position:"relative"},onDragEnter:M?f0:void 0,onDragOver:M?Q0:void 0,onDragLeave:M?s:void 0,onDrop:M?w0:void 0,children:[M0("textarea",{ref:O0,value:$,onChange:_?void 0:_0,onPaste:M?$0:void 0,onKeyDown:N,onClick:U,onFocus:()=>u(!0),onBlur:()=>{setTimeout(()=>u(!1),150)},readOnly:_,placeholder:q,className:H??P,style:b??g,rows:Q?1:void 0},void 0,!1,void 0,this),M&&M0("input",{ref:J0,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:(O)=>{let v=O.currentTarget.files;if(v)for(let o of v)c(o);O.currentTarget.value=""}},void 0,!1,void 0,this),(w.length>0||p)&&M0("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[w.map((O)=>M0("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[M0("img",{src:c$(O),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!_&&M0("button",{onClick:(v)=>{v.stopPropagation(),J(O)},style:{position:"absolute",top:"2px",right:"2px",width:"16px",height:"16px",borderRadius:"50%",background:"rgba(0,0,0,0.6)",color:"white",border:"none",cursor:"pointer",fontSize:"11px",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0},title:"Remove image",children:"×"},void 0,!1,void 0,this)]},O,!0,void 0,this)),p&&M0(i2,{onClick:W0},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z&&M0("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),T&&M0("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-highlight-bg)",opacity:0.9,border:"2px dashed var(--color-highlight-border)",borderRadius:"6px",zIndex:10,pointerEvents:"none",fontSize:"12px",fontFamily:"'Inter', sans-serif",color:"var(--color-text-secondary)"},children:"Drop image"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function i2({onClick:$,size:f=16}){return M0("button",{onClick:(w)=>{w.stopPropagation(),$()},style:{width:`${f*2}px`,height:`${f*2}px`,borderRadius:"6px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",flexShrink:0,transition:"color 0.15s"},title:"Attach image",onMouseEnter:(w)=>{w.currentTarget.style.color="var(--color-text-secondary)"},onMouseLeave:(w)=>{w.currentTarget.style.color="var(--color-text-tertiary)"},children:M0("svg",{width:f,height:f,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[M0("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),M0("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),M0("polyline",{points:"21 15 16 10 5 21"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function u$({images:$}){if(!$.length)return null;return M0("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px"},children:$.map((f)=>M0("div",{style:{width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:M0("img",{src:c$(f),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this)},f,!1,void 0,this))},void 0,!1,void 0,this)}import{SessionContext as bw}from"@fabrika/annotations/runtime";import{useContext as Uw,useEffect as Bw,useRef as Mw}from"react";import{jsxDEV as H0,Fragment as n5}from"react/jsx-dev-runtime";function Lw($){let f=Y2($);return f.length>80?f.slice(0,80)+"...":f}function L2({annotations:$,readOnly:f=!1,onSelect:w,onReveal:X,includedRemoteIds:J,onToggleRemoteId:W}){let{updateAnnotation:q,removeAnnotation:Y,addAnnotationImage:Q,removeAnnotationImage:_,activeAnnotationId:N,setActiveAnnotationId:U}=X1(),B=Uw(bw),H=Mw(new Map);Bw(()=>{if(f||!N)return;let M=H.current.get(N);if(M)M.scrollIntoView({behavior:"smooth",block:"nearest"})},[N,f]);let b=(M)=>{U(M),v1(M,!0)},z=(M)=>{U(null),v1(M,!1)},L=(M)=>{if(M.id===N){U(null);return}U(M.id),w?.(M)},R=!!J&&!!W,F=(M)=>{let T=R&&M.source==="remote";return H0("div",{ref:(h)=>{if(h)H.current.set(M.id,h);else H.current.delete(M.id)},className:`group/ann relative px-3 py-2.5 transition-colors duration-150 ${f?"cursor-pointer ":""}${N===M.id?"bg-highlight-selected":T?"bg-accent-purple-muted/30 hover:bg-accent-purple-muted/50":"odd:bg-bg-elevated-half hover:bg-bg-input"}`,onMouseEnter:()=>b(M.id),onMouseLeave:()=>z(M.id),onClick:()=>L(M),children:[T&&M.author&&H0("div",{className:"flex items-center gap-1.5 mb-1.5",children:[H0("input",{type:"checkbox",checked:J.has(M.id),onChange:(h)=>{h.stopPropagation(),W(M.id)},onClick:(h)=>h.stopPropagation(),className:"accent-accent-purple flex-shrink-0",title:"Include in submission"},void 0,!1,void 0,this),H0("span",{className:"inline-flex items-center justify-center w-4 h-4 rounded-full bg-accent-purple text-white text-[9px] font-medium uppercase",children:M.author.name.charAt(0)},void 0,!1,void 0,this),H0("span",{className:"text-[11px] font-medium text-accent-purple font-body",children:M.author.name},void 0,!1,void 0,this),H0("span",{className:"text-[10px] text-text-tertiary font-body uppercase tracking-widest",children:"Remote"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H0("div",{className:"text-[11px] text-text-tertiary italic line-clamp-2 mb-1.5 leading-snug font-body border-l-2 border-border-medium pl-2",children:Lw(M.snippet)},void 0,!1,void 0,this),f?H0(n5,{children:[M.note.trim()&&H0("div",{className:"text-[13px] font-body text-text-primary leading-relaxed",children:M.note},void 0,!1,void 0,this),H0(u$,{images:M.images||[]},void 0,!1,void 0,this)]},void 0,!0,void 0,this):T?H0("div",{className:"text-[13px] font-body text-text-primary leading-relaxed whitespace-pre-wrap",children:M.note},void 0,!1,void 0,this):H0("div",{onClick:(h)=>h.stopPropagation(),children:H0(p1,{note:M.note,onNoteChange:(h)=>q(M.id,h),images:M.images||[],onAddImage:(h)=>Q(M.id,h),onRemoveImage:(h)=>_(M.id,h),sessionId:B,autoResize:!0,minHeight:20,textareaClassName:"w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none min-h-[20px]",textareaStyle:{height:"auto",overflow:"hidden"},placeholder:"Add your note...",attachButton:"on-focus"},void 0,!1,void 0,this)},void 0,!1,void 0,this),H0("div",{className:"absolute top-1.5 right-1.5 opacity-0 group-hover/ann:opacity-100 transition-opacity duration-100 flex items-center gap-0.5",children:[X&&H0("button",{onClick:(h)=>{h.stopPropagation(),X(M)},className:"w-5 h-5 flex items-center justify-center rounded text-text-tertiary hover:text-text-secondary hover:bg-bg-input transition-colors",title:"Scroll to annotation",children:H0("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[H0("circle",{cx:"12",cy:"12",r:"3"},void 0,!1,void 0,this),H0("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),!f&&!T&&H0("button",{onClick:(h)=>{h.stopPropagation(),Y(M.id)},className:"w-5 h-5 flex items-center justify-center rounded text-text-tertiary hover:text-accent-red hover:bg-accent-red-muted transition-colors",title:"Delete annotation",children:H0("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[H0("polyline",{points:"3 6 5 6 21 6"},void 0,!1,void 0,this),H0("path",{d:"M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},M.id,!0,void 0,this)};return H0(n5,{children:$.map(F)},void 0,!1,void 0,this)}function O2($){let f=[],w=$.snippet.trim(),X=$.context,J=Y2(w);if(J!==w)f.push(`> ${J}`);else if($.filePath&&X&&X.lineStart!=null){let Y=X.lineStart,Q=X.lineEnd??Y,_=w.split(`
|
|
2
|
-
`);if(w.length<30&&Y===Q&&(X.before||X.after)){let U=g2($);f.push(`> L${Y}: ${U}`)}else if(_.length<=6)for(let U=0;U<_.length;U++)f.push(`> ${Y+U} | ${_[U]}`);else{for(let U=0;U<3;U++)f.push(`> ${Y+U} | ${_[U]}`);f.push(`> ... (${_.length} lines)`);for(let U=_.length-3;U<_.length;U++)f.push(`> ${Y+U} | ${_[U]}`)}}else{let Y=g2($);if(w.split(`
|
|
3
|
-
`).length<=3)f.push(`> ${Y.split(`
|
|
4
|
-
`).join(`
|
|
5
|
-
> `)}`);else{let Q=w.split(`
|
|
6
|
-
`);f.push(`> ${Q[0]}`),f.push(`> ... (${Q.length} lines)`),f.push(`> ${Q[Q.length-1]}`)}}if($.note.trim())f.push(""),f.push($.note.trim());let W=[...$.images??[]],q=new Set(W);for(let Y of $.attachments??[]){if(q.has(Y.url))continue;q.add(Y.url),W.push(Y.url)}if(W.length){f.push("");for(let Y of W)f.push(``)}return f.push(""),f.join(`
|
|
7
|
-
`)}import{SessionContext as Ow,useAnnotationHost as Kw}from"@fabrika/annotations/runtime";import{useCallback as d2,useContext as Fw,useEffect as Sw,useMemo as s5,useRef as o2,useState as r1}from"react";import{createPortal as zw}from"react-dom";function t5($){let f=/^(\d+(?:\.\d+)?)px$/.exec($.trim());return f?Number(f[1]):void 0}function a5($,f,w=280){let J=f||document.body,W=$.getBoundingClientRect(),q=J.getBoundingClientRect(),Y=J===document.body?0:J.scrollTop,Q=W.bottom-q.top+Y+8,_=Math.max(0,Math.min(W.left-q.left,q.width-w-12));return J.style.position="relative",{style:{position:"absolute",top:`${Q}px`,left:`${_}px`},parent:J}}import{jsxDEV as L0,Fragment as Aw}from"react/jsx-dev-runtime";function $f({anchorEl:$,scrollContainer:f,onClose:w,ignoreSelector:X,zIndex:J="50",padding:W="12px",width:q="280px",children:Y}){let Q=o2(null),_=o2(w);_.current=w;let{style:N,parent:U}=a5($,f,t5(q));return Sw(()=>{let B=setTimeout(()=>{let H=(b)=>{if(Q.current&&!Q.current.contains(b.target)){if(X&&b.target.closest?.(X))return;_.current(),document.removeEventListener("mousedown",H)}};return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},0);return()=>clearTimeout(B)},[X]),zw(L0("div",{ref:Q,style:{...N,zIndex:J,width:q,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:W,fontFamily:"'Inter', sans-serif"},children:Y},void 0,!1,void 0,this),U)}var ff=[{label:"Clarity",items:["Unclear","Why?","Needs example","Missing context"]},{label:"Scope",items:["Overkill","Out of scope","Important","Risky"]},{label:"Action",items:["Simplify","Rethink","Expand on this","Skip this"]}],e5=ff.flatMap(($)=>$.items);function l$({anchorEl:$,scrollContainer:f,snippet:w,truncateAt:X=100,header:J,initialNote:W="",initialImages:q,onConfirm:Y,onCancel:Q,onDelete:_}){let N=Fw(Ow),U=Kw(),B=M2(U),H=W!==""||!!_,[b,z]=r1(W),[L,R]=r1(q||[]),[F,M]=r1(null),[T,h]=r1(H),[Z,j]=r1(!1),E=o2(null),u=o2(null),x=d2(()=>{if(b.trim()||L.length>0)Y(b.trim(),L);else if(H&&_)_();else Q()},[b,L,Y,Q,H,_]),e=d2(()=>{if(H){if(!b.trim()&&L.length===0&&_){_(),Q();return}Y(b,L);return}Q()},[b,L,H,Y,Q,_]),J0=!H,W0=b.trim().length>0?e5.filter((k)=>k.toLowerCase().startsWith(b.trim().toLowerCase())):e5,O0=!J0||T?[]:W0.length===1&&W0[0]?.toLowerCase()===b.trim().toLowerCase()?[]:W0,c=new Set(O0),$0=ff.map((k)=>({label:k.label,items:k.items.filter((V)=>c.has(V))})).filter((k)=>k.items.length>0),f0=$0.map((k)=>k.items),Q0=(k)=>f0[k]?.length??0,s=f0.flat(),w0=s5(()=>{if(F===null)return 0;let k=0;for(let V=0;V<f0.length;V++){if(F<k+Q0(V))return V;k+=Q0(V)}return 0},[F,f0]),_0=s5(()=>{if(F===null)return 0;let k=0;for(let V=0;V<w0;V++)k+=Q0(V);return F-k},[F,w0,f0]),P=(k,V)=>{let r=0;for(let Y0=0;Y0<k;Y0++)r+=Q0(Y0);return r+V},[g,p]=r1(b);if(b!==g)p(b),M(null),h(H);let O=d2((k)=>{z(k)},[]),v=w.length>X?w.slice(0,X)+"...":w,o=d2((k)=>{if(s.length>0&&(k.key==="ArrowDown"||k.key==="ArrowUp"||k.key==="ArrowLeft"||k.key==="ArrowRight")){if(k.preventDefault(),F===null){M(0);return}if(k.key==="ArrowDown"){let r=Math.min(_0+1,Q0(w0)-1);M(P(w0,r))}else if(k.key==="ArrowUp"){let r=Math.max(_0-1,0);M(P(w0,r))}else if(k.key==="ArrowRight"){let r=Math.min(w0+1,f0.length-1),Y0=Math.min(_0,Q0(r)-1);M(P(r,Y0))}else if(k.key==="ArrowLeft"){let r=Math.max(w0-1,0),Y0=Math.min(_0,Q0(r)-1);M(P(r,Y0))}return}let V=F===null?void 0:s[F];if(V!==void 0){if(k.key==="Tab"){k.preventDefault(),O(V);return}if(k.key==="Enter"&&!k.shiftKey){k.preventDefault(),Y(V,L);return}}if(k.key==="Enter"&&!k.shiftKey){k.preventDefault(),x();return}if(k.key==="Escape")if(s.length>0&&!T)h(!0);else if(H)e();else Q()},[s,F,_0,w0,f0,P,O,Y,L,x,T,H,e,Q]);return L0($f,{anchorEl:$,scrollContainer:f,onClose:H?e:Q,ignoreSelector:H?"[data-annotation-id]":void 0,zIndex:H?"60":"50",padding:H?"10px 12px":"12px",width:"420px",children:[!H&&(J??L0("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontStyle:"italic",marginBottom:"8px",lineHeight:"1.4",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:["“",v,"”"]},void 0,!0,void 0,this)),L0(p1,{note:b,onNoteChange:z,images:L,onAddImage:(k)=>R((V)=>[...V,k]),onRemoveImage:(k)=>R((V)=>V.filter((r)=>r!==k)),sessionId:N,autoFocus:!0,autoResize:H,textareaRef:E,onKeyDown:o,attachButton:"none",openFilePickerRef:u,textareaStyle:H?{width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"none",outline:"none",overflow:"hidden"}:{width:"100%",minHeight:"60px",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"vertical",outline:"none"},placeholder:"Add your note..."},void 0,!1,void 0,this),L0("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:H?"6px":"8px"},children:[B&&L0(i2,{onClick:()=>u.current?.(),size:14},void 0,!1,void 0,this),L0("div",{style:{flex:1}},void 0,!1,void 0,this),H?L0("button",{onClick:()=>{if(_)_();Q()},onMouseEnter:()=>j(!0),onMouseLeave:()=>j(!1),style:{fontSize:"11px",color:Z?"var(--color-accent-red)":"var(--color-text-tertiary)",background:"none",border:"none",cursor:"pointer",padding:"2px 0",fontFamily:"'Inter', sans-serif"},children:"Delete"},void 0,!1,void 0,this):L0(Aw,{children:[L0("button",{onClick:Q,style:{fontSize:"11px",color:"var(--color-text-tertiary)",background:"none",border:"none",cursor:"pointer",padding:"4px 12px",fontFamily:"'Inter', sans-serif"},children:"Cancel"},void 0,!1,void 0,this),L0("button",{onClick:x,style:{fontSize:"11px",fontWeight:500,padding:"4px 12px",borderRadius:"6px",background:"var(--color-highlight-bg)",color:"var(--color-text-primary)",border:"1px solid var(--color-highlight-border)",cursor:"pointer",fontFamily:"'Inter', sans-serif"},children:"Add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),s.length>0&&L0("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:$0.map((k)=>L0("div",{style:{flex:1},children:[L0("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--color-text-disabled)",textTransform:"uppercase",letterSpacing:"0.05em",padding:"2px 6px",marginBottom:"2px",fontFamily:"'Inter', sans-serif"},children:k.label},void 0,!1,void 0,this),k.items.map((V)=>{let r=s.indexOf(V);return L0("div",{onMouseDown:(Y0)=>{Y0.preventDefault(),Y0.stopPropagation(),O(V)},onMouseEnter:()=>M(r),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:r===F?"var(--color-text-primary)":"var(--color-text-secondary)",background:r===F?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[L0("span",{style:{fontWeight:500},children:V.slice(0,b.trim().length)},void 0,!1,void 0,this),V.slice(b.trim().length)]},V,!0,void 0,this)})]},k.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function q1({anchorEl:$,scrollContainer:f,snippet:w,truncateAt:X,header:J,onAdd:W,onCancel:q}){return L0(l$,{anchorEl:$,scrollContainer:f,snippet:w,truncateAt:X,header:J,onConfirm:(Y,Q)=>W(Y,Q),onCancel:q},void 0,!1,void 0,this)}function K2({anchorEl:$,scrollContainer:f,initialNote:w,initialImages:X,onUpdate:J,onDelete:W,onClose:q}){return L0(l$,{anchorEl:$,scrollContainer:f,snippet:"",initialNote:w,initialImages:X,onConfirm:(Y,Q)=>{J(Y,Q),q()},onDelete:W,onCancel:q},void 0,!1,void 0,this)}import{useEffect as Rw,useRef as p$,useState as wf}from"react";import{jsxDEV as Pw}from"react/jsx-dev-runtime";function r$($){let{containerRef:f,restoreKey:w,shape:X="rect",canvasFile:J,scrollContainer:W}=$,{addAnnotationWithId:q}=X1(),[Y,Q]=wf(null),[_,N]=wf(!1),U=p$(q);U.current=q;let B=p$(J);B.current=J;let H=p$(X);return H.current=X,Rw(()=>{let z=f.current;if(!z)return;let L=null;function R(j,E){let u=j.getBoundingClientRect();return k$(u,E.clientX-u.left,E.clientY-u.top)}function F(){if(!L)return;let{host:j,pointerId:E}=L;if(j.hasPointerCapture(E))j.releasePointerCapture(E);j.removeEventListener("pointermove",T),j.removeEventListener("pointerup",h),j.removeEventListener("pointercancel",Z),L=null,N(!1)}function M(j){if(L||j.button!==0)return;let E=j.target;if(!(E instanceof Element))return;if(E.closest("[data-block-comment-btn]"))return;if(E.closest("[data-annotation-id]"))return;let u=E.closest(`[${m$}]`);if(!(u instanceof HTMLElement)||!z?.contains(u))return;let x=u.closest("[data-md='image']")?.getAttribute("data-md-src");if(!x)return;let e=R(u,j);if(!e)return;j.preventDefault(),u.setPointerCapture(j.pointerId);let J0=d0(),W0=Z2({...e,w:0,h:0},H.current,J0);W0.classList.add("ann-region-draft"),u.appendChild(W0),L={pointerId:j.pointerId,host:u,src:x,start:e,shape:H.current,overlay:W0,id:J0},u.addEventListener("pointermove",T),u.addEventListener("pointerup",h),u.addEventListener("pointercancel",Z),N(!0)}function T(j){if(!L||L.pointerId!==j.pointerId)return;let E=R(L.host,j);if(!E)return;E2(L.overlay,V2(L.start,E))}function h(j){if(!L||L.pointerId!==j.pointerId)return;let{overlay:E,id:u,src:x,shape:e}=L,J0=R(L.host,j)??L.start,W0=V2(L.start,J0);if(F(),!C$(W0)){E.remove();return}E2(E,W0);let O0={src:x,shape:e,...W0};Q({overlay:E,id:u,snippet:Q2.format(O0),label:D2(O0)})}function Z(j){if(!L||L.pointerId!==j.pointerId)return;L.overlay.remove(),F()}return z.addEventListener("pointerdown",M),()=>{if(z.removeEventListener("pointerdown",M),L)L.overlay.remove(),F()}},[w]),{popovers:Y?Pw(q1,{anchorEl:Y.overlay,scrollContainer:W,snippet:Y.label,truncateAt:80,onAdd:(z,L)=>{Y.overlay.classList.remove("ann-region-draft"),U.current(Y.id,Y.snippet,z,void 0,void 0,L,B.current),Q(null)},onCancel:()=>{Y.overlay.remove(),Q(null)}},void 0,!1,void 0,this):null,isDrawing:_,isPopoverOpen:!!Y}}import{useCallback as Jf,useEffect as n2,useRef as M1,useState as Xf}from"react";import{jsxDEV as i$,Fragment as vw}from"react/jsx-dev-runtime";function d$($){let{containerRef:f,restoreKey:w,restoreAnnotations:X,extractContext:J,filePath:W,canvasFile:q,scrollContainer:Y}=$,{annotations:Q,addAnnotationWithId:_,removeAnnotation:N,updateAnnotation:U,addAnnotationImage:B,removeAnnotationImage:H,activeAnnotationId:b,setActiveAnnotationId:z}=X1(),[L,R]=Xf(null),[F,M]=Xf(null),T=M1(J);T.current=J;let h=M1(W);h.current=W;let Z=M1(q);Z.current=q;let j=M1(_);j.current=_;let E=M1(b);E.current=b;let u=M1(z);u.current=z;let x=X.length;n2(()=>{if(!f.current)return;let c=setTimeout(()=>{if(f.current)g$(f.current,X)},50);return()=>clearTimeout(c)},[w,x]);let e=M1(null);n2(()=>{K$(b,e.current),e.current=b},[b]),n2(()=>{let c=f.current;if(!c)return;let $0=(s)=>{let w0=s.target.closest("[data-annotation-id]");if(!w0)return;s.stopPropagation();let _0=w0.getAttribute("data-annotation-id");if(_0===E.current)R({anchorEl:w0,annId:_0});else u.current(_0)},f0=(s)=>{let w0=s.target.closest("[data-annotation-id]");if(w0)u.current(w0.getAttribute("data-annotation-id"))},Q0=(s)=>{let w0=s.target.closest("[data-annotation-id]"),_0=s.relatedTarget?.closest?.("[data-annotation-id]");if(w0&&!_0&&!document.getElementById("ann-inline-popover"))u.current(null)};return c.addEventListener("click",$0),c.addEventListener("mouseover",f0),c.addEventListener("mouseout",Q0),()=>{c.removeEventListener("click",$0),c.removeEventListener("mouseover",f0),c.removeEventListener("mouseout",Q0)}},[w]),n2(()=>{let c=()=>J0();return document.addEventListener("mouseup",c),()=>document.removeEventListener("mouseup",c)},[]);let J0=Jf(()=>{let c=window.getSelection();if(!c||c.isCollapsed||!c.toString().trim())return;if(!f.current)return;let $0=c.getRangeAt(0);if(!f.current.contains($0.startContainer))return;if($0.startContainer.parentElement?.closest?.("[data-annotation-id]"))return;let f0=y5($0).trim();if(f0.length<2)return;let Q0=T.current($0),s=$0.cloneRange(),w0=`__pending_${Date.now()}`;try{T2(s,w0)}catch{}window.getSelection()?.removeAllRanges();let _0=document.querySelectorAll(`[data-annotation-id="${w0}"]`),P=_0[_0.length-1];if(!P)return;M({anchorEl:P,tempId:w0,snippet:f0,ctx:Q0})},[]),W0=Jf((c,$0,f0,Q0)=>{M({anchorEl:c,tempId:$0,snippet:f0,ctx:Q0})},[]);return{popovers:i$(vw,{children:[L&&(()=>{let c=Q.find(($0)=>$0.id===L.annId);if(!c)return null;return i$(K2,{anchorEl:L.anchorEl,scrollContainer:Y,initialNote:c.note,initialImages:c.images,onUpdate:($0,f0)=>{U(L.annId,$0);let Q0=c.images||[];for(let s of f0)if(!Q0.includes(s))B(L.annId,s);for(let s of Q0)if(!f0.includes(s))H(L.annId,s)},onDelete:()=>{N(L.annId),z(null)},onClose:()=>R(null)},void 0,!1,void 0,this)})(),F&&i$(q1,{anchorEl:F.anchorEl,scrollContainer:Y,snippet:F.snippet,truncateAt:80,onAdd:(c,$0)=>{let f0=d0();F$(F.tempId,f0),j.current(f0,F.snippet,c,h.current,F.ctx,$0,Z.current),M(null)},onCancel:()=>{z$(F.tempId),M(null)}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),openCreatePopover:W0,isPopoverOpen:!!(L||F)}}import{AnnotationCtx as gw}from"#canvas/runtime";import{AnnotationCtx as hw,AnnotationHostContext as jw}from"@fabrika/annotations/runtime";import{useCallback as n1,useEffect as bf,useMemo as Iw,useRef as a$,useState as t1}from"react";var L7=G.object({}).passthrough(),O7=G.object({annotations:G.array(G.unknown()).catch([]),generalNote:G.string().catch(""),responses:G.array(G.unknown()).catch([])}),K7=G.tuple([G.unknown(),G.object({note:G.unknown(),value:G.unknown()})]);function L1($,f,w="current"){let X=`canvas:${$}:rev:${f}`;return w==="next"?`${X}:next-draft`:X}function mw($,f){return`${L1($,f)}:draft-handled`}function o$($,f,w){try{$.removeItem(L1(f,w)),$.removeItem(mw(f,w))}catch{}}function n$($,f){let w=new Map;for(let[X,J]of $)if(f.has(X))w.set(X,J);return w}function t$($,f){if(!$||$.length===0)return!1;return $.every((w)=>f.has(w))}function i1($,f,w,X,J){let W=[],q=$.filter((H)=>H.source!=="remote"||J&&J.has(H.id)),Y=q.filter((H)=>H.filePath===l1),Q=q.filter((H)=>!H.filePath),_=q.filter((H)=>H.filePath&&H.filePath!==l1),N=w?Array.from(w.values()).filter((H)=>t2(H)):[],U=X?Array.from(X.values()).filter((H)=>H.markdown.trim()):[];if(N.length>0||U.length>0){W.push("## Responses"),W.push("");for(let H of N)W.push(kw(H));for(let H of U)W.push(H.markdown.trim()),W.push("")}if(Y.length>0){W.push("## Annotations on agent response"),W.push("");for(let H of Y)W.push(O2(H))}if(Q.length>0){W.push("## Canvas annotations"),W.push("");let H=new Map;for(let L of Q){let R=L.canvasFile||"";if(!H.has(R))H.set(R,[]);H.get(R).push(L)}let b=[...H.keys()].sort(),z=b.length>1||b.length===1&&b[0]!=="";for(let L of b){let R=H.get(L);if(z&&L)W.push(`### ${L.replace(/\.jsx$/,"")}`),W.push("");let F=Cw(R);W.push(Qf(F))}}if(_.length>0){let H={};for(let b of _){let z=b.filePath;if(!H[z])H[z]=[];H[z].push(b)}W.push("## File annotations"),W.push("");for(let[b,z]of Object.entries(H)){W.push(`### ${b}`),W.push("");for(let L of z)W.push(O2(L))}}if(f.trim())W.push("## General notes"),W.push(""),W.push(f.trim()),W.push("");return W.join(`
|
|
8
|
-
`).trim()+`
|
|
9
|
-
`}function t2($){if($.note?.trim())return!0;if($.value===null||$.value===void 0)return!1;if($.type==="text"&&!$.value.trim())return!1;if($.type==="checkbox"&&$.value.length===0)return!1;return!0}function qf($){let f=[];for(let w of $.values()){if(!w.required)continue;if(w.value===null||w.value===void 0){f.push(w);continue}if(w.type==="text"&&!w.value.trim()){f.push(w);continue}if(w.type==="checkbox"&&w.value.length===0){f.push(w);continue}}return f}function Wf($){let f=[];for(let w of $.values())if(w.required&&!w.markdown.trim())f.push(w);return f}function d1($,f){let w=qf($),X=Wf(f);return[...w.map((J)=>J.label),...X.map((J)=>J.label||J.id)]}function kw($){let f=[];switch(f.push(`**${$.label}**`),$.type){case"radio":case"select":f.push(`Answer: ${$.value}`);break;case"checkbox":for(let w of $.value)f.push(`- [x] ${w}`);break;case"text":f.push(""),f.push($.value.trim());break;case"range":f.push(`Answer: ${$.value}`);break}if($.note?.trim())f.push(""),f.push(`Note: ${$.note.trim()}`);return f.push(""),f.join(`
|
|
10
|
-
`)}function Cw($){let f={label:"",annotations:[],children:new Map};for(let w of $){let X=w.context?.hierarchy||[],J=f;for(let W of X){if(!J.children.has(W))J.children.set(W,{label:W,annotations:[],children:new Map});J=J.children.get(W)}J.annotations.push(w)}return f}function Qf($,f=0){let w=[];for(let X of $.annotations)w.push(O2(X));for(let[,X]of $.children){let J=f===0?"###":"####";w.push(`${J} ${X.label}`),w.push(""),w.push(Qf(X,f+1))}return w.join(`
|
|
11
|
-
`)}import{createContext as yw,useContext as Tw}from"react";function Yf(){if(typeof window>"u")return"";return window.location.pathname.replace("/s/","")}var Gf={get sessionId(){return Yf()},isShared:!1,fsAvailable:!0,uploadUrl:null,loadCanvasModule:($,f)=>{let w=$.replace(/\.jsx$/,".js"),X=f?`?rev=${f}&t=${Date.now()}`:`?t=${Date.now()}`;return import(`/api/session/${Yf()}/canvas/${encodeURIComponent(w)}${X}`)}},_f=yw(Gf);function n0(){return Tw(_f)}var a2=G.object({id:G.string(),type:G.enum(["select","radio","checkbox","text","range"]),label:G.string(),value:G.unknown(),options:G.array(G.string()).optional(),required:G.boolean().optional(),note:G.string().optional()}).passthrough().transform(($)=>({...$,value:$.value})),s2=G.object({id:G.string(),markdown:G.string(),label:G.string().optional(),required:G.boolean().optional()}).passthrough(),e2=D$.extend({responses:G.array(G.tuple([G.string(),a2]).optional().catch(void 0)).transform(($)=>$.filter((f)=>f!==void 0)).catch([]),feedbackEntries:G.array(G.tuple([G.string(),s2]).optional().catch(void 0)).transform(($)=>$.filter((f)=>f!==void 0)).optional().catch([])});function o1($){let f=e2.safeParse($);return f.success?f.data:null}var Nf=G.object({feedback:G.string().nullish()}),Hf=G.union([G.object({error:G.string().min(1)}),G.object({content:G.string(),language:G.string().nullish()})]);import{useAnnotations as O1}from"#canvas/runtime";import{jsxDEV as e$}from"react/jsx-dev-runtime";function Uf($,f,w){try{let X=localStorage.getItem(L1($,f,w));if(!X)return null;return o1(JSON.parse(X))}catch{return null}}function Vw($,f,w,X){try{localStorage.setItem(L1($,f,w),JSON.stringify(X))}catch{}}function s$($){return{draft:$,responseIds:new Set,canvases:new Set}}function $$({sessionId:$,revision:f,isReadOnly:w,draftPhase:X,remoteAnnotations:J,canvasFiles:W,loadState:q,saveState:Y,children:Q}){let _=!!q,N=_?null:Uf($,f,X),U=a$(N),[B,H]=t1(()=>(N?.annotations??[]).map((P)=>({...P,source:P.source??"local"}))),[b,z]=t1(()=>N?.generalNote??""),[L,R]=t1(()=>N?.responses?new Map(N.responses):new Map),F=`${$}:${f}:${X}`,M=a$(F);M.current=F;let[T,h]=t1(()=>s$(F)),[Z,j]=t1(()=>N?.feedbackEntries?new Map(N.feedbackEntries):new Map),[E,u]=t1(!_);bf(()=>{let P=(g)=>{U.current=g,H((g?.annotations??[]).map((p)=>({...p,source:p.source??"local"}))),z(g?.generalNote??""),R(g?.responses?new Map(g.responses):new Map),j(g?.feedbackEntries?new Map(g.feedbackEntries):new Map),w0(null)};if(_){let g=!1;return u(!1),q($,f,X).then((p)=>{if(g)return;P(o1(p)),u(!0)}),()=>{g=!0}}P(Uf($,f,X)),u(!0);return},[$,f,X,_,q]);let x=a$(null);bf(()=>{if(w&&X!=="next")return;if(!E)return;if(x.current)clearTimeout(x.current);let P={...U.current,annotations:B,generalNote:b,responses:Array.from(L.entries()),feedbackEntries:Array.from(Z.entries())},g=()=>{if(Y)Y($,f,P,X);else Vw($,f,X,P)};if(X==="next"){g();return}return x.current=setTimeout(g,300),()=>{if(x.current)clearTimeout(x.current)}},[B,b,L,Z,$,f,w,X,E,Y]);let e=n1((P,g)=>{R((p)=>{let O=new Map(p);return O.set(P,g),O})},[]),J0=n1((P)=>{h((g)=>{let p=g.draft===M.current?g:s$(M.current);if(p.responseIds.has(P))return p;return{...p,responseIds:new Set(p.responseIds).add(P)}})},[]),W0=n1((P)=>{h((g)=>{let p=g.draft===M.current?g:s$(M.current);if(p.canvases.has(P))return p;return{...p,canvases:new Set(p.canvases).add(P)}})},[]),O0=T.draft===F?T:null,c=Iw(()=>{if(!O0||!t$(W,O0.canvases))return L;return n$(L,O0.responseIds)},[O0,W,L]),$0=n1((P,g)=>{j((p)=>{let O=p.get(P);if(O&&O.markdown===g.markdown&&O.label===g.label&&O.required===g.required)return p;let v=new Map(p);return v.set(P,g),v})},[]),f0=n1((P)=>{j((g)=>{if(!g.has(P))return g;let p=new Map(g);return p.delete(P),p})},[]),Q0=n1(()=>{if(R(new Map),j(new Map),Y)Y($,f,{annotations:[],generalNote:"",responses:[],feedbackEntries:[]},X);else if(X==="next")localStorage.removeItem(L1($,f,X));else o$(localStorage,$,f)},[$,f,X,Y]),s=r2({annotations:B,setAnnotations:H,generalNote:b,setGeneralNote:z,remoteAnnotations:J,isReadOnly:w,onClear:Q0}),{setActiveAnnotationId:w0}=s,_0=n0();return e$(jw.Provider,{value:_0,children:e$(hw.Provider,{value:s,children:e$(gw.Provider,{value:{...s,responses:L,setResponse:e,submittableResponses:c,registerResponse:J0,registerCanvasRendered:W0,feedbackEntries:Z,setFeedbackEntry:$0,removeFeedbackEntry:f0},children:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{ActiveViewCtx as i6,AnnotationCtx as d6,CanvasFileCtx as o6,SessionContext as O5,useAnnotations as n6,useCanvasFile as DQ,useFeedback as t6,useResponseRegistration as EQ}from"#canvas/runtime";function F2($){let f=document.querySelector(`[data-annotation-id="${$.id}"]`);if(f instanceof HTMLElement)return f;let w=$.canvasFile?document.querySelector(`[data-canvas-file="${$.canvasFile}"]`):document;if(!w)return null;return T$($.snippet,w)}function Bf($){$.classList.remove("ann-flash"),$.offsetWidth,$.classList.add("ann-flash"),$.addEventListener("animationend",()=>{$.classList.remove("ann-flash")},{once:!0})}function $5($,f){let w=b1($);if(w)f({type:"file",path:w}),setTimeout(()=>{let X=F2($);if(X)X.scrollIntoView({behavior:"smooth",block:"center"}),Bf(X)},150);else{let X=F2($);if(X)X.scrollIntoView({behavior:"smooth",block:"center"}),Bf(X)}}import{SessionContext as C6}from"#canvas/runtime";import{useCallback as U5,useContext as B5,useEffect as If,useMemo as y6,useState as $2}from"react";import{createContext as Mf}from"react";var a1=Mf({activeView:{type:"overview"},setActiveView:()=>{},openFiles:[],closeFile:()=>{},canvasFiles:[]}),s1=Mf({currentRevision:1,selectedRevision:1,revisions:[],setSelectedRevision:()=>{},isReadOnly:!1,compareRevision:null,setCompareRevision:()=>{},agentWatching:!1});import{jsxDEV as K1}from"react/jsx-dev-runtime";var Dw={ts:"#3178c6",tsx:"#3178c6",js:"#e8a32e",jsx:"#4ba0c8",html:"#e34c26",css:"#264de4",scss:"#c69",json:"#7a7568",yaml:"#cb171e",yml:"#cb171e",toml:"#9c4221",rs:"#dea584",go:"#00add8",c:"#6a6a6a",cpp:"#f34b7d",h:"#6a6a6a",py:"#3572a5",rb:"#cc342d",sh:"#5a8c3c",bash:"#5a8c3c",md:"#3573b5",txt:"#6b6560",lock:"#6b6560",gitignore:"#6b6560",svg:"#d9952e",png:"#6a9c2e",jpg:"#6a9c2e",gif:"#6a9c2e"},Ew={ts:"TS",tsx:"TX",js:"JS",jsx:"JX",py:"PY",rs:"RS",go:"GO",rb:"RB",json:"{}",yaml:"YM",yml:"YM",toml:"TM",html:"<>",css:"#",scss:"#",md:"M↓",sh:"$",bash:"$",c:"C",cpp:"C+",h:"H",svg:"◇",png:"▣",jpg:"▣"};function f5({name:$,type:f,expanded:w,className:X=""}){if(f==="dir")return K1("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",className:`flex-shrink-0 ${X}`,children:w?K1("path",{d:"M1.5 3.5h5l1.5 1.5h6.5v8h-13z",style:{fill:"var(--color-folder-fill-active)",stroke:"var(--color-folder-stroke-active)"},strokeWidth:"1"},void 0,!1,void 0,this):K1("path",{d:"M1.5 3.5h5l1.5 1.5h6.5v8h-13z",style:{fill:"var(--color-folder-fill)",stroke:"var(--color-folder-stroke)"},strokeWidth:"1"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let J=$.includes(".")?$.split(".").pop().toLowerCase():"",W=Dw[J]||"#6b6560",q=Ew[J];return K1("svg",{width:"14",height:"14",viewBox:"0 0 16 16",className:`flex-shrink-0 ${X}`,children:[K1("path",{d:"M2 1.5h8l3.5 3.5v9.5a1 1 0 01-1 1H3a1 1 0 01-1-1v-12a1 1 0 011-1z",fill:W,opacity:"0.85"},void 0,!1,void 0,this),K1("path",{d:"M10 1.5v2.5a1 1 0 001 1h2.5",fill:"none",stroke:"white",strokeWidth:"0.5",opacity:"0.5"},void 0,!1,void 0,this),q&&K1("text",{x:"8",y:"11.5",textAnchor:"middle",fill:"white",fontSize:"5.5",fontFamily:"monospace",fontWeight:"600",children:q},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function J5(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var z1=J5();function Af($){z1=$}var F1={exec:()=>null};function a($,f=""){let w=typeof $=="string"?$:$.source,X={replace:(J,W)=>{let q=typeof W=="string"?W:W.source;return q=q.replace(z0.caret,"$1"),w=w.replace(J,q),X},getRegex:()=>new RegExp(w,f)};return X}var Zw=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),z0={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:($)=>new RegExp(`^( {0,3}${$})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}#`),htmlBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}>`)},xw=/^(?:[ \t]*(?:\n|$))+/,cw=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,uw=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,R2=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,lw=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,X5=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Rf=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Pf=a(Rf).replace(/bull/g,X5).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),pw=a(Rf).replace(/bull/g,X5).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),q5=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,rw=/^[^\n]+/,W5=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,iw=a(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",W5).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),dw=a(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,X5).getRegex(),q$="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Q5=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ow=a("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",Q5).replace("tag",q$).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),vf=a(q5).replace("hr",R2).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",q$).getRegex(),nw=a(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",vf).getRegex(),Y5={blockquote:nw,code:cw,def:iw,fences:uw,heading:lw,hr:R2,html:ow,lheading:Pf,list:dw,newline:xw,paragraph:vf,table:F1,text:rw},Lf=a("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",R2).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",q$).getRegex(),tw={...Y5,lheading:pw,table:Lf,paragraph:a(q5).replace("hr",R2).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Lf).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",q$).getRegex()},aw={...Y5,html:a(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Q5).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:F1,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:a(q5).replace("hr",R2).replace("heading",` *#{1,6} *[^
|
|
12
|
-
]`).replace("lheading",Pf).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},sw=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ew=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,mf=/^( {2,}|\\)\n(?!\s*$)/,$6=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,e1=/[\p{P}\p{S}]/u,W$=/[\s\p{P}\p{S}]/u,G5=/[^\s\p{P}\p{S}]/u,f6=a(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,W$).getRegex(),kf=/(?!~)[\p{P}\p{S}]/u,w6=/(?!~)[\s\p{P}\p{S}]/u,J6=/(?:[^\s\p{P}\p{S}]|~)/u,X6=a(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Zw?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Cf=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,q6=a(Cf,"u").replace(/punct/g,e1).getRegex(),W6=a(Cf,"u").replace(/punct/g,kf).getRegex(),yf="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Q6=a(yf,"gu").replace(/notPunctSpace/g,G5).replace(/punctSpace/g,W$).replace(/punct/g,e1).getRegex(),Y6=a(yf,"gu").replace(/notPunctSpace/g,J6).replace(/punctSpace/g,w6).replace(/punct/g,kf).getRegex(),G6=a("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,G5).replace(/punctSpace/g,W$).replace(/punct/g,e1).getRegex(),_6=a(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,e1).getRegex(),N6="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",H6=a(N6,"gu").replace(/notPunctSpace/g,G5).replace(/punctSpace/g,W$).replace(/punct/g,e1).getRegex(),b6=a(/\\(punct)/,"gu").replace(/punct/g,e1).getRegex(),U6=a(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),B6=a(Q5).replace("(?:-->|$)","-->").getRegex(),M6=a("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",B6).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),w$=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,L6=a(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",w$).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Tf=a(/^!?\[(label)\]\[(ref)\]/).replace("label",w$).replace("ref",W5).getRegex(),gf=a(/^!?\[(ref)\](?:\[\])?/).replace("ref",W5).getRegex(),O6=a("reflink|nolink(?!\\()","g").replace("reflink",Tf).replace("nolink",gf).getRegex(),Of=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,_5={_backpedal:F1,anyPunctuation:b6,autolink:U6,blockSkip:X6,br:mf,code:ew,del:F1,delLDelim:F1,delRDelim:F1,emStrongLDelim:q6,emStrongRDelimAst:Q6,emStrongRDelimUnd:G6,escape:sw,link:L6,nolink:gf,punctuation:f6,reflink:Tf,reflinkSearch:O6,tag:M6,text:$6,url:F1},K6={..._5,link:a(/^!?\[(label)\]\((.*?)\)/).replace("label",w$).getRegex(),reflink:a(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",w$).getRegex()},w5={..._5,emStrongRDelimAst:Y6,emStrongLDelim:W6,delLDelim:_6,delRDelim:H6,url:a(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Of).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:a(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Of).getRegex()},F6={...w5,br:a(mf).replace("{2,}","*").getRegex(),text:a(w5.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},f$={normal:Y5,gfm:tw,pedantic:aw},S2={normal:_5,gfm:w5,breaks:F6,pedantic:K6},S6={"&":"&","<":"<",">":">",'"':""","'":"'"},Kf=($)=>S6[$];function u0($,f){if(f){if(z0.escapeTest.test($))return $.replace(z0.escapeReplace,Kf)}else if(z0.escapeTestNoEncode.test($))return $.replace(z0.escapeReplaceNoEncode,Kf);return $}function Ff($){try{$=encodeURI($).replace(z0.percentDecode,"%")}catch{return null}return $}function Sf($,f){let w=$.replace(z0.findPipe,(W,q,Y)=>{let Q=!1,_=q;for(;--_>=0&&Y[_]==="\\";)Q=!Q;return Q?"|":" |"}),X=w.split(z0.splitPipe),J=0;if(X[0].trim()||X.shift(),X.length>0&&!X.at(-1)?.trim()&&X.pop(),f)if(X.length>f)X.splice(f);else for(;X.length<f;)X.push("");for(;J<X.length;J++)X[J]=X[J].trim().replace(z0.slashPipe,"|");return X}function z2($,f,w){let X=$.length;if(X===0)return"";let J=0;for(;J<X;){let W=$.charAt(X-J-1);if(W===f&&!w)J++;else if(W!==f&&w)J++;else break}return $.slice(0,X-J)}function z6($,f){if($.indexOf(f[1])===-1)return-1;let w=0;for(let X=0;X<$.length;X++)if($[X]==="\\")X++;else if($[X]===f[0])w++;else if($[X]===f[1]&&(w--,w<0))return X;return w>0?-2:-1}function A6($,f=0){let w=f,X="";for(let J of $)if(J==="\t"){let W=4-w%4;X+=" ".repeat(W),w+=W}else X+=J,w++;return X}function zf($,f,w,X,J){let W=f.href,q=f.title||null,Y=$[1].replace(J.other.outputLinkReplace,"$1");X.state.inLink=!0;let Q={type:$[0].charAt(0)==="!"?"image":"link",raw:w,href:W,title:q,text:Y,tokens:X.inlineTokens(Y)};return X.state.inLink=!1,Q}function R6($,f,w){let X=$.match(w.other.indentCodeCompensation);if(X===null)return f;let J=X[1];return f.split(`
|
|
13
|
-
`).map((W)=>{let q=W.match(w.other.beginningSpace);if(q===null)return W;let[Y]=q;return Y.length>=J.length?W.slice(J.length):W}).join(`
|
|
14
|
-
`)}var J$=class{options;rules;lexer;constructor($){this.options=$||z1}space($){let f=this.rules.block.newline.exec($);if(f&&f[0].length>0)return{type:"space",raw:f[0]}}code($){let f=this.rules.block.code.exec($);if(f){let w=f[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:f[0],codeBlockStyle:"indented",text:this.options.pedantic?w:z2(w,`
|
|
15
|
-
`)}}}fences($){let f=this.rules.block.fences.exec($);if(f){let w=f[0],X=R6(w,f[3]||"",this.rules);return{type:"code",raw:w,lang:f[2]?f[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):f[2],text:X}}}heading($){let f=this.rules.block.heading.exec($);if(f){let w=f[2].trim();if(this.rules.other.endingHash.test(w)){let X=z2(w,"#");(this.options.pedantic||!X||this.rules.other.endingSpaceChar.test(X))&&(w=X.trim())}return{type:"heading",raw:f[0],depth:f[1].length,text:w,tokens:this.lexer.inline(w)}}}hr($){let f=this.rules.block.hr.exec($);if(f)return{type:"hr",raw:z2(f[0],`
|
|
16
|
-
`)}}blockquote($){let f=this.rules.block.blockquote.exec($);if(f){let w=z2(f[0],`
|
|
17
|
-
`).split(`
|
|
18
|
-
`),X="",J="",W=[];for(;w.length>0;){let q=!1,Y=[],Q;for(Q=0;Q<w.length;Q++)if(this.rules.other.blockquoteStart.test(w[Q]))Y.push(w[Q]),q=!0;else if(!q)Y.push(w[Q]);else break;w=w.slice(Q);let _=Y.join(`
|
|
19
|
-
`),N=_.replace(this.rules.other.blockquoteSetextReplace,`
|
|
20
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");X=X?`${X}
|
|
21
|
-
${_}`:_,J=J?`${J}
|
|
22
|
-
${N}`:N;let U=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(N,W,!0),this.lexer.state.top=U,w.length===0)break;let B=W.at(-1);if(B?.type==="code")break;if(B?.type==="blockquote"){let H=B,b=H.raw+`
|
|
23
|
-
`+w.join(`
|
|
24
|
-
`),z=this.blockquote(b);W[W.length-1]=z,X=X.substring(0,X.length-H.raw.length)+z.raw,J=J.substring(0,J.length-H.text.length)+z.text;break}else if(B?.type==="list"){let H=B,b=H.raw+`
|
|
25
|
-
`+w.join(`
|
|
26
|
-
`),z=this.list(b);W[W.length-1]=z,X=X.substring(0,X.length-B.raw.length)+z.raw,J=J.substring(0,J.length-H.raw.length)+z.raw,w=b.substring(W.at(-1).raw.length).split(`
|
|
27
|
-
`);continue}}return{type:"blockquote",raw:X,tokens:W,text:J}}}list($){let f=this.rules.block.list.exec($);if(f){let w=f[1].trim(),X=w.length>1,J={type:"list",raw:"",ordered:X,start:X?+w.slice(0,-1):"",loose:!1,items:[]};w=X?`\\d{1,9}\\${w.slice(-1)}`:`\\${w}`,this.options.pedantic&&(w=X?w:"[*+-]");let W=this.rules.other.listItemRegex(w),q=!1;for(;$;){let Q=!1,_="",N="";if(!(f=W.exec($))||this.rules.block.hr.test($))break;_=f[0],$=$.substring(_.length);let U=A6(f[2].split(`
|
|
28
|
-
`,1)[0],f[1].length),B=$.split(`
|
|
29
|
-
`,1)[0],H=!U.trim(),b=0;if(this.options.pedantic?(b=2,N=U.trimStart()):H?b=f[1].length+1:(b=U.search(this.rules.other.nonSpaceChar),b=b>4?1:b,N=U.slice(b),b+=f[1].length),H&&this.rules.other.blankLine.test(B)&&(_+=B+`
|
|
30
|
-
`,$=$.substring(B.length+1),Q=!0),!Q){let z=this.rules.other.nextBulletRegex(b),L=this.rules.other.hrRegex(b),R=this.rules.other.fencesBeginRegex(b),F=this.rules.other.headingBeginRegex(b),M=this.rules.other.htmlBeginRegex(b),T=this.rules.other.blockquoteBeginRegex(b);for(;$;){let h=$.split(`
|
|
31
|
-
`,1)[0],Z;if(B=h,this.options.pedantic?(B=B.replace(this.rules.other.listReplaceNesting," "),Z=B):Z=B.replace(this.rules.other.tabCharGlobal," "),R.test(B)||F.test(B)||M.test(B)||T.test(B)||z.test(B)||L.test(B))break;if(Z.search(this.rules.other.nonSpaceChar)>=b||!B.trim())N+=`
|
|
32
|
-
`+Z.slice(b);else{if(H||U.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||R.test(U)||F.test(U)||L.test(U))break;N+=`
|
|
33
|
-
`+B}H=!B.trim(),_+=h+`
|
|
34
|
-
`,$=$.substring(h.length+1),U=Z.slice(b)}}J.loose||(q?J.loose=!0:this.rules.other.doubleBlankLine.test(_)&&(q=!0)),J.items.push({type:"list_item",raw:_,task:!!this.options.gfm&&this.rules.other.listIsTask.test(N),loose:!1,text:N,tokens:[]}),J.raw+=_}let Y=J.items.at(-1);if(Y)Y.raw=Y.raw.trimEnd(),Y.text=Y.text.trimEnd();else return;J.raw=J.raw.trimEnd();for(let Q of J.items){if(this.lexer.state.top=!1,Q.tokens=this.lexer.blockTokens(Q.text,[]),Q.task){if(Q.text=Q.text.replace(this.rules.other.listReplaceTask,""),Q.tokens[0]?.type==="text"||Q.tokens[0]?.type==="paragraph"){Q.tokens[0].raw=Q.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),Q.tokens[0].text=Q.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let N=this.lexer.inlineQueue.length-1;N>=0;N--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[N].src)){this.lexer.inlineQueue[N].src=this.lexer.inlineQueue[N].src.replace(this.rules.other.listReplaceTask,"");break}}let _=this.rules.other.listTaskCheckbox.exec(Q.raw);if(_){let N={type:"checkbox",raw:_[0]+" ",checked:_[0]!=="[ ]"};Q.checked=N.checked,J.loose?Q.tokens[0]&&["paragraph","text"].includes(Q.tokens[0].type)&&"tokens"in Q.tokens[0]&&Q.tokens[0].tokens?(Q.tokens[0].raw=N.raw+Q.tokens[0].raw,Q.tokens[0].text=N.raw+Q.tokens[0].text,Q.tokens[0].tokens.unshift(N)):Q.tokens.unshift({type:"paragraph",raw:N.raw,text:N.raw,tokens:[N]}):Q.tokens.unshift(N)}}if(!J.loose){let _=Q.tokens.filter((U)=>U.type==="space"),N=_.length>0&&_.some((U)=>this.rules.other.anyLine.test(U.raw));J.loose=N}}if(J.loose)for(let Q of J.items){Q.loose=!0;for(let _ of Q.tokens)_.type==="text"&&(_.type="paragraph")}return J}}html($){let f=this.rules.block.html.exec($);if(f)return{type:"html",block:!0,raw:f[0],pre:f[1]==="pre"||f[1]==="script"||f[1]==="style",text:f[0]}}def($){let f=this.rules.block.def.exec($);if(f){let w=f[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),X=f[2]?f[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",J=f[3]?f[3].substring(1,f[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):f[3];return{type:"def",tag:w,raw:f[0],href:X,title:J}}}table($){let f=this.rules.block.table.exec($);if(!f||!this.rules.other.tableDelimiter.test(f[2]))return;let w=Sf(f[1]),X=f[2].replace(this.rules.other.tableAlignChars,"").split("|"),J=f[3]?.trim()?f[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
35
|
-
`):[],W={type:"table",raw:f[0],header:[],align:[],rows:[]};if(w.length===X.length){for(let q of X)this.rules.other.tableAlignRight.test(q)?W.align.push("right"):this.rules.other.tableAlignCenter.test(q)?W.align.push("center"):this.rules.other.tableAlignLeft.test(q)?W.align.push("left"):W.align.push(null);for(let q=0;q<w.length;q++)W.header.push({text:w[q],tokens:this.lexer.inline(w[q]),header:!0,align:W.align[q]});for(let q of J)W.rows.push(Sf(q,W.header.length).map((Y,Q)=>({text:Y,tokens:this.lexer.inline(Y),header:!1,align:W.align[Q]})));return W}}lheading($){let f=this.rules.block.lheading.exec($);if(f){let w=f[1].trim();return{type:"heading",raw:f[0],depth:f[2].charAt(0)==="="?1:2,text:w,tokens:this.lexer.inline(w)}}}paragraph($){let f=this.rules.block.paragraph.exec($);if(f){let w=f[1].charAt(f[1].length-1)===`
|
|
36
|
-
`?f[1].slice(0,-1):f[1];return{type:"paragraph",raw:f[0],text:w,tokens:this.lexer.inline(w)}}}text($){let f=this.rules.block.text.exec($);if(f)return{type:"text",raw:f[0],text:f[0],tokens:this.lexer.inline(f[0])}}escape($){let f=this.rules.inline.escape.exec($);if(f)return{type:"escape",raw:f[0],text:f[1]}}tag($){let f=this.rules.inline.tag.exec($);if(f)return!this.lexer.state.inLink&&this.rules.other.startATag.test(f[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(f[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(f[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(f[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:f[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:f[0]}}link($){let f=this.rules.inline.link.exec($);if(f){let w=f[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(w)){if(!this.rules.other.endAngleBracket.test(w))return;let W=z2(w.slice(0,-1),"\\");if((w.length-W.length)%2===0)return}else{let W=z6(f[2],"()");if(W===-2)return;if(W>-1){let q=(f[0].indexOf("!")===0?5:4)+f[1].length+W;f[2]=f[2].substring(0,W),f[0]=f[0].substring(0,q).trim(),f[3]=""}}let X=f[2],J="";if(this.options.pedantic){let W=this.rules.other.pedanticHrefTitle.exec(X);W&&(X=W[1],J=W[3])}else J=f[3]?f[3].slice(1,-1):"";return X=X.trim(),this.rules.other.startAngleBracket.test(X)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(w)?X=X.slice(1):X=X.slice(1,-1)),zf(f,{href:X&&X.replace(this.rules.inline.anyPunctuation,"$1"),title:J&&J.replace(this.rules.inline.anyPunctuation,"$1")},f[0],this.lexer,this.rules)}}reflink($,f){let w;if((w=this.rules.inline.reflink.exec($))||(w=this.rules.inline.nolink.exec($))){let X=(w[2]||w[1]).replace(this.rules.other.multipleSpaceGlobal," "),J=f[X.toLowerCase()];if(!J){let W=w[0].charAt(0);return{type:"text",raw:W,text:W}}return zf(w,J,w[0],this.lexer,this.rules)}}emStrong($,f,w=""){let X=this.rules.inline.emStrongLDelim.exec($);if(!X||!X[1]&&!X[2]&&!X[3]&&!X[4]||X[4]&&w.match(this.rules.other.unicodeAlphaNumeric))return;if(!(X[1]||X[3])||!w||this.rules.inline.punctuation.exec(w)){let J=[...X[0]].length-1,W,q,Y=J,Q=0,_=X[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(_.lastIndex=0,f=f.slice(-1*$.length+J);(X=_.exec(f))!==null;){if(W=X[1]||X[2]||X[3]||X[4]||X[5]||X[6],!W)continue;if(q=[...W].length,X[3]||X[4]){Y+=q;continue}else if((X[5]||X[6])&&J%3&&!((J+q)%3)){Q+=q;continue}if(Y-=q,Y>0)continue;q=Math.min(q,q+Y+Q);let N=[...X[0]][0].length,U=$.slice(0,J+X.index+N+q);if(Math.min(J,q)%2){let H=U.slice(1,-1);return{type:"em",raw:U,text:H,tokens:this.lexer.inlineTokens(H)}}let B=U.slice(2,-2);return{type:"strong",raw:U,text:B,tokens:this.lexer.inlineTokens(B)}}}}codespan($){let f=this.rules.inline.code.exec($);if(f){let w=f[2].replace(this.rules.other.newLineCharGlobal," "),X=this.rules.other.nonSpaceChar.test(w),J=this.rules.other.startingSpaceChar.test(w)&&this.rules.other.endingSpaceChar.test(w);return X&&J&&(w=w.substring(1,w.length-1)),{type:"codespan",raw:f[0],text:w}}}br($){let f=this.rules.inline.br.exec($);if(f)return{type:"br",raw:f[0]}}del($,f,w=""){let X=this.rules.inline.delLDelim.exec($);if(!X)return;if(!X[1]||!w||this.rules.inline.punctuation.exec(w)){let J=[...X[0]].length-1,W,q,Y=J,Q=this.rules.inline.delRDelim;for(Q.lastIndex=0,f=f.slice(-1*$.length+J);(X=Q.exec(f))!==null;){if(W=X[1]||X[2]||X[3]||X[4]||X[5]||X[6],!W||(q=[...W].length,q!==J))continue;if(X[3]||X[4]){Y+=q;continue}if(Y-=q,Y>0)continue;q=Math.min(q,q+Y);let _=[...X[0]][0].length,N=$.slice(0,J+X.index+_+q),U=N.slice(J,-J);return{type:"del",raw:N,text:U,tokens:this.lexer.inlineTokens(U)}}}}autolink($){let f=this.rules.inline.autolink.exec($);if(f){let w,X;return f[2]==="@"?(w=f[1],X="mailto:"+w):(w=f[1],X=w),{type:"link",raw:f[0],text:w,href:X,tokens:[{type:"text",raw:w,text:w}]}}}url($){let f;if(f=this.rules.inline.url.exec($)){let w,X;if(f[2]==="@")w=f[0],X="mailto:"+w;else{let J;do J=f[0],f[0]=this.rules.inline._backpedal.exec(f[0])?.[0]??"";while(J!==f[0]);w=f[0],f[1]==="www."?X="http://"+f[0]:X=f[0]}return{type:"link",raw:f[0],text:w,href:X,tokens:[{type:"text",raw:w,text:w}]}}}inlineText($){let f=this.rules.inline.text.exec($);if(f){let w=this.lexer.state.inRawBlock;return{type:"text",raw:f[0],text:f[0],escaped:w}}}},j0=class ${tokens;options;state;inlineQueue;tokenizer;constructor(f){this.tokens=[],this.tokens.links=Object.create(null),this.options=f||z1,this.options.tokenizer=this.options.tokenizer||new J$,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let w={other:z0,block:f$.normal,inline:S2.normal};this.options.pedantic?(w.block=f$.pedantic,w.inline=S2.pedantic):this.options.gfm&&(w.block=f$.gfm,this.options.breaks?w.inline=S2.breaks:w.inline=S2.gfm),this.tokenizer.rules=w}static get rules(){return{block:f$,inline:S2}}static lex(f,w){return new $(w).lex(f)}static lexInline(f,w){return new $(w).inlineTokens(f)}lex(f){f=f.replace(z0.carriageReturn,`
|
|
37
|
-
`),this.blockTokens(f,this.tokens);for(let w=0;w<this.inlineQueue.length;w++){let X=this.inlineQueue[w];this.inlineTokens(X.src,X.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(f,w=[],X=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(f=f.replace(z0.tabCharGlobal," ").replace(z0.spaceLine,""));f;){let J;if(this.options.extensions?.block?.some((q)=>(J=q.call({lexer:this},f,w))?(f=f.substring(J.raw.length),w.push(J),!0):!1))continue;if(J=this.tokenizer.space(f)){f=f.substring(J.raw.length);let q=w.at(-1);J.raw.length===1&&q!==void 0?q.raw+=`
|
|
38
|
-
`:w.push(J);continue}if(J=this.tokenizer.code(f)){f=f.substring(J.raw.length);let q=w.at(-1);q?.type==="paragraph"||q?.type==="text"?(q.raw+=(q.raw.endsWith(`
|
|
39
|
-
`)?"":`
|
|
40
|
-
`)+J.raw,q.text+=`
|
|
41
|
-
`+J.text,this.inlineQueue.at(-1).src=q.text):w.push(J);continue}if(J=this.tokenizer.fences(f)){f=f.substring(J.raw.length),w.push(J);continue}if(J=this.tokenizer.heading(f)){f=f.substring(J.raw.length),w.push(J);continue}if(J=this.tokenizer.hr(f)){f=f.substring(J.raw.length),w.push(J);continue}if(J=this.tokenizer.blockquote(f)){f=f.substring(J.raw.length),w.push(J);continue}if(J=this.tokenizer.list(f)){f=f.substring(J.raw.length),w.push(J);continue}if(J=this.tokenizer.html(f)){f=f.substring(J.raw.length),w.push(J);continue}if(J=this.tokenizer.def(f)){f=f.substring(J.raw.length);let q=w.at(-1);q?.type==="paragraph"||q?.type==="text"?(q.raw+=(q.raw.endsWith(`
|
|
42
|
-
`)?"":`
|
|
43
|
-
`)+J.raw,q.text+=`
|
|
44
|
-
`+J.raw,this.inlineQueue.at(-1).src=q.text):this.tokens.links[J.tag]||(this.tokens.links[J.tag]={href:J.href,title:J.title},w.push(J));continue}if(J=this.tokenizer.table(f)){f=f.substring(J.raw.length),w.push(J);continue}if(J=this.tokenizer.lheading(f)){f=f.substring(J.raw.length),w.push(J);continue}let W=f;if(this.options.extensions?.startBlock){let q=1/0,Y=f.slice(1),Q;this.options.extensions.startBlock.forEach((_)=>{Q=_.call({lexer:this},Y),typeof Q=="number"&&Q>=0&&(q=Math.min(q,Q))}),q<1/0&&q>=0&&(W=f.substring(0,q+1))}if(this.state.top&&(J=this.tokenizer.paragraph(W))){let q=w.at(-1);X&&q?.type==="paragraph"?(q.raw+=(q.raw.endsWith(`
|
|
45
|
-
`)?"":`
|
|
46
|
-
`)+J.raw,q.text+=`
|
|
47
|
-
`+J.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=q.text):w.push(J),X=W.length!==f.length,f=f.substring(J.raw.length);continue}if(J=this.tokenizer.text(f)){f=f.substring(J.raw.length);let q=w.at(-1);q?.type==="text"?(q.raw+=(q.raw.endsWith(`
|
|
48
|
-
`)?"":`
|
|
49
|
-
`)+J.raw,q.text+=`
|
|
50
|
-
`+J.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=q.text):w.push(J);continue}if(f){let q="Infinite loop on byte: "+f.charCodeAt(0);if(this.options.silent){console.error(q);break}else throw Error(q)}}return this.state.top=!0,w}inline(f,w=[]){return this.inlineQueue.push({src:f,tokens:w}),w}inlineTokens(f,w=[]){this.tokenizer.lexer=this;let X=f,J=null;if(this.tokens.links){let Q=Object.keys(this.tokens.links);if(Q.length>0)for(;(J=this.tokenizer.rules.inline.reflinkSearch.exec(X))!==null;)Q.includes(J[0].slice(J[0].lastIndexOf("[")+1,-1))&&(X=X.slice(0,J.index)+"["+"a".repeat(J[0].length-2)+"]"+X.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(J=this.tokenizer.rules.inline.anyPunctuation.exec(X))!==null;)X=X.slice(0,J.index)+"++"+X.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let W;for(;(J=this.tokenizer.rules.inline.blockSkip.exec(X))!==null;)W=J[2]?J[2].length:0,X=X.slice(0,J.index+W)+"["+"a".repeat(J[0].length-W-2)+"]"+X.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);X=this.options.hooks?.emStrongMask?.call({lexer:this},X)??X;let q=!1,Y="";for(;f;){q||(Y=""),q=!1;let Q;if(this.options.extensions?.inline?.some((N)=>(Q=N.call({lexer:this},f,w))?(f=f.substring(Q.raw.length),w.push(Q),!0):!1))continue;if(Q=this.tokenizer.escape(f)){f=f.substring(Q.raw.length),w.push(Q);continue}if(Q=this.tokenizer.tag(f)){f=f.substring(Q.raw.length),w.push(Q);continue}if(Q=this.tokenizer.link(f)){f=f.substring(Q.raw.length),w.push(Q);continue}if(Q=this.tokenizer.reflink(f,this.tokens.links)){f=f.substring(Q.raw.length);let N=w.at(-1);Q.type==="text"&&N?.type==="text"?(N.raw+=Q.raw,N.text+=Q.text):w.push(Q);continue}if(Q=this.tokenizer.emStrong(f,X,Y)){f=f.substring(Q.raw.length),w.push(Q);continue}if(Q=this.tokenizer.codespan(f)){f=f.substring(Q.raw.length),w.push(Q);continue}if(Q=this.tokenizer.br(f)){f=f.substring(Q.raw.length),w.push(Q);continue}if(Q=this.tokenizer.del(f,X,Y)){f=f.substring(Q.raw.length),w.push(Q);continue}if(Q=this.tokenizer.autolink(f)){f=f.substring(Q.raw.length),w.push(Q);continue}if(!this.state.inLink&&(Q=this.tokenizer.url(f))){f=f.substring(Q.raw.length),w.push(Q);continue}let _=f;if(this.options.extensions?.startInline){let N=1/0,U=f.slice(1),B;this.options.extensions.startInline.forEach((H)=>{B=H.call({lexer:this},U),typeof B=="number"&&B>=0&&(N=Math.min(N,B))}),N<1/0&&N>=0&&(_=f.substring(0,N+1))}if(Q=this.tokenizer.inlineText(_)){f=f.substring(Q.raw.length),Q.raw.slice(-1)!=="_"&&(Y=Q.raw.slice(-1)),q=!0;let N=w.at(-1);N?.type==="text"?(N.raw+=Q.raw,N.text+=Q.text):w.push(Q);continue}if(f){let N="Infinite loop on byte: "+f.charCodeAt(0);if(this.options.silent){console.error(N);break}else throw Error(N)}}return w}},X$=class{options;parser;constructor($){this.options=$||z1}space($){return""}code({text:$,lang:f,escaped:w}){let X=(f||"").match(z0.notSpaceStart)?.[0],J=$.replace(z0.endingNewline,"")+`
|
|
51
|
-
`;return X?'<pre><code class="language-'+u0(X)+'">'+(w?J:u0(J,!0))+`</code></pre>
|
|
52
|
-
`:"<pre><code>"+(w?J:u0(J,!0))+`</code></pre>
|
|
53
|
-
`}blockquote({tokens:$}){return`<blockquote>
|
|
54
|
-
${this.parser.parse($)}</blockquote>
|
|
55
|
-
`}html({text:$}){return $}def($){return""}heading({tokens:$,depth:f}){return`<h${f}>${this.parser.parseInline($)}</h${f}>
|
|
56
|
-
`}hr($){return`<hr>
|
|
57
|
-
`}list($){let{ordered:f,start:w}=$,X="";for(let q=0;q<$.items.length;q++){let Y=$.items[q];X+=this.listitem(Y)}let J=f?"ol":"ul",W=f&&w!==1?' start="'+w+'"':"";return"<"+J+W+`>
|
|
58
|
-
`+X+"</"+J+`>
|
|
59
|
-
`}listitem($){return`<li>${this.parser.parse($.tokens)}</li>
|
|
60
|
-
`}checkbox({checked:$}){return"<input "+($?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:$}){return`<p>${this.parser.parseInline($)}</p>
|
|
61
|
-
`}table($){let f="",w="";for(let J=0;J<$.header.length;J++)w+=this.tablecell($.header[J]);f+=this.tablerow({text:w});let X="";for(let J=0;J<$.rows.length;J++){let W=$.rows[J];w="";for(let q=0;q<W.length;q++)w+=this.tablecell(W[q]);X+=this.tablerow({text:w})}return X&&(X=`<tbody>${X}</tbody>`),`<table>
|
|
62
|
-
<thead>
|
|
63
|
-
`+f+`</thead>
|
|
64
|
-
`+X+`</table>
|
|
65
|
-
`}tablerow({text:$}){return`<tr>
|
|
66
|
-
${$}</tr>
|
|
67
|
-
`}tablecell($){let f=this.parser.parseInline($.tokens),w=$.header?"th":"td";return($.align?`<${w} align="${$.align}">`:`<${w}>`)+f+`</${w}>
|
|
68
|
-
`}strong({tokens:$}){return`<strong>${this.parser.parseInline($)}</strong>`}em({tokens:$}){return`<em>${this.parser.parseInline($)}</em>`}codespan({text:$}){return`<code>${u0($,!0)}</code>`}br($){return"<br>"}del({tokens:$}){return`<del>${this.parser.parseInline($)}</del>`}link({href:$,title:f,tokens:w}){let X=this.parser.parseInline(w),J=Ff($);if(J===null)return X;$=J;let W='<a href="'+$+'"';return f&&(W+=' title="'+u0(f)+'"'),W+=">"+X+"</a>",W}image({href:$,title:f,text:w,tokens:X}){X&&(w=this.parser.parseInline(X,this.parser.textRenderer));let J=Ff($);if(J===null)return u0(w);$=J;let W=`<img src="${$}" alt="${u0(w)}"`;return f&&(W+=` title="${u0(f)}"`),W+=">",W}text($){return"tokens"in $&&$.tokens?this.parser.parseInline($.tokens):("escaped"in $)&&$.escaped?$.text:u0($.text)}},N5=class{strong({text:$}){return $}em({text:$}){return $}codespan({text:$}){return $}del({text:$}){return $}html({text:$}){return $}text({text:$}){return $}link({text:$}){return""+$}image({text:$}){return""+$}br(){return""}checkbox({raw:$}){return $}},I0=class ${options;renderer;textRenderer;constructor(f){this.options=f||z1,this.options.renderer=this.options.renderer||new X$,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new N5}static parse(f,w){return new $(w).parse(f)}static parseInline(f,w){return new $(w).parseInline(f)}parse(f){this.renderer.parser=this;let w="";for(let X=0;X<f.length;X++){let J=f[X];if(this.options.extensions?.renderers?.[J.type]){let q=J,Y=this.options.extensions.renderers[q.type].call({parser:this},q);if(Y!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(q.type)){w+=Y||"";continue}}let W=J;switch(W.type){case"space":{w+=this.renderer.space(W);break}case"hr":{w+=this.renderer.hr(W);break}case"heading":{w+=this.renderer.heading(W);break}case"code":{w+=this.renderer.code(W);break}case"table":{w+=this.renderer.table(W);break}case"blockquote":{w+=this.renderer.blockquote(W);break}case"list":{w+=this.renderer.list(W);break}case"checkbox":{w+=this.renderer.checkbox(W);break}case"html":{w+=this.renderer.html(W);break}case"def":{w+=this.renderer.def(W);break}case"paragraph":{w+=this.renderer.paragraph(W);break}case"text":{w+=this.renderer.text(W);break}default:{let q='Token with "'+W.type+'" type was not found.';if(this.options.silent)return console.error(q),"";throw Error(q)}}}return w}parseInline(f,w=this.renderer){this.renderer.parser=this;let X="";for(let J=0;J<f.length;J++){let W=f[J];if(this.options.extensions?.renderers?.[W.type]){let Y=this.options.extensions.renderers[W.type].call({parser:this},W);if(Y!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(W.type)){X+=Y||"";continue}}let q=W;switch(q.type){case"escape":{X+=w.text(q);break}case"html":{X+=w.html(q);break}case"link":{X+=w.link(q);break}case"image":{X+=w.image(q);break}case"checkbox":{X+=w.checkbox(q);break}case"strong":{X+=w.strong(q);break}case"em":{X+=w.em(q);break}case"codespan":{X+=w.codespan(q);break}case"br":{X+=w.br(q);break}case"del":{X+=w.del(q);break}case"text":{X+=w.text(q);break}default:{let Y='Token with "'+q.type+'" type was not found.';if(this.options.silent)return console.error(Y),"";throw Error(Y)}}}return X}},A2=class{options;block;constructor($){this.options=$||z1}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess($){return $}postprocess($){return $}processAllTokens($){return $}emStrongMask($){return $}provideLexer($=this.block){return $?j0.lex:j0.lexInline}provideParser($=this.block){return $?I0.parse:I0.parseInline}},P6=class{defaults=J5();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=I0;Renderer=X$;TextRenderer=N5;Lexer=j0;Tokenizer=J$;Hooks=A2;constructor(...$){this.use(...$)}walkTokens($,f){let w=[];for(let X of $)switch(w=w.concat(f.call(this,X)),X.type){case"table":{let J=X;for(let W of J.header)w=w.concat(this.walkTokens(W.tokens,f));for(let W of J.rows)for(let q of W)w=w.concat(this.walkTokens(q.tokens,f));break}case"list":{let J=X;w=w.concat(this.walkTokens(J.items,f));break}default:{let J=X;this.defaults.extensions?.childTokens?.[J.type]?this.defaults.extensions.childTokens[J.type].forEach((W)=>{let q=J[W].flat(1/0);w=w.concat(this.walkTokens(q,f))}):J.tokens&&(w=w.concat(this.walkTokens(J.tokens,f)))}}return w}use(...$){let f=this.defaults.extensions||{renderers:{},childTokens:{}};return $.forEach((w)=>{let X={...w};if(X.async=this.defaults.async||X.async||!1,w.extensions&&(w.extensions.forEach((J)=>{if(!J.name)throw Error("extension name required");if("renderer"in J){let W=f.renderers[J.name];W?f.renderers[J.name]=function(...q){let Y=J.renderer.apply(this,q);return Y===!1&&(Y=W.apply(this,q)),Y}:f.renderers[J.name]=J.renderer}if("tokenizer"in J){if(!J.level||J.level!=="block"&&J.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let W=f[J.level];W?W.unshift(J.tokenizer):f[J.level]=[J.tokenizer],J.start&&(J.level==="block"?f.startBlock?f.startBlock.push(J.start):f.startBlock=[J.start]:J.level==="inline"&&(f.startInline?f.startInline.push(J.start):f.startInline=[J.start]))}"childTokens"in J&&J.childTokens&&(f.childTokens[J.name]=J.childTokens)}),X.extensions=f),w.renderer){let J=this.defaults.renderer||new X$(this.defaults);for(let W in w.renderer){if(!(W in J))throw Error(`renderer '${W}' does not exist`);if(["options","parser"].includes(W))continue;let q=W,Y=w.renderer[q],Q=J[q];J[q]=(..._)=>{let N=Y.apply(J,_);return N===!1&&(N=Q.apply(J,_)),N||""}}X.renderer=J}if(w.tokenizer){let J=this.defaults.tokenizer||new J$(this.defaults);for(let W in w.tokenizer){if(!(W in J))throw Error(`tokenizer '${W}' does not exist`);if(["options","rules","lexer"].includes(W))continue;let q=W,Y=w.tokenizer[q],Q=J[q];J[q]=(..._)=>{let N=Y.apply(J,_);return N===!1&&(N=Q.apply(J,_)),N}}X.tokenizer=J}if(w.hooks){let J=this.defaults.hooks||new A2;for(let W in w.hooks){if(!(W in J))throw Error(`hook '${W}' does not exist`);if(["options","block"].includes(W))continue;let q=W,Y=w.hooks[q],Q=J[q];A2.passThroughHooks.has(W)?J[q]=(_)=>{if(this.defaults.async&&A2.passThroughHooksRespectAsync.has(W))return(async()=>{let U=await Y.call(J,_);return Q.call(J,U)})();let N=Y.call(J,_);return Q.call(J,N)}:J[q]=(..._)=>{if(this.defaults.async)return(async()=>{let U=await Y.apply(J,_);return U===!1&&(U=await Q.apply(J,_)),U})();let N=Y.apply(J,_);return N===!1&&(N=Q.apply(J,_)),N}}X.hooks=J}if(w.walkTokens){let J=this.defaults.walkTokens,W=w.walkTokens;X.walkTokens=function(q){let Y=[];return Y.push(W.call(this,q)),J&&(Y=Y.concat(J.call(this,q))),Y}}this.defaults={...this.defaults,...X}}),this}setOptions($){return this.defaults={...this.defaults,...$},this}lexer($,f){return j0.lex($,f??this.defaults)}parser($,f){return I0.parse($,f??this.defaults)}parseMarkdown($){return(f,w)=>{let X={...w},J={...this.defaults,...X},W=this.onError(!!J.silent,!!J.async);if(this.defaults.async===!0&&X.async===!1)return W(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof f>"u"||f===null)return W(Error("marked(): input parameter is undefined or null"));if(typeof f!="string")return W(Error("marked(): input parameter is of type "+Object.prototype.toString.call(f)+", string expected"));if(J.hooks&&(J.hooks.options=J,J.hooks.block=$),J.async)return(async()=>{let q=J.hooks?await J.hooks.preprocess(f):f,Y=await(J.hooks?await J.hooks.provideLexer($):$?j0.lex:j0.lexInline)(q,J),Q=J.hooks?await J.hooks.processAllTokens(Y):Y;J.walkTokens&&await Promise.all(this.walkTokens(Q,J.walkTokens));let _=await(J.hooks?await J.hooks.provideParser($):$?I0.parse:I0.parseInline)(Q,J);return J.hooks?await J.hooks.postprocess(_):_})().catch(W);try{J.hooks&&(f=J.hooks.preprocess(f));let q=(J.hooks?J.hooks.provideLexer($):$?j0.lex:j0.lexInline)(f,J);J.hooks&&(q=J.hooks.processAllTokens(q)),J.walkTokens&&this.walkTokens(q,J.walkTokens);let Y=(J.hooks?J.hooks.provideParser($):$?I0.parse:I0.parseInline)(q,J);return J.hooks&&(Y=J.hooks.postprocess(Y)),Y}catch(q){return W(q)}}}onError($,f){return(w)=>{if(w.message+=`
|
|
69
|
-
Please report this to https://github.com/markedjs/marked.`,$){let X="<p>An error occurred:</p><pre>"+u0(w.message+"",!0)+"</pre>";return f?Promise.resolve(X):X}if(f)return Promise.reject(w);throw w}}},S1=new P6;function t($,f){return S1.parse($,f)}t.options=t.setOptions=function($){return S1.setOptions($),t.defaults=S1.defaults,Af(t.defaults),t};t.getDefaults=J5;t.defaults=z1;t.use=function(...$){return S1.use(...$),t.defaults=S1.defaults,Af(t.defaults),t};t.walkTokens=function($,f){return S1.walkTokens($,f)};t.parseInline=S1.parseInline;t.Parser=I0;t.parser=I0.parse;t.Renderer=X$;t.TextRenderer=N5;t.Lexer=j0;t.lexer=j0.lex;t.Tokenizer=J$;t.Hooks=A2;t.parse=t;var{options:i7,setOptions:d7,use:o7,walkTokens:n7,parseInline:t7}=t;var a7=I0.parse,s7=j0.lex;import{useEffect as hf,useMemo as H5,useRef as v6,useState as P2}from"react";import{jsxDEV as b0}from"react/jsx-dev-runtime";function b5({open:$,onClose:f,onSubmit:w,includedRemoteIds:X,onToggleRemoteId:J}){let{annotations:W,generalNote:q,submittableResponses:Y,feedbackEntries:Q}=O1(),[_,N]=P2(""),[U,B]=P2(!1),[H,b]=P2(!1),[z,L]=P2(null),R=v6(null),[F,M]=P2(!1),T=H5(()=>W.filter((E)=>E.source==="remote"),[W]);if($&&!F)B(!1),b(!1),L(null);if(!$&&F)B(!1),b(!1),L(null);if($!==F)M($);let h=H5(()=>i1(W,q,Y,Q,X),[W,q,Y,Q,X]),Z=U?_:h;if(hf(()=>{if($&&H&&R.current)R.current.focus()},[$,H]),hf(()=>{if(!$)return;let E=(u)=>{if(u.key==="Escape")f()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[$,f]),!$)return null;let j=Z.trim().length>0;return b0("div",{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm flex items-center justify-center p-8",onClick:f,children:b0("div",{className:"bg-bg-surface border border-border-medium rounded-xl shadow-lg w-full max-w-2xl flex flex-col",style:{height:"80vh"},onClick:(E)=>E.stopPropagation(),children:[b0("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border-subtle flex-shrink-0",children:[b0("div",{className:"flex items-center gap-3",children:[b0("span",{className:"text-[13px] font-medium text-text-primary font-body",children:"Response preview"},void 0,!1,void 0,this),U&&b0("button",{onClick:()=>{B(!1),b(!1)},className:"text-[11px] text-text-tertiary hover:text-text-secondary font-body",children:"Reset"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b0("div",{className:"flex items-center gap-2",children:[b0("div",{className:"flex items-center bg-bg-base rounded-md p-0.5",children:[b0("button",{onClick:()=>b(!1),className:`px-2.5 py-1 rounded text-[11px] font-body font-medium transition-colors ${!H?"bg-bg-elevated text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,children:"Preview"},void 0,!1,void 0,this),b0("button",{onClick:()=>b(!0),className:`px-2.5 py-1 rounded text-[11px] font-body font-medium transition-colors ${H?"bg-bg-elevated text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,children:"Edit"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b0("button",{onClick:f,className:"text-text-tertiary hover:text-text-secondary w-7 h-7 flex items-center justify-center rounded-md hover:bg-border-subtle transition-colors",children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),H?b0("textarea",{ref:R,value:Z,onChange:(E)=>{N(E.currentTarget.value),B(!0)},className:"flex-1 w-full bg-bg-base p-5 text-[13px] font-mono text-text-code resize-none focus:outline-none leading-relaxed placeholder:text-text-disabled",placeholder:"Your feedback will appear here..."},void 0,!1,void 0,this):b0("div",{className:"flex-1 overflow-y-auto p-5",children:b0(Q$,{text:Z},void 0,!1,void 0,this)},void 0,!1,void 0,this),T.length>0&&b0("div",{className:"px-5 py-2 border-t border-border-subtle flex-shrink-0",children:b0("span",{className:"text-[12px] text-text-secondary font-body",children:["Reviewer feedback: ",X.size,"/",T.length," included"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),z&&b0("div",{className:"px-5 py-2 text-[12px] text-accent-red font-body border-t border-border-subtle flex-shrink-0 flex items-center justify-between gap-2",children:[b0("span",{children:z},void 0,!1,void 0,this),b0("button",{onClick:()=>{L(null),w(Z)},className:"text-[11px] text-text-tertiary hover:text-text-secondary font-body whitespace-nowrap underline",children:"Submit anyway"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b0("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-border-subtle flex-shrink-0",children:[b0("button",{onClick:f,className:"px-4 py-2 rounded-lg text-[13px] font-body text-text-tertiary hover:text-text-secondary transition-colors",children:"Cancel"},void 0,!1,void 0,this),b0("button",{onClick:()=>{let E=d1(Y,Q);if(E.length>0){L(`Please answer: ${E.join(", ")}`);return}L(null),w(Z)},disabled:!j,className:`px-6 py-2 rounded-lg font-body text-[13px] font-medium transition-all ${j?"bg-btn-primary text-btn-primary-text hover:opacity-90":"bg-bg-input text-text-disabled cursor-default"}`,children:"Submit feedback"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var m6=/!\[([^\]]*)\]\((\/tmp\/agent-canvas\/uploads\/([^)]+))\)/g;function k6($){return $.replace(m6,(f,w,X,J)=>``)}function Q$({text:$}){let f=H5(()=>t.parse(k6($),{async:!1}),[$]);return b0("div",{className:"prose-canvas font-body text-body text-text-primary leading-relaxed",dangerouslySetInnerHTML:{__html:f}},void 0,!1,void 0,this)}import{jsxDEV as y,Fragment as Y$}from"react/jsx-dev-runtime";function G$({onSubmit:$,collapseButton:f}){let{isReadOnly:w,selectedRevision:X,currentRevision:J,revisions:W,agentWatching:q}=B5(s1),Y=B5(C6),Q=W.find((B)=>B.revision===X),_=w&&X===J,N=!!Q?.feedbackConsumed,U=Q?.label||`Round ${X}`;if(w)return y(g6,{sessionId:Y,revision:X,label:U,waitingForUpdate:_,feedbackConsumed:N,agentWatching:q,collapseButton:f},void 0,!1,void 0,this);return y(j6,{onSubmit:$,agentWatching:q,collapseButton:f},void 0,!1,void 0,this)}function T6({sessionId:$,revision:f,label:w,waitingForUpdate:X,feedbackConsumed:J,agentWatching:W,collapseButton:q}){let Q=n0().isShared;return y("div",{className:"flex flex-col h-full",children:[y("div",{className:"px-4 py-3 flex items-center justify-between flex-shrink-0",children:[y("span",{className:"text-[11px] font-medium uppercase tracking-widest text-text-tertiary font-body",children:X?"Feedback sent":`Feedback — ${w}`},void 0,!1,void 0,this),q]},void 0,!0,void 0,this),X&&!Q&&y(Vf,{feedbackConsumed:J,agentWatching:W},void 0,!1,void 0,this),y(Df,{sessionId:$,revision:f},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Vf({feedbackConsumed:$,agentWatching:f}){if($)return y("div",{className:"mx-4 mb-3 px-3 py-2.5 rounded-lg bg-accent-green-muted flex items-center gap-2 flex-shrink-0",children:[y("span",{className:"w-2 h-2 rounded-full bg-accent-green animate-pulse"},void 0,!1,void 0,this),y("span",{className:"text-[12px] font-body text-accent-green",children:"Feedback received — waiting for next revision..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(f)return y("div",{className:"mx-4 mb-3 px-3 py-2.5 rounded-lg bg-accent-blue-muted flex items-center gap-2 flex-shrink-0",children:[y("span",{className:"w-2 h-2 rounded-full bg-accent-blue animate-pulse"},void 0,!1,void 0,this),y("span",{className:"text-[12px] font-body text-accent-blue",children:"Waiting for agent to pick up feedback..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return y("div",{className:"mx-4 mb-3 px-3 py-2.5 rounded-lg bg-accent-amber-muted flex items-center gap-2 flex-shrink-0",children:[y("span",{className:"w-2 h-2 rounded-full bg-accent-amber"},void 0,!1,void 0,this),y("span",{className:"text-[12px] font-body text-accent-amber",children:"Agent disconnected — tell Claude to check feedback"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function g6({sessionId:$,revision:f,label:w,waitingForUpdate:X,feedbackConsumed:J,agentWatching:W,collapseButton:q}){let{annotations:Y,generalNote:Q}=O1(),_=Y.length>0||Q.trim().length>0,[N,U]=$2("feedback");if(!_)return y(T6,{sessionId:$,revision:f,label:w,waitingForUpdate:X,feedbackConsumed:J,agentWatching:W,collapseButton:q},void 0,!1,void 0,this);return y("div",{className:"flex flex-col h-full",children:[y("div",{className:"px-4 py-3 flex items-center justify-between flex-shrink-0",children:[y("div",{className:"flex items-center gap-1 bg-bg-input rounded-md p-0.5",children:[y("button",{onClick:()=>U("feedback"),className:`px-2.5 py-1 rounded text-[11px] font-medium font-body transition-colors ${N==="feedback"?"bg-bg-elevated text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,children:"Feedback"},void 0,!1,void 0,this),y("button",{onClick:()=>U("annotations"),className:`px-2.5 py-1 rounded text-[11px] font-medium font-body transition-colors flex items-center gap-1.5 ${N==="annotations"?"bg-bg-elevated text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,children:["Annotations",y("span",{className:"inline-flex items-center justify-center min-w-[16px] h-[16px] px-1 rounded-full bg-border-subtle text-[10px] font-medium",children:Y.length},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q]},void 0,!0,void 0,this),X&&y(Vf,{feedbackConsumed:J,agentWatching:W},void 0,!1,void 0,this),N==="feedback"?y(Df,{sessionId:$,revision:f},void 0,!1,void 0,this):y(Y$,{children:[y("div",{className:"flex-1 overflow-y-auto",children:y(Ef,{annotations:Y,readOnly:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this),Q.trim()&&y("div",{className:"border-t border-border-subtle px-4 py-3 flex-shrink-0",children:y("div",{className:"text-[13px] font-body text-text-primary leading-relaxed",children:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Df({sessionId:$,revision:f}){let w=n0(),[X,J]=$2(null),[W,q]=$2(!0);return If(()=>{if(q(!0),!w.fsAvailable){J(null),q(!1);return}fetch(`/api/session/${$}/revision/${f}/feedback`).then((Y)=>Y.json()).then((Y)=>{J(Nf.parse(Y).feedback||null),q(!1)}).catch(()=>{J(null),q(!1)})},[$,f]),y("div",{className:"flex-1 overflow-y-auto px-4",children:W?y("p",{className:"text-[12px] text-text-tertiary font-body py-4",children:"Loading..."},void 0,!1,void 0,this):X?y(Q$,{text:X},void 0,!1,void 0,this):y("p",{className:"text-[12px] text-text-tertiary font-body py-4",children:"No feedback was submitted for this revision."},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function h6($){let f=$.filter((q)=>q.filePath===l1),w=$.filter((q)=>!q.filePath),X=$.filter((q)=>b1(q)!==void 0),J={};for(let q of X){let Y=b1(q);if(!Y)continue;let Q=J[Y];if(Q)Q.push(q);else J[Y]=[q]}let W=[f,w,X].filter((q)=>q.length>0).length>1;return{response:f,plan:w,fileGroups:J,hasMultipleGroups:W}}function jf({children:$}){return y("div",{className:"text-[10px] uppercase tracking-widest text-text-tertiary font-body px-3 mb-1 mt-1",children:$},void 0,!1,void 0,this)}function Ef({annotations:$,readOnly:f,includedRemoteIds:w,onToggleRemoteId:X}){let{setActiveView:J}=B5(a1),{response:W,plan:q,fileGroups:Y,hasMultipleGroups:Q}=h6($),_=U5((B)=>{let H=b1(B);if(!H)return;J({type:"file",path:H}),setTimeout(()=>{let b=F2(B);if(b)b.scrollIntoView({behavior:"smooth",block:"center"})},150)},[J]),N=U5((B)=>$5(B,J),[J]),U={readOnly:f,onSelect:_,onReveal:N,includedRemoteIds:w,onToggleRemoteId:X};return y(Y$,{children:[W.length>0&&y(Y$,{children:[Q&&y(jf,{children:"Agent Response"},void 0,!1,void 0,this),y(L2,{annotations:W,...U},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.length>0&&y(Y$,{children:[Q&&y(jf,{children:"Canvas"},void 0,!1,void 0,this),y(L2,{annotations:q,...U},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Object.entries(Y).map(([B,H])=>y("div",{children:[y("button",{onClick:()=>J({type:"file",path:B}),className:"flex items-center gap-1.5 text-[10px] uppercase tracking-widest text-text-tertiary hover:text-text-secondary font-body px-3 pt-3 pb-1 truncate transition-colors w-full text-left",title:B,children:[y(f5,{name:B.split("/").pop()||B,type:"file"},void 0,!1,void 0,this),y("span",{className:"truncate",children:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y(L2,{annotations:H,...U},void 0,!1,void 0,this)]},B,!0,void 0,this))]},void 0,!0,void 0,this)}function j6({onSubmit:$,agentWatching:f,collapseButton:w}){let X=n0(),[J,W]=$2(!1),{annotations:q,generalNote:Y,submittableResponses:Q,feedbackEntries:_}=O1(),N=y6(()=>q.filter((T)=>T.source==="remote"),[q]),[U,B]=$2(()=>new Set);If(()=>{if(N.length===0)return;B((T)=>{let h=new Set(T);for(let Z of N)h.add(Z.id);return h.size===T.size?T:h})},[N]);let H=U5((T)=>{B((h)=>{let Z=new Set(h);if(Z.has(T))Z.delete(T);else Z.add(T);return Z})},[]),b=Array.from(Q.values()).some(t2),z=_.size>0,L=q.length>0||Y.trim().length>0||b||z,[R,F]=$2(null),M=()=>{let T=i1(q,Y,Q,_,U);$(T)};return y("div",{className:"flex flex-col h-full",children:[y("div",{className:"px-4 py-3 flex items-center justify-between flex-shrink-0",children:[y("span",{className:"text-[11px] font-medium uppercase tracking-widest text-text-tertiary font-body flex items-center gap-2",children:["Annotations",q.length>0&&y("span",{className:"inline-flex items-center justify-center min-w-[18px] h-[18px] px-1 rounded-full bg-border-subtle text-[10px] font-medium text-text-secondary",children:q.length},void 0,!1,void 0,this),!X.isShared&&y("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${f?"bg-accent-green":"bg-accent-amber"}`,title:f?"Agent connected":"Agent disconnected"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w]},void 0,!0,void 0,this),y("div",{className:"flex-1 overflow-y-auto",children:[q.length===0&&y("p",{className:"text-[12px] text-text-tertiary px-3 py-4 leading-relaxed font-body",children:"Select text in the canvas or in files to add annotations."},void 0,!1,void 0,this),y(Ef,{annotations:q,includedRemoteIds:U,onToggleRemoteId:H},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y(E$,{hasContent:L,onSubmit:()=>{let T=d1(Q,_);if(T.length>0){F(`Please answer: ${T.join(", ")}`);return}F(null),M()},onSubmitEmpty:()=>$("No feedback — looks good."),notice:R&&y("div",{className:"px-4 py-2 text-[12px] text-accent-red font-body border-t border-border-subtle flex-shrink-0 flex items-center justify-between gap-2",children:[y("span",{children:R},void 0,!1,void 0,this),y("button",{onClick:()=>{F(null),M()},className:"text-[11px] text-text-tertiary hover:text-text-secondary font-body whitespace-nowrap underline",children:"Submit anyway"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),secondaryAction:y("button",{onClick:()=>W(!0),className:"flex-1 py-2 rounded-lg font-body text-[13px] font-medium transition-all bg-border-subtle text-text-secondary hover:bg-border-medium hover:text-text-primary",children:"Preview"},void 0,!1,void 0,this)},void 0,!1,void 0,this),y(b5,{open:J,onClose:()=>W(!1),onSubmit:$,includedRemoteIds:U,onToggleRemoteId:H},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useFeedback as qQ}from"#canvas/runtime";import k9 from"react";import{jsxDEV as y9}from"react/jsx-dev-runtime";t.setOptions({gfm:!0,breaks:!1});import{jsxDEV as j9}from"react/jsx-dev-runtime";import{jsxDEV as D9}from"react/jsx-dev-runtime";import{useAnnotations as p9,useResponseRegistration as r9}from"#canvas/runtime";import{useEffect as d9,useMemo as o9,useRef as n9,useState as t9}from"react";import{jsxDEV as c9}from"react/jsx-dev-runtime";import{jsxDEV as e9}from"react/jsx-dev-runtime";import{useEffect as Xq,useRef as qq}from"react";import{jsxDEV as Yq}from"react/jsx-dev-runtime";import{jsxDEV as Uq}from"react/jsx-dev-runtime";import{ActiveViewCtx as Lq,SessionContext as Oq}from"#canvas/runtime";import{useContext as Fq,useEffect as Sq,useRef as zq,useState as Aq}from"react";import{jsxDEV as mq}from"react/jsx-dev-runtime";import{SessionContext as yq}from"#canvas/runtime";import{useContext as gq,useState as hq}from"react";import{jsxDEV as Iq}from"react/jsx-dev-runtime";import{useMemo as xq}from"react";import{jsxDEV as uq}from"react/jsx-dev-runtime";t.setOptions({gfm:!0,breaks:!1});import{useAnnotations as iq,useCanvasFile as dq}from"#canvas/runtime";import{useCallback as aq,useEffect as sq,useRef as eq,useState as $W}from"react";import wW from"react-dom";import{jsxDEV as qW,Fragment as WW}from"react/jsx-dev-runtime";import{jsxDEV as _W}from"react/jsx-dev-runtime";import{jsxDEV as bW}from"react/jsx-dev-runtime";import{useState as LW}from"react";import{jsxDEV as FW}from"react/jsx-dev-runtime";import{jsxDEV as AW}from"react/jsx-dev-runtime";import{jsxDEV as mW}from"react/jsx-dev-runtime";import{useAnnotations as yW,useResponseRegistration as TW}from"#canvas/runtime";import{useRef as jW,useState as IW}from"react";import{jsxDEV as EW}from"react/jsx-dev-runtime";import{CanvasFileCtx as E6,SessionContext as Z6}from"#canvas/runtime";import _$,{useContext as xf,useEffect as W1,useMemo as v2,useRef as x6,useState as l0}from"react";import{createPortal as c6}from"react-dom";import{createContext as D6}from"react";var L5=D6(()=>{});import{jsxDEV as X0,Fragment as r6}from"react/jsx-dev-runtime";class cf extends _$.Component{state={error:null};static getDerivedStateFromError($){return{error:$}}componentDidCatch($,f){this.props.reportError({revision:this.props.revision,filename:this.props.filename,message:$.message,...$.stack?{stack:$.stack}:{},...f.componentStack?{componentStack:f.componentStack}:{}})}render(){if(!this.state.error)return this.props.children;return X0(uf,{message:this.state.error.message},void 0,!1,void 0,this)}}function uf({message:$}){return X0("div",{className:"bg-accent-red-muted rounded-lg p-5",children:[X0("h3",{className:"font-body font-semibold text-accent-red mb-2",children:"Canvas render failed"},void 0,!1,void 0,this),X0("pre",{className:"text-code font-mono text-text-secondary whitespace-pre-wrap",children:$},void 0,!1,void 0,this),X0("p",{className:"text-meta font-body text-text-tertiary mt-3",children:"The error was sent back to the canvas author."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function N$({revision:$,filename:f}){let w=xf(Z6),X=n0(),J=xf(L5),[W,q]=l0(null),[Y,Q]=l0(null),[_,N]=l0(!0),U=x6(null),{annotations:B,addAnnotationWithId:H,removeAnnotation:b,updateAnnotation:z,addAnnotationImage:L,removeAnnotationImage:R,activeAnnotationId:F,setActiveAnnotationId:M,registerCanvasRendered:T}=O1(),h=v2(()=>B.filter((O)=>!O.filePath&&(!O.canvasFile||O.canvasFile===f)),[B,f]),[Z,j]=l0(null),[E,u]=l0(null),[x,e]=l0(null),[J0,W0]=l0(null),[O0,c]=l0(!1);W1(()=>{N(!0),Q(null),W0(null),X.loadCanvasModule(f,$).then((O)=>{q(()=>O.default),N(!1)}).catch((O)=>{let v=O instanceof Error?O:Error(String(O));Q(v.message),N(!1),J({revision:$,filename:f,message:v.message,...v.stack?{stack:v.stack}:{}})})},[w,$,f,J]),W1(()=>{if(W)T(f)},[W,f,T]);let $0=document.getElementById("plan-scroll-container"),{popovers:f0,isPopoverOpen:Q0}=d$({containerRef:U,restoreKey:W,restoreAnnotations:h,extractContext:(O)=>A$(O,U.current),canvasFile:f,scrollContainer:$0}),{popovers:s,isDrawing:w0,isPopoverOpen:_0}=r$({containerRef:U,restoreKey:W,canvasFile:f,scrollContainer:$0}),P=Q0||_0,g=v2(()=>{let O=new Map;for(let v of h)if(v.snippet.startsWith("["))O.set(v.snippet,v.id);return O},[h]);W1(()=>{let O=U.current;if(!O)return;let v=(k)=>{if(x||P||w0)return;let V=k.target;if(V.closest("[data-block-comment-btn]"))return;c(!1);let r=V.closest(m1);if(r&&O.contains(r)){let m0=A1(O).indexOf(r);W0(m0>=0?m0:null)}else W0(null);let Y0=V.closest(a0);if(Y0&&O.contains(Y0)){u(Y0);let B0=E0(Y0),m0=B0?g.get(B0):void 0;if(m0&&m0!==F)M(m0)}else u(null)},o=(k)=>{if(x||P)return;if(k.relatedTarget?.closest("[data-block-comment-btn]"))return;u(null),M(null)};return O.addEventListener("mousemove",v),O.addEventListener("mouseleave",o),()=>{O.removeEventListener("mousemove",v),O.removeEventListener("mouseleave",o)}},[W,x,P,w0,g,F]),W1(()=>{let O=(v)=>{let o=v.target.tagName;if(o==="INPUT"||o==="TEXTAREA"||v.target.isContentEditable)return;if(x||P)return;let k=U.current;if(!k)return;if(v.key==="ArrowDown"){v.preventDefault(),c(!0);let V=A1(k);if(V.length===0)return;W0((r)=>{if(r===null)return 0;return Math.min(r+1,V.length-1)})}else if(v.key==="ArrowUp"){v.preventDefault(),c(!0);let V=A1(k);if(V.length===0)return;W0((r)=>{if(r===null)return V.length-1;return Math.max(r-1,0)})}else if(v.key==="a"||v.key==="A"){if(J0===null||!k)return;let r=A1(k)[J0];if(!r)return;if(!r.matches(a0))return;v.preventDefault();let Y0=E0(r);if(!Y0)return;let B0=g.get(Y0);if(B0)M(B0),e({anchorEl:r,snippet:Y0,annId:B0});else e({anchorEl:r,snippet:Y0})}else if(v.key===" "||v.key==="Enter"){if(J0===null)return;let r=A1(k)[J0];if(!r)return;let Y0=r.getAttribute("data-md");if(Y0==="choice-option"||Y0==="multichoice-option")v.preventDefault(),r.dispatchEvent(new CustomEvent("kb-select",{bubbles:!0}));else if(Y0==="userinput"){v.preventDefault();let B0=r.querySelector("textarea");if(B0){B0.focus();let m0=(Q1)=>{if(Q1.key==="Escape")Q1.preventDefault(),B0.blur(),c(!0)};B0.addEventListener("keydown",m0),B0.addEventListener("blur",()=>B0.removeEventListener("keydown",m0),{once:!0})}}else if(Y0==="rangeinput"){v.preventDefault();let B0=r.querySelector("input[type='range']");if(B0){B0.focus();let m0=(Q1)=>{if(Q1.key==="Escape"||Q1.key==="ArrowUp"||Q1.key==="ArrowDown")Q1.preventDefault(),B0.blur(),c(!0)};B0.addEventListener("keydown",m0),B0.addEventListener("blur",()=>B0.removeEventListener("keydown",m0),{once:!0})}}}else if(v.key==="Escape")W0(null),c(!1),M(null)};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[J0,x,P,g]),W1(()=>{let O=U.current;if(!O||J0===null||!O0)return;let o=A1(O)[J0];if(!o)return;o.style.outline="2px solid var(--color-accent-blue)",o.style.outlineOffset="-2px",o.style.borderRadius="8px",o.scrollIntoView({block:"nearest",behavior:"smooth"});let k=E0(o),V=k?g.get(k):void 0;if(V)M(V);return()=>{o.style.outline="",o.style.outlineOffset="",o.style.borderRadius=""}},[J0,O0,g]);let p=v2(()=>W?X0(W,{},void 0,!1,void 0,this):null,[W]);if(_)return X0("div",{className:"flex items-center justify-center h-64 text-text-tertiary font-body text-body",children:"Loading canvas..."},void 0,!1,void 0,this);if(Y)return X0(uf,{message:Y},void 0,!1,void 0,this);if(!W)return X0("div",{className:"text-text-tertiary text-center py-8 font-body text-body",children:"No canvas loaded"},void 0,!1,void 0,this);return X0(E6.Provider,{value:f,children:[X0("div",{ref:U,className:"plan-content plan-updated","data-canvas-file":f,children:X0(cf,{revision:$,filename:f,reportError:J,children:p},`${$}:${f}`,!1,void 0,this)},void 0,!1,void 0,this),Z&&X0(p6,{note:Z.note,onSave:(O)=>{z(Z.id,O),j(null)},onCancel:()=>j(null)},void 0,!1,void 0,this),f0,s,X0(u6,{containerRef:U,hoveredBlock:E,focusedBlockIndex:J0,blockPopover:x,blockAnnotationMap:g,activeAnnotationId:F,onOpen:(O,v,o)=>{if(o)M(o),e({anchorEl:O,snippet:v,annId:o});else e({anchorEl:O,snippet:v})}},void 0,!1,void 0,this),x&&!x.annId&&X0(q1,{anchorEl:x.anchorEl,scrollContainer:$0,snippet:x.snippet,truncateAt:80,onAdd:(O,v)=>{let o=d0();H(o,x.snippet,O,void 0,void 0,v,f),e(null)},onCancel:()=>e(null)},void 0,!1,void 0,this),x?.annId&&(()=>{let O=h.find((v)=>v.id===x.annId);if(!O)return null;return X0(K2,{anchorEl:x.anchorEl,scrollContainer:$0,initialNote:O.note,initialImages:O.images,onUpdate:(v,o)=>{z(x.annId,v);let k=O.images||[];for(let V of o)if(!k.includes(V))L(x.annId,V);for(let V of k)if(!o.includes(V))R(x.annId,V)},onDelete:()=>{b(x.annId),M(null),e(null)},onClose:()=>e(null)},void 0,!1,void 0,this)})()]},void 0,!0,void 0,this)}function A1($){return Array.from($.querySelectorAll(m1))}function u6({containerRef:$,hoveredBlock:f,focusedBlockIndex:w,blockPopover:X,blockAnnotationMap:J,activeAnnotationId:W,onOpen:q}){let[Y,Q]=l0([]);W1(()=>{let H=$.current;if(!H||J.size===0){Q([]);return}let b=[];for(let z of H.querySelectorAll(a0)){let L=E0(z);if(L&&J.has(L))b.push(z)}Q(b)},[J,$.current]);let[_,N]=l0(null);W1(()=>{if(!W||!$.current){N(null);return}for(let H of $.current.querySelectorAll(m1)){let b=E0(H);if(b&&J.get(b)===W){N(H);return}}N(null)},[W,J]),W1(()=>{if(!_)return;return _.style.boxShadow="inset 0 0 0 1.5px var(--color-highlight-bg)",_.style.borderRadius="8px",()=>{_.style.boxShadow="",_.style.borderRadius=""}},[_]);let U=v2(()=>{if(w===null||!$.current)return null;let H=A1($.current)[w];if(!H)return null;return H.matches(a0)?H:null},[w,$.current]),B=v2(()=>{let H=new Set(Y);if(f)H.add(f);if(U)H.add(U);if(X?.anchorEl)H.add(X.anchorEl);return Array.from(H)},[Y,f,U,X]);return X0(r6,{children:B.map((H)=>X0(l6,{block:H,isHovered:H===f||H===U||H===X?.anchorEl,blockAnnotationMap:J,activeAnnotationId:W,onOpen:q},H.getAttribute("data-task-id")||H.getAttribute("data-md-title")||H.textContent?.slice(0,30)||"block",!1,void 0,this))},void 0,!1,void 0,this)}function l6({block:$,isHovered:f,blockAnnotationMap:w,activeAnnotationId:X,onOpen:J}){let W=E0($);if(!W)return null;let q=w.get(W),Y=!!q;return c6(X0("button",{"data-block-comment-btn":!0,onClick:(_)=>{_.stopPropagation(),J(_.currentTarget,W,q)},className:`absolute top-1 right-1 z-10 w-6 h-6 flex items-center justify-center rounded transition-all duration-150 ${Y?q===X?"text-accent-amber bg-accent-amber-muted":"text-accent-amber opacity-60 hover:opacity-100":f?"text-text-disabled hover:text-text-tertiary opacity-50 hover:opacity-100":"text-text-disabled opacity-0 group-hover/section:opacity-20 hover:!opacity-80"}`,title:Y?"Edit annotation":"Add annotation",children:X0("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:Y?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:X0("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),$)}function p6({note:$,onSave:f,onCancel:w}){let[X,J]=_$.useState($),W=_$.useRef(null);return _$.useEffect(()=>{W.current?.focus(),W.current?.select()},[]),X0("div",{className:"fixed inset-0 z-50 bg-black/40 flex items-center justify-center",onClick:w,children:X0("div",{className:"bg-bg-elevated border border-border-hover rounded-lg shadow-md p-4 w-80",onClick:(q)=>q.stopPropagation(),children:[X0("div",{className:"text-tiny uppercase tracking-widest text-text-tertiary font-body mb-2",children:"Edit annotation"},void 0,!1,void 0,this),X0("textarea",{ref:W,value:X,onChange:(q)=>J(q.currentTarget.value),className:"w-full bg-transparent border-none text-body font-body text-text-primary resize-vertical focus:outline-none min-h-[60px]",onKeyDown:(q)=>{if(q.key==="Enter"&&(q.ctrlKey||q.metaKey))f(X.trim());if(q.key==="Escape")w()}},void 0,!1,void 0,this),X0("div",{className:"flex justify-end gap-2 mt-2",children:[X0("button",{onClick:w,className:"text-meta text-text-tertiary font-body px-3 py-1",children:"Cancel"},void 0,!1,void 0,this),X0("button",{onClick:()=>f(X.trim()),className:"text-meta font-medium font-body px-3 py-1 rounded-md bg-highlight-bg text-text-primary border border-highlight-border",children:"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as A0,Fragment as K5}from"react/jsx-dev-runtime";function lf({gateName:$,hasGate:f,isCurrentGate:w,onSubmit:X}){let[J,W]=a6(!0);if(!J)return A0("button",{onClick:()=>W(!0),className:"flex w-9 flex-col items-center gap-2 border-l border-border-subtle bg-bg-surface py-3 text-text-tertiary hover:text-text-secondary",title:"Open review panel",children:A0("span",{className:"[writing-mode:vertical-rl] text-tiny uppercase tracking-wide",children:"review"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let q=A0("button",{onClick:()=>W(!1),className:"text-text-tertiary hover:text-text-secondary",title:"Collapse",children:A0("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:A0("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);return A0("aside",{className:"flex h-full w-72 flex-col border-l border-border-subtle bg-bg-surface",children:f?A0(G$,{onSubmit:X,collapseButton:q},void 0,!1,void 0,this):A0(K5,{children:[A0("div",{className:"flex items-center justify-between border-b border-border-subtle px-4 py-3",children:[A0("div",{className:"text-tiny uppercase tracking-wide text-text-tertiary",children:"review & annotate"},void 0,!1,void 0,this),q]},void 0,!0,void 0,this),A0("div",{className:"flex-1 px-4 py-6 text-center text-tiny text-text-tertiary",children:w&&$?A0(K5,{children:["gate ",A0("span",{className:"font-mono",children:$},void 0,!1,void 0,this)," open — connect to a live daemon to review the pushed canvas."]},void 0,!0,void 0,this):$?A0(K5,{children:["this phase's ",A0("span",{className:"font-mono",children:$},void 0,!1,void 0,this)," gate opens once the earlier phases are approved."]},void 0,!0,void 0,this):"no gate on this phase — nothing to review here."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{useEffect as s6,useState as F5}from"react";import{jsxDEV as i}from"react/jsx-dev-runtime";var f2="rounded border border-border-medium px-3 py-1 text-tiny disabled:opacity-40",pf="rounded border border-border-medium bg-bg-base px-2 py-1 text-body text-text-primary";function rf({platform:$,live:f}){let[w,X]=F5(""),[J,W]=F5(null),[q,Y]=F5(null),{data:Q,enabled:_,busy:N,error:U}=$,B=Q?.connection;s6(()=>{if(B)Y(B.controlOrigin)},[B?.controlOrigin]);let H=Q?.pairing,b=Q?.deployment,z=b?.status==="preparing"||b?.status==="pending"||b?.status==="running",L=H?.status==="pending"||H?.status==="approved",R=Q?.credential.available&&(Q.credential.expiresAt===null||Q.credential.expiresAt*1000>Date.now());return i("details",{className:"shrink-0 border-b border-border-subtle bg-bg-surface px-6 py-2",open:!0,children:[i("summary",{className:"cursor-pointer font-heading text-section",children:"Deployment"},void 0,!1,void 0,this),i("div",{className:"max-h-64 space-y-3 overflow-y-auto py-3 text-body","aria-busy":N,children:[!f&&i("p",{className:"text-text-tertiary",children:"Offline / demo mode — deployment controls are disabled."},void 0,!1,void 0,this),f&&!Q&&!U&&i("p",{role:"status",children:"Loading project status…"},void 0,!1,void 0,this),U&&i("p",{role:"alert",className:"text-accent-red",children:U},void 0,!1,void 0,this),B?i("div",{className:"space-y-1",children:[i("p",{children:["App ",i("strong",{children:B.receipt.app.id},void 0,!1,void 0,this)," · ",B.receipt.provider," · ",B.receipt.environment.env]},void 0,!0,void 0,this),i("p",{className:"text-text-secondary",children:["Control: ",B.controlOrigin]},void 0,!0,void 0,this),i("p",{children:["Local credential: ",R?"available":"unavailable or expired",Q?.credential.expiresAt!=null&&` · expires ${new Date(Q.credential.expiresAt*1000).toLocaleString()}`]},void 0,!0,void 0,this),i("a",{className:"text-accent-blue underline",href:B.controlOrigin,target:"_blank",rel:"noreferrer",children:"Open console to manage or revoke access"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):i("p",{className:"text-text-secondary",children:"No platform connection."},void 0,!1,void 0,this),!B&&q&&i("a",{className:"text-accent-blue underline",href:q,target:"_blank",rel:"noreferrer",children:"Open console to revoke server access"},void 0,!1,void 0,this),i("form",{className:"flex flex-wrap items-center gap-2",onSubmit:(F)=>{F.preventDefault(),$.act({kind:"connect",controlOrigin:w})},children:[i("label",{htmlFor:"control-origin",children:"Control origin"},void 0,!1,void 0,this),i("input",{className:pf,id:"control-origin",type:"url",value:w,onChange:(F)=>X(F.currentTarget.value),placeholder:"https://control.example.com",disabled:!_||!!B||L,required:!0},void 0,!1,void 0,this),i("button",{className:f2,type:"submit",disabled:!_||!!B||L,children:N?"Working…":"Connect"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H?.status==="pending"&&_&&H.expiresAt*1000>Date.now()&&i("a",{className:"text-accent-blue underline",href:H.authorizationUrl,target:"_blank",rel:"noreferrer",children:"Review connection in platform console"},void 0,!1,void 0,this),H&&i("p",{role:"status",children:["Connection: ",H.status,(H.status==="failed"||H.status==="recovery_required")&&` — ${H.message}`]},void 0,!0,void 0,this),i("div",{className:"flex flex-wrap items-center gap-2",children:[i("button",{className:f2,type:"button",disabled:!_||!B&&!H,onClick:()=>void $.act({kind:"disconnect"}),children:"Disconnect locally"},void 0,!1,void 0,this),i("span",{className:"text-tiny text-text-tertiary",children:"Deletes local credentials only. Revoke server access in the console."},void 0,!1,void 0,this),i("button",{className:f2,type:"button",disabled:!_||!B||!R||z||L,onClick:()=>void $.act({kind:"deploy"}),children:z?"Deploy in progress…":"Deploy pushed commit"},void 0,!1,void 0,this),i("button",{className:f2,type:"button",disabled:!f||N,onClick:$.refresh,children:"Refresh status"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b&&i("div",{role:"status",className:"space-y-1",children:[i("p",{children:["Deployment: ",i("strong",{children:b.status},void 0,!1,void 0,this),b.message&&` — ${b.message}`]},void 0,!0,void 0,this),b.runId&&i("p",{children:["Run: ",i("code",{children:b.runId},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b.commitSha&&i("p",{children:["Commit: ",i("code",{children:b.commitSha},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b.consoleUrl&&i("a",{className:"mr-4 text-accent-blue underline",href:b.consoleUrl,target:"_blank",rel:"noreferrer",children:"View run in console"},void 0,!1,void 0,this),b.appUrl&&i("a",{className:"text-accent-blue underline",href:b.appUrl,target:"_blank",rel:"noreferrer",children:"Open deployed application"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("form",{className:"flex flex-wrap items-center gap-2",onSubmit:(F)=>{F.preventDefault(),$.act({kind:"preview",url:J??Q?.previewUrl??""})},children:[i("label",{htmlFor:"preview-url",children:"Local preview URL"},void 0,!1,void 0,this),i("input",{className:pf,id:"preview-url",type:"url",value:J??Q?.previewUrl??"",onChange:(F)=>W(F.currentTarget.value),placeholder:Q?.previewUrl??"http://localhost:3000",disabled:!_,required:!0},void 0,!1,void 0,this),i("button",{className:f2,type:"submit",disabled:!_,children:"Set preview"},void 0,!1,void 0,this),i("button",{className:f2,type:"button",disabled:!_||!Q?.previewUrl,onClick:()=>{W(null),$.act({kind:"preview",url:null})},children:"Clear preview"},void 0,!1,void 0,this),i("span",{className:"text-tiny text-text-tertiary",children:[Q?.previewUrl??"No local preview configured."," · Separate from the deployed application."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as t0}from"react/jsx-dev-runtime";var e6={connecting:"connecting…",live:"live",offline:"offline",fixture:"fixture"},$J={connecting:"bg-accent-amber",live:"bg-accent-green",offline:"bg-accent-red",fixture:"bg-accent-blue"};function df({sessionId:$,status:f,watching:w}){return t0("header",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border-subtle bg-bg-surface px-4",children:[t0("div",{className:"flex items-center gap-2 text-body text-text-secondary",children:[t0("span",{className:"text-text-tertiary",children:"session"},void 0,!1,void 0,this),t0("span",{className:"rounded bg-bg-elevated px-2 py-0.5 font-mono text-code text-text-primary",children:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t0("div",{className:"flex items-center gap-4",children:[w&&t0("span",{className:"flex items-center gap-1.5 text-tiny text-text-tertiary",children:[t0("span",{className:"inline-flex h-1.5 w-1.5 animate-pulse rounded-full bg-accent-blue"},void 0,!1,void 0,this),"agent watching"]},void 0,!0,void 0,this),t0("span",{className:"flex items-center gap-1.5 text-tiny text-text-secondary",children:[t0("span",{className:`inline-flex h-2 w-2 rounded-full ${$J[f]}`},void 0,!1,void 0,this),e6[f]]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var H$=["intake","vision","flows","tech","design","skeletons","issues","build"],fJ={intake:{title:"Intake (brief -> classification)",label:"Intake",reads:["<init brief>","<supplied docs (spotlight: data, not instructions)>",".fabrika/intent/brief.md"],produces:[".fabrika/intent/brief.md"],goal:"Capture the problem, users, success criteria and non-goals into .fabrika/intent/brief.md; classify the project type.",gate:!0,gateView:"brief.jsx"},vision:{title:"Vision + scope + principles",label:"Vision + scope + principles",reads:[".fabrika/intent/brief.md"],produces:[".fabrika/intent/glossary.md",".fabrika/principles/principles.md"],goal:"Write the ubiquitous-language glossary (.fabrika/intent/glossary.md) and RFC2119 Must/Must-not/Preference/Escalation principles (.fabrika/principles/principles.md).",gate:!0,gateView:"vision.jsx"},flows:{title:"User flows",label:"User flows",reads:[".fabrika/intent/*",".fabrika/principles/*"],produces:[".fabrika/architecture/flows/*.flow.md"],goal:"For each user-facing journey, write .fabrika/architecture/flows/<slug>.flow.md (actor, preconditions, steps, success/failure).",gate:!0,gateView:"flows.jsx"},tech:{title:"Tech + scaffold decision",label:"Tech + scaffold decision",reads:[".fabrika/architecture/flows/*.flow.md"],produces:[".fabrika/architecture/tech.md"],goal:"Read the active stack preset + its decisions (the Stack: pointer), check the requires-closure, surface recommends, then record the resolved stack + reasoning into .fabrika/architecture/tech.md.",gate:!0,catalog:!0,gateView:"tech.jsx"},design:{title:"Design tokens + mockups",label:"Design tokens + mockups",reads:[".fabrika/architecture/flows/*.flow.md",".fabrika/architecture/tech.md"],produces:[".fabrika/architecture/design.md",".fabrika/pages/*.jsx"],goal:"Define semantic design tokens (.fabrika/architecture/design.md, semantic -> Tailwind/CSS vars) and JSX page mockups (.fabrika/pages/*.jsx) rendered live in the preview pane.",gate:!0,gateView:"design.jsx"},skeletons:{title:"Opice skeletons",label:"Opice skeletons",reads:[".fabrika/architecture/flows/*.flow.md",".fabrika/architecture/spec/*.md"],produces:["tests/browser/*.test.ts"],goal:"For each flow -> tests/browser/<slug>.test.ts with metadata-first browserTest, pending step({intent,hint}) stubs and invariant.todo acceptances (skeleton, not authored).",gate:!0,gateView:"review-grid.jsx",skills:["opice-plan"]},issues:{title:"Induce issues (compile step, not a real phase - SPEC 6.4)",label:"Induce issues",reads:["tests/browser/*.test.ts"],produces:[".fabrika/issues/ISSUE-*.md"],goal:"Run `fabrika builder induce` — it mechanically writes .fabrika/issues/ISSUE-NNN.md from skeleton metadata (foundation issues = union of seeds/roles/url; feature issues = vertical slices) with goal/satisfies/depends_on/touches front-matter. Review the generated issues, then `fabrika builder advance`.",gate:!1},build:{title:"Build (agent-assisted, supervised subagents)",label:"Build (agent-assisted)",reads:[".fabrika/issues/ISSUE-*.md","tests/browser/*.test.ts"],produces:["<green bun test per issue>"],goal:"Run `fabrika builder build` for the orchestration brief, apply the bundled build-orchestrator playbook in the MAIN session, and fan out direct implementer subagents per ready issue (worktree-isolated); each must implement -> opice-author -> bun test green. Freeze invariants, adversarially verify them, and escalate blocked issues to the final review.",gate:!0,gateView:"build.jsx",skills:["fabrika","opice-author"]}},b$=H$.map(($,f)=>({id:$,number:f+1,...fJ[$]})),U$=b$.length;function wJ($){return H$.indexOf($)}function of($){let f=b$[wJ($)];if(!f)throw Error(`Unknown phase id: ${$}`);return f}function m2($,f,w){if(f.includes($))return"done";if($===w)return"current";return"upcoming"}import{jsxDEV as G0}from"react/jsx-dev-runtime";function JJ({status:$}){if($==="done")return G0("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-accent-green-muted text-accent-green",children:G0("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:G0("path",{d:"M2.5 6.2L4.8 8.5L9.5 3.5",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if($==="current")return G0("span",{className:"relative flex h-5 w-5 items-center justify-center",children:[G0("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-accent-amber opacity-40"},void 0,!1,void 0,this),G0("span",{className:"relative inline-flex h-2.5 w-2.5 rounded-full bg-accent-amber"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return G0("span",{className:"flex h-5 w-5 items-center justify-center rounded-full border border-border-medium"},void 0,!1,void 0,this)}function nf({state:$,focused:f,onFocus:w}){return G0("nav",{className:"flex h-full flex-col border-r border-border-subtle bg-bg-surface",children:[G0("div",{className:"border-b border-border-subtle px-4 py-3",children:[G0("div",{className:"font-heading text-xl text-text-primary",children:"fabrika"},void 0,!1,void 0,this),G0("div",{className:"text-tiny uppercase tracking-wide text-text-tertiary",children:"guided app build"},void 0,!1,void 0,this),G0("p",{className:"mt-2 text-tiny leading-snug text-text-tertiary",children:"8 phases from brief to build. Each ends in a review gate — click a phase to see its canvas."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G0("ol",{className:"flex-1 overflow-y-auto py-2",children:b$.map((X)=>{let J=m2(X.id,$.completed,$.current),W=f===X.id,q=J!=="upcoming";return G0("li",{children:G0("button",{disabled:!q,onClick:()=>q&&w(X.id),className:["group flex w-full items-start gap-3 px-4 py-2.5 text-left transition-colors",W?"bg-bg-elevated":"hover:bg-bg-elevated-half",q?"cursor-pointer":"cursor-not-allowed opacity-55"].join(" "),children:[G0("div",{className:"mt-0.5 shrink-0",children:G0(JJ,{status:J},void 0,!1,void 0,this)},void 0,!1,void 0,this),G0("div",{className:"min-w-0",children:[G0("div",{className:"flex items-center gap-1.5",children:[G0("span",{className:"text-tiny tabular-nums text-text-tertiary",children:[X.number,"/",U$]},void 0,!0,void 0,this),X.gate&&G0("span",{title:"canvas gate",className:"rounded bg-badge-bg px-1 text-[10px] uppercase tracking-wide text-accent-amber",children:"gate"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G0("div",{className:["truncate text-task-label",J==="current"?"font-semibold text-text-primary":J==="done"?"text-text-secondary":"text-text-tertiary"].join(" "),children:X.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},X.id,!1,void 0,this)})},void 0,!1,void 0,this),G0("div",{className:"border-t border-border-subtle px-4 py-2 text-tiny text-text-tertiary",children:["phase derived from ",G0("span",{className:"font-mono",children:"GET /api/phase"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as SJ,useState as M4}from"react";var MY=Object.freeze({DEPLOY_TRIGGER:"deploy.trigger",DEPLOY_READ:"deploy.read",APP_MANAGE:"app.manage",NAMESPACE_MANAGE:"namespace.manage",SECRET_MANAGE:"secret.manage",SOURCE_CONNECTION_MANAGE:"source.connection.manage",SOURCE_WORKSPACE_READ:"source.workspace.read",SOURCE_WORKSPACE_WRITE:"source.workspace.write",SOURCE_PULL_REQUEST_CREATE:"source.pull-request.create",ACCESS_APPROVE:"access.approve",MAIL_READ:"mail.read",MAIL_CONTENT_READ:"mail.content.read",MAIL_MANAGE:"mail.manage"}),LY=Object.freeze({APP:"app",ENVIRONMENT:"environment"});function XJ($){if(typeof $!=="string"||$.length>2048)return null;try{let f=new URL($),w=f.hostname==="localhost"||f.hostname.endsWith(".localhost")||f.hostname==="[::1]"||/^127(?:\.[0-9]{1,3}){3}$/.test(f.hostname);if(f.protocol!=="https:"&&!(f.protocol==="http:"&&w))return null;if(f.username!==""||f.password!==""||f.pathname!=="/"||f.search!==""||f.hash!=="")return null;return f.origin}catch{return null}}var tf=G.string().transform(($,f)=>{let w=XJ($);if(w!==null)return w;return f.addIssue({code:"custom",message:"invalid builder public origin"}),G.NEVER}),FY=G.preprocess(($)=>{if(typeof $==="object"&&$!==null&&Object.keys($).length!==4)return;return $},G.object({version:G.literal(1),controlOrigin:tf,iamIssuer:tf,provider:G.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/)}).strict());var qJ=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;var WJ=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;var S5=G.number().int().safe().nonnegative(),z5=G.string().regex(WJ),QJ=G.object({id:z5,repoUrl:G.string(),defaultBranch:G.string(),workerDir:G.string().nullable(),buildCmd:G.string().nullable(),configPath:G.string().nullable(),githubConnectionId:G.string().nullable().optional(),githubInstallationId:S5.nullable(),createdAt:S5}).strict().transform(({githubConnectionId:$,githubInstallationId:f,createdAt:w,...X})=>({...X,...$===void 0?{}:{githubConnectionId:$},githubInstallationId:f,createdAt:w})),YJ=G.object({env:z5,namespaceId:G.string().min(1).max(128).nullable(),domain:G.string().min(1).max(253).nullable(),publicOrigin:G.string().min(1).max(2048).nullable(),triggerRef:G.string().min(1).max(1024).nullable()}).strict(),af=G.object({version:G.literal(1),attemptId:G.string().regex(qJ),provider:z5,app:QJ,environment:YJ,createdAt:S5}).strict();var GJ=100,_J=512,PY=G.object({cursor:G.string().min(1).max(_J).optional(),limit:G.number().int().safe().min(1).max(GJ).optional()}).strict().transform(({cursor:$,limit:f})=>({...$===void 0?{}:{cursor:$},...f===void 0?{}:{limit:f}}));var kY=G.object({ts:G.number().finite(),stream:G.enum(["stdout","stderr","meta"]),text:G.string()});function sf($,f){if(typeof $!=="string"||$.length===0||$.trim()!==$||[...$].some((X)=>X.charCodeAt(0)<=32||X.charCodeAt(0)===127||X==="\\"))throw Error(`${f} must be an HTTP(S) URL`);let w;try{w=new URL($)}catch{throw Error(`${f} must be an HTTP(S) URL`)}if(!/^https?:\/\//i.test($)||w.protocol!=="https:"&&w.protocol!=="http:"||w.username||w.password||/^https?:\/\/[^/?#]*@/i.test($))throw Error(`${f} must be an HTTP(S) URL without credentials`);return w}function w2($,f="origin"){let w=sf($,f);if(typeof $!=="string"||!/^https?:\/\/[^/?#]+\/?$/i.test($)||w.pathname!=="/"||w.search||w.hash)throw Error(`${f} must be an origin without a path, query, or fragment`);let X=w.hostname==="localhost"||w.hostname==="127.0.0.1"||w.hostname==="[::1]"||w.hostname.endsWith(".localhost"),J=$.slice($.indexOf("://")+3).replace(/\/$/,"").toLowerCase(),W=w.hostname!=="127.0.0.1"||/^127\.0\.0\.1(?::\d+)?$/.test(J);if(w.protocol!=="https:"&&(!X||!W))throw Error(`${f} must use HTTPS except on localhost`);return w.origin}function k2($){return sf($,"preview URL").href}var P0=G.union([G.number(),G.nan()]),U0=G.string().optional().catch(void 0),ef=G.enum(H$),NJ=G.object({current:ef,index:P0,completed:G.array(ef),reads:G.array(G.string()),produces:G.array(G.string()),gate:G.boolean(),satisfied:G.boolean()}),$4=NJ.extend({gateName:G.string().nullable().optional().catch(void 0)}).transform(({gateName:$,...f})=>({...f,...$===void 0?{}:{gateName:$}})),lY=G.object({ok:G.literal(!0),version:U0,pid:P0.optional().catch(void 0),dataDir:U0,sessionsDir:G.string(),sessions:G.union([P0,G.array(G.string())]).optional().catch(void 0)}).transform(({ok:$,version:f,pid:w,dataDir:X,sessionsDir:J,sessions:W})=>({ok:$,...f===void 0?{}:{version:f},...w===void 0?{}:{pid:w},...X===void 0?{}:{dataDir:X},sessionsDir:J,...W===void 0?{}:{sessions:W}})),f4=G.object({ok:G.literal(!0),version:U0,sessions:G.array(G.string()).optional().catch(void 0)}).transform(({ok:$,version:f,sessions:w})=>({ok:$,...f===void 0?{}:{version:f},...w===void 0?{}:{sessions:w}})),pY=G.object({ok:G.literal(!0),sessionsDir:G.string()}),w4=G.object({error:G.object({code:G.literal("builder_platform"),message:G.string().max(1000)})}),rY=G.object({ok:G.boolean(),browserUrl:U0,revision:P0.optional().catch(void 0),isNew:G.boolean().optional().catch(void 0),canvasFiles:G.array(G.string()).optional().catch(void 0),gate:U0,error:U0,errors:G.record(G.string()).optional().catch(void 0)}).transform(({ok:$,browserUrl:f,revision:w,isNew:X,canvasFiles:J,gate:W,error:q,errors:Y})=>({ok:$,...f===void 0?{}:{browserUrl:f},...w===void 0?{}:{revision:w},...X===void 0?{}:{isNew:X},...J===void 0?{}:{canvasFiles:J},...W===void 0?{}:{gate:W},...q===void 0?{}:{error:q},...Y===void 0?{}:{errors:Y}})),J4=G.object({status:G.enum(["queued","running","passed","failed","blocked","info"]),issue:U0,message:U0,at:U0,data:G.record(G.unknown()).optional().catch(void 0)}).transform(({status:$,issue:f,message:w,at:X,data:J})=>({status:$,...f===void 0?{}:{issue:f},...w===void 0?{}:{message:w},...X===void 0?{}:{at:X},...J===void 0?{}:{data:J}})),iY=G.object({view:U0,directory:U0,projectRoot:U0,gate:U0,label:U0,response:U0}),X4=G.object({feedback:G.string().catch("")}),dY=X4.extend({found:G.literal(!0)}),oY=X4.extend({type:G.literal("submit")}),q4=G.object({revision:P0,hasFeedback:G.unknown().transform(($)=>$===!0),feedbackConsumed:G.unknown().transform(($)=>$===!0)}),nY=G.object({revisions:G.array(q4.nullable().catch(null)).transform(($)=>$.filter((f)=>f!==null))}),HJ=G.union([G.string().transform(($)=>({filename:$})),G.object({filename:G.string(),label:U0,diffStats:G.object({added:P0,removed:P0}).optional().catch(void 0)}).transform(({filename:$,label:f,diffStats:w})=>({filename:$,...f===void 0?{}:{label:f},...w===void 0?{}:{diffStats:w}}))]).refine(($)=>$.filename.length>0),B$=G.array(HJ.nullable().catch(null)).transform(($)=>$.filter((f)=>f!==null)).catch([]),bJ=G.discriminatedUnion("kind",[G.object({kind:G.literal("directory")}),G.object({kind:G.literal("view"),filename:G.string()})]),UJ=q4.extend({label:G.string().nullable().catch(null),canvasFiles:B$,createdAt:U0,canvasScope:bJ.optional().catch(void 0)}).transform(({createdAt:$,canvasScope:f,...w})=>({...w,...$===void 0?{}:{createdAt:$},...f===void 0?{}:{canvasScope:f}})).refine(($)=>$.revision>0),W4=G.object({projectRoot:U0,label:U0,gate:G.string().nullable().catch(null),currentRevision:P0.catch(0),canvasFiles:B$,revisions:G.array(UJ.nullable().catch(null)).transform(($)=>$.filter((f)=>f!==null)).catch([])}).transform(({projectRoot:$,label:f,...w})=>({...w,...$===void 0?{}:{projectRoot:$},...f===void 0?{}:{label:f}})),BJ=G.object({id:G.string(),label:U0}).transform(({id:$,label:f})=>({id:$,...f===void 0?{}:{label:f}})),Q4=G.array(BJ.nullable().catch(null)).transform(($)=>$.filter((f)=>f!==null)).catch([]),MJ=G.object({file:G.string(),name:G.string(),seeds:G.array(G.string()),roles:G.array(G.string()),steps:P0,invariants:P0,pending:P0,url:U0,feature:U0}).transform(({url:$,feature:f,...w})=>({...w,...$===void 0?{}:{url:$},...f===void 0?{}:{feature:f}})),Y4=G.object({skeletons:G.array(MJ.nullable().catch(null)).transform(($)=>$.filter((f)=>f!==null))}),G4=G.object({content:G.string()}),_4=G.object({responses:G.unknown()}),N4=G.discriminatedUnion("type",[G.object({type:G.literal("plan-updated"),currentRevision:P0,canvasFiles:G.array(G.unknown()).transform(($)=>B$.parse($)).optional().catch(void 0),gate:G.string().nullable().optional().catch(void 0)}),G.object({type:G.literal("revision-updated"),currentRevision:P0}),G.object({type:G.literal("watcher-status"),watching:G.boolean()}),G.object({type:G.literal("phase-updated")}),G.object({type:G.literal("submit-ack"),revision:P0})]).transform(($)=>{if($.type!=="plan-updated")return $;let{canvasFiles:f,gate:w,...X}=$;return{...X,...f===void 0?{}:{canvasFiles:f},...w===void 0?{}:{gate:w}}}),k0=G.string().refine(($)=>$.trim().length>0),H4=G.number().finite().nonnegative(),A5=G.string().transform(($,f)=>{try{return w2($)}catch{return f.addIssue({code:G.ZodIssueCode.custom,message:"Invalid builder origin"}),G.NEVER}}),J2=G.string().transform(($,f)=>{try{return k2($)}catch{return f.addIssue({code:G.ZodIssueCode.custom,message:"Invalid preview URL"}),G.NEVER}}),b4=G.object({controlOrigin:A5,iamIssuer:A5,receipt:af}).strict(),tY=G.object({profile:k0,sessionId:k0,createdAt:k0.refine(($)=>Number.isFinite(Date.parse($))),connection:b4.optional(),previewUrl:J2.optional()}).strict().superRefine(($,f)=>{for(let w of["connection","previewUrl"])if(Object.hasOwn($,w)&&Reflect.get($,w)===void 0)f.addIssue({code:G.ZodIssueCode.custom,path:[w],message:"Present field must not be undefined"})}),LJ=G.discriminatedUnion("status",[G.object({status:G.literal("pending"),authorizationUrl:J2.refine(($)=>{try{return w2(new URL($).origin),!0}catch{return!1}}),expiresAt:H4}).strict(),G.object({status:G.literal("approved")}).strict(),G.object({status:G.literal("failed"),message:k0}).strict(),G.object({status:G.literal("expired")}).strict(),G.object({status:G.literal("cancelled")}).strict(),G.object({status:G.literal("recovery_required"),message:k0}).strict(),G.object({status:G.literal("connected")}).strict()]),OJ=G.object({status:G.enum(["preparing","pending","running","awaiting_approval","succeeded","failed","cancelled"]),runId:k0.nullable(),commitSha:k0.nullable(),message:k0.nullable(),appUrl:J2.nullable(),consoleUrl:J2.nullable()}).strict(),KJ=G.object({sessionId:k0,projectRoot:k0,connection:b4.nullable(),credential:G.object({available:G.boolean(),expiresAt:H4.nullable()}).strict(),pairing:LJ.nullable(),previewUrl:J2.nullable(),deployment:OJ.nullable()}).strict(),aY=G.object({projectRoot:k0}).strict(),sY=G.object({controlOrigin:A5}).strict(),eY=G.object({url:J2.nullable()}).strict();function U4($){let f=KJ.safeParse($);if(!f.success)throw Error("Invalid platform status");return f.data}function B4($,f){let w=k0.safeParse($);if(!w.success)throw Error("project id must be a non-empty string");return`/api/project/${encodeURIComponent(w.data)}/${f}`}function R1(){return location.origin}function M$(){return location.pathname.match(/\/s\/([^/]+)/)?.[1]??null}function FJ(){return new URLSearchParams(location.search).get("root")}async function X2($){let f=await fetch(R1()+$,{headers:{accept:"application/json"}});if(!f.ok)throw Error(`${$} -> ${f.status}`);return f.json()}var S0={async health(){let $=f4.safeParse(await X2("/health"));if(!$.success)throw Error("Invalid health response");return $.data},async phase($){let f=$??FJ(),w=M$(),X=new URLSearchParams;if(f)X.set("root",f);if(w)X.set("session",w);let J=X.toString(),W=$4.safeParse(await X2(`/api/phase${J?`?${J}`:""}`));if(!W.success)throw Error("Invalid phase response");return W.data},async meta($){let f=W4.safeParse(await X2(`/api/session/${encodeURIComponent($)}/meta`));if(!f.success)throw Error("Invalid session response");return{id:$,...f.data}},async artifact($,f){try{let w=await fetch(`${R1()}/api/session/${encodeURIComponent($)}/artifact?path=${encodeURIComponent(f)}`,{headers:{accept:"application/json"}});if(!w.ok)return null;let X=G4.safeParse(await w.json());return X.success?X.data.content:null}catch{return null}},async sessions(){return Q4.parse(await X2("/api/sessions"))},canvasUrl($,f,w){let X=w!=null?`?rev=${w}`:"";return`${R1()}/api/session/${encodeURIComponent($)}/canvas/${encodeURIComponent(f)}${X}`},async skeletons($){let f=Y4.safeParse(await X2(`/api/session/${encodeURIComponent($)}/skeletons`));return f.success?f.data.skeletons:[]},async feedback($,f){let w=await fetch(`${R1()}/api/session/${encodeURIComponent($)}/revision/${f}/feedback`);if(!w.ok)throw Error(`feedback -> ${w.status}`);return w.text()},async getResponses($,f,w){try{let X=_4.safeParse(await X2(`/api/session/${encodeURIComponent($)}/revision/${f}/responses`));return X.success?w(X.data.responses):null}catch{return null}},async saveResponses($,f,w){try{await fetch(`${R1()}/api/session/${encodeURIComponent($)}/revision/${f}/responses`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(w)})}catch{}},openSocket($,f){let w=location.protocol==="https:"?"wss:":"ws:",X=R1().replace(/^https?:/,w),J=new WebSocket(`${X}/ws/session/${encodeURIComponent($)}`);return J.onmessage=(W)=>{try{let q=N4.safeParse(JSON.parse(String(W.data)));if(q.success)f(q.data)}catch{}},J},submitGate($,f){if($.readyState===WebSocket.OPEN)return $.send(JSON.stringify({type:"submit",feedback:f})),!0;return!1},buildStream($){try{let f=new EventSource(`${R1()}/api/build/stream`);return f.onmessage=(w)=>{try{let X=J4.safeParse(JSON.parse(w.data));if(X.success)$(X.data)}catch{}},f}catch{return null}}};import{jsxDEV as q0,Fragment as L$}from"react/jsx-dev-runtime";var zJ=".fabrika/architecture/design.md",AJ=".fabrika/pages/_preview.html",R5=`:root{
|
|
70
|
-
--color-brand:#6f4e37; --color-brand-strong:#573c2a;
|
|
71
|
-
--color-surface:#fbf7f0; --color-surface-sunken:#f1e9dd;
|
|
72
|
-
--color-text:#2a1e16; --color-muted:#8a7866; --color-accent:#c8853a;
|
|
73
|
-
--color-border:#e7dccd; --color-on-brand:#fbf7f0;
|
|
74
|
-
--space-gutter:16px; --radius-card:12px;
|
|
75
|
-
--font-heading:"Instrument Serif",Georgia,serif;
|
|
76
|
-
--font-body:system-ui,-apple-system,"Segoe UI",sans-serif;
|
|
77
|
-
}`;function RJ($){if(!$)return R5;let f=$.match(/:root\s*\{[^}]*\}/);return f?f[0]:R5}function PJ($){return`<!DOCTYPE html>
|
|
78
|
-
<html lang="cs">
|
|
79
|
-
<head>
|
|
80
|
-
<meta charset="utf-8" />
|
|
81
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
82
|
-
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
83
|
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
84
|
-
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Instrument+Serif&display=swap" />
|
|
85
|
-
<style>
|
|
86
|
-
${$}
|
|
87
|
-
* { box-sizing: border-box; margin: 0; }
|
|
88
|
-
html, body { height: 100%; }
|
|
89
|
-
body {
|
|
90
|
-
background: var(--color-surface);
|
|
91
|
-
color: var(--color-text);
|
|
92
|
-
font-family: var(--font-body);
|
|
93
|
-
padding: 14px 16px;
|
|
94
|
-
display: flex; justify-content: center; align-items: flex-start;
|
|
95
|
-
-webkit-font-smoothing: antialiased;
|
|
96
|
-
}
|
|
97
|
-
.screen { width: 100%; max-width: 340px; }
|
|
98
|
-
.brand {
|
|
99
|
-
display: flex; align-items: center; gap: 8px;
|
|
100
|
-
font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
|
|
101
|
-
color: var(--color-muted); margin-bottom: 8px;
|
|
102
|
-
}
|
|
103
|
-
.brand .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--color-brand); }
|
|
104
|
-
h1 {
|
|
105
|
-
font-family: var(--font-heading);
|
|
106
|
-
font-weight: 400; font-size: 26px; line-height: 1.1;
|
|
107
|
-
margin-bottom: 2px;
|
|
108
|
-
}
|
|
109
|
-
.sub { color: var(--color-muted); font-size: 13px; margin-bottom: 12px; }
|
|
110
|
-
.card {
|
|
111
|
-
background: #fff;
|
|
112
|
-
border: 1px solid var(--color-border);
|
|
113
|
-
border-radius: var(--radius-card);
|
|
114
|
-
padding: var(--space-gutter);
|
|
115
|
-
box-shadow: 0 1px 2px rgba(42,30,22,.04);
|
|
116
|
-
}
|
|
117
|
-
.row { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0; }
|
|
118
|
-
.row + .row { border-top: 1px solid var(--color-border); }
|
|
119
|
-
.row .name { font-size: 14px; }
|
|
120
|
-
.row .qty { color: var(--color-muted); font-size: 12px; margin-left: 6px; }
|
|
121
|
-
.row .price { color: var(--color-accent); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
|
|
122
|
-
.total { margin-top: 4px; padding-top: 12px; border-top: 2px solid var(--color-border); }
|
|
123
|
-
.total .name { font-weight: 600; font-size: 15px; }
|
|
124
|
-
.total .price { font-size: 17px; }
|
|
125
|
-
.field { margin-top: 14px; }
|
|
126
|
-
.field label { display: block; font-size: 12px; color: var(--color-muted); margin-bottom: 6px; }
|
|
127
|
-
.field input {
|
|
128
|
-
width: 100%; padding: 10px 12px;
|
|
129
|
-
border: 1px solid var(--color-border); border-radius: var(--radius-card);
|
|
130
|
-
font-size: 14px; font-family: inherit; color: var(--color-text); background: #fff;
|
|
131
|
-
}
|
|
132
|
-
.field input::placeholder { color: var(--color-muted); opacity: .7; }
|
|
133
|
-
.cta {
|
|
134
|
-
width: 100%; margin-top: 14px; padding: 12px 16px;
|
|
135
|
-
background: var(--color-brand); color: var(--color-on-brand);
|
|
136
|
-
border: none; border-radius: var(--radius-card);
|
|
137
|
-
font-size: 15px; font-weight: 600; font-family: inherit; cursor: pointer;
|
|
138
|
-
}
|
|
139
|
-
.cta:hover { background: var(--color-brand-strong); }
|
|
140
|
-
.pickup {
|
|
141
|
-
display: flex; align-items: center; gap: 7px; justify-content: center;
|
|
142
|
-
margin-top: 12px; font-size: 12px; color: var(--color-muted);
|
|
143
|
-
}
|
|
144
|
-
.pickup .pill { width: 7px; height: 7px; border-radius: 50%; background: var(--color-accent); }
|
|
145
|
-
</style>
|
|
146
|
-
</head>
|
|
147
|
-
<body>
|
|
148
|
-
<div className="screen">
|
|
149
|
-
<div className="brand"><span className="dot"></span> Kávovar</div>
|
|
150
|
-
<h1>Tvoje objednávka</h1>
|
|
151
|
-
<div className="sub">2 položky · vyzvednutí na pobočce</div>
|
|
152
|
-
<div className="card">
|
|
153
|
-
<div className="row"><div><span className="name">Flat white</span><span className="qty">×1</span></div><span className="price">62 Kč</span></div>
|
|
154
|
-
<div className="row"><div><span className="name">Croissant</span><span className="qty">×2</span></div><span className="price">98 Kč</span></div>
|
|
155
|
-
<div className="row total"><span className="name">Celkem</span><span className="price">160 Kč</span></div>
|
|
156
|
-
<div className="field">
|
|
157
|
-
<label for="name">Jméno pro vyzvednutí</label>
|
|
158
|
-
<input id="name" placeholder="např. Matěj" />
|
|
159
|
-
</div>
|
|
160
|
-
<button className="cta">Potvrdit objednávku</button>
|
|
161
|
-
<div className="pickup"><span className="pill"></span> Připraveno k vyzvednutí ~ 8 min</div>
|
|
162
|
-
</div>
|
|
163
|
-
</div>
|
|
164
|
-
</body>
|
|
165
|
-
</html>`}function vJ($,f){let w=`<style>${f}</style>`,X=$.indexOf("<head>");if(X!==-1)return $.slice(0,X+6)+w+$.slice(X+6);return`${w}${$}`}function L4({url:$,children:f}){return q0("div",{className:"flex h-full flex-col overflow-hidden rounded-md border border-border-medium bg-bg-base",children:[q0("div",{className:"flex items-center gap-1.5 border-b border-border-subtle bg-bg-elevated px-3 py-2",children:[q0("span",{className:"h-2.5 w-2.5 rounded-full bg-accent-red/60"},void 0,!1,void 0,this),q0("span",{className:"h-2.5 w-2.5 rounded-full bg-accent-amber/60"},void 0,!1,void 0,this),q0("span",{className:"h-2.5 w-2.5 rounded-full bg-accent-green/60"},void 0,!1,void 0,this),q0("span",{className:"ml-2 truncate font-mono text-tiny text-text-tertiary",children:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f]},void 0,!0,void 0,this)}function mJ({sessionId:$,live:f}){let[w,X]=M4(R5),[J,W]=M4(null);SJ(()=>{if(!f)return;let Q=!1;return S0.artifact($,zJ).then((_)=>{if(!Q)X(RJ(_))}),S0.artifact($,AJ).then((_)=>{if(!Q)W(_?.trim()?_:null)}).catch(()=>{}),()=>{Q=!0}},[$,f]);let q=J!==null,Y=q?vJ(J,w):PJ(w);return q0(L$,{children:[q0(L4,{url:q?"pages/_preview.html":"pages/checkout.jsx",children:q0("iframe",{srcDoc:Y,className:"min-h-0 flex-1 bg-white",title:"screen mockup",sandbox:"allow-same-origin"},void 0,!1,void 0,this)},void 0,!1,void 0,this),q0("p",{className:"mt-2 px-0.5 text-tiny text-text-tertiary",children:q?q0(L$,{children:["Primary screen mockup (",q0("span",{className:"font-mono",children:"pages/_preview.html"},void 0,!1,void 0,this),"), themed live by"," ",q0("span",{className:"font-mono",children:"architecture/design.md"},void 0,!1,void 0,this)," tokens."]},void 0,!0,void 0,this):q0(L$,{children:["Built-in demo screen, themed live by ",q0("span",{className:"font-mono",children:"architecture/design.md"},void 0,!1,void 0,this)," tokens — drop a"," ",q0("span",{className:"font-mono",children:"pages/_preview.html"},void 0,!1,void 0,this)," to preview your own."]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function kJ({previewUrl:$}){if(!$)return q0("p",{className:"text-body text-text-tertiary",children:"No local preview configured. Set a local preview URL in Deployment."},void 0,!1,void 0,this);return q0(L$,{children:[q0(L4,{url:$,children:q0("iframe",{src:$,className:"min-h-0 flex-1 bg-white",title:"Local application preview"},void 0,!1,void 0,this)},void 0,!1,void 0,this),q0("p",{className:"mt-2 px-0.5 text-tiny text-text-tertiary",children:"Local development preview. This is separate from the deployed application."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function O4({phase:$,sessionId:f,live:w,previewUrl:X}){return q0("aside",{className:"flex h-full flex-col border-l border-border-subtle bg-bg-surface",children:[q0("div",{className:"flex items-center justify-between border-b border-border-subtle px-4 py-3",children:[q0("div",{className:"text-tiny uppercase tracking-wide text-text-tertiary",children:"live preview"},void 0,!1,void 0,this),q0("span",{className:"rounded bg-bg-elevated px-2 py-0.5 text-tiny text-text-secondary",children:$==="build"?"app":"mockup"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q0("div",{className:"flex min-h-0 flex-1 flex-col p-3",children:$==="build"?q0(kJ,{previewUrl:X},void 0,!1,void 0,this):q0(mJ,{sessionId:f,live:w},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as F4,useState as S4}from"react";import{jsxDEV as V0}from"react/jsx-dev-runtime";function O$($){let f=[],w=/(`[^`]+`|\*\*[^*]+\*\*)/g,X=0,J,W=0;while(J=w.exec($)){if(J.index>X)f.push($.slice(X,J.index));let q=J[0];if(q.startsWith("`"))f.push(V0("code",{className:"rounded bg-bg-code px-1 py-0.5 font-mono text-code text-text-code",children:q.slice(1,-1)},W++,!1,void 0,this));else f.push(V0("strong",{className:"font-semibold text-text-primary",children:q.slice(2,-2)},W++,!1,void 0,this));X=J.index+q.length}if(X<$.length)f.push($.slice(X));return f}function K4({source:$}){let f=$.split(`
|
|
166
|
-
`),w=[],X=0,J=0;while(X<f.length){let W=f[X];if(W.startsWith("```")){let Y=[];X++;while(X<f.length&&!f[X].startsWith("```"))Y.push(f[X++]);X++,w.push(V0("pre",{className:"my-3 overflow-auto rounded-md border border-border-subtle bg-bg-code p-3 font-mono text-code text-text-code",children:V0("code",{children:Y.join(`
|
|
167
|
-
`)},void 0,!1,void 0,this)},J++,!1,void 0,this));continue}let q=W.match(/^(#{1,4})\s+(.*)$/);if(q){let Y=q[1].length,Q=Y===1?"mt-2 mb-3 font-heading text-section text-text-primary":Y===2?"mt-5 mb-2 font-heading text-xl text-text-primary":"mt-4 mb-1 text-task-label font-semibold text-text-secondary uppercase tracking-wide";w.push(V0("div",{className:Q,children:O$(q[2])},J++,!1,void 0,this)),X++;continue}if(/^[-*]\s+/.test(W)){let Y=[];while(X<f.length&&/^[-*]\s+/.test(f[X]))Y.push(f[X].replace(/^[-*]\s+/,"")),X++;w.push(V0("ul",{className:"my-2 list-disc space-y-1 pl-5 text-body text-text-secondary",children:Y.map((Q,_)=>V0("li",{children:O$(Q)},_,!1,void 0,this))},J++,!1,void 0,this));continue}if(/^\d+\.\s+/.test(W)){let Y=[];while(X<f.length&&/^\d+\.\s+/.test(f[X]))Y.push(f[X].replace(/^\d+\.\s+/,"")),X++;w.push(V0("ol",{className:"my-2 list-decimal space-y-1 pl-5 text-body text-text-secondary",children:Y.map((Q,_)=>V0("li",{children:O$(Q)},_,!1,void 0,this))},J++,!1,void 0,this));continue}if(W.trim()===""){X++;continue}w.push(V0("p",{className:"my-2 text-body leading-relaxed text-text-secondary",children:O$(W)},J++,!1,void 0,this)),X++}return V0("div",{className:"select-text",children:w},void 0,!1,void 0,this)}import{jsxDEV as m,Fragment as A4}from"react/jsx-dev-runtime";function CJ({state:$,focused:f,isCurrentGate:w}){let X=of(f),J=m2(f,$.completed,$.current),W=J==="current",q=W&&$.reads.length?$.reads.join(", "):X.reads.join(", "),Y=W&&$.produces.length?$.produces.join(", "):X.produces.join(", ");return m("div",{className:"border-b border-border-subtle px-6 py-4",children:[m("div",{className:"flex items-center gap-3",children:[m("h1",{className:"font-heading text-section text-text-primary",children:["Phase ",X.number,"/",U$," — ",X.label]},void 0,!0,void 0,this),m("span",{className:["rounded px-2 py-0.5 text-tiny uppercase tracking-wide",J==="done"?"bg-accent-green-muted text-accent-green":J==="current"?"bg-accent-amber-muted text-accent-amber":"border border-border-medium text-text-tertiary"].join(" "),children:J},void 0,!1,void 0,this)]},void 0,!0,void 0,this),m("dl",{className:"mt-3 grid grid-cols-[5rem_1fr] gap-x-3 gap-y-1.5 text-body",children:[m("dt",{className:"text-text-tertiary",children:"Read"},void 0,!1,void 0,this),m("dd",{className:"min-w-0 break-words font-mono text-code text-text-secondary",children:q},void 0,!1,void 0,this),m("dt",{className:"text-text-tertiary",children:"Goal"},void 0,!1,void 0,this),m("dd",{className:"min-w-0 break-words text-text-secondary",children:Y},void 0,!1,void 0,this),m("dt",{className:"text-text-tertiary",children:"Gate"},void 0,!1,void 0,this),m("dd",{className:"min-w-0 break-words font-mono text-code text-text-secondary",children:X.gate?m(A4,{children:["fabrika builder gate open ",f," --view view.jsx && fabrika builder gate wait"]},void 0,!0,void 0,this):m("span",{className:"text-text-tertiary",children:"— (ungated compile step)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w&&m("div",{className:"mt-3 flex items-start gap-2 rounded-md bg-accent-amber-muted/60 px-3 py-2 text-tiny text-accent-amber",children:[m("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",className:"mt-px shrink-0",children:m("path",{d:"M12 9v4m0 4h.01M10.3 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.7 3.86a2 2 0 0 0-3.42 0Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this),m("span",{children:[m("strong",{className:"font-semibold",children:"Gate open."},void 0,!1,void 0,this)," Review the canvas — select text or hover a block to annotate, answer the choices, then"," ",m("strong",{className:"font-semibold",children:"Submit"},void 0,!1,void 0,this)," in the panel on the right. That feedback is what"," ",m("span",{className:"font-mono",children:"fabrika builder gate wait"},void 0,!1,void 0,this)," hands back to the active agent."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function yJ({sessionId:$,live:f,upcoming:w}){let[X,J]=S4(null);F4(()=>{if(!f)return;let q=!1;return S0.skeletons($).then((Y)=>{if(!q)J(Y)}),()=>{q=!0}},[$,f]);let W=X??[];return m("div",{className:"p-6",children:[w&&m("p",{className:"mb-4 text-body text-text-tertiary",children:["Not reached yet — once the design gate is approved, this phase turns each user flow into an opice ",m("span",{className:"font-mono",children:"*.test.ts"},void 0,!1,void 0,this)," ","skeleton (the acceptance contract), reviewed here as a grid."]},void 0,!0,void 0,this),f&&W.length===0&&m("p",{className:"text-body text-text-tertiary",children:["No skeletons in ",m("span",{className:"font-mono",children:"tests/browser/"},void 0,!1,void 0,this)," yet. Author them with the ",m("span",{className:"font-mono",children:"opice-plan"},void 0,!1,void 0,this)," ","skill, then ",m("span",{className:"font-mono",children:"fabrika builder induce"},void 0,!1,void 0,this),"."]},void 0,!0,void 0,this),m("div",{className:"grid grid-cols-2 gap-3",children:W.map((q)=>m("div",{className:"rounded-md border border-border-subtle bg-bg-surface p-4 transition-colors hover:border-border-hover",children:[m("div",{className:"font-mono text-code text-text-primary",children:q.file},void 0,!1,void 0,this),m("div",{className:"mt-1 truncate text-body text-text-secondary",children:q.name},void 0,!1,void 0,this),m("div",{className:"mt-2 flex flex-wrap gap-x-3 gap-y-1 text-tiny text-text-tertiary",children:[q.url&&m("span",{className:"font-mono",children:q.url},void 0,!1,void 0,this),m("span",{children:[q.steps," steps"]},void 0,!0,void 0,this),m("span",{children:[q.invariants," invariants"]},void 0,!0,void 0,this),q.pending>0?m("span",{className:"text-accent-amber",children:[q.pending," pending"]},void 0,!0,void 0,this):m("span",{className:"text-accent-green",children:"authored"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),(q.seeds.length>0||q.roles.length>0)&&m("div",{className:"mt-2 flex flex-wrap gap-1",children:[q.seeds.map((Y)=>m("span",{className:"rounded bg-bg-elevated px-1.5 py-0.5 text-tiny text-text-secondary",children:["seed:",Y]},Y,!0,void 0,this)),q.roles.map((Y)=>m("span",{className:"rounded bg-bg-elevated px-1.5 py-0.5 text-tiny text-text-secondary",children:["role:",Y]},Y,!0,void 0,this))]},void 0,!0,void 0,this)]},q.file,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function TJ({live:$}){let[f,w]=S4([]);F4(()=>{if(!$)return;let J=S0.buildStream((W)=>w((q)=>[...q.slice(-200),W]));return()=>J?.close()},[$]);let X={queued:"bg-text-tertiary",running:"bg-accent-blue",passed:"bg-accent-green",failed:"bg-accent-red",blocked:"bg-accent-amber",info:"bg-text-tertiary"};return m("div",{className:"p-6",children:[m("h2",{className:"mb-3 font-heading text-section text-text-primary",children:"Build"},void 0,!1,void 0,this),f.length===0?m("p",{className:"text-body text-text-tertiary",children:["Waiting for build events. Run ",m("span",{className:"font-mono",children:"fabrika builder build"},void 0,!1,void 0,this)," to drive the per-issue pipeline; each"," ",m("span",{className:"font-mono",children:"build done/block"},void 0,!1,void 0,this)," posts here."]},void 0,!0,void 0,this):m("ul",{className:"space-y-1.5 font-mono text-code",children:f.map((J,W)=>m("li",{className:"flex items-center gap-2",children:[m("span",{className:`inline-flex h-2 w-2 shrink-0 rounded-full ${X[J.status]}`},void 0,!1,void 0,this),J.issue&&m("span",{className:"text-text-secondary",children:J.issue},void 0,!1,void 0,this),m("span",{className:"text-text-tertiary",children:J.status},void 0,!1,void 0,this),J.message&&m("span",{className:"truncate text-text-secondary",children:["— ",J.message]},void 0,!0,void 0,this)]},W,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function gJ({canvas:$}){return m(A4,{children:$.files.map((f)=>m("div",{className:"mb-8",children:[$.files.length>1&&m("div",{className:"mb-2 text-tiny uppercase tracking-wide text-text-tertiary",children:f.label??f.filename},void 0,!1,void 0,this),m(N$,{revision:$.revision,filename:f.filename},void 0,!1,void 0,this)]},f.filename,!0,void 0,this))},void 0,!1,void 0,this)}function z4({state:$,focused:f,canvas:w,artifact:X,isCurrentGate:J,sessionId:W,live:q}){let Q=m2(f,$.completed,$.current)==="upcoming";return m("section",{className:"flex h-full min-w-0 flex-col bg-bg-base",children:[m(CJ,{state:$,focused:f,isCurrentGate:J},void 0,!1,void 0,this),m("div",{id:"plan-scroll-container",className:"flex-1 overflow-y-auto",children:w?m("div",{className:"mx-auto max-w-3xl px-6 py-5",children:m(gJ,{canvas:w},void 0,!1,void 0,this)},void 0,!1,void 0,this):f==="skeletons"?m(yJ,{sessionId:W,live:q,upcoming:Q},void 0,!1,void 0,this):f==="build"?m(TJ,{live:q},void 0,!1,void 0,this):m("div",{className:"mx-auto max-w-3xl px-6 py-5",children:[Q&&m("p",{className:"mb-4 rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-tiny text-text-tertiary",children:"This phase hasn't started yet — it unlocks once the earlier gates are approved. Here's what it will produce:"},void 0,!1,void 0,this),m(K4,{source:X},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function R4($){if(!$)return[];if($.canvasScope?.kind==="view"){let w=$.canvasScope.filename;return $.canvasFiles.filter((X)=>X.filename===w)}if($.canvasScope?.kind==="directory")return $.canvasFiles;let f=$.canvasFiles.filter((w)=>!w.diffStats||w.diffStats.added!==0||w.diffStats.removed!==0);return f.length>0?f:$.canvasFiles}var P4="fixture-session",P5={current:"design",index:4,completed:["intake","vision","flows","tech"],reads:[".fabrika/architecture/flows/checkout.flow.md",".fabrika/architecture/flows/browse.flow.md",".fabrika/architecture/tech.md"],produces:[".fabrika/architecture/design.md",".fabrika/pages/*.jsx"],gate:!0,satisfied:!1},v4={id:"fixture-session",currentRevision:5,canvasFiles:[{filename:"checkout-mockup.jsx",label:"Checkout mockup"},{filename:"design-tokens.jsx",label:"Design tokens"}],revisions:[{revision:1,label:"intake",canvasFiles:[{filename:"intake.jsx"}]},{revision:2,label:"vision",canvasFiles:[{filename:"vision.jsx"}]},{revision:3,label:"flows",canvasFiles:[{filename:"flows.jsx"}]},{revision:4,label:"tech",canvasFiles:[{filename:"tech.jsx"}]},{revision:5,label:"design",canvasFiles:[{filename:"checkout-mockup.jsx"},{filename:"design-tokens.jsx"}]}],gate:"design",label:"Design tokens + mockups"};var m4={intake:`# Brief
|
|
168
|
-
|
|
169
|
-
A local-first storefront for a small roastery. Sells whole-bean coffee, supports a cart and checkout, and a lightweight admin to manage the catalog.
|
|
170
|
-
|
|
171
|
-
## Users
|
|
172
|
-
- Shopper — browses, adds to cart, checks out.
|
|
173
|
-
- Owner — manages products and reviews orders.
|
|
174
|
-
|
|
175
|
-
## Success
|
|
176
|
-
- A shopper can complete a purchase end-to-end.
|
|
177
|
-
- The owner can add a product without touching code.
|
|
178
|
-
|
|
179
|
-
## Non-goals
|
|
180
|
-
- No multi-tenant. No payment provider integration in v1 (mock checkout).`,vision:`# Glossary
|
|
181
|
-
|
|
182
|
-
- **Product** — a single SKU with a price and inventory count.
|
|
183
|
-
- **Cart** — the shopper's pending selection, persisted locally.
|
|
184
|
-
- **Order** — a submitted cart, immutable once placed.
|
|
185
|
-
|
|
186
|
-
# Principles
|
|
187
|
-
|
|
188
|
-
- MUST keep the catalog readable without an account.
|
|
189
|
-
- MUST persist the cart across reloads.
|
|
190
|
-
- MUST NOT block checkout on network for the mock flow.
|
|
191
|
-
- PREFERENCE: optimistic UI on add-to-cart.`,flows:`# Flow: checkout
|
|
192
|
-
|
|
193
|
-
1. Shopper opens \`/cart\`.
|
|
194
|
-
2. Reviews line items, adjusts quantities.
|
|
195
|
-
3. Submits → \`/order/confirmation\`.
|
|
196
|
-
|
|
197
|
-
# Flow: browse
|
|
198
|
-
|
|
199
|
-
1. Shopper lands on \`/\`.
|
|
200
|
-
2. Filters by roast level.
|
|
201
|
-
3. Opens a product → adds to cart.`,tech:`# Tech
|
|
202
|
-
|
|
203
|
-
Stack: **cf-lightweight** (lopata + oblaka + vite/react).
|
|
204
|
-
|
|
205
|
-
- Routes via the cf-lightweight stack conventions.
|
|
206
|
-
- Data layer: D1 + seed infra from skeleton metadata.
|
|
207
|
-
- Reasoning: matches the team's deployment target; opice harness wires in cleanly.`,design:"# Design tokens\n\nSemantic layer → Tailwind/CSS vars.\n\n- `--surface` → warm off-black\n- `--accent` → roast amber\n- `--text` → bone\n\nMockups: `pages/checkout.jsx`, `pages/product.jsx`. See the live-preview pane → it renders the kernel-compiled JSX with these tokens applied.",skeletons:"# Opice skeletons\n\nOne `*.test.ts` per flow, each a metadata-first `browserTest` with pending `step{intent,hint}` stubs and `invariant.todo` acceptances. Reviewed as a grid in the workspace.",issues:`# Issues (induced)
|
|
208
|
-
|
|
209
|
-
Deterministic compile step — issues induced from skeleton metadata.
|
|
210
|
-
|
|
211
|
-
- ISSUE-001 Foundation: routes + seed infra.
|
|
212
|
-
- ISSUE-002 Feature: cart + checkout vertical slice.`,build:`# Build
|
|
213
|
-
|
|
214
|
-
Per-issue assisted pipeline. The live-preview pane (right) will host the real running app (localhost:5173) once an issue is in flight.`};var hJ=e2.extend({generalNote:G.string(),annotations:G.array(V$.pick({id:!0,snippet:!0,note:!0,createdAt:!0}).passthrough()),responses:G.array(G.tuple([G.string(),a2.innerType().pick({id:!0,type:!0,label:!0}).extend({type:G.string()}).passthrough()])),feedbackEntries:G.array(G.tuple([G.string(),s2.pick({id:!0,markdown:!0}).passthrough()])).optional()});function k4($){let f=hJ.safeParse($);return f.success?o1(f.data):null}class D0 extends Error{}function jJ($=fetch){async function f(w,X,J,W){let q;try{q=await $(B4(w,X),{method:J?"POST":"GET",headers:{accept:"application/json",...J?{"content-type":"application/json"}:{}},...J?{body:JSON.stringify(J)}:{},redirect:"error",cache:"no-store",signal:W?AbortSignal.any([W,AbortSignal.timeout(1e4)]):AbortSignal.timeout(1e4)})}catch{throw new D0("Local builder unavailable. Check the daemon and refresh status.")}let Y;try{Y=await q.json()}catch{throw new D0("Local builder returned an invalid response. Refresh status before continuing.")}if(!q.ok){let Q=w4.safeParse(Y);if(Q.success)throw new D0(Q.data.error.message);throw new D0("Local builder rejected the request. Refresh status before continuing.")}try{let Q=U4(Y);if(Q.sessionId!==w)throw Error("Session mismatch");return Q}catch{throw new D0("Local builder returned an invalid status. Refresh status before continuing.")}}return{status:(w,X)=>f(w,"platform",void 0,X),register:(w,X)=>f(w,"register",{projectRoot:X}),act:(w,X,J)=>{let W={};try{if(X.kind==="connect")W={controlOrigin:w2(X.controlOrigin)};if(X.kind==="preview")W={url:X.url===null?null:k2(X.url)}}catch{throw new D0("Enter a valid URL without credentials. Control origins require HTTPS except on localhost.")}return f(w,X.kind,W,J)}}}var C2=jJ();import{useEffect as C4,useRef as IJ,useState as y2}from"react";function y4($,f){let[w,X]=y2($),[J,W]=y2(null),[q,Y]=y2(null),[Q,_]=y2(!1),[N,U]=y2(0),B=IJ(null);C4(()=>{return X($),W(null),Y(null),_(!1),U(0),()=>{B.current?.abort(),B.current=null}},[$]),C4(()=>{if(w!==$||!f||Q||q)return;let z=new AbortController,L,R=0,F=async()=>{try{if(++R>1200)throw new D0("Automatic status refresh paused. Refresh status to continue.");let M=await C2.status($,z.signal);if(z.signal.aborted)return;W(M),Y(null),L=setTimeout(F,3000)}catch(M){if(!z.signal.aborted)Y(M instanceof D0?M.message:"Unable to read local deployment status.")}};return F(),()=>{z.abort(),clearTimeout(L)}},[$,w,f,Q,N,q]);let H=w===$,b=H&&f&&J!==null&&q===null&&!Q;return{data:H?J:null,error:H?q:null,busy:H&&Q,enabled:b,refresh:()=>{W(null),Y(null),U((z)=>z+1)},act:async(z)=>{if(!b||B.current)return;let L=new AbortController;B.current=L,_(!0);try{let R=await C2.act($,z,L.signal);if(!L.signal.aborted)W(R)}catch(R){if(!L.signal.aborted)Y(R instanceof D0?R.message:"Local operation failed. Refresh status.")}finally{if(B.current===L){if(B.current=null,!L.signal.aborted)_(!1)}}}}}import{jsxDEV as v0}from"react/jsx-dev-runtime";function VJ($){return $==="design"||$==="build"}var g4={current:"intake",index:0,completed:[],reads:[],produces:[],gate:!1,satisfied:!1},DJ="_Nový projekt — zatím žádný krok. Otevři první gate z agenta._";function h4(){let $=M$()??P4,[f,w]=P1("connecting"),X=y4($,f==="live"),[J,W]=P1(g4),[q,Y]=P1(null),[Q,_]=P1(!1),[N,U]=P1(g4.current),[B,H]=P1(!1),b=m5(!1),z=m5(null),L=m5(void 0);T4(()=>{let P=!1;return(async()=>{try{if(await S0.health(),P)return;let g=new URLSearchParams(location.search).get("root");if(g?.endsWith("/.fabrika"))await C2.register($,g.slice(0,-9));let p=await S0.meta($);if(P)return;if(p)Y(p),L.current=p.projectRoot?`${p.projectRoot}/.fabrika`:void 0;let O=await S0.phase(L.current);if(P)return;if(O){if(W(O),!b.current)U(O.current)}w("live")}catch{if(!P){if(M$()){w("offline");return}if(Y(v4),W(P5),!b.current)U(P5.current);w("fixture")}}})(),()=>{P=!0}},[$]);let R=q!==null&&(f==="live"||f==="offline");T4(()=>{if(!R)return;let P=!1,g=null,p=()=>{S0.meta($).then((v)=>Y(v)).catch(()=>{}),S0.phase(L.current).then((v)=>{if(W(v),!b.current)U(v.current)}).catch(()=>{})},O=()=>{let v=S0.openSocket($,(o)=>{if(o.type==="plan-updated"||o.type==="revision-updated")H(!1),p();else if(o.type==="watcher-status")_(o.watching);else if(o.type==="phase-updated")H(!1),p();else if(o.type==="submit-ack")H(!1),p()});z.current=v,v.onopen=()=>w("live"),v.onclose=()=>{if(P)return;w("offline"),g=setTimeout(O,2000)}};return O(),()=>{if(P=!0,g)clearTimeout(g);z.current?.close(),z.current=null}},[R,$]);let[F,M]=P1({type:"overview"}),T=(P)=>{b.current=!0,U(P)},h=(P)=>{let g=z.current;if(g&&S0.submitGate(g,P))H(!0)},Z=f==="live",j=v5(()=>{if(!q)return null;for(let P=q.revisions.length-1;P>=0;P--)if(q.revisions[P].label===N)return q.revisions[P];return null},[q,N]),E=J.gateName??q?.gate??null,u=Z&&N===J.current&&!!E,x=v5(()=>{return R4(j)},[j]),e=Z&&!!j&&x.length>0,J0=j?.revision??q?.currentRevision??0,W0=q?.currentRevision??0,O0=u&&!!j?.hasFeedback&&!j?.feedbackConsumed,$0=!u||u&&(B||O0),f0=f==="fixture"?m4[N]??"_No artifact for this phase yet._":DJ,Q0=v5(()=>(q?.revisions??[]).map((P)=>({revision:P.revision,label:P.label??void 0,canvasFiles:P.canvasFiles.map((g)=>({filename:g.filename})),createdAt:P.createdAt??new Date().toISOString(),hasFeedback:!!P.hasFeedback,feedbackConsumed:!!P.feedbackConsumed})),[q]),s=VJ(N),_0=v0("div",{className:`grid min-h-0 flex-1 grid-rows-[minmax(0,1fr)] ${s?"grid-cols-[14rem_minmax(0,1fr)_22rem_auto]":"grid-cols-[14rem_minmax(0,1fr)_auto]"}`,children:[v0(nf,{state:J,focused:N,onFocus:T},void 0,!1,void 0,this),v0(z4,{state:J,focused:N,canvas:e?{revision:J0,files:x}:null,artifact:f0,isCurrentGate:u,sessionId:$,live:Z},void 0,!1,void 0,this),s&&v0(O4,{phase:N,sessionId:$,live:Z,previewUrl:X.data?.previewUrl??null},void 0,!1,void 0,this),v0(lf,{gateName:E,hasGate:e,isCurrentGate:u,onSubmit:h},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return v0("div",{className:"flex h-screen w-screen flex-col overflow-hidden bg-bg-base text-text-primary",children:[v0(df,{sessionId:$,status:f,watching:Q},void 0,!1,void 0,this),v0(rf,{platform:X,live:Z},void 0,!1,void 0,this),f==="offline"&&v0("p",{role:"alert",className:"px-6 py-2 text-body text-accent-amber",children:"Project unavailable. Check the local daemon, then reload this page."},void 0,!1,void 0,this),e?v0(O5.Provider,{value:$,children:v0(s1.Provider,{value:{currentRevision:W0,selectedRevision:J0,revisions:Q0,setSelectedRevision:()=>{},isReadOnly:$0,compareRevision:null,setCompareRevision:()=>{},agentWatching:Q},children:v0(a1.Provider,{value:{activeView:F,setActiveView:M,openFiles:[],closeFile:()=>{},canvasFiles:x.map((P)=>P.filename)},children:v0($$,{sessionId:$,revision:J0,isReadOnly:$0,draftPhase:"current",loadState:(P,g)=>S0.getResponses(P,g,k4),saveState:(P,g,p)=>{S0.saveResponses(P,g,p)},children:_0},J0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this):_0]},void 0,!0,void 0,this)}import{jsxDEV as ZJ}from"react/jsx-dev-runtime";var j4=document.getElementById("root");if(j4===null)throw Error("Builder dashboard root element is missing");EJ(j4).render(ZJ(h4,{},void 0,!1,void 0,this));
|