Packages
corex
0.1.0-alpha.2
0.1.2
0.1.1
0.1.0
0.1.0-rc.1
0.1.0-rc.0
0.1.0-beta.5
0.1.0-beta.4
0.1.0-beta.3
0.1.0-beta.2
0.1.0-beta.1
0.1.0-alpha.33
0.1.0-alpha.32
0.1.0-alpha.31
0.1.0-alpha.30
0.1.0-alpha.29
0.1.0-alpha.28
0.1.0-alpha.27
0.1.0-alpha.26
0.1.0-alpha.25
0.1.0-alpha.24
0.1.0-alpha.23
0.1.0-alpha.22
0.1.0-alpha.21
0.1.0-alpha.20
0.1.0-alpha.19
0.1.0-alpha.18
0.1.0-alpha.17
0.1.0-alpha.16
0.1.0-alpha.15
0.1.0-alpha.14
0.1.0-alpha.13
0.1.0-alpha.12
0.1.0-alpha.11
0.1.0-alpha.10
0.1.0-alpha.9
0.1.0-alpha.8
0.1.0-alpha.7
0.1.0-alpha.6
0.1.0-alpha.5
0.1.0-alpha.4
0.1.0-alpha.3
0.1.0-alpha.2
0.1.0-alpha.1
Accessible and unstyled UI components library written in Elixir and TypeScript that integrates Zag.js state machines into the Phoenix Framework.
Current section
Files
Jump to
Current section
Files
priv/static/corex.min.js
"use strict";var Corex=(()=>{var Ee=Object.defineProperty,Dr=Object.defineProperties,Nr=Object.getOwnPropertyDescriptor,_r=Object.getOwnPropertyDescriptors,Fr=Object.getOwnPropertyNames,bt=Object.getOwnPropertySymbols;var Et=Object.prototype.hasOwnProperty,Hr=Object.prototype.propertyIsEnumerable;var We=(e,t,r)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,h=(e,t)=>{for(var r in t||(t={}))Et.call(t,r)&&We(e,r,t[r]);if(bt)for(var r of bt(t))Hr.call(t,r)&&We(e,r,t[r]);return e},E=(e,t)=>Dr(e,_r(t));var Br=(e,t)=>{for(var r in t)Ee(e,r,{get:t[r],enumerable:!0})},Kr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Fr(t))!Et.call(e,s)&&s!==r&&Ee(e,s,{get:()=>t[s],enumerable:!(n=Nr(t,s))||n.enumerable});return e};var jr=e=>Kr(Ee({},"__esModule",{value:!0}),e);var V=(e,t,r)=>We(e,typeof t!="symbol"?t+"":t,r);var ze=(e,t,r)=>new Promise((n,s)=>{var o=d=>{try{u(r.next(d))}catch(f){s(f)}},c=d=>{try{u(r.throw(d))}catch(f){s(f)}},u=d=>d.done?n(d.value):Promise.resolve(d.value).then(o,c);u((r=r.apply(e,t)).next())});var js={};Br(js,{default:()=>Ks});var G=(e,t=[])=>({parts:(...r)=>{if(qr(t))return G(e,r);throw new Error("createAnatomy().parts(...) should only be called once. Did you mean to use .extendWith(...) ?")},extendWith:(...r)=>G(e,[...t,...r]),omit:(...r)=>G(e,t.filter(n=>!r.includes(n))),rename:r=>G(r,t),keys:()=>t,build:()=>[...new Set(t)].reduce((r,n)=>Object.assign(r,{[n]:{selector:[`&[data-scope="${ae(e)}"][data-part="${ae(n)}"]`,`& [data-scope="${ae(e)}"][data-part="${ae(n)}"]`].join(", "),attrs:{"data-scope":ae(e),"data-part":ae(n)}}}),{})}),ae=e=>e.replace(/([A-Z])([A-Z])/g,"$1-$2").replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase(),qr=e=>e.length===0;var Gr=Object.defineProperty,$r=(e,t,r)=>t in e?Gr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ue=(e,t,r)=>$r(e,typeof t!="symbol"?t+"":t,r);var Ye=(...e)=>t=>e.reduce((r,n)=>n(r),t),we=()=>{},Se=e=>typeof e=="object"&&e!==null,Tt=2147483647,x=e=>e?"":void 0;var Wr=1,zr=9,Ur=11,Te=e=>Se(e)&&e.nodeType===Wr&&typeof e.nodeName=="string",St=e=>Se(e)&&e.nodeType===zr,Yr=e=>Se(e)&&e===e.window;var Xr=e=>Se(e)&&e.nodeType!==void 0,Pt=e=>Xr(e)&&e.nodeType===Ur&&"host"in e;function Xe(e){if(!e)return!1;let t=e.getRootNode();return Je(t)===e}function ce(e,t){var n;if(!e||!t||!Te(e)||!Te(t))return!1;let r=(n=t.getRootNode)==null?void 0:n.call(t);if(e===t||e.contains(t))return!0;if(r&&Pt(r)){let s=t;for(;s;){if(e===s)return!0;s=s.parentNode||s.host}}return!1}function Q(e){var t;return St(e)?e:Yr(e)?e.document:(t=e==null?void 0:e.ownerDocument)!=null?t:document}function K(e){var t,r,n;return Pt(e)?K(e.host):St(e)?(t=e.defaultView)!=null?t:window:Te(e)&&(n=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?n:window}function Je(e){let t=e.activeElement;for(;t!=null&&t.shadowRoot;){let r=t.shadowRoot.activeElement;if(!r||r===t)break;t=r}return t}var Ze=()=>typeof document!="undefined";function Jr(){var t;let e=navigator.userAgentData;return(t=e==null?void 0:e.platform)!=null?t:navigator.platform}function Zr(){let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:r})=>`${t}/${r}`).join(" "):navigator.userAgent}var Qe=e=>Ze()&&e.test(Jr()),Qr=e=>Ze()&&e.test(Zr()),en=e=>Ze()&&e.test(navigator.vendor);var tn=()=>Qe(/^iPhone/i),rn=()=>Qe(/^iPad/i)||Pe()&&navigator.maxTouchPoints>1,nn=()=>tn()||rn(),sn=()=>Pe()||nn(),Pe=()=>Qe(/^Mac/i),ke=()=>sn()&&en(/apple/i);var on=()=>Qr(/Android/i);function an(e){var t,r,n,s;return(s=(t=e.composedPath)==null?void 0:t.call(e))!=null?s:(n=(r=e.nativeEvent)==null?void 0:r.composedPath)==null?void 0:n.call(r)}function ee(e){var r;let t=an(e);return(r=t==null?void 0:t[0])!=null?r:e.target}function kt(e){return e.pointerType===""&&e.isTrusted?!0:on()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}var cn=e=>"touches"in e&&e.touches.length>0,un={Up:"ArrowUp",Down:"ArrowDown",Esc:"Escape"," ":"Space",",":"Comma",Left:"ArrowLeft",Right:"ArrowRight"},wt={ArrowLeft:"ArrowRight",ArrowRight:"ArrowLeft"};function At(e,t={}){var c;let{dir:r="ltr",orientation:n="horizontal"}=t,s=e.key;return s=(c=un[s])!=null?c:s,r==="rtl"&&n==="horizontal"&&s in wt&&(s=wt[s]),s}function ln(e,t="client"){let r=cn(e)?e.touches[0]||e.changedTouches[0]:e;return{x:r[`${t}X`],y:r[`${t}Y`]}}var B=(e,t,r,n)=>{let s=typeof e=="function"?e():e;return s==null||s.addEventListener(t,r,n),()=>{s==null||s.removeEventListener(t,r,n)}};function dn(e,t){var o;let{type:r="HTMLInputElement",property:n="value"}=t,s=K(e)[r].prototype;return(o=Object.getOwnPropertyDescriptor(s,n))!=null?o:{}}function et(e,t){var n;if(!e)return;(n=dn(e,{type:"HTMLInputElement",property:"checked"}).set)==null||n.call(e,t),t?e.setAttribute("checked",""):e.removeAttribute("checked")}function It(e,t){let{checked:r,bubbles:n=!0}=t;if(!e)return;let s=K(e);e instanceof s.HTMLInputElement&&(et(e,r),e.dispatchEvent(new s.Event("click",{bubbles:n})))}function fn(e){return hn(e)?e.form:e.closest("form")}function hn(e){return e.matches("textarea, input, select, button")}function pn(e,t){if(!e)return;let r=fn(e),n=s=>{s.defaultPrevented||t()};return r==null||r.addEventListener("reset",n,{passive:!0}),()=>r==null?void 0:r.removeEventListener("reset",n)}function gn(e,t){let r=e==null?void 0:e.closest("fieldset");if(!r)return;t(r.disabled);let n=K(r),s=new n.MutationObserver(()=>t(r.disabled));return s.observe(r,{attributes:!0,attributeFilter:["disabled"]}),()=>s.disconnect()}function Ct(e,t){if(!e)return;let{onFieldsetDisabledChange:r,onFormReset:n}=t,s=[pn(e,n),gn(e,r)];return()=>s.forEach(o=>o==null?void 0:o())}var tt=class Ot{constructor(){Ue(this,"id",null),Ue(this,"fn_cleanup"),Ue(this,"cleanup",()=>{this.cancel()})}static create(){return new Ot}request(t){this.cancel(),this.id=globalThis.requestAnimationFrame(()=>{this.id=null,this.fn_cleanup=t==null?void 0:t()})}cancel(){var t;this.id!==null&&(globalThis.cancelAnimationFrame(this.id),this.id=null),(t=this.fn_cleanup)==null||t.call(this),this.fn_cleanup=void 0}isActive(){return this.id!==null}};function pe(e){let t=tt.create();return t.request(e),t.cleanup}function Lt(e){let{pointerNode:t,keyboardNode:r=t,onPress:n,onPressStart:s,onPressEnd:o,isValidKey:c=w=>w.key==="Enter"}=e;if(!t)return we;let u=K(t),d=we,f=we,g=we,y=w=>({point:ln(w),event:w});function b(w){s==null||s(y(w))}function p(w){o==null||o(y(w))}let i=B(t,"pointerdown",w=>{f();let A=B(u,"pointerup",D=>{let P=ee(D);ce(t,P)?n==null||n(y(D)):o==null||o(y(D))},{passive:!n,once:!0}),L=B(u,"pointercancel",p,{passive:!o,once:!0});f=Ye(A,L),Xe(r)&&w.pointerType==="mouse"&&w.preventDefault(),b(w)},{passive:!s}),l=B(r,"focus",S);d=Ye(i,l);function S(){let w=D=>{if(!c(D))return;let P=k=>{if(!c(k))return;let R=new u.PointerEvent("pointerup"),j=y(R);n==null||n(j),o==null||o(j)};f(),f=B(r,"keyup",P);let T=new u.PointerEvent("pointerdown");b(T)},O=()=>{let D=new u.PointerEvent("pointercancel");p(D)},A=B(r,"keydown",w),L=B(r,"blur",O);g=Ye(A,L)}return()=>{d(),f(),g()}}function Mt(e,t){var r;return Array.from((r=e==null?void 0:e.querySelectorAll(t))!=null?r:[])}var xt=e=>e.id;function mn(e,t,r=xt){return e.find(n=>r(n)===t)}function Rt(e,t,r=xt){let n=mn(e,t,r);return n?e.indexOf(n):-1}function Vt(e,t,r=!0){let n=Rt(e,t);return n=r?(n+1)%e.length:Math.min(n+1,e.length-1),e[n]}function Dt(e,t,r=!0){let n=Rt(e,t);return n===-1?r?e[e.length-1]:null:(n=r?(n-1+e.length)%e.length:Math.max(0,n-1),e[n])}var Nt={border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"};var vn=Object.defineProperty,Ht=e=>{throw TypeError(e)},yn=(e,t,r)=>t in e?vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Y=(e,t,r)=>yn(e,typeof t!="symbol"?t+"":t,r),bn=(e,t,r)=>t.has(e)||Ht("Cannot "+r),_t=(e,t,r)=>(bn(e,t,"read from private field"),t.get(e)),En=(e,t,r)=>t.has(e)?Ht("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r);function Bt(e){return e==null?[]:Array.isArray(e)?e:[e]}var Kt=e=>e[0],jt=e=>e[e.length-1];var qt=(e,...t)=>e.concat(t),Gt=(e,...t)=>e.filter(r=>!t.includes(r));var Ft=e=>(e==null?void 0:e.constructor.name)==="Array",wn=(e,t)=>{if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Ce(e[r],t[r]))return!1;return!0},Ce=(e,t)=>{if(Object.is(e,t))return!0;if(e==null&&t!=null||e!=null&&t==null)return!1;if(typeof(e==null?void 0:e.isEqual)=="function"&&typeof(t==null?void 0:t.isEqual)=="function")return e.isEqual(t);if(typeof e=="function"&&typeof t=="function")return e.toString()===t.toString();if(Ft(e)&&Ft(t))return wn(Array.from(e),Array.from(t));if(typeof e!="object"||typeof t!="object")return!1;let r=Object.keys(t!=null?t:Object.create(null)),n=r.length;for(let s=0;s<n;s++)if(!Reflect.has(e,r[s]))return!1;for(let s=0;s<n;s++){let o=r[s];if(!Ce(e[o],t[o]))return!1}return!0};var Tn=e=>e!=null&&typeof e=="object";var $t=e=>typeof e=="string",X=e=>typeof e=="function";var Sn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Pn=e=>Object.prototype.toString.call(e),Wt=Function.prototype.toString,kn=Wt.call(Object),ue=e=>{if(!Tn(e)||Pn(e)!="[object Object]"||Cn(e))return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Sn(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Wt.call(r)==kn},An=e=>typeof e=="object"&&e!==null&&"$$typeof"in e&&"props"in e,In=e=>typeof e=="object"&&e!==null&&"__v_isVNode"in e,Cn=e=>An(e)||In(e),$=(e,...t)=>{let r=typeof e=="function"?e(...t):e;return r!=null?r:void 0};var zt=e=>e();var rt=(()=>{let e=0;return()=>(e++,e.toString(36))})();var{floor:Ys,abs:Xs,round:Js,min:Zs,max:Qs,pow:eo,sign:to}=Math;function ge(e){if(!ue(e)||e===void 0)return e;let t=Reflect.ownKeys(e).filter(n=>typeof n=="string"),r={};for(let n of t){let s=e[n];s!==void 0&&(r[n]=ge(s))}return r}function On(e,t){let r={},n={},s=new Set(t),o=Reflect.ownKeys(e);for(let c of o)s.has(c)?n[c]=e[c]:r[c]=e[c];return[n,r]}var me=e=>function(r){return On(r,e)};var Ae=()=>performance.now(),Ie,Ln=class{constructor(e){this.onTick=e,Y(this,"frameId",null),Y(this,"pausedAtMs",null),Y(this,"context"),Y(this,"cancelFrame",()=>{this.frameId!==null&&(cancelAnimationFrame(this.frameId),this.frameId=null)}),Y(this,"setStartMs",t=>{this.context.startMs=t}),Y(this,"start",()=>{if(this.frameId!==null)return;let t=Ae();this.pausedAtMs!==null?(this.context.startMs+=t-this.pausedAtMs,this.pausedAtMs=null):this.context.startMs=t,this.frameId=requestAnimationFrame(_t(this,Ie))}),Y(this,"pause",()=>{this.frameId!==null&&(this.cancelFrame(),this.pausedAtMs=Ae())}),Y(this,"stop",()=>{this.frameId!==null&&(this.cancelFrame(),this.pausedAtMs=null)}),En(this,Ie,t=>{if(this.context.now=t,this.context.deltaMs=t-this.context.startMs,this.onTick(this.context)===!1){this.stop();return}this.frameId=requestAnimationFrame(_t(this,Ie))}),this.context={now:0,startMs:Ae(),deltaMs:0}}get elapsedMs(){return this.pausedAtMs!==null?this.pausedAtMs-this.context.startMs:Ae()-this.context.startMs}};Ie=new WeakMap;function Oe(e,t){let r=new Ln(({deltaMs:n})=>{if(n>=t)return e(),!1});return r.start(),()=>r.stop()}function W(...e){let t=e.length===1?e[0]:e[1],r=e.length===2?e[0]:!0}function Ut(e,t,r){let n=[];for(let s of t)e[s]==null&&n.push(s);if(n.length>0)throw new Error(`[zag-js${r?` > ${r}`:""}] missing required props: ${n.join(", ")}`)}function te(){return{and:(...e)=>function(r){return e.every(n=>r.guard(n))},or:(...e)=>function(r){return e.some(n=>r.guard(n))},not:e=>function(r){return!r.guard(e)}}}function Yt(){return{guards:te(),createMachine:e=>e,choose:e=>function({choose:r}){var n;return(n=r(e))==null?void 0:n.actions}}}var le=(e=>(e.NotStarted="Not Started",e.Started="Started",e.Stopped="Stopped",e))(le||{}),Le="__init__";function Xt(e){let t=()=>{var c,u;return(u=(c=e.getRootNode)==null?void 0:c.call(e))!=null?u:document},r=()=>Q(t()),n=()=>{var c;return(c=r().defaultView)!=null?c:window},s=()=>Je(t()),o=c=>t().getElementById(c);return E(h({},e),{getRootNode:t,getDoc:r,getWin:n,getActiveElement:s,isActiveElement:Xe,getById:o})}function Jt(e){return new Proxy({},{get(t,r){return r==="style"?n=>e({style:n}).style:e}})}var ve=()=>e=>Array.from(new Set(e));var Mn=G("accordion").parts("root","item","itemTrigger","itemContent","itemIndicator"),ye=Mn.build(),Me=e=>{var t,r;return(r=(t=e.ids)==null?void 0:t.root)!=null?r:`accordion:${e.id}`},xn=(e,t)=>{var r,n,s;return(s=(n=(r=e.ids)==null?void 0:r.item)==null?void 0:n.call(r,t))!=null?s:`accordion:${e.id}:item:${t}`},nt=(e,t)=>{var r,n,s;return(s=(n=(r=e.ids)==null?void 0:r.itemContent)==null?void 0:n.call(r,t))!=null?s:`accordion:${e.id}:content:${t}`},xe=(e,t)=>{var r,n,s;return(s=(n=(r=e.ids)==null?void 0:r.itemTrigger)==null?void 0:n.call(r,t))!=null?s:`accordion:${e.id}:trigger:${t}`},Rn=e=>e.getById(Me(e)),Re=e=>{let r=`[data-controls][data-ownedby='${CSS.escape(Me(e))}']:not([disabled])`;return Mt(Rn(e),r)},Vn=e=>Kt(Re(e)),Dn=e=>jt(Re(e)),Nn=(e,t)=>Vt(Re(e),xe(e,t)),_n=(e,t)=>Dt(Re(e),xe(e,t));function Qt(e,t){let{send:r,context:n,prop:s,scope:o,computed:c}=e,u=n.get("focusedValue"),d=n.get("value"),f=s("multiple");function g(b){let p=b;!f&&p.length>1&&(p=[p[0]]),r({type:"VALUE.SET",value:p})}function y(b){var p;return{expanded:d.includes(b.value),focused:u===b.value,disabled:!!((p=b.disabled)!=null?p:s("disabled"))}}return{focusedValue:u,value:d,setValue:g,getItemState:y,getRootProps(){return t.element(E(h({},ye.root.attrs),{dir:s("dir"),id:Me(o),"data-orientation":s("orientation")}))},getItemProps(b){let p=y(b);return t.element(E(h({},ye.item.attrs),{dir:s("dir"),id:xn(o,b.value),"data-state":p.expanded?"open":"closed","data-focus":x(p.focused),"data-disabled":x(p.disabled),"data-orientation":s("orientation")}))},getItemContentProps(b){let p=y(b);return t.element(E(h({},ye.itemContent.attrs),{dir:s("dir"),role:"region",id:nt(o,b.value),"aria-labelledby":xe(o,b.value),hidden:!p.expanded,"data-state":p.expanded?"open":"closed","data-disabled":x(p.disabled),"data-focus":x(p.focused),"data-orientation":s("orientation")}))},getItemIndicatorProps(b){let p=y(b);return t.element(E(h({},ye.itemIndicator.attrs),{dir:s("dir"),"aria-hidden":!0,"data-state":p.expanded?"open":"closed","data-disabled":x(p.disabled),"data-focus":x(p.focused),"data-orientation":s("orientation")}))},getItemTriggerProps(b){let{value:p}=b,a=y(b);return t.button(E(h({},ye.itemTrigger.attrs),{type:"button",dir:s("dir"),id:xe(o,p),"aria-controls":nt(o,p),"data-controls":nt(o,p),"aria-expanded":a.expanded,disabled:a.disabled,"data-orientation":s("orientation"),"aria-disabled":a.disabled,"data-state":a.expanded?"open":"closed","data-ownedby":Me(o),onFocus(){a.disabled||r({type:"TRIGGER.FOCUS",value:p})},onBlur(){a.disabled||r({type:"TRIGGER.BLUR"})},onClick(i){a.disabled||(ke()&&i.currentTarget.focus(),r({type:"TRIGGER.CLICK",value:p}))},onKeyDown(i){if(i.defaultPrevented||a.disabled)return;let l={ArrowDown(){c("isHorizontal")||r({type:"GOTO.NEXT",value:p})},ArrowUp(){c("isHorizontal")||r({type:"GOTO.PREV",value:p})},ArrowRight(){c("isHorizontal")&&r({type:"GOTO.NEXT",value:p})},ArrowLeft(){c("isHorizontal")&&r({type:"GOTO.PREV",value:p})},Home(){r({type:"GOTO.FIRST",value:p})},End(){r({type:"GOTO.LAST",value:p})}},S=At(i,{dir:s("dir"),orientation:s("orientation")}),w=l[S];w&&(w(i),i.preventDefault())}}))}}}var{and:Fn,not:Hn}=te(),er={props({props:e}){return h({collapsible:!1,multiple:!1,orientation:"vertical",defaultValue:[]},e)},initialState(){return"idle"},context({prop:e,bindable:t}){return{focusedValue:t(()=>({defaultValue:null,sync:!0,onChange(r){var n;(n=e("onFocusChange"))==null||n({value:r})}})),value:t(()=>({defaultValue:e("defaultValue"),value:e("value"),onChange(r){var n;(n=e("onValueChange"))==null||n({value:r})}}))}},computed:{isHorizontal:({prop:e})=>e("orientation")==="horizontal"},on:{"VALUE.SET":{actions:["setValue"]}},states:{idle:{on:{"TRIGGER.FOCUS":{target:"focused",actions:["setFocusedValue"]}}},focused:{on:{"GOTO.NEXT":{actions:["focusNextTrigger"]},"GOTO.PREV":{actions:["focusPrevTrigger"]},"TRIGGER.CLICK":[{guard:Fn("isExpanded","canToggle"),actions:["collapse"]},{guard:Hn("isExpanded"),actions:["expand"]}],"GOTO.FIRST":{actions:["focusFirstTrigger"]},"GOTO.LAST":{actions:["focusLastTrigger"]},"TRIGGER.BLUR":{target:"idle",actions:["clearFocusedValue"]}}}},implementations:{guards:{canToggle:({prop:e})=>!!e("collapsible")||!!e("multiple"),isExpanded:({context:e,event:t})=>e.get("value").includes(t.value)},actions:{collapse({context:e,prop:t,event:r}){let n=t("multiple")?Gt(e.get("value"),r.value):[];e.set("value",n)},expand({context:e,prop:t,event:r}){let n=t("multiple")?qt(e.get("value"),r.value):[r.value];e.set("value",n)},focusFirstTrigger({scope:e}){var t;(t=Vn(e))==null||t.focus()},focusLastTrigger({scope:e}){var t;(t=Dn(e))==null||t.focus()},focusNextTrigger({context:e,scope:t}){let r=e.get("focusedValue");if(!r)return;let n=Nn(t,r);n==null||n.focus()},focusPrevTrigger({context:e,scope:t}){let r=e.get("focusedValue");if(!r)return;let n=_n(t,r);n==null||n.focus()},setFocusedValue({context:e,event:t}){e.set("focusedValue",t.value)},clearFocusedValue({context:e}){e.set("focusedValue",null)},setValue({context:e,event:t}){e.set("value",t.value)},coarseValue({context:e,prop:t}){!t("multiple")&&e.get("value").length>1&&(W("The value of accordion should be a single value when multiple is false."),e.set("value",[e.get("value")[0]]))}}}},Bn=ve()(["collapsible","dir","disabled","getRootNode","id","ids","multiple","onFocusChange","onValueChange","orientation","value","defaultValue"]),go=me(Bn),Kn=ve()(["value","disabled"]),mo=me(Kn);var yo=Symbol(),qn=Symbol();var tr=Object.getPrototypeOf,st=new WeakMap,Gn=e=>e&&(st.has(e)?st.get(e):tr(e)===Object.prototype||tr(e)===Array.prototype);var rr=e=>Gn(e)&&e[qn]||null,ot=(e,t=!0)=>{st.set(e,t)};function $n(){if(typeof globalThis!="undefined")return globalThis;if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global}function sr(e,t){let r=$n();return r?(r[e]||(r[e]=t()),r[e]):t()}var Ve=sr("__zag__refSet",()=>new WeakSet),Wn=e=>typeof e=="object"&&e!==null&&"$$typeof"in e&&"props"in e,zn=e=>typeof e=="object"&&e!==null&&"__v_isVNode"in e,Un=e=>typeof e=="object"&&e!==null&&"nodeType"in e&&typeof e.nodeName=="string",Yn=e=>Wn(e)||zn(e)||Un(e),it=e=>e!==null&&typeof e=="object",nr=e=>it(e)&&!Ve.has(e)&&(Array.isArray(e)||!(Symbol.iterator in e))&&!Yn(e)&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof Error)&&!(e instanceof Number)&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof RegExp)&&!(e instanceof ArrayBuffer)&&!(e instanceof Promise)&&!(e instanceof File)&&!(e instanceof Blob)&&!(e instanceof AbortController),De=()=>!1;var re=sr("__zag__proxyStateMap",()=>new WeakMap),Xn=(e=Object.is,t=(u,d)=>new Proxy(u,d),r=new WeakMap,n=(u,d)=>{let f=r.get(u);if((f==null?void 0:f[0])===d)return f[1];let g=Array.isArray(u)?[]:Object.create(Object.getPrototypeOf(u));return ot(g,!0),r.set(u,[d,g]),Reflect.ownKeys(u).forEach(y=>{let b=Reflect.get(u,y);Ve.has(b)?(ot(b,!1),g[y]=b):re.has(b)?g[y]=Zn(b):g[y]=b}),Object.freeze(g)},s=new WeakMap,o=[1,1],c=u=>{if(!it(u))throw new Error("object required");let d=s.get(u);if(d)return d;let f=o[0],g=new Set,y=(P,T=++o[0])=>{f!==T&&(f=T,g.forEach(k=>k(P,T)))},b=o[1],p=(P=++o[1])=>(b!==P&&!g.size&&(b=P,i.forEach(([T])=>{let k=T[1](P);k>f&&(f=k)})),f),a=P=>(T,k)=>{let R=[...T];R[1]=[P,...R[1]],y(R,k)},i=new Map,l=(P,T)=>{if(De()&&i.has(P))throw new Error("prop listener already exists");if(g.size){let k=T[3](a(P));i.set(P,[T,k])}else i.set(P,[T])},S=P=>{var k;let T=i.get(P);T&&(i.delete(P),(k=T[1])==null||k.call(T))},w=P=>(g.add(P),g.size===1&&i.forEach(([k,R],j)=>{if(De()&&R)throw new Error("remove already exists");let m=k[3](a(j));i.set(j,[k,m])}),()=>{g.delete(P),g.size===0&&i.forEach(([k,R],j)=>{R&&(R(),i.set(j,[k]))})}),O=Array.isArray(u)?[]:Object.create(Object.getPrototypeOf(u)),L=t(O,{deleteProperty(P,T){let k=Reflect.get(P,T);S(T);let R=Reflect.deleteProperty(P,T);return R&&y(["delete",[T],k]),R},set(P,T,k,R){var F;let j=Reflect.has(P,T),m=Reflect.get(P,T,R);if(j&&(e(m,k)||s.has(k)&&e(m,s.get(k))))return!0;S(T),it(k)&&(k=rr(k)||k);let v=k;if(!((F=Object.getOwnPropertyDescriptor(P,T))!=null&&F.set)){!re.has(k)&&nr(k)&&(v=at(k));let H=!Ve.has(v)&&re.get(v);H&&l(T,H)}return Reflect.set(P,T,v,R),y(["set",[T],k,m]),!0}});s.set(u,L);let D=[O,p,n,w];return re.set(L,D),Reflect.ownKeys(u).forEach(P=>{let T=Object.getOwnPropertyDescriptor(u,P);T.get||T.set?Object.defineProperty(O,P,T):L[P]=u[P]}),L})=>[c,re,Ve,e,t,nr,r,n,s,o],[Jn]=Xn();function at(e={}){return Jn(e)}function ct(e,t,r){let n=re.get(e);De()&&!n&&console.warn("Please use proxy object");let s,o=[],c=n[3],u=!1,f=c(g=>{if(o.push(g),r){t(o.splice(0));return}s||(s=Promise.resolve().then(()=>{s=void 0,u&&t(o.splice(0))}))});return u=!0,()=>{u=!1,f()}}function Zn(e){let t=re.get(e);De()&&!t&&console.warn("Please use proxy object");let[r,n,s]=t;return s(r,n())}var Qn=Object.defineProperty,es=(e,t,r)=>t in e?Qn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,I=(e,t,r)=>es(e,typeof t!="symbol"?t+"":t,r),or={onFocus:"onFocusin",onBlur:"onFocusout",onChange:"onInput",onDoubleClick:"onDblclick",htmlFor:"for",className:"class",defaultValue:"value",defaultChecked:"checked"},ts=new Set(["viewBox","preserveAspectRatio"]),rs=e=>{let t="";for(let r in e){let n=e[r];n!=null&&(r.startsWith("--")||(r=r.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`)),t+=`${r}:${n};`)}return t},ne=Jt(e=>Object.entries(e).reduce((t,[r,n])=>{if(n===void 0)return t;if(r in or&&(r=or[r]),r==="style"&&typeof n=="object")return t.style=rs(n),t;let s=ts.has(r)?r:r.toLowerCase();return t[s]=n,t},{})),Ne=new WeakMap,ir=new Set(["value","checked","selected"]),ns=new Set(["viewBox","preserveAspectRatio","clipPath","clipRule","fillRule","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeDashoffset","strokeMiterlimit"]),ss=e=>e.tagName==="svg"||e.namespaceURI==="http://www.w3.org/2000/svg",_e=(e,t)=>ss(e)&&ns.has(t)?t:t.toLowerCase();function ar(e,t,r){let n=r||"default",s=Ne.get(e);s||(s=new Map,Ne.set(e,s));let o=s.get(n)||{},c=Object.keys(t),u=(i,l)=>{e.addEventListener(i.toLowerCase(),l)},d=(i,l)=>{e.removeEventListener(i.toLowerCase(),l)},f=i=>i.startsWith("on"),g=i=>!i.startsWith("on"),y=i=>u(i.substring(2),t[i]),b=i=>d(i.substring(2),t[i]),p=i=>{let l=t[i],S=o[i];if(l!==S){if(i==="class"){e.className=l!=null?l:"";return}if(ir.has(i)){e[i]=l!=null?l:"";return}if(typeof l=="boolean"&&!i.includes("aria-")){e.toggleAttribute(_e(e,i),l);return}if(i==="children"){e.innerHTML=l;return}if(l!=null){e.setAttribute(_e(e,i),l);return}e.removeAttribute(_e(e,i))}};for(let i in o)t[i]==null&&(i==="class"?e.className="":ir.has(i)?e[i]="":e.removeAttribute(_e(e,i)));return Object.keys(o).filter(f).forEach(i=>{d(i.substring(2),o[i])}),c.filter(f).forEach(y),c.filter(g).forEach(p),s.set(n,t),function(){c.filter(f).forEach(b);let l=Ne.get(e);l&&(l.delete(n),l.size===0&&Ne.delete(e))}}function Fe(e){var o,c;let t=(o=e().value)!=null?o:e().defaultValue;e().debug&&console.log(`[bindable > ${e().debug}] initial`,t);let r=(c=e().isEqual)!=null?c:Object.is,n=at({value:t}),s=()=>e().value!==void 0;return{initial:t,ref:n,get(){return s()?e().value:n.value},set(u){var g,y;let d=n.value,f=X(u)?u(d):u;e().debug&&console.log(`[bindable > ${e().debug}] setValue`,{next:f,prev:d}),s()||(n.value=f),r(f,d)||(y=(g=e()).onChange)==null||y.call(g,f,d)},invoke(u,d){var f,g;(g=(f=e()).onChange)==null||g.call(f,u,d)},hash(u){var d,f,g;return(g=(f=(d=e()).hash)==null?void 0:f.call(d,u))!=null?g:String(u)}}}Fe.cleanup=e=>{};Fe.ref=e=>{let t=e;return{get:()=>t,set:r=>{t=r}}};function os(e){let t={current:e};return{get(r){return t.current[r]},set(r,n){t.current[r]=n}}}function cr(e,t){if(!ue(e)||!ue(t))return t===void 0?e:t;let r=h({},e);for(let n of Object.keys(t)){let s=t[n],o=e[n];s!==void 0&&(ue(o)&&ue(s)?r[n]=cr(o,s):r[n]=s)}return r}var se=class{constructor(e,t={}){var y,b,p;this.machine=e,I(this,"scope"),I(this,"context"),I(this,"prop"),I(this,"state"),I(this,"refs"),I(this,"computed"),I(this,"event",{type:""}),I(this,"previousEvent",{type:""}),I(this,"effects",new Map),I(this,"transition",null),I(this,"cleanups",[]),I(this,"subscriptions",[]),I(this,"userPropsRef"),I(this,"getEvent",()=>E(h({},this.event),{current:()=>this.event,previous:()=>this.previousEvent})),I(this,"getStateConfig",a=>this.machine.states[a]),I(this,"getState",()=>E(h({},this.state),{matches:(...a)=>a.includes(this.state.get()),hasTag:a=>{var i,l;return!!((l=(i=this.getStateConfig(this.state.get()))==null?void 0:i.tags)!=null&&l.includes(a))}})),I(this,"debug",(...a)=>{this.machine.debug&&console.log(...a)}),I(this,"notify",()=>{this.publish()}),I(this,"send",a=>{this.status===le.Started&&queueMicrotask(()=>{var L,D,P,T,k;if(!a)return;this.previousEvent=this.event,this.event=a,this.debug("send",a);let i=this.state.get(),l=a.type,S=(T=(D=(L=this.getStateConfig(i))==null?void 0:L.on)==null?void 0:D[l])!=null?T:(P=this.machine.on)==null?void 0:P[l],w=this.choose(S);if(!w)return;this.transition=w;let O=(k=w.target)!=null?k:i;this.debug("transition",w);let A=O!==i;A?this.state.set(O):w.reenter&&!A?this.state.invoke(i,i):this.action(w.actions)})}),I(this,"action",a=>{let i=X(a)?a(this.getParams()):a;if(!i)return;let l=i.map(S=>{var O,A;let w=(A=(O=this.machine.implementations)==null?void 0:O.actions)==null?void 0:A[S];return w||W(`[zag-js] No implementation found for action "${JSON.stringify(S)}"`),w});for(let S of l)S==null||S(this.getParams())}),I(this,"guard",a=>{var i,l;return X(a)?a(this.getParams()):(l=(i=this.machine.implementations)==null?void 0:i.guards)==null?void 0:l[a](this.getParams())}),I(this,"effect",a=>{let i=X(a)?a(this.getParams()):a;if(!i)return;let l=i.map(w=>{var A,L;let O=(L=(A=this.machine.implementations)==null?void 0:A.effects)==null?void 0:L[w];return O||W(`[zag-js] No implementation found for effect "${JSON.stringify(w)}"`),O}),S=[];for(let w of l){let O=w==null?void 0:w(this.getParams());O&&S.push(O)}return()=>S.forEach(w=>w==null?void 0:w())}),I(this,"choose",a=>Bt(a).find(i=>{let l=!i.guard;return $t(i.guard)?l=!!this.guard(i.guard):X(i.guard)&&(l=i.guard(this.getParams())),l})),I(this,"subscribe",a=>(this.subscriptions.push(a),()=>{let i=this.subscriptions.indexOf(a);i>-1&&this.subscriptions.splice(i,1)})),I(this,"status",le.NotStarted),I(this,"publish",()=>{this.callTrackers(),this.subscriptions.forEach(a=>a(this.service))}),I(this,"trackers",[]),I(this,"setupTrackers",()=>{var a,i;(i=(a=this.machine).watch)==null||i.call(a,this.getParams())}),I(this,"callTrackers",()=>{this.trackers.forEach(({deps:a,fn:i})=>{let l=a.map(S=>S());Ce(i.prev,l)||(i(),i.prev=l)})}),I(this,"getParams",()=>({state:this.getState(),context:this.context,event:this.getEvent(),prop:this.prop,send:this.send,action:this.action,guard:this.guard,track:(a,i)=>{i.prev=a.map(l=>l()),this.trackers.push({deps:a,fn:i})},refs:this.refs,computed:this.computed,flush:zt,scope:this.scope,choose:this.choose})),this.userPropsRef={current:t};let{id:r,ids:n,getRootNode:s}=$(t);this.scope=Xt({id:r,ids:n,getRootNode:s});let o=a=>{var S,w;let i=$(this.userPropsRef.current);return((w=(S=e.props)==null?void 0:S.call(e,{props:ge(i),scope:this.scope}))!=null?w:i)[a]};this.prop=o;let c=(y=e.context)==null?void 0:y.call(e,{prop:o,bindable:Fe,scope:this.scope,flush(a){queueMicrotask(a)},getContext(){return u},getComputed(){return d},getRefs(){return f},getEvent:this.getEvent.bind(this)});c&&Object.values(c).forEach(a=>{let i=ct(a.ref,()=>this.notify());this.cleanups.push(i)});let u={get(a){return c==null?void 0:c[a].get()},set(a,i){c==null||c[a].set(i)},initial(a){return c==null?void 0:c[a].initial},hash(a){let i=c==null?void 0:c[a].get();return c==null?void 0:c[a].hash(i)}};this.context=u;let d=a=>{var i,l;return(l=(i=e.computed)==null?void 0:i[a]({context:u,event:this.getEvent(),prop:o,refs:this.refs,scope:this.scope,computed:d}))!=null?l:{}};this.computed=d;let f=os((p=(b=e.refs)==null?void 0:b.call(e,{prop:o,context:u}))!=null?p:{});this.refs=f;let g=Fe(()=>({defaultValue:e.initialState({prop:o}),onChange:(a,i)=>{var S,w,O,A;if(i){let L=this.effects.get(i);L==null||L(),this.effects.delete(i)}i&&this.action((S=this.getStateConfig(i))==null?void 0:S.exit),this.action((w=this.transition)==null?void 0:w.actions);let l=this.effect((O=this.getStateConfig(a))==null?void 0:O.effects);if(l&&this.effects.set(a,l),i===Le){this.action(e.entry);let L=this.effect(e.effects);L&&this.effects.set(Le,L)}this.action((A=this.getStateConfig(a))==null?void 0:A.entry)}}));this.state=g,this.cleanups.push(ct(this.state.ref,()=>this.notify()))}updateProps(e){let t=this.userPropsRef.current;this.userPropsRef.current=()=>{let r=$(t),n=$(e);return cr(r,n)},this.notify()}start(){this.status=le.Started,this.debug("initializing..."),this.state.invoke(this.state.initial,Le),this.setupTrackers()}stop(){this.effects.forEach(e=>e==null?void 0:e()),this.effects.clear(),this.transition=null,this.action(this.machine.exit),this.cleanups.forEach(e=>e()),this.cleanups=[],this.subscriptions=[],this.status=le.Stopped,this.debug("unmounting...")}get service(){return{state:this.getState(),send:this.send,context:this.context,prop:this.prop,scope:this.scope,refs:this.refs,computed:this.computed,event:this.getEvent(),getStatus:()=>this.status}}};var z=class{constructor(t,r){V(this,"el");V(this,"machine");V(this,"api");V(this,"init",()=>{this.machine.start(),this.render(),this.machine.subscribe(()=>{this.api=this.initApi(),this.render()})});V(this,"destroy",()=>{this.machine.stop()});V(this,"spreadProps",(t,r)=>{ar(t,r)});V(this,"updateProps",t=>{this.machine.updateProps(t)});if(!t)throw new Error("Root element not found");this.el=t,this.machine=this.initMachine(r),this.api=this.initApi()}};var M=(e,t,r)=>{let n=e.dataset[t];if(n!==void 0&&(!r||r.includes(n)))return n},be=(e,t)=>{let r=e.dataset[t];if(typeof r=="string")return r.split(",").map(n=>n.trim()).filter(n=>n.length>0)},ut=(e,t,r)=>{let n=e.dataset[t];if(n===void 0)return;let s=Number(n);if(!Number.isNaN(s))return r&&!r.includes(s)?0:s},C=(e,t)=>e.hasAttribute(`data-${t}`),J=(e,t="element")=>e!=null&&e.id?e.id:`${t}-${Math.random().toString(36).substring(2,9)}`;var He=class extends z{initMachine(t){return new se(er,t)}initApi(){return Qt(this.machine.service,ne)}render(){let t=this.el.querySelector('[data-part="root"]')||this.el;this.spreadProps(t,this.api.getRootProps());let r=this.el.querySelectorAll('[data-part="item"]');for(let n=0;n<r.length;n++){let s=r[n],o=M(s,"value");if(!o)continue;let c=C(s,"disabled");this.spreadProps(s,this.api.getItemProps({value:o,disabled:c}));let u=s.querySelector('[data-part="item-trigger"]');u&&this.spreadProps(u,this.api.getItemTriggerProps({value:o,disabled:c}));let d=s.querySelector('[data-part="item-indicator"]');d&&this.spreadProps(d,this.api.getItemIndicatorProps({value:o,disabled:c}));let f=s.querySelector('[data-part="item-content"]');f&&this.spreadProps(f,this.api.getItemContentProps({value:o,disabled:c}))}}};var ur={mounted(){this.wasFocused=null;let e=this.el,t=this.pushEvent.bind(this),r={id:e.id,defaultValue:be(e,"defaultValue"),value:be(e,"value"),collapsible:C(e,"collapsible"),disabled:C(e,"disabled"),multiple:C(e,"multiple"),orientation:M(e,"orientation",["horizontal","vertical"]),dir:M(e,"dir",["ltr","rtl"]),onValueChange:s=>{let o=M(e,"onValueChange");o&&!this.liveSocket.main.isDead&&this.liveSocket.main.isConnected()&&t(o,{value:s.value,accordion_id:e.id});let c=M(e,"onValueChangeClient");c&&e.dispatchEvent(new CustomEvent(c,{bubbles:!0,detail:{value:s.value,accordion_id:e.id}}))}},n=new He(e,r);n.init(),this.accordion=n,this.onSetValue=s=>{let{value:o}=s.detail;n.api.setValue(o)},e.addEventListener("phx:accordion:set-value",this.onSetValue),this.handlers=[],this.handlers.push(this.handleEvent("accordion_set_value",s=>{let o=s.accordion_id;o&&o!==e.id||n.api.setValue(s.value)})),this.handlers.push(this.handleEvent("accordion_value",()=>{this.pushEvent("accordion_value_response",{value:n.api.value})})),this.handlers.push(this.handleEvent("accordion_focused_value",()=>{this.pushEvent("accordion_focused_value_response",{value:n.api.focusedValue})}))},updated(){var e;(e=this.accordion)==null||e.updateProps({defaultValue:be(this.el,"defaultValue"),value:be(this.el,"value"),collapsible:C(this.el,"collapsible"),disabled:C(this.el,"disabled"),multiple:C(this.el,"multiple"),orientation:M(this.el,"orientation",["horizontal","vertical"]),dir:M(this.el,"dir",["ltr","rtl"])})},destroyed(){var e;if(this.onSetValue&&this.el.removeEventListener("phx:accordion:set-value",this.onSetValue),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.accordion)==null||e.destroy()}};var lr="layer:request-dismiss",lt={layers:[],branches:[],count(){return this.layers.length},pointerBlockingLayers(){return this.layers.filter(e=>e.pointerBlocking)},topMostPointerBlockingLayer(){return[...this.pointerBlockingLayers()].slice(-1)[0]},hasPointerBlockingLayer(){return this.pointerBlockingLayers().length>0},isBelowPointerBlockingLayer(e){var n;let t=this.indexOf(e),r=this.topMostPointerBlockingLayer()?this.indexOf((n=this.topMostPointerBlockingLayer())==null?void 0:n.node):-1;return t<r},isTopMost(e){let t=this.layers[this.count()-1];return(t==null?void 0:t.node)===e},getNestedLayers(e){return Array.from(this.layers).slice(this.indexOf(e)+1)},getLayersByType(e){return this.layers.filter(t=>t.type===e)},getNestedLayersByType(e,t){let r=this.indexOf(e);return r===-1?[]:this.layers.slice(r+1).filter(n=>n.type===t)},getParentLayerOfType(e,t){let r=this.indexOf(e);if(!(r<=0))return this.layers.slice(0,r).reverse().find(n=>n.type===t)},countNestedLayersOfType(e,t){return this.getNestedLayersByType(e,t).length},isInNestedLayer(e,t){return this.getNestedLayers(e).some(r=>ce(r.node,t))},isInBranch(e){return Array.from(this.branches).some(t=>ce(t,e))},add(e){this.layers.push(e),this.syncLayers()},addBranch(e){this.branches.push(e)},remove(e){let t=this.indexOf(e);t<0||(t<this.count()-1&&this.getNestedLayers(e).forEach(n=>lt.dismiss(n.node,e)),this.layers.splice(t,1),this.syncLayers())},removeBranch(e){let t=this.branches.indexOf(e);t>=0&&this.branches.splice(t,1)},syncLayers(){this.layers.forEach((e,t)=>{e.node.style.setProperty("--layer-index",`${t}`),e.node.removeAttribute("data-nested"),e.node.removeAttribute("data-has-nested"),this.getParentLayerOfType(e.node,e.type)&&e.node.setAttribute("data-nested",e.type);let n=this.countNestedLayersOfType(e.node,e.type);n>0&&e.node.setAttribute("data-has-nested",e.type),e.node.style.setProperty("--nested-layer-count",`${n}`)})},indexOf(e){return this.layers.findIndex(t=>t.node===e)},dismiss(e,t){let r=this.indexOf(e);if(r===-1)return;let n=this.layers[r];as(e,lr,s=>{var o;(o=n.requestDismiss)==null||o.call(n,s),s.defaultPrevented||n==null||n.dismiss()}),is(e,lr,{originalLayer:e,targetLayer:t,originalIndex:r,targetIndex:t?this.indexOf(t):-1}),this.syncLayers()},clear(){this.remove(this.layers[0].node)}};function is(e,t,r){let n=e.ownerDocument.defaultView||window,s=new n.CustomEvent(t,{cancelable:!0,bubbles:!0,detail:r});return e.dispatchEvent(s)}function as(e,t,r){e.addEventListener(t,r,{once:!0})}function dr(e,t={}){let{defer:r}=t,n=r?pe:o=>o(),s=[];return s.push(n(()=>{let o=X(e)?e():e;if(!o){W("[@zag-js/dismissable] branch node is `null` or `undefined`");return}lt.addBranch(o),s.push(()=>{lt.removeBranch(o)})})),()=>{s.forEach(o=>o==null?void 0:o())}}var cs=G("toast").parts("group","root","title","description","actionTrigger","closeTrigger"),de=cs.build(),us=e=>`toast-group:${e}`,fr=(e,t)=>e.getById(`toast-group:${t}`),yr=e=>`toast:${e.id}`,hr=e=>e.getById(yr(e)),pr=e=>`toast:${e.id}:title`,gr=e=>`toast:${e.id}:description`,ls=e=>`toast${e.id}:close`,mr={info:5e3,error:5e3,success:2e3,loading:1/0,DEFAULT:5e3};function dt(e,t){var r;return(r=e!=null?e:mr[t])!=null?r:mr.DEFAULT}var ds=e=>typeof e=="string"?{left:e,right:e,bottom:e,top:e}:e;function fs(e,t){var i;let{prop:r,computed:n,context:s}=e,{offsets:o,gap:c}=r("store").attrs,u=s.get("heights"),d=ds(o),f=r("dir")==="rtl",g=t.replace("-start",f?"-right":"-left").replace("-end",f?"-left":"-right"),y=g.includes("right"),b=g.includes("left"),p={position:"fixed",pointerEvents:n("count")>0?void 0:"none",display:"flex",flexDirection:"column","--gap":`${c}px`,"--first-height":`${((i=u[0])==null?void 0:i.height)||0}px`,"--viewport-offset-left":d.left,"--viewport-offset-right":d.right,"--viewport-offset-top":d.top,"--viewport-offset-bottom":d.bottom,zIndex:Tt},a="center";if(y&&(a="flex-end"),b&&(a="flex-start"),p.alignItems=a,g.includes("top")){let l=d.top;p.top=`max(env(safe-area-inset-top, 0px), ${l})`}if(g.includes("bottom")){let l=d.bottom;p.bottom=`max(env(safe-area-inset-bottom, 0px), ${l})`}if(!g.includes("left")){let l=d.right;p.insetInlineEnd=`calc(env(safe-area-inset-right, 0px) + ${l})`}if(!g.includes("right")){let l=d.left;p.insetInlineStart=`calc(env(safe-area-inset-left, 0px) + ${l})`}return p}function hs(e,t){let{prop:r,context:n,computed:s}=e,o=r("parent"),c=o.computed("placement"),{gap:u}=o.prop("store").attrs,[d]=c.split("-"),f=n.get("mounted"),g=n.get("remainingTime"),y=s("height"),b=s("frontmost"),p=!b,a=!r("stacked"),i=r("stacked"),S=r("type")==="loading"?Number.MAX_SAFE_INTEGER:g,w=s("heightIndex")*u+s("heightBefore"),O={position:"absolute",pointerEvents:"auto","--opacity":"0","--remove-delay":`${r("removeDelay")}ms`,"--duration":`${S}ms`,"--initial-height":`${y}px`,"--offset":`${w}px`,"--index":r("index"),"--z-index":s("zIndex"),"--lift-amount":"calc(var(--lift) * var(--gap))","--y":"100%","--x":"0"},A=L=>Object.assign(O,L);return d==="top"?A({top:"0","--sign":"-1","--y":"-100%","--lift":"1"}):d==="bottom"&&A({bottom:"0","--sign":"1","--y":"100%","--lift":"-1"}),f&&(A({"--y":"0","--opacity":"1"}),i&&A({"--y":"calc(var(--lift) * var(--offset))","--height":"var(--initial-height)"})),t||A({"--opacity":"0",pointerEvents:"none"}),p&&a&&(A({"--base-scale":"var(--index) * 0.05 + 1","--y":"calc(var(--lift-amount) * var(--index))","--scale":"calc(-1 * var(--base-scale))","--height":"var(--first-height)"}),t||A({"--y":"calc(var(--sign) * 40%)"})),p&&i&&!t&&A({"--y":"calc(var(--lift) * var(--offset) + var(--lift) * -100%)"}),b&&!t&&A({"--y":"calc(var(--lift) * -100%)"}),O}function ps(e,t){let{computed:r}=e,n={position:"absolute",inset:"0",scale:"1 2",pointerEvents:t?"none":"auto"},s=o=>Object.assign(n,o);return r("frontmost")&&!t&&s({height:"calc(var(--initial-height) + 80%)"}),n}function gs(){return{position:"absolute",left:"0",height:"calc(var(--gap) + 2px)",bottom:"100%",width:"100%"}}function ms(e,t){let{context:r,prop:n,send:s,refs:o,computed:c}=e;return{getCount(){return r.get("toasts").length},getToasts(){return r.get("toasts")},getGroupProps(u={}){let{label:d="Notifications"}=u,{hotkey:f}=n("store").attrs,g=f.join("+").replace(/Key/g,"").replace(/Digit/g,""),y=c("placement"),[b,p="center"]=y.split("-");return t.element(E(h({},de.group.attrs),{dir:n("dir"),tabIndex:-1,"aria-label":`${y} ${d} ${g}`,id:us(y),"data-placement":y,"data-side":b,"data-align":p,"aria-live":"polite",role:"region",style:fs(e,y),onMouseEnter(){o.get("ignoreMouseTimer").isActive()||s({type:"REGION.POINTER_ENTER",placement:y})},onMouseMove(){o.get("ignoreMouseTimer").isActive()||s({type:"REGION.POINTER_ENTER",placement:y})},onMouseLeave(){o.get("ignoreMouseTimer").isActive()||s({type:"REGION.POINTER_LEAVE",placement:y})},onFocus(a){s({type:"REGION.FOCUS",target:a.relatedTarget})},onBlur(a){o.get("isFocusWithin")&&!ce(a.currentTarget,a.relatedTarget)&&queueMicrotask(()=>s({type:"REGION.BLUR"}))}}))},subscribe(u){return n("store").subscribe(()=>u(r.get("toasts")))}}}var{guards:vs,createMachine:ys}=Yt(),{and:bs}=vs,Es=ys({props({props:e}){return E(h({dir:"ltr",id:rt()},e),{store:e.store})},initialState({prop:e}){return e("store").attrs.overlap?"overlap":"stack"},refs(){return{lastFocusedEl:null,isFocusWithin:!1,isPointerWithin:!1,ignoreMouseTimer:tt.create(),dismissableCleanup:void 0}},context({bindable:e}){return{toasts:e(()=>({defaultValue:[],sync:!0,hash:t=>t.map(r=>r.id).join(",")})),heights:e(()=>({defaultValue:[],sync:!0}))}},computed:{count:({context:e})=>e.get("toasts").length,overlap:({prop:e})=>e("store").attrs.overlap,placement:({prop:e})=>e("store").attrs.placement},effects:["subscribeToStore","trackDocumentVisibility","trackHotKeyPress"],watch({track:e,context:t,action:r}){e([()=>t.hash("toasts")],()=>{queueMicrotask(()=>{r(["collapsedIfEmpty","setDismissableBranch"])})})},exit:["clearDismissableBranch","clearLastFocusedEl","clearMouseEventTimer"],on:{"DOC.HOTKEY":{actions:["focusRegionEl"]},"REGION.BLUR":[{guard:bs("isOverlapping","isPointerOut"),target:"overlap",actions:["collapseToasts","resumeToasts","restoreFocusIfPointerOut"]},{guard:"isPointerOut",target:"stack",actions:["resumeToasts","restoreFocusIfPointerOut"]},{actions:["clearFocusWithin"]}],"TOAST.REMOVE":{actions:["removeToast","removeHeight","ignoreMouseEventsTemporarily"]},"TOAST.PAUSE":{actions:["pauseToasts"]}},states:{stack:{on:{"REGION.POINTER_LEAVE":[{guard:"isOverlapping",target:"overlap",actions:["clearPointerWithin","resumeToasts","collapseToasts"]},{actions:["clearPointerWithin","resumeToasts"]}],"REGION.OVERLAP":{target:"overlap",actions:["collapseToasts"]},"REGION.FOCUS":{actions:["setLastFocusedEl","pauseToasts"]},"REGION.POINTER_ENTER":{actions:["setPointerWithin","pauseToasts"]}}},overlap:{on:{"REGION.STACK":{target:"stack",actions:["expandToasts"]},"REGION.POINTER_ENTER":{target:"stack",actions:["setPointerWithin","pauseToasts","expandToasts"]},"REGION.FOCUS":{target:"stack",actions:["setLastFocusedEl","pauseToasts","expandToasts"]}}}},implementations:{guards:{isOverlapping:({computed:e})=>e("overlap"),isPointerOut:({refs:e})=>!e.get("isPointerWithin")},effects:{subscribeToStore({context:e,prop:t}){let r=t("store");return e.set("toasts",r.getVisibleToasts()),r.subscribe(n=>{if(n.dismiss){e.set("toasts",s=>s.filter(o=>o.id!==n.id));return}e.set("toasts",s=>{let o=s.findIndex(c=>c.id===n.id);return o!==-1?[...s.slice(0,o),h(h({},s[o]),n),...s.slice(o+1)]:[n,...s]})})},trackHotKeyPress({prop:e,send:t}){return B(document,"keydown",n=>{let{hotkey:s}=e("store").attrs;s.every(c=>n[c]||n.code===c)&&t({type:"DOC.HOTKEY"})},{capture:!0})},trackDocumentVisibility({prop:e,send:t,scope:r}){let{pauseOnPageIdle:n}=e("store").attrs;if(!n)return;let s=r.getDoc();return B(s,"visibilitychange",()=>{let o=s.visibilityState==="hidden";t({type:o?"PAUSE_ALL":"RESUME_ALL"})})}},actions:{setDismissableBranch({refs:e,context:t,computed:r,scope:n}){var f;let s=t.get("toasts"),o=r("placement"),c=s.length>0;if(!c){(f=e.get("dismissableCleanup"))==null||f();return}if(c&&e.get("dismissableCleanup"))return;let d=dr(()=>fr(n,o),{defer:!0});e.set("dismissableCleanup",d)},clearDismissableBranch({refs:e}){var t;(t=e.get("dismissableCleanup"))==null||t()},focusRegionEl({scope:e,computed:t}){queueMicrotask(()=>{var r;(r=fr(e,t("placement")))==null||r.focus()})},pauseToasts({prop:e}){e("store").pause()},resumeToasts({prop:e}){e("store").resume()},expandToasts({prop:e}){e("store").expand()},collapseToasts({prop:e}){e("store").collapse()},removeToast({prop:e,event:t}){e("store").remove(t.id)},removeHeight({event:e,context:t}){(e==null?void 0:e.id)!=null&&queueMicrotask(()=>{t.set("heights",r=>r.filter(n=>n.id!==e.id))})},collapsedIfEmpty({send:e,computed:t}){!t("overlap")||t("count")>1||e({type:"REGION.OVERLAP"})},setLastFocusedEl({refs:e,event:t}){e.get("isFocusWithin")||!t.target||(e.set("isFocusWithin",!0),e.set("lastFocusedEl",t.target))},restoreFocusIfPointerOut({refs:e}){var t;!e.get("lastFocusedEl")||e.get("isPointerWithin")||((t=e.get("lastFocusedEl"))==null||t.focus({preventScroll:!0}),e.set("lastFocusedEl",null),e.set("isFocusWithin",!1))},setPointerWithin({refs:e}){e.set("isPointerWithin",!0)},clearPointerWithin({refs:e}){var t;e.set("isPointerWithin",!1),e.get("lastFocusedEl")&&!e.get("isFocusWithin")&&((t=e.get("lastFocusedEl"))==null||t.focus({preventScroll:!0}),e.set("lastFocusedEl",null))},clearFocusWithin({refs:e}){e.set("isFocusWithin",!1)},clearLastFocusedEl({refs:e}){var t;e.get("lastFocusedEl")&&((t=e.get("lastFocusedEl"))==null||t.focus({preventScroll:!0}),e.set("lastFocusedEl",null),e.set("isFocusWithin",!1))},ignoreMouseEventsTemporarily({refs:e}){e.get("ignoreMouseTimer").request()},clearMouseEventTimer({refs:e}){e.get("ignoreMouseTimer").cancel()}}}});function br(e,t){let{state:r,send:n,prop:s,scope:o,context:c,computed:u}=e,d=r.hasTag("visible"),f=r.hasTag("paused"),g=c.get("mounted"),y=u("frontmost"),b=s("parent").computed("placement"),p=s("type"),a=s("stacked"),i=s("title"),l=s("description"),S=s("action"),[w,O="center"]=b.split("-");return{type:p,title:i,description:l,placement:b,visible:d,paused:f,closable:!!s("closable"),pause(){n({type:"PAUSE"})},resume(){n({type:"RESUME"})},dismiss(){n({type:"DISMISS",src:"programmatic"})},getRootProps(){return t.element(E(h({},de.root.attrs),{dir:s("dir"),id:yr(o),"data-state":d?"open":"closed","data-type":p,"data-placement":b,"data-align":O,"data-side":w,"data-mounted":x(g),"data-paused":x(f),"data-first":x(y),"data-sibling":x(!y),"data-stack":x(a),"data-overlap":x(!a),role:"status","aria-atomic":"true","aria-describedby":l?gr(o):void 0,"aria-labelledby":i?pr(o):void 0,tabIndex:0,style:hs(e,d),onKeyDown(A){A.defaultPrevented||A.key=="Escape"&&(n({type:"DISMISS",src:"keyboard"}),A.preventDefault())}}))},getGhostBeforeProps(){return t.element({"data-ghost":"before",style:ps(e,d)})},getGhostAfterProps(){return t.element({"data-ghost":"after",style:gs()})},getTitleProps(){return t.element(E(h({},de.title.attrs),{id:pr(o)}))},getDescriptionProps(){return t.element(E(h({},de.description.attrs),{id:gr(o)}))},getActionTriggerProps(){return t.button(E(h({},de.actionTrigger.attrs),{type:"button",onClick(A){var L;A.defaultPrevented||((L=S==null?void 0:S.onClick)==null||L.call(S),n({type:"DISMISS",src:"user"}))}}))},getCloseTriggerProps(){return t.button(E(h({id:ls(o)},de.closeTrigger.attrs),{type:"button","aria-label":"Dismiss notification",onClick(A){A.defaultPrevented||n({type:"DISMISS",src:"user"})}}))}}}var{not:ws}=te(),Er={props({props:e}){return Ut(e,["id","type","parent","removeDelay"],"toast"),E(h({closable:!0},e),{duration:dt(e.duration,e.type)})},initialState({prop:e}){return e("type")==="loading"||e("duration")===1/0?"visible:persist":"visible"},context({prop:e,bindable:t}){return{remainingTime:t(()=>({defaultValue:dt(e("duration"),e("type"))})),createdAt:t(()=>({defaultValue:Date.now()})),mounted:t(()=>({defaultValue:!1})),initialHeight:t(()=>({defaultValue:0}))}},refs(){return{closeTimerStartTime:Date.now(),lastCloseStartTimerStartTime:0}},computed:{zIndex:({prop:e})=>{let t=e("parent").context.get("toasts"),r=t.findIndex(n=>n.id===e("id"));return t.length-r},height:({prop:e})=>{var n;let r=e("parent").context.get("heights").find(s=>s.id===e("id"));return(n=r==null?void 0:r.height)!=null?n:0},heightIndex:({prop:e})=>e("parent").context.get("heights").findIndex(r=>r.id===e("id")),frontmost:({prop:e})=>e("index")===0,heightBefore:({prop:e})=>{let t=e("parent").context.get("heights"),r=t.findIndex(n=>n.id===e("id"));return t.reduce((n,s,o)=>o>=r?n:n+s.height,0)},shouldPersist:({prop:e})=>e("type")==="loading"||e("duration")===1/0},watch({track:e,prop:t,send:r}){e([()=>t("message")],()=>{let n=t("message");n&&r({type:n,src:"programmatic"})}),e([()=>t("type"),()=>t("duration")],()=>{r({type:"UPDATE"})})},on:{UPDATE:[{guard:"shouldPersist",target:"visible:persist",actions:["resetCloseTimer"]},{target:"visible:updating",actions:["resetCloseTimer"]}],MEASURE:{actions:["measureHeight"]}},entry:["setMounted","measureHeight","invokeOnVisible"],effects:["trackHeight"],states:{"visible:updating":{tags:["visible","updating"],effects:["waitForNextTick"],on:{SHOW:{target:"visible"}}},"visible:persist":{tags:["visible","paused"],on:{RESUME:{guard:ws("isLoadingType"),target:"visible",actions:["setCloseTimer"]},DISMISS:{target:"dismissing"}}},visible:{tags:["visible"],effects:["waitForDuration"],on:{DISMISS:{target:"dismissing"},PAUSE:{target:"visible:persist",actions:["syncRemainingTime"]}}},dismissing:{entry:["invokeOnDismiss"],effects:["waitForRemoveDelay"],on:{REMOVE:{target:"unmounted",actions:["notifyParentToRemove"]}}},unmounted:{entry:["invokeOnUnmount"]}},implementations:{effects:{waitForRemoveDelay({prop:e,send:t}){return Oe(()=>{t({type:"REMOVE",src:"timer"})},e("removeDelay"))},waitForDuration({send:e,context:t,computed:r}){if(!r("shouldPersist"))return Oe(()=>{e({type:"DISMISS",src:"timer"})},t.get("remainingTime"))},waitForNextTick({send:e}){return Oe(()=>{e({type:"SHOW",src:"timer"})},0)},trackHeight({scope:e,prop:t}){let r;return pe(()=>{let n=hr(e);if(!n)return;let s=()=>{let u=n.style.height;n.style.height="auto";let d=n.getBoundingClientRect().height;n.style.height=u;let f={id:t("id"),height:d};vr(t("parent"),f)},o=e.getWin(),c=new o.MutationObserver(s);c.observe(n,{childList:!0,subtree:!0,characterData:!0}),r=()=>c.disconnect()}),()=>r==null?void 0:r()}},guards:{isLoadingType:({prop:e})=>e("type")==="loading",shouldPersist:({computed:e})=>e("shouldPersist")},actions:{setMounted({context:e}){pe(()=>{e.set("mounted",!0)})},measureHeight({scope:e,prop:t,context:r}){queueMicrotask(()=>{let n=hr(e);if(!n)return;let s=n.style.height;n.style.height="auto";let o=n.getBoundingClientRect().height;n.style.height=s,r.set("initialHeight",o);let c={id:t("id"),height:o};vr(t("parent"),c)})},setCloseTimer({refs:e}){e.set("closeTimerStartTime",Date.now())},resetCloseTimer({context:e,refs:t,prop:r}){t.set("closeTimerStartTime",Date.now()),e.set("remainingTime",dt(r("duration"),r("type")))},syncRemainingTime({context:e,refs:t}){e.set("remainingTime",r=>{let n=t.get("closeTimerStartTime"),s=Date.now()-n;return t.set("lastCloseStartTimerStartTime",Date.now()),r-s})},notifyParentToRemove({prop:e}){e("parent").send({type:"TOAST.REMOVE",id:e("id")})},invokeOnDismiss({prop:e,event:t}){var r;(r=e("onStatusChange"))==null||r({status:"dismissing",src:t.src})},invokeOnUnmount({prop:e}){var t;(t=e("onStatusChange"))==null||t({status:"unmounted"})},invokeOnVisible({prop:e}){var t;(t=e("onStatusChange"))==null||t({status:"visible"})}}}};function vr(e,t){let{id:r,height:n}=t;e.context.set("heights",s=>s.find(c=>c.id===r)?s.map(c=>c.id===r?E(h({},c),{height:n}):c):[{id:r,height:n},...s])}var Ts=(e,t)=>h(h({},t),ge(e));function wr(e={}){let t=Ts(e,{placement:"bottom",overlap:!1,max:24,gap:16,offsets:"1rem",hotkey:["altKey","KeyT"],removeDelay:200,pauseOnPageIdle:!0}),r=[],n=[],s=new Set,o=[],c=m=>(r.push(m),()=>{let v=r.indexOf(m);r.splice(v,1)}),u=m=>(r.forEach(v=>v(m)),m),d=m=>{if(n.length>=t.max){o.push(m);return}u(m),n.unshift(m)},f=()=>{for(;o.length>0&&n.length<t.max;){let m=o.shift();m&&(u(m),n.unshift(m))}},g=m=>{var H;let v=(H=m.id)!=null?H:`toast:${rt()}`,F=n.find(q=>q.id===v);return s.has(v)&&s.delete(v),F?n=n.map(q=>q.id===v?u(E(h(h({},q),m),{id:v})):q):d(E(h({id:v,duration:t.duration,removeDelay:t.removeDelay,type:"info"},m),{stacked:!t.overlap,gap:t.gap})),v},y=m=>(s.add(m),m?(r.forEach(v=>v({id:m,dismiss:!0})),n=n.filter(v=>v.id!==m),f()):(n.forEach(v=>{r.forEach(F=>F({id:v.id,dismiss:!0}))}),n=[],o=[]),m);return{attrs:t,subscribe:c,create:g,update:(m,v)=>g(h({id:m},v)),remove:y,dismiss:m=>{m!=null?n=n.map(v=>v.id===m?u(E(h({},v),{message:"DISMISS"})):v):n=n.map(v=>u(E(h({},v),{message:"DISMISS"})))},error:m=>g(E(h({},m),{type:"error"})),success:m=>g(E(h({},m),{type:"success"})),info:m=>g(E(h({},m),{type:"info"})),warning:m=>g(E(h({},m),{type:"warning"})),loading:m=>g(E(h({},m),{type:"loading"})),getVisibleToasts:()=>n.filter(m=>!s.has(m.id)),getCount:()=>n.length,promise:(m,v,F={})=>{if(!v||!v.loading){W("[zag-js > toast] toaster.promise() requires at least a 'loading' option to be specified");return}let H=g(E(h(h({},F),v.loading),{promise:m,type:"loading"})),q=!0,he,Vr=$(m).then(N=>ze(null,null,function*(){if(he=["resolve",N],Ss(N)&&!N.ok){q=!1;let U=$(v.error,`HTTP Error! status: ${N.status}`);g(E(h(h({},F),U),{id:H,type:"error"}))}else if(v.success!==void 0){q=!1;let U=$(v.success,N);g(E(h(h({},F),U),{id:H,type:"success"}))}})).catch(N=>ze(null,null,function*(){if(he=["reject",N],v.error!==void 0){q=!1;let U=$(v.error,N);g(E(h(h({},F),U),{id:H,type:"error"}))}})).finally(()=>{var N;q&&y(H),(N=v.finally)==null||N.call(v)});return{id:H,unwrap:()=>new Promise((N,U)=>Vr.then(()=>he[0]==="reject"?U(he[1]):N(he[1])).catch(U))}},pause:m=>{m!=null?n=n.map(v=>v.id===m?u(E(h({},v),{message:"PAUSE"})):v):n=n.map(v=>u(E(h({},v),{message:"PAUSE"})))},resume:m=>{m!=null?n=n.map(v=>v.id===m?u(E(h({},v),{message:"RESUME"})):v):n=n.map(v=>u(E(h({},v),{message:"RESUME"})))},isVisible:m=>!s.has(m)&&!!n.find(v=>v.id===m),isDismissed:m=>s.has(m),expand:()=>{n=n.map(m=>u(E(h({},m),{stacked:!0})))},collapse:()=>{n=n.map(m=>u(E(h({},m),{stacked:!1})))}}}var Ss=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",ft={connect:ms,machine:Es};var ks=new Map,ht=new Map,pt=class extends z{constructor(r,n){super(r,n);V(this,"parts");V(this,"destroy",()=>{this.machine.stop(),this.el.remove()});this.el.setAttribute("data-scope","toast"),this.el.setAttribute("data-part","root"),this.el.innerHTML=`
<span data-scope="toast" data-part="ghost-before"></span>
<div data-scope="toast" data-part="progressbar"></div>
<div data-scope="toast" data-part="content">
<div data-scope="toast" data-part="title"></div>
<div data-scope="toast" data-part="description"></div>
</div>
<button data-scope="toast" data-part="close-trigger">
<svg viewBox="0 0 20 20" aria-hidden="true">
<path d="M4.293 4.293 10 8.586l5.707-5.707 1.414 1.414L11.414 10l5.707 5.707-1.414 1.414L10 11.414l-5.707 5.707-1.414-1.414L8.586 10 2.879 4.293z"/>
</svg>
</button>
<span data-scope="toast" data-part="ghost-after"></span>
`,this.parts={title:this.el.querySelector('[data-part="title"]'),description:this.el.querySelector('[data-part="description"]'),close:this.el.querySelector('[data-part="close-trigger"]'),ghostBefore:this.el.querySelector('[data-part="ghost-before"]'),ghostAfter:this.el.querySelector('[data-part="ghost-after"]')}}initMachine(r){return new se(Er,r)}initApi(){return br(this.machine.service,ne)}render(){var r,n;this.spreadProps(this.el,this.api.getRootProps()),this.spreadProps(this.parts.close,this.api.getCloseTriggerProps()),this.spreadProps(this.parts.ghostBefore,this.api.getGhostBeforeProps()),this.spreadProps(this.parts.ghostAfter,this.api.getGhostAfterProps()),this.parts.title.textContent!==this.api.title&&(this.parts.title.textContent=(r=this.api.title)!=null?r:""),this.parts.description.textContent!==this.api.description&&(this.parts.description.textContent=(n=this.api.description)!=null?n:""),this.spreadProps(this.parts.title,this.api.getTitleProps()),this.spreadProps(this.parts.description,this.api.getDescriptionProps())}},gt=class extends z{constructor(r,n){var s;super(r,n);V(this,"toastComponents",new Map);V(this,"groupEl");V(this,"store");V(this,"destroy",()=>{for(let r of this.toastComponents.values())r.destroy();this.toastComponents.clear(),this.machine.stop()});this.store=n.store,this.groupEl=(s=r.querySelector('[data-part="group"]'))!=null?s:(()=>{let o=document.createElement("div");return o.setAttribute("data-scope","toast"),o.setAttribute("data-part","group"),r.appendChild(o),o})()}initMachine(r){return new se(ft.machine,r)}initApi(){return ft.connect(this.machine.service,ne)}render(){this.spreadProps(this.groupEl,this.api.getGroupProps());let r=this.api.getToasts().filter(s=>typeof s.id=="string"),n=new Set(r.map(s=>s.id));r.forEach((s,o)=>{let c=this.toastComponents.get(s.id);if(c)c.updateProps(E(h({},s),{parent:this.machine.service,index:o}));else{let u=document.createElement("div");u.setAttribute("data-scope","toast"),u.setAttribute("data-part","root"),this.groupEl.appendChild(u),c=new pt(u,E(h({},s),{parent:this.machine.service,index:o})),c.init(),this.toastComponents.set(s.id,c)}});for(let[s,o]of this.toastComponents)n.has(s)||(o.destroy(),this.toastComponents.delete(s))}};function Tr(e,t){var o,c,u;let r=(o=t==null?void 0:t.id)!=null?o:J(e,"toast"),n=(u=t==null?void 0:t.store)!=null?u:wr({placement:(c=t==null?void 0:t.placement)!=null?c:"bottom",overlap:t==null?void 0:t.overlap,max:t==null?void 0:t.max,gap:t==null?void 0:t.gap,offsets:t==null?void 0:t.offsets,pauseOnPageIdle:t==null?void 0:t.pauseOnPageIdle}),s=new gt(e,{id:r,store:n});return s.init(),ks.set(r,s),ht.set(r,n),e.dataset.toastGroup="true",e.dataset.toastGroupId=r,{group:s,store:n}}function Z(e){if(e)return ht.get(e);let t=document.querySelector("[data-toast-group]");if(!t)return;let r=t.dataset.toastGroupId||t.id;return r?ht.get(r):void 0}function As(e){let t=Z(e);t&&t.create({title:"Disconnected",description:"You have been disconnected from the server.",type:"info"})}function Is(e){let t=Z(e);t&&t.create({title:"Connected",description:"You have been connected to the server.",type:"success"})}var Sr={mounted(){let e=this.el;e.id||(e.id=J(e,"toast"));let t=e.id,r=M(e,"placement",["top-start","top","top-end","bottom-start","bottom","bottom-end"])||"bottom-end",n=C(e,"overlap"),s=ut(e,"max"),o=ut(e,"gap"),c=M(e,"offset"),u=C(e,"pause-on-page-idle"),d;if(c)try{d=c.includes("{")?JSON.parse(c):c}catch(a){d=c}Tr(e,{id:t,placement:r,overlap:n,max:s,gap:o,offsets:d,pauseOnPageIdle:u}),this.handleEvent("toast-create",a=>{let i=Z(a.groupId||t);if(i)try{i.create({title:a.title,description:a.description,type:a.type||"info",id:a.id||J(void 0,"toast"),duration:a.duration})}catch(l){console.error("Failed to create toast:",l)}}),this.handleEvent("toast-update",a=>{let i=Z(a.groupId||t);if(i)try{i.update(a.id,{title:a.title,description:a.description,type:a.type})}catch(l){console.error("Failed to update toast:",l)}}),this.handleEvent("toast-dismiss",a=>{let i=Z(a.groupId||t);if(i)try{i.dismiss(a.id)}catch(l){console.error("Failed to dismiss toast:",l)}}),e.addEventListener("toast:create",a=>{let{detail:i}=a,l=Z(i.groupId||t);if(l)try{l.create({title:i.title,description:i.description,type:i.type||"info",id:i.id||J(void 0,"toast"),duration:i.duration})}catch(S){console.error("Failed to create toast:",S)}});let f=Z(t),g=e.dataset.flashInfo,y=e.dataset.flashError;if(f&&g)try{f.create({title:g,type:"info",id:J(void 0,"toast")})}catch(a){console.error("Failed to create flash info toast:",a)}if(f&&y)try{f.create({title:y,type:"error",id:J(void 0,"toast")})}catch(a){console.error("Failed to create flash error toast:",a)}let b=()=>As(t),p=()=>Is(t);this._toastDisconnect=b,this._toastConnect=p,window.addEventListener("phx:disconnect",b),window.addEventListener("phx:connect",p)},destroyed(){let e=this;e._toastDisconnect&&window.removeEventListener("phx:disconnect",e._toastDisconnect),e._toastConnect&&window.removeEventListener("phx:connect",e._toastConnect)}};function Cs(e){return!(e.metaKey||!Pe()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}var Os=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function Ls(e,t,r){let n=r?ee(r):null,s=K(n);return e=e||n instanceof s.HTMLInputElement&&!Os.has(n==null?void 0:n.type)||n instanceof s.HTMLTextAreaElement||n instanceof s.HTMLElement&&n.isContentEditable,!(e&&t==="keyboard"&&r instanceof s.KeyboardEvent&&!Reflect.has(Ms,r.key))}var ie=null,mt=new Set,Be=new Map,oe=!1,vt=!1,Ms={Tab:!0,Escape:!0};function qe(e,t){for(let r of mt)r(e,t)}function Ke(e){oe=!0,Cs(e)&&(ie="keyboard",qe("keyboard",e))}function _(e){ie="pointer",(e.type==="mousedown"||e.type==="pointerdown")&&(oe=!0,qe("pointer",e))}function Pr(e){kt(e)&&(oe=!0,ie="virtual")}function kr(e){let t=ee(e);t===K(t)||t===Q(t)||(!oe&&!vt&&(ie="virtual",qe("virtual",e)),oe=!1,vt=!1)}function Ar(){oe=!1,vt=!0}function xs(e){if(typeof window=="undefined"||Be.get(K(e)))return;let t=K(e),r=Q(e),n=t.HTMLElement.prototype.focus;function s(){ie="virtual",qe("virtual",null),oe=!0,n.apply(this,arguments)}try{Object.defineProperty(t.HTMLElement.prototype,"focus",{configurable:!0,value:s})}catch(o){}r.addEventListener("keydown",Ke,!0),r.addEventListener("keyup",Ke,!0),r.addEventListener("click",Pr,!0),t.addEventListener("focus",kr,!0),t.addEventListener("blur",Ar,!1),typeof t.PointerEvent!="undefined"?(r.addEventListener("pointerdown",_,!0),r.addEventListener("pointermove",_,!0),r.addEventListener("pointerup",_,!0)):(r.addEventListener("mousedown",_,!0),r.addEventListener("mousemove",_,!0),r.addEventListener("mouseup",_,!0)),t.addEventListener("beforeunload",()=>{Rs(e)},{once:!0}),Be.set(t,{focus:n})}var Rs=(e,t)=>{let r=K(e),n=Q(e),s=Be.get(r);if(s){try{Object.defineProperty(r.HTMLElement.prototype,"focus",{configurable:!0,value:s.focus})}catch(o){}n.removeEventListener("keydown",Ke,!0),n.removeEventListener("keyup",Ke,!0),n.removeEventListener("click",Pr,!0),r.removeEventListener("focus",kr,!0),r.removeEventListener("blur",Ar,!1),typeof r.PointerEvent!="undefined"?(n.removeEventListener("pointerdown",_,!0),n.removeEventListener("pointermove",_,!0),n.removeEventListener("pointerup",_,!0)):(n.removeEventListener("mousedown",_,!0),n.removeEventListener("mousemove",_,!0),n.removeEventListener("mouseup",_,!0)),Be.delete(r)}};function je(){return ie==="keyboard"}function Ir(e={}){let{isTextInput:t,autoFocus:r,onChange:n,root:s}=e;xs(s),n==null||n({isFocusVisible:r||je(),modality:ie});let o=(c,u)=>{Ls(!!t,c,u)&&(n==null||n({isFocusVisible:je(),modality:c}))};return mt.add(o),()=>{mt.delete(o)}}var Vs=G("switch").parts("root","label","control","thumb"),Ge=Vs.build(),Lr=e=>{var t,r;return(r=(t=e.ids)==null?void 0:t.root)!=null?r:`switch:${e.id}`},Cr=e=>{var t,r;return(r=(t=e.ids)==null?void 0:t.label)!=null?r:`switch:${e.id}:label`},Ds=e=>{var t,r;return(r=(t=e.ids)==null?void 0:t.thumb)!=null?r:`switch:${e.id}:thumb`},Ns=e=>{var t,r;return(r=(t=e.ids)==null?void 0:t.control)!=null?r:`switch:${e.id}:control`},yt=e=>{var t,r;return(r=(t=e.ids)==null?void 0:t.hiddenInput)!=null?r:`switch:${e.id}:input`},_s=e=>e.getById(Lr(e)),fe=e=>e.getById(yt(e));function Mr(e,t){let{context:r,send:n,prop:s,scope:o}=e,c=!!s("disabled"),u=!!s("readOnly"),d=!!s("required"),f=!!r.get("checked"),g=!c&&r.get("focused"),y=!c&&r.get("focusVisible"),b=!c&&r.get("active"),p={"data-active":x(b),"data-focus":x(g),"data-focus-visible":x(y),"data-readonly":x(u),"data-hover":x(r.get("hovered")),"data-disabled":x(c),"data-state":f?"checked":"unchecked","data-invalid":x(s("invalid")),"data-required":x(d)};return{checked:f,disabled:c,focused:g,setChecked(a){n({type:"CHECKED.SET",checked:a,isTrusted:!1})},toggleChecked(){n({type:"CHECKED.TOGGLE",checked:f,isTrusted:!1})},getRootProps(){return t.label(E(h(h({},Ge.root.attrs),p),{dir:s("dir"),id:Lr(o),htmlFor:yt(o),onPointerMove(){c||n({type:"CONTEXT.SET",context:{hovered:!0}})},onPointerLeave(){c||n({type:"CONTEXT.SET",context:{hovered:!1}})},onClick(a){var l;if(c)return;ee(a)===fe(o)&&a.stopPropagation(),ke()&&((l=fe(o))==null||l.focus())}}))},getLabelProps(){return t.element(E(h(h({},Ge.label.attrs),p),{dir:s("dir"),id:Cr(o)}))},getThumbProps(){return t.element(E(h(h({},Ge.thumb.attrs),p),{dir:s("dir"),id:Ds(o),"aria-hidden":!0}))},getControlProps(){return t.element(E(h(h({},Ge.control.attrs),p),{dir:s("dir"),id:Ns(o),"aria-hidden":!0}))},getHiddenInputProps(){return t.input({id:yt(o),type:"checkbox",required:s("required"),defaultChecked:f,disabled:c,"aria-labelledby":Cr(o),"aria-invalid":s("invalid"),name:s("name"),form:s("form"),value:s("value"),style:Nt,onFocus(){let a=je();n({type:"CONTEXT.SET",context:{focused:!0,focusVisible:a}})},onBlur(){n({type:"CONTEXT.SET",context:{focused:!1,focusVisible:!1}})},onClick(a){if(u){a.preventDefault();return}let i=a.currentTarget.checked;n({type:"CHECKED.SET",checked:i,isTrusted:!0})}})}}}var{not:Or}=te(),xr={props({props:e}){return h({defaultChecked:!1,label:"switch",value:"on"},e)},initialState(){return"ready"},context({prop:e,bindable:t}){return{checked:t(()=>({defaultValue:e("defaultChecked"),value:e("checked"),onChange(r){var n;(n=e("onCheckedChange"))==null||n({checked:r})}})),fieldsetDisabled:t(()=>({defaultValue:!1})),focusVisible:t(()=>({defaultValue:!1})),active:t(()=>({defaultValue:!1})),focused:t(()=>({defaultValue:!1})),hovered:t(()=>({defaultValue:!1}))}},computed:{isDisabled:({context:e,prop:t})=>t("disabled")||e.get("fieldsetDisabled")},watch({track:e,prop:t,context:r,action:n}){e([()=>t("disabled")],()=>{n(["removeFocusIfNeeded"])}),e([()=>r.get("checked")],()=>{n(["syncInputElement"])})},effects:["trackFormControlState","trackPressEvent","trackFocusVisible"],on:{"CHECKED.TOGGLE":[{guard:Or("isTrusted"),actions:["toggleChecked","dispatchChangeEvent"]},{actions:["toggleChecked"]}],"CHECKED.SET":[{guard:Or("isTrusted"),actions:["setChecked","dispatchChangeEvent"]},{actions:["setChecked"]}],"CONTEXT.SET":{actions:["setContext"]}},states:{ready:{}},implementations:{guards:{isTrusted:({event:e})=>!!e.isTrusted},effects:{trackPressEvent({computed:e,scope:t,context:r}){if(!e("isDisabled"))return Lt({pointerNode:_s(t),keyboardNode:fe(t),isValidKey:n=>n.key===" ",onPress:()=>r.set("active",!1),onPressStart:()=>r.set("active",!0),onPressEnd:()=>r.set("active",!1)})},trackFocusVisible({computed:e,scope:t}){if(!e("isDisabled"))return Ir({root:t.getRootNode()})},trackFormControlState({context:e,send:t,scope:r}){return Ct(fe(r),{onFieldsetDisabledChange(n){e.set("fieldsetDisabled",n)},onFormReset(){let n=e.initial("checked");t({type:"CHECKED.SET",checked:!!n,src:"form-reset"})}})}},actions:{setContext({context:e,event:t}){for(let r in t.context)e.set(r,t.context[r])},syncInputElement({context:e,scope:t}){let r=fe(t);r&&et(r,!!e.get("checked"))},removeFocusIfNeeded({context:e,prop:t}){t("disabled")&&e.set("focused",!1)},setChecked({context:e,event:t}){e.set("checked",t.checked)},toggleChecked({context:e}){e.set("checked",!e.get("checked"))},dispatchChangeEvent({context:e,scope:t}){queueMicrotask(()=>{let r=fe(t);It(r,{checked:e.get("checked")})})}}}},Fs=ve()(["checked","defaultChecked","dir","disabled","form","getRootNode","id","ids","invalid","label","name","onCheckedChange","readOnly","required","value"]),pi=me(Fs);var $e=class extends z{initMachine(t){return new se(xr,t)}initApi(){return Mr(this.machine.service,ne)}render(){let t=this.el.querySelector('[data-part="root"]')||this.el;this.spreadProps(t,this.api.getRootProps());let r=this.el.querySelector('[data-part="hidden-input"]');r&&this.spreadProps(r,this.api.getHiddenInputProps());let n=this.el.querySelector('[data-part="label"]');n&&this.spreadProps(n,this.api.getLabelProps());let s=this.el.querySelector('[data-part="control"]');s&&this.spreadProps(s,this.api.getControlProps());let o=this.el.querySelector('[data-part="thumb"]');o&&this.spreadProps(o,this.api.getThumbProps())}};var Rr={mounted(){let e=this.el,t=this.pushEvent.bind(this),r=new $e(e,E(h({id:e.id},C(e,"controlled")?{checked:C(e,"checked")}:{defaultChecked:C(e,"default-checked")}),{disabled:C(e,"disabled"),name:M(e,"name"),form:M(e,"form"),value:M(e,"value"),dir:M(e,"dir",["ltr","rtl"]),invalid:C(e,"invalid"),required:C(e,"required"),readOnly:C(e,"readOnly"),label:M(e,"label"),onCheckedChange:n=>{let s=M(e,"onCheckedChange");s&&!this.liveSocket.main.isDead&&this.liveSocket.main.isConnected()&&t(s,{checked:n.checked,switch_id:e.id});let o=M(e,"onCheckedChangeClient");o&&e.dispatchEvent(new CustomEvent(o,{bubbles:!0,detail:{value:n,switch_id:e.id}}))}}));r.init(),this.zagSwitch=r,this.onSetChecked=n=>{let{value:s}=n.detail;r.api.setChecked(s)},e.addEventListener("phx:switch:set-checked",this.onSetChecked),this.handlers=[],this.handlers.push(this.handleEvent("switch_set_checked",n=>{let s=n.switch_id;s&&s!==e.id||r.api.setChecked(n.value)})),this.handlers.push(this.handleEvent("switch_toggle_checked",n=>{let s=n.switch_id;s&&s!==e.id||r.api.toggleChecked()})),this.handlers.push(this.handleEvent("switch_checked",()=>{this.pushEvent("switch_checked_response",{value:r.api.checked})})),this.handlers.push(this.handleEvent("switch_focused",()=>{this.pushEvent("switch_focused_response",{value:r.api.focused})})),this.handlers.push(this.handleEvent("switch_disabled",()=>{this.pushEvent("switch_disabled_response",{value:r.api.disabled})}))},beforeUpdate(){var e;this.wasFocused=((e=this.zagSwitch)==null?void 0:e.api.focused)||!1},updated(){var e;if((e=this.zagSwitch)==null||e.updateProps(E(h({id:this.el.id},C(this.el,"controlled")?{checked:C(this.el,"checked")}:{defaultChecked:C(this.el,"default-checked")}),{disabled:C(this.el,"disabled"),name:M(this.el,"name"),value:M(this.el,"value"),dir:M(this.el,"dir",["ltr","rtl"]),invalid:C(this.el,"invalid"),required:C(this.el,"required"),readOnly:C(this.el,"read-only"),label:M(this.el,"label")})),C(this.el,"controlled")&&this.wasFocused){let t=this.el.querySelector('[data-part="hidden-input"]');t==null||t.focus()}},destroyed(){var e;if(this.onSetChecked&&this.el.removeEventListener("phx:switch:set-checked",this.onSetChecked),this.handlers)for(let t of this.handlers)this.removeHandleEvent(t);(e=this.zagSwitch)==null||e.destroy()}};var Bs={Accordion:ur,Toast:Sr,Switch:Rr},Ks=Bs;return jr(js);})();