define(['exports', 'preact/jsx-runtime', 'preact/hooks', './Flex-590160eb', './UNSAFE_MessageBanner/themes/redwood/MessageBannerTheme', './useComponentTheme-5aa41a8f', './timer-571d3748', './classNames-08d99695', './Close-a88a3dcf', './IconButton-368fba34', './useTranslationBundle-7c40cb58', './PRIVATE_Message/themes/MessageStyles.css', 'preact', './MessageFormattingUtils-2e19d8de', './MessagesManager-2c4c218f', './utils-32e81a13'], (function(e,s,a,t,n,r,o,l,c,i,u,m,d,g,f,y){"use strict";function v({onAction:e,variant:a="banner"}){const t=u.useTranslationBundle("@oracle/oraclejet-preact"),n=s.jsx(i.IconButton,{"aria-label":t.message_close(),size:"sm",variant:"borderless",onAction:e,children:s.jsx(c.SvgClose,{})}),r=l.classNames([m.messageCloseButtonStyles.base,m.messageCloseButtonStyles[a]]);return s.jsx("div",{class:r,"data-oj-message-close-button":"",children:n})}function p({item:e,renderer:a}){const t=l.classNames([m.messageStartIconStyles.base,m.messageStartIconStyles.toast,m.messageStartIconStyles.customToast]);return s.jsx("div",{class:t,role:"presentation","data-oj-message-custom-icon":"",children:a(e)})}function b(e){const{detail:a}=e.data;return g.isValidValueForProp(a)?s.jsx(d.Fragment,{children:a}):null}function x({item:e,renderer:a,variant:t="banner"}){const n=null!=a,r=(a??b)(e);if(null==r)return null;const o=l.classNames([m.messageDetailStyles.base,m.messageDetailStyles[t]]);return s.jsx("div",{class:o,...n?{"data-oj-message-custom-detail":""}:{},children:r})}function j({children:e,variant:a="banner"}){const t=l.classNames([m.messageHeaderStyles.base,m.messageHeaderStyles[a]]);return s.jsx("div",{role:"presentation",class:t,children:e})}function S({value:e,variant:a="banner"}){const t=l.classNames([m.messageTimestampStyles[a]]),n=g.formatTimestamp(e);return s.jsx("div",{class:t,children:n})}function h(e){return g.isValidValueForProp(e,"severity")&&"none"!==e}e.Message=function({detailRenderer:e,iconRenderer:c,item:i,onClose:u,messageRef:d=(()=>{}),variant:b="pageBanner"}){const{closeAffordance:C="on",severity:B="error",sound:M,summary:T,timestamp:k}=i.data,{autoTimeout:F="off"}=i.data,I=function(e){return"pageBanner"===e||"sectionBanner"===e?"banner":"toast"}(b),N=a.useCallback((()=>{u?.(i)}),[i,u]),V=a.useCallback((e=>{"Escape"===e.key&&"on"===C&&u?.(i)}),[C,i,u]),A="toast"===I&&"off"!==F,R=a.useRef(),P="on"===F?5e3:"number"==typeof F?F:5e3,E=a.useCallback((()=>{R.current||(R.current=new o.Timer(N,P))}),[N,P]),U=a.useCallback((()=>{R.current&&(R.current.clear(),R.current=void 0)}),[]),w=a.useCallback((()=>{R.current?.pause()}),[]),D=a.useCallback((()=>{R.current?.resume()}),[]);a.useEffect((()=>(g.isValidValueForProp(M)&&f.playSound(M),A&&E(),()=>{U()})),[]);const{variantClasses:_}=r.useComponentTheme(n.MessageBannerRedwoodTheme,{severity:B}),H=l.classNames(["banner"===I&&_,m.messageStyles.base[I],"toast"!==b&&f.severityBasedStyleClass(B,I),"sectionBanner"===b&&m.messageStyles.section]),$=l.classNames([m.messageStyles.content.base,m.messageStyles.content[I]]);return s.jsx("div",{ref:d,class:H,role:"alert","aria-atomic":"true","data-oj-key":`${typeof i.key}-${i.key}`,tabIndex:0,onKeyUp:V,onFocusIn:w,onFocusOut:D,children:s.jsxs("div",{class:$,children:[c?s.jsx(p,{item:i,renderer:c}):h(B)?s.jsx(f.MessageStartIcon,{severity:B,variant:I}):null,s.jsxs(t.Flex,{direction:"column",flex:"1",gap:y.xUnits(2),children:[s.jsxs(j,{variant:I,children:[s.jsx(f.MessageSummary,{variant:I,text:T,role:"heading","aria-level":2}),g.isValidValueForProp(k,"timestamp")&&"toast"!==b&&s.jsx(S,{variant:I,value:k})]}),s.jsx(x,{variant:I,item:i,renderer:e})]}),"on"===C&&s.jsx(v,{variant:I,onAction:N})]})})},e.MessageCloseButton=v,e.MessageDetail=x,e.MessageTimestamp=S}));
//# sourceMappingURL=Message-d66cc7e9.js.map
