@fabrika/builder 0.9.0-cloudflare.2 → 0.9.0-cloudflare.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/src/inject-skills.ts +2 -2
- package/cli/src/skeletons.ts +2 -2
- package/daemon/src/handlers.ts +1 -1
- package/daemon/src/platform-remote.ts +1 -1
- package/decisions/technologies/zerops-fabrika-auth.md +1 -1
- package/decisions/technologies/zerops-platform.md +1 -1
- package/package.json +8 -8
- package/types/daemon/src/platform-remote.d.ts +30 -0
- package/types/shared/index.d.ts +39 -39
- package/ui/dist/assets/client.1cjttr57.js +214 -0
- package/ui/dist/index.html +1 -1
- package/ui/dist/assets/client.v5z73zge.js +0 -214
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
var e3=Object.defineProperty;var $6=($)=>$;function J6($,J){this[$]=$6.bind(null,J)}var Q6=($,J)=>{for(var Q in J)e3($,Q,{get:J[Q],enumerable:!0,configurable:!0,set:J6.bind(J,Q)})};import{createRoot as T7}from"react-dom/client";import{useEffect as o3,useMemo as m5,useRef as c5,useState as j1}from"react";import{useState as M9}from"react";import{AnnotationCtx as vX,AnnotationHostContext as mX,SessionContext as cX,useAnnotationHost as uX,useAnnotations as pX}from"@fabrika/annotations/runtime";function I2($,J){let Q=[],X=p5($);for(let W of X){let q=document.createRange();if(q.selectNodeContents(W),W===$.startContainer)q.setStart(W,$.startOffset);if(W===$.endContainer)q.setEnd(W,$.endOffset);let Y=q.toString();if(!Y||!Y.trim())continue;let H=document.createElement("mark");H.setAttribute("data-annotation-id",J);try{q.surroundContents(H)}catch{let G=q.extractContents();H.appendChild(G),q.insertNode(H)}Q.push(H)}return Q}function H2($){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(!H2(W))continue;if($.intersectsNode(W))J.push(W)}return J}function X6($,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+=X6(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 k$($,J){if(J!=null&&J!==$)V1(J,!1);if($!=null)V1($,!0)}function A$($,J){let Q=document.querySelectorAll(`[data-annotation-id="${$}"]`);for(let X of Q)X.setAttribute("data-annotation-id",J)}function j$($,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:q}=W6($),Y=[],H=0;while(!0){let F=W.indexOf(X,H);if(F===-1)break;Y.push(F),H=F+1}let[G]=Y;if(G===void 0)continue;let B=G;if(Y.length>1&&Q.context){let F=-1;for(let C of Y){let K=0;if(Q.context.before){let O=W.slice(Math.max(0,C-80),C);if(O.includes(Q.context.before))K+=2;else if(Q.context.before.length>10&&O.includes(Q.context.before.slice(-10)))K+=1}if(Q.context.after){let O=W.slice(C+X.length,C+X.length+80);if(O.includes(Q.context.after))K+=2;else if(Q.context.after.length>10&&O.includes(Q.context.after.slice(0,10)))K+=1}if(K>F)F=K,B=C}}let N=B,L=B+X.length,M=u5(q,N),w=u5(q,L);if(!M||!w)continue;try{let F=document.createRange();F.setStart(M.node,M.offset),F.setEnd(w.node,w.offset),I2(F,Q.id)}catch{}}}function W6($){let J=[],Q="",X=document.createTreeWalker($,NodeFilter.SHOW_TEXT),W;while(W=X.nextNode()){if(!H2(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,q=X.node.textContent?.length??0;if(W<=q)return{node:X.node,offset:W}}return null}function V$($){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=q6($.startContainer,J);return{before:Q,after:X,hierarchy:W}}function d5($,J,Q){let X=Y6(J==="before"?$.startContainer:$.endContainer);if(!X)return"";let W="";if(J==="before"){let q=document.createTreeWalker(X,NodeFilter.SHOW_TEXT),Y;while(Y=q.nextNode()){if(Y===$.startContainer){W+=(Y.textContent||"").slice(0,$.startOffset);break}if(!H2(Y))continue;W+=Y.textContent||""}if(W.length>Q){W=W.slice(-Q);let H=W.indexOf(" ");if(H>0)W=W.slice(H+1)}}else{let q=document.createTreeWalker(X,NodeFilter.SHOW_TEXT),Y=!1,H;while(H=q.nextNode()){if(H===$.endContainer){W+=(H.textContent||"").slice($.endOffset),Y=!0;continue}if(Y){if(!H2(H))continue;W+=H.textContent||""}}if(W.length>Q){W=W.slice(0,Q);let G=W.lastIndexOf(" ");if(G>0)W=W.slice(0,G)}}return W.trim()}function Y6($){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 q6($,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 q=G6(X);if(q)Q.unshift(q);X=X.parentElement}return Q}function G6($){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 y2($){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 E2($,J,Q){return{selector:$,snippet:(X)=>{let W=X.getAttribute(Q);return W?`${J} ${W}`:null}}}var Z$=[E2("[data-md='item']","[Item]","data-md-label"),E2("[data-md='section']","[Section]","data-md-title"),E2("[data-md='checklist-item']","[Checklist]","data-md-label"),E2("[data-md='image']","[Image]","data-md-src"),{selector:"[data-md='callout']",snippet:($)=>{return`[Callout:${$.getAttribute("data-md-type")||"info"}] ${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}}],H6=["[data-md='choice-option']","[data-md='multichoice-option']","[data-md='userinput']","[data-md='rangeinput']"],e0=Z$.map(($)=>$.selector).join(", "),T1=[...Z$.map(($)=>$.selector),...H6].join(", ");function v0($){for(let J of Z$)if($.matches(J.selector))return J.snippet($);return null}var D$={kind:"block",parse:($)=>$.startsWith("[")?{snippet:$}:null,format:($)=>$.snippet,find:($,J)=>{for(let Q of J.querySelectorAll(e0)){if(!(Q instanceof HTMLElement))continue;if(v0(Q)===$.snippet)return Q}return null}};var g$="data-annotation-image",U6=/^\[Region:(rect|ellipse)\] ([\s\S]+) @(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*)$/;function B6($){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 I$($,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 v2($,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 h2($){return`${($/100).toFixed(1).replace(/\.0$/,"")}%`}function m2($){let J=`${h2($.x)}-${h2($.x+$.w)}`,Q=`${h2($.y)}-${h2($.y+$.h)}`;return`[Region] ${$.src} — ${$.shape} x ${J}, y ${Q} of the image`}function b$($,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=U6.exec($);if(!J)return null;let Q=B6(J[1]),X=J[2],W=x2(J[3]),q=x2(J[4]),Y=x2(J[5]),H=x2(J[6]);if(Q===null||X===void 0)return null;if(W===null||q===null||Y===null||H===null)return null;if(Y<1||H<1)return null;return{src:X,shape:Q,x:W,y:q,w:Y,h:H}},format:($)=>`[Region:${$.shape}] ${$.src} @${$.x},${$.y},${$.w},${$.h}`,find:($,J)=>b$($.src,J),restore:($,J,Q)=>{if(J.querySelector(`[data-annotation-id="${Q.id}"]`))return;let X=b$($.src,J);if(!X)return;X.appendChild(u2($,$.shape,Q.id))},describe:m2};var E$={kind:"text",parse:($)=>$?{text:$}:null,format:($)=>$.text,find:()=>null,restore:($,J,Q)=>{j$(J,[Q])}};var p2=[U2(B2),U2(D$),U2(E$)];function x$($,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 kQ,SessionContext as AQ,useAnnotationHost as jQ}from"@fabrika/annotations/runtime";import{useEffect as ZQ,useRef as DQ,useState as bQ}from"react";var U={};Q6(U,{void:()=>n6,util:()=>o,unknown:()=>i6,union:()=>a6,undefined:()=>p6,tuple:()=>J8,transformer:()=>N8,symbol:()=>u6,string:()=>X4,strictObject:()=>t6,setErrorMap:()=>F6,set:()=>W8,record:()=>Q8,quotelessJson:()=>N6,promise:()=>B8,preprocess:()=>L8,pipeline:()=>M8,ostring:()=>f8,optional:()=>w8,onumber:()=>K8,oboolean:()=>z8,objectUtil:()=>v$,object:()=>s6,number:()=>W4,nullable:()=>F8,null:()=>l6,never:()=>r6,nativeEnum:()=>U8,nan:()=>v6,map:()=>X8,makeIssue:()=>w2,literal:()=>G8,lazy:()=>q8,late:()=>x6,isValid:()=>$1,isDirty:()=>d2,isAsync:()=>D1,isAborted:()=>l2,intersection:()=>$8,instanceof:()=>h6,getParsedType:()=>m0,getErrorMap:()=>Z1,function:()=>Y8,enum:()=>H8,effect:()=>N8,discriminatedUnion:()=>e6,defaultErrorMap:()=>i0,datetimeRegex:()=>$4,date:()=>c6,custom:()=>Q4,coerce:()=>_8,boolean:()=>Y4,bigint:()=>m6,array:()=>o6,any:()=>d6,addIssueToContext:()=>P,ZodVoid:()=>L2,ZodUnknown:()=>J1,ZodUnion:()=>x1,ZodUndefined:()=>y1,ZodType:()=>r,ZodTuple:()=>u0,ZodTransformer:()=>I0,ZodSymbol:()=>F2,ZodString:()=>Z0,ZodSet:()=>F1,ZodSchema:()=>r,ZodRecord:()=>M2,ZodReadonly:()=>l1,ZodPromise:()=>L1,ZodPipeline:()=>z2,ZodParsedType:()=>R,ZodOptional:()=>b0,ZodObject:()=>N0,ZodNumber:()=>Q1,ZodNullable:()=>n0,ZodNull:()=>E1,ZodNever:()=>c0,ZodNativeEnum:()=>c1,ZodNaN:()=>K2,ZodMap:()=>f2,ZodLiteral:()=>m1,ZodLazy:()=>v1,ZodIssueCode:()=>_,ZodIntersection:()=>h1,ZodFunction:()=>g1,ZodFirstPartyTypeKind:()=>x,ZodError:()=>P0,ZodEnum:()=>W1,ZodEffects:()=>I0,ZodDiscriminatedUnion:()=>i2,ZodDefault:()=>u1,ZodDate:()=>N1,ZodCatch:()=>p1,ZodBranded:()=>r2,ZodBoolean:()=>I1,ZodBigInt:()=>X1,ZodArray:()=>D0,ZodAny:()=>w1,Schema:()=>r,ParseStatus:()=>_0,OK:()=>O0,NEVER:()=>O8,INVALID:()=>y,EMPTY_PATH:()=>L6,DIRTY:()=>B1,BRAND:()=>E6});var o;(function($){$.assertEqual=(W)=>{};function J(W){}$.assertIs=J;function Q(W){throw Error()}$.assertNever=Q,$.arrayToEnum=(W)=>{let q={};for(let Y of W)q[Y]=Y;return q},$.getValidEnumValues=(W)=>{let q=$.objectKeys(W).filter((H)=>typeof W[W[H]]!=="number"),Y={};for(let H of q)Y[H]=W[H];return $.objectValues(Y)},$.objectValues=(W)=>{return $.objectKeys(W).map(function(q){return W[q]})},$.objectKeys=typeof Object.keys==="function"?(W)=>Object.keys(W):(W)=>{let q=[];for(let Y in W)if(Object.prototype.hasOwnProperty.call(W,Y))q.push(Y);return q},$.find=(W,q)=>{for(let Y of W)if(q(Y))return Y;return},$.isInteger=typeof Number.isInteger==="function"?(W)=>Number.isInteger(W):(W)=>typeof W==="number"&&Number.isFinite(W)&&Math.floor(W)===W;function X(W,q=" | "){return W.map((Y)=>typeof Y==="string"?`'${Y}'`:Y).join(q)}$.joinValues=X,$.jsonStringifyReplacer=(W,q)=>{if(typeof q==="bigint")return q.toString();return q}})(o||(o={}));var v$;(function($){$.mergeShapes=(J,Q)=>{return{...J,...Q}}})(v$||(v$={}));var R=o.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),m0=($)=>{switch(typeof $){case"undefined":return R.undefined;case"string":return R.string;case"number":return Number.isNaN($)?R.nan:R.number;case"boolean":return R.boolean;case"function":return R.function;case"bigint":return R.bigint;case"symbol":return R.symbol;case"object":if(Array.isArray($))return R.array;if($===null)return R.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return R.promise;if(typeof Map<"u"&&$ instanceof Map)return R.map;if(typeof Set<"u"&&$ instanceof Set)return R.set;if(typeof Date<"u"&&$ instanceof Date)return R.date;return R.object;default:return R.unknown}};var _=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"]),N6=($)=>{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 q of W.issues)if(q.code==="invalid_union")q.unionErrors.map(X);else if(q.code==="invalid_return_type")X(q.returnTypeError);else if(q.code==="invalid_arguments")X(q.argumentsError);else if(q.path.length===0)Q._errors.push(J(q));else{let Y=Q,H=0;while(H<q.path.length){let G=q.path[H];if(H!==q.path.length-1)Y[G]=Y[G]||{_errors:[]};else Y[G]=Y[G]||{_errors:[]},Y[G]._errors.push(J(q));Y=Y[G],H++}}};return 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 w6=($,J)=>{let Q;switch($.code){case _.invalid_type:if($.received===R.undefined)Q="Required";else Q=`Expected ${$.expected}, received ${$.received}`;break;case _.invalid_literal:Q=`Invalid literal value, expected ${JSON.stringify($.expected,o.jsonStringifyReplacer)}`;break;case _.unrecognized_keys:Q=`Unrecognized key(s) in object: ${o.joinValues($.keys,", ")}`;break;case _.invalid_union:Q="Invalid input";break;case _.invalid_union_discriminator:Q=`Invalid discriminator value. Expected ${o.joinValues($.options)}`;break;case _.invalid_enum_value:Q=`Invalid enum value. Expected ${o.joinValues($.options)}, received '${$.received}'`;break;case _.invalid_arguments:Q="Invalid function arguments";break;case _.invalid_return_type:Q="Invalid function return type";break;case _.invalid_date:Q="Invalid date";break;case _.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 _.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 _.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 _.custom:Q="Invalid input";break;case _.invalid_intersection_types:Q="Intersection results could not be merged";break;case _.not_multiple_of:Q=`Number must be a multiple of ${$.multipleOf}`;break;case _.not_finite:Q="Number must be finite";break;default:Q=J.defaultError,o.assertNever($)}return{message:Q}},i0=w6;var o5=i0;function F6($){o5=$}function Z1(){return o5}var w2=($)=>{let{data:J,path:Q,errorMaps:X,issueData:W}=$,q=[...Q,...W.path||[]],Y={...W,path:q};if(W.message!==void 0)return{...W,path:q,message:W.message};let H="",G=X.filter((B)=>!!B).slice().reverse();for(let B of G)H=B(Y,{data:J,defaultError:H}).message;return{...W,path:q,message:H}},L6=[];function P($,J){let Q=Z1(),X=w2({issueData:J,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,Q,Q===i0?void 0:i0].filter((W)=>!!W)});$.common.issues.push(X)}class _0{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 y;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,q=await X.value;Q.push({key:W,value:q})}return _0.mergeObjectSync($,Q)}static mergeObjectSync($,J){let Q={};for(let X of J){let{key:W,value:q}=X;if(W.status==="aborted")return y;if(q.status==="aborted")return y;if(W.status==="dirty")$.dirty();if(q.status==="dirty")$.dirty();if(W.value!=="__proto__"&&(typeof q.value<"u"||X.alwaysSet))Q[W.value]=q.value}return{status:$.value,value:Q}}}var y=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 g0{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 p($){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,H)=>{let{message:G}=$;if(Y.code==="invalid_enum_value")return{message:G??H.defaultError};if(typeof H.data>"u")return{message:G??X??H.defaultError};if(Y.code!=="invalid_type")return{message:H.defaultError};return{message:G??Q??H.defaultError}},description:W}}class r{get description(){return this._def.description}_getType($){return m0($.data)}_getOrReturnCtx($,J){return J||{common:$.parent.common,data:$.data,parsedType:m0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new _0,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 q=$(X),Y=()=>W.addIssue({code:_.custom,...Q(X)});if(typeof Promise<"u"&&q instanceof Promise)return q.then((H)=>{if(!H)return Y(),!1;else return!0});if(!q)return Y(),!1;else return!0})}refinement($,J){return this._refinement((Q,X)=>{if(!$(Q))return X.addIssue(typeof J==="function"?J(Q,X):J),!1;else return!0})}_refinement($){return new I0({schema:this,typeName:x.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(J)=>this["~validate"](J)}}optional(){return 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 h1.create(this,$,this._def)}transform($){return new I0({...p(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:$}})}default($){let J=typeof $==="function"?$:()=>$;return new u1({...p(this._def),innerType:this,defaultValue:J,typeName:x.ZodDefault})}brand(){return new r2({typeName:x.ZodBranded,type:this,...p(this._def)})}catch($){let J=typeof $==="function"?$:()=>$;return new p1({...p(this._def),innerType:this,catchValue:J,typeName:x.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return z2.create(this,$)}readonly(){return l1.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var M6=/^c[^\s-]{8,}$/i,f6=/^[0-9a-z]+$/,K6=/^[0-9A-HJKMNP-TV-Z]{26}$/i,z6=/^[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,_6=/^[a-z0-9_-]{21}$/i,O6=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,S6=/^[-+]?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)?)??$/,R6=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,C6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",m$,P6=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,k6=/^(?:(?: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])$/,A6=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,j6=/^(([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])$/,V6=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,T6=/^([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])))",Z6=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 D6($){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 b6($,J){if((J==="v4"||!J)&&P6.test($))return!0;if((J==="v6"||!J)&&A6.test($))return!0;return!1}function g6($,J){if(!O6.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 I6($,J){if((J==="v4"||!J)&&k6.test($))return!0;if((J==="v6"||!J)&&j6.test($))return!0;return!1}class Z0 extends r{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==R.string){let W=this._getOrReturnCtx($);return P(W,{code:_.invalid_type,expected:R.string,received:W.parsedType}),y}let Q=new _0,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:_.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:_.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="length"){let q=$.data.length>W.value,Y=$.data.length<W.value;if(q||Y){if(X=this._getOrReturnCtx($,X),q)P(X,{code:_.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});else if(Y)P(X,{code:_.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});Q.dirty()}}else if(W.kind==="email"){if(!R6.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"email",code:_.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="emoji"){if(!m$)m$=new RegExp(C6,"u");if(!m$.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"emoji",code:_.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="uuid"){if(!z6.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"uuid",code:_.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="nanoid"){if(!_6.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"nanoid",code:_.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cuid"){if(!M6.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"cuid",code:_.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cuid2"){if(!f6.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"cuid2",code:_.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="ulid"){if(!K6.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"ulid",code:_.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:_.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:_.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:_.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:_.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:_.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:_.invalid_string,validation:"datetime",message:W.message}),Q.dirty()}else if(W.kind==="date"){if(!Z6.test($.data))X=this._getOrReturnCtx($,X),P(X,{code:_.invalid_string,validation:"date",message:W.message}),Q.dirty()}else if(W.kind==="time"){if(!D6(W).test($.data))X=this._getOrReturnCtx($,X),P(X,{code:_.invalid_string,validation:"time",message:W.message}),Q.dirty()}else if(W.kind==="duration"){if(!S6.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"duration",code:_.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="ip"){if(!b6($.data,W.version))X=this._getOrReturnCtx($,X),P(X,{validation:"ip",code:_.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="jwt"){if(!g6($.data,W.alg))X=this._getOrReturnCtx($,X),P(X,{validation:"jwt",code:_.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cidr"){if(!I6($.data,W.version))X=this._getOrReturnCtx($,X),P(X,{validation:"cidr",code:_.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="base64"){if(!V6.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"base64",code:_.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="base64url"){if(!T6.test($.data))X=this._getOrReturnCtx($,X),P(X,{validation:"base64url",code:_.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:_.invalid_string,...D.errToObj(Q)})}_addCheck($){return new Z0({...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 Z0({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Z0({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Z0({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxLength(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}}Z0.create=($)=>{return new Z0({checks:[],typeName:x.ZodString,coerce:$?.coerce??!1,...p($)})};function y6($,J){let Q=($.toString().split(".")[1]||"").length,X=(J.toString().split(".")[1]||"").length,W=Q>X?Q:X,q=Number.parseInt($.toFixed(W).replace(".","")),Y=Number.parseInt(J.toFixed(W).replace(".",""));return q%Y/10**W}class Q1 extends r{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==R.number){let W=this._getOrReturnCtx($);return P(W,{code:_.invalid_type,expected:R.number,received:W.parsedType}),y}let Q=void 0,X=new _0;for(let W of this._def.checks)if(W.kind==="int"){if(!o.isInteger($.data))Q=this._getOrReturnCtx($,Q),P(Q,{code:_.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:_.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:_.too_big,maximum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),X.dirty()}else if(W.kind==="multipleOf"){if(y6($.data,W.value)!==0)Q=this._getOrReturnCtx($,Q),P(Q,{code:_.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:_.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:x.ZodNumber,coerce:$?.coerce||!1,...p($)})};class X1 extends r{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==R.bigint)return this._getInvalidInput($);let Q=void 0,X=new _0;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:_.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:_.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:_.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:_.invalid_type,expected:R.bigint,received:J.parsedType}),y}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:x.ZodBigInt,coerce:$?.coerce??!1,...p($)})};class I1 extends r{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==R.boolean){let Q=this._getOrReturnCtx($);return P(Q,{code:_.invalid_type,expected:R.boolean,received:Q.parsedType}),y}return O0($.data)}}I1.create=($)=>{return new I1({typeName:x.ZodBoolean,coerce:$?.coerce||!1,...p($)})};class N1 extends r{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==R.date){let W=this._getOrReturnCtx($);return P(W,{code:_.invalid_type,expected:R.date,received:W.parsedType}),y}if(Number.isNaN($.data.getTime())){let W=this._getOrReturnCtx($);return P(W,{code:_.invalid_date}),y}let Q=new _0,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:_.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:_.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:x.ZodDate,...p($)})};class F2 extends r{_parse($){if(this._getType($)!==R.symbol){let Q=this._getOrReturnCtx($);return P(Q,{code:_.invalid_type,expected:R.symbol,received:Q.parsedType}),y}return O0($.data)}}F2.create=($)=>{return new F2({typeName:x.ZodSymbol,...p($)})};class y1 extends r{_parse($){if(this._getType($)!==R.undefined){let Q=this._getOrReturnCtx($);return P(Q,{code:_.invalid_type,expected:R.undefined,received:Q.parsedType}),y}return O0($.data)}}y1.create=($)=>{return new y1({typeName:x.ZodUndefined,...p($)})};class E1 extends r{_parse($){if(this._getType($)!==R.null){let Q=this._getOrReturnCtx($);return P(Q,{code:_.invalid_type,expected:R.null,received:Q.parsedType}),y}return O0($.data)}}E1.create=($)=>{return new E1({typeName:x.ZodNull,...p($)})};class w1 extends r{constructor(){super(...arguments);this._any=!0}_parse($){return O0($.data)}}w1.create=($)=>{return new w1({typeName:x.ZodAny,...p($)})};class J1 extends r{constructor(){super(...arguments);this._unknown=!0}_parse($){return O0($.data)}}J1.create=($)=>{return new J1({typeName:x.ZodUnknown,...p($)})};class c0 extends r{_parse($){let J=this._getOrReturnCtx($);return P(J,{code:_.invalid_type,expected:R.never,received:J.parsedType}),y}}c0.create=($)=>{return new c0({typeName:x.ZodNever,...p($)})};class L2 extends r{_parse($){if(this._getType($)!==R.undefined){let Q=this._getOrReturnCtx($);return P(Q,{code:_.invalid_type,expected:R.void,received:Q.parsedType}),y}return O0($.data)}}L2.create=($)=>{return new L2({typeName:x.ZodVoid,...p($)})};class D0 extends r{_parse($){let{ctx:J,status:Q}=this._processInputParams($),X=this._def;if(J.parsedType!==R.array)return P(J,{code:_.invalid_type,expected:R.array,received:J.parsedType}),y;if(X.exactLength!==null){let q=J.data.length>X.exactLength.value,Y=J.data.length<X.exactLength.value;if(q||Y)P(J,{code:q?_.too_big:_.too_small,minimum:Y?X.exactLength.value:void 0,maximum:q?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:_.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:_.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((q,Y)=>{return X.type._parseAsync(new g0(J,q,J.path,Y))})).then((q)=>{return _0.mergeArray(Q,q)});let W=[...J.data].map((q,Y)=>{return X.type._parseSync(new g0(J,q,J.path,Y))});return _0.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:x.ZodArray,...p(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 r{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),J=o.objectKeys($);return this._cached={shape:$,keys:J},this._cached}_parse($){if(this._getType($)!==R.object){let G=this._getOrReturnCtx($);return P(G,{code:_.invalid_type,expected:R.object,received:G.parsedType}),y}let{status:Q,ctx:X}=this._processInputParams($),{shape:W,keys:q}=this._getCached(),Y=[];if(!(this._def.catchall instanceof c0&&this._def.unknownKeys==="strip")){for(let G in X.data)if(!q.includes(G))Y.push(G)}let H=[];for(let G of q){let B=W[G],N=X.data[G];H.push({key:{status:"valid",value:G},value:B._parse(new g0(X,N,X.path,G)),alwaysSet:G in X.data})}if(this._def.catchall instanceof c0){let G=this._def.unknownKeys;if(G==="passthrough")for(let B of Y)H.push({key:{status:"valid",value:B},value:{status:"valid",value:X.data[B]}});else if(G==="strict"){if(Y.length>0)P(X,{code:_.unrecognized_keys,keys:Y}),Q.dirty()}else if(G==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let G=this._def.catchall;for(let B of Y){let N=X.data[B];H.push({key:{status:"valid",value:B},value:G._parse(new g0(X,N,X.path,B)),alwaysSet:B in X.data})}}if(X.common.async)return Promise.resolve().then(async()=>{let G=[];for(let B of H){let N=await B.key,L=await B.value;G.push({key:N,value:L,alwaysSet:B.alwaysSet})}return G}).then((G)=>{return _0.mergeObjectSync(Q,G)});else return _0.mergeObjectSync(Q,H)}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:x.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:x.ZodObject,...p(J)})};N0.strictCreate=($,J)=>{return new N0({shape:()=>$,unknownKeys:"strict",catchall:c0.create(),typeName:x.ZodObject,...p(J)})};N0.lazycreate=($,J)=>{return new N0({shape:$,unknownKeys:"strip",catchall:c0.create(),typeName:x.ZodObject,...p(J)})};class x1 extends r{_parse($){let{ctx:J}=this._processInputParams($),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 q=W.map((Y)=>new P0(Y.ctx.common.issues));return P(J,{code:_.invalid_union,unionErrors:q}),y}if(J.common.async)return Promise.all(Q.map(async(W)=>{let q={...J,common:{...J.common,issues:[]},parent:null};return{result:await W._parseAsync({data:J.data,path:J.path,parent:q}),ctx:q}})).then(X);else{let W=void 0,q=[];for(let H of Q){let G={...J,common:{...J.common,issues:[]},parent:null},B=H._parseSync({data:J.data,path:J.path,parent:G});if(B.status==="valid")return B;else if(B.status==="dirty"&&!W)W={result:B,ctx:G};if(G.common.issues.length)q.push(G.common.issues)}if(W)return J.common.issues.push(...W.ctx.common.issues),W.result;let Y=q.map((H)=>new P0(H));return P(J,{code:_.invalid_union,unionErrors:Y}),y}}get options(){return this._def.options}}x1.create=($,J)=>{return new x1({options:$,typeName:x.ZodUnion,...p(J)})};var r0=($)=>{if($ instanceof v1)return r0($.schema);else if($ instanceof I0)return r0($.innerType());else if($ instanceof m1)return[$.value];else if($ instanceof W1)return $.options;else if($ instanceof c1)return o.objectValues($.enum);else if($ instanceof u1)return r0($._def.innerType);else if($ instanceof y1)return[void 0];else if($ instanceof E1)return[null];else if($ instanceof 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 r{_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==R.object)return P(J,{code:_.invalid_type,expected:R.object,received:J.parsedType}),y;let Q=this.discriminator,X=J.data[Q],W=this.optionsMap.get(X);if(!W)return P(J,{code:_.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[Q]}),y;if(J.common.async)return W._parseAsync({data:J.data,path:J.path,parent:J});else return W._parseSync({data:J.data,path:J.path,parent:J})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,J,Q){let X=new Map;for(let W of J){let q=r0(W.shape[$]);if(!q.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let Y of q){if(X.has(Y))throw Error(`Discriminator property ${String($)} has duplicate value ${String(Y)}`);X.set(Y,W)}}return new i2({typeName:x.ZodDiscriminatedUnion,discriminator:$,options:J,optionsMap:X,...p(Q)})}}function c$($,J){let Q=m0($),X=m0(J);if($===J)return{valid:!0,data:$};else if(Q===R.object&&X===R.object){let W=o.objectKeys(J),q=o.objectKeys($).filter((H)=>W.indexOf(H)!==-1),Y={...$,...J};for(let H of q){let G=c$($[H],J[H]);if(!G.valid)return{valid:!1};Y[H]=G.data}return{valid:!0,data:Y}}else if(Q===R.array&&X===R.array){if($.length!==J.length)return{valid:!1};let W=[];for(let q=0;q<$.length;q++){let Y=$[q],H=J[q],G=c$(Y,H);if(!G.valid)return{valid:!1};W.push(G.data)}return{valid:!0,data:W}}else if(Q===R.date&&X===R.date&&+$===+J)return{valid:!0,data:$};else return{valid:!1}}class h1 extends r{_parse($){let{status:J,ctx:Q}=this._processInputParams($),X=(W,q)=>{if(l2(W)||l2(q))return y;let Y=c$(W.value,q.value);if(!Y.valid)return P(Q,{code:_.invalid_intersection_types}),y;if(d2(W)||d2(q))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,q])=>X(W,q));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}))}}h1.create=($,J,Q)=>{return new h1({left:$,right:J,typeName:x.ZodIntersection,...p(Q)})};class u0 extends r{_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==R.array)return P(Q,{code:_.invalid_type,expected:R.array,received:Q.parsedType}),y;if(Q.data.length<this._def.items.length)return P(Q,{code:_.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;if(!this._def.rest&&Q.data.length>this._def.items.length)P(Q,{code:_.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),J.dirty();let W=[...Q.data].map((q,Y)=>{let H=this._def.items[Y]||this._def.rest;if(!H)return null;return H._parse(new g0(Q,q,Q.path,Y))}).filter((q)=>!!q);if(Q.common.async)return Promise.all(W).then((q)=>{return _0.mergeArray(J,q)});else return _0.mergeArray(J,W)}get items(){return this._def.items}rest($){return new u0({...this._def,rest:$})}}u0.create=($,J)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new u0({items:$,typeName:x.ZodTuple,rest:null,...p(J)})};class M2 extends r{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==R.object)return P(Q,{code:_.invalid_type,expected:R.object,received:Q.parsedType}),y;let X=[],W=this._def.keyType,q=this._def.valueType;for(let Y in Q.data)X.push({key:W._parse(new g0(Q,Y,Q.path,Y)),value:q._parse(new g0(Q,Q.data[Y],Q.path,Y)),alwaysSet:Y in Q.data});if(Q.common.async)return _0.mergeObjectAsync(J,X);else return _0.mergeObjectSync(J,X)}get element(){return this._def.valueType}static create($,J,Q){if(J instanceof r)return new M2({keyType:$,valueType:J,typeName:x.ZodRecord,...p(Q)});return new M2({keyType:Z0.create(),valueType:$,typeName:x.ZodRecord,...p(J)})}}class f2 extends r{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==R.map)return P(Q,{code:_.invalid_type,expected:R.map,received:Q.parsedType}),y;let X=this._def.keyType,W=this._def.valueType,q=[...Q.data.entries()].map(([Y,H],G)=>{return{key:X._parse(new g0(Q,Y,Q.path,[G,"key"])),value:W._parse(new g0(Q,H,Q.path,[G,"value"]))}});if(Q.common.async){let Y=new Map;return Promise.resolve().then(async()=>{for(let H of q){let G=await H.key,B=await H.value;if(G.status==="aborted"||B.status==="aborted")return y;if(G.status==="dirty"||B.status==="dirty")J.dirty();Y.set(G.value,B.value)}return{status:J.value,value:Y}})}else{let Y=new Map;for(let H of q){let{key:G,value:B}=H;if(G.status==="aborted"||B.status==="aborted")return y;if(G.status==="dirty"||B.status==="dirty")J.dirty();Y.set(G.value,B.value)}return{status:J.value,value:Y}}}}f2.create=($,J,Q)=>{return new f2({valueType:J,keyType:$,typeName:x.ZodMap,...p(Q)})};class F1 extends r{_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==R.set)return P(Q,{code:_.invalid_type,expected:R.set,received:Q.parsedType}),y;let X=this._def;if(X.minSize!==null){if(Q.data.size<X.minSize.value)P(Q,{code:_.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:_.too_big,maximum:X.maxSize.value,type:"set",inclusive:!0,exact:!1,message:X.maxSize.message}),J.dirty()}let W=this._def.valueType;function q(H){let G=new Set;for(let B of H){if(B.status==="aborted")return y;if(B.status==="dirty")J.dirty();G.add(B.value)}return{status:J.value,value:G}}let Y=[...Q.data.values()].map((H,G)=>W._parse(new g0(Q,H,Q.path,G)));if(Q.common.async)return Promise.all(Y).then((H)=>q(H));else return q(Y)}min($,J){return new F1({...this._def,minSize:{value:$,message:D.toString(J)}})}max($,J){return new F1({...this._def,maxSize:{value:$,message:D.toString(J)}})}size($,J){return this.min($,J).max($,J)}nonempty($){return this.min(1,$)}}F1.create=($,J)=>{return new F1({valueType:$,minSize:null,maxSize:null,typeName:x.ZodSet,...p(J)})};class g1 extends r{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==R.function)return P(J,{code:_.invalid_type,expected:R.function,received:J.parsedType}),y;function Q(Y,H){return w2({data:Y,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,Z1(),i0].filter((G)=>!!G),issueData:{code:_.invalid_arguments,argumentsError:H}})}function X(Y,H){return w2({data:Y,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,Z1(),i0].filter((G)=>!!G),issueData:{code:_.invalid_return_type,returnTypeError:H}})}let W={errorMap:J.common.contextualErrorMap},q=J.data;if(this._def.returns instanceof L1){let Y=this;return O0(async function(...H){let G=new P0([]),B=await Y._def.args.parseAsync(H,W).catch((M)=>{throw G.addIssue(Q(H,M)),G}),N=await Reflect.apply(q,this,B);return await Y._def.returns._def.type.parseAsync(N,W).catch((M)=>{throw G.addIssue(X(N,M)),G})})}else{let Y=this;return O0(function(...H){let G=Y._def.args.safeParse(H,W);if(!G.success)throw new P0([Q(H,G.error)]);let B=Reflect.apply(q,this,G.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 g1({...this._def,args:u0.create($).rest(J1.create())})}returns($){return new g1({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,J,Q){return new g1({args:$?$:u0.create([]).rest(J1.create()),returns:J||J1.create(),typeName:x.ZodFunction,...p(Q)})}}class v1 extends r{get schema(){return this._def.getter()}_parse($){let{ctx:J}=this._processInputParams($);return this._def.getter()._parse({data:J.data,path:J.path,parent:J})}}v1.create=($,J)=>{return new v1({getter:$,typeName:x.ZodLazy,...p(J)})};class m1 extends r{_parse($){if($.data!==this._def.value){let J=this._getOrReturnCtx($);return P(J,{received:J.data,code:_.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:$.data}}get value(){return this._def.value}}m1.create=($,J)=>{return new m1({value:$,typeName:x.ZodLiteral,...p(J)})};function J4($,J){return new W1({values:$,typeName:x.ZodEnum,...p(J)})}class W1 extends r{_parse($){if(typeof $.data!=="string"){let J=this._getOrReturnCtx($),Q=this._def.values;return P(J,{expected:o.joinValues(Q),received:J.parsedType,code:_.invalid_type}),y}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:_.invalid_enum_value,options:Q}),y}return O0($.data)}get options(){return this._def.values}get enum(){let $={};for(let J of this._def.values)$[J]=J;return $}get Values(){let $={};for(let J of this._def.values)$[J]=J;return $}get Enum(){let $={};for(let J of this._def.values)$[J]=J;return $}extract($,J=this._def){return W1.create($,{...this._def,...J})}exclude($,J=this._def){return W1.create(this.options.filter((Q)=>!$.includes(Q)),{...this._def,...J})}}W1.create=J4;class c1 extends r{_parse($){let J=o.getValidEnumValues(this._def.values),Q=this._getOrReturnCtx($);if(Q.parsedType!==R.string&&Q.parsedType!==R.number){let X=o.objectValues(J);return P(Q,{expected:o.joinValues(X),received:Q.parsedType,code:_.invalid_type}),y}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:_.invalid_enum_value,options:X}),y}return O0($.data)}get enum(){return this._def.values}}c1.create=($,J)=>{return new c1({values:$,typeName:x.ZodNativeEnum,...p(J)})};class L1 extends r{unwrap(){return this._def.type}_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==R.promise&&J.common.async===!1)return P(J,{code:_.invalid_type,expected:R.promise,received:J.parsedType}),y;let Q=J.parsedType===R.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:x.ZodPromise,...p(J)})};class I0 extends r{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:J,ctx:Q}=this._processInputParams($),X=this._def.effect||null,W={addIssue:(q)=>{if(P(Q,q),q.fatal)J.abort();else J.dirty()},get path(){return Q.path}};if(W.addIssue=W.addIssue.bind(W),X.type==="preprocess"){let q=X.transform(Q.data,W);if(Q.common.async)return Promise.resolve(q).then(async(Y)=>{if(J.value==="aborted")return y;let H=await this._def.schema._parseAsync({data:Y,path:Q.path,parent:Q});if(H.status==="aborted")return y;if(H.status==="dirty")return B1(H.value);if(J.value==="dirty")return B1(H.value);return H});else{if(J.value==="aborted")return y;let Y=this._def.schema._parseSync({data:q,path:Q.path,parent:Q});if(Y.status==="aborted")return y;if(Y.status==="dirty")return B1(Y.value);if(J.value==="dirty")return B1(Y.value);return Y}}if(X.type==="refinement"){let q=(Y)=>{let H=X.refinement(Y,W);if(Q.common.async)return Promise.resolve(H);if(H instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return Y};if(Q.common.async===!1){let Y=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(Y.status==="aborted")return y;if(Y.status==="dirty")J.dirty();return q(Y.value),{status:J.value,value:Y.value}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((Y)=>{if(Y.status==="aborted")return y;if(Y.status==="dirty")J.dirty();return q(Y.value).then(()=>{return{status:J.value,value:Y.value}})})}if(X.type==="transform")if(Q.common.async===!1){let q=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(!$1(q))return y;let Y=X.transform(q.value,W);if(Y instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:J.value,value:Y}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((q)=>{if(!$1(q))return y;return Promise.resolve(X.transform(q.value,W)).then((Y)=>({status:J.value,value:Y}))});o.assertNever(X)}}I0.create=($,J,Q)=>{return new I0({schema:$,typeName:x.ZodEffects,effect:J,...p(Q)})};I0.createWithPreprocess=($,J,Q)=>{return new I0({schema:J,effect:{type:"preprocess",transform:$},typeName:x.ZodEffects,...p(Q)})};class b0 extends r{_parse($){if(this._getType($)===R.undefined)return O0(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}b0.create=($,J)=>{return new b0({innerType:$,typeName:x.ZodOptional,...p(J)})};class n0 extends r{_parse($){if(this._getType($)===R.null)return O0(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}n0.create=($,J)=>{return new n0({innerType:$,typeName:x.ZodNullable,...p(J)})};class u1 extends r{_parse($){let{ctx:J}=this._processInputParams($),Q=J.data;if(J.parsedType===R.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:x.ZodDefault,defaultValue:typeof J.default==="function"?J.default:()=>J.default,...p(J)})};class p1 extends r{_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:x.ZodCatch,catchValue:typeof J.catch==="function"?J.catch:()=>J.catch,...p(J)})};class K2 extends r{_parse($){if(this._getType($)!==R.nan){let Q=this._getOrReturnCtx($);return P(Q,{code:_.invalid_type,expected:R.nan,received:Q.parsedType}),y}return{status:"valid",value:$.data}}}K2.create=($)=>{return new K2({typeName:x.ZodNaN,...p($)})};var E6=Symbol("zod_brand");class r2 extends r{_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 z2 extends r{_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 y;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 y;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 z2({in:$,out:J,typeName:x.ZodPipeline})}}class l1 extends r{_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:x.ZodReadonly,...p(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 w1.create().superRefine((X,W)=>{let q=$(X);if(q instanceof Promise)return q.then((Y)=>{if(!Y){let H=t5(J,X),G=H.fatal??Q??!0;W.addIssue({code:"custom",...H,fatal:G})}});if(!q){let Y=t5(J,X),H=Y.fatal??Q??!0;W.addIssue({code:"custom",...Y,fatal:H})}return});return w1.create()}var x6={object:N0.lazycreate},x;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(x||(x={}));var h6=($,J={message:`Input not instance of ${$.name}`})=>Q4((Q)=>Q instanceof $,J),X4=Z0.create,W4=Q1.create,v6=K2.create,m6=X1.create,Y4=I1.create,c6=N1.create,u6=F2.create,p6=y1.create,l6=E1.create,d6=w1.create,i6=J1.create,r6=c0.create,n6=L2.create,o6=D0.create,s6=N0.create,t6=N0.strictCreate,a6=x1.create,e6=i2.create,$8=h1.create,J8=u0.create,Q8=M2.create,X8=f2.create,W8=F1.create,Y8=g1.create,q8=v1.create,G8=m1.create,H8=W1.create,U8=c1.create,B8=L1.create,N8=I0.create,w8=b0.create,F8=n0.create,L8=I0.createWithPreprocess,M8=z2.create,f8=()=>X4().optional(),K8=()=>W4().optional(),z8=()=>Y4().optional(),_8={string:($)=>Z0.create({...$,coerce:!0}),number:($)=>Q1.create({...$,coerce:!0}),boolean:($)=>I1.create({...$,coerce:!0}),bigint:($)=>X1.create({...$,coerce:!0}),date:($)=>N1.create({...$,coerce:!0})};var O8=y;var S8=U.object({before:U.string(),after:U.string(),hierarchy:U.array(U.string()),lineStart:U.number().optional(),lineEnd:U.number().optional()}).passthrough(),R8=U.object({id:U.string(),name:U.string()}).passthrough(),C8=U.object({url:U.string(),mime:U.string().optional()}).passthrough(),u$=U.object({id:U.string(),snippet:U.string(),note:U.string(),createdAt:U.string(),filePath:U.string().optional(),canvasFile:U.string().optional(),context:S8.optional(),images:U.array(U.string()).optional(),attachments:U.array(C8).optional(),source:U.enum(["local","remote"]).optional(),author:R8.optional()}).passthrough(),P8=U.array(u$.optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).catch([]),p$=U.object({annotations:P8,generalNote:U.string().catch("")}).passthrough(),q4=U.object({path:U.string()}),G4=U.object({url:U.string()});import{useCallback as f1,useMemo as k8,useState as A8}from"react";var d1="__agent-response__";function M1($){return $.filePath&&$.filePath!=="__agent-response__"?$.filePath:void 0}function _2($){return $.uploadUrl!==null}function o0(){return`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}function Y1($,J){$.style.height="auto",$.style.height=(J?Math.max(J,$.scrollHeight):$.scrollHeight)+"px"}function H4($){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:q,onClear:Y}){let[H,G]=A8(null),B=k8(()=>{if(!W?.length)return $;let O=new Set($.map((f)=>f.id)),S=W.filter((f)=>!O.has(f.id));return[...$,...S.map((f)=>({...f,source:"remote"}))]},[$,W]),N=f1((O,S,f,A,Z,h,I)=>{J((v)=>[...v,{id:O,snippet:S,note:f,createdAt:new Date().toISOString(),filePath:A,context:Z,...h?.length?{images:h}:{},...I?{canvasFile:I}:{}}])},[J]),L=f1((O,S,f)=>{N(o0(),O,S,f)},[N]),M=f1((O,S)=>{J((f)=>f.map((A)=>A.id===O?{...A,note:S}:A))},[J]),w=f1((O)=>{if(!$.some((S)=>S.id===O))return;H4(O),J((S)=>S.filter((f)=>f.id!==O)),G((S)=>S===O?null:S)},[$,J]),F=f1((O,S)=>{J((f)=>f.map((A)=>A.id===O?{...A,images:[...A.images||[],S]}:A))},[J]),C=f1((O,S)=>{J((f)=>f.map((A)=>A.id===O?{...A,images:(A.images||[]).filter((Z)=>Z!==S)}:A))},[J]),K=f1(()=>{H4(),J([]),X(""),G(null),Y?.()},[J,X,Y]);return{annotations:B,generalNote:Q,setGeneralNote:X,activeAnnotationId:H,setActiveAnnotationId:G,addAnnotation:L,addAnnotationWithId:N,updateAnnotation:M,removeAnnotation:w,addAnnotationImage:F,removeAnnotationImage:C,clearAll:K,isReadOnly:q}}import{useAnnotations as q1}from"@fabrika/annotations/runtime";import{jsxDEV as xQ}from"react/jsx-dev-runtime";import{jsxDEV as K1,Fragment as j8}from"react/jsx-dev-runtime";function l$({hasContent:$,onSubmit:J,onSubmitEmpty:Q,notice:X,secondaryAction:W,placeholder:q="General notes...",submitLabel:Y="Submit",emptyLabel:H="Submit without feedback"}){let{generalNote:G,setGeneralNote:B}=q1();return K1(j8,{children:[K1("div",{className:"border-t border-border-subtle px-4 py-3 flex-shrink-0",children:K1("textarea",{value:G,onChange:(N)=>B(N.currentTarget.value),className:"w-full bg-transparent text-[13px] font-body text-text-primary resize-none leading-relaxed p-0 border-none ring-0 shadow-none outline-none focus:outline-none focus:ring-0 focus:border-none placeholder:text-text-disabled min-h-[40px]",placeholder:q,onInput:(N)=>Y1(N.currentTarget,40),ref:(N)=>{if(N)Y1(N,40)}},void 0,!1,void 0,this)},void 0,!1,void 0,this),X,K1("div",{className:"px-4 py-3 border-t border-border-subtle flex-shrink-0",children:$?K1("div",{className:"flex gap-2",children:[W,K1("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):K1("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:H},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useAnnotationHost as V8}from"@fabrika/annotations/runtime";import{useCallback as s0,useEffect as T8,useRef as d$,useState as i$}from"react";import{jsxDEV as f0}from"react/jsx-dev-runtime";function r$($){if($.startsWith("/s/")||$.startsWith("http://")||$.startsWith("https://"))return $;return`/api/uploads/${$.split("/").pop()}`}async function Z8($,J){let Q=$.uploadUrl;if(!Q)return null;let X=new FormData;X.append("image",J);try{let q=await(await fetch(Q(),{method:"POST",body:X})).json();if($.isShared)return G4.parse(q).url||null;return q4.parse(q).path||null}catch{return null}}function i1({note:$,onNoteChange:J,images:Q,onAddImage:X,onRemoveImage:W,sessionId:q,placeholder:Y="Add your note...",autoFocus:H=!1,autoResize:G=!1,readOnly:B=!1,onKeyDown:N,onTextareaClick:L,textareaRef:M,textareaClassName:w,textareaStyle:F,minHeight:C,attachButton:K="always",openFilePickerRef:O}){let S=V8(),f=!B&&_2(S),[A,Z]=i$(!1),[h,I]=i$(!1),[v,u]=i$(!1),m=d$(0),e=d$(null),X0=d$(null),q0=s0(()=>X0.current?.click(),[]);if(O)O.current=q0;let z0=s0((z)=>{if(e.current=z,M)M.current=z;if(z&&G)Y1(z,C)},[M,G,C]);T8(()=>{if(H&&e.current){let z=e.current;if(z.focus(),z.value)z.setSelectionRange(z.value.length,z.value.length)}},[H]);let c=s0(async(z)=>{if(!z.type.startsWith("image/"))return;I(!0);try{let j=await Z8(S,z);if(j)X(j)}finally{I(!1)}},[S,X]),$0=s0((z)=>{for(let j of z.clipboardData?.items??[])if(j.type.startsWith("image/")){z.preventDefault();let n=j.getAsFile();if(n)c(n);return}},[c]),J0=s0((z)=>{if(z.preventDefault(),m.current++,m.current===1)Z(!0)},[]),G0=s0((z)=>{z.preventDefault()},[]),a=s0((z)=>{if(z.preventDefault(),m.current--,m.current===0)Z(!1)},[]),Q0=s0((z)=>{z.preventDefault(),m.current=0,Z(!1);for(let j of z.dataTransfer?.files??[])if(j.type.startsWith("image/"))c(j)},[c]),B0=s0((z)=>{if(J(z.currentTarget.value),G)z.currentTarget.style.height="auto",z.currentTarget.style.height=(C?Math.max(C,z.currentTarget.scrollHeight):z.currentTarget.scrollHeight)+"px"},[J,G,C]),k="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",g={width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",outline:"none",...G?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},l=f&&(K==="always"||K==="on-focus"&&v);return f0("div",{style:{position:"relative"},onDragEnter:f?J0:void 0,onDragOver:f?G0:void 0,onDragLeave:f?a:void 0,onDrop:f?Q0:void 0,children:[f0("textarea",{ref:z0,value:$,onChange:B?void 0:B0,onPaste:f?$0:void 0,onKeyDown:N,onClick:L,onFocus:()=>u(!0),onBlur:()=>{setTimeout(()=>u(!1),150)},readOnly:B,placeholder:Y,className:w??k,style:F??g,rows:G?1:void 0},void 0,!1,void 0,this),f&&f0("input",{ref:X0,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:(z)=>{let j=z.currentTarget.files;if(j)for(let n of j)c(n);z.currentTarget.value=""}},void 0,!1,void 0,this),(Q.length>0||l)&&f0("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[Q.map((z)=>f0("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[f0("img",{src:r$(z),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!B&&f0("button",{onClick:(j)=>{j.stopPropagation(),W(z)},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)]},z,!0,void 0,this)),l&&f0(o2,{onClick:q0},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h&&f0("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),A&&f0("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-highlight-bg)",opacity:0.9,border:"2px dashed var(--color-highlight-border)",borderRadius:"6px",zIndex:10,pointerEvents:"none",fontSize:"12px",fontFamily:"'Inter', sans-serif",color:"var(--color-text-secondary)"},children:"Drop image"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function o2({onClick:$,size:J=16}){return f0("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:f0("svg",{width:J,height:J,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[f0("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),f0("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),f0("polyline",{points:"21 15 16 10 5 21"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function n$({images:$}){if(!$.length)return null;return f0("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px"},children:$.map((J)=>f0("div",{style:{width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:f0("img",{src:r$(J),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this)},J,!1,void 0,this))},void 0,!1,void 0,this)}import{SessionContext as D8}from"@fabrika/annotations/runtime";import{useContext as b8,useEffect as g8,useRef as I8}from"react";import{jsxDEV as w0,Fragment as U4}from"react/jsx-dev-runtime";function y8($){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:q}){let{updateAnnotation:Y,removeAnnotation:H,addAnnotationImage:G,removeAnnotationImage:B,activeAnnotationId:N,setActiveAnnotationId:L}=q1(),M=b8(D8),w=I8(new Map);g8(()=>{if(J||!N)return;let f=w.current.get(N);if(f)f.scrollIntoView({behavior:"smooth",block:"nearest"})},[N,J]);let F=(f)=>{L(f),V1(f,!0)},C=(f)=>{L(null),V1(f,!1)},K=(f)=>{if(f.id===N){L(null);return}L(f.id),Q?.(f)},O=!!W&&!!q,S=(f)=>{let A=O&&f.source==="remote";return w0("div",{ref:(Z)=>{if(Z)w.current.set(f.id,Z);else w.current.delete(f.id)},className:`group/ann relative px-3 py-2.5 transition-colors duration-150 ${J?"cursor-pointer ":""}${N===f.id?"bg-highlight-selected":A?"bg-accent-purple-muted/30 hover:bg-accent-purple-muted/50":"odd:bg-bg-elevated-half hover:bg-bg-input"}`,onMouseEnter:()=>F(f.id),onMouseLeave:()=>C(f.id),onClick:()=>K(f),children:[A&&f.author&&w0("div",{className:"flex items-center gap-1.5 mb-1.5",children:[w0("input",{type:"checkbox",checked:W.has(f.id),onChange:(Z)=>{Z.stopPropagation(),q(f.id)},onClick:(Z)=>Z.stopPropagation(),className:"accent-accent-purple flex-shrink-0",title:"Include in submission"},void 0,!1,void 0,this),w0("span",{className:"inline-flex items-center justify-center w-4 h-4 rounded-full bg-accent-purple text-white text-[9px] font-medium uppercase",children:f.author.name.charAt(0)},void 0,!1,void 0,this),w0("span",{className:"text-[11px] font-medium text-accent-purple font-body",children:f.author.name},void 0,!1,void 0,this),w0("span",{className:"text-[10px] text-text-tertiary font-body uppercase tracking-widest",children:"Remote"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w0("div",{className:"text-[11px] text-text-tertiary italic line-clamp-2 mb-1.5 leading-snug font-body border-l-2 border-border-medium pl-2",children:y8(f.snippet)},void 0,!1,void 0,this),J?w0(U4,{children:[f.note.trim()&&w0("div",{className:"text-[13px] font-body text-text-primary leading-relaxed",children:f.note},void 0,!1,void 0,this),w0(n$,{images:f.images||[]},void 0,!1,void 0,this)]},void 0,!0,void 0,this):A?w0("div",{className:"text-[13px] font-body text-text-primary leading-relaxed whitespace-pre-wrap",children:f.note},void 0,!1,void 0,this):w0("div",{onClick:(Z)=>Z.stopPropagation(),children:w0(i1,{note:f.note,onNoteChange:(Z)=>Y(f.id,Z),images:f.images||[],onAddImage:(Z)=>G(f.id,Z),onRemoveImage:(Z)=>B(f.id,Z),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),w0("div",{className:"absolute top-1.5 right-1.5 opacity-0 group-hover/ann:opacity-100 transition-opacity duration-100 flex items-center gap-0.5",children:[X&&w0("button",{onClick:(Z)=>{Z.stopPropagation(),X(f)},className:"w-5 h-5 flex items-center justify-center rounded text-text-tertiary hover:text-text-secondary hover:bg-bg-input transition-colors",title:"Scroll to annotation",children:w0("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[w0("circle",{cx:"12",cy:"12",r:"3"},void 0,!1,void 0,this),w0("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),!J&&!A&&w0("button",{onClick:(Z)=>{Z.stopPropagation(),H(f.id)},className:"w-5 h-5 flex items-center justify-center rounded text-text-tertiary hover:text-accent-red hover:bg-accent-red-muted transition-colors",title:"Delete annotation",children:w0("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[w0("polyline",{points:"3 6 5 6 21 6"},void 0,!1,void 0,this),w0("path",{d:"M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},f.id,!0,void 0,this)};return w0(U4,{children:$.map(S)},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 H=X.lineStart,G=X.lineEnd??H,B=Q.split(`
|
|
2
|
+
`);if(Q.length<30&&H===G&&(X.before||X.after)){let L=y2($);J.push(`> L${H}: ${L}`)}else if(B.length<=6)for(let L=0;L<B.length;L++)J.push(`> ${H+L} | ${B[L]}`);else{for(let L=0;L<3;L++)J.push(`> ${H+L} | ${B[L]}`);J.push(`> ... (${B.length} lines)`);for(let L=B.length-3;L<B.length;L++)J.push(`> ${H+L} | ${B[L]}`)}}else{let H=y2($);if(Q.split(`
|
|
3
|
+
`).length<=3)J.push(`> ${H.split(`
|
|
4
|
+
`).join(`
|
|
5
|
+
> `)}`);else{let G=Q.split(`
|
|
6
|
+
`);J.push(`> ${G[0]}`),J.push(`> ... (${G.length} lines)`),J.push(`> ${G[G.length-1]}`)}}if($.note.trim())J.push(""),J.push($.note.trim());let q=[...$.images??[]],Y=new Set(q);for(let H of $.attachments??[]){if(Y.has(H.url))continue;Y.add(H.url),q.push(H.url)}if(q.length){J.push("");for(let H of q)J.push(``)}return J.push(""),J.join(`
|
|
7
|
+
`)}import{SessionContext as E8,useAnnotationHost as x8}from"@fabrika/annotations/runtime";import{useCallback as s2,useContext as h8,useEffect as v8,useMemo as w4,useRef as t2,useState as r1}from"react";import{createPortal as m8}from"react-dom";function B4($){let J=/^(\d+(?:\.\d+)?)px$/.exec($.trim());return J?Number(J[1]):void 0}function N4($,J,Q=280){let W=J||document.body,q=$.getBoundingClientRect(),Y=W.getBoundingClientRect(),H=W===document.body?0:W.scrollTop,G=q.bottom-Y.top+H+8,B=Math.max(0,Math.min(q.left-Y.left,Y.width-Q-12));return W.style.position="relative",{style:{position:"absolute",top:`${G}px`,left:`${B}px`},parent:W}}import{jsxDEV as K0,Fragment as c8}from"react/jsx-dev-runtime";function L4({anchorEl:$,scrollContainer:J,onClose:Q,ignoreSelector:X,zIndex:W="50",padding:q="12px",width:Y="280px",children:H}){let G=t2(null),B=t2(Q);B.current=Q;let{style:N,parent:L}=N4($,J,B4(Y));return v8(()=>{let M=setTimeout(()=>{let w=(F)=>{if(G.current&&!G.current.contains(F.target)){if(X&&F.target.closest?.(X))return;B.current(),document.removeEventListener("mousedown",w)}};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},0);return()=>clearTimeout(M)},[X]),m8(K0("div",{ref:G,style:{...N,zIndex:W,width:Y,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:q,fontFamily:"'Inter', sans-serif"},children:H},void 0,!1,void 0,this),L)}var M4=[{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"]}],F4=M4.flatMap(($)=>$.items);function o$({anchorEl:$,scrollContainer:J,snippet:Q,truncateAt:X=100,header:W,initialNote:q="",initialImages:Y,onConfirm:H,onCancel:G,onDelete:B}){let N=h8(E8),L=x8(),M=_2(L),w=q!==""||!!B,[F,C]=r1(q),[K,O]=r1(Y||[]),[S,f]=r1(null),[A,Z]=r1(w),[h,I]=r1(!1),v=t2(null),u=t2(null),m=s2(()=>{if(F.trim()||K.length>0)H(F.trim(),K);else if(w&&B)B();else G()},[F,K,H,G,w,B]),e=s2(()=>{if(w){if(!F.trim()&&K.length===0&&B){B(),G();return}H(F,K);return}G()},[F,K,w,H,G,B]),X0=!w,q0=F.trim().length>0?F4.filter((T)=>T.toLowerCase().startsWith(F.trim().toLowerCase())):F4,z0=!X0||A?[]:q0.length===1&&q0[0]?.toLowerCase()===F.trim().toLowerCase()?[]:q0,c=new Set(z0),$0=M4.map((T)=>({label:T.label,items:T.items.filter((E)=>c.has(E))})).filter((T)=>T.items.length>0),J0=$0.map((T)=>T.items),G0=(T)=>J0[T]?.length??0,a=J0.flat(),Q0=w4(()=>{if(S===null)return 0;let T=0;for(let E=0;E<J0.length;E++){if(S<T+G0(E))return E;T+=G0(E)}return 0},[S,J0]),B0=w4(()=>{if(S===null)return 0;let T=0;for(let E=0;E<Q0;E++)T+=G0(E);return S-T},[S,Q0,J0]),k=(T,E)=>{let d=0;for(let H0=0;H0<T;H0++)d+=G0(H0);return d+E},[g,l]=r1(F);if(F!==g)l(F),f(null),Z(w);let z=s2((T)=>{C(T)},[]),j=Q.length>X?Q.slice(0,X)+"...":Q,n=s2((T)=>{if(a.length>0&&(T.key==="ArrowDown"||T.key==="ArrowUp"||T.key==="ArrowLeft"||T.key==="ArrowRight")){if(T.preventDefault(),S===null){f(0);return}if(T.key==="ArrowDown"){let d=Math.min(B0+1,G0(Q0)-1);f(k(Q0,d))}else if(T.key==="ArrowUp"){let d=Math.max(B0-1,0);f(k(Q0,d))}else if(T.key==="ArrowRight"){let d=Math.min(Q0+1,J0.length-1),H0=Math.min(B0,G0(d)-1);f(k(d,H0))}else if(T.key==="ArrowLeft"){let d=Math.max(Q0-1,0),H0=Math.min(B0,G0(d)-1);f(k(d,H0))}return}let E=S===null?void 0:a[S];if(E!==void 0){if(T.key==="Tab"){T.preventDefault(),z(E);return}if(T.key==="Enter"&&!T.shiftKey){T.preventDefault(),H(E,K);return}}if(T.key==="Enter"&&!T.shiftKey){T.preventDefault(),m();return}if(T.key==="Escape")if(a.length>0&&!A)Z(!0);else if(w)e();else G()},[a,S,B0,Q0,J0,k,z,H,K,m,A,w,e,G]);return K0(L4,{anchorEl:$,scrollContainer:J,onClose:w?e:G,ignoreSelector:w?"[data-annotation-id]":void 0,zIndex:w?"60":"50",padding:w?"10px 12px":"12px",width:"420px",children:[!w&&(W??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:["“",j,"”"]},void 0,!0,void 0,this)),K0(i1,{note:F,onNoteChange:C,images:K,onAddImage:(T)=>O((E)=>[...E,T]),onRemoveImage:(T)=>O((E)=>E.filter((d)=>d!==T)),sessionId:N,autoFocus:!0,autoResize:w,textareaRef:v,onKeyDown:n,attachButton:"none",openFilePickerRef:u,textareaStyle:w?{width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"none",outline:"none",overflow:"hidden"}:{width:"100%",minHeight:"60px",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"vertical",outline:"none"},placeholder:"Add your note..."},void 0,!1,void 0,this),K0("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:w?"6px":"8px"},children:[M&&K0(o2,{onClick:()=>u.current?.(),size:14},void 0,!1,void 0,this),K0("div",{style:{flex:1}},void 0,!1,void 0,this),w?K0("button",{onClick:()=>{if(B)B();G()},onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),style:{fontSize:"11px",color:h?"var(--color-accent-red)":"var(--color-text-tertiary)",background:"none",border:"none",cursor:"pointer",padding:"2px 0",fontFamily:"'Inter', sans-serif"},children:"Delete"},void 0,!1,void 0,this):K0(c8,{children:[K0("button",{onClick:G,style:{fontSize:"11px",color:"var(--color-text-tertiary)",background:"none",border:"none",cursor:"pointer",padding:"4px 12px",fontFamily:"'Inter', sans-serif"},children:"Cancel"},void 0,!1,void 0,this),K0("button",{onClick:m,style:{fontSize:"11px",fontWeight:500,padding:"4px 12px",borderRadius:"6px",background:"var(--color-highlight-bg)",color:"var(--color-text-primary)",border:"1px solid var(--color-highlight-border)",cursor:"pointer",fontFamily:"'Inter', sans-serif"},children:"Add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),a.length>0&&K0("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:$0.map((T)=>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:T.label},void 0,!1,void 0,this),T.items.map((E)=>{let d=a.indexOf(E);return K0("div",{onMouseDown:(H0)=>{H0.preventDefault(),H0.stopPropagation(),z(E)},onMouseEnter:()=>f(d),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:d===S?"var(--color-text-primary)":"var(--color-text-secondary)",background:d===S?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[K0("span",{style:{fontWeight:500},children:E.slice(0,F.trim().length)},void 0,!1,void 0,this),E.slice(F.trim().length)]},E,!0,void 0,this)})]},T.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function G1({anchorEl:$,scrollContainer:J,snippet:Q,truncateAt:X,header:W,onAdd:q,onCancel:Y}){return K0(o$,{anchorEl:$,scrollContainer:J,snippet:Q,truncateAt:X,header:W,onConfirm:(H,G)=>q(H,G),onCancel:Y},void 0,!1,void 0,this)}function R2({anchorEl:$,scrollContainer:J,initialNote:Q,initialImages:X,onUpdate:W,onDelete:q,onClose:Y}){return K0(o$,{anchorEl:$,scrollContainer:J,snippet:"",initialNote:Q,initialImages:X,onConfirm:(H,G)=>{W(H,G),Y()},onDelete:q,onCancel:Y},void 0,!1,void 0,this)}import{useEffect as u8,useRef as s$,useState as f4}from"react";import{jsxDEV as p8}from"react/jsx-dev-runtime";function t$($){let{containerRef:J,restoreKey:Q,shape:X="rect",canvasFile:W,scrollContainer:q}=$,{addAnnotationWithId:Y}=q1(),[H,G]=f4(null),[B,N]=f4(!1),L=s$(Y);L.current=Y;let M=s$(W);M.current=W;let w=s$(X);return w.current=X,u8(()=>{let C=J.current;if(!C)return;let K=null;function O(I,v){let u=I.getBoundingClientRect();return I$(u,v.clientX-u.left,v.clientY-u.top)}function S(){if(!K)return;let{host:I,pointerId:v}=K;if(I.hasPointerCapture(v))I.releasePointerCapture(v);I.removeEventListener("pointermove",A),I.removeEventListener("pointerup",Z),I.removeEventListener("pointercancel",h),K=null,N(!1)}function f(I){if(K||I.button!==0)return;let v=I.target;if(!(v instanceof Element))return;if(v.closest("[data-block-comment-btn]"))return;if(v.closest("[data-annotation-id]"))return;let u=v.closest(`[${g$}]`);if(!(u instanceof HTMLElement)||!C?.contains(u))return;let m=u.closest("[data-md='image']")?.getAttribute("data-md-src");if(!m)return;let e=O(u,I);if(!e)return;I.preventDefault(),u.setPointerCapture(I.pointerId);let X0=o0(),q0=u2({...e,w:0,h:0},w.current,X0);q0.classList.add("ann-region-draft"),u.appendChild(q0),K={pointerId:I.pointerId,host:u,src:m,start:e,shape:w.current,overlay:q0,id:X0},u.addEventListener("pointermove",A),u.addEventListener("pointerup",Z),u.addEventListener("pointercancel",h),N(!0)}function A(I){if(!K||K.pointerId!==I.pointerId)return;let v=O(K.host,I);if(!v)return;c2(K.overlay,v2(K.start,v))}function Z(I){if(!K||K.pointerId!==I.pointerId)return;let{overlay:v,id:u,src:m,shape:e}=K,X0=O(K.host,I)??K.start,q0=v2(K.start,X0);if(S(),!y$(q0)){v.remove();return}c2(v,q0);let z0={src:m,shape:e,...q0};G({overlay:v,id:u,snippet:B2.format(z0),label:m2(z0)})}function h(I){if(!K||K.pointerId!==I.pointerId)return;K.overlay.remove(),S()}return C.addEventListener("pointerdown",f),()=>{if(C.removeEventListener("pointerdown",f),K)K.overlay.remove(),S()}},[Q]),{popovers:H?p8(G1,{anchorEl:H.overlay,scrollContainer:q,snippet:H.label,truncateAt:80,onAdd:(C,K)=>{H.overlay.classList.remove("ann-region-draft"),L.current(H.id,H.snippet,C,void 0,void 0,K,M.current),G(null)},onCancel:()=>{H.overlay.remove(),G(null)}},void 0,!1,void 0,this):null,isDrawing:B,isPopoverOpen:!!H}}import{useCallback as K4,useEffect as a2,useRef as z1,useState as z4}from"react";import{jsxDEV as a$,Fragment as l8}from"react/jsx-dev-runtime";function e$($){let{containerRef:J,restoreKey:Q,restoreAnnotations:X,extractContext:W,filePath:q,canvasFile:Y,scrollContainer:H}=$,{annotations:G,addAnnotationWithId:B,removeAnnotation:N,updateAnnotation:L,addAnnotationImage:M,removeAnnotationImage:w,activeAnnotationId:F,setActiveAnnotationId:C}=q1(),[K,O]=z4(null),[S,f]=z4(null),A=z1(W);A.current=W;let Z=z1(q);Z.current=q;let h=z1(Y);h.current=Y;let I=z1(B);I.current=B;let v=z1(F);v.current=F;let u=z1(C);u.current=C;let m=X.length;a2(()=>{if(!J.current)return;let c=setTimeout(()=>{if(J.current)h$(J.current,X)},50);return()=>clearTimeout(c)},[Q,m]);let e=z1(null);a2(()=>{k$(F,e.current),e.current=F},[F]),a2(()=>{let c=J.current;if(!c)return;let $0=(a)=>{let Q0=a.target.closest("[data-annotation-id]");if(!Q0)return;a.stopPropagation();let B0=Q0.getAttribute("data-annotation-id");if(B0===v.current)O({anchorEl:Q0,annId:B0});else u.current(B0)},J0=(a)=>{let Q0=a.target.closest("[data-annotation-id]");if(Q0)u.current(Q0.getAttribute("data-annotation-id"))},G0=(a)=>{let Q0=a.target.closest("[data-annotation-id]"),B0=a.relatedTarget?.closest?.("[data-annotation-id]");if(Q0&&!B0&&!document.getElementById("ann-inline-popover"))u.current(null)};return c.addEventListener("click",$0),c.addEventListener("mouseover",J0),c.addEventListener("mouseout",G0),()=>{c.removeEventListener("click",$0),c.removeEventListener("mouseover",J0),c.removeEventListener("mouseout",G0)}},[Q]),a2(()=>{let c=()=>X0();return document.addEventListener("mouseup",c),()=>document.removeEventListener("mouseup",c)},[]);let X0=K4(()=>{let c=window.getSelection();if(!c||c.isCollapsed||!c.toString().trim())return;if(!J.current)return;let $0=c.getRangeAt(0);if(!J.current.contains($0.startContainer))return;if($0.startContainer.parentElement?.closest?.("[data-annotation-id]"))return;let J0=l5($0).trim();if(J0.length<2)return;let G0=A.current($0),a=$0.cloneRange(),Q0=`__pending_${Date.now()}`;try{I2(a,Q0)}catch{}window.getSelection()?.removeAllRanges();let B0=document.querySelectorAll(`[data-annotation-id="${Q0}"]`),k=B0[B0.length-1];if(!k)return;f({anchorEl:k,tempId:Q0,snippet:J0,ctx:G0})},[]),q0=K4((c,$0,J0,G0)=>{f({anchorEl:c,tempId:$0,snippet:J0,ctx:G0})},[]);return{popovers:a$(l8,{children:[K&&(()=>{let c=G.find(($0)=>$0.id===K.annId);if(!c)return null;return a$(R2,{anchorEl:K.anchorEl,scrollContainer:H,initialNote:c.note,initialImages:c.images,onUpdate:($0,J0)=>{L(K.annId,$0);let G0=c.images||[];for(let a of J0)if(!G0.includes(a))M(K.annId,a);for(let a of G0)if(!J0.includes(a))w(K.annId,a)},onDelete:()=>{N(K.annId),C(null)},onClose:()=>O(null)},void 0,!1,void 0,this)})(),S&&a$(G1,{anchorEl:S.anchorEl,scrollContainer:H,snippet:S.snippet,truncateAt:80,onAdd:(c,$0)=>{let J0=o0();A$(S.tempId,J0),I.current(J0,S.snippet,c,Z.current,S.ctx,$0,h.current),f(null)},onCancel:()=>{V$(S.tempId),f(null)}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),openCreatePopover:q0,isPopoverOpen:!!(K||S)}}import{AnnotationCtx as s8}from"#canvas/runtime";import{AnnotationCtx as t8,AnnotationHostContext as a8}from"@fabrika/annotations/runtime";import{useCallback as t1,useEffect as j4,useMemo as e8,useRef as X5,useState as a1}from"react";var HW=U.object({}).passthrough(),UW=U.object({annotations:U.array(U.unknown()).catch([]),generalNote:U.string().catch(""),responses:U.array(U.unknown()).catch([])}),BW=U.tuple([U.unknown(),U.object({note:U.unknown(),value:U.unknown()})]);function _1($,J,Q="current"){let X=`canvas:${$}:rev:${J}`;return Q==="next"?`${X}:next-draft`:X}function d8($,J){return`${_1($,J)}:draft-handled`}function $5($,J,Q){try{$.removeItem(_1(J,Q)),$.removeItem(d8(J,Q))}catch{}}function J5($,J){let Q=new Map;for(let[X,W]of $)if(J.has(X))Q.set(X,W);return Q}function Q5($,J){if(!$||$.length===0)return!1;return $.every((Q)=>J.has(Q))}function n1($,J,Q,X,W){let q=[],Y=$.filter((w)=>w.source!=="remote"||W&&W.has(w.id)),H=Y.filter((w)=>w.filePath===d1),G=Y.filter((w)=>!w.filePath),B=Y.filter((w)=>w.filePath&&w.filePath!==d1),N=Q?Array.from(Q.values()).filter((w)=>e2(w)):[],L=X?Array.from(X.values()).filter((w)=>w.markdown.trim()):[];if(N.length>0||L.length>0){q.push("## Responses"),q.push("");for(let w of N)q.push(i8(w));for(let w of L)q.push(w.markdown.trim()),q.push("")}if(H.length>0){q.push("## Annotations on agent response"),q.push("");for(let w of H)q.push(S2(w))}if(G.length>0){q.push("## Canvas annotations"),q.push("");let w=new Map;for(let K of G){let O=K.canvasFile||"";if(!w.has(O))w.set(O,[]);w.get(O).push(K)}let F=[...w.keys()].sort(),C=F.length>1||F.length===1&&F[0]!=="";for(let K of F){let O=w.get(K);if(C&&K)q.push(`### ${K.replace(/\.jsx$/,"")}`),q.push("");let S=r8(O);q.push(S4(S))}}if(B.length>0){let w={};for(let F of B){let C=F.filePath;if(!w[C])w[C]=[];w[C].push(F)}q.push("## File annotations"),q.push("");for(let[F,C]of Object.entries(w)){q.push(`### ${F}`),q.push("");for(let K of C)q.push(S2(K))}}if(J.trim())q.push("## General notes"),q.push(""),q.push(J.trim()),q.push("");return q.join(`
|
|
8
|
+
`).trim()+`
|
|
9
|
+
`}function e2($){if($.note?.trim())return!0;if($.value===null||$.value===void 0)return!1;if($.type==="text"&&!$.value.trim())return!1;if($.type==="checkbox"&&$.value.length===0)return!1;return!0}function _4($){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 O4($){let J=[];for(let Q of $.values())if(Q.required&&!Q.markdown.trim())J.push(Q);return J}function o1($,J){let Q=_4($),X=O4(J);return[...Q.map((W)=>W.label),...X.map((W)=>W.label||W.id)]}function i8($){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 r8($){let J={label:"",annotations:[],children:new Map};for(let Q of $){let X=Q.context?.hierarchy||[],W=J;for(let q of X){if(!W.children.has(q))W.children.set(q,{label:q,annotations:[],children:new Map});W=W.children.get(q)}W.annotations.push(Q)}return J}function S4($,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(S4(X,J+1))}return Q.join(`
|
|
11
|
+
`)}import{createContext as n8,useContext as o8}from"react";function R4(){if(typeof window>"u")return"";return window.location.pathname.replace("/s/","")}var C4={get sessionId(){return R4()},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/${R4()}/canvas/${encodeURIComponent(Q)}${X}`)}},P4=n8(C4);function t0(){return o8(P4)}var $$=U.object({id:U.string(),type:U.enum(["select","radio","checkbox","text","range"]),label:U.string(),value:U.unknown(),options:U.array(U.string()).optional(),required:U.boolean().optional(),note:U.string().optional()}).passthrough().transform(($)=>({...$,value:$.value})),J$=U.object({id:U.string(),markdown:U.string(),label:U.string().optional(),required:U.boolean().optional()}).passthrough(),Q$=p$.extend({responses:U.array(U.tuple([U.string(),$$]).optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).catch([]),feedbackEntries:U.array(U.tuple([U.string(),J$]).optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).optional().catch([])});function s1($){let J=Q$.safeParse($);return J.success?J.data:null}var k4=U.object({feedback:U.string().nullish()}),A4=U.union([U.object({error:U.string().min(1)}),U.object({content:U.string(),language:U.string().nullish()})]);import{useAnnotations as O1}from"#canvas/runtime";import{jsxDEV as Y5}from"react/jsx-dev-runtime";function V4($,J,Q){try{let X=localStorage.getItem(_1($,J,Q));if(!X)return null;return s1(JSON.parse(X))}catch{return null}}function $J($,J,Q,X){try{localStorage.setItem(_1($,J,Q),JSON.stringify(X))}catch{}}function W5($){return{draft:$,responseIds:new Set,canvases:new Set}}function X$({sessionId:$,revision:J,isReadOnly:Q,draftPhase:X,remoteAnnotations:W,canvasFiles:q,loadState:Y,saveState:H,children:G}){let B=!!Y,N=B?null:V4($,J,X),L=X5(N),[M,w]=a1(()=>(N?.annotations??[]).map((k)=>({...k,source:k.source??"local"}))),[F,C]=a1(()=>N?.generalNote??""),[K,O]=a1(()=>N?.responses?new Map(N.responses):new Map),S=`${$}:${J}:${X}`,f=X5(S);f.current=S;let[A,Z]=a1(()=>W5(S)),[h,I]=a1(()=>N?.feedbackEntries?new Map(N.feedbackEntries):new Map),[v,u]=a1(!B);j4(()=>{let k=(g)=>{L.current=g,w((g?.annotations??[]).map((l)=>({...l,source:l.source??"local"}))),C(g?.generalNote??""),O(g?.responses?new Map(g.responses):new Map),I(g?.feedbackEntries?new Map(g.feedbackEntries):new Map),Q0(null)};if(B){let g=!1;return u(!1),Y($,J,X).then((l)=>{if(g)return;k(s1(l)),u(!0)}),()=>{g=!0}}k(V4($,J,X)),u(!0);return},[$,J,X,B,Y]);let m=X5(null);j4(()=>{if(Q&&X!=="next")return;if(!v)return;if(m.current)clearTimeout(m.current);let k={...L.current,annotations:M,generalNote:F,responses:Array.from(K.entries()),feedbackEntries:Array.from(h.entries())},g=()=>{if(H)H($,J,k,X);else $J($,J,X,k)};if(X==="next"){g();return}return m.current=setTimeout(g,300),()=>{if(m.current)clearTimeout(m.current)}},[M,F,K,h,$,J,Q,X,v,H]);let e=t1((k,g)=>{O((l)=>{let z=new Map(l);return z.set(k,g),z})},[]),X0=t1((k)=>{Z((g)=>{let l=g.draft===f.current?g:W5(f.current);if(l.responseIds.has(k))return l;return{...l,responseIds:new Set(l.responseIds).add(k)}})},[]),q0=t1((k)=>{Z((g)=>{let l=g.draft===f.current?g:W5(f.current);if(l.canvases.has(k))return l;return{...l,canvases:new Set(l.canvases).add(k)}})},[]),z0=A.draft===S?A:null,c=e8(()=>{if(!z0||!Q5(q,z0.canvases))return K;return J5(K,z0.responseIds)},[z0,q,K]),$0=t1((k,g)=>{I((l)=>{let z=l.get(k);if(z&&z.markdown===g.markdown&&z.label===g.label&&z.required===g.required)return l;let j=new Map(l);return j.set(k,g),j})},[]),J0=t1((k)=>{I((g)=>{if(!g.has(k))return g;let l=new Map(g);return l.delete(k),l})},[]),G0=t1(()=>{if(O(new Map),I(new Map),H)H($,J,{annotations:[],generalNote:"",responses:[],feedbackEntries:[]},X);else if(X==="next")localStorage.removeItem(_1($,J,X));else $5(localStorage,$,J)},[$,J,X,H]),a=n2({annotations:M,setAnnotations:w,generalNote:F,setGeneralNote:C,remoteAnnotations:W,isReadOnly:Q,onClear:G0}),{setActiveAnnotationId:Q0}=a,B0=t0();return Y5(a8.Provider,{value:B0,children:Y5(t8.Provider,{value:a,children:Y5(s8.Provider,{value:{...a,responses:K,setResponse:e,submittableResponses:c,registerResponse:X0,registerCanvasRendered:q0,feedbackEntries:h,setFeedbackEntry:$0,removeFeedbackEntry:J0},children:G},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{ActiveViewCtx as B9,AnnotationCtx as N9,CanvasFileCtx as w9,SessionContext as P5,useAnnotations as F9,useCanvasFile as VH,useFeedback as L9,useResponseRegistration as TH}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 x$($.snippet,Q)}function T4($){$.classList.remove("ann-flash"),$.offsetWidth,$.classList.add("ann-flash"),$.addEventListener("animationend",()=>{$.classList.remove("ann-flash")},{once:!0})}function q5($,J){let Q=M1($);if(Q)J({type:"file",path:Q}),setTimeout(()=>{let X=C2($);if(X)X.scrollIntoView({behavior:"smooth",block:"center"}),T4(X)},150);else{let X=C2($);if(X)X.scrollIntoView({behavior:"smooth",block:"center"}),T4(X)}}import{SessionContext as rJ}from"#canvas/runtime";import{useCallback as O5,useContext as S5,useEffect as o4,useMemo as nJ,useState as Q2}from"react";import{createContext as Z4}from"react";var e1=Z4({activeView:{type:"overview"},setActiveView:()=>{},openFiles:[],closeFile:()=>{},canvasFiles:[]}),$2=Z4({currentRevision:1,selectedRevision:1,revisions:[],setSelectedRevision:()=>{},isReadOnly:!1,compareRevision:null,setCompareRevision:()=>{},agentWatching:!1});import{jsxDEV as S1}from"react/jsx-dev-runtime";var JJ={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"},QJ={ts:"TS",tsx:"TX",js:"JS",jsx:"JX",py:"PY",rs:"RS",go:"GO",rb:"RB",json:"{}",yaml:"YM",yml:"YM",toml:"TM",html:"<>",css:"#",scss:"#",md:"M↓",sh:"$",bash:"$",c:"C",cpp:"C+",h:"H",svg:"◇",png:"▣",jpg:"▣"};function G5({name:$,type:J,expanded: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():"",q=JJ[W]||"#6b6560",Y=QJ[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:q,opacity:"0.85"},void 0,!1,void 0,this),S1("path",{d:"M10 1.5v2.5a1 1 0 001 1h2.5",fill:"none",stroke:"white",strokeWidth:"0.5",opacity:"0.5"},void 0,!1,void 0,this),Y&&S1("text",{x:"8",y:"11.5",textAnchor:"middle",fill:"white",fontSize:"5.5",fontFamily:"monospace",fontWeight:"600",children:Y},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function U5(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var P1=U5();function x4($){P1=$}var R1={exec:()=>null};function t($,J=""){let Q=typeof $=="string"?$:$.source,X={replace:(W,q)=>{let Y=typeof q=="string"?q:q.source;return Y=Y.replace(R0.caret,"$1"),Q=Q.replace(W,Y),X},getRegex:()=>new RegExp(Q,J)};return X}var XJ=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),R0={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:($)=>new RegExp(`^( {0,3}${$})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}#`),htmlBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}>`)},WJ=/^(?:[ \t]*(?:\n|$))+/,YJ=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,qJ=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,j2=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,GJ=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,B5=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,h4=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,v4=t(h4).replace(/bull/g,B5).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),HJ=t(h4).replace(/bull/g,B5).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),N5=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,UJ=/^[^\n]+/,w5=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,BJ=t(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",w5).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),NJ=t(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,B5).getRegex(),H$="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",F5=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,wJ=t("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",F5).replace("tag",H$).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),m4=t(N5).replace("hr",j2).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",H$).getRegex(),FJ=t(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",m4).getRegex(),L5={blockquote:FJ,code:YJ,def:BJ,fences:qJ,heading:GJ,hr:j2,html:wJ,lheading:v4,list:NJ,newline:WJ,paragraph:m4,table:R1,text:UJ},D4=t("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",j2).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",H$).getRegex(),LJ={...L5,lheading:HJ,table:D4,paragraph:t(N5).replace("hr",j2).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",D4).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",H$).getRegex()},MJ={...L5,html:t(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",F5).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:R1,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:t(N5).replace("hr",j2).replace("heading",` *#{1,6} *[^
|
|
12
|
+
]`).replace("lheading",v4).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},fJ=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,KJ=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,c4=/^( {2,}|\\)\n(?!\s*$)/,zJ=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,J2=/[\p{P}\p{S}]/u,U$=/[\s\p{P}\p{S}]/u,M5=/[^\s\p{P}\p{S}]/u,_J=t(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,U$).getRegex(),u4=/(?!~)[\p{P}\p{S}]/u,OJ=/(?!~)[\s\p{P}\p{S}]/u,SJ=/(?:[^\s\p{P}\p{S}]|~)/u,RJ=t(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",XJ?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),p4=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,CJ=t(p4,"u").replace(/punct/g,J2).getRegex(),PJ=t(p4,"u").replace(/punct/g,u4).getRegex(),l4="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",kJ=t(l4,"gu").replace(/notPunctSpace/g,M5).replace(/punctSpace/g,U$).replace(/punct/g,J2).getRegex(),AJ=t(l4,"gu").replace(/notPunctSpace/g,SJ).replace(/punctSpace/g,OJ).replace(/punct/g,u4).getRegex(),jJ=t("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,M5).replace(/punctSpace/g,U$).replace(/punct/g,J2).getRegex(),VJ=t(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,J2).getRegex(),TJ="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",ZJ=t(TJ,"gu").replace(/notPunctSpace/g,M5).replace(/punctSpace/g,U$).replace(/punct/g,J2).getRegex(),DJ=t(/\\(punct)/,"gu").replace(/punct/g,J2).getRegex(),bJ=t(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),gJ=t(F5).replace("(?:-->|$)","-->").getRegex(),IJ=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",gJ).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Y$=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,yJ=t(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Y$).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),d4=t(/^!?\[(label)\]\[(ref)\]/).replace("label",Y$).replace("ref",w5).getRegex(),i4=t(/^!?\[(ref)\](?:\[\])?/).replace("ref",w5).getRegex(),EJ=t("reflink|nolink(?!\\()","g").replace("reflink",d4).replace("nolink",i4).getRegex(),b4=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,f5={_backpedal:R1,anyPunctuation:DJ,autolink:bJ,blockSkip:RJ,br:c4,code:KJ,del:R1,delLDelim:R1,delRDelim:R1,emStrongLDelim:CJ,emStrongRDelimAst:kJ,emStrongRDelimUnd:jJ,escape:fJ,link:yJ,nolink:i4,punctuation:_J,reflink:d4,reflinkSearch:EJ,tag:IJ,text:zJ,url:R1},xJ={...f5,link:t(/^!?\[(label)\]\((.*?)\)/).replace("label",Y$).getRegex(),reflink:t(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Y$).getRegex()},H5={...f5,emStrongRDelimAst:AJ,emStrongLDelim:PJ,delLDelim:VJ,delRDelim:ZJ,url:t(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",b4).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:t(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",b4).getRegex()},hJ={...H5,br:t(c4).replace("{2,}","*").getRegex(),text:t(H5.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},W$={normal:L5,gfm:LJ,pedantic:MJ},P2={normal:f5,gfm:H5,breaks:hJ,pedantic:xJ},vJ={"&":"&","<":"<",">":">",'"':""","'":"'"},g4=($)=>vJ[$];function p0($,J){if(J){if(R0.escapeTest.test($))return $.replace(R0.escapeReplace,g4)}else if(R0.escapeTestNoEncode.test($))return $.replace(R0.escapeReplaceNoEncode,g4);return $}function I4($){try{$=encodeURI($).replace(R0.percentDecode,"%")}catch{return null}return $}function y4($,J){let Q=$.replace(R0.findPipe,(q,Y,H)=>{let G=!1,B=Y;for(;--B>=0&&H[B]==="\\";)G=!G;return G?"|":" |"}),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 q=$.charAt(X-W-1);if(q===J&&!Q)W++;else if(q!==J&&Q)W++;else break}return $.slice(0,X-W)}function mJ($,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 cJ($,J=0){let Q=J,X="";for(let W of $)if(W==="\t"){let q=4-Q%4;X+=" ".repeat(q),Q+=q}else X+=W,Q++;return X}function E4($,J,Q,X,W){let q=J.href,Y=J.title||null,H=$[1].replace(W.other.outputLinkReplace,"$1");X.state.inLink=!0;let G={type:$[0].charAt(0)==="!"?"image":"link",raw:Q,href:q,title:Y,text:H,tokens:X.inlineTokens(H)};return X.state.inLink=!1,G}function uJ($,J,Q){let X=$.match(Q.other.indentCodeCompensation);if(X===null)return J;let W=X[1];return J.split(`
|
|
13
|
+
`).map((q)=>{let Y=q.match(Q.other.beginningSpace);if(Y===null)return q;let[H]=Y;return H.length>=W.length?q.slice(W.length):q}).join(`
|
|
14
|
+
`)}var q$=class{options;rules;lexer;constructor($){this.options=$||P1}space($){let J=this.rules.block.newline.exec($);if(J&&J[0].length>0)return{type:"space",raw:J[0]}}code($){let J=this.rules.block.code.exec($);if(J){let 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=uJ(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="",q=[];for(;Q.length>0;){let Y=!1,H=[],G;for(G=0;G<Q.length;G++)if(this.rules.other.blockquoteStart.test(Q[G]))H.push(Q[G]),Y=!0;else if(!Y)H.push(Q[G]);else break;Q=Q.slice(G);let B=H.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,q,!0),this.lexer.state.top=L,Q.length===0)break;let M=q.at(-1);if(M?.type==="code")break;if(M?.type==="blockquote"){let w=M,F=w.raw+`
|
|
23
|
+
`+Q.join(`
|
|
24
|
+
`),C=this.blockquote(F);q[q.length-1]=C,X=X.substring(0,X.length-w.raw.length)+C.raw,W=W.substring(0,W.length-w.text.length)+C.text;break}else if(M?.type==="list"){let w=M,F=w.raw+`
|
|
25
|
+
`+Q.join(`
|
|
26
|
+
`),C=this.list(F);q[q.length-1]=C,X=X.substring(0,X.length-M.raw.length)+C.raw,W=W.substring(0,W.length-w.raw.length)+C.raw,Q=F.substring(q.at(-1).raw.length).split(`
|
|
27
|
+
`);continue}}return{type:"blockquote",raw:X,tokens:q,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 q=this.rules.other.listItemRegex(Q),Y=!1;for(;$;){let G=!1,B="",N="";if(!(J=q.exec($))||this.rules.block.hr.test($))break;B=J[0],$=$.substring(B.length);let L=cJ(J[2].split(`
|
|
28
|
+
`,1)[0],J[1].length),M=$.split(`
|
|
29
|
+
`,1)[0],w=!L.trim(),F=0;if(this.options.pedantic?(F=2,N=L.trimStart()):w?F=J[1].length+1:(F=L.search(this.rules.other.nonSpaceChar),F=F>4?1:F,N=L.slice(F),F+=J[1].length),w&&this.rules.other.blankLine.test(M)&&(B+=M+`
|
|
30
|
+
`,$=$.substring(M.length+1),G=!0),!G){let C=this.rules.other.nextBulletRegex(F),K=this.rules.other.hrRegex(F),O=this.rules.other.fencesBeginRegex(F),S=this.rules.other.headingBeginRegex(F),f=this.rules.other.htmlBeginRegex(F),A=this.rules.other.blockquoteBeginRegex(F);for(;$;){let Z=$.split(`
|
|
31
|
+
`,1)[0],h;if(M=Z,this.options.pedantic?(M=M.replace(this.rules.other.listReplaceNesting," "),h=M):h=M.replace(this.rules.other.tabCharGlobal," "),O.test(M)||S.test(M)||f.test(M)||A.test(M)||C.test(M)||K.test(M))break;if(h.search(this.rules.other.nonSpaceChar)>=F||!M.trim())N+=`
|
|
32
|
+
`+h.slice(F);else{if(w||L.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||O.test(L)||S.test(L)||K.test(L))break;N+=`
|
|
33
|
+
`+M}w=!M.trim(),B+=Z+`
|
|
34
|
+
`,$=$.substring(Z.length+1),L=h.slice(F)}}W.loose||(Y?W.loose=!0:this.rules.other.doubleBlankLine.test(B)&&(Y=!0)),W.items.push({type:"list_item",raw:B,task:!!this.options.gfm&&this.rules.other.listIsTask.test(N),loose:!1,text:N,tokens:[]}),W.raw+=B}let H=W.items.at(-1);if(H)H.raw=H.raw.trimEnd(),H.text=H.text.trimEnd();else return;W.raw=W.raw.trimEnd();for(let G of W.items){if(this.lexer.state.top=!1,G.tokens=this.lexer.blockTokens(G.text,[]),G.task){if(G.text=G.text.replace(this.rules.other.listReplaceTask,""),G.tokens[0]?.type==="text"||G.tokens[0]?.type==="paragraph"){G.tokens[0].raw=G.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),G.tokens[0].text=G.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let N=this.lexer.inlineQueue.length-1;N>=0;N--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[N].src)){this.lexer.inlineQueue[N].src=this.lexer.inlineQueue[N].src.replace(this.rules.other.listReplaceTask,"");break}}let B=this.rules.other.listTaskCheckbox.exec(G.raw);if(B){let N={type:"checkbox",raw:B[0]+" ",checked:B[0]!=="[ ]"};G.checked=N.checked,W.loose?G.tokens[0]&&["paragraph","text"].includes(G.tokens[0].type)&&"tokens"in G.tokens[0]&&G.tokens[0].tokens?(G.tokens[0].raw=N.raw+G.tokens[0].raw,G.tokens[0].text=N.raw+G.tokens[0].text,G.tokens[0].tokens.unshift(N)):G.tokens.unshift({type:"paragraph",raw:N.raw,text:N.raw,tokens:[N]}):G.tokens.unshift(N)}}if(!W.loose){let B=G.tokens.filter((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 G of W.items){G.loose=!0;for(let B of G.tokens)B.type==="text"&&(B.type="paragraph")}return W}}html($){let J=this.rules.block.html.exec($);if(J)return{type:"html",block:!0,raw:J[0],pre:J[1]==="pre"||J[1]==="script"||J[1]==="style",text:J[0]}}def($){let J=this.rules.block.def.exec($);if(J){let 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=y4(J[1]),X=J[2].replace(this.rules.other.tableAlignChars,"").split("|"),W=J[3]?.trim()?J[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
35
|
+
`):[],q={type:"table",raw:J[0],header:[],align:[],rows:[]};if(Q.length===X.length){for(let Y of X)this.rules.other.tableAlignRight.test(Y)?q.align.push("right"):this.rules.other.tableAlignCenter.test(Y)?q.align.push("center"):this.rules.other.tableAlignLeft.test(Y)?q.align.push("left"):q.align.push(null);for(let Y=0;Y<Q.length;Y++)q.header.push({text:Q[Y],tokens:this.lexer.inline(Q[Y]),header:!0,align:q.align[Y]});for(let Y of W)q.rows.push(y4(Y,q.header.length).map((H,G)=>({text:H,tokens:this.lexer.inline(H),header:!1,align:q.align[G]})));return q}}lheading($){let J=this.rules.block.lheading.exec($);if(J){let 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 q=k2(Q.slice(0,-1),"\\");if((Q.length-q.length)%2===0)return}else{let q=mJ(J[2],"()");if(q===-2)return;if(q>-1){let Y=(J[0].indexOf("!")===0?5:4)+J[1].length+q;J[2]=J[2].substring(0,q),J[0]=J[0].substring(0,Y).trim(),J[3]=""}}let X=J[2],W="";if(this.options.pedantic){let q=this.rules.other.pedanticHrefTitle.exec(X);q&&(X=q[1],W=q[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)),E4(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 q=Q[0].charAt(0);return{type:"text",raw:q,text:q}}return E4(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,q,Y,H=W,G=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(q=X[1]||X[2]||X[3]||X[4]||X[5]||X[6],!q)continue;if(Y=[...q].length,X[3]||X[4]){H+=Y;continue}else if((X[5]||X[6])&&W%3&&!((W+Y)%3)){G+=Y;continue}if(H-=Y,H>0)continue;Y=Math.min(Y,Y+H+G);let N=[...X[0]][0].length,L=$.slice(0,W+X.index+N+Y);if(Math.min(W,Y)%2){let w=L.slice(1,-1);return{type:"em",raw:L,text:w,tokens:this.lexer.inlineTokens(w)}}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,q,Y,H=W,G=this.rules.inline.delRDelim;for(G.lastIndex=0,J=J.slice(-1*$.length+W);(X=G.exec(J))!==null;){if(q=X[1]||X[2]||X[3]||X[4]||X[5]||X[6],!q||(Y=[...q].length,Y!==W))continue;if(X[3]||X[4]){H+=Y;continue}if(H-=Y,H>0)continue;Y=Math.min(Y,Y+H);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}}}},y0=class ${tokens;options;state;inlineQueue;tokenizer;constructor(J){this.tokens=[],this.tokens.links=Object.create(null),this.options=J||P1,this.options.tokenizer=this.options.tokenizer||new q$,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let Q={other:R0,block:W$.normal,inline:P2.normal};this.options.pedantic?(Q.block=W$.pedantic,Q.inline=P2.pedantic):this.options.gfm&&(Q.block=W$.gfm,this.options.breaks?Q.inline=P2.breaks:Q.inline=P2.gfm),this.tokenizer.rules=Q}static get rules(){return{block:W$,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 q=J;if(this.options.extensions?.startBlock){let Y=1/0,H=J.slice(1),G;this.options.extensions.startBlock.forEach((B)=>{G=B.call({lexer:this},H),typeof G=="number"&&G>=0&&(Y=Math.min(Y,G))}),Y<1/0&&Y>=0&&(q=J.substring(0,Y+1))}if(this.state.top&&(W=this.tokenizer.paragraph(q))){let Y=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=q.length!==J.length,J=J.substring(W.raw.length);continue}if(W=this.tokenizer.text(J)){J=J.substring(W.raw.length);let Y=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 G=Object.keys(this.tokens.links);if(G.length>0)for(;(W=this.tokenizer.rules.inline.reflinkSearch.exec(X))!==null;)G.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 q;for(;(W=this.tokenizer.rules.inline.blockSkip.exec(X))!==null;)q=W[2]?W[2].length:0,X=X.slice(0,W.index+q)+"["+"a".repeat(W[0].length-q-2)+"]"+X.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);X=this.options.hooks?.emStrongMask?.call({lexer:this},X)??X;let Y=!1,H="";for(;J;){Y||(H=""),Y=!1;let G;if(this.options.extensions?.inline?.some((N)=>(G=N.call({lexer:this},J,Q))?(J=J.substring(G.raw.length),Q.push(G),!0):!1))continue;if(G=this.tokenizer.escape(J)){J=J.substring(G.raw.length),Q.push(G);continue}if(G=this.tokenizer.tag(J)){J=J.substring(G.raw.length),Q.push(G);continue}if(G=this.tokenizer.link(J)){J=J.substring(G.raw.length),Q.push(G);continue}if(G=this.tokenizer.reflink(J,this.tokens.links)){J=J.substring(G.raw.length);let N=Q.at(-1);G.type==="text"&&N?.type==="text"?(N.raw+=G.raw,N.text+=G.text):Q.push(G);continue}if(G=this.tokenizer.emStrong(J,X,H)){J=J.substring(G.raw.length),Q.push(G);continue}if(G=this.tokenizer.codespan(J)){J=J.substring(G.raw.length),Q.push(G);continue}if(G=this.tokenizer.br(J)){J=J.substring(G.raw.length),Q.push(G);continue}if(G=this.tokenizer.del(J,X,H)){J=J.substring(G.raw.length),Q.push(G);continue}if(G=this.tokenizer.autolink(J)){J=J.substring(G.raw.length),Q.push(G);continue}if(!this.state.inLink&&(G=this.tokenizer.url(J))){J=J.substring(G.raw.length),Q.push(G);continue}let B=J;if(this.options.extensions?.startInline){let N=1/0,L=J.slice(1),M;this.options.extensions.startInline.forEach((w)=>{M=w.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(G=this.tokenizer.inlineText(B)){J=J.substring(G.raw.length),G.raw.slice(-1)!=="_"&&(H=G.raw.slice(-1)),Y=!0;let N=Q.at(-1);N?.type==="text"?(N.raw+=G.raw,N.text+=G.text):Q.push(G);continue}if(J){let N="Infinite loop on byte: "+J.charCodeAt(0);if(this.options.silent){console.error(N);break}else throw Error(N)}}return Q}},G$=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 H=$.items[Y];X+=this.listitem(H)}let W=J?"ol":"ul",q=J&&Q!==1?' start="'+Q+'"':"";return"<"+W+q+`>
|
|
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 q=$.rows[W];Q="";for(let Y=0;Y<q.length;Y++)Q+=this.tablecell(q[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=I4($);if(W===null)return X;$=W;let q='<a href="'+$+'"';return J&&(q+=' title="'+p0(J)+'"'),q+=">"+X+"</a>",q}image({href:$,title:J,text:Q,tokens:X}){X&&(Q=this.parser.parseInline(X,this.parser.textRenderer));let W=I4($);if(W===null)return p0(Q);$=W;let q=`<img src="${$}" alt="${p0(Q)}"`;return J&&(q+=` title="${p0(J)}"`),q+=">",q}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 $}},E0=class ${options;renderer;textRenderer;constructor(J){this.options=J||P1,this.options.renderer=this.options.renderer||new G$,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new 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,H=this.options.extensions.renderers[Y.type].call({parser:this},Y);if(H!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(Y.type)){Q+=H||"";continue}}let q=W;switch(q.type){case"space":{Q+=this.renderer.space(q);break}case"hr":{Q+=this.renderer.hr(q);break}case"heading":{Q+=this.renderer.heading(q);break}case"code":{Q+=this.renderer.code(q);break}case"table":{Q+=this.renderer.table(q);break}case"blockquote":{Q+=this.renderer.blockquote(q);break}case"list":{Q+=this.renderer.list(q);break}case"checkbox":{Q+=this.renderer.checkbox(q);break}case"html":{Q+=this.renderer.html(q);break}case"def":{Q+=this.renderer.def(q);break}case"paragraph":{Q+=this.renderer.paragraph(q);break}case"text":{Q+=this.renderer.text(q);break}default:{let Y='Token with "'+q.type+'" type was not found.';if(this.options.silent)return console.error(Y),"";throw Error(Y)}}}return Q}parseInline(J,Q=this.renderer){this.renderer.parser=this;let X="";for(let W=0;W<J.length;W++){let q=J[W];if(this.options.extensions?.renderers?.[q.type]){let H=this.options.extensions.renderers[q.type].call({parser:this},q);if(H!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(q.type)){X+=H||"";continue}}let Y=q;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 H='Token with "'+Y.type+'" type was not found.';if(this.options.silent)return console.error(H),"";throw Error(H)}}}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 $?y0.lex:y0.lexInline}provideParser($=this.block){return $?E0.parse:E0.parseInline}},pJ=class{defaults=U5();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=E0;Renderer=G$;TextRenderer=K5;Lexer=y0;Tokenizer=q$;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 q of W.header)Q=Q.concat(this.walkTokens(q.tokens,J));for(let q of W.rows)for(let Y of q)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((q)=>{let Y=W[q].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 q=J.renderers[W.name];q?J.renderers[W.name]=function(...Y){let H=W.renderer.apply(this,Y);return H===!1&&(H=q.apply(this,Y)),H}:J.renderers[W.name]=W.renderer}if("tokenizer"in W){if(!W.level||W.level!=="block"&&W.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let q=J[W.level];q?q.unshift(W.tokenizer):J[W.level]=[W.tokenizer],W.start&&(W.level==="block"?J.startBlock?J.startBlock.push(W.start):J.startBlock=[W.start]:W.level==="inline"&&(J.startInline?J.startInline.push(W.start):J.startInline=[W.start]))}"childTokens"in W&&W.childTokens&&(J.childTokens[W.name]=W.childTokens)}),X.extensions=J),Q.renderer){let W=this.defaults.renderer||new G$(this.defaults);for(let q in Q.renderer){if(!(q in W))throw Error(`renderer '${q}' does not exist`);if(["options","parser"].includes(q))continue;let Y=q,H=Q.renderer[Y],G=W[Y];W[Y]=(...B)=>{let N=H.apply(W,B);return N===!1&&(N=G.apply(W,B)),N||""}}X.renderer=W}if(Q.tokenizer){let W=this.defaults.tokenizer||new q$(this.defaults);for(let q in Q.tokenizer){if(!(q in W))throw Error(`tokenizer '${q}' does not exist`);if(["options","rules","lexer"].includes(q))continue;let Y=q,H=Q.tokenizer[Y],G=W[Y];W[Y]=(...B)=>{let N=H.apply(W,B);return N===!1&&(N=G.apply(W,B)),N}}X.tokenizer=W}if(Q.hooks){let W=this.defaults.hooks||new A2;for(let q in Q.hooks){if(!(q in W))throw Error(`hook '${q}' does not exist`);if(["options","block"].includes(q))continue;let Y=q,H=Q.hooks[Y],G=W[Y];A2.passThroughHooks.has(q)?W[Y]=(B)=>{if(this.defaults.async&&A2.passThroughHooksRespectAsync.has(q))return(async()=>{let L=await H.call(W,B);return G.call(W,L)})();let N=H.call(W,B);return G.call(W,N)}:W[Y]=(...B)=>{if(this.defaults.async)return(async()=>{let L=await H.apply(W,B);return L===!1&&(L=await G.apply(W,B)),L})();let N=H.apply(W,B);return N===!1&&(N=G.apply(W,B)),N}}X.hooks=W}if(Q.walkTokens){let W=this.defaults.walkTokens,q=Q.walkTokens;X.walkTokens=function(Y){let H=[];return H.push(q.call(this,Y)),W&&(H=H.concat(W.call(this,Y))),H}}this.defaults={...this.defaults,...X}}),this}setOptions($){return this.defaults={...this.defaults,...$},this}lexer($,J){return y0.lex($,J??this.defaults)}parser($,J){return E0.parse($,J??this.defaults)}parseMarkdown($){return(J,Q)=>{let X={...Q},W={...this.defaults,...X},q=this.onError(!!W.silent,!!W.async);if(this.defaults.async===!0&&X.async===!1)return q(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof J>"u"||J===null)return q(Error("marked(): input parameter is undefined or null"));if(typeof J!="string")return q(Error("marked(): input parameter is of type "+Object.prototype.toString.call(J)+", string expected"));if(W.hooks&&(W.hooks.options=W,W.hooks.block=$),W.async)return(async()=>{let Y=W.hooks?await W.hooks.preprocess(J):J,H=await(W.hooks?await W.hooks.provideLexer($):$?y0.lex:y0.lexInline)(Y,W),G=W.hooks?await W.hooks.processAllTokens(H):H;W.walkTokens&&await Promise.all(this.walkTokens(G,W.walkTokens));let B=await(W.hooks?await W.hooks.provideParser($):$?E0.parse:E0.parseInline)(G,W);return W.hooks?await W.hooks.postprocess(B):B})().catch(q);try{W.hooks&&(J=W.hooks.preprocess(J));let Y=(W.hooks?W.hooks.provideLexer($):$?y0.lex:y0.lexInline)(J,W);W.hooks&&(Y=W.hooks.processAllTokens(Y)),W.walkTokens&&this.walkTokens(Y,W.walkTokens);let H=(W.hooks?W.hooks.provideParser($):$?E0.parse:E0.parseInline)(Y,W);return W.hooks&&(H=W.hooks.postprocess(H)),H}catch(Y){return q(Y)}}}onError($,J){return(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 pJ;function s($,J){return C1.parse($,J)}s.options=s.setOptions=function($){return C1.setOptions($),s.defaults=C1.defaults,x4(s.defaults),s};s.getDefaults=U5;s.defaults=P1;s.use=function(...$){return C1.use(...$),s.defaults=C1.defaults,x4(s.defaults),s};s.walkTokens=function($,J){return C1.walkTokens($,J)};s.parseInline=C1.parseInline;s.Parser=E0;s.parser=E0.parse;s.Renderer=G$;s.TextRenderer=K5;s.Lexer=y0;s.lexer=y0.lex;s.Tokenizer=q$;s.Hooks=A2;s.parse=s;var{options:xW,setOptions:hW,use:vW,walkTokens:mW,parseInline:cW}=s;var uW=E0.parse,pW=y0.lex;import{useEffect as r4,useMemo as z5,useRef as lJ,useState as V2}from"react";import{jsxDEV as F0}from"react/jsx-dev-runtime";function _5({open:$,onClose:J,onSubmit:Q,includedRemoteIds:X,onToggleRemoteId:W}){let{annotations:q,generalNote:Y,submittableResponses:H,feedbackEntries:G}=O1(),[B,N]=V2(""),[L,M]=V2(!1),[w,F]=V2(!1),[C,K]=V2(null),O=lJ(null),[S,f]=V2(!1),A=z5(()=>q.filter((v)=>v.source==="remote"),[q]);if($&&!S)M(!1),F(!1),K(null);if(!$&&S)M(!1),F(!1),K(null);if($!==S)f($);let Z=z5(()=>n1(q,Y,H,G,X),[q,Y,H,G,X]),h=L?B:Z;if(r4(()=>{if($&&w&&O.current)O.current.focus()},[$,w]),r4(()=>{if(!$)return;let v=(u)=>{if(u.key==="Escape")J()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[$,J]),!$)return null;let I=h.trim().length>0;return F0("div",{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm flex items-center justify-center p-8",onClick:J,children:F0("div",{className:"bg-bg-surface border border-border-medium rounded-xl shadow-lg w-full max-w-2xl flex flex-col",style:{height:"80vh"},onClick:(v)=>v.stopPropagation(),children:[F0("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border-subtle flex-shrink-0",children:[F0("div",{className:"flex items-center gap-3",children:[F0("span",{className:"text-[13px] font-medium text-text-primary font-body",children:"Response preview"},void 0,!1,void 0,this),L&&F0("button",{onClick:()=>{M(!1),F(!1)},className:"text-[11px] text-text-tertiary hover:text-text-secondary font-body",children:"Reset"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F0("div",{className:"flex items-center gap-2",children:[F0("div",{className:"flex items-center bg-bg-base rounded-md p-0.5",children:[F0("button",{onClick:()=>F(!1),className:`px-2.5 py-1 rounded text-[11px] font-body font-medium transition-colors ${!w?"bg-bg-elevated text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,children:"Preview"},void 0,!1,void 0,this),F0("button",{onClick:()=>F(!0),className:`px-2.5 py-1 rounded text-[11px] font-body font-medium transition-colors ${w?"bg-bg-elevated text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,children:"Edit"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F0("button",{onClick:J,className:"text-text-tertiary hover:text-text-secondary w-7 h-7 flex items-center justify-center rounded-md hover:bg-border-subtle transition-colors",children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),w?F0("textarea",{ref:O,value:h,onChange:(v)=>{N(v.currentTarget.value),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):F0("div",{className:"flex-1 overflow-y-auto p-5",children:F0(B$,{text:h},void 0,!1,void 0,this)},void 0,!1,void 0,this),A.length>0&&F0("div",{className:"px-5 py-2 border-t border-border-subtle flex-shrink-0",children:F0("span",{className:"text-[12px] text-text-secondary font-body",children:["Reviewer feedback: ",X.size,"/",A.length," included"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),C&&F0("div",{className:"px-5 py-2 text-[12px] text-accent-red font-body border-t border-border-subtle flex-shrink-0 flex items-center justify-between gap-2",children:[F0("span",{children:C},void 0,!1,void 0,this),F0("button",{onClick:()=>{K(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),F0("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-border-subtle flex-shrink-0",children:[F0("button",{onClick:J,className:"px-4 py-2 rounded-lg text-[13px] font-body text-text-tertiary hover:text-text-secondary transition-colors",children:"Cancel"},void 0,!1,void 0,this),F0("button",{onClick:()=>{let v=o1(H,G);if(v.length>0){K(`Please answer: ${v.join(", ")}`);return}K(null),Q(h)},disabled:!I,className:`px-6 py-2 rounded-lg font-body text-[13px] font-medium transition-all ${I?"bg-btn-primary text-btn-primary-text hover:opacity-90":"bg-bg-input text-text-disabled cursor-default"}`,children:"Submit feedback"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var dJ=/!\[([^\]]*)\]\((\/tmp\/agent-canvas\/uploads\/([^)]+))\)/g;function iJ($){return $.replace(dJ,(J,Q,X,W)=>``)}function B$({text:$}){let J=z5(()=>s.parse(iJ($),{async:!1}),[$]);return F0("div",{className:"prose-canvas font-body text-body text-text-primary leading-relaxed",dangerouslySetInnerHTML:{__html:J}},void 0,!1,void 0,this)}import{jsxDEV as b,Fragment as N$}from"react/jsx-dev-runtime";function w$({onSubmit:$,collapseButton:J}){let{isReadOnly:Q,selectedRevision:X,currentRevision:W,revisions:q,agentWatching:Y}=S5($2),H=S5(rJ),G=q.find((M)=>M.revision===X),B=Q&&X===W,N=!!G?.feedbackConsumed,L=G?.label||`Round ${X}`;if(Q)return b(sJ,{sessionId:H,revision:X,label:L,waitingForUpdate:B,feedbackConsumed:N,agentWatching:Y,collapseButton:J},void 0,!1,void 0,this);return b(aJ,{onSubmit:$,agentWatching:Y,collapseButton:J},void 0,!1,void 0,this)}function oJ({sessionId:$,revision:J,label:Q,waitingForUpdate:X,feedbackConsumed:W,agentWatching:q,collapseButton:Y}){let G=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&&!G&&b(s4,{feedbackConsumed:W,agentWatching:q},void 0,!1,void 0,this),b(t4,{sessionId:$,revision:J},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function s4({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 sJ({sessionId:$,revision:J,label:Q,waitingForUpdate:X,feedbackConsumed:W,agentWatching:q,collapseButton:Y}){let{annotations:H,generalNote:G}=O1(),B=H.length>0||G.trim().length>0,[N,L]=Q2("feedback");if(!B)return b(oJ,{sessionId:$,revision:J,label:Q,waitingForUpdate:X,feedbackConsumed:W,agentWatching:q,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:H.length},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Y]},void 0,!0,void 0,this),X&&b(s4,{feedbackConsumed:W,agentWatching:q},void 0,!1,void 0,this),N==="feedback"?b(t4,{sessionId:$,revision:J},void 0,!1,void 0,this):b(N$,{children:[b("div",{className:"flex-1 overflow-y-auto",children:b(a4,{annotations:H,readOnly:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this),G.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:G},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function t4({sessionId:$,revision:J}){let Q=t0(),[X,W]=Q2(null),[q,Y]=Q2(!0);return o4(()=>{if(Y(!0),!Q.fsAvailable){W(null),Y(!1);return}fetch(`/api/session/${$}/revision/${J}/feedback`).then((H)=>H.json()).then((H)=>{W(k4.parse(H).feedback||null),Y(!1)}).catch(()=>{W(null),Y(!1)})},[$,J]),b("div",{className:"flex-1 overflow-y-auto px-4",children:q?b("p",{className:"text-[12px] text-text-tertiary font-body py-4",children:"Loading..."},void 0,!1,void 0,this):X?b(B$,{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 tJ($){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 H=M1(Y);if(!H)continue;let G=W[H];if(G)G.push(Y);else W[H]=[Y]}let q=[J,Q,X].filter((Y)=>Y.length>0).length>1;return{response:J,plan:Q,fileGroups:W,hasMultipleGroups:q}}function n4({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 a4({annotations:$,readOnly:J,includedRemoteIds:Q,onToggleRemoteId:X}){let{setActiveView:W}=S5(e1),{response:q,plan:Y,fileGroups:H,hasMultipleGroups:G}=tJ($),B=O5((M)=>{let w=M1(M);if(!w)return;W({type:"file",path:w}),setTimeout(()=>{let F=C2(M);if(F)F.scrollIntoView({behavior:"smooth",block:"center"})},150)},[W]),N=O5((M)=>q5(M,W),[W]),L={readOnly:J,onSelect:B,onReveal:N,includedRemoteIds:Q,onToggleRemoteId:X};return b(N$,{children:[q.length>0&&b(N$,{children:[G&&b(n4,{children:"Agent Response"},void 0,!1,void 0,this),b(O2,{annotations:q,...L},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y.length>0&&b(N$,{children:[G&&b(n4,{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(H).map(([M,w])=>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(G5,{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:w,...L},void 0,!1,void 0,this)]},M,!0,void 0,this))]},void 0,!0,void 0,this)}function aJ({onSubmit:$,agentWatching:J,collapseButton:Q}){let X=t0(),[W,q]=Q2(!1),{annotations:Y,generalNote:H,submittableResponses:G,feedbackEntries:B}=O1(),N=nJ(()=>Y.filter((A)=>A.source==="remote"),[Y]),[L,M]=Q2(()=>new Set);o4(()=>{if(N.length===0)return;M((A)=>{let Z=new Set(A);for(let h of N)Z.add(h.id);return Z.size===A.size?A:Z})},[N]);let w=O5((A)=>{M((Z)=>{let h=new Set(Z);if(h.has(A))h.delete(A);else h.add(A);return h})},[]),F=Array.from(G.values()).some(e2),C=B.size>0,K=Y.length>0||H.trim().length>0||F||C,[O,S]=Q2(null),f=()=>{let A=n1(Y,H,G,B,L);$(A)};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(a4,{annotations:Y,includedRemoteIds:L,onToggleRemoteId:w},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b(l$,{hasContent:K,onSubmit:()=>{let A=o1(G,B);if(A.length>0){S(`Please answer: ${A.join(", ")}`);return}S(null),f()},onSubmitEmpty:()=>$("No feedback — looks good."),notice:O&&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:O},void 0,!1,void 0,this),b("button",{onClick:()=>{S(null),f()},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:()=>q(!0),className:"flex-1 py-2 rounded-lg font-body text-[13px] font-medium transition-all bg-border-subtle text-text-secondary hover:bg-border-medium hover:text-text-primary",children:"Preview"},void 0,!1,void 0,this)},void 0,!1,void 0,this),b(_5,{open:W,onClose:()=>q(!1),onSubmit:$,includedRemoteIds:L,onToggleRemoteId:w},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useFeedback as sG}from"#canvas/runtime";import _Y from"react";import{jsxDEV as SY}from"react/jsx-dev-runtime";s.setOptions({gfm:!0,breaks:!1});import{jsxDEV as kY}from"react/jsx-dev-runtime";import{jsxDEV as VY}from"react/jsx-dev-runtime";import{useAnnotations as yY,useResponseRegistration as EY}from"#canvas/runtime";import{useEffect as hY,useMemo as vY,useRef as mY,useState as cY}from"react";import{jsxDEV as bY}from"react/jsx-dev-runtime";import{jsxDEV as lY}from"react/jsx-dev-runtime";import{useEffect as oY,useRef as sY}from"react";import{jsxDEV as eY}from"react/jsx-dev-runtime";import{jsxDEV as Yq}from"react/jsx-dev-runtime";import{ActiveViewCtx as Hq,SessionContext as Uq}from"#canvas/runtime";import{useContext as Nq,useEffect as wq,useRef as Fq,useState as Lq}from"react";import{jsxDEV as zq}from"react/jsx-dev-runtime";import{SessionContext as Sq}from"#canvas/runtime";import{useContext as Cq,useState as Pq}from"react";import{jsxDEV as Aq}from"react/jsx-dev-runtime";import{useMemo as Dq}from"react";import{jsxDEV as gq}from"react/jsx-dev-runtime";s.setOptions({gfm:!0,breaks:!1});import{useAnnotations as xq,useCanvasFile as hq}from"#canvas/runtime";import{useCallback as uq,useEffect as pq,useRef as lq,useState as dq}from"react";import rq from"react-dom";import{jsxDEV as sq,Fragment as tq}from"react/jsx-dev-runtime";import{jsxDEV as JG}from"react/jsx-dev-runtime";import{jsxDEV as WG}from"react/jsx-dev-runtime";import{useState as HG}from"react";import{jsxDEV as NG}from"react/jsx-dev-runtime";import{jsxDEV as LG}from"react/jsx-dev-runtime";import{jsxDEV as zG}from"react/jsx-dev-runtime";import{useAnnotations as SG,useResponseRegistration as RG}from"#canvas/runtime";import{useRef as kG,useState as AG}from"react";import{jsxDEV as TG}from"react/jsx-dev-runtime";import{CanvasFileCtx as Q9,SessionContext as X9}from"#canvas/runtime";import F$,{useContext as $3,useEffect as H1,useMemo as T2,useRef as W9,useState as l0}from"react";import{createPortal as Y9}from"react-dom";import{createContext as J9}from"react";var C5=J9(()=>{});import{jsxDEV as W0,Fragment as U9}from"react/jsx-dev-runtime";class J3 extends F$.Component{state={error:null};static getDerivedStateFromError($){return{error:$}}componentDidCatch($,J){this.props.reportError({revision:this.props.revision,filename:this.props.filename,message:$.message,...$.stack?{stack:$.stack}:{},...J.componentStack?{componentStack:J.componentStack}:{}})}render(){if(!this.state.error)return this.props.children;return W0(Q3,{message:this.state.error.message},void 0,!1,void 0,this)}}function Q3({message:$}){return W0("div",{className:"bg-accent-red-muted rounded-lg p-5",children:[W0("h3",{className:"font-body font-semibold text-accent-red mb-2",children:"Canvas render failed"},void 0,!1,void 0,this),W0("pre",{className:"text-code font-mono text-text-secondary whitespace-pre-wrap",children:$},void 0,!1,void 0,this),W0("p",{className:"text-meta font-body text-text-tertiary mt-3",children:"The error was sent back to the canvas author."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function L$({revision:$,filename:J}){let Q=$3(X9),X=t0(),W=$3(C5),[q,Y]=l0(null),[H,G]=l0(null),[B,N]=l0(!0),L=W9(null),{annotations:M,addAnnotationWithId:w,removeAnnotation:F,updateAnnotation:C,addAnnotationImage:K,removeAnnotationImage:O,activeAnnotationId:S,setActiveAnnotationId:f,registerCanvasRendered:A}=O1(),Z=T2(()=>M.filter((z)=>!z.filePath&&(!z.canvasFile||z.canvasFile===J)),[M,J]),[h,I]=l0(null),[v,u]=l0(null),[m,e]=l0(null),[X0,q0]=l0(null),[z0,c]=l0(!1);H1(()=>{N(!0),G(null),q0(null),X.loadCanvasModule(J,$).then((z)=>{Y(()=>z.default),N(!1)}).catch((z)=>{let j=z instanceof Error?z:Error(String(z));G(j.message),N(!1),W({revision:$,filename:J,message:j.message,...j.stack?{stack:j.stack}:{}})})},[Q,$,J,W]),H1(()=>{if(q)A(J)},[q,J,A]);let $0=document.getElementById("plan-scroll-container"),{popovers:J0,isPopoverOpen:G0}=e$({containerRef:L,restoreKey:q,restoreAnnotations:Z,extractContext:(z)=>T$(z,L.current),canvasFile:J,scrollContainer:$0}),{popovers:a,isDrawing:Q0,isPopoverOpen:B0}=t$({containerRef:L,restoreKey:q,canvasFile:J,scrollContainer:$0}),k=G0||B0,g=T2(()=>{let z=new Map;for(let j of Z)if(j.snippet.startsWith("["))z.set(j.snippet,j.id);return z},[Z]);H1(()=>{let z=L.current;if(!z)return;let j=(T)=>{if(m||k||Q0)return;let E=T.target;if(E.closest("[data-block-comment-btn]"))return;c(!1);let d=E.closest(T1);if(d&&z.contains(d)){let j0=k1(z).indexOf(d);q0(j0>=0?j0:null)}else q0(null);let H0=E.closest(e0);if(H0&&z.contains(H0)){u(H0);let M0=v0(H0),j0=M0?g.get(M0):void 0;if(j0&&j0!==S)f(j0)}else u(null)},n=(T)=>{if(m||k)return;if(T.relatedTarget?.closest("[data-block-comment-btn]"))return;u(null),f(null)};return z.addEventListener("mousemove",j),z.addEventListener("mouseleave",n),()=>{z.removeEventListener("mousemove",j),z.removeEventListener("mouseleave",n)}},[q,m,k,Q0,g,S]),H1(()=>{let z=(j)=>{let n=j.target.tagName;if(n==="INPUT"||n==="TEXTAREA"||j.target.isContentEditable)return;if(m||k)return;let T=L.current;if(!T)return;if(j.key==="ArrowDown"){j.preventDefault(),c(!0);let E=k1(T);if(E.length===0)return;q0((d)=>{if(d===null)return 0;return Math.min(d+1,E.length-1)})}else if(j.key==="ArrowUp"){j.preventDefault(),c(!0);let E=k1(T);if(E.length===0)return;q0((d)=>{if(d===null)return E.length-1;return Math.max(d-1,0)})}else if(j.key==="a"||j.key==="A"){if(X0===null||!T)return;let d=k1(T)[X0];if(!d)return;if(!d.matches(e0))return;j.preventDefault();let H0=v0(d);if(!H0)return;let M0=g.get(H0);if(M0)f(M0),e({anchorEl:d,snippet:H0,annId:M0});else e({anchorEl:d,snippet:H0})}else if(j.key===" "||j.key==="Enter"){if(X0===null)return;let d=k1(T)[X0];if(!d)return;let H0=d.getAttribute("data-md");if(H0==="choice-option"||H0==="multichoice-option")j.preventDefault(),d.dispatchEvent(new CustomEvent("kb-select",{bubbles:!0}));else if(H0==="userinput"){j.preventDefault();let M0=d.querySelector("textarea");if(M0){M0.focus();let j0=(U1)=>{if(U1.key==="Escape")U1.preventDefault(),M0.blur(),c(!0)};M0.addEventListener("keydown",j0),M0.addEventListener("blur",()=>M0.removeEventListener("keydown",j0),{once:!0})}}else if(H0==="rangeinput"){j.preventDefault();let M0=d.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(),c(!0)};M0.addEventListener("keydown",j0),M0.addEventListener("blur",()=>M0.removeEventListener("keydown",j0),{once:!0})}}}else if(j.key==="Escape")q0(null),c(!1),f(null)};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[X0,m,k,g]),H1(()=>{let z=L.current;if(!z||X0===null||!z0)return;let n=k1(z)[X0];if(!n)return;n.style.outline="2px solid var(--color-accent-blue)",n.style.outlineOffset="-2px",n.style.borderRadius="8px",n.scrollIntoView({block:"nearest",behavior:"smooth"});let T=v0(n),E=T?g.get(T):void 0;if(E)f(E);return()=>{n.style.outline="",n.style.outlineOffset="",n.style.borderRadius=""}},[X0,z0,g]);let l=T2(()=>q?W0(q,{},void 0,!1,void 0,this):null,[q]);if(B)return W0("div",{className:"flex items-center justify-center h-64 text-text-tertiary font-body text-body",children:"Loading canvas..."},void 0,!1,void 0,this);if(H)return W0(Q3,{message:H},void 0,!1,void 0,this);if(!q)return W0("div",{className:"text-text-tertiary text-center py-8 font-body text-body",children:"No canvas loaded"},void 0,!1,void 0,this);return W0(Q9.Provider,{value:J,children:[W0("div",{ref:L,className:"plan-content plan-updated","data-canvas-file":J,children:W0(J3,{revision:$,filename:J,reportError:W,children:l},`${$}:${J}`,!1,void 0,this)},void 0,!1,void 0,this),h&&W0(H9,{note:h.note,onSave:(z)=>{C(h.id,z),I(null)},onCancel:()=>I(null)},void 0,!1,void 0,this),J0,a,W0(q9,{containerRef:L,hoveredBlock:v,focusedBlockIndex:X0,blockPopover:m,blockAnnotationMap:g,activeAnnotationId:S,onOpen:(z,j,n)=>{if(n)f(n),e({anchorEl:z,snippet:j,annId:n});else e({anchorEl:z,snippet:j})}},void 0,!1,void 0,this),m&&!m.annId&&W0(G1,{anchorEl:m.anchorEl,scrollContainer:$0,snippet:m.snippet,truncateAt:80,onAdd:(z,j)=>{let n=o0();w(n,m.snippet,z,void 0,void 0,j,J),e(null)},onCancel:()=>e(null)},void 0,!1,void 0,this),m?.annId&&(()=>{let z=Z.find((j)=>j.id===m.annId);if(!z)return null;return W0(R2,{anchorEl:m.anchorEl,scrollContainer:$0,initialNote:z.note,initialImages:z.images,onUpdate:(j,n)=>{C(m.annId,j);let T=z.images||[];for(let E of n)if(!T.includes(E))K(m.annId,E);for(let E of T)if(!n.includes(E))O(m.annId,E)},onDelete:()=>{F(m.annId),f(null),e(null)},onClose:()=>e(null)},void 0,!1,void 0,this)})()]},void 0,!0,void 0,this)}function k1($){return Array.from($.querySelectorAll(T1))}function q9({containerRef:$,hoveredBlock:J,focusedBlockIndex:Q,blockPopover:X,blockAnnotationMap:W,activeAnnotationId:q,onOpen:Y}){let[H,G]=l0([]);H1(()=>{let w=$.current;if(!w||W.size===0){G([]);return}let F=[];for(let C of w.querySelectorAll(e0)){let K=v0(C);if(K&&W.has(K))F.push(C)}G(F)},[W,$.current]);let[B,N]=l0(null);H1(()=>{if(!q||!$.current){N(null);return}for(let w of $.current.querySelectorAll(T1)){let F=v0(w);if(F&&W.get(F)===q){N(w);return}}N(null)},[q,W]),H1(()=>{if(!B)return;return B.style.boxShadow="inset 0 0 0 1.5px var(--color-highlight-bg)",B.style.borderRadius="8px",()=>{B.style.boxShadow="",B.style.borderRadius=""}},[B]);let L=T2(()=>{if(Q===null||!$.current)return null;let w=k1($.current)[Q];if(!w)return null;return w.matches(e0)?w:null},[Q,$.current]),M=T2(()=>{let w=new Set(H);if(J)w.add(J);if(L)w.add(L);if(X?.anchorEl)w.add(X.anchorEl);return Array.from(w)},[H,J,L,X]);return W0(U9,{children:M.map((w)=>W0(G9,{block:w,isHovered:w===J||w===L||w===X?.anchorEl,blockAnnotationMap:W,activeAnnotationId:q,onOpen:Y},w.getAttribute("data-task-id")||w.getAttribute("data-md-title")||w.textContent?.slice(0,30)||"block",!1,void 0,this))},void 0,!1,void 0,this)}function G9({block:$,isHovered:J,blockAnnotationMap:Q,activeAnnotationId:X,onOpen:W}){let q=v0($);if(!q)return null;let Y=Q.get(q),H=!!Y;return Y9(W0("button",{"data-block-comment-btn":!0,onClick:(B)=>{B.stopPropagation(),W(B.currentTarget,q,Y)},className:`absolute top-1 right-1 z-10 w-6 h-6 flex items-center justify-center rounded transition-all duration-150 ${H?Y===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:H?"Edit annotation":"Add annotation",children:W0("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:H?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:W0("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),$)}function H9({note:$,onSave:J,onCancel:Q}){let[X,W]=F$.useState($),q=F$.useRef(null);return F$.useEffect(()=>{q.current?.focus(),q.current?.select()},[]),W0("div",{className:"fixed inset-0 z-50 bg-black/40 flex items-center justify-center",onClick:Q,children:W0("div",{className:"bg-bg-elevated border border-border-hover rounded-lg shadow-md p-4 w-80",onClick:(Y)=>Y.stopPropagation(),children:[W0("div",{className:"text-tiny uppercase tracking-widest text-text-tertiary font-body mb-2",children:"Edit annotation"},void 0,!1,void 0,this),W0("textarea",{ref:q,value: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),W0("div",{className:"flex justify-end gap-2 mt-2",children:[W0("button",{onClick:Q,className:"text-meta text-text-tertiary font-body px-3 py-1",children:"Cancel"},void 0,!1,void 0,this),W0("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 k5}from"react/jsx-dev-runtime";function X3({gateName:$,hasGate:J,isCurrentGate:Q,onSubmit:X}){let[W,q]=M9(!0);if(!W)return C0("button",{onClick:()=>q(!0),className:"flex w-9 flex-col items-center gap-2 border-l border-border-subtle bg-bg-surface py-3 text-text-tertiary hover:text-text-secondary",title:"Open review panel",children:C0("span",{className:"[writing-mode:vertical-rl] text-tiny uppercase tracking-wide",children:"review"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Y=C0("button",{onClick:()=>q(!1),className:"text-text-tertiary hover:text-text-secondary",title:"Collapse",children:C0("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:C0("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);return C0("aside",{className:"flex h-full w-72 flex-col border-l border-border-subtle bg-bg-surface",children:J?C0(w$,{onSubmit:X,collapseButton:Y},void 0,!1,void 0,this):C0(k5,{children:[C0("div",{className:"flex items-center justify-between border-b border-border-subtle px-4 py-3",children:[C0("div",{className:"text-tiny uppercase tracking-wide text-text-tertiary",children:"review & annotate"},void 0,!1,void 0,this),Y]},void 0,!0,void 0,this),C0("div",{className:"flex-1 px-4 py-6 text-center text-tiny text-text-tertiary",children:Q&&$?C0(k5,{children:["gate ",C0("span",{className:"font-mono",children:$},void 0,!1,void 0,this)," open — connect to a live daemon to review the pushed canvas."]},void 0,!0,void 0,this):$?C0(k5,{children:["this phase's ",C0("span",{className:"font-mono",children:$},void 0,!1,void 0,this)," gate opens once the earlier phases are approved."]},void 0,!0,void 0,this):"no gate on this phase — nothing to review here."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{useEffect as f9,useState as A5}from"react";import{jsxDEV as i}from"react/jsx-dev-runtime";var X2="rounded border border-border-medium px-3 py-1 text-tiny disabled:opacity-40",W3="rounded border border-border-medium bg-bg-base px-2 py-1 text-body text-text-primary";function Y3({platform:$,live:J}){let[Q,X]=A5(""),[W,q]=A5(null),[Y,H]=A5(null),{data:G,enabled:B,busy:N,error:L}=$,M=G?.connection;f9(()=>{if(M)H(M.controlOrigin)},[M?.controlOrigin]);let w=G?.pairing,F=G?.deployment,C=F?.status==="preparing"||F?.status==="pending"||F?.status==="running",K=w?.status==="pending"||w?.status==="approved",O=G?.credential.available&&(G.credential.expiresAt===null||G.credential.expiresAt*1000>Date.now());return i("details",{className:"shrink-0 border-b border-border-subtle bg-bg-surface px-6 py-2",open:!0,children:[i("summary",{className:"cursor-pointer font-heading text-section",children:"Deployment"},void 0,!1,void 0,this),i("div",{className:"max-h-64 space-y-3 overflow-y-auto py-3 text-body","aria-busy":N,children:[!J&&i("p",{className:"text-text-tertiary",children:"Offline / demo mode — deployment controls are disabled."},void 0,!1,void 0,this),J&&!G&&!L&&i("p",{role:"status",children:"Loading project status…"},void 0,!1,void 0,this),L&&i("p",{role:"alert",className:"text-accent-red",children:L},void 0,!1,void 0,this),M?i("div",{className:"space-y-1",children:[i("p",{children:["App ",i("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),i("p",{className:"text-text-secondary",children:["Control: ",M.controlOrigin]},void 0,!0,void 0,this),i("p",{children:["Local credential: ",O?"available":"unavailable or expired",G?.credential.expiresAt!=null&&` · expires ${new Date(G.credential.expiresAt*1000).toLocaleString()}`]},void 0,!0,void 0,this),i("a",{className:"text-accent-blue underline",href: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):i("p",{className:"text-text-secondary",children:"No platform connection."},void 0,!1,void 0,this),!M&&Y&&i("a",{className:"text-accent-blue underline",href:Y,target:"_blank",rel:"noreferrer",children:"Open console to revoke server access"},void 0,!1,void 0,this),i("form",{className:"flex flex-wrap items-center gap-2",onSubmit:(S)=>{S.preventDefault(),$.act({kind:"connect",controlOrigin:Q})},children:[i("label",{htmlFor:"control-origin",children:"Control origin"},void 0,!1,void 0,this),i("input",{className:W3,id:"control-origin",type:"url",value:Q,onChange:(S)=>X(S.currentTarget.value),placeholder:"https://control.example.com",disabled:!B||!!M||K,required:!0},void 0,!1,void 0,this),i("button",{className:X2,type:"submit",disabled:!B||!!M||K,children:N?"Working…":"Connect"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w?.status==="pending"&&B&&w.expiresAt*1000>Date.now()&&i("a",{className:"text-accent-blue underline",href:w.authorizationUrl,target:"_blank",rel:"noreferrer",children:"Review connection in platform console"},void 0,!1,void 0,this),w&&i("p",{role:"status",children:["Connection: ",w.status,(w.status==="failed"||w.status==="recovery_required")&&` — ${w.message}`]},void 0,!0,void 0,this),i("div",{className:"flex flex-wrap items-center gap-2",children:[i("button",{className:X2,type:"button",disabled:!B||!M&&!w,onClick:()=>void $.act({kind:"disconnect"}),children:"Disconnect locally"},void 0,!1,void 0,this),i("span",{className:"text-tiny text-text-tertiary",children:"Deletes local credentials only. Revoke server access in the console."},void 0,!1,void 0,this),i("button",{className:X2,type:"button",disabled:!B||!M||!O||C||K,onClick:()=>void $.act({kind:"deploy"}),children:C?"Deploy in progress…":"Deploy pushed commit"},void 0,!1,void 0,this),i("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),F&&i("div",{role:"status",className:"space-y-1",children:[i("p",{children:["Deployment: ",i("strong",{children:F.status},void 0,!1,void 0,this),F.message&&` — ${F.message}`]},void 0,!0,void 0,this),F.runId&&i("p",{children:["Run: ",i("code",{children:F.runId},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F.commitSha&&i("p",{children:["Commit: ",i("code",{children:F.commitSha},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F.consoleUrl&&i("a",{className:"mr-4 text-accent-blue underline",href:F.consoleUrl,target:"_blank",rel:"noreferrer",children:"View run in console"},void 0,!1,void 0,this),F.appUrl&&i("a",{className:"text-accent-blue underline",href:F.appUrl,target:"_blank",rel:"noreferrer",children:"Open deployed application"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("form",{className:"flex flex-wrap items-center gap-2",onSubmit:(S)=>{S.preventDefault(),$.act({kind:"preview",url:W??G?.previewUrl??""})},children:[i("label",{htmlFor:"preview-url",children:"Local preview URL"},void 0,!1,void 0,this),i("input",{className:W3,id:"preview-url",type:"url",value:W??G?.previewUrl??"",onChange:(S)=>q(S.currentTarget.value),placeholder:G?.previewUrl??"http://localhost:3000",disabled:!B,required:!0},void 0,!1,void 0,this),i("button",{className:X2,type:"submit",disabled:!B,children:"Set preview"},void 0,!1,void 0,this),i("button",{className:X2,type:"button",disabled:!B||!G?.previewUrl,onClick:()=>{q(null),$.act({kind:"preview",url:null})},children:"Clear preview"},void 0,!1,void 0,this),i("span",{className:"text-tiny text-text-tertiary",children:[G?.previewUrl??"No local preview configured."," · Separate from the deployed application."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as a0}from"react/jsx-dev-runtime";var K9={connecting:"connecting…",live:"live",offline:"offline",fixture:"fixture"},z9={connecting:"bg-accent-amber",live:"bg-accent-green",offline:"bg-accent-red",fixture:"bg-accent-blue"};function q3({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 ${z9[J]}`},void 0,!1,void 0,this),K9[J]]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var M$=["intake","vision","flows","tech","design","skeletons","issues","build"],_9={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"]}},f$=M$.map(($,J)=>({id:$,number:J+1,..._9[$]})),K$=f$.length;function O9($){return M$.indexOf($)}function G3($){let J=f$[O9($)];if(!J)throw Error(`Unknown phase id: ${$}`);return J}function Z2($,J,Q){if(J.includes($))return"done";if($===Q)return"current";return"upcoming"}import{jsxDEV as U0}from"react/jsx-dev-runtime";function S9({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 H3({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:f$.map((X)=>{let W=Z2(X.id,$.completed,$.current),q=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",q?"bg-bg-elevated":"hover:bg-bg-elevated-half",Y?"cursor-pointer":"cursor-not-allowed opacity-55"].join(" "),children:[U0("div",{className:"mt-0.5 shrink-0",children:U0(S9,{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 w7,useState as I3}from"react";var GU=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"}),HU=Object.freeze({APP:"app",ENVIRONMENT:"environment"});function R9($){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 U3=U.string().transform(($,J)=>{let Q=R9($);if(Q!==null)return Q;return J.addIssue({code:"custom",message:"invalid builder public origin"}),U.NEVER}),NU=U.preprocess(($)=>{if(typeof $==="object"&&$!==null&&Object.keys($).length!==4)return;return $},U.object({version:U.literal(1),controlOrigin:U3,iamIssuer:U3,provider:U.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/)}).strict());var C9=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;var P9=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;var j5=U.number().int().safe().nonnegative(),V5=U.string().regex(P9),k9=U.object({id:V5,repoUrl:U.string(),defaultBranch:U.string(),workerDir:U.string().nullable(),buildCmd:U.string().nullable(),configPath:U.string().nullable(),githubConnectionId:U.string().nullable().optional(),githubInstallationId:j5.nullable(),createdAt:j5}).strict().transform(({githubConnectionId:$,githubInstallationId:J,createdAt:Q,...X})=>({...X,...$===void 0?{}:{githubConnectionId:$},githubInstallationId:J,createdAt:Q})),A9=U.object({env:V5,namespaceId:U.string().min(1).max(128).nullable(),domain:U.string().min(1).max(253).nullable(),publicOrigin:U.string().min(1).max(2048).nullable(),triggerRef:U.string().min(1).max(1024).nullable()}).strict(),B3=U.object({version:U.literal(1),attemptId:U.string().regex(C9),provider:V5,app:k9,environment:A9,createdAt:j5}).strict();var j9=100,V9=512,fU=U.object({cursor:U.string().min(1).max(V9).optional(),limit:U.number().int().safe().min(1).max(j9).optional()}).strict().transform(({cursor:$,limit:J})=>({...$===void 0?{}:{cursor:$},...J===void 0?{}:{limit:J}}));var z$="FABRIKA_IAM_APP_ID";var T9=/%2f|%5c/i,Z9=/%2e/gi;function T5($){if($==="/")return!0;if(!$.startsWith("/")||$.includes("\\")||T9.test($))return!1;let J=$.slice(1).split("/"),Q=J.length-1;return J.every((X,W)=>(X!==""||W===Q)&&!b9(X)&&D9(X))}function D9($){try{return decodeURIComponent($),!0}catch{return!1}}function b9($){let J=$.replace(Z9,".");return J==="."||J===".."}var g9=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),I9=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function d0($,J){return $>>>J|$<<32-J}function W2($){let J=new TextEncoder().encode($),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 q=new Uint32Array(I9),Y=new Uint32Array(64);for(let H=0;H<Q.length;H+=64){for(let O=0;O<16;O++)Y[O]=X.getUint32(H+O*4);for(let O=16;O<64;O++){let S=Y[O-15]??0,f=Y[O-2]??0,A=d0(S,7)^d0(S,18)^S>>>3,Z=d0(f,17)^d0(f,19)^f>>>10;Y[O]=(Y[O-16]??0)+A+(Y[O-7]??0)+Z}let[G=0,B=0,N=0,L=0,M=0,w=0,F=0,C=0]=q;for(let O=0;O<64;O++){let S=d0(M,6)^d0(M,11)^d0(M,25),f=M&w^~M&F,A=C+S+f+(g9[O]??0)+(Y[O]??0)>>>0,Z=d0(G,2)^d0(G,13)^d0(G,22),h=G&B^G&N^B&N,I=Z+h>>>0;C=F,F=w,w=M,M=L+A>>>0,L=N,N=B,B=G,G=A+I>>>0}let K=[G,B,N,L,M,w,F,C];for(let[O,S]of K.entries())q[O]=(q[O]??0)+S}return Array.from(q,(H)=>H.toString(16).padStart(8,"0")).join("")}var Z5="FABRIKA_CONTRACT_DIGEST";var w3="*";class y9{#$;#J;constructor($,J){this.#$=$,this.#J=J}plan($,J){return E9(this.#$,this.#J,$,J)}}function E9($,J,Q,X){if(!T5(X))return{outcome:"non-canonical"};let W=h9(X),q=v9(X,J),Y=null,H=!1;for(let G of $){if(!x9(G.row.method,Q)||q!==null&&!L3(G.row.path,q))continue;let B=m9(G.segments,W);if(B===null)continue;let N=Y===null?-1:c9(G.segments,Y.endpoint.segments);if(N<0)Y={endpoint:G,params:B},H=!1;else if(N===0)H=!0}if(Y===null||H)return{outcome:"no-endpoint"};return{outcome:"endpoint",endpoint:Y.endpoint.row,params:Y.params}}function x9($,J){return $===w3||$===J}function h9($){return $==="/"?[]:$.slice(1).split("/")}function L3($,J){return $.startsWith(`${J}/`)}function v9($,J){let Q=null;for(let X of J)if(L3($,X)&&(Q===null||X.length>Q.length))Q=X;return Q}function m9($,J){let Q=[];for(let[X,W]of $.entries()){if(W.kind==="wildcard")return X===0||J.length>X?Object.fromEntries(Q):null;let q=J[X];if(q===void 0)return null;if(W.kind==="param"){if(q==="")return null;Q.push([W.name,q])}else if(W.value!==q)return null}return $.length===J.length?Object.fromEntries(Q):null}var F3={literal:0,param:1,wildcard:2};function c9($,J){let Q=Math.min($.length,J.length);for(let X=0;X<Q;X++){let W=$[X],q=J[X];if(W===void 0||q===void 0)break;let Y=F3[W.kind]-F3[q.kind];if(Y!==0)return Y}return $.length-J.length}var _$="FABRIKA_IAM_ISSUER";var O$="FABRIKA_PROXY_SECRET";var u9="FABRIKA_SOURCE_MAP_UPLOAD",p9="FABRIKA_SOURCE_MAP_UPLOAD_KEY",D5="FABRIKA_TOKEN_KEYS",b5="FABRIKA_APP_ORIGIN",g5="FABRIKA_OPS_KEY_DIGESTS",I5="FABRIKA_EGRESS_REFUSED_HOSTS",l9="FABRIKA_APPLICATION_OBJECT",d9="FABRIKA_APPLICATION_OBJECTS",i9=["FABRIKA_RELEASE",Z5,_$,z$,"FABRIKA_OPERATIONS_DSN","FABRIKA_APP_ID","FABRIKA_ENVIRONMENT","FABRIKA_SERVICE_KEY","FABRIKA_APP_DATABASE_URL","FABRIKA_APP_RUNTIME_DATABASE_URL","FABRIKA_APP_DATABASE_CONNECTIONS","FABRIKA_APP_STORAGE_ENDPOINT","FABRIKA_APP_STORAGE_BUCKET","FABRIKA_APP_STORAGE_ACCESS_KEY_ID","FABRIKA_APP_STORAGE_SECRET_ACCESS_KEY","FABRIKA_STORAGE_PROVENANCE",O$,"FABRIKA_IAM_RPC_URL","FABRIKA_IAM_RPC_KEY",u9,p9,D5,b5,g5,I5,l9,d9];var sU=new Set(i9);function r9($){return $.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()}var y5=["mail","source"];function E5($){let J=`FABRIKA_PLATFORM_${r9($)}`;return{url:`${J}_URL`,key:`${J}_KEY`}}var tU=new Set(y5.flatMap(($)=>Object.values(E5($))));var n9=["FABRIKA_RELEASE","FABRIKA_OPERATIONS_DSN",_$,z$,"FABRIKA_APP_ID","FABRIKA_ENVIRONMENT","FABRIKA_SERVICE_KEY",O$,"FABRIKA_IAM_RPC_URL","FABRIKA_IAM_RPC_KEY",b5,D5,g5,I5],wB=new Set(n9);var FB=new Set(y5.map(($)=>E5($).url));var o9="/__fabrika/ops/";var AB=`${o9}*`;var s9=100,jB=(s9-2)/2;var VB=W2("");var TB=-(2n**63n),ZB=2n**63n-1n;var t9="__Host-px_",YN=`${t9}session`;var M3=100,V0=U.string().min(1),a9=U.enum(["open","read-only","closed","inspect"]),e9=U.object({appId:V0,env:V0,before:V0.optional(),limit:U.number().int().min(1).max(M3).optional()}).strict(),$7=U.discriminatedUnion("kind",[U.object({appId:V0,env:V0,kind:U.literal("maintenance"),mode:a9}).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()]),J7=U.object({appId:V0,env:V0,operationId:V0,resolution:U.enum(["resume","open"])}).strict();var iN=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(),q=Q.hostname!=="127.0.0.1"||/^127\.0\.0\.1(?::\d+)?$/.test(W);if(Q.protocol!=="https:"&&(!X||!q))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),K3=U.enum(M$),Q7=U.object({current:K3,index:k0,completed:U.array(K3),reads:U.array(U.string()),produces:U.array(U.string()),gate:U.boolean(),satisfied:U.boolean()}),z3=Q7.extend({gateName:U.string().nullable().optional().catch(void 0)}).transform(({gateName:$,...J})=>({...J,...$===void 0?{}:{gateName:$}})),Bw=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:q})=>({ok:$,...J===void 0?{}:{version:J},...Q===void 0?{}:{pid:Q},...X===void 0?{}:{dataDir:X},sessionsDir:W,...q===void 0?{}:{sessions:q}})),_3=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}})),Nw=U.object({ok:U.literal(!0),sessionsDir:U.string()}),O3=U.object({error:U.object({code:U.literal("builder_platform"),message:U.string().max(1000)})}),ww=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:q,error:Y,errors:H})=>({ok:$,...J===void 0?{}:{browserUrl:J},...Q===void 0?{}:{revision:Q},...X===void 0?{}:{isNew:X},...W===void 0?{}:{canvasFiles:W},...q===void 0?{}:{gate:q},...Y===void 0?{}:{error:Y},...H===void 0?{}:{errors:H}})),S3=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}})),Fw=U.object({view:L0,directory:L0,projectRoot:L0,gate:L0,label:L0,response:L0}),R3=U.object({feedback:U.string().catch("")}),Lw=R3.extend({found:U.literal(!0)}),Mw=R3.extend({type:U.literal("submit")}),C3=U.object({revision:k0,hasFeedback:U.unknown().transform(($)=>$===!0),feedbackConsumed:U.unknown().transform(($)=>$===!0)}),fw=U.object({revisions:U.array(C3.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null))}),X7=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),S$=U.array(X7.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null)).catch([]),W7=U.discriminatedUnion("kind",[U.object({kind:U.literal("directory")}),U.object({kind:U.literal("view"),filename:U.string()})]),Y7=C3.extend({label:U.string().nullable().catch(null),canvasFiles:S$,createdAt:L0,canvasScope:W7.optional().catch(void 0)}).transform(({createdAt:$,canvasScope:J,...Q})=>({...Q,...$===void 0?{}:{createdAt:$},...J===void 0?{}:{canvasScope:J}})).refine(($)=>$.revision>0),P3=U.object({projectRoot:L0,label:L0,gate:U.string().nullable().catch(null),currentRevision:k0.catch(0),canvasFiles:S$,revisions:U.array(Y7.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}})),k3=U.array(q7.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null)).catch([]),G7=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}})),A3=U.object({skeletons:U.array(G7.nullable().catch(null)).transform(($)=>$.filter((J)=>J!==null))}),j3=U.object({content:U.string()}),V3=U.object({responses:U.unknown()}),T3=U.discriminatedUnion("type",[U.object({type:U.literal("plan-updated"),currentRevision:k0,canvasFiles:U.array(U.unknown()).transform(($)=>S$.parse($)).optional().catch(void 0),gate:U.string().nullable().optional().catch(void 0)}),U.object({type:U.literal("revision-updated"),currentRevision:k0}),U.object({type:U.literal("watcher-status"),watching:U.boolean()}),U.object({type:U.literal("phase-updated")}),U.object({type:U.literal("submit-ack"),revision:k0})]).transform(($)=>{if($.type!=="plan-updated")return $;let{canvasFiles:J,gate:Q,...X}=$;return{...X,...J===void 0?{}:{canvasFiles:J},...Q===void 0?{}:{gate:Q}}}),T0=U.string().refine(($)=>$.trim().length>0),Z3=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}}),q2=U.string().transform(($,J)=>{try{return D2($)}catch{return J.addIssue({code:U.ZodIssueCode.custom,message:"Invalid preview URL"}),U.NEVER}}),D3=U.object({controlOrigin:x5,iamIssuer:x5,receipt:B3}).strict(),Kw=U.object({profile:T0,sessionId:T0,createdAt:T0.refine(($)=>Number.isFinite(Date.parse($))),connection:D3.optional(),previewUrl:q2.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"})}),H7=U.discriminatedUnion("status",[U.object({status:U.literal("pending"),authorizationUrl:q2.refine(($)=>{try{return Y2(new URL($).origin),!0}catch{return!1}}),expiresAt:Z3}).strict(),U.object({status:U.literal("approved")}).strict(),U.object({status:U.literal("failed"),message:T0}).strict(),U.object({status:U.literal("expired")}).strict(),U.object({status:U.literal("cancelled")}).strict(),U.object({status:U.literal("recovery_required"),message:T0}).strict(),U.object({status:U.literal("connected")}).strict()]),U7=U.object({status:U.enum(["preparing","pending","running","awaiting_approval","succeeded","failed","cancelled"]),runId:T0.nullable(),commitSha:T0.nullable(),message:T0.nullable(),appUrl:q2.nullable(),consoleUrl:q2.nullable()}).strict(),B7=U.object({sessionId:T0,projectRoot:T0,connection:D3.nullable(),credential:U.object({available:U.boolean(),expiresAt:Z3.nullable()}).strict(),pairing:H7.nullable(),previewUrl:q2.nullable(),deployment:U7.nullable()}).strict(),zw=U.object({projectRoot:T0}).strict(),_w=U.object({controlOrigin:x5}).strict(),Ow=U.object({url:q2.nullable()}).strict();function b3($){let J=B7.safeParse($);if(!J.success)throw Error("Invalid platform status");return J.data}function g3($,J){let Q=T0.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 R$(){return location.pathname.match(/\/s\/([^/]+)/)?.[1]??null}function N7(){return new URLSearchParams(location.search).get("root")}async function G2($){let J=await fetch(A1()+$,{headers:{accept:"application/json"}});if(!J.ok)throw Error(`${$} -> ${J.status}`);return J.json()}var S0={async health(){let $=_3.safeParse(await G2("/health"));if(!$.success)throw Error("Invalid health response");return $.data},async phase($){let J=$??N7(),Q=R$(),X=new URLSearchParams;if(J)X.set("root",J);if(Q)X.set("session",Q);let W=X.toString(),q=z3.safeParse(await G2(`/api/phase${W?`?${W}`:""}`));if(!q.success)throw Error("Invalid phase response");return q.data},async meta($){let J=P3.safeParse(await G2(`/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=j3.safeParse(await Q.json());return X.success?X.data.content:null}catch{return null}},async sessions(){return k3.parse(await G2("/api/sessions"))},canvasUrl($,J,Q){let X=Q!=null?`?rev=${Q}`:"";return`${A1()}/api/session/${encodeURIComponent($)}/canvas/${encodeURIComponent(J)}${X}`},async skeletons($){let J=A3.safeParse(await G2(`/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=V3.safeParse(await G2(`/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=(q)=>{try{let Y=T3.safeParse(JSON.parse(String(q.data)));if(Y.success)J(Y.data)}catch{}},W},submitGate($,J){if($.readyState===WebSocket.OPEN)return $.send(JSON.stringify({type:"submit",feedback:J})),!0;return!1},buildStream($){try{let J=new EventSource(`${A1()}/api/build/stream`);return J.onmessage=(Q)=>{try{let X=S3.safeParse(JSON.parse(Q.data));if(X.success)$(X.data)}catch{}},J}catch{return null}}};import{jsxDEV as Y0,Fragment as C$}from"react/jsx-dev-runtime";var F7=".fabrika/architecture/design.md",L7=".fabrika/pages/_preview.html",h5=`: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 M7($){if(!$)return h5;let J=$.match(/:root\s*\{[^}]*\}/);return J?J[0]:h5}function f7($){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 K7($,J){let Q=`<style>${J}</style>`,X=$.indexOf("<head>");if(X!==-1)return $.slice(0,X+6)+Q+$.slice(X+6);return`${Q}${$}`}function y3({url:$,children:J}){return Y0("div",{className:"flex h-full flex-col overflow-hidden rounded-md border border-border-medium bg-bg-base",children:[Y0("div",{className:"flex items-center gap-1.5 border-b border-border-subtle bg-bg-elevated px-3 py-2",children:[Y0("span",{className:"h-2.5 w-2.5 rounded-full bg-accent-red/60"},void 0,!1,void 0,this),Y0("span",{className:"h-2.5 w-2.5 rounded-full bg-accent-amber/60"},void 0,!1,void 0,this),Y0("span",{className:"h-2.5 w-2.5 rounded-full bg-accent-green/60"},void 0,!1,void 0,this),Y0("span",{className:"ml-2 truncate font-mono text-tiny text-text-tertiary",children:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this),J]},void 0,!0,void 0,this)}function z7({sessionId:$,live:J}){let[Q,X]=I3(h5),[W,q]=I3(null);w7(()=>{if(!J)return;let G=!1;return S0.artifact($,F7).then((B)=>{if(!G)X(M7(B))}),S0.artifact($,L7).then((B)=>{if(!G)q(B?.trim()?B:null)}).catch(()=>{}),()=>{G=!0}},[$,J]);let Y=W!==null,H=Y?K7(W,Q):f7(Q);return Y0(C$,{children:[Y0(y3,{url:Y?"pages/_preview.html":"pages/checkout.jsx",children:Y0("iframe",{srcDoc:H,className:"min-h-0 flex-1 bg-white",title:"screen mockup",sandbox:"allow-same-origin"},void 0,!1,void 0,this)},void 0,!1,void 0,this),Y0("p",{className:"mt-2 px-0.5 text-tiny text-text-tertiary",children:Y?Y0(C$,{children:["Primary screen mockup (",Y0("span",{className:"font-mono",children:"pages/_preview.html"},void 0,!1,void 0,this),"), themed live by"," ",Y0("span",{className:"font-mono",children:"architecture/design.md"},void 0,!1,void 0,this)," tokens."]},void 0,!0,void 0,this):Y0(C$,{children:["Built-in demo screen, themed live by ",Y0("span",{className:"font-mono",children:"architecture/design.md"},void 0,!1,void 0,this)," tokens — drop a"," ",Y0("span",{className:"font-mono",children:"pages/_preview.html"},void 0,!1,void 0,this)," to preview your own."]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function _7({previewUrl:$}){if(!$)return Y0("p",{className:"text-body text-text-tertiary",children:"No local preview configured. Set a local preview URL in Deployment."},void 0,!1,void 0,this);return Y0(C$,{children:[Y0(y3,{url:$,children:Y0("iframe",{src:$,className:"min-h-0 flex-1 bg-white",title:"Local application preview"},void 0,!1,void 0,this)},void 0,!1,void 0,this),Y0("p",{className:"mt-2 px-0.5 text-tiny text-text-tertiary",children:"Local development preview. This is separate from the deployed application."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function E3({phase:$,sessionId:J,live:Q,previewUrl:X}){return Y0("aside",{className:"flex h-full flex-col border-l border-border-subtle bg-bg-surface",children:[Y0("div",{className:"flex items-center justify-between border-b border-border-subtle px-4 py-3",children:[Y0("div",{className:"text-tiny uppercase tracking-wide text-text-tertiary",children:"live preview"},void 0,!1,void 0,this),Y0("span",{className:"rounded bg-bg-elevated px-2 py-0.5 text-tiny text-text-secondary",children:$==="build"?"app":"mockup"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y0("div",{className:"flex min-h-0 flex-1 flex-col p-3",children:$==="build"?Y0(_7,{previewUrl:X},void 0,!1,void 0,this):Y0(z7,{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 h3,useState as v3}from"react";import{jsxDEV as x0}from"react/jsx-dev-runtime";function P$($){let J=[],Q=/(`[^`]+`|\*\*[^*]+\*\*)/g,X=0,W,q=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)},q++,!1,void 0,this));else J.push(x0("strong",{className:"font-semibold text-text-primary",children:Y.slice(2,-2)},q++,!1,void 0,this));X=W.index+Y.length}if(X<$.length)J.push($.slice(X));return J}function x3({source:$}){let J=$.split(`
|
|
166
|
+
`),Q=[],X=0,W=0;while(X<J.length){let q=J[X];if(q.startsWith("```")){let H=[];X++;while(X<J.length&&!J[X].startsWith("```"))H.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:H.join(`
|
|
167
|
+
`)},void 0,!1,void 0,this)},W++,!1,void 0,this));continue}let Y=q.match(/^(#{1,4})\s+(.*)$/);if(Y){let H=Y[1].length,G=H===1?"mt-2 mb-3 font-heading text-section text-text-primary":H===2?"mt-5 mb-2 font-heading text-xl text-text-primary":"mt-4 mb-1 text-task-label font-semibold text-text-secondary uppercase tracking-wide";Q.push(x0("div",{className:G,children:P$(Y[2])},W++,!1,void 0,this)),X++;continue}if(/^[-*]\s+/.test(q)){let H=[];while(X<J.length&&/^[-*]\s+/.test(J[X]))H.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:H.map((G,B)=>x0("li",{children:P$(G)},B,!1,void 0,this))},W++,!1,void 0,this));continue}if(/^\d+\.\s+/.test(q)){let H=[];while(X<J.length&&/^\d+\.\s+/.test(J[X]))H.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:H.map((G,B)=>x0("li",{children:P$(G)},B,!1,void 0,this))},W++,!1,void 0,this));continue}if(q.trim()===""){X++;continue}Q.push(x0("p",{className:"my-2 text-body leading-relaxed text-text-secondary",children:P$(q)},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 c3}from"react/jsx-dev-runtime";function O7({state:$,focused:J,isCurrentGate:Q}){let X=G3(J),W=Z2(J,$.completed,$.current),q=W==="current",Y=q&&$.reads.length?$.reads.join(", "):X.reads.join(", "),H=q&&$.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:H},void 0,!1,void 0,this),V("dt",{className:"text-text-tertiary",children:"Gate"},void 0,!1,void 0,this),V("dd",{className:"min-w-0 break-words font-mono text-code text-text-secondary",children:X.gate?V(c3,{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 S7({sessionId:$,live:J,upcoming:Q}){let[X,W]=v3(null);h3(()=>{if(!J)return;let Y=!1;return S0.skeletons($).then((H)=>{if(!Y)W(H)}),()=>{Y=!0}},[$,J]);let q=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&&q.length===0&&V("p",{className:"text-body text-text-tertiary",children:["No skeletons in ",V("span",{className:"font-mono",children:"tests/browser/"},void 0,!1,void 0,this)," yet. Author them with the ",V("span",{className:"font-mono",children:"opice-plan"},void 0,!1,void 0,this)," ","skill, then ",V("span",{className:"font-mono",children:"fabrika builder induce"},void 0,!1,void 0,this),"."]},void 0,!0,void 0,this),V("div",{className:"grid grid-cols-2 gap-3",children:q.map((Y)=>V("div",{className:"rounded-md border border-border-subtle bg-bg-surface p-4 transition-colors hover:border-border-hover",children:[V("div",{className:"font-mono text-code text-text-primary",children:Y.file},void 0,!1,void 0,this),V("div",{className:"mt-1 truncate text-body text-text-secondary",children:Y.name},void 0,!1,void 0,this),V("div",{className:"mt-2 flex flex-wrap gap-x-3 gap-y-1 text-tiny text-text-tertiary",children:[Y.url&&V("span",{className:"font-mono",children:Y.url},void 0,!1,void 0,this),V("span",{children:[Y.steps," steps"]},void 0,!0,void 0,this),V("span",{children:[Y.invariants," invariants"]},void 0,!0,void 0,this),Y.pending>0?V("span",{className:"text-accent-amber",children:[Y.pending," pending"]},void 0,!0,void 0,this):V("span",{className:"text-accent-green",children:"authored"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),(Y.seeds.length>0||Y.roles.length>0)&&V("div",{className:"mt-2 flex flex-wrap gap-1",children:[Y.seeds.map((H)=>V("span",{className:"rounded bg-bg-elevated px-1.5 py-0.5 text-tiny text-text-secondary",children:["seed:",H]},H,!0,void 0,this)),Y.roles.map((H)=>V("span",{className:"rounded bg-bg-elevated px-1.5 py-0.5 text-tiny text-text-secondary",children:["role:",H]},H,!0,void 0,this))]},void 0,!0,void 0,this)]},Y.file,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function R7({live:$}){let[J,Q]=v3([]);h3(()=>{if(!$)return;let W=S0.buildStream((q)=>Q((Y)=>[...Y.slice(-200),q]));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,q)=>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)]},q,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function C7({canvas:$}){return V(c3,{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(L$,{revision:$.revision,filename:J.filename},void 0,!1,void 0,this)]},J.filename,!0,void 0,this))},void 0,!1,void 0,this)}function m3({state:$,focused:J,canvas:Q,artifact:X,isCurrentGate:W,sessionId:q,live:Y}){let G=Z2(J,$.completed,$.current)==="upcoming";return V("section",{className:"flex h-full min-w-0 flex-col bg-bg-base",children:[V(O7,{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(C7,{canvas:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this):J==="skeletons"?V(S7,{sessionId:q,live:Y,upcoming:G},void 0,!1,void 0,this):J==="build"?V(R7,{live:Y},void 0,!1,void 0,this):V("div",{className:"mx-auto max-w-3xl px-6 py-5",children:[G&&V("p",{className:"mb-4 rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-tiny text-text-tertiary",children:"This phase hasn't started yet — it unlocks once the earlier gates are approved. Here's what it will produce:"},void 0,!1,void 0,this),V(x3,{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 u3($){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 p3="fixture-session",v5={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},l3={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 d3={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 P7=Q$.extend({generalNote:U.string(),annotations:U.array(u$.pick({id:!0,snippet:!0,note:!0,createdAt:!0}).passthrough()),responses:U.array(U.tuple([U.string(),$$.innerType().pick({id:!0,type:!0,label:!0}).extend({type:U.string()}).passthrough()])),feedbackEntries:U.array(U.tuple([U.string(),J$.pick({id:!0,markdown:!0}).passthrough()])).optional()});function i3($){let J=P7.safeParse($);return J.success?s1(J.data):null}class h0 extends Error{}function k7($=fetch){async function J(Q,X,W,q){let Y;try{Y=await $(g3(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:q?AbortSignal.any([q,AbortSignal.timeout(1e4)]):AbortSignal.timeout(1e4)})}catch{throw new h0("Local builder unavailable. Check the daemon and refresh status.")}let H;try{H=await Y.json()}catch{throw new h0("Local builder returned an invalid response. Refresh status before continuing.")}if(!Y.ok){let G=O3.safeParse(H);if(G.success)throw new h0(G.data.error.message);throw new h0("Local builder rejected the request. Refresh status before continuing.")}try{let G=b3(H);if(G.sessionId!==Q)throw Error("Session mismatch");return G}catch{throw new h0("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 q={};try{if(X.kind==="connect")q={controlOrigin:Y2(X.controlOrigin)};if(X.kind==="preview")q={url:X.url===null?null:D2(X.url)}}catch{throw new h0("Enter a valid URL without credentials. Control origins require HTTPS except on localhost.")}return J(Q,X.kind,q,W)}}}var b2=k7();import{useEffect as r3,useRef as A7,useState as g2}from"react";function n3($,J){let[Q,X]=g2($),[W,q]=g2(null),[Y,H]=g2(null),[G,B]=g2(!1),[N,L]=g2(0),M=A7(null);r3(()=>{return X($),q(null),H(null),B(!1),L(0),()=>{M.current?.abort(),M.current=null}},[$]),r3(()=>{if(Q!==$||!J||G||Y)return;let C=new AbortController,K,O=0,S=async()=>{try{if(++O>1200)throw new h0("Automatic status refresh paused. Refresh status to continue.");let f=await b2.status($,C.signal);if(C.signal.aborted)return;q(f),H(null),K=setTimeout(S,3000)}catch(f){if(!C.signal.aborted)H(f instanceof h0?f.message:"Unable to read local deployment status.")}};return S(),()=>{C.abort(),clearTimeout(K)}},[$,Q,J,G,N,Y]);let w=Q===$,F=w&&J&&W!==null&&Y===null&&!G;return{data:w?W:null,error:w?Y:null,busy:w&&G,enabled:F,refresh:()=>{q(null),H(null),L((C)=>C+1)},act:async(C)=>{if(!F||M.current)return;let K=new AbortController;M.current=K,B(!0);try{let O=await b2.act($,C,K.signal);if(!K.signal.aborted)q(O)}catch(O){if(!K.signal.aborted)H(O instanceof h0?O.message:"Local operation failed. Refresh status.")}finally{if(M.current===K){if(M.current=null,!K.signal.aborted)B(!1)}}}}}import{jsxDEV as A0}from"react/jsx-dev-runtime";function j7($){return $==="design"||$==="build"}var s3={current:"intake",index:0,completed:[],reads:[],produces:[],gate:!1,satisfied:!1},V7="_Nový projekt — zatím žádný krok. Otevři první gate z agenta._";function t3(){let $=R$()??p3,[J,Q]=j1("connecting"),X=n3($,J==="live"),[W,q]=j1(s3),[Y,H]=j1(null),[G,B]=j1(!1),[N,L]=j1(s3.current),[M,w]=j1(!1),F=c5(!1),C=c5(null),K=c5(void 0);o3(()=>{let k=!1;return(async()=>{try{if(await S0.health(),k)return;let g=new URLSearchParams(location.search).get("root");if(g?.endsWith("/.fabrika"))await b2.register($,g.slice(0,-9));let l=await S0.meta($);if(k)return;if(l)H(l),K.current=l.projectRoot?`${l.projectRoot}/.fabrika`:void 0;let z=await S0.phase(K.current);if(k)return;if(z){if(q(z),!F.current)L(z.current)}Q("live")}catch{if(!k){if(R$()){Q("offline");return}if(H(l3),q(v5),!F.current)L(v5.current);Q("fixture")}}})(),()=>{k=!0}},[$]);let O=Y!==null&&(J==="live"||J==="offline");o3(()=>{if(!O)return;let k=!1,g=null,l=()=>{S0.meta($).then((j)=>H(j)).catch(()=>{}),S0.phase(K.current).then((j)=>{if(q(j),!F.current)L(j.current)}).catch(()=>{})},z=()=>{let j=S0.openSocket($,(n)=>{if(n.type==="plan-updated"||n.type==="revision-updated")w(!1),l();else if(n.type==="watcher-status")B(n.watching);else if(n.type==="phase-updated")w(!1),l();else if(n.type==="submit-ack")w(!1),l()});C.current=j,j.onopen=()=>Q("live"),j.onclose=()=>{if(k)return;Q("offline"),g=setTimeout(z,2000)}};return z(),()=>{if(k=!0,g)clearTimeout(g);C.current?.close(),C.current=null}},[O,$]);let[S,f]=j1({type:"overview"}),A=(k)=>{F.current=!0,L(k)},Z=(k)=>{let g=C.current;if(g&&S0.submitGate(g,k))w(!0)},h=J==="live",I=m5(()=>{if(!Y)return null;for(let k=Y.revisions.length-1;k>=0;k--)if(Y.revisions[k].label===N)return Y.revisions[k];return null},[Y,N]),v=W.gateName??Y?.gate??null,u=h&&N===W.current&&!!v,m=m5(()=>{return u3(I)},[I]),e=h&&!!I&&m.length>0,X0=I?.revision??Y?.currentRevision??0,q0=Y?.currentRevision??0,z0=u&&!!I?.hasFeedback&&!I?.feedbackConsumed,$0=!u||u&&(M||z0),J0=J==="fixture"?d3[N]??"_No artifact for this phase yet._":V7,G0=m5(()=>(Y?.revisions??[]).map((k)=>({revision:k.revision,label:k.label??void 0,canvasFiles:k.canvasFiles.map((g)=>({filename:g.filename})),createdAt:k.createdAt??new Date().toISOString(),hasFeedback:!!k.hasFeedback,feedbackConsumed:!!k.feedbackConsumed})),[Y]),a=j7(N),B0=A0("div",{className:`grid min-h-0 flex-1 grid-rows-[minmax(0,1fr)] ${a?"grid-cols-[14rem_minmax(0,1fr)_22rem_auto]":"grid-cols-[14rem_minmax(0,1fr)_auto]"}`,children:[A0(H3,{state:W,focused:N,onFocus:A},void 0,!1,void 0,this),A0(m3,{state:W,focused:N,canvas:e?{revision:X0,files:m}:null,artifact:J0,isCurrentGate:u,sessionId:$,live:h},void 0,!1,void 0,this),a&&A0(E3,{phase:N,sessionId:$,live:h,previewUrl:X.data?.previewUrl??null},void 0,!1,void 0,this),A0(X3,{gateName:v,hasGate:e,isCurrentGate:u,onSubmit:Z},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return A0("div",{className:"flex h-screen w-screen flex-col overflow-hidden bg-bg-base text-text-primary",children:[A0(q3,{sessionId:$,status:J,watching:G},void 0,!1,void 0,this),A0(Y3,{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),e?A0(P5.Provider,{value:$,children:A0($2.Provider,{value:{currentRevision:q0,selectedRevision:X0,revisions:G0,setSelectedRevision:()=>{},isReadOnly:$0,compareRevision:null,setCompareRevision:()=>{},agentWatching:G},children:A0(e1.Provider,{value:{activeView:S,setActiveView:f,openFiles:[],closeFile:()=>{},canvasFiles:m.map((k)=>k.filename)},children:A0(X$,{sessionId:$,revision:X0,isReadOnly:$0,draftPhase:"current",loadState:(k,g)=>S0.getResponses(k,g,i3),saveState:(k,g,l)=>{S0.saveResponses(k,g,l)},children:B0},X0,!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 Z7}from"react/jsx-dev-runtime";var a3=document.getElementById("root");if(a3===null)throw Error("Builder dashboard root element is missing");T7(a3).render(Z7(t3,{},void 0,!1,void 0,this));
|