@fabrika/builder 0.9.0-dev.5 → 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.
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
var a3=Object.defineProperty;var e3=($)=>$;function $6($,J){this[$]=e3.bind(null,J)}var J6=($,J)=>{for(var X in J)a3($,X,{get:J[X],enumerable:!0,configurable:!0,set:$6.bind(J,X)})};import{createRoot as j7}from"react-dom/client";import{useEffect as n3,useMemo as v5,useRef as m5,useState as j1}from"react";import{useState as f9}from"react";import{AnnotationCtx as xQ,AnnotationHostContext as hQ,SessionContext as vQ,useAnnotationHost as mQ,useAnnotations as cQ}from"@fabrika/annotations/runtime";function g2($,J){let X=[],Q=u5($);for(let W of Q){let Y=document.createRange();if(Y.selectNodeContents(W),W===$.startContainer)Y.setStart(W,$.startOffset);if(W===$.endContainer)Y.setEnd(W,$.endOffset);let q=Y.toString();if(!q||!q.trim())continue;let H=document.createElement("mark");H.setAttribute("data-annotation-id",J);try{Y.surroundContents(H)}catch{let G=Y.extractContents();H.appendChild(G),Y.insertNode(H)}X.push(H)}return X}function H2($){let J=$.parentElement;if(J?.classList.contains("select-none"))return!1;if(J?.closest("[data-annotation-id]"))return!1;return!0}function u5($){let J=[],X=$.commonAncestorContainer;if(X.nodeType===Node.TEXT_NODE)return J.push(X),J;let Q=document.createTreeWalker(X,NodeFilter.SHOW_TEXT),W;while(W=Q.nextNode()){if(!H2(W))continue;if($.intersectsNode(W))J.push(W)}return J}function X6($,J){let X=document.createRange();if(X.selectNodeContents($),$===J.startContainer)X.setStart($,J.startOffset);if($===J.endContainer)X.setEnd($,J.endOffset);return X.toString()}function p5($){let J="";for(let X of u5($))J+=X6(X,$);return J}function V1($,J){let X=document.querySelectorAll(`[data-annotation-id="${$}"]`);for(let Q of X)Q.classList.toggle("mark-active",J)}function k$($,J){if(J!=null&&J!==$)V1(J,!1);if($!=null)V1($,!0)}function A$($,J){let X=document.querySelectorAll(`[data-annotation-id="${$}"]`);for(let Q of X)Q.setAttribute("data-annotation-id",J)}function j$($,J){for(let X of J){if($.querySelector(`[data-annotation-id="${X.id}"]`))continue;let Q=X.snippet;if(!Q)continue;let{fullText:W,textNodes:Y}=Q6($),q=[],H=0;while(!0){let F=W.indexOf(Q,H);if(F===-1)break;q.push(F),H=F+1}let[G]=q;if(G===void 0)continue;let B=G;if(q.length>1&&X.context){let F=-1;for(let C of q){let _=0;if(X.context.before){let O=W.slice(Math.max(0,C-80),C);if(O.includes(X.context.before))_+=2;else if(X.context.before.length>10&&O.includes(X.context.before.slice(-10)))_+=1}if(X.context.after){let O=W.slice(C+Q.length,C+Q.length+80);if(O.includes(X.context.after))_+=2;else if(X.context.after.length>10&&O.includes(X.context.after.slice(0,10)))_+=1}if(_>F)F=_,B=C}}let N=B,f=B+Q.length,L=c5(Y,N),w=c5(Y,f);if(!L||!w)continue;try{let F=document.createRange();F.setStart(L.node,L.offset),F.setEnd(w.node,w.offset),g2(F,X.id)}catch{}}}function Q6($){let J=[],X="",Q=document.createTreeWalker($,NodeFilter.SHOW_TEXT),W;while(W=Q.nextNode()){if(!H2(W))continue;J.push({node:W,start:X.length}),X+=W.textContent||""}return{fullText:X,textNodes:J}}function c5($,J){for(let X=$.length-1;X>=0;X--){let Q=$[X];if(!Q||Q.start>J)continue;let W=J-Q.start,Y=Q.node.textContent?.length??0;if(W<=Y)return{node:Q.node,offset:W}}return null}function V$($){let J=document.querySelectorAll(`[data-annotation-id="${$}"]`);for(let X of J){let Q=X.parentNode;if(!Q)continue;if(X.tagName!=="MARK"){Q.removeChild(X);continue}while(X.firstChild)Q.insertBefore(X.firstChild,X);Q.removeChild(X),Q.normalize()}}function T$($,J){let X=l5($,"before",60),Q=l5($,"after",60),W=q6($.startContainer,J);return{before:X,after:Q,hierarchy:W}}function l5($,J,X){let Q=W6(J==="before"?$.startContainer:$.endContainer);if(!Q)return"";let W="";if(J==="before"){let Y=document.createTreeWalker(Q,NodeFilter.SHOW_TEXT),q;while(q=Y.nextNode()){if(q===$.startContainer){W+=(q.textContent||"").slice(0,$.startOffset);break}if(!H2(q))continue;W+=q.textContent||""}if(W.length>X){W=W.slice(-X);let H=W.indexOf(" ");if(H>0)W=W.slice(H+1)}}else{let Y=document.createTreeWalker(Q,NodeFilter.SHOW_TEXT),q=!1,H;while(H=Y.nextNode()){if(H===$.endContainer){W+=(H.textContent||"").slice($.endOffset),q=!0;continue}if(q){if(!H2(H))continue;W+=H.textContent||""}}if(W.length>X){W=W.slice(0,X);let G=W.lastIndexOf(" ");if(G>0)W=W.slice(0,G)}}return W.trim()}function W6($){let J=new Set(["DIV","P","LI","PRE","BLOCKQUOTE","SECTION","ARTICLE"]),X=$.parentElement;while(X){if(J.has(X.tagName))return X;X=X.parentElement}return null}function q6($,J){let X=[],Q=$ instanceof Element?$:$.parentElement;while(Q&&Q!==J){let W=Q.getAttribute?.("data-task-id");if(W){let q=Q.querySelector(".font-semibold");if(q)X.unshift(q.textContent?.trim()||W)}let Y=Y6(Q);if(Y)X.unshift(Y);Q=Q.parentElement}return X}function Y6($){if($.getAttribute("data-md")==="section"){let X=$.getAttribute("data-md-title");if(X)return X}if($.tagName!=="DIV")return null;return $.querySelector(":scope > button > .font-heading, :scope > div > .font-heading")?.textContent?.trim()||null}function y2($){let J=$.snippet.trim(),X=$.context,Q=J.length<30;if(X&&Q&&(X.before||X.after)){let W=[];if(X.before)W.push(`...${X.before} `);if(W.push(`**${J}**`),X.after)W.push(` ${X.after}...`);return W.join("")}return J}function U2($){return{kind:$.kind,owns:(J)=>$.parse(J)!==null,find:(J,X)=>{let Q=$.parse(J);return Q===null?null:$.find(Q,X)},restore:(J,X)=>{let Q=$.parse(X.snippet);if(Q===null)return;$.restore?.(Q,J,X)},describe:(J)=>{let X=$.parse(J);if(X===null||!$.describe)return null;return $.describe(X)}}}function d5($){let J=document.createTreeWalker($,NodeFilter.SHOW_TEXT),X="";for(let Q=J.nextNode();Q;Q=J.nextNode()){let W=Q.parentElement?.closest("[aria-hidden='true']");if(W&&$.contains(W))continue;X+=Q.textContent??""}return X.trim()}function E2($,J,X){return{selector:$,snippet:(Q)=>{let W=Q.getAttribute(X);return W?`${J} ${W}`:null}}}var Z$=[E2("[data-md='item']","[Item]","data-md-label"),E2("[data-md='section']","[Section]","data-md-title"),E2("[data-md='checklist-item']","[Checklist]","data-md-label"),E2("[data-md='image']","[Image]","data-md-src"),{selector:"[data-md='callout']",snippet:($)=>{return`[Callout:${$.getAttribute("data-md-type")||"info"}] ${d5($).slice(0,60)||"Callout"}`}},{selector:"[data-md='note']",snippet:($)=>`[Note] ${d5($).slice(0,60)||"Note"}`},{selector:"[data-md='table'] tbody tr",snippet:($)=>{let J=Array.from($.querySelectorAll("td")).map((X)=>X.textContent?.trim()).filter(Boolean);return J.length?`[Row] ${J.join(" | ")}`:null}}],G6=["[data-md='choice-option']","[data-md='multichoice-option']","[data-md='userinput']","[data-md='rangeinput']"],e0=Z$.map(($)=>$.selector).join(", "),T1=[...Z$.map(($)=>$.selector),...G6].join(", ");function v0($){for(let J of Z$)if($.matches(J.selector))return J.snippet($);return null}var b$={kind:"block",parse:($)=>$.startsWith("[")?{snippet:$}:null,format:($)=>$.snippet,find:($,J)=>{for(let X of J.querySelectorAll(e0)){if(!(X instanceof HTMLElement))continue;if(v0(X)===$.snippet)return X}return null}};var I$="data-annotation-image",H6=/^\[Region:(rect|ellipse)\] ([\s\S]+) @(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*)$/;function U6($){if($==="rect")return"rect";if($==="ellipse")return"ellipse";return null}function x2($){if($===void 0)return null;let J=Number($);if(!Number.isInteger(J)||J<0||J>1e4)return null;return J}function i5($){return Math.min(1e4,Math.max(0,$))}function g$($,J,X){if(!($.width>0)||!($.height>0))return null;return{x:i5(Math.round(J/$.width*1e4)),y:i5(Math.round(X/$.height*1e4))}}function v2($,J){let X=Math.min($.x,J.x),Q=Math.min($.y,J.y);return{x:X,y:Q,w:Math.min(1e4-X,Math.abs($.x-J.x)),h:Math.min(1e4-Q,Math.abs($.y-J.y))}}function y$($){return $.w>=30&&$.h>=30}function r5($){return{left:`${$.x/100}%`,top:`${$.y/100}%`,width:`${$.w/100}%`,height:`${$.h/100}%`}}function h2($){return`${($/100).toFixed(1).replace(/\.0$/,"")}%`}function m2($){let J=`${h2($.x)}-${h2($.x+$.w)}`,X=`${h2($.y)}-${h2($.y+$.h)}`;return`[Region] ${$.src} — ${$.shape} x ${J}, y ${X} of the image`}function D$($,J){for(let X of J.querySelectorAll("[data-md='image']")){if(!(X instanceof HTMLElement))continue;if(X.getAttribute("data-md-src")!==$)continue;let Q=X.querySelector("[data-annotation-image]");if(Q instanceof HTMLElement)return Q}return null}function c2($,J){let X=r5(J);$.style.left=X.left,$.style.top=X.top,$.style.width=X.width,$.style.height=X.height}function u2($,J,X){let Q=document.createElement("div");return Q.className="ann-region",Q.setAttribute("data-annotation-id",X),Q.setAttribute("data-annotation-region",J),c2(Q,$),Q}var B2={kind:"region",parse:($)=>{let J=H6.exec($);if(!J)return null;let X=U6(J[1]),Q=J[2],W=x2(J[3]),Y=x2(J[4]),q=x2(J[5]),H=x2(J[6]);if(X===null||Q===void 0)return null;if(W===null||Y===null||q===null||H===null)return null;if(q<1||H<1)return null;return{src:Q,shape:X,x:W,y:Y,w:q,h:H}},format:($)=>`[Region:${$.shape}] ${$.src} @${$.x},${$.y},${$.w},${$.h}`,find:($,J)=>D$($.src,J),restore:($,J,X)=>{if(J.querySelector(`[data-annotation-id="${X.id}"]`))return;let Q=D$($.src,J);if(!Q)return;Q.appendChild(u2($,$.shape,X.id))},describe:m2};var E$={kind:"text",parse:($)=>$?{text:$}:null,format:($)=>$.text,find:()=>null,restore:($,J,X)=>{j$(J,[X])}};var p2=[U2(B2),U2(b$),U2(E$)];function x$($,J){for(let X of p2){let Q=X.find($,J);if(Q)return Q}return null}function h$($,J){for(let X of J){if(!X.snippet)continue;for(let Q of p2)Q.restore($,X)}}function N2($){for(let J of p2){let X=J.describe($);if(X!==null)return X}return $}import{AnnotationCtx as CX,SessionContext as PX,useAnnotationHost as kX}from"@fabrika/annotations/runtime";import{useEffect as VX,useRef as TX,useState as ZX}from"react";var U={};J6(U,{void:()=>r6,util:()=>o,unknown:()=>d6,union:()=>t6,undefined:()=>u6,tuple:()=>$8,transformer:()=>B8,symbol:()=>c6,string:()=>X4,strictObject:()=>s6,setErrorMap:()=>w6,set:()=>Q8,record:()=>J8,quotelessJson:()=>B6,promise:()=>U8,preprocess:()=>F8,pipeline:()=>f8,ostring:()=>L8,optional:()=>N8,onumber:()=>M8,oboolean:()=>_8,objectUtil:()=>v$,object:()=>o6,number:()=>Q4,nullable:()=>w8,null:()=>p6,never:()=>i6,nativeEnum:()=>H8,nan:()=>h6,map:()=>X8,makeIssue:()=>w2,literal:()=>Y8,lazy:()=>q8,late:()=>E6,isValid:()=>$1,isDirty:()=>d2,isAsync:()=>b1,isAborted:()=>l2,intersection:()=>e6,instanceof:()=>x6,getParsedType:()=>m0,getErrorMap:()=>Z1,function:()=>W8,enum:()=>G8,effect:()=>B8,discriminatedUnion:()=>a6,defaultErrorMap:()=>i0,datetimeRegex:()=>e5,date:()=>m6,custom:()=>J4,coerce:()=>K8,boolean:()=>W4,bigint:()=>v6,array:()=>n6,any:()=>l6,addIssueToContext:()=>P,ZodVoid:()=>f2,ZodUnknown:()=>J1,ZodUnion:()=>x1,ZodUndefined:()=>y1,ZodType:()=>r,ZodTuple:()=>u0,ZodTransformer:()=>g0,ZodSymbol:()=>F2,ZodString:()=>Z0,ZodSet:()=>F1,ZodSchema:()=>r,ZodRecord:()=>L2,ZodReadonly:()=>l1,ZodPromise:()=>f1,ZodPipeline:()=>K2,ZodParsedType:()=>R,ZodOptional:()=>D0,ZodObject:()=>N0,ZodNumber:()=>X1,ZodNullable:()=>n0,ZodNull:()=>E1,ZodNever:()=>c0,ZodNativeEnum:()=>c1,ZodNaN:()=>_2,ZodMap:()=>M2,ZodLiteral:()=>m1,ZodLazy:()=>v1,ZodIssueCode:()=>z,ZodIntersection:()=>h1,ZodFunction:()=>I1,ZodFirstPartyTypeKind:()=>x,ZodError:()=>P0,ZodEnum:()=>W1,ZodEffects:()=>g0,ZodDiscriminatedUnion:()=>i2,ZodDefault:()=>u1,ZodDate:()=>N1,ZodCatch:()=>p1,ZodBranded:()=>r2,ZodBoolean:()=>g1,ZodBigInt:()=>Q1,ZodArray:()=>b0,ZodAny:()=>w1,Schema:()=>r,ParseStatus:()=>z0,OK:()=>O0,NEVER:()=>z8,INVALID:()=>y,EMPTY_PATH:()=>F6,DIRTY:()=>B1,BRAND:()=>y6});var o;(function($){$.assertEqual=(W)=>{};function J(W){}$.assertIs=J;function X(W){throw Error()}$.assertNever=X,$.arrayToEnum=(W)=>{let Y={};for(let q of W)Y[q]=q;return Y},$.getValidEnumValues=(W)=>{let Y=$.objectKeys(W).filter((H)=>typeof W[W[H]]!=="number"),q={};for(let H of Y)q[H]=W[H];return $.objectValues(q)},$.objectValues=(W)=>{return $.objectKeys(W).map(function(Y){return W[Y]})},$.objectKeys=typeof Object.keys==="function"?(W)=>Object.keys(W):(W)=>{let Y=[];for(let q in W)if(Object.prototype.hasOwnProperty.call(W,q))Y.push(q);return Y},$.find=(W,Y)=>{for(let q of W)if(Y(q))return q;return},$.isInteger=typeof Number.isInteger==="function"?(W)=>Number.isInteger(W):(W)=>typeof W==="number"&&Number.isFinite(W)&&Math.floor(W)===W;function Q(W,Y=" | "){return W.map((q)=>typeof q==="string"?`'${q}'`:q).join(Y)}$.joinValues=Q,$.jsonStringifyReplacer=(W,Y)=>{if(typeof Y==="bigint")return Y.toString();return Y}})(o||(o={}));var v$;(function($){$.mergeShapes=(J,X)=>{return{...J,...X}}})(v$||(v$={}));var R=o.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),m0=($)=>{switch(typeof $){case"undefined":return R.undefined;case"string":return R.string;case"number":return Number.isNaN($)?R.nan:R.number;case"boolean":return R.boolean;case"function":return R.function;case"bigint":return R.bigint;case"symbol":return R.symbol;case"object":if(Array.isArray($))return R.array;if($===null)return R.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return R.promise;if(typeof Map<"u"&&$ instanceof Map)return R.map;if(typeof Set<"u"&&$ instanceof Set)return R.set;if(typeof Date<"u"&&$ instanceof Date)return R.date;return R.object;default:return R.unknown}};var z=o.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"]),B6=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class P0 extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(X)=>{this.issues=[...this.issues,X]},this.addIssues=(X=[])=>{this.issues=[...this.issues,...X]};let J=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,J);else this.__proto__=J;this.name="ZodError",this.issues=$}format($){let J=$||function(W){return W.message},X={_errors:[]},Q=(W)=>{for(let Y of W.issues)if(Y.code==="invalid_union")Y.unionErrors.map(Q);else if(Y.code==="invalid_return_type")Q(Y.returnTypeError);else if(Y.code==="invalid_arguments")Q(Y.argumentsError);else if(Y.path.length===0)X._errors.push(J(Y));else{let q=X,H=0;while(H<Y.path.length){let G=Y.path[H];if(H!==Y.path.length-1)q[G]=q[G]||{_errors:[]};else q[G]=q[G]||{_errors:[]},q[G]._errors.push(J(Y));q=q[G],H++}}};return Q(this),X}static assert($){if(!($ instanceof P0))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,o.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(J)=>J.message){let J={},X=[];for(let Q of this.issues)if(Q.path.length>0){let W=Q.path[0];J[W]=J[W]||[],J[W].push($(Q))}else X.push($(Q));return{formErrors:X,fieldErrors:J}}get formErrors(){return this.flatten()}}P0.create=($)=>{return new P0($)};var N6=($,J)=>{let X;switch($.code){case z.invalid_type:if($.received===R.undefined)X="Required";else X=`Expected ${$.expected}, received ${$.received}`;break;case z.invalid_literal:X=`Invalid literal value, expected ${JSON.stringify($.expected,o.jsonStringifyReplacer)}`;break;case z.unrecognized_keys:X=`Unrecognized key(s) in object: ${o.joinValues($.keys,", ")}`;break;case z.invalid_union:X="Invalid input";break;case z.invalid_union_discriminator:X=`Invalid discriminator value. Expected ${o.joinValues($.options)}`;break;case z.invalid_enum_value:X=`Invalid enum value. Expected ${o.joinValues($.options)}, received '${$.received}'`;break;case z.invalid_arguments:X="Invalid function arguments";break;case z.invalid_return_type:X="Invalid function return type";break;case z.invalid_date:X="Invalid date";break;case z.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(X=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")X=`${X} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)X=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)X=`Invalid input: must end with "${$.validation.endsWith}"`;else o.assertNever($.validation);else if($.validation!=="regex")X=`Invalid ${$.validation}`;else X="Invalid";break;case z.too_small:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else X="Invalid input";break;case z.too_big:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")X=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else X="Invalid input";break;case z.custom:X="Invalid input";break;case z.invalid_intersection_types:X="Intersection results could not be merged";break;case z.not_multiple_of:X=`Number must be a multiple of ${$.multipleOf}`;break;case z.not_finite:X="Number must be finite";break;default:X=J.defaultError,o.assertNever($)}return{message:X}},i0=N6;var n5=i0;function w6($){n5=$}function Z1(){return n5}var w2=($)=>{let{data:J,path:X,errorMaps:Q,issueData:W}=$,Y=[...X,...W.path||[]],q={...W,path:Y};if(W.message!==void 0)return{...W,path:Y,message:W.message};let H="",G=Q.filter((B)=>!!B).slice().reverse();for(let B of G)H=B(q,{data:J,defaultError:H}).message;return{...W,path:Y,message:H}},F6=[];function P($,J){let X=Z1(),Q=w2({issueData:J,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,X,X===i0?void 0:i0].filter((W)=>!!W)});$.common.issues.push(Q)}class z0{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,J){let X=[];for(let Q of J){if(Q.status==="aborted")return y;if(Q.status==="dirty")$.dirty();X.push(Q.value)}return{status:$.value,value:X}}static async mergeObjectAsync($,J){let X=[];for(let Q of J){let W=await Q.key,Y=await Q.value;X.push({key:W,value:Y})}return z0.mergeObjectSync($,X)}static mergeObjectSync($,J){let X={};for(let Q of J){let{key:W,value:Y}=Q;if(W.status==="aborted")return y;if(Y.status==="aborted")return y;if(W.status==="dirty")$.dirty();if(Y.status==="dirty")$.dirty();if(W.value!=="__proto__"&&(typeof Y.value<"u"||Q.alwaysSet))X[W.value]=Y.value}return{status:$.value,value:X}}}var y=Object.freeze({status:"aborted"}),B1=($)=>({status:"dirty",value:$}),O0=($)=>({status:"valid",value:$}),l2=($)=>$.status==="aborted",d2=($)=>$.status==="dirty",$1=($)=>$.status==="valid",b1=($)=>typeof Promise<"u"&&$ instanceof Promise;var b;(function($){$.errToObj=(J)=>typeof J==="string"?{message:J}:J||{},$.toString=(J)=>typeof J==="string"?J:J?.message})(b||(b={}));class I0{constructor($,J,X,Q){this._cachedPath=[],this.parent=$,this.data=J,this._path=X,this._key=Q}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 o5=($,J)=>{if($1(J))return{success:!0,data:J.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 X=new P0($.common.issues);return this._error=X,this._error}}}};function p($){if(!$)return{};let{errorMap:J,invalid_type_error:X,required_error:Q,description:W}=$;if(J&&(X||Q))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(J)return{errorMap:J,description:W};return{errorMap:(q,H)=>{let{message:G}=$;if(q.code==="invalid_enum_value")return{message:G??H.defaultError};if(typeof H.data>"u")return{message:G??Q??H.defaultError};if(q.code!=="invalid_type")return{message:H.defaultError};return{message:G??X??H.defaultError}},description:W}}class r{get description(){return this._def.description}_getType($){return m0($.data)}_getOrReturnCtx($,J){return J||{common:$.parent.common,data:$.data,parsedType:m0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new z0,ctx:{common:$.parent.common,data:$.data,parsedType:m0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let J=this._parse($);if(b1(J))throw Error("Synchronous parse encountered promise.");return J}_parseAsync($){let J=this._parse($);return Promise.resolve(J)}parse($,J){let X=this.safeParse($,J);if(X.success)return X.data;throw X.error}safeParse($,J){let X={common:{issues:[],async:J?.async??!1,contextualErrorMap:J?.errorMap},path:J?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:m0($)},Q=this._parseSync({data:$,path:X.path,parent:X});return o5(X,Q)}"~validate"($){let J={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:m0($)};if(!this["~standard"].async)try{let X=this._parseSync({data:$,path:[],parent:J});return $1(X)?{value:X.value}:{issues:J.common.issues}}catch(X){if(X?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;J.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:J}).then((X)=>$1(X)?{value:X.value}:{issues:J.common.issues})}async parseAsync($,J){let X=await this.safeParseAsync($,J);if(X.success)return X.data;throw X.error}async safeParseAsync($,J){let X={common:{issues:[],contextualErrorMap:J?.errorMap,async:!0},path:J?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:m0($)},Q=this._parse({data:$,path:X.path,parent:X}),W=await(b1(Q)?Q:Promise.resolve(Q));return o5(X,W)}refine($,J){let X=(Q)=>{if(typeof J==="string"||typeof J>"u")return{message:J};else if(typeof J==="function")return J(Q);else return J};return this._refinement((Q,W)=>{let Y=$(Q),q=()=>W.addIssue({code:z.custom,...X(Q)});if(typeof Promise<"u"&&Y instanceof Promise)return Y.then((H)=>{if(!H)return q(),!1;else return!0});if(!Y)return q(),!1;else return!0})}refinement($,J){return this._refinement((X,Q)=>{if(!$(X))return Q.addIssue(typeof J==="function"?J(X,Q):J),!1;else return!0})}_refinement($){return new g0({schema:this,typeName:x.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:(J)=>this["~validate"](J)}}optional(){return D0.create(this,this._def)}nullable(){return n0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return b0.create(this)}promise(){return f1.create(this,this._def)}or($){return x1.create([this,$],this._def)}and($){return h1.create(this,$,this._def)}transform($){return new g0({...p(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:$}})}default($){let J=typeof $==="function"?$:()=>$;return new u1({...p(this._def),innerType:this,defaultValue:J,typeName:x.ZodDefault})}brand(){return new r2({typeName:x.ZodBranded,type:this,...p(this._def)})}catch($){let J=typeof $==="function"?$:()=>$;return new p1({...p(this._def),innerType:this,catchValue:J,typeName:x.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return K2.create(this,$)}readonly(){return l1.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var f6=/^c[^\s-]{8,}$/i,L6=/^[0-9a-z]+$/,M6=/^[0-9A-HJKMNP-TV-Z]{26}$/i,_6=/^[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,K6=/^[a-z0-9_-]{21}$/i,z6=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,O6=/^[-+]?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)?)??$/,S6=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,R6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",m$,C6=/^(?:(?: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])$/,P6=/^(?:(?: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])$/,k6=/^(([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]))$/,A6=/^(([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])$/,j6=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,V6=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,t5="((\\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])))",T6=new RegExp(`^${t5}$`);function a5($){let J="[0-5]\\d";if($.precision)J=`${J}\\.\\d{${$.precision}}`;else if($.precision==null)J=`${J}(\\.\\d+)?`;let X=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${J})${X}`}function Z6($){return new RegExp(`^${a5($)}$`)}function e5($){let J=`${t5}T${a5($)}`,X=[];if(X.push($.local?"Z?":"Z"),$.offset)X.push("([+-]\\d{2}:?\\d{2})");return J=`${J}(${X.join("|")})`,new RegExp(`^${J}$`)}function b6($,J){if((J==="v4"||!J)&&C6.test($))return!0;if((J==="v6"||!J)&&k6.test($))return!0;return!1}function D6($,J){if(!z6.test($))return!1;try{let[X]=$.split(".");if(!X)return!1;let Q=X.replace(/-/g,"+").replace(/_/g,"/").padEnd(X.length+(4-X.length%4)%4,"="),W=JSON.parse(atob(Q));if(typeof W!=="object"||W===null)return!1;if("typ"in W&&W?.typ!=="JWT")return!1;if(!W.alg)return!1;if(J&&W.alg!==J)return!1;return!0}catch{return!1}}function I6($,J){if((J==="v4"||!J)&&P6.test($))return!0;if((J==="v6"||!J)&&A6.test($))return!0;return!1}class Z0 extends r{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==R.string){let W=this._getOrReturnCtx($);return P(W,{code:z.invalid_type,expected:R.string,received:W.parsedType}),y}let X=new z0,Q=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.length<W.value)Q=this._getOrReturnCtx($,Q),P(Q,{code:z.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),X.dirty()}else if(W.kind==="max"){if($.data.length>W.value)Q=this._getOrReturnCtx($,Q),P(Q,{code:z.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),X.dirty()}else if(W.kind==="length"){let Y=$.data.length>W.value,q=$.data.length<W.value;if(Y||q){if(Q=this._getOrReturnCtx($,Q),Y)P(Q,{code:z.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});else if(q)P(Q,{code:z.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});X.dirty()}}else if(W.kind==="email"){if(!S6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"email",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="emoji"){if(!m$)m$=new RegExp(R6,"u");if(!m$.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"emoji",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="uuid"){if(!_6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"uuid",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="nanoid"){if(!K6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"nanoid",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="cuid"){if(!f6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"cuid",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="cuid2"){if(!L6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"cuid2",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="ulid"){if(!M6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"ulid",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="url")try{new URL($.data)}catch{Q=this._getOrReturnCtx($,Q),P(Q,{validation:"url",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="regex"){if(W.regex.lastIndex=0,!W.regex.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"regex",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="trim")$.data=$.data.trim();else if(W.kind==="includes"){if(!$.data.includes(W.value,W.position))Q=this._getOrReturnCtx($,Q),P(Q,{code:z.invalid_string,validation:{includes:W.value,position:W.position},message:W.message}),X.dirty()}else if(W.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(W.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(W.kind==="startsWith"){if(!$.data.startsWith(W.value))Q=this._getOrReturnCtx($,Q),P(Q,{code:z.invalid_string,validation:{startsWith:W.value},message:W.message}),X.dirty()}else if(W.kind==="endsWith"){if(!$.data.endsWith(W.value))Q=this._getOrReturnCtx($,Q),P(Q,{code:z.invalid_string,validation:{endsWith:W.value},message:W.message}),X.dirty()}else if(W.kind==="datetime"){if(!e5(W).test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{code:z.invalid_string,validation:"datetime",message:W.message}),X.dirty()}else if(W.kind==="date"){if(!T6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{code:z.invalid_string,validation:"date",message:W.message}),X.dirty()}else if(W.kind==="time"){if(!Z6(W).test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{code:z.invalid_string,validation:"time",message:W.message}),X.dirty()}else if(W.kind==="duration"){if(!O6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"duration",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="ip"){if(!b6($.data,W.version))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"ip",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="jwt"){if(!D6($.data,W.alg))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"jwt",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="cidr"){if(!I6($.data,W.version))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"cidr",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="base64"){if(!j6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"base64",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="base64url"){if(!V6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"base64url",code:z.invalid_string,message:W.message}),X.dirty()}else o.assertNever(W);return{status:X.value,value:$.data}}_regex($,J,X){return this.refinement((Q)=>$.test(Q),{validation:J,code:z.invalid_string,...b.errToObj(X)})}_addCheck($){return new Z0({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...b.errToObj($)})}url($){return this._addCheck({kind:"url",...b.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...b.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...b.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...b.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...b.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...b.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...b.errToObj($)})}base64($){return this._addCheck({kind:"base64",...b.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...b.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...b.errToObj($)})}ip($){return this._addCheck({kind:"ip",...b.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...b.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,...b.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,...b.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...b.errToObj($)})}regex($,J){return this._addCheck({kind:"regex",regex:$,...b.errToObj(J)})}includes($,J){return this._addCheck({kind:"includes",value:$,position:J?.position,...b.errToObj(J?.message)})}startsWith($,J){return this._addCheck({kind:"startsWith",value:$,...b.errToObj(J)})}endsWith($,J){return this._addCheck({kind:"endsWith",value:$,...b.errToObj(J)})}min($,J){return this._addCheck({kind:"min",value:$,...b.errToObj(J)})}max($,J){return this._addCheck({kind:"max",value:$,...b.errToObj(J)})}length($,J){return this._addCheck({kind:"length",value:$,...b.errToObj(J)})}nonempty($){return this.min(1,b.errToObj($))}trim(){return new Z0({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Z0({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Z0({...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 J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxLength(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}}Z0.create=($)=>{return new Z0({checks:[],typeName:x.ZodString,coerce:$?.coerce??!1,...p($)})};function g6($,J){let X=($.toString().split(".")[1]||"").length,Q=(J.toString().split(".")[1]||"").length,W=X>Q?X:Q,Y=Number.parseInt($.toFixed(W).replace(".","")),q=Number.parseInt(J.toFixed(W).replace(".",""));return Y%q/10**W}class X1 extends r{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($)!==R.number){let W=this._getOrReturnCtx($);return P(W,{code:z.invalid_type,expected:R.number,received:W.parsedType}),y}let X=void 0,Q=new z0;for(let W of this._def.checks)if(W.kind==="int"){if(!o.isInteger($.data))X=this._getOrReturnCtx($,X),P(X,{code:z.invalid_type,expected:"integer",received:"float",message:W.message}),Q.dirty()}else if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)X=this._getOrReturnCtx($,X),P(X,{code:z.too_small,minimum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)X=this._getOrReturnCtx($,X),P(X,{code:z.too_big,maximum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="multipleOf"){if(g6($.data,W.value)!==0)X=this._getOrReturnCtx($,X),P(X,{code:z.not_multiple_of,multipleOf:W.value,message:W.message}),Q.dirty()}else if(W.kind==="finite"){if(!Number.isFinite($.data))X=this._getOrReturnCtx($,X),P(X,{code:z.not_finite,message:W.message}),Q.dirty()}else o.assertNever(W);return{status:Q.value,value:$.data}}gte($,J){return this.setLimit("min",$,!0,b.toString(J))}gt($,J){return this.setLimit("min",$,!1,b.toString(J))}lte($,J){return this.setLimit("max",$,!0,b.toString(J))}lt($,J){return this.setLimit("max",$,!1,b.toString(J))}setLimit($,J,X,Q){return new X1({...this._def,checks:[...this._def.checks,{kind:$,value:J,inclusive:X,message:b.toString(Q)}]})}_addCheck($){return new X1({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:b.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString($)})}multipleOf($,J){return this._addCheck({kind:"multipleOf",value:$,message:b.toString(J)})}finite($){return this._addCheck({kind:"finite",message:b.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString($)})}get minValue(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxValue(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&o.isInteger($.value))}get isFinite(){let $=null,J=null;for(let X of this._def.checks)if(X.kind==="finite"||X.kind==="int"||X.kind==="multipleOf")return!0;else if(X.kind==="min"){if(J===null||X.value>J)J=X.value}else if(X.kind==="max"){if($===null||X.value<$)$=X.value}return Number.isFinite(J)&&Number.isFinite($)}}X1.create=($)=>{return new X1({checks:[],typeName:x.ZodNumber,coerce:$?.coerce||!1,...p($)})};class Q1 extends r{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($)!==R.bigint)return this._getInvalidInput($);let X=void 0,Q=new z0;for(let W of this._def.checks)if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)X=this._getOrReturnCtx($,X),P(X,{code:z.too_small,type:"bigint",minimum:W.value,inclusive:W.inclusive,message:W.message}),Q.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)X=this._getOrReturnCtx($,X),P(X,{code:z.too_big,type:"bigint",maximum:W.value,inclusive:W.inclusive,message:W.message}),Q.dirty()}else if(W.kind==="multipleOf"){if($.data%W.value!==BigInt(0))X=this._getOrReturnCtx($,X),P(X,{code:z.not_multiple_of,multipleOf:W.value,message:W.message}),Q.dirty()}else o.assertNever(W);return{status:Q.value,value:$.data}}_getInvalidInput($){let J=this._getOrReturnCtx($);return P(J,{code:z.invalid_type,expected:R.bigint,received:J.parsedType}),y}gte($,J){return this.setLimit("min",$,!0,b.toString(J))}gt($,J){return this.setLimit("min",$,!1,b.toString(J))}lte($,J){return this.setLimit("max",$,!0,b.toString(J))}lt($,J){return this.setLimit("max",$,!1,b.toString(J))}setLimit($,J,X,Q){return new Q1({...this._def,checks:[...this._def.checks,{kind:$,value:J,inclusive:X,message:b.toString(Q)}]})}_addCheck($){return new Q1({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString($)})}multipleOf($,J){return this._addCheck({kind:"multipleOf",value:$,message:b.toString(J)})}get minValue(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxValue(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}}Q1.create=($)=>{return new Q1({checks:[],typeName:x.ZodBigInt,coerce:$?.coerce??!1,...p($)})};class g1 extends r{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==R.boolean){let X=this._getOrReturnCtx($);return P(X,{code:z.invalid_type,expected:R.boolean,received:X.parsedType}),y}return O0($.data)}}g1.create=($)=>{return new g1({typeName:x.ZodBoolean,coerce:$?.coerce||!1,...p($)})};class N1 extends r{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==R.date){let W=this._getOrReturnCtx($);return P(W,{code:z.invalid_type,expected:R.date,received:W.parsedType}),y}if(Number.isNaN($.data.getTime())){let W=this._getOrReturnCtx($);return P(W,{code:z.invalid_date}),y}let X=new z0,Q=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.getTime()<W.value)Q=this._getOrReturnCtx($,Q),P(Q,{code:z.too_small,message:W.message,inclusive:!0,exact:!1,minimum:W.value,type:"date"}),X.dirty()}else if(W.kind==="max"){if($.data.getTime()>W.value)Q=this._getOrReturnCtx($,Q),P(Q,{code:z.too_big,message:W.message,inclusive:!0,exact:!1,maximum:W.value,type:"date"}),X.dirty()}else o.assertNever(W);return{status:X.value,value:new Date($.data.getTime())}}_addCheck($){return new N1({...this._def,checks:[...this._def.checks,$]})}min($,J){return this._addCheck({kind:"min",value:$.getTime(),message:b.toString(J)})}max($,J){return this._addCheck({kind:"max",value:$.getTime(),message:b.toString(J)})}get minDate(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $!=null?new Date($):null}}N1.create=($)=>{return new N1({checks:[],coerce:$?.coerce||!1,typeName:x.ZodDate,...p($)})};class F2 extends r{_parse($){if(this._getType($)!==R.symbol){let X=this._getOrReturnCtx($);return P(X,{code:z.invalid_type,expected:R.symbol,received:X.parsedType}),y}return O0($.data)}}F2.create=($)=>{return new F2({typeName:x.ZodSymbol,...p($)})};class y1 extends r{_parse($){if(this._getType($)!==R.undefined){let X=this._getOrReturnCtx($);return P(X,{code:z.invalid_type,expected:R.undefined,received:X.parsedType}),y}return O0($.data)}}y1.create=($)=>{return new y1({typeName:x.ZodUndefined,...p($)})};class E1 extends r{_parse($){if(this._getType($)!==R.null){let X=this._getOrReturnCtx($);return P(X,{code:z.invalid_type,expected:R.null,received:X.parsedType}),y}return O0($.data)}}E1.create=($)=>{return new E1({typeName:x.ZodNull,...p($)})};class w1 extends r{constructor(){super(...arguments);this._any=!0}_parse($){return O0($.data)}}w1.create=($)=>{return new w1({typeName:x.ZodAny,...p($)})};class J1 extends r{constructor(){super(...arguments);this._unknown=!0}_parse($){return O0($.data)}}J1.create=($)=>{return new J1({typeName:x.ZodUnknown,...p($)})};class c0 extends r{_parse($){let J=this._getOrReturnCtx($);return P(J,{code:z.invalid_type,expected:R.never,received:J.parsedType}),y}}c0.create=($)=>{return new c0({typeName:x.ZodNever,...p($)})};class f2 extends r{_parse($){if(this._getType($)!==R.undefined){let X=this._getOrReturnCtx($);return P(X,{code:z.invalid_type,expected:R.void,received:X.parsedType}),y}return O0($.data)}}f2.create=($)=>{return new f2({typeName:x.ZodVoid,...p($)})};class b0 extends r{_parse($){let{ctx:J,status:X}=this._processInputParams($),Q=this._def;if(J.parsedType!==R.array)return P(J,{code:z.invalid_type,expected:R.array,received:J.parsedType}),y;if(Q.exactLength!==null){let Y=J.data.length>Q.exactLength.value,q=J.data.length<Q.exactLength.value;if(Y||q)P(J,{code:Y?z.too_big:z.too_small,minimum:q?Q.exactLength.value:void 0,maximum:Y?Q.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:Q.exactLength.message}),X.dirty()}if(Q.minLength!==null){if(J.data.length<Q.minLength.value)P(J,{code:z.too_small,minimum:Q.minLength.value,type:"array",inclusive:!0,exact:!1,message:Q.minLength.message}),X.dirty()}if(Q.maxLength!==null){if(J.data.length>Q.maxLength.value)P(J,{code:z.too_big,maximum:Q.maxLength.value,type:"array",inclusive:!0,exact:!1,message:Q.maxLength.message}),X.dirty()}if(J.common.async)return Promise.all([...J.data].map((Y,q)=>{return Q.type._parseAsync(new I0(J,Y,J.path,q))})).then((Y)=>{return z0.mergeArray(X,Y)});let W=[...J.data].map((Y,q)=>{return Q.type._parseSync(new I0(J,Y,J.path,q))});return z0.mergeArray(X,W)}get element(){return this._def.type}min($,J){return new b0({...this._def,minLength:{value:$,message:b.toString(J)}})}max($,J){return new b0({...this._def,maxLength:{value:$,message:b.toString(J)}})}length($,J){return new b0({...this._def,exactLength:{value:$,message:b.toString(J)}})}nonempty($){return this.min(1,$)}}b0.create=($,J)=>{return new b0({type:$,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...p(J)})};function D1($){if($ instanceof N0){let J={};for(let X in $.shape){let Q=$.shape[X];J[X]=D0.create(D1(Q))}return new N0({...$._def,shape:()=>J})}else if($ instanceof b0)return new b0({...$._def,type:D1($.element)});else if($ instanceof D0)return D0.create(D1($.unwrap()));else if($ instanceof n0)return n0.create(D1($.unwrap()));else if($ instanceof u0)return u0.create($.items.map((J)=>D1(J)));else return $}class N0 extends r{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(),J=o.objectKeys($);return this._cached={shape:$,keys:J},this._cached}_parse($){if(this._getType($)!==R.object){let G=this._getOrReturnCtx($);return P(G,{code:z.invalid_type,expected:R.object,received:G.parsedType}),y}let{status:X,ctx:Q}=this._processInputParams($),{shape:W,keys:Y}=this._getCached(),q=[];if(!(this._def.catchall instanceof c0&&this._def.unknownKeys==="strip")){for(let G in Q.data)if(!Y.includes(G))q.push(G)}let H=[];for(let G of Y){let B=W[G],N=Q.data[G];H.push({key:{status:"valid",value:G},value:B._parse(new I0(Q,N,Q.path,G)),alwaysSet:G in Q.data})}if(this._def.catchall instanceof c0){let G=this._def.unknownKeys;if(G==="passthrough")for(let B of q)H.push({key:{status:"valid",value:B},value:{status:"valid",value:Q.data[B]}});else if(G==="strict"){if(q.length>0)P(Q,{code:z.unrecognized_keys,keys:q}),X.dirty()}else if(G==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let G=this._def.catchall;for(let B of q){let N=Q.data[B];H.push({key:{status:"valid",value:B},value:G._parse(new I0(Q,N,Q.path,B)),alwaysSet:B in Q.data})}}if(Q.common.async)return Promise.resolve().then(async()=>{let G=[];for(let B of H){let N=await B.key,f=await B.value;G.push({key:N,value:f,alwaysSet:B.alwaysSet})}return G}).then((G)=>{return z0.mergeObjectSync(X,G)});else return z0.mergeObjectSync(X,H)}get shape(){return this._def.shape()}strict($){return b.errToObj,new N0({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(J,X)=>{let Q=this._def.errorMap?.(J,X).message??X.defaultError;if(J.code==="unrecognized_keys")return{message:b.errToObj($).message??Q};return{message:Q}}}:{}})}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:x.ZodObject})}setKey($,J){return this.augment({[$]:J})}catchall($){return new N0({...this._def,catchall:$})}pick($){let J={};for(let X of o.objectKeys($))if($[X]&&this.shape[X])J[X]=this.shape[X];return new N0({...this._def,shape:()=>J})}omit($){let J={};for(let X of o.objectKeys(this.shape))if(!$[X])J[X]=this.shape[X];return new N0({...this._def,shape:()=>J})}deepPartial(){return D1(this)}partial($){let J={};for(let X of o.objectKeys(this.shape)){let Q=this.shape[X];if($&&!$[X])J[X]=Q;else J[X]=Q.optional()}return new N0({...this._def,shape:()=>J})}required($){let J={};for(let X of o.objectKeys(this.shape))if($&&!$[X])J[X]=this.shape[X];else{let W=this.shape[X];while(W instanceof D0)W=W._def.innerType;J[X]=W}return new N0({...this._def,shape:()=>J})}keyof(){return $4(o.objectKeys(this.shape))}}N0.create=($,J)=>{return new N0({shape:()=>$,unknownKeys:"strip",catchall:c0.create(),typeName:x.ZodObject,...p(J)})};N0.strictCreate=($,J)=>{return new N0({shape:()=>$,unknownKeys:"strict",catchall:c0.create(),typeName:x.ZodObject,...p(J)})};N0.lazycreate=($,J)=>{return new N0({shape:$,unknownKeys:"strip",catchall:c0.create(),typeName:x.ZodObject,...p(J)})};class x1 extends r{_parse($){let{ctx:J}=this._processInputParams($),X=this._def.options;function Q(W){for(let q of W)if(q.result.status==="valid")return q.result;for(let q of W)if(q.result.status==="dirty")return J.common.issues.push(...q.ctx.common.issues),q.result;let Y=W.map((q)=>new P0(q.ctx.common.issues));return P(J,{code:z.invalid_union,unionErrors:Y}),y}if(J.common.async)return Promise.all(X.map(async(W)=>{let Y={...J,common:{...J.common,issues:[]},parent:null};return{result:await W._parseAsync({data:J.data,path:J.path,parent:Y}),ctx:Y}})).then(Q);else{let W=void 0,Y=[];for(let H of X){let G={...J,common:{...J.common,issues:[]},parent:null},B=H._parseSync({data:J.data,path:J.path,parent:G});if(B.status==="valid")return B;else if(B.status==="dirty"&&!W)W={result:B,ctx:G};if(G.common.issues.length)Y.push(G.common.issues)}if(W)return J.common.issues.push(...W.ctx.common.issues),W.result;let q=Y.map((H)=>new P0(H));return P(J,{code:z.invalid_union,unionErrors:q}),y}}get options(){return this._def.options}}x1.create=($,J)=>{return new x1({options:$,typeName:x.ZodUnion,...p(J)})};var r0=($)=>{if($ instanceof v1)return r0($.schema);else if($ instanceof g0)return r0($.innerType());else if($ instanceof m1)return[$.value];else if($ instanceof W1)return $.options;else if($ instanceof c1)return o.objectValues($.enum);else if($ instanceof u1)return r0($._def.innerType);else if($ instanceof y1)return[void 0];else if($ instanceof E1)return[null];else if($ instanceof D0)return[void 0,...r0($.unwrap())];else if($ instanceof n0)return[null,...r0($.unwrap())];else if($ instanceof r2)return r0($.unwrap());else if($ instanceof l1)return r0($.unwrap());else if($ instanceof p1)return r0($._def.innerType);else return[]};class i2 extends r{_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==R.object)return P(J,{code:z.invalid_type,expected:R.object,received:J.parsedType}),y;let X=this.discriminator,Q=J.data[X],W=this.optionsMap.get(Q);if(!W)return P(J,{code:z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[X]}),y;if(J.common.async)return W._parseAsync({data:J.data,path:J.path,parent:J});else return W._parseSync({data:J.data,path:J.path,parent:J})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,J,X){let Q=new Map;for(let W of J){let Y=r0(W.shape[$]);if(!Y.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let q of Y){if(Q.has(q))throw Error(`Discriminator property ${String($)} has duplicate value ${String(q)}`);Q.set(q,W)}}return new i2({typeName:x.ZodDiscriminatedUnion,discriminator:$,options:J,optionsMap:Q,...p(X)})}}function c$($,J){let X=m0($),Q=m0(J);if($===J)return{valid:!0,data:$};else if(X===R.object&&Q===R.object){let W=o.objectKeys(J),Y=o.objectKeys($).filter((H)=>W.indexOf(H)!==-1),q={...$,...J};for(let H of Y){let G=c$($[H],J[H]);if(!G.valid)return{valid:!1};q[H]=G.data}return{valid:!0,data:q}}else if(X===R.array&&Q===R.array){if($.length!==J.length)return{valid:!1};let W=[];for(let Y=0;Y<$.length;Y++){let q=$[Y],H=J[Y],G=c$(q,H);if(!G.valid)return{valid:!1};W.push(G.data)}return{valid:!0,data:W}}else if(X===R.date&&Q===R.date&&+$===+J)return{valid:!0,data:$};else return{valid:!1}}class h1 extends r{_parse($){let{status:J,ctx:X}=this._processInputParams($),Q=(W,Y)=>{if(l2(W)||l2(Y))return y;let q=c$(W.value,Y.value);if(!q.valid)return P(X,{code:z.invalid_intersection_types}),y;if(d2(W)||d2(Y))J.dirty();return{status:J.value,value:q.data}};if(X.common.async)return Promise.all([this._def.left._parseAsync({data:X.data,path:X.path,parent:X}),this._def.right._parseAsync({data:X.data,path:X.path,parent:X})]).then(([W,Y])=>Q(W,Y));else return Q(this._def.left._parseSync({data:X.data,path:X.path,parent:X}),this._def.right._parseSync({data:X.data,path:X.path,parent:X}))}}h1.create=($,J,X)=>{return new h1({left:$,right:J,typeName:x.ZodIntersection,...p(X)})};class u0 extends r{_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.parsedType!==R.array)return P(X,{code:z.invalid_type,expected:R.array,received:X.parsedType}),y;if(X.data.length<this._def.items.length)return P(X,{code:z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;if(!this._def.rest&&X.data.length>this._def.items.length)P(X,{code:z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),J.dirty();let W=[...X.data].map((Y,q)=>{let H=this._def.items[q]||this._def.rest;if(!H)return null;return H._parse(new I0(X,Y,X.path,q))}).filter((Y)=>!!Y);if(X.common.async)return Promise.all(W).then((Y)=>{return z0.mergeArray(J,Y)});else return z0.mergeArray(J,W)}get items(){return this._def.items}rest($){return new u0({...this._def,rest:$})}}u0.create=($,J)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new u0({items:$,typeName:x.ZodTuple,rest:null,...p(J)})};class L2 extends r{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.parsedType!==R.object)return P(X,{code:z.invalid_type,expected:R.object,received:X.parsedType}),y;let Q=[],W=this._def.keyType,Y=this._def.valueType;for(let q in X.data)Q.push({key:W._parse(new I0(X,q,X.path,q)),value:Y._parse(new I0(X,X.data[q],X.path,q)),alwaysSet:q in X.data});if(X.common.async)return z0.mergeObjectAsync(J,Q);else return z0.mergeObjectSync(J,Q)}get element(){return this._def.valueType}static create($,J,X){if(J instanceof r)return new L2({keyType:$,valueType:J,typeName:x.ZodRecord,...p(X)});return new L2({keyType:Z0.create(),valueType:$,typeName:x.ZodRecord,...p(J)})}}class M2 extends r{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.parsedType!==R.map)return P(X,{code:z.invalid_type,expected:R.map,received:X.parsedType}),y;let Q=this._def.keyType,W=this._def.valueType,Y=[...X.data.entries()].map(([q,H],G)=>{return{key:Q._parse(new I0(X,q,X.path,[G,"key"])),value:W._parse(new I0(X,H,X.path,[G,"value"]))}});if(X.common.async){let q=new Map;return Promise.resolve().then(async()=>{for(let H of Y){let G=await H.key,B=await H.value;if(G.status==="aborted"||B.status==="aborted")return y;if(G.status==="dirty"||B.status==="dirty")J.dirty();q.set(G.value,B.value)}return{status:J.value,value:q}})}else{let q=new Map;for(let H of Y){let{key:G,value:B}=H;if(G.status==="aborted"||B.status==="aborted")return y;if(G.status==="dirty"||B.status==="dirty")J.dirty();q.set(G.value,B.value)}return{status:J.value,value:q}}}}M2.create=($,J,X)=>{return new M2({valueType:J,keyType:$,typeName:x.ZodMap,...p(X)})};class F1 extends r{_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.parsedType!==R.set)return P(X,{code:z.invalid_type,expected:R.set,received:X.parsedType}),y;let Q=this._def;if(Q.minSize!==null){if(X.data.size<Q.minSize.value)P(X,{code:z.too_small,minimum:Q.minSize.value,type:"set",inclusive:!0,exact:!1,message:Q.minSize.message}),J.dirty()}if(Q.maxSize!==null){if(X.data.size>Q.maxSize.value)P(X,{code:z.too_big,maximum:Q.maxSize.value,type:"set",inclusive:!0,exact:!1,message:Q.maxSize.message}),J.dirty()}let W=this._def.valueType;function Y(H){let G=new Set;for(let B of H){if(B.status==="aborted")return y;if(B.status==="dirty")J.dirty();G.add(B.value)}return{status:J.value,value:G}}let q=[...X.data.values()].map((H,G)=>W._parse(new I0(X,H,X.path,G)));if(X.common.async)return Promise.all(q).then((H)=>Y(H));else return Y(q)}min($,J){return new F1({...this._def,minSize:{value:$,message:b.toString(J)}})}max($,J){return new F1({...this._def,maxSize:{value:$,message:b.toString(J)}})}size($,J){return this.min($,J).max($,J)}nonempty($){return this.min(1,$)}}F1.create=($,J)=>{return new F1({valueType:$,minSize:null,maxSize:null,typeName:x.ZodSet,...p(J)})};class I1 extends r{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==R.function)return P(J,{code:z.invalid_type,expected:R.function,received:J.parsedType}),y;function X(q,H){return w2({data:q,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,Z1(),i0].filter((G)=>!!G),issueData:{code:z.invalid_arguments,argumentsError:H}})}function Q(q,H){return w2({data:q,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,Z1(),i0].filter((G)=>!!G),issueData:{code:z.invalid_return_type,returnTypeError:H}})}let W={errorMap:J.common.contextualErrorMap},Y=J.data;if(this._def.returns instanceof f1){let q=this;return O0(async function(...H){let G=new P0([]),B=await q._def.args.parseAsync(H,W).catch((L)=>{throw G.addIssue(X(H,L)),G}),N=await Reflect.apply(Y,this,B);return await q._def.returns._def.type.parseAsync(N,W).catch((L)=>{throw G.addIssue(Q(N,L)),G})})}else{let q=this;return O0(function(...H){let G=q._def.args.safeParse(H,W);if(!G.success)throw new P0([X(H,G.error)]);let B=Reflect.apply(Y,this,G.data),N=q._def.returns.safeParse(B,W);if(!N.success)throw new P0([Q(B,N.error)]);return N.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new I1({...this._def,args:u0.create($).rest(J1.create())})}returns($){return new I1({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,J,X){return new I1({args:$?$:u0.create([]).rest(J1.create()),returns:J||J1.create(),typeName:x.ZodFunction,...p(X)})}}class v1 extends r{get schema(){return this._def.getter()}_parse($){let{ctx:J}=this._processInputParams($);return this._def.getter()._parse({data:J.data,path:J.path,parent:J})}}v1.create=($,J)=>{return new v1({getter:$,typeName:x.ZodLazy,...p(J)})};class m1 extends r{_parse($){if($.data!==this._def.value){let J=this._getOrReturnCtx($);return P(J,{received:J.data,code:z.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:$.data}}get value(){return this._def.value}}m1.create=($,J)=>{return new m1({value:$,typeName:x.ZodLiteral,...p(J)})};function $4($,J){return new W1({values:$,typeName:x.ZodEnum,...p(J)})}class W1 extends r{_parse($){if(typeof $.data!=="string"){let J=this._getOrReturnCtx($),X=this._def.values;return P(J,{expected:o.joinValues(X),received:J.parsedType,code:z.invalid_type}),y}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let J=this._getOrReturnCtx($),X=this._def.values;return P(J,{received:J.data,code:z.invalid_enum_value,options:X}),y}return O0($.data)}get options(){return this._def.values}get enum(){let $={};for(let J of this._def.values)$[J]=J;return $}get Values(){let $={};for(let J of this._def.values)$[J]=J;return $}get Enum(){let $={};for(let J of this._def.values)$[J]=J;return $}extract($,J=this._def){return W1.create($,{...this._def,...J})}exclude($,J=this._def){return W1.create(this.options.filter((X)=>!$.includes(X)),{...this._def,...J})}}W1.create=$4;class c1 extends r{_parse($){let J=o.getValidEnumValues(this._def.values),X=this._getOrReturnCtx($);if(X.parsedType!==R.string&&X.parsedType!==R.number){let Q=o.objectValues(J);return P(X,{expected:o.joinValues(Q),received:X.parsedType,code:z.invalid_type}),y}if(!this._cache)this._cache=new Set(o.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let Q=o.objectValues(J);return P(X,{received:X.data,code:z.invalid_enum_value,options:Q}),y}return O0($.data)}get enum(){return this._def.values}}c1.create=($,J)=>{return new c1({values:$,typeName:x.ZodNativeEnum,...p(J)})};class f1 extends r{unwrap(){return this._def.type}_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==R.promise&&J.common.async===!1)return P(J,{code:z.invalid_type,expected:R.promise,received:J.parsedType}),y;let X=J.parsedType===R.promise?J.data:Promise.resolve(J.data);return O0(X.then((Q)=>{return this._def.type.parseAsync(Q,{path:J.path,errorMap:J.common.contextualErrorMap})}))}}f1.create=($,J)=>{return new f1({type:$,typeName:x.ZodPromise,...p(J)})};class g0 extends r{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:J,ctx:X}=this._processInputParams($),Q=this._def.effect||null,W={addIssue:(Y)=>{if(P(X,Y),Y.fatal)J.abort();else J.dirty()},get path(){return X.path}};if(W.addIssue=W.addIssue.bind(W),Q.type==="preprocess"){let Y=Q.transform(X.data,W);if(X.common.async)return Promise.resolve(Y).then(async(q)=>{if(J.value==="aborted")return y;let H=await this._def.schema._parseAsync({data:q,path:X.path,parent:X});if(H.status==="aborted")return y;if(H.status==="dirty")return B1(H.value);if(J.value==="dirty")return B1(H.value);return H});else{if(J.value==="aborted")return y;let q=this._def.schema._parseSync({data:Y,path:X.path,parent:X});if(q.status==="aborted")return y;if(q.status==="dirty")return B1(q.value);if(J.value==="dirty")return B1(q.value);return q}}if(Q.type==="refinement"){let Y=(q)=>{let H=Q.refinement(q,W);if(X.common.async)return Promise.resolve(H);if(H instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return q};if(X.common.async===!1){let q=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(q.status==="aborted")return y;if(q.status==="dirty")J.dirty();return Y(q.value),{status:J.value,value:q.value}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((q)=>{if(q.status==="aborted")return y;if(q.status==="dirty")J.dirty();return Y(q.value).then(()=>{return{status:J.value,value:q.value}})})}if(Q.type==="transform")if(X.common.async===!1){let Y=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(!$1(Y))return y;let q=Q.transform(Y.value,W);if(q instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:J.value,value:q}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((Y)=>{if(!$1(Y))return y;return Promise.resolve(Q.transform(Y.value,W)).then((q)=>({status:J.value,value:q}))});o.assertNever(Q)}}g0.create=($,J,X)=>{return new g0({schema:$,typeName:x.ZodEffects,effect:J,...p(X)})};g0.createWithPreprocess=($,J,X)=>{return new g0({schema:J,effect:{type:"preprocess",transform:$},typeName:x.ZodEffects,...p(X)})};class D0 extends r{_parse($){if(this._getType($)===R.undefined)return O0(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}D0.create=($,J)=>{return new D0({innerType:$,typeName:x.ZodOptional,...p(J)})};class n0 extends r{_parse($){if(this._getType($)===R.null)return O0(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}n0.create=($,J)=>{return new n0({innerType:$,typeName:x.ZodNullable,...p(J)})};class u1 extends r{_parse($){let{ctx:J}=this._processInputParams($),X=J.data;if(J.parsedType===R.undefined)X=this._def.defaultValue();return this._def.innerType._parse({data:X,path:J.path,parent:J})}removeDefault(){return this._def.innerType}}u1.create=($,J)=>{return new u1({innerType:$,typeName:x.ZodDefault,defaultValue:typeof J.default==="function"?J.default:()=>J.default,...p(J)})};class p1 extends r{_parse($){let{ctx:J}=this._processInputParams($),X={...J,common:{...J.common,issues:[]}},Q=this._def.innerType._parse({data:X.data,path:X.path,parent:{...X}});if(b1(Q))return Q.then((W)=>{return{status:"valid",value:W.status==="valid"?W.value:this._def.catchValue({get error(){return new P0(X.common.issues)},input:X.data})}});else return{status:"valid",value:Q.status==="valid"?Q.value:this._def.catchValue({get error(){return new P0(X.common.issues)},input:X.data})}}removeCatch(){return this._def.innerType}}p1.create=($,J)=>{return new p1({innerType:$,typeName:x.ZodCatch,catchValue:typeof J.catch==="function"?J.catch:()=>J.catch,...p(J)})};class _2 extends r{_parse($){if(this._getType($)!==R.nan){let X=this._getOrReturnCtx($);return P(X,{code:z.invalid_type,expected:R.nan,received:X.parsedType}),y}return{status:"valid",value:$.data}}}_2.create=($)=>{return new _2({typeName:x.ZodNaN,...p($)})};var y6=Symbol("zod_brand");class r2 extends r{_parse($){let{ctx:J}=this._processInputParams($),X=J.data;return this._def.type._parse({data:X,path:J.path,parent:J})}unwrap(){return this._def.type}}class K2 extends r{_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.common.async)return(async()=>{let W=await this._def.in._parseAsync({data:X.data,path:X.path,parent:X});if(W.status==="aborted")return y;if(W.status==="dirty")return J.dirty(),B1(W.value);else return this._def.out._parseAsync({data:W.value,path:X.path,parent:X})})();else{let Q=this._def.in._parseSync({data:X.data,path:X.path,parent:X});if(Q.status==="aborted")return y;if(Q.status==="dirty")return J.dirty(),{status:"dirty",value:Q.value};else return this._def.out._parseSync({data:Q.value,path:X.path,parent:X})}}static create($,J){return new K2({in:$,out:J,typeName:x.ZodPipeline})}}class l1 extends r{_parse($){let J=this._def.innerType._parse($),X=(Q)=>{if($1(Q))Q.value=Object.freeze(Q.value);return Q};return b1(J)?J.then((Q)=>X(Q)):X(J)}unwrap(){return this._def.innerType}}l1.create=($,J)=>{return new l1({innerType:$,typeName:x.ZodReadonly,...p(J)})};function s5($,J){let X=typeof $==="function"?$(J):typeof $==="string"?{message:$}:$;return typeof X==="string"?{message:X}:X}function J4($,J={},X){if($)return w1.create().superRefine((Q,W)=>{let Y=$(Q);if(Y instanceof Promise)return Y.then((q)=>{if(!q){let H=s5(J,Q),G=H.fatal??X??!0;W.addIssue({code:"custom",...H,fatal:G})}});if(!Y){let q=s5(J,Q),H=q.fatal??X??!0;W.addIssue({code:"custom",...q,fatal:H})}return});return w1.create()}var E6={object:N0.lazycreate},x;(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"})(x||(x={}));var x6=($,J={message:`Input not instance of ${$.name}`})=>J4((X)=>X instanceof $,J),X4=Z0.create,Q4=X1.create,h6=_2.create,v6=Q1.create,W4=g1.create,m6=N1.create,c6=F2.create,u6=y1.create,p6=E1.create,l6=w1.create,d6=J1.create,i6=c0.create,r6=f2.create,n6=b0.create,o6=N0.create,s6=N0.strictCreate,t6=x1.create,a6=i2.create,e6=h1.create,$8=u0.create,J8=L2.create,X8=M2.create,Q8=F1.create,W8=I1.create,q8=v1.create,Y8=m1.create,G8=W1.create,H8=c1.create,U8=f1.create,B8=g0.create,N8=D0.create,w8=n0.create,F8=g0.createWithPreprocess,f8=K2.create,L8=()=>X4().optional(),M8=()=>Q4().optional(),_8=()=>W4().optional(),K8={string:($)=>Z0.create({...$,coerce:!0}),number:($)=>X1.create({...$,coerce:!0}),boolean:($)=>g1.create({...$,coerce:!0}),bigint:($)=>Q1.create({...$,coerce:!0}),date:($)=>N1.create({...$,coerce:!0})};var z8=y;var O8=U.object({before:U.string(),after:U.string(),hierarchy:U.array(U.string()),lineStart:U.number().optional(),lineEnd:U.number().optional()}).passthrough(),S8=U.object({id:U.string(),name:U.string()}).passthrough(),R8=U.object({url:U.string(),mime:U.string().optional()}).passthrough(),u$=U.object({id:U.string(),snippet:U.string(),note:U.string(),createdAt:U.string(),filePath:U.string().optional(),canvasFile:U.string().optional(),context:O8.optional(),images:U.array(U.string()).optional(),attachments:U.array(R8).optional(),source:U.enum(["local","remote"]).optional(),author:S8.optional()}).passthrough(),C8=U.array(u$.optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).catch([]),p$=U.object({annotations:C8,generalNote:U.string().catch("")}).passthrough(),q4=U.object({path:U.string()}),Y4=U.object({url:U.string()});import{useCallback as M1,useMemo as P8,useState as k8}from"react";var d1="__agent-response__";function L1($){return $.filePath&&$.filePath!=="__agent-response__"?$.filePath:void 0}function z2($){return $.uploadUrl!==null}function o0(){return`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}function q1($,J){$.style.height="auto",$.style.height=(J?Math.max(J,$.scrollHeight):$.scrollHeight)+"px"}function G4($){let J=$?`[data-annotation-id="${CSS.escape($)}"]`:"[data-annotation-id]";for(let X of document.querySelectorAll(J))if(X.tagName==="MARK"){let Q=X.parentNode;X.replaceWith(document.createTextNode(X.textContent||"")),Q?.normalize()}else X.remove()}function n2({annotations:$,setAnnotations:J,generalNote:X,setGeneralNote:Q,remoteAnnotations:W,isReadOnly:Y,onClear:q}){let[H,G]=k8(null),B=P8(()=>{if(!W?.length)return $;let O=new Set($.map((M)=>M.id)),S=W.filter((M)=>!O.has(M.id));return[...$,...S.map((M)=>({...M,source:"remote"}))]},[$,W]),N=M1((O,S,M,A,Z,h,g)=>{J((v)=>[...v,{id:O,snippet:S,note:M,createdAt:new Date().toISOString(),filePath:A,context:Z,...h?.length?{images:h}:{},...g?{canvasFile:g}:{}}])},[J]),f=M1((O,S,M)=>{N(o0(),O,S,M)},[N]),L=M1((O,S)=>{J((M)=>M.map((A)=>A.id===O?{...A,note:S}:A))},[J]),w=M1((O)=>{if(!$.some((S)=>S.id===O))return;G4(O),J((S)=>S.filter((M)=>M.id!==O)),G((S)=>S===O?null:S)},[$,J]),F=M1((O,S)=>{J((M)=>M.map((A)=>A.id===O?{...A,images:[...A.images||[],S]}:A))},[J]),C=M1((O,S)=>{J((M)=>M.map((A)=>A.id===O?{...A,images:(A.images||[]).filter((Z)=>Z!==S)}:A))},[J]),_=M1(()=>{G4(),J([]),Q(""),G(null),q?.()},[J,Q,q]);return{annotations:B,generalNote:X,setGeneralNote:Q,activeAnnotationId:H,setActiveAnnotationId:G,addAnnotation:f,addAnnotationWithId:N,updateAnnotation:L,removeAnnotation:w,addAnnotationImage:F,removeAnnotationImage:C,clearAll:_,isReadOnly:Y}}import{useAnnotations as Y1}from"@fabrika/annotations/runtime";import{jsxDEV as yX}from"react/jsx-dev-runtime";import{jsxDEV as _1,Fragment as A8}from"react/jsx-dev-runtime";function l$({hasContent:$,onSubmit:J,onSubmitEmpty:X,notice:Q,secondaryAction:W,placeholder:Y="General notes...",submitLabel:q="Submit",emptyLabel:H="Submit without feedback"}){let{generalNote:G,setGeneralNote:B}=Y1();return _1(A8,{children:[_1("div",{className:"border-t border-border-subtle px-4 py-3 flex-shrink-0",children:_1("textarea",{value:G,onChange:(N)=>B(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:Y,onInput:(N)=>q1(N.currentTarget,40),ref:(N)=>{if(N)q1(N,40)}},void 0,!1,void 0,this)},void 0,!1,void 0,this),Q,_1("div",{className:"px-4 py-3 border-t border-border-subtle flex-shrink-0",children:$?_1("div",{className:"flex gap-2",children:[W,_1("button",{onClick:J,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):_1("button",{onClick:X,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:H},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useAnnotationHost as j8}from"@fabrika/annotations/runtime";import{useCallback as s0,useEffect as V8,useRef as d$,useState as i$}from"react";import{jsxDEV as M0}from"react/jsx-dev-runtime";function r$($){if($.startsWith("/s/")||$.startsWith("http://")||$.startsWith("https://"))return $;return`/api/uploads/${$.split("/").pop()}`}async function T8($,J){let X=$.uploadUrl;if(!X)return null;let Q=new FormData;Q.append("image",J);try{let Y=await(await fetch(X(),{method:"POST",body:Q})).json();if($.isShared)return Y4.parse(Y).url||null;return q4.parse(Y).path||null}catch{return null}}function i1({note:$,onNoteChange:J,images:X,onAddImage:Q,onRemoveImage:W,sessionId:Y,placeholder:q="Add your note...",autoFocus:H=!1,autoResize:G=!1,readOnly:B=!1,onKeyDown:N,onTextareaClick:f,textareaRef:L,textareaClassName:w,textareaStyle:F,minHeight:C,attachButton:_="always",openFilePickerRef:O}){let S=j8(),M=!B&&z2(S),[A,Z]=i$(!1),[h,g]=i$(!1),[v,u]=i$(!1),m=d$(0),e=d$(null),Q0=d$(null),Y0=s0(()=>Q0.current?.click(),[]);if(O)O.current=Y0;let K0=s0((K)=>{if(e.current=K,L)L.current=K;if(K&&G)q1(K,C)},[L,G,C]);V8(()=>{if(H&&e.current){let K=e.current;if(K.focus(),K.value)K.setSelectionRange(K.value.length,K.value.length)}},[H]);let c=s0(async(K)=>{if(!K.type.startsWith("image/"))return;g(!0);try{let j=await T8(S,K);if(j)Q(j)}finally{g(!1)}},[S,Q]),$0=s0((K)=>{for(let j of K.clipboardData?.items??[])if(j.type.startsWith("image/")){K.preventDefault();let n=j.getAsFile();if(n)c(n);return}},[c]),J0=s0((K)=>{if(K.preventDefault(),m.current++,m.current===1)Z(!0)},[]),G0=s0((K)=>{K.preventDefault()},[]),a=s0((K)=>{if(K.preventDefault(),m.current--,m.current===0)Z(!1)},[]),X0=s0((K)=>{K.preventDefault(),m.current=0,Z(!1);for(let j of K.dataTransfer?.files??[])if(j.type.startsWith("image/"))c(j)},[c]),B0=s0((K)=>{if(J(K.currentTarget.value),G)K.currentTarget.style.height="auto",K.currentTarget.style.height=(C?Math.max(C,K.currentTarget.scrollHeight):K.currentTarget.scrollHeight)+"px"},[J,G,C]),k="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",I={width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",outline:"none",...G?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},l=M&&(_==="always"||_==="on-focus"&&v);return M0("div",{style:{position:"relative"},onDragEnter:M?J0:void 0,onDragOver:M?G0:void 0,onDragLeave:M?a:void 0,onDrop:M?X0:void 0,children:[M0("textarea",{ref:K0,value:$,onChange:B?void 0:B0,onPaste:M?$0:void 0,onKeyDown:N,onClick:f,onFocus:()=>u(!0),onBlur:()=>{setTimeout(()=>u(!1),150)},readOnly:B,placeholder:q,className:w??k,style:F??I,rows:G?1:void 0},void 0,!1,void 0,this),M&&M0("input",{ref:Q0,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:(K)=>{let j=K.currentTarget.files;if(j)for(let n of j)c(n);K.currentTarget.value=""}},void 0,!1,void 0,this),(X.length>0||l)&&M0("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[X.map((K)=>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:r$(K),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!B&&M0("button",{onClick:(j)=>{j.stopPropagation(),W(K)},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)]},K,!0,void 0,this)),l&&M0(o2,{onClick:Y0},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h&&M0("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),A&&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 o2({onClick:$,size:J=16}){return M0("button",{onClick:(X)=>{X.stopPropagation(),$()},style:{width:`${J*2}px`,height:`${J*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:(X)=>{X.currentTarget.style.color="var(--color-text-secondary)"},onMouseLeave:(X)=>{X.currentTarget.style.color="var(--color-text-tertiary)"},children:M0("svg",{width:J,height:J,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 n$({images:$}){if(!$.length)return null;return M0("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px"},children:$.map((J)=>M0("div",{style:{width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:M0("img",{src:r$(J),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this)},J,!1,void 0,this))},void 0,!1,void 0,this)}import{SessionContext as Z8}from"@fabrika/annotations/runtime";import{useContext as b8,useEffect as D8,useRef as I8}from"react";import{jsxDEV as w0,Fragment as H4}from"react/jsx-dev-runtime";function g8($){let J=N2($);return J.length>80?J.slice(0,80)+"...":J}function O2({annotations:$,readOnly:J=!1,onSelect:X,onReveal:Q,includedRemoteIds:W,onToggleRemoteId:Y}){let{updateAnnotation:q,removeAnnotation:H,addAnnotationImage:G,removeAnnotationImage:B,activeAnnotationId:N,setActiveAnnotationId:f}=Y1(),L=b8(Z8),w=I8(new Map);D8(()=>{if(J||!N)return;let M=w.current.get(N);if(M)M.scrollIntoView({behavior:"smooth",block:"nearest"})},[N,J]);let F=(M)=>{f(M),V1(M,!0)},C=(M)=>{f(null),V1(M,!1)},_=(M)=>{if(M.id===N){f(null);return}f(M.id),X?.(M)},O=!!W&&!!Y,S=(M)=>{let A=O&&M.source==="remote";return w0("div",{ref:(Z)=>{if(Z)w.current.set(M.id,Z);else w.current.delete(M.id)},className:`group/ann relative px-3 py-2.5 transition-colors duration-150 ${J?"cursor-pointer ":""}${N===M.id?"bg-highlight-selected":A?"bg-accent-purple-muted/30 hover:bg-accent-purple-muted/50":"odd:bg-bg-elevated-half hover:bg-bg-input"}`,onMouseEnter:()=>F(M.id),onMouseLeave:()=>C(M.id),onClick:()=>_(M),children:[A&&M.author&&w0("div",{className:"flex items-center gap-1.5 mb-1.5",children:[w0("input",{type:"checkbox",checked:W.has(M.id),onChange:(Z)=>{Z.stopPropagation(),Y(M.id)},onClick:(Z)=>Z.stopPropagation(),className:"accent-accent-purple flex-shrink-0",title:"Include in submission"},void 0,!1,void 0,this),w0("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),w0("span",{className:"text-[11px] font-medium text-accent-purple font-body",children:M.author.name},void 0,!1,void 0,this),w0("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),w0("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:g8(M.snippet)},void 0,!1,void 0,this),J?w0(H4,{children:[M.note.trim()&&w0("div",{className:"text-[13px] font-body text-text-primary leading-relaxed",children:M.note},void 0,!1,void 0,this),w0(n$,{images:M.images||[]},void 0,!1,void 0,this)]},void 0,!0,void 0,this):A?w0("div",{className:"text-[13px] font-body text-text-primary leading-relaxed whitespace-pre-wrap",children:M.note},void 0,!1,void 0,this):w0("div",{onClick:(Z)=>Z.stopPropagation(),children:w0(i1,{note:M.note,onNoteChange:(Z)=>q(M.id,Z),images:M.images||[],onAddImage:(Z)=>G(M.id,Z),onRemoveImage:(Z)=>B(M.id,Z),sessionId:L,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),w0("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:[Q&&w0("button",{onClick:(Z)=>{Z.stopPropagation(),Q(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:w0("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[w0("circle",{cx:"12",cy:"12",r:"3"},void 0,!1,void 0,this),w0("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),!J&&!A&&w0("button",{onClick:(Z)=>{Z.stopPropagation(),H(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:w0("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[w0("polyline",{points:"3 6 5 6 21 6"},void 0,!1,void 0,this),w0("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 w0(H4,{children:$.map(S)},void 0,!1,void 0,this)}function S2($){let J=[],X=$.snippet.trim(),Q=$.context,W=N2(X);if(W!==X)J.push(`> ${W}`);else if($.filePath&&Q&&Q.lineStart!=null){let H=Q.lineStart,G=Q.lineEnd??H,B=X.split(`
|
|
1
|
+
var a3=Object.defineProperty;var e3=($)=>$;function $6($,J){this[$]=e3.bind(null,J)}var J6=($,J)=>{for(var X in J)a3($,X,{get:J[X],enumerable:!0,configurable:!0,set:$6.bind(J,X)})};import{createRoot as V7}from"react-dom/client";import{useEffect as n3,useMemo as v5,useRef as m5,useState as j1}from"react";import{useState as f9}from"react";import{AnnotationCtx as hQ,AnnotationHostContext as vQ,SessionContext as mQ,useAnnotationHost as cQ,useAnnotations as uQ}from"@fabrika/annotations/runtime";function I2($,J){let X=[],Q=u5($);for(let W of Q){let q=document.createRange();if(q.selectNodeContents(W),W===$.startContainer)q.setStart(W,$.startOffset);if(W===$.endContainer)q.setEnd(W,$.endOffset);let Y=q.toString();if(!Y||!Y.trim())continue;let H=document.createElement("mark");H.setAttribute("data-annotation-id",J);try{q.surroundContents(H)}catch{let G=q.extractContents();H.appendChild(G),q.insertNode(H)}X.push(H)}return X}function H2($){let J=$.parentElement;if(J?.classList.contains("select-none"))return!1;if(J?.closest("[data-annotation-id]"))return!1;return!0}function u5($){let J=[],X=$.commonAncestorContainer;if(X.nodeType===Node.TEXT_NODE)return J.push(X),J;let Q=document.createTreeWalker(X,NodeFilter.SHOW_TEXT),W;while(W=Q.nextNode()){if(!H2(W))continue;if($.intersectsNode(W))J.push(W)}return J}function X6($,J){let X=document.createRange();if(X.selectNodeContents($),$===J.startContainer)X.setStart($,J.startOffset);if($===J.endContainer)X.setEnd($,J.endOffset);return X.toString()}function p5($){let J="";for(let X of u5($))J+=X6(X,$);return J}function V1($,J){let X=document.querySelectorAll(`[data-annotation-id="${$}"]`);for(let Q of X)Q.classList.toggle("mark-active",J)}function k$($,J){if(J!=null&&J!==$)V1(J,!1);if($!=null)V1($,!0)}function A$($,J){let X=document.querySelectorAll(`[data-annotation-id="${$}"]`);for(let Q of X)Q.setAttribute("data-annotation-id",J)}function j$($,J){for(let X of J){if($.querySelector(`[data-annotation-id="${X.id}"]`))continue;let Q=X.snippet;if(!Q)continue;let{fullText:W,textNodes:q}=Q6($),Y=[],H=0;while(!0){let F=W.indexOf(Q,H);if(F===-1)break;Y.push(F),H=F+1}let[G]=Y;if(G===void 0)continue;let B=G;if(Y.length>1&&X.context){let F=-1;for(let C of Y){let _=0;if(X.context.before){let O=W.slice(Math.max(0,C-80),C);if(O.includes(X.context.before))_+=2;else if(X.context.before.length>10&&O.includes(X.context.before.slice(-10)))_+=1}if(X.context.after){let O=W.slice(C+Q.length,C+Q.length+80);if(O.includes(X.context.after))_+=2;else if(X.context.after.length>10&&O.includes(X.context.after.slice(0,10)))_+=1}if(_>F)F=_,B=C}}let N=B,f=B+Q.length,L=c5(q,N),w=c5(q,f);if(!L||!w)continue;try{let F=document.createRange();F.setStart(L.node,L.offset),F.setEnd(w.node,w.offset),I2(F,X.id)}catch{}}}function Q6($){let J=[],X="",Q=document.createTreeWalker($,NodeFilter.SHOW_TEXT),W;while(W=Q.nextNode()){if(!H2(W))continue;J.push({node:W,start:X.length}),X+=W.textContent||""}return{fullText:X,textNodes:J}}function c5($,J){for(let X=$.length-1;X>=0;X--){let Q=$[X];if(!Q||Q.start>J)continue;let W=J-Q.start,q=Q.node.textContent?.length??0;if(W<=q)return{node:Q.node,offset:W}}return null}function V$($){let J=document.querySelectorAll(`[data-annotation-id="${$}"]`);for(let X of J){let Q=X.parentNode;if(!Q)continue;if(X.tagName!=="MARK"){Q.removeChild(X);continue}while(X.firstChild)Q.insertBefore(X.firstChild,X);Q.removeChild(X),Q.normalize()}}function T$($,J){let X=l5($,"before",60),Q=l5($,"after",60),W=Y6($.startContainer,J);return{before:X,after:Q,hierarchy:W}}function l5($,J,X){let Q=W6(J==="before"?$.startContainer:$.endContainer);if(!Q)return"";let W="";if(J==="before"){let q=document.createTreeWalker(Q,NodeFilter.SHOW_TEXT),Y;while(Y=q.nextNode()){if(Y===$.startContainer){W+=(Y.textContent||"").slice(0,$.startOffset);break}if(!H2(Y))continue;W+=Y.textContent||""}if(W.length>X){W=W.slice(-X);let H=W.indexOf(" ");if(H>0)W=W.slice(H+1)}}else{let q=document.createTreeWalker(Q,NodeFilter.SHOW_TEXT),Y=!1,H;while(H=q.nextNode()){if(H===$.endContainer){W+=(H.textContent||"").slice($.endOffset),Y=!0;continue}if(Y){if(!H2(H))continue;W+=H.textContent||""}}if(W.length>X){W=W.slice(0,X);let G=W.lastIndexOf(" ");if(G>0)W=W.slice(0,G)}}return W.trim()}function W6($){let J=new Set(["DIV","P","LI","PRE","BLOCKQUOTE","SECTION","ARTICLE"]),X=$.parentElement;while(X){if(J.has(X.tagName))return X;X=X.parentElement}return null}function Y6($,J){let X=[],Q=$ instanceof Element?$:$.parentElement;while(Q&&Q!==J){let W=Q.getAttribute?.("data-task-id");if(W){let Y=Q.querySelector(".font-semibold");if(Y)X.unshift(Y.textContent?.trim()||W)}let q=q6(Q);if(q)X.unshift(q);Q=Q.parentElement}return X}function q6($){if($.getAttribute("data-md")==="section"){let X=$.getAttribute("data-md-title");if(X)return X}if($.tagName!=="DIV")return null;return $.querySelector(":scope > button > .font-heading, :scope > div > .font-heading")?.textContent?.trim()||null}function y2($){let J=$.snippet.trim(),X=$.context,Q=J.length<30;if(X&&Q&&(X.before||X.after)){let W=[];if(X.before)W.push(`...${X.before} `);if(W.push(`**${J}**`),X.after)W.push(` ${X.after}...`);return W.join("")}return J}function U2($){return{kind:$.kind,owns:(J)=>$.parse(J)!==null,find:(J,X)=>{let Q=$.parse(J);return Q===null?null:$.find(Q,X)},restore:(J,X)=>{let Q=$.parse(X.snippet);if(Q===null)return;$.restore?.(Q,J,X)},describe:(J)=>{let X=$.parse(J);if(X===null||!$.describe)return null;return $.describe(X)}}}function d5($){let J=document.createTreeWalker($,NodeFilter.SHOW_TEXT),X="";for(let Q=J.nextNode();Q;Q=J.nextNode()){let W=Q.parentElement?.closest("[aria-hidden='true']");if(W&&$.contains(W))continue;X+=Q.textContent??""}return X.trim()}function E2($,J,X){return{selector:$,snippet:(Q)=>{let W=Q.getAttribute(X);return W?`${J} ${W}`:null}}}var Z$=[E2("[data-md='item']","[Item]","data-md-label"),E2("[data-md='section']","[Section]","data-md-title"),E2("[data-md='checklist-item']","[Checklist]","data-md-label"),E2("[data-md='image']","[Image]","data-md-src"),{selector:"[data-md='callout']",snippet:($)=>{return`[Callout:${$.getAttribute("data-md-type")||"info"}] ${d5($).slice(0,60)||"Callout"}`}},{selector:"[data-md='note']",snippet:($)=>`[Note] ${d5($).slice(0,60)||"Note"}`},{selector:"[data-md='table'] tbody tr",snippet:($)=>{let J=Array.from($.querySelectorAll("td")).map((X)=>X.textContent?.trim()).filter(Boolean);return J.length?`[Row] ${J.join(" | ")}`:null}}],G6=["[data-md='choice-option']","[data-md='multichoice-option']","[data-md='userinput']","[data-md='rangeinput']"],e0=Z$.map(($)=>$.selector).join(", "),T1=[...Z$.map(($)=>$.selector),...G6].join(", ");function v0($){for(let J of Z$)if($.matches(J.selector))return J.snippet($);return null}var b$={kind:"block",parse:($)=>$.startsWith("[")?{snippet:$}:null,format:($)=>$.snippet,find:($,J)=>{for(let X of J.querySelectorAll(e0)){if(!(X instanceof HTMLElement))continue;if(v0(X)===$.snippet)return X}return null}};var g$="data-annotation-image",H6=/^\[Region:(rect|ellipse)\] ([\s\S]+) @(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*)$/;function U6($){if($==="rect")return"rect";if($==="ellipse")return"ellipse";return null}function x2($){if($===void 0)return null;let J=Number($);if(!Number.isInteger(J)||J<0||J>1e4)return null;return J}function i5($){return Math.min(1e4,Math.max(0,$))}function I$($,J,X){if(!($.width>0)||!($.height>0))return null;return{x:i5(Math.round(J/$.width*1e4)),y:i5(Math.round(X/$.height*1e4))}}function v2($,J){let X=Math.min($.x,J.x),Q=Math.min($.y,J.y);return{x:X,y:Q,w:Math.min(1e4-X,Math.abs($.x-J.x)),h:Math.min(1e4-Q,Math.abs($.y-J.y))}}function y$($){return $.w>=30&&$.h>=30}function r5($){return{left:`${$.x/100}%`,top:`${$.y/100}%`,width:`${$.w/100}%`,height:`${$.h/100}%`}}function h2($){return`${($/100).toFixed(1).replace(/\.0$/,"")}%`}function m2($){let J=`${h2($.x)}-${h2($.x+$.w)}`,X=`${h2($.y)}-${h2($.y+$.h)}`;return`[Region] ${$.src} — ${$.shape} x ${J}, y ${X} of the image`}function D$($,J){for(let X of J.querySelectorAll("[data-md='image']")){if(!(X instanceof HTMLElement))continue;if(X.getAttribute("data-md-src")!==$)continue;let Q=X.querySelector("[data-annotation-image]");if(Q instanceof HTMLElement)return Q}return null}function c2($,J){let X=r5(J);$.style.left=X.left,$.style.top=X.top,$.style.width=X.width,$.style.height=X.height}function u2($,J,X){let Q=document.createElement("div");return Q.className="ann-region",Q.setAttribute("data-annotation-id",X),Q.setAttribute("data-annotation-region",J),c2(Q,$),Q}var B2={kind:"region",parse:($)=>{let J=H6.exec($);if(!J)return null;let X=U6(J[1]),Q=J[2],W=x2(J[3]),q=x2(J[4]),Y=x2(J[5]),H=x2(J[6]);if(X===null||Q===void 0)return null;if(W===null||q===null||Y===null||H===null)return null;if(Y<1||H<1)return null;return{src:Q,shape:X,x:W,y:q,w:Y,h:H}},format:($)=>`[Region:${$.shape}] ${$.src} @${$.x},${$.y},${$.w},${$.h}`,find:($,J)=>D$($.src,J),restore:($,J,X)=>{if(J.querySelector(`[data-annotation-id="${X.id}"]`))return;let Q=D$($.src,J);if(!Q)return;Q.appendChild(u2($,$.shape,X.id))},describe:m2};var E$={kind:"text",parse:($)=>$?{text:$}:null,format:($)=>$.text,find:()=>null,restore:($,J,X)=>{j$(J,[X])}};var p2=[U2(B2),U2(b$),U2(E$)];function x$($,J){for(let X of p2){let Q=X.find($,J);if(Q)return Q}return null}function h$($,J){for(let X of J){if(!X.snippet)continue;for(let Q of p2)Q.restore($,X)}}function N2($){for(let J of p2){let X=J.describe($);if(X!==null)return X}return $}import{AnnotationCtx as PX,SessionContext as kX,useAnnotationHost as AX}from"@fabrika/annotations/runtime";import{useEffect as TX,useRef as ZX,useState as bX}from"react";var U={};J6(U,{void:()=>r6,util:()=>o,unknown:()=>d6,union:()=>t6,undefined:()=>u6,tuple:()=>$8,transformer:()=>B8,symbol:()=>c6,string:()=>X4,strictObject:()=>s6,setErrorMap:()=>w6,set:()=>Q8,record:()=>J8,quotelessJson:()=>B6,promise:()=>U8,preprocess:()=>F8,pipeline:()=>f8,ostring:()=>L8,optional:()=>N8,onumber:()=>M8,oboolean:()=>_8,objectUtil:()=>v$,object:()=>o6,number:()=>Q4,nullable:()=>w8,null:()=>p6,never:()=>i6,nativeEnum:()=>H8,nan:()=>h6,map:()=>X8,makeIssue:()=>w2,literal:()=>q8,lazy:()=>Y8,late:()=>E6,isValid:()=>$1,isDirty:()=>d2,isAsync:()=>b1,isAborted:()=>l2,intersection:()=>e6,instanceof:()=>x6,getParsedType:()=>m0,getErrorMap:()=>Z1,function:()=>W8,enum:()=>G8,effect:()=>B8,discriminatedUnion:()=>a6,defaultErrorMap:()=>i0,datetimeRegex:()=>e5,date:()=>m6,custom:()=>J4,coerce:()=>K8,boolean:()=>W4,bigint:()=>v6,array:()=>n6,any:()=>l6,addIssueToContext:()=>P,ZodVoid:()=>f2,ZodUnknown:()=>J1,ZodUnion:()=>x1,ZodUndefined:()=>y1,ZodType:()=>r,ZodTuple:()=>u0,ZodTransformer:()=>I0,ZodSymbol:()=>F2,ZodString:()=>Z0,ZodSet:()=>F1,ZodSchema:()=>r,ZodRecord:()=>L2,ZodReadonly:()=>l1,ZodPromise:()=>f1,ZodPipeline:()=>K2,ZodParsedType:()=>R,ZodOptional:()=>D0,ZodObject:()=>N0,ZodNumber:()=>X1,ZodNullable:()=>n0,ZodNull:()=>E1,ZodNever:()=>c0,ZodNativeEnum:()=>c1,ZodNaN:()=>_2,ZodMap:()=>M2,ZodLiteral:()=>m1,ZodLazy:()=>v1,ZodIssueCode:()=>z,ZodIntersection:()=>h1,ZodFunction:()=>g1,ZodFirstPartyTypeKind:()=>x,ZodError:()=>P0,ZodEnum:()=>W1,ZodEffects:()=>I0,ZodDiscriminatedUnion:()=>i2,ZodDefault:()=>u1,ZodDate:()=>N1,ZodCatch:()=>p1,ZodBranded:()=>r2,ZodBoolean:()=>I1,ZodBigInt:()=>Q1,ZodArray:()=>b0,ZodAny:()=>w1,Schema:()=>r,ParseStatus:()=>z0,OK:()=>O0,NEVER:()=>z8,INVALID:()=>y,EMPTY_PATH:()=>F6,DIRTY:()=>B1,BRAND:()=>y6});var o;(function($){$.assertEqual=(W)=>{};function J(W){}$.assertIs=J;function X(W){throw Error()}$.assertNever=X,$.arrayToEnum=(W)=>{let q={};for(let Y of W)q[Y]=Y;return q},$.getValidEnumValues=(W)=>{let q=$.objectKeys(W).filter((H)=>typeof W[W[H]]!=="number"),Y={};for(let H of q)Y[H]=W[H];return $.objectValues(Y)},$.objectValues=(W)=>{return $.objectKeys(W).map(function(q){return W[q]})},$.objectKeys=typeof Object.keys==="function"?(W)=>Object.keys(W):(W)=>{let q=[];for(let Y in W)if(Object.prototype.hasOwnProperty.call(W,Y))q.push(Y);return q},$.find=(W,q)=>{for(let Y of W)if(q(Y))return Y;return},$.isInteger=typeof Number.isInteger==="function"?(W)=>Number.isInteger(W):(W)=>typeof W==="number"&&Number.isFinite(W)&&Math.floor(W)===W;function Q(W,q=" | "){return W.map((Y)=>typeof Y==="string"?`'${Y}'`:Y).join(q)}$.joinValues=Q,$.jsonStringifyReplacer=(W,q)=>{if(typeof q==="bigint")return q.toString();return q}})(o||(o={}));var v$;(function($){$.mergeShapes=(J,X)=>{return{...J,...X}}})(v$||(v$={}));var R=o.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),m0=($)=>{switch(typeof $){case"undefined":return R.undefined;case"string":return R.string;case"number":return Number.isNaN($)?R.nan:R.number;case"boolean":return R.boolean;case"function":return R.function;case"bigint":return R.bigint;case"symbol":return R.symbol;case"object":if(Array.isArray($))return R.array;if($===null)return R.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return R.promise;if(typeof Map<"u"&&$ instanceof Map)return R.map;if(typeof Set<"u"&&$ instanceof Set)return R.set;if(typeof Date<"u"&&$ instanceof Date)return R.date;return R.object;default:return R.unknown}};var z=o.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"]),B6=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class P0 extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(X)=>{this.issues=[...this.issues,X]},this.addIssues=(X=[])=>{this.issues=[...this.issues,...X]};let J=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,J);else this.__proto__=J;this.name="ZodError",this.issues=$}format($){let J=$||function(W){return W.message},X={_errors:[]},Q=(W)=>{for(let q of W.issues)if(q.code==="invalid_union")q.unionErrors.map(Q);else if(q.code==="invalid_return_type")Q(q.returnTypeError);else if(q.code==="invalid_arguments")Q(q.argumentsError);else if(q.path.length===0)X._errors.push(J(q));else{let Y=X,H=0;while(H<q.path.length){let G=q.path[H];if(H!==q.path.length-1)Y[G]=Y[G]||{_errors:[]};else Y[G]=Y[G]||{_errors:[]},Y[G]._errors.push(J(q));Y=Y[G],H++}}};return Q(this),X}static assert($){if(!($ instanceof P0))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,o.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(J)=>J.message){let J={},X=[];for(let Q of this.issues)if(Q.path.length>0){let W=Q.path[0];J[W]=J[W]||[],J[W].push($(Q))}else X.push($(Q));return{formErrors:X,fieldErrors:J}}get formErrors(){return this.flatten()}}P0.create=($)=>{return new P0($)};var N6=($,J)=>{let X;switch($.code){case z.invalid_type:if($.received===R.undefined)X="Required";else X=`Expected ${$.expected}, received ${$.received}`;break;case z.invalid_literal:X=`Invalid literal value, expected ${JSON.stringify($.expected,o.jsonStringifyReplacer)}`;break;case z.unrecognized_keys:X=`Unrecognized key(s) in object: ${o.joinValues($.keys,", ")}`;break;case z.invalid_union:X="Invalid input";break;case z.invalid_union_discriminator:X=`Invalid discriminator value. Expected ${o.joinValues($.options)}`;break;case z.invalid_enum_value:X=`Invalid enum value. Expected ${o.joinValues($.options)}, received '${$.received}'`;break;case z.invalid_arguments:X="Invalid function arguments";break;case z.invalid_return_type:X="Invalid function return type";break;case z.invalid_date:X="Invalid date";break;case z.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(X=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")X=`${X} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)X=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)X=`Invalid input: must end with "${$.validation.endsWith}"`;else o.assertNever($.validation);else if($.validation!=="regex")X=`Invalid ${$.validation}`;else X="Invalid";break;case z.too_small:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else X="Invalid input";break;case z.too_big:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")X=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else X="Invalid input";break;case z.custom:X="Invalid input";break;case z.invalid_intersection_types:X="Intersection results could not be merged";break;case z.not_multiple_of:X=`Number must be a multiple of ${$.multipleOf}`;break;case z.not_finite:X="Number must be finite";break;default:X=J.defaultError,o.assertNever($)}return{message:X}},i0=N6;var n5=i0;function w6($){n5=$}function Z1(){return n5}var w2=($)=>{let{data:J,path:X,errorMaps:Q,issueData:W}=$,q=[...X,...W.path||[]],Y={...W,path:q};if(W.message!==void 0)return{...W,path:q,message:W.message};let H="",G=Q.filter((B)=>!!B).slice().reverse();for(let B of G)H=B(Y,{data:J,defaultError:H}).message;return{...W,path:q,message:H}},F6=[];function P($,J){let X=Z1(),Q=w2({issueData:J,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,X,X===i0?void 0:i0].filter((W)=>!!W)});$.common.issues.push(Q)}class z0{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,J){let X=[];for(let Q of J){if(Q.status==="aborted")return y;if(Q.status==="dirty")$.dirty();X.push(Q.value)}return{status:$.value,value:X}}static async mergeObjectAsync($,J){let X=[];for(let Q of J){let W=await Q.key,q=await Q.value;X.push({key:W,value:q})}return z0.mergeObjectSync($,X)}static mergeObjectSync($,J){let X={};for(let Q of J){let{key:W,value:q}=Q;if(W.status==="aborted")return y;if(q.status==="aborted")return y;if(W.status==="dirty")$.dirty();if(q.status==="dirty")$.dirty();if(W.value!=="__proto__"&&(typeof q.value<"u"||Q.alwaysSet))X[W.value]=q.value}return{status:$.value,value:X}}}var y=Object.freeze({status:"aborted"}),B1=($)=>({status:"dirty",value:$}),O0=($)=>({status:"valid",value:$}),l2=($)=>$.status==="aborted",d2=($)=>$.status==="dirty",$1=($)=>$.status==="valid",b1=($)=>typeof Promise<"u"&&$ instanceof Promise;var b;(function($){$.errToObj=(J)=>typeof J==="string"?{message:J}:J||{},$.toString=(J)=>typeof J==="string"?J:J?.message})(b||(b={}));class g0{constructor($,J,X,Q){this._cachedPath=[],this.parent=$,this.data=J,this._path=X,this._key=Q}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 o5=($,J)=>{if($1(J))return{success:!0,data:J.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 X=new P0($.common.issues);return this._error=X,this._error}}}};function p($){if(!$)return{};let{errorMap:J,invalid_type_error:X,required_error:Q,description:W}=$;if(J&&(X||Q))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(J)return{errorMap:J,description:W};return{errorMap:(Y,H)=>{let{message:G}=$;if(Y.code==="invalid_enum_value")return{message:G??H.defaultError};if(typeof H.data>"u")return{message:G??Q??H.defaultError};if(Y.code!=="invalid_type")return{message:H.defaultError};return{message:G??X??H.defaultError}},description:W}}class r{get description(){return this._def.description}_getType($){return m0($.data)}_getOrReturnCtx($,J){return J||{common:$.parent.common,data:$.data,parsedType:m0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new z0,ctx:{common:$.parent.common,data:$.data,parsedType:m0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let J=this._parse($);if(b1(J))throw Error("Synchronous parse encountered promise.");return J}_parseAsync($){let J=this._parse($);return Promise.resolve(J)}parse($,J){let X=this.safeParse($,J);if(X.success)return X.data;throw X.error}safeParse($,J){let X={common:{issues:[],async:J?.async??!1,contextualErrorMap:J?.errorMap},path:J?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:m0($)},Q=this._parseSync({data:$,path:X.path,parent:X});return o5(X,Q)}"~validate"($){let J={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:m0($)};if(!this["~standard"].async)try{let X=this._parseSync({data:$,path:[],parent:J});return $1(X)?{value:X.value}:{issues:J.common.issues}}catch(X){if(X?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;J.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:J}).then((X)=>$1(X)?{value:X.value}:{issues:J.common.issues})}async parseAsync($,J){let X=await this.safeParseAsync($,J);if(X.success)return X.data;throw X.error}async safeParseAsync($,J){let X={common:{issues:[],contextualErrorMap:J?.errorMap,async:!0},path:J?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:m0($)},Q=this._parse({data:$,path:X.path,parent:X}),W=await(b1(Q)?Q:Promise.resolve(Q));return o5(X,W)}refine($,J){let X=(Q)=>{if(typeof J==="string"||typeof J>"u")return{message:J};else if(typeof J==="function")return J(Q);else return J};return this._refinement((Q,W)=>{let q=$(Q),Y=()=>W.addIssue({code:z.custom,...X(Q)});if(typeof Promise<"u"&&q instanceof Promise)return q.then((H)=>{if(!H)return Y(),!1;else return!0});if(!q)return Y(),!1;else return!0})}refinement($,J){return this._refinement((X,Q)=>{if(!$(X))return Q.addIssue(typeof J==="function"?J(X,Q):J),!1;else return!0})}_refinement($){return new I0({schema:this,typeName:x.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:(J)=>this["~validate"](J)}}optional(){return D0.create(this,this._def)}nullable(){return n0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return b0.create(this)}promise(){return f1.create(this,this._def)}or($){return x1.create([this,$],this._def)}and($){return h1.create(this,$,this._def)}transform($){return new I0({...p(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:$}})}default($){let J=typeof $==="function"?$:()=>$;return new u1({...p(this._def),innerType:this,defaultValue:J,typeName:x.ZodDefault})}brand(){return new r2({typeName:x.ZodBranded,type:this,...p(this._def)})}catch($){let J=typeof $==="function"?$:()=>$;return new p1({...p(this._def),innerType:this,catchValue:J,typeName:x.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return K2.create(this,$)}readonly(){return l1.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var f6=/^c[^\s-]{8,}$/i,L6=/^[0-9a-z]+$/,M6=/^[0-9A-HJKMNP-TV-Z]{26}$/i,_6=/^[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,K6=/^[a-z0-9_-]{21}$/i,z6=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,O6=/^[-+]?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)?)??$/,S6=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,R6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",m$,C6=/^(?:(?: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])$/,P6=/^(?:(?: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])$/,k6=/^(([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]))$/,A6=/^(([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])$/,j6=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,V6=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,t5="((\\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])))",T6=new RegExp(`^${t5}$`);function a5($){let J="[0-5]\\d";if($.precision)J=`${J}\\.\\d{${$.precision}}`;else if($.precision==null)J=`${J}(\\.\\d+)?`;let X=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${J})${X}`}function Z6($){return new RegExp(`^${a5($)}$`)}function e5($){let J=`${t5}T${a5($)}`,X=[];if(X.push($.local?"Z?":"Z"),$.offset)X.push("([+-]\\d{2}:?\\d{2})");return J=`${J}(${X.join("|")})`,new RegExp(`^${J}$`)}function b6($,J){if((J==="v4"||!J)&&C6.test($))return!0;if((J==="v6"||!J)&&k6.test($))return!0;return!1}function D6($,J){if(!z6.test($))return!1;try{let[X]=$.split(".");if(!X)return!1;let Q=X.replace(/-/g,"+").replace(/_/g,"/").padEnd(X.length+(4-X.length%4)%4,"="),W=JSON.parse(atob(Q));if(typeof W!=="object"||W===null)return!1;if("typ"in W&&W?.typ!=="JWT")return!1;if(!W.alg)return!1;if(J&&W.alg!==J)return!1;return!0}catch{return!1}}function g6($,J){if((J==="v4"||!J)&&P6.test($))return!0;if((J==="v6"||!J)&&A6.test($))return!0;return!1}class Z0 extends r{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==R.string){let W=this._getOrReturnCtx($);return P(W,{code:z.invalid_type,expected:R.string,received:W.parsedType}),y}let X=new z0,Q=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.length<W.value)Q=this._getOrReturnCtx($,Q),P(Q,{code:z.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),X.dirty()}else if(W.kind==="max"){if($.data.length>W.value)Q=this._getOrReturnCtx($,Q),P(Q,{code:z.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),X.dirty()}else if(W.kind==="length"){let q=$.data.length>W.value,Y=$.data.length<W.value;if(q||Y){if(Q=this._getOrReturnCtx($,Q),q)P(Q,{code:z.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});else if(Y)P(Q,{code:z.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});X.dirty()}}else if(W.kind==="email"){if(!S6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"email",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="emoji"){if(!m$)m$=new RegExp(R6,"u");if(!m$.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"emoji",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="uuid"){if(!_6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"uuid",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="nanoid"){if(!K6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"nanoid",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="cuid"){if(!f6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"cuid",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="cuid2"){if(!L6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"cuid2",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="ulid"){if(!M6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"ulid",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="url")try{new URL($.data)}catch{Q=this._getOrReturnCtx($,Q),P(Q,{validation:"url",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="regex"){if(W.regex.lastIndex=0,!W.regex.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"regex",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="trim")$.data=$.data.trim();else if(W.kind==="includes"){if(!$.data.includes(W.value,W.position))Q=this._getOrReturnCtx($,Q),P(Q,{code:z.invalid_string,validation:{includes:W.value,position:W.position},message:W.message}),X.dirty()}else if(W.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(W.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(W.kind==="startsWith"){if(!$.data.startsWith(W.value))Q=this._getOrReturnCtx($,Q),P(Q,{code:z.invalid_string,validation:{startsWith:W.value},message:W.message}),X.dirty()}else if(W.kind==="endsWith"){if(!$.data.endsWith(W.value))Q=this._getOrReturnCtx($,Q),P(Q,{code:z.invalid_string,validation:{endsWith:W.value},message:W.message}),X.dirty()}else if(W.kind==="datetime"){if(!e5(W).test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{code:z.invalid_string,validation:"datetime",message:W.message}),X.dirty()}else if(W.kind==="date"){if(!T6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{code:z.invalid_string,validation:"date",message:W.message}),X.dirty()}else if(W.kind==="time"){if(!Z6(W).test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{code:z.invalid_string,validation:"time",message:W.message}),X.dirty()}else if(W.kind==="duration"){if(!O6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"duration",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="ip"){if(!b6($.data,W.version))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"ip",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="jwt"){if(!D6($.data,W.alg))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"jwt",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="cidr"){if(!g6($.data,W.version))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"cidr",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="base64"){if(!j6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"base64",code:z.invalid_string,message:W.message}),X.dirty()}else if(W.kind==="base64url"){if(!V6.test($.data))Q=this._getOrReturnCtx($,Q),P(Q,{validation:"base64url",code:z.invalid_string,message:W.message}),X.dirty()}else o.assertNever(W);return{status:X.value,value:$.data}}_regex($,J,X){return this.refinement((Q)=>$.test(Q),{validation:J,code:z.invalid_string,...b.errToObj(X)})}_addCheck($){return new Z0({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...b.errToObj($)})}url($){return this._addCheck({kind:"url",...b.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...b.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...b.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...b.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...b.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...b.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...b.errToObj($)})}base64($){return this._addCheck({kind:"base64",...b.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...b.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...b.errToObj($)})}ip($){return this._addCheck({kind:"ip",...b.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...b.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,...b.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,...b.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...b.errToObj($)})}regex($,J){return this._addCheck({kind:"regex",regex:$,...b.errToObj(J)})}includes($,J){return this._addCheck({kind:"includes",value:$,position:J?.position,...b.errToObj(J?.message)})}startsWith($,J){return this._addCheck({kind:"startsWith",value:$,...b.errToObj(J)})}endsWith($,J){return this._addCheck({kind:"endsWith",value:$,...b.errToObj(J)})}min($,J){return this._addCheck({kind:"min",value:$,...b.errToObj(J)})}max($,J){return this._addCheck({kind:"max",value:$,...b.errToObj(J)})}length($,J){return this._addCheck({kind:"length",value:$,...b.errToObj(J)})}nonempty($){return this.min(1,b.errToObj($))}trim(){return new Z0({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Z0({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Z0({...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 J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxLength(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}}Z0.create=($)=>{return new Z0({checks:[],typeName:x.ZodString,coerce:$?.coerce??!1,...p($)})};function I6($,J){let X=($.toString().split(".")[1]||"").length,Q=(J.toString().split(".")[1]||"").length,W=X>Q?X:Q,q=Number.parseInt($.toFixed(W).replace(".","")),Y=Number.parseInt(J.toFixed(W).replace(".",""));return q%Y/10**W}class X1 extends r{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($)!==R.number){let W=this._getOrReturnCtx($);return P(W,{code:z.invalid_type,expected:R.number,received:W.parsedType}),y}let X=void 0,Q=new z0;for(let W of this._def.checks)if(W.kind==="int"){if(!o.isInteger($.data))X=this._getOrReturnCtx($,X),P(X,{code:z.invalid_type,expected:"integer",received:"float",message:W.message}),Q.dirty()}else if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)X=this._getOrReturnCtx($,X),P(X,{code:z.too_small,minimum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)X=this._getOrReturnCtx($,X),P(X,{code:z.too_big,maximum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="multipleOf"){if(I6($.data,W.value)!==0)X=this._getOrReturnCtx($,X),P(X,{code:z.not_multiple_of,multipleOf:W.value,message:W.message}),Q.dirty()}else if(W.kind==="finite"){if(!Number.isFinite($.data))X=this._getOrReturnCtx($,X),P(X,{code:z.not_finite,message:W.message}),Q.dirty()}else o.assertNever(W);return{status:Q.value,value:$.data}}gte($,J){return this.setLimit("min",$,!0,b.toString(J))}gt($,J){return this.setLimit("min",$,!1,b.toString(J))}lte($,J){return this.setLimit("max",$,!0,b.toString(J))}lt($,J){return this.setLimit("max",$,!1,b.toString(J))}setLimit($,J,X,Q){return new X1({...this._def,checks:[...this._def.checks,{kind:$,value:J,inclusive:X,message:b.toString(Q)}]})}_addCheck($){return new X1({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:b.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString($)})}multipleOf($,J){return this._addCheck({kind:"multipleOf",value:$,message:b.toString(J)})}finite($){return this._addCheck({kind:"finite",message:b.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString($)})}get minValue(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxValue(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&o.isInteger($.value))}get isFinite(){let $=null,J=null;for(let X of this._def.checks)if(X.kind==="finite"||X.kind==="int"||X.kind==="multipleOf")return!0;else if(X.kind==="min"){if(J===null||X.value>J)J=X.value}else if(X.kind==="max"){if($===null||X.value<$)$=X.value}return Number.isFinite(J)&&Number.isFinite($)}}X1.create=($)=>{return new X1({checks:[],typeName:x.ZodNumber,coerce:$?.coerce||!1,...p($)})};class Q1 extends r{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($)!==R.bigint)return this._getInvalidInput($);let X=void 0,Q=new z0;for(let W of this._def.checks)if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)X=this._getOrReturnCtx($,X),P(X,{code:z.too_small,type:"bigint",minimum:W.value,inclusive:W.inclusive,message:W.message}),Q.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)X=this._getOrReturnCtx($,X),P(X,{code:z.too_big,type:"bigint",maximum:W.value,inclusive:W.inclusive,message:W.message}),Q.dirty()}else if(W.kind==="multipleOf"){if($.data%W.value!==BigInt(0))X=this._getOrReturnCtx($,X),P(X,{code:z.not_multiple_of,multipleOf:W.value,message:W.message}),Q.dirty()}else o.assertNever(W);return{status:Q.value,value:$.data}}_getInvalidInput($){let J=this._getOrReturnCtx($);return P(J,{code:z.invalid_type,expected:R.bigint,received:J.parsedType}),y}gte($,J){return this.setLimit("min",$,!0,b.toString(J))}gt($,J){return this.setLimit("min",$,!1,b.toString(J))}lte($,J){return this.setLimit("max",$,!0,b.toString(J))}lt($,J){return this.setLimit("max",$,!1,b.toString(J))}setLimit($,J,X,Q){return new Q1({...this._def,checks:[...this._def.checks,{kind:$,value:J,inclusive:X,message:b.toString(Q)}]})}_addCheck($){return new Q1({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString($)})}multipleOf($,J){return this._addCheck({kind:"multipleOf",value:$,message:b.toString(J)})}get minValue(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxValue(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}}Q1.create=($)=>{return new Q1({checks:[],typeName:x.ZodBigInt,coerce:$?.coerce??!1,...p($)})};class I1 extends r{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==R.boolean){let X=this._getOrReturnCtx($);return P(X,{code:z.invalid_type,expected:R.boolean,received:X.parsedType}),y}return O0($.data)}}I1.create=($)=>{return new I1({typeName:x.ZodBoolean,coerce:$?.coerce||!1,...p($)})};class N1 extends r{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==R.date){let W=this._getOrReturnCtx($);return P(W,{code:z.invalid_type,expected:R.date,received:W.parsedType}),y}if(Number.isNaN($.data.getTime())){let W=this._getOrReturnCtx($);return P(W,{code:z.invalid_date}),y}let X=new z0,Q=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.getTime()<W.value)Q=this._getOrReturnCtx($,Q),P(Q,{code:z.too_small,message:W.message,inclusive:!0,exact:!1,minimum:W.value,type:"date"}),X.dirty()}else if(W.kind==="max"){if($.data.getTime()>W.value)Q=this._getOrReturnCtx($,Q),P(Q,{code:z.too_big,message:W.message,inclusive:!0,exact:!1,maximum:W.value,type:"date"}),X.dirty()}else o.assertNever(W);return{status:X.value,value:new Date($.data.getTime())}}_addCheck($){return new N1({...this._def,checks:[...this._def.checks,$]})}min($,J){return this._addCheck({kind:"min",value:$.getTime(),message:b.toString(J)})}max($,J){return this._addCheck({kind:"max",value:$.getTime(),message:b.toString(J)})}get minDate(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $!=null?new Date($):null}}N1.create=($)=>{return new N1({checks:[],coerce:$?.coerce||!1,typeName:x.ZodDate,...p($)})};class F2 extends r{_parse($){if(this._getType($)!==R.symbol){let X=this._getOrReturnCtx($);return P(X,{code:z.invalid_type,expected:R.symbol,received:X.parsedType}),y}return O0($.data)}}F2.create=($)=>{return new F2({typeName:x.ZodSymbol,...p($)})};class y1 extends r{_parse($){if(this._getType($)!==R.undefined){let X=this._getOrReturnCtx($);return P(X,{code:z.invalid_type,expected:R.undefined,received:X.parsedType}),y}return O0($.data)}}y1.create=($)=>{return new y1({typeName:x.ZodUndefined,...p($)})};class E1 extends r{_parse($){if(this._getType($)!==R.null){let X=this._getOrReturnCtx($);return P(X,{code:z.invalid_type,expected:R.null,received:X.parsedType}),y}return O0($.data)}}E1.create=($)=>{return new E1({typeName:x.ZodNull,...p($)})};class w1 extends r{constructor(){super(...arguments);this._any=!0}_parse($){return O0($.data)}}w1.create=($)=>{return new w1({typeName:x.ZodAny,...p($)})};class J1 extends r{constructor(){super(...arguments);this._unknown=!0}_parse($){return O0($.data)}}J1.create=($)=>{return new J1({typeName:x.ZodUnknown,...p($)})};class c0 extends r{_parse($){let J=this._getOrReturnCtx($);return P(J,{code:z.invalid_type,expected:R.never,received:J.parsedType}),y}}c0.create=($)=>{return new c0({typeName:x.ZodNever,...p($)})};class f2 extends r{_parse($){if(this._getType($)!==R.undefined){let X=this._getOrReturnCtx($);return P(X,{code:z.invalid_type,expected:R.void,received:X.parsedType}),y}return O0($.data)}}f2.create=($)=>{return new f2({typeName:x.ZodVoid,...p($)})};class b0 extends r{_parse($){let{ctx:J,status:X}=this._processInputParams($),Q=this._def;if(J.parsedType!==R.array)return P(J,{code:z.invalid_type,expected:R.array,received:J.parsedType}),y;if(Q.exactLength!==null){let q=J.data.length>Q.exactLength.value,Y=J.data.length<Q.exactLength.value;if(q||Y)P(J,{code:q?z.too_big:z.too_small,minimum:Y?Q.exactLength.value:void 0,maximum:q?Q.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:Q.exactLength.message}),X.dirty()}if(Q.minLength!==null){if(J.data.length<Q.minLength.value)P(J,{code:z.too_small,minimum:Q.minLength.value,type:"array",inclusive:!0,exact:!1,message:Q.minLength.message}),X.dirty()}if(Q.maxLength!==null){if(J.data.length>Q.maxLength.value)P(J,{code:z.too_big,maximum:Q.maxLength.value,type:"array",inclusive:!0,exact:!1,message:Q.maxLength.message}),X.dirty()}if(J.common.async)return Promise.all([...J.data].map((q,Y)=>{return Q.type._parseAsync(new g0(J,q,J.path,Y))})).then((q)=>{return z0.mergeArray(X,q)});let W=[...J.data].map((q,Y)=>{return Q.type._parseSync(new g0(J,q,J.path,Y))});return z0.mergeArray(X,W)}get element(){return this._def.type}min($,J){return new b0({...this._def,minLength:{value:$,message:b.toString(J)}})}max($,J){return new b0({...this._def,maxLength:{value:$,message:b.toString(J)}})}length($,J){return new b0({...this._def,exactLength:{value:$,message:b.toString(J)}})}nonempty($){return this.min(1,$)}}b0.create=($,J)=>{return new b0({type:$,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...p(J)})};function D1($){if($ instanceof N0){let J={};for(let X in $.shape){let Q=$.shape[X];J[X]=D0.create(D1(Q))}return new N0({...$._def,shape:()=>J})}else if($ instanceof b0)return new b0({...$._def,type:D1($.element)});else if($ instanceof D0)return D0.create(D1($.unwrap()));else if($ instanceof n0)return n0.create(D1($.unwrap()));else if($ instanceof u0)return u0.create($.items.map((J)=>D1(J)));else return $}class N0 extends r{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(),J=o.objectKeys($);return this._cached={shape:$,keys:J},this._cached}_parse($){if(this._getType($)!==R.object){let G=this._getOrReturnCtx($);return P(G,{code:z.invalid_type,expected:R.object,received:G.parsedType}),y}let{status:X,ctx:Q}=this._processInputParams($),{shape:W,keys:q}=this._getCached(),Y=[];if(!(this._def.catchall instanceof c0&&this._def.unknownKeys==="strip")){for(let G in Q.data)if(!q.includes(G))Y.push(G)}let H=[];for(let G of q){let B=W[G],N=Q.data[G];H.push({key:{status:"valid",value:G},value:B._parse(new g0(Q,N,Q.path,G)),alwaysSet:G in Q.data})}if(this._def.catchall instanceof c0){let G=this._def.unknownKeys;if(G==="passthrough")for(let B of Y)H.push({key:{status:"valid",value:B},value:{status:"valid",value:Q.data[B]}});else if(G==="strict"){if(Y.length>0)P(Q,{code:z.unrecognized_keys,keys:Y}),X.dirty()}else if(G==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let G=this._def.catchall;for(let B of Y){let N=Q.data[B];H.push({key:{status:"valid",value:B},value:G._parse(new g0(Q,N,Q.path,B)),alwaysSet:B in Q.data})}}if(Q.common.async)return Promise.resolve().then(async()=>{let G=[];for(let B of H){let N=await B.key,f=await B.value;G.push({key:N,value:f,alwaysSet:B.alwaysSet})}return G}).then((G)=>{return z0.mergeObjectSync(X,G)});else return z0.mergeObjectSync(X,H)}get shape(){return this._def.shape()}strict($){return b.errToObj,new N0({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(J,X)=>{let Q=this._def.errorMap?.(J,X).message??X.defaultError;if(J.code==="unrecognized_keys")return{message:b.errToObj($).message??Q};return{message:Q}}}:{}})}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:x.ZodObject})}setKey($,J){return this.augment({[$]:J})}catchall($){return new N0({...this._def,catchall:$})}pick($){let J={};for(let X of o.objectKeys($))if($[X]&&this.shape[X])J[X]=this.shape[X];return new N0({...this._def,shape:()=>J})}omit($){let J={};for(let X of o.objectKeys(this.shape))if(!$[X])J[X]=this.shape[X];return new N0({...this._def,shape:()=>J})}deepPartial(){return D1(this)}partial($){let J={};for(let X of o.objectKeys(this.shape)){let Q=this.shape[X];if($&&!$[X])J[X]=Q;else J[X]=Q.optional()}return new N0({...this._def,shape:()=>J})}required($){let J={};for(let X of o.objectKeys(this.shape))if($&&!$[X])J[X]=this.shape[X];else{let W=this.shape[X];while(W instanceof D0)W=W._def.innerType;J[X]=W}return new N0({...this._def,shape:()=>J})}keyof(){return $4(o.objectKeys(this.shape))}}N0.create=($,J)=>{return new N0({shape:()=>$,unknownKeys:"strip",catchall:c0.create(),typeName:x.ZodObject,...p(J)})};N0.strictCreate=($,J)=>{return new N0({shape:()=>$,unknownKeys:"strict",catchall:c0.create(),typeName:x.ZodObject,...p(J)})};N0.lazycreate=($,J)=>{return new N0({shape:$,unknownKeys:"strip",catchall:c0.create(),typeName:x.ZodObject,...p(J)})};class x1 extends r{_parse($){let{ctx:J}=this._processInputParams($),X=this._def.options;function Q(W){for(let Y of W)if(Y.result.status==="valid")return Y.result;for(let Y of W)if(Y.result.status==="dirty")return J.common.issues.push(...Y.ctx.common.issues),Y.result;let q=W.map((Y)=>new P0(Y.ctx.common.issues));return P(J,{code:z.invalid_union,unionErrors:q}),y}if(J.common.async)return Promise.all(X.map(async(W)=>{let q={...J,common:{...J.common,issues:[]},parent:null};return{result:await W._parseAsync({data:J.data,path:J.path,parent:q}),ctx:q}})).then(Q);else{let W=void 0,q=[];for(let H of X){let G={...J,common:{...J.common,issues:[]},parent:null},B=H._parseSync({data:J.data,path:J.path,parent:G});if(B.status==="valid")return B;else if(B.status==="dirty"&&!W)W={result:B,ctx:G};if(G.common.issues.length)q.push(G.common.issues)}if(W)return J.common.issues.push(...W.ctx.common.issues),W.result;let Y=q.map((H)=>new P0(H));return P(J,{code:z.invalid_union,unionErrors:Y}),y}}get options(){return this._def.options}}x1.create=($,J)=>{return new x1({options:$,typeName:x.ZodUnion,...p(J)})};var r0=($)=>{if($ instanceof v1)return r0($.schema);else if($ instanceof I0)return r0($.innerType());else if($ instanceof m1)return[$.value];else if($ instanceof W1)return $.options;else if($ instanceof c1)return o.objectValues($.enum);else if($ instanceof u1)return r0($._def.innerType);else if($ instanceof y1)return[void 0];else if($ instanceof E1)return[null];else if($ instanceof D0)return[void 0,...r0($.unwrap())];else if($ instanceof n0)return[null,...r0($.unwrap())];else if($ instanceof r2)return r0($.unwrap());else if($ instanceof l1)return r0($.unwrap());else if($ instanceof p1)return r0($._def.innerType);else return[]};class i2 extends r{_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==R.object)return P(J,{code:z.invalid_type,expected:R.object,received:J.parsedType}),y;let X=this.discriminator,Q=J.data[X],W=this.optionsMap.get(Q);if(!W)return P(J,{code:z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[X]}),y;if(J.common.async)return W._parseAsync({data:J.data,path:J.path,parent:J});else return W._parseSync({data:J.data,path:J.path,parent:J})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,J,X){let Q=new Map;for(let W of J){let q=r0(W.shape[$]);if(!q.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let Y of q){if(Q.has(Y))throw Error(`Discriminator property ${String($)} has duplicate value ${String(Y)}`);Q.set(Y,W)}}return new i2({typeName:x.ZodDiscriminatedUnion,discriminator:$,options:J,optionsMap:Q,...p(X)})}}function c$($,J){let X=m0($),Q=m0(J);if($===J)return{valid:!0,data:$};else if(X===R.object&&Q===R.object){let W=o.objectKeys(J),q=o.objectKeys($).filter((H)=>W.indexOf(H)!==-1),Y={...$,...J};for(let H of q){let G=c$($[H],J[H]);if(!G.valid)return{valid:!1};Y[H]=G.data}return{valid:!0,data:Y}}else if(X===R.array&&Q===R.array){if($.length!==J.length)return{valid:!1};let W=[];for(let q=0;q<$.length;q++){let Y=$[q],H=J[q],G=c$(Y,H);if(!G.valid)return{valid:!1};W.push(G.data)}return{valid:!0,data:W}}else if(X===R.date&&Q===R.date&&+$===+J)return{valid:!0,data:$};else return{valid:!1}}class h1 extends r{_parse($){let{status:J,ctx:X}=this._processInputParams($),Q=(W,q)=>{if(l2(W)||l2(q))return y;let Y=c$(W.value,q.value);if(!Y.valid)return P(X,{code:z.invalid_intersection_types}),y;if(d2(W)||d2(q))J.dirty();return{status:J.value,value:Y.data}};if(X.common.async)return Promise.all([this._def.left._parseAsync({data:X.data,path:X.path,parent:X}),this._def.right._parseAsync({data:X.data,path:X.path,parent:X})]).then(([W,q])=>Q(W,q));else return Q(this._def.left._parseSync({data:X.data,path:X.path,parent:X}),this._def.right._parseSync({data:X.data,path:X.path,parent:X}))}}h1.create=($,J,X)=>{return new h1({left:$,right:J,typeName:x.ZodIntersection,...p(X)})};class u0 extends r{_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.parsedType!==R.array)return P(X,{code:z.invalid_type,expected:R.array,received:X.parsedType}),y;if(X.data.length<this._def.items.length)return P(X,{code:z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;if(!this._def.rest&&X.data.length>this._def.items.length)P(X,{code:z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),J.dirty();let W=[...X.data].map((q,Y)=>{let H=this._def.items[Y]||this._def.rest;if(!H)return null;return H._parse(new g0(X,q,X.path,Y))}).filter((q)=>!!q);if(X.common.async)return Promise.all(W).then((q)=>{return z0.mergeArray(J,q)});else return z0.mergeArray(J,W)}get items(){return this._def.items}rest($){return new u0({...this._def,rest:$})}}u0.create=($,J)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new u0({items:$,typeName:x.ZodTuple,rest:null,...p(J)})};class L2 extends r{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.parsedType!==R.object)return P(X,{code:z.invalid_type,expected:R.object,received:X.parsedType}),y;let Q=[],W=this._def.keyType,q=this._def.valueType;for(let Y in X.data)Q.push({key:W._parse(new g0(X,Y,X.path,Y)),value:q._parse(new g0(X,X.data[Y],X.path,Y)),alwaysSet:Y in X.data});if(X.common.async)return z0.mergeObjectAsync(J,Q);else return z0.mergeObjectSync(J,Q)}get element(){return this._def.valueType}static create($,J,X){if(J instanceof r)return new L2({keyType:$,valueType:J,typeName:x.ZodRecord,...p(X)});return new L2({keyType:Z0.create(),valueType:$,typeName:x.ZodRecord,...p(J)})}}class M2 extends r{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.parsedType!==R.map)return P(X,{code:z.invalid_type,expected:R.map,received:X.parsedType}),y;let Q=this._def.keyType,W=this._def.valueType,q=[...X.data.entries()].map(([Y,H],G)=>{return{key:Q._parse(new g0(X,Y,X.path,[G,"key"])),value:W._parse(new g0(X,H,X.path,[G,"value"]))}});if(X.common.async){let Y=new Map;return Promise.resolve().then(async()=>{for(let H of q){let G=await H.key,B=await H.value;if(G.status==="aborted"||B.status==="aborted")return y;if(G.status==="dirty"||B.status==="dirty")J.dirty();Y.set(G.value,B.value)}return{status:J.value,value:Y}})}else{let Y=new Map;for(let H of q){let{key:G,value:B}=H;if(G.status==="aborted"||B.status==="aborted")return y;if(G.status==="dirty"||B.status==="dirty")J.dirty();Y.set(G.value,B.value)}return{status:J.value,value:Y}}}}M2.create=($,J,X)=>{return new M2({valueType:J,keyType:$,typeName:x.ZodMap,...p(X)})};class F1 extends r{_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.parsedType!==R.set)return P(X,{code:z.invalid_type,expected:R.set,received:X.parsedType}),y;let Q=this._def;if(Q.minSize!==null){if(X.data.size<Q.minSize.value)P(X,{code:z.too_small,minimum:Q.minSize.value,type:"set",inclusive:!0,exact:!1,message:Q.minSize.message}),J.dirty()}if(Q.maxSize!==null){if(X.data.size>Q.maxSize.value)P(X,{code:z.too_big,maximum:Q.maxSize.value,type:"set",inclusive:!0,exact:!1,message:Q.maxSize.message}),J.dirty()}let W=this._def.valueType;function q(H){let G=new Set;for(let B of H){if(B.status==="aborted")return y;if(B.status==="dirty")J.dirty();G.add(B.value)}return{status:J.value,value:G}}let Y=[...X.data.values()].map((H,G)=>W._parse(new g0(X,H,X.path,G)));if(X.common.async)return Promise.all(Y).then((H)=>q(H));else return q(Y)}min($,J){return new F1({...this._def,minSize:{value:$,message:b.toString(J)}})}max($,J){return new F1({...this._def,maxSize:{value:$,message:b.toString(J)}})}size($,J){return this.min($,J).max($,J)}nonempty($){return this.min(1,$)}}F1.create=($,J)=>{return new F1({valueType:$,minSize:null,maxSize:null,typeName:x.ZodSet,...p(J)})};class g1 extends r{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==R.function)return P(J,{code:z.invalid_type,expected:R.function,received:J.parsedType}),y;function X(Y,H){return w2({data:Y,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,Z1(),i0].filter((G)=>!!G),issueData:{code:z.invalid_arguments,argumentsError:H}})}function Q(Y,H){return w2({data:Y,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,Z1(),i0].filter((G)=>!!G),issueData:{code:z.invalid_return_type,returnTypeError:H}})}let W={errorMap:J.common.contextualErrorMap},q=J.data;if(this._def.returns instanceof f1){let Y=this;return O0(async function(...H){let G=new P0([]),B=await Y._def.args.parseAsync(H,W).catch((L)=>{throw G.addIssue(X(H,L)),G}),N=await Reflect.apply(q,this,B);return await Y._def.returns._def.type.parseAsync(N,W).catch((L)=>{throw G.addIssue(Q(N,L)),G})})}else{let Y=this;return O0(function(...H){let G=Y._def.args.safeParse(H,W);if(!G.success)throw new P0([X(H,G.error)]);let B=Reflect.apply(q,this,G.data),N=Y._def.returns.safeParse(B,W);if(!N.success)throw new P0([Q(B,N.error)]);return N.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new g1({...this._def,args:u0.create($).rest(J1.create())})}returns($){return new g1({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,J,X){return new g1({args:$?$:u0.create([]).rest(J1.create()),returns:J||J1.create(),typeName:x.ZodFunction,...p(X)})}}class v1 extends r{get schema(){return this._def.getter()}_parse($){let{ctx:J}=this._processInputParams($);return this._def.getter()._parse({data:J.data,path:J.path,parent:J})}}v1.create=($,J)=>{return new v1({getter:$,typeName:x.ZodLazy,...p(J)})};class m1 extends r{_parse($){if($.data!==this._def.value){let J=this._getOrReturnCtx($);return P(J,{received:J.data,code:z.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:$.data}}get value(){return this._def.value}}m1.create=($,J)=>{return new m1({value:$,typeName:x.ZodLiteral,...p(J)})};function $4($,J){return new W1({values:$,typeName:x.ZodEnum,...p(J)})}class W1 extends r{_parse($){if(typeof $.data!=="string"){let J=this._getOrReturnCtx($),X=this._def.values;return P(J,{expected:o.joinValues(X),received:J.parsedType,code:z.invalid_type}),y}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let J=this._getOrReturnCtx($),X=this._def.values;return P(J,{received:J.data,code:z.invalid_enum_value,options:X}),y}return O0($.data)}get options(){return this._def.values}get enum(){let $={};for(let J of this._def.values)$[J]=J;return $}get Values(){let $={};for(let J of this._def.values)$[J]=J;return $}get Enum(){let $={};for(let J of this._def.values)$[J]=J;return $}extract($,J=this._def){return W1.create($,{...this._def,...J})}exclude($,J=this._def){return W1.create(this.options.filter((X)=>!$.includes(X)),{...this._def,...J})}}W1.create=$4;class c1 extends r{_parse($){let J=o.getValidEnumValues(this._def.values),X=this._getOrReturnCtx($);if(X.parsedType!==R.string&&X.parsedType!==R.number){let Q=o.objectValues(J);return P(X,{expected:o.joinValues(Q),received:X.parsedType,code:z.invalid_type}),y}if(!this._cache)this._cache=new Set(o.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let Q=o.objectValues(J);return P(X,{received:X.data,code:z.invalid_enum_value,options:Q}),y}return O0($.data)}get enum(){return this._def.values}}c1.create=($,J)=>{return new c1({values:$,typeName:x.ZodNativeEnum,...p(J)})};class f1 extends r{unwrap(){return this._def.type}_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==R.promise&&J.common.async===!1)return P(J,{code:z.invalid_type,expected:R.promise,received:J.parsedType}),y;let X=J.parsedType===R.promise?J.data:Promise.resolve(J.data);return O0(X.then((Q)=>{return this._def.type.parseAsync(Q,{path:J.path,errorMap:J.common.contextualErrorMap})}))}}f1.create=($,J)=>{return new f1({type:$,typeName:x.ZodPromise,...p(J)})};class I0 extends r{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:J,ctx:X}=this._processInputParams($),Q=this._def.effect||null,W={addIssue:(q)=>{if(P(X,q),q.fatal)J.abort();else J.dirty()},get path(){return X.path}};if(W.addIssue=W.addIssue.bind(W),Q.type==="preprocess"){let q=Q.transform(X.data,W);if(X.common.async)return Promise.resolve(q).then(async(Y)=>{if(J.value==="aborted")return y;let H=await this._def.schema._parseAsync({data:Y,path:X.path,parent:X});if(H.status==="aborted")return y;if(H.status==="dirty")return B1(H.value);if(J.value==="dirty")return B1(H.value);return H});else{if(J.value==="aborted")return y;let Y=this._def.schema._parseSync({data:q,path:X.path,parent:X});if(Y.status==="aborted")return y;if(Y.status==="dirty")return B1(Y.value);if(J.value==="dirty")return B1(Y.value);return Y}}if(Q.type==="refinement"){let q=(Y)=>{let H=Q.refinement(Y,W);if(X.common.async)return Promise.resolve(H);if(H instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return Y};if(X.common.async===!1){let Y=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(Y.status==="aborted")return y;if(Y.status==="dirty")J.dirty();return q(Y.value),{status:J.value,value:Y.value}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((Y)=>{if(Y.status==="aborted")return y;if(Y.status==="dirty")J.dirty();return q(Y.value).then(()=>{return{status:J.value,value:Y.value}})})}if(Q.type==="transform")if(X.common.async===!1){let q=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(!$1(q))return y;let Y=Q.transform(q.value,W);if(Y instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:J.value,value:Y}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((q)=>{if(!$1(q))return y;return Promise.resolve(Q.transform(q.value,W)).then((Y)=>({status:J.value,value:Y}))});o.assertNever(Q)}}I0.create=($,J,X)=>{return new I0({schema:$,typeName:x.ZodEffects,effect:J,...p(X)})};I0.createWithPreprocess=($,J,X)=>{return new I0({schema:J,effect:{type:"preprocess",transform:$},typeName:x.ZodEffects,...p(X)})};class D0 extends r{_parse($){if(this._getType($)===R.undefined)return O0(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}D0.create=($,J)=>{return new D0({innerType:$,typeName:x.ZodOptional,...p(J)})};class n0 extends r{_parse($){if(this._getType($)===R.null)return O0(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}n0.create=($,J)=>{return new n0({innerType:$,typeName:x.ZodNullable,...p(J)})};class u1 extends r{_parse($){let{ctx:J}=this._processInputParams($),X=J.data;if(J.parsedType===R.undefined)X=this._def.defaultValue();return this._def.innerType._parse({data:X,path:J.path,parent:J})}removeDefault(){return this._def.innerType}}u1.create=($,J)=>{return new u1({innerType:$,typeName:x.ZodDefault,defaultValue:typeof J.default==="function"?J.default:()=>J.default,...p(J)})};class p1 extends r{_parse($){let{ctx:J}=this._processInputParams($),X={...J,common:{...J.common,issues:[]}},Q=this._def.innerType._parse({data:X.data,path:X.path,parent:{...X}});if(b1(Q))return Q.then((W)=>{return{status:"valid",value:W.status==="valid"?W.value:this._def.catchValue({get error(){return new P0(X.common.issues)},input:X.data})}});else return{status:"valid",value:Q.status==="valid"?Q.value:this._def.catchValue({get error(){return new P0(X.common.issues)},input:X.data})}}removeCatch(){return this._def.innerType}}p1.create=($,J)=>{return new p1({innerType:$,typeName:x.ZodCatch,catchValue:typeof J.catch==="function"?J.catch:()=>J.catch,...p(J)})};class _2 extends r{_parse($){if(this._getType($)!==R.nan){let X=this._getOrReturnCtx($);return P(X,{code:z.invalid_type,expected:R.nan,received:X.parsedType}),y}return{status:"valid",value:$.data}}}_2.create=($)=>{return new _2({typeName:x.ZodNaN,...p($)})};var y6=Symbol("zod_brand");class r2 extends r{_parse($){let{ctx:J}=this._processInputParams($),X=J.data;return this._def.type._parse({data:X,path:J.path,parent:J})}unwrap(){return this._def.type}}class K2 extends r{_parse($){let{status:J,ctx:X}=this._processInputParams($);if(X.common.async)return(async()=>{let W=await this._def.in._parseAsync({data:X.data,path:X.path,parent:X});if(W.status==="aborted")return y;if(W.status==="dirty")return J.dirty(),B1(W.value);else return this._def.out._parseAsync({data:W.value,path:X.path,parent:X})})();else{let Q=this._def.in._parseSync({data:X.data,path:X.path,parent:X});if(Q.status==="aborted")return y;if(Q.status==="dirty")return J.dirty(),{status:"dirty",value:Q.value};else return this._def.out._parseSync({data:Q.value,path:X.path,parent:X})}}static create($,J){return new K2({in:$,out:J,typeName:x.ZodPipeline})}}class l1 extends r{_parse($){let J=this._def.innerType._parse($),X=(Q)=>{if($1(Q))Q.value=Object.freeze(Q.value);return Q};return b1(J)?J.then((Q)=>X(Q)):X(J)}unwrap(){return this._def.innerType}}l1.create=($,J)=>{return new l1({innerType:$,typeName:x.ZodReadonly,...p(J)})};function s5($,J){let X=typeof $==="function"?$(J):typeof $==="string"?{message:$}:$;return typeof X==="string"?{message:X}:X}function J4($,J={},X){if($)return w1.create().superRefine((Q,W)=>{let q=$(Q);if(q instanceof Promise)return q.then((Y)=>{if(!Y){let H=s5(J,Q),G=H.fatal??X??!0;W.addIssue({code:"custom",...H,fatal:G})}});if(!q){let Y=s5(J,Q),H=Y.fatal??X??!0;W.addIssue({code:"custom",...Y,fatal:H})}return});return w1.create()}var E6={object:N0.lazycreate},x;(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"})(x||(x={}));var x6=($,J={message:`Input not instance of ${$.name}`})=>J4((X)=>X instanceof $,J),X4=Z0.create,Q4=X1.create,h6=_2.create,v6=Q1.create,W4=I1.create,m6=N1.create,c6=F2.create,u6=y1.create,p6=E1.create,l6=w1.create,d6=J1.create,i6=c0.create,r6=f2.create,n6=b0.create,o6=N0.create,s6=N0.strictCreate,t6=x1.create,a6=i2.create,e6=h1.create,$8=u0.create,J8=L2.create,X8=M2.create,Q8=F1.create,W8=g1.create,Y8=v1.create,q8=m1.create,G8=W1.create,H8=c1.create,U8=f1.create,B8=I0.create,N8=D0.create,w8=n0.create,F8=I0.createWithPreprocess,f8=K2.create,L8=()=>X4().optional(),M8=()=>Q4().optional(),_8=()=>W4().optional(),K8={string:($)=>Z0.create({...$,coerce:!0}),number:($)=>X1.create({...$,coerce:!0}),boolean:($)=>I1.create({...$,coerce:!0}),bigint:($)=>Q1.create({...$,coerce:!0}),date:($)=>N1.create({...$,coerce:!0})};var z8=y;var O8=U.object({before:U.string(),after:U.string(),hierarchy:U.array(U.string()),lineStart:U.number().optional(),lineEnd:U.number().optional()}).passthrough(),S8=U.object({id:U.string(),name:U.string()}).passthrough(),R8=U.object({url:U.string(),mime:U.string().optional()}).passthrough(),u$=U.object({id:U.string(),snippet:U.string(),note:U.string(),createdAt:U.string(),filePath:U.string().optional(),canvasFile:U.string().optional(),context:O8.optional(),images:U.array(U.string()).optional(),attachments:U.array(R8).optional(),source:U.enum(["local","remote"]).optional(),author:S8.optional()}).passthrough(),C8=U.array(u$.optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).catch([]),p$=U.object({annotations:C8,generalNote:U.string().catch("")}).passthrough(),Y4=U.object({path:U.string()}),q4=U.object({url:U.string()});import{useCallback as M1,useMemo as P8,useState as k8}from"react";var d1="__agent-response__";function L1($){return $.filePath&&$.filePath!=="__agent-response__"?$.filePath:void 0}function z2($){return $.uploadUrl!==null}function o0(){return`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}function Y1($,J){$.style.height="auto",$.style.height=(J?Math.max(J,$.scrollHeight):$.scrollHeight)+"px"}function G4($){let J=$?`[data-annotation-id="${CSS.escape($)}"]`:"[data-annotation-id]";for(let X of document.querySelectorAll(J))if(X.tagName==="MARK"){let Q=X.parentNode;X.replaceWith(document.createTextNode(X.textContent||"")),Q?.normalize()}else X.remove()}function n2({annotations:$,setAnnotations:J,generalNote:X,setGeneralNote:Q,remoteAnnotations:W,isReadOnly:q,onClear:Y}){let[H,G]=k8(null),B=P8(()=>{if(!W?.length)return $;let O=new Set($.map((M)=>M.id)),S=W.filter((M)=>!O.has(M.id));return[...$,...S.map((M)=>({...M,source:"remote"}))]},[$,W]),N=M1((O,S,M,A,Z,h,I)=>{J((v)=>[...v,{id:O,snippet:S,note:M,createdAt:new Date().toISOString(),filePath:A,context:Z,...h?.length?{images:h}:{},...I?{canvasFile:I}:{}}])},[J]),f=M1((O,S,M)=>{N(o0(),O,S,M)},[N]),L=M1((O,S)=>{J((M)=>M.map((A)=>A.id===O?{...A,note:S}:A))},[J]),w=M1((O)=>{if(!$.some((S)=>S.id===O))return;G4(O),J((S)=>S.filter((M)=>M.id!==O)),G((S)=>S===O?null:S)},[$,J]),F=M1((O,S)=>{J((M)=>M.map((A)=>A.id===O?{...A,images:[...A.images||[],S]}:A))},[J]),C=M1((O,S)=>{J((M)=>M.map((A)=>A.id===O?{...A,images:(A.images||[]).filter((Z)=>Z!==S)}:A))},[J]),_=M1(()=>{G4(),J([]),Q(""),G(null),Y?.()},[J,Q,Y]);return{annotations:B,generalNote:X,setGeneralNote:Q,activeAnnotationId:H,setActiveAnnotationId:G,addAnnotation:f,addAnnotationWithId:N,updateAnnotation:L,removeAnnotation:w,addAnnotationImage:F,removeAnnotationImage:C,clearAll:_,isReadOnly:q}}import{useAnnotations as q1}from"@fabrika/annotations/runtime";import{jsxDEV as EX}from"react/jsx-dev-runtime";import{jsxDEV as _1,Fragment as A8}from"react/jsx-dev-runtime";function l$({hasContent:$,onSubmit:J,onSubmitEmpty:X,notice:Q,secondaryAction:W,placeholder:q="General notes...",submitLabel:Y="Submit",emptyLabel:H="Submit without feedback"}){let{generalNote:G,setGeneralNote:B}=q1();return _1(A8,{children:[_1("div",{className:"border-t border-border-subtle px-4 py-3 flex-shrink-0",children:_1("textarea",{value:G,onChange:(N)=>B(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:q,onInput:(N)=>Y1(N.currentTarget,40),ref:(N)=>{if(N)Y1(N,40)}},void 0,!1,void 0,this)},void 0,!1,void 0,this),Q,_1("div",{className:"px-4 py-3 border-t border-border-subtle flex-shrink-0",children:$?_1("div",{className:"flex gap-2",children:[W,_1("button",{onClick:J,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:Y},void 0,!1,void 0,this)]},void 0,!0,void 0,this):_1("button",{onClick:X,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:H},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useAnnotationHost as j8}from"@fabrika/annotations/runtime";import{useCallback as s0,useEffect as V8,useRef as d$,useState as i$}from"react";import{jsxDEV as M0}from"react/jsx-dev-runtime";function r$($){if($.startsWith("/s/")||$.startsWith("http://")||$.startsWith("https://"))return $;return`/api/uploads/${$.split("/").pop()}`}async function T8($,J){let X=$.uploadUrl;if(!X)return null;let Q=new FormData;Q.append("image",J);try{let q=await(await fetch(X(),{method:"POST",body:Q})).json();if($.isShared)return q4.parse(q).url||null;return Y4.parse(q).path||null}catch{return null}}function i1({note:$,onNoteChange:J,images:X,onAddImage:Q,onRemoveImage:W,sessionId:q,placeholder:Y="Add your note...",autoFocus:H=!1,autoResize:G=!1,readOnly:B=!1,onKeyDown:N,onTextareaClick:f,textareaRef:L,textareaClassName:w,textareaStyle:F,minHeight:C,attachButton:_="always",openFilePickerRef:O}){let S=j8(),M=!B&&z2(S),[A,Z]=i$(!1),[h,I]=i$(!1),[v,u]=i$(!1),m=d$(0),e=d$(null),Q0=d$(null),q0=s0(()=>Q0.current?.click(),[]);if(O)O.current=q0;let K0=s0((K)=>{if(e.current=K,L)L.current=K;if(K&&G)Y1(K,C)},[L,G,C]);V8(()=>{if(H&&e.current){let K=e.current;if(K.focus(),K.value)K.setSelectionRange(K.value.length,K.value.length)}},[H]);let c=s0(async(K)=>{if(!K.type.startsWith("image/"))return;I(!0);try{let j=await T8(S,K);if(j)Q(j)}finally{I(!1)}},[S,Q]),$0=s0((K)=>{for(let j of K.clipboardData?.items??[])if(j.type.startsWith("image/")){K.preventDefault();let n=j.getAsFile();if(n)c(n);return}},[c]),J0=s0((K)=>{if(K.preventDefault(),m.current++,m.current===1)Z(!0)},[]),G0=s0((K)=>{K.preventDefault()},[]),a=s0((K)=>{if(K.preventDefault(),m.current--,m.current===0)Z(!1)},[]),X0=s0((K)=>{K.preventDefault(),m.current=0,Z(!1);for(let j of K.dataTransfer?.files??[])if(j.type.startsWith("image/"))c(j)},[c]),B0=s0((K)=>{if(J(K.currentTarget.value),G)K.currentTarget.style.height="auto",K.currentTarget.style.height=(C?Math.max(C,K.currentTarget.scrollHeight):K.currentTarget.scrollHeight)+"px"},[J,G,C]),k="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",...G?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},l=M&&(_==="always"||_==="on-focus"&&v);return M0("div",{style:{position:"relative"},onDragEnter:M?J0:void 0,onDragOver:M?G0:void 0,onDragLeave:M?a:void 0,onDrop:M?X0:void 0,children:[M0("textarea",{ref:K0,value:$,onChange:B?void 0:B0,onPaste:M?$0:void 0,onKeyDown:N,onClick:f,onFocus:()=>u(!0),onBlur:()=>{setTimeout(()=>u(!1),150)},readOnly:B,placeholder:Y,className:w??k,style:F??g,rows:G?1:void 0},void 0,!1,void 0,this),M&&M0("input",{ref:Q0,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:(K)=>{let j=K.currentTarget.files;if(j)for(let n of j)c(n);K.currentTarget.value=""}},void 0,!1,void 0,this),(X.length>0||l)&&M0("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[X.map((K)=>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:r$(K),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!B&&M0("button",{onClick:(j)=>{j.stopPropagation(),W(K)},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)]},K,!0,void 0,this)),l&&M0(o2,{onClick:q0},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h&&M0("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),A&&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 o2({onClick:$,size:J=16}){return M0("button",{onClick:(X)=>{X.stopPropagation(),$()},style:{width:`${J*2}px`,height:`${J*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:(X)=>{X.currentTarget.style.color="var(--color-text-secondary)"},onMouseLeave:(X)=>{X.currentTarget.style.color="var(--color-text-tertiary)"},children:M0("svg",{width:J,height:J,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 n$({images:$}){if(!$.length)return null;return M0("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px"},children:$.map((J)=>M0("div",{style:{width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:M0("img",{src:r$(J),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this)},J,!1,void 0,this))},void 0,!1,void 0,this)}import{SessionContext as Z8}from"@fabrika/annotations/runtime";import{useContext as b8,useEffect as D8,useRef as g8}from"react";import{jsxDEV as w0,Fragment as H4}from"react/jsx-dev-runtime";function I8($){let J=N2($);return J.length>80?J.slice(0,80)+"...":J}function O2({annotations:$,readOnly:J=!1,onSelect:X,onReveal:Q,includedRemoteIds:W,onToggleRemoteId:q}){let{updateAnnotation:Y,removeAnnotation:H,addAnnotationImage:G,removeAnnotationImage:B,activeAnnotationId:N,setActiveAnnotationId:f}=q1(),L=b8(Z8),w=g8(new Map);D8(()=>{if(J||!N)return;let M=w.current.get(N);if(M)M.scrollIntoView({behavior:"smooth",block:"nearest"})},[N,J]);let F=(M)=>{f(M),V1(M,!0)},C=(M)=>{f(null),V1(M,!1)},_=(M)=>{if(M.id===N){f(null);return}f(M.id),X?.(M)},O=!!W&&!!q,S=(M)=>{let A=O&&M.source==="remote";return w0("div",{ref:(Z)=>{if(Z)w.current.set(M.id,Z);else w.current.delete(M.id)},className:`group/ann relative px-3 py-2.5 transition-colors duration-150 ${J?"cursor-pointer ":""}${N===M.id?"bg-highlight-selected":A?"bg-accent-purple-muted/30 hover:bg-accent-purple-muted/50":"odd:bg-bg-elevated-half hover:bg-bg-input"}`,onMouseEnter:()=>F(M.id),onMouseLeave:()=>C(M.id),onClick:()=>_(M),children:[A&&M.author&&w0("div",{className:"flex items-center gap-1.5 mb-1.5",children:[w0("input",{type:"checkbox",checked:W.has(M.id),onChange:(Z)=>{Z.stopPropagation(),q(M.id)},onClick:(Z)=>Z.stopPropagation(),className:"accent-accent-purple flex-shrink-0",title:"Include in submission"},void 0,!1,void 0,this),w0("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),w0("span",{className:"text-[11px] font-medium text-accent-purple font-body",children:M.author.name},void 0,!1,void 0,this),w0("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),w0("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:I8(M.snippet)},void 0,!1,void 0,this),J?w0(H4,{children:[M.note.trim()&&w0("div",{className:"text-[13px] font-body text-text-primary leading-relaxed",children:M.note},void 0,!1,void 0,this),w0(n$,{images:M.images||[]},void 0,!1,void 0,this)]},void 0,!0,void 0,this):A?w0("div",{className:"text-[13px] font-body text-text-primary leading-relaxed whitespace-pre-wrap",children:M.note},void 0,!1,void 0,this):w0("div",{onClick:(Z)=>Z.stopPropagation(),children:w0(i1,{note:M.note,onNoteChange:(Z)=>Y(M.id,Z),images:M.images||[],onAddImage:(Z)=>G(M.id,Z),onRemoveImage:(Z)=>B(M.id,Z),sessionId:L,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),w0("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:[Q&&w0("button",{onClick:(Z)=>{Z.stopPropagation(),Q(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:w0("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[w0("circle",{cx:"12",cy:"12",r:"3"},void 0,!1,void 0,this),w0("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),!J&&!A&&w0("button",{onClick:(Z)=>{Z.stopPropagation(),H(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:w0("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[w0("polyline",{points:"3 6 5 6 21 6"},void 0,!1,void 0,this),w0("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 w0(H4,{children:$.map(S)},void 0,!1,void 0,this)}function S2($){let J=[],X=$.snippet.trim(),Q=$.context,W=N2(X);if(W!==X)J.push(`> ${W}`);else if($.filePath&&Q&&Q.lineStart!=null){let H=Q.lineStart,G=Q.lineEnd??H,B=X.split(`
|
|
2
2
|
`);if(X.length<30&&H===G&&(Q.before||Q.after)){let f=y2($);J.push(`> L${H}: ${f}`)}else if(B.length<=6)for(let f=0;f<B.length;f++)J.push(`> ${H+f} | ${B[f]}`);else{for(let f=0;f<3;f++)J.push(`> ${H+f} | ${B[f]}`);J.push(`> ... (${B.length} lines)`);for(let f=B.length-3;f<B.length;f++)J.push(`> ${H+f} | ${B[f]}`)}}else{let H=y2($);if(X.split(`
|
|
3
3
|
`).length<=3)J.push(`> ${H.split(`
|
|
4
4
|
`).join(`
|
|
5
5
|
> `)}`);else{let G=X.split(`
|
|
6
|
-
`);J.push(`> ${G[0]}`),J.push(`> ... (${G.length} lines)`),J.push(`> ${G[G.length-1]}`)}}if($.note.trim())J.push(""),J.push($.note.trim());let
|
|
7
|
-
`)}import{SessionContext as y8,useAnnotationHost as E8}from"@fabrika/annotations/runtime";import{useCallback as s2,useContext as x8,useEffect as h8,useMemo as N4,useRef as t2,useState as r1}from"react";import{createPortal as v8}from"react-dom";function U4($){let J=/^(\d+(?:\.\d+)?)px$/.exec($.trim());return J?Number(J[1]):void 0}function B4($,J,X=280){let W=J||document.body,Y=$.getBoundingClientRect(),q=W.getBoundingClientRect(),H=W===document.body?0:W.scrollTop,G=Y.bottom-q.top+H+8,B=Math.max(0,Math.min(Y.left-q.left,q.width-X-12));return W.style.position="relative",{style:{position:"absolute",top:`${G}px`,left:`${B}px`},parent:W}}import{jsxDEV as _0,Fragment as m8}from"react/jsx-dev-runtime";function F4({anchorEl:$,scrollContainer:J,onClose:X,ignoreSelector:Q,zIndex:W="50",padding:Y="12px",width:q="280px",children:H}){let G=t2(null),B=t2(X);B.current=X;let{style:N,parent:f}=B4($,J,U4(q));return h8(()=>{let L=setTimeout(()=>{let w=(F)=>{if(G.current&&!G.current.contains(F.target)){if(Q&&F.target.closest?.(Q))return;B.current(),document.removeEventListener("mousedown",w)}};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},0);return()=>clearTimeout(L)},[Q]),v8(_0("div",{ref:G,style:{...N,zIndex:W,width:q,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:Y,fontFamily:"'Inter', sans-serif"},children:H},void 0,!1,void 0,this),f)}var f4=[{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"]}],w4=f4.flatMap(($)=>$.items);function o$({anchorEl:$,scrollContainer:J,snippet:X,truncateAt:Q=100,header:W,initialNote:Y="",initialImages:q,onConfirm:H,onCancel:G,onDelete:B}){let N=x8(y8),f=E8(),L=z2(f),w=Y!==""||!!B,[F,C]=r1(Y),[_,O]=r1(q||[]),[S,M]=r1(null),[A,Z]=r1(w),[h,g]=r1(!1),v=t2(null),u=t2(null),m=s2(()=>{if(F.trim()||_.length>0)H(F.trim(),_);else if(w&&B)B();else G()},[F,_,H,G,w,B]),e=s2(()=>{if(w){if(!F.trim()&&_.length===0&&B){B(),G();return}H(F,_);return}G()},[F,_,w,H,G,B]),Q0=!w,Y0=F.trim().length>0?w4.filter((T)=>T.toLowerCase().startsWith(F.trim().toLowerCase())):w4,K0=!Q0||A?[]:Y0.length===1&&Y0[0]?.toLowerCase()===F.trim().toLowerCase()?[]:Y0,c=new Set(K0),$0=f4.map((T)=>({label:T.label,items:T.items.filter((E)=>c.has(E))})).filter((T)=>T.items.length>0),J0=$0.map((T)=>T.items),G0=(T)=>J0[T]?.length??0,a=J0.flat(),X0=N4(()=>{if(S===null)return 0;let T=0;for(let E=0;E<J0.length;E++){if(S<T+G0(E))return E;T+=G0(E)}return 0},[S,J0]),B0=N4(()=>{if(S===null)return 0;let T=0;for(let E=0;E<X0;E++)T+=G0(E);return S-T},[S,X0,J0]),k=(T,E)=>{let d=0;for(let H0=0;H0<T;H0++)d+=G0(H0);return d+E},[I,l]=r1(F);if(F!==I)l(F),M(null),Z(w);let K=s2((T)=>{C(T)},[]),j=X.length>Q?X.slice(0,Q)+"...":X,n=s2((T)=>{if(a.length>0&&(T.key==="ArrowDown"||T.key==="ArrowUp"||T.key==="ArrowLeft"||T.key==="ArrowRight")){if(T.preventDefault(),S===null){M(0);return}if(T.key==="ArrowDown"){let d=Math.min(B0+1,G0(X0)-1);M(k(X0,d))}else if(T.key==="ArrowUp"){let d=Math.max(B0-1,0);M(k(X0,d))}else if(T.key==="ArrowRight"){let d=Math.min(X0+1,J0.length-1),H0=Math.min(B0,G0(d)-1);M(k(d,H0))}else if(T.key==="ArrowLeft"){let d=Math.max(X0-1,0),H0=Math.min(B0,G0(d)-1);M(k(d,H0))}return}let E=S===null?void 0:a[S];if(E!==void 0){if(T.key==="Tab"){T.preventDefault(),K(E);return}if(T.key==="Enter"&&!T.shiftKey){T.preventDefault(),H(E,_);return}}if(T.key==="Enter"&&!T.shiftKey){T.preventDefault(),m();return}if(T.key==="Escape")if(a.length>0&&!A)Z(!0);else if(w)e();else G()},[a,S,B0,X0,J0,k,K,H,_,m,A,w,e,G]);return _0(F4,{anchorEl:$,scrollContainer:J,onClose:w?e:G,ignoreSelector:w?"[data-annotation-id]":void 0,zIndex:w?"60":"50",padding:w?"10px 12px":"12px",width:"420px",children:[!w&&(W??_0("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:["“",j,"”"]},void 0,!0,void 0,this)),_0(i1,{note:F,onNoteChange:C,images:_,onAddImage:(T)=>O((E)=>[...E,T]),onRemoveImage:(T)=>O((E)=>E.filter((d)=>d!==T)),sessionId:N,autoFocus:!0,autoResize:w,textareaRef:v,onKeyDown:n,attachButton:"none",openFilePickerRef:u,textareaStyle:w?{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),_0("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:w?"6px":"8px"},children:[L&&_0(o2,{onClick:()=>u.current?.(),size:14},void 0,!1,void 0,this),_0("div",{style:{flex:1}},void 0,!1,void 0,this),w?_0("button",{onClick:()=>{if(B)B();G()},onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),style:{fontSize:"11px",color:h?"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):_0(m8,{children:[_0("button",{onClick:G,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),_0("button",{onClick:m,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),a.length>0&&_0("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:$0.map((T)=>_0("div",{style:{flex:1},children:[_0("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:T.label},void 0,!1,void 0,this),T.items.map((E)=>{let d=a.indexOf(E);return _0("div",{onMouseDown:(H0)=>{H0.preventDefault(),H0.stopPropagation(),K(E)},onMouseEnter:()=>M(d),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:d===S?"var(--color-text-primary)":"var(--color-text-secondary)",background:d===S?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[_0("span",{style:{fontWeight:500},children:E.slice(0,F.trim().length)},void 0,!1,void 0,this),E.slice(F.trim().length)]},E,!0,void 0,this)})]},T.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function G1({anchorEl:$,scrollContainer:J,snippet:X,truncateAt:Q,header:W,onAdd:Y,onCancel:q}){return _0(o$,{anchorEl:$,scrollContainer:J,snippet:X,truncateAt:Q,header:W,onConfirm:(H,G)=>Y(H,G),onCancel:q},void 0,!1,void 0,this)}function R2({anchorEl:$,scrollContainer:J,initialNote:X,initialImages:Q,onUpdate:W,onDelete:Y,onClose:q}){return _0(o$,{anchorEl:$,scrollContainer:J,snippet:"",initialNote:X,initialImages:Q,onConfirm:(H,G)=>{W(H,G),q()},onDelete:Y,onCancel:q},void 0,!1,void 0,this)}import{useEffect as c8,useRef as s$,useState as L4}from"react";import{jsxDEV as u8}from"react/jsx-dev-runtime";function t$($){let{containerRef:J,restoreKey:X,shape:Q="rect",canvasFile:W,scrollContainer:Y}=$,{addAnnotationWithId:q}=Y1(),[H,G]=L4(null),[B,N]=L4(!1),f=s$(q);f.current=q;let L=s$(W);L.current=W;let w=s$(Q);return w.current=Q,c8(()=>{let C=J.current;if(!C)return;let _=null;function O(g,v){let u=g.getBoundingClientRect();return g$(u,v.clientX-u.left,v.clientY-u.top)}function S(){if(!_)return;let{host:g,pointerId:v}=_;if(g.hasPointerCapture(v))g.releasePointerCapture(v);g.removeEventListener("pointermove",A),g.removeEventListener("pointerup",Z),g.removeEventListener("pointercancel",h),_=null,N(!1)}function M(g){if(_||g.button!==0)return;let v=g.target;if(!(v instanceof Element))return;if(v.closest("[data-block-comment-btn]"))return;if(v.closest("[data-annotation-id]"))return;let u=v.closest(`[${I$}]`);if(!(u instanceof HTMLElement)||!C?.contains(u))return;let m=u.closest("[data-md='image']")?.getAttribute("data-md-src");if(!m)return;let e=O(u,g);if(!e)return;g.preventDefault(),u.setPointerCapture(g.pointerId);let Q0=o0(),Y0=u2({...e,w:0,h:0},w.current,Q0);Y0.classList.add("ann-region-draft"),u.appendChild(Y0),_={pointerId:g.pointerId,host:u,src:m,start:e,shape:w.current,overlay:Y0,id:Q0},u.addEventListener("pointermove",A),u.addEventListener("pointerup",Z),u.addEventListener("pointercancel",h),N(!0)}function A(g){if(!_||_.pointerId!==g.pointerId)return;let v=O(_.host,g);if(!v)return;c2(_.overlay,v2(_.start,v))}function Z(g){if(!_||_.pointerId!==g.pointerId)return;let{overlay:v,id:u,src:m,shape:e}=_,Q0=O(_.host,g)??_.start,Y0=v2(_.start,Q0);if(S(),!y$(Y0)){v.remove();return}c2(v,Y0);let K0={src:m,shape:e,...Y0};G({overlay:v,id:u,snippet:B2.format(K0),label:m2(K0)})}function h(g){if(!_||_.pointerId!==g.pointerId)return;_.overlay.remove(),S()}return C.addEventListener("pointerdown",M),()=>{if(C.removeEventListener("pointerdown",M),_)_.overlay.remove(),S()}},[X]),{popovers:H?u8(G1,{anchorEl:H.overlay,scrollContainer:Y,snippet:H.label,truncateAt:80,onAdd:(C,_)=>{H.overlay.classList.remove("ann-region-draft"),f.current(H.id,H.snippet,C,void 0,void 0,_,L.current),G(null)},onCancel:()=>{H.overlay.remove(),G(null)}},void 0,!1,void 0,this):null,isDrawing:B,isPopoverOpen:!!H}}import{useCallback as M4,useEffect as a2,useRef as K1,useState as _4}from"react";import{jsxDEV as a$,Fragment as p8}from"react/jsx-dev-runtime";function e$($){let{containerRef:J,restoreKey:X,restoreAnnotations:Q,extractContext:W,filePath:Y,canvasFile:q,scrollContainer:H}=$,{annotations:G,addAnnotationWithId:B,removeAnnotation:N,updateAnnotation:f,addAnnotationImage:L,removeAnnotationImage:w,activeAnnotationId:F,setActiveAnnotationId:C}=Y1(),[_,O]=_4(null),[S,M]=_4(null),A=K1(W);A.current=W;let Z=K1(Y);Z.current=Y;let h=K1(q);h.current=q;let g=K1(B);g.current=B;let v=K1(F);v.current=F;let u=K1(C);u.current=C;let m=Q.length;a2(()=>{if(!J.current)return;let c=setTimeout(()=>{if(J.current)h$(J.current,Q)},50);return()=>clearTimeout(c)},[X,m]);let e=K1(null);a2(()=>{k$(F,e.current),e.current=F},[F]),a2(()=>{let c=J.current;if(!c)return;let $0=(a)=>{let X0=a.target.closest("[data-annotation-id]");if(!X0)return;a.stopPropagation();let B0=X0.getAttribute("data-annotation-id");if(B0===v.current)O({anchorEl:X0,annId:B0});else u.current(B0)},J0=(a)=>{let X0=a.target.closest("[data-annotation-id]");if(X0)u.current(X0.getAttribute("data-annotation-id"))},G0=(a)=>{let X0=a.target.closest("[data-annotation-id]"),B0=a.relatedTarget?.closest?.("[data-annotation-id]");if(X0&&!B0&&!document.getElementById("ann-inline-popover"))u.current(null)};return c.addEventListener("click",$0),c.addEventListener("mouseover",J0),c.addEventListener("mouseout",G0),()=>{c.removeEventListener("click",$0),c.removeEventListener("mouseover",J0),c.removeEventListener("mouseout",G0)}},[X]),a2(()=>{let c=()=>Q0();return document.addEventListener("mouseup",c),()=>document.removeEventListener("mouseup",c)},[]);let Q0=M4(()=>{let c=window.getSelection();if(!c||c.isCollapsed||!c.toString().trim())return;if(!J.current)return;let $0=c.getRangeAt(0);if(!J.current.contains($0.startContainer))return;if($0.startContainer.parentElement?.closest?.("[data-annotation-id]"))return;let J0=p5($0).trim();if(J0.length<2)return;let G0=A.current($0),a=$0.cloneRange(),X0=`__pending_${Date.now()}`;try{g2(a,X0)}catch{}window.getSelection()?.removeAllRanges();let B0=document.querySelectorAll(`[data-annotation-id="${X0}"]`),k=B0[B0.length-1];if(!k)return;M({anchorEl:k,tempId:X0,snippet:J0,ctx:G0})},[]),Y0=M4((c,$0,J0,G0)=>{M({anchorEl:c,tempId:$0,snippet:J0,ctx:G0})},[]);return{popovers:a$(p8,{children:[_&&(()=>{let c=G.find(($0)=>$0.id===_.annId);if(!c)return null;return a$(R2,{anchorEl:_.anchorEl,scrollContainer:H,initialNote:c.note,initialImages:c.images,onUpdate:($0,J0)=>{f(_.annId,$0);let G0=c.images||[];for(let a of J0)if(!G0.includes(a))L(_.annId,a);for(let a of G0)if(!J0.includes(a))w(_.annId,a)},onDelete:()=>{N(_.annId),C(null)},onClose:()=>O(null)},void 0,!1,void 0,this)})(),S&&a$(G1,{anchorEl:S.anchorEl,scrollContainer:H,snippet:S.snippet,truncateAt:80,onAdd:(c,$0)=>{let J0=o0();A$(S.tempId,J0),g.current(J0,S.snippet,c,Z.current,S.ctx,$0,h.current),M(null)},onCancel:()=>{V$(S.tempId),M(null)}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),openCreatePopover:Y0,isPopoverOpen:!!(_||S)}}import{AnnotationCtx as o8}from"#canvas/runtime";import{AnnotationCtx as s8,AnnotationHostContext as t8}from"@fabrika/annotations/runtime";import{useCallback as t1,useEffect as A4,useMemo as a8,useRef as Q5,useState as a1}from"react";var YW=U.object({}).passthrough(),GW=U.object({annotations:U.array(U.unknown()).catch([]),generalNote:U.string().catch(""),responses:U.array(U.unknown()).catch([])}),HW=U.tuple([U.unknown(),U.object({note:U.unknown(),value:U.unknown()})]);function z1($,J,X="current"){let Q=`canvas:${$}:rev:${J}`;return X==="next"?`${Q}:next-draft`:Q}function l8($,J){return`${z1($,J)}:draft-handled`}function $5($,J,X){try{$.removeItem(z1(J,X)),$.removeItem(l8(J,X))}catch{}}function J5($,J){let X=new Map;for(let[Q,W]of $)if(J.has(Q))X.set(Q,W);return X}function X5($,J){if(!$||$.length===0)return!1;return $.every((X)=>J.has(X))}function n1($,J,X,Q,W){let Y=[],q=$.filter((w)=>w.source!=="remote"||W&&W.has(w.id)),H=q.filter((w)=>w.filePath===d1),G=q.filter((w)=>!w.filePath),B=q.filter((w)=>w.filePath&&w.filePath!==d1),N=X?Array.from(X.values()).filter((w)=>e2(w)):[],f=Q?Array.from(Q.values()).filter((w)=>w.markdown.trim()):[];if(N.length>0||f.length>0){Y.push("## Responses"),Y.push("");for(let w of N)Y.push(d8(w));for(let w of f)Y.push(w.markdown.trim()),Y.push("")}if(H.length>0){Y.push("## Annotations on agent response"),Y.push("");for(let w of H)Y.push(S2(w))}if(G.length>0){Y.push("## Canvas annotations"),Y.push("");let w=new Map;for(let _ of G){let O=_.canvasFile||"";if(!w.has(O))w.set(O,[]);w.get(O).push(_)}let F=[...w.keys()].sort(),C=F.length>1||F.length===1&&F[0]!=="";for(let _ of F){let O=w.get(_);if(C&&_)Y.push(`### ${_.replace(/\.jsx$/,"")}`),Y.push("");let S=i8(O);Y.push(O4(S))}}if(B.length>0){let w={};for(let F of B){let C=F.filePath;if(!w[C])w[C]=[];w[C].push(F)}Y.push("## File annotations"),Y.push("");for(let[F,C]of Object.entries(w)){Y.push(`### ${F}`),Y.push("");for(let _ of C)Y.push(S2(_))}}if(J.trim())Y.push("## General notes"),Y.push(""),Y.push(J.trim()),Y.push("");return Y.join(`
|
|
6
|
+
`);J.push(`> ${G[0]}`),J.push(`> ... (${G.length} lines)`),J.push(`> ${G[G.length-1]}`)}}if($.note.trim())J.push(""),J.push($.note.trim());let q=[...$.images??[]],Y=new Set(q);for(let H of $.attachments??[]){if(Y.has(H.url))continue;Y.add(H.url),q.push(H.url)}if(q.length){J.push("");for(let H of q)J.push(``)}return J.push(""),J.join(`
|
|
7
|
+
`)}import{SessionContext as y8,useAnnotationHost as E8}from"@fabrika/annotations/runtime";import{useCallback as s2,useContext as x8,useEffect as h8,useMemo as N4,useRef as t2,useState as r1}from"react";import{createPortal as v8}from"react-dom";function U4($){let J=/^(\d+(?:\.\d+)?)px$/.exec($.trim());return J?Number(J[1]):void 0}function B4($,J,X=280){let W=J||document.body,q=$.getBoundingClientRect(),Y=W.getBoundingClientRect(),H=W===document.body?0:W.scrollTop,G=q.bottom-Y.top+H+8,B=Math.max(0,Math.min(q.left-Y.left,Y.width-X-12));return W.style.position="relative",{style:{position:"absolute",top:`${G}px`,left:`${B}px`},parent:W}}import{jsxDEV as _0,Fragment as m8}from"react/jsx-dev-runtime";function F4({anchorEl:$,scrollContainer:J,onClose:X,ignoreSelector:Q,zIndex:W="50",padding:q="12px",width:Y="280px",children:H}){let G=t2(null),B=t2(X);B.current=X;let{style:N,parent:f}=B4($,J,U4(Y));return h8(()=>{let L=setTimeout(()=>{let w=(F)=>{if(G.current&&!G.current.contains(F.target)){if(Q&&F.target.closest?.(Q))return;B.current(),document.removeEventListener("mousedown",w)}};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},0);return()=>clearTimeout(L)},[Q]),v8(_0("div",{ref:G,style:{...N,zIndex:W,width:Y,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:q,fontFamily:"'Inter', sans-serif"},children:H},void 0,!1,void 0,this),f)}var f4=[{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"]}],w4=f4.flatMap(($)=>$.items);function o$({anchorEl:$,scrollContainer:J,snippet:X,truncateAt:Q=100,header:W,initialNote:q="",initialImages:Y,onConfirm:H,onCancel:G,onDelete:B}){let N=x8(y8),f=E8(),L=z2(f),w=q!==""||!!B,[F,C]=r1(q),[_,O]=r1(Y||[]),[S,M]=r1(null),[A,Z]=r1(w),[h,I]=r1(!1),v=t2(null),u=t2(null),m=s2(()=>{if(F.trim()||_.length>0)H(F.trim(),_);else if(w&&B)B();else G()},[F,_,H,G,w,B]),e=s2(()=>{if(w){if(!F.trim()&&_.length===0&&B){B(),G();return}H(F,_);return}G()},[F,_,w,H,G,B]),Q0=!w,q0=F.trim().length>0?w4.filter((T)=>T.toLowerCase().startsWith(F.trim().toLowerCase())):w4,K0=!Q0||A?[]:q0.length===1&&q0[0]?.toLowerCase()===F.trim().toLowerCase()?[]:q0,c=new Set(K0),$0=f4.map((T)=>({label:T.label,items:T.items.filter((E)=>c.has(E))})).filter((T)=>T.items.length>0),J0=$0.map((T)=>T.items),G0=(T)=>J0[T]?.length??0,a=J0.flat(),X0=N4(()=>{if(S===null)return 0;let T=0;for(let E=0;E<J0.length;E++){if(S<T+G0(E))return E;T+=G0(E)}return 0},[S,J0]),B0=N4(()=>{if(S===null)return 0;let T=0;for(let E=0;E<X0;E++)T+=G0(E);return S-T},[S,X0,J0]),k=(T,E)=>{let d=0;for(let H0=0;H0<T;H0++)d+=G0(H0);return d+E},[g,l]=r1(F);if(F!==g)l(F),M(null),Z(w);let K=s2((T)=>{C(T)},[]),j=X.length>Q?X.slice(0,Q)+"...":X,n=s2((T)=>{if(a.length>0&&(T.key==="ArrowDown"||T.key==="ArrowUp"||T.key==="ArrowLeft"||T.key==="ArrowRight")){if(T.preventDefault(),S===null){M(0);return}if(T.key==="ArrowDown"){let d=Math.min(B0+1,G0(X0)-1);M(k(X0,d))}else if(T.key==="ArrowUp"){let d=Math.max(B0-1,0);M(k(X0,d))}else if(T.key==="ArrowRight"){let d=Math.min(X0+1,J0.length-1),H0=Math.min(B0,G0(d)-1);M(k(d,H0))}else if(T.key==="ArrowLeft"){let d=Math.max(X0-1,0),H0=Math.min(B0,G0(d)-1);M(k(d,H0))}return}let E=S===null?void 0:a[S];if(E!==void 0){if(T.key==="Tab"){T.preventDefault(),K(E);return}if(T.key==="Enter"&&!T.shiftKey){T.preventDefault(),H(E,_);return}}if(T.key==="Enter"&&!T.shiftKey){T.preventDefault(),m();return}if(T.key==="Escape")if(a.length>0&&!A)Z(!0);else if(w)e();else G()},[a,S,B0,X0,J0,k,K,H,_,m,A,w,e,G]);return _0(F4,{anchorEl:$,scrollContainer:J,onClose:w?e:G,ignoreSelector:w?"[data-annotation-id]":void 0,zIndex:w?"60":"50",padding:w?"10px 12px":"12px",width:"420px",children:[!w&&(W??_0("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:["“",j,"”"]},void 0,!0,void 0,this)),_0(i1,{note:F,onNoteChange:C,images:_,onAddImage:(T)=>O((E)=>[...E,T]),onRemoveImage:(T)=>O((E)=>E.filter((d)=>d!==T)),sessionId:N,autoFocus:!0,autoResize:w,textareaRef:v,onKeyDown:n,attachButton:"none",openFilePickerRef:u,textareaStyle:w?{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),_0("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:w?"6px":"8px"},children:[L&&_0(o2,{onClick:()=>u.current?.(),size:14},void 0,!1,void 0,this),_0("div",{style:{flex:1}},void 0,!1,void 0,this),w?_0("button",{onClick:()=>{if(B)B();G()},onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),style:{fontSize:"11px",color:h?"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):_0(m8,{children:[_0("button",{onClick:G,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),_0("button",{onClick:m,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),a.length>0&&_0("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:$0.map((T)=>_0("div",{style:{flex:1},children:[_0("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:T.label},void 0,!1,void 0,this),T.items.map((E)=>{let d=a.indexOf(E);return _0("div",{onMouseDown:(H0)=>{H0.preventDefault(),H0.stopPropagation(),K(E)},onMouseEnter:()=>M(d),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:d===S?"var(--color-text-primary)":"var(--color-text-secondary)",background:d===S?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[_0("span",{style:{fontWeight:500},children:E.slice(0,F.trim().length)},void 0,!1,void 0,this),E.slice(F.trim().length)]},E,!0,void 0,this)})]},T.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function G1({anchorEl:$,scrollContainer:J,snippet:X,truncateAt:Q,header:W,onAdd:q,onCancel:Y}){return _0(o$,{anchorEl:$,scrollContainer:J,snippet:X,truncateAt:Q,header:W,onConfirm:(H,G)=>q(H,G),onCancel:Y},void 0,!1,void 0,this)}function R2({anchorEl:$,scrollContainer:J,initialNote:X,initialImages:Q,onUpdate:W,onDelete:q,onClose:Y}){return _0(o$,{anchorEl:$,scrollContainer:J,snippet:"",initialNote:X,initialImages:Q,onConfirm:(H,G)=>{W(H,G),Y()},onDelete:q,onCancel:Y},void 0,!1,void 0,this)}import{useEffect as c8,useRef as s$,useState as L4}from"react";import{jsxDEV as u8}from"react/jsx-dev-runtime";function t$($){let{containerRef:J,restoreKey:X,shape:Q="rect",canvasFile:W,scrollContainer:q}=$,{addAnnotationWithId:Y}=q1(),[H,G]=L4(null),[B,N]=L4(!1),f=s$(Y);f.current=Y;let L=s$(W);L.current=W;let w=s$(Q);return w.current=Q,c8(()=>{let C=J.current;if(!C)return;let _=null;function O(I,v){let u=I.getBoundingClientRect();return I$(u,v.clientX-u.left,v.clientY-u.top)}function S(){if(!_)return;let{host:I,pointerId:v}=_;if(I.hasPointerCapture(v))I.releasePointerCapture(v);I.removeEventListener("pointermove",A),I.removeEventListener("pointerup",Z),I.removeEventListener("pointercancel",h),_=null,N(!1)}function M(I){if(_||I.button!==0)return;let v=I.target;if(!(v instanceof Element))return;if(v.closest("[data-block-comment-btn]"))return;if(v.closest("[data-annotation-id]"))return;let u=v.closest(`[${g$}]`);if(!(u instanceof HTMLElement)||!C?.contains(u))return;let m=u.closest("[data-md='image']")?.getAttribute("data-md-src");if(!m)return;let e=O(u,I);if(!e)return;I.preventDefault(),u.setPointerCapture(I.pointerId);let Q0=o0(),q0=u2({...e,w:0,h:0},w.current,Q0);q0.classList.add("ann-region-draft"),u.appendChild(q0),_={pointerId:I.pointerId,host:u,src:m,start:e,shape:w.current,overlay:q0,id:Q0},u.addEventListener("pointermove",A),u.addEventListener("pointerup",Z),u.addEventListener("pointercancel",h),N(!0)}function A(I){if(!_||_.pointerId!==I.pointerId)return;let v=O(_.host,I);if(!v)return;c2(_.overlay,v2(_.start,v))}function Z(I){if(!_||_.pointerId!==I.pointerId)return;let{overlay:v,id:u,src:m,shape:e}=_,Q0=O(_.host,I)??_.start,q0=v2(_.start,Q0);if(S(),!y$(q0)){v.remove();return}c2(v,q0);let K0={src:m,shape:e,...q0};G({overlay:v,id:u,snippet:B2.format(K0),label:m2(K0)})}function h(I){if(!_||_.pointerId!==I.pointerId)return;_.overlay.remove(),S()}return C.addEventListener("pointerdown",M),()=>{if(C.removeEventListener("pointerdown",M),_)_.overlay.remove(),S()}},[X]),{popovers:H?u8(G1,{anchorEl:H.overlay,scrollContainer:q,snippet:H.label,truncateAt:80,onAdd:(C,_)=>{H.overlay.classList.remove("ann-region-draft"),f.current(H.id,H.snippet,C,void 0,void 0,_,L.current),G(null)},onCancel:()=>{H.overlay.remove(),G(null)}},void 0,!1,void 0,this):null,isDrawing:B,isPopoverOpen:!!H}}import{useCallback as M4,useEffect as a2,useRef as K1,useState as _4}from"react";import{jsxDEV as a$,Fragment as p8}from"react/jsx-dev-runtime";function e$($){let{containerRef:J,restoreKey:X,restoreAnnotations:Q,extractContext:W,filePath:q,canvasFile:Y,scrollContainer:H}=$,{annotations:G,addAnnotationWithId:B,removeAnnotation:N,updateAnnotation:f,addAnnotationImage:L,removeAnnotationImage:w,activeAnnotationId:F,setActiveAnnotationId:C}=q1(),[_,O]=_4(null),[S,M]=_4(null),A=K1(W);A.current=W;let Z=K1(q);Z.current=q;let h=K1(Y);h.current=Y;let I=K1(B);I.current=B;let v=K1(F);v.current=F;let u=K1(C);u.current=C;let m=Q.length;a2(()=>{if(!J.current)return;let c=setTimeout(()=>{if(J.current)h$(J.current,Q)},50);return()=>clearTimeout(c)},[X,m]);let e=K1(null);a2(()=>{k$(F,e.current),e.current=F},[F]),a2(()=>{let c=J.current;if(!c)return;let $0=(a)=>{let X0=a.target.closest("[data-annotation-id]");if(!X0)return;a.stopPropagation();let B0=X0.getAttribute("data-annotation-id");if(B0===v.current)O({anchorEl:X0,annId:B0});else u.current(B0)},J0=(a)=>{let X0=a.target.closest("[data-annotation-id]");if(X0)u.current(X0.getAttribute("data-annotation-id"))},G0=(a)=>{let X0=a.target.closest("[data-annotation-id]"),B0=a.relatedTarget?.closest?.("[data-annotation-id]");if(X0&&!B0&&!document.getElementById("ann-inline-popover"))u.current(null)};return c.addEventListener("click",$0),c.addEventListener("mouseover",J0),c.addEventListener("mouseout",G0),()=>{c.removeEventListener("click",$0),c.removeEventListener("mouseover",J0),c.removeEventListener("mouseout",G0)}},[X]),a2(()=>{let c=()=>Q0();return document.addEventListener("mouseup",c),()=>document.removeEventListener("mouseup",c)},[]);let Q0=M4(()=>{let c=window.getSelection();if(!c||c.isCollapsed||!c.toString().trim())return;if(!J.current)return;let $0=c.getRangeAt(0);if(!J.current.contains($0.startContainer))return;if($0.startContainer.parentElement?.closest?.("[data-annotation-id]"))return;let J0=p5($0).trim();if(J0.length<2)return;let G0=A.current($0),a=$0.cloneRange(),X0=`__pending_${Date.now()}`;try{I2(a,X0)}catch{}window.getSelection()?.removeAllRanges();let B0=document.querySelectorAll(`[data-annotation-id="${X0}"]`),k=B0[B0.length-1];if(!k)return;M({anchorEl:k,tempId:X0,snippet:J0,ctx:G0})},[]),q0=M4((c,$0,J0,G0)=>{M({anchorEl:c,tempId:$0,snippet:J0,ctx:G0})},[]);return{popovers:a$(p8,{children:[_&&(()=>{let c=G.find(($0)=>$0.id===_.annId);if(!c)return null;return a$(R2,{anchorEl:_.anchorEl,scrollContainer:H,initialNote:c.note,initialImages:c.images,onUpdate:($0,J0)=>{f(_.annId,$0);let G0=c.images||[];for(let a of J0)if(!G0.includes(a))L(_.annId,a);for(let a of G0)if(!J0.includes(a))w(_.annId,a)},onDelete:()=>{N(_.annId),C(null)},onClose:()=>O(null)},void 0,!1,void 0,this)})(),S&&a$(G1,{anchorEl:S.anchorEl,scrollContainer:H,snippet:S.snippet,truncateAt:80,onAdd:(c,$0)=>{let J0=o0();A$(S.tempId,J0),I.current(J0,S.snippet,c,Z.current,S.ctx,$0,h.current),M(null)},onCancel:()=>{V$(S.tempId),M(null)}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),openCreatePopover:q0,isPopoverOpen:!!(_||S)}}import{AnnotationCtx as o8}from"#canvas/runtime";import{AnnotationCtx as s8,AnnotationHostContext as t8}from"@fabrika/annotations/runtime";import{useCallback as t1,useEffect as A4,useMemo as a8,useRef as Q5,useState as a1}from"react";var GW=U.object({}).passthrough(),HW=U.object({annotations:U.array(U.unknown()).catch([]),generalNote:U.string().catch(""),responses:U.array(U.unknown()).catch([])}),UW=U.tuple([U.unknown(),U.object({note:U.unknown(),value:U.unknown()})]);function z1($,J,X="current"){let Q=`canvas:${$}:rev:${J}`;return X==="next"?`${Q}:next-draft`:Q}function l8($,J){return`${z1($,J)}:draft-handled`}function $5($,J,X){try{$.removeItem(z1(J,X)),$.removeItem(l8(J,X))}catch{}}function J5($,J){let X=new Map;for(let[Q,W]of $)if(J.has(Q))X.set(Q,W);return X}function X5($,J){if(!$||$.length===0)return!1;return $.every((X)=>J.has(X))}function n1($,J,X,Q,W){let q=[],Y=$.filter((w)=>w.source!=="remote"||W&&W.has(w.id)),H=Y.filter((w)=>w.filePath===d1),G=Y.filter((w)=>!w.filePath),B=Y.filter((w)=>w.filePath&&w.filePath!==d1),N=X?Array.from(X.values()).filter((w)=>e2(w)):[],f=Q?Array.from(Q.values()).filter((w)=>w.markdown.trim()):[];if(N.length>0||f.length>0){q.push("## Responses"),q.push("");for(let w of N)q.push(d8(w));for(let w of f)q.push(w.markdown.trim()),q.push("")}if(H.length>0){q.push("## Annotations on agent response"),q.push("");for(let w of H)q.push(S2(w))}if(G.length>0){q.push("## Canvas annotations"),q.push("");let w=new Map;for(let _ of G){let O=_.canvasFile||"";if(!w.has(O))w.set(O,[]);w.get(O).push(_)}let F=[...w.keys()].sort(),C=F.length>1||F.length===1&&F[0]!=="";for(let _ of F){let O=w.get(_);if(C&&_)q.push(`### ${_.replace(/\.jsx$/,"")}`),q.push("");let S=i8(O);q.push(O4(S))}}if(B.length>0){let w={};for(let F of B){let C=F.filePath;if(!w[C])w[C]=[];w[C].push(F)}q.push("## File annotations"),q.push("");for(let[F,C]of Object.entries(w)){q.push(`### ${F}`),q.push("");for(let _ of C)q.push(S2(_))}}if(J.trim())q.push("## General notes"),q.push(""),q.push(J.trim()),q.push("");return q.join(`
|
|
8
8
|
`).trim()+`
|
|
9
9
|
`}function e2($){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 K4($){let J=[];for(let X of $.values()){if(!X.required)continue;if(X.value===null||X.value===void 0){J.push(X);continue}if(X.type==="text"&&!X.value.trim()){J.push(X);continue}if(X.type==="checkbox"&&X.value.length===0){J.push(X);continue}}return J}function z4($){let J=[];for(let X of $.values())if(X.required&&!X.markdown.trim())J.push(X);return J}function o1($,J){let X=K4($),Q=z4(J);return[...X.map((W)=>W.label),...Q.map((W)=>W.label||W.id)]}function d8($){let J=[];switch(J.push(`**${$.label}**`),$.type){case"radio":case"select":J.push(`Answer: ${$.value}`);break;case"checkbox":for(let X of $.value)J.push(`- [x] ${X}`);break;case"text":J.push(""),J.push($.value.trim());break;case"range":J.push(`Answer: ${$.value}`);break}if($.note?.trim())J.push(""),J.push(`Note: ${$.note.trim()}`);return J.push(""),J.join(`
|
|
10
|
-
`)}function i8($){let J={label:"",annotations:[],children:new Map};for(let X of $){let Q=X.context?.hierarchy||[],W=J;for(let
|
|
11
|
-
`)}import{createContext as r8,useContext as n8}from"react";function S4(){if(typeof window>"u")return"";return window.location.pathname.replace("/s/","")}var R4={get sessionId(){return S4()},isShared:!1,fsAvailable:!0,uploadUrl:null,loadCanvasModule:($,J)=>{let X=$.replace(/\.jsx$/,".js"),Q=J?`?rev=${J}&t=${Date.now()}`:`?t=${Date.now()}`;return import(`/api/session/${S4()}/canvas/${encodeURIComponent(X)}${Q}`)}},C4=r8(R4);function t0(){return n8(C4)}var $$=U.object({id:U.string(),type:U.enum(["select","radio","checkbox","text","range"]),label:U.string(),value:U.unknown(),options:U.array(U.string()).optional(),required:U.boolean().optional(),note:U.string().optional()}).passthrough().transform(($)=>({...$,value:$.value})),J$=U.object({id:U.string(),markdown:U.string(),label:U.string().optional(),required:U.boolean().optional()}).passthrough(),X$=p$.extend({responses:U.array(U.tuple([U.string(),$$]).optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).catch([]),feedbackEntries:U.array(U.tuple([U.string(),J$]).optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).optional().catch([])});function s1($){let J=X$.safeParse($);return J.success?J.data:null}var P4=U.object({feedback:U.string().nullish()}),k4=U.union([U.object({error:U.string().min(1)}),U.object({content:U.string(),language:U.string().nullish()})]);import{useAnnotations as O1}from"#canvas/runtime";import{jsxDEV as q5}from"react/jsx-dev-runtime";function j4($,J,X){try{let Q=localStorage.getItem(z1($,J,X));if(!Q)return null;return s1(JSON.parse(Q))}catch{return null}}function e8($,J,X,Q){try{localStorage.setItem(z1($,J,X),JSON.stringify(Q))}catch{}}function W5($){return{draft:$,responseIds:new Set,canvases:new Set}}function Q$({sessionId:$,revision:J,isReadOnly:X,draftPhase:Q,remoteAnnotations:W,canvasFiles:Y,loadState:q,saveState:H,children:G}){let B=!!q,N=B?null:j4($,J,Q),f=Q5(N),[L,w]=a1(()=>(N?.annotations??[]).map((k)=>({...k,source:k.source??"local"}))),[F,C]=a1(()=>N?.generalNote??""),[_,O]=a1(()=>N?.responses?new Map(N.responses):new Map),S=`${$}:${J}:${Q}`,M=Q5(S);M.current=S;let[A,Z]=a1(()=>W5(S)),[h,g]=a1(()=>N?.feedbackEntries?new Map(N.feedbackEntries):new Map),[v,u]=a1(!B);A4(()=>{let k=(I)=>{f.current=I,w((I?.annotations??[]).map((l)=>({...l,source:l.source??"local"}))),C(I?.generalNote??""),O(I?.responses?new Map(I.responses):new Map),g(I?.feedbackEntries?new Map(I.feedbackEntries):new Map),X0(null)};if(B){let I=!1;return u(!1),q($,J,Q).then((l)=>{if(I)return;k(s1(l)),u(!0)}),()=>{I=!0}}k(j4($,J,Q)),u(!0);return},[$,J,Q,B,q]);let m=Q5(null);A4(()=>{if(X&&Q!=="next")return;if(!v)return;if(m.current)clearTimeout(m.current);let k={...f.current,annotations:L,generalNote:F,responses:Array.from(_.entries()),feedbackEntries:Array.from(h.entries())},I=()=>{if(H)H($,J,k,Q);else e8($,J,Q,k)};if(Q==="next"){I();return}return m.current=setTimeout(I,300),()=>{if(m.current)clearTimeout(m.current)}},[L,F,_,h,$,J,X,Q,v,H]);let e=t1((k,I)=>{O((l)=>{let K=new Map(l);return K.set(k,I),K})},[]),Q0=t1((k)=>{Z((I)=>{let l=I.draft===M.current?I:W5(M.current);if(l.responseIds.has(k))return l;return{...l,responseIds:new Set(l.responseIds).add(k)}})},[]),Y0=t1((k)=>{Z((I)=>{let l=I.draft===M.current?I:W5(M.current);if(l.canvases.has(k))return l;return{...l,canvases:new Set(l.canvases).add(k)}})},[]),K0=A.draft===S?A:null,c=a8(()=>{if(!K0||!X5(Y,K0.canvases))return _;return J5(_,K0.responseIds)},[K0,Y,_]),$0=t1((k,I)=>{g((l)=>{let K=l.get(k);if(K&&K.markdown===I.markdown&&K.label===I.label&&K.required===I.required)return l;let j=new Map(l);return j.set(k,I),j})},[]),J0=t1((k)=>{g((I)=>{if(!I.has(k))return I;let l=new Map(I);return l.delete(k),l})},[]),G0=t1(()=>{if(O(new Map),g(new Map),H)H($,J,{annotations:[],generalNote:"",responses:[],feedbackEntries:[]},Q);else if(Q==="next")localStorage.removeItem(z1($,J,Q));else $5(localStorage,$,J)},[$,J,Q,H]),a=n2({annotations:L,setAnnotations:w,generalNote:F,setGeneralNote:C,remoteAnnotations:W,isReadOnly:X,onClear:G0}),{setActiveAnnotationId:X0}=a,B0=t0();return q5(t8.Provider,{value:B0,children:q5(s8.Provider,{value:a,children:q5(o8.Provider,{value:{...a,responses:_,setResponse:e,submittableResponses:c,registerResponse:Q0,registerCanvasRendered:Y0,feedbackEntries:h,setFeedbackEntry:$0,removeFeedbackEntry:J0},children:G},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{ActiveViewCtx as U9,AnnotationCtx as B9,CanvasFileCtx as N9,SessionContext as P5,useAnnotations as w9,useCanvasFile as AH,useFeedback as F9,useResponseRegistration as jH}from"#canvas/runtime";function C2($){let J=document.querySelector(`[data-annotation-id="${$.id}"]`);if(J instanceof HTMLElement)return J;let X=$.canvasFile?document.querySelector(`[data-canvas-file="${$.canvasFile}"]`):document;if(!X)return null;return x$($.snippet,X)}function V4($){$.classList.remove("ann-flash"),$.offsetWidth,$.classList.add("ann-flash"),$.addEventListener("animationend",()=>{$.classList.remove("ann-flash")},{once:!0})}function Y5($,J){let X=L1($);if(X)J({type:"file",path:X}),setTimeout(()=>{let Q=C2($);if(Q)Q.scrollIntoView({behavior:"smooth",block:"center"}),V4(Q)},150);else{let Q=C2($);if(Q)Q.scrollIntoView({behavior:"smooth",block:"center"}),V4(Q)}}import{SessionContext as iJ}from"#canvas/runtime";import{useCallback as O5,useContext as S5,useEffect as n4,useMemo as rJ,useState as X2}from"react";import{createContext as T4}from"react";var e1=T4({activeView:{type:"overview"},setActiveView:()=>{},openFiles:[],closeFile:()=>{},canvasFiles:[]}),$2=T4({currentRevision:1,selectedRevision:1,revisions:[],setSelectedRevision:()=>{},isReadOnly:!1,compareRevision:null,setCompareRevision:()=>{},agentWatching:!1});import{jsxDEV as S1}from"react/jsx-dev-runtime";var $J={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"},JJ={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 G5({name:$,type:J,expanded:X,className:Q=""}){if(J==="dir")return S1("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",className:`flex-shrink-0 ${Q}`,children:X?S1("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):S1("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 W=$.includes(".")?$.split(".").pop().toLowerCase():"",Y=$J[W]||"#6b6560",q=JJ[W];return S1("svg",{width:"14",height:"14",viewBox:"0 0 16 16",className:`flex-shrink-0 ${Q}`,children:[S1("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:Y,opacity:"0.85"},void 0,!1,void 0,this),S1("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&&S1("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 U5(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var P1=U5();function E4($){P1=$}var R1={exec:()=>null};function t($,J=""){let X=typeof $=="string"?$:$.source,Q={replace:(W,Y)=>{let q=typeof Y=="string"?Y:Y.source;return q=q.replace(R0.caret,"$1"),X=X.replace(W,q),Q},getRegex:()=>new RegExp(X,J)};return Q}var XJ=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),R0={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)}}>`)},QJ=/^(?:[ \t]*(?:\n|$))+/,WJ=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,qJ=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,j2=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,YJ=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,B5=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,x4=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,h4=t(x4).replace(/bull/g,B5).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(),GJ=t(x4).replace(/bull/g,B5).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(),N5=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,HJ=/^[^\n]+/,w5=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,UJ=t(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",w5).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),BJ=t(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,B5).getRegex(),H$="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",F5=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,NJ=t("^ {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",F5).replace("tag",H$).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),v4=t(N5).replace("hr",j2).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",H$).getRegex(),wJ=t(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",v4).getRegex(),f5={blockquote:wJ,code:WJ,def:UJ,fences:qJ,heading:YJ,hr:j2,html:NJ,lheading:h4,list:BJ,newline:QJ,paragraph:v4,table:R1,text:HJ},Z4=t("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",j2).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",H$).getRegex(),FJ={...f5,lheading:GJ,table:Z4,paragraph:t(N5).replace("hr",j2).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Z4).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",H$).getRegex()},fJ={...f5,html:t(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",F5).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:R1,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:t(N5).replace("hr",j2).replace("heading",` *#{1,6} *[^
|
|
12
|
-
]`).replace("lheading",h4).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},LJ=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,MJ=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,m4=/^( {2,}|\\)\n(?!\s*$)/,_J=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,J2=/[\p{P}\p{S}]/u,U$=/[\s\p{P}\p{S}]/u,L5=/[^\s\p{P}\p{S}]/u,KJ=t(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,U$).getRegex(),c4=/(?!~)[\p{P}\p{S}]/u,zJ=/(?!~)[\s\p{P}\p{S}]/u,OJ=/(?:[^\s\p{P}\p{S}]|~)/u,SJ=t(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",XJ?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),u4=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,RJ=t(u4,"u").replace(/punct/g,J2).getRegex(),CJ=t(u4,"u").replace(/punct/g,c4).getRegex(),p4="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",PJ=t(p4,"gu").replace(/notPunctSpace/g,L5).replace(/punctSpace/g,U$).replace(/punct/g,J2).getRegex(),kJ=t(p4,"gu").replace(/notPunctSpace/g,OJ).replace(/punctSpace/g,zJ).replace(/punct/g,c4).getRegex(),AJ=t("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,L5).replace(/punctSpace/g,U$).replace(/punct/g,J2).getRegex(),jJ=t(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,J2).getRegex(),VJ="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",TJ=t(VJ,"gu").replace(/notPunctSpace/g,L5).replace(/punctSpace/g,U$).replace(/punct/g,J2).getRegex(),ZJ=t(/\\(punct)/,"gu").replace(/punct/g,J2).getRegex(),bJ=t(/^<(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(),DJ=t(F5).replace("(?:-->|$)","-->").getRegex(),
|
|
13
|
-
`).map((
|
|
14
|
-
`)}var
|
|
10
|
+
`)}function i8($){let J={label:"",annotations:[],children:new Map};for(let X of $){let Q=X.context?.hierarchy||[],W=J;for(let q of Q){if(!W.children.has(q))W.children.set(q,{label:q,annotations:[],children:new Map});W=W.children.get(q)}W.annotations.push(X)}return J}function O4($,J=0){let X=[];for(let Q of $.annotations)X.push(S2(Q));for(let[,Q]of $.children){let W=J===0?"###":"####";X.push(`${W} ${Q.label}`),X.push(""),X.push(O4(Q,J+1))}return X.join(`
|
|
11
|
+
`)}import{createContext as r8,useContext as n8}from"react";function S4(){if(typeof window>"u")return"";return window.location.pathname.replace("/s/","")}var R4={get sessionId(){return S4()},isShared:!1,fsAvailable:!0,uploadUrl:null,loadCanvasModule:($,J)=>{let X=$.replace(/\.jsx$/,".js"),Q=J?`?rev=${J}&t=${Date.now()}`:`?t=${Date.now()}`;return import(`/api/session/${S4()}/canvas/${encodeURIComponent(X)}${Q}`)}},C4=r8(R4);function t0(){return n8(C4)}var $$=U.object({id:U.string(),type:U.enum(["select","radio","checkbox","text","range"]),label:U.string(),value:U.unknown(),options:U.array(U.string()).optional(),required:U.boolean().optional(),note:U.string().optional()}).passthrough().transform(($)=>({...$,value:$.value})),J$=U.object({id:U.string(),markdown:U.string(),label:U.string().optional(),required:U.boolean().optional()}).passthrough(),X$=p$.extend({responses:U.array(U.tuple([U.string(),$$]).optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).catch([]),feedbackEntries:U.array(U.tuple([U.string(),J$]).optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).optional().catch([])});function s1($){let J=X$.safeParse($);return J.success?J.data:null}var P4=U.object({feedback:U.string().nullish()}),k4=U.union([U.object({error:U.string().min(1)}),U.object({content:U.string(),language:U.string().nullish()})]);import{useAnnotations as O1}from"#canvas/runtime";import{jsxDEV as Y5}from"react/jsx-dev-runtime";function j4($,J,X){try{let Q=localStorage.getItem(z1($,J,X));if(!Q)return null;return s1(JSON.parse(Q))}catch{return null}}function e8($,J,X,Q){try{localStorage.setItem(z1($,J,X),JSON.stringify(Q))}catch{}}function W5($){return{draft:$,responseIds:new Set,canvases:new Set}}function Q$({sessionId:$,revision:J,isReadOnly:X,draftPhase:Q,remoteAnnotations:W,canvasFiles:q,loadState:Y,saveState:H,children:G}){let B=!!Y,N=B?null:j4($,J,Q),f=Q5(N),[L,w]=a1(()=>(N?.annotations??[]).map((k)=>({...k,source:k.source??"local"}))),[F,C]=a1(()=>N?.generalNote??""),[_,O]=a1(()=>N?.responses?new Map(N.responses):new Map),S=`${$}:${J}:${Q}`,M=Q5(S);M.current=S;let[A,Z]=a1(()=>W5(S)),[h,I]=a1(()=>N?.feedbackEntries?new Map(N.feedbackEntries):new Map),[v,u]=a1(!B);A4(()=>{let k=(g)=>{f.current=g,w((g?.annotations??[]).map((l)=>({...l,source:l.source??"local"}))),C(g?.generalNote??""),O(g?.responses?new Map(g.responses):new Map),I(g?.feedbackEntries?new Map(g.feedbackEntries):new Map),X0(null)};if(B){let g=!1;return u(!1),Y($,J,Q).then((l)=>{if(g)return;k(s1(l)),u(!0)}),()=>{g=!0}}k(j4($,J,Q)),u(!0);return},[$,J,Q,B,Y]);let m=Q5(null);A4(()=>{if(X&&Q!=="next")return;if(!v)return;if(m.current)clearTimeout(m.current);let k={...f.current,annotations:L,generalNote:F,responses:Array.from(_.entries()),feedbackEntries:Array.from(h.entries())},g=()=>{if(H)H($,J,k,Q);else e8($,J,Q,k)};if(Q==="next"){g();return}return m.current=setTimeout(g,300),()=>{if(m.current)clearTimeout(m.current)}},[L,F,_,h,$,J,X,Q,v,H]);let e=t1((k,g)=>{O((l)=>{let K=new Map(l);return K.set(k,g),K})},[]),Q0=t1((k)=>{Z((g)=>{let l=g.draft===M.current?g:W5(M.current);if(l.responseIds.has(k))return l;return{...l,responseIds:new Set(l.responseIds).add(k)}})},[]),q0=t1((k)=>{Z((g)=>{let l=g.draft===M.current?g:W5(M.current);if(l.canvases.has(k))return l;return{...l,canvases:new Set(l.canvases).add(k)}})},[]),K0=A.draft===S?A:null,c=a8(()=>{if(!K0||!X5(q,K0.canvases))return _;return J5(_,K0.responseIds)},[K0,q,_]),$0=t1((k,g)=>{I((l)=>{let K=l.get(k);if(K&&K.markdown===g.markdown&&K.label===g.label&&K.required===g.required)return l;let j=new Map(l);return j.set(k,g),j})},[]),J0=t1((k)=>{I((g)=>{if(!g.has(k))return g;let l=new Map(g);return l.delete(k),l})},[]),G0=t1(()=>{if(O(new Map),I(new Map),H)H($,J,{annotations:[],generalNote:"",responses:[],feedbackEntries:[]},Q);else if(Q==="next")localStorage.removeItem(z1($,J,Q));else $5(localStorage,$,J)},[$,J,Q,H]),a=n2({annotations:L,setAnnotations:w,generalNote:F,setGeneralNote:C,remoteAnnotations:W,isReadOnly:X,onClear:G0}),{setActiveAnnotationId:X0}=a,B0=t0();return Y5(t8.Provider,{value:B0,children:Y5(s8.Provider,{value:a,children:Y5(o8.Provider,{value:{...a,responses:_,setResponse:e,submittableResponses:c,registerResponse:Q0,registerCanvasRendered:q0,feedbackEntries:h,setFeedbackEntry:$0,removeFeedbackEntry:J0},children:G},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{ActiveViewCtx as U9,AnnotationCtx as B9,CanvasFileCtx as N9,SessionContext as P5,useAnnotations as w9,useCanvasFile as jH,useFeedback as F9,useResponseRegistration as VH}from"#canvas/runtime";function C2($){let J=document.querySelector(`[data-annotation-id="${$.id}"]`);if(J instanceof HTMLElement)return J;let X=$.canvasFile?document.querySelector(`[data-canvas-file="${$.canvasFile}"]`):document;if(!X)return null;return x$($.snippet,X)}function V4($){$.classList.remove("ann-flash"),$.offsetWidth,$.classList.add("ann-flash"),$.addEventListener("animationend",()=>{$.classList.remove("ann-flash")},{once:!0})}function q5($,J){let X=L1($);if(X)J({type:"file",path:X}),setTimeout(()=>{let Q=C2($);if(Q)Q.scrollIntoView({behavior:"smooth",block:"center"}),V4(Q)},150);else{let Q=C2($);if(Q)Q.scrollIntoView({behavior:"smooth",block:"center"}),V4(Q)}}import{SessionContext as iJ}from"#canvas/runtime";import{useCallback as O5,useContext as S5,useEffect as n4,useMemo as rJ,useState as X2}from"react";import{createContext as T4}from"react";var e1=T4({activeView:{type:"overview"},setActiveView:()=>{},openFiles:[],closeFile:()=>{},canvasFiles:[]}),$2=T4({currentRevision:1,selectedRevision:1,revisions:[],setSelectedRevision:()=>{},isReadOnly:!1,compareRevision:null,setCompareRevision:()=>{},agentWatching:!1});import{jsxDEV as S1}from"react/jsx-dev-runtime";var $J={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"},JJ={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 G5({name:$,type:J,expanded:X,className:Q=""}){if(J==="dir")return S1("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",className:`flex-shrink-0 ${Q}`,children:X?S1("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):S1("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 W=$.includes(".")?$.split(".").pop().toLowerCase():"",q=$J[W]||"#6b6560",Y=JJ[W];return S1("svg",{width:"14",height:"14",viewBox:"0 0 16 16",className:`flex-shrink-0 ${Q}`,children:[S1("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:q,opacity:"0.85"},void 0,!1,void 0,this),S1("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),Y&&S1("text",{x:"8",y:"11.5",textAnchor:"middle",fill:"white",fontSize:"5.5",fontFamily:"monospace",fontWeight:"600",children:Y},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function U5(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var P1=U5();function E4($){P1=$}var R1={exec:()=>null};function t($,J=""){let X=typeof $=="string"?$:$.source,Q={replace:(W,q)=>{let Y=typeof q=="string"?q:q.source;return Y=Y.replace(R0.caret,"$1"),X=X.replace(W,Y),Q},getRegex:()=>new RegExp(X,J)};return Q}var XJ=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),R0={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)}}>`)},QJ=/^(?:[ \t]*(?:\n|$))+/,WJ=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,YJ=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,j2=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,qJ=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,B5=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,x4=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,h4=t(x4).replace(/bull/g,B5).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(),GJ=t(x4).replace(/bull/g,B5).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(),N5=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,HJ=/^[^\n]+/,w5=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,UJ=t(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",w5).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),BJ=t(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,B5).getRegex(),H$="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",F5=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,NJ=t("^ {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",F5).replace("tag",H$).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),v4=t(N5).replace("hr",j2).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",H$).getRegex(),wJ=t(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",v4).getRegex(),f5={blockquote:wJ,code:WJ,def:UJ,fences:YJ,heading:qJ,hr:j2,html:NJ,lheading:h4,list:BJ,newline:QJ,paragraph:v4,table:R1,text:HJ},Z4=t("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",j2).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",H$).getRegex(),FJ={...f5,lheading:GJ,table:Z4,paragraph:t(N5).replace("hr",j2).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Z4).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",H$).getRegex()},fJ={...f5,html:t(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",F5).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:R1,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:t(N5).replace("hr",j2).replace("heading",` *#{1,6} *[^
|
|
12
|
+
]`).replace("lheading",h4).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},LJ=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,MJ=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,m4=/^( {2,}|\\)\n(?!\s*$)/,_J=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,J2=/[\p{P}\p{S}]/u,U$=/[\s\p{P}\p{S}]/u,L5=/[^\s\p{P}\p{S}]/u,KJ=t(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,U$).getRegex(),c4=/(?!~)[\p{P}\p{S}]/u,zJ=/(?!~)[\s\p{P}\p{S}]/u,OJ=/(?:[^\s\p{P}\p{S}]|~)/u,SJ=t(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",XJ?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),u4=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,RJ=t(u4,"u").replace(/punct/g,J2).getRegex(),CJ=t(u4,"u").replace(/punct/g,c4).getRegex(),p4="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",PJ=t(p4,"gu").replace(/notPunctSpace/g,L5).replace(/punctSpace/g,U$).replace(/punct/g,J2).getRegex(),kJ=t(p4,"gu").replace(/notPunctSpace/g,OJ).replace(/punctSpace/g,zJ).replace(/punct/g,c4).getRegex(),AJ=t("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,L5).replace(/punctSpace/g,U$).replace(/punct/g,J2).getRegex(),jJ=t(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,J2).getRegex(),VJ="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",TJ=t(VJ,"gu").replace(/notPunctSpace/g,L5).replace(/punctSpace/g,U$).replace(/punct/g,J2).getRegex(),ZJ=t(/\\(punct)/,"gu").replace(/punct/g,J2).getRegex(),bJ=t(/^<(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(),DJ=t(F5).replace("(?:-->|$)","-->").getRegex(),gJ=t("^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",DJ).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Y$=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,IJ=t(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Y$).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),l4=t(/^!?\[(label)\]\[(ref)\]/).replace("label",Y$).replace("ref",w5).getRegex(),d4=t(/^!?\[(ref)\](?:\[\])?/).replace("ref",w5).getRegex(),yJ=t("reflink|nolink(?!\\()","g").replace("reflink",l4).replace("nolink",d4).getRegex(),b4=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,M5={_backpedal:R1,anyPunctuation:ZJ,autolink:bJ,blockSkip:SJ,br:m4,code:MJ,del:R1,delLDelim:R1,delRDelim:R1,emStrongLDelim:RJ,emStrongRDelimAst:PJ,emStrongRDelimUnd:AJ,escape:LJ,link:IJ,nolink:d4,punctuation:KJ,reflink:l4,reflinkSearch:yJ,tag:gJ,text:_J,url:R1},EJ={...M5,link:t(/^!?\[(label)\]\((.*?)\)/).replace("label",Y$).getRegex(),reflink:t(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Y$).getRegex()},H5={...M5,emStrongRDelimAst:kJ,emStrongLDelim:CJ,delLDelim:jJ,delRDelim:TJ,url:t(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",b4).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:t(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",b4).getRegex()},xJ={...H5,br:t(m4).replace("{2,}","*").getRegex(),text:t(H5.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},W$={normal:f5,gfm:FJ,pedantic:fJ},P2={normal:M5,gfm:H5,breaks:xJ,pedantic:EJ},hJ={"&":"&","<":"<",">":">",'"':""","'":"'"},D4=($)=>hJ[$];function p0($,J){if(J){if(R0.escapeTest.test($))return $.replace(R0.escapeReplace,D4)}else if(R0.escapeTestNoEncode.test($))return $.replace(R0.escapeReplaceNoEncode,D4);return $}function g4($){try{$=encodeURI($).replace(R0.percentDecode,"%")}catch{return null}return $}function I4($,J){let X=$.replace(R0.findPipe,(q,Y,H)=>{let G=!1,B=Y;for(;--B>=0&&H[B]==="\\";)G=!G;return G?"|":" |"}),Q=X.split(R0.splitPipe),W=0;if(Q[0].trim()||Q.shift(),Q.length>0&&!Q.at(-1)?.trim()&&Q.pop(),J)if(Q.length>J)Q.splice(J);else for(;Q.length<J;)Q.push("");for(;W<Q.length;W++)Q[W]=Q[W].trim().replace(R0.slashPipe,"|");return Q}function k2($,J,X){let Q=$.length;if(Q===0)return"";let W=0;for(;W<Q;){let q=$.charAt(Q-W-1);if(q===J&&!X)W++;else if(q!==J&&X)W++;else break}return $.slice(0,Q-W)}function vJ($,J){if($.indexOf(J[1])===-1)return-1;let X=0;for(let Q=0;Q<$.length;Q++)if($[Q]==="\\")Q++;else if($[Q]===J[0])X++;else if($[Q]===J[1]&&(X--,X<0))return Q;return X>0?-2:-1}function mJ($,J=0){let X=J,Q="";for(let W of $)if(W==="\t"){let q=4-X%4;Q+=" ".repeat(q),X+=q}else Q+=W,X++;return Q}function y4($,J,X,Q,W){let q=J.href,Y=J.title||null,H=$[1].replace(W.other.outputLinkReplace,"$1");Q.state.inLink=!0;let G={type:$[0].charAt(0)==="!"?"image":"link",raw:X,href:q,title:Y,text:H,tokens:Q.inlineTokens(H)};return Q.state.inLink=!1,G}function cJ($,J,X){let Q=$.match(X.other.indentCodeCompensation);if(Q===null)return J;let W=Q[1];return J.split(`
|
|
13
|
+
`).map((q)=>{let Y=q.match(X.other.beginningSpace);if(Y===null)return q;let[H]=Y;return H.length>=W.length?q.slice(W.length):q}).join(`
|
|
14
|
+
`)}var q$=class{options;rules;lexer;constructor($){this.options=$||P1}space($){let J=this.rules.block.newline.exec($);if(J&&J[0].length>0)return{type:"space",raw:J[0]}}code($){let J=this.rules.block.code.exec($);if(J){let X=J[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:J[0],codeBlockStyle:"indented",text:this.options.pedantic?X:k2(X,`
|
|
15
15
|
`)}}}fences($){let J=this.rules.block.fences.exec($);if(J){let X=J[0],Q=cJ(X,J[3]||"",this.rules);return{type:"code",raw:X,lang:J[2]?J[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):J[2],text:Q}}}heading($){let J=this.rules.block.heading.exec($);if(J){let X=J[2].trim();if(this.rules.other.endingHash.test(X)){let Q=k2(X,"#");(this.options.pedantic||!Q||this.rules.other.endingSpaceChar.test(Q))&&(X=Q.trim())}return{type:"heading",raw:J[0],depth:J[1].length,text:X,tokens:this.lexer.inline(X)}}}hr($){let J=this.rules.block.hr.exec($);if(J)return{type:"hr",raw:k2(J[0],`
|
|
16
16
|
`)}}blockquote($){let J=this.rules.block.blockquote.exec($);if(J){let X=k2(J[0],`
|
|
17
17
|
`).split(`
|
|
18
|
-
`),Q="",W="",
|
|
18
|
+
`),Q="",W="",q=[];for(;X.length>0;){let Y=!1,H=[],G;for(G=0;G<X.length;G++)if(this.rules.other.blockquoteStart.test(X[G]))H.push(X[G]),Y=!0;else if(!Y)H.push(X[G]);else break;X=X.slice(G);let B=H.join(`
|
|
19
19
|
`),N=B.replace(this.rules.other.blockquoteSetextReplace,`
|
|
20
20
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");Q=Q?`${Q}
|
|
21
21
|
${B}`:B,W=W?`${W}
|
|
22
|
-
${N}`:N;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(N,
|
|
22
|
+
${N}`:N;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(N,q,!0),this.lexer.state.top=f,X.length===0)break;let L=q.at(-1);if(L?.type==="code")break;if(L?.type==="blockquote"){let w=L,F=w.raw+`
|
|
23
23
|
`+X.join(`
|
|
24
|
-
`),C=this.blockquote(F);
|
|
24
|
+
`),C=this.blockquote(F);q[q.length-1]=C,Q=Q.substring(0,Q.length-w.raw.length)+C.raw,W=W.substring(0,W.length-w.text.length)+C.text;break}else if(L?.type==="list"){let w=L,F=w.raw+`
|
|
25
25
|
`+X.join(`
|
|
26
|
-
`),C=this.list(F);
|
|
27
|
-
`);continue}}return{type:"blockquote",raw:Q,tokens:
|
|
26
|
+
`),C=this.list(F);q[q.length-1]=C,Q=Q.substring(0,Q.length-L.raw.length)+C.raw,W=W.substring(0,W.length-w.raw.length)+C.raw,X=F.substring(q.at(-1).raw.length).split(`
|
|
27
|
+
`);continue}}return{type:"blockquote",raw:Q,tokens:q,text:W}}}list($){let J=this.rules.block.list.exec($);if(J){let X=J[1].trim(),Q=X.length>1,W={type:"list",raw:"",ordered:Q,start:Q?+X.slice(0,-1):"",loose:!1,items:[]};X=Q?`\\d{1,9}\\${X.slice(-1)}`:`\\${X}`,this.options.pedantic&&(X=Q?X:"[*+-]");let q=this.rules.other.listItemRegex(X),Y=!1;for(;$;){let G=!1,B="",N="";if(!(J=q.exec($))||this.rules.block.hr.test($))break;B=J[0],$=$.substring(B.length);let f=mJ(J[2].split(`
|
|
28
28
|
`,1)[0],J[1].length),L=$.split(`
|
|
29
29
|
`,1)[0],w=!f.trim(),F=0;if(this.options.pedantic?(F=2,N=f.trimStart()):w?F=J[1].length+1:(F=f.search(this.rules.other.nonSpaceChar),F=F>4?1:F,N=f.slice(F),F+=J[1].length),w&&this.rules.other.blankLine.test(L)&&(B+=L+`
|
|
30
30
|
`,$=$.substring(L.length+1),G=!0),!G){let C=this.rules.other.nextBulletRegex(F),_=this.rules.other.hrRegex(F),O=this.rules.other.fencesBeginRegex(F),S=this.rules.other.headingBeginRegex(F),M=this.rules.other.htmlBeginRegex(F),A=this.rules.other.blockquoteBeginRegex(F);for(;$;){let Z=$.split(`
|
|
31
31
|
`,1)[0],h;if(L=Z,this.options.pedantic?(L=L.replace(this.rules.other.listReplaceNesting," "),h=L):h=L.replace(this.rules.other.tabCharGlobal," "),O.test(L)||S.test(L)||M.test(L)||A.test(L)||C.test(L)||_.test(L))break;if(h.search(this.rules.other.nonSpaceChar)>=F||!L.trim())N+=`
|
|
32
32
|
`+h.slice(F);else{if(w||f.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||O.test(f)||S.test(f)||_.test(f))break;N+=`
|
|
33
33
|
`+L}w=!L.trim(),B+=Z+`
|
|
34
|
-
`,$=$.substring(Z.length+1),f=h.slice(F)}}W.loose||(
|
|
35
|
-
`):[],
|
|
36
|
-
`?J[1].slice(0,-1):J[1];return{type:"paragraph",raw:J[0],text:X,tokens:this.lexer.inline(X)}}}text($){let J=this.rules.block.text.exec($);if(J)return{type:"text",raw:J[0],text:J[0],tokens:this.lexer.inline(J[0])}}escape($){let J=this.rules.inline.escape.exec($);if(J)return{type:"escape",raw:J[0],text:J[1]}}tag($){let J=this.rules.inline.tag.exec($);if(J)return!this.lexer.state.inLink&&this.rules.other.startATag.test(J[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(J[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(J[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(J[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:J[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:J[0]}}link($){let J=this.rules.inline.link.exec($);if(J){let X=J[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(X)){if(!this.rules.other.endAngleBracket.test(X))return;let
|
|
37
|
-
`),this.blockTokens(J,this.tokens);for(let X=0;X<this.inlineQueue.length;X++){let Q=this.inlineQueue[X];this.inlineTokens(Q.src,Q.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(J,X=[],Q=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(J=J.replace(R0.tabCharGlobal," ").replace(R0.spaceLine,""));J;){let W;if(this.options.extensions?.block?.some((
|
|
38
|
-
`:X.push(W);continue}if(W=this.tokenizer.code(J)){J=J.substring(W.raw.length);let
|
|
34
|
+
`,$=$.substring(Z.length+1),f=h.slice(F)}}W.loose||(Y?W.loose=!0:this.rules.other.doubleBlankLine.test(B)&&(Y=!0)),W.items.push({type:"list_item",raw:B,task:!!this.options.gfm&&this.rules.other.listIsTask.test(N),loose:!1,text:N,tokens:[]}),W.raw+=B}let H=W.items.at(-1);if(H)H.raw=H.raw.trimEnd(),H.text=H.text.trimEnd();else return;W.raw=W.raw.trimEnd();for(let G of W.items){if(this.lexer.state.top=!1,G.tokens=this.lexer.blockTokens(G.text,[]),G.task){if(G.text=G.text.replace(this.rules.other.listReplaceTask,""),G.tokens[0]?.type==="text"||G.tokens[0]?.type==="paragraph"){G.tokens[0].raw=G.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),G.tokens[0].text=G.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 B=this.rules.other.listTaskCheckbox.exec(G.raw);if(B){let N={type:"checkbox",raw:B[0]+" ",checked:B[0]!=="[ ]"};G.checked=N.checked,W.loose?G.tokens[0]&&["paragraph","text"].includes(G.tokens[0].type)&&"tokens"in G.tokens[0]&&G.tokens[0].tokens?(G.tokens[0].raw=N.raw+G.tokens[0].raw,G.tokens[0].text=N.raw+G.tokens[0].text,G.tokens[0].tokens.unshift(N)):G.tokens.unshift({type:"paragraph",raw:N.raw,text:N.raw,tokens:[N]}):G.tokens.unshift(N)}}if(!W.loose){let B=G.tokens.filter((f)=>f.type==="space"),N=B.length>0&&B.some((f)=>this.rules.other.anyLine.test(f.raw));W.loose=N}}if(W.loose)for(let G of W.items){G.loose=!0;for(let B of G.tokens)B.type==="text"&&(B.type="paragraph")}return W}}html($){let J=this.rules.block.html.exec($);if(J)return{type:"html",block:!0,raw:J[0],pre:J[1]==="pre"||J[1]==="script"||J[1]==="style",text:J[0]}}def($){let J=this.rules.block.def.exec($);if(J){let X=J[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),Q=J[2]?J[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",W=J[3]?J[3].substring(1,J[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):J[3];return{type:"def",tag:X,raw:J[0],href:Q,title:W}}}table($){let J=this.rules.block.table.exec($);if(!J||!this.rules.other.tableDelimiter.test(J[2]))return;let X=I4(J[1]),Q=J[2].replace(this.rules.other.tableAlignChars,"").split("|"),W=J[3]?.trim()?J[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
35
|
+
`):[],q={type:"table",raw:J[0],header:[],align:[],rows:[]};if(X.length===Q.length){for(let Y of Q)this.rules.other.tableAlignRight.test(Y)?q.align.push("right"):this.rules.other.tableAlignCenter.test(Y)?q.align.push("center"):this.rules.other.tableAlignLeft.test(Y)?q.align.push("left"):q.align.push(null);for(let Y=0;Y<X.length;Y++)q.header.push({text:X[Y],tokens:this.lexer.inline(X[Y]),header:!0,align:q.align[Y]});for(let Y of W)q.rows.push(I4(Y,q.header.length).map((H,G)=>({text:H,tokens:this.lexer.inline(H),header:!1,align:q.align[G]})));return q}}lheading($){let J=this.rules.block.lheading.exec($);if(J){let X=J[1].trim();return{type:"heading",raw:J[0],depth:J[2].charAt(0)==="="?1:2,text:X,tokens:this.lexer.inline(X)}}}paragraph($){let J=this.rules.block.paragraph.exec($);if(J){let X=J[1].charAt(J[1].length-1)===`
|
|
36
|
+
`?J[1].slice(0,-1):J[1];return{type:"paragraph",raw:J[0],text:X,tokens:this.lexer.inline(X)}}}text($){let J=this.rules.block.text.exec($);if(J)return{type:"text",raw:J[0],text:J[0],tokens:this.lexer.inline(J[0])}}escape($){let J=this.rules.inline.escape.exec($);if(J)return{type:"escape",raw:J[0],text:J[1]}}tag($){let J=this.rules.inline.tag.exec($);if(J)return!this.lexer.state.inLink&&this.rules.other.startATag.test(J[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(J[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(J[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(J[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:J[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:J[0]}}link($){let J=this.rules.inline.link.exec($);if(J){let X=J[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(X)){if(!this.rules.other.endAngleBracket.test(X))return;let q=k2(X.slice(0,-1),"\\");if((X.length-q.length)%2===0)return}else{let q=vJ(J[2],"()");if(q===-2)return;if(q>-1){let Y=(J[0].indexOf("!")===0?5:4)+J[1].length+q;J[2]=J[2].substring(0,q),J[0]=J[0].substring(0,Y).trim(),J[3]=""}}let Q=J[2],W="";if(this.options.pedantic){let q=this.rules.other.pedanticHrefTitle.exec(Q);q&&(Q=q[1],W=q[3])}else W=J[3]?J[3].slice(1,-1):"";return Q=Q.trim(),this.rules.other.startAngleBracket.test(Q)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(X)?Q=Q.slice(1):Q=Q.slice(1,-1)),y4(J,{href:Q&&Q.replace(this.rules.inline.anyPunctuation,"$1"),title:W&&W.replace(this.rules.inline.anyPunctuation,"$1")},J[0],this.lexer,this.rules)}}reflink($,J){let X;if((X=this.rules.inline.reflink.exec($))||(X=this.rules.inline.nolink.exec($))){let Q=(X[2]||X[1]).replace(this.rules.other.multipleSpaceGlobal," "),W=J[Q.toLowerCase()];if(!W){let q=X[0].charAt(0);return{type:"text",raw:q,text:q}}return y4(X,W,X[0],this.lexer,this.rules)}}emStrong($,J,X=""){let Q=this.rules.inline.emStrongLDelim.exec($);if(!Q||!Q[1]&&!Q[2]&&!Q[3]&&!Q[4]||Q[4]&&X.match(this.rules.other.unicodeAlphaNumeric))return;if(!(Q[1]||Q[3])||!X||this.rules.inline.punctuation.exec(X)){let W=[...Q[0]].length-1,q,Y,H=W,G=0,B=Q[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(B.lastIndex=0,J=J.slice(-1*$.length+W);(Q=B.exec(J))!==null;){if(q=Q[1]||Q[2]||Q[3]||Q[4]||Q[5]||Q[6],!q)continue;if(Y=[...q].length,Q[3]||Q[4]){H+=Y;continue}else if((Q[5]||Q[6])&&W%3&&!((W+Y)%3)){G+=Y;continue}if(H-=Y,H>0)continue;Y=Math.min(Y,Y+H+G);let N=[...Q[0]][0].length,f=$.slice(0,W+Q.index+N+Y);if(Math.min(W,Y)%2){let w=f.slice(1,-1);return{type:"em",raw:f,text:w,tokens:this.lexer.inlineTokens(w)}}let L=f.slice(2,-2);return{type:"strong",raw:f,text:L,tokens:this.lexer.inlineTokens(L)}}}}codespan($){let J=this.rules.inline.code.exec($);if(J){let X=J[2].replace(this.rules.other.newLineCharGlobal," "),Q=this.rules.other.nonSpaceChar.test(X),W=this.rules.other.startingSpaceChar.test(X)&&this.rules.other.endingSpaceChar.test(X);return Q&&W&&(X=X.substring(1,X.length-1)),{type:"codespan",raw:J[0],text:X}}}br($){let J=this.rules.inline.br.exec($);if(J)return{type:"br",raw:J[0]}}del($,J,X=""){let Q=this.rules.inline.delLDelim.exec($);if(!Q)return;if(!Q[1]||!X||this.rules.inline.punctuation.exec(X)){let W=[...Q[0]].length-1,q,Y,H=W,G=this.rules.inline.delRDelim;for(G.lastIndex=0,J=J.slice(-1*$.length+W);(Q=G.exec(J))!==null;){if(q=Q[1]||Q[2]||Q[3]||Q[4]||Q[5]||Q[6],!q||(Y=[...q].length,Y!==W))continue;if(Q[3]||Q[4]){H+=Y;continue}if(H-=Y,H>0)continue;Y=Math.min(Y,Y+H);let B=[...Q[0]][0].length,N=$.slice(0,W+Q.index+B+Y),f=N.slice(W,-W);return{type:"del",raw:N,text:f,tokens:this.lexer.inlineTokens(f)}}}}autolink($){let J=this.rules.inline.autolink.exec($);if(J){let X,Q;return J[2]==="@"?(X=J[1],Q="mailto:"+X):(X=J[1],Q=X),{type:"link",raw:J[0],text:X,href:Q,tokens:[{type:"text",raw:X,text:X}]}}}url($){let J;if(J=this.rules.inline.url.exec($)){let X,Q;if(J[2]==="@")X=J[0],Q="mailto:"+X;else{let W;do W=J[0],J[0]=this.rules.inline._backpedal.exec(J[0])?.[0]??"";while(W!==J[0]);X=J[0],J[1]==="www."?Q="http://"+J[0]:Q=J[0]}return{type:"link",raw:J[0],text:X,href:Q,tokens:[{type:"text",raw:X,text:X}]}}}inlineText($){let J=this.rules.inline.text.exec($);if(J){let X=this.lexer.state.inRawBlock;return{type:"text",raw:J[0],text:J[0],escaped:X}}}},y0=class ${tokens;options;state;inlineQueue;tokenizer;constructor(J){this.tokens=[],this.tokens.links=Object.create(null),this.options=J||P1,this.options.tokenizer=this.options.tokenizer||new q$,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 X={other:R0,block:W$.normal,inline:P2.normal};this.options.pedantic?(X.block=W$.pedantic,X.inline=P2.pedantic):this.options.gfm&&(X.block=W$.gfm,this.options.breaks?X.inline=P2.breaks:X.inline=P2.gfm),this.tokenizer.rules=X}static get rules(){return{block:W$,inline:P2}}static lex(J,X){return new $(X).lex(J)}static lexInline(J,X){return new $(X).inlineTokens(J)}lex(J){J=J.replace(R0.carriageReturn,`
|
|
37
|
+
`),this.blockTokens(J,this.tokens);for(let X=0;X<this.inlineQueue.length;X++){let Q=this.inlineQueue[X];this.inlineTokens(Q.src,Q.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(J,X=[],Q=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(J=J.replace(R0.tabCharGlobal," ").replace(R0.spaceLine,""));J;){let W;if(this.options.extensions?.block?.some((Y)=>(W=Y.call({lexer:this},J,X))?(J=J.substring(W.raw.length),X.push(W),!0):!1))continue;if(W=this.tokenizer.space(J)){J=J.substring(W.raw.length);let Y=X.at(-1);W.raw.length===1&&Y!==void 0?Y.raw+=`
|
|
38
|
+
`:X.push(W);continue}if(W=this.tokenizer.code(J)){J=J.substring(W.raw.length);let Y=X.at(-1);Y?.type==="paragraph"||Y?.type==="text"?(Y.raw+=(Y.raw.endsWith(`
|
|
39
39
|
`)?"":`
|
|
40
|
-
`)+W.raw,
|
|
41
|
-
`+W.text,this.inlineQueue.at(-1).src=
|
|
40
|
+
`)+W.raw,Y.text+=`
|
|
41
|
+
`+W.text,this.inlineQueue.at(-1).src=Y.text):X.push(W);continue}if(W=this.tokenizer.fences(J)){J=J.substring(W.raw.length),X.push(W);continue}if(W=this.tokenizer.heading(J)){J=J.substring(W.raw.length),X.push(W);continue}if(W=this.tokenizer.hr(J)){J=J.substring(W.raw.length),X.push(W);continue}if(W=this.tokenizer.blockquote(J)){J=J.substring(W.raw.length),X.push(W);continue}if(W=this.tokenizer.list(J)){J=J.substring(W.raw.length),X.push(W);continue}if(W=this.tokenizer.html(J)){J=J.substring(W.raw.length),X.push(W);continue}if(W=this.tokenizer.def(J)){J=J.substring(W.raw.length);let Y=X.at(-1);Y?.type==="paragraph"||Y?.type==="text"?(Y.raw+=(Y.raw.endsWith(`
|
|
42
42
|
`)?"":`
|
|
43
|
-
`)+W.raw,
|
|
44
|
-
`+W.raw,this.inlineQueue.at(-1).src=
|
|
43
|
+
`)+W.raw,Y.text+=`
|
|
44
|
+
`+W.raw,this.inlineQueue.at(-1).src=Y.text):this.tokens.links[W.tag]||(this.tokens.links[W.tag]={href:W.href,title:W.title},X.push(W));continue}if(W=this.tokenizer.table(J)){J=J.substring(W.raw.length),X.push(W);continue}if(W=this.tokenizer.lheading(J)){J=J.substring(W.raw.length),X.push(W);continue}let q=J;if(this.options.extensions?.startBlock){let Y=1/0,H=J.slice(1),G;this.options.extensions.startBlock.forEach((B)=>{G=B.call({lexer:this},H),typeof G=="number"&&G>=0&&(Y=Math.min(Y,G))}),Y<1/0&&Y>=0&&(q=J.substring(0,Y+1))}if(this.state.top&&(W=this.tokenizer.paragraph(q))){let Y=X.at(-1);Q&&Y?.type==="paragraph"?(Y.raw+=(Y.raw.endsWith(`
|
|
45
45
|
`)?"":`
|
|
46
|
-
`)+W.raw,
|
|
47
|
-
`+W.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=
|
|
46
|
+
`)+W.raw,Y.text+=`
|
|
47
|
+
`+W.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=Y.text):X.push(W),Q=q.length!==J.length,J=J.substring(W.raw.length);continue}if(W=this.tokenizer.text(J)){J=J.substring(W.raw.length);let Y=X.at(-1);Y?.type==="text"?(Y.raw+=(Y.raw.endsWith(`
|
|
48
48
|
`)?"":`
|
|
49
|
-
`)+W.raw,
|
|
50
|
-
`+W.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=
|
|
49
|
+
`)+W.raw,Y.text+=`
|
|
50
|
+
`+W.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=Y.text):X.push(W);continue}if(J){let Y="Infinite loop on byte: "+J.charCodeAt(0);if(this.options.silent){console.error(Y);break}else throw Error(Y)}}return this.state.top=!0,X}inline(J,X=[]){return this.inlineQueue.push({src:J,tokens:X}),X}inlineTokens(J,X=[]){this.tokenizer.lexer=this;let Q=J,W=null;if(this.tokens.links){let G=Object.keys(this.tokens.links);if(G.length>0)for(;(W=this.tokenizer.rules.inline.reflinkSearch.exec(Q))!==null;)G.includes(W[0].slice(W[0].lastIndexOf("[")+1,-1))&&(Q=Q.slice(0,W.index)+"["+"a".repeat(W[0].length-2)+"]"+Q.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(W=this.tokenizer.rules.inline.anyPunctuation.exec(Q))!==null;)Q=Q.slice(0,W.index)+"++"+Q.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let q;for(;(W=this.tokenizer.rules.inline.blockSkip.exec(Q))!==null;)q=W[2]?W[2].length:0,Q=Q.slice(0,W.index+q)+"["+"a".repeat(W[0].length-q-2)+"]"+Q.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);Q=this.options.hooks?.emStrongMask?.call({lexer:this},Q)??Q;let Y=!1,H="";for(;J;){Y||(H=""),Y=!1;let G;if(this.options.extensions?.inline?.some((N)=>(G=N.call({lexer:this},J,X))?(J=J.substring(G.raw.length),X.push(G),!0):!1))continue;if(G=this.tokenizer.escape(J)){J=J.substring(G.raw.length),X.push(G);continue}if(G=this.tokenizer.tag(J)){J=J.substring(G.raw.length),X.push(G);continue}if(G=this.tokenizer.link(J)){J=J.substring(G.raw.length),X.push(G);continue}if(G=this.tokenizer.reflink(J,this.tokens.links)){J=J.substring(G.raw.length);let N=X.at(-1);G.type==="text"&&N?.type==="text"?(N.raw+=G.raw,N.text+=G.text):X.push(G);continue}if(G=this.tokenizer.emStrong(J,Q,H)){J=J.substring(G.raw.length),X.push(G);continue}if(G=this.tokenizer.codespan(J)){J=J.substring(G.raw.length),X.push(G);continue}if(G=this.tokenizer.br(J)){J=J.substring(G.raw.length),X.push(G);continue}if(G=this.tokenizer.del(J,Q,H)){J=J.substring(G.raw.length),X.push(G);continue}if(G=this.tokenizer.autolink(J)){J=J.substring(G.raw.length),X.push(G);continue}if(!this.state.inLink&&(G=this.tokenizer.url(J))){J=J.substring(G.raw.length),X.push(G);continue}let B=J;if(this.options.extensions?.startInline){let N=1/0,f=J.slice(1),L;this.options.extensions.startInline.forEach((w)=>{L=w.call({lexer:this},f),typeof L=="number"&&L>=0&&(N=Math.min(N,L))}),N<1/0&&N>=0&&(B=J.substring(0,N+1))}if(G=this.tokenizer.inlineText(B)){J=J.substring(G.raw.length),G.raw.slice(-1)!=="_"&&(H=G.raw.slice(-1)),Y=!0;let N=X.at(-1);N?.type==="text"?(N.raw+=G.raw,N.text+=G.text):X.push(G);continue}if(J){let N="Infinite loop on byte: "+J.charCodeAt(0);if(this.options.silent){console.error(N);break}else throw Error(N)}}return X}},G$=class{options;parser;constructor($){this.options=$||P1}space($){return""}code({text:$,lang:J,escaped:X}){let Q=(J||"").match(R0.notSpaceStart)?.[0],W=$.replace(R0.endingNewline,"")+`
|
|
51
51
|
`;return Q?'<pre><code class="language-'+p0(Q)+'">'+(X?W:p0(W,!0))+`</code></pre>
|
|
52
52
|
`:"<pre><code>"+(X?W:p0(W,!0))+`</code></pre>
|
|
53
53
|
`}blockquote({tokens:$}){return`<blockquote>
|
|
54
54
|
${this.parser.parse($)}</blockquote>
|
|
55
55
|
`}html({text:$}){return $}def($){return""}heading({tokens:$,depth:J}){return`<h${J}>${this.parser.parseInline($)}</h${J}>
|
|
56
56
|
`}hr($){return`<hr>
|
|
57
|
-
`}list($){let{ordered:J,start:X}=$,Q="";for(let
|
|
57
|
+
`}list($){let{ordered:J,start:X}=$,Q="";for(let Y=0;Y<$.items.length;Y++){let H=$.items[Y];Q+=this.listitem(H)}let W=J?"ol":"ul",q=J&&X!==1?' start="'+X+'"':"";return"<"+W+q+`>
|
|
58
58
|
`+Q+"</"+W+`>
|
|
59
59
|
`}listitem($){return`<li>${this.parser.parse($.tokens)}</li>
|
|
60
60
|
`}checkbox({checked:$}){return"<input "+($?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:$}){return`<p>${this.parser.parseInline($)}</p>
|
|
61
|
-
`}table($){let J="",X="";for(let W=0;W<$.header.length;W++)X+=this.tablecell($.header[W]);J+=this.tablerow({text:X});let Q="";for(let W=0;W<$.rows.length;W++){let
|
|
61
|
+
`}table($){let J="",X="";for(let W=0;W<$.header.length;W++)X+=this.tablecell($.header[W]);J+=this.tablerow({text:X});let Q="";for(let W=0;W<$.rows.length;W++){let q=$.rows[W];X="";for(let Y=0;Y<q.length;Y++)X+=this.tablecell(q[Y]);Q+=this.tablerow({text:X})}return Q&&(Q=`<tbody>${Q}</tbody>`),`<table>
|
|
62
62
|
<thead>
|
|
63
63
|
`+J+`</thead>
|
|
64
64
|
`+Q+`</table>
|
|
65
65
|
`}tablerow({text:$}){return`<tr>
|
|
66
66
|
${$}</tr>
|
|
67
67
|
`}tablecell($){let J=this.parser.parseInline($.tokens),X=$.header?"th":"td";return($.align?`<${X} align="${$.align}">`:`<${X}>`)+J+`</${X}>
|
|
68
|
-
`}strong({tokens:$}){return`<strong>${this.parser.parseInline($)}</strong>`}em({tokens:$}){return`<em>${this.parser.parseInline($)}</em>`}codespan({text:$}){return`<code>${p0($,!0)}</code>`}br($){return"<br>"}del({tokens:$}){return`<del>${this.parser.parseInline($)}</del>`}link({href:$,title:J,tokens:X}){let Q=this.parser.parseInline(X),W=
|
|
69
|
-
Please report this to https://github.com/markedjs/marked.`,$){let Q="<p>An error occurred:</p><pre>"+p0(X.message+"",!0)+"</pre>";return J?Promise.resolve(Q):Q}if(J)return Promise.reject(X);throw X}}},C1=new uJ;function s($,J){return C1.parse($,J)}s.options=s.setOptions=function($){return C1.setOptions($),s.defaults=C1.defaults,E4(s.defaults),s};s.getDefaults=U5;s.defaults=P1;s.use=function(...$){return C1.use(...$),s.defaults=C1.defaults,E4(s.defaults),s};s.walkTokens=function($,J){return C1.walkTokens($,J)};s.parseInline=C1.parseInline;s.Parser=E0;s.parser=E0.parse;s.Renderer=G$;s.TextRenderer=_5;s.Lexer=y0;s.lexer=y0.lex;s.Tokenizer=Y$;s.Hooks=A2;s.parse=s;var{options:yW,setOptions:EW,use:xW,walkTokens:hW,parseInline:vW}=s;var mW=E0.parse,cW=y0.lex;import{useEffect as i4,useMemo as K5,useRef as pJ,useState as V2}from"react";import{jsxDEV as F0}from"react/jsx-dev-runtime";function z5({open:$,onClose:J,onSubmit:X,includedRemoteIds:Q,onToggleRemoteId:W}){let{annotations:Y,generalNote:q,submittableResponses:H,feedbackEntries:G}=O1(),[B,N]=V2(""),[f,L]=V2(!1),[w,F]=V2(!1),[C,_]=V2(null),O=pJ(null),[S,M]=V2(!1),A=K5(()=>Y.filter((v)=>v.source==="remote"),[Y]);if($&&!S)L(!1),F(!1),_(null);if(!$&&S)L(!1),F(!1),_(null);if($!==S)M($);let Z=K5(()=>n1(Y,q,H,G,Q),[Y,q,H,G,Q]),h=f?B:Z;if(i4(()=>{if($&&w&&O.current)O.current.focus()},[$,w]),i4(()=>{if(!$)return;let v=(u)=>{if(u.key==="Escape")J()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[$,J]),!$)return null;let g=h.trim().length>0;return F0("div",{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm flex items-center justify-center p-8",onClick:J,children:F0("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:(v)=>v.stopPropagation(),children:[F0("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border-subtle flex-shrink-0",children:[F0("div",{className:"flex items-center gap-3",children:[F0("span",{className:"text-[13px] font-medium text-text-primary font-body",children:"Response preview"},void 0,!1,void 0,this),f&&F0("button",{onClick:()=>{L(!1),F(!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),F0("div",{className:"flex items-center gap-2",children:[F0("div",{className:"flex items-center bg-bg-base rounded-md p-0.5",children:[F0("button",{onClick:()=>F(!1),className:`px-2.5 py-1 rounded text-[11px] font-body font-medium transition-colors ${!w?"bg-bg-elevated text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,children:"Preview"},void 0,!1,void 0,this),F0("button",{onClick:()=>F(!0),className:`px-2.5 py-1 rounded text-[11px] font-body font-medium transition-colors ${w?"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),F0("button",{onClick:J,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),w?F0("textarea",{ref:O,value:h,onChange:(v)=>{N(v.currentTarget.value),L(!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):F0("div",{className:"flex-1 overflow-y-auto p-5",children:F0(B$,{text:h},void 0,!1,void 0,this)},void 0,!1,void 0,this),A.length>0&&F0("div",{className:"px-5 py-2 border-t border-border-subtle flex-shrink-0",children:F0("span",{className:"text-[12px] text-text-secondary font-body",children:["Reviewer feedback: ",Q.size,"/",A.length," included"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),C&&F0("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:[F0("span",{children:C},void 0,!1,void 0,this),F0("button",{onClick:()=>{_(null),X(h)},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),F0("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-border-subtle flex-shrink-0",children:[F0("button",{onClick:J,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),F0("button",{onClick:()=>{let v=o1(H,G);if(v.length>0){_(`Please answer: ${v.join(", ")}`);return}_(null),X(h)},disabled:!g,className:`px-6 py-2 rounded-lg font-body text-[13px] font-medium transition-all ${g?"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 lJ=/!\[([^\]]*)\]\((\/tmp\/agent-canvas\/uploads\/([^)]+))\)/g;function dJ($){return $.replace(lJ,(J,X,Q,W)=>``)}function B$({text:$}){let J=K5(()=>s.parse(dJ($),{async:!1}),[$]);return F0("div",{className:"prose-canvas font-body text-body text-text-primary leading-relaxed",dangerouslySetInnerHTML:{__html:J}},void 0,!1,void 0,this)}import{jsxDEV as D,Fragment as N$}from"react/jsx-dev-runtime";function w$({onSubmit:$,collapseButton:J}){let{isReadOnly:X,selectedRevision:Q,currentRevision:W,revisions:Y,agentWatching:q}=S5($2),H=S5(iJ),G=Y.find((L)=>L.revision===Q),B=X&&Q===W,N=!!G?.feedbackConsumed,f=G?.label||`Round ${Q}`;if(X)return D(oJ,{sessionId:H,revision:Q,label:f,waitingForUpdate:B,feedbackConsumed:N,agentWatching:q,collapseButton:J},void 0,!1,void 0,this);return D(tJ,{onSubmit:$,agentWatching:q,collapseButton:J},void 0,!1,void 0,this)}function nJ({sessionId:$,revision:J,label:X,waitingForUpdate:Q,feedbackConsumed:W,agentWatching:Y,collapseButton:q}){let G=t0().isShared;return D("div",{className:"flex flex-col h-full",children:[D("div",{className:"px-4 py-3 flex items-center justify-between flex-shrink-0",children:[D("span",{className:"text-[11px] font-medium uppercase tracking-widest text-text-tertiary font-body",children:Q?"Feedback sent":`Feedback — ${X}`},void 0,!1,void 0,this),q]},void 0,!0,void 0,this),Q&&!G&&D(o4,{feedbackConsumed:W,agentWatching:Y},void 0,!1,void 0,this),D(s4,{sessionId:$,revision:J},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function o4({feedbackConsumed:$,agentWatching:J}){if($)return D("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:[D("span",{className:"w-2 h-2 rounded-full bg-accent-green animate-pulse"},void 0,!1,void 0,this),D("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(J)return D("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:[D("span",{className:"w-2 h-2 rounded-full bg-accent-blue animate-pulse"},void 0,!1,void 0,this),D("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 D("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:[D("span",{className:"w-2 h-2 rounded-full bg-accent-amber"},void 0,!1,void 0,this),D("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 oJ({sessionId:$,revision:J,label:X,waitingForUpdate:Q,feedbackConsumed:W,agentWatching:Y,collapseButton:q}){let{annotations:H,generalNote:G}=O1(),B=H.length>0||G.trim().length>0,[N,f]=X2("feedback");if(!B)return D(nJ,{sessionId:$,revision:J,label:X,waitingForUpdate:Q,feedbackConsumed:W,agentWatching:Y,collapseButton:q},void 0,!1,void 0,this);return D("div",{className:"flex flex-col h-full",children:[D("div",{className:"px-4 py-3 flex items-center justify-between flex-shrink-0",children:[D("div",{className:"flex items-center gap-1 bg-bg-input rounded-md p-0.5",children:[D("button",{onClick:()=>f("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),D("button",{onClick:()=>f("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",D("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:H.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),Q&&D(o4,{feedbackConsumed:W,agentWatching:Y},void 0,!1,void 0,this),N==="feedback"?D(s4,{sessionId:$,revision:J},void 0,!1,void 0,this):D(N$,{children:[D("div",{className:"flex-1 overflow-y-auto",children:D(t4,{annotations:H,readOnly:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this),G.trim()&&D("div",{className:"border-t border-border-subtle px-4 py-3 flex-shrink-0",children:D("div",{className:"text-[13px] font-body text-text-primary leading-relaxed",children:G},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 s4({sessionId:$,revision:J}){let X=t0(),[Q,W]=X2(null),[Y,q]=X2(!0);return n4(()=>{if(q(!0),!X.fsAvailable){W(null),q(!1);return}fetch(`/api/session/${$}/revision/${J}/feedback`).then((H)=>H.json()).then((H)=>{W(P4.parse(H).feedback||null),q(!1)}).catch(()=>{W(null),q(!1)})},[$,J]),D("div",{className:"flex-1 overflow-y-auto px-4",children:Y?D("p",{className:"text-[12px] text-text-tertiary font-body py-4",children:"Loading..."},void 0,!1,void 0,this):Q?D(B$,{text:Q},void 0,!1,void 0,this):D("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 sJ($){let J=$.filter((q)=>q.filePath===d1),X=$.filter((q)=>!q.filePath),Q=$.filter((q)=>L1(q)!==void 0),W={};for(let q of Q){let H=L1(q);if(!H)continue;let G=W[H];if(G)G.push(q);else W[H]=[q]}let Y=[J,X,Q].filter((q)=>q.length>0).length>1;return{response:J,plan:X,fileGroups:W,hasMultipleGroups:Y}}function r4({children:$}){return D("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 t4({annotations:$,readOnly:J,includedRemoteIds:X,onToggleRemoteId:Q}){let{setActiveView:W}=S5(e1),{response:Y,plan:q,fileGroups:H,hasMultipleGroups:G}=sJ($),B=O5((L)=>{let w=L1(L);if(!w)return;W({type:"file",path:w}),setTimeout(()=>{let F=C2(L);if(F)F.scrollIntoView({behavior:"smooth",block:"center"})},150)},[W]),N=O5((L)=>Y5(L,W),[W]),f={readOnly:J,onSelect:B,onReveal:N,includedRemoteIds:X,onToggleRemoteId:Q};return D(N$,{children:[Y.length>0&&D(N$,{children:[G&&D(r4,{children:"Agent Response"},void 0,!1,void 0,this),D(O2,{annotations:Y,...f},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.length>0&&D(N$,{children:[G&&D(r4,{children:"Canvas"},void 0,!1,void 0,this),D(O2,{annotations:q,...f},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Object.entries(H).map(([L,w])=>D("div",{children:[D("button",{onClick:()=>W({type:"file",path:L}),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:L,children:[D(G5,{name:L.split("/").pop()||L,type:"file"},void 0,!1,void 0,this),D("span",{className:"truncate",children:L},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D(O2,{annotations:w,...f},void 0,!1,void 0,this)]},L,!0,void 0,this))]},void 0,!0,void 0,this)}function tJ({onSubmit:$,agentWatching:J,collapseButton:X}){let Q=t0(),[W,Y]=X2(!1),{annotations:q,generalNote:H,submittableResponses:G,feedbackEntries:B}=O1(),N=rJ(()=>q.filter((A)=>A.source==="remote"),[q]),[f,L]=X2(()=>new Set);n4(()=>{if(N.length===0)return;L((A)=>{let Z=new Set(A);for(let h of N)Z.add(h.id);return Z.size===A.size?A:Z})},[N]);let w=O5((A)=>{L((Z)=>{let h=new Set(Z);if(h.has(A))h.delete(A);else h.add(A);return h})},[]),F=Array.from(G.values()).some(e2),C=B.size>0,_=q.length>0||H.trim().length>0||F||C,[O,S]=X2(null),M=()=>{let A=n1(q,H,G,B,f);$(A)};return D("div",{className:"flex flex-col h-full",children:[D("div",{className:"px-4 py-3 flex items-center justify-between flex-shrink-0",children:[D("span",{className:"text-[11px] font-medium uppercase tracking-widest text-text-tertiary font-body flex items-center gap-2",children:["Annotations",q.length>0&&D("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),!Q.isShared&&D("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${J?"bg-accent-green":"bg-accent-amber"}`,title:J?"Agent connected":"Agent disconnected"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X]},void 0,!0,void 0,this),D("div",{className:"flex-1 overflow-y-auto",children:[q.length===0&&D("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),D(t4,{annotations:q,includedRemoteIds:f,onToggleRemoteId:w},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D(l$,{hasContent:_,onSubmit:()=>{let A=o1(G,B);if(A.length>0){S(`Please answer: ${A.join(", ")}`);return}S(null),M()},onSubmitEmpty:()=>$("No feedback — looks good."),notice:O&&D("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:[D("span",{children:O},void 0,!1,void 0,this),D("button",{onClick:()=>{S(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:D("button",{onClick:()=>Y(!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),D(z5,{open:W,onClose:()=>Y(!1),onSubmit:$,includedRemoteIds:f,onToggleRemoteId:w},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useFeedback as nG}from"#canvas/runtime";import _q from"react";import{jsxDEV as zq}from"react/jsx-dev-runtime";s.setOptions({gfm:!0,breaks:!1});import{jsxDEV as Cq}from"react/jsx-dev-runtime";import{jsxDEV as Aq}from"react/jsx-dev-runtime";import{useAnnotations as Iq,useResponseRegistration as gq}from"#canvas/runtime";import{useEffect as Eq,useMemo as xq,useRef as hq,useState as vq}from"react";import{jsxDEV as Zq}from"react/jsx-dev-runtime";import{jsxDEV as uq}from"react/jsx-dev-runtime";import{useEffect as rq,useRef as nq}from"react";import{jsxDEV as tq}from"react/jsx-dev-runtime";import{jsxDEV as QY}from"react/jsx-dev-runtime";import{ActiveViewCtx as YY,SessionContext as GY}from"#canvas/runtime";import{useContext as UY,useEffect as BY,useRef as NY,useState as wY}from"react";import{jsxDEV as MY}from"react/jsx-dev-runtime";import{SessionContext as zY}from"#canvas/runtime";import{useContext as SY,useState as RY}from"react";import{jsxDEV as PY}from"react/jsx-dev-runtime";import{useMemo as TY}from"react";import{jsxDEV as bY}from"react/jsx-dev-runtime";s.setOptions({gfm:!0,breaks:!1});import{useAnnotations as yY,useCanvasFile as EY}from"#canvas/runtime";import{useCallback as mY,useEffect as cY,useRef as uY,useState as pY}from"react";import dY from"react-dom";import{jsxDEV as nY,Fragment as oY}from"react/jsx-dev-runtime";import{jsxDEV as eY}from"react/jsx-dev-runtime";import{jsxDEV as XG}from"react/jsx-dev-runtime";import{useState as YG}from"react";import{jsxDEV as UG}from"react/jsx-dev-runtime";import{jsxDEV as wG}from"react/jsx-dev-runtime";import{jsxDEV as MG}from"react/jsx-dev-runtime";import{useAnnotations as zG,useResponseRegistration as OG}from"#canvas/runtime";import{useRef as CG,useState as PG}from"react";import{jsxDEV as jG}from"react/jsx-dev-runtime";import{CanvasFileCtx as J9,SessionContext as X9}from"#canvas/runtime";import F$,{useContext as e4,useEffect as H1,useMemo as T2,useRef as Q9,useState as l0}from"react";import{createPortal as W9}from"react-dom";import{createContext as $9}from"react";var C5=$9(()=>{});import{jsxDEV as W0,Fragment as H9}from"react/jsx-dev-runtime";class $3 extends F$.Component{state={error:null};static getDerivedStateFromError($){return{error:$}}componentDidCatch($,J){this.props.reportError({revision:this.props.revision,filename:this.props.filename,message:$.message,...$.stack?{stack:$.stack}:{},...J.componentStack?{componentStack:J.componentStack}:{}})}render(){if(!this.state.error)return this.props.children;return W0(J3,{message:this.state.error.message},void 0,!1,void 0,this)}}function J3({message:$}){return W0("div",{className:"bg-accent-red-muted rounded-lg p-5",children:[W0("h3",{className:"font-body font-semibold text-accent-red mb-2",children:"Canvas render failed"},void 0,!1,void 0,this),W0("pre",{className:"text-code font-mono text-text-secondary whitespace-pre-wrap",children:$},void 0,!1,void 0,this),W0("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 f$({revision:$,filename:J}){let X=e4(X9),Q=t0(),W=e4(C5),[Y,q]=l0(null),[H,G]=l0(null),[B,N]=l0(!0),f=Q9(null),{annotations:L,addAnnotationWithId:w,removeAnnotation:F,updateAnnotation:C,addAnnotationImage:_,removeAnnotationImage:O,activeAnnotationId:S,setActiveAnnotationId:M,registerCanvasRendered:A}=O1(),Z=T2(()=>L.filter((K)=>!K.filePath&&(!K.canvasFile||K.canvasFile===J)),[L,J]),[h,g]=l0(null),[v,u]=l0(null),[m,e]=l0(null),[Q0,Y0]=l0(null),[K0,c]=l0(!1);H1(()=>{N(!0),G(null),Y0(null),Q.loadCanvasModule(J,$).then((K)=>{q(()=>K.default),N(!1)}).catch((K)=>{let j=K instanceof Error?K:Error(String(K));G(j.message),N(!1),W({revision:$,filename:J,message:j.message,...j.stack?{stack:j.stack}:{}})})},[X,$,J,W]),H1(()=>{if(Y)A(J)},[Y,J,A]);let $0=document.getElementById("plan-scroll-container"),{popovers:J0,isPopoverOpen:G0}=e$({containerRef:f,restoreKey:Y,restoreAnnotations:Z,extractContext:(K)=>T$(K,f.current),canvasFile:J,scrollContainer:$0}),{popovers:a,isDrawing:X0,isPopoverOpen:B0}=t$({containerRef:f,restoreKey:Y,canvasFile:J,scrollContainer:$0}),k=G0||B0,I=T2(()=>{let K=new Map;for(let j of Z)if(j.snippet.startsWith("["))K.set(j.snippet,j.id);return K},[Z]);H1(()=>{let K=f.current;if(!K)return;let j=(T)=>{if(m||k||X0)return;let E=T.target;if(E.closest("[data-block-comment-btn]"))return;c(!1);let d=E.closest(T1);if(d&&K.contains(d)){let j0=k1(K).indexOf(d);Y0(j0>=0?j0:null)}else Y0(null);let H0=E.closest(e0);if(H0&&K.contains(H0)){u(H0);let L0=v0(H0),j0=L0?I.get(L0):void 0;if(j0&&j0!==S)M(j0)}else u(null)},n=(T)=>{if(m||k)return;if(T.relatedTarget?.closest("[data-block-comment-btn]"))return;u(null),M(null)};return K.addEventListener("mousemove",j),K.addEventListener("mouseleave",n),()=>{K.removeEventListener("mousemove",j),K.removeEventListener("mouseleave",n)}},[Y,m,k,X0,I,S]),H1(()=>{let K=(j)=>{let n=j.target.tagName;if(n==="INPUT"||n==="TEXTAREA"||j.target.isContentEditable)return;if(m||k)return;let T=f.current;if(!T)return;if(j.key==="ArrowDown"){j.preventDefault(),c(!0);let E=k1(T);if(E.length===0)return;Y0((d)=>{if(d===null)return 0;return Math.min(d+1,E.length-1)})}else if(j.key==="ArrowUp"){j.preventDefault(),c(!0);let E=k1(T);if(E.length===0)return;Y0((d)=>{if(d===null)return E.length-1;return Math.max(d-1,0)})}else if(j.key==="a"||j.key==="A"){if(Q0===null||!T)return;let d=k1(T)[Q0];if(!d)return;if(!d.matches(e0))return;j.preventDefault();let H0=v0(d);if(!H0)return;let L0=I.get(H0);if(L0)M(L0),e({anchorEl:d,snippet:H0,annId:L0});else e({anchorEl:d,snippet:H0})}else if(j.key===" "||j.key==="Enter"){if(Q0===null)return;let d=k1(T)[Q0];if(!d)return;let H0=d.getAttribute("data-md");if(H0==="choice-option"||H0==="multichoice-option")j.preventDefault(),d.dispatchEvent(new CustomEvent("kb-select",{bubbles:!0}));else if(H0==="userinput"){j.preventDefault();let L0=d.querySelector("textarea");if(L0){L0.focus();let j0=(U1)=>{if(U1.key==="Escape")U1.preventDefault(),L0.blur(),c(!0)};L0.addEventListener("keydown",j0),L0.addEventListener("blur",()=>L0.removeEventListener("keydown",j0),{once:!0})}}else if(H0==="rangeinput"){j.preventDefault();let L0=d.querySelector("input[type='range']");if(L0){L0.focus();let j0=(U1)=>{if(U1.key==="Escape"||U1.key==="ArrowUp"||U1.key==="ArrowDown")U1.preventDefault(),L0.blur(),c(!0)};L0.addEventListener("keydown",j0),L0.addEventListener("blur",()=>L0.removeEventListener("keydown",j0),{once:!0})}}}else if(j.key==="Escape")Y0(null),c(!1),M(null)};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[Q0,m,k,I]),H1(()=>{let K=f.current;if(!K||Q0===null||!K0)return;let n=k1(K)[Q0];if(!n)return;n.style.outline="2px solid var(--color-accent-blue)",n.style.outlineOffset="-2px",n.style.borderRadius="8px",n.scrollIntoView({block:"nearest",behavior:"smooth"});let T=v0(n),E=T?I.get(T):void 0;if(E)M(E);return()=>{n.style.outline="",n.style.outlineOffset="",n.style.borderRadius=""}},[Q0,K0,I]);let l=T2(()=>Y?W0(Y,{},void 0,!1,void 0,this):null,[Y]);if(B)return W0("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(H)return W0(J3,{message:H},void 0,!1,void 0,this);if(!Y)return W0("div",{className:"text-text-tertiary text-center py-8 font-body text-body",children:"No canvas loaded"},void 0,!1,void 0,this);return W0(J9.Provider,{value:J,children:[W0("div",{ref:f,className:"plan-content plan-updated","data-canvas-file":J,children:W0($3,{revision:$,filename:J,reportError:W,children:l},`${$}:${J}`,!1,void 0,this)},void 0,!1,void 0,this),h&&W0(G9,{note:h.note,onSave:(K)=>{C(h.id,K),g(null)},onCancel:()=>g(null)},void 0,!1,void 0,this),J0,a,W0(q9,{containerRef:f,hoveredBlock:v,focusedBlockIndex:Q0,blockPopover:m,blockAnnotationMap:I,activeAnnotationId:S,onOpen:(K,j,n)=>{if(n)M(n),e({anchorEl:K,snippet:j,annId:n});else e({anchorEl:K,snippet:j})}},void 0,!1,void 0,this),m&&!m.annId&&W0(G1,{anchorEl:m.anchorEl,scrollContainer:$0,snippet:m.snippet,truncateAt:80,onAdd:(K,j)=>{let n=o0();w(n,m.snippet,K,void 0,void 0,j,J),e(null)},onCancel:()=>e(null)},void 0,!1,void 0,this),m?.annId&&(()=>{let K=Z.find((j)=>j.id===m.annId);if(!K)return null;return W0(R2,{anchorEl:m.anchorEl,scrollContainer:$0,initialNote:K.note,initialImages:K.images,onUpdate:(j,n)=>{C(m.annId,j);let T=K.images||[];for(let E of n)if(!T.includes(E))_(m.annId,E);for(let E of T)if(!n.includes(E))O(m.annId,E)},onDelete:()=>{F(m.annId),M(null),e(null)},onClose:()=>e(null)},void 0,!1,void 0,this)})()]},void 0,!0,void 0,this)}function k1($){return Array.from($.querySelectorAll(T1))}function q9({containerRef:$,hoveredBlock:J,focusedBlockIndex:X,blockPopover:Q,blockAnnotationMap:W,activeAnnotationId:Y,onOpen:q}){let[H,G]=l0([]);H1(()=>{let w=$.current;if(!w||W.size===0){G([]);return}let F=[];for(let C of w.querySelectorAll(e0)){let _=v0(C);if(_&&W.has(_))F.push(C)}G(F)},[W,$.current]);let[B,N]=l0(null);H1(()=>{if(!Y||!$.current){N(null);return}for(let w of $.current.querySelectorAll(T1)){let F=v0(w);if(F&&W.get(F)===Y){N(w);return}}N(null)},[Y,W]),H1(()=>{if(!B)return;return B.style.boxShadow="inset 0 0 0 1.5px var(--color-highlight-bg)",B.style.borderRadius="8px",()=>{B.style.boxShadow="",B.style.borderRadius=""}},[B]);let f=T2(()=>{if(X===null||!$.current)return null;let w=k1($.current)[X];if(!w)return null;return w.matches(e0)?w:null},[X,$.current]),L=T2(()=>{let w=new Set(H);if(J)w.add(J);if(f)w.add(f);if(Q?.anchorEl)w.add(Q.anchorEl);return Array.from(w)},[H,J,f,Q]);return W0(H9,{children:L.map((w)=>W0(Y9,{block:w,isHovered:w===J||w===f||w===Q?.anchorEl,blockAnnotationMap:W,activeAnnotationId:Y,onOpen:q},w.getAttribute("data-task-id")||w.getAttribute("data-md-title")||w.textContent?.slice(0,30)||"block",!1,void 0,this))},void 0,!1,void 0,this)}function Y9({block:$,isHovered:J,blockAnnotationMap:X,activeAnnotationId:Q,onOpen:W}){let Y=v0($);if(!Y)return null;let q=X.get(Y),H=!!q;return W9(W0("button",{"data-block-comment-btn":!0,onClick:(B)=>{B.stopPropagation(),W(B.currentTarget,Y,q)},className:`absolute top-1 right-1 z-10 w-6 h-6 flex items-center justify-center rounded transition-all duration-150 ${H?q===Q?"text-accent-amber bg-accent-amber-muted":"text-accent-amber opacity-60 hover:opacity-100":J?"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:H?"Edit annotation":"Add annotation",children:W0("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:H?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:W0("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 G9({note:$,onSave:J,onCancel:X}){let[Q,W]=F$.useState($),Y=F$.useRef(null);return F$.useEffect(()=>{Y.current?.focus(),Y.current?.select()},[]),W0("div",{className:"fixed inset-0 z-50 bg-black/40 flex items-center justify-center",onClick:X,children:W0("div",{className:"bg-bg-elevated border border-border-hover rounded-lg shadow-md p-4 w-80",onClick:(q)=>q.stopPropagation(),children:[W0("div",{className:"text-tiny uppercase tracking-widest text-text-tertiary font-body mb-2",children:"Edit annotation"},void 0,!1,void 0,this),W0("textarea",{ref:Y,value:Q,onChange:(q)=>W(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))J(Q.trim());if(q.key==="Escape")X()}},void 0,!1,void 0,this),W0("div",{className:"flex justify-end gap-2 mt-2",children:[W0("button",{onClick:X,className:"text-meta text-text-tertiary font-body px-3 py-1",children:"Cancel"},void 0,!1,void 0,this),W0("button",{onClick:()=>J(Q.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 C0,Fragment as k5}from"react/jsx-dev-runtime";function X3({gateName:$,hasGate:J,isCurrentGate:X,onSubmit:Q}){let[W,Y]=f9(!0);if(!W)return C0("button",{onClick:()=>Y(!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:C0("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=C0("button",{onClick:()=>Y(!1),className:"text-text-tertiary hover:text-text-secondary",title:"Collapse",children:C0("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:C0("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 C0("aside",{className:"flex h-full w-72 flex-col border-l border-border-subtle bg-bg-surface",children:J?C0(w$,{onSubmit:Q,collapseButton:q},void 0,!1,void 0,this):C0(k5,{children:[C0("div",{className:"flex items-center justify-between border-b border-border-subtle px-4 py-3",children:[C0("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),C0("div",{className:"flex-1 px-4 py-6 text-center text-tiny text-text-tertiary",children:X&&$?C0(k5,{children:["gate ",C0("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):$?C0(k5,{children:["this phase's ",C0("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 L9,useState as A5}from"react";import{jsxDEV as i}from"react/jsx-dev-runtime";var Q2="rounded border border-border-medium px-3 py-1 text-tiny disabled:opacity-40",Q3="rounded border border-border-medium bg-bg-base px-2 py-1 text-body text-text-primary";function W3({platform:$,live:J}){let[X,Q]=A5(""),[W,Y]=A5(null),[q,H]=A5(null),{data:G,enabled:B,busy:N,error:f}=$,L=G?.connection;L9(()=>{if(L)H(L.controlOrigin)},[L?.controlOrigin]);let w=G?.pairing,F=G?.deployment,C=F?.status==="preparing"||F?.status==="pending"||F?.status==="running",_=w?.status==="pending"||w?.status==="approved",O=G?.credential.available&&(G.credential.expiresAt===null||G.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:[!J&&i("p",{className:"text-text-tertiary",children:"Offline / demo mode — deployment controls are disabled."},void 0,!1,void 0,this),J&&!G&&!f&&i("p",{role:"status",children:"Loading project status…"},void 0,!1,void 0,this),f&&i("p",{role:"alert",className:"text-accent-red",children:f},void 0,!1,void 0,this),L?i("div",{className:"space-y-1",children:[i("p",{children:["App ",i("strong",{children:L.receipt.app.id},void 0,!1,void 0,this)," · ",L.receipt.provider," · ",L.receipt.environment.env]},void 0,!0,void 0,this),i("p",{className:"text-text-secondary",children:["Control: ",L.controlOrigin]},void 0,!0,void 0,this),i("p",{children:["Local credential: ",O?"available":"unavailable or expired",G?.credential.expiresAt!=null&&` · expires ${new Date(G.credential.expiresAt*1000).toLocaleString()}`]},void 0,!0,void 0,this),i("a",{className:"text-accent-blue underline",href:L.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),!L&&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:(S)=>{S.preventDefault(),$.act({kind:"connect",controlOrigin:X})},children:[i("label",{htmlFor:"control-origin",children:"Control origin"},void 0,!1,void 0,this),i("input",{className:Q3,id:"control-origin",type:"url",value:X,onChange:(S)=>Q(S.currentTarget.value),placeholder:"https://control.example.com",disabled:!B||!!L||_,required:!0},void 0,!1,void 0,this),i("button",{className:Q2,type:"submit",disabled:!B||!!L||_,children:N?"Working…":"Connect"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w?.status==="pending"&&B&&w.expiresAt*1000>Date.now()&&i("a",{className:"text-accent-blue underline",href:w.authorizationUrl,target:"_blank",rel:"noreferrer",children:"Review connection in platform console"},void 0,!1,void 0,this),w&&i("p",{role:"status",children:["Connection: ",w.status,(w.status==="failed"||w.status==="recovery_required")&&` — ${w.message}`]},void 0,!0,void 0,this),i("div",{className:"flex flex-wrap items-center gap-2",children:[i("button",{className:Q2,type:"button",disabled:!B||!L&&!w,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:Q2,type:"button",disabled:!B||!L||!O||C||_,onClick:()=>void $.act({kind:"deploy"}),children:C?"Deploy in progress…":"Deploy pushed commit"},void 0,!1,void 0,this),i("button",{className:Q2,type:"button",disabled:!J||N,onClick:$.refresh,children:"Refresh status"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F&&i("div",{role:"status",className:"space-y-1",children:[i("p",{children:["Deployment: ",i("strong",{children:F.status},void 0,!1,void 0,this),F.message&&` — ${F.message}`]},void 0,!0,void 0,this),F.runId&&i("p",{children:["Run: ",i("code",{children:F.runId},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F.commitSha&&i("p",{children:["Commit: ",i("code",{children:F.commitSha},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F.consoleUrl&&i("a",{className:"mr-4 text-accent-blue underline",href:F.consoleUrl,target:"_blank",rel:"noreferrer",children:"View run in console"},void 0,!1,void 0,this),F.appUrl&&i("a",{className:"text-accent-blue underline",href:F.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:(S)=>{S.preventDefault(),$.act({kind:"preview",url:W??G?.previewUrl??""})},children:[i("label",{htmlFor:"preview-url",children:"Local preview URL"},void 0,!1,void 0,this),i("input",{className:Q3,id:"preview-url",type:"url",value:W??G?.previewUrl??"",onChange:(S)=>Y(S.currentTarget.value),placeholder:G?.previewUrl??"http://localhost:3000",disabled:!B,required:!0},void 0,!1,void 0,this),i("button",{className:Q2,type:"submit",disabled:!B,children:"Set preview"},void 0,!1,void 0,this),i("button",{className:Q2,type:"button",disabled:!B||!G?.previewUrl,onClick:()=>{Y(null),$.act({kind:"preview",url:null})},children:"Clear preview"},void 0,!1,void 0,this),i("span",{className:"text-tiny text-text-tertiary",children:[G?.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 a0}from"react/jsx-dev-runtime";var M9={connecting:"connecting…",live:"live",offline:"offline",fixture:"fixture"},_9={connecting:"bg-accent-amber",live:"bg-accent-green",offline:"bg-accent-red",fixture:"bg-accent-blue"};function q3({sessionId:$,status:J,watching:X}){return a0("header",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border-subtle bg-bg-surface px-4",children:[a0("div",{className:"flex items-center gap-2 text-body text-text-secondary",children:[a0("span",{className:"text-text-tertiary",children:"session"},void 0,!1,void 0,this),a0("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),a0("div",{className:"flex items-center gap-4",children:[X&&a0("span",{className:"flex items-center gap-1.5 text-tiny text-text-tertiary",children:[a0("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),a0("span",{className:"flex items-center gap-1.5 text-tiny text-text-secondary",children:[a0("span",{className:`inline-flex h-2 w-2 rounded-full ${_9[J]}`},void 0,!1,void 0,this),M9[J]]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var L$=["intake","vision","flows","tech","design","skeletons","issues","build"],K9={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"]}},M$=L$.map(($,J)=>({id:$,number:J+1,...K9[$]})),_$=M$.length;function z9($){return L$.indexOf($)}function Y3($){let J=M$[z9($)];if(!J)throw Error(`Unknown phase id: ${$}`);return J}function Z2($,J,X){if(J.includes($))return"done";if($===X)return"current";return"upcoming"}import{jsxDEV as U0}from"react/jsx-dev-runtime";function O9({status:$}){if($==="done")return U0("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-accent-green-muted text-accent-green",children:U0("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:U0("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 U0("span",{className:"relative flex h-5 w-5 items-center justify-center",children:[U0("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-accent-amber opacity-40"},void 0,!1,void 0,this),U0("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 U0("span",{className:"flex h-5 w-5 items-center justify-center rounded-full border border-border-medium"},void 0,!1,void 0,this)}function G3({state:$,focused:J,onFocus:X}){return U0("nav",{className:"flex h-full flex-col border-r border-border-subtle bg-bg-surface",children:[U0("div",{className:"border-b border-border-subtle px-4 py-3",children:[U0("div",{className:"font-heading text-xl text-text-primary",children:"fabrika"},void 0,!1,void 0,this),U0("div",{className:"text-tiny uppercase tracking-wide text-text-tertiary",children:"guided app build"},void 0,!1,void 0,this),U0("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),U0("ol",{className:"flex-1 overflow-y-auto py-2",children:M$.map((Q)=>{let W=Z2(Q.id,$.completed,$.current),Y=J===Q.id,q=W!=="upcoming";return U0("li",{children:U0("button",{disabled:!q,onClick:()=>q&&X(Q.id),className:["group flex w-full items-start gap-3 px-4 py-2.5 text-left transition-colors",Y?"bg-bg-elevated":"hover:bg-bg-elevated-half",q?"cursor-pointer":"cursor-not-allowed opacity-55"].join(" "),children:[U0("div",{className:"mt-0.5 shrink-0",children:U0(O9,{status:W},void 0,!1,void 0,this)},void 0,!1,void 0,this),U0("div",{className:"min-w-0",children:[U0("div",{className:"flex items-center gap-1.5",children:[U0("span",{className:"text-tiny tabular-nums text-text-tertiary",children:[Q.number,"/",_$]},void 0,!0,void 0,this),Q.gate&&U0("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),U0("div",{className:["truncate text-task-label",W==="current"?"font-semibold text-text-primary":W==="done"?"text-text-secondary":"text-text-tertiary"].join(" "),children:Q.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},Q.id,!1,void 0,this)})},void 0,!1,void 0,this),U0("div",{className:"border-t border-border-subtle px-4 py-2 text-tiny text-text-tertiary",children:["phase derived from ",U0("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 B7,useState as I3}from"react";var qU=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",DATA_READ:"data.read",DATA_CONTENT_READ:"data.content.read",DATA_MANAGE:"data.manage"}),YU=Object.freeze({APP:"app",ENVIRONMENT:"environment"});function S9($){if(typeof $!=="string"||$.length>2048)return null;try{let J=new URL($),X=J.hostname==="localhost"||J.hostname.endsWith(".localhost")||J.hostname==="[::1]"||/^127(?:\.[0-9]{1,3}){3}$/.test(J.hostname);if(J.protocol!=="https:"&&!(J.protocol==="http:"&&X))return null;if(J.username!==""||J.password!==""||J.pathname!=="/"||J.search!==""||J.hash!=="")return null;return J.origin}catch{return null}}var H3=U.string().transform(($,J)=>{let X=S9($);if(X!==null)return X;return J.addIssue({code:"custom",message:"invalid builder public origin"}),U.NEVER}),UU=U.preprocess(($)=>{if(typeof $==="object"&&$!==null&&Object.keys($).length!==4)return;return $},U.object({version:U.literal(1),controlOrigin:H3,iamIssuer:H3,provider:U.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/)}).strict());var R9=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;var C9=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;var j5=U.number().int().safe().nonnegative(),V5=U.string().regex(C9),P9=U.object({id:V5,repoUrl:U.string(),defaultBranch:U.string(),workerDir:U.string().nullable(),buildCmd:U.string().nullable(),configPath:U.string().nullable(),githubConnectionId:U.string().nullable().optional(),githubInstallationId:j5.nullable(),createdAt:j5}).strict().transform(({githubConnectionId:$,githubInstallationId:J,createdAt:X,...Q})=>({...Q,...$===void 0?{}:{githubConnectionId:$},githubInstallationId:J,createdAt:X})),k9=U.object({env:V5,namespaceId:U.string().min(1).max(128).nullable(),domain:U.string().min(1).max(253).nullable(),publicOrigin:U.string().min(1).max(2048).nullable(),triggerRef:U.string().min(1).max(1024).nullable()}).strict(),U3=U.object({version:U.literal(1),attemptId:U.string().regex(R9),provider:V5,app:P9,environment:k9,createdAt:j5}).strict();var A9=100,j9=512,fU=U.object({cursor:U.string().min(1).max(j9).optional(),limit:U.number().int().safe().min(1).max(A9).optional()}).strict().transform(({cursor:$,limit:J})=>({...$===void 0?{}:{cursor:$},...J===void 0?{}:{limit:J}}));var K$="FABRIKA_IAM_APP_ID";var V9=/%2f|%5c/i,T9=/%2e/gi;function T5($){if($==="/")return!0;if(!$.startsWith("/")||$.includes("\\")||V9.test($))return!1;let J=$.slice(1).split("/"),X=J.length-1;return J.every((Q,W)=>(Q!==""||W===X)&&!b9(Q)&&Z9(Q))}function Z9($){try{return decodeURIComponent($),!0}catch{return!1}}function b9($){let J=$.replace(T9,".");return J==="."||J===".."}var D9=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),I9=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function d0($,J){return $>>>J|$<<32-J}function W2($){let J=new TextEncoder().encode($),X=new Uint8Array(Math.ceil((J.length+9)/64)*64);X.set(J),X[J.length]=128;let Q=new DataView(X.buffer),W=J.length*8;Q.setUint32(X.length-8,Math.floor(W/4294967296)),Q.setUint32(X.length-4,W>>>0);let Y=new Uint32Array(I9),q=new Uint32Array(64);for(let H=0;H<X.length;H+=64){for(let O=0;O<16;O++)q[O]=Q.getUint32(H+O*4);for(let O=16;O<64;O++){let S=q[O-15]??0,M=q[O-2]??0,A=d0(S,7)^d0(S,18)^S>>>3,Z=d0(M,17)^d0(M,19)^M>>>10;q[O]=(q[O-16]??0)+A+(q[O-7]??0)+Z}let[G=0,B=0,N=0,f=0,L=0,w=0,F=0,C=0]=Y;for(let O=0;O<64;O++){let S=d0(L,6)^d0(L,11)^d0(L,25),M=L&w^~L&F,A=C+S+M+(D9[O]??0)+(q[O]??0)>>>0,Z=d0(G,2)^d0(G,13)^d0(G,22),h=G&B^G&N^B&N,g=Z+h>>>0;C=F,F=w,w=L,L=f+A>>>0,f=N,N=B,B=G,G=A+g>>>0}let _=[G,B,N,f,L,w,F,C];for(let[O,S]of _.entries())Y[O]=(Y[O]??0)+S}return Array.from(Y,(H)=>H.toString(16).padStart(8,"0")).join("")}var Z5="FABRIKA_CONTRACT_DIGEST";var N3="*";class g9{#$;#J;constructor($,J){this.#$=$,this.#J=J}plan($,J){return y9(this.#$,this.#J,$,J)}}function y9($,J,X,Q){if(!T5(Q))return{outcome:"non-canonical"};let W=x9(Q),Y=h9(Q,J),q=null,H=!1;for(let G of $){if(!E9(G.row.method,X)||Y!==null&&!F3(G.row.path,Y))continue;let B=v9(G.segments,W);if(B===null)continue;let N=q===null?-1:m9(G.segments,q.endpoint.segments);if(N<0)q={endpoint:G,params:B},H=!1;else if(N===0)H=!0}if(q===null||H)return{outcome:"no-endpoint"};return{outcome:"endpoint",endpoint:q.endpoint.row,params:q.params}}function E9($,J){return $===N3||$===J}function x9($){return $==="/"?[]:$.slice(1).split("/")}function F3($,J){return $.startsWith(`${J}/`)}function h9($,J){let X=null;for(let Q of J)if(F3($,Q)&&(X===null||Q.length>X.length))X=Q;return X}function v9($,J){let X=[];for(let[Q,W]of $.entries()){if(W.kind==="wildcard")return Q===0||J.length>Q?Object.fromEntries(X):null;let Y=J[Q];if(Y===void 0)return null;if(W.kind==="param"){if(Y==="")return null;X.push([W.name,Y])}else if(W.value!==Y)return null}return $.length===J.length?Object.fromEntries(X):null}var w3={literal:0,param:1,wildcard:2};function m9($,J){let X=Math.min($.length,J.length);for(let Q=0;Q<X;Q++){let W=$[Q],Y=J[Q];if(W===void 0||Y===void 0)break;let q=w3[W.kind]-w3[Y.kind];if(q!==0)return q}return $.length-J.length}var z$="FABRIKA_IAM_ISSUER";var O$="FABRIKA_PROXY_SECRET";var c9="FABRIKA_SOURCE_MAP_UPLOAD",u9="FABRIKA_SOURCE_MAP_UPLOAD_KEY",b5="FABRIKA_TOKEN_KEYS",D5="FABRIKA_APP_ORIGIN",I5="FABRIKA_OPS_KEY_DIGESTS",p9="FABRIKA_APPLICATION_OBJECT",l9="FABRIKA_APPLICATION_OBJECTS",d9=["FABRIKA_RELEASE",Z5,z$,K$,"FABRIKA_OPERATIONS_DSN","FABRIKA_APP_ID","FABRIKA_ENVIRONMENT","FABRIKA_SERVICE_KEY","FABRIKA_APP_DATABASE_URL","FABRIKA_APP_RUNTIME_DATABASE_URL","FABRIKA_APP_DATABASE_CONNECTIONS","FABRIKA_APP_STORAGE_ENDPOINT","FABRIKA_APP_STORAGE_BUCKET","FABRIKA_APP_STORAGE_ACCESS_KEY_ID","FABRIKA_APP_STORAGE_SECRET_ACCESS_KEY","FABRIKA_STORAGE_PROVENANCE",O$,"FABRIKA_IAM_RPC_URL","FABRIKA_IAM_RPC_KEY",c9,u9,b5,D5,I5,p9,l9];var nU=new Set(d9);function i9($){return $.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()}var g5=["mail","source"];function y5($){let J=`FABRIKA_PLATFORM_${i9($)}`;return{url:`${J}_URL`,key:`${J}_KEY`}}var oU=new Set(g5.flatMap(($)=>Object.values(y5($))));var r9=["FABRIKA_RELEASE","FABRIKA_OPERATIONS_DSN",z$,K$,"FABRIKA_APP_ID","FABRIKA_ENVIRONMENT","FABRIKA_SERVICE_KEY",O$,"FABRIKA_IAM_RPC_URL","FABRIKA_IAM_RPC_KEY",D5,b5,I5],BB=new Set(r9);var NB=new Set(g5.map(($)=>y5($).url));var n9="/__fabrika/ops/";var PB=`${n9}*`;var kB=W2("");var AB=-(2n**63n),jB=2n**63n-1n;var o9="__Host-px_",JN=`${o9}session`;var f3=100,V0=U.string().min(1),s9=U.enum(["open","read-only","closed","inspect"]),t9=U.object({appId:V0,env:V0,before:V0.optional(),limit:U.number().int().min(1).max(f3).optional()}).strict(),a9=U.discriminatedUnion("kind",[U.object({appId:V0,env:V0,kind:U.literal("maintenance"),mode:s9}).strict(),U.object({appId:V0,env:V0,kind:U.literal("backup")}).strict(),U.object({appId:V0,env:V0,kind:U.literal("restore"),at:U.string().datetime({offset:!0})}).strict()]),e9=U.object({appId:V0,env:V0,operationId:V0,resolution:U.enum(["resume","open"])}).strict();var cN=U.object({ts:U.number().finite(),stream:U.enum(["stdout","stderr","meta"]),text:U.string()});function L3($,J){if(typeof $!=="string"||$.length===0||$.trim()!==$||[...$].some((Q)=>Q.charCodeAt(0)<=32||Q.charCodeAt(0)===127||Q==="\\"))throw Error(`${J} must be an HTTP(S) URL`);let X;try{X=new URL($)}catch{throw Error(`${J} must be an HTTP(S) URL`)}if(!/^https?:\/\//i.test($)||X.protocol!=="https:"&&X.protocol!=="http:"||X.username||X.password||/^https?:\/\/[^/?#]*@/i.test($))throw Error(`${J} must be an HTTP(S) URL without credentials`);return X}function q2($,J="origin"){let X=L3($,J);if(typeof $!=="string"||!/^https?:\/\/[^/?#]+\/?$/i.test($)||X.pathname!=="/"||X.search||X.hash)throw Error(`${J} must be an origin without a path, query, or fragment`);let Q=X.hostname==="localhost"||X.hostname==="127.0.0.1"||X.hostname==="[::1]"||X.hostname.endsWith(".localhost"),W=$.slice($.indexOf("://")+3).replace(/\/$/,"").toLowerCase(),Y=X.hostname!=="127.0.0.1"||/^127\.0\.0\.1(?::\d+)?$/.test(W);if(X.protocol!=="https:"&&(!Q||!Y))throw Error(`${J} must use HTTPS except on localhost`);return X.origin}function b2($){return L3($,"preview URL").href}var k0=U.union([U.number(),U.nan()]),f0=U.string().optional().catch(void 0),M3=U.enum(L$),$7=U.object({current:M3,index:k0,completed:U.array(M3),reads:U.array(U.string()),produces:U.array(U.string()),gate:U.boolean(),satisfied:U.boolean()}),_3=$7.extend({gateName:U.string().nullable().optional().catch(void 0)}).transform(({gateName:$,...J})=>({...J,...$===void 0?{}:{gateName:$}})),qw=U.object({ok:U.literal(!0),version:f0,pid:k0.optional().catch(void 0),dataDir:f0,sessionsDir:U.string(),sessions:U.union([k0,U.array(U.string())]).optional().catch(void 0)}).transform(({ok:$,version:J,pid:X,dataDir:Q,sessionsDir:W,sessions:Y})=>({ok:$,...J===void 0?{}:{version:J},...X===void 0?{}:{pid:X},...Q===void 0?{}:{dataDir:Q},sessionsDir:W,...Y===void 0?{}:{sessions:Y}})),K3=U.object({ok:U.literal(!0),version:f0,sessions:U.array(U.string()).optional().catch(void 0)}).transform(({ok:$,version:J,sessions:X})=>({ok:$,...J===void 0?{}:{version:J},...X===void 0?{}:{sessions:X}})),Yw=U.object({ok:U.literal(!0),sessionsDir:U.string()}),z3=U.object({error:U.object({code:U.literal("builder_platform"),message:U.string().max(1000)})}),Gw=U.object({ok:U.boolean(),browserUrl:f0,revision:k0.optional().catch(void 0),isNew:U.boolean().optional().catch(void 0),canvasFiles:U.array(U.string()).optional().catch(void 0),gate:f0,error:f0,errors:U.record(U.string()).optional().catch(void 0)}).transform(({ok:$,browserUrl:J,revision:X,isNew:Q,canvasFiles:W,gate:Y,error:q,errors:H})=>({ok:$,...J===void 0?{}:{browserUrl:J},...X===void 0?{}:{revision:X},...Q===void 0?{}:{isNew:Q},...W===void 0?{}:{canvasFiles:W},...Y===void 0?{}:{gate:Y},...q===void 0?{}:{error:q},...H===void 0?{}:{errors:H}})),O3=U.object({status:U.enum(["queued","running","passed","failed","blocked","info"]),issue:f0,message:f0,at:f0,data:U.record(U.unknown()).optional().catch(void 0)}).transform(({status:$,issue:J,message:X,at:Q,data:W})=>({status:$,...J===void 0?{}:{issue:J},...X===void 0?{}:{message:X},...Q===void 0?{}:{at:Q},...W===void 0?{}:{data:W}})),Hw=U.object({view:f0,directory:f0,projectRoot:f0,gate:f0,label:f0,response:f0}),S3=U.object({feedback:U.string().catch("")}),Uw=S3.extend({found:U.literal(!0)}),Bw=S3.extend({type:U.literal("submit")}),R3=U.object({revision:k0,hasFeedback:U.unknown().transform(($)=>$===!0),feedbackConsumed:U.unknown().transform(($)=>$===!0)}),Nw=U.object({revisions:U.array(R3.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null))}),J7=U.union([U.string().transform(($)=>({filename:$})),U.object({filename:U.string(),label:f0,diffStats:U.object({added:k0,removed:k0}).optional().catch(void 0)}).transform(({filename:$,label:J,diffStats:X})=>({filename:$,...J===void 0?{}:{label:J},...X===void 0?{}:{diffStats:X}}))]).refine(($)=>$.filename.length>0),S$=U.array(J7.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null)).catch([]),X7=U.discriminatedUnion("kind",[U.object({kind:U.literal("directory")}),U.object({kind:U.literal("view"),filename:U.string()})]),Q7=R3.extend({label:U.string().nullable().catch(null),canvasFiles:S$,createdAt:f0,canvasScope:X7.optional().catch(void 0)}).transform(({createdAt:$,canvasScope:J,...X})=>({...X,...$===void 0?{}:{createdAt:$},...J===void 0?{}:{canvasScope:J}})).refine(($)=>$.revision>0),C3=U.object({projectRoot:f0,label:f0,gate:U.string().nullable().catch(null),currentRevision:k0.catch(0),canvasFiles:S$,revisions:U.array(Q7.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null)).catch([])}).transform(({projectRoot:$,label:J,...X})=>({...X,...$===void 0?{}:{projectRoot:$},...J===void 0?{}:{label:J}})),W7=U.object({id:U.string(),label:f0}).transform(({id:$,label:J})=>({id:$,...J===void 0?{}:{label:J}})),P3=U.array(W7.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null)).catch([]),q7=U.object({file:U.string(),name:U.string(),seeds:U.array(U.string()),roles:U.array(U.string()),steps:k0,invariants:k0,pending:k0,url:f0,feature:f0}).transform(({url:$,feature:J,...X})=>({...X,...$===void 0?{}:{url:$},...J===void 0?{}:{feature:J}})),k3=U.object({skeletons:U.array(q7.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null))}),A3=U.object({content:U.string()}),j3=U.object({responses:U.unknown()}),V3=U.discriminatedUnion("type",[U.object({type:U.literal("plan-updated"),currentRevision:k0,canvasFiles:U.array(U.unknown()).transform(($)=>S$.parse($)).optional().catch(void 0),gate:U.string().nullable().optional().catch(void 0)}),U.object({type:U.literal("revision-updated"),currentRevision:k0}),U.object({type:U.literal("watcher-status"),watching:U.boolean()}),U.object({type:U.literal("phase-updated")}),U.object({type:U.literal("submit-ack"),revision:k0})]).transform(($)=>{if($.type!=="plan-updated")return $;let{canvasFiles:J,gate:X,...Q}=$;return{...Q,...J===void 0?{}:{canvasFiles:J},...X===void 0?{}:{gate:X}}}),T0=U.string().refine(($)=>$.trim().length>0),T3=U.number().finite().nonnegative(),E5=U.string().transform(($,J)=>{try{return q2($)}catch{return J.addIssue({code:U.ZodIssueCode.custom,message:"Invalid builder origin"}),U.NEVER}}),Y2=U.string().transform(($,J)=>{try{return b2($)}catch{return J.addIssue({code:U.ZodIssueCode.custom,message:"Invalid preview URL"}),U.NEVER}}),Z3=U.object({controlOrigin:E5,iamIssuer:E5,receipt:U3}).strict(),ww=U.object({profile:T0,sessionId:T0,createdAt:T0.refine(($)=>Number.isFinite(Date.parse($))),connection:Z3.optional(),previewUrl:Y2.optional()}).strict().superRefine(($,J)=>{for(let X of["connection","previewUrl"])if(Object.hasOwn($,X)&&Reflect.get($,X)===void 0)J.addIssue({code:U.ZodIssueCode.custom,path:[X],message:"Present field must not be undefined"})}),Y7=U.discriminatedUnion("status",[U.object({status:U.literal("pending"),authorizationUrl:Y2.refine(($)=>{try{return q2(new URL($).origin),!0}catch{return!1}}),expiresAt:T3}).strict(),U.object({status:U.literal("approved")}).strict(),U.object({status:U.literal("failed"),message:T0}).strict(),U.object({status:U.literal("expired")}).strict(),U.object({status:U.literal("cancelled")}).strict(),U.object({status:U.literal("recovery_required"),message:T0}).strict(),U.object({status:U.literal("connected")}).strict()]),G7=U.object({status:U.enum(["preparing","pending","running","awaiting_approval","succeeded","failed","cancelled"]),runId:T0.nullable(),commitSha:T0.nullable(),message:T0.nullable(),appUrl:Y2.nullable(),consoleUrl:Y2.nullable()}).strict(),H7=U.object({sessionId:T0,projectRoot:T0,connection:Z3.nullable(),credential:U.object({available:U.boolean(),expiresAt:T3.nullable()}).strict(),pairing:Y7.nullable(),previewUrl:Y2.nullable(),deployment:G7.nullable()}).strict(),Fw=U.object({projectRoot:T0}).strict(),fw=U.object({controlOrigin:E5}).strict(),Lw=U.object({url:Y2.nullable()}).strict();function b3($){let J=H7.safeParse($);if(!J.success)throw Error("Invalid platform status");return J.data}function D3($,J){let X=T0.safeParse($);if(!X.success)throw Error("project id must be a non-empty string");return`/api/project/${encodeURIComponent(X.data)}/${J}`}function A1(){return location.origin}function R$(){return location.pathname.match(/\/s\/([^/]+)/)?.[1]??null}function U7(){return new URLSearchParams(location.search).get("root")}async function G2($){let J=await fetch(A1()+$,{headers:{accept:"application/json"}});if(!J.ok)throw Error(`${$} -> ${J.status}`);return J.json()}var S0={async health(){let $=K3.safeParse(await G2("/health"));if(!$.success)throw Error("Invalid health response");return $.data},async phase($){let J=$??U7(),X=R$(),Q=new URLSearchParams;if(J)Q.set("root",J);if(X)Q.set("session",X);let W=Q.toString(),Y=_3.safeParse(await G2(`/api/phase${W?`?${W}`:""}`));if(!Y.success)throw Error("Invalid phase response");return Y.data},async meta($){let J=C3.safeParse(await G2(`/api/session/${encodeURIComponent($)}/meta`));if(!J.success)throw Error("Invalid session response");return{id:$,...J.data}},async artifact($,J){try{let X=await fetch(`${A1()}/api/session/${encodeURIComponent($)}/artifact?path=${encodeURIComponent(J)}`,{headers:{accept:"application/json"}});if(!X.ok)return null;let Q=A3.safeParse(await X.json());return Q.success?Q.data.content:null}catch{return null}},async sessions(){return P3.parse(await G2("/api/sessions"))},canvasUrl($,J,X){let Q=X!=null?`?rev=${X}`:"";return`${A1()}/api/session/${encodeURIComponent($)}/canvas/${encodeURIComponent(J)}${Q}`},async skeletons($){let J=k3.safeParse(await G2(`/api/session/${encodeURIComponent($)}/skeletons`));return J.success?J.data.skeletons:[]},async feedback($,J){let X=await fetch(`${A1()}/api/session/${encodeURIComponent($)}/revision/${J}/feedback`);if(!X.ok)throw Error(`feedback -> ${X.status}`);return X.text()},async getResponses($,J,X){try{let Q=j3.safeParse(await G2(`/api/session/${encodeURIComponent($)}/revision/${J}/responses`));return Q.success?X(Q.data.responses):null}catch{return null}},async saveResponses($,J,X){try{await fetch(`${A1()}/api/session/${encodeURIComponent($)}/revision/${J}/responses`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(X)})}catch{}},openSocket($,J){let X=location.protocol==="https:"?"wss:":"ws:",Q=A1().replace(/^https?:/,X),W=new WebSocket(`${Q}/ws/session/${encodeURIComponent($)}`);return W.onmessage=(Y)=>{try{let q=V3.safeParse(JSON.parse(String(Y.data)));if(q.success)J(q.data)}catch{}},W},submitGate($,J){if($.readyState===WebSocket.OPEN)return $.send(JSON.stringify({type:"submit",feedback:J})),!0;return!1},buildStream($){try{let J=new EventSource(`${A1()}/api/build/stream`);return J.onmessage=(X)=>{try{let Q=O3.safeParse(JSON.parse(X.data));if(Q.success)$(Q.data)}catch{}},J}catch{return null}}};import{jsxDEV as q0,Fragment as C$}from"react/jsx-dev-runtime";var N7=".fabrika/architecture/design.md",w7=".fabrika/pages/_preview.html",x5=`:root{
|
|
68
|
+
`}strong({tokens:$}){return`<strong>${this.parser.parseInline($)}</strong>`}em({tokens:$}){return`<em>${this.parser.parseInline($)}</em>`}codespan({text:$}){return`<code>${p0($,!0)}</code>`}br($){return"<br>"}del({tokens:$}){return`<del>${this.parser.parseInline($)}</del>`}link({href:$,title:J,tokens:X}){let Q=this.parser.parseInline(X),W=g4($);if(W===null)return Q;$=W;let q='<a href="'+$+'"';return J&&(q+=' title="'+p0(J)+'"'),q+=">"+Q+"</a>",q}image({href:$,title:J,text:X,tokens:Q}){Q&&(X=this.parser.parseInline(Q,this.parser.textRenderer));let W=g4($);if(W===null)return p0(X);$=W;let q=`<img src="${$}" alt="${p0(X)}"`;return J&&(q+=` title="${p0(J)}"`),q+=">",q}text($){return"tokens"in $&&$.tokens?this.parser.parseInline($.tokens):("escaped"in $)&&$.escaped?$.text:p0($.text)}},_5=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 $}},E0=class ${options;renderer;textRenderer;constructor(J){this.options=J||P1,this.options.renderer=this.options.renderer||new G$,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new _5}static parse(J,X){return new $(X).parse(J)}static parseInline(J,X){return new $(X).parseInline(J)}parse(J){this.renderer.parser=this;let X="";for(let Q=0;Q<J.length;Q++){let W=J[Q];if(this.options.extensions?.renderers?.[W.type]){let Y=W,H=this.options.extensions.renderers[Y.type].call({parser:this},Y);if(H!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(Y.type)){X+=H||"";continue}}let q=W;switch(q.type){case"space":{X+=this.renderer.space(q);break}case"hr":{X+=this.renderer.hr(q);break}case"heading":{X+=this.renderer.heading(q);break}case"code":{X+=this.renderer.code(q);break}case"table":{X+=this.renderer.table(q);break}case"blockquote":{X+=this.renderer.blockquote(q);break}case"list":{X+=this.renderer.list(q);break}case"checkbox":{X+=this.renderer.checkbox(q);break}case"html":{X+=this.renderer.html(q);break}case"def":{X+=this.renderer.def(q);break}case"paragraph":{X+=this.renderer.paragraph(q);break}case"text":{X+=this.renderer.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}parseInline(J,X=this.renderer){this.renderer.parser=this;let Q="";for(let W=0;W<J.length;W++){let q=J[W];if(this.options.extensions?.renderers?.[q.type]){let H=this.options.extensions.renderers[q.type].call({parser:this},q);if(H!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(q.type)){Q+=H||"";continue}}let Y=q;switch(Y.type){case"escape":{Q+=X.text(Y);break}case"html":{Q+=X.html(Y);break}case"link":{Q+=X.link(Y);break}case"image":{Q+=X.image(Y);break}case"checkbox":{Q+=X.checkbox(Y);break}case"strong":{Q+=X.strong(Y);break}case"em":{Q+=X.em(Y);break}case"codespan":{Q+=X.codespan(Y);break}case"br":{Q+=X.br(Y);break}case"del":{Q+=X.del(Y);break}case"text":{Q+=X.text(Y);break}default:{let H='Token with "'+Y.type+'" type was not found.';if(this.options.silent)return console.error(H),"";throw Error(H)}}}return Q}},A2=class{options;block;constructor($){this.options=$||P1}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 $?y0.lex:y0.lexInline}provideParser($=this.block){return $?E0.parse:E0.parseInline}},uJ=class{defaults=U5();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=E0;Renderer=G$;TextRenderer=_5;Lexer=y0;Tokenizer=q$;Hooks=A2;constructor(...$){this.use(...$)}walkTokens($,J){let X=[];for(let Q of $)switch(X=X.concat(J.call(this,Q)),Q.type){case"table":{let W=Q;for(let q of W.header)X=X.concat(this.walkTokens(q.tokens,J));for(let q of W.rows)for(let Y of q)X=X.concat(this.walkTokens(Y.tokens,J));break}case"list":{let W=Q;X=X.concat(this.walkTokens(W.items,J));break}default:{let W=Q;this.defaults.extensions?.childTokens?.[W.type]?this.defaults.extensions.childTokens[W.type].forEach((q)=>{let Y=W[q].flat(1/0);X=X.concat(this.walkTokens(Y,J))}):W.tokens&&(X=X.concat(this.walkTokens(W.tokens,J)))}}return X}use(...$){let J=this.defaults.extensions||{renderers:{},childTokens:{}};return $.forEach((X)=>{let Q={...X};if(Q.async=this.defaults.async||Q.async||!1,X.extensions&&(X.extensions.forEach((W)=>{if(!W.name)throw Error("extension name required");if("renderer"in W){let q=J.renderers[W.name];q?J.renderers[W.name]=function(...Y){let H=W.renderer.apply(this,Y);return H===!1&&(H=q.apply(this,Y)),H}:J.renderers[W.name]=W.renderer}if("tokenizer"in W){if(!W.level||W.level!=="block"&&W.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let q=J[W.level];q?q.unshift(W.tokenizer):J[W.level]=[W.tokenizer],W.start&&(W.level==="block"?J.startBlock?J.startBlock.push(W.start):J.startBlock=[W.start]:W.level==="inline"&&(J.startInline?J.startInline.push(W.start):J.startInline=[W.start]))}"childTokens"in W&&W.childTokens&&(J.childTokens[W.name]=W.childTokens)}),Q.extensions=J),X.renderer){let W=this.defaults.renderer||new G$(this.defaults);for(let q in X.renderer){if(!(q in W))throw Error(`renderer '${q}' does not exist`);if(["options","parser"].includes(q))continue;let Y=q,H=X.renderer[Y],G=W[Y];W[Y]=(...B)=>{let N=H.apply(W,B);return N===!1&&(N=G.apply(W,B)),N||""}}Q.renderer=W}if(X.tokenizer){let W=this.defaults.tokenizer||new q$(this.defaults);for(let q in X.tokenizer){if(!(q in W))throw Error(`tokenizer '${q}' does not exist`);if(["options","rules","lexer"].includes(q))continue;let Y=q,H=X.tokenizer[Y],G=W[Y];W[Y]=(...B)=>{let N=H.apply(W,B);return N===!1&&(N=G.apply(W,B)),N}}Q.tokenizer=W}if(X.hooks){let W=this.defaults.hooks||new A2;for(let q in X.hooks){if(!(q in W))throw Error(`hook '${q}' does not exist`);if(["options","block"].includes(q))continue;let Y=q,H=X.hooks[Y],G=W[Y];A2.passThroughHooks.has(q)?W[Y]=(B)=>{if(this.defaults.async&&A2.passThroughHooksRespectAsync.has(q))return(async()=>{let f=await H.call(W,B);return G.call(W,f)})();let N=H.call(W,B);return G.call(W,N)}:W[Y]=(...B)=>{if(this.defaults.async)return(async()=>{let f=await H.apply(W,B);return f===!1&&(f=await G.apply(W,B)),f})();let N=H.apply(W,B);return N===!1&&(N=G.apply(W,B)),N}}Q.hooks=W}if(X.walkTokens){let W=this.defaults.walkTokens,q=X.walkTokens;Q.walkTokens=function(Y){let H=[];return H.push(q.call(this,Y)),W&&(H=H.concat(W.call(this,Y))),H}}this.defaults={...this.defaults,...Q}}),this}setOptions($){return this.defaults={...this.defaults,...$},this}lexer($,J){return y0.lex($,J??this.defaults)}parser($,J){return E0.parse($,J??this.defaults)}parseMarkdown($){return(J,X)=>{let Q={...X},W={...this.defaults,...Q},q=this.onError(!!W.silent,!!W.async);if(this.defaults.async===!0&&Q.async===!1)return q(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 J>"u"||J===null)return q(Error("marked(): input parameter is undefined or null"));if(typeof J!="string")return q(Error("marked(): input parameter is of type "+Object.prototype.toString.call(J)+", string expected"));if(W.hooks&&(W.hooks.options=W,W.hooks.block=$),W.async)return(async()=>{let Y=W.hooks?await W.hooks.preprocess(J):J,H=await(W.hooks?await W.hooks.provideLexer($):$?y0.lex:y0.lexInline)(Y,W),G=W.hooks?await W.hooks.processAllTokens(H):H;W.walkTokens&&await Promise.all(this.walkTokens(G,W.walkTokens));let B=await(W.hooks?await W.hooks.provideParser($):$?E0.parse:E0.parseInline)(G,W);return W.hooks?await W.hooks.postprocess(B):B})().catch(q);try{W.hooks&&(J=W.hooks.preprocess(J));let Y=(W.hooks?W.hooks.provideLexer($):$?y0.lex:y0.lexInline)(J,W);W.hooks&&(Y=W.hooks.processAllTokens(Y)),W.walkTokens&&this.walkTokens(Y,W.walkTokens);let H=(W.hooks?W.hooks.provideParser($):$?E0.parse:E0.parseInline)(Y,W);return W.hooks&&(H=W.hooks.postprocess(H)),H}catch(Y){return q(Y)}}}onError($,J){return(X)=>{if(X.message+=`
|
|
69
|
+
Please report this to https://github.com/markedjs/marked.`,$){let Q="<p>An error occurred:</p><pre>"+p0(X.message+"",!0)+"</pre>";return J?Promise.resolve(Q):Q}if(J)return Promise.reject(X);throw X}}},C1=new uJ;function s($,J){return C1.parse($,J)}s.options=s.setOptions=function($){return C1.setOptions($),s.defaults=C1.defaults,E4(s.defaults),s};s.getDefaults=U5;s.defaults=P1;s.use=function(...$){return C1.use(...$),s.defaults=C1.defaults,E4(s.defaults),s};s.walkTokens=function($,J){return C1.walkTokens($,J)};s.parseInline=C1.parseInline;s.Parser=E0;s.parser=E0.parse;s.Renderer=G$;s.TextRenderer=_5;s.Lexer=y0;s.lexer=y0.lex;s.Tokenizer=q$;s.Hooks=A2;s.parse=s;var{options:EW,setOptions:xW,use:hW,walkTokens:vW,parseInline:mW}=s;var cW=E0.parse,uW=y0.lex;import{useEffect as i4,useMemo as K5,useRef as pJ,useState as V2}from"react";import{jsxDEV as F0}from"react/jsx-dev-runtime";function z5({open:$,onClose:J,onSubmit:X,includedRemoteIds:Q,onToggleRemoteId:W}){let{annotations:q,generalNote:Y,submittableResponses:H,feedbackEntries:G}=O1(),[B,N]=V2(""),[f,L]=V2(!1),[w,F]=V2(!1),[C,_]=V2(null),O=pJ(null),[S,M]=V2(!1),A=K5(()=>q.filter((v)=>v.source==="remote"),[q]);if($&&!S)L(!1),F(!1),_(null);if(!$&&S)L(!1),F(!1),_(null);if($!==S)M($);let Z=K5(()=>n1(q,Y,H,G,Q),[q,Y,H,G,Q]),h=f?B:Z;if(i4(()=>{if($&&w&&O.current)O.current.focus()},[$,w]),i4(()=>{if(!$)return;let v=(u)=>{if(u.key==="Escape")J()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[$,J]),!$)return null;let I=h.trim().length>0;return F0("div",{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm flex items-center justify-center p-8",onClick:J,children:F0("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:(v)=>v.stopPropagation(),children:[F0("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border-subtle flex-shrink-0",children:[F0("div",{className:"flex items-center gap-3",children:[F0("span",{className:"text-[13px] font-medium text-text-primary font-body",children:"Response preview"},void 0,!1,void 0,this),f&&F0("button",{onClick:()=>{L(!1),F(!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),F0("div",{className:"flex items-center gap-2",children:[F0("div",{className:"flex items-center bg-bg-base rounded-md p-0.5",children:[F0("button",{onClick:()=>F(!1),className:`px-2.5 py-1 rounded text-[11px] font-body font-medium transition-colors ${!w?"bg-bg-elevated text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,children:"Preview"},void 0,!1,void 0,this),F0("button",{onClick:()=>F(!0),className:`px-2.5 py-1 rounded text-[11px] font-body font-medium transition-colors ${w?"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),F0("button",{onClick:J,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),w?F0("textarea",{ref:O,value:h,onChange:(v)=>{N(v.currentTarget.value),L(!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):F0("div",{className:"flex-1 overflow-y-auto p-5",children:F0(B$,{text:h},void 0,!1,void 0,this)},void 0,!1,void 0,this),A.length>0&&F0("div",{className:"px-5 py-2 border-t border-border-subtle flex-shrink-0",children:F0("span",{className:"text-[12px] text-text-secondary font-body",children:["Reviewer feedback: ",Q.size,"/",A.length," included"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),C&&F0("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:[F0("span",{children:C},void 0,!1,void 0,this),F0("button",{onClick:()=>{_(null),X(h)},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),F0("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-border-subtle flex-shrink-0",children:[F0("button",{onClick:J,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),F0("button",{onClick:()=>{let v=o1(H,G);if(v.length>0){_(`Please answer: ${v.join(", ")}`);return}_(null),X(h)},disabled:!I,className:`px-6 py-2 rounded-lg font-body text-[13px] font-medium transition-all ${I?"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 lJ=/!\[([^\]]*)\]\((\/tmp\/agent-canvas\/uploads\/([^)]+))\)/g;function dJ($){return $.replace(lJ,(J,X,Q,W)=>``)}function B$({text:$}){let J=K5(()=>s.parse(dJ($),{async:!1}),[$]);return F0("div",{className:"prose-canvas font-body text-body text-text-primary leading-relaxed",dangerouslySetInnerHTML:{__html:J}},void 0,!1,void 0,this)}import{jsxDEV as D,Fragment as N$}from"react/jsx-dev-runtime";function w$({onSubmit:$,collapseButton:J}){let{isReadOnly:X,selectedRevision:Q,currentRevision:W,revisions:q,agentWatching:Y}=S5($2),H=S5(iJ),G=q.find((L)=>L.revision===Q),B=X&&Q===W,N=!!G?.feedbackConsumed,f=G?.label||`Round ${Q}`;if(X)return D(oJ,{sessionId:H,revision:Q,label:f,waitingForUpdate:B,feedbackConsumed:N,agentWatching:Y,collapseButton:J},void 0,!1,void 0,this);return D(tJ,{onSubmit:$,agentWatching:Y,collapseButton:J},void 0,!1,void 0,this)}function nJ({sessionId:$,revision:J,label:X,waitingForUpdate:Q,feedbackConsumed:W,agentWatching:q,collapseButton:Y}){let G=t0().isShared;return D("div",{className:"flex flex-col h-full",children:[D("div",{className:"px-4 py-3 flex items-center justify-between flex-shrink-0",children:[D("span",{className:"text-[11px] font-medium uppercase tracking-widest text-text-tertiary font-body",children:Q?"Feedback sent":`Feedback — ${X}`},void 0,!1,void 0,this),Y]},void 0,!0,void 0,this),Q&&!G&&D(o4,{feedbackConsumed:W,agentWatching:q},void 0,!1,void 0,this),D(s4,{sessionId:$,revision:J},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function o4({feedbackConsumed:$,agentWatching:J}){if($)return D("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:[D("span",{className:"w-2 h-2 rounded-full bg-accent-green animate-pulse"},void 0,!1,void 0,this),D("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(J)return D("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:[D("span",{className:"w-2 h-2 rounded-full bg-accent-blue animate-pulse"},void 0,!1,void 0,this),D("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 D("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:[D("span",{className:"w-2 h-2 rounded-full bg-accent-amber"},void 0,!1,void 0,this),D("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 oJ({sessionId:$,revision:J,label:X,waitingForUpdate:Q,feedbackConsumed:W,agentWatching:q,collapseButton:Y}){let{annotations:H,generalNote:G}=O1(),B=H.length>0||G.trim().length>0,[N,f]=X2("feedback");if(!B)return D(nJ,{sessionId:$,revision:J,label:X,waitingForUpdate:Q,feedbackConsumed:W,agentWatching:q,collapseButton:Y},void 0,!1,void 0,this);return D("div",{className:"flex flex-col h-full",children:[D("div",{className:"px-4 py-3 flex items-center justify-between flex-shrink-0",children:[D("div",{className:"flex items-center gap-1 bg-bg-input rounded-md p-0.5",children:[D("button",{onClick:()=>f("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),D("button",{onClick:()=>f("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",D("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:H.length},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Y]},void 0,!0,void 0,this),Q&&D(o4,{feedbackConsumed:W,agentWatching:q},void 0,!1,void 0,this),N==="feedback"?D(s4,{sessionId:$,revision:J},void 0,!1,void 0,this):D(N$,{children:[D("div",{className:"flex-1 overflow-y-auto",children:D(t4,{annotations:H,readOnly:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this),G.trim()&&D("div",{className:"border-t border-border-subtle px-4 py-3 flex-shrink-0",children:D("div",{className:"text-[13px] font-body text-text-primary leading-relaxed",children:G},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 s4({sessionId:$,revision:J}){let X=t0(),[Q,W]=X2(null),[q,Y]=X2(!0);return n4(()=>{if(Y(!0),!X.fsAvailable){W(null),Y(!1);return}fetch(`/api/session/${$}/revision/${J}/feedback`).then((H)=>H.json()).then((H)=>{W(P4.parse(H).feedback||null),Y(!1)}).catch(()=>{W(null),Y(!1)})},[$,J]),D("div",{className:"flex-1 overflow-y-auto px-4",children:q?D("p",{className:"text-[12px] text-text-tertiary font-body py-4",children:"Loading..."},void 0,!1,void 0,this):Q?D(B$,{text:Q},void 0,!1,void 0,this):D("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 sJ($){let J=$.filter((Y)=>Y.filePath===d1),X=$.filter((Y)=>!Y.filePath),Q=$.filter((Y)=>L1(Y)!==void 0),W={};for(let Y of Q){let H=L1(Y);if(!H)continue;let G=W[H];if(G)G.push(Y);else W[H]=[Y]}let q=[J,X,Q].filter((Y)=>Y.length>0).length>1;return{response:J,plan:X,fileGroups:W,hasMultipleGroups:q}}function r4({children:$}){return D("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 t4({annotations:$,readOnly:J,includedRemoteIds:X,onToggleRemoteId:Q}){let{setActiveView:W}=S5(e1),{response:q,plan:Y,fileGroups:H,hasMultipleGroups:G}=sJ($),B=O5((L)=>{let w=L1(L);if(!w)return;W({type:"file",path:w}),setTimeout(()=>{let F=C2(L);if(F)F.scrollIntoView({behavior:"smooth",block:"center"})},150)},[W]),N=O5((L)=>q5(L,W),[W]),f={readOnly:J,onSelect:B,onReveal:N,includedRemoteIds:X,onToggleRemoteId:Q};return D(N$,{children:[q.length>0&&D(N$,{children:[G&&D(r4,{children:"Agent Response"},void 0,!1,void 0,this),D(O2,{annotations:q,...f},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y.length>0&&D(N$,{children:[G&&D(r4,{children:"Canvas"},void 0,!1,void 0,this),D(O2,{annotations:Y,...f},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Object.entries(H).map(([L,w])=>D("div",{children:[D("button",{onClick:()=>W({type:"file",path:L}),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:L,children:[D(G5,{name:L.split("/").pop()||L,type:"file"},void 0,!1,void 0,this),D("span",{className:"truncate",children:L},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D(O2,{annotations:w,...f},void 0,!1,void 0,this)]},L,!0,void 0,this))]},void 0,!0,void 0,this)}function tJ({onSubmit:$,agentWatching:J,collapseButton:X}){let Q=t0(),[W,q]=X2(!1),{annotations:Y,generalNote:H,submittableResponses:G,feedbackEntries:B}=O1(),N=rJ(()=>Y.filter((A)=>A.source==="remote"),[Y]),[f,L]=X2(()=>new Set);n4(()=>{if(N.length===0)return;L((A)=>{let Z=new Set(A);for(let h of N)Z.add(h.id);return Z.size===A.size?A:Z})},[N]);let w=O5((A)=>{L((Z)=>{let h=new Set(Z);if(h.has(A))h.delete(A);else h.add(A);return h})},[]),F=Array.from(G.values()).some(e2),C=B.size>0,_=Y.length>0||H.trim().length>0||F||C,[O,S]=X2(null),M=()=>{let A=n1(Y,H,G,B,f);$(A)};return D("div",{className:"flex flex-col h-full",children:[D("div",{className:"px-4 py-3 flex items-center justify-between flex-shrink-0",children:[D("span",{className:"text-[11px] font-medium uppercase tracking-widest text-text-tertiary font-body flex items-center gap-2",children:["Annotations",Y.length>0&&D("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:Y.length},void 0,!1,void 0,this),!Q.isShared&&D("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${J?"bg-accent-green":"bg-accent-amber"}`,title:J?"Agent connected":"Agent disconnected"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X]},void 0,!0,void 0,this),D("div",{className:"flex-1 overflow-y-auto",children:[Y.length===0&&D("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),D(t4,{annotations:Y,includedRemoteIds:f,onToggleRemoteId:w},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D(l$,{hasContent:_,onSubmit:()=>{let A=o1(G,B);if(A.length>0){S(`Please answer: ${A.join(", ")}`);return}S(null),M()},onSubmitEmpty:()=>$("No feedback — looks good."),notice:O&&D("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:[D("span",{children:O},void 0,!1,void 0,this),D("button",{onClick:()=>{S(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:D("button",{onClick:()=>q(!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),D(z5,{open:W,onClose:()=>q(!1),onSubmit:$,includedRemoteIds:f,onToggleRemoteId:w},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useFeedback as oG}from"#canvas/runtime";import KY from"react";import{jsxDEV as OY}from"react/jsx-dev-runtime";s.setOptions({gfm:!0,breaks:!1});import{jsxDEV as PY}from"react/jsx-dev-runtime";import{jsxDEV as jY}from"react/jsx-dev-runtime";import{useAnnotations as IY,useResponseRegistration as yY}from"#canvas/runtime";import{useEffect as xY,useMemo as hY,useRef as vY,useState as mY}from"react";import{jsxDEV as bY}from"react/jsx-dev-runtime";import{jsxDEV as pY}from"react/jsx-dev-runtime";import{useEffect as nY,useRef as oY}from"react";import{jsxDEV as aY}from"react/jsx-dev-runtime";import{jsxDEV as Wq}from"react/jsx-dev-runtime";import{ActiveViewCtx as Gq,SessionContext as Hq}from"#canvas/runtime";import{useContext as Bq,useEffect as Nq,useRef as wq,useState as Fq}from"react";import{jsxDEV as _q}from"react/jsx-dev-runtime";import{SessionContext as Oq}from"#canvas/runtime";import{useContext as Rq,useState as Cq}from"react";import{jsxDEV as kq}from"react/jsx-dev-runtime";import{useMemo as Zq}from"react";import{jsxDEV as Dq}from"react/jsx-dev-runtime";s.setOptions({gfm:!0,breaks:!1});import{useAnnotations as Eq,useCanvasFile as xq}from"#canvas/runtime";import{useCallback as cq,useEffect as uq,useRef as pq,useState as lq}from"react";import iq from"react-dom";import{jsxDEV as oq,Fragment as sq}from"react/jsx-dev-runtime";import{jsxDEV as $G}from"react/jsx-dev-runtime";import{jsxDEV as QG}from"react/jsx-dev-runtime";import{useState as GG}from"react";import{jsxDEV as BG}from"react/jsx-dev-runtime";import{jsxDEV as FG}from"react/jsx-dev-runtime";import{jsxDEV as _G}from"react/jsx-dev-runtime";import{useAnnotations as OG,useResponseRegistration as SG}from"#canvas/runtime";import{useRef as PG,useState as kG}from"react";import{jsxDEV as VG}from"react/jsx-dev-runtime";import{CanvasFileCtx as J9,SessionContext as X9}from"#canvas/runtime";import F$,{useContext as e4,useEffect as H1,useMemo as T2,useRef as Q9,useState as l0}from"react";import{createPortal as W9}from"react-dom";import{createContext as $9}from"react";var C5=$9(()=>{});import{jsxDEV as W0,Fragment as H9}from"react/jsx-dev-runtime";class $3 extends F$.Component{state={error:null};static getDerivedStateFromError($){return{error:$}}componentDidCatch($,J){this.props.reportError({revision:this.props.revision,filename:this.props.filename,message:$.message,...$.stack?{stack:$.stack}:{},...J.componentStack?{componentStack:J.componentStack}:{}})}render(){if(!this.state.error)return this.props.children;return W0(J3,{message:this.state.error.message},void 0,!1,void 0,this)}}function J3({message:$}){return W0("div",{className:"bg-accent-red-muted rounded-lg p-5",children:[W0("h3",{className:"font-body font-semibold text-accent-red mb-2",children:"Canvas render failed"},void 0,!1,void 0,this),W0("pre",{className:"text-code font-mono text-text-secondary whitespace-pre-wrap",children:$},void 0,!1,void 0,this),W0("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 f$({revision:$,filename:J}){let X=e4(X9),Q=t0(),W=e4(C5),[q,Y]=l0(null),[H,G]=l0(null),[B,N]=l0(!0),f=Q9(null),{annotations:L,addAnnotationWithId:w,removeAnnotation:F,updateAnnotation:C,addAnnotationImage:_,removeAnnotationImage:O,activeAnnotationId:S,setActiveAnnotationId:M,registerCanvasRendered:A}=O1(),Z=T2(()=>L.filter((K)=>!K.filePath&&(!K.canvasFile||K.canvasFile===J)),[L,J]),[h,I]=l0(null),[v,u]=l0(null),[m,e]=l0(null),[Q0,q0]=l0(null),[K0,c]=l0(!1);H1(()=>{N(!0),G(null),q0(null),Q.loadCanvasModule(J,$).then((K)=>{Y(()=>K.default),N(!1)}).catch((K)=>{let j=K instanceof Error?K:Error(String(K));G(j.message),N(!1),W({revision:$,filename:J,message:j.message,...j.stack?{stack:j.stack}:{}})})},[X,$,J,W]),H1(()=>{if(q)A(J)},[q,J,A]);let $0=document.getElementById("plan-scroll-container"),{popovers:J0,isPopoverOpen:G0}=e$({containerRef:f,restoreKey:q,restoreAnnotations:Z,extractContext:(K)=>T$(K,f.current),canvasFile:J,scrollContainer:$0}),{popovers:a,isDrawing:X0,isPopoverOpen:B0}=t$({containerRef:f,restoreKey:q,canvasFile:J,scrollContainer:$0}),k=G0||B0,g=T2(()=>{let K=new Map;for(let j of Z)if(j.snippet.startsWith("["))K.set(j.snippet,j.id);return K},[Z]);H1(()=>{let K=f.current;if(!K)return;let j=(T)=>{if(m||k||X0)return;let E=T.target;if(E.closest("[data-block-comment-btn]"))return;c(!1);let d=E.closest(T1);if(d&&K.contains(d)){let j0=k1(K).indexOf(d);q0(j0>=0?j0:null)}else q0(null);let H0=E.closest(e0);if(H0&&K.contains(H0)){u(H0);let L0=v0(H0),j0=L0?g.get(L0):void 0;if(j0&&j0!==S)M(j0)}else u(null)},n=(T)=>{if(m||k)return;if(T.relatedTarget?.closest("[data-block-comment-btn]"))return;u(null),M(null)};return K.addEventListener("mousemove",j),K.addEventListener("mouseleave",n),()=>{K.removeEventListener("mousemove",j),K.removeEventListener("mouseleave",n)}},[q,m,k,X0,g,S]),H1(()=>{let K=(j)=>{let n=j.target.tagName;if(n==="INPUT"||n==="TEXTAREA"||j.target.isContentEditable)return;if(m||k)return;let T=f.current;if(!T)return;if(j.key==="ArrowDown"){j.preventDefault(),c(!0);let E=k1(T);if(E.length===0)return;q0((d)=>{if(d===null)return 0;return Math.min(d+1,E.length-1)})}else if(j.key==="ArrowUp"){j.preventDefault(),c(!0);let E=k1(T);if(E.length===0)return;q0((d)=>{if(d===null)return E.length-1;return Math.max(d-1,0)})}else if(j.key==="a"||j.key==="A"){if(Q0===null||!T)return;let d=k1(T)[Q0];if(!d)return;if(!d.matches(e0))return;j.preventDefault();let H0=v0(d);if(!H0)return;let L0=g.get(H0);if(L0)M(L0),e({anchorEl:d,snippet:H0,annId:L0});else e({anchorEl:d,snippet:H0})}else if(j.key===" "||j.key==="Enter"){if(Q0===null)return;let d=k1(T)[Q0];if(!d)return;let H0=d.getAttribute("data-md");if(H0==="choice-option"||H0==="multichoice-option")j.preventDefault(),d.dispatchEvent(new CustomEvent("kb-select",{bubbles:!0}));else if(H0==="userinput"){j.preventDefault();let L0=d.querySelector("textarea");if(L0){L0.focus();let j0=(U1)=>{if(U1.key==="Escape")U1.preventDefault(),L0.blur(),c(!0)};L0.addEventListener("keydown",j0),L0.addEventListener("blur",()=>L0.removeEventListener("keydown",j0),{once:!0})}}else if(H0==="rangeinput"){j.preventDefault();let L0=d.querySelector("input[type='range']");if(L0){L0.focus();let j0=(U1)=>{if(U1.key==="Escape"||U1.key==="ArrowUp"||U1.key==="ArrowDown")U1.preventDefault(),L0.blur(),c(!0)};L0.addEventListener("keydown",j0),L0.addEventListener("blur",()=>L0.removeEventListener("keydown",j0),{once:!0})}}}else if(j.key==="Escape")q0(null),c(!1),M(null)};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[Q0,m,k,g]),H1(()=>{let K=f.current;if(!K||Q0===null||!K0)return;let n=k1(K)[Q0];if(!n)return;n.style.outline="2px solid var(--color-accent-blue)",n.style.outlineOffset="-2px",n.style.borderRadius="8px",n.scrollIntoView({block:"nearest",behavior:"smooth"});let T=v0(n),E=T?g.get(T):void 0;if(E)M(E);return()=>{n.style.outline="",n.style.outlineOffset="",n.style.borderRadius=""}},[Q0,K0,g]);let l=T2(()=>q?W0(q,{},void 0,!1,void 0,this):null,[q]);if(B)return W0("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(H)return W0(J3,{message:H},void 0,!1,void 0,this);if(!q)return W0("div",{className:"text-text-tertiary text-center py-8 font-body text-body",children:"No canvas loaded"},void 0,!1,void 0,this);return W0(J9.Provider,{value:J,children:[W0("div",{ref:f,className:"plan-content plan-updated","data-canvas-file":J,children:W0($3,{revision:$,filename:J,reportError:W,children:l},`${$}:${J}`,!1,void 0,this)},void 0,!1,void 0,this),h&&W0(G9,{note:h.note,onSave:(K)=>{C(h.id,K),I(null)},onCancel:()=>I(null)},void 0,!1,void 0,this),J0,a,W0(Y9,{containerRef:f,hoveredBlock:v,focusedBlockIndex:Q0,blockPopover:m,blockAnnotationMap:g,activeAnnotationId:S,onOpen:(K,j,n)=>{if(n)M(n),e({anchorEl:K,snippet:j,annId:n});else e({anchorEl:K,snippet:j})}},void 0,!1,void 0,this),m&&!m.annId&&W0(G1,{anchorEl:m.anchorEl,scrollContainer:$0,snippet:m.snippet,truncateAt:80,onAdd:(K,j)=>{let n=o0();w(n,m.snippet,K,void 0,void 0,j,J),e(null)},onCancel:()=>e(null)},void 0,!1,void 0,this),m?.annId&&(()=>{let K=Z.find((j)=>j.id===m.annId);if(!K)return null;return W0(R2,{anchorEl:m.anchorEl,scrollContainer:$0,initialNote:K.note,initialImages:K.images,onUpdate:(j,n)=>{C(m.annId,j);let T=K.images||[];for(let E of n)if(!T.includes(E))_(m.annId,E);for(let E of T)if(!n.includes(E))O(m.annId,E)},onDelete:()=>{F(m.annId),M(null),e(null)},onClose:()=>e(null)},void 0,!1,void 0,this)})()]},void 0,!0,void 0,this)}function k1($){return Array.from($.querySelectorAll(T1))}function Y9({containerRef:$,hoveredBlock:J,focusedBlockIndex:X,blockPopover:Q,blockAnnotationMap:W,activeAnnotationId:q,onOpen:Y}){let[H,G]=l0([]);H1(()=>{let w=$.current;if(!w||W.size===0){G([]);return}let F=[];for(let C of w.querySelectorAll(e0)){let _=v0(C);if(_&&W.has(_))F.push(C)}G(F)},[W,$.current]);let[B,N]=l0(null);H1(()=>{if(!q||!$.current){N(null);return}for(let w of $.current.querySelectorAll(T1)){let F=v0(w);if(F&&W.get(F)===q){N(w);return}}N(null)},[q,W]),H1(()=>{if(!B)return;return B.style.boxShadow="inset 0 0 0 1.5px var(--color-highlight-bg)",B.style.borderRadius="8px",()=>{B.style.boxShadow="",B.style.borderRadius=""}},[B]);let f=T2(()=>{if(X===null||!$.current)return null;let w=k1($.current)[X];if(!w)return null;return w.matches(e0)?w:null},[X,$.current]),L=T2(()=>{let w=new Set(H);if(J)w.add(J);if(f)w.add(f);if(Q?.anchorEl)w.add(Q.anchorEl);return Array.from(w)},[H,J,f,Q]);return W0(H9,{children:L.map((w)=>W0(q9,{block:w,isHovered:w===J||w===f||w===Q?.anchorEl,blockAnnotationMap:W,activeAnnotationId:q,onOpen:Y},w.getAttribute("data-task-id")||w.getAttribute("data-md-title")||w.textContent?.slice(0,30)||"block",!1,void 0,this))},void 0,!1,void 0,this)}function q9({block:$,isHovered:J,blockAnnotationMap:X,activeAnnotationId:Q,onOpen:W}){let q=v0($);if(!q)return null;let Y=X.get(q),H=!!Y;return W9(W0("button",{"data-block-comment-btn":!0,onClick:(B)=>{B.stopPropagation(),W(B.currentTarget,q,Y)},className:`absolute top-1 right-1 z-10 w-6 h-6 flex items-center justify-center rounded transition-all duration-150 ${H?Y===Q?"text-accent-amber bg-accent-amber-muted":"text-accent-amber opacity-60 hover:opacity-100":J?"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:H?"Edit annotation":"Add annotation",children:W0("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:H?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:W0("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 G9({note:$,onSave:J,onCancel:X}){let[Q,W]=F$.useState($),q=F$.useRef(null);return F$.useEffect(()=>{q.current?.focus(),q.current?.select()},[]),W0("div",{className:"fixed inset-0 z-50 bg-black/40 flex items-center justify-center",onClick:X,children:W0("div",{className:"bg-bg-elevated border border-border-hover rounded-lg shadow-md p-4 w-80",onClick:(Y)=>Y.stopPropagation(),children:[W0("div",{className:"text-tiny uppercase tracking-widest text-text-tertiary font-body mb-2",children:"Edit annotation"},void 0,!1,void 0,this),W0("textarea",{ref:q,value:Q,onChange:(Y)=>W(Y.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:(Y)=>{if(Y.key==="Enter"&&(Y.ctrlKey||Y.metaKey))J(Q.trim());if(Y.key==="Escape")X()}},void 0,!1,void 0,this),W0("div",{className:"flex justify-end gap-2 mt-2",children:[W0("button",{onClick:X,className:"text-meta text-text-tertiary font-body px-3 py-1",children:"Cancel"},void 0,!1,void 0,this),W0("button",{onClick:()=>J(Q.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 C0,Fragment as k5}from"react/jsx-dev-runtime";function X3({gateName:$,hasGate:J,isCurrentGate:X,onSubmit:Q}){let[W,q]=f9(!0);if(!W)return C0("button",{onClick:()=>q(!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:C0("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 Y=C0("button",{onClick:()=>q(!1),className:"text-text-tertiary hover:text-text-secondary",title:"Collapse",children:C0("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:C0("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 C0("aside",{className:"flex h-full w-72 flex-col border-l border-border-subtle bg-bg-surface",children:J?C0(w$,{onSubmit:Q,collapseButton:Y},void 0,!1,void 0,this):C0(k5,{children:[C0("div",{className:"flex items-center justify-between border-b border-border-subtle px-4 py-3",children:[C0("div",{className:"text-tiny uppercase tracking-wide text-text-tertiary",children:"review & annotate"},void 0,!1,void 0,this),Y]},void 0,!0,void 0,this),C0("div",{className:"flex-1 px-4 py-6 text-center text-tiny text-text-tertiary",children:X&&$?C0(k5,{children:["gate ",C0("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):$?C0(k5,{children:["this phase's ",C0("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 L9,useState as A5}from"react";import{jsxDEV as i}from"react/jsx-dev-runtime";var Q2="rounded border border-border-medium px-3 py-1 text-tiny disabled:opacity-40",Q3="rounded border border-border-medium bg-bg-base px-2 py-1 text-body text-text-primary";function W3({platform:$,live:J}){let[X,Q]=A5(""),[W,q]=A5(null),[Y,H]=A5(null),{data:G,enabled:B,busy:N,error:f}=$,L=G?.connection;L9(()=>{if(L)H(L.controlOrigin)},[L?.controlOrigin]);let w=G?.pairing,F=G?.deployment,C=F?.status==="preparing"||F?.status==="pending"||F?.status==="running",_=w?.status==="pending"||w?.status==="approved",O=G?.credential.available&&(G.credential.expiresAt===null||G.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:[!J&&i("p",{className:"text-text-tertiary",children:"Offline / demo mode — deployment controls are disabled."},void 0,!1,void 0,this),J&&!G&&!f&&i("p",{role:"status",children:"Loading project status…"},void 0,!1,void 0,this),f&&i("p",{role:"alert",className:"text-accent-red",children:f},void 0,!1,void 0,this),L?i("div",{className:"space-y-1",children:[i("p",{children:["App ",i("strong",{children:L.receipt.app.id},void 0,!1,void 0,this)," · ",L.receipt.provider," · ",L.receipt.environment.env]},void 0,!0,void 0,this),i("p",{className:"text-text-secondary",children:["Control: ",L.controlOrigin]},void 0,!0,void 0,this),i("p",{children:["Local credential: ",O?"available":"unavailable or expired",G?.credential.expiresAt!=null&&` · expires ${new Date(G.credential.expiresAt*1000).toLocaleString()}`]},void 0,!0,void 0,this),i("a",{className:"text-accent-blue underline",href:L.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),!L&&Y&&i("a",{className:"text-accent-blue underline",href:Y,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:(S)=>{S.preventDefault(),$.act({kind:"connect",controlOrigin:X})},children:[i("label",{htmlFor:"control-origin",children:"Control origin"},void 0,!1,void 0,this),i("input",{className:Q3,id:"control-origin",type:"url",value:X,onChange:(S)=>Q(S.currentTarget.value),placeholder:"https://control.example.com",disabled:!B||!!L||_,required:!0},void 0,!1,void 0,this),i("button",{className:Q2,type:"submit",disabled:!B||!!L||_,children:N?"Working…":"Connect"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w?.status==="pending"&&B&&w.expiresAt*1000>Date.now()&&i("a",{className:"text-accent-blue underline",href:w.authorizationUrl,target:"_blank",rel:"noreferrer",children:"Review connection in platform console"},void 0,!1,void 0,this),w&&i("p",{role:"status",children:["Connection: ",w.status,(w.status==="failed"||w.status==="recovery_required")&&` — ${w.message}`]},void 0,!0,void 0,this),i("div",{className:"flex flex-wrap items-center gap-2",children:[i("button",{className:Q2,type:"button",disabled:!B||!L&&!w,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:Q2,type:"button",disabled:!B||!L||!O||C||_,onClick:()=>void $.act({kind:"deploy"}),children:C?"Deploy in progress…":"Deploy pushed commit"},void 0,!1,void 0,this),i("button",{className:Q2,type:"button",disabled:!J||N,onClick:$.refresh,children:"Refresh status"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F&&i("div",{role:"status",className:"space-y-1",children:[i("p",{children:["Deployment: ",i("strong",{children:F.status},void 0,!1,void 0,this),F.message&&` — ${F.message}`]},void 0,!0,void 0,this),F.runId&&i("p",{children:["Run: ",i("code",{children:F.runId},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F.commitSha&&i("p",{children:["Commit: ",i("code",{children:F.commitSha},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F.consoleUrl&&i("a",{className:"mr-4 text-accent-blue underline",href:F.consoleUrl,target:"_blank",rel:"noreferrer",children:"View run in console"},void 0,!1,void 0,this),F.appUrl&&i("a",{className:"text-accent-blue underline",href:F.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:(S)=>{S.preventDefault(),$.act({kind:"preview",url:W??G?.previewUrl??""})},children:[i("label",{htmlFor:"preview-url",children:"Local preview URL"},void 0,!1,void 0,this),i("input",{className:Q3,id:"preview-url",type:"url",value:W??G?.previewUrl??"",onChange:(S)=>q(S.currentTarget.value),placeholder:G?.previewUrl??"http://localhost:3000",disabled:!B,required:!0},void 0,!1,void 0,this),i("button",{className:Q2,type:"submit",disabled:!B,children:"Set preview"},void 0,!1,void 0,this),i("button",{className:Q2,type:"button",disabled:!B||!G?.previewUrl,onClick:()=>{q(null),$.act({kind:"preview",url:null})},children:"Clear preview"},void 0,!1,void 0,this),i("span",{className:"text-tiny text-text-tertiary",children:[G?.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 a0}from"react/jsx-dev-runtime";var M9={connecting:"connecting…",live:"live",offline:"offline",fixture:"fixture"},_9={connecting:"bg-accent-amber",live:"bg-accent-green",offline:"bg-accent-red",fixture:"bg-accent-blue"};function Y3({sessionId:$,status:J,watching:X}){return a0("header",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border-subtle bg-bg-surface px-4",children:[a0("div",{className:"flex items-center gap-2 text-body text-text-secondary",children:[a0("span",{className:"text-text-tertiary",children:"session"},void 0,!1,void 0,this),a0("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),a0("div",{className:"flex items-center gap-4",children:[X&&a0("span",{className:"flex items-center gap-1.5 text-tiny text-text-tertiary",children:[a0("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),a0("span",{className:"flex items-center gap-1.5 text-tiny text-text-secondary",children:[a0("span",{className:`inline-flex h-2 w-2 rounded-full ${_9[J]}`},void 0,!1,void 0,this),M9[J]]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var L$=["intake","vision","flows","tech","design","skeletons","issues","build"],K9={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"]}},M$=L$.map(($,J)=>({id:$,number:J+1,...K9[$]})),_$=M$.length;function z9($){return L$.indexOf($)}function q3($){let J=M$[z9($)];if(!J)throw Error(`Unknown phase id: ${$}`);return J}function Z2($,J,X){if(J.includes($))return"done";if($===X)return"current";return"upcoming"}import{jsxDEV as U0}from"react/jsx-dev-runtime";function O9({status:$}){if($==="done")return U0("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-accent-green-muted text-accent-green",children:U0("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:U0("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 U0("span",{className:"relative flex h-5 w-5 items-center justify-center",children:[U0("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-accent-amber opacity-40"},void 0,!1,void 0,this),U0("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 U0("span",{className:"flex h-5 w-5 items-center justify-center rounded-full border border-border-medium"},void 0,!1,void 0,this)}function G3({state:$,focused:J,onFocus:X}){return U0("nav",{className:"flex h-full flex-col border-r border-border-subtle bg-bg-surface",children:[U0("div",{className:"border-b border-border-subtle px-4 py-3",children:[U0("div",{className:"font-heading text-xl text-text-primary",children:"fabrika"},void 0,!1,void 0,this),U0("div",{className:"text-tiny uppercase tracking-wide text-text-tertiary",children:"guided app build"},void 0,!1,void 0,this),U0("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),U0("ol",{className:"flex-1 overflow-y-auto py-2",children:M$.map((Q)=>{let W=Z2(Q.id,$.completed,$.current),q=J===Q.id,Y=W!=="upcoming";return U0("li",{children:U0("button",{disabled:!Y,onClick:()=>Y&&X(Q.id),className:["group flex w-full items-start gap-3 px-4 py-2.5 text-left transition-colors",q?"bg-bg-elevated":"hover:bg-bg-elevated-half",Y?"cursor-pointer":"cursor-not-allowed opacity-55"].join(" "),children:[U0("div",{className:"mt-0.5 shrink-0",children:U0(O9,{status:W},void 0,!1,void 0,this)},void 0,!1,void 0,this),U0("div",{className:"min-w-0",children:[U0("div",{className:"flex items-center gap-1.5",children:[U0("span",{className:"text-tiny tabular-nums text-text-tertiary",children:[Q.number,"/",_$]},void 0,!0,void 0,this),Q.gate&&U0("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),U0("div",{className:["truncate text-task-label",W==="current"?"font-semibold text-text-primary":W==="done"?"text-text-secondary":"text-text-tertiary"].join(" "),children:Q.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},Q.id,!1,void 0,this)})},void 0,!1,void 0,this),U0("div",{className:"border-t border-border-subtle px-4 py-2 text-tiny text-text-tertiary",children:["phase derived from ",U0("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 N7,useState as g3}from"react";var qU=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",DATA_READ:"data.read",DATA_CONTENT_READ:"data.content.read",DATA_MANAGE:"data.manage"}),GU=Object.freeze({APP:"app",ENVIRONMENT:"environment"});function S9($){if(typeof $!=="string"||$.length>2048)return null;try{let J=new URL($),X=J.hostname==="localhost"||J.hostname.endsWith(".localhost")||J.hostname==="[::1]"||/^127(?:\.[0-9]{1,3}){3}$/.test(J.hostname);if(J.protocol!=="https:"&&!(J.protocol==="http:"&&X))return null;if(J.username!==""||J.password!==""||J.pathname!=="/"||J.search!==""||J.hash!=="")return null;return J.origin}catch{return null}}var H3=U.string().transform(($,J)=>{let X=S9($);if(X!==null)return X;return J.addIssue({code:"custom",message:"invalid builder public origin"}),U.NEVER}),BU=U.preprocess(($)=>{if(typeof $==="object"&&$!==null&&Object.keys($).length!==4)return;return $},U.object({version:U.literal(1),controlOrigin:H3,iamIssuer:H3,provider:U.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/)}).strict());var R9=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;var C9=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;var j5=U.number().int().safe().nonnegative(),V5=U.string().regex(C9),P9=U.object({id:V5,repoUrl:U.string(),defaultBranch:U.string(),workerDir:U.string().nullable(),buildCmd:U.string().nullable(),configPath:U.string().nullable(),githubConnectionId:U.string().nullable().optional(),githubInstallationId:j5.nullable(),createdAt:j5}).strict().transform(({githubConnectionId:$,githubInstallationId:J,createdAt:X,...Q})=>({...Q,...$===void 0?{}:{githubConnectionId:$},githubInstallationId:J,createdAt:X})),k9=U.object({env:V5,namespaceId:U.string().min(1).max(128).nullable(),domain:U.string().min(1).max(253).nullable(),publicOrigin:U.string().min(1).max(2048).nullable(),triggerRef:U.string().min(1).max(1024).nullable()}).strict(),U3=U.object({version:U.literal(1),attemptId:U.string().regex(R9),provider:V5,app:P9,environment:k9,createdAt:j5}).strict();var A9=100,j9=512,LU=U.object({cursor:U.string().min(1).max(j9).optional(),limit:U.number().int().safe().min(1).max(A9).optional()}).strict().transform(({cursor:$,limit:J})=>({...$===void 0?{}:{cursor:$},...J===void 0?{}:{limit:J}}));var K$="FABRIKA_IAM_APP_ID";var V9=/%2f|%5c/i,T9=/%2e/gi;function T5($){if($==="/")return!0;if(!$.startsWith("/")||$.includes("\\")||V9.test($))return!1;let J=$.slice(1).split("/"),X=J.length-1;return J.every((Q,W)=>(Q!==""||W===X)&&!b9(Q)&&Z9(Q))}function Z9($){try{return decodeURIComponent($),!0}catch{return!1}}function b9($){let J=$.replace(T9,".");return J==="."||J===".."}var D9=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),g9=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function d0($,J){return $>>>J|$<<32-J}function W2($){let J=new TextEncoder().encode($),X=new Uint8Array(Math.ceil((J.length+9)/64)*64);X.set(J),X[J.length]=128;let Q=new DataView(X.buffer),W=J.length*8;Q.setUint32(X.length-8,Math.floor(W/4294967296)),Q.setUint32(X.length-4,W>>>0);let q=new Uint32Array(g9),Y=new Uint32Array(64);for(let H=0;H<X.length;H+=64){for(let O=0;O<16;O++)Y[O]=Q.getUint32(H+O*4);for(let O=16;O<64;O++){let S=Y[O-15]??0,M=Y[O-2]??0,A=d0(S,7)^d0(S,18)^S>>>3,Z=d0(M,17)^d0(M,19)^M>>>10;Y[O]=(Y[O-16]??0)+A+(Y[O-7]??0)+Z}let[G=0,B=0,N=0,f=0,L=0,w=0,F=0,C=0]=q;for(let O=0;O<64;O++){let S=d0(L,6)^d0(L,11)^d0(L,25),M=L&w^~L&F,A=C+S+M+(D9[O]??0)+(Y[O]??0)>>>0,Z=d0(G,2)^d0(G,13)^d0(G,22),h=G&B^G&N^B&N,I=Z+h>>>0;C=F,F=w,w=L,L=f+A>>>0,f=N,N=B,B=G,G=A+I>>>0}let _=[G,B,N,f,L,w,F,C];for(let[O,S]of _.entries())q[O]=(q[O]??0)+S}return Array.from(q,(H)=>H.toString(16).padStart(8,"0")).join("")}var Z5="FABRIKA_CONTRACT_DIGEST";var N3="*";class I9{#$;#J;constructor($,J){this.#$=$,this.#J=J}plan($,J){return y9(this.#$,this.#J,$,J)}}function y9($,J,X,Q){if(!T5(Q))return{outcome:"non-canonical"};let W=x9(Q),q=h9(Q,J),Y=null,H=!1;for(let G of $){if(!E9(G.row.method,X)||q!==null&&!F3(G.row.path,q))continue;let B=v9(G.segments,W);if(B===null)continue;let N=Y===null?-1:m9(G.segments,Y.endpoint.segments);if(N<0)Y={endpoint:G,params:B},H=!1;else if(N===0)H=!0}if(Y===null||H)return{outcome:"no-endpoint"};return{outcome:"endpoint",endpoint:Y.endpoint.row,params:Y.params}}function E9($,J){return $===N3||$===J}function x9($){return $==="/"?[]:$.slice(1).split("/")}function F3($,J){return $.startsWith(`${J}/`)}function h9($,J){let X=null;for(let Q of J)if(F3($,Q)&&(X===null||Q.length>X.length))X=Q;return X}function v9($,J){let X=[];for(let[Q,W]of $.entries()){if(W.kind==="wildcard")return Q===0||J.length>Q?Object.fromEntries(X):null;let q=J[Q];if(q===void 0)return null;if(W.kind==="param"){if(q==="")return null;X.push([W.name,q])}else if(W.value!==q)return null}return $.length===J.length?Object.fromEntries(X):null}var w3={literal:0,param:1,wildcard:2};function m9($,J){let X=Math.min($.length,J.length);for(let Q=0;Q<X;Q++){let W=$[Q],q=J[Q];if(W===void 0||q===void 0)break;let Y=w3[W.kind]-w3[q.kind];if(Y!==0)return Y}return $.length-J.length}var z$="FABRIKA_IAM_ISSUER";var O$="FABRIKA_PROXY_SECRET";var c9="FABRIKA_SOURCE_MAP_UPLOAD",u9="FABRIKA_SOURCE_MAP_UPLOAD_KEY",b5="FABRIKA_TOKEN_KEYS",D5="FABRIKA_APP_ORIGIN",g5="FABRIKA_OPS_KEY_DIGESTS",p9="FABRIKA_APPLICATION_OBJECT",l9="FABRIKA_APPLICATION_OBJECTS",d9=["FABRIKA_RELEASE",Z5,z$,K$,"FABRIKA_OPERATIONS_DSN","FABRIKA_APP_ID","FABRIKA_ENVIRONMENT","FABRIKA_SERVICE_KEY","FABRIKA_APP_DATABASE_URL","FABRIKA_APP_RUNTIME_DATABASE_URL","FABRIKA_APP_DATABASE_CONNECTIONS","FABRIKA_APP_STORAGE_ENDPOINT","FABRIKA_APP_STORAGE_BUCKET","FABRIKA_APP_STORAGE_ACCESS_KEY_ID","FABRIKA_APP_STORAGE_SECRET_ACCESS_KEY","FABRIKA_STORAGE_PROVENANCE",O$,"FABRIKA_IAM_RPC_URL","FABRIKA_IAM_RPC_KEY",c9,u9,b5,D5,g5,p9,l9];var oU=new Set(d9);function i9($){return $.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()}var I5=["mail","source"];function y5($){let J=`FABRIKA_PLATFORM_${i9($)}`;return{url:`${J}_URL`,key:`${J}_KEY`}}var sU=new Set(I5.flatMap(($)=>Object.values(y5($))));var r9=["FABRIKA_RELEASE","FABRIKA_OPERATIONS_DSN",z$,K$,"FABRIKA_APP_ID","FABRIKA_ENVIRONMENT","FABRIKA_SERVICE_KEY",O$,"FABRIKA_IAM_RPC_URL","FABRIKA_IAM_RPC_KEY",D5,b5,g5],NB=new Set(r9);var wB=new Set(I5.map(($)=>y5($).url));var n9="/__fabrika/ops/";var kB=`${n9}*`;var o9=100,AB=(o9-2)/2;var jB=W2("");var VB=-(2n**63n),TB=2n**63n-1n;var s9="__Host-px_",QN=`${s9}session`;var f3=100,V0=U.string().min(1),t9=U.enum(["open","read-only","closed","inspect"]),a9=U.object({appId:V0,env:V0,before:V0.optional(),limit:U.number().int().min(1).max(f3).optional()}).strict(),e9=U.discriminatedUnion("kind",[U.object({appId:V0,env:V0,kind:U.literal("maintenance"),mode:t9}).strict(),U.object({appId:V0,env:V0,kind:U.literal("backup")}).strict(),U.object({appId:V0,env:V0,kind:U.literal("restore"),at:U.string().datetime({offset:!0})}).strict()]),$7=U.object({appId:V0,env:V0,operationId:V0,resolution:U.enum(["resume","open"])}).strict();var pN=U.object({ts:U.number().finite(),stream:U.enum(["stdout","stderr","meta"]),text:U.string()});function L3($,J){if(typeof $!=="string"||$.length===0||$.trim()!==$||[...$].some((Q)=>Q.charCodeAt(0)<=32||Q.charCodeAt(0)===127||Q==="\\"))throw Error(`${J} must be an HTTP(S) URL`);let X;try{X=new URL($)}catch{throw Error(`${J} must be an HTTP(S) URL`)}if(!/^https?:\/\//i.test($)||X.protocol!=="https:"&&X.protocol!=="http:"||X.username||X.password||/^https?:\/\/[^/?#]*@/i.test($))throw Error(`${J} must be an HTTP(S) URL without credentials`);return X}function Y2($,J="origin"){let X=L3($,J);if(typeof $!=="string"||!/^https?:\/\/[^/?#]+\/?$/i.test($)||X.pathname!=="/"||X.search||X.hash)throw Error(`${J} must be an origin without a path, query, or fragment`);let Q=X.hostname==="localhost"||X.hostname==="127.0.0.1"||X.hostname==="[::1]"||X.hostname.endsWith(".localhost"),W=$.slice($.indexOf("://")+3).replace(/\/$/,"").toLowerCase(),q=X.hostname!=="127.0.0.1"||/^127\.0\.0\.1(?::\d+)?$/.test(W);if(X.protocol!=="https:"&&(!Q||!q))throw Error(`${J} must use HTTPS except on localhost`);return X.origin}function b2($){return L3($,"preview URL").href}var k0=U.union([U.number(),U.nan()]),f0=U.string().optional().catch(void 0),M3=U.enum(L$),J7=U.object({current:M3,index:k0,completed:U.array(M3),reads:U.array(U.string()),produces:U.array(U.string()),gate:U.boolean(),satisfied:U.boolean()}),_3=J7.extend({gateName:U.string().nullable().optional().catch(void 0)}).transform(({gateName:$,...J})=>({...J,...$===void 0?{}:{gateName:$}})),Gw=U.object({ok:U.literal(!0),version:f0,pid:k0.optional().catch(void 0),dataDir:f0,sessionsDir:U.string(),sessions:U.union([k0,U.array(U.string())]).optional().catch(void 0)}).transform(({ok:$,version:J,pid:X,dataDir:Q,sessionsDir:W,sessions:q})=>({ok:$,...J===void 0?{}:{version:J},...X===void 0?{}:{pid:X},...Q===void 0?{}:{dataDir:Q},sessionsDir:W,...q===void 0?{}:{sessions:q}})),K3=U.object({ok:U.literal(!0),version:f0,sessions:U.array(U.string()).optional().catch(void 0)}).transform(({ok:$,version:J,sessions:X})=>({ok:$,...J===void 0?{}:{version:J},...X===void 0?{}:{sessions:X}})),Hw=U.object({ok:U.literal(!0),sessionsDir:U.string()}),z3=U.object({error:U.object({code:U.literal("builder_platform"),message:U.string().max(1000)})}),Uw=U.object({ok:U.boolean(),browserUrl:f0,revision:k0.optional().catch(void 0),isNew:U.boolean().optional().catch(void 0),canvasFiles:U.array(U.string()).optional().catch(void 0),gate:f0,error:f0,errors:U.record(U.string()).optional().catch(void 0)}).transform(({ok:$,browserUrl:J,revision:X,isNew:Q,canvasFiles:W,gate:q,error:Y,errors:H})=>({ok:$,...J===void 0?{}:{browserUrl:J},...X===void 0?{}:{revision:X},...Q===void 0?{}:{isNew:Q},...W===void 0?{}:{canvasFiles:W},...q===void 0?{}:{gate:q},...Y===void 0?{}:{error:Y},...H===void 0?{}:{errors:H}})),O3=U.object({status:U.enum(["queued","running","passed","failed","blocked","info"]),issue:f0,message:f0,at:f0,data:U.record(U.unknown()).optional().catch(void 0)}).transform(({status:$,issue:J,message:X,at:Q,data:W})=>({status:$,...J===void 0?{}:{issue:J},...X===void 0?{}:{message:X},...Q===void 0?{}:{at:Q},...W===void 0?{}:{data:W}})),Bw=U.object({view:f0,directory:f0,projectRoot:f0,gate:f0,label:f0,response:f0}),S3=U.object({feedback:U.string().catch("")}),Nw=S3.extend({found:U.literal(!0)}),ww=S3.extend({type:U.literal("submit")}),R3=U.object({revision:k0,hasFeedback:U.unknown().transform(($)=>$===!0),feedbackConsumed:U.unknown().transform(($)=>$===!0)}),Fw=U.object({revisions:U.array(R3.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null))}),X7=U.union([U.string().transform(($)=>({filename:$})),U.object({filename:U.string(),label:f0,diffStats:U.object({added:k0,removed:k0}).optional().catch(void 0)}).transform(({filename:$,label:J,diffStats:X})=>({filename:$,...J===void 0?{}:{label:J},...X===void 0?{}:{diffStats:X}}))]).refine(($)=>$.filename.length>0),S$=U.array(X7.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null)).catch([]),Q7=U.discriminatedUnion("kind",[U.object({kind:U.literal("directory")}),U.object({kind:U.literal("view"),filename:U.string()})]),W7=R3.extend({label:U.string().nullable().catch(null),canvasFiles:S$,createdAt:f0,canvasScope:Q7.optional().catch(void 0)}).transform(({createdAt:$,canvasScope:J,...X})=>({...X,...$===void 0?{}:{createdAt:$},...J===void 0?{}:{canvasScope:J}})).refine(($)=>$.revision>0),C3=U.object({projectRoot:f0,label:f0,gate:U.string().nullable().catch(null),currentRevision:k0.catch(0),canvasFiles:S$,revisions:U.array(W7.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null)).catch([])}).transform(({projectRoot:$,label:J,...X})=>({...X,...$===void 0?{}:{projectRoot:$},...J===void 0?{}:{label:J}})),Y7=U.object({id:U.string(),label:f0}).transform(({id:$,label:J})=>({id:$,...J===void 0?{}:{label:J}})),P3=U.array(Y7.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null)).catch([]),q7=U.object({file:U.string(),name:U.string(),seeds:U.array(U.string()),roles:U.array(U.string()),steps:k0,invariants:k0,pending:k0,url:f0,feature:f0}).transform(({url:$,feature:J,...X})=>({...X,...$===void 0?{}:{url:$},...J===void 0?{}:{feature:J}})),k3=U.object({skeletons:U.array(q7.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null))}),A3=U.object({content:U.string()}),j3=U.object({responses:U.unknown()}),V3=U.discriminatedUnion("type",[U.object({type:U.literal("plan-updated"),currentRevision:k0,canvasFiles:U.array(U.unknown()).transform(($)=>S$.parse($)).optional().catch(void 0),gate:U.string().nullable().optional().catch(void 0)}),U.object({type:U.literal("revision-updated"),currentRevision:k0}),U.object({type:U.literal("watcher-status"),watching:U.boolean()}),U.object({type:U.literal("phase-updated")}),U.object({type:U.literal("submit-ack"),revision:k0})]).transform(($)=>{if($.type!=="plan-updated")return $;let{canvasFiles:J,gate:X,...Q}=$;return{...Q,...J===void 0?{}:{canvasFiles:J},...X===void 0?{}:{gate:X}}}),T0=U.string().refine(($)=>$.trim().length>0),T3=U.number().finite().nonnegative(),E5=U.string().transform(($,J)=>{try{return Y2($)}catch{return J.addIssue({code:U.ZodIssueCode.custom,message:"Invalid builder origin"}),U.NEVER}}),q2=U.string().transform(($,J)=>{try{return b2($)}catch{return J.addIssue({code:U.ZodIssueCode.custom,message:"Invalid preview URL"}),U.NEVER}}),Z3=U.object({controlOrigin:E5,iamIssuer:E5,receipt:U3}).strict(),fw=U.object({profile:T0,sessionId:T0,createdAt:T0.refine(($)=>Number.isFinite(Date.parse($))),connection:Z3.optional(),previewUrl:q2.optional()}).strict().superRefine(($,J)=>{for(let X of["connection","previewUrl"])if(Object.hasOwn($,X)&&Reflect.get($,X)===void 0)J.addIssue({code:U.ZodIssueCode.custom,path:[X],message:"Present field must not be undefined"})}),G7=U.discriminatedUnion("status",[U.object({status:U.literal("pending"),authorizationUrl:q2.refine(($)=>{try{return Y2(new URL($).origin),!0}catch{return!1}}),expiresAt:T3}).strict(),U.object({status:U.literal("approved")}).strict(),U.object({status:U.literal("failed"),message:T0}).strict(),U.object({status:U.literal("expired")}).strict(),U.object({status:U.literal("cancelled")}).strict(),U.object({status:U.literal("recovery_required"),message:T0}).strict(),U.object({status:U.literal("connected")}).strict()]),H7=U.object({status:U.enum(["preparing","pending","running","awaiting_approval","succeeded","failed","cancelled"]),runId:T0.nullable(),commitSha:T0.nullable(),message:T0.nullable(),appUrl:q2.nullable(),consoleUrl:q2.nullable()}).strict(),U7=U.object({sessionId:T0,projectRoot:T0,connection:Z3.nullable(),credential:U.object({available:U.boolean(),expiresAt:T3.nullable()}).strict(),pairing:G7.nullable(),previewUrl:q2.nullable(),deployment:H7.nullable()}).strict(),Lw=U.object({projectRoot:T0}).strict(),Mw=U.object({controlOrigin:E5}).strict(),_w=U.object({url:q2.nullable()}).strict();function b3($){let J=U7.safeParse($);if(!J.success)throw Error("Invalid platform status");return J.data}function D3($,J){let X=T0.safeParse($);if(!X.success)throw Error("project id must be a non-empty string");return`/api/project/${encodeURIComponent(X.data)}/${J}`}function A1(){return location.origin}function R$(){return location.pathname.match(/\/s\/([^/]+)/)?.[1]??null}function B7(){return new URLSearchParams(location.search).get("root")}async function G2($){let J=await fetch(A1()+$,{headers:{accept:"application/json"}});if(!J.ok)throw Error(`${$} -> ${J.status}`);return J.json()}var S0={async health(){let $=K3.safeParse(await G2("/health"));if(!$.success)throw Error("Invalid health response");return $.data},async phase($){let J=$??B7(),X=R$(),Q=new URLSearchParams;if(J)Q.set("root",J);if(X)Q.set("session",X);let W=Q.toString(),q=_3.safeParse(await G2(`/api/phase${W?`?${W}`:""}`));if(!q.success)throw Error("Invalid phase response");return q.data},async meta($){let J=C3.safeParse(await G2(`/api/session/${encodeURIComponent($)}/meta`));if(!J.success)throw Error("Invalid session response");return{id:$,...J.data}},async artifact($,J){try{let X=await fetch(`${A1()}/api/session/${encodeURIComponent($)}/artifact?path=${encodeURIComponent(J)}`,{headers:{accept:"application/json"}});if(!X.ok)return null;let Q=A3.safeParse(await X.json());return Q.success?Q.data.content:null}catch{return null}},async sessions(){return P3.parse(await G2("/api/sessions"))},canvasUrl($,J,X){let Q=X!=null?`?rev=${X}`:"";return`${A1()}/api/session/${encodeURIComponent($)}/canvas/${encodeURIComponent(J)}${Q}`},async skeletons($){let J=k3.safeParse(await G2(`/api/session/${encodeURIComponent($)}/skeletons`));return J.success?J.data.skeletons:[]},async feedback($,J){let X=await fetch(`${A1()}/api/session/${encodeURIComponent($)}/revision/${J}/feedback`);if(!X.ok)throw Error(`feedback -> ${X.status}`);return X.text()},async getResponses($,J,X){try{let Q=j3.safeParse(await G2(`/api/session/${encodeURIComponent($)}/revision/${J}/responses`));return Q.success?X(Q.data.responses):null}catch{return null}},async saveResponses($,J,X){try{await fetch(`${A1()}/api/session/${encodeURIComponent($)}/revision/${J}/responses`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(X)})}catch{}},openSocket($,J){let X=location.protocol==="https:"?"wss:":"ws:",Q=A1().replace(/^https?:/,X),W=new WebSocket(`${Q}/ws/session/${encodeURIComponent($)}`);return W.onmessage=(q)=>{try{let Y=V3.safeParse(JSON.parse(String(q.data)));if(Y.success)J(Y.data)}catch{}},W},submitGate($,J){if($.readyState===WebSocket.OPEN)return $.send(JSON.stringify({type:"submit",feedback:J})),!0;return!1},buildStream($){try{let J=new EventSource(`${A1()}/api/build/stream`);return J.onmessage=(X)=>{try{let Q=O3.safeParse(JSON.parse(X.data));if(Q.success)$(Q.data)}catch{}},J}catch{return null}}};import{jsxDEV as Y0,Fragment as C$}from"react/jsx-dev-runtime";var w7=".fabrika/architecture/design.md",F7=".fabrika/pages/_preview.html",x5=`:root{
|
|
70
70
|
--color-brand:#6f4e37; --color-brand-strong:#573c2a;
|
|
71
71
|
--color-surface:#fbf7f0; --color-surface-sunken:#f1e9dd;
|
|
72
72
|
--color-text:#2a1e16; --color-muted:#8a7866; --color-accent:#c8853a;
|
|
@@ -74,7 +74,7 @@ Please report this to https://github.com/markedjs/marked.`,$){let Q="<p>An error
|
|
|
74
74
|
--space-gutter:16px; --radius-card:12px;
|
|
75
75
|
--font-heading:"Instrument Serif",Georgia,serif;
|
|
76
76
|
--font-body:system-ui,-apple-system,"Segoe UI",sans-serif;
|
|
77
|
-
}`;function
|
|
77
|
+
}`;function f7($){if(!$)return x5;let J=$.match(/:root\s*\{[^}]*\}/);return J?J[0]:x5}function L7($){return`<!DOCTYPE html>
|
|
78
78
|
<html lang="cs">
|
|
79
79
|
<head>
|
|
80
80
|
<meta charset="utf-8" />
|
|
@@ -162,9 +162,9 @@ h1 {
|
|
|
162
162
|
</div>
|
|
163
163
|
</div>
|
|
164
164
|
</body>
|
|
165
|
-
</html>`}function
|
|
166
|
-
`),X=[],Q=0,W=0;while(Q<J.length){let
|
|
167
|
-
`)},void 0,!1,void 0,this)},W++,!1,void 0,this));continue}let q=Y.match(/^(#{1,4})\s+(.*)$/);if(q){let H=q[1].length,G=H===1?"mt-2 mb-3 font-heading text-section text-text-primary":H===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";X.push(x0("div",{className:G,children:P$(q[2])},W++,!1,void 0,this)),Q++;continue}if(/^[-*]\s+/.test(Y)){let H=[];while(Q<J.length&&/^[-*]\s+/.test(J[Q]))H.push(J[Q].replace(/^[-*]\s+/,"")),Q++;X.push(x0("ul",{className:"my-2 list-disc space-y-1 pl-5 text-body text-text-secondary",children:H.map((G,B)=>x0("li",{children:P$(G)},B,!1,void 0,this))},W++,!1,void 0,this));continue}if(/^\d+\.\s+/.test(Y)){let H=[];while(Q<J.length&&/^\d+\.\s+/.test(J[Q]))H.push(J[Q].replace(/^\d+\.\s+/,"")),Q++;X.push(x0("ol",{className:"my-2 list-decimal space-y-1 pl-5 text-body text-text-secondary",children:H.map((G,B)=>x0("li",{children:P$(G)},B,!1,void 0,this))},W++,!1,void 0,this));continue}if(Y.trim()===""){Q++;continue}X.push(x0("p",{className:"my-2 text-body leading-relaxed text-text-secondary",children:P$(Y)},W++,!1,void 0,this)),Q++}return x0("div",{className:"select-text",children:X},void 0,!1,void 0,this)}import{jsxDEV as V,Fragment as m3}from"react/jsx-dev-runtime";function K7({state:$,focused:J,isCurrentGate:X}){let Q=Y3(J),W=Z2(J,$.completed,$.current),Y=W==="current",q=Y&&$.reads.length?$.reads.join(", "):Q.reads.join(", "),H=Y&&$.produces.length?$.produces.join(", "):Q.produces.join(", ");return V("div",{className:"border-b border-border-subtle px-6 py-4",children:[V("div",{className:"flex items-center gap-3",children:[V("h1",{className:"font-heading text-section text-text-primary",children:["Phase ",Q.number,"/",_$," — ",Q.label]},void 0,!0,void 0,this),V("span",{className:["rounded px-2 py-0.5 text-tiny uppercase tracking-wide",W==="done"?"bg-accent-green-muted text-accent-green":W==="current"?"bg-accent-amber-muted text-accent-amber":"border border-border-medium text-text-tertiary"].join(" "),children:W},void 0,!1,void 0,this)]},void 0,!0,void 0,this),V("dl",{className:"mt-3 grid grid-cols-[5rem_1fr] gap-x-3 gap-y-1.5 text-body",children:[V("dt",{className:"text-text-tertiary",children:"Read"},void 0,!1,void 0,this),V("dd",{className:"min-w-0 break-words font-mono text-code text-text-secondary",children:q},void 0,!1,void 0,this),V("dt",{className:"text-text-tertiary",children:"Goal"},void 0,!1,void 0,this),V("dd",{className:"min-w-0 break-words text-text-secondary",children:H},void 0,!1,void 0,this),V("dt",{className:"text-text-tertiary",children:"Gate"},void 0,!1,void 0,this),V("dd",{className:"min-w-0 break-words font-mono text-code text-text-secondary",children:Q.gate?V(m3,{children:["fabrika builder gate open ",J," --view view.jsx && fabrika builder gate wait"]},void 0,!0,void 0,this):V("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),X&&V("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:[V("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",className:"mt-px shrink-0",children:V("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),V("span",{children:[V("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"," ",V("strong",{className:"font-semibold",children:"Submit"},void 0,!1,void 0,this)," in the panel on the right. That feedback is what"," ",V("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 z7({sessionId:$,live:J,upcoming:X}){let[Q,W]=h3(null);x3(()=>{if(!J)return;let q=!1;return S0.skeletons($).then((H)=>{if(!q)W(H)}),()=>{q=!0}},[$,J]);let Y=Q??[];return V("div",{className:"p-6",children:[X&&V("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 ",V("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),J&&Y.length===0&&V("p",{className:"text-body text-text-tertiary",children:["No skeletons in ",V("span",{className:"font-mono",children:"tests/browser/"},void 0,!1,void 0,this)," yet. Author them with the ",V("span",{className:"font-mono",children:"opice-plan"},void 0,!1,void 0,this)," ","skill, then ",V("span",{className:"font-mono",children:"fabrika builder induce"},void 0,!1,void 0,this),"."]},void 0,!0,void 0,this),V("div",{className:"grid grid-cols-2 gap-3",children:Y.map((q)=>V("div",{className:"rounded-md border border-border-subtle bg-bg-surface p-4 transition-colors hover:border-border-hover",children:[V("div",{className:"font-mono text-code text-text-primary",children:q.file},void 0,!1,void 0,this),V("div",{className:"mt-1 truncate text-body text-text-secondary",children:q.name},void 0,!1,void 0,this),V("div",{className:"mt-2 flex flex-wrap gap-x-3 gap-y-1 text-tiny text-text-tertiary",children:[q.url&&V("span",{className:"font-mono",children:q.url},void 0,!1,void 0,this),V("span",{children:[q.steps," steps"]},void 0,!0,void 0,this),V("span",{children:[q.invariants," invariants"]},void 0,!0,void 0,this),q.pending>0?V("span",{className:"text-accent-amber",children:[q.pending," pending"]},void 0,!0,void 0,this):V("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)&&V("div",{className:"mt-2 flex flex-wrap gap-1",children:[q.seeds.map((H)=>V("span",{className:"rounded bg-bg-elevated px-1.5 py-0.5 text-tiny text-text-secondary",children:["seed:",H]},H,!0,void 0,this)),q.roles.map((H)=>V("span",{className:"rounded bg-bg-elevated px-1.5 py-0.5 text-tiny text-text-secondary",children:["role:",H]},H,!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 O7({live:$}){let[J,X]=h3([]);x3(()=>{if(!$)return;let W=S0.buildStream((Y)=>X((q)=>[...q.slice(-200),Y]));return()=>W?.close()},[$]);let Q={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 V("div",{className:"p-6",children:[V("h2",{className:"mb-3 font-heading text-section text-text-primary",children:"Build"},void 0,!1,void 0,this),J.length===0?V("p",{className:"text-body text-text-tertiary",children:["Waiting for build events. Run ",V("span",{className:"font-mono",children:"fabrika builder build"},void 0,!1,void 0,this)," to drive the per-issue pipeline; each"," ",V("span",{className:"font-mono",children:"build done/block"},void 0,!1,void 0,this)," posts here."]},void 0,!0,void 0,this):V("ul",{className:"space-y-1.5 font-mono text-code",children:J.map((W,Y)=>V("li",{className:"flex items-center gap-2",children:[V("span",{className:`inline-flex h-2 w-2 shrink-0 rounded-full ${Q[W.status]}`},void 0,!1,void 0,this),W.issue&&V("span",{className:"text-text-secondary",children:W.issue},void 0,!1,void 0,this),V("span",{className:"text-text-tertiary",children:W.status},void 0,!1,void 0,this),W.message&&V("span",{className:"truncate text-text-secondary",children:["— ",W.message]},void 0,!0,void 0,this)]},Y,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function S7({canvas:$}){return V(m3,{children:$.files.map((J)=>V("div",{className:"mb-8",children:[$.files.length>1&&V("div",{className:"mb-2 text-tiny uppercase tracking-wide text-text-tertiary",children:J.label??J.filename},void 0,!1,void 0,this),V(f$,{revision:$.revision,filename:J.filename},void 0,!1,void 0,this)]},J.filename,!0,void 0,this))},void 0,!1,void 0,this)}function v3({state:$,focused:J,canvas:X,artifact:Q,isCurrentGate:W,sessionId:Y,live:q}){let G=Z2(J,$.completed,$.current)==="upcoming";return V("section",{className:"flex h-full min-w-0 flex-col bg-bg-base",children:[V(K7,{state:$,focused:J,isCurrentGate:W},void 0,!1,void 0,this),V("div",{id:"plan-scroll-container",className:"flex-1 overflow-y-auto",children:X?V("div",{className:"mx-auto max-w-3xl px-6 py-5",children:V(S7,{canvas:X},void 0,!1,void 0,this)},void 0,!1,void 0,this):J==="skeletons"?V(z7,{sessionId:Y,live:q,upcoming:G},void 0,!1,void 0,this):J==="build"?V(O7,{live:q},void 0,!1,void 0,this):V("div",{className:"mx-auto max-w-3xl px-6 py-5",children:[G&&V("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),V(E3,{source:Q},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 c3($){if(!$)return[];if($.canvasScope?.kind==="view"){let X=$.canvasScope.filename;return $.canvasFiles.filter((Q)=>Q.filename===X)}if($.canvasScope?.kind==="directory")return $.canvasFiles;let J=$.canvasFiles.filter((X)=>!X.diffStats||X.diffStats.added!==0||X.diffStats.removed!==0);return J.length>0?J:$.canvasFiles}var u3="fixture-session",h5={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},p3={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 l3={intake:`# Brief
|
|
165
|
+
</html>`}function M7($,J){let X=`<style>${J}</style>`,Q=$.indexOf("<head>");if(Q!==-1)return $.slice(0,Q+6)+X+$.slice(Q+6);return`${X}${$}`}function I3({url:$,children:J}){return Y0("div",{className:"flex h-full flex-col overflow-hidden rounded-md border border-border-medium bg-bg-base",children:[Y0("div",{className:"flex items-center gap-1.5 border-b border-border-subtle bg-bg-elevated px-3 py-2",children:[Y0("span",{className:"h-2.5 w-2.5 rounded-full bg-accent-red/60"},void 0,!1,void 0,this),Y0("span",{className:"h-2.5 w-2.5 rounded-full bg-accent-amber/60"},void 0,!1,void 0,this),Y0("span",{className:"h-2.5 w-2.5 rounded-full bg-accent-green/60"},void 0,!1,void 0,this),Y0("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),J]},void 0,!0,void 0,this)}function _7({sessionId:$,live:J}){let[X,Q]=g3(x5),[W,q]=g3(null);N7(()=>{if(!J)return;let G=!1;return S0.artifact($,w7).then((B)=>{if(!G)Q(f7(B))}),S0.artifact($,F7).then((B)=>{if(!G)q(B?.trim()?B:null)}).catch(()=>{}),()=>{G=!0}},[$,J]);let Y=W!==null,H=Y?M7(W,X):L7(X);return Y0(C$,{children:[Y0(I3,{url:Y?"pages/_preview.html":"pages/checkout.jsx",children:Y0("iframe",{srcDoc:H,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),Y0("p",{className:"mt-2 px-0.5 text-tiny text-text-tertiary",children:Y?Y0(C$,{children:["Primary screen mockup (",Y0("span",{className:"font-mono",children:"pages/_preview.html"},void 0,!1,void 0,this),"), themed live by"," ",Y0("span",{className:"font-mono",children:"architecture/design.md"},void 0,!1,void 0,this)," tokens."]},void 0,!0,void 0,this):Y0(C$,{children:["Built-in demo screen, themed live by ",Y0("span",{className:"font-mono",children:"architecture/design.md"},void 0,!1,void 0,this)," tokens — drop a"," ",Y0("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 K7({previewUrl:$}){if(!$)return Y0("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 Y0(C$,{children:[Y0(I3,{url:$,children:Y0("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),Y0("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 y3({phase:$,sessionId:J,live:X,previewUrl:Q}){return Y0("aside",{className:"flex h-full flex-col border-l border-border-subtle bg-bg-surface",children:[Y0("div",{className:"flex items-center justify-between border-b border-border-subtle px-4 py-3",children:[Y0("div",{className:"text-tiny uppercase tracking-wide text-text-tertiary",children:"live preview"},void 0,!1,void 0,this),Y0("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),Y0("div",{className:"flex min-h-0 flex-1 flex-col p-3",children:$==="build"?Y0(K7,{previewUrl:Q},void 0,!1,void 0,this):Y0(_7,{sessionId:J,live:X},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as x3,useState as h3}from"react";import{jsxDEV as x0}from"react/jsx-dev-runtime";function P$($){let J=[],X=/(`[^`]+`|\*\*[^*]+\*\*)/g,Q=0,W,q=0;while(W=X.exec($)){if(W.index>Q)J.push($.slice(Q,W.index));let Y=W[0];if(Y.startsWith("`"))J.push(x0("code",{className:"rounded bg-bg-code px-1 py-0.5 font-mono text-code text-text-code",children:Y.slice(1,-1)},q++,!1,void 0,this));else J.push(x0("strong",{className:"font-semibold text-text-primary",children:Y.slice(2,-2)},q++,!1,void 0,this));Q=W.index+Y.length}if(Q<$.length)J.push($.slice(Q));return J}function E3({source:$}){let J=$.split(`
|
|
166
|
+
`),X=[],Q=0,W=0;while(Q<J.length){let q=J[Q];if(q.startsWith("```")){let H=[];Q++;while(Q<J.length&&!J[Q].startsWith("```"))H.push(J[Q++]);Q++,X.push(x0("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:x0("code",{children:H.join(`
|
|
167
|
+
`)},void 0,!1,void 0,this)},W++,!1,void 0,this));continue}let Y=q.match(/^(#{1,4})\s+(.*)$/);if(Y){let H=Y[1].length,G=H===1?"mt-2 mb-3 font-heading text-section text-text-primary":H===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";X.push(x0("div",{className:G,children:P$(Y[2])},W++,!1,void 0,this)),Q++;continue}if(/^[-*]\s+/.test(q)){let H=[];while(Q<J.length&&/^[-*]\s+/.test(J[Q]))H.push(J[Q].replace(/^[-*]\s+/,"")),Q++;X.push(x0("ul",{className:"my-2 list-disc space-y-1 pl-5 text-body text-text-secondary",children:H.map((G,B)=>x0("li",{children:P$(G)},B,!1,void 0,this))},W++,!1,void 0,this));continue}if(/^\d+\.\s+/.test(q)){let H=[];while(Q<J.length&&/^\d+\.\s+/.test(J[Q]))H.push(J[Q].replace(/^\d+\.\s+/,"")),Q++;X.push(x0("ol",{className:"my-2 list-decimal space-y-1 pl-5 text-body text-text-secondary",children:H.map((G,B)=>x0("li",{children:P$(G)},B,!1,void 0,this))},W++,!1,void 0,this));continue}if(q.trim()===""){Q++;continue}X.push(x0("p",{className:"my-2 text-body leading-relaxed text-text-secondary",children:P$(q)},W++,!1,void 0,this)),Q++}return x0("div",{className:"select-text",children:X},void 0,!1,void 0,this)}import{jsxDEV as V,Fragment as m3}from"react/jsx-dev-runtime";function z7({state:$,focused:J,isCurrentGate:X}){let Q=q3(J),W=Z2(J,$.completed,$.current),q=W==="current",Y=q&&$.reads.length?$.reads.join(", "):Q.reads.join(", "),H=q&&$.produces.length?$.produces.join(", "):Q.produces.join(", ");return V("div",{className:"border-b border-border-subtle px-6 py-4",children:[V("div",{className:"flex items-center gap-3",children:[V("h1",{className:"font-heading text-section text-text-primary",children:["Phase ",Q.number,"/",_$," — ",Q.label]},void 0,!0,void 0,this),V("span",{className:["rounded px-2 py-0.5 text-tiny uppercase tracking-wide",W==="done"?"bg-accent-green-muted text-accent-green":W==="current"?"bg-accent-amber-muted text-accent-amber":"border border-border-medium text-text-tertiary"].join(" "),children:W},void 0,!1,void 0,this)]},void 0,!0,void 0,this),V("dl",{className:"mt-3 grid grid-cols-[5rem_1fr] gap-x-3 gap-y-1.5 text-body",children:[V("dt",{className:"text-text-tertiary",children:"Read"},void 0,!1,void 0,this),V("dd",{className:"min-w-0 break-words font-mono text-code text-text-secondary",children:Y},void 0,!1,void 0,this),V("dt",{className:"text-text-tertiary",children:"Goal"},void 0,!1,void 0,this),V("dd",{className:"min-w-0 break-words text-text-secondary",children:H},void 0,!1,void 0,this),V("dt",{className:"text-text-tertiary",children:"Gate"},void 0,!1,void 0,this),V("dd",{className:"min-w-0 break-words font-mono text-code text-text-secondary",children:Q.gate?V(m3,{children:["fabrika builder gate open ",J," --view view.jsx && fabrika builder gate wait"]},void 0,!0,void 0,this):V("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),X&&V("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:[V("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",className:"mt-px shrink-0",children:V("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),V("span",{children:[V("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"," ",V("strong",{className:"font-semibold",children:"Submit"},void 0,!1,void 0,this)," in the panel on the right. That feedback is what"," ",V("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 O7({sessionId:$,live:J,upcoming:X}){let[Q,W]=h3(null);x3(()=>{if(!J)return;let Y=!1;return S0.skeletons($).then((H)=>{if(!Y)W(H)}),()=>{Y=!0}},[$,J]);let q=Q??[];return V("div",{className:"p-6",children:[X&&V("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 ",V("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),J&&q.length===0&&V("p",{className:"text-body text-text-tertiary",children:["No skeletons in ",V("span",{className:"font-mono",children:"tests/browser/"},void 0,!1,void 0,this)," yet. Author them with the ",V("span",{className:"font-mono",children:"opice-plan"},void 0,!1,void 0,this)," ","skill, then ",V("span",{className:"font-mono",children:"fabrika builder induce"},void 0,!1,void 0,this),"."]},void 0,!0,void 0,this),V("div",{className:"grid grid-cols-2 gap-3",children:q.map((Y)=>V("div",{className:"rounded-md border border-border-subtle bg-bg-surface p-4 transition-colors hover:border-border-hover",children:[V("div",{className:"font-mono text-code text-text-primary",children:Y.file},void 0,!1,void 0,this),V("div",{className:"mt-1 truncate text-body text-text-secondary",children:Y.name},void 0,!1,void 0,this),V("div",{className:"mt-2 flex flex-wrap gap-x-3 gap-y-1 text-tiny text-text-tertiary",children:[Y.url&&V("span",{className:"font-mono",children:Y.url},void 0,!1,void 0,this),V("span",{children:[Y.steps," steps"]},void 0,!0,void 0,this),V("span",{children:[Y.invariants," invariants"]},void 0,!0,void 0,this),Y.pending>0?V("span",{className:"text-accent-amber",children:[Y.pending," pending"]},void 0,!0,void 0,this):V("span",{className:"text-accent-green",children:"authored"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),(Y.seeds.length>0||Y.roles.length>0)&&V("div",{className:"mt-2 flex flex-wrap gap-1",children:[Y.seeds.map((H)=>V("span",{className:"rounded bg-bg-elevated px-1.5 py-0.5 text-tiny text-text-secondary",children:["seed:",H]},H,!0,void 0,this)),Y.roles.map((H)=>V("span",{className:"rounded bg-bg-elevated px-1.5 py-0.5 text-tiny text-text-secondary",children:["role:",H]},H,!0,void 0,this))]},void 0,!0,void 0,this)]},Y.file,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function S7({live:$}){let[J,X]=h3([]);x3(()=>{if(!$)return;let W=S0.buildStream((q)=>X((Y)=>[...Y.slice(-200),q]));return()=>W?.close()},[$]);let Q={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 V("div",{className:"p-6",children:[V("h2",{className:"mb-3 font-heading text-section text-text-primary",children:"Build"},void 0,!1,void 0,this),J.length===0?V("p",{className:"text-body text-text-tertiary",children:["Waiting for build events. Run ",V("span",{className:"font-mono",children:"fabrika builder build"},void 0,!1,void 0,this)," to drive the per-issue pipeline; each"," ",V("span",{className:"font-mono",children:"build done/block"},void 0,!1,void 0,this)," posts here."]},void 0,!0,void 0,this):V("ul",{className:"space-y-1.5 font-mono text-code",children:J.map((W,q)=>V("li",{className:"flex items-center gap-2",children:[V("span",{className:`inline-flex h-2 w-2 shrink-0 rounded-full ${Q[W.status]}`},void 0,!1,void 0,this),W.issue&&V("span",{className:"text-text-secondary",children:W.issue},void 0,!1,void 0,this),V("span",{className:"text-text-tertiary",children:W.status},void 0,!1,void 0,this),W.message&&V("span",{className:"truncate text-text-secondary",children:["— ",W.message]},void 0,!0,void 0,this)]},q,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function R7({canvas:$}){return V(m3,{children:$.files.map((J)=>V("div",{className:"mb-8",children:[$.files.length>1&&V("div",{className:"mb-2 text-tiny uppercase tracking-wide text-text-tertiary",children:J.label??J.filename},void 0,!1,void 0,this),V(f$,{revision:$.revision,filename:J.filename},void 0,!1,void 0,this)]},J.filename,!0,void 0,this))},void 0,!1,void 0,this)}function v3({state:$,focused:J,canvas:X,artifact:Q,isCurrentGate:W,sessionId:q,live:Y}){let G=Z2(J,$.completed,$.current)==="upcoming";return V("section",{className:"flex h-full min-w-0 flex-col bg-bg-base",children:[V(z7,{state:$,focused:J,isCurrentGate:W},void 0,!1,void 0,this),V("div",{id:"plan-scroll-container",className:"flex-1 overflow-y-auto",children:X?V("div",{className:"mx-auto max-w-3xl px-6 py-5",children:V(R7,{canvas:X},void 0,!1,void 0,this)},void 0,!1,void 0,this):J==="skeletons"?V(O7,{sessionId:q,live:Y,upcoming:G},void 0,!1,void 0,this):J==="build"?V(S7,{live:Y},void 0,!1,void 0,this):V("div",{className:"mx-auto max-w-3xl px-6 py-5",children:[G&&V("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),V(E3,{source:Q},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 c3($){if(!$)return[];if($.canvasScope?.kind==="view"){let X=$.canvasScope.filename;return $.canvasFiles.filter((Q)=>Q.filename===X)}if($.canvasScope?.kind==="directory")return $.canvasFiles;let J=$.canvasFiles.filter((X)=>!X.diffStats||X.diffStats.added!==0||X.diffStats.removed!==0);return J.length>0?J:$.canvasFiles}var u3="fixture-session",h5={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},p3={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 l3={intake:`# Brief
|
|
168
168
|
|
|
169
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
170
|
|
|
@@ -211,4 +211,4 @@ Deterministic compile step — issues induced from skeleton metadata.
|
|
|
211
211
|
- ISSUE-001 Foundation: routes + seed infra.
|
|
212
212
|
- ISSUE-002 Feature: cart + checkout vertical slice.`,build:`# Build
|
|
213
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
|
|
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 C7=X$.extend({generalNote:U.string(),annotations:U.array(u$.pick({id:!0,snippet:!0,note:!0,createdAt:!0}).passthrough()),responses:U.array(U.tuple([U.string(),$$.innerType().pick({id:!0,type:!0,label:!0}).extend({type:U.string()}).passthrough()])),feedbackEntries:U.array(U.tuple([U.string(),J$.pick({id:!0,markdown:!0}).passthrough()])).optional()});function d3($){let J=C7.safeParse($);return J.success?s1(J.data):null}class h0 extends Error{}function P7($=fetch){async function J(X,Q,W,q){let Y;try{Y=await $(D3(X,Q),{method:W?"POST":"GET",headers:{accept:"application/json",...W?{"content-type":"application/json"}:{}},...W?{body:JSON.stringify(W)}:{},redirect:"error",cache:"no-store",signal:q?AbortSignal.any([q,AbortSignal.timeout(1e4)]):AbortSignal.timeout(1e4)})}catch{throw new h0("Local builder unavailable. Check the daemon and refresh status.")}let H;try{H=await Y.json()}catch{throw new h0("Local builder returned an invalid response. Refresh status before continuing.")}if(!Y.ok){let G=z3.safeParse(H);if(G.success)throw new h0(G.data.error.message);throw new h0("Local builder rejected the request. Refresh status before continuing.")}try{let G=b3(H);if(G.sessionId!==X)throw Error("Session mismatch");return G}catch{throw new h0("Local builder returned an invalid status. Refresh status before continuing.")}}return{status:(X,Q)=>J(X,"platform",void 0,Q),register:(X,Q)=>J(X,"register",{projectRoot:Q}),act:(X,Q,W)=>{let q={};try{if(Q.kind==="connect")q={controlOrigin:Y2(Q.controlOrigin)};if(Q.kind==="preview")q={url:Q.url===null?null:b2(Q.url)}}catch{throw new h0("Enter a valid URL without credentials. Control origins require HTTPS except on localhost.")}return J(X,Q.kind,q,W)}}}var D2=P7();import{useEffect as i3,useRef as k7,useState as g2}from"react";function r3($,J){let[X,Q]=g2($),[W,q]=g2(null),[Y,H]=g2(null),[G,B]=g2(!1),[N,f]=g2(0),L=k7(null);i3(()=>{return Q($),q(null),H(null),B(!1),f(0),()=>{L.current?.abort(),L.current=null}},[$]),i3(()=>{if(X!==$||!J||G||Y)return;let C=new AbortController,_,O=0,S=async()=>{try{if(++O>1200)throw new h0("Automatic status refresh paused. Refresh status to continue.");let M=await D2.status($,C.signal);if(C.signal.aborted)return;q(M),H(null),_=setTimeout(S,3000)}catch(M){if(!C.signal.aborted)H(M instanceof h0?M.message:"Unable to read local deployment status.")}};return S(),()=>{C.abort(),clearTimeout(_)}},[$,X,J,G,N,Y]);let w=X===$,F=w&&J&&W!==null&&Y===null&&!G;return{data:w?W:null,error:w?Y:null,busy:w&&G,enabled:F,refresh:()=>{q(null),H(null),f((C)=>C+1)},act:async(C)=>{if(!F||L.current)return;let _=new AbortController;L.current=_,B(!0);try{let O=await D2.act($,C,_.signal);if(!_.signal.aborted)q(O)}catch(O){if(!_.signal.aborted)H(O instanceof h0?O.message:"Local operation failed. Refresh status.")}finally{if(L.current===_){if(L.current=null,!_.signal.aborted)B(!1)}}}}}import{jsxDEV as A0}from"react/jsx-dev-runtime";function A7($){return $==="design"||$==="build"}var o3={current:"intake",index:0,completed:[],reads:[],produces:[],gate:!1,satisfied:!1},j7="_Nový projekt — zatím žádný krok. Otevři první gate z agenta._";function s3(){let $=R$()??u3,[J,X]=j1("connecting"),Q=r3($,J==="live"),[W,q]=j1(o3),[Y,H]=j1(null),[G,B]=j1(!1),[N,f]=j1(o3.current),[L,w]=j1(!1),F=m5(!1),C=m5(null),_=m5(void 0);n3(()=>{let k=!1;return(async()=>{try{if(await S0.health(),k)return;let g=new URLSearchParams(location.search).get("root");if(g?.endsWith("/.fabrika"))await D2.register($,g.slice(0,-9));let l=await S0.meta($);if(k)return;if(l)H(l),_.current=l.projectRoot?`${l.projectRoot}/.fabrika`:void 0;let K=await S0.phase(_.current);if(k)return;if(K){if(q(K),!F.current)f(K.current)}X("live")}catch{if(!k){if(R$()){X("offline");return}if(H(p3),q(h5),!F.current)f(h5.current);X("fixture")}}})(),()=>{k=!0}},[$]);let O=Y!==null&&(J==="live"||J==="offline");n3(()=>{if(!O)return;let k=!1,g=null,l=()=>{S0.meta($).then((j)=>H(j)).catch(()=>{}),S0.phase(_.current).then((j)=>{if(q(j),!F.current)f(j.current)}).catch(()=>{})},K=()=>{let j=S0.openSocket($,(n)=>{if(n.type==="plan-updated"||n.type==="revision-updated")w(!1),l();else if(n.type==="watcher-status")B(n.watching);else if(n.type==="phase-updated")w(!1),l();else if(n.type==="submit-ack")w(!1),l()});C.current=j,j.onopen=()=>X("live"),j.onclose=()=>{if(k)return;X("offline"),g=setTimeout(K,2000)}};return K(),()=>{if(k=!0,g)clearTimeout(g);C.current?.close(),C.current=null}},[O,$]);let[S,M]=j1({type:"overview"}),A=(k)=>{F.current=!0,f(k)},Z=(k)=>{let g=C.current;if(g&&S0.submitGate(g,k))w(!0)},h=J==="live",I=v5(()=>{if(!Y)return null;for(let k=Y.revisions.length-1;k>=0;k--)if(Y.revisions[k].label===N)return Y.revisions[k];return null},[Y,N]),v=W.gateName??Y?.gate??null,u=h&&N===W.current&&!!v,m=v5(()=>{return c3(I)},[I]),e=h&&!!I&&m.length>0,Q0=I?.revision??Y?.currentRevision??0,q0=Y?.currentRevision??0,K0=u&&!!I?.hasFeedback&&!I?.feedbackConsumed,$0=!u||u&&(L||K0),J0=J==="fixture"?l3[N]??"_No artifact for this phase yet._":j7,G0=v5(()=>(Y?.revisions??[]).map((k)=>({revision:k.revision,label:k.label??void 0,canvasFiles:k.canvasFiles.map((g)=>({filename:g.filename})),createdAt:k.createdAt??new Date().toISOString(),hasFeedback:!!k.hasFeedback,feedbackConsumed:!!k.feedbackConsumed})),[Y]),a=A7(N),B0=A0("div",{className:`grid min-h-0 flex-1 grid-rows-[minmax(0,1fr)] ${a?"grid-cols-[14rem_minmax(0,1fr)_22rem_auto]":"grid-cols-[14rem_minmax(0,1fr)_auto]"}`,children:[A0(G3,{state:W,focused:N,onFocus:A},void 0,!1,void 0,this),A0(v3,{state:W,focused:N,canvas:e?{revision:Q0,files:m}:null,artifact:J0,isCurrentGate:u,sessionId:$,live:h},void 0,!1,void 0,this),a&&A0(y3,{phase:N,sessionId:$,live:h,previewUrl:Q.data?.previewUrl??null},void 0,!1,void 0,this),A0(X3,{gateName:v,hasGate:e,isCurrentGate:u,onSubmit:Z},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return A0("div",{className:"flex h-screen w-screen flex-col overflow-hidden bg-bg-base text-text-primary",children:[A0(Y3,{sessionId:$,status:J,watching:G},void 0,!1,void 0,this),A0(W3,{platform:Q,live:h},void 0,!1,void 0,this),J==="offline"&&A0("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?A0(P5.Provider,{value:$,children:A0($2.Provider,{value:{currentRevision:q0,selectedRevision:Q0,revisions:G0,setSelectedRevision:()=>{},isReadOnly:$0,compareRevision:null,setCompareRevision:()=>{},agentWatching:G},children:A0(e1.Provider,{value:{activeView:S,setActiveView:M,openFiles:[],closeFile:()=>{},canvasFiles:m.map((k)=>k.filename)},children:A0(Q$,{sessionId:$,revision:Q0,isReadOnly:$0,draftPhase:"current",loadState:(k,g)=>S0.getResponses(k,g,d3),saveState:(k,g,l)=>{S0.saveResponses(k,g,l)},children:B0},Q0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this):B0]},void 0,!0,void 0,this)}import{jsxDEV as T7}from"react/jsx-dev-runtime";var t3=document.getElementById("root");if(t3===null)throw Error("Builder dashboard root element is missing");V7(t3).render(T7(s3,{},void 0,!1,void 0,this));
|