@popmelt.com/core 0.24.1 → 0.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{a as o,b as d,c as l,d as s}from"./chunk-4WAFUF5Y.mjs";function g(r){let p=r?.basePath??"/popmelt",e={port:null,projectId:null},n="virtual:popmelt/bridge",i=`\0${n}`;return{name:"popmelt",resolveId(t){if(t===n)return i},load(t){if(t===i)return`export const bridgeUrl = ${JSON.stringify(e.port===null?null:`http://localhost:${e.port}`)}; export const projectId = ${JSON.stringify(e.projectId)};`},async configureServer(t){e=await o(r,t,5173),await d(e,t),t.middlewares.use(l(p,()=>e))},transformIndexHtml(){if(e.port!==null)return[{tag:"script",attrs:{type:"text/javascript"},children:s(e),injectTo:"head-prepend"}]}}}export{g as a};
1
+ import{a as o,b as d,c as l,d as s}from"./chunk-TJVWZRAF.mjs";function g(r){let p=r?.basePath??"/popmelt",e={port:null,projectId:null},n="virtual:popmelt/bridge",i=`\0${n}`;return{name:"popmelt",resolveId(t){if(t===n)return i},load(t){if(t===i)return`export const bridgeUrl = ${JSON.stringify(e.port===null?null:`http://localhost:${e.port}`)}; export const projectId = ${JSON.stringify(e.projectId)};`},async configureServer(t){e=await o(r,t,5173),await d(e,t),t.middlewares.use(l(p,()=>e))},transformIndexHtml(){if(e.port!==null)return[{tag:"script",attrs:{type:"text/javascript"},children:s(e),injectTo:"head-prepend"}]}}}export{g as a};
@@ -1 +1 @@
1
- import{a as p}from"./chunk-NOHXTT24.mjs";import{request as c}from"http";function u(){let e=process.env.POPMELT_BRIDGE_URL;if(!e)return null;try{let t=new URL(e);return{port:t.port?Number.parseInt(t.port,10):null,projectId:process.env.POPMELT_PROJECT_ID||null,leaseEligible:!1}}catch{return null}}async function h(e,t,i){let r=u();if(e?.bridge===!1||r)return r??{port:null,projectId:null,leaseEligible:!1};try{let{startPopmelt:o}=await import("./server-OPX7SKA7.mjs"),n=t.config?.server?.host,l=n===!0?"0.0.0.0":n||"localhost",s=t.config?.server?.port??i,d=`http://${l==="0.0.0.0"?"localhost":l}:${s}`,a=await o({port:e?.port,projectRoot:e?.projectRoot,devOrigin:d,force:!0,detached:!0,manageLease:!1});return console.log(`[popmelt] bridge ready at http://localhost:${a.port}`),{port:a.port,projectId:a.projectId,leaseEligible:!0}}catch(o){let n=o instanceof Error?o.message:String(o);return console.warn("[popmelt] bridge failed to start:",n),{port:null,projectId:null,leaseEligible:!1}}}async function v(e,t,i=fetch){if(!e.leaseEligible||e.port===null)return null;let r=await p({port:e.port,projectId:e.projectId},i);if(!r)return null;let o=()=>{n()},n=async()=>{process.removeListener("beforeExit",o),await r.release()};return process.once("beforeExit",o),t.httpServer?.once("close",()=>{n()}),{id:r.id,release:n}}function g(e,t,i){if(i.port===null)return null;let r=new URL(t,"http://popmelt.local");if(r.pathname!==`${e}/status`)return null;let o=new URL("/status",`http://localhost:${i.port}`);return r.searchParams.forEach((n,l)=>o.searchParams.append(l,n)),i.projectId&&o.searchParams.set("projectId",i.projectId),o}function b(e,t){return(i,r,o)=>{let n=g(e,i.url||"",t());if(!n)return o();let l=c(n,{method:i.method,headers:{...i.headers,host:n.host}},s=>{r.writeHead(s.statusCode||502,s.headers),s.pipe(r)});l.on("error",()=>{r.writeHead(502,{"Content-Type":"text/plain"}),r.end(`Popmelt bridge not running on port ${t().port}`)}),i.pipe(l)}}function P(e){let t=e.port===null?null:`http://localhost:${e.port}`;return`window.__POPMELT_BRIDGE_URL__=${JSON.stringify(t)};window.__POPMELT_PROJECT_ID__=${JSON.stringify(e.projectId)};`}export{h as a,v as b,b as c,P as d};
1
+ import{a as p}from"./chunk-NOHXTT24.mjs";import{request as c}from"http";function u(){let e=process.env.POPMELT_BRIDGE_URL;if(!e)return null;try{let t=new URL(e);return{port:t.port?Number.parseInt(t.port,10):null,projectId:process.env.POPMELT_PROJECT_ID||null,leaseEligible:!1}}catch{return null}}async function h(e,t,i){let r=u();if(e?.bridge===!1||r)return r??{port:null,projectId:null,leaseEligible:!1};try{let{startPopmelt:o}=await import("./server-M6OXW7FE.mjs"),n=t.config?.server?.host,l=n===!0?"0.0.0.0":n||"localhost",s=t.config?.server?.port??i,d=`http://${l==="0.0.0.0"?"localhost":l}:${s}`,a=await o({port:e?.port,projectRoot:e?.projectRoot,devOrigin:d,force:!0,detached:!0,manageLease:!1});return console.log(`[popmelt] bridge ready at http://localhost:${a.port}`),{port:a.port,projectId:a.projectId,leaseEligible:!0}}catch(o){let n=o instanceof Error?o.message:String(o);return console.warn("[popmelt] bridge failed to start:",n),{port:null,projectId:null,leaseEligible:!1}}}async function v(e,t,i=fetch){if(!e.leaseEligible||e.port===null)return null;let r=await p({port:e.port,projectId:e.projectId},i);if(!r)return null;let o=()=>{n()},n=async()=>{process.removeListener("beforeExit",o),await r.release()};return process.once("beforeExit",o),t.httpServer?.once("close",()=>{n()}),{id:r.id,release:n}}function g(e,t,i){if(i.port===null)return null;let r=new URL(t,"http://popmelt.local");if(r.pathname!==`${e}/status`)return null;let o=new URL("/status",`http://localhost:${i.port}`);return r.searchParams.forEach((n,l)=>o.searchParams.append(l,n)),i.projectId&&o.searchParams.set("projectId",i.projectId),o}function b(e,t){return(i,r,o)=>{let n=g(e,i.url||"",t());if(!n)return o();let l=c(n,{method:i.method,headers:{...i.headers,host:n.host}},s=>{r.writeHead(s.statusCode||502,s.headers),s.pipe(r)});l.on("error",()=>{r.writeHead(502,{"Content-Type":"text/plain"}),r.end(`Popmelt bridge not running on port ${t().port}`)}),i.pipe(l)}}function P(e){let t=e.port===null?null:`http://localhost:${e.port}`;return`window.__POPMELT_BRIDGE_URL__=${JSON.stringify(t)};window.__POPMELT_PROJECT_ID__=${JSON.stringify(e.projectId)};`}export{h as a,v as b,b as c,P as d};
@@ -26,7 +26,7 @@ import{q as mc,w as Do,E as Ia,D as Po,G as Ma,F as No,I as Ta,H as Fo,h as Rr,g
26
26
  [data-popmelt-session-connection] .lucide-loader-circle { animation: popmelt-connection-spin .8s linear infinite; }
27
27
  [data-popmelt-session-connection] > svg { flex-shrink: 0; }
28
28
  @media (prefers-reduced-motion: reduce) { [data-popmelt-session-connection] .lucide-loader-circle { animation: none; } }
29
- `}),v("button",{"data-popmelt-session-connection":!0,type:"button",disabled:m,title:X,"aria-label":`${q}. ${X}`,"aria-busy":m,onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),onFocus:()=>h(!0),onBlur:()=>h(!1),onClick:()=>{ge()},style:{...vn(Te[e],T),cursor:m?"default":"pointer",minWidth:0,maxWidth:"100%"},children:[m||n&&!T?d(ir,{size:14,strokeWidth:1.5,"aria-hidden":"true"}):T||x?d(jo,{size:14,strokeWidth:1.5,"aria-hidden":"true"}):d(Ha,{size:14,strokeWidth:1.5,"aria-hidden":"true"}),v("span",{style:{display:"inline-grid",textAlign:"left",whiteSpace:"nowrap",position:"relative",minWidth:0},children:[I.map(ke=>d("span",{"aria-hidden":"true",style:{gridArea:"1 / 1",visibility:"hidden",pointerEvents:"none",overflow:"hidden"},children:ke},ke)),d("span",{"data-popmelt-connection-label":!0,title:q,style:{position:"absolute",inset:0,overflow:"hidden",textOverflow:"ellipsis"},children:q})]})]})]})}function Hn(e){return e<=767}function xn(e){return Hn(e)?8:16}function Pt(e){let t=xn(e);return e<=480?Math.max(0,e-t*2):Math.min(360,Math.max(0,e-t*2))}var sl=16,vt=40,wn=8,dl="popmelt-toolbar-snap-position";function Cn(e){return e.startsWith("top-")}function qn(e){return e.endsWith("-right")}function cr(e){return e.endsWith("-center")}function cl(){try{let e=localStorage.getItem(dl);if(e&&_u(e))return e}catch{}return"bottom-right"}function ul(e){try{localStorage.setItem(dl,e)}catch{}}function _u(e){return["bottom-right","bottom-center","bottom-left","top-right","top-center","top-left"].includes(e)}function ep(e,t,n){let r=Hn(t),o=xn(t),i=Cn(e)?r?`max(${o}px, env(safe-area-inset-top))`:o:r?"auto":n-o-vt,a=!Cn(e)&&r?`max(${o}px, env(safe-area-inset-bottom))`:void 0;return cr(e)?{position:"fixed",top:i,bottom:a,left:"50%",transform:"translateX(-50%)"}:qn(e)?{position:"fixed",top:i,bottom:a,right:r?`max(${o}px, env(safe-area-inset-right))`:o,left:"auto"}:{position:"fixed",top:i,bottom:a,left:r?`max(${o}px, env(safe-area-inset-left))`:o,right:"auto"}}function en(e,t,n,r=12){let o=Cn(e),i=Hn(t),a=xn(t),l=o?{top:i?`calc(max(${a}px, env(safe-area-inset-top)) + ${vt+r}px)`:a+vt+r}:{bottom:i?`calc(max(${a}px, env(safe-area-inset-bottom)) + ${vt+r}px)`:a+vt+r},s;return cr(e)?s={left:"50%",transform:"translateX(-50%)"}:qn(e)?s={right:i?`max(${a}px, env(safe-area-inset-right))`:a}:s={left:i?`max(${a}px, env(safe-area-inset-left))`:a},{position:"fixed",...l,...s}}function tp(e,t,n){let r=Cn(e),o=Hn(t),i=xn(t),a=r?{top:o?`calc(max(${i}px, env(safe-area-inset-top)) + ${vt+8}px)`:i+vt+8}:{bottom:o?`calc(max(${i}px, env(safe-area-inset-bottom)) + ${vt+8}px)`:i+vt+8},l,s;return cr(e)?(l={left:"50%",transform:"translateX(-50%)"},s="center"):qn(e)?(l={right:o?`max(${i}px, env(safe-area-inset-right))`:i},s="flex-end"):(l={left:o?`max(${i}px, env(safe-area-inset-left))`:i},s="flex-start"),{position:"fixed",...a,...l,zIndex:9999,display:"flex",flexDirection:"column",alignItems:s}}function np(e,t=typeof window<"u"?window.innerWidth:1920){let n=Cn(e),r=qn(e)||cr(e),o=Hn(t),i=xn(t),a=n&&r?i+vt+wn:i,l=!n&&r?i+vt+wn:i;return{position:"fixed",top:o?`max(${a}px, env(safe-area-inset-top))`:a,right:o?`max(${i}px, env(safe-area-inset-right))`:i,bottom:o?`max(${l}px, env(safe-area-inset-bottom))`:l,width:Pt(t)}}function rp(e,t,n){let r=Pt(t),o=xn(t),i=Cn(e),a,l;qn(e)||cr(e)?(a=t-o,l=a-r):(l=o,a=l+r);let s=i?o+vt+wn:n-o-vt-wn;return{left:l,right:a,y:s}}var op=["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"],kn={toolbar:{toggleWindowMs:300},tools:{imprint:{key:"i",tool:"model"},steer:{key:"s",tool:"sticker"},comment:{key:"c",tool:"inspector"}},actions:{send:{key:"Enter"},screenshot:{key:"c"},clear:{keys:["Backspace","Delete"]},undo:{key:"z"}},omnidial:{previous:["a","ArrowLeft"],next:["d","ArrowRight"],previousFacet:["q"],nextFacet:["e"],descendOrApply:["w","Enter"],ascend:["s","Escape"],query:[" "]}},ip=[{type:"model",label:"Imprint",shortcut:"I"},{type:"sticker",label:"Steer",shortcut:"S"},{type:"inspector",label:"Chat",shortcut:"C"}];function ap(e){let t=e.toLowerCase();return Object.values(kn.tools).find(n=>n.key===t)?.tool??null}function lp(e){let t=e.length===1?e.toLowerCase():e,n=kn.omnidial;return[...n.previous,...n.next,...n.previousFacet,...n.nextFacet,...n.descendOrApply,...n.ascend,...n.query].includes(t)||/^[a-z0-9]$/i.test(e)}var pl=100,Vt=200,Wr={surface:null,phase:"visible"};function Yo({openDelayMs:e=pl,exitDurationMs:t=Vt}={}){let[n,r]=N(Wr),o=O(Wr),i=O(null),a=O(null),l=O(null),s=ie(g=>{o.current.surface===g.surface&&o.current.phase===g.phase||(o.current=g,r(g))},[]),c=ie(()=>{a.current&&(clearTimeout(a.current),a.current=null)},[]),u=ie(()=>{l.current&&(clearTimeout(l.current),l.current=null)},[]),p=ie(g=>{i.current=g,c(),u(),s({surface:g,phase:"visible"})},[u,c,s]),f=ie(g=>{if(i.current=g,c(),u(),o.current.surface!==null){s({surface:g,phase:"visible"});return}a.current=setTimeout(()=>{a.current=null,i.current===g&&s({surface:g,phase:"visible"})},e)},[u,c,e,s]),h=ie(g=>{i.current===g&&(i.current=null),c(),o.current.surface===g&&(u(),s({surface:g,phase:"exiting"}),l.current=setTimeout(()=>{l.current=null,i.current===null&&s(Wr)},t))},[u,c,t,s]),m=ie(g=>{g&&o.current.surface!==g||(i.current=null,c(),u(),s(Wr))},[u,c,s]);return Z(()=>()=>{c(),u()},[u,c]),{surface:n.surface,phase:n.phase,enter:f,leave:h,show:p,dismiss:m}}var sp={version:"0.24.1"},fl=sp.version;function Qo({theme:e,expanded:t,width:n,snapPosition:r,viewport:o,toolbarRef:i,style:a,...l}){let s=Te[e];return d("div",{...l,ref:i,id:"devtools-toolbar",role:"toolbar","data-popmelt-theme":e,style:{...ep(r,o.w,o.h),zIndex:9999,display:"flex",alignItems:"center",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",cursor:"pointer",overflow:"visible",transition:"none",backgroundColor:s.surface,color:s.primary,colorScheme:e,boxSizing:"border-box",border:t?0:`1px solid ${s.border}`,boxShadow:t?`0 0 0 1px ${s.border}`:void 0,borderRadius:20,padding:t?"4px 8px 4px 4px":0,width:t?n:40,height:40,gap:t?6:0,justifyContent:t?"flex-start":"center",...a}})}function Ko({expanded:e,active:t=!1,color:n,onSettlingChange:r,...o}){return d("button",{type:"button",title:e?"Collapse (\u2318\u2318)":"Open Popmelt (\u2318\u2318)",...o,style:{display:"flex",alignItems:"center",justifyContent:"center",width:e?24:40,height:e?32:40,flexShrink:0,border:"none",background:"none",padding:0,cursor:"pointer"},children:d(nl,{"data-popmelt-logo":!0,active:t,onSettlingChange:r,width:"24",height:"24",viewBox:"0 0 40 40",fill:e||t?n:"none",stroke:e||t?"none":n,strokeWidth:"1",strokeLinejoin:"round",xmlns:"http://www.w3.org/2000/svg"})})}function hl({theme:e,active:t,busy:n,color:r,onSettlingChange:o,onOpen:i,onCrosshairHover:a,onMouseEnter:l,toolbarRef:s,...c}){let u=O(null);return Z(()=>{let p=u.current;if(!p)return;let f=p.querySelector("[data-popmelt-logo]"),h=()=>{p.style.opacity="1",!n&&f&&(f.style.fill=Te[e].primary,f.style.stroke="none")},m=()=>{p.style.opacity=n?"1":"0.2",!n&&f&&(f.style.fill="none",f.style.removeProperty("stroke"))};return p.addEventListener("mouseenter",h),p.addEventListener("mouseleave",m),()=>{p.removeEventListener("mouseenter",h),p.removeEventListener("mouseleave",m)}},[n,e]),d(Qo,{...c,theme:e,expanded:!1,width:40,toolbarRef:p=>{u.current=p,typeof s=="function"?s(p):s&&(s.current=p)},onMouseEnter:l,style:{opacity:n?1:.2,...c.style},children:d(Ko,{expanded:!1,active:t,color:r,onSettlingChange:o,onClick:i,onMouseEnter:()=>a?.(!0),onMouseLeave:()=>a?.(!1)})})}function ml(){let e=()=>typeof window>"u"?{w:1920,h:1080}:{w:window.visualViewport?.width??window.innerWidth,h:window.visualViewport?.height??window.innerHeight},[t,n]=N(e);return Z(()=>{let r=()=>n(e());return window.addEventListener("resize",r),window.visualViewport?.addEventListener("resize",r),()=>{window.removeEventListener("resize",r),window.visualViewport?.removeEventListener("resize",r)}},[]),t}function gl(e){let t=O(e);t.current=e,Z(()=>{let n=0,r=0,o=a=>{if(a.key!=="Meta"&&a.key!=="Control"){r=0;return}let l=Date.now();r=l-n<kn.toolbar.toggleWindowMs?r+1:1,r>=2&&(t.current(),r=0),n=l},i=a=>{a.key!=="Meta"&&a.key!=="Control"&&(r=0)};return window.addEventListener("keydown",o),window.addEventListener("keyup",i),()=>{window.removeEventListener("keydown",o),window.removeEventListener("keyup",i)}},[])}var dp=(e,t)=>({display:"flex",width:t,height:32,borderRadius:16,overflow:"hidden",background:Te[e].control});function cp({theme:e,icon:t,menuOpen:n=!1,interactive:r=!0,primaryLabel:o="Cycle annotations",primaryCursor:i=!1,dotColor:a,onPrimary:l,onMenu:s}){let c=Te[e];return v("div",{"data-popmelt-compact-tool-control":!0,style:{...dp(e,46),pointerEvents:r?void 0:"none"},children:[v("button",{type:"button","aria-label":o,"aria-disabled":!r,tabIndex:r?void 0:-1,onClick:l,style:{width:26,height:32,display:"flex",alignItems:"center",justifyContent:"flex-end",position:"relative",padding:0,border:0,background:"transparent",color:c.primary,cursor:r&&i?"pointer":"default"},children:[t,a&&d("span",{"aria-hidden":"true",style:{position:"absolute",left:16,top:14,width:4,height:4,borderRadius:"50%",background:a,pointerEvents:"none"}})]}),d("button",{type:"button","aria-label":"Choose tool","aria-haspopup":"menu","aria-expanded":n,"aria-disabled":!r,tabIndex:r?void 0:-1,onClick:s,style:{width:20,height:32,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",padding:"0 6px 0 2px",border:0,background:"transparent",color:c.mutedStrong,cursor:r?"pointer":"default"},children:d(Vo,{size:12,strokeWidth:2,style:{transform:n?"rotate(180deg)":"rotate(0deg)",transition:"transform 120ms ease"}})})]})}function up({theme:e,themePreference:t=e,onThemePreferenceChange:n,action:r,logoOnly:o=!1,connection:i,panel:a,deemphasizeControls:l=!1,onCollapse:s,ariaLabel:c="Popmelt admission"}){let[u,p]=N(()=>!o),[f,h]=N(cl),m=O(null),g=Yo(),{leave:w,dismiss:k}=g,x=g.surface!==null&&g.phase==="visible",M=ml(),I=()=>{if(u){k(),s?.(),p(!1);return}p(!0),o&&g.show("popmelt-guide")};return gl(I),Z(()=>{let S=m.current;if(!S)return;let A=D=>{D.relatedTarget instanceof Node&&S.contains(D.relatedTarget)||w("popmelt-guide")};return S.addEventListener("pointerout",A),()=>S.removeEventListener("pointerout",A)},[u,w]),u?v("div",{ref:m,style:{display:"contents"},onKeyDown:S=>{S.key==="Escape"&&k()},onBlur:S=>{S.relatedTarget instanceof Node&&m.current?.contains(S.relatedTarget)||w("popmelt-guide")},children:[d("style",{children:`
29
+ `}),v("button",{"data-popmelt-session-connection":!0,type:"button",disabled:m,title:X,"aria-label":`${q}. ${X}`,"aria-busy":m,onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),onFocus:()=>h(!0),onBlur:()=>h(!1),onClick:()=>{ge()},style:{...vn(Te[e],T),cursor:m?"default":"pointer",minWidth:0,maxWidth:"100%"},children:[m||n&&!T?d(ir,{size:14,strokeWidth:1.5,"aria-hidden":"true"}):T||x?d(jo,{size:14,strokeWidth:1.5,"aria-hidden":"true"}):d(Ha,{size:14,strokeWidth:1.5,"aria-hidden":"true"}),v("span",{style:{display:"inline-grid",textAlign:"left",whiteSpace:"nowrap",position:"relative",minWidth:0},children:[I.map(ke=>d("span",{"aria-hidden":"true",style:{gridArea:"1 / 1",visibility:"hidden",pointerEvents:"none",overflow:"hidden"},children:ke},ke)),d("span",{"data-popmelt-connection-label":!0,title:q,style:{position:"absolute",inset:0,overflow:"hidden",textOverflow:"ellipsis"},children:q})]})]})]})}function Hn(e){return e<=767}function xn(e){return Hn(e)?8:16}function Pt(e){let t=xn(e);return e<=480?Math.max(0,e-t*2):Math.min(360,Math.max(0,e-t*2))}var sl=16,vt=40,wn=8,dl="popmelt-toolbar-snap-position";function Cn(e){return e.startsWith("top-")}function qn(e){return e.endsWith("-right")}function cr(e){return e.endsWith("-center")}function cl(){try{let e=localStorage.getItem(dl);if(e&&_u(e))return e}catch{}return"bottom-right"}function ul(e){try{localStorage.setItem(dl,e)}catch{}}function _u(e){return["bottom-right","bottom-center","bottom-left","top-right","top-center","top-left"].includes(e)}function ep(e,t,n){let r=Hn(t),o=xn(t),i=Cn(e)?r?`max(${o}px, env(safe-area-inset-top))`:o:r?"auto":n-o-vt,a=!Cn(e)&&r?`max(${o}px, env(safe-area-inset-bottom))`:void 0;return cr(e)?{position:"fixed",top:i,bottom:a,left:"50%",transform:"translateX(-50%)"}:qn(e)?{position:"fixed",top:i,bottom:a,right:r?`max(${o}px, env(safe-area-inset-right))`:o,left:"auto"}:{position:"fixed",top:i,bottom:a,left:r?`max(${o}px, env(safe-area-inset-left))`:o,right:"auto"}}function en(e,t,n,r=12){let o=Cn(e),i=Hn(t),a=xn(t),l=o?{top:i?`calc(max(${a}px, env(safe-area-inset-top)) + ${vt+r}px)`:a+vt+r}:{bottom:i?`calc(max(${a}px, env(safe-area-inset-bottom)) + ${vt+r}px)`:a+vt+r},s;return cr(e)?s={left:"50%",transform:"translateX(-50%)"}:qn(e)?s={right:i?`max(${a}px, env(safe-area-inset-right))`:a}:s={left:i?`max(${a}px, env(safe-area-inset-left))`:a},{position:"fixed",...l,...s}}function tp(e,t,n){let r=Cn(e),o=Hn(t),i=xn(t),a=r?{top:o?`calc(max(${i}px, env(safe-area-inset-top)) + ${vt+8}px)`:i+vt+8}:{bottom:o?`calc(max(${i}px, env(safe-area-inset-bottom)) + ${vt+8}px)`:i+vt+8},l,s;return cr(e)?(l={left:"50%",transform:"translateX(-50%)"},s="center"):qn(e)?(l={right:o?`max(${i}px, env(safe-area-inset-right))`:i},s="flex-end"):(l={left:o?`max(${i}px, env(safe-area-inset-left))`:i},s="flex-start"),{position:"fixed",...a,...l,zIndex:9999,display:"flex",flexDirection:"column",alignItems:s}}function np(e,t=typeof window<"u"?window.innerWidth:1920){let n=Cn(e),r=qn(e)||cr(e),o=Hn(t),i=xn(t),a=n&&r?i+vt+wn:i,l=!n&&r?i+vt+wn:i;return{position:"fixed",top:o?`max(${a}px, env(safe-area-inset-top))`:a,right:o?`max(${i}px, env(safe-area-inset-right))`:i,bottom:o?`max(${l}px, env(safe-area-inset-bottom))`:l,width:Pt(t)}}function rp(e,t,n){let r=Pt(t),o=xn(t),i=Cn(e),a,l;qn(e)||cr(e)?(a=t-o,l=a-r):(l=o,a=l+r);let s=i?o+vt+wn:n-o-vt-wn;return{left:l,right:a,y:s}}var op=["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"],kn={toolbar:{toggleWindowMs:300},tools:{imprint:{key:"i",tool:"model"},steer:{key:"s",tool:"sticker"},comment:{key:"c",tool:"inspector"}},actions:{send:{key:"Enter"},screenshot:{key:"c"},clear:{keys:["Backspace","Delete"]},undo:{key:"z"}},omnidial:{previous:["a","ArrowLeft"],next:["d","ArrowRight"],previousFacet:["q"],nextFacet:["e"],descendOrApply:["w","Enter"],ascend:["s","Escape"],query:[" "]}},ip=[{type:"model",label:"Imprint",shortcut:"I"},{type:"sticker",label:"Steer",shortcut:"S"},{type:"inspector",label:"Chat",shortcut:"C"}];function ap(e){let t=e.toLowerCase();return Object.values(kn.tools).find(n=>n.key===t)?.tool??null}function lp(e){let t=e.length===1?e.toLowerCase():e,n=kn.omnidial;return[...n.previous,...n.next,...n.previousFacet,...n.nextFacet,...n.descendOrApply,...n.ascend,...n.query].includes(t)||/^[a-z0-9]$/i.test(e)}var pl=100,Vt=200,Wr={surface:null,phase:"visible"};function Yo({openDelayMs:e=pl,exitDurationMs:t=Vt}={}){let[n,r]=N(Wr),o=O(Wr),i=O(null),a=O(null),l=O(null),s=ie(g=>{o.current.surface===g.surface&&o.current.phase===g.phase||(o.current=g,r(g))},[]),c=ie(()=>{a.current&&(clearTimeout(a.current),a.current=null)},[]),u=ie(()=>{l.current&&(clearTimeout(l.current),l.current=null)},[]),p=ie(g=>{i.current=g,c(),u(),s({surface:g,phase:"visible"})},[u,c,s]),f=ie(g=>{if(i.current=g,c(),u(),o.current.surface!==null){s({surface:g,phase:"visible"});return}a.current=setTimeout(()=>{a.current=null,i.current===g&&s({surface:g,phase:"visible"})},e)},[u,c,e,s]),h=ie(g=>{i.current===g&&(i.current=null),c(),o.current.surface===g&&(u(),s({surface:g,phase:"exiting"}),l.current=setTimeout(()=>{l.current=null,i.current===null&&s(Wr)},t))},[u,c,t,s]),m=ie(g=>{g&&o.current.surface!==g||(i.current=null,c(),u(),s(Wr))},[u,c,s]);return Z(()=>()=>{c(),u()},[u,c]),{surface:n.surface,phase:n.phase,enter:f,leave:h,show:p,dismiss:m}}var sp={version:"0.24.2"},fl=sp.version;function Qo({theme:e,expanded:t,width:n,snapPosition:r,viewport:o,toolbarRef:i,style:a,...l}){let s=Te[e];return d("div",{...l,ref:i,id:"devtools-toolbar",role:"toolbar","data-popmelt-theme":e,style:{...ep(r,o.w,o.h),zIndex:9999,display:"flex",alignItems:"center",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",cursor:"pointer",overflow:"visible",transition:"none",backgroundColor:s.surface,color:s.primary,colorScheme:e,boxSizing:"border-box",border:t?0:`1px solid ${s.border}`,boxShadow:t?`0 0 0 1px ${s.border}`:void 0,borderRadius:20,padding:t?"4px 8px 4px 4px":0,width:t?n:40,height:40,gap:t?6:0,justifyContent:t?"flex-start":"center",...a}})}function Ko({expanded:e,active:t=!1,color:n,onSettlingChange:r,...o}){return d("button",{type:"button",title:e?"Collapse (\u2318\u2318)":"Open Popmelt (\u2318\u2318)",...o,style:{display:"flex",alignItems:"center",justifyContent:"center",width:e?24:40,height:e?32:40,flexShrink:0,border:"none",background:"none",padding:0,cursor:"pointer"},children:d(nl,{"data-popmelt-logo":!0,active:t,onSettlingChange:r,width:"24",height:"24",viewBox:"0 0 40 40",fill:e||t?n:"none",stroke:e||t?"none":n,strokeWidth:"1",strokeLinejoin:"round",xmlns:"http://www.w3.org/2000/svg"})})}function hl({theme:e,active:t,busy:n,color:r,onSettlingChange:o,onOpen:i,onCrosshairHover:a,onMouseEnter:l,toolbarRef:s,...c}){let u=O(null);return Z(()=>{let p=u.current;if(!p)return;let f=p.querySelector("[data-popmelt-logo]"),h=()=>{p.style.opacity="1",!n&&f&&(f.style.fill=Te[e].primary,f.style.stroke="none")},m=()=>{p.style.opacity=n?"1":"0.2",!n&&f&&(f.style.fill="none",f.style.removeProperty("stroke"))};return p.addEventListener("mouseenter",h),p.addEventListener("mouseleave",m),()=>{p.removeEventListener("mouseenter",h),p.removeEventListener("mouseleave",m)}},[n,e]),d(Qo,{...c,theme:e,expanded:!1,width:40,toolbarRef:p=>{u.current=p,typeof s=="function"?s(p):s&&(s.current=p)},onMouseEnter:l,style:{opacity:n?1:.2,...c.style},children:d(Ko,{expanded:!1,active:t,color:r,onSettlingChange:o,onClick:i,onMouseEnter:()=>a?.(!0),onMouseLeave:()=>a?.(!1)})})}function ml(){let e=()=>typeof window>"u"?{w:1920,h:1080}:{w:window.visualViewport?.width??window.innerWidth,h:window.visualViewport?.height??window.innerHeight},[t,n]=N(e);return Z(()=>{let r=()=>n(e());return window.addEventListener("resize",r),window.visualViewport?.addEventListener("resize",r),()=>{window.removeEventListener("resize",r),window.visualViewport?.removeEventListener("resize",r)}},[]),t}function gl(e){let t=O(e);t.current=e,Z(()=>{let n=0,r=0,o=a=>{if(a.key!=="Meta"&&a.key!=="Control"){r=0;return}let l=Date.now();r=l-n<kn.toolbar.toggleWindowMs?r+1:1,r>=2&&(t.current(),r=0),n=l},i=a=>{a.key!=="Meta"&&a.key!=="Control"&&(r=0)};return window.addEventListener("keydown",o),window.addEventListener("keyup",i),()=>{window.removeEventListener("keydown",o),window.removeEventListener("keyup",i)}},[])}var dp=(e,t)=>({display:"flex",width:t,height:32,borderRadius:16,overflow:"hidden",background:Te[e].control});function cp({theme:e,icon:t,menuOpen:n=!1,interactive:r=!0,primaryLabel:o="Cycle annotations",primaryCursor:i=!1,dotColor:a,onPrimary:l,onMenu:s}){let c=Te[e];return v("div",{"data-popmelt-compact-tool-control":!0,style:{...dp(e,46),pointerEvents:r?void 0:"none"},children:[v("button",{type:"button","aria-label":o,"aria-disabled":!r,tabIndex:r?void 0:-1,onClick:l,style:{width:26,height:32,display:"flex",alignItems:"center",justifyContent:"flex-end",position:"relative",padding:0,border:0,background:"transparent",color:c.primary,cursor:r&&i?"pointer":"default"},children:[t,a&&d("span",{"aria-hidden":"true",style:{position:"absolute",left:16,top:14,width:4,height:4,borderRadius:"50%",background:a,pointerEvents:"none"}})]}),d("button",{type:"button","aria-label":"Choose tool","aria-haspopup":"menu","aria-expanded":n,"aria-disabled":!r,tabIndex:r?void 0:-1,onClick:s,style:{width:20,height:32,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",padding:"0 6px 0 2px",border:0,background:"transparent",color:c.mutedStrong,cursor:r?"pointer":"default"},children:d(Vo,{size:12,strokeWidth:2,style:{transform:n?"rotate(180deg)":"rotate(0deg)",transition:"transform 120ms ease"}})})]})}function up({theme:e,themePreference:t=e,onThemePreferenceChange:n,action:r,logoOnly:o=!1,connection:i,panel:a,deemphasizeControls:l=!1,onCollapse:s,ariaLabel:c="Popmelt admission"}){let[u,p]=N(()=>!o),[f,h]=N(cl),m=O(null),g=Yo(),{leave:w,dismiss:k}=g,x=g.surface!==null&&g.phase==="visible",M=ml(),I=()=>{if(u){k(),s?.(),p(!1);return}p(!0),o&&g.show("popmelt-guide")};return gl(I),Z(()=>{let S=m.current;if(!S)return;let A=D=>{D.relatedTarget instanceof Node&&S.contains(D.relatedTarget)||w("popmelt-guide")};return S.addEventListener("pointerout",A),()=>S.removeEventListener("pointerout",A)},[u,w]),u?v("div",{ref:m,style:{display:"contents"},onKeyDown:S=>{S.key==="Escape"&&k()},onBlur:S=>{S.relatedTarget instanceof Node&&m.current?.contains(S.relatedTarget)||w("popmelt-guide")},children:[d("style",{children:`
30
30
  [data-popmelt-entry-dimmed] [data-popmelt-entry-content],
31
31
  [data-popmelt-entry-dimmed] [data-popmelt-entry-control] > [data-popmelt-logo] {
32
32
  opacity: 1;