@1agh/maude 1.3.1 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{Component as hQ,createElement as C7,useCallback as v7,useEffect as f,useMemo as fQ,useRef as p,useState as $7}from"react";import{createRoot as pQ}from"react-dom/client";import{useCallback as b,useEffect as S,useMemo as o,useRef as g,useState as u}from"react";function F7(){if(typeof window>"u")return;try{let J=window.location.pathname;if(J==="/_canvas-shell.html"||J==="/_canvas-shell"){let Q=new URLSearchParams(window.location.search),$=Q.get("canvas")??"",Z=(Q.get("designRel")??".design").replace(/^\/+|\/+$/g,"");return $?`${Z}/${$}`:void 0}return decodeURIComponent(J).replace(/^\//,"")}catch{return}}function Z7(J){if(!J)return"";return(J.getAttribute("class")??"").trim().split(/\s+/).filter((Q)=>Q&&!Q.startsWith("dgn-")&&!Q.startsWith("dc-cv-")).join(" ")}function EJ(J,Q){if(!J)return"";let $=(J.innerText||J.textContent||"").replace(/\s+/g," ").trim();return $.length>Q?`${$.slice(0,Q-1)}…`:$}function wJ(J){if(!J)return"";let Q=[],$=J;while($&&$.nodeType===1&&Q.length<8){let Z=$.getAttribute?.("data-dc-element");if(Z){Q.unshift(`[data-dc-element="${Z}"]`);break}let q=$.getAttribute?.("data-dc-screen");if(q){Q.unshift(`[data-dc-screen="${q}"]`);break}let G=$.nodeName.toLowerCase();if($.id){G=`#${$.id}`,Q.unshift(G);break}let z=Z7($).split(/\s+/).filter(Boolean).slice(0,2);if(z.length)G+=`.${z.join(".")}`;let X=1,H=$.previousElementSibling;while(H)X++,H=H.previousElementSibling;G+=`:nth-child(${X})`,Q.unshift(G),$=$.parentElement}return Q.join(" > ")}function f7(J){let Q=[],$=J;while($&&$.nodeType===1&&Q.length<8){let Z=$.nodeName.toLowerCase(),q=$.getAttribute?.("data-dc-element"),G=$.getAttribute?.("data-dc-screen");if(q)Z+=`[data-dc-element="${q}"]`;else if(G)Z+=`[data-dc-screen="${G}"]`;else if($.id)Z+=`#${$.id}`;let z=Z7($).split(/\s+/).filter(Boolean).slice(0,2);if(z.length&&!q&&!G)Z+=`.${z.join(".")}`;Q.unshift(Z),$=$.parentElement}return Q}function TJ(J){return J.replace(/[^a-zA-Z0-9_-]/g,(Q)=>`\\${Q}`)}function p7(J,Q){return Q?`[data-dc-screen="${Q}"] [data-cd-id="${J}"]`:`[data-cd-id="${J}"]`}function u7(J,Q,$){if(!$)return 0;try{let Z=J.querySelectorAll(Q);for(let q=0;q<Z.length;q++)if(Z[q]===$)return q}catch{}return 0}function m7(J,Q,$){if(!Q||!$)return 0;return u7(J,`[data-cd-id="${TJ(Q)}"]`,$)}function P7(J,Q){let $=(Z)=>{try{let q=J.querySelectorAll(Z);if(!q.length)return null;let G=Q.index&&Q.index>0&&Q.index<q.length?Q.index:0;return q[G]??q[0]}catch{return null}};if(Q.id){let Z=$(p7(Q.id,Q.artboardId));if(Z)return Z}if(Q.selector)return $(Q.selector);return null}function bJ(J,Q){let $=0,Z=Math.min(J.length,Q.length);for(let q=1;q<=Z;q++){if(J[J.length-q]!==Q[Q.length-q])break;$++}return $}function d7(J,Q){let $=Q.dom_path,Z=(Q.tag||"").toLowerCase();if(!$||$.length===0||!Z)return null;let q=J;if(Q.artboardId){let H=J.querySelector(`[data-dc-screen="${Q.artboardId}"]`);if(H)q=H}let G=(Q.classes||"").split(/\s+/).filter(Boolean),z=null,X=0;for(let H of Array.from(q.querySelectorAll("[data-cd-id]"))){if(H.tagName.toLowerCase()!==Z)continue;let N=bJ(f7(H),$);if(N===0)continue;let M=Z7(H).split(/\s+/).filter(Boolean),U=G.filter((F)=>M.includes(F)).length,W=N*10+U;if(W>X)X=W,z=H}return z}var h7=["display","flex-direction","flex-wrap","align-items","justify-content","gap","flex","flex-grow","flex-shrink","flex-basis","align-self","font-family","color","font-size","font-weight","line-height","letter-spacing","text-align","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","width","height","min-width","min-height","max-width","max-height","background-color","border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius","border-width","border-style","border-color","box-shadow","opacity","position","top","right","bottom","left","z-index","transform","transform-origin","font-style","text-transform","text-decoration","white-space","overflow","object-fit","aspect-ratio","object-position"],xJ=/^(style|class|data-cd-id|data-dc-|data-dcid$)/;function yJ(J){if(!J||typeof window>"u"||!window.getComputedStyle)return{authored:{},computed:{},customStyles:{},attrs:{}};try{let Q=J.style,$=window.getComputedStyle(J),Z={},q={},G=new Set(h7);for(let W of h7){let F=Q.getPropertyValue(W);if(F)Z[W]=F.trim();let Y=$.getPropertyValue(W);if(Y)q[W]=Y.trim()}let z=/^(margin|padding|border)(-|$)/,X={};for(let W=0;W<Q.length;W++){let F=Q.item(W);if(!F||G.has(F)||z.test(F))continue;let Y=Q.getPropertyValue(F);if(Y)X[F]=Y.trim()}let H={};for(let W of Array.from(J.attributes)){if(xJ.test(W.name))continue;H[W.name]=W.value}if(J.hasAttribute("data-dc-screen")){for(let W of Array.from(J.attributes))if(W.name.startsWith("data-dc-")&&W.name!=="data-dcid")H[W.name]=W.value}let N=J.parentElement,M=N?window.getComputedStyle(N).display:"",U=N&&(M==="flex"||M==="inline-flex")?window.getComputedStyle(N).flexDirection:"";return{authored:Z,computed:q,customStyles:X,attrs:H,parentDisplay:M,parentFlexDirection:U}}catch{return{authored:{},computed:{},customStyles:{},attrs:{}}}}function D7(J,Q){let $=J.el,Z=$&&$.getBoundingClientRect?$.getBoundingClientRect():null,q=J.cdId,G=q?p7(q,J.artboardId):J.artboardId?`[data-dc-screen="${J.artboardId}"]`:wJ($),z=q&&typeof document<"u"?u7(document,G,$):0;return{file:Q??F7(),id:q??void 0,selector:G,artboardId:J.artboardId,index:z,tag:$?.tagName.toLowerCase()??"",classes:Z7($),text:EJ($,240),dom_path:f7($),bounds:Z?{x:Math.round(Z.left),y:Math.round(Z.top),w:Math.round(Z.width),h:Math.round(Z.height)}:null,worldW:$ instanceof HTMLElement?Math.round($.offsetWidth):void 0,worldH:$ instanceof HTMLElement?Math.round($.offsetHeight):void 0,html:$?($.outerHTML??"").slice(0,4000):"",...(()=>{if($?.tagName?.toLowerCase()!=="img")return{};let X=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,H=$.getAttribute?.("data-photo-asset");if(H&&X.test(H))return{photoKind:"artboard-img",photoAsset:H};let N=$.getAttribute?.("src")||"",M=X.exec(N);return M?{photoKind:"artboard-img",photoAsset:M[0]}:{}})(),...yJ($)}}var q7=null;function G7(){if(typeof window>"u")return!1;if(q7===null)try{q7=new URLSearchParams(window.location.search).get("ro")==="1"}catch{q7=!1}return q7}import*as j7 from"lib0/decoding";import*as a from"lib0/encoding";import{createContext as RJ,useCallback as q0,useContext as SJ,useEffect as G0,useMemo as B0,useReducer as W0,useRef as K0,useState as z0}from"react";import{Awareness as X0,applyAwarenessUpdate as H0,encodeAwarenessUpdate as Y0}from"y-protocols/awareness";import{readSyncMessage as P0,writeSyncStep1 as D0,writeUpdate as j0}from"y-protocols/sync";import*as gJ from"yjs";import*as vJ from"yjs";var CJ=new WeakSet;function i7(J){return CJ.add(J),J}var eQ=i7(Object.freeze({maudeOrigin:"shell-edit"})),J0=i7(Object.freeze({maudeOrigin:"sync-agent"}));import{jsx as N0}from"react/jsx-runtime";var hJ=RJ(null);function c7(){return SJ(hJ)}import{createContext as fJ,useCallback as l,useContext as M7,useEffect as pJ,useMemo as uJ,useRef as mJ,useState as dJ}from"react";import{jsx as L7,Fragment as lJ}from"react/jsx-runtime";var B7=fJ(null);function r(J){return J.id?`id:${J.id}`:`sel:${J.selector}`}function l7(J){let Q=[],$=new Set;for(let Z of J){let q=r(Z);if($.has(q))continue;$.add(q),Q.push(Z)}return Q}var iJ=50;function cJ({children:J,postTarget:Q}){let[$,Z]=dJ([]),q=mJ(null),G=l((W)=>{if(q.current)clearTimeout(q.current);q.current=setTimeout(()=>{q.current=null;let F=Q??(typeof window<"u"?window.parent:null);if(!F)return;let Y=W.length===0?null:W.length===1?W[0]??null:W;try{F.postMessage({dgn:"select-set",selection:Y},"*")}catch{}},iJ)},[Q]);pJ(()=>()=>{if(q.current)clearTimeout(q.current)},[]);let z=l((W)=>{let F=l7(Array.isArray(W)?W:[W]);Z(F),G(F)},[G]),X=l((W)=>{let F=Array.isArray(W)?W:[W];Z((Y)=>{let j=l7([...Y,...F]);return G(j),j})},[G]),H=l((W)=>{let F=r(W);Z((Y)=>{let j=Y.filter((_)=>r(_)!==F);return G(j),j})},[G]),N=l((W)=>{let F=r(W);Z((Y)=>{let j=Y.some((_)=>r(_)===F)?Y.filter((_)=>r(_)!==F):[...Y,W];return G(j),j})},[G]),M=l(()=>{Z([]),G([])},[G]),U=uJ(()=>({selected:$,replace:z,add:X,remove:H,toggle:N,clear:M}),[$,z,X,H,N,M]);return L7(B7.Provider,{value:U,children:J})}function r7({children:J}){if(M7(B7))return L7(lJ,{children:J});return L7(cJ,{children:J})}function W7(){let J=M7(B7);if(!J)throw Error("useSelectionSet must be used inside <SelectionSetProvider>");return J}function n7(){return M7(B7)}import{jsx as w,jsxs as y,Fragment as GQ}from"react/jsx-runtime";var rJ="/_client/comments-overlay.css";function nJ(){if(typeof document>"u")return;if(document.getElementById("cm-overlay-css"))return;let J=document.createElement("link");J.id="cm-overlay-css",J.rel="stylesheet",J.href=rJ,document.head.appendChild(J)}function aJ(){if(typeof window>"u")return null;try{let J=window.location.pathname;if(J==="/_canvas-shell.html"||J==="/_canvas-shell"){let Q=new URLSearchParams(window.location.search),$=Q.get("canvas")??"",Z=(Q.get("designRel")??".design").replace(/^\/+|\/+$/g,"");return $?`${Z}/${$}`:null}return decodeURIComponent(J).replace(/^\//,"")}catch{return null}}function oJ(J){if(!J.selector)return null;let Q=null;try{let $=document.querySelectorAll(J.selector),Z=J.index&&J.index>0&&J.index<$.length?J.index:0;Q=$[Z]??$[0]??null}catch{Q=null}if(Q&&J.tag&&Q.tagName.toLowerCase()!==J.tag.toLowerCase())Q=null;if(!Q&&J.dom_path?.length){let $=J.selector.match(/data-dc-screen="([^"]+)"/)?.[1];Q=d7(document,{artboardId:$,tag:J.tag,classes:J.classes,dom_path:J.dom_path})}return Q}function _7(J){let Q=oJ(J);if(!Q?.isConnected)return null;let $=Q.getBoundingClientRect();if($.width===0&&$.height===0)return null;return{x:$.left,y:$.top,w:$.width,h:$.height}}function t7(J,Q){let Z=typeof window<"u"?window.innerWidth:J.x+Q.w,q=typeof window<"u"?window.innerHeight:J.y+Q.h,G=J.x;if(G+Q.w+8>Z){let X=J.x-Q.w;G=X>=8?X:Math.max(8,Z-Q.w-8)}let z=J.y;if(z+Q.h+8>q){let X=J.y-Q.h;z=X>=8?X:Math.max(8,q-Q.h-8)}return{x:G,y:z}}function e7(){nJ();let J=n7(),[Q,$]=u([]),[Z,q]=u(null),[G,z]=u(null),X=o(()=>aJ(),[]);S(()=>{if(typeof document>"u")return;let B=document.getElementById("dgn-pin-layer");if(!B)return;let P=B.style.display;return B.style.display="none",()=>{B.style.display=P}},[]);let H=b((B)=>{if(!J)return;if(!B?.selector){J.clear();return}let P=B.selector.match(/data-cd-id="([^"]+)"/),L=P?P[1]:void 0,A,k;try{let D=document.querySelector(B.selector);if(D)A=D.tagName.toLowerCase(),k=(D.getAttribute("class")??"").split(/\s+/).filter((I)=>I&&!I.startsWith("dgn-")&&!I.startsWith("dc-cv-")).join(" ")}catch{}J.replace({file:X??void 0,id:L,selector:B.selector,tag:A,classes:k,bounds:B.bounds??void 0})},[J,X]),N=g(Q);N.current=Q;let M=c7();S(()=>{if(!M)return;let B=M.doc.getArray("comments"),P=()=>{$(B.toArray())};if(B.length>0)P();return B.observe(P),()=>{try{B.unobserve(P)}catch{}}},[M]),S(()=>{if(typeof window>"u")return;let B=(P)=>{let L=P.data;if(!L||typeof L!=="object"||!L.dgn)return;if(L.dgn==="comments-set"&&Array.isArray(L.comments))$(L.comments);else if(L.dgn==="comment-focus"){let A=typeof L.id==="string"?L.id:null;q(A);let k=A?N.current.find((D)=>D.id===A):void 0;H(k)}};return window.addEventListener("message",B),()=>window.removeEventListener("message",B)},[H]),S(()=>{if(typeof document>"u")return;let B=(P)=>{let L=P.detail;if(!L?.selection)return;z({selection:L.selection,clientX:typeof L.clientX==="number"?L.clientX:0,clientY:typeof L.clientY==="number"?L.clientY:0})};return document.addEventListener("cm:open-composer",B),()=>document.removeEventListener("cm:open-composer",B)},[]);let U=b(()=>{if(z(null),typeof window>"u")return;try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},[]),W=b((B)=>{if(!G)return;let P=G.selection,L={file:P.file,selector:P.selector,index:P.index,dom_path:P.dom_path,tag:P.tag,classes:P.classes,bounds:P.bounds,html_excerpt:P.html,text:B};if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-submit",payload:L},"*")}catch{}U()},[G,U]);S(()=>{if(!X)return;let B=!1;return(async()=>{try{let P=await fetch(`/_comments?file=${encodeURIComponent(X)}`);if(!P.ok)return;let L=await P.json();if(B)return;if(Array.isArray(L.comments))$((A)=>A.length===0?L.comments??[]:A)}catch{}})(),()=>{B=!0}},[X]);let F=o(()=>{return Q.slice().sort((P,L)=>P.created.localeCompare(L.created)).filter((P)=>P.status!=="resolved")},[Q]),Y=o(()=>{let B=new Map;return Q.slice().sort((L,A)=>L.created.localeCompare(A.created)).forEach((L,A)=>{B.set(L.id,A+1)}),B},[Q]),j=b((B)=>{if(q(B),H(Q.find((P)=>P.id===B)),typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-click",id:B},"*")}catch{}},[Q,H]),_=b((B,P)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-patch",id:B,patch:P},"*")}catch{}},[]),V=b((B)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-delete",id:B},"*")}catch{}q((P)=>P===B?null:P)},[]),K=b(async(B,P)=>{if(typeof fetch>"u")return!1;try{let L=await fetch(`/_api/comments/${encodeURIComponent(B)}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:P})});if(!L.ok)return!1;let A=await L.json();return $((k)=>k.map((D)=>D.id===A.id?A:D)),!0}catch{return!1}},[]);return y("div",{className:"cm-layer","aria-hidden":!1,children:[F.map((B)=>{let P=Y.get(B.id)??0;return w(JQ,{comment:B,sequence:P,focused:Z===B.id,onClick:j,onOrphaned:V},B.id)}),G?w(QQ,{state:G,onSubmit:W,onCancel:U}):null,(()=>{if(!Z)return null;let B=F.find((P)=>P.id===Z);if(!B)return null;return w($Q,{comment:B,sequence:Y.get(B.id)??0,onClose:()=>{q(null),J?.clear()},onPatch:(P)=>_(B.id,P),onDelete:()=>V(B.id),onReply:(P)=>K(B.id,P)})})()]})}var N7=null;async function sJ(){if(!N7)N7=(async()=>{try{let J=await fetch("/_api/git-committers");if(!J.ok)return[];let Q=await J.json();return Array.isArray(Q.committers)?Q.committers:[]}catch{return[]}})();return N7}function a7(J){return(J.trim().split(/\s+/)[0]??"").replace(/[^\w.-]/g,"").toLowerCase()}function tJ(J,Q){if(Q<=0||Q>J.length)return null;let $=Q-1;while($>=0){let Z=J[$]??"";if(Z==="@"){let q=$>0?J[$-1]:"";if($===0||/\s/.test(q??"")){let G=J.slice($+1,Q);return{start:$,end:Q,query:G}}return null}if(!/[\w.-]/.test(Z))return null;$-=1}return null}function JJ({className:J,value:Q,onChange:$,onKeyDown:Z,placeholder:q,rows:G,disabled:z,textareaRef:X,ariaLabel:H}){let N=g(null),M=b((D)=>{if(N.current=D,X)X.current=D},[X]),[U,W]=u([]),[F,Y]=u(null),[j,_]=u(0),V=b(()=>{if(U.length>0)return;sJ().then((D)=>W(D))},[U.length]),K=o(()=>{if(!F)return[];let D=F.query.toLowerCase();return(!D?U:U.filter((E)=>E.name.toLowerCase().includes(D)||E.email.toLowerCase().includes(D))).slice(0,8)},[F,U]),B=b((D)=>{let I=D.selectionStart??D.value.length,E=tJ(D.value,I);Y(E),_(0)},[]),P=b((D)=>{$(D.target.value),B(D.target)},[$,B]),L=b((D)=>{if(!F)return;let I=N.current;if(!I)return;let E=`@${a7(D.name)}`,O=`${Q.slice(0,F.start)}${E} ${Q.slice(F.end)}`;$(O),Y(null);let T=F.start+E.length+1;requestAnimationFrame(()=>{I.focus(),I.setSelectionRange(T,T)})},[F,Q,$]),A=b((D)=>{if(F&&K.length>0){if(D.key==="ArrowDown"){D.preventDefault(),_((I)=>(I+1)%K.length);return}if(D.key==="ArrowUp"){D.preventDefault(),_((I)=>(I-1+K.length)%K.length);return}if(D.key==="Enter"||D.key==="Tab"){D.preventDefault();let I=K[j]??K[0];if(I)L(I);return}if(D.key==="Escape"){D.preventDefault(),Y(null);return}}Z?.(D)},[F,K,j,L,Z]),k=b((D)=>{B(D.currentTarget)},[B]);return y("div",{style:{position:"relative"},children:[w("textarea",{ref:M,className:J,value:Q,placeholder:q,rows:G,disabled:z,"aria-label":H,onChange:P,onKeyDown:A,onFocus:V,onSelect:k,onClick:k}),F&&K.length>0?w("ul",{className:"cm-mention-popup",role:"listbox","aria-label":"Mention suggestions",style:{left:0,top:"100%"},children:K.map((D,I)=>{return y("li",{role:"option","aria-selected":I===j,className:"cm-mention-popup__item",onMouseEnter:()=>_(I),onMouseDown:(O)=>{O.preventDefault(),L(D)},children:[y("span",{className:"cm-mention-popup__name",children:["@",a7(D.name)]}),w("span",{className:"cm-mention-popup__email",children:D.email})]},`${D.name}-${D.email}`)})}):null]})}var eJ=3000;function JQ({comment:J,sequence:Q,focused:$,onClick:Z,onOrphaned:q}){let G=g(null),z=g(null),X=g(null);S(()=>{let M=()=>{z.current=null;let U=G.current;if(!U)return;let W=_7(J);if(W)X.current=null;else{if(X.current==null)X.current=Date.now();else if(Date.now()-X.current>eJ)q(J.id);if(J.bounds)W={x:J.bounds.x,y:J.bounds.y,w:J.bounds.w,h:J.bounds.h}}if(!W){U.style.display="none",z.current=requestAnimationFrame(M);return}U.style.display="grid";let F=Math.round(W.x+W.w-12),Y=Math.round(W.y-12);U.style.left=`${F}px`,U.style.top=`${Y}px`,z.current=requestAnimationFrame(M)};return z.current=requestAnimationFrame(M),()=>{if(z.current!=null)cancelAnimationFrame(z.current)}},[J,q]);let H=J.author?.trim()||"unknown",N=`Comment ${Q} by ${H}`;return w("button",{ref:G,type:"button",className:"cm-pin","data-resolved":J.status==="resolved"?"true":"false","data-focused":$?"true":"false","data-comment-pin":J.id,"aria-label":N,"aria-expanded":$,title:J.text.slice(0,200),onClick:(M)=>{M.preventDefault(),M.stopPropagation(),Z(J.id)},children:Q})}function QQ({state:J,onSubmit:Q,onCancel:$}){let[Z,q]=u(""),G=g(null),z=g(null),X=g(null);S(()=>{let U=()=>{X.current=null;let W=z.current;if(!W)return;let F=qQ(J),Y=t7(F,{w:W.offsetWidth,h:W.offsetHeight});W.style.left=`${Math.round(Y.x)}px`,W.style.top=`${Math.round(Y.y)}px`,X.current=requestAnimationFrame(U)};return X.current=requestAnimationFrame(U),()=>{if(X.current!=null)cancelAnimationFrame(X.current)}},[J]),S(()=>{G.current?.focus()},[]);let H=b(()=>{let U=Z.trim();if(!U)return;Q(U)},[Z,Q]),N=b((U)=>{if(U.key==="Escape"){U.preventDefault(),$();return}if((U.metaKey||U.ctrlKey)&&U.key==="Enter")U.preventDefault(),H()},[$,H]),M=o(()=>{let U=J.selection.selector||"";if(!U)return J.selection.tag||"canvas";let W=U.match(/data-cd-id="([^"]+)"/);if(W)return`cd:${W[1]}`;return U.length>36?`${U.slice(0,33)}…`:U},[J.selection]);return y("div",{ref:z,className:"cm-composer",role:"dialog","aria-label":"New comment",onClick:(U)=>U.stopPropagation(),onPointerDown:(U)=>U.stopPropagation(),children:[y("div",{className:"cm-composer__head",children:[w("span",{children:"New comment"}),w("span",{className:"cm-composer__selector",children:M})]}),w(JJ,{textareaRef:G,className:"cm-composer__textarea",value:Z,placeholder:"Type a comment. ⌘↵ to save · Esc to cancel · @name to tag",onChange:q,onKeyDown:N,rows:3,ariaLabel:"Comment body"}),y("div",{className:"cm-composer__actions",children:[w("button",{type:"button",className:"cm-btn",onClick:$,children:"Cancel"}),w("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!Z.trim(),onClick:H,children:"Save"})]})]})}function $Q({comment:J,sequence:Q,onClose:$,onPatch:Z,onDelete:q,onReply:G}){let z=g(null),X=g(null),H=g(null),[N,M]=u(""),[U,W]=u(!1);S(()=>{let V=()=>{H.current=null;let K=z.current;if(!K)return;let B=ZQ(J),P=t7(B,{w:K.offsetWidth,h:K.offsetHeight});K.style.left=`${Math.round(P.x)}px`,K.style.top=`${Math.round(P.y)}px`,H.current=requestAnimationFrame(V)};return H.current=requestAnimationFrame(V),()=>{if(H.current!=null)cancelAnimationFrame(H.current)}},[J]),S(()=>{z.current?.focus();let V=J.id;return()=>{document.querySelector(`[data-comment-pin="${V}"]`)?.focus()}},[J.id]),S(()=>{if(typeof document>"u")return;let V=(K)=>{if(K.key!=="Escape")return;let B=z.current;if(!B)return;if(B.contains(K.target)||document.activeElement===B)K.preventDefault(),$()};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[$]);let F=b(async()=>{let V=N.trim();if(!V||U)return;W(!0);let K=await G(V);if(W(!1),K)M(""),X.current?.focus()},[N,U,G]),Y=b((V)=>{if((V.metaKey||V.ctrlKey)&&V.key==="Enter")V.preventDefault(),F()},[F]),j=`cm-thread-head-${J.id}`,_=VQ(J.selector,"");return y("div",{ref:z,className:"cm-thread",role:"dialog","aria-labelledby":j,tabIndex:-1,onClick:(V)=>V.stopPropagation(),onPointerDown:(V)=>V.stopPropagation(),children:[y("div",{className:"cm-thread__head",id:j,children:[y("div",{className:"cm-thread__head-row",children:[w("span",{className:"cm-thread__seq","aria-hidden":"true",children:Q}),w("span",{className:"cm-thread__author",children:J.author?.trim()||"unknown"}),w("span",{className:"cm-thread__time",children:s7(J.created)}),w("button",{type:"button",className:"cm-thread__close","aria-label":"Close thread",title:"Close · Esc",onClick:$,children:"×"})]}),_?w("code",{className:"cm-thread__selector",children:_}):null]}),w("div",{className:"cm-thread__body",children:o7(J.text)}),(J.thread??[]).map((V)=>y("div",{className:"cm-thread__reply",children:[y("div",{className:"cm-thread__reply-head",children:[w("span",{className:"cm-thread__reply-author",children:V.author?.trim()||"unknown"}),w("span",{className:"cm-thread__reply-time",children:s7(V.created)})]}),w("div",{className:"cm-thread__reply-body",children:o7(V.body)})]},V.id)),!G7()&&y(GQ,{children:[y("div",{className:"cm-thread__reply-form",children:[w(JJ,{textareaRef:X,className:"cm-thread__reply-textarea",value:N,placeholder:"Reply… ⌘↵ to send · @name to tag",onChange:M,onKeyDown:Y,rows:2,ariaLabel:"Reply",disabled:U}),w("div",{className:"cm-thread__reply-actions",children:w("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!N.trim()||U,onClick:()=>void F(),children:"Send"})})]}),y("div",{className:"cm-thread__actions",children:[J.status==="resolved"?w("button",{type:"button",className:"cm-btn",onClick:()=>Z({status:"open"}),children:"↺ Reopen"}):w("button",{type:"button",className:"cm-btn cm-btn--primary",onClick:()=>{Z({status:"resolved"}),$()},children:"✓ Resolve"}),w("button",{type:"button",className:"cm-btn cm-btn--danger",onClick:()=>{q(),$()},children:"Delete"})]})]})]})}function o7(J){if(!J)return null;let Q=/(@[\w][\w.-]*)/g;return J.split(Q).map((Z,q)=>{let G=`${q}:${Z}`;if(q%2===1)return w("strong",{"data-mention":"true",children:Z},G);return w("span",{children:Z},G)})}function s7(J){if(!J)return"";let Q=Date.parse(J);if(!Number.isFinite(Q))return"";let $=Math.round((Date.now()-Q)/1000);if($<60)return`${Math.max($,0)}s ago`;if($<3600)return`${Math.round($/60)}m ago`;if($<86400)return`${Math.round($/3600)}h ago`;return`${Math.round($/86400)}d ago`}function VQ(J,Q){if(!J)return Q;let $=J.match(/data-cd-id="([^"]+)"/);if($)return`cd:${$[1]}`;return J.length>36?`${J.slice(0,33)}…`:J}function ZQ(J){let Q=J.selector?_7(J):null;if(Q)return{x:Q.x+Q.w-12,y:Q.y+16};if(J.bounds)return{x:J.bounds.x+J.bounds.w-12,y:J.bounds.y+16};return{x:16,y:16}}function qQ(J){if(J.clientX||J.clientY)return{x:J.clientX,y:J.clientY+8};if(J.selection.selector){let Q=_7(J.selection);if(Q)return{x:Q.x,y:Q.y+Q.h+8}}return{x:16,y:16}}import{useEffect as BQ}from"react";var WQ=new Set(["pen","highlighter","shape","rect","ellipse","arrow","sticky","text","section","eraser"]);function I7(J){return WQ.has(J)}var s=(J)=>!!(J.metaKey||J.ctrlKey);function t(J){if(J.type==="keydown"){if(J.isEditable)return{kind:"no-op"};if(J.metaKey||J.ctrlKey||J.altKey){if(J.key==="Escape")return{kind:"escape"};let $=(J.key||"").toLowerCase();if(!J.altKey&&(J.metaKey||J.ctrlKey)){if($==="z"&&J.shiftKey)return{kind:"redo"};if($==="z")return{kind:"undo"};if($==="y"&&!J.shiftKey)return{kind:"redo"}}return{kind:"no-op"}}let Q=(J.key||"").toLowerCase();if(Q==="v")return{kind:"tool",tool:"move"};if(Q==="h")return{kind:"tool",tool:"hand"};if(Q==="c")return{kind:"tool",tool:"comment"};if(Q==="b")return{kind:"tool",tool:"pen"};if(Q==="i")return{kind:"tool",tool:"highlighter"};if(Q==="r"||Q==="o")return{kind:"tool",tool:"shape"};if(Q==="a")return{kind:"tool",tool:"arrow"};if(Q==="n")return{kind:"tool",tool:"sticky"};if(Q==="t")return{kind:"tool",tool:"text"};if(Q==="s"&&J.shiftKey)return{kind:"tool",tool:"section"};if(Q==="e")return{kind:"tool",tool:"eraser"};if(J.key==="Escape")return{kind:"escape"};return{kind:"no-op"}}if(J.type==="contextmenu")return{kind:"context-menu",clientX:J.clientX??0,clientY:J.clientY??0};if(J.type==="pointermove"){if(I7(J.activeTool))return{kind:"no-op"};if(J.activeTool==="hand")return{kind:"no-op"};if(J.activeTool==="browse"){if(!s(J))return{kind:"no-op"};return{kind:"hover",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0}}if(J.activeTool==="comment")return{kind:"hover",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0};return{kind:"hover",deep:s(J),clientX:J.clientX??0,clientY:J.clientY??0}}if(J.type==="pointerdown"){if(J.button===2)return{kind:"context-menu",clientX:J.clientX??0,clientY:J.clientY??0};if(J.button===1||J.spaceHeld)return{kind:"no-op"};if(J.button!==0)return{kind:"no-op"};if(I7(J.activeTool)&&!s(J))return{kind:"no-op"};if(J.activeTool==="comment")return{kind:"drop-comment",clientX:J.clientX??0,clientY:J.clientY??0};if(J.activeTool==="hand")return{kind:"no-op"};if(J.activeTool==="browse"){if(!s(J))return{kind:"no-op"};return{kind:"select",mode:J.shiftKey?"add":"replace",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0}}let Q=s(J);return{kind:"select",mode:!!J.shiftKey?"add":"replace",deep:Q,clientX:J.clientX??0,clientY:J.clientY??0}}return{kind:"no-op"}}function K7(J){if(!J||!J.tagName)return!1;let Q=J,$=Q.tagName;if($==="INPUT"||$==="TEXTAREA"||$==="SELECT")return!0;if(Q.isContentEditable)return!0;let Z=Q.getAttribute?.("contenteditable");if(Z==="true"||Z==="plaintext-only"||Z==="")return!0;return!1}function e(J){if(!J||!J.closest)return!1;let Q=J;if(Q.closest(".dc-world"))return!1;return!!Q.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mediaref-player], .dc-tool-palette, .dc-zoom-tb, .dc-mm, .dc-context-menu")}function $J(J){if(!J||typeof J.closest!=="function")return!1;let Q=J;return!!Q.closest("[data-dc-screen]")&&!Q.closest(".dc-artboard-body")}function QJ(J,Q,$){return J.kind==="select"&&!$.metaKey&&!$.ctrlKey&&$J(Q)}function KQ(J,Q,$){return J==="select"&&!$.metaKey&&!$.ctrlKey&&$J(Q)}function VJ(J){let{hostRef:Q,getActiveTool:$,isSpaceHeld:Z,callbacks:q,enabled:G=!0,claimableActions:z}=J;BQ(()=>{if(!G)return;let X=Q.current;if(!X)return;let H=(V)=>z&&V.kind!=="no-op"&&!z.has(V.kind)?{kind:"no-op"}:V,N=(V)=>{switch(V.kind){case"hover":q.onHover?.(V);break;case"select":q.onSelect?.(V);break;case"drop-comment":q.onDropComment?.(V);break;case"context-menu":q.onContextMenu?.(V);break;case"tool":q.onTool?.(V);break;case"escape":q.onEscape?.();break;case"undo":q.onUndo?.();break;case"redo":q.onRedo?.();break;case"no-op":break}},M=(V)=>{let K=H(t({type:"pointermove",button:V.button,metaKey:V.metaKey,ctrlKey:V.ctrlKey,shiftKey:V.shiftKey,altKey:V.altKey,clientX:V.clientX,clientY:V.clientY,spaceHeld:Z?.()??!1,activeTool:$()}));N(K)},U=(V)=>{if(e(V.target))return;if(K7(V.target))return;let K=H(t({type:"pointerdown",button:V.button,metaKey:V.metaKey,ctrlKey:V.ctrlKey,shiftKey:V.shiftKey,altKey:V.altKey,clientX:V.clientX,clientY:V.clientY,spaceHeld:Z?.()??!1,activeTool:$()})),B=QJ(K,V.target,V);if(K.kind!=="no-op"){if(V.preventDefault(),!B)V.stopImmediatePropagation()}N(K)},W=(V)=>{if(e(V.target))return;if(K7(V.target))return;let K=H(t({type:"pointerdown",button:V.button,metaKey:V.metaKey,ctrlKey:V.ctrlKey,shiftKey:V.shiftKey,altKey:V.altKey,clientX:V.clientX,clientY:V.clientY,spaceHeld:Z?.()??!1,activeTool:$()})),B=QJ(K,V.target,V);if(K.kind!=="no-op"){if(V.preventDefault(),!B)V.stopImmediatePropagation();if(K.kind==="select")try{window.focus()}catch{}}},F=(V)=>{if(e(V.target))return;if(K7(V.target))return;let K=$(),B=V.metaKey||V.ctrlKey,P=K==="comment"?"drop-comment":K==="move"&&V.button===0?"select":(I7(K)||K==="browse")&&B&&V.button===0?"select":V.button===2?"context-menu":null;if(P&&(!z||z.has(P))){let L=KQ(P,V.target,V);if(V.preventDefault(),!L)V.stopImmediatePropagation()}},Y=(V)=>{let K=H(t({type:"contextmenu",clientX:V.clientX,clientY:V.clientY,metaKey:V.metaKey,ctrlKey:V.ctrlKey,shiftKey:V.shiftKey,altKey:V.altKey,activeTool:$()}));if(K.kind==="no-op")return;V.preventDefault(),V.stopImmediatePropagation(),N(K)},j=(V)=>{let K=H(t({type:"keydown",key:V.key,metaKey:V.metaKey,ctrlKey:V.ctrlKey,shiftKey:V.shiftKey,altKey:V.altKey,isEditable:K7(V.target),activeTool:$()}));if(K.kind==="tool"||K.kind==="escape"||K.kind==="undo"||K.kind==="redo")V.preventDefault();N(K)};X.addEventListener("pointermove",M,{passive:!0}),X.addEventListener("pointerdown",U,{capture:!0}),X.addEventListener("mousedown",W,{capture:!0}),X.addEventListener("click",F,{capture:!0}),X.addEventListener("contextmenu",Y,{capture:!0});let _=X.ownerDocument??document;return _.addEventListener("keydown",j,!0),()=>{X.removeEventListener("pointermove",M),X.removeEventListener("pointerdown",U,{capture:!0}),X.removeEventListener("mousedown",W,{capture:!0}),X.removeEventListener("click",F,{capture:!0}),X.removeEventListener("contextmenu",Y,{capture:!0}),_.removeEventListener("keydown",j,!0)}},[G,Q,$,Z,q,z])}function A7(J,Q,$,Z){let q=J.elementFromPoint(Q,$);if(!q)return null;if(q.closest?.(".dc-mm, .dc-zoom-tb, .dc-tool-palette, .dc-context-menu, .dc-cv-group-bbox"))return null;let G=q.closest?.("[data-dc-screen]")??null,z=G?.getAttribute("data-dc-screen")??null,X=q.closest?.(".dc-artboard-body")??null;if(!X){if(G&&z)return{el:G,cdId:null,artboardId:z};return null}if(q===X){if(G&&z)return{el:G,cdId:null,artboardId:z};return null}if(Z.deep){let W=q.getAttribute?.("data-cd-id")??null;return{el:q,cdId:W,artboardId:z}}let H=q,N=null;while(H&&H!==X){if(H.hasAttribute?.("data-cd-id"))N=H;H=H.parentElement}let M=N??q,U=M.getAttribute?.("data-cd-id")??null;return{el:M,cdId:U,artboardId:z}}import{useCallback as OQ,useEffect as UJ,useRef as X7}from"react";var zQ=!1;function ZJ(){return zQ}import{createContext as LQ,useCallback as Q7,useContext as KJ,useEffect as w7,useMemo as GJ,useRef as T7,useState as z7}from"react";function m(J,Q,$,Z){return`url("data:image/svg+xml,${encodeURIComponent(J.trim())}") ${Q} ${$}, ${Z}`}var k7="width='24' height='24' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'",E7="#1f1f1f",O7="stroke='#ffffff' stroke-linejoin='round' stroke-linecap='round'";function i(J,Q,$){let Z=$?`<g transform='${$}'>`:"";return`<svg ${k7}>${Z}<path fill='#ffffff' d='${J}'/><path fill='${E7}' d='${Q}'/>${$?"</g>":""}</svg>`}var qJ="translate(0,32) scale(1,-1)",UQ=m(i("M10.25 8.25 L10.05 8.65 10 9 10 23.1 10.05 23.4 10.25 23.75 10.8 24 11.45 23.85 11.6 23.7 11.75 23.45 14.65 19.8 14.85 19.65 14.95 19.5 15.4 19.2 15.95 19.1 21.05 19.1 21.2 19.1 21.35 19.05 21.65 18.9 21.9 18.6 22 18.3 22 17.9 21.9 17.65 21.75 17.35 21.65 17.3 21.55 17.15 11.5 8.25 11.25 8.05 10.95 8 10.6 8.05 10.25 8.25 M9.15 6.6 L9.7 6.25 10 6.15 10.95 6 11.9 6.15 13 6.9 22.9 15.65 23 15.8 23.2 15.95 23.75 16.75 24 17.9 24 18.3 23.9 18.95 23.8 19.25 23.6 19.7 23.1 20.35 22.75 20.6 22.1 20.9 22.05 20.95 22 20.95 21.2 21.1 21.05 21.1 16.2 21.1 16.1 21.25 16.05 21.25 13.4 24.6 13.05 25.15 12.9 25.3 12.55 25.55 Q11.6 26.15 10.55 26 L10.5 26 Q9.65 25.85 9 25.3 L8.45 24.65 8.4 24.5 8.15 24.05 8 23.1 8 9 Q8 8.45 8.15 8.05 L8.25 7.75 8.45 7.35 9.15 6.6","M10.25 8.25 L10.6 8.05 10.95 8 11.25 8.05 11.5 8.25 21.55 17.15 21.65 17.3 21.75 17.35 21.9 17.65 22 17.9 22 18.3 21.9 18.6 21.65 18.9 21.35 19.05 21.2 19.1 21.05 19.1 15.95 19.1 15.4 19.2 14.95 19.5 14.85 19.65 14.65 19.8 11.75 23.45 11.6 23.7 11.45 23.85 10.8 24 10.25 23.75 10.05 23.4 10 23.1 10 9 10.05 8.65 10.25 8.25"),8,5,"default"),XQ=m(i("M28.55 17.8 Q29.4 20.3 28.75 22.8 L28.7 23 28.15 24.55 28.05 24.75 Q26.4 28.2 22.75 29.4 L22.45 29.5 18 29.9 17.75 29.85 Q15.8 29.25 13.8 28.1 L13.45 27.95 Q12 27.05 10.35 26.8 L10.25 26.75 7.9 26.7 7.8 26.7 Q6.1 26.9 4.8 25.8 L4.75 25.8 4.65 25.7 4.6 25.65 Q3.25 24.5 3.05 22.85 L3 22.75 Q2.8 20.95 4 19.5 5.05 18.15 6.75 17.95 L8.4 17.9 7.5 15.55 7.3 15.2 7.2 15 5 10.95 Q3.9 9.15 4.3 7.75 L4.4 7.5 Q4.75 6.15 6.45 5.2 9 3.65 11 5 11.05 4.1 11.5 3.45 12.15 2.1 14.2 1.6 L14.35 1.6 Q18.05 0.6 19.6 4.4 L19.65 4.55 Q20.75 3.65 22.7 3.75 L22.75 3.75 Q26.75 4 27 8.15 L27 8.25 27 8.35 27 8.45 Q26.9 10.75 27.1 12.6 27.15 14.65 28.2 16.75 L28.55 17.8 M26.65 18.4 L26.1 16.8 26.1 16.85 Q24.8 13.7 25 8.35 L25 8.25 Q24.85 5.9 22.6 5.75 20.7 5.65 20.4 7.35 L20.1 7.95 19.5 8.2 18.85 8.05 18.45 7.5 17.75 5.15 Q16.85 2.95 14.7 3.55 L14.65 3.55 Q12.55 4.05 13.15 6.15 L13.85 8.75 13.75 9.45 13.25 9.95 12.55 9.95 12 9.55 10.9 7.7 Q9.5 5.7 7.45 6.9 6.5 7.45 6.25 8.15 6.1 8.9 6.7 9.85 9.2 13.9 10.8 18.65 L10.8 19.3 10.4 19.8 9.75 19.95 Q8.35 19.8 6.95 19.95 6.1 20.05 5.55 20.75 4.9 21.55 5 22.55 5.15 23.55 6 24.2 L6.05 24.25 Q6.75 24.85 7.65 24.7 L7.7 24.7 10.65 24.8 Q12.7 25.15 14.45 26.2 L14.5 26.2 Q16.4 27.35 18.3 27.9 L22.05 27.5 22.1 27.5 Q24.95 26.55 26.25 23.85 L26.8 22.3 Q27.3 20.35 26.65 18.4","M26.65 18.4 Q27.3 20.35 26.8 22.3 L26.25 23.85 Q24.95 26.55 22.1 27.5 L22.05 27.5 18.3 27.9 Q16.4 27.35 14.5 26.2 L14.45 26.2 Q12.7 25.15 10.65 24.8 L7.7 24.7 7.65 24.7 Q6.75 24.85 6.05 24.25 L6 24.2 Q5.15 23.55 5 22.55 4.9 21.55 5.55 20.75 6.1 20.05 6.95 19.95 8.35 19.8 9.75 19.95 L10.4 19.8 10.8 19.3 10.8 18.65 Q9.2 13.9 6.7 9.85 6.1 8.9 6.25 8.15 6.5 7.45 7.45 6.9 9.5 5.7 10.9 7.7 L12 9.55 12.55 9.95 13.25 9.95 13.75 9.45 13.85 8.75 13.15 6.15 Q12.55 4.05 14.65 3.55 L14.7 3.55 Q16.85 2.95 17.75 5.15 L18.45 7.5 18.85 8.05 19.5 8.2 20.1 7.95 20.4 7.35 Q20.7 5.65 22.6 5.75 24.85 5.9 25 8.25 L25 8.35 Q24.8 13.7 26.1 16.85 L26.1 16.8 26.65 18.4"),12,12,"grab"),HQ=m(i("M28 14 Q28 9.85 24.45 6.9 20.95 4 16 4 11.05 4 7.5 6.9 L7.45 7 Q4 9.9 4 14 4 18.15 7.55 21.05 L7.5 21.05 Q9.2 22.45 11.2 23.2 L15.3 27.3 16 27.6 16.7 27.3 20.85 23.2 Q22.7 22.45 24.3 21.15 L24.45 21.05 Q28 18.15 28 14 M25.75 5.35 Q30.05 8.95 30 14 30.05 19.05 25.75 22.6 L25.4 22.85 Q23.8 24.1 22 24.9 L18.1 28.75 18.15 28.75 Q17.2 29.6 16 29.6 14.8 29.6 13.85 28.75 L13.9 28.75 10 24.9 6.6 22.85 6.25 22.6 Q1.95 19.05 2 14 1.95 8.95 6.25 5.35 10.3 2 16 2 21.7 2 25.75 5.35","M28 14 Q28 18.15 24.45 21.05 L24.3 21.15 Q22.7 22.45 20.85 23.2 L16.7 27.3 16 27.6 15.3 27.3 11.2 23.2 Q9.2 22.45 7.5 21.05 L7.55 21.05 Q4 18.15 4 14 4 9.9 7.45 7 L7.5 6.9 Q11.05 4 16 4 20.95 4 24.45 6.9 28 9.85 28 14"),12,21,"crosshair"),YQ=m(i("M4 13.1 L4 6 Q4 5.15 4.6 4.6 5.15 4 6 4 L13.1 4 Q13.95 4 14.55 4.6 L28.65 18.75 Q29.8 19.9 29.75 21.45 L29.75 21.6 29.75 21.7 Q29.75 23.2 28.7 24.35 L24.45 28.65 24.35 28.75 Q23.15 29.85 21.65 29.8 L21.55 29.8 21.4 29.8 Q20.2 29.8 19.25 29.15 L18 29.35 Q16.6 29.4 15.25 28 L15.2 27.95 8.2 20.95 Q7.6 20.35 7.6 19.55 7.6 18.7 8.2 18.1 L4.6 14.5 Q4 13.9 4 13.1 M19.5 26.65 L20.1 27.25 Q20.7 27.85 21.5 27.8 22.35 27.85 23 27.25 L27.25 22.95 Q27.8 22.35 27.75 21.55 27.8 20.75 27.2 20.15 L13.1 6 6 6 6 13.1 12.35 19.45 9.6 19.5 16.65 26.55 Q18.05 28.05 19.5 26.65 M8.05 12.3 L8 8 12.25 8.05 13.8 9.6 9.6 13.85 8.05 12.3 M15.25 11.05 L23 18.8 18.8 23.05 11.05 15.3 15.25 11.05","M15.25 11.05 L11.05 15.3 18.8 23.05 23 18.8 15.25 11.05 M12.35 19.45 L6 13.1 6 6 13.1 6 27.2 20.15 Q27.8 20.75 27.75 21.55 27.8 22.35 27.25 22.95 L23 27.25 Q22.35 27.85 21.5 27.8 20.7 27.85 20.1 27.25 L19.5 26.65 12.35 19.45 M8.05 12.3 L9.6 13.85 13.8 9.6 12.25 8.05 8 8 8.05 12.3",qJ),6,18,"crosshair"),FQ=m(i("M5.15 10.85 Q4 9.65 4 8.1 L4 7.95 4 7.85 Q3.95 6.2 5.1 5.15 6.25 4 7.85 4 L7.95 4 8.1 4 Q9.65 4 10.85 5.15 L11 5.3 14.3 5.25 Q15.15 5.25 15.75 5.85 L29.9 20 Q31 21.15 31 22.75 L31 22.85 31 23 Q31.05 24.5 29.9 25.7 L29.55 25.95 25.65 29.9 25.65 29.95 Q24.45 31.1 22.75 31.1 21.2 31.15 20 29.95 L5.85 15.8 Q5.25 15.2 5.25 14.35 L5.25 10.95 5.15 10.85 M19.95 24.2 L18.55 22.8 22.8 18.55 24.2 19.95 19.95 24.2 M28.45 21.4 L14.3 7.25 10.15 7.3 9.4 6.55 Q8.8 5.95 7.95 6 7.1 5.95 6.5 6.55 5.95 7.1 6 7.95 5.95 8.8 6.55 9.4 L7.25 10.1 7.25 14.35 21.4 28.5 Q22 29.1 22.75 29.1 23.6 29.1 24.2 28.5 L28.45 24.25 Q29.05 23.65 29 22.85 29.05 22 28.45 21.4 M9.25 13.5 L9.25 9.3 13.5 9.25 14.3 10.05 10.05 14.3 9.25 13.5 M17.15 21.4 L11.5 15.75 15.75 11.5 21.4 17.15 17.15 21.4","M17.15 21.4 L21.4 17.15 15.75 11.5 11.5 15.75 17.15 21.4 M28.45 21.4 Q29.05 22 29 22.85 29.05 23.65 28.45 24.25 L24.2 28.5 Q23.6 29.1 22.75 29.1 22 29.1 21.4 28.5 L7.25 14.35 7.25 10.1 6.55 9.4 Q5.95 8.8 6 7.95 5.95 7.1 6.5 6.55 7.1 5.95 7.95 6 8.8 5.95 9.4 6.55 L10.15 7.3 14.3 7.25 28.45 21.4 M19.95 24.2 L24.2 19.95 22.8 18.55 18.55 22.8 19.95 24.2 M9.25 13.5 L10.05 14.3 14.3 10.05 13.5 9.25 9.25 9.3 9.25 13.5",qJ),6,18,"crosshair"),J7=m(i("M17 2 Q18.2 2 19.15 2.9 20 3.8 20 5 L20 12 27 12 Q28.2 12 29.15 12.9 30 13.8 30 15 L30 17 Q30 18.2 29.15 19.15 28.2 20 27 20 L20 20 20 27 Q20 28.2 19.15 29.15 18.2 30 17 30 L15 30 Q13.8 30 12.9 29.15 12 28.2 12 27 L12 20 5 20 Q3.8 20 2.9 19.15 2 18.2 2 17 L2 15 Q2 13.8 2.9 12.9 3.8 12 5 12 L12 12 12 5 Q12 3.8 12.9 2.9 13.8 2 15 2 L17 2 M14 27 L14.3 27.7 Q14.6 28 15 28 L17 28 17.7 27.7 18 27 18 18.05 18.05 18 27 18 Q27.4 18 27.7 17.7 L28 17 28 15 27.7 14.3 Q27.4 14 27 14 L18 14 18 5 17.7 4.3 17 4 15 4 Q14.6 4 14.3 4.3 14 4.6 14 5 L14 14 5 14 Q4.6 14 4.3 14.3 4 14.6 4 15 L4 17 Q4 17.4 4.3 17.7 4.6 18 5 18 L14 18 14 27","M14 27 L14 18 5 18 Q4.6 18 4.3 17.7 4 17.4 4 17 L4 15 Q4 14.6 4.3 14.3 4.6 14 5 14 L14 14 14 5 Q14 4.6 14.3 4.3 14.6 4 15 4 L17 4 17.7 4.3 18 5 18 14 27 14 Q27.4 14 27.7 14.3 L28 15 28 17 27.7 17.7 Q27.4 18 27 18 L18.05 18 18 18.05 18 27 17.7 27.7 17 28 15 28 Q14.6 28 14.3 27.7 L14 27"),12,12,"crosshair"),PQ=m(i("M3.9 11.35 Q2.3 12.5 3.7 13.9 L16.4 26.65 Q17.85 28.05 19.45 26.9 L27.65 21.15 Q29.3 20 27.85 18.6 L15.15 5.85 Q13.75 4.45 12.1 5.6 L3.9 11.35 M1.05 12.4 Q1 10.95 2.75 9.75 L10.95 4 10.95 3.95 Q14 1.85 16.6 4.45 L29.3 17.2 Q30.8 18.65 30.55 20.1 30.55 21.55 28.8 22.8 L20.6 28.55 20.65 28.55 Q17.7 30.65 15 28.1 L15 28.05 2.3 15.3 2.3 15.35 Q0.8 13.85 1.05 12.4 M13.5 7 L19.85 13.35 11.65 19.15 5.3 12.75 13.5 7","M13.5 7 L5.3 12.75 11.65 19.15 19.85 13.35 13.5 7 M3.9 11.35 L12.1 5.6 Q13.75 4.45 15.15 5.85 L27.85 18.6 Q29.3 20 27.65 21.15 L19.45 26.9 Q17.85 28.05 16.4 26.65 L3.7 13.9 Q2.3 12.5 3.9 11.35"),6,14,"cell"),DQ=m(`<svg ${k7}><path d='M16 4V28M11 4H21M11 28H21' fill='none' ${O7} stroke-width='5'/><path d='M16 4V28M11 4H21M11 28H21' fill='none' stroke='${E7}' stroke-width='2.25' stroke-linecap='round'/></svg>`,12,12,"text"),jQ=m(`<svg ${k7}><path d='M6 5H21L26 10V27H6Z' fill='${E7}' ${O7} stroke-width='2.5'/><path d='M21 5V11H26' fill='none' ${O7} stroke-width='2.25'/></svg>`,5,5,"crosshair"),C=Object.freeze({browse:"default",move:UQ,hand:XQ,comment:HQ,pen:YQ,section:J7,highlighter:FQ,shape:J7,rect:J7,ellipse:J7,sticky:jQ,arrow:J7,text:DQ,eraser:PQ});import{jsx as x7,Fragment as AQ}from"react/jsx-runtime";var b7="maude:tool-sync",BJ=Object.freeze({preview:"browse",edit:"move"});function WJ(J){if(J==="browse")return"preview";if(J==="move")return"edit";return null}var MQ=Object.freeze([{id:"browse",label:"Browse",shortcut:"",cursor:C.browse},{id:"move",label:"Select",shortcut:"V",cursor:C.move},{id:"hand",label:"Hand",shortcut:"H",cursor:C.hand},{id:"comment",label:"Comment",shortcut:"C",cursor:C.comment},{id:"pen",label:"Pen",shortcut:"B",cursor:C.pen},{id:"highlighter",label:"Highlighter",shortcut:"I",cursor:C.highlighter},{id:"shape",label:"Shape",shortcut:"R",cursor:C.shape},{id:"sticky",label:"Sticky",shortcut:"N",cursor:C.sticky},{id:"section",label:"Section",shortcut:"⇧S",cursor:C.shape},{id:"arrow",label:"Arrow",shortcut:"A",cursor:C.arrow},{id:"text",label:"Text",shortcut:"T",cursor:C.text},{id:"eraser",label:"Eraser",shortcut:"E",cursor:C.eraser}]),NQ=new Set(["browse","move","hand"]);function _Q(J,Q){return Q?J.filter(($)=>NQ.has($.id)):J}var y7=LQ(null);function IQ({children:J,tools:Q=MQ,initial:$,initialMode:Z}){let q=G7(),G=GJ(()=>_Q(Q,q),[Q,q]),z=$??(q?"browse":"move"),X=Z??WJ(z)??(q?"preview":"edit"),[H,N]=z7(z),[M,U]=z7(X),[W,F]=z7(()=>({tool:null,locked:!1})),Y=Q7((I)=>{if(!G.some((O)=>O.id===I))return;N(I);let E=WJ(I);if(E)U(E);F((O)=>O.locked&&O.tool===I?O:{tool:null,locked:!1})},[G]),j=Q7((I)=>{let E=BJ[I];if(!G.some((O)=>O.id===E))return;U(I),N(E),F((O)=>O.locked&&O.tool===E?O:{tool:null,locked:!1})},[G]),_=Q7(()=>{Y(BJ[M])},[M,Y]),V=Q7((I)=>{F((E)=>{if(E.locked&&E.tool===I)return{tool:null,locked:!1};return{tool:I,locked:!0}}),N(I)},[]),K=Q7(()=>{F({tool:null,locked:!1})},[]),[B,P]=z7("rounded"),L=T7(Math.random().toString(36).slice(2)),A=T7(H);A.current=H;let k=T7(!1);w7(()=>{if(!k.current){k.current=!0;return}if(typeof document>"u")return;document.dispatchEvent(new CustomEvent(b7,{detail:{tool:H,from:L.current}}))},[H]),w7(()=>{if(typeof document>"u")return;let I=(E)=>{let O=E.detail;if(!O||O.from===L.current||typeof O.tool!=="string")return;if(O.tool===A.current)return;Y(O.tool)};return document.addEventListener(b7,I),()=>document.removeEventListener(b7,I)},[Y]),w7(()=>{if(typeof document>"u")return;let I=G.find((T)=>T.id===H);if(!I)return;let E=document.body.style.cursor,O=document.getElementById("dc-tool-cursor");if(!O)O=document.createElement("style"),O.id="dc-tool-cursor",document.head.appendChild(O);if(H==="browse"){if(document.body.style.cursor="",O.textContent="",typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:H},"*")}catch{}return()=>{document.body.style.cursor=E}}if(document.body.style.cursor=I.cursor,O.textContent=`* { cursor: ${I.cursor} !important; }`,typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:H},"*")}catch{}return()=>{document.body.style.cursor=E;let T=document.getElementById("dc-tool-cursor");if(T)T.textContent=""}},[H,G]);let D=GJ(()=>({tool:H,setTool:Y,tools:G,mode:M,setMode:j,resetTool:_,sticky:W,toggleSticky:V,clearSticky:K,shapeKind:B,setShapeKind:P}),[H,Y,G,M,j,_,W,V,K,B]);return x7(y7.Provider,{value:D,children:J})}function zJ({children:J,initial:Q,initialMode:$}){if(KJ(y7))return x7(AQ,{children:J});return x7(IQ,{initial:Q,initialMode:$,children:J})}function U7(){let J=KJ(y7);if(!J)throw Error("useToolMode must be used inside <ToolProvider>");return J}import{jsx as gQ}from"react/jsx-runtime";var kQ=`
1
+ import{Component as pQ,createElement as R7,useCallback as C7,useEffect as p,useMemo as uQ,useRef as u,useState as V7}from"react";import{createRoot as mQ}from"react-dom/client";import{useCallback as b,useEffect as S,useMemo as s,useRef as g,useState as h}from"react";function F7(){if(typeof window>"u")return;try{let J=window.location.pathname;if(J==="/_canvas-shell.html"||J==="/_canvas-shell"){let Q=new URLSearchParams(window.location.search),$=Q.get("canvas")??"",V=(Q.get("designRel")??".design").replace(/^\/+|\/+$/g,"");return $?`${V}/${$}`:void 0}return decodeURIComponent(J).replace(/^\//,"")}catch{return}}function q7(J){if(!J)return"";return(J.getAttribute("class")??"").trim().split(/\s+/).filter((Q)=>Q&&!Q.startsWith("dgn-")&&!Q.startsWith("dc-cv-")).join(" ")}function wJ(J,Q){if(!J)return"";let $=(J.innerText||J.textContent||"").replace(/\s+/g," ").trim();return $.length>Q?`${$.slice(0,Q-1)}…`:$}function TJ(J){if(!J)return"";let Q=[],$=J;while($&&$.nodeType===1&&Q.length<8){let V=$.getAttribute?.("data-dc-element");if(V){Q.unshift(`[data-dc-element="${V}"]`);break}let Z=$.getAttribute?.("data-dc-screen");if(Z){Q.unshift(`[data-dc-screen="${Z}"]`);break}let G=$.nodeName.toLowerCase();if($.id){G=`#${$.id}`,Q.unshift(G);break}let z=q7($).split(/\s+/).filter(Boolean).slice(0,2);if(z.length)G+=`.${z.join(".")}`;let K=1,H=$.previousElementSibling;while(H)K++,H=H.previousElementSibling;G+=`:nth-child(${K})`,Q.unshift(G),$=$.parentElement}return Q.join(" > ")}function p7(J){let Q=[],$=J;while($&&$.nodeType===1&&Q.length<8){let V=$.nodeName.toLowerCase(),Z=$.getAttribute?.("data-dc-element"),G=$.getAttribute?.("data-dc-screen");if(Z)V+=`[data-dc-element="${Z}"]`;else if(G)V+=`[data-dc-screen="${G}"]`;else if($.id)V+=`#${$.id}`;let z=q7($).split(/\s+/).filter(Boolean).slice(0,2);if(z.length&&!Z&&!G)V+=`.${z.join(".")}`;Q.unshift(V),$=$.parentElement}return Q}function bJ(J){return J.replace(/[^a-zA-Z0-9_-]/g,(Q)=>`\\${Q}`)}function u7(J,Q){return Q?`[data-dc-screen="${Q}"] [data-cd-id="${J}"]`:`[data-cd-id="${J}"]`}function m7(J,Q,$){if(!$)return 0;try{let V=J.querySelectorAll(Q);for(let Z=0;Z<V.length;Z++)if(V[Z]===$)return Z}catch{}return 0}function d7(J,Q,$){if(!Q||!$)return 0;return m7(J,`[data-cd-id="${bJ(Q)}"]`,$)}function P7(J,Q){let $=(V)=>{try{let Z=J.querySelectorAll(V);if(!Z.length)return null;let G=Q.index&&Q.index>0&&Q.index<Z.length?Q.index:0;return Z[G]??Z[0]}catch{return null}};if(Q.id){let V=$(u7(Q.id,Q.artboardId));if(V)return V}if(Q.selector)return $(Q.selector);return null}function xJ(J,Q){let $=0,V=Math.min(J.length,Q.length);for(let Z=1;Z<=V;Z++){if(J[J.length-Z]!==Q[Q.length-Z])break;$++}return $}function i7(J,Q){let $=Q.dom_path,V=(Q.tag||"").toLowerCase();if(!$||$.length===0||!V)return null;let Z=J;if(Q.artboardId){let H=J.querySelector(`[data-dc-screen="${Q.artboardId}"]`);if(H)Z=H}let G=(Q.classes||"").split(/\s+/).filter(Boolean),z=null,K=0;for(let H of Array.from(Z.querySelectorAll("[data-cd-id]"))){if(H.tagName.toLowerCase()!==V)continue;let j=xJ(p7(H),$);if(j===0)continue;let N=q7(H).split(/\s+/).filter(Boolean),U=G.filter((P)=>N.includes(P)).length,B=j*10+U;if(B>K)K=B,z=H}return z}var f7=["display","flex-direction","flex-wrap","align-items","justify-content","gap","flex","flex-grow","flex-shrink","flex-basis","align-self","font-family","color","font-size","font-weight","line-height","letter-spacing","text-align","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","width","height","min-width","min-height","max-width","max-height","background-color","border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius","border-width","border-style","border-color","box-shadow","opacity","position","top","right","bottom","left","z-index","transform","transform-origin","font-style","text-transform","text-decoration","white-space","overflow","object-fit","aspect-ratio","object-position"],yJ=/^(style|class|data-cd-id|data-dc-|data-dcid$)/;function vJ(J){if(!J||typeof window>"u"||!window.getComputedStyle)return{authored:{},computed:{},customStyles:{},attrs:{}};try{let Q=J.style,$=window.getComputedStyle(J),V={},Z={},G=new Set(f7);for(let B of f7){let P=Q.getPropertyValue(B);if(P)V[B]=P.trim();let Y=$.getPropertyValue(B);if(Y)Z[B]=Y.trim()}let z=/^(margin|padding|border)(-|$)/,K={};for(let B=0;B<Q.length;B++){let P=Q.item(B);if(!P||G.has(P)||z.test(P))continue;let Y=Q.getPropertyValue(P);if(Y)K[P]=Y.trim()}let H={};for(let B of Array.from(J.attributes)){if(yJ.test(B.name))continue;H[B.name]=B.value}if(J.hasAttribute("data-dc-screen")){for(let B of Array.from(J.attributes))if(B.name.startsWith("data-dc-")&&B.name!=="data-dcid")H[B.name]=B.value}let j=J.parentElement,N=j?window.getComputedStyle(j).display:"",U=j&&(N==="flex"||N==="inline-flex")?window.getComputedStyle(j).flexDirection:"";return{authored:V,computed:Z,customStyles:K,attrs:H,parentDisplay:N,parentFlexDirection:U}}catch{return{authored:{},computed:{},customStyles:{},attrs:{}}}}function D7(J,Q){let $=J.el,V=$&&$.getBoundingClientRect?$.getBoundingClientRect():null,Z=J.cdId,G=Z?u7(Z,J.artboardId):J.artboardId?`[data-dc-screen="${J.artboardId}"]`:TJ($),z=Z&&typeof document<"u"?m7(document,G,$):0;return{file:Q??F7(),id:Z??void 0,selector:G,artboardId:J.artboardId,index:z,tag:$?.tagName.toLowerCase()??"",classes:q7($),text:wJ($,240),dom_path:p7($),bounds:V?{x:Math.round(V.left),y:Math.round(V.top),w:Math.round(V.width),h:Math.round(V.height)}:null,worldW:$ instanceof HTMLElement?Math.round($.offsetWidth):void 0,worldH:$ instanceof HTMLElement?Math.round($.offsetHeight):void 0,html:$?($.outerHTML??"").slice(0,4000):"",...(()=>{if($?.tagName?.toLowerCase()!=="img")return{};let K=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,H=$.getAttribute?.("data-photo-asset");if(H&&K.test(H))return{photoKind:"artboard-img",photoAsset:H};let j=$.getAttribute?.("src")||"",N=K.exec(j);return N?{photoKind:"artboard-img",photoAsset:N[0]}:{}})(),...vJ($)}}var G7=null;function a(){if(typeof window>"u")return!1;if(G7===null)try{G7=new URLSearchParams(window.location.search).get("ro")==="1"}catch{G7=!1}return G7}import*as L7 from"lib0/decoding";import*as o from"lib0/encoding";import{createContext as SJ,useCallback as B0,useContext as gJ,useEffect as W0,useMemo as K0,useReducer as z0,useRef as U0,useState as X0}from"react";import{Awareness as Y0,applyAwarenessUpdate as F0,encodeAwarenessUpdate as P0}from"y-protocols/awareness";import{readSyncMessage as L0,writeSyncStep1 as M0,writeUpdate as N0}from"y-protocols/sync";import*as hJ from"yjs";import*as CJ from"yjs";var RJ=new WeakSet;function c7(J){return RJ.add(J),J}var Q0=c7(Object.freeze({maudeOrigin:"shell-edit"})),$0=c7(Object.freeze({maudeOrigin:"sync-agent"}));import{jsx as I0}from"react/jsx-runtime";var fJ=SJ(null);function l7(){return gJ(fJ)}import{createContext as pJ,useCallback as l,useContext as N7,useEffect as uJ,useMemo as mJ,useRef as dJ,useState as iJ}from"react";import{jsx as M7,Fragment as rJ}from"react/jsx-runtime";var B7=pJ(null);function r(J){return J.id?`id:${J.id}`:`sel:${J.selector}`}function r7(J){let Q=[],$=new Set;for(let V of J){let Z=r(V);if($.has(Z))continue;$.add(Z),Q.push(V)}return Q}var cJ=50;function lJ({children:J,postTarget:Q}){let[$,V]=iJ([]),Z=dJ(null),G=l((B)=>{if(Z.current)clearTimeout(Z.current);Z.current=setTimeout(()=>{Z.current=null;let P=Q??(typeof window<"u"?window.parent:null);if(!P)return;let Y=B.length===0?null:B.length===1?B[0]??null:B;try{P.postMessage({dgn:"select-set",selection:Y},"*")}catch{}},cJ)},[Q]);uJ(()=>()=>{if(Z.current)clearTimeout(Z.current)},[]);let z=l((B)=>{let P=r7(Array.isArray(B)?B:[B]);V(P),G(P)},[G]),K=l((B)=>{let P=Array.isArray(B)?B:[B];V((Y)=>{let M=r7([...Y,...P]);return G(M),M})},[G]),H=l((B)=>{let P=r(B);V((Y)=>{let M=Y.filter((O)=>r(O)!==P);return G(M),M})},[G]),j=l((B)=>{let P=r(B);V((Y)=>{let M=Y.some((O)=>r(O)===P)?Y.filter((O)=>r(O)!==P):[...Y,B];return G(M),M})},[G]),N=l(()=>{V([]),G([])},[G]),U=mJ(()=>({selected:$,replace:z,add:K,remove:H,toggle:j,clear:N}),[$,z,K,H,j,N]);return M7(B7.Provider,{value:U,children:J})}function n7({children:J}){if(N7(B7))return M7(rJ,{children:J});return M7(lJ,{children:J})}function W7(){let J=N7(B7);if(!J)throw Error("useSelectionSet must be used inside <SelectionSetProvider>");return J}function a7(){return N7(B7)}import{jsx as w,jsxs as x,Fragment as WQ}from"react/jsx-runtime";var nJ="/_client/comments-overlay.css";function aJ(){if(typeof document>"u")return;if(document.getElementById("cm-overlay-css"))return;let J=document.createElement("link");J.id="cm-overlay-css",J.rel="stylesheet",J.href=nJ,document.head.appendChild(J)}function oJ(){if(typeof window>"u")return null;try{let J=window.location.pathname;if(J==="/_canvas-shell.html"||J==="/_canvas-shell"){let Q=new URLSearchParams(window.location.search),$=Q.get("canvas")??"",V=(Q.get("designRel")??".design").replace(/^\/+|\/+$/g,"");return $?`${V}/${$}`:null}return decodeURIComponent(J).replace(/^\//,"")}catch{return null}}function sJ(J){if(!J.selector)return null;let Q=null;try{let $=document.querySelectorAll(J.selector),V=J.index&&J.index>0&&J.index<$.length?J.index:0;Q=$[V]??$[0]??null}catch{Q=null}if(Q&&J.tag&&Q.tagName.toLowerCase()!==J.tag.toLowerCase())Q=null;if(!Q&&J.dom_path?.length){let $=J.selector.match(/data-dc-screen="([^"]+)"/)?.[1];Q=i7(document,{artboardId:$,tag:J.tag,classes:J.classes,dom_path:J.dom_path})}return Q}function I7(J){let Q=sJ(J);if(!Q?.isConnected)return null;let $=Q.getBoundingClientRect();if($.width===0&&$.height===0)return null;return{x:$.left,y:$.top,w:$.width,h:$.height}}function JJ(J,Q){let V=typeof window<"u"?window.innerWidth:J.x+Q.w,Z=typeof window<"u"?window.innerHeight:J.y+Q.h,G=J.x;if(G+Q.w+8>V){let K=J.x-Q.w;G=K>=8?K:Math.max(8,V-Q.w-8)}let z=J.y;if(z+Q.h+8>Z){let K=J.y-Q.h;z=K>=8?K:Math.max(8,Z-Q.h-8)}return{x:G,y:z}}function QJ(){aJ();let J=a7(),[Q,$]=h([]),[V,Z]=h(null),[G,z]=h(null),K=s(()=>oJ(),[]);S(()=>{if(typeof document>"u")return;let F=document.getElementById("dgn-pin-layer");if(!F)return;let W=F.style.display;return F.style.display="none",()=>{F.style.display=W}},[]);let H=b((F)=>{if(!J)return;if(!F?.selector){J.clear();return}let W=F.selector.match(/data-cd-id="([^"]+)"/),D=W?W[1]:void 0,A,L;try{let I=document.querySelector(F.selector);if(I)A=I.tagName.toLowerCase(),L=(I.getAttribute("class")??"").split(/\s+/).filter((E)=>E&&!E.startsWith("dgn-")&&!E.startsWith("dc-cv-")).join(" ")}catch{}J.replace({file:K??void 0,id:D,selector:F.selector,tag:A,classes:L,bounds:F.bounds??void 0})},[J,K]),j=g(Q);j.current=Q;let N=l7(),U=VQ();S(()=>{if(!N)return;let F=N.doc.getArray("comments"),W=()=>{$(F.toArray())};if(F.length>0)W();return F.observe(W),()=>{try{F.unobserve(W)}catch{}}},[N]),S(()=>{if(typeof window>"u")return;let F=(W)=>{let D=W.data;if(!D||typeof D!=="object"||!D.dgn)return;if(D.dgn==="comments-set"&&Array.isArray(D.comments))$(D.comments);else if(D.dgn==="comment-focus"){let A=typeof D.id==="string"?D.id:null;Z(A);let L=A?j.current.find((I)=>I.id===A):void 0;H(L)}};return window.addEventListener("message",F),()=>window.removeEventListener("message",F)},[H]),S(()=>{if(typeof document>"u")return;let F=(W)=>{let D=W.detail;if(!D?.selection)return;z({selection:D.selection,clientX:typeof D.clientX==="number"?D.clientX:0,clientY:typeof D.clientY==="number"?D.clientY:0})};return document.addEventListener("cm:open-composer",F),()=>document.removeEventListener("cm:open-composer",F)},[]);let B=b(()=>{if(z(null),typeof window>"u")return;try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},[]),P=b((F)=>{if(!G)return;let W=G.selection,D={file:W.file,selector:W.selector,index:W.index,dom_path:W.dom_path,tag:W.tag,classes:W.classes,bounds:W.bounds,html_excerpt:W.html,text:F};if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-submit",payload:D},"*")}catch{}B()},[G,B]);S(()=>{if(!K)return;let F=!1;return(async()=>{try{let W=await fetch(`/_comments?file=${encodeURIComponent(K)}`);if(!W.ok)return;let D=await W.json();if(F)return;if(Array.isArray(D.comments))$((A)=>A.length===0?D.comments??[]:A)}catch{}})(),()=>{F=!0}},[K]);let Y=s(()=>{return Q.slice().sort((W,D)=>W.created.localeCompare(D.created)).filter((W)=>W.status!=="resolved")},[Q]),M=s(()=>{let F=new Map;return Q.slice().sort((D,A)=>D.created.localeCompare(A.created)).forEach((D,A)=>{F.set(D.id,A+1)}),F},[Q]),O=b((F)=>{if(Z(F),H(Q.find((W)=>W.id===F)),typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-click",id:F},"*")}catch{}},[Q,H]),q=b((F,W)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-patch",id:F,patch:W},"*")}catch{}},[]),X=b((F)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-delete",id:F},"*")}catch{}Z((W)=>W===F?null:W)},[]),_=b(async(F,W)=>{if(typeof fetch>"u")return!1;try{let D=await fetch(`/_api/comments/${encodeURIComponent(F)}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:W})});if(!D.ok)return!1;let A=await D.json();return $((L)=>L.map((I)=>I.id===A.id?A:I)),!0}catch{return!1}},[]);return x("div",{className:"cm-layer","aria-hidden":!1,children:[Y.map((F)=>{let W=M.get(F.id)??0;return w(QQ,{comment:F,sequence:W,focused:V===F.id,onClick:O,onOrphaned:X},F.id)}),G?w($Q,{state:G,onSubmit:P,onCancel:B}):null,(()=>{if(!V)return null;let F=Y.find((W)=>W.id===V);if(!F)return null;return w(ZQ,{comment:F,sequence:M.get(F.id)??0,onClose:()=>{Z(null),J?.clear()},onPatch:(W)=>q(F.id,W),onDelete:()=>X(F.id),onReply:(W)=>_(F.id,W),mine:!a()&&!!(U??N?.myName)&&(F.author??"").trim()===(U??N?.myName??"").trim()})})()]})}var j7=null;async function tJ(){if(!j7)j7=(async()=>{try{let J=await fetch("/_api/git-committers");if(!J.ok)return[];let Q=await J.json();return Array.isArray(Q.committers)?Q.committers:[]}catch{return[]}})();return j7}function o7(J){return(J.trim().split(/\s+/)[0]??"").replace(/[^\w.-]/g,"").toLowerCase()}function eJ(J,Q){if(Q<=0||Q>J.length)return null;let $=Q-1;while($>=0){let V=J[$]??"";if(V==="@"){let Z=$>0?J[$-1]:"";if($===0||/\s/.test(Z??"")){let G=J.slice($+1,Q);return{start:$,end:Q,query:G}}return null}if(!/[\w.-]/.test(V))return null;$-=1}return null}function _7({className:J,value:Q,onChange:$,onKeyDown:V,placeholder:Z,rows:G,disabled:z,textareaRef:K,ariaLabel:H}){let j=g(null),N=b((L)=>{if(j.current=L,K)K.current=L},[K]),[U,B]=h([]),[P,Y]=h(null),[M,O]=h(0),q=b(()=>{if(U.length>0)return;tJ().then((L)=>B(L))},[U.length]),X=s(()=>{if(!P)return[];let L=P.query.toLowerCase();return(!L?U:U.filter((E)=>E.name.toLowerCase().includes(L)||E.email.toLowerCase().includes(L))).slice(0,8)},[P,U]),_=b((L)=>{let I=L.selectionStart??L.value.length,E=eJ(L.value,I);Y(E),O(0)},[]),F=b((L)=>{$(L.target.value),_(L.target)},[$,_]),W=b((L)=>{if(!P)return;let I=j.current;if(!I)return;let E=`@${o7(L.name)}`,k=`${Q.slice(0,P.start)}${E} ${Q.slice(P.end)}`;$(k),Y(null);let T=P.start+E.length+1;requestAnimationFrame(()=>{I.focus(),I.setSelectionRange(T,T)})},[P,Q,$]),D=b((L)=>{if(P&&X.length>0){if(L.key==="ArrowDown"){L.preventDefault(),O((I)=>(I+1)%X.length);return}if(L.key==="ArrowUp"){L.preventDefault(),O((I)=>(I-1+X.length)%X.length);return}if(L.key==="Enter"||L.key==="Tab"){L.preventDefault();let I=X[M]??X[0];if(I)W(I);return}if(L.key==="Escape"){L.preventDefault(),Y(null);return}}V?.(L)},[P,X,M,W,V]),A=b((L)=>{_(L.currentTarget)},[_]);return x("div",{style:{position:"relative"},children:[w("textarea",{ref:N,className:J,value:Q,placeholder:Z,rows:G,disabled:z,"aria-label":H,onChange:F,onKeyDown:D,onFocus:q,onSelect:A,onClick:A}),P&&X.length>0?w("ul",{className:"cm-mention-popup",role:"listbox","aria-label":"Mention suggestions",style:{left:0,top:"100%"},children:X.map((L,I)=>{return x("li",{role:"option","aria-selected":I===M,className:"cm-mention-popup__item",onMouseEnter:()=>O(I),onMouseDown:(k)=>{k.preventDefault(),W(L)},children:[x("span",{className:"cm-mention-popup__name",children:["@",o7(L.name)]}),w("span",{className:"cm-mention-popup__email",children:L.email})]},`${L.name}-${L.email}`)})}):null]})}var JQ=3000;function QQ({comment:J,sequence:Q,focused:$,onClick:V,onOrphaned:Z}){let G=g(null),z=g(null),K=g(null);S(()=>{let N=()=>{z.current=null;let U=G.current;if(!U)return;let B=I7(J);if(B)K.current=null;else{if(K.current==null)K.current=Date.now();else if(Date.now()-K.current>JQ)Z(J.id);if(J.bounds)B={x:J.bounds.x,y:J.bounds.y,w:J.bounds.w,h:J.bounds.h}}if(!B){U.style.display="none",z.current=requestAnimationFrame(N);return}U.style.display="grid";let P=Math.round(B.x+B.w-12),Y=Math.round(B.y-12);U.style.left=`${P}px`,U.style.top=`${Y}px`,z.current=requestAnimationFrame(N)};return z.current=requestAnimationFrame(N),()=>{if(z.current!=null)cancelAnimationFrame(z.current)}},[J,Z]);let H=J.author?.trim()||"unknown",j=`Comment ${Q} by ${H}`;return w("button",{ref:G,type:"button",className:"cm-pin","data-resolved":J.status==="resolved"?"true":"false","data-focused":$?"true":"false","data-comment-pin":J.id,"aria-label":j,"aria-expanded":$,title:J.text.slice(0,200),onClick:(N)=>{N.preventDefault(),N.stopPropagation(),V(J.id)},children:Q})}function $Q({state:J,onSubmit:Q,onCancel:$}){let[V,Z]=h(""),G=g(null),z=g(null),K=g(null);S(()=>{let U=()=>{K.current=null;let B=z.current;if(!B)return;let P=BQ(J),Y=JJ(P,{w:B.offsetWidth,h:B.offsetHeight});B.style.left=`${Math.round(Y.x)}px`,B.style.top=`${Math.round(Y.y)}px`,K.current=requestAnimationFrame(U)};return K.current=requestAnimationFrame(U),()=>{if(K.current!=null)cancelAnimationFrame(K.current)}},[J]),S(()=>{G.current?.focus()},[]);let H=b(()=>{let U=V.trim();if(!U)return;Q(U)},[V,Q]),j=b((U)=>{if(U.key==="Escape"){U.preventDefault(),$();return}if((U.metaKey||U.ctrlKey)&&U.key==="Enter")U.preventDefault(),H()},[$,H]),N=s(()=>{let U=J.selection.selector||"";if(!U)return J.selection.tag||"canvas";let B=U.match(/data-cd-id="([^"]+)"/);if(B)return`cd:${B[1]}`;return U.length>36?`${U.slice(0,33)}…`:U},[J.selection]);return x("div",{ref:z,className:"cm-composer",role:"dialog","aria-label":"New comment",onClick:(U)=>U.stopPropagation(),onPointerDown:(U)=>U.stopPropagation(),children:[x("div",{className:"cm-composer__head",children:[w("span",{children:"New comment"}),w("span",{className:"cm-composer__selector",children:N})]}),w(_7,{textareaRef:G,className:"cm-composer__textarea",value:V,placeholder:"Type a comment. ⌘↵ to save · Esc to cancel · @name to tag",onChange:Z,onKeyDown:j,rows:3,ariaLabel:"Comment body"}),x("div",{className:"cm-composer__actions",children:[w("button",{type:"button",className:"cm-btn",onClick:$,children:"Cancel"}),w("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!V.trim(),onClick:H,children:"Save"})]})]})}var s7=null;function VQ(){let[J,Q]=h(null);return S(()=>{if(typeof fetch>"u")return;s7??=fetch("/_api/git-user").then((V)=>V.ok?V.json():null).then((V)=>typeof V?.name==="string"&&V.name.trim()?V.name.trim():null).catch(()=>null);let $=!0;return s7.then((V)=>$&&Q(V)),()=>{$=!1}},[]),J}function ZQ({comment:J,sequence:Q,onClose:$,onPatch:V,onDelete:Z,onReply:G,mine:z=!1}){let K=g(null),H=g(null),j=g(null),[N,U]=h(""),[B,P]=h(!1),[Y,M]=h(null),O=b(()=>{let W=(Y??"").trim();if(!W)return;if(W!==J.text)V({text:W});M(null)},[Y,J.text,V]);S(()=>{let W=()=>{j.current=null;let D=K.current;if(!D)return;let A=GQ(J),L=JJ(A,{w:D.offsetWidth,h:D.offsetHeight});D.style.left=`${Math.round(L.x)}px`,D.style.top=`${Math.round(L.y)}px`,j.current=requestAnimationFrame(W)};return j.current=requestAnimationFrame(W),()=>{if(j.current!=null)cancelAnimationFrame(j.current)}},[J]),S(()=>{K.current?.focus();let W=J.id;return()=>{document.querySelector(`[data-comment-pin="${W}"]`)?.focus()}},[J.id]),S(()=>{if(typeof document>"u")return;let W=(D)=>{if(D.key!=="Escape")return;let A=K.current;if(!A)return;if(A.contains(D.target)||document.activeElement===A)D.preventDefault(),$()};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[$]);let q=b(async()=>{let W=N.trim();if(!W||B)return;P(!0);let D=await G(W);if(P(!1),D)U(""),H.current?.focus()},[N,B,G]),X=b((W)=>{if((W.metaKey||W.ctrlKey)&&W.key==="Enter")W.preventDefault(),q()},[q]),_=`cm-thread-head-${J.id}`,F=qQ(J.selector,"");return x("div",{ref:K,className:"cm-thread",role:"dialog","aria-labelledby":_,tabIndex:-1,onClick:(W)=>W.stopPropagation(),onPointerDown:(W)=>W.stopPropagation(),children:[x("div",{className:"cm-thread__head",id:_,children:[x("div",{className:"cm-thread__head-row",children:[w("span",{className:"cm-thread__seq","aria-hidden":"true",children:Q}),w("span",{className:"cm-thread__author",children:J.author?.trim()||"unknown"}),w("span",{className:"cm-thread__time",children:e7(J.created)}),w("button",{type:"button",className:"cm-thread__close","aria-label":"Close thread",title:"Close · Esc",onClick:$,children:"×"})]}),F?w("code",{className:"cm-thread__selector",children:F}):null]}),Y===null?w("div",{className:"cm-thread__body",children:t7(J.text)}):x("div",{className:"cm-thread__reply-form",children:[w(_7,{className:"cm-thread__reply-textarea",value:Y,placeholder:"Edit your comment… ⌘↵ to save",onChange:M,onKeyDown:(W)=>{if((W.metaKey||W.ctrlKey)&&W.key==="Enter")W.preventDefault(),O()},rows:3,ariaLabel:"Edit comment"}),x("div",{className:"cm-thread__reply-actions",children:[w("button",{type:"button",className:"cm-btn",onClick:()=>M(null),children:"Cancel"}),w("button",{type:"button",className:"cm-btn cm-btn--primary","data-testid":"comment-edit-save",disabled:!Y.trim(),onClick:O,children:"Save"})]})]}),(J.thread??[]).map((W)=>x("div",{className:"cm-thread__reply",children:[x("div",{className:"cm-thread__reply-head",children:[w("span",{className:"cm-thread__reply-author",children:W.author?.trim()||"unknown"}),w("span",{className:"cm-thread__reply-time",children:e7(W.created)})]}),w("div",{className:"cm-thread__reply-body",children:t7(W.body)})]},W.id)),!a()&&x(WQ,{children:[x("div",{className:"cm-thread__reply-form",children:[w(_7,{textareaRef:H,className:"cm-thread__reply-textarea",value:N,placeholder:"Reply… ⌘↵ to send · @name to tag",onChange:U,onKeyDown:X,rows:2,ariaLabel:"Reply",disabled:B}),w("div",{className:"cm-thread__reply-actions",children:w("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!N.trim()||B,onClick:()=>void q(),children:"Send"})})]}),x("div",{className:"cm-thread__actions",children:[z&&Y===null?w("button",{type:"button",className:"cm-btn","data-testid":"comment-edit",onClick:()=>M(J.text),children:"Edit"}):null,J.status==="resolved"?w("button",{type:"button",className:"cm-btn",onClick:()=>V({status:"open"}),children:"↺ Reopen"}):w("button",{type:"button",className:"cm-btn cm-btn--primary",onClick:()=>{V({status:"resolved"}),$()},children:"✓ Resolve"}),w("button",{type:"button",className:"cm-btn cm-btn--danger",onClick:()=>{Z(),$()},children:"Delete"})]})]})]})}function t7(J){if(!J)return null;let Q=/(@[\w][\w.-]*)/g;return J.split(Q).map((V,Z)=>{let G=`${Z}:${V}`;if(Z%2===1)return w("strong",{"data-mention":"true",children:V},G);return w("span",{children:V},G)})}function e7(J){if(!J)return"";let Q=Date.parse(J);if(!Number.isFinite(Q))return"";let $=Math.round((Date.now()-Q)/1000);if($<60)return`${Math.max($,0)}s ago`;if($<3600)return`${Math.round($/60)}m ago`;if($<86400)return`${Math.round($/3600)}h ago`;return`${Math.round($/86400)}d ago`}function qQ(J,Q){if(!J)return Q;let $=J.match(/data-cd-id="([^"]+)"/);if($)return`cd:${$[1]}`;return J.length>36?`${J.slice(0,33)}…`:J}function GQ(J){let Q=J.selector?I7(J):null;if(Q)return{x:Q.x+Q.w-12,y:Q.y+16};if(J.bounds)return{x:J.bounds.x+J.bounds.w-12,y:J.bounds.y+16};return{x:16,y:16}}function BQ(J){if(J.clientX||J.clientY)return{x:J.clientX,y:J.clientY+8};if(J.selection.selector){let Q=I7(J.selection);if(Q)return{x:Q.x,y:Q.y+Q.h+8}}return{x:16,y:16}}import{useEffect as KQ}from"react";var zQ=new Set(["pen","highlighter","shape","rect","ellipse","arrow","sticky","text","section","eraser"]);function A7(J){return zQ.has(J)}var t=(J)=>!!(J.metaKey||J.ctrlKey);function e(J){if(J.type==="keydown"){if(J.isEditable)return{kind:"no-op"};if(J.metaKey||J.ctrlKey||J.altKey){if(J.key==="Escape")return{kind:"escape"};let $=(J.key||"").toLowerCase();if(!J.altKey&&(J.metaKey||J.ctrlKey)){if($==="z"&&J.shiftKey)return{kind:"redo"};if($==="z")return{kind:"undo"};if($==="y"&&!J.shiftKey)return{kind:"redo"}}return{kind:"no-op"}}let Q=(J.key||"").toLowerCase();if(Q==="v")return{kind:"tool",tool:"move"};if(Q==="h")return{kind:"tool",tool:"hand"};if(Q==="c")return{kind:"tool",tool:"comment"};if(Q==="b")return{kind:"tool",tool:"pen"};if(Q==="i")return{kind:"tool",tool:"highlighter"};if(Q==="r"||Q==="o")return{kind:"tool",tool:"shape"};if(Q==="a")return{kind:"tool",tool:"arrow"};if(Q==="n")return{kind:"tool",tool:"sticky"};if(Q==="t")return{kind:"tool",tool:"text"};if(Q==="s"&&J.shiftKey)return{kind:"tool",tool:"section"};if(Q==="e")return{kind:"tool",tool:"eraser"};if(J.key==="Escape")return{kind:"escape"};return{kind:"no-op"}}if(J.type==="contextmenu")return{kind:"context-menu",clientX:J.clientX??0,clientY:J.clientY??0};if(J.type==="pointermove"){if(A7(J.activeTool))return{kind:"no-op"};if(J.activeTool==="hand")return{kind:"no-op"};if(J.activeTool==="browse"){if(!t(J))return{kind:"no-op"};return{kind:"hover",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0}}if(J.activeTool==="comment")return{kind:"hover",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0};return{kind:"hover",deep:t(J),clientX:J.clientX??0,clientY:J.clientY??0}}if(J.type==="pointerdown"){if(J.button===2)return{kind:"context-menu",clientX:J.clientX??0,clientY:J.clientY??0};if(J.button===1||J.spaceHeld)return{kind:"no-op"};if(J.button!==0)return{kind:"no-op"};if(A7(J.activeTool)&&!t(J))return{kind:"no-op"};if(J.activeTool==="comment")return{kind:"drop-comment",clientX:J.clientX??0,clientY:J.clientY??0};if(J.activeTool==="hand")return{kind:"no-op"};if(J.activeTool==="browse"){if(!t(J))return{kind:"no-op"};return{kind:"select",mode:J.shiftKey?"add":"replace",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0}}let Q=t(J);return{kind:"select",mode:!!J.shiftKey?"add":"replace",deep:Q,clientX:J.clientX??0,clientY:J.clientY??0}}return{kind:"no-op"}}function K7(J){if(!J||!J.tagName)return!1;let Q=J,$=Q.tagName;if($==="INPUT"||$==="TEXTAREA"||$==="SELECT")return!0;if(Q.isContentEditable)return!0;let V=Q.getAttribute?.("contenteditable");if(V==="true"||V==="plaintext-only"||V==="")return!0;return!1}function J7(J){if(!J||!J.closest)return!1;let Q=J;if(Q.closest(".dc-world"))return!1;return!!Q.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mediaref-player], .dc-tool-palette, .dc-zoom-tb, .dc-mm, .dc-context-menu")}function VJ(J){if(!J||typeof J.closest!=="function")return!1;let Q=J;return!!Q.closest("[data-dc-screen]")&&!Q.closest(".dc-artboard-body")}function $J(J,Q,$){return J.kind==="select"&&!$.metaKey&&!$.ctrlKey&&VJ(Q)}function UQ(J,Q,$){return J==="select"&&!$.metaKey&&!$.ctrlKey&&VJ(Q)}function ZJ(J){let{hostRef:Q,getActiveTool:$,isSpaceHeld:V,callbacks:Z,enabled:G=!0,claimableActions:z}=J;KQ(()=>{if(!G)return;let K=Q.current;if(!K)return;let H=(q)=>z&&q.kind!=="no-op"&&!z.has(q.kind)?{kind:"no-op"}:q,j=(q)=>{switch(q.kind){case"hover":Z.onHover?.(q);break;case"select":Z.onSelect?.(q);break;case"drop-comment":Z.onDropComment?.(q);break;case"context-menu":Z.onContextMenu?.(q);break;case"tool":Z.onTool?.(q);break;case"escape":Z.onEscape?.();break;case"undo":Z.onUndo?.();break;case"redo":Z.onRedo?.();break;case"no-op":break}},N=(q)=>{let X=H(e({type:"pointermove",button:q.button,metaKey:q.metaKey,ctrlKey:q.ctrlKey,shiftKey:q.shiftKey,altKey:q.altKey,clientX:q.clientX,clientY:q.clientY,spaceHeld:V?.()??!1,activeTool:$()}));j(X)},U=(q)=>{if(J7(q.target))return;if(K7(q.target))return;let X=H(e({type:"pointerdown",button:q.button,metaKey:q.metaKey,ctrlKey:q.ctrlKey,shiftKey:q.shiftKey,altKey:q.altKey,clientX:q.clientX,clientY:q.clientY,spaceHeld:V?.()??!1,activeTool:$()})),_=$J(X,q.target,q);if(X.kind!=="no-op"){if(q.preventDefault(),!_)q.stopImmediatePropagation()}j(X)},B=(q)=>{if(J7(q.target))return;if(K7(q.target))return;let X=H(e({type:"pointerdown",button:q.button,metaKey:q.metaKey,ctrlKey:q.ctrlKey,shiftKey:q.shiftKey,altKey:q.altKey,clientX:q.clientX,clientY:q.clientY,spaceHeld:V?.()??!1,activeTool:$()})),_=$J(X,q.target,q);if(X.kind!=="no-op"){if(q.preventDefault(),!_)q.stopImmediatePropagation();if(X.kind==="select")try{window.focus()}catch{}}},P=(q)=>{if(J7(q.target))return;if(K7(q.target))return;let X=$(),_=q.metaKey||q.ctrlKey,F=X==="comment"?"drop-comment":X==="move"&&q.button===0?"select":(A7(X)||X==="browse")&&_&&q.button===0?"select":q.button===2?"context-menu":null;if(F&&(!z||z.has(F))){let W=UQ(F,q.target,q);if(q.preventDefault(),!W)q.stopImmediatePropagation()}},Y=(q)=>{let X=H(e({type:"contextmenu",clientX:q.clientX,clientY:q.clientY,metaKey:q.metaKey,ctrlKey:q.ctrlKey,shiftKey:q.shiftKey,altKey:q.altKey,activeTool:$()}));if(X.kind==="no-op")return;q.preventDefault(),q.stopImmediatePropagation(),j(X)},M=(q)=>{let X=H(e({type:"keydown",key:q.key,metaKey:q.metaKey,ctrlKey:q.ctrlKey,shiftKey:q.shiftKey,altKey:q.altKey,isEditable:K7(q.target),activeTool:$()}));if(X.kind==="tool"||X.kind==="escape"||X.kind==="undo"||X.kind==="redo")q.preventDefault();j(X)};K.addEventListener("pointermove",N,{passive:!0}),K.addEventListener("pointerdown",U,{capture:!0}),K.addEventListener("mousedown",B,{capture:!0}),K.addEventListener("click",P,{capture:!0}),K.addEventListener("contextmenu",Y,{capture:!0});let O=K.ownerDocument??document;return O.addEventListener("keydown",M,!0),()=>{K.removeEventListener("pointermove",N),K.removeEventListener("pointerdown",U,{capture:!0}),K.removeEventListener("mousedown",B,{capture:!0}),K.removeEventListener("click",P,{capture:!0}),K.removeEventListener("contextmenu",Y,{capture:!0}),O.removeEventListener("keydown",M,!0)}},[G,Q,$,V,Z,z])}function O7(J,Q,$,V){let Z=J.elementFromPoint(Q,$);if(!Z)return null;if(Z.closest?.(".dc-mm, .dc-zoom-tb, .dc-tool-palette, .dc-context-menu, .dc-cv-group-bbox"))return null;let G=Z.closest?.("[data-dc-screen]")??null,z=G?.getAttribute("data-dc-screen")??null,K=Z.closest?.(".dc-artboard-body")??null;if(!K){if(G&&z)return{el:G,cdId:null,artboardId:z};return null}if(Z===K){if(G&&z)return{el:G,cdId:null,artboardId:z};return null}if(V.deep){let B=Z.getAttribute?.("data-cd-id")??null;return{el:Z,cdId:B,artboardId:z}}let H=Z,j=null;while(H&&H!==K){if(H.hasAttribute?.("data-cd-id"))j=H;H=H.parentElement}let N=j??Z,U=N.getAttribute?.("data-cd-id")??null;return{el:N,cdId:U,artboardId:z}}import{useCallback as EQ,useEffect as XJ,useRef as X7}from"react";var XQ=!1;function qJ(){return XQ}import{createContext as jQ,useCallback as $7,useContext as zJ,useEffect as T7,useMemo as BJ,useRef as b7,useState as z7}from"react";function m(J,Q,$,V){return`url("data:image/svg+xml,${encodeURIComponent(J.trim())}") ${Q} ${$}, ${V}`}var E7="width='24' height='24' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'",w7="#1f1f1f",k7="stroke='#ffffff' stroke-linejoin='round' stroke-linecap='round'";function i(J,Q,$){let V=$?`<g transform='${$}'>`:"";return`<svg ${E7}>${V}<path fill='#ffffff' d='${J}'/><path fill='${w7}' d='${Q}'/>${$?"</g>":""}</svg>`}var GJ="translate(0,32) scale(1,-1)",HQ=m(i("M10.25 8.25 L10.05 8.65 10 9 10 23.1 10.05 23.4 10.25 23.75 10.8 24 11.45 23.85 11.6 23.7 11.75 23.45 14.65 19.8 14.85 19.65 14.95 19.5 15.4 19.2 15.95 19.1 21.05 19.1 21.2 19.1 21.35 19.05 21.65 18.9 21.9 18.6 22 18.3 22 17.9 21.9 17.65 21.75 17.35 21.65 17.3 21.55 17.15 11.5 8.25 11.25 8.05 10.95 8 10.6 8.05 10.25 8.25 M9.15 6.6 L9.7 6.25 10 6.15 10.95 6 11.9 6.15 13 6.9 22.9 15.65 23 15.8 23.2 15.95 23.75 16.75 24 17.9 24 18.3 23.9 18.95 23.8 19.25 23.6 19.7 23.1 20.35 22.75 20.6 22.1 20.9 22.05 20.95 22 20.95 21.2 21.1 21.05 21.1 16.2 21.1 16.1 21.25 16.05 21.25 13.4 24.6 13.05 25.15 12.9 25.3 12.55 25.55 Q11.6 26.15 10.55 26 L10.5 26 Q9.65 25.85 9 25.3 L8.45 24.65 8.4 24.5 8.15 24.05 8 23.1 8 9 Q8 8.45 8.15 8.05 L8.25 7.75 8.45 7.35 9.15 6.6","M10.25 8.25 L10.6 8.05 10.95 8 11.25 8.05 11.5 8.25 21.55 17.15 21.65 17.3 21.75 17.35 21.9 17.65 22 17.9 22 18.3 21.9 18.6 21.65 18.9 21.35 19.05 21.2 19.1 21.05 19.1 15.95 19.1 15.4 19.2 14.95 19.5 14.85 19.65 14.65 19.8 11.75 23.45 11.6 23.7 11.45 23.85 10.8 24 10.25 23.75 10.05 23.4 10 23.1 10 9 10.05 8.65 10.25 8.25"),8,5,"default"),YQ=m(i("M28.55 17.8 Q29.4 20.3 28.75 22.8 L28.7 23 28.15 24.55 28.05 24.75 Q26.4 28.2 22.75 29.4 L22.45 29.5 18 29.9 17.75 29.85 Q15.8 29.25 13.8 28.1 L13.45 27.95 Q12 27.05 10.35 26.8 L10.25 26.75 7.9 26.7 7.8 26.7 Q6.1 26.9 4.8 25.8 L4.75 25.8 4.65 25.7 4.6 25.65 Q3.25 24.5 3.05 22.85 L3 22.75 Q2.8 20.95 4 19.5 5.05 18.15 6.75 17.95 L8.4 17.9 7.5 15.55 7.3 15.2 7.2 15 5 10.95 Q3.9 9.15 4.3 7.75 L4.4 7.5 Q4.75 6.15 6.45 5.2 9 3.65 11 5 11.05 4.1 11.5 3.45 12.15 2.1 14.2 1.6 L14.35 1.6 Q18.05 0.6 19.6 4.4 L19.65 4.55 Q20.75 3.65 22.7 3.75 L22.75 3.75 Q26.75 4 27 8.15 L27 8.25 27 8.35 27 8.45 Q26.9 10.75 27.1 12.6 27.15 14.65 28.2 16.75 L28.55 17.8 M26.65 18.4 L26.1 16.8 26.1 16.85 Q24.8 13.7 25 8.35 L25 8.25 Q24.85 5.9 22.6 5.75 20.7 5.65 20.4 7.35 L20.1 7.95 19.5 8.2 18.85 8.05 18.45 7.5 17.75 5.15 Q16.85 2.95 14.7 3.55 L14.65 3.55 Q12.55 4.05 13.15 6.15 L13.85 8.75 13.75 9.45 13.25 9.95 12.55 9.95 12 9.55 10.9 7.7 Q9.5 5.7 7.45 6.9 6.5 7.45 6.25 8.15 6.1 8.9 6.7 9.85 9.2 13.9 10.8 18.65 L10.8 19.3 10.4 19.8 9.75 19.95 Q8.35 19.8 6.95 19.95 6.1 20.05 5.55 20.75 4.9 21.55 5 22.55 5.15 23.55 6 24.2 L6.05 24.25 Q6.75 24.85 7.65 24.7 L7.7 24.7 10.65 24.8 Q12.7 25.15 14.45 26.2 L14.5 26.2 Q16.4 27.35 18.3 27.9 L22.05 27.5 22.1 27.5 Q24.95 26.55 26.25 23.85 L26.8 22.3 Q27.3 20.35 26.65 18.4","M26.65 18.4 Q27.3 20.35 26.8 22.3 L26.25 23.85 Q24.95 26.55 22.1 27.5 L22.05 27.5 18.3 27.9 Q16.4 27.35 14.5 26.2 L14.45 26.2 Q12.7 25.15 10.65 24.8 L7.7 24.7 7.65 24.7 Q6.75 24.85 6.05 24.25 L6 24.2 Q5.15 23.55 5 22.55 4.9 21.55 5.55 20.75 6.1 20.05 6.95 19.95 8.35 19.8 9.75 19.95 L10.4 19.8 10.8 19.3 10.8 18.65 Q9.2 13.9 6.7 9.85 6.1 8.9 6.25 8.15 6.5 7.45 7.45 6.9 9.5 5.7 10.9 7.7 L12 9.55 12.55 9.95 13.25 9.95 13.75 9.45 13.85 8.75 13.15 6.15 Q12.55 4.05 14.65 3.55 L14.7 3.55 Q16.85 2.95 17.75 5.15 L18.45 7.5 18.85 8.05 19.5 8.2 20.1 7.95 20.4 7.35 Q20.7 5.65 22.6 5.75 24.85 5.9 25 8.25 L25 8.35 Q24.8 13.7 26.1 16.85 L26.1 16.8 26.65 18.4"),12,12,"grab"),FQ=m(i("M28 14 Q28 9.85 24.45 6.9 20.95 4 16 4 11.05 4 7.5 6.9 L7.45 7 Q4 9.9 4 14 4 18.15 7.55 21.05 L7.5 21.05 Q9.2 22.45 11.2 23.2 L15.3 27.3 16 27.6 16.7 27.3 20.85 23.2 Q22.7 22.45 24.3 21.15 L24.45 21.05 Q28 18.15 28 14 M25.75 5.35 Q30.05 8.95 30 14 30.05 19.05 25.75 22.6 L25.4 22.85 Q23.8 24.1 22 24.9 L18.1 28.75 18.15 28.75 Q17.2 29.6 16 29.6 14.8 29.6 13.85 28.75 L13.9 28.75 10 24.9 6.6 22.85 6.25 22.6 Q1.95 19.05 2 14 1.95 8.95 6.25 5.35 10.3 2 16 2 21.7 2 25.75 5.35","M28 14 Q28 18.15 24.45 21.05 L24.3 21.15 Q22.7 22.45 20.85 23.2 L16.7 27.3 16 27.6 15.3 27.3 11.2 23.2 Q9.2 22.45 7.5 21.05 L7.55 21.05 Q4 18.15 4 14 4 9.9 7.45 7 L7.5 6.9 Q11.05 4 16 4 20.95 4 24.45 6.9 28 9.85 28 14"),12,21,"crosshair"),PQ=m(i("M4 13.1 L4 6 Q4 5.15 4.6 4.6 5.15 4 6 4 L13.1 4 Q13.95 4 14.55 4.6 L28.65 18.75 Q29.8 19.9 29.75 21.45 L29.75 21.6 29.75 21.7 Q29.75 23.2 28.7 24.35 L24.45 28.65 24.35 28.75 Q23.15 29.85 21.65 29.8 L21.55 29.8 21.4 29.8 Q20.2 29.8 19.25 29.15 L18 29.35 Q16.6 29.4 15.25 28 L15.2 27.95 8.2 20.95 Q7.6 20.35 7.6 19.55 7.6 18.7 8.2 18.1 L4.6 14.5 Q4 13.9 4 13.1 M19.5 26.65 L20.1 27.25 Q20.7 27.85 21.5 27.8 22.35 27.85 23 27.25 L27.25 22.95 Q27.8 22.35 27.75 21.55 27.8 20.75 27.2 20.15 L13.1 6 6 6 6 13.1 12.35 19.45 9.6 19.5 16.65 26.55 Q18.05 28.05 19.5 26.65 M8.05 12.3 L8 8 12.25 8.05 13.8 9.6 9.6 13.85 8.05 12.3 M15.25 11.05 L23 18.8 18.8 23.05 11.05 15.3 15.25 11.05","M15.25 11.05 L11.05 15.3 18.8 23.05 23 18.8 15.25 11.05 M12.35 19.45 L6 13.1 6 6 13.1 6 27.2 20.15 Q27.8 20.75 27.75 21.55 27.8 22.35 27.25 22.95 L23 27.25 Q22.35 27.85 21.5 27.8 20.7 27.85 20.1 27.25 L19.5 26.65 12.35 19.45 M8.05 12.3 L9.6 13.85 13.8 9.6 12.25 8.05 8 8 8.05 12.3",GJ),6,18,"crosshair"),DQ=m(i("M5.15 10.85 Q4 9.65 4 8.1 L4 7.95 4 7.85 Q3.95 6.2 5.1 5.15 6.25 4 7.85 4 L7.95 4 8.1 4 Q9.65 4 10.85 5.15 L11 5.3 14.3 5.25 Q15.15 5.25 15.75 5.85 L29.9 20 Q31 21.15 31 22.75 L31 22.85 31 23 Q31.05 24.5 29.9 25.7 L29.55 25.95 25.65 29.9 25.65 29.95 Q24.45 31.1 22.75 31.1 21.2 31.15 20 29.95 L5.85 15.8 Q5.25 15.2 5.25 14.35 L5.25 10.95 5.15 10.85 M19.95 24.2 L18.55 22.8 22.8 18.55 24.2 19.95 19.95 24.2 M28.45 21.4 L14.3 7.25 10.15 7.3 9.4 6.55 Q8.8 5.95 7.95 6 7.1 5.95 6.5 6.55 5.95 7.1 6 7.95 5.95 8.8 6.55 9.4 L7.25 10.1 7.25 14.35 21.4 28.5 Q22 29.1 22.75 29.1 23.6 29.1 24.2 28.5 L28.45 24.25 Q29.05 23.65 29 22.85 29.05 22 28.45 21.4 M9.25 13.5 L9.25 9.3 13.5 9.25 14.3 10.05 10.05 14.3 9.25 13.5 M17.15 21.4 L11.5 15.75 15.75 11.5 21.4 17.15 17.15 21.4","M17.15 21.4 L21.4 17.15 15.75 11.5 11.5 15.75 17.15 21.4 M28.45 21.4 Q29.05 22 29 22.85 29.05 23.65 28.45 24.25 L24.2 28.5 Q23.6 29.1 22.75 29.1 22 29.1 21.4 28.5 L7.25 14.35 7.25 10.1 6.55 9.4 Q5.95 8.8 6 7.95 5.95 7.1 6.5 6.55 7.1 5.95 7.95 6 8.8 5.95 9.4 6.55 L10.15 7.3 14.3 7.25 28.45 21.4 M19.95 24.2 L24.2 19.95 22.8 18.55 18.55 22.8 19.95 24.2 M9.25 13.5 L10.05 14.3 14.3 10.05 13.5 9.25 9.25 9.3 9.25 13.5",GJ),6,18,"crosshair"),Q7=m(i("M17 2 Q18.2 2 19.15 2.9 20 3.8 20 5 L20 12 27 12 Q28.2 12 29.15 12.9 30 13.8 30 15 L30 17 Q30 18.2 29.15 19.15 28.2 20 27 20 L20 20 20 27 Q20 28.2 19.15 29.15 18.2 30 17 30 L15 30 Q13.8 30 12.9 29.15 12 28.2 12 27 L12 20 5 20 Q3.8 20 2.9 19.15 2 18.2 2 17 L2 15 Q2 13.8 2.9 12.9 3.8 12 5 12 L12 12 12 5 Q12 3.8 12.9 2.9 13.8 2 15 2 L17 2 M14 27 L14.3 27.7 Q14.6 28 15 28 L17 28 17.7 27.7 18 27 18 18.05 18.05 18 27 18 Q27.4 18 27.7 17.7 L28 17 28 15 27.7 14.3 Q27.4 14 27 14 L18 14 18 5 17.7 4.3 17 4 15 4 Q14.6 4 14.3 4.3 14 4.6 14 5 L14 14 5 14 Q4.6 14 4.3 14.3 4 14.6 4 15 L4 17 Q4 17.4 4.3 17.7 4.6 18 5 18 L14 18 14 27","M14 27 L14 18 5 18 Q4.6 18 4.3 17.7 4 17.4 4 17 L4 15 Q4 14.6 4.3 14.3 4.6 14 5 14 L14 14 14 5 Q14 4.6 14.3 4.3 14.6 4 15 4 L17 4 17.7 4.3 18 5 18 14 27 14 Q27.4 14 27.7 14.3 L28 15 28 17 27.7 17.7 Q27.4 18 27 18 L18.05 18 18 18.05 18 27 17.7 27.7 17 28 15 28 Q14.6 28 14.3 27.7 L14 27"),12,12,"crosshair"),LQ=m(i("M3.9 11.35 Q2.3 12.5 3.7 13.9 L16.4 26.65 Q17.85 28.05 19.45 26.9 L27.65 21.15 Q29.3 20 27.85 18.6 L15.15 5.85 Q13.75 4.45 12.1 5.6 L3.9 11.35 M1.05 12.4 Q1 10.95 2.75 9.75 L10.95 4 10.95 3.95 Q14 1.85 16.6 4.45 L29.3 17.2 Q30.8 18.65 30.55 20.1 30.55 21.55 28.8 22.8 L20.6 28.55 20.65 28.55 Q17.7 30.65 15 28.1 L15 28.05 2.3 15.3 2.3 15.35 Q0.8 13.85 1.05 12.4 M13.5 7 L19.85 13.35 11.65 19.15 5.3 12.75 13.5 7","M13.5 7 L5.3 12.75 11.65 19.15 19.85 13.35 13.5 7 M3.9 11.35 L12.1 5.6 Q13.75 4.45 15.15 5.85 L27.85 18.6 Q29.3 20 27.65 21.15 L19.45 26.9 Q17.85 28.05 16.4 26.65 L3.7 13.9 Q2.3 12.5 3.9 11.35"),6,14,"cell"),MQ=m(`<svg ${E7}><path d='M16 4V28M11 4H21M11 28H21' fill='none' ${k7} stroke-width='5'/><path d='M16 4V28M11 4H21M11 28H21' fill='none' stroke='${w7}' stroke-width='2.25' stroke-linecap='round'/></svg>`,12,12,"text"),NQ=m(`<svg ${E7}><path d='M6 5H21L26 10V27H6Z' fill='${w7}' ${k7} stroke-width='2.5'/><path d='M21 5V11H26' fill='none' ${k7} stroke-width='2.25'/></svg>`,5,5,"crosshair"),C=Object.freeze({browse:"default",move:HQ,hand:YQ,comment:FQ,pen:PQ,section:Q7,highlighter:DQ,shape:Q7,rect:Q7,ellipse:Q7,sticky:NQ,arrow:Q7,text:MQ,eraser:LQ});import{jsx as y7,Fragment as kQ}from"react/jsx-runtime";var x7="maude:tool-sync",WJ=Object.freeze({preview:"browse",edit:"move"});function KJ(J){if(J==="browse")return"preview";if(J==="move")return"edit";return null}var _Q=Object.freeze([{id:"browse",label:"Browse",shortcut:"",cursor:C.browse},{id:"move",label:"Select",shortcut:"V",cursor:C.move},{id:"hand",label:"Hand",shortcut:"H",cursor:C.hand},{id:"comment",label:"Comment",shortcut:"C",cursor:C.comment},{id:"pen",label:"Pen",shortcut:"B",cursor:C.pen},{id:"highlighter",label:"Highlighter",shortcut:"I",cursor:C.highlighter},{id:"shape",label:"Shape",shortcut:"R",cursor:C.shape},{id:"sticky",label:"Sticky",shortcut:"N",cursor:C.sticky},{id:"section",label:"Section",shortcut:"⇧S",cursor:C.shape},{id:"arrow",label:"Arrow",shortcut:"A",cursor:C.arrow},{id:"text",label:"Text",shortcut:"T",cursor:C.text},{id:"eraser",label:"Eraser",shortcut:"E",cursor:C.eraser}]),IQ=new Set(["browse","move","hand"]);function AQ(J,Q){return Q?J.filter(($)=>IQ.has($.id)):J}var v7=jQ(null);function OQ({children:J,tools:Q=_Q,initial:$,initialMode:V}){let Z=a(),G=BJ(()=>AQ(Q,Z),[Q,Z]),z=$??(Z?"browse":"move"),K=V??KJ(z)??(Z?"preview":"edit"),[H,j]=z7(z),[N,U]=z7(K),[B,P]=z7(()=>({tool:null,locked:!1})),Y=$7((I)=>{if(!G.some((k)=>k.id===I))return;j(I);let E=KJ(I);if(E)U(E);P((k)=>k.locked&&k.tool===I?k:{tool:null,locked:!1})},[G]),M=$7((I)=>{let E=WJ[I];if(!G.some((k)=>k.id===E))return;U(I),j(E),P((k)=>k.locked&&k.tool===E?k:{tool:null,locked:!1})},[G]),O=$7(()=>{Y(WJ[N])},[N,Y]),q=$7((I)=>{P((E)=>{if(E.locked&&E.tool===I)return{tool:null,locked:!1};return{tool:I,locked:!0}}),j(I)},[]),X=$7(()=>{P({tool:null,locked:!1})},[]),[_,F]=z7("rounded"),W=b7(Math.random().toString(36).slice(2)),D=b7(H);D.current=H;let A=b7(!1);T7(()=>{if(!A.current){A.current=!0;return}if(typeof document>"u")return;document.dispatchEvent(new CustomEvent(x7,{detail:{tool:H,from:W.current}}))},[H]),T7(()=>{if(typeof document>"u")return;let I=(E)=>{let k=E.detail;if(!k||k.from===W.current||typeof k.tool!=="string")return;if(k.tool===D.current)return;Y(k.tool)};return document.addEventListener(x7,I),()=>document.removeEventListener(x7,I)},[Y]),T7(()=>{if(typeof document>"u")return;let I=G.find((T)=>T.id===H);if(!I)return;let E=document.body.style.cursor,k=document.getElementById("dc-tool-cursor");if(!k)k=document.createElement("style"),k.id="dc-tool-cursor",document.head.appendChild(k);if(H==="browse"){if(document.body.style.cursor="",k.textContent="",typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:H},"*")}catch{}return()=>{document.body.style.cursor=E}}if(document.body.style.cursor=I.cursor,k.textContent=`* { cursor: ${I.cursor} !important; }`,typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:H},"*")}catch{}return()=>{document.body.style.cursor=E;let T=document.getElementById("dc-tool-cursor");if(T)T.textContent=""}},[H,G]);let L=BJ(()=>({tool:H,setTool:Y,tools:G,mode:N,setMode:M,resetTool:O,sticky:B,toggleSticky:q,clearSticky:X,shapeKind:_,setShapeKind:F}),[H,Y,G,N,M,O,B,q,X,_]);return y7(v7.Provider,{value:L,children:J})}function UJ({children:J,initial:Q,initialMode:$}){if(zJ(v7))return y7(kQ,{children:J});return y7(OQ,{initial:Q,initialMode:$,children:J})}function U7(){let J=zJ(v7);if(!J)throw Error("useToolMode must be used inside <ToolProvider>");return J}import{jsx as fQ}from"react/jsx-runtime";var wQ=`
2
2
  .dc-el-resize-handle {
3
3
  position: fixed;
4
4
  width: 8px;
@@ -56,4 +56,4 @@ import{Component as hQ,createElement as C7,useCallback as v7,useEffect as f,useM
56
56
  @media (prefers-reduced-motion: reduce) {
57
57
  .dc-el-resize-handle, .dc-el-resize-readout { transition-duration: 1ms; }
58
58
  }
59
- `.trim();function EQ(){if(typeof document>"u")return;if(document.getElementById("dc-el-resize-css"))return;let J=document.createElement("style");J.id="dc-el-resize-css",J.textContent=kQ,document.head.appendChild(J)}var wQ=["nw","n","ne","e","se","s","sw","w"];function TQ(J){return{movesLeft:J==="nw"||J==="w"||J==="sw",movesRight:J==="ne"||J==="e"||J==="se",movesTop:J==="nw"||J==="n"||J==="ne",movesBottom:J==="sw"||J==="s"||J==="se"}}var n=(J)=>Math.round(J*100)/100,H7=1;function bQ(J,Q,$,Z,q,G){let{movesLeft:z,movesRight:X,movesTop:H,movesBottom:N}=TQ(J),M=q.center,U=Q.w,W=Q.h;if(X)U=Q.w+(M?2*$:$);else if(z)U=Q.w-(M?2*$:$);if(N)W=Q.h+(M?2*Z:Z);else if(H)W=Q.h-(M?2*Z:Z);if(q.aspect&&Q.w>0&&Q.h>0){let Y=Q.w/Q.h;if((z||X)&&(H||N)){let _=Math.abs(U-Q.w)/Q.w,V=Math.abs(W-Q.h)/Q.h;if(_>=V)W=U/Y;else U=W*Y}else if(z||X)W=U/Y;else if(H||N)U=W*Y}if(U<H7)U=H7;if(W<H7)W=H7;let F={width:n(U),height:n(W)};if(M){if(G.canMoveLeft&&(z||X))F.left=n(Q.left+(Q.w-U)/2);if(G.canMoveTop&&(H||N))F.top=n(Q.top+(Q.h-W)/2)}else{if(G.canMoveLeft&&z)F.left=n(Q.left+Q.w-U);if(G.canMoveTop&&H)F.top=n(Q.top+Q.h-W)}return F}function XJ(J){if(!J||J==="none")return 0;let Q=/matrix\(([^)]+)\)/.exec(J);if(!Q)return 0;let $=Q[1].split(",").map(Number),Z=$[0]??1,q=$[1]??0;return Math.round(Math.atan2(q,Z)*(180/Math.PI)*100)/100}function xQ(J){if(!J||J==="none")return 1;let Q=/matrix\(([^)]+)\)/.exec(J);if(!Q)return 1;let $=Q[1].split(",").map(Number),Z=$[0]??1,q=$[1]??0,G=Math.hypot(Z,q);return G>0?G:1}function yQ(J){let Q=J.closest(".dc-world");if(!Q)return 1;let $=getComputedStyle(Q),Z=Number.parseFloat($.zoom||"1")||1;return xQ($.transform)*Z}function HJ(J,Q,$){let Z=$*Math.PI/180,q=Math.cos(Z),G=Math.sin(Z);return[J*q-Q*G,J*G+Q*q]}function YJ(J,Q,$,Z){return Math.atan2(Z-Q,$-J)}function vQ(J,Q,$,Z){let q=J+($-Q)*(180/Math.PI);while(q>180)q-=360;while(q<=-180)q+=360;if(Z)q=Math.round(q/15)*15;return Math.round(q*100)/100}function CQ(J,Q){let $={width:`${Q.width}px`,height:`${Q.height}px`};if(typeof Q.left==="number")$.left=`${Q.left}px`;if(typeof Q.top==="number")$.top=`${Q.top}px`;try{window.parent.postMessage({dgn:"resize-request",id:J.cdId,patch:$,before:J.before,idIndex:J.idIndex},"*")}catch{}}function RQ(J,Q){if(!J.artboardId)return;try{window.parent.postMessage({dgn:"resize-artboard-request",artboardId:J.artboardId,width:Q.width,height:Q.height},"*")}catch{}}function SQ(J,Q){try{window.parent.postMessage({dgn:"resize-request",id:J.cdId,patch:{transform:Q},before:J.before,idIndex:J.idIndex},"*")}catch{}}function FJ(){EQ();let{selected:J}=W7(),{tool:Q}=U7(),$=X7(null),Z=X7(null),q=X7(null),G=X7(null),z=J.length===1?J[0]:null,X=z&&typeof z.id==="string"?z.id:null,H=z&&!X&&typeof z.artboardId==="string"?z.artboardId:null,N=Q==="move"&&(!!X||!!H);UJ(()=>{let U=$.current;if(!U)return;let W=()=>{for(let Y of Array.from(U.children)){let j=Y;j.style.opacity="0",j.style.pointerEvents="none"}};if(!N||!z){W();return}let F=()=>{if(Z.current=null,ZJ()){W(),Z.current=requestAnimationFrame(F);return}let Y=P7(document,z);if(!Y){W(),Z.current=requestAnimationFrame(F);return}let j=Y.getBoundingClientRect();if(j.width<=0&&j.height<=0){W(),Z.current=requestAnimationFrame(F);return}let _=H?["e","s","se"]:wQ,V=H?[]:["rot-nw","rot-ne","rot-sw","rot-se"],K=_.length+V.length+1;while(U.children.length<K)U.appendChild(document.createElement("div"));while(U.children.length>K)U.lastChild&&U.removeChild(U.lastChild);let B=j.left+j.width/2,P=j.top+j.height/2,L=XJ(getComputedStyle(Y).transform),A=yQ(Y),k=Y.offsetWidth*A/2,D=Y.offsetHeight*A/2,I={nw:[-k,-D],n:[0,-D],ne:[k,-D],e:[k,0],se:[k,D],s:[0,D],sw:[-k,D],w:[-k,0],"rot-nw":[-k,-D],"rot-ne":[k,-D],"rot-sw":[-k,D],"rot-se":[k,D]},E=[...V,..._];for(let h=0;h<E.length;h++){let x=E[h],v=U.children[h],[d,c]=I[x]??[0,0],[NJ,_J]=HJ(d,c,L),IJ=B+NJ,AJ=P+_J,Y7=x.startsWith("rot-"),S7=x==="n"||x==="s",g7=x==="e"||x==="w",OJ=Y7?10:S7?7:g7?3:4,kJ=Y7?10:S7?3:g7?7:4;v.className="dc-el-resize-handle",v.dataset.corner=x,v.style.opacity="1",v.style.pointerEvents="auto",v.style.left=`${Math.round(IJ-OJ)}px`,v.style.top=`${Math.round(AJ-kJ)}px`,v.style.transform=Y7?"":`rotate(${L}deg)`}let O=U.children[E.length],T=q.current;if(T&&T.el===Y&&!T.corner.startsWith("rot-")){let h=T.lastResult?.width??Y.offsetWidth,x=T.lastResult?.height??Y.offsetHeight,v=`${Math.round(h)} × ${Math.round(x)}`,d=T.lastResult?.left,c=T.lastResult?.top;if(typeof d==="number"||typeof c==="number")v+=` · ${Math.round(d??T.start.left)}, ${Math.round(c??T.start.top)}`;O.className="dc-el-resize-readout",O.textContent=v,O.style.opacity="1",O.style.left=`${Math.round(B)}px`,O.style.top=`${Math.round(P+D)}px`}else O.style.opacity="0";Z.current=requestAnimationFrame(F)};return Z.current=requestAnimationFrame(F),()=>{if(Z.current!=null)cancelAnimationFrame(Z.current)}},[N,z,H]);let M=OQ((U,W)=>{if(U.el.style.width=`${W.width}px`,U.el.style.height=`${W.height}px`,typeof W.left==="number")U.el.style.left=`${W.left}px`;if(typeof W.top==="number")U.el.style.top=`${W.top}px`;U.lastResult=W},[]);return UJ(()=>{let U=$.current;if(!U)return;let W=(V,K)=>{let[B,P]=HJ(K.clientX-V.startClientX,K.clientY-V.startClientY,-V.angle);return bQ(V.corner,V.start,B/V.elZoom,P/V.elZoom,{aspect:!!K.shiftKey,center:!V.artboardId&&!!K.altKey},V.flags)},F=(V)=>{let K=V.target;if(!K?.classList.contains("dc-el-resize-handle"))return;let B=K.dataset.corner;if(!B||!z)return;let P=typeof z.id==="string"?z.id:null,L=!P&&typeof z.artboardId==="string"?z.artboardId:null;if(!P&&!L)return;let A=P7(document,z);if(!A)return;V.preventDefault(),V.stopPropagation();let k=A.getBoundingClientRect(),D=A.offsetWidth?k.width/A.offsetWidth:1,I=getComputedStyle(A),E=!L&&(I.position==="absolute"||I.position==="fixed"),O=L?Number.NaN:Number.parseFloat(A.style.left),T=L?Number.NaN:Number.parseFloat(A.style.top),h=L?0:XJ(I.transform),x=D>0?D:1,v=k.left+k.width/2,d=k.top+k.height/2,c={pointerId:V.pointerId,corner:B,el:A,cdId:P??"",artboardId:L,idIndex:P?m7(document,P,A):0,startClientX:V.clientX,startClientY:V.clientY,elZoom:x,angle:h,cx:v,cy:d,rotStartPointer:YJ(v,d,V.clientX,V.clientY),start:{w:(h?A.offsetWidth:k.width/x)||k.width/x,h:(h?A.offsetHeight:k.height/x)||k.height/x,left:O,top:T},flags:{canMoveLeft:E&&Number.isFinite(O),canMoveTop:E&&Number.isFinite(T)},before:{width:A.style.width||null,height:A.style.height||null,left:A.style.left||null,top:A.style.top||null,transform:A.style.transform||null},lastResult:null,lastTransform:null};q.current=c;try{K.setPointerCapture(V.pointerId)}catch{}},Y=(V)=>{let K=q.current;if(!K||V.pointerId!==K.pointerId)return;if(V.preventDefault(),K.corner.startsWith("rot-")){let P=`rotate(${vQ(K.angle,K.rotStartPointer,YJ(K.cx,K.cy,V.clientX,V.clientY),!!V.shiftKey)}deg)`;K.el.style.transform=P,K.lastTransform=P;return}M(K,W(K,V))},j=(V)=>{let K=q.current;if(!K||V.pointerId!==K.pointerId)return;if(q.current=null,K.corner.startsWith("rot-")){let L=K.lastTransform;if(!L||L===K.before.transform)return;G.current={el:K.el,before:K.before},SQ(K,L);return}let B=K.lastResult??W(K,V);if(!(`${B.width}px`!==K.before.width||`${B.height}px`!==K.before.height||typeof B.left==="number"&&`${B.left}px`!==K.before.left||typeof B.top==="number"&&`${B.top}px`!==K.before.top))return;if(G.current={el:K.el,before:K.before},K.artboardId)RQ(K,B);else CQ(K,B)},_=(V)=>{let K=V.data;if(K?.dgn!=="resize-failed"&&K?.dgn!=="resize-artboard-failed")return;if(V.source!==window.parent)return;let B=G.current;if(!B)return;if(B.el.style.width=B.before.width??"",B.el.style.height=B.before.height??"",B.before.left!==null||B.el.style.left)B.el.style.left=B.before.left??"";if(B.before.top!==null||B.el.style.top)B.el.style.top=B.before.top??"";if(B.before.transform!==null||B.el.style.transform)B.el.style.transform=B.before.transform??"";G.current=null};return U.addEventListener("pointerdown",F),window.addEventListener("pointermove",Y),window.addEventListener("pointerup",j),window.addEventListener("pointercancel",j),window.addEventListener("message",_),()=>{U.removeEventListener("pointerdown",F),window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",j),window.removeEventListener("pointercancel",j),window.removeEventListener("message",_)}},[z,M]),gQ("div",{ref:$,"aria-hidden":"true"})}import{jsx as R,jsxs as MJ,Fragment as oQ}from"react/jsx-runtime";var uQ=new Set(["drop-comment","tool","escape","hover"]);function V7(){return typeof document<"u"&&!document.querySelector(".dc-canvas")}function R7(J,Q){if(typeof document>"u")return null;let $=document.elementFromPoint(J,Q);if(!$)return null;if($.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mc-hover-halo], [data-mc-selection-halo], .dc-el-resize-handle"))return null;let Z=$.tagName;if(Z==="HTML"||Z==="BODY")return null;return $}function mQ(J,Q){let $=R7(J,Q);if(!$)return null;return $.closest("[data-cd-id]")??$}function dQ({children:J,file:Q}){let{tool:$,setTool:Z}=U7(),q=W7(),G=p(null),[z,X]=$7(null),H=p($);H.current=$;let N=fQ(()=>()=>H.current,[]);f(()=>{if($!=="comment")X(null)},[$]);let[M,U]=$7(null),[W,F]=$7(!1);return f(()=>{let Y=()=>F(V7());Y();let j=requestAnimationFrame(Y),_=setTimeout(Y,120);return()=>{cancelAnimationFrame(j),clearTimeout(_)}},[]),f(()=>{if(typeof document>"u")return;let Y=(j)=>{if(j.button!==0||!(j.metaKey||j.ctrlKey))return;if(!V7())return;if(e(j.target))return;let _=mQ(j.clientX,j.clientY);if(!_)return;j.preventDefault(),j.stopImmediatePropagation();let V=_.getAttribute("data-cd-id"),K=D7({el:_,cdId:V,artboardId:null});if(j.shiftKey)q.add(K);else q.replace(K);U(_)};return document.addEventListener("pointerdown",Y,!0),()=>document.removeEventListener("pointerdown",Y,!0)},[q]),f(()=>{if(q.selected.length===0)U(null)},[q.selected]),f(()=>{let Y=G.current;if(Y)Y.setAttribute("data-active-tool",$);if(typeof document<"u"&&document.body)document.body.setAttribute("data-active-tool",$);return()=>{Y?.removeAttribute("data-active-tool")}},[$]),f(()=>{if(typeof window>"u")return;let Y=(j)=>{let _=j.data;if(!_||typeof _!=="object"||_.dgn!=="tool-set")return;if(typeof _.tool==="string")Z(_.tool)};return window.addEventListener("message",Y),()=>window.removeEventListener("message",Y)},[Z]),VJ({hostRef:G,getActiveTool:N,claimableActions:uQ,callbacks:{onHover:({clientX:Y,clientY:j})=>{if(H.current!=="comment"||!V7()){X(null);return}let _=R7(Y,j);X((V)=>V===_?V:_)},onTool:({tool:Y})=>Z(Y),onEscape:()=>{if(H.current!=="move")Z("move");if(X(null),q.clear(),typeof window<"u")try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},onDropComment:({clientX:Y,clientY:j})=>lQ(Y,j,q,Q)}}),MJ("div",{"data-mc-host":!0,ref:G,style:{display:"contents"},children:[J,z?R(cQ,{el:z}):null,M?R(iQ,{el:M}):null,W?R(FJ,{}):null,R(e7,{})]})}function iQ({el:J}){let Q=p(null),$=p(J);$.current=J;let Z=p(null);return f(()=>{let q=()=>{Z.current=null;let G=Q.current,z=$.current;if(G&&z?.isConnected){let X=z.getBoundingClientRect();if(X.width===0&&X.height===0)G.style.display="none";else G.style.display="block",G.style.left=`${Math.round(X.left)}px`,G.style.top=`${Math.round(X.top)}px`,G.style.width=`${Math.round(X.width)}px`,G.style.height=`${Math.round(X.height)}px`}else if(G)G.style.display="none";Z.current=requestAnimationFrame(q)};return Z.current=requestAnimationFrame(q),()=>{if(Z.current!=null)cancelAnimationFrame(Z.current)}},[]),R("div",{ref:Q,"aria-hidden":"true","data-mc-selection-halo":"",style:{position:"fixed",display:"none",pointerEvents:"none",zIndex:2147483645,border:"1.5px solid var(--maude-hud-accent, oklch(0.680 0.180 268))",borderRadius:"3px",boxSizing:"border-box"}})}function cQ({el:J}){let Q=p(null),$=p(J);$.current=J;let Z=p(null);return f(()=>{let q=()=>{Z.current=null;let G=Q.current,z=$.current;if(G&&z?.isConnected){let X=z.getBoundingClientRect();if(X.width===0&&X.height===0)G.style.display="none";else G.style.display="block",G.style.left=`${Math.round(X.left)}px`,G.style.top=`${Math.round(X.top)}px`,G.style.width=`${Math.round(X.width)}px`,G.style.height=`${Math.round(X.height)}px`}else if(G)G.style.display="none";Z.current=requestAnimationFrame(q)};return Z.current=requestAnimationFrame(q),()=>{if(Z.current!=null)cancelAnimationFrame(Z.current)}},[]),R("div",{ref:Q,"aria-hidden":"true","data-mc-hover-halo":"",style:{position:"fixed",display:"none",pointerEvents:"none",zIndex:2147483646,border:"2px solid var(--maude-hud-accent, #d63b1f)",borderRadius:"3px",boxSizing:"border-box"}})}function lQ(J,Q,$,Z){if(typeof document>"u")return;let q=A7(document,J,Q,{deep:!0});if(!q)q=A7(document,J,Q,{deep:!1});if(!q&&!V7()&&typeof document.elementsFromPoint==="function"){let z=document.elementsFromPoint(J,Q);for(let X of z){let H=X.closest?.("[data-cd-id]");if(!H)continue;if(!H.closest(".dc-artboard-body"))continue;let N=H.closest("[data-dc-screen]");q={el:H,cdId:H.getAttribute("data-cd-id"),artboardId:N?.getAttribute("data-dc-screen")??null};break}}if(!q&&V7()){let z=R7(J,Q);if(z)q={el:z,cdId:z.getAttribute("data-cd-id"),artboardId:null}}if(!q){let z={file:Z,id:void 0,selector:"",artboardId:null,tag:"",classes:"",text:"",dom_path:[],bounds:{x:J-12,y:Q-12,w:24,h:24},html:""};PJ(z,J,Q);return}let G=D7(q,Z);$.replace(G),PJ(G,J,Q)}function PJ(J,Q,$){if(typeof document<"u")try{document.dispatchEvent(new CustomEvent("cm:open-composer",{detail:{selection:J,clientX:Q,clientY:$}}))}catch{}if(typeof window<"u")try{window.parent.postMessage({dgn:"comment-compose",selection:J},"*")}catch{}}function jJ(J,Q){return R(zJ,{initial:"browse",children:R(r7,{children:R(dQ,{file:Q,children:R(J,{})})})})}function V3(J,Q){let $=pQ(Q.rootEl);if(!Q.commentsEnabled){$.render(C7(J));return}let Z=Q.file??F7();$.render(C7(aQ,{initialCanvas:J,file:Z}))}var DJ="__maudeCanvasRuntime";function rQ({Canvas:J,file:Q,onOk:$}){return f(()=>{$()},[]),jJ(J,Q)}class LJ extends hQ{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(){this.props.onError()}componentDidUpdate(J){if(J.attempt!==this.props.attempt&&this.state.hasError)this.setState({hasError:!1})}render(){if(this.state.hasError)return this.props.fallback();return this.props.children}}function nQ({message:J}){return C7("div",{className:"dc-hmr-holding",role:"status","aria-live":"polite",title:J?`Holding last working render — ${J}`:"Holding last working render"},"⏸ build error — držím poslední funkční verzi")}function aQ({initialCanvas:J,file:Q}){let[{canvas:$,attempt:Z},q]=$7({canvas:J,attempt:0}),[G,z]=$7({on:!1}),X=p(null),H=p($);H.current=$,f(()=>{let W={remount:(F)=>q((Y)=>({canvas:F,attempt:Y.attempt+1})),setHolding:(F,Y)=>z(F?{on:!0,message:Y}:{on:!1})};return window[DJ]=W,()=>{window[DJ]=void 0}},[]);let N=v7(()=>{X.current=H.current,z((W)=>W.on?{on:!1}:W)},[]),M=v7(()=>{z({on:!0,message:"render error"})},[]),U=v7(()=>{let W=X.current;return W?jJ(W,Q):null},[Q]);return MJ(oQ,{children:[R(LJ,{attempt:Z,onError:M,fallback:U,children:R(rQ,{Canvas:$,file:Q,onOk:N},Z)}),G.on?R(nQ,{message:G.message}):null]})}export{mQ as pickSpecimenSelectEl,V3 as mountCanvas,V7 as isBareSpecimen,LJ as CanvasErrorBoundary};
59
+ `.trim();function TQ(){if(typeof document>"u")return;if(document.getElementById("dc-el-resize-css"))return;let J=document.createElement("style");J.id="dc-el-resize-css",J.textContent=wQ,document.head.appendChild(J)}var bQ=["nw","n","ne","e","se","s","sw","w"];function xQ(J){return{movesLeft:J==="nw"||J==="w"||J==="sw",movesRight:J==="ne"||J==="e"||J==="se",movesTop:J==="nw"||J==="n"||J==="ne",movesBottom:J==="sw"||J==="s"||J==="se"}}var n=(J)=>Math.round(J*100)/100,H7=1;function yQ(J,Q,$,V,Z,G){let{movesLeft:z,movesRight:K,movesTop:H,movesBottom:j}=xQ(J),N=Z.center,U=Q.w,B=Q.h;if(K)U=Q.w+(N?2*$:$);else if(z)U=Q.w-(N?2*$:$);if(j)B=Q.h+(N?2*V:V);else if(H)B=Q.h-(N?2*V:V);if(Z.aspect&&Q.w>0&&Q.h>0){let Y=Q.w/Q.h;if((z||K)&&(H||j)){let O=Math.abs(U-Q.w)/Q.w,q=Math.abs(B-Q.h)/Q.h;if(O>=q)B=U/Y;else U=B*Y}else if(z||K)B=U/Y;else if(H||j)U=B*Y}if(U<H7)U=H7;if(B<H7)B=H7;let P={width:n(U),height:n(B)};if(N){if(G.canMoveLeft&&(z||K))P.left=n(Q.left+(Q.w-U)/2);if(G.canMoveTop&&(H||j))P.top=n(Q.top+(Q.h-B)/2)}else{if(G.canMoveLeft&&z)P.left=n(Q.left+Q.w-U);if(G.canMoveTop&&H)P.top=n(Q.top+Q.h-B)}return P}function HJ(J){if(!J||J==="none")return 0;let Q=/matrix\(([^)]+)\)/.exec(J);if(!Q)return 0;let $=Q[1].split(",").map(Number),V=$[0]??1,Z=$[1]??0;return Math.round(Math.atan2(Z,V)*(180/Math.PI)*100)/100}function vQ(J){if(!J||J==="none")return 1;let Q=/matrix\(([^)]+)\)/.exec(J);if(!Q)return 1;let $=Q[1].split(",").map(Number),V=$[0]??1,Z=$[1]??0,G=Math.hypot(V,Z);return G>0?G:1}function CQ(J){let Q=J.closest(".dc-world");if(!Q)return 1;let $=getComputedStyle(Q),V=Number.parseFloat($.zoom||"1")||1;return vQ($.transform)*V}function YJ(J,Q,$){let V=$*Math.PI/180,Z=Math.cos(V),G=Math.sin(V);return[J*Z-Q*G,J*G+Q*Z]}function FJ(J,Q,$,V){return Math.atan2(V-Q,$-J)}function RQ(J,Q,$,V){let Z=J+($-Q)*(180/Math.PI);while(Z>180)Z-=360;while(Z<=-180)Z+=360;if(V)Z=Math.round(Z/15)*15;return Math.round(Z*100)/100}function SQ(J,Q){let $={width:`${Q.width}px`,height:`${Q.height}px`};if(typeof Q.left==="number")$.left=`${Q.left}px`;if(typeof Q.top==="number")$.top=`${Q.top}px`;try{window.parent.postMessage({dgn:"resize-request",id:J.cdId,patch:$,before:J.before,idIndex:J.idIndex},"*")}catch{}}function gQ(J,Q){if(!J.artboardId)return;try{window.parent.postMessage({dgn:"resize-artboard-request",artboardId:J.artboardId,width:Q.width,height:Q.height},"*")}catch{}}function hQ(J,Q){try{window.parent.postMessage({dgn:"resize-request",id:J.cdId,patch:{transform:Q},before:J.before,idIndex:J.idIndex},"*")}catch{}}function PJ(){TQ();let{selected:J}=W7(),{tool:Q}=U7(),$=X7(null),V=X7(null),Z=X7(null),G=X7(null),z=J.length===1?J[0]:null,K=z&&typeof z.id==="string"?z.id:null,H=z&&!K&&typeof z.artboardId==="string"?z.artboardId:null,j=Q==="move"&&(!!K||!!H);XJ(()=>{let U=$.current;if(!U)return;let B=()=>{for(let Y of Array.from(U.children)){let M=Y;M.style.opacity="0",M.style.pointerEvents="none"}};if(!j||!z){B();return}let P=()=>{if(V.current=null,qJ()){B(),V.current=requestAnimationFrame(P);return}let Y=P7(document,z);if(!Y){B(),V.current=requestAnimationFrame(P);return}let M=Y.getBoundingClientRect();if(M.width<=0&&M.height<=0){B(),V.current=requestAnimationFrame(P);return}let O=H?["e","s","se"]:bQ,q=H?[]:["rot-nw","rot-ne","rot-sw","rot-se"],X=O.length+q.length+1;while(U.children.length<X)U.appendChild(document.createElement("div"));while(U.children.length>X)U.lastChild&&U.removeChild(U.lastChild);let _=M.left+M.width/2,F=M.top+M.height/2,W=HJ(getComputedStyle(Y).transform),D=CQ(Y),A=Y.offsetWidth*D/2,L=Y.offsetHeight*D/2,I={nw:[-A,-L],n:[0,-L],ne:[A,-L],e:[A,0],se:[A,L],s:[0,L],sw:[-A,L],w:[-A,0],"rot-nw":[-A,-L],"rot-ne":[A,-L],"rot-sw":[-A,L],"rot-se":[A,L]},E=[...q,...O];for(let f=0;f<E.length;f++){let y=E[f],v=U.children[f],[d,c]=I[y]??[0,0],[_J,IJ]=YJ(d,c,W),AJ=_+_J,OJ=F+IJ,Y7=y.startsWith("rot-"),g7=y==="n"||y==="s",h7=y==="e"||y==="w",kJ=Y7?10:g7?7:h7?3:4,EJ=Y7?10:g7?3:h7?7:4;v.className="dc-el-resize-handle",v.dataset.corner=y,v.style.opacity="1",v.style.pointerEvents="auto",v.style.left=`${Math.round(AJ-kJ)}px`,v.style.top=`${Math.round(OJ-EJ)}px`,v.style.transform=Y7?"":`rotate(${W}deg)`}let k=U.children[E.length],T=Z.current;if(T&&T.el===Y&&!T.corner.startsWith("rot-")){let f=T.lastResult?.width??Y.offsetWidth,y=T.lastResult?.height??Y.offsetHeight,v=`${Math.round(f)} × ${Math.round(y)}`,d=T.lastResult?.left,c=T.lastResult?.top;if(typeof d==="number"||typeof c==="number")v+=` · ${Math.round(d??T.start.left)}, ${Math.round(c??T.start.top)}`;k.className="dc-el-resize-readout",k.textContent=v,k.style.opacity="1",k.style.left=`${Math.round(_)}px`,k.style.top=`${Math.round(F+L)}px`}else k.style.opacity="0";V.current=requestAnimationFrame(P)};return V.current=requestAnimationFrame(P),()=>{if(V.current!=null)cancelAnimationFrame(V.current)}},[j,z,H]);let N=EQ((U,B)=>{if(U.el.style.width=`${B.width}px`,U.el.style.height=`${B.height}px`,typeof B.left==="number")U.el.style.left=`${B.left}px`;if(typeof B.top==="number")U.el.style.top=`${B.top}px`;U.lastResult=B},[]);return XJ(()=>{let U=$.current;if(!U)return;let B=(q,X)=>{let[_,F]=YJ(X.clientX-q.startClientX,X.clientY-q.startClientY,-q.angle);return yQ(q.corner,q.start,_/q.elZoom,F/q.elZoom,{aspect:!!X.shiftKey,center:!q.artboardId&&!!X.altKey},q.flags)},P=(q)=>{let X=q.target;if(!X?.classList.contains("dc-el-resize-handle"))return;let _=X.dataset.corner;if(!_||!z)return;let F=typeof z.id==="string"?z.id:null,W=!F&&typeof z.artboardId==="string"?z.artboardId:null;if(!F&&!W)return;let D=P7(document,z);if(!D)return;q.preventDefault(),q.stopPropagation();let A=D.getBoundingClientRect(),L=D.offsetWidth?A.width/D.offsetWidth:1,I=getComputedStyle(D),E=!W&&(I.position==="absolute"||I.position==="fixed"),k=W?Number.NaN:Number.parseFloat(D.style.left),T=W?Number.NaN:Number.parseFloat(D.style.top),f=W?0:HJ(I.transform),y=L>0?L:1,v=A.left+A.width/2,d=A.top+A.height/2,c={pointerId:q.pointerId,corner:_,el:D,cdId:F??"",artboardId:W,idIndex:F?d7(document,F,D):0,startClientX:q.clientX,startClientY:q.clientY,elZoom:y,angle:f,cx:v,cy:d,rotStartPointer:FJ(v,d,q.clientX,q.clientY),start:{w:(f?D.offsetWidth:A.width/y)||A.width/y,h:(f?D.offsetHeight:A.height/y)||A.height/y,left:k,top:T},flags:{canMoveLeft:E&&Number.isFinite(k),canMoveTop:E&&Number.isFinite(T)},before:{width:D.style.width||null,height:D.style.height||null,left:D.style.left||null,top:D.style.top||null,transform:D.style.transform||null},lastResult:null,lastTransform:null};Z.current=c;try{X.setPointerCapture(q.pointerId)}catch{}},Y=(q)=>{let X=Z.current;if(!X||q.pointerId!==X.pointerId)return;if(q.preventDefault(),X.corner.startsWith("rot-")){let F=`rotate(${RQ(X.angle,X.rotStartPointer,FJ(X.cx,X.cy,q.clientX,q.clientY),!!q.shiftKey)}deg)`;X.el.style.transform=F,X.lastTransform=F;return}N(X,B(X,q))},M=(q)=>{let X=Z.current;if(!X||q.pointerId!==X.pointerId)return;if(Z.current=null,X.corner.startsWith("rot-")){let W=X.lastTransform;if(!W||W===X.before.transform)return;G.current={el:X.el,before:X.before},hQ(X,W);return}let _=X.lastResult??B(X,q);if(!(`${_.width}px`!==X.before.width||`${_.height}px`!==X.before.height||typeof _.left==="number"&&`${_.left}px`!==X.before.left||typeof _.top==="number"&&`${_.top}px`!==X.before.top))return;if(G.current={el:X.el,before:X.before},X.artboardId)gQ(X,_);else SQ(X,_)},O=(q)=>{let X=q.data;if(X?.dgn!=="resize-failed"&&X?.dgn!=="resize-artboard-failed")return;if(q.source!==window.parent)return;let _=G.current;if(!_)return;if(_.el.style.width=_.before.width??"",_.el.style.height=_.before.height??"",_.before.left!==null||_.el.style.left)_.el.style.left=_.before.left??"";if(_.before.top!==null||_.el.style.top)_.el.style.top=_.before.top??"";if(_.before.transform!==null||_.el.style.transform)_.el.style.transform=_.before.transform??"";G.current=null};return U.addEventListener("pointerdown",P),window.addEventListener("pointermove",Y),window.addEventListener("pointerup",M),window.addEventListener("pointercancel",M),window.addEventListener("message",O),()=>{U.removeEventListener("pointerdown",P),window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",M),window.removeEventListener("pointercancel",M),window.removeEventListener("message",O)}},[z,N]),fQ("div",{ref:$,"aria-hidden":"true"})}import{jsx as R,jsxs as jJ,Fragment as tQ}from"react/jsx-runtime";var dQ=new Set(["drop-comment","tool","escape","hover"]);function Z7(){return typeof document<"u"&&!document.querySelector(".dc-canvas")}function S7(J,Q){if(typeof document>"u")return null;let $=document.elementFromPoint(J,Q);if(!$)return null;if($.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mc-hover-halo], [data-mc-selection-halo], .dc-el-resize-handle"))return null;let V=$.tagName;if(V==="HTML"||V==="BODY")return null;return $}function iQ(J,Q){let $=S7(J,Q);if(!$)return null;return $.closest("[data-cd-id]")??$}function cQ({children:J,file:Q}){let{tool:$,setTool:V}=U7(),Z=W7(),G=u(null),[z,K]=V7(null),H=u($);H.current=$;let j=uQ(()=>()=>H.current,[]);p(()=>{if($!=="comment")K(null)},[$]);let[N,U]=V7(null),[B,P]=V7(!1);return p(()=>{let Y=()=>P(Z7());Y();let M=requestAnimationFrame(Y),O=setTimeout(Y,120);return()=>{cancelAnimationFrame(M),clearTimeout(O)}},[]),p(()=>{if(typeof document>"u")return;let Y=(M)=>{if(M.button!==0||!(M.metaKey||M.ctrlKey))return;if(!Z7())return;if(J7(M.target))return;let O=iQ(M.clientX,M.clientY);if(!O)return;M.preventDefault(),M.stopImmediatePropagation();let q=O.getAttribute("data-cd-id"),X=D7({el:O,cdId:q,artboardId:null});if(M.shiftKey)Z.add(X);else Z.replace(X);U(O)};return document.addEventListener("pointerdown",Y,!0),()=>document.removeEventListener("pointerdown",Y,!0)},[Z]),p(()=>{if(Z.selected.length===0)U(null)},[Z.selected]),p(()=>{let Y=G.current;if(Y)Y.setAttribute("data-active-tool",$);if(typeof document<"u"&&document.body)document.body.setAttribute("data-active-tool",$);return()=>{Y?.removeAttribute("data-active-tool")}},[$]),p(()=>{if(typeof window>"u")return;let Y=(M)=>{let O=M.data;if(!O||typeof O!=="object"||O.dgn!=="tool-set")return;if(typeof O.tool==="string")V(O.tool)};return window.addEventListener("message",Y),()=>window.removeEventListener("message",Y)},[V]),ZJ({hostRef:G,getActiveTool:j,claimableActions:dQ,callbacks:{onHover:({clientX:Y,clientY:M})=>{if(H.current!=="comment"||!Z7()){K(null);return}let O=S7(Y,M);K((q)=>q===O?q:O)},onTool:({tool:Y})=>V(Y),onEscape:()=>{if(H.current!=="move")V("move");if(K(null),Z.clear(),typeof window<"u")try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},onDropComment:({clientX:Y,clientY:M})=>nQ(Y,M,Z,Q)}}),jJ("div",{"data-mc-host":!0,ref:G,style:{display:"contents"},children:[J,z?R(rQ,{el:z}):null,N?R(lQ,{el:N}):null,B?R(PJ,{}):null,R(QJ,{})]})}function lQ({el:J}){let Q=u(null),$=u(J);$.current=J;let V=u(null);return p(()=>{let Z=()=>{V.current=null;let G=Q.current,z=$.current;if(G&&z?.isConnected){let K=z.getBoundingClientRect();if(K.width===0&&K.height===0)G.style.display="none";else G.style.display="block",G.style.left=`${Math.round(K.left)}px`,G.style.top=`${Math.round(K.top)}px`,G.style.width=`${Math.round(K.width)}px`,G.style.height=`${Math.round(K.height)}px`}else if(G)G.style.display="none";V.current=requestAnimationFrame(Z)};return V.current=requestAnimationFrame(Z),()=>{if(V.current!=null)cancelAnimationFrame(V.current)}},[]),R("div",{ref:Q,"aria-hidden":"true","data-mc-selection-halo":"",style:{position:"fixed",display:"none",pointerEvents:"none",zIndex:2147483645,border:"1.5px solid var(--maude-hud-accent, oklch(0.680 0.180 268))",borderRadius:"3px",boxSizing:"border-box"}})}function rQ({el:J}){let Q=u(null),$=u(J);$.current=J;let V=u(null);return p(()=>{let Z=()=>{V.current=null;let G=Q.current,z=$.current;if(G&&z?.isConnected){let K=z.getBoundingClientRect();if(K.width===0&&K.height===0)G.style.display="none";else G.style.display="block",G.style.left=`${Math.round(K.left)}px`,G.style.top=`${Math.round(K.top)}px`,G.style.width=`${Math.round(K.width)}px`,G.style.height=`${Math.round(K.height)}px`}else if(G)G.style.display="none";V.current=requestAnimationFrame(Z)};return V.current=requestAnimationFrame(Z),()=>{if(V.current!=null)cancelAnimationFrame(V.current)}},[]),R("div",{ref:Q,"aria-hidden":"true","data-mc-hover-halo":"",style:{position:"fixed",display:"none",pointerEvents:"none",zIndex:2147483646,border:"2px solid var(--maude-hud-accent, #d63b1f)",borderRadius:"3px",boxSizing:"border-box"}})}function nQ(J,Q,$,V){if(typeof document>"u")return;let Z=O7(document,J,Q,{deep:!0});if(!Z)Z=O7(document,J,Q,{deep:!1});if(!Z&&!Z7()&&typeof document.elementsFromPoint==="function"){let z=document.elementsFromPoint(J,Q);for(let K of z){let H=K.closest?.("[data-cd-id]");if(!H)continue;if(!H.closest(".dc-artboard-body"))continue;let j=H.closest("[data-dc-screen]");Z={el:H,cdId:H.getAttribute("data-cd-id"),artboardId:j?.getAttribute("data-dc-screen")??null};break}}if(!Z&&Z7()){let z=S7(J,Q);if(z)Z={el:z,cdId:z.getAttribute("data-cd-id"),artboardId:null}}if(!Z){let z={file:V,id:void 0,selector:"",artboardId:null,tag:"",classes:"",text:"",dom_path:[],bounds:{x:J-12,y:Q-12,w:24,h:24},html:""};DJ(z,J,Q);return}let G=D7(Z,V);$.replace(G),DJ(G,J,Q)}function DJ(J,Q,$){if(typeof document<"u")try{document.dispatchEvent(new CustomEvent("cm:open-composer",{detail:{selection:J,clientX:Q,clientY:$}}))}catch{}if(typeof window<"u")try{window.parent.postMessage({dgn:"comment-compose",selection:J},"*")}catch{}}function MJ(J,Q){return R(UJ,{initial:"browse",children:R(n7,{children:R(cQ,{file:Q,children:R(J,{})})})})}function q3(J,Q){let $=mQ(Q.rootEl);if(!Q.commentsEnabled){$.render(R7(J));return}let V=Q.file??F7();$.render(R7(sQ,{initialCanvas:J,file:V}))}var LJ="__maudeCanvasRuntime";function aQ({Canvas:J,file:Q,onOk:$}){return p(()=>{$()},[]),MJ(J,Q)}class NJ extends pQ{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(){this.props.onError()}componentDidUpdate(J){if(J.attempt!==this.props.attempt&&this.state.hasError)this.setState({hasError:!1})}render(){if(this.state.hasError)return this.props.fallback();return this.props.children}}function oQ({message:J}){return R7("div",{className:"dc-hmr-holding",role:"status","aria-live":"polite",title:J?`Holding last working render — ${J}`:"Holding last working render"},"⏸ build error — držím poslední funkční verzi")}function sQ({initialCanvas:J,file:Q}){let[{canvas:$,attempt:V},Z]=V7({canvas:J,attempt:0}),[G,z]=V7({on:!1}),K=u(null),H=u($);H.current=$,p(()=>{let B={remount:(P)=>Z((Y)=>({canvas:P,attempt:Y.attempt+1})),setHolding:(P,Y)=>z(P?{on:!0,message:Y}:{on:!1})};return window[LJ]=B,()=>{window[LJ]=void 0}},[]);let j=C7(()=>{K.current=H.current,z((B)=>B.on?{on:!1}:B)},[]),N=C7(()=>{z({on:!0,message:"render error"})},[]),U=C7(()=>{let B=K.current;return B?MJ(B,Q):null},[Q]);return jJ(tQ,{children:[R(NJ,{attempt:V,onError:N,fallback:U,children:R(aQ,{Canvas:$,file:Q,onOk:j},V)}),G.on?R(oQ,{message:G.message}):null]})}export{iQ as pickSpecimenSelectEl,q3 as mountCanvas,Z7 as isBareSpecimen,NJ as CanvasErrorBoundary};
@@ -5529,9 +5529,12 @@ export function createHttp(
5529
5529
  if (!body || typeof body.body !== 'string' || !body.body.trim()) {
5530
5530
  return new Response('body.body required', { status: 400 });
5531
5531
  }
5532
+ // In a cell the proxy vouches who is replying; a body cannot claim
5533
+ // somebody else (and the cell's git identity is the machine's).
5534
+ const vouched = isWorkspaceMode() ? req.headers.get('x-maude-user') : null;
5532
5535
  const next = await api.commentsAddReply(id, {
5533
5536
  body: body.body,
5534
- author: typeof body.author === 'string' ? body.author : undefined,
5537
+ author: vouched || (typeof body.author === 'string' ? body.author : undefined),
5535
5538
  });
5536
5539
  if (!next) return new Response('Not found', { status: 404 });
5537
5540
  return Response.json(next, { headers: { 'Cache-Control': 'no-store' } });
@@ -468,6 +468,9 @@ function startServer(port: number): BunServer {
468
468
  // D3 — whose socket this is, from the proxy's vouched header. Same
469
469
  // handshake-time reasoning as `readOnly` below; `''` on a desktop.
470
470
  session: WORKSPACE ? normalizeSessionKey(req.headers.get(SESSION_HEADER)) : '',
471
+ // Who, for attribution (a comment's author) — the proxy's vouched
472
+ // member; a desktop leaves it to the project's git identity.
473
+ user: WORKSPACE ? (req.headers.get('x-maude-user') ?? '').slice(0, 120) : '',
471
474
  // Cloud Phase 27 — stamp the role onto the socket at the handshake,
472
475
  // the one moment the session is unambiguous. Fails CLOSED in a cell
473
476
  // for the same reason the HTTP gate does: an absent header is an
@@ -41,6 +41,8 @@ export interface AcceptedLinkOptions {
41
41
  client?: TransactionClient;
42
42
  /** T16 — an AI action opened, was held, or ended. */
43
43
  onStage?: (summary: StageSummary | null) => void;
44
+ /** Every bootstrap the project answered (its manifest and its own config). */
45
+ onBootstrap?: (b: Bootstrap) => void;
44
46
  }
45
47
 
46
48
  export type StructuralOutcome = ProposalOutcome & { queued?: boolean };
@@ -96,6 +98,7 @@ export function createAcceptedLink(opts: AcceptedLinkOptions) {
96
98
  }
97
99
  mode = next;
98
100
  manifest = b;
101
+ opts.onBootstrap?.(b);
99
102
  return b;
100
103
  } catch (err) {
101
104
  if (err instanceof TransactionError && err.code === 'absent') mode = 'legacy';
@@ -547,6 +547,16 @@ export interface FilePlane {
547
547
  doruceka(): Record<string, DeliveryState>;
548
548
  /** How many rows the ledger holds, before the doručenka's cap. */
549
549
  dorucekaTotal(): number;
550
+ /**
551
+ * The media this machine cannot place, in BYTES as well as files — T29.
552
+ * `null` when nothing is blocked, so a healthy project carries no field.
553
+ */
554
+ blocked(): {
555
+ files: number;
556
+ bytes: number;
557
+ unmeasured: number;
558
+ byClass: Record<string, { files: number; bytes: number }>;
559
+ } | null;
550
560
  }
551
561
 
552
562
  export function createFilePlane(opts: FilePlaneOptions): FilePlane {
@@ -1600,6 +1610,21 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
1600
1610
  holdOversized(out, ledger, here);
1601
1611
  continue;
1602
1612
  }
1613
+ // THE FILE THAT WAS TOO BIG IS GONE. It never reached the project and
1614
+ // is no longer on this machine, so nothing is held any more — the panel
1615
+ // kept saying "1 file — too big" for a file that no longer existed.
1616
+ const kept = ledger.row(rel);
1617
+ if (
1618
+ !here &&
1619
+ kept?.state === 'refused' &&
1620
+ kept.blockedClass === 'too-large' &&
1621
+ !kept.syncedHash &&
1622
+ !(row && !row.deleted) &&
1623
+ !ledger.remoteOf(rel)
1624
+ ) {
1625
+ ledger.forget(rel);
1626
+ continue;
1627
+ }
1603
1628
  // What the hub holds: this page when it spoke about the path, otherwise
1604
1629
  // what we last learned. `undefined` (never learned) reads as null only
1605
1630
  // after a full read has had the chance to say so.
@@ -2208,6 +2233,39 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
2208
2233
  dorucekaTotal() {
2209
2234
  return Object.keys(ledger.rows()).length;
2210
2235
  },
2236
+ /**
2237
+ * HOW MUCH MEDIA IS NOT HERE — plan T29.
2238
+ *
2239
+ * `failed` counts files, and a count is the wrong unit for the question
2240
+ * an operator is actually asking. "Nine files failed" is unreadable: nine
2241
+ * CSS sidecars is nothing, nine videos is the project. The bytes are what
2242
+ * says whether a person is looking at a broken thumbnail or at a project
2243
+ * whose media never arrived.
2244
+ *
2245
+ * Bounded by construction — one entry per blocked CLASS, and the classes
2246
+ * are a fixed set (`file-ledger.ts`), never per path. Sizes come from the
2247
+ * ledger's stat cache; a row we have never measured contributes to the
2248
+ * file count and nothing to the bytes, which is honest about not knowing
2249
+ * rather than guessing a size.
2250
+ */
2251
+ blocked() {
2252
+ const byClass: Record<string, { files: number; bytes: number }> = {};
2253
+ let files = 0;
2254
+ let bytes = 0;
2255
+ let unmeasured = 0;
2256
+ for (const row of Object.values(ledger.rows())) {
2257
+ if (row.state !== 'refused' && row.state !== 'stuck') continue;
2258
+ const cls = row.blockedClass ?? (row.state === 'stuck' ? 'unreachable' : 'refused');
2259
+ const size = typeof row.size === 'number' ? row.size : 0;
2260
+ if (!row.size) unmeasured += 1;
2261
+ byClass[cls] ??= { files: 0, bytes: 0 };
2262
+ byClass[cls].files += 1;
2263
+ byClass[cls].bytes += size;
2264
+ files += 1;
2265
+ bytes += size;
2266
+ }
2267
+ return files === 0 ? null : { files, bytes, unmeasured, byClass };
2268
+ },
2211
2269
  };
2212
2270
  }
2213
2271
 
@@ -36,6 +36,7 @@ import * as Y from 'yjs';
36
36
  import { renewHubCredential } from '../cloud/renew.ts';
37
37
  import { Y_TYPES } from '../collab/persistence.ts';
38
38
  import type { Context, LinkedHub } from '../context.ts';
39
+ import { PROJECT_CONFIG_CACHE_REL, reloadConfig, sanitizeProjectConfig } from '../context.ts';
39
40
  import { createHistory } from '../history.ts';
40
41
  import { SYNTHETIC_FS_DELAY_MS } from '../hmr-broadcast.ts';
41
42
  import { acceptedColdStart } from './accepted-cold-start.ts';
@@ -924,8 +925,39 @@ export function createSyncRuntime(
924
925
  retryMs: opts.transactionRetryMs,
925
926
  onStats: (stats) => statusStore?.updateAccepted?.(stats),
926
927
  onStage: (summary) => statusStore?.updateAiAction?.(summary),
928
+ onBootstrap: (b) => noteProjectConfig(b.projectConfig),
927
929
  })
928
930
  : null;
931
+ /**
932
+ * The project's own group labels and design systems, kept for this copy's
933
+ * config to fill in what it lacks (context.ts `withProjectConfig`) — so a
934
+ * managed desktop copy shows the project's design system. Written only when
935
+ * it changed; the live config reloads and the shells refetch it.
936
+ */
937
+ function noteProjectConfig(raw: unknown): void {
938
+ const clean = sanitizeProjectConfig(raw);
939
+ if (!clean) return;
940
+ const file = path.join(ctx.paths.designRoot, PROJECT_CONFIG_CACHE_REL);
941
+ const text = `${JSON.stringify(clean, null, 2)}\n`;
942
+ try {
943
+ if (readFileSync(file, 'utf8') === text) return;
944
+ } catch {
945
+ /* first answer */
946
+ }
947
+ try {
948
+ mkdirSync(path.dirname(file), { recursive: true });
949
+ writeFileSync(file, text);
950
+ } catch {
951
+ return; // best-effort — the next bootstrap tries again
952
+ }
953
+ if (reloadConfig(ctx)) {
954
+ console.log(
955
+ `[sync] the project's design systems: ${clean.designSystems.map((d) => d.name).join(', ') || 'none'}`
956
+ );
957
+ ctx.bus.emit('config-updated');
958
+ ctx.bus.emit('canvas-list-update', { action: 'config' });
959
+ }
960
+ }
929
961
  const acceptedOn = (): boolean => acceptedLink?.on() === true;
930
962
  /**
931
963
  * T26 — which accepted action carried a given canvas content of ours, so the
@@ -4272,6 +4304,9 @@ export function createSyncRuntime(
4272
4304
  lastSeedProgress = progress;
4273
4305
  reportSeedProgress(progress, result);
4274
4306
  }
4307
+ // Read once: calling it inside the spread evaluated it twice and made
4308
+ // its `null` case the object's type.
4309
+ const blockedMedia = filePlane?.blocked() ?? null;
4275
4310
  statusStore?.updateFiles?.({
4276
4311
  ...fileTotals,
4277
4312
  pushed: filePushed,
@@ -4282,6 +4317,9 @@ export function createSyncRuntime(
4282
4317
  ...(filePlane.dorucekaTotal() > MAX_DORUCEKA_ROWS
4283
4318
  ? { deliveryTruncated: filePlane.dorucekaTotal() - MAX_DORUCEKA_ROWS }
4284
4319
  : {}),
4320
+ // T29 — the bytes, not just the count. Omitted entirely when
4321
+ // nothing is blocked, so a healthy project carries no field.
4322
+ ...(blockedMedia ? { blocked: blockedMedia } : {}),
4285
4323
  }
4286
4324
  : {}),
4287
4325
  ...(held.length > 0 ? { held } : {}),
@@ -159,6 +159,23 @@ export interface FilePlaneStatus {
159
159
  * added to cure, one lane over.
160
160
  */
161
161
  failed?: number;
162
+ /**
163
+ * HOW MUCH is not here — plan T29, the unit `failed` gets wrong.
164
+ *
165
+ * A count cannot answer the operator's question: nine blocked CSS sidecars
166
+ * is nothing and nine blocked videos is the project. `bytes` is what tells
167
+ * those apart. `byClass` is bounded by the ledger's fixed blocked-class set
168
+ * and never keyed by path; `unmeasured` says how many of the files have no
169
+ * size on record, so an under-count is visible rather than silent.
170
+ *
171
+ * Absent — not zero — when nothing is blocked.
172
+ */
173
+ blocked?: {
174
+ files: number;
175
+ bytes: number;
176
+ unmeasured: number;
177
+ byClass: Record<string, { files: number; bytes: number }>;
178
+ };
162
179
  /**
163
180
  * The hub asked us to slow down and the WHOLE LANE is paused until `until`.
164
181
  *
@@ -51,6 +51,9 @@ export interface Bootstrap {
51
51
  }[];
52
52
  dirs: string[];
53
53
  you?: { actor: string; readOnly: boolean };
54
+ /** What the project's own config says about itself (UNTRUSTED — a copy
55
+ * re-validates it; see context.ts `withProjectConfig`). */
56
+ projectConfig?: unknown;
54
57
  }
55
58
 
56
59
  interface OutboxAction {
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "$schema": "./whats-new.schema.json",
3
3
  "entries": [
4
+ {
5
+ "id": "history-on-a-team-project",
6
+ "version": "1.4.1",
7
+ "date": "2026-09-16",
8
+ "kind": "fix",
9
+ "title": "Your project history, from the status bar",
10
+ "summary": "On a project you were invited to, the status bar now opens the project history — every change with who made it, and Undo on the ones that are yours. It was only reachable from the View menu before.",
11
+ "surface": "design-ui"
12
+ },
13
+ {
14
+ "id": "design-system-on-every-desktop",
15
+ "version": "1.4.0",
16
+ "date": "2026-09-16",
17
+ "kind": "improvement",
18
+ "title": "Your team’s design system on your desktop too",
19
+ "summary": "When you open a team project on the desktop, its design system now appears in the Design System section — tokens, specimens and all — the same as on the machine that made it. Specimens someone adds show up for everyone.",
20
+ "surface": "design-ui"
21
+ },
22
+ {
23
+ "id": "sync-reliability-sept",
24
+ "version": "1.4.0",
25
+ "date": "2026-09-16",
26
+ "kind": "fix",
27
+ "title": "Steadier syncing in shared projects",
28
+ "summary": "Renaming a folder no longer makes you miss a teammate’s later edits to the canvases inside it; replacing an image keeps showing the new one on your screen; a file the workspace can’t store right now is named in the Sync panel and delivers by itself when it can; and a too-big file you remove stops being reported.",
29
+ "surface": "design-ui"
30
+ },
31
+ {
32
+ "id": "edits-follow-moves",
33
+ "version": "1.4.0",
34
+ "date": "2026-09-16",
35
+ "kind": "improvement",
36
+ "title": "Your edit follows a canvas a teammate moved",
37
+ "summary": "If a teammate moves a canvas — or renames its folder — while you are editing it offline, your change now lands at the canvas’s new place for everyone instead of waiting for review. Deleting a canvas you were editing still asks you what to keep.",
38
+ "surface": "design-ui"
39
+ },
40
+ {
41
+ "id": "edit-own-comments",
42
+ "version": "1.4.0",
43
+ "date": "2026-09-16",
44
+ "kind": "feature",
45
+ "title": "Fix a typo in your own comment",
46
+ "summary": "Open a comment you wrote and choose Edit — change the text and save; everyone sees the new wording and the replies stay. On a Maude Cloud project in the browser, your comments and replies now carry your name instead of the workspace’s.",
47
+ "surface": "design-ui"
48
+ },
4
49
  {
5
50
  "id": "live-canvases-long-sessions",
6
51
  "version": "1.3.1",