@popmelt.com/core 0.5.12 → 0.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -18
- package/dist/cli.mjs +6 -6
- package/dist/index.mjs +24 -15
- package/dist/plugin-astro.d.mts +8 -5
- package/dist/plugin-astro.mjs +1 -1
- package/dist/plugin-vite.d.mts +14 -5
- package/dist/plugin-vite.mjs +1 -1
- package/dist/server-A5ZYTJTS.mjs +127 -0
- package/dist/server.mjs +6 -6
- package/package.json +1 -1
- package/dist/chunk-HGGX55FR.mjs +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var ba=Object.defineProperty,xa=Object.defineProperties;var va=Object.getOwnPropertyDescriptors;var Xo=Object.getOwnPropertySymbols;var fs=Object.prototype.hasOwnProperty,gs=Object.prototype.propertyIsEnumerable;var ps=(e,t,o)=>t in e?ba(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,f=(e,t)=>{for(var o in t||(t={}))fs.call(t,o)&&ps(e,o,t[o]);if(Xo)for(var o of Xo(t))gs.call(t,o)&&ps(e,o,t[o]);return e},m=(e,t)=>xa(e,va(t));var Ko=e=>typeof e=="symbol"?e:e+"",Bn=(e,t)=>{var o={};for(var n in e)fs.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Xo)for(var n of Xo(e))t.indexOf(n)<0&&gs.call(e,n)&&(o[n]=e[n]);return o};import{createContext as mp,useCallback as zt,useContext as hp,useEffect as Ot,useMemo as Io,useRef as nn,useState as $t}from"react";import{useCallback as Es,useEffect as Sa,useSyncExternalStore as wa}from"react";var Sn="http://localhost:1111";function vn(e,t={},o=15e3){let n=new AbortController;t.signal&&t.signal.addEventListener("abort",()=>n.abort());let r=setTimeout(()=>n.abort(),o);return fetch(e,m(f({},t),{signal:n.signal})).finally(()=>clearTimeout(r))}async function hs(e=Sn){try{let t=await vn(`${e}/capabilities`,{},5e3);return t.ok?await t.json():null}catch(t){return null}}async function Zo(e=Sn){try{let t=new AbortController,o=setTimeout(()=>t.abort(),2e3),n=await fetch(`${e}/status`,{signal:t.signal});return clearTimeout(o),n.ok?await n.json():null}catch(t){return null}}async function ms(e){try{let t=new AbortController,o=setTimeout(()=>t.abort(),500),n=await fetch(`http://localhost:${e}/status`,{signal:t.signal});return clearTimeout(o),n.ok?await n.json():null}catch(t){return null}}async function ys(e){if(e&&e!=="http://localhost:1111")try{let c=new URL(e);return{url:e,port:parseInt(c.port,10)||1111}}catch(c){return null}let r=typeof window!="undefined"?window.location.origin:null,i=await ms(1111);if(i&&i.devOrigin&&r&&i.devOrigin===r)return{url:"http://localhost:1111",port:1111};let s=Array.from({length:8},(c,d)=>{let p=1112+d;return ms(p).then(u=>u?{status:u,port:p}:null)}),l=(await Promise.all(s)).filter(c=>c!==null),a=[];i&&a.push({port:1111,devOrigin:i.devOrigin});for(let c of l)a.push({port:c.port,devOrigin:c.status.devOrigin});if(r){let c=a.find(d=>d.devOrigin===r);if(c)return{url:`http://localhost:${c.port}`,port:c.port}}return a.length===1?{url:`http://localhost:${a[0].port}`,port:a[0].port}:i?{url:"http://localhost:1111",port:1111}:a.length>0?{url:`http://localhost:${a[0].port}`,port:a[0].port}:null}async function bs(e,t,o=Sn,n,r,i,s,l){let a=new FormData;if(a.append("screenshot",e,"screenshot.png"),a.append("feedback",t),n&&a.append("color",n),r&&a.append("provider",r),i&&a.append("model",i),l&&a.append("sourceId",l),s)for(let[d,p]of s)for(let u=0;u<p.length;u++)a.append(`image-${d}-${u}`,p[u],`image-${d}-${u}.png`);let c=await vn(`${o}/send`,{method:"POST",body:a},3e4);if(!c.ok){let d=await c.text();throw new Error(`Bridge returned ${c.status}: ${d}`)}return c.json()}async function xs(e=Sn,t){try{let o=await vn(`${e}/mcp/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{serverUrl:t}:{})},15e3);return o.ok?await o.json():null}catch(o){return null}}async function vs(e,t=Sn){let o=await vn(`${t}/model/component`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})},1e4);if(!o.ok){let n=await o.text();throw new Error(`Bridge returned ${o.status}: ${n}`)}return o.json()}async function Ss(e,t=Sn){let o=await vn(`${t}/model/component`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})},1e4);if(!o.ok){let n=await o.text();throw new Error(`Bridge returned ${o.status}: ${n}`)}return o.json()}async function Ir(e,t,o=Sn){let n=await vn(`${o}/model/token`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,value:t})},1e4);if(!n.ok){let r=await n.text();throw new Error(`Bridge returned ${n.status}: ${r}`)}return n.json()}async function ws(e,t=Sn){let o=await vn(`${t}/model/token`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})},1e4);if(!o.ok){let n=await o.text();throw new Error(`Bridge returned ${o.status}: ${n}`)}return o.json()}async function no(e=Sn){var t;try{let o=await vn(`${e}/model`,{},5e3);return o.ok&&(t=(await o.json()).model)!=null?t:null}catch(o){return null}}async function ks(e,t,o=Sn,n,r,i,s,l){let a;if(s&&s.length>0){let c=new FormData,d=new Blob([new Uint8Array([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,6,0,0,0,31,21,196,137,0,0,0,10,73,68,65,84,120,156,98,0,0,0,2,0,1,229,39,222,252,0,0,0,0,73,69,78,68,174,66,96,130])],{type:"image/png"});c.append("screenshot",d,"screenshot.png"),c.append("feedback",JSON.stringify({threadId:e,reply:t,color:n,provider:r,model:i,sourceId:l}));for(let p=0;p<s.length;p++)c.append(`image-reply-${p}`,s[p],`reply-image-${p}.png`);a=await vn(`${o}/reply`,{method:"POST",body:c},3e4)}else a=await vn(`${o}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:e,reply:t,color:n,provider:r,model:i,sourceId:l})},3e4);if(!a.ok){let c=await a.text();throw new Error(`Bridge returned ${a.status}: ${c}`)}return a.json()}var Is=typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Math.random().toString(36).slice(2);function Rr(){return Is}var ka={isConnected:!1,status:"disconnected",jobResponses:{},jobThinking:{},activeJobIds:[],currentResponse:"",currentThinking:"",events:[],activeJobId:null,lastCompletedJobId:null,lastResponseText:null,lastThreadId:null,lastErrorByJob:{},pendingQuestions:[],incrementalResolutions:[],capabilitiesVersion:0},qo=f({},ka),Lr=new Set,oo=null,Cs=null,_n=null,Ms=0,io=null,ro=null;async function Ea(e){return e&&e!=="http://localhost:1111"?(io=e,e):io||ro||(ro=ys(e).then(o=>{var n;return io=(n=o==null?void 0:o.url)!=null?n:null,ro=null,io}).catch(()=>(ro=null,null)),ro)}function Ls(){return io}function Ts(){return qo}function Ca(e){return Lr.add(e),()=>{Lr.delete(e)}}function Qt(e){qo=e(qo);for(let t of Lr)t()}function Rs(e){if(oo&&oo.readyState!==EventSource.CLOSED&&Cs===e)return;oo&&(oo.close(),oo=null),_n&&(clearTimeout(_n),_n=null),Cs=e;let t=++Ms,o=new EventSource(`${e}/events?sourceId=${Is}`);oo=o;let n=()=>t!==Ms;o.addEventListener("connected",()=>{n()||Zo(e).then(r=>{var d,p;if(n())return;let i=(d=r==null?void 0:r.activeJobs)!=null?d:r!=null&&r.activeJob?[r.activeJob]:[],s=new Set(i.map(u=>u.id)),l=(p=r==null?void 0:r.recentJobs)!=null?p:[],a=new Map(l.map(u=>[u.id,u])),c=i.length>0;Qt(u=>{let g=f({},u.lastErrorByJob),x=u.activeJobIds.filter(h=>!s.has(h));for(let h of x){let w=a.get(h);(w==null?void 0:w.status)==="error"&&w.error&&(g[h]=w.error)}let E=u.activeJobIds.filter(h=>s.has(h));for(let h of s)E.includes(h)||E.push(h);return m(f({},u),{isConnected:!0,status:c?"streaming":x.length>0||u.status==="disconnected"?"idle":u.status,activeJobId:c?i[i.length-1].id:E.length>0?E[E.length-1]:null,activeJobIds:E,lastErrorByJob:g,lastCompletedJobId:x.length>0?x[x.length-1]:u.lastCompletedJobId})})})}),o.addEventListener("job_started",r=>{if(n())return;let i=JSON.parse(r.data),s=i.jobId;Qt(l=>m(f({},l),{status:"streaming",activeJobId:s,activeJobIds:[...l.activeJobIds,s],jobResponses:m(f({},l.jobResponses),{[s]:""}),jobThinking:m(f({},l.jobThinking),{[s]:""}),currentResponse:"",currentThinking:"",lastResponseText:null,lastThreadId:null,events:[...l.events,{type:"job_started",data:i,timestamp:Date.now()}]}))}),o.addEventListener("delta",r=>{if(n())return;let i=JSON.parse(r.data),s=i.jobId,l=i.text||"";Qt(a=>m(f({},a),{jobResponses:s?m(f({},a.jobResponses),{[s]:(a.jobResponses[s]||"")+l}):a.jobResponses,currentResponse:!s||s===a.activeJobId?a.currentResponse+l:a.currentResponse,events:[...a.events,{type:"delta",data:i,timestamp:Date.now()}]}))}),o.addEventListener("thinking",r=>{if(n())return;let i=JSON.parse(r.data),s=i.jobId,l=i.text||"";Qt(a=>m(f({},a),{jobThinking:s?m(f({},a.jobThinking),{[s]:(a.jobThinking[s]||"")+l}):a.jobThinking,currentThinking:!s||s===a.activeJobId?a.currentThinking+l:a.currentThinking,events:[...a.events,{type:"thinking",data:i,timestamp:Date.now()}]}))}),o.addEventListener("tool_use",r=>{if(n())return;let i=JSON.parse(r.data);Qt(s=>m(f({},s),{events:[...s.events,{type:"tool_use",data:i,timestamp:Date.now()}]}))}),o.addEventListener("done",r=>{if(n())return;let i=JSON.parse(r.data),s=i.jobId;Qt(l=>{var g;let a=s?l.activeJobIds.filter(x=>x!==s):l.activeJobIds,c=f({},l.jobResponses),d=f({},l.jobThinking),p=s?c[s]:void 0;s&&(delete c[s],delete d[s]);let u=s===l.activeJobId?a.length>0?a[a.length-1]:null:l.activeJobId;return m(f(m(f({},l),{activeJobIds:a,activeJobId:u,jobResponses:c,jobThinking:d,lastCompletedJobId:s!=null?s:l.activeJobId,lastResponseText:p||l.currentResponse||i.responseText||null,lastThreadId:(g=i.threadId)!=null?g:null}),s===l.activeJobId?{currentResponse:u&&c[u]||"",currentThinking:u&&d[u]||""}:{}),{events:[...l.events,{type:"done",data:i,timestamp:Date.now()}]})})}),o.addEventListener("question",r=>{if(n())return;let i=JSON.parse(r.data);Qt(s=>m(f({},s),{pendingQuestions:[...s.pendingQuestions,{jobId:i.jobId,threadId:i.threadId,question:i.question,annotationIds:i.annotationIds,timestamp:Date.now()}],events:[...s.events,{type:"question",data:i,timestamp:Date.now()}]}))}),o.addEventListener("capabilities_changed",()=>{n()||Qt(r=>m(f({},r),{capabilitiesVersion:r.capabilitiesVersion+1}))}),o.addEventListener("queue_drained",()=>{n()||Qt(r=>m(f({},r),{status:r.status==="error"?"error":"idle",activeJobId:null,activeJobIds:[],currentResponse:"",currentThinking:"",jobResponses:{},jobThinking:{},lastErrorByJob:{},incrementalResolutions:[]}))}),o.addEventListener("error",r=>{var i,s;if(!n()){if(o.readyState===EventSource.CLOSED)Qt(l=>m(f({},l),{isConnected:!1,status:"disconnected"})),_n&&(clearTimeout(_n),_n=null),_n=setTimeout(()=>{Zo(e).then(l=>{l&&Rs(e)})},5e3);else if(r instanceof MessageEvent){let l=JSON.parse(r.data),a=(i=l.jobId)!=null?i:null,c=(s=l.message)!=null?s:"";Qt(d=>{let p=a?d.activeJobIds.filter(g=>g!==a):d.activeJobIds,u=p.length>0?d.status:"error";return m(f({},d),{status:u,activeJobIds:p,lastCompletedJobId:a!=null?a:d.activeJobId,lastErrorByJob:a&&c?m(f({},d.lastErrorByJob),{[a]:c}):d.lastErrorByJob,events:[...d.events,{type:"error",data:l,timestamp:Date.now()}]})})}}}),o.onerror=()=>{n()||o.readyState===EventSource.CLOSED&&Qt(r=>m(f({},r),{isConnected:!1,status:"disconnected"}))}}function As(e="http://localhost:1111"){let t=wa(Ca,Ts,Ts);Sa(()=>{Ea(e).then(r=>{r&&Zo(r).then(i=>{i&&Rs(r)})})},[e]);let o=Es(()=>{Qt(()=>m(f({},qo),{events:[],currentResponse:"",currentThinking:"",jobResponses:{},jobThinking:{},lastResponseText:null,lastThreadId:null,lastErrorByJob:{},incrementalResolutions:[]}))},[]),n=Es(r=>{Qt(i=>m(f({},i),{pendingQuestions:i.pendingQuestions.filter(s=>s.threadId!==r)}))},[]);return m(f({},t),{clearEvents:o,dismissQuestion:n})}import{useEffect as Ma,useReducer as Ta}from"react";var Ia={isAnnotating:!1,activeTool:"inspector",activeColor:"#ff0000",strokeWidth:3,annotations:[],undoStack:[],redoStack:[],currentPath:[],selectedAnnotationIds:[],lastSelectedId:null,inspectedElement:null,styleModifications:[],spacingTokenChanges:[],spacingTokenMods:[]};function Qo(){return Math.random().toString(36).substring(2,9)}function Ps(e){return e.status?e:e.captured?m(f({},e),{status:"in_flight"}):m(f({},e),{status:"pending"})}function Ut(e){return m(f({},e),{undoStack:[...e.undoStack,{annotations:e.annotations,styleModifications:e.styleModifications,spacingTokenMods:e.spacingTokenMods}],redoStack:[]})}function La(e,t){return m(f({},e),{isAnnotating:t})}function Ra(e,t){return m(f({},e),{activeTool:t,inspectedElement:null})}function Aa(e,t){return m(f({},e),{activeColor:t})}function Pa(e,t){return m(f({},e),{strokeWidth:t})}function Ba(e,t){return m(f({},e),{currentPath:[t]})}function Oa(e,t){return m(f({},e),{currentPath:[...e.currentPath,t]})}function Da(e){return m(f({},e),{currentPath:[]})}function Fa(e,t){if(e.currentPath.length<2&&e.activeTool!=="text")return m(f({},e),{currentPath:[]});let o={id:Qo(),type:e.activeTool,points:e.currentPath,color:e.activeColor,strokeWidth:e.strokeWidth,timestamp:Date.now(),status:"pending",groupId:t==null?void 0:t.groupId,elements:t==null?void 0:t.elements},n=Ut(e);return m(f({},n),{annotations:[...e.annotations,o],currentPath:[]})}function Na(e,t){var r;let o=f({id:(r=t.id)!=null?r:Qo(),type:"text",points:[t.point],text:t.text,fontSize:t.fontSize||12,color:e.activeColor,strokeWidth:e.strokeWidth,timestamp:Date.now(),status:"pending",groupId:t.groupId,linkedSelector:t.linkedSelector,linkedAnchor:t.linkedAnchor,elements:t.elements},t.imageCount?{imageCount:t.imageCount}:{}),n=t.groupId?e:Ut(e);return m(f({},n),{annotations:[...e.annotations,o]})}function Ha(e,t){let o=Ut(e);return m(f({},o),{annotations:e.annotations.map(n=>n.id===t.id?f(m(f({},n),{text:t.text}),t.imageCount!=null?{imageCount:t.imageCount}:{}):n)})}function za(e,t){return m(f({},e),{annotations:e.annotations.map(o=>o.id===t.id?m(f({},o),{fontSize:Math.max(12,Math.min(72,t.fontSize))}):o)})}function _a(e,t){let o=Ut(e),n=e.annotations.find(i=>i.id===t.id),r=n==null?void 0:n.groupId;return m(f({},o),{annotations:e.annotations.filter(i=>i.id!==t.id&&!(r&&i.groupId===r))})}function $a(e,t){let o=t.saveUndo?Ut(e):e,n=e.annotations.find(i=>i.id===t.id),r=n==null?void 0:n.groupId;return m(f({},o),{annotations:e.annotations.map(i=>{if(!(i.id===t.id||r&&i.groupId===r))return i;let l=t.delta.x,a=t.delta.y;return m(f({},i),{points:i.points.map(c=>({x:c.x+l,y:c.y+a}))})})})}function Wa(e,t){let o=t.saveUndo?Ut(e):e,n=e.annotations.find(s=>s.id===t.id);if(!n||n.type==="text"||n.points.length<2)return e;let r=0,i=0;if(n.type==="rectangle"&&n.groupId){let s=t.points,l=Math.min(s[0].x,s[1].x),a=Math.max(s[0].y,s[1].y),c=n.points[0],d=n.points[n.points.length-1],p=Math.min(c.x,d.x),u=Math.max(c.y,d.y);r=l-p,i=a-u}return m(f({},o),{annotations:e.annotations.map(s=>s.id===t.id?m(f({},s),{points:t.points}):n.groupId&&s.groupId===n.groupId&&s.type==="text"?m(f({},s),{points:s.points.map(l=>({x:l.x+r,y:l.y+i}))}):s)})}function Ya(e,t){let o=Ut(e);return m(f({},o),{annotations:[...e.annotations,...t.annotations.map(Ps)]})}function ja(e,t){let o=new Set,n=[];for(let r of t.annotations)o.has(r.id)||(o.add(r.id),n.push(Ps(r)));return m(f({},e),{annotations:n})}function Ga(e){if(e.undoStack.length===0)return e;let t=e.undoStack[e.undoStack.length-1];return m(f({},e),{annotations:(t==null?void 0:t.annotations)||[],styleModifications:(t==null?void 0:t.styleModifications)||[],spacingTokenMods:(t==null?void 0:t.spacingTokenMods)||[],undoStack:e.undoStack.slice(0,-1),redoStack:[...e.redoStack,{annotations:e.annotations,styleModifications:e.styleModifications,spacingTokenMods:e.spacingTokenMods}]})}function Va(e){if(e.redoStack.length===0)return e;let t=e.redoStack[e.redoStack.length-1];return m(f({},e),{annotations:(t==null?void 0:t.annotations)||[],styleModifications:(t==null?void 0:t.styleModifications)||[],spacingTokenMods:(t==null?void 0:t.spacingTokenMods)||[],redoStack:e.redoStack.slice(0,-1),undoStack:[...e.undoStack,{annotations:e.annotations,styleModifications:e.styleModifications,spacingTokenMods:e.spacingTokenMods}]})}function Ua(e,t){let{id:o,addToSelection:n}=t;if(o===null)return m(f({},e),{selectedAnnotationIds:[],lastSelectedId:null});if(n)if(e.selectedAnnotationIds.includes(o)){let i=e.selectedAnnotationIds.filter(s=>s!==o);return m(f({},e),{selectedAnnotationIds:i,lastSelectedId:i.length>0?i[i.length-1]:null})}else return m(f({},e),{selectedAnnotationIds:[...e.selectedAnnotationIds,o],lastSelectedId:o});return m(f({},e),{selectedAnnotationIds:[o],lastSelectedId:o})}function Ja(e,t){let o=new Set;for(let n of e.selectedAnnotationIds){let r=e.annotations.find(i=>i.id===n);r!=null&&r.groupId&&o.add(r.groupId)}return m(f({},e),{annotations:e.annotations.map(n=>{let r=e.selectedAnnotationIds.includes(n.id),i=n.groupId&&o.has(n.groupId);return!r&&!i?n:m(f({},n),{color:t.color})})})}function Xa(e){return m(f({},e),{annotations:e.annotations.map(t=>m(f({},t),{captured:!0,status:t.status==="pending"||!t.status?"in_flight":t.status})),styleModifications:e.styleModifications.map(t=>m(f({},t),{captured:!0})),spacingTokenChanges:e.spacingTokenChanges.map(t=>m(f({},t),{captured:!0}))})}function Ka(e){return m(f({},e),{annotations:[],undoStack:[],redoStack:[],currentPath:[],selectedAnnotationIds:[],lastSelectedId:null,spacingTokenChanges:[],spacingTokenMods:[]})}function Za(e,t){return m(f({},e),{inspectedElement:t})}function qa(e,t){let{selector:o,element:n,property:r,original:i,modified:s}=t,l=e.styleModifications.findIndex(a=>a.selector===o);if(i===s&&l<0)return e;if(l>=0){let a=e.styleModifications[l];if(a.captured){let g=Ut(e),x=g.styleModifications.map((E,h)=>h===l?m(f({},E),{changes:[{property:r,original:i,modified:s}],captured:!1}):E);return m(f({},g),{styleModifications:x})}let c=a.changes.findIndex(g=>g.property===r),d,p=e;if(c>=0){let g=a.changes[c];s===g.original?d=a.changes.filter((x,E)=>E!==c):d=a.changes.map((x,E)=>E===c?m(f({},x),{modified:s}):x)}else{if(i===s)return e;p=Ut(e),d=[...a.changes,{property:r,original:i,modified:s}]}if(d.length===0)return m(f({},p),{styleModifications:p.styleModifications.filter((g,x)=>x!==l)});let u=p.styleModifications.map((g,x)=>x===l?m(f({},g),{changes:d}):g);return m(f({},p),{styleModifications:u})}else{let a=Ut(e),c={selector:o,element:n,changes:[{property:r,original:i,modified:s}]};return m(f({},a),{styleModifications:[...a.styleModifications,c]})}}function Qa(e,t){let{selector:o,durableSelector:n,element:r,changes:i}=t,s=i.filter(c=>c.original!==c.modified);if(s.length===0)return e;let l=Ut(e),a=l.styleModifications.findIndex(c=>c.selector===o);if(a>=0){let c=l.styleModifications[a],d=c.captured?[]:[...c.changes];for(let p of s){let u=d.findIndex(g=>g.property===p.property);u>=0?p.modified===d[u].original?d=d.filter((g,x)=>x!==u):d=d.map((g,x)=>x===u?m(f({},g),{modified:p.modified}):g):d.push(p)}return d.length===0?m(f({},l),{styleModifications:l.styleModifications.filter((p,u)=>u!==a)}):m(f({},l),{styleModifications:l.styleModifications.map((p,u)=>u===a?m(f({},p),{changes:d,captured:!1}):p)})}else return m(f({},l),{styleModifications:[...l.styleModifications,{selector:o,durableSelector:n,element:r,changes:s}]})}function ec(e,t){let{selector:o,property:n}=t,r=Ut(e),i=r.styleModifications.map(s=>s.selector!==o?s:m(f({},s),{changes:s.changes.filter(l=>l.property!==n)})).filter(s=>s.changes.length>0);return m(f({},r),{styleModifications:i})}function tc(e){if(e.styleModifications.length===0)return m(f({},e),{inspectedElement:null});let t=Ut(e);return m(f({},t),{styleModifications:[],inspectedElement:null})}function nc(e,t){return m(f({},e),{styleModifications:t})}function oc(e,t){let{updates:o}=t,n=new Map(o.map(r=>[r.id,r]));return m(f({},e),{annotations:e.annotations.map(r=>{let i=n.get(r.id);return i?f(m(f({},r),{points:[i.point,...r.points.slice(1)]}),i.linkedAnchor?{linkedAnchor:i.linkedAnchor}:{}):r})})}function rc(e,t){let o=new Set(t.ids);return m(f({},e),{annotations:e.annotations.map(n=>o.has(n.id)?m(f({},n),{status:t.status}):n)})}function ic(e,t){let o=new Set(t.ids),n=new Set;for(let r of e.annotations)o.has(r.id)&&r.groupId&&n.add(r.groupId);return m(f({},e),{annotations:e.annotations.map(r=>o.has(r.id)||r.groupId&&n.has(r.groupId)?m(f({},r),{threadId:t.threadId}):r)})}function sc(e,t){let o=new Set(t.ids),n=new Set;for(let r of e.annotations)o.has(r.id)&&r.groupId&&n.add(r.groupId);return m(f({},e),{annotations:e.annotations.map(r=>o.has(r.id)||r.groupId&&n.has(r.groupId)?m(f({},r),{status:"waiting_input",question:t.question,threadId:t.threadId}):r)})}function lc(e,t){let o=new Map(t.resolutions.map(r=>[r.annotationId,r])),n=new Map;for(let r of e.annotations){let i=o.get(r.id);i&&r.groupId&&n.set(r.groupId,i)}return m(f({},e),{annotations:e.annotations.map(r=>{var s,l,a;let i=o.get(r.id)||(r.groupId?n.get(r.groupId):void 0);return i?m(f({},r),{status:i.status,resolutionSummary:i.summary,scope:(l=(s=i.finalScope)!=null?s:i.inferredScope)!=null?l:null,replyCount:((a=r.replyCount)!=null?a:0)+1,question:void 0,threadId:r.threadId||t.threadId}):r})})}function ac(e,t){let{linkedSelectors:o,styleSelectors:n}=t,r=new Set(o),i=new Set(n),s=new Set,l=new Set;for(let u of e.annotations)u.linkedSelector&&r.has(u.linkedSelector)&&(s.add(u.id),u.groupId&&l.add(u.groupId));for(let u of e.annotations)u.groupId&&l.has(u.groupId)&&s.add(u.id);let a=e.annotations.filter(u=>!s.has(u.id)),c=e.styleModifications.filter(u=>!i.has(u.selector));if(a.length===e.annotations.length&&c.length===e.styleModifications.length)return e;let d=e.selectedAnnotationIds.filter(u=>!s.has(u)),p=e.inspectedElement&&i.has(e.inspectedElement.info.selector)?null:e.inspectedElement;return m(f({},e),{annotations:a,styleModifications:c,selectedAnnotationIds:d,lastSelectedId:d.length>0?d[d.length-1]:null,inspectedElement:p})}function cc(e,t){let o=e.spacingTokenChanges.findIndex(n=>n.tokenPath===t.tokenPath);return o>=0?m(f({},e),{spacingTokenChanges:e.spacingTokenChanges.map((n,r)=>r===o?t:n)}):m(f({},e),{spacingTokenChanges:[...e.spacingTokenChanges,t]})}function dc(e,t){return m(f({},e),{spacingTokenChanges:t})}function uc(e,t){let o=Ut(e),n=e.spacingTokenMods.findIndex(i=>i.tokenPath===t.tokenPath),r;if(n>=0){let i=e.spacingTokenMods[n],s=m(f({},t),{originalValue:i.originalValue,originalPx:i.originalPx});r=e.spacingTokenMods.map((l,a)=>a===n?s:l)}else r=[...e.spacingTokenMods,t];return m(f({},o),{spacingTokenMods:r})}function pc(e,t){let o=Ut(e),n=e.spacingTokenMods.findIndex(a=>a.tokenPath===t.tokenPath),r=n>=0?e.spacingTokenMods[n].originalValue:t.originalValue,i=n>=0?e.spacingTokenMods[n].originalPx:parseFloat(t.originalValue)||0,s={tokenPath:t.tokenPath,originalValue:r,currentValue:"__deleted__",targets:n>=0?e.spacingTokenMods[n].targets:[],originalPx:i,currentPx:0},l;return n>=0?l=e.spacingTokenMods.map((a,c)=>c===n?s:a):l=[...e.spacingTokenMods,s],m(f({},o),{spacingTokenMods:l})}var fc={SET_ANNOTATING:La,SET_TOOL:Ra,SET_COLOR:Aa,SET_STROKE_WIDTH:Pa,START_PATH:Ba,CONTINUE_PATH:Oa,CANCEL_PATH:Da,FINISH_PATH:Fa,ADD_TEXT:Na,UPDATE_TEXT:Ha,UPDATE_TEXT_SIZE:za,DELETE_ANNOTATION:_a,MOVE_ANNOTATION:$a,RESIZE_ANNOTATION:Wa,PASTE_ANNOTATIONS:Ya,RESTORE_ANNOTATIONS:ja,UNDO:Ga,REDO:Va,SELECT_ANNOTATION:Ua,UPDATE_ANNOTATION_COLOR:Ja,MARK_CAPTURED:Xa,CLEAR:Ka,SELECT_ELEMENT:Za,MODIFY_STYLE:qa,MODIFY_STYLES_BATCH:Qa,CLEAR_STYLE:ec,CLEAR_ALL_STYLES:tc,RESTORE_STYLE_MODIFICATIONS:nc,UPDATE_LINKED_POSITIONS:oc,CLEANUP_ORPHANED:ac,SET_ANNOTATION_STATUS:rc,SET_ANNOTATION_THREAD:ic,SET_ANNOTATION_QUESTION:sc,APPLY_RESOLUTIONS:lc,ADD_SPACING_TOKEN_CHANGE:cc,RESTORE_SPACING_TOKEN_CHANGES:dc,MODIFY_SPACING_TOKEN:uc,DELETE_SPACING_TOKEN:pc};function gc(e,t){let o=fc[t.type];return o?o(e,t.payload):e}function Bs(){let[e,t]=Ta(gc,Ia);return Ma(()=>{let o=n=>{(n.metaKey||n.ctrlKey)&&n.key==="z"&&(n.preventDefault(),n.shiftKey?t({type:"REDO"}):t({type:"UNDO"}))};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[]),[e,t]}import{domToCanvas as mc}from"modern-screenshot";function Ar(e){let t=document.createElement("canvas").getContext("2d");return t?(t.fillStyle=e,t.fillStyle):"#888888"}function Pr(e,t=[],o,n){let r=new Map,i=[];for(let l of e)if(l.groupId){let a=r.get(l.groupId)||[];a.push(l),r.set(l.groupId,a)}else i.push(l);let s=[];for(let[l,a]of r){let c=a.find(p=>p.type!=="text"),d=a.find(p=>p.type==="text");if(c){let p=c.linkedSelector||(d==null?void 0:d.linkedSelector),u=(d==null?void 0:d.imageCount)||c.imageCount;s.push(f(m(f({id:c.id,type:c.type,instruction:d==null?void 0:d.text},p?{linkedSelector:p}:{}),{elements:c.elements||[]}),u?{imageCount:u}:{}))}}for(let l of i)s.push(f(m(f({id:l.id,type:l.type,instruction:l.type==="text"?l.text:void 0},l.linkedSelector?{linkedSelector:l.linkedSelector}:{}),{elements:l.elements||[]}),l.imageCount?{imageCount:l.imageCount}:{}));return f(f({timestamp:new Date().toISOString(),url:window.location.href,viewport:{width:window.innerWidth,height:window.innerHeight},scrollPosition:{x:window.scrollX,y:window.scrollY},annotations:s,styleModifications:t},o?{inspectedElement:o}:{}),n&&n.length>0?{spacingTokenChanges:n}:{})}function hc(e){if(!e.points||e.points.length===0)return null;let t=e.points.map(n=>n.x),o=e.points.map(n=>n.y);return{minX:Math.min(...t),minY:Math.min(...o),maxX:Math.max(...t),maxY:Math.max(...o)}}function yc(e,t){if(e.length===0)return[];let o=e.map(d=>({annotation:d,bounds:hc(d)})).filter(d=>d.bounds!==null);if(o.length===0)return[];o.sort((d,p)=>d.bounds.minY-p.bounds.minY);let n=Math.min(...o.map(d=>d.bounds.minY)),r=Math.max(...o.map(d=>d.bounds.maxY));if(r-n<=t){let d=(n+r)/2,p=Math.max(0,d-t/2);return[{top:p,bottom:p+t,annotations:e}]}let i=[],s=50,l=Math.max(0,n-s),a=[],c=l;for(let{annotation:d,bounds:p}of o){let u=p.maxY+s;if(u-l<=t)a.push(d),c=Math.max(c,u);else{if(a.length>0){let g=(l+c)/2,x=Math.max(0,g-t/2);i.push({top:x,bottom:x+t,annotations:a})}l=Math.max(0,p.minY-s),a=[d],c=p.maxY+s}}if(a.length>0){let d=(l+c)/2,p=Math.max(0,d-t/2);i.push({top:p,bottom:p+t,annotations:a})}return i}function bc(e,t,o,n){e.save(),e.scale(n,n);for(let r of t){let i=r.points.map(s=>({x:s.x,y:s.y-o}));switch(e.strokeStyle=r.color,e.fillStyle=r.color,e.lineWidth=r.strokeWidth,e.lineCap="round",e.lineJoin="round",r.type){case"freehand":if(i.length<2)break;e.beginPath(),e.moveTo(i[0].x,i[0].y);for(let s=1;s<i.length;s++)e.lineTo(i[s].x,i[s].y);e.stroke();break;case"line":if(i.length<2)break;e.beginPath(),e.moveTo(i[0].x,i[0].y),e.lineTo(i[i.length-1].x,i[i.length-1].y),e.stroke();break;case"rectangle":{if(i.length<2)break;let s=i[0],l=i[i.length-1],a=Math.min(s.x,l.x),c=Math.min(s.y,l.y),d=Math.abs(l.x-s.x),p=Math.abs(l.y-s.y);e.strokeRect(a,c,d,p);break}case"circle":{if(i.length<2)break;let s=i[0],l=i[i.length-1],a=(s.x+l.x)/2,c=(s.y+l.y)/2,d=Math.abs(l.x-s.x)/2,p=Math.abs(l.y-s.y)/2;e.beginPath(),e.ellipse(a,c,d,p,0,0,Math.PI*2),e.stroke();break}case"text":{if(!r.text||i.length<1)break;let s=i[0],l=r.fontSize||16;e.font=`${l}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,e.fillStyle=r.color;let c=(r.imageCount&&r.imageCount>0?`[${r.imageCount} image${r.imageCount>1?"s":""}] ${r.text}`:r.text).split(`
|
|
3
|
-
`),d=l*1.2,
|
|
4
|
-
`),c=i!==void 0?[i+". "+(a[0]||""),...a.slice(1)]:a;e.font=`${r}px ${Ft}`,e.textBaseline="middle";let d=s!==void 0?Math.min(400,Math.max(60,window.innerWidth-s-16)):400,p=$n(e,c,d),u=Math.min(d,Math.max(...p.map(w=>e.measureText(w).width))),g=p.length*l,x=c.length*l,E=g-x,h=t.y-E;e.fillStyle=n,e.fillRect(t.x-4,h-4,u+8,g+8),e.fillStyle="#ffffff",p.forEach((w,D)=>{e.fillText(w,t.x,h+D*l+l/2)})}var Ns=11,zr=4,Sc=`600 ${Ns}px system-ui, -apple-system, sans-serif`;function _r(e,t,o){return e.map(n=>({x:n.x-t,y:n.y-o}))}function wc(e,t,o,n,r,i){let s=String(n);e.font=Sc;let a=e.measureText(s).width+zr*2,c=Ns+zr*2,d=t-a/2,p=o+i/2+2;e.fillStyle=r,e.fillRect(d,p,a,c),e.fillStyle="#ffffff",e.textBaseline="middle",e.fillText(s,d+zr,p+c/2)}function kc(e,t){if(e.points.length<2&&e.type!=="text")return null;switch(e.type){case"rectangle":case"freehand":{let o,n;if(e.type==="freehand")o=Math.min(...e.points.map(r=>r.x)),n=Math.max(...e.points.map(r=>r.y));else{let r=e.points[0],i=e.points[e.points.length-1];o=Math.min(r.x,i.x),n=Math.max(r.y,i.y)}return{x:o,y:n}}case"circle":{let o=e.points[0],n=e.points[e.points.length-1],r=Math.min(o.x,n.x),i=(Math.min(o.y,n.y)+Math.max(o.y,n.y))/2;return{x:r,y:i}}case"line":{let o=e.points[0],n=e.points[e.points.length-1],r=o.y>n.y?o:n;return{x:r.x,y:r.y}}default:return null}}function Hs(){let e=vc(null),t=lo(()=>{let l=e.current;if(!l)return;let a=l.getContext("2d");a&&a.clearRect(0,0,l.width,l.height)},[]),o=lo((l,a,c)=>{var x;let d=e.current;if(!d)return;let p=d.getContext("2d");if(!p)return;let g=((x=l.status)!=null?x:l.captured?"in_flight":"pending")==="pending"||c?l.color:"#999999";switch(l.type){case"freehand":Fr(p,l.points,g,l.strokeWidth);break;case"line":Nr(p,l.points,g,l.strokeWidth);break;case"rectangle":Hr(p,l.points,g,l.strokeWidth);break;case"circle":Dr(p,l.points,g,l.strokeWidth);break;case"text":l.text&&l.points[0]&&Fs(p,l.points[0],l.text,g,l.fontSize,a,l.points[0].x);break}},[]),n=lo((l,a,c,d)=>{let p=e.current;if(!p||l.length<2)return;let u=p.getContext("2d");if(u)switch(a){case"freehand":Fr(u,l,c,d);break;case"line":Nr(u,l,c,d);break;case"rectangle":Hr(u,l,c,d);break;case"circle":Dr(u,l,c,d);break}},[]),r=lo((l,a)=>{let c=e.current;if(!c||l.points.length<2)return;let d=c.getContext("2d");if(d){if(d.fillStyle="#ffffff",d.strokeStyle=l.color,d.lineWidth=1.5,l.type==="line"){let p=l.points[0],u=l.points[l.points.length-1];[p,u].forEach(g=>{d.beginPath(),d.arc(g.x,g.y,a/2,0,Math.PI*2),d.fill(),d.stroke()});return}if(l.type==="circle"){let p=l.points[0],u=l.points[l.points.length-1],g=Math.min(p.x,u.x),x=Math.max(p.x,u.x),E=Math.min(p.y,u.y),h=Math.max(p.y,u.y),w=(g+x)/2,D=(E+h)/2;[{x:w,y:E},{x:w,y:h},{x:g,y:D},{x,y:D}].forEach(M=>{d.beginPath(),d.rect(M.x-a/2,M.y-a/2,a,a),d.fill(),d.stroke()});return}if(l.type==="rectangle"||l.type==="freehand"){let p,u,g,x;if(l.type==="freehand")p=Math.min(...l.points.map(h=>h.x)),u=Math.max(...l.points.map(h=>h.x)),g=Math.min(...l.points.map(h=>h.y)),x=Math.max(...l.points.map(h=>h.y));else{let h=l.points[0],w=l.points[l.points.length-1];p=Math.min(h.x,w.x),u=Math.max(h.x,w.x),g=Math.min(h.y,w.y),x=Math.max(h.y,w.y)}[{x:p,y:g},{x:u,y:g},{x:p,y:x},{x:u,y:x}].forEach(h=>{d.beginPath(),d.rect(h.x-a/2,h.y-a/2,a,a),d.fill(),d.stroke()})}}},[]),i=lo((l,a,c,d,p,u,g,x=0,E=0,h,w)=>{var D;if(t(),l.forEach(B=>{var k;let M=m(f({},B),{points:_r(B.points,x,E)}),C=h==null?void 0:h.get(B.id),L=(k=w==null?void 0:w.has(B.id))!=null?k:!1;o(M,C,L)}),a.length>0){let B=_r(a,x,E);n(B,c,d,p)}if(u&&u.length>0&&g){let B=e.current,M=B==null?void 0:B.getContext("2d");for(let C of u){let L=l.find(k=>k.id===C);if(L){let k=m(f({},L),{points:_r(L.points,x,E)});if(r(k,g),M&&L.type!=="text"&&h&&!(L.groupId&&l.some(ee=>ee.groupId===L.groupId&&ee.type==="text"))){let ee=h.get(L.id);if(ee!==void 0){let Z=kc(k,g);if(Z){let K=((D=L.status)!=null?D:L.captured?"in_flight":"pending")==="pending"?L.color:"#999999";wc(M,Z.x,Z.y,ee,K,g)}}}}}}},[t,o,n,r]),s=lo(()=>{let l=e.current;if(!l)return;let a=window.devicePixelRatio||1;l.width=window.innerWidth*a,l.height=window.innerHeight*a;let c=l.getContext("2d");c&&c.scale(a,a)},[]);return{canvasRef:e,clearCanvas:t,drawAnnotation:o,drawCurrentPath:n,redrawAll:i,resizeCanvas:s}}import{useEffect as Ec,useRef as Cc}from"react";function zs(){let e=Cc({shift:!1,cmd:!1});return Ec(()=>{let t=r=>{r.key==="Shift"&&(e.current.shift=!0),(r.key==="Meta"||r.key==="Control")&&(e.current.cmd=!0)},o=r=>{r.key==="Shift"&&(e.current.shift=!1),(r.key==="Meta"||r.key==="Control")&&(e.current.cmd=!1)},n=()=>{e.current={shift:!1,cmd:!1}};return window.addEventListener("keydown",t,!0),window.addEventListener("keyup",o,!0),window.addEventListener("blur",n),()=>{window.removeEventListener("keydown",t,!0),window.removeEventListener("keyup",o,!0),window.removeEventListener("blur",n)}},[]),e}import{useEffect as Mc}from"react";function _s(e,t,o,n,r){Mc(()=>{let i=s=>{if(e){if(e.linkedSelector)return;s.preventDefault(),s.stopPropagation();let a=s.deltaY>0?-2:2;t(c=>c?m(f({},c),{fontSize:Math.max(12,Math.min(72,c.fontSize+a))}):null);return}if(!o)return;s.preventDefault();let l=n.find(a=>a.id===o);if(l&&l.type==="text"&&!l.linkedSelector){let a=l.fontSize||12,c=s.deltaY>0?-2:2;r({type:"UPDATE_TEXT_SIZE",payload:{id:o,fontSize:a+c}})}};return window.addEventListener("wheel",i,{passive:!1}),()=>{window.removeEventListener("wheel",i)}},[o,e,n,r,t])}import{useCallback as el,useEffect as cr,useRef as tl,useState as No}from"react";function er(e){let t=Object.keys(e).find(r=>r.startsWith("__reactFiber$")||r.startsWith("__reactInternalInstance$"));if(!t)return null;let o=e[t],n=[];for(;o;){let r=o.type,i=(r==null?void 0:r.displayName)||(r==null?void 0:r.name);i&&typeof i=="string"&&/^[A-Z]/.test(i)&&!i.startsWith("_")&&i!=="Fragment"&&n.unshift(i),o=o.return}return n.length>0?{name:n[n.length-1],path:n}:null}function $r(e){let t=Object.keys(e).find(r=>r.startsWith("__reactFiber$")||r.startsWith("__reactInternalInstance$"));if(!t)return[];let o=e[t],n=[];for(;o;){let r=o.type,i=typeof r=="function"||typeof r=="object"?(r==null?void 0:r.displayName)||(r==null?void 0:r.name):null;i&&typeof i=="string"&&/^[A-Z]/.test(i)&&!i.startsWith("_")&&i!=="Fragment"&&n.push({name:i,fiber:o}),o=o.return}return n.reverse(),n}function tr(e){let t=e,o=new Set;for(;t&&!o.has(t);){if(o.add(t),t.stateNode instanceof Element)return t.stateNode;t.child?t=t.child:t=null}return null}function $s(e){if(e.id)return`#${e.id}`;let t=e.tagName.toLowerCase(),o=Array.from(e.classList).slice(0,3).join(".");return o?`${t}.${o}`:t}function on(e){if(e.id&&!e.id.startsWith("radix-")&&!e.id.startsWith(":"))return`#${CSS.escape(e.id)}`;let t=[],o=e;for(;o&&o!==document.documentElement;){let n=o.tagName.toLowerCase();if(o.id&&!o.id.startsWith("radix-")&&!o.id.startsWith(":")){t.unshift(`#${CSS.escape(o.id)}`);break}let r=Array.from(o.classList).filter(s=>!s.startsWith("_")&&s.length<30).slice(0,2);r.length>0&&(n+="."+r.map(s=>CSS.escape(s)).join("."));let i=o.parentElement;if(i){let s=Array.from(i.children).filter(l=>l.tagName===o.tagName);if(s.length>1){let l=s.indexOf(o)+1;n+=`:nth-of-type(${l})`}}t.unshift(n),o=i}return t.join(" > ")}function jt(e){try{return document.querySelector(e)}catch(t){return null}}function nr(e,t=0){var a;let o=$r(e);if(o.length===0)return null;let n=o.map(c=>c.name),r=o.length-1,i=Math.max(0,Math.min(o.length-1,r-t)),s=o[i],l=(a=tr(s.fiber))!=null?a:e;return{name:s.name,path:n,depthIndex:i,rootElement:l}}function Ws(e,t){var i,s;let o=$r(e),n=t.toLowerCase(),r=-1;for(let l=o.length-1;l>=0;l--){let a=o[l].name;if(a===t){let c=(i=tr(o[l].fiber))!=null?i:e;return{name:t,path:o.map(d=>d.name),depthIndex:l,rootElement:c}}if(r===-1){let c=a.toLowerCase();(c.length>=4&&n.includes(c)||n.length>=4&&c.includes(n))&&(r=l)}}if(r>=0){let l=(s=tr(o[r].fiber))!=null?s:e;return{name:t,path:o.map(a=>a.name),depthIndex:r,rootElement:l}}return null}function ao(e){let t=co(),o=[],n=new Set,r=t.currentNode;for(;r=t.nextNode();){let i=Ws(r,e);i&&!n.has(i.rootElement)&&(n.add(i.rootElement),o.push(i))}return o}function Wr(e){let t=new Map;if(e.size===0)return t;let o=new Set(e),n=co(),r=new Set,i=n.currentNode;for(;(i=n.nextNode())&&o.size>0;)for(let s of o){let l=Ws(i,s);if(!l||r.has(l.rootElement))continue;r.add(l.rootElement);let a=l.rootElement.getBoundingClientRect();t.set(s,a.top+window.scrollY),o.delete(s);break}for(let s of o)t.set(s,1/0);return t}function co(){return document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return e.closest("#devtools-toolbar, #devtools-canvas, #devtools-scrim, [data-popmelt-panel]")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function Jt(e){let t={selector:$s(e),tagName:e.tagName.toLowerCase()};e.id&&(t.id=e.id),e.classList.length>0&&(t.className=Array.from(e.classList).join(" "));let o=Ys(e);o&&o.length>0&&o.length<200&&(t.textContent=o);let n={};for(let s of e.attributes)s.name.startsWith("data-")&&(n[s.name]=s.value);Object.keys(n).length>0&&(t.dataAttributes=n);let r=er(e);r&&(t.reactComponent=r.name);let i=Tc(e);return i&&(t.context=i),t}function Ys(e){let t="";for(let o of e.childNodes)o.nodeType===Node.TEXT_NODE&&(t+=o.textContent||"");return t.trim()}function Wn(e,t){let o=document.elementsFromPoint(e,t);for(let n of o)if(n instanceof HTMLElement&&!(n.id==="devtools-canvas"||n.id==="devtools-toolbar"||n.id==="devtools-scrim")&&!n.closest("#devtools-toolbar")&&!(n.dataset.devtools||n.closest("[data-devtools]"))&&!["html","body"].includes(n.tagName.toLowerCase()))return n;return null}function Tc(e){let t=e.parentElement,o=["section","article","nav","aside","header","footer","main"];for(;t&&t!==document.body;){let n=t.tagName.toLowerCase();if(o.includes(n)&&t.id)return`${n}#${t.id}`;if(t.id&&!t.id.startsWith("radix-")&&!t.id.startsWith(":"))return`${n}#${t.id}`;t=t.parentElement}return null}function js(e){let t=new Set,o=[],n=window.scrollX,r=window.scrollY,i=[{x:(e.minX+e.maxX)/2,y:(e.minY+e.maxY)/2},{x:e.minX,y:e.minY},{x:e.maxX,y:e.minY},{x:e.minX,y:e.maxY},{x:e.maxX,y:e.maxY}];for(let s of i){let l=s.x-n,a=s.y-r;if(l<0||a<0||l>window.innerWidth||a>window.innerHeight)continue;let c=Wn(l,a);c&&!t.has(c)&&(t.add(c),o.push(Jt(c)))}return o.slice(0,3)}function Yr(e){if(e.length===0)return[];let t=e.map(n=>n.x),o=e.map(n=>n.y);return js({minX:Math.min(...t),minY:Math.min(...o),maxX:Math.max(...t),maxY:Math.max(...o)})}function Tt(e,t){return e.style.getPropertyValue(t)!==""}function Ic(e,t=30){if(e<=0)return[];let o=[],n=co(),r=.5,i=n.currentNode;for(;(i=n.nextNode())&&o.length<t;){let s=i,l=s.getBoundingClientRect();if(l.bottom<-50||l.top>window.innerHeight+50||l.right<-50||l.left>window.innerWidth+50||l.width<1||l.height<1)continue;let a=getComputedStyle(s);!Tt(s,"padding-top")&&Math.abs((parseFloat(a.paddingTop)||0)-e)<r&&o.push({element:s,property:"padding-top"}),!Tt(s,"padding-bottom")&&Math.abs((parseFloat(a.paddingBottom)||0)-e)<r&&o.length<t&&o.push({element:s,property:"padding-bottom"}),!Tt(s,"padding-left")&&Math.abs((parseFloat(a.paddingLeft)||0)-e)<r&&o.length<t&&o.push({element:s,property:"padding-left"}),!Tt(s,"padding-right")&&Math.abs((parseFloat(a.paddingRight)||0)-e)<r&&o.length<t&&o.push({element:s,property:"padding-right"}),!Tt(s,"margin-top")&&Math.abs((parseFloat(a.marginTop)||0)-e)<r&&o.length<t&&o.push({element:s,property:"margin-top"}),!Tt(s,"margin-bottom")&&Math.abs((parseFloat(a.marginBottom)||0)-e)<r&&o.length<t&&o.push({element:s,property:"margin-bottom"}),!Tt(s,"margin-left")&&Math.abs((parseFloat(a.marginLeft)||0)-e)<r&&o.length<t&&o.push({element:s,property:"margin-left"}),!Tt(s,"margin-right")&&Math.abs((parseFloat(a.marginRight)||0)-e)<r&&o.length<t&&o.push({element:s,property:"margin-right"});let c=a.display;if((c.includes("flex")||c.includes("grid"))&&o.length<t){let d=Tt(s,"gap"),p=parseFloat(a.gap)||0,u=parseFloat(a.rowGap)||0,g=parseFloat(a.columnGap)||0;!d&&Math.abs(p-e)<r?o.push({element:s,property:"gap"}):!Tt(s,"row-gap")&&Math.abs(u-e)<r?o.push({element:s,property:"row-gap"}):!Tt(s,"column-gap")&&Math.abs(g-e)<r&&o.push({element:s,property:"column-gap"})}}return o}function jr(e,t=30){if(e<=0)return[];let o=[],n=co(),r=.5,i=n.currentNode;for(;(i=n.nextNode())&&o.length<t;){let s=i,l=s.getBoundingClientRect();if(l.bottom<-50||l.top>window.innerHeight+50||l.right<-50||l.left>window.innerWidth+50||l.width<1||l.height<1)continue;let a=getComputedStyle(s),c=parseFloat(a.borderTopWidth)||0,d=parseFloat(a.borderRightWidth)||0,p=parseFloat(a.borderBottomWidth)||0,u=parseFloat(a.borderLeftWidth)||0,g=s.clientWidth,x=s.clientHeight,E=parseFloat(a.paddingTop)||0;!Tt(s,"padding-top")&&Math.abs(E-e)<r&&o.push({x:l.left+u,y:l.top+c,width:g,height:e,direction:"vertical",property:"padding-top"});let h=parseFloat(a.paddingBottom)||0;!Tt(s,"padding-bottom")&&Math.abs(h-e)<r&&o.length<t&&o.push({x:l.left+u,y:l.top+c+x-e,width:g,height:e,direction:"vertical",property:"padding-bottom"});let w=parseFloat(a.paddingLeft)||0;!Tt(s,"padding-left")&&Math.abs(w-e)<r&&o.length<t&&o.push({x:l.left+u,y:l.top+c,width:e,height:x,direction:"horizontal",property:"padding-left"});let D=parseFloat(a.paddingRight)||0;!Tt(s,"padding-right")&&Math.abs(D-e)<r&&o.length<t&&o.push({x:l.left+u+g-e,y:l.top+c,width:e,height:x,direction:"horizontal",property:"padding-right"});let B=parseFloat(a.marginTop)||0;!Tt(s,"margin-top")&&Math.abs(B-e)<r&&o.length<t&&o.push({x:l.left,y:l.top-e,width:l.width,height:e,direction:"vertical",property:"margin-top"});let M=parseFloat(a.marginBottom)||0;!Tt(s,"margin-bottom")&&Math.abs(M-e)<r&&o.length<t&&o.push({x:l.left,y:l.bottom,width:l.width,height:e,direction:"vertical",property:"margin-bottom"});let C=parseFloat(a.marginLeft)||0;!Tt(s,"margin-left")&&Math.abs(C-e)<r&&o.length<t&&o.push({x:l.left-e,y:l.top,width:e,height:l.height,direction:"horizontal",property:"margin-left"});let L=parseFloat(a.marginRight)||0;!Tt(s,"margin-right")&&Math.abs(L-e)<r&&o.length<t&&o.push({x:l.right,y:l.top,width:e,height:l.height,direction:"horizontal",property:"margin-right"});let k=a.display;if((k.includes("flex")||k.includes("grid"))&&o.length<t&&!Tt(s,"gap")){let ee=Array.from(s.children).filter(Z=>{let F=getComputedStyle(Z);return F.display!=="none"&&F.position!=="absolute"&&F.position!=="fixed"});if(ee.length>=2)for(let Z=0;Z<ee.length-1&&o.length<t;Z++){let F=ee[Z].getBoundingClientRect(),K=ee[Z+1].getBoundingClientRect(),q=K.top-F.bottom;Math.abs(q-e)<r&&q>.5&&o.push({x:Math.min(F.left,K.left),y:F.bottom,width:Math.max(F.right,K.right)-Math.min(F.left,K.left),height:q,direction:"vertical",property:"gap"});let we=K.left-F.right;Math.abs(we-e)<r&&we>.5&&o.push({x:F.right,y:Math.min(F.top,K.top),width:we,height:Math.max(F.bottom,K.bottom)-Math.min(F.top,K.top),direction:"horizontal",property:"gap"})}}}return o}function or(e){return typeof e=="string"?{value:e}:e}var Vs={gap:["gap","row-gap","column-gap"],padding:["padding-top","padding-bottom","padding-left","padding-right"],margin:["margin-top","margin-bottom","margin-left","margin-right"]};function Gs(e,t){let o=Vs[t];return o?o.includes(e):!1}function Lc(e,t){let o=e.split(/\s+/);for(let n of o){if(n===t)return!0;let r=n.lastIndexOf(":");if(r>=0&&n.slice(r+1)===t)return!0}return!1}function Rc(e){var l,a;let t=e.lastIndexOf(":"),o=t>=0?e.slice(t+1):e,n=o.indexOf("-");if(n<0)return null;let r=o.slice(0,n),i={gap:"gap","gap-x":"column-gap","gap-y":"row-gap",p:"padding",pt:"padding-top",pb:"padding-bottom",pl:"padding-left",pr:"padding-right",px:"padding-left",py:"padding-top",m:"margin",mt:"margin-top",mb:"margin-bottom",ml:"margin-left",mr:"margin-right",mx:"margin-left",my:"margin-top"},s=o.slice(0,o.indexOf("-",n+1)>0?o.indexOf("-",n+1):n);return(a=(l=i[s])!=null?l:i[r])!=null?a:null}function Gr(e,t=30){let o=parseFloat(e.value);if(isNaN(o)||o<=0)return[];if(e.bindings&&e.bindings.length>0){let r=[],i=co(),s=i.currentNode;for(;(s=i.nextNode())&&r.length<t;){let l=s,a=l.getBoundingClientRect();if(a.bottom<-50||a.top>window.innerHeight+50||a.right<-50||a.left>window.innerWidth+50||a.width<1||a.height<1)continue;let c=l.className;if(typeof c=="string")for(let d of e.bindings){if(!Lc(c,d))continue;let p=Rc(d);if(p&&!(e.property&&!Gs(p,e.property))){r.push({element:l,property:p});break}}}return r}let n=Ic(o,t*2);return e.property?n.filter(r=>Gs(r.property,e.property)).slice(0,t):n.slice(0,t)}function Vr(e,t=30){let o=Gr(e,t),n=[];for(let r of o){let i=r.element,s=i.getBoundingClientRect(),l=getComputedStyle(i),a=parseFloat(l.borderTopWidth)||0,c=parseFloat(l.borderRightWidth)||0,d=parseFloat(l.borderLeftWidth)||0,p=i.clientWidth,u=i.clientHeight;switch(r.property){case"padding-top":{let g=parseFloat(l.paddingTop)||0;n.push({x:s.left+d,y:s.top+a,width:p,height:g,direction:"vertical",property:r.property});break}case"padding-bottom":{let g=parseFloat(l.paddingBottom)||0;n.push({x:s.left+d,y:s.top+a+u-g,width:p,height:g,direction:"vertical",property:r.property});break}case"padding-left":{let g=parseFloat(l.paddingLeft)||0;n.push({x:s.left+d,y:s.top+a,width:g,height:u,direction:"horizontal",property:r.property});break}case"padding-right":{let g=parseFloat(l.paddingRight)||0;n.push({x:s.left+d+p-g,y:s.top+a,width:g,height:u,direction:"horizontal",property:r.property});break}case"margin-top":{let g=parseFloat(l.marginTop)||0;n.push({x:s.left,y:s.top-g,width:s.width,height:g,direction:"vertical",property:r.property});break}case"margin-bottom":{let g=parseFloat(l.marginBottom)||0;n.push({x:s.left,y:s.bottom,width:s.width,height:g,direction:"vertical",property:r.property});break}case"margin-left":{let g=parseFloat(l.marginLeft)||0;n.push({x:s.left-g,y:s.top,width:g,height:s.height,direction:"horizontal",property:r.property});break}case"margin-right":{let g=parseFloat(l.marginRight)||0;n.push({x:s.right,y:s.top,width:g,height:s.height,direction:"horizontal",property:r.property});break}case"gap":case"row-gap":case"column-gap":{let g=Array.from(i.children).filter(x=>{let E=getComputedStyle(x);return E.display!=="none"&&E.position!=="absolute"&&E.position!=="fixed"});for(let x=0;x<g.length-1&&n.length<t;x++){let E=g[x].getBoundingClientRect(),h=g[x+1].getBoundingClientRect(),w=h.top-E.bottom;w>.5&&n.push({x:Math.min(E.left,h.left),y:E.bottom,width:Math.max(E.right,h.right)-Math.min(E.left,h.left),height:w,direction:"vertical",property:"gap"});let D=h.left-E.right;D>.5&&n.push({x:E.right,y:Math.min(E.top,h.top),width:D,height:Math.max(E.bottom,h.bottom)-Math.min(E.top,h.top),direction:"horizontal",property:"gap"})}break}}}return n}function Us(e,t){let o=new Set,n=Ao(t);for(let r of e){let i=Xs[r.property];if(!i)continue;let s=r.element.className;if(typeof s=="string")for(let l of i){let a=`${l}-${n}`;for(let c of s.split(/\s+/)){let d=c.lastIndexOf(":"),p=d>=0?c.slice(d+1):c;if(p===a){o.add(p);break}}}}return[...o]}function Js(e){let t=new Set;for(let o of e)for(let[n,r]of Object.entries(Vs))if(r.includes(o.property)){t.add(n);break}if(t.size===1)return[...t][0]}function Ur(e,t,o){if(t===o)return e;let n=Ao(t),r=Ao(o);return e.map(i=>{let s=i.lastIndexOf("-");if(s<0)return i;let l=i.slice(0,s),a=i.slice(s+1);return a===n||a===`[${t}px]`?`${l}-${r}`:i})}var Ac={0:"0",1:"px",2:"0.5",4:"1",6:"1.5",8:"2",12:"3",16:"4",20:"5",24:"6",28:"7",32:"8",40:"10",48:"12",64:"16",80:"20",96:"24"};function Ao(e){var t;return(t=Ac[e])!=null?t:`[${e}px]`}var Xs={"padding-top":["pt","py","p"],"padding-bottom":["pb","py","p"],"padding-left":["pl","px","p"],"padding-right":["pr","px","p"],"margin-top":["mt","my","m"],"margin-bottom":["mb","my","m"],"margin-left":["ml","mx","m"],"margin-right":["mr","mx","m"],gap:["gap"],"row-gap":["gap-y","gap"],"column-gap":["gap-x","gap"]};function Pc(e,t,o,n){let r=Xs[t];if(!r)return null;let i=Ao(o);for(let s of r){let l=new RegExp("(?:^|\\s)((?:[\\w-]+:)*"+s+"-(?:"+Bc(i)+"|\\["+o+"px\\]))(?:\\s|$)"),a=e.match(l);if(a!=null&&a[1]){let c=Ao(n),d=a[1].lastIndexOf(":"),p=d>=0?a[1].slice(0,d+1):"";return{matched:a[1],suggested:`${p}${s}-${c}`}}}return null}function Bc(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ks(e,t,o){let n=new Set,r=[];for(let i of e){let s=on(i.element),l=`${s}::${i.property}`;if(n.has(l))continue;n.add(l);let a=er(i.element),c=i.element.className||"",d=Pc(c,i.property,t,o);r.push({selector:s,reactComponent:a==null?void 0:a.name,className:c,property:i.property,matchedClass:d==null?void 0:d.matched,suggestedClass:d==null?void 0:d.suggested})}return r}function Po(e,t){return window.getComputedStyle(e).getPropertyValue(t)}function Jr(e,t){if(e instanceof HTMLElement){let n=e.style.getPropertyValue(t);if(n)return n}let o=Oc(e,t);return o&&o.includes("var(")?o:Po(e,t)}function Oc(e,t){let o=t.replace(/-([a-z])/g,(n,r)=>r.toUpperCase());try{for(let n of document.styleSheets)try{let r=n.cssRules||n.rules;for(let i of r)if(i instanceof CSSStyleRule&&e.matches(i.selectorText)){let s=i.style.getPropertyValue(t);if(s&&s.includes("var("))return s;let l=i.style[o];if(l&&l.includes("var("))return l}}catch(r){}}catch(n){}return null}function rr(e,t){if(e instanceof HTMLElement){let n=e.style.getPropertyValue(t);if(n)return n}let o=t.replace(/-([a-z])/g,(n,r)=>r.toUpperCase());try{for(let n of document.styleSheets)try{let r=n.cssRules||n.rules;for(let i of r)if(i instanceof CSSStyleRule&&e.matches(i.selectorText)){let s=i.style.getPropertyValue(t);if(s)return s;let l=i.style[o];if(l)return l}}catch(r){}}catch(n){}return null}function ir(e){let t=window.getComputedStyle(e).display;return t==="flex"||t==="inline-flex"||t==="grid"||t==="inline-grid"}function Bo(e){let t=window.getComputedStyle(e);return{row:parseFloat(t.rowGap)||0,column:parseFloat(t.columnGap)||0}}function Dc(e){let t=[];for(let o of e){let n=t.find(r=>r.axis!==o.axis?!1:o.axis==="row"?Math.abs(r.y-o.y)<2&&Math.abs(r.h-o.h)<2:Math.abs(r.x-o.x)<2&&Math.abs(r.w-o.w)<2);if(n)if(o.axis==="row"){let r=Math.min(n.x,o.x),i=Math.max(n.x+n.w,o.x+o.w);n.x=r,n.w=i-r}else{let r=Math.min(n.y,o.y),i=Math.max(n.y+n.h,o.y+o.h);n.y=r,n.h=i-r}else t.push(f({},o))}return t}function Yn(e){let t=Array.from(e.children).filter(a=>{if(!(a instanceof HTMLElement))return!1;let c=window.getComputedStyle(a);return c.display!=="none"&&c.position!=="absolute"&&c.position!=="fixed"});if(t.length<2)return[];let o=[],n=e.getBoundingClientRect(),i=window.getComputedStyle(e).flexDirection,s=i==="column"||i==="column-reverse",l=6;for(let a=0;a<t.length-1;a++){let c=t[a].getBoundingClientRect(),d=t[a+1].getBoundingClientRect();if(d.left>c.right+.5&&o.push({axis:"column",x:c.right,y:n.top,w:d.left-c.right,h:n.height}),d.top>c.bottom+.5&&o.push({axis:"row",x:n.left,y:c.bottom,w:n.width,h:d.top-c.bottom}),!(d.left>c.right+.5)&&!(d.top>c.bottom+.5))if(s){let p=(c.bottom+d.top)/2;o.push({axis:"row",x:n.left,y:p-l/2,w:n.width,h:l})}else{let p=(c.right+d.left)/2;o.push({axis:"column",x:p-l/2,y:n.top,w:l,h:n.height})}}return Dc(o)}function Xr(e,t){let o=window.getComputedStyle(e),n=o.display;if(n!=="flex"&&n!=="inline-flex")return!1;let r=o.justifyContent;if(r!=="space-between"&&r!=="space-around"&&r!=="space-evenly"&&r!=="stretch")return!1;let i=o.flexDirection;return!(t!==(i==="column"||i==="column-reverse"?"row":"column")||parseFloat(t==="row"?o.rowGap:o.columnGap)>0)}function uo(e){let t=window.getComputedStyle(e);return{top:parseFloat(t.paddingTop)||0,right:parseFloat(t.paddingRight)||0,bottom:parseFloat(t.paddingBottom)||0,left:parseFloat(t.paddingLeft)||0}}function jn(e){let t=window.getComputedStyle(e);return{"top-left":parseFloat(t.borderTopLeftRadius)||0,"top-right":parseFloat(t.borderTopRightRadius)||0,"bottom-right":parseFloat(t.borderBottomRightRadius)||0,"bottom-left":parseFloat(t.borderBottomLeftRadius)||0}}function Kr(e){for(let t of e.childNodes)if(t.nodeType===Node.TEXT_NODE&&(t.textContent||"").trim().length>0)return!0;return!1}function po(e){var d,p;let t=document.createRange(),o=!1;for(let u of e.childNodes)u.nodeType===Node.TEXT_NODE&&(u.textContent||"").trim().length>0&&(o||(t.setStart(u,0),o=!0),t.setEnd(u,(p=(d=u.textContent)==null?void 0:d.length)!=null?p:0));if(!o)return null;let n=t.getBoundingClientRect(),r=window.getComputedStyle(e),i=parseFloat(r.fontSize)||16,s=parseFloat(r.lineHeight);isNaN(s)&&(s=i*1.2);let l=Math.max(1,t.getClientRects().length),a=Math.max(n.height,l*s),c=(a-n.height)/2;return new DOMRect(n.x,n.y-c,n.width,a)}function Oo(e){let t=window.getComputedStyle(e),o=parseFloat(t.fontSize)||16,n=parseFloat(t.lineHeight);return isNaN(n)&&(n=o*1.2),{fontSize:o,lineHeight:n}}function ze(e,t,o){e instanceof HTMLElement&&e.style.setProperty(t,o,"important")}function Zr(e,t,o){e instanceof HTMLElement&&e.style.removeProperty(t)}function sr(e){var t;for(let o of e){let n=jt(o.selector);if(!n&&o.durableSelector&&(n=jt(o.durableSelector),n)){let r=(t=o.selector.match(/\[data-pm="([^"]+)"\]/))==null?void 0:t[1];r&&n.setAttribute("data-pm",r)}if(n)for(let r of o.changes)ze(n,r.property,r.modified)}}function qr(e,t){let o=jt(e);if(!o)return;let n=t.find(r=>r.selector===e);if(n)for(let r of n.changes)Zr(o,r.property,r.original)}function lr(e){for(let t of e){let o=jt(t.selector);if(o)for(let n of t.changes)Zr(o,n.property,n.original)}}function qs(e,t,o,n){if(e)for(let r of e){if(r instanceof CSSGroupingRule){qs(r.cssRules,t,o,n);continue}if(r instanceof CSSStyleRule){let i=r.selectorText.toLowerCase();(i===":root"||i==="html"||i==="*"||i.includes(":root"))&&Fc(r.style,t,o,n)}}}function Fc(e,t,o,n){for(let r=0;r<e.length;r++){let i=e[r];if(i!=null&&i.startsWith("--")){if(o.has(i))continue;o.add(i);let s=t.getPropertyValue(i).trim();Qs(s)&&n.push({name:i,value:s,usage:`var(${i})`})}}}var ar=null,Nc=5e3;function Qr(){if(ar&&Date.now()-ar.timestamp<Nc)return ar.variables;let e=[],t=new Set,o=getComputedStyle(document.documentElement);try{for(let i of document.styleSheets)try{qs(i.cssRules||i.rules,o,t,e)}catch(s){}}catch(i){}let n=document.documentElement.style;for(let i=0;i<n.length;i++){let s=n[i];if(s!=null&&s.startsWith("--")&&!t.has(s)){t.add(s);let l=o.getPropertyValue(s).trim();Qs(l)&&e.push({name:s,value:l,usage:`var(${s})`})}}let r=e.sort((i,s)=>i.name.localeCompare(s.name));return ar={variables:r,timestamp:Date.now()},r}function Qs(e){if(!e)return!1;let t=e.toLowerCase().trim();return!!(/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||t.startsWith("rgb")||t.startsWith("hsl")||t.startsWith("oklch")||t.startsWith("oklab")||t.startsWith("lch")||t.startsWith("lab")||["transparent","currentcolor","inherit","white","black","red","green","blue","yellow","orange","purple","pink","gray","grey"].includes(t))}function Do(e,t){let o=t.match(/var\((--[^,)]+)(?:,\s*([^)]+))?\)/);if(o){let n=o[1],r=o[2];return getComputedStyle(document.documentElement).getPropertyValue(n).trim()||r||t}return t}function Fo(e,t){if(!e)return null;let o=Zs(e);if(!o)return null;for(let n of t){let r=Zs(n.value);if(r&&o===r)return n}return null}function Zs(e){if(!e)return null;let t=e.trim().toLowerCase();if(t.startsWith("oklch(")){let o=t.match(/oklch\(\s*([\d.]+%?)\s+([\d.]+%?)\s+([\d.]+)/);if(o){let n=o[1].endsWith("%")?parseFloat(o[1])/100:parseFloat(o[1]),r=o[2].endsWith("%")?parseFloat(o[2])/100:parseFloat(o[2]),i=parseFloat(o[3]);n=Math.round(n*100)/100,r=Math.round(r*1e3)/1e3;let s=Math.round(i);return`oklch(${n} ${r} ${s})`}}if(t.startsWith("rgb")){let o=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/);if(o)return`rgb(${o[1]},${o[2]},${o[3]})`}return t.startsWith("#")?t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t.slice(0,7):t}import{Fragment as Gn,jsx as Je,jsxs as dn}from"react/jsx-runtime";var Vn=22,fo=12,Hc=3,zc=250,ei=["reviewing","considering","thinking","zhuzhing","iterating","tweaking","reflecting","noodling","pondering","finessing","polishing","riffing"],_c=3e3;function $c(i){var s=i,{left:e,top:t,style:o,children:n}=s,r=Bn(s,["left","top","style","children"]);return Je("div",m(f({"data-devtools":"badge-hit-area"},r),{style:f({position:"fixed",left:`max(0px, ${e}px)`,top:`max(0px, ${t}px)`,padding:fo,transform:`translate(min(0px, calc(100vw - max(0px, ${e}px) - 100%)), min(0px, calc(100vh - max(0px, ${t}px) - 100%)))`},o),children:n}))}function nl({annotations:e,supersededAnnotations:t,inFlightIds:o,scrollX:n,scrollY:r,annotationGroupMap:i,onViewThread:s,onSelectAnnotation:l,canvasRef:a}){var h,w,D,B;let[c,d]=No(0),[p,u]=No(()=>Math.floor(Math.random()*ei.length)),g=!!(o&&o.size>0);cr(()=>{if(!g)return;let M=setInterval(()=>{d(L=>(L+1)%Hc)},zc),C=setInterval(()=>{u(L=>(L+1)%ei.length)},_c);return()=>{clearInterval(M),clearInterval(C)}},[g]);let x=[];for(let M of e){if(M.type!=="text"||!M.text||!M.points[0]||t.has(M))continue;let C=M.groupId?e.filter(me=>me.groupId===M.groupId):[M],L=!!(o&&(o.has(M.id)||C.some(me=>o.has(me.id)))),k=(h=M.status)!=null?h:"pending",W=C.some(me=>me.status==="resolved"||me.status==="needs_review"),ee=C.some(me=>me.threadId);if(!L&&k!=="resolved"&&k!=="needs_review"&&!W&&!ee)continue;let Z=M.threadId||((w=C.find(me=>me.threadId))==null?void 0:w.threadId),F=k==="needs_review"||C.some(me=>me.status==="needs_review"),K=C.reduce((me,lt)=>{var qe;return me+((qe=lt.replyCount)!=null?qe:0)},0),q=M.points[0],we=M.fontSize||12,le=we*1.4,he=M.text.split(`
|
|
5
|
-
`),
|
|
6
|
-
`),h=i.get(p.id),w=h!==void 0?[h+". "+(E[0]||""),...E.slice(1)]:E,B=document.createElement("canvas").getContext("2d");if(!B)continue;B.font=`${g}px ${Ft}`;let M=u.x-o,C=so(M),L=C!==void 0?Math.min(400,C):400,k=$n(B,w,L),W=Math.min(L,Math.max(...k.map(q=>B.measureText(q).width))),ee=k.length*x,Z=w.length*x,F=ee-Z,K=ee+8;c.push({annotation:d,x:u.x+W+4,y:u.y-4-F,size:K})}}return c.length===0?null:Je(Gn,{children:c.map(({annotation:d,x:p,y:u,size:g})=>Je(Wc,{annotation:d,x:p-o,y:u-n,size:g,onReply:r},`question-${d.threadId}`))})}function Wc({annotation:e,x:t,y:o,size:n,onReply:r}){let[i,s]=No(!1),[l,a]=No(""),c=tl(null),d=tl(null);cr(()=>{i&&c.current&&c.current.focus()},[i]),cr(()=>{if(!i)return;let E=w=>{d.current&&!d.current.contains(w.target)&&s(!1)},h=w=>{w.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",E),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",h)}},[i]);let p=el(()=>{!l.trim()||!e.threadId||(r(e.threadId,l.trim()),a(""),s(!1))},[l,e.threadId,r]),u=el(E=>{E.key==="Enter"&&(E.metaKey||E.ctrlKey)&&(E.preventDefault(),p())},[p]),g=i?t:t-fo,x=i?o:o-fo;return dn("div",{ref:d,"data-devtools":"question-badge",style:{position:"fixed",left:`max(0px, ${g}px)`,top:`max(0px, ${x}px)`,padding:i?0:fo,transform:`translate(min(0px, calc(100vw - max(0px, ${g}px) - 100%)), min(0px, calc(100vh - max(0px, ${x}px) - 100%)))`,zIndex:i?10002:9999,pointerEvents:"auto",cursor:i?void 0:"pointer"},children:[!i&&dn("div",{onClick:()=>s(!0),style:{height:n,display:"flex",alignItems:"center",backgroundColor:e.color,padding:`0 ${4}px`,gap:4,fontFamily:Ft,fontSize:12,color:"#ffffff",whiteSpace:"nowrap"},children:[dn("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[Je("line",{x1:"12",y1:"3",x2:"12",y2:"9"}),Je("line",{x1:"12",y1:"15",x2:"12",y2:"21"}),Je("line",{x1:"3",y1:"12",x2:"9",y2:"12"}),Je("line",{x1:"15",y1:"12",x2:"21",y2:"12"})]}),Je("span",{style:{opacity:.7},children:"reply?"})]}),i&&dn("div",{style:{minWidth:260,maxWidth:360,backgroundColor:"#ffffff",fontFamily:Ft,fontSize:12,color:"#1f2937",border:"1px solid rgba(0, 0, 0, 0.1)"},children:[Je("div",{style:{padding:`${6}px ${8}px`,lineHeight:1.4},children:e.question}),dn("div",{style:{padding:`0 ${4}px ${4}px`},children:[Je("textarea",{ref:c,value:l,onChange:E=>a(E.target.value),onKeyDown:u,placeholder:"Type your reply...",style:{width:"100%",minHeight:40,padding:4,fontSize:12,fontFamily:Ft,backgroundColor:"rgba(0, 0, 0, 0.04)",color:"#1f2937",border:"1px solid rgba(0, 0, 0, 0.1)",borderRadius:0,outline:"none",resize:"vertical",lineHeight:1.4,boxSizing:"border-box"}}),Je("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:4},children:Je("button",{onClick:p,disabled:!l.trim(),style:{padding:"4px 12px",fontSize:11,fontFamily:Ft,fontWeight:600,backgroundColor:l.trim()?e.color:"rgba(0,0,0,0.1)",color:l.trim()?"#ffffff":"rgba(0,0,0,0.3)",border:"none",cursor:l.trim()?"pointer":"default"},children:"Send \u2318\u23CE"})})]})]})]})}function dr(e){var i;let t=new Set,o=new Map;for(let s of e){if(!s.linkedSelector)continue;let l=o.get(s.linkedSelector)||[];l.push(s),o.set(s.linkedSelector,l)}let n=new Set,r=new Set;for(let s of o.values()){if(s.length<=1){(i=s[0])!=null&&i.groupId&&r.add(s[0].groupId);continue}s.sort((a,c)=>c.timestamp-a.timestamp);let l=s[0];l.groupId&&r.add(l.groupId);for(let a=1;a<s.length;a++){let c=s[a];t.add(c),c.groupId&&n.add(c.groupId)}}for(let s of e)s.groupId&&n.has(s.groupId)&&!r.has(s.groupId)&&t.add(s);return t}import{useEffect as rl,useLayoutEffect as Yc,useState as il}from"react";import{jsx as ni,jsxs as ll}from"react/jsx-runtime";function jc(e,t){let o=e.match(/^oklch\(([^)]+)\)$/i);return o?`oklch(${o[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}var sl=["top-left","top-right","bottom-right","bottom-left"];function al({element:e,radius:t,accentColor:o,hoveredCorner:n,draggingCorner:r,cursorViewport:i}){let[s,l]=il(null),[a,c]=il(!1);if(rl(()=>{let w=M=>{(M.key==="Meta"||M.key==="Control")&&c(!0)},D=M=>{(M.key==="Meta"||M.key==="Control")&&c(!1)},B=()=>c(!1);return window.addEventListener("keydown",w,!0),window.addEventListener("keyup",D,!0),window.addEventListener("blur",B),()=>{window.removeEventListener("keydown",w,!0),window.removeEventListener("keyup",D,!0),window.removeEventListener("blur",B)}},[]),rl(()=>{if(!e){l(null);return}let w=()=>{l(e.getBoundingClientRect())};return w(),window.addEventListener("scroll",w,{passive:!0}),window.addEventListener("resize",w,{passive:!0}),()=>{window.removeEventListener("scroll",w),window.removeEventListener("resize",w)}},[e]),Yc(()=>{e&&l(e.getBoundingClientRect())},[e,t["top-left"],t["top-right"],t["bottom-right"],t["bottom-left"]]),!s)return null;let d=s.width,p=s.height,u=jc(o,.2),g={"top-left":{x:0,y:t["top-left"]},"top-right":{x:d,y:t["top-right"]},"bottom-right":{x:d,y:p-t["bottom-right"]},"bottom-left":{x:0,y:p-t["bottom-left"]}},x=new Set,E=r!=null?r:n;if(E)if(a)x.add(E);else for(let w of sl)x.add(w);let h={position:"fixed",top:s.top,left:s.left,width:d,height:p,pointerEvents:"none",zIndex:9996,overflow:"visible"};return ll("div",{"data-devtools":"border-radius-handles",style:h,children:[ll("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:`0 0 ${d} ${p}`,children:[ni("rect",{x:"0.5",y:"0.5",width:Math.max(0,d-1),height:Math.max(0,p-1),fill:"none",stroke:u,strokeWidth:"1"}),sl.map(w=>{let D=g[w],B=x.has(w);return ni("circle",{cx:D.x,cy:D.y,r:w===(r!=null?r:n)?3:2.5,fill:o,stroke:"#ffffff",strokeWidth:w===(r!=null?r:n)?4:2,paintOrder:"stroke"},w)})]}),i&&E&&(()=>{let w=Math.round(t[E]);return ni("div",{style:{position:"fixed",left:i.x+8,top:i.y-28,background:o,color:"#fff",fontSize:11,fontWeight:600,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1,padding:"4px 4px",borderRadius:0,whiteSpace:"nowrap",pointerEvents:"none",zIndex:9997},children:w})})()]})}import{useEffect as Gc,useState as Vc}from"react";function Un(e,t){let o=e.match(/^oklch\(([^)]+)\)$/i);if(o)return`oklch(${o[1]} / ${t})`;let n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n){let r=parseInt(n[1],16),i=parseInt(n[2],16),s=parseInt(n[3],16);return`rgba(${r}, ${i}, ${s}, ${t})`}return`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}import{Fragment as Uc,jsx as Jn,jsxs as Ho}from"react/jsx-runtime";function mo({element:e,isSelected:t=!1,elementInfo:o,color:n="#3b82f6",annotationNumber:r,changeCount:i,hideTooltip:s=!1}){let[l,a]=Vc(null);if(Gc(()=>{if(!e){a(null);return}let L=()=>{let k=e.getBoundingClientRect();a(k)};return L(),window.addEventListener("scroll",L,{passive:!0}),window.addEventListener("resize",L,{passive:!0}),()=>{window.removeEventListener("scroll",L),window.removeEventListener("resize",L)}},[e]),!l||!e)return null;let c={position:"fixed",top:l.top,left:l.left,width:l.width,height:l.height,pointerEvents:"none",zIndex:9996,backgroundColor:t?Un(n,.1):Un(n,.05),overflow:"visible"},d={position:"absolute",width:2,height:2,backgroundColor:n,pointerEvents:"none"},p=e.tagName.toLowerCase(),u=e.id?`#${e.id}`:"",g=e.classList.length>0?"."+Array.from(e.classList).slice(0,2).join("."):"",x=o==null?void 0:o.reactComponent,E=x?`<${x}> ${p}${u}${g}`:`${p}${u}${g}`,h=22,w=l.height>=window.innerHeight,D=w?0:l.top>=h?l.top-h:l.bottom,B=w?{position:"absolute",top:8,left:8,zIndex:9997,display:"flex",alignItems:"center",gap:6,backgroundColor:n,color:"#fff",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',padding:"4px 8px",borderRadius:0,pointerEvents:"none",whiteSpace:"nowrap",maxWidth:400}:{position:"fixed",top:D,left:l.left,zIndex:9997,display:"flex",alignItems:"center",gap:6,backgroundColor:n,color:"#fff",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',padding:"4px 8px",borderRadius:0,pointerEvents:"none",whiteSpace:"nowrap",maxWidth:400},C=!s&&Ho("div",{"data-devtools":"tooltip",style:B,children:[r!==void 0&&Ho("span",{children:[r,"."]}),Jn("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:E}),i!==void 0&&i>0&&Ho("span",{style:{opacity:.8},children:["(",i," ",i===1?"change":"changes",")"]})]});return Ho(Uc,{children:[Ho("div",{"data-devtools":"highlight",style:c,children:[Jn("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},children:Jn("rect",f({x:"0.5",y:"0.5",width:Math.max(0,l.width-1),height:Math.max(0,l.height-1),fill:"none",stroke:n,strokeWidth:"1"},!t&&{strokeDasharray:"2 4"}))}),Jn("div",{style:m(f({},d),{top:-1,left:-1})}),Jn("div",{style:m(f({},d),{top:-1,right:-1})}),Jn("div",{style:m(f({},d),{bottom:-1,left:-1})}),Jn("div",{style:m(f({},d),{bottom:-1,right:-1})}),w&&C]}),!w&&C]})}import{useEffect as cl,useLayoutEffect as Jc,useState as oi}from"react";import{jsx as Cn,jsxs as ii}from"react/jsx-runtime";function ri(e,t){let o=e.match(/^oklch\(([^)]+)\)$/i);return o?`oklch(${o[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}function si({element:e,gap:t,accentColor:o,hoveredAxis:n,draggingAxis:r,cursorViewport:i,isAutoGap:s=!1,refreshKey:l=0}){let[a,c]=oi(null),[d,p]=oi([]),[u,g]=oi(!1);if(cl(()=>{let W=F=>{(F.key==="Meta"||F.key==="Control")&&g(!0)},ee=F=>{(F.key==="Meta"||F.key==="Control")&&g(!1)},Z=()=>g(!1);return window.addEventListener("keydown",W,!0),window.addEventListener("keyup",ee,!0),window.addEventListener("blur",Z),()=>{window.removeEventListener("keydown",W,!0),window.removeEventListener("keyup",ee,!0),window.removeEventListener("blur",Z)}},[]),cl(()=>{if(!e){c(null),p([]);return}let W=()=>{c(e.getBoundingClientRect()),p(Yn(e))};return W(),window.addEventListener("scroll",W,{passive:!0}),window.addEventListener("resize",W,{passive:!0}),()=>{window.removeEventListener("scroll",W),window.removeEventListener("resize",W)}},[e]),Jc(()=>{e&&(c(e.getBoundingClientRect()),p(Yn(e)))},[e,t.row,t.column,l]),!a||d.length===0)return null;let x=a.width,E=a.height,h="pm-gap-stripe-pattern",w=ri(o,.25),D=ri(o,.1),B=ri(o,.2),M=8,C=2,L={position:"fixed",top:a.top,left:a.left,width:x,height:E,pointerEvents:"none",zIndex:9996,overflow:"visible"},k=r!=null?r:n;return ii("div",{"data-devtools":"gap-handles",style:L,children:[ii("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:`0 0 ${x} ${E}`,children:[Cn("defs",{children:Cn("pattern",{id:h,patternUnits:"userSpaceOnUse",width:"4",height:"4",patternTransform:"rotate(45)",children:Cn("line",{x1:"0",y1:"0",x2:"0",y2:"4",stroke:w,strokeWidth:"1.5"})})}),Cn("rect",{x:"0.5",y:"0.5",width:Math.max(0,x-1),height:Math.max(0,E-1),fill:"none",stroke:B,strokeWidth:"1"}),d.map((W,ee)=>{let Z=W.x-a.left,F=W.y-a.top,K=W.w,q=W.h,we=u?W.axis===k:!0;return(W.axis==="row"?t.row:t.column)===0?null:ii("g",{opacity:we?1:.6,children:[Cn("rect",{x:Z,y:F,width:K,height:q,fill:D}),Cn("rect",{x:Z,y:F,width:K,height:q,fill:`url(#${h})`})]},ee)}),k&&(()=>{let W=d.filter(V=>V.axis===k);if(W.length===0)return null;let ee=W[0];if(i&&W.length>1){let V=1/0;for(let te of W){let fe=te.x+te.w/2,Ce=te.y+te.h/2,ge=Math.abs(i.x-fe)+Math.abs(i.y-Ce);ge<V&&(V=ge,ee=te)}}let Z=ee.x-a.left,F=ee.y-a.top,K=ee.w,q=ee.h,we=Z+K/2,le=F+q/2;if(s)return Cn("circle",{cx:we,cy:le,r:1.5,fill:o,stroke:"#ffffff",strokeWidth:4,paintOrder:"stroke"});let he=k==="column",Fe=he?C:M,Ie=he?M:C,$e=we-Fe/2,J=le-Ie/2;return Cn("rect",{x:$e,y:J,width:Fe,height:Ie,fill:o,stroke:"#ffffff",strokeWidth:4,paintOrder:"stroke"})})()]}),i&&k&&(()=>{let W=s?"auto":String(Math.round(k==="row"?t.row:t.column));return Cn("div",{style:{position:"fixed",left:i.x+8,top:i.y-28,background:o,color:"#fff",fontSize:11,fontWeight:600,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1,padding:"4px 4px",borderRadius:0,whiteSpace:"nowrap",pointerEvents:"none",zIndex:9997},children:W})})()]})}import{useCallback as Qc,useEffect as ed,useState as td}from"react";import{useEffect as Xc,useState as dl}from"react";var Kc=3,Zc=250,li=["reviewing","considering","thinking","zhuzhing","iterating","tweaking","reflecting","noodling","pondering","finessing","polishing","riffing"],qc=3e3;function ur(e){let[t,o]=dl(0),[n,r]=dl(()=>Math.floor(Math.random()*li.length));return Xc(()=>{if(!e)return;let i=setInterval(()=>o(l=>(l+1)%Kc),Zc),s=setInterval(()=>r(l=>(l+1)%li.length),qc);return()=>{clearInterval(i),clearInterval(s)}},[e]),{charIndex:t,word:li[n]}}import{Fragment as ai,jsx as rn,jsxs as ho}from"react/jsx-runtime";function nd(e){let{element:t}=e,o=t.tagName,n=t.id?`#${t.id}`:"",r=t.className?"."+t.className.split(" ").slice(0,2).join("."):"",i=t.reactComponent;return i?`<${i}> ${o}${n}${r}`:`${o}${n}${r}`}var ul=22,ci=12;function od(i){var s=i,{left:e,top:t,style:o,children:n}=s,r=Bn(s,["left","top","style","children"]);return rn("div",m(f({"data-devtools":"badge-hit-area"},r),{style:f({position:"fixed",left:`max(0px, ${e}px)`,top:`max(0px, ${t}px)`,padding:ci,transform:`translate(min(0px, calc(100vw - max(0px, ${e}px) - 100%)), min(0px, calc(100vh - max(0px, ${t}px) - 100%)))`},o),children:n}))}function pl({styleModifications:e,isInspecting:t,accentColor:o,annotationGroupCount:n,dispatch:r,inFlightSelectors:i}){let[s,l]=td([]),a=i&&i.size>0,{charIndex:c,word:d}=ur(!!a);ed(()=>{if(t){l([]);return}let x=null,E=()=>{let D=[];e.forEach((B,M)=>{let C=jt(B.selector);if(!C)return;let L=C.getBoundingClientRect();D.push({selector:B.selector,modIndex:M,top:L.top>=ul?L.top-ul:L.bottom,left:L.left,label:nd(B),changeCount:B.changes.length,annotationNumber:n+M+1})}),l(D)},h=()=>{x&&cancelAnimationFrame(x),x=requestAnimationFrame(E)};E(),window.addEventListener("scroll",h,!0),window.addEventListener("resize",h,!0);let w=new MutationObserver(h);return w.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]}),window.addEventListener("load",h),document.fonts.ready.then(h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h,!0),window.removeEventListener("load",h),w.disconnect(),x&&cancelAnimationFrame(x)}},[e,t,n]);let p=Qc(x=>{let E=e[x];if(!E)return;let h=jt(E.selector);h&&(r({type:"SELECT_ANNOTATION",payload:{id:null}}),r({type:"SET_TOOL",payload:"inspector"}),r({type:"SELECT_ELEMENT",payload:{el:h,info:E.element}}))},[e,r]);if(s.length===0)return null;let u={display:"flex",alignItems:"center",gap:6,backgroundColor:o,color:"#fff",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',padding:"4px 8px",borderRadius:0,whiteSpace:"nowrap",maxWidth:400},g={overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0};return rn(ai,{children:s.map(x=>{let E=i==null?void 0:i.has(x.selector);return rn(od,{left:x.left-ci,top:x.top-ci,onClick:()=>p(x.modIndex),style:{zIndex:1e4,cursor:"pointer",pointerEvents:"auto"},children:ho("div",{"data-devtools":"badge",style:m(f({},u),{backgroundColor:E?"#999999":o}),children:[ho("span",{children:[x.annotationNumber,"."]}),rn("span",{style:g,children:x.label}),ho("span",{style:{opacity:.8},children:["(",x.changeCount," ",x.changeCount===1?"change":"changes",")"]}),E&&ho("span",{style:{opacity:.8,marginLeft:4,display:"inline-flex",alignItems:"center",gap:4},children:[rn("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"currentColor",style:{verticalAlign:"middle"},children:c===1?ho(ai,{children:[rn("circle",{cx:"7",cy:"7",r:"2"}),rn("circle",{cx:"17",cy:"7",r:"2"}),rn("circle",{cx:"7",cy:"17",r:"2"}),rn("circle",{cx:"17",cy:"17",r:"2"})]}):ho(ai,{children:[rn("circle",{cx:"12",cy:"6",r:"2"}),rn("circle",{cx:"6",cy:"12",r:"2"}),rn("circle",{cx:"18",cy:"12",r:"2"}),rn("circle",{cx:"12",cy:"18",r:"2"})]})}),d]})]})},x.selector)})})}import{useEffect as rd,useState as id}from"react";import{Fragment as ld,jsx as fl}from"react/jsx-runtime";function sd(e,t){let o=e.match(/^oklch\(([^)]+)\)$/i);return o?`oklch(${o[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}function gl({styleModifications:e,accentColor:t}){let[o,n]=id([]);if(rd(()=>{let i=null,s=()=>{let c=[];for(let d of e){let p=jt(d.selector);if(!p)continue;let u=p.getBoundingClientRect();if(u.width===0&&u.height===0)continue;let g=jn(p);c.push({selector:d.selector,top:u.top,left:u.left,width:u.width,height:u.height,borderRadius:`${g["top-left"]}px ${g["top-right"]}px ${g["bottom-right"]}px ${g["bottom-left"]}px`})}n(c)},l=()=>{i&&cancelAnimationFrame(i),i=requestAnimationFrame(s)};s(),window.addEventListener("scroll",l,{passive:!0}),window.addEventListener("resize",l,{passive:!0});let a=new MutationObserver(l);return a.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]}),()=>{window.removeEventListener("scroll",l),window.removeEventListener("resize",l),a.disconnect(),i&&cancelAnimationFrame(i)}},[e]),o.length===0)return null;let r=sd(t,.2);return fl(ld,{children:o.map(i=>{let s={position:"fixed",top:i.top,left:i.left,width:i.width,height:i.height,pointerEvents:"none",zIndex:9995,border:`1px solid ${r}`,borderRadius:i.borderRadius,boxSizing:"border-box"};return fl("div",{"data-devtools":"mod-border",style:s},i.selector)})})}import{useEffect as ml,useLayoutEffect as ad,useState as hl}from"react";import{jsx as On,jsxs as ui}from"react/jsx-runtime";function di(e,t){let o=e.match(/^oklch\(([^)]+)\)$/i);return o?`oklch(${o[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}var cd={top:"bottom",bottom:"top",left:"right",right:"left"};function pi({element:e,padding:t,accentColor:o,hoveredSide:n,draggingSide:r,cursorViewport:i,refreshKey:s}){let[l,a]=hl(null),[c,d]=hl(!1);if(ml(()=>{let K=le=>{(le.key==="Meta"||le.key==="Control")&&d(!0)},q=le=>{(le.key==="Meta"||le.key==="Control")&&d(!1)},we=()=>d(!1);return window.addEventListener("keydown",K,!0),window.addEventListener("keyup",q,!0),window.addEventListener("blur",we),()=>{window.removeEventListener("keydown",K,!0),window.removeEventListener("keyup",q,!0),window.removeEventListener("blur",we)}},[]),ml(()=>{if(!e){a(null);return}let K=()=>{a(e.getBoundingClientRect())};return K(),window.addEventListener("scroll",K,{passive:!0}),window.addEventListener("resize",K,{passive:!0}),()=>{window.removeEventListener("scroll",K),window.removeEventListener("resize",K)}},[e]),ad(()=>{e&&a(e.getBoundingClientRect())},[e,t.top,t.right,t.bottom,t.left,s]),!l)return null;let p=l.width,u=l.height,{top:g,right:x,bottom:E,left:h}=t,w="pm-stripe-pattern",D=di(o,.25),B=di(o,.1),M=di(o,.2),C=8,L=2,k={position:"fixed",top:l.top,left:l.left,width:p,height:u,pointerEvents:"none",zIndex:9996,overflow:"visible"},W=["top","right","bottom","left"],ee={top:`0,0 ${p},0 ${p-x},${g} ${h},${g}`,right:`${p},0 ${p},${u} ${p-x},${u-E} ${p-x},${g}`,bottom:`0,${u} ${h},${u-E} ${p-x},${u-E} ${p},${u}`,left:`0,0 ${h},${g} ${h},${u-E} 0,${u}`},Z={top:{x:p/2-C/2,y:g/2-L/2,w:C,h:L},bottom:{x:p/2-C/2,y:u-E/2-L/2,w:C,h:L},left:{x:h/2-L/2,y:u/2-C/2,w:L,h:C},right:{x:p-x/2-L/2,y:u/2-C/2,w:L,h:C}},F=new Set;return r?F.add(r):n&&(F.add(n),c||F.add(cd[n])),ui("div",{"data-devtools":"padding-handles",style:k,children:[ui("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:`0 0 ${p} ${u}`,children:[On("defs",{children:On("pattern",{id:w,patternUnits:"userSpaceOnUse",width:"4",height:"4",patternTransform:"rotate(45)",children:On("line",{x1:"0",y1:"0",x2:"0",y2:"4",stroke:D,strokeWidth:"1.5"})})}),On("rect",{x:"0.5",y:"0.5",width:Math.max(0,p-1),height:Math.max(0,u-1),fill:"none",stroke:M,strokeWidth:"1"}),W.map(K=>{if(t[K]<=0)return null;let we=F.has(K);return ui("g",{opacity:we?1:.6,children:[On("polygon",{points:ee[K],fill:B}),On("polygon",{points:ee[K],fill:`url(#${w})`})]},K)}),W.map(K=>{let q=Z[K],we=F.has(K);return On("rect",{x:q.x,y:q.y,width:q.w,height:q.h,fill:o,stroke:"#ffffff",strokeWidth:we?4:2,paintOrder:"stroke"},`handle-${K}`)})]}),i&&(n||r)&&(()=>{let K=r!=null?r:n,q=Math.round(t[K]);return On("div",{style:{position:"fixed",left:i.x+8,top:i.y-28,background:o,color:"#fff",fontSize:11,fontWeight:600,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1,padding:"4px 4px",borderRadius:0,whiteSpace:"nowrap",pointerEvents:"none",zIndex:9997},children:q})})()]})}import{useCallback as wn,useEffect as pn,useMemo as br,useRef as tn,useState as Ht}from"react";import{Check as yr,ChevronDown as vi,MoveHorizontal as Il,RotateCcw as Od,Shrink as Dd,X as Fd}from"lucide-react";var dd="data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPScxMicgaGVpZ2h0PScxMic+PGRlZnM+PHBhdHRlcm4gaWQ9J2QnIHdpZHRoPSc0JyBoZWlnaHQ9JzQnIHBhdHRlcm5Vbml0cz0ndXNlclNwYWNlT25Vc2UnPjxwYXRoIGQ9J00tMSwxIGwyLC0yIE0wLDQgbDQsLTQgTTMsNSBsMiwtMicgc3Ryb2tlPSdibGFjaycgc3Ryb2tlLXdpZHRoPScuNScvPjwvcGF0dGVybj48L2RlZnM+PHJlY3Qgd2lkdGg9JzEyJyBoZWlnaHQ9JzEyJyBmaWxsPSd1cmwoI2QpJy8+PC9zdmc+",gn={borderWidth:3,borderStyle:"solid",borderImage:`url("${dd}") 4 / 1.9 / 0 round`};var pr={"font-size":["rem","px","em"],"line-height":["","rem","px","em"],"letter-spacing":["rem","px","em"],gap:["rem","px","em"],"column-gap":["rem","px","em"],"row-gap":["rem","px","em"],padding:["rem","px","em","%"],margin:["rem","px","em","%"],width:["rem","px","%","em"],height:["rem","px","%","em"],"min-width":["rem","px","%","em"],"max-width":["rem","px","%","em"],"min-height":["rem","px","%","em"],"max-height":["rem","px","%","em"],"border-width":["px","rem","em"],"border-radius":["rem","px","%","em"]};function yo(e){var t,o;return(o=(t=pr[e])==null?void 0:t[0])!=null?o:"px"}function Dn(e){let t=e.match(/^([\d.-]+)(.*)$/);return t?{num:parseFloat(t[1]),unit:t[2]||""}:{num:0,unit:""}}function fr(e,t,o,n){let r=e.trim();if(!r)return"";let i=r.match(/^(-?[\d.]+)\s*(rem|em|px|%)$/i);if(i)return`${parseFloat(i[1])}${i[2].toLowerCase()}`;let s=parseFloat(r);if(!isNaN(s)){if(n){let{unit:l}=Dn(o);return`${s}${l||yo(t)}`}return`${s}${yo(t)}`}return r}function fi(e,t){if(!t||t==="px")return e;if(t==="rem"){let o=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return Math.round(e/o*1e3)/1e3}return e}import{useCallback as ud,useEffect as pd,useRef as yl,useState as fd}from"react";import{Plus as bl,X as gd}from"lucide-react";import{jsx as en,jsxs as Xn}from"react/jsx-runtime";var gr=[{name:"blur",label:"Blur",unit:"px",defaultValue:10,min:0,max:100,step:1},{name:"brightness",label:"Brightness",unit:"",defaultValue:1,min:0,max:3,step:.05},{name:"contrast",label:"Contrast",unit:"",defaultValue:1,min:0,max:3,step:.05},{name:"saturate",label:"Saturate",unit:"",defaultValue:1,min:0,max:3,step:.05},{name:"grayscale",label:"Grayscale",unit:"",defaultValue:0,min:0,max:1,step:.05},{name:"sepia",label:"Sepia",unit:"",defaultValue:0,min:0,max:1,step:.05},{name:"invert",label:"Invert",unit:"",defaultValue:0,min:0,max:1,step:.05},{name:"hue-rotate",label:"Hue Rotate",unit:"deg",defaultValue:0,min:0,max:360,step:1},{name:"opacity",label:"Opacity",unit:"",defaultValue:1,min:0,max:1,step:.05}];function md(e){if(!e||e==="none")return[];let t=[],o=/([\w-]+)\(([^)]+)\)/g,n;for(;(n=o.exec(e))!==null;){let r=n[1],i=n[2],s=parseFloat(i);isNaN(s)||t.push({name:r,value:s})}return t}function gi(e){return e.length===0?"none":e.map(t=>{var r;let o=gr.find(i=>i.name===t.name),n=(r=o==null?void 0:o.unit)!=null?r:"";return`${t.name}(${t.value}${n})`}).join(" ")}function xl({value:e,onChange:t,accentColor:o,modified:n,panelContentRef:r}){let i=md(e),[s,l]=fd(!1),a=yl(null),c=yl(null);pd(()=>{if(!s)return;let B=M=>{a.current&&!a.current.contains(M.target)&&l(!1)};return document.addEventListener("mousedown",B,!0),()=>document.removeEventListener("mousedown",B,!0)},[s]);let d=gr.filter(B=>!i.some(M=>M.name===B.name)),p=B=>{let M=[...i,{name:B.name,value:B.defaultValue}];t(gi(M)),l(!1)},u=B=>{let M=i.filter((C,L)=>L!==B);t(gi(M))},g=(B,M)=>{let C=i.map((L,k)=>k===B?m(f({},L),{value:M}):L);t(gi(C))},x={width:"100%",padding:"4px 8px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',border:"none",borderRadius:2,outline:"none",backgroundColor:"transparent"},E=ud(B=>{var F;if(!c.current)return{position:"fixed",top:0,left:0};let M=c.current.getBoundingClientRect(),C=c.current.closest('[data-devtools="panel"]'),L=C?C.getBoundingClientRect():{top:0,left:0,bottom:9999},k=(F=r==null?void 0:r.current)==null?void 0:F.getBoundingClientRect(),W=B*24+8,Z=L.bottom-M.bottom<W;return m(f({position:"fixed"},Z?{bottom:L.bottom-M.top+2-L.top}:{top:M.bottom+2-L.top}),{left:k?k.left+4-L.left:M.left-L.left,width:k?k.width-8:140,zIndex:10001})},[r]),h={backgroundColor:"rgba(255, 255, 255, 0.95)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",border:"1px solid rgba(0,0,0,0.1)",borderRadius:4,padding:"4px 0",boxShadow:"0 4px 12px rgba(0,0,0,0.1)"},w={display:"block",width:"100%",padding:"4px 10px",border:"none",backgroundColor:"transparent",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#334155",cursor:"pointer",textAlign:"left"},D=B=>en("div",{ref:a,style:f(f({},E(B.length)),h),children:B.map(M=>en("button",{type:"button",onClick:()=>p(M),style:w,onMouseEnter:C=>{C.currentTarget.style.backgroundColor="rgba(0,0,0,0.05)"},onMouseLeave:C=>{C.currentTarget.style.backgroundColor="transparent"},children:M.label},M.name))});return i.length===0?Xn("div",{children:[Xn("div",{style:{display:"flex",alignItems:"center",gap:4},children:[en(Mn,{modified:!1,children:en("input",{type:"text",value:"",placeholder:"\u2014",readOnly:!0,style:m(f({},x),{color:"#999",cursor:"default"})})}),en("button",{ref:c,type:"button",onClick:()=>l(!s),style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,border:"none",borderRadius:2,backgroundColor:"transparent",color:"#94a3b8",cursor:"pointer",flexShrink:0},children:en(bl,{size:12})})]}),s&&D(gr)]}):Xn("div",{style:{display:"flex",flexDirection:"column",gap:4,position:"relative"},children:[i.map((B,M)=>{let C=gr.find(L=>L.name===B.name);return C?Xn("div",{style:{display:"flex",alignItems:"center",gap:4},children:[en("span",{style:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:n?o:"#94a3b8",fontWeight:n?600:400,width:56,flexShrink:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:C.label}),en(Mn,{modified:n,children:Xn("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"0 4px"},children:[en("input",{type:"range",min:C.min,max:C.max,step:C.step,value:B.value,onChange:L=>g(M,parseFloat(L.target.value)),style:{flex:1,height:2,appearance:"none",WebkitAppearance:"none",background:`linear-gradient(to right, ${o} ${(B.value-C.min)/(C.max-C.min)*100}%, rgba(0,0,0,0.1) ${(B.value-C.min)/(C.max-C.min)*100}%)`,borderRadius:1,outline:"none",cursor:"pointer"}}),en("input",{type:"number",min:C.min,max:C.max,step:C.step,value:C.unit==="px"||C.unit==="deg"?Math.round(B.value):Math.round(B.value*100)/100,onChange:L=>g(M,parseFloat(L.target.value)||0),style:m(f({},x),{width:44,padding:"2px 4px",textAlign:"right",flexShrink:0})}),C.unit&&en("span",{style:{fontSize:9,color:"#94a3b8",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',flexShrink:0,width:16},children:C.unit})]})}),en("button",{type:"button",onClick:()=>u(M),style:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,padding:0,border:"none",borderRadius:2,backgroundColor:"transparent",color:"#94a3b8",cursor:"pointer",flexShrink:0},children:en(gd,{size:10})})]},B.name):null}),d.length>0&&Xn("div",{children:[Xn("button",{ref:c,type:"button",onClick:()=>l(!s),style:{display:"flex",alignItems:"center",gap:4,padding:"2px 4px",border:"none",borderRadius:2,backgroundColor:"transparent",fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#94a3b8",cursor:"pointer"},children:[en(bl,{size:10}),"Add filter"]}),s&&D(d)]})]})}import{useCallback as xo,useEffect as xd,useRef as mr,useState as vl}from"react";import{AlignHorizontalSpaceAround as vd,AlignVerticalSpaceAround as Sd,Columns3 as wd,Grid2x2 as kd,RectangleHorizontal as Ed,Rows3 as Cd,UnfoldHorizontal as Sl,UnfoldVertical as wl}from"lucide-react";import{useCallback as hd,useEffect as yd,useRef as zo}from"react";import{jsx as bd}from"react/jsx-runtime";var mi=[0,1,2,4,8,12,16,20,24,28,32];function bo({value:e,onChange:t,onPreview:o,onScrubEnd:n,onReset:r,isModified:i,accentColor:s,defaultUnit:l="rem",snapSteps:a,color:c,style:d,children:p}){let u=zo(null),g=zo(null),x=zo(r),E=zo(i),h=zo(!1);x.current=r,E.current=i,yd(()=>{let D=M=>{let C=g.current;if(!C)return;C.hasMoved=!0,h.current=M.shiftKey;let L=C.unit==="rem"||C.unit==="em"?.1:1;C.accum+=M.movementX*L;let k=Math.max(0,Math.round((C.startValue+C.accum)*10)/10);if(M.shiftKey&&a){let W=C.unit==="rem"||C.unit==="em"?parseFloat(getComputedStyle(document.documentElement).fontSize)||16:1,ee=C.unit==="rem"||C.unit==="em"?k*W:k,Z=a[a.length-1];for(let F=0;F<a.length-1;F++){let K=a[F],q=a[F+1];if(ee<=(K+q)/2){Z=K;break}if(ee<q){Z=q;break}}ee>a[a.length-1]&&(Z=Math.round(ee/8)*8),k=C.unit==="rem"||C.unit==="em"?Math.round(Z/W*1e3)/1e3:Z}o==null||o(`${k}${C.unit}`)},B=()=>{let M=g.current;if(!M)return;let C=Math.max(0,Math.round((M.startValue+M.accum)*10)/10);if(h.current&&a){let k=M.unit==="rem"||M.unit==="em"?parseFloat(getComputedStyle(document.documentElement).fontSize)||16:1,W=M.unit==="rem"||M.unit==="em"?C*k:C,ee=a[a.length-1];for(let Z=0;Z<a.length-1;Z++){let F=a[Z],K=a[Z+1];if(W<=(F+K)/2){ee=F;break}if(W<K){ee=K;break}}W>a[a.length-1]&&(ee=Math.round(W/8)*8),C=M.unit==="rem"||M.unit==="em"?Math.round(ee/k*1e3)/1e3:ee}let L=M.hasMoved&&C!==M.startValue;g.current=null,document.exitPointerLock(),L?t(`${C}${M.unit}`):M.hasMoved?o==null||o(`${M.startValue}${M.unit}`):E.current&&x.current&&x.current(),n==null||n()};return document.addEventListener("mousemove",D),document.addEventListener("mouseup",B),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",B)}},[t,o,n]);let w=hd(D=>{var C;if(D.button!==0)return;D.preventDefault();let B=Dn(e),M=B.unit&&B.unit!=="px"?B.unit:l;g.current={startValue:B.num,unit:M,accum:0,hasMoved:!1},(C=u.current)==null||C.requestPointerLock()},[e,l]);return bd("span",{ref:u,onMouseDown:w,title:i?"Click to reset \xB7 Drag to scrub":"Drag to scrub",style:f({color:i?s||"#3b82f6":c||"#999",padding:"0 4px",display:"flex",alignItems:"center",cursor:"ew-resize"},d),children:p})}import{Fragment as hi,jsx as Se,jsxs as At}from"react/jsx-runtime";function Md({gridCols:e,gridRows:t,gridModified:o,accentColor:n,onColsChange:r,onRowsChange:i}){return Se(sn,{style:{width:100},children:At("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 4px"},children:[Se("input",{type:"number",min:1,max:12,value:e,onChange:s=>r(parseInt(s.target.value)||1),style:m(f({},Nt),{width:32,textAlign:"center",padding:2})}),Se("span",{style:{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:o?n:"#999",fontWeight:o?600:400,fontSize:11,margin:"0 4px"},children:"\xD7"}),Se("input",{type:"number",min:1,max:12,value:t,onChange:s=>i(parseInt(s.target.value)||1),style:m(f({},Nt),{width:32,textAlign:"center",padding:2})})]})})}function kl({element:e,getValue:t,getOriginalValue:o,handleChange:n,isModified:r,onResetProperty:i,isCollapsed:s,onToggle:l,sectionHeaderStyle:a,activeDropdown:c,onDropdownChange:d,panelContentRef:p,accentColor:u,onFieldHover:g,preferredUnit:x,onUnitCycle:E}){let h=d,w=t("display"),D=t("flex-direction"),B=El(w,D),M=w==="flex"||w==="inline-flex",C=w==="grid",L=M||C,k=t("width"),W=t("height"),ee=r("width")?k:rr(e,"width"),Z=r("height")?W:rr(e,"height"),F=yi(k,ee),K=yi(W,Z),q=t("min-width"),we=t("max-width"),le=t("min-height"),he=t("max-height"),Fe=vo(t("padding")),Ie=t("gap"),$e=t("row-gap"),J=t("column-gap"),V=t("grid-template-columns"),te=t("grid-template-rows"),fe=t("overflow"),Ce=V.split(/\s+/).filter(j=>j&&j!=="none").length||1,ge=te.split(/\s+/).filter(j=>j&&j!=="none").length||1,[ue,We]=vl(!1),me=c!==null,lt=me||ue,qe=me?.3:ue?.65:1,Ne=({mode:j,icon:Ee,active:He})=>Se("button",{type:"button",onClick:()=>Cl(j,n),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"6px 8px",border:"none",borderRadius:2,backgroundColor:He?Un(u,.15):"transparent",color:He?u:"#64748b",cursor:"pointer",fontSize:14},children:Ee}),tt=(j,Ee,He)=>{He==="fixed"?n(j,Ee):n(j,hr(He,Ee))},A=j=>{let Ee=vo(t("padding")),He=j||"0";n("padding",`${Ee.top} ${He} ${Ee.bottom} ${He}`)},re=j=>{let Ee=vo(t("padding")),He=j||"0";n("padding",`${He} ${Ee.right} ${He} ${Ee.left}`)},[de,Le]=vl({}),ke=xo((j,Ee)=>He=>{Ee(He),Le(qt=>m(f({},qt),{[j]:He}))},[]),Re=xo(j=>{Le(Ee=>{let He=f({},Ee);return delete He[j],He})},[]),ve=xo(j=>{let Ee=vo(t("padding"));ze(e,"padding",`${Ee.top} ${j} ${Ee.bottom} ${j}`)},[e,t]),at=xo(j=>{let Ee=vo(t("padding"));ze(e,"padding",`${j} ${Ee.right} ${j} ${Ee.left}`)},[e,t]),Qe=xo(j=>Ee=>{ze(e,j,Ee)},[e]),ft=D==="column"||D==="column-reverse",rt=j=>j==="center"?1:j==="flex-end"||j==="end"?2:0,gt=rt(t("justify-content")),ct=rt(t("align-items")),Ct=ft?ct:gt,Pe=ft?gt:ct,Kt=mr(null),mt=mr({x:0,y:0}),Dt=mr({col:Ct,row:Pe});Dt.current={col:Ct,row:Pe};let Wt=xo((j,Ee)=>{let He=["flex-start","center","flex-end"];ft?(n("justify-content",He[Ee]),n("align-items",He[j])):(n("justify-content",He[j]),n("align-items",He[Ee]))},[ft,n]),xn=mr(Wt);xn.current=Wt,xd(()=>{let Ee=He=>{let qt=Kt.current;if(!qt||!qt.contains(He.target))return;He.preventDefault(),He.stopPropagation(),mt.current.x+=He.deltaX,mt.current.y+=He.deltaY;let{col:nt,row:vt}=Dt.current,ut=!1;Math.abs(mt.current.x)>=30&&(nt=Math.max(0,Math.min(2,nt+(mt.current.x>0?1:-1))),mt.current.x=0,mt.current.y=0,ut=!0),!ut&&Math.abs(mt.current.y)>=30&&(vt=Math.max(0,Math.min(2,vt+(mt.current.y>0?1:-1))),mt.current.x=0,mt.current.y=0,ut=!0),ut&&(nt!==Dt.current.col||vt!==Dt.current.row)&&xn.current(nt,vt)};return document.addEventListener("wheel",Ee,{passive:!1,capture:!0}),()=>document.removeEventListener("wheel",Ee,{capture:!0})},[]);let Yt=()=>Se("div",{ref:Kt,onMouseEnter:()=>{We(!0),p.current&&(p.current.style.overflowY="hidden")},onMouseLeave:()=>{We(!1),p.current&&(p.current.style.overflowY="auto")},style:{width:56,height:56,backgroundColor:hn,borderRadius:2,display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gridTemplateRows:"repeat(3, 1fr)",padding:6,gap:2,touchAction:"none"},children:[0,1,2].map(j=>[0,1,2].map(Ee=>Se("button",{type:"button",onClick:()=>Wt(Ee,j),style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",border:"none",backgroundColor:"transparent",cursor:"pointer",padding:0},children:Ee===Ct&&j===Pe?Se("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",style:{flexShrink:0},children:Ee===0?At(hi,{children:[Se("rect",{x:"1",y:"1.5",width:"8",height:"1.2",rx:"0.5",fill:u}),Se("rect",{x:"1",y:"4.4",width:"5",height:"1.2",rx:"0.5",fill:u}),Se("rect",{x:"1",y:"7.3",width:"7",height:"1.2",rx:"0.5",fill:u})]}):Ee===1?At(hi,{children:[Se("rect",{x:"1",y:"1.5",width:"8",height:"1.2",rx:"0.5",fill:u}),Se("rect",{x:"2.5",y:"4.4",width:"5",height:"1.2",rx:"0.5",fill:u}),Se("rect",{x:"1.5",y:"7.3",width:"7",height:"1.2",rx:"0.5",fill:u})]}):At(hi,{children:[Se("rect",{x:"1",y:"1.5",width:"8",height:"1.2",rx:"0.5",fill:u}),Se("rect",{x:"4",y:"4.4",width:"5",height:"1.2",rx:"0.5",fill:u}),Se("rect",{x:"2",y:"7.3",width:"7",height:"1.2",rx:"0.5",fill:u})]})}):Se("div",{style:{width:5,height:5,borderRadius:"50%",backgroundColor:"#aaa"}})},`${j}-${Ee}`)))}),Zt=r("grid-template-columns")||r("grid-template-rows");return At("div",{style:{borderBottom:"1px solid rgba(0,0,0,0.08)"},children:[Se("div",{style:a,children:Se("span",{children:L?"Auto layout":"Layout"})}),At("div",{style:{padding:"8px 12px"},children:[At("div",{style:{display:"flex",gap:2,marginBottom:8,backgroundColor:hn,borderRadius:2,padding:2,opacity:qe,transition:"opacity 150ms ease"},children:[Se(Ne,{mode:"block",icon:Se(Ed,{size:16}),active:B==="block"}),Se(Ne,{mode:"flex-col",icon:Se(Cd,{size:16}),active:B==="flex-col"}),Se(Ne,{mode:"flex-row",icon:Se(wd,{size:16}),active:B==="flex-row"}),Se(Ne,{mode:"grid",icon:Se(kd,{size:16}),active:B==="grid"})]}),At("div",{style:{display:"flex",gap:4,marginBottom:8},children:[Se(bi,{label:"W",property:"width",cssValue:F==="fixed"?k:`${Math.round(e.getBoundingClientRect().width)}px`,mode:F,onValueChange:j=>n("width",j),onModeChange:j=>{if(j==="fixed"){let Ee=e.getBoundingClientRect();n("width",`${Math.round(Ee.width)}px`)}else n("width",hr(j,k))},modified:r("width"),dimmed:me&&c!=="width",dropdownOpen:c==="width",onDropdownChange:j=>h(j?"width":null),panelContentRef:p,accentColor:u,onReset:()=>i("width"),minValue:q!=="none"&&q!=="0px"&&q!=="auto"?q:"",maxValue:we!=="none"&&we!=="auto"?we:"",onMinChange:j=>n("min-width",j||"0"),onMaxChange:j=>n("max-width",j||"none"),onMinReset:()=>i("min-width"),onMaxReset:()=>i("max-width"),minModified:r("min-width"),maxModified:r("max-width")}),Se(bi,{label:"H",property:"height",cssValue:K==="fixed"?W:`${Math.round(e.getBoundingClientRect().height)}px`,mode:K,onValueChange:j=>n("height",j),onModeChange:j=>{if(j==="fixed"){let Ee=e.getBoundingClientRect();n("height",`${Math.round(Ee.height)}px`)}else n("height",hr(j,W))},modified:r("height"),dimmed:me&&c!=="height",dropdownOpen:c==="height",onDropdownChange:j=>h(j?"height":null),panelContentRef:p,minValue:le!=="none"&&le!=="0px"&&le!=="auto"?le:"",maxValue:he!=="none"&&he!=="auto"?he:"",onMinChange:j=>n("min-height",j||"0"),onMaxChange:j=>n("max-height",j||"none"),onMinReset:()=>i("min-height"),onMaxReset:()=>i("max-height"),minModified:r("min-height"),maxModified:r("max-height"),accentColor:u,onReset:()=>i("height")})]}),M&&At("div",{onMouseEnter:()=>g==null?void 0:g("gap"),onMouseLeave:()=>g==null?void 0:g("element"),style:{display:"flex",gap:8,marginBottom:8},children:[Se("div",{style:{opacity:me?.3:1,transition:"opacity 150ms ease"},children:Yt()}),At("div",{style:{flex:1,opacity:qe,transition:"opacity 150ms ease"},children:[Se("div",{onClick:r("gap")?()=>i("gap"):void 0,title:r("gap")?"Click to reset":void 0,style:{fontSize:9,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:r("gap")?u:"#999",fontWeight:r("gap")?600:400,marginBottom:2,cursor:r("gap")?"pointer":"default"},children:"Gap"}),Se(sn,{dimmed:me,children:At("div",{style:{display:"flex",alignItems:"center"},children:[Se(bo,{value:Ie,onChange:j=>{Re("gap"),n("gap",j)},onPreview:ke("gap",Qe("gap")),onScrubEnd:()=>Re("gap"),onReset:()=>i("gap"),isModified:r("gap"),accentColor:u,defaultUnit:x,children:D==="column"||D==="column-reverse"?Se(wl,{size:12,strokeWidth:r("gap")?2.5:1.5}):Se(Sl,{size:12,strokeWidth:r("gap")?2.5:1.5})}),Se(mn,{property:"gap",value:de.gap||Ie,onChange:j=>n("gap",j),isModified:r("gap")||"gap"in de,style:m(f({},Nt),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:x,onUnitCycle:E})]})})]})]}),C&&At("div",{onMouseEnter:()=>g==null?void 0:g("gap"),onMouseLeave:()=>g==null?void 0:g("element"),style:{display:"flex",gap:8,marginBottom:8,opacity:qe,transition:"opacity 150ms ease"},children:[Se(Md,{gridCols:Ce,gridRows:ge,gridModified:Zt,accentColor:u,onColsChange:j=>n("grid-template-columns",`repeat(${j}, 1fr)`),onRowsChange:j=>n("grid-template-rows",`repeat(${j}, 1fr)`)}),At("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:4},children:[Se(sn,{dimmed:me,children:At("div",{style:{display:"flex",alignItems:"center"},children:[Se(bo,{value:J||Ie,onChange:j=>{Re("column-gap"),n("column-gap",j)},onPreview:ke("column-gap",Qe("column-gap")),onScrubEnd:()=>Re("column-gap"),onReset:()=>i("column-gap"),isModified:r("column-gap"),accentColor:u,defaultUnit:x,children:Se(Sl,{size:12,strokeWidth:r("column-gap")?2.5:1.5})}),Se(mn,{property:"column-gap",value:de["column-gap"]||J||Ie,onChange:j=>n("column-gap",j),isModified:r("column-gap")||"column-gap"in de,placeholder:"col",style:m(f({},Nt),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:x,onUnitCycle:E})]})}),Se(sn,{dimmed:me,children:At("div",{style:{display:"flex",alignItems:"center"},children:[Se(bo,{value:$e||Ie,onChange:j=>{Re("row-gap"),n("row-gap",j)},onPreview:ke("row-gap",Qe("row-gap")),onScrubEnd:()=>Re("row-gap"),onReset:()=>i("row-gap"),isModified:r("row-gap"),accentColor:u,defaultUnit:x,children:Se(wl,{size:12,strokeWidth:r("row-gap")?2.5:1.5})}),Se(mn,{property:"row-gap",value:de["row-gap"]||$e||Ie,onChange:j=>n("row-gap",j),isModified:r("row-gap")||"row-gap"in de,placeholder:"row",style:m(f({},Nt),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:x,onUnitCycle:E})]})})]})]}),L&&At("div",{onMouseEnter:()=>g==null?void 0:g("padding"),onMouseLeave:()=>g==null?void 0:g("element"),style:{display:"flex",gap:4,marginBottom:8,opacity:qe,transition:"opacity 150ms ease"},children:[Se(sn,{style:{flex:1},dimmed:me,children:At("div",{style:{display:"flex",alignItems:"center"},children:[Se(bo,{value:Fe.left,onChange:j=>{Re("padding-h"),A(j)},onPreview:ke("padding-h",ve),onScrubEnd:()=>Re("padding-h"),onReset:()=>i("padding"),isModified:r("padding"),accentColor:u,defaultUnit:x,snapSteps:mi,children:Se(vd,{size:12,strokeWidth:r("padding")?2.5:1.5})}),Se(mn,{property:"padding",value:de["padding-h"]||Fe.left,onChange:j=>A(j),isModified:r("padding")||"padding-h"in de,placeholder:"H pad",style:m(f({},Nt),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:x,onUnitCycle:E})]})}),Se(sn,{style:{flex:1},dimmed:me,children:At("div",{style:{display:"flex",alignItems:"center"},children:[Se(bo,{value:Fe.top,onChange:j=>{Re("padding-v"),re(j)},onPreview:ke("padding-v",at),onScrubEnd:()=>Re("padding-v"),onReset:()=>i("padding"),isModified:r("padding"),accentColor:u,defaultUnit:x,snapSteps:mi,children:Se(Sd,{size:12,strokeWidth:r("padding")?2.5:1.5})}),Se(mn,{property:"padding",value:de["padding-v"]||Fe.top,onChange:j=>re(j),isModified:r("padding")||"padding-v"in de,placeholder:"V pad",style:m(f({},Nt),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:x,onUnitCycle:E})]})})]}),At("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#64748b",opacity:qe,transition:"opacity 150ms ease"},children:[Se("input",{type:"checkbox",checked:fe==="hidden",onChange:j=>n("overflow",j.target.checked?"hidden":"visible"),style:{margin:0,accentColor:u}}),"Clip content"]})]})]})}import{AlignCenter as Td,AlignJustify as Id,AlignLeft as Ld,AlignRight as Rd,Baseline as Ad,ChevronDown as Pd,WholeWord as Bd}from"lucide-react";import{jsx as dt,jsxs as Tn}from"react/jsx-runtime";var Ml={100:"Thin",200:"Extra Light",300:"Light",400:"Regular",500:"Medium",600:"Semi Bold",700:"Bold",800:"Extra Bold",900:"Black"};function Tl({element:e,getValue:t,handleChange:o,isModified:n,onResetProperty:r,isCollapsed:i,onToggle:s,sectionHeaderStyle:l,accentColor:a,colorVariables:c,activeColorDropdown:d,onColorDropdownChange:p,panelContentRef:u,preferredUnit:g,onUnitCycle:x}){var K;let E=t("font-family"),h=t("font-size"),w=t("font-weight"),D=t("line-height"),B=t("letter-spacing"),M=t("text-align"),C=t("color"),L=String(w),k=Ml[L]||L,W=Do(e,C),ee=C.includes("var(")?null:Fo(W,c),Z=({align:q,icon:we})=>{let le=M===q;return dt("button",{type:"button",onClick:()=>o("text-align",q),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"6px 8px",border:"none",borderRadius:2,backgroundColor:le?Un(a,.15):"transparent",color:le?a:"#64748b",cursor:"pointer"},children:we})},F=((K=E.split(",")[0])==null?void 0:K.trim().replace(/^["']|["']$/g,""))||"System";return Tn("div",{style:{borderBottom:"1px solid rgba(0,0,0,0.08)"},children:[dt("div",{style:l,children:dt("span",{children:"Typography"})}),Tn("div",{style:{padding:"8px 12px",display:"flex",flexDirection:"column",gap:4},children:[dt(sn,{children:Tn("div",{style:{display:"flex",alignItems:"center",padding:"6px 8px"},children:[dt("input",{type:"text",value:E,onChange:q=>o("font-family",q.target.value),style:m(f({},Nt),{flex:1,minWidth:0,padding:0,fontWeight:n("font-family")?600:400,color:n("font-family")?a:"inherit"}),title:E}),dt(Pd,{size:12,style:{color:"#999",flexShrink:0,marginLeft:4}})]})}),Tn("div",{style:{display:"flex",gap:4},children:[dt(sn,{style:{flex:1},children:dt("select",{value:L,onChange:q=>o("font-weight",q.target.value),style:m(f({},Nt),{padding:"6px 8px",paddingLeft:4,paddingRight:20,cursor:"pointer",fontWeight:n("font-weight")?600:400,color:n("font-weight")?a:"inherit"}),children:Object.entries(Ml).map(([q,we])=>dt("option",{value:q,children:we},q))})}),dt(sn,{style:{flex:1},children:dt("div",{style:{display:"flex",alignItems:"center",position:"relative"},children:dt(mn,{property:"font-size",value:h,onChange:q=>o("font-size",q),isModified:n("font-size"),min:1,max:999,style:m(f({},Nt),{padding:"6px 8px",paddingRight:24,fontWeight:n("font-size")?600:400,color:n("font-size")?a:"inherit"}),unitStyle:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999"},preferredUnit:g,onUnitCycle:x})})})]}),Tn("div",{style:{display:"flex",gap:4},children:[dt(sn,{style:{flex:1},children:Tn("div",{style:{display:"flex",alignItems:"center",padding:"6px 8px",gap:4},children:[dt(Ad,{size:12,style:{color:n("line-height")?a:"#999",flexShrink:0}}),dt(mn,{property:"line-height",value:D,onChange:q=>o("line-height",q),isModified:n("line-height"),step:.1,min:0,placeholder:"Auto",style:m(f({},Nt),{flex:1,minWidth:0,padding:0,fontWeight:n("line-height")?600:400,color:n("line-height")?a:"inherit"}),showUnit:!1})]})}),dt(sn,{style:{flex:1},children:Tn("div",{style:{display:"flex",alignItems:"center",padding:"6px 8px",gap:4},children:[dt(Bd,{size:12,style:{color:n("letter-spacing")?a:"#999",flexShrink:0}}),dt(mn,{property:"letter-spacing",value:B,onChange:q=>o("letter-spacing",q),isModified:n("letter-spacing"),step:.1,placeholder:"\u2014",style:m(f({},Nt),{flex:1,minWidth:0,padding:0,fontWeight:n("letter-spacing")?600:400,color:n("letter-spacing")?a:"inherit"}),showUnit:!1})]})})]}),Tn("div",{style:{display:"flex",gap:2,backgroundColor:hn,borderRadius:2,padding:2},children:[dt(Z,{align:"left",icon:dt(Ld,{size:14})}),dt(Z,{align:"center",icon:dt(Td,{size:14})}),dt(Z,{align:"right",icon:dt(Rd,{size:14})}),dt(Z,{align:"justify",icon:dt(Id,{size:14})})]}),Tn("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 0"},children:[dt("span",{onClick:n("color")?()=>r("color"):void 0,title:n("color")?"Click to reset":void 0,style:{fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:n("color")?a:"#64748b",fontWeight:n("color")?600:400,cursor:n("color")?"pointer":"default",width:40,flexShrink:0},children:"Color"}),dt("div",{style:{flex:1,minWidth:0},children:dt(xi,{value:C,resolvedValue:W,colorVariables:c,matchingVariable:ee,onChange:q=>o("color",q),accentColor:a,modified:n("color"),panelContentRef:u,isDropdownOpen:d==="color",onDropdownChange:q=>p(q?"color":null)})})]})]})]})}import{Fragment as Hd,jsx as ce,jsxs as bt}from"react/jsx-runtime";var Ll=[{name:"Background",properties:[{property:"background-color",label:"Color",type:"color"},{property:"opacity",label:"Opacity",type:"number",step:.1,min:0,max:1}]},{name:"Borders",properties:[{property:"border-width",label:"Width",type:"number",min:0,max:20},{property:"border-color",label:"Color",type:"color"},{property:"border-radius",label:"Radius",type:"number",min:0,max:100},{property:"border-style",label:"Style",type:"select",options:["none","solid","dashed","dotted","double"]}]},{name:"Effects",properties:[{property:"box-shadow",label:"Box Shadow",type:"text"},{property:"backdrop-filter",label:"Backdrop Filter",type:"backdrop-filter"},{property:"transform",label:"Transform",type:"text"}]}];function Nd(e,t){let o=t.trim().toLowerCase();switch(e){case"opacity":return o==="1";case"border-width":return o==="0px"||o==="0"||o==="medium";case"border-radius":return o==="0px"||o==="0";case"border-style":return o==="none";case"box-shadow":return o==="none";case"backdrop-filter":return o==="none"||o==="";case"letter-spacing":return o==="normal"||o==="0px"||o==="0";case"background-color":return o==="rgba(0, 0, 0, 0)"||o==="transparent";default:return!1}}function yi(e,t){return!t||e==="auto"||e==="fit-content"||e==="max-content"||e==="min-content"?"hug":e==="100%"||t==="100%"?"fill":"fixed"}function hr(e,t){switch(e){case"hug":return"fit-content";case"fill":return"100%";case"fixed":{let o=Dn(t);if(typeof o.num=="number"&&!isNaN(o.num)){let n=o.unit==="%"?"px":o.unit||"px";return`${o.num}${n}`}return"auto"}}}function vo(e){let t=e.split(/\s+/).filter(Boolean);return t.length===1?{top:t[0],right:t[0],bottom:t[0],left:t[0]}:t.length===2?{top:t[0],right:t[1],bottom:t[0],left:t[1]}:t.length===3?{top:t[0],right:t[1],bottom:t[2],left:t[1]}:t.length>=4?{top:t[0],right:t[1],bottom:t[2],left:t[3]}:{top:"0px",right:"0px",bottom:"0px",left:"0px"}}function El(e,t){return e==="grid"?"grid":e==="flex"||e==="inline-flex"?t==="column"||t==="column-reverse"?"flex-col":"flex-row":"block"}function Cl(e,t){switch(e){case"block":t("display","block");break;case"flex-row":t("display","flex"),t("flex-direction","row");break;case"flex-col":t("display","flex"),t("flex-direction","column");break;case"grid":t("display","grid");break}}var hn="rgba(0, 0, 0, 0.04)",Nt={width:"100%",padding:"4px 8px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',border:"none",borderRadius:2,outline:"none",backgroundColor:"transparent"};function bi({label:e,property:t,cssValue:o,mode:n,onValueChange:r,onModeChange:i,modified:s,dimmed:l,dropdownOpen:a,onDropdownChange:c,panelContentRef:d,accentColor:p="#3b82f6",onReset:u,minValue:g,maxValue:x,onMinChange:E,onMaxChange:h,onMinReset:w,onMaxReset:D,minModified:B,maxModified:M}){let C=Dn(o),L=s?C.unit||yo(t):yo(t),k=!s&&C.unit&&C.unit!==L?fi(C.num,L):C.num,[W,ee]=Ht(!1),[Z,F]=Ht(String(k)),[K,q]=Ht(!1),we=tn(null),le=tn(null),he=tn(null),Fe=tn(!1);pn(()=>{W||F(String(k))},[k,W]),pn(()=>{if(!a)return;let ge=We=>{le.current&&!le.current.contains(We.target)&&he.current&&!he.current.contains(We.target)&&(c==null||c(!1))},ue=We=>{We.key==="Escape"&&(c==null||c(!1))};return document.addEventListener("mousedown",ge),document.addEventListener("keydown",ue),()=>{document.removeEventListener("mousedown",ge),document.removeEventListener("keydown",ue)}},[a,c]),pn(()=>{W&&we.current&&(we.current.focus(),we.current.select())},[W]);let Ie=()=>{let ge=fr(Z,t,o,s);r(ge||`${Math.max(0,parseFloat(Z)||0)}${L}`),ee(!1)},$e=()=>{if(Fe.current){Fe.current=!1;return}Ie()},J=ge=>{if(ge.key==="Enter"){Ie();return}if(ge.key==="Escape"){Fe.current=!0,F(String(k)),ee(!1);return}if(ge.key==="ArrowUp"||ge.key==="ArrowDown"){ge.preventDefault();let ue=ge.key==="ArrowUp"?1:-1,We=ge.shiftKey?8:ge.altKey?.1:1,me=parseFloat(Z)||0,lt=Math.round(Math.max(0,me+ue*We)*1e3)/1e3;F(String(lt)),r(`${lt}${L}`)}},V={fixed:"Fixed",hug:"Hug",fill:"Fill"},te={fixed:ce(Il,{size:12}),hug:ce(Dd,{size:12}),fill:ce(Il,{size:12})},fe=()=>{c==null||c(!a)},Ce=()=>{if(!he.current||!(d!=null&&d.current))return{position:"absolute",top:"100%",left:-4,right:-4,width:"calc(100% + 8px)",marginTop:4};let ge=he.current.getBoundingClientRect(),ue=d.current.getBoundingClientRect(),We=d.current.closest('[data-devtools="panel"]'),me=We?We.getBoundingClientRect():{top:0,left:0};return{position:"fixed",top:ge.bottom+4-me.top,left:ue.left+4-me.left,width:ue.width-8}};return bt("div",{ref:he,onMouseEnter:()=>q(!0),onMouseLeave:()=>q(!1),style:{flex:1,display:"flex",alignItems:"center",position:"relative",borderRadius:2,border:"1px solid",borderColor:W?p:K?"rgba(0,0,0,0.15)":"transparent",backgroundColor:hn,transition:"border-color 100ms ease, opacity 150ms ease",opacity:l?.3:1},children:[ce("span",{onClick:s&&u?u:void 0,title:s?"Click to reset":void 0,style:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:s?p:"#999",fontWeight:s?600:400,padding:"0 8px",flexShrink:0,cursor:s?"pointer":"default"},children:e}),n==="fixed"?W?ce("input",{ref:we,type:"text",inputMode:"numeric",value:Z,onChange:ge=>F(ge.target.value),onKeyDown:J,onBlur:$e,style:m(f({},Nt),{flex:1,minWidth:0,padding:"4px 2px"})}):ce("span",{onClick:()=>ee(!0),style:{flex:1,padding:"4px 2px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',cursor:"text"},children:k}):ce("span",{style:{flex:1}}),bt("button",{type:"button",onClick:fe,style:{display:"flex",alignItems:"center",gap:2,padding:"4px 8px",border:"none",outline:"none",backgroundColor:"transparent",color:"#999",fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',cursor:"pointer",flexShrink:0},children:[V[n],ce(vi,{size:12})]}),a&&bt("div",{ref:le,style:m(f({},Ce()),{backgroundColor:"#ffffff",border:"1px solid rgba(0,0,0,0.1)",borderRadius:0,zIndex:10001,overflow:"hidden",fontSize:12,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'}),children:[bt("button",{type:"button",onClick:()=>{i("fixed"),c==null||c(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",outline:"none",backgroundColor:n==="fixed"?"#f1f5f9":"transparent",color:"#1e293b",fontWeight:n==="fixed"?600:400,cursor:"pointer",textAlign:"left"},children:[te.fixed,bt("span",{children:["Fixed ",t," (",o,")"]}),n==="fixed"&&ce(yr,{size:14,style:{marginLeft:"auto"}})]}),bt("button",{type:"button",onClick:()=>{i("hug"),c==null||c(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",outline:"none",backgroundColor:n==="hug"?"#f1f5f9":"transparent",color:"#1e293b",fontWeight:n==="hug"?600:400,cursor:"pointer",textAlign:"left"},children:[te.hug,ce("span",{children:"Hug contents"}),n==="hug"&&ce(yr,{size:14,style:{marginLeft:"auto"}})]}),bt("button",{type:"button",onClick:()=>{i("fill"),c==null||c(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",outline:"none",backgroundColor:n==="fill"?"#f1f5f9":"transparent",color:"#1e293b",fontWeight:n==="fill"?600:400,cursor:"pointer",textAlign:"left"},children:[te.fill,ce("span",{children:"Fill container"}),n==="fill"&&ce(yr,{size:14,style:{marginLeft:"auto"}})]}),ce("div",{style:{borderTop:"1px solid rgba(0,0,0,0.08)",margin:"4px 0"}}),bt("div",{style:{padding:"8px 12px",display:"flex",flexDirection:"column",gap:4},children:[bt("div",{style:{display:"flex",alignItems:"center",backgroundColor:hn,borderRadius:2,padding:"4px 8px"},children:[ce("span",{onClick:B?ge=>{ge.stopPropagation(),w==null||w()}:void 0,title:B?"Click to reset":void 0,style:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:B?p:"#999",fontWeight:B?600:400,marginRight:8,flexShrink:0,cursor:B?"pointer":"default"},children:"Min"}),ce("input",{type:"text",value:g||"",placeholder:"\u2014",onChange:ge=>E==null?void 0:E(ge.target.value),onClick:ge=>ge.stopPropagation(),style:m(f({},Nt),{flex:1,minWidth:0,padding:0,textAlign:"right",color:B?p:"inherit",fontWeight:B?600:400})})]}),bt("div",{style:{display:"flex",alignItems:"center",backgroundColor:hn,borderRadius:2,padding:"4px 8px"},children:[ce("span",{onClick:M?ge=>{ge.stopPropagation(),D==null||D()}:void 0,title:M?"Click to reset":void 0,style:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:M?p:"#999",fontWeight:M?600:400,marginRight:8,flexShrink:0,cursor:M?"pointer":"default"},children:"Max"}),ce("input",{type:"text",value:x||"",placeholder:"\u2014",onChange:ge=>h==null?void 0:h(ge.target.value),onClick:ge=>ge.stopPropagation(),style:m(f({},Nt),{flex:1,minWidth:0,padding:0,textAlign:"right",color:M?p:"inherit",fontWeight:M?600:400})})]})]})]})]})}function sn({children:e,style:t,dimmed:o}){let[n,r]=Ht(!1);return ce("div",{onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:f({position:"relative",borderRadius:2,border:"1px solid",borderColor:n?"rgba(0,0,0,0.15)":"transparent",backgroundColor:hn,transition:"border-color 100ms ease, opacity 150ms ease",opacity:o?.3:1},t),children:e})}function Mn({children:e}){let[t,o]=Ht(!1);return ce("div",{onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{position:"relative",borderRadius:2,border:"1px solid",borderColor:t?"rgba(0,0,0,0.15)":"transparent",backgroundColor:hn,transition:"border-color 100ms ease"},children:e})}function mn({property:e,value:t,onChange:o,isModified:n=!1,step:r=1,min:i,max:s,style:l,placeholder:a,showUnit:c=!0,unitStyle:d,preferredUnit:p,onUnitCycle:u}){let g=Dn(t),x=yo(e),E=pr[e],w=p&&E&&E.includes(p)?p:x,D=n&&g.unit||w,B=!n&&g.unit&&g.unit!==D?fi(g.num,D):g.num,[M,C]=Ht(!1),[L,k]=Ht(""),W=$e=>{C(!0),k(String(B||"")),requestAnimationFrame(()=>$e.target.select())},ee=()=>{if(C(!1),L.trim()){let $e=fr(L,e,t,n);$e&&o($e)}},Z=$e=>{let J=$e.target.value;k(J);let V=J.trim(),te=V.match(/^(-?[\d.]+)\s*(rem|em|px|%)$/i),fe=V.match(/^(-?[\d.]+)$/);if(te){let Ce=parseFloat(te[1]);isNaN(Ce)||o(`${Ce}${te[2].toLowerCase()}`)}else if(fe){let Ce=parseFloat(fe[1]);isNaN(Ce)||o(`${Ce}${D}`)}},F=$e=>{if($e.key==="Enter"){if(L.trim()){let J=fr(L,e,t,n);J&&o(J)}$e.target.blur();return}if($e.key==="ArrowUp"||$e.key==="ArrowDown"){$e.preventDefault();let J=$e.shiftKey?10:$e.altKey?.1:1,V=($e.key==="ArrowUp"?1:-1)*r*J,te=parseFloat(L)||B||0,fe=Math.round((te+V)*1e3)/1e3;i!==void 0&&(fe=Math.max(i,fe)),s!==void 0&&(fe=Math.min(s,fe)),k(String(fe)),o(`${fe}${D}`)}},K=/^-?[\d.]/.test(t.trim()),q=M?L:K?String(B):"",le=M&&/\s*(rem|em|px|%)\s*$/i.test(L)?"":D,he=u&&(le==="rem"||le==="px"),Fe={fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",pointerEvents:"none"},Ie=m(f({},d!=null?d:Fe),{pointerEvents:"auto",cursor:"pointer"});return bt(Hd,{children:[ce("input",{type:"text",inputMode:"decimal",value:q,onFocus:W,onBlur:ee,onChange:Z,onKeyDown:F,placeholder:a,style:l}),c&&le&&ce("span",{style:he?Ie:d!=null?d:Fe,onClick:he?u:void 0,title:he?"Click to switch units":void 0,children:le})]})}function xi({value:e,resolvedValue:t,colorVariables:o,matchingVariable:n,onChange:r,accentColor:i="#3b82f6",modified:s,panelContentRef:l,isDropdownOpen:a,onDropdownChange:c}){let[d,p]=Ht(!1),u=!e.includes("var(")&&n?n.usage:e,[g,x]=Ht(u),[E,h]=Ht(!1),[w,D]=Ht(!1),[B,M]=Ht(!1),C=tn(null),L=tn(null),k=tn(null),W=a!==void 0?a:E,ee=c||h,Z=wn(()=>{if(!k.current)return{position:"fixed",top:0,left:0,width:200};let J=k.current.getBoundingClientRect(),V=k.current.closest('[data-devtools="panel"]'),te=V?V.getBoundingClientRect():{top:0,left:0};if(l!=null&&l.current){let fe=l.current.getBoundingClientRect();return{position:"fixed",top:J.bottom+4-te.top,left:fe.left+4-te.left,width:fe.width-8}}return{position:"fixed",top:J.bottom+4-te.top,left:J.left-te.left,width:J.width}},[l]);pn(()=>{if(!d){let J=!e.includes("var(")&&n?n.usage:e;x(J)}},[e,d,n]),pn(()=>{if(!W&&!w)return;let J=te=>{k.current&&!k.current.contains(te.target)&&(ee(!1),D(!1))},V=te=>{te.key==="Escape"&&(ee(!1),D(!1))};return document.addEventListener("mousedown",J),document.addEventListener("keydown",V),()=>{document.removeEventListener("mousedown",J),document.removeEventListener("keydown",V)}},[W,w]),pn(()=>{d&&C.current&&(C.current.focus(),C.current.select())},[d]);let F=br(()=>{if(!g||g.startsWith("#")||g.startsWith("rgb")||g.startsWith("hsl")||g.startsWith("oklch"))return[];let J=g.toLowerCase();return o.filter(V=>V.name.toLowerCase().includes(J)||V.usage.toLowerCase().includes(J)).slice(0,8)},[g,o]),K=()=>{r(g),p(!1),D(!1)},q=J=>{x(J),J.includes("var")||J.includes("--")||J.length>0&&!J.startsWith("#")?D(!0):D(!1)},we=J=>{x(J.usage),r(J.usage),ee(!1),D(!1),p(!1)},le=()=>{setTimeout(()=>{!W&&!w&&K()},150)},he=J=>{J.key==="Enter"?K():J.key==="Escape"&&(x(e),p(!1),D(!1))},Fe=br(()=>{let J=t.trim().toLowerCase();if(J.startsWith("#"))return J.length===4?`#${J[1]}${J[1]}${J[2]}${J[2]}${J[3]}${J[3]}`:J.slice(0,7);let V=J.match(/rgba?\((\d+),?\s*(\d+),?\s*(\d+)/);if(V){let fe=parseInt(V[1],10).toString(16).padStart(2,"0"),Ce=parseInt(V[2],10).toString(16).padStart(2,"0"),ge=parseInt(V[3],10).toString(16).padStart(2,"0");return`#${fe}${Ce}${ge}`}let te=J.match(/oklch\(\s*([\d.]+)/);if(te){let fe=Math.max(0,Math.min(1,parseFloat(te[1]))),Ce=Math.round(fe*255).toString(16).padStart(2,"0");return`#${Ce}${Ce}${Ce}`}return"#000000"},[t]),Ie=J=>{let V=J.target.value;x(V),r(V)},$e=e.includes("var(");return bt("div",{ref:k,onMouseEnter:()=>M(!0),onMouseLeave:()=>M(!1),style:{position:"relative",borderRadius:2,border:"1px solid",borderColor:d?i:B?"rgba(0,0,0,0.15)":"transparent",backgroundColor:hn,transition:"border-color 100ms ease",overflow:"hidden"},children:[bt("div",{style:{display:"flex",alignItems:"center",minWidth:0},children:[bt("div",{style:{position:"relative",marginLeft:8,flexShrink:0},children:[ce("input",{type:"color",value:Fe,onChange:Ie,style:{width:12,height:12,padding:0,border:"none",cursor:"pointer",opacity:0,position:"absolute",top:0,left:0}}),ce("div",{style:{width:12,height:12,borderRadius:2,backgroundColor:t,border:"1px solid rgba(0,0,0,0.1)",pointerEvents:"none"}})]}),d?ce("input",{ref:C,type:"text",value:g,onChange:J=>q(J.target.value),onKeyDown:he,onBlur:le,style:m(f({},Nt),{flex:1,minWidth:0})}):ce("span",{onClick:()=>p(!0),style:{flex:1,minWidth:0,padding:"4px 8px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',cursor:"text",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:s?i:"inherit"},title:u,children:u}),o.length>0&&ce("button",{type:"button",onClick:()=>ee(!W),style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:24,border:"none",background:"none",cursor:"pointer",color:"#999",flexShrink:0},children:ce(vi,{size:12})})]}),w&&F.length>0&&ce("div",{style:m(f({},Z()),{backgroundColor:"#ffffff",border:"1px solid rgba(0,0,0,0.1)",borderRadius:0,zIndex:10001,maxHeight:200,overflowY:"auto",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'}),children:F.map(J=>bt("button",{type:"button",onClick:()=>we(J),style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",backgroundColor:"transparent",color:"#1e293b",cursor:"pointer",textAlign:"left",fontSize:12},children:[ce("div",{style:{width:14,height:14,borderRadius:2,backgroundColor:J.value,border:"1px solid rgba(0,0,0,0.1)",flexShrink:0}}),ce("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:J.name})]},J.name))}),W&&ce("div",{ref:L,style:m(f({},Z()),{backgroundColor:"#ffffff",border:"1px solid rgba(0,0,0,0.1)",borderRadius:0,zIndex:10001,maxHeight:280,overflowY:"auto",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'}),children:o.map(J=>bt("button",{type:"button",onClick:()=>we(J),style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",backgroundColor:u===J.usage||e===J.usage?"#f1f5f9":"transparent",color:"#1e293b",fontWeight:u===J.usage||e===J.usage?600:400,cursor:"pointer",textAlign:"left",fontSize:12},children:[ce("div",{style:{width:14,height:14,borderRadius:2,backgroundColor:J.value,border:"1px solid rgba(0,0,0,0.1)",flexShrink:0}}),ce("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:J.name}),(u===J.usage||e===J.usage)&&ce(yr,{size:14,style:{marginLeft:"auto",flexShrink:0}})]},J.name))})]})}function Rl({element:e,elementInfo:t,selector:o,styleModifications:n,dispatch:r,onClose:i,onHover:s,accentColor:l="#3b82f6"}){var Ne,tt;let a=tn(null),c=tn(null),[d,p]=Ht(()=>{try{return!!localStorage.getItem("devtools-panel-position")}catch(A){return!1}});pn(()=>{if(d)return;let A=setTimeout(()=>p(!0),50);return()=>clearTimeout(A)},[d]);let[u,g]=Ht(null),[x,E]=Ht(null),h=u!==null||x!==null,[w,D]=Ht("rem"),B=wn(()=>{D(A=>A==="rem"?"px":"rem")},[]),M=tn(new Map),[C,L]=Ht(""),k=br(()=>Qr(),[]);pn(()=>{let A=re=>{var Le;if(re.key!=="Escape")return;let de=document.activeElement;de&&((Le=a.current)!=null&&Le.contains(de))||i()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[i]);let W=tn({top:0,left:0,maxHeight:400}),[,ee]=Ht(0),Z="devtools-panel-position",F=tn({x:0,y:0}),K=tn(null),q=tn(!1);pn(()=>{try{let A=localStorage.getItem(Z);if(A){let re=JSON.parse(A);typeof re.top=="number"&&typeof re.left=="number"&&(q.current=!0,W.current=m(f({},W.current),{top:re.top,left:re.left}))}}catch(A){}},[]),pn(()=>{let A=de=>{let Le=K.current;if(!Le)return;let ke=Le.startOffsetX+(de.clientX-Le.startX),Re=Le.startOffsetY+(de.clientY-Le.startY),ve=280,at=16,Qe=Math.max(at,Math.min(window.innerWidth-ve-at,W.current.left+ke)),ft=Math.max(at,W.current.top+Re);F.current={x:Qe-W.current.left,y:ft-W.current.top};let rt=a.current,gt=rt==null?void 0:rt.parentElement;if(!gt)return;gt.style.top=`${ft}px`,gt.style.left=`${Qe}px`;let ct=document.getElementById("devtools-toolbar"),Ct=ct==null?void 0:ct.getBoundingClientRect(),Pe=window.innerHeight-16;Ct&&Qe+ve>Ct.left&&(Pe=Ct.top-8);let Kt=Math.max(0,ft),mt=Math.max(200,Pe-Kt);rt&&(rt.style.maxHeight=`${mt}px`)},re=()=>{if(!K.current)return;let de=W.current.top+F.current.y,Le=W.current.left+F.current.x;W.current=m(f({},W.current),{top:de,left:Le}),F.current={x:0,y:0},q.current=!0;try{localStorage.setItem(Z,JSON.stringify({top:de,left:Le}))}catch(ke){}K.current=null};return window.addEventListener("mousemove",A),window.addEventListener("mouseup",re),()=>{window.removeEventListener("mousemove",A),window.removeEventListener("mouseup",re)}},[]);let we=wn(A=>{A.button!==0||A.target.closest("button")||(A.preventDefault(),K.current={startX:A.clientX,startY:A.clientY,startOffsetX:F.current.x,startOffsetY:F.current.y})},[]);pn(()=>{F.current={x:0,y:0};let A=(Le=!1)=>{let ke=a.current,Re=280,ve=8,at,Qe;if(q.current)at=W.current.top,Qe=W.current.left;else{let Pe=e.getBoundingClientRect();Qe=Pe.right+ve,at=Pe.top,Qe+Re>window.innerWidth-ve&&(Qe=Pe.left-Re-ve),Qe<ve&&(Qe=Math.max(ve,(window.innerWidth-Re)/2))}let ft=document.getElementById("devtools-toolbar"),rt=ft==null?void 0:ft.getBoundingClientRect(),gt=window.innerHeight-16;rt&&Qe+Re>rt.left&&(gt=rt.top-ve);let ct=Math.max(0,at),Ct=Math.max(200,gt-ct);if(W.current={top:at,left:Qe,maxHeight:Ct},Le&&ke){let Pe=ke.parentElement;Pe&&!q.current&&(Pe.style.top=`${at+F.current.y}px`,Pe.style.left=`${Qe+F.current.x}px`),ke.style.maxHeight=`${Ct}px`}else ee(Pe=>Pe+1)};A(!1);let re=()=>A(!0),de=()=>A(!1);return window.addEventListener("scroll",re,{passive:!0}),window.addEventListener("resize",de,{passive:!0}),()=>{window.removeEventListener("scroll",re),window.removeEventListener("resize",de)}},[e]),pn(()=>{let A=a.current;if(!A)return;let re=de=>{let Le=c.current;if(!Le){de.preventDefault();return}let{scrollTop:ke,scrollHeight:Re,clientHeight:ve}=Le,at=ke<=0&&de.deltaY<0,Qe=ke+ve>=Re&&de.deltaY>0;(at||Qe)&&de.preventDefault()};return A.addEventListener("wheel",re,{passive:!1}),()=>A.removeEventListener("wheel",re)},[]);let le=br(()=>n.find(A=>A.selector===o),[n,o]),he=wn(A=>{let re=le==null?void 0:le.changes.find(de=>de.property===A);if(re)return re.modified;if(A.includes("color")){let de=Jr(e,A);if(de&&de.includes("var("))return de}return Po(e,A)},[e,le]),Fe=wn(A=>{if(M.current.has(A))return M.current.get(A);let re=le==null?void 0:le.changes.find(Le=>Le.property===A);if(re)return re.original;let de=Po(e,A);return M.current.set(A,de),de},[e,le]),Ie=wn((A,re)=>{let de=Fe(A);ze(e,A,re),A==="backdrop-filter"&&ze(e,"-webkit-backdrop-filter",re),r({type:"MODIFY_STYLE",payload:{selector:o,element:t,property:A,original:de,modified:re}})},[e,o,t,r,Fe]),$e=wn(()=>{qr(o,n);let A=n.find(re=>re.selector===o);if(A)for(let re of A.changes)r({type:"CLEAR_STYLE",payload:{selector:o,property:re.property}});M.current.clear()},[o,n,r]),J=wn(A=>{let re=n.find(Le=>Le.selector===o);re!=null&&re.changes.find(Le=>Le.property===A)&&e instanceof HTMLElement&&(e.style.removeProperty(A),r({type:"CLEAR_STYLE",payload:{selector:o,property:A}}),M.current.delete(A))},[e,o,n,r]),V=wn(()=>{let A=C.split(";").map(re=>re.trim()).filter(re=>re);for(let re of A){let de=re.indexOf(":");if(de>0){let Le=re.slice(0,de).trim(),ke=re.slice(de+1).trim();Le&&ke&&Ie(Le,ke)}}L("")},[C,Ie]),te=wn(A=>{var re;return(re=le==null?void 0:le.changes.some(de=>de.property===A))!=null?re:!1},[le]),fe=A=>{var Re;let re=he(A.property),de=te(A.property),Le=!de&&Nd(A.property,re),ke={width:"100%",padding:"4px 8px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',border:"none",borderRadius:2,outline:"none",backgroundColor:"transparent"};if(Le&&A.type!=="backdrop-filter")return ce(Mn,{modified:!1,children:ce("input",{type:"text",value:"",placeholder:"\u2014",onFocus:()=>{},onChange:ve=>Ie(A.property,ve.target.value),style:m(f({},ke),{color:"#999"})})});switch(A.type){case"color":{let ve=Do(e,re),at=re.includes("var(")?null:Fo(ve,k);return ce(xi,{value:re,resolvedValue:ve,colorVariables:k,matchingVariable:at,onChange:Qe=>Ie(A.property,Qe),accentColor:l,modified:de,panelContentRef:c,isDropdownOpen:x===A.property,onDropdownChange:Qe=>E(Qe?A.property:null)})}case"number":{if(!!pr[A.property])return ce(Mn,{modified:de,children:ce(mn,{property:A.property,value:re,onChange:Qe=>Ie(A.property,Qe),isModified:de,min:A.min,max:A.max,step:A.step||1,style:m(f({},ke),{paddingRight:32}),unitStyle:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999"},preferredUnit:w,onUnitCycle:B})});let{num:at}=Dn(re);return ce(Mn,{modified:de,children:ce("input",{type:"number",value:at,min:A.min,max:A.max,step:A.step||1,onChange:Qe=>Ie(A.property,Qe.target.value),style:ke})})}case"select":return ce(Mn,{modified:de,children:bt("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[ce("select",{value:re,onChange:ve=>Ie(A.property,ve.target.value),style:m(f({},ke),{cursor:"pointer",paddingLeft:4,paddingRight:24,appearance:"none",WebkitAppearance:"none"}),children:(Re=A.options)==null?void 0:Re.map(ve=>ce("option",{value:ve,children:ve},ve))}),ce("div",{style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",pointerEvents:"none",color:"#999",display:"flex",alignItems:"center"},children:ce(vi,{size:12})})]})});case"spacing":return ce(Mn,{modified:de,children:ce("input",{type:"text",value:re,onChange:ve=>Ie(A.property,ve.target.value),placeholder:"e.g., 10px or 10px 20px",style:ke})});case"backdrop-filter":return ce(xl,{value:re,onChange:ve=>Ie(A.property,ve),accentColor:l,modified:de,panelContentRef:c});default:return ce(Mn,{modified:de,children:ce("input",{type:"text",value:re,onChange:ve=>Ie(A.property,ve.target.value),style:ke})})}},Ce=(Ne=le==null?void 0:le.changes.length)!=null?Ne:0,ge=(tt=le==null?void 0:le.captured)!=null?tt:!1,ue=m(f({position:"fixed",top:W.current.top,left:W.current.left,width:280,maxHeight:W.current.maxHeight,backgroundColor:"rgba(255, 255, 255, 0.85)",backdropFilter:"blur(32px)",WebkitBackdropFilter:"blur(32px)"},gn),{zIndex:1e4,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',fontSize:12,overflow:"hidden",display:"flex",flexDirection:"column",opacity:d?1:0,transition:"opacity 150ms ease"}),We={display:"flex",alignItems:"center",justifyContent:"space-between",margin:"3px 3px 0",padding:"8px 7px 8px 12px",borderBottom:"1px solid rgba(0,0,0,0.1)",backgroundColor:"#f8fafc",cursor:K.current?"grabbing":"grab"},me={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 12px 6px",userSelect:"none",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',fontWeight:600,color:"#475569"},lt={display:"flex",alignItems:"center",padding:"4px 12px",gap:8},qe={width:80,fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#64748b",flexShrink:0};return ce("div",{"data-devtools":"panel-wrapper",style:{position:"fixed",top:W.current.top+F.current.y,left:W.current.left+F.current.x,zIndex:1e4,pointerEvents:"none"},children:bt("div",{ref:a,"data-devtools":"panel",style:m(f({},ue),{position:"relative",top:0,left:0,zIndex:0,pointerEvents:"auto"}),onMouseEnter:()=>s==null?void 0:s("element"),onMouseLeave:()=>s==null?void 0:s(null),children:[bt("div",{style:We,onMouseDown:we,children:[bt("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[ce("span",{style:{fontWeight:600,fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.tagName}),Ce>0&&ce("span",{style:{backgroundColor:ge?"#999999":l,color:"#fff",fontSize:9,padding:"1px 4px",borderRadius:2},children:Ce})]}),bt("div",{style:{display:"flex",gap:4},children:[Ce>0&&ce("button",{type:"button",onClick:$e,title:"Reset all changes",style:{display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,border:"none",background:"none",cursor:"pointer",color:"#64748b",borderRadius:2},children:ce(Od,{size:14})}),ce("button",{type:"button",onClick:i,title:"Close",style:{display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,border:"none",background:"none",cursor:"pointer",color:"#64748b",borderRadius:2},children:ce(Fd,{size:14})})]})]}),bt("div",{ref:c,style:{flex:1,overflowY:"auto",margin:"0 3px 3px"},children:[ce("div",{style:{opacity:x?.3:1,transition:"opacity 150ms ease"},children:ce(kl,{element:e,getValue:he,getOriginalValue:Fe,handleChange:Ie,isModified:te,onResetProperty:J,isCollapsed:!1,onToggle:()=>{},sectionHeaderStyle:me,activeDropdown:u,onDropdownChange:g,panelContentRef:c,accentColor:l,onFieldHover:s,preferredUnit:w,onUnitCycle:B})}),ce("div",{style:{opacity:u?.3:1,transition:"opacity 150ms ease"},children:ce(Tl,{element:e,getValue:he,handleChange:Ie,isModified:te,onResetProperty:J,isCollapsed:!1,onToggle:()=>{},sectionHeaderStyle:me,accentColor:l,colorVariables:k,activeColorDropdown:x,onColorDropdownChange:E,panelContentRef:c,preferredUnit:w,onUnitCycle:B})}),Ll.map((A,re)=>{let de=re===Ll.length-1,Le=x&&A.properties.some(Re=>Re.property===x);return bt("div",{style:{borderBottom:de?"none":"1px solid rgba(0,0,0,0.08)",opacity:h&&!Le?.3:1,transition:"opacity 150ms ease"},children:[ce("div",{style:me,children:ce("span",{children:A.name})}),ce("div",{style:{padding:"4px 0"},children:A.properties.map(Re=>{let ve=te(Re.property),at=Le&&Re.property!==x;return bt("div",{style:m(f({},lt),{opacity:at?.3:1,transition:"opacity 150ms ease"}),children:[ce("span",{onClick:ve?()=>J(Re.property):void 0,title:ve?"Click to reset":void 0,style:m(f({},qe),{color:ve?l:"#64748b",fontWeight:ve?600:400,cursor:ve?"pointer":"default"}),children:Re.label}),ce("div",{style:{flex:1,minWidth:0,overflow:"hidden"},children:fe(Re)})]},Re.property)})})]},A.name)}),bt("div",{style:{opacity:h?.3:1,transition:"opacity 150ms ease"},children:[ce("div",{style:me,children:ce("span",{children:"Raw CSS"})}),bt("div",{style:{padding:"8px 12px"},children:[ce("textarea",{value:C,onChange:A=>L(A.target.value),placeholder:"property: value; ...",style:{width:"100%",height:60,padding:8,fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',border:"1px solid rgba(0,0,0,0.1)",borderRadius:2,resize:"vertical",outline:"none"}}),C.trim()&&ce("button",{type:"button",onClick:V,style:{marginTop:4,padding:"4px 8px",width:"100%",fontSize:11,border:"none",borderRadius:2,backgroundColor:l,color:"#fff",cursor:"pointer",opacity:C.trim()?1:.5},children:"Apply"})]})]})]})]})})}import{useEffect as zd,useLayoutEffect as _d,useState as $d}from"react";import{Fragment as Gd,jsx as Kn,jsxs as jd}from"react/jsx-runtime";var Si=["flex-start","center","flex-end"],wi=["flex-start","center","flex-end"];function Wd(e){return e==="normal"||e==="flex-start"||e==="start"?"flex-start":e==="flex-end"||e==="end"?"flex-end":e==="center"?"center":null}function Yd(e){return e==="normal"||e==="stretch"||e==="flex-start"||e==="start"?"flex-start":e==="flex-end"||e==="end"?"flex-end":e==="center"?"center":null}function Al(e){let t=Array.from(e.children);if(t.length===0)return null;let o=1/0,n=1/0,r=-1/0,i=-1/0;for(let s of t){let l=s.getBoundingClientRect();l.width===0&&l.height===0||(l.top<o&&(o=l.top),l.left<n&&(n=l.left),l.bottom>r&&(r=l.bottom),l.right>i&&(i=l.right))}return o===1/0?null:new DOMRect(n,o,i-n,r-o)}function Pl({element:e,modifier:t,accentColor:o,refreshKey:n=0}){let[r,i]=$d(null);if(zd(()=>{if(!e){i(null);return}let E=()=>i(Al(e));return E(),window.addEventListener("scroll",E,{passive:!0}),window.addEventListener("resize",E,{passive:!0}),()=>{window.removeEventListener("scroll",E),window.removeEventListener("resize",E)}},[e]),_d(()=>{e&&i(Al(e))},[e,n]),!r)return null;let s=r,l=window.getComputedStyle(e),a=l.display;if(a!=="flex"&&a!=="inline-flex")return null;let c=l.flexDirection,d=c==="column"||c==="column-reverse"?"vertical":"horizontal",p=d==="horizontal"?"vertical":"horizontal",u=[];if(t==="shift"){let E=Wd(l.justifyContent);if(E){let h=Si.indexOf(E);d==="horizontal"?(h>0&&u.push("left"),h<Si.length-1&&u.push("right")):(h>0&&u.push("up"),h<Si.length-1&&u.push("down"))}}else{let E=Yd(l.alignItems);if(E){let h=wi.indexOf(E);p==="horizontal"?(h>0&&u.push("left"),h<wi.length-1&&u.push("right")):(h>0&&u.push("up"),h<wi.length-1&&u.push("down"))}}if(u.length===0)return null;let g=14,x=7;return Kn(Gd,{children:u.map(E=>{let h,w;switch(E){case"right":h=s.right+g,w=s.top+s.height/2;break;case"left":h=s.left-g,w=s.top+s.height/2;break;case"down":h=s.left+s.width/2,w=s.bottom+g;break;case"up":h=s.left+s.width/2,w=s.top-g;break}let D=E==="right"?0:E==="left"?180:E==="down"?90:-90,B={position:"fixed",left:h-x,top:w-x,width:x*2,height:x*2,pointerEvents:"none",zIndex:9997};return Kn("div",{"data-devtools":"swipe-hint",style:B,children:Kn("svg",{width:x*2,height:x*2,viewBox:"-7 -7 14 14",style:{overflow:"visible"},children:jd("g",{transform:`rotate(${D})`,children:[Kn("line",{x1:"-5",y1:"0",x2:"3",y2:"0",stroke:"#fff",strokeWidth:"4",strokeLinecap:"round"}),Kn("polyline",{points:"0,-4 5,0 0,4",fill:"none",stroke:"#fff",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),Kn("line",{x1:"-5",y1:"0",x2:"3",y2:"0",stroke:o,strokeWidth:"1.5",strokeLinecap:"round"}),Kn("polyline",{points:"0,-4 5,0 0,4",fill:"none",stroke:o,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})},E)})})}import{useEffect as Vd,useLayoutEffect as Ud,useState as Jd}from"react";import{jsx as ki,jsxs as Ei}from"react/jsx-runtime";function Xd(e,t){let o=e.match(/^oklch\(([^)]+)\)$/i);return o?`oklch(${o[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}function Bl({element:e,fontSize:t,lineHeight:o,accentColor:n,hoveredProperty:r,draggingProperty:i,cursorViewport:s}){let[l,a]=Jd(null);if(Vd(()=>{if(!e){a(null);return}let w=()=>{a(po(e))};return w(),window.addEventListener("scroll",w,{passive:!0}),window.addEventListener("resize",w,{passive:!0}),()=>{window.removeEventListener("scroll",w),window.removeEventListener("resize",w)}},[e]),Ud(()=>{e&&a(po(e))},[e,t,o]),!l)return null;let c=l.width,d=l.height,p=Xd(n,.2),u=i!=null?i:r,g=8,x=2,E={position:"fixed",top:l.top,left:l.left,width:c,height:d,pointerEvents:"none",zIndex:9996,overflow:"visible"},h=w=>w==="font-size"?`${Math.round(t)}`:(t>0?o/t:1.2).toFixed(2).replace(/\.?0+$/,"");return Ei("div",{"data-devtools":"text-handles",style:E,children:[Ei("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:`0 0 ${c} ${d}`,children:[ki("rect",{x:"0.5",y:"0.5",width:Math.max(0,c-1),height:Math.max(0,d-1),fill:"none",stroke:p,strokeWidth:"1"}),(u==="font-size"||!u)&&ki("rect",{x:c-x/2,y:d/2-g/2,width:x,height:g,fill:n,stroke:"#ffffff",strokeWidth:u==="font-size"?4:2,paintOrder:"stroke"}),(u==="line-height"||!u)&&ki("rect",{x:c/2-g/2,y:d-x/2,width:g,height:x,fill:n,stroke:"#ffffff",strokeWidth:u==="line-height"?4:2,paintOrder:"stroke"})]}),s&&u&&(()=>{let w=u==="font-size"?"Aa":"Lh",D=h(u);return Ei("div",{style:{position:"fixed",left:s.x+8,top:s.y-28,background:n,color:"#fff",fontSize:11,fontWeight:600,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1,padding:"4px 4px",borderRadius:0,whiteSpace:"nowrap",pointerEvents:"none",zIndex:9997},children:[w," ",D]})})()]})}import{Fragment as wo,jsx as ot,jsxs as So}from"react/jsx-runtime";var Ol=8,Mi=[0,1,2,4,8,12,16,20,24,28,32],Ti="devtools-active-text";function Dl(e,t,o=0){let n=e.left+window.scrollX+4,r=t==="top-left"?e.top+window.scrollY-Vn-o*Vn+4:e.bottom+window.scrollY+4-1+o*Vn,i=window.scrollY+4,s=window.scrollY+window.innerHeight-Vn-4;return r<i?r=e.top+window.scrollY+4:r>s&&(r=Math.max(e.top+window.scrollY+4,s)),{x:n,y:r}}function Fl({state:e,dispatch:t,onScreenshot:o,inFlightAnnotationIds:n,inFlightStyleSelectors:r,inFlightSelectorColors:i,onAttachImages:s,onReply:l,onViewThread:a,onCloseThread:c,onModelComponentsAdd:d,onModelComponentFocus:p,onModelComponentHover:u,modelComponentNames:g,modelPanelHoveredComponent:x,modelSpacingTokenHover:E,highlightedAnnotationIds:h}){var os,rs,is,ss,ls,as,cs,ds,us;let{canvasRef:w,redrawAll:D,resizeCanvas:B}=Hs(),M=kt(!1);_t(()=>{let b=w.current;if(!b)return;let S=()=>{M.current&&(M.current=!1,b.style.pointerEvents="")},X=I=>{I.button===0&&M.current&&S()};return window.addEventListener("mousedown",X),()=>window.removeEventListener("mousedown",X)},[w]);let[C,L]=st(!1),[k,W]=st(()=>{if(typeof window=="undefined")return null;try{let b=localStorage.getItem(Ti);return b?JSON.parse(b):null}catch(b){return null}}),[ee,Z]=st(null),[F,K]=st(null),[q,we]=st(null),le=kt(null),he=kt(null),Fe=kt({x:0,y:0}),Ie=kt([]),$e=kt(0),[J,V]=st(null),[te,fe]=st(new Map),Ce=kt(0),ge=kt(null),[ue,We]=st(null),[me,lt]=st(null),qe=kt({isDragging:!1,side:null,startX:0,startY:0,original:{top:0,right:0,bottom:0,left:0},element:null,elementInfo:null,selector:null,durableSelector:null}),[Ne,tt]=st(null),[A,re]=st(null),[de,Le]=st(null),[ke,Re]=st(null),ve=kt({x:0,y:0}),[at,Qe]=st({x:0,y:0}),ft=kt({isDragging:!1,hasMoved:!1,axis:null,startX:0,startY:0,originalRow:0,originalColumn:0,element:null,elementInfo:null,selector:null,durableSelector:null,isAuto:!1,originalJustifyContent:"",visualGap:0}),[rt,gt]=st(null),[ct,Ct]=st(null),[Pe,Kt]=st(null),[mt,Dt]=st(!1),[Wt,xn]=st(0),[Yt,Zt]=st(null),Gt=kt({isDragging:!1,corner:null,startY:0,original:{"top-left":0,"top-right":0,"bottom-right":0,"bottom-left":0},maxRadius:0,element:null,elementInfo:null,selector:null,durableSelector:null}),[j,Ee]=st(null),[He,qt]=st(null),[nt,vt]=st(null),ut=kt({isDragging:!1,property:null,startX:0,startY:0,originalFontSize:0,originalLineHeight:0,originalRatio:1.2,element:null,elementInfo:null,selector:null,durableSelector:null}),[ht,An]=st(null),[Vt,an]=st(null),[N,Q]=st(null),pe=zs(),Ae=kt(i);Ae.current=i;let Te=Pt(b=>{let S=Ae.current;if(!S||S.size===0)return!1;for(let X of S.keys())try{if(b.matches(X))return!0}catch(I){}return!1},[]),v=kt(e);v.current=e;let U=kt(k);U.current=k;let oe=kt([]),Be=kt(o);Be.current=o;let[ye,et]=st(null),je=e.selectedAnnotationIds;oe.current=je;let Me=Pt((b,S=!1)=>{t({type:"SELECT_ANNOTATION",payload:{id:b,addToSelection:S}})},[t]),Ye=Pt(()=>{t({type:"SELECT_ANNOTATION",payload:{id:null}})},[t]),[Ke,Lt]=st(null),[St,Er]=st({x:window.scrollX,y:window.scrollY});_t(()=>(B(),window.addEventListener("resize",B),()=>window.removeEventListener("resize",B)),[B]),_t(()=>{let b=()=>{Er({x:window.scrollX,y:window.scrollY})};return window.addEventListener("scroll",b,{passive:!0}),()=>window.removeEventListener("scroll",b)},[]),_t(()=>{k?localStorage.setItem(Ti,JSON.stringify(k)):localStorage.removeItem(Ti)},[k]),_s(k,W,ee,e.annotations,t);let Nn=kt(J);Nn.current=J,_t(()=>{if(e.activeTool!=="model"||!e.isAnnotating)return;let b=S=>{if(!S.altKey||!Nn.current)return;S.preventDefault();let X=S.deltaY>0?-1:1;Ce.current=Math.max(0,Ce.current+X);let I=ge.current;if(I){let P=nr(I,Ce.current);V(P)}};return window.addEventListener("wheel",b,{passive:!1}),()=>window.removeEventListener("wheel",b)},[e.activeTool,e.isAnnotating]),_t(()=>{e.activeTool!=="model"&&(V(null),fe(new Map),Ce.current=0,ge.current=null)},[e.activeTool]),_t(()=>{var X;let b=(X=J==null?void 0:J.name)!=null?X:null,S=b&&(g!=null&&g.has(b))?b:null;u==null||u(S)},[J,g,u]);let[Lo,jo]=st(null);_t(()=>{var X;if(!x){jo(null);return}let b=ao(x.name),S=x.instanceIndex;jo((X=b[S%b.length])!=null?X:null)},[x]);let[cn,Cr]=st([]);_t(()=>{var b,S;if(!E){Cr([]);return}(S=(b=E.token)==null?void 0:b.bindings)!=null&&S.length?Cr(Vr(E.token)):Cr(jr(E.px))},[E]);let ia=kt(null),sa=kt(null);ia.current=rt,sa.current=ct,_t(()=>{let b=["flex-start","center","flex-end"],S=["flex-start","center","flex-end"],I=null,P=!1,H=null,ie=null,z=(ae,xe)=>{let Ve=Wn(ae,xe);for(;Ve&&Ve!==document.documentElement;){let it=window.getComputedStyle(Ve).display;if(it==="flex"||it==="inline-flex")return Ve;Ve=Ve.parentElement}return null},Y=ae=>{let xe=window.getComputedStyle(ae).flexDirection;return xe==="column"||xe==="column-reverse"?"vertical":"horizontal"},y=ae=>{let xe=ae.getAttribute("data-pm");return xe||(xe=Math.random().toString(36).substring(2,8),ae.setAttribute("data-pm",xe)),{selector:`[data-pm="${xe}"]`,durableSelector:on(ae)}},T=()=>{P=!0,I&&clearTimeout(I),I=setTimeout(()=>{P=!1,I=null},300)},G=(ae,xe,Ue)=>{let Ve=Y(ae);if(xe===Ve){let Oe=window.getComputedStyle(ae).justifyContent,yt=Oe==="normal"||Oe==="flex-start"||Oe==="start"?"flex-start":Oe==="flex-end"||Oe==="end"?"flex-end":Oe==="center"?"center":null;if(!yt)return;let Rt=b.indexOf(yt)+Ue;if(Rt<0||Rt>=b.length)return;let En=b[Rt],{selector:zn,durableSelector:Tr}=y(ae);ze(ae,"justify-content",En),t({type:"MODIFY_STYLES_BATCH",payload:{selector:zn,durableSelector:Tr,element:Jt(ae),changes:[{property:"justify-content",original:Oe,modified:En}]}})}else{let Oe=window.getComputedStyle(ae).flexDirection,yt=Ve==="horizontal"?"column":"row",{selector:fn,durableSelector:Rt}=y(ae);ze(ae,"flex-direction",yt),t({type:"MODIFY_STYLES_BATCH",payload:{selector:fn,durableSelector:Rt,element:Jt(ae),changes:[{property:"flex-direction",original:Oe,modified:yt}]}})}xn(it=>it+1)},R=(ae,xe,Ue)=>{let it=Y(ae)==="horizontal"?"vertical":"horizontal";if(xe!==it)return;let yt=window.getComputedStyle(ae).alignItems,fn=yt==="normal"||yt==="stretch"||yt==="flex-start"||yt==="start"?"flex-start":yt==="flex-end"||yt==="end"?"flex-end":yt==="center"?"center":null;if(!fn)return;let En=S.indexOf(fn)+Ue;if(En<0||En>=S.length)return;let zn=S[En],{selector:Tr,durableSelector:ha}=y(ae);ze(ae,"align-items",zn),t({type:"MODIFY_STYLES_BATCH",payload:{selector:Tr,durableSelector:ha,element:Jt(ae),changes:[{property:"align-items",original:yt,modified:zn}]}}),xn(ya=>ya+1)},O=20,_=null,$=null,se=0,be=(ae,xe,Ue)=>{let Ve=z(xe,Ue);Zt(Ve?{modifier:ae,target:Ve}:null)},Ze=ae=>{if(!(e.activeTool!=="hand"||!e.isAnnotating)){if(ae.key==="Shift"&&!ae.altKey){let xe=ve.current;be("shift",xe.x,xe.y)}else if(ae.key==="Alt"&&!ae.shiftKey){let xe=ve.current;be("alt",xe.x,xe.y)}}},Ge=ae=>{if(e.activeTool!=="hand"||!e.isAnnotating)return;let xe=ae.shiftKey&&!ae.altKey,Ue=ae.altKey&&!ae.shiftKey;if(!xe&&!Ue||ae.buttons!==0){_=null,$=null,se=0,H=null,ie=null,Zt(null);return}if(H===null&&(H=ae.clientX,ie=ae.clientY,be(xe?"shift":"alt",ae.clientX,ae.clientY)),P)return;_===null&&(_=ae.clientX,$=ae.clientY,se=0);let Ve=ae.clientX-_,it=ae.clientY-$,Oe=Math.abs(Ve)>=Math.abs(it)?Ve:it;if(Math.abs(Oe)>3){let zn=Oe>0?1:-1;if(se!==0&&zn!==se){_=ae.clientX,$=ae.clientY,se=0;return}se=zn}if(Math.abs(Ve)<O&&Math.abs(it)<O)return;let yt=z(H,ie);if(!yt)return;let fn=Math.abs(Ve)>=Math.abs(it)?"horizontal":"vertical",En=(fn==="horizontal"?Ve:it)>0?1:-1;_=null,$=null,se=0,xe?G(yt,fn,En):R(yt,fn,En),T()},Mt=ae=>{(ae.key==="Shift"||ae.key==="Alt")&&(H=null,ie=null,_=null,$=null,se=0,Zt(null))},pt=()=>{Zt(null),_=null,$=null,se=0};return window.addEventListener("keydown",Ze),window.addEventListener("mousemove",Ge),window.addEventListener("mousedown",pt),window.addEventListener("keyup",Mt),()=>{window.removeEventListener("keydown",Ze),window.removeEventListener("mousemove",Ge),window.removeEventListener("mousedown",pt),window.removeEventListener("keyup",Mt),I&&clearTimeout(I)}},[e.activeTool,e.isAnnotating,t]),_t(()=>{let b=S=>{var P,H,ie,z;if(S.key==="Escape"){if(U.current)return;if(e.activeTool==="model"&&te.size>0){S.preventDefault(),fe(new Map);return}if(oe.current.length>0){S.preventDefault(),Ye();return}}if(S.key==="Enter"&&e.activeTool==="model"&&te.size>0&&d){S.preventDefault();let Y=[...te.keys()].filter(y=>!(g!=null&&g.has(y)));Y.length>0&&d(Y),fe(new Map);return}if((S.metaKey||S.ctrlKey)&&S.key==="v"&&Ie.current.length>0&&!U.current){S.preventDefault(),$e.current++;let Y=$e.current*20,T=((P=Ie.current[0])==null?void 0:P.groupId)?Math.random().toString(36).substring(2,9):void 0,G=Ie.current.map(O=>m(f({},O),{id:Math.random().toString(36).substring(2,9),groupId:O.groupId?T:void 0,timestamp:Date.now(),points:O.points.map(_=>({x:_.x+Y,y:_.y+Y}))}));t({type:"PASTE_ANNOTATIONS",payload:{annotations:G}});let R=G.find(O=>O.type!=="text")||G[0];R&&Me(R.id);return}let X=oe.current;if(X.length===0||U.current)return;let I=(H=S.target)==null?void 0:H.tagName;if(!(I==="INPUT"||I==="TEXTAREA"||(ie=S.target)!=null&&ie.isContentEditable)&&(S.key==="Delete"||S.key==="Backspace")){if(S.preventDefault(),c){let Y=v.current.annotations;for(let y of X){let T=Y.find(R=>R.id===y);if(!T)continue;let G=T.threadId||T.groupId&&((z=Y.find(R=>R.groupId===T.groupId&&R.threadId))==null?void 0:z.threadId);G&&c(G)}}for(let Y of X)t({type:"DELETE_ANNOTATION",payload:{id:Y}});Ye()}};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[t,Ye,Me,e.activeTool,te,g,d,c]);let Pn=Ci(()=>dr(e.annotations),[e.annotations]),Go=Ci(()=>{let b=new Map,S=new Set,X=1;for(let I of e.annotations)if(!Pn.has(I))if(I.groupId){if(!S.has(I.groupId)){S.add(I.groupId);let P=e.annotations.filter(H=>H.groupId===I.groupId);for(let H of P)b.set(H.id,X);X++}}else b.set(I.id,X),X++;return b},[e.annotations,Pn]),Ki=Ci(()=>{if(je.length===0)return null;let b=new Map;for(let S of je){let X=e.annotations.find(P=>P.id===S);if(!X)continue;let I=X.groupId?e.annotations.filter(P=>P.groupId===X.groupId):[X];for(let P of I)if(P.linkedSelector&&!(i!=null&&i.has(P.linkedSelector))){let H=P.color||e.activeColor;b.set(P.linkedSelector,H)}}return b.size>0?b:null},[je,e.annotations,e.activeColor,i]);_t(()=>{let b=e.annotations.filter(S=>!(Pn.has(S)||k&&!k.isNew&&S.id===k.id));D(b,e.currentPath,e.activeTool,e.activeColor,e.strokeWidth,je,Ol,St.x,St.y,Go,h)},[e.annotations,e.currentPath,e.activeTool,e.activeColor,e.strokeWidth,D,k,je,St,Go,Pn,h]),_t(()=>{if(F){let b=Math.random().toString(36).substring(2,9);W({id:b,point:F.point,text:"",fontSize:12,isNew:!0,groupId:F.groupId}),K(null)}},[F]),_t(()=>{q&&(W({id:Math.random().toString(36).substring(2,9),point:q.point,text:"",fontSize:12,isNew:!0,linkedSelector:q.linkedSelector,linkedAnchor:q.linkedAnchor,elements:q.elements}),we(null))},[q]);let Vo=kt(null),Uo=(os=k==null?void 0:k.id)!=null?os:null;_t(()=>{Uo&&le.current?requestAnimationFrame(()=>{var X;let b=le.current;if(!b||(b.focus(),he.current===Uo))return;he.current=Uo;let S=U.current;if(S){if(Vo.current!==null){let I=Math.min(Vo.current,b.value.length);b.setSelectionRange(I,I);return}if(!S.isNew&&S.clickPoint){let I=w.current;if(!I)return;let P=I.getContext("2d");if(!P)return;P.font=`${S.fontSize}px ${Ft}`;let H=S.fontSize*1.4,ie=S.text.split(`
|
|
7
|
-
`),
|
|
8
|
-
`),T=H.x-St.x,G=so(T),R=G!==void 0?Math.min(400,G):void 0,O=R?$n(Y,y,R):y,_=R?Math.min(R,Math.max(...O.map(Ze=>Y.measureText(Ze).width))):Math.max(...y.map(Ze=>Y.measureText(Ze).width)),$=O.length*(ie*1.4),se=y.length*(ie*1.4),be=$-se;if(b.x>=H.x-4-4&&b.x<=H.x+_+4+4&&b.y>=H.y-4-4-be&&b.y<=H.y+se+4+4)return I}}break}case"rectangle":{if(I.points.length<2)continue;let H=I.points[0],ie=I.points[I.points.length-1],z=Math.min(H.x,ie.x),Y=Math.max(H.x,ie.x),y=Math.min(H.y,ie.y),T=Math.max(H.y,ie.y),G=Hn(b,{x:z,y},{x:Y,y},P),R=Hn(b,{x:z,y:T},{x:Y,y:T},P),O=Hn(b,{x:z,y},{x:z,y:T},P),_=Hn(b,{x:Y,y},{x:Y,y:T},P);if(G||R||O||_)return I;break}case"circle":{if(I.points.length<2)continue;let H=I.points[0],ie=I.points[I.points.length-1],z=(H.x+ie.x)/2,Y=(H.y+ie.y)/2,y=Math.abs(ie.x-H.x)/2,T=Math.abs(ie.y-H.y)/2,G=b.x-z,R=b.y-Y,O=Math.sqrt((G/y)**2+(R/T)**2);if(Math.abs(O-1)*Math.max(y,T)<=P)return I;break}case"line":{if(I.points.length<2)continue;let H=I.points[0],ie=I.points[I.points.length-1];if(Hn(b,H,ie,P))return I;break}case"freehand":{if(I.points.length<2)continue;for(let H=0;H<I.points.length-1;H++){let ie=I.points[H],z=I.points[H+1];if(Hn(b,ie,z,P))return I}break}}}return null},[e.annotations,w,Hn,Pn,St.x]),Zi=Pt(b=>{let S=Jo(b);return(S==null?void 0:S.type)==="text"?S:null},[Jo]),qi=Pt(b=>{if(je.length===0)return null;let S=Ol/2+4;for(let X of je){let I=e.annotations.find(P=>P.id===X);if(!(!I||I.points.length<2)){if(I.type==="line"){let P=I.points[0],H=I.points[I.points.length-1];if(Math.sqrt((b.x-P.x)**2+(b.y-P.y)**2)<=S)return{handle:"start",annotationId:X};if(Math.sqrt((b.x-H.x)**2+(b.y-H.y)**2)<=S)return{handle:"end",annotationId:X};continue}if(I.type==="circle"){let P=I.points[0],H=I.points[I.points.length-1],ie=Math.min(P.x,H.x),z=Math.max(P.x,H.x),Y=Math.min(P.y,H.y),y=Math.max(P.y,H.y),T=(ie+z)/2,G=(Y+y)/2,R=[{handle:"top",x:T,y:Y},{handle:"bottom",x:T,y},{handle:"left",x:ie,y:G},{handle:"right",x:z,y:G}];for(let{handle:O,x:_,y:$}of R)if(Math.sqrt((b.x-_)**2+(b.y-$)**2)<=S)return{handle:O,annotationId:X};continue}if(I.type==="rectangle"||I.type==="freehand"){let P=I.points[0],H=I.points[I.points.length-1],ie,z,Y,y;I.type==="freehand"?(ie=Math.min(...I.points.map(G=>G.x)),z=Math.max(...I.points.map(G=>G.x)),Y=Math.min(...I.points.map(G=>G.y)),y=Math.max(...I.points.map(G=>G.y))):(ie=Math.min(P.x,H.x),z=Math.max(P.x,H.x),Y=Math.min(P.y,H.y),y=Math.max(P.y,H.y));let T=[{corner:"topLeft",x:ie,y:Y},{corner:"topRight",x:z,y:Y},{corner:"bottomLeft",x:ie,y},{corner:"bottomRight",x:z,y}];for(let{corner:G,x:R,y:O}of T)if(Math.sqrt((b.x-R)**2+(b.y-O)**2)<=S)return{handle:G,annotationId:X}}}}return null},[je,e.annotations]);_t(()=>{let b=S=>{if(Fe.current={x:S.clientX+window.scrollX,y:S.clientY+window.scrollY},!k){let X=Zi(Fe.current);Z((X==null?void 0:X.id)||null)}};return window.addEventListener("mousemove",b),()=>window.removeEventListener("mousemove",b)},[k,Zi]);let to=Pt(()=>{var S;if(!k)return;let b=((S=k.images)==null?void 0:S.length)||0;if(k.text.trim()||b>0)if(k.isNew){let X=Qo();t({type:"ADD_TEXT",payload:f({point:k.point,text:k.text||(b>0?`[${b} image${b>1?"s":""}]`:""),fontSize:k.fontSize,id:X,groupId:k.groupId,linkedSelector:k.linkedSelector,linkedAnchor:k.linkedAnchor,elements:k.elements},b>0?{imageCount:b}:{})}),b>0&&k.images&&s&&s(X,k.images)}else t({type:"UPDATE_TEXT",payload:f({id:k.id,text:k.text||(b>0?`[${b} image${b>1?"s":""}]`:"")},b>0?{imageCount:b}:{})}),b>0&&k.images&&s&&s(k.id,k.images);else k.isNew||t({type:"DELETE_ANNOTATION",payload:{id:k.id}});W(null)},[k,t,s]),kn=Pt(b=>{for(let S=0;S<Mi.length-1;S++){let X=Mi[S],I=Mi[S+1];if(b<=(X+I)/2)return X;if(b<I)return I}return Math.round(b/8)*8},[]),Qi=Pt((b,S,X,I)=>{let P=X.top+Math.max(I.top,4),H=X.bottom-Math.max(I.bottom,4),ie=X.left+Math.max(I.left,4),z=X.right-Math.max(I.right,4);if(b<X.left||b>X.right||S<X.top||S>X.bottom)return null;let Y=S<P,y=S>H,T=b<ie,G=b>z;return Y&&T?I.top>=I.left?"top":"left":Y&&G?I.top>=I.right?"top":"right":y&&T?I.bottom>=I.left?"bottom":"left":y&&G?I.bottom>=I.right?"bottom":"right":Y?"top":y?"bottom":T?"left":G?"right":null},[]),es=Pt(b=>{var H,ie;if(!e.isAnnotating)return;if(e.inspectedElement&&e.activeTool==="hand"&&!("button"in b&&b.button===2)){b.preventDefault(),b.stopPropagation(),t({type:"SELECT_ELEMENT",payload:null});return}let S=eo(b),X="shiftKey"in b&&b.shiftKey;if(e.activeTool==="inspector"){if("button"in b&&b.button===2)return;if(ue&&!Te(ue)){let z=Jt(ue),Y=on(ue),y=ue.getBoundingClientRect(),T=ue.getAttribute("data-pm");T||(T=Math.random().toString(36).substring(2,8),ue.setAttribute("data-pm",T));let G=`[data-pm="${T}"]`,R=e.styleModifications.some(be=>{try{return ue.matches(be.selector)}catch(Ze){return!1}}),O=e.annotations.filter(be=>{if(!be.linkedSelector)return!1;try{return ue.matches(be.linkedSelector)}catch(Ze){return!1}}).length,_=(R?1:0)+O,$=y.top>=Vn*(1+_)?"top-left":"bottom-left",se=Dl(y,$,_);we({point:se,linkedSelector:G,linkedAnchor:$,elements:[m(f({},z),{selector:Y})]})}return}if(e.activeTool==="model"){if("button"in b&&b.button===2)return;if(J){let z=J.name;if(g!=null&&g.has(z)){p==null||p(z);return}"shiftKey"in b&&b.shiftKey?fe(y=>{let T=new Map(y);return T.has(z)?T.delete(z):T.set(z,J),T}):te.size===1&&te.has(z)?(d&&d([z]),fe(new Map)):fe(new Map([[z,J]]))}return}if(e.activeTool==="hand"&&rt&&ct){let z=rt,Y=z.getAttribute("data-pm");Y||(Y=Math.random().toString(36).substring(2,8),z.setAttribute("data-pm",Y));let y=on(z),T=`[data-pm="${Y}"]`,G=Jt(z),R=Bo(z),O=S.x-window.scrollX,_=S.y-window.scrollY,$=mt,se=window.getComputedStyle(z).justifyContent,be=0;if($){let Ge=Yn(z).find(Mt=>Mt.axis===ct);be=Ge?ct==="column"?Ge.w:Ge.h:0}ze(z,"transition","none"),ft.current={isDragging:!0,hasMoved:!1,axis:ct,startX:O,startY:_,originalRow:$?be:R.row,originalColumn:$?be:R.column,element:z,elementInfo:m(f({},G),{selector:T}),selector:T,durableSelector:y,isAuto:$,originalJustifyContent:se,visualGap:be},Kt({axis:ct,row:$?be:R.row,column:$?be:R.column});return}if(e.activeTool==="hand"&&ht&&Vt){let z=ht,Y=z.getAttribute("data-pm");Y||(Y=Math.random().toString(36).substring(2,8),z.setAttribute("data-pm",Y));let y=`[data-pm="${Y}"]`,T=Jt(z),{fontSize:G,lineHeight:R}=Oo(z),O=G>0?R/G:1.2,_=S.x-window.scrollX,$=S.y-window.scrollY;ze(z,"transition","none");let se=on(z);ut.current={isDragging:!0,property:Vt,startX:_,startY:$,originalFontSize:G,originalLineHeight:R,originalRatio:O,element:z,elementInfo:m(f({},T),{selector:y}),selector:y,durableSelector:se},Q({property:Vt,fontSize:G,lineHeight:R});return}if(e.activeTool==="hand"&&j&&He){let z=j,Y=z.getAttribute("data-pm");Y||(Y=Math.random().toString(36).substring(2,8),z.setAttribute("data-pm",Y));let y=`[data-pm="${Y}"]`,T=on(z),G=Jt(z),R=jn(z),O=z.getBoundingClientRect(),_=Math.floor(O.height/2),$=S.y-window.scrollY;ze(z,"transition","none"),Gt.current={isDragging:!0,corner:He,startY:$,original:R,maxRadius:_,element:z,elementInfo:m(f({},G),{selector:y}),selector:y,durableSelector:T},vt({corner:He,radius:f({},R)});return}if(e.activeTool==="hand"&&Ne&&A){let z=Ne,Y=z.getAttribute("data-pm");Y||(Y=Math.random().toString(36).substring(2,8),z.setAttribute("data-pm",Y));let y=`[data-pm="${Y}"]`,T=on(z),G=Jt(z),R=uo(z),O=S.x-window.scrollX,_=S.y-window.scrollY;ze(z,"transition","none"),qe.current={isDragging:!0,side:A,startX:O,startY:_,original:R,element:z,elementInfo:m(f({},G),{selector:y}),selector:y,durableSelector:T},Re({side:A,padding:f({},R)});return}let I=qi(S);if(I){let z=e.annotations.find(Y=>Y.id===I.annotationId);if(z&&z.type!=="text"&&((H=z.status)!=null?H:"pending")==="pending"){Lt({annotationId:I.annotationId,handle:I.handle,startPoint:S,originalPoints:[...z.points],hasMoved:!1});return}}let P=Jo(S);if(P&&P.points[0]){if(k&&to(),P.type!=="text"?(Me(P.id,X),P.color&&t({type:"SET_COLOR",payload:P.color})):X||Ye(),a){let z=P.threadId||(P.groupId?(ie=e.annotations.find(Y=>Y.groupId===P.groupId&&Y.threadId))==null?void 0:ie.threadId:void 0);z&&a(z)}et({annotation:P,startPoint:S,hasMoved:!1});return}if(X||Ye(),e.activeTool==="text"){k&&to();let z=Math.random().toString(36).substring(2,9);W({id:z,point:S,text:"",fontSize:12,isNew:!0});return}L(!0),t({type:"START_PATH",payload:S})},[e.isAnnotating,e.activeTool,e.inspectedElement,e.annotations,k,je,ue,Ne,A,j,He,rt,ct,mt,ht,Vt,J,te,g,d,p,a,eo,Jo,qi,t,Me,Ye,to]),ts=Pt(b=>{var X,I;let S=eo(b);if(e.activeTool==="inspector"&&e.isAnnotating){let P=S.x-window.scrollX,H=S.y-window.scrollY,ie=Wn(P,H),z=ie&&Te(ie)?null:ie;z!==ue&&(We(z),lt(z?Jt(z):null));return}if(e.activeTool==="model"&&e.isAnnotating){let P=S.x-window.scrollX,H=S.y-window.scrollY,ie=Wn(P,H);if(ie!==ge.current&&(ge.current=ie,Ce.current=0),ie){let z=nr(ie,Ce.current);V(z)}else V(null);return}if(e.activeTool==="hand"&&e.isAnnotating){let P=S.x-window.scrollX,H=S.y-window.scrollY;ve.current={x:P,y:H},Qe({x:P,y:H});let ie=pe.current.cmd,z=pe.current.shift;if(ft.current.isDragging){let y=ft.current,T=y.element;if(!T)return;if(!y.hasMoved){let _=Math.abs(P-y.startX),$=Math.abs(H-y.startY);if(_<=2&&$<=2)return;y.hasMoved=!0,y.isAuto&&(ze(T,"justify-content","normal"),ze(T,"row-gap",`${y.visualGap}px`),ze(T,"column-gap",`${y.visualGap}px`),Dt(!1))}let G=y.axis,R=y.originalRow,O=y.originalColumn;if(G==="column"){let _=P-y.startX;O=y.originalColumn+_,ie||(R=y.originalRow+_)}else{let _=H-y.startY;R=y.originalRow+_,ie||(O=y.originalColumn+_)}R=Math.max(0,R),O=Math.max(0,O),z&&(R=kn(R),O=kn(O)),R=Math.round(R),O=Math.round(O),ze(T,"row-gap",`${R}px`),ze(T,"column-gap",`${O}px`),Kt({axis:G,row:R,column:O});return}if(Gt.current.isDragging){let y=Gt.current,T=y.element;if(!T)return;let G=H-y.startY,R=y.corner,O=y.original,_=f({},O);if(ie){let $=O[R]+G;$=Math.max(0,Math.min(y.maxRadius,$)),z&&($=kn($)),$=Math.round($),_[R]=$}else{let $=O[R]+G;$=Math.max(0,Math.min(y.maxRadius,$)),z&&($=kn($)),$=Math.round($),_={"top-left":$,"top-right":$,"bottom-right":$,"bottom-left":$}}ze(T,"border-top-left-radius",`${_["top-left"]}px`),ze(T,"border-top-right-radius",`${_["top-right"]}px`),ze(T,"border-bottom-right-radius",`${_["bottom-right"]}px`),ze(T,"border-bottom-left-radius",`${_["bottom-left"]}px`),vt({corner:R,radius:_});return}if(ut.current.isDragging){let y=ut.current,T=y.element;if(!T)return;let G=y.property,R=y.originalFontSize,O=y.originalLineHeight,_=[8,10,11,12,13,14,16,18,20,22,24,28,32,36,40,48,56,64,72,80,96];if(G==="font-size"){let se=P-y.startX;R=y.originalFontSize+se,R=Math.max(1,R)}else{let se=H-y.startY;O=y.originalLineHeight+se,O=Math.max(R,O)}if(z)if(G==="font-size"){let se=_[0],be=Math.abs(R-se);for(let Ze of _){let Ge=Math.abs(R-Ze);Ge<be&&(se=Ze,be=Ge)}R=se}else{let se=R>0?O/R:1.2,be=Math.round(se*2)/2;O=R*Math.max(1,be)}R=Math.round(R),O=Math.round(O*10)/10,ze(T,"font-size",`${R}px`);let $=R>0?Math.round(O/R*1e3)/1e3:1.2;ze(T,"line-height",`${$}`),Q({property:G,fontSize:R,lineHeight:O});return}if(qe.current.isDragging){let y=qe.current,T=y.element;if(!T)return;let G=y.side,R=y.original,O=R.top,_=R.right,$=R.bottom,se=R.left;if(G==="top"){let be=y.startY-H;O=R.top+be,ie||($=R.bottom+be)}else if(G==="bottom"){let be=H-y.startY;$=R.bottom+be,ie||(O=R.top+be)}else if(G==="left"){let be=y.startX-P;se=R.left+be,ie||(_=R.right+be)}else if(G==="right"){let be=P-y.startX;_=R.right+be,ie||(se=R.left+be)}O=Math.max(0,O),_=Math.max(0,_),$=Math.max(0,$),se=Math.max(0,se),z&&(O=kn(O),_=kn(_),$=kn($),se=kn(se)),O=Math.round(O),_=Math.round(_),$=Math.round($),se=Math.round(se),ze(T,"padding",`${O}px ${_}px ${$}px ${se}px`),Re({side:G,padding:{top:O,right:_,bottom:$,left:se}});return}let Y=Wn(P,H);for(;Y&&Y.tagName==="A";)Y=Y.parentElement;{let T=[];Y&&T.push(Y),j&&j!==Y&&T.push(j);let G=null,R=16,O=null;for(let _ of T){let $=_.getBoundingClientRect(),se=jn(_),be=[["top-left",$.left,$.top+se["top-left"]],["top-right",$.right,$.top+se["top-right"]],["bottom-right",$.right,$.bottom-se["bottom-right"]],["bottom-left",$.left,$.bottom-se["bottom-left"]]];for(let[Ze,Ge,Mt]of be){let pt=Math.hypot(P-Ge,H-Mt);pt<R&&(R=pt,G=Ze,O=_)}}if(G&&O){Ee(O),qt(G),Ne&&tt(null),A&&re(null),rt&>(null),ct&&Ct(null),Dt(!1),ht&&An(null),Vt&&an(null);return}}j&&Ee(null),He&&qt(null);{let y=[];Y&&ir(Y)&&y.push(Y);let T=(X=Y==null?void 0:Y.parentElement)!=null?X:null;for(;T&&T!==document.body&&y.length<3;)ir(T)&&y.push(T),T=T.parentElement;for(let G of y){let O=Yn(G).find(_=>P>=_.x&&P<=_.x+_.w&&H>=_.y&&H<=_.y+_.h);if(O){gt(G),Ct(O.axis),Dt(Xr(G,O.axis)),Ne&&tt(null),A&&re(null),ht&&An(null),Vt&&an(null);return}}}rt&>(null),ct&&Ct(null),Dt(!1);{let T=[];Y&&T.push(Y),ht&&ht!==Y&&T.push(ht);let G=null,R=1/0,O=null;for(let _ of T){if(!Kr(_))continue;let $=po(_);if(!$)continue;let se=P>=$.left&&P<=$.right&&H>=$.top&&H<=$.bottom,be=[["font-size",$.right,$.top+$.height/2],["line-height",$.left+$.width/2,$.bottom]];for(let[Ze,Ge,Mt]of be){let pt=Math.hypot(P-Ge,H-Mt);(se||pt<12)&&pt<R&&(R=pt,G=Ze,O=_)}}G&&O?(An(O),an(G)):(ht&&An(null),Vt&&an(null))}if(Y!==Ne&&tt(Y),Y){let y=uo(Y),T=Y.getBoundingClientRect(),G=Qi(P,H,T,y);re(G)}else re(null);return}if(Ke){let{handle:P,originalPoints:H,hasMoved:ie}=Ke,z=e.annotations.find(R=>R.id===Ke.annotationId);if(!z)return;let Y="metaKey"in b,y=Y&&(b.metaKey||b.ctrlKey),T=Y&&b.shiftKey,G;if(z.type==="line"){let R=H[0],O=H[H.length-1];P==="start"?G=[S,O]:G=[R,S]}else if(z.type==="freehand"){let R=Math.min(...H.map(Oe=>Oe.x)),O=Math.max(...H.map(Oe=>Oe.x)),_=Math.min(...H.map(Oe=>Oe.y)),$=Math.max(...H.map(Oe=>Oe.y)),se=(R+O)/2,be=(_+$)/2,Ze=O-R||1,Ge=$-_||1,Mt=Ze/Ge,pt=R,ae=O,xe=_,Ue=$;switch(P){case"topLeft":pt=S.x,xe=S.y;break;case"topRight":ae=S.x,xe=S.y;break;case"bottomLeft":pt=S.x,Ue=S.y;break;case"bottomRight":ae=S.x,Ue=S.y;break}if(y)switch(P){case"topLeft":ae=O+(R-pt),Ue=$+(_-xe);break;case"topRight":pt=R-(ae-O),Ue=$+(_-xe);break;case"bottomLeft":ae=O+(R-pt),xe=_-(Ue-$);break;case"bottomRight":pt=R-(ae-O),xe=_-(Ue-$);break}if(T){let Oe=ae-pt,yt=Ue-xe;if(Math.abs(Oe/yt)>Mt){let Rt=Math.abs(yt)*Mt*Math.sign(Oe);P==="topLeft"||P==="bottomLeft"?pt=ae-Rt:ae=pt+Rt}else{let Rt=Math.abs(Oe)/Mt*Math.sign(yt);P==="topLeft"||P==="topRight"?xe=Ue-Rt:Ue=xe+Rt}}let Ve=ae-pt||1,it=Ue-xe||1;G=H.map(Oe=>({x:pt+(Oe.x-R)/Ze*Ve,y:xe+(Oe.y-_)/Ge*it}))}else if(z.type==="circle"){let R=H[0],O=H[H.length-1],_=Math.min(R.x,O.x),$=Math.max(R.x,O.x),se=Math.min(R.y,O.y),be=Math.max(R.y,O.y),Ze=(_+$)/2,Ge=(se+be)/2,Mt=$-_,pt=be-se,ae=_,xe=$,Ue=se,Ve=be;switch(P){case"top":if(Ue=S.y,y&&(Ve=Ge+(Ge-S.y)),T){let Oe=(Ve-Ue)*(Mt/pt)/2;ae=Ze-Oe,xe=Ze+Oe}break;case"bottom":if(Ve=S.y,y&&(Ue=Ge-(S.y-Ge)),T){let Oe=(Ve-Ue)*(Mt/pt)/2;ae=Ze-Oe,xe=Ze+Oe}break;case"left":if(ae=S.x,y&&(xe=Ze+(Ze-S.x)),T){let Oe=(xe-ae)*(pt/Mt)/2;Ue=Ge-Oe,Ve=Ge+Oe}break;case"right":if(xe=S.x,y&&(ae=Ze-(S.x-Ze)),T){let Oe=(xe-ae)*(pt/Mt)/2;Ue=Ge-Oe,Ve=Ge+Oe}break}G=[{x:ae,y:Ue},{x:xe,y:Ve}]}else{let R=H[0],O=H[H.length-1],_=Math.min(R.x,O.x),$=Math.max(R.x,O.x),se=Math.min(R.y,O.y),be=Math.max(R.y,O.y),Ze=(_+$)/2,Ge=(se+be)/2,Mt=$-_||1,pt=be-se||1,ae=Mt/pt,xe=_,Ue=$,Ve=se,it=be;switch(P){case"topLeft":xe=S.x,Ve=S.y;break;case"topRight":Ue=S.x,Ve=S.y;break;case"bottomLeft":xe=S.x,it=S.y;break;case"bottomRight":Ue=S.x,it=S.y;break}if(y)switch(P){case"topLeft":Ue=$+(_-xe),it=be+(se-Ve);break;case"topRight":xe=_-(Ue-$),it=be+(se-Ve);break;case"bottomLeft":Ue=$+(_-xe),Ve=se-(it-be);break;case"bottomRight":xe=_-(Ue-$),Ve=se-(it-be);break}if(T){let Oe=Ue-xe,yt=it-Ve;if(Math.abs(Oe/yt)>ae){let Rt=Math.abs(yt)*ae*Math.sign(Oe);P==="topLeft"||P==="bottomLeft"?xe=Ue-Rt:Ue=xe+Rt}else{let Rt=Math.abs(Oe)/ae*Math.sign(yt);P==="topLeft"||P==="topRight"?Ve=it-Rt:it=Ve+Rt}}G=[{x:xe,y:Ve},{x:Ue,y:it}]}t({type:"RESIZE_ANNOTATION",payload:{id:Ke.annotationId,points:G,saveUndo:!ie}}),ie||Lt(m(f({},Ke),{hasMoved:!0}));return}if(ye&&((I=ye.annotation.status)!=null?I:"pending")==="pending"){let P=S.x-ye.startPoint.x,H=S.y-ye.startPoint.y;if((Math.abs(P)>2||Math.abs(H)>2)&&!ye.hasMoved)et(m(f({},ye),{hasMoved:!0,startPoint:S})),t({type:"MOVE_ANNOTATION",payload:{id:ye.annotation.id,delta:{x:P,y:H},saveUndo:!0}});else if(ye.hasMoved){let z=S.x-ye.startPoint.x,Y=S.y-ye.startPoint.y;et(m(f({},ye),{startPoint:S})),t({type:"MOVE_ANNOTATION",payload:{id:ye.annotation.id,delta:{x:z,y:Y}}})}return}!C||!e.isAnnotating||t({type:"CONTINUE_PATH",payload:S})},[C,e.isAnnotating,e.activeTool,ye,Ke,ue,Ne,A,j,He,rt,ct,ht,Vt,eo,t,kn,Qi]),Mr=Pt(b=>{var I,P,H,ie,z,Y;if(ut.current.isDragging){let y=ut.current,T=y.element;if(T&&y.selector&&y.elementInfo&&N){T instanceof HTMLElement&&(T.style.removeProperty("font-size"),T.style.removeProperty("line-height"),T.style.removeProperty("transition"));let G=[];if(y.originalFontSize!==N.fontSize&&(ze(T,"font-size",`${N.fontSize}px`),G.push({property:"font-size",original:`${y.originalFontSize}px`,modified:`${N.fontSize}px`})),y.originalLineHeight!==N.lineHeight){let R=y.originalFontSize>0?Math.round(y.originalLineHeight/y.originalFontSize*1e3)/1e3:1.2,O=N.fontSize>0?Math.round(N.lineHeight/N.fontSize*1e3)/1e3:1.2;ze(T,"line-height",`${O}`),G.push({property:"line-height",original:`${R}`,modified:`${O}`})}G.length>0&&t({type:"MODIFY_STYLES_BATCH",payload:{selector:y.selector,durableSelector:(I=y.durableSelector)!=null?I:void 0,element:y.elementInfo,changes:G}})}ut.current={isDragging:!1,property:null,startX:0,startY:0,originalFontSize:0,originalLineHeight:0,originalRatio:1.2,element:null,elementInfo:null,selector:null,durableSelector:null},Q(null);return}if(ft.current.isDragging){let y=ft.current,T=y.element,G="button"in b&&b.button===2;if(!y.hasMoved&&!G&&T&&y.selector&&y.elementInfo){T instanceof HTMLElement&&T.style.removeProperty("transition");let R=["space-between","space-around","stretch","normal"],O=y.originalJustifyContent||"normal",_=R.indexOf(O),$=R[(_+1)%R.length],se=[];$==="normal"?(ze(T,"justify-content","normal"),se.push({property:"justify-content",original:y.originalJustifyContent,modified:"normal"})):$==="stretch"?(ze(T,"justify-content",$),ze(T,"row-gap","8px"),ze(T,"column-gap","8px"),se.push({property:"justify-content",original:y.originalJustifyContent||"normal",modified:$}),y.originalRow!==8&&se.push({property:"row-gap",original:`${y.originalRow}px`,modified:"8px"}),y.originalColumn!==8&&se.push({property:"column-gap",original:`${y.originalColumn}px`,modified:"8px"})):(T instanceof HTMLElement&&(T.style.removeProperty("row-gap"),T.style.removeProperty("column-gap")),ze(T,"justify-content",$),se.push({property:"justify-content",original:y.originalJustifyContent||"normal",modified:$}),y.originalRow>0&&se.push({property:"row-gap",original:`${y.originalRow}px`,modified:"0px"}),y.originalColumn>0&&se.push({property:"column-gap",original:`${y.originalColumn}px`,modified:"0px"})),se.length>0&&t({type:"MODIFY_STYLES_BATCH",payload:{selector:y.selector,durableSelector:(P=y.durableSelector)!=null?P:void 0,element:y.elementInfo,changes:se}})}else if(y.hasMoved&&T&&y.selector&&y.elementInfo&&Pe){T instanceof HTMLElement&&(T.style.removeProperty("row-gap"),T.style.removeProperty("column-gap"),T.style.removeProperty("transition"));let R=[];y.isAuto?(T instanceof HTMLElement&&T.style.removeProperty("justify-content"),ze(T,"justify-content","normal"),ze(T,"row-gap",`${Pe.row}px`),ze(T,"column-gap",`${Pe.column}px`),R.push({property:"justify-content",original:y.originalJustifyContent,modified:"normal"}),R.push({property:"row-gap",original:"0px",modified:`${Pe.row}px`}),R.push({property:"column-gap",original:"0px",modified:`${Pe.column}px`})):(y.originalRow!==Pe.row&&(ze(T,"row-gap",`${Pe.row}px`),R.push({property:"row-gap",original:`${y.originalRow}px`,modified:`${Pe.row}px`})),y.originalColumn!==Pe.column&&(ze(T,"column-gap",`${Pe.column}px`),R.push({property:"column-gap",original:`${y.originalColumn}px`,modified:`${Pe.column}px`}))),R.length>0&&t({type:"MODIFY_STYLES_BATCH",payload:{selector:y.selector,durableSelector:(H=y.durableSelector)!=null?H:void 0,element:y.elementInfo,changes:R}})}ft.current={isDragging:!1,hasMoved:!1,axis:null,startX:0,startY:0,originalRow:0,originalColumn:0,element:null,elementInfo:null,selector:null,durableSelector:null,isAuto:!1,originalJustifyContent:"",visualGap:0},Kt(null);return}if(Gt.current.isDragging){let y=Gt.current,T=y.element;if(T&&y.selector&&y.elementInfo&&nt){T instanceof HTMLElement&&(T.style.removeProperty("border-top-left-radius"),T.style.removeProperty("border-top-right-radius"),T.style.removeProperty("border-bottom-right-radius"),T.style.removeProperty("border-bottom-left-radius"),T.style.removeProperty("transition"));let G=["top-left","top-right","bottom-right","bottom-left"],R={"top-left":"border-top-left-radius","top-right":"border-top-right-radius","bottom-right":"border-bottom-right-radius","bottom-left":"border-bottom-left-radius"},O=[];for(let _ of G)y.original[_]!==nt.radius[_]&&(ze(T,R[_],`${nt.radius[_]}px`),O.push({property:R[_],original:`${y.original[_]}px`,modified:`${nt.radius[_]}px`}));O.length>0&&t({type:"MODIFY_STYLES_BATCH",payload:{selector:y.selector,durableSelector:(ie=y.durableSelector)!=null?ie:void 0,element:y.elementInfo,changes:O}})}Gt.current={isDragging:!1,corner:null,startY:0,original:{"top-left":0,"top-right":0,"bottom-right":0,"bottom-left":0},maxRadius:0,element:null,elementInfo:null,selector:null,durableSelector:null},vt(null);return}if(qe.current.isDragging){let y=qe.current,T=y.element,G=y.selector,R=y.elementInfo;if(T&&G&&R&&ke){let O=y.original,_=ke.padding;T instanceof HTMLElement&&(T.style.removeProperty("padding"),T.style.removeProperty("transition"));let $=[],se=[{prop:"padding-top",origVal:O.top,newVal:_.top},{prop:"padding-right",origVal:O.right,newVal:_.right},{prop:"padding-bottom",origVal:O.bottom,newVal:_.bottom},{prop:"padding-left",origVal:O.left,newVal:_.left}];for(let{prop:be,origVal:Ze,newVal:Ge}of se)Ze!==Ge&&(ze(T,be,`${Ge}px`),$.push({property:be,original:`${Ze}px`,modified:`${Ge}px`}));$.length>0&&t({type:"MODIFY_STYLES_BATCH",payload:{selector:G,durableSelector:(z=y.durableSelector)!=null?z:void 0,element:R,changes:$}})}qe.current={isDragging:!1,side:null,startX:0,startY:0,original:{top:0,right:0,bottom:0,left:0},element:null,elementInfo:null,selector:null,durableSelector:null},Re(null);return}if(Ke){Lt(null);return}if(ye){if(!ye.hasMoved&&ye.annotation.type==="text"&&((Y=ye.annotation.status)!=null?Y:"pending")==="pending"){let y=eo(b);W({id:ye.annotation.id,point:ye.annotation.points[0],text:ye.annotation.text||"",fontSize:ye.annotation.fontSize||12,isNew:!1,clickPoint:y,groupId:ye.annotation.groupId})}et(null);return}if(!C)return;let S=5;if(e.currentPath.length>=2){let y=e.currentPath[0],T=e.currentPath[e.currentPath.length-1],G=Math.abs(T.x-y.x),R=Math.abs(T.y-y.y);if((e.activeTool==="line"?Math.sqrt(G*G+R*R)<S:G<S&&R<S)&&["rectangle","circle","line"].includes(e.activeTool)){L(!1),t({type:"CANCEL_PATH"});return}}let X=Yr(e.currentPath);if(e.activeTool==="rectangle"&&e.currentPath.length>=2){let y=e.currentPath[0],T=e.currentPath[e.currentPath.length-1],G=Math.min(y.x,T.x),R=Math.max(y.y,T.y),O=e.strokeWidth/2,_=Math.random().toString(36).substring(2,9);K({point:{x:G-O+4,y:R+O+4},groupId:_}),L(!1),t({type:"FINISH_PATH",payload:{groupId:_,elements:X}});return}L(!1),t({type:"FINISH_PATH",payload:{elements:X}})},[C,ye,Ke,ke,nt,Pe,N,eo,t,e.activeTool,e.currentPath,e.strokeWidth]),la=Pt(b=>{let S=b.target.value;Vo.current=b.target.selectionStart,W(X=>X&&m(f({},X),{text:S}))},[]),aa=Pt(b=>{b.key==="Escape"?W(null):b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),to())},[to]),ca=Pt(b=>{if(!k)return;let S=b.clipboardData.items,X=[];for(let I=0;I<S.length;I++){let P=S[I];if(P.type.startsWith("image/")){let H=P.getAsFile();H&&X.push(H)}}X.length>0&&(b.preventDefault(),W(I=>I?m(f({},I),{images:[...I.images||[],...X]}):null))},[k]),da=Pt(b=>{if(!e.isAnnotating)return;if(e.activeTool==="hand"){b.preventDefault();let X=Ne||rt||j||ht;if(X&&!Te(X)){let I=Jt(X),P=on(X);t({type:"SELECT_ELEMENT",payload:{el:X,info:m(f({},I),{selector:P})}})}return}b.preventDefault();let S=w.current;S&&(M.current=!0,S.style.pointerEvents="none",setTimeout(()=>{M.current&&(M.current=!1,S.style.pointerEvents="")},4e3))},[e.activeTool,e.isAnnotating,Ne,rt,j,ht,t,Te,w]);_t(()=>{let b=e.annotations.filter(H=>H.linkedSelector);if(b.length===0)return;let S=null,X=()=>{var ie,z,Y;let H=[];for(let y of b){let T=document.querySelector(y.linkedSelector);if(!T&&((z=(ie=y.elements)==null?void 0:ie[0])!=null&&z.selector)&&y.linkedSelector.startsWith("[data-pm=")){try{T=document.querySelector(y.elements[0].selector)}catch(Ge){}if(T){let Ge=(Y=y.linkedSelector.match(/data-pm="([^"]+)"/))==null?void 0:Y[1];Ge&&T.setAttribute("data-pm",Ge)}}if(!T)continue;let G=T.getBoundingClientRect(),R=e.styleModifications.some(Ge=>{try{return T.matches(Ge.selector)}catch(Mt){return!1}}),O=b.filter(Ge=>Ge.id!==y.id&&Ge.timestamp<y.timestamp&&Ge.linkedSelector===y.linkedSelector).length,_=(R?1:0)+O,$=G.top>=Vn*(1+_)?"top-left":"bottom-left",se=Dl(G,$,_),be=y.points[0],Ze=$!==y.linkedAnchor;be&&(Ze||Math.abs(se.x-be.x)>1||Math.abs(se.y-be.y)>1)&&H.push({id:y.id,point:se,linkedAnchor:Ze?$:void 0})}H.length>0&&t({type:"UPDATE_LINKED_POSITIONS",payload:{updates:H}})},I=()=>{S&&cancelAnimationFrame(S),S=requestAnimationFrame(X)};X(),window.addEventListener("scroll",I,!0),window.addEventListener("resize",I,!0),window.addEventListener("load",I),document.fonts.ready.then(I);let P=new MutationObserver(I);return P.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]}),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I,!0),window.removeEventListener("load",I),P.disconnect(),S&&cancelAnimationFrame(S)}},[e.annotations,t]);let ua=()=>{var b,S,X;if(!e.isAnnotating)return"default";if(Ke){let{handle:I}=Ke;return I==="start"||I==="end"?"move":I==="top"||I==="bottom"?"ns-resize":I==="left"||I==="right"?"ew-resize":I==="topLeft"||I==="bottomRight"?"nwse-resize":"nesw-resize"}if(e.activeTool==="text")return"text";if(e.activeTool==="hand"){let I=(b=Pe==null?void 0:Pe.axis)!=null?b:ct;if(I==="row")return"ns-resize";if(I==="column")return"ew-resize";if(nt||He)return"ns-resize";let P=(S=N==null?void 0:N.property)!=null?S:Vt;if(P==="font-size")return"ew-resize";if(P==="line-height")return"ns-resize";let H=(X=ke==null?void 0:ke.side)!=null?X:A;return H==="top"||H==="bottom"?"ns-resize":H==="left"||H==="right"?"ew-resize":"default"}return"crosshair"},pa={position:"fixed",top:0,left:0,width:"100vw",height:"100vh",zIndex:9998,pointerEvents:e.isAnnotating?"auto":"none",visibility:e.isAnnotating?"visible":"hidden",cursor:ua()},Ro=Pt(()=>{let b=w.current;if(!b||!k)return{width:100,height:12*1.4,isWrapped:!1};let S=b.getContext("2d");if(!S)return{width:100,height:k.fontSize*1.4,isWrapped:!1};S.font=`${k.fontSize}px ${Ft}`;let I=S.measureText("Type here...").width,P=k.text.split(`
|
|
9
|
-
`),H=P.length>0?Math.max(
|
|
10
|
-
`).length)*k.fontSize*1.4+8:0,ns=Ro.height+8,ga=Ro.isWrapped?ns-fa:0,ma=k?{position:"fixed",left:k.point.x-4-St.x,top:k.point.y-4-St.y-ga,zIndex:9999,width:Ro.width+8,height:ns,padding:4,fontSize:k.fontSize,fontFamily:Ft,color:"#ffffff",backgroundColor:e.activeColor,border:"none",borderRadius:0,outline:"none",boxShadow:"none",lineHeight:1.4,resize:"none",overflow:"hidden",whiteSpace:Ro.isWrapped?"pre-wrap":"pre",wordBreak:Ro.isWrapped?"break-word":void 0}:{};return So(wo,{children:[ot("canvas",{ref:w,id:"devtools-canvas",style:pa,onMouseDown:es,onMouseMove:ts,onMouseUp:b=>Mr(b),onMouseLeave:b=>{Mr(b),We(null),lt(null)},onTouchStart:es,onTouchMove:ts,onTouchEnd:b=>Mr(b),onContextMenu:da}),k&&So(wo,{children:[ot("style",{children:"#devtools-text-input::placeholder { color: rgba(255, 255, 255, 0.5); }"}),ot("textarea",{id:"devtools-text-input",ref:le,value:k.text,onChange:la,onKeyDown:aa,onPaste:ca,onBlur:to,placeholder:"Type here...",style:ma}),k.images&&k.images.length>0&&So("div",{"data-devtools":!0,style:{position:"fixed",left:k.point.x-4-St.x,top:k.point.y-4-St.y-20,zIndex:1e4,fontSize:11,fontFamily:"system-ui, sans-serif",color:"#fff",backgroundColor:"rgba(0,0,0,0.7)",padding:"2px 6px",borderRadius:3,whiteSpace:"nowrap"},children:[k.images.length," image",k.images.length>1?"s":""," attached"]})]}),e.isAnnotating&&e.activeTool!=="hand"&&e.styleModifications.length>0&&ot(pl,{styleModifications:e.styleModifications,isInspecting:!!e.inspectedElement,accentColor:e.activeColor,annotationGroupCount:new Set(e.annotations.map(b=>b.groupId||b.id)).size,dispatch:t,inFlightSelectors:r}),e.activeTool==="hand"&&e.isAnnotating&&e.styleModifications.length>0&&ot(gl,{styleModifications:e.styleModifications,accentColor:e.activeColor}),e.isAnnotating&&ot(nl,{annotations:e.annotations,supersededAnnotations:Pn,inFlightIds:n,scrollX:St.x,scrollY:St.y,annotationGroupMap:Go,onViewThread:a,onSelectAnnotation:Me,canvasRef:w}),e.isAnnotating&&l&&ot(ol,{annotations:e.annotations,supersededAnnotations:Pn,scrollX:St.x,scrollY:St.y,onReply:l,annotationGroupMap:Go,canvasRef:w}),e.isAnnotating&&i&&i.size>0&&ot(ti,{inFlightSelectorColors:i}),e.isAnnotating&&Ki&&ot(ti,{inFlightSelectorColors:Ki,animated:!1}),e.activeTool==="hand"&&e.isAnnotating&&(Pe?ft.current.element:rt)&&ot(si,{element:Pe?ft.current.element:rt,gap:Pe?{row:Pe.row,column:Pe.column}:Bo(rt),accentColor:e.activeColor,hoveredAxis:ct,draggingAxis:(rs=Pe==null?void 0:Pe.axis)!=null?rs:null,cursorViewport:at,isAutoGap:mt,refreshKey:Wt}),e.activeTool==="hand"&&e.isAnnotating&&Yt&&ot(Pl,{element:Yt.target,modifier:Yt.modifier,accentColor:e.activeColor,refreshKey:Wt}),e.activeTool==="hand"&&e.isAnnotating&&!Yt&&(nt?Gt.current.element:j)&&ot(al,{element:nt?Gt.current.element:j,radius:(is=nt==null?void 0:nt.radius)!=null?is:jn(j),accentColor:e.activeColor,hoveredCorner:He,draggingCorner:(ss=nt==null?void 0:nt.corner)!=null?ss:null,cursorViewport:at}),e.activeTool==="hand"&&e.isAnnotating&&!Yt&&(N?ut.current.element:ht)&&ot(Bl,{element:N?ut.current.element:ht,fontSize:(ls=N==null?void 0:N.fontSize)!=null?ls:Oo(ht).fontSize,lineHeight:(as=N==null?void 0:N.lineHeight)!=null?as:Oo(ht).lineHeight,accentColor:e.activeColor,hoveredProperty:Vt,draggingProperty:(cs=N==null?void 0:N.property)!=null?cs:null,cursorViewport:at}),e.activeTool==="hand"&&e.isAnnotating&&!Yt&&(ke?qe.current.element:Ne)&&ot(pi,{element:ke?qe.current.element:Ne,padding:(ds=ke==null?void 0:ke.padding)!=null?ds:uo(Ne),accentColor:e.activeColor,hoveredSide:A,draggingSide:(us=ke==null?void 0:ke.side)!=null?us:null,cursorViewport:at,refreshKey:N?N.fontSize+N.lineHeight*1e3:0}),e.activeTool==="inspector"&&e.isAnnotating&&ot(wo,{children:ue&&!e.inspectedElement&&(()=>{let b=!!q||!!(k!=null&&k.linkedSelector)||e.annotations.some(S=>{if(!S.linkedSelector)return!1;try{return ue.matches(S.linkedSelector)}catch(X){return!1}});return ot(mo,{element:ue,isSelected:!1,elementInfo:me,color:e.activeColor,hideTooltip:b})})()}),e.activeTool==="model"&&e.isAnnotating&&te.size>0&&[...te.entries()].map(([b,S])=>ot(mo,{element:S.rootElement,isSelected:!0,elementInfo:{selector:"",tagName:S.rootElement.tagName.toLowerCase(),reactComponent:b},color:"#8b5cf6"},b)),e.activeTool==="model"&&e.isAnnotating&&Lo&&ot(mo,{element:Lo.rootElement,isSelected:!0,elementInfo:{selector:"",tagName:Lo.rootElement.tagName.toLowerCase(),reactComponent:Lo.name},color:"#22c55e"}),e.activeTool==="model"&&e.isAnnotating&&cn.length>0&&cn.map((b,S)=>ot("div",{style:{position:"absolute",left:b.x,top:b.y,width:b.width,height:b.height,backgroundColor:"rgba(255, 0, 0, 0.08)",pointerEvents:"none",zIndex:9998},children:b.direction==="vertical"?So(wo,{children:[ot("div",{style:{position:"absolute",left:"50%",top:0,width:6,height:1,backgroundColor:"#FF0000",transform:"translateX(-50%)"}}),ot("div",{style:{position:"absolute",left:"50%",top:0,bottom:0,width:1,backgroundColor:"#FF0000",transform:"translateX(-50%)"}}),ot("div",{style:{position:"absolute",left:"50%",bottom:0,width:6,height:1,backgroundColor:"#FF0000",transform:"translateX(-50%)"}}),ot("div",{style:{position:"absolute",left:"calc(50% + 6px)",top:b.height<16?-6:"50%",transform:b.height<16?"none":"translateY(-50%)",fontSize:11,fontWeight:600,color:"#fff",backgroundColor:"#FF0000",padding:"2px 4px",whiteSpace:"nowrap",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1},children:Math.round(b.height)})]}):So(wo,{children:[ot("div",{style:{position:"absolute",left:0,top:"50%",width:1,height:6,backgroundColor:"#FF0000",transform:"translateY(-50%)"}}),ot("div",{style:{position:"absolute",left:0,right:0,top:"50%",height:1,backgroundColor:"#FF0000",transform:"translateY(-50%)"}}),ot("div",{style:{position:"absolute",right:0,top:"50%",width:1,height:6,backgroundColor:"#FF0000",transform:"translateY(-50%)"}}),ot("div",{style:{position:"absolute",left:b.width<30?0:"50%",top:(b.width<30,void 0),bottom:"calc(50% + 4px)",transform:b.width<30?"none":"translateX(-50%)",fontSize:11,fontWeight:600,color:"#fff",backgroundColor:"#FF0000",padding:"2px 4px",whiteSpace:"nowrap",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1},children:Math.round(b.width)})]})},S)),e.activeTool==="model"&&e.isAnnotating&&J&&ot(mo,{element:J.rootElement,isSelected:!1,elementInfo:{selector:"",tagName:J.rootElement.tagName.toLowerCase(),reactComponent:J.name},color:g!=null&&g.has(J.name)?"#22c55e":"#8b5cf6"}),e.activeTool==="hand"&&e.isAnnotating&&e.inspectedElement&&So(wo,{children:[de&&de!=="padding"&&de!=="gap"&&(()=>{var z;let b=new Set(e.annotations.map(Y=>Y.groupId||Y.id)).size,S=e.inspectedElement.info.selector,X=e.styleModifications.findIndex(Y=>Y.selector===S),I=X>=0?b+X+1:b+e.styleModifications.length+1,P=e.styleModifications.find(Y=>Y.selector===S),H=(z=P==null?void 0:P.changes.length)!=null?z:0,ie=!!(P!=null&&P.captured);return ot(mo,{element:e.inspectedElement.el,isSelected:!0,elementInfo:e.inspectedElement.info,color:ie?"#999999":e.activeColor,annotationNumber:I,changeCount:H})})(),de==="padding"&&ot(pi,{element:e.inspectedElement.el,padding:uo(e.inspectedElement.el),accentColor:e.activeColor,hoveredSide:null,draggingSide:null}),de==="gap"&&ot(si,{element:e.inspectedElement.el,gap:Bo(e.inspectedElement.el),accentColor:e.activeColor,hoveredAxis:null,draggingAxis:null}),ot(Rl,{element:e.inspectedElement.el,elementInfo:e.inspectedElement.info,selector:e.inspectedElement.info.selector,styleModifications:e.styleModifications,dispatch:t,onClose:()=>t({type:"SELECT_ELEMENT",payload:null}),onHover:Le,accentColor:e.activeColor})]})]})}import{useCallback as ln,useEffect as bn,useMemo as Pi,useRef as It,useState as _o}from"react";import{Circle as Su,Component as wu,Hand as ku,MessageCircle as Eu,Pen as Cu,Slash as Mu,Square as Tu,Trash2 as Iu,Type as Lu}from"lucide-react";import{useEffect as Kd,useRef as Zd}from"react";function Nl(e,t,o,n,r){let i=Zd(0);Kd(()=>{if(!o.current||(localStorage.setItem(r.expanded,String(e)),!e))return;let s=t.annotations.length;(s>=i.current||s===0||!n)&&(localStorage.setItem(r.annotations,JSON.stringify(t.annotations)),i.current=s),localStorage.setItem(r.styleMods,JSON.stringify(t.styleModifications)),localStorage.setItem(r.spacingChanges,JSON.stringify(t.spacingTokenChanges)),localStorage.setItem(r.tool,t.activeTool),localStorage.setItem(r.color,t.activeColor),localStorage.setItem(r.stroke,String(t.strokeWidth)),t.inspectedElement?localStorage.setItem(r.inspected,JSON.stringify({selector:t.inspectedElement.info.selector,info:t.inspectedElement.info})):localStorage.removeItem(r.inspected)},[e,t.annotations,t.styleModifications,t.spacingTokenChanges,t.activeTool,t.activeColor,t.strokeWidth,t.inspectedElement,n,o,r])}import{Component as qd,createElement as Qd,useCallback as vr,useEffect as Eo,useRef as ko,useState as yn}from"react";import{Fragment as Co,jsx as De,jsxs as Xt}from"react/jsx-runtime";var Hl="popmelt-library-tab",eu=/^#[0-9a-fA-F]{3,8}$/,tu=/^(?:rgba?|hsla?|oklch)\([^)]+\)$/,nu=new Set(["black","white","red","blue","green","yellow","orange","purple","pink","gray","grey","cyan","magenta","brown","navy","teal","maroon","olive","silver","aqua","fuchsia","lime"]),ou=/^-?\d+(\.\d+)?(px|rem|em|%)$/;function zl(e){let t=e.trim();return eu.test(t)||tu.test(t)||nu.has(t.toLowerCase())}function ru(e){return ou.test(e.trim())}function iu(e){let t=e.trim().match(/^(-?\d+(?:\.\d+)?)px$/);return t?parseFloat(t[1]):null}function Li(e,t=""){if(e==null)return[];if(typeof e!="object")return[[t,String(e)]];if(Array.isArray(e))return[[t,e.map(String).join(", ")]];let o=[];for(let[n,r]of Object.entries(e)){let i=t?`${t}.${n}`:n;if(r!==null&&typeof r=="object"&&!Array.isArray(r)){let s=r;typeof s.value=="string"?o.push([i,s.value]):o.push(...Li(r,i))}else o.push([i,Array.isArray(r)?r.map(String).join(", "):String(r!=null?r:"")])}return o}function su(e){return e.length===0?"generic":e.filter(([,n])=>zl(n)).length>e.length/2?"colors":e.filter(([,n])=>ru(n)).length>e.length/2?"spacing":"generic"}var lu=m(f({position:"fixed",top:16,right:16,bottom:80,width:300,backgroundColor:"#ffffff"},gn),{boxSizing:"content-box",zIndex:10001,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12,color:"#1f2937",padding:12,pointerEvents:"auto"}),_l={border:"none",background:"none",cursor:"pointer",fontFamily:"inherit",fontSize:11,fontWeight:600,padding:"2px 0",color:"#9ca3af"},au=m(f({},_l),{color:"#1f2937",borderBottom:"1.5px solid #1f2937"});function cu({entries:e}){let t=[],o=[];for(let n of e)zl(n[1])?t.push(n):o.push(n);return Xt(Co,{children:[t.length>0&&De("div",{style:{display:"flex",flexWrap:"wrap",gap:2,marginBottom:o.length>0?6:0},children:t.map(([n,r])=>De("div",{title:`${n.split(".").pop()}: ${r}`,style:{width:28,height:28,backgroundColor:r,outline:"1px solid rgba(0,0,0,0.08)",outlineOffset:-1}},n))}),o.length>0&&De(Ri,{entries:o})]})}var xr=[0,1,2,4,8,12,16,20,24,28,32];function du(e){if(e<=32){let t=xr[0],o=Math.abs(e-t);for(let n=1;n<xr.length;n++){let r=Math.abs(e-xr[n]);r<o&&(t=xr[n],o=r)}return t}return Math.round(e/8)*8}function uu({label:e,value:t,px:o,tokenPath:n,rawToken:r,onHover:i,onModify:s,onDelete:l}){let[a,c]=yn(!1),[d,p]=yn(null),u=ko(!1),g=ko(0),x=ko(0),E=ko([]),h=d!==null?d:o,w=d!==null?`${d}px`:t,D=d!==null,B=vr(C=>{C.preventDefault(),u.current=!0,g.current=C.clientX,x.current=o;let L=or(r);E.current=Gr(L);let k=ee=>{let Z=ee.clientX-g.current,F=Math.max(0,Math.round(x.current+Z));ee.shiftKey&&(F=du(F));for(let K of E.current)K.element.style.setProperty(K.property,F+"px","important");p(F),i==null||i({name:e,px:F,token:L})},W=()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",W),document.body.style.cursor="",u.current=!1,p(ee=>{if(ee!==null&&ee!==o&&s){let Z=or(r),F=Z.bindings&&Z.bindings.length>0,K;if(F){let he=Ur(Z.bindings,x.current,ee);K=JSON.stringify(m(f({},Z),{value:`${ee}px`,bindings:he}))}else{let he=Us(E.current,x.current),Fe=Js(E.current);if(he.length>0){let Ie=Ur(he,x.current,ee);K=JSON.stringify({value:`${ee}px`,property:Fe,bindings:Ie})}else K=`${ee}px`}let q=typeof r=="string"?r:JSON.stringify(r),we=E.current.map(he=>({selector:on(he.element),property:he.property})),le=Ks(E.current,x.current,ee);s({tokenPath:n,originalValue:q,currentValue:K,targets:we,originalPx:x.current,currentPx:ee},{id:Math.random().toString(36).substring(2,9),tokenPath:n,tokenName:e,originalPx:x.current,newPx:ee,affectedElements:le})}return ee})};document.body.style.cursor="ew-resize",window.addEventListener("mousemove",k),window.addEventListener("mouseup",W)},[o,e,n,r,i,s]),M=or(r);return Xt("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:11,padding:"1px 0",cursor:"ew-resize",userSelect:"none"},onMouseEnter:()=>{u.current||(c(!0),i==null||i({name:e,px:h,token:M}))},onMouseLeave:()=>{u.current||(c(!1),i==null||i(null))},onMouseDown:B,children:[De("span",{style:{color:a||D?"#FF0000":"#9ca3af"},children:e}),Xt("span",{style:{display:"flex",alignItems:"center",gap:4},children:[De("span",{style:{color:a||D?"#FF0000":"#6b7280",fontWeight:600},children:w}),l&&a&&!D&&De("button",{type:"button",title:"Remove token",onMouseDown:C=>{C.stopPropagation();let L=typeof r=="string"?r:JSON.stringify(r);l(n,L)},style:{border:"none",background:"none",cursor:"pointer",padding:0,fontSize:10,lineHeight:1,color:"#9ca3af"},onMouseEnter:C=>{C.currentTarget.style.color="#FF0000"},onMouseLeave:C=>{C.currentTarget.style.color="#9ca3af"},children:"\u2715"})]})]})}function pu({entries:e,categoryKey:t,rawTokens:o,onHover:n,onModify:r,onDelete:i}){let s=[],l=[];for(let a of e){let c=iu(a[1]);c!==null?s.push([a[0],a[1],c]):l.push(a)}return Xt(Co,{children:[s.length>0&&De("div",{style:{display:"flex",flexDirection:"column",gap:2},children:s.map(([a,c,d])=>{let p=a.split(".").pop(),u=o?fu(o,a):c,g=u&&typeof u=="object"&&"value"in u?u:c;return De(uu,{label:p,value:c,px:d,tokenPath:`tokens.${t}.${a}`,rawToken:g,onHover:n,onModify:r,onDelete:i},a)})}),l.length>0&&De(Ri,{entries:l})]})}function fu(e,t){let o=t.split("."),n=e;for(let r of o){if(n==null||typeof n!="object")return;n=n[r]}return n}function Ri({entries:e}){return De("div",{style:{display:"flex",flexDirection:"column",gap:3},children:e.map(([t,o])=>Xt("div",{style:{fontSize:11},children:[De("div",{style:{color:"#9ca3af",fontSize:10,marginBottom:1},children:t}),De("div",{style:{color:"#1f2937",lineHeight:1.4,paddingLeft:8},children:o})]},t))})}function $l({entries:e,categoryKey:t,rawTokens:o,onSpacingHover:n,onModifyToken:r,onDeleteToken:i}){let s=su(e);return s==="colors"?De(cu,{entries:e}):s==="spacing"?De(pu,{entries:e,categoryKey:t,rawTokens:o,onHover:n,onModify:r,onDelete:i}):De(Ri,{entries:e})}function gu(e){let t=e.toLowerCase(),o=null,n=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,{acceptNode(i){return i.closest("#devtools-toolbar, #devtools-canvas, #devtools-scrim, [data-popmelt-panel]")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),r=n.currentNode;for(;r=n.nextNode();){let i=r,s=Object.keys(i).find(a=>a.startsWith("__reactFiber$")||a.startsWith("__reactInternalInstance$"));if(!s)continue;let l=i[s];for(;l;){let a=l.type,c=typeof a=="function"||typeof a=="object"?(a==null?void 0:a.displayName)||(a==null?void 0:a.name):null;if(typeof c=="string"){let d=c.toLowerCase();if(d===t){let p=f({},l.memoizedProps);return delete p.ref,{type:a,props:p}}if(!o){if(d.length>=4&&t.includes(d)){let p=f({},l.memoizedProps);delete p.ref,o={type:a,props:p}}else if(t.length>=4&&d.includes(t)){let p=f({},l.memoizedProps);delete p.ref,o={type:a,props:p}}}}l=l.return}}return o}var Ii=class extends qd{constructor(){super(...arguments);this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(){this.props.onError()}render(){return this.state.hasError?null:this.props.children}};function mu({children:e}){return De("div",{style:{fontWeight:700,fontSize:11,color:"#6b7280",letterSpacing:"0.05em",marginBottom:6},children:e})}function hu({tokens:e,onSpacingTokenHover:t,onModifyToken:o,onDeleteToken:n}){return!e||Object.keys(e).length===0?De("div",{style:{color:"#9ca3af",fontSize:11},children:"No tokens defined yet."}):De(Co,{children:Object.entries(e).map(([r,i])=>Xt("div",{style:{marginBottom:14},children:[De(mu,{children:r}),De($l,{entries:Li(i),categoryKey:r,rawTokens:i,onSpacingHover:t,onModifyToken:o,onDeleteToken:n})]},r))})}function yu({rules:e}){return!e||e.length===0?De("div",{style:{color:"#9ca3af",fontSize:11},children:"No rules defined yet."}):De(Co,{children:e.map((t,o)=>Xt("div",{style:{display:"flex",gap:6,marginBottom:4,lineHeight:1.4,fontSize:11},children:[Xt("span",{style:{color:"#9ca3af",flexShrink:0},children:[o+1,"."]}),De("span",{children:t})]},o))})}function bu({name:e,value:t,selected:o,highlighted:n,onRemove:r,onHover:i}){var ee;let[s,l]=yn(!1),[a,c]=yn(!1),d=ko(null),p=ko(0),[u,g]=yn(0),[x,E]=yn(0),h=Li(t),w=(ee=h.find(([Z])=>Z==="description"))==null?void 0:ee[1];Eo(()=>{if(!a&&!n){g(0),E(0),p.current=0;return}let Z=ao(e);g(Z.length)},[a,n,e]),Eo(()=>{o&&d.current&&d.current.scrollIntoView({behavior:"smooth",block:"nearest"})},[o]);let D=o||n||a,B=o?"139,92,246":"34,197,94",M=o?"#8b5cf6":"#22c55e",C=D?`rgba(${B},0.06)`:void 0,L=D?`inset 0 0 0 1.5px rgba(${B},0.35)`:void 0,k=n||a,W=vr(()=>{let Z=ao(e);if(Z.length===0)return;let F=p.current%Z.length;Z[F].rootElement.scrollIntoView({behavior:"smooth",block:"center"}),E(F),p.current=F+1,i==null||i({name:e,instanceIndex:F})},[e,i]);return Xt("div",{ref:d,onClick:W,onMouseEnter:()=>{c(!0),i==null||i({name:e,instanceIndex:0})},onMouseLeave:()=>{c(!1),i==null||i(null)},style:{marginBottom:8,background:C,padding:6,boxShadow:L,cursor:"pointer"},children:[Xt("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Xt("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[De("div",{style:{fontWeight:700,fontSize:11,letterSpacing:"0.05em",padding:"2px 6px",backgroundColor:k?M:"transparent",color:k?"#fff":"#6b7280"},children:e}),k&&u>1&&Xt("span",{style:{fontSize:10,fontWeight:600,color:"#9ca3af"},children:[x+1,"/",u]})]}),r&&a&&De("button",{type:"button",title:"Remove from model",onClick:Z=>{Z.stopPropagation(),r(e)},style:{border:"none",background:"none",cursor:"pointer",padding:"0 2px",fontSize:14,lineHeight:1,color:"#9ca3af",marginTop:-4},onMouseEnter:Z=>{Z.currentTarget.style.color="#FF0000"},onMouseLeave:Z=>{Z.currentTarget.style.color="#9ca3af"},children:"\u2715"})]}),w&&De("div",{style:{fontSize:11,color:k?"#1f2937":"#9ca3af",marginBottom:6,lineHeight:1.4},children:w}),s?De($l,{entries:h.filter(([Z])=>Z!=="description"),categoryKey:""}):De(xu,{name:e,onNotFound:()=>l(!0),entries:h})]})}function xu({name:e,onNotFound:t}){let[o,n]=yn(null),[r,i]=yn(!1);return Eo(()=>{let s=gu(e);s||t(),n(s),i(!0)},[e,t]),!r||!o?null:De(Ii,{onError:t,children:De("div",{"data-popmelt-panel":!0,onClick:s=>{s.preventDefault(),s.stopPropagation()},style:{width:"100%",overflowY:"auto",overflowX:"hidden",maxHeight:150,padding:"1rem",outline:"1px solid rgba(0,0,0,0.06)",backgroundColor:"rgb(250,250,250)",boxSizing:"border-box",marginBottom:4,display:"flex",flexDirection:"column",justifyContent:"stretch",alignItems:"center"},children:De("div",{style:{zoom:.5},children:Qd(o.type,o.props)})})})}function vu({components:e,selectedComponent:t,hoveredComponent:o,onRemove:n,onHover:r}){if(!e||Object.keys(e).length===0)return De("div",{style:{color:"#9ca3af",fontSize:11},children:"No component patterns defined yet."});let i=new Set(Object.keys(e)),s=Wr(i),l=Object.entries(e).sort(([a],[c])=>{var d,p;return((d=s.get(a))!=null?d:1/0)-((p=s.get(c))!=null?p:1/0)});return De(Co,{children:l.map(([a,c])=>De(bu,{name:a,value:c,selected:t===a,highlighted:o===a,onRemove:n,onHover:r},a))})}function Wl({bridgeUrl:e,modelRefreshKey:t,onMouseEnter:o,onMouseLeave:n,selectedComponent:r,hoveredComponent:i,onComponentHover:s,onSpacingTokenHover:l,onModifySpacingToken:a,onDeleteSpacingToken:c,onComponentAdded:d,onComponentRemoved:p}){let[u,g]=yn(void 0),[x,E]=yn(!0),[h,w]=yn(()=>{try{let F=localStorage.getItem(Hl);if(F==="tokens"||F==="components"||F==="rules")return F}catch(F){}return"components"});Eo(()=>{no(e).then(F=>{g(F),E(!1)})},[e,t]),Eo(()=>{try{localStorage.setItem(Hl,h)}catch(F){}},[h]),Eo(()=>{r&&(w("components"),no(e).then(F=>{F&&g(F)}))},[r,e]);let D=vr((F,K)=>{g(q=>{if(!(q!=null&&q.tokens))return q;let we=JSON.parse(JSON.stringify(q.tokens)),le=F.split("."),he=we;for(let Fe=1;Fe<le.length-1;Fe++)if(he=he[le[Fe]],!he)return q;return delete he[le[le.length-1]],m(f({},q),{tokens:we})}),c==null||c(F,K)},[c]),B=vr(F=>{g(K=>{if(!(K!=null&&K.components))return K;let le=K.components,{[F]:q}=le,we=Bn(le,[Ko(F)]);return m(f({},K),{components:we})}),p==null||p(F)},[p]),M=u==null?void 0:u.tokens,C=u==null?void 0:u.components,L=u==null?void 0:u.rules,k=M&&Object.keys(M).length>0,W=C&&Object.keys(C).length>0,ee=L&&L.length>0,Z=!u||!k&&!W&&!ee;return Xt("div",{style:lu,onMouseEnter:o,onMouseLeave:n,children:[Xt("div",{style:{display:"flex",alignItems:"center",gap:6,fontWeight:700,fontSize:13,marginBottom:6},children:[De("span",{children:"Model"}),De("code",{style:{fontSize:10,fontWeight:500,backgroundColor:"rgba(0,0,0,0.06)",padding:"1px 4px",color:"#6b7280"},children:"M"})]}),De("div",{style:{display:"flex",gap:12,marginBottom:10,borderBottom:"1px solid rgba(0,0,0,0.08)",paddingBottom:6},children:["components","rules"].map(F=>De("button",{type:"button",style:h===F?au:_l,onClick:()=>w(F),children:F.charAt(0).toUpperCase()+F.slice(1)},F))}),De("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:x?De("div",{style:{color:"#9ca3af",fontSize:11},children:"Loading..."}):Z?De("div",{style:{color:"#9ca3af",lineHeight:1.5},children:"No design model yet. Pattern-scoped annotations will build one automatically."}):Xt(Co,{children:[h==="components"&&De(vu,{components:C,selectedComponent:r,hoveredComponent:i,onRemove:B,onHover:s}),h==="tokens"&&De(hu,{tokens:M,onSpacingTokenHover:l,onModifyToken:a,onDeleteToken:c?D:void 0}),h==="rules"&&De(yu,{rules:L})]})})]})}import{jsx as Yl}from"react/jsx-runtime";var In={iconDefault:"#1f2937",iconActive:"#1f2937",bgActive:"#f3f4f6",bgHover:"#f9fafb",separator:"#e5e7eb"};function Ln({children:e,active:t,siblingActive:o,disabled:n,onClick:r,title:i}){let s=()=>n?.4:o&&!t?.5:1,l={position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:0,border:"none",cursor:n?"default":"pointer",transition:"background-color 150ms ease, color 150ms ease, transform 100ms ease, opacity 150ms ease",backgroundColor:t?In.bgActive:"transparent",color:t?In.iconActive:In.iconDefault,opacity:s()};return Yl("button",{type:"button",onClick:n?void 0:r,title:i,disabled:n,style:l,onMouseEnter:a=>{n||(a.currentTarget.style.opacity="1",t||(a.currentTarget.style.backgroundColor=In.bgHover))},onMouseLeave:a=>{n||(a.currentTarget.style.opacity=String(s()),t||(a.currentTarget.style.backgroundColor="transparent"))},onMouseDown:a=>{n||(a.currentTarget.style.transform="scale(0.95)")},onMouseUp:a=>{n||(a.currentTarget.style.transform="scale(1)")},children:e})}function Ai(){return Yl("div",{style:{width:1,height:20,backgroundColor:"rgba(0, 0, 0, 0.05)",margin:"0 8px"}})}import{Fragment as Zn,jsx as ne,jsxs as xt}from"react/jsx-runtime";var qn=[{type:"rectangle",icon:Tu,label:"Rectangle",shortcut:"R"},{type:"circle",icon:Su,label:"Oval",shortcut:"O"},{type:"line",icon:Mu,label:"Line",shortcut:"L"},{type:"freehand",icon:Cu,label:"Pen",shortcut:"P"}],Ru=new Set(qn.map(e=>e.type));function Au(e,t,o,n,r,i,s,l){let a=(e-r)*(n-i)-(o-r)*(t-i),c=(e-s)*(i-l)-(r-s)*(t-l),d=(e-o)*(l-n)-(s-o)*(t-n),p=a<0||c<0||d<0,u=a>0||c>0||d>0;return!(p&&u)}function Pu(){let e=window.innerWidth-16,t=e-326,o=window.innerHeight-80;return{left:t,right:e,y:o}}var Bu=[{type:"text",icon:Lu,label:"Text",shortcut:"T"}],jl={inspector:{name:"Comment",desc:"Pin feedback to specific elements on the page.",usage:["Click any element to attach a comment","Type your note, then hand off to your AI","Your AI may ask clarifying questions","Replies get threaded"],keys:[{key:"C",desc:"Select tool"},{key:"Click",desc:"Pin comment to element"},{key:"Esc",desc:"Deselect"},{key:"\u2318 Enter",desc:"Hand off to your AI",accent:!0}]},hand:{name:"Handle",desc:"Quickly finetune layout and typescale.",usage:["Edges \u2192 padding","Between items \u2192 spacing","Corners \u2192 rounding","Right of text \u2192 font size","Below text \u2192 line height","Click a spacing handle to cycle distribution","Right-click \u2192 inspect element styles"],keys:[{key:"H",desc:"Select tool"},{key:"Shift",desc:"Snap to scale"},{key:"\u2325 + swipe",desc:"Cycle justify / flip direction"},{key:"\u21E7 + swipe",desc:"Cycle align-items"},{key:"Right-click",desc:"Inspect styles"},{key:"Esc",desc:"Deselect"},{key:"\u2318 Enter",desc:"Hand off to your AI",accent:!0}]},rectangle:{name:"Rectangle",desc:"Draw rectangular highlights to mark areas of interest.",usage:["Click and drag to draw","Cycle between shapes with the dot selector"],keys:[{key:"R",desc:"Rectangle"},{key:"O",desc:"Oval"},{key:"L",desc:"Line"},{key:"P",desc:"Pen"},{key:"Esc",desc:"Cancel or deselect"},{key:"\u2318 Enter",desc:"Hand off to your AI",accent:!0}]},circle:{name:"Oval",desc:"Draw oval highlights to mark areas of interest.",usage:["Click and drag to draw","Cycle between shapes with the dot selector"],keys:[{key:"O",desc:"Oval"},{key:"R",desc:"Rectangle"},{key:"L",desc:"Line"},{key:"P",desc:"Pen"},{key:"Esc",desc:"Cancel or deselect"},{key:"\u2318 Enter",desc:"Hand off to your AI",accent:!0}]},line:{name:"Line",desc:"Draw line annotations to point at or connect elements.",usage:["Click and drag to draw","Cycle between shapes with the dot selector"],keys:[{key:"L",desc:"Line"},{key:"R",desc:"Rectangle"},{key:"O",desc:"Oval"},{key:"P",desc:"Pen"},{key:"Esc",desc:"Cancel or deselect"},{key:"\u2318 Enter",desc:"Hand off to your AI",accent:!0}]},freehand:{name:"Pen",desc:"Draw freehand paths to annotate freely.",usage:["Click and drag to draw","Cycle between shapes with the dot selector"],keys:[{key:"P",desc:"Pen"},{key:"R",desc:"Rectangle"},{key:"O",desc:"Oval"},{key:"L",desc:"Line"},{key:"Esc",desc:"Cancel or deselect"},{key:"\u2318 Enter",desc:"Hand off to your AI",accent:!0}]},text:{name:"Text",desc:"Place text labels anywhere on the page.",usage:["Click to place, then start typing","Click away or press Enter to finish","Scroll while hovering a label to resize it"],keys:[{key:"T",desc:"Select tool"},{key:"Esc",desc:"Cancel text or deselect"},{key:"\u2318 Enter",desc:"Hand off to your AI",accent:!0}]},model:{name:"Model",desc:"Promote components into the local design model.",usage:["Hover to highlight component boundaries","Scroll to walk up/down the component tree","Click to add to model.json","Green = already in model"],keys:[{key:"M",desc:"Select tool"},{key:"Scroll",desc:"Walk tree depth"},{key:"Click",desc:"Promote component"},{key:"Esc",desc:"Deselect"}]},counter:{name:"Annotations",desc:"Click to cycle, scroll to change color, long press to reset.",usage:[],keys:[{key:"Click",desc:"Cycle annotations"},{key:"Scroll",desc:"Change color"},{key:"Hold",desc:"Reset to red"}]},clear:{name:"Clear",desc:"Remove all annotations and style changes.",usage:[],keys:[{key:"\u2318 \u232B",desc:"Clear all"},{key:"\u232B",desc:"Delete selected annotation"},{key:"\u2318 Z",desc:"Undo"},{key:"\u2318 \u21E7 Z",desc:"Redo"}]},collapse:{name:"Popmelt",desc:`Comment and zhuzh, then hand off.
|
|
2
|
+
var Ma=Object.defineProperty,Ta=Object.defineProperties;var La=Object.getOwnPropertyDescriptors;var qo=Object.getOwnPropertySymbols;var hs=Object.prototype.hasOwnProperty,ys=Object.prototype.propertyIsEnumerable;var ms=(e,t,o)=>t in e?Ma(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,f=(e,t)=>{for(var o in t||(t={}))hs.call(t,o)&&ms(e,o,t[o]);if(qo)for(var o of qo(t))ys.call(t,o)&&ms(e,o,t[o]);return e},m=(e,t)=>Ta(e,La(t));var Qo=e=>typeof e=="symbol"?e:e+"",Hn=(e,t)=>{var o={};for(var r in e)hs.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&qo)for(var r of qo(e))t.indexOf(r)<0&&ys.call(e,r)&&(o[r]=e[r]);return o};import{createContext as Ap,useCallback as jt,useContext as Pp,useEffect as _t,useMemo as Ao,useRef as Xt,useState as Ut}from"react";import{useCallback as Ts,useEffect as Ia,useSyncExternalStore as Ra}from"react";var Cn="http://localhost:1111";function kn(e,t={},o=15e3){let r=new AbortController;t.signal&&t.signal.addEventListener("abort",()=>r.abort());let n=setTimeout(()=>r.abort(),o);return fetch(e,m(f({},t),{signal:r.signal})).finally(()=>clearTimeout(n))}async function xs(e=Cn){try{let t=await kn(`${e}/capabilities`,{},5e3);return t.ok?await t.json():null}catch(t){return null}}async function er(e=Cn){try{let t=new AbortController,o=setTimeout(()=>t.abort(),2e3),r=await fetch(`${e}/status`,{signal:t.signal});return clearTimeout(o),r.ok?await r.json():null}catch(t){return null}}async function bs(e){try{let t=new AbortController,o=setTimeout(()=>t.abort(),500),r=await fetch(`http://localhost:${e}/status`,{signal:t.signal});return clearTimeout(o),r.ok?await r.json():null}catch(t){return null}}async function vs(e){if(e&&e!=="http://localhost:1111")try{let c=new URL(e);return{url:e,port:parseInt(c.port,10)||1111}}catch(c){return null}let n=typeof window!="undefined"?window.location.origin:null,i=await bs(1111);if(i&&i.devOrigin&&n&&i.devOrigin===n)return{url:"http://localhost:1111",port:1111};let s=Array.from({length:8},(c,d)=>{let u=1112+d;return bs(u).then(p=>p?{status:p,port:u}:null)}),l=(await Promise.all(s)).filter(c=>c!==null),a=[];i&&a.push({port:1111,devOrigin:i.devOrigin});for(let c of l)a.push({port:c.port,devOrigin:c.status.devOrigin});if(n){let c=a.find(d=>d.devOrigin===n);if(c)return{url:`http://localhost:${c.port}`,port:c.port}}return a.length===1?{url:`http://localhost:${a[0].port}`,port:a[0].port}:i?{url:"http://localhost:1111",port:1111}:a.length>0?{url:`http://localhost:${a[0].port}`,port:a[0].port}:null}async function Ss(e,t,o=Cn,r,n,i,s,l){let a=new FormData;if(a.append("screenshot",e,"screenshot.png"),a.append("feedback",t),r&&a.append("color",r),n&&a.append("provider",n),i&&a.append("model",i),l&&a.append("sourceId",l),s)for(let[d,u]of s)for(let p=0;p<u.length;p++)a.append(`image-${d}-${p}`,u[p],`image-${d}-${p}.png`);let c=await kn(`${o}/send`,{method:"POST",body:a},3e4);if(!c.ok){let d=await c.text();throw new Error(`Bridge returned ${c.status}: ${d}`)}return c.json()}async function ws(e=Cn,t){try{let o=await kn(`${e}/mcp/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{serverUrl:t}:{})},15e3);return o.ok?await o.json():null}catch(o){return null}}async function Es(e,t=Cn){let o=await kn(`${t}/model/component`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})},1e4);if(!o.ok){let r=await o.text();throw new Error(`Bridge returned ${o.status}: ${r}`)}return o.json()}async function ks(e,t=Cn){let o=await kn(`${t}/model/component`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})},1e4);if(!o.ok){let r=await o.text();throw new Error(`Bridge returned ${o.status}: ${r}`)}return o.json()}async function Ar(e,t,o=Cn){let r=await kn(`${o}/model/token`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,value:t})},1e4);if(!r.ok){let n=await r.text();throw new Error(`Bridge returned ${r.status}: ${n}`)}return r.json()}async function Cs(e,t=Cn){let o=await kn(`${t}/model/token`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})},1e4);if(!o.ok){let r=await o.text();throw new Error(`Bridge returned ${o.status}: ${r}`)}return o.json()}async function io(e=Cn){var t;try{let o=await kn(`${e}/model`,{},5e3);return o.ok&&(t=(await o.json()).model)!=null?t:null}catch(o){return null}}async function Ms(e,t,o=Cn,r,n,i,s,l){let a;if(s&&s.length>0){let c=new FormData,d=new Blob([new Uint8Array([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,6,0,0,0,31,21,196,137,0,0,0,10,73,68,65,84,120,156,98,0,0,0,2,0,1,229,39,222,252,0,0,0,0,73,69,78,68,174,66,96,130])],{type:"image/png"});c.append("screenshot",d,"screenshot.png"),c.append("feedback",JSON.stringify({threadId:e,reply:t,color:r,provider:n,model:i,sourceId:l}));for(let u=0;u<s.length;u++)c.append(`image-reply-${u}`,s[u],`reply-image-${u}.png`);a=await kn(`${o}/reply`,{method:"POST",body:c},3e4)}else a=await kn(`${o}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:e,reply:t,color:r,provider:n,model:i,sourceId:l})},3e4);if(!a.ok){let c=await a.text();throw new Error(`Bridge returned ${a.status}: ${c}`)}return a.json()}var As=typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Math.random().toString(36).slice(2);function Br(){return As}var Aa={isConnected:!1,status:"disconnected",jobResponses:{},jobThinking:{},activeJobIds:[],currentResponse:"",currentThinking:"",events:[],activeJobId:null,lastCompletedJobId:null,lastResponseText:null,lastThreadId:null,lastErrorByJob:{},pendingQuestions:[],incrementalResolutions:[],capabilitiesVersion:0},tr=f({},Aa),Pr=new Set,so=null,Ls=null,Yn=null,Is=0,ao=null,lo=null;async function Pa(e){return e&&e!=="http://localhost:1111"?(ao=e,e):ao||lo||(lo=vs(e).then(o=>{var r;return ao=(r=o==null?void 0:o.url)!=null?r:null,lo=null,ao}).catch(()=>(lo=null,null)),lo)}function Ps(){return ao}function Rs(){return tr}function Ba(e){return Pr.add(e),()=>{Pr.delete(e)}}function tn(e){tr=e(tr);for(let t of Pr)t()}function Bs(e){if(so&&so.readyState!==EventSource.CLOSED&&Ls===e)return;so&&(so.close(),so=null),Yn&&(clearTimeout(Yn),Yn=null),Ls=e;let t=++Is,o=new EventSource(`${e}/events?sourceId=${As}`);so=o;let r=()=>t!==Is;o.addEventListener("connected",()=>{r()||er(e).then(n=>{var d,u;if(r())return;let i=(d=n==null?void 0:n.activeJobs)!=null?d:n!=null&&n.activeJob?[n.activeJob]:[],s=new Set(i.map(p=>p.id)),l=(u=n==null?void 0:n.recentJobs)!=null?u:[],a=new Map(l.map(p=>[p.id,p])),c=i.length>0;tn(p=>{let g=f({},p.lastErrorByJob),S=p.activeJobIds.filter(y=>!s.has(y));for(let y of S){let w=a.get(y);(w==null?void 0:w.status)==="error"&&w.error&&(g[y]=w.error)}let v=p.activeJobIds.filter(y=>s.has(y));for(let y of s)v.includes(y)||v.push(y);return m(f({},p),{isConnected:!0,status:c?"streaming":S.length>0||p.status==="disconnected"?"idle":p.status,activeJobId:c?i[i.length-1].id:v.length>0?v[v.length-1]:null,activeJobIds:v,lastErrorByJob:g,lastCompletedJobId:S.length>0?S[S.length-1]:p.lastCompletedJobId})})})}),o.addEventListener("job_started",n=>{if(r())return;let i=JSON.parse(n.data),s=i.jobId;tn(l=>m(f({},l),{status:"streaming",activeJobId:s,activeJobIds:[...l.activeJobIds,s],jobResponses:m(f({},l.jobResponses),{[s]:""}),jobThinking:m(f({},l.jobThinking),{[s]:""}),currentResponse:"",currentThinking:"",lastResponseText:null,lastThreadId:null,events:[...l.events,{type:"job_started",data:i,timestamp:Date.now()}]}))}),o.addEventListener("delta",n=>{if(r())return;let i=JSON.parse(n.data),s=i.jobId,l=i.text||"";tn(a=>m(f({},a),{jobResponses:s?m(f({},a.jobResponses),{[s]:(a.jobResponses[s]||"")+l}):a.jobResponses,currentResponse:!s||s===a.activeJobId?a.currentResponse+l:a.currentResponse,events:[...a.events,{type:"delta",data:i,timestamp:Date.now()}]}))}),o.addEventListener("thinking",n=>{if(r())return;let i=JSON.parse(n.data),s=i.jobId,l=i.text||"";tn(a=>m(f({},a),{jobThinking:s?m(f({},a.jobThinking),{[s]:(a.jobThinking[s]||"")+l}):a.jobThinking,currentThinking:!s||s===a.activeJobId?a.currentThinking+l:a.currentThinking,events:[...a.events,{type:"thinking",data:i,timestamp:Date.now()}]}))}),o.addEventListener("tool_use",n=>{if(r())return;let i=JSON.parse(n.data);tn(s=>m(f({},s),{events:[...s.events,{type:"tool_use",data:i,timestamp:Date.now()}]}))}),o.addEventListener("done",n=>{if(r())return;let i=JSON.parse(n.data),s=i.jobId;tn(l=>{var g;let a=s?l.activeJobIds.filter(S=>S!==s):l.activeJobIds,c=f({},l.jobResponses),d=f({},l.jobThinking),u=s?c[s]:void 0;s&&(delete c[s],delete d[s]);let p=s===l.activeJobId?a.length>0?a[a.length-1]:null:l.activeJobId;return m(f(m(f({},l),{activeJobIds:a,activeJobId:p,jobResponses:c,jobThinking:d,lastCompletedJobId:s!=null?s:l.activeJobId,lastResponseText:u||l.currentResponse||i.responseText||null,lastThreadId:(g=i.threadId)!=null?g:null}),s===l.activeJobId?{currentResponse:p&&c[p]||"",currentThinking:p&&d[p]||""}:{}),{events:[...l.events,{type:"done",data:i,timestamp:Date.now()}]})})}),o.addEventListener("question",n=>{if(r())return;let i=JSON.parse(n.data);tn(s=>m(f({},s),{pendingQuestions:[...s.pendingQuestions,{jobId:i.jobId,threadId:i.threadId,question:i.question,annotationIds:i.annotationIds,timestamp:Date.now()}],events:[...s.events,{type:"question",data:i,timestamp:Date.now()}]}))}),o.addEventListener("capabilities_changed",()=>{r()||tn(n=>m(f({},n),{capabilitiesVersion:n.capabilitiesVersion+1}))}),o.addEventListener("queue_drained",()=>{r()||tn(n=>m(f({},n),{status:n.status==="error"?"error":"idle",activeJobId:null,activeJobIds:[],currentResponse:"",currentThinking:"",jobResponses:{},jobThinking:{},lastErrorByJob:{},incrementalResolutions:[]}))}),o.addEventListener("error",n=>{var i,s;if(!r()){if(o.readyState===EventSource.CLOSED)tn(l=>m(f({},l),{isConnected:!1,status:"disconnected"})),Yn&&(clearTimeout(Yn),Yn=null),Yn=setTimeout(()=>{er(e).then(l=>{l&&Bs(e)})},5e3);else if(n instanceof MessageEvent){let l=JSON.parse(n.data),a=(i=l.jobId)!=null?i:null,c=(s=l.message)!=null?s:"";tn(d=>{let u=a?d.activeJobIds.filter(g=>g!==a):d.activeJobIds,p=u.length>0?d.status:"error";return m(f({},d),{status:p,activeJobIds:u,lastCompletedJobId:a!=null?a:d.activeJobId,lastErrorByJob:a&&c?m(f({},d.lastErrorByJob),{[a]:c}):d.lastErrorByJob,events:[...d.events,{type:"error",data:l,timestamp:Date.now()}]})})}}}),o.onerror=()=>{r()||o.readyState===EventSource.CLOSED&&tn(n=>m(f({},n),{isConnected:!1,status:"disconnected"}))}}function Os(e="http://localhost:1111"){let t=Ra(Ba,Rs,Rs);Ia(()=>{Pa(e).then(n=>{n&&er(n).then(i=>{i&&Bs(n)})})},[e]);let o=Ts(()=>{tn(()=>m(f({},tr),{events:[],currentResponse:"",currentThinking:"",jobResponses:{},jobThinking:{},lastResponseText:null,lastThreadId:null,lastErrorByJob:{},incrementalResolutions:[]}))},[]),r=Ts(n=>{tn(i=>m(f({},i),{pendingQuestions:i.pendingQuestions.filter(s=>s.threadId!==n)}))},[]);return m(f({},t),{clearEvents:o,dismissQuestion:r})}import{useEffect as Oa,useReducer as Da}from"react";var Ha={isAnnotating:!1,activeTool:"inspector",activeColor:"#ff0000",strokeWidth:3,annotations:[],undoStack:[],redoStack:[],currentPath:[],selectedAnnotationIds:[],lastSelectedId:null,inspectedElement:null,styleModifications:[],spacingTokenChanges:[],spacingTokenMods:[]};function nr(){return Math.random().toString(36).substring(2,9)}function Ds(e){return e.status?e:e.captured?m(f({},e),{status:"in_flight"}):m(f({},e),{status:"pending"})}function Zt(e){return m(f({},e),{undoStack:[...e.undoStack,{annotations:e.annotations,styleModifications:e.styleModifications,spacingTokenMods:e.spacingTokenMods}],redoStack:[]})}function Fa(e,t){return m(f({},e),{isAnnotating:t})}function Na(e,t){return m(f({},e),{activeTool:t,inspectedElement:null})}function _a(e,t){return m(f({},e),{activeColor:t})}function za(e,t){return m(f({},e),{strokeWidth:t})}function $a(e,t){return m(f({},e),{currentPath:[t]})}function Wa(e,t){return m(f({},e),{currentPath:[...e.currentPath,t]})}function Ya(e){return m(f({},e),{currentPath:[]})}function ja(e,t){if(e.currentPath.length<2&&e.activeTool!=="text")return m(f({},e),{currentPath:[]});let o={id:nr(),type:e.activeTool,points:e.currentPath,color:e.activeColor,strokeWidth:e.strokeWidth,timestamp:Date.now(),status:"pending",groupId:t==null?void 0:t.groupId,elements:t==null?void 0:t.elements},r=Zt(e);return m(f({},r),{annotations:[...e.annotations,o],currentPath:[]})}function Ga(e,t){var n;let o=f({id:(n=t.id)!=null?n:nr(),type:"text",points:[t.point],text:t.text,fontSize:t.fontSize||12,color:e.activeColor,strokeWidth:e.strokeWidth,timestamp:Date.now(),status:"pending",groupId:t.groupId,linkedSelector:t.linkedSelector,linkedAnchor:t.linkedAnchor,elements:t.elements},t.imageCount?{imageCount:t.imageCount}:{}),r=t.groupId?e:Zt(e);return m(f({},r),{annotations:[...e.annotations,o]})}function Va(e,t){let o=Zt(e);return m(f({},o),{annotations:e.annotations.map(r=>r.id===t.id?f(m(f({},r),{text:t.text}),t.imageCount!=null?{imageCount:t.imageCount}:{}):r)})}function Ua(e,t){return m(f({},e),{annotations:e.annotations.map(o=>o.id===t.id?m(f({},o),{fontSize:Math.max(12,Math.min(72,t.fontSize))}):o)})}function Ja(e,t){let o=Zt(e),r=e.annotations.find(i=>i.id===t.id),n=r==null?void 0:r.groupId;return m(f({},o),{annotations:e.annotations.filter(i=>i.id!==t.id&&!(n&&i.groupId===n))})}function Xa(e,t){let o=t.saveUndo?Zt(e):e,r=e.annotations.find(i=>i.id===t.id),n=r==null?void 0:r.groupId;return m(f({},o),{annotations:e.annotations.map(i=>{if(!(i.id===t.id||n&&i.groupId===n))return i;let l=t.delta.x,a=t.delta.y;return m(f({},i),{points:i.points.map(c=>({x:c.x+l,y:c.y+a}))})})})}function Ka(e,t){let o=t.saveUndo?Zt(e):e,r=e.annotations.find(s=>s.id===t.id);if(!r||r.type==="text"||r.points.length<2)return e;let n=0,i=0;if(r.type==="rectangle"&&r.groupId){let s=t.points,l=Math.min(s[0].x,s[1].x),a=Math.max(s[0].y,s[1].y),c=r.points[0],d=r.points[r.points.length-1],u=Math.min(c.x,d.x),p=Math.max(c.y,d.y);n=l-u,i=a-p}return m(f({},o),{annotations:e.annotations.map(s=>s.id===t.id?m(f({},s),{points:t.points}):r.groupId&&s.groupId===r.groupId&&s.type==="text"?m(f({},s),{points:s.points.map(l=>({x:l.x+n,y:l.y+i}))}):s)})}function Za(e,t){let o=Zt(e);return m(f({},o),{annotations:[...e.annotations,...t.annotations.map(Ds)]})}function qa(e,t){let o=new Set,r=[];for(let n of t.annotations)o.has(n.id)||(o.add(n.id),r.push(Ds(n)));return m(f({},e),{annotations:r})}function Qa(e){if(e.undoStack.length===0)return e;let t=e.undoStack[e.undoStack.length-1];return m(f({},e),{annotations:(t==null?void 0:t.annotations)||[],styleModifications:(t==null?void 0:t.styleModifications)||[],spacingTokenMods:(t==null?void 0:t.spacingTokenMods)||[],undoStack:e.undoStack.slice(0,-1),redoStack:[...e.redoStack,{annotations:e.annotations,styleModifications:e.styleModifications,spacingTokenMods:e.spacingTokenMods}]})}function ec(e){if(e.redoStack.length===0)return e;let t=e.redoStack[e.redoStack.length-1];return m(f({},e),{annotations:(t==null?void 0:t.annotations)||[],styleModifications:(t==null?void 0:t.styleModifications)||[],spacingTokenMods:(t==null?void 0:t.spacingTokenMods)||[],redoStack:e.redoStack.slice(0,-1),undoStack:[...e.undoStack,{annotations:e.annotations,styleModifications:e.styleModifications,spacingTokenMods:e.spacingTokenMods}]})}function tc(e,t){let{id:o,addToSelection:r}=t;if(o===null)return m(f({},e),{selectedAnnotationIds:[],lastSelectedId:null});if(r)if(e.selectedAnnotationIds.includes(o)){let i=e.selectedAnnotationIds.filter(s=>s!==o);return m(f({},e),{selectedAnnotationIds:i,lastSelectedId:i.length>0?i[i.length-1]:null})}else return m(f({},e),{selectedAnnotationIds:[...e.selectedAnnotationIds,o],lastSelectedId:o});return m(f({},e),{selectedAnnotationIds:[o],lastSelectedId:o})}function nc(e,t){let o=new Set;for(let r of e.selectedAnnotationIds){let n=e.annotations.find(i=>i.id===r);n!=null&&n.groupId&&o.add(n.groupId)}return m(f({},e),{annotations:e.annotations.map(r=>{let n=e.selectedAnnotationIds.includes(r.id),i=r.groupId&&o.has(r.groupId);return!n&&!i?r:m(f({},r),{color:t.color})})})}function oc(e){return m(f({},e),{annotations:e.annotations.map(t=>m(f({},t),{captured:!0,status:t.status==="pending"||!t.status?"in_flight":t.status})),styleModifications:e.styleModifications.map(t=>m(f({},t),{captured:!0})),spacingTokenChanges:e.spacingTokenChanges.map(t=>m(f({},t),{captured:!0}))})}function rc(e){return m(f({},e),{annotations:[],undoStack:[],redoStack:[],currentPath:[],selectedAnnotationIds:[],lastSelectedId:null,spacingTokenChanges:[],spacingTokenMods:[]})}function ic(e,t){return m(f({},e),{inspectedElement:t})}function sc(e,t){let{selector:o,element:r,property:n,original:i,modified:s}=t,l=e.styleModifications.findIndex(a=>a.selector===o);if(i===s&&l<0)return e;if(l>=0){let a=e.styleModifications[l];if(a.captured){let g=Zt(e),S=g.styleModifications.map((v,y)=>y===l?m(f({},v),{changes:[{property:n,original:i,modified:s}],captured:!1}):v);return m(f({},g),{styleModifications:S})}let c=a.changes.findIndex(g=>g.property===n),d,u=e;if(c>=0){let g=a.changes[c];s===g.original?d=a.changes.filter((S,v)=>v!==c):d=a.changes.map((S,v)=>v===c?m(f({},S),{modified:s}):S)}else{if(i===s)return e;u=Zt(e),d=[...a.changes,{property:n,original:i,modified:s}]}if(d.length===0)return m(f({},u),{styleModifications:u.styleModifications.filter((g,S)=>S!==l)});let p=u.styleModifications.map((g,S)=>S===l?m(f({},g),{changes:d}):g);return m(f({},u),{styleModifications:p})}else{let a=Zt(e),c={selector:o,element:r,changes:[{property:n,original:i,modified:s}]};return m(f({},a),{styleModifications:[...a.styleModifications,c]})}}function lc(e,t){let{selector:o,durableSelector:r,element:n,changes:i}=t,s=i.filter(c=>c.original!==c.modified);if(s.length===0)return e;let l=Zt(e),a=l.styleModifications.findIndex(c=>c.selector===o);if(a>=0){let c=l.styleModifications[a],d=c.captured?[]:[...c.changes];for(let u of s){let p=d.findIndex(g=>g.property===u.property);p>=0?u.modified===d[p].original?d=d.filter((g,S)=>S!==p):d=d.map((g,S)=>S===p?m(f({},g),{modified:u.modified}):g):d.push(u)}return d.length===0?m(f({},l),{styleModifications:l.styleModifications.filter((u,p)=>p!==a)}):m(f({},l),{styleModifications:l.styleModifications.map((u,p)=>p===a?m(f({},u),{changes:d,captured:!1}):u)})}else return m(f({},l),{styleModifications:[...l.styleModifications,{selector:o,durableSelector:r,element:n,changes:s}]})}function ac(e,t){let{selector:o,property:r}=t,n=Zt(e),i=n.styleModifications.map(s=>s.selector!==o?s:m(f({},s),{changes:s.changes.filter(l=>l.property!==r)})).filter(s=>s.changes.length>0);return m(f({},n),{styleModifications:i})}function cc(e){if(e.styleModifications.length===0)return m(f({},e),{inspectedElement:null});let t=Zt(e);return m(f({},t),{styleModifications:[],inspectedElement:null})}function dc(e,t){return m(f({},e),{styleModifications:t})}function uc(e,t){let{updates:o}=t,r=new Map(o.map(n=>[n.id,n]));return m(f({},e),{annotations:e.annotations.map(n=>{let i=r.get(n.id);return i?f(m(f({},n),{points:[i.point,...n.points.slice(1)]}),i.linkedAnchor?{linkedAnchor:i.linkedAnchor}:{}):n})})}function pc(e,t){let o=new Set(t.ids);return m(f({},e),{annotations:e.annotations.map(r=>o.has(r.id)?m(f({},r),{status:t.status}):r)})}function fc(e,t){let o=new Set(t.ids),r=new Set;for(let n of e.annotations)o.has(n.id)&&n.groupId&&r.add(n.groupId);return m(f({},e),{annotations:e.annotations.map(n=>o.has(n.id)||n.groupId&&r.has(n.groupId)?m(f({},n),{threadId:t.threadId}):n)})}function gc(e,t){let o=new Set(t.ids),r=new Set;for(let n of e.annotations)o.has(n.id)&&n.groupId&&r.add(n.groupId);return m(f({},e),{annotations:e.annotations.map(n=>o.has(n.id)||n.groupId&&r.has(n.groupId)?m(f({},n),{status:"waiting_input",question:t.question,threadId:t.threadId}):n)})}function mc(e,t){let o=new Map(t.resolutions.map(n=>[n.annotationId,n])),r=new Map;for(let n of e.annotations){let i=o.get(n.id);i&&n.groupId&&r.set(n.groupId,i)}return m(f({},e),{annotations:e.annotations.map(n=>{var s,l,a;let i=o.get(n.id)||(n.groupId?r.get(n.groupId):void 0);return i?m(f({},n),{status:i.status,resolutionSummary:i.summary,scope:(l=(s=i.finalScope)!=null?s:i.inferredScope)!=null?l:null,replyCount:((a=n.replyCount)!=null?a:0)+1,question:void 0,threadId:n.threadId||t.threadId}):n})})}function hc(e,t){let{linkedSelectors:o,styleSelectors:r}=t,n=new Set(o),i=new Set(r),s=new Set,l=new Set;for(let p of e.annotations)p.linkedSelector&&n.has(p.linkedSelector)&&(s.add(p.id),p.groupId&&l.add(p.groupId));for(let p of e.annotations)p.groupId&&l.has(p.groupId)&&s.add(p.id);let a=e.annotations.filter(p=>!s.has(p.id)),c=e.styleModifications.filter(p=>!i.has(p.selector));if(a.length===e.annotations.length&&c.length===e.styleModifications.length)return e;let d=e.selectedAnnotationIds.filter(p=>!s.has(p)),u=e.inspectedElement&&i.has(e.inspectedElement.info.selector)?null:e.inspectedElement;return m(f({},e),{annotations:a,styleModifications:c,selectedAnnotationIds:d,lastSelectedId:d.length>0?d[d.length-1]:null,inspectedElement:u})}function yc(e,t){let o=e.spacingTokenChanges.findIndex(r=>r.tokenPath===t.tokenPath);return o>=0?m(f({},e),{spacingTokenChanges:e.spacingTokenChanges.map((r,n)=>n===o?t:r)}):m(f({},e),{spacingTokenChanges:[...e.spacingTokenChanges,t]})}function bc(e,t){return m(f({},e),{spacingTokenChanges:t})}function xc(e,t){let o=Zt(e),r=e.spacingTokenMods.findIndex(i=>i.tokenPath===t.tokenPath),n;if(r>=0){let i=e.spacingTokenMods[r],s=m(f({},t),{originalValue:i.originalValue,originalPx:i.originalPx});n=e.spacingTokenMods.map((l,a)=>a===r?s:l)}else n=[...e.spacingTokenMods,t];return m(f({},o),{spacingTokenMods:n})}function vc(e,t){let o=Zt(e),r=e.spacingTokenMods.findIndex(a=>a.tokenPath===t.tokenPath),n=r>=0?e.spacingTokenMods[r].originalValue:t.originalValue,i=r>=0?e.spacingTokenMods[r].originalPx:parseFloat(t.originalValue)||0,s={tokenPath:t.tokenPath,originalValue:n,currentValue:"__deleted__",targets:r>=0?e.spacingTokenMods[r].targets:[],originalPx:i,currentPx:0},l;return r>=0?l=e.spacingTokenMods.map((a,c)=>c===r?s:a):l=[...e.spacingTokenMods,s],m(f({},o),{spacingTokenMods:l})}var Sc={SET_ANNOTATING:Fa,SET_TOOL:Na,SET_COLOR:_a,SET_STROKE_WIDTH:za,START_PATH:$a,CONTINUE_PATH:Wa,CANCEL_PATH:Ya,FINISH_PATH:ja,ADD_TEXT:Ga,UPDATE_TEXT:Va,UPDATE_TEXT_SIZE:Ua,DELETE_ANNOTATION:Ja,MOVE_ANNOTATION:Xa,RESIZE_ANNOTATION:Ka,PASTE_ANNOTATIONS:Za,RESTORE_ANNOTATIONS:qa,UNDO:Qa,REDO:ec,SELECT_ANNOTATION:tc,UPDATE_ANNOTATION_COLOR:nc,MARK_CAPTURED:oc,CLEAR:rc,SELECT_ELEMENT:ic,MODIFY_STYLE:sc,MODIFY_STYLES_BATCH:lc,CLEAR_STYLE:ac,CLEAR_ALL_STYLES:cc,RESTORE_STYLE_MODIFICATIONS:dc,UPDATE_LINKED_POSITIONS:uc,CLEANUP_ORPHANED:hc,SET_ANNOTATION_STATUS:pc,SET_ANNOTATION_THREAD:fc,SET_ANNOTATION_QUESTION:gc,APPLY_RESOLUTIONS:mc,ADD_SPACING_TOKEN_CHANGE:yc,RESTORE_SPACING_TOKEN_CHANGES:bc,MODIFY_SPACING_TOKEN:xc,DELETE_SPACING_TOKEN:vc};function wc(e,t){let o=Sc[t.type];return o?o(e,t.payload):e}function Hs(){let[e,t]=Da(wc,Ha);return Oa(()=>{let o=r=>{(r.metaKey||r.ctrlKey)&&r.key==="z"&&(r.preventDefault(),r.shiftKey?t({type:"REDO"}):t({type:"UNDO"}))};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[]),[e,t]}import{domToCanvas as Ec}from"modern-screenshot";function Or(e){let t=document.createElement("canvas").getContext("2d");return t?(t.fillStyle=e,t.fillStyle):"#888888"}function Dr(e,t=[],o,r){let n=new Map,i=[];for(let l of e)if(l.groupId){let a=n.get(l.groupId)||[];a.push(l),n.set(l.groupId,a)}else i.push(l);let s=[];for(let[l,a]of n){let c=a.find(u=>u.type!=="text"),d=a.find(u=>u.type==="text");if(c){let u=c.linkedSelector||(d==null?void 0:d.linkedSelector),p=(d==null?void 0:d.imageCount)||c.imageCount;s.push(f(m(f({id:c.id,type:c.type,instruction:d==null?void 0:d.text},u?{linkedSelector:u}:{}),{elements:c.elements||[]}),p?{imageCount:p}:{}))}}for(let l of i)s.push(f(m(f({id:l.id,type:l.type,instruction:l.type==="text"?l.text:void 0},l.linkedSelector?{linkedSelector:l.linkedSelector}:{}),{elements:l.elements||[]}),l.imageCount?{imageCount:l.imageCount}:{}));return f(f({timestamp:new Date().toISOString(),url:window.location.href,viewport:{width:window.innerWidth,height:window.innerHeight},scrollPosition:{x:window.scrollX,y:window.scrollY},annotations:s,styleModifications:t},o?{inspectedElement:o}:{}),r&&r.length>0?{spacingTokenChanges:r}:{})}function kc(e){if(!e.points||e.points.length===0)return null;let t=e.points.map(r=>r.x),o=e.points.map(r=>r.y);return{minX:Math.min(...t),minY:Math.min(...o),maxX:Math.max(...t),maxY:Math.max(...o)}}function Cc(e,t){if(e.length===0)return[];let o=e.map(d=>({annotation:d,bounds:kc(d)})).filter(d=>d.bounds!==null);if(o.length===0)return[];o.sort((d,u)=>d.bounds.minY-u.bounds.minY);let r=Math.min(...o.map(d=>d.bounds.minY)),n=Math.max(...o.map(d=>d.bounds.maxY));if(n-r<=t){let d=(r+n)/2,u=Math.max(0,d-t/2);return[{top:u,bottom:u+t,annotations:e}]}let i=[],s=50,l=Math.max(0,r-s),a=[],c=l;for(let{annotation:d,bounds:u}of o){let p=u.maxY+s;if(p-l<=t)a.push(d),c=Math.max(c,p);else{if(a.length>0){let g=(l+c)/2,S=Math.max(0,g-t/2);i.push({top:S,bottom:S+t,annotations:a})}l=Math.max(0,u.minY-s),a=[d],c=u.maxY+s}}if(a.length>0){let d=(l+c)/2,u=Math.max(0,d-t/2);i.push({top:u,bottom:u+t,annotations:a})}return i}function Mc(e,t,o,r){e.save(),e.scale(r,r);for(let n of t){let i=n.points.map(s=>({x:s.x,y:s.y-o}));switch(e.strokeStyle=n.color,e.fillStyle=n.color,e.lineWidth=n.strokeWidth,e.lineCap="round",e.lineJoin="round",n.type){case"freehand":if(i.length<2)break;e.beginPath(),e.moveTo(i[0].x,i[0].y);for(let s=1;s<i.length;s++)e.lineTo(i[s].x,i[s].y);e.stroke();break;case"line":if(i.length<2)break;e.beginPath(),e.moveTo(i[0].x,i[0].y),e.lineTo(i[i.length-1].x,i[i.length-1].y),e.stroke();break;case"rectangle":{if(i.length<2)break;let s=i[0],l=i[i.length-1],a=Math.min(s.x,l.x),c=Math.min(s.y,l.y),d=Math.abs(l.x-s.x),u=Math.abs(l.y-s.y);e.strokeRect(a,c,d,u);break}case"circle":{if(i.length<2)break;let s=i[0],l=i[i.length-1],a=(s.x+l.x)/2,c=(s.y+l.y)/2,d=Math.abs(l.x-s.x)/2,u=Math.abs(l.y-s.y)/2;e.beginPath(),e.ellipse(a,c,d,u,0,0,Math.PI*2),e.stroke();break}case"text":{if(!n.text||i.length<1)break;let s=i[0],l=n.fontSize||16;e.font=`${l}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,e.fillStyle=n.color;let c=(n.imageCount&&n.imageCount>0?`[${n.imageCount} image${n.imageCount>1?"s":""}] ${n.text}`:n.text).split(`
|
|
3
|
+
`),d=l*1.2,u=4,p=0;for(let g of c)p=Math.max(p,e.measureText(g).width);e.fillRect(s.x-u,s.y-u,p+u*2,c.length*d+u*2),e.fillStyle="#ffffff",c.forEach((g,S)=>{e.fillText(g,s.x,s.y+l+S*d)});break}}}e.restore()}async function Hr(e,t,o=[]){try{let r=window.devicePixelRatio||1,n=window.innerWidth,i=window.innerHeight,s=o.filter(c=>{var d;return((d=c.status)!=null?d:"pending")==="pending"});console.log("[Screenshot] Starting capture with",s.length,"active annotations (filtered",o.length-s.length,"captured)");let l=Cc(s,i);if(l.length===0){let c=await Fs(e,[],window.scrollY,n,i,r);return c?[c]:[]}let a=[];for(let c=0;c<l.length;c++){let d=l[c],u=await Fs(e,d.annotations,d.top,n,i,r);u?a.push(u):console.warn(`[Screenshot] Region ${c+1} failed to capture`)}return console.log("[Screenshot] Capture complete"),a}catch(r){return console.error("[Screenshot] Capture failed:",r),[]}}async function Fs(e,t,o,r,n,i){try{let s=await Ec(e,{filter:c=>!(c instanceof HTMLElement&&(c.id==="devtools-canvas"||c.id==="devtools-toolbar"||c.id==="devtools-scrim"||c.dataset.devtools!==void 0)),scale:i,backgroundColor:"#ffffff",width:r,height:n,style:{transform:`translate(${-window.scrollX}px, ${-o}px)`}}),l=document.createElement("canvas");l.width=r*i,l.height=n*i;let a=l.getContext("2d");return a?(a.drawImage(s,0,0,r*i,n*i,0,0,r*i,n*i),Mc(a,t,o,i),new Promise(c=>{l.toBlob(d=>c(d),"image/png")})):null}catch(s){return console.error("Region capture failed:",s),null}}async function Fr(e){if(e.length===0)return null;if(e.length===1)return e[0];let t=await Promise.all(e.map(l=>new Promise((a,c)=>{let d=new Image;d.onload=()=>a(d),d.onerror=c,d.src=URL.createObjectURL(l)}))),o=t[0].width,r=t.reduce((l,a)=>l+a.height,0),n=document.createElement("canvas");n.width=o,n.height=r;let i=n.getContext("2d");if(!i)return null;let s=0;for(let l of t)i.drawImage(l,0,s),s+=l.height,URL.revokeObjectURL(l.src);return new Promise(l=>{n.toBlob(a=>l(a),"image/png")})}async function Ns(e,t,o){try{let r=Array.isArray(e)?e:[e];if(r.length===0)return!1;let n=await Fr(r);if(!n)return!1;let i={"image/png":n},s=t&&t.length>0,l=o&&o.length>0;if(s||l){let a=t?t.filter(c=>{var d;return((d=c.status)!=null?d:"pending")==="pending"}):[];if(a.length>0||l){let c=Dr(a,o||[]),d=new Blob([JSON.stringify(c,null,2)],{type:"text/plain"});i["text/plain"]=d}}return await navigator.clipboard.write([new ClipboardItem(i)]),!0}catch(r){return console.warn("Clipboard write failed:",r),!1}}import{useCallback as At,useEffect as Vt,useMemo as Li,useRef as Ct,useState as it}from"react";import{useCallback as uo,useRef as Lc}from"react";function Nr(e,t,o,r){if(t.length<2)return;let n=t[0],i=t[t.length-1];if(!n||!i)return;let s=(n.x+i.x)/2,l=(n.y+i.y)/2,a=Math.abs(i.x-n.x)/2,c=Math.abs(i.y-n.y)/2;e.beginPath(),e.strokeStyle=o,e.lineWidth=r,e.ellipse(s,l,a,c,0,0,Math.PI*2),e.stroke()}function _r(e,t,o,r){if(t.length<2)return;let n=t[0],i=t[t.length-1];if(!(!n||!i)){e.beginPath(),e.strokeStyle=o,e.lineWidth=r,e.lineCap="round",e.lineJoin="round",e.moveTo(n.x,n.y);for(let s=1;s<t.length-1;s++){let l=t[s],a=t[s+1];if(!l||!a)continue;let c=(l.x+a.x)/2,d=(l.y+a.y)/2;e.quadraticCurveTo(l.x,l.y,c,d)}e.lineTo(i.x,i.y),e.stroke()}}function zr(e,t,o,r){if(t.length<2)return;let n=t[0],i=t[t.length-1];!n||!i||(e.beginPath(),e.strokeStyle=o,e.lineWidth=r,e.lineCap="round",e.moveTo(n.x,n.y),e.lineTo(i.x,i.y),e.stroke())}function $r(e,t,o,r){if(t.length<2)return;let n=t[0],i=t[t.length-1];if(!n||!i)return;let s=Math.min(n.x,i.x),l=Math.min(n.y,i.y),a=Math.abs(i.x-n.x),c=Math.abs(i.y-n.y);e.beginPath(),e.strokeStyle=o,e.lineWidth=r,e.lineCap="round",e.lineJoin="round",e.strokeRect(s,l,a,c)}var $t='"JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace';function Tc(e,t,o){if(!t||e.measureText(t).width<=o)return[t];let r=t.split(/\s+/),n=[],i="";for(let s of r){let l=i?i+" "+s:s;i&&e.measureText(l).width>o?(n.push(i),i=s):i=l}return i&&n.push(i),n.length>0?n:[t]}function co(e){let t=window.innerWidth-e-16;if(t<400)return Math.max(60,t)}function jn(e,t,o){let r=[];for(let n of t)r.push(...Tc(e,n,o));return r}function _s(e,t,o,r,n=12,i,s){if(!o)return;let l=n*1.4,a=o.split(`
|
|
4
|
+
`),c=i!==void 0?[i+". "+(a[0]||""),...a.slice(1)]:a;e.font=`${n}px ${$t}`,e.textBaseline="middle";let d=s!==void 0?Math.min(400,Math.max(60,window.innerWidth-s-16)):400,u=jn(e,c,d),p=Math.min(d,Math.max(...u.map(w=>e.measureText(w).width))),g=u.length*l,S=c.length*l,v=g-S,y=t.y-v;e.fillStyle=r,e.fillRect(t.x-4,y-4,p+8,g+8),e.fillStyle="#ffffff",u.forEach((w,O)=>{e.fillText(w,t.x,y+O*l+l/2)})}var zs=11,Wr=4,Ic=`600 ${zs}px system-ui, -apple-system, sans-serif`;function Yr(e,t,o){return e.map(r=>({x:r.x-t,y:r.y-o}))}function Rc(e,t,o,r,n,i){let s=String(r);e.font=Ic;let a=e.measureText(s).width+Wr*2,c=zs+Wr*2,d=t-a/2,u=o+i/2+2;e.fillStyle=n,e.fillRect(d,u,a,c),e.fillStyle="#ffffff",e.textBaseline="middle",e.fillText(s,d+Wr,u+c/2)}function Ac(e,t){if(e.points.length<2&&e.type!=="text")return null;switch(e.type){case"rectangle":case"freehand":{let o,r;if(e.type==="freehand")o=Math.min(...e.points.map(n=>n.x)),r=Math.max(...e.points.map(n=>n.y));else{let n=e.points[0],i=e.points[e.points.length-1];o=Math.min(n.x,i.x),r=Math.max(n.y,i.y)}return{x:o,y:r}}case"circle":{let o=e.points[0],r=e.points[e.points.length-1],n=Math.min(o.x,r.x),i=(Math.min(o.y,r.y)+Math.max(o.y,r.y))/2;return{x:n,y:i}}case"line":{let o=e.points[0],r=e.points[e.points.length-1],n=o.y>r.y?o:r;return{x:n.x,y:n.y}}default:return null}}function $s(){let e=Lc(null),t=uo(()=>{let l=e.current;if(!l)return;let a=l.getContext("2d");a&&a.clearRect(0,0,l.width,l.height)},[]),o=uo((l,a,c)=>{var S;let d=e.current;if(!d)return;let u=d.getContext("2d");if(!u)return;let g=((S=l.status)!=null?S:l.captured?"in_flight":"pending")==="pending"||c?l.color:"#999999";switch(l.type){case"freehand":_r(u,l.points,g,l.strokeWidth);break;case"line":zr(u,l.points,g,l.strokeWidth);break;case"rectangle":$r(u,l.points,g,l.strokeWidth);break;case"circle":Nr(u,l.points,g,l.strokeWidth);break;case"text":l.text&&l.points[0]&&_s(u,l.points[0],l.text,g,l.fontSize,a,l.points[0].x);break}},[]),r=uo((l,a,c,d)=>{let u=e.current;if(!u||l.length<2)return;let p=u.getContext("2d");if(p)switch(a){case"freehand":_r(p,l,c,d);break;case"line":zr(p,l,c,d);break;case"rectangle":$r(p,l,c,d);break;case"circle":Nr(p,l,c,d);break}},[]),n=uo((l,a)=>{let c=e.current;if(!c||l.points.length<2)return;let d=c.getContext("2d");if(d){if(d.fillStyle="#ffffff",d.strokeStyle=l.color,d.lineWidth=1.5,l.type==="line"){let u=l.points[0],p=l.points[l.points.length-1];[u,p].forEach(g=>{d.beginPath(),d.arc(g.x,g.y,a/2,0,Math.PI*2),d.fill(),d.stroke()});return}if(l.type==="circle"){let u=l.points[0],p=l.points[l.points.length-1],g=Math.min(u.x,p.x),S=Math.max(u.x,p.x),v=Math.min(u.y,p.y),y=Math.max(u.y,p.y),w=(g+S)/2,O=(v+y)/2;[{x:w,y:v},{x:w,y},{x:g,y:O},{x:S,y:O}].forEach(C=>{d.beginPath(),d.rect(C.x-a/2,C.y-a/2,a,a),d.fill(),d.stroke()});return}if(l.type==="rectangle"||l.type==="freehand"){let u,p,g,S;if(l.type==="freehand")u=Math.min(...l.points.map(y=>y.x)),p=Math.max(...l.points.map(y=>y.x)),g=Math.min(...l.points.map(y=>y.y)),S=Math.max(...l.points.map(y=>y.y));else{let y=l.points[0],w=l.points[l.points.length-1];u=Math.min(y.x,w.x),p=Math.max(y.x,w.x),g=Math.min(y.y,w.y),S=Math.max(y.y,w.y)}[{x:u,y:g},{x:p,y:g},{x:u,y:S},{x:p,y:S}].forEach(y=>{d.beginPath(),d.rect(y.x-a/2,y.y-a/2,a,a),d.fill(),d.stroke()})}}},[]),i=uo((l,a,c,d,u,p,g,S=0,v=0,y,w)=>{var O;if(t(),l.forEach(A=>{var $;let C=m(f({},A),{points:Yr(A.points,S,v)}),E=y==null?void 0:y.get(A.id),I=($=w==null?void 0:w.has(A.id))!=null?$:!1;o(C,E,I)}),a.length>0){let A=Yr(a,S,v);r(A,c,d,u)}if(p&&p.length>0&&g){let A=e.current,C=A==null?void 0:A.getContext("2d");for(let E of p){let I=l.find($=>$.id===E);if(I){let $=m(f({},I),{points:Yr(I.points,S,v)});if(n($,g),C&&I.type!=="text"&&y&&!(I.groupId&&l.some(G=>G.groupId===I.groupId&&G.type==="text"))){let G=y.get(I.id);if(G!==void 0){let M=Ac($,g);if(M){let X=((O=I.status)!=null?O:I.captured?"in_flight":"pending")==="pending"?I.color:"#999999";Rc(C,M.x,M.y,G,X,g)}}}}}}},[t,o,r,n]),s=uo(()=>{let l=e.current;if(!l)return;let a=window.devicePixelRatio||1;l.width=window.innerWidth*a,l.height=window.innerHeight*a;let c=l.getContext("2d");c&&c.scale(a,a)},[]);return{canvasRef:e,clearCanvas:t,drawAnnotation:o,drawCurrentPath:r,redrawAll:i,resizeCanvas:s}}import{useEffect as Pc,useRef as Bc}from"react";function Ws(){let e=Bc({shift:!1,cmd:!1});return Pc(()=>{let t=n=>{n.key==="Shift"&&(e.current.shift=!0),(n.key==="Meta"||n.key==="Control")&&(e.current.cmd=!0)},o=n=>{n.key==="Shift"&&(e.current.shift=!1),(n.key==="Meta"||n.key==="Control")&&(e.current.cmd=!1)},r=()=>{e.current={shift:!1,cmd:!1}};return window.addEventListener("keydown",t,!0),window.addEventListener("keyup",o,!0),window.addEventListener("blur",r),()=>{window.removeEventListener("keydown",t,!0),window.removeEventListener("keyup",o,!0),window.removeEventListener("blur",r)}},[]),e}import{useEffect as Oc}from"react";function Ys(e,t,o,r,n){Oc(()=>{let i=s=>{if(e){if(e.linkedSelector)return;s.preventDefault(),s.stopPropagation();let a=s.deltaY>0?-2:2;t(c=>c?m(f({},c),{fontSize:Math.max(12,Math.min(72,c.fontSize+a))}):null);return}if(!o)return;s.preventDefault();let l=r.find(a=>a.id===o);if(l&&l.type==="text"&&!l.linkedSelector){let a=l.fontSize||12,c=s.deltaY>0?-2:2;n({type:"UPDATE_TEXT_SIZE",payload:{id:o,fontSize:a+c}})}};return window.addEventListener("wheel",i,{passive:!1}),()=>{window.removeEventListener("wheel",i)}},[o,e,r,n,t])}import{useCallback as ol,useEffect as pr,useRef as rl,useState as $o}from"react";function or(e){let t=Object.keys(e).find(n=>n.startsWith("__reactFiber$")||n.startsWith("__reactInternalInstance$"));if(!t)return null;let o=e[t],r=[];for(;o;){let n=o.type,i=(n==null?void 0:n.displayName)||(n==null?void 0:n.name);i&&typeof i=="string"&&/^[A-Z]/.test(i)&&!i.startsWith("_")&&i!=="Fragment"&&r.unshift(i),o=o.return}return r.length>0?{name:r[r.length-1],path:r}:null}function jr(e){let t=Object.keys(e).find(n=>n.startsWith("__reactFiber$")||n.startsWith("__reactInternalInstance$"));if(!t)return[];let o=e[t],r=[];for(;o;){let n=o.type,i=typeof n=="function"||typeof n=="object"?(n==null?void 0:n.displayName)||(n==null?void 0:n.name):null;i&&typeof i=="string"&&/^[A-Z]/.test(i)&&!i.startsWith("_")&&i!=="Fragment"&&r.push({name:i,fiber:o}),o=o.return}return r.reverse(),r}function rr(e){let t=e,o=new Set;for(;t&&!o.has(t);){if(o.add(t),t.stateNode instanceof Element)return t.stateNode;t.child?t=t.child:t=null}return null}function js(e){if(e.id)return`#${e.id}`;let t=e.tagName.toLowerCase(),o=Array.from(e.classList).slice(0,3).join(".");return o?`${t}.${o}`:t}function sn(e){if(e.id&&!e.id.startsWith("radix-")&&!e.id.startsWith(":"))return`#${CSS.escape(e.id)}`;let t=[],o=e;for(;o&&o!==document.documentElement;){let r=o.tagName.toLowerCase();if(o.id&&!o.id.startsWith("radix-")&&!o.id.startsWith(":")){t.unshift(`#${CSS.escape(o.id)}`);break}let n=Array.from(o.classList).filter(s=>!s.startsWith("_")&&s.length<30).slice(0,2);n.length>0&&(r+="."+n.map(s=>CSS.escape(s)).join("."));let i=o.parentElement;if(i){let s=Array.from(i.children).filter(l=>l.tagName===o.tagName);if(s.length>1){let l=s.indexOf(o)+1;r+=`:nth-of-type(${l})`}}t.unshift(r),o=i}return t.join(" > ")}function Jt(e){try{return document.querySelector(e)}catch(t){return null}}function ir(e,t=0){var a;let o=jr(e);if(o.length===0)return null;let r=o.map(c=>c.name),n=o.length-1,i=Math.max(0,Math.min(o.length-1,n-t)),s=o[i],l=(a=rr(s.fiber))!=null?a:e;return{name:s.name,path:r,depthIndex:i,rootElement:l}}function Gs(e,t){var i,s;let o=jr(e),r=t.toLowerCase(),n=-1;for(let l=o.length-1;l>=0;l--){let a=o[l].name;if(a===t){let c=(i=rr(o[l].fiber))!=null?i:e;return{name:t,path:o.map(d=>d.name),depthIndex:l,rootElement:c}}if(n===-1){let c=a.toLowerCase();(c.length>=4&&r.includes(c)||r.length>=4&&c.includes(r))&&(n=l)}}if(n>=0){let l=(s=rr(o[n].fiber))!=null?s:e;return{name:t,path:o.map(a=>a.name),depthIndex:n,rootElement:l}}return null}function po(e){let t=fo(),o=[],r=new Set,n=t.currentNode;for(;n=t.nextNode();){let i=Gs(n,e);i&&!r.has(i.rootElement)&&(r.add(i.rootElement),o.push(i))}return o}function Gr(e){let t=new Map;if(e.size===0)return t;let o=new Set(e),r=fo(),n=new Set,i=r.currentNode;for(;(i=r.nextNode())&&o.size>0;)for(let s of o){let l=Gs(i,s);if(!l||n.has(l.rootElement))continue;n.add(l.rootElement);let a=l.rootElement.getBoundingClientRect();t.set(s,a.top+window.scrollY),o.delete(s);break}for(let s of o)t.set(s,1/0);return t}function fo(){return document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return e.closest("#devtools-toolbar, #devtools-canvas, #devtools-scrim, [data-popmelt-panel]")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function qt(e){let t={selector:js(e),tagName:e.tagName.toLowerCase()};e.id&&(t.id=e.id),e.classList.length>0&&(t.className=Array.from(e.classList).join(" "));let o=Vs(e);o&&o.length>0&&o.length<200&&(t.textContent=o);let r={};for(let s of e.attributes)s.name.startsWith("data-")&&(r[s.name]=s.value);Object.keys(r).length>0&&(t.dataAttributes=r);let n=or(e);n&&(t.reactComponent=n.name);let i=Dc(e);return i&&(t.context=i),t}function Vs(e){let t="";for(let o of e.childNodes)o.nodeType===Node.TEXT_NODE&&(t+=o.textContent||"");return t.trim()}function Gn(e,t){let o=document.elementsFromPoint(e,t);for(let r of o)if(r instanceof HTMLElement&&!(r.id==="devtools-canvas"||r.id==="devtools-toolbar"||r.id==="devtools-scrim")&&!r.closest("#devtools-toolbar")&&!(r.dataset.devtools||r.closest("[data-devtools]"))&&!["html","body"].includes(r.tagName.toLowerCase()))return r;return null}function Dc(e){let t=e.parentElement,o=["section","article","nav","aside","header","footer","main"];for(;t&&t!==document.body;){let r=t.tagName.toLowerCase();if(o.includes(r)&&t.id)return`${r}#${t.id}`;if(t.id&&!t.id.startsWith("radix-")&&!t.id.startsWith(":"))return`${r}#${t.id}`;t=t.parentElement}return null}function Us(e){let t=new Set,o=[],r=window.scrollX,n=window.scrollY,i=[{x:(e.minX+e.maxX)/2,y:(e.minY+e.maxY)/2},{x:e.minX,y:e.minY},{x:e.maxX,y:e.minY},{x:e.minX,y:e.maxY},{x:e.maxX,y:e.maxY}];for(let s of i){let l=s.x-r,a=s.y-n;if(l<0||a<0||l>window.innerWidth||a>window.innerHeight)continue;let c=Gn(l,a);c&&!t.has(c)&&(t.add(c),o.push(qt(c)))}return o.slice(0,3)}function Vr(e){if(e.length===0)return[];let t=e.map(r=>r.x),o=e.map(r=>r.y);return Us({minX:Math.min(...t),minY:Math.min(...o),maxX:Math.max(...t),maxY:Math.max(...o)})}function Rt(e,t){return e.style.getPropertyValue(t)!==""}function Hc(e,t=30){if(e<=0)return[];let o=[],r=fo(),n=.5,i=r.currentNode;for(;(i=r.nextNode())&&o.length<t;){let s=i,l=s.getBoundingClientRect();if(l.bottom<-50||l.top>window.innerHeight+50||l.right<-50||l.left>window.innerWidth+50||l.width<1||l.height<1)continue;let a=getComputedStyle(s);!Rt(s,"padding-top")&&Math.abs((parseFloat(a.paddingTop)||0)-e)<n&&o.push({element:s,property:"padding-top"}),!Rt(s,"padding-bottom")&&Math.abs((parseFloat(a.paddingBottom)||0)-e)<n&&o.length<t&&o.push({element:s,property:"padding-bottom"}),!Rt(s,"padding-left")&&Math.abs((parseFloat(a.paddingLeft)||0)-e)<n&&o.length<t&&o.push({element:s,property:"padding-left"}),!Rt(s,"padding-right")&&Math.abs((parseFloat(a.paddingRight)||0)-e)<n&&o.length<t&&o.push({element:s,property:"padding-right"}),!Rt(s,"margin-top")&&Math.abs((parseFloat(a.marginTop)||0)-e)<n&&o.length<t&&o.push({element:s,property:"margin-top"}),!Rt(s,"margin-bottom")&&Math.abs((parseFloat(a.marginBottom)||0)-e)<n&&o.length<t&&o.push({element:s,property:"margin-bottom"}),!Rt(s,"margin-left")&&Math.abs((parseFloat(a.marginLeft)||0)-e)<n&&o.length<t&&o.push({element:s,property:"margin-left"}),!Rt(s,"margin-right")&&Math.abs((parseFloat(a.marginRight)||0)-e)<n&&o.length<t&&o.push({element:s,property:"margin-right"});let c=a.display;if((c.includes("flex")||c.includes("grid"))&&o.length<t){let d=Rt(s,"gap"),u=parseFloat(a.gap)||0,p=parseFloat(a.rowGap)||0,g=parseFloat(a.columnGap)||0;!d&&Math.abs(u-e)<n?o.push({element:s,property:"gap"}):!Rt(s,"row-gap")&&Math.abs(p-e)<n?o.push({element:s,property:"row-gap"}):!Rt(s,"column-gap")&&Math.abs(g-e)<n&&o.push({element:s,property:"column-gap"})}}return o}function Ur(e,t=30){if(e<=0)return[];let o=[],r=fo(),n=.5,i=r.currentNode;for(;(i=r.nextNode())&&o.length<t;){let s=i,l=s.getBoundingClientRect();if(l.bottom<-50||l.top>window.innerHeight+50||l.right<-50||l.left>window.innerWidth+50||l.width<1||l.height<1)continue;let a=getComputedStyle(s),c=parseFloat(a.borderTopWidth)||0,d=parseFloat(a.borderRightWidth)||0,u=parseFloat(a.borderBottomWidth)||0,p=parseFloat(a.borderLeftWidth)||0,g=s.clientWidth,S=s.clientHeight,v=parseFloat(a.paddingTop)||0;!Rt(s,"padding-top")&&Math.abs(v-e)<n&&o.push({x:l.left+p,y:l.top+c,width:g,height:e,direction:"vertical",property:"padding-top"});let y=parseFloat(a.paddingBottom)||0;!Rt(s,"padding-bottom")&&Math.abs(y-e)<n&&o.length<t&&o.push({x:l.left+p,y:l.top+c+S-e,width:g,height:e,direction:"vertical",property:"padding-bottom"});let w=parseFloat(a.paddingLeft)||0;!Rt(s,"padding-left")&&Math.abs(w-e)<n&&o.length<t&&o.push({x:l.left+p,y:l.top+c,width:e,height:S,direction:"horizontal",property:"padding-left"});let O=parseFloat(a.paddingRight)||0;!Rt(s,"padding-right")&&Math.abs(O-e)<n&&o.length<t&&o.push({x:l.left+p+g-e,y:l.top+c,width:e,height:S,direction:"horizontal",property:"padding-right"});let A=parseFloat(a.marginTop)||0;!Rt(s,"margin-top")&&Math.abs(A-e)<n&&o.length<t&&o.push({x:l.left,y:l.top-e,width:l.width,height:e,direction:"vertical",property:"margin-top"});let C=parseFloat(a.marginBottom)||0;!Rt(s,"margin-bottom")&&Math.abs(C-e)<n&&o.length<t&&o.push({x:l.left,y:l.bottom,width:l.width,height:e,direction:"vertical",property:"margin-bottom"});let E=parseFloat(a.marginLeft)||0;!Rt(s,"margin-left")&&Math.abs(E-e)<n&&o.length<t&&o.push({x:l.left-e,y:l.top,width:e,height:l.height,direction:"horizontal",property:"margin-left"});let I=parseFloat(a.marginRight)||0;!Rt(s,"margin-right")&&Math.abs(I-e)<n&&o.length<t&&o.push({x:l.right,y:l.top,width:e,height:l.height,direction:"horizontal",property:"margin-right"});let $=a.display;if(($.includes("flex")||$.includes("grid"))&&o.length<t&&!Rt(s,"gap")){let G=Array.from(s.children).filter(M=>{let D=getComputedStyle(M);return D.display!=="none"&&D.position!=="absolute"&&D.position!=="fixed"});if(G.length>=2)for(let M=0;M<G.length-1&&o.length<t;M++){let D=G[M].getBoundingClientRect(),X=G[M+1].getBoundingClientRect(),ee=X.top-D.bottom;Math.abs(ee-e)<n&&ee>.5&&o.push({x:Math.min(D.left,X.left),y:D.bottom,width:Math.max(D.right,X.right)-Math.min(D.left,X.left),height:ee,direction:"vertical",property:"gap"});let he=X.left-D.right;Math.abs(he-e)<n&&he>.5&&o.push({x:D.right,y:Math.min(D.top,X.top),width:he,height:Math.max(D.bottom,X.bottom)-Math.min(D.top,X.top),direction:"horizontal",property:"gap"})}}}return o}function sr(e){return typeof e=="string"?{value:e}:e}var Xs={gap:["gap","row-gap","column-gap"],padding:["padding-top","padding-bottom","padding-left","padding-right"],margin:["margin-top","margin-bottom","margin-left","margin-right"]};function Js(e,t){let o=Xs[t];return o?o.includes(e):!1}function Fc(e,t){let o=e.split(/\s+/);for(let r of o){if(r===t)return!0;let n=r.lastIndexOf(":");if(n>=0&&r.slice(n+1)===t)return!0}return!1}function Nc(e){var l,a;let t=e.lastIndexOf(":"),o=t>=0?e.slice(t+1):e,r=o.indexOf("-");if(r<0)return null;let n=o.slice(0,r),i={gap:"gap","gap-x":"column-gap","gap-y":"row-gap",p:"padding",pt:"padding-top",pb:"padding-bottom",pl:"padding-left",pr:"padding-right",px:"padding-left",py:"padding-top",m:"margin",mt:"margin-top",mb:"margin-bottom",ml:"margin-left",mr:"margin-right",mx:"margin-left",my:"margin-top"},s=o.slice(0,o.indexOf("-",r+1)>0?o.indexOf("-",r+1):r);return(a=(l=i[s])!=null?l:i[n])!=null?a:null}function Jr(e,t=30){let o=parseFloat(e.value);if(isNaN(o)||o<=0)return[];if(e.bindings&&e.bindings.length>0){let n=[],i=fo(),s=i.currentNode;for(;(s=i.nextNode())&&n.length<t;){let l=s,a=l.getBoundingClientRect();if(a.bottom<-50||a.top>window.innerHeight+50||a.right<-50||a.left>window.innerWidth+50||a.width<1||a.height<1)continue;let c=l.className;if(typeof c=="string")for(let d of e.bindings){if(!Fc(c,d))continue;let u=Nc(d);if(u&&!(e.property&&!Js(u,e.property))){n.push({element:l,property:u});break}}}return n}let r=Hc(o,t*2);return e.property?r.filter(n=>Js(n.property,e.property)).slice(0,t):r.slice(0,t)}function Xr(e,t=30){let o=Jr(e,t),r=[];for(let n of o){let i=n.element,s=i.getBoundingClientRect(),l=getComputedStyle(i),a=parseFloat(l.borderTopWidth)||0,c=parseFloat(l.borderRightWidth)||0,d=parseFloat(l.borderLeftWidth)||0,u=i.clientWidth,p=i.clientHeight;switch(n.property){case"padding-top":{let g=parseFloat(l.paddingTop)||0;r.push({x:s.left+d,y:s.top+a,width:u,height:g,direction:"vertical",property:n.property});break}case"padding-bottom":{let g=parseFloat(l.paddingBottom)||0;r.push({x:s.left+d,y:s.top+a+p-g,width:u,height:g,direction:"vertical",property:n.property});break}case"padding-left":{let g=parseFloat(l.paddingLeft)||0;r.push({x:s.left+d,y:s.top+a,width:g,height:p,direction:"horizontal",property:n.property});break}case"padding-right":{let g=parseFloat(l.paddingRight)||0;r.push({x:s.left+d+u-g,y:s.top+a,width:g,height:p,direction:"horizontal",property:n.property});break}case"margin-top":{let g=parseFloat(l.marginTop)||0;r.push({x:s.left,y:s.top-g,width:s.width,height:g,direction:"vertical",property:n.property});break}case"margin-bottom":{let g=parseFloat(l.marginBottom)||0;r.push({x:s.left,y:s.bottom,width:s.width,height:g,direction:"vertical",property:n.property});break}case"margin-left":{let g=parseFloat(l.marginLeft)||0;r.push({x:s.left-g,y:s.top,width:g,height:s.height,direction:"horizontal",property:n.property});break}case"margin-right":{let g=parseFloat(l.marginRight)||0;r.push({x:s.right,y:s.top,width:g,height:s.height,direction:"horizontal",property:n.property});break}case"gap":case"row-gap":case"column-gap":{let g=Array.from(i.children).filter(S=>{let v=getComputedStyle(S);return v.display!=="none"&&v.position!=="absolute"&&v.position!=="fixed"});for(let S=0;S<g.length-1&&r.length<t;S++){let v=g[S].getBoundingClientRect(),y=g[S+1].getBoundingClientRect(),w=y.top-v.bottom;w>.5&&r.push({x:Math.min(v.left,y.left),y:v.bottom,width:Math.max(v.right,y.right)-Math.min(v.left,y.left),height:w,direction:"vertical",property:"gap"});let O=y.left-v.right;O>.5&&r.push({x:v.right,y:Math.min(v.top,y.top),width:O,height:Math.max(v.bottom,y.bottom)-Math.min(v.top,y.top),direction:"horizontal",property:"gap"})}break}}}return r}function Ks(e,t){let o=new Set,r=Do(t);for(let n of e){let i=qs[n.property];if(!i)continue;let s=n.element.className;if(typeof s=="string")for(let l of i){let a=`${l}-${r}`;for(let c of s.split(/\s+/)){let d=c.lastIndexOf(":"),u=d>=0?c.slice(d+1):c;if(u===a){o.add(u);break}}}}return[...o]}function Zs(e){let t=new Set;for(let o of e)for(let[r,n]of Object.entries(Xs))if(n.includes(o.property)){t.add(r);break}if(t.size===1)return[...t][0]}function Kr(e,t,o){if(t===o)return e;let r=Do(t),n=Do(o);return e.map(i=>{let s=i.lastIndexOf("-");if(s<0)return i;let l=i.slice(0,s),a=i.slice(s+1);return a===r||a===`[${t}px]`?`${l}-${n}`:i})}var _c={0:"0",1:"px",2:"0.5",4:"1",6:"1.5",8:"2",12:"3",16:"4",20:"5",24:"6",28:"7",32:"8",40:"10",48:"12",64:"16",80:"20",96:"24"};function Do(e){var t;return(t=_c[e])!=null?t:`[${e}px]`}var qs={"padding-top":["pt","py","p"],"padding-bottom":["pb","py","p"],"padding-left":["pl","px","p"],"padding-right":["pr","px","p"],"margin-top":["mt","my","m"],"margin-bottom":["mb","my","m"],"margin-left":["ml","mx","m"],"margin-right":["mr","mx","m"],gap:["gap"],"row-gap":["gap-y","gap"],"column-gap":["gap-x","gap"]};function zc(e,t,o,r){let n=qs[t];if(!n)return null;let i=Do(o);for(let s of n){let l=new RegExp("(?:^|\\s)((?:[\\w-]+:)*"+s+"-(?:"+$c(i)+"|\\["+o+"px\\]))(?:\\s|$)"),a=e.match(l);if(a!=null&&a[1]){let c=Do(r),d=a[1].lastIndexOf(":"),u=d>=0?a[1].slice(0,d+1):"";return{matched:a[1],suggested:`${u}${s}-${c}`}}}return null}function $c(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Qs(e,t,o){let r=new Set,n=[];for(let i of e){let s=sn(i.element),l=`${s}::${i.property}`;if(r.has(l))continue;r.add(l);let a=or(i.element),c=i.element.className||"",d=zc(c,i.property,t,o);n.push({selector:s,reactComponent:a==null?void 0:a.name,className:c,property:i.property,matchedClass:d==null?void 0:d.matched,suggestedClass:d==null?void 0:d.suggested})}return n}function Ho(e,t){return window.getComputedStyle(e).getPropertyValue(t)}function Zr(e,t){if(e instanceof HTMLElement){let r=e.style.getPropertyValue(t);if(r)return r}let o=Wc(e,t);return o&&o.includes("var(")?o:Ho(e,t)}function Wc(e,t){let o=t.replace(/-([a-z])/g,(r,n)=>n.toUpperCase());try{for(let r of document.styleSheets)try{let n=r.cssRules||r.rules;for(let i of n)if(i instanceof CSSStyleRule&&e.matches(i.selectorText)){let s=i.style.getPropertyValue(t);if(s&&s.includes("var("))return s;let l=i.style[o];if(l&&l.includes("var("))return l}}catch(n){}}catch(r){}return null}function lr(e,t){if(e instanceof HTMLElement){let r=e.style.getPropertyValue(t);if(r)return r}let o=t.replace(/-([a-z])/g,(r,n)=>n.toUpperCase());try{for(let r of document.styleSheets)try{let n=r.cssRules||r.rules;for(let i of n)if(i instanceof CSSStyleRule&&e.matches(i.selectorText)){let s=i.style.getPropertyValue(t);if(s)return s;let l=i.style[o];if(l)return l}}catch(n){}}catch(r){}return null}function ar(e){let t=window.getComputedStyle(e).display;return t==="flex"||t==="inline-flex"||t==="grid"||t==="inline-grid"}function Fo(e){let t=window.getComputedStyle(e);return{row:parseFloat(t.rowGap)||0,column:parseFloat(t.columnGap)||0}}function Yc(e){let t=[];for(let o of e){let r=t.find(n=>n.axis!==o.axis?!1:o.axis==="row"?Math.abs(n.y-o.y)<2&&Math.abs(n.h-o.h)<2:Math.abs(n.x-o.x)<2&&Math.abs(n.w-o.w)<2);if(r)if(o.axis==="row"){let n=Math.min(r.x,o.x),i=Math.max(r.x+r.w,o.x+o.w);r.x=n,r.w=i-n}else{let n=Math.min(r.y,o.y),i=Math.max(r.y+r.h,o.y+o.h);r.y=n,r.h=i-n}else t.push(f({},o))}return t}function Vn(e){let t=Array.from(e.children).filter(a=>{if(!(a instanceof HTMLElement))return!1;let c=window.getComputedStyle(a);return c.display!=="none"&&c.position!=="absolute"&&c.position!=="fixed"});if(t.length<2)return[];let o=[],r=e.getBoundingClientRect(),i=window.getComputedStyle(e).flexDirection,s=i==="column"||i==="column-reverse",l=6;for(let a=0;a<t.length-1;a++){let c=t[a].getBoundingClientRect(),d=t[a+1].getBoundingClientRect();if(d.left>c.right+.5&&o.push({axis:"column",x:c.right,y:r.top,w:d.left-c.right,h:r.height}),d.top>c.bottom+.5&&o.push({axis:"row",x:r.left,y:c.bottom,w:r.width,h:d.top-c.bottom}),!(d.left>c.right+.5)&&!(d.top>c.bottom+.5))if(s){let u=(c.bottom+d.top)/2;o.push({axis:"row",x:r.left,y:u-l/2,w:r.width,h:l})}else{let u=(c.right+d.left)/2;o.push({axis:"column",x:u-l/2,y:r.top,w:l,h:r.height})}}return Yc(o)}function qr(e,t){let o=window.getComputedStyle(e),r=o.display;if(r!=="flex"&&r!=="inline-flex")return!1;let n=o.justifyContent;if(n!=="space-between"&&n!=="space-around"&&n!=="space-evenly"&&n!=="stretch")return!1;let i=o.flexDirection;return!(t!==(i==="column"||i==="column-reverse"?"row":"column")||parseFloat(t==="row"?o.rowGap:o.columnGap)>0)}function go(e){let t=window.getComputedStyle(e);return{top:parseFloat(t.paddingTop)||0,right:parseFloat(t.paddingRight)||0,bottom:parseFloat(t.paddingBottom)||0,left:parseFloat(t.paddingLeft)||0}}function Un(e){let t=window.getComputedStyle(e);return{"top-left":parseFloat(t.borderTopLeftRadius)||0,"top-right":parseFloat(t.borderTopRightRadius)||0,"bottom-right":parseFloat(t.borderBottomRightRadius)||0,"bottom-left":parseFloat(t.borderBottomLeftRadius)||0}}function Qr(e){for(let t of e.childNodes)if(t.nodeType===Node.TEXT_NODE&&(t.textContent||"").trim().length>0)return!0;return!1}function mo(e){var d,u;let t=document.createRange(),o=!1;for(let p of e.childNodes)p.nodeType===Node.TEXT_NODE&&(p.textContent||"").trim().length>0&&(o||(t.setStart(p,0),o=!0),t.setEnd(p,(u=(d=p.textContent)==null?void 0:d.length)!=null?u:0));if(!o)return null;let r=t.getBoundingClientRect(),n=window.getComputedStyle(e),i=parseFloat(n.fontSize)||16,s=parseFloat(n.lineHeight);isNaN(s)&&(s=i*1.2);let l=Math.max(1,t.getClientRects().length),a=Math.max(r.height,l*s),c=(a-r.height)/2;return new DOMRect(r.x,r.y-c,r.width,a)}function No(e){let t=window.getComputedStyle(e),o=parseFloat(t.fontSize)||16,r=parseFloat(t.lineHeight);return isNaN(r)&&(r=o*1.2),{fontSize:o,lineHeight:r}}function _e(e,t,o){e instanceof HTMLElement&&e.style.setProperty(t,o,"important")}function ei(e,t,o){e instanceof HTMLElement&&e.style.removeProperty(t)}function cr(e){var t;for(let o of e){let r=Jt(o.selector);if(!r&&o.durableSelector&&(r=Jt(o.durableSelector),r)){let n=(t=o.selector.match(/\[data-pm="([^"]+)"\]/))==null?void 0:t[1];n&&r.setAttribute("data-pm",n)}if(r)for(let n of o.changes)_e(r,n.property,n.modified)}}function ti(e,t){let o=Jt(e);if(!o)return;let r=t.find(n=>n.selector===e);if(r)for(let n of r.changes)ei(o,n.property,n.original)}function dr(e){for(let t of e){let o=Jt(t.selector);if(o)for(let r of t.changes)ei(o,r.property,r.original)}}function tl(e,t,o,r){if(e)for(let n of e){if(n instanceof CSSGroupingRule){tl(n.cssRules,t,o,r);continue}if(n instanceof CSSStyleRule){let i=n.selectorText.toLowerCase();(i===":root"||i==="html"||i==="*"||i.includes(":root"))&&jc(n.style,t,o,r)}}}function jc(e,t,o,r){for(let n=0;n<e.length;n++){let i=e[n];if(i!=null&&i.startsWith("--")){if(o.has(i))continue;o.add(i);let s=t.getPropertyValue(i).trim();nl(s)&&r.push({name:i,value:s,usage:`var(${i})`})}}}var ur=null,Gc=5e3;function ni(){if(ur&&Date.now()-ur.timestamp<Gc)return ur.variables;let e=[],t=new Set,o=getComputedStyle(document.documentElement);try{for(let i of document.styleSheets)try{tl(i.cssRules||i.rules,o,t,e)}catch(s){}}catch(i){}let r=document.documentElement.style;for(let i=0;i<r.length;i++){let s=r[i];if(s!=null&&s.startsWith("--")&&!t.has(s)){t.add(s);let l=o.getPropertyValue(s).trim();nl(l)&&e.push({name:s,value:l,usage:`var(${s})`})}}let n=e.sort((i,s)=>i.name.localeCompare(s.name));return ur={variables:n,timestamp:Date.now()},n}function nl(e){if(!e)return!1;let t=e.toLowerCase().trim();return!!(/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||t.startsWith("rgb")||t.startsWith("hsl")||t.startsWith("oklch")||t.startsWith("oklab")||t.startsWith("lch")||t.startsWith("lab")||["transparent","currentcolor","inherit","white","black","red","green","blue","yellow","orange","purple","pink","gray","grey"].includes(t))}function _o(e,t){let o=t.match(/var\((--[^,)]+)(?:,\s*([^)]+))?\)/);if(o){let r=o[1],n=o[2];return getComputedStyle(document.documentElement).getPropertyValue(r).trim()||n||t}return t}function zo(e,t){if(!e)return null;let o=el(e);if(!o)return null;for(let r of t){let n=el(r.value);if(n&&o===n)return r}return null}function el(e){if(!e)return null;let t=e.trim().toLowerCase();if(t.startsWith("oklch(")){let o=t.match(/oklch\(\s*([\d.]+%?)\s+([\d.]+%?)\s+([\d.]+)/);if(o){let r=o[1].endsWith("%")?parseFloat(o[1])/100:parseFloat(o[1]),n=o[2].endsWith("%")?parseFloat(o[2])/100:parseFloat(o[2]),i=parseFloat(o[3]);r=Math.round(r*100)/100,n=Math.round(n*1e3)/1e3;let s=Math.round(i);return`oklch(${r} ${n} ${s})`}}if(t.startsWith("rgb")){let o=t.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/);if(o)return`rgb(${o[1]},${o[2]},${o[3]})`}return t.startsWith("#")?t.length===4?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t.slice(0,7):t}import{Fragment as Jn,jsx as Xe,jsxs as pn}from"react/jsx-runtime";var Xn=22,ho=12,Vc=3,Uc=250,oi=["reviewing","considering","thinking","zhuzhing","iterating","tweaking","reflecting","noodling","pondering","finessing","polishing","riffing"],Jc=3e3;function Xc(i){var s=i,{left:e,top:t,style:o,children:r}=s,n=Hn(s,["left","top","style","children"]);return Xe("div",m(f({"data-devtools":"badge-hit-area"},n),{style:f({position:"fixed",left:`max(0px, ${e}px)`,top:`max(0px, ${t}px)`,padding:ho,transform:`translate(min(0px, calc(100vw - max(0px, ${e}px) - 100%)), min(0px, calc(100vh - max(0px, ${t}px) - 100%)))`},o),children:r}))}function il({annotations:e,supersededAnnotations:t,inFlightIds:o,scrollX:r,scrollY:n,annotationGroupMap:i,onViewThread:s,onSelectAnnotation:l,canvasRef:a}){var y,w,O,A;let[c,d]=$o(0),[u,p]=$o(()=>Math.floor(Math.random()*oi.length)),g=!!(o&&o.size>0);pr(()=>{if(!g)return;let C=setInterval(()=>{d(I=>(I+1)%Vc)},Uc),E=setInterval(()=>{p(I=>(I+1)%oi.length)},Jc);return()=>{clearInterval(C),clearInterval(E)}},[g]);let S=[];for(let C of e){if(C.type!=="text"||!C.text||!C.points[0]||t.has(C))continue;let E=C.groupId?e.filter(xe=>xe.groupId===C.groupId):[C],I=!!(o&&(o.has(C.id)||E.some(xe=>o.has(xe.id)))),$=(y=C.status)!=null?y:"pending",Z=E.some(xe=>xe.status==="resolved"||xe.status==="needs_review"),G=E.some(xe=>xe.threadId);if(!I&&$!=="resolved"&&$!=="needs_review"&&!Z&&!G)continue;let M=C.threadId||((w=E.find(xe=>xe.threadId))==null?void 0:w.threadId),D=$==="needs_review"||E.some(xe=>xe.status==="needs_review"),X=E.reduce((xe,me)=>{var Ge;return xe+((Ge=me.replyCount)!=null?Ge:0)},0),ee=C.points[0],he=C.fontSize||12,ve=he*1.4,ae=C.text.split(`
|
|
5
|
+
`),Re=i.get(C.id),We=Re!==void 0?[Re+". "+(ae[0]||""),...ae.slice(1)]:ae,Me=(A=(O=a==null?void 0:a.current)==null?void 0:O.getContext("2d"))!=null?A:document.createElement("canvas").getContext("2d");if(!Me)continue;Me.font=`${he}px ${$t}`;let ne=ee.x-r,Ae=co(ne),V=Ae!==void 0?Math.min(400,Ae):400,oe=jn(Me,We,V),Ee=Math.min(V,Math.max(...oe.map(xe=>Me.measureText(xe).width))),ce=oe.length*ve,Ke=We.length*ve,Te=ce-Ke;S.push({id:C.id,threadId:M,x:ee.x+Ee+4,y:ee.y-4-Te,size:ce+8,color:C.color,isInFlight:I,isNeedsReview:D,replyCount:X})}if(S.length===0)return null;let v=!!s;return Xe(Jn,{children:S.map(C=>Xe(Xc,{left:C.x-r-ho,top:C.y-n-ho,onClick:v&&C.threadId?()=>{l==null||l(C.id),s(C.threadId)}:void 0,style:{pointerEvents:v?"auto":"none",cursor:v&&C.threadId?"pointer":void 0,zIndex:9999},children:Xe("div",{"data-devtools":"annotation-badge",style:{height:C.size,display:"flex",alignItems:"center",backgroundColor:C.color,fontFamily:$t,fontSize:12,color:"#ffffff",userSelect:"none",padding:`0 ${4}px`,gap:4,whiteSpace:"nowrap"},children:C.isInFlight?pn(Jn,{children:[Xe("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"currentColor",style:{verticalAlign:"middle"},children:c===1?pn(Jn,{children:[Xe("circle",{cx:"7",cy:"7",r:"2"}),Xe("circle",{cx:"17",cy:"7",r:"2"}),Xe("circle",{cx:"7",cy:"17",r:"2"}),Xe("circle",{cx:"17",cy:"17",r:"2"})]}):pn(Jn,{children:[Xe("circle",{cx:"12",cy:"6",r:"2"}),Xe("circle",{cx:"6",cy:"12",r:"2"}),Xe("circle",{cx:"18",cy:"12",r:"2"}),Xe("circle",{cx:"12",cy:"18",r:"2"})]})}),Xe("span",{style:{opacity:.7},children:oi[u]})]}):pn(Jn,{children:[C.isNeedsReview?Xe("span",{style:{fontWeight:700},children:"?"}):pn("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[Xe("line",{x1:"12",y1:"3",x2:"12",y2:"9"}),Xe("line",{x1:"12",y1:"15",x2:"12",y2:"21"}),Xe("line",{x1:"3",y1:"12",x2:"9",y2:"12"}),Xe("line",{x1:"15",y1:"12",x2:"21",y2:"12"})]}),Xe("span",{style:{opacity:.7},children:C.replyCount>0?`${C.replyCount} ${C.replyCount===1?"reply":"replies"}`:"Cancelled"})]})})},C.id))})}function ri({inFlightSelectorColors:e,animated:t=!0}){let[o,r]=$o([]);if(pr(()=>{if(e.size===0){r([]);return}let i=null,s=()=>{let c=[];for(let[d,u]of e){let p=Jt(d);if(!p)continue;let g=p.getBoundingClientRect();c.push({selector:d,top:g.top,left:g.left,width:g.width,height:g.height,color:u})}r(c)},l=()=>{i&&cancelAnimationFrame(i),i=requestAnimationFrame(s)};s(),window.addEventListener("scroll",l,!0),window.addEventListener("resize",l,!0);let a=new MutationObserver(l);return a.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]}),()=>{window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",l,!0),a.disconnect(),i&&cancelAnimationFrame(i)}},[e]),o.length===0)return null;let n={position:"absolute",width:2,height:2,pointerEvents:"none"};return pn(Jn,{children:[t&&Xe("style",{children:"@keyframes popmelt-march { to { stroke-dashoffset: -6; } }"}),o.map(i=>pn("div",{"data-devtools":"marching-ants",style:{position:"fixed",top:i.top,left:i.left,width:i.width,height:i.height,pointerEvents:"none",zIndex:9995,overflow:"visible"},children:[Xe("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible"},children:Xe("rect",{x:"0.5",y:"0.5",width:Math.max(0,i.width-1),height:Math.max(0,i.height-1),fill:"none",stroke:i.color,strokeWidth:"1",strokeDasharray:"2 4",style:t?{animation:"popmelt-march 0.5s steps(2) infinite"}:void 0})}),Xe("div",{style:m(f({},n),{top:-1,left:-1,backgroundColor:i.color})}),Xe("div",{style:m(f({},n),{top:-1,right:-1,backgroundColor:i.color})}),Xe("div",{style:m(f({},n),{bottom:-1,left:-1,backgroundColor:i.color})}),Xe("div",{style:m(f({},n),{bottom:-1,right:-1,backgroundColor:i.color})})]},i.selector))]})}function sl({annotations:e,supersededAnnotations:t,scrollX:o,scrollY:r,onReply:n,annotationGroupMap:i,canvasRef:s}){let l=e.filter(d=>t.has(d)?!1:d.status==="waiting_input"&&d.question&&d.threadId);if(l.length===0)return null;let a=new Set,c=[];for(let d of l){if(!d.threadId||a.has(d.threadId))continue;a.add(d.threadId);let u=d.type==="text"?d:e.find(p=>p.groupId&&p.groupId===d.groupId&&p.type==="text")||d;if(u.type==="text"&&u.text&&u.points[0]){let p=u.points[0],g=u.fontSize||12,S=g*1.4,v=u.text.split(`
|
|
6
|
+
`),y=i.get(u.id),w=y!==void 0?[y+". "+(v[0]||""),...v.slice(1)]:v,A=document.createElement("canvas").getContext("2d");if(!A)continue;A.font=`${g}px ${$t}`;let C=p.x-o,E=co(C),I=E!==void 0?Math.min(400,E):400,$=jn(A,w,I),Z=Math.min(I,Math.max(...$.map(ee=>A.measureText(ee).width))),G=$.length*S,M=w.length*S,D=G-M,X=G+8;c.push({annotation:d,x:p.x+Z+4,y:p.y-4-D,size:X})}}return c.length===0?null:Xe(Jn,{children:c.map(({annotation:d,x:u,y:p,size:g})=>Xe(Kc,{annotation:d,x:u-o,y:p-r,size:g,onReply:n},`question-${d.threadId}`))})}function Kc({annotation:e,x:t,y:o,size:r,onReply:n}){let[i,s]=$o(!1),[l,a]=$o(""),c=rl(null),d=rl(null);pr(()=>{i&&c.current&&c.current.focus()},[i]),pr(()=>{if(!i)return;let v=w=>{d.current&&!w.composedPath().includes(d.current)&&s(!1)},y=w=>{w.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",v),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",y)}},[i]);let u=ol(()=>{!l.trim()||!e.threadId||(n(e.threadId,l.trim()),a(""),s(!1))},[l,e.threadId,n]),p=ol(v=>{v.key==="Enter"&&(v.metaKey||v.ctrlKey)&&(v.preventDefault(),u())},[u]),g=i?t:t-ho,S=i?o:o-ho;return pn("div",{ref:d,"data-devtools":"question-badge",style:{position:"fixed",left:`max(0px, ${g}px)`,top:`max(0px, ${S}px)`,padding:i?0:ho,transform:`translate(min(0px, calc(100vw - max(0px, ${g}px) - 100%)), min(0px, calc(100vh - max(0px, ${S}px) - 100%)))`,zIndex:i?10002:9999,pointerEvents:"auto",cursor:i?void 0:"pointer"},children:[!i&&pn("div",{onClick:()=>s(!0),style:{height:r,display:"flex",alignItems:"center",backgroundColor:e.color,padding:`0 ${4}px`,gap:4,fontFamily:$t,fontSize:12,color:"#ffffff",whiteSpace:"nowrap"},children:[pn("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[Xe("line",{x1:"12",y1:"3",x2:"12",y2:"9"}),Xe("line",{x1:"12",y1:"15",x2:"12",y2:"21"}),Xe("line",{x1:"3",y1:"12",x2:"9",y2:"12"}),Xe("line",{x1:"15",y1:"12",x2:"21",y2:"12"})]}),Xe("span",{style:{opacity:.7},children:"reply?"})]}),i&&pn("div",{style:{minWidth:260,maxWidth:360,backgroundColor:"#ffffff",fontFamily:$t,fontSize:12,color:"#1f2937",border:"1px solid rgba(0, 0, 0, 0.1)"},children:[Xe("div",{style:{padding:`${6}px ${8}px`,lineHeight:1.4},children:e.question}),pn("div",{style:{padding:`0 ${4}px ${4}px`},children:[Xe("textarea",{ref:c,value:l,onChange:v=>a(v.target.value),onKeyDown:p,placeholder:"Type your reply...",style:{width:"100%",minHeight:40,padding:4,fontSize:12,fontFamily:$t,backgroundColor:"rgba(0, 0, 0, 0.04)",color:"#1f2937",border:"1px solid rgba(0, 0, 0, 0.1)",borderRadius:0,outline:"none",resize:"vertical",lineHeight:1.4,boxSizing:"border-box"}}),Xe("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:4},children:Xe("button",{onClick:u,disabled:!l.trim(),style:{padding:"4px 12px",fontSize:11,fontFamily:$t,fontWeight:600,backgroundColor:l.trim()?e.color:"rgba(0,0,0,0.1)",color:l.trim()?"#ffffff":"rgba(0,0,0,0.3)",border:"none",cursor:l.trim()?"pointer":"default"},children:"Send \u2318\u23CE"})})]})]})]})}function fr(e){var i;let t=new Set,o=new Map;for(let s of e){if(!s.linkedSelector)continue;let l=o.get(s.linkedSelector)||[];l.push(s),o.set(s.linkedSelector,l)}let r=new Set,n=new Set;for(let s of o.values()){if(s.length<=1){(i=s[0])!=null&&i.groupId&&n.add(s[0].groupId);continue}s.sort((a,c)=>c.timestamp-a.timestamp);let l=s[0];l.groupId&&n.add(l.groupId);for(let a=1;a<s.length;a++){let c=s[a];t.add(c),c.groupId&&r.add(c.groupId)}}for(let s of e)s.groupId&&r.has(s.groupId)&&!n.has(s.groupId)&&t.add(s);return t}import{useEffect as ll,useLayoutEffect as Zc,useState as al}from"react";import{jsx as ii,jsxs as dl}from"react/jsx-runtime";function qc(e,t){let o=e.match(/^oklch\(([^)]+)\)$/i);return o?`oklch(${o[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}var cl=["top-left","top-right","bottom-right","bottom-left"];function ul({element:e,radius:t,accentColor:o,hoveredCorner:r,draggingCorner:n,cursorViewport:i}){let[s,l]=al(null),[a,c]=al(!1);if(ll(()=>{let w=C=>{(C.key==="Meta"||C.key==="Control")&&c(!0)},O=C=>{(C.key==="Meta"||C.key==="Control")&&c(!1)},A=()=>c(!1);return window.addEventListener("keydown",w,!0),window.addEventListener("keyup",O,!0),window.addEventListener("blur",A),()=>{window.removeEventListener("keydown",w,!0),window.removeEventListener("keyup",O,!0),window.removeEventListener("blur",A)}},[]),ll(()=>{if(!e){l(null);return}let w=()=>{l(e.getBoundingClientRect())};return w(),window.addEventListener("scroll",w,{passive:!0}),window.addEventListener("resize",w,{passive:!0}),()=>{window.removeEventListener("scroll",w),window.removeEventListener("resize",w)}},[e]),Zc(()=>{e&&l(e.getBoundingClientRect())},[e,t["top-left"],t["top-right"],t["bottom-right"],t["bottom-left"]]),!s)return null;let d=s.width,u=s.height,p=qc(o,.2),g={"top-left":{x:0,y:t["top-left"]},"top-right":{x:d,y:t["top-right"]},"bottom-right":{x:d,y:u-t["bottom-right"]},"bottom-left":{x:0,y:u-t["bottom-left"]}},S=new Set,v=n!=null?n:r;if(v)if(a)S.add(v);else for(let w of cl)S.add(w);let y={position:"fixed",top:s.top,left:s.left,width:d,height:u,pointerEvents:"none",zIndex:9996,overflow:"visible"};return dl("div",{"data-devtools":"border-radius-handles",style:y,children:[dl("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:`0 0 ${d} ${u}`,children:[ii("rect",{x:"0.5",y:"0.5",width:Math.max(0,d-1),height:Math.max(0,u-1),fill:"none",stroke:p,strokeWidth:"1"}),cl.map(w=>{let O=g[w],A=S.has(w);return ii("circle",{cx:O.x,cy:O.y,r:w===(n!=null?n:r)?3:2.5,fill:o,stroke:"#ffffff",strokeWidth:w===(n!=null?n:r)?4:2,paintOrder:"stroke"},w)})]}),i&&v&&(()=>{let w=Math.round(t[v]);return ii("div",{style:{position:"fixed",left:i.x+8,top:i.y-28,background:o,color:"#fff",fontSize:11,fontWeight:600,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1,padding:"4px 4px",borderRadius:0,whiteSpace:"nowrap",pointerEvents:"none",zIndex:9997},children:w})})()]})}import{useEffect as Qc,useState as ed}from"react";function Kn(e,t){let o=e.match(/^oklch\(([^)]+)\)$/i);if(o)return`oklch(${o[1]} / ${t})`;let r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(r){let n=parseInt(r[1],16),i=parseInt(r[2],16),s=parseInt(r[3],16);return`rgba(${n}, ${i}, ${s}, ${t})`}return`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}import{Fragment as td,jsx as Zn,jsxs as Wo}from"react/jsx-runtime";function bo({element:e,isSelected:t=!1,elementInfo:o,color:r="#3b82f6",annotationNumber:n,changeCount:i,hideTooltip:s=!1}){let[l,a]=ed(null);if(Qc(()=>{if(!e){a(null);return}let I=()=>{let $=e.getBoundingClientRect();a($)};return I(),window.addEventListener("scroll",I,{passive:!0}),window.addEventListener("resize",I,{passive:!0}),()=>{window.removeEventListener("scroll",I),window.removeEventListener("resize",I)}},[e]),!l||!e)return null;let c={position:"fixed",top:l.top,left:l.left,width:l.width,height:l.height,pointerEvents:"none",zIndex:9996,backgroundColor:t?Kn(r,.1):Kn(r,.05),overflow:"visible"},d={position:"absolute",width:2,height:2,backgroundColor:r,pointerEvents:"none"},u=e.tagName.toLowerCase(),p=e.id?`#${e.id}`:"",g=e.classList.length>0?"."+Array.from(e.classList).slice(0,2).join("."):"",S=o==null?void 0:o.reactComponent,v=S?`<${S}> ${u}${p}${g}`:`${u}${p}${g}`,y=22,w=l.height>=window.innerHeight,O=w?0:l.top>=y?l.top-y:l.bottom,A=w?{position:"absolute",top:8,left:8,zIndex:9997,display:"flex",alignItems:"center",gap:6,backgroundColor:r,color:"#fff",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',padding:"4px 8px",borderRadius:0,pointerEvents:"none",whiteSpace:"nowrap",maxWidth:400}:{position:"fixed",top:O,left:l.left,zIndex:9997,display:"flex",alignItems:"center",gap:6,backgroundColor:r,color:"#fff",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',padding:"4px 8px",borderRadius:0,pointerEvents:"none",whiteSpace:"nowrap",maxWidth:400},E=!s&&Wo("div",{"data-devtools":"tooltip",style:A,children:[n!==void 0&&Wo("span",{children:[n,"."]}),Zn("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:v}),i!==void 0&&i>0&&Wo("span",{style:{opacity:.8},children:["(",i," ",i===1?"change":"changes",")"]})]});return Wo(td,{children:[Wo("div",{"data-devtools":"highlight",style:c,children:[Zn("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},children:Zn("rect",f({x:"0.5",y:"0.5",width:Math.max(0,l.width-1),height:Math.max(0,l.height-1),fill:"none",stroke:r,strokeWidth:"1"},!t&&{strokeDasharray:"2 4"}))}),Zn("div",{style:m(f({},d),{top:-1,left:-1})}),Zn("div",{style:m(f({},d),{top:-1,right:-1})}),Zn("div",{style:m(f({},d),{bottom:-1,left:-1})}),Zn("div",{style:m(f({},d),{bottom:-1,right:-1})}),w&&E]}),!w&&E]})}import{useEffect as pl,useLayoutEffect as nd,useState as si}from"react";import{jsx as In,jsxs as ai}from"react/jsx-runtime";function li(e,t){let o=e.match(/^oklch\(([^)]+)\)$/i);return o?`oklch(${o[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}function ci({element:e,gap:t,accentColor:o,hoveredAxis:r,draggingAxis:n,cursorViewport:i,isAutoGap:s=!1,refreshKey:l=0}){let[a,c]=si(null),[d,u]=si([]),[p,g]=si(!1);if(pl(()=>{let Z=D=>{(D.key==="Meta"||D.key==="Control")&&g(!0)},G=D=>{(D.key==="Meta"||D.key==="Control")&&g(!1)},M=()=>g(!1);return window.addEventListener("keydown",Z,!0),window.addEventListener("keyup",G,!0),window.addEventListener("blur",M),()=>{window.removeEventListener("keydown",Z,!0),window.removeEventListener("keyup",G,!0),window.removeEventListener("blur",M)}},[]),pl(()=>{if(!e){c(null),u([]);return}let Z=()=>{c(e.getBoundingClientRect()),u(Vn(e))};return Z(),window.addEventListener("scroll",Z,{passive:!0}),window.addEventListener("resize",Z,{passive:!0}),()=>{window.removeEventListener("scroll",Z),window.removeEventListener("resize",Z)}},[e]),nd(()=>{e&&(c(e.getBoundingClientRect()),u(Vn(e)))},[e,t.row,t.column,l]),!a||d.length===0)return null;let S=a.width,v=a.height,y="pm-gap-stripe-pattern",w=li(o,.25),O=li(o,.1),A=li(o,.2),C=8,E=2,I={position:"fixed",top:a.top,left:a.left,width:S,height:v,pointerEvents:"none",zIndex:9996,overflow:"visible"},$=n!=null?n:r;return ai("div",{"data-devtools":"gap-handles",style:I,children:[ai("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:`0 0 ${S} ${v}`,children:[In("defs",{children:In("pattern",{id:y,patternUnits:"userSpaceOnUse",width:"4",height:"4",patternTransform:"rotate(45)",children:In("line",{x1:"0",y1:"0",x2:"0",y2:"4",stroke:w,strokeWidth:"1.5"})})}),In("rect",{x:"0.5",y:"0.5",width:Math.max(0,S-1),height:Math.max(0,v-1),fill:"none",stroke:A,strokeWidth:"1"}),d.map((Z,G)=>{let M=Z.x-a.left,D=Z.y-a.top,X=Z.w,ee=Z.h,he=p?Z.axis===$:!0;return(Z.axis==="row"?t.row:t.column)===0?null:ai("g",{opacity:he?1:.6,children:[In("rect",{x:M,y:D,width:X,height:ee,fill:O}),In("rect",{x:M,y:D,width:X,height:ee,fill:`url(#${y})`})]},G)}),$&&(()=>{let Z=d.filter(Ae=>Ae.axis===$);if(Z.length===0)return null;let G=Z[0];if(i&&Z.length>1){let Ae=1/0;for(let V of Z){let oe=V.x+V.w/2,Ee=V.y+V.h/2,ce=Math.abs(i.x-oe)+Math.abs(i.y-Ee);ce<Ae&&(Ae=ce,G=V)}}let M=G.x-a.left,D=G.y-a.top,X=G.w,ee=G.h,he=M+X/2,ve=D+ee/2;if(s)return In("circle",{cx:he,cy:ve,r:1.5,fill:o,stroke:"#ffffff",strokeWidth:4,paintOrder:"stroke"});let ae=$==="column",Re=ae?E:C,We=ae?C:E,Me=he-Re/2,ne=ve-We/2;return In("rect",{x:Me,y:ne,width:Re,height:We,fill:o,stroke:"#ffffff",strokeWidth:4,paintOrder:"stroke"})})()]}),i&&$&&(()=>{let Z=s?"auto":String(Math.round($==="row"?t.row:t.column));return In("div",{style:{position:"fixed",left:i.x+8,top:i.y-28,background:o,color:"#fff",fontSize:11,fontWeight:600,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1,padding:"4px 4px",borderRadius:0,whiteSpace:"nowrap",pointerEvents:"none",zIndex:9997},children:Z})})()]})}import{useCallback as ld,useEffect as ad,useState as cd}from"react";import{useEffect as od,useState as fl}from"react";var rd=3,id=250,di=["reviewing","considering","thinking","zhuzhing","iterating","tweaking","reflecting","noodling","pondering","finessing","polishing","riffing"],sd=3e3;function gr(e){let[t,o]=fl(0),[r,n]=fl(()=>Math.floor(Math.random()*di.length));return od(()=>{if(!e)return;let i=setInterval(()=>o(l=>(l+1)%rd),id),s=setInterval(()=>n(l=>(l+1)%di.length),sd);return()=>{clearInterval(i),clearInterval(s)}},[e]),{charIndex:t,word:di[r]}}import{Fragment as ui,jsx as ln,jsxs as xo}from"react/jsx-runtime";function dd(e){let{element:t}=e,o=t.tagName,r=t.id?`#${t.id}`:"",n=t.className?"."+t.className.split(" ").slice(0,2).join("."):"",i=t.reactComponent;return i?`<${i}> ${o}${r}${n}`:`${o}${r}${n}`}var gl=22,pi=12;function ud(i){var s=i,{left:e,top:t,style:o,children:r}=s,n=Hn(s,["left","top","style","children"]);return ln("div",m(f({"data-devtools":"badge-hit-area"},n),{style:f({position:"fixed",left:`max(0px, ${e}px)`,top:`max(0px, ${t}px)`,padding:pi,transform:`translate(min(0px, calc(100vw - max(0px, ${e}px) - 100%)), min(0px, calc(100vh - max(0px, ${t}px) - 100%)))`},o),children:r}))}function ml({styleModifications:e,isInspecting:t,accentColor:o,annotationGroupCount:r,dispatch:n,inFlightSelectors:i}){let[s,l]=cd([]),a=i&&i.size>0,{charIndex:c,word:d}=gr(!!a);ad(()=>{if(t){l([]);return}let S=null,v=()=>{let O=[];e.forEach((A,C)=>{let E=Jt(A.selector);if(!E)return;let I=E.getBoundingClientRect();O.push({selector:A.selector,modIndex:C,top:I.top>=gl?I.top-gl:I.bottom,left:I.left,label:dd(A),changeCount:A.changes.length,annotationNumber:r+C+1})}),l(O)},y=()=>{S&&cancelAnimationFrame(S),S=requestAnimationFrame(v)};v(),window.addEventListener("scroll",y,!0),window.addEventListener("resize",y,!0);let w=new MutationObserver(y);return w.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]}),window.addEventListener("load",y),document.fonts.ready.then(y),()=>{window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y,!0),window.removeEventListener("load",y),w.disconnect(),S&&cancelAnimationFrame(S)}},[e,t,r]);let u=ld(S=>{let v=e[S];if(!v)return;let y=Jt(v.selector);y&&(n({type:"SELECT_ANNOTATION",payload:{id:null}}),n({type:"SET_TOOL",payload:"inspector"}),n({type:"SELECT_ELEMENT",payload:{el:y,info:v.element}}))},[e,n]);if(s.length===0)return null;let p={display:"flex",alignItems:"center",gap:6,backgroundColor:o,color:"#fff",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',padding:"4px 8px",borderRadius:0,whiteSpace:"nowrap",maxWidth:400},g={overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0};return ln(ui,{children:s.map(S=>{let v=i==null?void 0:i.has(S.selector);return ln(ud,{left:S.left-pi,top:S.top-pi,onClick:()=>u(S.modIndex),style:{zIndex:1e4,cursor:"pointer",pointerEvents:"auto"},children:xo("div",{"data-devtools":"badge",style:m(f({},p),{backgroundColor:v?"#999999":o}),children:[xo("span",{children:[S.annotationNumber,"."]}),ln("span",{style:g,children:S.label}),xo("span",{style:{opacity:.8},children:["(",S.changeCount," ",S.changeCount===1?"change":"changes",")"]}),v&&xo("span",{style:{opacity:.8,marginLeft:4,display:"inline-flex",alignItems:"center",gap:4},children:[ln("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"currentColor",style:{verticalAlign:"middle"},children:c===1?xo(ui,{children:[ln("circle",{cx:"7",cy:"7",r:"2"}),ln("circle",{cx:"17",cy:"7",r:"2"}),ln("circle",{cx:"7",cy:"17",r:"2"}),ln("circle",{cx:"17",cy:"17",r:"2"})]}):xo(ui,{children:[ln("circle",{cx:"12",cy:"6",r:"2"}),ln("circle",{cx:"6",cy:"12",r:"2"}),ln("circle",{cx:"18",cy:"12",r:"2"}),ln("circle",{cx:"12",cy:"18",r:"2"})]})}),d]})]})},S.selector)})})}import{useEffect as pd,useState as fd}from"react";import{Fragment as md,jsx as hl}from"react/jsx-runtime";function gd(e,t){let o=e.match(/^oklch\(([^)]+)\)$/i);return o?`oklch(${o[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}function yl({styleModifications:e,accentColor:t}){let[o,r]=fd([]);if(pd(()=>{let i=null,s=()=>{let c=[];for(let d of e){let u=Jt(d.selector);if(!u)continue;let p=u.getBoundingClientRect();if(p.width===0&&p.height===0)continue;let g=Un(u);c.push({selector:d.selector,top:p.top,left:p.left,width:p.width,height:p.height,borderRadius:`${g["top-left"]}px ${g["top-right"]}px ${g["bottom-right"]}px ${g["bottom-left"]}px`})}r(c)},l=()=>{i&&cancelAnimationFrame(i),i=requestAnimationFrame(s)};s(),window.addEventListener("scroll",l,{passive:!0}),window.addEventListener("resize",l,{passive:!0});let a=new MutationObserver(l);return a.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]}),()=>{window.removeEventListener("scroll",l),window.removeEventListener("resize",l),a.disconnect(),i&&cancelAnimationFrame(i)}},[e]),o.length===0)return null;let n=gd(t,.2);return hl(md,{children:o.map(i=>{let s={position:"fixed",top:i.top,left:i.left,width:i.width,height:i.height,pointerEvents:"none",zIndex:9995,border:`1px solid ${n}`,borderRadius:i.borderRadius,boxSizing:"border-box"};return hl("div",{"data-devtools":"mod-border",style:s},i.selector)})})}import{useEffect as bl,useLayoutEffect as hd,useState as xl}from"react";import{jsx as Fn,jsxs as gi}from"react/jsx-runtime";function fi(e,t){let o=e.match(/^oklch\(([^)]+)\)$/i);return o?`oklch(${o[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}var yd={top:"bottom",bottom:"top",left:"right",right:"left"};function mi({element:e,padding:t,accentColor:o,hoveredSide:r,draggingSide:n,cursorViewport:i,refreshKey:s}){let[l,a]=xl(null),[c,d]=xl(!1);if(bl(()=>{let X=ve=>{(ve.key==="Meta"||ve.key==="Control")&&d(!0)},ee=ve=>{(ve.key==="Meta"||ve.key==="Control")&&d(!1)},he=()=>d(!1);return window.addEventListener("keydown",X,!0),window.addEventListener("keyup",ee,!0),window.addEventListener("blur",he),()=>{window.removeEventListener("keydown",X,!0),window.removeEventListener("keyup",ee,!0),window.removeEventListener("blur",he)}},[]),bl(()=>{if(!e){a(null);return}let X=()=>{a(e.getBoundingClientRect())};return X(),window.addEventListener("scroll",X,{passive:!0}),window.addEventListener("resize",X,{passive:!0}),()=>{window.removeEventListener("scroll",X),window.removeEventListener("resize",X)}},[e]),hd(()=>{e&&a(e.getBoundingClientRect())},[e,t.top,t.right,t.bottom,t.left,s]),!l)return null;let u=l.width,p=l.height,{top:g,right:S,bottom:v,left:y}=t,w="pm-stripe-pattern",O=fi(o,.25),A=fi(o,.1),C=fi(o,.2),E=8,I=2,$={position:"fixed",top:l.top,left:l.left,width:u,height:p,pointerEvents:"none",zIndex:9996,overflow:"visible"},Z=["top","right","bottom","left"],G={top:`0,0 ${u},0 ${u-S},${g} ${y},${g}`,right:`${u},0 ${u},${p} ${u-S},${p-v} ${u-S},${g}`,bottom:`0,${p} ${y},${p-v} ${u-S},${p-v} ${u},${p}`,left:`0,0 ${y},${g} ${y},${p-v} 0,${p}`},M={top:{x:u/2-E/2,y:g/2-I/2,w:E,h:I},bottom:{x:u/2-E/2,y:p-v/2-I/2,w:E,h:I},left:{x:y/2-I/2,y:p/2-E/2,w:I,h:E},right:{x:u-S/2-I/2,y:p/2-E/2,w:I,h:E}},D=new Set;return n?D.add(n):r&&(D.add(r),c||D.add(yd[r])),gi("div",{"data-devtools":"padding-handles",style:$,children:[gi("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:`0 0 ${u} ${p}`,children:[Fn("defs",{children:Fn("pattern",{id:w,patternUnits:"userSpaceOnUse",width:"4",height:"4",patternTransform:"rotate(45)",children:Fn("line",{x1:"0",y1:"0",x2:"0",y2:"4",stroke:O,strokeWidth:"1.5"})})}),Fn("rect",{x:"0.5",y:"0.5",width:Math.max(0,u-1),height:Math.max(0,p-1),fill:"none",stroke:C,strokeWidth:"1"}),Z.map(X=>{if(t[X]<=0)return null;let he=D.has(X);return gi("g",{opacity:he?1:.6,children:[Fn("polygon",{points:G[X],fill:A}),Fn("polygon",{points:G[X],fill:`url(#${w})`})]},X)}),Z.map(X=>{let ee=M[X],he=D.has(X);return Fn("rect",{x:ee.x,y:ee.y,width:ee.w,height:ee.h,fill:o,stroke:"#ffffff",strokeWidth:he?4:2,paintOrder:"stroke"},`handle-${X}`)})]}),i&&(r||n)&&(()=>{let X=n!=null?n:r,ee=Math.round(t[X]);return Fn("div",{style:{position:"fixed",left:i.x+8,top:i.y-28,background:o,color:"#fff",fontSize:11,fontWeight:600,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1,padding:"4px 4px",borderRadius:0,whiteSpace:"nowrap",pointerEvents:"none",zIndex:9997},children:ee})})()]})}import{useCallback as Mn,useEffect as gn,useMemo as Sr,useRef as on,useState as Yt}from"react";import{Check as vr,ChevronDown as Ei,MoveHorizontal as Al,RotateCcw as Wd,Shrink as Yd,X as jd}from"lucide-react";var bd="data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPScxMicgaGVpZ2h0PScxMic+PGRlZnM+PHBhdHRlcm4gaWQ9J2QnIHdpZHRoPSc0JyBoZWlnaHQ9JzQnIHBhdHRlcm5Vbml0cz0ndXNlclNwYWNlT25Vc2UnPjxwYXRoIGQ9J00tMSwxIGwyLC0yIE0wLDQgbDQsLTQgTTMsNSBsMiwtMicgc3Ryb2tlPSdibGFjaycgc3Ryb2tlLXdpZHRoPScuNScvPjwvcGF0dGVybj48L2RlZnM+PHJlY3Qgd2lkdGg9JzEyJyBoZWlnaHQ9JzEyJyBmaWxsPSd1cmwoI2QpJy8+PC9zdmc+",bn={borderWidth:3,borderStyle:"solid",borderImage:`url("${bd}") 4 / 1.9 / 0 round`};var mr={"font-size":["rem","px","em"],"line-height":["","rem","px","em"],"letter-spacing":["rem","px","em"],gap:["rem","px","em"],"column-gap":["rem","px","em"],"row-gap":["rem","px","em"],padding:["rem","px","em","%"],margin:["rem","px","em","%"],width:["rem","px","%","em"],height:["rem","px","%","em"],"min-width":["rem","px","%","em"],"max-width":["rem","px","%","em"],"min-height":["rem","px","%","em"],"max-height":["rem","px","%","em"],"border-width":["px","rem","em"],"border-radius":["rem","px","%","em"]};function vo(e){var t,o;return(o=(t=mr[e])==null?void 0:t[0])!=null?o:"px"}function Nn(e){let t=e.match(/^([\d.-]+)(.*)$/);return t?{num:parseFloat(t[1]),unit:t[2]||""}:{num:0,unit:""}}function hr(e,t,o,r){let n=e.trim();if(!n)return"";let i=n.match(/^(-?[\d.]+)\s*(rem|em|px|%)$/i);if(i)return`${parseFloat(i[1])}${i[2].toLowerCase()}`;let s=parseFloat(n);if(!isNaN(s)){if(r){let{unit:l}=Nn(o);return`${s}${l||vo(t)}`}return`${s}${vo(t)}`}return n}function hi(e,t){if(!t||t==="px")return e;if(t==="rem"){let o=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return Math.round(e/o*1e3)/1e3}return e}import{useCallback as xd,useEffect as vd,useRef as vl,useState as Sd}from"react";import{Plus as Sl,X as wd}from"lucide-react";import{jsx as nn,jsxs as qn}from"react/jsx-runtime";var yr=[{name:"blur",label:"Blur",unit:"px",defaultValue:10,min:0,max:100,step:1},{name:"brightness",label:"Brightness",unit:"",defaultValue:1,min:0,max:3,step:.05},{name:"contrast",label:"Contrast",unit:"",defaultValue:1,min:0,max:3,step:.05},{name:"saturate",label:"Saturate",unit:"",defaultValue:1,min:0,max:3,step:.05},{name:"grayscale",label:"Grayscale",unit:"",defaultValue:0,min:0,max:1,step:.05},{name:"sepia",label:"Sepia",unit:"",defaultValue:0,min:0,max:1,step:.05},{name:"invert",label:"Invert",unit:"",defaultValue:0,min:0,max:1,step:.05},{name:"hue-rotate",label:"Hue Rotate",unit:"deg",defaultValue:0,min:0,max:360,step:1},{name:"opacity",label:"Opacity",unit:"",defaultValue:1,min:0,max:1,step:.05}];function Ed(e){if(!e||e==="none")return[];let t=[],o=/([\w-]+)\(([^)]+)\)/g,r;for(;(r=o.exec(e))!==null;){let n=r[1],i=r[2],s=parseFloat(i);isNaN(s)||t.push({name:n,value:s})}return t}function yi(e){return e.length===0?"none":e.map(t=>{var n;let o=yr.find(i=>i.name===t.name),r=(n=o==null?void 0:o.unit)!=null?n:"";return`${t.name}(${t.value}${r})`}).join(" ")}function wl({value:e,onChange:t,accentColor:o,modified:r,panelContentRef:n}){let i=Ed(e),[s,l]=Sd(!1),a=vl(null),c=vl(null);vd(()=>{if(!s)return;let A=C=>{a.current&&!C.composedPath().includes(a.current)&&l(!1)};return document.addEventListener("mousedown",A,!0),()=>document.removeEventListener("mousedown",A,!0)},[s]);let d=yr.filter(A=>!i.some(C=>C.name===A.name)),u=A=>{let C=[...i,{name:A.name,value:A.defaultValue}];t(yi(C)),l(!1)},p=A=>{let C=i.filter((E,I)=>I!==A);t(yi(C))},g=(A,C)=>{let E=i.map((I,$)=>$===A?m(f({},I),{value:C}):I);t(yi(E))},S={width:"100%",padding:"4px 8px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',border:"none",borderRadius:2,outline:"none",backgroundColor:"transparent"},v=xd(A=>{var D;if(!c.current)return{position:"fixed",top:0,left:0};let C=c.current.getBoundingClientRect(),E=c.current.closest('[data-devtools="panel"]'),I=E?E.getBoundingClientRect():{top:0,left:0,bottom:9999},$=(D=n==null?void 0:n.current)==null?void 0:D.getBoundingClientRect(),Z=A*24+8,M=I.bottom-C.bottom<Z;return m(f({position:"fixed"},M?{bottom:I.bottom-C.top+2-I.top}:{top:C.bottom+2-I.top}),{left:$?$.left+4-I.left:C.left-I.left,width:$?$.width-8:140,zIndex:10001})},[n]),y={backgroundColor:"rgba(255, 255, 255, 0.95)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",border:"1px solid rgba(0,0,0,0.1)",borderRadius:4,padding:"4px 0",boxShadow:"0 4px 12px rgba(0,0,0,0.1)"},w={display:"block",width:"100%",padding:"4px 10px",border:"none",backgroundColor:"transparent",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#334155",cursor:"pointer",textAlign:"left"},O=A=>nn("div",{ref:a,style:f(f({},v(A.length)),y),children:A.map(C=>nn("button",{type:"button",onClick:()=>u(C),style:w,onMouseEnter:E=>{E.currentTarget.style.backgroundColor="rgba(0,0,0,0.05)"},onMouseLeave:E=>{E.currentTarget.style.backgroundColor="transparent"},children:C.label},C.name))});return i.length===0?qn("div",{children:[qn("div",{style:{display:"flex",alignItems:"center",gap:4},children:[nn(Rn,{modified:!1,children:nn("input",{type:"text",value:"",placeholder:"\u2014",readOnly:!0,style:m(f({},S),{color:"#999",cursor:"default"})})}),nn("button",{ref:c,type:"button",onClick:()=>l(!s),style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,border:"none",borderRadius:2,backgroundColor:"transparent",color:"#94a3b8",cursor:"pointer",flexShrink:0},children:nn(Sl,{size:12})})]}),s&&O(yr)]}):qn("div",{style:{display:"flex",flexDirection:"column",gap:4,position:"relative"},children:[i.map((A,C)=>{let E=yr.find(I=>I.name===A.name);return E?qn("div",{style:{display:"flex",alignItems:"center",gap:4},children:[nn("span",{style:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:r?o:"#94a3b8",fontWeight:r?600:400,width:56,flexShrink:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:E.label}),nn(Rn,{modified:r,children:qn("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"0 4px"},children:[nn("input",{type:"range",min:E.min,max:E.max,step:E.step,value:A.value,onChange:I=>g(C,parseFloat(I.target.value)),style:{flex:1,height:2,appearance:"none",WebkitAppearance:"none",background:`linear-gradient(to right, ${o} ${(A.value-E.min)/(E.max-E.min)*100}%, rgba(0,0,0,0.1) ${(A.value-E.min)/(E.max-E.min)*100}%)`,borderRadius:1,outline:"none",cursor:"pointer"}}),nn("input",{type:"number",min:E.min,max:E.max,step:E.step,value:E.unit==="px"||E.unit==="deg"?Math.round(A.value):Math.round(A.value*100)/100,onChange:I=>g(C,parseFloat(I.target.value)||0),style:m(f({},S),{width:44,padding:"2px 4px",textAlign:"right",flexShrink:0})}),E.unit&&nn("span",{style:{fontSize:9,color:"#94a3b8",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',flexShrink:0,width:16},children:E.unit})]})}),nn("button",{type:"button",onClick:()=>p(C),style:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,padding:0,border:"none",borderRadius:2,backgroundColor:"transparent",color:"#94a3b8",cursor:"pointer",flexShrink:0},children:nn(wd,{size:10})})]},A.name):null}),d.length>0&&qn("div",{children:[qn("button",{ref:c,type:"button",onClick:()=>l(!s),style:{display:"flex",alignItems:"center",gap:4,padding:"2px 4px",border:"none",borderRadius:2,backgroundColor:"transparent",fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#94a3b8",cursor:"pointer"},children:[nn(Sl,{size:10}),"Add filter"]}),s&&O(d)]})]})}import{useCallback as wo,useEffect as Td,useRef as br,useState as El}from"react";import{AlignHorizontalSpaceAround as Ld,AlignVerticalSpaceAround as Id,Columns3 as Rd,Grid2x2 as Ad,RectangleHorizontal as Pd,Rows3 as Bd,UnfoldHorizontal as kl,UnfoldVertical as Cl}from"lucide-react";import{useCallback as kd,useEffect as Cd,useRef as Yo}from"react";import{jsx as Md}from"react/jsx-runtime";var bi=[0,1,2,4,8,12,16,20,24,28,32];function So({value:e,onChange:t,onPreview:o,onScrubEnd:r,onReset:n,isModified:i,accentColor:s,defaultUnit:l="rem",snapSteps:a,color:c,style:d,children:u}){let p=Yo(null),g=Yo(null),S=Yo(n),v=Yo(i),y=Yo(!1);S.current=n,v.current=i,Cd(()=>{let O=C=>{let E=g.current;if(!E)return;E.hasMoved=!0,y.current=C.shiftKey;let I=E.unit==="rem"||E.unit==="em"?.1:1;E.accum+=C.movementX*I;let $=Math.max(0,Math.round((E.startValue+E.accum)*10)/10);if(C.shiftKey&&a){let Z=E.unit==="rem"||E.unit==="em"?parseFloat(getComputedStyle(document.documentElement).fontSize)||16:1,G=E.unit==="rem"||E.unit==="em"?$*Z:$,M=a[a.length-1];for(let D=0;D<a.length-1;D++){let X=a[D],ee=a[D+1];if(G<=(X+ee)/2){M=X;break}if(G<ee){M=ee;break}}G>a[a.length-1]&&(M=Math.round(G/8)*8),$=E.unit==="rem"||E.unit==="em"?Math.round(M/Z*1e3)/1e3:M}o==null||o(`${$}${E.unit}`)},A=()=>{let C=g.current;if(!C)return;let E=Math.max(0,Math.round((C.startValue+C.accum)*10)/10);if(y.current&&a){let $=C.unit==="rem"||C.unit==="em"?parseFloat(getComputedStyle(document.documentElement).fontSize)||16:1,Z=C.unit==="rem"||C.unit==="em"?E*$:E,G=a[a.length-1];for(let M=0;M<a.length-1;M++){let D=a[M],X=a[M+1];if(Z<=(D+X)/2){G=D;break}if(Z<X){G=X;break}}Z>a[a.length-1]&&(G=Math.round(Z/8)*8),E=C.unit==="rem"||C.unit==="em"?Math.round(G/$*1e3)/1e3:G}let I=C.hasMoved&&E!==C.startValue;g.current=null,document.exitPointerLock(),I?t(`${E}${C.unit}`):C.hasMoved?o==null||o(`${C.startValue}${C.unit}`):v.current&&S.current&&S.current(),r==null||r()};return document.addEventListener("mousemove",O),document.addEventListener("mouseup",A),()=>{document.removeEventListener("mousemove",O),document.removeEventListener("mouseup",A)}},[t,o,r]);let w=kd(O=>{var E;if(O.button!==0)return;O.preventDefault();let A=Nn(e),C=A.unit&&A.unit!=="px"?A.unit:l;g.current={startValue:A.num,unit:C,accum:0,hasMoved:!1},(E=p.current)==null||E.requestPointerLock()},[e,l]);return Md("span",{ref:p,onMouseDown:w,title:i?"Click to reset \xB7 Drag to scrub":"Drag to scrub",style:f({color:i?s||"#3b82f6":c||"#999",padding:"0 4px",display:"flex",alignItems:"center",cursor:"ew-resize"},d),children:u})}import{Fragment as xi,jsx as Ce,jsxs as Ft}from"react/jsx-runtime";function Od({gridCols:e,gridRows:t,gridModified:o,accentColor:r,onColsChange:n,onRowsChange:i}){return Ce(an,{style:{width:100},children:Ft("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 4px"},children:[Ce("input",{type:"number",min:1,max:12,value:e,onChange:s=>n(parseInt(s.target.value)||1),style:m(f({},Wt),{width:32,textAlign:"center",padding:2})}),Ce("span",{style:{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:o?r:"#999",fontWeight:o?600:400,fontSize:11,margin:"0 4px"},children:"\xD7"}),Ce("input",{type:"number",min:1,max:12,value:t,onChange:s=>i(parseInt(s.target.value)||1),style:m(f({},Wt),{width:32,textAlign:"center",padding:2})})]})})}function Ml({element:e,getValue:t,getOriginalValue:o,handleChange:r,isModified:n,onResetProperty:i,isCollapsed:s,onToggle:l,sectionHeaderStyle:a,activeDropdown:c,onDropdownChange:d,panelContentRef:u,accentColor:p,onFieldHover:g,preferredUnit:S,onUnitCycle:v}){let y=d,w=t("display"),O=t("flex-direction"),A=Tl(w,O),C=w==="flex"||w==="inline-flex",E=w==="grid",I=C||E,$=t("width"),Z=t("height"),G=n("width")?$:lr(e,"width"),M=n("height")?Z:lr(e,"height"),D=vi($,G),X=vi(Z,M),ee=t("min-width"),he=t("max-width"),ve=t("min-height"),ae=t("max-height"),Re=Eo(t("padding")),We=t("gap"),Me=t("row-gap"),ne=t("column-gap"),Ae=t("grid-template-columns"),V=t("grid-template-rows"),oe=t("overflow"),Ee=Ae.split(/\s+/).filter(U=>U&&U!=="none").length||1,ce=V.split(/\s+/).filter(U=>U&&U!=="none").length||1,[Ke,Te]=El(!1),xe=c!==null,me=xe||Ke,Ge=xe?.3:Ke?.65:1,xt=({mode:U,icon:Ie,active:Fe})=>Ce("button",{type:"button",onClick:()=>Ll(U,r),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"6px 8px",border:"none",borderRadius:2,backgroundColor:Fe?Kn(p,.15):"transparent",color:Fe?p:"#64748b",cursor:"pointer",fontSize:14},children:Ie}),dt=(U,Ie,Fe)=>{Fe==="fixed"?r(U,Ie):r(U,xr(Fe,Ie))},Ve=U=>{let Ie=Eo(t("padding")),Fe=U||"0";r("padding",`${Ie.top} ${Fe} ${Ie.bottom} ${Fe}`)},z=U=>{let Ie=Eo(t("padding")),Fe=U||"0";r("padding",`${Fe} ${Ie.right} ${Fe} ${Ie.left}`)},[ie,Q]=El({}),Se=wo((U,Ie)=>Fe=>{Ie(Fe),Q(ft=>m(f({},ft),{[U]:Fe}))},[]),Le=wo(U=>{Q(Ie=>{let Fe=f({},Ie);return delete Fe[U],Fe})},[]),Ze=wo(U=>{let Ie=Eo(t("padding"));_e(e,"padding",`${Ie.top} ${U} ${Ie.bottom} ${U}`)},[e,t]),fe=wo(U=>{let Ie=Eo(t("padding"));_e(e,"padding",`${U} ${Ie.right} ${U} ${Ie.left}`)},[e,t]),lt=wo(U=>Ie=>{_e(e,U,Ie)},[e]),Qe=O==="column"||O==="column-reverse",Tt=U=>U==="center"?1:U==="flex-end"||U==="end"?2:0,Bt=Tt(t("justify-content")),st=Tt(t("align-items")),at=Qe?st:Bt,Ot=Qe?Bt:st,tt=br(null),vt=br({x:0,y:0}),$e=br({col:at,row:Ot});$e.current={col:at,row:Ot};let en=wo((U,Ie)=>{let Fe=["flex-start","center","flex-end"];Qe?(r("justify-content",Fe[Ie]),r("align-items",Fe[U])):(r("justify-content",Fe[U]),r("align-items",Fe[Ie]))},[Qe,r]),Kt=br(en);Kt.current=en,Td(()=>{let Ie=Fe=>{let ft=tt.current;if(!ft||!Fe.composedPath().includes(ft))return;Fe.preventDefault(),Fe.stopPropagation(),vt.current.x+=Fe.deltaX,vt.current.y+=Fe.deltaY;let{col:Lt,row:pt}=$e.current,bt=!1;Math.abs(vt.current.x)>=30&&(Lt=Math.max(0,Math.min(2,Lt+(vt.current.x>0?1:-1))),vt.current.x=0,vt.current.y=0,bt=!0),!bt&&Math.abs(vt.current.y)>=30&&(pt=Math.max(0,Math.min(2,pt+(vt.current.y>0?1:-1))),vt.current.x=0,vt.current.y=0,bt=!0),bt&&(Lt!==$e.current.col||pt!==$e.current.row)&&Kt.current(Lt,pt)};return document.addEventListener("wheel",Ie,{passive:!1,capture:!0}),()=>document.removeEventListener("wheel",Ie,{capture:!0})},[]);let rn=()=>Ce("div",{ref:tt,onMouseEnter:()=>{Te(!0),u.current&&(u.current.style.overflowY="hidden")},onMouseLeave:()=>{Te(!1),u.current&&(u.current.style.overflowY="auto")},style:{width:56,height:56,backgroundColor:vn,borderRadius:2,display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gridTemplateRows:"repeat(3, 1fr)",padding:6,gap:2,touchAction:"none"},children:[0,1,2].map(U=>[0,1,2].map(Ie=>Ce("button",{type:"button",onClick:()=>en(Ie,U),style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",border:"none",backgroundColor:"transparent",cursor:"pointer",padding:0},children:Ie===at&&U===Ot?Ce("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",style:{flexShrink:0},children:Ie===0?Ft(xi,{children:[Ce("rect",{x:"1",y:"1.5",width:"8",height:"1.2",rx:"0.5",fill:p}),Ce("rect",{x:"1",y:"4.4",width:"5",height:"1.2",rx:"0.5",fill:p}),Ce("rect",{x:"1",y:"7.3",width:"7",height:"1.2",rx:"0.5",fill:p})]}):Ie===1?Ft(xi,{children:[Ce("rect",{x:"1",y:"1.5",width:"8",height:"1.2",rx:"0.5",fill:p}),Ce("rect",{x:"2.5",y:"4.4",width:"5",height:"1.2",rx:"0.5",fill:p}),Ce("rect",{x:"1.5",y:"7.3",width:"7",height:"1.2",rx:"0.5",fill:p})]}):Ft(xi,{children:[Ce("rect",{x:"1",y:"1.5",width:"8",height:"1.2",rx:"0.5",fill:p}),Ce("rect",{x:"4",y:"4.4",width:"5",height:"1.2",rx:"0.5",fill:p}),Ce("rect",{x:"2",y:"7.3",width:"7",height:"1.2",rx:"0.5",fill:p})]})}):Ce("div",{style:{width:5,height:5,borderRadius:"50%",backgroundColor:"#aaa"}})},`${U}-${Ie}`)))}),mn=n("grid-template-columns")||n("grid-template-rows");return Ft("div",{style:{borderBottom:"1px solid rgba(0,0,0,0.08)"},children:[Ce("div",{style:a,children:Ce("span",{children:I?"Auto layout":"Layout"})}),Ft("div",{style:{padding:"8px 12px"},children:[Ft("div",{style:{display:"flex",gap:2,marginBottom:8,backgroundColor:vn,borderRadius:2,padding:2,opacity:Ge,transition:"opacity 150ms ease"},children:[Ce(xt,{mode:"block",icon:Ce(Pd,{size:16}),active:A==="block"}),Ce(xt,{mode:"flex-col",icon:Ce(Bd,{size:16}),active:A==="flex-col"}),Ce(xt,{mode:"flex-row",icon:Ce(Rd,{size:16}),active:A==="flex-row"}),Ce(xt,{mode:"grid",icon:Ce(Ad,{size:16}),active:A==="grid"})]}),Ft("div",{style:{display:"flex",gap:4,marginBottom:8},children:[Ce(Si,{label:"W",property:"width",cssValue:D==="fixed"?$:`${Math.round(e.getBoundingClientRect().width)}px`,mode:D,onValueChange:U=>r("width",U),onModeChange:U=>{if(U==="fixed"){let Ie=e.getBoundingClientRect();r("width",`${Math.round(Ie.width)}px`)}else r("width",xr(U,$))},modified:n("width"),dimmed:xe&&c!=="width",dropdownOpen:c==="width",onDropdownChange:U=>y(U?"width":null),panelContentRef:u,accentColor:p,onReset:()=>i("width"),minValue:ee!=="none"&&ee!=="0px"&&ee!=="auto"?ee:"",maxValue:he!=="none"&&he!=="auto"?he:"",onMinChange:U=>r("min-width",U||"0"),onMaxChange:U=>r("max-width",U||"none"),onMinReset:()=>i("min-width"),onMaxReset:()=>i("max-width"),minModified:n("min-width"),maxModified:n("max-width")}),Ce(Si,{label:"H",property:"height",cssValue:X==="fixed"?Z:`${Math.round(e.getBoundingClientRect().height)}px`,mode:X,onValueChange:U=>r("height",U),onModeChange:U=>{if(U==="fixed"){let Ie=e.getBoundingClientRect();r("height",`${Math.round(Ie.height)}px`)}else r("height",xr(U,Z))},modified:n("height"),dimmed:xe&&c!=="height",dropdownOpen:c==="height",onDropdownChange:U=>y(U?"height":null),panelContentRef:u,minValue:ve!=="none"&&ve!=="0px"&&ve!=="auto"?ve:"",maxValue:ae!=="none"&&ae!=="auto"?ae:"",onMinChange:U=>r("min-height",U||"0"),onMaxChange:U=>r("max-height",U||"none"),onMinReset:()=>i("min-height"),onMaxReset:()=>i("max-height"),minModified:n("min-height"),maxModified:n("max-height"),accentColor:p,onReset:()=>i("height")})]}),C&&Ft("div",{onMouseEnter:()=>g==null?void 0:g("gap"),onMouseLeave:()=>g==null?void 0:g("element"),style:{display:"flex",gap:8,marginBottom:8},children:[Ce("div",{style:{opacity:xe?.3:1,transition:"opacity 150ms ease"},children:rn()}),Ft("div",{style:{flex:1,opacity:Ge,transition:"opacity 150ms ease"},children:[Ce("div",{onClick:n("gap")?()=>i("gap"):void 0,title:n("gap")?"Click to reset":void 0,style:{fontSize:9,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:n("gap")?p:"#999",fontWeight:n("gap")?600:400,marginBottom:2,cursor:n("gap")?"pointer":"default"},children:"Gap"}),Ce(an,{dimmed:xe,children:Ft("div",{style:{display:"flex",alignItems:"center"},children:[Ce(So,{value:We,onChange:U=>{Le("gap"),r("gap",U)},onPreview:Se("gap",lt("gap")),onScrubEnd:()=>Le("gap"),onReset:()=>i("gap"),isModified:n("gap"),accentColor:p,defaultUnit:S,children:O==="column"||O==="column-reverse"?Ce(Cl,{size:12,strokeWidth:n("gap")?2.5:1.5}):Ce(kl,{size:12,strokeWidth:n("gap")?2.5:1.5})}),Ce(xn,{property:"gap",value:ie.gap||We,onChange:U=>r("gap",U),isModified:n("gap")||"gap"in ie,style:m(f({},Wt),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:S,onUnitCycle:v})]})})]})]}),E&&Ft("div",{onMouseEnter:()=>g==null?void 0:g("gap"),onMouseLeave:()=>g==null?void 0:g("element"),style:{display:"flex",gap:8,marginBottom:8,opacity:Ge,transition:"opacity 150ms ease"},children:[Ce(Od,{gridCols:Ee,gridRows:ce,gridModified:mn,accentColor:p,onColsChange:U=>r("grid-template-columns",`repeat(${U}, 1fr)`),onRowsChange:U=>r("grid-template-rows",`repeat(${U}, 1fr)`)}),Ft("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:4},children:[Ce(an,{dimmed:xe,children:Ft("div",{style:{display:"flex",alignItems:"center"},children:[Ce(So,{value:ne||We,onChange:U=>{Le("column-gap"),r("column-gap",U)},onPreview:Se("column-gap",lt("column-gap")),onScrubEnd:()=>Le("column-gap"),onReset:()=>i("column-gap"),isModified:n("column-gap"),accentColor:p,defaultUnit:S,children:Ce(kl,{size:12,strokeWidth:n("column-gap")?2.5:1.5})}),Ce(xn,{property:"column-gap",value:ie["column-gap"]||ne||We,onChange:U=>r("column-gap",U),isModified:n("column-gap")||"column-gap"in ie,placeholder:"col",style:m(f({},Wt),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:S,onUnitCycle:v})]})}),Ce(an,{dimmed:xe,children:Ft("div",{style:{display:"flex",alignItems:"center"},children:[Ce(So,{value:Me||We,onChange:U=>{Le("row-gap"),r("row-gap",U)},onPreview:Se("row-gap",lt("row-gap")),onScrubEnd:()=>Le("row-gap"),onReset:()=>i("row-gap"),isModified:n("row-gap"),accentColor:p,defaultUnit:S,children:Ce(Cl,{size:12,strokeWidth:n("row-gap")?2.5:1.5})}),Ce(xn,{property:"row-gap",value:ie["row-gap"]||Me||We,onChange:U=>r("row-gap",U),isModified:n("row-gap")||"row-gap"in ie,placeholder:"row",style:m(f({},Wt),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:S,onUnitCycle:v})]})})]})]}),I&&Ft("div",{onMouseEnter:()=>g==null?void 0:g("padding"),onMouseLeave:()=>g==null?void 0:g("element"),style:{display:"flex",gap:4,marginBottom:8,opacity:Ge,transition:"opacity 150ms ease"},children:[Ce(an,{style:{flex:1},dimmed:xe,children:Ft("div",{style:{display:"flex",alignItems:"center"},children:[Ce(So,{value:Re.left,onChange:U=>{Le("padding-h"),Ve(U)},onPreview:Se("padding-h",Ze),onScrubEnd:()=>Le("padding-h"),onReset:()=>i("padding"),isModified:n("padding"),accentColor:p,defaultUnit:S,snapSteps:bi,children:Ce(Ld,{size:12,strokeWidth:n("padding")?2.5:1.5})}),Ce(xn,{property:"padding",value:ie["padding-h"]||Re.left,onChange:U=>Ve(U),isModified:n("padding")||"padding-h"in ie,placeholder:"H pad",style:m(f({},Wt),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:S,onUnitCycle:v})]})}),Ce(an,{style:{flex:1},dimmed:xe,children:Ft("div",{style:{display:"flex",alignItems:"center"},children:[Ce(So,{value:Re.top,onChange:U=>{Le("padding-v"),z(U)},onPreview:Se("padding-v",fe),onScrubEnd:()=>Le("padding-v"),onReset:()=>i("padding"),isModified:n("padding"),accentColor:p,defaultUnit:S,snapSteps:bi,children:Ce(Id,{size:12,strokeWidth:n("padding")?2.5:1.5})}),Ce(xn,{property:"padding",value:ie["padding-v"]||Re.top,onChange:U=>z(U),isModified:n("padding")||"padding-v"in ie,placeholder:"V pad",style:m(f({},Wt),{flex:1,minWidth:0}),unitStyle:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",padding:"0 8px"},preferredUnit:S,onUnitCycle:v})]})})]}),Ft("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#64748b",opacity:Ge,transition:"opacity 150ms ease"},children:[Ce("input",{type:"checkbox",checked:oe==="hidden",onChange:U=>r("overflow",U.target.checked?"hidden":"visible"),style:{margin:0,accentColor:p}}),"Clip content"]})]})]})}import{AlignCenter as Dd,AlignJustify as Hd,AlignLeft as Fd,AlignRight as Nd,Baseline as _d,ChevronDown as zd,WholeWord as $d}from"lucide-react";import{jsx as ct,jsxs as An}from"react/jsx-runtime";var Il={100:"Thin",200:"Extra Light",300:"Light",400:"Regular",500:"Medium",600:"Semi Bold",700:"Bold",800:"Extra Bold",900:"Black"};function Rl({element:e,getValue:t,handleChange:o,isModified:r,onResetProperty:n,isCollapsed:i,onToggle:s,sectionHeaderStyle:l,accentColor:a,colorVariables:c,activeColorDropdown:d,onColorDropdownChange:u,panelContentRef:p,preferredUnit:g,onUnitCycle:S}){var X;let v=t("font-family"),y=t("font-size"),w=t("font-weight"),O=t("line-height"),A=t("letter-spacing"),C=t("text-align"),E=t("color"),I=String(w),$=Il[I]||I,Z=_o(e,E),G=E.includes("var(")?null:zo(Z,c),M=({align:ee,icon:he})=>{let ve=C===ee;return ct("button",{type:"button",onClick:()=>o("text-align",ee),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"6px 8px",border:"none",borderRadius:2,backgroundColor:ve?Kn(a,.15):"transparent",color:ve?a:"#64748b",cursor:"pointer"},children:he})},D=((X=v.split(",")[0])==null?void 0:X.trim().replace(/^["']|["']$/g,""))||"System";return An("div",{style:{borderBottom:"1px solid rgba(0,0,0,0.08)"},children:[ct("div",{style:l,children:ct("span",{children:"Typography"})}),An("div",{style:{padding:"8px 12px",display:"flex",flexDirection:"column",gap:4},children:[ct(an,{children:An("div",{style:{display:"flex",alignItems:"center",padding:"6px 8px"},children:[ct("input",{type:"text",value:v,onChange:ee=>o("font-family",ee.target.value),style:m(f({},Wt),{flex:1,minWidth:0,padding:0,fontWeight:r("font-family")?600:400,color:r("font-family")?a:"inherit"}),title:v}),ct(zd,{size:12,style:{color:"#999",flexShrink:0,marginLeft:4}})]})}),An("div",{style:{display:"flex",gap:4},children:[ct(an,{style:{flex:1},children:ct("select",{value:I,onChange:ee=>o("font-weight",ee.target.value),style:m(f({},Wt),{padding:"6px 8px",paddingLeft:4,paddingRight:20,cursor:"pointer",fontWeight:r("font-weight")?600:400,color:r("font-weight")?a:"inherit"}),children:Object.entries(Il).map(([ee,he])=>ct("option",{value:ee,children:he},ee))})}),ct(an,{style:{flex:1},children:ct("div",{style:{display:"flex",alignItems:"center",position:"relative"},children:ct(xn,{property:"font-size",value:y,onChange:ee=>o("font-size",ee),isModified:r("font-size"),min:1,max:999,style:m(f({},Wt),{padding:"6px 8px",paddingRight:24,fontWeight:r("font-size")?600:400,color:r("font-size")?a:"inherit"}),unitStyle:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999"},preferredUnit:g,onUnitCycle:S})})})]}),An("div",{style:{display:"flex",gap:4},children:[ct(an,{style:{flex:1},children:An("div",{style:{display:"flex",alignItems:"center",padding:"6px 8px",gap:4},children:[ct(_d,{size:12,style:{color:r("line-height")?a:"#999",flexShrink:0}}),ct(xn,{property:"line-height",value:O,onChange:ee=>o("line-height",ee),isModified:r("line-height"),step:.1,min:0,placeholder:"Auto",style:m(f({},Wt),{flex:1,minWidth:0,padding:0,fontWeight:r("line-height")?600:400,color:r("line-height")?a:"inherit"}),showUnit:!1})]})}),ct(an,{style:{flex:1},children:An("div",{style:{display:"flex",alignItems:"center",padding:"6px 8px",gap:4},children:[ct($d,{size:12,style:{color:r("letter-spacing")?a:"#999",flexShrink:0}}),ct(xn,{property:"letter-spacing",value:A,onChange:ee=>o("letter-spacing",ee),isModified:r("letter-spacing"),step:.1,placeholder:"\u2014",style:m(f({},Wt),{flex:1,minWidth:0,padding:0,fontWeight:r("letter-spacing")?600:400,color:r("letter-spacing")?a:"inherit"}),showUnit:!1})]})})]}),An("div",{style:{display:"flex",gap:2,backgroundColor:vn,borderRadius:2,padding:2},children:[ct(M,{align:"left",icon:ct(Fd,{size:14})}),ct(M,{align:"center",icon:ct(Dd,{size:14})}),ct(M,{align:"right",icon:ct(Nd,{size:14})}),ct(M,{align:"justify",icon:ct(Hd,{size:14})})]}),An("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 0"},children:[ct("span",{onClick:r("color")?()=>n("color"):void 0,title:r("color")?"Click to reset":void 0,style:{fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:r("color")?a:"#64748b",fontWeight:r("color")?600:400,cursor:r("color")?"pointer":"default",width:40,flexShrink:0},children:"Color"}),ct("div",{style:{flex:1,minWidth:0},children:ct(wi,{value:E,resolvedValue:Z,colorVariables:c,matchingVariable:G,onChange:ee=>o("color",ee),accentColor:a,modified:r("color"),panelContentRef:p,isDropdownOpen:d==="color",onDropdownChange:ee=>u(ee?"color":null)})})]})]})]})}import{Fragment as Vd,jsx as pe,jsxs as ht}from"react/jsx-runtime";var Pl=[{name:"Background",properties:[{property:"background-color",label:"Color",type:"color"},{property:"opacity",label:"Opacity",type:"number",step:.1,min:0,max:1}]},{name:"Borders",properties:[{property:"border-width",label:"Width",type:"number",min:0,max:20},{property:"border-color",label:"Color",type:"color"},{property:"border-radius",label:"Radius",type:"number",min:0,max:100},{property:"border-style",label:"Style",type:"select",options:["none","solid","dashed","dotted","double"]}]},{name:"Effects",properties:[{property:"box-shadow",label:"Box Shadow",type:"text"},{property:"backdrop-filter",label:"Backdrop Filter",type:"backdrop-filter"},{property:"transform",label:"Transform",type:"text"}]}];function Gd(e,t){let o=t.trim().toLowerCase();switch(e){case"opacity":return o==="1";case"border-width":return o==="0px"||o==="0"||o==="medium";case"border-radius":return o==="0px"||o==="0";case"border-style":return o==="none";case"box-shadow":return o==="none";case"backdrop-filter":return o==="none"||o==="";case"letter-spacing":return o==="normal"||o==="0px"||o==="0";case"background-color":return o==="rgba(0, 0, 0, 0)"||o==="transparent";default:return!1}}function vi(e,t){return!t||e==="auto"||e==="fit-content"||e==="max-content"||e==="min-content"?"hug":e==="100%"||t==="100%"?"fill":"fixed"}function xr(e,t){switch(e){case"hug":return"fit-content";case"fill":return"100%";case"fixed":{let o=Nn(t);if(typeof o.num=="number"&&!isNaN(o.num)){let r=o.unit==="%"?"px":o.unit||"px";return`${o.num}${r}`}return"auto"}}}function Eo(e){let t=e.split(/\s+/).filter(Boolean);return t.length===1?{top:t[0],right:t[0],bottom:t[0],left:t[0]}:t.length===2?{top:t[0],right:t[1],bottom:t[0],left:t[1]}:t.length===3?{top:t[0],right:t[1],bottom:t[2],left:t[1]}:t.length>=4?{top:t[0],right:t[1],bottom:t[2],left:t[3]}:{top:"0px",right:"0px",bottom:"0px",left:"0px"}}function Tl(e,t){return e==="grid"?"grid":e==="flex"||e==="inline-flex"?t==="column"||t==="column-reverse"?"flex-col":"flex-row":"block"}function Ll(e,t){switch(e){case"block":t("display","block");break;case"flex-row":t("display","flex"),t("flex-direction","row");break;case"flex-col":t("display","flex"),t("flex-direction","column");break;case"grid":t("display","grid");break}}var vn="rgba(0, 0, 0, 0.04)",Wt={width:"100%",padding:"4px 8px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',border:"none",borderRadius:2,outline:"none",backgroundColor:"transparent"};function Si({label:e,property:t,cssValue:o,mode:r,onValueChange:n,onModeChange:i,modified:s,dimmed:l,dropdownOpen:a,onDropdownChange:c,panelContentRef:d,accentColor:u="#3b82f6",onReset:p,minValue:g,maxValue:S,onMinChange:v,onMaxChange:y,onMinReset:w,onMaxReset:O,minModified:A,maxModified:C}){let E=Nn(o),I=s?E.unit||vo(t):vo(t),$=!s&&E.unit&&E.unit!==I?hi(E.num,I):E.num,[Z,G]=Yt(!1),[M,D]=Yt(String($)),[X,ee]=Yt(!1),he=on(null),ve=on(null),ae=on(null),Re=on(!1);gn(()=>{Z||D(String($))},[$,Z]),gn(()=>{if(!a)return;let ce=Te=>{ve.current&&!Te.composedPath().includes(ve.current)&&ae.current&&!Te.composedPath().includes(ae.current)&&(c==null||c(!1))},Ke=Te=>{Te.key==="Escape"&&(c==null||c(!1))};return document.addEventListener("mousedown",ce),document.addEventListener("keydown",Ke),()=>{document.removeEventListener("mousedown",ce),document.removeEventListener("keydown",Ke)}},[a,c]),gn(()=>{Z&&he.current&&(he.current.focus(),he.current.select())},[Z]);let We=()=>{let ce=hr(M,t,o,s);n(ce||`${Math.max(0,parseFloat(M)||0)}${I}`),G(!1)},Me=()=>{if(Re.current){Re.current=!1;return}We()},ne=ce=>{if(ce.key==="Enter"){We();return}if(ce.key==="Escape"){Re.current=!0,D(String($)),G(!1);return}if(ce.key==="ArrowUp"||ce.key==="ArrowDown"){ce.preventDefault();let Ke=ce.key==="ArrowUp"?1:-1,Te=ce.shiftKey?8:ce.altKey?.1:1,xe=parseFloat(M)||0,me=Math.round(Math.max(0,xe+Ke*Te)*1e3)/1e3;D(String(me)),n(`${me}${I}`)}},Ae={fixed:"Fixed",hug:"Hug",fill:"Fill"},V={fixed:pe(Al,{size:12}),hug:pe(Yd,{size:12}),fill:pe(Al,{size:12})},oe=()=>{c==null||c(!a)},Ee=()=>{if(!ae.current||!(d!=null&&d.current))return{position:"absolute",top:"100%",left:-4,right:-4,width:"calc(100% + 8px)",marginTop:4};let ce=ae.current.getBoundingClientRect(),Ke=d.current.getBoundingClientRect(),Te=d.current.closest('[data-devtools="panel"]'),xe=Te?Te.getBoundingClientRect():{top:0,left:0};return{position:"fixed",top:ce.bottom+4-xe.top,left:Ke.left+4-xe.left,width:Ke.width-8}};return ht("div",{ref:ae,onMouseEnter:()=>ee(!0),onMouseLeave:()=>ee(!1),style:{flex:1,display:"flex",alignItems:"center",position:"relative",borderRadius:2,border:"1px solid",borderColor:Z?u:X?"rgba(0,0,0,0.15)":"transparent",backgroundColor:vn,transition:"border-color 100ms ease, opacity 150ms ease",opacity:l?.3:1},children:[pe("span",{onClick:s&&p?p:void 0,title:s?"Click to reset":void 0,style:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:s?u:"#999",fontWeight:s?600:400,padding:"0 8px",flexShrink:0,cursor:s?"pointer":"default"},children:e}),r==="fixed"?Z?pe("input",{ref:he,type:"text",inputMode:"numeric",value:M,onChange:ce=>D(ce.target.value),onKeyDown:ne,onBlur:Me,style:m(f({},Wt),{flex:1,minWidth:0,padding:"4px 2px"})}):pe("span",{onClick:()=>G(!0),style:{flex:1,padding:"4px 2px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',cursor:"text"},children:$}):pe("span",{style:{flex:1}}),ht("button",{type:"button",onClick:oe,style:{display:"flex",alignItems:"center",gap:2,padding:"4px 8px",border:"none",outline:"none",backgroundColor:"transparent",color:"#999",fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',cursor:"pointer",flexShrink:0},children:[Ae[r],pe(Ei,{size:12})]}),a&&ht("div",{ref:ve,style:m(f({},Ee()),{backgroundColor:"#ffffff",border:"1px solid rgba(0,0,0,0.1)",borderRadius:0,zIndex:10001,overflow:"hidden",fontSize:12,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'}),children:[ht("button",{type:"button",onClick:()=>{i("fixed"),c==null||c(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",outline:"none",backgroundColor:r==="fixed"?"#f1f5f9":"transparent",color:"#1e293b",fontWeight:r==="fixed"?600:400,cursor:"pointer",textAlign:"left"},children:[V.fixed,ht("span",{children:["Fixed ",t," (",o,")"]}),r==="fixed"&&pe(vr,{size:14,style:{marginLeft:"auto"}})]}),ht("button",{type:"button",onClick:()=>{i("hug"),c==null||c(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",outline:"none",backgroundColor:r==="hug"?"#f1f5f9":"transparent",color:"#1e293b",fontWeight:r==="hug"?600:400,cursor:"pointer",textAlign:"left"},children:[V.hug,pe("span",{children:"Hug contents"}),r==="hug"&&pe(vr,{size:14,style:{marginLeft:"auto"}})]}),ht("button",{type:"button",onClick:()=>{i("fill"),c==null||c(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",outline:"none",backgroundColor:r==="fill"?"#f1f5f9":"transparent",color:"#1e293b",fontWeight:r==="fill"?600:400,cursor:"pointer",textAlign:"left"},children:[V.fill,pe("span",{children:"Fill container"}),r==="fill"&&pe(vr,{size:14,style:{marginLeft:"auto"}})]}),pe("div",{style:{borderTop:"1px solid rgba(0,0,0,0.08)",margin:"4px 0"}}),ht("div",{style:{padding:"8px 12px",display:"flex",flexDirection:"column",gap:4},children:[ht("div",{style:{display:"flex",alignItems:"center",backgroundColor:vn,borderRadius:2,padding:"4px 8px"},children:[pe("span",{onClick:A?ce=>{ce.stopPropagation(),w==null||w()}:void 0,title:A?"Click to reset":void 0,style:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:A?u:"#999",fontWeight:A?600:400,marginRight:8,flexShrink:0,cursor:A?"pointer":"default"},children:"Min"}),pe("input",{type:"text",value:g||"",placeholder:"\u2014",onChange:ce=>v==null?void 0:v(ce.target.value),onClick:ce=>ce.stopPropagation(),style:m(f({},Wt),{flex:1,minWidth:0,padding:0,textAlign:"right",color:A?u:"inherit",fontWeight:A?600:400})})]}),ht("div",{style:{display:"flex",alignItems:"center",backgroundColor:vn,borderRadius:2,padding:"4px 8px"},children:[pe("span",{onClick:C?ce=>{ce.stopPropagation(),O==null||O()}:void 0,title:C?"Click to reset":void 0,style:{fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:C?u:"#999",fontWeight:C?600:400,marginRight:8,flexShrink:0,cursor:C?"pointer":"default"},children:"Max"}),pe("input",{type:"text",value:S||"",placeholder:"\u2014",onChange:ce=>y==null?void 0:y(ce.target.value),onClick:ce=>ce.stopPropagation(),style:m(f({},Wt),{flex:1,minWidth:0,padding:0,textAlign:"right",color:C?u:"inherit",fontWeight:C?600:400})})]})]})]})]})}function an({children:e,style:t,dimmed:o}){let[r,n]=Yt(!1);return pe("div",{onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),style:f({position:"relative",borderRadius:2,border:"1px solid",borderColor:r?"rgba(0,0,0,0.15)":"transparent",backgroundColor:vn,transition:"border-color 100ms ease, opacity 150ms ease",opacity:o?.3:1},t),children:e})}function Rn({children:e}){let[t,o]=Yt(!1);return pe("div",{onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{position:"relative",borderRadius:2,border:"1px solid",borderColor:t?"rgba(0,0,0,0.15)":"transparent",backgroundColor:vn,transition:"border-color 100ms ease"},children:e})}function xn({property:e,value:t,onChange:o,isModified:r=!1,step:n=1,min:i,max:s,style:l,placeholder:a,showUnit:c=!0,unitStyle:d,preferredUnit:u,onUnitCycle:p}){let g=Nn(t),S=vo(e),v=mr[e],w=u&&v&&v.includes(u)?u:S,O=r&&g.unit||w,A=!r&&g.unit&&g.unit!==O?hi(g.num,O):g.num,[C,E]=Yt(!1),[I,$]=Yt(""),Z=Me=>{E(!0),$(String(A||"")),requestAnimationFrame(()=>Me.target.select())},G=()=>{if(E(!1),I.trim()){let Me=hr(I,e,t,r);Me&&o(Me)}},M=Me=>{let ne=Me.target.value;$(ne);let Ae=ne.trim(),V=Ae.match(/^(-?[\d.]+)\s*(rem|em|px|%)$/i),oe=Ae.match(/^(-?[\d.]+)$/);if(V){let Ee=parseFloat(V[1]);isNaN(Ee)||o(`${Ee}${V[2].toLowerCase()}`)}else if(oe){let Ee=parseFloat(oe[1]);isNaN(Ee)||o(`${Ee}${O}`)}},D=Me=>{if(Me.key==="Enter"){if(I.trim()){let ne=hr(I,e,t,r);ne&&o(ne)}Me.target.blur();return}if(Me.key==="ArrowUp"||Me.key==="ArrowDown"){Me.preventDefault();let ne=Me.shiftKey?10:Me.altKey?.1:1,Ae=(Me.key==="ArrowUp"?1:-1)*n*ne,V=parseFloat(I)||A||0,oe=Math.round((V+Ae)*1e3)/1e3;i!==void 0&&(oe=Math.max(i,oe)),s!==void 0&&(oe=Math.min(s,oe)),$(String(oe)),o(`${oe}${O}`)}},X=/^-?[\d.]/.test(t.trim()),ee=C?I:X?String(A):"",ve=C&&/\s*(rem|em|px|%)\s*$/i.test(I)?"":O,ae=p&&(ve==="rem"||ve==="px"),Re={fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999",pointerEvents:"none"},We=m(f({},d!=null?d:Re),{pointerEvents:"auto",cursor:"pointer"});return ht(Vd,{children:[pe("input",{type:"text",inputMode:"decimal",value:ee,onFocus:Z,onBlur:G,onChange:M,onKeyDown:D,placeholder:a,style:l}),c&&ve&&pe("span",{style:ae?We:d!=null?d:Re,onClick:ae?p:void 0,title:ae?"Click to switch units":void 0,children:ve})]})}function wi({value:e,resolvedValue:t,colorVariables:o,matchingVariable:r,onChange:n,accentColor:i="#3b82f6",modified:s,panelContentRef:l,isDropdownOpen:a,onDropdownChange:c}){let[d,u]=Yt(!1),p=!e.includes("var(")&&r?r.usage:e,[g,S]=Yt(p),[v,y]=Yt(!1),[w,O]=Yt(!1),[A,C]=Yt(!1),E=on(null),I=on(null),$=on(null),Z=a!==void 0?a:v,G=c||y,M=Mn(()=>{if(!$.current)return{position:"fixed",top:0,left:0,width:200};let ne=$.current.getBoundingClientRect(),Ae=$.current.closest('[data-devtools="panel"]'),V=Ae?Ae.getBoundingClientRect():{top:0,left:0};if(l!=null&&l.current){let oe=l.current.getBoundingClientRect();return{position:"fixed",top:ne.bottom+4-V.top,left:oe.left+4-V.left,width:oe.width-8}}return{position:"fixed",top:ne.bottom+4-V.top,left:ne.left-V.left,width:ne.width}},[l]);gn(()=>{if(!d){let ne=!e.includes("var(")&&r?r.usage:e;S(ne)}},[e,d,r]),gn(()=>{if(!Z&&!w)return;let ne=V=>{$.current&&!V.composedPath().includes($.current)&&(G(!1),O(!1))},Ae=V=>{V.key==="Escape"&&(G(!1),O(!1))};return document.addEventListener("mousedown",ne),document.addEventListener("keydown",Ae),()=>{document.removeEventListener("mousedown",ne),document.removeEventListener("keydown",Ae)}},[Z,w]),gn(()=>{d&&E.current&&(E.current.focus(),E.current.select())},[d]);let D=Sr(()=>{if(!g||g.startsWith("#")||g.startsWith("rgb")||g.startsWith("hsl")||g.startsWith("oklch"))return[];let ne=g.toLowerCase();return o.filter(Ae=>Ae.name.toLowerCase().includes(ne)||Ae.usage.toLowerCase().includes(ne)).slice(0,8)},[g,o]),X=()=>{n(g),u(!1),O(!1)},ee=ne=>{S(ne),ne.includes("var")||ne.includes("--")||ne.length>0&&!ne.startsWith("#")?O(!0):O(!1)},he=ne=>{S(ne.usage),n(ne.usage),G(!1),O(!1),u(!1)},ve=()=>{setTimeout(()=>{!Z&&!w&&X()},150)},ae=ne=>{ne.key==="Enter"?X():ne.key==="Escape"&&(S(e),u(!1),O(!1))},Re=Sr(()=>{let ne=t.trim().toLowerCase();if(ne.startsWith("#"))return ne.length===4?`#${ne[1]}${ne[1]}${ne[2]}${ne[2]}${ne[3]}${ne[3]}`:ne.slice(0,7);let Ae=ne.match(/rgba?\((\d+),?\s*(\d+),?\s*(\d+)/);if(Ae){let oe=parseInt(Ae[1],10).toString(16).padStart(2,"0"),Ee=parseInt(Ae[2],10).toString(16).padStart(2,"0"),ce=parseInt(Ae[3],10).toString(16).padStart(2,"0");return`#${oe}${Ee}${ce}`}let V=ne.match(/oklch\(\s*([\d.]+)/);if(V){let oe=Math.max(0,Math.min(1,parseFloat(V[1]))),Ee=Math.round(oe*255).toString(16).padStart(2,"0");return`#${Ee}${Ee}${Ee}`}return"#000000"},[t]),We=ne=>{let Ae=ne.target.value;S(Ae),n(Ae)},Me=e.includes("var(");return ht("div",{ref:$,onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),style:{position:"relative",borderRadius:2,border:"1px solid",borderColor:d?i:A?"rgba(0,0,0,0.15)":"transparent",backgroundColor:vn,transition:"border-color 100ms ease",overflow:"hidden"},children:[ht("div",{style:{display:"flex",alignItems:"center",minWidth:0},children:[ht("div",{style:{position:"relative",marginLeft:8,flexShrink:0},children:[pe("input",{type:"color",value:Re,onChange:We,style:{width:12,height:12,padding:0,border:"none",cursor:"pointer",opacity:0,position:"absolute",top:0,left:0}}),pe("div",{style:{width:12,height:12,borderRadius:2,backgroundColor:t,border:"1px solid rgba(0,0,0,0.1)",pointerEvents:"none"}})]}),d?pe("input",{ref:E,type:"text",value:g,onChange:ne=>ee(ne.target.value),onKeyDown:ae,onBlur:ve,style:m(f({},Wt),{flex:1,minWidth:0})}):pe("span",{onClick:()=>u(!0),style:{flex:1,minWidth:0,padding:"4px 8px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',cursor:"text",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:s?i:"inherit"},title:p,children:p}),o.length>0&&pe("button",{type:"button",onClick:()=>G(!Z),style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:24,border:"none",background:"none",cursor:"pointer",color:"#999",flexShrink:0},children:pe(Ei,{size:12})})]}),w&&D.length>0&&pe("div",{style:m(f({},M()),{backgroundColor:"#ffffff",border:"1px solid rgba(0,0,0,0.1)",borderRadius:0,zIndex:10001,maxHeight:200,overflowY:"auto",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'}),children:D.map(ne=>ht("button",{type:"button",onClick:()=>he(ne),style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",backgroundColor:"transparent",color:"#1e293b",cursor:"pointer",textAlign:"left",fontSize:12},children:[pe("div",{style:{width:14,height:14,borderRadius:2,backgroundColor:ne.value,border:"1px solid rgba(0,0,0,0.1)",flexShrink:0}}),pe("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:ne.name})]},ne.name))}),Z&&pe("div",{ref:I,style:m(f({},M()),{backgroundColor:"#ffffff",border:"1px solid rgba(0,0,0,0.1)",borderRadius:0,zIndex:10001,maxHeight:280,overflowY:"auto",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'}),children:o.map(ne=>ht("button",{type:"button",onClick:()=>he(ne),style:{width:"100%",display:"flex",alignItems:"center",gap:8,padding:"10px 12px",border:"none",backgroundColor:p===ne.usage||e===ne.usage?"#f1f5f9":"transparent",color:"#1e293b",fontWeight:p===ne.usage||e===ne.usage?600:400,cursor:"pointer",textAlign:"left",fontSize:12},children:[pe("div",{style:{width:14,height:14,borderRadius:2,backgroundColor:ne.value,border:"1px solid rgba(0,0,0,0.1)",flexShrink:0}}),pe("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:ne.name}),(p===ne.usage||e===ne.usage)&&pe(vr,{size:14,style:{marginLeft:"auto",flexShrink:0}})]},ne.name))})]})}function Bl({element:e,elementInfo:t,selector:o,styleModifications:r,dispatch:n,onClose:i,onHover:s,accentColor:l="#3b82f6",toolbarRef:a}){var dt,Ve;let c=on(null),d=on(null),[u,p]=Yt(()=>{try{return!!localStorage.getItem("devtools-panel-position")}catch(z){return!1}});gn(()=>{if(u)return;let z=setTimeout(()=>p(!0),50);return()=>clearTimeout(z)},[u]);let[g,S]=Yt(null),[v,y]=Yt(null),w=g!==null||v!==null,[O,A]=Yt("rem"),C=Mn(()=>{A(z=>z==="rem"?"px":"rem")},[]),E=on(new Map),[I,$]=Yt(""),Z=Sr(()=>ni(),[]);gn(()=>{let z=ie=>{var Se;if(ie.key!=="Escape")return;let Q=document.activeElement;Q&&((Se=c.current)!=null&&Se.contains(Q))||i()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[i]);let G=on({top:0,left:0,maxHeight:400}),[,M]=Yt(0),D="devtools-panel-position",X=on({x:0,y:0}),ee=on(null),he=on(!1);gn(()=>{try{let z=localStorage.getItem(D);if(z){let ie=JSON.parse(z);typeof ie.top=="number"&&typeof ie.left=="number"&&(he.current=!0,G.current=m(f({},G.current),{top:ie.top,left:ie.left}))}}catch(z){}},[]),gn(()=>{let z=Q=>{var $e;let Se=ee.current;if(!Se)return;let Le=Se.startOffsetX+(Q.clientX-Se.startX),Ze=Se.startOffsetY+(Q.clientY-Se.startY),fe=280,lt=16,Qe=Math.max(lt,Math.min(window.innerWidth-fe-lt,G.current.left+Le)),Tt=Math.max(lt,G.current.top+Ze);X.current={x:Qe-G.current.left,y:Tt-G.current.top};let Bt=c.current,st=Bt==null?void 0:Bt.parentElement;if(!st)return;st.style.top=`${Tt}px`,st.style.left=`${Qe}px`;let at=($e=a==null?void 0:a.current)==null?void 0:$e.getBoundingClientRect(),Ot=window.innerHeight-16;at&&Qe+fe>at.left&&(Ot=at.top-8);let tt=Math.max(0,Tt),vt=Math.max(200,Ot-tt);Bt&&(Bt.style.maxHeight=`${vt}px`)},ie=()=>{if(!ee.current)return;let Q=G.current.top+X.current.y,Se=G.current.left+X.current.x;G.current=m(f({},G.current),{top:Q,left:Se}),X.current={x:0,y:0},he.current=!0;try{localStorage.setItem(D,JSON.stringify({top:Q,left:Se}))}catch(Le){}ee.current=null};return window.addEventListener("mousemove",z),window.addEventListener("mouseup",ie),()=>{window.removeEventListener("mousemove",z),window.removeEventListener("mouseup",ie)}},[]);let ve=Mn(z=>{z.button!==0||z.target.closest("button")||(z.preventDefault(),ee.current={startX:z.clientX,startY:z.clientY,startOffsetX:X.current.x,startOffsetY:X.current.y})},[]);gn(()=>{X.current={x:0,y:0};let z=(Se=!1)=>{var Ot;let Le=c.current,Ze=280,fe=8,lt,Qe;if(he.current)lt=G.current.top,Qe=G.current.left;else{let tt=e.getBoundingClientRect();Qe=tt.right+fe,lt=tt.top,Qe+Ze>window.innerWidth-fe&&(Qe=tt.left-Ze-fe),Qe<fe&&(Qe=Math.max(fe,(window.innerWidth-Ze)/2))}let Tt=(Ot=a==null?void 0:a.current)==null?void 0:Ot.getBoundingClientRect(),Bt=window.innerHeight-16;Tt&&Qe+Ze>Tt.left&&(Bt=Tt.top-fe);let st=Math.max(0,lt),at=Math.max(200,Bt-st);if(G.current={top:lt,left:Qe,maxHeight:at},Se&&Le){let tt=Le.parentElement;tt&&!he.current&&(tt.style.top=`${lt+X.current.y}px`,tt.style.left=`${Qe+X.current.x}px`),Le.style.maxHeight=`${at}px`}else M(tt=>tt+1)};z(!1);let ie=()=>z(!0),Q=()=>z(!1);return window.addEventListener("scroll",ie,{passive:!0}),window.addEventListener("resize",Q,{passive:!0}),()=>{window.removeEventListener("scroll",ie),window.removeEventListener("resize",Q)}},[e]),gn(()=>{let z=c.current;if(!z)return;let ie=Q=>{let Se=d.current;if(!Se){Q.preventDefault();return}let{scrollTop:Le,scrollHeight:Ze,clientHeight:fe}=Se,lt=Le<=0&&Q.deltaY<0,Qe=Le+fe>=Ze&&Q.deltaY>0;(lt||Qe)&&Q.preventDefault()};return z.addEventListener("wheel",ie,{passive:!1}),()=>z.removeEventListener("wheel",ie)},[]);let ae=Sr(()=>r.find(z=>z.selector===o),[r,o]),Re=Mn(z=>{let ie=ae==null?void 0:ae.changes.find(Q=>Q.property===z);if(ie)return ie.modified;if(z.includes("color")){let Q=Zr(e,z);if(Q&&Q.includes("var("))return Q}return Ho(e,z)},[e,ae]),We=Mn(z=>{if(E.current.has(z))return E.current.get(z);let ie=ae==null?void 0:ae.changes.find(Se=>Se.property===z);if(ie)return ie.original;let Q=Ho(e,z);return E.current.set(z,Q),Q},[e,ae]),Me=Mn((z,ie)=>{let Q=We(z);_e(e,z,ie),z==="backdrop-filter"&&_e(e,"-webkit-backdrop-filter",ie),n({type:"MODIFY_STYLE",payload:{selector:o,element:t,property:z,original:Q,modified:ie}})},[e,o,t,n,We]),ne=Mn(()=>{ti(o,r);let z=r.find(ie=>ie.selector===o);if(z)for(let ie of z.changes)n({type:"CLEAR_STYLE",payload:{selector:o,property:ie.property}});E.current.clear()},[o,r,n]),Ae=Mn(z=>{let ie=r.find(Se=>Se.selector===o);ie!=null&&ie.changes.find(Se=>Se.property===z)&&e instanceof HTMLElement&&(e.style.removeProperty(z),n({type:"CLEAR_STYLE",payload:{selector:o,property:z}}),E.current.delete(z))},[e,o,r,n]),V=Mn(()=>{let z=I.split(";").map(ie=>ie.trim()).filter(ie=>ie);for(let ie of z){let Q=ie.indexOf(":");if(Q>0){let Se=ie.slice(0,Q).trim(),Le=ie.slice(Q+1).trim();Se&&Le&&Me(Se,Le)}}$("")},[I,Me]),oe=Mn(z=>{var ie;return(ie=ae==null?void 0:ae.changes.some(Q=>Q.property===z))!=null?ie:!1},[ae]),Ee=z=>{var Ze;let ie=Re(z.property),Q=oe(z.property),Se=!Q&&Gd(z.property,ie),Le={width:"100%",padding:"4px 8px",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',border:"none",borderRadius:2,outline:"none",backgroundColor:"transparent"};if(Se&&z.type!=="backdrop-filter")return pe(Rn,{modified:!1,children:pe("input",{type:"text",value:"",placeholder:"\u2014",onFocus:()=>{},onChange:fe=>Me(z.property,fe.target.value),style:m(f({},Le),{color:"#999"})})});switch(z.type){case"color":{let fe=_o(e,ie),lt=ie.includes("var(")?null:zo(fe,Z);return pe(wi,{value:ie,resolvedValue:fe,colorVariables:Z,matchingVariable:lt,onChange:Qe=>Me(z.property,Qe),accentColor:l,modified:Q,panelContentRef:d,isDropdownOpen:v===z.property,onDropdownChange:Qe=>y(Qe?z.property:null)})}case"number":{if(!!mr[z.property])return pe(Rn,{modified:Q,children:pe(xn,{property:z.property,value:ie,onChange:Qe=>Me(z.property,Qe),isModified:Q,min:z.min,max:z.max,step:z.step||1,style:m(f({},Le),{paddingRight:32}),unitStyle:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",fontSize:10,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#999"},preferredUnit:O,onUnitCycle:C})});let{num:lt}=Nn(ie);return pe(Rn,{modified:Q,children:pe("input",{type:"number",value:lt,min:z.min,max:z.max,step:z.step||1,onChange:Qe=>Me(z.property,Qe.target.value),style:Le})})}case"select":return pe(Rn,{modified:Q,children:ht("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[pe("select",{value:ie,onChange:fe=>Me(z.property,fe.target.value),style:m(f({},Le),{cursor:"pointer",paddingLeft:4,paddingRight:24,appearance:"none",WebkitAppearance:"none"}),children:(Ze=z.options)==null?void 0:Ze.map(fe=>pe("option",{value:fe,children:fe},fe))}),pe("div",{style:{position:"absolute",right:4,top:"50%",transform:"translateY(-50%)",pointerEvents:"none",color:"#999",display:"flex",alignItems:"center"},children:pe(Ei,{size:12})})]})});case"spacing":return pe(Rn,{modified:Q,children:pe("input",{type:"text",value:ie,onChange:fe=>Me(z.property,fe.target.value),placeholder:"e.g., 10px or 10px 20px",style:Le})});case"backdrop-filter":return pe(wl,{value:ie,onChange:fe=>Me(z.property,fe),accentColor:l,modified:Q,panelContentRef:d});default:return pe(Rn,{modified:Q,children:pe("input",{type:"text",value:ie,onChange:fe=>Me(z.property,fe.target.value),style:Le})})}},ce=(dt=ae==null?void 0:ae.changes.length)!=null?dt:0,Ke=(Ve=ae==null?void 0:ae.captured)!=null?Ve:!1,Te=m(f({position:"fixed",top:G.current.top,left:G.current.left,width:280,maxHeight:G.current.maxHeight,backgroundColor:"rgba(255, 255, 255, 0.85)",backdropFilter:"blur(32px)",WebkitBackdropFilter:"blur(32px)"},bn),{zIndex:1e4,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',fontSize:12,overflow:"hidden",display:"flex",flexDirection:"column",opacity:u?1:0,transition:"opacity 150ms ease"}),xe={display:"flex",alignItems:"center",justifyContent:"space-between",margin:"3px 3px 0",padding:"8px 7px 8px 12px",borderBottom:"1px solid rgba(0,0,0,0.1)",backgroundColor:"#f8fafc",cursor:ee.current?"grabbing":"grab"},me={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 12px 6px",userSelect:"none",fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',fontWeight:600,color:"#475569"},Ge={display:"flex",alignItems:"center",padding:"4px 12px",gap:8},xt={width:80,fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:"#64748b",flexShrink:0};return pe("div",{"data-devtools":"panel-wrapper",style:{position:"fixed",top:G.current.top+X.current.y,left:G.current.left+X.current.x,zIndex:1e4,pointerEvents:"none"},children:ht("div",{ref:c,"data-devtools":"panel",style:m(f({},Te),{position:"relative",top:0,left:0,zIndex:0,pointerEvents:"auto"}),onMouseEnter:()=>s==null?void 0:s("element"),onMouseLeave:()=>s==null?void 0:s(null),children:[ht("div",{style:xe,onMouseDown:ve,children:[ht("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[pe("span",{style:{fontWeight:600,fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.tagName}),ce>0&&pe("span",{style:{backgroundColor:Ke?"#999999":l,color:"#fff",fontSize:9,padding:"1px 4px",borderRadius:2},children:ce})]}),ht("div",{style:{display:"flex",gap:4},children:[ce>0&&pe("button",{type:"button",onClick:ne,title:"Reset all changes",style:{display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,border:"none",background:"none",cursor:"pointer",color:"#64748b",borderRadius:2},children:pe(Wd,{size:14})}),pe("button",{type:"button",onClick:i,title:"Close",style:{display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,border:"none",background:"none",cursor:"pointer",color:"#64748b",borderRadius:2},children:pe(jd,{size:14})})]})]}),ht("div",{ref:d,style:{flex:1,overflowY:"auto",margin:"0 3px 3px"},children:[pe("div",{style:{opacity:v?.3:1,transition:"opacity 150ms ease"},children:pe(Ml,{element:e,getValue:Re,getOriginalValue:We,handleChange:Me,isModified:oe,onResetProperty:Ae,isCollapsed:!1,onToggle:()=>{},sectionHeaderStyle:me,activeDropdown:g,onDropdownChange:S,panelContentRef:d,accentColor:l,onFieldHover:s,preferredUnit:O,onUnitCycle:C})}),pe("div",{style:{opacity:g?.3:1,transition:"opacity 150ms ease"},children:pe(Rl,{element:e,getValue:Re,handleChange:Me,isModified:oe,onResetProperty:Ae,isCollapsed:!1,onToggle:()=>{},sectionHeaderStyle:me,accentColor:l,colorVariables:Z,activeColorDropdown:v,onColorDropdownChange:y,panelContentRef:d,preferredUnit:O,onUnitCycle:C})}),Pl.map((z,ie)=>{let Q=ie===Pl.length-1,Se=v&&z.properties.some(Ze=>Ze.property===v);return ht("div",{style:{borderBottom:Q?"none":"1px solid rgba(0,0,0,0.08)",opacity:w&&!Se?.3:1,transition:"opacity 150ms ease"},children:[pe("div",{style:me,children:pe("span",{children:z.name})}),pe("div",{style:{padding:"4px 0"},children:z.properties.map(Ze=>{let fe=oe(Ze.property),lt=Se&&Ze.property!==v;return ht("div",{style:m(f({},Ge),{opacity:lt?.3:1,transition:"opacity 150ms ease"}),children:[pe("span",{onClick:fe?()=>Ae(Ze.property):void 0,title:fe?"Click to reset":void 0,style:m(f({},xt),{color:fe?l:"#64748b",fontWeight:fe?600:400,cursor:fe?"pointer":"default"}),children:Ze.label}),pe("div",{style:{flex:1,minWidth:0,overflow:"hidden"},children:Ee(Ze)})]},Ze.property)})})]},z.name)}),ht("div",{style:{opacity:w?.3:1,transition:"opacity 150ms ease"},children:[pe("div",{style:me,children:pe("span",{children:"Raw CSS"})}),ht("div",{style:{padding:"8px 12px"},children:[pe("textarea",{value:I,onChange:z=>$(z.target.value),placeholder:"property: value; ...",style:{width:"100%",height:60,padding:8,fontSize:11,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',border:"1px solid rgba(0,0,0,0.1)",borderRadius:2,resize:"vertical",outline:"none"}}),I.trim()&&pe("button",{type:"button",onClick:V,style:{marginTop:4,padding:"4px 8px",width:"100%",fontSize:11,border:"none",borderRadius:2,backgroundColor:l,color:"#fff",cursor:"pointer",opacity:I.trim()?1:.5},children:"Apply"})]})]})]})]})})}import{useEffect as Ud,useLayoutEffect as Jd,useState as Xd}from"react";import{Fragment as Qd,jsx as Qn,jsxs as qd}from"react/jsx-runtime";var ki=["flex-start","center","flex-end"],Ci=["flex-start","center","flex-end"];function Kd(e){return e==="normal"||e==="flex-start"||e==="start"?"flex-start":e==="flex-end"||e==="end"?"flex-end":e==="center"?"center":null}function Zd(e){return e==="normal"||e==="stretch"||e==="flex-start"||e==="start"?"flex-start":e==="flex-end"||e==="end"?"flex-end":e==="center"?"center":null}function Ol(e){let t=Array.from(e.children);if(t.length===0)return null;let o=1/0,r=1/0,n=-1/0,i=-1/0;for(let s of t){let l=s.getBoundingClientRect();l.width===0&&l.height===0||(l.top<o&&(o=l.top),l.left<r&&(r=l.left),l.bottom>n&&(n=l.bottom),l.right>i&&(i=l.right))}return o===1/0?null:new DOMRect(r,o,i-r,n-o)}function Dl({element:e,modifier:t,accentColor:o,refreshKey:r=0}){let[n,i]=Xd(null);if(Ud(()=>{if(!e){i(null);return}let v=()=>i(Ol(e));return v(),window.addEventListener("scroll",v,{passive:!0}),window.addEventListener("resize",v,{passive:!0}),()=>{window.removeEventListener("scroll",v),window.removeEventListener("resize",v)}},[e]),Jd(()=>{e&&i(Ol(e))},[e,r]),!n)return null;let s=n,l=window.getComputedStyle(e),a=l.display;if(a!=="flex"&&a!=="inline-flex")return null;let c=l.flexDirection,d=c==="column"||c==="column-reverse"?"vertical":"horizontal",u=d==="horizontal"?"vertical":"horizontal",p=[];if(t==="shift"){let v=Kd(l.justifyContent);if(v){let y=ki.indexOf(v);d==="horizontal"?(y>0&&p.push("left"),y<ki.length-1&&p.push("right")):(y>0&&p.push("up"),y<ki.length-1&&p.push("down"))}}else{let v=Zd(l.alignItems);if(v){let y=Ci.indexOf(v);u==="horizontal"?(y>0&&p.push("left"),y<Ci.length-1&&p.push("right")):(y>0&&p.push("up"),y<Ci.length-1&&p.push("down"))}}if(p.length===0)return null;let g=14,S=7;return Qn(Qd,{children:p.map(v=>{let y,w;switch(v){case"right":y=s.right+g,w=s.top+s.height/2;break;case"left":y=s.left-g,w=s.top+s.height/2;break;case"down":y=s.left+s.width/2,w=s.bottom+g;break;case"up":y=s.left+s.width/2,w=s.top-g;break}let O=v==="right"?0:v==="left"?180:v==="down"?90:-90,A={position:"fixed",left:y-S,top:w-S,width:S*2,height:S*2,pointerEvents:"none",zIndex:9997};return Qn("div",{"data-devtools":"swipe-hint",style:A,children:Qn("svg",{width:S*2,height:S*2,viewBox:"-7 -7 14 14",style:{overflow:"visible"},children:qd("g",{transform:`rotate(${O})`,children:[Qn("line",{x1:"-5",y1:"0",x2:"3",y2:"0",stroke:"#fff",strokeWidth:"4",strokeLinecap:"round"}),Qn("polyline",{points:"0,-4 5,0 0,4",fill:"none",stroke:"#fff",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),Qn("line",{x1:"-5",y1:"0",x2:"3",y2:"0",stroke:o,strokeWidth:"1.5",strokeLinecap:"round"}),Qn("polyline",{points:"0,-4 5,0 0,4",fill:"none",stroke:o,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})},v)})})}import{useEffect as eu,useLayoutEffect as tu,useState as nu}from"react";import{jsx as Mi,jsxs as Ti}from"react/jsx-runtime";function ou(e,t){let o=e.match(/^oklch\(([^)]+)\)$/i);return o?`oklch(${o[1]} / ${t})`:`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}function Hl({element:e,fontSize:t,lineHeight:o,accentColor:r,hoveredProperty:n,draggingProperty:i,cursorViewport:s}){let[l,a]=nu(null);if(eu(()=>{if(!e){a(null);return}let w=()=>{a(mo(e))};return w(),window.addEventListener("scroll",w,{passive:!0}),window.addEventListener("resize",w,{passive:!0}),()=>{window.removeEventListener("scroll",w),window.removeEventListener("resize",w)}},[e]),tu(()=>{e&&a(mo(e))},[e,t,o]),!l)return null;let c=l.width,d=l.height,u=ou(r,.2),p=i!=null?i:n,g=8,S=2,v={position:"fixed",top:l.top,left:l.left,width:c,height:d,pointerEvents:"none",zIndex:9996,overflow:"visible"},y=w=>w==="font-size"?`${Math.round(t)}`:(t>0?o/t:1.2).toFixed(2).replace(/\.?0+$/,"");return Ti("div",{"data-devtools":"text-handles",style:v,children:[Ti("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:`0 0 ${c} ${d}`,children:[Mi("rect",{x:"0.5",y:"0.5",width:Math.max(0,c-1),height:Math.max(0,d-1),fill:"none",stroke:u,strokeWidth:"1"}),(p==="font-size"||!p)&&Mi("rect",{x:c-S/2,y:d/2-g/2,width:S,height:g,fill:r,stroke:"#ffffff",strokeWidth:p==="font-size"?4:2,paintOrder:"stroke"}),(p==="line-height"||!p)&&Mi("rect",{x:c/2-g/2,y:d-S/2,width:g,height:S,fill:r,stroke:"#ffffff",strokeWidth:p==="line-height"?4:2,paintOrder:"stroke"})]}),s&&p&&(()=>{let w=p==="font-size"?"Aa":"Lh",O=y(p);return Ti("div",{style:{position:"fixed",left:s.x+8,top:s.y-28,background:r,color:"#fff",fontSize:11,fontWeight:600,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1,padding:"4px 4px",borderRadius:0,whiteSpace:"nowrap",pointerEvents:"none",zIndex:9997},children:[w," ",O]})})()]})}import{Fragment as Co,jsx as ot,jsxs as ko}from"react/jsx-runtime";var Fl=8,Ii=[0,1,2,4,8,12,16,20,24,28,32],Ri="devtools-active-text";function Nl(e,t,o=0){let r=e.left+window.scrollX+4,n=t==="top-left"?e.top+window.scrollY-Xn-o*Xn+4:e.bottom+window.scrollY+4-1+o*Xn,i=window.scrollY+4,s=window.scrollY+window.innerHeight-Xn-4;return n<i?n=e.top+window.scrollY+4:n>s&&(n=Math.max(e.top+window.scrollY+4,s)),{x:r,y:n}}function _l({state:e,dispatch:t,onScreenshot:o,inFlightAnnotationIds:r,inFlightStyleSelectors:n,inFlightSelectorColors:i,onAttachImages:s,onReply:l,onViewThread:a,onCloseThread:c,onModelComponentsAdd:d,onModelComponentFocus:u,onModelComponentHover:p,modelComponentNames:g,modelPanelHoveredComponent:S,modelSpacingTokenHover:v,highlightedAnnotationIds:y,externalCanvasRef:w,toolbarRef:O}){var ss,ls,as,cs,ds,us,ps,fs,gs;let{canvasRef:A,redrawAll:C,resizeCanvas:E}=$s(),I=At(h=>{A.current=h,w&&(w.current=h)},[w,A]),$=Ct(!1);Vt(()=>{let h=A.current;if(!h)return;let x=()=>{$.current&&($.current=!1,h.style.pointerEvents="")},J=T=>{T.button===0&&$.current&&x()};return window.addEventListener("mousedown",J),()=>window.removeEventListener("mousedown",J)},[A]);let[Z,G]=it(!1),[M,D]=it(()=>{if(typeof window=="undefined")return null;try{let h=localStorage.getItem(Ri);return h?JSON.parse(h):null}catch(h){return null}}),[X,ee]=it(null),[he,ve]=it(null),[ae,Re]=it(null),We=Ct(null),Me=Ct(null),ne=Ct({x:0,y:0}),Ae=Ct([]),V=Ct(0),[oe,Ee]=it(null),[ce,Ke]=it(new Map),Te=Ct(0),xe=Ct(null),[me,Ge]=it(null),[xt,dt]=it(null),Ve=Ct({isDragging:!1,side:null,startX:0,startY:0,original:{top:0,right:0,bottom:0,left:0},element:null,elementInfo:null,selector:null,durableSelector:null}),[z,ie]=it(null),[Q,Se]=it(null),[Le,Ze]=it(null),[fe,lt]=it(null),Qe=Ct({x:0,y:0}),[Tt,Bt]=it({x:0,y:0}),st=Ct({isDragging:!1,hasMoved:!1,axis:null,startX:0,startY:0,originalRow:0,originalColumn:0,element:null,elementInfo:null,selector:null,durableSelector:null,isAuto:!1,originalJustifyContent:"",visualGap:0}),[at,Ot]=it(null),[tt,vt]=it(null),[$e,en]=it(null),[Kt,rn]=it(!1),[mn,En]=it(0),[U,Ie]=it(null),Fe=Ct({isDragging:!1,corner:null,startY:0,original:{"top-left":0,"top-right":0,"bottom-right":0,"bottom-left":0},maxRadius:0,element:null,elementInfo:null,selector:null,durableSelector:null}),[ft,Lt]=it(null),[pt,bt]=it(null),[St,dn]=it(null),zt=Ct({isDragging:!1,property:null,startX:0,startY:0,originalFontSize:0,originalLineHeight:0,originalRatio:1.2,element:null,elementInfo:null,selector:null,durableSelector:null}),[kt,hn]=it(null),[Y,te]=it(null),[q,Pe]=it(null),Be=Ws(),ge=Ct(i);ge.current=i;let Gt=At(h=>{let x=ge.current;if(!x||x.size===0)return!1;for(let J of x.keys())try{if(h.matches(J))return!0}catch(T){}return!1},[]),R=Ct(e);R.current=e;let K=Ct(M);K.current=M;let de=Ct([]),Oe=Ct(o);Oe.current=o;let[ye,ke]=it(null),Ne=e.selectedAnnotationIds;de.current=Ne;let gt=At((h,x=!1)=>{t({type:"SELECT_ANNOTATION",payload:{id:h,addToSelection:x}})},[t]),Ue=At(()=>{t({type:"SELECT_ANNOTATION",payload:{id:null}})},[t]),[et,Dt]=it(null),[wt,Tr]=it({x:window.scrollX,y:window.scrollY});Vt(()=>(E(),window.addEventListener("resize",E),()=>window.removeEventListener("resize",E)),[E]),Vt(()=>{let h=()=>{Tr({x:window.scrollX,y:window.scrollY})};return window.addEventListener("scroll",h,{passive:!0}),()=>window.removeEventListener("scroll",h)},[]),Vt(()=>{M?localStorage.setItem(Ri,JSON.stringify(M)):localStorage.removeItem(Ri)},[M]),Ys(M,D,X,e.annotations,t);let zn=Ct(oe);zn.current=oe,Vt(()=>{if(e.activeTool!=="model"||!e.isAnnotating)return;let h=x=>{if(!x.altKey||!zn.current)return;x.preventDefault();let J=x.deltaY>0?-1:1;Te.current=Math.max(0,Te.current+J);let T=xe.current;if(T){let P=ir(T,Te.current);Ee(P)}};return window.addEventListener("wheel",h,{passive:!1}),()=>window.removeEventListener("wheel",h)},[e.activeTool,e.isAnnotating]),Vt(()=>{e.activeTool!=="model"&&(Ee(null),Ke(new Map),Te.current=0,xe.current=null)},[e.activeTool]),Vt(()=>{var J;let h=(J=oe==null?void 0:oe.name)!=null?J:null,x=h&&(g!=null&&g.has(h))?h:null;p==null||p(x)},[oe,g,p]);let[Bo,Uo]=it(null);Vt(()=>{var J;if(!S){Uo(null);return}let h=po(S.name),x=S.instanceIndex;Uo((J=h[x%h.length])!=null?J:null)},[S]);let[un,Lr]=it([]);Vt(()=>{var h,x;if(!v){Lr([]);return}(x=(h=v.token)==null?void 0:h.bindings)!=null&&x.length?Lr(Xr(v.token)):Lr(Ur(v.px))},[v]);let fa=Ct(null),ga=Ct(null);fa.current=at,ga.current=tt,Vt(()=>{let h=["flex-start","center","flex-end"],x=["flex-start","center","flex-end"],T=null,P=!1,H=null,se=null,F=(ue,we)=>{let je=Gn(ue,we);for(;je&&je!==document.documentElement;){let rt=window.getComputedStyle(je).display;if(rt==="flex"||rt==="inline-flex")return je;je=je.parentElement}return null},W=ue=>{let we=window.getComputedStyle(ue).flexDirection;return we==="column"||we==="column-reverse"?"vertical":"horizontal"},b=ue=>{let we=ue.getAttribute("data-pm");return we||(we=Math.random().toString(36).substring(2,8),ue.setAttribute("data-pm",we)),{selector:`[data-pm="${we}"]`,durableSelector:sn(ue)}},k=()=>{P=!0,T&&clearTimeout(T),T=setTimeout(()=>{P=!1,T=null},300)},j=(ue,we,Je)=>{let je=W(ue);if(we===je){let De=window.getComputedStyle(ue).justifyContent,mt=De==="normal"||De==="flex-start"||De==="start"?"flex-start":De==="flex-end"||De==="end"?"flex-end":De==="center"?"center":null;if(!mt)return;let Ht=h.indexOf(mt)+Je;if(Ht<0||Ht>=h.length)return;let Ln=h[Ht],{selector:Wn,durableSelector:Rr}=b(ue);_e(ue,"justify-content",Ln),t({type:"MODIFY_STYLES_BATCH",payload:{selector:Wn,durableSelector:Rr,element:qt(ue),changes:[{property:"justify-content",original:De,modified:Ln}]}})}else{let De=window.getComputedStyle(ue).flexDirection,mt=je==="horizontal"?"column":"row",{selector:yn,durableSelector:Ht}=b(ue);_e(ue,"flex-direction",mt),t({type:"MODIFY_STYLES_BATCH",payload:{selector:yn,durableSelector:Ht,element:qt(ue),changes:[{property:"flex-direction",original:De,modified:mt}]}})}En(rt=>rt+1)},L=(ue,we,Je)=>{let rt=W(ue)==="horizontal"?"vertical":"horizontal";if(we!==rt)return;let mt=window.getComputedStyle(ue).alignItems,yn=mt==="normal"||mt==="stretch"||mt==="flex-start"||mt==="start"?"flex-start":mt==="flex-end"||mt==="end"?"flex-end":mt==="center"?"center":null;if(!yn)return;let Ln=x.indexOf(yn)+Je;if(Ln<0||Ln>=x.length)return;let Wn=x[Ln],{selector:Rr,durableSelector:ka}=b(ue);_e(ue,"align-items",Wn),t({type:"MODIFY_STYLES_BATCH",payload:{selector:Rr,durableSelector:ka,element:qt(ue),changes:[{property:"align-items",original:mt,modified:Wn}]}}),En(Ca=>Ca+1)},B=20,N=null,_=null,le=0,be=(ue,we,Je)=>{let je=F(we,Je);Ie(je?{modifier:ue,target:je}:null)},nt=ue=>{if(!(e.activeTool!=="hand"||!e.isAnnotating)){if(ue.key==="Shift"&&!ue.altKey){let we=Qe.current;be("shift",we.x,we.y)}else if(ue.key==="Alt"&&!ue.shiftKey){let we=Qe.current;be("alt",we.x,we.y)}}},Ye=ue=>{if(e.activeTool!=="hand"||!e.isAnnotating)return;let we=ue.shiftKey&&!ue.altKey,Je=ue.altKey&&!ue.shiftKey;if(!we&&!Je||ue.buttons!==0){N=null,_=null,le=0,H=null,se=null,Ie(null);return}if(H===null&&(H=ue.clientX,se=ue.clientY,be(we?"shift":"alt",ue.clientX,ue.clientY)),P)return;N===null&&(N=ue.clientX,_=ue.clientY,le=0);let je=ue.clientX-N,rt=ue.clientY-_,De=Math.abs(je)>=Math.abs(rt)?je:rt;if(Math.abs(De)>3){let Wn=De>0?1:-1;if(le!==0&&Wn!==le){N=ue.clientX,_=ue.clientY,le=0;return}le=Wn}if(Math.abs(je)<B&&Math.abs(rt)<B)return;let mt=F(H,se);if(!mt)return;let yn=Math.abs(je)>=Math.abs(rt)?"horizontal":"vertical",Ln=(yn==="horizontal"?je:rt)>0?1:-1;N=null,_=null,le=0,we?j(mt,yn,Ln):L(mt,yn,Ln),k()},It=ue=>{(ue.key==="Shift"||ue.key==="Alt")&&(H=null,se=null,N=null,_=null,le=0,Ie(null))},ut=()=>{Ie(null),N=null,_=null,le=0};return window.addEventListener("keydown",nt),window.addEventListener("mousemove",Ye),window.addEventListener("mousedown",ut),window.addEventListener("keyup",It),()=>{window.removeEventListener("keydown",nt),window.removeEventListener("mousemove",Ye),window.removeEventListener("mousedown",ut),window.removeEventListener("keyup",It),T&&clearTimeout(T)}},[e.activeTool,e.isAnnotating,t]),Vt(()=>{let h=x=>{var P,H,se,F;if(x.key==="Escape"){if(K.current)return;if(e.activeTool==="model"&&ce.size>0){x.preventDefault(),Ke(new Map);return}if(de.current.length>0){x.preventDefault(),Ue();return}}if(x.key==="Enter"&&e.activeTool==="model"&&ce.size>0&&d){x.preventDefault();let W=[...ce.keys()].filter(b=>!(g!=null&&g.has(b)));W.length>0&&d(W),Ke(new Map);return}if((x.metaKey||x.ctrlKey)&&x.key==="v"&&Ae.current.length>0&&!K.current){x.preventDefault(),V.current++;let W=V.current*20,k=((P=Ae.current[0])==null?void 0:P.groupId)?Math.random().toString(36).substring(2,9):void 0,j=Ae.current.map(B=>m(f({},B),{id:Math.random().toString(36).substring(2,9),groupId:B.groupId?k:void 0,timestamp:Date.now(),points:B.points.map(N=>({x:N.x+W,y:N.y+W}))}));t({type:"PASTE_ANNOTATIONS",payload:{annotations:j}});let L=j.find(B=>B.type!=="text")||j[0];L&>(L.id);return}let J=de.current;if(J.length===0||K.current)return;let T=(H=x.target)==null?void 0:H.tagName;if(!(T==="INPUT"||T==="TEXTAREA"||(se=x.target)!=null&&se.isContentEditable)&&(x.key==="Delete"||x.key==="Backspace")){if(x.preventDefault(),c){let W=R.current.annotations;for(let b of J){let k=W.find(L=>L.id===b);if(!k)continue;let j=k.threadId||k.groupId&&((F=W.find(L=>L.groupId===k.groupId&&L.threadId))==null?void 0:F.threadId);j&&c(j)}}for(let W of J)t({type:"DELETE_ANNOTATION",payload:{id:W}});Ue()}};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[t,Ue,gt,e.activeTool,ce,g,d,c]);let Dn=Li(()=>fr(e.annotations),[e.annotations]),Jo=Li(()=>{let h=new Map,x=new Set,J=1;for(let T of e.annotations)if(!Dn.has(T))if(T.groupId){if(!x.has(T.groupId)){x.add(T.groupId);let P=e.annotations.filter(H=>H.groupId===T.groupId);for(let H of P)h.set(H.id,J);J++}}else h.set(T.id,J),J++;return h},[e.annotations,Dn]),Qi=Li(()=>{if(Ne.length===0)return null;let h=new Map;for(let x of Ne){let J=e.annotations.find(P=>P.id===x);if(!J)continue;let T=J.groupId?e.annotations.filter(P=>P.groupId===J.groupId):[J];for(let P of T)if(P.linkedSelector&&!(i!=null&&i.has(P.linkedSelector))){let H=P.color||e.activeColor;h.set(P.linkedSelector,H)}}return h.size>0?h:null},[Ne,e.annotations,e.activeColor,i]);Vt(()=>{let h=e.annotations.filter(x=>!(Dn.has(x)||M&&!M.isNew&&x.id===M.id));C(h,e.currentPath,e.activeTool,e.activeColor,e.strokeWidth,Ne,Fl,wt.x,wt.y,Jo,y)},[e.annotations,e.currentPath,e.activeTool,e.activeColor,e.strokeWidth,C,M,Ne,wt,Jo,Dn,y]),Vt(()=>{if(he){let h=Math.random().toString(36).substring(2,9);D({id:h,point:he.point,text:"",fontSize:12,isNew:!0,groupId:he.groupId}),ve(null)}},[he]),Vt(()=>{ae&&(D({id:Math.random().toString(36).substring(2,9),point:ae.point,text:"",fontSize:12,isNew:!0,linkedSelector:ae.linkedSelector,linkedAnchor:ae.linkedAnchor,elements:ae.elements}),Re(null))},[ae]);let Xo=Ct(null),Ko=(ss=M==null?void 0:M.id)!=null?ss:null;Vt(()=>{Ko&&We.current?requestAnimationFrame(()=>{var J;let h=We.current;if(!h||(h.focus(),Me.current===Ko))return;Me.current=Ko;let x=K.current;if(x){if(Xo.current!==null){let T=Math.min(Xo.current,h.value.length);h.setSelectionRange(T,T);return}if(!x.isNew&&x.clickPoint){let T=A.current;if(!T)return;let P=T.getContext("2d");if(!P)return;P.font=`${x.fontSize}px ${$t}`;let H=x.fontSize*1.4,se=x.text.split(`
|
|
7
|
+
`),F=x.clickPoint.y-x.point.y,W=Math.max(0,Math.min(se.length-1,Math.floor(F/H))),b=x.clickPoint.x-x.point.x,k=se[W]||"",j=0;for(let B=0;B<=k.length;B++){let N=P.measureText(k.substring(0,B)).width;if(N>b){let _=B>0?P.measureText(k.substring(0,B-1)).width:0;j=b-_<N-b?B-1:B;break}j=B}let L=j;for(let B=0;B<W;B++)L+=(((J=se[B])==null?void 0:J.length)||0)+1;h.setSelectionRange(L,L)}}}):(Me.current=null,Xo.current=null)},[Ko,A]);let oo=At(h=>{let x=A.current;if(!x)return{x:0,y:0};let J=x.getBoundingClientRect(),T,P;if("touches"in h&&h.touches[0])T=h.touches[0].clientX,P=h.touches[0].clientY;else if("clientX"in h)T=h.clientX,P=h.clientY;else return{x:0,y:0};return{x:T-J.left+window.scrollX,y:P-J.top+window.scrollY}},[A]),$n=At((h,x,J,T)=>{let P=J.x-x.x,H=J.y-x.y,se=P*P+H*H;if(se===0)return Math.sqrt((h.x-x.x)**2+(h.y-x.y)**2)<=T;let F=Math.max(0,Math.min(1,((h.x-x.x)*P+(h.y-x.y)*H)/se)),W=x.x+F*P,b=x.y+F*H;return Math.sqrt((h.x-W)**2+(h.y-b)**2)<=T},[]),Zo=At(h=>{for(let J=e.annotations.length-1;J>=0;J--){let T=e.annotations[J];if(!T||Dn.has(T))continue;let P=(T.strokeWidth||3)+4;switch(T.type){case"text":{if(!T.points[0]||!T.text)continue;let H=T.points[0],se=T.fontSize||12,F=A.current;if(F){let W=F.getContext("2d");if(W){W.font=`${se}px ${$t}`;let b=T.text.split(`
|
|
8
|
+
`),k=H.x-wt.x,j=co(k),L=j!==void 0?Math.min(400,j):void 0,B=L?jn(W,b,L):b,N=L?Math.min(L,Math.max(...B.map(nt=>W.measureText(nt).width))):Math.max(...b.map(nt=>W.measureText(nt).width)),_=B.length*(se*1.4),le=b.length*(se*1.4),be=_-le;if(h.x>=H.x-4-4&&h.x<=H.x+N+4+4&&h.y>=H.y-4-4-be&&h.y<=H.y+le+4+4)return T}}break}case"rectangle":{if(T.points.length<2)continue;let H=T.points[0],se=T.points[T.points.length-1],F=Math.min(H.x,se.x),W=Math.max(H.x,se.x),b=Math.min(H.y,se.y),k=Math.max(H.y,se.y),j=$n(h,{x:F,y:b},{x:W,y:b},P),L=$n(h,{x:F,y:k},{x:W,y:k},P),B=$n(h,{x:F,y:b},{x:F,y:k},P),N=$n(h,{x:W,y:b},{x:W,y:k},P);if(j||L||B||N)return T;break}case"circle":{if(T.points.length<2)continue;let H=T.points[0],se=T.points[T.points.length-1],F=(H.x+se.x)/2,W=(H.y+se.y)/2,b=Math.abs(se.x-H.x)/2,k=Math.abs(se.y-H.y)/2,j=h.x-F,L=h.y-W,B=Math.sqrt((j/b)**2+(L/k)**2);if(Math.abs(B-1)*Math.max(b,k)<=P)return T;break}case"line":{if(T.points.length<2)continue;let H=T.points[0],se=T.points[T.points.length-1];if($n(h,H,se,P))return T;break}case"freehand":{if(T.points.length<2)continue;for(let H=0;H<T.points.length-1;H++){let se=T.points[H],F=T.points[H+1];if($n(h,se,F,P))return T}break}}}return null},[e.annotations,A,$n,Dn,wt.x]),es=At(h=>{let x=Zo(h);return(x==null?void 0:x.type)==="text"?x:null},[Zo]),ts=At(h=>{if(Ne.length===0)return null;let x=Fl/2+4;for(let J of Ne){let T=e.annotations.find(P=>P.id===J);if(!(!T||T.points.length<2)){if(T.type==="line"){let P=T.points[0],H=T.points[T.points.length-1];if(Math.sqrt((h.x-P.x)**2+(h.y-P.y)**2)<=x)return{handle:"start",annotationId:J};if(Math.sqrt((h.x-H.x)**2+(h.y-H.y)**2)<=x)return{handle:"end",annotationId:J};continue}if(T.type==="circle"){let P=T.points[0],H=T.points[T.points.length-1],se=Math.min(P.x,H.x),F=Math.max(P.x,H.x),W=Math.min(P.y,H.y),b=Math.max(P.y,H.y),k=(se+F)/2,j=(W+b)/2,L=[{handle:"top",x:k,y:W},{handle:"bottom",x:k,y:b},{handle:"left",x:se,y:j},{handle:"right",x:F,y:j}];for(let{handle:B,x:N,y:_}of L)if(Math.sqrt((h.x-N)**2+(h.y-_)**2)<=x)return{handle:B,annotationId:J};continue}if(T.type==="rectangle"||T.type==="freehand"){let P=T.points[0],H=T.points[T.points.length-1],se,F,W,b;T.type==="freehand"?(se=Math.min(...T.points.map(j=>j.x)),F=Math.max(...T.points.map(j=>j.x)),W=Math.min(...T.points.map(j=>j.y)),b=Math.max(...T.points.map(j=>j.y))):(se=Math.min(P.x,H.x),F=Math.max(P.x,H.x),W=Math.min(P.y,H.y),b=Math.max(P.y,H.y));let k=[{corner:"topLeft",x:se,y:W},{corner:"topRight",x:F,y:W},{corner:"bottomLeft",x:se,y:b},{corner:"bottomRight",x:F,y:b}];for(let{corner:j,x:L,y:B}of k)if(Math.sqrt((h.x-L)**2+(h.y-B)**2)<=x)return{handle:j,annotationId:J}}}}return null},[Ne,e.annotations]);Vt(()=>{let h=x=>{if(ne.current={x:x.clientX+window.scrollX,y:x.clientY+window.scrollY},!M){let J=es(ne.current);ee((J==null?void 0:J.id)||null)}};return window.addEventListener("mousemove",h),()=>window.removeEventListener("mousemove",h)},[M,es]);let ro=At(()=>{var x;if(!M)return;let h=((x=M.images)==null?void 0:x.length)||0;if(M.text.trim()||h>0)if(M.isNew){let J=nr();t({type:"ADD_TEXT",payload:f({point:M.point,text:M.text||(h>0?`[${h} image${h>1?"s":""}]`:""),fontSize:M.fontSize,id:J,groupId:M.groupId,linkedSelector:M.linkedSelector,linkedAnchor:M.linkedAnchor,elements:M.elements},h>0?{imageCount:h}:{})}),h>0&&M.images&&s&&s(J,M.images)}else t({type:"UPDATE_TEXT",payload:f({id:M.id,text:M.text||(h>0?`[${h} image${h>1?"s":""}]`:"")},h>0?{imageCount:h}:{})}),h>0&&M.images&&s&&s(M.id,M.images);else M.isNew||t({type:"DELETE_ANNOTATION",payload:{id:M.id}});D(null)},[M,t,s]),Tn=At(h=>{for(let x=0;x<Ii.length-1;x++){let J=Ii[x],T=Ii[x+1];if(h<=(J+T)/2)return J;if(h<T)return T}return Math.round(h/8)*8},[]),ns=At((h,x,J,T)=>{let P=J.top+Math.max(T.top,4),H=J.bottom-Math.max(T.bottom,4),se=J.left+Math.max(T.left,4),F=J.right-Math.max(T.right,4);if(h<J.left||h>J.right||x<J.top||x>J.bottom)return null;let W=x<P,b=x>H,k=h<se,j=h>F;return W&&k?T.top>=T.left?"top":"left":W&&j?T.top>=T.right?"top":"right":b&&k?T.bottom>=T.left?"bottom":"left":b&&j?T.bottom>=T.right?"bottom":"right":W?"top":b?"bottom":k?"left":j?"right":null},[]),os=At(h=>{var H,se;if(!e.isAnnotating)return;if(e.inspectedElement&&e.activeTool==="hand"&&!("button"in h&&h.button===2)){h.preventDefault(),h.stopPropagation(),t({type:"SELECT_ELEMENT",payload:null});return}let x=oo(h),J="shiftKey"in h&&h.shiftKey;if(e.activeTool==="inspector"){if("button"in h&&h.button===2)return;if(me&&!Gt(me)){let F=qt(me),W=sn(me),b=me.getBoundingClientRect(),k=me.getAttribute("data-pm");k||(k=Math.random().toString(36).substring(2,8),me.setAttribute("data-pm",k));let j=`[data-pm="${k}"]`,L=e.styleModifications.some(be=>{try{return me.matches(be.selector)}catch(nt){return!1}}),B=e.annotations.filter(be=>{if(!be.linkedSelector)return!1;try{return me.matches(be.linkedSelector)}catch(nt){return!1}}).length,N=(L?1:0)+B,_=b.top>=Xn*(1+N)?"top-left":"bottom-left",le=Nl(b,_,N);Re({point:le,linkedSelector:j,linkedAnchor:_,elements:[m(f({},F),{selector:W})]})}return}if(e.activeTool==="model"){if("button"in h&&h.button===2)return;if(oe){let F=oe.name;if(g!=null&&g.has(F)){u==null||u(F);return}"shiftKey"in h&&h.shiftKey?Ke(b=>{let k=new Map(b);return k.has(F)?k.delete(F):k.set(F,oe),k}):ce.size===1&&ce.has(F)?(d&&d([F]),Ke(new Map)):Ke(new Map([[F,oe]]))}return}if(e.activeTool==="hand"&&at&&tt){let F=at,W=F.getAttribute("data-pm");W||(W=Math.random().toString(36).substring(2,8),F.setAttribute("data-pm",W));let b=sn(F),k=`[data-pm="${W}"]`,j=qt(F),L=Fo(F),B=x.x-window.scrollX,N=x.y-window.scrollY,_=Kt,le=window.getComputedStyle(F).justifyContent,be=0;if(_){let Ye=Vn(F).find(It=>It.axis===tt);be=Ye?tt==="column"?Ye.w:Ye.h:0}_e(F,"transition","none"),st.current={isDragging:!0,hasMoved:!1,axis:tt,startX:B,startY:N,originalRow:_?be:L.row,originalColumn:_?be:L.column,element:F,elementInfo:m(f({},j),{selector:k}),selector:k,durableSelector:b,isAuto:_,originalJustifyContent:le,visualGap:be},en({axis:tt,row:_?be:L.row,column:_?be:L.column});return}if(e.activeTool==="hand"&&kt&&Y){let F=kt,W=F.getAttribute("data-pm");W||(W=Math.random().toString(36).substring(2,8),F.setAttribute("data-pm",W));let b=`[data-pm="${W}"]`,k=qt(F),{fontSize:j,lineHeight:L}=No(F),B=j>0?L/j:1.2,N=x.x-window.scrollX,_=x.y-window.scrollY;_e(F,"transition","none");let le=sn(F);zt.current={isDragging:!0,property:Y,startX:N,startY:_,originalFontSize:j,originalLineHeight:L,originalRatio:B,element:F,elementInfo:m(f({},k),{selector:b}),selector:b,durableSelector:le},Pe({property:Y,fontSize:j,lineHeight:L});return}if(e.activeTool==="hand"&&ft&&pt){let F=ft,W=F.getAttribute("data-pm");W||(W=Math.random().toString(36).substring(2,8),F.setAttribute("data-pm",W));let b=`[data-pm="${W}"]`,k=sn(F),j=qt(F),L=Un(F),B=F.getBoundingClientRect(),N=Math.floor(B.height/2),_=x.y-window.scrollY;_e(F,"transition","none"),Fe.current={isDragging:!0,corner:pt,startY:_,original:L,maxRadius:N,element:F,elementInfo:m(f({},j),{selector:b}),selector:b,durableSelector:k},dn({corner:pt,radius:f({},L)});return}if(e.activeTool==="hand"&&z&&Q){let F=z,W=F.getAttribute("data-pm");W||(W=Math.random().toString(36).substring(2,8),F.setAttribute("data-pm",W));let b=`[data-pm="${W}"]`,k=sn(F),j=qt(F),L=go(F),B=x.x-window.scrollX,N=x.y-window.scrollY;_e(F,"transition","none"),Ve.current={isDragging:!0,side:Q,startX:B,startY:N,original:L,element:F,elementInfo:m(f({},j),{selector:b}),selector:b,durableSelector:k},lt({side:Q,padding:f({},L)});return}let T=ts(x);if(T){let F=e.annotations.find(W=>W.id===T.annotationId);if(F&&F.type!=="text"&&((H=F.status)!=null?H:"pending")==="pending"){Dt({annotationId:T.annotationId,handle:T.handle,startPoint:x,originalPoints:[...F.points],hasMoved:!1});return}}let P=Zo(x);if(P&&P.points[0]){if(M&&ro(),P.type!=="text"?(gt(P.id,J),P.color&&t({type:"SET_COLOR",payload:P.color})):J||Ue(),a){let F=P.threadId||(P.groupId?(se=e.annotations.find(W=>W.groupId===P.groupId&&W.threadId))==null?void 0:se.threadId:void 0);F&&a(F)}ke({annotation:P,startPoint:x,hasMoved:!1});return}if(J||Ue(),e.activeTool==="text"){M&&ro();let F=Math.random().toString(36).substring(2,9);D({id:F,point:x,text:"",fontSize:12,isNew:!0});return}G(!0),t({type:"START_PATH",payload:x})},[e.isAnnotating,e.activeTool,e.inspectedElement,e.annotations,M,Ne,me,z,Q,ft,pt,at,tt,Kt,kt,Y,oe,ce,g,d,u,a,oo,Zo,ts,t,gt,Ue,ro]),rs=At(h=>{var J,T;let x=oo(h);if(e.activeTool==="inspector"&&e.isAnnotating){let P=x.x-window.scrollX,H=x.y-window.scrollY,se=Gn(P,H),F=se&&Gt(se)?null:se;F!==me&&(Ge(F),dt(F?qt(F):null));return}if(e.activeTool==="model"&&e.isAnnotating){let P=x.x-window.scrollX,H=x.y-window.scrollY,se=Gn(P,H);if(se!==xe.current&&(xe.current=se,Te.current=0),se){let F=ir(se,Te.current);Ee(F)}else Ee(null);return}if(e.activeTool==="hand"&&e.isAnnotating){let P=x.x-window.scrollX,H=x.y-window.scrollY;Qe.current={x:P,y:H},Bt({x:P,y:H});let se=Be.current.cmd,F=Be.current.shift;if(st.current.isDragging){let b=st.current,k=b.element;if(!k)return;if(!b.hasMoved){let N=Math.abs(P-b.startX),_=Math.abs(H-b.startY);if(N<=2&&_<=2)return;b.hasMoved=!0,b.isAuto&&(_e(k,"justify-content","normal"),_e(k,"row-gap",`${b.visualGap}px`),_e(k,"column-gap",`${b.visualGap}px`),rn(!1))}let j=b.axis,L=b.originalRow,B=b.originalColumn;if(j==="column"){let N=P-b.startX;B=b.originalColumn+N,se||(L=b.originalRow+N)}else{let N=H-b.startY;L=b.originalRow+N,se||(B=b.originalColumn+N)}L=Math.max(0,L),B=Math.max(0,B),F&&(L=Tn(L),B=Tn(B)),L=Math.round(L),B=Math.round(B),_e(k,"row-gap",`${L}px`),_e(k,"column-gap",`${B}px`),en({axis:j,row:L,column:B});return}if(Fe.current.isDragging){let b=Fe.current,k=b.element;if(!k)return;let j=H-b.startY,L=b.corner,B=b.original,N=f({},B);if(se){let _=B[L]+j;_=Math.max(0,Math.min(b.maxRadius,_)),F&&(_=Tn(_)),_=Math.round(_),N[L]=_}else{let _=B[L]+j;_=Math.max(0,Math.min(b.maxRadius,_)),F&&(_=Tn(_)),_=Math.round(_),N={"top-left":_,"top-right":_,"bottom-right":_,"bottom-left":_}}_e(k,"border-top-left-radius",`${N["top-left"]}px`),_e(k,"border-top-right-radius",`${N["top-right"]}px`),_e(k,"border-bottom-right-radius",`${N["bottom-right"]}px`),_e(k,"border-bottom-left-radius",`${N["bottom-left"]}px`),dn({corner:L,radius:N});return}if(zt.current.isDragging){let b=zt.current,k=b.element;if(!k)return;let j=b.property,L=b.originalFontSize,B=b.originalLineHeight,N=[8,10,11,12,13,14,16,18,20,22,24,28,32,36,40,48,56,64,72,80,96];if(j==="font-size"){let le=P-b.startX;L=b.originalFontSize+le,L=Math.max(1,L)}else{let le=H-b.startY;B=b.originalLineHeight+le,B=Math.max(L,B)}if(F)if(j==="font-size"){let le=N[0],be=Math.abs(L-le);for(let nt of N){let Ye=Math.abs(L-nt);Ye<be&&(le=nt,be=Ye)}L=le}else{let le=L>0?B/L:1.2,be=Math.round(le*2)/2;B=L*Math.max(1,be)}L=Math.round(L),B=Math.round(B*10)/10,_e(k,"font-size",`${L}px`);let _=L>0?Math.round(B/L*1e3)/1e3:1.2;_e(k,"line-height",`${_}`),Pe({property:j,fontSize:L,lineHeight:B});return}if(Ve.current.isDragging){let b=Ve.current,k=b.element;if(!k)return;let j=b.side,L=b.original,B=L.top,N=L.right,_=L.bottom,le=L.left;if(j==="top"){let be=b.startY-H;B=L.top+be,se||(_=L.bottom+be)}else if(j==="bottom"){let be=H-b.startY;_=L.bottom+be,se||(B=L.top+be)}else if(j==="left"){let be=b.startX-P;le=L.left+be,se||(N=L.right+be)}else if(j==="right"){let be=P-b.startX;N=L.right+be,se||(le=L.left+be)}B=Math.max(0,B),N=Math.max(0,N),_=Math.max(0,_),le=Math.max(0,le),F&&(B=Tn(B),N=Tn(N),_=Tn(_),le=Tn(le)),B=Math.round(B),N=Math.round(N),_=Math.round(_),le=Math.round(le),_e(k,"padding",`${B}px ${N}px ${_}px ${le}px`),lt({side:j,padding:{top:B,right:N,bottom:_,left:le}});return}let W=Gn(P,H);for(;W&&W.tagName==="A";)W=W.parentElement;{let k=[];W&&k.push(W),ft&&ft!==W&&k.push(ft);let j=null,L=16,B=null;for(let N of k){let _=N.getBoundingClientRect(),le=Un(N),be=[["top-left",_.left,_.top+le["top-left"]],["top-right",_.right,_.top+le["top-right"]],["bottom-right",_.right,_.bottom-le["bottom-right"]],["bottom-left",_.left,_.bottom-le["bottom-left"]]];for(let[nt,Ye,It]of be){let ut=Math.hypot(P-Ye,H-It);ut<L&&(L=ut,j=nt,B=N)}}if(j&&B){Lt(B),bt(j),z&&ie(null),Q&&Se(null),at&&Ot(null),tt&&vt(null),rn(!1),kt&&hn(null),Y&&te(null);return}}ft&&Lt(null),pt&&bt(null);{let b=[];W&&ar(W)&&b.push(W);let k=(J=W==null?void 0:W.parentElement)!=null?J:null;for(;k&&k!==document.body&&b.length<3;)ar(k)&&b.push(k),k=k.parentElement;for(let j of b){let B=Vn(j).find(N=>P>=N.x&&P<=N.x+N.w&&H>=N.y&&H<=N.y+N.h);if(B){Ot(j),vt(B.axis),rn(qr(j,B.axis)),z&&ie(null),Q&&Se(null),kt&&hn(null),Y&&te(null);return}}}at&&Ot(null),tt&&vt(null),rn(!1);{let k=[];W&&k.push(W),kt&&kt!==W&&k.push(kt);let j=null,L=1/0,B=null;for(let N of k){if(!Qr(N))continue;let _=mo(N);if(!_)continue;let le=P>=_.left&&P<=_.right&&H>=_.top&&H<=_.bottom,be=[["font-size",_.right,_.top+_.height/2],["line-height",_.left+_.width/2,_.bottom]];for(let[nt,Ye,It]of be){let ut=Math.hypot(P-Ye,H-It);(le||ut<12)&&ut<L&&(L=ut,j=nt,B=N)}}j&&B?(hn(B),te(j)):(kt&&hn(null),Y&&te(null))}if(W!==z&&ie(W),W){let b=go(W),k=W.getBoundingClientRect(),j=ns(P,H,k,b);Se(j)}else Se(null);return}if(et){let{handle:P,originalPoints:H,hasMoved:se}=et,F=e.annotations.find(L=>L.id===et.annotationId);if(!F)return;let W="metaKey"in h,b=W&&(h.metaKey||h.ctrlKey),k=W&&h.shiftKey,j;if(F.type==="line"){let L=H[0],B=H[H.length-1];P==="start"?j=[x,B]:j=[L,x]}else if(F.type==="freehand"){let L=Math.min(...H.map(De=>De.x)),B=Math.max(...H.map(De=>De.x)),N=Math.min(...H.map(De=>De.y)),_=Math.max(...H.map(De=>De.y)),le=(L+B)/2,be=(N+_)/2,nt=B-L||1,Ye=_-N||1,It=nt/Ye,ut=L,ue=B,we=N,Je=_;switch(P){case"topLeft":ut=x.x,we=x.y;break;case"topRight":ue=x.x,we=x.y;break;case"bottomLeft":ut=x.x,Je=x.y;break;case"bottomRight":ue=x.x,Je=x.y;break}if(b)switch(P){case"topLeft":ue=B+(L-ut),Je=_+(N-we);break;case"topRight":ut=L-(ue-B),Je=_+(N-we);break;case"bottomLeft":ue=B+(L-ut),we=N-(Je-_);break;case"bottomRight":ut=L-(ue-B),we=N-(Je-_);break}if(k){let De=ue-ut,mt=Je-we;if(Math.abs(De/mt)>It){let Ht=Math.abs(mt)*It*Math.sign(De);P==="topLeft"||P==="bottomLeft"?ut=ue-Ht:ue=ut+Ht}else{let Ht=Math.abs(De)/It*Math.sign(mt);P==="topLeft"||P==="topRight"?we=Je-Ht:Je=we+Ht}}let je=ue-ut||1,rt=Je-we||1;j=H.map(De=>({x:ut+(De.x-L)/nt*je,y:we+(De.y-N)/Ye*rt}))}else if(F.type==="circle"){let L=H[0],B=H[H.length-1],N=Math.min(L.x,B.x),_=Math.max(L.x,B.x),le=Math.min(L.y,B.y),be=Math.max(L.y,B.y),nt=(N+_)/2,Ye=(le+be)/2,It=_-N,ut=be-le,ue=N,we=_,Je=le,je=be;switch(P){case"top":if(Je=x.y,b&&(je=Ye+(Ye-x.y)),k){let De=(je-Je)*(It/ut)/2;ue=nt-De,we=nt+De}break;case"bottom":if(je=x.y,b&&(Je=Ye-(x.y-Ye)),k){let De=(je-Je)*(It/ut)/2;ue=nt-De,we=nt+De}break;case"left":if(ue=x.x,b&&(we=nt+(nt-x.x)),k){let De=(we-ue)*(ut/It)/2;Je=Ye-De,je=Ye+De}break;case"right":if(we=x.x,b&&(ue=nt-(x.x-nt)),k){let De=(we-ue)*(ut/It)/2;Je=Ye-De,je=Ye+De}break}j=[{x:ue,y:Je},{x:we,y:je}]}else{let L=H[0],B=H[H.length-1],N=Math.min(L.x,B.x),_=Math.max(L.x,B.x),le=Math.min(L.y,B.y),be=Math.max(L.y,B.y),nt=(N+_)/2,Ye=(le+be)/2,It=_-N||1,ut=be-le||1,ue=It/ut,we=N,Je=_,je=le,rt=be;switch(P){case"topLeft":we=x.x,je=x.y;break;case"topRight":Je=x.x,je=x.y;break;case"bottomLeft":we=x.x,rt=x.y;break;case"bottomRight":Je=x.x,rt=x.y;break}if(b)switch(P){case"topLeft":Je=_+(N-we),rt=be+(le-je);break;case"topRight":we=N-(Je-_),rt=be+(le-je);break;case"bottomLeft":Je=_+(N-we),je=le-(rt-be);break;case"bottomRight":we=N-(Je-_),je=le-(rt-be);break}if(k){let De=Je-we,mt=rt-je;if(Math.abs(De/mt)>ue){let Ht=Math.abs(mt)*ue*Math.sign(De);P==="topLeft"||P==="bottomLeft"?we=Je-Ht:Je=we+Ht}else{let Ht=Math.abs(De)/ue*Math.sign(mt);P==="topLeft"||P==="topRight"?je=rt-Ht:rt=je+Ht}}j=[{x:we,y:je},{x:Je,y:rt}]}t({type:"RESIZE_ANNOTATION",payload:{id:et.annotationId,points:j,saveUndo:!se}}),se||Dt(m(f({},et),{hasMoved:!0}));return}if(ye&&((T=ye.annotation.status)!=null?T:"pending")==="pending"){let P=x.x-ye.startPoint.x,H=x.y-ye.startPoint.y;if((Math.abs(P)>2||Math.abs(H)>2)&&!ye.hasMoved)ke(m(f({},ye),{hasMoved:!0,startPoint:x})),t({type:"MOVE_ANNOTATION",payload:{id:ye.annotation.id,delta:{x:P,y:H},saveUndo:!0}});else if(ye.hasMoved){let F=x.x-ye.startPoint.x,W=x.y-ye.startPoint.y;ke(m(f({},ye),{startPoint:x})),t({type:"MOVE_ANNOTATION",payload:{id:ye.annotation.id,delta:{x:F,y:W}}})}return}!Z||!e.isAnnotating||t({type:"CONTINUE_PATH",payload:x})},[Z,e.isAnnotating,e.activeTool,ye,et,me,z,Q,ft,pt,at,tt,kt,Y,oo,t,Tn,ns]),Ir=At(h=>{var T,P,H,se,F,W;if(zt.current.isDragging){let b=zt.current,k=b.element;if(k&&b.selector&&b.elementInfo&&q){k instanceof HTMLElement&&(k.style.removeProperty("font-size"),k.style.removeProperty("line-height"),k.style.removeProperty("transition"));let j=[];if(b.originalFontSize!==q.fontSize&&(_e(k,"font-size",`${q.fontSize}px`),j.push({property:"font-size",original:`${b.originalFontSize}px`,modified:`${q.fontSize}px`})),b.originalLineHeight!==q.lineHeight){let L=b.originalFontSize>0?Math.round(b.originalLineHeight/b.originalFontSize*1e3)/1e3:1.2,B=q.fontSize>0?Math.round(q.lineHeight/q.fontSize*1e3)/1e3:1.2;_e(k,"line-height",`${B}`),j.push({property:"line-height",original:`${L}`,modified:`${B}`})}j.length>0&&t({type:"MODIFY_STYLES_BATCH",payload:{selector:b.selector,durableSelector:(T=b.durableSelector)!=null?T:void 0,element:b.elementInfo,changes:j}})}zt.current={isDragging:!1,property:null,startX:0,startY:0,originalFontSize:0,originalLineHeight:0,originalRatio:1.2,element:null,elementInfo:null,selector:null,durableSelector:null},Pe(null);return}if(st.current.isDragging){let b=st.current,k=b.element,j="button"in h&&h.button===2;if(!b.hasMoved&&!j&&k&&b.selector&&b.elementInfo){k instanceof HTMLElement&&k.style.removeProperty("transition");let L=["space-between","space-around","stretch","normal"],B=b.originalJustifyContent||"normal",N=L.indexOf(B),_=L[(N+1)%L.length],le=[];_==="normal"?(_e(k,"justify-content","normal"),le.push({property:"justify-content",original:b.originalJustifyContent,modified:"normal"})):_==="stretch"?(_e(k,"justify-content",_),_e(k,"row-gap","8px"),_e(k,"column-gap","8px"),le.push({property:"justify-content",original:b.originalJustifyContent||"normal",modified:_}),b.originalRow!==8&&le.push({property:"row-gap",original:`${b.originalRow}px`,modified:"8px"}),b.originalColumn!==8&&le.push({property:"column-gap",original:`${b.originalColumn}px`,modified:"8px"})):(k instanceof HTMLElement&&(k.style.removeProperty("row-gap"),k.style.removeProperty("column-gap")),_e(k,"justify-content",_),le.push({property:"justify-content",original:b.originalJustifyContent||"normal",modified:_}),b.originalRow>0&&le.push({property:"row-gap",original:`${b.originalRow}px`,modified:"0px"}),b.originalColumn>0&&le.push({property:"column-gap",original:`${b.originalColumn}px`,modified:"0px"})),le.length>0&&t({type:"MODIFY_STYLES_BATCH",payload:{selector:b.selector,durableSelector:(P=b.durableSelector)!=null?P:void 0,element:b.elementInfo,changes:le}})}else if(b.hasMoved&&k&&b.selector&&b.elementInfo&&$e){k instanceof HTMLElement&&(k.style.removeProperty("row-gap"),k.style.removeProperty("column-gap"),k.style.removeProperty("transition"));let L=[];b.isAuto?(k instanceof HTMLElement&&k.style.removeProperty("justify-content"),_e(k,"justify-content","normal"),_e(k,"row-gap",`${$e.row}px`),_e(k,"column-gap",`${$e.column}px`),L.push({property:"justify-content",original:b.originalJustifyContent,modified:"normal"}),L.push({property:"row-gap",original:"0px",modified:`${$e.row}px`}),L.push({property:"column-gap",original:"0px",modified:`${$e.column}px`})):(b.originalRow!==$e.row&&(_e(k,"row-gap",`${$e.row}px`),L.push({property:"row-gap",original:`${b.originalRow}px`,modified:`${$e.row}px`})),b.originalColumn!==$e.column&&(_e(k,"column-gap",`${$e.column}px`),L.push({property:"column-gap",original:`${b.originalColumn}px`,modified:`${$e.column}px`}))),L.length>0&&t({type:"MODIFY_STYLES_BATCH",payload:{selector:b.selector,durableSelector:(H=b.durableSelector)!=null?H:void 0,element:b.elementInfo,changes:L}})}st.current={isDragging:!1,hasMoved:!1,axis:null,startX:0,startY:0,originalRow:0,originalColumn:0,element:null,elementInfo:null,selector:null,durableSelector:null,isAuto:!1,originalJustifyContent:"",visualGap:0},en(null);return}if(Fe.current.isDragging){let b=Fe.current,k=b.element;if(k&&b.selector&&b.elementInfo&&St){k instanceof HTMLElement&&(k.style.removeProperty("border-top-left-radius"),k.style.removeProperty("border-top-right-radius"),k.style.removeProperty("border-bottom-right-radius"),k.style.removeProperty("border-bottom-left-radius"),k.style.removeProperty("transition"));let j=["top-left","top-right","bottom-right","bottom-left"],L={"top-left":"border-top-left-radius","top-right":"border-top-right-radius","bottom-right":"border-bottom-right-radius","bottom-left":"border-bottom-left-radius"},B=[];for(let N of j)b.original[N]!==St.radius[N]&&(_e(k,L[N],`${St.radius[N]}px`),B.push({property:L[N],original:`${b.original[N]}px`,modified:`${St.radius[N]}px`}));B.length>0&&t({type:"MODIFY_STYLES_BATCH",payload:{selector:b.selector,durableSelector:(se=b.durableSelector)!=null?se:void 0,element:b.elementInfo,changes:B}})}Fe.current={isDragging:!1,corner:null,startY:0,original:{"top-left":0,"top-right":0,"bottom-right":0,"bottom-left":0},maxRadius:0,element:null,elementInfo:null,selector:null,durableSelector:null},dn(null);return}if(Ve.current.isDragging){let b=Ve.current,k=b.element,j=b.selector,L=b.elementInfo;if(k&&j&&L&&fe){let B=b.original,N=fe.padding;k instanceof HTMLElement&&(k.style.removeProperty("padding"),k.style.removeProperty("transition"));let _=[],le=[{prop:"padding-top",origVal:B.top,newVal:N.top},{prop:"padding-right",origVal:B.right,newVal:N.right},{prop:"padding-bottom",origVal:B.bottom,newVal:N.bottom},{prop:"padding-left",origVal:B.left,newVal:N.left}];for(let{prop:be,origVal:nt,newVal:Ye}of le)nt!==Ye&&(_e(k,be,`${Ye}px`),_.push({property:be,original:`${nt}px`,modified:`${Ye}px`}));_.length>0&&t({type:"MODIFY_STYLES_BATCH",payload:{selector:j,durableSelector:(F=b.durableSelector)!=null?F:void 0,element:L,changes:_}})}Ve.current={isDragging:!1,side:null,startX:0,startY:0,original:{top:0,right:0,bottom:0,left:0},element:null,elementInfo:null,selector:null,durableSelector:null},lt(null);return}if(et){Dt(null);return}if(ye){if(!ye.hasMoved&&ye.annotation.type==="text"&&((W=ye.annotation.status)!=null?W:"pending")==="pending"){let b=oo(h);D({id:ye.annotation.id,point:ye.annotation.points[0],text:ye.annotation.text||"",fontSize:ye.annotation.fontSize||12,isNew:!1,clickPoint:b,groupId:ye.annotation.groupId})}ke(null);return}if(!Z)return;let x=5;if(e.currentPath.length>=2){let b=e.currentPath[0],k=e.currentPath[e.currentPath.length-1],j=Math.abs(k.x-b.x),L=Math.abs(k.y-b.y);if((e.activeTool==="line"?Math.sqrt(j*j+L*L)<x:j<x&&L<x)&&["rectangle","circle","line"].includes(e.activeTool)){G(!1),t({type:"CANCEL_PATH"});return}}let J=Vr(e.currentPath);if(e.activeTool==="rectangle"&&e.currentPath.length>=2){let b=e.currentPath[0],k=e.currentPath[e.currentPath.length-1],j=Math.min(b.x,k.x),L=Math.max(b.y,k.y),B=e.strokeWidth/2,N=Math.random().toString(36).substring(2,9);ve({point:{x:j-B+4,y:L+B+4},groupId:N}),G(!1),t({type:"FINISH_PATH",payload:{groupId:N,elements:J}});return}G(!1),t({type:"FINISH_PATH",payload:{elements:J}})},[Z,ye,et,fe,St,$e,q,oo,t,e.activeTool,e.currentPath,e.strokeWidth]),ma=At(h=>{let x=h.target.value;Xo.current=h.target.selectionStart,D(J=>J&&m(f({},J),{text:x}))},[]),ha=At(h=>{h.key==="Escape"?D(null):h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),ro())},[ro]),ya=At(h=>{if(!M)return;let x=h.clipboardData.items,J=[];for(let T=0;T<x.length;T++){let P=x[T];if(P.type.startsWith("image/")){let H=P.getAsFile();H&&J.push(H)}}J.length>0&&(h.preventDefault(),D(T=>T?m(f({},T),{images:[...T.images||[],...J]}):null))},[M]),ba=At(h=>{if(!e.isAnnotating)return;if(e.activeTool==="hand"){h.preventDefault();let J=z||at||ft||kt;if(J&&!Gt(J)){let T=qt(J),P=sn(J);t({type:"SELECT_ELEMENT",payload:{el:J,info:m(f({},T),{selector:P})}})}return}h.preventDefault();let x=A.current;x&&($.current=!0,x.style.pointerEvents="none",setTimeout(()=>{$.current&&($.current=!1,x.style.pointerEvents="")},4e3))},[e.activeTool,e.isAnnotating,z,at,ft,kt,t,Gt,A]);Vt(()=>{let h=e.annotations.filter(H=>H.linkedSelector);if(h.length===0)return;let x=null,J=()=>{var se,F,W;let H=[];for(let b of h){let k=document.querySelector(b.linkedSelector);if(!k&&((F=(se=b.elements)==null?void 0:se[0])!=null&&F.selector)&&b.linkedSelector.startsWith("[data-pm=")){try{k=document.querySelector(b.elements[0].selector)}catch(Ye){}if(k){let Ye=(W=b.linkedSelector.match(/data-pm="([^"]+)"/))==null?void 0:W[1];Ye&&k.setAttribute("data-pm",Ye)}}if(!k)continue;let j=k.getBoundingClientRect(),L=e.styleModifications.some(Ye=>{try{return k.matches(Ye.selector)}catch(It){return!1}}),B=h.filter(Ye=>Ye.id!==b.id&&Ye.timestamp<b.timestamp&&Ye.linkedSelector===b.linkedSelector).length,N=(L?1:0)+B,_=j.top>=Xn*(1+N)?"top-left":"bottom-left",le=Nl(j,_,N),be=b.points[0],nt=_!==b.linkedAnchor;be&&(nt||Math.abs(le.x-be.x)>1||Math.abs(le.y-be.y)>1)&&H.push({id:b.id,point:le,linkedAnchor:nt?_:void 0})}H.length>0&&t({type:"UPDATE_LINKED_POSITIONS",payload:{updates:H}})},T=()=>{x&&cancelAnimationFrame(x),x=requestAnimationFrame(J)};J(),window.addEventListener("scroll",T,!0),window.addEventListener("resize",T,!0),window.addEventListener("load",T),document.fonts.ready.then(T);let P=new MutationObserver(T);return P.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]}),()=>{window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",T,!0),window.removeEventListener("load",T),P.disconnect(),x&&cancelAnimationFrame(x)}},[e.annotations,t]);let xa=()=>{var h,x,J;if(!e.isAnnotating)return"default";if(et){let{handle:T}=et;return T==="start"||T==="end"?"move":T==="top"||T==="bottom"?"ns-resize":T==="left"||T==="right"?"ew-resize":T==="topLeft"||T==="bottomRight"?"nwse-resize":"nesw-resize"}if(e.activeTool==="text")return"text";if(e.activeTool==="hand"){let T=(h=$e==null?void 0:$e.axis)!=null?h:tt;if(T==="row")return"ns-resize";if(T==="column")return"ew-resize";if(St||pt)return"ns-resize";let P=(x=q==null?void 0:q.property)!=null?x:Y;if(P==="font-size")return"ew-resize";if(P==="line-height")return"ns-resize";let H=(J=fe==null?void 0:fe.side)!=null?J:Q;return H==="top"||H==="bottom"?"ns-resize":H==="left"||H==="right"?"ew-resize":"default"}return"crosshair"},va={position:"fixed",top:0,left:0,width:"100vw",height:"100vh",zIndex:9998,pointerEvents:e.isAnnotating?"auto":"none",visibility:e.isAnnotating?"visible":"hidden",cursor:xa()},Oo=At(()=>{let h=A.current;if(!h||!M)return{width:100,height:12*1.4,isWrapped:!1};let x=h.getContext("2d");if(!x)return{width:100,height:M.fontSize*1.4,isWrapped:!1};x.font=`${M.fontSize}px ${$t}`;let T=x.measureText("Type here...").width,P=M.text.split(`
|
|
9
|
+
`),H=P.length>0?Math.max(T,...P.map(k=>x.measureText(k||" ").width)):T,se=M.point.x-wt.x,F=co(se);if(F!==void 0&&H>F){let k=jn(x,P,F),j=Math.min(F,Math.max(T,...k.map(B=>x.measureText(B).width))),L=Math.max(1,k.length)*M.fontSize*1.4;return{width:j,height:L,isWrapped:!0}}let b=Math.max(1,P.length)*M.fontSize*1.4;return{width:H,height:b,isWrapped:!1}},[M,A,wt.x])(),Sa=M?Math.max(1,M.text.split(`
|
|
10
|
+
`).length)*M.fontSize*1.4+8:0,is=Oo.height+8,wa=Oo.isWrapped?is-Sa:0,Ea=M?{position:"fixed",left:M.point.x-4-wt.x,top:M.point.y-4-wt.y-wa,zIndex:9999,width:Oo.width+8,height:is,padding:4,fontSize:M.fontSize,fontFamily:$t,color:"#ffffff",backgroundColor:e.activeColor,border:"none",borderRadius:0,outline:"none",boxShadow:"none",lineHeight:1.4,resize:"none",overflow:"hidden",whiteSpace:Oo.isWrapped?"pre-wrap":"pre",wordBreak:Oo.isWrapped?"break-word":void 0}:{};return ko(Co,{children:[ot("canvas",{ref:I,id:"devtools-canvas",style:va,onMouseDown:os,onMouseMove:rs,onMouseUp:h=>Ir(h),onMouseLeave:h=>{Ir(h),Ge(null),dt(null)},onTouchStart:os,onTouchMove:rs,onTouchEnd:h=>Ir(h),onContextMenu:ba}),M&&ko(Co,{children:[ot("style",{children:"#devtools-text-input::placeholder { color: rgba(255, 255, 255, 0.5); }"}),ot("textarea",{id:"devtools-text-input",ref:We,value:M.text,onChange:ma,onKeyDown:ha,onPaste:ya,onBlur:ro,placeholder:"Type here...",style:Ea}),M.images&&M.images.length>0&&ko("div",{"data-devtools":!0,style:{position:"fixed",left:M.point.x-4-wt.x,top:M.point.y-4-wt.y-20,zIndex:1e4,fontSize:11,fontFamily:"system-ui, sans-serif",color:"#fff",backgroundColor:"rgba(0,0,0,0.7)",padding:"2px 6px",borderRadius:3,whiteSpace:"nowrap"},children:[M.images.length," image",M.images.length>1?"s":""," attached"]})]}),e.isAnnotating&&e.activeTool!=="hand"&&e.styleModifications.length>0&&ot(ml,{styleModifications:e.styleModifications,isInspecting:!!e.inspectedElement,accentColor:e.activeColor,annotationGroupCount:new Set(e.annotations.map(h=>h.groupId||h.id)).size,dispatch:t,inFlightSelectors:n}),e.activeTool==="hand"&&e.isAnnotating&&e.styleModifications.length>0&&ot(yl,{styleModifications:e.styleModifications,accentColor:e.activeColor}),e.isAnnotating&&ot(il,{annotations:e.annotations,supersededAnnotations:Dn,inFlightIds:r,scrollX:wt.x,scrollY:wt.y,annotationGroupMap:Jo,onViewThread:a,onSelectAnnotation:gt,canvasRef:A}),e.isAnnotating&&l&&ot(sl,{annotations:e.annotations,supersededAnnotations:Dn,scrollX:wt.x,scrollY:wt.y,onReply:l,annotationGroupMap:Jo,canvasRef:A}),e.isAnnotating&&i&&i.size>0&&ot(ri,{inFlightSelectorColors:i}),e.isAnnotating&&Qi&&ot(ri,{inFlightSelectorColors:Qi,animated:!1}),e.activeTool==="hand"&&e.isAnnotating&&($e?st.current.element:at)&&ot(ci,{element:$e?st.current.element:at,gap:$e?{row:$e.row,column:$e.column}:Fo(at),accentColor:e.activeColor,hoveredAxis:tt,draggingAxis:(ls=$e==null?void 0:$e.axis)!=null?ls:null,cursorViewport:Tt,isAutoGap:Kt,refreshKey:mn}),e.activeTool==="hand"&&e.isAnnotating&&U&&ot(Dl,{element:U.target,modifier:U.modifier,accentColor:e.activeColor,refreshKey:mn}),e.activeTool==="hand"&&e.isAnnotating&&!U&&(St?Fe.current.element:ft)&&ot(ul,{element:St?Fe.current.element:ft,radius:(as=St==null?void 0:St.radius)!=null?as:Un(ft),accentColor:e.activeColor,hoveredCorner:pt,draggingCorner:(cs=St==null?void 0:St.corner)!=null?cs:null,cursorViewport:Tt}),e.activeTool==="hand"&&e.isAnnotating&&!U&&(q?zt.current.element:kt)&&ot(Hl,{element:q?zt.current.element:kt,fontSize:(ds=q==null?void 0:q.fontSize)!=null?ds:No(kt).fontSize,lineHeight:(us=q==null?void 0:q.lineHeight)!=null?us:No(kt).lineHeight,accentColor:e.activeColor,hoveredProperty:Y,draggingProperty:(ps=q==null?void 0:q.property)!=null?ps:null,cursorViewport:Tt}),e.activeTool==="hand"&&e.isAnnotating&&!U&&(fe?Ve.current.element:z)&&ot(mi,{element:fe?Ve.current.element:z,padding:(fs=fe==null?void 0:fe.padding)!=null?fs:go(z),accentColor:e.activeColor,hoveredSide:Q,draggingSide:(gs=fe==null?void 0:fe.side)!=null?gs:null,cursorViewport:Tt,refreshKey:q?q.fontSize+q.lineHeight*1e3:0}),e.activeTool==="inspector"&&e.isAnnotating&&ot(Co,{children:me&&!e.inspectedElement&&(()=>{let h=!!ae||!!(M!=null&&M.linkedSelector)||e.annotations.some(x=>{if(!x.linkedSelector)return!1;try{return me.matches(x.linkedSelector)}catch(J){return!1}});return ot(bo,{element:me,isSelected:!1,elementInfo:xt,color:e.activeColor,hideTooltip:h})})()}),e.activeTool==="model"&&e.isAnnotating&&ce.size>0&&[...ce.entries()].map(([h,x])=>ot(bo,{element:x.rootElement,isSelected:!0,elementInfo:{selector:"",tagName:x.rootElement.tagName.toLowerCase(),reactComponent:h},color:"#8b5cf6"},h)),e.activeTool==="model"&&e.isAnnotating&&Bo&&ot(bo,{element:Bo.rootElement,isSelected:!0,elementInfo:{selector:"",tagName:Bo.rootElement.tagName.toLowerCase(),reactComponent:Bo.name},color:"#22c55e"}),e.activeTool==="model"&&e.isAnnotating&&un.length>0&&un.map((h,x)=>ot("div",{style:{position:"absolute",left:h.x,top:h.y,width:h.width,height:h.height,backgroundColor:"rgba(255, 0, 0, 0.08)",pointerEvents:"none",zIndex:9998},children:h.direction==="vertical"?ko(Co,{children:[ot("div",{style:{position:"absolute",left:"50%",top:0,width:6,height:1,backgroundColor:"#FF0000",transform:"translateX(-50%)"}}),ot("div",{style:{position:"absolute",left:"50%",top:0,bottom:0,width:1,backgroundColor:"#FF0000",transform:"translateX(-50%)"}}),ot("div",{style:{position:"absolute",left:"50%",bottom:0,width:6,height:1,backgroundColor:"#FF0000",transform:"translateX(-50%)"}}),ot("div",{style:{position:"absolute",left:"calc(50% + 6px)",top:h.height<16?-6:"50%",transform:h.height<16?"none":"translateY(-50%)",fontSize:11,fontWeight:600,color:"#fff",backgroundColor:"#FF0000",padding:"2px 4px",whiteSpace:"nowrap",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1},children:Math.round(h.height)})]}):ko(Co,{children:[ot("div",{style:{position:"absolute",left:0,top:"50%",width:1,height:6,backgroundColor:"#FF0000",transform:"translateY(-50%)"}}),ot("div",{style:{position:"absolute",left:0,right:0,top:"50%",height:1,backgroundColor:"#FF0000",transform:"translateY(-50%)"}}),ot("div",{style:{position:"absolute",right:0,top:"50%",width:1,height:6,backgroundColor:"#FF0000",transform:"translateY(-50%)"}}),ot("div",{style:{position:"absolute",left:h.width<30?0:"50%",top:(h.width<30,void 0),bottom:"calc(50% + 4px)",transform:h.width<30?"none":"translateX(-50%)",fontSize:11,fontWeight:600,color:"#fff",backgroundColor:"#FF0000",padding:"2px 4px",whiteSpace:"nowrap",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:1},children:Math.round(h.width)})]})},x)),e.activeTool==="model"&&e.isAnnotating&&oe&&ot(bo,{element:oe.rootElement,isSelected:!1,elementInfo:{selector:"",tagName:oe.rootElement.tagName.toLowerCase(),reactComponent:oe.name},color:g!=null&&g.has(oe.name)?"#22c55e":"#8b5cf6"}),e.activeTool==="hand"&&e.isAnnotating&&e.inspectedElement&&ko(Co,{children:[Le&&Le!=="padding"&&Le!=="gap"&&(()=>{var F;let h=new Set(e.annotations.map(W=>W.groupId||W.id)).size,x=e.inspectedElement.info.selector,J=e.styleModifications.findIndex(W=>W.selector===x),T=J>=0?h+J+1:h+e.styleModifications.length+1,P=e.styleModifications.find(W=>W.selector===x),H=(F=P==null?void 0:P.changes.length)!=null?F:0,se=!!(P!=null&&P.captured);return ot(bo,{element:e.inspectedElement.el,isSelected:!0,elementInfo:e.inspectedElement.info,color:se?"#999999":e.activeColor,annotationNumber:T,changeCount:H})})(),Le==="padding"&&ot(mi,{element:e.inspectedElement.el,padding:go(e.inspectedElement.el),accentColor:e.activeColor,hoveredSide:null,draggingSide:null}),Le==="gap"&&ot(ci,{element:e.inspectedElement.el,gap:Fo(e.inspectedElement.el),accentColor:e.activeColor,hoveredAxis:null,draggingAxis:null}),ot(Bl,{element:e.inspectedElement.el,elementInfo:e.inspectedElement.info,selector:e.inspectedElement.info.selector,styleModifications:e.styleModifications,dispatch:t,onClose:()=>t({type:"SELECT_ELEMENT",payload:null}),onHover:Ze,accentColor:e.activeColor,toolbarRef:O})]})]})}import{useCallback as cn,useEffect as wn,useMemo as Di,useRef as Pt,useState as jo}from"react";import{Circle as Iu,Component as Ru,Hand as Au,MessageCircle as Pu,Pen as Bu,Slash as Ou,Square as Du,Trash2 as Hu,Type as Fu}from"lucide-react";import{useEffect as ru,useRef as iu}from"react";function zl(e,t,o,r,n){let i=iu(0);ru(()=>{if(!o.current||(localStorage.setItem(n.expanded,String(e)),!e))return;let s=t.annotations.length;(s>=i.current||s===0||!r)&&(localStorage.setItem(n.annotations,JSON.stringify(t.annotations)),i.current=s),localStorage.setItem(n.styleMods,JSON.stringify(t.styleModifications)),localStorage.setItem(n.spacingChanges,JSON.stringify(t.spacingTokenChanges)),localStorage.setItem(n.tool,t.activeTool),localStorage.setItem(n.color,t.activeColor),localStorage.setItem(n.stroke,String(t.strokeWidth)),t.inspectedElement?localStorage.setItem(n.inspected,JSON.stringify({selector:t.inspectedElement.info.selector,info:t.inspectedElement.info})):localStorage.removeItem(n.inspected)},[e,t.annotations,t.styleModifications,t.spacingTokenChanges,t.activeTool,t.activeColor,t.strokeWidth,t.inspectedElement,r,o,n])}import{Component as su,createElement as lu,useCallback as Er,useEffect as To,useRef as Mo,useState as Sn}from"react";import{Fragment as Lo,jsx as He,jsxs as Qt}from"react/jsx-runtime";var $l="popmelt-library-tab",au=/^#[0-9a-fA-F]{3,8}$/,cu=/^(?:rgba?|hsla?|oklch)\([^)]+\)$/,du=new Set(["black","white","red","blue","green","yellow","orange","purple","pink","gray","grey","cyan","magenta","brown","navy","teal","maroon","olive","silver","aqua","fuchsia","lime"]),uu=/^-?\d+(\.\d+)?(px|rem|em|%)$/;function Wl(e){let t=e.trim();return au.test(t)||cu.test(t)||du.has(t.toLowerCase())}function pu(e){return uu.test(e.trim())}function fu(e){let t=e.trim().match(/^(-?\d+(?:\.\d+)?)px$/);return t?parseFloat(t[1]):null}function Pi(e,t=""){if(e==null)return[];if(typeof e!="object")return[[t,String(e)]];if(Array.isArray(e))return[[t,e.map(String).join(", ")]];let o=[];for(let[r,n]of Object.entries(e)){let i=t?`${t}.${r}`:r;if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let s=n;typeof s.value=="string"?o.push([i,s.value]):o.push(...Pi(n,i))}else o.push([i,Array.isArray(n)?n.map(String).join(", "):String(n!=null?n:"")])}return o}function gu(e){return e.length===0?"generic":e.filter(([,r])=>Wl(r)).length>e.length/2?"colors":e.filter(([,r])=>pu(r)).length>e.length/2?"spacing":"generic"}var mu=m(f({position:"fixed",top:16,right:16,bottom:80,width:300,backgroundColor:"#ffffff"},bn),{boxSizing:"content-box",zIndex:10001,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12,color:"#1f2937",padding:12,pointerEvents:"auto"}),Yl={border:"none",background:"none",cursor:"pointer",fontFamily:"inherit",fontSize:11,fontWeight:600,padding:"2px 0",color:"#9ca3af"},hu=m(f({},Yl),{color:"#1f2937",borderBottom:"1.5px solid #1f2937"});function yu({entries:e}){let t=[],o=[];for(let r of e)Wl(r[1])?t.push(r):o.push(r);return Qt(Lo,{children:[t.length>0&&He("div",{style:{display:"flex",flexWrap:"wrap",gap:2,marginBottom:o.length>0?6:0},children:t.map(([r,n])=>He("div",{title:`${r.split(".").pop()}: ${n}`,style:{width:28,height:28,backgroundColor:n,outline:"1px solid rgba(0,0,0,0.08)",outlineOffset:-1}},r))}),o.length>0&&He(Bi,{entries:o})]})}var wr=[0,1,2,4,8,12,16,20,24,28,32];function bu(e){if(e<=32){let t=wr[0],o=Math.abs(e-t);for(let r=1;r<wr.length;r++){let n=Math.abs(e-wr[r]);n<o&&(t=wr[r],o=n)}return t}return Math.round(e/8)*8}function xu({label:e,value:t,px:o,tokenPath:r,rawToken:n,onHover:i,onModify:s,onDelete:l}){let[a,c]=Sn(!1),[d,u]=Sn(null),p=Mo(!1),g=Mo(0),S=Mo(0),v=Mo([]),y=d!==null?d:o,w=d!==null?`${d}px`:t,O=d!==null,A=Er(E=>{E.preventDefault(),p.current=!0,g.current=E.clientX,S.current=o;let I=sr(n);v.current=Jr(I);let $=G=>{let M=G.clientX-g.current,D=Math.max(0,Math.round(S.current+M));G.shiftKey&&(D=bu(D));for(let X of v.current)X.element.style.setProperty(X.property,D+"px","important");u(D),i==null||i({name:e,px:D,token:I})},Z=()=>{window.removeEventListener("mousemove",$),window.removeEventListener("mouseup",Z),document.body.style.cursor="",p.current=!1,u(G=>{if(G!==null&&G!==o&&s){let M=sr(n),D=M.bindings&&M.bindings.length>0,X;if(D){let ae=Kr(M.bindings,S.current,G);X=JSON.stringify(m(f({},M),{value:`${G}px`,bindings:ae}))}else{let ae=Ks(v.current,S.current),Re=Zs(v.current);if(ae.length>0){let We=Kr(ae,S.current,G);X=JSON.stringify({value:`${G}px`,property:Re,bindings:We})}else X=`${G}px`}let ee=typeof n=="string"?n:JSON.stringify(n),he=v.current.map(ae=>({selector:sn(ae.element),property:ae.property})),ve=Qs(v.current,S.current,G);s({tokenPath:r,originalValue:ee,currentValue:X,targets:he,originalPx:S.current,currentPx:G},{id:Math.random().toString(36).substring(2,9),tokenPath:r,tokenName:e,originalPx:S.current,newPx:G,affectedElements:ve})}return G})};document.body.style.cursor="ew-resize",window.addEventListener("mousemove",$),window.addEventListener("mouseup",Z)},[o,e,r,n,i,s]),C=sr(n);return Qt("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:11,padding:"1px 0",cursor:"ew-resize",userSelect:"none"},onMouseEnter:()=>{p.current||(c(!0),i==null||i({name:e,px:y,token:C}))},onMouseLeave:()=>{p.current||(c(!1),i==null||i(null))},onMouseDown:A,children:[He("span",{style:{color:a||O?"#FF0000":"#9ca3af"},children:e}),Qt("span",{style:{display:"flex",alignItems:"center",gap:4},children:[He("span",{style:{color:a||O?"#FF0000":"#6b7280",fontWeight:600},children:w}),l&&a&&!O&&He("button",{type:"button",title:"Remove token",onMouseDown:E=>{E.stopPropagation();let I=typeof n=="string"?n:JSON.stringify(n);l(r,I)},style:{border:"none",background:"none",cursor:"pointer",padding:0,fontSize:10,lineHeight:1,color:"#9ca3af"},onMouseEnter:E=>{E.currentTarget.style.color="#FF0000"},onMouseLeave:E=>{E.currentTarget.style.color="#9ca3af"},children:"\u2715"})]})]})}function vu({entries:e,categoryKey:t,rawTokens:o,onHover:r,onModify:n,onDelete:i}){let s=[],l=[];for(let a of e){let c=fu(a[1]);c!==null?s.push([a[0],a[1],c]):l.push(a)}return Qt(Lo,{children:[s.length>0&&He("div",{style:{display:"flex",flexDirection:"column",gap:2},children:s.map(([a,c,d])=>{let u=a.split(".").pop(),p=o?Su(o,a):c,g=p&&typeof p=="object"&&"value"in p?p:c;return He(xu,{label:u,value:c,px:d,tokenPath:`tokens.${t}.${a}`,rawToken:g,onHover:r,onModify:n,onDelete:i},a)})}),l.length>0&&He(Bi,{entries:l})]})}function Su(e,t){let o=t.split("."),r=e;for(let n of o){if(r==null||typeof r!="object")return;r=r[n]}return r}function Bi({entries:e}){return He("div",{style:{display:"flex",flexDirection:"column",gap:3},children:e.map(([t,o])=>Qt("div",{style:{fontSize:11},children:[He("div",{style:{color:"#9ca3af",fontSize:10,marginBottom:1},children:t}),He("div",{style:{color:"#1f2937",lineHeight:1.4,paddingLeft:8},children:o})]},t))})}function jl({entries:e,categoryKey:t,rawTokens:o,onSpacingHover:r,onModifyToken:n,onDeleteToken:i}){let s=gu(e);return s==="colors"?He(yu,{entries:e}):s==="spacing"?He(vu,{entries:e,categoryKey:t,rawTokens:o,onHover:r,onModify:n,onDelete:i}):He(Bi,{entries:e})}function wu(e){let t=e.toLowerCase(),o=null,r=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,{acceptNode(i){return i.closest("#devtools-toolbar, #devtools-canvas, #devtools-scrim, [data-popmelt-panel]")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),n=r.currentNode;for(;n=r.nextNode();){let i=n,s=Object.keys(i).find(a=>a.startsWith("__reactFiber$")||a.startsWith("__reactInternalInstance$"));if(!s)continue;let l=i[s];for(;l;){let a=l.type,c=typeof a=="function"||typeof a=="object"?(a==null?void 0:a.displayName)||(a==null?void 0:a.name):null;if(typeof c=="string"){let d=c.toLowerCase();if(d===t){let u=f({},l.memoizedProps);return delete u.ref,{type:a,props:u}}if(!o){if(d.length>=4&&t.includes(d)){let u=f({},l.memoizedProps);delete u.ref,o={type:a,props:u}}else if(t.length>=4&&d.includes(t)){let u=f({},l.memoizedProps);delete u.ref,o={type:a,props:u}}}}l=l.return}}return o}var Ai=class extends su{constructor(){super(...arguments);this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(){this.props.onError()}render(){return this.state.hasError?null:this.props.children}};function Eu({children:e}){return He("div",{style:{fontWeight:700,fontSize:11,color:"#6b7280",letterSpacing:"0.05em",marginBottom:6},children:e})}function ku({tokens:e,onSpacingTokenHover:t,onModifyToken:o,onDeleteToken:r}){return!e||Object.keys(e).length===0?He("div",{style:{color:"#9ca3af",fontSize:11},children:"No tokens defined yet."}):He(Lo,{children:Object.entries(e).map(([n,i])=>Qt("div",{style:{marginBottom:14},children:[He(Eu,{children:n}),He(jl,{entries:Pi(i),categoryKey:n,rawTokens:i,onSpacingHover:t,onModifyToken:o,onDeleteToken:r})]},n))})}function Cu({rules:e}){return!e||e.length===0?He("div",{style:{color:"#9ca3af",fontSize:11},children:"No rules defined yet."}):He(Lo,{children:e.map((t,o)=>Qt("div",{style:{display:"flex",gap:6,marginBottom:4,lineHeight:1.4,fontSize:11},children:[Qt("span",{style:{color:"#9ca3af",flexShrink:0},children:[o+1,"."]}),He("span",{children:t})]},o))})}function Mu({name:e,value:t,selected:o,highlighted:r,onRemove:n,onHover:i}){var G;let[s,l]=Sn(!1),[a,c]=Sn(!1),d=Mo(null),u=Mo(0),[p,g]=Sn(0),[S,v]=Sn(0),y=Pi(t),w=(G=y.find(([M])=>M==="description"))==null?void 0:G[1];To(()=>{if(!a&&!r){g(0),v(0),u.current=0;return}let M=po(e);g(M.length)},[a,r,e]),To(()=>{o&&d.current&&d.current.scrollIntoView({behavior:"smooth",block:"nearest"})},[o]);let O=o||r||a,A=o?"139,92,246":"34,197,94",C=o?"#8b5cf6":"#22c55e",E=O?`rgba(${A},0.06)`:void 0,I=O?`inset 0 0 0 1.5px rgba(${A},0.35)`:void 0,$=r||a,Z=Er(()=>{let M=po(e);if(M.length===0)return;let D=u.current%M.length;M[D].rootElement.scrollIntoView({behavior:"smooth",block:"center"}),v(D),u.current=D+1,i==null||i({name:e,instanceIndex:D})},[e,i]);return Qt("div",{ref:d,onClick:Z,onMouseEnter:()=>{c(!0),i==null||i({name:e,instanceIndex:0})},onMouseLeave:()=>{c(!1),i==null||i(null)},style:{marginBottom:8,background:E,padding:6,boxShadow:I,cursor:"pointer"},children:[Qt("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Qt("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[He("div",{style:{fontWeight:700,fontSize:11,letterSpacing:"0.05em",padding:"2px 6px",backgroundColor:$?C:"transparent",color:$?"#fff":"#6b7280"},children:e}),$&&p>1&&Qt("span",{style:{fontSize:10,fontWeight:600,color:"#9ca3af"},children:[S+1,"/",p]})]}),n&&a&&He("button",{type:"button",title:"Remove from model",onClick:M=>{M.stopPropagation(),n(e)},style:{border:"none",background:"none",cursor:"pointer",padding:"0 2px",fontSize:14,lineHeight:1,color:"#9ca3af",marginTop:-4},onMouseEnter:M=>{M.currentTarget.style.color="#FF0000"},onMouseLeave:M=>{M.currentTarget.style.color="#9ca3af"},children:"\u2715"})]}),w&&He("div",{style:{fontSize:11,color:$?"#1f2937":"#9ca3af",marginBottom:6,lineHeight:1.4},children:w}),s?He(jl,{entries:y.filter(([M])=>M!=="description"),categoryKey:""}):He(Tu,{name:e,onNotFound:()=>l(!0),entries:y})]})}function Tu({name:e,onNotFound:t}){let[o,r]=Sn(null),[n,i]=Sn(!1);return To(()=>{let s=wu(e);s||t(),r(s),i(!0)},[e,t]),!n||!o?null:He(Ai,{onError:t,children:He("div",{"data-popmelt-panel":!0,onClick:s=>{s.preventDefault(),s.stopPropagation()},style:{width:"100%",overflowY:"auto",overflowX:"hidden",maxHeight:150,padding:"1rem",outline:"1px solid rgba(0,0,0,0.06)",backgroundColor:"rgb(250,250,250)",boxSizing:"border-box",marginBottom:4,display:"flex",flexDirection:"column",justifyContent:"stretch",alignItems:"center",contain:"layout paint",position:"relative",isolation:"isolate"},children:He("div",{style:{zoom:.5,pointerEvents:"none"},children:lu(o.type,o.props)})})})}function Lu({components:e,selectedComponent:t,hoveredComponent:o,onRemove:r,onHover:n}){if(!e||Object.keys(e).length===0)return He("div",{style:{color:"#9ca3af",fontSize:11},children:"No component patterns defined yet."});let i=new Set(Object.keys(e)),s=Gr(i),l=Object.entries(e).sort(([a],[c])=>{var d,u;return((d=s.get(a))!=null?d:1/0)-((u=s.get(c))!=null?u:1/0)});return He(Lo,{children:l.map(([a,c])=>He(Mu,{name:a,value:c,selected:t===a,highlighted:o===a,onRemove:r,onHover:n},a))})}function Gl({bridgeUrl:e,modelRefreshKey:t,onMouseEnter:o,onMouseLeave:r,selectedComponent:n,hoveredComponent:i,onComponentHover:s,onSpacingTokenHover:l,onModifySpacingToken:a,onDeleteSpacingToken:c,onComponentAdded:d,onComponentRemoved:u}){let[p,g]=Sn(void 0),[S,v]=Sn(!0),[y,w]=Sn(()=>{try{let D=localStorage.getItem($l);if(D==="tokens"||D==="components"||D==="rules")return D}catch(D){}return"components"});To(()=>{io(e).then(D=>{g(D),v(!1)})},[e,t]),To(()=>{try{localStorage.setItem($l,y)}catch(D){}},[y]),To(()=>{n&&(w("components"),io(e).then(D=>{D&&g(D)}))},[n,e]);let O=Er((D,X)=>{g(ee=>{if(!(ee!=null&&ee.tokens))return ee;let he=JSON.parse(JSON.stringify(ee.tokens)),ve=D.split("."),ae=he;for(let Re=1;Re<ve.length-1;Re++)if(ae=ae[ve[Re]],!ae)return ee;return delete ae[ve[ve.length-1]],m(f({},ee),{tokens:he})}),c==null||c(D,X)},[c]),A=Er(D=>{g(X=>{if(!(X!=null&&X.components))return X;let ve=X.components,{[D]:ee}=ve,he=Hn(ve,[Qo(D)]);return m(f({},X),{components:he})}),u==null||u(D)},[u]),C=p==null?void 0:p.tokens,E=p==null?void 0:p.components,I=p==null?void 0:p.rules,$=C&&Object.keys(C).length>0,Z=E&&Object.keys(E).length>0,G=I&&I.length>0,M=!p||!$&&!Z&&!G;return Qt("div",{style:mu,onMouseEnter:o,onMouseLeave:r,children:[Qt("div",{style:{display:"flex",alignItems:"center",gap:6,fontWeight:700,fontSize:13,marginBottom:6},children:[He("span",{children:"Model"}),He("code",{style:{fontSize:10,fontWeight:500,backgroundColor:"rgba(0,0,0,0.06)",padding:"1px 4px",color:"#6b7280"},children:"M"})]}),He("div",{style:{display:"flex",gap:12,marginBottom:10,borderBottom:"1px solid rgba(0,0,0,0.08)",paddingBottom:6},children:["components","rules"].map(D=>He("button",{type:"button",style:y===D?hu:Yl,onClick:()=>w(D),children:D.charAt(0).toUpperCase()+D.slice(1)},D))}),He("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:S?He("div",{style:{color:"#9ca3af",fontSize:11},children:"Loading..."}):M?He("div",{style:{color:"#9ca3af",lineHeight:1.5},children:"No design model yet. Pattern-scoped annotations will build one automatically."}):Qt(Lo,{children:[y==="components"&&He(Lu,{components:E,selectedComponent:n,hoveredComponent:i,onRemove:A,onHover:s}),y==="tokens"&&He(ku,{tokens:C,onSpacingTokenHover:l,onModifyToken:a,onDeleteToken:c?O:void 0}),y==="rules"&&He(Cu,{rules:I})]})})]})}import{jsx as Vl}from"react/jsx-runtime";var Pn={iconDefault:"#1f2937",iconActive:"#1f2937",bgActive:"#f3f4f6",bgHover:"#f9fafb",separator:"#e5e7eb"};function Bn({children:e,active:t,siblingActive:o,disabled:r,onClick:n,title:i}){let s=()=>r?.4:o&&!t?.5:1,l={position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:0,border:"none",cursor:r?"default":"pointer",transition:"background-color 150ms ease, color 150ms ease, transform 100ms ease, opacity 150ms ease",backgroundColor:t?Pn.bgActive:"transparent",color:t?Pn.iconActive:Pn.iconDefault,opacity:s()};return Vl("button",{type:"button",onClick:r?void 0:n,title:i,disabled:r,style:l,onMouseEnter:a=>{r||(a.currentTarget.style.opacity="1",t||(a.currentTarget.style.backgroundColor=Pn.bgHover))},onMouseLeave:a=>{r||(a.currentTarget.style.opacity=String(s()),t||(a.currentTarget.style.backgroundColor="transparent"))},onMouseDown:a=>{r||(a.currentTarget.style.transform="scale(0.95)")},onMouseUp:a=>{r||(a.currentTarget.style.transform="scale(1)")},children:e})}function Oi(){return Vl("div",{style:{width:1,height:20,backgroundColor:"rgba(0, 0, 0, 0.05)",margin:"0 8px"}})}import{Fragment as eo,jsx as re,jsxs as yt}from"react/jsx-runtime";var to=[{type:"rectangle",icon:Du,label:"Rectangle",shortcut:"R"},{type:"circle",icon:Iu,label:"Oval",shortcut:"O"},{type:"line",icon:Ou,label:"Line",shortcut:"L"},{type:"freehand",icon:Bu,label:"Pen",shortcut:"P"}],Nu=new Set(to.map(e=>e.type));function _u(e,t,o,r,n,i,s,l){let a=(e-n)*(r-i)-(o-n)*(t-i),c=(e-s)*(i-l)-(n-s)*(t-l),d=(e-o)*(l-r)-(s-o)*(t-r),u=a<0||c<0||d<0,p=a>0||c>0||d>0;return!(u&&p)}function zu(){let e=window.innerWidth-16,t=e-326,o=window.innerHeight-80;return{left:t,right:e,y:o}}var $u=[{type:"text",icon:Fu,label:"Text",shortcut:"T"}],Ul={inspector:{name:"Comment",desc:"Pin feedback to specific elements on the page.",usage:["Click any element to attach a comment","Type your note, then hand off to your AI","Your AI may ask clarifying questions","Replies get threaded"],keys:[{key:"C",desc:"Select tool"},{key:"Click",desc:"Pin comment to element"},{key:"Esc",desc:"Deselect"},{key:"\u2318 Enter",desc:"Hand off to your AI",accent:!0}]},hand:{name:"Handle",desc:"Quickly finetune layout and typescale.",usage:["Edges \u2192 padding","Between items \u2192 spacing","Corners \u2192 rounding","Right of text \u2192 font size","Below text \u2192 line height","Click a spacing handle to cycle distribution","Right-click \u2192 inspect element styles"],keys:[{key:"H",desc:"Select tool"},{key:"Shift",desc:"Snap to scale"},{key:"\u2325 + swipe",desc:"Cycle justify / flip direction"},{key:"\u21E7 + swipe",desc:"Cycle align-items"},{key:"Right-click",desc:"Inspect styles"},{key:"Esc",desc:"Deselect"},{key:"\u2318 Enter",desc:"Hand off to your AI",accent:!0}]},rectangle:{name:"Rectangle",desc:"Draw rectangular highlights to mark areas of interest.",usage:["Click and drag to draw","Cycle between shapes with the dot selector"],keys:[{key:"R",desc:"Rectangle"},{key:"O",desc:"Oval"},{key:"L",desc:"Line"},{key:"P",desc:"Pen"},{key:"Esc",desc:"Cancel or deselect"},{key:"\u2318 Enter",desc:"Hand off to your AI",accent:!0}]},circle:{name:"Oval",desc:"Draw oval highlights to mark areas of interest.",usage:["Click and drag to draw","Cycle between shapes with the dot selector"],keys:[{key:"O",desc:"Oval"},{key:"R",desc:"Rectangle"},{key:"L",desc:"Line"},{key:"P",desc:"Pen"},{key:"Esc",desc:"Cancel or deselect"},{key:"\u2318 Enter",desc:"Hand off to your AI",accent:!0}]},line:{name:"Line",desc:"Draw line annotations to point at or connect elements.",usage:["Click and drag to draw","Cycle between shapes with the dot selector"],keys:[{key:"L",desc:"Line"},{key:"R",desc:"Rectangle"},{key:"O",desc:"Oval"},{key:"P",desc:"Pen"},{key:"Esc",desc:"Cancel or deselect"},{key:"\u2318 Enter",desc:"Hand off to your AI",accent:!0}]},freehand:{name:"Pen",desc:"Draw freehand paths to annotate freely.",usage:["Click and drag to draw","Cycle between shapes with the dot selector"],keys:[{key:"P",desc:"Pen"},{key:"R",desc:"Rectangle"},{key:"O",desc:"Oval"},{key:"L",desc:"Line"},{key:"Esc",desc:"Cancel or deselect"},{key:"\u2318 Enter",desc:"Hand off to your AI",accent:!0}]},text:{name:"Text",desc:"Place text labels anywhere on the page.",usage:["Click to place, then start typing","Click away or press Enter to finish","Scroll while hovering a label to resize it"],keys:[{key:"T",desc:"Select tool"},{key:"Esc",desc:"Cancel text or deselect"},{key:"\u2318 Enter",desc:"Hand off to your AI",accent:!0}]},model:{name:"Model",desc:"Promote components into the local design model.",usage:["Hover to highlight component boundaries","Scroll to walk up/down the component tree","Click to add to model.json","Green = already in model"],keys:[{key:"M",desc:"Select tool"},{key:"Scroll",desc:"Walk tree depth"},{key:"Click",desc:"Promote component"},{key:"Esc",desc:"Deselect"}]},counter:{name:"Annotations",desc:"Click to cycle, scroll to change color, long press to reset.",usage:[],keys:[{key:"Click",desc:"Cycle annotations"},{key:"Scroll",desc:"Change color"},{key:"Hold",desc:"Reset to red"}]},clear:{name:"Clear",desc:"Remove all annotations and style changes.",usage:[],keys:[{key:"\u2318 \u232B",desc:"Clear all"},{key:"\u232B",desc:"Delete selected annotation"},{key:"\u2318 Z",desc:"Undo"},{key:"\u2318 \u21E7 Z",desc:"Redo"}]},collapse:{name:"Popmelt",desc:`Comment and zhuzh, then hand off.
|
|
11
11
|
|
|
12
|
-
Your AI gets the visual and technical context it needs to act.`,usage:[],keys:[{key:"\u2318\u2318",desc:"Toggle toolbar"}]}},Ou=m(f({position:"fixed",bottom:16,right:16,zIndex:9999,display:"flex",alignItems:"center",backgroundColor:"#ffffff"},gn),{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",cursor:"pointer",overflow:"visible",boxSizing:"content-box",transition:"all 0ms cubic-bezier(0.4, 0, 0.2, 1)"}),Bi="devtools-toolbar-expanded",Oi="devtools-annotations",Di="devtools-style-modifications",Fi="devtools-active-tool",Gl="devtools-active-color",Vl="devtools-stroke-width",Ul="devtools-inspected-element",Ni="devtools-spacing-changes",Du={expanded:Bi,annotations:Oi,styleMods:Di,spacingChanges:Ni,tool:Fi,color:Gl,stroke:Vl,inspected:Ul};function Fu(){return ne("svg",{width:"16",height:"16",viewBox:"0 0 1200 1200",fill:"currentColor",stroke:"none",children:ne("path",{d:"M 233.959793 800.214905 L 468.644287 668.536987 L 472.590637 657.100647 L 468.644287 650.738403 L 457.208069 650.738403 L 417.986633 648.322144 L 283.892639 644.69812 L 167.597321 639.865845 L 54.926208 633.825623 L 26.577238 627.785339 L 3.3e-05 592.751709 L 2.73832 575.27533 L 26.577238 559.248352 L 60.724873 562.228149 L 136.187973 567.382629 L 249.422867 575.194763 L 331.570496 580.026978 L 453.261841 592.671082 L 472.590637 592.671082 L 475.328857 584.859009 L 468.724915 580.026978 L 463.570557 575.194763 L 346.389313 495.785217 L 219.543671 411.865906 L 153.100723 363.543762 L 117.181267 339.060425 L 99.060455 316.107361 L 91.248367 266.01355 L 123.865784 230.093994 L 167.677887 233.073853 L 178.872513 236.053772 L 223.248367 270.201477 L 318.040283 343.570496 L 441.825592 434.738342 L 459.946411 449.798706 L 467.194672 444.64447 L 468.080597 441.020203 L 459.946411 427.409485 L 392.617493 305.718323 L 320.778564 181.932983 L 288.80542 130.630859 L 280.348999 99.865845 C 277.369171 87.221436 275.194641 76.590698 275.194641 63.624268 L 312.322174 13.20813 L 332.8591 6.604126 L 382.389313 13.20813 L 403.248352 31.328979 L 434.013519 101.71814 L 483.865753 212.537048 L 561.181274 363.221497 L 583.812134 407.919434 L 595.892639 449.315491 L 600.40271 461.959839 L 608.214783 461.959839 L 608.214783 454.711609 L 614.577271 369.825623 L 626.335632 265.61084 L 637.771851 131.516846 L 641.718201 93.745117 L 660.402832 48.483276 L 697.530334 24.000122 L 726.52356 37.852417 L 750.362549 72 L 747.060486 94.067139 L 732.886047 186.201416 L 705.100708 330.52356 L 686.979919 427.167847 L 697.530334 427.167847 L 709.61084 415.087341 L 758.496704 350.174561 L 840.644348 247.490051 L 876.885925 206.738342 L 919.167847 161.71814 L 946.308838 140.29541 L 997.61084 140.29541 L 1035.38269 196.429626 L 1018.469849 254.416199 L 965.637634 321.422852 L 921.825562 378.201538 L 859.006714 462.765259 L 819.785278 530.41626 L 823.409424 535.812073 L 832.75177 534.92627 L 974.657776 504.724915 L 1051.328979 490.872559 L 1142.818848 475.167786 L 1184.214844 494.496582 L 1188.724854 514.147644 L 1172.456421 554.335693 L 1074.604126 578.496765 L 959.838989 601.449829 L 788.939636 641.879272 L 786.845764 643.409485 L 789.261841 646.389343 L 866.255127 653.637634 L 899.194702 655.409424 L 979.812134 655.409424 L 1129.932861 666.604187 L 1169.154419 692.537109 L 1192.671265 724.268677 L 1188.724854 748.429688 L 1128.322144 779.194641 L 1046.818848 759.865845 L 856.590759 714.604126 L 791.355774 698.335754 L 782.335693 698.335754 L 782.335693 703.731567 L 836.69812 756.885986 L 936.322205 846.845581 L 1061.073975 962.81897 L 1067.436279 991.490112 L 1051.409424 1014.120911 L 1034.496704 1011.704712 L 924.885986 929.234924 L 882.604126 892.107544 L 786.845764 811.48999 L 780.483276 811.48999 L 780.483276 819.946289 L 802.550415 852.241699 L 919.087341 1027.409424 L 925.127625 1081.127686 L 916.671204 1098.604126 L 886.469849 1109.154419 L 853.288696 1103.114136 L 785.073914 1007.355835 L 714.684631 899.516785 L 657.906067 802.872498 L 650.979858 806.81897 L 617.476624 1167.704834 L 601.771851 1186.147705 L 565.530212 1200 L 535.328857 1177.046997 L 519.302124 1139.919556 L 535.328857 1066.550537 L 554.657776 970.792053 L 570.362488 894.68457 L 584.536926 800.134277 L 592.993347 768.724976 L 592.429626 766.630859 L 585.503479 767.516968 L 514.22821 865.369263 L 405.825531 1011.865906 L 320.053711 1103.677979 L 299.516815 1111.812256 L 263.919525 1093.369263 L 267.221497 1060.429688 L 287.114136 1031.114136 L 405.825531 880.107361 L 477.422913 786.52356 L 523.651062 732.483276 L 523.328918 724.671265 L 520.590698 724.671265 L 205.288605 929.395935 L 149.154434 936.644409 L 124.993355 914.01355 L 127.973183 876.885986 L 139.409409 864.80542 L 234.201385 799.570435 L 233.879227 799.8927 Z"})})}function Nu(){return ne("svg",{width:"16",height:"16",viewBox:"0 0 158.7128 157.296",fill:"currentColor",stroke:"none",children:ne("path",{d:"M60.8734,57.2556v-14.9432c0-1.2586.4722-2.2029,1.5728-2.8314l30.0443-17.3023c4.0899-2.3593,8.9662-3.4599,13.9988-3.4599,18.8759,0,30.8307,14.6289,30.8307,30.2006,0,1.1007,0,2.3593-.158,3.6178l-31.1446-18.2467c-1.8872-1.1006-3.7754-1.1006-5.6629,0l-39.4812,22.9651ZM131.0276,115.4561v-35.7074c0-2.2028-.9446-3.7756-2.8318-4.8763l-39.481-22.9651,12.8982-7.3934c1.1007-.6285,2.0453-.6285,3.1458,0l30.0441,17.3024c8.6523,5.0341,14.4708,15.7296,14.4708,26.1107,0,11.9539-7.0769,22.965-18.2461,27.527v.0021ZM51.593,83.9964l-12.8982-7.5497c-1.1007-.6285-1.5728-1.5728-1.5728-2.8314v-34.6048c0-16.8303,12.8982-29.5722,30.3585-29.5722,6.607,0,12.7403,2.2029,17.9324,6.1349l-30.987,17.9324c-1.8871,1.1007-2.8314,2.6735-2.8314,4.8764v45.6159l-.0014-.0015ZM79.3562,100.0403l-18.4829-10.3811v-22.0209l18.4829-10.3811,18.4812,10.3811v22.0209l-18.4812,10.3811ZM91.2319,147.8591c-6.607,0-12.7403-2.2031-17.9324-6.1344l30.9866-17.9333c1.8872-1.1005,2.8318-2.6728,2.8318-4.8759v-45.616l13.0564,7.5498c1.1005.6285,1.5723,1.5728,1.5723,2.8314v34.6051c0,16.8297-13.0564,29.5723-30.5147,29.5723v.001ZM53.9522,112.7822l-30.0443-17.3024c-8.652-5.0343-14.471-15.7296-14.471-26.1107,0-12.1119,7.2356-22.9652,18.403-27.5272v35.8634c0,2.2028.9443,3.7756,2.8314,4.8763l39.3248,22.8068-12.8982,7.3938c-1.1007.6287-2.045.6287-3.1456,0ZM52.2229,138.5791c-17.7745,0-30.8306-13.3713-30.8306-29.8871,0-1.2585.1578-2.5169.3143-3.7754l30.987,17.9323c1.8871,1.1005,3.7757,1.1005,5.6628,0l39.4811-22.807v14.9435c0,1.2585-.4721,2.2021-1.5728,2.8308l-30.0443,17.3025c-4.0898,2.359-8.9662,3.4605-13.9989,3.4605h.0014ZM91.2319,157.296c19.0327,0,34.9188-13.5272,38.5383-31.4594,17.6164-4.562,28.9425-21.0779,28.9425-37.908,0-11.0112-4.719-21.7066-13.2133-29.4143.7867-3.3035,1.2595-6.607,1.2595-9.909,0-22.4929-18.2471-39.3247-39.3251-39.3247-4.2461,0-8.3363.6285-12.4262,2.045-7.0792-6.9213-16.8318-11.3254-27.5271-11.3254-19.0331,0-34.9191,13.5268-38.5384,31.4591C11.3255,36.0212,0,52.5373,0,69.3675c0,11.0112,4.7184,21.7065,13.2125,29.4142-.7865,3.3035-1.2586,6.6067-1.2586,9.9092,0,22.4923,18.2466,39.3241,39.3248,39.3241,4.2462,0,8.3362-.6277,12.426-2.0441,7.0776,6.921,16.8302,11.3251,27.5271,11.3251Z"})})}function Jl({state:e,dispatch:t,onScreenshot:o,onSendToClaude:n,hasActiveJobs:r,activeJobColor:i,onCrosshairHover:s,onClear:l,provider:a="claude",onProviderChange:c,availableProviders:d,modelIndex:p=0,modelCount:u=2,modelLabel:g="Opus 4.6",onModelChange:x,onViewThread:E,isThreadPanelOpen:h,mcpStatus:w,onInstallMcp:D,mcpJustInstalled:B,bridgeUrl:M,isBridgeConnected:C,modelSelectedComponent:L,modelCanvasHoveredComponent:k,onModelComponentHover:W,onSpacingTokenHover:ee,onModifySpacingToken:Z,onDeleteSpacingToken:F,modelRefreshKey:K,onModelComponentAdded:q,onModelComponentRemoved:we,onMouseEnter:le}){let[he,Fe]=_o(()=>typeof window=="undefined"?!1:localStorage.getItem(Bi)==="true"),[Ie,$e]=_o(0),J=It(0),V=It(0),te=It(e.isAnnotating),fe=It(!1),Ce=It(typeof window!="undefined"?localStorage.getItem(Fi):null),ge=It(typeof window!="undefined"?localStorage.getItem(Gl):null),ue=It(typeof window!="undefined"?localStorage.getItem(Vl):null),{charIndex:We}=ur(!!r),[me,lt]=_o(null),qe=It(!1),Ne=It(null),tt=It(null),A=It({x:0,y:0}),re=It(null),de=It(null),Le=It(null),ke=ln(()=>{re.current=null,de.current=null,Le.current&&(clearTimeout(Le.current),Le.current=null)},[]),Re=ln(N=>{tt.current&&(clearTimeout(tt.current),tt.current=null),qe.current?(re.current=N,de.current=f({},A.current),Le.current&&clearTimeout(Le.current),Le.current=setTimeout(()=>{re.current&&(lt(re.current),ke())},300)):(Ne.current&&clearTimeout(Ne.current),Ne.current=setTimeout(()=>{qe.current=!0,lt(N),Ne.current=null},500))},[ke]),ve=ln(()=>{ke(),Ne.current&&(clearTimeout(Ne.current),Ne.current=null),tt.current=setTimeout(()=>{qe.current=!1,lt(null)},150)},[ke]),at=ln(N=>{if(A.current={x:N.clientX,y:N.clientY},re.current&&de.current){let Q=de.current,pe=Pu();Au(N.clientX,N.clientY,Q.x,Q.y,pe.left,pe.y,pe.right,pe.y)||(lt(re.current),ke())}},[ke]),Qe=Pi(()=>{let N=(d!=null?d:[]).map(Q=>Q==="claude"?"Claude":Q==="codex"?"Codex":Q);return{name:"AI Model",desc:N.length>1?`${N.join(" and ")} are available.`:N.length===1?`Connected to ${N[0]}.`:"No AI providers detected.",usage:N.length>1?["Click the logo to switch between providers","Click the model name to switch tiers"]:["Click the model name to switch tiers"],keys:N.length>1?[{key:"Click",desc:"Switch"},{key:"\u2318 Enter",desc:"Hand off to your AI",accent:!0}]:[{key:"\u2318 Enter",desc:"Hand off to your AI",accent:!0}]}},[d]);Nl(he,e,fe,!!r,Du),bn(()=>{if(localStorage.getItem(Bi)==="true"&&!e.isAnnotating){if(he||Fe(!0),t({type:"SET_TOOL",payload:Ce.current||"inspector"}),t({type:"SET_ANNOTATING",payload:!0}),ge.current&&t({type:"SET_COLOR",payload:ge.current}),ue.current){let v=parseFloat(ue.current);isNaN(v)||t({type:"SET_STROKE_WIDTH",payload:v})}let Q=localStorage.getItem(Oi);if(Q)try{let v=JSON.parse(Q);Array.isArray(v)&&v.length>0&&t({type:"RESTORE_ANNOTATIONS",payload:{annotations:v}})}catch(v){}let pe=localStorage.getItem(Di);if(pe)try{let v=JSON.parse(pe);Array.isArray(v)&&v.length>0&&(t({type:"RESTORE_STYLE_MODIFICATIONS",payload:v}),sr(v))}catch(v){}let Ae=localStorage.getItem(Ni);if(Ae)try{let v=JSON.parse(Ae);Array.isArray(v)&&v.length>0&&t({type:"RESTORE_SPACING_TOKEN_CHANGES",payload:v})}catch(v){}let Te=localStorage.getItem(Ul);if(Te)try{let{selector:v,info:U}=JSON.parse(Te);if(v){let oe=jt(v);if(oe){let Be=U||m(f({},Jt(oe)),{selector:v});t({type:"SELECT_ELEMENT",payload:{el:oe,info:Be}})}}}catch(v){}}return fe.current=!0,()=>{fe.current=!1}},[]);let ft=It(e.styleModifications);bn(()=>{let N=ft.current,Q=e.styleModifications;N!==Q&&(lr(N),sr(Q),ft.current=Q)},[e.styleModifications]),bn(()=>{let N=te.current;te.current=e.isAnnotating,N&&!e.isAnnotating&&he&&Fe(!1)},[e.isAnnotating,he]);let rt=It(he);rt.current=he,bn(()=>{let N=pe=>{if(pe.key==="Meta"||pe.key==="Control"){let Ae=Date.now();if(Ae-J.current<300){if(V.current++,V.current>=2){if(rt.current)t({type:"SET_ANNOTATING",payload:!1}),Fe(!1);else{let U=localStorage.getItem(Fi);t({type:"SET_TOOL",payload:U||"inspector"}),t({type:"SET_ANNOTATING",payload:!0}),Fe(!0)}V.current=0}}else V.current=1;J.current=Ae}else V.current=0},Q=pe=>{pe.key!=="Meta"&&pe.key!=="Control"&&(V.current=0)};return window.addEventListener("keydown",N),window.addEventListener("keyup",Q),()=>{window.removeEventListener("keydown",N),window.removeEventListener("keyup",Q)}},[t]);let gt=ln(N=>{ke(),t({type:"SET_TOOL",payload:N}),e.isAnnotating||t({type:"SET_ANNOTATING",payload:!0}),qe.current=!1,lt(null),Ne.current&&(clearTimeout(Ne.current),Ne.current=null),tt.current&&(clearTimeout(tt.current),tt.current=null)},[t,e.isAnnotating,ke]),ct=ln(async()=>{window.focus(),await o()},[o]),Ct=ln(async()=>{n&&await n()},[n]),Pe=ln(()=>{t({type:"SET_ANNOTATING",payload:!1}),Fe(!1)},[t]),Kt=ln(()=>{lr(e.styleModifications),document.querySelectorAll("[data-pm]").forEach(N=>N.removeAttribute("data-pm")),t({type:"CLEAR"}),t({type:"CLEAR_ALL_STYLES"}),localStorage.removeItem(Oi),localStorage.removeItem(Di),localStorage.removeItem(Ni),ut(null),l==null||l()},[t,e.styleModifications,l]),[mt,Dt]=_o(29),Wt=It(null),xn=It(null),Yt=It(!1),Zt=ln(N=>{let Q=N.match(/oklch\([^)]*\s+([\d.]+)\s*\)/);return Q&&Q[1]?parseFloat(Q[1]):null},[]);bn(()=>{Yt.current=!0;let N=`oklch(0.628 0.258 ${mt})`;t({type:"SET_COLOR",payload:N}),requestAnimationFrame(()=>{Yt.current=!1})},[mt,t]),bn(()=>{if(Yt.current)return;let N=Zt(e.activeColor);N!==null&&Math.abs(N-mt)>.5&&Dt(N)},[e.activeColor,Zt,mt]);let Gt=e.annotations.length>0;bn(()=>{let N=xn.current;if(!N||!Gt)return;let Q=pe=>{pe.preventDefault(),pe.stopPropagation();let Ae=pe.deltaY>0?-1:1,Te=((mt+Ae)%360+360)%360,v=`oklch(0.628 0.258 ${Te})`;Dt(Te),e.selectedAnnotationIds.length>0&&t({type:"UPDATE_ANNOTATION_COLOR",payload:{id:e.lastSelectedId||e.selectedAnnotationIds[0],color:v}})};return N.addEventListener("wheel",Q,{passive:!1}),()=>N.removeEventListener("wheel",Q)},[Gt,e.selectedAnnotationIds,e.lastSelectedId,mt,t]);let j=It(!1),Ee=ln(()=>{j.current=!1,Wt.current=setTimeout(()=>{j.current=!0,Dt(29)},500)},[]),He=ln(()=>{Wt.current&&(clearTimeout(Wt.current),Wt.current=null)},[]);bn(()=>()=>{Wt.current&&clearTimeout(Wt.current),Le.current&&clearTimeout(Le.current)},[]);let qt=Pi(()=>dr(e.annotations),[e.annotations]),nt=Pi(()=>{let N=[],Q=new Set;for(let pe of e.annotations)if(!qt.has(pe))if(pe.groupId){if(!Q.has(pe.groupId)){Q.add(pe.groupId);let Ae=e.annotations.filter(v=>v.groupId===pe.groupId&&!qt.has(v)),Te=Ae.find(v=>v.type!=="text")||Ae[0];N.push({id:Te.id,annotations:Ae})}}else N.push({id:pe.id,annotations:[pe]});return N},[e.annotations,qt]),[vt,ut]=_o(null),ht=nt.length+e.styleModifications.length;bn(()=>{(ht===0||vt!==null&&vt>=ht)&&ut(null)},[ht,vt]),bn(()=>{if(e.selectedAnnotationIds.length===0&&!e.inspectedElement){ut(null);return}if(e.selectedAnnotationIds.length>0){let N=e.selectedAnnotationIds[0],Q=nt.findIndex(pe=>pe.id===N||pe.annotations.some(Ae=>Ae.id===N));Q>=0&&Q!==vt&&ut(Q)}},[e.selectedAnnotationIds,e.inspectedElement,nt]);let An=ln(()=>{var Q;if(ht===0)return;let N;if(vt===null?N=0:N=(vt+1)%ht,ut(N),N<nt.length){let pe=nt[N];if(!pe)return;t({type:"SELECT_ELEMENT",payload:null}),t({type:"SELECT_ANNOTATION",payload:{id:pe.id}});let Ae=pe.annotations.find(Me=>Me.type!=="text")||pe.annotations[0];if(pe.annotations.some(Me=>Me.linkedSelector))t({type:"SET_TOOL",payload:"inspector"});else if(Ae!=null&&Ae.type&&Ae.type!=="text"&&Ae.type!=="inspector"){t({type:"SET_TOOL",payload:Ae.type});let Me=qn.findIndex(Ye=>Ye.type===Ae.type);Me>=0&&$e(Me)}if(Ae!=null&&Ae.color){t({type:"SET_COLOR",payload:Ae.color});let Me=Zt(Ae.color);Me!==null&&Dt(Me)}let v=pe.annotations.flatMap(Me=>Me.points);if(v.length===0)return;let U=Math.min(...v.map(Me=>Me.x)),oe=Math.max(...v.map(Me=>Me.x)),Be=Math.min(...v.map(Me=>Me.y)),ye=Math.max(...v.map(Me=>Me.y)),et=(U+oe)/2,je=(Be+ye)/2;if(window.scrollTo({left:et-window.innerWidth/2,top:je-window.innerHeight/2,behavior:"smooth"}),h&&E){let Me=(Q=pe.annotations.find(Ye=>Ye.threadId))==null?void 0:Q.threadId;Me&&E(Me)}}else{let pe=N-nt.length,Ae=e.styleModifications[pe];if(!Ae)return;let Te=jt(Ae.selector);if(!Te)return;t({type:"SELECT_ANNOTATION",payload:{id:null}}),t({type:"SET_TOOL",payload:"inspector"}),t({type:"SELECT_ELEMENT",payload:{el:Te,info:Ae.element}});let v=Te.getBoundingClientRect(),U=v.left+v.width/2+window.scrollX,oe=v.top+v.height/2+window.scrollY;window.scrollTo({left:U-window.innerWidth/2,top:oe-window.innerHeight/2,behavior:"smooth"})}},[nt,e.styleModifications,ht,vt,t,Zt,h,E]);bn(()=>{if(!he)return;let N=Q=>{let pe=document.activeElement;if((pe==null?void 0:pe.tagName)==="INPUT"||(pe==null?void 0:pe.tagName)==="TEXTAREA")return;if((Q.metaKey||Q.ctrlKey)&&Q.key==="Enter"){n&&(e.annotations.length>0||e.styleModifications.length>0||e.spacingTokenChanges.filter(v=>!v.captured).length>0)&&(Q.preventDefault(),Ct());return}if((Q.metaKey||Q.ctrlKey)&&(Q.key==="c"||Q.key==="C"||Q.code==="KeyC")){(e.annotations.length>0||e.styleModifications.length>0)&&(Q.preventDefault(),window.focus(),ct());return}if((Q.metaKey||Q.ctrlKey)&&(Q.key==="Backspace"||Q.key==="Delete")){Q.preventDefault(),Kt();return}if(Q.metaKey||Q.ctrlKey||Q.altKey)return;let Ae={p:"freehand",l:"line",r:"rectangle",o:"circle",t:"text",c:"inspector",h:"hand"};if(Q.key.toLowerCase()==="m"){Q.preventDefault(),gt("model");return}let Te=Ae[Q.key.toLowerCase()];if(Te){Q.preventDefault();let v=qn.findIndex(U=>U.type===Te);v>=0&&$e(v),gt(Te)}};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[he,gt,ct,Ct,n,Kt,e.annotations.length,e.styleModifications.length,e.spacingTokenChanges,me]);let Vt=m(f({},Ou),{borderRadius:0,padding:he?"0 8px":"0",width:he?"auto":48,height:48,gap:0,justifyContent:he?"flex-start":"center"}),an=C===!1?"rgba(239, 68, 68, 0.4)":r&&i?i:In.iconActive;return he?xt(Zn,{children:[ne("style",{children:`
|
|
12
|
+
Your AI gets the visual and technical context it needs to act.`,usage:[],keys:[{key:"\u2318\u2318",desc:"Toggle toolbar"}]}},Wu=m(f({position:"fixed",bottom:16,right:16,zIndex:9999,display:"flex",alignItems:"center",backgroundColor:"#ffffff"},bn),{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",cursor:"pointer",overflow:"visible",boxSizing:"content-box",transition:"all 0ms cubic-bezier(0.4, 0, 0.2, 1)"}),Hi="devtools-toolbar-expanded",Fi="devtools-annotations",Ni="devtools-style-modifications",_i="devtools-active-tool",Jl="devtools-active-color",Xl="devtools-stroke-width",Kl="devtools-inspected-element",zi="devtools-spacing-changes",Yu={expanded:Hi,annotations:Fi,styleMods:Ni,spacingChanges:zi,tool:_i,color:Jl,stroke:Xl,inspected:Kl};function ju(){return re("svg",{width:"16",height:"16",viewBox:"0 0 1200 1200",fill:"currentColor",stroke:"none",children:re("path",{d:"M 233.959793 800.214905 L 468.644287 668.536987 L 472.590637 657.100647 L 468.644287 650.738403 L 457.208069 650.738403 L 417.986633 648.322144 L 283.892639 644.69812 L 167.597321 639.865845 L 54.926208 633.825623 L 26.577238 627.785339 L 3.3e-05 592.751709 L 2.73832 575.27533 L 26.577238 559.248352 L 60.724873 562.228149 L 136.187973 567.382629 L 249.422867 575.194763 L 331.570496 580.026978 L 453.261841 592.671082 L 472.590637 592.671082 L 475.328857 584.859009 L 468.724915 580.026978 L 463.570557 575.194763 L 346.389313 495.785217 L 219.543671 411.865906 L 153.100723 363.543762 L 117.181267 339.060425 L 99.060455 316.107361 L 91.248367 266.01355 L 123.865784 230.093994 L 167.677887 233.073853 L 178.872513 236.053772 L 223.248367 270.201477 L 318.040283 343.570496 L 441.825592 434.738342 L 459.946411 449.798706 L 467.194672 444.64447 L 468.080597 441.020203 L 459.946411 427.409485 L 392.617493 305.718323 L 320.778564 181.932983 L 288.80542 130.630859 L 280.348999 99.865845 C 277.369171 87.221436 275.194641 76.590698 275.194641 63.624268 L 312.322174 13.20813 L 332.8591 6.604126 L 382.389313 13.20813 L 403.248352 31.328979 L 434.013519 101.71814 L 483.865753 212.537048 L 561.181274 363.221497 L 583.812134 407.919434 L 595.892639 449.315491 L 600.40271 461.959839 L 608.214783 461.959839 L 608.214783 454.711609 L 614.577271 369.825623 L 626.335632 265.61084 L 637.771851 131.516846 L 641.718201 93.745117 L 660.402832 48.483276 L 697.530334 24.000122 L 726.52356 37.852417 L 750.362549 72 L 747.060486 94.067139 L 732.886047 186.201416 L 705.100708 330.52356 L 686.979919 427.167847 L 697.530334 427.167847 L 709.61084 415.087341 L 758.496704 350.174561 L 840.644348 247.490051 L 876.885925 206.738342 L 919.167847 161.71814 L 946.308838 140.29541 L 997.61084 140.29541 L 1035.38269 196.429626 L 1018.469849 254.416199 L 965.637634 321.422852 L 921.825562 378.201538 L 859.006714 462.765259 L 819.785278 530.41626 L 823.409424 535.812073 L 832.75177 534.92627 L 974.657776 504.724915 L 1051.328979 490.872559 L 1142.818848 475.167786 L 1184.214844 494.496582 L 1188.724854 514.147644 L 1172.456421 554.335693 L 1074.604126 578.496765 L 959.838989 601.449829 L 788.939636 641.879272 L 786.845764 643.409485 L 789.261841 646.389343 L 866.255127 653.637634 L 899.194702 655.409424 L 979.812134 655.409424 L 1129.932861 666.604187 L 1169.154419 692.537109 L 1192.671265 724.268677 L 1188.724854 748.429688 L 1128.322144 779.194641 L 1046.818848 759.865845 L 856.590759 714.604126 L 791.355774 698.335754 L 782.335693 698.335754 L 782.335693 703.731567 L 836.69812 756.885986 L 936.322205 846.845581 L 1061.073975 962.81897 L 1067.436279 991.490112 L 1051.409424 1014.120911 L 1034.496704 1011.704712 L 924.885986 929.234924 L 882.604126 892.107544 L 786.845764 811.48999 L 780.483276 811.48999 L 780.483276 819.946289 L 802.550415 852.241699 L 919.087341 1027.409424 L 925.127625 1081.127686 L 916.671204 1098.604126 L 886.469849 1109.154419 L 853.288696 1103.114136 L 785.073914 1007.355835 L 714.684631 899.516785 L 657.906067 802.872498 L 650.979858 806.81897 L 617.476624 1167.704834 L 601.771851 1186.147705 L 565.530212 1200 L 535.328857 1177.046997 L 519.302124 1139.919556 L 535.328857 1066.550537 L 554.657776 970.792053 L 570.362488 894.68457 L 584.536926 800.134277 L 592.993347 768.724976 L 592.429626 766.630859 L 585.503479 767.516968 L 514.22821 865.369263 L 405.825531 1011.865906 L 320.053711 1103.677979 L 299.516815 1111.812256 L 263.919525 1093.369263 L 267.221497 1060.429688 L 287.114136 1031.114136 L 405.825531 880.107361 L 477.422913 786.52356 L 523.651062 732.483276 L 523.328918 724.671265 L 520.590698 724.671265 L 205.288605 929.395935 L 149.154434 936.644409 L 124.993355 914.01355 L 127.973183 876.885986 L 139.409409 864.80542 L 234.201385 799.570435 L 233.879227 799.8927 Z"})})}function Gu(){return re("svg",{width:"16",height:"16",viewBox:"0 0 158.7128 157.296",fill:"currentColor",stroke:"none",children:re("path",{d:"M60.8734,57.2556v-14.9432c0-1.2586.4722-2.2029,1.5728-2.8314l30.0443-17.3023c4.0899-2.3593,8.9662-3.4599,13.9988-3.4599,18.8759,0,30.8307,14.6289,30.8307,30.2006,0,1.1007,0,2.3593-.158,3.6178l-31.1446-18.2467c-1.8872-1.1006-3.7754-1.1006-5.6629,0l-39.4812,22.9651ZM131.0276,115.4561v-35.7074c0-2.2028-.9446-3.7756-2.8318-4.8763l-39.481-22.9651,12.8982-7.3934c1.1007-.6285,2.0453-.6285,3.1458,0l30.0441,17.3024c8.6523,5.0341,14.4708,15.7296,14.4708,26.1107,0,11.9539-7.0769,22.965-18.2461,27.527v.0021ZM51.593,83.9964l-12.8982-7.5497c-1.1007-.6285-1.5728-1.5728-1.5728-2.8314v-34.6048c0-16.8303,12.8982-29.5722,30.3585-29.5722,6.607,0,12.7403,2.2029,17.9324,6.1349l-30.987,17.9324c-1.8871,1.1007-2.8314,2.6735-2.8314,4.8764v45.6159l-.0014-.0015ZM79.3562,100.0403l-18.4829-10.3811v-22.0209l18.4829-10.3811,18.4812,10.3811v22.0209l-18.4812,10.3811ZM91.2319,147.8591c-6.607,0-12.7403-2.2031-17.9324-6.1344l30.9866-17.9333c1.8872-1.1005,2.8318-2.6728,2.8318-4.8759v-45.616l13.0564,7.5498c1.1005.6285,1.5723,1.5728,1.5723,2.8314v34.6051c0,16.8297-13.0564,29.5723-30.5147,29.5723v.001ZM53.9522,112.7822l-30.0443-17.3024c-8.652-5.0343-14.471-15.7296-14.471-26.1107,0-12.1119,7.2356-22.9652,18.403-27.5272v35.8634c0,2.2028.9443,3.7756,2.8314,4.8763l39.3248,22.8068-12.8982,7.3938c-1.1007.6287-2.045.6287-3.1456,0ZM52.2229,138.5791c-17.7745,0-30.8306-13.3713-30.8306-29.8871,0-1.2585.1578-2.5169.3143-3.7754l30.987,17.9323c1.8871,1.1005,3.7757,1.1005,5.6628,0l39.4811-22.807v14.9435c0,1.2585-.4721,2.2021-1.5728,2.8308l-30.0443,17.3025c-4.0898,2.359-8.9662,3.4605-13.9989,3.4605h.0014ZM91.2319,157.296c19.0327,0,34.9188-13.5272,38.5383-31.4594,17.6164-4.562,28.9425-21.0779,28.9425-37.908,0-11.0112-4.719-21.7066-13.2133-29.4143.7867-3.3035,1.2595-6.607,1.2595-9.909,0-22.4929-18.2471-39.3247-39.3251-39.3247-4.2461,0-8.3363.6285-12.4262,2.045-7.0792-6.9213-16.8318-11.3254-27.5271-11.3254-19.0331,0-34.9191,13.5268-38.5384,31.4591C11.3255,36.0212,0,52.5373,0,69.3675c0,11.0112,4.7184,21.7065,13.2125,29.4142-.7865,3.3035-1.2586,6.6067-1.2586,9.9092,0,22.4923,18.2466,39.3241,39.3248,39.3241,4.2462,0,8.3362-.6277,12.426-2.0441,7.0776,6.921,16.8302,11.3251,27.5271,11.3251Z"})})}function Zl({state:e,dispatch:t,onScreenshot:o,onSendToClaude:r,hasActiveJobs:n,activeJobColor:i,onCrosshairHover:s,onClear:l,provider:a="claude",onProviderChange:c,availableProviders:d,modelIndex:u=0,modelCount:p=2,modelLabel:g="Opus 4.6",onModelChange:S,onViewThread:v,isThreadPanelOpen:y,mcpStatus:w,onInstallMcp:O,mcpJustInstalled:A,bridgeUrl:C,isBridgeConnected:E,modelSelectedComponent:I,modelCanvasHoveredComponent:$,onModelComponentHover:Z,onSpacingTokenHover:G,onModifySpacingToken:M,onDeleteSpacingToken:D,modelRefreshKey:X,onModelComponentAdded:ee,onModelComponentRemoved:he,onMouseEnter:ve,toolbarRef:ae}){let[Re,We]=jo(()=>typeof window=="undefined"?!1:localStorage.getItem(Hi)==="true"),[Me,ne]=jo(0),Ae=Pt(0),V=Pt(0),oe=Pt(e.isAnnotating),Ee=Pt(!1),ce=Pt(typeof window!="undefined"?localStorage.getItem(_i):null),Ke=Pt(typeof window!="undefined"?localStorage.getItem(Jl):null),Te=Pt(typeof window!="undefined"?localStorage.getItem(Xl):null),{charIndex:xe}=gr(!!n),[me,Ge]=jo(null),xt=Pt(!1),dt=Pt(null),Ve=Pt(null),z=Pt({x:0,y:0}),ie=Pt(null),Q=Pt(null),Se=Pt(null),Le=cn(()=>{ie.current=null,Q.current=null,Se.current&&(clearTimeout(Se.current),Se.current=null)},[]),Ze=cn(Y=>{Ve.current&&(clearTimeout(Ve.current),Ve.current=null),xt.current?(ie.current=Y,Q.current=f({},z.current),Se.current&&clearTimeout(Se.current),Se.current=setTimeout(()=>{ie.current&&(Ge(ie.current),Le())},300)):(dt.current&&clearTimeout(dt.current),dt.current=setTimeout(()=>{xt.current=!0,Ge(Y),dt.current=null},500))},[Le]),fe=cn(()=>{Le(),dt.current&&(clearTimeout(dt.current),dt.current=null),Ve.current=setTimeout(()=>{xt.current=!1,Ge(null)},150)},[Le]),lt=cn(Y=>{if(z.current={x:Y.clientX,y:Y.clientY},ie.current&&Q.current){let te=Q.current,q=zu();_u(Y.clientX,Y.clientY,te.x,te.y,q.left,q.y,q.right,q.y)||(Ge(ie.current),Le())}},[Le]),Qe=Di(()=>{let Y=(d!=null?d:[]).map(te=>te==="claude"?"Claude":te==="codex"?"Codex":te);return{name:"AI Model",desc:Y.length>1?`${Y.join(" and ")} are available.`:Y.length===1?`Connected to ${Y[0]}.`:"No AI providers detected.",usage:Y.length>1?["Click the logo to switch between providers","Click the model name to switch tiers"]:["Click the model name to switch tiers"],keys:Y.length>1?[{key:"Click",desc:"Switch"},{key:"\u2318 Enter",desc:"Hand off to your AI",accent:!0}]:[{key:"\u2318 Enter",desc:"Hand off to your AI",accent:!0}]}},[d]);zl(Re,e,Ee,!!n,Yu),wn(()=>{if(localStorage.getItem(Hi)==="true"&&!e.isAnnotating){if(Re||We(!0),t({type:"SET_TOOL",payload:ce.current||"inspector"}),t({type:"SET_ANNOTATING",payload:!0}),Ke.current&&t({type:"SET_COLOR",payload:Ke.current}),Te.current){let ge=parseFloat(Te.current);isNaN(ge)||t({type:"SET_STROKE_WIDTH",payload:ge})}let te=localStorage.getItem(Fi);if(te)try{let ge=JSON.parse(te);Array.isArray(ge)&&ge.length>0&&t({type:"RESTORE_ANNOTATIONS",payload:{annotations:ge}})}catch(ge){}let q=localStorage.getItem(Ni);if(q)try{let ge=JSON.parse(q);Array.isArray(ge)&&ge.length>0&&(t({type:"RESTORE_STYLE_MODIFICATIONS",payload:ge}),cr(ge))}catch(ge){}let Pe=localStorage.getItem(zi);if(Pe)try{let ge=JSON.parse(Pe);Array.isArray(ge)&&ge.length>0&&t({type:"RESTORE_SPACING_TOKEN_CHANGES",payload:ge})}catch(ge){}let Be=localStorage.getItem(Kl);if(Be)try{let{selector:ge,info:Gt}=JSON.parse(Be);if(ge){let R=Jt(ge);if(R){let K=Gt||m(f({},qt(R)),{selector:ge});t({type:"SELECT_ELEMENT",payload:{el:R,info:K}})}}}catch(ge){}}return Ee.current=!0,()=>{Ee.current=!1}},[]);let Tt=Pt(e.styleModifications);wn(()=>{let Y=Tt.current,te=e.styleModifications;Y!==te&&(dr(Y),cr(te),Tt.current=te)},[e.styleModifications]),wn(()=>{let Y=oe.current;oe.current=e.isAnnotating,Y&&!e.isAnnotating&&Re&&We(!1)},[e.isAnnotating,Re]);let Bt=Pt(Re);Bt.current=Re,wn(()=>{let Y=q=>{if(q.key==="Meta"||q.key==="Control"){let Pe=Date.now();if(Pe-Ae.current<300){if(V.current++,V.current>=2){if(Bt.current)t({type:"SET_ANNOTATING",payload:!1}),We(!1);else{let Gt=localStorage.getItem(_i);t({type:"SET_TOOL",payload:Gt||"inspector"}),t({type:"SET_ANNOTATING",payload:!0}),We(!0)}V.current=0}}else V.current=1;Ae.current=Pe}else V.current=0},te=q=>{q.key!=="Meta"&&q.key!=="Control"&&(V.current=0)};return window.addEventListener("keydown",Y),window.addEventListener("keyup",te),()=>{window.removeEventListener("keydown",Y),window.removeEventListener("keyup",te)}},[t]);let st=cn(Y=>{Le(),t({type:"SET_TOOL",payload:Y}),e.isAnnotating||t({type:"SET_ANNOTATING",payload:!0}),xt.current=!1,Ge(null),dt.current&&(clearTimeout(dt.current),dt.current=null),Ve.current&&(clearTimeout(Ve.current),Ve.current=null)},[t,e.isAnnotating,Le]),at=cn(async()=>{window.focus(),await o()},[o]),Ot=cn(async()=>{r&&await r()},[r]),tt=cn(()=>{t({type:"SET_ANNOTATING",payload:!1}),We(!1)},[t]),vt=cn(()=>{dr(e.styleModifications),document.querySelectorAll("[data-pm]").forEach(Y=>Y.removeAttribute("data-pm")),t({type:"CLEAR"}),t({type:"CLEAR_ALL_STYLES"}),localStorage.removeItem(Fi),localStorage.removeItem(Ni),localStorage.removeItem(zi),St(null),l==null||l()},[t,e.styleModifications,l]),[$e,en]=jo(29),Kt=Pt(null),rn=Pt(null),mn=Pt(!1),En=cn(Y=>{let te=Y.match(/oklch\([^)]*\s+([\d.]+)\s*\)/);return te&&te[1]?parseFloat(te[1]):null},[]);wn(()=>{mn.current=!0;let Y=`oklch(0.628 0.258 ${$e})`;t({type:"SET_COLOR",payload:Y}),requestAnimationFrame(()=>{mn.current=!1})},[$e,t]),wn(()=>{if(mn.current)return;let Y=En(e.activeColor);Y!==null&&Math.abs(Y-$e)>.5&&en(Y)},[e.activeColor,En,$e]);let U=e.annotations.length>0;wn(()=>{let Y=rn.current;if(!Y||!U)return;let te=q=>{q.preventDefault(),q.stopPropagation();let Pe=q.deltaY>0?-1:1,Be=(($e+Pe)%360+360)%360,ge=`oklch(0.628 0.258 ${Be})`;en(Be),e.selectedAnnotationIds.length>0&&t({type:"UPDATE_ANNOTATION_COLOR",payload:{id:e.lastSelectedId||e.selectedAnnotationIds[0],color:ge}})};return Y.addEventListener("wheel",te,{passive:!1}),()=>Y.removeEventListener("wheel",te)},[U,e.selectedAnnotationIds,e.lastSelectedId,$e,t]);let Ie=Pt(!1),Fe=cn(()=>{Ie.current=!1,Kt.current=setTimeout(()=>{Ie.current=!0,en(29)},500)},[]),ft=cn(()=>{Kt.current&&(clearTimeout(Kt.current),Kt.current=null)},[]);wn(()=>()=>{Kt.current&&clearTimeout(Kt.current),Se.current&&clearTimeout(Se.current)},[]);let Lt=Di(()=>fr(e.annotations),[e.annotations]),pt=Di(()=>{let Y=[],te=new Set;for(let q of e.annotations)if(!Lt.has(q))if(q.groupId){if(!te.has(q.groupId)){te.add(q.groupId);let Pe=e.annotations.filter(ge=>ge.groupId===q.groupId&&!Lt.has(ge)),Be=Pe.find(ge=>ge.type!=="text")||Pe[0];Y.push({id:Be.id,annotations:Pe})}}else Y.push({id:q.id,annotations:[q]});return Y},[e.annotations,Lt]),[bt,St]=jo(null),dn=pt.length+e.styleModifications.length;wn(()=>{(dn===0||bt!==null&&bt>=dn)&&St(null)},[dn,bt]),wn(()=>{if(e.selectedAnnotationIds.length===0&&!e.inspectedElement){St(null);return}if(e.selectedAnnotationIds.length>0){let Y=e.selectedAnnotationIds[0],te=pt.findIndex(q=>q.id===Y||q.annotations.some(Pe=>Pe.id===Y));te>=0&&te!==bt&&St(te)}},[e.selectedAnnotationIds,e.inspectedElement,pt]);let zt=cn(()=>{var te;if(dn===0)return;let Y;if(bt===null?Y=0:Y=(bt+1)%dn,St(Y),Y<pt.length){let q=pt[Y];if(!q)return;t({type:"SELECT_ELEMENT",payload:null}),t({type:"SELECT_ANNOTATION",payload:{id:q.id}});let Pe=q.annotations.find(ke=>ke.type!=="text")||q.annotations[0];if(q.annotations.some(ke=>ke.linkedSelector))t({type:"SET_TOOL",payload:"inspector"});else if(Pe!=null&&Pe.type&&Pe.type!=="text"&&Pe.type!=="inspector"){t({type:"SET_TOOL",payload:Pe.type});let ke=to.findIndex(Ne=>Ne.type===Pe.type);ke>=0&&ne(ke)}if(Pe!=null&&Pe.color){t({type:"SET_COLOR",payload:Pe.color});let ke=En(Pe.color);ke!==null&&en(ke)}let ge=q.annotations.flatMap(ke=>ke.points);if(ge.length===0)return;let Gt=Math.min(...ge.map(ke=>ke.x)),R=Math.max(...ge.map(ke=>ke.x)),K=Math.min(...ge.map(ke=>ke.y)),de=Math.max(...ge.map(ke=>ke.y)),Oe=(Gt+R)/2,ye=(K+de)/2;if(window.scrollTo({left:Oe-window.innerWidth/2,top:ye-window.innerHeight/2,behavior:"smooth"}),y&&v){let ke=(te=q.annotations.find(Ne=>Ne.threadId))==null?void 0:te.threadId;ke&&v(ke)}}else{let q=Y-pt.length,Pe=e.styleModifications[q];if(!Pe)return;let Be=Jt(Pe.selector);if(!Be)return;t({type:"SELECT_ANNOTATION",payload:{id:null}}),t({type:"SET_TOOL",payload:"inspector"}),t({type:"SELECT_ELEMENT",payload:{el:Be,info:Pe.element}});let ge=Be.getBoundingClientRect(),Gt=ge.left+ge.width/2+window.scrollX,R=ge.top+ge.height/2+window.scrollY;window.scrollTo({left:Gt-window.innerWidth/2,top:R-window.innerHeight/2,behavior:"smooth"})}},[pt,e.styleModifications,dn,bt,t,En,y,v]);wn(()=>{if(!Re)return;let Y=te=>{let q=document.activeElement;if((q==null?void 0:q.tagName)==="INPUT"||(q==null?void 0:q.tagName)==="TEXTAREA")return;if((te.metaKey||te.ctrlKey)&&te.key==="Enter"){r&&(e.annotations.length>0||e.styleModifications.length>0||e.spacingTokenChanges.filter(ge=>!ge.captured).length>0)&&(te.preventDefault(),Ot());return}if((te.metaKey||te.ctrlKey)&&(te.key==="c"||te.key==="C"||te.code==="KeyC")){(e.annotations.length>0||e.styleModifications.length>0)&&(te.preventDefault(),window.focus(),at());return}if((te.metaKey||te.ctrlKey)&&(te.key==="Backspace"||te.key==="Delete")){te.preventDefault(),vt();return}if(te.metaKey||te.ctrlKey||te.altKey)return;let Pe={p:"freehand",l:"line",r:"rectangle",o:"circle",t:"text",c:"inspector",h:"hand"};if(te.key.toLowerCase()==="m"){te.preventDefault(),st("model");return}let Be=Pe[te.key.toLowerCase()];if(Be){te.preventDefault();let ge=to.findIndex(Gt=>Gt.type===Be);ge>=0&&ne(ge),st(Be)}};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[Re,st,at,Ot,r,vt,e.annotations.length,e.styleModifications.length,e.spacingTokenChanges,me]);let kt=m(f({},Wu),{borderRadius:0,padding:Re?"0 8px":"0",width:Re?"auto":48,height:48,gap:0,justifyContent:Re?"flex-start":"center"}),hn=E===!1?"rgba(239, 68, 68, 0.4)":n&&i?i:Pn.iconActive;return Re?yt(eo,{children:[re("style",{children:`
|
|
13
13
|
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
|
|
14
|
-
`}),
|
|
14
|
+
`}),re("div",{id:"devtools-scrim",style:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.06)",zIndex:9997,pointerEvents:"none"}}),!y&&(me==="model"||e.activeTool==="model")&&re(Gl,{bridgeUrl:C,selectedComponent:I,hoveredComponent:$,onComponentHover:Z,onSpacingTokenHover:G,onModifySpacingToken:M,onDeleteSpacingToken:D,modelRefreshKey:X,onComponentAdded:ee,onComponentRemoved:he,onMouseEnter:()=>{Le(),Ve.current&&(clearTimeout(Ve.current),Ve.current=null)},onMouseLeave:e.activeTool==="model"?void 0:fe}),me&&me!=="model"&&(me==="provider"||Ul[me])&&(()=>{let Y=me==="provider"?Qe:Ul[me];return yt("div",{onMouseEnter:me==="collapse"?()=>{Le(),Ve.current&&(clearTimeout(Ve.current),Ve.current=null)}:void 0,onMouseLeave:me==="collapse"?fe:void 0,style:f(m(f({position:"fixed",bottom:80,right:16,width:300,backgroundColor:"#ffffff"},bn),{boxSizing:"content-box",zIndex:10001,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12,color:"#1f2937",padding:12}),me!=="collapse"?{pointerEvents:"none"}:{}),children:[me==="collapse"&&re("div",{style:{marginBottom:10},children:re("svg",{width:"48",height:"48",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:re("path",{d:"M11.1406 31.2559C11.2407 31.3875 11.351 31.5132 11.4697 31.6338L3.10449 40H2.39746L11.1406 31.2559ZM8.05371 40H7.34668L14.5498 32.7959C14.8554 32.7706 15.1541 32.7063 15.4414 32.6113L8.05371 40ZM18.2197 34.0762C18.3788 34.1569 18.5445 34.2272 18.7168 34.2861L13.0039 40H12.2969L18.2197 34.0762ZM17.9531 40H17.2461L26.1338 31.1113C26.438 31.0829 26.7427 31.0148 27.0439 30.9082L17.9531 40ZM40 22.9023L22.9033 40H22.1963L40 22.1953V22.9023ZM40 27.8525L27.8525 40H27.1455L40 27.1455V27.8525ZM40 32.8027L32.8027 40H32.0957L40 32.0957V32.8027ZM40 37.752L37.752 40H37.0449L40 37.0449V37.752ZM9.06543 28.3809C9.25255 28.4332 9.45183 28.4715 9.66504 28.4883L0 38.1543V37.4473L9.06543 28.3809ZM6.59375 25.9023C6.65822 26.0626 6.73171 26.2263 6.81445 26.3896L0 33.2041V32.4971L6.59375 25.9023ZM20.25 8.00293H20.249C21.5098 8.0286 22.7219 8.25094 23.8584 8.63672L23.8604 8.63574C23.8961 8.64787 23.9312 8.66145 23.9668 8.67383C24.0611 8.70686 24.1548 8.74106 24.248 8.77637C24.2915 8.79273 24.3357 8.80727 24.3789 8.82422L24.376 8.82617C27.6145 10.0955 30.1646 12.7301 31.3213 16.0234L31.3232 16.0225C31.3327 16.0493 31.3404 16.0766 31.3496 16.1035C31.7691 17.3256 32 18.6356 32 20C32 20.8726 31.9366 21.6706 31.7598 22.4902L31.7197 22.6328C31.6412 23.0066 31.5136 23.6108 31.3408 24.2217L31.3398 24.2246C31.2967 24.377 31.251 24.5299 31.2021 24.6797C30.9215 25.5403 30.5473 26.2998 30.0879 26.2998C29.7613 26.2996 29.5995 25.9674 29.4316 25.6221C29.2501 25.2487 29.0614 24.8605 28.6484 24.8604C27.8532 24.8604 27.2081 25.5046 27.208 26.2998V27.0771C27.2079 27.6079 26.9661 28.112 26.5205 28.4004C25.9146 28.7925 25.2357 28.6462 24.7959 28.2061L24.7949 28.208C24.7897 28.2028 24.7854 28.1967 24.7803 28.1914C24.7654 28.1761 24.7507 28.1606 24.7363 28.1445C24.7105 28.1156 24.6858 28.0857 24.6621 28.0547C24.6461 28.0339 24.6302 28.013 24.6152 27.9912C24.5931 27.9591 24.5726 27.9257 24.5527 27.8916C24.5392 27.8685 24.5261 27.8452 24.5137 27.8213C24.5093 27.8128 24.5043 27.8045 24.5 27.7959L24.501 27.7939C24.3932 27.5763 24.3282 27.3276 24.3281 27.0576V26.2998C24.328 25.5993 23.8278 25.0158 23.165 24.8867V24.8877C23.0752 24.8702 22.9826 24.8604 22.8877 24.8604C22.8446 24.8604 22.8019 24.8624 22.7598 24.8662C22.0247 24.9312 21.4483 25.5479 21.4482 26.2998C21.4482 26.9127 21.4608 27.5305 21.4736 28.1494L21.4951 29.3135C21.5 29.7013 21.5015 30.089 21.4971 30.4756C21.4874 31.3103 20.8426 32 20.0078 32C19.1732 31.9998 18.5292 31.3102 18.5195 30.4756C18.5159 30.1613 18.5176 29.8464 18.5205 29.5312V29.5322C18.5212 29.4593 18.5206 29.3864 18.5215 29.3135L18.5303 28.8154V28.8145C18.5343 28.5927 18.5384 28.371 18.543 28.1494C18.5558 27.5305 18.5684 28.1129 18.5684 27.5C18.5684 26.7047 17.9232 26.0596 17.1279 26.0596C16.907 26.0596 16.6978 26.1103 16.5107 26.1992C16.2161 26.3393 15.9767 26.5769 15.834 26.8701C15.8269 26.8846 15.8201 26.8993 15.8135 26.9141C15.7821 26.9845 15.7562 27.0579 15.7363 27.1338C15.7243 27.1798 15.7155 27.2267 15.708 27.2744C15.7012 27.3175 15.6953 27.361 15.6924 27.4053C15.6903 27.4366 15.6885 27.4681 15.6885 27.5V28.7383C15.6883 29.9234 14.4911 30.7248 13.4961 30.0811C13.0505 29.7926 12.8086 29.2886 12.8086 28.7578V26.2998C12.8086 25.9737 12.6984 25.674 12.5156 25.4326C12.4437 25.3381 12.3612 25.2521 12.2686 25.1777V25.1768C12.0219 24.9788 11.709 24.8604 11.3682 24.8604C10.9892 24.8604 10.8622 24.8872 10.7295 25.2295C10.5837 25.6055 10.4302 26 9.92773 26C9.33081 25.9996 8.95963 25.2403 8.71484 24.3799C8.5591 23.8325 8.45907 23.571 8.3623 23.0107C8.3501 22.9401 8.33284 22.8403 8.31738 22.7529C8.12812 21.9466 8.02043 21.1089 8.00293 20.249V20.25L8 20C8 19.8617 8.00317 19.724 8.00781 19.5869C8.00837 19.5703 8.00816 19.5537 8.00879 19.5371L8.00977 19.5352C8.0998 17.1716 8.87444 14.9844 10.1396 13.1631C10.1488 13.1499 10.1587 13.1372 10.168 13.124C12.255 10.1453 15.6582 8.15745 19.5352 8.00977L19.5371 8.00879C19.5537 8.00816 19.5703 8.00837 19.5869 8.00781C19.724 8.00317 19.8617 8 20 8L20.25 8.00293ZM5.72266 22.5303L0 28.2539V27.5469L5.62793 21.918C5.6553 22.1234 5.6868 22.3275 5.72266 22.5303ZM16.2637 26.8398L16.2617 26.8408C16.2784 26.8013 16.2954 26.7627 16.3135 26.7256C16.3203 26.7116 16.3275 26.6982 16.334 26.6855C16.3125 26.7277 16.289 26.7808 16.2637 26.8398ZM40 17.9531L33.9854 23.9668C34.051 23.6832 34.1043 23.4321 34.1445 23.2412L34.1641 23.1748L34.1865 23.0967L34.1963 23.0488L40 17.2461V17.9531ZM5.87012 16.7266C5.80321 17.0165 5.74649 17.3101 5.69727 17.6064L0 23.3047V22.5977L5.87012 16.7266ZM40 13.0039L34.4297 18.5732C34.409 18.3615 34.3832 18.1513 34.3535 17.9424L40 12.2969V13.0039ZM0 18.3555V17.6484L17.6484 0H18.3555L0 18.3555ZM40 8.05371L33.458 14.5947C33.3909 14.4277 33.3202 14.2625 33.2471 14.0986L40 7.34668V8.05371ZM0 13.4053V12.6982L12.6992 0H13.4062L0 13.4053ZM40 3.10352L31.6865 11.416C31.5868 11.2805 31.4851 11.1465 31.3809 11.0146L40 2.39648V3.10352ZM29.2881 8.86523C29.1595 8.75783 29.0288 8.65278 28.8965 8.5498L37.4473 0H38.1543L29.2881 8.86523ZM0 8.45508V7.74805L7.74805 0H8.45508L0 8.45508ZM26.2783 6.92578C26.1183 6.84878 25.9562 6.77534 25.793 6.7041L32.498 0H33.2051L26.2783 6.92578ZM17.6064 5.69727C17.3101 5.74649 17.0165 5.80321 16.7266 5.87012L22.5977 0H23.3047L17.6064 5.69727ZM22.5322 5.7207C22.3295 5.685 22.1254 5.65316 21.9199 5.62598L27.5469 0H28.2539L22.5322 5.7207ZM0 3.50586V2.79883L2.79883 0H3.50586L0 3.50586Z",fill:"currentColor"})})}),yt("div",{style:{display:"flex",alignItems:"center",gap:6,fontWeight:700,fontSize:13,marginBottom:6},children:[re("span",{children:Y.name}),Y.keys[0]&&re("code",{style:{fontSize:10,fontWeight:500,backgroundColor:"rgba(0,0,0,0.06)",padding:"1px 4px",color:"#6b7280"},children:Y.keys[0].key})]}),re("div",{style:{color:"#6b7280",lineHeight:1.5,marginBottom:me==="collapse"?0:10},children:Y.desc.split(`
|
|
15
15
|
|
|
16
|
-
`).map((Q,pe)=>ne("p",{style:{margin:0,marginTop:pe>0?8:0},children:Q},pe))}),N.usage.map((Q,pe)=>xt("div",{style:{display:"flex",gap:6,marginBottom:3,lineHeight:1.4},children:[ne("span",{style:{color:"#9ca3af",flexShrink:0},children:"\u2013"}),ne("span",{children:Q})]},pe)),me==="collapse"&&w&&Object.keys(w).length>0&&(()=>{let Q=Object.entries(w).filter(([,Te])=>Te.found&&!Te.disabled).map(([Te])=>Te.charAt(0).toUpperCase()+Te.slice(1)),pe=Object.entries(w).filter(([,Te])=>!Te.found).map(([Te])=>Te);if(Q.length===0&&pe.length===0)return null;let Ae=pe.map(Te=>Te.charAt(0).toUpperCase()+Te.slice(1));return xt("div",{style:{borderTop:"1px solid rgba(0,0,0,0.08)",marginTop:10,paddingTop:8,display:"flex",alignItems:"center",gap:6,fontSize:11},children:[ne("span",{style:{width:6,height:6,borderRadius:"50%",backgroundColor:Q.length>0?"#22c55e":"rgba(0,0,0,0.2)",flexShrink:0}}),Q.length>0?xt("span",{style:{color:"#6b7280",display:"flex",alignItems:"center",gap:6},children:[xt("span",{children:["Taste library ready in ",Q.join(", "),B&&" \u2014 restart CLI to activate"]}),pe.length>0&&D&&!B&&xt("button",{type:"button",onClick:Te=>{Te.stopPropagation(),D()},style:{border:"none",background:"transparent",color:"#3b82f6",fontSize:10,fontWeight:500,fontFamily:"inherit",padding:0,cursor:"pointer",pointerEvents:"auto",textDecoration:"underline",textUnderlineOffset:2},children:["+ ",Ae.join(", ")]})]}):pe.length>0&&D?xt("span",{style:{color:"#6b7280",display:"flex",alignItems:"center",gap:6},children:[ne("span",{children:"Connect Popmelt MCP"}),ne("button",{type:"button",onClick:Te=>{Te.stopPropagation(),D()},style:{border:"none",background:"#1f2937",color:"#fff",fontSize:10,fontWeight:600,fontFamily:"inherit",padding:"2px 8px",cursor:"pointer",pointerEvents:"auto"},children:"Connect"})]}):null]})})(),N.keys.length>1&&ne("div",{style:{borderTop:"1px solid rgba(0,0,0,0.08)",marginTop:8,paddingTop:8,display:"flex",flexDirection:"column",gap:4},children:N.keys.slice(1).map((Q,pe)=>xt("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11,color:Q.accent?"#fff":"#6b7280"},children:[ne("code",{style:{fontSize:10,backgroundColor:Q.accent?e.activeColor:"rgba(0,0,0,0.06)",color:Q.accent?"#fff":void 0,padding:"1px 4px",whiteSpace:"nowrap"},children:Q.key}),ne("span",{style:{color:Q.accent?e.activeColor:void 0,fontWeight:Q.accent?600:void 0},children:Q.desc})]},pe))})]})})(),xt("div",{id:"devtools-toolbar",style:Vt,onMouseEnter:le,onMouseMove:at,children:[(e.annotations.length>0||e.styleModifications.length>0)&&xt(Zn,{children:[ne("span",{onMouseEnter:()=>Re("clear"),onMouseLeave:ve,children:ne(Ln,{onClick:Kt,title:"Clear all (\u2318\u232B)",children:ne(Iu,{size:17,strokeWidth:1.5})})}),ne(Ai,{})]}),xt("div",{style:{display:"flex",flexDirection:"row",gap:4,alignItems:"center"},children:[ne("span",{onMouseEnter:()=>Re("inspector"),onMouseLeave:ve,children:ne(Ln,{active:e.isAnnotating&&e.activeTool==="inspector",siblingActive:e.isAnnotating,onClick:()=>gt("inspector"),children:ne(Eu,{size:20,strokeWidth:1.5})})}),ne("span",{onMouseEnter:()=>Re("hand"),onMouseLeave:ve,children:ne(Ln,{active:e.isAnnotating&&e.activeTool==="hand",siblingActive:e.isAnnotating,onClick:()=>gt("hand"),children:xt("div",{style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:[ne(ku,{size:20,strokeWidth:1.5}),e.styleModifications.filter(N=>!N.captured).length>0&&ne("div",{style:{position:"absolute",top:-7,right:-9,minWidth:14,height:14,borderRadius:0,backgroundColor:e.activeColor,color:"#fff",fontSize:9,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 2px",lineHeight:1},children:e.styleModifications.filter(N=>!N.captured).length})]})})}),(()=>{let N=qn[Ie],Q=N.icon,pe=e.isAnnotating&&Ru.has(e.activeTool);return ne("span",{onMouseEnter:()=>Re(N.type),onMouseLeave:ve,children:xt("div",{style:{display:"flex",alignItems:"center",gap:0},children:[ne(Ln,{active:pe,siblingActive:e.isAnnotating,onClick:()=>gt(N.type),children:ne(Q,{size:20,strokeWidth:1.5})}),ne("button",{type:"button",onClick:()=>{let Ae=(Ie+1)%qn.length;$e(Ae),gt(qn[Ae].type)},title:"Cycle shape tool",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,width:12,height:32,border:"none",background:"none",cursor:"pointer",padding:"0 2px",opacity:e.isAnnotating&&!pe?.5:1,transition:"opacity 150ms ease"},children:qn.map((Ae,Te)=>ne("div",{style:{width:3,height:3,borderRadius:"50%",backgroundColor:Te===Ie?In.iconDefault:"rgba(0,0,0,0.2)",transition:"background-color 150ms ease"}},Te))})]})})})(),Bu.map(({type:N,icon:Q,label:pe,shortcut:Ae})=>ne("span",{onMouseEnter:()=>Re(N),onMouseLeave:ve,children:ne(Ln,{active:e.isAnnotating&&e.activeTool===N,siblingActive:e.isAnnotating,onClick:()=>gt(N),children:ne(Q,{size:20,strokeWidth:1.5})})},N)),ne("span",{onMouseEnter:()=>Re("model"),onMouseLeave:ve,children:ne(Ln,{active:e.isAnnotating&&e.activeTool==="model",siblingActive:e.isAnnotating,onClick:()=>gt("model"),children:ne(wu,{size:17,strokeWidth:1.5})})})]}),ne(Ai,{}),xt("div",{style:{display:"flex",flexDirection:"row",gap:4,alignItems:"center"},children:[(nt.length>0||e.styleModifications.length>0||e.spacingTokenChanges.filter(N=>!N.captured).length>0)&&(()=>{var Te;let N=vt!==null&&vt<nt.length?nt[vt]:null,Q=e.annotations.length>0&&e.annotations.every(v=>v.status&&v.status!=="pending"),pe=vt!==null?(Te=N==null?void 0:N.annotations.some(v=>v.status&&v.status!=="pending"))!=null?Te:!1:Q,Ae=`oklch(0.628 0.258 ${mt})`;return ne("span",{onMouseEnter:()=>Re("counter"),onMouseLeave:ve,children:ne("button",{ref:xn,type:"button",onClick:()=>{if(j.current){j.current=!1;return}An()},onMouseDown:Ee,onMouseUp:He,onMouseLeave:He,title:"Cycle through annotations \u2022 Scroll to change color \u2022 Long press to reset",style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,marginRight:4,border:"none",borderRadius:0,background:pe?"#999999":Ae,cursor:"pointer",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:11,fontWeight:600,color:"#ffffff",transition:"background 150ms ease"},children:vt!==null?vt+1:nt.length+e.styleModifications.length+e.spacingTokenChanges.filter(v=>!v.captured).length})})})(),c&&ne("span",{onMouseEnter:()=>Re("provider"),onMouseLeave:ve,style:{display:"contents"},children:xt("div",{style:{display:"flex",alignItems:"center",gap:0},children:[ne(Ln,{onClick:()=>c(a==="claude"?"codex":"claude"),children:a==="claude"?ne(Fu,{}):ne(Nu,{})}),xt("button",{type:"button",onClick:()=>{let N=(p+1)%u;x==null||x(N)},style:{display:"flex",alignItems:"center",gap:6,height:32,border:"none",background:"none",cursor:"pointer",padding:"0 4px 0 0",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:10,fontWeight:500,color:In.iconDefault,whiteSpace:"nowrap"},children:[ne("span",{children:g}),ne("span",{style:{display:"flex",flexDirection:"column",gap:2},children:Array.from({length:u},(N,Q)=>ne("div",{style:{width:3,height:3,borderRadius:"50%",backgroundColor:Q===p?In.iconDefault:"rgba(0,0,0,0.2)",transition:"background-color 150ms ease"}},Q))})]})]})}),ne("div",{onMouseEnter:N=>{s==null||s(!0),N.currentTarget.style.opacity="1",Re("collapse")},onMouseLeave:N=>{s==null||s(!1),N.currentTarget.style.opacity=r?"1":"0.3",ve()},style:{display:"inline-flex",opacity:r?1:.3,transition:"opacity 150ms ease"},children:ne(Ln,{onClick:Pe,title:"Collapse (\u2318\u2318)",children:r?ne("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:an,children:We===1?xt(Zn,{children:[ne("circle",{cx:"7",cy:"7",r:"2"}),ne("circle",{cx:"17",cy:"7",r:"2"}),ne("circle",{cx:"7",cy:"17",r:"2"}),ne("circle",{cx:"17",cy:"17",r:"2"})]}):xt(Zn,{children:[ne("circle",{cx:"12",cy:"6",r:"2"}),ne("circle",{cx:"6",cy:"12",r:"2"}),ne("circle",{cx:"18",cy:"12",r:"2"}),ne("circle",{cx:"12",cy:"18",r:"2"})]})}):xt("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:an,strokeWidth:"1.5",strokeLinecap:"round",style:{transform:"rotate(45deg)"},children:[ne("line",{x1:"12",y1:"3",x2:"12",y2:"9"}),ne("line",{x1:"12",y1:"15",x2:"12",y2:"21"}),ne("line",{x1:"3",y1:"12",x2:"9",y2:"12"}),ne("line",{x1:"15",y1:"12",x2:"21",y2:"12"})]})})})]})]})]}):xt(Zn,{children:[ne("style",{children:"@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }"}),ne("div",{id:"devtools-toolbar",style:m(f({},Vt),{overflow:"visible",opacity:.5,transition:"opacity 150ms ease"}),onMouseEnter:N=>{N.currentTarget.style.opacity="1",le==null||le()},onMouseLeave:N=>N.currentTarget.style.opacity="0.5",children:ne("button",{type:"button",style:{display:"flex",alignItems:"center",justifyContent:"center",width:48,height:48,border:"none",background:"none",cursor:"pointer",padding:0},onClick:()=>{Fe(!0),t({type:"SET_TOOL",payload:"inspector"}),t({type:"SET_ANNOTATING",payload:!0})},onMouseEnter:()=>s==null?void 0:s(!0),onMouseLeave:()=>s==null?void 0:s(!1),title:"Open annotation toolbar (\u2318\u2318)",children:r?ne("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:an,children:We===1?xt(Zn,{children:[ne("circle",{cx:"7",cy:"7",r:"2"}),ne("circle",{cx:"17",cy:"7",r:"2"}),ne("circle",{cx:"7",cy:"17",r:"2"}),ne("circle",{cx:"17",cy:"17",r:"2"})]}):xt(Zn,{children:[ne("circle",{cx:"12",cy:"6",r:"2"}),ne("circle",{cx:"6",cy:"12",r:"2"}),ne("circle",{cx:"18",cy:"12",r:"2"}),ne("circle",{cx:"12",cy:"18",r:"2"})]})}):xt("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:an,strokeWidth:"1.5",strokeLinecap:"round",children:[ne("line",{x1:"12",y1:"3",x2:"12",y2:"9"}),ne("line",{x1:"12",y1:"15",x2:"12",y2:"21"}),ne("line",{x1:"3",y1:"12",x2:"9",y2:"12"}),ne("line",{x1:"15",y1:"12",x2:"21",y2:"12"})]})})})]})}import{useEffect as Mo,useRef as Hu,useState as Hi}from"react";import{Fragment as Kl,jsx as Et,jsxs as $o}from"react/jsx-runtime";var zu={position:"fixed",bottom:86,right:16,zIndex:9999,display:"flex",flexDirection:"column"},_u=24,$u=6,Wu=_u-$u,Yu=8,Xl=m(f({display:"flex",alignItems:"center",gap:6,padding:"4px 10px",backgroundColor:"rgba(255, 255, 255, 0.85)"},gn),{backdropFilter:"blur(32px)",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:11,color:"#1f2937",whiteSpace:"nowrap",transition:"transform 200ms ease, opacity 200ms ease"});function ju(e){var s;let t=e.filter(l=>l.type==="tool_use");if(t.length===0)return"Starting\u2026";let o=t[t.length-1],n=String(o.data.tool||""),r=o.data.file?String(o.data.file):null,i=r?(s=r.split("/").pop())!=null?s:r:null;switch(n){case"Read":return i?`Reading ${i}`:"Reading file";case"Edit":return i?`Editing ${i}`:"Editing file";case"Write":return i?`Writing ${i}`:"Writing file";case"Bash":return"Running command";case"Glob":return"Searching files";case"Grep":return"Searching code";default:return n?`Using ${n}`:"Working\u2026"}}function Gu(e,t){if(e.some(r=>r.type==="question"&&r.data.jobId===t))return"Has a question";let n=e.find(r=>r.type==="done"&&r.data.jobId===t);if(n){let r=n.data.resolutions;if(Array.isArray(r)&&r.length>0)return"Applied changes"}return"Replied"}function Vu({color:e}){let[t,o]=Hi(0);return Mo(()=>{let n=setInterval(()=>{o(r=>(r+1)%2)},250);return()=>clearInterval(n)},[]),Et("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:e,style:{verticalAlign:"middle",flexShrink:0},children:t===1?$o(Kl,{children:[Et("circle",{cx:"7",cy:"7",r:"2"}),Et("circle",{cx:"17",cy:"7",r:"2"}),Et("circle",{cx:"7",cy:"17",r:"2"}),Et("circle",{cx:"17",cy:"17",r:"2"})]}):$o(Kl,{children:[Et("circle",{cx:"12",cy:"6",r:"2"}),Et("circle",{cx:"6",cy:"12",r:"2"}),Et("circle",{cx:"18",cy:"12",r:"2"}),Et("circle",{cx:"12",cy:"18",r:"2"})]})})}function Uu({color:e}){return Et("span",{style:{display:"inline-block",width:8,height:8,backgroundColor:e,opacity:.6}})}function Ju({color:e}){return Et("span",{style:{color:e,fontSize:12,lineHeight:1,width:10,display:"inline-block"},children:"\u2713"})}function Xu(){return Et("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",backgroundColor:"#ef4444"}})}function Zl({bridge:e,inFlightJobs:t,isVisible:o,onHover:n,clearSignal:r,onViewThread:i,onCancel:s,onHoverJob:l,isConnected:a,dismissedThreadIds:c}){let[d,p]=Hi([]),[u,g]=Hi(!1);Mo(()=>{r>0&&p([])},[r]),Mo(()=>{!c||c.size===0||p(h=>{let w=h.filter(D=>!D.threadId||!c.has(D.threadId));return w.length===h.length?h:w})},[c]),Mo(()=>{p(h=>{var M;let w=new Set(h.map(C=>C.jobId)),D=!1,B=h.map(C=>{let L=t[C.jobId];return L&&(!C.threadId||C.color==="#888")?(D=!0,m(f({},C),{threadId:C.threadId||L.threadId,color:C.color==="#888"?L.color:C.color})):C});for(let[C,L]of Object.entries(t))w.has(C)||(B.push({jobId:C,color:L.color,status:"queued",threadId:L.threadId}),D=!0);for(let C of e.activeJobIds)if(!w.has(C)&&!B.some(L=>L.jobId===C)){let L=e.events.find(k=>k.type==="job_started"&&k.data.jobId===C);B.push({jobId:C,color:"#888",status:"working",threadId:(M=L==null?void 0:L.data)==null?void 0:M.threadId}),D=!0}return D?B:h})},[t,e.activeJobIds]),Mo(()=>{if(e.activeJobIds.length===0)return;let h=new Set(e.activeJobIds);p(w=>w.map(D=>h.has(D.jobId)&&D.status!=="done"&&D.status!=="error"?m(f({},D),{status:"working"}):D))},[e.activeJobIds]);let x=Hu(null);if(Mo(()=>{let h=e.lastCompletedJobId;if(!h||h===x.current)return;x.current=h;let w=e.events.find(L=>L.type==="error"&&(L.data.jobId===h||e.status==="error")),D=!!w,B=D?void 0:Gu(e.events,h),M=w?String(w.data.message||""):void 0,C=w?!!w.data.cancelled:void 0;p(L=>L.map(k=>k.jobId===h?m(f({},k),{status:D?"error":"done",doneLabel:B,errorMessage:M,cancelled:C}):k))},[e.lastCompletedJobId,e.events,e.status]),!o||d.length===0&&a!==!1)return null;let E=!u&&d.length>1;return $o("div",{style:zu,"data-devtools":!0,onMouseEnter:()=>{g(!0),n(!0)},onMouseLeave:()=>{g(!1),n(!1),l==null||l(null)},children:[[...d].reverse().map((h,w)=>{var C;let D=w===d.length-1,B=d.length-1-w,M=h.status==="working"?ju(e.events.filter(L=>L.data.jobId===h.jobId)):h.status==="queued"?"Queued":h.status==="done"?h.doneLabel||"Done":h.cancelled?"Cancelled":(C=h.errorMessage)!=null&&C.includes("Timed out")?"Timed out":"Error";return Et("div",{style:{position:"relative",zIndex:w,marginBottom:E?D?0:-Wu:D?0:Yu,transform:E?`scale(${Math.max(.94,1-B*.02)})`:"scale(1)",opacity:E?Math.max(.5,1-B*.15):1,transformOrigin:"bottom right",transition:"margin-bottom 250ms ease, transform 250ms ease, opacity 250ms ease"},children:$o("div",{style:m(f({},Xl),{cursor:h.threadId&&i?"pointer":void 0}),onClick:h.threadId&&i?()=>i(h.threadId):void 0,onMouseEnter:l?()=>l(h.jobId):void 0,onMouseLeave:l?()=>l(null):void 0,title:h.errorMessage||void 0,children:[h.status==="working"&&Et(Vu,{color:h.color}),h.status==="queued"&&Et(Uu,{color:h.color}),h.status==="done"&&Et(Ju,{color:h.color}),h.status==="error"&&Et(Xu,{}),Et("span",{style:{color:h.status==="queued"?"#9ca3af":"#1f2937"},children:M}),h.status==="working"&&s&&Et("button",{onClick:L=>{L.stopPropagation(),s(h.jobId)},style:{background:"none",border:"none",cursor:"pointer",color:"#9ca3af",fontSize:14,padding:"0 4px",lineHeight:1},title:"Cancel",children:"\xD7"}),(h.status==="done"||h.status==="error")&&Et("button",{onClick:L=>{L.stopPropagation(),p(k=>k.filter(W=>W.jobId!==h.jobId))},style:{background:"none",border:"none",cursor:"pointer",color:"#9ca3af",fontSize:14,padding:"0 4px",lineHeight:1},title:"Dismiss",children:"\xD7"})]})},h.jobId)}),a===!1&&d.length>0&&$o("div",{style:m(f({},Xl),{color:"#9ca3af"}),children:[Et("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",backgroundColor:"#f59e0b"}}),Et("span",{children:"Reconnecting\u2026"})]})]})}import{useCallback as wr,useEffect as Fn,useRef as Rn,useState as Qn}from"react";import{Fragment as ep,jsx as wt}from"react/jsx-runtime";var ql="ui-monospace, SFMono-Regular, Menlo, monospace",Ku=/^#[0-9a-fA-F]{3,8}$/,Zu=/^(?:rgba?|hsla?|oklch)\([^)]+\)$/,qu=new Set(["black","white","red","blue","green","yellow","orange","purple","pink","gray","grey","cyan","magenta","brown","navy","teal","maroon","olive","silver","aqua","fuchsia","lime"]);function Qu(e){let t=e.trim();return Ku.test(t)||Zu.test(t)||qu.has(t.toLowerCase())}function zi(e,t){return wt("span",{style:{display:"inline-block",width:10,height:10,backgroundColor:e,border:"1px solid rgba(0,0,0,0.15)",borderRadius:2,verticalAlign:"middle",marginRight:3}},t)}function Wo(e){let t=[],o=/(`[^`]+`)|(\*\*\*(.+?)\*\*\*)|(\*\*(.+?)\*\*)|(\*(.+?)\*)|(_([^_]+?)_)|(\[([^\]]+)\]\(([^)]+)\))|(#[0-9a-fA-F]{3,8})(?![0-9a-fA-F])|((?:rgba?|hsla?|oklch)\([^)]+\))/g,n=0,r;for(;(r=o.exec(e))!==null;){if(r.index>n&&t.push(e.slice(n,r.index)),r[1]){let i=r[1].slice(1,-1);Qu(i)&&t.push(zi(i,`sw-${r.index}`)),t.push(wt("code",{style:{fontFamily:ql,fontSize:"0.9em",backgroundColor:"rgba(0,0,0,0.06)",padding:"1px 4px",borderRadius:2},children:i},r.index))}else r[3]!==void 0?t.push(wt("strong",{children:wt("em",{children:r[3]})},r.index)):r[5]!==void 0?t.push(wt("strong",{children:r[5]},r.index)):r[7]!==void 0?t.push(wt("em",{children:r[7]},r.index)):r[9]!==void 0?t.push(wt("em",{children:r[9]},r.index)):r[11]!==void 0&&r[12]!==void 0?t.push(wt("a",{href:r[12],target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"},children:r[11]},r.index)):r[13]!==void 0?(t.push(zi(r[13],`sw-${r.index}`)),t.push(r[13])):r[14]!==void 0&&(t.push(zi(r[14],`sw-${r.index}`)),t.push(r[14]));n=r.index+r[0].length}return n<e.length&&t.push(e.slice(n)),t}function Sr(e){var r;let t=e.split(`
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
`).map((te,q)=>re("p",{style:{margin:0,marginTop:q>0?8:0},children:te},q))}),Y.usage.map((te,q)=>yt("div",{style:{display:"flex",gap:6,marginBottom:3,lineHeight:1.4},children:[re("span",{style:{color:"#9ca3af",flexShrink:0},children:"\u2013"}),re("span",{children:te})]},q)),me==="collapse"&&w&&Object.keys(w).length>0&&(()=>{let te=Object.entries(w).filter(([,Be])=>Be.found&&!Be.disabled).map(([Be])=>Be.charAt(0).toUpperCase()+Be.slice(1)),q=Object.entries(w).filter(([,Be])=>!Be.found).map(([Be])=>Be);if(te.length===0&&q.length===0)return null;let Pe=q.map(Be=>Be.charAt(0).toUpperCase()+Be.slice(1));return yt("div",{style:{borderTop:"1px solid rgba(0,0,0,0.08)",marginTop:10,paddingTop:8,display:"flex",alignItems:"center",gap:6,fontSize:11},children:[re("span",{style:{width:6,height:6,borderRadius:"50%",backgroundColor:te.length>0?"#22c55e":"rgba(0,0,0,0.2)",flexShrink:0}}),te.length>0?yt("span",{style:{color:"#6b7280",display:"flex",alignItems:"center",gap:6},children:[yt("span",{children:["Taste library ready in ",te.join(", "),A&&" \u2014 restart CLI to activate"]}),q.length>0&&O&&!A&&yt("button",{type:"button",onClick:Be=>{Be.stopPropagation(),O()},style:{border:"none",background:"transparent",color:"#3b82f6",fontSize:10,fontWeight:500,fontFamily:"inherit",padding:0,cursor:"pointer",pointerEvents:"auto",textDecoration:"underline",textUnderlineOffset:2},children:["+ ",Pe.join(", ")]})]}):q.length>0&&O?yt("span",{style:{color:"#6b7280",display:"flex",alignItems:"center",gap:6},children:[re("span",{children:"Connect Popmelt MCP"}),re("button",{type:"button",onClick:Be=>{Be.stopPropagation(),O()},style:{border:"none",background:"#1f2937",color:"#fff",fontSize:10,fontWeight:600,fontFamily:"inherit",padding:"2px 8px",cursor:"pointer",pointerEvents:"auto"},children:"Connect"})]}):null]})})(),Y.keys.length>1&&re("div",{style:{borderTop:"1px solid rgba(0,0,0,0.08)",marginTop:8,paddingTop:8,display:"flex",flexDirection:"column",gap:4},children:Y.keys.slice(1).map((te,q)=>yt("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11,color:te.accent?"#fff":"#6b7280"},children:[re("code",{style:{fontSize:10,backgroundColor:te.accent?e.activeColor:"rgba(0,0,0,0.06)",color:te.accent?"#fff":void 0,padding:"1px 4px",whiteSpace:"nowrap"},children:te.key}),re("span",{style:{color:te.accent?e.activeColor:void 0,fontWeight:te.accent?600:void 0},children:te.desc})]},q))})]})})(),yt("div",{ref:Y=>{ae&&(ae.current=Y)},id:"devtools-toolbar",style:kt,onMouseEnter:ve,onMouseMove:lt,children:[(e.annotations.length>0||e.styleModifications.length>0)&&yt(eo,{children:[re("span",{onMouseEnter:()=>Ze("clear"),onMouseLeave:fe,children:re(Bn,{onClick:vt,title:"Clear all (\u2318\u232B)",children:re(Hu,{size:17,strokeWidth:1.5})})}),re(Oi,{})]}),yt("div",{style:{display:"flex",flexDirection:"row",gap:4,alignItems:"center"},children:[re("span",{onMouseEnter:()=>Ze("inspector"),onMouseLeave:fe,children:re(Bn,{active:e.isAnnotating&&e.activeTool==="inspector",siblingActive:e.isAnnotating,onClick:()=>st("inspector"),children:re(Pu,{size:20,strokeWidth:1.5})})}),re("span",{onMouseEnter:()=>Ze("hand"),onMouseLeave:fe,children:re(Bn,{active:e.isAnnotating&&e.activeTool==="hand",siblingActive:e.isAnnotating,onClick:()=>st("hand"),children:yt("div",{style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:[re(Au,{size:20,strokeWidth:1.5}),e.styleModifications.filter(Y=>!Y.captured).length>0&&re("div",{style:{position:"absolute",top:-7,right:-9,minWidth:14,height:14,borderRadius:0,backgroundColor:e.activeColor,color:"#fff",fontSize:9,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 2px",lineHeight:1},children:e.styleModifications.filter(Y=>!Y.captured).length})]})})}),(()=>{let Y=to[Me],te=Y.icon,q=e.isAnnotating&&Nu.has(e.activeTool);return re("span",{onMouseEnter:()=>Ze(Y.type),onMouseLeave:fe,children:yt("div",{style:{display:"flex",alignItems:"center",gap:0},children:[re(Bn,{active:q,siblingActive:e.isAnnotating,onClick:()=>st(Y.type),children:re(te,{size:20,strokeWidth:1.5})}),re("button",{type:"button",onClick:()=>{let Pe=(Me+1)%to.length;ne(Pe),st(to[Pe].type)},title:"Cycle shape tool",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,width:12,height:32,border:"none",background:"none",cursor:"pointer",padding:"0 2px",opacity:e.isAnnotating&&!q?.5:1,transition:"opacity 150ms ease"},children:to.map((Pe,Be)=>re("div",{style:{width:3,height:3,borderRadius:"50%",backgroundColor:Be===Me?Pn.iconDefault:"rgba(0,0,0,0.2)",transition:"background-color 150ms ease"}},Be))})]})})})(),$u.map(({type:Y,icon:te,label:q,shortcut:Pe})=>re("span",{onMouseEnter:()=>Ze(Y),onMouseLeave:fe,children:re(Bn,{active:e.isAnnotating&&e.activeTool===Y,siblingActive:e.isAnnotating,onClick:()=>st(Y),children:re(te,{size:20,strokeWidth:1.5})})},Y)),re("span",{onMouseEnter:()=>Ze("model"),onMouseLeave:fe,children:re(Bn,{active:e.isAnnotating&&e.activeTool==="model",siblingActive:e.isAnnotating,onClick:()=>st("model"),children:re(Ru,{size:17,strokeWidth:1.5})})})]}),re(Oi,{}),yt("div",{style:{display:"flex",flexDirection:"row",gap:4,alignItems:"center"},children:[(pt.length>0||e.styleModifications.length>0||e.spacingTokenChanges.filter(Y=>!Y.captured).length>0)&&(()=>{var Be;let Y=bt!==null&&bt<pt.length?pt[bt]:null,te=e.annotations.length>0&&e.annotations.every(ge=>ge.status&&ge.status!=="pending"),q=bt!==null?(Be=Y==null?void 0:Y.annotations.some(ge=>ge.status&&ge.status!=="pending"))!=null?Be:!1:te,Pe=`oklch(0.628 0.258 ${$e})`;return re("span",{onMouseEnter:()=>Ze("counter"),onMouseLeave:fe,children:re("button",{ref:rn,type:"button",onClick:()=>{if(Ie.current){Ie.current=!1;return}zt()},onMouseDown:Fe,onMouseUp:ft,onMouseLeave:ft,title:"Cycle through annotations \u2022 Scroll to change color \u2022 Long press to reset",style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,marginRight:4,border:"none",borderRadius:0,background:q?"#999999":Pe,cursor:"pointer",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:11,fontWeight:600,color:"#ffffff",transition:"background 150ms ease"},children:bt!==null?bt+1:pt.length+e.styleModifications.length+e.spacingTokenChanges.filter(ge=>!ge.captured).length})})})(),c&&re("span",{onMouseEnter:()=>Ze("provider"),onMouseLeave:fe,style:{display:"contents"},children:yt("div",{style:{display:"flex",alignItems:"center",gap:0},children:[re(Bn,{onClick:()=>c(a==="claude"?"codex":"claude"),children:a==="claude"?re(ju,{}):re(Gu,{})}),yt("button",{type:"button",onClick:()=>{let Y=(u+1)%p;S==null||S(Y)},style:{display:"flex",alignItems:"center",gap:6,height:32,border:"none",background:"none",cursor:"pointer",padding:"0 4px 0 0",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:10,fontWeight:500,color:Pn.iconDefault,whiteSpace:"nowrap"},children:[re("span",{children:g}),re("span",{style:{display:"flex",flexDirection:"column",gap:2},children:Array.from({length:p},(Y,te)=>re("div",{style:{width:3,height:3,borderRadius:"50%",backgroundColor:te===u?Pn.iconDefault:"rgba(0,0,0,0.2)",transition:"background-color 150ms ease"}},te))})]})]})}),re("div",{onMouseEnter:Y=>{s==null||s(!0),Y.currentTarget.style.opacity="1",Ze("collapse")},onMouseLeave:Y=>{s==null||s(!1),Y.currentTarget.style.opacity=n?"1":"0.3",fe()},style:{display:"inline-flex",opacity:n?1:.3,transition:"opacity 150ms ease"},children:re(Bn,{onClick:tt,title:"Collapse (\u2318\u2318)",children:n?re("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:hn,children:xe===1?yt(eo,{children:[re("circle",{cx:"7",cy:"7",r:"2"}),re("circle",{cx:"17",cy:"7",r:"2"}),re("circle",{cx:"7",cy:"17",r:"2"}),re("circle",{cx:"17",cy:"17",r:"2"})]}):yt(eo,{children:[re("circle",{cx:"12",cy:"6",r:"2"}),re("circle",{cx:"6",cy:"12",r:"2"}),re("circle",{cx:"18",cy:"12",r:"2"}),re("circle",{cx:"12",cy:"18",r:"2"})]})}):yt("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:hn,strokeWidth:"1.5",strokeLinecap:"round",style:{transform:"rotate(45deg)"},children:[re("line",{x1:"12",y1:"3",x2:"12",y2:"9"}),re("line",{x1:"12",y1:"15",x2:"12",y2:"21"}),re("line",{x1:"3",y1:"12",x2:"9",y2:"12"}),re("line",{x1:"15",y1:"12",x2:"21",y2:"12"})]})})})]})]})]}):yt(eo,{children:[re("style",{children:"@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }"}),re("div",{ref:Y=>{ae&&(ae.current=Y)},id:"devtools-toolbar",style:m(f({},kt),{overflow:"visible",opacity:.5,transition:"opacity 150ms ease"}),onMouseEnter:Y=>{Y.currentTarget.style.opacity="1",ve==null||ve()},onMouseLeave:Y=>Y.currentTarget.style.opacity="0.5",children:re("button",{type:"button",style:{display:"flex",alignItems:"center",justifyContent:"center",width:48,height:48,border:"none",background:"none",cursor:"pointer",padding:0},onClick:()=>{We(!0),t({type:"SET_TOOL",payload:"inspector"}),t({type:"SET_ANNOTATING",payload:!0})},onMouseEnter:()=>s==null?void 0:s(!0),onMouseLeave:()=>s==null?void 0:s(!1),title:"Open annotation toolbar (\u2318\u2318)",children:n?re("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:hn,children:xe===1?yt(eo,{children:[re("circle",{cx:"7",cy:"7",r:"2"}),re("circle",{cx:"17",cy:"7",r:"2"}),re("circle",{cx:"7",cy:"17",r:"2"}),re("circle",{cx:"17",cy:"17",r:"2"})]}):yt(eo,{children:[re("circle",{cx:"12",cy:"6",r:"2"}),re("circle",{cx:"6",cy:"12",r:"2"}),re("circle",{cx:"18",cy:"12",r:"2"}),re("circle",{cx:"12",cy:"18",r:"2"})]})}):yt("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:hn,strokeWidth:"1.5",strokeLinecap:"round",children:[re("line",{x1:"12",y1:"3",x2:"12",y2:"9"}),re("line",{x1:"12",y1:"15",x2:"12",y2:"21"}),re("line",{x1:"3",y1:"12",x2:"9",y2:"12"}),re("line",{x1:"15",y1:"12",x2:"21",y2:"12"})]})})})]})}import{useEffect as Io,useRef as Vu,useState as $i}from"react";import{Fragment as Ql,jsx as Mt,jsxs as Go}from"react/jsx-runtime";var Uu={position:"fixed",bottom:86,right:16,zIndex:9999,display:"flex",flexDirection:"column"},Ju=24,Xu=6,Ku=Ju-Xu,Zu=8,ql=m(f({display:"flex",alignItems:"center",gap:6,padding:"4px 10px",backgroundColor:"rgba(255, 255, 255, 0.85)"},bn),{backdropFilter:"blur(32px)",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:11,color:"#1f2937",whiteSpace:"nowrap",transition:"transform 200ms ease, opacity 200ms ease"});function qu(e){var s;let t=e.filter(l=>l.type==="tool_use");if(t.length===0)return"Starting\u2026";let o=t[t.length-1],r=String(o.data.tool||""),n=o.data.file?String(o.data.file):null,i=n?(s=n.split("/").pop())!=null?s:n:null;switch(r){case"Read":return i?`Reading ${i}`:"Reading file";case"Edit":return i?`Editing ${i}`:"Editing file";case"Write":return i?`Writing ${i}`:"Writing file";case"Bash":return"Running command";case"Glob":return"Searching files";case"Grep":return"Searching code";default:return r?`Using ${r}`:"Working\u2026"}}function Qu(e,t){if(e.some(n=>n.type==="question"&&n.data.jobId===t))return"Has a question";let r=e.find(n=>n.type==="done"&&n.data.jobId===t);if(r){let n=r.data.resolutions;if(Array.isArray(n)&&n.length>0)return"Applied changes"}return"Replied"}function ep({color:e}){let[t,o]=$i(0);return Io(()=>{let r=setInterval(()=>{o(n=>(n+1)%2)},250);return()=>clearInterval(r)},[]),Mt("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:e,style:{verticalAlign:"middle",flexShrink:0},children:t===1?Go(Ql,{children:[Mt("circle",{cx:"7",cy:"7",r:"2"}),Mt("circle",{cx:"17",cy:"7",r:"2"}),Mt("circle",{cx:"7",cy:"17",r:"2"}),Mt("circle",{cx:"17",cy:"17",r:"2"})]}):Go(Ql,{children:[Mt("circle",{cx:"12",cy:"6",r:"2"}),Mt("circle",{cx:"6",cy:"12",r:"2"}),Mt("circle",{cx:"18",cy:"12",r:"2"}),Mt("circle",{cx:"12",cy:"18",r:"2"})]})})}function tp({color:e}){return Mt("span",{style:{display:"inline-block",width:8,height:8,backgroundColor:e,opacity:.6}})}function np({color:e}){return Mt("span",{style:{color:e,fontSize:12,lineHeight:1,width:10,display:"inline-block"},children:"\u2713"})}function op(){return Mt("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",backgroundColor:"#ef4444"}})}function ea({bridge:e,inFlightJobs:t,isVisible:o,onHover:r,clearSignal:n,onViewThread:i,onCancel:s,onHoverJob:l,isConnected:a,dismissedThreadIds:c}){let[d,u]=$i([]),[p,g]=$i(!1);Io(()=>{n>0&&u([])},[n]),Io(()=>{!c||c.size===0||u(y=>{let w=y.filter(O=>!O.threadId||!c.has(O.threadId));return w.length===y.length?y:w})},[c]),Io(()=>{u(y=>{var C;let w=new Set(y.map(E=>E.jobId)),O=!1,A=y.map(E=>{let I=t[E.jobId];return I&&(!E.threadId||E.color==="#888")?(O=!0,m(f({},E),{threadId:E.threadId||I.threadId,color:E.color==="#888"?I.color:E.color})):E});for(let[E,I]of Object.entries(t))w.has(E)||(A.push({jobId:E,color:I.color,status:"queued",threadId:I.threadId}),O=!0);for(let E of e.activeJobIds)if(!w.has(E)&&!A.some(I=>I.jobId===E)){let I=e.events.find($=>$.type==="job_started"&&$.data.jobId===E);A.push({jobId:E,color:"#888",status:"working",threadId:(C=I==null?void 0:I.data)==null?void 0:C.threadId}),O=!0}return O?A:y})},[t,e.activeJobIds]),Io(()=>{if(e.activeJobIds.length===0)return;let y=new Set(e.activeJobIds);u(w=>w.map(O=>y.has(O.jobId)&&O.status!=="done"&&O.status!=="error"?m(f({},O),{status:"working"}):O))},[e.activeJobIds]);let S=Vu(null);if(Io(()=>{let y=e.lastCompletedJobId;if(!y||y===S.current)return;S.current=y;let w=e.events.find(I=>I.type==="error"&&(I.data.jobId===y||e.status==="error")),O=!!w,A=O?void 0:Qu(e.events,y),C=w?String(w.data.message||""):void 0,E=w?!!w.data.cancelled:void 0;u(I=>I.map($=>$.jobId===y?m(f({},$),{status:O?"error":"done",doneLabel:A,errorMessage:C,cancelled:E}):$))},[e.lastCompletedJobId,e.events,e.status]),!o||d.length===0&&a!==!1)return null;let v=!p&&d.length>1;return Go("div",{style:Uu,"data-devtools":!0,onMouseEnter:()=>{g(!0),r(!0)},onMouseLeave:()=>{g(!1),r(!1),l==null||l(null)},children:[[...d].reverse().map((y,w)=>{var E;let O=w===d.length-1,A=d.length-1-w,C=y.status==="working"?qu(e.events.filter(I=>I.data.jobId===y.jobId)):y.status==="queued"?"Queued":y.status==="done"?y.doneLabel||"Done":y.cancelled?"Cancelled":(E=y.errorMessage)!=null&&E.includes("Timed out")?"Timed out":"Error";return Mt("div",{style:{position:"relative",zIndex:w,marginBottom:v?O?0:-Ku:O?0:Zu,transform:v?`scale(${Math.max(.94,1-A*.02)})`:"scale(1)",opacity:v?Math.max(.5,1-A*.15):1,transformOrigin:"bottom right",transition:"margin-bottom 250ms ease, transform 250ms ease, opacity 250ms ease"},children:Go("div",{style:m(f({},ql),{cursor:y.threadId&&i?"pointer":void 0}),onClick:y.threadId&&i?()=>i(y.threadId):void 0,onMouseEnter:l?()=>l(y.jobId):void 0,onMouseLeave:l?()=>l(null):void 0,title:y.errorMessage||void 0,children:[y.status==="working"&&Mt(ep,{color:y.color}),y.status==="queued"&&Mt(tp,{color:y.color}),y.status==="done"&&Mt(np,{color:y.color}),y.status==="error"&&Mt(op,{}),Mt("span",{style:{color:y.status==="queued"?"#9ca3af":"#1f2937"},children:C}),y.status==="working"&&s&&Mt("button",{onClick:I=>{I.stopPropagation(),s(y.jobId)},style:{background:"none",border:"none",cursor:"pointer",color:"#9ca3af",fontSize:14,padding:"0 4px",lineHeight:1},title:"Cancel",children:"\xD7"}),(y.status==="done"||y.status==="error")&&Mt("button",{onClick:I=>{I.stopPropagation(),u($=>$.filter(Z=>Z.jobId!==y.jobId))},style:{background:"none",border:"none",cursor:"pointer",color:"#9ca3af",fontSize:14,padding:"0 4px",lineHeight:1},title:"Dismiss",children:"\xD7"})]})},y.jobId)}),a===!1&&d.length>0&&Go("div",{style:m(f({},ql),{color:"#9ca3af"}),children:[Mt("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",backgroundColor:"#f59e0b"}}),Mt("span",{children:"Reconnecting\u2026"})]})]})}import{Fragment as sp,jsx as ip,jsxs as lp}from"react/jsx-runtime";var rp=`
|
|
17
|
+
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
18
|
+
:host {
|
|
19
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
20
|
+
font-size: 12px;
|
|
21
|
+
color: #1f2937;
|
|
22
|
+
line-height: 1.5;
|
|
23
|
+
-webkit-font-smoothing: antialiased;
|
|
24
|
+
}
|
|
25
|
+
`;function ta({children:e}){return lp(sp,{children:[ip("style",{children:rp}),e]})}import{useEffect as ap,useLayoutEffect as cp,useRef as na}from"react";import{createRoot as dp}from"react-dom/client";import{Fragment as up,jsx as oa}from"react/jsx-runtime";function ra({children:e}){let t=na(null),o=na(null);return ap(()=>{let r=t.current;if(!r||r.shadowRoot)return;let n=r.attachShadow({mode:"open"}),i=document.createElement("div");return i.setAttribute("data-popmelt-root",""),n.appendChild(i),o.current=dp(i),()=>{var s;(s=o.current)==null||s.unmount(),o.current=null}},[]),cp(()=>{var r;(r=o.current)==null||r.render(oa(up,{children:e}))}),oa("div",{ref:t,"data-popmelt-shadow-host":!0,style:{display:"contents"}})}import{useCallback as Cr,useEffect as _n,useRef as On,useState as no}from"react";import{Fragment as hp,jsx as Et}from"react/jsx-runtime";var ia="ui-monospace, SFMono-Regular, Menlo, monospace",pp=/^#[0-9a-fA-F]{3,8}$/,fp=/^(?:rgba?|hsla?|oklch)\([^)]+\)$/,gp=new Set(["black","white","red","blue","green","yellow","orange","purple","pink","gray","grey","cyan","magenta","brown","navy","teal","maroon","olive","silver","aqua","fuchsia","lime"]);function mp(e){let t=e.trim();return pp.test(t)||fp.test(t)||gp.has(t.toLowerCase())}function Wi(e,t){return Et("span",{style:{display:"inline-block",width:10,height:10,backgroundColor:e,border:"1px solid rgba(0,0,0,0.15)",borderRadius:2,verticalAlign:"middle",marginRight:3}},t)}function Vo(e){let t=[],o=/(`[^`]+`)|(\*\*\*(.+?)\*\*\*)|(\*\*(.+?)\*\*)|(\*(.+?)\*)|(_([^_]+?)_)|(\[([^\]]+)\]\(([^)]+)\))|(#[0-9a-fA-F]{3,8})(?![0-9a-fA-F])|((?:rgba?|hsla?|oklch)\([^)]+\))/g,r=0,n;for(;(n=o.exec(e))!==null;){if(n.index>r&&t.push(e.slice(r,n.index)),n[1]){let i=n[1].slice(1,-1);mp(i)&&t.push(Wi(i,`sw-${n.index}`)),t.push(Et("code",{style:{fontFamily:ia,fontSize:"0.9em",backgroundColor:"rgba(0,0,0,0.06)",padding:"1px 4px",borderRadius:2},children:i},n.index))}else n[3]!==void 0?t.push(Et("strong",{children:Et("em",{children:n[3]})},n.index)):n[5]!==void 0?t.push(Et("strong",{children:n[5]},n.index)):n[7]!==void 0?t.push(Et("em",{children:n[7]},n.index)):n[9]!==void 0?t.push(Et("em",{children:n[9]},n.index)):n[11]!==void 0&&n[12]!==void 0?t.push(Et("a",{href:n[12],target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"},children:n[11]},n.index)):n[13]!==void 0?(t.push(Wi(n[13],`sw-${n.index}`)),t.push(n[13])):n[14]!==void 0&&(t.push(Wi(n[14],`sw-${n.index}`)),t.push(n[14]));r=n.index+n[0].length}return r<e.length&&t.push(e.slice(r)),t}function kr(e){var n;let t=e.split(`
|
|
26
|
+
`),o=[],r=0;for(;r<t.length;){let i=t[r];if(i.trimStart().startsWith("```")){let c=[];for(r++;r<t.length&&!t[r].trimStart().startsWith("```");)c.push(t[r]),r++;r++,o.push(Et("pre",{style:{fontFamily:ia,fontSize:"0.9em",lineHeight:1.4,backgroundColor:"rgba(0,0,0,0.04)",padding:"6px 8px",margin:"4px 0",overflowX:"auto",whiteSpace:"pre"},children:c.join(`
|
|
27
|
+
`)},o.length));continue}if(/^(-{3,}|\*{3,}|_{3,})\s*$/.test(i)){o.push(Et("hr",{style:{border:"none",borderTop:"1px solid rgba(0,0,0,0.1)",margin:"6px 0"}},o.length)),r++;continue}let s=i.match(/^(#{1,4})\s+(.+)/);if(s){let c=s[1].length,d={1:16,2:14,3:13,4:12};o.push(Et("div",{style:{fontWeight:700,fontSize:(n=d[c])!=null?n:12,margin:"8px 0 2px"},children:Vo(s[2])},o.length)),r++;continue}if(i.trimStart().startsWith("|")&&i.trimEnd().endsWith("|")){let c=[];for(;r<t.length&&t[r].trimStart().startsWith("|")&&t[r].trimEnd().endsWith("|");)c.push(t[r]),r++;let d=w=>/^\|[\s\-:|]+\|$/.test(w),u=c.filter(w=>!d(w)),p=w=>w.split("|").slice(1,-1).map(O=>O.trim()),g=w=>/^\*\*.+\*\*$/.test(w)||/^__.+__$/.test(w),S=u.map(p),v=S.length>1&&S.slice(1).every(w=>w[0]&&g(w[0])),y=S.length>0&&S[0].every(w=>g(w));o.push(Et("div",{style:{overflowX:"auto",margin:"4px 0",paddingBottom:4},children:Et("table",{style:{borderCollapse:"separate",borderSpacing:0,fontSize:"0.95em",width:"max-content",minWidth:"100%"},children:Et("tbody",{children:u.map((w,O)=>Et("tr",{children:p(w).map((A,C)=>Et(O===0?"th":"td",{style:f({border:"1px solid rgba(0,0,0,0.1)",padding:"3px 6px",textAlign:"left",fontWeight:O===0?600:400,minWidth:60,whiteSpace:"nowrap"},C===0&&v||O===0&&y?m(f(f({position:"sticky"},C===0&&v?{left:0}:{}),O===0&&y?{top:0}:{}),{background:"#fff",zIndex:C===0&&v&&O===0&&y?2:1}):{}),children:Vo(A)},C))},O))})})},o.length));continue}if(i.match(/^(\s*)([-*])\s+(.+)/)){let c=[];for(;r<t.length&&/^\s*[-*]\s+/.test(t[r]);){let d=t[r].match(/^\s*[-*]\s+(.+)/);d&&c.push(Et("li",{children:Vo(d[1])},c.length)),r++}o.push(Et("ul",{style:{margin:"2px 0",paddingLeft:20},children:c},o.length));continue}if(i.match(/^(\s*)\d+\.\s+(.+)/)){let c=[];for(;r<t.length&&/^\s*\d+\.\s+/.test(t[r]);){let d=t[r].match(/^\s*\d+\.\s+(.+)/);d&&c.push(Et("li",{children:Vo(d[1])},c.length)),r++}o.push(Et("ol",{style:{margin:"2px 0",paddingLeft:20},children:c},o.length));continue}if(i.trim()===""){o.push(Et("div",{style:{height:4}},o.length)),r++;continue}o.push(Et("div",{style:{margin:"2px 0"},children:Vo(i)},o.length)),r++}return Et(hp,{children:o})}import{Fragment as Vi,jsx as ze,jsxs as Nt}from"react/jsx-runtime";var Mr=400,Ro=16,Ui=3,yp=16,Yi="devtools-thread-panel-position";function ji(){return{top:Ro,left:window.innerWidth-Mr-2*Ui-Ro}}function sa(e,t,o){let r=o==null?void 0:o.getBoundingClientRect(),n=window.innerHeight-Ro;return r&&t+Mr+2*Ui>r.left&&(n=r.top-yp),Math.max(200,n-Math.max(0,e))}var bp=m(f({width:Mr,backgroundColor:"#ffffff"},bn),{boxSizing:"content-box",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:$t,fontSize:12,color:"#1f2937",pointerEvents:"auto"}),xp={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 5px 4px 10px",margin:"3px 3px 0",fontWeight:600,fontSize:12},vp={flex:1,overflowY:"auto",padding:"8px 0",scrollbarWidth:"none"},Sp=`
|
|
19
28
|
[data-devtools="thread-panel-messages"]:hover {
|
|
20
29
|
scrollbar-width: thin !important;
|
|
21
30
|
}
|
|
@@ -29,4 +38,4 @@ Your AI gets the visual and technical context it needs to act.`,usage:[],keys:[{
|
|
|
29
38
|
background: rgba(0,0,0,0.15);
|
|
30
39
|
border-radius: 3px;
|
|
31
40
|
}
|
|
32
|
-
`,sp={borderTop:"1px solid rgba(0, 0, 0, 0.08)",padding:12};function ea(e){return e.replace(/<resolution>[\s\S]*?<\/resolution>/g,"").replace(/<question>[\s\S]*?<\/question>/g,"").replace(/<plan>[\s\S]*?<\/plan>/g,"").replace(/<review>[\s\S]*?<\/review>/g,"").trim()}function ta(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}var Wi=["reviewing","considering","thinking","zhuzhing","iterating","tweaking","reflecting","noodling","pondering","finessing","polishing","riffing"],lp=3e3,ap=250;function na({size:e=14}){return _e("svg",{width:e,height:e,viewBox:"0 0 1200 1200",fill:"#6b7280",stroke:"none",style:{flexShrink:0},children:_e("path",{d:"M 233.959793 800.214905 L 468.644287 668.536987 L 472.590637 657.100647 L 468.644287 650.738403 L 457.208069 650.738403 L 417.986633 648.322144 L 283.892639 644.69812 L 167.597321 639.865845 L 54.926208 633.825623 L 26.577238 627.785339 L 3.3e-05 592.751709 L 2.73832 575.27533 L 26.577238 559.248352 L 60.724873 562.228149 L 136.187973 567.382629 L 249.422867 575.194763 L 331.570496 580.026978 L 453.261841 592.671082 L 472.590637 592.671082 L 475.328857 584.859009 L 468.724915 580.026978 L 463.570557 575.194763 L 346.389313 495.785217 L 219.543671 411.865906 L 153.100723 363.543762 L 117.181267 339.060425 L 99.060455 316.107361 L 91.248367 266.01355 L 123.865784 230.093994 L 167.677887 233.073853 L 178.872513 236.053772 L 223.248367 270.201477 L 318.040283 343.570496 L 441.825592 434.738342 L 459.946411 449.798706 L 467.194672 444.64447 L 468.080597 441.020203 L 459.946411 427.409485 L 392.617493 305.718323 L 320.778564 181.932983 L 288.80542 130.630859 L 280.348999 99.865845 C 277.369171 87.221436 275.194641 76.590698 275.194641 63.624268 L 312.322174 13.20813 L 332.8591 6.604126 L 382.389313 13.20813 L 403.248352 31.328979 L 434.013519 101.71814 L 483.865753 212.537048 L 561.181274 363.221497 L 583.812134 407.919434 L 595.892639 449.315491 L 600.40271 461.959839 L 608.214783 461.959839 L 608.214783 454.711609 L 614.577271 369.825623 L 626.335632 265.61084 L 637.771851 131.516846 L 641.718201 93.745117 L 660.402832 48.483276 L 697.530334 24.000122 L 726.52356 37.852417 L 750.362549 72 L 747.060486 94.067139 L 732.886047 186.201416 L 705.100708 330.52356 L 686.979919 427.167847 L 697.530334 427.167847 L 709.61084 415.087341 L 758.496704 350.174561 L 840.644348 247.490051 L 876.885925 206.738342 L 919.167847 161.71814 L 946.308838 140.29541 L 997.61084 140.29541 L 1035.38269 196.429626 L 1018.469849 254.416199 L 965.637634 321.422852 L 921.825562 378.201538 L 859.006714 462.765259 L 819.785278 530.41626 L 823.409424 535.812073 L 832.75177 534.92627 L 974.657776 504.724915 L 1051.328979 490.872559 L 1142.818848 475.167786 L 1184.214844 494.496582 L 1188.724854 514.147644 L 1172.456421 554.335693 L 1074.604126 578.496765 L 959.838989 601.449829 L 788.939636 641.879272 L 786.845764 643.409485 L 789.261841 646.389343 L 866.255127 653.637634 L 899.194702 655.409424 L 979.812134 655.409424 L 1129.932861 666.604187 L 1169.154419 692.537109 L 1192.671265 724.268677 L 1188.724854 748.429688 L 1128.322144 779.194641 L 1046.818848 759.865845 L 856.590759 714.604126 L 791.355774 698.335754 L 782.335693 698.335754 L 782.335693 703.731567 L 836.69812 756.885986 L 936.322205 846.845581 L 1061.073975 962.81897 L 1067.436279 991.490112 L 1051.409424 1014.120911 L 1034.496704 1011.704712 L 924.885986 929.234924 L 882.604126 892.107544 L 786.845764 811.48999 L 780.483276 811.48999 L 780.483276 819.946289 L 802.550415 852.241699 L 919.087341 1027.409424 L 925.127625 1081.127686 L 916.671204 1098.604126 L 886.469849 1109.154419 L 853.288696 1103.114136 L 785.073914 1007.355835 L 714.684631 899.516785 L 657.906067 802.872498 L 650.979858 806.81897 L 617.476624 1167.704834 L 601.771851 1186.147705 L 565.530212 1200 L 535.328857 1177.046997 L 519.302124 1139.919556 L 535.328857 1066.550537 L 554.657776 970.792053 L 570.362488 894.68457 L 584.536926 800.134277 L 592.993347 768.724976 L 592.429626 766.630859 L 585.503479 767.516968 L 514.22821 865.369263 L 405.825531 1011.865906 L 320.053711 1103.677979 L 299.516815 1111.812256 L 263.919525 1093.369263 L 267.221497 1060.429688 L 287.114136 1031.114136 L 405.825531 880.107361 L 477.422913 786.52356 L 523.651062 732.483276 L 523.328918 724.671265 L 520.590698 724.671265 L 205.288605 929.395935 L 149.154434 936.644409 L 124.993355 914.01355 L 127.973183 876.885986 L 139.409409 864.80542 L 234.201385 799.570435 L 233.879227 799.8927 Z"})})}function cp({color:e}){let[t,o]=Qn(0),[n,r]=Qn(()=>Math.floor(Math.random()*Wi.length));return Fn(()=>{let i=setInterval(()=>o(l=>(l+1)%2),ap),s=setInterval(()=>r(l=>(l+1)%Wi.length),lp);return()=>{clearInterval(i),clearInterval(s)}},[]),Bt("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[_e("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:e,style:{verticalAlign:"middle",flexShrink:0},children:t===1?Bt(Yi,{children:[_e("circle",{cx:"7",cy:"7",r:"2"}),_e("circle",{cx:"17",cy:"7",r:"2"}),_e("circle",{cx:"7",cy:"17",r:"2"}),_e("circle",{cx:"17",cy:"17",r:"2"})]}):Bt(Yi,{children:[_e("circle",{cx:"12",cy:"6",r:"2"}),_e("circle",{cx:"6",cy:"12",r:"2"}),_e("circle",{cx:"18",cy:"12",r:"2"}),_e("circle",{cx:"12",cy:"18",r:"2"})]})}),_e("span",{style:{fontSize:11,color:"#9ca3af",fontStyle:"italic"},children:Wi[n]})]})}function dp(e){var r;let t=String(e.data.tool||""),o=e.data.file?String(e.data.file):null,n=o?(r=o.split("/").pop())!=null?r:o:null;switch(t){case"Read":return n?`Reading ${n}`:"Reading file";case"Edit":return n?`Editing ${n}`:"Editing file";case"Write":return n?`Writing ${n}`:"Writing file";case"Bash":return"Running command";case"Glob":return"Searching files";case"Grep":return"Searching code";case"WebFetch":return"Fetching page";case"WebSearch":return"Searching web";default:return t?`Using ${t}`:null}}var up=new Set(["Read","Glob","Grep","WebFetch","WebSearch"]),pp=new Set(["Edit","Write","Bash"]);function fp(e){let t=0,o=!1;for(let n of e){if(n.type!=="tool_use")continue;let r=String(n.data.tool||"");pp.has(r)?o=!0:up.has(r)&&t++}return!o&&t>=3?"researching":o?"applying changes":null}function gp(e){let t=[];for(let o of e)if(o.type==="tool_use"){let n=dp(o);n&&t.push({kind:"tool",label:n})}else if(o.type==="delta"){let n=String(o.data.text||"");if(!n)continue;let r=t[t.length-1];r&&r.kind==="text"?r.text+=n:t.push({kind:"text",text:n})}else if(o.type==="thinking"){let n=String(o.data.text||"");if(!n)continue;let r=t[t.length-1];r&&r.kind==="thinking"?r.text+=n:t.push({kind:"thinking",text:n})}return t}function oa({threadId:e,bridgeUrl:t,accentColor:o,isStreaming:n,streamingEvents:r,onClose:i,onReply:s,onCancel:l,lastError:a,onMouseEnter:c}){let[d,p]=Qn([]),[u,g]=Qn(!0),[x,E]=Qn(""),[h,w]=Qn([]),D=Rn(null),B=Rn(null),M=Rn(null),C=Rn(n),L=Rn($i()),k=Rn({x:0,y:0}),W=Rn(!1),ee=Rn({x:0,y:0,offsetX:0,offsetY:0}),Z=Rn(!1),[,F]=Qn(0);Fn(()=>{try{let V=localStorage.getItem(_i);if(V){let te=JSON.parse(V);typeof te.top=="number"&&typeof te.left=="number"&&(Z.current=!0,L.current={top:te.top,left:te.left},F(fe=>fe+1))}}catch(V){}},[]),Fn(()=>{let V=()=>{Z.current||(L.current=$i()),F(te=>te+1)};return window.addEventListener("resize",V,{passive:!0}),()=>window.removeEventListener("resize",V)},[]),Fn(()=>{let V=M.current;if(!V)return;let te=ue=>{ue.button!==0||ue.target.closest("button")||(ue.preventDefault(),ue.stopPropagation(),W.current=!0,ee.current={x:ue.clientX,y:ue.clientY,offsetX:k.current.x,offsetY:k.current.y})},fe=ue=>{if(!W.current)return;let We=ee.current,me=We.offsetX+(ue.clientX-We.x),lt=We.offsetY+(ue.clientY-We.y),qe=Math.max(To,Math.min(window.innerWidth-kr-2*ji-To,L.current.left+me)),Ne=Math.max(To,L.current.top+lt);k.current={x:qe-L.current.left,y:Ne-L.current.top};let tt=B.current;tt&&(tt.style.top=`${Ne}px`,tt.style.left=`${qe}px`,tt.style.height=`${Ql(Ne,qe)}px`)},Ce=()=>{if(!W.current)return;let ue=L.current.top+k.current.y,We=L.current.left+k.current.x;L.current={top:ue,left:We},k.current={x:0,y:0},Z.current=!0;try{localStorage.setItem(_i,JSON.stringify({top:ue,left:We}))}catch(me){}W.current=!1},ge=()=>{L.current=$i(),k.current={x:0,y:0},Z.current=!1;try{localStorage.removeItem(_i)}catch(ue){}F(ue=>ue+1)};return V.addEventListener("mousedown",te),window.addEventListener("mousemove",fe),window.addEventListener("mouseup",Ce),V.addEventListener("dblclick",ge),()=>{V.removeEventListener("mousedown",te),window.removeEventListener("mousemove",fe),window.removeEventListener("mouseup",Ce),V.removeEventListener("dblclick",ge)}},[]);let K=wr(()=>{fetch(`${t}/thread/${e}`).then(V=>V.json()).then(V=>{var te;p((te=V.messages)!=null?te:[]),g(!1)}).catch(()=>g(!1))},[t,e]);Fn(()=>{g(!0),K()},[K]),Fn(()=>{C.current&&!n&&K(),C.current=n},[n,K]);let q=r?gp(r):[],we=r?fp(r):null;Fn(()=>{D.current&&(D.current.scrollTop=D.current.scrollHeight)},[d,q.length,n]),Fn(()=>{let V=te=>{te.key==="Escape"&&(te.stopPropagation(),i())};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[i]);let le=wr(()=>{if(!x.trim()||!s)return;let V=x.trim(),te=h.length>0?h:void 0;p(fe=>[...fe,{role:"human",timestamp:Date.now(),jobId:"pending",replyToQuestion:te?`${V} [${te.length} image${te.length>1?"s":""}]`:V}]),s(e,V,te),E(""),w([])},[x,h,e,s]),he=wr(V=>{let te=V.clipboardData.items,fe=[];for(let Ce=0;Ce<te.length;Ce++){let ge=te[Ce];if(ge.type.startsWith("image/")){let ue=ge.getAsFile();ue&&fe.push(ue)}}fe.length>0&&(V.preventDefault(),w(Ce=>[...Ce,...fe]))},[]),Fe=wr(V=>{V.key==="Enter"&&(V.metaKey||V.ctrlKey)&&(V.preventDefault(),le())},[le]),Ie=L.current.top+k.current.y,$e=L.current.left+k.current.x,J=Ql(Ie,$e);return Bt(Yi,{children:[_e("div",{"data-devtools":"thread-panel-backdrop",onMouseDown:V=>{V.target===V.currentTarget&&i()},style:{position:"fixed",inset:0,zIndex:9999}}),Bt("div",{ref:B,style:m(f({},np),{height:J,position:"fixed",top:Ie,left:$e,zIndex:1e4}),"data-devtools":"thread-panel",onMouseEnter:c,children:[Bt("div",{ref:M,style:m(f({},op),{backgroundColor:o,color:"#ffffff",cursor:"grab",userSelect:"none",WebkitUserSelect:"none"}),children:[_e("span",{children:"Conversation"}),_e("button",{onClick:i,style:{background:"none",border:"none",cursor:"pointer",fontSize:16,color:"#ffffff",padding:"0 4px",lineHeight:1},children:"\xD7"})]}),_e("style",{dangerouslySetInnerHTML:{__html:ip}}),Bt("div",{ref:D,style:rp,"data-devtools":"thread-panel-messages",children:[u&&_e("div",{style:{padding:16,color:"#9ca3af",textAlign:"center"},children:"Loading..."}),!u&&d.length===0&&!n&&_e("div",{style:{padding:16,color:"#9ca3af",textAlign:"center"},children:"No messages yet."}),d.map((V,te)=>{let fe=V.role==="human";if(V.cancelled)return _e("div",{style:{padding:"8px 16px",borderBottom:"1px solid rgba(0, 0, 0, 0.04)",opacity:te===d.length-1?1:.5},children:Bt("div",{style:{display:"flex",alignItems:"center",gap:4},children:[_e("span",{style:{fontSize:11,color:"#9ca3af",fontStyle:"italic"},children:"Cancelled"}),_e("span",{style:{fontSize:10,color:"#9ca3af",marginLeft:"auto"},children:ta(V.timestamp)})]})},`${V.jobId}-${te}`);let Ce=fe?V.replyToQuestion||V.feedbackSummary||"(annotation)":ea(V.responseText||""),ge=fe?void 0:V.question,ue=!fe&&V.resolutions&&V.resolutions.length>0,We=!fe&&V.toolsUsed&&V.toolsUsed.length>0;if(!Ce&&!ge&&!ue)return null;let me=te===d.length-1;return Bt("div",{style:{padding:"8px 16px",borderBottom:"1px solid rgba(0, 0, 0, 0.04)",opacity:me?1:.5},children:[Bt("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:4},children:[!fe&&_e(na,{size:11}),_e("span",{style:{fontWeight:600,fontSize:11,color:fe?o:"#6b7280"},children:fe?"You":"Claude Code"}),_e("span",{style:{fontSize:10,color:"#9ca3af",marginLeft:"auto"},children:ta(V.timestamp)})]}),Ce&&_e("div",{style:{lineHeight:1.5,wordBreak:"break-word"},children:fe?Ce:Sr(Ce)}),ge&&_e("div",{style:{marginTop:Ce?4:0,lineHeight:1.5,wordBreak:"break-word"},children:Sr(ge)}),(We||ue)&&Bt("div",{style:{marginTop:Ce||ge?6:0,padding:"4px 8px",backgroundColor:"rgba(0, 0, 0, 0.03)",fontSize:11,lineHeight:1.5,color:"#6b7280"},children:[We&&_e("div",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:10},children:V.toolsUsed.map((lt,qe)=>_e("div",{children:lt},qe))}),ue&&V.resolutions.map((lt,qe)=>{var A;let Ne=(A=lt.finalScope)!=null?A:lt.inferredScope,tt=Ne?`${Ne.breadth} \xB7 ${Ne.target}`:null;return Bt("div",{style:{marginTop:We?4:0},children:[_e("span",{style:{color:lt.status==="resolved"?"#10b981":"#f59e0b"},children:lt.status==="resolved"?"Done":"Needs review"}),tt&&_e("span",{style:{marginLeft:6,padding:"1px 5px",backgroundColor:"rgba(0, 0, 0, 0.06)",fontSize:10,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:tt}),lt.summary?` \u2014 ${lt.summary}`:""]},qe)})]})]},`${V.jobId}-${te}`)}),n&&Bt("div",{style:{padding:"8px 16px",borderBottom:"1px solid rgba(0, 0, 0, 0.04)"},children:[Bt("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:4},children:[_e(na,{size:11}),_e("span",{style:{fontWeight:600,fontSize:11,color:"#6b7280"},children:"Claude Code"}),we&&_e("span",{style:{fontSize:10,color:"#b0b7c3",fontStyle:"italic"},children:we}),Bt("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:6},children:[_e(cp,{color:o}),l&&_e("button",{onClick:l,style:{background:"none",border:"1px solid rgba(0,0,0,0.1)",color:"#6b7280",fontSize:10,padding:"2px 8px",cursor:"pointer",fontFamily:"inherit"},children:"Cancel"})]})]}),q.map((V,te)=>{if(V.kind==="tool")return _e("div",{style:{paddingLeft:12,fontSize:11,color:"#9ca3af",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",lineHeight:1.6},children:V.label},te);if(V.kind==="thinking")return _e("div",{style:{paddingLeft:12,marginTop:2,marginBottom:2,fontSize:11,color:"#9ca3af",fontStyle:"italic",lineHeight:1.4,whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:80,overflowY:"auto"},children:V.text},te);let fe=ea(V.text);return fe?_e("div",{style:{paddingLeft:12,marginTop:2,marginBottom:2,lineHeight:1.5,wordBreak:"break-word"},children:Sr(fe)},te):null})]})]}),!n&&a&&Bt("div",{style:{padding:"8px 16px",backgroundColor:"rgba(239, 68, 68, 0.06)",borderBottom:"1px solid rgba(0,0,0,0.04)",fontSize:11,color:"#dc2626",lineHeight:1.4},children:[_e("span",{style:{fontWeight:600},children:"Error: "}),a]}),s&&Bt("div",{style:sp,children:[h.length>0&&Bt("div",{style:{fontSize:11,color:"#6b7280",marginBottom:4,display:"flex",alignItems:"center",gap:4},children:[Bt("span",{children:[h.length," image",h.length>1?"s":""," attached"]}),_e("button",{onClick:()=>w([]),style:{background:"none",border:"none",cursor:"pointer",fontSize:11,color:"#9ca3af",padding:"0 2px"},children:"\xD7"})]}),_e("textarea",{value:x,onChange:V=>E(V.target.value),onKeyDown:Fe,onPaste:he,placeholder:"Reply... (Cmd+Enter to send)",style:{width:"100%",minHeight:60,padding:4,fontSize:12,fontFamily:Ft,backgroundColor:"rgba(0, 0, 0, 0.03)",color:"#1f2937",border:"1px solid rgba(0, 0, 0, 0.1)",borderRadius:0,outline:"none",resize:"vertical",lineHeight:1.4,boxSizing:"border-box"}}),_e("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:6},children:_e("button",{onClick:le,disabled:!x.trim(),style:{padding:"5px 14px",fontSize:11,fontFamily:Ft,fontWeight:600,backgroundColor:x.trim()?o:"rgba(0,0,0,0.1)",color:x.trim()?"#ffffff":"rgba(0,0,0,0.3)",border:"none",cursor:x.trim()?"pointer":"default"},children:"Send \u2318\u23CE"})})]})]})]})}import{Fragment as vp,jsx as Yo,jsxs as Sp}from"react/jsx-runtime";var ra=mp(null),Gi="devtools-provider",Vi="devtools-model",Ui="devtools-open-thread-id",Ji=[{id:"claude-opus-4-6",label:"Opus 4.6"},{id:"claude-sonnet-4-6",label:"Sonn 4.6"}],Xi=[{id:"gpt-5.3-codex",label:"Codex 5.3"},{id:"gpt-5.3-codex-spark",label:"Spark 5.3"},{id:"gpt-5.1-codex-mini",label:"Mini 5.1"}];function yp(e,t,o){let n=e==="codex"?Xi:Ji;return Math.min(o,(t==="codex"?Xi:Ji).length-1)}function bp({children:e,enabled:t=process.env.NODE_ENV==="development",bridgeUrl:o="http://localhost:1111"}){var an,N,Q,pe,Ae,Te;let[n,r]=Bs(),i=As(o),s=(an=Ls())!=null?an:o,l=nn(new Map),[a,c]=$t(()=>typeof window=="undefined"?"claude":localStorage.getItem(Gi)||"claude"),[d,p]=$t(()=>{if(typeof window=="undefined")return 0;let v=localStorage.getItem(Vi);return v&&parseInt(v,10)||0}),[u,g]=$t(["claude","codex"]),[x,E]=$t({}),[h,w]=$t(!1);Ot(()=>{i.isConnected&&hs(s).then(v=>{if(!v)return;let U=Object.entries(v.providers).filter(([,ye])=>ye.available).map(([ye])=>ye);U.length>0&&g(U);let oe={};for(let[ye,et]of Object.entries(v.providers))et.mcp&&(oe[ye]=et.mcp);E(oe),Object.values(oe).every(ye=>ye.found)&&w(!1)})},[i.isConnected,i.capabilitiesVersion,s]),Ot(()=>{if(u.length>0&&!u.includes(a)){let v=u[0];c(v),localStorage.setItem(Gi,v)}},[u,a]);let D=a==="codex"?Xi:Ji,B=(N=D[d])!=null?N:D[0],M=zt(v=>{let U=a;c(v),localStorage.setItem(Gi,v);let oe=yp(U,v,d);p(oe),localStorage.setItem(Vi,String(oe))},[a,d]),C=zt(v=>{p(v),localStorage.setItem(Vi,String(v))},[]),L=zt(async()=>{let v=await xs(s);if(!v)return;let U={};for(let[oe,Be]of Object.entries(v.capabilities.providers))Be.mcp&&(U[oe]=Be.mcp);E(U),v.results.some(oe=>oe.installed)&&w(!0)},[s]),[k,W]=$t(new Set),[ee,Z]=$t(null),[F,K]=$t(null),[q,we]=$t(null),[le,he]=$t(null);Ot(()=>{i.isConnected&&no(s).then(v=>{v!=null&&v.components&&W(new Set(Object.keys(v.components)))})},[i.isConnected,s]);let Fe=zt(async v=>{let U=[];for(let oe of v)try{(await vs(oe,s)).added&&U.push(oe)}catch(Be){console.error("[Popmelt] Failed to add component to model:",oe,Be)}U.length>0&&(W(oe=>{let Be=new Set(oe);for(let ye of U)Be.add(ye);return Be}),Z(U[U.length-1]))},[s]),Ie=zt(v=>{Z(v)},[]),$e=zt(()=>{no(s).then(v=>{v!=null&&v.components&&W(new Set(Object.keys(v.components)))})},[s]),J=zt(async v=>{try{(await Ss(v,s)).removed&&W(oe=>{let Be=new Set(oe);return Be.delete(v),Be})}catch(U){console.error("[Popmelt] Failed to remove component from model:",U)}},[s]),V=zt((v,U)=>{r({type:"MODIFY_SPACING_TOKEN",payload:v}),r({type:"ADD_SPACING_TOKEN_CHANGE",payload:U})},[r]),te=zt((v,U)=>{r({type:"DELETE_SPACING_TOKEN",payload:{tokenPath:v,originalValue:U}})},[r]),[fe,Ce]=$t(0),ge=nn([]);Ot(()=>{let v=ge.current,U=n.spacingTokenMods;ge.current=U;let oe=new Map(v.map(et=>[et.tokenPath,et])),Be=new Map(U.map(et=>[et.tokenPath,et])),ye=!1;for(let[et,je]of Be){let Me=oe.get(et);if(!(Me&&Me.currentValue===je.currentValue)){ye=!0,je.currentValue==="__deleted__"?ws(et,s).catch(Ye=>console.error("[Popmelt] Failed to sync token delete:",Ye)):Ir(et,je.currentValue,s).catch(Ye=>console.error("[Popmelt] Failed to sync token update:",Ye));for(let Ye of je.targets){let Ke=document.querySelector(Ye.selector);if(Ke)if(je.currentValue==="__deleted__")Ke.style.removeProperty(Ye.property);else{let Lt=je.currentPx;Lt>0&&Ke.style.setProperty(Ye.property,`${Lt}px`,"important")}}}}for(let[et,je]of oe)if(!Be.has(et)){ye=!0,Ir(et,je.originalValue,s).catch(Me=>console.error("[Popmelt] Failed to restore token on undo:",Me));for(let Me of je.targets){let Ye=document.querySelector(Me.selector);Ye&&Ye.style.removeProperty(Me.property)}}ye&&Ce(et=>et+1)},[n.spacingTokenMods,s]);let[ue,We]=$t(()=>typeof window=="undefined"?null:localStorage.getItem(Ui)||null),[me,lt]=$t(new Set),[qe,Ne]=$t(null);Ot(()=>{ue?localStorage.setItem(Ui,ue):localStorage.removeItem(Ui)},[ue]);let tt="popmelt-in-flight-jobs",[A,re]=$t(()=>{try{let v=sessionStorage.getItem(tt);return v?JSON.parse(v):{}}catch(v){return{}}});Ot(()=>{try{Object.keys(A).length>0?sessionStorage.setItem(tt,JSON.stringify(A)):sessionStorage.removeItem(tt)}catch(v){}},[A]);let de=nn(new Map);Ot(()=>{for(let[v,U]of Object.entries(A))U.annotationIds.length>0&&de.current.set(v,U.annotationIds)},[A]);let Le=nn(!1);Ot(()=>{if(Le.current||n.annotations.length===0)return;Le.current=!0;let v=new Set;for(let oe of Object.values(A))for(let Be of oe.annotationIds)v.add(Be);let U=n.annotations.filter(oe=>v.has(oe.id)?!1:!!(oe.status==="in_flight"||(oe.status==="pending"||!oe.status)&&(oe.captured||oe.threadId))).map(oe=>oe.id);U.length>0&&r({type:"SET_ANNOTATION_STATUS",payload:{ids:U,status:"dismissed"}})},[n.annotations,A,r]);let ke=Io(()=>{let v=new Set;for(let U of Object.values(A))for(let oe of U.annotationIds)v.add(oe);return v},[A]),Re=Io(()=>{let v=new Set;for(let U of Object.values(A))for(let oe of U.styleSelectors)v.add(oe);return v},[A]),ve=Io(()=>{let v=new Map;for(let U of Object.values(A)){for(let oe of U.styleSelectors)v.set(oe,U.color);for(let oe of U.annotationIds){let Be=n.annotations.find(ye=>ye.id===oe);if(Be&&(Be.linkedSelector&&v.set(Be.linkedSelector,U.color),Be.groupId))for(let ye of n.annotations)ye.groupId===Be.groupId&&ye.linkedSelector&&v.set(ye.linkedSelector,U.color)}}return v},[A,n.annotations]),at=nn(n.annotations);at.current=n.annotations;let Qe=nn(n.styleModifications);Qe.current=n.styleModifications;let ft=nn(A);ft.current=A,Ot(()=>{let v=null,U=()=>{var Me,Ye;if(Object.keys(ft.current).length>0)return;let Be=at.current,ye=Qe.current,et=[],je=[];for(let Ke of Be){if(!Ke.linkedSelector||!Ke.linkedSelector.startsWith("[data-pm=")||Ke.captured||Ke.status&&Ke.status!=="pending")continue;let Lt=document.querySelector(Ke.linkedSelector);!Lt&&((Ye=(Me=Ke.elements)==null?void 0:Me[0])!=null&&Ye.selector)&&(Lt=document.querySelector(Ke.elements[0].selector)),Lt||et.push(Ke.linkedSelector)}for(let Ke of ye)document.querySelector(Ke.selector)||je.push(Ke.selector);(et.length>0||je.length>0)&&r({type:"CLEANUP_ORPHANED",payload:{linkedSelectors:et,styleSelectors:je}})},oe=new MutationObserver(Be=>{Be.some(ye=>ye.removedNodes.length>0)&&(v&&clearTimeout(v),v=setTimeout(U,3e3))});return oe.observe(document.body,{childList:!0,subtree:!0}),()=>{oe.disconnect(),v&&clearTimeout(v)}},[r]),Ot(()=>{i.lastCompletedJobId&&i.lastCompletedJobId in A&&re(v=>{var Be;let ye=v,{[Be=i.lastCompletedJobId]:U}=ye;return Bn(ye,[Ko(Be)])})},[i.lastCompletedJobId]);let rt=nn(new Set);Ot(()=>{let v=i.events.filter(U=>U.type==="done"&&U.data.resolutions);for(let U of v){let oe=U.data.jobId;rt.current.has(oe)||(rt.current.add(oe),Array.isArray(U.data.resolutions)&&r({type:"APPLY_RESOLUTIONS",payload:{resolutions:U.data.resolutions,threadId:U.data.threadId}}))}},[i.events,r]);let gt=nn(new Set);Ot(()=>{let v=i.events.filter(U=>U.type==="error"&&U.data.cancelled);for(let U of v){let oe=U.data.jobId;if(!oe||gt.current.has(oe))continue;gt.current.add(oe);let Be=A[oe];Be&&Be.annotationIds.length>0&&r({type:"SET_ANNOTATION_STATUS",payload:{ids:Be.annotationIds,status:"dismissed"}})}},[i.events,A,r]);let ct=nn(0);Ot(()=>{let v=i.incrementalResolutions;if(v.length<=ct.current)return;let U=v.slice(ct.current);ct.current=v.length,r({type:"APPLY_RESOLUTIONS",payload:{resolutions:U}})},[i.incrementalResolutions,r]),Ot(()=>{i.incrementalResolutions.length===0&&(ct.current=0)},[i.incrementalResolutions.length]);let Ct=nn(i.status);Ot(()=>{let v=Ct.current;Ct.current=i.status,v==="disconnected"&&i.status==="idle"&&re({})},[i.status]);let Pe=zt(async()=>{let v=document.getElementById("devtools-canvas");if(!v)return!1;let U=await Br(document.body,v,n.annotations);if(U.length===0)return!1;let oe=await Ds(U,n.annotations,n.styleModifications);return oe&&r({type:"MARK_CAPTURED"}),oe},[n.annotations,n.styleModifications,r]),Kt=zt((v,U)=>{let oe=l.current.get(v)||[];l.current.set(v,[...oe,...U])},[]),mt=zt(async()=>{let v=document.getElementById("devtools-canvas");if(!v)return!1;let U=n.annotations.filter(Ye=>{var Ke;return((Ke=Ye.status)!=null?Ke:"pending")==="pending"}),oe=n.spacingTokenChanges.filter(Ye=>!Ye.captured);if(U.length===0&&n.styleModifications.filter(Ye=>!Ye.captured).length===0&&oe.length===0)return!1;let Be=await Br(document.body,v,n.annotations);if(Be.length===0)return!1;let ye=await Or(Be);if(!ye)return!1;let et=Pr(U,n.styleModifications,void 0,oe.length>0?oe:void 0),je=JSON.stringify(et),Me=new Map;for(let Ye of U){let Ke=l.current.get(Ye.id);if(Ke&&Ke.length>0&&Me.set(Ye.id,Ke),Ye.groupId){for(let Lt of U)if(Lt.groupId===Ye.groupId&&Lt.id!==Ye.id){let St=l.current.get(Lt.id);St&&St.length>0&&Me.set(Lt.id,St)}}}try{let Ye=Ar(n.activeColor),{jobId:Ke,threadId:Lt}=await bs(ye,je,s,Ye,a,B.id,Me.size>0?Me:void 0,Rr());for(let cn of Me.keys())l.current.delete(cn);let St=U.map(cn=>cn.id),Er=n.styleModifications.filter(cn=>!cn.captured).map(cn=>cn.selector);re(cn=>m(f({},cn),{[Ke]:{annotationIds:St,styleSelectors:Er,color:n.activeColor,threadId:Lt}})),r({type:"MARK_CAPTURED"}),Lt&&St.length>0&&r({type:"SET_ANNOTATION_THREAD",payload:{ids:St,threadId:Lt}});let Nn=n.activeColor.match(/oklch\([^)]*\s+([\d.]+)\s*\)/),jo=((Nn!=null&&Nn[1]?parseFloat(Nn[1]):29)+60)%360;return r({type:"SET_COLOR",payload:`oklch(0.628 0.258 ${jo})`}),!0}catch(Ye){return console.error("[Pare] Failed to send to bridge:",Ye),!1}},[n.annotations,n.styleModifications,n.spacingTokenChanges,n.activeColor,r,s,a,B.id]),Dt=zt(async(v,U,oe)=>{try{let Be=Ar(n.activeColor),{jobId:ye}=await ks(v,U,s,Be,a,B.id,oe,Rr());re(je=>m(f({},je),{[ye]:{annotationIds:[],styleSelectors:[],color:n.activeColor,threadId:v}}));let et=n.annotations.filter(je=>je.threadId===v&&(je.status==="waiting_input"||je.status==="resolved"||je.status==="needs_review"));et.length>0&&(r({type:"SET_ANNOTATION_STATUS",payload:{ids:et.map(je=>je.id),status:"in_flight"}}),re(je=>{let Me=je[ye];return Me?m(f({},je),{[ye]:m(f({},Me),{annotationIds:[...Me.annotationIds,...et.map(Ye=>Ye.id)]})}):je})),i.dismissQuestion(v)}catch(Be){console.error("[Pare] Failed to send reply:",Be)}},[n.activeColor,n.annotations,s,i.dismissQuestion,r,a,B.id]),Wt=nn(new Set);Ot(()=>{for(let v of i.pendingQuestions){if(Wt.current.has(v.jobId))continue;Wt.current.add(v.jobId);let U=v.annotationIds&&v.annotationIds.length>0?v.annotationIds:void 0;!U&&v.threadId&&(U=n.annotations.filter(oe=>oe.threadId===v.threadId).map(oe=>oe.id)),U&&U.length>0&&r({type:"SET_ANNOTATION_QUESTION",payload:{ids:U,question:v.question,threadId:v.threadId}})}},[i.pendingQuestions,r,n.annotations]);let xn=Io(()=>{if(i.activeJobId&&i.activeJobId in A)return A[i.activeJobId].color;let v=Object.values(A);return v.length>0?v[v.length-1].color:void 0},[i.activeJobId,A]),Yt=zt(v=>{We(v)},[]),Zt=zt(v=>{if(!v){Ne(null);return}let U=de.current.get(v);U&&U.length>0?Ne(new Set(U)):Ne(null)},[]),Gt=zt(async v=>{try{let U=v?`${s}/cancel?jobId=${v}`:`${s}/cancel`;await fetch(U,{method:"POST"})}catch(U){}},[s]);Ot(()=>{n.activeTool==="model"&&ue&&We(null)},[n.activeTool]);let j=nn(null);Ot(()=>{n.isAnnotating?j.current&&(We(j.current),j.current=null):ue&&(j.current=ue,We(null))},[n.isAnnotating]);let Ee=Io(()=>{if(!ue)return null;for(let[v,U]of Object.entries(A))if(U.threadId===ue)return v;return null},[ue,A]),[He,qt]=$t(!1),[nt,vt]=$t(0),ut=nn(null),ht=zt(v=>{v?(ut.current&&(clearTimeout(ut.current),ut.current=null),qt(!0)):ut.current=setTimeout(()=>{qt(!1),ut.current=null},150)},[]),An=zt(()=>{vt(v=>v+1),i.clearEvents(),We(null),lt(new Set)},[i.clearEvents]);Ot(()=>()=>{ut.current&&clearTimeout(ut.current)},[]);let Vt=Io(()=>({isEnabled:t}),[t]);return t?Sp(ra.Provider,{value:Vt,children:[e,Yo(Fl,{state:n,dispatch:r,onScreenshot:Pe,inFlightAnnotationIds:ke,inFlightStyleSelectors:Re,inFlightSelectorColors:ve,onAttachImages:Kt,onReply:i.isConnected?Dt:void 0,onViewThread:i.isConnected?Yt:void 0,onCloseThread:v=>{We(null),v&<(U=>new Set(U).add(v))},onModelComponentsAdd:i.isConnected?Fe:void 0,onModelComponentFocus:i.isConnected?Ie:void 0,onModelComponentHover:K,modelComponentNames:k,modelPanelHoveredComponent:q,modelSpacingTokenHover:le,highlightedAnnotationIds:qe}),Yo(Jl,{state:n,dispatch:r,onScreenshot:Pe,onSendToClaude:i.isConnected?mt:void 0,hasActiveJobs:Object.keys(A).length>0||i.activeJobIds.length>0,activeJobColor:xn,onCrosshairHover:ht,onClear:An,provider:a,onProviderChange:i.isConnected&&u.length>1?M:void 0,availableProviders:u,modelIndex:d,modelCount:D.length,modelLabel:B.label,onModelChange:i.isConnected?C:void 0,onViewThread:i.isConnected?Yt:void 0,isThreadPanelOpen:ue!==null,mcpStatus:x,onInstallMcp:i.isConnected?L:void 0,mcpJustInstalled:h,bridgeUrl:s,isBridgeConnected:i.isConnected,modelSelectedComponent:ee,modelCanvasHoveredComponent:F,onModelComponentHover:we,onSpacingTokenHover:he,onModifySpacingToken:i.isConnected?V:void 0,onDeleteSpacingToken:i.isConnected?te:void 0,modelRefreshKey:fe,onModelComponentAdded:$e,onModelComponentRemoved:J}),ue&&i.isConnected&&Yo(oa,{threadId:ue,bridgeUrl:s,accentColor:(pe=(Q=n.annotations.find(v=>v.threadId===ue))==null?void 0:Q.color)!=null?pe:n.activeColor,isStreaming:Ee!==null,streamingEvents:Ee?i.events.filter(v=>v.data.jobId===Ee):[],onClose:()=>We(null),onReply:Dt,onCancel:Ee?()=>Gt(Ee):void 0,lastError:(Te=(Ae=i.lastErrorByJob)==null?void 0:Ae[Ee!=null?Ee:""])!=null?Te:void 0}),Yo(Zl,{bridge:i,bridgeUrl:s,inFlightJobs:A,isVisible:He||i.lastResponseText!==null||i.activeJobIds.length>0,onHover:ht,clearSignal:nt,onReply:Dt,onViewThread:Yt,onCancel:Gt,onHoverJob:Zt,isConnected:i.isConnected,dismissedThreadIds:me})]}):Yo(vp,{children:e})}function xp(){let e=hp(ra);if(!e)throw new Error("usePopmelt must be used within PopmeltProvider");return e}export{bp as PopmeltProvider,xp as usePopmelt};
|
|
41
|
+
`,wp={borderTop:"1px solid rgba(0, 0, 0, 0.08)",padding:12};function la(e){return e.replace(/<resolution>[\s\S]*?<\/resolution>/g,"").replace(/<question>[\s\S]*?<\/question>/g,"").replace(/<plan>[\s\S]*?<\/plan>/g,"").replace(/<review>[\s\S]*?<\/review>/g,"").trim()}function aa(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}var Gi=["reviewing","considering","thinking","zhuzhing","iterating","tweaking","reflecting","noodling","pondering","finessing","polishing","riffing"],Ep=3e3,kp=250;function ca({size:e=14}){return ze("svg",{width:e,height:e,viewBox:"0 0 1200 1200",fill:"#6b7280",stroke:"none",style:{flexShrink:0},children:ze("path",{d:"M 233.959793 800.214905 L 468.644287 668.536987 L 472.590637 657.100647 L 468.644287 650.738403 L 457.208069 650.738403 L 417.986633 648.322144 L 283.892639 644.69812 L 167.597321 639.865845 L 54.926208 633.825623 L 26.577238 627.785339 L 3.3e-05 592.751709 L 2.73832 575.27533 L 26.577238 559.248352 L 60.724873 562.228149 L 136.187973 567.382629 L 249.422867 575.194763 L 331.570496 580.026978 L 453.261841 592.671082 L 472.590637 592.671082 L 475.328857 584.859009 L 468.724915 580.026978 L 463.570557 575.194763 L 346.389313 495.785217 L 219.543671 411.865906 L 153.100723 363.543762 L 117.181267 339.060425 L 99.060455 316.107361 L 91.248367 266.01355 L 123.865784 230.093994 L 167.677887 233.073853 L 178.872513 236.053772 L 223.248367 270.201477 L 318.040283 343.570496 L 441.825592 434.738342 L 459.946411 449.798706 L 467.194672 444.64447 L 468.080597 441.020203 L 459.946411 427.409485 L 392.617493 305.718323 L 320.778564 181.932983 L 288.80542 130.630859 L 280.348999 99.865845 C 277.369171 87.221436 275.194641 76.590698 275.194641 63.624268 L 312.322174 13.20813 L 332.8591 6.604126 L 382.389313 13.20813 L 403.248352 31.328979 L 434.013519 101.71814 L 483.865753 212.537048 L 561.181274 363.221497 L 583.812134 407.919434 L 595.892639 449.315491 L 600.40271 461.959839 L 608.214783 461.959839 L 608.214783 454.711609 L 614.577271 369.825623 L 626.335632 265.61084 L 637.771851 131.516846 L 641.718201 93.745117 L 660.402832 48.483276 L 697.530334 24.000122 L 726.52356 37.852417 L 750.362549 72 L 747.060486 94.067139 L 732.886047 186.201416 L 705.100708 330.52356 L 686.979919 427.167847 L 697.530334 427.167847 L 709.61084 415.087341 L 758.496704 350.174561 L 840.644348 247.490051 L 876.885925 206.738342 L 919.167847 161.71814 L 946.308838 140.29541 L 997.61084 140.29541 L 1035.38269 196.429626 L 1018.469849 254.416199 L 965.637634 321.422852 L 921.825562 378.201538 L 859.006714 462.765259 L 819.785278 530.41626 L 823.409424 535.812073 L 832.75177 534.92627 L 974.657776 504.724915 L 1051.328979 490.872559 L 1142.818848 475.167786 L 1184.214844 494.496582 L 1188.724854 514.147644 L 1172.456421 554.335693 L 1074.604126 578.496765 L 959.838989 601.449829 L 788.939636 641.879272 L 786.845764 643.409485 L 789.261841 646.389343 L 866.255127 653.637634 L 899.194702 655.409424 L 979.812134 655.409424 L 1129.932861 666.604187 L 1169.154419 692.537109 L 1192.671265 724.268677 L 1188.724854 748.429688 L 1128.322144 779.194641 L 1046.818848 759.865845 L 856.590759 714.604126 L 791.355774 698.335754 L 782.335693 698.335754 L 782.335693 703.731567 L 836.69812 756.885986 L 936.322205 846.845581 L 1061.073975 962.81897 L 1067.436279 991.490112 L 1051.409424 1014.120911 L 1034.496704 1011.704712 L 924.885986 929.234924 L 882.604126 892.107544 L 786.845764 811.48999 L 780.483276 811.48999 L 780.483276 819.946289 L 802.550415 852.241699 L 919.087341 1027.409424 L 925.127625 1081.127686 L 916.671204 1098.604126 L 886.469849 1109.154419 L 853.288696 1103.114136 L 785.073914 1007.355835 L 714.684631 899.516785 L 657.906067 802.872498 L 650.979858 806.81897 L 617.476624 1167.704834 L 601.771851 1186.147705 L 565.530212 1200 L 535.328857 1177.046997 L 519.302124 1139.919556 L 535.328857 1066.550537 L 554.657776 970.792053 L 570.362488 894.68457 L 584.536926 800.134277 L 592.993347 768.724976 L 592.429626 766.630859 L 585.503479 767.516968 L 514.22821 865.369263 L 405.825531 1011.865906 L 320.053711 1103.677979 L 299.516815 1111.812256 L 263.919525 1093.369263 L 267.221497 1060.429688 L 287.114136 1031.114136 L 405.825531 880.107361 L 477.422913 786.52356 L 523.651062 732.483276 L 523.328918 724.671265 L 520.590698 724.671265 L 205.288605 929.395935 L 149.154434 936.644409 L 124.993355 914.01355 L 127.973183 876.885986 L 139.409409 864.80542 L 234.201385 799.570435 L 233.879227 799.8927 Z"})})}function Cp({color:e}){let[t,o]=no(0),[r,n]=no(()=>Math.floor(Math.random()*Gi.length));return _n(()=>{let i=setInterval(()=>o(l=>(l+1)%2),kp),s=setInterval(()=>n(l=>(l+1)%Gi.length),Ep);return()=>{clearInterval(i),clearInterval(s)}},[]),Nt("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[ze("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:e,style:{verticalAlign:"middle",flexShrink:0},children:t===1?Nt(Vi,{children:[ze("circle",{cx:"7",cy:"7",r:"2"}),ze("circle",{cx:"17",cy:"7",r:"2"}),ze("circle",{cx:"7",cy:"17",r:"2"}),ze("circle",{cx:"17",cy:"17",r:"2"})]}):Nt(Vi,{children:[ze("circle",{cx:"12",cy:"6",r:"2"}),ze("circle",{cx:"6",cy:"12",r:"2"}),ze("circle",{cx:"18",cy:"12",r:"2"}),ze("circle",{cx:"12",cy:"18",r:"2"})]})}),ze("span",{style:{fontSize:11,color:"#9ca3af",fontStyle:"italic"},children:Gi[r]})]})}function Mp(e){var n;let t=String(e.data.tool||""),o=e.data.file?String(e.data.file):null,r=o?(n=o.split("/").pop())!=null?n:o:null;switch(t){case"Read":return r?`Reading ${r}`:"Reading file";case"Edit":return r?`Editing ${r}`:"Editing file";case"Write":return r?`Writing ${r}`:"Writing file";case"Bash":return"Running command";case"Glob":return"Searching files";case"Grep":return"Searching code";case"WebFetch":return"Fetching page";case"WebSearch":return"Searching web";default:return t?`Using ${t}`:null}}var Tp=new Set(["Read","Glob","Grep","WebFetch","WebSearch"]),Lp=new Set(["Edit","Write","Bash"]);function Ip(e){let t=0,o=!1;for(let r of e){if(r.type!=="tool_use")continue;let n=String(r.data.tool||"");Lp.has(n)?o=!0:Tp.has(n)&&t++}return!o&&t>=3?"researching":o?"applying changes":null}function Rp(e){let t=[];for(let o of e)if(o.type==="tool_use"){let r=Mp(o);r&&t.push({kind:"tool",label:r})}else if(o.type==="delta"){let r=String(o.data.text||"");if(!r)continue;let n=t[t.length-1];n&&n.kind==="text"?n.text+=r:t.push({kind:"text",text:r})}else if(o.type==="thinking"){let r=String(o.data.text||"");if(!r)continue;let n=t[t.length-1];n&&n.kind==="thinking"?n.text+=r:t.push({kind:"thinking",text:r})}return t}function da({threadId:e,bridgeUrl:t,accentColor:o,isStreaming:r,streamingEvents:n,onClose:i,onReply:s,onCancel:l,lastError:a,onMouseEnter:c,toolbarRef:d}){let[u,p]=no([]),[g,S]=no(!0),[v,y]=no(""),[w,O]=no([]),A=On(null),C=On(null),E=On(null),I=On(r),$=On(ji()),Z=On({x:0,y:0}),G=On(!1),M=On({x:0,y:0,offsetX:0,offsetY:0}),D=On(!1),[,X]=no(0);_n(()=>{try{let V=localStorage.getItem(Yi);if(V){let oe=JSON.parse(V);typeof oe.top=="number"&&typeof oe.left=="number"&&(D.current=!0,$.current={top:oe.top,left:oe.left},X(Ee=>Ee+1))}}catch(V){}},[]),_n(()=>{let V=()=>{D.current||($.current=ji()),X(oe=>oe+1)};return window.addEventListener("resize",V,{passive:!0}),()=>window.removeEventListener("resize",V)},[]),_n(()=>{let V=E.current;if(!V)return;let oe=Te=>{Te.button!==0||Te.target.closest("button")||(Te.preventDefault(),Te.stopPropagation(),G.current=!0,M.current={x:Te.clientX,y:Te.clientY,offsetX:Z.current.x,offsetY:Z.current.y})},Ee=Te=>{if(!G.current)return;let xe=M.current,me=xe.offsetX+(Te.clientX-xe.x),Ge=xe.offsetY+(Te.clientY-xe.y),xt=Math.max(Ro,Math.min(window.innerWidth-Mr-2*Ui-Ro,$.current.left+me)),dt=Math.max(Ro,$.current.top+Ge);Z.current={x:xt-$.current.left,y:dt-$.current.top};let Ve=C.current;Ve&&(Ve.style.top=`${dt}px`,Ve.style.left=`${xt}px`,Ve.style.height=`${sa(dt,xt,d==null?void 0:d.current)}px`)},ce=()=>{if(!G.current)return;let Te=$.current.top+Z.current.y,xe=$.current.left+Z.current.x;$.current={top:Te,left:xe},Z.current={x:0,y:0},D.current=!0;try{localStorage.setItem(Yi,JSON.stringify({top:Te,left:xe}))}catch(me){}G.current=!1},Ke=()=>{$.current=ji(),Z.current={x:0,y:0},D.current=!1;try{localStorage.removeItem(Yi)}catch(Te){}X(Te=>Te+1)};return V.addEventListener("mousedown",oe),window.addEventListener("mousemove",Ee),window.addEventListener("mouseup",ce),V.addEventListener("dblclick",Ke),()=>{V.removeEventListener("mousedown",oe),window.removeEventListener("mousemove",Ee),window.removeEventListener("mouseup",ce),V.removeEventListener("dblclick",Ke)}},[]);let ee=Cr(()=>{fetch(`${t}/thread/${e}`).then(V=>V.json()).then(V=>{var oe;p((oe=V.messages)!=null?oe:[]),S(!1)}).catch(()=>S(!1))},[t,e]);_n(()=>{S(!0),ee()},[ee]),_n(()=>{I.current&&!r&&ee(),I.current=r},[r,ee]);let he=n?Rp(n):[],ve=n?Ip(n):null;_n(()=>{A.current&&(A.current.scrollTop=A.current.scrollHeight)},[u,he.length,r]),_n(()=>{let V=oe=>{oe.key==="Escape"&&(oe.stopPropagation(),i())};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[i]);let ae=Cr(()=>{if(!v.trim()||!s)return;let V=v.trim(),oe=w.length>0?w:void 0;p(Ee=>[...Ee,{role:"human",timestamp:Date.now(),jobId:"pending",replyToQuestion:oe?`${V} [${oe.length} image${oe.length>1?"s":""}]`:V}]),s(e,V,oe),y(""),O([])},[v,w,e,s]),Re=Cr(V=>{let oe=V.clipboardData.items,Ee=[];for(let ce=0;ce<oe.length;ce++){let Ke=oe[ce];if(Ke.type.startsWith("image/")){let Te=Ke.getAsFile();Te&&Ee.push(Te)}}Ee.length>0&&(V.preventDefault(),O(ce=>[...ce,...Ee]))},[]),We=Cr(V=>{V.key==="Enter"&&(V.metaKey||V.ctrlKey)&&(V.preventDefault(),ae())},[ae]),Me=$.current.top+Z.current.y,ne=$.current.left+Z.current.x,Ae=sa(Me,ne,d==null?void 0:d.current);return Nt(Vi,{children:[ze("div",{"data-devtools":"thread-panel-backdrop",onMouseDown:V=>{V.target===V.currentTarget&&i()},style:{position:"fixed",inset:0,zIndex:9999}}),Nt("div",{ref:C,style:m(f({},bp),{height:Ae,position:"fixed",top:Me,left:ne,zIndex:1e4}),"data-devtools":"thread-panel",onMouseEnter:c,children:[Nt("div",{ref:E,style:m(f({},xp),{backgroundColor:o,color:"#ffffff",cursor:"grab",userSelect:"none",WebkitUserSelect:"none"}),children:[ze("span",{children:"Conversation"}),ze("button",{onClick:i,style:{background:"none",border:"none",cursor:"pointer",fontSize:16,color:"#ffffff",padding:"0 4px",lineHeight:1},children:"\xD7"})]}),ze("style",{dangerouslySetInnerHTML:{__html:Sp}}),Nt("div",{ref:A,style:vp,"data-devtools":"thread-panel-messages",children:[g&&ze("div",{style:{padding:16,color:"#9ca3af",textAlign:"center"},children:"Loading..."}),!g&&u.length===0&&!r&&ze("div",{style:{padding:16,color:"#9ca3af",textAlign:"center"},children:"No messages yet."}),u.map((V,oe)=>{let Ee=V.role==="human";if(V.cancelled)return ze("div",{style:{padding:"8px 16px",borderBottom:"1px solid rgba(0, 0, 0, 0.04)",opacity:oe===u.length-1?1:.5},children:Nt("div",{style:{display:"flex",alignItems:"center",gap:4},children:[ze("span",{style:{fontSize:11,color:"#9ca3af",fontStyle:"italic"},children:"Cancelled"}),ze("span",{style:{fontSize:10,color:"#9ca3af",marginLeft:"auto"},children:aa(V.timestamp)})]})},`${V.jobId}-${oe}`);let ce=Ee?V.replyToQuestion||V.feedbackSummary||"(annotation)":la(V.responseText||""),Ke=Ee?void 0:V.question,Te=!Ee&&V.resolutions&&V.resolutions.length>0,xe=!Ee&&V.toolsUsed&&V.toolsUsed.length>0;if(!ce&&!Ke&&!Te)return null;let me=oe===u.length-1;return Nt("div",{style:{padding:"8px 16px",borderBottom:"1px solid rgba(0, 0, 0, 0.04)",opacity:me?1:.5},children:[Nt("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:4},children:[!Ee&&ze(ca,{size:11}),ze("span",{style:{fontWeight:600,fontSize:11,color:Ee?o:"#6b7280"},children:Ee?"You":"Claude Code"}),ze("span",{style:{fontSize:10,color:"#9ca3af",marginLeft:"auto"},children:aa(V.timestamp)})]}),ce&&ze("div",{style:{lineHeight:1.5,wordBreak:"break-word"},children:Ee?ce:kr(ce)}),Ke&&ze("div",{style:{marginTop:ce?4:0,lineHeight:1.5,wordBreak:"break-word"},children:kr(Ke)}),(xe||Te)&&Nt("div",{style:{marginTop:ce||Ke?6:0,padding:"4px 8px",backgroundColor:"rgba(0, 0, 0, 0.03)",fontSize:11,lineHeight:1.5,color:"#6b7280"},children:[xe&&ze("div",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:10},children:V.toolsUsed.map((Ge,xt)=>ze("div",{children:Ge},xt))}),Te&&V.resolutions.map((Ge,xt)=>{var z;let dt=(z=Ge.finalScope)!=null?z:Ge.inferredScope,Ve=dt?`${dt.breadth} \xB7 ${dt.target}`:null;return Nt("div",{style:{marginTop:xe?4:0},children:[ze("span",{style:{color:Ge.status==="resolved"?"#10b981":"#f59e0b"},children:Ge.status==="resolved"?"Done":"Needs review"}),Ve&&ze("span",{style:{marginLeft:6,padding:"1px 5px",backgroundColor:"rgba(0, 0, 0, 0.06)",fontSize:10,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:Ve}),Ge.summary?` \u2014 ${Ge.summary}`:""]},xt)})]})]},`${V.jobId}-${oe}`)}),r&&Nt("div",{style:{padding:"8px 16px",borderBottom:"1px solid rgba(0, 0, 0, 0.04)"},children:[Nt("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:4},children:[ze(ca,{size:11}),ze("span",{style:{fontWeight:600,fontSize:11,color:"#6b7280"},children:"Claude Code"}),ve&&ze("span",{style:{fontSize:10,color:"#b0b7c3",fontStyle:"italic"},children:ve}),Nt("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:6},children:[ze(Cp,{color:o}),l&&ze("button",{onClick:l,style:{background:"none",border:"1px solid rgba(0,0,0,0.1)",color:"#6b7280",fontSize:10,padding:"2px 8px",cursor:"pointer",fontFamily:"inherit"},children:"Cancel"})]})]}),he.map((V,oe)=>{if(V.kind==="tool")return ze("div",{style:{paddingLeft:12,fontSize:11,color:"#9ca3af",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",lineHeight:1.6},children:V.label},oe);if(V.kind==="thinking")return ze("div",{style:{paddingLeft:12,marginTop:2,marginBottom:2,fontSize:11,color:"#9ca3af",fontStyle:"italic",lineHeight:1.4,whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:80,overflowY:"auto"},children:V.text},oe);let Ee=la(V.text);return Ee?ze("div",{style:{paddingLeft:12,marginTop:2,marginBottom:2,lineHeight:1.5,wordBreak:"break-word"},children:kr(Ee)},oe):null})]})]}),!r&&a&&Nt("div",{style:{padding:"8px 16px",backgroundColor:"rgba(239, 68, 68, 0.06)",borderBottom:"1px solid rgba(0,0,0,0.04)",fontSize:11,color:"#dc2626",lineHeight:1.4},children:[ze("span",{style:{fontWeight:600},children:"Error: "}),a]}),s&&Nt("div",{style:wp,children:[w.length>0&&Nt("div",{style:{fontSize:11,color:"#6b7280",marginBottom:4,display:"flex",alignItems:"center",gap:4},children:[Nt("span",{children:[w.length," image",w.length>1?"s":""," attached"]}),ze("button",{onClick:()=>O([]),style:{background:"none",border:"none",cursor:"pointer",fontSize:11,color:"#9ca3af",padding:"0 2px"},children:"\xD7"})]}),ze("textarea",{value:v,onChange:V=>y(V.target.value),onKeyDown:We,onPaste:Re,placeholder:"Reply... (Cmd+Enter to send)",style:{width:"100%",minHeight:60,padding:4,fontSize:12,fontFamily:$t,backgroundColor:"rgba(0, 0, 0, 0.03)",color:"#1f2937",border:"1px solid rgba(0, 0, 0, 0.1)",borderRadius:0,outline:"none",resize:"vertical",lineHeight:1.4,boxSizing:"border-box"}}),ze("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:6},children:ze("button",{onClick:ae,disabled:!v.trim(),style:{padding:"5px 14px",fontSize:11,fontFamily:$t,fontWeight:600,backgroundColor:v.trim()?o:"rgba(0,0,0,0.1)",color:v.trim()?"#ffffff":"rgba(0,0,0,0.3)",border:"none",cursor:v.trim()?"pointer":"default"},children:"Send \u2318\u23CE"})})]})]})]})}import{Fragment as Hp,jsx as Po,jsxs as ua}from"react/jsx-runtime";var pa=Ap(null),Ji="devtools-provider",Xi="devtools-model",Ki="devtools-open-thread-id",Zi=[{id:"claude-opus-4-6",label:"Opus 4.6"},{id:"claude-sonnet-4-6",label:"Sonn 4.6"}],qi=[{id:"gpt-5.3-codex",label:"Codex 5.3"},{id:"gpt-5.3-codex-spark",label:"Spark 5.3"},{id:"gpt-5.1-codex-mini",label:"Mini 5.1"}];function Bp(e,t,o){let r=e==="codex"?qi:Zi;return Math.min(o,(t==="codex"?qi:Zi).length-1)}function Op({children:e,enabled:t=process.env.NODE_ENV==="development",bridgeUrl:o=typeof window!="undefined"?(r=>(r=window.__POPMELT_BRIDGE_URL__)!=null?r:"http://localhost:1111")():"http://localhost:1111"}){var te,q,Pe,Be,ge,Gt;let[n,i]=Hs(),s=Os(o),l=Xt(null),a=Xt(null),c=(te=Ps())!=null?te:o,d=Xt(new Map),[u,p]=Ut(()=>typeof window=="undefined"?"claude":localStorage.getItem(Ji)||"claude"),[g,S]=Ut(()=>{if(typeof window=="undefined")return 0;let R=localStorage.getItem(Xi);return R&&parseInt(R,10)||0}),[v,y]=Ut(["claude","codex"]),[w,O]=Ut({}),[A,C]=Ut(!1);_t(()=>{s.isConnected&&xs(c).then(R=>{if(!R)return;let K=Object.entries(R.providers).filter(([,ye])=>ye.available).map(([ye])=>ye);K.length>0&&y(K);let de={};for(let[ye,ke]of Object.entries(R.providers))ke.mcp&&(de[ye]=ke.mcp);O(de),Object.values(de).every(ye=>ye.found)&&C(!1)})},[s.isConnected,s.capabilitiesVersion,c]),_t(()=>{if(v.length>0&&!v.includes(u)){let R=v[0];p(R),localStorage.setItem(Ji,R)}},[v,u]);let E=u==="codex"?qi:Zi,I=(q=E[g])!=null?q:E[0],$=jt(R=>{let K=u;p(R),localStorage.setItem(Ji,R);let de=Bp(K,R,g);S(de),localStorage.setItem(Xi,String(de))},[u,g]),Z=jt(R=>{S(R),localStorage.setItem(Xi,String(R))},[]),G=jt(async()=>{let R=await ws(c);if(!R)return;let K={};for(let[de,Oe]of Object.entries(R.capabilities.providers))Oe.mcp&&(K[de]=Oe.mcp);O(K),R.results.some(de=>de.installed)&&C(!0)},[c]),[M,D]=Ut(new Set),[X,ee]=Ut(null),[he,ve]=Ut(null),[ae,Re]=Ut(null),[We,Me]=Ut(null);_t(()=>{s.isConnected&&io(c).then(R=>{R!=null&&R.components&&D(new Set(Object.keys(R.components)))})},[s.isConnected,c]);let ne=jt(async R=>{let K=[];for(let de of R)try{(await Es(de,c)).added&&K.push(de)}catch(Oe){console.error("[Popmelt] Failed to add component to model:",de,Oe)}K.length>0&&(D(de=>{let Oe=new Set(de);for(let ye of K)Oe.add(ye);return Oe}),ee(K[K.length-1]))},[c]),Ae=jt(R=>{ee(R)},[]),V=jt(()=>{io(c).then(R=>{R!=null&&R.components&&D(new Set(Object.keys(R.components)))})},[c]),oe=jt(async R=>{try{(await ks(R,c)).removed&&D(de=>{let Oe=new Set(de);return Oe.delete(R),Oe})}catch(K){console.error("[Popmelt] Failed to remove component from model:",K)}},[c]),Ee=jt((R,K)=>{i({type:"MODIFY_SPACING_TOKEN",payload:R}),i({type:"ADD_SPACING_TOKEN_CHANGE",payload:K})},[i]),ce=jt((R,K)=>{i({type:"DELETE_SPACING_TOKEN",payload:{tokenPath:R,originalValue:K}})},[i]),[Ke,Te]=Ut(0),xe=Xt([]);_t(()=>{let R=xe.current,K=n.spacingTokenMods;xe.current=K;let de=new Map(R.map(ke=>[ke.tokenPath,ke])),Oe=new Map(K.map(ke=>[ke.tokenPath,ke])),ye=!1;for(let[ke,Ne]of Oe){let gt=de.get(ke);if(!(gt&>.currentValue===Ne.currentValue)){ye=!0,Ne.currentValue==="__deleted__"?Cs(ke,c).catch(Ue=>console.error("[Popmelt] Failed to sync token delete:",Ue)):Ar(ke,Ne.currentValue,c).catch(Ue=>console.error("[Popmelt] Failed to sync token update:",Ue));for(let Ue of Ne.targets){let et=document.querySelector(Ue.selector);if(et)if(Ne.currentValue==="__deleted__")et.style.removeProperty(Ue.property);else{let Dt=Ne.currentPx;Dt>0&&et.style.setProperty(Ue.property,`${Dt}px`,"important")}}}}for(let[ke,Ne]of de)if(!Oe.has(ke)){ye=!0,Ar(ke,Ne.originalValue,c).catch(gt=>console.error("[Popmelt] Failed to restore token on undo:",gt));for(let gt of Ne.targets){let Ue=document.querySelector(gt.selector);Ue&&Ue.style.removeProperty(gt.property)}}ye&&Te(ke=>ke+1)},[n.spacingTokenMods,c]);let[me,Ge]=Ut(()=>typeof window=="undefined"?null:localStorage.getItem(Ki)||null),[xt,dt]=Ut(new Set),[Ve,z]=Ut(null);_t(()=>{me?localStorage.setItem(Ki,me):localStorage.removeItem(Ki)},[me]);let ie="popmelt-in-flight-jobs",[Q,Se]=Ut(()=>{try{let R=sessionStorage.getItem(ie);return R?JSON.parse(R):{}}catch(R){return{}}});_t(()=>{try{Object.keys(Q).length>0?sessionStorage.setItem(ie,JSON.stringify(Q)):sessionStorage.removeItem(ie)}catch(R){}},[Q]);let Le=Xt(new Map);_t(()=>{for(let[R,K]of Object.entries(Q))K.annotationIds.length>0&&Le.current.set(R,K.annotationIds)},[Q]);let Ze=Xt(!1);_t(()=>{if(Ze.current||n.annotations.length===0)return;Ze.current=!0;let R=new Set;for(let de of Object.values(Q))for(let Oe of de.annotationIds)R.add(Oe);let K=n.annotations.filter(de=>R.has(de.id)?!1:!!(de.status==="in_flight"||(de.status==="pending"||!de.status)&&(de.captured||de.threadId))).map(de=>de.id);K.length>0&&i({type:"SET_ANNOTATION_STATUS",payload:{ids:K,status:"dismissed"}})},[n.annotations,Q,i]);let fe=Ao(()=>{let R=new Set;for(let K of Object.values(Q))for(let de of K.annotationIds)R.add(de);return R},[Q]),lt=Ao(()=>{let R=new Set;for(let K of Object.values(Q))for(let de of K.styleSelectors)R.add(de);return R},[Q]),Qe=Ao(()=>{let R=new Map;for(let K of Object.values(Q)){for(let de of K.styleSelectors)R.set(de,K.color);for(let de of K.annotationIds){let Oe=n.annotations.find(ye=>ye.id===de);if(Oe&&(Oe.linkedSelector&&R.set(Oe.linkedSelector,K.color),Oe.groupId))for(let ye of n.annotations)ye.groupId===Oe.groupId&&ye.linkedSelector&&R.set(ye.linkedSelector,K.color)}}return R},[Q,n.annotations]),Tt=Xt(n.annotations);Tt.current=n.annotations;let Bt=Xt(n.styleModifications);Bt.current=n.styleModifications;let st=Xt(Q);st.current=Q,_t(()=>{let R=null,K=()=>{var gt,Ue;if(Object.keys(st.current).length>0)return;let Oe=Tt.current,ye=Bt.current,ke=[],Ne=[];for(let et of Oe){if(!et.linkedSelector||!et.linkedSelector.startsWith("[data-pm=")||et.captured||et.status&&et.status!=="pending")continue;let Dt=document.querySelector(et.linkedSelector);!Dt&&((Ue=(gt=et.elements)==null?void 0:gt[0])!=null&&Ue.selector)&&(Dt=document.querySelector(et.elements[0].selector)),Dt||ke.push(et.linkedSelector)}for(let et of ye)document.querySelector(et.selector)||Ne.push(et.selector);(ke.length>0||Ne.length>0)&&i({type:"CLEANUP_ORPHANED",payload:{linkedSelectors:ke,styleSelectors:Ne}})},de=new MutationObserver(Oe=>{Oe.some(ye=>ye.removedNodes.length>0)&&(R&&clearTimeout(R),R=setTimeout(K,3e3))});return de.observe(document.body,{childList:!0,subtree:!0}),()=>{de.disconnect(),R&&clearTimeout(R)}},[i]),_t(()=>{s.lastCompletedJobId&&s.lastCompletedJobId in Q&&Se(R=>{var Oe;let ye=R,{[Oe=s.lastCompletedJobId]:K}=ye;return Hn(ye,[Qo(Oe)])})},[s.lastCompletedJobId]);let at=Xt(new Set);_t(()=>{let R=s.events.filter(K=>K.type==="done"&&K.data.resolutions);for(let K of R){let de=K.data.jobId;at.current.has(de)||(at.current.add(de),Array.isArray(K.data.resolutions)&&i({type:"APPLY_RESOLUTIONS",payload:{resolutions:K.data.resolutions,threadId:K.data.threadId}}))}},[s.events,i]);let Ot=Xt(new Set);_t(()=>{let R=s.events.filter(K=>K.type==="error"&&K.data.cancelled);for(let K of R){let de=K.data.jobId;if(!de||Ot.current.has(de))continue;Ot.current.add(de);let Oe=Q[de];Oe&&Oe.annotationIds.length>0&&i({type:"SET_ANNOTATION_STATUS",payload:{ids:Oe.annotationIds,status:"dismissed"}})}},[s.events,Q,i]);let tt=Xt(0);_t(()=>{let R=s.incrementalResolutions;if(R.length<=tt.current)return;let K=R.slice(tt.current);tt.current=R.length,i({type:"APPLY_RESOLUTIONS",payload:{resolutions:K}})},[s.incrementalResolutions,i]),_t(()=>{s.incrementalResolutions.length===0&&(tt.current=0)},[s.incrementalResolutions.length]);let vt=Xt(s.status);_t(()=>{let R=vt.current;vt.current=s.status,R==="disconnected"&&s.status==="idle"&&Se({})},[s.status]);let $e=jt(async()=>{let R=l.current;if(!R)return!1;let K=await Hr(document.body,R,n.annotations);if(K.length===0)return!1;let de=await Ns(K,n.annotations,n.styleModifications);return de&&i({type:"MARK_CAPTURED"}),de},[n.annotations,n.styleModifications,i]),en=jt((R,K)=>{let de=d.current.get(R)||[];d.current.set(R,[...de,...K])},[]),Kt=jt(async()=>{let R=l.current;if(!R)return!1;let K=n.annotations.filter(Ue=>{var et;return((et=Ue.status)!=null?et:"pending")==="pending"}),de=n.spacingTokenChanges.filter(Ue=>!Ue.captured);if(K.length===0&&n.styleModifications.filter(Ue=>!Ue.captured).length===0&&de.length===0)return!1;let Oe=await Hr(document.body,R,n.annotations);if(Oe.length===0)return!1;let ye=await Fr(Oe);if(!ye)return!1;let ke=Dr(K,n.styleModifications,void 0,de.length>0?de:void 0),Ne=JSON.stringify(ke),gt=new Map;for(let Ue of K){let et=d.current.get(Ue.id);if(et&&et.length>0&>.set(Ue.id,et),Ue.groupId){for(let Dt of K)if(Dt.groupId===Ue.groupId&&Dt.id!==Ue.id){let wt=d.current.get(Dt.id);wt&&wt.length>0&>.set(Dt.id,wt)}}}try{let Ue=Or(n.activeColor),{jobId:et,threadId:Dt}=await Ss(ye,Ne,c,Ue,u,I.id,gt.size>0?gt:void 0,Br());for(let un of gt.keys())d.current.delete(un);let wt=K.map(un=>un.id),Tr=n.styleModifications.filter(un=>!un.captured).map(un=>un.selector);Se(un=>m(f({},un),{[et]:{annotationIds:wt,styleSelectors:Tr,color:n.activeColor,threadId:Dt}})),i({type:"MARK_CAPTURED"}),Dt&&wt.length>0&&i({type:"SET_ANNOTATION_THREAD",payload:{ids:wt,threadId:Dt}});let zn=n.activeColor.match(/oklch\([^)]*\s+([\d.]+)\s*\)/),Uo=((zn!=null&&zn[1]?parseFloat(zn[1]):29)+60)%360;return i({type:"SET_COLOR",payload:`oklch(0.628 0.258 ${Uo})`}),!0}catch(Ue){return console.error("[Pare] Failed to send to bridge:",Ue),!1}},[n.annotations,n.styleModifications,n.spacingTokenChanges,n.activeColor,i,c,u,I.id]),rn=jt(async(R,K,de)=>{try{let Oe=Or(n.activeColor),{jobId:ye}=await Ms(R,K,c,Oe,u,I.id,de,Br());Se(Ne=>m(f({},Ne),{[ye]:{annotationIds:[],styleSelectors:[],color:n.activeColor,threadId:R}}));let ke=n.annotations.filter(Ne=>Ne.threadId===R&&(Ne.status==="waiting_input"||Ne.status==="resolved"||Ne.status==="needs_review"));ke.length>0&&(i({type:"SET_ANNOTATION_STATUS",payload:{ids:ke.map(Ne=>Ne.id),status:"in_flight"}}),Se(Ne=>{let gt=Ne[ye];return gt?m(f({},Ne),{[ye]:m(f({},gt),{annotationIds:[...gt.annotationIds,...ke.map(Ue=>Ue.id)]})}):Ne})),s.dismissQuestion(R)}catch(Oe){console.error("[Pare] Failed to send reply:",Oe)}},[n.activeColor,n.annotations,c,s.dismissQuestion,i,u,I.id]),mn=Xt(new Set);_t(()=>{for(let R of s.pendingQuestions){if(mn.current.has(R.jobId))continue;mn.current.add(R.jobId);let K=R.annotationIds&&R.annotationIds.length>0?R.annotationIds:void 0;!K&&R.threadId&&(K=n.annotations.filter(de=>de.threadId===R.threadId).map(de=>de.id)),K&&K.length>0&&i({type:"SET_ANNOTATION_QUESTION",payload:{ids:K,question:R.question,threadId:R.threadId}})}},[s.pendingQuestions,i,n.annotations]);let En=Ao(()=>{if(s.activeJobId&&s.activeJobId in Q)return Q[s.activeJobId].color;let R=Object.values(Q);return R.length>0?R[R.length-1].color:void 0},[s.activeJobId,Q]),U=jt(R=>{Ge(R)},[]),Ie=jt(R=>{if(!R){z(null);return}let K=Le.current.get(R);K&&K.length>0?z(new Set(K)):z(null)},[]),Fe=jt(async R=>{try{let K=R?`${c}/cancel?jobId=${R}`:`${c}/cancel`;await fetch(K,{method:"POST"})}catch(K){}},[c]);_t(()=>{n.activeTool==="model"&&me&&Ge(null)},[n.activeTool]);let ft=Xt(null);_t(()=>{n.isAnnotating?ft.current&&(Ge(ft.current),ft.current=null):me&&(ft.current=me,Ge(null))},[n.isAnnotating]);let Lt=Ao(()=>{if(!me)return null;for(let[R,K]of Object.entries(Q))if(K.threadId===me)return R;return null},[me,Q]),[pt,bt]=Ut(!1),[St,dn]=Ut(0),zt=Xt(null),kt=jt(R=>{R?(zt.current&&(clearTimeout(zt.current),zt.current=null),bt(!0)):zt.current=setTimeout(()=>{bt(!1),zt.current=null},150)},[]),hn=jt(()=>{dn(R=>R+1),s.clearEvents(),Ge(null),dt(new Set)},[s.clearEvents]);_t(()=>()=>{zt.current&&clearTimeout(zt.current)},[]);let Y=Ao(()=>({isEnabled:t}),[t]);return t?ua(pa.Provider,{value:Y,children:[e,Po(ra,{children:ua(ta,{children:[Po(_l,{state:n,dispatch:i,onScreenshot:$e,inFlightAnnotationIds:fe,inFlightStyleSelectors:lt,inFlightSelectorColors:Qe,onAttachImages:en,onReply:s.isConnected?rn:void 0,onViewThread:s.isConnected?U:void 0,onCloseThread:R=>{Ge(null),R&&dt(K=>new Set(K).add(R))},onModelComponentsAdd:s.isConnected?ne:void 0,onModelComponentFocus:s.isConnected?Ae:void 0,onModelComponentHover:ve,modelComponentNames:M,modelPanelHoveredComponent:ae,modelSpacingTokenHover:We,highlightedAnnotationIds:Ve,externalCanvasRef:l,toolbarRef:a}),Po(Zl,{state:n,dispatch:i,onScreenshot:$e,onSendToClaude:s.isConnected?Kt:void 0,hasActiveJobs:Object.keys(Q).length>0||s.activeJobIds.length>0,activeJobColor:En,onCrosshairHover:kt,onClear:hn,provider:u,onProviderChange:s.isConnected&&v.length>1?$:void 0,availableProviders:v,modelIndex:g,modelCount:E.length,modelLabel:I.label,onModelChange:s.isConnected?Z:void 0,onViewThread:s.isConnected?U:void 0,isThreadPanelOpen:me!==null,mcpStatus:w,onInstallMcp:s.isConnected?G:void 0,mcpJustInstalled:A,bridgeUrl:c,isBridgeConnected:s.isConnected,modelSelectedComponent:X,modelCanvasHoveredComponent:he,onModelComponentHover:Re,onSpacingTokenHover:Me,onModifySpacingToken:s.isConnected?Ee:void 0,onDeleteSpacingToken:s.isConnected?ce:void 0,modelRefreshKey:Ke,onModelComponentAdded:V,onModelComponentRemoved:oe,toolbarRef:a}),me&&s.isConnected&&Po(da,{threadId:me,bridgeUrl:c,accentColor:(Be=(Pe=n.annotations.find(R=>R.threadId===me))==null?void 0:Pe.color)!=null?Be:n.activeColor,isStreaming:Lt!==null,streamingEvents:Lt?s.events.filter(R=>R.data.jobId===Lt):[],onClose:()=>Ge(null),onReply:rn,onCancel:Lt?()=>Fe(Lt):void 0,lastError:(Gt=(ge=s.lastErrorByJob)==null?void 0:ge[Lt!=null?Lt:""])!=null?Gt:void 0,toolbarRef:a}),Po(ea,{bridge:s,bridgeUrl:c,inFlightJobs:Q,isVisible:pt||s.lastResponseText!==null||s.activeJobIds.length>0,onHover:kt,clearSignal:St,onReply:rn,onViewThread:U,onCancel:Fe,onHoverJob:Ie,isConnected:s.isConnected,dismissedThreadIds:xt})]})})]}):Po(Hp,{children:e})}function Dp(){let e=Pp(pa);if(!e)throw new Error("usePopmelt must be used within PopmeltProvider");return e}export{Op as PopmeltProvider,Dp as usePopmelt};
|