agent-canvas 0.1.11 → 0.1.13
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/daemon/client/AnnotationEditor.tsx +1 -3
- package/daemon/client/AnnotationProvider.tsx +0 -15
- package/daemon/client/App.tsx +5 -1
- package/daemon/client/Popover.tsx +6 -1
- package/daemon/client/ResponsePreview.tsx +22 -7
- package/daemon/client/components/Choice.tsx +8 -12
- package/daemon/client/components/UserInput.tsx +7 -11
- package/daemon/dist/client.js +54 -54
- package/daemon/dist/components.js +45 -45
- package/daemon/src/compiler.ts +43 -15
- package/package.json +1 -1
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import{useState as
|
|
1
|
+
import{useState as j0}from"react";import{jsxDEV as Q1}from"react/jsx-dev-runtime";function V0({title:Q,children:y}){let[J,Y]=j0(!1);return Q1("div",{className:"relative mb-8 p-4 group/section","data-md":"section","data-md-title":Q,children:[Q1("div",{className:"relative mb-2",children:[Q1("button",{onClick:()=>Y(!J),className:`absolute -left-8 top-1/2 -translate-y-1/2 text-text-tertiary opacity-0 group-hover/section:opacity-50 hover:!opacity-100 transition-all duration-150 p-0.5 ${J?"-rotate-90":""}`,children:Q1("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:Q1("path",{d:"M3 4.5L6 7.5L9 4.5",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),Q1("h2",{className:"font-heading text-section text-text-primary",style:{fontWeight:400},children:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q1("div",{className:J?"mt-6 hidden":"mt-6",children:y},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as a}from"react/jsx-dev-runtime";var x0={todo:"bg-border-hover",done:"bg-accent-green",blocked:"bg-accent-red","in-progress":"bg-accent-blue"},D0={todo:"Todo",done:"Done",blocked:"Blocked","in-progress":"In progress"},c0={info:"bg-accent-blue-muted text-accent-blue",success:"bg-accent-green-muted text-accent-green",warning:"bg-accent-amber-muted text-accent-amber",danger:"bg-accent-red-muted text-accent-red",neutral:"bg-border-subtle text-text-tertiary"};function n1({id:Q,label:y,status:J,badge:Y,badgeVariant:$="neutral",children:B}){return a("div",{className:"group/task relative -mx-4 px-4 py-3 rounded-md transition-colors duration-150 hover:bg-bg-input","data-task-id":Q,"data-md":"item","data-md-label":y,...J?{"data-md-status":J}:{},...Y?{"data-md-badge":Y}:{},children:a("div",{className:"flex items-start gap-3",children:[J&&a("span",{className:`w-2 h-2 rounded-full mt-[7px] flex-shrink-0 ${x0[J]}`},void 0,!1,void 0,this),a("div",{className:"flex-1 min-w-0",children:[a("div",{className:"flex items-baseline gap-2",children:[a("span",{className:"font-body text-task-label font-semibold text-text-primary",children:y},void 0,!1,void 0,this),J&&a("span",{className:"font-body text-tiny uppercase tracking-wider text-text-tertiary opacity-0 group-hover/task:opacity-100 transition-opacity duration-150",children:D0[J]},void 0,!1,void 0,this),Y&&a("span",{className:`font-body text-tiny font-medium px-1.5 py-px rounded-full ${c0[$]}`,children:Y},void 0,!1,void 0,this)]},void 0,!0,void 0,this),B&&a("div",{className:"text-body text-text-secondary mt-1 leading-relaxed",children:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function p0(Q){return a(n1,{...Q},void 0,!1,void 0,this)}import{useEffect as E0,useRef as d0}from"react";import{jsxDEV as _1}from"react/jsx-dev-runtime";function u0({language:Q,children:y}){let J=typeof y==="string"?y:String(y??""),Y=d0(null);return E0(()=>{let $=Y.current,B=window.hljs;if(!$||!B)return;$.removeAttribute("data-highlighted"),$.className=Q?`language-${Q}`:"",$.textContent=J,B.highlightElement($)},[J,Q]),_1("div",{className:"relative mt-3 group/code","data-md":"codeblock","data-md-language":Q||"",children:[Q&&_1("span",{className:"absolute top-2 right-3 text-tiny text-text-tertiary opacity-0 group-hover/code:opacity-60 transition-opacity duration-150 z-10 font-mono",children:Q},void 0,!1,void 0,this),_1("pre",{className:"bg-bg-code rounded-md p-4 overflow-x-auto text-code font-mono leading-relaxed",children:_1("code",{ref:Y,className:Q?`language-${Q}`:"",children:J},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as j1}from"react/jsx-dev-runtime";var r0={info:{bg:"bg-accent-blue-muted",icon:"i",iconColor:"text-accent-blue"},warning:{bg:"bg-accent-amber-muted",icon:"!",iconColor:"text-accent-amber"},danger:{bg:"bg-accent-red-muted",icon:"✕",iconColor:"text-accent-red"},tip:{bg:"bg-accent-green-muted",icon:"✓",iconColor:"text-accent-green"}};function i0({type:Q="info",children:y}){let J=r0[Q];return j1("div",{className:`${J.bg} relative rounded-lg px-5 py-4 mt-3 flex gap-3 items-start`,"data-md":"callout","data-md-type":Q,children:[j1("span",{className:`${J.iconColor} opacity-70 text-base leading-relaxed flex-shrink-0 mt-px`,children:J.icon},void 0,!1,void 0,this),j1("div",{className:"text-body text-text-secondary leading-relaxed",children:y},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as a0}from"react/jsx-dev-runtime";function l0({children:Q}){return a0("div",{className:"relative bg-bg-elevated rounded-lg px-5 py-4 mt-3 text-body text-text-secondary italic leading-relaxed","data-md":"note",children:Q},void 0,!1,void 0,this)}import{jsxDEV as y1}from"react/jsx-dev-runtime";function o0({headers:Q,rows:y}){return y1("div",{className:"overflow-x-auto mt-3","data-md":"table",children:y1("table",{className:"w-full text-body",children:[y1("thead",{children:y1("tr",{className:"border-b border-border-subtle",children:Q.map((J,Y)=>y1("th",{className:"text-left px-4 py-2.5 text-meta font-medium uppercase tracking-wider text-text-tertiary font-body",children:J},Y,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),y1("tbody",{children:y.map((J,Y)=>y1("tr",{className:`relative border-b border-border-subtle last:border-b-0 transition-colors hover:bg-bg-surface/50 ${Y%2===1?"bg-bg-surface/30":""}`,children:J.map(($,B)=>y1("td",{className:"px-4 py-2.5 text-text-secondary font-body",children:$},B,!1,void 0,this))},Y,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as N1}from"react/jsx-dev-runtime";function s0({items:Q}){return N1("ul",{className:"space-y-1 mt-3","data-md":"checklist",children:Q.map((y,J)=>N1("li",{"data-md":"checklist-item","data-md-label":y.label,className:"relative flex items-start gap-2.5 py-1",children:[N1("span",{className:`w-4 h-4 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5 transition-all ${y.checked?"bg-accent-green":"border-[1.5px] border-border-hover"}`,children:y.checked&&N1("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:N1("path",{d:"M2.5 5L4.5 7L7.5 3",style:{stroke:"var(--color-text-inverse)"},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),N1("span",{className:`text-body font-body ${y.checked?"text-text-tertiary line-through decoration-border-hover":"text-text-secondary"}`,children:y.label},void 0,!1,void 0,this)]},J,!0,void 0,this))},void 0,!1,void 0,this)}import{jsxDEV as e0}from"react/jsx-dev-runtime";var n0={high:"text-accent-red bg-accent-red-muted",medium:"text-accent-amber bg-accent-amber-muted",low:"text-text-tertiary bg-border-subtle"};function t0({level:Q}){return e0("span",{className:`inline text-tiny font-medium font-body ml-2 px-1.5 py-0.5 rounded ${n0[Q]}`,"data-md":"priority","data-md-level":Q,children:Q},void 0,!1,void 0,this)}import{useEffect as t1,useState as w1,useContext as e1,useRef as yy}from"react";import{SessionContext as $y,ActiveViewCtx as Jy}from"#canvas/runtime";import{jsxDEV as $1}from"react/jsx-dev-runtime";var Qy={ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",py:"python",rs:"rust",go:"go",rb:"ruby",java:"java",json:"json",yaml:"yaml",yml:"yaml",md:"markdown",css:"css",html:"html",sh:"bash",bash:"bash",toml:"toml",sql:"sql",xml:"xml",c:"c",cpp:"cpp",h:"c"};function Yy({path:Q,lines:y,__content:J}){let Y=e1($y),{setActiveView:$}=e1(Jy),[B,W]=w1(J??null),[K,X]=w1(()=>{let q=Q.split(".").pop()||"";return Qy[q]||"text"}),[L,N]=w1(null),[G,U]=w1(!J),b=yy(null);if(t1(()=>{if(J!==void 0)return;U(!0),N(null),fetch(`/api/file?session=${Y}&path=${encodeURIComponent(Q)}`).then((q)=>q.json()).then((q)=>{if(q.error)N(q.error);else{let T=q.content;if(y)T=T.split(`
|
|
2
2
|
`).slice(y[0]-1,y[1]).join(`
|
|
3
|
-
`);W(T),X(q.language||"text")}}).catch(()=>N("Failed to fetch file")).finally(()=>H(!1))},[Y,J,y?.[0],y?.[1],Q]),n1(()=>{let q=b.current,T=window.hljs;if(!q||!T||!B)return;q.removeAttribute("data-highlighted"),q.className=K?`language-${K}`:"",q.textContent=B,T.highlightElement(q)},[B,K]),G)return y1("div",{className:"text-text-tertiary text-body mt-3 bg-bg-code rounded-md p-4",children:["Loading ",J,"..."]},void 0,!0,void 0,this);if(L)return y1("div",{className:"text-accent-red text-body mt-3 bg-accent-red-muted rounded-md p-4",children:[J,": ",L]},void 0,!0,void 0,this);return y1("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden","data-md":"filepreview","data-md-path":J,...y?{"data-md-lines":`${y[0]}-${y[1]}`}:{},children:[y1("div",{className:"px-4 py-2 flex items-center justify-between",children:[y1("button",{className:"font-mono text-meta text-text-tertiary hover:text-text-secondary hover:underline cursor-pointer text-left",onClick:()=>$({type:"file",path:J}),title:`Open ${J}`,children:J},void 0,!1,void 0,this),y&&y1("span",{className:"font-mono text-meta text-text-tertiary opacity-60",children:["L",y[0],"–",y[1]]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),y1("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono !bg-transparent",style:{background:"transparent"},children:y1("code",{ref:b,className:K?`language-${K}`:"",children:B},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as D1,useRef as U1,useState as K1,useCallback as l}from"react";import Hy from"react-dom";import{useAnnotations as Py}from"#canvas/runtime";import{useEffect as Y0,useRef as A1,useState as G1,useCallback as M1,useMemo as J0,useContext as Ky}from"react";import{createPortal as Ly}from"react-dom";function e1(J,y){let $=y||document.body,B=J.getBoundingClientRect(),W=$.getBoundingClientRect(),K=$===document.body?window.scrollY:$.scrollTop,X=B.bottom-W.top+K+8,L=Math.max(0,Math.min(B.left-W.left,W.width-280-12));return $.style.position="relative",{style:{position:"absolute",top:`${X}px`,left:`${L}px`},parent:$}}import{useState as j1,useRef as V1,useCallback as n,useEffect as y0}from"react";function Q1(J,y){J.style.height="auto",J.style.height=(y?Math.max(y,J.scrollHeight):J.scrollHeight)+"px"}import{jsxDEV as g}from"react/jsx-dev-runtime";function Wy(J){return`/api/uploads/${J.split("/").pop()}`}async function Xy(J,y){let Q=new FormData;Q.append("image",y);try{return(await(await fetch(`/api/session/${J}/upload`,{method:"POST",body:Q})).json()).path||null}catch{return null}}function $0({note:J,onNoteChange:y,images:Q,onAddImage:Y,onRemoveImage:$,sessionId:B,placeholder:W="Add your note...",autoFocus:K=!1,autoResize:X=!1,readOnly:L=!1,onKeyDown:N,onTextareaClick:G,textareaRef:H,textareaClassName:b,textareaStyle:q,minHeight:T,attachButton:P="always",openFilePickerRef:v}){let[A,O]=j1(!1),[c,V]=j1(!1),[k,D]=j1(!1),S=V1(0),f=V1(null),h=V1(null),I=n(()=>h.current?.click(),[]);y0(()=>{if(v)v.current=I},[v,I]);let p=n((U)=>{if(f.current=U,H)H.current=U;if(U&&X)Q1(U,T)},[H,X,T]);y0(()=>{if(K&&f.current){let U=f.current;if(U.focus(),U.value)U.setSelectionRange(U.value.length,U.value.length)}},[K]);let x=n(async(U)=>{if(!U.type.startsWith("image/"))return;V(!0);try{let Z=await Xy(B,U);if(Z)Y(Z)}finally{V(!1)}},[B,Y]),t=n((U)=>{let Z=U.clipboardData.items;for(let C of Z)if(C.type.startsWith("image/")){U.preventDefault();let s=C.getAsFile();if(s)x(s);return}},[x]),m=n((U)=>{if(U.preventDefault(),S.current++,S.current===1)O(!0)},[]),E=n((U)=>{U.preventDefault()},[]),d=n((U)=>{if(U.preventDefault(),S.current--,S.current===0)O(!1)},[]),o=n((U)=>{U.preventDefault(),S.current=0,O(!1);for(let Z of U.dataTransfer.files)if(Z.type.startsWith("image/"))x(Z)},[x]),$1=n((U)=>{if(y(U.target.value),X)U.target.style.height="auto",U.target.style.height=(T?Math.max(T,U.target.scrollHeight):U.target.scrollHeight)+"px"},[y,X,T]),q1="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",h1={width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",outline:"none",...X?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},v1=!L&&(P==="always"||P==="on-focus"&&k);return g("div",{style:{position:"relative"},onDragEnter:L?void 0:m,onDragOver:L?void 0:E,onDragLeave:L?void 0:d,onDrop:L?void 0:o,children:[g("textarea",{ref:p,value:J,onChange:L?void 0:$1,onPaste:L?void 0:t,onKeyDown:N,onClick:G,onFocus:()=>D(!0),onBlur:()=>{setTimeout(()=>D(!1),150)},readOnly:L,placeholder:W,className:b??q1,style:q??h1,rows:X?1:void 0},void 0,!1,void 0,this),!L&&g("input",{ref:h,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:(U)=>{let Z=U.target.files;if(Z)for(let C of Z)x(C);U.target.value=""}},void 0,!1,void 0,this),(Q.length>0||v1)&&g("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[Q.map((U)=>g("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[g("img",{src:Wy(U),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!L&&g("button",{onClick:(Z)=>{Z.stopPropagation(),$(U)},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)]},U,!0,void 0,this)),v1&&g(x1,{onClick:I},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c&&g("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),A&&g("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 x1({onClick:J,size:y=16}){return g("button",{onClick:(Q)=>{Q.stopPropagation(),J()},style:{width:`${y*2}px`,height:`${y*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:g("svg",{width:y,height:y,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[g("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),g("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),g("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)}import{SessionContext as Ny}from"#canvas/runtime";import{jsxDEV as R,Fragment as Uy}from"react/jsx-dev-runtime";function qy({anchorEl:J,scrollContainer:y,onClose:Q,ignoreSelector:Y,zIndex:$="50",padding:B="12px",width:W="280px",children:K}){let X=A1(null),L=A1(Q);L.current=Q;let{style:N,parent:G}=e1(J,y);return Y0(()=>{let H=setTimeout(()=>{let b=(q)=>{if(X.current&&!X.current.contains(q.target)){if(Y&&q.target.closest?.(Y))return;L.current(),document.removeEventListener("mousedown",b)}};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},0);return()=>clearTimeout(H)},[Y]),Ly(R("div",{ref:X,style:{...N,zIndex:$,width:W,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:B,fontFamily:"'Inter', sans-serif"},children:K},void 0,!1,void 0,this),G)}var B0=[{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"]}],Q0=B0.flatMap((J)=>J.items);function Gy({anchorEl:J,scrollContainer:y,snippet:Q,truncateAt:Y=100,header:$,initialNote:B="",initialImages:W,onConfirm:K,onCancel:X,onDelete:L}){let N=Ky(Ny),G=B!==""||!!L,[H,b]=G1(B),[q,T]=G1(W||[]),[P,v]=G1(null),[A,O]=G1(G),[c,V]=G1(!1),k=A1(null),D=A1(null),S=M1(()=>{if(H.trim()||q.length>0)K(H.trim(),q);else if(G&&L)L();else X()},[H,q,K,X,G,L]),f=M1(()=>{if(G){if(!H.trim()&&q.length===0&&L){L(),X();return}K(H,q);return}X()},[H,q,G,K,X,L]),h=!G,I=H.trim().length>0?Q0.filter((U)=>U.toLowerCase().startsWith(H.trim().toLowerCase())):Q0,p=!h||A?[]:I.length===1&&I[0].toLowerCase()===H.trim().toLowerCase()?[]:I,x=new Set(p),t=B0.map((U)=>({label:U.label,items:U.items.filter((Z)=>x.has(Z))})).filter((U)=>U.items.length>0),m=t.map((U)=>U.items),E=m.flat(),d=J0(()=>{if(P===null)return 0;let U=0;for(let Z=0;Z<m.length;Z++){if(P<U+m[Z].length)return Z;U+=m[Z].length}return 0},[P,m]),o=J0(()=>{if(P===null)return 0;let U=0;for(let Z=0;Z<d;Z++)U+=m[Z].length;return P-U},[P,d,m]),$1=(U,Z)=>{let C=0;for(let s=0;s<U;s++)C+=m[s].length;return C+Z};Y0(()=>{v(null),O(G)},[H]);let q1=M1((U)=>{b(U)},[]),h1=Q.length>Y?Q.slice(0,Y)+"...":Q,v1=M1((U)=>{if(E.length>0&&(U.key==="ArrowDown"||U.key==="ArrowUp"||U.key==="ArrowLeft"||U.key==="ArrowRight")){if(U.preventDefault(),P===null){v(0);return}if(U.key==="ArrowDown"){let Z=Math.min(o+1,m[d].length-1);v($1(d,Z))}else if(U.key==="ArrowUp"){let Z=Math.max(o-1,0);v($1(d,Z))}else if(U.key==="ArrowRight"){let Z=Math.min(d+1,m.length-1),C=Math.min(o,m[Z].length-1);v($1(Z,C))}else if(U.key==="ArrowLeft"){let Z=Math.max(d-1,0),C=Math.min(o,m[Z].length-1);v($1(Z,C))}return}if(P!==null&&E.length>0){if(U.key==="Tab"){U.preventDefault(),q1(E[P]);return}if(U.key==="Enter"&&!U.shiftKey){U.preventDefault(),K(E[P],q);return}}if(U.key==="Enter"&&!U.shiftKey){U.preventDefault(),S();return}if(U.key==="Escape")if(E.length>0&&!A)O(!0);else if(G)f();else X()},[E,P,o,d,m,$1,q1,K,q,S,A,G,f,X]);return R(qy,{anchorEl:J,scrollContainer:y,onClose:G?f:X,ignoreSelector:G?"[data-annotation-id]":void 0,zIndex:G?"60":"50",padding:G?"10px 12px":"12px",width:"420px",children:[!G&&($??R("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:["“",h1,"”"]},void 0,!0,void 0,this)),R($0,{note:H,onNoteChange:b,images:q,onAddImage:(U)=>T((Z)=>[...Z,U]),onRemoveImage:(U)=>T((Z)=>Z.filter((C)=>C!==U)),sessionId:N,autoFocus:!0,autoResize:G,textareaRef:k,onKeyDown:v1,attachButton:"none",openFilePickerRef:D,textareaStyle:G?{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),R("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:G?"6px":"8px"},children:[R(x1,{onClick:()=>D.current?.(),size:14},void 0,!1,void 0,this),R("div",{style:{flex:1}},void 0,!1,void 0,this),G?R("button",{onClick:()=>{if(L)L();X()},onMouseEnter:()=>V(!0),onMouseLeave:()=>V(!1),style:{fontSize:"11px",color:c?"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):R(Uy,{children:[R("button",{onClick:X,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),R("button",{onClick:S,style:{fontSize:"11px",fontWeight:500,padding:"4px 12px",borderRadius:"6px",background:"var(--color-highlight-bg)",color:"var(--color-text-primary)",border:"1px solid var(--color-highlight-border)",cursor:"pointer",fontFamily:"'Inter', sans-serif"},children:"Add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),E.length>0&&R("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:t.map((U)=>R("div",{style:{flex:1},children:[R("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:U.label},void 0,!1,void 0,this),U.items.map((Z)=>{let C=E.indexOf(Z);return R("div",{onMouseDown:(s)=>{s.preventDefault(),s.stopPropagation(),q1(Z)},onMouseEnter:()=>v(C),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:C===P?"var(--color-text-primary)":"var(--color-text-secondary)",background:C===P?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[R("span",{style:{fontWeight:500},children:Z.slice(0,H.trim().length)},void 0,!1,void 0,this),Z.slice(H.trim().length)]},Z,!0,void 0,this)})]},U.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function W0({anchorEl:J,scrollContainer:y,snippet:Q,truncateAt:Y,header:$,onAdd:B,onCancel:W}){return R(Gy,{anchorEl:J,scrollContainer:y,snippet:Q,truncateAt:Y,header:$,onConfirm:(K,X)=>B(K,X),onCancel:W},void 0,!1,void 0,this)}import{jsxDEV as F,Fragment as N0}from"react/jsx-dev-runtime";var L1=0.2,f1=0.25,z1=4;function K0({zoom:J,onZoomIn:y,onZoomOut:Q,onZoomReset:Y,onFullscreen:$}){return F("div",{className:"flex items-center gap-0.5 bg-bg-surface border border-border-subtle rounded-md px-1 py-0.5",style:{fontSize:"12px"},children:[F("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:Q,title:"Zoom out",disabled:J<=f1,children:F("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:F("line",{x1:"5",y1:"12",x2:"19",y2:"12"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),F("button",{className:"px-1.5 h-7 rounded hover:bg-bg-elevated text-text-tertiary hover:text-text-primary transition-colors tabular-nums",onClick:Y,title:"Reset zoom",children:[Math.round(J*100),"%"]},void 0,!0,void 0,this),F("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:y,title:"Zoom in",disabled:J>=z1,children:F("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[F("line",{x1:"12",y1:"5",x2:"12",y2:"19"},void 0,!1,void 0,this),F("line",{x1:"5",y1:"12",x2:"19",y2:"12"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),$&&F(N0,{children:[F("div",{className:"w-px h-4 bg-border-subtle mx-0.5"},void 0,!1,void 0,this),F("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:$,title:"Fullscreen",children:F("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[F("polyline",{points:"15 3 21 3 21 9"},void 0,!1,void 0,this),F("polyline",{points:"9 21 3 21 3 15"},void 0,!1,void 0,this),F("line",{x1:"21",y1:"3",x2:"14",y2:"10"},void 0,!1,void 0,this),F("line",{x1:"3",y1:"21",x2:"10",y2:"14"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function L0(J=1){let[y,Q]=K1(J),Y=l(()=>Q((W)=>Math.min(z1,+(W+L1).toFixed(2))),[]),$=l(()=>Q((W)=>Math.max(f1,+(W-L1).toFixed(2))),[]),B=l(()=>Q(1),[]);return{zoom:y,zoomIn:Y,zoomOut:$,zoomReset:B,setZoom:Q}}function by({svgHtml:J,source:y,onClose:Q}){let Y=U1(null),{zoom:$,zoomIn:B,zoomOut:W,zoomReset:K,setZoom:X}=L0(1),[L,N]=K1({x:0,y:0}),G=U1(null);D1(()=>{let v=(A)=>{if(A.key==="Escape")Q()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[Q]);let H=l((v)=>{v.preventDefault();let A=v.deltaY>0?-L1:L1;X((O)=>Math.max(f1,Math.min(z1,+(O+A).toFixed(2))))},[X]),b=l((v)=>{if(v.button!==0)return;G.current={startX:v.clientX,startY:v.clientY,panX:L.x,panY:L.y},v.preventDefault()},[L]),q=l((v)=>{if(!G.current)return;N({x:G.current.panX+(v.clientX-G.current.startX),y:G.current.panY+(v.clientY-G.current.startY)})},[]),T=l(()=>{G.current=null},[]),P=l(()=>{K(),N({x:0,y:0})},[K]);return Hy.createPortal(F("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"var(--color-bg-base)",display:"flex",flexDirection:"column"},onMouseMove:q,onMouseUp:T,onMouseLeave:T,children:[F("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border-subtle",style:{flexShrink:0,background:"var(--color-bg-surface)"},children:[F("span",{className:"text-body text-text-secondary",style:{fontSize:"13px"},children:"Mermaid Diagram"},void 0,!1,void 0,this),F("div",{className:"flex items-center gap-2",children:[F(K0,{zoom:$,onZoomIn:B,onZoomOut:W,onZoomReset:P},void 0,!1,void 0,this),F("button",{className:"flex items-center justify-center w-8 h-8 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:Q,title:"Close (Esc)",children:F("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[F("line",{x1:"18",y1:"6",x2:"6",y2:"18"},void 0,!1,void 0,this),F("line",{x1:"6",y1:"6",x2:"18",y2:"18"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),F("div",{style:{flex:1,overflow:"hidden",cursor:G.current?"grabbing":"grab"},onWheel:H,onMouseDown:b,children:F("div",{ref:Y,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transform:`translate(${L.x}px, ${L.y}px) scale(${$})`,transformOrigin:"center center",transition:G.current?"none":"transform 0.1s ease-out"},dangerouslySetInnerHTML:{__html:J}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),document.body)}function Ty({children:J}){let y=U1(null),[Q,Y]=K1(null),[$,B]=K1(!1),[W,K]=K1(""),X=typeof J==="string"?J:String(J??""),{annotations:L,addAnnotationWithId:N,activeAnnotationId:G,setActiveAnnotationId:H}=Py(),[b,q]=K1(null),{zoom:T,zoomIn:P,zoomOut:v,zoomReset:A,setZoom:O}=L0(1),c=U1(L);c.current=L;let V=l((f,h,I)=>{let p=`[Diagram ${I.toLowerCase()}] ${h}`,x=c.current.find((t)=>t.snippet===p);if(x)H(x.id);else q({anchorEl:f,snippet:h,prefix:I})},[H]),k=U1(V);k.current=V,D1(()=>{let f=!1,h=async()=>{try{let p=window.mermaid;if(!p){Y("Mermaid library not loaded");return}let x=document.documentElement.dataset.theme==="light"?"default":"dark";p.initialize({startOnLoad:!1,theme:x});let t=`mermaid-${Math.random().toString(36).slice(2)}`,{svg:m}=await p.render(t,X.trim());if(!f&&y.current)y.current.innerHTML=m,K(m),Zy(y.current,(E,d,o)=>k.current(E,d,o)),X0(y.current,c.current);Y(null)}catch(p){if(!f)Y(p.message||"Invalid diagram")}};h();let I=new MutationObserver((p)=>{for(let x of p)if(x.attributeName==="data-theme")h()});return I.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{f=!0,I.disconnect()}},[X]),D1(()=>{if(y.current)X0(y.current,L,G)},[L,G]);let D=l((f)=>{if(!f.ctrlKey&&!f.metaKey)return;f.preventDefault();let h=f.deltaY>0?-L1:L1;O((I)=>Math.max(f1,Math.min(z1,+(I+h).toFixed(2))))},[O]);if(Q)return F("div",{className:"bg-accent-red-muted rounded-md p-4 mt-3 text-body text-accent-red",children:["Mermaid error: ",Q,F("pre",{className:"mt-2 text-tiny text-text-tertiary whitespace-pre-wrap",children:X},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let S=y.current?.closest("#plan-scroll-container");return F(N0,{children:[F("div",{className:"mt-3 mermaid-container","data-md":"mermaid","data-md-source":X.trim(),children:[F("div",{className:"flex justify-end mb-1",children:F(K0,{zoom:T,onZoomIn:P,onZoomOut:v,onZoomReset:A,onFullscreen:()=>B(!0)},void 0,!1,void 0,this)},void 0,!1,void 0,this),F("div",{style:{overflow:"auto",maxHeight:"70vh"},onWheel:D,children:F("div",{ref:y,className:"flex justify-center",style:{transform:`scale(${T})`,transformOrigin:"top center",transition:"transform 0.1s ease-out",minHeight:T<1?void 0:void 0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b&&F(W0,{anchorEl:b.anchorEl,scrollContainer:S,snippet:b.snippet,header:F("div",{style:{fontSize:"12px",color:"var(--color-text-tertiary)",marginBottom:"8px",lineHeight:"1.4",display:"flex",alignItems:"center",gap:"6px"},children:[F("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:"var(--color-accent-amber)",flexShrink:0}},void 0,!1,void 0,this),b.snippet]},void 0,!0,void 0,this),onAdd:(f,h)=>{let I=`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;N(I,`[Diagram ${b.prefix.toLowerCase()}] ${b.snippet}`,f,void 0,void 0,h),q(null)},onCancel:()=>q(null)},void 0,!1,void 0,this),$&&W&&F(by,{svgHtml:W,source:X,onClose:()=>B(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Zy(J,y){let Q=(Y,$,B)=>{Y.style.cursor="pointer",Y.addEventListener("mouseenter",()=>{Y.style.filter="brightness(1.2)"}),Y.addEventListener("mouseleave",()=>{Y.style.filter=""}),Y.addEventListener("click",(W)=>{W.stopPropagation(),W.preventDefault(),y(Y,$(),B)})};for(let Y of J.querySelectorAll(".node"))Q(Y,()=>{return(Y.querySelector(".nodeLabel")||Y.querySelector("foreignObject span")||Y.querySelector("text"))?.textContent?.trim()||"Node"},"Node");for(let Y of J.querySelectorAll(".edgePath")){let $=Y,B=$.querySelector("path");if(B){B.style.strokeWidth=Math.max(parseFloat(B.style.strokeWidth||"1"),8)+"px",B.style.strokeOpacity="0";let K=B.cloneNode(!0);K.style.strokeWidth="",K.style.strokeOpacity="",$.insertBefore(K,B)}let W=$.id||"";Q($,()=>{let K=J.querySelectorAll(".edgeLabel");for(let X of K)if(X.id&&W&&X.id.replace("label","").includes(W.replace("L-","").replace("edge",""))){let L=X.textContent?.trim();if(L)return L}return"Connection"},"Edge")}for(let Y of J.querySelectorAll(".edgeLabel")){let $=Y.textContent?.trim();if(!$)continue;Q(Y,()=>$,"Edge")}for(let Y of J.querySelectorAll(".actor")){let $=Y.closest("g")?.querySelector("text")||Y.parentElement?.querySelector("text");if(!$)continue;let B=Y.closest("g");if(!B||B.hasAttribute("data-clickable"))continue;B.setAttribute("data-clickable","true"),Q(B,()=>$.textContent?.trim()||"Participant","Node")}for(let Y of J.querySelectorAll(".messageText")){let $=Y.textContent?.trim();if(!$)continue;Q(Y,()=>$,"Edge")}for(let Y of J.querySelectorAll(".entityBox")){let $=Y.closest("g");if(!$||$.hasAttribute("data-clickable"))continue;let B=$.querySelector(".entityLabel");if(!B)continue;$.setAttribute("data-clickable","true"),Q($,()=>B.textContent?.trim()||"Entity","Node")}for(let Y of J.querySelectorAll(".relationshipLabel")){let $=Y.textContent?.trim();if(!$)continue;let W=Y.closest("g")||Y;if(W.hasAttribute("data-clickable"))continue;W.setAttribute("data-clickable","true"),Q(W,()=>$,"Edge")}for(let Y of J.querySelectorAll(".classGroup")){let $=Y;if($.hasAttribute("data-clickable"))continue;let B=$.querySelector(".classTitle, .classTitleText, text");if(!B)continue;$.setAttribute("data-clickable","true"),Q($,()=>B.textContent?.trim()||"Class","Node")}for(let Y of J.querySelectorAll(".statediagram-state")){let $=Y;if($.hasAttribute("data-clickable"))continue;let B=$.querySelector(".state-title, text");if(!B)continue;$.setAttribute("data-clickable","true"),Q($,()=>B.textContent?.trim()||"State","Node")}for(let Y of J.querySelectorAll(".mindmap-node")){let $=Y;if($.hasAttribute("data-clickable"))continue;let B=$.querySelector(".mindmap-node-label, text");if(!B)continue;$.setAttribute("data-clickable","true"),Q($,()=>B.textContent?.trim()||"Node","Node")}}function X0(J,y,Q){let Y=new Map;for(let B of y){let W=B.snippet.match(/^\[Diagram (?:node|edge)\] (.+)$/);if(W)Y.set(W[1],B.id)}for(let B of J.querySelectorAll("[data-annotated]"))B.style.outline="",B.style.outlineOffset="",B.style.borderRadius="",B.removeAttribute("data-annotated");if(Y.size===0)return;for(let B of J.querySelectorAll(".node")){let K=(B.querySelector(".nodeLabel")||B.querySelector("foreignObject span")||B.querySelector("text"))?.textContent?.trim();if(!K||!Y.has(K))continue;let X=Y.get(K),L=B;L.setAttribute("data-annotated",X);let N=X===Q;L.style.outline=N?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",L.style.outlineOffset="2px",L.style.borderRadius="4px"}for(let B of J.querySelectorAll(".edgeLabel")){let W=B.textContent?.trim();if(!W||!Y.has(W))continue;let K=Y.get(W),X=B;X.setAttribute("data-annotated",K);let L=K===Q;X.style.outline=L?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",X.style.outlineOffset="2px",X.style.borderRadius="4px"}for(let B of J.querySelectorAll(".actor")){let W=B.closest("g");if(!W)continue;let X=W.querySelector("text")?.textContent?.trim();if(!X||!Y.has(X))continue;if(W.hasAttribute("data-annotated"))continue;let L=Y.get(X);W.setAttribute("data-annotated",L);let N=L===Q,G=W.querySelector("rect");if(G)G.style.outline=N?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",G.style.outlineOffset="2px",G.style.borderRadius="4px"}for(let B of J.querySelectorAll(".messageText")){let W=B.textContent?.trim();if(!W||!Y.has(W))continue;let K=Y.get(W),X=B;X.setAttribute("data-annotated",K);let L=K===Q;X.style.outline=L?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",X.style.outlineOffset="2px",X.style.borderRadius="4px"}let $=(B,W,K)=>{for(let X of J.querySelectorAll(B)){let L=K(X);if(!L||L.hasAttribute("data-annotated"))continue;let G=L.querySelector(W)?.textContent?.trim();if(!G||!Y.has(G))continue;let H=Y.get(G);L.setAttribute("data-annotated",H);let b=H===Q,q=L.querySelector("rect, circle, ellipse, polygon")||L;q.style.outline=b?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",q.style.outlineOffset="2px",q.style.borderRadius="4px"}};$(".entityBox",".entityLabel",(B)=>B.closest("g"));for(let B of J.querySelectorAll(".relationshipLabel")){let K=B.closest("g")||B;if(K.hasAttribute("data-annotated"))continue;let X=B.textContent?.trim();if(!X||!Y.has(X))continue;let L=Y.get(X);K.setAttribute("data-annotated",L);let N=L===Q;K.style.outline=N?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",K.style.outlineOffset="2px",K.style.borderRadius="4px"}$(".classGroup",".classTitle, .classTitleText, text",(B)=>B),$(".statediagram-state",".state-title, text",(B)=>B),$(".mindmap-node",".mindmap-node-label, text",(B)=>B)}import{jsxDEV as H1}from"react/jsx-dev-runtime";function Fy({before:J,after:y,language:Q}){let Y=J.split(`
|
|
3
|
+
`);W(T),X(q.language||"text")}}).catch(()=>N("Failed to fetch file")).finally(()=>U(!1))},[Y,Q,y?.[0],y?.[1],J]),t1(()=>{let q=b.current,T=window.hljs;if(!q||!T||!B)return;q.removeAttribute("data-highlighted"),q.className=K?`language-${K}`:"",q.textContent=B,T.highlightElement(q)},[B,K]),G)return $1("div",{className:"text-text-tertiary text-body mt-3 bg-bg-code rounded-md p-4",children:["Loading ",Q,"..."]},void 0,!0,void 0,this);if(L)return $1("div",{className:"text-accent-red text-body mt-3 bg-accent-red-muted rounded-md p-4",children:[Q,": ",L]},void 0,!0,void 0,this);return $1("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden","data-md":"filepreview","data-md-path":Q,...y?{"data-md-lines":`${y[0]}-${y[1]}`}:{},children:[$1("div",{className:"px-4 py-2 flex items-center justify-between",children:[$1("button",{className:"font-mono text-meta text-text-tertiary hover:text-text-secondary hover:underline cursor-pointer text-left",onClick:()=>$({type:"file",path:Q}),title:`Open ${Q}`,children:Q},void 0,!1,void 0,this),y&&$1("span",{className:"font-mono text-meta text-text-tertiary opacity-60",children:["L",y[0],"–",y[1]]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),$1("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono !bg-transparent",style:{background:"transparent"},children:$1("code",{ref:b,className:K?`language-${K}`:"",children:B},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as c1,useRef as H1,useState as G1,useCallback as o}from"react";import Hy from"react-dom";import{useAnnotations as by}from"#canvas/runtime";import{useEffect as Ky,useRef as A1,useState as q1,useCallback as M1,useMemo as J0,useContext as Ly}from"react";import{createPortal as Ny}from"react-dom";function y0(Q,y){let $=y||document.body,B=Q.getBoundingClientRect(),W=$.getBoundingClientRect(),K=$===document.body?window.scrollY:$.scrollTop,X=B.bottom-W.top+K+8,L=Math.max(0,Math.min(B.left-W.left,W.width-280-12));return $.style.position="relative",{style:{position:"absolute",top:`${X}px`,left:`${L}px`},parent:$}}import{useState as V1,useRef as x1,useCallback as t,useEffect as By}from"react";function Y1(Q,y){Q.style.height="auto",Q.style.height=(y?Math.max(y,Q.scrollHeight):Q.scrollHeight)+"px"}import{jsxDEV as g}from"react/jsx-dev-runtime";function Wy(Q){return`/api/uploads/${Q.split("/").pop()}`}async function Xy(Q,y){let J=new FormData;J.append("image",y);try{return(await(await fetch(`/api/session/${Q}/upload`,{method:"POST",body:J})).json()).path||null}catch{return null}}function $0({note:Q,onNoteChange:y,images:J,onAddImage:Y,onRemoveImage:$,sessionId:B,placeholder:W="Add your note...",autoFocus:K=!1,autoResize:X=!1,readOnly:L=!1,onKeyDown:N,onTextareaClick:G,textareaRef:U,textareaClassName:b,textareaStyle:q,minHeight:T,attachButton:P="always",openFilePickerRef:v}){let[A,S]=V1(!1),[E,V]=V1(!1),[O,c]=V1(!1),I=x1(0),k=x1(null),h=x1(null),R=t(()=>h.current?.click(),[]);if(v)v.current=R;let p=t((Z)=>{if(k.current=Z,U)U.current=Z;if(Z&&X)Y1(Z,T)},[U,X,T]);By(()=>{if(K&&k.current){let Z=k.current;if(Z.focus(),Z.value)Z.setSelectionRange(Z.value.length,Z.value.length)}},[K]);let x=t(async(Z)=>{if(!Z.type.startsWith("image/"))return;V(!0);try{let D=await Xy(B,Z);if(D)Y(D)}finally{V(!1)}},[B,Y]),e=t((Z)=>{let D=Z.clipboardData.items;for(let H of D)if(H.type.startsWith("image/")){Z.preventDefault();let f=H.getAsFile();if(f)x(f);return}},[x]),m=t((Z)=>{if(Z.preventDefault(),I.current++,I.current===1)S(!0)},[]),d=t((Z)=>{Z.preventDefault()},[]),u=t((Z)=>{if(Z.preventDefault(),I.current--,I.current===0)S(!1)},[]),n=t((Z)=>{Z.preventDefault(),I.current=0,S(!1);for(let D of Z.dataTransfer.files)if(D.type.startsWith("image/"))x(D)},[x]),J1=t((Z)=>{if(y(Z.target.value),X)Z.target.style.height="auto",Z.target.style.height=(T?Math.max(T,Z.target.scrollHeight):Z.target.scrollHeight)+"px"},[y,X,T]),h1="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",g1={width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",outline:"none",...X?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},K1=!L&&(P==="always"||P==="on-focus"&&O);return g("div",{style:{position:"relative"},onDragEnter:L?void 0:m,onDragOver:L?void 0:d,onDragLeave:L?void 0:u,onDrop:L?void 0:n,children:[g("textarea",{ref:p,value:Q,onChange:L?void 0:J1,onPaste:L?void 0:e,onKeyDown:N,onClick:G,onFocus:()=>c(!0),onBlur:()=>{setTimeout(()=>c(!1),150)},readOnly:L,placeholder:W,className:b??h1,style:q??g1,rows:X?1:void 0},void 0,!1,void 0,this),!L&&g("input",{ref:h,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:(Z)=>{let D=Z.target.files;if(D)for(let H of D)x(H);Z.target.value=""}},void 0,!1,void 0,this),(J.length>0||K1)&&g("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[J.map((Z)=>g("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[g("img",{src:Wy(Z),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!L&&g("button",{onClick:(D)=>{D.stopPropagation(),$(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)),K1&&g(D1,{onClick:R},void 0,!1,void 0,this)]},void 0,!0,void 0,this),E&&g("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),A&&g("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 D1({onClick:Q,size:y=16}){return g("button",{onClick:(J)=>{J.stopPropagation(),Q()},style:{width:`${y*2}px`,height:`${y*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:(J)=>{J.currentTarget.style.color="var(--color-text-secondary)"},onMouseLeave:(J)=>{J.currentTarget.style.color="var(--color-text-tertiary)"},children:g("svg",{width:y,height:y,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[g("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),g("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),g("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)}import{SessionContext as qy}from"#canvas/runtime";import{jsxDEV as C,Fragment as Py}from"react/jsx-dev-runtime";function Gy({anchorEl:Q,scrollContainer:y,onClose:J,ignoreSelector:Y,zIndex:$="50",padding:B="12px",width:W="280px",children:K}){let X=A1(null),L=A1(J);L.current=J;let{style:N,parent:G}=y0(Q,y);return Ky(()=>{let U=setTimeout(()=>{let b=(q)=>{if(X.current&&!X.current.contains(q.target)){if(Y&&q.target.closest?.(Y))return;L.current(),document.removeEventListener("mousedown",b)}};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},0);return()=>clearTimeout(U)},[Y]),Ny(C("div",{ref:X,style:{...N,zIndex:$,width:W,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:B,fontFamily:"'Inter', sans-serif"},children:K},void 0,!1,void 0,this),G)}var Y0=[{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"]}],Q0=Y0.flatMap((Q)=>Q.items);function Uy({anchorEl:Q,scrollContainer:y,snippet:J,truncateAt:Y=100,header:$,initialNote:B="",initialImages:W,onConfirm:K,onCancel:X,onDelete:L}){let N=Ly(qy),G=B!==""||!!L,[U,b]=q1(B),[q,T]=q1(W||[]),[P,v]=q1(null),[A,S]=q1(G),[E,V]=q1(!1),O=A1(null),c=A1(null),I=M1(()=>{if(U.trim()||q.length>0)K(U.trim(),q);else if(G&&L)L();else X()},[U,q,K,X,G,L]),k=M1(()=>{if(G){if(!U.trim()&&q.length===0&&L){L(),X();return}K(U,q);return}X()},[U,q,G,K,X,L]),h=!G,R=U.trim().length>0?Q0.filter((H)=>H.toLowerCase().startsWith(U.trim().toLowerCase())):Q0,p=!h||A?[]:R.length===1&&R[0].toLowerCase()===U.trim().toLowerCase()?[]:R,x=new Set(p),e=Y0.map((H)=>({label:H.label,items:H.items.filter((f)=>x.has(f))})).filter((H)=>H.items.length>0),m=e.map((H)=>H.items),d=m.flat(),u=J0(()=>{if(P===null)return 0;let H=0;for(let f=0;f<m.length;f++){if(P<H+m[f].length)return f;H+=m[f].length}return 0},[P,m]),n=J0(()=>{if(P===null)return 0;let H=0;for(let f=0;f<u;f++)H+=m[f].length;return P-H},[P,u,m]),J1=(H,f)=>{let r=0;for(let L1=0;L1<H;L1++)r+=m[L1].length;return r+f},[h1,g1]=q1(U);if(U!==h1)g1(U),v(null),S(G);let K1=M1((H)=>{b(H)},[]),Z=J.length>Y?J.slice(0,Y)+"...":J,D=M1((H)=>{if(d.length>0&&(H.key==="ArrowDown"||H.key==="ArrowUp"||H.key==="ArrowLeft"||H.key==="ArrowRight")){if(H.preventDefault(),P===null){v(0);return}if(H.key==="ArrowDown"){let f=Math.min(n+1,m[u].length-1);v(J1(u,f))}else if(H.key==="ArrowUp"){let f=Math.max(n-1,0);v(J1(u,f))}else if(H.key==="ArrowRight"){let f=Math.min(u+1,m.length-1),r=Math.min(n,m[f].length-1);v(J1(f,r))}else if(H.key==="ArrowLeft"){let f=Math.max(u-1,0),r=Math.min(n,m[f].length-1);v(J1(f,r))}return}if(P!==null&&d.length>0){if(H.key==="Tab"){H.preventDefault(),K1(d[P]);return}if(H.key==="Enter"&&!H.shiftKey){H.preventDefault(),K(d[P],q);return}}if(H.key==="Enter"&&!H.shiftKey){H.preventDefault(),I();return}if(H.key==="Escape")if(d.length>0&&!A)S(!0);else if(G)k();else X()},[d,P,n,u,m,J1,K1,K,q,I,A,G,k,X]);return C(Gy,{anchorEl:Q,scrollContainer:y,onClose:G?k:X,ignoreSelector:G?"[data-annotation-id]":void 0,zIndex:G?"60":"50",padding:G?"10px 12px":"12px",width:"420px",children:[!G&&($??C("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:["“",Z,"”"]},void 0,!0,void 0,this)),C($0,{note:U,onNoteChange:b,images:q,onAddImage:(H)=>T((f)=>[...f,H]),onRemoveImage:(H)=>T((f)=>f.filter((r)=>r!==H)),sessionId:N,autoFocus:!0,autoResize:G,textareaRef:O,onKeyDown:D,attachButton:"none",openFilePickerRef:c,textareaStyle:G?{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),C("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:G?"6px":"8px"},children:[C(D1,{onClick:()=>c.current?.(),size:14},void 0,!1,void 0,this),C("div",{style:{flex:1}},void 0,!1,void 0,this),G?C("button",{onClick:()=>{if(L)L();X()},onMouseEnter:()=>V(!0),onMouseLeave:()=>V(!1),style:{fontSize:"11px",color:E?"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):C(Py,{children:[C("button",{onClick:X,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),C("button",{onClick:I,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),d.length>0&&C("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:e.map((H)=>C("div",{style:{flex:1},children:[C("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:H.label},void 0,!1,void 0,this),H.items.map((f)=>{let r=d.indexOf(f);return C("div",{onMouseDown:(L1)=>{L1.preventDefault(),L1.stopPropagation(),K1(f)},onMouseEnter:()=>v(r),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:r===P?"var(--color-text-primary)":"var(--color-text-secondary)",background:r===P?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[C("span",{style:{fontWeight:500},children:f.slice(0,U.trim().length)},void 0,!1,void 0,this),f.slice(U.trim().length)]},f,!0,void 0,this)})]},H.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function B0({anchorEl:Q,scrollContainer:y,snippet:J,truncateAt:Y,header:$,onAdd:B,onCancel:W}){return C(Uy,{anchorEl:Q,scrollContainer:y,snippet:J,truncateAt:Y,header:$,onConfirm:(K,X)=>B(K,X),onCancel:W},void 0,!1,void 0,this)}import{jsxDEV as F,Fragment as L0}from"react/jsx-dev-runtime";var U1=0.2,k1=0.25,z1=4;function X0({zoom:Q,onZoomIn:y,onZoomOut:J,onZoomReset:Y,onFullscreen:$}){return F("div",{className:"flex items-center gap-0.5 bg-bg-surface border border-border-subtle rounded-md px-1 py-0.5",style:{fontSize:"12px"},children:[F("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:J,title:"Zoom out",disabled:Q<=k1,children:F("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:F("line",{x1:"5",y1:"12",x2:"19",y2:"12"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),F("button",{className:"px-1.5 h-7 rounded hover:bg-bg-elevated text-text-tertiary hover:text-text-primary transition-colors tabular-nums",onClick:Y,title:"Reset zoom",children:[Math.round(Q*100),"%"]},void 0,!0,void 0,this),F("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:y,title:"Zoom in",disabled:Q>=z1,children:F("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[F("line",{x1:"12",y1:"5",x2:"12",y2:"19"},void 0,!1,void 0,this),F("line",{x1:"5",y1:"12",x2:"19",y2:"12"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),$&&F(L0,{children:[F("div",{className:"w-px h-4 bg-border-subtle mx-0.5"},void 0,!1,void 0,this),F("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:$,title:"Fullscreen",children:F("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[F("polyline",{points:"15 3 21 3 21 9"},void 0,!1,void 0,this),F("polyline",{points:"9 21 3 21 3 15"},void 0,!1,void 0,this),F("line",{x1:"21",y1:"3",x2:"14",y2:"10"},void 0,!1,void 0,this),F("line",{x1:"3",y1:"21",x2:"10",y2:"14"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function K0(Q=1){let[y,J]=G1(Q),Y=o(()=>J((W)=>Math.min(z1,+(W+U1).toFixed(2))),[]),$=o(()=>J((W)=>Math.max(k1,+(W-U1).toFixed(2))),[]),B=o(()=>J(1),[]);return{zoom:y,zoomIn:Y,zoomOut:$,zoomReset:B,setZoom:J}}function Ty({svgHtml:Q,source:y,onClose:J}){let Y=H1(null),{zoom:$,zoomIn:B,zoomOut:W,zoomReset:K,setZoom:X}=K0(1),[L,N]=G1({x:0,y:0}),G=H1(null);c1(()=>{let v=(A)=>{if(A.key==="Escape")J()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[J]);let U=o((v)=>{v.preventDefault();let A=v.deltaY>0?-U1:U1;X((S)=>Math.max(k1,Math.min(z1,+(S+A).toFixed(2))))},[X]),b=o((v)=>{if(v.button!==0)return;G.current={startX:v.clientX,startY:v.clientY,panX:L.x,panY:L.y},v.preventDefault()},[L]),q=o((v)=>{if(!G.current)return;N({x:G.current.panX+(v.clientX-G.current.startX),y:G.current.panY+(v.clientY-G.current.startY)})},[]),T=o(()=>{G.current=null},[]),P=o(()=>{K(),N({x:0,y:0})},[K]);return Hy.createPortal(F("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"var(--color-bg-base)",display:"flex",flexDirection:"column"},onMouseMove:q,onMouseUp:T,onMouseLeave:T,children:[F("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border-subtle",style:{flexShrink:0,background:"var(--color-bg-surface)"},children:[F("span",{className:"text-body text-text-secondary",style:{fontSize:"13px"},children:"Mermaid Diagram"},void 0,!1,void 0,this),F("div",{className:"flex items-center gap-2",children:[F(X0,{zoom:$,onZoomIn:B,onZoomOut:W,onZoomReset:P},void 0,!1,void 0,this),F("button",{className:"flex items-center justify-center w-8 h-8 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:J,title:"Close (Esc)",children:F("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[F("line",{x1:"18",y1:"6",x2:"6",y2:"18"},void 0,!1,void 0,this),F("line",{x1:"6",y1:"6",x2:"18",y2:"18"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),F("div",{style:{flex:1,overflow:"hidden",cursor:G.current?"grabbing":"grab"},onWheel:U,onMouseDown:b,children:F("div",{ref:Y,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transform:`translate(${L.x}px, ${L.y}px) scale(${$})`,transformOrigin:"center center",transition:G.current?"none":"transform 0.1s ease-out"},dangerouslySetInnerHTML:{__html:Q}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),document.body)}function Zy({children:Q}){let y=H1(null),[J,Y]=G1(null),[$,B]=G1(!1),[W,K]=G1(""),X=typeof Q==="string"?Q:String(Q??""),{annotations:L,addAnnotationWithId:N,activeAnnotationId:G,setActiveAnnotationId:U}=by(),[b,q]=G1(null),{zoom:T,zoomIn:P,zoomOut:v,zoomReset:A,setZoom:S}=K0(1),E=H1(L);E.current=L;let V=o((k,h,R)=>{let p=`[Diagram ${R.toLowerCase()}] ${h}`,x=E.current.find((e)=>e.snippet===p);if(x)U(x.id);else q({anchorEl:k,snippet:h,prefix:R})},[U]),O=H1(V);O.current=V,c1(()=>{let k=!1,h=async()=>{try{let p=window.mermaid;if(!p){Y("Mermaid library not loaded");return}let x=document.documentElement.dataset.theme==="light"?"default":"dark";p.initialize({startOnLoad:!1,theme:x});let e=`mermaid-${Math.random().toString(36).slice(2)}`,{svg:m}=await p.render(e,X.trim());if(!k&&y.current)y.current.innerHTML=m,K(m),Fy(y.current,(d,u,n)=>O.current(d,u,n)),W0(y.current,E.current);Y(null)}catch(p){if(!k)Y(p.message||"Invalid diagram")}};h();let R=new MutationObserver((p)=>{for(let x of p)if(x.attributeName==="data-theme")h()});return R.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{k=!0,R.disconnect()}},[X]),c1(()=>{if(y.current)W0(y.current,L,G)},[L,G]);let c=o((k)=>{if(!k.ctrlKey&&!k.metaKey)return;k.preventDefault();let h=k.deltaY>0?-U1:U1;S((R)=>Math.max(k1,Math.min(z1,+(R+h).toFixed(2))))},[S]);if(J)return F("div",{className:"bg-accent-red-muted rounded-md p-4 mt-3 text-body text-accent-red",children:["Mermaid error: ",J,F("pre",{className:"mt-2 text-tiny text-text-tertiary whitespace-pre-wrap",children:X},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let I=y.current?.closest("#plan-scroll-container");return F(L0,{children:[F("div",{className:"mt-3 mermaid-container","data-md":"mermaid","data-md-source":X.trim(),children:[F("div",{className:"flex justify-end mb-1",children:F(X0,{zoom:T,onZoomIn:P,onZoomOut:v,onZoomReset:A,onFullscreen:()=>B(!0)},void 0,!1,void 0,this)},void 0,!1,void 0,this),F("div",{style:{overflow:"auto",maxHeight:"70vh"},onWheel:c,children:F("div",{ref:y,className:"flex justify-center",style:{transform:`scale(${T})`,transformOrigin:"top center",transition:"transform 0.1s ease-out",minHeight:T<1?void 0:void 0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b&&F(B0,{anchorEl:b.anchorEl,scrollContainer:I,snippet:b.snippet,header:F("div",{style:{fontSize:"12px",color:"var(--color-text-tertiary)",marginBottom:"8px",lineHeight:"1.4",display:"flex",alignItems:"center",gap:"6px"},children:[F("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:"var(--color-accent-amber)",flexShrink:0}},void 0,!1,void 0,this),b.snippet]},void 0,!0,void 0,this),onAdd:(k,h)=>{let R=`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;N(R,`[Diagram ${b.prefix.toLowerCase()}] ${b.snippet}`,k,void 0,void 0,h),q(null)},onCancel:()=>q(null)},void 0,!1,void 0,this),$&&W&&F(Ty,{svgHtml:W,source:X,onClose:()=>B(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Fy(Q,y){let J=(Y,$,B)=>{Y.style.cursor="pointer",Y.addEventListener("mouseenter",()=>{Y.style.filter="brightness(1.2)"}),Y.addEventListener("mouseleave",()=>{Y.style.filter=""}),Y.addEventListener("click",(W)=>{W.stopPropagation(),W.preventDefault(),y(Y,$(),B)})};for(let Y of Q.querySelectorAll(".node"))J(Y,()=>{return(Y.querySelector(".nodeLabel")||Y.querySelector("foreignObject span")||Y.querySelector("text"))?.textContent?.trim()||"Node"},"Node");for(let Y of Q.querySelectorAll(".edgePath")){let $=Y,B=$.querySelector("path");if(B){B.style.strokeWidth=Math.max(parseFloat(B.style.strokeWidth||"1"),8)+"px",B.style.strokeOpacity="0";let K=B.cloneNode(!0);K.style.strokeWidth="",K.style.strokeOpacity="",$.insertBefore(K,B)}let W=$.id||"";J($,()=>{let K=Q.querySelectorAll(".edgeLabel");for(let X of K)if(X.id&&W&&X.id.replace("label","").includes(W.replace("L-","").replace("edge",""))){let L=X.textContent?.trim();if(L)return L}return"Connection"},"Edge")}for(let Y of Q.querySelectorAll(".edgeLabel")){let $=Y.textContent?.trim();if(!$)continue;J(Y,()=>$,"Edge")}for(let Y of Q.querySelectorAll(".actor")){let $=Y.closest("g")?.querySelector("text")||Y.parentElement?.querySelector("text");if(!$)continue;let B=Y.closest("g");if(!B||B.hasAttribute("data-clickable"))continue;B.setAttribute("data-clickable","true"),J(B,()=>$.textContent?.trim()||"Participant","Node")}for(let Y of Q.querySelectorAll(".messageText")){let $=Y.textContent?.trim();if(!$)continue;J(Y,()=>$,"Edge")}for(let Y of Q.querySelectorAll(".entityBox")){let $=Y.closest("g");if(!$||$.hasAttribute("data-clickable"))continue;let B=$.querySelector(".entityLabel");if(!B)continue;$.setAttribute("data-clickable","true"),J($,()=>B.textContent?.trim()||"Entity","Node")}for(let Y of Q.querySelectorAll(".relationshipLabel")){let $=Y.textContent?.trim();if(!$)continue;let W=Y.closest("g")||Y;if(W.hasAttribute("data-clickable"))continue;W.setAttribute("data-clickable","true"),J(W,()=>$,"Edge")}for(let Y of Q.querySelectorAll(".classGroup")){let $=Y;if($.hasAttribute("data-clickable"))continue;let B=$.querySelector(".classTitle, .classTitleText, text");if(!B)continue;$.setAttribute("data-clickable","true"),J($,()=>B.textContent?.trim()||"Class","Node")}for(let Y of Q.querySelectorAll(".statediagram-state")){let $=Y;if($.hasAttribute("data-clickable"))continue;let B=$.querySelector(".state-title, text");if(!B)continue;$.setAttribute("data-clickable","true"),J($,()=>B.textContent?.trim()||"State","Node")}for(let Y of Q.querySelectorAll(".mindmap-node")){let $=Y;if($.hasAttribute("data-clickable"))continue;let B=$.querySelector(".mindmap-node-label, text");if(!B)continue;$.setAttribute("data-clickable","true"),J($,()=>B.textContent?.trim()||"Node","Node")}}function W0(Q,y,J){let Y=new Map;for(let B of y){let W=B.snippet.match(/^\[Diagram (?:node|edge)\] (.+)$/);if(W)Y.set(W[1],B.id)}for(let B of Q.querySelectorAll("[data-annotated]"))B.style.outline="",B.style.outlineOffset="",B.style.borderRadius="",B.removeAttribute("data-annotated");if(Y.size===0)return;for(let B of Q.querySelectorAll(".node")){let K=(B.querySelector(".nodeLabel")||B.querySelector("foreignObject span")||B.querySelector("text"))?.textContent?.trim();if(!K||!Y.has(K))continue;let X=Y.get(K),L=B;L.setAttribute("data-annotated",X);let N=X===J;L.style.outline=N?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",L.style.outlineOffset="2px",L.style.borderRadius="4px"}for(let B of Q.querySelectorAll(".edgeLabel")){let W=B.textContent?.trim();if(!W||!Y.has(W))continue;let K=Y.get(W),X=B;X.setAttribute("data-annotated",K);let L=K===J;X.style.outline=L?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",X.style.outlineOffset="2px",X.style.borderRadius="4px"}for(let B of Q.querySelectorAll(".actor")){let W=B.closest("g");if(!W)continue;let X=W.querySelector("text")?.textContent?.trim();if(!X||!Y.has(X))continue;if(W.hasAttribute("data-annotated"))continue;let L=Y.get(X);W.setAttribute("data-annotated",L);let N=L===J,G=W.querySelector("rect");if(G)G.style.outline=N?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",G.style.outlineOffset="2px",G.style.borderRadius="4px"}for(let B of Q.querySelectorAll(".messageText")){let W=B.textContent?.trim();if(!W||!Y.has(W))continue;let K=Y.get(W),X=B;X.setAttribute("data-annotated",K);let L=K===J;X.style.outline=L?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",X.style.outlineOffset="2px",X.style.borderRadius="4px"}let $=(B,W,K)=>{for(let X of Q.querySelectorAll(B)){let L=K(X);if(!L||L.hasAttribute("data-annotated"))continue;let G=L.querySelector(W)?.textContent?.trim();if(!G||!Y.has(G))continue;let U=Y.get(G);L.setAttribute("data-annotated",U);let b=U===J,q=L.querySelector("rect, circle, ellipse, polygon")||L;q.style.outline=b?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",q.style.outlineOffset="2px",q.style.borderRadius="4px"}};$(".entityBox",".entityLabel",(B)=>B.closest("g"));for(let B of Q.querySelectorAll(".relationshipLabel")){let K=B.closest("g")||B;if(K.hasAttribute("data-annotated"))continue;let X=B.textContent?.trim();if(!X||!Y.has(X))continue;let L=Y.get(X);K.setAttribute("data-annotated",L);let N=L===J;K.style.outline=N?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",K.style.outlineOffset="2px",K.style.borderRadius="4px"}$(".classGroup",".classTitle, .classTitleText, text",(B)=>B),$(".statediagram-state",".state-title, text",(B)=>B),$(".mindmap-node",".mindmap-node-label, text",(B)=>B)}import{jsxDEV as b1}from"react/jsx-dev-runtime";function fy({before:Q,after:y,language:J}){let Y=Q.split(`
|
|
4
4
|
`),$=y.split(`
|
|
5
|
-
`),B=vy(Y,$),W=[],K=0,X=0,L=0;while(K<Y.length||X<$.length)if(L<B.length&&K<Y.length&&X<$.length&&Y[K]===B[L]&&$[X]===B[L])W.push({type:"same",line:Y[K]}),K++,X++,L++;else if(K<Y.length&&(L>=B.length||Y[K]!==B[L]))W.push({type:"removed",line:Y[K]}),K++;else if(X<$.length)W.push({type:"added",line:$[X]}),X++;return H1("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden group/diff","data-md":"diff","data-md-language":Q||"",children:[Q&&H1("div",{className:"px-4 py-2 text-meta font-mono text-text-tertiary opacity-0 group-hover/diff:opacity-60 transition-opacity",children:["diff (",Q,")"]},void 0,!0,void 0,this),H1("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono",children:W.map((N,G)=>H1("div",{className:N.type==="removed"?"bg-accent-red-muted text-accent-red":N.type==="added"?"bg-accent-green-muted text-accent-green":"text-text-tertiary",children:[H1("span",{className:"select-none w-6 inline-block text-center opacity-60",children:N.type==="removed"?"-":N.type==="added"?"+":" "},void 0,!1,void 0,this),N.line]},G,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function vy(J,y){let Q=J.length,Y=y.length,$=Array.from({length:Q+1},()=>Array(Y+1).fill(0));for(let X=1;X<=Q;X++)for(let L=1;L<=Y;L++)$[X][L]=J[X-1]===y[L-1]?$[X-1][L-1]+1:Math.max($[X-1][L],$[X][L-1]);let B=[],W=Q,K=Y;while(W>0&&K>0)if(J[W-1]===y[K-1])B.unshift(J[W-1]),W--,K--;else if($[W-1][K]>$[W][K-1])W--;else K--;return B}import{useEffect as k1,useRef as G0,useState as U0}from"react";import{useAnnotations as H0}from"#canvas/runtime";import{jsxDEV as q0}from"react/jsx-dev-runtime";function N1({note:J,onChange:y}){return q0("div",{className:"mt-1.5",children:q0("textarea",{value:J,onChange:(Q)=>y(Q.target.value),className:"w-full bg-transparent text-[12px] font-body text-text-primary resize-none focus:outline-none border-none placeholder:text-text-disabled transition-colors min-h-[20px] p-0 leading-relaxed",placeholder:"Add a note...",rows:1,onInput:(Q)=>Q1(Q.target),ref:(Q)=>{if(Q)Q1(Q)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as z}from"react/jsx-dev-runtime";function _y({id:J,label:y,options:Q,required:Y}){let{responses:$,setResponse:B}=H0(),W=$.get(J),K=W?.value,X=W?.note||"",[L,N]=U0(!1),G=G0(null);k1(()=>{if(!$.has(J))B(J,{id:J,type:"radio",label:y,value:null,options:Q,required:Y})},[J]);let H=(q)=>{B(J,{...W,value:q})};k1(()=>{let q=G.current;if(!q)return;let T=(P)=>{let A=P.target.closest("[data-md-label]")?.getAttribute("data-md-label");if(A&&Q.includes(A))H(A)};return q.addEventListener("kb-select",T),()=>q.removeEventListener("kb-select",T)});let b=W?.required&&!K;return z("div",{ref:G,"data-md":"choice","data-md-label":y,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[z("div",{className:"flex items-baseline gap-2 mb-2",children:[z("span",{className:"text-[13px] font-body font-medium text-text-primary",children:y},void 0,!1,void 0,this),Y&&z("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z("div",{className:"space-y-1",children:Q.map((q)=>z("label",{"data-md":"choice-option","data-md-label":q,onClick:()=>H(q),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${K===q?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[z("span",{className:`w-4 h-4 rounded-full border-[1.5px] flex items-center justify-center flex-shrink-0 transition-all ${K===q?"border-accent-amber bg-accent-amber":"border-border-strong"}`,children:K===q&&z("span",{className:"w-1.5 h-1.5 rounded-full bg-text-inverse"},void 0,!1,void 0,this)},void 0,!1,void 0,this),z("span",{className:"text-[13px] font-body text-text-secondary",children:q},void 0,!1,void 0,this)]},q,!0,void 0,this))},void 0,!1,void 0,this),z(N1,{show:L,note:X,onToggle:()=>N(!L),onChange:(q)=>B(J,{...W,note:q})},void 0,!1,void 0,this),b&&z("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select an option."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function wy({id:J,label:y,options:Q,required:Y}){let{responses:$,setResponse:B}=H0(),W=$.get(J),K=W?.value||[],X=W?.note||"",[L,N]=U0(!1),G=G0(null);k1(()=>{if(!$.has(J))B(J,{id:J,type:"checkbox",label:y,value:[],options:Q,required:Y})},[J]);let H=(q)=>{let T=K.includes(q)?K.filter((P)=>P!==q):[...K,q];B(J,{...W,value:T})};k1(()=>{let q=G.current;if(!q)return;let T=(P)=>{let A=P.target.closest("[data-md-label]")?.getAttribute("data-md-label");if(A&&Q.includes(A))H(A)};return q.addEventListener("kb-select",T),()=>q.removeEventListener("kb-select",T)});let b=W?.required&&K.length===0;return z("div",{ref:G,"data-md":"multichoice","data-md-label":y,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[z("div",{className:"flex items-baseline gap-2 mb-2",children:[z("span",{className:"text-[13px] font-body font-medium text-text-primary",children:y},void 0,!1,void 0,this),Y&&z("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z("div",{className:"space-y-1",children:Q.map((q)=>{let T=K.includes(q);return z("label",{"data-md":"multichoice-option","data-md-label":q,onClick:()=>H(q),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${T?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[z("span",{className:`w-4 h-4 rounded flex items-center justify-center flex-shrink-0 transition-all ${T?"bg-accent-amber":"border-[1.5px] border-border-strong"}`,children:T&&z("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:z("path",{d:"M2.5 5L4.5 7L7.5 3",style:{stroke:"var(--color-text-inverse)"},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),z("span",{className:"text-[13px] font-body text-text-secondary",children:q},void 0,!1,void 0,this)]},q,!0,void 0,this)})},void 0,!1,void 0,this),z(N1,{show:L,note:X,onToggle:()=>N(!L),onChange:(q)=>B(J,{...W,note:q})},void 0,!1,void 0,this),b&&z("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select at least one option."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as P0,useRef as My,useState as b0}from"react";import{useAnnotations as T0}from"#canvas/runtime";import{jsxDEV as M}from"react/jsx-dev-runtime";function Ay({id:J,label:y,placeholder:Q,multiline:Y,required:$}){let{responses:B,setResponse:W}=T0(),K=B.get(J),X=K?.value??"",L=K?.note||"",[N,G]=b0(!1),H=My(null);P0(()=>{if(!B.has(J))W(J,{id:J,type:"text",label:y,value:"",required:$})},[J]);let b=(P)=>{W(J,{...K,value:P})},q=(P)=>Q1(P,Y?60:32),T=K?.required&&!X.trim();return M("div",{"data-md":"userinput","data-md-label":y,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[M("div",{className:"flex items-baseline gap-2 mb-2",children:[M("span",{className:"text-[13px] font-body font-medium text-text-primary",children:y},void 0,!1,void 0,this),$&&M("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),M("textarea",{ref:H,value:X,onChange:(P)=>{b(P.target.value),q(P.target)},placeholder:Q||"Type your response...",rows:Y?3:1,className:"w-full bg-bg-input text-[13px] font-body text-text-primary rounded-lg px-3 py-2 resize-none focus:outline-none border border-border-subtle focus:border-border-hover placeholder:text-text-tertiary transition-colors",onInput:(P)=>q(P.target),onFocus:(P)=>q(P.target)},void 0,!1,void 0,this),M(N1,{show:N,note:L,onToggle:()=>G(!N),onChange:(P)=>W(J,{...K,note:P})},void 0,!1,void 0,this),T&&M("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"This field is required."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function fy({id:J,label:y,min:Q=1,max:Y=10,step:$=1,required:B,minLabel:W,maxLabel:K}){let{responses:X,setResponse:L}=T0(),N=X.get(J),G=N?.value,H=N?.note||"",[b,q]=b0(!1);P0(()=>{if(!X.has(J))L(J,{id:J,type:"range",label:y,value:null,required:B})},[J]);let T=(k)=>{L(J,{...N,value:k})},P=G!==null&&G!==void 0,v=P?G:Math.round((Q+Y)/2),A=(v-Q)/(Y-Q)*100,O=Math.round((Y-Q)/$),c=O<=20,V=N?.required&&!P;return M("div",{"data-md":"rangeinput","data-md-label":y,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[M("div",{className:"flex items-baseline justify-between mb-1",children:[M("div",{className:"flex items-baseline gap-2",children:[M("span",{className:"text-[13px] font-body font-medium text-text-primary",children:y},void 0,!1,void 0,this),B&&M("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),M("span",{className:"flex items-center gap-1.5",children:[M("span",{className:`text-[13px] font-mono ${P?"text-accent-amber":"text-text-disabled"}`,children:P?G:"—"},void 0,!1,void 0,this),P&&M("button",{onClick:()=>L(J,{...N,value:null}),className:"text-text-disabled hover:text-text-tertiary transition-colors text-[10px] leading-none",title:"Clear",children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),M("div",{className:"relative h-6 flex items-center",children:[M("div",{className:"absolute left-0 right-0 h-1.5 rounded-full bg-border-medium",children:P&&M("div",{className:"h-full rounded-full bg-accent-amber transition-all duration-150",style:{width:`${A}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),c&&Array.from({length:O+1},(k,D)=>{let S=Q+D*$,f=(S-Q)/(Y-Q)*100,h=P&&S<=G;return M("div",{className:`absolute rounded-full pointer-events-none transition-all duration-150 ${P&&S===G?"w-2.5 h-2.5 bg-accent-amber":h?"w-1.5 h-1.5 bg-accent-amber":"w-1.5 h-1.5 bg-border-hover"}`,style:{left:`${f}%`,transform:"translate(-50%, -50%)",top:"50%"}},D,!1,void 0,this)}),P?M("div",{className:"absolute h-5 w-5 rounded-full bg-accent-amber shadow-md pointer-events-none transition-all duration-150",style:{left:`calc(${A}% - 10px)`,borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this):M("div",{className:"absolute h-4 w-4 rounded-full bg-border-hover pointer-events-none opacity-50",style:{left:"calc(50% - 8px)",borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this),M("input",{type:"range",min:Q,max:Y,step:$,value:v,onChange:(k)=>T(Number(k.target.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c&&O<=10?M("div",{className:"flex justify-between -mt-0.5 px-0",children:Array.from({length:O+1},(k,D)=>{let S=Q+D*$;return M("span",{className:`text-[10px] font-mono transition-colors ${P&&S===G?"text-accent-amber font-medium":"text-text-disabled"}`,style:{minWidth:"1ch",textAlign:"center"},children:S},D,!1,void 0,this)})},void 0,!1,void 0,this):M("div",{className:"flex justify-between -mt-0.5",children:[M("span",{className:"text-[11px] text-text-tertiary font-body",children:W||Q},void 0,!1,void 0,this),M("span",{className:"text-[11px] text-text-tertiary font-body",children:K||Y},void 0,!1,void 0,this)]},void 0,!0,void 0,this),M(N1,{show:b,note:H,onToggle:()=>q(!b),onChange:(k)=>L(J,{...N,note:k})},void 0,!1,void 0,this),V&&M("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select a value."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useContext as zy,useState as ky}from"react";import{SessionContext as Oy}from"#canvas/runtime";import{jsxDEV as P1}from"react/jsx-dev-runtime";function Sy({src:J,alt:y,caption:Q,width:Y,height:$}){let B=zy(Oy),[W,K]=ky(!1),X=`/api/image?session=${encodeURIComponent(B)}&path=${encodeURIComponent(J)}`;if(W)return P1("div",{className:"mt-3 text-accent-red text-body bg-accent-red-muted rounded-md p-4",children:[J,": Failed to load image"]},void 0,!0,void 0,this);return P1("figure",{className:"mt-3 relative","data-md":"image","data-md-src":J,children:[P1("div",{className:"rounded-md overflow-hidden border border-border-subtle bg-bg-code inline-block",children:P1("img",{src:X,alt:y||J,onError:()=>K(!0),className:"block max-w-full h-auto",...Y?{width:Y}:{},...$?{height:$}:{}},void 0,!1,void 0,this)},void 0,!1,void 0,this),Q&&P1("figcaption",{className:"mt-1.5 text-meta text-text-tertiary font-body",children:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useMemo as F5}from"react";function c1(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var W1=c1();function A0(J){W1=J}var Y1={exec:()=>null};function _(J,y=""){let Q=typeof J=="string"?J:J.source,Y={replace:($,B)=>{let W=typeof B=="string"?B:B.source;return W=W.replace(j.caret,"$1"),Q=Q.replace($,W),Y},getRegex:()=>new RegExp(Q,y)};return Y}var Iy=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),j={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:(J)=>new RegExp(`^( {0,3}${J})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:(J)=>new RegExp(`^ {0,${Math.min(3,J-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:(J)=>new RegExp(`^ {0,${Math.min(3,J-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:(J)=>new RegExp(`^ {0,${Math.min(3,J-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:(J)=>new RegExp(`^ {0,${Math.min(3,J-1)}}#`),htmlBeginRegex:(J)=>new RegExp(`^ {0,${Math.min(3,J-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:(J)=>new RegExp(`^ {0,${Math.min(3,J-1)}}>`)},my=/^(?:[ \t]*(?:\n|$))+/,Cy=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ry=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,F1=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,hy=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,E1=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,f0=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,z0=_(f0).replace(/bull/g,E1).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(),gy=_(f0).replace(/bull/g,E1).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(),d1=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,jy=/^[^\n]+/,u1=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Vy=_(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",u1).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),xy=_(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,E1).getRegex(),C1="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",r1=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Dy=_("^ {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",r1).replace("tag",C1).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),k0=_(d1).replace("hr",F1).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",C1).getRegex(),py=_(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",k0).getRegex(),i1={blockquote:py,code:Cy,def:Vy,fences:Ry,heading:hy,hr:F1,html:Dy,lheading:z0,list:xy,newline:my,paragraph:k0,table:Y1,text:jy},Z0=_("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",F1).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",C1).getRegex(),cy={...i1,lheading:gy,table:Z0,paragraph:_(d1).replace("hr",F1).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Z0).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",C1).getRegex()},Ey={...i1,html:_(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",r1).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:Y1,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:_(d1).replace("hr",F1).replace("heading",` *#{1,6} *[^
|
|
6
|
-
]`).replace("lheading",
|
|
7
|
-
`).map((B)=>{let W=B.match(
|
|
8
|
-
`)}var I1=class{options;rules;lexer;constructor(
|
|
9
|
-
`)}}}fences(
|
|
10
|
-
`)}}blockquote(
|
|
5
|
+
`),B=vy(Y,$),W=[],K=0,X=0,L=0;while(K<Y.length||X<$.length)if(L<B.length&&K<Y.length&&X<$.length&&Y[K]===B[L]&&$[X]===B[L])W.push({type:"same",line:Y[K]}),K++,X++,L++;else if(K<Y.length&&(L>=B.length||Y[K]!==B[L]))W.push({type:"removed",line:Y[K]}),K++;else if(X<$.length)W.push({type:"added",line:$[X]}),X++;return b1("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden group/diff","data-md":"diff","data-md-language":J||"",children:[J&&b1("div",{className:"px-4 py-2 text-meta font-mono text-text-tertiary opacity-0 group-hover/diff:opacity-60 transition-opacity",children:["diff (",J,")"]},void 0,!0,void 0,this),b1("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono",children:W.map((N,G)=>b1("div",{className:N.type==="removed"?"bg-accent-red-muted text-accent-red":N.type==="added"?"bg-accent-green-muted text-accent-green":"text-text-tertiary",children:[b1("span",{className:"select-none w-6 inline-block text-center opacity-60",children:N.type==="removed"?"-":N.type==="added"?"+":" "},void 0,!1,void 0,this),N.line]},G,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function vy(Q,y){let J=Q.length,Y=y.length,$=Array.from({length:J+1},()=>Array(Y+1).fill(0));for(let X=1;X<=J;X++)for(let L=1;L<=Y;L++)$[X][L]=Q[X-1]===y[L-1]?$[X-1][L-1]+1:Math.max($[X-1][L],$[X][L-1]);let B=[],W=J,K=Y;while(W>0&&K>0)if(Q[W-1]===y[K-1])B.unshift(Q[W-1]),W--,K--;else if($[W-1][K]>$[W][K-1])W--;else K--;return B}import{useEffect as q0,useRef as G0,useState as U0}from"react";import{useAnnotations as P0}from"#canvas/runtime";import{jsxDEV as N0}from"react/jsx-dev-runtime";function P1({note:Q,onChange:y}){return N0("div",{className:"mt-1.5",children:N0("textarea",{value:Q,onChange:(J)=>y(J.target.value),className:"w-full bg-transparent text-[12px] font-body text-text-primary resize-none focus:outline-none border-none placeholder:text-text-disabled transition-colors min-h-[20px] p-0 leading-relaxed",placeholder:"Add a note...",rows:1,onInput:(J)=>Y1(J.target),ref:(J)=>{if(J)Y1(J)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as z}from"react/jsx-dev-runtime";function _y({id:Q,label:y,options:J,required:Y}){let{responses:$,setResponse:B}=P0(),W=$.get(Q),K=W?.value,X=W?.note||"",[L,N]=U0(!1),G=G0(null);if(!$.has(Q))B(Q,{id:Q,type:"radio",label:y,value:null,options:J,required:Y});let U=(q)=>{B(Q,{...W,value:q})};q0(()=>{let q=G.current;if(!q)return;let T=(P)=>{let A=P.target.closest("[data-md-label]")?.getAttribute("data-md-label");if(A&&J.includes(A))U(A)};return q.addEventListener("kb-select",T),()=>q.removeEventListener("kb-select",T)},[J,U]);let b=W?.required&&!K;return z("div",{ref:G,"data-md":"choice","data-md-label":y,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[z("div",{className:"flex items-baseline gap-2 mb-2",children:[z("span",{className:"text-[13px] font-body font-medium text-text-primary",children:y},void 0,!1,void 0,this),Y&&z("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z("div",{className:"space-y-1",children:J.map((q)=>z("label",{"data-md":"choice-option","data-md-label":q,onClick:()=>U(q),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${K===q?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[z("span",{className:`w-4 h-4 rounded-full border-[1.5px] flex items-center justify-center flex-shrink-0 transition-all ${K===q?"border-accent-amber bg-accent-amber":"border-border-strong"}`,children:K===q&&z("span",{className:"w-1.5 h-1.5 rounded-full bg-text-inverse"},void 0,!1,void 0,this)},void 0,!1,void 0,this),z("span",{className:"text-[13px] font-body text-text-secondary",children:q},void 0,!1,void 0,this)]},q,!0,void 0,this))},void 0,!1,void 0,this),z(P1,{show:L,note:X,onToggle:()=>N(!L),onChange:(q)=>B(Q,{...W,note:q})},void 0,!1,void 0,this),b&&z("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select an option."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function wy({id:Q,label:y,options:J,required:Y}){let{responses:$,setResponse:B}=P0(),W=$.get(Q),K=W?.value||[],X=W?.note||"",[L,N]=U0(!1),G=G0(null);if(!$.has(Q))B(Q,{id:Q,type:"checkbox",label:y,value:[],options:J,required:Y});let U=(q)=>{let T=K.includes(q)?K.filter((P)=>P!==q):[...K,q];B(Q,{...W,value:T})};q0(()=>{let q=G.current;if(!q)return;let T=(P)=>{let A=P.target.closest("[data-md-label]")?.getAttribute("data-md-label");if(A&&J.includes(A))U(A)};return q.addEventListener("kb-select",T),()=>q.removeEventListener("kb-select",T)},[J,U]);let b=W?.required&&K.length===0;return z("div",{ref:G,"data-md":"multichoice","data-md-label":y,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[z("div",{className:"flex items-baseline gap-2 mb-2",children:[z("span",{className:"text-[13px] font-body font-medium text-text-primary",children:y},void 0,!1,void 0,this),Y&&z("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z("div",{className:"space-y-1",children:J.map((q)=>{let T=K.includes(q);return z("label",{"data-md":"multichoice-option","data-md-label":q,onClick:()=>U(q),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${T?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[z("span",{className:`w-4 h-4 rounded flex items-center justify-center flex-shrink-0 transition-all ${T?"bg-accent-amber":"border-[1.5px] border-border-strong"}`,children:T&&z("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:z("path",{d:"M2.5 5L4.5 7L7.5 3",style:{stroke:"var(--color-text-inverse)"},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),z("span",{className:"text-[13px] font-body text-text-secondary",children:q},void 0,!1,void 0,this)]},q,!0,void 0,this)})},void 0,!1,void 0,this),z(P1,{show:L,note:X,onToggle:()=>N(!L),onChange:(q)=>B(Q,{...W,note:q})},void 0,!1,void 0,this),b&&z("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select at least one option."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useRef as My,useState as H0}from"react";import{useAnnotations as b0}from"#canvas/runtime";import{jsxDEV as M}from"react/jsx-dev-runtime";function Ay({id:Q,label:y,placeholder:J,multiline:Y,required:$}){let{responses:B,setResponse:W}=b0(),K=B.get(Q),X=K?.value??"",L=K?.note||"",[N,G]=H0(!1),U=My(null);if(!B.has(Q))W(Q,{id:Q,type:"text",label:y,value:"",required:$});let b=(P)=>{W(Q,{...K,value:P})},q=(P)=>Y1(P,Y?60:32),T=K?.required&&!X.trim();return M("div",{"data-md":"userinput","data-md-label":y,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[M("div",{className:"flex items-baseline gap-2 mb-2",children:[M("span",{className:"text-[13px] font-body font-medium text-text-primary",children:y},void 0,!1,void 0,this),$&&M("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),M("textarea",{ref:U,value:X,onChange:(P)=>{b(P.target.value),q(P.target)},placeholder:J||"Type your response...",rows:Y?3:1,className:"w-full bg-bg-input text-[13px] font-body text-text-primary rounded-lg px-3 py-2 resize-none focus:outline-none border border-border-subtle focus:border-border-hover placeholder:text-text-tertiary transition-colors",onInput:(P)=>q(P.target),onFocus:(P)=>q(P.target)},void 0,!1,void 0,this),M(P1,{show:N,note:L,onToggle:()=>G(!N),onChange:(P)=>W(Q,{...K,note:P})},void 0,!1,void 0,this),T&&M("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"This field is required."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ky({id:Q,label:y,min:J=1,max:Y=10,step:$=1,required:B,minLabel:W,maxLabel:K}){let{responses:X,setResponse:L}=b0(),N=X.get(Q),G=N?.value,U=N?.note||"",[b,q]=H0(!1);if(!X.has(Q))L(Q,{id:Q,type:"range",label:y,value:null,required:B});let T=(O)=>{L(Q,{...N,value:O})},P=G!==null&&G!==void 0,v=P?G:Math.round((J+Y)/2),A=(v-J)/(Y-J)*100,S=Math.round((Y-J)/$),E=S<=20,V=N?.required&&!P;return M("div",{"data-md":"rangeinput","data-md-label":y,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[M("div",{className:"flex items-baseline justify-between mb-1",children:[M("div",{className:"flex items-baseline gap-2",children:[M("span",{className:"text-[13px] font-body font-medium text-text-primary",children:y},void 0,!1,void 0,this),B&&M("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),M("span",{className:"flex items-center gap-1.5",children:[M("span",{className:`text-[13px] font-mono ${P?"text-accent-amber":"text-text-disabled"}`,children:P?G:"—"},void 0,!1,void 0,this),P&&M("button",{onClick:()=>L(Q,{...N,value:null}),className:"text-text-disabled hover:text-text-tertiary transition-colors text-[10px] leading-none",title:"Clear",children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),M("div",{className:"relative h-6 flex items-center",children:[M("div",{className:"absolute left-0 right-0 h-1.5 rounded-full bg-border-medium",children:P&&M("div",{className:"h-full rounded-full bg-accent-amber transition-all duration-150",style:{width:`${A}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),E&&Array.from({length:S+1},(O,c)=>{let I=J+c*$,k=(I-J)/(Y-J)*100,h=P&&I<=G;return M("div",{className:`absolute rounded-full pointer-events-none transition-all duration-150 ${P&&I===G?"w-2.5 h-2.5 bg-accent-amber":h?"w-1.5 h-1.5 bg-accent-amber":"w-1.5 h-1.5 bg-border-hover"}`,style:{left:`${k}%`,transform:"translate(-50%, -50%)",top:"50%"}},c,!1,void 0,this)}),P?M("div",{className:"absolute h-5 w-5 rounded-full bg-accent-amber shadow-md pointer-events-none transition-all duration-150",style:{left:`calc(${A}% - 10px)`,borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this):M("div",{className:"absolute h-4 w-4 rounded-full bg-border-hover pointer-events-none opacity-50",style:{left:"calc(50% - 8px)",borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this),M("input",{type:"range",min:J,max:Y,step:$,value:v,onChange:(O)=>T(Number(O.target.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),E&&S<=10?M("div",{className:"flex justify-between -mt-0.5 px-0",children:Array.from({length:S+1},(O,c)=>{let I=J+c*$;return M("span",{className:`text-[10px] font-mono transition-colors ${P&&I===G?"text-accent-amber font-medium":"text-text-disabled"}`,style:{minWidth:"1ch",textAlign:"center"},children:I},c,!1,void 0,this)})},void 0,!1,void 0,this):M("div",{className:"flex justify-between -mt-0.5",children:[M("span",{className:"text-[11px] text-text-tertiary font-body",children:W||J},void 0,!1,void 0,this),M("span",{className:"text-[11px] text-text-tertiary font-body",children:K||Y},void 0,!1,void 0,this)]},void 0,!0,void 0,this),M(P1,{show:b,note:U,onToggle:()=>q(!b),onChange:(O)=>L(Q,{...N,note:O})},void 0,!1,void 0,this),V&&M("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select a value."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useContext as zy,useState as Oy}from"react";import{SessionContext as Sy}from"#canvas/runtime";import{jsxDEV as T1}from"react/jsx-dev-runtime";function Iy({src:Q,alt:y,caption:J,width:Y,height:$}){let B=zy(Sy),[W,K]=Oy(!1),X=`/api/image?session=${encodeURIComponent(B)}&path=${encodeURIComponent(Q)}`;if(W)return T1("div",{className:"mt-3 text-accent-red text-body bg-accent-red-muted rounded-md p-4",children:[Q,": Failed to load image"]},void 0,!0,void 0,this);return T1("figure",{className:"mt-3 relative","data-md":"image","data-md-src":Q,children:[T1("div",{className:"rounded-md overflow-hidden border border-border-subtle bg-bg-code inline-block",children:T1("img",{src:X,alt:y||Q,onError:()=>K(!0),className:"block max-w-full h-auto",...Y?{width:Y}:{},...$?{height:$}:{}},void 0,!1,void 0,this)},void 0,!1,void 0,this),J&&T1("figcaption",{className:"mt-1.5 text-meta text-text-tertiary font-body",children:J},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useMemo as f5}from"react";function E1(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var X1=E1();function w0(Q){X1=Q}var B1={exec:()=>null};function _(Q,y=""){let J=typeof Q=="string"?Q:Q.source,Y={replace:($,B)=>{let W=typeof B=="string"?B:B.source;return W=W.replace(j.caret,"$1"),J=J.replace($,W),Y},getRegex:()=>new RegExp(J,y)};return Y}var my=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),j={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:(Q)=>new RegExp(`^( {0,3}${Q})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}#`),htmlBeginRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}>`)},Ry=/^(?:[ \t]*(?:\n|$))+/,Cy=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,hy=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,v1=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,gy=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,d1=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,M0=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,A0=_(M0).replace(/bull/g,d1).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(),jy=_(M0).replace(/bull/g,d1).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(),u1=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Vy=/^[^\n]+/,r1=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,xy=_(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",r1).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Dy=_(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,d1).getRegex(),R1="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",i1=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,cy=_("^ {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",i1).replace("tag",R1).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),k0=_(u1).replace("hr",v1).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",R1).getRegex(),py=_(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",k0).getRegex(),l1={blockquote:py,code:Cy,def:xy,fences:hy,heading:gy,hr:v1,html:cy,lheading:A0,list:Dy,newline:Ry,paragraph:k0,table:B1,text:Vy},T0=_("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",v1).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",R1).getRegex(),Ey={...l1,lheading:jy,table:T0,paragraph:_(u1).replace("hr",v1).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",T0).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",R1).getRegex()},dy={...l1,html:_(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",i1).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:B1,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:_(u1).replace("hr",v1).replace("heading",` *#{1,6} *[^
|
|
6
|
+
]`).replace("lheading",A0).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},uy=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ry=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,z0=/^( {2,}|\\)\n(?!\s*$)/,iy=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,C1=/[\p{P}\p{S}]/u,a1=/[\s\p{P}\p{S}]/u,O0=/[^\s\p{P}\p{S}]/u,ly=_(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,a1).getRegex(),S0=/(?!~)[\p{P}\p{S}]/u,ay=/(?!~)[\s\p{P}\p{S}]/u,oy=/(?:[^\s\p{P}\p{S}]|~)/u,I0=/(?![*_])[\p{P}\p{S}]/u,sy=/(?![*_])[\s\p{P}\p{S}]/u,ny=/(?:[^\s\p{P}\p{S}]|[*_])/u,ty=_(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",my?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),m0=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ey=_(m0,"u").replace(/punct/g,C1).getRegex(),y5=_(m0,"u").replace(/punct/g,S0).getRegex(),R0="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",$5=_(R0,"gu").replace(/notPunctSpace/g,O0).replace(/punctSpace/g,a1).replace(/punct/g,C1).getRegex(),J5=_(R0,"gu").replace(/notPunctSpace/g,oy).replace(/punctSpace/g,ay).replace(/punct/g,S0).getRegex(),Q5=_("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,O0).replace(/punctSpace/g,a1).replace(/punct/g,C1).getRegex(),Y5=_(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,I0).getRegex(),B5="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",W5=_(B5,"gu").replace(/notPunctSpace/g,ny).replace(/punctSpace/g,sy).replace(/punct/g,I0).getRegex(),X5=_(/\\(punct)/,"gu").replace(/punct/g,C1).getRegex(),K5=_(/^<(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(),L5=_(i1).replace("(?:-->|$)","-->").getRegex(),N5=_("^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",L5).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),S1=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,q5=_(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",S1).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),C0=_(/^!?\[(label)\]\[(ref)\]/).replace("label",S1).replace("ref",r1).getRegex(),h0=_(/^!?\[(ref)\](?:\[\])?/).replace("ref",r1).getRegex(),G5=_("reflink|nolink(?!\\()","g").replace("reflink",C0).replace("nolink",h0).getRegex(),Z0=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,o1={_backpedal:B1,anyPunctuation:X5,autolink:K5,blockSkip:ty,br:z0,code:ry,del:B1,delLDelim:B1,delRDelim:B1,emStrongLDelim:ey,emStrongRDelimAst:$5,emStrongRDelimUnd:Q5,escape:uy,link:q5,nolink:h0,punctuation:ly,reflink:C0,reflinkSearch:G5,tag:N5,text:iy,url:B1},U5={...o1,link:_(/^!?\[(label)\]\((.*?)\)/).replace("label",S1).getRegex(),reflink:_(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",S1).getRegex()},p1={...o1,emStrongRDelimAst:J5,emStrongLDelim:y5,delLDelim:Y5,delRDelim:W5,url:_(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Z0).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:_(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Z0).getRegex()},P5={...p1,br:_(z0).replace("{2,}","*").getRegex(),text:_(p1.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},O1={normal:l1,gfm:Ey,pedantic:dy},Z1={normal:o1,gfm:p1,breaks:P5,pedantic:U5},H5={"&":"&","<":"<",">":">",'"':""","'":"'"},F0=(Q)=>H5[Q];function s(Q,y){if(y){if(j.escapeTest.test(Q))return Q.replace(j.escapeReplace,F0)}else if(j.escapeTestNoEncode.test(Q))return Q.replace(j.escapeReplaceNoEncode,F0);return Q}function f0(Q){try{Q=encodeURI(Q).replace(j.percentDecode,"%")}catch{return null}return Q}function v0(Q,y){let J=Q.replace(j.findPipe,(B,W,K)=>{let X=!1,L=W;for(;--L>=0&&K[L]==="\\";)X=!X;return X?"|":" |"}),Y=J.split(j.splitPipe),$=0;if(Y[0].trim()||Y.shift(),Y.length>0&&!Y.at(-1)?.trim()&&Y.pop(),y)if(Y.length>y)Y.splice(y);else for(;Y.length<y;)Y.push("");for(;$<Y.length;$++)Y[$]=Y[$].trim().replace(j.slashPipe,"|");return Y}function F1(Q,y,J){let Y=Q.length;if(Y===0)return"";let $=0;for(;$<Y;){let B=Q.charAt(Y-$-1);if(B===y&&!J)$++;else if(B!==y&&J)$++;else break}return Q.slice(0,Y-$)}function b5(Q,y){if(Q.indexOf(y[1])===-1)return-1;let J=0;for(let Y=0;Y<Q.length;Y++)if(Q[Y]==="\\")Y++;else if(Q[Y]===y[0])J++;else if(Q[Y]===y[1]&&(J--,J<0))return Y;return J>0?-2:-1}function T5(Q,y=0){let J=y,Y="";for(let $ of Q)if($==="\t"){let B=4-J%4;Y+=" ".repeat(B),J+=B}else Y+=$,J++;return Y}function _0(Q,y,J,Y,$){let B=y.href,W=y.title||null,K=Q[1].replace($.other.outputLinkReplace,"$1");Y.state.inLink=!0;let X={type:Q[0].charAt(0)==="!"?"image":"link",raw:J,href:B,title:W,text:K,tokens:Y.inlineTokens(K)};return Y.state.inLink=!1,X}function Z5(Q,y,J){let Y=Q.match(J.other.indentCodeCompensation);if(Y===null)return y;let $=Y[1];return y.split(`
|
|
7
|
+
`).map((B)=>{let W=B.match(J.other.beginningSpace);if(W===null)return B;let[K]=W;return K.length>=$.length?B.slice($.length):B}).join(`
|
|
8
|
+
`)}var I1=class{options;rules;lexer;constructor(Q){this.options=Q||X1}space(Q){let y=this.rules.block.newline.exec(Q);if(y&&y[0].length>0)return{type:"space",raw:y[0]}}code(Q){let y=this.rules.block.code.exec(Q);if(y){let J=y[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:y[0],codeBlockStyle:"indented",text:this.options.pedantic?J:F1(J,`
|
|
9
|
+
`)}}}fences(Q){let y=this.rules.block.fences.exec(Q);if(y){let J=y[0],Y=Z5(J,y[3]||"",this.rules);return{type:"code",raw:J,lang:y[2]?y[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):y[2],text:Y}}}heading(Q){let y=this.rules.block.heading.exec(Q);if(y){let J=y[2].trim();if(this.rules.other.endingHash.test(J)){let Y=F1(J,"#");(this.options.pedantic||!Y||this.rules.other.endingSpaceChar.test(Y))&&(J=Y.trim())}return{type:"heading",raw:y[0],depth:y[1].length,text:J,tokens:this.lexer.inline(J)}}}hr(Q){let y=this.rules.block.hr.exec(Q);if(y)return{type:"hr",raw:F1(y[0],`
|
|
10
|
+
`)}}blockquote(Q){let y=this.rules.block.blockquote.exec(Q);if(y){let J=F1(y[0],`
|
|
11
11
|
`).split(`
|
|
12
|
-
`),Y="",$="",B=[];for(;
|
|
12
|
+
`),Y="",$="",B=[];for(;J.length>0;){let W=!1,K=[],X;for(X=0;X<J.length;X++)if(this.rules.other.blockquoteStart.test(J[X]))K.push(J[X]),W=!0;else if(!W)K.push(J[X]);else break;J=J.slice(X);let L=K.join(`
|
|
13
13
|
`),N=L.replace(this.rules.other.blockquoteSetextReplace,`
|
|
14
14
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");Y=Y?`${Y}
|
|
15
15
|
${L}`:L,$=$?`${$}
|
|
16
|
-
${N}`:N;let G=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(N,B,!0),this.lexer.state.top=G,
|
|
17
|
-
`+
|
|
18
|
-
`),T=this.blockquote(q);B[B.length-1]=T,Y=Y.substring(0,Y.length-b.raw.length)+T.raw,$=$.substring(0,$.length-b.text.length)+T.text;break}else if(
|
|
19
|
-
`+
|
|
20
|
-
`),T=this.list(q);B[B.length-1]=T,Y=Y.substring(0,Y.length-
|
|
21
|
-
`);continue}}return{type:"blockquote",raw:Y,tokens:B,text:$}}}list(
|
|
22
|
-
`,1)[0],y[1].length),
|
|
23
|
-
`,1)[0],b=!G.trim(),q=0;if(this.options.pedantic?(q=2,N=G.trimStart()):b?q=y[1].length+1:(q=G.search(this.rules.other.nonSpaceChar),q=q>4?1:q,N=G.slice(q),q+=y[1].length),b&&this.rules.other.blankLine.test(
|
|
24
|
-
`,
|
|
25
|
-
`,1)[0],
|
|
26
|
-
`+
|
|
27
|
-
`+
|
|
28
|
-
`,
|
|
29
|
-
`):[],B={type:"table",raw:y[0],header:[],align:[],rows:[]};if(
|
|
30
|
-
`?y[1].slice(0,-1):y[1];return{type:"paragraph",raw:y[0],text:
|
|
31
|
-
`),this.blockTokens(y,this.tokens);for(let
|
|
32
|
-
`:
|
|
16
|
+
${N}`:N;let G=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(N,B,!0),this.lexer.state.top=G,J.length===0)break;let U=B.at(-1);if(U?.type==="code")break;if(U?.type==="blockquote"){let b=U,q=b.raw+`
|
|
17
|
+
`+J.join(`
|
|
18
|
+
`),T=this.blockquote(q);B[B.length-1]=T,Y=Y.substring(0,Y.length-b.raw.length)+T.raw,$=$.substring(0,$.length-b.text.length)+T.text;break}else if(U?.type==="list"){let b=U,q=b.raw+`
|
|
19
|
+
`+J.join(`
|
|
20
|
+
`),T=this.list(q);B[B.length-1]=T,Y=Y.substring(0,Y.length-U.raw.length)+T.raw,$=$.substring(0,$.length-b.raw.length)+T.raw,J=q.substring(B.at(-1).raw.length).split(`
|
|
21
|
+
`);continue}}return{type:"blockquote",raw:Y,tokens:B,text:$}}}list(Q){let y=this.rules.block.list.exec(Q);if(y){let J=y[1].trim(),Y=J.length>1,$={type:"list",raw:"",ordered:Y,start:Y?+J.slice(0,-1):"",loose:!1,items:[]};J=Y?`\\d{1,9}\\${J.slice(-1)}`:`\\${J}`,this.options.pedantic&&(J=Y?J:"[*+-]");let B=this.rules.other.listItemRegex(J),W=!1;for(;Q;){let X=!1,L="",N="";if(!(y=B.exec(Q))||this.rules.block.hr.test(Q))break;L=y[0],Q=Q.substring(L.length);let G=T5(y[2].split(`
|
|
22
|
+
`,1)[0],y[1].length),U=Q.split(`
|
|
23
|
+
`,1)[0],b=!G.trim(),q=0;if(this.options.pedantic?(q=2,N=G.trimStart()):b?q=y[1].length+1:(q=G.search(this.rules.other.nonSpaceChar),q=q>4?1:q,N=G.slice(q),q+=y[1].length),b&&this.rules.other.blankLine.test(U)&&(L+=U+`
|
|
24
|
+
`,Q=Q.substring(U.length+1),X=!0),!X){let T=this.rules.other.nextBulletRegex(q),P=this.rules.other.hrRegex(q),v=this.rules.other.fencesBeginRegex(q),A=this.rules.other.headingBeginRegex(q),S=this.rules.other.htmlBeginRegex(q),E=this.rules.other.blockquoteBeginRegex(q);for(;Q;){let V=Q.split(`
|
|
25
|
+
`,1)[0],O;if(U=V,this.options.pedantic?(U=U.replace(this.rules.other.listReplaceNesting," "),O=U):O=U.replace(this.rules.other.tabCharGlobal," "),v.test(U)||A.test(U)||S.test(U)||E.test(U)||T.test(U)||P.test(U))break;if(O.search(this.rules.other.nonSpaceChar)>=q||!U.trim())N+=`
|
|
26
|
+
`+O.slice(q);else{if(b||G.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||v.test(G)||A.test(G)||P.test(G))break;N+=`
|
|
27
|
+
`+U}b=!U.trim(),L+=V+`
|
|
28
|
+
`,Q=Q.substring(V.length+1),G=O.slice(q)}}$.loose||(W?$.loose=!0:this.rules.other.doubleBlankLine.test(L)&&(W=!0)),$.items.push({type:"list_item",raw:L,task:!!this.options.gfm&&this.rules.other.listIsTask.test(N),loose:!1,text:N,tokens:[]}),$.raw+=L}let K=$.items.at(-1);if(K)K.raw=K.raw.trimEnd(),K.text=K.text.trimEnd();else return;$.raw=$.raw.trimEnd();for(let X of $.items){if(this.lexer.state.top=!1,X.tokens=this.lexer.blockTokens(X.text,[]),X.task){if(X.text=X.text.replace(this.rules.other.listReplaceTask,""),X.tokens[0]?.type==="text"||X.tokens[0]?.type==="paragraph"){X.tokens[0].raw=X.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),X.tokens[0].text=X.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 L=this.rules.other.listTaskCheckbox.exec(X.raw);if(L){let N={type:"checkbox",raw:L[0]+" ",checked:L[0]!=="[ ]"};X.checked=N.checked,$.loose?X.tokens[0]&&["paragraph","text"].includes(X.tokens[0].type)&&"tokens"in X.tokens[0]&&X.tokens[0].tokens?(X.tokens[0].raw=N.raw+X.tokens[0].raw,X.tokens[0].text=N.raw+X.tokens[0].text,X.tokens[0].tokens.unshift(N)):X.tokens.unshift({type:"paragraph",raw:N.raw,text:N.raw,tokens:[N]}):X.tokens.unshift(N)}}if(!$.loose){let L=X.tokens.filter((G)=>G.type==="space"),N=L.length>0&&L.some((G)=>this.rules.other.anyLine.test(G.raw));$.loose=N}}if($.loose)for(let X of $.items){X.loose=!0;for(let L of X.tokens)L.type==="text"&&(L.type="paragraph")}return $}}html(Q){let y=this.rules.block.html.exec(Q);if(y)return{type:"html",block:!0,raw:y[0],pre:y[1]==="pre"||y[1]==="script"||y[1]==="style",text:y[0]}}def(Q){let y=this.rules.block.def.exec(Q);if(y){let J=y[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),Y=y[2]?y[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",$=y[3]?y[3].substring(1,y[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):y[3];return{type:"def",tag:J,raw:y[0],href:Y,title:$}}}table(Q){let y=this.rules.block.table.exec(Q);if(!y||!this.rules.other.tableDelimiter.test(y[2]))return;let J=v0(y[1]),Y=y[2].replace(this.rules.other.tableAlignChars,"").split("|"),$=y[3]?.trim()?y[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
29
|
+
`):[],B={type:"table",raw:y[0],header:[],align:[],rows:[]};if(J.length===Y.length){for(let W of Y)this.rules.other.tableAlignRight.test(W)?B.align.push("right"):this.rules.other.tableAlignCenter.test(W)?B.align.push("center"):this.rules.other.tableAlignLeft.test(W)?B.align.push("left"):B.align.push(null);for(let W=0;W<J.length;W++)B.header.push({text:J[W],tokens:this.lexer.inline(J[W]),header:!0,align:B.align[W]});for(let W of $)B.rows.push(v0(W,B.header.length).map((K,X)=>({text:K,tokens:this.lexer.inline(K),header:!1,align:B.align[X]})));return B}}lheading(Q){let y=this.rules.block.lheading.exec(Q);if(y)return{type:"heading",raw:y[0],depth:y[2].charAt(0)==="="?1:2,text:y[1],tokens:this.lexer.inline(y[1])}}paragraph(Q){let y=this.rules.block.paragraph.exec(Q);if(y){let J=y[1].charAt(y[1].length-1)===`
|
|
30
|
+
`?y[1].slice(0,-1):y[1];return{type:"paragraph",raw:y[0],text:J,tokens:this.lexer.inline(J)}}}text(Q){let y=this.rules.block.text.exec(Q);if(y)return{type:"text",raw:y[0],text:y[0],tokens:this.lexer.inline(y[0])}}escape(Q){let y=this.rules.inline.escape.exec(Q);if(y)return{type:"escape",raw:y[0],text:y[1]}}tag(Q){let y=this.rules.inline.tag.exec(Q);if(y)return!this.lexer.state.inLink&&this.rules.other.startATag.test(y[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(y[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(y[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(y[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:y[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:y[0]}}link(Q){let y=this.rules.inline.link.exec(Q);if(y){let J=y[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(J)){if(!this.rules.other.endAngleBracket.test(J))return;let B=F1(J.slice(0,-1),"\\");if((J.length-B.length)%2===0)return}else{let B=b5(y[2],"()");if(B===-2)return;if(B>-1){let W=(y[0].indexOf("!")===0?5:4)+y[1].length+B;y[2]=y[2].substring(0,B),y[0]=y[0].substring(0,W).trim(),y[3]=""}}let Y=y[2],$="";if(this.options.pedantic){let B=this.rules.other.pedanticHrefTitle.exec(Y);B&&(Y=B[1],$=B[3])}else $=y[3]?y[3].slice(1,-1):"";return Y=Y.trim(),this.rules.other.startAngleBracket.test(Y)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(J)?Y=Y.slice(1):Y=Y.slice(1,-1)),_0(y,{href:Y&&Y.replace(this.rules.inline.anyPunctuation,"$1"),title:$&&$.replace(this.rules.inline.anyPunctuation,"$1")},y[0],this.lexer,this.rules)}}reflink(Q,y){let J;if((J=this.rules.inline.reflink.exec(Q))||(J=this.rules.inline.nolink.exec(Q))){let Y=(J[2]||J[1]).replace(this.rules.other.multipleSpaceGlobal," "),$=y[Y.toLowerCase()];if(!$){let B=J[0].charAt(0);return{type:"text",raw:B,text:B}}return _0(J,$,J[0],this.lexer,this.rules)}}emStrong(Q,y,J=""){let Y=this.rules.inline.emStrongLDelim.exec(Q);if(!Y||Y[3]&&J.match(this.rules.other.unicodeAlphaNumeric))return;if(!(Y[1]||Y[2])||!J||this.rules.inline.punctuation.exec(J)){let $=[...Y[0]].length-1,B,W,K=$,X=0,L=Y[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(L.lastIndex=0,y=y.slice(-1*Q.length+$);(Y=L.exec(y))!=null;){if(B=Y[1]||Y[2]||Y[3]||Y[4]||Y[5]||Y[6],!B)continue;if(W=[...B].length,Y[3]||Y[4]){K+=W;continue}else if((Y[5]||Y[6])&&$%3&&!(($+W)%3)){X+=W;continue}if(K-=W,K>0)continue;W=Math.min(W,W+K+X);let N=[...Y[0]][0].length,G=Q.slice(0,$+Y.index+N+W);if(Math.min($,W)%2){let b=G.slice(1,-1);return{type:"em",raw:G,text:b,tokens:this.lexer.inlineTokens(b)}}let U=G.slice(2,-2);return{type:"strong",raw:G,text:U,tokens:this.lexer.inlineTokens(U)}}}}codespan(Q){let y=this.rules.inline.code.exec(Q);if(y){let J=y[2].replace(this.rules.other.newLineCharGlobal," "),Y=this.rules.other.nonSpaceChar.test(J),$=this.rules.other.startingSpaceChar.test(J)&&this.rules.other.endingSpaceChar.test(J);return Y&&$&&(J=J.substring(1,J.length-1)),{type:"codespan",raw:y[0],text:J}}}br(Q){let y=this.rules.inline.br.exec(Q);if(y)return{type:"br",raw:y[0]}}del(Q,y,J=""){let Y=this.rules.inline.delLDelim.exec(Q);if(!Y)return;if(!Y[1]||!J||this.rules.inline.punctuation.exec(J)){let $=[...Y[0]].length-1,B,W,K=$,X=this.rules.inline.delRDelim;for(X.lastIndex=0,y=y.slice(-1*Q.length+$);(Y=X.exec(y))!=null;){if(B=Y[1]||Y[2]||Y[3]||Y[4]||Y[5]||Y[6],!B||(W=[...B].length,W!==$))continue;if(Y[3]||Y[4]){K+=W;continue}if(K-=W,K>0)continue;W=Math.min(W,W+K);let L=[...Y[0]][0].length,N=Q.slice(0,$+Y.index+L+W),G=N.slice($,-$);return{type:"del",raw:N,text:G,tokens:this.lexer.inlineTokens(G)}}}}autolink(Q){let y=this.rules.inline.autolink.exec(Q);if(y){let J,Y;return y[2]==="@"?(J=y[1],Y="mailto:"+J):(J=y[1],Y=J),{type:"link",raw:y[0],text:J,href:Y,tokens:[{type:"text",raw:J,text:J}]}}}url(Q){let y;if(y=this.rules.inline.url.exec(Q)){let J,Y;if(y[2]==="@")J=y[0],Y="mailto:"+J;else{let $;do $=y[0],y[0]=this.rules.inline._backpedal.exec(y[0])?.[0]??"";while($!==y[0]);J=y[0],y[1]==="www."?Y="http://"+y[0]:Y=y[0]}return{type:"link",raw:y[0],text:J,href:Y,tokens:[{type:"text",raw:J,text:J}]}}}inlineText(Q){let y=this.rules.inline.text.exec(Q);if(y){let J=this.lexer.state.inRawBlock;return{type:"text",raw:y[0],text:y[0],escaped:J}}}},i=class Q{tokens;options;state;inlineQueue;tokenizer;constructor(y){this.tokens=[],this.tokens.links=Object.create(null),this.options=y||X1,this.options.tokenizer=this.options.tokenizer||new I1,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 J={other:j,block:O1.normal,inline:Z1.normal};this.options.pedantic?(J.block=O1.pedantic,J.inline=Z1.pedantic):this.options.gfm&&(J.block=O1.gfm,this.options.breaks?J.inline=Z1.breaks:J.inline=Z1.gfm),this.tokenizer.rules=J}static get rules(){return{block:O1,inline:Z1}}static lex(y,J){return new Q(J).lex(y)}static lexInline(y,J){return new Q(J).inlineTokens(y)}lex(y){y=y.replace(j.carriageReturn,`
|
|
31
|
+
`),this.blockTokens(y,this.tokens);for(let J=0;J<this.inlineQueue.length;J++){let Y=this.inlineQueue[J];this.inlineTokens(Y.src,Y.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(y,J=[],Y=!1){for(this.options.pedantic&&(y=y.replace(j.tabCharGlobal," ").replace(j.spaceLine,""));y;){let $;if(this.options.extensions?.block?.some((W)=>($=W.call({lexer:this},y,J))?(y=y.substring($.raw.length),J.push($),!0):!1))continue;if($=this.tokenizer.space(y)){y=y.substring($.raw.length);let W=J.at(-1);$.raw.length===1&&W!==void 0?W.raw+=`
|
|
32
|
+
`:J.push($);continue}if($=this.tokenizer.code(y)){y=y.substring($.raw.length);let W=J.at(-1);W?.type==="paragraph"||W?.type==="text"?(W.raw+=(W.raw.endsWith(`
|
|
33
33
|
`)?"":`
|
|
34
34
|
`)+$.raw,W.text+=`
|
|
35
|
-
`+$.text,this.inlineQueue.at(-1).src=W.text):
|
|
35
|
+
`+$.text,this.inlineQueue.at(-1).src=W.text):J.push($);continue}if($=this.tokenizer.fences(y)){y=y.substring($.raw.length),J.push($);continue}if($=this.tokenizer.heading(y)){y=y.substring($.raw.length),J.push($);continue}if($=this.tokenizer.hr(y)){y=y.substring($.raw.length),J.push($);continue}if($=this.tokenizer.blockquote(y)){y=y.substring($.raw.length),J.push($);continue}if($=this.tokenizer.list(y)){y=y.substring($.raw.length),J.push($);continue}if($=this.tokenizer.html(y)){y=y.substring($.raw.length),J.push($);continue}if($=this.tokenizer.def(y)){y=y.substring($.raw.length);let W=J.at(-1);W?.type==="paragraph"||W?.type==="text"?(W.raw+=(W.raw.endsWith(`
|
|
36
36
|
`)?"":`
|
|
37
37
|
`)+$.raw,W.text+=`
|
|
38
|
-
`+$.raw,this.inlineQueue.at(-1).src=W.text):this.tokens.links[$.tag]||(this.tokens.links[$.tag]={href:$.href,title:$.title},
|
|
38
|
+
`+$.raw,this.inlineQueue.at(-1).src=W.text):this.tokens.links[$.tag]||(this.tokens.links[$.tag]={href:$.href,title:$.title},J.push($));continue}if($=this.tokenizer.table(y)){y=y.substring($.raw.length),J.push($);continue}if($=this.tokenizer.lheading(y)){y=y.substring($.raw.length),J.push($);continue}let B=y;if(this.options.extensions?.startBlock){let W=1/0,K=y.slice(1),X;this.options.extensions.startBlock.forEach((L)=>{X=L.call({lexer:this},K),typeof X=="number"&&X>=0&&(W=Math.min(W,X))}),W<1/0&&W>=0&&(B=y.substring(0,W+1))}if(this.state.top&&($=this.tokenizer.paragraph(B))){let W=J.at(-1);Y&&W?.type==="paragraph"?(W.raw+=(W.raw.endsWith(`
|
|
39
39
|
`)?"":`
|
|
40
40
|
`)+$.raw,W.text+=`
|
|
41
|
-
`+$.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=W.text):
|
|
41
|
+
`+$.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=W.text):J.push($),Y=B.length!==y.length,y=y.substring($.raw.length);continue}if($=this.tokenizer.text(y)){y=y.substring($.raw.length);let W=J.at(-1);W?.type==="text"?(W.raw+=(W.raw.endsWith(`
|
|
42
42
|
`)?"":`
|
|
43
43
|
`)+$.raw,W.text+=`
|
|
44
|
-
`+$.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=W.text):
|
|
45
|
-
`;return Y?'<pre><code class="language-'+
|
|
46
|
-
`:"<pre><code>"+(
|
|
47
|
-
`}blockquote({tokens:
|
|
48
|
-
${this.parser.parse(
|
|
49
|
-
`}html({text:
|
|
50
|
-
`}hr(
|
|
51
|
-
`}list(
|
|
44
|
+
`+$.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=W.text):J.push($);continue}if(y){let W="Infinite loop on byte: "+y.charCodeAt(0);if(this.options.silent){console.error(W);break}else throw Error(W)}}return this.state.top=!0,J}inline(y,J=[]){return this.inlineQueue.push({src:y,tokens:J}),J}inlineTokens(y,J=[]){let Y=y,$=null;if(this.tokens.links){let X=Object.keys(this.tokens.links);if(X.length>0)for(;($=this.tokenizer.rules.inline.reflinkSearch.exec(Y))!=null;)X.includes($[0].slice($[0].lastIndexOf("[")+1,-1))&&(Y=Y.slice(0,$.index)+"["+"a".repeat($[0].length-2)+"]"+Y.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;($=this.tokenizer.rules.inline.anyPunctuation.exec(Y))!=null;)Y=Y.slice(0,$.index)+"++"+Y.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let B;for(;($=this.tokenizer.rules.inline.blockSkip.exec(Y))!=null;)B=$[2]?$[2].length:0,Y=Y.slice(0,$.index+B)+"["+"a".repeat($[0].length-B-2)+"]"+Y.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);Y=this.options.hooks?.emStrongMask?.call({lexer:this},Y)??Y;let W=!1,K="";for(;y;){W||(K=""),W=!1;let X;if(this.options.extensions?.inline?.some((N)=>(X=N.call({lexer:this},y,J))?(y=y.substring(X.raw.length),J.push(X),!0):!1))continue;if(X=this.tokenizer.escape(y)){y=y.substring(X.raw.length),J.push(X);continue}if(X=this.tokenizer.tag(y)){y=y.substring(X.raw.length),J.push(X);continue}if(X=this.tokenizer.link(y)){y=y.substring(X.raw.length),J.push(X);continue}if(X=this.tokenizer.reflink(y,this.tokens.links)){y=y.substring(X.raw.length);let N=J.at(-1);X.type==="text"&&N?.type==="text"?(N.raw+=X.raw,N.text+=X.text):J.push(X);continue}if(X=this.tokenizer.emStrong(y,Y,K)){y=y.substring(X.raw.length),J.push(X);continue}if(X=this.tokenizer.codespan(y)){y=y.substring(X.raw.length),J.push(X);continue}if(X=this.tokenizer.br(y)){y=y.substring(X.raw.length),J.push(X);continue}if(X=this.tokenizer.del(y,Y,K)){y=y.substring(X.raw.length),J.push(X);continue}if(X=this.tokenizer.autolink(y)){y=y.substring(X.raw.length),J.push(X);continue}if(!this.state.inLink&&(X=this.tokenizer.url(y))){y=y.substring(X.raw.length),J.push(X);continue}let L=y;if(this.options.extensions?.startInline){let N=1/0,G=y.slice(1),U;this.options.extensions.startInline.forEach((b)=>{U=b.call({lexer:this},G),typeof U=="number"&&U>=0&&(N=Math.min(N,U))}),N<1/0&&N>=0&&(L=y.substring(0,N+1))}if(X=this.tokenizer.inlineText(L)){y=y.substring(X.raw.length),X.raw.slice(-1)!=="_"&&(K=X.raw.slice(-1)),W=!0;let N=J.at(-1);N?.type==="text"?(N.raw+=X.raw,N.text+=X.text):J.push(X);continue}if(y){let N="Infinite loop on byte: "+y.charCodeAt(0);if(this.options.silent){console.error(N);break}else throw Error(N)}}return J}},m1=class{options;parser;constructor(Q){this.options=Q||X1}space(Q){return""}code({text:Q,lang:y,escaped:J}){let Y=(y||"").match(j.notSpaceStart)?.[0],$=Q.replace(j.endingNewline,"")+`
|
|
45
|
+
`;return Y?'<pre><code class="language-'+s(Y)+'">'+(J?$:s($,!0))+`</code></pre>
|
|
46
|
+
`:"<pre><code>"+(J?$:s($,!0))+`</code></pre>
|
|
47
|
+
`}blockquote({tokens:Q}){return`<blockquote>
|
|
48
|
+
${this.parser.parse(Q)}</blockquote>
|
|
49
|
+
`}html({text:Q}){return Q}def(Q){return""}heading({tokens:Q,depth:y}){return`<h${y}>${this.parser.parseInline(Q)}</h${y}>
|
|
50
|
+
`}hr(Q){return`<hr>
|
|
51
|
+
`}list(Q){let{ordered:y,start:J}=Q,Y="";for(let W=0;W<Q.items.length;W++){let K=Q.items[W];Y+=this.listitem(K)}let $=y?"ol":"ul",B=y&&J!==1?' start="'+J+'"':"";return"<"+$+B+`>
|
|
52
52
|
`+Y+"</"+$+`>
|
|
53
|
-
`}listitem(
|
|
54
|
-
`}checkbox({checked:
|
|
55
|
-
`}table(
|
|
53
|
+
`}listitem(Q){return`<li>${this.parser.parse(Q.tokens)}</li>
|
|
54
|
+
`}checkbox({checked:Q}){return"<input "+(Q?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:Q}){return`<p>${this.parser.parseInline(Q)}</p>
|
|
55
|
+
`}table(Q){let y="",J="";for(let $=0;$<Q.header.length;$++)J+=this.tablecell(Q.header[$]);y+=this.tablerow({text:J});let Y="";for(let $=0;$<Q.rows.length;$++){let B=Q.rows[$];J="";for(let W=0;W<B.length;W++)J+=this.tablecell(B[W]);Y+=this.tablerow({text:J})}return Y&&(Y=`<tbody>${Y}</tbody>`),`<table>
|
|
56
56
|
<thead>
|
|
57
57
|
`+y+`</thead>
|
|
58
58
|
`+Y+`</table>
|
|
59
|
-
`}tablerow({text:
|
|
60
|
-
${
|
|
61
|
-
`}tablecell(
|
|
62
|
-
`}strong({tokens:
|
|
63
|
-
Please report this to https://github.com/markedjs/marked.`,
|
|
59
|
+
`}tablerow({text:Q}){return`<tr>
|
|
60
|
+
${Q}</tr>
|
|
61
|
+
`}tablecell(Q){let y=this.parser.parseInline(Q.tokens),J=Q.header?"th":"td";return(Q.align?`<${J} align="${Q.align}">`:`<${J}>`)+y+`</${J}>
|
|
62
|
+
`}strong({tokens:Q}){return`<strong>${this.parser.parseInline(Q)}</strong>`}em({tokens:Q}){return`<em>${this.parser.parseInline(Q)}</em>`}codespan({text:Q}){return`<code>${s(Q,!0)}</code>`}br(Q){return"<br>"}del({tokens:Q}){return`<del>${this.parser.parseInline(Q)}</del>`}link({href:Q,title:y,tokens:J}){let Y=this.parser.parseInline(J),$=f0(Q);if($===null)return Y;Q=$;let B='<a href="'+Q+'"';return y&&(B+=' title="'+s(y)+'"'),B+=">"+Y+"</a>",B}image({href:Q,title:y,text:J,tokens:Y}){Y&&(J=this.parser.parseInline(Y,this.parser.textRenderer));let $=f0(Q);if($===null)return s(J);Q=$;let B=`<img src="${Q}" alt="${s(J)}"`;return y&&(B+=` title="${s(y)}"`),B+=">",B}text(Q){return"tokens"in Q&&Q.tokens?this.parser.parseInline(Q.tokens):("escaped"in Q)&&Q.escaped?Q.text:s(Q.text)}},s1=class{strong({text:Q}){return Q}em({text:Q}){return Q}codespan({text:Q}){return Q}del({text:Q}){return Q}html({text:Q}){return Q}text({text:Q}){return Q}link({text:Q}){return""+Q}image({text:Q}){return""+Q}br(){return""}checkbox({raw:Q}){return Q}},l=class Q{options;renderer;textRenderer;constructor(y){this.options=y||X1,this.options.renderer=this.options.renderer||new m1,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new s1}static parse(y,J){return new Q(J).parse(y)}static parseInline(y,J){return new Q(J).parseInline(y)}parse(y){let J="";for(let Y=0;Y<y.length;Y++){let $=y[Y];if(this.options.extensions?.renderers?.[$.type]){let W=$,K=this.options.extensions.renderers[W.type].call({parser:this},W);if(K!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(W.type)){J+=K||"";continue}}let B=$;switch(B.type){case"space":{J+=this.renderer.space(B);break}case"hr":{J+=this.renderer.hr(B);break}case"heading":{J+=this.renderer.heading(B);break}case"code":{J+=this.renderer.code(B);break}case"table":{J+=this.renderer.table(B);break}case"blockquote":{J+=this.renderer.blockquote(B);break}case"list":{J+=this.renderer.list(B);break}case"checkbox":{J+=this.renderer.checkbox(B);break}case"html":{J+=this.renderer.html(B);break}case"def":{J+=this.renderer.def(B);break}case"paragraph":{J+=this.renderer.paragraph(B);break}case"text":{J+=this.renderer.text(B);break}default:{let W='Token with "'+B.type+'" type was not found.';if(this.options.silent)return console.error(W),"";throw Error(W)}}}return J}parseInline(y,J=this.renderer){let Y="";for(let $=0;$<y.length;$++){let B=y[$];if(this.options.extensions?.renderers?.[B.type]){let K=this.options.extensions.renderers[B.type].call({parser:this},B);if(K!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(B.type)){Y+=K||"";continue}}let W=B;switch(W.type){case"escape":{Y+=J.text(W);break}case"html":{Y+=J.html(W);break}case"link":{Y+=J.link(W);break}case"image":{Y+=J.image(W);break}case"checkbox":{Y+=J.checkbox(W);break}case"strong":{Y+=J.strong(W);break}case"em":{Y+=J.em(W);break}case"codespan":{Y+=J.codespan(W);break}case"br":{Y+=J.br(W);break}case"del":{Y+=J.del(W);break}case"text":{Y+=J.text(W);break}default:{let K='Token with "'+W.type+'" type was not found.';if(this.options.silent)return console.error(K),"";throw Error(K)}}}return Y}},f1=class{options;block;constructor(Q){this.options=Q||X1}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(Q){return Q}postprocess(Q){return Q}processAllTokens(Q){return Q}emStrongMask(Q){return Q}provideLexer(){return this.block?i.lex:i.lexInline}provideParser(){return this.block?l.parse:l.parseInline}},F5=class{defaults=E1();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=l;Renderer=m1;TextRenderer=s1;Lexer=i;Tokenizer=I1;Hooks=f1;constructor(...Q){this.use(...Q)}walkTokens(Q,y){let J=[];for(let Y of Q)switch(J=J.concat(y.call(this,Y)),Y.type){case"table":{let $=Y;for(let B of $.header)J=J.concat(this.walkTokens(B.tokens,y));for(let B of $.rows)for(let W of B)J=J.concat(this.walkTokens(W.tokens,y));break}case"list":{let $=Y;J=J.concat(this.walkTokens($.items,y));break}default:{let $=Y;this.defaults.extensions?.childTokens?.[$.type]?this.defaults.extensions.childTokens[$.type].forEach((B)=>{let W=$[B].flat(1/0);J=J.concat(this.walkTokens(W,y))}):$.tokens&&(J=J.concat(this.walkTokens($.tokens,y)))}}return J}use(...Q){let y=this.defaults.extensions||{renderers:{},childTokens:{}};return Q.forEach((J)=>{let Y={...J};if(Y.async=this.defaults.async||Y.async||!1,J.extensions&&(J.extensions.forEach(($)=>{if(!$.name)throw Error("extension name required");if("renderer"in $){let B=y.renderers[$.name];B?y.renderers[$.name]=function(...W){let K=$.renderer.apply(this,W);return K===!1&&(K=B.apply(this,W)),K}:y.renderers[$.name]=$.renderer}if("tokenizer"in $){if(!$.level||$.level!=="block"&&$.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let B=y[$.level];B?B.unshift($.tokenizer):y[$.level]=[$.tokenizer],$.start&&($.level==="block"?y.startBlock?y.startBlock.push($.start):y.startBlock=[$.start]:$.level==="inline"&&(y.startInline?y.startInline.push($.start):y.startInline=[$.start]))}"childTokens"in $&&$.childTokens&&(y.childTokens[$.name]=$.childTokens)}),Y.extensions=y),J.renderer){let $=this.defaults.renderer||new m1(this.defaults);for(let B in J.renderer){if(!(B in $))throw Error(`renderer '${B}' does not exist`);if(["options","parser"].includes(B))continue;let W=B,K=J.renderer[W],X=$[W];$[W]=(...L)=>{let N=K.apply($,L);return N===!1&&(N=X.apply($,L)),N||""}}Y.renderer=$}if(J.tokenizer){let $=this.defaults.tokenizer||new I1(this.defaults);for(let B in J.tokenizer){if(!(B in $))throw Error(`tokenizer '${B}' does not exist`);if(["options","rules","lexer"].includes(B))continue;let W=B,K=J.tokenizer[W],X=$[W];$[W]=(...L)=>{let N=K.apply($,L);return N===!1&&(N=X.apply($,L)),N}}Y.tokenizer=$}if(J.hooks){let $=this.defaults.hooks||new f1;for(let B in J.hooks){if(!(B in $))throw Error(`hook '${B}' does not exist`);if(["options","block"].includes(B))continue;let W=B,K=J.hooks[W],X=$[W];f1.passThroughHooks.has(B)?$[W]=(L)=>{if(this.defaults.async&&f1.passThroughHooksRespectAsync.has(B))return(async()=>{let G=await K.call($,L);return X.call($,G)})();let N=K.call($,L);return X.call($,N)}:$[W]=(...L)=>{if(this.defaults.async)return(async()=>{let G=await K.apply($,L);return G===!1&&(G=await X.apply($,L)),G})();let N=K.apply($,L);return N===!1&&(N=X.apply($,L)),N}}Y.hooks=$}if(J.walkTokens){let $=this.defaults.walkTokens,B=J.walkTokens;Y.walkTokens=function(W){let K=[];return K.push(B.call(this,W)),$&&(K=K.concat($.call(this,W))),K}}this.defaults={...this.defaults,...Y}}),this}setOptions(Q){return this.defaults={...this.defaults,...Q},this}lexer(Q,y){return i.lex(Q,y??this.defaults)}parser(Q,y){return l.parse(Q,y??this.defaults)}parseMarkdown(Q){return(y,J)=>{let Y={...J},$={...this.defaults,...Y},B=this.onError(!!$.silent,!!$.async);if(this.defaults.async===!0&&Y.async===!1)return B(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 y>"u"||y===null)return B(Error("marked(): input parameter is undefined or null"));if(typeof y!="string")return B(Error("marked(): input parameter is of type "+Object.prototype.toString.call(y)+", string expected"));if($.hooks&&($.hooks.options=$,$.hooks.block=Q),$.async)return(async()=>{let W=$.hooks?await $.hooks.preprocess(y):y,K=await($.hooks?await $.hooks.provideLexer():Q?i.lex:i.lexInline)(W,$),X=$.hooks?await $.hooks.processAllTokens(K):K;$.walkTokens&&await Promise.all(this.walkTokens(X,$.walkTokens));let L=await($.hooks?await $.hooks.provideParser():Q?l.parse:l.parseInline)(X,$);return $.hooks?await $.hooks.postprocess(L):L})().catch(B);try{$.hooks&&(y=$.hooks.preprocess(y));let W=($.hooks?$.hooks.provideLexer():Q?i.lex:i.lexInline)(y,$);$.hooks&&(W=$.hooks.processAllTokens(W)),$.walkTokens&&this.walkTokens(W,$.walkTokens);let K=($.hooks?$.hooks.provideParser():Q?l.parse:l.parseInline)(W,$);return $.hooks&&(K=$.hooks.postprocess(K)),K}catch(W){return B(W)}}}onError(Q,y){return(J)=>{if(J.message+=`
|
|
63
|
+
Please report this to https://github.com/markedjs/marked.`,Q){let Y="<p>An error occurred:</p><pre>"+s(J.message+"",!0)+"</pre>";return y?Promise.resolve(Y):Y}if(y)return Promise.reject(J);throw J}}},W1=new F5;function w(Q,y){return W1.parse(Q,y)}w.options=w.setOptions=function(Q){return W1.setOptions(Q),w.defaults=W1.defaults,w0(w.defaults),w};w.getDefaults=E1;w.defaults=X1;w.use=function(...Q){return W1.use(...Q),w.defaults=W1.defaults,w0(w.defaults),w};w.walkTokens=function(Q,y){return W1.walkTokens(Q,y)};w.parseInline=W1.parseInline;w.Parser=l;w.parser=l.parse;w.Renderer=m1;w.TextRenderer=s1;w.Lexer=i;w.lexer=i.lex;w.Tokenizer=I1;w.Hooks=f1;w.parse=w;var{options:D2,setOptions:c2,use:p2,walkTokens:E2,parseInline:d2}=w;var u2=l.parse,r2=i.lex;import{jsxDEV as g0}from"react/jsx-dev-runtime";w.setOptions({gfm:!0,breaks:!1});function v5({children:Q,file:y,__content:J}){let Y=J??(typeof Q==="string"?Q:String(Q??"")),$=f5(()=>{if(!Y)return"";return w.parse(Y,{async:!1})},[Y]);if(!Y)return g0("div",{className:"text-text-tertiary text-tiny mt-3",children:y?`Could not load: ${y}`:"No markdown content"},void 0,!1,void 0,this);return g0("div",{className:"mt-3 prose-canvas","data-md":"markdown",...y?{"data-md-file":y}:{},"data-md-source":Y,dangerouslySetInnerHTML:{__html:$}},void 0,!1,void 0,this)}import{useFeedback as f4}from"#canvas/runtime";export{f4 as useFeedback,Ay as UserInput,p0 as Task,o0 as Table,V0 as Section,ky as RangeInput,t0 as Priority,l0 as Note,wy as MultiChoice,Zy as Mermaid,v5 as Markdown,n1 as Item,Iy as ImageView,Yy as FilePreview,fy as Diff,u0 as CodeBlock,_y as Choice,s0 as Checklist,i0 as Callout};
|