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