@1agh/maude 0.55.0 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/studio/bin/_smart-frames.mjs +187 -20
- package/apps/studio/bin/_smart-frames.test.mjs +59 -4
- package/apps/studio/bin/_transcribe.mjs +40 -3
- package/apps/studio/bin/smoke.sh +7 -1
- package/apps/studio/client/app.jsx +31 -3
- package/apps/studio/client/panels/CloudBar.jsx +44 -5
- package/apps/studio/client/panels/GitPanel.jsx +38 -25
- package/apps/studio/client/panels/SettingsPanel.jsx +239 -27
- package/apps/studio/client/styles/4-components.css +72 -0
- package/apps/studio/cloud/endpoints.ts +56 -3
- package/apps/studio/collab/persistence.ts +29 -2
- package/apps/studio/config.schema.json +3 -3
- package/apps/studio/context.ts +41 -0
- package/apps/studio/dist/client.bundle.js +1464 -1464
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/generation/gemma-models.ts +312 -14
- package/apps/studio/generation/prefs.ts +7 -2
- package/apps/studio/generation/runtime-probe.ts +50 -0
- package/apps/studio/generation/whisper-models.ts +124 -0
- package/apps/studio/hmr-broadcast.ts +67 -0
- package/apps/studio/http.ts +196 -109
- package/apps/studio/input-router.tsx +55 -2
- package/apps/studio/server.ts +11 -9
- package/apps/studio/sync/autocommit.ts +61 -2
- package/apps/studio/sync/cell-pairing.ts +174 -0
- package/apps/studio/sync/codec.ts +11 -5
- package/apps/studio/sync/index.ts +239 -26
- package/apps/studio/sync/limits.ts +49 -0
- package/apps/studio/sync/loopback.ts +21 -0
- package/apps/studio/sync/projection.ts +47 -12
- package/apps/studio/sync/supervisor.ts +178 -0
- package/apps/studio/test/cloud-endpoints.test.ts +95 -0
- package/apps/studio/test/csrf-write-guard.test.ts +19 -2
- package/apps/studio/test/gemma-models.test.ts +245 -0
- package/apps/studio/test/hmr-broadcast.test.ts +57 -1
- package/apps/studio/test/input-router.test.ts +95 -0
- package/apps/studio/test/shared-doc-cell-pairing.test.ts +639 -0
- package/apps/studio/test/sync-autocommit.test.ts +47 -0
- package/apps/studio/test/sync-supervisor.test.ts +212 -0
- package/apps/studio/test/trusted-request-host.test.ts +66 -0
- package/apps/studio/test/whisper-setup.test.ts +97 -0
- package/apps/studio/whats-new.json +27 -0
- package/apps/studio/ws.ts +9 -1
- package/cli/commands/kg.mjs +9 -2
- package/package.json +8 -8
- package/plugins/design/dependencies.json +21 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Component as bQ,createElement as g,Fragment as yQ,useCallback as y7,useEffect as f,useMemo as xQ,useRef as p,useState as $7}from"react";import{createRoot as vQ}from"react-dom/client";import{useCallback as k,useEffect as R,useMemo as s,useRef as S,useState as u}from"react";function H7(){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 Z7(J){if(!J)return"";return(J.getAttribute("class")??"").trim().split(/\s+/).filter((Q)=>Q&&!Q.startsWith("dgn-")&&!Q.startsWith("dc-cv-")).join(" ")}function jJ(J,Q){if(!J)return"";let $=(J.innerText||J.textContent||"").replace(/\s+/g," ").trim();return $.length>Q?`${$.slice(0,Q-1)}…`:$}function LJ(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 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 W=Z7($).split(/\s+/).filter(Boolean).slice(0,2);if(W.length)G+=`.${W.join(".")}`;let X=1,H=$.previousElementSibling;while(H)X++,H=H.previousElementSibling;G+=`:nth-child(${X})`,Q.unshift(G),$=$.parentElement}return Q.join(" > ")}function S7(J){let Q=[],$=J;while($&&$.nodeType===1&&Q.length<8){let V=$.nodeName.toLowerCase(),q=$.getAttribute?.("data-dc-element"),G=$.getAttribute?.("data-dc-screen");if(q)V+=`[data-dc-element="${q}"]`;else if(G)V+=`[data-dc-screen="${G}"]`;else if($.id)V+=`#${$.id}`;let W=Z7($).split(/\s+/).filter(Boolean).slice(0,2);if(W.length&&!q&&!G)V+=`.${W.join(".")}`;Q.unshift(V),$=$.parentElement}return Q}function NJ(J){return J.replace(/[^a-zA-Z0-9_-]/g,(Q)=>`\\${Q}`)}function g7(J,Q){return Q?`[data-dc-screen="${Q}"] [data-cd-id="${J}"]`:`[data-cd-id="${J}"]`}function h7(J,Q,$){if(!$)return 0;try{let V=J.querySelectorAll(Q);for(let q=0;q<V.length;q++)if(V[q]===$)return q}catch{}return 0}function f7(J,Q,$){if(!Q||!$)return 0;return h7(J,`[data-cd-id="${NJ(Q)}"]`,$)}function F7(J,Q){let $=(V)=>{try{let q=J.querySelectorAll(V);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 V=$(g7(Q.id,Q.artboardId));if(V)return V}if(Q.selector)return $(Q.selector);return null}function _J(J,Q){let $=0,V=Math.min(J.length,Q.length);for(let q=1;q<=V;q++){if(J[J.length-q]!==Q[Q.length-q])break;$++}return $}function p7(J,Q){let $=Q.dom_path,V=(Q.tag||"").toLowerCase();if(!$||$.length===0||!V)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),W=null,X=0;for(let H of Array.from(q.querySelectorAll("[data-cd-id]"))){if(H.tagName.toLowerCase()!==V)continue;let j=_J(S7(H),$);if(j===0)continue;let L=Z7(H).split(/\s+/).filter(Boolean),z=G.filter((F)=>L.includes(F)).length,B=j*10+z;if(B>X)X=B,W=H}return W}var R7=["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"],AJ=/^(style|class|data-cd-id|data-dc-|data-dcid$)/;function IJ(J){if(!J||typeof window>"u"||!window.getComputedStyle)return{authored:{},computed:{},customStyles:{},attrs:{}};try{let Q=J.style,$=window.getComputedStyle(J),V={},q={},G=new Set(R7);for(let B of R7){let F=Q.getPropertyValue(B);if(F)V[B]=F.trim();let Y=$.getPropertyValue(B);if(Y)q[B]=Y.trim()}let W=/^(margin|padding|border)(-|$)/,X={};for(let B=0;B<Q.length;B++){let F=Q.item(B);if(!F||G.has(F)||W.test(F))continue;let Y=Q.getPropertyValue(F);if(Y)X[F]=Y.trim()}let H={};for(let B of Array.from(J.attributes)){if(AJ.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,L=j?window.getComputedStyle(j).display:"",z=j&&(L==="flex"||L==="inline-flex")?window.getComputedStyle(j).flexDirection:"";return{authored:V,computed:q,customStyles:X,attrs:H,parentDisplay:L,parentFlexDirection:z}}catch{return{authored:{},computed:{},customStyles:{},attrs:{}}}}function D7(J,Q){let $=J.el,V=$&&$.getBoundingClientRect?$.getBoundingClientRect():null,q=J.cdId,G=q?g7(q,J.artboardId):J.artboardId?`[data-dc-screen="${J.artboardId}"]`:LJ($),W=q&&typeof document<"u"?h7(document,G,$):0;return{file:Q??H7(),id:q??void 0,selector:G,artboardId:J.artboardId,index:W,tag:$?.tagName.toLowerCase()??"",classes:Z7($),text:jJ($,240),dom_path:S7($),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 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 j=$.getAttribute?.("src")||"",L=X.exec(j);return L?{photoKind:"artboard-img",photoAsset:L[0]}:{}})(),...IJ($)}}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 P7 from"lib0/decoding";import*as a from"lib0/encoding";import{createContext as kJ,useCallback as tQ,useContext as EJ,useEffect as eQ,useMemo as J0,useReducer as Q0,useRef as $0,useState as V0}from"react";import{Awareness as q0,applyAwarenessUpdate as G0,encodeAwarenessUpdate as B0}from"y-protocols/awareness";import{readSyncMessage as W0,writeSyncStep1 as X0,writeUpdate as z0}from"y-protocols/sync";import*as wJ from"yjs";import*as OJ from"yjs";var TJ=new WeakSet;function u7(J){return TJ.add(J),J}var lQ=u7(Object.freeze({maudeOrigin:"shell-edit"})),rQ=u7(Object.freeze({maudeOrigin:"sync-agent"}));import{jsx as H0}from"react/jsx-runtime";var bJ=kJ(null);function m7(){return EJ(bJ)}import{createContext as yJ,useCallback as l,useContext as j7,useEffect as xJ,useMemo as vJ,useRef as CJ,useState as RJ}from"react";import{jsx as M7,Fragment as hJ}from"react/jsx-runtime";var B7=yJ(null);function r(J){return J.id?`id:${J.id}`:`sel:${J.selector}`}function d7(J){let Q=[],$=new Set;for(let V of J){let q=r(V);if($.has(q))continue;$.add(q),Q.push(V)}return Q}var SJ=50;function gJ({children:J,postTarget:Q}){let[$,V]=RJ([]),q=CJ(null),G=l((B)=>{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=B.length===0?null:B.length===1?B[0]??null:B;try{F.postMessage({dgn:"select-set",selection:Y},"*")}catch{}},SJ)},[Q]);xJ(()=>()=>{if(q.current)clearTimeout(q.current)},[]);let W=l((B)=>{let F=d7(Array.isArray(B)?B:[B]);V(F),G(F)},[G]),X=l((B)=>{let F=Array.isArray(B)?B:[B];V((Y)=>{let P=d7([...Y,...F]);return G(P),P})},[G]),H=l((B)=>{let F=r(B);V((Y)=>{let P=Y.filter((_)=>r(_)!==F);return G(P),P})},[G]),j=l((B)=>{let F=r(B);V((Y)=>{let P=Y.some((_)=>r(_)===F)?Y.filter((_)=>r(_)!==F):[...Y,B];return G(P),P})},[G]),L=l(()=>{V([]),G([])},[G]),z=vJ(()=>({selected:$,replace:W,add:X,remove:H,toggle:j,clear:L}),[$,W,X,H,j,L]);return M7(B7.Provider,{value:z,children:J})}function i7({children:J}){if(j7(B7))return M7(hJ,{children:J});return M7(gJ,{children:J})}function K7(){let J=j7(B7);if(!J)throw Error("useSelectionSet must be used inside <SelectionSetProvider>");return J}function c7(){return j7(B7)}import{jsx as O,jsxs as y,Fragment as tJ}from"react/jsx-runtime";var fJ="/_client/comments-overlay.css";function pJ(){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=fJ,document.head.appendChild(J)}function uJ(){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 mJ(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=p7(document,{artboardId:$,tag:J.tag,classes:J.classes,dom_path:J.dom_path})}return Q}function N7(J){let Q=mJ(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 o7(J,Q){let V=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>V){let X=J.x-Q.w;G=X>=8?X:Math.max(8,V-Q.w-8)}let W=J.y;if(W+Q.h+8>q){let X=J.y-Q.h;W=X>=8?X:Math.max(8,q-Q.h-8)}return{x:G,y:W}}function a7(){pJ();let J=c7(),[Q,$]=u([]),[V,q]=u(null),[G,W]=u(null),X=s(()=>uJ(),[]);R(()=>{if(typeof document>"u")return;let K=document.getElementById("dgn-pin-layer");if(!K)return;let D=K.style.display;return K.style.display="none",()=>{K.style.display=D}},[]);let H=k((K)=>{if(!J)return;if(!K?.selector){J.clear();return}let D=K.selector.match(/data-cd-id="([^"]+)"/),N=D?D[1]:void 0,A,I;try{let M=document.querySelector(K.selector);if(M)A=M.tagName.toLowerCase(),I=(M.getAttribute("class")??"").split(/\s+/).filter((T)=>T&&!T.startsWith("dgn-")&&!T.startsWith("dc-cv-")).join(" ")}catch{}J.replace({file:X??void 0,id:N,selector:K.selector,tag:A,classes:I,bounds:K.bounds??void 0})},[J,X]),j=S(Q);j.current=Q;let L=m7();R(()=>{if(!L)return;let K=L.doc.getArray("comments"),D=()=>{$(K.toArray())};if(K.length>0)D();return K.observe(D),()=>{try{K.unobserve(D)}catch{}}},[L]),R(()=>{if(typeof window>"u")return;let K=(D)=>{let N=D.data;if(!N||typeof N!=="object"||!N.dgn)return;if(N.dgn==="comments-set"&&Array.isArray(N.comments))$(N.comments);else if(N.dgn==="comment-focus"){let A=typeof N.id==="string"?N.id:null;q(A);let I=A?j.current.find((M)=>M.id===A):void 0;H(I)}};return window.addEventListener("message",K),()=>window.removeEventListener("message",K)},[H]),R(()=>{if(typeof document>"u")return;let K=(D)=>{let N=D.detail;if(!N?.selection)return;W({selection:N.selection,clientX:typeof N.clientX==="number"?N.clientX:0,clientY:typeof N.clientY==="number"?N.clientY:0})};return document.addEventListener("cm:open-composer",K),()=>document.removeEventListener("cm:open-composer",K)},[]);let z=k(()=>{if(W(null),typeof window>"u")return;try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},[]),B=k((K)=>{if(!G)return;let D=G.selection,N={file:D.file,selector:D.selector,index:D.index,dom_path:D.dom_path,tag:D.tag,classes:D.classes,bounds:D.bounds,html_excerpt:D.html,text:K};if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-submit",payload:N},"*")}catch{}z()},[G,z]);R(()=>{if(!X)return;let K=!1;return(async()=>{try{let D=await fetch(`/_comments?file=${encodeURIComponent(X)}`);if(!D.ok)return;let N=await D.json();if(K)return;if(Array.isArray(N.comments))$((A)=>A.length===0?N.comments??[]:A)}catch{}})(),()=>{K=!0}},[X]);let F=s(()=>{return Q.slice().sort((D,N)=>D.created.localeCompare(N.created)).filter((D)=>D.status!=="resolved")},[Q]),Y=s(()=>{let K=new Map;return Q.slice().sort((N,A)=>N.created.localeCompare(A.created)).forEach((N,A)=>{K.set(N.id,A+1)}),K},[Q]),P=k((K)=>{if(q(K),H(Q.find((D)=>D.id===K)),typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-click",id:K},"*")}catch{}},[Q,H]),_=k((K,D)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-patch",id:K,patch:D},"*")}catch{}},[]),Z=k((K)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-delete",id:K},"*")}catch{}q((D)=>D===K?null:D)},[]),U=k(async(K,D)=>{if(typeof fetch>"u")return!1;try{let N=await fetch(`/_api/comments/${encodeURIComponent(K)}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:D})});if(!N.ok)return!1;let A=await N.json();return $((I)=>I.map((M)=>M.id===A.id?A:M)),!0}catch{return!1}},[]);return y("div",{className:"cm-layer","aria-hidden":!1,children:[F.map((K)=>{let D=Y.get(K.id)??0;return O(lJ,{comment:K,sequence:D,focused:V===K.id,onClick:P,onOrphaned:Z},K.id)}),G?O(rJ,{state:G,onSubmit:B,onCancel:z}):null,(()=>{if(!V)return null;let K=F.find((D)=>D.id===V);if(!K)return null;return O(nJ,{comment:K,sequence:Y.get(K.id)??0,onClose:()=>{q(null),J?.clear()},onPatch:(D)=>_(K.id,D),onDelete:()=>Z(K.id),onReply:(D)=>U(K.id,D)})})()]})}var L7=null;async function dJ(){if(!L7)L7=(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 L7}function l7(J){return(J.trim().split(/\s+/)[0]??"").replace(/[^\w.-]/g,"").toLowerCase()}function iJ(J,Q){if(Q<=0||Q>J.length)return null;let $=Q-1;while($>=0){let V=J[$]??"";if(V==="@"){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(V))return null;$-=1}return null}function s7({className:J,value:Q,onChange:$,onKeyDown:V,placeholder:q,rows:G,disabled:W,textareaRef:X,ariaLabel:H}){let j=S(null),L=k((M)=>{if(j.current=M,X)X.current=M},[X]),[z,B]=u([]),[F,Y]=u(null),[P,_]=u(0),Z=k(()=>{if(z.length>0)return;dJ().then((M)=>B(M))},[z.length]),U=s(()=>{if(!F)return[];let M=F.query.toLowerCase();return(!M?z:z.filter((E)=>E.name.toLowerCase().includes(M)||E.email.toLowerCase().includes(M))).slice(0,8)},[F,z]),K=k((M)=>{let T=M.selectionStart??M.value.length,E=iJ(M.value,T);Y(E),_(0)},[]),D=k((M)=>{$(M.target.value),K(M.target)},[$,K]),N=k((M)=>{if(!F)return;let T=j.current;if(!T)return;let E=`@${l7(M.name)}`,x=`${Q.slice(0,F.start)}${E} ${Q.slice(F.end)}`;$(x),Y(null);let w=F.start+E.length+1;requestAnimationFrame(()=>{T.focus(),T.setSelectionRange(w,w)})},[F,Q,$]),A=k((M)=>{if(F&&U.length>0){if(M.key==="ArrowDown"){M.preventDefault(),_((T)=>(T+1)%U.length);return}if(M.key==="ArrowUp"){M.preventDefault(),_((T)=>(T-1+U.length)%U.length);return}if(M.key==="Enter"||M.key==="Tab"){M.preventDefault();let T=U[P]??U[0];if(T)N(T);return}if(M.key==="Escape"){M.preventDefault(),Y(null);return}}V?.(M)},[F,U,P,N,V]),I=k((M)=>{K(M.currentTarget)},[K]);return y("div",{style:{position:"relative"},children:[O("textarea",{ref:L,className:J,value:Q,placeholder:q,rows:G,disabled:W,"aria-label":H,onChange:D,onKeyDown:A,onFocus:Z,onSelect:I,onClick:I}),F&&U.length>0?O("ul",{className:"cm-mention-popup",role:"listbox","aria-label":"Mention suggestions",style:{left:0,top:"100%"},children:U.map((M,T)=>{return y("li",{role:"option","aria-selected":T===P,className:"cm-mention-popup__item",onMouseEnter:()=>_(T),onMouseDown:(x)=>{x.preventDefault(),N(M)},children:[y("span",{className:"cm-mention-popup__name",children:["@",l7(M.name)]}),O("span",{className:"cm-mention-popup__email",children:M.email})]},`${M.name}-${M.email}`)})}):null]})}var cJ=3000;function lJ({comment:J,sequence:Q,focused:$,onClick:V,onOrphaned:q}){let G=S(null),W=S(null),X=S(null);R(()=>{let L=()=>{W.current=null;let z=G.current;if(!z)return;let B=N7(J);if(B)X.current=null;else{if(X.current==null)X.current=Date.now();else if(Date.now()-X.current>cJ)q(J.id);if(J.bounds)B={x:J.bounds.x,y:J.bounds.y,w:J.bounds.w,h:J.bounds.h}}if(!B){z.style.display="none",W.current=requestAnimationFrame(L);return}z.style.display="grid";let F=Math.round(B.x+B.w-12),Y=Math.round(B.y-12);z.style.left=`${F}px`,z.style.top=`${Y}px`,W.current=requestAnimationFrame(L)};return W.current=requestAnimationFrame(L),()=>{if(W.current!=null)cancelAnimationFrame(W.current)}},[J,q]);let H=J.author?.trim()||"unknown",j=`Comment ${Q} by ${H}`;return O("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:(L)=>{L.preventDefault(),L.stopPropagation(),V(J.id)},children:Q})}function rJ({state:J,onSubmit:Q,onCancel:$}){let[V,q]=u(""),G=S(null),W=S(null),X=S(null);R(()=>{let z=()=>{X.current=null;let B=W.current;if(!B)return;let F=sJ(J),Y=o7(F,{w:B.offsetWidth,h:B.offsetHeight});B.style.left=`${Math.round(Y.x)}px`,B.style.top=`${Math.round(Y.y)}px`,X.current=requestAnimationFrame(z)};return X.current=requestAnimationFrame(z),()=>{if(X.current!=null)cancelAnimationFrame(X.current)}},[J]),R(()=>{G.current?.focus()},[]);let H=k(()=>{let z=V.trim();if(!z)return;Q(z)},[V,Q]),j=k((z)=>{if(z.key==="Escape"){z.preventDefault(),$();return}if((z.metaKey||z.ctrlKey)&&z.key==="Enter")z.preventDefault(),H()},[$,H]),L=s(()=>{let z=J.selection.selector||"";if(!z)return J.selection.tag||"canvas";let B=z.match(/data-cd-id="([^"]+)"/);if(B)return`cd:${B[1]}`;return z.length>36?`${z.slice(0,33)}…`:z},[J.selection]);return y("div",{ref:W,className:"cm-composer",role:"dialog","aria-label":"New comment",onClick:(z)=>z.stopPropagation(),onPointerDown:(z)=>z.stopPropagation(),children:[y("div",{className:"cm-composer__head",children:[O("span",{children:"New comment"}),O("span",{className:"cm-composer__selector",children:L})]}),O(s7,{textareaRef:G,className:"cm-composer__textarea",value:V,placeholder:"Type a comment. ⌘↵ to save · Esc to cancel · @name to tag",onChange:q,onKeyDown:j,rows:3,ariaLabel:"Comment body"}),y("div",{className:"cm-composer__actions",children:[O("button",{type:"button",className:"cm-btn",onClick:$,children:"Cancel"}),O("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!V.trim(),onClick:H,children:"Save"})]})]})}function nJ({comment:J,sequence:Q,onClose:$,onPatch:V,onDelete:q,onReply:G}){let W=S(null),X=S(null),H=S(null),[j,L]=u(""),[z,B]=u(!1);R(()=>{let Z=()=>{H.current=null;let U=W.current;if(!U)return;let K=aJ(J),D=o7(K,{w:U.offsetWidth,h:U.offsetHeight});U.style.left=`${Math.round(D.x)}px`,U.style.top=`${Math.round(D.y)}px`,H.current=requestAnimationFrame(Z)};return H.current=requestAnimationFrame(Z),()=>{if(H.current!=null)cancelAnimationFrame(H.current)}},[J]),R(()=>{W.current?.focus();let Z=J.id;return()=>{document.querySelector(`[data-comment-pin="${Z}"]`)?.focus()}},[J.id]),R(()=>{if(typeof document>"u")return;let Z=(U)=>{if(U.key!=="Escape")return;let K=W.current;if(!K)return;if(K.contains(U.target)||document.activeElement===K)U.preventDefault(),$()};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[$]);let F=k(async()=>{let Z=j.trim();if(!Z||z)return;B(!0);let U=await G(Z);if(B(!1),U)L(""),X.current?.focus()},[j,z,G]),Y=k((Z)=>{if((Z.metaKey||Z.ctrlKey)&&Z.key==="Enter")Z.preventDefault(),F()},[F]),P=`cm-thread-head-${J.id}`,_=oJ(J.selector,"");return y("div",{ref:W,className:"cm-thread",role:"dialog","aria-labelledby":P,tabIndex:-1,onClick:(Z)=>Z.stopPropagation(),onPointerDown:(Z)=>Z.stopPropagation(),children:[y("div",{className:"cm-thread__head",id:P,children:[y("div",{className:"cm-thread__head-row",children:[O("span",{className:"cm-thread__seq","aria-hidden":"true",children:Q}),O("span",{className:"cm-thread__author",children:J.author?.trim()||"unknown"}),O("span",{className:"cm-thread__time",children:n7(J.created)}),O("button",{type:"button",className:"cm-thread__close","aria-label":"Close thread",title:"Close · Esc",onClick:$,children:"×"})]}),_?O("code",{className:"cm-thread__selector",children:_}):null]}),O("div",{className:"cm-thread__body",children:r7(J.text)}),(J.thread??[]).map((Z)=>y("div",{className:"cm-thread__reply",children:[y("div",{className:"cm-thread__reply-head",children:[O("span",{className:"cm-thread__reply-author",children:Z.author?.trim()||"unknown"}),O("span",{className:"cm-thread__reply-time",children:n7(Z.created)})]}),O("div",{className:"cm-thread__reply-body",children:r7(Z.body)})]},Z.id)),!G7()&&y(tJ,{children:[y("div",{className:"cm-thread__reply-form",children:[O(s7,{textareaRef:X,className:"cm-thread__reply-textarea",value:j,placeholder:"Reply… ⌘↵ to send · @name to tag",onChange:L,onKeyDown:Y,rows:2,ariaLabel:"Reply",disabled:z}),O("div",{className:"cm-thread__reply-actions",children:O("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!j.trim()||z,onClick:()=>void F(),children:"Send"})})]}),y("div",{className:"cm-thread__actions",children:[J.status==="resolved"?O("button",{type:"button",className:"cm-btn",onClick:()=>V({status:"open"}),children:"↺ Reopen"}):O("button",{type:"button",className:"cm-btn cm-btn--primary",onClick:()=>{V({status:"resolved"}),$()},children:"✓ Resolve"}),O("button",{type:"button",className:"cm-btn cm-btn--danger",onClick:()=>{q(),$()},children:"Delete"})]})]})]})}function r7(J){if(!J)return null;let Q=/(@[\w][\w.-]*)/g;return J.split(Q).map((V,q)=>{let G=`${q}:${V}`;if(q%2===1)return O("strong",{"data-mention":"true",children:V},G);return O("span",{children:V},G)})}function n7(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 oJ(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 aJ(J){let Q=J.selector?N7(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 sJ(J){if(J.clientX||J.clientY)return{x:J.clientX,y:J.clientY+8};if(J.selection.selector){let Q=N7(J.selection);if(Q)return{x:Q.x,y:Q.y+Q.h+8}}return{x:16,y:16}}import{useEffect as eJ}from"react";var JQ=new Set(["pen","highlighter","shape","rect","ellipse","arrow","sticky","text","section","eraser"]);function _7(J){return JQ.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(_7(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(_7(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 W7(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;return!!J.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mediaref-player]")}function t7(J){let{hostRef:Q,getActiveTool:$,isSpaceHeld:V,callbacks:q,enabled:G=!0,claimableActions:W}=J;eJ(()=>{if(!G)return;let X=Q.current;if(!X)return;let H=(Z)=>W&&Z.kind!=="no-op"&&!W.has(Z.kind)?{kind:"no-op"}:Z,j=(Z)=>{switch(Z.kind){case"hover":q.onHover?.(Z);break;case"select":q.onSelect?.(Z);break;case"drop-comment":q.onDropComment?.(Z);break;case"context-menu":q.onContextMenu?.(Z);break;case"tool":q.onTool?.(Z);break;case"escape":q.onEscape?.();break;case"undo":q.onUndo?.();break;case"redo":q.onRedo?.();break;case"no-op":break}},L=(Z)=>{let U=H(e({type:"pointermove",button:Z.button,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,clientX:Z.clientX,clientY:Z.clientY,spaceHeld:V?.()??!1,activeTool:$()}));j(U)},z=(Z)=>{if(J7(Z.target))return;if(W7(Z.target))return;let U=H(e({type:"pointerdown",button:Z.button,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,clientX:Z.clientX,clientY:Z.clientY,spaceHeld:V?.()??!1,activeTool:$()}));if(U.kind!=="no-op")Z.preventDefault(),Z.stopImmediatePropagation();j(U)},B=(Z)=>{if(J7(Z.target))return;if(W7(Z.target))return;let U=H(e({type:"pointerdown",button:Z.button,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,clientX:Z.clientX,clientY:Z.clientY,spaceHeld:V?.()??!1,activeTool:$()}));if(U.kind!=="no-op"){if(Z.preventDefault(),Z.stopImmediatePropagation(),U.kind==="select")try{window.focus()}catch{}}},F=(Z)=>{if(J7(Z.target))return;if(W7(Z.target))return;let U=$(),K=Z.metaKey||Z.ctrlKey,D=U==="comment"?"drop-comment":U==="move"&&Z.button===0?"select":(_7(U)||U==="browse")&&K&&Z.button===0?"select":Z.button===2?"context-menu":null;if(D&&(!W||W.has(D)))Z.preventDefault(),Z.stopImmediatePropagation()},Y=(Z)=>{let U=H(e({type:"contextmenu",clientX:Z.clientX,clientY:Z.clientY,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,activeTool:$()}));if(U.kind==="no-op")return;Z.preventDefault(),Z.stopImmediatePropagation(),j(U)},P=(Z)=>{let U=H(e({type:"keydown",key:Z.key,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,isEditable:W7(Z.target),activeTool:$()}));if(U.kind==="tool"||U.kind==="escape"||U.kind==="undo"||U.kind==="redo")Z.preventDefault();j(U)};X.addEventListener("pointermove",L,{passive:!0}),X.addEventListener("pointerdown",z,{capture:!0}),X.addEventListener("mousedown",B,{capture:!0}),X.addEventListener("click",F,{capture:!0}),X.addEventListener("contextmenu",Y,{capture:!0});let _=X.ownerDocument??document;return _.addEventListener("keydown",P,!0),()=>{X.removeEventListener("pointermove",L),X.removeEventListener("pointerdown",z,{capture:!0}),X.removeEventListener("mousedown",B,{capture:!0}),X.removeEventListener("click",F,{capture:!0}),X.removeEventListener("contextmenu",Y,{capture:!0}),_.removeEventListener("keydown",P,!0)}},[G,Q,$,V,q,W])}function A7(J,Q,$,V){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,W=G?.getAttribute("data-dc-screen")??null,X=q.closest?.(".dc-artboard-body")??null;if(!X){if(G&&W)return{el:G,cdId:null,artboardId:W};return null}if(q===X){if(G&&W)return{el:G,cdId:null,artboardId:W};return null}if(V.deep){let B=q.getAttribute?.("data-cd-id")??null;return{el:q,cdId:B,artboardId:W}}let H=q,j=null;while(H&&H!==X){if(H.hasAttribute?.("data-cd-id"))j=H;H=H.parentElement}let L=j??q,z=L.getAttribute?.("data-cd-id")??null;return{el:L,cdId:z,artboardId:W}}import{useCallback as PQ,useEffect as ZJ,useRef as z7}from"react";var QQ=!1;function e7(){return QQ}import{createContext as XQ,useCallback as k7,useContext as $J,useEffect as zQ,useMemo as QJ,useState as E7}from"react";function m(J,Q,$,V){return`url("data:image/svg+xml,${encodeURIComponent(J.trim())}") ${Q} ${$}, ${V}`}var O7="width='24' height='24' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'",T7="#1f1f1f",I7="stroke='#ffffff' stroke-linejoin='round' stroke-linecap='round'";function i(J,Q,$){let V=$?`<g transform='${$}'>`:"";return`<svg ${O7}>${V}<path fill='#ffffff' d='${J}'/><path fill='${T7}' d='${Q}'/>${$?"</g>":""}</svg>`}var JJ="translate(0,32) scale(1,-1)",$Q=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"),VQ=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"),ZQ=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"),qQ=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",JJ),6,18,"crosshair"),GQ=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",JJ),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"),BQ=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"),KQ=m(`<svg ${O7}><path d='M16 4V28M11 4H21M11 28H21' fill='none' ${I7} stroke-width='5'/><path d='M16 4V28M11 4H21M11 28H21' fill='none' stroke='${T7}' stroke-width='2.25' stroke-linecap='round'/></svg>`,12,12,"text"),WQ=m(`<svg ${O7}><path d='M6 5H21L26 10V27H6Z' fill='${T7}' ${I7} stroke-width='2.5'/><path d='M21 5V11H26' fill='none' ${I7} stroke-width='2.25'/></svg>`,5,5,"crosshair"),C=Object.freeze({browse:"default",move:$Q,hand:VQ,comment:ZQ,pen:qQ,section:Q7,highlighter:GQ,shape:Q7,rect:Q7,ellipse:Q7,sticky:WQ,arrow:Q7,text:KQ,eraser:BQ});import{jsx as w7,Fragment as DQ}from"react/jsx-runtime";var UQ=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}]),YQ=new Set(["browse","move","hand"]);function HQ(J,Q){return Q?J.filter(($)=>YQ.has($.id)):J}var b7=XQ(null);function FQ({children:J,tools:Q=UQ,initial:$="browse"}){let V=QJ(()=>HQ(Q,G7()),[Q]),[q,G]=E7($),[W,X]=E7(()=>({tool:null,locked:!1})),H=k7((Y)=>{if(!V.some((P)=>P.id===Y))return;G(Y),X((P)=>P.locked&&P.tool===Y?P:{tool:null,locked:!1})},[V]),j=k7((Y)=>{X((P)=>{if(P.locked&&P.tool===Y)return{tool:null,locked:!1};return{tool:Y,locked:!0}}),G(Y)},[]),L=k7(()=>{X({tool:null,locked:!1})},[]),[z,B]=E7("rounded");zQ(()=>{if(typeof document>"u")return;let Y=V.find((Z)=>Z.id===q);if(!Y)return;let P=document.body.style.cursor,_=document.getElementById("dc-tool-cursor");if(!_)_=document.createElement("style"),_.id="dc-tool-cursor",document.head.appendChild(_);if(q==="browse"){if(document.body.style.cursor="",_.textContent="",typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:q},"*")}catch{}return()=>{document.body.style.cursor=P}}if(document.body.style.cursor=Y.cursor,_.textContent=`* { cursor: ${Y.cursor} !important; }`,typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:q},"*")}catch{}return()=>{document.body.style.cursor=P;let Z=document.getElementById("dc-tool-cursor");if(Z)Z.textContent=""}},[q,V]);let F=QJ(()=>({tool:q,setTool:H,tools:V,sticky:W,toggleSticky:j,clearSticky:L,shapeKind:z,setShapeKind:B}),[q,H,V,W,j,L,z]);return w7(b7.Provider,{value:F,children:J})}function VJ({children:J}){if($J(b7))return w7(DQ,{children:J});return w7(FQ,{children:J})}function X7(){let J=$J(b7);if(!J)throw Error("useToolMode must be used inside <ToolProvider>");return J}import{jsx as wQ}from"react/jsx-runtime";var MQ=`
|
|
1
|
+
import{Component as yQ,createElement as g,Fragment as vQ,useCallback as x7,useEffect as f,useMemo as CQ,useRef as p,useState as $7}from"react";import{createRoot as RQ}from"react-dom/client";import{useCallback as k,useEffect as R,useMemo as s,useRef as S,useState as u}from"react";function H7(){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 LJ(J,Q){if(!J)return"";let $=(J.innerText||J.textContent||"").replace(/\s+/g," ").trim();return $.length>Q?`${$.slice(0,Q-1)}…`:$}function NJ(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 W=Z7($).split(/\s+/).filter(Boolean).slice(0,2);if(W.length)G+=`.${W.join(".")}`;let z=1,H=$.previousElementSibling;while(H)z++,H=H.previousElementSibling;G+=`:nth-child(${z})`,Q.unshift(G),$=$.parentElement}return Q.join(" > ")}function S7(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 W=Z7($).split(/\s+/).filter(Boolean).slice(0,2);if(W.length&&!q&&!G)Z+=`.${W.join(".")}`;Q.unshift(Z),$=$.parentElement}return Q}function _J(J){return J.replace(/[^a-zA-Z0-9_-]/g,(Q)=>`\\${Q}`)}function g7(J,Q){return Q?`[data-dc-screen="${Q}"] [data-cd-id="${J}"]`:`[data-cd-id="${J}"]`}function h7(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 f7(J,Q,$){if(!Q||!$)return 0;return h7(J,`[data-cd-id="${_J(Q)}"]`,$)}function F7(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=$(g7(Q.id,Q.artboardId));if(Z)return Z}if(Q.selector)return $(Q.selector);return null}function AJ(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 p7(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),W=null,z=0;for(let H of Array.from(q.querySelectorAll("[data-cd-id]"))){if(H.tagName.toLowerCase()!==Z)continue;let j=AJ(S7(H),$);if(j===0)continue;let L=Z7(H).split(/\s+/).filter(Boolean),U=G.filter((F)=>L.includes(F)).length,B=j*10+U;if(B>z)z=B,W=H}return W}var R7=["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"],IJ=/^(style|class|data-cd-id|data-dc-|data-dcid$)/;function OJ(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(R7);for(let B of R7){let F=Q.getPropertyValue(B);if(F)Z[B]=F.trim();let Y=$.getPropertyValue(B);if(Y)q[B]=Y.trim()}let W=/^(margin|padding|border)(-|$)/,z={};for(let B=0;B<Q.length;B++){let F=Q.item(B);if(!F||G.has(F)||W.test(F))continue;let Y=Q.getPropertyValue(F);if(Y)z[F]=Y.trim()}let H={};for(let B of Array.from(J.attributes)){if(IJ.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,L=j?window.getComputedStyle(j).display:"",U=j&&(L==="flex"||L==="inline-flex")?window.getComputedStyle(j).flexDirection:"";return{authored:Z,computed:q,customStyles:z,attrs:H,parentDisplay:L,parentFlexDirection:U}}catch{return{authored:{},computed:{},customStyles:{},attrs:{}}}}function D7(J,Q){let $=J.el,Z=$&&$.getBoundingClientRect?$.getBoundingClientRect():null,q=J.cdId,G=q?g7(q,J.artboardId):J.artboardId?`[data-dc-screen="${J.artboardId}"]`:NJ($),W=q&&typeof document<"u"?h7(document,G,$):0;return{file:Q??H7(),id:q??void 0,selector:G,artboardId:J.artboardId,index:W,tag:$?.tagName.toLowerCase()??"",classes:Z7($),text:LJ($,240),dom_path:S7($),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 z=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,H=$.getAttribute?.("data-photo-asset");if(H&&z.test(H))return{photoKind:"artboard-img",photoAsset:H};let j=$.getAttribute?.("src")||"",L=z.exec(j);return L?{photoKind:"artboard-img",photoAsset:L[0]}:{}})(),...OJ($)}}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 P7 from"lib0/decoding";import*as a from"lib0/encoding";import{createContext as EJ,useCallback as J0,useContext as wJ,useEffect as Q0,useMemo as $0,useReducer as V0,useRef as Z0,useState as q0}from"react";import{Awareness as B0,applyAwarenessUpdate as K0,encodeAwarenessUpdate as W0}from"y-protocols/awareness";import{readSyncMessage as z0,writeSyncStep1 as U0,writeUpdate as Y0}from"y-protocols/sync";import*as bJ from"yjs";import*as TJ from"yjs";var kJ=new WeakSet;function u7(J){return kJ.add(J),J}var nQ=u7(Object.freeze({maudeOrigin:"shell-edit"})),oQ=u7(Object.freeze({maudeOrigin:"sync-agent"}));import{jsx as D0}from"react/jsx-runtime";var xJ=EJ(null);function m7(){return wJ(xJ)}import{createContext as yJ,useCallback as l,useContext as j7,useEffect as vJ,useMemo as CJ,useRef as RJ,useState as SJ}from"react";import{jsx as M7,Fragment as fJ}from"react/jsx-runtime";var B7=yJ(null);function r(J){return J.id?`id:${J.id}`:`sel:${J.selector}`}function d7(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 gJ=50;function hJ({children:J,postTarget:Q}){let[$,Z]=SJ([]),q=RJ(null),G=l((B)=>{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=B.length===0?null:B.length===1?B[0]??null:B;try{F.postMessage({dgn:"select-set",selection:Y},"*")}catch{}},gJ)},[Q]);vJ(()=>()=>{if(q.current)clearTimeout(q.current)},[]);let W=l((B)=>{let F=d7(Array.isArray(B)?B:[B]);Z(F),G(F)},[G]),z=l((B)=>{let F=Array.isArray(B)?B:[B];Z((Y)=>{let P=d7([...Y,...F]);return G(P),P})},[G]),H=l((B)=>{let F=r(B);Z((Y)=>{let P=Y.filter((_)=>r(_)!==F);return G(P),P})},[G]),j=l((B)=>{let F=r(B);Z((Y)=>{let P=Y.some((_)=>r(_)===F)?Y.filter((_)=>r(_)!==F):[...Y,B];return G(P),P})},[G]),L=l(()=>{Z([]),G([])},[G]),U=CJ(()=>({selected:$,replace:W,add:z,remove:H,toggle:j,clear:L}),[$,W,z,H,j,L]);return M7(B7.Provider,{value:U,children:J})}function i7({children:J}){if(j7(B7))return M7(fJ,{children:J});return M7(hJ,{children:J})}function K7(){let J=j7(B7);if(!J)throw Error("useSelectionSet must be used inside <SelectionSetProvider>");return J}function c7(){return j7(B7)}import{jsx as O,jsxs as x,Fragment as eJ}from"react/jsx-runtime";var pJ="/_client/comments-overlay.css";function uJ(){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=pJ,document.head.appendChild(J)}function mJ(){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 dJ(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=p7(document,{artboardId:$,tag:J.tag,classes:J.classes,dom_path:J.dom_path})}return Q}function N7(J){let Q=dJ(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 o7(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 z=J.x-Q.w;G=z>=8?z:Math.max(8,Z-Q.w-8)}let W=J.y;if(W+Q.h+8>q){let z=J.y-Q.h;W=z>=8?z:Math.max(8,q-Q.h-8)}return{x:G,y:W}}function a7(){uJ();let J=c7(),[Q,$]=u([]),[Z,q]=u(null),[G,W]=u(null),z=s(()=>mJ(),[]);R(()=>{if(typeof document>"u")return;let K=document.getElementById("dgn-pin-layer");if(!K)return;let D=K.style.display;return K.style.display="none",()=>{K.style.display=D}},[]);let H=k((K)=>{if(!J)return;if(!K?.selector){J.clear();return}let D=K.selector.match(/data-cd-id="([^"]+)"/),N=D?D[1]:void 0,A,I;try{let M=document.querySelector(K.selector);if(M)A=M.tagName.toLowerCase(),I=(M.getAttribute("class")??"").split(/\s+/).filter((T)=>T&&!T.startsWith("dgn-")&&!T.startsWith("dc-cv-")).join(" ")}catch{}J.replace({file:z??void 0,id:N,selector:K.selector,tag:A,classes:I,bounds:K.bounds??void 0})},[J,z]),j=S(Q);j.current=Q;let L=m7();R(()=>{if(!L)return;let K=L.doc.getArray("comments"),D=()=>{$(K.toArray())};if(K.length>0)D();return K.observe(D),()=>{try{K.unobserve(D)}catch{}}},[L]),R(()=>{if(typeof window>"u")return;let K=(D)=>{let N=D.data;if(!N||typeof N!=="object"||!N.dgn)return;if(N.dgn==="comments-set"&&Array.isArray(N.comments))$(N.comments);else if(N.dgn==="comment-focus"){let A=typeof N.id==="string"?N.id:null;q(A);let I=A?j.current.find((M)=>M.id===A):void 0;H(I)}};return window.addEventListener("message",K),()=>window.removeEventListener("message",K)},[H]),R(()=>{if(typeof document>"u")return;let K=(D)=>{let N=D.detail;if(!N?.selection)return;W({selection:N.selection,clientX:typeof N.clientX==="number"?N.clientX:0,clientY:typeof N.clientY==="number"?N.clientY:0})};return document.addEventListener("cm:open-composer",K),()=>document.removeEventListener("cm:open-composer",K)},[]);let U=k(()=>{if(W(null),typeof window>"u")return;try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},[]),B=k((K)=>{if(!G)return;let D=G.selection,N={file:D.file,selector:D.selector,index:D.index,dom_path:D.dom_path,tag:D.tag,classes:D.classes,bounds:D.bounds,html_excerpt:D.html,text:K};if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-submit",payload:N},"*")}catch{}U()},[G,U]);R(()=>{if(!z)return;let K=!1;return(async()=>{try{let D=await fetch(`/_comments?file=${encodeURIComponent(z)}`);if(!D.ok)return;let N=await D.json();if(K)return;if(Array.isArray(N.comments))$((A)=>A.length===0?N.comments??[]:A)}catch{}})(),()=>{K=!0}},[z]);let F=s(()=>{return Q.slice().sort((D,N)=>D.created.localeCompare(N.created)).filter((D)=>D.status!=="resolved")},[Q]),Y=s(()=>{let K=new Map;return Q.slice().sort((N,A)=>N.created.localeCompare(A.created)).forEach((N,A)=>{K.set(N.id,A+1)}),K},[Q]),P=k((K)=>{if(q(K),H(Q.find((D)=>D.id===K)),typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-click",id:K},"*")}catch{}},[Q,H]),_=k((K,D)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-patch",id:K,patch:D},"*")}catch{}},[]),V=k((K)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-delete",id:K},"*")}catch{}q((D)=>D===K?null:D)},[]),X=k(async(K,D)=>{if(typeof fetch>"u")return!1;try{let N=await fetch(`/_api/comments/${encodeURIComponent(K)}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:D})});if(!N.ok)return!1;let A=await N.json();return $((I)=>I.map((M)=>M.id===A.id?A:M)),!0}catch{return!1}},[]);return x("div",{className:"cm-layer","aria-hidden":!1,children:[F.map((K)=>{let D=Y.get(K.id)??0;return O(rJ,{comment:K,sequence:D,focused:Z===K.id,onClick:P,onOrphaned:V},K.id)}),G?O(nJ,{state:G,onSubmit:B,onCancel:U}):null,(()=>{if(!Z)return null;let K=F.find((D)=>D.id===Z);if(!K)return null;return O(oJ,{comment:K,sequence:Y.get(K.id)??0,onClose:()=>{q(null),J?.clear()},onPatch:(D)=>_(K.id,D),onDelete:()=>V(K.id),onReply:(D)=>X(K.id,D)})})()]})}var L7=null;async function iJ(){if(!L7)L7=(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 L7}function l7(J){return(J.trim().split(/\s+/)[0]??"").replace(/[^\w.-]/g,"").toLowerCase()}function cJ(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 s7({className:J,value:Q,onChange:$,onKeyDown:Z,placeholder:q,rows:G,disabled:W,textareaRef:z,ariaLabel:H}){let j=S(null),L=k((M)=>{if(j.current=M,z)z.current=M},[z]),[U,B]=u([]),[F,Y]=u(null),[P,_]=u(0),V=k(()=>{if(U.length>0)return;iJ().then((M)=>B(M))},[U.length]),X=s(()=>{if(!F)return[];let M=F.query.toLowerCase();return(!M?U:U.filter((E)=>E.name.toLowerCase().includes(M)||E.email.toLowerCase().includes(M))).slice(0,8)},[F,U]),K=k((M)=>{let T=M.selectionStart??M.value.length,E=cJ(M.value,T);Y(E),_(0)},[]),D=k((M)=>{$(M.target.value),K(M.target)},[$,K]),N=k((M)=>{if(!F)return;let T=j.current;if(!T)return;let E=`@${l7(M.name)}`,y=`${Q.slice(0,F.start)}${E} ${Q.slice(F.end)}`;$(y),Y(null);let w=F.start+E.length+1;requestAnimationFrame(()=>{T.focus(),T.setSelectionRange(w,w)})},[F,Q,$]),A=k((M)=>{if(F&&X.length>0){if(M.key==="ArrowDown"){M.preventDefault(),_((T)=>(T+1)%X.length);return}if(M.key==="ArrowUp"){M.preventDefault(),_((T)=>(T-1+X.length)%X.length);return}if(M.key==="Enter"||M.key==="Tab"){M.preventDefault();let T=X[P]??X[0];if(T)N(T);return}if(M.key==="Escape"){M.preventDefault(),Y(null);return}}Z?.(M)},[F,X,P,N,Z]),I=k((M)=>{K(M.currentTarget)},[K]);return x("div",{style:{position:"relative"},children:[O("textarea",{ref:L,className:J,value:Q,placeholder:q,rows:G,disabled:W,"aria-label":H,onChange:D,onKeyDown:A,onFocus:V,onSelect:I,onClick:I}),F&&X.length>0?O("ul",{className:"cm-mention-popup",role:"listbox","aria-label":"Mention suggestions",style:{left:0,top:"100%"},children:X.map((M,T)=>{return x("li",{role:"option","aria-selected":T===P,className:"cm-mention-popup__item",onMouseEnter:()=>_(T),onMouseDown:(y)=>{y.preventDefault(),N(M)},children:[x("span",{className:"cm-mention-popup__name",children:["@",l7(M.name)]}),O("span",{className:"cm-mention-popup__email",children:M.email})]},`${M.name}-${M.email}`)})}):null]})}var lJ=3000;function rJ({comment:J,sequence:Q,focused:$,onClick:Z,onOrphaned:q}){let G=S(null),W=S(null),z=S(null);R(()=>{let L=()=>{W.current=null;let U=G.current;if(!U)return;let B=N7(J);if(B)z.current=null;else{if(z.current==null)z.current=Date.now();else if(Date.now()-z.current>lJ)q(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",W.current=requestAnimationFrame(L);return}U.style.display="grid";let F=Math.round(B.x+B.w-12),Y=Math.round(B.y-12);U.style.left=`${F}px`,U.style.top=`${Y}px`,W.current=requestAnimationFrame(L)};return W.current=requestAnimationFrame(L),()=>{if(W.current!=null)cancelAnimationFrame(W.current)}},[J,q]);let H=J.author?.trim()||"unknown",j=`Comment ${Q} by ${H}`;return O("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:(L)=>{L.preventDefault(),L.stopPropagation(),Z(J.id)},children:Q})}function nJ({state:J,onSubmit:Q,onCancel:$}){let[Z,q]=u(""),G=S(null),W=S(null),z=S(null);R(()=>{let U=()=>{z.current=null;let B=W.current;if(!B)return;let F=tJ(J),Y=o7(F,{w:B.offsetWidth,h:B.offsetHeight});B.style.left=`${Math.round(Y.x)}px`,B.style.top=`${Math.round(Y.y)}px`,z.current=requestAnimationFrame(U)};return z.current=requestAnimationFrame(U),()=>{if(z.current!=null)cancelAnimationFrame(z.current)}},[J]),R(()=>{G.current?.focus()},[]);let H=k(()=>{let U=Z.trim();if(!U)return;Q(U)},[Z,Q]),j=k((U)=>{if(U.key==="Escape"){U.preventDefault(),$();return}if((U.metaKey||U.ctrlKey)&&U.key==="Enter")U.preventDefault(),H()},[$,H]),L=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:W,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:[O("span",{children:"New comment"}),O("span",{className:"cm-composer__selector",children:L})]}),O(s7,{textareaRef:G,className:"cm-composer__textarea",value:Z,placeholder:"Type a comment. ⌘↵ to save · Esc to cancel · @name to tag",onChange:q,onKeyDown:j,rows:3,ariaLabel:"Comment body"}),x("div",{className:"cm-composer__actions",children:[O("button",{type:"button",className:"cm-btn",onClick:$,children:"Cancel"}),O("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!Z.trim(),onClick:H,children:"Save"})]})]})}function oJ({comment:J,sequence:Q,onClose:$,onPatch:Z,onDelete:q,onReply:G}){let W=S(null),z=S(null),H=S(null),[j,L]=u(""),[U,B]=u(!1);R(()=>{let V=()=>{H.current=null;let X=W.current;if(!X)return;let K=sJ(J),D=o7(K,{w:X.offsetWidth,h:X.offsetHeight});X.style.left=`${Math.round(D.x)}px`,X.style.top=`${Math.round(D.y)}px`,H.current=requestAnimationFrame(V)};return H.current=requestAnimationFrame(V),()=>{if(H.current!=null)cancelAnimationFrame(H.current)}},[J]),R(()=>{W.current?.focus();let V=J.id;return()=>{document.querySelector(`[data-comment-pin="${V}"]`)?.focus()}},[J.id]),R(()=>{if(typeof document>"u")return;let V=(X)=>{if(X.key!=="Escape")return;let K=W.current;if(!K)return;if(K.contains(X.target)||document.activeElement===K)X.preventDefault(),$()};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[$]);let F=k(async()=>{let V=j.trim();if(!V||U)return;B(!0);let X=await G(V);if(B(!1),X)L(""),z.current?.focus()},[j,U,G]),Y=k((V)=>{if((V.metaKey||V.ctrlKey)&&V.key==="Enter")V.preventDefault(),F()},[F]),P=`cm-thread-head-${J.id}`,_=aJ(J.selector,"");return x("div",{ref:W,className:"cm-thread",role:"dialog","aria-labelledby":P,tabIndex:-1,onClick:(V)=>V.stopPropagation(),onPointerDown:(V)=>V.stopPropagation(),children:[x("div",{className:"cm-thread__head",id:P,children:[x("div",{className:"cm-thread__head-row",children:[O("span",{className:"cm-thread__seq","aria-hidden":"true",children:Q}),O("span",{className:"cm-thread__author",children:J.author?.trim()||"unknown"}),O("span",{className:"cm-thread__time",children:n7(J.created)}),O("button",{type:"button",className:"cm-thread__close","aria-label":"Close thread",title:"Close · Esc",onClick:$,children:"×"})]}),_?O("code",{className:"cm-thread__selector",children:_}):null]}),O("div",{className:"cm-thread__body",children:r7(J.text)}),(J.thread??[]).map((V)=>x("div",{className:"cm-thread__reply",children:[x("div",{className:"cm-thread__reply-head",children:[O("span",{className:"cm-thread__reply-author",children:V.author?.trim()||"unknown"}),O("span",{className:"cm-thread__reply-time",children:n7(V.created)})]}),O("div",{className:"cm-thread__reply-body",children:r7(V.body)})]},V.id)),!G7()&&x(eJ,{children:[x("div",{className:"cm-thread__reply-form",children:[O(s7,{textareaRef:z,className:"cm-thread__reply-textarea",value:j,placeholder:"Reply… ⌘↵ to send · @name to tag",onChange:L,onKeyDown:Y,rows:2,ariaLabel:"Reply",disabled:U}),O("div",{className:"cm-thread__reply-actions",children:O("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!j.trim()||U,onClick:()=>void F(),children:"Send"})})]}),x("div",{className:"cm-thread__actions",children:[J.status==="resolved"?O("button",{type:"button",className:"cm-btn",onClick:()=>Z({status:"open"}),children:"↺ Reopen"}):O("button",{type:"button",className:"cm-btn cm-btn--primary",onClick:()=>{Z({status:"resolved"}),$()},children:"✓ Resolve"}),O("button",{type:"button",className:"cm-btn cm-btn--danger",onClick:()=>{q(),$()},children:"Delete"})]})]})]})}function r7(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 O("strong",{"data-mention":"true",children:Z},G);return O("span",{children:Z},G)})}function n7(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 aJ(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 sJ(J){let Q=J.selector?N7(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 tJ(J){if(J.clientX||J.clientY)return{x:J.clientX,y:J.clientY+8};if(J.selection.selector){let Q=N7(J.selection);if(Q)return{x:Q.x,y:Q.y+Q.h+8}}return{x:16,y:16}}import{useEffect as JQ}from"react";var QQ=new Set(["pen","highlighter","shape","rect","ellipse","arrow","sticky","text","section","eraser"]);function _7(J){return QQ.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(_7(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(_7(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 W7(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 J7(J){if(!J||!J.closest)return!1;return!!J.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mediaref-player]")}function $Q(J){if(!J||typeof J.closest!=="function")return!1;let Q=J;return!!Q.closest("[data-dc-screen]")&&!Q.closest(".dc-artboard-body")}function t7(J,Q,$){return J.kind==="select"&&!$.metaKey&&!$.ctrlKey&&$Q(Q)}function e7(J){let{hostRef:Q,getActiveTool:$,isSpaceHeld:Z,callbacks:q,enabled:G=!0,claimableActions:W}=J;JQ(()=>{if(!G)return;let z=Q.current;if(!z)return;let H=(V)=>W&&V.kind!=="no-op"&&!W.has(V.kind)?{kind:"no-op"}:V,j=(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}},L=(V)=>{let X=H(e({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:$()}));j(X)},U=(V)=>{if(J7(V.target))return;if(W7(V.target))return;let X=H(e({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:$()})),K=t7(X,V.target,V);if(X.kind!=="no-op"){if(V.preventDefault(),!K)V.stopImmediatePropagation()}j(X)},B=(V)=>{if(J7(V.target))return;if(W7(V.target))return;let X=H(e({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:$()})),K=t7(X,V.target,V);if(X.kind!=="no-op"){if(V.preventDefault(),!K)V.stopImmediatePropagation();if(X.kind==="select")try{window.focus()}catch{}}},F=(V)=>{if(J7(V.target))return;if(W7(V.target))return;let X=$(),K=V.metaKey||V.ctrlKey,D=X==="comment"?"drop-comment":X==="move"&&V.button===0?"select":(_7(X)||X==="browse")&&K&&V.button===0?"select":V.button===2?"context-menu":null;if(D&&(!W||W.has(D)))V.preventDefault(),V.stopImmediatePropagation()},Y=(V)=>{let X=H(e({type:"contextmenu",clientX:V.clientX,clientY:V.clientY,metaKey:V.metaKey,ctrlKey:V.ctrlKey,shiftKey:V.shiftKey,altKey:V.altKey,activeTool:$()}));if(X.kind==="no-op")return;V.preventDefault(),V.stopImmediatePropagation(),j(X)},P=(V)=>{let X=H(e({type:"keydown",key:V.key,metaKey:V.metaKey,ctrlKey:V.ctrlKey,shiftKey:V.shiftKey,altKey:V.altKey,isEditable:W7(V.target),activeTool:$()}));if(X.kind==="tool"||X.kind==="escape"||X.kind==="undo"||X.kind==="redo")V.preventDefault();j(X)};z.addEventListener("pointermove",L,{passive:!0}),z.addEventListener("pointerdown",U,{capture:!0}),z.addEventListener("mousedown",B,{capture:!0}),z.addEventListener("click",F,{capture:!0}),z.addEventListener("contextmenu",Y,{capture:!0});let _=z.ownerDocument??document;return _.addEventListener("keydown",P,!0),()=>{z.removeEventListener("pointermove",L),z.removeEventListener("pointerdown",U,{capture:!0}),z.removeEventListener("mousedown",B,{capture:!0}),z.removeEventListener("click",F,{capture:!0}),z.removeEventListener("contextmenu",Y,{capture:!0}),_.removeEventListener("keydown",P,!0)}},[G,Q,$,Z,q,W])}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,W=G?.getAttribute("data-dc-screen")??null,z=q.closest?.(".dc-artboard-body")??null;if(!z){if(G&&W)return{el:G,cdId:null,artboardId:W};return null}if(q===z){if(G&&W)return{el:G,cdId:null,artboardId:W};return null}if(Z.deep){let B=q.getAttribute?.("data-cd-id")??null;return{el:q,cdId:B,artboardId:W}}let H=q,j=null;while(H&&H!==z){if(H.hasAttribute?.("data-cd-id"))j=H;H=H.parentElement}let L=j??q,U=L.getAttribute?.("data-cd-id")??null;return{el:L,cdId:U,artboardId:W}}import{useCallback as jQ,useEffect as qJ,useRef as z7}from"react";var VQ=!1;function JJ(){return VQ}import{createContext as UQ,useCallback as k7,useContext as VJ,useEffect as YQ,useMemo as $J,useState as E7}from"react";function m(J,Q,$,Z){return`url("data:image/svg+xml,${encodeURIComponent(J.trim())}") ${Q} ${$}, ${Z}`}var O7="width='24' height='24' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'",T7="#1f1f1f",I7="stroke='#ffffff' stroke-linejoin='round' stroke-linecap='round'";function i(J,Q,$){let Z=$?`<g transform='${$}'>`:"";return`<svg ${O7}>${Z}<path fill='#ffffff' d='${J}'/><path fill='${T7}' d='${Q}'/>${$?"</g>":""}</svg>`}var QJ="translate(0,32) scale(1,-1)",ZQ=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"),qQ=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"),GQ=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"),BQ=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"),KQ=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"),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"),WQ=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"),XQ=m(`<svg ${O7}><path d='M16 4V28M11 4H21M11 28H21' fill='none' ${I7} stroke-width='5'/><path d='M16 4V28M11 4H21M11 28H21' fill='none' stroke='${T7}' stroke-width='2.25' stroke-linecap='round'/></svg>`,12,12,"text"),zQ=m(`<svg ${O7}><path d='M6 5H21L26 10V27H6Z' fill='${T7}' ${I7} stroke-width='2.5'/><path d='M21 5V11H26' fill='none' ${I7} stroke-width='2.25'/></svg>`,5,5,"crosshair"),C=Object.freeze({browse:"default",move:ZQ,hand:qQ,comment:GQ,pen:BQ,section:Q7,highlighter:KQ,shape:Q7,rect:Q7,ellipse:Q7,sticky:zQ,arrow:Q7,text:XQ,eraser:WQ});import{jsx as w7,Fragment as MQ}from"react/jsx-runtime";var HQ=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}]),FQ=new Set(["browse","move","hand"]);function DQ(J,Q){return Q?J.filter(($)=>FQ.has($.id)):J}var b7=UQ(null);function PQ({children:J,tools:Q=HQ,initial:$="browse"}){let Z=$J(()=>DQ(Q,G7()),[Q]),[q,G]=E7($),[W,z]=E7(()=>({tool:null,locked:!1})),H=k7((Y)=>{if(!Z.some((P)=>P.id===Y))return;G(Y),z((P)=>P.locked&&P.tool===Y?P:{tool:null,locked:!1})},[Z]),j=k7((Y)=>{z((P)=>{if(P.locked&&P.tool===Y)return{tool:null,locked:!1};return{tool:Y,locked:!0}}),G(Y)},[]),L=k7(()=>{z({tool:null,locked:!1})},[]),[U,B]=E7("rounded");YQ(()=>{if(typeof document>"u")return;let Y=Z.find((V)=>V.id===q);if(!Y)return;let P=document.body.style.cursor,_=document.getElementById("dc-tool-cursor");if(!_)_=document.createElement("style"),_.id="dc-tool-cursor",document.head.appendChild(_);if(q==="browse"){if(document.body.style.cursor="",_.textContent="",typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:q},"*")}catch{}return()=>{document.body.style.cursor=P}}if(document.body.style.cursor=Y.cursor,_.textContent=`* { cursor: ${Y.cursor} !important; }`,typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:q},"*")}catch{}return()=>{document.body.style.cursor=P;let V=document.getElementById("dc-tool-cursor");if(V)V.textContent=""}},[q,Z]);let F=$J(()=>({tool:q,setTool:H,tools:Z,sticky:W,toggleSticky:j,clearSticky:L,shapeKind:U,setShapeKind:B}),[q,H,Z,W,j,L,U]);return w7(b7.Provider,{value:F,children:J})}function ZJ({children:J}){if(VJ(b7))return w7(MQ,{children:J});return w7(PQ,{children:J})}function X7(){let J=VJ(b7);if(!J)throw Error("useToolMode must be used inside <ToolProvider>");return J}import{jsx as xQ}from"react/jsx-runtime";var LQ=`
|
|
2
2
|
.dc-el-resize-handle {
|
|
3
3
|
position: fixed;
|
|
4
4
|
width: 8px;
|
|
@@ -56,4 +56,4 @@ import{Component as bQ,createElement as g,Fragment as yQ,useCallback as y7,useEf
|
|
|
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 jQ(){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=MQ,document.head.appendChild(J)}var LQ=["nw","n","ne","e","se","s","sw","w"];function NQ(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,U7=1;function _Q(J,Q,$,V,q,G){let{movesLeft:W,movesRight:X,movesTop:H,movesBottom:j}=NQ(J),L=q.center,z=Q.w,B=Q.h;if(X)z=Q.w+(L?2*$:$);else if(W)z=Q.w-(L?2*$:$);if(j)B=Q.h+(L?2*V:V);else if(H)B=Q.h-(L?2*V:V);if(q.aspect&&Q.w>0&&Q.h>0){let Y=Q.w/Q.h;if((W||X)&&(H||j)){let _=Math.abs(z-Q.w)/Q.w,Z=Math.abs(B-Q.h)/Q.h;if(_>=Z)B=z/Y;else z=B*Y}else if(W||X)B=z/Y;else if(H||j)z=B*Y}if(z<U7)z=U7;if(B<U7)B=U7;let F={width:n(z),height:n(B)};if(L){if(G.canMoveLeft&&(W||X))F.left=n(Q.left+(Q.w-z)/2);if(G.canMoveTop&&(H||j))F.top=n(Q.top+(Q.h-B)/2)}else{if(G.canMoveLeft&&W)F.left=n(Q.left+Q.w-z);if(G.canMoveTop&&H)F.top=n(Q.top+Q.h-B)}return F}function qJ(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,q=$[1]??0;return Math.round(Math.atan2(q,V)*(180/Math.PI)*100)/100}function AQ(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,q=$[1]??0,G=Math.hypot(V,q);return G>0?G:1}function IQ(J){let Q=J.closest(".dc-world");if(!Q)return 1;let $=getComputedStyle(Q),V=Number.parseFloat($.zoom||"1")||1;return AQ($.transform)*V}function GJ(J,Q,$){let V=$*Math.PI/180,q=Math.cos(V),G=Math.sin(V);return[J*q-Q*G,J*G+Q*q]}function BJ(J,Q,$,V){return Math.atan2(V-Q,$-J)}function OQ(J,Q,$,V){let q=J+($-Q)*(180/Math.PI);while(q>180)q-=360;while(q<=-180)q+=360;if(V)q=Math.round(q/15)*15;return Math.round(q*100)/100}function TQ(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 kQ(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 EQ(J,Q){try{window.parent.postMessage({dgn:"resize-request",id:J.cdId,patch:{transform:Q},before:J.before,idIndex:J.idIndex},"*")}catch{}}function KJ(){jQ();let{selected:J}=K7(),{tool:Q}=X7(),$=z7(null),V=z7(null),q=z7(null),G=z7(null),W=J.length===1?J[0]:null,X=W&&typeof W.id==="string"?W.id:null,H=W&&!X&&typeof W.artboardId==="string"?W.artboardId:null,j=Q==="move"&&(!!X||!!H);ZJ(()=>{let z=$.current;if(!z)return;let B=()=>{for(let Y of Array.from(z.children)){let P=Y;P.style.opacity="0",P.style.pointerEvents="none"}};if(!j||!W){B();return}let F=()=>{if(V.current=null,e7()){B(),V.current=requestAnimationFrame(F);return}let Y=F7(document,W);if(!Y){B(),V.current=requestAnimationFrame(F);return}let P=Y.getBoundingClientRect();if(P.width<=0&&P.height<=0){B(),V.current=requestAnimationFrame(F);return}let _=H?["e","s","se"]:LQ,Z=H?[]:["rot-nw","rot-ne","rot-sw","rot-se"],U=_.length+Z.length+1;while(z.children.length<U)z.appendChild(document.createElement("div"));while(z.children.length>U)z.lastChild&&z.removeChild(z.lastChild);let K=P.left+P.width/2,D=P.top+P.height/2,N=qJ(getComputedStyle(Y).transform),A=IQ(Y),I=Y.offsetWidth*A/2,M=Y.offsetHeight*A/2,T={nw:[-I,-M],n:[0,-M],ne:[I,-M],e:[I,0],se:[I,M],s:[0,M],sw:[-I,M],w:[-I,0],"rot-nw":[-I,-M],"rot-ne":[I,-M],"rot-sw":[-I,M],"rot-se":[I,M]},E=[...Z,..._];for(let h=0;h<E.length;h++){let b=E[h],v=z.children[h],[d,c]=T[b]??[0,0],[YJ,HJ]=GJ(d,c,N),FJ=K+YJ,DJ=D+HJ,Y7=b.startsWith("rot-"),v7=b==="n"||b==="s",C7=b==="e"||b==="w",PJ=Y7?10:v7?7:C7?3:4,MJ=Y7?10:v7?3:C7?7:4;v.className="dc-el-resize-handle",v.dataset.corner=b,v.style.opacity="1",v.style.pointerEvents="auto",v.style.left=`${Math.round(FJ-PJ)}px`,v.style.top=`${Math.round(DJ-MJ)}px`,v.style.transform=Y7?"":`rotate(${N}deg)`}let x=z.children[E.length],w=q.current;if(w&&w.el===Y&&!w.corner.startsWith("rot-")){let h=w.lastResult?.width??Y.offsetWidth,b=w.lastResult?.height??Y.offsetHeight,v=`${Math.round(h)} × ${Math.round(b)}`,d=w.lastResult?.left,c=w.lastResult?.top;if(typeof d==="number"||typeof c==="number")v+=` · ${Math.round(d??w.start.left)}, ${Math.round(c??w.start.top)}`;x.className="dc-el-resize-readout",x.textContent=v,x.style.opacity="1",x.style.left=`${Math.round(K)}px`,x.style.top=`${Math.round(D+M)}px`}else x.style.opacity="0";V.current=requestAnimationFrame(F)};return V.current=requestAnimationFrame(F),()=>{if(V.current!=null)cancelAnimationFrame(V.current)}},[j,W,H]);let L=PQ((z,B)=>{if(z.el.style.width=`${B.width}px`,z.el.style.height=`${B.height}px`,typeof B.left==="number")z.el.style.left=`${B.left}px`;if(typeof B.top==="number")z.el.style.top=`${B.top}px`;z.lastResult=B},[]);return ZJ(()=>{let z=$.current;if(!z)return;let B=(Z,U)=>{let[K,D]=GJ(U.clientX-Z.startClientX,U.clientY-Z.startClientY,-Z.angle);return _Q(Z.corner,Z.start,K/Z.elZoom,D/Z.elZoom,{aspect:!!U.shiftKey,center:!Z.artboardId&&!!U.altKey},Z.flags)},F=(Z)=>{let U=Z.target;if(!U?.classList.contains("dc-el-resize-handle"))return;let K=U.dataset.corner;if(!K||!W)return;let D=typeof W.id==="string"?W.id:null,N=!D&&typeof W.artboardId==="string"?W.artboardId:null;if(!D&&!N)return;let A=F7(document,W);if(!A)return;Z.preventDefault(),Z.stopPropagation();let I=A.getBoundingClientRect(),M=A.offsetWidth?I.width/A.offsetWidth:1,T=getComputedStyle(A),E=!N&&(T.position==="absolute"||T.position==="fixed"),x=N?Number.NaN:Number.parseFloat(A.style.left),w=N?Number.NaN:Number.parseFloat(A.style.top),h=N?0:qJ(T.transform),b=M>0?M:1,v=I.left+I.width/2,d=I.top+I.height/2,c={pointerId:Z.pointerId,corner:K,el:A,cdId:D??"",artboardId:N,idIndex:D?f7(document,D,A):0,startClientX:Z.clientX,startClientY:Z.clientY,elZoom:b,angle:h,cx:v,cy:d,rotStartPointer:BJ(v,d,Z.clientX,Z.clientY),start:{w:(h?A.offsetWidth:I.width/b)||I.width/b,h:(h?A.offsetHeight:I.height/b)||I.height/b,left:x,top:w},flags:{canMoveLeft:E&&Number.isFinite(x),canMoveTop:E&&Number.isFinite(w)},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{U.setPointerCapture(Z.pointerId)}catch{}},Y=(Z)=>{let U=q.current;if(!U||Z.pointerId!==U.pointerId)return;if(Z.preventDefault(),U.corner.startsWith("rot-")){let D=`rotate(${OQ(U.angle,U.rotStartPointer,BJ(U.cx,U.cy,Z.clientX,Z.clientY),!!Z.shiftKey)}deg)`;U.el.style.transform=D,U.lastTransform=D;return}L(U,B(U,Z))},P=(Z)=>{let U=q.current;if(!U||Z.pointerId!==U.pointerId)return;if(q.current=null,U.corner.startsWith("rot-")){let N=U.lastTransform;if(!N||N===U.before.transform)return;G.current={el:U.el,before:U.before},EQ(U,N);return}let K=U.lastResult??B(U,Z);if(!(`${K.width}px`!==U.before.width||`${K.height}px`!==U.before.height||typeof K.left==="number"&&`${K.left}px`!==U.before.left||typeof K.top==="number"&&`${K.top}px`!==U.before.top))return;if(G.current={el:U.el,before:U.before},U.artboardId)kQ(U,K);else TQ(U,K)},_=(Z)=>{let U=Z.data;if(U?.dgn!=="resize-failed"&&U?.dgn!=="resize-artboard-failed")return;if(Z.source!==window.parent)return;let K=G.current;if(!K)return;if(K.el.style.width=K.before.width??"",K.el.style.height=K.before.height??"",K.before.left!==null||K.el.style.left)K.el.style.left=K.before.left??"";if(K.before.top!==null||K.el.style.top)K.el.style.top=K.before.top??"";if(K.before.transform!==null||K.el.style.transform)K.el.style.transform=K.before.transform??"";G.current=null};return z.addEventListener("pointerdown",F),window.addEventListener("pointermove",Y),window.addEventListener("pointerup",P),window.addEventListener("pointercancel",P),window.addEventListener("message",_),()=>{z.removeEventListener("pointerdown",F),window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",P),window.removeEventListener("pointercancel",P),window.removeEventListener("message",_)}},[W,L]),wQ("div",{ref:$,"aria-hidden":"true"})}import{jsx as o,jsxs as dQ}from"react/jsx-runtime";var CQ=new Set(["drop-comment","tool","escape","hover"]);function V7(){return typeof document<"u"&&!document.querySelector(".dc-canvas")}function x7(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 RQ(J,Q){let $=x7(J,Q);if(!$)return null;return $.closest("[data-cd-id]")??$}function SQ({children:J,file:Q}){let{tool:$,setTool:V}=X7(),q=K7(),G=p(null),[W,X]=$7(null),H=p($);H.current=$;let j=xQ(()=>()=>H.current,[]);f(()=>{if($!=="comment")X(null)},[$]);let[L,z]=$7(null),[B,F]=$7(!1);return f(()=>{let Y=()=>F(V7());Y();let P=requestAnimationFrame(Y),_=setTimeout(Y,120);return()=>{cancelAnimationFrame(P),clearTimeout(_)}},[]),f(()=>{if(typeof document>"u")return;let Y=(P)=>{if(P.button!==0||!(P.metaKey||P.ctrlKey))return;if(!V7())return;if(J7(P.target))return;let _=RQ(P.clientX,P.clientY);if(!_)return;P.preventDefault(),P.stopImmediatePropagation();let Z=_.getAttribute("data-cd-id"),U=D7({el:_,cdId:Z,artboardId:null});if(P.shiftKey)q.add(U);else q.replace(U);z(_)};return document.addEventListener("pointerdown",Y,!0),()=>document.removeEventListener("pointerdown",Y,!0)},[q]),f(()=>{if(q.selected.length===0)z(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=(P)=>{let _=P.data;if(!_||typeof _!=="object"||_.dgn!=="tool-set")return;if(typeof _.tool==="string")V(_.tool)};return window.addEventListener("message",Y),()=>window.removeEventListener("message",Y)},[V]),t7({hostRef:G,getActiveTool:j,claimableActions:CQ,callbacks:{onHover:({clientX:Y,clientY:P})=>{if(H.current!=="comment"||!V7()){X(null);return}let _=x7(Y,P);X((Z)=>Z===_?Z:_)},onTool:({tool:Y})=>V(Y),onEscape:()=>{if(H.current!=="move")V("move");if(X(null),q.clear(),typeof window<"u")try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},onDropComment:({clientX:Y,clientY:P})=>fQ(Y,P,q,Q)}}),dQ("div",{"data-mc-host":!0,ref:G,style:{display:"contents"},children:[J,W?o(hQ,{el:W}):null,L?o(gQ,{el:L}):null,B?o(KJ,{}):null,o(a7,{})]})}function gQ({el:J}){let Q=p(null),$=p(J);$.current=J;let V=p(null);return f(()=>{let q=()=>{V.current=null;let G=Q.current,W=$.current;if(G&&W?.isConnected){let X=W.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";V.current=requestAnimationFrame(q)};return V.current=requestAnimationFrame(q),()=>{if(V.current!=null)cancelAnimationFrame(V.current)}},[]),o("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 hQ({el:J}){let Q=p(null),$=p(J);$.current=J;let V=p(null);return f(()=>{let q=()=>{V.current=null;let G=Q.current,W=$.current;if(G&&W?.isConnected){let X=W.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";V.current=requestAnimationFrame(q)};return V.current=requestAnimationFrame(q),()=>{if(V.current!=null)cancelAnimationFrame(V.current)}},[]),o("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 fQ(J,Q,$,V){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 W=document.elementsFromPoint(J,Q);for(let X of W){let H=X.closest?.("[data-cd-id]");if(!H)continue;if(!H.closest(".dc-artboard-body"))continue;let j=H.closest("[data-dc-screen]");q={el:H,cdId:H.getAttribute("data-cd-id"),artboardId:j?.getAttribute("data-dc-screen")??null};break}}if(!q&&V7()){let W=x7(J,Q);if(W)q={el:W,cdId:W.getAttribute("data-cd-id"),artboardId:null}}if(!q){let W={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:""};WJ(W,J,Q);return}let G=D7(q,V);$.replace(G),WJ(G,J,Q)}function WJ(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 zJ(J,Q){return g(VJ,null,g(i7,null,g(SQ,{file:Q},g(J))))}function a0(J,Q){let $=vQ(Q.rootEl);if(!Q.commentsEnabled){$.render(g(J));return}let V=Q.file??H7();$.render(g(mQ,{initialCanvas:J,file:V}))}var XJ="__maudeCanvasRuntime";function pQ({Canvas:J,file:Q,onOk:$}){return f(()=>{$()},[]),zJ(J,Q)}class UJ extends bQ{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 uQ({message:J}){return g("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 mQ({initialCanvas:J,file:Q}){let[{canvas:$,attempt:V},q]=$7({canvas:J,attempt:0}),[G,W]=$7({on:!1}),X=p(null),H=p($);H.current=$,f(()=>{let B={remount:(F)=>q((Y)=>({canvas:F,attempt:Y.attempt+1})),setHolding:(F,Y)=>W(F?{on:!0,message:Y}:{on:!1})};return window[XJ]=B,()=>{window[XJ]=void 0}},[]);let j=y7(()=>{X.current=H.current,W((B)=>B.on?{on:!1}:B)},[]),L=y7(()=>{W({on:!0,message:"render error"})},[]),z=y7(()=>{let B=X.current;return B?zJ(B,Q):null},[Q]);return g(yQ,null,g(UJ,{attempt:V,onError:L,fallback:z},g(pQ,{key:V,Canvas:$,file:Q,onOk:j})),G.on?g(uQ,{message:G.message}):null)}export{RQ as pickSpecimenSelectEl,a0 as mountCanvas,V7 as isBareSpecimen,UJ as CanvasErrorBoundary};
|
|
59
|
+
`.trim();function NQ(){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=LQ,document.head.appendChild(J)}var _Q=["nw","n","ne","e","se","s","sw","w"];function AQ(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,U7=1;function IQ(J,Q,$,Z,q,G){let{movesLeft:W,movesRight:z,movesTop:H,movesBottom:j}=AQ(J),L=q.center,U=Q.w,B=Q.h;if(z)U=Q.w+(L?2*$:$);else if(W)U=Q.w-(L?2*$:$);if(j)B=Q.h+(L?2*Z:Z);else if(H)B=Q.h-(L?2*Z:Z);if(q.aspect&&Q.w>0&&Q.h>0){let Y=Q.w/Q.h;if((W||z)&&(H||j)){let _=Math.abs(U-Q.w)/Q.w,V=Math.abs(B-Q.h)/Q.h;if(_>=V)B=U/Y;else U=B*Y}else if(W||z)B=U/Y;else if(H||j)U=B*Y}if(U<U7)U=U7;if(B<U7)B=U7;let F={width:n(U),height:n(B)};if(L){if(G.canMoveLeft&&(W||z))F.left=n(Q.left+(Q.w-U)/2);if(G.canMoveTop&&(H||j))F.top=n(Q.top+(Q.h-B)/2)}else{if(G.canMoveLeft&&W)F.left=n(Q.left+Q.w-U);if(G.canMoveTop&&H)F.top=n(Q.top+Q.h-B)}return F}function GJ(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 OQ(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 TQ(J){let Q=J.closest(".dc-world");if(!Q)return 1;let $=getComputedStyle(Q),Z=Number.parseFloat($.zoom||"1")||1;return OQ($.transform)*Z}function BJ(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 KJ(J,Q,$,Z){return Math.atan2(Z-Q,$-J)}function kQ(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 EQ(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 wQ(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 bQ(J,Q){try{window.parent.postMessage({dgn:"resize-request",id:J.cdId,patch:{transform:Q},before:J.before,idIndex:J.idIndex},"*")}catch{}}function WJ(){NQ();let{selected:J}=K7(),{tool:Q}=X7(),$=z7(null),Z=z7(null),q=z7(null),G=z7(null),W=J.length===1?J[0]:null,z=W&&typeof W.id==="string"?W.id:null,H=W&&!z&&typeof W.artboardId==="string"?W.artboardId:null,j=Q==="move"&&(!!z||!!H);qJ(()=>{let U=$.current;if(!U)return;let B=()=>{for(let Y of Array.from(U.children)){let P=Y;P.style.opacity="0",P.style.pointerEvents="none"}};if(!j||!W){B();return}let F=()=>{if(Z.current=null,JJ()){B(),Z.current=requestAnimationFrame(F);return}let Y=F7(document,W);if(!Y){B(),Z.current=requestAnimationFrame(F);return}let P=Y.getBoundingClientRect();if(P.width<=0&&P.height<=0){B(),Z.current=requestAnimationFrame(F);return}let _=H?["e","s","se"]:_Q,V=H?[]:["rot-nw","rot-ne","rot-sw","rot-se"],X=_.length+V.length+1;while(U.children.length<X)U.appendChild(document.createElement("div"));while(U.children.length>X)U.lastChild&&U.removeChild(U.lastChild);let K=P.left+P.width/2,D=P.top+P.height/2,N=GJ(getComputedStyle(Y).transform),A=TQ(Y),I=Y.offsetWidth*A/2,M=Y.offsetHeight*A/2,T={nw:[-I,-M],n:[0,-M],ne:[I,-M],e:[I,0],se:[I,M],s:[0,M],sw:[-I,M],w:[-I,0],"rot-nw":[-I,-M],"rot-ne":[I,-M],"rot-sw":[-I,M],"rot-se":[I,M]},E=[...V,..._];for(let h=0;h<E.length;h++){let b=E[h],v=U.children[h],[d,c]=T[b]??[0,0],[HJ,FJ]=BJ(d,c,N),DJ=K+HJ,PJ=D+FJ,Y7=b.startsWith("rot-"),v7=b==="n"||b==="s",C7=b==="e"||b==="w",MJ=Y7?10:v7?7:C7?3:4,jJ=Y7?10:v7?3:C7?7:4;v.className="dc-el-resize-handle",v.dataset.corner=b,v.style.opacity="1",v.style.pointerEvents="auto",v.style.left=`${Math.round(DJ-MJ)}px`,v.style.top=`${Math.round(PJ-jJ)}px`,v.style.transform=Y7?"":`rotate(${N}deg)`}let y=U.children[E.length],w=q.current;if(w&&w.el===Y&&!w.corner.startsWith("rot-")){let h=w.lastResult?.width??Y.offsetWidth,b=w.lastResult?.height??Y.offsetHeight,v=`${Math.round(h)} × ${Math.round(b)}`,d=w.lastResult?.left,c=w.lastResult?.top;if(typeof d==="number"||typeof c==="number")v+=` · ${Math.round(d??w.start.left)}, ${Math.round(c??w.start.top)}`;y.className="dc-el-resize-readout",y.textContent=v,y.style.opacity="1",y.style.left=`${Math.round(K)}px`,y.style.top=`${Math.round(D+M)}px`}else y.style.opacity="0";Z.current=requestAnimationFrame(F)};return Z.current=requestAnimationFrame(F),()=>{if(Z.current!=null)cancelAnimationFrame(Z.current)}},[j,W,H]);let L=jQ((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 qJ(()=>{let U=$.current;if(!U)return;let B=(V,X)=>{let[K,D]=BJ(X.clientX-V.startClientX,X.clientY-V.startClientY,-V.angle);return IQ(V.corner,V.start,K/V.elZoom,D/V.elZoom,{aspect:!!X.shiftKey,center:!V.artboardId&&!!X.altKey},V.flags)},F=(V)=>{let X=V.target;if(!X?.classList.contains("dc-el-resize-handle"))return;let K=X.dataset.corner;if(!K||!W)return;let D=typeof W.id==="string"?W.id:null,N=!D&&typeof W.artboardId==="string"?W.artboardId:null;if(!D&&!N)return;let A=F7(document,W);if(!A)return;V.preventDefault(),V.stopPropagation();let I=A.getBoundingClientRect(),M=A.offsetWidth?I.width/A.offsetWidth:1,T=getComputedStyle(A),E=!N&&(T.position==="absolute"||T.position==="fixed"),y=N?Number.NaN:Number.parseFloat(A.style.left),w=N?Number.NaN:Number.parseFloat(A.style.top),h=N?0:GJ(T.transform),b=M>0?M:1,v=I.left+I.width/2,d=I.top+I.height/2,c={pointerId:V.pointerId,corner:K,el:A,cdId:D??"",artboardId:N,idIndex:D?f7(document,D,A):0,startClientX:V.clientX,startClientY:V.clientY,elZoom:b,angle:h,cx:v,cy:d,rotStartPointer:KJ(v,d,V.clientX,V.clientY),start:{w:(h?A.offsetWidth:I.width/b)||I.width/b,h:(h?A.offsetHeight:I.height/b)||I.height/b,left:y,top:w},flags:{canMoveLeft:E&&Number.isFinite(y),canMoveTop:E&&Number.isFinite(w)},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{X.setPointerCapture(V.pointerId)}catch{}},Y=(V)=>{let X=q.current;if(!X||V.pointerId!==X.pointerId)return;if(V.preventDefault(),X.corner.startsWith("rot-")){let D=`rotate(${kQ(X.angle,X.rotStartPointer,KJ(X.cx,X.cy,V.clientX,V.clientY),!!V.shiftKey)}deg)`;X.el.style.transform=D,X.lastTransform=D;return}L(X,B(X,V))},P=(V)=>{let X=q.current;if(!X||V.pointerId!==X.pointerId)return;if(q.current=null,X.corner.startsWith("rot-")){let N=X.lastTransform;if(!N||N===X.before.transform)return;G.current={el:X.el,before:X.before},bQ(X,N);return}let K=X.lastResult??B(X,V);if(!(`${K.width}px`!==X.before.width||`${K.height}px`!==X.before.height||typeof K.left==="number"&&`${K.left}px`!==X.before.left||typeof K.top==="number"&&`${K.top}px`!==X.before.top))return;if(G.current={el:X.el,before:X.before},X.artboardId)wQ(X,K);else EQ(X,K)},_=(V)=>{let X=V.data;if(X?.dgn!=="resize-failed"&&X?.dgn!=="resize-artboard-failed")return;if(V.source!==window.parent)return;let K=G.current;if(!K)return;if(K.el.style.width=K.before.width??"",K.el.style.height=K.before.height??"",K.before.left!==null||K.el.style.left)K.el.style.left=K.before.left??"";if(K.before.top!==null||K.el.style.top)K.el.style.top=K.before.top??"";if(K.before.transform!==null||K.el.style.transform)K.el.style.transform=K.before.transform??"";G.current=null};return U.addEventListener("pointerdown",F),window.addEventListener("pointermove",Y),window.addEventListener("pointerup",P),window.addEventListener("pointercancel",P),window.addEventListener("message",_),()=>{U.removeEventListener("pointerdown",F),window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",P),window.removeEventListener("pointercancel",P),window.removeEventListener("message",_)}},[W,L]),xQ("div",{ref:$,"aria-hidden":"true"})}import{jsx as o,jsxs as cQ}from"react/jsx-runtime";var SQ=new Set(["drop-comment","tool","escape","hover"]);function V7(){return typeof document<"u"&&!document.querySelector(".dc-canvas")}function y7(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 gQ(J,Q){let $=y7(J,Q);if(!$)return null;return $.closest("[data-cd-id]")??$}function hQ({children:J,file:Q}){let{tool:$,setTool:Z}=X7(),q=K7(),G=p(null),[W,z]=$7(null),H=p($);H.current=$;let j=CQ(()=>()=>H.current,[]);f(()=>{if($!=="comment")z(null)},[$]);let[L,U]=$7(null),[B,F]=$7(!1);return f(()=>{let Y=()=>F(V7());Y();let P=requestAnimationFrame(Y),_=setTimeout(Y,120);return()=>{cancelAnimationFrame(P),clearTimeout(_)}},[]),f(()=>{if(typeof document>"u")return;let Y=(P)=>{if(P.button!==0||!(P.metaKey||P.ctrlKey))return;if(!V7())return;if(J7(P.target))return;let _=gQ(P.clientX,P.clientY);if(!_)return;P.preventDefault(),P.stopImmediatePropagation();let V=_.getAttribute("data-cd-id"),X=D7({el:_,cdId:V,artboardId:null});if(P.shiftKey)q.add(X);else q.replace(X);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=(P)=>{let _=P.data;if(!_||typeof _!=="object"||_.dgn!=="tool-set")return;if(typeof _.tool==="string")Z(_.tool)};return window.addEventListener("message",Y),()=>window.removeEventListener("message",Y)},[Z]),e7({hostRef:G,getActiveTool:j,claimableActions:SQ,callbacks:{onHover:({clientX:Y,clientY:P})=>{if(H.current!=="comment"||!V7()){z(null);return}let _=y7(Y,P);z((V)=>V===_?V:_)},onTool:({tool:Y})=>Z(Y),onEscape:()=>{if(H.current!=="move")Z("move");if(z(null),q.clear(),typeof window<"u")try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},onDropComment:({clientX:Y,clientY:P})=>uQ(Y,P,q,Q)}}),cQ("div",{"data-mc-host":!0,ref:G,style:{display:"contents"},children:[J,W?o(pQ,{el:W}):null,L?o(fQ,{el:L}):null,B?o(WJ,{}):null,o(a7,{})]})}function fQ({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,W=$.current;if(G&&W?.isConnected){let z=W.getBoundingClientRect();if(z.width===0&&z.height===0)G.style.display="none";else G.style.display="block",G.style.left=`${Math.round(z.left)}px`,G.style.top=`${Math.round(z.top)}px`,G.style.width=`${Math.round(z.width)}px`,G.style.height=`${Math.round(z.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)}},[]),o("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 pQ({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,W=$.current;if(G&&W?.isConnected){let z=W.getBoundingClientRect();if(z.width===0&&z.height===0)G.style.display="none";else G.style.display="block",G.style.left=`${Math.round(z.left)}px`,G.style.top=`${Math.round(z.top)}px`,G.style.width=`${Math.round(z.width)}px`,G.style.height=`${Math.round(z.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)}},[]),o("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 uQ(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 W=document.elementsFromPoint(J,Q);for(let z of W){let H=z.closest?.("[data-cd-id]");if(!H)continue;if(!H.closest(".dc-artboard-body"))continue;let j=H.closest("[data-dc-screen]");q={el:H,cdId:H.getAttribute("data-cd-id"),artboardId:j?.getAttribute("data-dc-screen")??null};break}}if(!q&&V7()){let W=y7(J,Q);if(W)q={el:W,cdId:W.getAttribute("data-cd-id"),artboardId:null}}if(!q){let W={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:""};XJ(W,J,Q);return}let G=D7(q,Z);$.replace(G),XJ(G,J,Q)}function XJ(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 UJ(J,Q){return g(ZJ,null,g(i7,null,g(hQ,{file:Q},g(J))))}function t0(J,Q){let $=RQ(Q.rootEl);if(!Q.commentsEnabled){$.render(g(J));return}let Z=Q.file??H7();$.render(g(iQ,{initialCanvas:J,file:Z}))}var zJ="__maudeCanvasRuntime";function mQ({Canvas:J,file:Q,onOk:$}){return f(()=>{$()},[]),UJ(J,Q)}class YJ extends yQ{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 dQ({message:J}){return g("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 iQ({initialCanvas:J,file:Q}){let[{canvas:$,attempt:Z},q]=$7({canvas:J,attempt:0}),[G,W]=$7({on:!1}),z=p(null),H=p($);H.current=$,f(()=>{let B={remount:(F)=>q((Y)=>({canvas:F,attempt:Y.attempt+1})),setHolding:(F,Y)=>W(F?{on:!0,message:Y}:{on:!1})};return window[zJ]=B,()=>{window[zJ]=void 0}},[]);let j=x7(()=>{z.current=H.current,W((B)=>B.on?{on:!1}:B)},[]),L=x7(()=>{W({on:!0,message:"render error"})},[]),U=x7(()=>{let B=z.current;return B?UJ(B,Q):null},[Q]);return g(vQ,null,g(YJ,{attempt:Z,onError:L,fallback:U},g(mQ,{key:Z,Canvas:$,file:Q,onOk:j})),G.on?g(dQ,{message:G.message}):null)}export{gQ as pickSpecimenSelectEl,t0 as mountCanvas,V7 as isBareSpecimen,YJ as CanvasErrorBoundary};
|