@burdenoff/microfe-support 2026.1114.1 → 2026.1115.1

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.
Files changed (117) hide show
  1. package/dist/generated/global-operations.d.ts +62 -0
  2. package/dist/generated/global-operations.js +104 -69
  3. package/dist/generated/global-operations.js.map +1 -1
  4. package/dist/generated/global-types.js +17 -15
  5. package/dist/generated/global-types.js.map +1 -1
  6. package/dist/support/SupportUserRoot.js +32 -28
  7. package/dist/support/SupportUserRoot.js.map +1 -1
  8. package/dist/support/SupportUserRoutes.d.ts +1 -0
  9. package/dist/support/SupportUserRoutes.js +31 -28
  10. package/dist/support/SupportUserRoutes.js.map +1 -1
  11. package/dist/support/components/PageLayout.js +35 -35
  12. package/dist/support/components/RouteHelpers.d.ts +2 -1
  13. package/dist/support/components/RouteHelpers.js +3 -3
  14. package/dist/support/components/RouteHelpers.js.map +1 -1
  15. package/dist/support/components/help/RelatedArticles.d.ts +12 -0
  16. package/dist/support/components/help/RelatedArticles.js +55 -0
  17. package/dist/support/components/help/RelatedArticles.js.map +1 -0
  18. package/dist/support/components/help/RequestDetailHeader.d.ts +18 -0
  19. package/dist/support/components/help/RequestDetailHeader.js +129 -0
  20. package/dist/support/components/help/RequestDetailHeader.js.map +1 -0
  21. package/dist/support/components/help/SatisfactionReview.d.ts +18 -0
  22. package/dist/support/components/help/SatisfactionReview.js +103 -0
  23. package/dist/support/components/help/SatisfactionReview.js.map +1 -0
  24. package/dist/support/components/help/StarRating.d.ts +16 -0
  25. package/dist/support/components/help/StarRating.js +63 -0
  26. package/dist/support/components/help/StarRating.js.map +1 -0
  27. package/dist/support/components/help/StatusGroupPill.d.ts +11 -0
  28. package/dist/support/components/help/StatusGroupPill.js +19 -0
  29. package/dist/support/components/help/StatusGroupPill.js.map +1 -0
  30. package/dist/support/components/settings/TicketCategoriesSettings.js +69 -69
  31. package/dist/support/components/settings/TicketCategoriesSettings.js.map +1 -1
  32. package/dist/support/components/tickets/MessageComposer.js +7 -7
  33. package/dist/support/components/tickets/MessageComposer.js.map +1 -1
  34. package/dist/support/components/tickets/TicketDetailHeader.js +54 -60
  35. package/dist/support/components/tickets/TicketDetailHeader.js.map +1 -1
  36. package/dist/support/components/ui.js +1 -1
  37. package/dist/support/constants.d.ts +23 -0
  38. package/dist/support/constants.js +2 -2
  39. package/dist/support/constants.js.map +1 -1
  40. package/dist/support/hooks/useDebouncedValue.d.ts +6 -0
  41. package/dist/support/hooks/useDebouncedValue.js +12 -0
  42. package/dist/support/hooks/useDebouncedValue.js.map +1 -0
  43. package/dist/support/hooks/useKnowledgeBaseOperations.d.ts +8 -1
  44. package/dist/support/hooks/useKnowledgeBaseOperations.js +86 -81
  45. package/dist/support/hooks/useKnowledgeBaseOperations.js.map +1 -1
  46. package/dist/support/hooks/useSupportVariant.d.ts +11 -0
  47. package/dist/support/hooks/useSupportVariant.js +11 -0
  48. package/dist/support/hooks/useSupportVariant.js.map +1 -0
  49. package/dist/support/hooks/useTicketCreatedToast.d.ts +16 -0
  50. package/dist/support/hooks/useTicketCreatedToast.js +25 -0
  51. package/dist/support/hooks/useTicketCreatedToast.js.map +1 -0
  52. package/dist/support/hooks/useTicketLabels.d.ts +22 -0
  53. package/dist/support/hooks/useTicketLabels.js +40 -0
  54. package/dist/support/hooks/useTicketLabels.js.map +1 -0
  55. package/dist/support/index.d.ts +1 -1
  56. package/dist/support/pages/ArticleDetailAdminPage.js +84 -84
  57. package/dist/support/pages/ArticleDetailAdminPage.js.map +1 -1
  58. package/dist/support/pages/ArticleDetailUserPage.d.ts +5 -0
  59. package/dist/support/pages/ArticleDetailUserPage.js +133 -69
  60. package/dist/support/pages/ArticleDetailUserPage.js.map +1 -1
  61. package/dist/support/pages/AskForHelpPage.d.ts +11 -0
  62. package/dist/support/pages/AskForHelpPage.js +396 -0
  63. package/dist/support/pages/AskForHelpPage.js.map +1 -0
  64. package/dist/support/pages/ContactInquiriesPage.js +73 -73
  65. package/dist/support/pages/ContactInquiryDetailPage.js +47 -47
  66. package/dist/support/pages/ContactInquiryDetailPage.js.map +1 -1
  67. package/dist/support/pages/CreateTicketPage.d.ts +4 -0
  68. package/dist/support/pages/CreateTicketPage.js +121 -117
  69. package/dist/support/pages/CreateTicketPage.js.map +1 -1
  70. package/dist/support/pages/HelpHubPage.d.ts +9 -0
  71. package/dist/support/pages/HelpHubPage.js +272 -0
  72. package/dist/support/pages/HelpHubPage.js.map +1 -0
  73. package/dist/support/pages/JobApplicationDetailPage.js +388 -388
  74. package/dist/support/pages/JobApplicationDetailPage.js.map +1 -1
  75. package/dist/support/pages/JobApplicationsPage.js +35 -35
  76. package/dist/support/pages/JobPostingDetailPage.js +236 -236
  77. package/dist/support/pages/JobPostingDetailPage.js.map +1 -1
  78. package/dist/support/pages/KnowledgeBaseUserPage.d.ts +6 -1
  79. package/dist/support/pages/KnowledgeBaseUserPage.js +188 -137
  80. package/dist/support/pages/KnowledgeBaseUserPage.js.map +1 -1
  81. package/dist/support/pages/MyRequestsPage.d.ts +16 -0
  82. package/dist/support/pages/MyRequestsPage.js +389 -0
  83. package/dist/support/pages/MyRequestsPage.js.map +1 -0
  84. package/dist/support/pages/TicketDetailUserPage.d.ts +5 -0
  85. package/dist/support/pages/TicketDetailUserPage.js +285 -192
  86. package/dist/support/pages/TicketDetailUserPage.js.map +1 -1
  87. package/dist/support/pages/TicketListPage.d.ts +7 -0
  88. package/dist/support/pages/TicketListPage.js +150 -153
  89. package/dist/support/pages/TicketListPage.js.map +1 -1
  90. package/dist/support/providers/SupportProvider.js +8 -7
  91. package/dist/support/providers/SupportProvider.js.map +1 -1
  92. package/dist/support/store/supportStore.d.ts +5 -0
  93. package/dist/support/store/supportStore.js +1 -0
  94. package/dist/support/store/supportStore.js.map +1 -1
  95. package/dist/support/translations/en.d.ts +279 -0
  96. package/dist/support/translations/en.js +270 -1
  97. package/dist/support/translations/en.js.map +1 -1
  98. package/dist/support/types/index.d.ts +13 -0
  99. package/dist/support/utils/cameFrom.d.ts +16 -0
  100. package/dist/support/utils/cameFrom.js +22 -0
  101. package/dist/support/utils/cameFrom.js.map +1 -0
  102. package/dist/support/utils/dates.d.ts +15 -0
  103. package/dist/support/utils/dates.js +35 -0
  104. package/dist/support/utils/dates.js.map +1 -0
  105. package/dist/support/utils/reopen.d.ts +27 -0
  106. package/dist/support/utils/reopen.js +27 -0
  107. package/dist/support/utils/reopen.js.map +1 -0
  108. package/dist/support/utils/requestTechnicalDetails.d.ts +13 -0
  109. package/dist/support/utils/requestTechnicalDetails.js +38 -0
  110. package/dist/support/utils/requestTechnicalDetails.js.map +1 -0
  111. package/dist/support/utils/ticketFilters.d.ts +16 -0
  112. package/dist/support/utils/ticketFilters.js +24 -12
  113. package/dist/support/utils/ticketFilters.js.map +1 -1
  114. package/dist/support/utils/ticketStatusGroups.d.ts +20 -0
  115. package/dist/support/utils/ticketStatusGroups.js +39 -0
  116. package/dist/support/utils/ticketStatusGroups.js.map +1 -0
  117. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"MessageComposer.js","names":["_Fragment","EMPTY_CANNED_RESPONSES","MessageComposer","_ticketId","useI18n","message","setMessage","useState","isInternal","setIsInternal","isSending","setIsSending","attachedFiles","setAttachedFiles","fileError","setFileError","textareaRef","useRef","fileInputRef","textarea","handleSubmit","result","onSendMessage","error","handleKeyDown","handleAttachFiles","handleFileChange","files","partitionAttachments","accepted","prev","rejected","rejectedAttachmentsMessage","handleRemoveFile","i","index","handleInsertCannedResponse","selectedResponse","cannedResponses","response","responseId","trimmedMessage","currentMessage","allowInternalNotes","Lock","tWithFallback","t","event","disabled","cannedResponsesLoading","placeholder","SUPPORT_ATTACHMENT_ACCEPT","Paperclip","file","Fragment","Loader2","Send"],"sources":["../../../../src/support/components/tickets/MessageComposer.tsx"],"sourcesContent":["import { useState, useRef, useEffect, type FC } from 'react';\nimport { Send, Paperclip, Lock, Loader2 } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { tWithFallback } from '../../utils/i18n';\nimport {\n SUPPORT_ATTACHMENT_ACCEPT,\n partitionAttachments,\n rejectedAttachmentsMessage,\n} from '../../utils/attachments';\n\nexport interface MessageComposerSendResult {\n preserveAttachedFiles?: boolean;\n preserveMessage?: boolean;\n}\n\ninterface MessageComposerProps {\n ticketId: string;\n onSendMessage: (\n content: string,\n isInternal: boolean,\n files: File[]\n ) => Promise<MessageComposerSendResult | void>;\n placeholder?: string;\n disabled?: boolean;\n allowInternalNotes?: boolean;\n cannedResponses?: readonly CannedResponseOption[];\n cannedResponsesLoading?: boolean;\n}\n\nexport interface CannedResponseOption {\n id: string;\n title: string;\n content: string;\n shortcut?: string | null;\n}\n\nconst EMPTY_CANNED_RESPONSES: readonly CannedResponseOption[] = [];\n\nexport const MessageComposer: FC<MessageComposerProps> = ({\n ticketId: _ticketId,\n onSendMessage,\n placeholder = 'Type your message...',\n disabled = false,\n allowInternalNotes = false,\n cannedResponses = EMPTY_CANNED_RESPONSES,\n cannedResponsesLoading = false,\n}) => {\n const { t } = useI18n();\n const [message, setMessage] = useState('');\n const [isInternal, setIsInternal] = useState(false);\n const [isSending, setIsSending] = useState(false);\n const [attachedFiles, setAttachedFiles] = useState<File[]>([]);\n const [fileError, setFileError] = useState<string | null>(null);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n // Auto-resize textarea as content changes\n useEffect(() => {\n const textarea = textareaRef.current;\n if (textarea) {\n // Reset height to auto to get the correct scrollHeight\n textarea.style.height = 'auto';\n // Set height to scrollHeight (content height) but respect CSS max-height\n textarea.style.height = `${textarea.scrollHeight}px`;\n }\n }, [message]);\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n if ((!message.trim() && attachedFiles.length === 0) || isSending) return;\n\n setIsSending(true);\n try {\n const result = await onSendMessage(message.trim(), isInternal, attachedFiles);\n if (!result?.preserveMessage) {\n setMessage('');\n }\n setIsInternal(false);\n if (!result?.preserveAttachedFiles) {\n setAttachedFiles([]);\n setFileError(null);\n }\n } catch (error) {\n console.error('Failed to send message:', error);\n } finally {\n setIsSending(false);\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n handleSubmit(e);\n }\n };\n\n const handleAttachFiles = () => {\n fileInputRef.current?.click();\n };\n\n const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const files = Array.from(e.target.files || []);\n const { accepted, rejected } = partitionAttachments(files);\n if (accepted.length > 0) {\n setAttachedFiles((prev) => [...prev, ...accepted]);\n }\n setFileError(rejected.length > 0 ? rejectedAttachmentsMessage(rejected) : null);\n // Reset input so the same file can be selected again\n e.target.value = '';\n };\n\n const handleRemoveFile = (index: number) => {\n setAttachedFiles((prev) => prev.filter((_, i) => i !== index));\n // Clear any stale rejection error once the user removes attachments, so a\n // prior \"unsupported type\" warning doesn't linger with no files visible.\n setFileError(null);\n };\n\n const handleInsertCannedResponse = (responseId: string) => {\n const selectedResponse = cannedResponses.find((response) => response.id === responseId);\n if (!selectedResponse) return;\n\n setMessage((currentMessage) => {\n const trimmedMessage = currentMessage.trimEnd();\n return trimmedMessage\n ? `${trimmedMessage}\\n\\n${selectedResponse.content}`\n : selectedResponse.content;\n });\n\n requestAnimationFrame(() => textareaRef.current?.focus());\n };\n\n return (\n <div\n data-tour=\"support-ticket-message-composer\"\n className=\"shrink-0 border-t border-border-subtle bg-bg-surface\"\n >\n <form onSubmit={handleSubmit} className=\"p-4\">\n {/* Internal note toggle */}\n {allowInternalNotes && (\n <div className=\"flex items-center gap-2 mb-3\">\n <label className=\"flex items-center gap-2 cursor-pointer\">\n <input\n type=\"checkbox\"\n aria-label=\"Internal note\"\n checked={isInternal}\n onChange={(e) => setIsInternal(e.target.checked)}\n className=\"rounded border-border-subtle\"\n disabled={disabled}\n />\n <span className=\"text-sm flex items-center gap-1 text-text-secondary\">\n <Lock size={14} />\n {tWithFallback(\n t,\n 'support.messageComposer.internalNote',\n 'Internal Note (not visible to customer)'\n )}\n </span>\n </label>\n </div>\n )}\n\n {allowInternalNotes && (\n <div className=\"mb-3 flex flex-col gap-1 sm:max-w-sm\">\n <label\n htmlFor=\"support-canned-response\"\n className=\"text-sm font-medium text-text-primary\"\n >\n {tWithFallback(t, 'support.messageComposer.cannedResponses', 'Canned responses')}\n </label>\n <select\n id=\"support-canned-response\"\n value=\"\"\n onChange={(event) => handleInsertCannedResponse(event.target.value)}\n disabled={\n disabled || isSending || cannedResponsesLoading || cannedResponses.length === 0\n }\n className=\"rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary transition-colors focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20 disabled:cursor-not-allowed disabled:opacity-50 scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"\">\n {cannedResponsesLoading\n ? tWithFallback(\n t,\n 'support.messageComposer.loadingCannedResponses',\n 'Loading saved replies...'\n )\n : cannedResponses.length > 0\n ? tWithFallback(\n t,\n 'support.messageComposer.selectCannedResponse',\n 'Insert a saved reply'\n )\n : tWithFallback(\n t,\n 'support.messageComposer.noCannedResponses',\n 'No saved replies available'\n )}\n </option>\n {cannedResponses.map((response) => (\n <option key={response.id} value={response.id}>\n {response.shortcut ? `${response.title} (${response.shortcut})` : response.title}\n </option>\n ))}\n </select>\n </div>\n )}\n\n {/* Message input */}\n <div className=\"relative\">\n <textarea\n ref={textareaRef}\n aria-label={tWithFallback(t, 'support.messageComposer.placeholder', placeholder)}\n value={message}\n onChange={(e) => setMessage(e.target.value)}\n onKeyDown={handleKeyDown}\n placeholder={tWithFallback(t, 'support.messageComposer.placeholder', placeholder)}\n disabled={disabled || isSending}\n rows={1}\n className={`auto-resize w-full px-4 py-3 rounded-lg border resize-none transition-colors ${\n isInternal\n ? 'border-status-warning-bg bg-status-warning-bg-subtle'\n : 'border-border-subtle bg-bg-surface'\n } text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary`}\n />\n\n {/* Hidden file input */}\n <input\n ref={fileInputRef}\n type=\"file\"\n multiple\n aria-label=\"Attach files\"\n onChange={handleFileChange}\n className=\"hidden\"\n accept={SUPPORT_ATTACHMENT_ACCEPT}\n />\n\n {/* Unsupported file type error */}\n {fileError && (\n <p role=\"alert\" className=\"mt-2 text-sm text-status-error-text\">\n {fileError}\n </p>\n )}\n\n {/* Attached files display */}\n {attachedFiles.length > 0 && (\n <div className=\"flex flex-wrap gap-2 mt-2\">\n {attachedFiles.map((file, index) => (\n <div\n key={`${file.name}-${index}`}\n className=\"flex items-center gap-2 px-3 py-1 rounded-lg bg-bg-sunken text-sm\"\n >\n <Paperclip size={14} />\n <span className=\"max-w-[200px] truncate\">{file.name}</span>\n <button\n type=\"button\"\n onClick={() => handleRemoveFile(index)}\n className=\"flex min-h-11 min-w-11 items-center justify-center rounded text-text-secondary transition-colors hover:text-text-primary\"\n aria-label={`Remove attachment ${file.name}`}\n >\n ×\n </button>\n </div>\n ))}\n </div>\n )}\n\n {/* Actions */}\n <div className=\"flex items-center justify-between mt-3\">\n <button\n type=\"button\"\n onClick={handleAttachFiles}\n className=\"min-h-11 inline-flex items-center gap-2 px-3 py-2 rounded-lg transition-colors text-text-secondary hover:bg-bg-sunken\"\n disabled={disabled || isSending}\n >\n <Paperclip size={18} />\n <span className=\"text-sm\">\n {tWithFallback(t, 'support.messageComposer.attachFiles', 'Attach files')}\n </span>\n {attachedFiles.length > 0 && (\n <span className=\"text-xs bg-action-primary-bg text-action-primary-text rounded-full px-2 py-0.5\">\n {attachedFiles.length}\n </span>\n )}\n </button>\n\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-text-secondary hidden sm:inline\">\n {tWithFallback(\n t,\n 'support.messageComposer.hint',\n 'Markdown supported. Press Enter to send, Shift+Enter for new line'\n )}\n </span>\n <button\n type=\"submit\"\n disabled={(!message.trim() && attachedFiles.length === 0) || disabled || isSending}\n className={`min-h-11 inline-flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${\n isInternal\n ? 'bg-status-warning-bg hover:bg-status-warning-bg/90 text-on-accent'\n : 'bg-action-primary-bg hover:bg-action-primary-bg/90 text-action-primary-text'\n }`}\n >\n {isSending ? (\n <>\n <Loader2 size={18} className=\"animate-spin\" />\n {tWithFallback(t, 'support.messageComposer.sending', 'Sending...')}\n </>\n ) : (\n <>\n <Send size={18} />\n {tWithFallback(t, 'support.messageComposer.send', 'Send')}\n </>\n )}\n </button>\n </div>\n </div>\n </div>\n </form>\n </div>\n );\n};\n"],"mappings":";;;;;;;AAoCA,IAAMC,IAA0D,CAAC,GAEpDC,KAA6C,EACxD,UAAUC,GACV,kBACA,iBAAc,wBACd,cAAW,IACX,wBAAqB,IACrB,qBAAkBF,GAClB,4BAAyB,SACrB;CACJ,IAAM,EAAE,SAAMG,EAAQ,GAChB,CAACC,GAASC,KAAcC,EAAS,EAAE,GACnC,CAACC,GAAYC,KAAiBF,EAAS,EAAK,GAC5C,CAACG,GAAWC,KAAgBJ,EAAS,EAAK,GAC1C,CAACK,GAAeC,KAAoBN,EAAiB,CAAC,CAAC,GACvD,CAACO,GAAWC,KAAgBR,EAAwB,IAAI,GACxDS,IAAcC,EAA4B,IAAI,GAC9CC,IAAeD,EAAyB,IAAI;CAGlD,QAAgB;EACd,IAAME,IAAWH,EAAY;EAC7B,AAAIG,MAEF,EAAS,MAAM,SAAS,QAExB,EAAS,MAAM,SAAS,GAAGA,EAAS,aAAa;CAErD,GAAG,CAACd,CAAO,CAAC;CAEZ,IAAMe,IAAe,OAAO,MAAuB;EAEjD,IADA,EAAE,eAAe,GACZ,GAACf,EAAQ,KAAK,KAAKO,EAAc,WAAW,KAAMF,IAEvD;KAAa,EAAI;GACjB,IAAI;IACF,IAAMW,IAAS,MAAMC,EAAcjB,EAAQ,KAAK,GAAGG,GAA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AW,KAAMoC,KAAYtC;SACzE,WAAW,8IACTF,IACI,sEACA;SAGL,UAAAE,IACC,kBAAAV,GAAA,EAAA,UAAA,CACE,kBAACuD,GAAD;UAAS,MAAM;UAAI,WAAU;SAAgB,CAAA,GAC5CV,EAAcC,GAAG,mCAAmC,YAAY,CACjE,EAAA,CAAA,IAEF,kBAAA9C,GAAA,EAAA,UAAA,CACE,kBAACwD,GAAD,EAAM,MAAM,GAAK,CAAA,GAChBX,EAAcC,GAAG,gCAAgC,MAAM,CACxD,EAAA,CAAA;QAEE,CAAA,CACL;OACF,CAAA,CAAA;;KACF;;GACD;;CACH,CAAA;AAET"}
1
+ {"version":3,"file":"MessageComposer.js","names":["_Fragment","EMPTY_CANNED_RESPONSES","MessageComposer","_ticketId","useI18n","message","setMessage","useState","isInternal","setIsInternal","isSending","setIsSending","attachedFiles","setAttachedFiles","fileError","setFileError","textareaRef","useRef","fileInputRef","textarea","handleSubmit","result","onSendMessage","error","handleKeyDown","handleAttachFiles","handleFileChange","files","partitionAttachments","accepted","prev","rejected","rejectedAttachmentsMessage","handleRemoveFile","i","index","handleInsertCannedResponse","selectedResponse","cannedResponses","response","responseId","trimmedMessage","currentMessage","allowInternalNotes","tWithFallback","t","Lock","event","disabled","cannedResponsesLoading","placeholder","SUPPORT_ATTACHMENT_ACCEPT","Paperclip","file","Fragment","Loader2","Send"],"sources":["../../../../src/support/components/tickets/MessageComposer.tsx"],"sourcesContent":["import { useState, useRef, useEffect, type FC } from 'react';\nimport { Send, Paperclip, Lock, Loader2 } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { tWithFallback } from '../../utils/i18n';\nimport {\n SUPPORT_ATTACHMENT_ACCEPT,\n partitionAttachments,\n rejectedAttachmentsMessage,\n} from '../../utils/attachments';\n\nexport interface MessageComposerSendResult {\n preserveAttachedFiles?: boolean;\n preserveMessage?: boolean;\n}\n\ninterface MessageComposerProps {\n ticketId: string;\n onSendMessage: (\n content: string,\n isInternal: boolean,\n files: File[]\n ) => Promise<MessageComposerSendResult | void>;\n placeholder?: string;\n disabled?: boolean;\n allowInternalNotes?: boolean;\n cannedResponses?: readonly CannedResponseOption[];\n cannedResponsesLoading?: boolean;\n}\n\nexport interface CannedResponseOption {\n id: string;\n title: string;\n content: string;\n shortcut?: string | null;\n}\n\nconst EMPTY_CANNED_RESPONSES: readonly CannedResponseOption[] = [];\n\nexport const MessageComposer: FC<MessageComposerProps> = ({\n ticketId: _ticketId,\n onSendMessage,\n placeholder = 'Type your message...',\n disabled = false,\n allowInternalNotes = false,\n cannedResponses = EMPTY_CANNED_RESPONSES,\n cannedResponsesLoading = false,\n}) => {\n const { t } = useI18n();\n const [message, setMessage] = useState('');\n const [isInternal, setIsInternal] = useState(false);\n const [isSending, setIsSending] = useState(false);\n const [attachedFiles, setAttachedFiles] = useState<File[]>([]);\n const [fileError, setFileError] = useState<string | null>(null);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n // Auto-resize textarea as content changes\n useEffect(() => {\n const textarea = textareaRef.current;\n if (textarea) {\n // Reset height to auto to get the correct scrollHeight\n textarea.style.height = 'auto';\n // Set height to scrollHeight (content height) but respect CSS max-height\n textarea.style.height = `${textarea.scrollHeight}px`;\n }\n }, [message]);\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n if ((!message.trim() && attachedFiles.length === 0) || isSending) return;\n\n setIsSending(true);\n try {\n const result = await onSendMessage(message.trim(), isInternal, attachedFiles);\n if (!result?.preserveMessage) {\n setMessage('');\n }\n setIsInternal(false);\n if (!result?.preserveAttachedFiles) {\n setAttachedFiles([]);\n setFileError(null);\n }\n } catch (error) {\n console.error('Failed to send message:', error);\n } finally {\n setIsSending(false);\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n handleSubmit(e);\n }\n };\n\n const handleAttachFiles = () => {\n fileInputRef.current?.click();\n };\n\n const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const files = Array.from(e.target.files || []);\n const { accepted, rejected } = partitionAttachments(files);\n if (accepted.length > 0) {\n setAttachedFiles((prev) => [...prev, ...accepted]);\n }\n setFileError(rejected.length > 0 ? rejectedAttachmentsMessage(rejected) : null);\n // Reset input so the same file can be selected again\n e.target.value = '';\n };\n\n const handleRemoveFile = (index: number) => {\n setAttachedFiles((prev) => prev.filter((_, i) => i !== index));\n // Clear any stale rejection error once the user removes attachments, so a\n // prior \"unsupported type\" warning doesn't linger with no files visible.\n setFileError(null);\n };\n\n const handleInsertCannedResponse = (responseId: string) => {\n const selectedResponse = cannedResponses.find((response) => response.id === responseId);\n if (!selectedResponse) return;\n\n setMessage((currentMessage) => {\n const trimmedMessage = currentMessage.trimEnd();\n return trimmedMessage\n ? `${trimmedMessage}\\n\\n${selectedResponse.content}`\n : selectedResponse.content;\n });\n\n requestAnimationFrame(() => textareaRef.current?.focus());\n };\n\n return (\n <div\n data-tour=\"support-ticket-message-composer\"\n className=\"shrink-0 border-t border-border-subtle bg-bg-surface\"\n >\n <form onSubmit={handleSubmit} className=\"p-4\">\n {/* Internal note toggle */}\n {allowInternalNotes && (\n <div className=\"flex items-center gap-2 mb-3\">\n <label className=\"flex items-center gap-2 cursor-pointer\">\n <input\n type=\"checkbox\"\n aria-label={tWithFallback(\n t,\n 'support.messageComposer.internalNoteAriaLabel',\n 'Internal note'\n )}\n checked={isInternal}\n onChange={(e) => setIsInternal(e.target.checked)}\n className=\"rounded border-border-subtle\"\n disabled={disabled}\n />\n <span className=\"text-sm flex items-center gap-1 text-text-secondary\">\n <Lock size={14} />\n {tWithFallback(\n t,\n 'support.messageComposer.internalNote',\n 'Internal Note (not visible to customer)'\n )}\n </span>\n </label>\n </div>\n )}\n\n {allowInternalNotes && (\n <div className=\"mb-3 flex flex-col gap-1 sm:max-w-sm\">\n <label\n htmlFor=\"support-canned-response\"\n className=\"text-sm font-medium text-text-primary\"\n >\n {tWithFallback(t, 'support.messageComposer.cannedResponses', 'Canned responses')}\n </label>\n <select\n id=\"support-canned-response\"\n value=\"\"\n onChange={(event) => handleInsertCannedResponse(event.target.value)}\n disabled={\n disabled || isSending || cannedResponsesLoading || cannedResponses.length === 0\n }\n className=\"rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary transition-colors focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20 disabled:cursor-not-allowed disabled:opacity-50 scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"\">\n {cannedResponsesLoading\n ? tWithFallback(\n t,\n 'support.messageComposer.loadingCannedResponses',\n 'Loading saved replies...'\n )\n : cannedResponses.length > 0\n ? tWithFallback(\n t,\n 'support.messageComposer.selectCannedResponse',\n 'Insert a saved reply'\n )\n : tWithFallback(\n t,\n 'support.messageComposer.noCannedResponses',\n 'No saved replies available'\n )}\n </option>\n {cannedResponses.map((response) => (\n <option key={response.id} value={response.id}>\n {response.shortcut ? `${response.title} (${response.shortcut})` : response.title}\n </option>\n ))}\n </select>\n </div>\n )}\n\n {/* Message input */}\n <div className=\"relative\">\n <textarea\n ref={textareaRef}\n aria-label={tWithFallback(t, 'support.messageComposer.placeholder', placeholder)}\n value={message}\n onChange={(e) => setMessage(e.target.value)}\n onKeyDown={handleKeyDown}\n placeholder={tWithFallback(t, 'support.messageComposer.placeholder', placeholder)}\n disabled={disabled || isSending}\n rows={1}\n className={`auto-resize w-full px-4 py-3 rounded-lg border resize-none transition-colors ${\n isInternal\n ? 'border-status-warning-bg bg-status-warning-bg-subtle'\n : 'border-border-subtle bg-bg-surface'\n } text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary`}\n />\n\n {/* Hidden file input */}\n <input\n ref={fileInputRef}\n type=\"file\"\n multiple\n aria-label={tWithFallback(t, 'support.messageComposer.attachFiles', 'Attach files')}\n onChange={handleFileChange}\n className=\"hidden\"\n accept={SUPPORT_ATTACHMENT_ACCEPT}\n />\n\n {/* Unsupported file type error */}\n {fileError && (\n <p role=\"alert\" className=\"mt-2 text-sm text-status-error-text\">\n {fileError}\n </p>\n )}\n\n {/* Attached files display */}\n {attachedFiles.length > 0 && (\n <div className=\"flex flex-wrap gap-2 mt-2\">\n {attachedFiles.map((file, index) => (\n <div\n key={`${file.name}-${index}`}\n className=\"flex items-center gap-2 px-3 py-1 rounded-lg bg-bg-sunken text-sm\"\n >\n <Paperclip size={14} />\n <span className=\"max-w-[200px] truncate\">{file.name}</span>\n <button\n type=\"button\"\n onClick={() => handleRemoveFile(index)}\n className=\"flex min-h-11 min-w-11 items-center justify-center rounded text-text-secondary transition-colors hover:text-text-primary\"\n aria-label={tWithFallback(\n t,\n 'support.messageComposer.removeAttachment',\n 'Remove attachment {{fileName}}',\n { fileName: file.name }\n )}\n >\n ×\n </button>\n </div>\n ))}\n </div>\n )}\n\n {/* Actions */}\n <div className=\"flex items-center justify-between mt-3\">\n <button\n type=\"button\"\n onClick={handleAttachFiles}\n className=\"min-h-11 inline-flex items-center gap-2 px-3 py-2 rounded-lg transition-colors text-text-secondary hover:bg-bg-sunken\"\n disabled={disabled || isSending}\n >\n <Paperclip size={18} />\n <span className=\"text-sm\">\n {tWithFallback(t, 'support.messageComposer.attachFiles', 'Attach files')}\n </span>\n {attachedFiles.length > 0 && (\n <span className=\"text-xs bg-action-primary-bg text-action-primary-text rounded-full px-2 py-0.5\">\n {attachedFiles.length}\n </span>\n )}\n </button>\n\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-text-secondary hidden sm:inline\">\n {tWithFallback(\n t,\n 'support.messageComposer.hint',\n 'Markdown supported. Press Enter to send, Shift+Enter for new line'\n )}\n </span>\n <button\n type=\"submit\"\n disabled={(!message.trim() && attachedFiles.length === 0) || disabled || isSending}\n className={`min-h-11 inline-flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${\n isInternal\n ? 'bg-status-warning-bg hover:bg-status-warning-bg/90 text-on-accent'\n : 'bg-action-primary-bg hover:bg-action-primary-bg/90 text-action-primary-text'\n }`}\n >\n {isSending ? (\n <>\n <Loader2 size={18} className=\"animate-spin\" />\n {tWithFallback(t, 'support.messageComposer.sending', 'Sending...')}\n </>\n ) : (\n <>\n <Send size={18} />\n {tWithFallback(t, 'support.messageComposer.send', 'Send')}\n </>\n )}\n </button>\n </div>\n </div>\n </div>\n </form>\n </div>\n );\n};\n"],"mappings":";;;;;;;AAoCA,IAAMC,IAA0D,CAAC,GAEpDC,KAA6C,EACxD,UAAUC,GACV,kBACA,iBAAc,wBACd,cAAW,IACX,wBAAqB,IACrB,qBAAkBF,GAClB,4BAAyB,SACrB;CACJ,IAAM,EAAE,SAAMG,EAAQ,GAChB,CAACC,GAASC,KAAcC,EAAS,EAAE,GACnC,CAACC,GAAYC,KAAiBF,EAAS,EAAK,GAC5C,CAACG,GAAWC,KAAgBJ,EAAS,EAAK,GAC1C,CAACK,GAAeC,KAAoBN,EAAiB,CAAC,CAAC,GACvD,CAACO,GAAWC,KAAgBR,EAAwB,IAAI,GACxDS,IAAcC,EAA4B,IAAI,GAC9CC,IAAeD,EAAyB,IAAI;CAGlD,QAAgB;EACd,IAAME,IAAWH,EAAY;EAC7B,AAAIG,MAEF,EAAS,MAAM,SAAS,QAExB,EAAS,MAAM,SAAS,GAAGA,EAAS,aAAa;CAErD,GAAG,CAACd,CAAO,CAAC;CAEZ,IAAMe,IAAe,OAAO,MAAuB;EAEjD,IADA,EAAE,eAAe,GACZ,GAACf,EAAQ,KAAK,KAAKO,EAAc,WAAW,KAAMF,IAEvD;KAAa,EAAI;GACjB,IAAI;IACF,IAAMW,IAAS,MAAMC,EAAcjB,EAAQ,KAAK,GAAGG,GAAYI,CAAa;IAK5E,AAJKS,GAAQ,mBACXf,EAAW,EAAE,GAEfG,EAAc,EAAK,GACdY,GAAQ,0BACXR,E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,WAAW,KAAMoC,KAAYtC;SACzE,WAAW,8IACTF,IACI,sEACA;SAGL,UAAAE,IACC,kBAAAV,GAAA,EAAA,UAAA,CACE,kBAACuD,GAAD;UAAS,MAAM;UAAI,WAAU;SAAgB,CAAA,GAC5CX,EAAcC,GAAG,mCAAmC,YAAY,CACjE,EAAA,CAAA,IAEF,kBAAA7C,GAAA,EAAA,UAAA,CACE,kBAACwD,GAAD,EAAM,MAAM,GAAK,CAAA,GAChBZ,EAAcC,GAAG,gCAAgC,MAAM,CACxD,EAAA,CAAA;QAEE,CAAA,CACL;OACF,CAAA,CAAA;;KACF;;GACD;;CACH,CAAA;AAET"}
@@ -1,111 +1,105 @@
1
1
  import { Badge as e, Button as t } from "../ui.js";
2
2
  import { ticketPriorityBadgeClasses as n, ticketStatusBadgeClasses as r } from "../../utils/uiTokens.js";
3
3
  import { useTr as i } from "../../hooks/useTr.js";
4
- import { AlertCircle as a, ArrowLeft as o, CheckCircle2 as s, Clock as c, RotateCcw as l } from "lucide-react";
5
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
4
+ import { canReopenTicket as a, getReopenCount as o, isReopenBlockedByLimit as s } from "../../utils/reopen.js";
5
+ import { AlertCircle as c, ArrowLeft as l, CheckCircle2 as u, Clock as d, RotateCcw as f } from "lucide-react";
6
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
6
7
  // src/support/components/tickets/TicketDetailHeader.tsx
7
- var f = {
8
- NEW: a,
9
- IN_PROGRESS: c,
10
- WAITING_CUSTOMER: c,
11
- RESOLVED: s,
12
- CLOSED: s,
13
- REOPENED: l
14
- }, p = ({ ticket: a, onBack: s, onReopenTicket: c, onCreateNewTicket: p, actionsDisabled: m = !1 }) => {
15
- let h = i(), g = f[a.status], _ = (a.metadata != null && typeof a.metadata == "object" ? a.metadata : null)?.reopenCount, v = (() => {
16
- if (typeof _ == "number" && Number.isFinite(_)) return _;
17
- if (typeof _ == "string") {
18
- let e = Number.parseInt(_, 10);
19
- return Number.isFinite(e) ? e : 0;
20
- }
21
- return 0;
22
- })(), y = v >= 3, b = (a.status === "CLOSED" || a.status === "RESOLVED") && !y && !!c, x = {
23
- NEW: h("support.shared.status.new", "New"),
24
- IN_PROGRESS: h("support.shared.status.inProgress", "In Progress"),
25
- WAITING_CUSTOMER: h("support.shared.status.waitingCustomer", "Waiting on Customer"),
26
- RESOLVED: h("support.shared.status.resolved", "Resolved"),
27
- CLOSED: h("support.shared.status.closed", "Closed"),
28
- REOPENED: h("support.shared.status.reopened", "Reopened")
29
- }, S = {
30
- LOW: h("support.shared.priority.low", "Low"),
31
- NORMAL: h("support.shared.priority.normal", "Normal"),
32
- HIGH: h("support.shared.priority.high", "High"),
33
- CRITICAL: h("support.shared.priority.critical", "Critical")
8
+ var h = {
9
+ NEW: c,
10
+ IN_PROGRESS: d,
11
+ WAITING_CUSTOMER: d,
12
+ RESOLVED: u,
13
+ CLOSED: u,
14
+ REOPENED: f
15
+ }, g = ({ ticket: c, onBack: u, onReopenTicket: d, onCreateNewTicket: g, actionsDisabled: _ = !1 }) => {
16
+ let v = i(), y = h[c.status], b = o(c.metadata), x = a(c) && !!d, S = {
17
+ NEW: v("support.shared.status.new", "New"),
18
+ IN_PROGRESS: v("support.shared.status.inProgress", "In Progress"),
19
+ WAITING_CUSTOMER: v("support.shared.status.waitingCustomer", "Waiting on Customer"),
20
+ RESOLVED: v("support.shared.status.resolved", "Resolved"),
21
+ CLOSED: v("support.shared.status.closed", "Closed"),
22
+ REOPENED: v("support.shared.status.reopened", "Reopened")
23
+ }, C = {
24
+ LOW: v("support.shared.priority.low", "Low"),
25
+ NORMAL: v("support.shared.priority.normal", "Normal"),
26
+ HIGH: v("support.shared.priority.high", "High"),
27
+ CRITICAL: v("support.shared.priority.critical", "Critical")
34
28
  };
35
- return /* @__PURE__ */ d("div", {
29
+ return /* @__PURE__ */ m("div", {
36
30
  "data-tour": "support-ticket-detail-header",
37
31
  className: "border-b border-border-subtle bg-bg-surface p-4",
38
32
  children: [
39
- /* @__PURE__ */ d("div", {
33
+ /* @__PURE__ */ m("div", {
40
34
  className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-3",
41
- children: [/* @__PURE__ */ d(t, {
35
+ children: [/* @__PURE__ */ m(t, {
42
36
  variant: "ghost",
43
37
  size: "sm",
44
- onClick: s,
45
- children: [/* @__PURE__ */ u(o, { size: 20 }), h("support.ticketDetail.actions.back", "Back to Tickets")]
46
- }), /* @__PURE__ */ d("div", {
38
+ onClick: u,
39
+ children: [/* @__PURE__ */ p(l, { size: 20 }), v("support.ticketDetail.actions.back", "Back to Tickets")]
40
+ }), /* @__PURE__ */ m("div", {
47
41
  className: "flex flex-wrap items-center gap-2",
48
42
  children: [
49
- b && /* @__PURE__ */ d(t, {
43
+ x && /* @__PURE__ */ m(t, {
50
44
  "data-tour": "support-ticket-reopen-button",
51
45
  variant: "outline",
52
46
  size: "sm",
53
- onClick: () => void c?.(),
54
- disabled: m,
55
- children: [/* @__PURE__ */ u(l, { size: 16 }), h("support.ticketDetail.actions.reopen", "Reopen")]
47
+ onClick: () => void d?.(),
48
+ disabled: _,
49
+ children: [/* @__PURE__ */ p(f, { size: 16 }), v("support.ticketDetail.actions.reopen", "Reopen")]
56
50
  }),
57
- /* @__PURE__ */ d(e, {
58
- className: r[a.status],
59
- children: [/* @__PURE__ */ u(g, {
51
+ /* @__PURE__ */ m(e, {
52
+ className: r[c.status],
53
+ children: [/* @__PURE__ */ p(y, {
60
54
  size: 14,
61
55
  className: "mr-1"
62
- }), x[a.status]]
56
+ }), S[c.status]]
63
57
  }),
64
- /* @__PURE__ */ u(e, {
58
+ /* @__PURE__ */ p(e, {
65
59
  variant: "outline",
66
- className: n[a.priority],
67
- children: S[a.priority] ?? a.priority
60
+ className: n[c.priority],
61
+ children: C[c.priority] ?? c.priority
68
62
  }),
69
- v > 0 && /* @__PURE__ */ u(e, {
63
+ b > 0 && /* @__PURE__ */ p(e, {
70
64
  variant: "outline",
71
65
  className: "text-text-secondary",
72
- children: h("support.ticketDetail.reopenCount", "Reopen {{current}}/{{max}}", {
73
- current: v,
66
+ children: v("support.ticketDetail.reopenCount", "Reopen {{current}}/{{max}}", {
67
+ current: b,
74
68
  max: 3
75
69
  })
76
70
  })
77
71
  ]
78
72
  })]
79
73
  }),
80
- /* @__PURE__ */ u("h1", {
74
+ /* @__PURE__ */ p("h1", {
81
75
  className: "text-xl font-bold text-text-primary",
82
- children: a.subject
76
+ children: c.subject
83
77
  }),
84
- /* @__PURE__ */ d("p", {
78
+ /* @__PURE__ */ m("p", {
85
79
  className: "text-sm text-text-secondary mt-1",
86
80
  children: [
87
81
  "#",
88
- a.ticketNumber,
82
+ c.ticketNumber,
89
83
  " ·",
90
84
  " ",
91
- h("support.ticketDetail.meta.created", "Created {{date}}", { date: new Date(a.createdAt).toLocaleDateString() })
85
+ v("support.ticketDetail.meta.created", "Created {{date}}", { date: new Date(c.createdAt).toLocaleDateString() })
92
86
  ]
93
87
  }),
94
- y && a.status === "CLOSED" && /* @__PURE__ */ d("div", {
88
+ s(c) && /* @__PURE__ */ m("div", {
95
89
  className: "mt-3 rounded-lg border border-warning/40 bg-warning/10 p-3 text-sm text-warning",
96
- children: [/* @__PURE__ */ u("p", { children: h("support.ticketDetail.errors.reopenLimit", "You have reached the maximum number of reopens for this ticket. Please create a new ticket to continue.") }), /* @__PURE__ */ u("div", {
90
+ children: [/* @__PURE__ */ p("p", { children: v("support.ticketDetail.errors.reopenLimit", "You have reached the maximum number of reopens for this ticket. Please create a new ticket to continue.") }), /* @__PURE__ */ p("div", {
97
91
  className: "mt-3",
98
- children: /* @__PURE__ */ u(t, {
92
+ children: /* @__PURE__ */ p(t, {
99
93
  variant: "outline",
100
94
  size: "sm",
101
- onClick: p,
102
- children: h("support.ticketDetail.actions.createNewTicket", "Create New Ticket")
95
+ onClick: g,
96
+ children: v("support.ticketDetail.actions.createNewTicket", "Create New Ticket")
103
97
  })
104
98
  })]
105
99
  })
106
100
  ]
107
101
  });
108
102
  };
109
- export { p as TicketDetailHeader };
103
+ export { g as TicketDetailHeader };
110
104
 
111
105
  //# sourceMappingURL=TicketDetailHeader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TicketDetailHeader.js","names":["statusIcons","AlertCircle","Clock","CheckCircle2","RotateCcw","TicketDetailHeader","tr","useTr","StatusIcon","ticket","rawReopenCount","reopenCount","parsed","reopenCapReached","canReopen","onReopenTicket","statusLabels","priorityLabels","Button","onBack","ArrowLeft","actionsDisabled","Badge","ticketStatusBadgeClasses","ticketPriorityBadgeClasses","onCreateNewTicket"],"sources":["../../../../src/support/components/tickets/TicketDetailHeader.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { ArrowLeft, AlertCircle, Clock, CheckCircle2, RotateCcw } from 'lucide-react';\nimport { Button, Badge } from '../ui';\nimport type { SupportTicket, SupportTicketStatus } from '../../../generated/global-types';\nimport { MAX_REOPEN_COUNT } from '../../constants';\nimport { ticketPriorityBadgeClasses, ticketStatusBadgeClasses } from '../../utils/uiTokens';\nimport { useTr } from '../../hooks/useTr';\n\ninterface TicketDetailHeaderProps {\n ticket: SupportTicket;\n onBack: () => void;\n onReopenTicket?: () => Promise<void>;\n onCreateNewTicket?: () => void;\n actionsDisabled?: boolean;\n}\n\nconst statusIcons: Record<SupportTicketStatus, typeof AlertCircle> = {\n NEW: AlertCircle,\n IN_PROGRESS: Clock,\n WAITING_CUSTOMER: Clock,\n RESOLVED: CheckCircle2,\n CLOSED: CheckCircle2,\n REOPENED: RotateCcw,\n};\n\n/**\n * Read-only ticket header for user-facing pages.\n * Displays ticket info, status, and priority without admin controls\n * (no status change dropdown, no assignment).\n */\nexport const TicketDetailHeader: FC<TicketDetailHeaderProps> = ({\n ticket,\n onBack,\n onReopenTicket,\n onCreateNewTicket,\n actionsDisabled = false,\n}) => {\n const tr = useTr();\n const StatusIcon = statusIcons[ticket.status];\n const metadata =\n ticket.metadata != null && typeof ticket.metadata === 'object'\n ? (ticket.metadata as Record<string, unknown>)\n : null;\n // `metadata` is JSONB on the server side so `reopenCount` may have landed\n // as a number OR a numeric string (`\"3\"`) depending on how it was written.\n // Coerce both to a safe number, falling back to 0 for anything else.\n const rawReopenCount = metadata?.reopenCount;\n const reopenCount = (() => {\n if (typeof rawReopenCount === 'number' && Number.isFinite(rawReopenCount)) {\n return rawReopenCount;\n }\n if (typeof rawReopenCount === 'string') {\n const parsed = Number.parseInt(rawReopenCount, 10);\n return Number.isFinite(parsed) ? parsed : 0;\n }\n return 0;\n })();\n const reopenCapReached = reopenCount >= MAX_REOPEN_COUNT;\n // Allow reopen from both CLOSED and RESOLVED. If the agent prematurely\n // marks a ticket RESOLVED the user gets a single \"Reopen\" button rather\n // than having to Close → Reopen in two clicks. This matches the pre-Round\n // 1 behavior and addresses the regression flagged in PR #11 review.\n const canReopen =\n (ticket.status === 'CLOSED' || ticket.status === 'RESOLVED') &&\n !reopenCapReached &&\n Boolean(onReopenTicket);\n\n const statusLabels: Record<SupportTicketStatus, string> = {\n NEW: tr('support.shared.status.new', 'New'),\n IN_PROGRESS: tr('support.shared.status.inProgress', 'In Progress'),\n WAITING_CUSTOMER: tr('support.shared.status.waitingCustomer', 'Waiting on Customer'),\n RESOLVED: tr('support.shared.status.resolved', 'Resolved'),\n CLOSED: tr('support.shared.status.closed', 'Closed'),\n REOPENED: tr('support.shared.status.reopened', 'Reopened'),\n };\n\n const priorityLabels: Record<string, string> = {\n LOW: tr('support.shared.priority.low', 'Low'),\n NORMAL: tr('support.shared.priority.normal', 'Normal'),\n HIGH: tr('support.shared.priority.high', 'High'),\n CRITICAL: tr('support.shared.priority.critical', 'Critical'),\n };\n\n return (\n <div\n data-tour=\"support-ticket-detail-header\"\n className=\"border-b border-border-subtle bg-bg-surface p-4\"\n >\n <div className=\"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-3\">\n <Button variant=\"ghost\" size=\"sm\" onClick={onBack}>\n <ArrowLeft size={20} />\n {tr('support.ticketDetail.actions.back', 'Back to Tickets')}\n </Button>\n <div className=\"flex flex-wrap items-center gap-2\">\n {canReopen && (\n <Button\n data-tour=\"support-ticket-reopen-button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={() => void onReopenTicket?.()}\n disabled={actionsDisabled}\n >\n <RotateCcw size={16} />\n {tr('support.ticketDetail.actions.reopen', 'Reopen')}\n </Button>\n )}\n <Badge className={ticketStatusBadgeClasses[ticket.status]}>\n <StatusIcon size={14} className=\"mr-1\" />\n {statusLabels[ticket.status]}\n </Badge>\n <Badge variant=\"outline\" className={ticketPriorityBadgeClasses[ticket.priority]}>\n {priorityLabels[ticket.priority] ?? ticket.priority}\n </Badge>\n {reopenCount > 0 && (\n <Badge variant=\"outline\" className=\"text-text-secondary\">\n {tr('support.ticketDetail.reopenCount', 'Reopen {{current}}/{{max}}', {\n current: reopenCount,\n max: MAX_REOPEN_COUNT,\n })}\n </Badge>\n )}\n </div>\n </div>\n <h1 className=\"text-xl font-bold text-text-primary\">{ticket.subject}</h1>\n <p className=\"text-sm text-text-secondary mt-1\">\n #{ticket.ticketNumber} &middot;{' '}\n {tr('support.ticketDetail.meta.created', 'Created {{date}}', {\n date: new Date(ticket.createdAt).toLocaleDateString(),\n })}\n </p>\n {reopenCapReached && ticket.status === 'CLOSED' && (\n <div className=\"mt-3 rounded-lg border border-warning/40 bg-warning/10 p-3 text-sm text-warning\">\n <p>\n {tr(\n 'support.ticketDetail.errors.reopenLimit',\n 'You have reached the maximum number of reopens for this ticket. Please create a new ticket to continue.'\n )}\n </p>\n <div className=\"mt-3\">\n <Button variant=\"outline\" size=\"sm\" onClick={onCreateNewTicket}>\n {tr('support.ticketDetail.actions.createNewTicket', 'Create New Ticket')}\n </Button>\n </div>\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;AAgBA,IAAMA,IAA+D;CACnE,KAAKC;CACL,aAAaC;CACb,kBAAkBA;CAClB,UAAUC;CACV,QAAQA;CACR,UAAUC;AACZ,GAOaC,KAAmD,EAC9D,WACA,WACA,mBACA,sBACA,qB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eAAe,KAAKH,IAAiB;OACrC,UAAUM;OALZ,UAAA,CAOE,kBAACjB,GAAD,EAAW,MAAM,GAAK,CAAA,GACrBE,EAAG,uCAAuC,QAAQ,CAC7C;;MAEV,kBAACgB,GAAD;OAAO,WAAWC,EAAyBd,EAAO;OAAlD,UAAA,CACE,kBAACD,GAAD;QAAY,MAAM;QAAI,WAAU;OAAQ,CAAA,GACvCQ,EAAaP,EAAO,OAChB;;MACP,kBAACa,GAAD;OAAO,SAAQ;OAAU,WAAWE,EAA2Bf,EAAO;OACnE,UAAAQ,EAAeR,EAAO,aAAaA,EAAO;MACtC,CAAA;MACNE,IAAc,KACb,kBAACW,GAAD;OAAO,SAAQ;OAAU,WAAU;OAChC,UAAAhB,EAAG,oCAAoC,8BAA8B;QACpE,SAASK;QACT,KAAA;OACF,CAAC;MACI,CAAA;KAEN;IACF,CAAA,CAAA;;GACL,kBAAC,MAAD;IAAI,WAAU;IAAuC,UAAAF,EAAO;GAAY,CAAA;GACxE,kBAAC,KAAD;IAAG,WAAU;IAAb,UAAA;KAAgD;KAC5CA,EAAO;KAAa;KAAU;KAC/BH,EAAG,qCAAqC,oBAAoB,EAC3D,MAAM,IAAI,KAAKG,EAAO,SAAS,CAAC,CAAC,mBAAmB,EACtD,CAAC;IACA;;GACFI,KAAoBJ,EAAO,WAAW,YACrC,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAAC,KAAD,EAAA,UACGH,EACC,2CACA,yGACF,EACC,CAAA,GACH,kBAAC,OAAD;KAAK,WAAU;KACb,UAAA,kBAACY,GAAD;MAAQ,SAAQ;MAAU,MAAK;MAAK,SAASO;MAC1C,UAAAnB,EAAG,gDAAgD,mBAAmB;KACjE,CAAA;IACL,CAAA,CACF;;EAEJ;;AAET"}
1
+ {"version":3,"file":"TicketDetailHeader.js","names":["statusIcons","AlertCircle","Clock","CheckCircle2","RotateCcw","TicketDetailHeader","tr","useTr","StatusIcon","ticket","reopenCount","getReopenCount","canReopen","canReopenTicket","onReopenTicket","statusLabels","priorityLabels","Button","onBack","ArrowLeft","actionsDisabled","Badge","ticketStatusBadgeClasses","ticketPriorityBadgeClasses","isReopenBlockedByLimit","onCreateNewTicket"],"sources":["../../../../src/support/components/tickets/TicketDetailHeader.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { ArrowLeft, AlertCircle, Clock, CheckCircle2, RotateCcw } from 'lucide-react';\nimport { Button, Badge } from '../ui';\nimport type { SupportTicket, SupportTicketStatus } from '../../../generated/global-types';\nimport { MAX_REOPEN_COUNT } from '../../constants';\nimport { ticketPriorityBadgeClasses, ticketStatusBadgeClasses } from '../../utils/uiTokens';\nimport { useTr } from '../../hooks/useTr';\nimport { canReopenTicket, getReopenCount, isReopenBlockedByLimit } from '../../utils/reopen';\n\ninterface TicketDetailHeaderProps {\n ticket: SupportTicket;\n onBack: () => void;\n onReopenTicket?: () => Promise<void>;\n onCreateNewTicket?: () => void;\n actionsDisabled?: boolean;\n}\n\nconst statusIcons: Record<SupportTicketStatus, typeof AlertCircle> = {\n NEW: AlertCircle,\n IN_PROGRESS: Clock,\n WAITING_CUSTOMER: Clock,\n RESOLVED: CheckCircle2,\n CLOSED: CheckCircle2,\n REOPENED: RotateCcw,\n};\n\n/**\n * Read-only ticket header for user-facing pages.\n * Displays ticket info, status, and priority without admin controls\n * (no status change dropdown, no assignment).\n */\nexport const TicketDetailHeader: FC<TicketDetailHeaderProps> = ({\n ticket,\n onBack,\n onReopenTicket,\n onCreateNewTicket,\n actionsDisabled = false,\n}) => {\n const tr = useTr();\n const StatusIcon = statusIcons[ticket.status];\n const reopenCount = getReopenCount(ticket.metadata);\n // One shared rule (utils/reopen): reopen from CLOSED or RESOLVED while under\n // the server's reopen cap.\n const canReopen = canReopenTicket(ticket) && Boolean(onReopenTicket);\n\n const statusLabels: Record<SupportTicketStatus, string> = {\n NEW: tr('support.shared.status.new', 'New'),\n IN_PROGRESS: tr('support.shared.status.inProgress', 'In Progress'),\n WAITING_CUSTOMER: tr('support.shared.status.waitingCustomer', 'Waiting on Customer'),\n RESOLVED: tr('support.shared.status.resolved', 'Resolved'),\n CLOSED: tr('support.shared.status.closed', 'Closed'),\n REOPENED: tr('support.shared.status.reopened', 'Reopened'),\n };\n\n const priorityLabels: Record<string, string> = {\n LOW: tr('support.shared.priority.low', 'Low'),\n NORMAL: tr('support.shared.priority.normal', 'Normal'),\n HIGH: tr('support.shared.priority.high', 'High'),\n CRITICAL: tr('support.shared.priority.critical', 'Critical'),\n };\n\n return (\n <div\n data-tour=\"support-ticket-detail-header\"\n className=\"border-b border-border-subtle bg-bg-surface p-4\"\n >\n <div className=\"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-3\">\n <Button variant=\"ghost\" size=\"sm\" onClick={onBack}>\n <ArrowLeft size={20} />\n {tr('support.ticketDetail.actions.back', 'Back to Tickets')}\n </Button>\n <div className=\"flex flex-wrap items-center gap-2\">\n {canReopen && (\n <Button\n data-tour=\"support-ticket-reopen-button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={() => void onReopenTicket?.()}\n disabled={actionsDisabled}\n >\n <RotateCcw size={16} />\n {tr('support.ticketDetail.actions.reopen', 'Reopen')}\n </Button>\n )}\n <Badge className={ticketStatusBadgeClasses[ticket.status]}>\n <StatusIcon size={14} className=\"mr-1\" />\n {statusLabels[ticket.status]}\n </Badge>\n <Badge variant=\"outline\" className={ticketPriorityBadgeClasses[ticket.priority]}>\n {priorityLabels[ticket.priority] ?? ticket.priority}\n </Badge>\n {reopenCount > 0 && (\n <Badge variant=\"outline\" className=\"text-text-secondary\">\n {tr('support.ticketDetail.reopenCount', 'Reopen {{current}}/{{max}}', {\n current: reopenCount,\n max: MAX_REOPEN_COUNT,\n })}\n </Badge>\n )}\n </div>\n </div>\n <h1 className=\"text-xl font-bold text-text-primary\">{ticket.subject}</h1>\n <p className=\"text-sm text-text-secondary mt-1\">\n #{ticket.ticketNumber} &middot;{' '}\n {tr('support.ticketDetail.meta.created', 'Created {{date}}', {\n date: new Date(ticket.createdAt).toLocaleDateString(),\n })}\n </p>\n {isReopenBlockedByLimit(ticket) && (\n <div className=\"mt-3 rounded-lg border border-warning/40 bg-warning/10 p-3 text-sm text-warning\">\n <p>\n {tr(\n 'support.ticketDetail.errors.reopenLimit',\n 'You have reached the maximum number of reopens for this ticket. Please create a new ticket to continue.'\n )}\n </p>\n <div className=\"mt-3\">\n <Button variant=\"outline\" size=\"sm\" onClick={onCreateNewTicket}>\n {tr('support.ticketDetail.actions.createNewTicket', 'Create New Ticket')}\n </Button>\n </div>\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;AAiBA,IAAMA,IAA+D;CACnE,KAAKC;CACL,aAAaC;CACb,kBAAkBA;CAClB,UAAUC;CACV,QAAQA;CACR,UAAUC;AACZ,GAOaC,KAAmD,EAC9D,WACA,WACA,mBACA,sBACA,qBAAkB,SACd;CACJ,IAAMC,IAAKC,EAAM,GACXC,IAAaR,EAAYS,EAAO,SAChCC,IAAcC,EAAeF,EAAO,QAAQ,GAG5CG,IAAYC,EAAgBJ,CAAM,KAAK,EAAQK,GAE/CC,IAAoD;EACxD,KAAKT,EAAG,6BAA6B,KAAK;EAC1C,aAAaA,EAAG,oCAAoC,aAAa;EACjE,kBAAkBA,EAAG,yCAAyC,qBAAqB;EACnF,UAAUA,EAAG,kCAAkC,UAAU;EACzD,QAAQA,EAAG,gCAAgC,QAAQ;EACnD,UAAUA,EAAG,kCAAkC,UAAU;CAC3D,GAEMU,IAAyC;EAC7C,KAAKV,EAAG,+BAA+B,KAAK;EAC5C,QAAQA,EAAG,kCAAkC,QAAQ;EACrD,MAAMA,EAAG,gCAAgC,MAAM;EAC/C,UAAUA,EAAG,oCAAoC,UAAU;CAC7D;CAEA,OACE,kBAAC,OAAD;EACE,aAAU;EACV,WAAU;EAFZ,UAAA;GAIE,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAACW,GAAD;KAAQ,SAAQ;KAAQ,MAAK;KAAK,SAASC;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AAG,gDAAgD,mBAAmB;KACjE,CAAA;IACL,CAAA,CACF;;EAEJ;;AAET"}
@@ -1 +1 @@
1
- export { Badge, Button, CTAOverflowMenu, Card, CardContent, CardHeader, CardTitle, Checkbox, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, EmphasisPanel, GlassCard, Input, Label, NextSteps, PagePurpose, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Tabs, TabsContent, TabsList, TabsTrigger, Textarea } from "@burdenoff/fe-libs/ui";
1
+ export { Badge, Button, CTAOverflowMenu, Card, CardContent, CardHeader, CardTitle, Checkbox, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, EmphasisPanel, GlassCard, Input, Label, NextSteps, PagePurpose, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Skeleton, Tabs, TabsContent, TabsList, TabsTrigger, Textarea } from "@burdenoff/fe-libs/ui";
@@ -18,3 +18,26 @@ export declare const MAX_REOPEN_COUNT = 3;
18
18
  * output was removed for exactly that reason.
19
19
  */
20
20
  export declare const ATTACHMENTS_FAILED_PARAM = "attachmentsFailed";
21
+ /**
22
+ * Search param the FluidGrids "Ask for help" form adds when it opens the new
23
+ * request, so the request page can say it was sent. A code-only flag, like
24
+ * `ATTACHMENTS_FAILED_PARAM`; the page removes it once the toast is shown.
25
+ */
26
+ export declare const TICKET_CREATED_PARAM = "created";
27
+ /**
28
+ * Search param (or router state key) a host uses to tell "Ask for help" which
29
+ * page the person came from, for example a workflow or run. It is stored in
30
+ * the new ticket's metadata as hidden context and never shown as a field.
31
+ */
32
+ export declare const ASK_FOR_HELP_FROM_PARAM = "from";
33
+ /** Longest "came from" value kept in ticket metadata. */
34
+ export declare const MAX_CAME_FROM_LENGTH = 500;
35
+ /**
36
+ * Client-side minimum lengths. Keep these in lockstep with the server-side
37
+ * validators in global-support-svc/src/modules/support/utils/validation.ts —
38
+ * when the server tightens or loosens these, update them here too. These are
39
+ * best-effort UX hints only; the server's validation error is authoritative
40
+ * and surfaces through `extractErrorMessage` on the catch path.
41
+ */
42
+ export declare const MIN_SUBJECT_LENGTH = 5;
43
+ export declare const MIN_DESCRIPTION_LENGTH = 10;
@@ -1,5 +1,5 @@
1
1
  // src/support/constants.ts
2
- var e = "attachmentsFailed";
3
- export { e as ATTACHMENTS_FAILED_PARAM };
2
+ var e = "attachmentsFailed", t = "created", n = "from";
3
+ export { n as ASK_FOR_HELP_FROM_PARAM, e as ATTACHMENTS_FAILED_PARAM, t as TICKET_CREATED_PARAM };
4
4
 
5
5
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["ATTACHMENTS_FAILED_PARAM"],"sources":["../../src/support/constants.ts"],"sourcesContent":["/**\n * Maximum number of reopens allowed per ticket. Mirrors the server limit\n * enforced in global-support-svc so the client chip / cap banner / reopen\n * button all read from a single source. When the server limit changes,\n * update this constant AND the server check in lockstep (or, ideally,\n * graduate this to a config value the server returns on the ticket).\n */\nexport const MAX_REOPEN_COUNT = 3;\n\n/**\n * Search param used to carry create-ticket attachment-failure signal across\n * the redirect from the create page to the newly-created ticket detail page.\n *\n * Only a code-level flag is surfaced in the URL. The user-facing message is\n * composed entirely client-side in `useAttachmentsFailedToast` so no server-\n * provided text ever lands in the URL, browser history, referer header, or\n * proxy / analytics logs. The original message variant\n * (`attachmentsFailedMessage`) that carried raw `extractErrorMessage(...)`\n * output was removed for exactly that reason.\n */\nexport const ATTACHMENTS_FAILED_PARAM = 'attachmentsFailed';\n"],"mappings":";AAoBA,IAAaA,IAA2B"}
1
+ {"version":3,"file":"constants.js","names":["ATTACHMENTS_FAILED_PARAM","TICKET_CREATED_PARAM","ASK_FOR_HELP_FROM_PARAM"],"sources":["../../src/support/constants.ts"],"sourcesContent":["/**\n * Maximum number of reopens allowed per ticket. Mirrors the server limit\n * enforced in global-support-svc so the client chip / cap banner / reopen\n * button all read from a single source. When the server limit changes,\n * update this constant AND the server check in lockstep (or, ideally,\n * graduate this to a config value the server returns on the ticket).\n */\nexport const MAX_REOPEN_COUNT = 3;\n\n/**\n * Search param used to carry create-ticket attachment-failure signal across\n * the redirect from the create page to the newly-created ticket detail page.\n *\n * Only a code-level flag is surfaced in the URL. The user-facing message is\n * composed entirely client-side in `useAttachmentsFailedToast` so no server-\n * provided text ever lands in the URL, browser history, referer header, or\n * proxy / analytics logs. The original message variant\n * (`attachmentsFailedMessage`) that carried raw `extractErrorMessage(...)`\n * output was removed for exactly that reason.\n */\nexport const ATTACHMENTS_FAILED_PARAM = 'attachmentsFailed';\n\n/**\n * Search param the FluidGrids \"Ask for help\" form adds when it opens the new\n * request, so the request page can say it was sent. A code-only flag, like\n * `ATTACHMENTS_FAILED_PARAM`; the page removes it once the toast is shown.\n */\nexport const TICKET_CREATED_PARAM = 'created';\n\n/**\n * Search param (or router state key) a host uses to tell \"Ask for help\" which\n * page the person came from, for example a workflow or run. It is stored in\n * the new ticket's metadata as hidden context and never shown as a field.\n */\nexport const ASK_FOR_HELP_FROM_PARAM = 'from';\n\n/** Longest \"came from\" value kept in ticket metadata. */\nexport const MAX_CAME_FROM_LENGTH = 500;\n\n/**\n * Client-side minimum lengths. Keep these in lockstep with the server-side\n * validators in global-support-svc/src/modules/support/utils/validation.ts —\n * when the server tightens or loosens these, update them here too. These are\n * best-effort UX hints only; the server's validation error is authoritative\n * and surfaces through `extractErrorMessage` on the catch path.\n */\nexport const MIN_SUBJECT_LENGTH = 5;\nexport const MIN_DESCRIPTION_LENGTH = 10;\n"],"mappings":";AAoBA,IAAaA,IAA2B,qBAO3BC,IAAuB,WAOvBC,IAA0B"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns `value` once it has stopped changing for `delayMs`. Used for search
3
+ * as you type, so a request goes out when the person pauses rather than on
4
+ * every keystroke.
5
+ */
6
+ export declare function useDebouncedValue<T>(value: T, delayMs?: number): T;
@@ -0,0 +1,12 @@
1
+ import { useEffect as e, useState as t } from "react";
2
+ // src/support/hooks/useDebouncedValue.ts
3
+ function n(n, r = 300) {
4
+ let [i, a] = t(n);
5
+ return e(() => {
6
+ let e = setTimeout(() => a(n), r);
7
+ return () => clearTimeout(e);
8
+ }, [n, r]), i;
9
+ }
10
+ export { n as useDebouncedValue };
11
+
12
+ //# sourceMappingURL=useDebouncedValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDebouncedValue.js","names":["useDebouncedValue","debounced","setDebounced","useState","value","useEffect","timer","delayMs"],"sources":["../../../src/support/hooks/useDebouncedValue.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/**\n * Returns `value` once it has stopped changing for `delayMs`. Used for search\n * as you type, so a request goes out when the person pauses rather than on\n * every keystroke.\n */\nexport function useDebouncedValue<T>(value: T, delayMs = 300): T {\n const [debounced, setDebounced] = useState(value);\n\n useEffect(() => {\n const timer = setTimeout(() => setDebounced(value), delayMs);\n return () => clearTimeout(timer);\n }, [value, delayMs]);\n\n return debounced;\n}\n"],"mappings":";;AAOA,SAAgBA,EAAqB,GAAU,IAAU,KAAQ;CAC/D,IAAM,CAACC,GAAWC,KAAgBC,EAASC,CAAK;CAOhD,OALAC,QAAgB;EACd,IAAMC,IAAQ,iBAAiBJ,EAAaE,CAAK,GAAGG,CAAO;EAC3D,aAAa,aAAaD,CAAK;CACjC,GAAG,CAACF,GAAOG,CAAO,CAAC,GAEZN;AACT"}
@@ -1,7 +1,14 @@
1
1
  import { KnowledgeBaseArticle, CreateKnowledgeBaseArticleInput, UpdateKnowledgeBaseArticleInput } from '../../generated/global-types';
2
2
  import { KnowledgeBaseArticleState } from '../store/supportStore';
3
3
  export type { CreateKnowledgeBaseArticleInput, UpdateKnowledgeBaseArticleInput };
4
- export declare function useKnowledgeBaseOperations(articleSlug?: string): {
4
+ export interface UseKnowledgeBaseOperationsOptions {
5
+ /**
6
+ * List only PUBLISHED articles. The user-facing pages set this; the admin
7
+ * pages leave it off so authors still see drafts and archived articles.
8
+ */
9
+ publishedOnly?: boolean;
10
+ }
11
+ export declare function useKnowledgeBaseOperations(articleSlug?: string, options?: UseKnowledgeBaseOperationsOptions): {
5
12
  articles: KnowledgeBaseArticle[];
6
13
  popularArticles: KnowledgeBaseArticle[];
7
14
  categories: any;