Current section
Files
Jump to
Current section
Files
dist/guillotine.mjs
var Ct=(t,n=[])=>({parts:(...e)=>{if(bi(n))return Ct(t,e);throw new Error("createAnatomy().parts(...) should only be called once. Did you mean to use .extendWith(...) ?")},extendWith:(...e)=>Ct(t,[...n,...e]),rename:e=>Ct(e,n),keys:()=>n,build:()=>[...new Set(n)].reduce((e,i)=>Object.assign(e,{[i]:{selector:[`&[data-scope="${bt(t)}"][data-part="${bt(i)}"]`,`& [data-scope="${bt(t)}"][data-part="${bt(i)}"]`].join(", "),attrs:{"data-scope":bt(t),"data-part":bt(i)}}}),{})}),bt=t=>t.replace(/([A-Z])([A-Z])/g,"$1-$2").replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase(),bi=t=>t.length===0;var Do=Symbol(),Oi=Symbol();var Le=Object.getPrototypeOf,ce=new WeakMap,Pi=t=>t&&(ce.has(t)?ce.get(t):Le(t)===Object.prototype||Le(t)===Array.prototype);var Ne=t=>Pi(t)&&t[Oi]||null,ae=(t,n=!0)=>{ce.set(t,n)};function Ti(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function ke(t,n){let e=Ti();return e?(e[t]||(e[t]=n()),e[t]):n()}var Ht=!1,le=t=>typeof t=="object"&&t!==null,lt=ke("__zag__proxyStateMap",()=>new WeakMap),It=ke("__zag__refSet",()=>new WeakSet),Si=(t=Object.is,n=(l,h)=>new Proxy(l,h),e=l=>le(l)&&!It.has(l)&&(Array.isArray(l)||!(Symbol.iterator in l))&&!(l instanceof WeakMap)&&!(l instanceof WeakSet)&&!(l instanceof Error)&&!(l instanceof Number)&&!(l instanceof Date)&&!(l instanceof String)&&!(l instanceof RegExp)&&!(l instanceof ArrayBuffer),i=l=>{switch(l.status){case"fulfilled":return l.value;case"rejected":throw l.reason;default:throw l}},r=new WeakMap,o=(l,h,p=i)=>{let c=r.get(l);if(c?.[0]===h)return c[1];let u=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l));return ae(u,!0),r.set(l,[h,u]),Reflect.ownKeys(l).forEach(g=>{let y=Reflect.get(l,g);It.has(y)?(ae(y,!1),u[g]=y):y instanceof Promise?Object.defineProperty(u,g,{get(){return p(y)}}):lt.has(y)?u[g]=rt(y,p):u[g]=y}),Object.freeze(u)},s=new WeakMap,a=[1,1],f=l=>{if(!le(l))throw new Error("object required");let h=s.get(l);if(h)return h;let p=a[0],c=new Set,u=(T,b=++a[0])=>{p!==b&&(p=b,c.forEach(P=>P(T,b)))},g=a[1],y=(T=++a[1])=>(g!==T&&!c.size&&(g=T,d.forEach(([b])=>{let P=b[1](T);P>p&&(p=P)})),p),m=T=>(b,P)=>{let A=[...b];A[1]=[T,...A[1]],u(A,P)},d=new Map,v=(T,b)=>{if(Ht&&d.has(T))throw new Error("prop listener already exists");if(c.size){let P=b[3](m(T));d.set(T,[b,P])}else d.set(T,[b])},x=T=>{let b=d.get(T);b&&(d.delete(T),b[1]?.())},O=T=>(c.add(T),c.size===1&&d.forEach(([P,A],B)=>{if(Ht&&A)throw new Error("remove already exists");let C=P[3](m(B));d.set(B,[P,C])}),()=>{c.delete(T),c.size===0&&d.forEach(([P,A],B)=>{A&&(A(),d.set(B,[P]))})}),S=Array.isArray(l)?[]:Object.create(Object.getPrototypeOf(l)),M=n(S,{deleteProperty(T,b){let P=Reflect.get(T,b);x(b);let A=Reflect.deleteProperty(T,b);return A&&u(["delete",[b],P]),A},set(T,b,P,A){let B=Reflect.has(T,b),C=Reflect.get(T,b,A);if(B&&(t(C,P)||s.has(P)&&t(C,s.get(P))))return!0;x(b),le(P)&&(P=Ne(P)||P);let L=P;if(!Object.getOwnPropertyDescriptor(T,b)?.set)if(P instanceof Promise)P.then(I=>{Object.assign(P,{status:"fulfilled",value:I}),u(["resolve",[b],I])}).catch(I=>{Object.assign(P,{status:"rejected",reason:I}),u(["reject",[b],I])});else{!lt.has(P)&&e(P)&&(L=Mt(P));let I=!It.has(L)&<.get(L);I&&v(b,I)}return Reflect.set(T,b,L,A),u(["set",[b],P,C]),!0}});s.set(l,M);let V=[S,y,o,O];return lt.set(M,V),Reflect.ownKeys(l).forEach(T=>{let b=Object.getOwnPropertyDescriptor(l,T);b.get||b.set?Object.defineProperty(S,T,b):M[T]=l[T]}),M})=>[f,lt,It,t,n,e,i,r,o,s,a],[Ai]=Si();function Mt(t={}){return Ai(t)}function Yt(t,n,e){let i=lt.get(t);Ht&&!i&&console.warn("Please use proxy object");let r,o=[],s=i[3],a=!1,l=s(h=>{if(o.push(h),e){n(o.splice(0));return}r||(r=Promise.resolve().then(()=>{r=void 0,a&&n(o.splice(0))}))});return a=!0,()=>{a=!1,l()}}function rt(t,n){let e=lt.get(t);Ht&&!e&&console.warn("Please use proxy object");let[i,r,o]=e;return o(i,r(),n)}function ot(t){return It.add(t),t}function De(t,n){Object.keys(n).forEach(r=>{if(Object.getOwnPropertyDescriptor(t,r))throw new Error("object property already defined");let o=n[r],{get:s,set:a}=typeof o=="function"?{get:o}:o,f={};f.get=()=>s(rt(i)),a&&(f.set=l=>a(i,l)),Object.defineProperty(t,r,f)});let i=Mt(t);return i}function _e(t,n,e){typeof e.value=="object"&&(e.value=ut(e.value)),!e.enumerable||e.get||e.set||!e.configurable||!e.writable||n==="__proto__"?Object.defineProperty(t,n,e):t[n]=e.value}function ut(t){if(typeof t!="object")return t;var n=0,e,i,r,o=Object.prototype.toString.call(t);if(o==="[object Object]"?r=Object.create(t.__proto__||null):o==="[object Array]"?r=Array(t.length):o==="[object Set]"?(r=new Set,t.forEach(function(s){r.add(ut(s))})):o==="[object Map]"?(r=new Map,t.forEach(function(s,a){r.set(ut(a),ut(s))})):o==="[object Date]"?r=new Date(+t):o==="[object RegExp]"?r=new RegExp(t.source,t.flags):o==="[object DataView]"?r=new t.constructor(ut(t.buffer)):o==="[object ArrayBuffer]"?r=t.slice(0):o.slice(-6)==="Array]"&&(r=new t.constructor(t)),r){for(i=Object.getOwnPropertySymbols(t);n<i.length;n++)_e(r,i[n],Object.getOwnPropertyDescriptor(t,i[n]));for(n=0,i=Object.getOwnPropertyNames(t);n<i.length;n++)Object.hasOwnProperty.call(r,e=i[n])&&r[e]===t[e]||_e(r,e,Object.getOwnPropertyDescriptor(t,e))}return r||t}var Ri=Object.defineProperty,Ci=(t,n,e)=>n in t?Ri(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,E=(t,n,e)=>(Ci(t,typeof n!="symbol"?n+"":n,e),e);function Ii(t){for(;t.length>0;)t.pop();return t}var Fe=(t,...n)=>(typeof t=="function"?t(...n):t)??void 0,Q=t=>t,Mi=()=>{},Li=(...t)=>(...n)=>{t.forEach(function(e){e?.(...n)})},We=(()=>{let t=0;return()=>(t++,t.toString(36))})(),Ni=()=>!1,$t=t=>Array.isArray(t),Nt=t=>!(t==null||typeof t!="object"||$t(t)),ki=t=>typeof t=="number"&&!Number.isNaN(t),F=t=>typeof t=="string",Xt=t=>typeof t=="function",Di=(t,n)=>Object.prototype.hasOwnProperty.call(t,n);function Gt(t){if(!_i(t)||t===void 0)return t;let n=Reflect.ownKeys(t).filter(i=>typeof i=="string"),e={};for(let i of n){let r=t[i];r!==void 0&&(e[i]=Gt(r))}return e}var _i=t=>t&&typeof t=="object"&&t.constructor===Object;function ue(...t){let n=t.length===1?t[0]:t[1],e=t.length===2?t[0]:!0}function Kt(...t){let n=t.length===1?t[0]:t[1],e=t.length===2?t[0]:!0}function He(t,...n){for(let e of n){let i=Gt(e);for(let r in i)Nt(e[r])?(t[r]||(t[r]={}),He(t[r],e[r])):t[r]=e[r]}return t}function Ve(t){return ut(t)}function $(t){return F(t)?{type:t}:t}function st(t){return t?$t(t)?t.slice():[t]:[]}function Ye(t){return Nt(t)&&t.predicate!=null}var Fi=()=>!0;function de(t,n,e,i){return r=>F(r)?!!t[r]?.(n,e,i):Xt(r)?r(n,e,i):r.predicate(t)(n,e,i)}function Wi(...t){return{predicate:n=>(e,i,r)=>t.map(de(n,e,i,r)).some(Boolean)}}function Vi(...t){return{predicate:n=>(e,i,r)=>t.map(de(n,e,i,r)).every(Boolean)}}function Bi(t){return{predicate:n=>(e,i,r)=>!de(n,e,i,r)(t)}}function Hi(...t){return(n,e,i)=>i.state.matches(...t)}var Ke={or:Wi,and:Vi,not:Bi,stateIn:Hi};function $e(t,n){return t=t??Fi,(e,i,r)=>{if(F(t)){let o=n[t];return Xt(o)?o(e,i,r):o}return Ye(t)?t.predicate(n)(e,i,r):t?.(e,i,r)}}function fe(t,n){return(e,i,r)=>Ye(t)?t.predicate(n)(e,i,r):t}function Yi(t){let n=t.computed??Q({}),e=t.context??Q({}),i=t.initial?t.states?.[t.initial]?.tags:[],r=Mt({value:t.initial??"",previousValue:"",event:Q({}),previousEvent:Q({}),context:De(e,n),done:!1,tags:i??[],hasTag(o){return this.tags.includes(o)},matches(...o){return o.includes(this.value)},can(o){return Q(this).nextEvents.includes(o)},get nextEvents(){let o=t.states?.[this.value]?.on??{},s=t?.on??{};return Object.keys({...o,...s})},get changed(){return this.event.value==="machine.init"||!this.previousValue?!1:this.value!==this.previousValue}});return Q(r)}function Lt(t,n){return(e,i)=>{if(ki(t))return t;if(Xt(t))return t(e,i);if(F(t)){let r=Number.parseFloat(t);if(!Number.isNaN(r))return r;if(n){let o=n?.[t];return Kt(o==null,`[@zag-js/core > determine-delay] Cannot determine delay for \`${t}\`. It doesn't exist in \`options.delays\``),Xt(o)?o(e,i):o}}}}function Ki(t){return F(t)?{target:t}:t}function $i(t,n){return(e,i,r)=>st(t).map(Ki).find(o=>$e(o.guard,n)(e,i,r)??o.target??o.actions)}var Xi=class{constructor(t,n){E(this,"status","Not Started"),E(this,"state"),E(this,"initialState"),E(this,"initialContext"),E(this,"id"),E(this,"type","machine"),E(this,"activityEvents",new Map),E(this,"delayedEvents",new Map),E(this,"stateListeners",new Set),E(this,"doneListeners",new Set),E(this,"contextWatchers",new Set),E(this,"removeStateListener",Mi),E(this,"parent"),E(this,"children",new Map),E(this,"guardMap"),E(this,"actionMap"),E(this,"delayMap"),E(this,"activityMap"),E(this,"sync"),E(this,"options"),E(this,"config"),E(this,"_created",()=>{let e=$("machine.created");this.executeActions(this.config?.created,e)}),E(this,"start",e=>{if(this.state.value="",this.state.tags=[],this.status==="Running")return this;this.status="Running",this.removeStateListener=Yt(this.state,()=>{this.stateListeners.forEach(f=>{f(this.stateSnapshot)})},this.sync),this.setupContextWatchers(),this.executeActivities($("machine.start"),st(this.config.activities),"machine.start"),this.executeActions(this.config.entry,$("machine.start"));let i=$("machine.init"),r=Nt(e)?e.value:e,o=Nt(e)?e.context:void 0;o&&this.setContext(o);let s={target:r??this.config.initial},a=this.getNextStateInfo(s,i);return this.initialState=a,this.performStateChangeEffects(this.state.value,a,i),this}),E(this,"setupContextWatchers",()=>{let{watch:e}=this.config;if(!e)return;let i=rt(this.state.context),r=Yt(this.state.context,()=>{let o=rt(this.state.context);for(let[s,a]of Object.entries(e))(this.options.compareFns?.[s]??Object.is)(i[s],o[s])||this.executeActions(a,this.state.event);i=o});this.contextWatchers.add(r)}),E(this,"stop",()=>{if(this.status!=="Stopped")return this.performExitEffects(this.state.value,$("machine.stop")),this.executeActions(this.config.exit,$("machine.stop")),this.setState(""),this.setEvent("machine.stop"),this.stopStateListeners(),this.stopChildren(),this.stopActivities(),this.stopDelayedEvents(),this.stopContextWatchers(),this.status="Stopped",this}),E(this,"stopStateListeners",()=>{this.removeStateListener(),this.stateListeners.clear()}),E(this,"stopContextWatchers",()=>{this.contextWatchers.forEach(e=>e()),this.contextWatchers.clear()}),E(this,"stopDelayedEvents",()=>{this.delayedEvents.forEach(e=>{e.forEach(i=>i())}),this.delayedEvents.clear()}),E(this,"stopActivities",e=>{e?(this.activityEvents.get(e)?.forEach(i=>i()),this.activityEvents.get(e)?.clear(),this.activityEvents.delete(e)):(this.activityEvents.forEach(i=>{i.forEach(r=>r()),i.clear()}),this.activityEvents.clear())}),E(this,"sendChild",(e,i)=>{let r=$(e),o=Fe(i,this.contextSnapshot),s=this.children.get(o);s||Kt(`[@zag-js/core] Cannot send '${r.type}' event to unknown child`),s.send(r)}),E(this,"stopChild",e=>{this.children.has(e)||Kt(`[@zag-js/core > stop-child] Cannot stop unknown child ${e}`),this.children.get(e).stop(),this.children.delete(e)}),E(this,"removeChild",e=>{this.children.delete(e)}),E(this,"stopChildren",()=>{this.children.forEach(e=>e.stop()),this.children.clear()}),E(this,"setParent",e=>{this.parent=e}),E(this,"spawn",(e,i)=>{let r=Fe(e);return i&&(r.id=i),r.type="machine.actor",r.setParent(this),this.children.set(r.id,Q(r)),r.onDone(()=>{this.removeChild(r.id)}).start(),Q(ot(r))}),E(this,"stopActivity",e=>{if(!this.state.value)return;let i=this.activityEvents.get(this.state.value);i?.get(e)?.(),i?.delete(e)}),E(this,"addActivityCleanup",(e,i,r)=>{e&&(this.activityEvents.has(e)?this.activityEvents.get(e)?.set(i,r):this.activityEvents.set(e,new Map([[i,r]])))}),E(this,"setState",e=>{this.state.previousValue=this.state.value,this.state.value=e;let i=this.getStateNode(e);e==null?Ii(this.state.tags):this.state.tags=st(i?.tags)}),E(this,"setContext",e=>{e&&He(this.state.context,Gt(e))}),E(this,"setOptions",e=>{let i=Gt(e);this.actionMap={...this.actionMap,...i.actions},this.delayMap={...this.delayMap,...i.delays},this.activityMap={...this.activityMap,...i.activities},this.guardMap={...this.guardMap,...i.guards}}),E(this,"getStateNode",e=>{if(e)return this.config.states?.[e]}),E(this,"getNextStateInfo",(e,i)=>{let r=this.determineTransition(e,i),o=!r?.target,s=r?.target??this.state.value,a=this.state.value!==s,f=this.getStateNode(s),h={reenter:!o&&!a&&!r?.internal,transition:r,stateNode:f,target:s,changed:a};return this.log("NextState:",`[${i.type}]`,this.state.value,"---->",h.target),h}),E(this,"getAfterActions",(e,i)=>{let r;return{entry:()=>{r=globalThis.setTimeout(()=>{let o=this.getNextStateInfo(e,this.state.event);this.performStateChangeEffects(this.state.value,o,this.state.event)},i)},exit:()=>{globalThis.clearTimeout(r)}}}),E(this,"getDelayedEventActions",e=>{let i=this.getStateNode(e),r=this.state.event;if(!i||!i.after)return;let o=[],s=[];if($t(i.after)){let a=this.determineTransition(i.after,r);if(!a)return;if(!Di(a,"delay"))throw new Error(`[@zag-js/core > after] Delay is required for after transition: ${JSON.stringify(a)}`);let l=Lt(a.delay,this.delayMap)(this.contextSnapshot,r),h=this.getAfterActions(a,l);return o.push(h.entry),s.push(h.exit),{entries:o,exits:s}}if(Nt(i.after))for(let a in i.after){let f=i.after[a],h=Lt(a,this.delayMap)(this.contextSnapshot,r),p=this.getAfterActions(f,h);o.push(p.entry),s.push(p.exit)}return{entries:o,exits:s}}),E(this,"executeActions",(e,i)=>{let r=fe(e,this.guardMap)(this.contextSnapshot,i,this.guardMeta);for(let o of st(r)){let s=F(o)?this.actionMap?.[o]:o;ue(F(o)&&!s,`[@zag-js/core > execute-actions] No implementation found for action: \`${o}\``),s?.(this.state.context,i,this.meta)}}),E(this,"executeActivities",(e,i,r)=>{for(let o of i){let s=F(o)?this.activityMap?.[o]:o;if(!s){ue(`[@zag-js/core > execute-activity] No implementation found for activity: \`${o}\``);continue}let a=s(this.state.context,e,this.meta);if(a){let f=F(o)?o:o.name||We();this.addActivityCleanup(r??this.state.value,f,a)}}}),E(this,"createEveryActivities",(e,i)=>{if(e)if($t(e)){let r=st(e).find(f=>{let l=f.delay,p=Lt(l,this.delayMap)(this.contextSnapshot,this.state.event);return $e(f.guard,this.guardMap)(this.contextSnapshot,this.state.event,this.guardMeta)??p!=null});if(!r)return;let s=Lt(r.delay,this.delayMap)(this.contextSnapshot,this.state.event);i(()=>{let f=globalThis.setInterval(()=>{this.executeActions(r.actions,this.state.event)},s);return()=>{globalThis.clearInterval(f)}})}else for(let r in e){let o=e?.[r],a=Lt(r,this.delayMap)(this.contextSnapshot,this.state.event);i(()=>{let l=globalThis.setInterval(()=>{this.executeActions(o,this.state.event)},a);return()=>{globalThis.clearInterval(l)}})}}),E(this,"setEvent",e=>{this.state.previousEvent=this.state.event,this.state.event=ot($(e))}),E(this,"performExitEffects",(e,i)=>{let r=this.state.value;if(r==="")return;let o=e?this.getStateNode(e):void 0;this.stopActivities(r);let s=fe(o?.exit,this.guardMap)(this.contextSnapshot,i,this.guardMeta),a=st(s),f=this.delayedEvents.get(r);f&&a.push(...f),this.executeActions(a,i)}),E(this,"performEntryEffects",(e,i)=>{let r=this.getStateNode(e),o=st(r?.activities);this.createEveryActivities(r?.every,l=>{o.unshift(l)}),o.length>0&&this.executeActivities(i,o);let s=fe(r?.entry,this.guardMap)(this.contextSnapshot,i,this.guardMeta),a=st(s),f=this.getDelayedEventActions(e);r?.after&&f&&(this.delayedEvents.set(e,f?.exits),a.push(...f.entries)),this.executeActions(a,i),r?.type==="final"&&(this.state.done=!0,this.doneListeners.forEach(l=>{l(this.stateSnapshot)}),this.stop())}),E(this,"performTransitionEffects",(e,i)=>{let r=this.determineTransition(e,i);this.executeActions(r?.actions,i)}),E(this,"performStateChangeEffects",(e,i,r)=>{this.setEvent(r);let o=i.changed||i.reenter;o&&this.performExitEffects(e,r),this.performTransitionEffects(i.transition,r),this.setState(i.target),o&&this.performEntryEffects(i.target,r)}),E(this,"determineTransition",(e,i)=>$i(e,this.guardMap)?.(this.contextSnapshot,i,this.guardMeta)),E(this,"sendParent",e=>{this.parent||Kt("[@zag-js/core > send-parent] Cannot send event to an unknown parent");let i=$(e);this.parent?.send(i)}),E(this,"log",(...e)=>{Ni()&&this.options.debug&&console.log(...e)}),E(this,"send",e=>{let i=$(e);this.transition(this.state.value,i)}),E(this,"transition",(e,i)=>{let r=F(e)?this.getStateNode(e):e?.stateNode,o=$(i);if(!r&&!this.config.on){let f=this.status==="Stopped"?"[@zag-js/core > transition] Cannot transition a stopped machine":`[@zag-js/core > transition] State does not have a definition for \`state\`: ${e}, \`event\`: ${o.type}`;ue(f);return}let s=r?.on?.[o.type]??this.config.on?.[o.type],a=this.getNextStateInfo(s,o);return this.performStateChangeEffects(this.state.value,a,o),a.stateNode}),E(this,"subscribe",e=>(this.stateListeners.add(e),this.status==="Running"&&e(this.stateSnapshot),()=>{this.stateListeners.delete(e)})),E(this,"onDone",e=>(this.doneListeners.add(e),this)),E(this,"onTransition",e=>(this.stateListeners.add(e),this.status==="Running"&&e(this.stateSnapshot),this)),this.config=Ve(t),this.options=Ve(n??{}),this.id=this.config.id??`machine-${We()}`,this.guardMap=this.options?.guards??{},this.actionMap=this.options?.actions??{},this.delayMap=this.options?.delays??{},this.activityMap=this.options?.activities??{},this.sync=this.options?.sync??!1,this.state=Yi(this.config),this.initialContext=rt(this.state.context)}get stateSnapshot(){return Q(rt(this.state))}getState(){return this.stateSnapshot}get contextSnapshot(){return this.stateSnapshot.context}get self(){let t=this;return{id:this.id,send:this.send.bind(this),sendParent:this.sendParent.bind(this),sendChild:this.sendChild.bind(this),stop:this.stop.bind(this),stopChild:this.stopChild.bind(this),spawn:this.spawn.bind(this),stopActivity:this.stopActivity.bind(this),get state(){return t.stateSnapshot},get initialContext(){return t.initialContext},get initialState(){return t.initialState?.target??""}}}get meta(){return{state:this.stateSnapshot,guards:this.guardMap,send:this.send.bind(this),self:this.self,initialContext:this.initialContext,initialState:this.initialState?.target??"",getState:()=>this.stateSnapshot,getAction:t=>this.actionMap[t],getGuard:t=>this.guardMap[t]}}get guardMeta(){return{state:this.stateSnapshot}}get[Symbol.toStringTag](){return"Machine"}},Xe=(t,n)=>new Xi(t,n);var Gi=(...t)=>t.map(n=>n?.trim?.()).filter(Boolean).join(" "),ji=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g,Be=t=>{let n={},e;for(;e=ji.exec(t);)n[e[1]]=e[2];return n},Ui=(t,n)=>{if(F(t)){if(F(n))return`${t};${n}`;t=Be(t)}else F(n)&&(n=Be(n));return Object.assign({},t??{},n??{})},zi=/^on[A-Z]/;function Ge(...t){let n={};for(let e of t){for(let i in n){if(zi.test(i)&&typeof n[i]=="function"&&typeof e[i]=="function"){n[i]=Li(e[i],n[i]);continue}if(i==="className"||i==="class"){n[i]=Gi(n[i],e[i]);continue}if(i==="style"){n[i]=Ui(n[i],e[i]);continue}n[i]=e[i]!==void 0?e[i]:n[i]}for(let i in e)n[i]===void 0&&(n[i]=e[i])}return n}var ft=t=>t?"":void 0;var N=t=>typeof t=="object"&&t?.nodeType===Node.ELEMENT_NODE&&typeof t?.nodeName=="string",Ue=t=>t.nodeType===Node.DOCUMENT_NODE,qi=t=>t!=null&&t===t.window;var Ji=t=>t.nodeType!==void 0,Zi=t=>t&&Ji(t)&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in t;function U(t,n){return!t||!n||!N(t)||!N(n)?!1:t===n||t.contains(n)}function dt(t){return Ue(t)?t:qi(t)?t.document:t?.ownerDocument??document}function ht(t){return Zi(t)?ht(t.host):Ue(t)?t.defaultView??window:N(t)?t.ownerDocument?.defaultView??window:window}var ge=()=>typeof document<"u";function Qi(){return navigator.userAgentData?.platform??navigator.platform}var ze=t=>ge()&&t.test(Qi()),tr=t=>ge()&&t.test(navigator.userAgent);var er=()=>ge()&&!!navigator.maxTouchPoints,qe=()=>ze(/^Mac/)&&!er();var Je=()=>tr(/firefox\//i),nr=()=>ze(/mac|iphone|ipad|ipod/i);function z(t){return t.composedPath?.()[0]??t.target}var Ze=t=>U(t.currentTarget,z(t));function pe(t){let n=t.currentTarget;if(!n)return!1;let e=nr();if(e&&!t.metaKey||!e&&!t.ctrlKey)return!1;let i=n.localName;return i==="a"||i==="button"&&n.type==="submit"||i==="input"&&n.type==="submit"}function me(t){let n=t.currentTarget;if(!n)return!1;let e=n.localName;return t.altKey?e==="a"||e==="button"&&n.type==="submit"||e==="input"&&n.type==="submit":!1}var ye=t=>t.id;function ir(t,n,e=ye){return t.find(i=>e(i)===n)}function Ee(t,n,e=ye){let i=ir(t,n,e);return i?t.indexOf(i):-1}function Qe(t,n,e=!0){let i=Ee(t,n);return i=e?(i+1)%t.length:Math.min(i+1,t.length-1),t[i]}function tn(t,n,e=!0){let i=Ee(t,n);return i===-1?e?t[t.length-1]:null:(i=e?(i-1+t.length)%t.length:Math.max(0,i-1),t[i])}var rr=t=>t.split("").map(n=>{let e=n.charCodeAt(0);return e>0&&e<128?n:e>=128&&e<=255?`/x${e.toString(16)}`.replace("/","\\"):""}).join("").trim(),or=t=>rr(t.dataset.valuetext??t.textContent??""),sr=(t,n)=>t.trim().toLowerCase().startsWith(n.toLowerCase()),cr=(t,n)=>t.map((e,i)=>t[(Math.max(n,0)+i)%t.length]);function ar(t,n,e,i=ye){let r=e?Ee(t,e,i):-1,o=e?cr(t,r):t;return n.length===1&&(o=o.filter(a=>i(a)!==e)),o.find(a=>sr(or(a),n))}function lr(t,n){let{state:e,activeId:i,key:r,timeout:o=350,itemToId:s}=n,a=e.keysSoFar+r,l=a.length>1&&Array.from(a).every(g=>g===a[0])?a[0]:a,h=t.slice(),p=ar(h,l,i,s);function c(){clearTimeout(e.timer),e.timer=-1}function u(g){e.keysSoFar=g,c(),g!==""&&(e.timer=+setTimeout(()=>{u(""),c()},o))}return u(a),p}var jt=Object.assign(lr,{defaultOptions:{keysSoFar:"",timer:-1},isValidEvent:ur});function ur(t){return t.key.length===1&&!t.ctrlKey&&!t.metaKey}var en=t=>typeof t=="object"&&t!==null&&t.nodeType===1,fr=t=>en(t)&&t.tagName==="IFRAME";function dr(t){return en(t)?t.offsetWidth>0||t.offsetHeight>0||t.getClientRects().length>0:!1}function hr(t){return parseInt(t.getAttribute("tabindex")||"0",10)<0}var nn="input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), details > summary:first-of-type";function Ut(t){return!t||t.closest("[inert]")?!1:t.matches(nn)&&dr(t)}function ve(t,n){if(!t)return[];let e=Array.from(t.querySelectorAll(nn)),i=e.filter(je);return n&&je(t)&&i.unshift(t),i.forEach((r,o)=>{if(fr(r)&&r.contentDocument){let s=r.contentDocument.body,a=ve(s);i.splice(o,1,...a)}}),!i.length&&n?e:i}function je(t){return t!=null&&t.tabIndex>0?!0:Ut(t)&&!hr(t)}function rn(t,n){let[e]=ve(t,n);return e||null}function gr(t,n){let e=ve(t,n),i=e[0]||null,r=e[e.length-1]||null;return[i,r]}function on(t){let n=t.currentTarget;if(!n)return!1;let[e,i]=gr(n),r=n.ownerDocument||document;return!(r.activeElement===e&&t.shiftKey||r.activeElement===i&&!t.shiftKey||!e&&!i)}function zt(t){if(t==null||!N(t))return!1;try{let n=ht(t);return t instanceof n.HTMLInputElement&&t.selectionStart!=null||/(textarea|select)/.test(t.localName)||t.isContentEditable}catch{return!1}}var pr=/auto|scroll|overlay|hidden|clip/;function mr(t){let n=ht(t),{overflow:e,overflowX:i,overflowY:r,display:o}=n.getComputedStyle(t);return pr.test(e+r+i)&&!["inline","contents"].includes(o)}function W(t){let n=globalThis.requestAnimationFrame(t);return()=>{globalThis.cancelAnimationFrame(n)}}function yr(t,n){if(!t)return;let{attributes:e,callback:i}=n,r=t.ownerDocument.defaultView||window,o=new r.MutationObserver(s=>{for(let a of s)a.type==="attributes"&&a.attributeName&&e.includes(a.attributeName)&&i(a)});return o.observe(t,{attributes:!0,attributeFilter:e}),()=>o.disconnect()}function sn(t,n){let{defer:e}=n,i=e?W:o=>o(),r=[];return r.push(i(()=>{let o=typeof t=="function"?t():t;r.push(yr(o,n))})),()=>{r.forEach(o=>o?.())}}function cn(t,n){return Array.from(t?.querySelectorAll(n)??[])}function an(t){let n={getRootNode:e=>e.getRootNode?.()??document,getDoc:e=>dt(n.getRootNode(e)),getWin:e=>n.getDoc(e).defaultView??window,getActiveElement:e=>n.getDoc(e).activeElement,isActiveElement:(e,i)=>i===n.getActiveElement(e),getById:(e,i)=>n.getRootNode(e).getElementById(i),setValue:(e,i)=>{if(e==null||i==null)return;let r=i.toString();e.value!==r&&(e.value=i.toString())}};return{...n,...t}}function Er(t){return t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth}function ln(t,n){let{rootEl:e,...i}=n||{};!t||!e||!mr(e)||!Er(e)||t.scrollIntoView(i)}var he=new WeakMap;function vr(t,n,e){he.has(t)||he.set(t,new Map);let i=he.get(t),r=i.get(n);if(!r)return i.set(n,e()),()=>{i.get(n)?.(),i.delete(n)};let o=e(),s=()=>{o(),r(),i.delete(n)};return i.set(n,s),()=>{i.get(n)===s&&(o(),i.set(n,r))}}function un(t,n){return t?vr(t,"style",()=>{let i=t.style.cssText;return Object.assign(t.style,n),()=>{t.style.cssText=i}}):()=>{}}var wr=1e3/60;function xr(t,n){let e=t();if(N(e)&&e.isConnected)return n(e),()=>{};{let i=setInterval(()=>{let r=t();N(r)&&r.isConnected&&(n(r),clearInterval(i))},wr);return()=>clearInterval(i)}}function fn(t,n){let e=[];return t?.forEach(i=>{let r=xr(i,n);e.push(r)}),()=>{e.forEach(i=>i())}}var gt=(t,n,e,i)=>{let r=typeof t=="function"?t():t;return r?.addEventListener(n,e,i),()=>{r?.removeEventListener(n,e,i)}};function hn(t){return t.key.length===1&&!t.ctrlKey&&!t.metaKey}var qt=t=>t.button===0,Jt=t=>t.button===2||qe()&&t.ctrlKey&&t.button===0,gn=t=>t.ctrlKey||t.altKey||t.metaKey;function br(t,n,e){let r=(s=>{let a=requestAnimationFrame(s);return()=>cancelAnimationFrame(a)})(()=>{t.removeEventListener(n,o,!0),e()}),o=()=>{r(),e()};return t.addEventListener(n,o,{once:!0,capture:!0}),r}function Or(t){return t?.matches("a[href]")??!1}function we(t){if(!Or(t))return;let n=()=>t.click();Je()?br(t,"keyup",n):queueMicrotask(n)}function xe(t,n,e){if(!t)return;let i=t.ownerDocument.defaultView||window,r=new i.CustomEvent(n,e);return t.dispatchEvent(r)}var Pr={Up:"ArrowUp",Down:"ArrowDown",Esc:"Escape"," ":"Space",",":"Comma",Left:"ArrowLeft",Right:"ArrowRight"},dn={ArrowLeft:"ArrowRight",ArrowRight:"ArrowLeft"};function be(t,n={}){let{dir:e="ltr",orientation:i="horizontal"}=n,{key:r}=t;return r=Pr[r]??r,e==="rtl"&&i==="horizontal"&&r in dn&&(r=dn[r]),r}function Tr(t,n="client"){let e=t.touches[0]||t.changedTouches[0];return{x:e[`${n}X`],y:e[`${n}Y`]}}function Sr(t,n="client"){return{x:t[`${n}X`],y:t[`${n}Y`]}}var Ar=t=>"touches"in t&&t.touches.length>0;function Zt(t,n="client"){return Ar(t)?Tr(t,n):Sr(t,n)}function Ot(t){return t.nativeEvent??t}var H=Math.min,k=Math.max,Dt=Math.round,_t=Math.floor,tt=t=>({x:t,y:t}),Rr={left:"right",right:"left",bottom:"top",top:"bottom"},Cr={start:"end",end:"start"};function te(t,n,e){return k(t,H(n,e))}function et(t,n){return typeof t=="function"?t(n):t}function q(t){return t.split("-")[0]}function pt(t){return t.split("-")[1]}function ee(t){return t==="x"?"y":"x"}function ne(t){return t==="y"?"height":"width"}function mt(t){return["top","bottom"].includes(q(t))?"y":"x"}function ie(t){return ee(mt(t))}function pn(t,n,e){e===void 0&&(e=!1);let i=pt(t),r=ie(t),o=ne(r),s=r==="x"?i===(e?"end":"start")?"right":"left":i==="start"?"bottom":"top";return n.reference[o]>n.floating[o]&&(s=kt(s)),[s,kt(s)]}function mn(t){let n=kt(t);return[Qt(t),n,Qt(n)]}function Qt(t){return t.replace(/start|end/g,n=>Cr[n])}function Ir(t,n,e){let i=["left","right"],r=["right","left"],o=["top","bottom"],s=["bottom","top"];switch(t){case"top":case"bottom":return e?n?r:i:n?i:r;case"left":case"right":return n?o:s;default:return[]}}function yn(t,n,e,i){let r=pt(t),o=Ir(q(t),e==="start",i);return r&&(o=o.map(s=>s+"-"+r),n&&(o=o.concat(o.map(Qt)))),o}function kt(t){return t.replace(/left|right|bottom|top/g,n=>Rr[n])}function Mr(t){return{top:0,right:0,bottom:0,left:0,...t}}function Oe(t){return typeof t!="number"?Mr(t):{top:t,right:t,bottom:t,left:t}}function yt(t){let{x:n,y:e,width:i,height:r}=t;return{width:i,height:r,top:e,left:n,right:n+i,bottom:e+r,x:n,y:e}}function En(t,n,e){let{reference:i,floating:r}=t,o=mt(n),s=ie(n),a=ne(s),f=q(n),l=o==="y",h=i.x+i.width/2-r.width/2,p=i.y+i.height/2-r.height/2,c=i[a]/2-r[a]/2,u;switch(f){case"top":u={x:h,y:i.y-r.height};break;case"bottom":u={x:h,y:i.y+i.height};break;case"right":u={x:i.x+i.width,y:p};break;case"left":u={x:i.x-r.width,y:p};break;default:u={x:i.x,y:i.y}}switch(pt(n)){case"start":u[s]-=c*(e&&l?-1:1);break;case"end":u[s]+=c*(e&&l?-1:1);break}return u}var vn=async(t,n,e)=>{let{placement:i="bottom",strategy:r="absolute",middleware:o=[],platform:s}=e,a=o.filter(Boolean),f=await(s.isRTL==null?void 0:s.isRTL(n)),l=await s.getElementRects({reference:t,floating:n,strategy:r}),{x:h,y:p}=En(l,i,f),c=i,u={},g=0;for(let y=0;y<a.length;y++){let{name:m,fn:d}=a[y],{x:v,y:x,data:O,reset:S}=await d({x:h,y:p,initialPlacement:i,placement:c,strategy:r,middlewareData:u,rects:l,platform:s,elements:{reference:t,floating:n}});h=v??h,p=x??p,u={...u,[m]:{...u[m],...O}},S&&g<=50&&(g++,typeof S=="object"&&(S.placement&&(c=S.placement),S.rects&&(l=S.rects===!0?await s.getElementRects({reference:t,floating:n,strategy:r}):S.rects),{x:h,y:p}=En(l,c,f)),y=-1)}return{x:h,y:p,placement:c,strategy:r,middlewareData:u}};async function re(t,n){var e;n===void 0&&(n={});let{x:i,y:r,platform:o,rects:s,elements:a,strategy:f}=t,{boundary:l="clippingAncestors",rootBoundary:h="viewport",elementContext:p="floating",altBoundary:c=!1,padding:u=0}=et(n,t),g=Oe(u),m=a[c?p==="floating"?"reference":"floating":p],d=yt(await o.getClippingRect({element:(e=await(o.isElement==null?void 0:o.isElement(m)))==null||e?m:m.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:l,rootBoundary:h,strategy:f})),v=p==="floating"?{x:i,y:r,width:s.floating.width,height:s.floating.height}:s.reference,x=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),O=await(o.isElement==null?void 0:o.isElement(x))?await(o.getScale==null?void 0:o.getScale(x))||{x:1,y:1}:{x:1,y:1},S=yt(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:x,strategy:f}):v);return{top:(d.top-S.top+g.top)/O.y,bottom:(S.bottom-d.bottom+g.bottom)/O.y,left:(d.left-S.left+g.left)/O.x,right:(S.right-d.right+g.right)/O.x}}var wn=t=>({name:"arrow",options:t,async fn(n){let{x:e,y:i,placement:r,rects:o,platform:s,elements:a,middlewareData:f}=n,{element:l,padding:h=0}=et(t,n)||{};if(l==null)return{};let p=Oe(h),c={x:e,y:i},u=ie(r),g=ne(u),y=await s.getDimensions(l),m=u==="y",d=m?"top":"left",v=m?"bottom":"right",x=m?"clientHeight":"clientWidth",O=o.reference[g]+o.reference[u]-c[u]-o.floating[g],S=c[u]-o.reference[u],R=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l)),M=R?R[x]:0;(!M||!await(s.isElement==null?void 0:s.isElement(R)))&&(M=a.floating[x]||o.floating[g]);let V=O/2-S/2,T=M/2-y[g]/2-1,b=H(p[d],T),P=H(p[v],T),A=b,B=M-y[g]-P,C=M/2-y[g]/2+V,L=te(A,C,B),I=!f.arrow&&pt(r)!=null&&C!==L&&o.reference[g]/2-(C<A?b:P)-y[g]/2<0,Z=I?C<A?C-A:C-B:0;return{[u]:c[u]+Z,data:{[u]:L,centerOffset:C-L-Z,...I&&{alignmentOffset:Z}},reset:I}}});var xn=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(n){var e,i;let{placement:r,middlewareData:o,rects:s,initialPlacement:a,platform:f,elements:l}=n,{mainAxis:h=!0,crossAxis:p=!0,fallbackPlacements:c,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...m}=et(t,n);if((e=o.arrow)!=null&&e.alignmentOffset)return{};let d=q(r),v=q(a)===a,x=await(f.isRTL==null?void 0:f.isRTL(l.floating)),O=c||(v||!y?[kt(a)]:mn(a));!c&&g!=="none"&&O.push(...yn(a,y,g,x));let S=[a,...O],R=await re(n,m),M=[],V=((i=o.flip)==null?void 0:i.overflows)||[];if(h&&M.push(R[d]),p){let A=pn(r,s,x);M.push(R[A[0]],R[A[1]])}if(V=[...V,{placement:r,overflows:M}],!M.every(A=>A<=0)){var T,b;let A=(((T=o.flip)==null?void 0:T.index)||0)+1,B=S[A];if(B)return{data:{index:A,overflows:V},reset:{placement:B}};let C=(b=V.filter(L=>L.overflows[0]<=0).sort((L,I)=>L.overflows[1]-I.overflows[1])[0])==null?void 0:b.placement;if(!C)switch(u){case"bestFit":{var P;let L=(P=V.map(I=>[I.placement,I.overflows.filter(Z=>Z>0).reduce((Z,xi)=>Z+xi,0)]).sort((I,Z)=>I[1]-Z[1])[0])==null?void 0:P[0];L&&(C=L);break}case"initialPlacement":C=a;break}if(r!==C)return{reset:{placement:C}}}return{}}}};async function Lr(t,n){let{placement:e,platform:i,elements:r}=t,o=await(i.isRTL==null?void 0:i.isRTL(r.floating)),s=q(e),a=pt(e),f=mt(e)==="y",l=["left","top"].includes(s)?-1:1,h=o&&f?-1:1,p=et(n,t),{mainAxis:c,crossAxis:u,alignmentAxis:g}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...p};return a&&typeof g=="number"&&(u=a==="end"?g*-1:g),f?{x:u*h,y:c*l}:{x:c*l,y:u*h}}var bn=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(n){var e,i;let{x:r,y:o,placement:s,middlewareData:a}=n,f=await Lr(n,t);return s===((e=a.offset)==null?void 0:e.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:r+f.x,y:o+f.y,data:{...f,placement:s}}}}},On=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(n){let{x:e,y:i,placement:r}=n,{mainAxis:o=!0,crossAxis:s=!1,limiter:a={fn:m=>{let{x:d,y:v}=m;return{x:d,y:v}}},...f}=et(t,n),l={x:e,y:i},h=await re(n,f),p=mt(q(r)),c=ee(p),u=l[c],g=l[p];if(o){let m=c==="y"?"top":"left",d=c==="y"?"bottom":"right",v=u+h[m],x=u-h[d];u=te(v,u,x)}if(s){let m=p==="y"?"top":"left",d=p==="y"?"bottom":"right",v=g+h[m],x=g-h[d];g=te(v,g,x)}let y=a.fn({...n,[c]:u,[p]:g});return{...y,data:{x:y.x-e,y:y.y-i}}}}},Pn=function(t){return t===void 0&&(t={}),{options:t,fn(n){let{x:e,y:i,placement:r,rects:o,middlewareData:s}=n,{offset:a=0,mainAxis:f=!0,crossAxis:l=!0}=et(t,n),h={x:e,y:i},p=mt(r),c=ee(p),u=h[c],g=h[p],y=et(a,n),m=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(f){let x=c==="y"?"height":"width",O=o.reference[c]-o.floating[x]+m.mainAxis,S=o.reference[c]+o.reference[x]-m.mainAxis;u<O?u=O:u>S&&(u=S)}if(l){var d,v;let x=c==="y"?"width":"height",O=["top","left"].includes(q(r)),S=o.reference[p]-o.floating[x]+(O&&((d=s.offset)==null?void 0:d[p])||0)+(O?0:m.crossAxis),R=o.reference[p]+o.reference[x]+(O?0:((v=s.offset)==null?void 0:v[p])||0)-(O?m.crossAxis:0);g<S?g=S:g>R&&(g=R)}return{[c]:u,[p]:g}}}},Tn=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(n){let{placement:e,rects:i,platform:r,elements:o}=n,{apply:s=()=>{},...a}=et(t,n),f=await re(n,a),l=q(e),h=pt(e),p=mt(e)==="y",{width:c,height:u}=i.floating,g,y;l==="top"||l==="bottom"?(g=l,y=h===(await(r.isRTL==null?void 0:r.isRTL(o.floating))?"start":"end")?"left":"right"):(y=l,g=h==="end"?"top":"bottom");let m=u-f.top-f.bottom,d=c-f.left-f.right,v=H(u-f[g],m),x=H(c-f[y],d),O=!n.middlewareData.shift,S=v,R=x;if(p?R=h||O?H(x,d):d:S=h||O?H(v,m):m,O&&!h){let V=k(f.left,0),T=k(f.right,0),b=k(f.top,0),P=k(f.bottom,0);p?R=c-2*(V!==0||T!==0?V+T:k(f.left,f.right)):S=u-2*(b!==0||P!==0?b+P:k(f.top,f.bottom))}await s({...n,availableWidth:R,availableHeight:S});let M=await r.getDimensions(o.floating);return c!==M.width||u!==M.height?{reset:{rects:!0}}:{}}}};function Et(t){return An(t)?(t.nodeName||"").toLowerCase():"#document"}function _(t){var n;return(t==null||(n=t.ownerDocument)==null?void 0:n.defaultView)||window}function J(t){var n;return(n=(An(t)?t.ownerDocument:t.document)||window.document)==null?void 0:n.documentElement}function An(t){return t instanceof Node||t instanceof _(t).Node}function X(t){return t instanceof Element||t instanceof _(t).Element}function G(t){return t instanceof HTMLElement||t instanceof _(t).HTMLElement}function Sn(t){return typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof _(t).ShadowRoot}function Tt(t){let{overflow:n,overflowX:e,overflowY:i,display:r}=Y(t);return/auto|scroll|overlay|hidden|clip/.test(n+i+e)&&!["inline","contents"].includes(r)}function Rn(t){return["table","td","th"].includes(Et(t))}function oe(t){let n=se(),e=Y(t);return e.transform!=="none"||e.perspective!=="none"||(e.containerType?e.containerType!=="normal":!1)||!n&&(e.backdropFilter?e.backdropFilter!=="none":!1)||!n&&(e.filter?e.filter!=="none":!1)||["transform","perspective","filter"].some(i=>(e.willChange||"").includes(i))||["paint","layout","strict","content"].some(i=>(e.contain||"").includes(i))}function Cn(t){let n=nt(t);for(;G(n)&&!vt(n);){if(oe(n))return n;n=nt(n)}return null}function se(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function vt(t){return["html","body","#document"].includes(Et(t))}function Y(t){return _(t).getComputedStyle(t)}function Ft(t){return X(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function nt(t){if(Et(t)==="html")return t;let n=t.assignedSlot||t.parentNode||Sn(t)&&t.host||J(t);return Sn(n)?n.host:n}function In(t){let n=nt(t);return vt(n)?t.ownerDocument?t.ownerDocument.body:t.body:G(n)&&Tt(n)?n:In(n)}function Pt(t,n,e){var i;n===void 0&&(n=[]),e===void 0&&(e=!0);let r=In(t),o=r===((i=t.ownerDocument)==null?void 0:i.body),s=_(r);return o?n.concat(s,s.visualViewport||[],Tt(r)?r:[],s.frameElement&&e?Pt(s.frameElement):[]):n.concat(r,Pt(r,[],e))}function Nn(t){let n=Y(t),e=parseFloat(n.width)||0,i=parseFloat(n.height)||0,r=G(t),o=r?t.offsetWidth:e,s=r?t.offsetHeight:i,a=Dt(e)!==o||Dt(i)!==s;return a&&(e=o,i=s),{width:e,height:i,$:a}}function Te(t){return X(t)?t:t.contextElement}function St(t){let n=Te(t);if(!G(n))return tt(1);let e=n.getBoundingClientRect(),{width:i,height:r,$:o}=Nn(n),s=(o?Dt(e.width):e.width)/i,a=(o?Dt(e.height):e.height)/r;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var Nr=tt(0);function kn(t){let n=_(t);return!se()||!n.visualViewport?Nr:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function kr(t,n,e){return n===void 0&&(n=!1),!e||n&&e!==_(t)?!1:n}function wt(t,n,e,i){n===void 0&&(n=!1),e===void 0&&(e=!1);let r=t.getBoundingClientRect(),o=Te(t),s=tt(1);n&&(i?X(i)&&(s=St(i)):s=St(t));let a=kr(o,e,i)?kn(o):tt(0),f=(r.left+a.x)/s.x,l=(r.top+a.y)/s.y,h=r.width/s.x,p=r.height/s.y;if(o){let c=_(o),u=i&&X(i)?_(i):i,g=c,y=g.frameElement;for(;y&&i&&u!==g;){let m=St(y),d=y.getBoundingClientRect(),v=Y(y),x=d.left+(y.clientLeft+parseFloat(v.paddingLeft))*m.x,O=d.top+(y.clientTop+parseFloat(v.paddingTop))*m.y;f*=m.x,l*=m.y,h*=m.x,p*=m.y,f+=x,l+=O,g=_(y),y=g.frameElement}}return yt({width:h,height:p,x:f,y:l})}var Dr=[":popover-open",":modal"];function Se(t){return Dr.some(n=>{try{return t.matches(n)}catch{return!1}})}function _r(t){let{elements:n,rect:e,offsetParent:i,strategy:r}=t,o=r==="fixed",s=J(i),a=n?Se(n.floating):!1;if(i===s||a&&o)return e;let f={scrollLeft:0,scrollTop:0},l=tt(1),h=tt(0),p=G(i);if((p||!p&&!o)&&((Et(i)!=="body"||Tt(s))&&(f=Ft(i)),G(i))){let c=wt(i);l=St(i),h.x=c.x+i.clientLeft,h.y=c.y+i.clientTop}return{width:e.width*l.x,height:e.height*l.y,x:e.x*l.x-f.scrollLeft*l.x+h.x,y:e.y*l.y-f.scrollTop*l.y+h.y}}function Fr(t){return Array.from(t.getClientRects())}function Dn(t){return wt(J(t)).left+Ft(t).scrollLeft}function Wr(t){let n=J(t),e=Ft(t),i=t.ownerDocument.body,r=k(n.scrollWidth,n.clientWidth,i.scrollWidth,i.clientWidth),o=k(n.scrollHeight,n.clientHeight,i.scrollHeight,i.clientHeight),s=-e.scrollLeft+Dn(t),a=-e.scrollTop;return Y(i).direction==="rtl"&&(s+=k(n.clientWidth,i.clientWidth)-r),{width:r,height:o,x:s,y:a}}function Vr(t,n){let e=_(t),i=J(t),r=e.visualViewport,o=i.clientWidth,s=i.clientHeight,a=0,f=0;if(r){o=r.width,s=r.height;let l=se();(!l||l&&n==="fixed")&&(a=r.offsetLeft,f=r.offsetTop)}return{width:o,height:s,x:a,y:f}}function Br(t,n){let e=wt(t,!0,n==="fixed"),i=e.top+t.clientTop,r=e.left+t.clientLeft,o=G(t)?St(t):tt(1),s=t.clientWidth*o.x,a=t.clientHeight*o.y,f=r*o.x,l=i*o.y;return{width:s,height:a,x:f,y:l}}function Mn(t,n,e){let i;if(n==="viewport")i=Vr(t,e);else if(n==="document")i=Wr(J(t));else if(X(n))i=Br(n,e);else{let r=kn(t);i={...n,x:n.x-r.x,y:n.y-r.y}}return yt(i)}function _n(t,n){let e=nt(t);return e===n||!X(e)||vt(e)?!1:Y(e).position==="fixed"||_n(e,n)}function Hr(t,n){let e=n.get(t);if(e)return e;let i=Pt(t,[],!1).filter(a=>X(a)&&Et(a)!=="body"),r=null,o=Y(t).position==="fixed",s=o?nt(t):t;for(;X(s)&&!vt(s);){let a=Y(s),f=oe(s);!f&&a.position==="fixed"&&(r=null),(o?!f&&!r:!f&&a.position==="static"&&!!r&&["absolute","fixed"].includes(r.position)||Tt(s)&&!f&&_n(t,s))?i=i.filter(h=>h!==s):r=a,s=nt(s)}return n.set(t,i),i}function Yr(t){let{element:n,boundary:e,rootBoundary:i,strategy:r}=t,s=[...e==="clippingAncestors"?Se(n)?[]:Hr(n,this._c):[].concat(e),i],a=s[0],f=s.reduce((l,h)=>{let p=Mn(n,h,r);return l.top=k(p.top,l.top),l.right=H(p.right,l.right),l.bottom=H(p.bottom,l.bottom),l.left=k(p.left,l.left),l},Mn(n,a,r));return{width:f.right-f.left,height:f.bottom-f.top,x:f.left,y:f.top}}function Kr(t){let{width:n,height:e}=Nn(t);return{width:n,height:e}}function $r(t,n,e){let i=G(n),r=J(n),o=e==="fixed",s=wt(t,!0,o,n),a={scrollLeft:0,scrollTop:0},f=tt(0);if(i||!i&&!o)if((Et(n)!=="body"||Tt(r))&&(a=Ft(n)),i){let p=wt(n,!0,o,n);f.x=p.x+n.clientLeft,f.y=p.y+n.clientTop}else r&&(f.x=Dn(r));let l=s.left+a.scrollLeft-f.x,h=s.top+a.scrollTop-f.y;return{x:l,y:h,width:s.width,height:s.height}}function Pe(t){return Y(t).position==="static"}function Ln(t,n){return!G(t)||Y(t).position==="fixed"?null:n?n(t):t.offsetParent}function Fn(t,n){let e=_(t);if(Se(t))return e;if(!G(t)){let r=nt(t);for(;r&&!vt(r);){if(X(r)&&!Pe(r))return r;r=nt(r)}return e}let i=Ln(t,n);for(;i&&Rn(i)&&Pe(i);)i=Ln(i,n);return i&&vt(i)&&Pe(i)&&!oe(i)?e:i||Cn(t)||e}var Xr=async function(t){let n=this.getOffsetParent||Fn,e=this.getDimensions,i=await e(t.floating);return{reference:$r(t.reference,await n(t.floating),t.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Gr(t){return Y(t).direction==="rtl"}var jr={convertOffsetParentRelativeRectToViewportRelativeRect:_r,getDocumentElement:J,getClippingRect:Yr,getOffsetParent:Fn,getElementRects:Xr,getClientRects:Fr,getDimensions:Kr,getScale:St,isElement:X,isRTL:Gr};function Ur(t,n){let e=null,i,r=J(t);function o(){var a;clearTimeout(i),(a=e)==null||a.disconnect(),e=null}function s(a,f){a===void 0&&(a=!1),f===void 0&&(f=1),o();let{left:l,top:h,width:p,height:c}=t.getBoundingClientRect();if(a||n(),!p||!c)return;let u=_t(h),g=_t(r.clientWidth-(l+p)),y=_t(r.clientHeight-(h+c)),m=_t(l),v={rootMargin:-u+"px "+-g+"px "+-y+"px "+-m+"px",threshold:k(0,H(1,f))||1},x=!0;function O(S){let R=S[0].intersectionRatio;if(R!==f){if(!x)return s();R?s(!1,R):i=setTimeout(()=>{s(!1,1e-7)},1e3)}x=!1}try{e=new IntersectionObserver(O,{...v,root:r.ownerDocument})}catch{e=new IntersectionObserver(O,v)}e.observe(t)}return s(!0),o}function Wn(t,n,e,i){i===void 0&&(i={});let{ancestorScroll:r=!0,ancestorResize:o=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:f=!1}=i,l=Te(t),h=r||o?[...l?Pt(l):[],...Pt(n)]:[];h.forEach(d=>{r&&d.addEventListener("scroll",e,{passive:!0}),o&&d.addEventListener("resize",e)});let p=l&&a?Ur(l,e):null,c=-1,u=null;s&&(u=new ResizeObserver(d=>{let[v]=d;v&&v.target===l&&u&&(u.unobserve(n),cancelAnimationFrame(c),c=requestAnimationFrame(()=>{var x;(x=u)==null||x.observe(n)})),e()}),l&&!f&&u.observe(l),u.observe(n));let g,y=f?wt(t):null;f&&m();function m(){let d=wt(t);y&&(d.x!==y.x||d.y!==y.y||d.width!==y.width||d.height!==y.height)&&e(),y=d,g=requestAnimationFrame(m)}return e(),()=>{var d;h.forEach(v=>{r&&v.removeEventListener("scroll",e),o&&v.removeEventListener("resize",e)}),p?.(),(d=u)==null||d.disconnect(),u=null,f&&cancelAnimationFrame(g)}}var Vn=bn;var Bn=On,Hn=xn,Yn=Tn;var Kn=wn;var $n=Pn,Xn=(t,n,e)=>{let i=new Map,r={platform:jr,...e},o={...r.platform,_c:i};return vn(t,n,{...r,platform:o})};var jn=t=>t[0],Un=t=>t[t.length-1];var Gn=t=>t?.constructor.name==="Array",Ae=(t,n)=>{if(Object.is(t,n))return!0;if(t==null&&n!=null||t!=null&&n==null)return!1;if(typeof t?.isEqual=="function"&&typeof n?.isEqual=="function")return t.isEqual(n);if(typeof t=="function"&&typeof n=="function")return t.toString()===n.toString();if(Gn(t)&&Gn(n))return Array.from(t).toString()===Array.from(n).toString();if(typeof t!="object"||typeof n!="object")return!1;let e=Object.keys(n??Object.create(null)),i=e.length;for(let r=0;r<i;r++)if(!Reflect.has(t,e[r]))return!1;for(let r=0;r<i;r++){let o=e[r];if(!Ae(t[o],n[o]))return!1}return!0},zn=(t,...n)=>(typeof t=="function"?t(...n):t)??void 0,qn=t=>t,Jn=()=>{},Re=(...t)=>(...n)=>{t.forEach(function(e){e?.(...n)})};var Zn=t=>typeof t=="function",Qn=t=>t==null;function Wt(t){if(!zr(t)||t===void 0)return t;let n=Reflect.ownKeys(t).filter(i=>typeof i=="string"),e={};for(let i of n){let r=t[i];r!==void 0&&(e[i]=Wt(r))}return e}var zr=t=>t&&typeof t=="object"&&t.constructor===Object;function qr(t,n){let e={},i={},r=new Set(n);for(let o in t)r.has(o)?i[o]=t[o]:e[o]=t[o];return[i,e]}var At=t=>function(e){return qr(e,t)};function ti(...t){let n=t.length===1?t[0]:t[1],e=t.length===2?t[0]:!0}function ei(t=0,n=0,e=0,i=0){if(typeof DOMRect=="function")return new DOMRect(t,n,e,i);let r={x:t,y:n,width:e,height:i,top:n,right:t+e,bottom:n+i,left:t};return{...r,toJSON:()=>r}}function Jr(t){if(!t)return ei();let{x:n,y:e,width:i,height:r}=t;return ei(n,e,i,r)}function Zr(t,n){return{contextElement:N(t)?t:void 0,getBoundingClientRect:()=>{let e=t,i=n?.(e);return i||!e?Jr(i):e.getBoundingClientRect()}}}var Vt=t=>({variable:t,reference:`var(${t})`}),it={arrowSize:Vt("--arrow-size"),arrowSizeHalf:Vt("--arrow-size-half"),arrowBg:Vt("--arrow-background"),transformOrigin:Vt("--transform-origin"),arrowOffset:Vt("--arrow-offset")},Qr=t=>({top:"bottom center","top-start":t?`${t.x}px bottom`:"left bottom","top-end":t?`${t.x}px bottom`:"right bottom",bottom:"top center","bottom-start":t?`${t.x}px top`:"top left","bottom-end":t?`${t.x}px top`:"top right",left:"right center","left-start":t?`right ${t.y}px`:"right top","left-end":t?`right ${t.y}px`:"right bottom",right:"left center","right-start":t?`left ${t.y}px`:"left top","right-end":t?`left ${t.y}px`:"left bottom"}),to={name:"transformOrigin",fn({placement:t,elements:n,middlewareData:e}){let{arrow:i}=e,r=Qr(i)[t],{floating:o}=n;return o.style.setProperty(it.transformOrigin.variable,r),{data:{transformOrigin:r}}}},eo={name:"rects",fn({rects:t}){return{data:t}}},no=t=>{if(t)return{name:"shiftArrow",fn({placement:n,middlewareData:e}){if(!e.arrow)return{};let{x:i,y:r}=e.arrow,o=n.split("-")[0];return Object.assign(t.style,{left:i!=null?`${i}px`:"",top:r!=null?`${r}px`:"",[o]:`calc(100% + ${it.arrowOffset.reference})`}),{}}}};function io(t){let[n,e]=t.split("-");return{side:n,align:e,hasAlign:e!=null}}function ii(t){return t.split("-")[0]}var ro={strategy:"absolute",placement:"bottom",listeners:!0,gutter:8,flip:!0,slide:!0,overlap:!1,sameWidth:!1,fitViewport:!1,overflowPadding:8,arrowPadding:4};function ni(t,n){let e=t.devicePixelRatio||1;return Math.round(n*e)/e}function ri(t){return zn(t.boundary)}function oo(t,n){if(t)return Kn({element:t,padding:n.arrowPadding})}function so(t,n){if(!Qn(n.offset??n.gutter))return Vn(({placement:e})=>{let i=(t?.clientHeight||0)/2,r=n.offset?.mainAxis??n.gutter,o=typeof r=="number"?r+i:r??i,{hasAlign:s}=io(e),a=s?void 0:n.shift,f=n.offset?.crossAxis??a;return Wt({crossAxis:f,mainAxis:o,alignmentAxis:n.shift})})}function co(t){if(t.flip)return Hn({boundary:ri(t),padding:t.overflowPadding,fallbackPlacements:t.flip===!0?void 0:t.flip})}function ao(t){if(!(!t.slide&&!t.overlap))return Bn({boundary:ri(t),mainAxis:t.slide,crossAxis:t.overlap,padding:t.overflowPadding,limiter:$n()})}function lo(t){return Yn({padding:t.overflowPadding,apply({elements:n,rects:e,availableHeight:i,availableWidth:r}){let o=n.floating,s=Math.round(e.reference.width);r=Math.floor(r),i=Math.floor(i),o.style.setProperty("--reference-width",`${s}px`),o.style.setProperty("--available-width",`${r}px`),o.style.setProperty("--available-height",`${i}px`)}})}function uo(t){return t?t===!0?{ancestorResize:!0,ancestorScroll:!0,elementResize:!0,layoutShift:!0}:t:{}}function fo(t,n,e={}){let i=Zr(t,e.getAnchorRect);if(!n||!i)return;let r=Object.assign({},ro,e),o=n.querySelector("[data-part=arrow]"),s=[so(o,r),co(r),ao(r),oo(o,r),no(o),to,lo(r),eo],{placement:a,strategy:f,onComplete:l,onPositioned:h}=r,p=async()=>{if(!i||!n)return;let y=await Xn(i,n,{placement:a,middleware:s,strategy:f});l?.(y),h?.({placed:!0});let m=ht(n),d=ni(m,y.x),v=ni(m,y.y);n.style.setProperty("--x",`${d}px`),n.style.setProperty("--y",`${v}px`);let x=n.firstElementChild;if(x){let O=m.getComputedStyle(x).zIndex;n.style.setProperty("--z-index",O)}},c=async()=>{e.updatePosition?(await e.updatePosition({updatePosition:p}),h?.({placed:!0})):await p()},u=uo(r.listeners),g=r.listeners?Wn(i,n,c,u):Jn;return c(),()=>{g?.(),h?.({placed:!1})}}function Ce(t,n,e={}){let{defer:i,...r}=e,o=i?W:a=>a(),s=[];return s.push(o(()=>{let a=typeof t=="function"?t():t,f=typeof n=="function"?n():n;s.push(fo(a,f,r))})),()=>{s.forEach(a=>a?.())}}var ho={bottom:"rotate(45deg)",left:"rotate(135deg)",top:"rotate(225deg)",right:"rotate(315deg)"};function oi(t={}){let{placement:n,sameWidth:e,fitViewport:i,strategy:r="absolute"}=t;return{arrow:{position:"absolute",width:it.arrowSize.reference,height:it.arrowSize.reference,[it.arrowSizeHalf.variable]:`calc(${it.arrowSize.reference} / 2)`,[it.arrowOffset.variable]:`calc(${it.arrowSizeHalf.reference} * -1)`},arrowTip:{transform:n?ho[n.split("-")[0]]:void 0,background:it.arrowBg.reference,top:"0",left:"0",width:"100%",height:"100%",position:"absolute",zIndex:"inherit"},floating:{position:r,isolation:"isolate",minWidth:e?void 0:"max-content",width:e?"var(--reference-width)":void 0,maxWidth:i?"var(--available-width)":void 0,maxHeight:i?"var(--available-height)":void 0,top:"0px",left:"0px",transform:n?"translate3d(var(--x), var(--y), 0)":"translate3d(0, -100vh, 0)",zIndex:"var(--z-index)"}}}function go(t){let n={each(e){for(let i=0;i<t.frames?.length;i+=1){let r=t.frames[i];r&&e(r)}},addEventListener(e,i,r){return n.each(o=>{try{o.document.addEventListener(e,i,r)}catch{}}),()=>{try{n.removeEventListener(e,i,r)}catch{}}},removeEventListener(e,i,r){n.each(o=>{try{o.document.removeEventListener(e,i,r)}catch{}})}};return n}var si="pointerdown.outside",ci="focus.outside";function po(t){for(let n of t)if(N(n)&&Ut(n))return!0;return!1}var ai=t=>"clientY"in t;function mo(t,n){if(!ai(n)||!t)return!1;let e=t.getBoundingClientRect();return e.width===0||e.height===0?!1:e.top<=n.clientY&&n.clientY<=e.top+e.height&&e.left<=n.clientX&&n.clientX<=e.left+e.width}function yo(t){let n=z(t);if(!n||!ai(t))return!1;let i=n.scrollHeight>n.clientHeight&&t.clientX>n.clientWidth,o=n.scrollWidth>n.clientWidth&&t.clientY>n.clientHeight;return i||o}function Eo(t,n){let{exclude:e,onFocusOutside:i,onPointerDownOutside:r,onInteractOutside:o,defer:s}=n;if(!t)return;let a=dt(t),f=ht(t),l=go(f);function h(m){let d=z(m);return!N(d)||U(t,d)||mo(t,m)||yo(m)?!1:!e?.(d)}let p;function c(m){function d(){let v=s?W:O=>O(),x=m.composedPath?.()??[m.target];v(()=>{if(!(!t||!h(m))){if(r||o){let O=Re(r,o);t.addEventListener(si,O,{once:!0})}xe(t,si,{bubbles:!1,cancelable:!0,detail:{originalEvent:m,contextmenu:Jt(m),focusable:po(x)}})}})}m.pointerType==="touch"?(l.removeEventListener("click",d),a.removeEventListener("click",d),p=d,a.addEventListener("click",d,{once:!0}),l.addEventListener("click",d,{once:!0})):d()}let u=new Set,g=setTimeout(()=>{u.add(l.addEventListener("pointerdown",c,!0)),u.add(gt(a,"pointerdown",c,!0))},0);function y(m){(s?W:v=>v())(()=>{if(!(!t||!h(m))){if(i||o){let v=Re(i,o);t.addEventListener(ci,v,{once:!0})}xe(t,ci,{bubbles:!1,cancelable:!0,detail:{originalEvent:m,contextmenu:!1,focusable:Ut(z(m))}})}})}return u.add(gt(a,"focusin",y,!0)),u.add(l.addEventListener("focusin",y,!0)),()=>{clearTimeout(g),p&&(l.removeEventListener("click",p),a.removeEventListener("click",p)),u.forEach(m=>m())}}function li(t,n){let{defer:e}=n,i=e?W:o=>o(),r=[];return r.push(i(()=>{let o=typeof t=="function"?t():t;r.push(Eo(o,n))})),()=>{r.forEach(o=>o?.())}}function vo(t,n){let e=i=>{i.key==="Escape"&&(i.isComposing||n?.(i))};return gt(dt(t),"keydown",e,{capture:!0})}var j={layers:[],branches:[],count(){return this.layers.length},pointerBlockingLayers(){return this.layers.filter(t=>t.pointerBlocking)},topMostPointerBlockingLayer(){return[...this.pointerBlockingLayers()].slice(-1)[0]},hasPointerBlockingLayer(){return this.pointerBlockingLayers().length>0},isBelowPointerBlockingLayer(t){let n=this.indexOf(t),e=this.topMostPointerBlockingLayer()?this.indexOf(this.topMostPointerBlockingLayer()?.node):-1;return n<e},isTopMost(t){return this.layers[this.count()-1]?.node===t},getNestedLayers(t){return Array.from(this.layers).slice(this.indexOf(t)+1)},isInNestedLayer(t,n){return this.getNestedLayers(t).some(e=>U(e.node,n))},isInBranch(t){return Array.from(this.branches).some(n=>U(n,t))},add(t){let n=this.layers.push(t);t.node.style.setProperty("--layer-index",`${n}`)},addBranch(t){this.branches.push(t)},remove(t){let n=this.indexOf(t);n<0||(n<this.count()-1&&this.getNestedLayers(t).forEach(i=>i.dismiss()),this.layers.splice(n,1),t.style.removeProperty("--layer-index"))},removeBranch(t){let n=this.branches.indexOf(t);n>=0&&this.branches.splice(n,1)},indexOf(t){return this.layers.findIndex(n=>n.node===t)},dismiss(t){this.layers[this.indexOf(t)]?.dismiss()},clear(){this.remove(this.layers[0].node)}},ui;function fi(){j.layers.forEach(({node:t})=>{t.style.pointerEvents=j.isBelowPointerBlockingLayer(t)?"none":"auto"})}function wo(t){t.style.pointerEvents=""}function xo(t,n){let e=dt(t),i=[];if(j.hasPointerBlockingLayer()&&!e.body.hasAttribute("data-inert")&&(ui=document.body.style.pointerEvents,queueMicrotask(()=>{e.body.style.pointerEvents="none",e.body.setAttribute("data-inert","")})),n){let r=fn(n,o=>{i.push(un(o,{pointerEvents:"auto"}))});i.push(r)}return()=>{j.hasPointerBlockingLayer()||(queueMicrotask(()=>{e.body.style.pointerEvents=ui,e.body.removeAttribute("data-inert"),e.body.style.length===0&&e.body.removeAttribute("style")}),i.forEach(r=>r()))}}function bo(t,n){if(!t){ti("[@zag-js/dismissable] node is `null` or `undefined`");return}let{onDismiss:e,pointerBlocking:i,exclude:r,debug:o}=n,s={dismiss:e,node:t,pointerBlocking:i};j.add(s),fi();function a(c){let u=z(c.detail.originalEvent);j.isBelowPointerBlockingLayer(t)||j.isInBranch(u)||(n.onPointerDownOutside?.(c),n.onInteractOutside?.(c),!c.defaultPrevented&&(o&&console.log("onPointerDownOutside:",c.detail.originalEvent),e?.()))}function f(c){let u=z(c.detail.originalEvent);j.isInBranch(u)||(n.onFocusOutside?.(c),n.onInteractOutside?.(c),!c.defaultPrevented&&(o&&console.log("onFocusOutside:",c.detail.originalEvent),e?.()))}function l(c){j.isTopMost(t)&&(n.onEscapeKeyDown?.(c),!c.defaultPrevented&&e&&(c.preventDefault(),e()))}function h(c){if(!t)return!1;let u=typeof r=="function"?r():r,g=Array.isArray(u)?u:[u],y=n.persistentElements?.map(m=>m()).filter(N);return y&&g.push(...y),g.some(m=>U(m,c))||j.isInNestedLayer(t,c)}let p=[i?xo(t,n.persistentElements):void 0,vo(t,l),li(t,{exclude:h,onFocusOutside:f,onPointerDownOutside:a,defer:n.defer})];return()=>{j.remove(t),fi(),wo(t),p.forEach(c=>c?.())}}function di(t,n){let{defer:e}=n,i=e?W:o=>o(),r=[];return r.push(i(()=>{let o=Zn(t)?t():t;r.push(bo(o,n))})),()=>{r.forEach(o=>o?.())}}var Bt=(t,n)=>({x:t,y:n});function Oo(t){let{x:n,y:e,width:i,height:r}=t,o=n+i/2,s=e+r/2;return{x:n,y:e,width:i,height:r,minX:n,minY:e,maxX:n+i,maxY:e+r,midX:o,midY:s,center:Bt(o,s)}}function Po(t){let n=Bt(t.minX,t.minY),e=Bt(t.maxX,t.minY),i=Bt(t.maxX,t.maxY),r=Bt(t.minX,t.maxY);return{top:n,right:e,bottom:i,left:r}}var{min:Rs,max:Cs}=Math;function hi(t,n){let e=Oo(t),{top:i,right:r,left:o,bottom:s}=Po(e),[a]=n.split("-");return{top:[o,i,r,s],right:[i,r,s,o],bottom:[i,o,s,r],left:[r,i,o,s]}[a]}function gi(t,n){let{x:e,y:i}=n,r=!1;for(let o=0,s=t.length-1;o<t.length;s=o++){let a=t[o].x,f=t[o].y,l=t[s].x,h=t[s].y;f>i!=h>i&&e<(l-a)*(i-f)/(h-f)+a&&(r=!r)}return r}var{sign:Is,abs:Ms,min:Ls}=Math;function pi(t){return new Proxy({},{get(){return t}})}var Rt=()=>t=>Array.from(new Set(t));var To=Ct("menu").parts("arrow","arrowTip","content","contextTrigger","indicator","item","itemGroup","itemGroupLabel","itemIndicator","itemText","positioner","separator","trigger","triggerItem"),D=To.build(),w=an({getTriggerId:t=>t.ids?.trigger??`menu:${t.id}:trigger`,getContextTriggerId:t=>t.ids?.contextTrigger??`menu:${t.id}:ctx-trigger`,getContentId:t=>t.ids?.content??`menu:${t.id}:content`,getArrowId:t=>t.ids?.arrow??`menu:${t.id}:arrow`,getPositionerId:t=>t.ids?.positioner??`menu:${t.id}:popper`,getGroupId:(t,n)=>t.ids?.group?.(n)??`menu:${t.id}:group:${n}`,getGroupLabelId:(t,n)=>t.ids?.label?.(n)??`menu:${t.id}:label:${n}`,getContentEl:t=>w.getById(t,w.getContentId(t)),getPositionerEl:t=>w.getById(t,w.getPositionerId(t)),getTriggerEl:t=>w.getById(t,w.getTriggerId(t)),getHighlightedItemEl:t=>t.highlightedValue?w.getById(t,t.highlightedValue):null,getArrowEl:t=>w.getById(t,w.getArrowId(t)),getElements:t=>{let e=`[role^="menuitem"][data-ownedby=${CSS.escape(w.getContentId(t))}]:not([data-disabled])`;return cn(w.getContentEl(t),e)},getFirstEl:t=>jn(w.getElements(t)),getLastEl:t=>Un(w.getElements(t)),getNextEl:(t,n)=>Qe(w.getElements(t),t.highlightedValue,n??t.loopFocus),getPrevEl:(t,n)=>tn(w.getElements(t),t.highlightedValue,n??t.loopFocus),getElemByKey:(t,n)=>jt(w.getElements(t),{state:t.typeaheadState,key:n,activeId:t.highlightedValue}),isTargetDisabled:t=>N(t)&&(t.dataset.disabled===""||t.hasAttribute("disabled")),isTriggerItem:t=>!!t?.getAttribute("role")?.startsWith("menuitem")&&!!t?.hasAttribute("aria-controls"),getOptionFromItemEl(t){return{id:t.id,name:t.dataset.name,value:t.dataset.value,valueText:t.dataset.valueText,type:t.dataset.type}}});function Ie(t,n,e){let i=t.context.isSubmenu,r=t.context.isTypingAhead,o=t.context.composite,s=t.hasTag("open"),a=oi({...t.context.positioning,placement:t.context.anchorPoint?"bottom":t.context.currentPlacement});function f(c){return{disabled:!!c.disabled,highlighted:t.context.highlightedValue===c.value}}function l(c){let u=c.valueText??c.value;return{...c,id:c.value,valueText:u}}function h(c){return{...f(l(c)),checked:!!c.checked}}function p(c){let{value:u,closeOnSelect:g,valueText:y}=c,m=f(c);return e.element({...D.item.attrs,id:u,role:"menuitem","aria-disabled":m.disabled,"data-disabled":ft(m.disabled),"data-ownedby":w.getContentId(t.context),"data-highlighted":ft(m.highlighted),"data-valuetext":y,onDragStart(d){d.currentTarget.matches("a[href]")&&d.preventDefault()},onPointerMove(d){if(m.disabled||d.pointerType!=="mouse")return;let v=d.currentTarget;m.highlighted||n({type:"ITEM_POINTERMOVE",id:u,target:v,closeOnSelect:g})},onPointerLeave(d){if(m.disabled||d.pointerType!=="mouse"||!t.previousEvent.type.includes("POINTER"))return;let x=d.currentTarget;n({type:"ITEM_POINTERLEAVE",id:u,target:x,closeOnSelect:g})},onPointerDown(d){if(m.disabled)return;let v=d.currentTarget;n({type:"ITEM_POINTERDOWN",target:v,id:u,closeOnSelect:g})},onPointerUp(d){if(me(d)||pe(d)||m.disabled||!qt(d))return;let v=d.currentTarget;n({type:"ITEM_CLICK",src:"pointerup",target:v,id:u,closeOnSelect:g}),d.pointerType==="touch"&&we(v)},onTouchEnd(d){d.preventDefault(),d.stopPropagation()}})}return{highlightedValue:t.context.highlightedValue,open:s,setOpen(c){c!==s&&n(c?"OPEN":"CLOSE")},setHighlightedValue(c){n({type:"HIGHLIGHTED.SET",id:c})},setParent(c){n({type:"PARENT.SET",value:c,id:c.state.context.id})},setChild(c){n({type:"CHILD.SET",value:c,id:c.state.context.id})},reposition(c={}){n({type:"POSITIONING.SET",options:c})},contextTriggerProps:e.element({...D.contextTrigger.attrs,dir:t.context.dir,id:w.getContextTriggerId(t.context),onPointerDown(c){if(c.pointerType==="mouse")return;let u=Ot(c),g=Zt(u);n({type:"CONTEXT_MENU_START",point:g})},onPointerCancel(c){c.pointerType!=="mouse"&&n("CONTEXT_MENU_CANCEL")},onPointerMove(c){c.pointerType!=="mouse"&&n("CONTEXT_MENU_CANCEL")},onPointerUp(c){c.pointerType!=="mouse"&&n("CONTEXT_MENU_CANCEL")},onContextMenu(c){let u=Ot(c),g=Zt(u);n({type:"CONTEXT_MENU",point:g}),c.preventDefault()},style:{WebkitTouchCallout:"none",userSelect:"none"}}),getTriggerItemProps(c){return Ge(p({value:c.triggerProps.id}),c.triggerProps)},triggerProps:e.button({...i?D.triggerItem.attrs:D.trigger.attrs,"data-placement":t.context.currentPlacement,type:"button",dir:t.context.dir,id:w.getTriggerId(t.context),"data-uid":t.context.id,"aria-haspopup":o?"menu":"dialog","aria-controls":w.getContentId(t.context),"aria-expanded":s||void 0,"data-state":s?"open":"closed",onPointerMove(c){c.pointerType!=="mouse"||w.isTargetDisabled(c.currentTarget)||!i||n({type:"TRIGGER_POINTERMOVE",target:c.currentTarget})},onPointerLeave(c){if(c.pointerType!=="mouse")return;let u=Ot(c);if(w.isTargetDisabled(c.currentTarget)||!i)return;let y=Zt(u);n({type:"TRIGGER_POINTERLEAVE",target:c.currentTarget,point:y})},onClick(c){w.isTriggerItem(c.currentTarget)&&n({type:"TRIGGER_CLICK",target:c.currentTarget})},onPointerDown(c){let u=w.isTargetDisabled(c.currentTarget),g=Ot(c);!qt(g)||u||Jt(c)||(c.preventDefault(),w.isTriggerItem(c.currentTarget)||n({type:"TRIGGER_CLICK",target:c.currentTarget}))},onBlur(){n("TRIGGER_BLUR")},onFocus(){n("TRIGGER_FOCUS")},onKeyDown(c){if(c.defaultPrevented)return;let u={ArrowDown(){n("ARROW_DOWN")},ArrowUp(){n("ARROW_UP")},Enter(){n({type:"ARROW_DOWN",src:"enter"})},Space(){n({type:"ARROW_DOWN",src:"space"})}},g=be(c,t.context),y=u[g];y&&(c.preventDefault(),y(c))}}),indicatorProps:e.element({...D.indicator.attrs,dir:t.context.dir,"data-state":s?"open":"closed"}),positionerProps:e.element({...D.positioner.attrs,dir:t.context.dir,id:w.getPositionerId(t.context),style:a.floating}),arrowProps:e.element({id:w.getArrowId(t.context),...D.arrow.attrs,dir:t.context.dir,style:a.arrow}),arrowTipProps:e.element({...D.arrowTip.attrs,dir:t.context.dir,style:a.arrowTip}),contentProps:e.element({...D.content.attrs,id:w.getContentId(t.context),"aria-label":t.context["aria-label"],hidden:!s,"data-state":s?"open":"closed",role:o?"menu":"dialog",tabIndex:0,dir:t.context.dir,"aria-activedescendant":t.context.highlightedValue??void 0,"aria-labelledby":w.getTriggerId(t.context),"data-placement":t.context.currentPlacement,onPointerEnter(c){c.pointerType==="mouse"&&n("MENU_POINTERENTER")},onKeyDown(c){if(c.defaultPrevented)return;let u=Ot(c);if(!Ze(u))return;let g=z(u);if(!(g?.closest("[role=menu]")===c.currentTarget||g===c.currentTarget))return;if(c.key==="Tab"&&!on(c)){c.preventDefault();return}let m=w.getHighlightedItemEl(t.context),d={ArrowDown(){n("ARROW_DOWN")},ArrowUp(){n("ARROW_UP")},ArrowLeft(){n("ARROW_LEFT")},ArrowRight(){n("ARROW_RIGHT")},Enter(){n("ENTER"),we(m)},Space(O){r?n({type:"TYPEAHEAD",key:O.key}):d.Enter?.(O)},Home(){n("HOME")},End(){n("END")}},v=be(c,{dir:t.context.dir}),x=d[v];if(x){x(c),c.stopPropagation(),c.preventDefault();return}t.context.typeahead&&hn(c)&&(gn(c)||zt(g)||(n({type:"TYPEAHEAD",key:c.key}),c.preventDefault()))}}),separatorProps:e.element({...D.separator.attrs,role:"separator",dir:t.context.dir,"aria-orientation":"horizontal"}),getItemState:f,getItemProps:p,getOptionItemState:h,getOptionItemProps(c){let{type:u,disabled:g,onCheckedChange:y,closeOnSelect:m}=c,d=l(c),v=h(c);return{...p(d),...e.element({"data-type":u,...D.item.attrs,dir:t.context.dir,"data-value":d.value,role:`menuitem${u}`,"aria-checked":!!v.checked,"data-state":v.checked?"checked":"unchecked",onPointerUp(x){if(!qt(x)||g||me(x)||pe(x))return;let O=x.currentTarget;n({type:"ITEM_CLICK",src:"pointerup",target:O,option:d,closeOnSelect:m}),y?.(!v.checked)}})}},getItemIndicatorProps(c){let u=h(c);return e.element({...D.itemIndicator.attrs,dir:t.context.dir,"data-disabled":ft(u.disabled),"data-highlighted":ft(u.highlighted),"data-state":u.checked?"checked":"unchecked",hidden:!u.checked})},getItemTextProps(c){let u=h(c);return e.element({...D.itemText.attrs,dir:t.context.dir,"data-disabled":ft(u.disabled),"data-highlighted":ft(u.highlighted),"data-state":u.checked?"checked":"unchecked"})},getItemGroupLabelProps(c){return e.element({id:w.getGroupLabelId(t.context,c.htmlFor),dir:t.context.dir,...D.itemGroupLabel.attrs})},getItemGroupProps(c){return e.element({id:w.getGroupId(t.context,c.id),...D.itemGroup.attrs,dir:t.context.dir,"aria-labelledby":w.getGroupLabelId(t.context,c.id),role:"group"})}}}var{not:K,and:xt,or:So}=Ke;function yi(t){let n=Wt(t);return Xe({id:"menu",initial:n.open?"open":"idle",context:{highlightedValue:null,loopFocus:!1,anchorPoint:null,closeOnSelect:!0,typeahead:!0,composite:!0,...n,positioning:{placement:"bottom-start",gutter:8,...n.positioning},intentPolygon:null,parent:null,lastHighlightedValue:null,children:qn(ot({})),suspendPointer:!1,restoreFocus:!0,typeaheadState:jt.defaultOptions},computed:{isSubmenu:e=>e.parent!==null,isRtl:e=>e.dir==="rtl",isTypingAhead:e=>e.typeaheadState.keysSoFar!==""},watch:{isSubmenu:"setSubmenuPlacement",anchorPoint:"reposition",open:"toggleVisibility"},on:{"PARENT.SET":{actions:"setParentMenu"},"CHILD.SET":{actions:"setChildMenu"},OPEN:[{guard:"isOpenControlled",actions:"invokeOnOpen"},{target:"open",actions:"invokeOnOpen"}],OPEN_AUTOFOCUS:[{guard:"isOpenControlled",actions:["invokeOnOpen"]},{internal:!0,target:"open",actions:["highlightFirstItem","invokeOnOpen"]}],CLOSE:[{guard:"isOpenControlled",actions:"invokeOnClose"},{target:"closed",actions:"invokeOnClose"}],"HIGHLIGHTED.RESTORE":{actions:"restoreHighlightedItem"},"HIGHLIGHTED.SET":{actions:"setHighlightedItem"}},states:{idle:{tags:["closed"],on:{"CONTROLLED.OPEN":"open","CONTROLLED.CLOSE":"closed",CONTEXT_MENU_START:{target:"opening:contextmenu",actions:"setAnchorPoint"},CONTEXT_MENU:[{guard:"isOpenControlled",actions:["setAnchorPoint","invokeOnOpen"]},{target:"open",actions:["setAnchorPoint","invokeOnOpen"]}],TRIGGER_CLICK:[{guard:"isOpenControlled",actions:"invokeOnOpen"},{target:"open",actions:"invokeOnOpen"}],TRIGGER_FOCUS:{guard:K("isSubmenu"),target:"closed"},TRIGGER_POINTERMOVE:{guard:"isSubmenu",target:"opening"}}},"opening:contextmenu":{tags:["closed"],after:{LONG_PRESS_DELAY:[{guard:"isOpenControlled",actions:"invokeOnOpen"},{target:"open",actions:"invokeOnOpen"}]},on:{"CONTROLLED.OPEN":"open","CONTROLLED.CLOSE":"closed",CONTEXT_MENU_CANCEL:[{guard:"isOpenControlled",actions:"invokeOnClose"},{target:"closed",actions:"invokeOnClose"}]}},opening:{tags:["closed"],after:{SUBMENU_OPEN_DELAY:[{guard:"isOpenControlled",actions:"invokeOnOpen"},{target:"open",actions:"invokeOnOpen"}]},on:{"CONTROLLED.OPEN":"open","CONTROLLED.CLOSE":"closed",BLUR:[{guard:"isOpenControlled",actions:"invokeOnClose"},{target:"closed",actions:"invokeOnClose"}],TRIGGER_POINTERLEAVE:[{guard:"isOpenControlled",actions:"invokeOnClose"},{target:"closed",actions:"invokeOnClose"}]}},closing:{tags:["open"],activities:["trackPointerMove","trackInteractOutside"],after:{SUBMENU_CLOSE_DELAY:[{guard:"isOpenControlled",actions:["invokeOnClose"]},{target:"closed",actions:["focusParentMenu","restoreParentHiglightedItem","invokeOnClose"]}]},on:{"CONTROLLED.OPEN":"open","CONTROLLED.CLOSE":{target:"closed",actions:["focusParentMenu","restoreParentHiglightedItem"]},MENU_POINTERENTER:{target:"open",actions:"clearIntentPolygon"},POINTER_MOVED_AWAY_FROM_SUBMENU:[{guard:"isOpenControlled",actions:"invokeOnClose"},{target:"closed",actions:["focusParentMenu","restoreParentHiglightedItem"]}]}},closed:{tags:["closed"],entry:["clearHighlightedItem","focusTrigger","clearAnchorPoint","resumePointer"],on:{"CONTROLLED.OPEN":[{guard:So("isOpenAutoFocusEvent","isArrowDownEvent"),target:"open",actions:"highlightFirstItem"},{guard:"isArrowUpEvent",target:"open",actions:"highlightLastItem"},{target:"open"}],CONTEXT_MENU_START:{target:"opening:contextmenu",actions:"setAnchorPoint"},CONTEXT_MENU:[{guard:"isOpenControlled",actions:["setAnchorPoint","invokeOnOpen"]},{target:"open",actions:["setAnchorPoint","invokeOnOpen"]}],TRIGGER_CLICK:[{guard:"isOpenControlled",actions:"invokeOnOpen"},{target:"open",actions:"invokeOnOpen"}],TRIGGER_POINTERMOVE:{guard:"isTriggerItem",target:"opening"},TRIGGER_BLUR:"idle",ARROW_DOWN:[{guard:"isOpenControlled",actions:"invokeOnOpen"},{target:"open",actions:["highlightFirstItem","invokeOnOpen"]}],ARROW_UP:[{guard:"isOpenControlled",actions:"invokeOnOpen"},{target:"open",actions:["highlightLastItem","invokeOnOpen"]}]}},open:{tags:["open"],activities:["trackInteractOutside","trackPositioning","scrollToHighlightedItem"],entry:["focusMenu","resumePointer"],on:{"CONTROLLED.CLOSE":[{target:"closed",guard:"isArrowLeftEvent",actions:["focusParentMenu"]},{target:"closed"}],TRIGGER_CLICK:[{guard:xt(K("isTriggerItem"),"isOpenControlled"),actions:"invokeOnClose"},{guard:K("isTriggerItem"),target:"closed",actions:"invokeOnClose"}],ARROW_UP:{actions:["highlightPrevItem","focusMenu"]},ARROW_DOWN:{actions:["highlightNextItem","focusMenu"]},ARROW_LEFT:[{guard:xt("isSubmenu","isOpenControlled"),actions:"invokeOnClose"},{guard:"isSubmenu",target:"closed",actions:["focusParentMenu","invokeOnClose"]}],HOME:{actions:["highlightFirstItem","focusMenu"]},END:{actions:["highlightLastItem","focusMenu"]},ARROW_RIGHT:{guard:"isTriggerItemHighlighted",actions:"openSubmenu"},ENTER:[{guard:"isTriggerItemHighlighted",actions:"openSubmenu"},{guard:xt("closeOnSelect","isOpenControlled"),actions:["clickHighlightedItem","invokeOnClose"]},{guard:"closeOnSelect",target:"closed",actions:"clickHighlightedItem"},{actions:"clickHighlightedItem"}],ITEM_POINTERMOVE:[{guard:K("suspendPointer"),actions:["setHighlightedItem","focusMenu"]},{actions:"setLastHighlightedItem"}],ITEM_POINTERLEAVE:{guard:xt(K("suspendPointer"),K("isTriggerItem")),actions:"clearHighlightedItem"},ITEM_CLICK:[{guard:xt(K("isTriggerItemHighlighted"),K("isHighlightedItemEditable"),"closeOnSelect","isOpenControlled"),actions:["invokeOnSelect","setOptionState","closeRootMenu","invokeOnClose"]},{guard:xt(K("isTriggerItemHighlighted"),K("isHighlightedItemEditable"),"closeOnSelect"),target:"closed",actions:["invokeOnSelect","setOptionState","closeRootMenu","invokeOnClose"]},{guard:xt(K("isTriggerItemHighlighted"),K("isHighlightedItemEditable")),actions:["invokeOnSelect","setOptionState"]},{actions:"setHighlightedItem"}],TRIGGER_POINTERLEAVE:{target:"closing",actions:"setIntentPolygon"},ITEM_POINTERDOWN:{actions:"setHighlightedItem"},TYPEAHEAD:{actions:"highlightMatchedItem"},FOCUS_MENU:{actions:"focusMenu"},"POSITIONING.SET":{actions:"reposition"}}}}},{delays:{LONG_PRESS_DELAY:700,SUBMENU_OPEN_DELAY:100,SUBMENU_CLOSE_DELAY:100},guards:{closeOnSelect:(e,i)=>!!(i?.closeOnSelect??e.closeOnSelect),isTriggerItem:(e,i)=>w.isTriggerItem(i.target),isTriggerItemHighlighted:(e,i)=>!!(i.target??w.getHighlightedItemEl(e))?.hasAttribute("aria-controls"),isSubmenu:e=>e.isSubmenu,suspendPointer:e=>e.suspendPointer,isHighlightedItemEditable:e=>zt(w.getHighlightedItemEl(e)),isWithinPolygon:(e,i)=>e.intentPolygon?gi(e.intentPolygon,i.point):!1,isOpenControlled:e=>!!e["open.controlled"],isArrowLeftEvent:(e,i)=>i.previousEvent?.type==="ARROW_LEFT",isArrowUpEvent:(e,i)=>i.previousEvent?.type==="ARROW_UP",isArrowDownEvent:(e,i)=>i.previousEvent?.type==="ARROW_DOWN",isOpenAutoFocusEvent:(e,i)=>i.previousEvent?.type==="OPEN_AUTOFOCUS"},activities:{trackPositioning(e){if(e.anchorPoint)return;e.currentPlacement=e.positioning.placement;let i=()=>w.getPositionerEl(e);return Ce(w.getTriggerEl(e),i,{...e.positioning,defer:!0,onComplete(r){e.currentPlacement=r.placement}})},trackInteractOutside(e,i,{send:r}){return di(()=>w.getContentEl(e),{defer:!0,exclude:[w.getTriggerEl(e)],onInteractOutside:e.onInteractOutside,onFocusOutside:e.onFocusOutside,onEscapeKeyDown(s){e.onEscapeKeyDown?.(s),e.isSubmenu&&s.preventDefault(),mi(e)},onPointerDownOutside(s){e.restoreFocus=!s.detail.focusable,e.onPointerDownOutside?.(s)},onDismiss(){r({type:"CLOSE",src:"interact-outside"})}})},trackPointerMove(e,i,{guards:r,send:o}){let{isWithinPolygon:s}=r;e.parent.state.context.suspendPointer=!0;let a=w.getDoc(e);return gt(a,"pointermove",f=>{let l={x:f.clientX,y:f.clientY};s(e,{point:l})||(o("POINTER_MOVED_AWAY_FROM_SUBMENU"),e.parent.state.context.suspendPointer=!1)})},scrollToHighlightedItem(e,i,{getState:r}){let o=()=>{if(r().event.type.startsWith("ITEM_POINTER"))return;let f=w.getHighlightedItemEl(e),l=w.getContentEl(e);ln(f,{rootEl:l,block:"nearest"})};return W(()=>o()),sn(()=>w.getContentEl(e),{defer:!0,attributes:["aria-activedescendant"],callback:o})}},actions:{setAnchorPoint(e,i){e.anchorPoint=i.point},clearAnchorPoint(e){e.anchorPoint=null},setSubmenuPlacement(e){e.isSubmenu&&(e.positioning.placement=e.isRtl?"left-start":"right-start",e.positioning.gutter=0)},reposition(e,i){let r=()=>w.getPositionerEl(e),o=e.anchorPoint?()=>({width:0,height:0,...e.anchorPoint}):void 0;Ce(w.getTriggerEl(e),r,{...e.positioning,getAnchorRect:o,...i.options??{},listeners:!1,onComplete(s){e.currentPlacement=s.placement}})},setOptionState(e,i){if(!i.option)return;let{checked:r,onCheckedChange:o,type:s}=i.option;s==="radio"?o?.(!0):s==="checkbox"&&o?.(!r)},clickHighlightedItem(e,i,{send:r}){let o=w.getHighlightedItemEl(e);if(!o||o.dataset.disabled)return;let s=w.getOptionFromItemEl(o);r({type:"ITEM_CLICK",src:"enter",target:o,id:s.id,option:s,closeOnSelect:e.closeOnSelect})},setIntentPolygon(e,i){let r=w.getContentEl(e),o=e.currentPlacement;if(!r||!o)return;let s=r.getBoundingClientRect(),a=hi(s,o);if(!a)return;let l=ii(o)==="right"?-5:5;e.intentPolygon=[{...i.point,x:i.point.x+l},...a]},clearIntentPolygon(e){e.intentPolygon=null},resumePointer(e){e.parent&&(e.parent.state.context.suspendPointer=!1)},setHighlightedItem(e,i){ct.highlighted(e,i.id)},clearHighlightedItem(e){ct.highlighted(e,null)},focusMenu(e){W(()=>{let i=w.getContentEl(e);if(U(i,w.getActiveElement(e)))return;(rn(i,!1)||i)?.focus({preventScroll:!0})})},highlightFirstItem(e){let i=w.getFirstEl(e);i&&ct.highlighted(e,i.id)},highlightLastItem(e){let i=w.getLastEl(e);i&&ct.highlighted(e,i.id)},highlightNextItem(e,i){let r=w.getNextEl(e,i.loop);ct.highlighted(e,r?.id??null)},highlightPrevItem(e,i){let r=w.getPrevEl(e,i.loop);ct.highlighted(e,r?.id??null)},invokeOnSelect(e){e.highlightedValue&&e.onSelect?.({value:e.highlightedValue})},focusTrigger(e){e.isSubmenu||e.anchorPoint||!e.restoreFocus||W(()=>w.getTriggerEl(e)?.focus({preventScroll:!0}))},highlightMatchedItem(e,i){let r=w.getElemByKey(e,i.key);r&&ct.highlighted(e,r.id)},setParentMenu(e,i){e.parent=ot(i.value)},setChildMenu(e,i){e.children[i.id]=ot(i.value)},closeRootMenu(e){mi(e)},openSubmenu(e){let r=w.getHighlightedItemEl(e)?.getAttribute("data-uid");(r?e.children[r]:null)?.send("OPEN_AUTOFOCUS")},focusParentMenu(e){e.parent?.send("FOCUS_MENU")},setLastHighlightedItem(e,i){e.lastHighlightedValue=i.id},restoreHighlightedItem(e){e.lastHighlightedValue&&(ct.highlighted(e,e.lastHighlightedValue),e.lastHighlightedValue=null)},restoreParentHiglightedItem(e){e.parent?.send("HIGHLIGHTED.RESTORE")},invokeOnOpen(e){e.onOpenChange?.({open:!0})},invokeOnClose(e){e.onOpenChange?.({open:!1})},toggleVisibility(e,i,{send:r}){r({type:e.open?"CONTROLLED.OPEN":"CONTROLLED.CLOSE",previousEvent:i})}}})}function mi(t){let n=t.parent;for(;n&&n.state.context.isSubmenu;)n=n.state.context.parent;n?.send("CLOSE")}var ct={highlighted(t,n){Ae(t.highlightedValue,n)||(t.highlightedValue=n,t.onHighlightChange?.({highlightedValue:n}))}},Ao=Rt()(["anchorPoint","aria-label","closeOnSelect","dir","getRootNode","highlightedValue","id","ids","loopFocus","onFocusOutside","onInteractOutside","onOpenChange","onPointerDownOutside","onEscapeKeyDown","onSelect","onHighlightChange","open","open.controlled","positioning","typeahead","composite"]),Js=At(Ao),Ro=Rt()(["closeOnSelect","disabled","value","valueText"]),Zs=At(Ro),Co=Rt()(["htmlFor"]),Qs=At(Co),Io=Rt()(["id"]),tc=At(Io),Mo=Rt()(["disabled","valueText","closeOnSelect","type","value","checked","onCheckedChange"]),ec=At(Mo);var Ei={onFocus:"onFocusin",onBlur:"onFocusout",onChange:"onInput",onDoubleClick:"onDblclick",htmlFor:"for",className:"class",defaultValue:"value",defaultChecked:"checked"},No=t=>{let n="";for(let e in t){let i=t[e];i!=null&&(e.startsWith("--")||(e=e.replace(/[A-Z]/g,r=>`-${r.toLowerCase()}`)),n+=`${e}:${i};`)}return n},Me=pi(t=>Object.entries(t).reduce((n,[e,i])=>i===void 0?n:(e in Ei&&(e=Ei[e]),e==="style"&&typeof i=="object"?(n.style=No(i),n):(n[e.toLowerCase()]=i,n)),{}));var vi=new WeakMap;function at(t,n){let e=vi.get(t)||{},i=Object.keys(n),r=(c,u)=>{t.addEventListener(c.toLowerCase(),u)},o=(c,u)=>{t.removeEventListener(c.toLowerCase(),u)},s=c=>c.startsWith("on"),a=c=>!c.startsWith("on"),f=c=>r(c.substring(2),n[c]),l=c=>o(c.substring(2),n[c]),h=c=>{let u=n[c],g=e[c];if(u!==g){if(typeof u=="boolean"&&(u=u||void 0),u!=null){["value","checked","htmlFor"].includes(c)?t[c]=u:t.setAttribute(c.toLowerCase(),u);return}t.removeAttribute(c.toLowerCase())}};for(let c in e)n[c]==null&&t.removeAttribute(c.toLowerCase());return Object.keys(e).filter(s).forEach(c=>{o(c.substring(2),e[c])}),i.filter(s).forEach(f),i.filter(a).forEach(h),vi.set(t,n),function(){i.filter(s).forEach(l)}}var wi={mounted(){this.context={id:this.el.id},this.service=yi(this.context),this.api=Ie(this.service.state,this.service.send,Me),this.render(),this.service.subscribe(()=>{this.api=Ie(this.service.state,this.service.send,Me),this.render()}),this.service.start()},updated(){this.render()},beforeDestroy(){this.service.stop()},labels(){return Array.from(this.el.querySelectorAll("[data-part='label']"))},groups(){return Array.from(this.el.querySelectorAll("[data-part='group']"))},separators(){return Array.from(this.el.querySelectorAll("[data-part='separator']"))},items(){return Array.from(this.el.querySelectorAll("[data-part='item']"))},render(){let t=this.el.querySelector("[data-part='trigger']"),n=this.el.querySelector("[data-part='positioner']"),e=this.el.querySelector("[data-part='content']");t&&at(t,this.api.triggerProps),n&&at(n,this.api.positionerProps),e&&at(e,this.api.contentProps),this.labels().forEach(i=>{at(i,this.api.getItemGroupLabelProps({htmlFor:i.dataset.for}))}),this.groups().forEach(i=>{at(i,this.api.getItemGroupProps({id:i.id}))}),this.separators().forEach(i=>at(i,this.api.separatorProps)),this.items().forEach(i=>{at(i,this.api.getItemProps({value:i.id}))})}};var lc={Menu:wi};export{lc as Hooks,wi as Menu};
//# sourceMappingURL=guillotine.mjs.map