@fabrika/builder 0.9.0-dev.10 → 0.9.0-dev.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/decisions/technologies/zerops-fabrika-auth.md +1 -1
- package/decisions/technologies/zerops-platform.md +1 -1
- package/package.json +9 -9
- package/types/shared/index.d.ts +27 -27
- package/ui/dist/assets/client.8aw2edb7.js +214 -0
- package/ui/dist/assets/components.js +21 -21
- package/ui/dist/index.html +1 -1
- package/ui/dist/assets/client.mh3w1dvc.js +0 -214
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
var Q8=Object.defineProperty;var X8=($)=>$;function W8($,J){this[$]=X8.bind(null,J)}var Y8=($,J)=>{for(var Q in J)Q8($,Q,{get:J[Q],enumerable:!0,configurable:!0,set:W8.bind(J,Q)})};import{createRoot as D7}from"react-dom/client";import{useEffect as a3,useMemo as m5,useRef as c5,useState as j1}from"react";import{useState as z9}from"react";import{AnnotationCtx as cX,AnnotationHostContext as uX,SessionContext as pX,useAnnotationHost as lX,useAnnotations as dX}from"@fabrika/annotations/runtime";function g2($,J){let Q=[],X=p5($);for(let W of X){let G=document.createRange();if(G.selectNodeContents(W),W===$.startContainer)G.setStart(W,$.startOffset);if(W===$.endContainer)G.setEnd(W,$.endOffset);let Y=G.toString();if(!Y||!Y.trim())continue;let q=document.createElement("mark");q.setAttribute("data-annotation-id",J);try{G.surroundContents(q)}catch{let H=G.extractContents();q.appendChild(H),G.insertNode(q)}Q.push(q)}return Q}function q2($){let J=$.parentElement;if(J?.classList.contains("select-none"))return!1;if(J?.closest("[data-annotation-id]"))return!1;return!0}function p5($){let J=[],Q=$.commonAncestorContainer;if(Q.nodeType===Node.TEXT_NODE)return J.push(Q),J;let X=document.createTreeWalker(Q,NodeFilter.SHOW_TEXT),W;while(W=X.nextNode()){if(!q2(W))continue;if($.intersectsNode(W))J.push(W)}return J}function G8($,J){let Q=document.createRange();if(Q.selectNodeContents($),$===J.startContainer)Q.setStart($,J.startOffset);if($===J.endContainer)Q.setEnd($,J.endOffset);return Q.toString()}function l5($){let J="";for(let Q of p5($))J+=G8(Q,$);return J}function V1($,J){let Q=document.querySelectorAll(`[data-annotation-id="${$}"]`);for(let X of Q)X.classList.toggle("mark-active",J)}function A$($,J){if(J!=null&&J!==$)V1(J,!1);if($!=null)V1($,!0)}function j$($,J){let Q=document.querySelectorAll(`[data-annotation-id="${$}"]`);for(let X of Q)X.setAttribute("data-annotation-id",J)}function V$($,J){for(let Q of J){if($.querySelector(`[data-annotation-id="${Q.id}"]`))continue;let X=Q.snippet;if(!X)continue;let{fullText:W,textNodes:G}=H8($),Y=[],q=0;while(!0){let w=W.indexOf(X,q);if(w===-1)break;Y.push(w),q=w+1}let[H]=Y;if(H===void 0)continue;let B=H;if(Y.length>1&&Q.context){let w=-1;for(let R of Y){let z=0;if(Q.context.before){let f=W.slice(Math.max(0,R-80),R);if(f.includes(Q.context.before))z+=2;else if(Q.context.before.length>10&&f.includes(Q.context.before.slice(-10)))z+=1}if(Q.context.after){let f=W.slice(R+X.length,R+X.length+80);if(f.includes(Q.context.after))z+=2;else if(Q.context.after.length>10&&f.includes(Q.context.after.slice(0,10)))z+=1}if(z>w)w=z,B=R}}let N=B,L=B+X.length,M=u5(G,N),F=u5(G,L);if(!M||!F)continue;try{let w=document.createRange();w.setStart(M.node,M.offset),w.setEnd(F.node,F.offset),g2(w,Q.id)}catch{}}}function H8($){let J=[],Q="",X=document.createTreeWalker($,NodeFilter.SHOW_TEXT),W;while(W=X.nextNode()){if(!q2(W))continue;J.push({node:W,start:Q.length}),Q+=W.textContent||""}return{fullText:Q,textNodes:J}}function u5($,J){for(let Q=$.length-1;Q>=0;Q--){let X=$[Q];if(!X||X.start>J)continue;let W=J-X.start,G=X.node.textContent?.length??0;if(W<=G)return{node:X.node,offset:W}}return null}function Z$($){let J=document.querySelectorAll(`[data-annotation-id="${$}"]`);for(let Q of J){let X=Q.parentNode;if(!X)continue;if(Q.tagName!=="MARK"){X.removeChild(Q);continue}while(Q.firstChild)X.insertBefore(Q.firstChild,Q);X.removeChild(Q),X.normalize()}}function T$($,J){let Q=d5($,"before",60),X=d5($,"after",60),W=U8($.startContainer,J);return{before:Q,after:X,hierarchy:W}}function d5($,J,Q){let X=q8(J==="before"?$.startContainer:$.endContainer);if(!X)return"";let W="";if(J==="before"){let G=document.createTreeWalker(X,NodeFilter.SHOW_TEXT),Y;while(Y=G.nextNode()){if(Y===$.startContainer){W+=(Y.textContent||"").slice(0,$.startOffset);break}if(!q2(Y))continue;W+=Y.textContent||""}if(W.length>Q){W=W.slice(-Q);let q=W.indexOf(" ");if(q>0)W=W.slice(q+1)}}else{let G=document.createTreeWalker(X,NodeFilter.SHOW_TEXT),Y=!1,q;while(q=G.nextNode()){if(q===$.endContainer){W+=(q.textContent||"").slice($.endOffset),Y=!0;continue}if(Y){if(!q2(q))continue;W+=q.textContent||""}}if(W.length>Q){W=W.slice(0,Q);let H=W.lastIndexOf(" ");if(H>0)W=W.slice(0,H)}}return W.trim()}function q8($){let J=new Set(["DIV","P","LI","PRE","BLOCKQUOTE","SECTION","ARTICLE"]),Q=$.parentElement;while(Q){if(J.has(Q.tagName))return Q;Q=Q.parentElement}return null}function U8($,J){let Q=[],X=$ instanceof Element?$:$.parentElement;while(X&&X!==J){let W=X.getAttribute?.("data-task-id");if(W){let Y=X.querySelector(".font-semibold");if(Y)Q.unshift(Y.textContent?.trim()||W)}let G=B8(X);if(G)Q.unshift(G);X=X.parentElement}return Q}function B8($){if($.getAttribute("data-md")==="section"){let Q=$.getAttribute("data-md-title");if(Q)return Q}if($.tagName!=="DIV")return null;return $.querySelector(":scope > button > .font-heading, :scope > div > .font-heading")?.textContent?.trim()||null}function E2($){let J=$.snippet.trim(),Q=$.context,X=J.length<30;if(Q&&X&&(Q.before||Q.after)){let W=[];if(Q.before)W.push(`...${Q.before} `);if(W.push(`**${J}**`),Q.after)W.push(` ${Q.after}...`);return W.join("")}return J}function U2($){return{kind:$.kind,owns:(J)=>$.parse(J)!==null,find:(J,Q)=>{let X=$.parse(J);return X===null?null:$.find(X,Q)},restore:(J,Q)=>{let X=$.parse(Q.snippet);if(X===null)return;$.restore?.(X,J,Q)},describe:(J)=>{let Q=$.parse(J);if(Q===null||!$.describe)return null;return $.describe(Q)}}}function i5($){let J=document.createTreeWalker($,NodeFilter.SHOW_TEXT),Q="";for(let X=J.nextNode();X;X=J.nextNode()){let W=X.parentElement?.closest("[aria-hidden='true']");if(W&&$.contains(W))continue;Q+=X.textContent??""}return Q.trim()}function y2($,J,Q){return{selector:$,snippet:(X)=>{let W=X.getAttribute(Q);return W?`${J} ${W}`:null}}}var D$=[y2("[data-md='item']","[Item]","data-md-label"),y2("[data-md='section']","[Section]","data-md-title"),y2("[data-md='checklist-item']","[Checklist]","data-md-label"),y2("[data-md='image']","[Image]","data-md-src"),{selector:"[data-md='callout']",snippet:($)=>{return`[Callout:${$.getAttribute("data-md-type")||"info"}] ${i5($).slice(0,60)||"Callout"}`}},{selector:"[data-md='note']",snippet:($)=>`[Note] ${i5($).slice(0,60)||"Note"}`},{selector:"[data-md='table'] tbody tr",snippet:($)=>{let J=Array.from($.querySelectorAll("td")).map((Q)=>Q.textContent?.trim()).filter(Boolean);return J.length?`[Row] ${J.join(" | ")}`:null}}],N8=["[data-md='choice-option']","[data-md='multichoice-option']","[data-md='userinput']","[data-md='rangeinput']"],e0=D$.map(($)=>$.selector).join(", "),Z1=[...D$.map(($)=>$.selector),...N8].join(", ");function h0($){for(let J of D$)if($.matches(J.selector))return J.snippet($);return null}var b$={kind:"block",parse:($)=>$.startsWith("[")?{snippet:$}:null,format:($)=>$.snippet,find:($,J)=>{for(let Q of J.querySelectorAll(e0)){if(!(Q instanceof HTMLElement))continue;if(h0(Q)===$.snippet)return Q}return null}};var g$="data-annotation-image",F8=/^\[Region:(rect|ellipse)\] ([\s\S]+) @(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*)$/;function w8($){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 r5($){return Math.min(1e4,Math.max(0,$))}function E$($,J,Q){if(!($.width>0)||!($.height>0))return null;return{x:r5(Math.round(J/$.width*1e4)),y:r5(Math.round(Q/$.height*1e4))}}function h2($,J){let Q=Math.min($.x,J.x),X=Math.min($.y,J.y);return{x:Q,y:X,w:Math.min(1e4-Q,Math.abs($.x-J.x)),h:Math.min(1e4-X,Math.abs($.y-J.y))}}function y$($){return $.w>=30&&$.h>=30}function n5($){return{left:`${$.x/100}%`,top:`${$.y/100}%`,width:`${$.w/100}%`,height:`${$.h/100}%`}}function v2($){return`${($/100).toFixed(1).replace(/\.0$/,"")}%`}function m2($){let J=`${v2($.x)}-${v2($.x+$.w)}`,Q=`${v2($.y)}-${v2($.y+$.h)}`;return`[Region] ${$.src} — ${$.shape} x ${J}, y ${Q} of the image`}function I$($,J){for(let Q of J.querySelectorAll("[data-md='image']")){if(!(Q instanceof HTMLElement))continue;if(Q.getAttribute("data-md-src")!==$)continue;let X=Q.querySelector("[data-annotation-image]");if(X instanceof HTMLElement)return X}return null}function c2($,J){let Q=n5(J);$.style.left=Q.left,$.style.top=Q.top,$.style.width=Q.width,$.style.height=Q.height}function u2($,J,Q){let X=document.createElement("div");return X.className="ann-region",X.setAttribute("data-annotation-id",Q),X.setAttribute("data-annotation-region",J),c2(X,$),X}var B2={kind:"region",parse:($)=>{let J=F8.exec($);if(!J)return null;let Q=w8(J[1]),X=J[2],W=x2(J[3]),G=x2(J[4]),Y=x2(J[5]),q=x2(J[6]);if(Q===null||X===void 0)return null;if(W===null||G===null||Y===null||q===null)return null;if(Y<1||q<1)return null;return{src:X,shape:Q,x:W,y:G,w:Y,h:q}},format:($)=>`[Region:${$.shape}] ${$.src} @${$.x},${$.y},${$.w},${$.h}`,find:($,J)=>I$($.src,J),restore:($,J,Q)=>{if(J.querySelector(`[data-annotation-id="${Q.id}"]`))return;let X=I$($.src,J);if(!X)return;X.appendChild(u2($,$.shape,Q.id))},describe:m2};var x$={kind:"text",parse:($)=>$?{text:$}:null,format:($)=>$.text,find:()=>null,restore:($,J,Q)=>{V$(J,[Q])}};var p2=[U2(B2),U2(b$),U2(x$)];function v$($,J){for(let Q of p2){let X=Q.find($,J);if(X)return X}return null}function h$($,J){for(let Q of J){if(!Q.snippet)continue;for(let X of p2)X.restore($,Q)}}function N2($){for(let J of p2){let Q=J.describe($);if(Q!==null)return Q}return $}import{AnnotationCtx as jQ,SessionContext as VQ,useAnnotationHost as ZQ}from"@fabrika/annotations/runtime";import{useEffect as bQ,useRef as IQ,useState as gQ}from"react";var U={};Y8(U,{void:()=>t8,util:()=>o,unknown:()=>o8,union:()=>J6,undefined:()=>i8,tuple:()=>W6,transformer:()=>L6,symbol:()=>d8,string:()=>X4,strictObject:()=>$6,setErrorMap:()=>_8,set:()=>H6,record:()=>Y6,quotelessJson:()=>L8,promise:()=>w6,preprocess:()=>z6,pipeline:()=>K6,ostring:()=>f6,optional:()=>M6,onumber:()=>O6,oboolean:()=>S6,objectUtil:()=>m$,object:()=>e8,number:()=>W4,nullable:()=>_6,null:()=>r8,never:()=>s8,nativeEnum:()=>F6,nan:()=>u8,map:()=>G6,makeIssue:()=>F2,literal:()=>B6,lazy:()=>U6,late:()=>m8,isValid:()=>$1,isDirty:()=>d2,isAsync:()=>D1,isAborted:()=>l2,intersection:()=>X6,instanceof:()=>c8,getParsedType:()=>m0,getErrorMap:()=>T1,function:()=>q6,enum:()=>N6,effect:()=>L6,discriminatedUnion:()=>Q6,defaultErrorMap:()=>i0,datetimeRegex:()=>$4,date:()=>l8,custom:()=>Q4,coerce:()=>R6,boolean:()=>Y4,bigint:()=>p8,array:()=>a8,any:()=>n8,addIssueToContext:()=>P,ZodVoid:()=>L2,ZodUnknown:()=>J1,ZodUnion:()=>x1,ZodUndefined:()=>E1,ZodType:()=>n,ZodTuple:()=>u0,ZodTransformer:()=>g0,ZodSymbol:()=>w2,ZodString:()=>T0,ZodSet:()=>w1,ZodSchema:()=>n,ZodRecord:()=>M2,ZodReadonly:()=>l1,ZodPromise:()=>L1,ZodPipeline:()=>K2,ZodParsedType:()=>S,ZodOptional:()=>b0,ZodObject:()=>N0,ZodNumber:()=>Q1,ZodNullable:()=>n0,ZodNull:()=>y1,ZodNever:()=>c0,ZodNativeEnum:()=>c1,ZodNaN:()=>z2,ZodMap:()=>_2,ZodLiteral:()=>m1,ZodLazy:()=>h1,ZodIssueCode:()=>K,ZodIntersection:()=>v1,ZodFunction:()=>I1,ZodFirstPartyTypeKind:()=>v,ZodError:()=>P0,ZodEnum:()=>W1,ZodEffects:()=>g0,ZodDiscriminatedUnion:()=>i2,ZodDefault:()=>u1,ZodDate:()=>N1,ZodCatch:()=>p1,ZodBranded:()=>r2,ZodBoolean:()=>g1,ZodBigInt:()=>X1,ZodArray:()=>D0,ZodAny:()=>F1,Schema:()=>n,ParseStatus:()=>f0,OK:()=>O0,NEVER:()=>C6,INVALID:()=>x,EMPTY_PATH:()=>z8,DIRTY:()=>B1,BRAND:()=>h8});var o;(function($){$.assertEqual=(W)=>{};function J(W){}$.assertIs=J;function Q(W){throw Error()}$.assertNever=Q,$.arrayToEnum=(W)=>{let G={};for(let Y of W)G[Y]=Y;return G},$.getValidEnumValues=(W)=>{let G=$.objectKeys(W).filter((q)=>typeof W[W[q]]!=="number"),Y={};for(let q of G)Y[q]=W[q];return $.objectValues(Y)},$.objectValues=(W)=>{return $.objectKeys(W).map(function(G){return W[G]})},$.objectKeys=typeof Object.keys==="function"?(W)=>Object.keys(W):(W)=>{let G=[];for(let Y in W)if(Object.prototype.hasOwnProperty.call(W,Y))G.push(Y);return G},$.find=(W,G)=>{for(let Y of W)if(G(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 X(W,G=" | "){return W.map((Y)=>typeof Y==="string"?`'${Y}'`:Y).join(G)}$.joinValues=X,$.jsonStringifyReplacer=(W,G)=>{if(typeof G==="bigint")return G.toString();return G}})(o||(o={}));var m$;(function($){$.mergeShapes=(J,Q)=>{return{...J,...Q}}})(m$||(m$={}));var S=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 S.undefined;case"string":return S.string;case"number":return Number.isNaN($)?S.nan:S.number;case"boolean":return S.boolean;case"function":return S.function;case"bigint":return S.bigint;case"symbol":return S.symbol;case"object":if(Array.isArray($))return S.array;if($===null)return S.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return S.promise;if(typeof Map<"u"&&$ instanceof Map)return S.map;if(typeof Set<"u"&&$ instanceof Set)return S.set;if(typeof Date<"u"&&$ instanceof Date)return S.date;return S.object;default:return S.unknown}};var K=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"]),L8=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class P0 extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(Q)=>{this.issues=[...this.issues,Q]},this.addIssues=(Q=[])=>{this.issues=[...this.issues,...Q]};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},Q={_errors:[]},X=(W)=>{for(let G of W.issues)if(G.code==="invalid_union")G.unionErrors.map(X);else if(G.code==="invalid_return_type")X(G.returnTypeError);else if(G.code==="invalid_arguments")X(G.argumentsError);else if(G.path.length===0)Q._errors.push(J(G));else{let Y=Q,q=0;while(q<G.path.length){let H=G.path[q];if(q!==G.path.length-1)Y[H]=Y[H]||{_errors:[]};else Y[H]=Y[H]||{_errors:[]},Y[H]._errors.push(J(G));Y=Y[H],q++}}};return X(this),Q}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={},Q=[];for(let X of this.issues)if(X.path.length>0){let W=X.path[0];J[W]=J[W]||[],J[W].push($(X))}else Q.push($(X));return{formErrors:Q,fieldErrors:J}}get formErrors(){return this.flatten()}}P0.create=($)=>{return new P0($)};var M8=($,J)=>{let Q;switch($.code){case K.invalid_type:if($.received===S.undefined)Q="Required";else Q=`Expected ${$.expected}, received ${$.received}`;break;case K.invalid_literal:Q=`Invalid literal value, expected ${JSON.stringify($.expected,o.jsonStringifyReplacer)}`;break;case K.unrecognized_keys:Q=`Unrecognized key(s) in object: ${o.joinValues($.keys,", ")}`;break;case K.invalid_union:Q="Invalid input";break;case K.invalid_union_discriminator:Q=`Invalid discriminator value. Expected ${o.joinValues($.options)}`;break;case K.invalid_enum_value:Q=`Invalid enum value. Expected ${o.joinValues($.options)}, received '${$.received}'`;break;case K.invalid_arguments:Q="Invalid function arguments";break;case K.invalid_return_type:Q="Invalid function return type";break;case K.invalid_date:Q="Invalid date";break;case K.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(Q=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")Q=`${Q} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)Q=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)Q=`Invalid input: must end with "${$.validation.endsWith}"`;else o.assertNever($.validation);else if($.validation!=="regex")Q=`Invalid ${$.validation}`;else Q="Invalid";break;case K.too_small:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else Q="Invalid input";break;case K.too_big:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")Q=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else Q="Invalid input";break;case K.custom:Q="Invalid input";break;case K.invalid_intersection_types:Q="Intersection results could not be merged";break;case K.not_multiple_of:Q=`Number must be a multiple of ${$.multipleOf}`;break;case K.not_finite:Q="Number must be finite";break;default:Q=J.defaultError,o.assertNever($)}return{message:Q}},i0=M8;var o5=i0;function _8($){o5=$}function T1(){return o5}var F2=($)=>{let{data:J,path:Q,errorMaps:X,issueData:W}=$,G=[...Q,...W.path||[]],Y={...W,path:G};if(W.message!==void 0)return{...W,path:G,message:W.message};let q="",H=X.filter((B)=>!!B).slice().reverse();for(let B of H)q=B(Y,{data:J,defaultError:q}).message;return{...W,path:G,message:q}},z8=[];function P($,J){let Q=T1(),X=F2({issueData:J,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,Q,Q===i0?void 0:i0].filter((W)=>!!W)});$.common.issues.push(X)}class f0{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,J){let Q=[];for(let X of J){if(X.status==="aborted")return x;if(X.status==="dirty")$.dirty();Q.push(X.value)}return{status:$.value,value:Q}}static async mergeObjectAsync($,J){let Q=[];for(let X of J){let W=await X.key,G=await X.value;Q.push({key:W,value:G})}return f0.mergeObjectSync($,Q)}static mergeObjectSync($,J){let Q={};for(let X of J){let{key:W,value:G}=X;if(W.status==="aborted")return x;if(G.status==="aborted")return x;if(W.status==="dirty")$.dirty();if(G.status==="dirty")$.dirty();if(W.value!=="__proto__"&&(typeof G.value<"u"||X.alwaysSet))Q[W.value]=G.value}return{status:$.value,value:Q}}}var x=Object.freeze({status:"aborted"}),B1=($)=>({status:"dirty",value:$}),O0=($)=>({status:"valid",value:$}),l2=($)=>$.status==="aborted",d2=($)=>$.status==="dirty",$1=($)=>$.status==="valid",D1=($)=>typeof Promise<"u"&&$ instanceof Promise;var D;(function($){$.errToObj=(J)=>typeof J==="string"?{message:J}:J||{},$.toString=(J)=>typeof J==="string"?J:J?.message})(D||(D={}));class I0{constructor($,J,Q,X){this._cachedPath=[],this.parent=$,this.data=J,this._path=Q,this._key=X}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var s5=($,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 Q=new P0($.common.issues);return this._error=Q,this._error}}}};function u($){if(!$)return{};let{errorMap:J,invalid_type_error:Q,required_error:X,description:W}=$;if(J&&(Q||X))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,q)=>{let{message:H}=$;if(Y.code==="invalid_enum_value")return{message:H??q.defaultError};if(typeof q.data>"u")return{message:H??X??q.defaultError};if(Y.code!=="invalid_type")return{message:q.defaultError};return{message:H??Q??q.defaultError}},description:W}}class n{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 f0,ctx:{common:$.parent.common,data:$.data,parsedType:m0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let J=this._parse($);if(D1(J))throw Error("Synchronous parse encountered promise.");return J}_parseAsync($){let J=this._parse($);return Promise.resolve(J)}parse($,J){let Q=this.safeParse($,J);if(Q.success)return Q.data;throw Q.error}safeParse($,J){let Q={common:{issues:[],async:J?.async??!1,contextualErrorMap:J?.errorMap},path:J?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:m0($)},X=this._parseSync({data:$,path:Q.path,parent:Q});return s5(Q,X)}"~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 Q=this._parseSync({data:$,path:[],parent:J});return $1(Q)?{value:Q.value}:{issues:J.common.issues}}catch(Q){if(Q?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;J.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:J}).then((Q)=>$1(Q)?{value:Q.value}:{issues:J.common.issues})}async parseAsync($,J){let Q=await this.safeParseAsync($,J);if(Q.success)return Q.data;throw Q.error}async safeParseAsync($,J){let Q={common:{issues:[],contextualErrorMap:J?.errorMap,async:!0},path:J?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:m0($)},X=this._parse({data:$,path:Q.path,parent:Q}),W=await(D1(X)?X:Promise.resolve(X));return s5(Q,W)}refine($,J){let Q=(X)=>{if(typeof J==="string"||typeof J>"u")return{message:J};else if(typeof J==="function")return J(X);else return J};return this._refinement((X,W)=>{let G=$(X),Y=()=>W.addIssue({code:K.custom,...Q(X)});if(typeof Promise<"u"&&G instanceof Promise)return G.then((q)=>{if(!q)return Y(),!1;else return!0});if(!G)return Y(),!1;else return!0})}refinement($,J){return this._refinement((Q,X)=>{if(!$(Q))return X.addIssue(typeof J==="function"?J(Q,X):J),!1;else return!0})}_refinement($){return new g0({schema:this,typeName:v.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 b0.create(this,this._def)}nullable(){return n0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return D0.create(this)}promise(){return L1.create(this,this._def)}or($){return x1.create([this,$],this._def)}and($){return v1.create(this,$,this._def)}transform($){return new g0({...u(this._def),schema:this,typeName:v.ZodEffects,effect:{type:"transform",transform:$}})}default($){let J=typeof $==="function"?$:()=>$;return new u1({...u(this._def),innerType:this,defaultValue:J,typeName:v.ZodDefault})}brand(){return new r2({typeName:v.ZodBranded,type:this,...u(this._def)})}catch($){let J=typeof $==="function"?$:()=>$;return new p1({...u(this._def),innerType:this,catchValue:J,typeName:v.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 K8=/^c[^\s-]{8,}$/i,f8=/^[0-9a-z]+$/,O8=/^[0-9A-HJKMNP-TV-Z]{26}$/i,S8=/^[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,R8=/^[a-z0-9_-]{21}$/i,C8=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,P8=/^[-+]?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)?)??$/,k8=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,A8="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",c$,j8=/^(?:(?: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])$/,V8=/^(?:(?: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])$/,Z8=/^(([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]))$/,T8=/^(([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])$/,D8=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,b8=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,a5="((\\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])))",I8=new RegExp(`^${a5}$`);function e5($){let J="[0-5]\\d";if($.precision)J=`${J}\\.\\d{${$.precision}}`;else if($.precision==null)J=`${J}(\\.\\d+)?`;let Q=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${J})${Q}`}function g8($){return new RegExp(`^${e5($)}$`)}function $4($){let J=`${a5}T${e5($)}`,Q=[];if(Q.push($.local?"Z?":"Z"),$.offset)Q.push("([+-]\\d{2}:?\\d{2})");return J=`${J}(${Q.join("|")})`,new RegExp(`^${J}$`)}function E8($,J){if((J==="v4"||!J)&&j8.test($))return!0;if((J==="v6"||!J)&&Z8.test($))return!0;return!1}function y8($,J){if(!C8.test($))return!1;try{let[Q]=$.split(".");if(!Q)return!1;let X=Q.replace(/-/g,"+").replace(/_/g,"/").padEnd(Q.length+(4-Q.length%4)%4,"="),W=JSON.parse(atob(X));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 x8($,J){if((J==="v4"||!J)&&V8.test($))return!0;if((J==="v6"||!J)&&T8.test($))return!0;return!1}class T0 extends n{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==S.string){let W=this._getOrReturnCtx($);return P(W,{code:K.invalid_type,expected:S.string,received:W.parsedType}),x}let Q=new f0,X=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.length<W.value)X=this._getOrReturnCtx($,X),P(X,{code:K.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="max"){if($.data.length>W.value)X=this._getOrReturnCtx($,X),P(X,{code:K.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="length"){let G=$.data.length>W.value,Y=$.data.length<W.value;if(G||Y){if(X=this._getOrReturnCtx($,X),G)P(X,{code:K.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});else if(Y)P(X,{code:K.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});Q.dirty()}}else if(W.kind==="email"){if(!k8.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"email",code:K.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="emoji"){if(!c$)c$=new RegExp(A8,"u");if(!c$.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"emoji",code:K.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="uuid"){if(!S8.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"uuid",code:K.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="nanoid"){if(!R8.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"nanoid",code:K.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cuid"){if(!K8.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"cuid",code:K.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cuid2"){if(!f8.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"cuid2",code:K.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="ulid"){if(!O8.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"ulid",code:K.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="url")try{new URL($.data)}catch{X=this._getOrReturnCtx($,X),P(X,{validation:"url",code:K.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="regex"){if(W.regex.lastIndex=0,!W.regex.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"regex",code:K.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="trim")$.data=$.data.trim();else if(W.kind==="includes"){if(!$.data.includes(W.value,W.position))X=this._getOrReturnCtx($,X),P(X,{code:K.invalid_string,validation:{includes:W.value,position:W.position},message:W.message}),Q.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))X=this._getOrReturnCtx($,X),P(X,{code:K.invalid_string,validation:{startsWith:W.value},message:W.message}),Q.dirty()}else if(W.kind==="endsWith"){if(!$.data.endsWith(W.value))X=this._getOrReturnCtx($,X),P(X,{code:K.invalid_string,validation:{endsWith:W.value},message:W.message}),Q.dirty()}else if(W.kind==="datetime"){if(!$4(W).test($.data))X=this._getOrReturnCtx($,X),P(X,{code:K.invalid_string,validation:"datetime",message:W.message}),Q.dirty()}else if(W.kind==="date"){if(!I8.test($.data))X=this._getOrReturnCtx($,X),P(X,{code:K.invalid_string,validation:"date",message:W.message}),Q.dirty()}else if(W.kind==="time"){if(!g8(W).test($.data))X=this._getOrReturnCtx($,X),P(X,{code:K.invalid_string,validation:"time",message:W.message}),Q.dirty()}else if(W.kind==="duration"){if(!P8.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"duration",code:K.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="ip"){if(!E8($.data,W.version))X=this._getOrReturnCtx($,X),P(X,{validation:"ip",code:K.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="jwt"){if(!y8($.data,W.alg))X=this._getOrReturnCtx($,X),P(X,{validation:"jwt",code:K.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cidr"){if(!x8($.data,W.version))X=this._getOrReturnCtx($,X),P(X,{validation:"cidr",code:K.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="base64"){if(!D8.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"base64",code:K.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="base64url"){if(!b8.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"base64url",code:K.invalid_string,message:W.message}),Q.dirty()}else o.assertNever(W);return{status:Q.value,value:$.data}}_regex($,J,Q){return this.refinement((X)=>$.test(X),{validation:J,code:K.invalid_string,...D.errToObj(Q)})}_addCheck($){return new T0({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...D.errToObj($)})}url($){return this._addCheck({kind:"url",...D.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...D.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...D.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...D.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...D.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...D.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...D.errToObj($)})}base64($){return this._addCheck({kind:"base64",...D.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...D.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...D.errToObj($)})}ip($){return this._addCheck({kind:"ip",...D.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...D.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,...D.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,...D.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...D.errToObj($)})}regex($,J){return this._addCheck({kind:"regex",regex:$,...D.errToObj(J)})}includes($,J){return this._addCheck({kind:"includes",value:$,position:J?.position,...D.errToObj(J?.message)})}startsWith($,J){return this._addCheck({kind:"startsWith",value:$,...D.errToObj(J)})}endsWith($,J){return this._addCheck({kind:"endsWith",value:$,...D.errToObj(J)})}min($,J){return this._addCheck({kind:"min",value:$,...D.errToObj(J)})}max($,J){return this._addCheck({kind:"max",value:$,...D.errToObj(J)})}length($,J){return this._addCheck({kind:"length",value:$,...D.errToObj(J)})}nonempty($){return this.min(1,D.errToObj($))}trim(){return new T0({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new T0({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new T0({...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 $}}T0.create=($)=>{return new T0({checks:[],typeName:v.ZodString,coerce:$?.coerce??!1,...u($)})};function v8($,J){let Q=($.toString().split(".")[1]||"").length,X=(J.toString().split(".")[1]||"").length,W=Q>X?Q:X,G=Number.parseInt($.toFixed(W).replace(".","")),Y=Number.parseInt(J.toFixed(W).replace(".",""));return G%Y/10**W}class Q1 extends n{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==S.number){let W=this._getOrReturnCtx($);return P(W,{code:K.invalid_type,expected:S.number,received:W.parsedType}),x}let Q=void 0,X=new f0;for(let W of this._def.checks)if(W.kind==="int"){if(!o.isInteger($.data))Q=this._getOrReturnCtx($,Q),P(Q,{code:K.invalid_type,expected:"integer",received:"float",message:W.message}),X.dirty()}else if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)Q=this._getOrReturnCtx($,Q),P(Q,{code:K.too_small,minimum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),X.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)Q=this._getOrReturnCtx($,Q),P(Q,{code:K.too_big,maximum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),X.dirty()}else if(W.kind==="multipleOf"){if(v8($.data,W.value)!==0)Q=this._getOrReturnCtx($,Q),P(Q,{code:K.not_multiple_of,multipleOf:W.value,message:W.message}),X.dirty()}else if(W.kind==="finite"){if(!Number.isFinite($.data))Q=this._getOrReturnCtx($,Q),P(Q,{code:K.not_finite,message:W.message}),X.dirty()}else o.assertNever(W);return{status:X.value,value:$.data}}gte($,J){return this.setLimit("min",$,!0,D.toString(J))}gt($,J){return this.setLimit("min",$,!1,D.toString(J))}lte($,J){return this.setLimit("max",$,!0,D.toString(J))}lt($,J){return this.setLimit("max",$,!1,D.toString(J))}setLimit($,J,Q,X){return new Q1({...this._def,checks:[...this._def.checks,{kind:$,value:J,inclusive:Q,message:D.toString(X)}]})}_addCheck($){return new Q1({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:D.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:D.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:D.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:D.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:D.toString($)})}multipleOf($,J){return this._addCheck({kind:"multipleOf",value:$,message:D.toString(J)})}finite($){return this._addCheck({kind:"finite",message:D.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:D.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:D.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 Q of this._def.checks)if(Q.kind==="finite"||Q.kind==="int"||Q.kind==="multipleOf")return!0;else if(Q.kind==="min"){if(J===null||Q.value>J)J=Q.value}else if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return Number.isFinite(J)&&Number.isFinite($)}}Q1.create=($)=>{return new Q1({checks:[],typeName:v.ZodNumber,coerce:$?.coerce||!1,...u($)})};class X1 extends n{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==S.bigint)return this._getInvalidInput($);let Q=void 0,X=new f0;for(let W of this._def.checks)if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)Q=this._getOrReturnCtx($,Q),P(Q,{code:K.too_small,type:"bigint",minimum:W.value,inclusive:W.inclusive,message:W.message}),X.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)Q=this._getOrReturnCtx($,Q),P(Q,{code:K.too_big,type:"bigint",maximum:W.value,inclusive:W.inclusive,message:W.message}),X.dirty()}else if(W.kind==="multipleOf"){if($.data%W.value!==BigInt(0))Q=this._getOrReturnCtx($,Q),P(Q,{code:K.not_multiple_of,multipleOf:W.value,message:W.message}),X.dirty()}else o.assertNever(W);return{status:X.value,value:$.data}}_getInvalidInput($){let J=this._getOrReturnCtx($);return P(J,{code:K.invalid_type,expected:S.bigint,received:J.parsedType}),x}gte($,J){return this.setLimit("min",$,!0,D.toString(J))}gt($,J){return this.setLimit("min",$,!1,D.toString(J))}lte($,J){return this.setLimit("max",$,!0,D.toString(J))}lt($,J){return this.setLimit("max",$,!1,D.toString(J))}setLimit($,J,Q,X){return new X1({...this._def,checks:[...this._def.checks,{kind:$,value:J,inclusive:Q,message:D.toString(X)}]})}_addCheck($){return new X1({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:D.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:D.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:D.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:D.toString($)})}multipleOf($,J){return this._addCheck({kind:"multipleOf",value:$,message:D.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 $}}X1.create=($)=>{return new X1({checks:[],typeName:v.ZodBigInt,coerce:$?.coerce??!1,...u($)})};class g1 extends n{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==S.boolean){let Q=this._getOrReturnCtx($);return P(Q,{code:K.invalid_type,expected:S.boolean,received:Q.parsedType}),x}return O0($.data)}}g1.create=($)=>{return new g1({typeName:v.ZodBoolean,coerce:$?.coerce||!1,...u($)})};class N1 extends n{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==S.date){let W=this._getOrReturnCtx($);return P(W,{code:K.invalid_type,expected:S.date,received:W.parsedType}),x}if(Number.isNaN($.data.getTime())){let W=this._getOrReturnCtx($);return P(W,{code:K.invalid_date}),x}let Q=new f0,X=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.getTime()<W.value)X=this._getOrReturnCtx($,X),P(X,{code:K.too_small,message:W.message,inclusive:!0,exact:!1,minimum:W.value,type:"date"}),Q.dirty()}else if(W.kind==="max"){if($.data.getTime()>W.value)X=this._getOrReturnCtx($,X),P(X,{code:K.too_big,message:W.message,inclusive:!0,exact:!1,maximum:W.value,type:"date"}),Q.dirty()}else o.assertNever(W);return{status:Q.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:D.toString(J)})}max($,J){return this._addCheck({kind:"max",value:$.getTime(),message:D.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:v.ZodDate,...u($)})};class w2 extends n{_parse($){if(this._getType($)!==S.symbol){let Q=this._getOrReturnCtx($);return P(Q,{code:K.invalid_type,expected:S.symbol,received:Q.parsedType}),x}return O0($.data)}}w2.create=($)=>{return new w2({typeName:v.ZodSymbol,...u($)})};class E1 extends n{_parse($){if(this._getType($)!==S.undefined){let Q=this._getOrReturnCtx($);return P(Q,{code:K.invalid_type,expected:S.undefined,received:Q.parsedType}),x}return O0($.data)}}E1.create=($)=>{return new E1({typeName:v.ZodUndefined,...u($)})};class y1 extends n{_parse($){if(this._getType($)!==S.null){let Q=this._getOrReturnCtx($);return P(Q,{code:K.invalid_type,expected:S.null,received:Q.parsedType}),x}return O0($.data)}}y1.create=($)=>{return new y1({typeName:v.ZodNull,...u($)})};class F1 extends n{constructor(){super(...arguments);this._any=!0}_parse($){return O0($.data)}}F1.create=($)=>{return new F1({typeName:v.ZodAny,...u($)})};class J1 extends n{constructor(){super(...arguments);this._unknown=!0}_parse($){return O0($.data)}}J1.create=($)=>{return new J1({typeName:v.ZodUnknown,...u($)})};class c0 extends n{_parse($){let J=this._getOrReturnCtx($);return P(J,{code:K.invalid_type,expected:S.never,received:J.parsedType}),x}}c0.create=($)=>{return new c0({typeName:v.ZodNever,...u($)})};class L2 extends n{_parse($){if(this._getType($)!==S.undefined){let Q=this._getOrReturnCtx($);return P(Q,{code:K.invalid_type,expected:S.void,received:Q.parsedType}),x}return O0($.data)}}L2.create=($)=>{return new L2({typeName:v.ZodVoid,...u($)})};class D0 extends n{_parse($){let{ctx:J,status:Q}=this._processInputParams($),X=this._def;if(J.parsedType!==S.array)return P(J,{code:K.invalid_type,expected:S.array,received:J.parsedType}),x;if(X.exactLength!==null){let G=J.data.length>X.exactLength.value,Y=J.data.length<X.exactLength.value;if(G||Y)P(J,{code:G?K.too_big:K.too_small,minimum:Y?X.exactLength.value:void 0,maximum:G?X.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:X.exactLength.message}),Q.dirty()}if(X.minLength!==null){if(J.data.length<X.minLength.value)P(J,{code:K.too_small,minimum:X.minLength.value,type:"array",inclusive:!0,exact:!1,message:X.minLength.message}),Q.dirty()}if(X.maxLength!==null){if(J.data.length>X.maxLength.value)P(J,{code:K.too_big,maximum:X.maxLength.value,type:"array",inclusive:!0,exact:!1,message:X.maxLength.message}),Q.dirty()}if(J.common.async)return Promise.all([...J.data].map((G,Y)=>{return X.type._parseAsync(new I0(J,G,J.path,Y))})).then((G)=>{return f0.mergeArray(Q,G)});let W=[...J.data].map((G,Y)=>{return X.type._parseSync(new I0(J,G,J.path,Y))});return f0.mergeArray(Q,W)}get element(){return this._def.type}min($,J){return new D0({...this._def,minLength:{value:$,message:D.toString(J)}})}max($,J){return new D0({...this._def,maxLength:{value:$,message:D.toString(J)}})}length($,J){return new D0({...this._def,exactLength:{value:$,message:D.toString(J)}})}nonempty($){return this.min(1,$)}}D0.create=($,J)=>{return new D0({type:$,minLength:null,maxLength:null,exactLength:null,typeName:v.ZodArray,...u(J)})};function b1($){if($ instanceof N0){let J={};for(let Q in $.shape){let X=$.shape[Q];J[Q]=b0.create(b1(X))}return new N0({...$._def,shape:()=>J})}else if($ instanceof D0)return new D0({...$._def,type:b1($.element)});else if($ instanceof b0)return b0.create(b1($.unwrap()));else if($ instanceof n0)return n0.create(b1($.unwrap()));else if($ instanceof u0)return u0.create($.items.map((J)=>b1(J)));else return $}class N0 extends n{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($)!==S.object){let H=this._getOrReturnCtx($);return P(H,{code:K.invalid_type,expected:S.object,received:H.parsedType}),x}let{status:Q,ctx:X}=this._processInputParams($),{shape:W,keys:G}=this._getCached(),Y=[];if(!(this._def.catchall instanceof c0&&this._def.unknownKeys==="strip")){for(let H in X.data)if(!G.includes(H))Y.push(H)}let q=[];for(let H of G){let B=W[H],N=X.data[H];q.push({key:{status:"valid",value:H},value:B._parse(new I0(X,N,X.path,H)),alwaysSet:H in X.data})}if(this._def.catchall instanceof c0){let H=this._def.unknownKeys;if(H==="passthrough")for(let B of Y)q.push({key:{status:"valid",value:B},value:{status:"valid",value:X.data[B]}});else if(H==="strict"){if(Y.length>0)P(X,{code:K.unrecognized_keys,keys:Y}),Q.dirty()}else if(H==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let H=this._def.catchall;for(let B of Y){let N=X.data[B];q.push({key:{status:"valid",value:B},value:H._parse(new I0(X,N,X.path,B)),alwaysSet:B in X.data})}}if(X.common.async)return Promise.resolve().then(async()=>{let H=[];for(let B of q){let N=await B.key,L=await B.value;H.push({key:N,value:L,alwaysSet:B.alwaysSet})}return H}).then((H)=>{return f0.mergeObjectSync(Q,H)});else return f0.mergeObjectSync(Q,q)}get shape(){return this._def.shape()}strict($){return D.errToObj,new N0({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(J,Q)=>{let X=this._def.errorMap?.(J,Q).message??Q.defaultError;if(J.code==="unrecognized_keys")return{message:D.errToObj($).message??X};return{message:X}}}:{}})}strip(){return new N0({...this._def,unknownKeys:"strip"})}passthrough(){return new N0({...this._def,unknownKeys:"passthrough"})}extend($){return new N0({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new N0({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:v.ZodObject})}setKey($,J){return this.augment({[$]:J})}catchall($){return new N0({...this._def,catchall:$})}pick($){let J={};for(let Q of o.objectKeys($))if($[Q]&&this.shape[Q])J[Q]=this.shape[Q];return new N0({...this._def,shape:()=>J})}omit($){let J={};for(let Q of o.objectKeys(this.shape))if(!$[Q])J[Q]=this.shape[Q];return new N0({...this._def,shape:()=>J})}deepPartial(){return b1(this)}partial($){let J={};for(let Q of o.objectKeys(this.shape)){let X=this.shape[Q];if($&&!$[Q])J[Q]=X;else J[Q]=X.optional()}return new N0({...this._def,shape:()=>J})}required($){let J={};for(let Q of o.objectKeys(this.shape))if($&&!$[Q])J[Q]=this.shape[Q];else{let W=this.shape[Q];while(W instanceof b0)W=W._def.innerType;J[Q]=W}return new N0({...this._def,shape:()=>J})}keyof(){return J4(o.objectKeys(this.shape))}}N0.create=($,J)=>{return new N0({shape:()=>$,unknownKeys:"strip",catchall:c0.create(),typeName:v.ZodObject,...u(J)})};N0.strictCreate=($,J)=>{return new N0({shape:()=>$,unknownKeys:"strict",catchall:c0.create(),typeName:v.ZodObject,...u(J)})};N0.lazycreate=($,J)=>{return new N0({shape:$,unknownKeys:"strip",catchall:c0.create(),typeName:v.ZodObject,...u(J)})};class x1 extends n{_parse($){let{ctx:J}=this._processInputParams($),Q=this._def.options;function X(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 G=W.map((Y)=>new P0(Y.ctx.common.issues));return P(J,{code:K.invalid_union,unionErrors:G}),x}if(J.common.async)return Promise.all(Q.map(async(W)=>{let G={...J,common:{...J.common,issues:[]},parent:null};return{result:await W._parseAsync({data:J.data,path:J.path,parent:G}),ctx:G}})).then(X);else{let W=void 0,G=[];for(let q of Q){let H={...J,common:{...J.common,issues:[]},parent:null},B=q._parseSync({data:J.data,path:J.path,parent:H});if(B.status==="valid")return B;else if(B.status==="dirty"&&!W)W={result:B,ctx:H};if(H.common.issues.length)G.push(H.common.issues)}if(W)return J.common.issues.push(...W.ctx.common.issues),W.result;let Y=G.map((q)=>new P0(q));return P(J,{code:K.invalid_union,unionErrors:Y}),x}}get options(){return this._def.options}}x1.create=($,J)=>{return new x1({options:$,typeName:v.ZodUnion,...u(J)})};var r0=($)=>{if($ instanceof h1)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 E1)return[void 0];else if($ instanceof y1)return[null];else if($ instanceof b0)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 n{_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==S.object)return P(J,{code:K.invalid_type,expected:S.object,received:J.parsedType}),x;let Q=this.discriminator,X=J.data[Q],W=this.optionsMap.get(X);if(!W)return P(J,{code:K.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[Q]}),x;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,Q){let X=new Map;for(let W of J){let G=r0(W.shape[$]);if(!G.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let Y of G){if(X.has(Y))throw Error(`Discriminator property ${String($)} has duplicate value ${String(Y)}`);X.set(Y,W)}}return new i2({typeName:v.ZodDiscriminatedUnion,discriminator:$,options:J,optionsMap:X,...u(Q)})}}function u$($,J){let Q=m0($),X=m0(J);if($===J)return{valid:!0,data:$};else if(Q===S.object&&X===S.object){let W=o.objectKeys(J),G=o.objectKeys($).filter((q)=>W.indexOf(q)!==-1),Y={...$,...J};for(let q of G){let H=u$($[q],J[q]);if(!H.valid)return{valid:!1};Y[q]=H.data}return{valid:!0,data:Y}}else if(Q===S.array&&X===S.array){if($.length!==J.length)return{valid:!1};let W=[];for(let G=0;G<$.length;G++){let Y=$[G],q=J[G],H=u$(Y,q);if(!H.valid)return{valid:!1};W.push(H.data)}return{valid:!0,data:W}}else if(Q===S.date&&X===S.date&&+$===+J)return{valid:!0,data:$};else return{valid:!1}}class v1 extends n{_parse($){let{status:J,ctx:Q}=this._processInputParams($),X=(W,G)=>{if(l2(W)||l2(G))return x;let Y=u$(W.value,G.value);if(!Y.valid)return P(Q,{code:K.invalid_intersection_types}),x;if(d2(W)||d2(G))J.dirty();return{status:J.value,value:Y.data}};if(Q.common.async)return Promise.all([this._def.left._parseAsync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseAsync({data:Q.data,path:Q.path,parent:Q})]).then(([W,G])=>X(W,G));else return X(this._def.left._parseSync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseSync({data:Q.data,path:Q.path,parent:Q}))}}v1.create=($,J,Q)=>{return new v1({left:$,right:J,typeName:v.ZodIntersection,...u(Q)})};class u0 extends n{_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==S.array)return P(Q,{code:K.invalid_type,expected:S.array,received:Q.parsedType}),x;if(Q.data.length<this._def.items.length)return P(Q,{code:K.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;if(!this._def.rest&&Q.data.length>this._def.items.length)P(Q,{code:K.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),J.dirty();let W=[...Q.data].map((G,Y)=>{let q=this._def.items[Y]||this._def.rest;if(!q)return null;return q._parse(new I0(Q,G,Q.path,Y))}).filter((G)=>!!G);if(Q.common.async)return Promise.all(W).then((G)=>{return f0.mergeArray(J,G)});else return f0.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:v.ZodTuple,rest:null,...u(J)})};class M2 extends n{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==S.object)return P(Q,{code:K.invalid_type,expected:S.object,received:Q.parsedType}),x;let X=[],W=this._def.keyType,G=this._def.valueType;for(let Y in Q.data)X.push({key:W._parse(new I0(Q,Y,Q.path,Y)),value:G._parse(new I0(Q,Q.data[Y],Q.path,Y)),alwaysSet:Y in Q.data});if(Q.common.async)return f0.mergeObjectAsync(J,X);else return f0.mergeObjectSync(J,X)}get element(){return this._def.valueType}static create($,J,Q){if(J instanceof n)return new M2({keyType:$,valueType:J,typeName:v.ZodRecord,...u(Q)});return new M2({keyType:T0.create(),valueType:$,typeName:v.ZodRecord,...u(J)})}}class _2 extends n{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==S.map)return P(Q,{code:K.invalid_type,expected:S.map,received:Q.parsedType}),x;let X=this._def.keyType,W=this._def.valueType,G=[...Q.data.entries()].map(([Y,q],H)=>{return{key:X._parse(new I0(Q,Y,Q.path,[H,"key"])),value:W._parse(new I0(Q,q,Q.path,[H,"value"]))}});if(Q.common.async){let Y=new Map;return Promise.resolve().then(async()=>{for(let q of G){let H=await q.key,B=await q.value;if(H.status==="aborted"||B.status==="aborted")return x;if(H.status==="dirty"||B.status==="dirty")J.dirty();Y.set(H.value,B.value)}return{status:J.value,value:Y}})}else{let Y=new Map;for(let q of G){let{key:H,value:B}=q;if(H.status==="aborted"||B.status==="aborted")return x;if(H.status==="dirty"||B.status==="dirty")J.dirty();Y.set(H.value,B.value)}return{status:J.value,value:Y}}}}_2.create=($,J,Q)=>{return new _2({valueType:J,keyType:$,typeName:v.ZodMap,...u(Q)})};class w1 extends n{_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==S.set)return P(Q,{code:K.invalid_type,expected:S.set,received:Q.parsedType}),x;let X=this._def;if(X.minSize!==null){if(Q.data.size<X.minSize.value)P(Q,{code:K.too_small,minimum:X.minSize.value,type:"set",inclusive:!0,exact:!1,message:X.minSize.message}),J.dirty()}if(X.maxSize!==null){if(Q.data.size>X.maxSize.value)P(Q,{code:K.too_big,maximum:X.maxSize.value,type:"set",inclusive:!0,exact:!1,message:X.maxSize.message}),J.dirty()}let W=this._def.valueType;function G(q){let H=new Set;for(let B of q){if(B.status==="aborted")return x;if(B.status==="dirty")J.dirty();H.add(B.value)}return{status:J.value,value:H}}let Y=[...Q.data.values()].map((q,H)=>W._parse(new I0(Q,q,Q.path,H)));if(Q.common.async)return Promise.all(Y).then((q)=>G(q));else return G(Y)}min($,J){return new w1({...this._def,minSize:{value:$,message:D.toString(J)}})}max($,J){return new w1({...this._def,maxSize:{value:$,message:D.toString(J)}})}size($,J){return this.min($,J).max($,J)}nonempty($){return this.min(1,$)}}w1.create=($,J)=>{return new w1({valueType:$,minSize:null,maxSize:null,typeName:v.ZodSet,...u(J)})};class I1 extends n{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==S.function)return P(J,{code:K.invalid_type,expected:S.function,received:J.parsedType}),x;function Q(Y,q){return F2({data:Y,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,T1(),i0].filter((H)=>!!H),issueData:{code:K.invalid_arguments,argumentsError:q}})}function X(Y,q){return F2({data:Y,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,T1(),i0].filter((H)=>!!H),issueData:{code:K.invalid_return_type,returnTypeError:q}})}let W={errorMap:J.common.contextualErrorMap},G=J.data;if(this._def.returns instanceof L1){let Y=this;return O0(async function(...q){let H=new P0([]),B=await Y._def.args.parseAsync(q,W).catch((M)=>{throw H.addIssue(Q(q,M)),H}),N=await Reflect.apply(G,this,B);return await Y._def.returns._def.type.parseAsync(N,W).catch((M)=>{throw H.addIssue(X(N,M)),H})})}else{let Y=this;return O0(function(...q){let H=Y._def.args.safeParse(q,W);if(!H.success)throw new P0([Q(q,H.error)]);let B=Reflect.apply(G,this,H.data),N=Y._def.returns.safeParse(B,W);if(!N.success)throw new P0([X(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,Q){return new I1({args:$?$:u0.create([]).rest(J1.create()),returns:J||J1.create(),typeName:v.ZodFunction,...u(Q)})}}class h1 extends n{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})}}h1.create=($,J)=>{return new h1({getter:$,typeName:v.ZodLazy,...u(J)})};class m1 extends n{_parse($){if($.data!==this._def.value){let J=this._getOrReturnCtx($);return P(J,{received:J.data,code:K.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:$.data}}get value(){return this._def.value}}m1.create=($,J)=>{return new m1({value:$,typeName:v.ZodLiteral,...u(J)})};function J4($,J){return new W1({values:$,typeName:v.ZodEnum,...u(J)})}class W1 extends n{_parse($){if(typeof $.data!=="string"){let J=this._getOrReturnCtx($),Q=this._def.values;return P(J,{expected:o.joinValues(Q),received:J.parsedType,code:K.invalid_type}),x}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let J=this._getOrReturnCtx($),Q=this._def.values;return P(J,{received:J.data,code:K.invalid_enum_value,options:Q}),x}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((Q)=>!$.includes(Q)),{...this._def,...J})}}W1.create=J4;class c1 extends n{_parse($){let J=o.getValidEnumValues(this._def.values),Q=this._getOrReturnCtx($);if(Q.parsedType!==S.string&&Q.parsedType!==S.number){let X=o.objectValues(J);return P(Q,{expected:o.joinValues(X),received:Q.parsedType,code:K.invalid_type}),x}if(!this._cache)this._cache=new Set(o.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let X=o.objectValues(J);return P(Q,{received:Q.data,code:K.invalid_enum_value,options:X}),x}return O0($.data)}get enum(){return this._def.values}}c1.create=($,J)=>{return new c1({values:$,typeName:v.ZodNativeEnum,...u(J)})};class L1 extends n{unwrap(){return this._def.type}_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==S.promise&&J.common.async===!1)return P(J,{code:K.invalid_type,expected:S.promise,received:J.parsedType}),x;let Q=J.parsedType===S.promise?J.data:Promise.resolve(J.data);return O0(Q.then((X)=>{return this._def.type.parseAsync(X,{path:J.path,errorMap:J.common.contextualErrorMap})}))}}L1.create=($,J)=>{return new L1({type:$,typeName:v.ZodPromise,...u(J)})};class g0 extends n{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===v.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:J,ctx:Q}=this._processInputParams($),X=this._def.effect||null,W={addIssue:(G)=>{if(P(Q,G),G.fatal)J.abort();else J.dirty()},get path(){return Q.path}};if(W.addIssue=W.addIssue.bind(W),X.type==="preprocess"){let G=X.transform(Q.data,W);if(Q.common.async)return Promise.resolve(G).then(async(Y)=>{if(J.value==="aborted")return x;let q=await this._def.schema._parseAsync({data:Y,path:Q.path,parent:Q});if(q.status==="aborted")return x;if(q.status==="dirty")return B1(q.value);if(J.value==="dirty")return B1(q.value);return q});else{if(J.value==="aborted")return x;let Y=this._def.schema._parseSync({data:G,path:Q.path,parent:Q});if(Y.status==="aborted")return x;if(Y.status==="dirty")return B1(Y.value);if(J.value==="dirty")return B1(Y.value);return Y}}if(X.type==="refinement"){let G=(Y)=>{let q=X.refinement(Y,W);if(Q.common.async)return Promise.resolve(q);if(q instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return Y};if(Q.common.async===!1){let Y=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(Y.status==="aborted")return x;if(Y.status==="dirty")J.dirty();return G(Y.value),{status:J.value,value:Y.value}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((Y)=>{if(Y.status==="aborted")return x;if(Y.status==="dirty")J.dirty();return G(Y.value).then(()=>{return{status:J.value,value:Y.value}})})}if(X.type==="transform")if(Q.common.async===!1){let G=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(!$1(G))return x;let Y=X.transform(G.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:Q.data,path:Q.path,parent:Q}).then((G)=>{if(!$1(G))return x;return Promise.resolve(X.transform(G.value,W)).then((Y)=>({status:J.value,value:Y}))});o.assertNever(X)}}g0.create=($,J,Q)=>{return new g0({schema:$,typeName:v.ZodEffects,effect:J,...u(Q)})};g0.createWithPreprocess=($,J,Q)=>{return new g0({schema:J,effect:{type:"preprocess",transform:$},typeName:v.ZodEffects,...u(Q)})};class b0 extends n{_parse($){if(this._getType($)===S.undefined)return O0(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}b0.create=($,J)=>{return new b0({innerType:$,typeName:v.ZodOptional,...u(J)})};class n0 extends n{_parse($){if(this._getType($)===S.null)return O0(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}n0.create=($,J)=>{return new n0({innerType:$,typeName:v.ZodNullable,...u(J)})};class u1 extends n{_parse($){let{ctx:J}=this._processInputParams($),Q=J.data;if(J.parsedType===S.undefined)Q=this._def.defaultValue();return this._def.innerType._parse({data:Q,path:J.path,parent:J})}removeDefault(){return this._def.innerType}}u1.create=($,J)=>{return new u1({innerType:$,typeName:v.ZodDefault,defaultValue:typeof J.default==="function"?J.default:()=>J.default,...u(J)})};class p1 extends n{_parse($){let{ctx:J}=this._processInputParams($),Q={...J,common:{...J.common,issues:[]}},X=this._def.innerType._parse({data:Q.data,path:Q.path,parent:{...Q}});if(D1(X))return X.then((W)=>{return{status:"valid",value:W.status==="valid"?W.value:this._def.catchValue({get error(){return new P0(Q.common.issues)},input:Q.data})}});else return{status:"valid",value:X.status==="valid"?X.value:this._def.catchValue({get error(){return new P0(Q.common.issues)},input:Q.data})}}removeCatch(){return this._def.innerType}}p1.create=($,J)=>{return new p1({innerType:$,typeName:v.ZodCatch,catchValue:typeof J.catch==="function"?J.catch:()=>J.catch,...u(J)})};class z2 extends n{_parse($){if(this._getType($)!==S.nan){let Q=this._getOrReturnCtx($);return P(Q,{code:K.invalid_type,expected:S.nan,received:Q.parsedType}),x}return{status:"valid",value:$.data}}}z2.create=($)=>{return new z2({typeName:v.ZodNaN,...u($)})};var h8=Symbol("zod_brand");class r2 extends n{_parse($){let{ctx:J}=this._processInputParams($),Q=J.data;return this._def.type._parse({data:Q,path:J.path,parent:J})}unwrap(){return this._def.type}}class K2 extends n{_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.common.async)return(async()=>{let W=await this._def.in._parseAsync({data:Q.data,path:Q.path,parent:Q});if(W.status==="aborted")return x;if(W.status==="dirty")return J.dirty(),B1(W.value);else return this._def.out._parseAsync({data:W.value,path:Q.path,parent:Q})})();else{let X=this._def.in._parseSync({data:Q.data,path:Q.path,parent:Q});if(X.status==="aborted")return x;if(X.status==="dirty")return J.dirty(),{status:"dirty",value:X.value};else return this._def.out._parseSync({data:X.value,path:Q.path,parent:Q})}}static create($,J){return new K2({in:$,out:J,typeName:v.ZodPipeline})}}class l1 extends n{_parse($){let J=this._def.innerType._parse($),Q=(X)=>{if($1(X))X.value=Object.freeze(X.value);return X};return D1(J)?J.then((X)=>Q(X)):Q(J)}unwrap(){return this._def.innerType}}l1.create=($,J)=>{return new l1({innerType:$,typeName:v.ZodReadonly,...u(J)})};function t5($,J){let Q=typeof $==="function"?$(J):typeof $==="string"?{message:$}:$;return typeof Q==="string"?{message:Q}:Q}function Q4($,J={},Q){if($)return F1.create().superRefine((X,W)=>{let G=$(X);if(G instanceof Promise)return G.then((Y)=>{if(!Y){let q=t5(J,X),H=q.fatal??Q??!0;W.addIssue({code:"custom",...q,fatal:H})}});if(!G){let Y=t5(J,X),q=Y.fatal??Q??!0;W.addIssue({code:"custom",...Y,fatal:q})}return});return F1.create()}var m8={object:N0.lazycreate},v;(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"})(v||(v={}));var c8=($,J={message:`Input not instance of ${$.name}`})=>Q4((Q)=>Q instanceof $,J),X4=T0.create,W4=Q1.create,u8=z2.create,p8=X1.create,Y4=g1.create,l8=N1.create,d8=w2.create,i8=E1.create,r8=y1.create,n8=F1.create,o8=J1.create,s8=c0.create,t8=L2.create,a8=D0.create,e8=N0.create,$6=N0.strictCreate,J6=x1.create,Q6=i2.create,X6=v1.create,W6=u0.create,Y6=M2.create,G6=_2.create,H6=w1.create,q6=I1.create,U6=h1.create,B6=m1.create,N6=W1.create,F6=c1.create,w6=L1.create,L6=g0.create,M6=b0.create,_6=n0.create,z6=g0.createWithPreprocess,K6=K2.create,f6=()=>X4().optional(),O6=()=>W4().optional(),S6=()=>Y4().optional(),R6={string:($)=>T0.create({...$,coerce:!0}),number:($)=>Q1.create({...$,coerce:!0}),boolean:($)=>g1.create({...$,coerce:!0}),bigint:($)=>X1.create({...$,coerce:!0}),date:($)=>N1.create({...$,coerce:!0})};var C6=x;var P6=U.object({before:U.string(),after:U.string(),hierarchy:U.array(U.string()),lineStart:U.number().optional(),lineEnd:U.number().optional()}).passthrough(),k6=U.object({id:U.string(),name:U.string()}).passthrough(),A6=U.object({url:U.string(),mime:U.string().optional()}).passthrough(),p$=U.object({id:U.string(),snippet:U.string(),note:U.string(),createdAt:U.string(),filePath:U.string().optional(),canvasFile:U.string().optional(),context:P6.optional(),images:U.array(U.string()).optional(),attachments:U.array(A6).optional(),source:U.enum(["local","remote"]).optional(),author:k6.optional()}).passthrough(),j6=U.array(p$.optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).catch([]),l$=U.object({annotations:j6,generalNote:U.string().catch("")}).passthrough(),G4=U.object({path:U.string()}),H4=U.object({url:U.string()}),q4=U.object({error:U.string()});import{useCallback as _1,useMemo as V6,useState as Z6}from"react";var d1="__agent-response__";function M1($){return $.filePath&&$.filePath!=="__agent-response__"?$.filePath:void 0}function f2($){return $.uploadUrl!==null}var d$=["image/png","image/jpeg","image/gif","image/webp"],U4="Only PNG, JPEG, GIF and WebP images can be attached";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 B4($){let J=$?`[data-annotation-id="${CSS.escape($)}"]`:"[data-annotation-id]";for(let Q of document.querySelectorAll(J))if(Q.tagName==="MARK"){let X=Q.parentNode;Q.replaceWith(document.createTextNode(Q.textContent||"")),X?.normalize()}else Q.remove()}function n2({annotations:$,setAnnotations:J,generalNote:Q,setGeneralNote:X,remoteAnnotations:W,isReadOnly:G,onClear:Y}){let[q,H]=Z6(null),B=V6(()=>{if(!W?.length)return $;let f=new Set($.map((_)=>_.id)),O=W.filter((_)=>!f.has(_.id));return[...$,...O.map((_)=>({..._,source:"remote"}))]},[$,W]),N=_1((f,O,_,j,T,h,g)=>{J((m)=>[...m,{id:f,snippet:O,note:_,createdAt:new Date().toISOString(),filePath:j,context:T,...h?.length?{images:h}:{},...g?{canvasFile:g}:{}}])},[J]),L=_1((f,O,_)=>{N(o0(),f,O,_)},[N]),M=_1((f,O)=>{J((_)=>_.map((j)=>j.id===f?{...j,note:O}:j))},[J]),F=_1((f)=>{if(!$.some((O)=>O.id===f))return;B4(f),J((O)=>O.filter((_)=>_.id!==f)),H((O)=>O===f?null:O)},[$,J]),w=_1((f,O)=>{J((_)=>_.map((j)=>j.id===f?{...j,images:[...j.images||[],O]}:j))},[J]),R=_1((f,O)=>{J((_)=>_.map((j)=>j.id===f?{...j,images:(j.images||[]).filter((T)=>T!==O)}:j))},[J]),z=_1(()=>{B4(),J([]),X(""),H(null),Y?.()},[J,X,Y]);return{annotations:B,generalNote:Q,setGeneralNote:X,activeAnnotationId:q,setActiveAnnotationId:H,addAnnotation:L,addAnnotationWithId:N,updateAnnotation:M,removeAnnotation:F,addAnnotationImage:w,removeAnnotationImage:R,clearAll:z,isReadOnly:G}}import{useAnnotations as G1}from"@fabrika/annotations/runtime";import{jsxDEV as hQ}from"react/jsx-dev-runtime";import{jsxDEV as z1,Fragment as T6}from"react/jsx-dev-runtime";function i$({hasContent:$,onSubmit:J,onSubmitEmpty:Q,notice:X,secondaryAction:W,placeholder:G="General notes...",submitLabel:Y="Submit",emptyLabel:q="Submit without feedback"}){let{generalNote:H,setGeneralNote:B}=G1();return z1(T6,{children:[z1("div",{className:"border-t border-border-subtle px-4 py-3 flex-shrink-0",children:z1("textarea",{value:H,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:G,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),X,z1("div",{className:"px-4 py-3 border-t border-border-subtle flex-shrink-0",children:$?z1("div",{className:"flex gap-2",children:[W,z1("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):z1("button",{onClick:Q,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:q},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useAnnotationHost as D6}from"@fabrika/annotations/runtime";import{useCallback as s0,useEffect as b6,useRef as r$,useState as o2}from"react";import{jsxDEV as _0}from"react/jsx-dev-runtime";function n$($){if($.startsWith("/s/")||$.startsWith("http://")||$.startsWith("https://"))return $;return`/api/uploads/${$.split("/").pop()}`}async function I6($,J){let Q=$.uploadUrl;if(!Q)return{error:"Uploads are not available here"};let X=new FormData;X.append("image",J);try{let W=await fetch(Q(),{method:"POST",body:X}),G=await W.json();if(!W.ok){let Y=q4.safeParse(G);return{error:Y.success?Y.data.error:`Upload failed (HTTP ${W.status})`}}return{path:$.isShared?H4.parse(G).url:G4.parse(G).path}}catch{return{error:"Upload failed"}}}function i1({note:$,onNoteChange:J,images:Q,onAddImage:X,onRemoveImage:W,sessionId:G,placeholder:Y="Add your note...",autoFocus:q=!1,autoResize:H=!1,readOnly:B=!1,onKeyDown:N,onTextareaClick:L,textareaRef:M,textareaClassName:F,textareaStyle:w,minHeight:R,attachButton:z="always",openFilePickerRef:f}){let O=D6(),_=!B&&f2(O),[j,T]=o2(!1),[h,g]=o2(!1),[m,c]=o2(null),[p,Q0]=o2(!1),$0=r$(0),W0=r$(null),z0=r$(null),l=s0(()=>z0.current?.click(),[]);if(f)f.current=l;let J0=s0((k)=>{if(W0.current=k,M)M.current=k;if(k&&H)Y1(k,R)},[M,H,R]);b6(()=>{if(q&&W0.current){let k=W0.current;if(k.focus(),k.value)k.setSelectionRange(k.value.length,k.value.length)}},[q]);let a=s0(async(k)=>{if(!d$.includes(k.type)){c(U4);return}c(null),g(!0);try{let C=await I6(O,k);if("path"in C)X(C.path);else c(C.error)}finally{g(!1)}},[O,X]),H0=s0((k)=>{for(let C of k.clipboardData?.items??[])if(C.type.startsWith("image/")){k.preventDefault();let y=C.getAsFile();if(y)a(y);return}},[a]),e=s0((k)=>{if(k.preventDefault(),$0.current++,$0.current===1)T(!0)},[]),X0=s0((k)=>{k.preventDefault()},[]),B0=s0((k)=>{if(k.preventDefault(),$0.current--,$0.current===0)T(!1)},[]),A=s0((k)=>{k.preventDefault(),$0.current=0,T(!1);for(let C of k.dataTransfer?.files??[])if(C.type.startsWith("image/"))a(C)},[a]),I=s0((k)=>{if(J(k.currentTarget.value),H)k.currentTarget.style.height="auto",k.currentTarget.style.height=(R?Math.max(R,k.currentTarget.scrollHeight):k.currentTarget.scrollHeight)+"px"},[J,H,R]),d="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",Z={width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",outline:"none",...H?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},E=_&&(z==="always"||z==="on-focus"&&p);return _0("div",{style:{position:"relative"},onDragEnter:_?e:void 0,onDragOver:_?X0:void 0,onDragLeave:_?B0:void 0,onDrop:_?A:void 0,children:[_0("textarea",{ref:J0,value:$,onChange:B?void 0:I,onPaste:_?H0:void 0,onKeyDown:N,onClick:L,onFocus:()=>Q0(!0),onBlur:()=>{setTimeout(()=>Q0(!1),150)},readOnly:B,placeholder:Y,className:F??d,style:w??Z,rows:H?1:void 0},void 0,!1,void 0,this),_&&_0("input",{ref:z0,type:"file",accept:d$.join(","),multiple:!0,style:{display:"none"},onChange:(k)=>{let C=k.currentTarget.files;if(C)for(let y of C)a(y);k.currentTarget.value=""}},void 0,!1,void 0,this),(Q.length>0||E)&&_0("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[Q.map((k)=>_0("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[_0("img",{src:n$(k),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!B&&_0("button",{onClick:(C)=>{C.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)),E&&_0(s2,{onClick:l},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h&&_0("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),m&&_0("div",{role:"alert",style:{fontSize:"11px",color:"var(--color-accent-red)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:m},void 0,!1,void 0,this),j&&_0("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 s2({onClick:$,size:J=16}){return _0("button",{onClick:(Q)=>{Q.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:(Q)=>{Q.currentTarget.style.color="var(--color-text-secondary)"},onMouseLeave:(Q)=>{Q.currentTarget.style.color="var(--color-text-tertiary)"},children:_0("svg",{width:J,height:J,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[_0("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),_0("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),_0("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 o$({images:$}){if(!$.length)return null;return _0("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px"},children:$.map((J)=>_0("div",{style:{width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:_0("img",{src:n$(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 g6}from"@fabrika/annotations/runtime";import{useContext as E6,useEffect as y6,useRef as x6}from"react";import{jsxDEV as F0,Fragment as N4}from"react/jsx-dev-runtime";function v6($){let J=N2($);return J.length>80?J.slice(0,80)+"...":J}function O2({annotations:$,readOnly:J=!1,onSelect:Q,onReveal:X,includedRemoteIds:W,onToggleRemoteId:G}){let{updateAnnotation:Y,removeAnnotation:q,addAnnotationImage:H,removeAnnotationImage:B,activeAnnotationId:N,setActiveAnnotationId:L}=G1(),M=E6(g6),F=x6(new Map);y6(()=>{if(J||!N)return;let _=F.current.get(N);if(_)_.scrollIntoView({behavior:"smooth",block:"nearest"})},[N,J]);let w=(_)=>{L(_),V1(_,!0)},R=(_)=>{L(null),V1(_,!1)},z=(_)=>{if(_.id===N){L(null);return}L(_.id),Q?.(_)},f=!!W&&!!G,O=(_)=>{let j=f&&_.source==="remote";return F0("div",{ref:(T)=>{if(T)F.current.set(_.id,T);else F.current.delete(_.id)},className:`group/ann relative px-3 py-2.5 transition-colors duration-150 ${J?"cursor-pointer ":""}${N===_.id?"bg-highlight-selected":j?"bg-accent-purple-muted/30 hover:bg-accent-purple-muted/50":"odd:bg-bg-elevated-half hover:bg-bg-input"}`,onMouseEnter:()=>w(_.id),onMouseLeave:()=>R(_.id),onClick:()=>z(_),children:[j&&_.author&&F0("div",{className:"flex items-center gap-1.5 mb-1.5",children:[F0("input",{type:"checkbox",checked:W.has(_.id),onChange:(T)=>{T.stopPropagation(),G(_.id)},onClick:(T)=>T.stopPropagation(),className:"accent-accent-purple flex-shrink-0",title:"Include in submission"},void 0,!1,void 0,this),F0("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:_.author.name.charAt(0)},void 0,!1,void 0,this),F0("span",{className:"text-[11px] font-medium text-accent-purple font-body",children:_.author.name},void 0,!1,void 0,this),F0("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),F0("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:v6(_.snippet)},void 0,!1,void 0,this),J?F0(N4,{children:[_.note.trim()&&F0("div",{className:"text-[13px] font-body text-text-primary leading-relaxed",children:_.note},void 0,!1,void 0,this),F0(o$,{images:_.images||[]},void 0,!1,void 0,this)]},void 0,!0,void 0,this):j?F0("div",{className:"text-[13px] font-body text-text-primary leading-relaxed whitespace-pre-wrap",children:_.note},void 0,!1,void 0,this):F0("div",{onClick:(T)=>T.stopPropagation(),children:F0(i1,{note:_.note,onNoteChange:(T)=>Y(_.id,T),images:_.images||[],onAddImage:(T)=>H(_.id,T),onRemoveImage:(T)=>B(_.id,T),sessionId:M,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),F0("div",{className:"absolute top-1.5 right-1.5 opacity-0 group-hover/ann:opacity-100 transition-opacity duration-100 flex items-center gap-0.5",children:[X&&F0("button",{onClick:(T)=>{T.stopPropagation(),X(_)},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:F0("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[F0("circle",{cx:"12",cy:"12",r:"3"},void 0,!1,void 0,this),F0("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&&!j&&F0("button",{onClick:(T)=>{T.stopPropagation(),q(_.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:F0("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[F0("polyline",{points:"3 6 5 6 21 6"},void 0,!1,void 0,this),F0("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)]},_.id,!0,void 0,this)};return F0(N4,{children:$.map(O)},void 0,!1,void 0,this)}function S2($){let J=[],Q=$.snippet.trim(),X=$.context,W=N2(Q);if(W!==Q)J.push(`> ${W}`);else if($.filePath&&X&&X.lineStart!=null){let q=X.lineStart,H=X.lineEnd??q,B=Q.split(`
|
|
2
|
+
`);if(Q.length<30&&q===H&&(X.before||X.after)){let L=E2($);J.push(`> L${q}: ${L}`)}else if(B.length<=6)for(let L=0;L<B.length;L++)J.push(`> ${q+L} | ${B[L]}`);else{for(let L=0;L<3;L++)J.push(`> ${q+L} | ${B[L]}`);J.push(`> ... (${B.length} lines)`);for(let L=B.length-3;L<B.length;L++)J.push(`> ${q+L} | ${B[L]}`)}}else{let q=E2($);if(Q.split(`
|
|
3
|
+
`).length<=3)J.push(`> ${q.split(`
|
|
4
|
+
`).join(`
|
|
5
|
+
> `)}`);else{let H=Q.split(`
|
|
6
|
+
`);J.push(`> ${H[0]}`),J.push(`> ... (${H.length} lines)`),J.push(`> ${H[H.length-1]}`)}}if($.note.trim())J.push(""),J.push($.note.trim());let G=[...$.images??[]],Y=new Set(G);for(let q of $.attachments??[]){if(Y.has(q.url))continue;Y.add(q.url),G.push(q.url)}if(G.length){J.push("");for(let q of G)J.push(``)}return J.push(""),J.join(`
|
|
7
|
+
`)}import{SessionContext as h6,useAnnotationHost as m6}from"@fabrika/annotations/runtime";import{useCallback as t2,useContext as c6,useEffect as u6,useMemo as L4,useRef as a2,useState as r1}from"react";import{createPortal as p6}from"react-dom";function F4($){let J=/^(\d+(?:\.\d+)?)px$/.exec($.trim());return J?Number(J[1]):void 0}function w4($,J,Q=280){let W=J||document.body,G=$.getBoundingClientRect(),Y=W.getBoundingClientRect(),q=W===document.body?0:W.scrollTop,H=G.bottom-Y.top+q+8,B=Math.max(0,Math.min(G.left-Y.left,Y.width-Q-12));return W.style.position="relative",{style:{position:"absolute",top:`${H}px`,left:`${B}px`},parent:W}}import{jsxDEV as K0,Fragment as l6}from"react/jsx-dev-runtime";function _4({anchorEl:$,scrollContainer:J,onClose:Q,ignoreSelector:X,zIndex:W="50",padding:G="12px",width:Y="280px",children:q}){let H=a2(null),B=a2(Q);B.current=Q;let{style:N,parent:L}=w4($,J,F4(Y));return u6(()=>{let M=setTimeout(()=>{let F=(w)=>{if(H.current&&!H.current.contains(w.target)){if(X&&w.target.closest?.(X))return;B.current(),document.removeEventListener("mousedown",F)}};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},0);return()=>clearTimeout(M)},[X]),p6(K0("div",{ref:H,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:G,fontFamily:"'Inter', sans-serif"},children:q},void 0,!1,void 0,this),L)}var z4=[{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"]}],M4=z4.flatMap(($)=>$.items);function s$({anchorEl:$,scrollContainer:J,snippet:Q,truncateAt:X=100,header:W,initialNote:G="",initialImages:Y,onConfirm:q,onCancel:H,onDelete:B}){let N=c6(h6),L=m6(),M=f2(L),F=G!==""||!!B,[w,R]=r1(G),[z,f]=r1(Y||[]),[O,_]=r1(null),[j,T]=r1(F),[h,g]=r1(!1),m=a2(null),c=a2(null),p=t2(()=>{if(w.trim()||z.length>0)q(w.trim(),z);else if(F&&B)B();else H()},[w,z,q,H,F,B]),Q0=t2(()=>{if(F){if(!w.trim()&&z.length===0&&B){B(),H();return}q(w,z);return}H()},[w,z,F,q,H,B]),$0=!F,W0=w.trim().length>0?M4.filter((C)=>C.toLowerCase().startsWith(w.trim().toLowerCase())):M4,z0=!$0||j?[]:W0.length===1&&W0[0]?.toLowerCase()===w.trim().toLowerCase()?[]:W0,l=new Set(z0),J0=z4.map((C)=>({label:C.label,items:C.items.filter((y)=>l.has(y))})).filter((C)=>C.items.length>0),a=J0.map((C)=>C.items),H0=(C)=>a[C]?.length??0,e=a.flat(),X0=L4(()=>{if(O===null)return 0;let C=0;for(let y=0;y<a.length;y++){if(O<C+H0(y))return y;C+=H0(y)}return 0},[O,a]),B0=L4(()=>{if(O===null)return 0;let C=0;for(let y=0;y<X0;y++)C+=H0(y);return O-C},[O,X0,a]),A=(C,y)=>{let i=0;for(let q0=0;q0<C;q0++)i+=H0(q0);return i+y},[I,d]=r1(w);if(w!==I)d(w),_(null),T(F);let Z=t2((C)=>{R(C)},[]),E=Q.length>X?Q.slice(0,X)+"...":Q,k=t2((C)=>{if(e.length>0&&(C.key==="ArrowDown"||C.key==="ArrowUp"||C.key==="ArrowLeft"||C.key==="ArrowRight")){if(C.preventDefault(),O===null){_(0);return}if(C.key==="ArrowDown"){let i=Math.min(B0+1,H0(X0)-1);_(A(X0,i))}else if(C.key==="ArrowUp"){let i=Math.max(B0-1,0);_(A(X0,i))}else if(C.key==="ArrowRight"){let i=Math.min(X0+1,a.length-1),q0=Math.min(B0,H0(i)-1);_(A(i,q0))}else if(C.key==="ArrowLeft"){let i=Math.max(X0-1,0),q0=Math.min(B0,H0(i)-1);_(A(i,q0))}return}let y=O===null?void 0:e[O];if(y!==void 0){if(C.key==="Tab"){C.preventDefault(),Z(y);return}if(C.key==="Enter"&&!C.shiftKey){C.preventDefault(),q(y,z);return}}if(C.key==="Enter"&&!C.shiftKey){C.preventDefault(),p();return}if(C.key==="Escape")if(e.length>0&&!j)T(!0);else if(F)Q0();else H()},[e,O,B0,X0,a,A,Z,q,z,p,j,F,Q0,H]);return K0(_4,{anchorEl:$,scrollContainer:J,onClose:F?Q0:H,ignoreSelector:F?"[data-annotation-id]":void 0,zIndex:F?"60":"50",padding:F?"10px 12px":"12px",width:"420px",children:[!F&&(W??K0("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:["“",E,"”"]},void 0,!0,void 0,this)),K0(i1,{note:w,onNoteChange:R,images:z,onAddImage:(C)=>f((y)=>[...y,C]),onRemoveImage:(C)=>f((y)=>y.filter((i)=>i!==C)),sessionId:N,autoFocus:!0,autoResize:F,textareaRef:m,onKeyDown:k,attachButton:"none",openFilePickerRef:c,textareaStyle:F?{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),K0("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:F?"6px":"8px"},children:[M&&K0(s2,{onClick:()=>c.current?.(),size:14},void 0,!1,void 0,this),K0("div",{style:{flex:1}},void 0,!1,void 0,this),F?K0("button",{onClick:()=>{if(B)B();H()},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):K0(l6,{children:[K0("button",{onClick:H,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),K0("button",{onClick:p,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),e.length>0&&K0("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:J0.map((C)=>K0("div",{style:{flex:1},children:[K0("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:C.label},void 0,!1,void 0,this),C.items.map((y)=>{let i=e.indexOf(y);return K0("div",{onMouseDown:(q0)=>{q0.preventDefault(),q0.stopPropagation(),Z(y)},onMouseEnter:()=>_(i),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:i===O?"var(--color-text-primary)":"var(--color-text-secondary)",background:i===O?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[K0("span",{style:{fontWeight:500},children:y.slice(0,w.trim().length)},void 0,!1,void 0,this),y.slice(w.trim().length)]},y,!0,void 0,this)})]},C.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function H1({anchorEl:$,scrollContainer:J,snippet:Q,truncateAt:X,header:W,onAdd:G,onCancel:Y}){return K0(s$,{anchorEl:$,scrollContainer:J,snippet:Q,truncateAt:X,header:W,onConfirm:(q,H)=>G(q,H),onCancel:Y},void 0,!1,void 0,this)}function R2({anchorEl:$,scrollContainer:J,initialNote:Q,initialImages:X,onUpdate:W,onDelete:G,onClose:Y}){return K0(s$,{anchorEl:$,scrollContainer:J,snippet:"",initialNote:Q,initialImages:X,onConfirm:(q,H)=>{W(q,H),Y()},onDelete:G,onCancel:Y},void 0,!1,void 0,this)}import{useEffect as d6,useRef as t$,useState as K4}from"react";import{jsxDEV as i6}from"react/jsx-dev-runtime";function a$($){let{containerRef:J,restoreKey:Q,shape:X="rect",canvasFile:W,scrollContainer:G}=$,{addAnnotationWithId:Y}=G1(),[q,H]=K4(null),[B,N]=K4(!1),L=t$(Y);L.current=Y;let M=t$(W);M.current=W;let F=t$(X);return F.current=X,d6(()=>{let R=J.current;if(!R)return;let z=null;function f(g,m){let c=g.getBoundingClientRect();return E$(c,m.clientX-c.left,m.clientY-c.top)}function O(){if(!z)return;let{host:g,pointerId:m}=z;if(g.hasPointerCapture(m))g.releasePointerCapture(m);g.removeEventListener("pointermove",j),g.removeEventListener("pointerup",T),g.removeEventListener("pointercancel",h),z=null,N(!1)}function _(g){if(z||g.button!==0)return;let m=g.target;if(!(m instanceof Element))return;if(m.closest("[data-block-comment-btn]"))return;if(m.closest("[data-annotation-id]"))return;let c=m.closest(`[${g$}]`);if(!(c instanceof HTMLElement)||!R?.contains(c))return;let p=c.closest("[data-md='image']")?.getAttribute("data-md-src");if(!p)return;let Q0=f(c,g);if(!Q0)return;g.preventDefault(),c.setPointerCapture(g.pointerId);let $0=o0(),W0=u2({...Q0,w:0,h:0},F.current,$0);W0.classList.add("ann-region-draft"),c.appendChild(W0),z={pointerId:g.pointerId,host:c,src:p,start:Q0,shape:F.current,overlay:W0,id:$0},c.addEventListener("pointermove",j),c.addEventListener("pointerup",T),c.addEventListener("pointercancel",h),N(!0)}function j(g){if(!z||z.pointerId!==g.pointerId)return;let m=f(z.host,g);if(!m)return;c2(z.overlay,h2(z.start,m))}function T(g){if(!z||z.pointerId!==g.pointerId)return;let{overlay:m,id:c,src:p,shape:Q0}=z,$0=f(z.host,g)??z.start,W0=h2(z.start,$0);if(O(),!y$(W0)){m.remove();return}c2(m,W0);let z0={src:p,shape:Q0,...W0};H({overlay:m,id:c,snippet:B2.format(z0),label:m2(z0)})}function h(g){if(!z||z.pointerId!==g.pointerId)return;z.overlay.remove(),O()}return R.addEventListener("pointerdown",_),()=>{if(R.removeEventListener("pointerdown",_),z)z.overlay.remove(),O()}},[Q]),{popovers:q?i6(H1,{anchorEl:q.overlay,scrollContainer:G,snippet:q.label,truncateAt:80,onAdd:(R,z)=>{q.overlay.classList.remove("ann-region-draft"),L.current(q.id,q.snippet,R,void 0,void 0,z,M.current),H(null)},onCancel:()=>{q.overlay.remove(),H(null)}},void 0,!1,void 0,this):null,isDrawing:B,isPopoverOpen:!!q}}import{useCallback as f4,useEffect as e2,useRef as K1,useState as O4}from"react";import{jsxDEV as e$,Fragment as r6}from"react/jsx-dev-runtime";function $5($){let{containerRef:J,restoreKey:Q,restoreAnnotations:X,extractContext:W,filePath:G,canvasFile:Y,scrollContainer:q}=$,{annotations:H,addAnnotationWithId:B,removeAnnotation:N,updateAnnotation:L,addAnnotationImage:M,removeAnnotationImage:F,activeAnnotationId:w,setActiveAnnotationId:R}=G1(),[z,f]=O4(null),[O,_]=O4(null),j=K1(W);j.current=W;let T=K1(G);T.current=G;let h=K1(Y);h.current=Y;let g=K1(B);g.current=B;let m=K1(w);m.current=w;let c=K1(R);c.current=R;let p=X.length;e2(()=>{if(!J.current)return;let l=setTimeout(()=>{if(J.current)h$(J.current,X)},50);return()=>clearTimeout(l)},[Q,p]);let Q0=K1(null);e2(()=>{A$(w,Q0.current),Q0.current=w},[w]),e2(()=>{let l=J.current;if(!l)return;let J0=(e)=>{let X0=e.target.closest("[data-annotation-id]");if(!X0)return;e.stopPropagation();let B0=X0.getAttribute("data-annotation-id");if(B0===m.current)f({anchorEl:X0,annId:B0});else c.current(B0)},a=(e)=>{let X0=e.target.closest("[data-annotation-id]");if(X0)c.current(X0.getAttribute("data-annotation-id"))},H0=(e)=>{let X0=e.target.closest("[data-annotation-id]"),B0=e.relatedTarget?.closest?.("[data-annotation-id]");if(X0&&!B0&&!document.getElementById("ann-inline-popover"))c.current(null)};return l.addEventListener("click",J0),l.addEventListener("mouseover",a),l.addEventListener("mouseout",H0),()=>{l.removeEventListener("click",J0),l.removeEventListener("mouseover",a),l.removeEventListener("mouseout",H0)}},[Q]),e2(()=>{let l=()=>$0();return document.addEventListener("mouseup",l),()=>document.removeEventListener("mouseup",l)},[]);let $0=f4(()=>{let l=window.getSelection();if(!l||l.isCollapsed||!l.toString().trim())return;if(!J.current)return;let J0=l.getRangeAt(0);if(!J.current.contains(J0.startContainer))return;if(J0.startContainer.parentElement?.closest?.("[data-annotation-id]"))return;let a=l5(J0).trim();if(a.length<2)return;let H0=j.current(J0),e=J0.cloneRange(),X0=`__pending_${Date.now()}`;try{g2(e,X0)}catch{}window.getSelection()?.removeAllRanges();let B0=document.querySelectorAll(`[data-annotation-id="${X0}"]`),A=B0[B0.length-1];if(!A)return;_({anchorEl:A,tempId:X0,snippet:a,ctx:H0})},[]),W0=f4((l,J0,a,H0)=>{_({anchorEl:l,tempId:J0,snippet:a,ctx:H0})},[]);return{popovers:e$(r6,{children:[z&&(()=>{let l=H.find((J0)=>J0.id===z.annId);if(!l)return null;return e$(R2,{anchorEl:z.anchorEl,scrollContainer:q,initialNote:l.note,initialImages:l.images,onUpdate:(J0,a)=>{L(z.annId,J0);let H0=l.images||[];for(let e of a)if(!H0.includes(e))M(z.annId,e);for(let e of H0)if(!a.includes(e))F(z.annId,e)},onDelete:()=>{N(z.annId),R(null)},onClose:()=>f(null)},void 0,!1,void 0,this)})(),O&&e$(H1,{anchorEl:O.anchorEl,scrollContainer:q,snippet:O.snippet,truncateAt:80,onAdd:(l,J0)=>{let a=o0();j$(O.tempId,a),g.current(a,O.snippet,l,T.current,O.ctx,J0,h.current),_(null)},onCancel:()=>{Z$(O.tempId),_(null)}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),openCreatePopover:W0,isPopoverOpen:!!(z||O)}}import{AnnotationCtx as e6}from"#canvas/runtime";import{AnnotationCtx as $J,AnnotationHostContext as JJ}from"@fabrika/annotations/runtime";import{useCallback as t1,useEffect as Z4,useMemo as QJ,useRef as W5,useState as a1}from"react";var BW=U.object({}).passthrough(),NW=U.object({annotations:U.array(U.unknown()).catch([]),generalNote:U.string().catch(""),responses:U.array(U.unknown()).catch([])}),FW=U.tuple([U.unknown(),U.object({note:U.unknown(),value:U.unknown()})]);function f1($,J,Q="current"){let X=`canvas:${$}:rev:${J}`;return Q==="next"?`${X}:next-draft`:X}function n6($,J){return`${f1($,J)}:draft-handled`}function J5($,J,Q){try{$.removeItem(f1(J,Q)),$.removeItem(n6(J,Q))}catch{}}function Q5($,J){let Q=new Map;for(let[X,W]of $)if(J.has(X))Q.set(X,W);return Q}function X5($,J){if(!$||$.length===0)return!1;return $.every((Q)=>J.has(Q))}function n1($,J,Q,X,W){let G=[],Y=$.filter((F)=>F.source!=="remote"||W&&W.has(F.id)),q=Y.filter((F)=>F.filePath===d1),H=Y.filter((F)=>!F.filePath),B=Y.filter((F)=>F.filePath&&F.filePath!==d1),N=Q?Array.from(Q.values()).filter((F)=>$$(F)):[],L=X?Array.from(X.values()).filter((F)=>F.markdown.trim()):[];if(N.length>0||L.length>0){G.push("## Responses"),G.push("");for(let F of N)G.push(o6(F));for(let F of L)G.push(F.markdown.trim()),G.push("")}if(q.length>0){G.push("## Annotations on agent response"),G.push("");for(let F of q)G.push(S2(F))}if(H.length>0){G.push("## Canvas annotations"),G.push("");let F=new Map;for(let z of H){let f=z.canvasFile||"";if(!F.has(f))F.set(f,[]);F.get(f).push(z)}let w=[...F.keys()].sort(),R=w.length>1||w.length===1&&w[0]!=="";for(let z of w){let f=F.get(z);if(R&&z)G.push(`### ${z.replace(/\.jsx$/,"")}`),G.push("");let O=s6(f);G.push(C4(O))}}if(B.length>0){let F={};for(let w of B){let R=w.filePath;if(!F[R])F[R]=[];F[R].push(w)}G.push("## File annotations"),G.push("");for(let[w,R]of Object.entries(F)){G.push(`### ${w}`),G.push("");for(let z of R)G.push(S2(z))}}if(J.trim())G.push("## General notes"),G.push(""),G.push(J.trim()),G.push("");return G.join(`
|
|
8
|
+
`).trim()+`
|
|
9
|
+
`}function $$($){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 S4($){let J=[];for(let Q of $.values()){if(!Q.required)continue;if(Q.value===null||Q.value===void 0){J.push(Q);continue}if(Q.type==="text"&&!Q.value.trim()){J.push(Q);continue}if(Q.type==="checkbox"&&Q.value.length===0){J.push(Q);continue}}return J}function R4($){let J=[];for(let Q of $.values())if(Q.required&&!Q.markdown.trim())J.push(Q);return J}function o1($,J){let Q=S4($),X=R4(J);return[...Q.map((W)=>W.label),...X.map((W)=>W.label||W.id)]}function o6($){let J=[];switch(J.push(`**${$.label}**`),$.type){case"radio":case"select":J.push(`Answer: ${$.value}`);break;case"checkbox":for(let Q of $.value)J.push(`- [x] ${Q}`);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 s6($){let J={label:"",annotations:[],children:new Map};for(let Q of $){let X=Q.context?.hierarchy||[],W=J;for(let G of X){if(!W.children.has(G))W.children.set(G,{label:G,annotations:[],children:new Map});W=W.children.get(G)}W.annotations.push(Q)}return J}function C4($,J=0){let Q=[];for(let X of $.annotations)Q.push(S2(X));for(let[,X]of $.children){let W=J===0?"###":"####";Q.push(`${W} ${X.label}`),Q.push(""),Q.push(C4(X,J+1))}return Q.join(`
|
|
11
|
+
`)}import{createContext as t6,useContext as a6}from"react";function P4(){if(typeof window>"u")return"";return window.location.pathname.replace("/s/","")}var k4={get sessionId(){return P4()},isShared:!1,fsAvailable:!0,uploadUrl:null,loadCanvasModule:($,J)=>{let Q=$.replace(/\.jsx$/,".js"),X=J?`?rev=${J}&t=${Date.now()}`:`?t=${Date.now()}`;return import(`/api/session/${P4()}/canvas/${encodeURIComponent(Q)}${X}`)}},A4=t6(k4);function t0(){return a6(A4)}var J$=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})),Q$=U.object({id:U.string(),markdown:U.string(),label:U.string().optional(),required:U.boolean().optional()}).passthrough(),X$=l$.extend({responses:U.array(U.tuple([U.string(),J$]).optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).catch([]),feedbackEntries:U.array(U.tuple([U.string(),Q$]).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 j4=U.object({feedback:U.string().nullish()}),V4=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 G5}from"react/jsx-dev-runtime";function T4($,J,Q){try{let X=localStorage.getItem(f1($,J,Q));if(!X)return null;return s1(JSON.parse(X))}catch{return null}}function XJ($,J,Q,X){try{localStorage.setItem(f1($,J,Q),JSON.stringify(X))}catch{}}function Y5($){return{draft:$,responseIds:new Set,canvases:new Set}}function W$({sessionId:$,revision:J,isReadOnly:Q,draftPhase:X,remoteAnnotations:W,canvasFiles:G,loadState:Y,saveState:q,children:H}){let B=!!Y,N=B?null:T4($,J,X),L=W5(N),[M,F]=a1(()=>(N?.annotations??[]).map((A)=>({...A,source:A.source??"local"}))),[w,R]=a1(()=>N?.generalNote??""),[z,f]=a1(()=>N?.responses?new Map(N.responses):new Map),O=`${$}:${J}:${X}`,_=W5(O);_.current=O;let[j,T]=a1(()=>Y5(O)),[h,g]=a1(()=>N?.feedbackEntries?new Map(N.feedbackEntries):new Map),[m,c]=a1(!B);Z4(()=>{let A=(I)=>{L.current=I,F((I?.annotations??[]).map((d)=>({...d,source:d.source??"local"}))),R(I?.generalNote??""),f(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 c(!1),Y($,J,X).then((d)=>{if(I)return;A(s1(d)),c(!0)}),()=>{I=!0}}A(T4($,J,X)),c(!0);return},[$,J,X,B,Y]);let p=W5(null);Z4(()=>{if(Q&&X!=="next")return;if(!m)return;if(p.current)clearTimeout(p.current);let A={...L.current,annotations:M,generalNote:w,responses:Array.from(z.entries()),feedbackEntries:Array.from(h.entries())},I=()=>{if(q)q($,J,A,X);else XJ($,J,X,A)};if(X==="next"){I();return}return p.current=setTimeout(I,300),()=>{if(p.current)clearTimeout(p.current)}},[M,w,z,h,$,J,Q,X,m,q]);let Q0=t1((A,I)=>{f((d)=>{let Z=new Map(d);return Z.set(A,I),Z})},[]),$0=t1((A)=>{T((I)=>{let d=I.draft===_.current?I:Y5(_.current);if(d.responseIds.has(A))return d;return{...d,responseIds:new Set(d.responseIds).add(A)}})},[]),W0=t1((A)=>{T((I)=>{let d=I.draft===_.current?I:Y5(_.current);if(d.canvases.has(A))return d;return{...d,canvases:new Set(d.canvases).add(A)}})},[]),z0=j.draft===O?j:null,l=QJ(()=>{if(!z0||!X5(G,z0.canvases))return z;return Q5(z,z0.responseIds)},[z0,G,z]),J0=t1((A,I)=>{g((d)=>{let Z=d.get(A);if(Z&&Z.markdown===I.markdown&&Z.label===I.label&&Z.required===I.required)return d;let E=new Map(d);return E.set(A,I),E})},[]),a=t1((A)=>{g((I)=>{if(!I.has(A))return I;let d=new Map(I);return d.delete(A),d})},[]),H0=t1(()=>{if(f(new Map),g(new Map),q)q($,J,{annotations:[],generalNote:"",responses:[],feedbackEntries:[]},X);else if(X==="next")localStorage.removeItem(f1($,J,X));else J5(localStorage,$,J)},[$,J,X,q]),e=n2({annotations:M,setAnnotations:F,generalNote:w,setGeneralNote:R,remoteAnnotations:W,isReadOnly:Q,onClear:H0}),{setActiveAnnotationId:X0}=e,B0=t0();return G5(JJ.Provider,{value:B0,children:G5($J.Provider,{value:e,children:G5(e6.Provider,{value:{...e,responses:z,setResponse:Q0,submittableResponses:l,registerResponse:$0,registerCanvasRendered:W0,feedbackEntries:h,setFeedbackEntry:J0,removeFeedbackEntry:a},children:H},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{ActiveViewCtx as F9,AnnotationCtx as w9,CanvasFileCtx as L9,SessionContext as k5,useAnnotations as M9,useCanvasFile as Tq,useFeedback as _9,useResponseRegistration as Dq}from"#canvas/runtime";function C2($){let J=document.querySelector(`[data-annotation-id="${$.id}"]`);if(J instanceof HTMLElement)return J;let Q=$.canvasFile?document.querySelector(`[data-canvas-file="${$.canvasFile}"]`):document;if(!Q)return null;return v$($.snippet,Q)}function D4($){$.classList.remove("ann-flash"),$.offsetWidth,$.classList.add("ann-flash"),$.addEventListener("animationend",()=>{$.classList.remove("ann-flash")},{once:!0})}function H5($,J){let Q=M1($);if(Q)J({type:"file",path:Q}),setTimeout(()=>{let X=C2($);if(X)X.scrollIntoView({behavior:"smooth",block:"center"}),D4(X)},150);else{let X=C2($);if(X)X.scrollIntoView({behavior:"smooth",block:"center"}),D4(X)}}import{SessionContext as sJ}from"#canvas/runtime";import{useCallback as S5,useContext as R5,useEffect as t4,useMemo as tJ,useState as Q2}from"react";import{createContext as b4}from"react";var e1=b4({activeView:{type:"overview"},setActiveView:()=>{},openFiles:[],closeFile:()=>{},canvasFiles:[]}),$2=b4({currentRevision:1,selectedRevision:1,revisions:[],setSelectedRevision:()=>{},isReadOnly:!1,compareRevision:null,setCompareRevision:()=>{},agentWatching:!1});import{jsxDEV as S1}from"react/jsx-dev-runtime";var WJ={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"},YJ={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 q5({name:$,type:J,expanded:Q,className:X=""}){if(J==="dir")return S1("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",className:`flex-shrink-0 ${X}`,children:Q?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():"",G=WJ[W]||"#6b6560",Y=YJ[W];return S1("svg",{width:"14",height:"14",viewBox:"0 0 16 16",className:`flex-shrink-0 ${X}`,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:G,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 B5(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var P1=B5();function h4($){P1=$}var R1={exec:()=>null};function t($,J=""){let Q=typeof $=="string"?$:$.source,X={replace:(W,G)=>{let Y=typeof G=="string"?G:G.source;return Y=Y.replace(R0.caret,"$1"),Q=Q.replace(W,Y),X},getRegex:()=>new RegExp(Q,J)};return X}var GJ=(()=>{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)}}>`)},HJ=/^(?:[ \t]*(?:\n|$))+/,qJ=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,UJ=/^ {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+|$)/,BJ=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,N5=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,m4=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,c4=t(m4).replace(/bull/g,N5).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(),NJ=t(m4).replace(/bull/g,N5).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(),F5=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,FJ=/^[^\n]+/,w5=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,wJ=t(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",w5).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),LJ=t(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,N5).getRegex(),U$="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",L5=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,MJ=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",L5).replace("tag",U$).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),u4=t(F5).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",U$).getRegex(),_J=t(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",u4).getRegex(),M5={blockquote:_J,code:qJ,def:wJ,fences:UJ,heading:BJ,hr:j2,html:MJ,lheading:c4,list:LJ,newline:HJ,paragraph:u4,table:R1,text:FJ},I4=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",U$).getRegex(),zJ={...M5,lheading:NJ,table:I4,paragraph:t(F5).replace("hr",j2).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",I4).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",U$).getRegex()},KJ={...M5,html:t(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",L5).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(F5).replace("hr",j2).replace("heading",` *#{1,6} *[^
|
|
12
|
+
]`).replace("lheading",c4).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},fJ=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,OJ=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,p4=/^( {2,}|\\)\n(?!\s*$)/,SJ=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,J2=/[\p{P}\p{S}]/u,B$=/[\s\p{P}\p{S}]/u,_5=/[^\s\p{P}\p{S}]/u,RJ=t(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,B$).getRegex(),l4=/(?!~)[\p{P}\p{S}]/u,CJ=/(?!~)[\s\p{P}\p{S}]/u,PJ=/(?:[^\s\p{P}\p{S}]|~)/u,kJ=t(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",GJ?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),d4=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,AJ=t(d4,"u").replace(/punct/g,J2).getRegex(),jJ=t(d4,"u").replace(/punct/g,l4).getRegex(),i4="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",VJ=t(i4,"gu").replace(/notPunctSpace/g,_5).replace(/punctSpace/g,B$).replace(/punct/g,J2).getRegex(),ZJ=t(i4,"gu").replace(/notPunctSpace/g,PJ).replace(/punctSpace/g,CJ).replace(/punct/g,l4).getRegex(),TJ=t("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,_5).replace(/punctSpace/g,B$).replace(/punct/g,J2).getRegex(),DJ=t(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,J2).getRegex(),bJ="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",IJ=t(bJ,"gu").replace(/notPunctSpace/g,_5).replace(/punctSpace/g,B$).replace(/punct/g,J2).getRegex(),gJ=t(/\\(punct)/,"gu").replace(/punct/g,J2).getRegex(),EJ=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(),yJ=t(L5).replace("(?:-->|$)","-->").getRegex(),xJ=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",yJ).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),G$=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,vJ=t(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",G$).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),r4=t(/^!?\[(label)\]\[(ref)\]/).replace("label",G$).replace("ref",w5).getRegex(),n4=t(/^!?\[(ref)\](?:\[\])?/).replace("ref",w5).getRegex(),hJ=t("reflink|nolink(?!\\()","g").replace("reflink",r4).replace("nolink",n4).getRegex(),g4=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,z5={_backpedal:R1,anyPunctuation:gJ,autolink:EJ,blockSkip:kJ,br:p4,code:OJ,del:R1,delLDelim:R1,delRDelim:R1,emStrongLDelim:AJ,emStrongRDelimAst:VJ,emStrongRDelimUnd:TJ,escape:fJ,link:vJ,nolink:n4,punctuation:RJ,reflink:r4,reflinkSearch:hJ,tag:xJ,text:SJ,url:R1},mJ={...z5,link:t(/^!?\[(label)\]\((.*?)\)/).replace("label",G$).getRegex(),reflink:t(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",G$).getRegex()},U5={...z5,emStrongRDelimAst:ZJ,emStrongLDelim:jJ,delLDelim:DJ,delRDelim:IJ,url:t(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",g4).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",g4).getRegex()},cJ={...U5,br:t(p4).replace("{2,}","*").getRegex(),text:t(U5.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Y$={normal:M5,gfm:zJ,pedantic:KJ},P2={normal:z5,gfm:U5,breaks:cJ,pedantic:mJ},uJ={"&":"&","<":"<",">":">",'"':""","'":"'"},E4=($)=>uJ[$];function p0($,J){if(J){if(R0.escapeTest.test($))return $.replace(R0.escapeReplace,E4)}else if(R0.escapeTestNoEncode.test($))return $.replace(R0.escapeReplaceNoEncode,E4);return $}function y4($){try{$=encodeURI($).replace(R0.percentDecode,"%")}catch{return null}return $}function x4($,J){let Q=$.replace(R0.findPipe,(G,Y,q)=>{let H=!1,B=Y;for(;--B>=0&&q[B]==="\\";)H=!H;return H?"|":" |"}),X=Q.split(R0.splitPipe),W=0;if(X[0].trim()||X.shift(),X.length>0&&!X.at(-1)?.trim()&&X.pop(),J)if(X.length>J)X.splice(J);else for(;X.length<J;)X.push("");for(;W<X.length;W++)X[W]=X[W].trim().replace(R0.slashPipe,"|");return X}function k2($,J,Q){let X=$.length;if(X===0)return"";let W=0;for(;W<X;){let G=$.charAt(X-W-1);if(G===J&&!Q)W++;else if(G!==J&&Q)W++;else break}return $.slice(0,X-W)}function pJ($,J){if($.indexOf(J[1])===-1)return-1;let Q=0;for(let X=0;X<$.length;X++)if($[X]==="\\")X++;else if($[X]===J[0])Q++;else if($[X]===J[1]&&(Q--,Q<0))return X;return Q>0?-2:-1}function lJ($,J=0){let Q=J,X="";for(let W of $)if(W==="\t"){let G=4-Q%4;X+=" ".repeat(G),Q+=G}else X+=W,Q++;return X}function v4($,J,Q,X,W){let G=J.href,Y=J.title||null,q=$[1].replace(W.other.outputLinkReplace,"$1");X.state.inLink=!0;let H={type:$[0].charAt(0)==="!"?"image":"link",raw:Q,href:G,title:Y,text:q,tokens:X.inlineTokens(q)};return X.state.inLink=!1,H}function dJ($,J,Q){let X=$.match(Q.other.indentCodeCompensation);if(X===null)return J;let W=X[1];return J.split(`
|
|
13
|
+
`).map((G)=>{let Y=G.match(Q.other.beginningSpace);if(Y===null)return G;let[q]=Y;return q.length>=W.length?G.slice(W.length):G}).join(`
|
|
14
|
+
`)}var H$=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 Q=J[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:J[0],codeBlockStyle:"indented",text:this.options.pedantic?Q:k2(Q,`
|
|
15
|
+
`)}}}fences($){let J=this.rules.block.fences.exec($);if(J){let Q=J[0],X=dJ(Q,J[3]||"",this.rules);return{type:"code",raw:Q,lang:J[2]?J[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):J[2],text:X}}}heading($){let J=this.rules.block.heading.exec($);if(J){let Q=J[2].trim();if(this.rules.other.endingHash.test(Q)){let X=k2(Q,"#");(this.options.pedantic||!X||this.rules.other.endingSpaceChar.test(X))&&(Q=X.trim())}return{type:"heading",raw:J[0],depth:J[1].length,text:Q,tokens:this.lexer.inline(Q)}}}hr($){let J=this.rules.block.hr.exec($);if(J)return{type:"hr",raw:k2(J[0],`
|
|
16
|
+
`)}}blockquote($){let J=this.rules.block.blockquote.exec($);if(J){let Q=k2(J[0],`
|
|
17
|
+
`).split(`
|
|
18
|
+
`),X="",W="",G=[];for(;Q.length>0;){let Y=!1,q=[],H;for(H=0;H<Q.length;H++)if(this.rules.other.blockquoteStart.test(Q[H]))q.push(Q[H]),Y=!0;else if(!Y)q.push(Q[H]);else break;Q=Q.slice(H);let B=q.join(`
|
|
19
|
+
`),N=B.replace(this.rules.other.blockquoteSetextReplace,`
|
|
20
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");X=X?`${X}
|
|
21
|
+
${B}`:B,W=W?`${W}
|
|
22
|
+
${N}`:N;let L=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(N,G,!0),this.lexer.state.top=L,Q.length===0)break;let M=G.at(-1);if(M?.type==="code")break;if(M?.type==="blockquote"){let F=M,w=F.raw+`
|
|
23
|
+
`+Q.join(`
|
|
24
|
+
`),R=this.blockquote(w);G[G.length-1]=R,X=X.substring(0,X.length-F.raw.length)+R.raw,W=W.substring(0,W.length-F.text.length)+R.text;break}else if(M?.type==="list"){let F=M,w=F.raw+`
|
|
25
|
+
`+Q.join(`
|
|
26
|
+
`),R=this.list(w);G[G.length-1]=R,X=X.substring(0,X.length-M.raw.length)+R.raw,W=W.substring(0,W.length-F.raw.length)+R.raw,Q=w.substring(G.at(-1).raw.length).split(`
|
|
27
|
+
`);continue}}return{type:"blockquote",raw:X,tokens:G,text:W}}}list($){let J=this.rules.block.list.exec($);if(J){let Q=J[1].trim(),X=Q.length>1,W={type:"list",raw:"",ordered:X,start:X?+Q.slice(0,-1):"",loose:!1,items:[]};Q=X?`\\d{1,9}\\${Q.slice(-1)}`:`\\${Q}`,this.options.pedantic&&(Q=X?Q:"[*+-]");let G=this.rules.other.listItemRegex(Q),Y=!1;for(;$;){let H=!1,B="",N="";if(!(J=G.exec($))||this.rules.block.hr.test($))break;B=J[0],$=$.substring(B.length);let L=lJ(J[2].split(`
|
|
28
|
+
`,1)[0],J[1].length),M=$.split(`
|
|
29
|
+
`,1)[0],F=!L.trim(),w=0;if(this.options.pedantic?(w=2,N=L.trimStart()):F?w=J[1].length+1:(w=L.search(this.rules.other.nonSpaceChar),w=w>4?1:w,N=L.slice(w),w+=J[1].length),F&&this.rules.other.blankLine.test(M)&&(B+=M+`
|
|
30
|
+
`,$=$.substring(M.length+1),H=!0),!H){let R=this.rules.other.nextBulletRegex(w),z=this.rules.other.hrRegex(w),f=this.rules.other.fencesBeginRegex(w),O=this.rules.other.headingBeginRegex(w),_=this.rules.other.htmlBeginRegex(w),j=this.rules.other.blockquoteBeginRegex(w);for(;$;){let T=$.split(`
|
|
31
|
+
`,1)[0],h;if(M=T,this.options.pedantic?(M=M.replace(this.rules.other.listReplaceNesting," "),h=M):h=M.replace(this.rules.other.tabCharGlobal," "),f.test(M)||O.test(M)||_.test(M)||j.test(M)||R.test(M)||z.test(M))break;if(h.search(this.rules.other.nonSpaceChar)>=w||!M.trim())N+=`
|
|
32
|
+
`+h.slice(w);else{if(F||L.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||f.test(L)||O.test(L)||z.test(L))break;N+=`
|
|
33
|
+
`+M}F=!M.trim(),B+=T+`
|
|
34
|
+
`,$=$.substring(T.length+1),L=h.slice(w)}}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 q=W.items.at(-1);if(q)q.raw=q.raw.trimEnd(),q.text=q.text.trimEnd();else return;W.raw=W.raw.trimEnd();for(let H of W.items){if(this.lexer.state.top=!1,H.tokens=this.lexer.blockTokens(H.text,[]),H.task){if(H.text=H.text.replace(this.rules.other.listReplaceTask,""),H.tokens[0]?.type==="text"||H.tokens[0]?.type==="paragraph"){H.tokens[0].raw=H.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),H.tokens[0].text=H.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(H.raw);if(B){let N={type:"checkbox",raw:B[0]+" ",checked:B[0]!=="[ ]"};H.checked=N.checked,W.loose?H.tokens[0]&&["paragraph","text"].includes(H.tokens[0].type)&&"tokens"in H.tokens[0]&&H.tokens[0].tokens?(H.tokens[0].raw=N.raw+H.tokens[0].raw,H.tokens[0].text=N.raw+H.tokens[0].text,H.tokens[0].tokens.unshift(N)):H.tokens.unshift({type:"paragraph",raw:N.raw,text:N.raw,tokens:[N]}):H.tokens.unshift(N)}}if(!W.loose){let B=H.tokens.filter((L)=>L.type==="space"),N=B.length>0&&B.some((L)=>this.rules.other.anyLine.test(L.raw));W.loose=N}}if(W.loose)for(let H of W.items){H.loose=!0;for(let B of H.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 Q=J[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),X=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:Q,raw:J[0],href:X,title:W}}}table($){let J=this.rules.block.table.exec($);if(!J||!this.rules.other.tableDelimiter.test(J[2]))return;let Q=x4(J[1]),X=J[2].replace(this.rules.other.tableAlignChars,"").split("|"),W=J[3]?.trim()?J[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
35
|
+
`):[],G={type:"table",raw:J[0],header:[],align:[],rows:[]};if(Q.length===X.length){for(let Y of X)this.rules.other.tableAlignRight.test(Y)?G.align.push("right"):this.rules.other.tableAlignCenter.test(Y)?G.align.push("center"):this.rules.other.tableAlignLeft.test(Y)?G.align.push("left"):G.align.push(null);for(let Y=0;Y<Q.length;Y++)G.header.push({text:Q[Y],tokens:this.lexer.inline(Q[Y]),header:!0,align:G.align[Y]});for(let Y of W)G.rows.push(x4(Y,G.header.length).map((q,H)=>({text:q,tokens:this.lexer.inline(q),header:!1,align:G.align[H]})));return G}}lheading($){let J=this.rules.block.lheading.exec($);if(J){let Q=J[1].trim();return{type:"heading",raw:J[0],depth:J[2].charAt(0)==="="?1:2,text:Q,tokens:this.lexer.inline(Q)}}}paragraph($){let J=this.rules.block.paragraph.exec($);if(J){let Q=J[1].charAt(J[1].length-1)===`
|
|
36
|
+
`?J[1].slice(0,-1):J[1];return{type:"paragraph",raw:J[0],text:Q,tokens:this.lexer.inline(Q)}}}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 Q=J[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(Q)){if(!this.rules.other.endAngleBracket.test(Q))return;let G=k2(Q.slice(0,-1),"\\");if((Q.length-G.length)%2===0)return}else{let G=pJ(J[2],"()");if(G===-2)return;if(G>-1){let Y=(J[0].indexOf("!")===0?5:4)+J[1].length+G;J[2]=J[2].substring(0,G),J[0]=J[0].substring(0,Y).trim(),J[3]=""}}let X=J[2],W="";if(this.options.pedantic){let G=this.rules.other.pedanticHrefTitle.exec(X);G&&(X=G[1],W=G[3])}else W=J[3]?J[3].slice(1,-1):"";return X=X.trim(),this.rules.other.startAngleBracket.test(X)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(Q)?X=X.slice(1):X=X.slice(1,-1)),v4(J,{href:X&&X.replace(this.rules.inline.anyPunctuation,"$1"),title:W&&W.replace(this.rules.inline.anyPunctuation,"$1")},J[0],this.lexer,this.rules)}}reflink($,J){let Q;if((Q=this.rules.inline.reflink.exec($))||(Q=this.rules.inline.nolink.exec($))){let X=(Q[2]||Q[1]).replace(this.rules.other.multipleSpaceGlobal," "),W=J[X.toLowerCase()];if(!W){let G=Q[0].charAt(0);return{type:"text",raw:G,text:G}}return v4(Q,W,Q[0],this.lexer,this.rules)}}emStrong($,J,Q=""){let X=this.rules.inline.emStrongLDelim.exec($);if(!X||!X[1]&&!X[2]&&!X[3]&&!X[4]||X[4]&&Q.match(this.rules.other.unicodeAlphaNumeric))return;if(!(X[1]||X[3])||!Q||this.rules.inline.punctuation.exec(Q)){let W=[...X[0]].length-1,G,Y,q=W,H=0,B=X[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(B.lastIndex=0,J=J.slice(-1*$.length+W);(X=B.exec(J))!==null;){if(G=X[1]||X[2]||X[3]||X[4]||X[5]||X[6],!G)continue;if(Y=[...G].length,X[3]||X[4]){q+=Y;continue}else if((X[5]||X[6])&&W%3&&!((W+Y)%3)){H+=Y;continue}if(q-=Y,q>0)continue;Y=Math.min(Y,Y+q+H);let N=[...X[0]][0].length,L=$.slice(0,W+X.index+N+Y);if(Math.min(W,Y)%2){let F=L.slice(1,-1);return{type:"em",raw:L,text:F,tokens:this.lexer.inlineTokens(F)}}let M=L.slice(2,-2);return{type:"strong",raw:L,text:M,tokens:this.lexer.inlineTokens(M)}}}}codespan($){let J=this.rules.inline.code.exec($);if(J){let Q=J[2].replace(this.rules.other.newLineCharGlobal," "),X=this.rules.other.nonSpaceChar.test(Q),W=this.rules.other.startingSpaceChar.test(Q)&&this.rules.other.endingSpaceChar.test(Q);return X&&W&&(Q=Q.substring(1,Q.length-1)),{type:"codespan",raw:J[0],text:Q}}}br($){let J=this.rules.inline.br.exec($);if(J)return{type:"br",raw:J[0]}}del($,J,Q=""){let X=this.rules.inline.delLDelim.exec($);if(!X)return;if(!X[1]||!Q||this.rules.inline.punctuation.exec(Q)){let W=[...X[0]].length-1,G,Y,q=W,H=this.rules.inline.delRDelim;for(H.lastIndex=0,J=J.slice(-1*$.length+W);(X=H.exec(J))!==null;){if(G=X[1]||X[2]||X[3]||X[4]||X[5]||X[6],!G||(Y=[...G].length,Y!==W))continue;if(X[3]||X[4]){q+=Y;continue}if(q-=Y,q>0)continue;Y=Math.min(Y,Y+q);let B=[...X[0]][0].length,N=$.slice(0,W+X.index+B+Y),L=N.slice(W,-W);return{type:"del",raw:N,text:L,tokens:this.lexer.inlineTokens(L)}}}}autolink($){let J=this.rules.inline.autolink.exec($);if(J){let Q,X;return J[2]==="@"?(Q=J[1],X="mailto:"+Q):(Q=J[1],X=Q),{type:"link",raw:J[0],text:Q,href:X,tokens:[{type:"text",raw:Q,text:Q}]}}}url($){let J;if(J=this.rules.inline.url.exec($)){let Q,X;if(J[2]==="@")Q=J[0],X="mailto:"+Q;else{let W;do W=J[0],J[0]=this.rules.inline._backpedal.exec(J[0])?.[0]??"";while(W!==J[0]);Q=J[0],J[1]==="www."?X="http://"+J[0]:X=J[0]}return{type:"link",raw:J[0],text:Q,href:X,tokens:[{type:"text",raw:Q,text:Q}]}}}inlineText($){let J=this.rules.inline.text.exec($);if(J){let Q=this.lexer.state.inRawBlock;return{type:"text",raw:J[0],text:J[0],escaped:Q}}}},E0=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 H$,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 Q={other:R0,block:Y$.normal,inline:P2.normal};this.options.pedantic?(Q.block=Y$.pedantic,Q.inline=P2.pedantic):this.options.gfm&&(Q.block=Y$.gfm,this.options.breaks?Q.inline=P2.breaks:Q.inline=P2.gfm),this.tokenizer.rules=Q}static get rules(){return{block:Y$,inline:P2}}static lex(J,Q){return new $(Q).lex(J)}static lexInline(J,Q){return new $(Q).inlineTokens(J)}lex(J){J=J.replace(R0.carriageReturn,`
|
|
37
|
+
`),this.blockTokens(J,this.tokens);for(let Q=0;Q<this.inlineQueue.length;Q++){let X=this.inlineQueue[Q];this.inlineTokens(X.src,X.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(J,Q=[],X=!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,Q))?(J=J.substring(W.raw.length),Q.push(W),!0):!1))continue;if(W=this.tokenizer.space(J)){J=J.substring(W.raw.length);let Y=Q.at(-1);W.raw.length===1&&Y!==void 0?Y.raw+=`
|
|
38
|
+
`:Q.push(W);continue}if(W=this.tokenizer.code(J)){J=J.substring(W.raw.length);let Y=Q.at(-1);Y?.type==="paragraph"||Y?.type==="text"?(Y.raw+=(Y.raw.endsWith(`
|
|
39
|
+
`)?"":`
|
|
40
|
+
`)+W.raw,Y.text+=`
|
|
41
|
+
`+W.text,this.inlineQueue.at(-1).src=Y.text):Q.push(W);continue}if(W=this.tokenizer.fences(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.heading(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.hr(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.blockquote(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.list(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.html(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.def(J)){J=J.substring(W.raw.length);let Y=Q.at(-1);Y?.type==="paragraph"||Y?.type==="text"?(Y.raw+=(Y.raw.endsWith(`
|
|
42
|
+
`)?"":`
|
|
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},Q.push(W));continue}if(W=this.tokenizer.table(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.lheading(J)){J=J.substring(W.raw.length),Q.push(W);continue}let G=J;if(this.options.extensions?.startBlock){let Y=1/0,q=J.slice(1),H;this.options.extensions.startBlock.forEach((B)=>{H=B.call({lexer:this},q),typeof H=="number"&&H>=0&&(Y=Math.min(Y,H))}),Y<1/0&&Y>=0&&(G=J.substring(0,Y+1))}if(this.state.top&&(W=this.tokenizer.paragraph(G))){let Y=Q.at(-1);X&&Y?.type==="paragraph"?(Y.raw+=(Y.raw.endsWith(`
|
|
45
|
+
`)?"":`
|
|
46
|
+
`)+W.raw,Y.text+=`
|
|
47
|
+
`+W.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=Y.text):Q.push(W),X=G.length!==J.length,J=J.substring(W.raw.length);continue}if(W=this.tokenizer.text(J)){J=J.substring(W.raw.length);let Y=Q.at(-1);Y?.type==="text"?(Y.raw+=(Y.raw.endsWith(`
|
|
48
|
+
`)?"":`
|
|
49
|
+
`)+W.raw,Y.text+=`
|
|
50
|
+
`+W.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=Y.text):Q.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,Q}inline(J,Q=[]){return this.inlineQueue.push({src:J,tokens:Q}),Q}inlineTokens(J,Q=[]){this.tokenizer.lexer=this;let X=J,W=null;if(this.tokens.links){let H=Object.keys(this.tokens.links);if(H.length>0)for(;(W=this.tokenizer.rules.inline.reflinkSearch.exec(X))!==null;)H.includes(W[0].slice(W[0].lastIndexOf("[")+1,-1))&&(X=X.slice(0,W.index)+"["+"a".repeat(W[0].length-2)+"]"+X.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(W=this.tokenizer.rules.inline.anyPunctuation.exec(X))!==null;)X=X.slice(0,W.index)+"++"+X.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let G;for(;(W=this.tokenizer.rules.inline.blockSkip.exec(X))!==null;)G=W[2]?W[2].length:0,X=X.slice(0,W.index+G)+"["+"a".repeat(W[0].length-G-2)+"]"+X.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);X=this.options.hooks?.emStrongMask?.call({lexer:this},X)??X;let Y=!1,q="";for(;J;){Y||(q=""),Y=!1;let H;if(this.options.extensions?.inline?.some((N)=>(H=N.call({lexer:this},J,Q))?(J=J.substring(H.raw.length),Q.push(H),!0):!1))continue;if(H=this.tokenizer.escape(J)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.tag(J)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.link(J)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.reflink(J,this.tokens.links)){J=J.substring(H.raw.length);let N=Q.at(-1);H.type==="text"&&N?.type==="text"?(N.raw+=H.raw,N.text+=H.text):Q.push(H);continue}if(H=this.tokenizer.emStrong(J,X,q)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.codespan(J)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.br(J)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.del(J,X,q)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.autolink(J)){J=J.substring(H.raw.length),Q.push(H);continue}if(!this.state.inLink&&(H=this.tokenizer.url(J))){J=J.substring(H.raw.length),Q.push(H);continue}let B=J;if(this.options.extensions?.startInline){let N=1/0,L=J.slice(1),M;this.options.extensions.startInline.forEach((F)=>{M=F.call({lexer:this},L),typeof M=="number"&&M>=0&&(N=Math.min(N,M))}),N<1/0&&N>=0&&(B=J.substring(0,N+1))}if(H=this.tokenizer.inlineText(B)){J=J.substring(H.raw.length),H.raw.slice(-1)!=="_"&&(q=H.raw.slice(-1)),Y=!0;let N=Q.at(-1);N?.type==="text"?(N.raw+=H.raw,N.text+=H.text):Q.push(H);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 Q}},q$=class{options;parser;constructor($){this.options=$||P1}space($){return""}code({text:$,lang:J,escaped:Q}){let X=(J||"").match(R0.notSpaceStart)?.[0],W=$.replace(R0.endingNewline,"")+`
|
|
51
|
+
`;return X?'<pre><code class="language-'+p0(X)+'">'+(Q?W:p0(W,!0))+`</code></pre>
|
|
52
|
+
`:"<pre><code>"+(Q?W:p0(W,!0))+`</code></pre>
|
|
53
|
+
`}blockquote({tokens:$}){return`<blockquote>
|
|
54
|
+
${this.parser.parse($)}</blockquote>
|
|
55
|
+
`}html({text:$}){return $}def($){return""}heading({tokens:$,depth:J}){return`<h${J}>${this.parser.parseInline($)}</h${J}>
|
|
56
|
+
`}hr($){return`<hr>
|
|
57
|
+
`}list($){let{ordered:J,start:Q}=$,X="";for(let Y=0;Y<$.items.length;Y++){let q=$.items[Y];X+=this.listitem(q)}let W=J?"ol":"ul",G=J&&Q!==1?' start="'+Q+'"':"";return"<"+W+G+`>
|
|
58
|
+
`+X+"</"+W+`>
|
|
59
|
+
`}listitem($){return`<li>${this.parser.parse($.tokens)}</li>
|
|
60
|
+
`}checkbox({checked:$}){return"<input "+($?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:$}){return`<p>${this.parser.parseInline($)}</p>
|
|
61
|
+
`}table($){let J="",Q="";for(let W=0;W<$.header.length;W++)Q+=this.tablecell($.header[W]);J+=this.tablerow({text:Q});let X="";for(let W=0;W<$.rows.length;W++){let G=$.rows[W];Q="";for(let Y=0;Y<G.length;Y++)Q+=this.tablecell(G[Y]);X+=this.tablerow({text:Q})}return X&&(X=`<tbody>${X}</tbody>`),`<table>
|
|
62
|
+
<thead>
|
|
63
|
+
`+J+`</thead>
|
|
64
|
+
`+X+`</table>
|
|
65
|
+
`}tablerow({text:$}){return`<tr>
|
|
66
|
+
${$}</tr>
|
|
67
|
+
`}tablecell($){let J=this.parser.parseInline($.tokens),Q=$.header?"th":"td";return($.align?`<${Q} align="${$.align}">`:`<${Q}>`)+J+`</${Q}>
|
|
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:Q}){let X=this.parser.parseInline(Q),W=y4($);if(W===null)return X;$=W;let G='<a href="'+$+'"';return J&&(G+=' title="'+p0(J)+'"'),G+=">"+X+"</a>",G}image({href:$,title:J,text:Q,tokens:X}){X&&(Q=this.parser.parseInline(X,this.parser.textRenderer));let W=y4($);if(W===null)return p0(Q);$=W;let G=`<img src="${$}" alt="${p0(Q)}"`;return J&&(G+=` title="${p0(J)}"`),G+=">",G}text($){return"tokens"in $&&$.tokens?this.parser.parseInline($.tokens):("escaped"in $)&&$.escaped?$.text:p0($.text)}},K5=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 $}},y0=class ${options;renderer;textRenderer;constructor(J){this.options=J||P1,this.options.renderer=this.options.renderer||new q$,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new K5}static parse(J,Q){return new $(Q).parse(J)}static parseInline(J,Q){return new $(Q).parseInline(J)}parse(J){this.renderer.parser=this;let Q="";for(let X=0;X<J.length;X++){let W=J[X];if(this.options.extensions?.renderers?.[W.type]){let Y=W,q=this.options.extensions.renderers[Y.type].call({parser:this},Y);if(q!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(Y.type)){Q+=q||"";continue}}let G=W;switch(G.type){case"space":{Q+=this.renderer.space(G);break}case"hr":{Q+=this.renderer.hr(G);break}case"heading":{Q+=this.renderer.heading(G);break}case"code":{Q+=this.renderer.code(G);break}case"table":{Q+=this.renderer.table(G);break}case"blockquote":{Q+=this.renderer.blockquote(G);break}case"list":{Q+=this.renderer.list(G);break}case"checkbox":{Q+=this.renderer.checkbox(G);break}case"html":{Q+=this.renderer.html(G);break}case"def":{Q+=this.renderer.def(G);break}case"paragraph":{Q+=this.renderer.paragraph(G);break}case"text":{Q+=this.renderer.text(G);break}default:{let Y='Token with "'+G.type+'" type was not found.';if(this.options.silent)return console.error(Y),"";throw Error(Y)}}}return Q}parseInline(J,Q=this.renderer){this.renderer.parser=this;let X="";for(let W=0;W<J.length;W++){let G=J[W];if(this.options.extensions?.renderers?.[G.type]){let q=this.options.extensions.renderers[G.type].call({parser:this},G);if(q!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(G.type)){X+=q||"";continue}}let Y=G;switch(Y.type){case"escape":{X+=Q.text(Y);break}case"html":{X+=Q.html(Y);break}case"link":{X+=Q.link(Y);break}case"image":{X+=Q.image(Y);break}case"checkbox":{X+=Q.checkbox(Y);break}case"strong":{X+=Q.strong(Y);break}case"em":{X+=Q.em(Y);break}case"codespan":{X+=Q.codespan(Y);break}case"br":{X+=Q.br(Y);break}case"del":{X+=Q.del(Y);break}case"text":{X+=Q.text(Y);break}default:{let q='Token with "'+Y.type+'" type was not found.';if(this.options.silent)return console.error(q),"";throw Error(q)}}}return X}},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 $?E0.lex:E0.lexInline}provideParser($=this.block){return $?y0.parse:y0.parseInline}},iJ=class{defaults=B5();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=y0;Renderer=q$;TextRenderer=K5;Lexer=E0;Tokenizer=H$;Hooks=A2;constructor(...$){this.use(...$)}walkTokens($,J){let Q=[];for(let X of $)switch(Q=Q.concat(J.call(this,X)),X.type){case"table":{let W=X;for(let G of W.header)Q=Q.concat(this.walkTokens(G.tokens,J));for(let G of W.rows)for(let Y of G)Q=Q.concat(this.walkTokens(Y.tokens,J));break}case"list":{let W=X;Q=Q.concat(this.walkTokens(W.items,J));break}default:{let W=X;this.defaults.extensions?.childTokens?.[W.type]?this.defaults.extensions.childTokens[W.type].forEach((G)=>{let Y=W[G].flat(1/0);Q=Q.concat(this.walkTokens(Y,J))}):W.tokens&&(Q=Q.concat(this.walkTokens(W.tokens,J)))}}return Q}use(...$){let J=this.defaults.extensions||{renderers:{},childTokens:{}};return $.forEach((Q)=>{let X={...Q};if(X.async=this.defaults.async||X.async||!1,Q.extensions&&(Q.extensions.forEach((W)=>{if(!W.name)throw Error("extension name required");if("renderer"in W){let G=J.renderers[W.name];G?J.renderers[W.name]=function(...Y){let q=W.renderer.apply(this,Y);return q===!1&&(q=G.apply(this,Y)),q}: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 G=J[W.level];G?G.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)}),X.extensions=J),Q.renderer){let W=this.defaults.renderer||new q$(this.defaults);for(let G in Q.renderer){if(!(G in W))throw Error(`renderer '${G}' does not exist`);if(["options","parser"].includes(G))continue;let Y=G,q=Q.renderer[Y],H=W[Y];W[Y]=(...B)=>{let N=q.apply(W,B);return N===!1&&(N=H.apply(W,B)),N||""}}X.renderer=W}if(Q.tokenizer){let W=this.defaults.tokenizer||new H$(this.defaults);for(let G in Q.tokenizer){if(!(G in W))throw Error(`tokenizer '${G}' does not exist`);if(["options","rules","lexer"].includes(G))continue;let Y=G,q=Q.tokenizer[Y],H=W[Y];W[Y]=(...B)=>{let N=q.apply(W,B);return N===!1&&(N=H.apply(W,B)),N}}X.tokenizer=W}if(Q.hooks){let W=this.defaults.hooks||new A2;for(let G in Q.hooks){if(!(G in W))throw Error(`hook '${G}' does not exist`);if(["options","block"].includes(G))continue;let Y=G,q=Q.hooks[Y],H=W[Y];A2.passThroughHooks.has(G)?W[Y]=(B)=>{if(this.defaults.async&&A2.passThroughHooksRespectAsync.has(G))return(async()=>{let L=await q.call(W,B);return H.call(W,L)})();let N=q.call(W,B);return H.call(W,N)}:W[Y]=(...B)=>{if(this.defaults.async)return(async()=>{let L=await q.apply(W,B);return L===!1&&(L=await H.apply(W,B)),L})();let N=q.apply(W,B);return N===!1&&(N=H.apply(W,B)),N}}X.hooks=W}if(Q.walkTokens){let W=this.defaults.walkTokens,G=Q.walkTokens;X.walkTokens=function(Y){let q=[];return q.push(G.call(this,Y)),W&&(q=q.concat(W.call(this,Y))),q}}this.defaults={...this.defaults,...X}}),this}setOptions($){return this.defaults={...this.defaults,...$},this}lexer($,J){return E0.lex($,J??this.defaults)}parser($,J){return y0.parse($,J??this.defaults)}parseMarkdown($){return(J,Q)=>{let X={...Q},W={...this.defaults,...X},G=this.onError(!!W.silent,!!W.async);if(this.defaults.async===!0&&X.async===!1)return G(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 G(Error("marked(): input parameter is undefined or null"));if(typeof J!="string")return G(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,q=await(W.hooks?await W.hooks.provideLexer($):$?E0.lex:E0.lexInline)(Y,W),H=W.hooks?await W.hooks.processAllTokens(q):q;W.walkTokens&&await Promise.all(this.walkTokens(H,W.walkTokens));let B=await(W.hooks?await W.hooks.provideParser($):$?y0.parse:y0.parseInline)(H,W);return W.hooks?await W.hooks.postprocess(B):B})().catch(G);try{W.hooks&&(J=W.hooks.preprocess(J));let Y=(W.hooks?W.hooks.provideLexer($):$?E0.lex:E0.lexInline)(J,W);W.hooks&&(Y=W.hooks.processAllTokens(Y)),W.walkTokens&&this.walkTokens(Y,W.walkTokens);let q=(W.hooks?W.hooks.provideParser($):$?y0.parse:y0.parseInline)(Y,W);return W.hooks&&(q=W.hooks.postprocess(q)),q}catch(Y){return G(Y)}}}onError($,J){return(Q)=>{if(Q.message+=`
|
|
69
|
+
Please report this to https://github.com/markedjs/marked.`,$){let X="<p>An error occurred:</p><pre>"+p0(Q.message+"",!0)+"</pre>";return J?Promise.resolve(X):X}if(J)return Promise.reject(Q);throw Q}}},C1=new iJ;function s($,J){return C1.parse($,J)}s.options=s.setOptions=function($){return C1.setOptions($),s.defaults=C1.defaults,h4(s.defaults),s};s.getDefaults=B5;s.defaults=P1;s.use=function(...$){return C1.use(...$),s.defaults=C1.defaults,h4(s.defaults),s};s.walkTokens=function($,J){return C1.walkTokens($,J)};s.parseInline=C1.parseInline;s.Parser=y0;s.parser=y0.parse;s.Renderer=q$;s.TextRenderer=K5;s.Lexer=E0;s.lexer=E0.lex;s.Tokenizer=H$;s.Hooks=A2;s.parse=s;var{options:hW,setOptions:mW,use:cW,walkTokens:uW,parseInline:pW}=s;var lW=y0.parse,dW=E0.lex;import{useEffect as o4,useMemo as f5,useRef as rJ,useState as V2}from"react";import{jsxDEV as w0}from"react/jsx-dev-runtime";function O5({open:$,onClose:J,onSubmit:Q,includedRemoteIds:X,onToggleRemoteId:W}){let{annotations:G,generalNote:Y,submittableResponses:q,feedbackEntries:H}=O1(),[B,N]=V2(""),[L,M]=V2(!1),[F,w]=V2(!1),[R,z]=V2(null),f=rJ(null),[O,_]=V2(!1),j=f5(()=>G.filter((m)=>m.source==="remote"),[G]);if($&&!O)M(!1),w(!1),z(null);if(!$&&O)M(!1),w(!1),z(null);if($!==O)_($);let T=f5(()=>n1(G,Y,q,H,X),[G,Y,q,H,X]),h=L?B:T;if(o4(()=>{if($&&F&&f.current)f.current.focus()},[$,F]),o4(()=>{if(!$)return;let m=(c)=>{if(c.key==="Escape")J()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[$,J]),!$)return null;let g=h.trim().length>0;return w0("div",{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm flex items-center justify-center p-8",onClick:J,children:w0("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:(m)=>m.stopPropagation(),children:[w0("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border-subtle flex-shrink-0",children:[w0("div",{className:"flex items-center gap-3",children:[w0("span",{className:"text-[13px] font-medium text-text-primary font-body",children:"Response preview"},void 0,!1,void 0,this),L&&w0("button",{onClick:()=>{M(!1),w(!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),w0("div",{className:"flex items-center gap-2",children:[w0("div",{className:"flex items-center bg-bg-base rounded-md p-0.5",children:[w0("button",{onClick:()=>w(!1),className:`px-2.5 py-1 rounded text-[11px] font-body font-medium transition-colors ${!F?"bg-bg-elevated text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,children:"Preview"},void 0,!1,void 0,this),w0("button",{onClick:()=>w(!0),className:`px-2.5 py-1 rounded text-[11px] font-body font-medium transition-colors ${F?"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),w0("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),F?w0("textarea",{ref:f,value:h,onChange:(m)=>{N(m.currentTarget.value),M(!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):w0("div",{className:"flex-1 overflow-y-auto p-5",children:w0(N$,{text:h},void 0,!1,void 0,this)},void 0,!1,void 0,this),j.length>0&&w0("div",{className:"px-5 py-2 border-t border-border-subtle flex-shrink-0",children:w0("span",{className:"text-[12px] text-text-secondary font-body",children:["Reviewer feedback: ",X.size,"/",j.length," included"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),R&&w0("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:[w0("span",{children:R},void 0,!1,void 0,this),w0("button",{onClick:()=>{z(null),Q(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),w0("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-border-subtle flex-shrink-0",children:[w0("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),w0("button",{onClick:()=>{let m=o1(q,H);if(m.length>0){z(`Please answer: ${m.join(", ")}`);return}z(null),Q(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 nJ=/!\[([^\]]*)\]\((\/tmp\/agent-canvas\/uploads\/([^)]+))\)/g;function oJ($){return $.replace(nJ,(J,Q,X,W)=>``)}function N$({text:$}){let J=f5(()=>s.parse(oJ($),{async:!1}),[$]);return w0("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 b,Fragment as F$}from"react/jsx-dev-runtime";function w$({onSubmit:$,collapseButton:J}){let{isReadOnly:Q,selectedRevision:X,currentRevision:W,revisions:G,agentWatching:Y}=R5($2),q=R5(sJ),H=G.find((M)=>M.revision===X),B=Q&&X===W,N=!!H?.feedbackConsumed,L=H?.label||`Round ${X}`;if(Q)return b(eJ,{sessionId:q,revision:X,label:L,waitingForUpdate:B,feedbackConsumed:N,agentWatching:Y,collapseButton:J},void 0,!1,void 0,this);return b(J9,{onSubmit:$,agentWatching:Y,collapseButton:J},void 0,!1,void 0,this)}function aJ({sessionId:$,revision:J,label:Q,waitingForUpdate:X,feedbackConsumed:W,agentWatching:G,collapseButton:Y}){let H=t0().isShared;return b("div",{className:"flex flex-col h-full",children:[b("div",{className:"px-4 py-3 flex items-center justify-between flex-shrink-0",children:[b("span",{className:"text-[11px] font-medium uppercase tracking-widest text-text-tertiary font-body",children:X?"Feedback sent":`Feedback — ${Q}`},void 0,!1,void 0,this),Y]},void 0,!0,void 0,this),X&&!H&&b(a4,{feedbackConsumed:W,agentWatching:G},void 0,!1,void 0,this),b(e4,{sessionId:$,revision:J},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function a4({feedbackConsumed:$,agentWatching:J}){if($)return b("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:[b("span",{className:"w-2 h-2 rounded-full bg-accent-green animate-pulse"},void 0,!1,void 0,this),b("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 b("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:[b("span",{className:"w-2 h-2 rounded-full bg-accent-blue animate-pulse"},void 0,!1,void 0,this),b("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 b("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:[b("span",{className:"w-2 h-2 rounded-full bg-accent-amber"},void 0,!1,void 0,this),b("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 eJ({sessionId:$,revision:J,label:Q,waitingForUpdate:X,feedbackConsumed:W,agentWatching:G,collapseButton:Y}){let{annotations:q,generalNote:H}=O1(),B=q.length>0||H.trim().length>0,[N,L]=Q2("feedback");if(!B)return b(aJ,{sessionId:$,revision:J,label:Q,waitingForUpdate:X,feedbackConsumed:W,agentWatching:G,collapseButton:Y},void 0,!1,void 0,this);return b("div",{className:"flex flex-col h-full",children:[b("div",{className:"px-4 py-3 flex items-center justify-between flex-shrink-0",children:[b("div",{className:"flex items-center gap-1 bg-bg-input rounded-md p-0.5",children:[b("button",{onClick:()=>L("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),b("button",{onClick:()=>L("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",b("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:q.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),X&&b(a4,{feedbackConsumed:W,agentWatching:G},void 0,!1,void 0,this),N==="feedback"?b(e4,{sessionId:$,revision:J},void 0,!1,void 0,this):b(F$,{children:[b("div",{className:"flex-1 overflow-y-auto",children:b($3,{annotations:q,readOnly:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this),H.trim()&&b("div",{className:"border-t border-border-subtle px-4 py-3 flex-shrink-0",children:b("div",{className:"text-[13px] font-body text-text-primary leading-relaxed",children:H},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 e4({sessionId:$,revision:J}){let Q=t0(),[X,W]=Q2(null),[G,Y]=Q2(!0);return t4(()=>{if(Y(!0),!Q.fsAvailable){W(null),Y(!1);return}fetch(`/api/session/${$}/revision/${J}/feedback`).then((q)=>q.json()).then((q)=>{W(j4.parse(q).feedback||null),Y(!1)}).catch(()=>{W(null),Y(!1)})},[$,J]),b("div",{className:"flex-1 overflow-y-auto px-4",children:G?b("p",{className:"text-[12px] text-text-tertiary font-body py-4",children:"Loading..."},void 0,!1,void 0,this):X?b(N$,{text:X},void 0,!1,void 0,this):b("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 $9($){let J=$.filter((Y)=>Y.filePath===d1),Q=$.filter((Y)=>!Y.filePath),X=$.filter((Y)=>M1(Y)!==void 0),W={};for(let Y of X){let q=M1(Y);if(!q)continue;let H=W[q];if(H)H.push(Y);else W[q]=[Y]}let G=[J,Q,X].filter((Y)=>Y.length>0).length>1;return{response:J,plan:Q,fileGroups:W,hasMultipleGroups:G}}function s4({children:$}){return b("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 $3({annotations:$,readOnly:J,includedRemoteIds:Q,onToggleRemoteId:X}){let{setActiveView:W}=R5(e1),{response:G,plan:Y,fileGroups:q,hasMultipleGroups:H}=$9($),B=S5((M)=>{let F=M1(M);if(!F)return;W({type:"file",path:F}),setTimeout(()=>{let w=C2(M);if(w)w.scrollIntoView({behavior:"smooth",block:"center"})},150)},[W]),N=S5((M)=>H5(M,W),[W]),L={readOnly:J,onSelect:B,onReveal:N,includedRemoteIds:Q,onToggleRemoteId:X};return b(F$,{children:[G.length>0&&b(F$,{children:[H&&b(s4,{children:"Agent Response"},void 0,!1,void 0,this),b(O2,{annotations:G,...L},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y.length>0&&b(F$,{children:[H&&b(s4,{children:"Canvas"},void 0,!1,void 0,this),b(O2,{annotations:Y,...L},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Object.entries(q).map(([M,F])=>b("div",{children:[b("button",{onClick:()=>W({type:"file",path:M}),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:M,children:[b(q5,{name:M.split("/").pop()||M,type:"file"},void 0,!1,void 0,this),b("span",{className:"truncate",children:M},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b(O2,{annotations:F,...L},void 0,!1,void 0,this)]},M,!0,void 0,this))]},void 0,!0,void 0,this)}function J9({onSubmit:$,agentWatching:J,collapseButton:Q}){let X=t0(),[W,G]=Q2(!1),{annotations:Y,generalNote:q,submittableResponses:H,feedbackEntries:B}=O1(),N=tJ(()=>Y.filter((j)=>j.source==="remote"),[Y]),[L,M]=Q2(()=>new Set);t4(()=>{if(N.length===0)return;M((j)=>{let T=new Set(j);for(let h of N)T.add(h.id);return T.size===j.size?j:T})},[N]);let F=S5((j)=>{M((T)=>{let h=new Set(T);if(h.has(j))h.delete(j);else h.add(j);return h})},[]),w=Array.from(H.values()).some($$),R=B.size>0,z=Y.length>0||q.trim().length>0||w||R,[f,O]=Q2(null),_=()=>{let j=n1(Y,q,H,B,L);$(j)};return b("div",{className:"flex flex-col h-full",children:[b("div",{className:"px-4 py-3 flex items-center justify-between flex-shrink-0",children:[b("span",{className:"text-[11px] font-medium uppercase tracking-widest text-text-tertiary font-body flex items-center gap-2",children:["Annotations",Y.length>0&&b("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),!X.isShared&&b("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),Q]},void 0,!0,void 0,this),b("div",{className:"flex-1 overflow-y-auto",children:[Y.length===0&&b("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),b($3,{annotations:Y,includedRemoteIds:L,onToggleRemoteId:F},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b(i$,{hasContent:z,onSubmit:()=>{let j=o1(H,B);if(j.length>0){O(`Please answer: ${j.join(", ")}`);return}O(null),_()},onSubmitEmpty:()=>$("No feedback — looks good."),notice:f&&b("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:[b("span",{children:f},void 0,!1,void 0,this),b("button",{onClick:()=>{O(null),_()},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:b("button",{onClick:()=>G(!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),b(O5,{open:W,onClose:()=>G(!1),onSubmit:$,includedRemoteIds:L,onToggleRemoteId:F},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useFeedback as aH}from"#canvas/runtime";import SY from"react";import{jsxDEV as CY}from"react/jsx-dev-runtime";s.setOptions({gfm:!0,breaks:!1});import{jsxDEV as jY}from"react/jsx-dev-runtime";import{jsxDEV as TY}from"react/jsx-dev-runtime";import{useAnnotations as xY,useResponseRegistration as vY}from"#canvas/runtime";import{useEffect as mY,useMemo as cY,useRef as uY,useState as pY}from"react";import{jsxDEV as gY}from"react/jsx-dev-runtime";import{jsxDEV as iY}from"react/jsx-dev-runtime";import{useEffect as tY,useRef as aY}from"react";import{jsxDEV as JG}from"react/jsx-dev-runtime";import{jsxDEV as HG}from"react/jsx-dev-runtime";import{ActiveViewCtx as BG,SessionContext as NG}from"#canvas/runtime";import{useContext as wG,useEffect as LG,useRef as MG,useState as _G}from"react";import{jsxDEV as OG}from"react/jsx-dev-runtime";import{SessionContext as CG}from"#canvas/runtime";import{useContext as kG,useState as AG}from"react";import{jsxDEV as VG}from"react/jsx-dev-runtime";import{useMemo as IG}from"react";import{jsxDEV as EG}from"react/jsx-dev-runtime";s.setOptions({gfm:!0,breaks:!1});import{useAnnotations as hG,useCanvasFile as mG}from"#canvas/runtime";import{useCallback as lG,useEffect as dG,useRef as iG,useState as rG}from"react";import oG from"react-dom";import{jsxDEV as aG,Fragment as eG}from"react/jsx-dev-runtime";import{jsxDEV as XH}from"react/jsx-dev-runtime";import{jsxDEV as GH}from"react/jsx-dev-runtime";import{useState as BH}from"react";import{jsxDEV as wH}from"react/jsx-dev-runtime";import{jsxDEV as _H}from"react/jsx-dev-runtime";import{jsxDEV as OH}from"react/jsx-dev-runtime";import{useAnnotations as CH,useResponseRegistration as PH}from"#canvas/runtime";import{useRef as jH,useState as VH}from"react";import{jsxDEV as DH}from"react/jsx-dev-runtime";import{CanvasFileCtx as W9,SessionContext as Y9}from"#canvas/runtime";import L$,{useContext as X3,useEffect as q1,useMemo as Z2,useRef as G9,useState as l0}from"react";import{createPortal as H9}from"react-dom";import{createContext as X9}from"react";var P5=X9(()=>{});import{jsxDEV as Y0,Fragment as N9}from"react/jsx-dev-runtime";class W3 extends L$.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 Y0(Y3,{message:this.state.error.message},void 0,!1,void 0,this)}}function Y3({message:$}){return Y0("div",{className:"bg-accent-red-muted rounded-lg p-5",children:[Y0("h3",{className:"font-body font-semibold text-accent-red mb-2",children:"Canvas render failed"},void 0,!1,void 0,this),Y0("pre",{className:"text-code font-mono text-text-secondary whitespace-pre-wrap",children:$},void 0,!1,void 0,this),Y0("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 M$({revision:$,filename:J}){let Q=X3(Y9),X=t0(),W=X3(P5),[G,Y]=l0(null),[q,H]=l0(null),[B,N]=l0(!0),L=G9(null),{annotations:M,addAnnotationWithId:F,removeAnnotation:w,updateAnnotation:R,addAnnotationImage:z,removeAnnotationImage:f,activeAnnotationId:O,setActiveAnnotationId:_,registerCanvasRendered:j}=O1(),T=Z2(()=>M.filter((Z)=>!Z.filePath&&(!Z.canvasFile||Z.canvasFile===J)),[M,J]),[h,g]=l0(null),[m,c]=l0(null),[p,Q0]=l0(null),[$0,W0]=l0(null),[z0,l]=l0(!1);q1(()=>{N(!0),H(null),W0(null),X.loadCanvasModule(J,$).then((Z)=>{Y(()=>Z.default),N(!1)}).catch((Z)=>{let E=Z instanceof Error?Z:Error(String(Z));H(E.message),N(!1),W({revision:$,filename:J,message:E.message,...E.stack?{stack:E.stack}:{}})})},[Q,$,J,W]),q1(()=>{if(G)j(J)},[G,J,j]);let J0=document.getElementById("plan-scroll-container"),{popovers:a,isPopoverOpen:H0}=$5({containerRef:L,restoreKey:G,restoreAnnotations:T,extractContext:(Z)=>T$(Z,L.current),canvasFile:J,scrollContainer:J0}),{popovers:e,isDrawing:X0,isPopoverOpen:B0}=a$({containerRef:L,restoreKey:G,canvasFile:J,scrollContainer:J0}),A=H0||B0,I=Z2(()=>{let Z=new Map;for(let E of T)if(E.snippet.startsWith("["))Z.set(E.snippet,E.id);return Z},[T]);q1(()=>{let Z=L.current;if(!Z)return;let E=(C)=>{if(p||A||X0)return;let y=C.target;if(y.closest("[data-block-comment-btn]"))return;l(!1);let i=y.closest(Z1);if(i&&Z.contains(i)){let j0=k1(Z).indexOf(i);W0(j0>=0?j0:null)}else W0(null);let q0=y.closest(e0);if(q0&&Z.contains(q0)){c(q0);let M0=h0(q0),j0=M0?I.get(M0):void 0;if(j0&&j0!==O)_(j0)}else c(null)},k=(C)=>{if(p||A)return;if(C.relatedTarget?.closest("[data-block-comment-btn]"))return;c(null),_(null)};return Z.addEventListener("mousemove",E),Z.addEventListener("mouseleave",k),()=>{Z.removeEventListener("mousemove",E),Z.removeEventListener("mouseleave",k)}},[G,p,A,X0,I,O]),q1(()=>{let Z=(E)=>{let k=E.target.tagName;if(k==="INPUT"||k==="TEXTAREA"||E.target.isContentEditable)return;if(p||A)return;let C=L.current;if(!C)return;if(E.key==="ArrowDown"){E.preventDefault(),l(!0);let y=k1(C);if(y.length===0)return;W0((i)=>{if(i===null)return 0;return Math.min(i+1,y.length-1)})}else if(E.key==="ArrowUp"){E.preventDefault(),l(!0);let y=k1(C);if(y.length===0)return;W0((i)=>{if(i===null)return y.length-1;return Math.max(i-1,0)})}else if(E.key==="a"||E.key==="A"){if($0===null||!C)return;let i=k1(C)[$0];if(!i)return;if(!i.matches(e0))return;E.preventDefault();let q0=h0(i);if(!q0)return;let M0=I.get(q0);if(M0)_(M0),Q0({anchorEl:i,snippet:q0,annId:M0});else Q0({anchorEl:i,snippet:q0})}else if(E.key===" "||E.key==="Enter"){if($0===null)return;let i=k1(C)[$0];if(!i)return;let q0=i.getAttribute("data-md");if(q0==="choice-option"||q0==="multichoice-option")E.preventDefault(),i.dispatchEvent(new CustomEvent("kb-select",{bubbles:!0}));else if(q0==="userinput"){E.preventDefault();let M0=i.querySelector("textarea");if(M0){M0.focus();let j0=(U1)=>{if(U1.key==="Escape")U1.preventDefault(),M0.blur(),l(!0)};M0.addEventListener("keydown",j0),M0.addEventListener("blur",()=>M0.removeEventListener("keydown",j0),{once:!0})}}else if(q0==="rangeinput"){E.preventDefault();let M0=i.querySelector("input[type='range']");if(M0){M0.focus();let j0=(U1)=>{if(U1.key==="Escape"||U1.key==="ArrowUp"||U1.key==="ArrowDown")U1.preventDefault(),M0.blur(),l(!0)};M0.addEventListener("keydown",j0),M0.addEventListener("blur",()=>M0.removeEventListener("keydown",j0),{once:!0})}}}else if(E.key==="Escape")W0(null),l(!1),_(null)};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[$0,p,A,I]),q1(()=>{let Z=L.current;if(!Z||$0===null||!z0)return;let k=k1(Z)[$0];if(!k)return;k.style.outline="2px solid var(--color-accent-blue)",k.style.outlineOffset="-2px",k.style.borderRadius="8px",k.scrollIntoView({block:"nearest",behavior:"smooth"});let C=h0(k),y=C?I.get(C):void 0;if(y)_(y);return()=>{k.style.outline="",k.style.outlineOffset="",k.style.borderRadius=""}},[$0,z0,I]);let d=Z2(()=>G?Y0(G,{},void 0,!1,void 0,this):null,[G]);if(B)return Y0("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(q)return Y0(Y3,{message:q},void 0,!1,void 0,this);if(!G)return Y0("div",{className:"text-text-tertiary text-center py-8 font-body text-body",children:"No canvas loaded"},void 0,!1,void 0,this);return Y0(W9.Provider,{value:J,children:[Y0("div",{ref:L,className:"plan-content plan-updated","data-canvas-file":J,children:Y0(W3,{revision:$,filename:J,reportError:W,children:d},`${$}:${J}`,!1,void 0,this)},void 0,!1,void 0,this),h&&Y0(B9,{note:h.note,onSave:(Z)=>{R(h.id,Z),g(null)},onCancel:()=>g(null)},void 0,!1,void 0,this),a,e,Y0(q9,{containerRef:L,hoveredBlock:m,focusedBlockIndex:$0,blockPopover:p,blockAnnotationMap:I,activeAnnotationId:O,onOpen:(Z,E,k)=>{if(k)_(k),Q0({anchorEl:Z,snippet:E,annId:k});else Q0({anchorEl:Z,snippet:E})}},void 0,!1,void 0,this),p&&!p.annId&&Y0(H1,{anchorEl:p.anchorEl,scrollContainer:J0,snippet:p.snippet,truncateAt:80,onAdd:(Z,E)=>{let k=o0();F(k,p.snippet,Z,void 0,void 0,E,J),Q0(null)},onCancel:()=>Q0(null)},void 0,!1,void 0,this),p?.annId&&(()=>{let Z=T.find((E)=>E.id===p.annId);if(!Z)return null;return Y0(R2,{anchorEl:p.anchorEl,scrollContainer:J0,initialNote:Z.note,initialImages:Z.images,onUpdate:(E,k)=>{R(p.annId,E);let C=Z.images||[];for(let y of k)if(!C.includes(y))z(p.annId,y);for(let y of C)if(!k.includes(y))f(p.annId,y)},onDelete:()=>{w(p.annId),_(null),Q0(null)},onClose:()=>Q0(null)},void 0,!1,void 0,this)})()]},void 0,!0,void 0,this)}function k1($){return Array.from($.querySelectorAll(Z1))}function q9({containerRef:$,hoveredBlock:J,focusedBlockIndex:Q,blockPopover:X,blockAnnotationMap:W,activeAnnotationId:G,onOpen:Y}){let[q,H]=l0([]);q1(()=>{let F=$.current;if(!F||W.size===0){H([]);return}let w=[];for(let R of F.querySelectorAll(e0)){let z=h0(R);if(z&&W.has(z))w.push(R)}H(w)},[W,$.current]);let[B,N]=l0(null);q1(()=>{if(!G||!$.current){N(null);return}for(let F of $.current.querySelectorAll(Z1)){let w=h0(F);if(w&&W.get(w)===G){N(F);return}}N(null)},[G,W]),q1(()=>{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 L=Z2(()=>{if(Q===null||!$.current)return null;let F=k1($.current)[Q];if(!F)return null;return F.matches(e0)?F:null},[Q,$.current]),M=Z2(()=>{let F=new Set(q);if(J)F.add(J);if(L)F.add(L);if(X?.anchorEl)F.add(X.anchorEl);return Array.from(F)},[q,J,L,X]);return Y0(N9,{children:M.map((F)=>Y0(U9,{block:F,isHovered:F===J||F===L||F===X?.anchorEl,blockAnnotationMap:W,activeAnnotationId:G,onOpen:Y},F.getAttribute("data-task-id")||F.getAttribute("data-md-title")||F.textContent?.slice(0,30)||"block",!1,void 0,this))},void 0,!1,void 0,this)}function U9({block:$,isHovered:J,blockAnnotationMap:Q,activeAnnotationId:X,onOpen:W}){let G=h0($);if(!G)return null;let Y=Q.get(G),q=!!Y;return H9(Y0("button",{"data-block-comment-btn":!0,onClick:(B)=>{B.stopPropagation(),W(B.currentTarget,G,Y)},className:`absolute top-1 right-1 z-10 w-6 h-6 flex items-center justify-center rounded transition-all duration-150 ${q?Y===X?"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:q?"Edit annotation":"Add annotation",children:Y0("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:q?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:Y0("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 B9({note:$,onSave:J,onCancel:Q}){let[X,W]=L$.useState($),G=L$.useRef(null);return L$.useEffect(()=>{G.current?.focus(),G.current?.select()},[]),Y0("div",{className:"fixed inset-0 z-50 bg-black/40 flex items-center justify-center",onClick:Q,children:Y0("div",{className:"bg-bg-elevated border border-border-hover rounded-lg shadow-md p-4 w-80",onClick:(Y)=>Y.stopPropagation(),children:[Y0("div",{className:"text-tiny uppercase tracking-widest text-text-tertiary font-body mb-2",children:"Edit annotation"},void 0,!1,void 0,this),Y0("textarea",{ref:G,value:X,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(X.trim());if(Y.key==="Escape")Q()}},void 0,!1,void 0,this),Y0("div",{className:"flex justify-end gap-2 mt-2",children:[Y0("button",{onClick:Q,className:"text-meta text-text-tertiary font-body px-3 py-1",children:"Cancel"},void 0,!1,void 0,this),Y0("button",{onClick:()=>J(X.trim()),className:"text-meta font-medium font-body px-3 py-1 rounded-md bg-highlight-bg text-text-primary border border-highlight-border",children:"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as C0,Fragment as A5}from"react/jsx-dev-runtime";function G3({gateName:$,hasGate:J,isCurrentGate:Q,onSubmit:X}){let[W,G]=z9(!0);if(!W)return C0("button",{onClick:()=>G(!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:()=>G(!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:X,collapseButton:Y},void 0,!1,void 0,this):C0(A5,{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:Q&&$?C0(A5,{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(A5,{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 K9,useState as j5}from"react";import{jsxDEV as r}from"react/jsx-dev-runtime";var X2="rounded border border-border-medium px-3 py-1 text-tiny disabled:opacity-40",H3="rounded border border-border-medium bg-bg-base px-2 py-1 text-body text-text-primary";function q3({platform:$,live:J}){let[Q,X]=j5(""),[W,G]=j5(null),[Y,q]=j5(null),{data:H,enabled:B,busy:N,error:L}=$,M=H?.connection;K9(()=>{if(M)q(M.controlOrigin)},[M?.controlOrigin]);let F=H?.pairing,w=H?.deployment,R=w?.status==="preparing"||w?.status==="pending"||w?.status==="running",z=F?.status==="pending"||F?.status==="approved",f=H?.credential.available&&(H.credential.expiresAt===null||H.credential.expiresAt*1000>Date.now());return r("details",{className:"shrink-0 border-b border-border-subtle bg-bg-surface px-6 py-2",open:!0,children:[r("summary",{className:"cursor-pointer font-heading text-section",children:"Deployment"},void 0,!1,void 0,this),r("div",{className:"max-h-64 space-y-3 overflow-y-auto py-3 text-body","aria-busy":N,children:[!J&&r("p",{className:"text-text-tertiary",children:"Offline / demo mode — deployment controls are disabled."},void 0,!1,void 0,this),J&&!H&&!L&&r("p",{role:"status",children:"Loading project status…"},void 0,!1,void 0,this),L&&r("p",{role:"alert",className:"text-accent-red",children:L},void 0,!1,void 0,this),M?r("div",{className:"space-y-1",children:[r("p",{children:["App ",r("strong",{children:M.receipt.app.id},void 0,!1,void 0,this)," · ",M.receipt.provider," · ",M.receipt.environment.env]},void 0,!0,void 0,this),r("p",{className:"text-text-secondary",children:["Control: ",M.controlOrigin]},void 0,!0,void 0,this),r("p",{children:["Local credential: ",f?"available":"unavailable or expired",H?.credential.expiresAt!=null&&` · expires ${new Date(H.credential.expiresAt*1000).toLocaleString()}`]},void 0,!0,void 0,this),r("a",{className:"text-accent-blue underline",href:M.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):r("p",{className:"text-text-secondary",children:"No platform connection."},void 0,!1,void 0,this),!M&&Y&&r("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),r("form",{className:"flex flex-wrap items-center gap-2",onSubmit:(O)=>{O.preventDefault(),$.act({kind:"connect",controlOrigin:Q})},children:[r("label",{htmlFor:"control-origin",children:"Control origin"},void 0,!1,void 0,this),r("input",{className:H3,id:"control-origin",type:"url",value:Q,onChange:(O)=>X(O.currentTarget.value),placeholder:"https://control.example.com",disabled:!B||!!M||z,required:!0},void 0,!1,void 0,this),r("button",{className:X2,type:"submit",disabled:!B||!!M||z,children:N?"Working…":"Connect"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F?.status==="pending"&&B&&F.expiresAt*1000>Date.now()&&r("a",{className:"text-accent-blue underline",href:F.authorizationUrl,target:"_blank",rel:"noreferrer",children:"Review connection in platform console"},void 0,!1,void 0,this),F&&r("p",{role:"status",children:["Connection: ",F.status,(F.status==="failed"||F.status==="recovery_required")&&` — ${F.message}`]},void 0,!0,void 0,this),r("div",{className:"flex flex-wrap items-center gap-2",children:[r("button",{className:X2,type:"button",disabled:!B||!M&&!F,onClick:()=>void $.act({kind:"disconnect"}),children:"Disconnect locally"},void 0,!1,void 0,this),r("span",{className:"text-tiny text-text-tertiary",children:"Deletes local credentials only. Revoke server access in the console."},void 0,!1,void 0,this),r("button",{className:X2,type:"button",disabled:!B||!M||!f||R||z,onClick:()=>void $.act({kind:"deploy"}),children:R?"Deploy in progress…":"Deploy pushed commit"},void 0,!1,void 0,this),r("button",{className:X2,type:"button",disabled:!J||N,onClick:$.refresh,children:"Refresh status"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w&&r("div",{role:"status",className:"space-y-1",children:[r("p",{children:["Deployment: ",r("strong",{children:w.status},void 0,!1,void 0,this),w.message&&` — ${w.message}`]},void 0,!0,void 0,this),w.runId&&r("p",{children:["Run: ",r("code",{children:w.runId},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.commitSha&&r("p",{children:["Commit: ",r("code",{children:w.commitSha},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w.consoleUrl&&r("a",{className:"mr-4 text-accent-blue underline",href:w.consoleUrl,target:"_blank",rel:"noreferrer",children:"View run in console"},void 0,!1,void 0,this),w.appUrl&&r("a",{className:"text-accent-blue underline",href:w.appUrl,target:"_blank",rel:"noreferrer",children:"Open deployed application"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),r("form",{className:"flex flex-wrap items-center gap-2",onSubmit:(O)=>{O.preventDefault(),$.act({kind:"preview",url:W??H?.previewUrl??""})},children:[r("label",{htmlFor:"preview-url",children:"Local preview URL"},void 0,!1,void 0,this),r("input",{className:H3,id:"preview-url",type:"url",value:W??H?.previewUrl??"",onChange:(O)=>G(O.currentTarget.value),placeholder:H?.previewUrl??"http://localhost:3000",disabled:!B,required:!0},void 0,!1,void 0,this),r("button",{className:X2,type:"submit",disabled:!B,children:"Set preview"},void 0,!1,void 0,this),r("button",{className:X2,type:"button",disabled:!B||!H?.previewUrl,onClick:()=>{G(null),$.act({kind:"preview",url:null})},children:"Clear preview"},void 0,!1,void 0,this),r("span",{className:"text-tiny text-text-tertiary",children:[H?.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 f9={connecting:"connecting…",live:"live",offline:"offline",fixture:"fixture"},O9={connecting:"bg-accent-amber",live:"bg-accent-green",offline:"bg-accent-red",fixture:"bg-accent-blue"};function U3({sessionId:$,status:J,watching:Q}){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:[Q&&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 ${O9[J]}`},void 0,!1,void 0,this),f9[J]]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var _$=["intake","vision","flows","tech","design","skeletons","issues","build"],S9={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"]}},z$=_$.map(($,J)=>({id:$,number:J+1,...S9[$]})),K$=z$.length;function R9($){return _$.indexOf($)}function B3($){let J=z$[R9($)];if(!J)throw Error(`Unknown phase id: ${$}`);return J}function T2($,J,Q){if(J.includes($))return"done";if($===Q)return"current";return"upcoming"}import{jsxDEV as U0}from"react/jsx-dev-runtime";function C9({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 N3({state:$,focused:J,onFocus:Q}){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:z$.map((X)=>{let W=T2(X.id,$.completed,$.current),G=J===X.id,Y=W!=="upcoming";return U0("li",{children:U0("button",{disabled:!Y,onClick:()=>Y&&Q(X.id),className:["group flex w-full items-start gap-3 px-4 py-2.5 text-left transition-colors",G?"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(C9,{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:[X.number,"/",K$]},void 0,!0,void 0,this),X.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:X.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},X.id,!1,void 0,this)})},void 0,!1,void 0,this),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 L7,useState as x3}from"react";var BU=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"}),NU=Object.freeze({APP:"app",ENVIRONMENT:"environment"});function P9($){if(typeof $!=="string"||$.length>2048)return null;try{let J=new URL($),Q=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:"&&Q))return null;if(J.username!==""||J.password!==""||J.pathname!=="/"||J.search!==""||J.hash!=="")return null;return J.origin}catch{return null}}var F3=U.string().transform(($,J)=>{let Q=P9($);if(Q!==null)return Q;return J.addIssue({code:"custom",message:"invalid builder public origin"}),U.NEVER}),LU=U.preprocess(($)=>{if(typeof $==="object"&&$!==null&&Object.keys($).length!==4)return;return $},U.object({version:U.literal(1),controlOrigin:F3,iamIssuer:F3,provider:U.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/)}).strict());var k9=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;var A9=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;var V5=U.number().int().safe().nonnegative(),Z5=U.string().regex(A9),j9=U.object({id:Z5,repoUrl:U.string(),defaultBranch:U.string(),workerDir:U.string().nullable(),buildCmd:U.string().nullable(),configPath:U.string().nullable(),githubConnectionId:U.string().nullable().optional(),githubInstallationId:V5.nullable(),createdAt:V5}).strict().transform(({githubConnectionId:$,githubInstallationId:J,createdAt:Q,...X})=>({...X,...$===void 0?{}:{githubConnectionId:$},githubInstallationId:J,createdAt:Q})),V9=U.object({env:Z5,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(),w3=U.object({version:U.literal(1),attemptId:U.string().regex(k9),provider:Z5,app:j9,environment:V9,createdAt:V5}).strict();var Z9=100,T9=512,fU=U.object({cursor:U.string().min(1).max(T9).optional(),limit:U.number().int().safe().min(1).max(Z9).optional()}).strict().transform(({cursor:$,limit:J})=>({...$===void 0?{}:{cursor:$},...J===void 0?{}:{limit:J}}));var f$="FABRIKA_IAM_APP_ID";var D9=/%2f|%5c/i,b9=/%2e/gi;function T5($){if($==="/")return!0;if(!$.startsWith("/")||$.includes("\\")||D9.test($))return!1;let J=$.slice(1).split("/"),Q=J.length-1;return J.every((X,W)=>(X!==""||W===Q)&&!g9(X)&&I9(X))}function I9($){try{return decodeURIComponent($),!0}catch{return!1}}function g9($){let J=$.replace(b9,".");return J==="."||J===".."}var E9=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]),y9=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function d0($,J){return $>>>J|$<<32-J}function W2($){let J=new TextEncoder().encode($),Q=new Uint8Array(Math.ceil((J.length+9)/64)*64);Q.set(J),Q[J.length]=128;let X=new DataView(Q.buffer),W=J.length*8;X.setUint32(Q.length-8,Math.floor(W/4294967296)),X.setUint32(Q.length-4,W>>>0);let G=new Uint32Array(y9),Y=new Uint32Array(64);for(let q=0;q<Q.length;q+=64){for(let f=0;f<16;f++)Y[f]=X.getUint32(q+f*4);for(let f=16;f<64;f++){let O=Y[f-15]??0,_=Y[f-2]??0,j=d0(O,7)^d0(O,18)^O>>>3,T=d0(_,17)^d0(_,19)^_>>>10;Y[f]=(Y[f-16]??0)+j+(Y[f-7]??0)+T}let[H=0,B=0,N=0,L=0,M=0,F=0,w=0,R=0]=G;for(let f=0;f<64;f++){let O=d0(M,6)^d0(M,11)^d0(M,25),_=M&F^~M&w,j=R+O+_+(E9[f]??0)+(Y[f]??0)>>>0,T=d0(H,2)^d0(H,13)^d0(H,22),h=H&B^H&N^B&N,g=T+h>>>0;R=w,w=F,F=M,M=L+j>>>0,L=N,N=B,B=H,H=j+g>>>0}let z=[H,B,N,L,M,F,w,R];for(let[f,O]of z.entries())G[f]=(G[f]??0)+O}return Array.from(G,(q)=>q.toString(16).padStart(8,"0")).join("")}var D5="FABRIKA_CONTRACT_DIGEST";var M3="*";class x9{#$;#J;constructor($,J){this.#$=$,this.#J=J}plan($,J){return v9(this.#$,this.#J,$,J)}}function v9($,J,Q,X){if(!T5(X))return{outcome:"non-canonical"};let W=m9(X),G=c9(X,J),Y=null,q=!1;for(let H of $){if(!h9(H.row.method,Q)||G!==null&&!z3(H.row.path,G))continue;let B=u9(H.segments,W);if(B===null)continue;let N=Y===null?-1:p9(H.segments,Y.endpoint.segments);if(N<0)Y={endpoint:H,params:B},q=!1;else if(N===0)q=!0}if(Y===null||q)return{outcome:"no-endpoint"};return{outcome:"endpoint",endpoint:Y.endpoint.row,params:Y.params}}function h9($,J){return $===M3||$===J}function m9($){return $==="/"?[]:$.slice(1).split("/")}function z3($,J){return $.startsWith(`${J}/`)}function c9($,J){let Q=null;for(let X of J)if(z3($,X)&&(Q===null||X.length>Q.length))Q=X;return Q}function u9($,J){let Q=[];for(let[X,W]of $.entries()){if(W.kind==="wildcard")return X===0||J.length>X?Object.fromEntries(Q):null;let G=J[X];if(G===void 0)return null;if(W.kind==="param"){if(G==="")return null;Q.push([W.name,G])}else if(W.value!==G)return null}return $.length===J.length?Object.fromEntries(Q):null}var _3={literal:0,param:1,wildcard:2};function p9($,J){let Q=Math.min($.length,J.length);for(let X=0;X<Q;X++){let W=$[X],G=J[X];if(W===void 0||G===void 0)break;let Y=_3[W.kind]-_3[G.kind];if(Y!==0)return Y}return $.length-J.length}var O$="FABRIKA_IAM_ISSUER";var S$="FABRIKA_PROXY_SECRET";var l9="FABRIKA_SOURCE_MAP_UPLOAD",d9="FABRIKA_SOURCE_MAP_UPLOAD_KEY",b5="FABRIKA_TOKEN_KEYS",I5="FABRIKA_APP_ORIGIN",g5="FABRIKA_OPS_KEY_DIGESTS",i9="FABRIKA_APPLICATION_OBJECT",r9="FABRIKA_APPLICATION_OBJECTS",n9=["FABRIKA_RELEASE",D5,O$,f$,"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",S$,"FABRIKA_IAM_RPC_URL","FABRIKA_IAM_RPC_KEY",l9,d9,b5,I5,g5,i9,r9];var JB=new Set(n9);function o9($){return $.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()}var E5=["mail","source"];function y5($){let J=`FABRIKA_PLATFORM_${o9($)}`;return{url:`${J}_URL`,key:`${J}_KEY`}}var QB=new Set(E5.flatMap(($)=>Object.values(y5($))));var s9=["FABRIKA_RELEASE","FABRIKA_OPERATIONS_DSN",O$,f$,"FABRIKA_APP_ID","FABRIKA_ENVIRONMENT","FABRIKA_SERVICE_KEY",S$,"FABRIKA_IAM_RPC_URL","FABRIKA_IAM_RPC_KEY",I5,b5,g5],zB=new Set(s9);var KB=new Set(E5.map(($)=>y5($).url));var t9="/__fabrika/ops/";var DB=`${t9}*`;var a9=100,bB=(a9-2)/2;var IB=W2("");var gB=-(2n**63n),EB=2n**63n-1n;var e9="__Host-px_",UN=`${e9}session`;var K3=100,V0=U.string().min(1),$7=U.enum(["open","read-only","closed","inspect"]),J7=U.object({appId:V0,env:V0,before:V0.optional(),limit:U.number().int().min(1).max(K3).optional()}).strict(),Q7=U.discriminatedUnion("kind",[U.object({appId:V0,env:V0,kind:U.literal("maintenance"),mode:$7}).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()]),X7=U.object({appId:V0,env:V0,operationId:V0,resolution:U.enum(["resume","open"])}).strict();var tN=U.object({ts:U.number().finite(),stream:U.enum(["stdout","stderr","meta"]),text:U.string()});function f3($,J){if(typeof $!=="string"||$.length===0||$.trim()!==$||[...$].some((X)=>X.charCodeAt(0)<=32||X.charCodeAt(0)===127||X==="\\"))throw Error(`${J} must be an HTTP(S) URL`);let Q;try{Q=new URL($)}catch{throw Error(`${J} must be an HTTP(S) URL`)}if(!/^https?:\/\//i.test($)||Q.protocol!=="https:"&&Q.protocol!=="http:"||Q.username||Q.password||/^https?:\/\/[^/?#]*@/i.test($))throw Error(`${J} must be an HTTP(S) URL without credentials`);return Q}function Y2($,J="origin"){let Q=f3($,J);if(typeof $!=="string"||!/^https?:\/\/[^/?#]+\/?$/i.test($)||Q.pathname!=="/"||Q.search||Q.hash)throw Error(`${J} must be an origin without a path, query, or fragment`);let X=Q.hostname==="localhost"||Q.hostname==="127.0.0.1"||Q.hostname==="[::1]"||Q.hostname.endsWith(".localhost"),W=$.slice($.indexOf("://")+3).replace(/\/$/,"").toLowerCase(),G=Q.hostname!=="127.0.0.1"||/^127\.0\.0\.1(?::\d+)?$/.test(W);if(Q.protocol!=="https:"&&(!X||!G))throw Error(`${J} must use HTTPS except on localhost`);return Q.origin}function D2($){return f3($,"preview URL").href}var k0=U.union([U.number(),U.nan()]),L0=U.string().optional().catch(void 0),O3=U.enum(_$),W7=U.object({current:O3,index:k0,completed:U.array(O3),reads:U.array(U.string()),produces:U.array(U.string()),gate:U.boolean(),satisfied:U.boolean()}),S3=W7.extend({gateName:U.string().nullable().optional().catch(void 0)}).transform(({gateName:$,...J})=>({...J,...$===void 0?{}:{gateName:$}})),MF=U.object({ok:U.literal(!0),version:L0,pid:k0.optional().catch(void 0),dataDir:L0,sessionsDir:U.string(),sessions:U.union([k0,U.array(U.string())]).optional().catch(void 0)}).transform(({ok:$,version:J,pid:Q,dataDir:X,sessionsDir:W,sessions:G})=>({ok:$,...J===void 0?{}:{version:J},...Q===void 0?{}:{pid:Q},...X===void 0?{}:{dataDir:X},sessionsDir:W,...G===void 0?{}:{sessions:G}})),R3=U.object({ok:U.literal(!0),version:L0,sessions:U.array(U.string()).optional().catch(void 0)}).transform(({ok:$,version:J,sessions:Q})=>({ok:$,...J===void 0?{}:{version:J},...Q===void 0?{}:{sessions:Q}})),_F=U.object({ok:U.literal(!0),sessionsDir:U.string()}),C3=U.object({error:U.object({code:U.literal("builder_platform"),message:U.string().max(1000)})}),zF=U.object({ok:U.boolean(),browserUrl:L0,revision:k0.optional().catch(void 0),isNew:U.boolean().optional().catch(void 0),canvasFiles:U.array(U.string()).optional().catch(void 0),gate:L0,error:L0,errors:U.record(U.string()).optional().catch(void 0)}).transform(({ok:$,browserUrl:J,revision:Q,isNew:X,canvasFiles:W,gate:G,error:Y,errors:q})=>({ok:$,...J===void 0?{}:{browserUrl:J},...Q===void 0?{}:{revision:Q},...X===void 0?{}:{isNew:X},...W===void 0?{}:{canvasFiles:W},...G===void 0?{}:{gate:G},...Y===void 0?{}:{error:Y},...q===void 0?{}:{errors:q}})),P3=U.object({status:U.enum(["queued","running","passed","failed","blocked","info"]),issue:L0,message:L0,at:L0,data:U.record(U.unknown()).optional().catch(void 0)}).transform(({status:$,issue:J,message:Q,at:X,data:W})=>({status:$,...J===void 0?{}:{issue:J},...Q===void 0?{}:{message:Q},...X===void 0?{}:{at:X},...W===void 0?{}:{data:W}})),KF=U.object({view:L0,directory:L0,projectRoot:L0,gate:L0,label:L0,response:L0}),k3=U.object({feedback:U.string().catch("")}),fF=k3.extend({found:U.literal(!0)}),OF=k3.extend({type:U.literal("submit")}),A3=U.object({revision:k0,hasFeedback:U.unknown().transform(($)=>$===!0),feedbackConsumed:U.unknown().transform(($)=>$===!0)}),SF=U.object({revisions:U.array(A3.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null))}),Y7=U.union([U.string().transform(($)=>({filename:$})),U.object({filename:U.string(),label:L0,diffStats:U.object({added:k0,removed:k0}).optional().catch(void 0)}).transform(({filename:$,label:J,diffStats:Q})=>({filename:$,...J===void 0?{}:{label:J},...Q===void 0?{}:{diffStats:Q}}))]).refine(($)=>$.filename.length>0),R$=U.array(Y7.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null)).catch([]),G7=U.discriminatedUnion("kind",[U.object({kind:U.literal("directory")}),U.object({kind:U.literal("view"),filename:U.string()})]),H7=A3.extend({label:U.string().nullable().catch(null),canvasFiles:R$,createdAt:L0,canvasScope:G7.optional().catch(void 0)}).transform(({createdAt:$,canvasScope:J,...Q})=>({...Q,...$===void 0?{}:{createdAt:$},...J===void 0?{}:{canvasScope:J}})).refine(($)=>$.revision>0),j3=U.object({projectRoot:L0,label:L0,gate:U.string().nullable().catch(null),currentRevision:k0.catch(0),canvasFiles:R$,revisions:U.array(H7.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null)).catch([])}).transform(({projectRoot:$,label:J,...Q})=>({...Q,...$===void 0?{}:{projectRoot:$},...J===void 0?{}:{label:J}})),q7=U.object({id:U.string(),label:L0}).transform(({id:$,label:J})=>({id:$,...J===void 0?{}:{label:J}})),V3=U.array(q7.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null)).catch([]),U7=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:L0,feature:L0}).transform(({url:$,feature:J,...Q})=>({...Q,...$===void 0?{}:{url:$},...J===void 0?{}:{feature:J}})),Z3=U.object({skeletons:U.array(U7.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null))}),T3=U.object({content:U.string()}),D3=U.object({responses:U.unknown()}),b3=U.discriminatedUnion("type",[U.object({type:U.literal("plan-updated"),currentRevision:k0,canvasFiles:U.array(U.unknown()).transform(($)=>R$.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:Q,...X}=$;return{...X,...J===void 0?{}:{canvasFiles:J},...Q===void 0?{}:{gate:Q}}}),Z0=U.string().refine(($)=>$.trim().length>0),I3=U.number().finite().nonnegative(),x5=U.string().transform(($,J)=>{try{return Y2($)}catch{return J.addIssue({code:U.ZodIssueCode.custom,message:"Invalid builder origin"}),U.NEVER}}),G2=U.string().transform(($,J)=>{try{return D2($)}catch{return J.addIssue({code:U.ZodIssueCode.custom,message:"Invalid preview URL"}),U.NEVER}}),g3=U.object({controlOrigin:x5,iamIssuer:x5,receipt:w3}).strict(),RF=U.object({profile:Z0,sessionId:Z0,createdAt:Z0.refine(($)=>Number.isFinite(Date.parse($))),connection:g3.optional(),previewUrl:G2.optional()}).strict().superRefine(($,J)=>{for(let Q of["connection","previewUrl"])if(Object.hasOwn($,Q)&&Reflect.get($,Q)===void 0)J.addIssue({code:U.ZodIssueCode.custom,path:[Q],message:"Present field must not be undefined"})}),B7=U.discriminatedUnion("status",[U.object({status:U.literal("pending"),authorizationUrl:G2.refine(($)=>{try{return Y2(new URL($).origin),!0}catch{return!1}}),expiresAt:I3}).strict(),U.object({status:U.literal("approved")}).strict(),U.object({status:U.literal("failed"),message:Z0}).strict(),U.object({status:U.literal("expired")}).strict(),U.object({status:U.literal("cancelled")}).strict(),U.object({status:U.literal("recovery_required"),message:Z0}).strict(),U.object({status:U.literal("connected")}).strict()]),N7=U.object({status:U.enum(["preparing","pending","running","awaiting_approval","succeeded","failed","cancelled"]),runId:Z0.nullable(),commitSha:Z0.nullable(),message:Z0.nullable(),appUrl:G2.nullable(),consoleUrl:G2.nullable()}).strict(),F7=U.object({sessionId:Z0,projectRoot:Z0,connection:g3.nullable(),credential:U.object({available:U.boolean(),expiresAt:I3.nullable()}).strict(),pairing:B7.nullable(),previewUrl:G2.nullable(),deployment:N7.nullable()}).strict(),CF=U.object({projectRoot:Z0}).strict(),PF=U.object({controlOrigin:x5}).strict(),kF=U.object({url:G2.nullable()}).strict();function E3($){let J=F7.safeParse($);if(!J.success)throw Error("Invalid platform status");return J.data}function y3($,J){let Q=Z0.safeParse($);if(!Q.success)throw Error("project id must be a non-empty string");return`/api/project/${encodeURIComponent(Q.data)}/${J}`}function A1(){return location.origin}function C$(){return location.pathname.match(/\/s\/([^/]+)/)?.[1]??null}function w7(){return new URLSearchParams(location.search).get("root")}async function H2($){let J=await fetch(A1()+$,{headers:{accept:"application/json"}});if(!J.ok)throw Error(`${$} -> ${J.status}`);return J.json()}var S0={async health(){let $=R3.safeParse(await H2("/health"));if(!$.success)throw Error("Invalid health response");return $.data},async phase($){let J=$??w7(),Q=C$(),X=new URLSearchParams;if(J)X.set("root",J);if(Q)X.set("session",Q);let W=X.toString(),G=S3.safeParse(await H2(`/api/phase${W?`?${W}`:""}`));if(!G.success)throw Error("Invalid phase response");return G.data},async meta($){let J=j3.safeParse(await H2(`/api/session/${encodeURIComponent($)}/meta`));if(!J.success)throw Error("Invalid session response");return{id:$,...J.data}},async artifact($,J){try{let Q=await fetch(`${A1()}/api/session/${encodeURIComponent($)}/artifact?path=${encodeURIComponent(J)}`,{headers:{accept:"application/json"}});if(!Q.ok)return null;let X=T3.safeParse(await Q.json());return X.success?X.data.content:null}catch{return null}},async sessions(){return V3.parse(await H2("/api/sessions"))},canvasUrl($,J,Q){let X=Q!=null?`?rev=${Q}`:"";return`${A1()}/api/session/${encodeURIComponent($)}/canvas/${encodeURIComponent(J)}${X}`},async skeletons($){let J=Z3.safeParse(await H2(`/api/session/${encodeURIComponent($)}/skeletons`));return J.success?J.data.skeletons:[]},async feedback($,J){let Q=await fetch(`${A1()}/api/session/${encodeURIComponent($)}/revision/${J}/feedback`);if(!Q.ok)throw Error(`feedback -> ${Q.status}`);return Q.text()},async getResponses($,J,Q){try{let X=D3.safeParse(await H2(`/api/session/${encodeURIComponent($)}/revision/${J}/responses`));return X.success?Q(X.data.responses):null}catch{return null}},async saveResponses($,J,Q){try{await fetch(`${A1()}/api/session/${encodeURIComponent($)}/revision/${J}/responses`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(Q)})}catch{}},openSocket($,J){let Q=location.protocol==="https:"?"wss:":"ws:",X=A1().replace(/^https?:/,Q),W=new WebSocket(`${X}/ws/session/${encodeURIComponent($)}`);return W.onmessage=(G)=>{try{let Y=b3.safeParse(JSON.parse(String(G.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=(Q)=>{try{let X=P3.safeParse(JSON.parse(Q.data));if(X.success)$(X.data)}catch{}},J}catch{return null}}};import{jsxDEV as G0,Fragment as P$}from"react/jsx-dev-runtime";var M7=".fabrika/architecture/design.md",_7=".fabrika/pages/_preview.html",v5=`:root{
|
|
70
|
+
--color-brand:#6f4e37; --color-brand-strong:#573c2a;
|
|
71
|
+
--color-surface:#fbf7f0; --color-surface-sunken:#f1e9dd;
|
|
72
|
+
--color-text:#2a1e16; --color-muted:#8a7866; --color-accent:#c8853a;
|
|
73
|
+
--color-border:#e7dccd; --color-on-brand:#fbf7f0;
|
|
74
|
+
--space-gutter:16px; --radius-card:12px;
|
|
75
|
+
--font-heading:"Instrument Serif",Georgia,serif;
|
|
76
|
+
--font-body:system-ui,-apple-system,"Segoe UI",sans-serif;
|
|
77
|
+
}`;function z7($){if(!$)return v5;let J=$.match(/:root\s*\{[^}]*\}/);return J?J[0]:v5}function K7($){return`<!DOCTYPE html>
|
|
78
|
+
<html lang="cs">
|
|
79
|
+
<head>
|
|
80
|
+
<meta charset="utf-8" />
|
|
81
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
82
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
83
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
84
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Instrument+Serif&display=swap" />
|
|
85
|
+
<style>
|
|
86
|
+
${$}
|
|
87
|
+
* { box-sizing: border-box; margin: 0; }
|
|
88
|
+
html, body { height: 100%; }
|
|
89
|
+
body {
|
|
90
|
+
background: var(--color-surface);
|
|
91
|
+
color: var(--color-text);
|
|
92
|
+
font-family: var(--font-body);
|
|
93
|
+
padding: 14px 16px;
|
|
94
|
+
display: flex; justify-content: center; align-items: flex-start;
|
|
95
|
+
-webkit-font-smoothing: antialiased;
|
|
96
|
+
}
|
|
97
|
+
.screen { width: 100%; max-width: 340px; }
|
|
98
|
+
.brand {
|
|
99
|
+
display: flex; align-items: center; gap: 8px;
|
|
100
|
+
font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
|
|
101
|
+
color: var(--color-muted); margin-bottom: 8px;
|
|
102
|
+
}
|
|
103
|
+
.brand .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--color-brand); }
|
|
104
|
+
h1 {
|
|
105
|
+
font-family: var(--font-heading);
|
|
106
|
+
font-weight: 400; font-size: 26px; line-height: 1.1;
|
|
107
|
+
margin-bottom: 2px;
|
|
108
|
+
}
|
|
109
|
+
.sub { color: var(--color-muted); font-size: 13px; margin-bottom: 12px; }
|
|
110
|
+
.card {
|
|
111
|
+
background: #fff;
|
|
112
|
+
border: 1px solid var(--color-border);
|
|
113
|
+
border-radius: var(--radius-card);
|
|
114
|
+
padding: var(--space-gutter);
|
|
115
|
+
box-shadow: 0 1px 2px rgba(42,30,22,.04);
|
|
116
|
+
}
|
|
117
|
+
.row { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0; }
|
|
118
|
+
.row + .row { border-top: 1px solid var(--color-border); }
|
|
119
|
+
.row .name { font-size: 14px; }
|
|
120
|
+
.row .qty { color: var(--color-muted); font-size: 12px; margin-left: 6px; }
|
|
121
|
+
.row .price { color: var(--color-accent); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
|
|
122
|
+
.total { margin-top: 4px; padding-top: 12px; border-top: 2px solid var(--color-border); }
|
|
123
|
+
.total .name { font-weight: 600; font-size: 15px; }
|
|
124
|
+
.total .price { font-size: 17px; }
|
|
125
|
+
.field { margin-top: 14px; }
|
|
126
|
+
.field label { display: block; font-size: 12px; color: var(--color-muted); margin-bottom: 6px; }
|
|
127
|
+
.field input {
|
|
128
|
+
width: 100%; padding: 10px 12px;
|
|
129
|
+
border: 1px solid var(--color-border); border-radius: var(--radius-card);
|
|
130
|
+
font-size: 14px; font-family: inherit; color: var(--color-text); background: #fff;
|
|
131
|
+
}
|
|
132
|
+
.field input::placeholder { color: var(--color-muted); opacity: .7; }
|
|
133
|
+
.cta {
|
|
134
|
+
width: 100%; margin-top: 14px; padding: 12px 16px;
|
|
135
|
+
background: var(--color-brand); color: var(--color-on-brand);
|
|
136
|
+
border: none; border-radius: var(--radius-card);
|
|
137
|
+
font-size: 15px; font-weight: 600; font-family: inherit; cursor: pointer;
|
|
138
|
+
}
|
|
139
|
+
.cta:hover { background: var(--color-brand-strong); }
|
|
140
|
+
.pickup {
|
|
141
|
+
display: flex; align-items: center; gap: 7px; justify-content: center;
|
|
142
|
+
margin-top: 12px; font-size: 12px; color: var(--color-muted);
|
|
143
|
+
}
|
|
144
|
+
.pickup .pill { width: 7px; height: 7px; border-radius: 50%; background: var(--color-accent); }
|
|
145
|
+
</style>
|
|
146
|
+
</head>
|
|
147
|
+
<body>
|
|
148
|
+
<div className="screen">
|
|
149
|
+
<div className="brand"><span className="dot"></span> Kávovar</div>
|
|
150
|
+
<h1>Tvoje objednávka</h1>
|
|
151
|
+
<div className="sub">2 položky · vyzvednutí na pobočce</div>
|
|
152
|
+
<div className="card">
|
|
153
|
+
<div className="row"><div><span className="name">Flat white</span><span className="qty">×1</span></div><span className="price">62 Kč</span></div>
|
|
154
|
+
<div className="row"><div><span className="name">Croissant</span><span className="qty">×2</span></div><span className="price">98 Kč</span></div>
|
|
155
|
+
<div className="row total"><span className="name">Celkem</span><span className="price">160 Kč</span></div>
|
|
156
|
+
<div className="field">
|
|
157
|
+
<label for="name">Jméno pro vyzvednutí</label>
|
|
158
|
+
<input id="name" placeholder="např. Matěj" />
|
|
159
|
+
</div>
|
|
160
|
+
<button className="cta">Potvrdit objednávku</button>
|
|
161
|
+
<div className="pickup"><span className="pill"></span> Připraveno k vyzvednutí ~ 8 min</div>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
</body>
|
|
165
|
+
</html>`}function f7($,J){let Q=`<style>${J}</style>`,X=$.indexOf("<head>");if(X!==-1)return $.slice(0,X+6)+Q+$.slice(X+6);return`${Q}${$}`}function v3({url:$,children:J}){return G0("div",{className:"flex h-full flex-col overflow-hidden rounded-md border border-border-medium bg-bg-base",children:[G0("div",{className:"flex items-center gap-1.5 border-b border-border-subtle bg-bg-elevated px-3 py-2",children:[G0("span",{className:"h-2.5 w-2.5 rounded-full bg-accent-red/60"},void 0,!1,void 0,this),G0("span",{className:"h-2.5 w-2.5 rounded-full bg-accent-amber/60"},void 0,!1,void 0,this),G0("span",{className:"h-2.5 w-2.5 rounded-full bg-accent-green/60"},void 0,!1,void 0,this),G0("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 O7({sessionId:$,live:J}){let[Q,X]=x3(v5),[W,G]=x3(null);L7(()=>{if(!J)return;let H=!1;return S0.artifact($,M7).then((B)=>{if(!H)X(z7(B))}),S0.artifact($,_7).then((B)=>{if(!H)G(B?.trim()?B:null)}).catch(()=>{}),()=>{H=!0}},[$,J]);let Y=W!==null,q=Y?f7(W,Q):K7(Q);return G0(P$,{children:[G0(v3,{url:Y?"pages/_preview.html":"pages/checkout.jsx",children:G0("iframe",{srcDoc:q,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),G0("p",{className:"mt-2 px-0.5 text-tiny text-text-tertiary",children:Y?G0(P$,{children:["Primary screen mockup (",G0("span",{className:"font-mono",children:"pages/_preview.html"},void 0,!1,void 0,this),"), themed live by"," ",G0("span",{className:"font-mono",children:"architecture/design.md"},void 0,!1,void 0,this)," tokens."]},void 0,!0,void 0,this):G0(P$,{children:["Built-in demo screen, themed live by ",G0("span",{className:"font-mono",children:"architecture/design.md"},void 0,!1,void 0,this)," tokens — drop a"," ",G0("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 S7({previewUrl:$}){if(!$)return G0("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 G0(P$,{children:[G0(v3,{url:$,children:G0("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),G0("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 h3({phase:$,sessionId:J,live:Q,previewUrl:X}){return G0("aside",{className:"flex h-full flex-col border-l border-border-subtle bg-bg-surface",children:[G0("div",{className:"flex items-center justify-between border-b border-border-subtle px-4 py-3",children:[G0("div",{className:"text-tiny uppercase tracking-wide text-text-tertiary",children:"live preview"},void 0,!1,void 0,this),G0("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),G0("div",{className:"flex min-h-0 flex-1 flex-col p-3",children:$==="build"?G0(S7,{previewUrl:X},void 0,!1,void 0,this):G0(O7,{sessionId:J,live:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as c3,useState as u3}from"react";import{jsxDEV as x0}from"react/jsx-dev-runtime";function k$($){let J=[],Q=/(`[^`]+`|\*\*[^*]+\*\*)/g,X=0,W,G=0;while(W=Q.exec($)){if(W.index>X)J.push($.slice(X,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)},G++,!1,void 0,this));else J.push(x0("strong",{className:"font-semibold text-text-primary",children:Y.slice(2,-2)},G++,!1,void 0,this));X=W.index+Y.length}if(X<$.length)J.push($.slice(X));return J}function m3({source:$}){let J=$.split(`
|
|
166
|
+
`),Q=[],X=0,W=0;while(X<J.length){let G=J[X];if(G.startsWith("```")){let q=[];X++;while(X<J.length&&!J[X].startsWith("```"))q.push(J[X++]);X++,Q.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:q.join(`
|
|
167
|
+
`)},void 0,!1,void 0,this)},W++,!1,void 0,this));continue}let Y=G.match(/^(#{1,4})\s+(.*)$/);if(Y){let q=Y[1].length,H=q===1?"mt-2 mb-3 font-heading text-section text-text-primary":q===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";Q.push(x0("div",{className:H,children:k$(Y[2])},W++,!1,void 0,this)),X++;continue}if(/^[-*]\s+/.test(G)){let q=[];while(X<J.length&&/^[-*]\s+/.test(J[X]))q.push(J[X].replace(/^[-*]\s+/,"")),X++;Q.push(x0("ul",{className:"my-2 list-disc space-y-1 pl-5 text-body text-text-secondary",children:q.map((H,B)=>x0("li",{children:k$(H)},B,!1,void 0,this))},W++,!1,void 0,this));continue}if(/^\d+\.\s+/.test(G)){let q=[];while(X<J.length&&/^\d+\.\s+/.test(J[X]))q.push(J[X].replace(/^\d+\.\s+/,"")),X++;Q.push(x0("ol",{className:"my-2 list-decimal space-y-1 pl-5 text-body text-text-secondary",children:q.map((H,B)=>x0("li",{children:k$(H)},B,!1,void 0,this))},W++,!1,void 0,this));continue}if(G.trim()===""){X++;continue}Q.push(x0("p",{className:"my-2 text-body leading-relaxed text-text-secondary",children:k$(G)},W++,!1,void 0,this)),X++}return x0("div",{className:"select-text",children:Q},void 0,!1,void 0,this)}import{jsxDEV as V,Fragment as l3}from"react/jsx-dev-runtime";function R7({state:$,focused:J,isCurrentGate:Q}){let X=B3(J),W=T2(J,$.completed,$.current),G=W==="current",Y=G&&$.reads.length?$.reads.join(", "):X.reads.join(", "),q=G&&$.produces.length?$.produces.join(", "):X.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 ",X.number,"/",K$," — ",X.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:q},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:X.gate?V(l3,{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),Q&&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 C7({sessionId:$,live:J,upcoming:Q}){let[X,W]=u3(null);c3(()=>{if(!J)return;let Y=!1;return S0.skeletons($).then((q)=>{if(!Y)W(q)}),()=>{Y=!0}},[$,J]);let G=X??[];return V("div",{className:"p-6",children:[Q&&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&&G.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:G.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((q)=>V("span",{className:"rounded bg-bg-elevated px-1.5 py-0.5 text-tiny text-text-secondary",children:["seed:",q]},q,!0,void 0,this)),Y.roles.map((q)=>V("span",{className:"rounded bg-bg-elevated px-1.5 py-0.5 text-tiny text-text-secondary",children:["role:",q]},q,!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 P7({live:$}){let[J,Q]=u3([]);c3(()=>{if(!$)return;let W=S0.buildStream((G)=>Q((Y)=>[...Y.slice(-200),G]));return()=>W?.close()},[$]);let X={queued:"bg-text-tertiary",running:"bg-accent-blue",passed:"bg-accent-green",failed:"bg-accent-red",blocked:"bg-accent-amber",info:"bg-text-tertiary"};return 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,G)=>V("li",{className:"flex items-center gap-2",children:[V("span",{className:`inline-flex h-2 w-2 shrink-0 rounded-full ${X[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)]},G,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function k7({canvas:$}){return V(l3,{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(M$,{revision:$.revision,filename:J.filename},void 0,!1,void 0,this)]},J.filename,!0,void 0,this))},void 0,!1,void 0,this)}function p3({state:$,focused:J,canvas:Q,artifact:X,isCurrentGate:W,sessionId:G,live:Y}){let H=T2(J,$.completed,$.current)==="upcoming";return V("section",{className:"flex h-full min-w-0 flex-col bg-bg-base",children:[V(R7,{state:$,focused:J,isCurrentGate:W},void 0,!1,void 0,this),V("div",{id:"plan-scroll-container",className:"flex-1 overflow-y-auto",children:Q?V("div",{className:"mx-auto max-w-3xl px-6 py-5",children:V(k7,{canvas:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this):J==="skeletons"?V(C7,{sessionId:G,live:Y,upcoming:H},void 0,!1,void 0,this):J==="build"?V(P7,{live:Y},void 0,!1,void 0,this):V("div",{className:"mx-auto max-w-3xl px-6 py-5",children:[H&&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(m3,{source:X},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function d3($){if(!$)return[];if($.canvasScope?.kind==="view"){let Q=$.canvasScope.filename;return $.canvasFiles.filter((X)=>X.filename===Q)}if($.canvasScope?.kind==="directory")return $.canvasFiles;let J=$.canvasFiles.filter((Q)=>!Q.diffStats||Q.diffStats.added!==0||Q.diffStats.removed!==0);return J.length>0?J:$.canvasFiles}var i3="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},r3={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 n3={intake:`# Brief
|
|
168
|
+
|
|
169
|
+
A local-first storefront for a small roastery. Sells whole-bean coffee, supports a cart and checkout, and a lightweight admin to manage the catalog.
|
|
170
|
+
|
|
171
|
+
## Users
|
|
172
|
+
- Shopper — browses, adds to cart, checks out.
|
|
173
|
+
- Owner — manages products and reviews orders.
|
|
174
|
+
|
|
175
|
+
## Success
|
|
176
|
+
- A shopper can complete a purchase end-to-end.
|
|
177
|
+
- The owner can add a product without touching code.
|
|
178
|
+
|
|
179
|
+
## Non-goals
|
|
180
|
+
- No multi-tenant. No payment provider integration in v1 (mock checkout).`,vision:`# Glossary
|
|
181
|
+
|
|
182
|
+
- **Product** — a single SKU with a price and inventory count.
|
|
183
|
+
- **Cart** — the shopper's pending selection, persisted locally.
|
|
184
|
+
- **Order** — a submitted cart, immutable once placed.
|
|
185
|
+
|
|
186
|
+
# Principles
|
|
187
|
+
|
|
188
|
+
- MUST keep the catalog readable without an account.
|
|
189
|
+
- MUST persist the cart across reloads.
|
|
190
|
+
- MUST NOT block checkout on network for the mock flow.
|
|
191
|
+
- PREFERENCE: optimistic UI on add-to-cart.`,flows:`# Flow: checkout
|
|
192
|
+
|
|
193
|
+
1. Shopper opens \`/cart\`.
|
|
194
|
+
2. Reviews line items, adjusts quantities.
|
|
195
|
+
3. Submits → \`/order/confirmation\`.
|
|
196
|
+
|
|
197
|
+
# Flow: browse
|
|
198
|
+
|
|
199
|
+
1. Shopper lands on \`/\`.
|
|
200
|
+
2. Filters by roast level.
|
|
201
|
+
3. Opens a product → adds to cart.`,tech:`# Tech
|
|
202
|
+
|
|
203
|
+
Stack: **cf-lightweight** (lopata + oblaka + vite/react).
|
|
204
|
+
|
|
205
|
+
- Routes via the cf-lightweight stack conventions.
|
|
206
|
+
- Data layer: D1 + seed infra from skeleton metadata.
|
|
207
|
+
- Reasoning: matches the team's deployment target; opice harness wires in cleanly.`,design:"# Design tokens\n\nSemantic layer → Tailwind/CSS vars.\n\n- `--surface` → warm off-black\n- `--accent` → roast amber\n- `--text` → bone\n\nMockups: `pages/checkout.jsx`, `pages/product.jsx`. See the live-preview pane → it renders the kernel-compiled JSX with these tokens applied.",skeletons:"# Opice skeletons\n\nOne `*.test.ts` per flow, each a metadata-first `browserTest` with pending `step{intent,hint}` stubs and `invariant.todo` acceptances. Reviewed as a grid in the workspace.",issues:`# Issues (induced)
|
|
208
|
+
|
|
209
|
+
Deterministic compile step — issues induced from skeleton metadata.
|
|
210
|
+
|
|
211
|
+
- ISSUE-001 Foundation: routes + seed infra.
|
|
212
|
+
- ISSUE-002 Feature: cart + checkout vertical slice.`,build:`# Build
|
|
213
|
+
|
|
214
|
+
Per-issue assisted pipeline. The live-preview pane (right) will host the real running app (localhost:5173) once an issue is in flight.`};var A7=X$.extend({generalNote:U.string(),annotations:U.array(p$.pick({id:!0,snippet:!0,note:!0,createdAt:!0}).passthrough()),responses:U.array(U.tuple([U.string(),J$.innerType().pick({id:!0,type:!0,label:!0}).extend({type:U.string()}).passthrough()])),feedbackEntries:U.array(U.tuple([U.string(),Q$.pick({id:!0,markdown:!0}).passthrough()])).optional()});function o3($){let J=A7.safeParse($);return J.success?s1(J.data):null}class v0 extends Error{}function j7($=fetch){async function J(Q,X,W,G){let Y;try{Y=await $(y3(Q,X),{method:W?"POST":"GET",headers:{accept:"application/json",...W?{"content-type":"application/json"}:{}},...W?{body:JSON.stringify(W)}:{},redirect:"error",cache:"no-store",signal:G?AbortSignal.any([G,AbortSignal.timeout(1e4)]):AbortSignal.timeout(1e4)})}catch{throw new v0("Local builder unavailable. Check the daemon and refresh status.")}let q;try{q=await Y.json()}catch{throw new v0("Local builder returned an invalid response. Refresh status before continuing.")}if(!Y.ok){let H=C3.safeParse(q);if(H.success)throw new v0(H.data.error.message);throw new v0("Local builder rejected the request. Refresh status before continuing.")}try{let H=E3(q);if(H.sessionId!==Q)throw Error("Session mismatch");return H}catch{throw new v0("Local builder returned an invalid status. Refresh status before continuing.")}}return{status:(Q,X)=>J(Q,"platform",void 0,X),register:(Q,X)=>J(Q,"register",{projectRoot:X}),act:(Q,X,W)=>{let G={};try{if(X.kind==="connect")G={controlOrigin:Y2(X.controlOrigin)};if(X.kind==="preview")G={url:X.url===null?null:D2(X.url)}}catch{throw new v0("Enter a valid URL without credentials. Control origins require HTTPS except on localhost.")}return J(Q,X.kind,G,W)}}}var b2=j7();import{useEffect as s3,useRef as V7,useState as I2}from"react";function t3($,J){let[Q,X]=I2($),[W,G]=I2(null),[Y,q]=I2(null),[H,B]=I2(!1),[N,L]=I2(0),M=V7(null);s3(()=>{return X($),G(null),q(null),B(!1),L(0),()=>{M.current?.abort(),M.current=null}},[$]),s3(()=>{if(Q!==$||!J||H||Y)return;let R=new AbortController,z,f=0,O=async()=>{try{if(++f>1200)throw new v0("Automatic status refresh paused. Refresh status to continue.");let _=await b2.status($,R.signal);if(R.signal.aborted)return;G(_),q(null),z=setTimeout(O,3000)}catch(_){if(!R.signal.aborted)q(_ instanceof v0?_.message:"Unable to read local deployment status.")}};return O(),()=>{R.abort(),clearTimeout(z)}},[$,Q,J,H,N,Y]);let F=Q===$,w=F&&J&&W!==null&&Y===null&&!H;return{data:F?W:null,error:F?Y:null,busy:F&&H,enabled:w,refresh:()=>{G(null),q(null),L((R)=>R+1)},act:async(R)=>{if(!w||M.current)return;let z=new AbortController;M.current=z,B(!0);try{let f=await b2.act($,R,z.signal);if(!z.signal.aborted)G(f)}catch(f){if(!z.signal.aborted)q(f instanceof v0?f.message:"Local operation failed. Refresh status.")}finally{if(M.current===z){if(M.current=null,!z.signal.aborted)B(!1)}}}}}import{jsxDEV as A0}from"react/jsx-dev-runtime";function Z7($){return $==="design"||$==="build"}var e3={current:"intake",index:0,completed:[],reads:[],produces:[],gate:!1,satisfied:!1},T7="_Nový projekt — zatím žádný krok. Otevři první gate z agenta._";function $8(){let $=C$()??i3,[J,Q]=j1("connecting"),X=t3($,J==="live"),[W,G]=j1(e3),[Y,q]=j1(null),[H,B]=j1(!1),[N,L]=j1(e3.current),[M,F]=j1(!1),w=c5(!1),R=c5(null),z=c5(void 0);a3(()=>{let A=!1;return(async()=>{try{if(await S0.health(),A)return;let I=new URLSearchParams(location.search).get("root");if(I?.endsWith("/.fabrika"))await b2.register($,I.slice(0,-9));let d=await S0.meta($);if(A)return;if(d)q(d),z.current=d.projectRoot?`${d.projectRoot}/.fabrika`:void 0;let Z=await S0.phase(z.current);if(A)return;if(Z){if(G(Z),!w.current)L(Z.current)}Q("live")}catch{if(!A){if(C$()){Q("offline");return}if(q(r3),G(h5),!w.current)L(h5.current);Q("fixture")}}})(),()=>{A=!0}},[$]);let f=Y!==null&&(J==="live"||J==="offline");a3(()=>{if(!f)return;let A=!1,I=null,d=()=>{S0.meta($).then((E)=>q(E)).catch(()=>{}),S0.phase(z.current).then((E)=>{if(G(E),!w.current)L(E.current)}).catch(()=>{})},Z=()=>{let E=S0.openSocket($,(k)=>{if(k.type==="plan-updated"||k.type==="revision-updated")F(!1),d();else if(k.type==="watcher-status")B(k.watching);else if(k.type==="phase-updated")F(!1),d();else if(k.type==="submit-ack")F(!1),d()});R.current=E,E.onopen=()=>Q("live"),E.onclose=()=>{if(A)return;Q("offline"),I=setTimeout(Z,2000)}};return Z(),()=>{if(A=!0,I)clearTimeout(I);R.current?.close(),R.current=null}},[f,$]);let[O,_]=j1({type:"overview"}),j=(A)=>{w.current=!0,L(A)},T=(A)=>{let I=R.current;if(I&&S0.submitGate(I,A))F(!0)},h=J==="live",g=m5(()=>{if(!Y)return null;for(let A=Y.revisions.length-1;A>=0;A--)if(Y.revisions[A].label===N)return Y.revisions[A];return null},[Y,N]),m=W.gateName??Y?.gate??null,c=h&&N===W.current&&!!m,p=m5(()=>{return d3(g)},[g]),Q0=h&&!!g&&p.length>0,$0=g?.revision??Y?.currentRevision??0,W0=Y?.currentRevision??0,z0=c&&!!g?.hasFeedback&&!g?.feedbackConsumed,J0=!c||c&&(M||z0),a=J==="fixture"?n3[N]??"_No artifact for this phase yet._":T7,H0=m5(()=>(Y?.revisions??[]).map((A)=>({revision:A.revision,label:A.label??void 0,canvasFiles:A.canvasFiles.map((I)=>({filename:I.filename})),createdAt:A.createdAt??new Date().toISOString(),hasFeedback:!!A.hasFeedback,feedbackConsumed:!!A.feedbackConsumed})),[Y]),e=Z7(N),B0=A0("div",{className:`grid min-h-0 flex-1 grid-rows-[minmax(0,1fr)] ${e?"grid-cols-[14rem_minmax(0,1fr)_22rem_auto]":"grid-cols-[14rem_minmax(0,1fr)_auto]"}`,children:[A0(N3,{state:W,focused:N,onFocus:j},void 0,!1,void 0,this),A0(p3,{state:W,focused:N,canvas:Q0?{revision:$0,files:p}:null,artifact:a,isCurrentGate:c,sessionId:$,live:h},void 0,!1,void 0,this),e&&A0(h3,{phase:N,sessionId:$,live:h,previewUrl:X.data?.previewUrl??null},void 0,!1,void 0,this),A0(G3,{gateName:m,hasGate:Q0,isCurrentGate:c,onSubmit:T},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(U3,{sessionId:$,status:J,watching:H},void 0,!1,void 0,this),A0(q3,{platform:X,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),Q0?A0(k5.Provider,{value:$,children:A0($2.Provider,{value:{currentRevision:W0,selectedRevision:$0,revisions:H0,setSelectedRevision:()=>{},isReadOnly:J0,compareRevision:null,setCompareRevision:()=>{},agentWatching:H},children:A0(e1.Provider,{value:{activeView:O,setActiveView:_,openFiles:[],closeFile:()=>{},canvasFiles:p.map((A)=>A.filename)},children:A0(W$,{sessionId:$,revision:$0,isReadOnly:J0,draftPhase:"current",loadState:(A,I)=>S0.getResponses(A,I,o3),saveState:(A,I,d)=>{S0.saveResponses(A,I,d)},children:B0},$0,!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 b7}from"react/jsx-dev-runtime";var J8=document.getElementById("root");if(J8===null)throw Error("Builder dashboard root element is missing");D7(J8).render(b7($8,{},void 0,!1,void 0,this));
|