@zag-js/toast 0.0.0-dev-20220412160604 → 0.0.0-dev-20220412212252

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,10 +12,8 @@ npm i @zag-js/toast
12
12
 
13
13
  ## Contribution
14
14
 
15
- Yes please! See the [contributing guidelines](https://github.com/chakra-ui/ui-machines/blob/main/CONTRIBUTING.md) for
16
- details.
15
+ Yes please! See the [contributing guidelines](https://github.com/chakra-ui/zag/blob/main/CONTRIBUTING.md) for details.
17
16
 
18
17
  ## Licence
19
18
 
20
- This project is licensed under the terms of the
21
- [MIT license](https://github.com/chakra-ui/ui-machines/blob/main/LICENSE).
19
+ This project is licensed under the terms of the [MIT license](https://github.com/chakra-ui/zag/blob/main/LICENSE).
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var E=Object.defineProperty,W=Object.defineProperties,$=Object.getOwnPropertyDescriptor,K=Object.getOwnPropertyDescriptors,Y=Object.getOwnPropertyNames,w=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var C=(t,e,n)=>e in t?E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,f=(t,e)=>{for(var n in e||(e={}))T.call(e,n)&&C(t,n,e[n]);if(w)for(var n of w(e))I.call(e,n)&&C(t,n,e[n]);return t},g=(t,e)=>W(t,K(e)),X=t=>E(t,"__esModule",{value:!0});var O=(t,e)=>{var n={};for(var r in t)T.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&w)for(var r of w(t))e.indexOf(r)<0&&I.call(t,r)&&(n[r]=t[r]);return n};var Z=(t,e)=>{for(var n in e)E(t,n,{get:e[n],enumerable:!0})},J=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Y(e))!T.call(t,o)&&(n||o!=="default")&&E(t,o,{get:()=>e[o],enumerable:!(r=$(e,o))||r.enumerable});return t};var Q=(t=>(e,n)=>t&&t.get(e)||(n=J(X({}),e,1),t&&t.set(e,n),n))(typeof WeakMap!="undefined"?new WeakMap:0);var ft={};Z(ft,{api:()=>pt,connect:()=>H,createMachine:()=>P,group:()=>dt});var A=(t,...e)=>{let n=typeof t=="function"?t(...e):t;return n!=null?n:void 0};var gt=(()=>{let t=0;return()=>(t++,t.toString(36))})();var D=()=>typeof window!="undefined";function _(...t){let e=t.length===1?t[0]:t[1],n=t.length===2?t[0]:!0}var V=require("@zag-js/core");function tt(t){return{button:t,label:t,input:t,output:t,element:t}}var S=tt(t=>t);var d={getDoc:t=>{var e;return(e=t.doc)!=null?e:document},getGroupId:t=>`toast-group--${t}`,getContainerId:t=>`toast--${t.id}`,getTitleId:t=>`toast-title--${t.id}`,getCloseButtonId:t=>`toast-close-button--${t.id}`,getPortalId:t=>`toast-portal--${t.uid}`,getPortalEl:t=>d.getDoc(t).getElementById(d.getPortalId(t)),createPortalEl:t=>{let e=d.getPortalEl(t);if(e)return e;let n=d.getDoc(t).createElement("toast-portal");return n.id=d.getPortalId(t),n}};function R(t){let e={};for(let n of t){let r=n.state.context.placement;e[r]||(e[r]=[]),e[r].push(n)}return e}var et={info:5e3,error:5e3,success:2e3,loading:1/0,custom:5e3};function M(t,e){return t!=null?t:et[e]}function U(t,e){let n=t.offsets,r=typeof n=="string"?{left:n,right:n,bottom:n,top:n}:n,o=t.dir==="rtl",a=e.replace("-start",o?"-right":"-left").replace("-end",o?"-left":"-right"),l=a.includes("right"),m=a.includes("left"),c={position:"fixed",pointerEvents:t.count>0?void 0:"none",display:"flex",flexDirection:"column","--toast-gutter":t.gutter,zIndex:t.zIndex},i="center";if(l&&(i="flex-end"),m&&(i="flex-start"),c.alignItems=i,a.includes("top")){let s=r.top;c.top=`calc(env(safe-area-inset-top, 0px) + ${s})`}if(a.includes("bottom")){let s=r.bottom;c.bottom=`calc(env(safe-area-inset-bottom, 0px) + ${s})`}if(!a.includes("left")){let s=r.right;c.right=`calc(env(safe-area-inset-right, 0px) + ${s})`}if(!a.includes("right")){let s=r.left;c.left=`calc(env(safe-area-inset-left, 0px) + ${s})`}return c}var L={};function F(t,e,n=S){let r={count:t.context.count,toasts:t.context.toasts,toastsByPlacement:R(t.context.toasts),isVisible(o){return t.context.toasts.length?!!t.context.toasts.find(a=>a.id==o):!1},create(o){let a="toast-"+Math.random().toString(36).substring(2,9),l=o.id?o.id:a;if(!r.isVisible(l))return e({type:"ADD_TOAST",toast:g(f({},o),{id:l})}),l},upsert(o){let{id:a}=o;return(a?r.isVisible(a):!1)&&a!=null?r.update(a,o):r.create(o)},dismiss(o){o==null?e("DISMISS_ALL"):r.isVisible(o)&&e({type:"DISMISS_TOAST",id:o})},remove(o){o==null?e("REMOVE_ALL"):r.isVisible(o)&&e({type:"REMOVE_TOAST",id:o})},dismissByPlacement(o){let a=r.toastsByPlacement[o];a&&a.forEach(l=>r.dismiss(l.id))},update(o,a){if(!!r.isVisible(o))return e({type:"UPDATE_TOAST",id:o,toast:a}),o},loading(o){return o.type="loading",r.upsert(o)},success(o){return o.type="success",r.upsert(o)},error(o){return o.type="error",r.upsert(o)},promise(o,a,l={}){let m=r.loading(g(f(f({},l),l==null?void 0:l.loading),{type:"loading",title:a.loading}));return o.then(c=>{let i=A(a.loading,c);r.success(g(f(f({},l),l==null?void 0:l.success),{id:m,title:i}))}).catch(c=>{let i=A(a.error,c);r.error(g(f(f({},l),l==null?void 0:l.error),{id:m,title:i}))}),o},pause(o){o==null?e("PAUSE_ALL"):r.isVisible(o)&&e({type:"PAUSE_TOAST",id:o})},resume(o){o==null?e("RESUME_ALL"):r.isVisible(o)&&e({type:"RESUME_TOAST",id:o})},getGroupProps(o){let{placement:a,label:l="Notifications"}=o;return n.element({tabIndex:-1,"aria-label":l,id:d.getGroupId(a),"data-placement":a,"aria-live":"polite",role:"region",style:U(t.context,a)})},createPortal(){let o=d.getDoc(t.context),a=d.getPortalEl(t.context);if(a)return a;let l=d.createPortalEl(t.context);return o.body.appendChild(l),l},subscribe(o){return(0,V.subscribe)(t.context.toasts,()=>o(t.context.toasts))}};return t.matches("unknown")||Object.assign(L,r),r}var b=require("@zag-js/core");var N=t=>t?"":void 0;var nt=t=>t,ot=()=>{};var Lt=(()=>{let t=0;return()=>(t++,t.toString(36))})();var y=new Map,v=new Map;function rt(t,e,n,r){var o;if(!t)return ot;let a=JSON.stringify({type:e,options:r}),l=y.get(t);if(y.has(t))(l==null?void 0:l.has(a))?(o=l==null?void 0:l.get(a))==null||o.add(n):l==null||l.set(a,new Set([n]));else{let c=new Map([[a,new Set([n])]]);y.set(t,c)}function m(c){var i,s;function u(p){var h;let k=y.get(c);(h=k==null?void 0:k.get(a))==null||h.forEach(q=>q(p))}if(!(v==null?void 0:v.has(c))){v.set(c,new Map([[a,u]])),c.addEventListener(e,u,r);return}((i=v==null?void 0:v.get(c))==null?void 0:i.has(a))||((s=v.get(c))==null||s.set(a,u),c.addEventListener(e,u,r))}return m(t),function(){var c,i,s,u;if(!y.has(t))return;let p=y.get(t);if((c=p==null?void 0:p.get(a))==null||c.delete(n),((i=p==null?void 0:p.get(a))==null?void 0:i.size)===0){let h=(s=v.get(t))==null?void 0:s.get(a);t.removeEventListener(e,h,r),p==null||p.delete(a),(u=v.get(t))==null||u.delete(a),(p==null?void 0:p.size)===0&&(y.delete(t),v.delete(t))}}}var B=t=>Object.prototype.toString.call(t).slice(8,-1),it=t=>B(t)==="Object"&&"current"in t,at=t=>B(t)==="Function"?t():t;function st(t,e,n,r){let o=it(t)?t.current:at(t);return rt(o,e,n,r)}var z=2147483647;var kt=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","embed","iframe","object","a[href]","area[href]","[tabindex]","audio[controls]","video[controls]","*[tabindex]:not([aria-disabled])","[contenteditable]:not([contenteditable=false])","details > summary:first-of-type"].join(",");function j(t,e){let n=nt(t);return st(n,"visibilitychange",()=>{let r=n.hidden||n.msHidden||n.webkitHidden;e(!!r)})}var x=require("@zag-js/core");var{not:lt,and:ct,or:ut}=x.guards;function P(t={}){let c=t,{type:e="info",duration:n,id:r="toast",placement:o="bottom",removeDelay:a=500}=c,l=O(c,["type","duration","id","placement","removeDelay"]),m=M(n,e);return(0,x.createMachine)({id:r,entry:"invokeOnOpen",initial:e==="loading"?"persist":"active",context:f({id:r,type:e,remaining:m,duration:m,removeDelay:a,createdAt:Date.now(),placement:o},l),on:{UPDATE:[{guard:ct("hasTypeChanged","isChangingToLoading"),target:"persist",actions:["setContext","invokeOnUpdate"]},{guard:ut("hasDurationChanged","hasTypeChanged"),target:"active:temp",actions:["setContext","invokeOnUpdate"]},{actions:["setContext","invokeOnUpdate"]}]},states:{"active:temp":{tags:["visible","updating"],after:{0:"active"}},persist:{tags:["visible","paused"],activities:"trackDocumentVisibility",on:{RESUME:{guard:lt("isLoadingType"),target:"active",actions:["setCreatedAt"]},DISMISS:"dismissing"}},active:{tags:["visible"],activities:"trackDocumentVisibility",after:{VISIBLE_DURATION:"dismissing"},on:{DISMISS:"dismissing",PAUSE:{target:"persist",actions:"setRemainingDuration"}}},dismissing:{entry:"invokeOnClosing",after:{REMOVE_DELAY:{target:"inactive",actions:"notifyParentToRemove"}}},inactive:{entry:"invokeOnClose",type:"final"}}},{activities:{trackDocumentVisibility(i,s,{send:u}){if(!!i.pauseOnPageIdle)return j(d.getDoc(i),function(p){u(p?"PAUSE":"RESUME")})}},guards:{isChangingToLoading:(i,s)=>{var u;return((u=s.toast)==null?void 0:u.type)==="loading"},isLoadingType:i=>i.type==="loading",hasTypeChanged:(i,s)=>{var u;return((u=s.toast)==null?void 0:u.type)!==i.type},hasDurationChanged:(i,s)=>{var u;return((u=s.toast)==null?void 0:u.duration)!==i.duration}},delays:{VISIBLE_DURATION:i=>i.remaining,REMOVE_DELAY:i=>i.removeDelay},actions:{setRemainingDuration(i){i.remaining-=Date.now()-i.createdAt},setCreatedAt(i){i.createdAt=Date.now()},notifyParentToRemove(i,s,{self:u}){u.sendParent({type:"REMOVE_TOAST",id:u.id})},invokeOnClosing(i){var s;(s=i.onClosing)==null||s.call(i)},invokeOnClose(i){var s;(s=i.onClose)==null||s.call(i)},invokeOnOpen(i){var s;(s=i.onOpen)==null||s.call(i)},invokeOnUpdate(i){var s;(s=i.onUpdate)==null||s.call(i)},setContext(i,s){let{duration:u,type:p}=s.toast,h=M(u,p);Object.assign(i,g(f({},s.toast),{duration:h,remaining:h}))}}})}var G=(0,b.createMachine)({id:"toaster",initial:"active",context:{dir:"ltr",max:Number.MAX_SAFE_INTEGER,uid:"",toasts:[],gutter:"1rem",zIndex:z,pauseOnPageIdle:!1,pauseOnInteraction:!0,offsets:{left:"0px",right:"0px",top:"0px",bottom:"0px"}},computed:{count:t=>t.toasts.length},on:{SETUP:{actions:(t,e)=>{t.uid=e.id,e.doc&&(t.doc=(0,b.ref)(e.doc))}},PAUSE_TOAST:{actions:(t,e,{self:n})=>{n.sendChild("PAUSE",e.id)}},PAUSE_ALL:{actions:t=>{t.toasts.forEach(e=>e.send("PAUSE"))}},RESUME_TOAST:{actions:(t,e,{self:n})=>{n.sendChild("RESUME",e.id)}},RESUME_ALL:{actions:t=>{t.toasts.forEach(e=>e.send("RESUME"))}},ADD_TOAST:{guard:t=>t.toasts.length<t.max,actions:(t,e,{self:n})=>{var l;let r=g(f({},e.toast),{pauseOnPageIdle:t.pauseOnPageIdle,pauseOnInteraction:t.pauseOnInteraction,dir:t.dir,doc:(0,b.ref)((l=t.doc)!=null?l:document)}),o=P(r),a=n.spawn(o);t.toasts.push(a)}},UPDATE_TOAST:{actions:(t,e,{self:n})=>{n.sendChild({type:"UPDATE",toast:e.toast},e.id)}},DISMISS_TOAST:{actions:(t,e,{self:n})=>{n.sendChild("DISMISS",e.id)}},DISMISS_ALL:{actions:t=>{t.toasts.forEach(e=>e.send("DISMISS"))}},REMOVE_TOAST:{actions:(t,e,{self:n})=>{n.stopChild(e.id);let r=t.toasts.findIndex(o=>o.id===e.id);t.toasts.splice(r,1)}},REMOVE_ALL:{actions:(t,e,{self:n})=>{for(t.toasts.forEach(r=>n.stopChild(r.id));t.toasts.length;)t.toasts.pop()}}}});function H(t,e,n=S){let r=t.hasTag("visible"),o=t.hasTag("paused"),a=t.hasTag("updating"),l=t.context.dir==="rtl",m=t.context.type,c=t.context.pauseOnInteraction,i=t.context.placement;return{type:t.context.type,title:t.context.title,placement:i,isVisible:r,isPaused:o,pause(){e("PAUSE")},resume(){e("RESUME")},dismiss(){e("DISMISS")},rootProps:n.element({"data-part":"root",dir:t.context.dir,id:d.getContainerId(t.context),"data-open":N(r),"data-type":t.context.type,"data-placement":i,role:"status","aria-atomic":"true",tabIndex:0,style:{position:"relative",pointerEvents:"auto",margin:"calc(var(--toast-gutter) / 2)","--remove-delay":`${t.context.removeDelay}ms`,"--duration":`${t.context.duration}ms`},onKeyDown(s){s.key=="Escape"&&(e("DISMISS"),s.preventDefault(),s.stopPropagation())},onFocus(){c&&e("PAUSE")},onBlur(){c&&e("RESUME")},onPointerEnter(){c&&e("PAUSE")},onPointerLeave(){c&&e("RESUME")}}),progressbarProps:n.element({"data-part":"progressbar","data-type":t.context.type,style:{opacity:r?1:0,transformOrigin:l?"right":"left",animationName:a||m==="loading"?"none":void 0,animationPlayState:o?"paused":"running",animationDuration:`${t.context.duration}ms`,animationFillMode:a?void 0:"forwards"}}),titleProps:n.element({"data-part":"title",id:d.getTitleId(t.context)}),closeButtonProps:n.button({id:d.getCloseButtonId(t.context),"data-part":"close-button",type:"button","aria-label":"Dismiss notification",onClick(){e("DISMISS")}}),render(){var s,u;return(u=(s=t.context).render)==null?void 0:u.call(s,{id:t.context.id,type:t.context.type,duration:t.context.duration,title:t.context.title,placement:t.context.placement,description:t.context.description,dismiss(){e("DISMISS")}})}}}var dt={connect:F,machine:G};function pt(){if(!D())_("toast.api() is only available in the browser");else return L}module.exports=Q(ft);
1
+ var Y=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var _t=Object.getOwnPropertyNames;var jt=Object.prototype.hasOwnProperty;var Nt=(t,e)=>{for(var o in e)Y(t,o,{get:e[o],enumerable:!0})},Vt=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _t(e))!jt.call(t,i)&&i!==o&&Y(t,i,{get:()=>e[i],enumerable:!(r=Rt(e,i))||r.enumerable});return t};var Wt=t=>Vt(Y({},"__esModule",{value:!0}),t);var we={};Nt(we,{api:()=>Se,connect:()=>It,createMachine:()=>q,group:()=>Ee});module.exports=Wt(we);var X=(t,...e)=>{let o=typeof t=="function"?t(...e):t;return o??void 0};var Ae=(()=>{let t=0;return()=>(t++,t.toString(36))})();var st=()=>typeof window<"u";function at(...t){let e=t.length===1?t[0]:t[1],o=t.length===2?t[0]:!0}var K={},Pe=Symbol(),Me=Symbol(),Ut=Symbol(),lt=Object.getPrototypeOf,tt=new WeakMap,Bt=t=>t&&(tt.has(t)?tt.get(t):lt(t)===Object.prototype||lt(t)===Array.prototype),Ft=t=>Bt(t)&&t[Ut]||null,ct=(t,e=!0)=>{tt.set(t,e)},yt=Symbol(),T=Symbol(),z=Symbol(),zt=Symbol(),_=Symbol(),ut=Symbol(),nt=new WeakSet;function N(t){return nt.add(t),t}var H=t=>typeof t=="object"&&t!==null,Ht=t=>H(t)&&!nt.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer),dt=new WeakMap,ht=1,ft=new WeakMap;function it(t={}){if(!H(t))throw new Error("object required");let e=dt.get(t);if(e)return e;let o=ht,r=new Set,i=(d,f=++ht)=>{o!==f&&(o=f,r.forEach(n=>n(d,f)))},l=new Map,h=d=>{let f=l.get(d);return f||(f=(n,s)=>{let a=[...n];a[1]=[d,...a[1]],i(a,s)},l.set(d,f)),f},b=d=>{let f=l.get(d);return l.delete(d),f},c=(d,f)=>{let n=ft.get(f);if(n?.[0]===o)return n[1];let s=Array.isArray(d)?[]:Object.create(Object.getPrototypeOf(d));return ct(s,!0),ft.set(f,[o,s]),Reflect.ownKeys(d).forEach(a=>{let u=Reflect.get(d,a,f);if(nt.has(u))ct(u,!1),s[a]=u;else if(u instanceof Promise)if(_ in u)s[a]=u[_];else{let m=u[ut]||u;Object.defineProperty(s,a,{get(){if(_ in u)return u[_];throw m}})}else u?.[T]?s[a]=u[z]:s[a]=u}),Object.freeze(s),s},v=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t)),g={get(d,f,n){return f===yt?o:f===T?r:f===z?c(d,n):f===zt?g:Reflect.get(d,f,n)},deleteProperty(d,f){let n=Reflect.get(d,f),s=n?.[T];s&&s.delete(b(f));let a=Reflect.deleteProperty(d,f);return a&&i(["delete",[f],n]),a},is:Object.is,canProxy:Ht,set(d,f,n,s){var a;let u=Reflect.get(d,f,s);if(this.is(u,n))return!0;let m=u?.[T];m&&m.delete(b(f)),H(n)&&(n=Ft(n)||n);let p;return(a=Object.getOwnPropertyDescriptor(d,f))!=null&&a.set?p=n:n instanceof Promise?p=n.then(y=>(p[_]=y,i(["resolve",[f],y]),y)).catch(y=>{p[ut]=y,i(["reject",[f],y])}):n?.[T]?(p=n,p[T].add(h(f))):this.canProxy(n)?(p=it(n),p[T].add(h(f))):p=n,Reflect.set(d,f,p,s),i(["set",[f],n,u]),!0}},E=new Proxy(v,g);return dt.set(t,E),Reflect.ownKeys(t).forEach(d=>{let f=Object.getOwnPropertyDescriptor(t,d);f.get||f.set?Object.defineProperty(v,d,f):E[d]=t[d]}),E}function pt(t){return H(t)?t[yt]:void 0}function U(t,e,o){(K.env&&K.env.MODE)!=="production"&&!t?.[T]&&console.warn("Please use proxy object");let r,i=[],l=h=>{if(i.push(h),o){e(i.splice(0));return}r||(r=Promise.resolve().then(()=>{r=void 0,e(i.splice(0))}))};return t[T].add(l),()=>{t[T].delete(l)}}function Kt(t){return(K.env&&K.env.MODE)!=="production"&&!t?.[z]&&console.warn("Please use proxy object"),t[z]}function $t(t){for(;t.length>0;)t.pop();return t}var mt=(t,...e)=>(typeof t=="function"?t(...e):t)??void 0,P=t=>t,vt=()=>{};var Gt=(()=>{let t=0;return()=>(t++,t.toString(36))})(),k=t=>Array.isArray(t),V=t=>!(t==null||typeof t!="object"||k(t)),qt=t=>typeof t=="number"&&!Number.isNaN(t),A=t=>typeof t=="string",I=t=>typeof t=="function";function J(...t){let e=t.length===1?t[0]:t[1],o=t.length===2?t[0]:!0}function Z(...t){let e=t.length===1?t[0]:t[1],o=t.length===2?t[0]:!0}function Yt(t){return V(t)&&t.predicate!=null}function Q(t,e){return(o,r)=>Yt(t)?t.predicate(e??{})(o,r):t}function Xt(...t){return{predicate:e=>(o,r)=>t.map(i=>{var l;return A(i)?!!((l=e[i])!=null&&l.call(e,o,r)):I(i)?i(o,r):i.predicate(e)(o,r)}).some(Boolean)}}function Jt(...t){return{predicate:e=>(o,r)=>t.map(i=>{var l;return A(i)?!!((l=e[i])!=null&&l.call(e,o,r)):I(i)?i(o,r):i.predicate(e)(o,r)}).every(Boolean)}}function Zt(t){return{predicate:e=>(o,r)=>{var i;return A(t)?!((i=e[t])!=null&&i.call(e,o,r)):I(t)?!t(o,r):!t.predicate(e)(o,r)}}}var bt={or:Xt,and:Jt,not:Zt};function Qt(t){return V(t)&&t.predicate!=null}var te=()=>!0;function Et(t,e){return t=t??te,(o,r)=>{if(A(t)){let i=e?.[t];return I(i)?i(o,r):i}return Qt(t)?t.predicate(e??{})(o,r):t?.(o,r)}}function j(t){var e,o,r;if(Array.isArray(t)){for(o=Array(e=t.length);e--;)o[e]=(r=t[e])&&typeof r=="object"?j(r):r;return o}if(Object.prototype.toString.call(t)==="[object Object]"){o={};for(e in t)e==="__proto__"?Object.defineProperty(o,e,{value:j(t[e]),configurable:!0,enumerable:!0,writable:!0}):o[e]=(r=t[e])&&typeof r=="object"?j(r):r;return o}return t}function gt(t,e,o,r){return U(t,i=>{i.some(l=>l[1][0]===e)&&o(t[e])},r)}var Ce=Symbol(),L=new WeakMap,W=new WeakMap,St=(t,e)=>{let o=L.get(t);o&&(o[0].forEach(r=>{let{d:i}=r;t!==i&&St(i)}),++o[2],e&&o[3].add(e))},ee=(t,e)=>{let o=L.get(t);return o?.[2]?(o[3].add(e),!0):!1},et=t=>{let e=L.get(t);e&&(--e[2],e[2]||(e[3].forEach(o=>o()),e[3].clear()),e[0].forEach(o=>{let{d:r}=o;t!==r&&et(r)}))},ne=t=>{let{s:e,d:o}=t,r=W.get(o);r||(r=[new Set],W.set(t.d,r)),r[0].add(t);let i=L.get(e);if(!i){let l=new Set,h=U(e,b=>{l.forEach(c=>{let{d:v,c:g,n:E,i:d}=c;e===v&&b.every(f=>f[1].length===1&&d.includes(f[1][0]))||c.p||(St(e,g),E?et(e):c.p=Promise.resolve().then(()=>{delete c.p,et(e)}))})},!0);i=[l,h,0,new Set],L.set(e,i)}i[0].add(t)},wt=t=>{let{s:e,d:o}=t,r=W.get(o);r?.[0].delete(t),r?.[0].size===0&&W.delete(o);let i=L.get(e);if(i){let[l,h]=i;l.delete(t),l.size||(h(),L.delete(e))}},ie=t=>{let e=W.get(t);return e?Array.from(e[0]):[]};function oe(t,e){let o=e?.proxy||it({}),r=!!e?.sync,i=Object.keys(t);return i.forEach(l=>{if(Object.getOwnPropertyDescriptor(o,l))throw new Error("object property already defined");let h=t[l],b=null,c=()=>{if(b&&(Array.from(b).map(([d])=>ee(d,c)).some(d=>d)||Array.from(b).every(([d,f])=>pt(d)===f.v)))return;let v=new Map,g=h(d=>(v.set(d,{v:pt(d)}),d)),E=()=>{v.forEach((d,f)=>{var n;let s=(n=b?.get(f))==null?void 0:n.s;if(s)d.s=s;else{let a={s:f,d:o,k:l,c,n:r,i};ne(a),d.s=a}}),b?.forEach((d,f)=>{!v.has(f)&&d.s&&wt(d.s)}),b=v};g instanceof Promise?g.finally(E):E(),o[l]=g};c()}),o}function re(t,e){let o=e?.delete?new Set:null;ie(t).forEach(r=>{let{k:i}=r;(!e?.keys||e.keys.includes(i))&&(wt(r),o&&o.add(i))}),o&&o.forEach(r=>{delete t[r]})}function se(t){var e;let o=it({value:"",previousValue:"",event:P({}),context:(e=t.context)!=null?e:P({}),done:!1,tags:[],hasTag(r){return this.tags.includes(r)},matches(...r){return r.includes(this.value)},can(r){return P(this).nextEvents.includes(r)},get nextEvents(){var r,i,l,h;let b=(l=(i=(r=t.states)==null?void 0:r[this.value])==null?void 0:i.on)!=null?l:{},c=(h=t?.on)!=null?h:{};return Object.keys({...b,...c})},get changed(){return this.event.value==="machine.init"||!this.previousValue?!1:this.value!==this.previousValue}});return P(o)}function B(t,e){return(o,r)=>{if(qt(t))return t;if(I(t))return t(o,r);if(A(t)){let i=Number.parseFloat(t);if(!Number.isNaN(i))return i;if(e){let l=e?.[t];if(l==null){let h=`[machine] Cannot determine delay for ${t}. It doesn't exist in options.delays`;throw new Error(h)}return I(l)?l(o,r):l}}}}function x(t){return A(t)?{type:t}:t}function C(t){return t?k(t)?t:[t]:[]}function xt(t){return A(t)?{target:t}:t}function ae(t,e){return(o,r)=>C(t).map(xt).find(i=>{var l;let h=Et(i.guard,e)(o,r);return(l=h??i.target)!=null?l:i.actions})}function le(t,e){let o=A(t)?xt(t):t,r=i=>(i.actions&&!i.target&&e&&(i.target=e),i);if(k(o))return o.map(r);if(V(o))return r(P(o))}var F=class{constructor(t,e){this.config=t,this.status="Not Started",this.type="machine",this.activityEvents=new Map,this.delayedEvents=new Map,this.stateListeners=new Set,this.eventListeners=new Set,this.doneListeners=new Set,this.contextWatchers=new Set,this.removeStateListener=vt,this.removeEventListener=vt,this.children=new Map,this.start=n=>{if(this.status==="Running")return this;this.status="Running";let s=x("machine.init");if(n){let m=V(n)?n:{context:this.config.context,value:n};this.setState(m.value),this.setContext(m.context)}let a={target:n?void 0:this.config.initial},u=this.getNextStateInfo(a,s);return u.target=P(u.target||a.target),this.initialState=u,this.performStateChangeEffects(u.target,u,s),this.removeStateListener=U(this.state,()=>{this.stateListeners.forEach(m=>{m(this.stateSnapshot)})},this.sync),this.removeEventListener=gt(this.state,"event",m=>{this.config.onEvent&&this.executeActions(this.config.onEvent,m);for(let p of this.eventListeners)p(m)}),this.setupContextWatchers(),this.executeActivities(x("machine.start"),C(this.config.activities),"machine.start"),this.executeActions(this.config.entry,x("machine.start")),this},this.setupContextWatchers=()=>{var n;for(let[s,a]of Object.entries((n=this.config.watch)!=null?n:{}))this.contextWatchers.add(gt(this.state.context,s,()=>{this.executeActions(a,this.state.event)}))},this.setupComputed=()=>{var n;let s=P((n=this.config.computed)!=null?n:{}),a=Object.fromEntries(Object.entries(s).map(([u,m])=>[u,p=>m(p(this.state.context))]));oe(a,{proxy:this.state.context})},this.detachComputed=()=>{re(this.state.context,{delete:!0})},this.stop=()=>{if(this.status!=="Stopped")return this.setState(null),this.setEvent("machine.stop"),this.config.context&&this.setContext(this.config.context),this.stopStateListeners(),this.stopChildren(),this.stopActivities(),this.stopDelayedEvents(),this.stopContextWatchers(),this.stopEventListeners(),this.detachComputed(),this.status="Stopped",this.executeActions(this.config.exit,x("machine.stop")),this},this.stopEventListeners=()=>{this.eventListeners.clear(),this.removeEventListener()},this.stopStateListeners=()=>{this.removeStateListener(),this.stateListeners.clear()},this.stopContextWatchers=()=>{this.contextWatchers.forEach(n=>n()),this.contextWatchers.clear()},this.stopDelayedEvents=()=>{this.delayedEvents.forEach(n=>{n.forEach(s=>s())}),this.delayedEvents.clear()},this.stopActivities=n=>{var s,a;n?((s=this.activityEvents.get(n))==null||s.forEach(u=>u()),(a=this.activityEvents.get(n))==null||a.clear(),this.activityEvents.delete(n)):(this.activityEvents.forEach(u=>{u.forEach(m=>m()),u.clear()}),this.activityEvents.clear())},this.sendChild=(n,s)=>{let a=x(n),u=mt(s,this.contextSnapshot),m=this.children.get(u);m||Z(`[machine/send-child] Cannot send '${a.type}' event to unknown child`),m.send(a)},this.stopChild=n=>{this.children.has(n)||Z("[machine/stop-child] Cannot stop unknown child"),this.children.get(n).stop(),this.children.delete(n)},this.removeChild=n=>{this.children.delete(n)},this.stopChildren=()=>{this.children.forEach(n=>n.stop()),this.children.clear()},this.setParent=n=>{this.parent=n},this.spawn=(n,s)=>{let a=mt(n);return s&&(a.id=s),a.type="machine.actor",a.setParent(this),this.children.set(a.id,P(a)),a.onDone(()=>{this.removeChild(a.id)}).start(),P(N(a))},this.addActivityCleanup=(n,s)=>{var a;!n||(this.activityEvents.has(n)?(a=this.activityEvents.get(n))==null||a.add(s):this.activityEvents.set(n,new Set([s])))},this.setState=n=>{this.state.previousValue=this.state.value,this.state.value=n;let s=this.getStateNode(n);n==null?$t(this.state.tags):this.state.tags=C(s?.tags)},this.setContext=n=>{for(let s in n)this.state.context[s]=n[s]},this.withContext=n=>{this.detachComputed();let s={...this.config.context,...n};return new F({...this.config,context:s},this.options)},this.withOptions=n=>(this.detachComputed(),new F(this.config,{...this.options,...n})),this.setActions=n=>{this.actionMap={...this.actionMap,...n}},this.clone=()=>(this.detachComputed(),new F(this.config,this.options)),this.getStateNode=n=>{var s;if(n)return(s=this.config.states)==null?void 0:s[n]},this.getNextStateInfo=(n,s)=>{var a;let u=this.determineTransition(n,s),m=(a=u?.target)!=null?a:this.state.value,p=this.getStateNode(m);return{transition:u,stateNode:p,target:m}},this.getActionFromDelayedTransition=n=>{let s=x("machine.after"),a=B(n.delay,this.delayMap)(this.contextSnapshot,s),u;return{entry:()=>{u=globalThis.setTimeout(()=>{let m=this.state.value,p=this.getNextStateInfo(n,s);this.performStateChangeEffects(m,p,s)},a)},exit:()=>{globalThis.clearTimeout(u)}}},this.getDelayedEventActions=n=>{let s=this.getStateNode(n),a=x("machine.after");if(!s||!s.after)return;let u=[],m=[];if(k(s.after)){let p=this.determineTransition(s.after,a);if(!p)return;let y=this.getActionFromDelayedTransition(p);u.push(y.entry),m.push(y.exit)}else if(V(s.after))for(let p in s.after){let y=s.after[p],w={};if(k(y)){let R=this.determineTransition(y,a);R&&(w=R)}else A(y)?w={target:y,delay:p}:w={...y,delay:p};let D=this.getActionFromDelayedTransition(w);u.push(D.entry),m.push(D.exit)}return{entries:u,exits:m}},this.executeActions=(n,s)=>{var a;let u=Q(n,this.guardMap)(this.contextSnapshot,s);for(let m of C(u)){let p=A(m)?(a=this.actionMap)==null?void 0:a[m]:m;J(A(m)&&!p,`[machine/exec-action] No implementation found for action: \`${m}\``),p?.(this.state.context,s,this.meta)}},this.executeActivities=(n,s,a)=>{var u;for(let m of s){let p=A(m)?(u=this.activityMap)==null?void 0:u[m]:m;if(!p){J(`[machine/exec-activity] No implementation found for activity: \`${m}\``);continue}let y=p(this.state.context,n,this.meta);y&&this.addActivityCleanup(a??this.state.value,y)}},this.createEveryActivities=(n,s)=>{if(!n)return;let a=x("machine.every");if(k(n)){let u=C(n).find(p=>{let y=B(p.delay,this.delayMap);p.delay=y(this.contextSnapshot,a);let w=Et(p.guard,this.guardMap)(this.contextSnapshot,a);return w??p.delay});if(!u)return;let m=B(u.delay,this.delayMap)(this.contextSnapshot,a);s(()=>{let p=globalThis.setInterval(()=>{this.executeActions(u.actions,a)},m);return()=>{globalThis.clearInterval(p)}})}else for(let u in n){let m=n?.[u],p=B(u,this.delayMap)(this.contextSnapshot,a);s(()=>{let y=globalThis.setInterval(()=>{this.executeActions(m,a)},p);return()=>{globalThis.clearInterval(y)}})}},this.setEvent=n=>{this.state.event=N(x(n))},this.performExitEffects=(n,s)=>{let a=this.state.value,u=n?this.getStateNode(n):void 0;this.stopActivities(a);let m=Q(u?.exit,this.guardMap)(this.contextSnapshot,s),p=C(m),y=this.delayedEvents.get(a);y&&p.push(...y),this.executeActions(p,s),this.eventListeners.clear()},this.performEntryEffects=(n,s)=>{let a=this.getStateNode(n),u=C(a?.activities);this.createEveryActivities(a?.every,w=>{u.unshift(w)}),u.length>0&&this.executeActivities(s,u);let m=Q(a?.entry,this.guardMap)(this.contextSnapshot,s),p=C(m),y=this.getDelayedEventActions(n);a?.after&&y&&(this.delayedEvents.set(n,y?.exits),p.push(...y.entries)),this.executeActions(p,s),a?.type==="final"&&(this.state.done=!0,this.doneListeners.forEach(w=>{w(this.stateSnapshot)}),this.stop())},this.performTransitionEffects=(n,s)=>{let a=this.determineTransition(n,s);this.executeActions(a?.actions,s)},this.performStateChangeEffects=(n,s,a)=>{var u,m;this.setEvent(a),s.target=(m=(u=s.target)!=null?u:this.state.value)!=null?m:void 0;let p=s.target&&s.target!==this.state.value;p&&this.performExitEffects(n,a),this.performTransitionEffects(s?.transition,a),this.setState(s.target),p&&this.performEntryEffects(s.target,a)},this.determineTransition=(n,s)=>{let a=ae(n,this.guardMap);return a?.(this.contextSnapshot,s)},this.sendParent=n=>{var s;this.parent||Z("[machine/send-parent] Cannot send event to an unknown parent");let a=x(n);(s=this.parent)==null||s.send(a)},this.send=n=>{let s=x(n);this.transition(this.state.value,s)},this.transition=(n,s)=>{var a,u,m;let p=A(n)?this.getStateNode(n):n?.stateNode,y=x(s);if(!p&&!this.config.on){let Dt=this.status==="Stopped"?"[machine/transition] Cannot transition a stopped machine":"[machine/transition] State does not have a definition";J(Dt);return}let w=(m=(a=p?.on)==null?void 0:a[y.type])!=null?m:(u=this.config.on)==null?void 0:u[y.type],D=le(w,this.state.value);if(!D)return;let R=this.getNextStateInfo(D,y);return this.performStateChangeEffects(this.state.value,R,y),R.stateNode},this.subscribe=n=>(this.stateListeners.add(n),this.status==="Running"&&n(this.stateSnapshot),()=>{this.stateListeners.delete(n)}),this.onDone=n=>(this.doneListeners.add(n),this),this.onTransition=n=>(this.stateListeners.add(n),this.status==="Running"&&n(this.stateSnapshot),this),this.onEvent=n=>(n(this.state.event),this.eventListeners.add(n),this);var o,r,i,l,h,b,c,v,g,E,d;this.options=j(e),this.id=(o=t.id)!=null?o:`machine-${Gt()}`,this.guardMap=(i=(r=this.options)==null?void 0:r.guards)!=null?i:{},this.actionMap=(h=(l=this.options)==null?void 0:l.actions)!=null?h:{},this.delayMap=(c=(b=this.options)==null?void 0:b.delays)!=null?c:{},this.activityMap=(g=(v=this.options)==null?void 0:v.activities)!=null?g:{},this.sync=(d=(E=this.options)==null?void 0:E.sync)!=null?d:!1,this.state=se(j(t)),this.setupComputed();let f=x("machine.created");this.executeActions(t?.created,f)}get stateSnapshot(){return P(Kt(this.state))}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),get state(){return t.stateSnapshot}}}get meta(){return{state:this.stateSnapshot,guards:this.guardMap,send:this.send.bind(this),listen:this.onEvent.bind(this),self:this.self,getState:()=>this.stateSnapshot}}},$=(t,e)=>new F(t,e);function ce(t){return{button:t,label:t,input:t,output:t,element:t}}var G=ce(t=>t);var S={getDoc:t=>{var e;return(e=t.doc)!=null?e:document},getGroupId:t=>`toast-group--${t}`,getContainerId:t=>`toast--${t.id}`,getTitleId:t=>`toast-title--${t.id}`,getCloseButtonId:t=>`toast-close-button--${t.id}`,getPortalId:t=>`toast-portal--${t.uid}`,getPortalEl:t=>S.getDoc(t).getElementById(S.getPortalId(t)),createPortalEl:t=>{let e=S.getPortalEl(t);if(e)return e;let o=S.getDoc(t).createElement("toast-portal");return o.id=S.getPortalId(t),o}};function At(t){let e={};for(let o of t){let r=o.state.context.placement;e[r]||(e[r]=[]),e[r].push(o)}return e}var ue={info:5e3,error:5e3,success:2e3,loading:1/0,custom:5e3};function ot(t,e){return t!=null?t:ue[e]}function Tt(t,e){let o=t.offsets,r=typeof o=="string"?{left:o,right:o,bottom:o,top:o}:o,i=t.dir==="rtl",l=e.replace("-start",i?"-right":"-left").replace("-end",i?"-left":"-right"),h=l.includes("right"),b=l.includes("left"),c={position:"fixed",pointerEvents:t.count>0?void 0:"none",display:"flex",flexDirection:"column","--toast-gutter":t.gutter,zIndex:t.zIndex},v="center";if(h&&(v="flex-end"),b&&(v="flex-start"),c.alignItems=v,l.includes("top")){let g=r.top;c.top=`calc(env(safe-area-inset-top, 0px) + ${g})`}if(l.includes("bottom")){let g=r.bottom;c.bottom=`calc(env(safe-area-inset-bottom, 0px) + ${g})`}if(!l.includes("left")){let g=r.right;c.right=`calc(env(safe-area-inset-right, 0px) + ${g})`}if(!l.includes("right")){let g=r.left;c.left=`calc(env(safe-area-inset-left, 0px) + ${g})`}return c}var rt={};function Pt(t,e,o=G){let r={count:t.context.count,toasts:t.context.toasts,toastsByPlacement:At(t.context.toasts),isVisible(i){return t.context.toasts.length?!!t.context.toasts.find(l=>l.id==i):!1},create(i){let l="toast-"+Math.random().toString(36).substring(2,9),h=i.id?i.id:l;if(!r.isVisible(h))return e({type:"ADD_TOAST",toast:{...i,id:h}}),h},upsert(i){let{id:l}=i;return(l?r.isVisible(l):!1)&&l!=null?r.update(l,i):r.create(i)},dismiss(i){i==null?e("DISMISS_ALL"):r.isVisible(i)&&e({type:"DISMISS_TOAST",id:i})},remove(i){i==null?e("REMOVE_ALL"):r.isVisible(i)&&e({type:"REMOVE_TOAST",id:i})},dismissByPlacement(i){let l=r.toastsByPlacement[i];l&&l.forEach(h=>r.dismiss(h.id))},update(i,l){if(!!r.isVisible(i))return e({type:"UPDATE_TOAST",id:i,toast:l}),i},loading(i){return i.type="loading",r.upsert(i)},success(i){return i.type="success",r.upsert(i)},error(i){return i.type="error",r.upsert(i)},promise(i,l,h={}){let b=r.loading({...h,...h==null?void 0:h.loading,type:"loading",title:l.loading});return i.then(c=>{let v=X(l.loading,c);r.success({...h,...h==null?void 0:h.success,id:b,title:v})}).catch(c=>{let v=X(l.error,c);r.error({...h,...h==null?void 0:h.error,id:b,title:v})}),i},pause(i){i==null?e("PAUSE_ALL"):r.isVisible(i)&&e({type:"PAUSE_TOAST",id:i})},resume(i){i==null?e("RESUME_ALL"):r.isVisible(i)&&e({type:"RESUME_TOAST",id:i})},getGroupProps(i){let{placement:l,label:h="Notifications"}=i;return o.element({tabIndex:-1,"aria-label":h,id:S.getGroupId(l),"data-placement":l,"aria-live":"polite",role:"region",style:Tt(t.context,l)})},createPortal(){let i=S.getDoc(t.context),l=S.getPortalEl(t.context);if(l)return l;let h=S.createPortalEl(t.context);return i.body.appendChild(h),h},subscribe(i){return U(t.context.toasts,()=>i(t.context.toasts))}};return t.matches("unknown")||Object.assign(rt,r),r}var Mt=t=>t?"":void 0;var de=t=>t,he=()=>{};var ze=(()=>{let t=0;return()=>(t++,t.toString(36))})();var O=new Map,M=new Map;function fe(t,e,o,r){var i;if(!t)return he;let l=JSON.stringify({type:e,options:r}),h=O.get(t);if(O.has(t))h!=null&&h.has(l)?(i=h?.get(l))==null||i.add(o):h?.set(l,new Set([o]));else{let c=new Map([[l,new Set([o])]]);O.set(t,c)}function b(c){var v,g;function E(d){var f;let n=O.get(c);(f=n?.get(l))==null||f.forEach(s=>s(d))}if(!(M!=null&&M.has(c))){M.set(c,new Map([[l,E]])),c.addEventListener(e,E,r);return}(v=M?.get(c))!=null&&v.has(l)||((g=M.get(c))==null||g.set(l,E),c.addEventListener(e,E,r))}return b(t),function(){var c,v,g,E;if(!O.has(t))return;let d=O.get(t);if((c=d?.get(l))==null||c.delete(o),((v=d?.get(l))==null?void 0:v.size)===0){let f=(g=M.get(t))==null?void 0:g.get(l);t.removeEventListener(e,f,r),d?.delete(l),(E=M.get(t))==null||E.delete(l),d?.size===0&&(O.delete(t),M.delete(t))}}}var Ct=t=>Object.prototype.toString.call(t).slice(8,-1),pe=t=>Ct(t)==="Object"&&"current"in t,me=t=>Ct(t)==="Function"?t():t;function ve(t,e,o,r){let i=pe(t)?t.current:me(t);return fe(i,e,o,r)}var Lt=2147483647;var He=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","embed","iframe","object","a[href]","area[href]","[tabindex]","audio[controls]","video[controls]","*[tabindex]:not([aria-disabled])","[contenteditable]:not([contenteditable=false])","details > summary:first-of-type"].join(",");function Ot(t,e){let o=de(t);return ve(o,"visibilitychange",()=>{let r=o.hidden||o.msHidden||o.webkitHidden;e(!!r)})}var{not:ge,and:ye,or:be}=bt;function q(t={}){let{type:e="info",duration:o,id:r="toast",placement:i="bottom",removeDelay:l=500,...h}=t,b=ot(o,e);return $({id:r,entry:"invokeOnOpen",initial:e==="loading"?"persist":"active",context:{id:r,type:e,remaining:b,duration:b,removeDelay:l,createdAt:Date.now(),placement:i,...h},on:{UPDATE:[{guard:ye("hasTypeChanged","isChangingToLoading"),target:"persist",actions:["setContext","invokeOnUpdate"]},{guard:be("hasDurationChanged","hasTypeChanged"),target:"active:temp",actions:["setContext","invokeOnUpdate"]},{actions:["setContext","invokeOnUpdate"]}]},states:{"active:temp":{tags:["visible","updating"],after:{0:"active"}},persist:{tags:["visible","paused"],activities:"trackDocumentVisibility",on:{RESUME:{guard:ge("isLoadingType"),target:"active",actions:["setCreatedAt"]},DISMISS:"dismissing"}},active:{tags:["visible"],activities:"trackDocumentVisibility",after:{VISIBLE_DURATION:"dismissing"},on:{DISMISS:"dismissing",PAUSE:{target:"persist",actions:"setRemainingDuration"}}},dismissing:{entry:"invokeOnClosing",after:{REMOVE_DELAY:{target:"inactive",actions:"notifyParentToRemove"}}},inactive:{entry:"invokeOnClose",type:"final"}}},{activities:{trackDocumentVisibility(c,v,{send:g}){if(!!c.pauseOnPageIdle)return Ot(S.getDoc(c),function(E){g(E?"PAUSE":"RESUME")})}},guards:{isChangingToLoading:(c,v)=>{var g;return((g=v.toast)==null?void 0:g.type)==="loading"},isLoadingType:c=>c.type==="loading",hasTypeChanged:(c,v)=>{var g;return((g=v.toast)==null?void 0:g.type)!==c.type},hasDurationChanged:(c,v)=>{var g;return((g=v.toast)==null?void 0:g.duration)!==c.duration}},delays:{VISIBLE_DURATION:c=>c.remaining,REMOVE_DELAY:c=>c.removeDelay},actions:{setRemainingDuration(c){c.remaining-=Date.now()-c.createdAt},setCreatedAt(c){c.createdAt=Date.now()},notifyParentToRemove(c,v,{self:g}){g.sendParent({type:"REMOVE_TOAST",id:g.id})},invokeOnClosing(c){var v;(v=c.onClosing)==null||v.call(c)},invokeOnClose(c){var v;(v=c.onClose)==null||v.call(c)},invokeOnOpen(c){var v;(v=c.onOpen)==null||v.call(c)},invokeOnUpdate(c){var v;(v=c.onUpdate)==null||v.call(c)},setContext(c,v){let{duration:g,type:E}=v.toast,d=ot(g,E);Object.assign(c,{...v.toast,duration:d,remaining:d})}}})}var kt=$({id:"toaster",initial:"active",context:{dir:"ltr",max:Number.MAX_SAFE_INTEGER,uid:"",toasts:[],gutter:"1rem",zIndex:Lt,pauseOnPageIdle:!1,pauseOnInteraction:!0,offsets:{left:"0px",right:"0px",top:"0px",bottom:"0px"}},computed:{count:t=>t.toasts.length},on:{SETUP:{actions:(t,e)=>{t.uid=e.id,e.doc&&(t.doc=N(e.doc))}},PAUSE_TOAST:{actions:(t,e,{self:o})=>{o.sendChild("PAUSE",e.id)}},PAUSE_ALL:{actions:t=>{t.toasts.forEach(e=>e.send("PAUSE"))}},RESUME_TOAST:{actions:(t,e,{self:o})=>{o.sendChild("RESUME",e.id)}},RESUME_ALL:{actions:t=>{t.toasts.forEach(e=>e.send("RESUME"))}},ADD_TOAST:{guard:t=>t.toasts.length<t.max,actions:(t,e,{self:o})=>{var h;let r={...e.toast,pauseOnPageIdle:t.pauseOnPageIdle,pauseOnInteraction:t.pauseOnInteraction,dir:t.dir,doc:N((h=t.doc)!=null?h:document)},i=q(r),l=o.spawn(i);t.toasts.push(l)}},UPDATE_TOAST:{actions:(t,e,{self:o})=>{o.sendChild({type:"UPDATE",toast:e.toast},e.id)}},DISMISS_TOAST:{actions:(t,e,{self:o})=>{o.sendChild("DISMISS",e.id)}},DISMISS_ALL:{actions:t=>{t.toasts.forEach(e=>e.send("DISMISS"))}},REMOVE_TOAST:{actions:(t,e,{self:o})=>{o.stopChild(e.id);let r=t.toasts.findIndex(i=>i.id===e.id);t.toasts.splice(r,1)}},REMOVE_ALL:{actions:(t,e,{self:o})=>{for(t.toasts.forEach(r=>o.stopChild(r.id));t.toasts.length;)t.toasts.pop()}}}});function It(t,e,o=G){let r=t.hasTag("visible"),i=t.hasTag("paused"),l=t.hasTag("updating"),h=t.context.dir==="rtl",b=t.context.type,c=t.context.pauseOnInteraction,v=t.context.placement;return{type:t.context.type,title:t.context.title,placement:v,isVisible:r,isPaused:i,pause(){e("PAUSE")},resume(){e("RESUME")},dismiss(){e("DISMISS")},rootProps:o.element({"data-part":"root",dir:t.context.dir,id:S.getContainerId(t.context),"data-open":Mt(r),"data-type":t.context.type,"data-placement":v,role:"status","aria-atomic":"true",tabIndex:0,style:{position:"relative",pointerEvents:"auto",margin:"calc(var(--toast-gutter) / 2)","--remove-delay":`${t.context.removeDelay}ms`,"--duration":`${t.context.duration}ms`},onKeyDown(g){g.key=="Escape"&&(e("DISMISS"),g.preventDefault(),g.stopPropagation())},onFocus(){c&&e("PAUSE")},onBlur(){c&&e("RESUME")},onPointerEnter(){c&&e("PAUSE")},onPointerLeave(){c&&e("RESUME")}}),progressbarProps:o.element({"data-part":"progressbar","data-type":t.context.type,style:{opacity:r?1:0,transformOrigin:h?"right":"left",animationName:l||b==="loading"?"none":void 0,animationPlayState:i?"paused":"running",animationDuration:`${t.context.duration}ms`,animationFillMode:l?void 0:"forwards"}}),titleProps:o.element({"data-part":"title",id:S.getTitleId(t.context)}),closeButtonProps:o.button({id:S.getCloseButtonId(t.context),"data-part":"close-button",type:"button","aria-label":"Dismiss notification",onClick(){e("DISMISS")}}),render(){var g,E;return(E=(g=t.context).render)==null?void 0:E.call(g,{id:t.context.id,type:t.context.type,duration:t.context.duration,title:t.context.title,placement:t.context.placement,description:t.context.description,dismiss(){e("DISMISS")}})}}}var Ee={connect:Pt,machine:kt};function Se(){if(!st())at("toast.api() is only available in the browser");else return rt}
2
2
  //# sourceMappingURL=index.js.map