define(['exports', 'preact/jsx-runtime', 'preact/hooks', './LayerHost-733ade2f', './EnvironmentProvider-806b8f3a', './useMessagesFocusManager-8777bce0', './useBreakpointValues-3a067093', './MessagesContext-602a69a2', './useMessagesContext-1395a997', './useTranslationBundle-7c40cb58', './Message-d66cc7e9', 'preact', './utils-32e81a13', './useComponentTheme-5aa41a8f', './useTestId-c286f212', 'css!./TooltipContentStyles.styles.css', 'module', './hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentVariants.css', './tooltipUtils-30886397', 'css!./IconStyle.styles.css', './IconButton-368fba34', 'css!./MessageStyles.styles.css', './MessageFormattingUtils-2e19d8de', './MessagesManager-2c4c218f', './Flex-590160eb', './FocusTrap-d351e5c9', './LiveRegion-1917f798', './UNSAFE_MessageToast/themes/redwood/MessageToastTheme', './MessageLayer-a439ce52'], (function(e,s,t,n,o,a,r,i,l,c,u,d,g,m,f,h,p,y,M,v,x,T,R,F,b,k,C,S,j){"use strict";const E={entering:e=>({from:{transform:`translate(0, ${e.offsetHeight}px)`,opacity:1},to:{transform:"translate(0, 0)",opacity:1},end:{transform:"unset",opacity:1},options:{duration:250}}),exiting:{from:{opacity:1},to:{opacity:0},end:{opacity:0},options:{duration:250}}},U={opacity:0};e.MessageToast=function({data:e,detailRendererKey:n,iconRendererKey:i,renderers:d,onClose:h,offset:p,position:y,testId:M}){const v=f.useTestId(M),x=t.useRef(new Map),T=t.useRef(null),R=t.useRef(null),I=t.useRef(null),[L,w]=t.useState(),[B,_]=t.useState(e.length>0),[z,A]=t.useState(!1),N=c.useTranslationBundle("@oracle/oraclejet-preact"),{UNSAFE_messagesLayerId:V}=l.useMessagesContext(),$=t.useRef(e.length),H=t.useRef(0);$.current=e.length,t.useImperativeHandle(I,(()=>({focus:()=>!!e.length&&(T.current=x.current.get(e[0].key)??null,A(!0),!0),contains:s=>!(!e.length||!s)&&(R.current?.contains(s)??!1)})),[e]);const{controller:K,handlers:P}=a.useMessageFocusManager(I,{onFocus:t.useCallback((()=>{w(N.message_navigationFromMessagesRegion())}),[N]),onFocusLeave:t.useCallback((()=>{A(!1)}),[])},{handleEscapeKey:!1}),W=t.useCallback(((s,t,n)=>{const o=n?.contains(document.activeElement);if(0===$.current)return _(!1),A(!1),void(o&&setTimeout((()=>K.restorePriorFocus()),0));const a=t+1<e.length?t+1:t-1;if(a>-1&&o){const s=e[a].key;x.current.get(s)?.focus()}}),[K,e]),D=t.useCallback((e=>s=>x.current.set(e,s)),[]);t.useEffect((()=>{const s=H.current;if(H.current=e.length,e.length)return _(!0),e.length>s&&w(N.message_navigationToMessagesRegion()),void K.prioritize();w(s?N.messageToast_allMessagesClosed():"")}),[K,e.length,N]);const q=r.useBreakpointValues({sm:`calc(100vw - ${g.xUnits(8)})`,md:`calc(100vw - ${g.xUnits(12)})`,lg:`calc(150 * ${g.xUnits(1)})`}),G=r.useBreakpointValues({sm:{horizontal:"number"==typeof p?p:p?.horizontal??0,vertical:16+("number"==typeof p?p:p?.vertical??0)},lg:{horizontal:"number"==typeof p?p:p?.horizontal??0,vertical:24+("number"==typeof p?p:p?.vertical??0)}}),{classes:J}=m.useComponentTheme(S.MessageToastRedwoodTheme);return B||0!==e.length?s.jsxs(o.EnvironmentProvider,{environment:{colorScheme:"dark"},children:[s.jsx(j.MessageLayer,{offset:G,position:y,children:s.jsx("div",{class:J,ref:R,tabIndex:-1,id:V,...P,...v,children:s.jsx(k.FocusTrap,{autoFocusRef:T,isDisabled:!z,children:s.jsx(b.Flex,{direction:"column",gap:"1x",align:"center",maxWidth:q,children:s.jsx(F.MessagesManager,{animationStates:E,initialAnimationStyles:U,data:e,onMessageWillRemove:W,children:({item:e})=>s.jsx(u.Message,{messageRef:D(e.key),item:e,detailRenderer:F.getRenderer(e,n,d),iconRenderer:F.getRenderer(e,i,d),onClose:h,variant:"toast"},e.key)})})})})}),s.jsx(C.LiveRegion,{children:L})]}):s.jsx(C.LiveRegion,{children:L})}}));
//# sourceMappingURL=MessageToast-19703f73.js.map
