1import{A as d,b as i,m as l,v,f as O,o as C,F as Ke,D as fe,a as N,e as y,Q as je,S as Be,G as Te,H as ve,R as He,i as we,q as ce,k as le,z as Ve,M as U,t as he}from"./web-Daoi1TEa.js";import{c as We}from"./index-CxOCE76-.js";import{c as L}from"./utils-_qghvgfj.js";import{D as Ye}from"./3NI6FTA2-CQeuLCvd.js";import{B as Xe}from"./UKTBL2JL-6K52ocrI.js";import{c as ue}from"./JNCCF6MP-4sxnBYeu.js";import{_ as ze,P as b}from"./5WXHJDCZ-9j09M0KL.js";import{m as F,d as de,e as Ue,b as w,j as pe,f as Ge,h as ye,a as qe}from"./index-DvQraQr3.js";import{c as q}from"./index-275LIXCi.js";import{c as Qe}from"./store-CR_V6Tem.js";import{s as Je}from"./index-DbZmQF6t.js";import{m as xe}from"./index-BNK4pR0r.js";import"./OYES4GOP-Qz7fQPZb.js";import"./R5675YMU-DknHYXiZ.js";import"./U42ECMND-BDjyePcW.js";var Ze={};ze(Ze,{CloseButton:()=>Q,Description:()=>J,List:()=>ee,ProgressFill:()=>Ie,ProgressTrack:()=>Ee,Region:()=>re,Root:()=>oe,Title:()=>ne,Toast:()=>Tt,toaster:()=>j});var be=Te();function K(){const r=ve(be);if(r===void 0)throw new Error("[kobalte]: `useToastContext` must be used within a `Toast.Root` component");return r}function Q(r){const t=K(),[e,o]=d(r,["aria-label","onClick"]);return i(Xe,l({get"aria-label"(){return e["aria-label"]||t.translations().close},onClick:c=>{w(c,e.onClick),t.close()}},o))}function J(r){const t=K(),e=F({id:t.generateId("description")},r),[o,a]=d(e,["id"]);return v(()=>O(t.registerDescriptionId(o.id))),i(b,l({as:"div",get id(){return o.id}},a))}var Pe=Te();function Z(){const r=ve(Pe);if(r===void 0)throw new Error("[kobalte]: `useToastRegionContext` must be used within a `Toast.Region` component");return r}function ee(r){let t;const e=Z(),[o,a]=d(r,["ref","onFocusIn","onFocusOut","onPointerMove","onPointerLeave"]),c=s=>{w(s,o.onFocusIn),e.pauseOnInteraction()&&!e.isPaused()&&e.pauseAllTimer()},g=s=>{w(s,o.onFocusOut),pe(t,s.relatedTarget)||e.resumeAllTimer()},m=s=>{w(s,o.onPointerMove),e.pauseOnInteraction()&&!e.isPaused()&&e.pauseAllTimer()},f=s=>{w(s,o.onPointerLeave),pe(t,de(t).activeElement)||e.resumeAllTimer()};return v(C([()=>t,()=>e.hotkey()],([s,p])=>{if(!s)return;const h=de(s),T=M=>{p.every(E=>M[E]||M.code===E)&&Ge(s)};h.addEventListener("keydown",T),O(()=>h.removeEventListener("keydown",T))})),v(()=>{if(!e.pauseOnPageIdle())return;const s=Ue(t);s.addEventListener("blur",e.pauseAllTimer),s.addEventListener("focus",e.resumeAllTimer),O(()=>{s.removeEventListener("blur",e.pauseAllTimer),s.removeEventListener("focus",e.resumeAllTimer)})}),i(b,l({as:"ol",ref(s){var p=xe(h=>t=h,o.ref);typeof p=="function"&&p(s)},tabIndex:-1,onFocusIn:c,onFocusOut:g,onPointerMove:m,onPointerLeave:f},a,{get children(){return i(Ke,{get each(){return e.toasts()},children:s=>s.toastComponent({get toastId(){return s.id}})})}}))}function Ie(r){const t=Z(),e=K(),[o,a]=d(r,["style"]),[c,g]=y(100);let m=0;return v(()=>{if(t.isPaused()||e.isPersistent())return;const f=setInterval(()=>{const s=new Date().getTime()-e.closeTimerStartTime()+m,p=Math.trunc(100-s/e.duration()*100);g(p<0?0:p)});O(()=>{m+=new Date().getTime()-e.closeTimerStartTime(),clearInterval(f)})}),i(b,l({as:"div",get style(){return q({"--kb-toast-progress-fill-width":`${c()}%`},o.style)}},a))}function Ee(r){return i(b,l({as:"div","aria-hidden":"true",role:"presentation"},r))}var[te,$]=Qe({toasts:[]});function et(r){$("toasts",t=>[...t,r])}function tt(r){return te.toasts.find(t=>t.id===r)}function rt(r,t){const e=te.toasts.findIndex(o=>o.id===r);e!==-1&&$("toasts",o=>[...o.slice(0,e),t,...o.slice(e+1)])}function ot(r){$("toasts",t=>t.id===r,"dismiss",!0)}function nt(r){$("toasts",t=>t.filter(e=>e.id!==r))}function st(){$("toasts",[])}var x={toasts:()=>te.toasts,add:et,get:tt,update:rt,dismiss:ot,remove:nt,clear:st},ge="{hotkey}",at={close:"Close"},it={notifications:r=>`Notifications (${r})`};function re(r){const t=F({id:`toast-region-${fe()}`,hotkey:["altKey","KeyT"],duration:5e3,limit:3,swipeDirection:"right",swipeThreshold:50,pauseOnInteraction:!0,pauseOnPageIdle:!0,topLayer:!0,translations:it},r),[e,o]=d(t,["translations","style","hotkey","duration","limit","swipeDirection","swipeThreshold","pauseOnInteraction","pauseOnPageIdle","topLayer","aria-label","regi
1onId"]),a=N(()=>x.toasts().filter(T=>T.region===e.regionId&&T.dismiss===!1).slice(0,e.limit)),[c,g]=y(!1),m=()=>a().length>0,f=()=>e.hotkey.join("+").replace(/Key/g,"").replace(/Digit/g,""),s=()=>(e["aria-label"]||e.translations.notifications(ge)).replace(ge,f()),p=()=>({[Ye]:e.topLayer?"":void 0}),h={isPaused:c,toasts:a,hotkey:()=>e.hotkey,duration:()=>e.duration,swipeDirection:()=>e.swipeDirection,swipeThreshold:()=>e.swipeThreshold,pauseOnInteraction:()=>e.pauseOnInteraction,pauseOnPageIdle:()=>e.pauseOnPageIdle,pauseAllTimer:()=>g(!0),resumeAllTimer:()=>g(!1),generateId:ye(()=>o.id)};return i(Pe.Provider,{value:h,get children(){return i(b,l({as:"div",role:"region",tabIndex:-1,get"aria-label"(){return s()},get style(){return q({"pointer-events":m()?e.topLayer?"auto":void 0:"none"},e.style)}},p,o))}})}var ct="toast.swipeStart",lt="toast.swipeMove",ut="toast.swipeCancel",dt="toast.swipeEnd";function oe(r){const t=Z(),e=F({id:`toast-${fe()}`,priority:"high",translations:at},r),[o,a]=d(e,["ref","translations","toastId","style","priority","duration","persistent","onPause","onResume","onSwipeStart","onSwipeMove","onSwipeCancel","onSwipeEnd","onEscapeKeyDown","onKeyDown","onPointerDown","onPointerMove","onPointerUp"]),[c,g]=y(!0),[m,f]=y(),[s,p]=y(),[h,T]=y(!0),[M,se]=y(),{present:E}=Je({show:c,element:()=>M()??null}),B=N(()=>o.duration||t.duration());let H,V=0,W=B(),P=null,S=null;const D=()=>{g(!1),T(!0)},ke=()=>{x.remove(o.toastId)},ae=n=>{!n||o.persistent||(window.clearTimeout(H),V=new Date().getTime(),H=window.setTimeout(D,n))},_e=()=>{ae(W),o.onResume?.()},Ae=()=>{const n=new Date().getTime()-V;W=W-n,window.clearTimeout(H),o.onPause?.()},Ce=n=>{w(n,o.onKeyDown),n.key==="Escape"&&(o.onEscapeKeyDown?.(n),n.defaultPrevented||D())},Oe=n=>{w(n,o.onPointerDown),n.button===0&&(P={x:n.clientX,y:n.clientY})},Le=n=>{if(w(n,o.onPointerMove),!P)return;const u=n.clientX-P.x,k=n.clientY-P.y,Y=!!S,_=["left","right"].includes(t.swipeDirection()),I=["left","up"].includes(t.swipeDirection())?Math.min:Math.max,X=_?I(0,u):0,Re=_?0:I(0,k),z=n.pointerType==="touch"?10:2,A={x:X,y:Re},ie={originalEvent:n,delta:A};if(Y){S=A,R(lt,o.onSwipeMove,ie);const{x:Ne,y:Fe}=A;n.currentTarget.setAttribute("data-swipe","move"),n.currentTarget.style.setProperty("--kb-toast-swipe-move-x",`${Ne}px`),n.currentTarget.style.setProperty("--kb-toast-swipe-move-y",`${Fe}px`)}else me(A,t.swipeDirection(),z)?(S=A,R(ct,o.onSwipeStart,ie),n.currentTarget.setAttribute("data-swipe","start"),n.target.setPointerCapture(n.pointerId)):(Math.abs(u)>z||Math.abs(k)>z)&&(P=null)},$e=n=>{w(n,o.onPointerUp);const u=S,k=n.target;if(k.hasPointerCapture(n.pointerId)&&k.releasePointerCapture(n.pointerId),S=null,P=null,u){const Y=n.currentTarget,_={originalEvent:n,delta:u};if(me(u,t.swipeDirection(),t.swipeThreshold())){R(dt,o.onSwipeEnd,_);const{x:I,y:X}=u;n.currentTarget.setAttribute("data-swipe","end"),n.currentTarget.style.removeProperty("--kb-toast-swipe-move-x"),n.currentTarget.style.removeProperty("--kb-toast-swipe-move-y"),n.currentTarget.style.setProperty("--kb-toast-swipe-end-x",`${I}px`),n.currentTarget.style.setProperty("--kb-toast-swipe-end-y",`${X}px`),D()}else R(ut,o.onSwipeCancel,_),n.currentTarget.setAttribute("data-swipe","cancel"),n.currentTarget.style.removeProperty("--kb-toast-swipe-move-x"),n.currentTarget.style.removeProperty("--kb-toast-swipe-move-y"),n.currentTarget.style.removeProperty("--kb-toast-swipe-end-x"),n.currentTarget.style.removeProperty("--kb-toast-swipe-end-y");Y.addEventListener("click",I=>I.preventDefault(),{once:!0})}};je(()=>{t.toasts().find(n=>n.id===o.toastId&&n.update)&&T(!1)}),v(C(()=>t.isPaused(),n=>{n?Ae():_e()},{defer:!0})),v(C([c,B],([n,u])=>{n&&!t.isPaused()&&ae(u)})),v(C(()=>x.get(o.toastId)?.dismiss,n=>n&&D())),v(C(()=>E(),n=>!n&&ke()));const Me={translations:()=>o.translations,close:D,duration:B,isPersistent:()=>o.persistent??!1,closeTimerStartTime:()=>V,generateId:ye(()=>a.id),registerTitleId:ue(f),registerDescriptionId:ue(p)};return i(Be,{get when(){return E()},get children(){return i(be.Provider,{value:Me,get children(){return i(b,l({as:"li",ref(n){var u=xe(se,o.ref);typeof u=="function"&&u(n)},role:"status",tabIndex:0,get style(){return q({animation:h()?void 0:"none","user-select":"none","touch-action":"none"},o.style)},get"aria-live"(){return o.priority==="high"?"assertive":"polite"},"aria-atomic":"true",get"aria-labelledby"(){return m()},get"aria-describedby"(){return s()},get"data-opened"(){return c()?"":void 0},get"data-closed"(){return c()?void 0:""},get"data-swipe-direction"(){return t.swipeDirection()},onKeyDown:Ce,onPointerDown:Oe,onPointerMove:Le,onPointerUp:$e},a))}})}})}function me(r,t,e=0){const o=Math.abs(r.x),a=Math.abs(r.y),c=o>a;return t==="left"||t==="right"?c&&o>e:!c&&a>e}function R(r,t,e){const o=e.originalEvent.currentTarget,a=new CustomEvent(r,{bubbles:!0,cancelable:!0,detail:e});t&&o.addEventListener(r,t,{once:!0}),o.dispatchEvent(a)}function ne(r){const t=K(),e=F({id:t.generateId("title")},r),[o,a]=d(e,["id"]);return v(()=>
1O(t.registerTitleId(o.id))),i(b,l({as:"div",get id(){return o.id}},a))}var pt=0;function Se(r,t){const e=pt++;return x.add({id:e,toastComponent:r,dismiss:!1,update:!1,region:t?.region}),e}function G(r,t){x.update(r,{id:r,toastComponent:t,dismiss:!1,update:!0})}function gt(r,t,e){const o=Se(a=>t({get toastId(){return a.toastId},state:"pending"}),e);return(qe(r)?r():r).then(a=>G(o,c=>t({get toastId(){return c.toastId},state:"fulfilled",data:a}))).catch(a=>G(o,c=>t({get toastId(){return c.toastId},state:"rejected",error:a}))),o}function mt(r){return x.dismiss(r),r}function ft(){x.clear()}var j={show:Se,update:G,promise:gt,dismiss:mt,clear:ft},Tt=Object.assign(oe,{CloseButton:Q,Description:J,List:ee,ProgressFill:Ie,ProgressTrack:Ee,Region:re,Title:ne,toaster:j}),vt=he('<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round class=size-4><path d="M18 6l-12 12"></path><path d="M6 6l12 12">'),wt=he('<div class="grid gap-1"><!$><!/><!$><!/>');const ht=We("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--kb-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--kb-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[opened]:animate-in data-[closed]:animate-out data-[swipe=end]:animate-out data-[closed]:fade-out-80 data-[closed]:slide-out-to-right-full data-[opened]:slide-in-from-top-full data-[opened]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground",success:"success border-success-foreground bg-success text-success-foreground",warning:"warning border-warning-foreground bg-warning text-warning-foreground",error:"error border-error-foreground bg-error text-error-foreground"}},defaultVariants:{variant:"default"}}),Ft=r=>{const[t,e]=d(r,["class"]);return i(He,{get children(){return i(re,{get children(){return i(ee,l({get class(){return L("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse gap-2 p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",t.class)}},e))}})}})},De=r=>{const[t,e]=d(r,["class","variant"]);return i(oe,l({get class(){return L(ht({variant:t.variant}),t.class)}},e))},yt=r=>{const[t,e]=d(r,["class"]);return i(Q,l({get class(){return L("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-destructive-foreground group-[.error]:text-error-foreground group-[.success]:text-success-foreground group-[.warning]:text-warning-foreground",t.class)}},e,{get children(){return we(vt)}}))},xt=r=>{const[t,e]=d(r,["class"]);return i(ne,l({get class(){return L("text-sm font-semibold",t.class)}},e))},bt=r=>{const[t,e]=d(r,["class"]);return i(J,l({get class(){return L("text-sm opacity-90",t.class)}},e))};function Kt(r){j.show(t=>i(De,{get toastId(){return t.toastId},get variant(){return r.variant},get duration(){return r.duration},get children(){return[(()=>{var e=we(wt),o=e.firstChild,[a,c]=ce(o.nextSibling),g=a.nextSibling,[m,f]=ce(g.nextSibling);return le(e,(()=>{var s=N(()=>!!r.title);return()=>s()&&i(xt,{get children(){return r.title}})})(),a,c),le(e,(()=>{var s=N(()=>!!r.description);return()=>s()&&i(bt,{get children(){return r.description}})})(),m,f),e})(),i(yt,{})]}}))}function jt(r,t){const e={pending:"default",fulfilled:"success",rejected:"error"};return j.promise(r,o=>i(De,{get toastId(){return o.toastId},get variant(){return e[o.state]},get duration(){return t.duration},get children(){return i(Ve,{get children(){return[i(U,{get when(){return o.state==="pending"},get children(){return t.loading}}),i(U,{get when(){return o.state==="fulfilled"},get children(){return t.success?.(o.data)}}),i(U,{get when(){return o.state==="rejected"},get children(){return t.error?.(o.error)}})]}})}}))}export{De as Toast,yt as ToastClose,bt as ToastDescription,xt as ToastTitle,Ft as Toaster,Kt as showToast,jt as showToastPromise};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.