@corva/ui 3.82.0-2 → 3.82.0-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs-bundle/components/CommentComposer/CommentComposer.js +1 -1
- package/cjs-bundle/components/CommentComposer/CommentComposer.js.map +1 -1
- package/components/CommentComposer/CommentComposer.d.ts.map +1 -1
- package/components/CommentComposer/CommentComposer.js +1 -1
- package/components/CommentComposer/CommentComposer.js.map +1 -1
- package/mcp-server/server.mjs +1 -1
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/components/CommentComposer/__tests__/CommentComposer.trailing.test.d.ts +0 -2
- package/components/CommentComposer/__tests__/CommentComposer.trailing.test.d.ts.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),s=require("@babel/runtime/helpers/slicedToArray"),o=require("react"),n=require("@material-ui/core"),i=require("@material-ui/icons/AlternateEmail"),c=require("../../componentsV2/ButtonIcon/ButtonIcon.js"),r=require("../../componentsV2/Tooltip/Tooltip.js"),t=require("../../icons/iconParkIcons.js");require("../../icons/customIcons/icons/AddMessage.js"),require("../../icons/customIcons/icons/DragOne.js"),require("../../icons/customIcons/icons/Attention.js"),require("../../icons/customIcons/icons/Collapse.js"),require("../../icons/customIcons/icons/Dashboard.js"),require("../../icons/customIcons/icons/Expand.js"),require("../../icons/customIcons/icons/FolderClosed.js"),require("../../icons/customIcons/icons/FolderClosedFilled.js"),require("../../icons/customIcons/icons/FolderOpened.js"),require("../../icons/customIcons/icons/GreaterOrEqual.js"),require("../../icons/customIcons/icons/LessOrEqual.js"),require("../../icons/customIcons/icons/Search.js"),require("../../icons/customIcons/icons/SearchOne.js"),require("../../icons/customIcons/icons/Wellhub.js"),require("../../icons/customIcons/icons/MultiRuler.js"),require("../../icons/customIcons/icons/Checkbox.js"),require("../../icons/customIcons/icons/CheckboxChecked.js"),require("../../icons/customIcons/icons/CheckboxIndeterminate.js"),require("../../icons/customIcons/icons/Radio.js"),require("../../icons/customIcons/icons/RadioChecked.js"),require("../../icons/customIcons/icons/SimulFrac.js"),require("../../icons/customIcons/icons/ZipperFrac.js"),require("../../icons/customIcons/icons/CautionFilled.js"),require("../../icons/customIcons/icons/InfoRounded.js"),require("../../icons/customIcons/icons/FlameFilled.js"),require("../../icons/customIcons/icons/MoreApp.js"),require("../../icons/customIcons/icons/Pad.js"),require("../../icons/customIcons/icons/DrilloutUnit.js"),require("../../icons/customIcons/icons/FracFleet.js"),require("../../icons/customIcons/icons/Global.js"),require("../../icons/customIcons/icons/Program.js"),require("../../icons/customIcons/icons/Rig.js"),require("../../icons/customIcons/icons/Well.js"),require("../../icons/customIcons/icons/Gap.js"),require("../../icons/customIcons/icons/Pin.js"),require("../../icons/customIcons/icons/PinOne.js"),require("../../icons/customIcons/icons/PinOneCrossed.js"),require("../../icons/customIcons/icons/CloseOneFilled.js"),require("../../icons/customIcons/icons/AttentionFilled.js"),require("../../icons/customIcons/icons/CheckOneFilled.js"),require("../../icons/customIcons/icons/Archive.js"),require("../../icons/customIcons/icons/ArchiveCancel.js"),require("../../icons/customIcons/icons/Unarchive.js"),require("../../icons/customIcons/icons/Archived.js"),require("../../icons/customIcons/icons/InterventionUnit.js"),require("../../icons/customIcons/icons/CloudDelete.js"),require("../../icons/customIcons/icons/Lasso.js"),require("../../icons/customIcons/icons/Radius.js"),require("../../icons/customIcons/icons/ErrorOps.js"),require("../../icons/customIcons/icons/DataTypeOps.js"),require("../../icons/customIcons/icons/FalsePositiveOps.js"),require("../../icons/customIcons/icons/CalibrationOps.js"),require("../../icons/customIcons/icons/CriticalOps.js"),require("../../icons/customIcons/icons/Company.js"),require("../../icons/customIcons/icons/ArchiveOne.js"),require("../../icons/customIcons/icons/ParseBotFusion.js"),require("../../icons/customIcons/icons/Connect.js"),require("../../icons/customIcons/icons/PuzzleOne.js"),require("../../icons/customIcons/icons/Feed.js"),require("../../icons/customIcons/icons/Prompt.js"),require("../../icons/customIcons/icons/Companies.js"),require("../../icons/customIcons/icons/ClipboardAi.js"),require("../../icons/customIcons/icons/Key.js"),require("../../icons/customIcons/icons/AtSignCrossed.js"),require("../../icons/customIcons/icons/MappingManual.js"),require("../../icons/customIcons/icons/Mapping.js"),require("../../icons/customIcons/icons/Metrics.js"),require("../../icons/customIcons/icons/Drops.js"),require("../../icons/customIcons/icons/ClipboardSearch.js"),require("../../icons/customIcons/icons/Template.js"),require("../../icons/customIcons/icons/ClipboardMetrics.js"),require("../../icons/customIcons/icons/ClipboardBuilder.js"),require("../../icons/customIcons/icons/UnitConversion.js"),require("../../icons/customIcons/icons/NPT.js"),require("../../icons/customIcons/icons/GuidedFrac.js");var u=require("../Avatar/index.js"),a=require("../AttachFileButton/AttachFileButton.js"),l=require("../CommentInputNext/CommentInputNext.js"),m=require("../EmojiIconButton.js"),d=require("../FailedFileUploading.js"),j=require("../UserMention/index.js"),p=require("../UserMention/utils/index.js"),q=require("../WellhubFilePicker/WellhubFilePicker.js");require("@babel/runtime/helpers/toConsumableArray"),require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/regenerator"),require("lodash/set"),require("lodash/get"),require("lodash/unset"),require("moment"),require("../../clients/jsonApi/index.js"),require("../../clients/subscriptions/subscriptions-client.factory.js"),require("../../clients/api/apiCore.js"),require("../../clients/constants.js"),require("../../clients/sso/auth0.js"),require("../../clients/sso/oauth2.js"),require("../../clients/api/rateLimiter.js"),require("uuid");var h=require("./useAttachmentUpload.js"),I=require("./CommentMetaLine.js"),b=require("./ShareToChatRow.js"),g=require("./CommentComposer.scss.js"),f=require("react/jsx-runtime");function C(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var v=C(e),F=C(s),x=C(i);function y(e,s){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter((function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable}))),o.push.apply(o,n)}return o}function O(e){for(var s=1;s<arguments.length;s++){var o=null!=arguments[s]?arguments[s]:{};s%2?y(Object(o),!0).forEach((function(s){v.default(e,s,o[s])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):y(Object(o)).forEach((function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(o,s))}))}return e}var A={fontSize:14,lineHeight:"20px",suggestions:{backgroundColor:"var(--palette-background-b-9)",list:{backgroundColor:"var(--palette-background-b-9)"},item:{color:"var(--palette-primary-text-1)","&focused":{backgroundColor:"rgb(from var(--palette-primary-text-1) r g b / 0.08)"}}}},S=function(e){return f.jsxs("div",{className:g.suggestion,children:[f.jsx(u.AvatarComponent,{size:26,alt:e.display,imgSrc:e.photo,displayName:e.display}),f.jsx("span",{children:e.display})]})};exports.CommentComposer=function(e){var s=e.body,i=e.onBodyChange,u=e.onSubmit,C=e.canSubmit,v=e.currentUser,y=e.attachments,P=e.onAttachmentsChange,k=e.maxAttachments,E=void 0===k?h.DEFAULT_MAX_ATTACHMENTS:k,M=e.attachment,w=e.onAttachmentChange,D=e.attachmentError,R=e.onAttachmentError,T=e.maxAttachmentSizeBytes,U=e.wellhubContext,L=e.disabled,B=e.autoFocus,N=e.placeholder,z=void 0===N?"Add a comment...":N,W=e.metaRows,G=e.isMetaSingleLine,_=e.shareToChat,H=e.trailing,K=e.renderTrailing,V=e.embedded,Q=e.className,X=e.testId,Z=!!P,$=o.useMemo((function(){return Z?null!=y?y:[]:[M].filter(Boolean)}),[Z,y,M]),J=o.useCallback((function(e){var s;P?P(e):null==w||w(null!==(s=e[0])&&void 0!==s?s:null)}),[P,w]),Y=h.useAttachmentUpload({value:$,onChange:J,onError:R,maxSizeBytes:T,maxFiles:Z?E:1}),ee=C&&!Y.isUploading,se=function(){ee&&!L&&u()},oe=o.useState(!1),ne=F.default(oe,2),ie=ne[0],ce=ne[1],re=o.useMemo((function(){return $.map((function(e){return e.name}))}),[$]),te=o.useRef(null);return f.jsxs(f.Fragment,{children:[f.jsx(l.CommentInput,{value:s,canSubmit:ee,disabled:L,onSubmit:u,trailing:K?K({canSend:ee&&!L,submit:se}):H,embedded:V,className:Q,testId:X,field:f.jsx(n.Input,{inputComponent:j,inputProps:{onChange:i,currentUser:v,allowEmptyQuery:!0,suggestionsPortalHost:document.querySelector("body"),withLightTheme:!1,mentionProps:{renderSuggestion:S},highlightLinks:!0,style:A},value:s,placeholder:z,inputRef:te,className:g.mentionField,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||ee&&!L&&(p.isSuggestionsListOpened()||(e.preventDefault(),se()))},disableUnderline:!0,rows:1,fullWidth:!0,multiline:!0,autoFocus:B}),attachments:Y.items,onAttachmentRemove:Y.removeAttachment,onAttachmentRetry:Y.handleRetry,onAttachmentReorder:Z?Y.reorderAttachments:void 0,onFilesDrop:Y.addFiles,onImageLinkPaste:Y.addLinkedImage,dropLabel:1===Y.maxFiles?"Drop a file here":"Drop files here",attachmentSlot:D?f.jsx(d,{errorMessage:D}):void 0,toolbar:f.jsxs(f.Fragment,{children:[f.jsx(a.AttachFileButton,{inputRef:Y.fileInputRef,onClick:Y.openFileDialog,onFileSelect:Y.handleFileSelect,onWellhubSelect:U?function(){return ce(!0)}:void 0,multiple:Z,disabled:Y.isFull,tooltip:Y.isFull?"Up to ".concat(Y.maxFiles," ").concat(1===Y.maxFiles?"file":"files"," can be attached"):"Attach ".concat(Z?"files":"file")}),f.jsx(r.Tooltip,{title:"Mention someone",children:f.jsx(c.ButtonIcon,{size:"xs",type:"tertiary",onClick:function(){var e,s=te.current;if(s){s.focus();var o=!!s.value&&!/\s$/.test(s.value),n="".concat(s.value).concat(o?" @":"@"),i=null===(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(s),"value"))||void 0===e?void 0:e.set;null==i||i.call(s,n),s.setSelectionRange(n.length,n.length),s.dispatchEvent(new Event("input",{bubbles:!0})),s.dispatchEvent(new Event("keyup",{bubbles:!0}))}},children:f.jsx(x.default,{fontSize:"inherit"})})}),f.jsx("span",{className:g.iconSlot,children:f.jsx(m,{icon:f.jsx(t.SmilingFaceIcon,{size:16}),handleSelectEmoji:function(e){return i("".concat(s).concat(e.native))}})})]}),footer:(!(null==W||!W.length)||!!_)&&f.jsxs(f.Fragment,{children:[f.jsx(I.CommentMetaLine,{rows:null!=W?W:[],singleLine:G}),_&&f.jsx(b.ShareToChatRow,O({},_))]})}),U&&f.jsx(q.WellhubFilePicker,O(O({},U),{},{open:ie,maxSelectable:Y.maxFiles-Y.count,attachedFileNames:re,onAdd:function(e){ce(!1),Y.addStoredFiles(e.map((function(e){return{fileName:e.fileName}})))},onClose:function(){return ce(!1)}}))]})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),s=require("@babel/runtime/helpers/slicedToArray"),o=require("react"),n=require("@material-ui/core"),i=require("@material-ui/icons/AlternateEmail"),c=require("../../componentsV2/ButtonIcon/ButtonIcon.js"),r=require("../../componentsV2/Tooltip/Tooltip.js"),t=require("../../icons/iconParkIcons.js");require("../../icons/customIcons/icons/AddMessage.js"),require("../../icons/customIcons/icons/DragOne.js"),require("../../icons/customIcons/icons/Attention.js"),require("../../icons/customIcons/icons/Collapse.js"),require("../../icons/customIcons/icons/Dashboard.js"),require("../../icons/customIcons/icons/Expand.js"),require("../../icons/customIcons/icons/FolderClosed.js"),require("../../icons/customIcons/icons/FolderClosedFilled.js"),require("../../icons/customIcons/icons/FolderOpened.js"),require("../../icons/customIcons/icons/GreaterOrEqual.js"),require("../../icons/customIcons/icons/LessOrEqual.js"),require("../../icons/customIcons/icons/Search.js"),require("../../icons/customIcons/icons/SearchOne.js"),require("../../icons/customIcons/icons/Wellhub.js"),require("../../icons/customIcons/icons/MultiRuler.js"),require("../../icons/customIcons/icons/Checkbox.js"),require("../../icons/customIcons/icons/CheckboxChecked.js"),require("../../icons/customIcons/icons/CheckboxIndeterminate.js"),require("../../icons/customIcons/icons/Radio.js"),require("../../icons/customIcons/icons/RadioChecked.js"),require("../../icons/customIcons/icons/SimulFrac.js"),require("../../icons/customIcons/icons/ZipperFrac.js"),require("../../icons/customIcons/icons/CautionFilled.js"),require("../../icons/customIcons/icons/InfoRounded.js"),require("../../icons/customIcons/icons/FlameFilled.js"),require("../../icons/customIcons/icons/MoreApp.js"),require("../../icons/customIcons/icons/Pad.js"),require("../../icons/customIcons/icons/DrilloutUnit.js"),require("../../icons/customIcons/icons/FracFleet.js"),require("../../icons/customIcons/icons/Global.js"),require("../../icons/customIcons/icons/Program.js"),require("../../icons/customIcons/icons/Rig.js"),require("../../icons/customIcons/icons/Well.js"),require("../../icons/customIcons/icons/Gap.js"),require("../../icons/customIcons/icons/Pin.js"),require("../../icons/customIcons/icons/PinOne.js"),require("../../icons/customIcons/icons/PinOneCrossed.js"),require("../../icons/customIcons/icons/CloseOneFilled.js"),require("../../icons/customIcons/icons/AttentionFilled.js"),require("../../icons/customIcons/icons/CheckOneFilled.js"),require("../../icons/customIcons/icons/Archive.js"),require("../../icons/customIcons/icons/ArchiveCancel.js"),require("../../icons/customIcons/icons/Unarchive.js"),require("../../icons/customIcons/icons/Archived.js"),require("../../icons/customIcons/icons/InterventionUnit.js"),require("../../icons/customIcons/icons/CloudDelete.js"),require("../../icons/customIcons/icons/Lasso.js"),require("../../icons/customIcons/icons/Radius.js"),require("../../icons/customIcons/icons/ErrorOps.js"),require("../../icons/customIcons/icons/DataTypeOps.js"),require("../../icons/customIcons/icons/FalsePositiveOps.js"),require("../../icons/customIcons/icons/CalibrationOps.js"),require("../../icons/customIcons/icons/CriticalOps.js"),require("../../icons/customIcons/icons/Company.js"),require("../../icons/customIcons/icons/ArchiveOne.js"),require("../../icons/customIcons/icons/ParseBotFusion.js"),require("../../icons/customIcons/icons/Connect.js"),require("../../icons/customIcons/icons/PuzzleOne.js"),require("../../icons/customIcons/icons/Feed.js"),require("../../icons/customIcons/icons/Prompt.js"),require("../../icons/customIcons/icons/Companies.js"),require("../../icons/customIcons/icons/ClipboardAi.js"),require("../../icons/customIcons/icons/Key.js"),require("../../icons/customIcons/icons/AtSignCrossed.js"),require("../../icons/customIcons/icons/MappingManual.js"),require("../../icons/customIcons/icons/Mapping.js"),require("../../icons/customIcons/icons/Metrics.js"),require("../../icons/customIcons/icons/Drops.js"),require("../../icons/customIcons/icons/ClipboardSearch.js"),require("../../icons/customIcons/icons/Template.js"),require("../../icons/customIcons/icons/ClipboardMetrics.js"),require("../../icons/customIcons/icons/ClipboardBuilder.js"),require("../../icons/customIcons/icons/UnitConversion.js"),require("../../icons/customIcons/icons/NPT.js"),require("../../icons/customIcons/icons/GuidedFrac.js");var u=require("../Avatar/index.js"),a=require("../AttachFileButton/AttachFileButton.js"),l=require("../CommentInputNext/CommentInputNext.js"),m=require("../EmojiIconButton.js"),d=require("../FailedFileUploading.js"),j=require("../UserMention/index.js"),p=require("../UserMention/utils/index.js"),q=require("../WellhubFilePicker/WellhubFilePicker.js");require("@babel/runtime/helpers/toConsumableArray"),require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/regenerator"),require("lodash/set"),require("lodash/get"),require("lodash/unset"),require("moment"),require("../../clients/jsonApi/index.js"),require("../../clients/subscriptions/subscriptions-client.factory.js"),require("../../clients/api/apiCore.js"),require("../../clients/constants.js"),require("../../clients/sso/auth0.js"),require("../../clients/sso/oauth2.js"),require("../../clients/api/rateLimiter.js"),require("uuid");var h=require("./useAttachmentUpload.js"),I=require("./CommentMetaLine.js"),b=require("./ShareToChatRow.js"),g=require("./CommentComposer.scss.js"),f=require("react/jsx-runtime");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var C=v(e),F=v(s),x=v(i);function y(e,s){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter((function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable}))),o.push.apply(o,n)}return o}function O(e){for(var s=1;s<arguments.length;s++){var o=null!=arguments[s]?arguments[s]:{};s%2?y(Object(o),!0).forEach((function(s){C.default(e,s,o[s])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):y(Object(o)).forEach((function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(o,s))}))}return e}var A={fontSize:14,lineHeight:"20px",suggestions:{backgroundColor:"var(--palette-background-b-9)",list:{backgroundColor:"var(--palette-background-b-9)"},item:{color:"var(--palette-primary-text-1)","&focused":{backgroundColor:"rgb(from var(--palette-primary-text-1) r g b / 0.08)"}}}},S=function(e){return f.jsxs("div",{className:g.suggestion,children:[f.jsx(u.AvatarComponent,{size:26,alt:e.display,imgSrc:e.photo,displayName:e.display}),f.jsx("span",{children:e.display})]})};exports.CommentComposer=function(e){var s=e.body,i=e.onBodyChange,u=e.onSubmit,v=e.canSubmit,C=e.currentUser,y=e.attachments,P=e.onAttachmentsChange,k=e.maxAttachments,E=void 0===k?h.DEFAULT_MAX_ATTACHMENTS:k,M=e.attachment,R=e.onAttachmentChange,w=e.attachmentError,D=e.onAttachmentError,T=e.maxAttachmentSizeBytes,U=e.wellhubContext,L=e.disabled,B=e.autoFocus,N=e.placeholder,z=void 0===N?"Add a comment...":N,W=e.metaRows,G=e.isMetaSingleLine,_=e.shareToChat,H=e.trailing,K=e.renderTrailing,V=e.embedded,Q=e.className,X=e.testId,Z=!!P,$=o.useMemo((function(){return Z?null!=y?y:[]:[M].filter(Boolean)}),[Z,y,M]),J=o.useCallback((function(e){var s;P?P(e):null==R||R(null!==(s=e[0])&&void 0!==s?s:null)}),[P,R]),Y=h.useAttachmentUpload({value:$,onChange:J,onError:D,maxSizeBytes:T,maxFiles:Z?E:1}),ee=v&&!Y.isUploading,se=function(){ee&&!L&&u()},oe=o.useState(!1),ne=F.default(oe,2),ie=ne[0],ce=ne[1],re=o.useMemo((function(){return $.map((function(e){return e.name}))}),[$]),te=o.useRef(null);o.useEffect((function(){var e=te.current;B&&e&&e.setSelectionRange(e.value.length,e.value.length)}),[B]);return f.jsxs(f.Fragment,{children:[f.jsx(l.CommentInput,{value:s,canSubmit:ee,disabled:L,onSubmit:u,trailing:K?K({canSend:ee&&!L,submit:se}):H,embedded:V,className:Q,testId:X,field:f.jsx(n.Input,{inputComponent:j,inputProps:{onChange:i,currentUser:C,allowEmptyQuery:!0,suggestionsPortalHost:document.querySelector("body"),withLightTheme:!1,mentionProps:{renderSuggestion:S},highlightLinks:!0,style:A},value:s,placeholder:z,inputRef:te,className:g.mentionField,onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||ee&&!L&&(p.isSuggestionsListOpened()||(e.preventDefault(),se()))},disableUnderline:!0,rows:1,fullWidth:!0,multiline:!0,autoFocus:B}),attachments:Y.items,onAttachmentRemove:Y.removeAttachment,onAttachmentRetry:Y.handleRetry,onAttachmentReorder:Z?Y.reorderAttachments:void 0,onFilesDrop:Y.addFiles,onImageLinkPaste:Y.addLinkedImage,dropLabel:1===Y.maxFiles?"Drop a file here":"Drop files here",attachmentSlot:w?f.jsx(d,{errorMessage:w}):void 0,toolbar:f.jsxs(f.Fragment,{children:[f.jsx(a.AttachFileButton,{inputRef:Y.fileInputRef,onClick:Y.openFileDialog,onFileSelect:Y.handleFileSelect,onWellhubSelect:U?function(){return ce(!0)}:void 0,multiple:Z,disabled:Y.isFull,tooltip:Y.isFull?"Up to ".concat(Y.maxFiles," ").concat(1===Y.maxFiles?"file":"files"," can be attached"):"Attach ".concat(Z?"files":"file")}),f.jsx(r.Tooltip,{title:"Mention someone",children:f.jsx(c.ButtonIcon,{size:"xs",type:"tertiary",onClick:function(){var e,s=te.current;if(s){s.focus();var o=!!s.value&&!/\s$/.test(s.value),n="".concat(s.value).concat(o?" @":"@"),i=null===(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(s),"value"))||void 0===e?void 0:e.set;null==i||i.call(s,n),s.setSelectionRange(n.length,n.length),s.dispatchEvent(new Event("input",{bubbles:!0})),s.dispatchEvent(new Event("keyup",{bubbles:!0}))}},children:f.jsx(x.default,{fontSize:"inherit"})})}),f.jsx("span",{className:g.iconSlot,children:f.jsx(m,{icon:f.jsx(t.SmilingFaceIcon,{size:16}),handleSelectEmoji:function(e){return i("".concat(s).concat(e.native))}})})]}),footer:(!(null==W||!W.length)||!!_)&&f.jsxs(f.Fragment,{children:[f.jsx(I.CommentMetaLine,{rows:null!=W?W:[],singleLine:G}),_&&f.jsx(b.ShareToChatRow,O({},_))]})}),U&&f.jsx(q.WellhubFilePicker,O(O({},U),{},{open:ie,maxSelectable:Y.maxFiles-Y.count,attachedFileNames:re,onAdd:function(e){ce(!1),Y.addStoredFiles(e.map((function(e){return{fileName:e.fileName}})))},onClose:function(){return ce(!1)}}))]})};
|
|
2
2
|
//# sourceMappingURL=CommentComposer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommentComposer.js","sources":["../../../../src/components/CommentComposer/CommentComposer.tsx"],"sourcesContent":["import {\n CSSProperties,\n FormEventHandler,\n KeyboardEvent,\n ReactNode,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { Input } from '@material-ui/core';\nimport AlternateEmailIcon from '@material-ui/icons/AlternateEmail';\n\nimport { ButtonIcon } from '../../componentsV2/ButtonIcon';\nimport { Tooltip } from '../../componentsV2/Tooltip';\nimport { SmilingFaceIcon } from '../../icons';\nimport Avatar from '../Avatar';\nimport { AttachFileButton } from '../AttachFileButton';\nimport { CommentInput } from '../CommentInputNext/CommentInputNext';\nimport EmojiIconButton from '../EmojiIconButton';\nimport FailedFileUploading from '../FailedFileUploading';\nimport UserMention from '../UserMention';\nimport { isSuggestionsListOpened } from '../UserMention/utils';\nimport { WellhubFilePicker } from '../WellhubFilePicker';\nimport type { WellhubContext, WellhubFile } from '../WellhubFilePicker';\n\nimport {\n useAttachmentUpload,\n UploadedAttachment,\n DEFAULT_MAX_ATTACHMENTS,\n} from './useAttachmentUpload';\nimport { CommentMetaLine, CommentMetaRow } from './CommentMetaLine';\nimport { ShareToChatRow, ShareToChatRowProps } from './ShareToChatRow';\n\nimport styles from './CommentComposer.scss';\n\n/* eslint-disable camelcase -- mirrors the platform's snake_case user payload. */\nexport type CommentComposerUser = {\n id?: number;\n company_id?: number;\n first_name?: string;\n last_name?: string;\n profile_photo?: string;\n [key: string]: unknown;\n};\n/* eslint-enable camelcase */\n\nexport type CommentComposerTrailingState = {\n canSend: boolean;\n submit: () => void;\n};\n\nexport type CommentComposerProps = {\n body: string;\n onBodyChange: (value: string) => void;\n onSubmit: () => void;\n canSubmit: boolean;\n currentUser: CommentComposerUser;\n\n attachments?: UploadedAttachment[];\n onAttachmentsChange?: (attachments: UploadedAttachment[]) => void;\n maxAttachments?: number;\n /** @deprecated Use `attachments` — kept so single-attachment callers keep working. */\n attachment?: UploadedAttachment | null;\n /** @deprecated Use `onAttachmentsChange`. */\n onAttachmentChange?: (attachment: UploadedAttachment | null) => void;\n attachmentError?: string | null;\n onAttachmentError?: (message: string | null) => void;\n maxAttachmentSizeBytes?: number;\n wellhubContext?: WellhubContext;\n\n disabled?: boolean;\n autoFocus?: boolean;\n placeholder?: string;\n metaRows?: CommentMetaRow[];\n isMetaSingleLine?: boolean;\n shareToChat?: Omit<ShareToChatRowProps, 'testId'>;\n /** Replaces the default send button, e.g. the edit form's Cancel/Save. */\n trailing?: ReactNode;\n /** Like `trailing`, but receives the upload-aware send state for a custom Save. */\n renderTrailing?: (state: CommentComposerTrailingState) => ReactNode;\n /** Render flush inside a host card instead of as its own surface. */\n embedded?: boolean;\n className?: string;\n testId?: string;\n};\n\nconst SUGGESTIONS_BACKGROUND = 'var(--palette-background-b-9)';\n\n// Module-level so react-mentions isn't re-rendered on every keystroke.\nconst MENTION_INPUT_STYLE = {\n fontSize: 14,\n lineHeight: '20px',\n suggestions: {\n backgroundColor: SUGGESTIONS_BACKGROUND,\n list: { backgroundColor: SUGGESTIONS_BACKGROUND },\n item: {\n color: 'var(--palette-primary-text-1)',\n '&focused': { backgroundColor: 'rgb(from var(--palette-primary-text-1) r g b / 0.08)' },\n },\n },\n} as unknown as CSSProperties;\n\nconst renderSuggestion = (entry: { display: string; photo?: string }) => (\n <div className={styles.suggestion}>\n <Avatar size={26} alt={entry.display} imgSrc={entry.photo} displayName={entry.display} />\n <span>{entry.display}</span>\n </div>\n);\n\nexport const CommentComposer = ({\n body,\n onBodyChange,\n onSubmit,\n canSubmit,\n currentUser,\n attachments,\n onAttachmentsChange,\n maxAttachments = DEFAULT_MAX_ATTACHMENTS,\n attachment,\n onAttachmentChange,\n attachmentError,\n onAttachmentError,\n maxAttachmentSizeBytes,\n wellhubContext,\n disabled,\n autoFocus,\n placeholder = 'Add a comment...',\n metaRows,\n isMetaSingleLine,\n shareToChat,\n trailing,\n renderTrailing,\n embedded,\n className,\n testId,\n}: CommentComposerProps) => {\n // Callers still on the singular props get the old one-file behaviour, unchanged.\n const isMulti = !!onAttachmentsChange;\n const value = useMemo(\n () => (isMulti ? attachments ?? [] : ([attachment].filter(Boolean) as UploadedAttachment[])),\n [isMulti, attachments, attachment]\n );\n\n const handleAttachmentsChange = useCallback(\n (next: UploadedAttachment[]) => {\n if (onAttachmentsChange) onAttachmentsChange(next);\n else onAttachmentChange?.(next[0] ?? null);\n },\n [onAttachmentsChange, onAttachmentChange]\n );\n\n const upload = useAttachmentUpload({\n value,\n onChange: handleAttachmentsChange,\n onError: onAttachmentError,\n maxSizeBytes: maxAttachmentSizeBytes,\n maxFiles: isMulti ? maxAttachments : 1,\n });\n\n // An attachment only lands once S3 confirms, so posting mid-upload would drop it.\n const canSend = canSubmit && !upload.isUploading;\n\n const submit = () => {\n if (!canSend || disabled) return;\n\n onSubmit();\n };\n\n const [isWellhubOpen, setIsWellhubOpen] = useState(false);\n const attachedKeys = useMemo(() => value.map(item => item.name), [value]);\n\n const addWellhubFiles = (files: WellhubFile[]) => {\n setIsWellhubOpen(false);\n upload.addStoredFiles(files.map(file => ({ fileName: file.fileName })));\n };\n\n const fieldRef = useRef<HTMLTextAreaElement | null>(null);\n\n // react-mentions opens suggestions from textarea events, so type \"@\" instead of setting state.\n const mentionSomeone = () => {\n const field = fieldRef.current;\n if (!field) return;\n\n field.focus();\n\n const needsSpace = !!field.value && !/\\s$/.test(field.value);\n const nextValue = `${field.value}${needsSpace ? ' @' : '@'}`;\n const setValue = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(field), 'value')?.set;\n\n setValue?.call(field, nextValue);\n field.setSelectionRange(nextValue.length, nextValue.length);\n field.dispatchEvent(new Event('input', { bubbles: true }));\n field.dispatchEvent(new Event('keyup', { bubbles: true }));\n };\n\n const handleEnterKey = (event: KeyboardEvent) => {\n if (event.key !== 'Enter' || event.shiftKey) return;\n if (!canSend || disabled) return;\n if (isSuggestionsListOpened()) return;\n\n event.preventDefault();\n submit();\n };\n\n return (\n <>\n <CommentInput\n value={body}\n canSubmit={canSend}\n disabled={disabled}\n onSubmit={onSubmit}\n trailing={\n renderTrailing ? renderTrailing({ canSend: canSend && !disabled, submit }) : trailing\n }\n embedded={embedded}\n className={className}\n testId={testId}\n field={\n <Input\n inputComponent={UserMention}\n inputProps={{\n // UserMention calls onChange with the text string, not a DOM event.\n onChange: onBodyChange as unknown as FormEventHandler<HTMLInputElement>,\n currentUser,\n allowEmptyQuery: true,\n suggestionsPortalHost: document.querySelector('body'),\n withLightTheme: false,\n mentionProps: { renderSuggestion },\n highlightLinks: true,\n style: MENTION_INPUT_STYLE,\n }}\n value={body}\n placeholder={placeholder}\n inputRef={fieldRef}\n className={styles.mentionField}\n onKeyDown={handleEnterKey}\n disableUnderline\n rows={1}\n fullWidth\n multiline\n autoFocus={autoFocus}\n />\n }\n attachments={upload.items}\n onAttachmentRemove={upload.removeAttachment}\n onAttachmentRetry={upload.handleRetry}\n onAttachmentReorder={isMulti ? upload.reorderAttachments : undefined}\n onFilesDrop={upload.addFiles}\n onImageLinkPaste={upload.addLinkedImage}\n dropLabel={upload.maxFiles === 1 ? 'Drop a file here' : 'Drop files here'}\n attachmentSlot={\n attachmentError ? <FailedFileUploading errorMessage={attachmentError} /> : undefined\n }\n toolbar={\n <>\n <AttachFileButton\n inputRef={upload.fileInputRef}\n onClick={upload.openFileDialog}\n onFileSelect={upload.handleFileSelect}\n onWellhubSelect={wellhubContext ? () => setIsWellhubOpen(true) : undefined}\n multiple={isMulti}\n disabled={upload.isFull}\n tooltip={\n upload.isFull\n ? `Up to ${upload.maxFiles} ${\n upload.maxFiles === 1 ? 'file' : 'files'\n } can be attached`\n : `Attach ${isMulti ? 'files' : 'file'}`\n }\n />\n <Tooltip title=\"Mention someone\">\n <ButtonIcon size=\"xs\" type=\"tertiary\" onClick={mentionSomeone}>\n <AlternateEmailIcon fontSize=\"inherit\" />\n </ButtonIcon>\n </Tooltip>\n <span className={styles.iconSlot}>\n <EmojiIconButton\n icon={<SmilingFaceIcon size={16} />}\n handleSelectEmoji={(emoji: { native: string }) =>\n onBodyChange(`${body}${emoji.native}`)\n }\n />\n </span>\n </>\n }\n footer={\n (!!metaRows?.length || !!shareToChat) && (\n <>\n <CommentMetaLine rows={metaRows ?? []} singleLine={isMetaSingleLine} />\n {shareToChat && <ShareToChatRow {...shareToChat} />}\n </>\n )\n }\n />\n\n {wellhubContext && (\n <WellhubFilePicker\n {...wellhubContext}\n open={isWellhubOpen}\n maxSelectable={upload.maxFiles - upload.count}\n attachedFileNames={attachedKeys}\n onAdd={addWellhubFiles}\n onClose={() => setIsWellhubOpen(false)}\n />\n )}\n </>\n );\n};\n"],"names":["MENTION_INPUT_STYLE","fontSize","lineHeight","suggestions","backgroundColor","list","item","color","renderSuggestion","entry","_jsxs","className","styles","suggestion","children","_jsx","Avatar","size","alt","display","imgSrc","photo","displayName","jsx","_ref","body","onBodyChange","onSubmit","canSubmit","currentUser","attachments","onAttachmentsChange","_ref$maxAttachments","maxAttachments","DEFAULT_MAX_ATTACHMENTS","attachment","onAttachmentChange","attachmentError","onAttachmentError","maxAttachmentSizeBytes","wellhubContext","disabled","autoFocus","_ref$placeholder","placeholder","metaRows","isMetaSingleLine","shareToChat","trailing","renderTrailing","embedded","testId","isMulti","value","useMemo","filter","Boolean","handleAttachmentsChange","useCallback","next","_next$","upload","useAttachmentUpload","onChange","onError","maxSizeBytes","maxFiles","canSend","isUploading","submit","useState","_useState2","_slicedToArray","_useState","isWellhubOpen","setIsWellhubOpen","attachedKeys","map","name","fieldRef","useRef","_Fragment","CommentInput","field","Input","inputComponent","UserMention","inputProps","allowEmptyQuery","suggestionsPortalHost","document","querySelector","withLightTheme","mentionProps","highlightLinks","style","inputRef","mentionField","onKeyDown","event","key","shiftKey","isSuggestionsListOpened","preventDefault","disableUnderline","rows","fullWidth","multiline","items","onAttachmentRemove","removeAttachment","onAttachmentRetry","handleRetry","onAttachmentReorder","reorderAttachments","undefined","onFilesDrop","addFiles","onImageLinkPaste","addLinkedImage","dropLabel","attachmentSlot","FailedFileUploading","errorMessage","toolbar","jsxs","AttachFileButton","fileInputRef","onClick","openFileDialog","onFileSelect","handleFileSelect","onWellhubSelect","multiple","isFull","tooltip","concat","Tooltip","title","ButtonIcon","type","_Object$getOwnPropert","current","focus","needsSpace","test","nextValue","setValue","Object","getOwnPropertyDescriptor","getPrototypeOf","set","call","setSelectionRange","length","dispatchEvent","Event","bubbles","AlternateEmailIcon","iconSlot","EmojiIconButton","icon","SmilingFaceIcon","handleSelectEmoji","emoji","native","footer","CommentMetaLine","singleLine","ShareToChatRow","_objectSpread","WellhubFilePicker","open","maxSelectable","count","attachedFileNames","onAdd","files","addStoredFiles","file","fileName","onClose"],"mappings":"4oMAuFA,IAGMA,EAAsB,CAC1BC,SAAU,GACVC,WAAY,OACZC,YAAa,CACXC,gBAP2B,gCAQ3BC,KAAM,CAAED,gBARmB,iCAS3BE,KAAM,CACJC,MAAO,gCACP,WAAY,CAAEH,gBAAiB,2DAK/BI,EAAmB,SAACC,GAA0C,OAClEC,EAAAA,KAAA,MAAA,CAAKC,UAAWC,EAAOC,WAAWC,SAAA,CAChCC,MAACC,kBAAM,CAACC,KAAM,GAAIC,IAAKT,EAAMU,QAASC,O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GAAehC,MAAC0J,EAAAA,eAAcC,EAAA,CAAA,EAAK3H,SAM3CP,GACCzB,EAACQ,IAAAoJ,2BACKnI,GAAc,GAAA,CAClBoI,KAAMlG,GACNmG,cAAehH,EAAOK,SAAWL,EAAOiH,MACxCC,kBAAmBnG,GACnBoG,MAlIgB,SAACC,GACvBtG,IAAiB,GACjBd,EAAOqH,eAAeD,EAAMpG,KAAI,SAAAsG,GAAI,MAAK,CAAEC,SAAUD,EAAKC,SAAW,MAiI/DC,QAAS,WAAA,OAAM1G,IAAiB,EAAM,OAKhD"}
|
|
1
|
+
{"version":3,"file":"CommentComposer.js","sources":["../../../../src/components/CommentComposer/CommentComposer.tsx"],"sourcesContent":["import {\n CSSProperties,\n FormEventHandler,\n KeyboardEvent,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { Input } from '@material-ui/core';\nimport AlternateEmailIcon from '@material-ui/icons/AlternateEmail';\n\nimport { ButtonIcon } from '../../componentsV2/ButtonIcon';\nimport { Tooltip } from '../../componentsV2/Tooltip';\nimport { SmilingFaceIcon } from '../../icons';\nimport Avatar from '../Avatar';\nimport { AttachFileButton } from '../AttachFileButton';\nimport { CommentInput } from '../CommentInputNext/CommentInputNext';\nimport EmojiIconButton from '../EmojiIconButton';\nimport FailedFileUploading from '../FailedFileUploading';\nimport UserMention from '../UserMention';\nimport { isSuggestionsListOpened } from '../UserMention/utils';\nimport { WellhubFilePicker } from '../WellhubFilePicker';\nimport type { WellhubContext, WellhubFile } from '../WellhubFilePicker';\n\nimport {\n useAttachmentUpload,\n UploadedAttachment,\n DEFAULT_MAX_ATTACHMENTS,\n} from './useAttachmentUpload';\nimport { CommentMetaLine, CommentMetaRow } from './CommentMetaLine';\nimport { ShareToChatRow, ShareToChatRowProps } from './ShareToChatRow';\n\nimport styles from './CommentComposer.scss';\n\n/* eslint-disable camelcase -- mirrors the platform's snake_case user payload. */\nexport type CommentComposerUser = {\n id?: number;\n company_id?: number;\n first_name?: string;\n last_name?: string;\n profile_photo?: string;\n [key: string]: unknown;\n};\n/* eslint-enable camelcase */\n\nexport type CommentComposerTrailingState = {\n canSend: boolean;\n submit: () => void;\n};\n\nexport type CommentComposerProps = {\n body: string;\n onBodyChange: (value: string) => void;\n onSubmit: () => void;\n canSubmit: boolean;\n currentUser: CommentComposerUser;\n\n attachments?: UploadedAttachment[];\n onAttachmentsChange?: (attachments: UploadedAttachment[]) => void;\n maxAttachments?: number;\n /** @deprecated Use `attachments` — kept so single-attachment callers keep working. */\n attachment?: UploadedAttachment | null;\n /** @deprecated Use `onAttachmentsChange`. */\n onAttachmentChange?: (attachment: UploadedAttachment | null) => void;\n attachmentError?: string | null;\n onAttachmentError?: (message: string | null) => void;\n maxAttachmentSizeBytes?: number;\n wellhubContext?: WellhubContext;\n\n disabled?: boolean;\n autoFocus?: boolean;\n placeholder?: string;\n metaRows?: CommentMetaRow[];\n isMetaSingleLine?: boolean;\n shareToChat?: Omit<ShareToChatRowProps, 'testId'>;\n /** Replaces the default send button, e.g. the edit form's Cancel/Save. */\n trailing?: ReactNode;\n /** Like `trailing`, but receives the upload-aware send state for a custom Save. */\n renderTrailing?: (state: CommentComposerTrailingState) => ReactNode;\n /** Render flush inside a host card instead of as its own surface. */\n embedded?: boolean;\n className?: string;\n testId?: string;\n};\n\nconst SUGGESTIONS_BACKGROUND = 'var(--palette-background-b-9)';\n\n// Module-level so react-mentions isn't re-rendered on every keystroke.\nconst MENTION_INPUT_STYLE = {\n fontSize: 14,\n lineHeight: '20px',\n suggestions: {\n backgroundColor: SUGGESTIONS_BACKGROUND,\n list: { backgroundColor: SUGGESTIONS_BACKGROUND },\n item: {\n color: 'var(--palette-primary-text-1)',\n '&focused': { backgroundColor: 'rgb(from var(--palette-primary-text-1) r g b / 0.08)' },\n },\n },\n} as unknown as CSSProperties;\n\nconst renderSuggestion = (entry: { display: string; photo?: string }) => (\n <div className={styles.suggestion}>\n <Avatar size={26} alt={entry.display} imgSrc={entry.photo} displayName={entry.display} />\n <span>{entry.display}</span>\n </div>\n);\n\nexport const CommentComposer = ({\n body,\n onBodyChange,\n onSubmit,\n canSubmit,\n currentUser,\n attachments,\n onAttachmentsChange,\n maxAttachments = DEFAULT_MAX_ATTACHMENTS,\n attachment,\n onAttachmentChange,\n attachmentError,\n onAttachmentError,\n maxAttachmentSizeBytes,\n wellhubContext,\n disabled,\n autoFocus,\n placeholder = 'Add a comment...',\n metaRows,\n isMetaSingleLine,\n shareToChat,\n trailing,\n renderTrailing,\n embedded,\n className,\n testId,\n}: CommentComposerProps) => {\n // Callers still on the singular props get the old one-file behaviour, unchanged.\n const isMulti = !!onAttachmentsChange;\n const value = useMemo(\n () => (isMulti ? attachments ?? [] : ([attachment].filter(Boolean) as UploadedAttachment[])),\n [isMulti, attachments, attachment]\n );\n\n const handleAttachmentsChange = useCallback(\n (next: UploadedAttachment[]) => {\n if (onAttachmentsChange) onAttachmentsChange(next);\n else onAttachmentChange?.(next[0] ?? null);\n },\n [onAttachmentsChange, onAttachmentChange]\n );\n\n const upload = useAttachmentUpload({\n value,\n onChange: handleAttachmentsChange,\n onError: onAttachmentError,\n maxSizeBytes: maxAttachmentSizeBytes,\n maxFiles: isMulti ? maxAttachments : 1,\n });\n\n // An attachment only lands once S3 confirms, so posting mid-upload would drop it.\n const canSend = canSubmit && !upload.isUploading;\n\n const submit = () => {\n if (!canSend || disabled) return;\n\n onSubmit();\n };\n\n const [isWellhubOpen, setIsWellhubOpen] = useState(false);\n const attachedKeys = useMemo(() => value.map(item => item.name), [value]);\n\n const addWellhubFiles = (files: WellhubFile[]) => {\n setIsWellhubOpen(false);\n upload.addStoredFiles(files.map(file => ({ fileName: file.fileName })));\n };\n\n const fieldRef = useRef<HTMLTextAreaElement | null>(null);\n\n // An autofocused edit form lands the caret at the start; editing usually continues from the end.\n useEffect(() => {\n const field = fieldRef.current;\n if (!autoFocus || !field) return;\n\n field.setSelectionRange(field.value.length, field.value.length);\n }, [autoFocus]);\n\n // react-mentions opens suggestions from textarea events, so type \"@\" instead of setting state.\n const mentionSomeone = () => {\n const field = fieldRef.current;\n if (!field) return;\n\n field.focus();\n\n const needsSpace = !!field.value && !/\\s$/.test(field.value);\n const nextValue = `${field.value}${needsSpace ? ' @' : '@'}`;\n const setValue = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(field), 'value')?.set;\n\n setValue?.call(field, nextValue);\n field.setSelectionRange(nextValue.length, nextValue.length);\n field.dispatchEvent(new Event('input', { bubbles: true }));\n field.dispatchEvent(new Event('keyup', { bubbles: true }));\n };\n\n const handleEnterKey = (event: KeyboardEvent) => {\n if (event.key !== 'Enter' || event.shiftKey) return;\n if (!canSend || disabled) return;\n if (isSuggestionsListOpened()) return;\n\n event.preventDefault();\n submit();\n };\n\n return (\n <>\n <CommentInput\n value={body}\n canSubmit={canSend}\n disabled={disabled}\n onSubmit={onSubmit}\n trailing={\n renderTrailing ? renderTrailing({ canSend: canSend && !disabled, submit }) : trailing\n }\n embedded={embedded}\n className={className}\n testId={testId}\n field={\n <Input\n inputComponent={UserMention}\n inputProps={{\n // UserMention calls onChange with the text string, not a DOM event.\n onChange: onBodyChange as unknown as FormEventHandler<HTMLInputElement>,\n currentUser,\n allowEmptyQuery: true,\n suggestionsPortalHost: document.querySelector('body'),\n withLightTheme: false,\n mentionProps: { renderSuggestion },\n highlightLinks: true,\n style: MENTION_INPUT_STYLE,\n }}\n value={body}\n placeholder={placeholder}\n inputRef={fieldRef}\n className={styles.mentionField}\n onKeyDown={handleEnterKey}\n disableUnderline\n rows={1}\n fullWidth\n multiline\n autoFocus={autoFocus}\n />\n }\n attachments={upload.items}\n onAttachmentRemove={upload.removeAttachment}\n onAttachmentRetry={upload.handleRetry}\n onAttachmentReorder={isMulti ? upload.reorderAttachments : undefined}\n onFilesDrop={upload.addFiles}\n onImageLinkPaste={upload.addLinkedImage}\n dropLabel={upload.maxFiles === 1 ? 'Drop a file here' : 'Drop files here'}\n attachmentSlot={\n attachmentError ? <FailedFileUploading errorMessage={attachmentError} /> : undefined\n }\n toolbar={\n <>\n <AttachFileButton\n inputRef={upload.fileInputRef}\n onClick={upload.openFileDialog}\n onFileSelect={upload.handleFileSelect}\n onWellhubSelect={wellhubContext ? () => setIsWellhubOpen(true) : undefined}\n multiple={isMulti}\n disabled={upload.isFull}\n tooltip={\n upload.isFull\n ? `Up to ${upload.maxFiles} ${\n upload.maxFiles === 1 ? 'file' : 'files'\n } can be attached`\n : `Attach ${isMulti ? 'files' : 'file'}`\n }\n />\n <Tooltip title=\"Mention someone\">\n <ButtonIcon size=\"xs\" type=\"tertiary\" onClick={mentionSomeone}>\n <AlternateEmailIcon fontSize=\"inherit\" />\n </ButtonIcon>\n </Tooltip>\n <span className={styles.iconSlot}>\n <EmojiIconButton\n icon={<SmilingFaceIcon size={16} />}\n handleSelectEmoji={(emoji: { native: string }) =>\n onBodyChange(`${body}${emoji.native}`)\n }\n />\n </span>\n </>\n }\n footer={\n (!!metaRows?.length || !!shareToChat) && (\n <>\n <CommentMetaLine rows={metaRows ?? []} singleLine={isMetaSingleLine} />\n {shareToChat && <ShareToChatRow {...shareToChat} />}\n </>\n )\n }\n />\n\n {wellhubContext && (\n <WellhubFilePicker\n {...wellhubContext}\n open={isWellhubOpen}\n maxSelectable={upload.maxFiles - upload.count}\n attachedFileNames={attachedKeys}\n onAdd={addWellhubFiles}\n onClose={() => setIsWellhubOpen(false)}\n />\n )}\n </>\n );\n};\n"],"names":["MENTION_INPUT_STYLE","fontSize","lineHeight","suggestions","backgroundColor","list","item","color","renderSuggestion","entry","_jsxs","className","styles","suggestion","children","_jsx","Avatar","size","alt","display","imgSrc","photo","displayName","jsx","_ref","body","onBodyChange","onSubmit","canSubmit","currentUser","attachments","onAttachmentsChange","_ref$maxAttachments","maxAttachments","DEFAULT_MAX_ATTACHMENTS","attachment","onAttachmentChange","attachmentError","onAttachmentError","maxAttachmentSizeBytes","wellhubContext","disabled","autoFocus","_ref$placeholder","placeholder","metaRows","isMetaSingleLine","shareToChat","trailing","renderTrailing","embedded","testId","isMulti","value","useMemo","filter","Boolean","handleAttachmentsChange","useCallback","next","_next$","upload","useAttachmentUpload","onChange","onError","maxSizeBytes","maxFiles","canSend","isUploading","submit","useState","_useState2","_slicedToArray","_useState","isWellhubOpen","setIsWellhubOpen","attachedKeys","map","name","fieldRef","useRef","useEffect","field","current","setSelectionRange","length","_Fragment","CommentInput","Input","inputComponent","UserMention","inputProps","allowEmptyQuery","suggestionsPortalHost","document","querySelector","withLightTheme","mentionProps","highlightLinks","style","inputRef","mentionField","onKeyDown","event","key","shiftKey","isSuggestionsListOpened","preventDefault","disableUnderline","rows","fullWidth","multiline","items","onAttachmentRemove","removeAttachment","onAttachmentRetry","handleRetry","onAttachmentReorder","reorderAttachments","undefined","onFilesDrop","addFiles","onImageLinkPaste","addLinkedImage","dropLabel","attachmentSlot","FailedFileUploading","errorMessage","toolbar","jsxs","AttachFileButton","fileInputRef","onClick","openFileDialog","onFileSelect","handleFileSelect","onWellhubSelect","multiple","isFull","tooltip","concat","Tooltip","title","ButtonIcon","type","_Object$getOwnPropert","focus","needsSpace","test","nextValue","setValue","Object","getOwnPropertyDescriptor","getPrototypeOf","set","call","dispatchEvent","Event","bubbles","AlternateEmailIcon","iconSlot","EmojiIconButton","icon","SmilingFaceIcon","handleSelectEmoji","emoji","native","footer","CommentMetaLine","singleLine","ShareToChatRow","_objectSpread","WellhubFilePicker","open","maxSelectable","count","attachedFileNames","onAdd","files","addStoredFiles","file","fileName","onClose"],"mappings":"4oMAwFA,IAGMA,EAAsB,CAC1BC,SAAU,GACVC,WAAY,OACZC,YAAa,CACXC,gBAP2B,gCAQ3BC,KAAM,CAAED,gBARmB,iCAS3BE,KAAM,CACJC,MAAO,gCACP,WAAY,CAAEH,gBAAiB,2DAK/BI,EAAmB,SAACC,GAA0C,OAClEC,EAAAA,KAAA,MAAA,CAAKC,UAAWC,EAAOC,WAAWC,SAAA,CAChCC,MAACC,kBAAM,CAACC,KAAM,GAAIC,IAAKT,E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K1H,UAAAA,EAAUwC,WAAYtC,IACvBrC,EAAAA,KAAA4E,EAAAA,SAAA,CAAAxE,SAAA,CACEC,MAACyJ,kBAAe,CAAC3D,KAAMhE,QAAAA,EAAY,GAAI4H,WAAY3H,IAClDC,GAAehC,MAAC2J,EAAAA,eAAcC,EAAA,CAAA,EAAK5H,SAM3CP,GACCzB,EAACQ,IAAAqJ,2BACKpI,GAAc,GAAA,CAClBqI,KAAMnG,GACNoG,cAAejH,EAAOK,SAAWL,EAAOkH,MACxCC,kBAAmBpG,GACnBqG,MA1IgB,SAACC,GACvBvG,IAAiB,GACjBd,EAAOsH,eAAeD,EAAMrG,KAAI,SAAAuG,GAAI,MAAK,CAAEC,SAAUD,EAAKC,SAAW,MAyI/DC,QAAS,WAAA,OAAM3G,IAAiB,EAAM,OAKhD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommentComposer.d.ts","sourceRoot":"","sources":["../../../src/components/CommentComposer/CommentComposer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,
|
|
1
|
+
{"version":3,"file":"CommentComposer.d.ts","sourceRoot":"","sources":["../../../src/components/CommentComposer/CommentComposer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EAMV,MAAM,OAAO,CAAC;AAef,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAEL,kBAAkB,EAEnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAmB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAkB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAKvE,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;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AC;IACrB,mFAAmF;IACnF,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,4BAA4B,KAAK,SAAS,CAAC;IACpE,qEAAqE;IACrE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAyBF,eAAO,MAAM,eAAe,8VA0BzB,oBAAoB,4CAoLtB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import o from"@babel/runtime/helpers/defineProperty";import s from"@babel/runtime/helpers/slicedToArray";import{useMemo as n,useCallback as t,useState as i,useRef as c}from"react";import{Input as
|
|
1
|
+
import o from"@babel/runtime/helpers/defineProperty";import s from"@babel/runtime/helpers/slicedToArray";import{useMemo as n,useCallback as t,useState as i,useRef as c,useEffect as e}from"react";import{Input as r}from"@material-ui/core";import m from"@material-ui/icons/AlternateEmail";import{ButtonIcon as a}from"../../componentsV2/ButtonIcon/ButtonIcon.js";import{Tooltip as l}from"../../componentsV2/Tooltip/Tooltip.js";import{SmilingFaceIcon as p}from"../../icons/iconParkIcons.js";import"../../icons/customIcons/icons/AddMessage.js";import"../../icons/customIcons/icons/DragOne.js";import"../../icons/customIcons/icons/Attention.js";import"../../icons/customIcons/icons/Collapse.js";import"../../icons/customIcons/icons/Dashboard.js";import"../../icons/customIcons/icons/Expand.js";import"../../icons/customIcons/icons/FolderClosed.js";import"../../icons/customIcons/icons/FolderClosedFilled.js";import"../../icons/customIcons/icons/FolderOpened.js";import"../../icons/customIcons/icons/GreaterOrEqual.js";import"../../icons/customIcons/icons/LessOrEqual.js";import"../../icons/customIcons/icons/Search.js";import"../../icons/customIcons/icons/SearchOne.js";import"../../icons/customIcons/icons/Wellhub.js";import"../../icons/customIcons/icons/MultiRuler.js";import"../../icons/customIcons/icons/Checkbox.js";import"../../icons/customIcons/icons/CheckboxChecked.js";import"../../icons/customIcons/icons/CheckboxIndeterminate.js";import"../../icons/customIcons/icons/Radio.js";import"../../icons/customIcons/icons/RadioChecked.js";import"../../icons/customIcons/icons/SimulFrac.js";import"../../icons/customIcons/icons/ZipperFrac.js";import"../../icons/customIcons/icons/CautionFilled.js";import"../../icons/customIcons/icons/InfoRounded.js";import"../../icons/customIcons/icons/FlameFilled.js";import"../../icons/customIcons/icons/MoreApp.js";import"../../icons/customIcons/icons/Pad.js";import"../../icons/customIcons/icons/DrilloutUnit.js";import"../../icons/customIcons/icons/FracFleet.js";import"../../icons/customIcons/icons/Global.js";import"../../icons/customIcons/icons/Program.js";import"../../icons/customIcons/icons/Rig.js";import"../../icons/customIcons/icons/Well.js";import"../../icons/customIcons/icons/Gap.js";import"../../icons/customIcons/icons/Pin.js";import"../../icons/customIcons/icons/PinOne.js";import"../../icons/customIcons/icons/PinOneCrossed.js";import"../../icons/customIcons/icons/CloseOneFilled.js";import"../../icons/customIcons/icons/AttentionFilled.js";import"../../icons/customIcons/icons/CheckOneFilled.js";import"../../icons/customIcons/icons/Archive.js";import"../../icons/customIcons/icons/ArchiveCancel.js";import"../../icons/customIcons/icons/Unarchive.js";import"../../icons/customIcons/icons/Archived.js";import"../../icons/customIcons/icons/InterventionUnit.js";import"../../icons/customIcons/icons/CloudDelete.js";import"../../icons/customIcons/icons/Lasso.js";import"../../icons/customIcons/icons/Radius.js";import"../../icons/customIcons/icons/ErrorOps.js";import"../../icons/customIcons/icons/DataTypeOps.js";import"../../icons/customIcons/icons/FalsePositiveOps.js";import"../../icons/customIcons/icons/CalibrationOps.js";import"../../icons/customIcons/icons/CriticalOps.js";import"../../icons/customIcons/icons/Company.js";import"../../icons/customIcons/icons/ArchiveOne.js";import"../../icons/customIcons/icons/ParseBotFusion.js";import"../../icons/customIcons/icons/Connect.js";import"../../icons/customIcons/icons/PuzzleOne.js";import"../../icons/customIcons/icons/Feed.js";import"../../icons/customIcons/icons/Prompt.js";import"../../icons/customIcons/icons/Companies.js";import"../../icons/customIcons/icons/ClipboardAi.js";import"../../icons/customIcons/icons/Key.js";import"../../icons/customIcons/icons/AtSignCrossed.js";import"../../icons/customIcons/icons/MappingManual.js";import"../../icons/customIcons/icons/Mapping.js";import"../../icons/customIcons/icons/Metrics.js";import"../../icons/customIcons/icons/Drops.js";import"../../icons/customIcons/icons/ClipboardSearch.js";import"../../icons/customIcons/icons/Template.js";import"../../icons/customIcons/icons/ClipboardMetrics.js";import"../../icons/customIcons/icons/ClipboardBuilder.js";import"../../icons/customIcons/icons/UnitConversion.js";import"../../icons/customIcons/icons/NPT.js";import"../../icons/customIcons/icons/GuidedFrac.js";import{AvatarComponent as u}from"../Avatar/index.js";import{AttachFileButton as d}from"../AttachFileButton/AttachFileButton.js";import{CommentInput as j}from"../CommentInputNext/CommentInputNext.js";import h from"../EmojiIconButton.js";import I from"../FailedFileUploading.js";import b from"../UserMention/index.js";import{isSuggestionsListOpened as f}from"../UserMention/utils/index.js";import{WellhubFilePicker as g}from"../WellhubFilePicker/WellhubFilePicker.js";import"@babel/runtime/helpers/toConsumableArray";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/regenerator";import"lodash/set";import"lodash/get";import"lodash/unset";import"moment";import"../../clients/jsonApi/index.js";import"../../clients/subscriptions/subscriptions-client.factory.js";import"../../clients/api/apiCore.js";import"../../clients/constants.js";import"../../clients/sso/auth0.js";import"../../clients/sso/oauth2.js";import"../../clients/api/rateLimiter.js";import"uuid";import{useAttachmentUpload as v,DEFAULT_MAX_ATTACHMENTS as C}from"./useAttachmentUpload.js";import{CommentMetaLine as y}from"./CommentMetaLine.js";import{ShareToChatRow as F}from"./ShareToChatRow.js";import O from"./CommentComposer.scss.js";import{jsxs as A,Fragment as S,jsx as P}from"react/jsx-runtime";function x(o,s){var n=Object.keys(o);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);s&&(t=t.filter((function(s){return Object.getOwnPropertyDescriptor(o,s).enumerable}))),n.push.apply(n,t)}return n}function k(s){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?x(Object(t),!0).forEach((function(n){o(s,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):x(Object(t)).forEach((function(o){Object.defineProperty(s,o,Object.getOwnPropertyDescriptor(t,o))}))}return s}var E={fontSize:14,lineHeight:"20px",suggestions:{backgroundColor:"var(--palette-background-b-9)",list:{backgroundColor:"var(--palette-background-b-9)"},item:{color:"var(--palette-primary-text-1)","&focused":{backgroundColor:"rgb(from var(--palette-primary-text-1) r g b / 0.08)"}}}},w=function(o){return A("div",{className:O.suggestion,children:[P(u,{size:26,alt:o.display,imgSrc:o.photo,displayName:o.display}),P("span",{children:o.display})]})},D=function(o){var u=o.body,x=o.onBodyChange,D=o.onSubmit,R=o.canSubmit,M=o.currentUser,U=o.attachments,N=o.onAttachmentsChange,B=o.maxAttachments,L=void 0===B?C:B,T=o.attachment,z=o.onAttachmentChange,W=o.attachmentError,G=o.onAttachmentError,q=o.maxAttachmentSizeBytes,K=o.wellhubContext,H=o.disabled,V=o.autoFocus,Q=o.placeholder,Z=void 0===Q?"Add a comment...":Q,$=o.metaRows,J=o.isMetaSingleLine,X=o.shareToChat,Y=o.trailing,_=o.renderTrailing,oo=o.embedded,so=o.className,no=o.testId,to=!!N,io=n((function(){return to?null!=U?U:[]:[T].filter(Boolean)}),[to,U,T]),co=t((function(o){var s;N?N(o):null==z||z(null!==(s=o[0])&&void 0!==s?s:null)}),[N,z]),eo=v({value:io,onChange:co,onError:G,maxSizeBytes:q,maxFiles:to?L:1}),ro=R&&!eo.isUploading,mo=function(){ro&&!H&&D()},ao=i(!1),lo=s(ao,2),po=lo[0],uo=lo[1],jo=n((function(){return io.map((function(o){return o.name}))}),[io]),ho=c(null);e((function(){var o=ho.current;V&&o&&o.setSelectionRange(o.value.length,o.value.length)}),[V]);return A(S,{children:[P(j,{value:u,canSubmit:ro,disabled:H,onSubmit:D,trailing:_?_({canSend:ro&&!H,submit:mo}):Y,embedded:oo,className:so,testId:no,field:P(r,{inputComponent:b,inputProps:{onChange:x,currentUser:M,allowEmptyQuery:!0,suggestionsPortalHost:document.querySelector("body"),withLightTheme:!1,mentionProps:{renderSuggestion:w},highlightLinks:!0,style:E},value:u,placeholder:Z,inputRef:ho,className:O.mentionField,onKeyDown:function(o){"Enter"!==o.key||o.shiftKey||ro&&!H&&(f()||(o.preventDefault(),mo()))},disableUnderline:!0,rows:1,fullWidth:!0,multiline:!0,autoFocus:V}),attachments:eo.items,onAttachmentRemove:eo.removeAttachment,onAttachmentRetry:eo.handleRetry,onAttachmentReorder:to?eo.reorderAttachments:void 0,onFilesDrop:eo.addFiles,onImageLinkPaste:eo.addLinkedImage,dropLabel:1===eo.maxFiles?"Drop a file here":"Drop files here",attachmentSlot:W?P(I,{errorMessage:W}):void 0,toolbar:A(S,{children:[P(d,{inputRef:eo.fileInputRef,onClick:eo.openFileDialog,onFileSelect:eo.handleFileSelect,onWellhubSelect:K?function(){return uo(!0)}:void 0,multiple:to,disabled:eo.isFull,tooltip:eo.isFull?"Up to ".concat(eo.maxFiles," ").concat(1===eo.maxFiles?"file":"files"," can be attached"):"Attach ".concat(to?"files":"file")}),P(l,{title:"Mention someone",children:P(a,{size:"xs",type:"tertiary",onClick:function(){var o,s=ho.current;if(s){s.focus();var n=!!s.value&&!/\s$/.test(s.value),t="".concat(s.value).concat(n?" @":"@"),i=null===(o=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(s),"value"))||void 0===o?void 0:o.set;null==i||i.call(s,t),s.setSelectionRange(t.length,t.length),s.dispatchEvent(new Event("input",{bubbles:!0})),s.dispatchEvent(new Event("keyup",{bubbles:!0}))}},children:P(m,{fontSize:"inherit"})})}),P("span",{className:O.iconSlot,children:P(h,{icon:P(p,{size:16}),handleSelectEmoji:function(o){return x("".concat(u).concat(o.native))}})})]}),footer:(!(null==$||!$.length)||!!X)&&A(S,{children:[P(y,{rows:null!=$?$:[],singleLine:J}),X&&P(F,k({},X))]})}),K&&P(g,k(k({},K),{},{open:po,maxSelectable:eo.maxFiles-eo.count,attachedFileNames:jo,onAdd:function(o){uo(!1),eo.addStoredFiles(o.map((function(o){return{fileName:o.fileName}})))},onClose:function(){return uo(!1)}}))]})};export{D as CommentComposer};
|
|
2
2
|
//# sourceMappingURL=CommentComposer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommentComposer.js","sources":["../../../src/components/CommentComposer/CommentComposer.tsx"],"sourcesContent":["import {\n CSSProperties,\n FormEventHandler,\n KeyboardEvent,\n ReactNode,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { Input } from '@material-ui/core';\nimport AlternateEmailIcon from '@material-ui/icons/AlternateEmail';\n\nimport { ButtonIcon } from '../../componentsV2/ButtonIcon';\nimport { Tooltip } from '../../componentsV2/Tooltip';\nimport { SmilingFaceIcon } from '../../icons';\nimport Avatar from '../Avatar';\nimport { AttachFileButton } from '../AttachFileButton';\nimport { CommentInput } from '../CommentInputNext/CommentInputNext';\nimport EmojiIconButton from '../EmojiIconButton';\nimport FailedFileUploading from '../FailedFileUploading';\nimport UserMention from '../UserMention';\nimport { isSuggestionsListOpened } from '../UserMention/utils';\nimport { WellhubFilePicker } from '../WellhubFilePicker';\nimport type { WellhubContext, WellhubFile } from '../WellhubFilePicker';\n\nimport {\n useAttachmentUpload,\n UploadedAttachment,\n DEFAULT_MAX_ATTACHMENTS,\n} from './useAttachmentUpload';\nimport { CommentMetaLine, CommentMetaRow } from './CommentMetaLine';\nimport { ShareToChatRow, ShareToChatRowProps } from './ShareToChatRow';\n\nimport styles from './CommentComposer.scss';\n\n/* eslint-disable camelcase -- mirrors the platform's snake_case user payload. */\nexport type CommentComposerUser = {\n id?: number;\n company_id?: number;\n first_name?: string;\n last_name?: string;\n profile_photo?: string;\n [key: string]: unknown;\n};\n/* eslint-enable camelcase */\n\nexport type CommentComposerTrailingState = {\n canSend: boolean;\n submit: () => void;\n};\n\nexport type CommentComposerProps = {\n body: string;\n onBodyChange: (value: string) => void;\n onSubmit: () => void;\n canSubmit: boolean;\n currentUser: CommentComposerUser;\n\n attachments?: UploadedAttachment[];\n onAttachmentsChange?: (attachments: UploadedAttachment[]) => void;\n maxAttachments?: number;\n /** @deprecated Use `attachments` — kept so single-attachment callers keep working. */\n attachment?: UploadedAttachment | null;\n /** @deprecated Use `onAttachmentsChange`. */\n onAttachmentChange?: (attachment: UploadedAttachment | null) => void;\n attachmentError?: string | null;\n onAttachmentError?: (message: string | null) => void;\n maxAttachmentSizeBytes?: number;\n wellhubContext?: WellhubContext;\n\n disabled?: boolean;\n autoFocus?: boolean;\n placeholder?: string;\n metaRows?: CommentMetaRow[];\n isMetaSingleLine?: boolean;\n shareToChat?: Omit<ShareToChatRowProps, 'testId'>;\n /** Replaces the default send button, e.g. the edit form's Cancel/Save. */\n trailing?: ReactNode;\n /** Like `trailing`, but receives the upload-aware send state for a custom Save. */\n renderTrailing?: (state: CommentComposerTrailingState) => ReactNode;\n /** Render flush inside a host card instead of as its own surface. */\n embedded?: boolean;\n className?: string;\n testId?: string;\n};\n\nconst SUGGESTIONS_BACKGROUND = 'var(--palette-background-b-9)';\n\n// Module-level so react-mentions isn't re-rendered on every keystroke.\nconst MENTION_INPUT_STYLE = {\n fontSize: 14,\n lineHeight: '20px',\n suggestions: {\n backgroundColor: SUGGESTIONS_BACKGROUND,\n list: { backgroundColor: SUGGESTIONS_BACKGROUND },\n item: {\n color: 'var(--palette-primary-text-1)',\n '&focused': { backgroundColor: 'rgb(from var(--palette-primary-text-1) r g b / 0.08)' },\n },\n },\n} as unknown as CSSProperties;\n\nconst renderSuggestion = (entry: { display: string; photo?: string }) => (\n <div className={styles.suggestion}>\n <Avatar size={26} alt={entry.display} imgSrc={entry.photo} displayName={entry.display} />\n <span>{entry.display}</span>\n </div>\n);\n\nexport const CommentComposer = ({\n body,\n onBodyChange,\n onSubmit,\n canSubmit,\n currentUser,\n attachments,\n onAttachmentsChange,\n maxAttachments = DEFAULT_MAX_ATTACHMENTS,\n attachment,\n onAttachmentChange,\n attachmentError,\n onAttachmentError,\n maxAttachmentSizeBytes,\n wellhubContext,\n disabled,\n autoFocus,\n placeholder = 'Add a comment...',\n metaRows,\n isMetaSingleLine,\n shareToChat,\n trailing,\n renderTrailing,\n embedded,\n className,\n testId,\n}: CommentComposerProps) => {\n // Callers still on the singular props get the old one-file behaviour, unchanged.\n const isMulti = !!onAttachmentsChange;\n const value = useMemo(\n () => (isMulti ? attachments ?? [] : ([attachment].filter(Boolean) as UploadedAttachment[])),\n [isMulti, attachments, attachment]\n );\n\n const handleAttachmentsChange = useCallback(\n (next: UploadedAttachment[]) => {\n if (onAttachmentsChange) onAttachmentsChange(next);\n else onAttachmentChange?.(next[0] ?? null);\n },\n [onAttachmentsChange, onAttachmentChange]\n );\n\n const upload = useAttachmentUpload({\n value,\n onChange: handleAttachmentsChange,\n onError: onAttachmentError,\n maxSizeBytes: maxAttachmentSizeBytes,\n maxFiles: isMulti ? maxAttachments : 1,\n });\n\n // An attachment only lands once S3 confirms, so posting mid-upload would drop it.\n const canSend = canSubmit && !upload.isUploading;\n\n const submit = () => {\n if (!canSend || disabled) return;\n\n onSubmit();\n };\n\n const [isWellhubOpen, setIsWellhubOpen] = useState(false);\n const attachedKeys = useMemo(() => value.map(item => item.name), [value]);\n\n const addWellhubFiles = (files: WellhubFile[]) => {\n setIsWellhubOpen(false);\n upload.addStoredFiles(files.map(file => ({ fileName: file.fileName })));\n };\n\n const fieldRef = useRef<HTMLTextAreaElement | null>(null);\n\n // react-mentions opens suggestions from textarea events, so type \"@\" instead of setting state.\n const mentionSomeone = () => {\n const field = fieldRef.current;\n if (!field) return;\n\n field.focus();\n\n const needsSpace = !!field.value && !/\\s$/.test(field.value);\n const nextValue = `${field.value}${needsSpace ? ' @' : '@'}`;\n const setValue = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(field), 'value')?.set;\n\n setValue?.call(field, nextValue);\n field.setSelectionRange(nextValue.length, nextValue.length);\n field.dispatchEvent(new Event('input', { bubbles: true }));\n field.dispatchEvent(new Event('keyup', { bubbles: true }));\n };\n\n const handleEnterKey = (event: KeyboardEvent) => {\n if (event.key !== 'Enter' || event.shiftKey) return;\n if (!canSend || disabled) return;\n if (isSuggestionsListOpened()) return;\n\n event.preventDefault();\n submit();\n };\n\n return (\n <>\n <CommentInput\n value={body}\n canSubmit={canSend}\n disabled={disabled}\n onSubmit={onSubmit}\n trailing={\n renderTrailing ? renderTrailing({ canSend: canSend && !disabled, submit }) : trailing\n }\n embedded={embedded}\n className={className}\n testId={testId}\n field={\n <Input\n inputComponent={UserMention}\n inputProps={{\n // UserMention calls onChange with the text string, not a DOM event.\n onChange: onBodyChange as unknown as FormEventHandler<HTMLInputElement>,\n currentUser,\n allowEmptyQuery: true,\n suggestionsPortalHost: document.querySelector('body'),\n withLightTheme: false,\n mentionProps: { renderSuggestion },\n highlightLinks: true,\n style: MENTION_INPUT_STYLE,\n }}\n value={body}\n placeholder={placeholder}\n inputRef={fieldRef}\n className={styles.mentionField}\n onKeyDown={handleEnterKey}\n disableUnderline\n rows={1}\n fullWidth\n multiline\n autoFocus={autoFocus}\n />\n }\n attachments={upload.items}\n onAttachmentRemove={upload.removeAttachment}\n onAttachmentRetry={upload.handleRetry}\n onAttachmentReorder={isMulti ? upload.reorderAttachments : undefined}\n onFilesDrop={upload.addFiles}\n onImageLinkPaste={upload.addLinkedImage}\n dropLabel={upload.maxFiles === 1 ? 'Drop a file here' : 'Drop files here'}\n attachmentSlot={\n attachmentError ? <FailedFileUploading errorMessage={attachmentError} /> : undefined\n }\n toolbar={\n <>\n <AttachFileButton\n inputRef={upload.fileInputRef}\n onClick={upload.openFileDialog}\n onFileSelect={upload.handleFileSelect}\n onWellhubSelect={wellhubContext ? () => setIsWellhubOpen(true) : undefined}\n multiple={isMulti}\n disabled={upload.isFull}\n tooltip={\n upload.isFull\n ? `Up to ${upload.maxFiles} ${\n upload.maxFiles === 1 ? 'file' : 'files'\n } can be attached`\n : `Attach ${isMulti ? 'files' : 'file'}`\n }\n />\n <Tooltip title=\"Mention someone\">\n <ButtonIcon size=\"xs\" type=\"tertiary\" onClick={mentionSomeone}>\n <AlternateEmailIcon fontSize=\"inherit\" />\n </ButtonIcon>\n </Tooltip>\n <span className={styles.iconSlot}>\n <EmojiIconButton\n icon={<SmilingFaceIcon size={16} />}\n handleSelectEmoji={(emoji: { native: string }) =>\n onBodyChange(`${body}${emoji.native}`)\n }\n />\n </span>\n </>\n }\n footer={\n (!!metaRows?.length || !!shareToChat) && (\n <>\n <CommentMetaLine rows={metaRows ?? []} singleLine={isMetaSingleLine} />\n {shareToChat && <ShareToChatRow {...shareToChat} />}\n </>\n )\n }\n />\n\n {wellhubContext && (\n <WellhubFilePicker\n {...wellhubContext}\n open={isWellhubOpen}\n maxSelectable={upload.maxFiles - upload.count}\n attachedFileNames={attachedKeys}\n onAdd={addWellhubFiles}\n onClose={() => setIsWellhubOpen(false)}\n />\n )}\n </>\n );\n};\n"],"names":["MENTION_INPUT_STYLE","fontSize","lineHeight","suggestions","backgroundColor","list","item","color","renderSuggestion","entry","_jsxs","className","styles","suggestion","children","_jsx","Avatar","size","alt","display","imgSrc","photo","displayName","CommentComposer","_ref","body","onBodyChange","onSubmit","canSubmit","currentUser","attachments","onAttachmentsChange","_ref$maxAttachments","maxAttachments","DEFAULT_MAX_ATTACHMENTS","attachment","onAttachmentChange","attachmentError","onAttachmentError","maxAttachmentSizeBytes","wellhubContext","disabled","autoFocus","_ref$placeholder","placeholder","metaRows","isMetaSingleLine","shareToChat","trailing","renderTrailing","embedded","testId","isMulti","value","useMemo","filter","Boolean","handleAttachmentsChange","useCallback","next","_next$","upload","useAttachmentUpload","onChange","onError","maxSizeBytes","maxFiles","canSend","isUploading","submit","useState","_useState2","_slicedToArray","_useState","isWellhubOpen","setIsWellhubOpen","attachedKeys","map","name","fieldRef","useRef","_Fragment","CommentInput","field","Input","inputComponent","UserMention","inputProps","allowEmptyQuery","suggestionsPortalHost","document","querySelector","withLightTheme","mentionProps","highlightLinks","style","inputRef","mentionField","onKeyDown","event","key","shiftKey","isSuggestionsListOpened","preventDefault","disableUnderline","rows","fullWidth","multiline","items","onAttachmentRemove","removeAttachment","onAttachmentRetry","handleRetry","onAttachmentReorder","reorderAttachments","undefined","onFilesDrop","addFiles","onImageLinkPaste","addLinkedImage","dropLabel","attachmentSlot","FailedFileUploading","errorMessage","toolbar","AttachFileButton","fileInputRef","onClick","openFileDialog","onFileSelect","handleFileSelect","onWellhubSelect","multiple","isFull","tooltip","concat","Tooltip","title","ButtonIcon","type","_Object$getOwnPropert","current","focus","needsSpace","test","nextValue","setValue","Object","getOwnPropertyDescriptor","getPrototypeOf","set","call","setSelectionRange","length","dispatchEvent","Event","bubbles","AlternateEmailIcon","iconSlot","EmojiIconButton","icon","SmilingFaceIcon","handleSelectEmoji","emoji","native","footer","CommentMetaLine","singleLine","ShareToChatRow","_objectSpread","WellhubFilePicker","open","maxSelectable","count","attachedFileNames","onAdd","files","addStoredFiles","file","fileName","onClose"],"mappings":"yjMAuFA,IAGMA,EAAsB,CAC1BC,SAAU,GACVC,WAAY,OACZC,YAAa,CACXC,gBAP2B,gCAQ3BC,KAAM,CAAED,gBARmB,iCAS3BE,KAAM,CACJC,MAAO,gCACP,WAAY,CAAEH,gBAAiB,2DAK/BI,EAAmB,SAACC,GAA0C,OAClEC,EAAA,MAAA,CAAKC,UAAWC,EAAOC,WAAWC,SAAA,CAChCC,EAACC,EAAM,CAACC,KAAM,GAAIC,IAAKT,EAAMU,QAASC,OAAQX,EAAMY,MAAOC,YAAab,EAAMU,UAC9EJ,EAAA,OAAA,CAAAD,SAAOL,EAAMU,YACT,EAGKI,EAAkB,SA0BHC,GAAA,IAzB1BC,IAAAA,KACAC,IAAAA,aACAC,IAAAA,SACAC,IAAAA,UACAC,IAAAA,YACAC,IAAAA,YACAC,IAAAA,oBAAmBC,EAAAR,EACnBS,eAAAA,aAAiBC,EAAuBF,EACxCG,IAAAA,WACAC,IAAAA,mBACAC,IAA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sourcesContent":["import {\n CSSProperties,\n FormEventHandler,\n KeyboardEvent,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { Input } from '@material-ui/core';\nimport AlternateEmailIcon from '@material-ui/icons/AlternateEmail';\n\nimport { ButtonIcon } from '../../componentsV2/ButtonIcon';\nimport { Tooltip } from '../../componentsV2/Tooltip';\nimport { SmilingFaceIcon } from '../../icons';\nimport Avatar from '../Avatar';\nimport { AttachFileButton } from '../AttachFileButton';\nimport { CommentInput } from '../CommentInputNext/CommentInputNext';\nimport EmojiIconButton from '../EmojiIconButton';\nimport FailedFileUploading from '../FailedFileUploading';\nimport UserMention from '../UserMention';\nimport { isSuggestionsListOpened } from '../UserMention/utils';\nimport { WellhubFilePicker } from '../WellhubFilePicker';\nimport type { WellhubContext, WellhubFile } from '../WellhubFilePicker';\n\nimport {\n useAttachmentUpload,\n UploadedAttachment,\n DEFAULT_MAX_ATTACHMENTS,\n} from './useAttachmentUpload';\nimport { CommentMetaLine, CommentMetaRow } from './CommentMetaLine';\nimport { ShareToChatRow, ShareToChatRowProps } from './ShareToChatRow';\n\nimport styles from './CommentComposer.scss';\n\n/* eslint-disable camelcase -- mirrors the platform's snake_case user payload. */\nexport type CommentComposerUser = {\n id?: number;\n company_id?: number;\n first_name?: string;\n last_name?: string;\n profile_photo?: string;\n [key: string]: unknown;\n};\n/* eslint-enable camelcase */\n\nexport type CommentComposerTrailingState = {\n canSend: boolean;\n submit: () => void;\n};\n\nexport type CommentComposerProps = {\n body: string;\n onBodyChange: (value: string) => void;\n onSubmit: () => void;\n canSubmit: boolean;\n currentUser: CommentComposerUser;\n\n attachments?: UploadedAttachment[];\n onAttachmentsChange?: (attachments: UploadedAttachment[]) => void;\n maxAttachments?: number;\n /** @deprecated Use `attachments` — kept so single-attachment callers keep working. */\n attachment?: UploadedAttachment | null;\n /** @deprecated Use `onAttachmentsChange`. */\n onAttachmentChange?: (attachment: UploadedAttachment | null) => void;\n attachmentError?: string | null;\n onAttachmentError?: (message: string | null) => void;\n maxAttachmentSizeBytes?: number;\n wellhubContext?: WellhubContext;\n\n disabled?: boolean;\n autoFocus?: boolean;\n placeholder?: string;\n metaRows?: CommentMetaRow[];\n isMetaSingleLine?: boolean;\n shareToChat?: Omit<ShareToChatRowProps, 'testId'>;\n /** Replaces the default send button, e.g. the edit form's Cancel/Save. */\n trailing?: ReactNode;\n /** Like `trailing`, but receives the upload-aware send state for a custom Save. */\n renderTrailing?: (state: CommentComposerTrailingState) => ReactNode;\n /** Render flush inside a host card instead of as its own surface. */\n embedded?: boolean;\n className?: string;\n testId?: string;\n};\n\nconst SUGGESTIONS_BACKGROUND = 'var(--palette-background-b-9)';\n\n// Module-level so react-mentions isn't re-rendered on every keystroke.\nconst MENTION_INPUT_STYLE = {\n fontSize: 14,\n lineHeight: '20px',\n suggestions: {\n backgroundColor: SUGGESTIONS_BACKGROUND,\n list: { backgroundColor: SUGGESTIONS_BACKGROUND },\n item: {\n color: 'var(--palette-primary-text-1)',\n '&focused': { backgroundColor: 'rgb(from var(--palette-primary-text-1) r g b / 0.08)' },\n },\n },\n} as unknown as CSSProperties;\n\nconst renderSuggestion = (entry: { display: string; photo?: string }) => (\n <div className={styles.suggestion}>\n <Avatar size={26} alt={entry.display} imgSrc={entry.photo} displayName={entry.display} />\n <span>{entry.display}</span>\n </div>\n);\n\nexport const CommentComposer = ({\n body,\n onBodyChange,\n onSubmit,\n canSubmit,\n currentUser,\n attachments,\n onAttachmentsChange,\n maxAttachments = DEFAULT_MAX_ATTACHMENTS,\n attachment,\n onAttachmentChange,\n attachmentError,\n onAttachmentError,\n maxAttachmentSizeBytes,\n wellhubContext,\n disabled,\n autoFocus,\n placeholder = 'Add a comment...',\n metaRows,\n isMetaSingleLine,\n shareToChat,\n trailing,\n renderTrailing,\n embedded,\n className,\n testId,\n}: CommentComposerProps) => {\n // Callers still on the singular props get the old one-file behaviour, unchanged.\n const isMulti = !!onAttachmentsChange;\n const value = useMemo(\n () => (isMulti ? attachments ?? [] : ([attachment].filter(Boolean) as UploadedAttachment[])),\n [isMulti, attachments, attachment]\n );\n\n const handleAttachmentsChange = useCallback(\n (next: UploadedAttachment[]) => {\n if (onAttachmentsChange) onAttachmentsChange(next);\n else onAttachmentChange?.(next[0] ?? null);\n },\n [onAttachmentsChange, onAttachmentChange]\n );\n\n const upload = useAttachmentUpload({\n value,\n onChange: handleAttachmentsChange,\n onError: onAttachmentError,\n maxSizeBytes: maxAttachmentSizeBytes,\n maxFiles: isMulti ? maxAttachments : 1,\n });\n\n // An attachment only lands once S3 confirms, so posting mid-upload would drop it.\n const canSend = canSubmit && !upload.isUploading;\n\n const submit = () => {\n if (!canSend || disabled) return;\n\n onSubmit();\n };\n\n const [isWellhubOpen, setIsWellhubOpen] = useState(false);\n const attachedKeys = useMemo(() => value.map(item => item.name), [value]);\n\n const addWellhubFiles = (files: WellhubFile[]) => {\n setIsWellhubOpen(false);\n upload.addStoredFiles(files.map(file => ({ fileName: file.fileName })));\n };\n\n const fieldRef = useRef<HTMLTextAreaElement | null>(null);\n\n // An autofocused edit form lands the caret at the start; editing usually continues from the end.\n useEffect(() => {\n const field = fieldRef.current;\n if (!autoFocus || !field) return;\n\n field.setSelectionRange(field.value.length, field.value.length);\n }, [autoFocus]);\n\n // react-mentions opens suggestions from textarea events, so type \"@\" instead of setting state.\n const mentionSomeone = () => {\n const field = fieldRef.current;\n if (!field) return;\n\n field.focus();\n\n const needsSpace = !!field.value && !/\\s$/.test(field.value);\n const nextValue = `${field.value}${needsSpace ? ' @' : '@'}`;\n const setValue = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(field), 'value')?.set;\n\n setValue?.call(field, nextValue);\n field.setSelectionRange(nextValue.length, nextValue.length);\n field.dispatchEvent(new Event('input', { bubbles: true }));\n field.dispatchEvent(new Event('keyup', { bubbles: true }));\n };\n\n const handleEnterKey = (event: KeyboardEvent) => {\n if (event.key !== 'Enter' || event.shiftKey) return;\n if (!canSend || disabled) return;\n if (isSuggestionsListOpened()) return;\n\n event.preventDefault();\n submit();\n };\n\n return (\n <>\n <CommentInput\n value={body}\n canSubmit={canSend}\n disabled={disabled}\n onSubmit={onSubmit}\n trailing={\n renderTrailing ? renderTrailing({ canSend: canSend && !disabled, submit }) : trailing\n }\n embedded={embedded}\n className={className}\n testId={testId}\n field={\n <Input\n inputComponent={UserMention}\n inputProps={{\n // UserMention calls onChange with the text string, not a DOM event.\n onChange: onBodyChange as unknown as FormEventHandler<HTMLInputElement>,\n currentUser,\n allowEmptyQuery: true,\n suggestionsPortalHost: document.querySelector('body'),\n withLightTheme: false,\n mentionProps: { renderSuggestion },\n highlightLinks: true,\n style: MENTION_INPUT_STYLE,\n }}\n value={body}\n placeholder={placeholder}\n inputRef={fieldRef}\n className={styles.mentionField}\n onKeyDown={handleEnterKey}\n disableUnderline\n rows={1}\n fullWidth\n multiline\n autoFocus={autoFocus}\n />\n }\n attachments={upload.items}\n onAttachmentRemove={upload.removeAttachment}\n onAttachmentRetry={upload.handleRetry}\n onAttachmentReorder={isMulti ? upload.reorderAttachments : undefined}\n onFilesDrop={upload.addFiles}\n onImageLinkPaste={upload.addLinkedImage}\n dropLabel={upload.maxFiles === 1 ? 'Drop a file here' : 'Drop files here'}\n attachmentSlot={\n attachmentError ? <FailedFileUploading errorMessage={attachmentError} /> : undefined\n }\n toolbar={\n <>\n <AttachFileButton\n inputRef={upload.fileInputRef}\n onClick={upload.openFileDialog}\n onFileSelect={upload.handleFileSelect}\n onWellhubSelect={wellhubContext ? () => setIsWellhubOpen(true) : undefined}\n multiple={isMulti}\n disabled={upload.isFull}\n tooltip={\n upload.isFull\n ? `Up to ${upload.maxFiles} ${\n upload.maxFiles === 1 ? 'file' : 'files'\n } can be attached`\n : `Attach ${isMulti ? 'files' : 'file'}`\n }\n />\n <Tooltip title=\"Mention someone\">\n <ButtonIcon size=\"xs\" type=\"tertiary\" onClick={mentionSomeone}>\n <AlternateEmailIcon fontSize=\"inherit\" />\n </ButtonIcon>\n </Tooltip>\n <span className={styles.iconSlot}>\n <EmojiIconButton\n icon={<SmilingFaceIcon size={16} />}\n handleSelectEmoji={(emoji: { native: string }) =>\n onBodyChange(`${body}${emoji.native}`)\n }\n />\n </span>\n </>\n }\n footer={\n (!!metaRows?.length || !!shareToChat) && (\n <>\n <CommentMetaLine rows={metaRows ?? []} singleLine={isMetaSingleLine} />\n {shareToChat && <ShareToChatRow {...shareToChat} />}\n </>\n )\n }\n />\n\n {wellhubContext && (\n <WellhubFilePicker\n {...wellhubContext}\n open={isWellhubOpen}\n maxSelectable={upload.maxFiles - upload.count}\n attachedFileNames={attachedKeys}\n onAdd={addWellhubFiles}\n onClose={() => setIsWellhubOpen(false)}\n />\n )}\n </>\n );\n};\n"],"names":["MENTION_INPUT_STYLE","fontSize","lineHeight","suggestions","backgroundColor","list","item","color","renderSuggestion","entry","_jsxs","className","styles","suggestion","children","_jsx","Avatar","size","alt","display","imgSrc","photo","displayName","CommentComposer","_ref","body","onBodyChange","onSubmit","canSubmit","currentUser","attachments","onAttachmentsChange","_ref$maxAttachments","maxAttachments","DEFAULT_MAX_ATTACHMENTS","attachment","onAttachmentChange","attachmentError","onAttachmentError","maxAttachmentSizeBytes","wellhubContext","disabled","autoFocus","_ref$placeholder","placeholder","metaRows","isMetaSingleLine","shareToChat","trailing","renderTrailing","embedded","testId","isMulti","value","useMemo","filter","Boolean","handleAttachmentsChange","useCallback","next","_next$","upload","useAttachmentUpload","onChange","onError","maxSizeBytes","maxFiles","canSend","isUploading","submit","useState","_useState2","_slicedToArray","_useState","isWellhubOpen","setIsWellhubOpen","attachedKeys","map","name","fieldRef","useRef","useEffect","field","current","setSelectionRange","length","_Fragment","CommentInput","Input","inputComponent","UserMention","inputProps","allowEmptyQuery","suggestionsPortalHost","document","querySelector","withLightTheme","mentionProps","highlightLinks","style","inputRef","mentionField","onKeyDown","event","key","shiftKey","isSuggestionsListOpened","preventDefault","disableUnderline","rows","fullWidth","multiline","items","onAttachmentRemove","removeAttachment","onAttachmentRetry","handleRetry","onAttachmentReorder","reorderAttachments","undefined","onFilesDrop","addFiles","onImageLinkPaste","addLinkedImage","dropLabel","attachmentSlot","FailedFileUploading","errorMessage","toolbar","AttachFileButton","fileInputRef","onClick","openFileDialog","onFileSelect","handleFileSelect","onWellhubSelect","multiple","isFull","tooltip","concat","Tooltip","title","ButtonIcon","type","_Object$getOwnPropert","focus","needsSpace","test","nextValue","setValue","Object","getOwnPropertyDescriptor","getPrototypeOf","set","call","dispatchEvent","Event","bubbles","AlternateEmailIcon","iconSlot","EmojiIconButton","icon","SmilingFaceIcon","handleSelectEmoji","emoji","native","footer","CommentMetaLine","singleLine","ShareToChatRow","_objectSpread","WellhubFilePicker","open","maxSelectable","count","attachedFileNames","onAdd","files","addStoredFiles","file","fileName","onClose"],"mappings":"wkMAwFA,IAGMA,EAAsB,CAC1BC,SAAU,GACVC,WAAY,OACZC,YAAa,CACXC,gBAP2B,gCAQ3BC,KAAM,CAAED,gBARmB,iCAS3BE,KAAM,CACJC,MAAO,gCACP,WAAY,CAAEH,gBAAiB,2DAK/BI,EAAmB,SAACC,GAA0C,OAClEC,EAAA,MAAA,CAAKC,UAAWC,EAAOC,WAAWC,SAAA,CAChCC,EAACC,EAAM,CAACC,KAAM,GAAIC,IAAKT,EAAMU,QAASC,OAAQX,EAAMY,MAAOC,YAAab,EAAMU,UAC9EJ,EAAA,OAAA,CAAAD,SAAOL,EAAMU,YACT,EAGKI,EAAkB,SA0BHC,GAAA,IAzB1BC,IAAAA,KACAC,IAAAA,aACAC,IAAAA,SACAC,IAAAA,UACAC,IAAAA,YACAC,IAAAA,YACAC,IAAAA,oBAAmBC,EAAAR,EACnBS,eAAAA,aAAiBC,EAAuBF,EACxCG,IAAAA,WACAC,IAAAA,mBACAC,IAAAA,gBACAC,IAAAA,kBACAC,IAAAA,uBACAC,IAAAA,eACAC,IAAAA,SACAC,IAAAA,UAASC,EAAAnB,EACToB,YAAAA,aAAc,mBAAkBD,EAChCE,IAAAA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