@1agh/maude 0.60.7 → 1.0.3

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.
Files changed (145) hide show
  1. package/apps/studio/acp/index.ts +1 -0
  2. package/apps/studio/ai-banner.tsx +1 -0
  3. package/apps/studio/annotations-context-toolbar.tsx +3 -1
  4. package/apps/studio/annotations-layer.tsx +33 -16
  5. package/apps/studio/api.ts +108 -18
  6. package/apps/studio/artboard-guides-overlay.tsx +5 -1
  7. package/apps/studio/assets-s3.ts +6 -1
  8. package/apps/studio/bin/_import-figma.mjs +8 -3
  9. package/apps/studio/build.ts +1 -1
  10. package/apps/studio/canvas-artifacts.ts +21 -0
  11. package/apps/studio/canvas-build.ts +14 -9
  12. package/apps/studio/canvas-comment-mount.tsx +27 -30
  13. package/apps/studio/canvas-icons.tsx +1 -1
  14. package/apps/studio/canvas-lib.tsx +94 -5
  15. package/apps/studio/canvas-list-watch.ts +14 -1
  16. package/apps/studio/canvas-shell.tsx +8 -0
  17. package/apps/studio/client/app.jsx +224 -45
  18. package/apps/studio/client/panels/GitPanel.jsx +121 -13
  19. package/apps/studio/client/panels/SettingsPanel.jsx +1 -1
  20. package/apps/studio/client/panels/SyncConsentDialog.jsx +182 -0
  21. package/apps/studio/client/panels/SyncPanel.jsx +595 -1
  22. package/apps/studio/client/styles/3-shell-maude.css +38 -0
  23. package/apps/studio/clip-ops.ts +8 -1
  24. package/apps/studio/cloud/endpoints.ts +265 -3
  25. package/apps/studio/collab/origins.ts +3 -1
  26. package/apps/studio/comments-overlay.tsx +5 -0
  27. package/apps/studio/config.schema.json +24 -0
  28. package/apps/studio/context-menu.tsx +40 -27
  29. package/apps/studio/context.ts +57 -8
  30. package/apps/studio/cursors-overlay.tsx +25 -13
  31. package/apps/studio/dist/client.bundle.js +686 -686
  32. package/apps/studio/dist/comment-mount.js +2 -2
  33. package/apps/studio/dist/styles.css +1 -1
  34. package/apps/studio/exporters/jobs.ts +77 -15
  35. package/apps/studio/exporters/remote.ts +201 -0
  36. package/apps/studio/exporters/video-encode-lib.ts +10 -4
  37. package/apps/studio/figma/to-strokes.ts +11 -9
  38. package/apps/studio/gifenc.d.ts +51 -0
  39. package/apps/studio/git/log-format.ts +88 -0
  40. package/apps/studio/git/safe-rel.ts +96 -0
  41. package/apps/studio/git/service.ts +46 -27
  42. package/apps/studio/hmr-broadcast.ts +10 -0
  43. package/apps/studio/http.ts +384 -6
  44. package/apps/studio/participants-chrome.tsx +1 -0
  45. package/apps/studio/photo-store.ts +7 -0
  46. package/apps/studio/react-augment.d.ts +17 -0
  47. package/apps/studio/runtime-bundle.ts +6 -1
  48. package/apps/studio/server.ts +43 -8
  49. package/apps/studio/sync/agent.ts +70 -82
  50. package/apps/studio/sync/asset-push.ts +28 -71
  51. package/apps/studio/sync/autocommit.ts +106 -5
  52. package/apps/studio/sync/cell-file-events.ts +117 -0
  53. package/apps/studio/sync/cell-pairing.ts +20 -5
  54. package/apps/studio/sync/cell-write-nudge.ts +244 -0
  55. package/apps/studio/sync/codec.ts +155 -3
  56. package/apps/studio/sync/cold-start-apply.ts +211 -0
  57. package/apps/studio/sync/ctl-heal.ts +253 -0
  58. package/apps/studio/sync/ctl-provider.ts +217 -0
  59. package/apps/studio/sync/decide-file.ts +335 -0
  60. package/apps/studio/sync/file-ledger.ts +581 -0
  61. package/apps/studio/sync/file-membership.ts +32 -0
  62. package/apps/studio/sync/file-plane.ts +1400 -0
  63. package/apps/studio/sync/file-pull.ts +41 -4
  64. package/apps/studio/sync/hub-link.ts +16 -1
  65. package/apps/studio/sync/hub-listing.ts +46 -0
  66. package/apps/studio/sync/hubs-config.ts +16 -0
  67. package/apps/studio/sync/index.ts +915 -308
  68. package/apps/studio/sync/journal-client.ts +200 -0
  69. package/apps/studio/sync/migrate-seed.ts +99 -67
  70. package/apps/studio/sync/poke.ts +50 -0
  71. package/apps/studio/sync/projection.ts +13 -0
  72. package/apps/studio/sync/pull-budget.ts +86 -0
  73. package/apps/studio/sync/settings.ts +110 -0
  74. package/apps/studio/sync/status.ts +68 -0
  75. package/apps/studio/sync/trash.ts +243 -0
  76. package/apps/studio/sync/untrusted.ts +30 -10
  77. package/apps/studio/test/_helpers.ts +8 -0
  78. package/apps/studio/test/canvas-build.test.ts +63 -0
  79. package/apps/studio/test/canvas-list-watch.test.ts +17 -0
  80. package/apps/studio/test/canvas-move-api.test.ts +31 -0
  81. package/apps/studio/test/canvas-origin-gate.test.ts +12 -0
  82. package/apps/studio/test/canvas-shell-build-error.test.ts +49 -0
  83. package/apps/studio/test/cloud-history-hardening.test.ts +165 -0
  84. package/apps/studio/test/cloud-history-posture.test.ts +230 -0
  85. package/apps/studio/test/cloud-session-role.test.ts +30 -0
  86. package/apps/studio/test/cloud-shell-surfaces.test.ts +39 -0
  87. package/apps/studio/test/cold-start-apply.test.ts +303 -0
  88. package/apps/studio/test/collab-stress.test.ts +9 -1
  89. package/apps/studio/test/export-lane.test.ts +245 -0
  90. package/apps/studio/test/fixtures/video-comp-fixture.tsx +1 -1
  91. package/apps/studio/test/git-log-format.test.ts +95 -0
  92. package/apps/studio/test/git-safe-rel.test.ts +132 -0
  93. package/apps/studio/test/hmr-broadcast.test.ts +26 -0
  94. package/apps/studio/test/peer-selection-follows-camera.test.tsx +131 -0
  95. package/apps/studio/test/shared-doc-cell-pairing.test.ts +5 -2
  96. package/apps/studio/test/sync-agent.test.ts +78 -0
  97. package/apps/studio/test/sync-asset-push.test.ts +71 -108
  98. package/apps/studio/test/sync-autocommit.test.ts +80 -0
  99. package/apps/studio/test/sync-cell-write-nudge.test.ts +346 -0
  100. package/apps/studio/test/sync-ctl-channel.test.ts +508 -0
  101. package/apps/studio/test/sync-decide-file.test.ts +420 -0
  102. package/apps/studio/test/sync-file-ledger.test.ts +334 -0
  103. package/apps/studio/test/sync-file-membership.test.ts +17 -1
  104. package/apps/studio/test/sync-file-plane.test.ts +976 -0
  105. package/apps/studio/test/sync-hub-listing.test.ts +46 -0
  106. package/apps/studio/test/sync-meta-codec.test.ts +76 -0
  107. package/apps/studio/test/sync-move-retirement.test.ts +231 -0
  108. package/apps/studio/test/sync-panel-surface.test.ts +20 -0
  109. package/apps/studio/test/sync-path-pull.test.ts +67 -1
  110. package/apps/studio/test/sync-pull-budget.test.ts +169 -0
  111. package/apps/studio/test/sync-seed-defers-to-hub.test.ts +83 -0
  112. package/apps/studio/test/sync-settings-routes.test.ts +195 -0
  113. package/apps/studio/test/sync-settings.test.ts +151 -0
  114. package/apps/studio/test/sync-status.test.ts +69 -0
  115. package/apps/studio/test/sync-trash.test.ts +132 -0
  116. package/apps/studio/test/workspace-containment.test.ts +45 -9
  117. package/apps/studio/tsconfig.json +9 -10
  118. package/apps/studio/use-annotation-resize.tsx +14 -3
  119. package/apps/studio/use-collab.tsx +3 -1
  120. package/apps/studio/whats-new.json +90 -0
  121. package/apps/studio/workspace-mode.ts +110 -62
  122. package/apps/studio/ws.ts +22 -1
  123. package/cli/bin/claude-design-server.mjs +19 -0
  124. package/cli/commands/design.mjs +25 -6
  125. package/cli/commands/hub-workspace.mjs +243 -22
  126. package/cli/commands/hub-workspace.test.mjs +171 -0
  127. package/cli/commands/hub.mjs +71 -1
  128. package/cli/lib/design-link.mjs +186 -1
  129. package/cli/lib/design-ownership.mjs +330 -0
  130. package/cli/lib/design-ownership.test.mjs +329 -0
  131. package/cli/lib/hubs-config.mjs +21 -0
  132. package/cli/lib/hubs-config.test.mjs +47 -1
  133. package/cli/lib/workspace-plan.mjs +298 -5
  134. package/cli/lib/workspace-plan.test.mjs +215 -1
  135. package/package.json +10 -10
  136. package/plugins/design/templates/_shell.html +43 -2
  137. package/plugins/design/templates/design-system-inspiration/SUB-AGENT-PROMPTS.md +1 -1
  138. package/plugins/design/templates/design-system-inspiration/core/preview/_motion-readme.md.tpl +1 -1
  139. package/apps/studio/server.mjs +0 -1312
  140. package/apps/studio/sync/asset-pull.ts +0 -210
  141. package/apps/studio/sync/asset-push-worker.ts +0 -84
  142. package/apps/studio/sync/asset-sweep.ts +0 -262
  143. package/apps/studio/test/sync-asset-pull.test.ts +0 -161
  144. package/apps/studio/test/sync-asset-push-worker.test.ts +0 -183
  145. package/apps/studio/test/sync-asset-sweep.test.ts +0 -243
@@ -1,4 +1,4 @@
1
- import{Component as RQ,createElement as h,Fragment as SQ,useCallback as b7,useEffect as f,useMemo as hQ,useRef as p,useState as V7}from"react";import{createRoot as gQ}from"react-dom/client";import{useCallback as T,useEffect as R,useMemo as s,useRef as S,useState as u}from"react";function P7(){if(typeof window>"u")return;try{let J=window.location.pathname;if(J==="/_canvas-shell.html"||J==="/_canvas-shell"){let Q=new URLSearchParams(window.location.search),$=Q.get("canvas")??"",Z=(Q.get("designRel")??".design").replace(/^\/+|\/+$/g,"");return $?`${Z}/${$}`:void 0}return decodeURIComponent(J).replace(/^\//,"")}catch{return}}function q7(J){if(!J)return"";return(J.getAttribute("class")??"").trim().split(/\s+/).filter((Q)=>Q&&!Q.startsWith("dgn-")&&!Q.startsWith("dc-cv-")).join(" ")}function IJ(J,Q){if(!J)return"";let $=(J.innerText||J.textContent||"").replace(/\s+/g," ").trim();return $.length>Q?`${$.slice(0,Q-1)}…`:$}function AJ(J){if(!J)return"";let Q=[],$=J;while($&&$.nodeType===1&&Q.length<8){let Z=$.getAttribute?.("data-dc-element");if(Z){Q.unshift(`[data-dc-element="${Z}"]`);break}let q=$.getAttribute?.("data-dc-screen");if(q){Q.unshift(`[data-dc-screen="${q}"]`);break}let G=$.nodeName.toLowerCase();if($.id){G=`#${$.id}`,Q.unshift(G);break}let z=q7($).split(/\s+/).filter(Boolean).slice(0,2);if(z.length)G+=`.${z.join(".")}`;let X=1,Y=$.previousElementSibling;while(Y)X++,Y=Y.previousElementSibling;G+=`:nth-child(${X})`,Q.unshift(G),$=$.parentElement}return Q.join(" > ")}function S7(J){let Q=[],$=J;while($&&$.nodeType===1&&Q.length<8){let Z=$.nodeName.toLowerCase(),q=$.getAttribute?.("data-dc-element"),G=$.getAttribute?.("data-dc-screen");if(q)Z+=`[data-dc-element="${q}"]`;else if(G)Z+=`[data-dc-screen="${G}"]`;else if($.id)Z+=`#${$.id}`;let z=q7($).split(/\s+/).filter(Boolean).slice(0,2);if(z.length&&!q&&!G)Z+=`.${z.join(".")}`;Q.unshift(Z),$=$.parentElement}return Q}function OJ(J){return J.replace(/[^a-zA-Z0-9_-]/g,(Q)=>`\\${Q}`)}function h7(J,Q){return Q?`[data-dc-screen="${Q}"] [data-cd-id="${J}"]`:`[data-cd-id="${J}"]`}function g7(J,Q,$){if(!$)return 0;try{let Z=J.querySelectorAll(Q);for(let q=0;q<Z.length;q++)if(Z[q]===$)return q}catch{}return 0}function f7(J,Q,$){if(!Q||!$)return 0;return g7(J,`[data-cd-id="${OJ(Q)}"]`,$)}function D7(J,Q){let $=(Z)=>{try{let q=J.querySelectorAll(Z);if(!q.length)return null;let G=Q.index&&Q.index>0&&Q.index<q.length?Q.index:0;return q[G]??q[0]}catch{return null}};if(Q.id){let Z=$(h7(Q.id,Q.artboardId));if(Z)return Z}if(Q.selector)return $(Q.selector);return null}function kJ(J,Q){let $=0,Z=Math.min(J.length,Q.length);for(let q=1;q<=Z;q++){if(J[J.length-q]!==Q[Q.length-q])break;$++}return $}function p7(J,Q){let $=Q.dom_path,Z=(Q.tag||"").toLowerCase();if(!$||$.length===0||!Z)return null;let q=J;if(Q.artboardId){let Y=J.querySelector(`[data-dc-screen="${Q.artboardId}"]`);if(Y)q=Y}let G=(Q.classes||"").split(/\s+/).filter(Boolean),z=null,X=0;for(let Y of Array.from(q.querySelectorAll("[data-cd-id]"))){if(Y.tagName.toLowerCase()!==Z)continue;let _=kJ(S7(Y),$);if(_===0)continue;let L=q7(Y).split(/\s+/).filter(Boolean),U=G.filter((P)=>L.includes(P)).length,W=_*10+U;if(W>X)X=W,z=Y}return z}var R7=["display","flex-direction","flex-wrap","align-items","justify-content","gap","flex","flex-grow","flex-shrink","flex-basis","align-self","font-family","color","font-size","font-weight","line-height","letter-spacing","text-align","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","width","height","min-width","min-height","max-width","max-height","background-color","border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius","border-width","border-style","border-color","box-shadow","opacity","position","top","right","bottom","left","z-index","transform","transform-origin","font-style","text-transform","text-decoration","white-space","overflow","object-fit","aspect-ratio","object-position"],TJ=/^(style|class|data-cd-id|data-dc-|data-dcid$)/;function EJ(J){if(!J||typeof window>"u"||!window.getComputedStyle)return{authored:{},computed:{},customStyles:{},attrs:{}};try{let Q=J.style,$=window.getComputedStyle(J),Z={},q={},G=new Set(R7);for(let W of R7){let P=Q.getPropertyValue(W);if(P)Z[W]=P.trim();let H=$.getPropertyValue(W);if(H)q[W]=H.trim()}let z=/^(margin|padding|border)(-|$)/,X={};for(let W=0;W<Q.length;W++){let P=Q.item(W);if(!P||G.has(P)||z.test(P))continue;let H=Q.getPropertyValue(P);if(H)X[P]=H.trim()}let Y={};for(let W of Array.from(J.attributes)){if(TJ.test(W.name))continue;Y[W.name]=W.value}if(J.hasAttribute("data-dc-screen")){for(let W of Array.from(J.attributes))if(W.name.startsWith("data-dc-")&&W.name!=="data-dcid")Y[W.name]=W.value}let _=J.parentElement,L=_?window.getComputedStyle(_).display:"",U=_&&(L==="flex"||L==="inline-flex")?window.getComputedStyle(_).flexDirection:"";return{authored:Z,computed:q,customStyles:X,attrs:Y,parentDisplay:L,parentFlexDirection:U}}catch{return{authored:{},computed:{},customStyles:{},attrs:{}}}}function j7(J,Q){let $=J.el,Z=$&&$.getBoundingClientRect?$.getBoundingClientRect():null,q=J.cdId,G=q?h7(q,J.artboardId):J.artboardId?`[data-dc-screen="${J.artboardId}"]`:AJ($),z=q&&typeof document<"u"?g7(document,G,$):0;return{file:Q??P7(),id:q??void 0,selector:G,artboardId:J.artboardId,index:z,tag:$?.tagName.toLowerCase()??"",classes:q7($),text:IJ($,240),dom_path:S7($),bounds:Z?{x:Math.round(Z.left),y:Math.round(Z.top),w:Math.round(Z.width),h:Math.round(Z.height)}:null,worldW:$ instanceof HTMLElement?Math.round($.offsetWidth):void 0,worldH:$ instanceof HTMLElement?Math.round($.offsetHeight):void 0,html:$?($.outerHTML??"").slice(0,4000):"",...(()=>{if($?.tagName?.toLowerCase()!=="img")return{};let X=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,Y=$.getAttribute?.("data-photo-asset");if(Y&&X.test(Y))return{photoKind:"artboard-img",photoAsset:Y};let _=$.getAttribute?.("src")||"",L=X.exec(_);return L?{photoKind:"artboard-img",photoAsset:L[0]}:{}})(),...EJ($)}}var G7=null;function B7(){if(typeof window>"u")return!1;if(G7===null)try{G7=new URLSearchParams(window.location.search).get("ro")==="1"}catch{G7=!1}return G7}import*as L7 from"lib0/decoding";import*as o from"lib0/encoding";import{createContext as bJ,useCallback as V0,useContext as yJ,useEffect as Z0,useMemo as q0,useReducer as G0,useRef as B0,useState as W0}from"react";import{Awareness as z0,applyAwarenessUpdate as U0,encodeAwarenessUpdate as X0}from"y-protocols/awareness";import{readSyncMessage as H0,writeSyncStep1 as F0,writeUpdate as P0}from"y-protocols/sync";import*as vJ from"yjs";import*as wJ from"yjs";var xJ=new WeakSet;function u7(J){return xJ.add(J),J}var sQ=u7(Object.freeze({maudeOrigin:"shell-edit"})),tQ=u7(Object.freeze({maudeOrigin:"sync-agent"}));import{jsx as L0}from"react/jsx-runtime";var CJ=bJ(null);function m7(){return yJ(CJ)}import{createContext as RJ,useCallback as l,useContext as M7,useEffect as SJ,useMemo as hJ,useRef as gJ,useState as fJ}from"react";import{jsx as N7,Fragment as mJ}from"react/jsx-runtime";var W7=RJ(null);function n(J){return J.id?`id:${J.id}`:`sel:${J.selector}`}function d7(J){let Q=[],$=new Set;for(let Z of J){let q=n(Z);if($.has(q))continue;$.add(q),Q.push(Z)}return Q}var pJ=50;function uJ({children:J,postTarget:Q}){let[$,Z]=fJ([]),q=gJ(null),G=l((W)=>{if(q.current)clearTimeout(q.current);q.current=setTimeout(()=>{q.current=null;let P=Q??(typeof window<"u"?window.parent:null);if(!P)return;let H=W.length===0?null:W.length===1?W[0]??null:W;try{P.postMessage({dgn:"select-set",selection:H},"*")}catch{}},pJ)},[Q]);SJ(()=>()=>{if(q.current)clearTimeout(q.current)},[]);let z=l((W)=>{let P=d7(Array.isArray(W)?W:[W]);Z(P),G(P)},[G]),X=l((W)=>{let P=Array.isArray(W)?W:[W];Z((H)=>{let j=d7([...H,...P]);return G(j),j})},[G]),Y=l((W)=>{let P=n(W);Z((H)=>{let j=H.filter((I)=>n(I)!==P);return G(j),j})},[G]),_=l((W)=>{let P=n(W);Z((H)=>{let j=H.some((I)=>n(I)===P)?H.filter((I)=>n(I)!==P):[...H,W];return G(j),j})},[G]),L=l(()=>{Z([]),G([])},[G]),U=hJ(()=>({selected:$,replace:z,add:X,remove:Y,toggle:_,clear:L}),[$,z,X,Y,_,L]);return N7(W7.Provider,{value:U,children:J})}function i7({children:J}){if(M7(W7))return N7(mJ,{children:J});return N7(uJ,{children:J})}function K7(){let J=M7(W7);if(!J)throw Error("useSelectionSet must be used inside <SelectionSetProvider>");return J}function c7(){return M7(W7)}import{jsx as k,jsxs as b,Fragment as $Q}from"react/jsx-runtime";var dJ="/_client/comments-overlay.css";function iJ(){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=dJ,document.head.appendChild(J)}function cJ(){if(typeof window>"u")return null;try{let J=window.location.pathname;if(J==="/_canvas-shell.html"||J==="/_canvas-shell"){let Q=new URLSearchParams(window.location.search),$=Q.get("canvas")??"",Z=(Q.get("designRel")??".design").replace(/^\/+|\/+$/g,"");return $?`${Z}/${$}`:null}return decodeURIComponent(J).replace(/^\//,"")}catch{return null}}function lJ(J){if(!J.selector)return null;let Q=null;try{let $=document.querySelectorAll(J.selector),Z=J.index&&J.index>0&&J.index<$.length?J.index:0;Q=$[Z]??$[0]??null}catch{Q=null}if(Q&&J.tag&&Q.tagName.toLowerCase()!==J.tag.toLowerCase())Q=null;if(!Q&&J.dom_path?.length){let $=J.selector.match(/data-dc-screen="([^"]+)"/)?.[1];Q=p7(document,{artboardId:$,tag:J.tag,classes:J.classes,dom_path:J.dom_path})}return Q}function I7(J){let Q=lJ(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 a7(J,Q){let Z=typeof window<"u"?window.innerWidth:J.x+Q.w,q=typeof window<"u"?window.innerHeight:J.y+Q.h,G=J.x;if(G+Q.w+8>Z){let X=J.x-Q.w;G=X>=8?X:Math.max(8,Z-Q.w-8)}let z=J.y;if(z+Q.h+8>q){let X=J.y-Q.h;z=X>=8?X:Math.max(8,q-Q.h-8)}return{x:G,y:z}}function o7(){iJ();let J=c7(),[Q,$]=u([]),[Z,q]=u(null),[G,z]=u(null),X=s(()=>cJ(),[]);R(()=>{if(typeof document>"u")return;let B=document.getElementById("dgn-pin-layer");if(!B)return;let D=B.style.display;return B.style.display="none",()=>{B.style.display=D}},[]);let Y=T((B)=>{if(!J)return;if(!B?.selector){J.clear();return}let D=B.selector.match(/data-cd-id="([^"]+)"/),N=D?D[1]:void 0,M,A;try{let F=document.querySelector(B.selector);if(F)M=F.tagName.toLowerCase(),A=(F.getAttribute("class")??"").split(/\s+/).filter((O)=>O&&!O.startsWith("dgn-")&&!O.startsWith("dc-cv-")).join(" ")}catch{}J.replace({file:X??void 0,id:N,selector:B.selector,tag:M,classes:A,bounds:B.bounds??void 0})},[J,X]),_=S(Q);_.current=Q;let L=m7();R(()=>{if(!L)return;let B=L.doc.getArray("comments"),D=()=>{$(B.toArray())};if(B.length>0)D();return B.observe(D),()=>{try{B.unobserve(D)}catch{}}},[L]),R(()=>{if(typeof window>"u")return;let B=(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 M=typeof N.id==="string"?N.id:null;q(M);let A=M?_.current.find((F)=>F.id===M):void 0;Y(A)}};return window.addEventListener("message",B),()=>window.removeEventListener("message",B)},[Y]),R(()=>{if(typeof document>"u")return;let B=(D)=>{let N=D.detail;if(!N?.selection)return;z({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",B),()=>document.removeEventListener("cm:open-composer",B)},[]);let U=T(()=>{if(z(null),typeof window>"u")return;try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},[]),W=T((B)=>{if(!G)return;let D=G.selection,N={file:D.file,selector:D.selector,index:D.index,dom_path:D.dom_path,tag:D.tag,classes:D.classes,bounds:D.bounds,html_excerpt:D.html,text:B};if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-submit",payload:N},"*")}catch{}U()},[G,U]);R(()=>{if(!X)return;let B=!1;return(async()=>{try{let D=await fetch(`/_comments?file=${encodeURIComponent(X)}`);if(!D.ok)return;let N=await D.json();if(B)return;if(Array.isArray(N.comments))$((M)=>M.length===0?N.comments??[]:M)}catch{}})(),()=>{B=!0}},[X]);let P=s(()=>{return Q.slice().sort((D,N)=>D.created.localeCompare(N.created)).filter((D)=>D.status!=="resolved")},[Q]),H=s(()=>{let B=new Map;return Q.slice().sort((N,M)=>N.created.localeCompare(M.created)).forEach((N,M)=>{B.set(N.id,M+1)}),B},[Q]),j=T((B)=>{if(q(B),Y(Q.find((D)=>D.id===B)),typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-click",id:B},"*")}catch{}},[Q,Y]),I=T((B,D)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-patch",id:B,patch:D},"*")}catch{}},[]),V=T((B)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-delete",id:B},"*")}catch{}q((D)=>D===B?null:D)},[]),K=T(async(B,D)=>{if(typeof fetch>"u")return!1;try{let N=await fetch(`/_api/comments/${encodeURIComponent(B)}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:D})});if(!N.ok)return!1;let M=await N.json();return $((A)=>A.map((F)=>F.id===M.id?M:F)),!0}catch{return!1}},[]);return b("div",{className:"cm-layer","aria-hidden":!1,children:[P.map((B)=>{let D=H.get(B.id)??0;return k(oJ,{comment:B,sequence:D,focused:Z===B.id,onClick:j,onOrphaned:V},B.id)}),G?k(sJ,{state:G,onSubmit:W,onCancel:U}):null,(()=>{if(!Z)return null;let B=P.find((D)=>D.id===Z);if(!B)return null;return k(tJ,{comment:B,sequence:H.get(B.id)??0,onClose:()=>{q(null),J?.clear()},onPatch:(D)=>I(B.id,D),onDelete:()=>V(B.id),onReply:(D)=>K(B.id,D)})})()]})}var _7=null;async function nJ(){if(!_7)_7=(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 _7}function l7(J){return(J.trim().split(/\s+/)[0]??"").replace(/[^\w.-]/g,"").toLowerCase()}function rJ(J,Q){if(Q<=0||Q>J.length)return null;let $=Q-1;while($>=0){let Z=J[$]??"";if(Z==="@"){let q=$>0?J[$-1]:"";if($===0||/\s/.test(q??"")){let G=J.slice($+1,Q);return{start:$,end:Q,query:G}}return null}if(!/[\w.-]/.test(Z))return null;$-=1}return null}function s7({className:J,value:Q,onChange:$,onKeyDown:Z,placeholder:q,rows:G,disabled:z,textareaRef:X,ariaLabel:Y}){let _=S(null),L=T((F)=>{if(_.current=F,X)X.current=F},[X]),[U,W]=u([]),[P,H]=u(null),[j,I]=u(0),V=T(()=>{if(U.length>0)return;nJ().then((F)=>W(F))},[U.length]),K=s(()=>{if(!P)return[];let F=P.query.toLowerCase();return(!F?U:U.filter((E)=>E.name.toLowerCase().includes(F)||E.email.toLowerCase().includes(F))).slice(0,8)},[P,U]),B=T((F)=>{let O=F.selectionStart??F.value.length,E=rJ(F.value,O);H(E),I(0)},[]),D=T((F)=>{$(F.target.value),B(F.target)},[$,B]),N=T((F)=>{if(!P)return;let O=_.current;if(!O)return;let E=`@${l7(F.name)}`,y=`${Q.slice(0,P.start)}${E} ${Q.slice(P.end)}`;$(y),H(null);let w=P.start+E.length+1;requestAnimationFrame(()=>{O.focus(),O.setSelectionRange(w,w)})},[P,Q,$]),M=T((F)=>{if(P&&K.length>0){if(F.key==="ArrowDown"){F.preventDefault(),I((O)=>(O+1)%K.length);return}if(F.key==="ArrowUp"){F.preventDefault(),I((O)=>(O-1+K.length)%K.length);return}if(F.key==="Enter"||F.key==="Tab"){F.preventDefault();let O=K[j]??K[0];if(O)N(O);return}if(F.key==="Escape"){F.preventDefault(),H(null);return}}Z?.(F)},[P,K,j,N,Z]),A=T((F)=>{B(F.currentTarget)},[B]);return b("div",{style:{position:"relative"},children:[k("textarea",{ref:L,className:J,value:Q,placeholder:q,rows:G,disabled:z,"aria-label":Y,onChange:D,onKeyDown:M,onFocus:V,onSelect:A,onClick:A}),P&&K.length>0?k("ul",{className:"cm-mention-popup",role:"listbox","aria-label":"Mention suggestions",style:{left:0,top:"100%"},children:K.map((F,O)=>{return b("li",{role:"option","aria-selected":O===j,className:"cm-mention-popup__item",onMouseEnter:()=>I(O),onMouseDown:(y)=>{y.preventDefault(),N(F)},children:[b("span",{className:"cm-mention-popup__name",children:["@",l7(F.name)]}),k("span",{className:"cm-mention-popup__email",children:F.email})]},`${F.name}-${F.email}`)})}):null]})}var aJ=3000;function oJ({comment:J,sequence:Q,focused:$,onClick:Z,onOrphaned:q}){let G=S(null),z=S(null),X=S(null);R(()=>{let L=()=>{z.current=null;let U=G.current;if(!U)return;let W=I7(J);if(W)X.current=null;else{if(X.current==null)X.current=Date.now();else if(Date.now()-X.current>aJ)q(J.id);if(J.bounds)W={x:J.bounds.x,y:J.bounds.y,w:J.bounds.w,h:J.bounds.h}}if(!W){U.style.display="none",z.current=requestAnimationFrame(L);return}U.style.display="grid";let P=Math.round(W.x+W.w-12),H=Math.round(W.y-12);U.style.left=`${P}px`,U.style.top=`${H}px`,z.current=requestAnimationFrame(L)};return z.current=requestAnimationFrame(L),()=>{if(z.current!=null)cancelAnimationFrame(z.current)}},[J,q]);let Y=J.author?.trim()||"unknown",_=`Comment ${Q} by ${Y}`;return k("button",{ref:G,type:"button",className:"cm-pin","data-resolved":J.status==="resolved"?"true":"false","data-focused":$?"true":"false","data-comment-pin":J.id,"aria-label":_,"aria-expanded":$,title:J.text.slice(0,200),onClick:(L)=>{L.preventDefault(),L.stopPropagation(),Z(J.id)},children:Q})}function sJ({state:J,onSubmit:Q,onCancel:$}){let[Z,q]=u(""),G=S(null),z=S(null),X=S(null);R(()=>{let U=()=>{X.current=null;let W=z.current;if(!W)return;let P=QQ(J),H=a7(P,{w:W.offsetWidth,h:W.offsetHeight});W.style.left=`${Math.round(H.x)}px`,W.style.top=`${Math.round(H.y)}px`,X.current=requestAnimationFrame(U)};return X.current=requestAnimationFrame(U),()=>{if(X.current!=null)cancelAnimationFrame(X.current)}},[J]),R(()=>{G.current?.focus()},[]);let Y=T(()=>{let U=Z.trim();if(!U)return;Q(U)},[Z,Q]),_=T((U)=>{if(U.key==="Escape"){U.preventDefault(),$();return}if((U.metaKey||U.ctrlKey)&&U.key==="Enter")U.preventDefault(),Y()},[$,Y]),L=s(()=>{let U=J.selection.selector||"";if(!U)return J.selection.tag||"canvas";let W=U.match(/data-cd-id="([^"]+)"/);if(W)return`cd:${W[1]}`;return U.length>36?`${U.slice(0,33)}…`:U},[J.selection]);return b("div",{ref:z,className:"cm-composer",role:"dialog","aria-label":"New comment",onClick:(U)=>U.stopPropagation(),onPointerDown:(U)=>U.stopPropagation(),children:[b("div",{className:"cm-composer__head",children:[k("span",{children:"New comment"}),k("span",{className:"cm-composer__selector",children:L})]}),k(s7,{textareaRef:G,className:"cm-composer__textarea",value:Z,placeholder:"Type a comment. ⌘↵ to save · Esc to cancel · @name to tag",onChange:q,onKeyDown:_,rows:3,ariaLabel:"Comment body"}),b("div",{className:"cm-composer__actions",children:[k("button",{type:"button",className:"cm-btn",onClick:$,children:"Cancel"}),k("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!Z.trim(),onClick:Y,children:"Save"})]})]})}function tJ({comment:J,sequence:Q,onClose:$,onPatch:Z,onDelete:q,onReply:G}){let z=S(null),X=S(null),Y=S(null),[_,L]=u(""),[U,W]=u(!1);R(()=>{let V=()=>{Y.current=null;let K=z.current;if(!K)return;let B=JQ(J),D=a7(B,{w:K.offsetWidth,h:K.offsetHeight});K.style.left=`${Math.round(D.x)}px`,K.style.top=`${Math.round(D.y)}px`,Y.current=requestAnimationFrame(V)};return Y.current=requestAnimationFrame(V),()=>{if(Y.current!=null)cancelAnimationFrame(Y.current)}},[J]),R(()=>{z.current?.focus();let V=J.id;return()=>{document.querySelector(`[data-comment-pin="${V}"]`)?.focus()}},[J.id]),R(()=>{if(typeof document>"u")return;let V=(K)=>{if(K.key!=="Escape")return;let B=z.current;if(!B)return;if(B.contains(K.target)||document.activeElement===B)K.preventDefault(),$()};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[$]);let P=T(async()=>{let V=_.trim();if(!V||U)return;W(!0);let K=await G(V);if(W(!1),K)L(""),X.current?.focus()},[_,U,G]),H=T((V)=>{if((V.metaKey||V.ctrlKey)&&V.key==="Enter")V.preventDefault(),P()},[P]),j=`cm-thread-head-${J.id}`,I=eJ(J.selector,"");return b("div",{ref:z,className:"cm-thread",role:"dialog","aria-labelledby":j,tabIndex:-1,onClick:(V)=>V.stopPropagation(),onPointerDown:(V)=>V.stopPropagation(),children:[b("div",{className:"cm-thread__head",id:j,children:[b("div",{className:"cm-thread__head-row",children:[k("span",{className:"cm-thread__seq","aria-hidden":"true",children:Q}),k("span",{className:"cm-thread__author",children:J.author?.trim()||"unknown"}),k("span",{className:"cm-thread__time",children:r7(J.created)}),k("button",{type:"button",className:"cm-thread__close","aria-label":"Close thread",title:"Close · Esc",onClick:$,children:"×"})]}),I?k("code",{className:"cm-thread__selector",children:I}):null]}),k("div",{className:"cm-thread__body",children:n7(J.text)}),(J.thread??[]).map((V)=>b("div",{className:"cm-thread__reply",children:[b("div",{className:"cm-thread__reply-head",children:[k("span",{className:"cm-thread__reply-author",children:V.author?.trim()||"unknown"}),k("span",{className:"cm-thread__reply-time",children:r7(V.created)})]}),k("div",{className:"cm-thread__reply-body",children:n7(V.body)})]},V.id)),!B7()&&b($Q,{children:[b("div",{className:"cm-thread__reply-form",children:[k(s7,{textareaRef:X,className:"cm-thread__reply-textarea",value:_,placeholder:"Reply… ⌘↵ to send · @name to tag",onChange:L,onKeyDown:H,rows:2,ariaLabel:"Reply",disabled:U}),k("div",{className:"cm-thread__reply-actions",children:k("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!_.trim()||U,onClick:()=>void P(),children:"Send"})})]}),b("div",{className:"cm-thread__actions",children:[J.status==="resolved"?k("button",{type:"button",className:"cm-btn",onClick:()=>Z({status:"open"}),children:"↺ Reopen"}):k("button",{type:"button",className:"cm-btn cm-btn--primary",onClick:()=>{Z({status:"resolved"}),$()},children:"✓ Resolve"}),k("button",{type:"button",className:"cm-btn cm-btn--danger",onClick:()=>{q(),$()},children:"Delete"})]})]})]})}function n7(J){if(!J)return null;let Q=/(@[\w][\w.-]*)/g;return J.split(Q).map((Z,q)=>{let G=`${q}:${Z}`;if(q%2===1)return k("strong",{"data-mention":"true",children:Z},G);return k("span",{children:Z},G)})}function r7(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 eJ(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 JQ(J){let Q=J.selector?I7(J):null;if(Q)return{x:Q.x+Q.w-12,y:Q.y+16};if(J.bounds)return{x:J.bounds.x+J.bounds.w-12,y:J.bounds.y+16};return{x:16,y:16}}function QQ(J){if(J.clientX||J.clientY)return{x:J.clientX,y:J.clientY+8};if(J.selection.selector){let Q=I7(J.selection);if(Q)return{x:Q.x,y:Q.y+Q.h+8}}return{x:16,y:16}}import{useEffect as VQ}from"react";var ZQ=new Set(["pen","highlighter","shape","rect","ellipse","arrow","sticky","text","section","eraser"]);function A7(J){return ZQ.has(J)}var t=(J)=>!!(J.metaKey||J.ctrlKey);function e(J){if(J.type==="keydown"){if(J.isEditable)return{kind:"no-op"};if(J.metaKey||J.ctrlKey||J.altKey){if(J.key==="Escape")return{kind:"escape"};let $=(J.key||"").toLowerCase();if(!J.altKey&&(J.metaKey||J.ctrlKey)){if($==="z"&&J.shiftKey)return{kind:"redo"};if($==="z")return{kind:"undo"};if($==="y"&&!J.shiftKey)return{kind:"redo"}}return{kind:"no-op"}}let Q=(J.key||"").toLowerCase();if(Q==="v")return{kind:"tool",tool:"move"};if(Q==="h")return{kind:"tool",tool:"hand"};if(Q==="c")return{kind:"tool",tool:"comment"};if(Q==="b")return{kind:"tool",tool:"pen"};if(Q==="i")return{kind:"tool",tool:"highlighter"};if(Q==="r"||Q==="o")return{kind:"tool",tool:"shape"};if(Q==="a")return{kind:"tool",tool:"arrow"};if(Q==="n")return{kind:"tool",tool:"sticky"};if(Q==="t")return{kind:"tool",tool:"text"};if(Q==="s"&&J.shiftKey)return{kind:"tool",tool:"section"};if(Q==="e")return{kind:"tool",tool:"eraser"};if(J.key==="Escape")return{kind:"escape"};return{kind:"no-op"}}if(J.type==="contextmenu")return{kind:"context-menu",clientX:J.clientX??0,clientY:J.clientY??0};if(J.type==="pointermove"){if(A7(J.activeTool))return{kind:"no-op"};if(J.activeTool==="hand")return{kind:"no-op"};if(J.activeTool==="browse"){if(!t(J))return{kind:"no-op"};return{kind:"hover",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0}}if(J.activeTool==="comment")return{kind:"hover",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0};return{kind:"hover",deep:t(J),clientX:J.clientX??0,clientY:J.clientY??0}}if(J.type==="pointerdown"){if(J.button===2)return{kind:"context-menu",clientX:J.clientX??0,clientY:J.clientY??0};if(J.button===1||J.spaceHeld)return{kind:"no-op"};if(J.button!==0)return{kind:"no-op"};if(A7(J.activeTool)&&!t(J))return{kind:"no-op"};if(J.activeTool==="comment")return{kind:"drop-comment",clientX:J.clientX??0,clientY:J.clientY??0};if(J.activeTool==="hand")return{kind:"no-op"};if(J.activeTool==="browse"){if(!t(J))return{kind:"no-op"};return{kind:"select",mode:J.shiftKey?"add":"replace",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0}}let Q=t(J);return{kind:"select",mode:!!J.shiftKey?"add":"replace",deep:Q,clientX:J.clientX??0,clientY:J.clientY??0}}return{kind:"no-op"}}function z7(J){if(!J||!J.tagName)return!1;let Q=J,$=Q.tagName;if($==="INPUT"||$==="TEXTAREA"||$==="SELECT")return!0;if(Q.isContentEditable)return!0;let Z=Q.getAttribute?.("contenteditable");if(Z==="true"||Z==="plaintext-only"||Z==="")return!0;return!1}function J7(J){if(!J||!J.closest)return!1;let Q=J;if(Q.closest(".dc-world"))return!1;return!!Q.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mediaref-player], .dc-tool-palette, .dc-zoom-tb, .dc-mm, .dc-context-menu")}function e7(J){if(!J||typeof J.closest!=="function")return!1;let Q=J;return!!Q.closest("[data-dc-screen]")&&!Q.closest(".dc-artboard-body")}function t7(J,Q,$){return J.kind==="select"&&!$.metaKey&&!$.ctrlKey&&e7(Q)}function qQ(J,Q,$){return J==="select"&&!$.metaKey&&!$.ctrlKey&&e7(Q)}function JJ(J){let{hostRef:Q,getActiveTool:$,isSpaceHeld:Z,callbacks:q,enabled:G=!0,claimableActions:z}=J;VQ(()=>{if(!G)return;let X=Q.current;if(!X)return;let Y=(V)=>z&&V.kind!=="no-op"&&!z.has(V.kind)?{kind:"no-op"}:V,_=(V)=>{switch(V.kind){case"hover":q.onHover?.(V);break;case"select":q.onSelect?.(V);break;case"drop-comment":q.onDropComment?.(V);break;case"context-menu":q.onContextMenu?.(V);break;case"tool":q.onTool?.(V);break;case"escape":q.onEscape?.();break;case"undo":q.onUndo?.();break;case"redo":q.onRedo?.();break;case"no-op":break}},L=(V)=>{let K=Y(e({type:"pointermove",button:V.button,metaKey:V.metaKey,ctrlKey:V.ctrlKey,shiftKey:V.shiftKey,altKey:V.altKey,clientX:V.clientX,clientY:V.clientY,spaceHeld:Z?.()??!1,activeTool:$()}));_(K)},U=(V)=>{if(J7(V.target))return;if(z7(V.target))return;let K=Y(e({type:"pointerdown",button:V.button,metaKey:V.metaKey,ctrlKey:V.ctrlKey,shiftKey:V.shiftKey,altKey:V.altKey,clientX:V.clientX,clientY:V.clientY,spaceHeld:Z?.()??!1,activeTool:$()})),B=t7(K,V.target,V);if(K.kind!=="no-op"){if(V.preventDefault(),!B)V.stopImmediatePropagation()}_(K)},W=(V)=>{if(J7(V.target))return;if(z7(V.target))return;let K=Y(e({type:"pointerdown",button:V.button,metaKey:V.metaKey,ctrlKey:V.ctrlKey,shiftKey:V.shiftKey,altKey:V.altKey,clientX:V.clientX,clientY:V.clientY,spaceHeld:Z?.()??!1,activeTool:$()})),B=t7(K,V.target,V);if(K.kind!=="no-op"){if(V.preventDefault(),!B)V.stopImmediatePropagation();if(K.kind==="select")try{window.focus()}catch{}}},P=(V)=>{if(J7(V.target))return;if(z7(V.target))return;let K=$(),B=V.metaKey||V.ctrlKey,D=K==="comment"?"drop-comment":K==="move"&&V.button===0?"select":(A7(K)||K==="browse")&&B&&V.button===0?"select":V.button===2?"context-menu":null;if(D&&(!z||z.has(D))){let N=qQ(D,V.target,V);if(V.preventDefault(),!N)V.stopImmediatePropagation()}},H=(V)=>{let K=Y(e({type:"contextmenu",clientX:V.clientX,clientY:V.clientY,metaKey:V.metaKey,ctrlKey:V.ctrlKey,shiftKey:V.shiftKey,altKey:V.altKey,activeTool:$()}));if(K.kind==="no-op")return;V.preventDefault(),V.stopImmediatePropagation(),_(K)},j=(V)=>{let K=Y(e({type:"keydown",key:V.key,metaKey:V.metaKey,ctrlKey:V.ctrlKey,shiftKey:V.shiftKey,altKey:V.altKey,isEditable:z7(V.target),activeTool:$()}));if(K.kind==="tool"||K.kind==="escape"||K.kind==="undo"||K.kind==="redo")V.preventDefault();_(K)};X.addEventListener("pointermove",L,{passive:!0}),X.addEventListener("pointerdown",U,{capture:!0}),X.addEventListener("mousedown",W,{capture:!0}),X.addEventListener("click",P,{capture:!0}),X.addEventListener("contextmenu",H,{capture:!0});let I=X.ownerDocument??document;return I.addEventListener("keydown",j,!0),()=>{X.removeEventListener("pointermove",L),X.removeEventListener("pointerdown",U,{capture:!0}),X.removeEventListener("mousedown",W,{capture:!0}),X.removeEventListener("click",P,{capture:!0}),X.removeEventListener("contextmenu",H,{capture:!0}),I.removeEventListener("keydown",j,!0)}},[G,Q,$,Z,q,z])}function O7(J,Q,$,Z){let q=J.elementFromPoint(Q,$);if(!q)return null;if(q.closest?.(".dc-mm, .dc-zoom-tb, .dc-tool-palette, .dc-context-menu, .dc-cv-group-bbox"))return null;let G=q.closest?.("[data-dc-screen]")??null,z=G?.getAttribute("data-dc-screen")??null,X=q.closest?.(".dc-artboard-body")??null;if(!X){if(G&&z)return{el:G,cdId:null,artboardId:z};return null}if(q===X){if(G&&z)return{el:G,cdId:null,artboardId:z};return null}if(Z.deep){let W=q.getAttribute?.("data-cd-id")??null;return{el:q,cdId:W,artboardId:z}}let Y=q,_=null;while(Y&&Y!==X){if(Y.hasAttribute?.("data-cd-id"))_=Y;Y=Y.parentElement}let L=_??q,U=L.getAttribute?.("data-cd-id")??null;return{el:L,cdId:U,artboardId:z}}import{useCallback as _Q,useEffect as WJ,useRef as Y7}from"react";var GQ=!1;function QJ(){return GQ}import{createContext as FQ,useCallback as $7,useContext as GJ,useEffect as PQ,useMemo as VJ,useState as U7}from"react";function m(J,Q,$,Z){return`url("data:image/svg+xml,${encodeURIComponent(J.trim())}") ${Q} ${$}, ${Z}`}var T7="width='24' height='24' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'",E7="#1f1f1f",k7="stroke='#ffffff' stroke-linejoin='round' stroke-linecap='round'";function i(J,Q,$){let Z=$?`<g transform='${$}'>`:"";return`<svg ${T7}>${Z}<path fill='#ffffff' d='${J}'/><path fill='${E7}' d='${Q}'/>${$?"</g>":""}</svg>`}var $J="translate(0,32) scale(1,-1)",BQ=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"),WQ=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"),KQ=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"),zQ=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",$J),6,18,"crosshair"),UQ=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",$J),6,18,"crosshair"),Q7=m(i("M17 2 Q18.2 2 19.15 2.9 20 3.8 20 5 L20 12 27 12 Q28.2 12 29.15 12.9 30 13.8 30 15 L30 17 Q30 18.2 29.15 19.15 28.2 20 27 20 L20 20 20 27 Q20 28.2 19.15 29.15 18.2 30 17 30 L15 30 Q13.8 30 12.9 29.15 12 28.2 12 27 L12 20 5 20 Q3.8 20 2.9 19.15 2 18.2 2 17 L2 15 Q2 13.8 2.9 12.9 3.8 12 5 12 L12 12 12 5 Q12 3.8 12.9 2.9 13.8 2 15 2 L17 2 M14 27 L14.3 27.7 Q14.6 28 15 28 L17 28 17.7 27.7 18 27 18 18.05 18.05 18 27 18 Q27.4 18 27.7 17.7 L28 17 28 15 27.7 14.3 Q27.4 14 27 14 L18 14 18 5 17.7 4.3 17 4 15 4 Q14.6 4 14.3 4.3 14 4.6 14 5 L14 14 5 14 Q4.6 14 4.3 14.3 4 14.6 4 15 L4 17 Q4 17.4 4.3 17.7 4.6 18 5 18 L14 18 14 27","M14 27 L14 18 5 18 Q4.6 18 4.3 17.7 4 17.4 4 17 L4 15 Q4 14.6 4.3 14.3 4.6 14 5 14 L14 14 14 5 Q14 4.6 14.3 4.3 14.6 4 15 4 L17 4 17.7 4.3 18 5 18 14 27 14 Q27.4 14 27.7 14.3 L28 15 28 17 27.7 17.7 Q27.4 18 27 18 L18.05 18 18 18.05 18 27 17.7 27.7 17 28 15 28 Q14.6 28 14.3 27.7 L14 27"),12,12,"crosshair"),XQ=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"),YQ=m(`<svg ${T7}><path d='M16 4V28M11 4H21M11 28H21' fill='none' ${k7} stroke-width='5'/><path d='M16 4V28M11 4H21M11 28H21' fill='none' stroke='${E7}' stroke-width='2.25' stroke-linecap='round'/></svg>`,12,12,"text"),HQ=m(`<svg ${T7}><path d='M6 5H21L26 10V27H6Z' fill='${E7}' ${k7} stroke-width='2.5'/><path d='M21 5V11H26' fill='none' ${k7} stroke-width='2.25'/></svg>`,5,5,"crosshair"),C=Object.freeze({browse:"default",move:BQ,hand:WQ,comment:KQ,pen:zQ,section:Q7,highlighter:UQ,shape:Q7,rect:Q7,ellipse:Q7,sticky:HQ,arrow:Q7,text:YQ,eraser:XQ});import{jsx as w7,Fragment as MQ}from"react/jsx-runtime";var ZJ=Object.freeze({preview:"browse",edit:"move"});function qJ(J){if(J==="browse")return"preview";if(J==="move")return"edit";return null}var DQ=Object.freeze([{id:"browse",label:"Browse",shortcut:"",cursor:C.browse},{id:"move",label:"Select",shortcut:"V",cursor:C.move},{id:"hand",label:"Hand",shortcut:"H",cursor:C.hand},{id:"comment",label:"Comment",shortcut:"C",cursor:C.comment},{id:"pen",label:"Pen",shortcut:"B",cursor:C.pen},{id:"highlighter",label:"Highlighter",shortcut:"I",cursor:C.highlighter},{id:"shape",label:"Shape",shortcut:"R",cursor:C.shape},{id:"sticky",label:"Sticky",shortcut:"N",cursor:C.sticky},{id:"section",label:"Section",shortcut:"⇧S",cursor:C.shape},{id:"arrow",label:"Arrow",shortcut:"A",cursor:C.arrow},{id:"text",label:"Text",shortcut:"T",cursor:C.text},{id:"eraser",label:"Eraser",shortcut:"E",cursor:C.eraser}]),jQ=new Set(["browse","move","hand"]);function LQ(J,Q){return Q?J.filter(($)=>jQ.has($.id)):J}var x7=FQ(null);function NQ({children:J,tools:Q=DQ,initial:$,initialMode:Z}){let q=B7(),G=VJ(()=>LQ(Q,q),[Q,q]),z=$??(q?"browse":"move"),X=Z??qJ(z)??(q?"preview":"edit"),[Y,_]=U7(z),[L,U]=U7(X),[W,P]=U7(()=>({tool:null,locked:!1})),H=$7((M)=>{if(!G.some((F)=>F.id===M))return;_(M);let A=qJ(M);if(A)U(A);P((F)=>F.locked&&F.tool===M?F:{tool:null,locked:!1})},[G]),j=$7((M)=>{let A=ZJ[M];if(!G.some((F)=>F.id===A))return;U(M),_(A),P((F)=>F.locked&&F.tool===A?F:{tool:null,locked:!1})},[G]),I=$7(()=>{H(ZJ[L])},[L,H]),V=$7((M)=>{P((A)=>{if(A.locked&&A.tool===M)return{tool:null,locked:!1};return{tool:M,locked:!0}}),_(M)},[]),K=$7(()=>{P({tool:null,locked:!1})},[]),[B,D]=U7("rounded");PQ(()=>{if(typeof document>"u")return;let M=G.find((O)=>O.id===Y);if(!M)return;let A=document.body.style.cursor,F=document.getElementById("dc-tool-cursor");if(!F)F=document.createElement("style"),F.id="dc-tool-cursor",document.head.appendChild(F);if(Y==="browse"){if(document.body.style.cursor="",F.textContent="",typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:Y},"*")}catch{}return()=>{document.body.style.cursor=A}}if(document.body.style.cursor=M.cursor,F.textContent=`* { cursor: ${M.cursor} !important; }`,typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:Y},"*")}catch{}return()=>{document.body.style.cursor=A;let O=document.getElementById("dc-tool-cursor");if(O)O.textContent=""}},[Y,G]);let N=VJ(()=>({tool:Y,setTool:H,tools:G,mode:L,setMode:j,resetTool:I,sticky:W,toggleSticky:V,clearSticky:K,shapeKind:B,setShapeKind:D}),[Y,H,G,L,j,I,W,V,K,B]);return w7(x7.Provider,{value:N,children:J})}function BJ({children:J,initial:Q,initialMode:$}){if(GJ(x7))return w7(MQ,{children:J});return w7(NQ,{initial:Q,initialMode:$,children:J})}function X7(){let J=GJ(x7);if(!J)throw Error("useToolMode must be used inside <ToolProvider>");return J}import{jsx as CQ}from"react/jsx-runtime";var IQ=`
1
+ import{Component as SQ,createElement as x7,useCallback as b7,useEffect as f,useMemo as gQ,useRef as p,useState as $7}from"react";import{createRoot as hQ}from"react-dom/client";import{useCallback as k,useEffect as S,useMemo as o,useRef as g,useState as u}from"react";function F7(){if(typeof window>"u")return;try{let J=window.location.pathname;if(J==="/_canvas-shell.html"||J==="/_canvas-shell"){let Q=new URLSearchParams(window.location.search),$=Q.get("canvas")??"",Z=(Q.get("designRel")??".design").replace(/^\/+|\/+$/g,"");return $?`${Z}/${$}`:void 0}return decodeURIComponent(J).replace(/^\//,"")}catch{return}}function Z7(J){if(!J)return"";return(J.getAttribute("class")??"").trim().split(/\s+/).filter((Q)=>Q&&!Q.startsWith("dgn-")&&!Q.startsWith("dc-cv-")).join(" ")}function AJ(J,Q){if(!J)return"";let $=(J.innerText||J.textContent||"").replace(/\s+/g," ").trim();return $.length>Q?`${$.slice(0,Q-1)}…`:$}function OJ(J){if(!J)return"";let Q=[],$=J;while($&&$.nodeType===1&&Q.length<8){let Z=$.getAttribute?.("data-dc-element");if(Z){Q.unshift(`[data-dc-element="${Z}"]`);break}let q=$.getAttribute?.("data-dc-screen");if(q){Q.unshift(`[data-dc-screen="${q}"]`);break}let G=$.nodeName.toLowerCase();if($.id){G=`#${$.id}`,Q.unshift(G);break}let z=Z7($).split(/\s+/).filter(Boolean).slice(0,2);if(z.length)G+=`.${z.join(".")}`;let X=1,Y=$.previousElementSibling;while(Y)X++,Y=Y.previousElementSibling;G+=`:nth-child(${X})`,Q.unshift(G),$=$.parentElement}return Q.join(" > ")}function S7(J){let Q=[],$=J;while($&&$.nodeType===1&&Q.length<8){let Z=$.nodeName.toLowerCase(),q=$.getAttribute?.("data-dc-element"),G=$.getAttribute?.("data-dc-screen");if(q)Z+=`[data-dc-element="${q}"]`;else if(G)Z+=`[data-dc-screen="${G}"]`;else if($.id)Z+=`#${$.id}`;let z=Z7($).split(/\s+/).filter(Boolean).slice(0,2);if(z.length&&!q&&!G)Z+=`.${z.join(".")}`;Q.unshift(Z),$=$.parentElement}return Q}function EJ(J){return J.replace(/[^a-zA-Z0-9_-]/g,(Q)=>`\\${Q}`)}function g7(J,Q){return Q?`[data-dc-screen="${Q}"] [data-cd-id="${J}"]`:`[data-cd-id="${J}"]`}function h7(J,Q,$){if(!$)return 0;try{let Z=J.querySelectorAll(Q);for(let q=0;q<Z.length;q++)if(Z[q]===$)return q}catch{}return 0}function f7(J,Q,$){if(!Q||!$)return 0;return h7(J,`[data-cd-id="${EJ(Q)}"]`,$)}function P7(J,Q){let $=(Z)=>{try{let q=J.querySelectorAll(Z);if(!q.length)return null;let G=Q.index&&Q.index>0&&Q.index<q.length?Q.index:0;return q[G]??q[0]}catch{return null}};if(Q.id){let Z=$(g7(Q.id,Q.artboardId));if(Z)return Z}if(Q.selector)return $(Q.selector);return null}function kJ(J,Q){let $=0,Z=Math.min(J.length,Q.length);for(let q=1;q<=Z;q++){if(J[J.length-q]!==Q[Q.length-q])break;$++}return $}function p7(J,Q){let $=Q.dom_path,Z=(Q.tag||"").toLowerCase();if(!$||$.length===0||!Z)return null;let q=J;if(Q.artboardId){let Y=J.querySelector(`[data-dc-screen="${Q.artboardId}"]`);if(Y)q=Y}let G=(Q.classes||"").split(/\s+/).filter(Boolean),z=null,X=0;for(let Y of Array.from(q.querySelectorAll("[data-cd-id]"))){if(Y.tagName.toLowerCase()!==Z)continue;let _=kJ(S7(Y),$);if(_===0)continue;let j=Z7(Y).split(/\s+/).filter(Boolean),U=G.filter((P)=>j.includes(P)).length,W=_*10+U;if(W>X)X=W,z=Y}return z}var R7=["display","flex-direction","flex-wrap","align-items","justify-content","gap","flex","flex-grow","flex-shrink","flex-basis","align-self","font-family","color","font-size","font-weight","line-height","letter-spacing","text-align","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","width","height","min-width","min-height","max-width","max-height","background-color","border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius","border-width","border-style","border-color","box-shadow","opacity","position","top","right","bottom","left","z-index","transform","transform-origin","font-style","text-transform","text-decoration","white-space","overflow","object-fit","aspect-ratio","object-position"],TJ=/^(style|class|data-cd-id|data-dc-|data-dcid$)/;function wJ(J){if(!J||typeof window>"u"||!window.getComputedStyle)return{authored:{},computed:{},customStyles:{},attrs:{}};try{let Q=J.style,$=window.getComputedStyle(J),Z={},q={},G=new Set(R7);for(let W of R7){let P=Q.getPropertyValue(W);if(P)Z[W]=P.trim();let H=$.getPropertyValue(W);if(H)q[W]=H.trim()}let z=/^(margin|padding|border)(-|$)/,X={};for(let W=0;W<Q.length;W++){let P=Q.item(W);if(!P||G.has(P)||z.test(P))continue;let H=Q.getPropertyValue(P);if(H)X[P]=H.trim()}let Y={};for(let W of Array.from(J.attributes)){if(TJ.test(W.name))continue;Y[W.name]=W.value}if(J.hasAttribute("data-dc-screen")){for(let W of Array.from(J.attributes))if(W.name.startsWith("data-dc-")&&W.name!=="data-dcid")Y[W.name]=W.value}let _=J.parentElement,j=_?window.getComputedStyle(_).display:"",U=_&&(j==="flex"||j==="inline-flex")?window.getComputedStyle(_).flexDirection:"";return{authored:Z,computed:q,customStyles:X,attrs:Y,parentDisplay:j,parentFlexDirection:U}}catch{return{authored:{},computed:{},customStyles:{},attrs:{}}}}function D7(J,Q){let $=J.el,Z=$&&$.getBoundingClientRect?$.getBoundingClientRect():null,q=J.cdId,G=q?g7(q,J.artboardId):J.artboardId?`[data-dc-screen="${J.artboardId}"]`:OJ($),z=q&&typeof document<"u"?h7(document,G,$):0;return{file:Q??F7(),id:q??void 0,selector:G,artboardId:J.artboardId,index:z,tag:$?.tagName.toLowerCase()??"",classes:Z7($),text:AJ($,240),dom_path:S7($),bounds:Z?{x:Math.round(Z.left),y:Math.round(Z.top),w:Math.round(Z.width),h:Math.round(Z.height)}:null,worldW:$ instanceof HTMLElement?Math.round($.offsetWidth):void 0,worldH:$ instanceof HTMLElement?Math.round($.offsetHeight):void 0,html:$?($.outerHTML??"").slice(0,4000):"",...(()=>{if($?.tagName?.toLowerCase()!=="img")return{};let X=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,Y=$.getAttribute?.("data-photo-asset");if(Y&&X.test(Y))return{photoKind:"artboard-img",photoAsset:Y};let _=$.getAttribute?.("src")||"",j=X.exec(_);return j?{photoKind:"artboard-img",photoAsset:j[0]}:{}})(),...wJ($)}}var q7=null;function G7(){if(typeof window>"u")return!1;if(q7===null)try{q7=new URLSearchParams(window.location.search).get("ro")==="1"}catch{q7=!1}return q7}import*as L7 from"lib0/decoding";import*as a from"lib0/encoding";import{createContext as yJ,useCallback as V0,useContext as vJ,useEffect as Z0,useMemo as q0,useReducer as G0,useRef as B0,useState as W0}from"react";import{Awareness as z0,applyAwarenessUpdate as U0,encodeAwarenessUpdate as X0}from"y-protocols/awareness";import{readSyncMessage as H0,writeSyncStep1 as F0,writeUpdate as P0}from"y-protocols/sync";import*as CJ from"yjs";import*as bJ from"yjs";var xJ=new WeakSet;function u7(J){return xJ.add(J),J}var sQ=u7(Object.freeze({maudeOrigin:"shell-edit"})),tQ=u7(Object.freeze({maudeOrigin:"sync-agent"}));import{jsx as j0}from"react/jsx-runtime";var RJ=yJ(null);function m7(){return vJ(RJ)}import{createContext as SJ,useCallback as l,useContext as N7,useEffect as gJ,useMemo as hJ,useRef as fJ,useState as pJ}from"react";import{jsx as j7,Fragment as dJ}from"react/jsx-runtime";var B7=SJ(null);function n(J){return J.id?`id:${J.id}`:`sel:${J.selector}`}function d7(J){let Q=[],$=new Set;for(let Z of J){let q=n(Z);if($.has(q))continue;$.add(q),Q.push(Z)}return Q}var uJ=50;function mJ({children:J,postTarget:Q}){let[$,Z]=pJ([]),q=fJ(null),G=l((W)=>{if(q.current)clearTimeout(q.current);q.current=setTimeout(()=>{q.current=null;let P=Q??(typeof window<"u"?window.parent:null);if(!P)return;let H=W.length===0?null:W.length===1?W[0]??null:W;try{P.postMessage({dgn:"select-set",selection:H},"*")}catch{}},uJ)},[Q]);gJ(()=>()=>{if(q.current)clearTimeout(q.current)},[]);let z=l((W)=>{let P=d7(Array.isArray(W)?W:[W]);Z(P),G(P)},[G]),X=l((W)=>{let P=Array.isArray(W)?W:[W];Z((H)=>{let L=d7([...H,...P]);return G(L),L})},[G]),Y=l((W)=>{let P=n(W);Z((H)=>{let L=H.filter((I)=>n(I)!==P);return G(L),L})},[G]),_=l((W)=>{let P=n(W);Z((H)=>{let L=H.some((I)=>n(I)===P)?H.filter((I)=>n(I)!==P):[...H,W];return G(L),L})},[G]),j=l(()=>{Z([]),G([])},[G]),U=hJ(()=>({selected:$,replace:z,add:X,remove:Y,toggle:_,clear:j}),[$,z,X,Y,_,j]);return j7(B7.Provider,{value:U,children:J})}function c7({children:J}){if(N7(B7))return j7(dJ,{children:J});return j7(mJ,{children:J})}function W7(){let J=N7(B7);if(!J)throw Error("useSelectionSet must be used inside <SelectionSetProvider>");return J}function i7(){return N7(B7)}import{jsx as E,jsxs as x,Fragment as VQ}from"react/jsx-runtime";var cJ="/_client/comments-overlay.css";function iJ(){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 lJ(){if(typeof window>"u")return null;try{let J=window.location.pathname;if(J==="/_canvas-shell.html"||J==="/_canvas-shell"){let Q=new URLSearchParams(window.location.search),$=Q.get("canvas")??"",Z=(Q.get("designRel")??".design").replace(/^\/+|\/+$/g,"");return $?`${Z}/${$}`:null}return decodeURIComponent(J).replace(/^\//,"")}catch{return null}}function nJ(J){if(!J.selector)return null;let Q=null;try{let $=document.querySelectorAll(J.selector),Z=J.index&&J.index>0&&J.index<$.length?J.index:0;Q=$[Z]??$[0]??null}catch{Q=null}if(Q&&J.tag&&Q.tagName.toLowerCase()!==J.tag.toLowerCase())Q=null;if(!Q&&J.dom_path?.length){let $=J.selector.match(/data-dc-screen="([^"]+)"/)?.[1];Q=p7(document,{artboardId:$,tag:J.tag,classes:J.classes,dom_path:J.dom_path})}return Q}function _7(J){let Q=nJ(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 a7(J,Q){let Z=typeof window<"u"?window.innerWidth:J.x+Q.w,q=typeof window<"u"?window.innerHeight:J.y+Q.h,G=J.x;if(G+Q.w+8>Z){let X=J.x-Q.w;G=X>=8?X:Math.max(8,Z-Q.w-8)}let z=J.y;if(z+Q.h+8>q){let X=J.y-Q.h;z=X>=8?X:Math.max(8,q-Q.h-8)}return{x:G,y:z}}function o7(){iJ();let J=i7(),[Q,$]=u([]),[Z,q]=u(null),[G,z]=u(null),X=o(()=>lJ(),[]);S(()=>{if(typeof document>"u")return;let B=document.getElementById("dgn-pin-layer");if(!B)return;let D=B.style.display;return B.style.display="none",()=>{B.style.display=D}},[]);let Y=k((B)=>{if(!J)return;if(!B?.selector){J.clear();return}let D=B.selector.match(/data-cd-id="([^"]+)"/),N=D?D[1]:void 0,M,A;try{let F=document.querySelector(B.selector);if(F)M=F.tagName.toLowerCase(),A=(F.getAttribute("class")??"").split(/\s+/).filter((O)=>O&&!O.startsWith("dgn-")&&!O.startsWith("dc-cv-")).join(" ")}catch{}J.replace({file:X??void 0,id:N,selector:B.selector,tag:M,classes:A,bounds:B.bounds??void 0})},[J,X]),_=g(Q);_.current=Q;let j=m7();S(()=>{if(!j)return;let B=j.doc.getArray("comments"),D=()=>{$(B.toArray())};if(B.length>0)D();return B.observe(D),()=>{try{B.unobserve(D)}catch{}}},[j]),S(()=>{if(typeof window>"u")return;let B=(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 M=typeof N.id==="string"?N.id:null;q(M);let A=M?_.current.find((F)=>F.id===M):void 0;Y(A)}};return window.addEventListener("message",B),()=>window.removeEventListener("message",B)},[Y]),S(()=>{if(typeof document>"u")return;let B=(D)=>{let N=D.detail;if(!N?.selection)return;z({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",B),()=>document.removeEventListener("cm:open-composer",B)},[]);let U=k(()=>{if(z(null),typeof window>"u")return;try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},[]),W=k((B)=>{if(!G)return;let D=G.selection,N={file:D.file,selector:D.selector,index:D.index,dom_path:D.dom_path,tag:D.tag,classes:D.classes,bounds:D.bounds,html_excerpt:D.html,text:B};if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-submit",payload:N},"*")}catch{}U()},[G,U]);S(()=>{if(!X)return;let B=!1;return(async()=>{try{let D=await fetch(`/_comments?file=${encodeURIComponent(X)}`);if(!D.ok)return;let N=await D.json();if(B)return;if(Array.isArray(N.comments))$((M)=>M.length===0?N.comments??[]:M)}catch{}})(),()=>{B=!0}},[X]);let P=o(()=>{return Q.slice().sort((D,N)=>D.created.localeCompare(N.created)).filter((D)=>D.status!=="resolved")},[Q]),H=o(()=>{let B=new Map;return Q.slice().sort((N,M)=>N.created.localeCompare(M.created)).forEach((N,M)=>{B.set(N.id,M+1)}),B},[Q]),L=k((B)=>{if(q(B),Y(Q.find((D)=>D.id===B)),typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-click",id:B},"*")}catch{}},[Q,Y]),I=k((B,D)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-patch",id:B,patch:D},"*")}catch{}},[]),V=k((B)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-delete",id:B},"*")}catch{}q((D)=>D===B?null:D)},[]),K=k(async(B,D)=>{if(typeof fetch>"u")return!1;try{let N=await fetch(`/_api/comments/${encodeURIComponent(B)}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:D})});if(!N.ok)return!1;let M=await N.json();return $((A)=>A.map((F)=>F.id===M.id?M:F)),!0}catch{return!1}},[]);return x("div",{className:"cm-layer","aria-hidden":!1,children:[P.map((B)=>{let D=H.get(B.id)??0;return E(sJ,{comment:B,sequence:D,focused:Z===B.id,onClick:L,onOrphaned:V},B.id)}),G?E(tJ,{state:G,onSubmit:W,onCancel:U}):null,(()=>{if(!Z)return null;let B=P.find((D)=>D.id===Z);if(!B)return null;return E(eJ,{comment:B,sequence:H.get(B.id)??0,onClose:()=>{q(null),J?.clear()},onPatch:(D)=>I(B.id,D),onDelete:()=>V(B.id),onReply:(D)=>K(B.id,D)})})()]})}var M7=null;async function rJ(){if(!M7)M7=(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 M7}function l7(J){return(J.trim().split(/\s+/)[0]??"").replace(/[^\w.-]/g,"").toLowerCase()}function aJ(J,Q){if(Q<=0||Q>J.length)return null;let $=Q-1;while($>=0){let Z=J[$]??"";if(Z==="@"){let q=$>0?J[$-1]:"";if($===0||/\s/.test(q??"")){let G=J.slice($+1,Q);return{start:$,end:Q,query:G}}return null}if(!/[\w.-]/.test(Z))return null;$-=1}return null}function s7({className:J,value:Q,onChange:$,onKeyDown:Z,placeholder:q,rows:G,disabled:z,textareaRef:X,ariaLabel:Y}){let _=g(null),j=k((F)=>{if(_.current=F,X)X.current=F},[X]),[U,W]=u([]),[P,H]=u(null),[L,I]=u(0),V=k(()=>{if(U.length>0)return;rJ().then((F)=>W(F))},[U.length]),K=o(()=>{if(!P)return[];let F=P.query.toLowerCase();return(!F?U:U.filter((T)=>T.name.toLowerCase().includes(F)||T.email.toLowerCase().includes(F))).slice(0,8)},[P,U]),B=k((F)=>{let O=F.selectionStart??F.value.length,T=aJ(F.value,O);H(T),I(0)},[]),D=k((F)=>{$(F.target.value),B(F.target)},[$,B]),N=k((F)=>{if(!P)return;let O=_.current;if(!O)return;let T=`@${l7(F.name)}`,y=`${Q.slice(0,P.start)}${T} ${Q.slice(P.end)}`;$(y),H(null);let w=P.start+T.length+1;requestAnimationFrame(()=>{O.focus(),O.setSelectionRange(w,w)})},[P,Q,$]),M=k((F)=>{if(P&&K.length>0){if(F.key==="ArrowDown"){F.preventDefault(),I((O)=>(O+1)%K.length);return}if(F.key==="ArrowUp"){F.preventDefault(),I((O)=>(O-1+K.length)%K.length);return}if(F.key==="Enter"||F.key==="Tab"){F.preventDefault();let O=K[L]??K[0];if(O)N(O);return}if(F.key==="Escape"){F.preventDefault(),H(null);return}}Z?.(F)},[P,K,L,N,Z]),A=k((F)=>{B(F.currentTarget)},[B]);return x("div",{style:{position:"relative"},children:[E("textarea",{ref:j,className:J,value:Q,placeholder:q,rows:G,disabled:z,"aria-label":Y,onChange:D,onKeyDown:M,onFocus:V,onSelect:A,onClick:A}),P&&K.length>0?E("ul",{className:"cm-mention-popup",role:"listbox","aria-label":"Mention suggestions",style:{left:0,top:"100%"},children:K.map((F,O)=>{return x("li",{role:"option","aria-selected":O===L,className:"cm-mention-popup__item",onMouseEnter:()=>I(O),onMouseDown:(y)=>{y.preventDefault(),N(F)},children:[x("span",{className:"cm-mention-popup__name",children:["@",l7(F.name)]}),E("span",{className:"cm-mention-popup__email",children:F.email})]},`${F.name}-${F.email}`)})}):null]})}var oJ=3000;function sJ({comment:J,sequence:Q,focused:$,onClick:Z,onOrphaned:q}){let G=g(null),z=g(null),X=g(null);S(()=>{let j=()=>{z.current=null;let U=G.current;if(!U)return;let W=_7(J);if(W)X.current=null;else{if(X.current==null)X.current=Date.now();else if(Date.now()-X.current>oJ)q(J.id);if(J.bounds)W={x:J.bounds.x,y:J.bounds.y,w:J.bounds.w,h:J.bounds.h}}if(!W){U.style.display="none",z.current=requestAnimationFrame(j);return}U.style.display="grid";let P=Math.round(W.x+W.w-12),H=Math.round(W.y-12);U.style.left=`${P}px`,U.style.top=`${H}px`,z.current=requestAnimationFrame(j)};return z.current=requestAnimationFrame(j),()=>{if(z.current!=null)cancelAnimationFrame(z.current)}},[J,q]);let Y=J.author?.trim()||"unknown",_=`Comment ${Q} by ${Y}`;return E("button",{ref:G,type:"button",className:"cm-pin","data-resolved":J.status==="resolved"?"true":"false","data-focused":$?"true":"false","data-comment-pin":J.id,"aria-label":_,"aria-expanded":$,title:J.text.slice(0,200),onClick:(j)=>{j.preventDefault(),j.stopPropagation(),Z(J.id)},children:Q})}function tJ({state:J,onSubmit:Q,onCancel:$}){let[Z,q]=u(""),G=g(null),z=g(null),X=g(null);S(()=>{let U=()=>{X.current=null;let W=z.current;if(!W)return;let P=$Q(J),H=a7(P,{w:W.offsetWidth,h:W.offsetHeight});W.style.left=`${Math.round(H.x)}px`,W.style.top=`${Math.round(H.y)}px`,X.current=requestAnimationFrame(U)};return X.current=requestAnimationFrame(U),()=>{if(X.current!=null)cancelAnimationFrame(X.current)}},[J]),S(()=>{G.current?.focus()},[]);let Y=k(()=>{let U=Z.trim();if(!U)return;Q(U)},[Z,Q]),_=k((U)=>{if(U.key==="Escape"){U.preventDefault(),$();return}if((U.metaKey||U.ctrlKey)&&U.key==="Enter")U.preventDefault(),Y()},[$,Y]),j=o(()=>{let U=J.selection.selector||"";if(!U)return J.selection.tag||"canvas";let W=U.match(/data-cd-id="([^"]+)"/);if(W)return`cd:${W[1]}`;return U.length>36?`${U.slice(0,33)}…`:U},[J.selection]);return x("div",{ref:z,className:"cm-composer",role:"dialog","aria-label":"New comment",onClick:(U)=>U.stopPropagation(),onPointerDown:(U)=>U.stopPropagation(),children:[x("div",{className:"cm-composer__head",children:[E("span",{children:"New comment"}),E("span",{className:"cm-composer__selector",children:j})]}),E(s7,{textareaRef:G,className:"cm-composer__textarea",value:Z,placeholder:"Type a comment. ⌘↵ to save · Esc to cancel · @name to tag",onChange:q,onKeyDown:_,rows:3,ariaLabel:"Comment body"}),x("div",{className:"cm-composer__actions",children:[E("button",{type:"button",className:"cm-btn",onClick:$,children:"Cancel"}),E("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!Z.trim(),onClick:Y,children:"Save"})]})]})}function eJ({comment:J,sequence:Q,onClose:$,onPatch:Z,onDelete:q,onReply:G}){let z=g(null),X=g(null),Y=g(null),[_,j]=u(""),[U,W]=u(!1);S(()=>{let V=()=>{Y.current=null;let K=z.current;if(!K)return;let B=QQ(J),D=a7(B,{w:K.offsetWidth,h:K.offsetHeight});K.style.left=`${Math.round(D.x)}px`,K.style.top=`${Math.round(D.y)}px`,Y.current=requestAnimationFrame(V)};return Y.current=requestAnimationFrame(V),()=>{if(Y.current!=null)cancelAnimationFrame(Y.current)}},[J]),S(()=>{z.current?.focus();let V=J.id;return()=>{document.querySelector(`[data-comment-pin="${V}"]`)?.focus()}},[J.id]),S(()=>{if(typeof document>"u")return;let V=(K)=>{if(K.key!=="Escape")return;let B=z.current;if(!B)return;if(B.contains(K.target)||document.activeElement===B)K.preventDefault(),$()};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[$]);let P=k(async()=>{let V=_.trim();if(!V||U)return;W(!0);let K=await G(V);if(W(!1),K)j(""),X.current?.focus()},[_,U,G]),H=k((V)=>{if((V.metaKey||V.ctrlKey)&&V.key==="Enter")V.preventDefault(),P()},[P]),L=`cm-thread-head-${J.id}`,I=JQ(J.selector,"");return x("div",{ref:z,className:"cm-thread",role:"dialog","aria-labelledby":L,tabIndex:-1,onClick:(V)=>V.stopPropagation(),onPointerDown:(V)=>V.stopPropagation(),children:[x("div",{className:"cm-thread__head",id:L,children:[x("div",{className:"cm-thread__head-row",children:[E("span",{className:"cm-thread__seq","aria-hidden":"true",children:Q}),E("span",{className:"cm-thread__author",children:J.author?.trim()||"unknown"}),E("span",{className:"cm-thread__time",children:r7(J.created)}),E("button",{type:"button",className:"cm-thread__close","aria-label":"Close thread",title:"Close · Esc",onClick:$,children:"×"})]}),I?E("code",{className:"cm-thread__selector",children:I}):null]}),E("div",{className:"cm-thread__body",children:n7(J.text)}),(J.thread??[]).map((V)=>x("div",{className:"cm-thread__reply",children:[x("div",{className:"cm-thread__reply-head",children:[E("span",{className:"cm-thread__reply-author",children:V.author?.trim()||"unknown"}),E("span",{className:"cm-thread__reply-time",children:r7(V.created)})]}),E("div",{className:"cm-thread__reply-body",children:n7(V.body)})]},V.id)),!G7()&&x(VQ,{children:[x("div",{className:"cm-thread__reply-form",children:[E(s7,{textareaRef:X,className:"cm-thread__reply-textarea",value:_,placeholder:"Reply… ⌘↵ to send · @name to tag",onChange:j,onKeyDown:H,rows:2,ariaLabel:"Reply",disabled:U}),E("div",{className:"cm-thread__reply-actions",children:E("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!_.trim()||U,onClick:()=>void P(),children:"Send"})})]}),x("div",{className:"cm-thread__actions",children:[J.status==="resolved"?E("button",{type:"button",className:"cm-btn",onClick:()=>Z({status:"open"}),children:"↺ Reopen"}):E("button",{type:"button",className:"cm-btn cm-btn--primary",onClick:()=>{Z({status:"resolved"}),$()},children:"✓ Resolve"}),E("button",{type:"button",className:"cm-btn cm-btn--danger",onClick:()=>{q(),$()},children:"Delete"})]})]})]})}function n7(J){if(!J)return null;let Q=/(@[\w][\w.-]*)/g;return J.split(Q).map((Z,q)=>{let G=`${q}:${Z}`;if(q%2===1)return E("strong",{"data-mention":"true",children:Z},G);return E("span",{children:Z},G)})}function r7(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 JQ(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 QQ(J){let Q=J.selector?_7(J):null;if(Q)return{x:Q.x+Q.w-12,y:Q.y+16};if(J.bounds)return{x:J.bounds.x+J.bounds.w-12,y:J.bounds.y+16};return{x:16,y:16}}function $Q(J){if(J.clientX||J.clientY)return{x:J.clientX,y:J.clientY+8};if(J.selection.selector){let Q=_7(J.selection);if(Q)return{x:Q.x,y:Q.y+Q.h+8}}return{x:16,y:16}}import{useEffect as ZQ}from"react";var qQ=new Set(["pen","highlighter","shape","rect","ellipse","arrow","sticky","text","section","eraser"]);function I7(J){return qQ.has(J)}var s=(J)=>!!(J.metaKey||J.ctrlKey);function t(J){if(J.type==="keydown"){if(J.isEditable)return{kind:"no-op"};if(J.metaKey||J.ctrlKey||J.altKey){if(J.key==="Escape")return{kind:"escape"};let $=(J.key||"").toLowerCase();if(!J.altKey&&(J.metaKey||J.ctrlKey)){if($==="z"&&J.shiftKey)return{kind:"redo"};if($==="z")return{kind:"undo"};if($==="y"&&!J.shiftKey)return{kind:"redo"}}return{kind:"no-op"}}let Q=(J.key||"").toLowerCase();if(Q==="v")return{kind:"tool",tool:"move"};if(Q==="h")return{kind:"tool",tool:"hand"};if(Q==="c")return{kind:"tool",tool:"comment"};if(Q==="b")return{kind:"tool",tool:"pen"};if(Q==="i")return{kind:"tool",tool:"highlighter"};if(Q==="r"||Q==="o")return{kind:"tool",tool:"shape"};if(Q==="a")return{kind:"tool",tool:"arrow"};if(Q==="n")return{kind:"tool",tool:"sticky"};if(Q==="t")return{kind:"tool",tool:"text"};if(Q==="s"&&J.shiftKey)return{kind:"tool",tool:"section"};if(Q==="e")return{kind:"tool",tool:"eraser"};if(J.key==="Escape")return{kind:"escape"};return{kind:"no-op"}}if(J.type==="contextmenu")return{kind:"context-menu",clientX:J.clientX??0,clientY:J.clientY??0};if(J.type==="pointermove"){if(I7(J.activeTool))return{kind:"no-op"};if(J.activeTool==="hand")return{kind:"no-op"};if(J.activeTool==="browse"){if(!s(J))return{kind:"no-op"};return{kind:"hover",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0}}if(J.activeTool==="comment")return{kind:"hover",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0};return{kind:"hover",deep:s(J),clientX:J.clientX??0,clientY:J.clientY??0}}if(J.type==="pointerdown"){if(J.button===2)return{kind:"context-menu",clientX:J.clientX??0,clientY:J.clientY??0};if(J.button===1||J.spaceHeld)return{kind:"no-op"};if(J.button!==0)return{kind:"no-op"};if(I7(J.activeTool)&&!s(J))return{kind:"no-op"};if(J.activeTool==="comment")return{kind:"drop-comment",clientX:J.clientX??0,clientY:J.clientY??0};if(J.activeTool==="hand")return{kind:"no-op"};if(J.activeTool==="browse"){if(!s(J))return{kind:"no-op"};return{kind:"select",mode:J.shiftKey?"add":"replace",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0}}let Q=s(J);return{kind:"select",mode:!!J.shiftKey?"add":"replace",deep:Q,clientX:J.clientX??0,clientY:J.clientY??0}}return{kind:"no-op"}}function K7(J){if(!J||!J.tagName)return!1;let Q=J,$=Q.tagName;if($==="INPUT"||$==="TEXTAREA"||$==="SELECT")return!0;if(Q.isContentEditable)return!0;let Z=Q.getAttribute?.("contenteditable");if(Z==="true"||Z==="plaintext-only"||Z==="")return!0;return!1}function e(J){if(!J||!J.closest)return!1;let Q=J;if(Q.closest(".dc-world"))return!1;return!!Q.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mediaref-player], .dc-tool-palette, .dc-zoom-tb, .dc-mm, .dc-context-menu")}function e7(J){if(!J||typeof J.closest!=="function")return!1;let Q=J;return!!Q.closest("[data-dc-screen]")&&!Q.closest(".dc-artboard-body")}function t7(J,Q,$){return J.kind==="select"&&!$.metaKey&&!$.ctrlKey&&e7(Q)}function GQ(J,Q,$){return J==="select"&&!$.metaKey&&!$.ctrlKey&&e7(Q)}function JJ(J){let{hostRef:Q,getActiveTool:$,isSpaceHeld:Z,callbacks:q,enabled:G=!0,claimableActions:z}=J;ZQ(()=>{if(!G)return;let X=Q.current;if(!X)return;let Y=(V)=>z&&V.kind!=="no-op"&&!z.has(V.kind)?{kind:"no-op"}:V,_=(V)=>{switch(V.kind){case"hover":q.onHover?.(V);break;case"select":q.onSelect?.(V);break;case"drop-comment":q.onDropComment?.(V);break;case"context-menu":q.onContextMenu?.(V);break;case"tool":q.onTool?.(V);break;case"escape":q.onEscape?.();break;case"undo":q.onUndo?.();break;case"redo":q.onRedo?.();break;case"no-op":break}},j=(V)=>{let K=Y(t({type:"pointermove",button:V.button,metaKey:V.metaKey,ctrlKey:V.ctrlKey,shiftKey:V.shiftKey,altKey:V.altKey,clientX:V.clientX,clientY:V.clientY,spaceHeld:Z?.()??!1,activeTool:$()}));_(K)},U=(V)=>{if(e(V.target))return;if(K7(V.target))return;let K=Y(t({type:"pointerdown",button:V.button,metaKey:V.metaKey,ctrlKey:V.ctrlKey,shiftKey:V.shiftKey,altKey:V.altKey,clientX:V.clientX,clientY:V.clientY,spaceHeld:Z?.()??!1,activeTool:$()})),B=t7(K,V.target,V);if(K.kind!=="no-op"){if(V.preventDefault(),!B)V.stopImmediatePropagation()}_(K)},W=(V)=>{if(e(V.target))return;if(K7(V.target))return;let K=Y(t({type:"pointerdown",button:V.button,metaKey:V.metaKey,ctrlKey:V.ctrlKey,shiftKey:V.shiftKey,altKey:V.altKey,clientX:V.clientX,clientY:V.clientY,spaceHeld:Z?.()??!1,activeTool:$()})),B=t7(K,V.target,V);if(K.kind!=="no-op"){if(V.preventDefault(),!B)V.stopImmediatePropagation();if(K.kind==="select")try{window.focus()}catch{}}},P=(V)=>{if(e(V.target))return;if(K7(V.target))return;let K=$(),B=V.metaKey||V.ctrlKey,D=K==="comment"?"drop-comment":K==="move"&&V.button===0?"select":(I7(K)||K==="browse")&&B&&V.button===0?"select":V.button===2?"context-menu":null;if(D&&(!z||z.has(D))){let N=GQ(D,V.target,V);if(V.preventDefault(),!N)V.stopImmediatePropagation()}},H=(V)=>{let K=Y(t({type:"contextmenu",clientX:V.clientX,clientY:V.clientY,metaKey:V.metaKey,ctrlKey:V.ctrlKey,shiftKey:V.shiftKey,altKey:V.altKey,activeTool:$()}));if(K.kind==="no-op")return;V.preventDefault(),V.stopImmediatePropagation(),_(K)},L=(V)=>{let K=Y(t({type:"keydown",key:V.key,metaKey:V.metaKey,ctrlKey:V.ctrlKey,shiftKey:V.shiftKey,altKey:V.altKey,isEditable:K7(V.target),activeTool:$()}));if(K.kind==="tool"||K.kind==="escape"||K.kind==="undo"||K.kind==="redo")V.preventDefault();_(K)};X.addEventListener("pointermove",j,{passive:!0}),X.addEventListener("pointerdown",U,{capture:!0}),X.addEventListener("mousedown",W,{capture:!0}),X.addEventListener("click",P,{capture:!0}),X.addEventListener("contextmenu",H,{capture:!0});let I=X.ownerDocument??document;return I.addEventListener("keydown",L,!0),()=>{X.removeEventListener("pointermove",j),X.removeEventListener("pointerdown",U,{capture:!0}),X.removeEventListener("mousedown",W,{capture:!0}),X.removeEventListener("click",P,{capture:!0}),X.removeEventListener("contextmenu",H,{capture:!0}),I.removeEventListener("keydown",L,!0)}},[G,Q,$,Z,q,z])}function A7(J,Q,$,Z){let q=J.elementFromPoint(Q,$);if(!q)return null;if(q.closest?.(".dc-mm, .dc-zoom-tb, .dc-tool-palette, .dc-context-menu, .dc-cv-group-bbox"))return null;let G=q.closest?.("[data-dc-screen]")??null,z=G?.getAttribute("data-dc-screen")??null,X=q.closest?.(".dc-artboard-body")??null;if(!X){if(G&&z)return{el:G,cdId:null,artboardId:z};return null}if(q===X){if(G&&z)return{el:G,cdId:null,artboardId:z};return null}if(Z.deep){let W=q.getAttribute?.("data-cd-id")??null;return{el:q,cdId:W,artboardId:z}}let Y=q,_=null;while(Y&&Y!==X){if(Y.hasAttribute?.("data-cd-id"))_=Y;Y=Y.parentElement}let j=_??q,U=j.getAttribute?.("data-cd-id")??null;return{el:j,cdId:U,artboardId:z}}import{useCallback as IQ,useEffect as WJ,useRef as X7}from"react";var BQ=!1;function QJ(){return BQ}import{createContext as PQ,useCallback as Q7,useContext as GJ,useEffect as DQ,useMemo as VJ,useState as z7}from"react";function m(J,Q,$,Z){return`url("data:image/svg+xml,${encodeURIComponent(J.trim())}") ${Q} ${$}, ${Z}`}var E7="width='24' height='24' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'",k7="#1f1f1f",O7="stroke='#ffffff' stroke-linejoin='round' stroke-linecap='round'";function c(J,Q,$){let Z=$?`<g transform='${$}'>`:"";return`<svg ${E7}>${Z}<path fill='#ffffff' d='${J}'/><path fill='${k7}' d='${Q}'/>${$?"</g>":""}</svg>`}var $J="translate(0,32) scale(1,-1)",WQ=m(c("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"),KQ=m(c("M28.55 17.8 Q29.4 20.3 28.75 22.8 L28.7 23 28.15 24.55 28.05 24.75 Q26.4 28.2 22.75 29.4 L22.45 29.5 18 29.9 17.75 29.85 Q15.8 29.25 13.8 28.1 L13.45 27.95 Q12 27.05 10.35 26.8 L10.25 26.75 7.9 26.7 7.8 26.7 Q6.1 26.9 4.8 25.8 L4.75 25.8 4.65 25.7 4.6 25.65 Q3.25 24.5 3.05 22.85 L3 22.75 Q2.8 20.95 4 19.5 5.05 18.15 6.75 17.95 L8.4 17.9 7.5 15.55 7.3 15.2 7.2 15 5 10.95 Q3.9 9.15 4.3 7.75 L4.4 7.5 Q4.75 6.15 6.45 5.2 9 3.65 11 5 11.05 4.1 11.5 3.45 12.15 2.1 14.2 1.6 L14.35 1.6 Q18.05 0.6 19.6 4.4 L19.65 4.55 Q20.75 3.65 22.7 3.75 L22.75 3.75 Q26.75 4 27 8.15 L27 8.25 27 8.35 27 8.45 Q26.9 10.75 27.1 12.6 27.15 14.65 28.2 16.75 L28.55 17.8 M26.65 18.4 L26.1 16.8 26.1 16.85 Q24.8 13.7 25 8.35 L25 8.25 Q24.85 5.9 22.6 5.75 20.7 5.65 20.4 7.35 L20.1 7.95 19.5 8.2 18.85 8.05 18.45 7.5 17.75 5.15 Q16.85 2.95 14.7 3.55 L14.65 3.55 Q12.55 4.05 13.15 6.15 L13.85 8.75 13.75 9.45 13.25 9.95 12.55 9.95 12 9.55 10.9 7.7 Q9.5 5.7 7.45 6.9 6.5 7.45 6.25 8.15 6.1 8.9 6.7 9.85 9.2 13.9 10.8 18.65 L10.8 19.3 10.4 19.8 9.75 19.95 Q8.35 19.8 6.95 19.95 6.1 20.05 5.55 20.75 4.9 21.55 5 22.55 5.15 23.55 6 24.2 L6.05 24.25 Q6.75 24.85 7.65 24.7 L7.7 24.7 10.65 24.8 Q12.7 25.15 14.45 26.2 L14.5 26.2 Q16.4 27.35 18.3 27.9 L22.05 27.5 22.1 27.5 Q24.95 26.55 26.25 23.85 L26.8 22.3 Q27.3 20.35 26.65 18.4","M26.65 18.4 Q27.3 20.35 26.8 22.3 L26.25 23.85 Q24.95 26.55 22.1 27.5 L22.05 27.5 18.3 27.9 Q16.4 27.35 14.5 26.2 L14.45 26.2 Q12.7 25.15 10.65 24.8 L7.7 24.7 7.65 24.7 Q6.75 24.85 6.05 24.25 L6 24.2 Q5.15 23.55 5 22.55 4.9 21.55 5.55 20.75 6.1 20.05 6.95 19.95 8.35 19.8 9.75 19.95 L10.4 19.8 10.8 19.3 10.8 18.65 Q9.2 13.9 6.7 9.85 6.1 8.9 6.25 8.15 6.5 7.45 7.45 6.9 9.5 5.7 10.9 7.7 L12 9.55 12.55 9.95 13.25 9.95 13.75 9.45 13.85 8.75 13.15 6.15 Q12.55 4.05 14.65 3.55 L14.7 3.55 Q16.85 2.95 17.75 5.15 L18.45 7.5 18.85 8.05 19.5 8.2 20.1 7.95 20.4 7.35 Q20.7 5.65 22.6 5.75 24.85 5.9 25 8.25 L25 8.35 Q24.8 13.7 26.1 16.85 L26.1 16.8 26.65 18.4"),12,12,"grab"),zQ=m(c("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"),UQ=m(c("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",$J),6,18,"crosshair"),XQ=m(c("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",$J),6,18,"crosshair"),J7=m(c("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"),YQ=m(c("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"),HQ=m(`<svg ${E7}><path d='M16 4V28M11 4H21M11 28H21' fill='none' ${O7} stroke-width='5'/><path d='M16 4V28M11 4H21M11 28H21' fill='none' stroke='${k7}' stroke-width='2.25' stroke-linecap='round'/></svg>`,12,12,"text"),FQ=m(`<svg ${E7}><path d='M6 5H21L26 10V27H6Z' fill='${k7}' ${O7} stroke-width='2.5'/><path d='M21 5V11H26' fill='none' ${O7} stroke-width='2.25'/></svg>`,5,5,"crosshair"),C=Object.freeze({browse:"default",move:WQ,hand:KQ,comment:zQ,pen:UQ,section:J7,highlighter:XQ,shape:J7,rect:J7,ellipse:J7,sticky:FQ,arrow:J7,text:HQ,eraser:YQ});import{jsx as T7,Fragment as _Q}from"react/jsx-runtime";var ZJ=Object.freeze({preview:"browse",edit:"move"});function qJ(J){if(J==="browse")return"preview";if(J==="move")return"edit";return null}var LQ=Object.freeze([{id:"browse",label:"Browse",shortcut:"",cursor:C.browse},{id:"move",label:"Select",shortcut:"V",cursor:C.move},{id:"hand",label:"Hand",shortcut:"H",cursor:C.hand},{id:"comment",label:"Comment",shortcut:"C",cursor:C.comment},{id:"pen",label:"Pen",shortcut:"B",cursor:C.pen},{id:"highlighter",label:"Highlighter",shortcut:"I",cursor:C.highlighter},{id:"shape",label:"Shape",shortcut:"R",cursor:C.shape},{id:"sticky",label:"Sticky",shortcut:"N",cursor:C.sticky},{id:"section",label:"Section",shortcut:"⇧S",cursor:C.shape},{id:"arrow",label:"Arrow",shortcut:"A",cursor:C.arrow},{id:"text",label:"Text",shortcut:"T",cursor:C.text},{id:"eraser",label:"Eraser",shortcut:"E",cursor:C.eraser}]),jQ=new Set(["browse","move","hand"]);function NQ(J,Q){return Q?J.filter(($)=>jQ.has($.id)):J}var w7=PQ(null);function MQ({children:J,tools:Q=LQ,initial:$,initialMode:Z}){let q=G7(),G=VJ(()=>NQ(Q,q),[Q,q]),z=$??(q?"browse":"move"),X=Z??qJ(z)??(q?"preview":"edit"),[Y,_]=z7(z),[j,U]=z7(X),[W,P]=z7(()=>({tool:null,locked:!1})),H=Q7((M)=>{if(!G.some((F)=>F.id===M))return;_(M);let A=qJ(M);if(A)U(A);P((F)=>F.locked&&F.tool===M?F:{tool:null,locked:!1})},[G]),L=Q7((M)=>{let A=ZJ[M];if(!G.some((F)=>F.id===A))return;U(M),_(A),P((F)=>F.locked&&F.tool===A?F:{tool:null,locked:!1})},[G]),I=Q7(()=>{H(ZJ[j])},[j,H]),V=Q7((M)=>{P((A)=>{if(A.locked&&A.tool===M)return{tool:null,locked:!1};return{tool:M,locked:!0}}),_(M)},[]),K=Q7(()=>{P({tool:null,locked:!1})},[]),[B,D]=z7("rounded");DQ(()=>{if(typeof document>"u")return;let M=G.find((O)=>O.id===Y);if(!M)return;let A=document.body.style.cursor,F=document.getElementById("dc-tool-cursor");if(!F)F=document.createElement("style"),F.id="dc-tool-cursor",document.head.appendChild(F);if(Y==="browse"){if(document.body.style.cursor="",F.textContent="",typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:Y},"*")}catch{}return()=>{document.body.style.cursor=A}}if(document.body.style.cursor=M.cursor,F.textContent=`* { cursor: ${M.cursor} !important; }`,typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:Y},"*")}catch{}return()=>{document.body.style.cursor=A;let O=document.getElementById("dc-tool-cursor");if(O)O.textContent=""}},[Y,G]);let N=VJ(()=>({tool:Y,setTool:H,tools:G,mode:j,setMode:L,resetTool:I,sticky:W,toggleSticky:V,clearSticky:K,shapeKind:B,setShapeKind:D}),[Y,H,G,j,L,I,W,V,K,B]);return T7(w7.Provider,{value:N,children:J})}function BJ({children:J,initial:Q,initialMode:$}){if(GJ(w7))return T7(_Q,{children:J});return T7(MQ,{initial:Q,initialMode:$,children:J})}function U7(){let J=GJ(w7);if(!J)throw Error("useToolMode must be used inside <ToolProvider>");return J}import{jsx as RQ}from"react/jsx-runtime";var AQ=`
2
2
  .dc-el-resize-handle {
3
3
  position: fixed;
4
4
  width: 8px;
@@ -56,4 +56,4 @@ import{Component as RQ,createElement as h,Fragment as SQ,useCallback as b7,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 AQ(){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=IQ,document.head.appendChild(J)}var OQ=["nw","n","ne","e","se","s","sw","w"];function kQ(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 r=(J)=>Math.round(J*100)/100,H7=1;function TQ(J,Q,$,Z,q,G){let{movesLeft:z,movesRight:X,movesTop:Y,movesBottom:_}=kQ(J),L=q.center,U=Q.w,W=Q.h;if(X)U=Q.w+(L?2*$:$);else if(z)U=Q.w-(L?2*$:$);if(_)W=Q.h+(L?2*Z:Z);else if(Y)W=Q.h-(L?2*Z:Z);if(q.aspect&&Q.w>0&&Q.h>0){let H=Q.w/Q.h;if((z||X)&&(Y||_)){let I=Math.abs(U-Q.w)/Q.w,V=Math.abs(W-Q.h)/Q.h;if(I>=V)W=U/H;else U=W*H}else if(z||X)W=U/H;else if(Y||_)U=W*H}if(U<H7)U=H7;if(W<H7)W=H7;let P={width:r(U),height:r(W)};if(L){if(G.canMoveLeft&&(z||X))P.left=r(Q.left+(Q.w-U)/2);if(G.canMoveTop&&(Y||_))P.top=r(Q.top+(Q.h-W)/2)}else{if(G.canMoveLeft&&z)P.left=r(Q.left+Q.w-U);if(G.canMoveTop&&Y)P.top=r(Q.top+Q.h-W)}return P}function KJ(J){if(!J||J==="none")return 0;let Q=/matrix\(([^)]+)\)/.exec(J);if(!Q)return 0;let $=Q[1].split(",").map(Number),Z=$[0]??1,q=$[1]??0;return Math.round(Math.atan2(q,Z)*(180/Math.PI)*100)/100}function EQ(J){if(!J||J==="none")return 1;let Q=/matrix\(([^)]+)\)/.exec(J);if(!Q)return 1;let $=Q[1].split(",").map(Number),Z=$[0]??1,q=$[1]??0,G=Math.hypot(Z,q);return G>0?G:1}function wQ(J){let Q=J.closest(".dc-world");if(!Q)return 1;let $=getComputedStyle(Q),Z=Number.parseFloat($.zoom||"1")||1;return EQ($.transform)*Z}function zJ(J,Q,$){let Z=$*Math.PI/180,q=Math.cos(Z),G=Math.sin(Z);return[J*q-Q*G,J*G+Q*q]}function UJ(J,Q,$,Z){return Math.atan2(Z-Q,$-J)}function xQ(J,Q,$,Z){let q=J+($-Q)*(180/Math.PI);while(q>180)q-=360;while(q<=-180)q+=360;if(Z)q=Math.round(q/15)*15;return Math.round(q*100)/100}function bQ(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 yQ(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 vQ(J,Q){try{window.parent.postMessage({dgn:"resize-request",id:J.cdId,patch:{transform:Q},before:J.before,idIndex:J.idIndex},"*")}catch{}}function XJ(){AQ();let{selected:J}=K7(),{tool:Q}=X7(),$=Y7(null),Z=Y7(null),q=Y7(null),G=Y7(null),z=J.length===1?J[0]:null,X=z&&typeof z.id==="string"?z.id:null,Y=z&&!X&&typeof z.artboardId==="string"?z.artboardId:null,_=Q==="move"&&(!!X||!!Y);WJ(()=>{let U=$.current;if(!U)return;let W=()=>{for(let H of Array.from(U.children)){let j=H;j.style.opacity="0",j.style.pointerEvents="none"}};if(!_||!z){W();return}let P=()=>{if(Z.current=null,QJ()){W(),Z.current=requestAnimationFrame(P);return}let H=D7(document,z);if(!H){W(),Z.current=requestAnimationFrame(P);return}let j=H.getBoundingClientRect();if(j.width<=0&&j.height<=0){W(),Z.current=requestAnimationFrame(P);return}let I=Y?["e","s","se"]:OQ,V=Y?[]:["rot-nw","rot-ne","rot-sw","rot-se"],K=I.length+V.length+1;while(U.children.length<K)U.appendChild(document.createElement("div"));while(U.children.length>K)U.lastChild&&U.removeChild(U.lastChild);let B=j.left+j.width/2,D=j.top+j.height/2,N=KJ(getComputedStyle(H).transform),M=wQ(H),A=H.offsetWidth*M/2,F=H.offsetHeight*M/2,O={nw:[-A,-F],n:[0,-F],ne:[A,-F],e:[A,0],se:[A,F],s:[0,F],sw:[-A,F],w:[-A,0],"rot-nw":[-A,-F],"rot-ne":[A,-F],"rot-sw":[-A,F],"rot-se":[A,F]},E=[...V,...I];for(let g=0;g<E.length;g++){let x=E[g],v=U.children[g],[d,c]=O[x]??[0,0],[DJ,jJ]=zJ(d,c,N),LJ=B+DJ,NJ=D+jJ,F7=x.startsWith("rot-"),v7=x==="n"||x==="s",C7=x==="e"||x==="w",MJ=F7?10:v7?7:C7?3:4,_J=F7?10:v7?3:C7?7:4;v.className="dc-el-resize-handle",v.dataset.corner=x,v.style.opacity="1",v.style.pointerEvents="auto",v.style.left=`${Math.round(LJ-MJ)}px`,v.style.top=`${Math.round(NJ-_J)}px`,v.style.transform=F7?"":`rotate(${N}deg)`}let y=U.children[E.length],w=q.current;if(w&&w.el===H&&!w.corner.startsWith("rot-")){let g=w.lastResult?.width??H.offsetWidth,x=w.lastResult?.height??H.offsetHeight,v=`${Math.round(g)} × ${Math.round(x)}`,d=w.lastResult?.left,c=w.lastResult?.top;if(typeof d==="number"||typeof c==="number")v+=` · ${Math.round(d??w.start.left)}, ${Math.round(c??w.start.top)}`;y.className="dc-el-resize-readout",y.textContent=v,y.style.opacity="1",y.style.left=`${Math.round(B)}px`,y.style.top=`${Math.round(D+F)}px`}else y.style.opacity="0";Z.current=requestAnimationFrame(P)};return Z.current=requestAnimationFrame(P),()=>{if(Z.current!=null)cancelAnimationFrame(Z.current)}},[_,z,Y]);let L=_Q((U,W)=>{if(U.el.style.width=`${W.width}px`,U.el.style.height=`${W.height}px`,typeof W.left==="number")U.el.style.left=`${W.left}px`;if(typeof W.top==="number")U.el.style.top=`${W.top}px`;U.lastResult=W},[]);return WJ(()=>{let U=$.current;if(!U)return;let W=(V,K)=>{let[B,D]=zJ(K.clientX-V.startClientX,K.clientY-V.startClientY,-V.angle);return TQ(V.corner,V.start,B/V.elZoom,D/V.elZoom,{aspect:!!K.shiftKey,center:!V.artboardId&&!!K.altKey},V.flags)},P=(V)=>{let K=V.target;if(!K?.classList.contains("dc-el-resize-handle"))return;let B=K.dataset.corner;if(!B||!z)return;let D=typeof z.id==="string"?z.id:null,N=!D&&typeof z.artboardId==="string"?z.artboardId:null;if(!D&&!N)return;let M=D7(document,z);if(!M)return;V.preventDefault(),V.stopPropagation();let A=M.getBoundingClientRect(),F=M.offsetWidth?A.width/M.offsetWidth:1,O=getComputedStyle(M),E=!N&&(O.position==="absolute"||O.position==="fixed"),y=N?Number.NaN:Number.parseFloat(M.style.left),w=N?Number.NaN:Number.parseFloat(M.style.top),g=N?0:KJ(O.transform),x=F>0?F:1,v=A.left+A.width/2,d=A.top+A.height/2,c={pointerId:V.pointerId,corner:B,el:M,cdId:D??"",artboardId:N,idIndex:D?f7(document,D,M):0,startClientX:V.clientX,startClientY:V.clientY,elZoom:x,angle:g,cx:v,cy:d,rotStartPointer:UJ(v,d,V.clientX,V.clientY),start:{w:(g?M.offsetWidth:A.width/x)||A.width/x,h:(g?M.offsetHeight:A.height/x)||A.height/x,left:y,top:w},flags:{canMoveLeft:E&&Number.isFinite(y),canMoveTop:E&&Number.isFinite(w)},before:{width:M.style.width||null,height:M.style.height||null,left:M.style.left||null,top:M.style.top||null,transform:M.style.transform||null},lastResult:null,lastTransform:null};q.current=c;try{K.setPointerCapture(V.pointerId)}catch{}},H=(V)=>{let K=q.current;if(!K||V.pointerId!==K.pointerId)return;if(V.preventDefault(),K.corner.startsWith("rot-")){let D=`rotate(${xQ(K.angle,K.rotStartPointer,UJ(K.cx,K.cy,V.clientX,V.clientY),!!V.shiftKey)}deg)`;K.el.style.transform=D,K.lastTransform=D;return}L(K,W(K,V))},j=(V)=>{let K=q.current;if(!K||V.pointerId!==K.pointerId)return;if(q.current=null,K.corner.startsWith("rot-")){let N=K.lastTransform;if(!N||N===K.before.transform)return;G.current={el:K.el,before:K.before},vQ(K,N);return}let B=K.lastResult??W(K,V);if(!(`${B.width}px`!==K.before.width||`${B.height}px`!==K.before.height||typeof B.left==="number"&&`${B.left}px`!==K.before.left||typeof B.top==="number"&&`${B.top}px`!==K.before.top))return;if(G.current={el:K.el,before:K.before},K.artboardId)yQ(K,B);else bQ(K,B)},I=(V)=>{let K=V.data;if(K?.dgn!=="resize-failed"&&K?.dgn!=="resize-artboard-failed")return;if(V.source!==window.parent)return;let B=G.current;if(!B)return;if(B.el.style.width=B.before.width??"",B.el.style.height=B.before.height??"",B.before.left!==null||B.el.style.left)B.el.style.left=B.before.left??"";if(B.before.top!==null||B.el.style.top)B.el.style.top=B.before.top??"";if(B.before.transform!==null||B.el.style.transform)B.el.style.transform=B.before.transform??"";G.current=null};return U.addEventListener("pointerdown",P),window.addEventListener("pointermove",H),window.addEventListener("pointerup",j),window.addEventListener("pointercancel",j),window.addEventListener("message",I),()=>{U.removeEventListener("pointerdown",P),window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",j),window.removeEventListener("pointercancel",j),window.removeEventListener("message",I)}},[z,L]),CQ("div",{ref:$,"aria-hidden":"true"})}import{jsx as a,jsxs as rQ}from"react/jsx-runtime";var fQ=new Set(["drop-comment","tool","escape","hover"]);function Z7(){return typeof document<"u"&&!document.querySelector(".dc-canvas")}function y7(J,Q){if(typeof document>"u")return null;let $=document.elementFromPoint(J,Q);if(!$)return null;if($.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mc-hover-halo], [data-mc-selection-halo], .dc-el-resize-handle"))return null;let Z=$.tagName;if(Z==="HTML"||Z==="BODY")return null;return $}function pQ(J,Q){let $=y7(J,Q);if(!$)return null;return $.closest("[data-cd-id]")??$}function uQ({children:J,file:Q}){let{tool:$,setTool:Z}=X7(),q=K7(),G=p(null),[z,X]=V7(null),Y=p($);Y.current=$;let _=hQ(()=>()=>Y.current,[]);f(()=>{if($!=="comment")X(null)},[$]);let[L,U]=V7(null),[W,P]=V7(!1);return f(()=>{let H=()=>P(Z7());H();let j=requestAnimationFrame(H),I=setTimeout(H,120);return()=>{cancelAnimationFrame(j),clearTimeout(I)}},[]),f(()=>{if(typeof document>"u")return;let H=(j)=>{if(j.button!==0||!(j.metaKey||j.ctrlKey))return;if(!Z7())return;if(J7(j.target))return;let I=pQ(j.clientX,j.clientY);if(!I)return;j.preventDefault(),j.stopImmediatePropagation();let V=I.getAttribute("data-cd-id"),K=j7({el:I,cdId:V,artboardId:null});if(j.shiftKey)q.add(K);else q.replace(K);U(I)};return document.addEventListener("pointerdown",H,!0),()=>document.removeEventListener("pointerdown",H,!0)},[q]),f(()=>{if(q.selected.length===0)U(null)},[q.selected]),f(()=>{let H=G.current;if(H)H.setAttribute("data-active-tool",$);if(typeof document<"u"&&document.body)document.body.setAttribute("data-active-tool",$);return()=>{H?.removeAttribute("data-active-tool")}},[$]),f(()=>{if(typeof window>"u")return;let H=(j)=>{let I=j.data;if(!I||typeof I!=="object"||I.dgn!=="tool-set")return;if(typeof I.tool==="string")Z(I.tool)};return window.addEventListener("message",H),()=>window.removeEventListener("message",H)},[Z]),JJ({hostRef:G,getActiveTool:_,claimableActions:fQ,callbacks:{onHover:({clientX:H,clientY:j})=>{if(Y.current!=="comment"||!Z7()){X(null);return}let I=y7(H,j);X((V)=>V===I?V:I)},onTool:({tool:H})=>Z(H),onEscape:()=>{if(Y.current!=="move")Z("move");if(X(null),q.clear(),typeof window<"u")try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},onDropComment:({clientX:H,clientY:j})=>iQ(H,j,q,Q)}}),rQ("div",{"data-mc-host":!0,ref:G,style:{display:"contents"},children:[J,z?a(dQ,{el:z}):null,L?a(mQ,{el:L}):null,W?a(XJ,{}):null,a(o7,{})]})}function mQ({el:J}){let Q=p(null),$=p(J);$.current=J;let Z=p(null);return f(()=>{let q=()=>{Z.current=null;let G=Q.current,z=$.current;if(G&&z?.isConnected){let X=z.getBoundingClientRect();if(X.width===0&&X.height===0)G.style.display="none";else G.style.display="block",G.style.left=`${Math.round(X.left)}px`,G.style.top=`${Math.round(X.top)}px`,G.style.width=`${Math.round(X.width)}px`,G.style.height=`${Math.round(X.height)}px`}else if(G)G.style.display="none";Z.current=requestAnimationFrame(q)};return Z.current=requestAnimationFrame(q),()=>{if(Z.current!=null)cancelAnimationFrame(Z.current)}},[]),a("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 dQ({el:J}){let Q=p(null),$=p(J);$.current=J;let Z=p(null);return f(()=>{let q=()=>{Z.current=null;let G=Q.current,z=$.current;if(G&&z?.isConnected){let X=z.getBoundingClientRect();if(X.width===0&&X.height===0)G.style.display="none";else G.style.display="block",G.style.left=`${Math.round(X.left)}px`,G.style.top=`${Math.round(X.top)}px`,G.style.width=`${Math.round(X.width)}px`,G.style.height=`${Math.round(X.height)}px`}else if(G)G.style.display="none";Z.current=requestAnimationFrame(q)};return Z.current=requestAnimationFrame(q),()=>{if(Z.current!=null)cancelAnimationFrame(Z.current)}},[]),a("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 iQ(J,Q,$,Z){if(typeof document>"u")return;let q=O7(document,J,Q,{deep:!0});if(!q)q=O7(document,J,Q,{deep:!1});if(!q&&!Z7()&&typeof document.elementsFromPoint==="function"){let z=document.elementsFromPoint(J,Q);for(let X of z){let Y=X.closest?.("[data-cd-id]");if(!Y)continue;if(!Y.closest(".dc-artboard-body"))continue;let _=Y.closest("[data-dc-screen]");q={el:Y,cdId:Y.getAttribute("data-cd-id"),artboardId:_?.getAttribute("data-dc-screen")??null};break}}if(!q&&Z7()){let z=y7(J,Q);if(z)q={el:z,cdId:z.getAttribute("data-cd-id"),artboardId:null}}if(!q){let z={file:Z,id:void 0,selector:"",artboardId:null,tag:"",classes:"",text:"",dom_path:[],bounds:{x:J-12,y:Q-12,w:24,h:24},html:""};YJ(z,J,Q);return}let G=j7(q,Z);$.replace(G),YJ(G,J,Q)}function YJ(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 FJ(J,Q){return h(BJ,{initial:"browse"},h(i7,null,h(uQ,{file:Q},h(J))))}function Q3(J,Q){let $=gQ(Q.rootEl);if(!Q.commentsEnabled){$.render(h(J));return}let Z=Q.file??P7();$.render(h(nQ,{initialCanvas:J,file:Z}))}var HJ="__maudeCanvasRuntime";function cQ({Canvas:J,file:Q,onOk:$}){return f(()=>{$()},[]),FJ(J,Q)}class PJ extends RQ{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 lQ({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 nQ({initialCanvas:J,file:Q}){let[{canvas:$,attempt:Z},q]=V7({canvas:J,attempt:0}),[G,z]=V7({on:!1}),X=p(null),Y=p($);Y.current=$,f(()=>{let W={remount:(P)=>q((H)=>({canvas:P,attempt:H.attempt+1})),setHolding:(P,H)=>z(P?{on:!0,message:H}:{on:!1})};return window[HJ]=W,()=>{window[HJ]=void 0}},[]);let _=b7(()=>{X.current=Y.current,z((W)=>W.on?{on:!1}:W)},[]),L=b7(()=>{z({on:!0,message:"render error"})},[]),U=b7(()=>{let W=X.current;return W?FJ(W,Q):null},[Q]);return h(SQ,null,h(PJ,{attempt:Z,onError:L,fallback:U},h(cQ,{key:Z,Canvas:$,file:Q,onOk:_})),G.on?h(lQ,{message:G.message}):null)}export{pQ as pickSpecimenSelectEl,Q3 as mountCanvas,Z7 as isBareSpecimen,PJ as CanvasErrorBoundary};
59
+ `.trim();function OQ(){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=AQ,document.head.appendChild(J)}var EQ=["nw","n","ne","e","se","s","sw","w"];function kQ(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 r=(J)=>Math.round(J*100)/100,Y7=1;function TQ(J,Q,$,Z,q,G){let{movesLeft:z,movesRight:X,movesTop:Y,movesBottom:_}=kQ(J),j=q.center,U=Q.w,W=Q.h;if(X)U=Q.w+(j?2*$:$);else if(z)U=Q.w-(j?2*$:$);if(_)W=Q.h+(j?2*Z:Z);else if(Y)W=Q.h-(j?2*Z:Z);if(q.aspect&&Q.w>0&&Q.h>0){let H=Q.w/Q.h;if((z||X)&&(Y||_)){let I=Math.abs(U-Q.w)/Q.w,V=Math.abs(W-Q.h)/Q.h;if(I>=V)W=U/H;else U=W*H}else if(z||X)W=U/H;else if(Y||_)U=W*H}if(U<Y7)U=Y7;if(W<Y7)W=Y7;let P={width:r(U),height:r(W)};if(j){if(G.canMoveLeft&&(z||X))P.left=r(Q.left+(Q.w-U)/2);if(G.canMoveTop&&(Y||_))P.top=r(Q.top+(Q.h-W)/2)}else{if(G.canMoveLeft&&z)P.left=r(Q.left+Q.w-U);if(G.canMoveTop&&Y)P.top=r(Q.top+Q.h-W)}return P}function KJ(J){if(!J||J==="none")return 0;let Q=/matrix\(([^)]+)\)/.exec(J);if(!Q)return 0;let $=Q[1].split(",").map(Number),Z=$[0]??1,q=$[1]??0;return Math.round(Math.atan2(q,Z)*(180/Math.PI)*100)/100}function wQ(J){if(!J||J==="none")return 1;let Q=/matrix\(([^)]+)\)/.exec(J);if(!Q)return 1;let $=Q[1].split(",").map(Number),Z=$[0]??1,q=$[1]??0,G=Math.hypot(Z,q);return G>0?G:1}function bQ(J){let Q=J.closest(".dc-world");if(!Q)return 1;let $=getComputedStyle(Q),Z=Number.parseFloat($.zoom||"1")||1;return wQ($.transform)*Z}function zJ(J,Q,$){let Z=$*Math.PI/180,q=Math.cos(Z),G=Math.sin(Z);return[J*q-Q*G,J*G+Q*q]}function UJ(J,Q,$,Z){return Math.atan2(Z-Q,$-J)}function xQ(J,Q,$,Z){let q=J+($-Q)*(180/Math.PI);while(q>180)q-=360;while(q<=-180)q+=360;if(Z)q=Math.round(q/15)*15;return Math.round(q*100)/100}function yQ(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 vQ(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 CQ(J,Q){try{window.parent.postMessage({dgn:"resize-request",id:J.cdId,patch:{transform:Q},before:J.before,idIndex:J.idIndex},"*")}catch{}}function XJ(){OQ();let{selected:J}=W7(),{tool:Q}=U7(),$=X7(null),Z=X7(null),q=X7(null),G=X7(null),z=J.length===1?J[0]:null,X=z&&typeof z.id==="string"?z.id:null,Y=z&&!X&&typeof z.artboardId==="string"?z.artboardId:null,_=Q==="move"&&(!!X||!!Y);WJ(()=>{let U=$.current;if(!U)return;let W=()=>{for(let H of Array.from(U.children)){let L=H;L.style.opacity="0",L.style.pointerEvents="none"}};if(!_||!z){W();return}let P=()=>{if(Z.current=null,QJ()){W(),Z.current=requestAnimationFrame(P);return}let H=P7(document,z);if(!H){W(),Z.current=requestAnimationFrame(P);return}let L=H.getBoundingClientRect();if(L.width<=0&&L.height<=0){W(),Z.current=requestAnimationFrame(P);return}let I=Y?["e","s","se"]:EQ,V=Y?[]:["rot-nw","rot-ne","rot-sw","rot-se"],K=I.length+V.length+1;while(U.children.length<K)U.appendChild(document.createElement("div"));while(U.children.length>K)U.lastChild&&U.removeChild(U.lastChild);let B=L.left+L.width/2,D=L.top+L.height/2,N=KJ(getComputedStyle(H).transform),M=bQ(H),A=H.offsetWidth*M/2,F=H.offsetHeight*M/2,O={nw:[-A,-F],n:[0,-F],ne:[A,-F],e:[A,0],se:[A,F],s:[0,F],sw:[-A,F],w:[-A,0],"rot-nw":[-A,-F],"rot-ne":[A,-F],"rot-sw":[-A,F],"rot-se":[A,F]},T=[...V,...I];for(let h=0;h<T.length;h++){let b=T[h],v=U.children[h],[d,i]=O[b]??[0,0],[LJ,jJ]=zJ(d,i,N),NJ=B+LJ,MJ=D+jJ,H7=b.startsWith("rot-"),v7=b==="n"||b==="s",C7=b==="e"||b==="w",_J=H7?10:v7?7:C7?3:4,IJ=H7?10:v7?3:C7?7:4;v.className="dc-el-resize-handle",v.dataset.corner=b,v.style.opacity="1",v.style.pointerEvents="auto",v.style.left=`${Math.round(NJ-_J)}px`,v.style.top=`${Math.round(MJ-IJ)}px`,v.style.transform=H7?"":`rotate(${N}deg)`}let y=U.children[T.length],w=q.current;if(w&&w.el===H&&!w.corner.startsWith("rot-")){let h=w.lastResult?.width??H.offsetWidth,b=w.lastResult?.height??H.offsetHeight,v=`${Math.round(h)} × ${Math.round(b)}`,d=w.lastResult?.left,i=w.lastResult?.top;if(typeof d==="number"||typeof i==="number")v+=` · ${Math.round(d??w.start.left)}, ${Math.round(i??w.start.top)}`;y.className="dc-el-resize-readout",y.textContent=v,y.style.opacity="1",y.style.left=`${Math.round(B)}px`,y.style.top=`${Math.round(D+F)}px`}else y.style.opacity="0";Z.current=requestAnimationFrame(P)};return Z.current=requestAnimationFrame(P),()=>{if(Z.current!=null)cancelAnimationFrame(Z.current)}},[_,z,Y]);let j=IQ((U,W)=>{if(U.el.style.width=`${W.width}px`,U.el.style.height=`${W.height}px`,typeof W.left==="number")U.el.style.left=`${W.left}px`;if(typeof W.top==="number")U.el.style.top=`${W.top}px`;U.lastResult=W},[]);return WJ(()=>{let U=$.current;if(!U)return;let W=(V,K)=>{let[B,D]=zJ(K.clientX-V.startClientX,K.clientY-V.startClientY,-V.angle);return TQ(V.corner,V.start,B/V.elZoom,D/V.elZoom,{aspect:!!K.shiftKey,center:!V.artboardId&&!!K.altKey},V.flags)},P=(V)=>{let K=V.target;if(!K?.classList.contains("dc-el-resize-handle"))return;let B=K.dataset.corner;if(!B||!z)return;let D=typeof z.id==="string"?z.id:null,N=!D&&typeof z.artboardId==="string"?z.artboardId:null;if(!D&&!N)return;let M=P7(document,z);if(!M)return;V.preventDefault(),V.stopPropagation();let A=M.getBoundingClientRect(),F=M.offsetWidth?A.width/M.offsetWidth:1,O=getComputedStyle(M),T=!N&&(O.position==="absolute"||O.position==="fixed"),y=N?Number.NaN:Number.parseFloat(M.style.left),w=N?Number.NaN:Number.parseFloat(M.style.top),h=N?0:KJ(O.transform),b=F>0?F:1,v=A.left+A.width/2,d=A.top+A.height/2,i={pointerId:V.pointerId,corner:B,el:M,cdId:D??"",artboardId:N,idIndex:D?f7(document,D,M):0,startClientX:V.clientX,startClientY:V.clientY,elZoom:b,angle:h,cx:v,cy:d,rotStartPointer:UJ(v,d,V.clientX,V.clientY),start:{w:(h?M.offsetWidth:A.width/b)||A.width/b,h:(h?M.offsetHeight:A.height/b)||A.height/b,left:y,top:w},flags:{canMoveLeft:T&&Number.isFinite(y),canMoveTop:T&&Number.isFinite(w)},before:{width:M.style.width||null,height:M.style.height||null,left:M.style.left||null,top:M.style.top||null,transform:M.style.transform||null},lastResult:null,lastTransform:null};q.current=i;try{K.setPointerCapture(V.pointerId)}catch{}},H=(V)=>{let K=q.current;if(!K||V.pointerId!==K.pointerId)return;if(V.preventDefault(),K.corner.startsWith("rot-")){let D=`rotate(${xQ(K.angle,K.rotStartPointer,UJ(K.cx,K.cy,V.clientX,V.clientY),!!V.shiftKey)}deg)`;K.el.style.transform=D,K.lastTransform=D;return}j(K,W(K,V))},L=(V)=>{let K=q.current;if(!K||V.pointerId!==K.pointerId)return;if(q.current=null,K.corner.startsWith("rot-")){let N=K.lastTransform;if(!N||N===K.before.transform)return;G.current={el:K.el,before:K.before},CQ(K,N);return}let B=K.lastResult??W(K,V);if(!(`${B.width}px`!==K.before.width||`${B.height}px`!==K.before.height||typeof B.left==="number"&&`${B.left}px`!==K.before.left||typeof B.top==="number"&&`${B.top}px`!==K.before.top))return;if(G.current={el:K.el,before:K.before},K.artboardId)vQ(K,B);else yQ(K,B)},I=(V)=>{let K=V.data;if(K?.dgn!=="resize-failed"&&K?.dgn!=="resize-artboard-failed")return;if(V.source!==window.parent)return;let B=G.current;if(!B)return;if(B.el.style.width=B.before.width??"",B.el.style.height=B.before.height??"",B.before.left!==null||B.el.style.left)B.el.style.left=B.before.left??"";if(B.before.top!==null||B.el.style.top)B.el.style.top=B.before.top??"";if(B.before.transform!==null||B.el.style.transform)B.el.style.transform=B.before.transform??"";G.current=null};return U.addEventListener("pointerdown",P),window.addEventListener("pointermove",H),window.addEventListener("pointerup",L),window.addEventListener("pointercancel",L),window.addEventListener("message",I),()=>{U.removeEventListener("pointerdown",P),window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",L),window.removeEventListener("pointercancel",L),window.removeEventListener("message",I)}},[z,j]),RQ("div",{ref:$,"aria-hidden":"true"})}import{jsx as R,jsxs as DJ,Fragment as rQ}from"react/jsx-runtime";var fQ=new Set(["drop-comment","tool","escape","hover"]);function V7(){return typeof document<"u"&&!document.querySelector(".dc-canvas")}function y7(J,Q){if(typeof document>"u")return null;let $=document.elementFromPoint(J,Q);if(!$)return null;if($.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mc-hover-halo], [data-mc-selection-halo], .dc-el-resize-handle"))return null;let Z=$.tagName;if(Z==="HTML"||Z==="BODY")return null;return $}function pQ(J,Q){let $=y7(J,Q);if(!$)return null;return $.closest("[data-cd-id]")??$}function uQ({children:J,file:Q}){let{tool:$,setTool:Z}=U7(),q=W7(),G=p(null),[z,X]=$7(null),Y=p($);Y.current=$;let _=gQ(()=>()=>Y.current,[]);f(()=>{if($!=="comment")X(null)},[$]);let[j,U]=$7(null),[W,P]=$7(!1);return f(()=>{let H=()=>P(V7());H();let L=requestAnimationFrame(H),I=setTimeout(H,120);return()=>{cancelAnimationFrame(L),clearTimeout(I)}},[]),f(()=>{if(typeof document>"u")return;let H=(L)=>{if(L.button!==0||!(L.metaKey||L.ctrlKey))return;if(!V7())return;if(e(L.target))return;let I=pQ(L.clientX,L.clientY);if(!I)return;L.preventDefault(),L.stopImmediatePropagation();let V=I.getAttribute("data-cd-id"),K=D7({el:I,cdId:V,artboardId:null});if(L.shiftKey)q.add(K);else q.replace(K);U(I)};return document.addEventListener("pointerdown",H,!0),()=>document.removeEventListener("pointerdown",H,!0)},[q]),f(()=>{if(q.selected.length===0)U(null)},[q.selected]),f(()=>{let H=G.current;if(H)H.setAttribute("data-active-tool",$);if(typeof document<"u"&&document.body)document.body.setAttribute("data-active-tool",$);return()=>{H?.removeAttribute("data-active-tool")}},[$]),f(()=>{if(typeof window>"u")return;let H=(L)=>{let I=L.data;if(!I||typeof I!=="object"||I.dgn!=="tool-set")return;if(typeof I.tool==="string")Z(I.tool)};return window.addEventListener("message",H),()=>window.removeEventListener("message",H)},[Z]),JJ({hostRef:G,getActiveTool:_,claimableActions:fQ,callbacks:{onHover:({clientX:H,clientY:L})=>{if(Y.current!=="comment"||!V7()){X(null);return}let I=y7(H,L);X((V)=>V===I?V:I)},onTool:({tool:H})=>Z(H),onEscape:()=>{if(Y.current!=="move")Z("move");if(X(null),q.clear(),typeof window<"u")try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},onDropComment:({clientX:H,clientY:L})=>cQ(H,L,q,Q)}}),DJ("div",{"data-mc-host":!0,ref:G,style:{display:"contents"},children:[J,z?R(dQ,{el:z}):null,j?R(mQ,{el:j}):null,W?R(XJ,{}):null,R(o7,{})]})}function mQ({el:J}){let Q=p(null),$=p(J);$.current=J;let Z=p(null);return f(()=>{let q=()=>{Z.current=null;let G=Q.current,z=$.current;if(G&&z?.isConnected){let X=z.getBoundingClientRect();if(X.width===0&&X.height===0)G.style.display="none";else G.style.display="block",G.style.left=`${Math.round(X.left)}px`,G.style.top=`${Math.round(X.top)}px`,G.style.width=`${Math.round(X.width)}px`,G.style.height=`${Math.round(X.height)}px`}else if(G)G.style.display="none";Z.current=requestAnimationFrame(q)};return Z.current=requestAnimationFrame(q),()=>{if(Z.current!=null)cancelAnimationFrame(Z.current)}},[]),R("div",{ref:Q,"aria-hidden":"true","data-mc-selection-halo":"",style:{position:"fixed",display:"none",pointerEvents:"none",zIndex:2147483645,border:"1.5px solid var(--maude-hud-accent, oklch(0.680 0.180 268))",borderRadius:"3px",boxSizing:"border-box"}})}function dQ({el:J}){let Q=p(null),$=p(J);$.current=J;let Z=p(null);return f(()=>{let q=()=>{Z.current=null;let G=Q.current,z=$.current;if(G&&z?.isConnected){let X=z.getBoundingClientRect();if(X.width===0&&X.height===0)G.style.display="none";else G.style.display="block",G.style.left=`${Math.round(X.left)}px`,G.style.top=`${Math.round(X.top)}px`,G.style.width=`${Math.round(X.width)}px`,G.style.height=`${Math.round(X.height)}px`}else if(G)G.style.display="none";Z.current=requestAnimationFrame(q)};return Z.current=requestAnimationFrame(q),()=>{if(Z.current!=null)cancelAnimationFrame(Z.current)}},[]),R("div",{ref:Q,"aria-hidden":"true","data-mc-hover-halo":"",style:{position:"fixed",display:"none",pointerEvents:"none",zIndex:2147483646,border:"2px solid var(--maude-hud-accent, #d63b1f)",borderRadius:"3px",boxSizing:"border-box"}})}function cQ(J,Q,$,Z){if(typeof document>"u")return;let q=A7(document,J,Q,{deep:!0});if(!q)q=A7(document,J,Q,{deep:!1});if(!q&&!V7()&&typeof document.elementsFromPoint==="function"){let z=document.elementsFromPoint(J,Q);for(let X of z){let Y=X.closest?.("[data-cd-id]");if(!Y)continue;if(!Y.closest(".dc-artboard-body"))continue;let _=Y.closest("[data-dc-screen]");q={el:Y,cdId:Y.getAttribute("data-cd-id"),artboardId:_?.getAttribute("data-dc-screen")??null};break}}if(!q&&V7()){let z=y7(J,Q);if(z)q={el:z,cdId:z.getAttribute("data-cd-id"),artboardId:null}}if(!q){let z={file:Z,id:void 0,selector:"",artboardId:null,tag:"",classes:"",text:"",dom_path:[],bounds:{x:J-12,y:Q-12,w:24,h:24},html:""};YJ(z,J,Q);return}let G=D7(q,Z);$.replace(G),YJ(G,J,Q)}function YJ(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 FJ(J,Q){return R(BJ,{initial:"browse",children:R(c7,{children:R(uQ,{file:Q,children:R(J,{})})})})}function Q3(J,Q){let $=hQ(Q.rootEl);if(!Q.commentsEnabled){$.render(x7(J));return}let Z=Q.file??F7();$.render(x7(nQ,{initialCanvas:J,file:Z}))}var HJ="__maudeCanvasRuntime";function iQ({Canvas:J,file:Q,onOk:$}){return f(()=>{$()},[]),FJ(J,Q)}class PJ extends SQ{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 lQ({message:J}){return x7("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 nQ({initialCanvas:J,file:Q}){let[{canvas:$,attempt:Z},q]=$7({canvas:J,attempt:0}),[G,z]=$7({on:!1}),X=p(null),Y=p($);Y.current=$,f(()=>{let W={remount:(P)=>q((H)=>({canvas:P,attempt:H.attempt+1})),setHolding:(P,H)=>z(P?{on:!0,message:H}:{on:!1})};return window[HJ]=W,()=>{window[HJ]=void 0}},[]);let _=b7(()=>{X.current=Y.current,z((W)=>W.on?{on:!1}:W)},[]),j=b7(()=>{z({on:!0,message:"render error"})},[]),U=b7(()=>{let W=X.current;return W?FJ(W,Q):null},[Q]);return DJ(rQ,{children:[R(PJ,{attempt:Z,onError:j,fallback:U,children:R(iQ,{Canvas:$,file:Q,onOk:_},Z)}),G.on?R(lQ,{message:G.message}):null]})}export{pQ as pickSpecimenSelectEl,Q3 as mountCanvas,V7 as isBareSpecimen,PJ as CanvasErrorBoundary};