@1agh/maude 0.45.1 → 0.46.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/acp/bridge.ts +628 -74
- package/apps/studio/acp/index.ts +172 -23
- package/apps/studio/acp/probe.ts +31 -7
- package/apps/studio/acp/transcript.ts +91 -5
- package/apps/studio/annotations-snap.ts +50 -10
- package/apps/studio/api.ts +344 -14
- package/apps/studio/artboard-guides-overlay.tsx +270 -0
- package/apps/studio/bin/_import-asset.mjs +35 -5
- package/apps/studio/bin/_pdf-playwright.mjs +35 -4
- package/apps/studio/bin/_png-playwright.mjs +38 -4
- package/apps/studio/bin/_pw-launch.mjs +52 -0
- package/apps/studio/bin/_pw-launch.test.mjs +90 -0
- package/apps/studio/bin/_smart-frames.mjs +419 -0
- package/apps/studio/bin/_smart-frames.test.mjs +140 -0
- package/apps/studio/bin/smart-frames.sh +30 -0
- package/apps/studio/canvas-edit.ts +302 -3
- package/apps/studio/canvas-lib.tsx +203 -11
- package/apps/studio/canvas-shell.tsx +167 -28
- package/apps/studio/client/app.jsx +678 -176
- package/apps/studio/client/panels/CapabilityBar.jsx +101 -0
- package/apps/studio/client/panels/ChatPanel.jsx +846 -133
- package/apps/studio/client/panels/ElicitationPrompt.jsx +429 -0
- package/apps/studio/client/panels/PermissionPrompt.jsx +119 -0
- package/apps/studio/client/panels/ReadinessList.jsx +17 -3
- package/apps/studio/client/panels/SettingsPanel.jsx +211 -0
- package/apps/studio/client/panels/ToolGroup.jsx +79 -0
- package/apps/studio/client/panels/acp-capabilities.js +82 -0
- package/apps/studio/client/panels/acp-elicitation.js +194 -0
- package/apps/studio/client/panels/acp-runtime.js +248 -9
- package/apps/studio/client/panels/acp-usage.js +65 -0
- package/apps/studio/client/panels/transcript-view.js +36 -0
- package/apps/studio/client/styles/6-acp-chat.css +689 -11
- package/apps/studio/dist/client.bundle.js +1738 -1736
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/dom-selection.ts +20 -0
- package/apps/studio/export-dialog.tsx +138 -18
- package/apps/studio/exporters/pdf.ts +332 -18
- package/apps/studio/exporters/png.ts +45 -3
- package/apps/studio/footage/schema.ts +17 -1
- package/apps/studio/generation/gemma-models.ts +224 -0
- package/apps/studio/generation/prefs.ts +43 -0
- package/apps/studio/generation/whisper-models.test.ts +28 -1
- package/apps/studio/generation/whisper-models.ts +22 -7
- package/apps/studio/http.ts +246 -9
- package/apps/studio/print/marks.ts +113 -0
- package/apps/studio/print/units.ts +269 -0
- package/apps/studio/print-overlay-content.tsx +132 -0
- package/apps/studio/test/acp-bridge.test.ts +11 -6
- package/apps/studio/test/acp-capabilities.test.ts +123 -0
- package/apps/studio/test/acp-caps-bridge.test.ts +274 -0
- package/apps/studio/test/acp-elicitation-bridge.test.ts +475 -0
- package/apps/studio/test/acp-elicitation.test.ts +251 -0
- package/apps/studio/test/acp-mode-banner.test.ts +45 -0
- package/apps/studio/test/acp-permission-prompt.test.ts +77 -0
- package/apps/studio/test/acp-permission.test.ts +262 -0
- package/apps/studio/test/acp-session-allowed-tools.test.ts +91 -0
- package/apps/studio/test/acp-toolgroup.test.ts +76 -0
- package/apps/studio/test/acp-transcript-view.test.ts +71 -0
- package/apps/studio/test/acp-transcript.test.ts +75 -2
- package/apps/studio/test/acp-usage-bridge.test.ts +136 -0
- package/apps/studio/test/acp-usage.test.ts +143 -0
- package/apps/studio/test/annotations-snap.test.ts +56 -0
- package/apps/studio/test/artboard-guides-overlay.test.tsx +152 -0
- package/apps/studio/test/artboard-kinds.test.tsx +83 -0
- package/apps/studio/test/artboard-selection-attrs.test.ts +69 -0
- package/apps/studio/test/canvas-meta-api.test.ts +167 -0
- package/apps/studio/test/element-structural-edit.test.ts +250 -0
- package/apps/studio/test/exporters/png.test.ts +49 -1
- package/apps/studio/test/fixtures/mock-acp-agent-caps.mjs +158 -0
- package/apps/studio/test/fixtures/mock-acp-agent-elicit-flood.mjs +46 -0
- package/apps/studio/test/fixtures/mock-acp-agent-elicit-url.mjs +42 -0
- package/apps/studio/test/fixtures/mock-acp-agent-elicit.mjs +63 -0
- package/apps/studio/test/fixtures/mock-acp-agent-permission-flood.mjs +51 -0
- package/apps/studio/test/fixtures/mock-acp-agent-permission.mjs +50 -0
- package/apps/studio/test/fixtures/mock-acp-agent-usage.mjs +56 -0
- package/apps/studio/test/import-asset.test.ts +31 -3
- package/apps/studio/test/pdf-print-boxes.test.ts +272 -0
- package/apps/studio/test/print-marks.test.ts +113 -0
- package/apps/studio/test/print-units.test.ts +173 -0
- package/apps/studio/test/use-snap-guides.test.ts +81 -0
- package/apps/studio/use-chrome-visibility.tsx +19 -0
- package/apps/studio/use-element-resize.tsx +21 -2
- package/apps/studio/use-snap-guides.tsx +73 -5
- package/apps/studio/use-spacing-handles.tsx +9 -5
- package/apps/studio/whats-new.json +62 -0
- package/cli/commands/design.mjs +116 -3
- package/cli/lib/pkg-root.mjs +42 -10
- package/cli/lib/pkg-root.test.mjs +33 -1
- package/package.json +11 -9
- package/plugins/design/dependencies.json +35 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Component as _Q,createElement as h,Fragment as AQ,useCallback as k7,useEffect as p,useMemo as IQ,useRef as u,useState as Q7}from"react";import{createRoot as OQ}from"react-dom/client";import{useCallback as E,useEffect as R,useMemo as s,useRef as g,useState as m}from"react";function z7(){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 FJ(J,Q){if(!J)return"";let $=(J.innerText||J.textContent||"").replace(/\s+/g," ").trim();return $.length>Q?`${$.slice(0,Q-1)}…`:$}function DJ(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 B=$.nodeName.toLowerCase();if($.id){B=`#${$.id}`,Q.unshift(B);break}let K=Z7($).split(/\s+/).filter(Boolean).slice(0,2);if(K.length)B+=`.${K.join(".")}`;let U=1,H=$.previousElementSibling;while(H)U++,H=H.previousElementSibling;B+=`:nth-child(${U})`,Q.unshift(B),$=$.parentElement}return Q.join(" > ")}function C7(J){let Q=[],$=J;while($&&$.nodeType===1&&Q.length<8){let V=$.nodeName.toLowerCase(),q=$.getAttribute?.("data-dc-element"),B=$.getAttribute?.("data-dc-screen");if(q)V+=`[data-dc-element="${q}"]`;else if(B)V+=`[data-dc-screen="${B}"]`;else if($.id)V+=`#${$.id}`;let K=Z7($).split(/\s+/).filter(Boolean).slice(0,2);if(K.length&&!q&&!B)V+=`.${K.join(".")}`;Q.unshift(V),$=$.parentElement}return Q}function LJ(J){return J.replace(/[^a-zA-Z0-9_-]/g,(Q)=>`\\${Q}`)}function v7(J,Q){return Q?`[data-dc-screen="${Q}"] [data-cd-id="${J}"]`:`[data-cd-id="${J}"]`}function S7(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 R7(J,Q,$){if(!Q||!$)return 0;return S7(J,`[data-cd-id="${LJ(Q)}"]`,$)}function X7(J,Q){let $=(V)=>{try{let q=J.querySelectorAll(V);if(!q.length)return null;let B=Q.index&&Q.index>0&&Q.index<q.length?Q.index:0;return q[B]??q[0]}catch{return null}};if(Q.id){let V=$(v7(Q.id,Q.artboardId));if(V)return V}if(Q.selector)return $(Q.selector);return null}function PJ(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 g7(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 B=(Q.classes||"").split(/\s+/).filter(Boolean),K=null,U=0;for(let H of Array.from(q.querySelectorAll("[data-cd-id]"))){if(H.tagName.toLowerCase()!==V)continue;let M=PJ(C7(H),$);if(M===0)continue;let j=Z7(H).split(/\s+/).filter(Boolean),z=B.filter((F)=>j.includes(F)).length,G=M*10+z;if(G>U)U=G,K=H}return K}var x7=["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"],MJ=/^(style|class|data-cd-id|data-dc-|data-dcid$)/;function jJ(J){if(!J||typeof window>"u"||!window.getComputedStyle)return{authored:{},computed:{},customStyles:{},attrs:{}};try{let Q=J.style,$=window.getComputedStyle(J),V={},q={},B=new Set(x7);for(let G of x7){let F=Q.getPropertyValue(G);if(F)V[G]=F.trim();let Y=$.getPropertyValue(G);if(Y)q[G]=Y.trim()}let K=/^(margin|padding|border)(-|$)/,U={};for(let G=0;G<Q.length;G++){let F=Q.item(G);if(!F||B.has(F)||K.test(F))continue;let Y=Q.getPropertyValue(F);if(Y)U[F]=Y.trim()}let H={};for(let G of Array.from(J.attributes)){if(MJ.test(G.name))continue;H[G.name]=G.value}let M=J.parentElement,j=M?window.getComputedStyle(M).display:"",z=M&&(j==="flex"||j==="inline-flex")?window.getComputedStyle(M).flexDirection:"";return{authored:V,computed:q,customStyles:U,attrs:H,parentDisplay:j,parentFlexDirection:z}}catch{return{authored:{},computed:{},customStyles:{},attrs:{}}}}function Y7(J,Q){let $=J.el,V=$&&$.getBoundingClientRect?$.getBoundingClientRect():null,q=J.cdId,B=q?v7(q,J.artboardId):J.artboardId?`[data-dc-screen="${J.artboardId}"]`:DJ($),K=q&&typeof document<"u"?S7(document,B,$):0;return{file:Q??z7(),id:q??void 0,selector:B,artboardId:J.artboardId,index:K,tag:$?.tagName.toLowerCase()??"",classes:Z7($),text:FJ($,240),dom_path:C7($),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 U=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,H=$.getAttribute?.("data-photo-asset");if(H&&U.test(H))return{photoKind:"artboard-img",photoAsset:H};let M=$.getAttribute?.("src")||"",j=U.exec(M);return j?{photoKind:"artboard-img",photoAsset:j[0]}:{}})(),...jJ($)}}import*as H7 from"lib0/decoding";import*as a from"lib0/encoding";import{createContext as NJ,useCallback as hQ,useContext as _J,useEffect as fQ,useMemo as pQ,useReducer as uQ,useRef as mQ,useState as dQ}from"react";import{Awareness as cQ,applyAwarenessUpdate as lQ,encodeAwarenessUpdate as rQ}from"y-protocols/awareness";import{readSyncMessage as oQ,writeSyncStep1 as aQ,writeUpdate as sQ}from"y-protocols/sync";import*as AJ from"yjs";import{jsx as eQ}from"react/jsx-runtime";var IJ=NJ(null);function h7(){return _J(IJ)}import{createContext as OJ,useCallback as l,useContext as D7,useEffect as TJ,useMemo as EJ,useRef as kJ,useState as wJ}from"react";import{jsx as F7,Fragment as xJ}from"react/jsx-runtime";var q7=OJ(null);function r(J){return J.id?`id:${J.id}`:`sel:${J.selector}`}function f7(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 yJ=50;function bJ({children:J,postTarget:Q}){let[$,V]=wJ([]),q=kJ(null),B=l((G)=>{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=G.length===0?null:G.length===1?G[0]??null:G;try{F.postMessage({dgn:"select-set",selection:Y},"*")}catch{}},yJ)},[Q]);TJ(()=>()=>{if(q.current)clearTimeout(q.current)},[]);let K=l((G)=>{let F=f7(Array.isArray(G)?G:[G]);V(F),B(F)},[B]),U=l((G)=>{let F=Array.isArray(G)?G:[G];V((Y)=>{let L=f7([...Y,...F]);return B(L),L})},[B]),H=l((G)=>{let F=r(G);V((Y)=>{let L=Y.filter((_)=>r(_)!==F);return B(L),L})},[B]),M=l((G)=>{let F=r(G);V((Y)=>{let L=Y.some((_)=>r(_)===F)?Y.filter((_)=>r(_)!==F):[...Y,G];return B(L),L})},[B]),j=l(()=>{V([]),B([])},[B]),z=EJ(()=>({selected:$,replace:K,add:U,remove:H,toggle:M,clear:j}),[$,K,U,H,M,j]);return F7(q7.Provider,{value:z,children:J})}function p7({children:J}){if(D7(q7))return F7(xJ,{children:J});return F7(bJ,{children:J})}function B7(){let J=D7(q7);if(!J)throw Error("useSelectionSet must be used inside <SelectionSetProvider>");return J}function u7(){return D7(q7)}import{jsx as O,jsxs as k}from"react/jsx-runtime";var CJ="/_client/comments-overlay.css";function vJ(){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=CJ,document.head.appendChild(J)}function SJ(){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 RJ(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=g7(document,{artboardId:$,tag:J.tag,classes:J.classes,dom_path:J.dom_path})}return Q}function P7(J){let Q=RJ(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 c7(J,Q){let V=typeof window<"u"?window.innerWidth:J.x+Q.w,q=typeof window<"u"?window.innerHeight:J.y+Q.h,B=J.x;if(B+Q.w+8>V){let U=J.x-Q.w;B=U>=8?U:Math.max(8,V-Q.w-8)}let K=J.y;if(K+Q.h+8>q){let U=J.y-Q.h;K=U>=8?U:Math.max(8,q-Q.h-8)}return{x:B,y:K}}function l7(){vJ();let J=u7(),[Q,$]=m([]),[V,q]=m(null),[B,K]=m(null),U=s(()=>SJ(),[]);R(()=>{if(typeof document>"u")return;let W=document.getElementById("dgn-pin-layer");if(!W)return;let D=W.style.display;return W.style.display="none",()=>{W.style.display=D}},[]);let H=E((W)=>{if(!J)return;if(!W?.selector){J.clear();return}let D=W.selector.match(/data-cd-id="([^"]+)"/),N=D?D[1]:void 0,A,T;try{let P=document.querySelector(W.selector);if(P)A=P.tagName.toLowerCase(),T=(P.getAttribute("class")??"").split(/\s+/).filter((I)=>I&&!I.startsWith("dgn-")&&!I.startsWith("dc-cv-")).join(" ")}catch{}J.replace({file:U??void 0,id:N,selector:W.selector,tag:A,classes:T,bounds:W.bounds??void 0})},[J,U]),M=g(Q);M.current=Q;let j=h7();R(()=>{if(!j)return;let W=j.doc.getArray("comments"),D=()=>{$(W.toArray())};if(W.length>0)D();return W.observe(D),()=>{try{W.unobserve(D)}catch{}}},[j]),R(()=>{if(typeof window>"u")return;let W=(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 T=A?M.current.find((P)=>P.id===A):void 0;H(T)}};return window.addEventListener("message",W),()=>window.removeEventListener("message",W)},[H]),R(()=>{if(typeof document>"u")return;let W=(D)=>{let N=D.detail;if(!N?.selection)return;K({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",W),()=>document.removeEventListener("cm:open-composer",W)},[]);let z=E(()=>{if(K(null),typeof window>"u")return;try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},[]),G=E((W)=>{if(!B)return;let D=B.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:W};if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-submit",payload:N},"*")}catch{}z()},[B,z]);R(()=>{if(!U)return;let W=!1;return(async()=>{try{let D=await fetch(`/_comments?file=${encodeURIComponent(U)}`);if(!D.ok)return;let N=await D.json();if(W)return;if(Array.isArray(N.comments))$((A)=>A.length===0?N.comments??[]:A)}catch{}})(),()=>{W=!0}},[U]);let F=s(()=>{return Q.slice().sort((D,N)=>D.created.localeCompare(N.created)).filter((D)=>D.status!=="resolved")},[Q]),Y=s(()=>{let W=new Map;return Q.slice().sort((N,A)=>N.created.localeCompare(A.created)).forEach((N,A)=>{W.set(N.id,A+1)}),W},[Q]),L=E((W)=>{if(q(W),H(Q.find((D)=>D.id===W)),typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-click",id:W},"*")}catch{}},[Q,H]),_=E((W,D)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-patch",id:W,patch:D},"*")}catch{}},[]),Z=E((W)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-delete",id:W},"*")}catch{}q((D)=>D===W?null:D)},[]),X=E(async(W,D)=>{if(typeof fetch>"u")return!1;try{let N=await fetch(`/_api/comments/${encodeURIComponent(W)}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:D})});if(!N.ok)return!1;let A=await N.json();return $((T)=>T.map((P)=>P.id===A.id?A:P)),!0}catch{return!1}},[]);return k("div",{className:"cm-layer","aria-hidden":!1,children:[F.map((W)=>{let D=Y.get(W.id)??0;return O(pJ,{comment:W,sequence:D,focused:V===W.id,onClick:L,onOrphaned:Z},W.id)}),B?O(uJ,{state:B,onSubmit:G,onCancel:z}):null,(()=>{if(!V)return null;let W=F.find((D)=>D.id===V);if(!W)return null;return O(mJ,{comment:W,sequence:Y.get(W.id)??0,onClose:()=>{q(null),J?.clear()},onPatch:(D)=>_(W.id,D),onDelete:()=>Z(W.id),onReply:(D)=>X(W.id,D)})})()]})}var L7=null;async function gJ(){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 m7(J){return(J.trim().split(/\s+/)[0]??"").replace(/[^\w.-]/g,"").toLowerCase()}function hJ(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 B=J.slice($+1,Q);return{start:$,end:Q,query:B}}return null}if(!/[\w.-]/.test(V))return null;$-=1}return null}function r7({className:J,value:Q,onChange:$,onKeyDown:V,placeholder:q,rows:B,disabled:K,textareaRef:U,ariaLabel:H}){let M=g(null),j=E((P)=>{if(M.current=P,U)U.current=P},[U]),[z,G]=m([]),[F,Y]=m(null),[L,_]=m(0),Z=E(()=>{if(z.length>0)return;gJ().then((P)=>G(P))},[z.length]),X=s(()=>{if(!F)return[];let P=F.query.toLowerCase();return(!P?z:z.filter((w)=>w.name.toLowerCase().includes(P)||w.email.toLowerCase().includes(P))).slice(0,8)},[F,z]),W=E((P)=>{let I=P.selectionStart??P.value.length,w=hJ(P.value,I);Y(w),_(0)},[]),D=E((P)=>{$(P.target.value),W(P.target)},[$,W]),N=E((P)=>{if(!F)return;let I=M.current;if(!I)return;let w=`@${m7(P.name)}`,f=`${Q.slice(0,F.start)}${w} ${Q.slice(F.end)}`;$(f),Y(null);let x=F.start+w.length+1;requestAnimationFrame(()=>{I.focus(),I.setSelectionRange(x,x)})},[F,Q,$]),A=E((P)=>{if(F&&X.length>0){if(P.key==="ArrowDown"){P.preventDefault(),_((I)=>(I+1)%X.length);return}if(P.key==="ArrowUp"){P.preventDefault(),_((I)=>(I-1+X.length)%X.length);return}if(P.key==="Enter"||P.key==="Tab"){P.preventDefault();let I=X[L]??X[0];if(I)N(I);return}if(P.key==="Escape"){P.preventDefault(),Y(null);return}}V?.(P)},[F,X,L,N,V]),T=E((P)=>{W(P.currentTarget)},[W]);return k("div",{style:{position:"relative"},children:[O("textarea",{ref:j,className:J,value:Q,placeholder:q,rows:B,disabled:K,"aria-label":H,onChange:D,onKeyDown:A,onFocus:Z,onSelect:T,onClick:T}),F&&X.length>0?O("ul",{className:"cm-mention-popup",role:"listbox","aria-label":"Mention suggestions",style:{left:0,top:"100%"},children:X.map((P,I)=>{return k("li",{role:"option","aria-selected":I===L,className:"cm-mention-popup__item",onMouseEnter:()=>_(I),onMouseDown:(f)=>{f.preventDefault(),N(P)},children:[k("span",{className:"cm-mention-popup__name",children:["@",m7(P.name)]}),O("span",{className:"cm-mention-popup__email",children:P.email})]},`${P.name}-${P.email}`)})}):null]})}var fJ=3000;function pJ({comment:J,sequence:Q,focused:$,onClick:V,onOrphaned:q}){let B=g(null),K=g(null),U=g(null);R(()=>{let j=()=>{K.current=null;let z=B.current;if(!z)return;let G=P7(J);if(G)U.current=null;else{if(U.current==null)U.current=Date.now();else if(Date.now()-U.current>fJ)q(J.id);if(J.bounds)G={x:J.bounds.x,y:J.bounds.y,w:J.bounds.w,h:J.bounds.h}}if(!G){z.style.display="none",K.current=requestAnimationFrame(j);return}z.style.display="grid";let F=Math.round(G.x+G.w-12),Y=Math.round(G.y-12);z.style.left=`${F}px`,z.style.top=`${Y}px`,K.current=requestAnimationFrame(j)};return K.current=requestAnimationFrame(j),()=>{if(K.current!=null)cancelAnimationFrame(K.current)}},[J,q]);let H=J.author?.trim()||"unknown",M=`Comment ${Q} by ${H}`;return O("button",{ref:B,type:"button",className:"cm-pin","data-resolved":J.status==="resolved"?"true":"false","data-focused":$?"true":"false","data-comment-pin":J.id,"aria-label":M,"aria-expanded":$,title:J.text.slice(0,200),onClick:(j)=>{j.preventDefault(),j.stopPropagation(),V(J.id)},children:Q})}function uJ({state:J,onSubmit:Q,onCancel:$}){let[V,q]=m(""),B=g(null),K=g(null),U=g(null);R(()=>{let z=()=>{U.current=null;let G=K.current;if(!G)return;let F=cJ(J),Y=c7(F,{w:G.offsetWidth,h:G.offsetHeight});G.style.left=`${Math.round(Y.x)}px`,G.style.top=`${Math.round(Y.y)}px`,U.current=requestAnimationFrame(z)};return U.current=requestAnimationFrame(z),()=>{if(U.current!=null)cancelAnimationFrame(U.current)}},[J]),R(()=>{B.current?.focus()},[]);let H=E(()=>{let z=V.trim();if(!z)return;Q(z)},[V,Q]),M=E((z)=>{if(z.key==="Escape"){z.preventDefault(),$();return}if((z.metaKey||z.ctrlKey)&&z.key==="Enter")z.preventDefault(),H()},[$,H]),j=s(()=>{let z=J.selection.selector||"";if(!z)return J.selection.tag||"canvas";let G=z.match(/data-cd-id="([^"]+)"/);if(G)return`cd:${G[1]}`;return z.length>36?`${z.slice(0,33)}…`:z},[J.selection]);return k("div",{ref:K,className:"cm-composer",role:"dialog","aria-label":"New comment",onClick:(z)=>z.stopPropagation(),onPointerDown:(z)=>z.stopPropagation(),children:[k("div",{className:"cm-composer__head",children:[O("span",{children:"New comment"}),O("span",{className:"cm-composer__selector",children:j})]}),O(r7,{textareaRef:B,className:"cm-composer__textarea",value:V,placeholder:"Type a comment. ⌘↵ to save · Esc to cancel · @name to tag",onChange:q,onKeyDown:M,rows:3,ariaLabel:"Comment body"}),k("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 mJ({comment:J,sequence:Q,onClose:$,onPatch:V,onDelete:q,onReply:B}){let K=g(null),U=g(null),H=g(null),[M,j]=m(""),[z,G]=m(!1);R(()=>{let Z=()=>{H.current=null;let X=K.current;if(!X)return;let W=iJ(J),D=c7(W,{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(Z)};return H.current=requestAnimationFrame(Z),()=>{if(H.current!=null)cancelAnimationFrame(H.current)}},[J]),R(()=>{K.current?.focus();let Z=J.id;return()=>{document.querySelector(`[data-comment-pin="${Z}"]`)?.focus()}},[J.id]),R(()=>{if(typeof document>"u")return;let Z=(X)=>{if(X.key!=="Escape")return;let W=K.current;if(!W)return;if(W.contains(X.target)||document.activeElement===W)X.preventDefault(),$()};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[$]);let F=E(async()=>{let Z=M.trim();if(!Z||z)return;G(!0);let X=await B(Z);if(G(!1),X)j(""),U.current?.focus()},[M,z,B]),Y=E((Z)=>{if((Z.metaKey||Z.ctrlKey)&&Z.key==="Enter")Z.preventDefault(),F()},[F]),L=`cm-thread-head-${J.id}`,_=dJ(J.selector,"");return k("div",{ref:K,className:"cm-thread",role:"dialog","aria-labelledby":L,tabIndex:-1,onClick:(Z)=>Z.stopPropagation(),onPointerDown:(Z)=>Z.stopPropagation(),children:[k("div",{className:"cm-thread__head",id:L,children:[k("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:i7(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:d7(J.text)}),(J.thread??[]).map((Z)=>k("div",{className:"cm-thread__reply",children:[k("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:i7(Z.created)})]}),O("div",{className:"cm-thread__reply-body",children:d7(Z.body)})]},Z.id)),k("div",{className:"cm-thread__reply-form",children:[O(r7,{textareaRef:U,className:"cm-thread__reply-textarea",value:M,placeholder:"Reply… ⌘↵ to send · @name to tag",onChange:j,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:!M.trim()||z,onClick:()=>void F(),children:"Send"})})]}),k("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 d7(J){if(!J)return null;let Q=/(@[\w][\w.-]*)/g;return J.split(Q).map((V,q)=>{let B=`${q}:${V}`;if(q%2===1)return O("strong",{"data-mention":"true",children:V},B);return O("span",{children:V},B)})}function i7(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 dJ(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 iJ(J){let Q=J.selector?P7(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 cJ(J){if(J.clientX||J.clientY)return{x:J.clientX,y:J.clientY+8};if(J.selection.selector){let Q=P7(J.selection);if(Q)return{x:Q.x,y:Q.y+Q.h+8}}return{x:16,y:16}}import{useEffect as lJ}from"react";var rJ=new Set(["pen","highlighter","shape","rect","ellipse","arrow","sticky","text","section","eraser"]);function n7(J){return rJ.has(J)}var M7=(J)=>!!(J.metaKey||J.ctrlKey);function t(J){if(J.type==="keydown"){if(J.isEditable)return{kind:"no-op"};if(J.metaKey||J.ctrlKey||J.altKey){if(J.key==="Escape")return{kind:"escape"};let $=(J.key||"").toLowerCase();if(!J.altKey&&(J.metaKey||J.ctrlKey)){if($==="z"&&J.shiftKey)return{kind:"redo"};if($==="z")return{kind:"undo"};if($==="y"&&!J.shiftKey)return{kind:"redo"}}return{kind:"no-op"}}let Q=(J.key||"").toLowerCase();if(Q==="v")return{kind:"tool",tool:"move"};if(Q==="h")return{kind:"tool",tool:"hand"};if(Q==="c")return{kind:"tool",tool:"comment"};if(Q==="b")return{kind:"tool",tool:"pen"};if(Q==="i")return{kind:"tool",tool:"highlighter"};if(Q==="r"||Q==="o")return{kind:"tool",tool:"shape"};if(Q==="a")return{kind:"tool",tool:"arrow"};if(Q==="n")return{kind:"tool",tool:"sticky"};if(Q==="t")return{kind:"tool",tool:"text"};if(Q==="s"&&J.shiftKey)return{kind:"tool",tool:"section"};if(Q==="e")return{kind:"tool",tool:"eraser"};if(J.key==="Escape")return{kind:"escape"};return{kind:"no-op"}}if(J.type==="contextmenu")return{kind:"context-menu",clientX:J.clientX??0,clientY:J.clientY??0};if(J.type==="pointermove"){if(n7(J.activeTool))return{kind:"no-op"};if(J.activeTool==="hand")return{kind:"no-op"};if(J.activeTool==="comment")return{kind:"hover",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0};if(!M7(J))return{kind:"no-op"};return{kind:"hover",deep:!0,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(n7(J.activeTool)&&!M7(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(!M7(J))return{kind:"no-op"};return{kind:"select",mode:!!J.shiftKey?"add":"replace",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0}}return{kind:"no-op"}}function nJ(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 e(J){if(!J||!J.closest)return!1;return!!J.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mediaref-player]")}function o7(J){let{hostRef:Q,getActiveTool:$,isSpaceHeld:V,callbacks:q,enabled:B=!0,claimableActions:K}=J;lJ(()=>{if(!B)return;let U=Q.current;if(!U)return;let H=(Z)=>K&&Z.kind!=="no-op"&&!K.has(Z.kind)?{kind:"no-op"}:Z,M=(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}},j=(Z)=>{let X=H(t({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:$()}));M(X)},z=(Z)=>{if(e(Z.target))return;let X=H(t({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(X.kind!=="no-op")Z.preventDefault(),Z.stopImmediatePropagation();M(X)},G=(Z)=>{if(e(Z.target))return;let X=H(t({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(X.kind!=="no-op"){if(Z.preventDefault(),Z.stopImmediatePropagation(),X.kind==="select")try{window.focus()}catch{}}},F=(Z)=>{if(e(Z.target))return;let X=$(),W=Z.metaKey||Z.ctrlKey,D=X==="comment"?"drop-comment":X==="move"&&W&&Z.button===0?"select":Z.button===2?"context-menu":null;if(D&&(!K||K.has(D)))Z.preventDefault(),Z.stopImmediatePropagation()},Y=(Z)=>{let X=H(t({type:"contextmenu",clientX:Z.clientX,clientY:Z.clientY,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,activeTool:$()}));if(X.kind==="no-op")return;Z.preventDefault(),Z.stopImmediatePropagation(),M(X)},L=(Z)=>{let X=H(t({type:"keydown",key:Z.key,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,isEditable:nJ(Z.target),activeTool:$()}));if(X.kind==="tool"||X.kind==="escape"||X.kind==="undo"||X.kind==="redo")Z.preventDefault();M(X)};U.addEventListener("pointermove",j,{passive:!0}),U.addEventListener("pointerdown",z,{capture:!0}),U.addEventListener("mousedown",G,{capture:!0}),U.addEventListener("click",F,{capture:!0}),U.addEventListener("contextmenu",Y,{capture:!0});let _=U.ownerDocument??document;return _.addEventListener("keydown",L,!0),()=>{U.removeEventListener("pointermove",j),U.removeEventListener("pointerdown",z,{capture:!0}),U.removeEventListener("mousedown",G,{capture:!0}),U.removeEventListener("click",F,{capture:!0}),U.removeEventListener("contextmenu",Y,{capture:!0}),_.removeEventListener("keydown",L,!0)}},[B,Q,$,V,q,K])}function j7(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 B=q.closest?.("[data-dc-screen]")??null,K=B?.getAttribute("data-dc-screen")??null,U=q.closest?.(".dc-artboard-body")??null;if(!U){if(B&&K)return{el:B,cdId:null,artboardId:K};return null}if(q===U){if(B&&K)return{el:B,cdId:null,artboardId:K};return null}if(V.deep){let G=q.getAttribute?.("data-cd-id")??null;return{el:q,cdId:G,artboardId:K}}let H=q,M=null;while(H&&H!==U){if(H.hasAttribute?.("data-cd-id"))M=H;H=H.parentElement}let j=M??q,z=j.getAttribute?.("data-cd-id")??null;return{el:j,cdId:z,artboardId:K}}import{useCallback as UQ,useEffect as JJ,useRef as W7}from"react";var oJ=!1;function a7(){return oJ}import{createContext as ZQ,useCallback as I7,useContext as t7,useEffect as qQ,useMemo as BQ,useState as O7}from"react";function d(J,Q,$,V){return`url("data:image/svg+xml,${encodeURIComponent(J.trim())}") ${Q} ${$}, ${V}`}var _7="width='24' height='24' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'",A7="#1f1f1f",N7="stroke='#ffffff' stroke-linejoin='round' stroke-linecap='round'";function i(J,Q,$){let V=$?`<g transform='${$}'>`:"";return`<svg ${_7}>${V}<path fill='#ffffff' d='${J}'/><path fill='${A7}' d='${Q}'/>${$?"</g>":""}</svg>`}var s7="translate(0,32) scale(1,-1)",aJ=d(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"),sJ=d(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"),tJ=d(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"),eJ=d(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",s7),6,18,"crosshair"),JQ=d(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",s7),6,18,"crosshair"),J7=d(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"),QQ=d(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"),$Q=d(`<svg ${_7}><path d='M16 4V28M11 4H21M11 28H21' fill='none' ${N7} stroke-width='5'/><path d='M16 4V28M11 4H21M11 28H21' fill='none' stroke='${A7}' stroke-width='2.25' stroke-linecap='round'/></svg>`,12,12,"text"),VQ=d(`<svg ${_7}><path d='M6 5H21L26 10V27H6Z' fill='${A7}' ${N7} stroke-width='2.5'/><path d='M21 5V11H26' fill='none' ${N7} stroke-width='2.25'/></svg>`,5,5,"crosshair"),S=Object.freeze({move:aJ,hand:sJ,comment:tJ,pen:eJ,section:J7,highlighter:JQ,shape:J7,rect:J7,ellipse:J7,sticky:VQ,arrow:J7,text:$Q,eraser:QQ});import{jsx as T7,Fragment as KQ}from"react/jsx-runtime";var GQ=Object.freeze([{id:"move",label:"Move",shortcut:"V",cursor:S.move},{id:"hand",label:"Hand",shortcut:"H",cursor:S.hand},{id:"comment",label:"Comment",shortcut:"C",cursor:S.comment},{id:"pen",label:"Pen",shortcut:"B",cursor:S.pen},{id:"highlighter",label:"Highlighter",shortcut:"I",cursor:S.highlighter},{id:"shape",label:"Shape",shortcut:"R",cursor:S.shape},{id:"sticky",label:"Sticky",shortcut:"N",cursor:S.sticky},{id:"section",label:"Section",shortcut:"⇧S",cursor:S.shape},{id:"arrow",label:"Arrow",shortcut:"A",cursor:S.arrow},{id:"text",label:"Text",shortcut:"T",cursor:S.text},{id:"eraser",label:"Eraser",shortcut:"E",cursor:S.eraser}]),E7=ZQ(null);function WQ({children:J,tools:Q=GQ,initial:$="move"}){let[V,q]=O7($),[B,K]=O7(()=>({tool:null,locked:!1})),U=I7((F)=>{q(F),K((Y)=>Y.locked&&Y.tool===F?Y:{tool:null,locked:!1})},[]),H=I7((F)=>{K((Y)=>{if(Y.locked&&Y.tool===F)return{tool:null,locked:!1};return{tool:F,locked:!0}}),q(F)},[]),M=I7(()=>{K({tool:null,locked:!1})},[]),[j,z]=O7("rounded");qQ(()=>{if(typeof document>"u")return;let F=Q.find((_)=>_.id===V);if(!F)return;let Y=document.body.style.cursor;document.body.style.cursor=F.cursor;let L=document.getElementById("dc-tool-cursor");if(!L)L=document.createElement("style"),L.id="dc-tool-cursor",document.head.appendChild(L);if(L.textContent=`* { cursor: ${F.cursor} !important; }`,typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:V},"*")}catch{}return()=>{document.body.style.cursor=Y;let _=document.getElementById("dc-tool-cursor");if(_)_.textContent=""}},[V,Q]);let G=BQ(()=>({tool:V,setTool:U,tools:Q,sticky:B,toggleSticky:H,clearSticky:M,shapeKind:j,setShapeKind:z}),[V,U,Q,B,H,M,j]);return T7(E7.Provider,{value:G,children:J})}function e7({children:J}){if(t7(E7))return T7(KQ,{children:J});return T7(WQ,{children:J})}function G7(){let J=t7(E7);if(!J)throw Error("useToolMode must be used inside <ToolProvider>");return J}import{jsx as NQ}from"react/jsx-runtime";var zQ=`
|
|
1
|
+
import{Component as _Q,createElement as g,Fragment as AQ,useCallback as E7,useEffect as f,useMemo as IQ,useRef as p,useState as Q7}from"react";import{createRoot as OQ}from"react-dom/client";import{useCallback as E,useEffect as S,useMemo as s,useRef as R,useState as u}from"react";function U7(){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 V7(J){if(!J)return"";return(J.getAttribute("class")??"").trim().split(/\s+/).filter((Q)=>Q&&!Q.startsWith("dgn-")&&!Q.startsWith("dc-cv-")).join(" ")}function HJ(J,Q){if(!J)return"";let $=(J.innerText||J.textContent||"").replace(/\s+/g," ").trim();return $.length>Q?`${$.slice(0,Q-1)}…`:$}function FJ(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 B=$.nodeName.toLowerCase();if($.id){B=`#${$.id}`,Q.unshift(B);break}let K=V7($).split(/\s+/).filter(Boolean).slice(0,2);if(K.length)B+=`.${K.join(".")}`;let U=1,H=$.previousElementSibling;while(H)U++,H=H.previousElementSibling;B+=`:nth-child(${U})`,Q.unshift(B),$=$.parentElement}return Q.join(" > ")}function x7(J){let Q=[],$=J;while($&&$.nodeType===1&&Q.length<8){let V=$.nodeName.toLowerCase(),q=$.getAttribute?.("data-dc-element"),B=$.getAttribute?.("data-dc-screen");if(q)V+=`[data-dc-element="${q}"]`;else if(B)V+=`[data-dc-screen="${B}"]`;else if($.id)V+=`#${$.id}`;let K=V7($).split(/\s+/).filter(Boolean).slice(0,2);if(K.length&&!q&&!B)V+=`.${K.join(".")}`;Q.unshift(V),$=$.parentElement}return Q}function DJ(J){return J.replace(/[^a-zA-Z0-9_-]/g,(Q)=>`\\${Q}`)}function C7(J,Q){return Q?`[data-dc-screen="${Q}"] [data-cd-id="${J}"]`:`[data-cd-id="${J}"]`}function v7(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 S7(J,Q,$){if(!Q||!$)return 0;return v7(J,`[data-cd-id="${DJ(Q)}"]`,$)}function X7(J,Q){let $=(V)=>{try{let q=J.querySelectorAll(V);if(!q.length)return null;let B=Q.index&&Q.index>0&&Q.index<q.length?Q.index:0;return q[B]??q[0]}catch{return null}};if(Q.id){let V=$(C7(Q.id,Q.artboardId));if(V)return V}if(Q.selector)return $(Q.selector);return null}function LJ(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 R7(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 B=(Q.classes||"").split(/\s+/).filter(Boolean),K=null,U=0;for(let H of Array.from(q.querySelectorAll("[data-cd-id]"))){if(H.tagName.toLowerCase()!==V)continue;let M=LJ(x7(H),$);if(M===0)continue;let j=V7(H).split(/\s+/).filter(Boolean),X=B.filter((F)=>j.includes(F)).length,G=M*10+X;if(G>U)U=G,K=H}return K}var b7=["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"],PJ=/^(style|class|data-cd-id|data-dc-|data-dcid$)/;function MJ(J){if(!J||typeof window>"u"||!window.getComputedStyle)return{authored:{},computed:{},customStyles:{},attrs:{}};try{let Q=J.style,$=window.getComputedStyle(J),V={},q={},B=new Set(b7);for(let G of b7){let F=Q.getPropertyValue(G);if(F)V[G]=F.trim();let Y=$.getPropertyValue(G);if(Y)q[G]=Y.trim()}let K=/^(margin|padding|border)(-|$)/,U={};for(let G=0;G<Q.length;G++){let F=Q.item(G);if(!F||B.has(F)||K.test(F))continue;let Y=Q.getPropertyValue(F);if(Y)U[F]=Y.trim()}let H={};for(let G of Array.from(J.attributes)){if(PJ.test(G.name))continue;H[G.name]=G.value}if(J.hasAttribute("data-dc-screen")){for(let G of Array.from(J.attributes))if(G.name.startsWith("data-dc-")&&G.name!=="data-dcid")H[G.name]=G.value}let M=J.parentElement,j=M?window.getComputedStyle(M).display:"",X=M&&(j==="flex"||j==="inline-flex")?window.getComputedStyle(M).flexDirection:"";return{authored:V,computed:q,customStyles:U,attrs:H,parentDisplay:j,parentFlexDirection:X}}catch{return{authored:{},computed:{},customStyles:{},attrs:{}}}}function z7(J,Q){let $=J.el,V=$&&$.getBoundingClientRect?$.getBoundingClientRect():null,q=J.cdId,B=q?C7(q,J.artboardId):J.artboardId?`[data-dc-screen="${J.artboardId}"]`:FJ($),K=q&&typeof document<"u"?v7(document,B,$):0;return{file:Q??U7(),id:q??void 0,selector:B,artboardId:J.artboardId,index:K,tag:$?.tagName.toLowerCase()??"",classes:V7($),text:HJ($,240),dom_path:x7($),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 U=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,H=$.getAttribute?.("data-photo-asset");if(H&&U.test(H))return{photoKind:"artboard-img",photoAsset:H};let M=$.getAttribute?.("src")||"",j=U.exec(M);return j?{photoKind:"artboard-img",photoAsset:j[0]}:{}})(),...MJ($)}}import*as Y7 from"lib0/decoding";import*as a from"lib0/encoding";import{createContext as jJ,useCallback as hQ,useContext as NJ,useEffect as fQ,useMemo as pQ,useReducer as uQ,useRef as mQ,useState as dQ}from"react";import{Awareness as cQ,applyAwarenessUpdate as lQ,encodeAwarenessUpdate as rQ}from"y-protocols/awareness";import{readSyncMessage as oQ,writeSyncStep1 as aQ,writeUpdate as sQ}from"y-protocols/sync";import*as _J from"yjs";import{jsx as eQ}from"react/jsx-runtime";var AJ=jJ(null);function g7(){return NJ(AJ)}import{createContext as IJ,useCallback as l,useContext as F7,useEffect as OJ,useMemo as TJ,useRef as EJ,useState as kJ}from"react";import{jsx as H7,Fragment as bJ}from"react/jsx-runtime";var Z7=IJ(null);function r(J){return J.id?`id:${J.id}`:`sel:${J.selector}`}function h7(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 wJ=50;function yJ({children:J,postTarget:Q}){let[$,V]=kJ([]),q=EJ(null),B=l((G)=>{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=G.length===0?null:G.length===1?G[0]??null:G;try{F.postMessage({dgn:"select-set",selection:Y},"*")}catch{}},wJ)},[Q]);OJ(()=>()=>{if(q.current)clearTimeout(q.current)},[]);let K=l((G)=>{let F=h7(Array.isArray(G)?G:[G]);V(F),B(F)},[B]),U=l((G)=>{let F=Array.isArray(G)?G:[G];V((Y)=>{let L=h7([...Y,...F]);return B(L),L})},[B]),H=l((G)=>{let F=r(G);V((Y)=>{let L=Y.filter((_)=>r(_)!==F);return B(L),L})},[B]),M=l((G)=>{let F=r(G);V((Y)=>{let L=Y.some((_)=>r(_)===F)?Y.filter((_)=>r(_)!==F):[...Y,G];return B(L),L})},[B]),j=l(()=>{V([]),B([])},[B]),X=TJ(()=>({selected:$,replace:K,add:U,remove:H,toggle:M,clear:j}),[$,K,U,H,M,j]);return H7(Z7.Provider,{value:X,children:J})}function f7({children:J}){if(F7(Z7))return H7(bJ,{children:J});return H7(yJ,{children:J})}function q7(){let J=F7(Z7);if(!J)throw Error("useSelectionSet must be used inside <SelectionSetProvider>");return J}function p7(){return F7(Z7)}import{jsx as O,jsxs as b}from"react/jsx-runtime";var xJ="/_client/comments-overlay.css";function CJ(){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=xJ,document.head.appendChild(J)}function vJ(){if(typeof window>"u")return null;try{let J=window.location.pathname;if(J==="/_canvas-shell.html"||J==="/_canvas-shell"){let Q=new URLSearchParams(window.location.search),$=Q.get("canvas")??"",V=(Q.get("designRel")??".design").replace(/^\/+|\/+$/g,"");return $?`${V}/${$}`:null}return decodeURIComponent(J).replace(/^\//,"")}catch{return null}}function SJ(J){if(!J.selector)return null;let Q=null;try{let $=document.querySelectorAll(J.selector),V=J.index&&J.index>0&&J.index<$.length?J.index:0;Q=$[V]??$[0]??null}catch{Q=null}if(Q&&J.tag&&Q.tagName.toLowerCase()!==J.tag.toLowerCase())Q=null;if(!Q&&J.dom_path?.length){let $=J.selector.match(/data-dc-screen="([^"]+)"/)?.[1];Q=R7(document,{artboardId:$,tag:J.tag,classes:J.classes,dom_path:J.dom_path})}return Q}function L7(J){let Q=SJ(J);if(!Q?.isConnected)return null;let $=Q.getBoundingClientRect();if($.width===0&&$.height===0)return null;return{x:$.left,y:$.top,w:$.width,h:$.height}}function i7(J,Q){let V=typeof window<"u"?window.innerWidth:J.x+Q.w,q=typeof window<"u"?window.innerHeight:J.y+Q.h,B=J.x;if(B+Q.w+8>V){let U=J.x-Q.w;B=U>=8?U:Math.max(8,V-Q.w-8)}let K=J.y;if(K+Q.h+8>q){let U=J.y-Q.h;K=U>=8?U:Math.max(8,q-Q.h-8)}return{x:B,y:K}}function c7(){CJ();let J=p7(),[Q,$]=u([]),[V,q]=u(null),[B,K]=u(null),U=s(()=>vJ(),[]);S(()=>{if(typeof document>"u")return;let W=document.getElementById("dgn-pin-layer");if(!W)return;let D=W.style.display;return W.style.display="none",()=>{W.style.display=D}},[]);let H=E((W)=>{if(!J)return;if(!W?.selector){J.clear();return}let D=W.selector.match(/data-cd-id="([^"]+)"/),N=D?D[1]:void 0,A,I;try{let P=document.querySelector(W.selector);if(P)A=P.tagName.toLowerCase(),I=(P.getAttribute("class")??"").split(/\s+/).filter((T)=>T&&!T.startsWith("dgn-")&&!T.startsWith("dc-cv-")).join(" ")}catch{}J.replace({file:U??void 0,id:N,selector:W.selector,tag:A,classes:I,bounds:W.bounds??void 0})},[J,U]),M=R(Q);M.current=Q;let j=g7();S(()=>{if(!j)return;let W=j.doc.getArray("comments"),D=()=>{$(W.toArray())};if(W.length>0)D();return W.observe(D),()=>{try{W.unobserve(D)}catch{}}},[j]),S(()=>{if(typeof window>"u")return;let W=(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?M.current.find((P)=>P.id===A):void 0;H(I)}};return window.addEventListener("message",W),()=>window.removeEventListener("message",W)},[H]),S(()=>{if(typeof document>"u")return;let W=(D)=>{let N=D.detail;if(!N?.selection)return;K({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",W),()=>document.removeEventListener("cm:open-composer",W)},[]);let X=E(()=>{if(K(null),typeof window>"u")return;try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},[]),G=E((W)=>{if(!B)return;let D=B.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:W};if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-submit",payload:N},"*")}catch{}X()},[B,X]);S(()=>{if(!U)return;let W=!1;return(async()=>{try{let D=await fetch(`/_comments?file=${encodeURIComponent(U)}`);if(!D.ok)return;let N=await D.json();if(W)return;if(Array.isArray(N.comments))$((A)=>A.length===0?N.comments??[]:A)}catch{}})(),()=>{W=!0}},[U]);let F=s(()=>{return Q.slice().sort((D,N)=>D.created.localeCompare(N.created)).filter((D)=>D.status!=="resolved")},[Q]),Y=s(()=>{let W=new Map;return Q.slice().sort((N,A)=>N.created.localeCompare(A.created)).forEach((N,A)=>{W.set(N.id,A+1)}),W},[Q]),L=E((W)=>{if(q(W),H(Q.find((D)=>D.id===W)),typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-click",id:W},"*")}catch{}},[Q,H]),_=E((W,D)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-patch",id:W,patch:D},"*")}catch{}},[]),Z=E((W)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-delete",id:W},"*")}catch{}q((D)=>D===W?null:D)},[]),z=E(async(W,D)=>{if(typeof fetch>"u")return!1;try{let N=await fetch(`/_api/comments/${encodeURIComponent(W)}/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((P)=>P.id===A.id?A:P)),!0}catch{return!1}},[]);return b("div",{className:"cm-layer","aria-hidden":!1,children:[F.map((W)=>{let D=Y.get(W.id)??0;return O(fJ,{comment:W,sequence:D,focused:V===W.id,onClick:L,onOrphaned:Z},W.id)}),B?O(pJ,{state:B,onSubmit:G,onCancel:X}):null,(()=>{if(!V)return null;let W=F.find((D)=>D.id===V);if(!W)return null;return O(uJ,{comment:W,sequence:Y.get(W.id)??0,onClose:()=>{q(null),J?.clear()},onPatch:(D)=>_(W.id,D),onDelete:()=>Z(W.id),onReply:(D)=>z(W.id,D)})})()]})}var D7=null;async function RJ(){if(!D7)D7=(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 D7}function u7(J){return(J.trim().split(/\s+/)[0]??"").replace(/[^\w.-]/g,"").toLowerCase()}function gJ(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 B=J.slice($+1,Q);return{start:$,end:Q,query:B}}return null}if(!/[\w.-]/.test(V))return null;$-=1}return null}function l7({className:J,value:Q,onChange:$,onKeyDown:V,placeholder:q,rows:B,disabled:K,textareaRef:U,ariaLabel:H}){let M=R(null),j=E((P)=>{if(M.current=P,U)U.current=P},[U]),[X,G]=u([]),[F,Y]=u(null),[L,_]=u(0),Z=E(()=>{if(X.length>0)return;RJ().then((P)=>G(P))},[X.length]),z=s(()=>{if(!F)return[];let P=F.query.toLowerCase();return(!P?X:X.filter((k)=>k.name.toLowerCase().includes(P)||k.email.toLowerCase().includes(P))).slice(0,8)},[F,X]),W=E((P)=>{let T=P.selectionStart??P.value.length,k=gJ(P.value,T);Y(k),_(0)},[]),D=E((P)=>{$(P.target.value),W(P.target)},[$,W]),N=E((P)=>{if(!F)return;let T=M.current;if(!T)return;let k=`@${u7(P.name)}`,x=`${Q.slice(0,F.start)}${k} ${Q.slice(F.end)}`;$(x),Y(null);let w=F.start+k.length+1;requestAnimationFrame(()=>{T.focus(),T.setSelectionRange(w,w)})},[F,Q,$]),A=E((P)=>{if(F&&z.length>0){if(P.key==="ArrowDown"){P.preventDefault(),_((T)=>(T+1)%z.length);return}if(P.key==="ArrowUp"){P.preventDefault(),_((T)=>(T-1+z.length)%z.length);return}if(P.key==="Enter"||P.key==="Tab"){P.preventDefault();let T=z[L]??z[0];if(T)N(T);return}if(P.key==="Escape"){P.preventDefault(),Y(null);return}}V?.(P)},[F,z,L,N,V]),I=E((P)=>{W(P.currentTarget)},[W]);return b("div",{style:{position:"relative"},children:[O("textarea",{ref:j,className:J,value:Q,placeholder:q,rows:B,disabled:K,"aria-label":H,onChange:D,onKeyDown:A,onFocus:Z,onSelect:I,onClick:I}),F&&z.length>0?O("ul",{className:"cm-mention-popup",role:"listbox","aria-label":"Mention suggestions",style:{left:0,top:"100%"},children:z.map((P,T)=>{return b("li",{role:"option","aria-selected":T===L,className:"cm-mention-popup__item",onMouseEnter:()=>_(T),onMouseDown:(x)=>{x.preventDefault(),N(P)},children:[b("span",{className:"cm-mention-popup__name",children:["@",u7(P.name)]}),O("span",{className:"cm-mention-popup__email",children:P.email})]},`${P.name}-${P.email}`)})}):null]})}var hJ=3000;function fJ({comment:J,sequence:Q,focused:$,onClick:V,onOrphaned:q}){let B=R(null),K=R(null),U=R(null);S(()=>{let j=()=>{K.current=null;let X=B.current;if(!X)return;let G=L7(J);if(G)U.current=null;else{if(U.current==null)U.current=Date.now();else if(Date.now()-U.current>hJ)q(J.id);if(J.bounds)G={x:J.bounds.x,y:J.bounds.y,w:J.bounds.w,h:J.bounds.h}}if(!G){X.style.display="none",K.current=requestAnimationFrame(j);return}X.style.display="grid";let F=Math.round(G.x+G.w-12),Y=Math.round(G.y-12);X.style.left=`${F}px`,X.style.top=`${Y}px`,K.current=requestAnimationFrame(j)};return K.current=requestAnimationFrame(j),()=>{if(K.current!=null)cancelAnimationFrame(K.current)}},[J,q]);let H=J.author?.trim()||"unknown",M=`Comment ${Q} by ${H}`;return O("button",{ref:B,type:"button",className:"cm-pin","data-resolved":J.status==="resolved"?"true":"false","data-focused":$?"true":"false","data-comment-pin":J.id,"aria-label":M,"aria-expanded":$,title:J.text.slice(0,200),onClick:(j)=>{j.preventDefault(),j.stopPropagation(),V(J.id)},children:Q})}function pJ({state:J,onSubmit:Q,onCancel:$}){let[V,q]=u(""),B=R(null),K=R(null),U=R(null);S(()=>{let X=()=>{U.current=null;let G=K.current;if(!G)return;let F=iJ(J),Y=i7(F,{w:G.offsetWidth,h:G.offsetHeight});G.style.left=`${Math.round(Y.x)}px`,G.style.top=`${Math.round(Y.y)}px`,U.current=requestAnimationFrame(X)};return U.current=requestAnimationFrame(X),()=>{if(U.current!=null)cancelAnimationFrame(U.current)}},[J]),S(()=>{B.current?.focus()},[]);let H=E(()=>{let X=V.trim();if(!X)return;Q(X)},[V,Q]),M=E((X)=>{if(X.key==="Escape"){X.preventDefault(),$();return}if((X.metaKey||X.ctrlKey)&&X.key==="Enter")X.preventDefault(),H()},[$,H]),j=s(()=>{let X=J.selection.selector||"";if(!X)return J.selection.tag||"canvas";let G=X.match(/data-cd-id="([^"]+)"/);if(G)return`cd:${G[1]}`;return X.length>36?`${X.slice(0,33)}…`:X},[J.selection]);return b("div",{ref:K,className:"cm-composer",role:"dialog","aria-label":"New comment",onClick:(X)=>X.stopPropagation(),onPointerDown:(X)=>X.stopPropagation(),children:[b("div",{className:"cm-composer__head",children:[O("span",{children:"New comment"}),O("span",{className:"cm-composer__selector",children:j})]}),O(l7,{textareaRef:B,className:"cm-composer__textarea",value:V,placeholder:"Type a comment. ⌘↵ to save · Esc to cancel · @name to tag",onChange:q,onKeyDown:M,rows:3,ariaLabel:"Comment body"}),b("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 uJ({comment:J,sequence:Q,onClose:$,onPatch:V,onDelete:q,onReply:B}){let K=R(null),U=R(null),H=R(null),[M,j]=u(""),[X,G]=u(!1);S(()=>{let Z=()=>{H.current=null;let z=K.current;if(!z)return;let W=dJ(J),D=i7(W,{w:z.offsetWidth,h:z.offsetHeight});z.style.left=`${Math.round(D.x)}px`,z.style.top=`${Math.round(D.y)}px`,H.current=requestAnimationFrame(Z)};return H.current=requestAnimationFrame(Z),()=>{if(H.current!=null)cancelAnimationFrame(H.current)}},[J]),S(()=>{K.current?.focus();let Z=J.id;return()=>{document.querySelector(`[data-comment-pin="${Z}"]`)?.focus()}},[J.id]),S(()=>{if(typeof document>"u")return;let Z=(z)=>{if(z.key!=="Escape")return;let W=K.current;if(!W)return;if(W.contains(z.target)||document.activeElement===W)z.preventDefault(),$()};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[$]);let F=E(async()=>{let Z=M.trim();if(!Z||X)return;G(!0);let z=await B(Z);if(G(!1),z)j(""),U.current?.focus()},[M,X,B]),Y=E((Z)=>{if((Z.metaKey||Z.ctrlKey)&&Z.key==="Enter")Z.preventDefault(),F()},[F]),L=`cm-thread-head-${J.id}`,_=mJ(J.selector,"");return b("div",{ref:K,className:"cm-thread",role:"dialog","aria-labelledby":L,tabIndex:-1,onClick:(Z)=>Z.stopPropagation(),onPointerDown:(Z)=>Z.stopPropagation(),children:[b("div",{className:"cm-thread__head",id:L,children:[b("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:d7(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:m7(J.text)}),(J.thread??[]).map((Z)=>b("div",{className:"cm-thread__reply",children:[b("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:d7(Z.created)})]}),O("div",{className:"cm-thread__reply-body",children:m7(Z.body)})]},Z.id)),b("div",{className:"cm-thread__reply-form",children:[O(l7,{textareaRef:U,className:"cm-thread__reply-textarea",value:M,placeholder:"Reply… ⌘↵ to send · @name to tag",onChange:j,onKeyDown:Y,rows:2,ariaLabel:"Reply",disabled:X}),O("div",{className:"cm-thread__reply-actions",children:O("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!M.trim()||X,onClick:()=>void F(),children:"Send"})})]}),b("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 m7(J){if(!J)return null;let Q=/(@[\w][\w.-]*)/g;return J.split(Q).map((V,q)=>{let B=`${q}:${V}`;if(q%2===1)return O("strong",{"data-mention":"true",children:V},B);return O("span",{children:V},B)})}function d7(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 mJ(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 dJ(J){let Q=J.selector?L7(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 iJ(J){if(J.clientX||J.clientY)return{x:J.clientX,y:J.clientY+8};if(J.selection.selector){let Q=L7(J.selection);if(Q)return{x:Q.x,y:Q.y+Q.h+8}}return{x:16,y:16}}import{useEffect as cJ}from"react";var lJ=new Set(["pen","highlighter","shape","rect","ellipse","arrow","sticky","text","section","eraser"]);function r7(J){return lJ.has(J)}var P7=(J)=>!!(J.metaKey||J.ctrlKey);function t(J){if(J.type==="keydown"){if(J.isEditable)return{kind:"no-op"};if(J.metaKey||J.ctrlKey||J.altKey){if(J.key==="Escape")return{kind:"escape"};let $=(J.key||"").toLowerCase();if(!J.altKey&&(J.metaKey||J.ctrlKey)){if($==="z"&&J.shiftKey)return{kind:"redo"};if($==="z")return{kind:"undo"};if($==="y"&&!J.shiftKey)return{kind:"redo"}}return{kind:"no-op"}}let Q=(J.key||"").toLowerCase();if(Q==="v")return{kind:"tool",tool:"move"};if(Q==="h")return{kind:"tool",tool:"hand"};if(Q==="c")return{kind:"tool",tool:"comment"};if(Q==="b")return{kind:"tool",tool:"pen"};if(Q==="i")return{kind:"tool",tool:"highlighter"};if(Q==="r"||Q==="o")return{kind:"tool",tool:"shape"};if(Q==="a")return{kind:"tool",tool:"arrow"};if(Q==="n")return{kind:"tool",tool:"sticky"};if(Q==="t")return{kind:"tool",tool:"text"};if(Q==="s"&&J.shiftKey)return{kind:"tool",tool:"section"};if(Q==="e")return{kind:"tool",tool:"eraser"};if(J.key==="Escape")return{kind:"escape"};return{kind:"no-op"}}if(J.type==="contextmenu")return{kind:"context-menu",clientX:J.clientX??0,clientY:J.clientY??0};if(J.type==="pointermove"){if(r7(J.activeTool))return{kind:"no-op"};if(J.activeTool==="hand")return{kind:"no-op"};if(J.activeTool==="comment")return{kind:"hover",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0};if(!P7(J))return{kind:"no-op"};return{kind:"hover",deep:!0,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(r7(J.activeTool)&&!P7(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(!P7(J))return{kind:"no-op"};return{kind:"select",mode:!!J.shiftKey?"add":"replace",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0}}return{kind:"no-op"}}function rJ(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 e(J){if(!J||!J.closest)return!1;return!!J.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mediaref-player]")}function n7(J){let{hostRef:Q,getActiveTool:$,isSpaceHeld:V,callbacks:q,enabled:B=!0,claimableActions:K}=J;cJ(()=>{if(!B)return;let U=Q.current;if(!U)return;let H=(Z)=>K&&Z.kind!=="no-op"&&!K.has(Z.kind)?{kind:"no-op"}:Z,M=(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}},j=(Z)=>{let z=H(t({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:$()}));M(z)},X=(Z)=>{if(e(Z.target))return;let z=H(t({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(z.kind!=="no-op")Z.preventDefault(),Z.stopImmediatePropagation();M(z)},G=(Z)=>{if(e(Z.target))return;let z=H(t({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(z.kind!=="no-op"){if(Z.preventDefault(),Z.stopImmediatePropagation(),z.kind==="select")try{window.focus()}catch{}}},F=(Z)=>{if(e(Z.target))return;let z=$(),W=Z.metaKey||Z.ctrlKey,D=z==="comment"?"drop-comment":z==="move"&&W&&Z.button===0?"select":Z.button===2?"context-menu":null;if(D&&(!K||K.has(D)))Z.preventDefault(),Z.stopImmediatePropagation()},Y=(Z)=>{let z=H(t({type:"contextmenu",clientX:Z.clientX,clientY:Z.clientY,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,activeTool:$()}));if(z.kind==="no-op")return;Z.preventDefault(),Z.stopImmediatePropagation(),M(z)},L=(Z)=>{let z=H(t({type:"keydown",key:Z.key,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,isEditable:rJ(Z.target),activeTool:$()}));if(z.kind==="tool"||z.kind==="escape"||z.kind==="undo"||z.kind==="redo")Z.preventDefault();M(z)};U.addEventListener("pointermove",j,{passive:!0}),U.addEventListener("pointerdown",X,{capture:!0}),U.addEventListener("mousedown",G,{capture:!0}),U.addEventListener("click",F,{capture:!0}),U.addEventListener("contextmenu",Y,{capture:!0});let _=U.ownerDocument??document;return _.addEventListener("keydown",L,!0),()=>{U.removeEventListener("pointermove",j),U.removeEventListener("pointerdown",X,{capture:!0}),U.removeEventListener("mousedown",G,{capture:!0}),U.removeEventListener("click",F,{capture:!0}),U.removeEventListener("contextmenu",Y,{capture:!0}),_.removeEventListener("keydown",L,!0)}},[B,Q,$,V,q,K])}function M7(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 B=q.closest?.("[data-dc-screen]")??null,K=B?.getAttribute("data-dc-screen")??null,U=q.closest?.(".dc-artboard-body")??null;if(!U){if(B&&K)return{el:B,cdId:null,artboardId:K};return null}if(q===U){if(B&&K)return{el:B,cdId:null,artboardId:K};return null}if(V.deep){let G=q.getAttribute?.("data-cd-id")??null;return{el:q,cdId:G,artboardId:K}}let H=q,M=null;while(H&&H!==U){if(H.hasAttribute?.("data-cd-id"))M=H;H=H.parentElement}let j=M??q,X=j.getAttribute?.("data-cd-id")??null;return{el:j,cdId:X,artboardId:K}}import{useCallback as KQ,useEffect as e7,useRef as G7}from"react";var nJ=!1;function o7(){return nJ}import{createContext as VQ,useCallback as A7,useContext as s7,useEffect as ZQ,useMemo as qQ,useState as I7}from"react";function m(J,Q,$,V){return`url("data:image/svg+xml,${encodeURIComponent(J.trim())}") ${Q} ${$}, ${V}`}var N7="width='24' height='24' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'",_7="#1f1f1f",j7="stroke='#ffffff' stroke-linejoin='round' stroke-linecap='round'";function i(J,Q,$){let V=$?`<g transform='${$}'>`:"";return`<svg ${N7}>${V}<path fill='#ffffff' d='${J}'/><path fill='${_7}' d='${Q}'/>${$?"</g>":""}</svg>`}var a7="translate(0,32) scale(1,-1)",oJ=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"),aJ=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"),sJ=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"),tJ=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",a7),6,18,"crosshair"),eJ=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",a7),6,18,"crosshair"),J7=m(i("M17 2 Q18.2 2 19.15 2.9 20 3.8 20 5 L20 12 27 12 Q28.2 12 29.15 12.9 30 13.8 30 15 L30 17 Q30 18.2 29.15 19.15 28.2 20 27 20 L20 20 20 27 Q20 28.2 19.15 29.15 18.2 30 17 30 L15 30 Q13.8 30 12.9 29.15 12 28.2 12 27 L12 20 5 20 Q3.8 20 2.9 19.15 2 18.2 2 17 L2 15 Q2 13.8 2.9 12.9 3.8 12 5 12 L12 12 12 5 Q12 3.8 12.9 2.9 13.8 2 15 2 L17 2 M14 27 L14.3 27.7 Q14.6 28 15 28 L17 28 17.7 27.7 18 27 18 18.05 18.05 18 27 18 Q27.4 18 27.7 17.7 L28 17 28 15 27.7 14.3 Q27.4 14 27 14 L18 14 18 5 17.7 4.3 17 4 15 4 Q14.6 4 14.3 4.3 14 4.6 14 5 L14 14 5 14 Q4.6 14 4.3 14.3 4 14.6 4 15 L4 17 Q4 17.4 4.3 17.7 4.6 18 5 18 L14 18 14 27","M14 27 L14 18 5 18 Q4.6 18 4.3 17.7 4 17.4 4 17 L4 15 Q4 14.6 4.3 14.3 4.6 14 5 14 L14 14 14 5 Q14 4.6 14.3 4.3 14.6 4 15 4 L17 4 17.7 4.3 18 5 18 14 27 14 Q27.4 14 27.7 14.3 L28 15 28 17 27.7 17.7 Q27.4 18 27 18 L18.05 18 18 18.05 18 27 17.7 27.7 17 28 15 28 Q14.6 28 14.3 27.7 L14 27"),12,12,"crosshair"),JQ=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"),QQ=m(`<svg ${N7}><path d='M16 4V28M11 4H21M11 28H21' fill='none' ${j7} stroke-width='5'/><path d='M16 4V28M11 4H21M11 28H21' fill='none' stroke='${_7}' stroke-width='2.25' stroke-linecap='round'/></svg>`,12,12,"text"),$Q=m(`<svg ${N7}><path d='M6 5H21L26 10V27H6Z' fill='${_7}' ${j7} stroke-width='2.5'/><path d='M21 5V11H26' fill='none' ${j7} stroke-width='2.25'/></svg>`,5,5,"crosshair"),v=Object.freeze({move:oJ,hand:aJ,comment:sJ,pen:tJ,section:J7,highlighter:eJ,shape:J7,rect:J7,ellipse:J7,sticky:$Q,arrow:J7,text:QQ,eraser:JQ});import{jsx as O7,Fragment as WQ}from"react/jsx-runtime";var BQ=Object.freeze([{id:"move",label:"Move",shortcut:"V",cursor:v.move},{id:"hand",label:"Hand",shortcut:"H",cursor:v.hand},{id:"comment",label:"Comment",shortcut:"C",cursor:v.comment},{id:"pen",label:"Pen",shortcut:"B",cursor:v.pen},{id:"highlighter",label:"Highlighter",shortcut:"I",cursor:v.highlighter},{id:"shape",label:"Shape",shortcut:"R",cursor:v.shape},{id:"sticky",label:"Sticky",shortcut:"N",cursor:v.sticky},{id:"section",label:"Section",shortcut:"⇧S",cursor:v.shape},{id:"arrow",label:"Arrow",shortcut:"A",cursor:v.arrow},{id:"text",label:"Text",shortcut:"T",cursor:v.text},{id:"eraser",label:"Eraser",shortcut:"E",cursor:v.eraser}]),T7=VQ(null);function GQ({children:J,tools:Q=BQ,initial:$="move"}){let[V,q]=I7($),[B,K]=I7(()=>({tool:null,locked:!1})),U=A7((F)=>{q(F),K((Y)=>Y.locked&&Y.tool===F?Y:{tool:null,locked:!1})},[]),H=A7((F)=>{K((Y)=>{if(Y.locked&&Y.tool===F)return{tool:null,locked:!1};return{tool:F,locked:!0}}),q(F)},[]),M=A7(()=>{K({tool:null,locked:!1})},[]),[j,X]=I7("rounded");ZQ(()=>{if(typeof document>"u")return;let F=Q.find((_)=>_.id===V);if(!F)return;let Y=document.body.style.cursor;document.body.style.cursor=F.cursor;let L=document.getElementById("dc-tool-cursor");if(!L)L=document.createElement("style"),L.id="dc-tool-cursor",document.head.appendChild(L);if(L.textContent=`* { cursor: ${F.cursor} !important; }`,typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:V},"*")}catch{}return()=>{document.body.style.cursor=Y;let _=document.getElementById("dc-tool-cursor");if(_)_.textContent=""}},[V,Q]);let G=qQ(()=>({tool:V,setTool:U,tools:Q,sticky:B,toggleSticky:H,clearSticky:M,shapeKind:j,setShapeKind:X}),[V,U,Q,B,H,M,j]);return O7(T7.Provider,{value:G,children:J})}function t7({children:J}){if(s7(T7))return O7(WQ,{children:J});return O7(GQ,{children:J})}function B7(){let J=s7(T7);if(!J)throw Error("useToolMode must be used inside <ToolProvider>");return J}import{jsx as NQ}from"react/jsx-runtime";var UQ=`
|
|
2
2
|
.dc-el-resize-handle {
|
|
3
3
|
position: fixed;
|
|
4
4
|
width: 8px;
|
|
@@ -56,4 +56,4 @@ import{Component as _Q,createElement as h,Fragment as AQ,useCallback as k7,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 XQ(){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=zQ,document.head.appendChild(J)}var YQ=["nw","n","ne","e","se","s","sw","w"];function HQ(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,K7=1;function FQ(J,Q,$,V,q,B){let{movesLeft:K,movesRight:U,movesTop:H,movesBottom:M}=HQ(J),j=q.center,z=Q.w,G=Q.h;if(U)z=Q.w+(j?2*$:$);else if(K)z=Q.w-(j?2*$:$);if(M)G=Q.h+(j?2*V:V);else if(H)G=Q.h-(j?2*V:V);if(q.aspect&&Q.w>0&&Q.h>0){let Y=Q.w/Q.h;if((K||U)&&(H||M)){let _=Math.abs(z-Q.w)/Q.w,Z=Math.abs(G-Q.h)/Q.h;if(_>=Z)G=z/Y;else z=G*Y}else if(K||U)G=z/Y;else if(H||M)z=G*Y}if(z<K7)z=K7;if(G<K7)G=K7;let F={width:n(z),height:n(G)};if(j){if(B.canMoveLeft&&(K||U))F.left=n(Q.left+(Q.w-z)/2);if(B.canMoveTop&&(H||M))F.top=n(Q.top+(Q.h-G)/2)}else{if(B.canMoveLeft&&K)F.left=n(Q.left+Q.w-z);if(B.canMoveTop&&H)F.top=n(Q.top+Q.h-G)}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 DQ(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,B=Math.hypot(V,q);return B>0?B:1}function $J(J,Q,$){let V=$*Math.PI/180,q=Math.cos(V),B=Math.sin(V);return[J*q-Q*B,J*B+Q*q]}function VJ(J,Q,$,V){return Math.atan2(V-Q,$-J)}function LQ(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 PQ(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 MQ(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 jQ(J,Q){try{window.parent.postMessage({dgn:"resize-request",id:J.cdId,patch:{transform:Q},before:J.before,idIndex:J.idIndex},"*")}catch{}}function ZJ(){XQ();let{selected:J}=B7(),{tool:Q}=G7(),$=W7(null),V=W7(null),q=W7(null),B=W7(null),K=J.length===1?J[0]:null,U=K&&typeof K.id==="string"?K.id:null,H=K&&!U&&typeof K.artboardId==="string"?K.artboardId:null,M=Q==="move"&&(!!U||!!H);JJ(()=>{let z=$.current;if(!z)return;let G=()=>{for(let Y of Array.from(z.children)){let L=Y;L.style.opacity="0",L.style.pointerEvents="none"}};if(!M||!K){G();return}let F=()=>{if(V.current=null,a7()){G(),V.current=requestAnimationFrame(F);return}let Y=X7(document,K);if(!Y){G(),V.current=requestAnimationFrame(F);return}let L=Y.getBoundingClientRect();if(L.width<=0&&L.height<=0){G(),V.current=requestAnimationFrame(F);return}let _=H?["e","s","se"]:YQ,Z=H?[]:["rot-nw","rot-ne","rot-sw","rot-se"],X=_.length+Z.length+1;while(z.children.length<X)z.appendChild(document.createElement("div"));while(z.children.length>X)z.lastChild&&z.removeChild(z.lastChild);let W=L.left+L.width/2,D=L.top+L.height/2,N=QJ(getComputedStyle(Y).transform),A=Y.closest(".dc-world"),T=A?DQ(getComputedStyle(A).transform):1,P=Y.offsetWidth*T/2,I=Y.offsetHeight*T/2,w={nw:[-P,-I],n:[0,-I],ne:[P,-I],e:[P,0],se:[P,I],s:[0,I],sw:[-P,I],w:[-P,0],"rot-nw":[-P,-I],"rot-ne":[P,-I],"rot-sw":[-P,I],"rot-se":[P,I]},f=[...Z,..._];for(let C=0;C<f.length;C++){let v=f[C],b=z.children[C],[c,V7]=w[v]??[0,0],[KJ,UJ]=$J(c,V7,N),zJ=W+KJ,XJ=D+UJ,U7=v.startsWith("rot-"),y7=v==="n"||v==="s",b7=v==="e"||v==="w",YJ=U7?10:y7?7:b7?3:4,HJ=U7?10:y7?3:b7?7:4;b.className="dc-el-resize-handle",b.dataset.corner=v,b.style.opacity="1",b.style.pointerEvents="auto",b.style.left=`${Math.round(zJ-YJ)}px`,b.style.top=`${Math.round(XJ-HJ)}px`,b.style.transform=U7?"":`rotate(${N}deg)`}let x=z.children[f.length],y=q.current;if(y&&y.el===Y&&!y.corner.startsWith("rot-")){let C=y.lastResult?.width??Y.offsetWidth,v=y.lastResult?.height??Y.offsetHeight,b=`${Math.round(C)} × ${Math.round(v)}`,c=y.lastResult?.left,V7=y.lastResult?.top;if(typeof c==="number"||typeof V7==="number")b+=` · ${Math.round(c??y.start.left)}, ${Math.round(V7??y.start.top)}`;x.className="dc-el-resize-readout",x.textContent=b,x.style.opacity="1",x.style.left=`${Math.round(W)}px`,x.style.top=`${Math.round(D+I)}px`}else x.style.opacity="0";V.current=requestAnimationFrame(F)};return V.current=requestAnimationFrame(F),()=>{if(V.current!=null)cancelAnimationFrame(V.current)}},[M,K,H]);let j=UQ((z,G)=>{if(z.el.style.width=`${G.width}px`,z.el.style.height=`${G.height}px`,typeof G.left==="number")z.el.style.left=`${G.left}px`;if(typeof G.top==="number")z.el.style.top=`${G.top}px`;z.lastResult=G},[]);return JJ(()=>{let z=$.current;if(!z)return;let G=(Z,X)=>{let[W,D]=$J(X.clientX-Z.startClientX,X.clientY-Z.startClientY,-Z.angle);return FQ(Z.corner,Z.start,W/Z.elZoom,D/Z.elZoom,{aspect:!!X.shiftKey,center:!Z.artboardId&&!!X.altKey},Z.flags)},F=(Z)=>{let X=Z.target;if(!X?.classList.contains("dc-el-resize-handle"))return;let W=X.dataset.corner;if(!W||!K)return;let D=typeof K.id==="string"?K.id:null,N=!D&&typeof K.artboardId==="string"?K.artboardId:null;if(!D&&!N)return;let A=X7(document,K);if(!A)return;Z.preventDefault(),Z.stopPropagation();let T=A.getBoundingClientRect(),P=A.offsetWidth?T.width/A.offsetWidth:1,I=getComputedStyle(A),w=!N&&(I.position==="absolute"||I.position==="fixed"),f=N?Number.NaN:Number.parseFloat(A.style.left),x=N?Number.NaN:Number.parseFloat(A.style.top),y=N?0:QJ(I.transform),C=P>0?P:1,v=T.left+T.width/2,b=T.top+T.height/2,c={pointerId:Z.pointerId,corner:W,el:A,cdId:D??"",artboardId:N,idIndex:D?R7(document,D,A):0,startClientX:Z.clientX,startClientY:Z.clientY,elZoom:C,angle:y,cx:v,cy:b,rotStartPointer:VJ(v,b,Z.clientX,Z.clientY),start:{w:(y?A.offsetWidth:T.width/C)||T.width/C,h:(y?A.offsetHeight:T.height/C)||T.height/C,left:f,top:x},flags:{canMoveLeft:w&&Number.isFinite(f),canMoveTop:w&&Number.isFinite(x)},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(Z.pointerId)}catch{}},Y=(Z)=>{let X=q.current;if(!X||Z.pointerId!==X.pointerId)return;if(Z.preventDefault(),X.corner.startsWith("rot-")){let D=`rotate(${LQ(X.angle,X.rotStartPointer,VJ(X.cx,X.cy,Z.clientX,Z.clientY),!!Z.shiftKey)}deg)`;X.el.style.transform=D,X.lastTransform=D;return}j(X,G(X,Z))},L=(Z)=>{let X=q.current;if(!X||Z.pointerId!==X.pointerId)return;if(q.current=null,X.corner.startsWith("rot-")){let N=X.lastTransform;if(!N||N===X.before.transform)return;B.current={el:X.el,before:X.before},jQ(X,N);return}let W=X.lastResult??G(X,Z);if(!(`${W.width}px`!==X.before.width||`${W.height}px`!==X.before.height||typeof W.left==="number"&&`${W.left}px`!==X.before.left||typeof W.top==="number"&&`${W.top}px`!==X.before.top))return;if(B.current={el:X.el,before:X.before},X.artboardId)MQ(X,W);else PQ(X,W)},_=(Z)=>{let X=Z.data;if(X?.dgn!=="resize-failed"&&X?.dgn!=="resize-artboard-failed")return;if(Z.source!==window.parent)return;let W=B.current;if(!W)return;if(W.el.style.width=W.before.width??"",W.el.style.height=W.before.height??"",W.before.left!==null||W.el.style.left)W.el.style.left=W.before.left??"";if(W.before.top!==null||W.el.style.top)W.el.style.top=W.before.top??"";if(W.before.transform!==null||W.el.style.transform)W.el.style.transform=W.before.transform??"";B.current=null};return z.addEventListener("pointerdown",F),window.addEventListener("pointermove",Y),window.addEventListener("pointerup",L),window.addEventListener("pointercancel",L),window.addEventListener("message",_),()=>{z.removeEventListener("pointerdown",F),window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",L),window.removeEventListener("pointercancel",L),window.removeEventListener("message",_)}},[K,j]),NQ("div",{ref:$,"aria-hidden":"true"})}import{jsx as o,jsxs as SQ}from"react/jsx-runtime";var TQ=new Set(["drop-comment","tool","escape","hover"]);function $7(){return typeof document<"u"&&!document.querySelector(".dc-canvas")}function w7(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 EQ(J,Q){let $=w7(J,Q);if(!$)return null;return $.closest("[data-cd-id]")??$}function kQ({children:J,file:Q}){let{tool:$,setTool:V}=G7(),q=B7(),B=u(null),[K,U]=Q7(null),H=u($);H.current=$;let M=IQ(()=>()=>H.current,[]);p(()=>{if($!=="comment")U(null)},[$]);let[j,z]=Q7(null),[G,F]=Q7(!1);return p(()=>{let Y=()=>F($7());Y();let L=requestAnimationFrame(Y),_=setTimeout(Y,120);return()=>{cancelAnimationFrame(L),clearTimeout(_)}},[]),p(()=>{if(typeof document>"u")return;let Y=(L)=>{if(L.button!==0||!(L.metaKey||L.ctrlKey))return;if(!$7())return;if(e(L.target))return;let _=EQ(L.clientX,L.clientY);if(!_)return;L.preventDefault(),L.stopImmediatePropagation();let Z=_.getAttribute("data-cd-id"),X=Y7({el:_,cdId:Z,artboardId:null});if(L.shiftKey)q.add(X);else q.replace(X);z(_)};return document.addEventListener("pointerdown",Y,!0),()=>document.removeEventListener("pointerdown",Y,!0)},[q]),p(()=>{if(q.selected.length===0)z(null)},[q.selected]),p(()=>{let Y=B.current;if(Y)Y.setAttribute("data-active-tool",$);if(typeof document<"u"&&document.body)document.body.setAttribute("data-active-tool",$);return()=>{Y?.removeAttribute("data-active-tool")}},[$]),p(()=>{if(typeof window>"u")return;let Y=(L)=>{let _=L.data;if(!_||typeof _!=="object"||_.dgn!=="tool-set")return;if(typeof _.tool==="string")V(_.tool)};return window.addEventListener("message",Y),()=>window.removeEventListener("message",Y)},[V]),o7({hostRef:B,getActiveTool:M,claimableActions:TQ,callbacks:{onHover:({clientX:Y,clientY:L})=>{if(H.current!=="comment"||!$7()){U(null);return}let _=w7(Y,L);U((Z)=>Z===_?Z:_)},onTool:({tool:Y})=>V(Y),onEscape:()=>{if(H.current!=="move")V("move");if(U(null),q.clear(),typeof window<"u")try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},onDropComment:({clientX:Y,clientY:L})=>bQ(Y,L,q,Q)}}),SQ("div",{"data-mc-host":!0,ref:B,style:{display:"contents"},children:[J,K?o(yQ,{el:K}):null,j?o(wQ,{el:j}):null,G?o(ZJ,{}):null,o(l7,{})]})}function wQ({el:J}){let Q=u(null),$=u(J);$.current=J;let V=u(null);return p(()=>{let q=()=>{V.current=null;let B=Q.current,K=$.current;if(B&&K?.isConnected){let U=K.getBoundingClientRect();if(U.width===0&&U.height===0)B.style.display="none";else B.style.display="block",B.style.left=`${Math.round(U.left)}px`,B.style.top=`${Math.round(U.top)}px`,B.style.width=`${Math.round(U.width)}px`,B.style.height=`${Math.round(U.height)}px`}else if(B)B.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 yQ({el:J}){let Q=u(null),$=u(J);$.current=J;let V=u(null);return p(()=>{let q=()=>{V.current=null;let B=Q.current,K=$.current;if(B&&K?.isConnected){let U=K.getBoundingClientRect();if(U.width===0&&U.height===0)B.style.display="none";else B.style.display="block",B.style.left=`${Math.round(U.left)}px`,B.style.top=`${Math.round(U.top)}px`,B.style.width=`${Math.round(U.width)}px`,B.style.height=`${Math.round(U.height)}px`}else if(B)B.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 bQ(J,Q,$,V){if(typeof document>"u")return;let q=j7(document,J,Q,{deep:!0});if(!q)q=j7(document,J,Q,{deep:!1});if(!q&&!$7()&&typeof document.elementsFromPoint==="function"){let K=document.elementsFromPoint(J,Q);for(let U of K){let H=U.closest?.("[data-cd-id]");if(!H)continue;if(!H.closest(".dc-artboard-body"))continue;let M=H.closest("[data-dc-screen]");q={el:H,cdId:H.getAttribute("data-cd-id"),artboardId:M?.getAttribute("data-dc-screen")??null};break}}if(!q&&$7()){let K=w7(J,Q);if(K)q={el:K,cdId:K.getAttribute("data-cd-id"),artboardId:null}}if(!q){let K={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:""};qJ(K,J,Q);return}let B=Y7(q,V);$.replace(B),qJ(B,J,Q)}function qJ(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 GJ(J,Q){return h(e7,null,h(p7,null,h(kQ,{file:Q},h(J))))}function C0(J,Q){let $=OQ(Q.rootEl);if(!Q.commentsEnabled){$.render(h(J));return}let V=Q.file??z7();$.render(h(vQ,{initialCanvas:J,file:V}))}var BJ="__maudeCanvasRuntime";function xQ({Canvas:J,file:Q,onOk:$}){return p(()=>{$()},[]),GJ(J,Q)}class WJ extends _Q{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 CQ({message:J}){return h("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 vQ({initialCanvas:J,file:Q}){let[{canvas:$,attempt:V},q]=Q7({canvas:J,attempt:0}),[B,K]=Q7({on:!1}),U=u(null),H=u($);H.current=$,p(()=>{let G={remount:(F)=>q((Y)=>({canvas:F,attempt:Y.attempt+1})),setHolding:(F,Y)=>K(F?{on:!0,message:Y}:{on:!1})};return window[BJ]=G,()=>{window[BJ]=void 0}},[]);let M=k7(()=>{U.current=H.current,K((G)=>G.on?{on:!1}:G)},[]),j=k7(()=>{K({on:!0,message:"render error"})},[]),z=k7(()=>{let G=U.current;return G?GJ(G,Q):null},[Q]);return h(AQ,null,h(WJ,{attempt:V,onError:j,fallback:z},h(xQ,{key:V,Canvas:$,file:Q,onOk:M})),B.on?h(CQ,{message:B.message}):null)}export{EQ as pickSpecimenSelectEl,C0 as mountCanvas,$7 as isBareSpecimen,WJ as CanvasErrorBoundary};
|
|
59
|
+
`.trim();function XQ(){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=UQ,document.head.appendChild(J)}var zQ=["nw","n","ne","e","se","s","sw","w"];function YQ(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,W7=1;function HQ(J,Q,$,V,q,B){let{movesLeft:K,movesRight:U,movesTop:H,movesBottom:M}=YQ(J),j=q.center,X=Q.w,G=Q.h;if(U)X=Q.w+(j?2*$:$);else if(K)X=Q.w-(j?2*$:$);if(M)G=Q.h+(j?2*V:V);else if(H)G=Q.h-(j?2*V:V);if(q.aspect&&Q.w>0&&Q.h>0){let Y=Q.w/Q.h;if((K||U)&&(H||M)){let _=Math.abs(X-Q.w)/Q.w,Z=Math.abs(G-Q.h)/Q.h;if(_>=Z)G=X/Y;else X=G*Y}else if(K||U)G=X/Y;else if(H||M)X=G*Y}if(X<W7)X=W7;if(G<W7)G=W7;let F={width:n(X),height:n(G)};if(j){if(B.canMoveLeft&&(K||U))F.left=n(Q.left+(Q.w-X)/2);if(B.canMoveTop&&(H||M))F.top=n(Q.top+(Q.h-G)/2)}else{if(B.canMoveLeft&&K)F.left=n(Q.left+Q.w-X);if(B.canMoveTop&&H)F.top=n(Q.top+Q.h-G)}return F}function JJ(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 FQ(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,B=Math.hypot(V,q);return B>0?B:1}function DQ(J){let Q=J.closest(".dc-world");if(!Q)return 1;let $=getComputedStyle(Q),V=Number.parseFloat($.zoom||"1")||1;return FQ($.transform)*V}function QJ(J,Q,$){let V=$*Math.PI/180,q=Math.cos(V),B=Math.sin(V);return[J*q-Q*B,J*B+Q*q]}function $J(J,Q,$,V){return Math.atan2(V-Q,$-J)}function LQ(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 PQ(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 MQ(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 jQ(J,Q){try{window.parent.postMessage({dgn:"resize-request",id:J.cdId,patch:{transform:Q},before:J.before,idIndex:J.idIndex},"*")}catch{}}function VJ(){XQ();let{selected:J}=q7(),{tool:Q}=B7(),$=G7(null),V=G7(null),q=G7(null),B=G7(null),K=J.length===1?J[0]:null,U=K&&typeof K.id==="string"?K.id:null,H=K&&!U&&typeof K.artboardId==="string"?K.artboardId:null,M=Q==="move"&&(!!U||!!H);e7(()=>{let X=$.current;if(!X)return;let G=()=>{for(let Y of Array.from(X.children)){let L=Y;L.style.opacity="0",L.style.pointerEvents="none"}};if(!M||!K){G();return}let F=()=>{if(V.current=null,o7()){G(),V.current=requestAnimationFrame(F);return}let Y=X7(document,K);if(!Y){G(),V.current=requestAnimationFrame(F);return}let L=Y.getBoundingClientRect();if(L.width<=0&&L.height<=0){G(),V.current=requestAnimationFrame(F);return}let _=H?["e","s","se"]:zQ,Z=H?[]:["rot-nw","rot-ne","rot-sw","rot-se"],z=_.length+Z.length+1;while(X.children.length<z)X.appendChild(document.createElement("div"));while(X.children.length>z)X.lastChild&&X.removeChild(X.lastChild);let W=L.left+L.width/2,D=L.top+L.height/2,N=JJ(getComputedStyle(Y).transform),A=DQ(Y),I=Y.offsetWidth*A/2,P=Y.offsetHeight*A/2,T={nw:[-I,-P],n:[0,-P],ne:[I,-P],e:[I,0],se:[I,P],s:[0,P],sw:[-I,P],w:[-I,0],"rot-nw":[-I,-P],"rot-ne":[I,-P],"rot-sw":[-I,P],"rot-se":[I,P]},k=[...Z,..._];for(let h=0;h<k.length;h++){let y=k[h],C=X.children[h],[d,c]=T[y]??[0,0],[WJ,KJ]=QJ(d,c,N),UJ=W+WJ,XJ=D+KJ,K7=y.startsWith("rot-"),w7=y==="n"||y==="s",y7=y==="e"||y==="w",zJ=K7?10:w7?7:y7?3:4,YJ=K7?10:w7?3:y7?7:4;C.className="dc-el-resize-handle",C.dataset.corner=y,C.style.opacity="1",C.style.pointerEvents="auto",C.style.left=`${Math.round(UJ-zJ)}px`,C.style.top=`${Math.round(XJ-YJ)}px`,C.style.transform=K7?"":`rotate(${N}deg)`}let x=X.children[k.length],w=q.current;if(w&&w.el===Y&&!w.corner.startsWith("rot-")){let h=w.lastResult?.width??Y.offsetWidth,y=w.lastResult?.height??Y.offsetHeight,C=`${Math.round(h)} × ${Math.round(y)}`,d=w.lastResult?.left,c=w.lastResult?.top;if(typeof d==="number"||typeof c==="number")C+=` · ${Math.round(d??w.start.left)}, ${Math.round(c??w.start.top)}`;x.className="dc-el-resize-readout",x.textContent=C,x.style.opacity="1",x.style.left=`${Math.round(W)}px`,x.style.top=`${Math.round(D+P)}px`}else x.style.opacity="0";V.current=requestAnimationFrame(F)};return V.current=requestAnimationFrame(F),()=>{if(V.current!=null)cancelAnimationFrame(V.current)}},[M,K,H]);let j=KQ((X,G)=>{if(X.el.style.width=`${G.width}px`,X.el.style.height=`${G.height}px`,typeof G.left==="number")X.el.style.left=`${G.left}px`;if(typeof G.top==="number")X.el.style.top=`${G.top}px`;X.lastResult=G},[]);return e7(()=>{let X=$.current;if(!X)return;let G=(Z,z)=>{let[W,D]=QJ(z.clientX-Z.startClientX,z.clientY-Z.startClientY,-Z.angle);return HQ(Z.corner,Z.start,W/Z.elZoom,D/Z.elZoom,{aspect:!!z.shiftKey,center:!Z.artboardId&&!!z.altKey},Z.flags)},F=(Z)=>{let z=Z.target;if(!z?.classList.contains("dc-el-resize-handle"))return;let W=z.dataset.corner;if(!W||!K)return;let D=typeof K.id==="string"?K.id:null,N=!D&&typeof K.artboardId==="string"?K.artboardId:null;if(!D&&!N)return;let A=X7(document,K);if(!A)return;Z.preventDefault(),Z.stopPropagation();let I=A.getBoundingClientRect(),P=A.offsetWidth?I.width/A.offsetWidth:1,T=getComputedStyle(A),k=!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:JJ(T.transform),y=P>0?P:1,C=I.left+I.width/2,d=I.top+I.height/2,c={pointerId:Z.pointerId,corner:W,el:A,cdId:D??"",artboardId:N,idIndex:D?S7(document,D,A):0,startClientX:Z.clientX,startClientY:Z.clientY,elZoom:y,angle:h,cx:C,cy:d,rotStartPointer:$J(C,d,Z.clientX,Z.clientY),start:{w:(h?A.offsetWidth:I.width/y)||I.width/y,h:(h?A.offsetHeight:I.height/y)||I.height/y,left:x,top:w},flags:{canMoveLeft:k&&Number.isFinite(x),canMoveTop:k&&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{z.setPointerCapture(Z.pointerId)}catch{}},Y=(Z)=>{let z=q.current;if(!z||Z.pointerId!==z.pointerId)return;if(Z.preventDefault(),z.corner.startsWith("rot-")){let D=`rotate(${LQ(z.angle,z.rotStartPointer,$J(z.cx,z.cy,Z.clientX,Z.clientY),!!Z.shiftKey)}deg)`;z.el.style.transform=D,z.lastTransform=D;return}j(z,G(z,Z))},L=(Z)=>{let z=q.current;if(!z||Z.pointerId!==z.pointerId)return;if(q.current=null,z.corner.startsWith("rot-")){let N=z.lastTransform;if(!N||N===z.before.transform)return;B.current={el:z.el,before:z.before},jQ(z,N);return}let W=z.lastResult??G(z,Z);if(!(`${W.width}px`!==z.before.width||`${W.height}px`!==z.before.height||typeof W.left==="number"&&`${W.left}px`!==z.before.left||typeof W.top==="number"&&`${W.top}px`!==z.before.top))return;if(B.current={el:z.el,before:z.before},z.artboardId)MQ(z,W);else PQ(z,W)},_=(Z)=>{let z=Z.data;if(z?.dgn!=="resize-failed"&&z?.dgn!=="resize-artboard-failed")return;if(Z.source!==window.parent)return;let W=B.current;if(!W)return;if(W.el.style.width=W.before.width??"",W.el.style.height=W.before.height??"",W.before.left!==null||W.el.style.left)W.el.style.left=W.before.left??"";if(W.before.top!==null||W.el.style.top)W.el.style.top=W.before.top??"";if(W.before.transform!==null||W.el.style.transform)W.el.style.transform=W.before.transform??"";B.current=null};return X.addEventListener("pointerdown",F),window.addEventListener("pointermove",Y),window.addEventListener("pointerup",L),window.addEventListener("pointercancel",L),window.addEventListener("message",_),()=>{X.removeEventListener("pointerdown",F),window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",L),window.removeEventListener("pointercancel",L),window.removeEventListener("message",_)}},[K,j]),NQ("div",{ref:$,"aria-hidden":"true"})}import{jsx as o,jsxs as SQ}from"react/jsx-runtime";var TQ=new Set(["drop-comment","tool","escape","hover"]);function $7(){return typeof document<"u"&&!document.querySelector(".dc-canvas")}function k7(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 EQ(J,Q){let $=k7(J,Q);if(!$)return null;return $.closest("[data-cd-id]")??$}function kQ({children:J,file:Q}){let{tool:$,setTool:V}=B7(),q=q7(),B=p(null),[K,U]=Q7(null),H=p($);H.current=$;let M=IQ(()=>()=>H.current,[]);f(()=>{if($!=="comment")U(null)},[$]);let[j,X]=Q7(null),[G,F]=Q7(!1);return f(()=>{let Y=()=>F($7());Y();let L=requestAnimationFrame(Y),_=setTimeout(Y,120);return()=>{cancelAnimationFrame(L),clearTimeout(_)}},[]),f(()=>{if(typeof document>"u")return;let Y=(L)=>{if(L.button!==0||!(L.metaKey||L.ctrlKey))return;if(!$7())return;if(e(L.target))return;let _=EQ(L.clientX,L.clientY);if(!_)return;L.preventDefault(),L.stopImmediatePropagation();let Z=_.getAttribute("data-cd-id"),z=z7({el:_,cdId:Z,artboardId:null});if(L.shiftKey)q.add(z);else q.replace(z);X(_)};return document.addEventListener("pointerdown",Y,!0),()=>document.removeEventListener("pointerdown",Y,!0)},[q]),f(()=>{if(q.selected.length===0)X(null)},[q.selected]),f(()=>{let Y=B.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=(L)=>{let _=L.data;if(!_||typeof _!=="object"||_.dgn!=="tool-set")return;if(typeof _.tool==="string")V(_.tool)};return window.addEventListener("message",Y),()=>window.removeEventListener("message",Y)},[V]),n7({hostRef:B,getActiveTool:M,claimableActions:TQ,callbacks:{onHover:({clientX:Y,clientY:L})=>{if(H.current!=="comment"||!$7()){U(null);return}let _=k7(Y,L);U((Z)=>Z===_?Z:_)},onTool:({tool:Y})=>V(Y),onEscape:()=>{if(H.current!=="move")V("move");if(U(null),q.clear(),typeof window<"u")try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},onDropComment:({clientX:Y,clientY:L})=>bQ(Y,L,q,Q)}}),SQ("div",{"data-mc-host":!0,ref:B,style:{display:"contents"},children:[J,K?o(yQ,{el:K}):null,j?o(wQ,{el:j}):null,G?o(VJ,{}):null,o(c7,{})]})}function wQ({el:J}){let Q=p(null),$=p(J);$.current=J;let V=p(null);return f(()=>{let q=()=>{V.current=null;let B=Q.current,K=$.current;if(B&&K?.isConnected){let U=K.getBoundingClientRect();if(U.width===0&&U.height===0)B.style.display="none";else B.style.display="block",B.style.left=`${Math.round(U.left)}px`,B.style.top=`${Math.round(U.top)}px`,B.style.width=`${Math.round(U.width)}px`,B.style.height=`${Math.round(U.height)}px`}else if(B)B.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 yQ({el:J}){let Q=p(null),$=p(J);$.current=J;let V=p(null);return f(()=>{let q=()=>{V.current=null;let B=Q.current,K=$.current;if(B&&K?.isConnected){let U=K.getBoundingClientRect();if(U.width===0&&U.height===0)B.style.display="none";else B.style.display="block",B.style.left=`${Math.round(U.left)}px`,B.style.top=`${Math.round(U.top)}px`,B.style.width=`${Math.round(U.width)}px`,B.style.height=`${Math.round(U.height)}px`}else if(B)B.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 bQ(J,Q,$,V){if(typeof document>"u")return;let q=M7(document,J,Q,{deep:!0});if(!q)q=M7(document,J,Q,{deep:!1});if(!q&&!$7()&&typeof document.elementsFromPoint==="function"){let K=document.elementsFromPoint(J,Q);for(let U of K){let H=U.closest?.("[data-cd-id]");if(!H)continue;if(!H.closest(".dc-artboard-body"))continue;let M=H.closest("[data-dc-screen]");q={el:H,cdId:H.getAttribute("data-cd-id"),artboardId:M?.getAttribute("data-dc-screen")??null};break}}if(!q&&$7()){let K=k7(J,Q);if(K)q={el:K,cdId:K.getAttribute("data-cd-id"),artboardId:null}}if(!q){let K={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:""};ZJ(K,J,Q);return}let B=z7(q,V);$.replace(B),ZJ(B,J,Q)}function ZJ(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 BJ(J,Q){return g(t7,null,g(f7,null,g(kQ,{file:Q},g(J))))}function C0(J,Q){let $=OQ(Q.rootEl);if(!Q.commentsEnabled){$.render(g(J));return}let V=Q.file??U7();$.render(g(vQ,{initialCanvas:J,file:V}))}var qJ="__maudeCanvasRuntime";function xQ({Canvas:J,file:Q,onOk:$}){return f(()=>{$()},[]),BJ(J,Q)}class GJ extends _Q{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 CQ({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 vQ({initialCanvas:J,file:Q}){let[{canvas:$,attempt:V},q]=Q7({canvas:J,attempt:0}),[B,K]=Q7({on:!1}),U=p(null),H=p($);H.current=$,f(()=>{let G={remount:(F)=>q((Y)=>({canvas:F,attempt:Y.attempt+1})),setHolding:(F,Y)=>K(F?{on:!0,message:Y}:{on:!1})};return window[qJ]=G,()=>{window[qJ]=void 0}},[]);let M=E7(()=>{U.current=H.current,K((G)=>G.on?{on:!1}:G)},[]),j=E7(()=>{K({on:!0,message:"render error"})},[]),X=E7(()=>{let G=U.current;return G?BJ(G,Q):null},[Q]);return g(AQ,null,g(GJ,{attempt:V,onError:j,fallback:X},g(xQ,{key:V,Canvas:$,file:Q,onOk:M})),B.on?g(CQ,{message:B.message}):null)}export{EQ as pickSpecimenSelectEl,C0 as mountCanvas,$7 as isBareSpecimen,GJ as CanvasErrorBoundary};
|