import{a as e,n as t}from"./chunk-BneVvdWh.js";import{t as n}from"./react-C7IZe2D1.js";import{t as r}from"./jsx-runtime-C2wGStra.js";import{n as i,t as a}from"./TokyoUIInfo-CL0Zo7ru.js";import{n as o,t as s}from"./useStableCallback-BRGKkp0I.js";import{i as c,n as l,r as u,t as d}from"./Toast-4qLSIopQ.js";var f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M;t((()=>{f=e(n(),1),i(),u(),s(),p=r(),{userEvent:m,waitForElementToBeRemoved:h,expect:g}=__STORYBOOK_MODULE_TEST__,{action:_}=__STORYBOOK_MODULE_ACTIONS__,v=({duration:e,showToasts:t})=>{let n=o(t);return(0,f.useEffect)(()=>{n()},[n]),(0,p.jsx)(d,{duration:e})},y={title:`Components/Toast`,component:l,render:e=>(0,p.jsx)(v,{...e}),parameters:{docs:{story:{inline:!1,iframeHeight:200}},chromatic:{modes:{"narrow-l":{viewport:`narrow-l`},"medium-s":{viewport:`medium-s`}}}},argTypes:{message:{description:`The toast title.`,type:`string`,table:{category:`showToast()`}},variant:{description:`The toast severity variant. This affects the toast colors.`,options:[`info`,`critical`],table:{category:`showToast()`,defaultValue:{summary:`info`}}},leadingSvgIcon:{description:`The toast icon.`,table:{category:`showToast()`,defaultValue:{summary:`undefined | critical.svg`,detail:"If the toast variant is `critical`, the `critical` icon is used."}}},actionLabel:{description:`The optional toast action's label.`,type:`string`,table:{category:`showToast()`}},actionOnClick:{description:`The optional toast action's click handler.`,type:`function`,table:{category:`showToast()`}},actionHref:{description:"The optional toast action's `href`.\n        When this is provided, an `<a>` tag is used for the action, otherwise, a `<button>` is used instead.\n        ",type:`string`,table:{category:`showToast()`}},duration:{table:{disable:!0}},showToasts:{table:{disable:!0}}}},b={args:{duration:1/0,showToasts:()=>{c(`This is a toast`)}}},x={tags:[`!autodocs`],args:{duration:500,showToasts:()=>{c(`This is a toast`,{dataset:{testid:`toast`}})}},play:async({step:e,canvas:t})=>{await e(`wait for toast`,async()=>{await g(await t.findByTestId(`toast`)).toBeInTheDocument()}),await e(`check toast is dismissed automatically`,()=>h(t.getByTestId(`toast`)))}},S={tags:[`!autodocs`],args:{duration:1/0,showToasts:()=>{c(`This is a toast`,{dataset:{testid:`toast`}})}},play:async({step:e,canvas:t})=>{await e(`wait for toast`,async()=>{await g(await t.findByTestId(`toast`)).toBeInTheDocument()}),await e(`check toast is dismissed on close button click`,async()=>{let e=t.getByTestId(`toast`);return t.getByRole(`button`).click(),h(e)})}},C={args:{duration:1/0,showToasts:()=>{c(`This is a toast`,{actionLabel:`Action`,actionOnClick:_(`actionOnClick`)})}}},w={tags:[`!autodocs`],args:{duration:1/0,showToasts:()=>{c(`This is a toast`,{actionLabel:`Action`,actionOnClick:_(`actionOnClick`),dataset:{testid:`toast`}})}},play:async({canvas:e,step:t})=>{await t(`wait for toast`,async()=>{await g(await e.findByTestId(`toast`)).toBeInTheDocument()}),await t(`check toast is dismissed on action button click`,async()=>{let t=e.getByTestId(`toast`),n=e.getByText(`Action`);return await m.click(n),h(t)})}},T={args:{duration:1/0,showToasts:()=>{c(`This is a toast`,{actionLabel:`Action`,actionOnClick:_(`actionOnClick`),actionHref:`#`})}}},E={args:{duration:1/0,showToasts:()=>{c(`This is a toast`,{leadingSvgIcon:a})}}},D={args:{duration:1/0,showToasts:()=>{c(`This is a critical toast`,{variant:`critical`})}}},O={args:{duration:1/0,showToasts:()=>{c(`This is a critical toast`,{variant:`critical`,actionLabel:`Action`,actionOnClick:_(`actionOnClick`)})}}},k={args:{duration:1/0,showToasts:()=>{c(`This is toast 1`),c(`This is toast 2`),c(`This is toast 3`)}}},A={args:{duration:1/0,showToasts:()=>{c(`This is toast 1`),c(`This is toast 2`),c(`This is toast 3`,{dataset:{testid:`toast3`}})}},play:async({canvas:e,canvasElement:t,step:n})=>{await n(`wait for toast 3`,async()=>{await g(await e.findByTestId(`toast3`)).toBeInTheDocument()}),await n(`Use global toast area shortcut`,async()=>{t.focus(),await m.keyboard(`{Alt>}T`)})}},j={args:{duration:1/0,showToasts:()=>{c(`What happens if the message is really really really really reeaaaaaaaallyyyyyyy looooooooooong`)}}},b.parameters={...b.parameters,docs:{...b.parameters?.docs,source:{originalSource:`{
  args: {
    duration: Infinity,
    showToasts: () => {
      showToast('This is a toast');
    }
  }
}`,...b.parameters?.docs?.source}}},x.parameters={...x.parameters,docs:{...x.parameters?.docs,source:{originalSource:`{
  tags: ['!autodocs'],
  args: {
    duration: 500,
    showToasts: () => {
      showToast('This is a toast', {
        dataset: {
          testid: 'toast'
        }
      });
    }
  },
  play: async ({
    step,
    canvas
  }) => {
    await step('wait for toast', async () => {
      const toast = await canvas.findByTestId('toast');
      await expect(toast).toBeInTheDocument();
    });
    await step('check toast is dismissed automatically', () => {
      const toast = canvas.getByTestId('toast');
      return waitForElementToBeRemoved(toast);
    });
  }
}`,...x.parameters?.docs?.source}}},S.parameters={...S.parameters,docs:{...S.parameters?.docs,source:{originalSource:`{
  tags: ['!autodocs'],
  args: {
    duration: Infinity,
    showToasts: () => {
      showToast('This is a toast', {
        dataset: {
          testid: 'toast'
        }
      });
    }
  },
  play: async ({
    step,
    canvas
  }) => {
    await step('wait for toast', async () => {
      const toast = await canvas.findByTestId('toast');
      await expect(toast).toBeInTheDocument();
    });
    await step('check toast is dismissed on close button click', async () => {
      const toast = canvas.getByTestId('toast');
      const close = canvas.getByRole('button');
      close.click();
      return waitForElementToBeRemoved(toast);
    });
  }
}`,...S.parameters?.docs?.source}}},C.parameters={...C.parameters,docs:{...C.parameters?.docs,source:{originalSource:`{
  args: {
    duration: Infinity,
    showToasts: () => {
      showToast('This is a toast', {
        actionLabel: 'Action',
        actionOnClick: action('actionOnClick')
      });
    }
  }
}`,...C.parameters?.docs?.source}}},w.parameters={...w.parameters,docs:{...w.parameters?.docs,source:{originalSource:`{
  tags: ['!autodocs'],
  args: {
    duration: Infinity,
    showToasts: () => {
      showToast('This is a toast', {
        actionLabel: 'Action',
        actionOnClick: action('actionOnClick'),
        dataset: {
          testid: 'toast'
        }
      });
    }
  },
  play: async ({
    canvas,
    step
  }) => {
    await step('wait for toast', async () => {
      const toast = await canvas.findByTestId('toast');
      await expect(toast).toBeInTheDocument();
    });
    await step('check toast is dismissed on action button click', async () => {
      const toast = canvas.getByTestId('toast');
      const action = canvas.getByText('Action');
      await userEvent.click(action);
      return waitForElementToBeRemoved(toast);
    });
  }
}`,...w.parameters?.docs?.source}}},T.parameters={...T.parameters,docs:{...T.parameters?.docs,source:{originalSource:`{
  args: {
    duration: Infinity,
    showToasts: () => {
      showToast('This is a toast', {
        actionLabel: 'Action',
        actionOnClick: action('actionOnClick'),
        actionHref: '#'
      });
    }
  }
}`,...T.parameters?.docs?.source}}},E.parameters={...E.parameters,docs:{...E.parameters?.docs,source:{originalSource:`{
  args: {
    duration: Infinity,
    showToasts: () => {
      showToast('This is a toast', {
        leadingSvgIcon: InfoIcon
      });
    }
  }
}`,...E.parameters?.docs?.source}}},D.parameters={...D.parameters,docs:{...D.parameters?.docs,source:{originalSource:`{
  args: {
    duration: Infinity,
    showToasts: () => {
      showToast('This is a critical toast', {
        variant: 'critical'
      });
    }
  }
}`,...D.parameters?.docs?.source}}},O.parameters={...O.parameters,docs:{...O.parameters?.docs,source:{originalSource:`{
  args: {
    duration: Infinity,
    showToasts: () => {
      showToast('This is a critical toast', {
        variant: 'critical',
        actionLabel: 'Action',
        actionOnClick: action('actionOnClick')
      });
    }
  }
}`,...O.parameters?.docs?.source}}},k.parameters={...k.parameters,docs:{...k.parameters?.docs,source:{originalSource:`{
  args: {
    duration: Infinity,
    showToasts: () => {
      showToast('This is toast 1');
      showToast('This is toast 2');
      showToast('This is toast 3');
    }
  }
}`,...k.parameters?.docs?.source}}},A.parameters={...A.parameters,docs:{...A.parameters?.docs,source:{originalSource:`{
  args: {
    duration: Infinity,
    showToasts: () => {
      showToast('This is toast 1');
      showToast('This is toast 2');
      showToast('This is toast 3', {
        dataset: {
          testid: 'toast3'
        }
      });
    }
  },
  play: async ({
    canvas,
    canvasElement,
    step
  }) => {
    await step('wait for toast 3', async () => {
      const toast3 = await canvas.findByTestId('toast3');
      await expect(toast3).toBeInTheDocument();
    });
    await step('Use global toast area shortcut', async () => {
      canvasElement.focus();
      await userEvent.keyboard('{Alt>}T');
      // Assertion for this is implicitly done by the visual snapshot test.
    });
  }
}`,...A.parameters?.docs?.source}}},j.parameters={...j.parameters,docs:{...j.parameters?.docs,source:{originalSource:`{
  args: {
    duration: Infinity,
    showToasts: () => {
      showToast('What happens if the message is really really really really reeaaaaaaaallyyyyyyy looooooooooong');
    }
  }
}`,...j.parameters?.docs?.source}}},M=[`Toast`,`TestTimer`,`TestClose`,`Action`,`TestActionClose`,`ActionLink`,`Icon`,`Critical`,`CriticalWithAction`,`Stack`,`TestStackExpand`,`LongMessage`]}))();export{C as Action,T as ActionLink,D as Critical,O as CriticalWithAction,E as Icon,j as LongMessage,k as Stack,w as TestActionClose,S as TestClose,A as TestStackExpand,x as TestTimer,b as Toast,M as __namedExportsOrder,y as default};