@fungi.computer/prints 0.18.1 → 0.18.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.
- package/dist/assets/{audio-waveform-CKaaFNjh.js → audio-waveform-Be5wRu8s.js} +1 -1
- package/dist/assets/{audio-waveform-view-CqGGEmLT.js → audio-waveform-view-DbTyVH72.js} +1 -1
- package/dist/assets/{computer-Dlwsjq-K.js → computer-Bfe-Ioxr.js} +1 -1
- package/dist/assets/{dist-Cc0qB3Mq.js → dist-DAokFn5x.js} +1 -1
- package/dist/assets/{dropdown-menu-Bp_cc0HZ.js → dropdown-menu-CAHLGfkb.js} +1 -1
- package/dist/assets/{generation-quote-DLlxvJxr.js → generation-quote-DcaCSlvV.js} +1 -1
- package/dist/assets/index-D-LwJiG1.js +2 -0
- package/dist/assets/{library-rail-CA4Qg4FP.js → library-rail-DVjIWa9C.js} +2 -2
- package/dist/assets/{library-view--GUDH_qa.js → library-view-BBAeJjj6.js} +1 -1
- package/dist/assets/log-event-B3BGsDWO.js +1 -0
- package/dist/assets/{print-download-button-hClIKKJA.js → print-download-button-BNNi_aoW.js} +2 -2
- package/dist/assets/{print-info-drawer-CtimiOWW.js → print-info-drawer-DDZan_oj.js} +2 -2
- package/dist/assets/{print-viewer-APDEs41V.js → print-viewer-D7p4Tznx.js} +2 -2
- package/dist/assets/query-CYqgVHJ7.js +1 -0
- package/dist/assets/useMutation-DH-cbXIA.js +1 -0
- package/dist/index.html +11 -11
- package/package.json +5 -5
- package/dist/assets/index-0YeCF6OC.js +0 -2
- package/dist/assets/log-event-R2fM9w5a.js +0 -1
- package/dist/assets/query-CvXKo0g1.js +0 -1
- package/dist/assets/useMutation-RbhZiO3b.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,Vn as n,v as r,y as i}from"./button-oE2Hrd5D.js";import{l as a,u as o}from"./log-event-R2fM9w5a.js";import{$ as s,$t as c,A as l,At as u,B as d,Bt as f,C as p,Cn as m,Ct as h,D as g,Dt as _,E as v,En as y,F as b,Ft as x,G as ee,Gt as S,H as C,Ht as w,I as T,It as E,J as te,K as ne,Kt as D,L as O,Lt as re,M as ie,Mt as ae,Nt as oe,On as k,Ot as A,Pt as se,Q as j,Qt as M,R as N,Rt as P,S as F,Sn as I,St as L,T as R,Tn as z,Tt as B,U as V,Ut as H,V as ce,Vt as U,W,Y as le,Z as ue,_ as G,_n as de,_t as K,a as fe,an as pe,at as me,b as he,bt as q,c as J,cn as ge,ct as _e,dn as ve,dt as ye,en as be,et as xe,f as Se,fn as Ce,ft as we,g as Te,gn as Y,gt as Ee,h as De,hn as Oe,ht as ke,i as Ae,in as X,it as je,j as Me,jt as Ne,k as Pe,kn as Fe,kt as Ie,l as Le,ln as Re,lt as ze,m as Be,mn as Ve,n as Z,nn as He,nt as Ue,o as We,on as Ge,p as Ke,pn as qe,pt as Je,q as Ye,r as Xe,rn as Ze,rt as Qe,s as $e,sn as et,t as tt,tn as nt,tt as rt,un as it,ut as at,v as ot,vn as st,w as ct,wn as lt,wt as ut,x as dt,xn as ft,xt as pt,y as mt,yn as ht,z as gt,zt as _t}from"./useTriggerFocusGuards-Bddw7Qdn.js";function vt(e){return/\.mp4$/iu.test(e)}async function yt(e,t){if(vt(e.name)){let n=document.createElement(`video`);return n.preload=`metadata`,n.muted=!0,await new Promise((e,r)=>{n.addEventListener(`loadedmetadata`,()=>{e()},{once:!0}),n.addEventListener(`error`,()=>{r(Error(`MP4 metadata could not be read`))},{once:!0}),n.src=t}),{file:e,url:t,width:n.videoWidth,height:n.videoHeight}}if(o(e.name)){let n=new Audio;return n.preload=`metadata`,await new Promise((e,r)=>{n.addEventListener(`loadedmetadata`,()=>{e()},{once:!0}),n.addEventListener(`error`,()=>{r(Error(`MP3 metadata could not be read`))},{once:!0}),n.src=t}),{file:e,url:t,...a}}let n=new Image;return n.src=t,await n.decode(),{file:e,url:t,width:n.naturalWidth,height:n.naturalHeight}}var Q=e(n(),1),bt=ge&&et;function xt(e,t={}){let{enabled:n=!0,delay:r}=t,{events:i,dataRef:a}=e.context,o=Q.useRef(!1),s=Q.useRef(null),c=Q.useRef(!0),l=ft();Q.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=it(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&Ce(t)&&t===Ze(Ie(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return je(B(r,`blur`,i),bt&&B(r,`keydown`,a,!0),bt&&B(r,`pointerdown`,l,!0))},[e,n]),Q.useEffect(()=>{if(!n)return;function t(t){if(t.reason===`trigger-press`||t.reason===`escape-key`){let t=e.select(`domReferenceElement`);ve(t)&&(s.current=t,o.current=!0)}}return i.on(`openchange`,t),()=>{i.off(`openchange`,t)}},[i,n,e]);let u=Q.useMemo(()=>{function t(){o.current=!1,s.current=null}return{onMouseLeave(){t()},onFocus(n){let i=n.currentTarget;if(o.current){if(s.current===i)return;t()}let a=pe(n.nativeEvent);if(ve(a)){if(bt&&!n.relatedTarget){if(!c.current&&!w(a))return}else if(!H(a))return}let u=f(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:p}=n;if(e.select(`open`)&&u||!r){e.setOpen(!0,q(K,d,p));return}l.start(r,()=>{o.current||e.setOpen(!0,q(K,d,p))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=ve(r)&&r.hasAttribute(xe(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{let t=e.select(`domReferenceElement`),n=Ze(Ie(t));!r&&n===t||X(a.current.floatingContext?.refs.floating.current,n)||X(t,n)||o||f(r??n,e.context.triggerElements)||e.setOpen(!1,q(K,i))})}}},[a,r,e,l]);return Q.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}function St(e){return et&&e.movementX===0&&e.movementY===0}function Ct(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function wt(e,t){return Ct(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function Tt(e,t,n){return Ct(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function Et(e,t,n){return Ct(t,n?e===be:e===nt,e===c)}function Dt(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:Ct(t,n?e===nt:e===be,e===He)}function Ot(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:c=!1,loopFocus:l=!1,nested:d=!1,rtl:f=!1,virtual:p=!1,focusItemOnOpen:m=`auto`,focusItemOnHover:h=!0,openOnArrowKeyDown:g=!0,disabledIndices:_=void 0,orientation:v=`vertical`,triggerOrientation:y=v,parentOrientation:b,id:x,resetOnPointerLeave:ee=!0,externalTree:S,nestedReturnFocusRef:C,grid:T}=t,te=T!=null,D=e.useState(`open`),O=e.useState(`floatingElement`),ie=e.useState(`domReferenceElement`),oe=e.context.dataRef,k=_t(O),j=U(ie),M=Qe(k),N=ne(),F=Ye(S),I=Q.useRef(m),L=Q.useRef(o??-1),R=Q.useRef(null),B=Q.useRef(!0),V=z(e=>{i(L.current===-1?null:L.current,e)}),H=Q.useRef(!!O),ce=Q.useRef(D),W=Q.useRef(!1),le=Q.useRef(!1),ue=Q.useRef(null),G=Qe(_),de=Qe(D),K=Qe(o),fe=Qe(ee),me=Ue(),he=Ue(),J=z(()=>{me.cancel();function e(e){p||(ue.current=s(e,{sync:W.current,preventScroll:!0}))}let t=n.current[L.current],r=le.current;t&&e(t),(W.current?e=>e():e=>me.request(e))(()=>{let i=n.current[L.current]||t;i&&(t||e(i),Se&&(r||!B.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});A(()=>{oe.current.orientation=v},[oe,v]),A(()=>{D||(R.current=null),(!D||m!==`auto`)&&(I.current=m)},[D,m]),A(()=>{a&&(D&&O?(L.current=o??-1,I.current&&o!=null&&(le.current=!0,V())):H.current&&(L.current=-1,V()))},[a,D,O,o,V]),A(()=>{if(a){if(!D){W.current=!1;return}if(O){if(r==null){if(W.current=!1,K.current!=null)return;if(H.current&&(L.current=-1,J()),(!ce.current||!H.current)&&I.current&&(R.current!=null||I.current===!0&&R.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>he.request(e):queueMicrotask)(t),e+=1):(L.current=R.current==null||Tt(R.current,y,f)||d?Ne(n):u(n),R.current=null,V())};t()}}else se(n.current,r)||(L.current=r,J(),le.current=!1)}}},[a,D,O,r,K,d,n,y,f,V,J,he]),A(()=>{if(!a||O||!F||p||!H.current)return;let e=F.nodesRef.current,t=e.find(e=>e.id===N)?.context?.elements.floating,n=Ze(Ie(ie??t??null)),r=e.some(e=>e.context&&X(e.context.elements.floating,n));t&&!r&&B.current&&t.focus({preventScroll:!0})},[a,O,ie,F,N,p]),A(()=>{ce.current=D,H.current=!!O});let ge=r!=null,ve=z(e=>{if(!de.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(L.current!==t||r!==t)&&(L.current=t,V(e))}),ye=z(()=>b??F?.nodesRef.current.find(e=>e.id===N)?.context?.dataRef?.current.orientation),be=z(()=>Ne(n,G.current)),xe=z(t=>{if(B.current=!1,W.current=!0,t.which===229||!de.current&&t.currentTarget===M.current)return;if(d&&Dt(t.key,v,f,te)){wt(t.key,ye())||P(t),e.setOpen(!1,q(we,t.nativeEvent));let n=C?.current??ie;Ce(n)&&n.focus();return}r!=null&&r!==L.current&&!se(n.current,r)&&(L.current=r);let i=L.current,a=Ne(n,_),o=u(n,_);if(j||(t.key===`Home`&&(P(t),L.current=a,V(t)),t.key===`End`&&(P(t),L.current=o,V(t))),T!=null){let e=T(t,L.current,n,v,l,f,_,a,o);if(e!=null&&e!==L.current&&(L.current=e,V(t)),v===`both`)return}if(wt(t.key,v)){P(t);let e=Ze(t.currentTarget.ownerDocument);if(D&&!p&&X(t.currentTarget,e)&&!n.current.some(t=>t!=null&&X(t,e))){L.current=Tt(t.key,v,f)?a:o,V(t),r===L.current&&J();return}let{index:s,wrapped:u}=ae(n.current,i,{decrement:!Tt(t.key,v,f),loopFocus:l,allowEscape:c,disabledIndices:_,minIndex:a,maxIndex:o});u&&(W.current=!1),L.current=s,V(t)}}),Se=Q.useMemo(()=>({onFocus(e){W.current=!0,ve(e)},onClick({currentTarget:e}){p||e.focus({preventScroll:!0})},onMouseMove(e){St(e)||(W.current=!0,le.current=!1,h&&ve(e))},onPointerLeave(e){if(!de.current||!B.current||e.pointerType===`touch`)return;W.current=!0;let t=e.relatedTarget;if(!(!h||n.current.includes(t))&&fe.current&&(ue.current?.(),ue.current=null,L.current=-1,V(e),!p)){let e=M.current,t=Ze(Ie(e));e&&X(e,t)&&e.focus({preventScroll:!0})}}}),[ve,de,M,h,n,V,fe,p]),Te=Q.useMemo(()=>p&&D&&ge&&{"aria-activedescendant":`${x}-${r}`},[p,D,ge,x,r]),Y=Q.useMemo(()=>({...j?{}:Te,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&D&&!p){let n=pe(t.nativeEvent);if(n&&!X(M.current,n))return;P(t);let r=q(_e,t.nativeEvent);e.setOpen(!1,r);let i=C?.current??ie;!r.isCanceled&&Ce(i)&&i.focus();return}xe(t)},onPointerMove(e){St(e)||(B.current=!0)}}),[Te,xe,M,j,e,D,p,ie,C]),Ee=Q.useMemo(()=>{function t(t){e.setOpen(!0,q(we,t.nativeEvent,t.currentTarget))}function n(e){m===`auto`&&E(e.nativeEvent)&&(I.current=!p)}function r(e){I.current=m,m===`auto`&&re(e.nativeEvent)&&(I.current=!0)}return{onKeyDown(n){let r=e.select(`open`);B.current=!1;let i=n.key.startsWith(`Arrow`),a=Et(n.key,ye(),f),o=wt(n.key,r?v:y),s=(d?a:o)||n.key===`Enter`||n.key.trim()===``;if(p&&r&&(!d||w(n.currentTarget)))return xe(n);if(!(!r&&!g&&i)){if(s){let e=wt(n.key,ye());R.current=d&&e?null:n.key}if(d){a&&(P(n),r?(L.current=be(),V(n),p&&M.current?.focus()):t(n));return}o&&(K.current!=null&&(L.current=K.current),P(n),!r&&g?t(n):xe(n),r&&V(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!p&&(L.current=-1,V(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[xe,m,be,d,V,e,g,v,y,ye,f,K,p,M]),De=Q.useMemo(()=>({...Te,...Ee}),[Te,Ee]);return Q.useMemo(()=>a?{reference:De,floating:Y,item:Se,trigger:Ee}:{},[a,De,Y,Ee,Se])}function kt(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=z(s),f=e.useState(`open`),p=ft(),m=Q.useRef(``),h=Q.useRef(u??i??-1),g=Q.useRef(null),_=z(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!oe(n)||n?.matches(`:disabled`)?!1:o==null||!x(I,e,o)}function c(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(!(!e[n]?.toLowerCase().startsWith(i)||!s(n)))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(P(e),d?.(!0)),m.current.length>0&&m.current[0]!==` `&&c(_,m.current)===-1&&e.key!==` `&&d?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(P(e),d?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&s(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,d?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=c(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,d?.(!1)):(a?.(b,e),g.current=b)}),v=z(t=>{let n=t.relatedTarget,r=e.select(`domReferenceElement`),i=e.select(`floatingElement`);X(r,n)||X(i,n)||(p.clear(),m.current=``,h.current=g.current,d?.(!1))});A(()=>{!f&&u!==null||(p.clear(),g.current=null,m.current!==``&&(m.current=``,d?.(!1)))},[f,u,p,d]);let y=Q.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return Q.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}function At({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=Q.useRef(e!==void 0),[a,o]=Q.useState(()=>t);return[i&&e!==void 0?e:a,Q.useCallback(e=>{i||o(e)},[])]}var $=t(),jt=Q.createContext(void 0);function Mt(e){let t=Q.useContext(jt);if(t===void 0&&!e)throw Error(ht(33));return t}var Nt=Q.createContext(void 0);function Pt(e){let t=Q.useContext(Nt);if(t===void 0&&!e)throw Error(ht(36));return t}var Ft=Q.createContext(void 0);function It(e=!0){let t=Q.useContext(Ft);if(t===void 0&&!e)throw Error(ht(25));return t}var Lt=Q.createContext(null);function Rt(e=`root`){let t=Q.useContext(Lt),n=Q.useContext(Nt);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var zt={visible:!0,ref:null};function Bt(){return zt}function Vt(e,t,n=`root`){let r=Rt(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??Bt)({label:e.label,children:e.children,render:e.render}),a=st(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}var Ht=Q.createContext(void 0);function Ut(){let e=Q.useContext(Ht);if(e===void 0)throw Error(ht(30));return e}function Wt(e){e.preventDefault()}function Gt(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=Pt(),u=It(!0),d=c.type===`submenu-trigger`,f=d?l.parentVirtualFocus:l.virtualFocus,p=(d&&l.parent.type===`menu`?l.parent.store:l.store).useState(`webkitAriaSelected`,n),{events:m}=a.useState(`floatingTreeRoot`),g=a.useState(`open`),_=u!==void 0,v=!f&&g&&n?0:-1;return Q.useMemo(()=>({id:r,role:`menuitem`,tabIndex:v,"aria-selected":p,onMouseDown:f?Wt:void 0,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&m.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&m.emit(`close`,{domEvent:e.nativeEvent,reason:at})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,_&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||_&&!ge&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!_||e.button===2)&&c.type===`regular-item`&&h(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,v,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,_,c.type,p,f])}var Kt={type:`regular-item`};function qt(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=Q.useRef(null),{getButtonProps:d,buttonRef:f}=L({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=Gt({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=Q.useCallback(e=>de(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=st(u,f);return Q.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Jt=Q.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function Yt(){return Q.useContext(Jt)}function Xt(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=Yt(),u=Q.useRef(-1),[d,f]=Q.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=Q.useRef(null),h=Q.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return A(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}var Zt=`data-checked`,Qt=`data-unchecked`,$t={checked(e){return e?{[Zt]:``}:{[Qt]:``}},...M},en=Q.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!1,checked:l=!1,onCheckedChange:u,style:d,...f}=e,{store:p}=Pt(),m=Xt({guess:!0,label:a}),h=Ve(i),g=p.useState(`disabled`),_=p.useState(`isActive`,m.index),v=p.useState(`floatingNodeId`),y=p.useState(`itemProps`),b=s||g,{getItemProps:x,itemRef:ee}=qt({closeOnClick:c,disabled:b,highlighted:_,id:h,store:p,nativeButton:o,nodeId:v,itemMetadata:Kt}),S=Q.useMemo(()=>({disabled:b,highlighted:_,checked:l}),[b,_,l]);function C(e){let t=q(at,e.nativeEvent,void 0,{preventUnmountOnClose:lt});u?.(!l,t)}let w=Y(`div`,e,{state:S,stateAttributesMapping:$t,props:[y,{role:`menuitemcheckbox`,"aria-checked":l,onClick:C},f,x],ref:[ee,t,m.ref]});return(0,$.jsx)(Ht.Provider,{value:S,children:w})}),tn=Q.forwardRef(function(e,t){let{checked:n,defaultChecked:r,onCheckedChange:i,...a}=e,[o,s]=At({controlled:n,default:r??!1,name:`MenuCheckboxItem`,state:`checked`}),c=Vt(e,t);function l(e,t){i?.(e,t),t.isCanceled||s(e)}return c.visible?(0,$.jsx)(en,{...a,checked:o,onCheckedChange:l,ref:c.ref}):null}),nn=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Ut(),c=Q.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=N(s.checked);T({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}});let f={checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l};return Y(`span`,e,{state:f,ref:[t,c],stateAttributesMapping:$t,props:{"aria-hidden":!0,...o},enabled:a||u})}),rn=Q.createContext(void 0);function an(){let e=Q.useContext(rn);if(e===void 0)throw Error(ht(31));return e}var on=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=Q.useState(void 0),c=Y(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,$.jsx)(rn.Provider,{value:s,children:c})}),sn=Q.forwardRef(function(e,t){let n=Rt()?.Group??on;return(0,$.jsx)(n,{...e,ref:t})}),cn=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Ve(a),c=an();return A(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),Y(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),ln=Q.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,{store:d}=Pt(),f=Xt({guess:!0,label:a}),p=Ve(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=qt({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:Kt});return Y(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),un=Q.forwardRef(function(e,t){let n=Vt(e,t);return n.visible?(0,$.jsx)(ln,{...e,ref:n.ref}):null}),dn=Q.createContext(void 0);function fn(){return Q.useContext(dn)}function pn(e,t){let n=Oe(e.render);if(Q.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function mn(e,t,n){let r=pn(e,t),i=r===t?void 0:r;return[r,Q.useCallback(e=>n?.(e?i:void 0),[i,n])]}function hn(e,t,n){let r=Oe(e.render),i=Q.isValidElement(r)?r.props:void 0,a=e[`aria-label`]??i?.[`aria-label`],o=e[`aria-labelledby`]??i?.[`aria-labelledby`];return o==null&&!a&&(o=t?t.id||void 0:n||void 0),o}var gn=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,id:o,initialFocus:s,...c}=e,{store:l,defaultFloatingId:u,setRenderedFloatingId:d,virtualFocus:f,orientation:p}=Pt(),m=fn(),{side:h,align:g}=Mt(),_=$e(!0)!=null,v=l.useState(`open`),y=l.useState(`transitionStatus`),b=l.useState(`popupProps`),x=l.useState(`mounted`),ee=l.useState(`instantType`),w=l.useState(`activeTriggerElement`),E=l.useState(`parent`),te=l.useState(`lastOpenChangeReason`),ne=l.useState(`rootId`),D=l.useState(`floatingRootContext`),O=l.useState(`floatingTreeRoot`),re=l.useState(`closeDelay`),ie=l.useState(`hoverEnabled`),ae=l.useState(`disabled`),oe=l.useState(`openMethod`),k=l.useState(`activeTriggerId`),A=l.useState(`listElement`),[se,j]=mn(e,u,d),M=hn(e,w,k),N=E.type===`menu`?m:void 0,P=E.type===`context-menu`,F=s??E.type!==`menu`;s===void 0&&A&&E.type!==`menu`&&(F=()=>l.state.activeIndex===null&&A),T({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),Q.useEffect(()=>{function e(e){l.setOpen(!1,q(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),G(D,{enabled:ie&&!ae&&!P&&E.type!==`menubar`,closeDelay:re});let I=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:L,handleFocus:R}=(Q.useContext(Lt)?.useParentHandoff??vn)(l,E,v,f),z={transitionStatus:y,side:h,align:g,open:v,nested:E.type===`menu`,instant:ee},B=Y(`div`,e,{state:z,ref:[t,l.context.popupRef,I,j],stateAttributesMapping:S,props:[b,{id:se,...A?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":M},onKeyDown(e){N?.onPopupKeyDown?.(e),_&&Be.has(e.key)&&e.stopPropagation()},onFocus:R},We(y),c,{"data-rootownerid":ne}]}),V=E.type===void 0||P;(w||E.type===`menubar`&&te!==`outside-press`)&&(V=!0);let H=N?.getReturnElement??L;return(0,$.jsx)(C,{context:D,openInteractionType:oe,modal:P,disabled:!x,returnFocus:a??H??V,explicitReturnFocus:a===void 0&&H?!1:void 0,initialFocus:F,restoreFocus:!0,getInsideElements:E.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:E.type===`menubar`?void 0:O,previousFocusableElement:w,nextFocusableElement:E.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:B})}),_n={parentVirtualFocusRef:void 0,handleFocus:void 0};function vn(){return _n}var yn=Q.forwardRef(function(e,t){let n=Rt()?.Popup??gn;return(0,$.jsx)(n,{...e,ref:t})}),bn=Q.createContext(void 0);function xn(){let e=Q.useContext(bn);if(e===void 0)throw Error(ht(32));return e}var Sn=Q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=Pt();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,$.jsx)(bn.Provider,{value:n,children:(0,$.jsx)(le,{ref:t,...r,portalOwnerRole:o})})});function Cn(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=z(i),[,o]=Q.useState(0),s=y(Tn).current,c=y(wn).current,l=Q.useRef(0),u=Q.useRef(!0),d=Q.useRef(null),f=Q.useRef(null),p=z(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=z((e,t)=>{c.set(e,t),p()}),h=z(e=>{c.delete(e),p()}),g=z(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!On(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&kn(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=Dn(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=z(()=>{let[e,t]=En(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});A(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),A(()=>{u.current&&v()}),A(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let b=z(e=>(s.add(e),()=>{s.delete(e)})),x=Q.useMemo(()=>({register:m,unregister:h,subscribeMapChange:b,nextIndexRef:l}),[m,h,b,l]);return(0,$.jsx)(Jt.Provider,{value:x,children:t})}function wn(){return new Map}function Tn(){return new Set}function En(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>kn(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function Dn(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function On(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function kn(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var An=Q.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=ue,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=Pt(),x=xn(),ee=It(!0),S=v.useState(`parent`),C=v.useState(`floatingRootContext`),w=v.useState(`floatingTreeRoot`),T=v.useState(`mounted`),E=v.useState(`open`),te=v.useState(`modal`),ne=v.useState(`openMethod`),D=v.useState(`activeTriggerElement`),O=v.useState(`transitionStatus`),re=v.useState(`positionerElement`),ie=v.useState(`instantType`),ae=v.useState(`adaptiveOrigin`),oe=v.useState(`lastOpenChangeReason`),k=v.useState(`floatingNodeId`),A=v.useState(`floatingParentNodeId`),se=C.useState(`domReferenceElement`),M=n,N=c,P=l,F=s,I=h;S.type===`context-menu`&&(M=n??S.context?.anchor,F??=`start`,!o&&F!==`center`&&(P=e.alignOffset??2,N=e.sideOffset??-5));let L=o,R=F;S.type===`menu`?(L??=`inline-end`,R??=`start`,I=e.collisionAvoidance??j):S.type===`menubar`&&(L??=S.context.orientation===`vertical`?`inline-end`:`bottom`,R??=`start`);let z=S.type===`context-menu`,B=fe({anchor:M,floatingRootContext:C,positionMethod:ee?`fixed`:r,mounted:T,side:L,sideOffset:N,align:R,alignOffset:P,arrowPadding:z?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:k,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:I,shift:z?{crossAxis:!(`side`in I&&I.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:w,adaptiveOrigin:ae,lazyFlip:y?`placement`:!1});Q.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===k&&v.set(`hoverEnabled`,!1),e.nodeId!==k&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,q(Ee)))}return w.events.on(`menuopenchange`,e),()=>{w.events.off(`menuopenchange`,e)}},[v,w.events,k]),Q.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,q(t))}return w.events.on(`menuopenchange`,e),()=>{w.events.off(`menuopenchange`,e)}},[w.events,v]);let H=ft();Q.useEffect(()=>{E||H.clear()},[E,H]),Q.useEffect(()=>{function e(e){if(!(!E||e.nodeId!==v.select(`floatingParentNodeId`))){if(e.target&&D&&D!==e.target){let e=v.select(`closeDelay`);e>0?H.isStarted()||H.start(e,()=>{v.setOpen(!1,q(Ee))}):v.setOpen(!1,q(Ee))}else H.clear()}}return w.events.on(`itemhover`,e),()=>{w.events.off(`itemhover`,e)}},[w.events,E,D,v,H]),Q.useEffect(()=>{let e={open:E,nodeId:k,parentNodeId:A,reason:v.select(`lastOpenChangeReason`)};w.events.emit(`menuopenchange`,e)},[w.events,E,v,k,A]),Ae({store:v,domReference:se,positionerElement:re,open:E});let ce={open:E,side:B.side,align:B.align,anchorHidden:B.anchorHidden,nested:S.type===`menu`,instant:ie},U=S.type===`menubar`&&S.context.modal;Z(E&&(U||te&&oe!==`trigger-hover`),ne===`touch`,re,D);let W=Xe(e,ce,{styles:B.positionerStyles,transitionStatus:O,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!T,inert:!E}),le=T&&S.type!==`menu`&&(S.type!==`menubar`&&te&&oe!==`trigger-hover`||S.type===`menubar`&&S.context.modal),G=null;return S.type===`menubar`?G=S.context.contentElement:S.type===void 0&&(G=D),(0,$.jsxs)(jt.Provider,{value:B,children:[le&&(0,$.jsx)(Se,{ref:S.type===`context-menu`||S.type===`nested-context-menu`?S.context.internalBackdropRef:null,inert:Ke(!E),cutout:G}),(0,$.jsx)(V,{id:k,children:(0,$.jsx)(Cn,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:W})})]})}),jn=Q.createContext(null);function Mn(e){let t=Q.useContext(jn);if(t===null&&!e)throw Error(ht(5));return t}function Nn(e){return e==null?Je:e.type.startsWith(`key`)?ye:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?ke:Je}var Pn={...he,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,keyboardOpen:e=>e.keyboardOpen,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,listElement:e=>e.listElement,triggerControlsId:(e,t)=>{let n=he.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>et&&e.inputFocused&&t?!0:void 0,highlightedItemId:e=>e.highlightedItem?.id||void 0,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType===`trigger-change`&&!he.open(e)?void 0:e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},Fn=class extends dt{constructor(e,t,n=!1){let r=new ct,i=Ln(r,t,n,e);super(i,In(r),Pn),this.observe(`parent`,e=>{e.type===`menu`?this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef:e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef)})}subscribeToParentMenu(){let e=this.state.parent;if(e.type!==`menu`)return;let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);return e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}setActiveIndex(e,t,n){if(this.state.activeIndex!==e){let r=(e===null?void 0:this.context.itemDomElements.current[e])===this.context.reportedItem;this.context.highlightReason=r?`none`:t,this.context.highlightEvent=r?void 0:n}this.set(`activeIndex`,e)}highlightItem(e,t,n){let r=this.context.itemDomElements.current.indexOf(e);r>-1&&this.setActiveIndex(r,t,n)}};function In(e){return{positionerRef:Q.createRef(),popupRef:Q.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:Q.createRef(),beforeTriggerFocusGuardRef:Q.createRef(),beforeContentFocusGuardRef:Q.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function Ln(e,t,n=!1,r){return{...mt(e,t,n),disabled:!1,modal:!0,openMethod:null,keyboardOpen:!1,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,listElement:null,filterTriggerProps:m,inputProps:m,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new te,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:m,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var Rn=Q.createContext(null);function zn(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function Bn(e,t){return e===`list-navigation`||zn(e,t)}var Vn=F(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:u=!0,orientation:f=`vertical`,actionsRef:p,closeParentOnEsc:h=!1,handle:b,triggerId:x,defaultTriggerId:S=null,highlightItemOnHover:C=!0,isSubmenu:w=!1,virtualFocus:T=!1,virtualFocusRef:E,allowEscape:te=!0,resetOnPointerLeave:D=!0}=e,re=It(!0),ae=Pt(!0),oe=Mn(!0),k=ae?.store,se=ae?.virtualFocus??!1,j=Q.useMemo(()=>w&&k?{type:`menu`,store:k}:oe?{type:`menubar`,context:oe}:re&&!k?{type:`context-menu`,context:re}:{type:void 0},[re,k,oe,w]),M=Ve(),N=Ve(),[P,F]=Q.useState(void 0),L=(P??N)||void 0,B=ne(),V=j.type===`menu`?j.store:void 0,H=(n??o)&&V?.state.transitionStatus===`starting`,ce=y(()=>H?V?.state.instantType:void 0).current,U=y(()=>{let e=new Fn({open:o,openProp:n,activeTriggerId:S,triggerIdProp:x,parent:j,disabled:s,highlightItemOnHover:C,modal:j.type===void 0?c:void 0,rootId:M,instantType:ce},L,B!=null);return e.context.virtualFocusRef=E,e}).current;U.useControlledProp(`openProp`,n),U.useControlledProp(`triggerIdProp`,x),U.useContextCallback(`onOpenChangeComplete`,i);let le=U.useState(`floatingTreeRoot`),ue=ee(le),G=U.useState(`open`),K=U.useState(`activeTriggerElement`),fe=U.useState(`positionerElement`),pe=U.useState(`hoverEnabled`),me=U.useState(`disabled`),he=U.useState(`lastOpenChangeReason`),J=U.useState(`parent`),ge=U.useState(`activeIndex`),_e=U.useState(`keyboardOpen`),ve=U.useState(`payload`),be=U.useState(`floatingParentNodeId`),xe=Q.useRef(null),Se=Q.useRef(J.type!==`context-menu`),Ce=ft(),we=Q.useRef(!0),Te=ft(),Y=be!=null,{openMethod:Ee,triggerProps:De}=Le(G);U.useSyncedValues({disabled:s,highlightItemOnHover:C,modal:J.type===void 0?c:void 0,openMethod:Ee,rootId:M}),l(U);let{forceUnmount:Oe,transitionStatus:ke}=Me(G,U,()=>{U.set(`allowMouseEnter`,!1)},H),Ae=O(U.context.popupRef);Q.useEffect(()=>{if(ce===void 0)return;let e=()=>{U.state.instantType===ce&&U.set(`instantType`,void 0)};if(!G){e();return}if(ke!==void 0)return;if(U.context.popupRef.current==null){e();return}let t=new AbortController;return Ae(e,t.signal),()=>{t.abort()}},[ce,G,ke,Ae,U]),A(()=>{re&&!ae?U.update({parent:{type:`context-menu`,context:re},floatingNodeId:ue,floatingParentNodeId:B}):(ae||!U.select(`activeTriggerElement`))&&U.update({floatingNodeId:ue,floatingParentNodeId:B})},[re,ae,ue,B,K,U]),Q.useEffect(()=>{if(G||(xe.current=null),J.type===`context-menu`){if(!G){Ce.clear(),Se.current=!1;return}Ce.start(500,()=>{Se.current=!0})}},[Ce,G,J.type]),A(()=>{!G&&!pe&&U.set(`hoverEnabled`,!0)},[G,pe,U]);let X=z((e,t)=>{let n=t.reason;if(!e&&!U.select(`open`)||G===e&&t.trigger===K&&he===n)return;let i=g(t);if(!e&&t.trigger==null&&(t.trigger=K??void 0),r?.(e,t),t.isCanceled)return;U.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!we.current)return;e&&n===`trigger-focus`?(we.current=!1,Te.start(300,()=>{we.current=!0})):(we.current=!0,Te.clear());let o=!e&&(n===`escape-key`||n==null);xe.current=t.event;let s=Pe(U.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&Bn(n,a),s.instantType=J.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:zn(n,a)?`click`:o?`dismiss`:void 0,U.update(s)}),je=gt({popupStore:U,floatingRootContext:U.state.floatingRootContext,floatingId:L,nested:B!=null,onOpenChange:X}),Ne=je.context.events;A(()=>{let e=({open:e,eventDetails:t})=>X(e,t);return Ne.on(`setOpen`,e),()=>{Ne?.off(`setOpen`,e)}},[Ne,X]),A(()=>U.subscribeToParentMenu(),[U]);let Fe=Q.useCallback(()=>{U.setOpen(!1,q(ze))},[U]);Q.useImperativeHandle(p,()=>({unmount:Oe,close:Fe}),[Oe,Fe]);let Ie;J.type===`context-menu`&&(Ie=J.context),Q.useImperativeHandle(Ie?.positionerRef,()=>fe,[fe]),Q.useImperativeHandle(Ie?.actionsRef,()=>({setOpen:X}),[X]);let Re=d(je,{enabled:!me,bubbles:{escapeKey:h&&J.type===`menu`},outsidePress(){return J.type!==`context-menu`||xe.current?.type===`contextmenu`||Se.current},externalTree:Y?le:void 0}),Be=_(),Z=Ot(je,{enabled:!me,listRef:U.context.itemDomElements,activeIndex:ge,virtual:T,nested:J.type===`menubar`||!T&&J.type!==void 0,parentOrientation:J.type===`menubar`?J.context.orientation:void 0,loopFocus:u,focusItemOnOpen:T?_e:void 0,allowEscape:T&&u&&te,orientation:f,triggerOrientation:T?`vertical`:f,rtl:Be===`rtl`,disabledIndices:I,onNavigate(e,t){U.setActiveIndex(e,Nn(t),t?.nativeEvent)},openOnArrowKeyDown:J.type!==`context-menu`&&!(T&&w),externalTree:!T&&Y?le:void 0,nestedReturnFocusRef:V?.context.virtualFocusRef,focusItemOnHover:C,resetOnPointerLeave:D}),He=Q.useCallback(e=>{U.context.typingRef.current=e},[U]),Ue=kt(je,{enabled:!me&&!T,listRef:U.context.itemLabels,elementsRef:U.context.itemDomElements,activeIndex:ge,resetMs:500,onMatch:(e,t)=>{G&&e!==ge&&U.setActiveIndex(e,ye,t.nativeEvent)},onTyping:He}),We=z(a),Ge=Q.useRef(-1),Ke=z(()=>{let e=U.state.activeIndex,t=e===null?void 0:U.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(Ge.current===n&&U.context.reportedItem===t)return;Ge.current=n,U.context.reportedItem=t,T&&U.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=U.context;U.context.highlightReason=Je,U.context.highlightEvent=void 0,a&&We(t,pt(r,i,{label:t===void 0?void 0:U.context.itemLabels.current[n]??void 0}))});A(()=>{Ke()},[ge,Ke]);let qe=Q.useMemo(()=>{if(!T)return Z.reference;if(!Z.trigger)return m;let{onFocus:e,...t}=Z.trigger;return t},[T,Z.reference,Z.trigger]);U.useSyncedValue(`inputProps`,T?Z.reference??m:m);let Ye=Q.useMemo(()=>{let e=de(Ue.reference,qe,Re.reference,{onMouseMove(){U.set(`allowMouseEnter`,!0)}},De);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=G,e},[U,Ue.reference,qe,Re.reference,De,G]),Xe=Q.useMemo(()=>{let e=de(Z.trigger,Re.trigger,De);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[Z.trigger,Re.trigger,De]);y(()=>(U.update({inactiveTriggerProps:Xe}),null));let Ze=Q.useMemo(()=>de(R,{onMouseMove(){U.set(`allowMouseEnter`,!0),J.type===`menu`&&U.set(`hoverEnabled`,!1)},onClick(){U.select(`hoverEnabled`)&&U.set(`hoverEnabled`,!1)},onKeyDown(e){let t=U.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Ue.floating,Z.floating,Re.floating),[J.type,U,Ue.floating,Z.floating,Re.floating]),Qe=Z.item??m;ie(U,{floatingRootContext:je,activeTriggerProps:Ye,inactiveTriggerProps:Xe,popupProps:Ze,itemProps:Qe});let $e=Q.useMemo(()=>({store:U,parent:j,orientation:f,loopFocus:u,allowEscape:te,defaultFloatingId:N,setRenderedFloatingId:F,virtualFocus:T,parentVirtualFocus:se,syncHighlightedItem:Ke}),[U,j,f,u,te,N,T,se,Ke]),et=typeof t==`function`?t({payload:ve}):t,tt=(0,$.jsxs)(Nt.Provider,{value:$e,children:[b&&(0,$.jsx)(v,{handle:b,store:U}),et]});return(J.type===void 0||J.type===`context-menu`)&&(tt=(0,$.jsx)(W,{externalTree:le,children:tt})),tt});function Hn(e){let t=Q.useContext(Rn);if(t===null)return(0,$.jsx)(Vn,{...e});let n=t.Root;return(0,$.jsx)(Rn.Provider,{value:null,children:(0,$.jsx)(n,{...t.options,...e})})}var Un=5;function Wn(e,t){let n=Gn(t);return e.clientX>=n.left-Un&&e.clientX<=n.right+Un&&e.clientY>=n.top-Un&&e.clientY<=n.bottom+Un}function Gn(e){let t=e.getBoundingClientRect(),n=it(e);if(Ge)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}function Kn(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=ut(),{ref:i,index:a}=Xt(e),o=n===a,s=Q.useRef(null),c=st(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function qn(e){let{render:t,className:n,style:r,state:i=m,props:a=I,refs:o=I,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=Kn({metadata:s});return Y(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function Jn(e){if(Ce(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!qe(e))return Jn(Re(e))}function Yn(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=Q.useRef(!1);return Q.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,Ie(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:m,[t,n,r])}var Xn=p(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,h=Pt(!0),g=ot(d)??h?.store;if(!g)throw Error(ht(85));let _=Ve(s),v=g.useState(`isTriggerActive`,_),y=g.useState(`floatingRootContext`),x=g.useState(`isOpenedByTrigger`,_),S=g.useState(`triggerControlsId`,_),C=Q.useRef(null),w=Qn(),T=ut(!0),E=Ye(),O=Q.useMemo(()=>E??new te,[E]),re=ee(O),ie=ne(),{registerTrigger:ae,isMountedByThisTrigger:oe}=b(_,C,g,{payload:f,closeDelay:u,parent:w,floatingTreeRoot:O,floatingNodeId:re,floatingParentNodeId:ie,keyboardEventRelay:T?.relayKeyboardEvent}),k=w.type===`menubar`,A=g.useState(`disabled`),se=a||A||k&&w.context.disabled,{getButtonProps:j,buttonRef:M}=L({disabled:se,native:o});Q.useEffect(()=>{!x&&w.type===void 0&&(g.context.allowMouseUpTriggerRef.current=!1)},[g,x,w.type]);let N=Q.useRef(null),P=ft(),F=z(e=>{if(!N.current)return;P.clear(),g.context.allowMouseUpTriggerRef.current=!1;let t=e.target;X(N.current,t)||X(g.select(`positionerElement`),t)||t===N.current||(t==null||Jn(t)!==g.select(`rootId`))&&(Wn(e,N.current)||O.events.emit(`close`,{domEvent:e,reason:me}))});Q.useEffect(()=>{let e=Ie(N.current);if(x&&g.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,F,{once:!0}),()=>{e.removeEventListener(`mouseup`,F)}},[x,F,g]);let I=k&&w.context.hasSubmenuOpen,R=Te(y,{enabled:(c??I)&&!se&&(!k||I&&!oe),handleClose:De({blockPointerEvents:!k}),mouseOnly:!0,move:!1,restMs:w.type===void 0?l:void 0,delay:{close:u},triggerElementRef:C,externalTree:O,isActiveTrigger:v,isClosing:()=>g.select(`transitionStatus`)===`ending`}),B=Zn(x,g.select(`lastOpenChangeReason`)),V=ce(y,{enabled:!se,event:x&&k?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:w.type===void 0&&B}),H=xt(y,{enabled:!se&&I}),U=Yn({open:x,enabled:k,mouseDownAction:`open`}),W=Q.useMemo(()=>de(H.reference,V.reference),[H.reference,V.reference]),le=g.useState(`triggerProps`,oe),ue=g.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:G,handleFocusTargetFocus:K}=tt(g,C),fe={disabled:se,open:x},pe=[N,t,M,ae,C],he=[W,R??m,le,{"aria-haspopup":`menu`,"aria-controls":S,id:_,onMouseDown:e=>{g.select(`open`)||(P.start(200,()=>{g.context.allowMouseUpTriggerRef.current=!0}),Ie(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},ue,k?{role:`menuitem`}:{},U,p,j],q=Y(`button`,e,{enabled:!k,stateAttributesMapping:D,state:fe,ref:pe,props:he});return k?(0,$.jsx)(qn,{tag:`button`,render:n,className:r,style:i,state:fe,refs:pe,props:he,stateAttributesMapping:D}):x?(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(rt,{ref:g.context.beforeTriggerFocusGuardRef,onFocus:G},`${_}-pre-focus-guard`),(0,$.jsx)(Q.Fragment,{children:q},_),(0,$.jsx)(rt,{ref:g.context.triggerFocusTargetRef,onFocus:K},`${_}-post-focus-guard`)]}):(0,$.jsx)(Q.Fragment,{children:q},_)});function Zn(e,t){let n=ft(),[r,i]=Q.useState(!1);return A(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function Qn(){let e=Mn(!0);return Q.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var $n=Q.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Y(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),er=(0,Q.createContext)(null);function tr({actionsRef:e,children:t,interactionOwner:n=`local`,onOpenChange:r,...i}){let a=(0,Q.useRef)(null),o=e??a;return k(()=>o.current?.close()),(0,$.jsx)(er.Provider,{value:{actionsRef:o,interactionOwner:n},children:(0,$.jsx)(Hn,{...i,actionsRef:o,onOpenChange:(e,t)=>{if(n===`host`&&!e&&t.reason===`escape-key`){t.cancel(),t.allowPropagation();return}r?.(e,t)},children:t})})}function nr(){let e=(0,Q.useContext)(er);if(!e)throw Error(`DropdownMenu parts must be used inside <DropdownMenu>`);return e}var rr=(0,Q.forwardRef)(function({className:e,render:t,type:n=`button`,...a},o){return(0,$.jsx)(Xn,{...a,className:t=>r(`btn caps-dropdown-trigger`,i(e,t)),ref:o,render:t,type:n})}),ir=(0,Q.forwardRef)(function({container:e,...t},n){let r=Fe(`popover`);return e==null&&r===null?null:(0,$.jsx)(Sn,{...t,container:e??r,ref:n})}),ar=(0,Q.forwardRef)(function({collisionBoundary:e,...t},n){let r=Fe(`popover`);return(0,$.jsx)(An,{...t,collisionBoundary:e??(r&&r!==document.body?r:void 0),ref:n})}),or=(0,Q.forwardRef)(function({className:e,finalFocus:t,...n},a){let{interactionOwner:o}=nr(),s=(0,Q.useRef)(null);(0,Q.useImperativeHandle)(a,()=>s.current);let c=J(`.caps-dropdown-item[data-highlighted]`),l=(0,Q.useCallback)(e=>{s.current=e,c(e)},[c]);return(0,$.jsx)(yn,{...n,className:t=>r(`caps-dropdown-popup min-w-40 rounded-box border border-base-300 bg-base-100 p-xs shadow-lg outline-none`,i(e,t)),finalFocus:o===`host`?!1:t??!0,ref:l})}),sr=(0,Q.forwardRef)(function({align:e=`end`,alignOffset:t,children:n,container:r,keepMounted:i,side:a=`bottom`,sideOffset:o=4,...s},c){return(0,$.jsx)(ir,{container:r,keepMounted:i,children:(0,$.jsx)(ar,{align:e,alignOffset:t,side:a,sideOffset:o,children:(0,$.jsx)(or,{...s,ref:c,children:n})})})}),cr=`caps-dropdown-item flex w-full items-center gap-sm rounded-field px-md py-sm text-left text-sm outline-none transition-colors hover:bg-base-200 focus-visible:bg-base-200 aria-[current=page]:bg-base-200 aria-[current=page]:font-semibold disabled:cursor-not-allowed disabled:text-base-content/40 data-disabled:cursor-not-allowed data-disabled:text-base-content/40`,lr=(0,Q.forwardRef)(function({className:e,onClick:t,onSelect:n,variant:a=`default`,...o},s){return(0,$.jsx)(un,{...o,className:t=>r(cr,a===`destructive`&&`text-error hover:bg-error hover:text-error-content focus-visible:bg-error focus-visible:text-error-content`,i(e,t)),onClick:e=>{t?.(e),e.defaultPrevented||n?.(e)},ref:s})}),ur=(0,Q.forwardRef)(function({children:e,className:t,onClick:n,onSelect:a,...o},s){return(0,$.jsxs)(tn,{...o,className:e=>r(cr,i(t,e)),onClick:e=>{n?.(e),e.defaultPrevented||a?.(e)},ref:s,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,$.jsx)(nn,{"aria-hidden":`true`,className:`shrink-0`,children:`✓`})]})}),dr=(0,Q.forwardRef)(function({className:e,...t},n){return(0,$.jsx)($n,{...t,className:t=>r(`my-xs h-px bg-base-300`,i(e,t)),ref:n})}),fr=sn,pr=(0,Q.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(cn,{...t,className:t=>r(`px-md pb-xs pt-sm text-xs font-semibold text-base-content/60`,i(e,t)),ref:n})});export{lr as a,rr as c,fr as i,yt as l,ur as n,pr as o,sr as r,dr as s,tr as t,vt as u};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,Vn as n,v as r,y as i}from"./button-oE2Hrd5D.js";import{l as a,u as o}from"./log-event-B3BGsDWO.js";import{$ as s,$t as c,A as l,At as u,B as d,Bt as f,C as p,Cn as m,Ct as h,D as g,Dt as _,E as v,En as y,F as b,Ft as x,G as ee,Gt as S,H as C,Ht as w,I as T,It as E,J as te,K as ne,Kt as D,L as O,Lt as re,M as ie,Mt as ae,Nt as oe,On as k,Ot as A,Pt as se,Q as j,Qt as M,R as N,Rt as P,S as F,Sn as I,St as L,T as R,Tn as z,Tt as B,U as V,Ut as H,V as ce,Vt as U,W,Y as le,Z as ue,_ as G,_n as de,_t as K,a as fe,an as pe,at as me,b as he,bt as q,c as J,cn as ge,ct as _e,dn as ve,dt as ye,en as be,et as xe,f as Se,fn as Ce,ft as we,g as Te,gn as Y,gt as Ee,h as De,hn as Oe,ht as ke,i as Ae,in as X,it as je,j as Me,jt as Ne,k as Pe,kn as Fe,kt as Ie,l as Le,ln as Re,lt as ze,m as Be,mn as Ve,n as Z,nn as He,nt as Ue,o as We,on as Ge,p as Ke,pn as qe,pt as Je,q as Ye,r as Xe,rn as Ze,rt as Qe,s as $e,sn as et,t as tt,tn as nt,tt as rt,un as it,ut as at,v as ot,vn as st,w as ct,wn as lt,wt as ut,x as dt,xn as ft,xt as pt,y as mt,yn as ht,z as gt,zt as _t}from"./useTriggerFocusGuards-Bddw7Qdn.js";function vt(e){return/\.mp4$/iu.test(e)}async function yt(e,t){if(vt(e.name)){let n=document.createElement(`video`);return n.preload=`metadata`,n.muted=!0,await new Promise((e,r)=>{n.addEventListener(`loadedmetadata`,()=>{e()},{once:!0}),n.addEventListener(`error`,()=>{r(Error(`MP4 metadata could not be read`))},{once:!0}),n.src=t}),{file:e,url:t,width:n.videoWidth,height:n.videoHeight}}if(o(e.name)){let n=new Audio;return n.preload=`metadata`,await new Promise((e,r)=>{n.addEventListener(`loadedmetadata`,()=>{e()},{once:!0}),n.addEventListener(`error`,()=>{r(Error(`MP3 metadata could not be read`))},{once:!0}),n.src=t}),{file:e,url:t,...a}}let n=new Image;return n.src=t,await n.decode(),{file:e,url:t,width:n.naturalWidth,height:n.naturalHeight}}var Q=e(n(),1),bt=ge&&et;function xt(e,t={}){let{enabled:n=!0,delay:r}=t,{events:i,dataRef:a}=e.context,o=Q.useRef(!1),s=Q.useRef(null),c=Q.useRef(!0),l=ft();Q.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=it(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&Ce(t)&&t===Ze(Ie(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return je(B(r,`blur`,i),bt&&B(r,`keydown`,a,!0),bt&&B(r,`pointerdown`,l,!0))},[e,n]),Q.useEffect(()=>{if(!n)return;function t(t){if(t.reason===`trigger-press`||t.reason===`escape-key`){let t=e.select(`domReferenceElement`);ve(t)&&(s.current=t,o.current=!0)}}return i.on(`openchange`,t),()=>{i.off(`openchange`,t)}},[i,n,e]);let u=Q.useMemo(()=>{function t(){o.current=!1,s.current=null}return{onMouseLeave(){t()},onFocus(n){let i=n.currentTarget;if(o.current){if(s.current===i)return;t()}let a=pe(n.nativeEvent);if(ve(a)){if(bt&&!n.relatedTarget){if(!c.current&&!w(a))return}else if(!H(a))return}let u=f(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:p}=n;if(e.select(`open`)&&u||!r){e.setOpen(!0,q(K,d,p));return}l.start(r,()=>{o.current||e.setOpen(!0,q(K,d,p))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=ve(r)&&r.hasAttribute(xe(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{let t=e.select(`domReferenceElement`),n=Ze(Ie(t));!r&&n===t||X(a.current.floatingContext?.refs.floating.current,n)||X(t,n)||o||f(r??n,e.context.triggerElements)||e.setOpen(!1,q(K,i))})}}},[a,r,e,l]);return Q.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}function St(e){return et&&e.movementX===0&&e.movementY===0}function Ct(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function wt(e,t){return Ct(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function Tt(e,t,n){return Ct(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function Et(e,t,n){return Ct(t,n?e===be:e===nt,e===c)}function Dt(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:Ct(t,n?e===nt:e===be,e===He)}function Ot(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:c=!1,loopFocus:l=!1,nested:d=!1,rtl:f=!1,virtual:p=!1,focusItemOnOpen:m=`auto`,focusItemOnHover:h=!0,openOnArrowKeyDown:g=!0,disabledIndices:_=void 0,orientation:v=`vertical`,triggerOrientation:y=v,parentOrientation:b,id:x,resetOnPointerLeave:ee=!0,externalTree:S,nestedReturnFocusRef:C,grid:T}=t,te=T!=null,D=e.useState(`open`),O=e.useState(`floatingElement`),ie=e.useState(`domReferenceElement`),oe=e.context.dataRef,k=_t(O),j=U(ie),M=Qe(k),N=ne(),F=Ye(S),I=Q.useRef(m),L=Q.useRef(o??-1),R=Q.useRef(null),B=Q.useRef(!0),V=z(e=>{i(L.current===-1?null:L.current,e)}),H=Q.useRef(!!O),ce=Q.useRef(D),W=Q.useRef(!1),le=Q.useRef(!1),ue=Q.useRef(null),G=Qe(_),de=Qe(D),K=Qe(o),fe=Qe(ee),me=Ue(),he=Ue(),J=z(()=>{me.cancel();function e(e){p||(ue.current=s(e,{sync:W.current,preventScroll:!0}))}let t=n.current[L.current],r=le.current;t&&e(t),(W.current?e=>e():e=>me.request(e))(()=>{let i=n.current[L.current]||t;i&&(t||e(i),Se&&(r||!B.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});A(()=>{oe.current.orientation=v},[oe,v]),A(()=>{D||(R.current=null),(!D||m!==`auto`)&&(I.current=m)},[D,m]),A(()=>{a&&(D&&O?(L.current=o??-1,I.current&&o!=null&&(le.current=!0,V())):H.current&&(L.current=-1,V()))},[a,D,O,o,V]),A(()=>{if(a){if(!D){W.current=!1;return}if(O){if(r==null){if(W.current=!1,K.current!=null)return;if(H.current&&(L.current=-1,J()),(!ce.current||!H.current)&&I.current&&(R.current!=null||I.current===!0&&R.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>he.request(e):queueMicrotask)(t),e+=1):(L.current=R.current==null||Tt(R.current,y,f)||d?Ne(n):u(n),R.current=null,V())};t()}}else se(n.current,r)||(L.current=r,J(),le.current=!1)}}},[a,D,O,r,K,d,n,y,f,V,J,he]),A(()=>{if(!a||O||!F||p||!H.current)return;let e=F.nodesRef.current,t=e.find(e=>e.id===N)?.context?.elements.floating,n=Ze(Ie(ie??t??null)),r=e.some(e=>e.context&&X(e.context.elements.floating,n));t&&!r&&B.current&&t.focus({preventScroll:!0})},[a,O,ie,F,N,p]),A(()=>{ce.current=D,H.current=!!O});let ge=r!=null,ve=z(e=>{if(!de.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(L.current!==t||r!==t)&&(L.current=t,V(e))}),ye=z(()=>b??F?.nodesRef.current.find(e=>e.id===N)?.context?.dataRef?.current.orientation),be=z(()=>Ne(n,G.current)),xe=z(t=>{if(B.current=!1,W.current=!0,t.which===229||!de.current&&t.currentTarget===M.current)return;if(d&&Dt(t.key,v,f,te)){wt(t.key,ye())||P(t),e.setOpen(!1,q(we,t.nativeEvent));let n=C?.current??ie;Ce(n)&&n.focus();return}r!=null&&r!==L.current&&!se(n.current,r)&&(L.current=r);let i=L.current,a=Ne(n,_),o=u(n,_);if(j||(t.key===`Home`&&(P(t),L.current=a,V(t)),t.key===`End`&&(P(t),L.current=o,V(t))),T!=null){let e=T(t,L.current,n,v,l,f,_,a,o);if(e!=null&&e!==L.current&&(L.current=e,V(t)),v===`both`)return}if(wt(t.key,v)){P(t);let e=Ze(t.currentTarget.ownerDocument);if(D&&!p&&X(t.currentTarget,e)&&!n.current.some(t=>t!=null&&X(t,e))){L.current=Tt(t.key,v,f)?a:o,V(t),r===L.current&&J();return}let{index:s,wrapped:u}=ae(n.current,i,{decrement:!Tt(t.key,v,f),loopFocus:l,allowEscape:c,disabledIndices:_,minIndex:a,maxIndex:o});u&&(W.current=!1),L.current=s,V(t)}}),Se=Q.useMemo(()=>({onFocus(e){W.current=!0,ve(e)},onClick({currentTarget:e}){p||e.focus({preventScroll:!0})},onMouseMove(e){St(e)||(W.current=!0,le.current=!1,h&&ve(e))},onPointerLeave(e){if(!de.current||!B.current||e.pointerType===`touch`)return;W.current=!0;let t=e.relatedTarget;if(!(!h||n.current.includes(t))&&fe.current&&(ue.current?.(),ue.current=null,L.current=-1,V(e),!p)){let e=M.current,t=Ze(Ie(e));e&&X(e,t)&&e.focus({preventScroll:!0})}}}),[ve,de,M,h,n,V,fe,p]),Te=Q.useMemo(()=>p&&D&&ge&&{"aria-activedescendant":`${x}-${r}`},[p,D,ge,x,r]),Y=Q.useMemo(()=>({...j?{}:Te,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&D&&!p){let n=pe(t.nativeEvent);if(n&&!X(M.current,n))return;P(t);let r=q(_e,t.nativeEvent);e.setOpen(!1,r);let i=C?.current??ie;!r.isCanceled&&Ce(i)&&i.focus();return}xe(t)},onPointerMove(e){St(e)||(B.current=!0)}}),[Te,xe,M,j,e,D,p,ie,C]),Ee=Q.useMemo(()=>{function t(t){e.setOpen(!0,q(we,t.nativeEvent,t.currentTarget))}function n(e){m===`auto`&&E(e.nativeEvent)&&(I.current=!p)}function r(e){I.current=m,m===`auto`&&re(e.nativeEvent)&&(I.current=!0)}return{onKeyDown(n){let r=e.select(`open`);B.current=!1;let i=n.key.startsWith(`Arrow`),a=Et(n.key,ye(),f),o=wt(n.key,r?v:y),s=(d?a:o)||n.key===`Enter`||n.key.trim()===``;if(p&&r&&(!d||w(n.currentTarget)))return xe(n);if(!(!r&&!g&&i)){if(s){let e=wt(n.key,ye());R.current=d&&e?null:n.key}if(d){a&&(P(n),r?(L.current=be(),V(n),p&&M.current?.focus()):t(n));return}o&&(K.current!=null&&(L.current=K.current),P(n),!r&&g?t(n):xe(n),r&&V(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!p&&(L.current=-1,V(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[xe,m,be,d,V,e,g,v,y,ye,f,K,p,M]),De=Q.useMemo(()=>({...Te,...Ee}),[Te,Ee]);return Q.useMemo(()=>a?{reference:De,floating:Y,item:Se,trigger:Ee}:{},[a,De,Y,Ee,Se])}function kt(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=z(s),f=e.useState(`open`),p=ft(),m=Q.useRef(``),h=Q.useRef(u??i??-1),g=Q.useRef(null),_=z(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!oe(n)||n?.matches(`:disabled`)?!1:o==null||!x(I,e,o)}function c(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(!(!e[n]?.toLowerCase().startsWith(i)||!s(n)))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(P(e),d?.(!0)),m.current.length>0&&m.current[0]!==` `&&c(_,m.current)===-1&&e.key!==` `&&d?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(P(e),d?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&s(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,d?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=c(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,d?.(!1)):(a?.(b,e),g.current=b)}),v=z(t=>{let n=t.relatedTarget,r=e.select(`domReferenceElement`),i=e.select(`floatingElement`);X(r,n)||X(i,n)||(p.clear(),m.current=``,h.current=g.current,d?.(!1))});A(()=>{!f&&u!==null||(p.clear(),g.current=null,m.current!==``&&(m.current=``,d?.(!1)))},[f,u,p,d]);let y=Q.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return Q.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}function At({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=Q.useRef(e!==void 0),[a,o]=Q.useState(()=>t);return[i&&e!==void 0?e:a,Q.useCallback(e=>{i||o(e)},[])]}var $=t(),jt=Q.createContext(void 0);function Mt(e){let t=Q.useContext(jt);if(t===void 0&&!e)throw Error(ht(33));return t}var Nt=Q.createContext(void 0);function Pt(e){let t=Q.useContext(Nt);if(t===void 0&&!e)throw Error(ht(36));return t}var Ft=Q.createContext(void 0);function It(e=!0){let t=Q.useContext(Ft);if(t===void 0&&!e)throw Error(ht(25));return t}var Lt=Q.createContext(null);function Rt(e=`root`){let t=Q.useContext(Lt),n=Q.useContext(Nt);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var zt={visible:!0,ref:null};function Bt(){return zt}function Vt(e,t,n=`root`){let r=Rt(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??Bt)({label:e.label,children:e.children,render:e.render}),a=st(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}var Ht=Q.createContext(void 0);function Ut(){let e=Q.useContext(Ht);if(e===void 0)throw Error(ht(30));return e}function Wt(e){e.preventDefault()}function Gt(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=Pt(),u=It(!0),d=c.type===`submenu-trigger`,f=d?l.parentVirtualFocus:l.virtualFocus,p=(d&&l.parent.type===`menu`?l.parent.store:l.store).useState(`webkitAriaSelected`,n),{events:m}=a.useState(`floatingTreeRoot`),g=a.useState(`open`),_=u!==void 0,v=!f&&g&&n?0:-1;return Q.useMemo(()=>({id:r,role:`menuitem`,tabIndex:v,"aria-selected":p,onMouseDown:f?Wt:void 0,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&m.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&m.emit(`close`,{domEvent:e.nativeEvent,reason:at})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,_&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||_&&!ge&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!_||e.button===2)&&c.type===`regular-item`&&h(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,v,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,_,c.type,p,f])}var Kt={type:`regular-item`};function qt(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=Q.useRef(null),{getButtonProps:d,buttonRef:f}=L({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=Gt({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=Q.useCallback(e=>de(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=st(u,f);return Q.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Jt=Q.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function Yt(){return Q.useContext(Jt)}function Xt(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=Yt(),u=Q.useRef(-1),[d,f]=Q.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=Q.useRef(null),h=Q.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return A(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}var Zt=`data-checked`,Qt=`data-unchecked`,$t={checked(e){return e?{[Zt]:``}:{[Qt]:``}},...M},en=Q.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!1,checked:l=!1,onCheckedChange:u,style:d,...f}=e,{store:p}=Pt(),m=Xt({guess:!0,label:a}),h=Ve(i),g=p.useState(`disabled`),_=p.useState(`isActive`,m.index),v=p.useState(`floatingNodeId`),y=p.useState(`itemProps`),b=s||g,{getItemProps:x,itemRef:ee}=qt({closeOnClick:c,disabled:b,highlighted:_,id:h,store:p,nativeButton:o,nodeId:v,itemMetadata:Kt}),S=Q.useMemo(()=>({disabled:b,highlighted:_,checked:l}),[b,_,l]);function C(e){let t=q(at,e.nativeEvent,void 0,{preventUnmountOnClose:lt});u?.(!l,t)}let w=Y(`div`,e,{state:S,stateAttributesMapping:$t,props:[y,{role:`menuitemcheckbox`,"aria-checked":l,onClick:C},f,x],ref:[ee,t,m.ref]});return(0,$.jsx)(Ht.Provider,{value:S,children:w})}),tn=Q.forwardRef(function(e,t){let{checked:n,defaultChecked:r,onCheckedChange:i,...a}=e,[o,s]=At({controlled:n,default:r??!1,name:`MenuCheckboxItem`,state:`checked`}),c=Vt(e,t);function l(e,t){i?.(e,t),t.isCanceled||s(e)}return c.visible?(0,$.jsx)(en,{...a,checked:o,onCheckedChange:l,ref:c.ref}):null}),nn=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Ut(),c=Q.useRef(null),{transitionStatus:l,mounted:u,setMounted:d}=N(s.checked);T({batch:!0,enabled:!s.checked,open:s.checked,ref:c,onComplete(){s.checked||d(!1)}});let f={checked:s.checked,disabled:s.disabled,highlighted:s.highlighted,transitionStatus:l};return Y(`span`,e,{state:f,ref:[t,c],stateAttributesMapping:$t,props:{"aria-hidden":!0,...o},enabled:a||u})}),rn=Q.createContext(void 0);function an(){let e=Q.useContext(rn);if(e===void 0)throw Error(ht(31));return e}var on=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=Q.useState(void 0),c=Y(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,$.jsx)(rn.Provider,{value:s,children:c})}),sn=Q.forwardRef(function(e,t){let n=Rt()?.Group??on;return(0,$.jsx)(n,{...e,ref:t})}),cn=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Ve(a),c=an();return A(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),Y(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),ln=Q.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,{store:d}=Pt(),f=Xt({guess:!0,label:a}),p=Ve(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=qt({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:Kt});return Y(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),un=Q.forwardRef(function(e,t){let n=Vt(e,t);return n.visible?(0,$.jsx)(ln,{...e,ref:n.ref}):null}),dn=Q.createContext(void 0);function fn(){return Q.useContext(dn)}function pn(e,t){let n=Oe(e.render);if(Q.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function mn(e,t,n){let r=pn(e,t),i=r===t?void 0:r;return[r,Q.useCallback(e=>n?.(e?i:void 0),[i,n])]}function hn(e,t,n){let r=Oe(e.render),i=Q.isValidElement(r)?r.props:void 0,a=e[`aria-label`]??i?.[`aria-label`],o=e[`aria-labelledby`]??i?.[`aria-labelledby`];return o==null&&!a&&(o=t?t.id||void 0:n||void 0),o}var gn=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,id:o,initialFocus:s,...c}=e,{store:l,defaultFloatingId:u,setRenderedFloatingId:d,virtualFocus:f,orientation:p}=Pt(),m=fn(),{side:h,align:g}=Mt(),_=$e(!0)!=null,v=l.useState(`open`),y=l.useState(`transitionStatus`),b=l.useState(`popupProps`),x=l.useState(`mounted`),ee=l.useState(`instantType`),w=l.useState(`activeTriggerElement`),E=l.useState(`parent`),te=l.useState(`lastOpenChangeReason`),ne=l.useState(`rootId`),D=l.useState(`floatingRootContext`),O=l.useState(`floatingTreeRoot`),re=l.useState(`closeDelay`),ie=l.useState(`hoverEnabled`),ae=l.useState(`disabled`),oe=l.useState(`openMethod`),k=l.useState(`activeTriggerId`),A=l.useState(`listElement`),[se,j]=mn(e,u,d),M=hn(e,w,k),N=E.type===`menu`?m:void 0,P=E.type===`context-menu`,F=s??E.type!==`menu`;s===void 0&&A&&E.type!==`menu`&&(F=()=>l.state.activeIndex===null&&A),T({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),Q.useEffect(()=>{function e(e){l.setOpen(!1,q(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),G(D,{enabled:ie&&!ae&&!P&&E.type!==`menubar`,closeDelay:re});let I=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:L,handleFocus:R}=(Q.useContext(Lt)?.useParentHandoff??vn)(l,E,v,f),z={transitionStatus:y,side:h,align:g,open:v,nested:E.type===`menu`,instant:ee},B=Y(`div`,e,{state:z,ref:[t,l.context.popupRef,I,j],stateAttributesMapping:S,props:[b,{id:se,...A?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":M},onKeyDown(e){N?.onPopupKeyDown?.(e),_&&Be.has(e.key)&&e.stopPropagation()},onFocus:R},We(y),c,{"data-rootownerid":ne}]}),V=E.type===void 0||P;(w||E.type===`menubar`&&te!==`outside-press`)&&(V=!0);let H=N?.getReturnElement??L;return(0,$.jsx)(C,{context:D,openInteractionType:oe,modal:P,disabled:!x,returnFocus:a??H??V,explicitReturnFocus:a===void 0&&H?!1:void 0,initialFocus:F,restoreFocus:!0,getInsideElements:E.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:E.type===`menubar`?void 0:O,previousFocusableElement:w,nextFocusableElement:E.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:B})}),_n={parentVirtualFocusRef:void 0,handleFocus:void 0};function vn(){return _n}var yn=Q.forwardRef(function(e,t){let n=Rt()?.Popup??gn;return(0,$.jsx)(n,{...e,ref:t})}),bn=Q.createContext(void 0);function xn(){let e=Q.useContext(bn);if(e===void 0)throw Error(ht(32));return e}var Sn=Q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=Pt();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,$.jsx)(bn.Provider,{value:n,children:(0,$.jsx)(le,{ref:t,...r,portalOwnerRole:o})})});function Cn(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=z(i),[,o]=Q.useState(0),s=y(Tn).current,c=y(wn).current,l=Q.useRef(0),u=Q.useRef(!0),d=Q.useRef(null),f=Q.useRef(null),p=z(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=z((e,t)=>{c.set(e,t),p()}),h=z(e=>{c.delete(e),p()}),g=z(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!On(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&kn(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=Dn(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=z(()=>{let[e,t]=En(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});A(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),A(()=>{u.current&&v()}),A(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let b=z(e=>(s.add(e),()=>{s.delete(e)})),x=Q.useMemo(()=>({register:m,unregister:h,subscribeMapChange:b,nextIndexRef:l}),[m,h,b,l]);return(0,$.jsx)(Jt.Provider,{value:x,children:t})}function wn(){return new Map}function Tn(){return new Set}function En(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>kn(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function Dn(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function On(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function kn(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var An=Q.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=ue,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=Pt(),x=xn(),ee=It(!0),S=v.useState(`parent`),C=v.useState(`floatingRootContext`),w=v.useState(`floatingTreeRoot`),T=v.useState(`mounted`),E=v.useState(`open`),te=v.useState(`modal`),ne=v.useState(`openMethod`),D=v.useState(`activeTriggerElement`),O=v.useState(`transitionStatus`),re=v.useState(`positionerElement`),ie=v.useState(`instantType`),ae=v.useState(`adaptiveOrigin`),oe=v.useState(`lastOpenChangeReason`),k=v.useState(`floatingNodeId`),A=v.useState(`floatingParentNodeId`),se=C.useState(`domReferenceElement`),M=n,N=c,P=l,F=s,I=h;S.type===`context-menu`&&(M=n??S.context?.anchor,F??=`start`,!o&&F!==`center`&&(P=e.alignOffset??2,N=e.sideOffset??-5));let L=o,R=F;S.type===`menu`?(L??=`inline-end`,R??=`start`,I=e.collisionAvoidance??j):S.type===`menubar`&&(L??=S.context.orientation===`vertical`?`inline-end`:`bottom`,R??=`start`);let z=S.type===`context-menu`,B=fe({anchor:M,floatingRootContext:C,positionMethod:ee?`fixed`:r,mounted:T,side:L,sideOffset:N,align:R,alignOffset:P,arrowPadding:z?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:k,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:I,shift:z?{crossAxis:!(`side`in I&&I.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:w,adaptiveOrigin:ae,lazyFlip:y?`placement`:!1});Q.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===k&&v.set(`hoverEnabled`,!1),e.nodeId!==k&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,q(Ee)))}return w.events.on(`menuopenchange`,e),()=>{w.events.off(`menuopenchange`,e)}},[v,w.events,k]),Q.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,q(t))}return w.events.on(`menuopenchange`,e),()=>{w.events.off(`menuopenchange`,e)}},[w.events,v]);let H=ft();Q.useEffect(()=>{E||H.clear()},[E,H]),Q.useEffect(()=>{function e(e){if(!(!E||e.nodeId!==v.select(`floatingParentNodeId`))){if(e.target&&D&&D!==e.target){let e=v.select(`closeDelay`);e>0?H.isStarted()||H.start(e,()=>{v.setOpen(!1,q(Ee))}):v.setOpen(!1,q(Ee))}else H.clear()}}return w.events.on(`itemhover`,e),()=>{w.events.off(`itemhover`,e)}},[w.events,E,D,v,H]),Q.useEffect(()=>{let e={open:E,nodeId:k,parentNodeId:A,reason:v.select(`lastOpenChangeReason`)};w.events.emit(`menuopenchange`,e)},[w.events,E,v,k,A]),Ae({store:v,domReference:se,positionerElement:re,open:E});let ce={open:E,side:B.side,align:B.align,anchorHidden:B.anchorHidden,nested:S.type===`menu`,instant:ie},U=S.type===`menubar`&&S.context.modal;Z(E&&(U||te&&oe!==`trigger-hover`),ne===`touch`,re,D);let W=Xe(e,ce,{styles:B.positionerStyles,transitionStatus:O,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!T,inert:!E}),le=T&&S.type!==`menu`&&(S.type!==`menubar`&&te&&oe!==`trigger-hover`||S.type===`menubar`&&S.context.modal),G=null;return S.type===`menubar`?G=S.context.contentElement:S.type===void 0&&(G=D),(0,$.jsxs)(jt.Provider,{value:B,children:[le&&(0,$.jsx)(Se,{ref:S.type===`context-menu`||S.type===`nested-context-menu`?S.context.internalBackdropRef:null,inert:Ke(!E),cutout:G}),(0,$.jsx)(V,{id:k,children:(0,$.jsx)(Cn,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:W})})]})}),jn=Q.createContext(null);function Mn(e){let t=Q.useContext(jn);if(t===null&&!e)throw Error(ht(5));return t}function Nn(e){return e==null?Je:e.type.startsWith(`key`)?ye:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?ke:Je}var Pn={...he,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,keyboardOpen:e=>e.keyboardOpen,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,listElement:e=>e.listElement,triggerControlsId:(e,t)=>{let n=he.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>et&&e.inputFocused&&t?!0:void 0,highlightedItemId:e=>e.highlightedItem?.id||void 0,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType===`trigger-change`&&!he.open(e)?void 0:e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},Fn=class extends dt{constructor(e,t,n=!1){let r=new ct,i=Ln(r,t,n,e);super(i,In(r),Pn),this.observe(`parent`,e=>{e.type===`menu`?this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef:e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef)})}subscribeToParentMenu(){let e=this.state.parent;if(e.type!==`menu`)return;let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);return e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}setActiveIndex(e,t,n){if(this.state.activeIndex!==e){let r=(e===null?void 0:this.context.itemDomElements.current[e])===this.context.reportedItem;this.context.highlightReason=r?`none`:t,this.context.highlightEvent=r?void 0:n}this.set(`activeIndex`,e)}highlightItem(e,t,n){let r=this.context.itemDomElements.current.indexOf(e);r>-1&&this.setActiveIndex(r,t,n)}};function In(e){return{positionerRef:Q.createRef(),popupRef:Q.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:Q.createRef(),beforeTriggerFocusGuardRef:Q.createRef(),beforeContentFocusGuardRef:Q.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function Ln(e,t,n=!1,r){return{...mt(e,t,n),disabled:!1,modal:!0,openMethod:null,keyboardOpen:!1,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,listElement:null,filterTriggerProps:m,inputProps:m,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new te,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:m,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var Rn=Q.createContext(null);function zn(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function Bn(e,t){return e===`list-navigation`||zn(e,t)}var Vn=F(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:u=!0,orientation:f=`vertical`,actionsRef:p,closeParentOnEsc:h=!1,handle:b,triggerId:x,defaultTriggerId:S=null,highlightItemOnHover:C=!0,isSubmenu:w=!1,virtualFocus:T=!1,virtualFocusRef:E,allowEscape:te=!0,resetOnPointerLeave:D=!0}=e,re=It(!0),ae=Pt(!0),oe=Mn(!0),k=ae?.store,se=ae?.virtualFocus??!1,j=Q.useMemo(()=>w&&k?{type:`menu`,store:k}:oe?{type:`menubar`,context:oe}:re&&!k?{type:`context-menu`,context:re}:{type:void 0},[re,k,oe,w]),M=Ve(),N=Ve(),[P,F]=Q.useState(void 0),L=(P??N)||void 0,B=ne(),V=j.type===`menu`?j.store:void 0,H=(n??o)&&V?.state.transitionStatus===`starting`,ce=y(()=>H?V?.state.instantType:void 0).current,U=y(()=>{let e=new Fn({open:o,openProp:n,activeTriggerId:S,triggerIdProp:x,parent:j,disabled:s,highlightItemOnHover:C,modal:j.type===void 0?c:void 0,rootId:M,instantType:ce},L,B!=null);return e.context.virtualFocusRef=E,e}).current;U.useControlledProp(`openProp`,n),U.useControlledProp(`triggerIdProp`,x),U.useContextCallback(`onOpenChangeComplete`,i);let le=U.useState(`floatingTreeRoot`),ue=ee(le),G=U.useState(`open`),K=U.useState(`activeTriggerElement`),fe=U.useState(`positionerElement`),pe=U.useState(`hoverEnabled`),me=U.useState(`disabled`),he=U.useState(`lastOpenChangeReason`),J=U.useState(`parent`),ge=U.useState(`activeIndex`),_e=U.useState(`keyboardOpen`),ve=U.useState(`payload`),be=U.useState(`floatingParentNodeId`),xe=Q.useRef(null),Se=Q.useRef(J.type!==`context-menu`),Ce=ft(),we=Q.useRef(!0),Te=ft(),Y=be!=null,{openMethod:Ee,triggerProps:De}=Le(G);U.useSyncedValues({disabled:s,highlightItemOnHover:C,modal:J.type===void 0?c:void 0,openMethod:Ee,rootId:M}),l(U);let{forceUnmount:Oe,transitionStatus:ke}=Me(G,U,()=>{U.set(`allowMouseEnter`,!1)},H),Ae=O(U.context.popupRef);Q.useEffect(()=>{if(ce===void 0)return;let e=()=>{U.state.instantType===ce&&U.set(`instantType`,void 0)};if(!G){e();return}if(ke!==void 0)return;if(U.context.popupRef.current==null){e();return}let t=new AbortController;return Ae(e,t.signal),()=>{t.abort()}},[ce,G,ke,Ae,U]),A(()=>{re&&!ae?U.update({parent:{type:`context-menu`,context:re},floatingNodeId:ue,floatingParentNodeId:B}):(ae||!U.select(`activeTriggerElement`))&&U.update({floatingNodeId:ue,floatingParentNodeId:B})},[re,ae,ue,B,K,U]),Q.useEffect(()=>{if(G||(xe.current=null),J.type===`context-menu`){if(!G){Ce.clear(),Se.current=!1;return}Ce.start(500,()=>{Se.current=!0})}},[Ce,G,J.type]),A(()=>{!G&&!pe&&U.set(`hoverEnabled`,!0)},[G,pe,U]);let X=z((e,t)=>{let n=t.reason;if(!e&&!U.select(`open`)||G===e&&t.trigger===K&&he===n)return;let i=g(t);if(!e&&t.trigger==null&&(t.trigger=K??void 0),r?.(e,t),t.isCanceled)return;U.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!we.current)return;e&&n===`trigger-focus`?(we.current=!1,Te.start(300,()=>{we.current=!0})):(we.current=!0,Te.clear());let o=!e&&(n===`escape-key`||n==null);xe.current=t.event;let s=Pe(U.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&Bn(n,a),s.instantType=J.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:zn(n,a)?`click`:o?`dismiss`:void 0,U.update(s)}),je=gt({popupStore:U,floatingRootContext:U.state.floatingRootContext,floatingId:L,nested:B!=null,onOpenChange:X}),Ne=je.context.events;A(()=>{let e=({open:e,eventDetails:t})=>X(e,t);return Ne.on(`setOpen`,e),()=>{Ne?.off(`setOpen`,e)}},[Ne,X]),A(()=>U.subscribeToParentMenu(),[U]);let Fe=Q.useCallback(()=>{U.setOpen(!1,q(ze))},[U]);Q.useImperativeHandle(p,()=>({unmount:Oe,close:Fe}),[Oe,Fe]);let Ie;J.type===`context-menu`&&(Ie=J.context),Q.useImperativeHandle(Ie?.positionerRef,()=>fe,[fe]),Q.useImperativeHandle(Ie?.actionsRef,()=>({setOpen:X}),[X]);let Re=d(je,{enabled:!me,bubbles:{escapeKey:h&&J.type===`menu`},outsidePress(){return J.type!==`context-menu`||xe.current?.type===`contextmenu`||Se.current},externalTree:Y?le:void 0}),Be=_(),Z=Ot(je,{enabled:!me,listRef:U.context.itemDomElements,activeIndex:ge,virtual:T,nested:J.type===`menubar`||!T&&J.type!==void 0,parentOrientation:J.type===`menubar`?J.context.orientation:void 0,loopFocus:u,focusItemOnOpen:T?_e:void 0,allowEscape:T&&u&&te,orientation:f,triggerOrientation:T?`vertical`:f,rtl:Be===`rtl`,disabledIndices:I,onNavigate(e,t){U.setActiveIndex(e,Nn(t),t?.nativeEvent)},openOnArrowKeyDown:J.type!==`context-menu`&&!(T&&w),externalTree:!T&&Y?le:void 0,nestedReturnFocusRef:V?.context.virtualFocusRef,focusItemOnHover:C,resetOnPointerLeave:D}),He=Q.useCallback(e=>{U.context.typingRef.current=e},[U]),Ue=kt(je,{enabled:!me&&!T,listRef:U.context.itemLabels,elementsRef:U.context.itemDomElements,activeIndex:ge,resetMs:500,onMatch:(e,t)=>{G&&e!==ge&&U.setActiveIndex(e,ye,t.nativeEvent)},onTyping:He}),We=z(a),Ge=Q.useRef(-1),Ke=z(()=>{let e=U.state.activeIndex,t=e===null?void 0:U.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(Ge.current===n&&U.context.reportedItem===t)return;Ge.current=n,U.context.reportedItem=t,T&&U.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=U.context;U.context.highlightReason=Je,U.context.highlightEvent=void 0,a&&We(t,pt(r,i,{label:t===void 0?void 0:U.context.itemLabels.current[n]??void 0}))});A(()=>{Ke()},[ge,Ke]);let qe=Q.useMemo(()=>{if(!T)return Z.reference;if(!Z.trigger)return m;let{onFocus:e,...t}=Z.trigger;return t},[T,Z.reference,Z.trigger]);U.useSyncedValue(`inputProps`,T?Z.reference??m:m);let Ye=Q.useMemo(()=>{let e=de(Ue.reference,qe,Re.reference,{onMouseMove(){U.set(`allowMouseEnter`,!0)}},De);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=G,e},[U,Ue.reference,qe,Re.reference,De,G]),Xe=Q.useMemo(()=>{let e=de(Z.trigger,Re.trigger,De);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[Z.trigger,Re.trigger,De]);y(()=>(U.update({inactiveTriggerProps:Xe}),null));let Ze=Q.useMemo(()=>de(R,{onMouseMove(){U.set(`allowMouseEnter`,!0),J.type===`menu`&&U.set(`hoverEnabled`,!1)},onClick(){U.select(`hoverEnabled`)&&U.set(`hoverEnabled`,!1)},onKeyDown(e){let t=U.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Ue.floating,Z.floating,Re.floating),[J.type,U,Ue.floating,Z.floating,Re.floating]),Qe=Z.item??m;ie(U,{floatingRootContext:je,activeTriggerProps:Ye,inactiveTriggerProps:Xe,popupProps:Ze,itemProps:Qe});let $e=Q.useMemo(()=>({store:U,parent:j,orientation:f,loopFocus:u,allowEscape:te,defaultFloatingId:N,setRenderedFloatingId:F,virtualFocus:T,parentVirtualFocus:se,syncHighlightedItem:Ke}),[U,j,f,u,te,N,T,se,Ke]),et=typeof t==`function`?t({payload:ve}):t,tt=(0,$.jsxs)(Nt.Provider,{value:$e,children:[b&&(0,$.jsx)(v,{handle:b,store:U}),et]});return(J.type===void 0||J.type===`context-menu`)&&(tt=(0,$.jsx)(W,{externalTree:le,children:tt})),tt});function Hn(e){let t=Q.useContext(Rn);if(t===null)return(0,$.jsx)(Vn,{...e});let n=t.Root;return(0,$.jsx)(Rn.Provider,{value:null,children:(0,$.jsx)(n,{...t.options,...e})})}var Un=5;function Wn(e,t){let n=Gn(t);return e.clientX>=n.left-Un&&e.clientX<=n.right+Un&&e.clientY>=n.top-Un&&e.clientY<=n.bottom+Un}function Gn(e){let t=e.getBoundingClientRect(),n=it(e);if(Ge)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}function Kn(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=ut(),{ref:i,index:a}=Xt(e),o=n===a,s=Q.useRef(null),c=st(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function qn(e){let{render:t,className:n,style:r,state:i=m,props:a=I,refs:o=I,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=Kn({metadata:s});return Y(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function Jn(e){if(Ce(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!qe(e))return Jn(Re(e))}function Yn(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=Q.useRef(!1);return Q.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,Ie(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:m,[t,n,r])}var Xn=p(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,h=Pt(!0),g=ot(d)??h?.store;if(!g)throw Error(ht(85));let _=Ve(s),v=g.useState(`isTriggerActive`,_),y=g.useState(`floatingRootContext`),x=g.useState(`isOpenedByTrigger`,_),S=g.useState(`triggerControlsId`,_),C=Q.useRef(null),w=Qn(),T=ut(!0),E=Ye(),O=Q.useMemo(()=>E??new te,[E]),re=ee(O),ie=ne(),{registerTrigger:ae,isMountedByThisTrigger:oe}=b(_,C,g,{payload:f,closeDelay:u,parent:w,floatingTreeRoot:O,floatingNodeId:re,floatingParentNodeId:ie,keyboardEventRelay:T?.relayKeyboardEvent}),k=w.type===`menubar`,A=g.useState(`disabled`),se=a||A||k&&w.context.disabled,{getButtonProps:j,buttonRef:M}=L({disabled:se,native:o});Q.useEffect(()=>{!x&&w.type===void 0&&(g.context.allowMouseUpTriggerRef.current=!1)},[g,x,w.type]);let N=Q.useRef(null),P=ft(),F=z(e=>{if(!N.current)return;P.clear(),g.context.allowMouseUpTriggerRef.current=!1;let t=e.target;X(N.current,t)||X(g.select(`positionerElement`),t)||t===N.current||(t==null||Jn(t)!==g.select(`rootId`))&&(Wn(e,N.current)||O.events.emit(`close`,{domEvent:e,reason:me}))});Q.useEffect(()=>{let e=Ie(N.current);if(x&&g.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,F,{once:!0}),()=>{e.removeEventListener(`mouseup`,F)}},[x,F,g]);let I=k&&w.context.hasSubmenuOpen,R=Te(y,{enabled:(c??I)&&!se&&(!k||I&&!oe),handleClose:De({blockPointerEvents:!k}),mouseOnly:!0,move:!1,restMs:w.type===void 0?l:void 0,delay:{close:u},triggerElementRef:C,externalTree:O,isActiveTrigger:v,isClosing:()=>g.select(`transitionStatus`)===`ending`}),B=Zn(x,g.select(`lastOpenChangeReason`)),V=ce(y,{enabled:!se,event:x&&k?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:w.type===void 0&&B}),H=xt(y,{enabled:!se&&I}),U=Yn({open:x,enabled:k,mouseDownAction:`open`}),W=Q.useMemo(()=>de(H.reference,V.reference),[H.reference,V.reference]),le=g.useState(`triggerProps`,oe),ue=g.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:G,handleFocusTargetFocus:K}=tt(g,C),fe={disabled:se,open:x},pe=[N,t,M,ae,C],he=[W,R??m,le,{"aria-haspopup":`menu`,"aria-controls":S,id:_,onMouseDown:e=>{g.select(`open`)||(P.start(200,()=>{g.context.allowMouseUpTriggerRef.current=!0}),Ie(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},ue,k?{role:`menuitem`}:{},U,p,j],q=Y(`button`,e,{enabled:!k,stateAttributesMapping:D,state:fe,ref:pe,props:he});return k?(0,$.jsx)(qn,{tag:`button`,render:n,className:r,style:i,state:fe,refs:pe,props:he,stateAttributesMapping:D}):x?(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(rt,{ref:g.context.beforeTriggerFocusGuardRef,onFocus:G},`${_}-pre-focus-guard`),(0,$.jsx)(Q.Fragment,{children:q},_),(0,$.jsx)(rt,{ref:g.context.triggerFocusTargetRef,onFocus:K},`${_}-post-focus-guard`)]}):(0,$.jsx)(Q.Fragment,{children:q},_)});function Zn(e,t){let n=ft(),[r,i]=Q.useState(!1);return A(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function Qn(){let e=Mn(!0);return Q.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var $n=Q.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Y(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),er=(0,Q.createContext)(null);function tr({actionsRef:e,children:t,interactionOwner:n=`local`,onOpenChange:r,...i}){let a=(0,Q.useRef)(null),o=e??a;return k(()=>o.current?.close()),(0,$.jsx)(er.Provider,{value:{actionsRef:o,interactionOwner:n},children:(0,$.jsx)(Hn,{...i,actionsRef:o,onOpenChange:(e,t)=>{if(n===`host`&&!e&&t.reason===`escape-key`){t.cancel(),t.allowPropagation();return}r?.(e,t)},children:t})})}function nr(){let e=(0,Q.useContext)(er);if(!e)throw Error(`DropdownMenu parts must be used inside <DropdownMenu>`);return e}var rr=(0,Q.forwardRef)(function({className:e,render:t,type:n=`button`,...a},o){return(0,$.jsx)(Xn,{...a,className:t=>r(`btn caps-dropdown-trigger`,i(e,t)),ref:o,render:t,type:n})}),ir=(0,Q.forwardRef)(function({container:e,...t},n){let r=Fe(`popover`);return e==null&&r===null?null:(0,$.jsx)(Sn,{...t,container:e??r,ref:n})}),ar=(0,Q.forwardRef)(function({collisionBoundary:e,...t},n){let r=Fe(`popover`);return(0,$.jsx)(An,{...t,collisionBoundary:e??(r&&r!==document.body?r:void 0),ref:n})}),or=(0,Q.forwardRef)(function({className:e,finalFocus:t,...n},a){let{interactionOwner:o}=nr(),s=(0,Q.useRef)(null);(0,Q.useImperativeHandle)(a,()=>s.current);let c=J(`.caps-dropdown-item[data-highlighted]`),l=(0,Q.useCallback)(e=>{s.current=e,c(e)},[c]);return(0,$.jsx)(yn,{...n,className:t=>r(`caps-dropdown-popup min-w-40 rounded-box border border-base-300 bg-base-100 p-xs shadow-lg outline-none`,i(e,t)),finalFocus:o===`host`?!1:t??!0,ref:l})}),sr=(0,Q.forwardRef)(function({align:e=`end`,alignOffset:t,children:n,container:r,keepMounted:i,side:a=`bottom`,sideOffset:o=4,...s},c){return(0,$.jsx)(ir,{container:r,keepMounted:i,children:(0,$.jsx)(ar,{align:e,alignOffset:t,side:a,sideOffset:o,children:(0,$.jsx)(or,{...s,ref:c,children:n})})})}),cr=`caps-dropdown-item flex w-full items-center gap-sm rounded-field px-md py-sm text-left text-sm outline-none transition-colors hover:bg-base-200 focus-visible:bg-base-200 aria-[current=page]:bg-base-200 aria-[current=page]:font-semibold disabled:cursor-not-allowed disabled:text-base-content/40 data-disabled:cursor-not-allowed data-disabled:text-base-content/40`,lr=(0,Q.forwardRef)(function({className:e,onClick:t,onSelect:n,variant:a=`default`,...o},s){return(0,$.jsx)(un,{...o,className:t=>r(cr,a===`destructive`&&`text-error hover:bg-error hover:text-error-content focus-visible:bg-error focus-visible:text-error-content`,i(e,t)),onClick:e=>{t?.(e),e.defaultPrevented||n?.(e)},ref:s})}),ur=(0,Q.forwardRef)(function({children:e,className:t,onClick:n,onSelect:a,...o},s){return(0,$.jsxs)(tn,{...o,className:e=>r(cr,i(t,e)),onClick:e=>{n?.(e),e.defaultPrevented||a?.(e)},ref:s,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,$.jsx)(nn,{"aria-hidden":`true`,className:`shrink-0`,children:`✓`})]})}),dr=(0,Q.forwardRef)(function({className:e,...t},n){return(0,$.jsx)($n,{...t,className:t=>r(`my-xs h-px bg-base-300`,i(e,t)),ref:n})}),fr=sn,pr=(0,Q.forwardRef)(function({className:e,...t},n){return(0,$.jsx)(cn,{...t,className:t=>r(`px-md pb-xs pt-sm text-xs font-semibold text-base-content/60`,i(e,t)),ref:n})});export{lr as a,rr as c,fr as i,yt as l,ur as n,pr as o,sr as r,dr as s,tr as t,vt as u};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,C as n,D as r,F as i,I as a,J as o,M as s,O as c,T as l,V as u,Vn as d,W as f,at as p,b as m,ct as h,d as g,it as _,l as ee,m as v,n as y,ot as b,v as x,w as S,x as C}from"./button-oE2Hrd5D.js";import{jt as w}from"./dist-Cc0qB3Mq.js";import{r as T,s as te}from"./log-event-R2fM9w5a.js";import{a as E,i as D,m as O,t as k}from"./query-CvXKo0g1.js";import{C as A,G as j,N as M,R as N,q as P,x as F}from"./audio-waveform-CKaaFNjh.js";import{c as ne,d as re,l as ie,n as ae,o as oe,s as se,t as ce}from"./textarea-LIOZDOK4.js";import{t as le}from"./keycap-D2RkH2IS.js";function ue(e,t){return P(e,O,t)}var de=C(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),fe=C(`ChevronUp`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),pe=C(`Cpu`,[[`rect`,{width:`16`,height:`16`,x:`4`,y:`4`,rx:`2`,key:`14l7u7`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,rx:`1`,key:`5aljv4`}],[`path`,{d:`M15 2v2`,key:`13l42r`}],[`path`,{d:`M15 20v2`,key:`15mkzm`}],[`path`,{d:`M2 15h2`,key:`1gxd5l`}],[`path`,{d:`M2 9h2`,key:`1bbxkp`}],[`path`,{d:`M20 15h2`,key:`19e6y8`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M9 2v2`,key:`165o2o`}],[`path`,{d:`M9 20v2`,key:`i2bqo8`}]]),me=C(`Maximize2`,[[`polyline`,{points:`15 3 21 3 21 9`,key:`mznyad`}],[`polyline`,{points:`9 21 3 21 3 15`,key:`1avn1i`}],[`line`,{x1:`21`,x2:`14`,y1:`3`,y2:`10`,key:`ota7mn`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),he=C(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ge={remove_background:`Remove background`,upscale:`Upscale`};function _e(e,t){return e.find(e=>e.transform?.operation===t)}function ve(e,t){let n=t.width*t.height/1e6;return(e.transform?.sizes??[]).map(({megapixels:e})=>({megapixels:e,disabledReason:n>=e?`This image is already ${n.toFixed(1)} MP.`:void 0}))}function ye(e,t){let n=e.transform?.source;if(n===void 0)return`${e.label} is not an image action.`;if(t.width*t.height>n.maxPixels)return`This image is over ${String(n.maxPixels/1e6)} MP, the most ${e.label} takes.`}function be(e,t,n){let r=e.transform;if(r===null)throw Error(`${e.id} is not an image action`);let i={computerId:t.computerId,path:t.path};if(r.operation===`upscale`){let t=n??r.defaultMegapixels;if(t===null)throw Error(`${e.id} needs an output size`);return{model:e.id,prompt:`${ge.upscale} to ${String(t)} MP`,references:[i],targetMegapixels:t}}return{model:e.id,prompt:ge[r.operation],references:[i]}}var xe=e=>{let t=e.lastIndexOf(`/`);return t<=0?`/`:e.slice(0,t)};function Se(e,t,n){let r=be(e,t,n),i={model:e.id,prompt:r.prompt,references:r.references??[],width:t.width,height:t.height},a=F(i,xe(t.path),e);return{input:{destination:{path:a},settings:r},draft:{...i,destination:a}}}var I=t,Ce=t.pipe(f(_(1024))),we=S(Ce).pipe(f(_(200)));u([a({operation:c(`read-notices`),computerId:I}),a({operation:c(`dismiss-notices`),computerId:I,keys:we})]);var Te=a({keys:we});async function Ee(e,t){return o(Te)(await e.require(j).request(JSON.stringify(t)))}u([a({operation:c(`read-folder`),computerId:I}),a({operation:c(`select-folder`),computerId:I,path:re})]);var De=a({path:re,configured:l});async function Oe(e,t){return o(De)(await e.require(j).request(JSON.stringify(t)))}var ke=2048,Ae=8e3,je=[{name:`Anime cel`,text:`Anime cel illustration with clean ink outlines, flat cel shading, and a limited palette of saturated colors. Soft painted backgrounds, expressive eyes, and crisp highlights, in the look of a hand-drawn animation frame.`},{name:`Cinematic film still`,text:`Cinematic film still shot on anamorphic lenses with shallow depth of field. Moody, motivated lighting, subtle film grain, and a considered color grade, composed like a frame from a feature film.`},{name:`Watercolor`,text:`Soft watercolor painting on textured paper, with translucent washes, visible pigment bleeds, and gentle color gradients. Loose brushwork, white paper left showing at the edges, and a calm, airy mood.`},{name:`Pixel art`,text:`Pixel art with a limited color palette, crisp square pixels, and no anti-aliasing. Clear readable silhouettes, dithered shading, and the charm of a classic 16-bit game sprite or scene.`},{name:`Product photo`,text:`Professional product photograph on a seamless studio background. Soft diffused lighting with gentle shadows, sharp focus across the subject, accurate colors, and clean, minimal composition suited to a catalog.`},{name:`Comic ink`,text:`Comic book panel with bold black ink linework, hatching and crosshatched shadows, and flat vivid colors. Dynamic angles, strong contrast, and a printed halftone texture.`}].map((e,t)=>({...e,id:-(t+1),builtIn:!0})),L=i.pipe(f(p(1)),f(_(64))),Me=i.pipe(f(p(1)),f(_(Ae))),R=t,Ne=a({id:r,name:L,text:Me,builtIn:l});u([a({operation:c(`list-styles`),computerId:R}),a({operation:c(`save-style`),computerId:R,id:h(r),name:L,text:Me}),a({operation:c(`delete-style`),computerId:R,id:r}),a({operation:c(`read-print-style`),computerId:R,path:t})]);var Pe=a({styles:S(Ne).pipe(f(_(50+je.length)))}),Fe=a({style:s(L)});function z(e,t){let n=t.trim();return e===void 0?n:`${e.trim()}\n\n${n}`}function Ie(e){return e?.maxPromptLength??ke}function Le(e,t,n,r=[]){if(e.length<=t)return;let i=`${String(e.length)} characters; this model accepts at most ${String(t)}.`,a=r.map(e=>`@${e}`).join(`, `);return n!==void 0&&a!==``?`The "${n}" style and your prompt with ${a} expanded total ${i}`:n===void 0?a===``?`The prompt is ${i}`:`Your prompt with ${a} expanded is ${i}`:`The "${n}" style and your prompt total ${i}`}var B=e=>e.require(j),V=e=>JSON.stringify(e),H=o(Pe);async function Re(e,t){return H(await B(e).request(V({operation:`list-styles`,computerId:t})))}async function ze(e,t,n){return H(await B(e).request(V({operation:`save-style`,computerId:t,id:n.id,name:n.name,text:n.text})))}async function Be(e,t,n){return H(await B(e).request(V({operation:`delete-style`,computerId:t,id:n})))}async function Ve(e,t,n){return o(Fe)(await B(e).request(V({operation:`read-print-style`,computerId:t,path:n})))}var U=/(?<![\p{L}\p{N}_@-])@image(\d+)(?![\p{L}\p{N}_-])/giu,W=e=>`image${String(e)}`;function G(e){let t=[];for(let n of e.matchAll(U)){let e=Number(n.at(1));t.includes(e)||t.push(e)}return t}var He=(e,t)=>JSON.stringify([e.computerId??t,e.path]),K={labels:new Map,next:1};function Ue(e,t,n){let r=G(n).length>0;if(t.length===0)return e.labels.size===0&&(e.next===1||r)?e:r?{labels:new Map,next:e.next}:K;let i=e.labels.size>0&&t.every(t=>!e.labels.has(t))?K:e,a=new Map,o=i.next;for(let e of t)a.has(e)||(a.set(e,i.labels.get(e)??o),i.labels.has(e)||(o+=1));return a.size===e.labels.size&&o===e.next&&[...a].every(([t,n])=>e.labels.get(t)===n)?e:{labels:a,next:o}}function We(e,t){return t.map(t=>e.labels.get(t)??0)}function Ge(e,t){let n=0;return e.map(e=>{if(t?.kind===`video`){if(e.role===`first-frame`)return`the first frame`;if(e.role===`last-frame`)return`the last frame`}return n+=1,`image ${String(n)}`})}function Ke(e,t,n){let r=[],i=e.replace(U,(e,i)=>{let a=t.indexOf(Number(i)),o=a<0?void 0:n.at(a);if(o===void 0){let t=W(Number(i));return r.includes(t)||r.push(t),e}return o});return r.length===0?{kind:`ready`,prompt:i}:{kind:`missing`,labels:r}}function qe(e,t){return e.replace(U,(e,n)=>{let r=t(Number(n));return r===void 0||r<1?e:`@${W(r)}`})}var Je=8,Ye=i.pipe(f(p(1)),f(_(32)),f(b(/^[\p{L}\p{N}_-]+$/u)),f(b(/^(?!image\d+$)/iu))),Xe=i.pipe(f(_(500))),Ze=t.pipe(f(_(4096))),Qe=S(a({path:Ze})).pipe(f(_(8))),$e=t,et=a({id:r,name:Ye,description:Xe,references:Qe});u([a({operation:c(`list-characters`),computerId:$e}),a({operation:c(`save-character`),computerId:$e,id:h(r),name:Ye,description:Xe,references:Qe}),a({operation:c(`delete-character`),computerId:$e,id:r})]);var tt=a({characters:S(et).pipe(f(_(50)))}),nt=(e,t)=>e.toLowerCase()===t.toLowerCase(),rt=/(?<![\p{L}\p{N}_@-])@([\p{L}\p{N}_-]+)/gu;function it(e){let t=[];for(let n of e.matchAll(rt)){let e=n.at(1);e!==void 0&&!t.some(t=>nt(t,e))&&t.push(e)}return t}function q(e,t){let n=[];return{prompt:e.replace(rt,(e,r)=>{let i=t.find(e=>nt(e.name,r));if(i===void 0)return e;let a=!n.includes(i);return a&&n.push(i),a&&i.description.trim()!==``?`${i.name} (${i.description.trim()})`:i.name}),characters:n}}function at(e,t,n){let r=e.trim();return z(t,q(r,n).prompt).length-r.length}function ot(e,t){let n=it(e),r=t.filter(e=>!n.some(t=>nt(t,e)));return r.length===0?e:`${r.map(e=>`@${e}`).join(` `)} ${e}`}function st(e,t,n){let r=(e,t)=>e.path===t&&(e.computerId===void 0||e.computerId===n),i=[...e];for(let e of t)for(let t of e.references)i.some(e=>r(e,t.path))||i.push({path:t.path});return i}function ct(e){return{kind:`ready`,prompt:e,references:[],characters:[]}}function lt(e){let t=ot(e.prompt,e.names??[]),n=q(t,e.saved),r=st(e.references,n.characters,e.computerId),i=(e.wording??(e=>Ge(e,void 0)))(r),a=Ke(t,e.labels??e.references.map((e,t)=>t+1),i.slice(0,e.references.length));if(a.kind===`missing`)return{kind:`refused`,message:`${a.labels.map(e=>`@${e}`).join(`, `)} ${a.labels.length===1?`names a reference that is`:`name references that are`} not attached. Remove ${a.labels.length===1?`it`:`them`} from the prompt or attach the image again.`};let o=r.length-e.references.length;if(e.model!==void 0&&o>0&&r.length>e.model.maxReferences){let t=n.characters.map(e=>e.name).join(`, `);return{kind:`refused`,message:e.model.maxReferences===0?`${e.model.label} does not take reference images, so it cannot use ${t}.`:`${t} add ${String(o)} reference ${o===1?`image`:`images`} to your ${String(e.references.length)}; ${e.model.label} accepts at most ${String(e.model.maxReferences)}.`}}return{kind:`ready`,prompt:q(a.prompt,e.saved).prompt,references:r,characters:n.characters}}function ut(e,t){let n=/(?<![\p{L}\p{N}_@-])@([\p{L}\p{N}_-]*)$/u.exec(e.slice(0,t));return n===null?null:{start:n.index,query:n.at(1)??``}}function dt(e,t,n){let r=n.toLowerCase(),i=e=>W(e.number).toLowerCase();return[...[...t.filter(e=>i(e).startsWith(r)),...t.filter(e=>!i(e).startsWith(r)&&i(e).includes(r))].map(e=>({kind:`reference`,reference:e})),...ft(e,n).map(e=>({kind:`character`,character:e}))]}function ft(e,t){let n=t.toLowerCase(),r=e=>e.name.toLowerCase();return[...e.filter(e=>r(e).startsWith(n)),...e.filter(e=>!r(e).startsWith(n)&&r(e).includes(n))].slice(0,Je)}var pt=e=>e.require(j),J=e=>JSON.stringify(e),mt=o(tt);async function ht(e,t){return mt(await pt(e).request(J({operation:`list-characters`,computerId:t})))}async function gt(e,t,n){return mt(await pt(e).request(J({operation:`save-character`,computerId:t,id:n.id,name:n.name,description:n.description,references:n.references})))}async function _t(e,t,n){return mt(await pt(e).request(J({operation:`delete-character`,computerId:t,id:n})))}var Y={models:e=>D.of(e,`prints`,`models`),folder:e=>D.of(e,`prints`,`folder`),dismissals:e=>D.of(e,`prints`,`dismissals`),styles:e=>D.of(e,`prints`,`styles`),printStyle:(e,t)=>D.of(e,`prints`,`print-style`,t),characters:e=>D.of(e,`prints`,`characters`)};function vt(e){return{...k(e,T,Y.models(e),async(t,n)=>{if(!e)throw Error(`Prints is disconnected`);let r=await te(e.capabilities);return n.throwIfAborted(),r}),enabled:!!(e?.context.get().computerId&&e.capabilities.has(T)),structuralSharing:!1}}function yt(e){let t=e?.context.get().computerId;return{...k(e,j,Y.folder(e),async(n,r)=>{if(!e||!t)throw Error(`No Computer selected`);let i=await Oe(e.capabilities,{operation:`read-folder`,computerId:t});if(r.throwIfAborted(),e.context.get().computerId!==t)throw new w(`Computer selection changed`,{code:`SELECTION_CHANGED`,retryable:!1});return i}),enabled:!!(t&&e.capabilities.has(j))}}function bt(e){let t=e?.context.get().computerId;return{...k(e,j,Y.dismissals(e),async(n,r)=>{if(!e||!t)throw Error(`No Computer selected`);let i=await Ee(e.capabilities,{operation:`read-notices`,computerId:t});return r.throwIfAborted(),i}),enabled:!!(t&&e.capabilities.has(j))}}function xt(e){let t=e?.context.get().computerId;return{...k(e,j,Y.styles(e),async(n,r)=>{if(!e||!t)throw Error(`No Computer selected`);let i=await Re(e.capabilities,t);return r.throwIfAborted(),i}),enabled:!!(t&&e.capabilities.has(j))}}function St(e,t){let n=e?.context.get().computerId;return{...k(e,j,Y.printStyle(e,t??``),async(r,i)=>{if(!e||!n||t===null)throw Error(`No print selected`);let a=await Ve(e.capabilities,n,t);return i.throwIfAborted(),a}),enabled:!!(n&&t!==null&&e.capabilities.has(j))}}function Ct(e){let t=e?.context.get().computerId;return{...k(e,j,Y.characters(e),async(n,r)=>{if(!e||!t)throw Error(`No Computer selected`);let i=await ht(e.capabilities,t);return r.throwIfAborted(),i}),enabled:!!(t&&e.capabilities.has(j))}}var X=e(d(),1),Z=n();function wt(e,t=/Mac|iPhone|iPad/u.test(globalThis.navigator.userAgent)){if(e.startsWith(`<leader>`)){let t=e.replaceAll(`<leader>`,`Ctrl K `).trimEnd();return e.endsWith(` `)?`${t} Space`:t}return e.split(` `).map(e=>e.split(`+`).map(e=>e===`mod`?t?`⌘`:`Ctrl`:e===`escape`?`Esc`:e.length===1?e.toUpperCase():e.charAt(0).toUpperCase()+e.slice(1)).join(e===`ctrl+k`||e===`mod+k`?` `:`+`)).join(` `)}function Tt(e){let t=new Map;for(let n of e.bindings)t.set(n.commandId,[...t.get(n.commandId)??[],wt(n.binding)]);return e.slash.map(e=>({alias:e.alias,commandId:e.commandId,command:e.command,title:e.title,description:e.description,category:e.category,order:e.order,grammar:e.arguments,consumesDraft:e.consumesDraft,keys:t.get(e.commandId)??[],availability:e.availability}))}function Et(e,t){let n=e.toLocaleLowerCase(),r=t.toLocaleLowerCase();if(r.length===0)return{tier:0,spread:0,indices:[]};let i=e=>Array.from({length:r.length},(t,n)=>e+n);if(n.startsWith(r))return{tier:0,spread:n.length-r.length,indices:i(0)};let a=n.search(RegExp(`[-_\\s]${r.replaceAll(/[.*+?^${}()|[\]\\]/gu,`\\$&`)}`,`u`));if(a>=0)return{tier:1,spread:a,indices:i(a+1)};let o=n.indexOf(r);if(o>=0)return{tier:2,spread:o,indices:i(o)};let s=[],c=0;for(let e of r){let t=n.indexOf(e,c);if(t<0)return;s.push(t),c=t+1}let l=s[0]??0;return{tier:3,spread:(s.at(-1)??0)-l-r.length+1,indices:s}}function Dt(e,t,n,r){return e.map(e=>({entry:e,match:Et(t(e),n)})).filter(e=>e.match!==void 0).sort((e,n)=>e.match.tier-n.match.tier||e.match.spread-n.match.spread||r(e.entry)-r(n.entry)||t(e.entry).localeCompare(t(n.entry))).map(({entry:e,match:t})=>({entry:e,indices:t.indices}))}var Q=[`help`,`login`,`model`];function Ot(e,t,n={}){if(!t.startsWith(`/`)||t.includes(`
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,C as n,D as r,F as i,I as a,J as o,M as s,O as c,T as l,V as u,Vn as d,W as f,at as p,b as m,ct as h,d as g,it as _,l as ee,m as v,n as y,ot as b,v as x,w as S,x as C}from"./button-oE2Hrd5D.js";import{Mt as w}from"./dist-DAokFn5x.js";import{r as T,s as te}from"./log-event-B3BGsDWO.js";import{a as E,i as D,m as O,t as k}from"./query-CYqgVHJ7.js";import{C as A,G as j,N as M,R as N,q as P,x as F}from"./audio-waveform-Be5wRu8s.js";import{c as ne,d as re,l as ie,n as ae,o as oe,s as se,t as ce}from"./textarea-LIOZDOK4.js";import{t as le}from"./keycap-D2RkH2IS.js";function ue(e,t){return P(e,O,t)}var de=C(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),fe=C(`ChevronUp`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),pe=C(`Cpu`,[[`rect`,{width:`16`,height:`16`,x:`4`,y:`4`,rx:`2`,key:`14l7u7`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,rx:`1`,key:`5aljv4`}],[`path`,{d:`M15 2v2`,key:`13l42r`}],[`path`,{d:`M15 20v2`,key:`15mkzm`}],[`path`,{d:`M2 15h2`,key:`1gxd5l`}],[`path`,{d:`M2 9h2`,key:`1bbxkp`}],[`path`,{d:`M20 15h2`,key:`19e6y8`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M9 2v2`,key:`165o2o`}],[`path`,{d:`M9 20v2`,key:`i2bqo8`}]]),me=C(`Maximize2`,[[`polyline`,{points:`15 3 21 3 21 9`,key:`mznyad`}],[`polyline`,{points:`9 21 3 21 3 15`,key:`1avn1i`}],[`line`,{x1:`21`,x2:`14`,y1:`3`,y2:`10`,key:`ota7mn`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),he=C(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ge={remove_background:`Remove background`,upscale:`Upscale`};function _e(e,t){return e.find(e=>e.transform?.operation===t)}function ve(e,t){let n=t.width*t.height/1e6;return(e.transform?.sizes??[]).map(({megapixels:e})=>({megapixels:e,disabledReason:n>=e?`This image is already ${n.toFixed(1)} MP.`:void 0}))}function ye(e,t){let n=e.transform?.source;if(n===void 0)return`${e.label} is not an image action.`;if(t.width*t.height>n.maxPixels)return`This image is over ${String(n.maxPixels/1e6)} MP, the most ${e.label} takes.`}function be(e,t,n){let r=e.transform;if(r===null)throw Error(`${e.id} is not an image action`);let i={computerId:t.computerId,path:t.path};if(r.operation===`upscale`){let t=n??r.defaultMegapixels;if(t===null)throw Error(`${e.id} needs an output size`);return{model:e.id,prompt:`${ge.upscale} to ${String(t)} MP`,references:[i],targetMegapixels:t}}return{model:e.id,prompt:ge[r.operation],references:[i]}}var xe=e=>{let t=e.lastIndexOf(`/`);return t<=0?`/`:e.slice(0,t)};function Se(e,t,n){let r=be(e,t,n),i={model:e.id,prompt:r.prompt,references:r.references??[],width:t.width,height:t.height},a=F(i,xe(t.path),e);return{input:{destination:{path:a},settings:r},draft:{...i,destination:a}}}var I=t,Ce=t.pipe(f(_(1024))),we=S(Ce).pipe(f(_(200)));u([a({operation:c(`read-notices`),computerId:I}),a({operation:c(`dismiss-notices`),computerId:I,keys:we})]);var Te=a({keys:we});async function Ee(e,t){return o(Te)(await e.require(j).request(JSON.stringify(t)))}u([a({operation:c(`read-folder`),computerId:I}),a({operation:c(`select-folder`),computerId:I,path:re})]);var De=a({path:re,configured:l});async function Oe(e,t){return o(De)(await e.require(j).request(JSON.stringify(t)))}var ke=2048,Ae=8e3,je=[{name:`Anime cel`,text:`Anime cel illustration with clean ink outlines, flat cel shading, and a limited palette of saturated colors. Soft painted backgrounds, expressive eyes, and crisp highlights, in the look of a hand-drawn animation frame.`},{name:`Cinematic film still`,text:`Cinematic film still shot on anamorphic lenses with shallow depth of field. Moody, motivated lighting, subtle film grain, and a considered color grade, composed like a frame from a feature film.`},{name:`Watercolor`,text:`Soft watercolor painting on textured paper, with translucent washes, visible pigment bleeds, and gentle color gradients. Loose brushwork, white paper left showing at the edges, and a calm, airy mood.`},{name:`Pixel art`,text:`Pixel art with a limited color palette, crisp square pixels, and no anti-aliasing. Clear readable silhouettes, dithered shading, and the charm of a classic 16-bit game sprite or scene.`},{name:`Product photo`,text:`Professional product photograph on a seamless studio background. Soft diffused lighting with gentle shadows, sharp focus across the subject, accurate colors, and clean, minimal composition suited to a catalog.`},{name:`Comic ink`,text:`Comic book panel with bold black ink linework, hatching and crosshatched shadows, and flat vivid colors. Dynamic angles, strong contrast, and a printed halftone texture.`}].map((e,t)=>({...e,id:-(t+1),builtIn:!0})),L=i.pipe(f(p(1)),f(_(64))),Me=i.pipe(f(p(1)),f(_(Ae))),R=t,Ne=a({id:r,name:L,text:Me,builtIn:l});u([a({operation:c(`list-styles`),computerId:R}),a({operation:c(`save-style`),computerId:R,id:h(r),name:L,text:Me}),a({operation:c(`delete-style`),computerId:R,id:r}),a({operation:c(`read-print-style`),computerId:R,path:t})]);var Pe=a({styles:S(Ne).pipe(f(_(50+je.length)))}),Fe=a({style:s(L)});function z(e,t){let n=t.trim();return e===void 0?n:`${e.trim()}\n\n${n}`}function Ie(e){return e?.maxPromptLength??ke}function Le(e,t,n,r=[]){if(e.length<=t)return;let i=`${String(e.length)} characters; this model accepts at most ${String(t)}.`,a=r.map(e=>`@${e}`).join(`, `);return n!==void 0&&a!==``?`The "${n}" style and your prompt with ${a} expanded total ${i}`:n===void 0?a===``?`The prompt is ${i}`:`Your prompt with ${a} expanded is ${i}`:`The "${n}" style and your prompt total ${i}`}var B=e=>e.require(j),V=e=>JSON.stringify(e),H=o(Pe);async function Re(e,t){return H(await B(e).request(V({operation:`list-styles`,computerId:t})))}async function ze(e,t,n){return H(await B(e).request(V({operation:`save-style`,computerId:t,id:n.id,name:n.name,text:n.text})))}async function Be(e,t,n){return H(await B(e).request(V({operation:`delete-style`,computerId:t,id:n})))}async function Ve(e,t,n){return o(Fe)(await B(e).request(V({operation:`read-print-style`,computerId:t,path:n})))}var U=/(?<![\p{L}\p{N}_@-])@image(\d+)(?![\p{L}\p{N}_-])/giu,W=e=>`image${String(e)}`;function G(e){let t=[];for(let n of e.matchAll(U)){let e=Number(n.at(1));t.includes(e)||t.push(e)}return t}var He=(e,t)=>JSON.stringify([e.computerId??t,e.path]),K={labels:new Map,next:1};function Ue(e,t,n){let r=G(n).length>0;if(t.length===0)return e.labels.size===0&&(e.next===1||r)?e:r?{labels:new Map,next:e.next}:K;let i=e.labels.size>0&&t.every(t=>!e.labels.has(t))?K:e,a=new Map,o=i.next;for(let e of t)a.has(e)||(a.set(e,i.labels.get(e)??o),i.labels.has(e)||(o+=1));return a.size===e.labels.size&&o===e.next&&[...a].every(([t,n])=>e.labels.get(t)===n)?e:{labels:a,next:o}}function We(e,t){return t.map(t=>e.labels.get(t)??0)}function Ge(e,t){let n=0;return e.map(e=>{if(t?.kind===`video`){if(e.role===`first-frame`)return`the first frame`;if(e.role===`last-frame`)return`the last frame`}return n+=1,`image ${String(n)}`})}function Ke(e,t,n){let r=[],i=e.replace(U,(e,i)=>{let a=t.indexOf(Number(i)),o=a<0?void 0:n.at(a);if(o===void 0){let t=W(Number(i));return r.includes(t)||r.push(t),e}return o});return r.length===0?{kind:`ready`,prompt:i}:{kind:`missing`,labels:r}}function qe(e,t){return e.replace(U,(e,n)=>{let r=t(Number(n));return r===void 0||r<1?e:`@${W(r)}`})}var Je=8,Ye=i.pipe(f(p(1)),f(_(32)),f(b(/^[\p{L}\p{N}_-]+$/u)),f(b(/^(?!image\d+$)/iu))),Xe=i.pipe(f(_(500))),Ze=t.pipe(f(_(4096))),Qe=S(a({path:Ze})).pipe(f(_(8))),$e=t,et=a({id:r,name:Ye,description:Xe,references:Qe});u([a({operation:c(`list-characters`),computerId:$e}),a({operation:c(`save-character`),computerId:$e,id:h(r),name:Ye,description:Xe,references:Qe}),a({operation:c(`delete-character`),computerId:$e,id:r})]);var tt=a({characters:S(et).pipe(f(_(50)))}),nt=(e,t)=>e.toLowerCase()===t.toLowerCase(),rt=/(?<![\p{L}\p{N}_@-])@([\p{L}\p{N}_-]+)/gu;function it(e){let t=[];for(let n of e.matchAll(rt)){let e=n.at(1);e!==void 0&&!t.some(t=>nt(t,e))&&t.push(e)}return t}function q(e,t){let n=[];return{prompt:e.replace(rt,(e,r)=>{let i=t.find(e=>nt(e.name,r));if(i===void 0)return e;let a=!n.includes(i);return a&&n.push(i),a&&i.description.trim()!==``?`${i.name} (${i.description.trim()})`:i.name}),characters:n}}function at(e,t,n){let r=e.trim();return z(t,q(r,n).prompt).length-r.length}function ot(e,t){let n=it(e),r=t.filter(e=>!n.some(t=>nt(t,e)));return r.length===0?e:`${r.map(e=>`@${e}`).join(` `)} ${e}`}function st(e,t,n){let r=(e,t)=>e.path===t&&(e.computerId===void 0||e.computerId===n),i=[...e];for(let e of t)for(let t of e.references)i.some(e=>r(e,t.path))||i.push({path:t.path});return i}function ct(e){return{kind:`ready`,prompt:e,references:[],characters:[]}}function lt(e){let t=ot(e.prompt,e.names??[]),n=q(t,e.saved),r=st(e.references,n.characters,e.computerId),i=(e.wording??(e=>Ge(e,void 0)))(r),a=Ke(t,e.labels??e.references.map((e,t)=>t+1),i.slice(0,e.references.length));if(a.kind===`missing`)return{kind:`refused`,message:`${a.labels.map(e=>`@${e}`).join(`, `)} ${a.labels.length===1?`names a reference that is`:`name references that are`} not attached. Remove ${a.labels.length===1?`it`:`them`} from the prompt or attach the image again.`};let o=r.length-e.references.length;if(e.model!==void 0&&o>0&&r.length>e.model.maxReferences){let t=n.characters.map(e=>e.name).join(`, `);return{kind:`refused`,message:e.model.maxReferences===0?`${e.model.label} does not take reference images, so it cannot use ${t}.`:`${t} add ${String(o)} reference ${o===1?`image`:`images`} to your ${String(e.references.length)}; ${e.model.label} accepts at most ${String(e.model.maxReferences)}.`}}return{kind:`ready`,prompt:q(a.prompt,e.saved).prompt,references:r,characters:n.characters}}function ut(e,t){let n=/(?<![\p{L}\p{N}_@-])@([\p{L}\p{N}_-]*)$/u.exec(e.slice(0,t));return n===null?null:{start:n.index,query:n.at(1)??``}}function dt(e,t,n){let r=n.toLowerCase(),i=e=>W(e.number).toLowerCase();return[...[...t.filter(e=>i(e).startsWith(r)),...t.filter(e=>!i(e).startsWith(r)&&i(e).includes(r))].map(e=>({kind:`reference`,reference:e})),...ft(e,n).map(e=>({kind:`character`,character:e}))]}function ft(e,t){let n=t.toLowerCase(),r=e=>e.name.toLowerCase();return[...e.filter(e=>r(e).startsWith(n)),...e.filter(e=>!r(e).startsWith(n)&&r(e).includes(n))].slice(0,Je)}var pt=e=>e.require(j),J=e=>JSON.stringify(e),mt=o(tt);async function ht(e,t){return mt(await pt(e).request(J({operation:`list-characters`,computerId:t})))}async function gt(e,t,n){return mt(await pt(e).request(J({operation:`save-character`,computerId:t,id:n.id,name:n.name,description:n.description,references:n.references})))}async function _t(e,t,n){return mt(await pt(e).request(J({operation:`delete-character`,computerId:t,id:n})))}var Y={models:e=>D.of(e,`prints`,`models`),folder:e=>D.of(e,`prints`,`folder`),dismissals:e=>D.of(e,`prints`,`dismissals`),styles:e=>D.of(e,`prints`,`styles`),printStyle:(e,t)=>D.of(e,`prints`,`print-style`,t),characters:e=>D.of(e,`prints`,`characters`)};function vt(e){return{...k(e,T,Y.models(e),async(t,n)=>{if(!e)throw Error(`Prints is disconnected`);let r=await te(e.capabilities);return n.throwIfAborted(),r}),enabled:!!(e?.context.get().computerId&&e.capabilities.has(T)),structuralSharing:!1}}function yt(e){let t=e?.context.get().computerId;return{...k(e,j,Y.folder(e),async(n,r)=>{if(!e||!t)throw Error(`No Computer selected`);let i=await Oe(e.capabilities,{operation:`read-folder`,computerId:t});if(r.throwIfAborted(),e.context.get().computerId!==t)throw new w(`Computer selection changed`,{code:`SELECTION_CHANGED`,retryable:!1});return i}),enabled:!!(t&&e.capabilities.has(j))}}function bt(e){let t=e?.context.get().computerId;return{...k(e,j,Y.dismissals(e),async(n,r)=>{if(!e||!t)throw Error(`No Computer selected`);let i=await Ee(e.capabilities,{operation:`read-notices`,computerId:t});return r.throwIfAborted(),i}),enabled:!!(t&&e.capabilities.has(j))}}function xt(e){let t=e?.context.get().computerId;return{...k(e,j,Y.styles(e),async(n,r)=>{if(!e||!t)throw Error(`No Computer selected`);let i=await Re(e.capabilities,t);return r.throwIfAborted(),i}),enabled:!!(t&&e.capabilities.has(j))}}function St(e,t){let n=e?.context.get().computerId;return{...k(e,j,Y.printStyle(e,t??``),async(r,i)=>{if(!e||!n||t===null)throw Error(`No print selected`);let a=await Ve(e.capabilities,n,t);return i.throwIfAborted(),a}),enabled:!!(n&&t!==null&&e.capabilities.has(j))}}function Ct(e){let t=e?.context.get().computerId;return{...k(e,j,Y.characters(e),async(n,r)=>{if(!e||!t)throw Error(`No Computer selected`);let i=await ht(e.capabilities,t);return r.throwIfAborted(),i}),enabled:!!(t&&e.capabilities.has(j))}}var X=e(d(),1),Z=n();function wt(e,t=/Mac|iPhone|iPad/u.test(globalThis.navigator.userAgent)){if(e.startsWith(`<leader>`)){let t=e.replaceAll(`<leader>`,`Ctrl K `).trimEnd();return e.endsWith(` `)?`${t} Space`:t}return e.split(` `).map(e=>e.split(`+`).map(e=>e===`mod`?t?`⌘`:`Ctrl`:e===`escape`?`Esc`:e.length===1?e.toUpperCase():e.charAt(0).toUpperCase()+e.slice(1)).join(e===`ctrl+k`||e===`mod+k`?` `:`+`)).join(` `)}function Tt(e){let t=new Map;for(let n of e.bindings)t.set(n.commandId,[...t.get(n.commandId)??[],wt(n.binding)]);return e.slash.map(e=>({alias:e.alias,commandId:e.commandId,command:e.command,title:e.title,description:e.description,category:e.category,order:e.order,grammar:e.arguments,consumesDraft:e.consumesDraft,keys:t.get(e.commandId)??[],availability:e.availability}))}function Et(e,t){let n=e.toLocaleLowerCase(),r=t.toLocaleLowerCase();if(r.length===0)return{tier:0,spread:0,indices:[]};let i=e=>Array.from({length:r.length},(t,n)=>e+n);if(n.startsWith(r))return{tier:0,spread:n.length-r.length,indices:i(0)};let a=n.search(RegExp(`[-_\\s]${r.replaceAll(/[.*+?^${}()|[\]\\]/gu,`\\$&`)}`,`u`));if(a>=0)return{tier:1,spread:a,indices:i(a+1)};let o=n.indexOf(r);if(o>=0)return{tier:2,spread:o,indices:i(o)};let s=[],c=0;for(let e of r){let t=n.indexOf(e,c);if(t<0)return;s.push(t),c=t+1}let l=s[0]??0;return{tier:3,spread:(s.at(-1)??0)-l-r.length+1,indices:s}}function Dt(e,t,n,r){return e.map(e=>({entry:e,match:Et(t(e),n)})).filter(e=>e.match!==void 0).sort((e,n)=>e.match.tier-n.match.tier||e.match.spread-n.match.spread||r(e.entry)-r(n.entry)||t(e.entry).localeCompare(t(n.entry))).map(({entry:e,match:t})=>({entry:e,indices:t.indices}))}var Q=[`help`,`login`,`model`];function Ot(e,t,n={}){if(!t.startsWith(`/`)||t.includes(`
|
|
2
2
|
`))return{kind:`none`};let r=t.search(/\s/u);if(r<0){let r=t.slice(1);return{kind:`commands`,query:r,items:Dt(e.filter(e=>e.availability.status===`available`&&(r.length===0?e.category===(n.idleCategory??`Conversation`)||Q.includes(e.alias):e.category!==`Advanced`||e.alias.toLocaleLowerCase().startsWith(r.toLocaleLowerCase()))),e=>e.alias,r,e=>{let t=Q.indexOf(e.alias);return r.length===0&&t>=0?t-Q.length:e.order}).map(({entry:e,indices:t})=>({command:e,label:`/${e.alias}`,matches:t.map(e=>e+1),insert:e.grammar===void 0?`/${e.alias}`:`/${e.alias} `}))}}let i=t.slice(1,r),a=e.find(e=>e.alias===i);if(a?.grammar===void 0||a.availability.status!==`available`)return{kind:`none`};let o=t.slice(r).trimStart(),s=(o.includes(` `)?[]:a.grammar.words??[]).filter(e=>e.word.toLocaleLowerCase().startsWith(o.toLocaleLowerCase())).map(e=>({word:e,label:e.word,matches:Array.from({length:o.length},(e,t)=>t),insert:`/${i} ${e.word}`}));return{kind:`arguments`,command:a,query:o,hint:`/${i} ${a.grammar.hint}`,items:s}}function kt(e,t){return e.animate(t.reduced?[{opacity:1},{opacity:0}]:[{opacity:1,transform:`none`},{opacity:0,transform:`translateY(-120%)`}],{duration:t.reduced?t.fast:t.normal,easing:g(t,t.easeExit),fill:`backwards`})}function At(e,t){let n=-12*Math.min(1.5,t.bounce/.3);return e.animate(t.reduced?[{opacity:0},{opacity:1}]:[{opacity:0,transform:`translateY(70%)`},{opacity:1,transform:`translateY(${String(n)}%)`,offset:.6},{opacity:1,transform:`none`}],{duration:t.reduced?t.fast:t.springDuration,easing:g(t,t.ease),fill:`backwards`})}function jt(e,t,n){return e.animate([{opacity:1-n},{opacity:n}],{duration:t.reduced?t.fast:t.normal,delay:n===1&&!t.reduced?t.fast/2:0,easing:g(t,t.ease),fill:`backwards`})}function Mt(e,t){let n=1+.05*Math.min(1.5,.4+t.bounce/.3);return e.animate([{transform:`scale(1)`},{transform:`scale(${String(n)})`,offset:.4},{transform:`scale(1)`}],{duration:t.springDuration,easing:g(t,`ease-out`)})}var Nt=(0,X.forwardRef)(function({state:e,onStop:t,stopLabel:n=`Stop`,iconSize:r=20,onClick:i,disabled:a,className:o,tone:s=`primary`,"aria-label":c,...l},u){let d=(0,X.useRef)(null);(0,X.useImperativeHandle)(u,()=>d.current);let f=(0,X.useRef)(e);(0,X.useLayoutEffect)(()=>{let t=d.current,n=f.current;if(f.current=e,!t||n===e||!ee(t))return;let r=t.querySelector(`[data-glyph="arrow"]`),i=t.querySelector(`[data-glyph="busy"]`);if(!r||!i)return;let a=v(t),o=[];return e===`busy`?o.push(kt(r,a),jt(i,a,1)):n===`busy`&&o.push(jt(i,a,0),At(r,a)),n===`empty`&&e===`ready`&&!a.reduced&&o.push(Mt(t,a)),()=>{for(let e of o)e.cancel()}},[e]);let p=e===`busy`,m=p&&t!==void 0;return(0,Z.jsx)(le,{...l,ref:d,className:x(`caps-send-action`,o),tone:s,"aria-busy":p?!0:void 0,"aria-label":m?n:c,"data-send-state":e,disabled:a===!0||e===`empty`||p&&!m,onClick:m?t:i,label:null,icon:(0,Z.jsxs)(`span`,{className:`caps-send-glyph`,"data-state":e,children:[(0,Z.jsx)(`span`,{"data-glyph":`arrow`,children:(0,Z.jsx)(de,{"aria-hidden":`true`,size:r})}),(0,Z.jsx)(`span`,{"data-glyph":`busy`,children:t===void 0?(0,Z.jsx)(y,{decorative:!0,size:`sm`}):(0,Z.jsx)(he,{"aria-hidden":`true`,fill:`currentColor`,size:Math.round(r*.7)})})]})})}),Pt=new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`,minimumFractionDigits:2,maximumFractionDigits:2}),Ft=new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`,minimumFractionDigits:2,maximumFractionDigits:5});function It(e,t){if(!Number.isFinite(e))throw RangeError(`Money amount must be finite`);let n=e!==0&&Math.abs(e)<.01;return n&&(t?.precision!==`exact`||Math.abs(e)<1e-5)?e<0?`>-$0.01`:`<$0.01`:n?Ft.format(e):Pt.format(e)}function Lt(e,t){return`${e}-${String(t)}`}function Rt(e){switch(e.key){case`ArrowDown`:return`next`;case`ArrowUp`:return`previous`;case`Enter`:return e.shiftKey?null:`accept`;case`Tab`:return`accept`;case`Escape`:return`dismiss`;default:return null}}function zt(e){return{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":e.open,"aria-controls":e.open?e.listId:void 0,"aria-activedescendant":e.open?Lt(e.listId,e.selected):void 0}}function Bt({open:e,rows:t,selected:n,listId:r,label:i,kind:a,hint:o,empty:s,onHighlight:c,onChoose:l}){return(0,Z.jsx)(oe,{open:e,side:`top`,"data-parakeet-slash":``,children:(0,Z.jsxs)(`div`,{className:`parakeet-slash-menu`,"data-kind":a,children:[o===void 0?null:(0,Z.jsx)(`p`,{className:`parakeet-slash-hint`,children:o}),t.length===0?s===void 0?null:(0,Z.jsx)(`p`,{className:`parakeet-slash-hint`,children:s}):(0,Z.jsx)(`div`,{id:r,role:`listbox`,"aria-label":i,children:t.map((e,t)=>(0,Z.jsxs)(ne,{id:Lt(r,t),active:t===n,"aria-disabled":e.disabled===!0||void 0,"data-disabled":e.disabled===!0,onMouseEnter:()=>{c(t)},onClick:()=>{l(t)},children:[e.media===void 0?null:(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`parakeet-slash-media`,children:e.media}),(0,Z.jsx)(`span`,{className:`parakeet-slash-label`,children:e.label}),(0,Z.jsx)(`span`,{className:`parakeet-slash-detail`,children:e.detail}),e.keys===void 0||e.keys.length===0?null:(0,Z.jsx)(`kbd`,{className:`parakeet-slash-keys`,children:e.keys})]},e.key))})]})})}var Vt=(0,X.forwardRef)(function({className:e,density:t=`regular`,...n},r){return(0,Z.jsx)(`ul`,{...n,className:x(`list`,t===`compact`&&`list-sm`,e),ref:r})}),Ht=(0,X.forwardRef)(function({className:e,...t},n){return(0,Z.jsx)(`li`,{...t,className:x(`list-row`,e),ref:n})});(0,X.forwardRef)(function({className:e,icon:t,label:n,children:r,...i},a){return(0,Z.jsxs)(`li`,{...i,className:x(`list-row caps-fact`,e),ref:a,children:[(0,Z.jsxs)(`span`,{className:`caps-fact-label`,children:[t?(0,Z.jsx)(`span`,{className:`caps-fact-icon`,"aria-hidden":`true`,children:t}):null,n]}),(0,Z.jsx)(`span`,{className:`caps-fact-value`,children:r})]})});var Ut=(0,X.forwardRef)(function({aside:e,children:t,className:n,level:r=2,...i},a){return(0,Z.jsxs)(r===3?`h3`:`h2`,{...i,className:x(`caps-data-list-heading`,n),ref:a,children:[(0,Z.jsx)(`span`,{children:t}),e===void 0?null:(0,Z.jsx)(`span`,{className:`caps-data-list-heading-aside`,children:e})]})}),Wt=m(`card caps-card`,{variants:{variant:{surface:`caps-card-surface`,outline:`caps-card-outline`,interactive:`caps-card-interactive`,game:`caps-card-game caps-card-interactive`,fit:`caps-card-fit`},density:{regular:``,compact:`caps-card-compact`}},defaultVariants:{variant:`surface`,density:`regular`}}),Gt=(0,X.forwardRef)(function({className:e,density:t,featured:n=!1,state:r,variant:i,...a},o){return(0,Z.jsx)(`div`,{...a,className:x(Wt({density:t,variant:i}),n&&`caps-card-featured`,e),"data-state":r,ref:o})});(0,X.forwardRef)(function({className:e,density:t,variant:n,width:r=`default`,...i},a){return(0,Z.jsx)(`main`,{className:`caps-centered-card-stage`,children:(0,Z.jsx)(Gt,{...i,className:x(`caps-centered-card`,r===`wide`&&`caps-centered-card-wide`,e),ref:a,variant:n??`surface`,...t?{density:t}:{}})})}),(0,X.forwardRef)(function({alignment:e=`start`,className:t,...n},r){return(0,Z.jsx)(`div`,{...n,className:x(`caps-card-header`,e===`center`&&`caps-card-header-centered`,t),ref:r})}),(0,X.forwardRef)(function({className:e,level:t=3,...n},r){return(0,Z.jsx)(t===2?`h2`:`h3`,{...n,className:x(`caps-card-title`,e),ref:r})}),(0,X.forwardRef)(function({className:e,...t},n){return(0,Z.jsx)(`p`,{...t,className:x(`caps-card-description`,e),ref:n})}),(0,X.forwardRef)(function({className:e,...t},n){return(0,Z.jsx)(`div`,{...t,className:x(`caps-card-content`,e),ref:n})}),(0,X.forwardRef)(function({className:e,...t},n){return(0,Z.jsx)(`div`,{...t,className:x(`caps-card-footer`,e),ref:n})});var Kt=(0,X.forwardRef)(function({action:e,attachments:t,className:n,input:r,toolbar:i,...a},o){return(0,Z.jsxs)(`div`,{...a,ref:o,className:x(`caps-composer`,n),children:[t===void 0?null:(0,Z.jsx)(`div`,{className:`caps-composer-attachments`,children:t}),(0,Z.jsx)(`div`,{className:`caps-composer-input`,children:r}),i===void 0&&e===void 0?null:(0,Z.jsxs)(`div`,{className:`caps-composer-bar`,children:[(0,Z.jsx)(`div`,{className:`caps-composer-toolbar`,children:i}),e]})]})});function qt({draft:e,hasAttachments:t=!1,busy:n,queueWhileBusy:r=!1,blocked:i=!1}){let a=!i&&(e.trim().length>0||t);return n&&(!r||!a)?`busy`:a?`ready`:`empty`}function Jt({attachments:e,action:t,children:n,className:r,input:i,menu:a,row:o,...s}){return(0,Z.jsxs)(se,{className:`parakeet-composer-anchor`,children:[a,(0,Z.jsxs)(Gt,{...s,className:x(`parakeet-composer-shell`,r),children:[(0,Z.jsx)(Kt,{action:t,attachments:e,input:i,toolbar:o===void 0?void 0:(0,Z.jsx)(ae,{className:`parakeet-composer-row`,align:`start`,items:o.items,openId:o.openId,onOpenChange:o.onOpenChange,renderTrigger:({children:e,...t})=>(0,Z.jsx)(le,{...t,label:e,expanded:t[`aria-expanded`]===!0}),leading:o.controls,trailing:(0,Z.jsxs)(`span`,{className:`parakeet-composer-trailing`,children:[o.status,o.readout==null?null:(0,Z.jsx)(`span`,{className:`parakeet-composer-readout`,children:o.readout}),(0,Z.jsx)(`span`,{className:`parakeet-composer-action`,children:o.action})]})})}),n]})]})}var Yt=1e5;function Xt(e){return!Number.isFinite(e)||e<=0?null:It(e/Yt)}var Zt=`prints-prompt-counter`;function Qt({busy:e,disabled:t,disabledReason:n,draft:r,label:i,onGenerate:a,promptOver:o}){return(0,Z.jsx)(Nt,{"aria-describedby":o?Zt:void 0,"aria-label":i,className:`prints-generate`,"data-generation-submit":!0,disabled:t||o,onClick:a,state:qt({draft:r,busy:e}),title:(t||o)&&n?n:i})}function $({addedLength:e,length:t,maxLength:n}){return`${String(t)} / ${String(n)} characters. This model accepts up to ${String(n)}; shorten the prompt${e>0?` or its style and characters`:``} by ${String(t-n)} or pick another model.`}var $t=.8;function en(e){let t=window.getComputedStyle(e),n=Number.parseFloat(t.lineHeight);return(Number.isFinite(n)?n:26)+Number.parseFloat(t.paddingTop)+Number.parseFloat(t.paddingBottom)}function tn({caretRequest:e,layout:t,onOverflow:n,onOver:r,disabled:i,maxLength:a,addedLength:o=0,menu:s,mentionCount:c,onCaret:l,onChange:u,onMentionDismiss:d,onMentionMove:f,onMentionPick:p,onSend:m,onSlashMove:h,onSlashPick:g,placeholder:_,slashCount:ee,value:v}){let y=(0,X.useRef)(null),b=(0,X.useRef)(v),[x,S]=(0,X.useState)([]),[C,w]=(0,X.useState)(-1),[T,te]=(0,X.useState)(!1),E=(0,X.useRef)(!1),D=(0,X.useRef)(!1);b.current=v,(0,X.useLayoutEffect)(()=>{if(T||i||!D.current)return;D.current=!1;let e=y.current;e&&e.ownerDocument.activeElement===e.ownerDocument.body&&e.focus({preventScroll:!0})},[i,T]),(0,X.useLayoutEffect)(()=>{let t=y.current;!t||e?.value!==v||(t.setSelectionRange(e.caret,e.caret),t.focus({preventScroll:!0}))},[e,v]);let{cap:O,collapsed:k,fullscreen:A}=t;(0,X.useLayoutEffect)(()=>{let e=y.current;if(!e)return;if(A){e.style.height=``,n(!1);return}e.style.height=`auto`;let t=e.scrollHeight;e.style.height=`${String(k?en(e):Math.min(t,O))}px`,n(!k&&t>O+1),k&&(e.scrollTop=0),k&&t>e.clientHeight+1?e.setAttribute(`data-clipped`,``):e.removeAttribute(`data-clipped`)},[v,O,k,A,n]),(0,X.useLayoutEffect)(()=>{let e=y.current;!e||!A||(e.setSelectionRange(e.value.length,e.value.length),e.scrollTop=e.scrollHeight)},[A]);let j=(0,X.useCallback)(async()=>{let e=b.current.trim();if(!(!e||i||E.current)){if(a!==void 0&&e.length+o>a){r($({addedLength:o,length:e.length+o,maxLength:a}));return}D.current=y.current===y.current?.ownerDocument.activeElement,E.current=!0,te(!0);try{if(!await m())return;S(t=>t.at(-1)===e?t:[...t,e].slice(-20)),w(-1)}finally{E.current=!1,te(!1)}}},[i,a,r,m,o]),M=v.trim().length,N=M>0?M+o:0,P=a!==void 0&&N>a,F=a!==void 0&&N>=Math.floor(a*$t);return(0,Z.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,Z.jsx)(ce,{"aria-invalid":P?!0:void 0,"aria-label":`Prompt`,className:`w-full`,"data-generation-prompt":!0,"data-counting":F?``:void 0,...zt(s),disabled:i===!0||T,onChange:e=>{u(e.currentTarget.value),l(e.currentTarget.selectionStart),w(-1)},onScroll:e=>{k&&(e.currentTarget.scrollTop=0)},onSelect:e=>{l(e.currentTarget.selectionStart)},onKeyDown:e=>{if(ie(e))return;let t=Rt(e);if(c>0&&t!==null){e.preventDefault(),t===`next`?f(1):t===`previous`?f(-1):t===`accept`?p():d();return}if(v.startsWith(`/`)&&t!==null&&(ee>0||t===`dismiss`||e.key===`Enter`)){if(e.preventDefault(),t===`dismiss`)u(v.slice(1));else if(ee)t===`next`?h(1):t===`previous`?h(-1):g();else return;return}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),j();return}if(e.key===`ArrowUp`&&y.current?.selectionStart===0&&x.length&&(C===-1||C>0)){e.preventDefault();let t=C===-1?x.length-1:C-1;w(t),u(x[t]);return}if(e.key===`ArrowDown`&&C!==-1){e.preventDefault();let t=C+1;t>=x.length?(w(-1),u(``)):(w(t),u(x[t]))}},placeholder:_,ref:y,style:{maxHeight:A?void 0:O},rows:1,value:v}),F?(0,Z.jsxs)(`p`,{className:`prints-prompt-counter ${P?`text-error`:`text-dim`}`,"data-prompt-counter":!0,id:Zt,role:`status`,title:P?$({addedLength:o,length:N,maxLength:a}):void 0,children:[`${String(N)} / ${String(a)}`,P?(0,Z.jsxs)(`span`,{className:`sr-only`,children:[` `,$({addedLength:o,length:N,maxLength:a})]}):null]}):null]})}function nn({index:e,listId:t,matches:n,onHighlight:r,onPick:i}){return(0,Z.jsx)(Bt,{open:!0,rows:n.map(e=>({key:e.id,label:`/${e.slash}`,detail:e.description??e.title})),selected:e,listId:t,label:`Commands`,kind:`commands`,empty:`No matching commands`,onHighlight:r,onChoose:i})}function rn(e,t){let[n,r]=(0,X.useState)(0),i=t.startsWith(`/`),a=(0,X.useMemo)(()=>{if(!i)return[];let n=Ot(e.map((e,t)=>({alias:e.slash,commandId:e.id,command:e.command,title:e.title,description:e.description,category:`Prompt`,order:t,keys:[],availability:{status:`available`}})),t,{idleCategory:`Prompt`});return n.kind===`commands`?n.items.flatMap(({command:t})=>e.find(e=>e.id===t.commandId)??[]):[]},[t,e,i]);return(0,X.useEffect)(()=>{r(0)},[t]),{moveSlash:e=>{r(t=>a.length?(t+e+a.length)%a.length:0)},highlightSlash:r,resetSlash:()=>{r(0)},slashIndex:n,slashMatches:a,slashOpen:i}}function an({images:e,index:t,listId:n,matches:r,onHighlight:i,onPick:a}){return(0,Z.jsx)(Bt,{open:!0,rows:r.map(t=>{if(t.kind===`reference`)return{key:W(t.reference.number),label:`@${W(t.reference.number)}`,detail:t.reference.name,media:(0,Z.jsx)(`span`,{className:`prints-character-thumb mask mask-squircle`,children:t.reference.url?(0,Z.jsx)(`img`,{src:t.reference.url,alt:``}):null})};let{character:n}=t,r=n.references.at(0)?.path,i=e.find(e=>e.path===r);return{key:String(n.id),label:`@${n.name}`,detail:n.description||void 0,media:(0,Z.jsx)(`span`,{className:`prints-character-thumb mask mask-squircle`,children:i?(0,Z.jsx)(`img`,{src:i.url,alt:``}):null})}}),selected:t,listId:n,label:`References and characters`,kind:`characters`,onHighlight:i,onChoose:a})}var on=e=>e.kind===`reference`?W(e.reference.number):e.character.name;function sn(e,t,n,r){return it(e).flatMap(e=>{let i=/^image(\d+)$/i.exec(e);if(i!==null){let t=n.find(e=>e.number===Number(i.at(1)));return[{key:e.toLowerCase(),label:`@${e.toLowerCase()}`,url:t?.url,valid:t!==void 0}]}let a=t.find(t=>t.name.toLowerCase()===e.toLowerCase());if(a===void 0)return[];let o=a.references.at(0)?.path;return[{key:`character:${String(a.id)}`,label:`@${a.name}`,url:r.find(e=>e.path===o)?.url,valid:!0}]})}function cn({tokens:e}){return e.length===0?null:(0,Z.jsx)(`ul`,{className:`prints-mention-tokens`,"aria-label":`Mentioned in the prompt`,children:e.map(e=>(0,Z.jsxs)(`li`,{className:`prints-mention-token`,"data-mention-token":e.label,"data-invalid":e.valid?void 0:``,title:e.valid?void 0:`No longer attached`,children:[(0,Z.jsx)(`span`,{className:`prints-mention-thumb mask mask-squircle`,children:e.url?(0,Z.jsx)(`img`,{src:e.url,alt:``}):null}),(0,Z.jsx)(`span`,{children:e.label}),e.valid?null:(0,Z.jsx)(`span`,{children:` · not attached`})]},e.key))})}function ln(e,t,n){let[r,i]=(0,X.useState)(0),[a,o]=(0,X.useState)(0),[s,c]=(0,X.useState)(null),[l,u]=(0,X.useState)(null),d=s===n?null:ut(n,r),f=d?dt(e,t,d.query):[];return(0,X.useEffect)(()=>{o(0)},[n]),{caretRequest:l,matches:f,index:a,setCaret:i,highlight:o,dismiss:()=>{c(n)},move:e=>{o(t=>f.length?(t+e+f.length)%f.length:0)},complete:e=>{let t=f.at(e);if(!d||!t)return null;let a=on(t),o=`${n.slice(0,d.start)}@${a} ${n.slice(r)}`,s=d.start+a.length+2;return u({value:o,caret:s}),i(s),o}}}function un(e,t,n){let[r,i]=(0,X.useState)(K),a=e.map(e=>He(e,n)),o=Ue(r,a,t);return o!==r&&i(o),We(o,a)}var dn=400;function fn(e){let{draft:t,model:n}=e;if(n===void 0||t.prompt.trim()===``)return null;let r=G(t.prompt).length>0,i=n.kind===`audio`?ct(t.prompt):lt({prompt:t.prompt,saved:e.characters,references:t.references,labels:e.labels,wording:e=>Ge(M(e,n,r),n),computerId:e.computerId,model:{label:n.label,maxReferences:n.input.maxReferences}});if(i.kind===`refused`)return null;let a=M(i.references,n,r),o={...t,prompt:z(n.kind===`audio`?void 0:e.styleText,i.prompt),references:a};return N(o,n)!==void 0||n.video!==null&&!n.video.formats.some(e=>e.width===o.width&&e.height===o.height)?null:A(o,n).settings}function pn(e,t){let n=e===null?null:JSON.stringify(e),r=(0,X.useRef)(e);r.current=e;let[i,a]=(0,X.useState)({key:n,settings:e});return(0,X.useEffect)(()=>{let e=setTimeout(()=>{a({key:n,settings:r.current})},t);return()=>{clearTimeout(e)}},[n,t]),i}function mn(e,t){return E({queryKey:[`prints`,`quote`,e?.computerId??null,t.key],enabled:e!==void 0&&t.settings!==null,queryFn:()=>e===void 0||t.settings===null?null:e.quote(t.settings),staleTime:6e4,retry:!1})}function hn(e,t){let n=t===null?null:JSON.stringify(t),r=pn(t,dn),i=ue(mn(e,r));return t===null||e===void 0?{state:`idle`}:r.key!==n||i.isPending?{state:`loading`}:i.isError||i.data==null?{state:`unavailable`}:{state:`ready`,price:Xt(i.data.costMilliunits)}}function gn(e,t){let n=hn(e,t);return n.state===`ready`?n.price:null}export{me as $,q as A,Le as B,St as C,at as D,xt as E,W as F,Oe as G,ze as H,Ge as I,_e as J,ge as K,qe as L,lt as M,gt as N,Ye as O,G as P,he as Q,z as R,bt as S,Ct as T,L as U,Ie as V,Ee as W,be as X,ye as Y,ve as Z,Ut as _,tn as a,yt as b,nn as c,rn as d,pe as et,ln as f,Vt as g,Jt as h,Qt as i,ct as j,_t as k,sn as l,Xt as m,gn as n,ue as nt,an as o,un as p,Se as q,hn as r,cn as s,fn as t,fe as tt,$ as u,Ht as v,Y as w,vt as x,Tt as y,Be as z};
|