{"version":3,"file":"useMessageComposerSubmitFn.mjs","names":[],"sources":["../../../../../src/components/MessageComposer/hooks/useMessageComposerSubmitFn.ts"],"sourcesContent":["import { useCallback } from 'react';\n\nimport { useMessageComposerController } from './useMessageComposerController';\n\n/**\n * Submits the composer: saves the edit while a message is being edited, sends a new message\n * otherwise. The choice is made when the callback runs and every submit control uses this hook, so\n * the send button and the Enter key cannot disagree.\n *\n * @returns Submit callback, stable while the composer is the same.\n */\nexport const useMessageComposerSubmitFn = () => {\n  const messageComposer = useMessageComposerController();\n\n  return useCallback(\n    () =>\n      messageComposer.editedMessage ? messageComposer.update() : messageComposer.send(),\n    [messageComposer],\n  );\n};\n"],"mappings":";;;;;;;;;;AAWA,IAAa,mCAAmC;CAC9C,MAAM,kBAAkB,6BAA6B;CAErD,OAAO,kBAEH,gBAAgB,gBAAgB,gBAAgB,OAAO,IAAI,gBAAgB,KAAK,GAClF,CAAC,eAAe,CAClB;AACF"}