@bikdotai/bik-component-library 0.0.838-beta.2 → 0.0.838-beta.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/dist/cjs/components/WhatsAppTextEditor/WhatsAppTextEditor.js +23 -23
- package/dist/cjs/components/WhatsAppTextEditor/WhatsAppTextEditor.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/AiTextArea.js +1 -1
- package/dist/cjs/components/agent-builder/components/AiTextArea.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js +2 -2
- package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js.map +1 -1
- package/dist/cjs/components/bik-chatbot/components/ChatWindow.js +20 -20
- package/dist/cjs/components/bik-chatbot/components/ChatWindow.js.map +1 -1
- package/dist/cjs/editor/BikEditor.js +1 -1
- package/dist/cjs/editor/BikEditor.js.map +1 -1
- package/dist/cjs/editor/BikEditor.utils.js +3 -3
- package/dist/cjs/editor/BikEditor.utils.js.map +1 -1
- package/dist/esm/components/WhatsAppTextEditor/WhatsAppTextEditor.js +144 -143
- package/dist/esm/components/WhatsAppTextEditor/WhatsAppTextEditor.js.map +1 -1
- package/dist/esm/components/agent-builder/components/AiTextArea.js +24 -23
- package/dist/esm/components/agent-builder/components/AiTextArea.js.map +1 -1
- package/dist/esm/components/agent-builder/components/ToolInstructionsField.js +31 -30
- package/dist/esm/components/agent-builder/components/ToolInstructionsField.js.map +1 -1
- package/dist/esm/components/bik-chatbot/components/ChatWindow.js +54 -53
- package/dist/esm/components/bik-chatbot/components/ChatWindow.js.map +1 -1
- package/dist/esm/editor/BikEditor.js +122 -118
- package/dist/esm/editor/BikEditor.js.map +1 -1
- package/dist/esm/editor/BikEditor.utils.d.ts +1 -1
- package/dist/esm/editor/BikEditor.utils.js +111 -111
- package/dist/esm/editor/BikEditor.utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiTextArea.js","sources":["../../../../../src/components/agent-builder/components/AiTextArea.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { BodyCaption, TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAiTextAreaInput,\n\tAiTextAreaShell,\n\tFieldBlock,\n\tFieldLabelRow,\n} from '../AgentBuilder.styled';\n\ninterface AiTextAreaProps {\n\tlabel: string;\n\tvalue: string;\n\tonChange: (value: string) => void;\n\tmaxLength: number;\n\tplaceholder?: string;\n\tminHeight?: string;\n\tdisabled?: boolean;\n\t'data-test'?: string;\n}\n\n/** Labelled textarea with a live character counter. */\nexport const AiTextArea: React.FC<AiTextAreaProps> = ({\n\tlabel,\n\tvalue,\n\tonChange,\n\tmaxLength,\n\tplaceholder,\n\tminHeight,\n\tdisabled,\n\t...rest\n}) => {\n\tconst [focused, setFocused] = useState(false);\n\n\treturn (\n\t\t<FieldBlock>\n\t\t\t<FieldLabelRow>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>{label}</TitleSmall>\n\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t{value.length}/{maxLength}\n\t\t\t\t</BodyCaption>\n\t\t\t</FieldLabelRow>\n\n\t\t\t<AiTextAreaShell focused={focused} minHeight={minHeight}>\n\t\t\t\t<AiTextAreaInput\n\t\t\t\t\tdata-test={rest['data-test']}\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\tmaxLength={maxLength}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tonFocus={() => setFocused(true)}\n\t\t\t\t\tonBlur={() => setFocused(false)}\n\t\t\t\t\tonChange={(e) => onChange(e.target.value)}\n\t\t\t\t/>\n\t\t\t</AiTextAreaShell>\n\t\t</FieldBlock>\n\t);\n};\n"],"names":["AiTextArea","label","value","onChange","maxLength","placeholder","minHeight","disabled","rest","focused","setFocused","useState","FieldBlock","jsxs","FieldLabelRow","jsx","TitleSmall","COLORS","BodyCaption","AiTextAreaShell","AiTextAreaInput","e"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AiTextArea.js","sources":["../../../../../src/components/agent-builder/components/AiTextArea.tsx"],"sourcesContent":["import { stripHtmlTags } from '@src/helpers/sanitize';\nimport React, { useState } from 'react';\nimport { BodyCaption, TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAiTextAreaInput,\n\tAiTextAreaShell,\n\tFieldBlock,\n\tFieldLabelRow,\n} from '../AgentBuilder.styled';\n\ninterface AiTextAreaProps {\n\tlabel: string;\n\tvalue: string;\n\tonChange: (value: string) => void;\n\tmaxLength: number;\n\tplaceholder?: string;\n\tminHeight?: string;\n\tdisabled?: boolean;\n\t'data-test'?: string;\n}\n\n/** Labelled textarea with a live character counter. */\nexport const AiTextArea: React.FC<AiTextAreaProps> = ({\n\tlabel,\n\tvalue,\n\tonChange,\n\tmaxLength,\n\tplaceholder,\n\tminHeight,\n\tdisabled,\n\t...rest\n}) => {\n\tconst [focused, setFocused] = useState(false);\n\n\treturn (\n\t\t<FieldBlock>\n\t\t\t<FieldLabelRow>\n\t\t\t\t<TitleSmall color={COLORS.content.primary}>{label}</TitleSmall>\n\t\t\t\t<BodyCaption color={COLORS.content.secondary}>\n\t\t\t\t\t{value.length}/{maxLength}\n\t\t\t\t</BodyCaption>\n\t\t\t</FieldLabelRow>\n\n\t\t\t<AiTextAreaShell focused={focused} minHeight={minHeight}>\n\t\t\t\t<AiTextAreaInput\n\t\t\t\t\tdata-test={rest['data-test']}\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\tmaxLength={maxLength}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tonFocus={() => setFocused(true)}\n\t\t\t\t\tonBlur={() => setFocused(false)}\n\t\t\t\t\tonChange={(e) => onChange(stripHtmlTags(e.target.value))}\n\t\t\t\t/>\n\t\t\t</AiTextAreaShell>\n\t\t</FieldBlock>\n\t);\n};\n"],"names":["AiTextArea","label","value","onChange","maxLength","placeholder","minHeight","disabled","rest","focused","setFocused","useState","FieldBlock","jsxs","FieldLabelRow","jsx","TitleSmall","COLORS","BodyCaption","AiTextAreaShell","AiTextAreaInput","e","stripHtmlTags"],"mappings":"wSAuBaA,EAAwC,CAAC,CACrD,MAAAC,EACA,MAAAC,EACA,SAAAC,EACA,UAAAC,EACA,YAAAC,EACA,UAAAC,EACA,SAAAC,EACA,GAAGC,CACJ,IAAM,CACL,KAAM,CAACC,EAASC,CAAU,EAAIC,EAAAA,SAAS,EAAK,EAE5C,cACEC,aAAA,CACA,SAAA,CAAAC,OAACC,EAAAA,cAAA,CACA,SAAA,CAAAC,MAACC,EAAAA,WAAA,CAAW,MAAOC,EAAAA,OAAO,QAAQ,QAAU,SAAAhB,EAAM,EAClDY,EAAAA,KAACK,EAAAA,YAAA,CAAY,MAAOD,EAAAA,OAAO,QAAQ,UACjC,SAAA,CAAAf,EAAM,OAAO,IAAEE,CAAA,CAAA,CACjB,CAAA,EACD,EAEAW,EAAAA,IAACI,EAAAA,gBAAA,CAAgB,QAAAV,EAAkB,UAAAH,EAClC,SAAAS,EAAAA,IAACK,EAAAA,gBAAA,CACA,YAAWZ,EAAK,WAAW,EAC3B,MAAAN,EACA,YAAAG,EACA,UAAAD,EACA,SAAAG,EACA,QAAS,IAAMG,EAAW,EAAI,EAC9B,OAAQ,IAAMA,EAAW,EAAK,EAC9B,SAAWW,GAAMlB,EAASmB,EAAAA,cAAcD,EAAE,OAAO,KAAK,CAAC,CAAA,CAAA,CACxD,CACD,CAAA,EACD,CAEF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("../../../helpers/sanitize.js"),u=require("react"),h=require("styled-components"),T=require("../../TypographyStyle.js"),j=require("../../../constants/Theme.js"),r=require("../AgentBuilder.styled.js"),q=require("../../button/Button.js"),S=require("../../../icons/BIK AI specific/WandSparkles.js"),I=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},b=I(h),A=({label:t,value:s,onChange:o,maxLength:d,placeholder:p,minHeight:f="120px",onImprove:n,...l})=>{const[m,a]=u.useState(!1),[i,c]=u.useState(!1),y=async()=>{if(!(!n||i||s.trim().length===0)){c(!0);try{o(await n(s))}finally{c(!1)}}};return e.jsxs(r.FieldBlock,{children:[e.jsx(T.TitleSmall,{color:j.COLORS.content.primary,children:t}),e.jsxs(r.AiTextAreaShell,{focused:m,minHeight:f,children:[e.jsx(r.AiTextAreaInput,{"data-test":l["data-test"],value:s,placeholder:p,maxLength:d,onFocus:()=>a(!0),onBlur:()=>a(!1),onChange:g=>o(x.stripHtmlTags(g.target.value))}),n&&e.jsx(B,{children:e.jsx(q.Button,{"data-test":`${l["data-test"]??"tool"}-improve`,buttonType:"ai",size:"small",LeadingIcon:S.default,buttonText:"Improve with AI",isLoading:i,disabled:i||s.trim().length===0,onClick:y})})]})]})},B=b.default.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
|
-
`;exports.ToolInstructionsField=
|
|
4
|
+
`;exports.ToolInstructionsField=A;
|
|
5
5
|
//# sourceMappingURL=ToolInstructionsField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolInstructionsField.js","sources":["../../../../../src/components/agent-builder/components/ToolInstructionsField.tsx"],"sourcesContent":["import { WandSparkles } from '@src/icons';\nimport React, { useState } from 'react';\nimport styled from 'styled-components';\nimport { Button } from '@src/components/button';\nimport { TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAiTextAreaInput,\n\tAiTextAreaShell,\n\tFieldBlock,\n} from '../AgentBuilder.styled';\n\ninterface ToolInstructionsFieldProps {\n\tlabel: string;\n\tvalue: string;\n\tonChange: (value: string) => void;\n\tmaxLength: number;\n\tplaceholder?: string;\n\tminHeight?: string;\n\t/** \"Improve with AI\" — resolves with rewritten text. Omit to hide the button. */\n\tonImprove?: (text: string) => Promise<string>;\n\t'data-test'?: string;\n}\n\n/**\n * A labelled multiline field with an inline \"Improve with AI\" action pinned to\n * the bottom-left of the box (Figma: Rest API / Handover-to-email drawers). The\n * button is hidden when `onImprove` is omitted.\n */\nexport const ToolInstructionsField: React.FC<ToolInstructionsFieldProps> = ({\n\tlabel,\n\tvalue,\n\tonChange,\n\tmaxLength,\n\tplaceholder,\n\tminHeight = '120px',\n\tonImprove,\n\t...rest\n}) => {\n\tconst [focused, setFocused] = useState(false);\n\tconst [improving, setImproving] = useState(false);\n\n\tconst handleImprove = async () => {\n\t\tif (!onImprove || improving || value.trim().length === 0) {\n\t\t\treturn;\n\t\t}\n\t\tsetImproving(true);\n\t\ttry {\n\t\t\tonChange(await onImprove(value));\n\t\t} finally {\n\t\t\tsetImproving(false);\n\t\t}\n\t};\n\n\treturn (\n\t\t<FieldBlock>\n\t\t\t<TitleSmall color={COLORS.content.primary}>{label}</TitleSmall>\n\t\t\t<AiTextAreaShell focused={focused} minHeight={minHeight}>\n\t\t\t\t<AiTextAreaInput\n\t\t\t\t\tdata-test={rest['data-test']}\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\tmaxLength={maxLength}\n\t\t\t\t\tonFocus={() => setFocused(true)}\n\t\t\t\t\tonBlur={() => setFocused(false)}\n\t\t\t\t\tonChange={(e) => onChange(e.target.value)}\n\t\t\t\t/>\n\t\t\t\t{onImprove && (\n\t\t\t\t\t<ImproveRow>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tdata-test={`${rest['data-test'] ?? 'tool'}-improve`}\n\t\t\t\t\t\t\tbuttonType=\"ai\"\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\tLeadingIcon={WandSparkles}\n\t\t\t\t\t\t\tbuttonText=\"Improve with AI\"\n\t\t\t\t\t\t\tisLoading={improving}\n\t\t\t\t\t\t\tdisabled={improving || value.trim().length === 0}\n\t\t\t\t\t\t\tonClick={handleImprove}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ImproveRow>\n\t\t\t\t)}\n\t\t\t</AiTextAreaShell>\n\t\t</FieldBlock>\n\t);\n};\n\nconst ImproveRow = styled.div`\n\tdisplay: flex;\n\talign-items: center;\n`;\n"],"names":["ToolInstructionsField","label","value","onChange","maxLength","placeholder","minHeight","onImprove","rest","focused","setFocused","useState","improving","setImproving","handleImprove","FieldBlock","jsx","TitleSmall","COLORS","jsxs","AiTextAreaShell","AiTextAreaInput","e","ImproveRow","Button","WandSparkles","styled"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ToolInstructionsField.js","sources":["../../../../../src/components/agent-builder/components/ToolInstructionsField.tsx"],"sourcesContent":["import { stripHtmlTags } from '@src/helpers/sanitize';\nimport { WandSparkles } from '@src/icons';\nimport React, { useState } from 'react';\nimport styled from 'styled-components';\nimport { Button } from '@src/components/button';\nimport { TitleSmall } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tAiTextAreaInput,\n\tAiTextAreaShell,\n\tFieldBlock,\n} from '../AgentBuilder.styled';\n\ninterface ToolInstructionsFieldProps {\n\tlabel: string;\n\tvalue: string;\n\tonChange: (value: string) => void;\n\tmaxLength: number;\n\tplaceholder?: string;\n\tminHeight?: string;\n\t/** \"Improve with AI\" — resolves with rewritten text. Omit to hide the button. */\n\tonImprove?: (text: string) => Promise<string>;\n\t'data-test'?: string;\n}\n\n/**\n * A labelled multiline field with an inline \"Improve with AI\" action pinned to\n * the bottom-left of the box (Figma: Rest API / Handover-to-email drawers). The\n * button is hidden when `onImprove` is omitted.\n */\nexport const ToolInstructionsField: React.FC<ToolInstructionsFieldProps> = ({\n\tlabel,\n\tvalue,\n\tonChange,\n\tmaxLength,\n\tplaceholder,\n\tminHeight = '120px',\n\tonImprove,\n\t...rest\n}) => {\n\tconst [focused, setFocused] = useState(false);\n\tconst [improving, setImproving] = useState(false);\n\n\tconst handleImprove = async () => {\n\t\tif (!onImprove || improving || value.trim().length === 0) {\n\t\t\treturn;\n\t\t}\n\t\tsetImproving(true);\n\t\ttry {\n\t\t\tonChange(await onImprove(value));\n\t\t} finally {\n\t\t\tsetImproving(false);\n\t\t}\n\t};\n\n\treturn (\n\t\t<FieldBlock>\n\t\t\t<TitleSmall color={COLORS.content.primary}>{label}</TitleSmall>\n\t\t\t<AiTextAreaShell focused={focused} minHeight={minHeight}>\n\t\t\t\t<AiTextAreaInput\n\t\t\t\t\tdata-test={rest['data-test']}\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\tmaxLength={maxLength}\n\t\t\t\t\tonFocus={() => setFocused(true)}\n\t\t\t\t\tonBlur={() => setFocused(false)}\n\t\t\t\t\tonChange={(e) => onChange(stripHtmlTags(e.target.value))}\n\t\t\t\t/>\n\t\t\t\t{onImprove && (\n\t\t\t\t\t<ImproveRow>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tdata-test={`${rest['data-test'] ?? 'tool'}-improve`}\n\t\t\t\t\t\t\tbuttonType=\"ai\"\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\tLeadingIcon={WandSparkles}\n\t\t\t\t\t\t\tbuttonText=\"Improve with AI\"\n\t\t\t\t\t\t\tisLoading={improving}\n\t\t\t\t\t\t\tdisabled={improving || value.trim().length === 0}\n\t\t\t\t\t\t\tonClick={handleImprove}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ImproveRow>\n\t\t\t\t)}\n\t\t\t</AiTextAreaShell>\n\t\t</FieldBlock>\n\t);\n};\n\nconst ImproveRow = styled.div`\n\tdisplay: flex;\n\talign-items: center;\n`;\n"],"names":["ToolInstructionsField","label","value","onChange","maxLength","placeholder","minHeight","onImprove","rest","focused","setFocused","useState","improving","setImproving","handleImprove","FieldBlock","jsx","TitleSmall","COLORS","jsxs","AiTextAreaShell","AiTextAreaInput","e","stripHtmlTags","ImproveRow","Button","WandSparkles","styled"],"mappings":"seA8BaA,EAA8D,CAAC,CAC3E,MAAAC,EACA,MAAAC,EACA,SAAAC,EACA,UAAAC,EACA,YAAAC,EACA,UAAAC,EAAY,QACZ,UAAAC,EACA,GAAGC,CACJ,IAAM,CACL,KAAM,CAACC,EAASC,CAAU,EAAIC,EAAAA,SAAS,EAAK,EACtC,CAACC,EAAWC,CAAY,EAAIF,EAAAA,SAAS,EAAK,EAE1CG,EAAgB,SAAY,CACjC,GAAI,GAACP,GAAaK,GAAaV,EAAM,KAAA,EAAO,SAAW,GAGvD,CAAAW,EAAa,EAAI,EACjB,GAAI,CACHV,EAAS,MAAMI,EAAUL,CAAK,CAAC,CAChC,QAAA,CACCW,EAAa,EAAK,CACnB,EACD,EAEA,cACEE,aAAA,CACA,SAAA,CAAAC,MAACC,EAAAA,WAAA,CAAW,MAAOC,EAAAA,OAAO,QAAQ,QAAU,SAAAjB,EAAM,EAClDkB,EAAAA,KAACC,EAAAA,gBAAA,CAAgB,QAAAX,EAAkB,UAAAH,EAClC,SAAA,CAAAU,EAAAA,IAACK,EAAAA,gBAAA,CACA,YAAWb,EAAK,WAAW,EAC3B,MAAAN,EACA,YAAAG,EACA,UAAAD,EACA,QAAS,IAAMM,EAAW,EAAI,EAC9B,OAAQ,IAAMA,EAAW,EAAK,EAC9B,SAAWY,GAAMnB,EAASoB,EAAAA,cAAcD,EAAE,OAAO,KAAK,CAAC,CAAA,CAAA,EAEvDf,SACCiB,EAAA,CACA,SAAAR,EAAAA,IAACS,EAAAA,OAAA,CACA,YAAW,GAAGjB,EAAK,WAAW,GAAK,MAAM,WACzC,WAAW,KACX,KAAK,QACL,YAAakB,EAAAA,QACb,WAAW,kBACX,UAAWd,EACX,SAAUA,GAAaV,EAAM,KAAA,EAAO,SAAW,EAC/C,QAASY,CAAA,CAAA,CACV,CACD,CAAA,CAAA,CAEF,CAAA,EACD,CAEF,EAEMU,EAAaG,EAAAA,QAAO;AAAA;AAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),H=require("../../../assets/icons/Ai_event_generating.svg.js"),G=require("../../../helpers/sanitize.js"),o=require("react"),L=require("styled-components"),F=require("../../TypographyStyle.js"),V=require("../utils/markdown.js"),W=require("./ThinkingIndicator.js"),K=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},n=K(L),P=n.default.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
width: 100%;
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
`;default:return`
|
|
19
19
|
background: white;
|
|
20
20
|
`}}}
|
|
21
|
-
`,
|
|
21
|
+
`,E=n.default.div`
|
|
22
22
|
padding: 16px;
|
|
23
23
|
border-bottom: 1px solid #e5e7eb;
|
|
24
24
|
display: flex;
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
font-weight: 500;
|
|
33
33
|
color: #374151;
|
|
34
34
|
}
|
|
35
|
-
`,
|
|
35
|
+
`,N=n.default.div`
|
|
36
36
|
flex: 1;
|
|
37
37
|
display: flex;
|
|
38
38
|
flex-direction: column;
|
|
39
39
|
overflow: hidden;
|
|
40
40
|
min-height: 0;
|
|
41
|
-
`,
|
|
41
|
+
`,O=n.default.div`
|
|
42
42
|
flex: 1;
|
|
43
43
|
overflow-y: auto;
|
|
44
44
|
padding: 16px;
|
|
@@ -67,13 +67,13 @@
|
|
|
67
67
|
&::-webkit-scrollbar-thumb:hover {
|
|
68
68
|
background: #a8a8a8;
|
|
69
69
|
}
|
|
70
|
-
`,
|
|
70
|
+
`,J=n.default.div`
|
|
71
71
|
background: white;
|
|
72
72
|
border-radius: 12px;
|
|
73
73
|
padding: 16px;
|
|
74
74
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
75
75
|
border: 1px solid #e5e7eb;
|
|
76
|
-
`,
|
|
76
|
+
`,Q=n.default.div`
|
|
77
77
|
width: 100%;
|
|
78
78
|
height: 180px;
|
|
79
79
|
background: #f3f4f6;
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
justify-content: center;
|
|
84
84
|
position: relative;
|
|
85
85
|
margin-bottom: 12px;
|
|
86
|
-
`,
|
|
86
|
+
`,U=n.default.div`
|
|
87
87
|
width: 48px;
|
|
88
88
|
height: 48px;
|
|
89
89
|
background: rgba(0, 0, 0, 0.7);
|
|
@@ -105,11 +105,11 @@
|
|
|
105
105
|
fill: white;
|
|
106
106
|
margin-left: 2px;
|
|
107
107
|
}
|
|
108
|
-
`,
|
|
108
|
+
`,X=n.default.div`
|
|
109
109
|
font-size: 14px;
|
|
110
110
|
color: #374151;
|
|
111
111
|
line-height: 1.5;
|
|
112
|
-
`,
|
|
112
|
+
`,Y=n.default.div`
|
|
113
113
|
padding: 12px 16px;
|
|
114
114
|
border-radius: 16px;
|
|
115
115
|
font-size: 14px;
|
|
@@ -145,15 +145,15 @@
|
|
|
145
145
|
border-bottom-left-radius: 4px;
|
|
146
146
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
147
147
|
`}
|
|
148
|
-
`,
|
|
148
|
+
`,Z=n.default.div`
|
|
149
149
|
padding: 16px;
|
|
150
150
|
flex-shrink: 0;
|
|
151
|
-
`,
|
|
151
|
+
`,ee=n.default.div`
|
|
152
152
|
display: flex;
|
|
153
153
|
flex-direction: column;
|
|
154
154
|
gap: 8px;
|
|
155
155
|
align-items: flex-end;
|
|
156
|
-
`,
|
|
156
|
+
`,te=n.default.button`
|
|
157
157
|
border: 1px dotted #febad2;
|
|
158
158
|
background: linear-gradient(
|
|
159
159
|
92.69deg,
|
|
@@ -182,14 +182,14 @@
|
|
|
182
182
|
&:active:not(:disabled) {
|
|
183
183
|
transform: scale(0.98);
|
|
184
184
|
}
|
|
185
|
-
`,
|
|
185
|
+
`,ie=n.default.div`
|
|
186
186
|
padding: 16px;
|
|
187
187
|
background: white;
|
|
188
|
-
`,
|
|
188
|
+
`,ne=n.default.div`
|
|
189
189
|
display: flex;
|
|
190
190
|
flex-direction: column;
|
|
191
191
|
gap: 8px;
|
|
192
|
-
`,
|
|
192
|
+
`,re=n.default.button`
|
|
193
193
|
background: #fef2f2;
|
|
194
194
|
color: #dc2626;
|
|
195
195
|
padding: 12px 16px;
|
|
@@ -209,14 +209,14 @@
|
|
|
209
209
|
&:active:not(:disabled) {
|
|
210
210
|
transform: scale(0.98);
|
|
211
211
|
}
|
|
212
|
-
`,
|
|
212
|
+
`,ae=n.default.div`
|
|
213
213
|
padding: 16px;
|
|
214
214
|
flex-shrink: 0;
|
|
215
|
-
`,
|
|
215
|
+
`,oe=n.default.div`
|
|
216
216
|
position: relative;
|
|
217
217
|
display: flex;
|
|
218
218
|
width: 100%;
|
|
219
|
-
`,
|
|
219
|
+
`,de=n.default.textarea`
|
|
220
220
|
flex: 1;
|
|
221
221
|
border: 1px solid ${e=>e.hasText?"#3b82f6":"#d1d5db"};
|
|
222
222
|
border-radius: 12px;
|
|
@@ -243,7 +243,7 @@
|
|
|
243
243
|
&::placeholder {
|
|
244
244
|
color: #9ca3af;
|
|
245
245
|
}
|
|
246
|
-
`,
|
|
246
|
+
`,le=n.default.button`
|
|
247
247
|
position: absolute;
|
|
248
248
|
bottom: 10px;
|
|
249
249
|
right: 10px;
|
|
@@ -284,5 +284,5 @@
|
|
|
284
284
|
-webkit-text-fill-color: transparent;
|
|
285
285
|
background-clip: text;
|
|
286
286
|
display: inline-block;
|
|
287
|
-
`,
|
|
287
|
+
`,se=({messages:e,onSend:u,header:S="Create with AI",placeholder:T="Discover the right event & launch campaigns for better conversions...",suggestions:g=["Top festivals for marketing","Top events this week?","Top August festivals near you"],iceBreakers:h,videoStarter:l,disabled:I=!1,isThinking:s=!1,onIceBreakerClick:$,chatState:b,chatWindowHeight:z,inputDisabled:M=!1})=>{const[a,w]=o.useState(""),[c,k]=o.useState(!1),[B,_]=o.useState(!1),m=o.useRef(null),v=o.useRef(null),p=c||s,r=I||M,d=b||(c||s?"thinking":B&&a.trim().length>0?"typing":e.length===0?"conversation-starter":e.length>0?"conversation":"default"),y=()=>{!a.trim()||r||p||(u(a),w(""),k(!0),setTimeout(()=>k(!1),1500))},q=i=>{r||i.key==="Enter"&&!i.shiftKey&&(i.preventDefault(),!p&&a.trim()&&y())},A=i=>{if(r)return;const j=G.stripHtmlTags(i.target.value);w(j),_(j.trim().length>0);const x=v.current;x&&(x.style.height="auto",x.style.height=`${Math.min(x.scrollHeight,117)}px`)},f=a.trim().length>0,D=r||p||!f;o.useEffect(()=>{m.current?.scrollIntoView({behavior:"smooth"})},[e,c,s]);const R=z||"100%";return t.jsxs(P,{chatState:d,style:{height:R},children:[t.jsxs(E,{children:[t.jsx(H.default,{height:24,width:24}),t.jsx("div",{className:"header-text",children:S})]}),t.jsxs(N,{children:[t.jsxs(O,{children:[d==="conversation-starter"&&l&&t.jsxs(J,{children:[t.jsx(Q,{children:t.jsx(U,{onClick:l.onPlay,children:t.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("path",{d:"M8 5v14l11-7z"})})})}),t.jsxs(X,{children:[t.jsx(F.BodySecondary,{style:{fontWeight:500,marginBottom:"4px"},children:l.title}),t.jsx(F.BodyCaption,{children:l.description})]})]}),e.map(i=>t.jsx(Y,{role:i.role,children:i.role==="assistant"?t.jsx("div",{dangerouslySetInnerHTML:{__html:V.renderMarkdownLite(i.content)}}):t.jsx("div",{style:{whiteSpace:"pre-wrap"},children:i.content})},i.id)),(c||s)&&t.jsx(W.default,{}),t.jsx("div",{ref:m})]}),h&&d==="conversation-starter"&&t.jsx(Z,{children:t.jsx(ee,{children:h.map(i=>t.jsx(te,{disabled:r,onClick:()=>{r||($?.(i),u(i.text))},children:t.jsx(C,{children:i.text})},i.id))})}),!h&&g.length>0&&d==="default"&&t.jsx(ie,{children:t.jsx(ne,{children:g.map(i=>t.jsx(re,{disabled:r,onClick:()=>!r&&u(i),children:i},i))})}),t.jsx(ae,{children:t.jsxs(oe,{children:[t.jsx(de,{ref:v,value:a,onChange:A,placeholder:T,onKeyDown:q,disabled:r,hasText:f,chatState:d}),t.jsx(le,{onClick:y,disabled:D,hasText:f,"aria-label":"Send",children:t.jsxs("svg",{viewBox:"0 0 24 24",width:"20",height:"20",stroke:"white",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M6 12h12"}),t.jsx("path",{d:"M12 6l6 6-6 6"})]})})]})})]})]})};exports.CustomGradientText=C;exports.default=se;
|
|
288
288
|
//# sourceMappingURL=ChatWindow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatWindow.js","sources":["../../../../../src/components/bik-chatbot/components/ChatWindow.tsx"],"sourcesContent":["import AiIcon from '@src/assets/icons/Ai_event_generating.svg';\nimport React, { useEffect, useRef, useState } from 'react';\nimport styled from 'styled-components';\nimport { BodyCaption, BodySecondary } from '@src/components/TypographyStyle';\nimport { ChatState, ChatWindowProps } from '../types';\nimport { renderMarkdownLite } from '../utils/markdown';\nimport ThinkingIndicator from './ThinkingIndicator';\n\n// Single-column layout container\nconst ChatContainer = styled.div<{ chatState: ChatState }>`\n\tdisplay: flex;\n\tflex-direction: column;\n\twidth: 100%;\n\tmin-width: 0;\n\tmin-height: 0;\n\theight: 100%;\n\tmax-height: 100%;\n\tbackground: white;\n\tborder-left: 1px solid #e5e7eb;\n\tposition: relative;\n\n\t/* State-based styling */\n\t${(props) => {\n\t\tswitch (props.chatState) {\n\t\t\tcase 'conversation-starter':\n\t\t\t\treturn `\n background: linear-gradient(180deg, #FFF6F9 0%, #FFFFFF 100%);\n `;\n\t\t\tcase 'thinking':\n\t\t\t\treturn `\n background: linear-gradient(180deg, #F8F9FA 0%, #FFFFFF 100%);\n `;\n\t\t\tdefault:\n\t\t\t\treturn `\n background: white;\n `;\n\t\t}\n\t}}\n`;\n\nconst Header = styled.div`\n\tpadding: 16px;\n\tborder-bottom: 1px solid #e5e7eb;\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\tbackground: white;\n\tflex-shrink: 0;\n\n\t.header-text {\n\t\tfont-size: 14px;\n\t\tfont-weight: 500;\n\t\tcolor: #374151;\n\t}\n`;\n\n// Main content area - single column\nconst MainContent = styled.div`\n\tflex: 1;\n\tdisplay: flex;\n\tflex-direction: column;\n\toverflow: hidden;\n\tmin-height: 0;\n`;\n\nconst MessagesWrapper = styled.div`\n\tflex: 1;\n\toverflow-y: auto;\n\tpadding: 16px;\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 16px;\n\tbackground: #fafafa;\n\tscroll-behavior: smooth;\n\tmin-height: 0;\n\n\t/* Custom scrollbar */\n\t&::-webkit-scrollbar {\n\t\twidth: 6px;\n\t}\n\n\t&::-webkit-scrollbar-track {\n\t\tbackground: #f1f1f1;\n\t\tborder-radius: 3px;\n\t}\n\n\t&::-webkit-scrollbar-thumb {\n\t\tbackground: #c1c1c1;\n\t\tborder-radius: 3px;\n\t}\n\n\t&::-webkit-scrollbar-thumb:hover {\n\t\tbackground: #a8a8a8;\n\t}\n`;\n\nconst VideoCard = styled.div`\n\tbackground: white;\n\tborder-radius: 12px;\n\tpadding: 16px;\n\tbox-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n\tborder: 1px solid #e5e7eb;\n`;\n\nconst VideoContainer = styled.div`\n\twidth: 100%;\n\theight: 180px;\n\tbackground: #f3f4f6;\n\tborder-radius: 8px;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tposition: relative;\n\tmargin-bottom: 12px;\n`;\n\nconst PlayButton = styled.div`\n\twidth: 48px;\n\theight: 48px;\n\tbackground: rgba(0, 0, 0, 0.7);\n\tborder-radius: 50%;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tcursor: pointer;\n\ttransition: all 0.2s ease;\n\n\t&:hover {\n\t\tbackground: rgba(0, 0, 0, 0.8);\n\t\ttransform: scale(1.05);\n\t}\n\n\tsvg {\n\t\twidth: 16px;\n\t\theight: 16px;\n\t\tfill: white;\n\t\tmargin-left: 2px;\n\t}\n`;\n\nconst VideoText = styled.div`\n\tfont-size: 14px;\n\tcolor: #374151;\n\tline-height: 1.5;\n`;\n\nconst Bubble = styled.div<{ role: 'user' | 'assistant' | 'system' }>`\n\tpadding: 12px 16px;\n\tborder-radius: 16px;\n\tfont-size: 14px;\n\tmax-width: 80%;\n\twhite-space: pre-line;\n\tword-wrap: break-word;\n\n\t${(props) =>\n\t\tprops.role === 'user'\n\t\t\t? `\n background: linear-gradient(92.69deg, rgba(255, 230, 238, 0.5) 0.37%, rgba(255, 240, 231, 0.5) 100%);\n margin-left: auto;\n border-bottom-right-radius: 4px;\n \n & > div {\n background: linear-gradient(92.69deg, #FF166A 0.37%, #FB5F08 100%);\n -webkit-background-clip: text;\n -webkit-text-fill-color: transparent;\n background-clip: text;\n display: inline-block;\n }\n `\n\t\t\t: props.role === 'system'\n\t\t\t? `\n background: #f3f4f6;\n color: #6b7280;\n font-size: 12px;\n font-style: italic;\n text-align: center;\n margin: 0 auto;\n max-width: 90%;\n `\n\t\t\t: `\n background: white;\n color: #111827;\n border: 1px solid #e5e7eb;\n margin-right: auto;\n border-bottom-left-radius: 4px;\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);\n `}\n`;\n\n// Ice breakers section - at the bottom before input\nconst IceBreakersSection = styled.div`\n\tpadding: 16px;\n\tflex-shrink: 0;\n`;\n\nconst IceBreakersGrid = styled.div`\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n\talign-items: flex-end;\n`;\n\nconst IceBreakerChip = styled.button<{ disabled?: boolean }>`\n\tborder: 1px dotted #febad2;\n\tbackground: linear-gradient(\n\t\t92.69deg,\n\t\trgba(255, 230, 238, 0.5) 0.37%,\n\t\trgba(255, 240, 231, 0.5) 100%\n\t);\n\tpadding: 8px 16px;\n\tborder-radius: 8px;\n\tfont-size: 13px;\n\tcursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};\n\ttransition: all 0.2s ease;\n\ttext-align: left;\n\tmax-width: 280px;\n\talign-self: flex-end;\n\topacity: ${(props) => (props.disabled ? 0.5 : 1)};\n\n\t&:hover:not(:disabled) {\n\t\tbackground: linear-gradient(\n\t\t\t92.69deg,\n\t\t\trgba(255, 230, 238, 0.7) 0.37%,\n\t\t\trgba(255, 240, 231, 0.7) 100%\n\t\t);\n\t\tborder-color: #f472b6;\n\t}\n\n\t&:active:not(:disabled) {\n\t\ttransform: scale(0.98);\n\t}\n`;\n\n// Suggestions section - styled like ice breakers but for regular suggestions\nconst SuggestionsSection = styled.div`\n\tpadding: 16px;\n\tbackground: white;\n`;\n\nconst SuggestionsGrid = styled.div`\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n`;\n\nconst SuggestionChip = styled.button<{ disabled?: boolean }>`\n\tbackground: #fef2f2;\n\tcolor: #dc2626;\n\tpadding: 12px 16px;\n\tborder-radius: 8px;\n\tfont-size: 13px;\n\tborder: 1px solid #fecaca;\n\tcursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};\n\ttransition: all 0.2s ease;\n\ttext-align: left;\n\topacity: ${(props) => (props.disabled ? 0.5 : 1)};\n\n\t&:hover:not(:disabled) {\n\t\tbackground: #fee2e2;\n\t\tborder-color: #fca5a5;\n\t}\n\n\t&:active:not(:disabled) {\n\t\ttransform: scale(0.98);\n\t}\n`;\n\nconst InputContainer = styled.div`\n\tpadding: 16px;\n\tflex-shrink: 0;\n`;\n\nconst InputBubble = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n\twidth: 100%;\n`;\n\nconst TextInput = styled.textarea<{ hasText: boolean; chatState: ChatState }>`\n\tflex: 1;\n\tborder: 1px solid ${(props) => (props.hasText ? '#3b82f6' : '#d1d5db')};\n\tborder-radius: 12px;\n\tpadding: 12px;\n\tpadding-right: 48px;\n\tfont-size: 14px;\n\toutline: none;\n\tcolor: #374151;\n\tbackground: white;\n\tbox-shadow: 0px 2px 8px 0px #0000001f;\n\ttransition: all 0.2s ease;\n\tresize: none;\n\tmin-height: 44px;\n\tmax-height: 120px;\n\tfont-family: inherit;\n\twidth: 100%;\n\n\t&:focus {\n\t\tborder-color: #3b82f6;\n\t\tbackground: white;\n\t\tbox-shadow: 0px 2px 8px 0px #0000001f, 0 0 0 3px rgba(59, 130, 246, 0.1);\n\t}\n\n\t&::placeholder {\n\t\tcolor: #9ca3af;\n\t}\n`;\n\nconst SendButton = styled.button<{ disabled?: boolean; hasText: boolean }>`\n\tposition: absolute;\n\tbottom: 10px;\n\tright: 10px;\n\twidth: 36px;\n\theight: 36px;\n\tborder-radius: 50%;\n\tbackground: ${(props) =>\n\t\tprops.hasText\n\t\t\t? 'linear-gradient(135deg, #FF166A 0%, #FB5F08 100%)'\n\t\t\t: '#e5e7eb'};\n\tborder: none;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tcursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};\n\ttransition: all 0.2s ease;\n\tbox-shadow: 0 2px 8px 0px #fa709a1c;\n\tz-index: 2;\n\n\t&:hover:not(:disabled) {\n\t\tbackground: ${(props) =>\n\t\t\tprops.hasText && !props.disabled\n\t\t\t\t? 'linear-gradient(135deg, #F857A6 0%, #FF5858 100%)'\n\t\t\t\t: '#e5e7eb'};\n\t\ttransform: scale(1.05);\n\t}\n\n\t&:active:not(:disabled) {\n\t\ttransform: scale(0.95);\n\t}\n\n\tsvg {\n\t\twidth: 16px;\n\t\theight: 16px;\n\t\tfill: white;\n\t\tfont-weight: bold;\n\t}\n`;\n\n// Customizable gradient text component\nexport const CustomGradientText = styled.span<{\n\tcolors?: string;\n\tangle?: number;\n}>`\n\tbackground: linear-gradient(\n\t\t${(props) => props.angle || 92.69}deg,\n\t\t${(props) => props.colors || '#ff166a 0.37%, #fb5f08 100%'}\n\t);\n\t-webkit-background-clip: text;\n\t-webkit-text-fill-color: transparent;\n\tbackground-clip: text;\n\tdisplay: inline-block;\n`;\n\n// Export ChatState type for backward compatibility\nexport type { ChatState } from '../types';\n\ninterface ChatWindowWithHeightProps extends ChatWindowProps {\n\tchatWindowHeight?: string | number;\n}\n\nconst ChatWindow: React.FC<ChatWindowWithHeightProps> = ({\n\tmessages,\n\tonSend,\n\theader = 'Create with AI',\n\tplaceholder = 'Discover the right event & launch campaigns for better conversions...',\n\tsuggestions = [\n\t\t'Top festivals for marketing',\n\t\t'Top events this week?',\n\t\t'Top August festivals near you',\n\t],\n\ticeBreakers,\n\tvideoStarter,\n\tdisabled = false,\n\tisThinking = false,\n\tonIceBreakerClick,\n\tchatState,\n\tchatWindowHeight,\n\tinputDisabled = false,\n}) => {\n\tconst [input, setInput] = useState('');\n\tconst [thinking, setThinking] = useState(false);\n\tconst [isTyping, setIsTyping] = useState(false);\n\tconst bottomRef = useRef<HTMLDivElement>(null);\n\tconst textareaRef = useRef<HTMLTextAreaElement>(null);\n\tconst isThinkingState = thinking || isThinking;\n\tconst isInputDisabledState = disabled || inputDisabled;\n\n\t// Determine current chat state\n\tconst getCurrentChatState = (): ChatState => {\n\t\tif (chatState) return chatState; // Explicit state override\n\t\tif (thinking || isThinking) return 'thinking';\n\t\tif (isTyping && input.trim().length > 0) return 'typing';\n\t\tif (messages.length === 0) return 'conversation-starter';\n\t\tif (messages.length > 0) return 'conversation';\n\t\treturn 'default';\n\t};\n\n\tconst currentState = getCurrentChatState();\n\n\t// markdown renderer moved to ../utils/markdown\n\n\tconst handleSend = () => {\n\t\tif (!input.trim() || isInputDisabledState || isThinkingState) return;\n\t\tonSend(input);\n\t\tsetInput('');\n\t\tsetThinking(true);\n\t\tsetTimeout(() => setThinking(false), 1500);\n\t};\n\n\tconst handleKeyDown = (e: React.KeyboardEvent) => {\n\t\tif (isInputDisabledState) return;\n\t\tif (e.key === 'Enter' && !e.shiftKey) {\n\t\t\te.preventDefault();\n\t\t\tif (!isThinkingState && input.trim()) {\n\t\t\t\thandleSend();\n\t\t\t}\n\t\t}\n\t};\n\n\tconst handleInputChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n\t\tif (isInputDisabledState) return;\n\t\tconst value = e.target.value;\n\t\tsetInput(value);\n\t\tsetIsTyping(value.trim().length > 0);\n\n\t\t// Auto-resize textarea\n\t\tconst textarea = textareaRef.current;\n\t\tif (textarea) {\n\t\t\ttextarea.style.height = 'auto';\n\t\t\ttextarea.style.height = `${Math.min(textarea.scrollHeight, 117)}px`;\n\t\t}\n\t};\n\n\tconst hasText = input.trim().length > 0;\n\tconst isSendDisabled = isInputDisabledState || isThinkingState || !hasText;\n\n\tuseEffect(() => {\n\t\tbottomRef.current?.scrollIntoView({ behavior: 'smooth' });\n\t}, [messages, thinking, isThinking]);\n\n\t// Use chatWindowHeight if provided, otherwise use 100% if fullHeight is active\n\tconst containerHeight = chatWindowHeight || '100%';\n\n\treturn (\n\t\t<ChatContainer chatState={currentState} style={{ height: containerHeight }}>\n\t\t\t{/* Header */}\n\t\t\t<Header>\n\t\t\t\t<AiIcon height={24} width={24} />\n\t\t\t\t<div className=\"header-text\">{header}</div>\n\t\t\t</Header>\n\n\t\t\t{/* Main Content - Single Column Layout */}\n\t\t\t<MainContent>\n\t\t\t\t{/* Messages Section */}\n\t\t\t\t<MessagesWrapper>\n\t\t\t\t\t{/* Video starter card - only when no messages and videoStarter provided */}\n\t\t\t\t\t{currentState === 'conversation-starter' && videoStarter && (\n\t\t\t\t\t\t<VideoCard>\n\t\t\t\t\t\t\t<VideoContainer>\n\t\t\t\t\t\t\t\t<PlayButton onClick={videoStarter.onPlay}>\n\t\t\t\t\t\t\t\t\t<svg viewBox=\"0 0 24 24\" fill=\"currentColor\">\n\t\t\t\t\t\t\t\t\t\t<path d=\"M8 5v14l11-7z\" />\n\t\t\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t\t\t</PlayButton>\n\t\t\t\t\t\t\t</VideoContainer>\n\t\t\t\t\t\t\t<VideoText>\n\t\t\t\t\t\t\t\t<BodySecondary style={{ fontWeight: 500, marginBottom: '4px' }}>\n\t\t\t\t\t\t\t\t\t{videoStarter.title}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t<BodyCaption>{videoStarter.description}</BodyCaption>\n\t\t\t\t\t\t\t</VideoText>\n\t\t\t\t\t\t</VideoCard>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{/* Render messages (assistant supports lite Markdown) */}\n\t\t\t\t\t{messages.map((m) => (\n\t\t\t\t\t\t<Bubble key={m.id} role={m.role}>\n\t\t\t\t\t\t\t{m.role === 'assistant' ? (\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t\t\t\t\t__html: renderMarkdownLite(m.content),\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<div style={{ whiteSpace: 'pre-wrap' }}>{m.content}</div>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</Bubble>\n\t\t\t\t\t))}\n\n\t\t\t\t\t{/* Thinking bubble */}\n\t\t\t\t\t{(thinking || isThinking) && <ThinkingIndicator />}\n\n\t\t\t\t\t<div ref={bottomRef} />\n\t\t\t\t</MessagesWrapper>\n\n\t\t\t\t{/* Ice Breakers Section - At bottom when no messages and ice breakers provided */}\n\t\t\t\t{iceBreakers && currentState === 'conversation-starter' && (\n\t\t\t\t\t<IceBreakersSection>\n\t\t\t\t\t\t<IceBreakersGrid>\n\t\t\t\t\t\t\t{iceBreakers.map((iceBreaker) => (\n\t\t\t\t\t\t\t\t<IceBreakerChip\n\t\t\t\t\t\t\t\t\tkey={iceBreaker.id}\n\t\t\t\t\t\t\t\t\tdisabled={isInputDisabledState}\n\t\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t\tif (!isInputDisabledState) {\n\t\t\t\t\t\t\t\t\t\t\tonIceBreakerClick?.(iceBreaker);\n\t\t\t\t\t\t\t\t\t\t\tonSend(iceBreaker.text);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<CustomGradientText>{iceBreaker.text}</CustomGradientText>\n\t\t\t\t\t\t\t\t</IceBreakerChip>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</IceBreakersGrid>\n\t\t\t\t\t</IceBreakersSection>\n\t\t\t\t)}\n\n\t\t\t\t{/* Regular Suggestions - Show when no ice breakers are provided */}\n\t\t\t\t{!iceBreakers &&\n\t\t\t\t\tsuggestions.length > 0 &&\n\t\t\t\t\tcurrentState === 'default' && (\n\t\t\t\t\t\t<SuggestionsSection>\n\t\t\t\t\t\t\t<SuggestionsGrid>\n\t\t\t\t\t\t\t\t{suggestions.map((s) => (\n\t\t\t\t\t\t\t\t\t<SuggestionChip\n\t\t\t\t\t\t\t\t\t\tkey={s}\n\t\t\t\t\t\t\t\t\t\tdisabled={isInputDisabledState}\n\t\t\t\t\t\t\t\t\t\tonClick={() => !isInputDisabledState && onSend(s)}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{s}\n\t\t\t\t\t\t\t\t\t</SuggestionChip>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</SuggestionsGrid>\n\t\t\t\t\t\t</SuggestionsSection>\n\t\t\t\t\t)}\n\n\t\t\t\t{/* Input Container - Always at bottom */}\n\t\t\t\t<InputContainer>\n\t\t\t\t\t<InputBubble>\n\t\t\t\t\t\t<TextInput\n\t\t\t\t\t\t\tref={textareaRef}\n\t\t\t\t\t\t\tvalue={input}\n\t\t\t\t\t\t\tonChange={handleInputChange}\n\t\t\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t\t\tonKeyDown={handleKeyDown}\n\t\t\t\t\t\t\tdisabled={isInputDisabledState}\n\t\t\t\t\t\t\thasText={hasText}\n\t\t\t\t\t\t\tchatState={currentState}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<SendButton\n\t\t\t\t\t\t\tonClick={handleSend}\n\t\t\t\t\t\t\tdisabled={isSendDisabled}\n\t\t\t\t\t\t\thasText={hasText}\n\t\t\t\t\t\t\taria-label=\"Send\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\t\twidth=\"20\"\n\t\t\t\t\t\t\t\theight=\"20\"\n\t\t\t\t\t\t\t\tstroke=\"white\"\n\t\t\t\t\t\t\t\tstrokeWidth=\"2\"\n\t\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\t\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<path d=\"M6 12h12\" />\n\t\t\t\t\t\t\t\t<path d=\"M12 6l6 6-6 6\" />\n\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t</SendButton>\n\t\t\t\t\t</InputBubble>\n\t\t\t\t</InputContainer>\n\t\t\t</MainContent>\n\t\t</ChatContainer>\n\t);\n};\n\nexport default ChatWindow;\n"],"names":["ChatContainer","styled","props","Header","MainContent","MessagesWrapper","VideoCard","VideoContainer","PlayButton","VideoText","Bubble","IceBreakersSection","IceBreakersGrid","IceBreakerChip","SuggestionsSection","SuggestionsGrid","SuggestionChip","InputContainer","InputBubble","TextInput","SendButton","CustomGradientText","ChatWindow","messages","onSend","header","placeholder","suggestions","iceBreakers","videoStarter","disabled","isThinking","onIceBreakerClick","chatState","chatWindowHeight","inputDisabled","input","setInput","useState","thinking","setThinking","isTyping","setIsTyping","bottomRef","useRef","textareaRef","isThinkingState","isInputDisabledState","currentState","handleSend","handleKeyDown","e","handleInputChange","value","textarea","hasText","isSendDisabled","useEffect","containerHeight","jsxs","jsx","AiIcon","BodySecondary","BodyCaption","m","renderMarkdownLite","ThinkingIndicator","iceBreaker","s"],"mappings":"4aASMA,EAAgBC,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAazBC,GAAU,CACZ,OAAQA,EAAM,UAAA,CACb,IAAK,uBACJ,MAAO;AAAA;AAAA,UAGR,IAAK,WACJ,MAAO;AAAA;AAAA,UAGR,QACC,MAAO;AAAA;AAAA,SAAA,CAIV,CAAC;AAAA,EAGIC,EAASF,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBhBG,EAAcH,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQrBI,EAAkBJ,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA+BzBK,EAAYL,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQnBM,EAAiBN,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYxBO,EAAaP,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAwBpBQ,EAAYR,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA,EAMnBS,EAAST,EAAAA,QAAO;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AA,CACD,EAIA,CAACvC,GACDD,EAAY,OAAS,GACrBqB,IAAiB,WAChBY,EAAAA,IAAC9C,GAAA,CACA,SAAA8C,EAAAA,IAAC7C,GAAA,CACC,SAAAY,EAAY,IAAKyC,GACjBR,EAAAA,IAAC5C,GAAA,CAEA,SAAU+B,EACV,QAAS,IAAM,CAACA,GAAwBvB,EAAO4C,CAAC,EAE/C,SAAAA,CAAA,EAJIA,CAAA,CAMN,EACF,CAAA,CACD,EAIFR,EAAAA,IAAC3C,GAAA,CACA,SAAA0C,EAAAA,KAACzC,GAAA,CACA,SAAA,CAAA0C,EAAAA,IAACzC,GAAA,CACA,IAAK0B,EACL,MAAOT,EACP,SAAUgB,EACV,YAAA1B,EACA,UAAWwB,EACX,SAAUH,EACV,QAAAQ,EACA,UAAWP,CAAA,CAAA,EAEZY,EAAAA,IAACxC,GAAA,CACA,QAAS6B,EACT,SAAUO,EACV,QAAAD,EACA,aAAW,OAEX,SAAAI,EAAAA,KAAC,MAAA,CACA,QAAQ,YACR,MAAM,KACN,OAAO,KACP,OAAO,QACP,YAAY,IACZ,KAAK,OACL,cAAc,QACd,eAAe,QAEf,SAAA,CAAAC,EAAAA,IAAC,OAAA,CAAK,EAAE,UAAA,CAAW,EACnBA,EAAAA,IAAC,OAAA,CAAK,EAAE,eAAA,CAAgB,CAAA,CAAA,CAAA,CACzB,CAAA,CACD,CAAA,CACD,CAAA,CACD,CAAA,CAAA,CACD,CAAA,EACD,CAEF"}
|
|
1
|
+
{"version":3,"file":"ChatWindow.js","sources":["../../../../../src/components/bik-chatbot/components/ChatWindow.tsx"],"sourcesContent":["import AiIcon from '@src/assets/icons/Ai_event_generating.svg';\nimport { stripHtmlTags } from '@src/helpers/sanitize';\nimport React, { useEffect, useRef, useState } from 'react';\nimport styled from 'styled-components';\nimport { BodyCaption, BodySecondary } from '@src/components/TypographyStyle';\nimport { ChatState, ChatWindowProps } from '../types';\nimport { renderMarkdownLite } from '../utils/markdown';\nimport ThinkingIndicator from './ThinkingIndicator';\n\n// Single-column layout container\nconst ChatContainer = styled.div<{ chatState: ChatState }>`\n\tdisplay: flex;\n\tflex-direction: column;\n\twidth: 100%;\n\tmin-width: 0;\n\tmin-height: 0;\n\theight: 100%;\n\tmax-height: 100%;\n\tbackground: white;\n\tborder-left: 1px solid #e5e7eb;\n\tposition: relative;\n\n\t/* State-based styling */\n\t${(props) => {\n\t\tswitch (props.chatState) {\n\t\t\tcase 'conversation-starter':\n\t\t\t\treturn `\n background: linear-gradient(180deg, #FFF6F9 0%, #FFFFFF 100%);\n `;\n\t\t\tcase 'thinking':\n\t\t\t\treturn `\n background: linear-gradient(180deg, #F8F9FA 0%, #FFFFFF 100%);\n `;\n\t\t\tdefault:\n\t\t\t\treturn `\n background: white;\n `;\n\t\t}\n\t}}\n`;\n\nconst Header = styled.div`\n\tpadding: 16px;\n\tborder-bottom: 1px solid #e5e7eb;\n\tdisplay: flex;\n\talign-items: center;\n\tgap: 8px;\n\tbackground: white;\n\tflex-shrink: 0;\n\n\t.header-text {\n\t\tfont-size: 14px;\n\t\tfont-weight: 500;\n\t\tcolor: #374151;\n\t}\n`;\n\n// Main content area - single column\nconst MainContent = styled.div`\n\tflex: 1;\n\tdisplay: flex;\n\tflex-direction: column;\n\toverflow: hidden;\n\tmin-height: 0;\n`;\n\nconst MessagesWrapper = styled.div`\n\tflex: 1;\n\toverflow-y: auto;\n\tpadding: 16px;\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 16px;\n\tbackground: #fafafa;\n\tscroll-behavior: smooth;\n\tmin-height: 0;\n\n\t/* Custom scrollbar */\n\t&::-webkit-scrollbar {\n\t\twidth: 6px;\n\t}\n\n\t&::-webkit-scrollbar-track {\n\t\tbackground: #f1f1f1;\n\t\tborder-radius: 3px;\n\t}\n\n\t&::-webkit-scrollbar-thumb {\n\t\tbackground: #c1c1c1;\n\t\tborder-radius: 3px;\n\t}\n\n\t&::-webkit-scrollbar-thumb:hover {\n\t\tbackground: #a8a8a8;\n\t}\n`;\n\nconst VideoCard = styled.div`\n\tbackground: white;\n\tborder-radius: 12px;\n\tpadding: 16px;\n\tbox-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n\tborder: 1px solid #e5e7eb;\n`;\n\nconst VideoContainer = styled.div`\n\twidth: 100%;\n\theight: 180px;\n\tbackground: #f3f4f6;\n\tborder-radius: 8px;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tposition: relative;\n\tmargin-bottom: 12px;\n`;\n\nconst PlayButton = styled.div`\n\twidth: 48px;\n\theight: 48px;\n\tbackground: rgba(0, 0, 0, 0.7);\n\tborder-radius: 50%;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tcursor: pointer;\n\ttransition: all 0.2s ease;\n\n\t&:hover {\n\t\tbackground: rgba(0, 0, 0, 0.8);\n\t\ttransform: scale(1.05);\n\t}\n\n\tsvg {\n\t\twidth: 16px;\n\t\theight: 16px;\n\t\tfill: white;\n\t\tmargin-left: 2px;\n\t}\n`;\n\nconst VideoText = styled.div`\n\tfont-size: 14px;\n\tcolor: #374151;\n\tline-height: 1.5;\n`;\n\nconst Bubble = styled.div<{ role: 'user' | 'assistant' | 'system' }>`\n\tpadding: 12px 16px;\n\tborder-radius: 16px;\n\tfont-size: 14px;\n\tmax-width: 80%;\n\twhite-space: pre-line;\n\tword-wrap: break-word;\n\n\t${(props) =>\n\t\tprops.role === 'user'\n\t\t\t? `\n background: linear-gradient(92.69deg, rgba(255, 230, 238, 0.5) 0.37%, rgba(255, 240, 231, 0.5) 100%);\n margin-left: auto;\n border-bottom-right-radius: 4px;\n \n & > div {\n background: linear-gradient(92.69deg, #FF166A 0.37%, #FB5F08 100%);\n -webkit-background-clip: text;\n -webkit-text-fill-color: transparent;\n background-clip: text;\n display: inline-block;\n }\n `\n\t\t\t: props.role === 'system'\n\t\t\t? `\n background: #f3f4f6;\n color: #6b7280;\n font-size: 12px;\n font-style: italic;\n text-align: center;\n margin: 0 auto;\n max-width: 90%;\n `\n\t\t\t: `\n background: white;\n color: #111827;\n border: 1px solid #e5e7eb;\n margin-right: auto;\n border-bottom-left-radius: 4px;\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);\n `}\n`;\n\n// Ice breakers section - at the bottom before input\nconst IceBreakersSection = styled.div`\n\tpadding: 16px;\n\tflex-shrink: 0;\n`;\n\nconst IceBreakersGrid = styled.div`\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n\talign-items: flex-end;\n`;\n\nconst IceBreakerChip = styled.button<{ disabled?: boolean }>`\n\tborder: 1px dotted #febad2;\n\tbackground: linear-gradient(\n\t\t92.69deg,\n\t\trgba(255, 230, 238, 0.5) 0.37%,\n\t\trgba(255, 240, 231, 0.5) 100%\n\t);\n\tpadding: 8px 16px;\n\tborder-radius: 8px;\n\tfont-size: 13px;\n\tcursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};\n\ttransition: all 0.2s ease;\n\ttext-align: left;\n\tmax-width: 280px;\n\talign-self: flex-end;\n\topacity: ${(props) => (props.disabled ? 0.5 : 1)};\n\n\t&:hover:not(:disabled) {\n\t\tbackground: linear-gradient(\n\t\t\t92.69deg,\n\t\t\trgba(255, 230, 238, 0.7) 0.37%,\n\t\t\trgba(255, 240, 231, 0.7) 100%\n\t\t);\n\t\tborder-color: #f472b6;\n\t}\n\n\t&:active:not(:disabled) {\n\t\ttransform: scale(0.98);\n\t}\n`;\n\n// Suggestions section - styled like ice breakers but for regular suggestions\nconst SuggestionsSection = styled.div`\n\tpadding: 16px;\n\tbackground: white;\n`;\n\nconst SuggestionsGrid = styled.div`\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n`;\n\nconst SuggestionChip = styled.button<{ disabled?: boolean }>`\n\tbackground: #fef2f2;\n\tcolor: #dc2626;\n\tpadding: 12px 16px;\n\tborder-radius: 8px;\n\tfont-size: 13px;\n\tborder: 1px solid #fecaca;\n\tcursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};\n\ttransition: all 0.2s ease;\n\ttext-align: left;\n\topacity: ${(props) => (props.disabled ? 0.5 : 1)};\n\n\t&:hover:not(:disabled) {\n\t\tbackground: #fee2e2;\n\t\tborder-color: #fca5a5;\n\t}\n\n\t&:active:not(:disabled) {\n\t\ttransform: scale(0.98);\n\t}\n`;\n\nconst InputContainer = styled.div`\n\tpadding: 16px;\n\tflex-shrink: 0;\n`;\n\nconst InputBubble = styled.div`\n\tposition: relative;\n\tdisplay: flex;\n\twidth: 100%;\n`;\n\nconst TextInput = styled.textarea<{ hasText: boolean; chatState: ChatState }>`\n\tflex: 1;\n\tborder: 1px solid ${(props) => (props.hasText ? '#3b82f6' : '#d1d5db')};\n\tborder-radius: 12px;\n\tpadding: 12px;\n\tpadding-right: 48px;\n\tfont-size: 14px;\n\toutline: none;\n\tcolor: #374151;\n\tbackground: white;\n\tbox-shadow: 0px 2px 8px 0px #0000001f;\n\ttransition: all 0.2s ease;\n\tresize: none;\n\tmin-height: 44px;\n\tmax-height: 120px;\n\tfont-family: inherit;\n\twidth: 100%;\n\n\t&:focus {\n\t\tborder-color: #3b82f6;\n\t\tbackground: white;\n\t\tbox-shadow: 0px 2px 8px 0px #0000001f, 0 0 0 3px rgba(59, 130, 246, 0.1);\n\t}\n\n\t&::placeholder {\n\t\tcolor: #9ca3af;\n\t}\n`;\n\nconst SendButton = styled.button<{ disabled?: boolean; hasText: boolean }>`\n\tposition: absolute;\n\tbottom: 10px;\n\tright: 10px;\n\twidth: 36px;\n\theight: 36px;\n\tborder-radius: 50%;\n\tbackground: ${(props) =>\n\t\tprops.hasText\n\t\t\t? 'linear-gradient(135deg, #FF166A 0%, #FB5F08 100%)'\n\t\t\t: '#e5e7eb'};\n\tborder: none;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tcursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};\n\ttransition: all 0.2s ease;\n\tbox-shadow: 0 2px 8px 0px #fa709a1c;\n\tz-index: 2;\n\n\t&:hover:not(:disabled) {\n\t\tbackground: ${(props) =>\n\t\t\tprops.hasText && !props.disabled\n\t\t\t\t? 'linear-gradient(135deg, #F857A6 0%, #FF5858 100%)'\n\t\t\t\t: '#e5e7eb'};\n\t\ttransform: scale(1.05);\n\t}\n\n\t&:active:not(:disabled) {\n\t\ttransform: scale(0.95);\n\t}\n\n\tsvg {\n\t\twidth: 16px;\n\t\theight: 16px;\n\t\tfill: white;\n\t\tfont-weight: bold;\n\t}\n`;\n\n// Customizable gradient text component\nexport const CustomGradientText = styled.span<{\n\tcolors?: string;\n\tangle?: number;\n}>`\n\tbackground: linear-gradient(\n\t\t${(props) => props.angle || 92.69}deg,\n\t\t${(props) => props.colors || '#ff166a 0.37%, #fb5f08 100%'}\n\t);\n\t-webkit-background-clip: text;\n\t-webkit-text-fill-color: transparent;\n\tbackground-clip: text;\n\tdisplay: inline-block;\n`;\n\n// Export ChatState type for backward compatibility\nexport type { ChatState } from '../types';\n\ninterface ChatWindowWithHeightProps extends ChatWindowProps {\n\tchatWindowHeight?: string | number;\n}\n\nconst ChatWindow: React.FC<ChatWindowWithHeightProps> = ({\n\tmessages,\n\tonSend,\n\theader = 'Create with AI',\n\tplaceholder = 'Discover the right event & launch campaigns for better conversions...',\n\tsuggestions = [\n\t\t'Top festivals for marketing',\n\t\t'Top events this week?',\n\t\t'Top August festivals near you',\n\t],\n\ticeBreakers,\n\tvideoStarter,\n\tdisabled = false,\n\tisThinking = false,\n\tonIceBreakerClick,\n\tchatState,\n\tchatWindowHeight,\n\tinputDisabled = false,\n}) => {\n\tconst [input, setInput] = useState('');\n\tconst [thinking, setThinking] = useState(false);\n\tconst [isTyping, setIsTyping] = useState(false);\n\tconst bottomRef = useRef<HTMLDivElement>(null);\n\tconst textareaRef = useRef<HTMLTextAreaElement>(null);\n\tconst isThinkingState = thinking || isThinking;\n\tconst isInputDisabledState = disabled || inputDisabled;\n\n\t// Determine current chat state\n\tconst getCurrentChatState = (): ChatState => {\n\t\tif (chatState) return chatState; // Explicit state override\n\t\tif (thinking || isThinking) return 'thinking';\n\t\tif (isTyping && input.trim().length > 0) return 'typing';\n\t\tif (messages.length === 0) return 'conversation-starter';\n\t\tif (messages.length > 0) return 'conversation';\n\t\treturn 'default';\n\t};\n\n\tconst currentState = getCurrentChatState();\n\n\t// markdown renderer moved to ../utils/markdown\n\n\tconst handleSend = () => {\n\t\tif (!input.trim() || isInputDisabledState || isThinkingState) return;\n\t\tonSend(input);\n\t\tsetInput('');\n\t\tsetThinking(true);\n\t\tsetTimeout(() => setThinking(false), 1500);\n\t};\n\n\tconst handleKeyDown = (e: React.KeyboardEvent) => {\n\t\tif (isInputDisabledState) return;\n\t\tif (e.key === 'Enter' && !e.shiftKey) {\n\t\t\te.preventDefault();\n\t\t\tif (!isThinkingState && input.trim()) {\n\t\t\t\thandleSend();\n\t\t\t}\n\t\t}\n\t};\n\n\tconst handleInputChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n\t\tif (isInputDisabledState) return;\n\t\tconst value = stripHtmlTags(e.target.value);\n\t\tsetInput(value);\n\t\tsetIsTyping(value.trim().length > 0);\n\n\t\t// Auto-resize textarea\n\t\tconst textarea = textareaRef.current;\n\t\tif (textarea) {\n\t\t\ttextarea.style.height = 'auto';\n\t\t\ttextarea.style.height = `${Math.min(textarea.scrollHeight, 117)}px`;\n\t\t}\n\t};\n\n\tconst hasText = input.trim().length > 0;\n\tconst isSendDisabled = isInputDisabledState || isThinkingState || !hasText;\n\n\tuseEffect(() => {\n\t\tbottomRef.current?.scrollIntoView({ behavior: 'smooth' });\n\t}, [messages, thinking, isThinking]);\n\n\t// Use chatWindowHeight if provided, otherwise use 100% if fullHeight is active\n\tconst containerHeight = chatWindowHeight || '100%';\n\n\treturn (\n\t\t<ChatContainer chatState={currentState} style={{ height: containerHeight }}>\n\t\t\t{/* Header */}\n\t\t\t<Header>\n\t\t\t\t<AiIcon height={24} width={24} />\n\t\t\t\t<div className=\"header-text\">{header}</div>\n\t\t\t</Header>\n\n\t\t\t{/* Main Content - Single Column Layout */}\n\t\t\t<MainContent>\n\t\t\t\t{/* Messages Section */}\n\t\t\t\t<MessagesWrapper>\n\t\t\t\t\t{/* Video starter card - only when no messages and videoStarter provided */}\n\t\t\t\t\t{currentState === 'conversation-starter' && videoStarter && (\n\t\t\t\t\t\t<VideoCard>\n\t\t\t\t\t\t\t<VideoContainer>\n\t\t\t\t\t\t\t\t<PlayButton onClick={videoStarter.onPlay}>\n\t\t\t\t\t\t\t\t\t<svg viewBox=\"0 0 24 24\" fill=\"currentColor\">\n\t\t\t\t\t\t\t\t\t\t<path d=\"M8 5v14l11-7z\" />\n\t\t\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t\t\t</PlayButton>\n\t\t\t\t\t\t\t</VideoContainer>\n\t\t\t\t\t\t\t<VideoText>\n\t\t\t\t\t\t\t\t<BodySecondary style={{ fontWeight: 500, marginBottom: '4px' }}>\n\t\t\t\t\t\t\t\t\t{videoStarter.title}\n\t\t\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t\t\t\t<BodyCaption>{videoStarter.description}</BodyCaption>\n\t\t\t\t\t\t\t</VideoText>\n\t\t\t\t\t\t</VideoCard>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{/* Render messages (assistant supports lite Markdown) */}\n\t\t\t\t\t{messages.map((m) => (\n\t\t\t\t\t\t<Bubble key={m.id} role={m.role}>\n\t\t\t\t\t\t\t{m.role === 'assistant' ? (\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t\t\t\t\t__html: renderMarkdownLite(m.content),\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<div style={{ whiteSpace: 'pre-wrap' }}>{m.content}</div>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</Bubble>\n\t\t\t\t\t))}\n\n\t\t\t\t\t{/* Thinking bubble */}\n\t\t\t\t\t{(thinking || isThinking) && <ThinkingIndicator />}\n\n\t\t\t\t\t<div ref={bottomRef} />\n\t\t\t\t</MessagesWrapper>\n\n\t\t\t\t{/* Ice Breakers Section - At bottom when no messages and ice breakers provided */}\n\t\t\t\t{iceBreakers && currentState === 'conversation-starter' && (\n\t\t\t\t\t<IceBreakersSection>\n\t\t\t\t\t\t<IceBreakersGrid>\n\t\t\t\t\t\t\t{iceBreakers.map((iceBreaker) => (\n\t\t\t\t\t\t\t\t<IceBreakerChip\n\t\t\t\t\t\t\t\t\tkey={iceBreaker.id}\n\t\t\t\t\t\t\t\t\tdisabled={isInputDisabledState}\n\t\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t\tif (!isInputDisabledState) {\n\t\t\t\t\t\t\t\t\t\t\tonIceBreakerClick?.(iceBreaker);\n\t\t\t\t\t\t\t\t\t\t\tonSend(iceBreaker.text);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<CustomGradientText>{iceBreaker.text}</CustomGradientText>\n\t\t\t\t\t\t\t\t</IceBreakerChip>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</IceBreakersGrid>\n\t\t\t\t\t</IceBreakersSection>\n\t\t\t\t)}\n\n\t\t\t\t{/* Regular Suggestions - Show when no ice breakers are provided */}\n\t\t\t\t{!iceBreakers &&\n\t\t\t\t\tsuggestions.length > 0 &&\n\t\t\t\t\tcurrentState === 'default' && (\n\t\t\t\t\t\t<SuggestionsSection>\n\t\t\t\t\t\t\t<SuggestionsGrid>\n\t\t\t\t\t\t\t\t{suggestions.map((s) => (\n\t\t\t\t\t\t\t\t\t<SuggestionChip\n\t\t\t\t\t\t\t\t\t\tkey={s}\n\t\t\t\t\t\t\t\t\t\tdisabled={isInputDisabledState}\n\t\t\t\t\t\t\t\t\t\tonClick={() => !isInputDisabledState && onSend(s)}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{s}\n\t\t\t\t\t\t\t\t\t</SuggestionChip>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</SuggestionsGrid>\n\t\t\t\t\t\t</SuggestionsSection>\n\t\t\t\t\t)}\n\n\t\t\t\t{/* Input Container - Always at bottom */}\n\t\t\t\t<InputContainer>\n\t\t\t\t\t<InputBubble>\n\t\t\t\t\t\t<TextInput\n\t\t\t\t\t\t\tref={textareaRef}\n\t\t\t\t\t\t\tvalue={input}\n\t\t\t\t\t\t\tonChange={handleInputChange}\n\t\t\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t\t\tonKeyDown={handleKeyDown}\n\t\t\t\t\t\t\tdisabled={isInputDisabledState}\n\t\t\t\t\t\t\thasText={hasText}\n\t\t\t\t\t\t\tchatState={currentState}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<SendButton\n\t\t\t\t\t\t\tonClick={handleSend}\n\t\t\t\t\t\t\tdisabled={isSendDisabled}\n\t\t\t\t\t\t\thasText={hasText}\n\t\t\t\t\t\t\taria-label=\"Send\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\t\twidth=\"20\"\n\t\t\t\t\t\t\t\theight=\"20\"\n\t\t\t\t\t\t\t\tstroke=\"white\"\n\t\t\t\t\t\t\t\tstrokeWidth=\"2\"\n\t\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\t\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<path d=\"M6 12h12\" />\n\t\t\t\t\t\t\t\t<path d=\"M12 6l6 6-6 6\" />\n\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t</SendButton>\n\t\t\t\t\t</InputBubble>\n\t\t\t\t</InputContainer>\n\t\t\t</MainContent>\n\t\t</ChatContainer>\n\t);\n};\n\nexport default ChatWindow;\n"],"names":["ChatContainer","styled","props","Header","MainContent","MessagesWrapper","VideoCard","VideoContainer","PlayButton","VideoText","Bubble","IceBreakersSection","IceBreakersGrid","IceBreakerChip","SuggestionsSection","SuggestionsGrid","SuggestionChip","InputContainer","InputBubble","TextInput","SendButton","CustomGradientText","ChatWindow","messages","onSend","header","placeholder","suggestions","iceBreakers","videoStarter","disabled","isThinking","onIceBreakerClick","chatState","chatWindowHeight","inputDisabled","input","setInput","useState","thinking","setThinking","isTyping","setIsTyping","bottomRef","useRef","textareaRef","isThinkingState","isInputDisabledState","currentState","handleSend","handleKeyDown","e","handleInputChange","value","stripHtmlTags","textarea","hasText","isSendDisabled","useEffect","containerHeight","jsxs","jsx","AiIcon","BodySecondary","BodyCaption","m","renderMarkdownLite","ThinkingIndicator","iceBreaker","s"],"mappings":"sdAUMA,EAAgBC,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAazBC,GAAU,CACZ,OAAQA,EAAM,UAAA,CACb,IAAK,uBACJ,MAAO;AAAA;AAAA,UAGR,IAAK,WACJ,MAAO;AAAA;AAAA,UAGR,QACC,MAAO;AAAA;AAAA,SAAA,CAIV,CAAC;AAAA,EAGIC,EAASF,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBhBG,EAAcH,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQrBI,EAAkBJ,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA+BzB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,CAAA,CAAA,CAAA,CACzB,CAAA,CACD,CAAA,CACD,CAAA,CACD,CAAA,CAAA,CACD,CAAA,EACD,CAEF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),me=require("../node_modules/@tiptap/core/dist/index.js"),$=require("@tiptap/react"),c=require("react"),V=require("../components/TypographyStyle.js"),B=require("./BikEditor.styles.js"),Q=require("./BikEditor.types.js"),s=require("./BikEditor.utils.js"),ge=require("./extensions/buildExtensions.js"),fe=require("./floating/LinkBubbleMenu.js"),he=require("../icons/BIK AI specific/WandSparkles.js"),pe=require("../icons/Actions/Formatting/Copy.js");function Ce(C){return Object.entries(C).map(([S,h])=>`${S.replace(/([A-Z])/g,p=>`-${p.toLowerCase()}`)}:${h}`).join(";")}const ke=(C,S)=>{const{initialContent:h,sections:p,features:k,disabled:G,maxCharacters:T,characterLimit:K,shortcuts:X,sendShortcut:Y,mentions:u,slashCommands:f,link:ee,onPaste:te,onReady:b,onChange:R,onSend:x,onFocus:v,onBlur:E,onSelectionChange:A,minHeight:ne,maxHeight:oe,style:se,className:re,editorClassName:z,editorStyle:H,renderJsonError:j}=C,m=!!k?.jsonMode,[d,J]=c.useState(null),[ie,I]=c.useState(!1),ce=m?s.buildJsonCodeBlockHtml(h??""):p?.length?s.buildSectionedContent(s.normalizeHtml(h??""),p.map(e=>({...e,content:s.normalizeHtml(e.content)}))):s.normalizeHtml(h??""),y=c.useRef([]),M=c.useRef(!1),L=c.useRef(b);L.current=b;const O=c.useRef(R);O.current=R;const F=c.useRef(A);F.current=A;const q=c.useRef(Q.DEFAULT_FORMAT_STATE),N=c.useRef(v);N.current=v;const P=c.useRef(E);P.current=E;const w=c.useRef(x);w.current=x;const D=c.useRef(u?.agents??[]);D.current=u?.agents??[];const U=c.useRef(u?.teams??[]);U.current=u?.teams??[];const _=c.useRef(f?.items??[]);_.current=f?.items??[];const n=$.useEditor({extensions:ge.buildExtensions({features:k,placeholder:C.placeholder,maxCharacters:T,characterLimit:K,hasSections:(p?.length??0)>0,mentions:{agents:u?D:void 0,teams:u?U:void 0},slashCommands:f?_:void 0,onPaste:te,onSend:x?e=>w.current?.(e):void 0,sendShortcut:Y,shortcuts:X,onMentionSelected:u?.onSelect,onSlashCommandSelected:f?.onSelect,renderMentionItem:u?.renderItem,renderMentionDropdown:u?.renderDropdown,removeMentionTriggerOnDismiss:u?.removeTriggerOnDismiss,renderSlashCommandItem:f?.renderItem,renderSlashCommandDropdown:f?.renderDropdown}),content:ce,editable:!G,immediatelyRender:!1,editorProps:{attributes:{...z?{class:z}:{},...H?{style:Ce(H)}:{}}},onUpdate:({editor:e})=>{if(O.current?.(s.extractContent(e)),m){const t=s.parseJson(s.getCodeBlockText(e));J(t.valid?null:t)}},onTransaction:({editor:e})=>{const t=s.extractActiveFormats(e),o=q.current;(o.bold!==t.bold||o.italic!==t.italic||o.underline!==t.underline||o.strike!==t.strike||o.bulletList!==t.bulletList||o.orderedList!==t.orderedList||o.blockquote!==t.blockquote||o.codeBlock!==t.codeBlock||o.superscript!==t.superscript||o.subscript!==t.subscript||o.textAlign!==t.textAlign||o.fontFamily!==t.fontFamily||o.fontSize!==t.fontSize||o.color!==t.color||o.highlight!==t.highlight||o.link?.href!==t.link?.href)&&(q.current=t,F.current?.(t))},onFocus:()=>N.current?.(),onBlur:()=>P.current?.()});function i(e){n?e(n):y.current.push(e)}c.useEffect(()=>{if(n&&(y.current.length>0&&y.current.splice(0).forEach(t=>t(n)),M.current||(M.current=!0,L.current?.()),m)){const e=s.parseJson(s.getCodeBlockText(n));J(e.valid?null:e)}},[n,m]),c.useImperativeHandle(S,()=>({focus:e=>i(t=>t.commands.focus(e)),blur:()=>i(e=>e.commands.blur()),clearContent:()=>i(e=>e.commands.clearContent(!0)),setContent:e=>{const t=s.normalizeHtml(e);i(o=>o.commands.setContent(t,{emitUpdate:!0}))},insertContent:e=>{const t=s.normalizeHtml(e);i(o=>o.commands.insertContent(t))},insertInlineContent:e=>{i(t=>s.insertInlineHtml(t,e))},insertAtStart:e=>{const t=s.normalizeHtml(e);i(o=>o.commands.insertContentAt(1,t))},insertBlock:e=>{const t=s.normalizeHtml(e);i(o=>o.commands.insertContentAt(o.state.doc.content.size,t))},appendInline:e=>{const t=s.normalizeHtml(e);i(o=>o.commands.insertContentAt(o.state.doc.content.size-1,t))},insertAtEnd(e){this.insertBlock(e)},appendContent(e){this.appendInline(e)},getContent:()=>n?s.extractContent(n):{html:"",text:"",isEmpty:!0,characterCount:0},getJSON:()=>n?.getJSON()??null,getMentions:()=>{const e=new Set,t=new Set;return n?(n.state.doc.descendants(o=>{o.type.name==="mentionAgent"&&o.attrs.id!=null?e.add(String(o.attrs.id)):o.type.name==="mentionTeam"&&o.attrs.id!=null&&t.add(String(o.attrs.id))}),{agentIds:Array.from(e),teamIds:Array.from(t)}):{agentIds:[],teamIds:[]}},getCursorPosition:()=>{if(!n)return{from:0,to:0};const{from:e,to:t}=n.state.selection;return{from:e,to:t}},insertAtPosition:(e,t)=>{const o=s.normalizeHtml(t);i(r=>r.commands.insertContentAt(e,o))},getSelectedText:()=>{if(!n)return"";const{state:e}=n,{from:t,to:o,empty:r}=e.selection;if(!r)return e.doc.textBetween(t,o," ");const l=e.schema.marks.link;if(l){const g=me.getMarkRange(e.doc.resolve(t),l);if(g)return e.doc.textBetween(g.from,g.to," ")}return""},getCharacterCount:()=>({count:n?.storage.characterCount?.characters?.()??n?.getText().length??0,limit:T??null}),getSectionContent:e=>n?s.extractSectionContent(n,e):{html:"",text:"",isEmpty:!0,characterCount:0},setSectionContent:(e,t)=>{const o=s.normalizeHtml(t);i(r=>s.setSectionContentInEditor(r,e,o))},focusSection:e=>{i(t=>{if(e==="body"){let r=t.state.doc.content.size-1;t.state.doc.descendants((l,g)=>(l.type.name==="sectionDivider"&&r===t.state.doc.content.size-1&&(r=g-1),r===t.state.doc.content.size-1)),r<1&&(r=1),t.chain().focus().setTextSelection(r).run();return}let o=-1;t.state.doc.descendants((r,l)=>{if(o!==-1)return!1;r.type.name==="sectionDivider"&&r.attrs.sectionId===e&&(o=l+r.nodeSize+1)}),o!==-1&&t.chain().focus().setTextSelection(o).run()})},clearSection:e=>{i(t=>s.setSectionContentInEditor(t,e,"<p></p>"))},getBodyContent:()=>n?s.extractBodyContent(n):{html:"",text:"",isEmpty:!0,characterCount:0},setBodyContent:e=>{const t=s.normalizeHtml(e);i(o=>s.setSectionContentInEditor(o,"body",t))},setBodyAndSections:(e,t)=>{const o=s.buildSectionedContent(s.normalizeHtml(e),t.map(r=>({id:r.id,content:s.normalizeHtml(r.content)})));i(r=>r.commands.setContent(o,{emitUpdate:!0}))},appendBodyContent:e=>{const t=s.normalizeHtml(e);i(o=>{const r=s.findSectionEndPos(o,"body");o.commands.insertContentAt(r-1,t,{parseOptions:{preserveWhitespace:!0}})})},insertAtSectionStart:(e,t)=>{const o=s.normalizeHtml(t);i(r=>{const l=s.findSectionStartPos(r,e);l!==-1&&r.commands.insertContentAt(l,o,{parseOptions:{preserveWhitespace:!0}})})},insertAtSectionEnd:(e,t)=>{const o=s.normalizeHtml(t);i(r=>{const l=s.findSectionEndPos(r,e);r.commands.insertContentAt(l,o,{parseOptions:{preserveWhitespace:!0}})})},getActiveFormats:()=>n?s.extractActiveFormats(n):Q.DEFAULT_FORMAT_STATE,actions:{toggleBold:()=>n?.chain().focus().toggleBold().run(),toggleItalic:()=>n?.chain().focus().toggleItalic().run(),toggleUnderline:()=>n?.chain().focus().toggleUnderline().run(),toggleStrike:()=>n?.chain().focus().toggleStrike().run(),toggleBulletList:()=>n?.chain().focus().toggleBulletList().run(),toggleOrderedList:()=>n?.chain().focus().toggleOrderedList().run(),toggleBlockquote:()=>n?.chain().focus().toggleBlockquote().run(),toggleCodeBlock:()=>n?.chain().focus().toggleCodeBlock().run(),setTextAlign:e=>n?.chain().focus().setTextAlign(e).run(),setFontFamily:e=>n?.chain().focus().setFontFamily(e).run(),setFontSize:e=>n?.chain().focus().setFontSize(e).run(),setColor:e=>n?.chain().focus().setColor(e).run(),setHighlight:e=>n?.chain().focus().toggleHighlight({color:e}).run(),unsetColor:()=>n?.chain().focus().unsetColor().run(),unsetHighlight:()=>n?.chain().focus().unsetHighlight().run(),setLink:(e,t)=>{n&&(t!==void 0?n.chain().focus().extendMarkRange("link").command(({tr:o,state:r})=>{const{from:l,to:g}=o.selection,W=r.schema.marks.link;if(!W)return!1;const ue=r.schema.text(t,[W.create({href:e})]),de=r.schema.text(" ");return o.replaceWith(l,g,[ue,de]),!0}).run():n.chain().focus().extendMarkRange("link").setLink({href:e}).insertContent(" ").run())},updateLink:e=>n?.chain().focus().extendMarkRange("link").setLink({href:e}).run(),removeLink:()=>n?.chain().focus().extendMarkRange("link").unsetLink().run(),insertEmoji:e=>n?.chain().focus().insertContent(e).run(),insertVariable:e=>n?.chain().focus().insertContent(`{{${e}}}`).run(),insertHtml:e=>n?.commands.insertContent(s.normalizeHtml(e)),undo:()=>n?.chain().focus().undo().run(),redo:()=>n?.chain().focus().redo().run(),canUndo:()=>n?.can().undo()??!1,canRedo:()=>n?.can().redo()??!1,toggleSuperscript:()=>n?.chain().focus().toggleSuperscript().run(),toggleSubscript:()=>n?.chain().focus().toggleSubscript().run(),insertImage:e=>n?.chain().focus().setImage({src:e}).run()},json:k?.jsonMode?{getText:()=>n?s.getCodeBlockText(n):"",setText:e=>i(t=>s.setCodeBlockText(t,e)),parse:()=>s.parseJson(n?s.getCodeBlockText(n):""),isValid:()=>s.parseJson(n?s.getCodeBlockText(n):"").valid,format:(e=2)=>i(t=>{const{valid:o,value:r}=s.parseJson(s.getCodeBlockText(t));!o||r===null||s.setCodeBlockText(t,JSON.stringify(r,null,e))}),minify:()=>i(e=>{const{valid:t,value:o}=s.parseJson(s.getCodeBlockText(e));!t||o===null||s.setCodeBlockText(e,JSON.stringify(o))})}:void 0}),[n]);const ae=()=>{if(!n)return;const{valid:e,value:t}=s.parseJson(s.getCodeBlockText(n));!e||t===null||s.setCodeBlockText(n,JSON.stringify(t,null,2))},le=()=>{n&&(navigator.clipboard?.writeText(s.getCodeBlockText(n)),I(!0),setTimeout(()=>I(!1),1500))};return n?a.jsxs(B.BikEditorShell,{minHeight:ne,maxHeight:oe,tightParagraphs:!k?.richPaste,jsonMode:m,style:se,className:re,children:[m&&a.jsxs(B.BikJsonHeader,{children:[a.jsx("span",{className:"bik-json-header-label",children:"JSON"}),a.jsxs("div",{className:"bik-json-header-actions",children:[a.jsxs("button",{type:"button",onClick:ae,disabled:!!d,title:"Format JSON",children:[a.jsx(he.default,{size:16}),a.jsx(V.BodyCaption,{children:"Beautify"})]}),a.jsxs("button",{type:"button",onClick:le,title:"Copy JSON",children:[a.jsx(pe.default,{size:16}),ie&&a.jsx(V.BodyCaption,{children:"Copied"})]})]})]}),a.jsx($.EditorContent,{editor:n}),a.jsx(fe.LinkBubbleMenu,{editor:n,renderLinkTooltip:ee?.renderTooltip}),m&&d?j?j(d):a.jsxs(B.BikJsonError,{children:[d.line!=null&&a.jsxs("strong",{children:["Line ",d.line,d.column!=null?`, column ${d.column}`:"",":"," "]}),d.error]}):null]}):null},Z=c.forwardRef(ke);Z.displayName="BikEditor";exports.BikEditor=Z;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),he=require("../node_modules/@tiptap/core/dist/index.js"),Q=require("@tiptap/react"),c=require("react"),Z=require("../components/TypographyStyle.js"),G=require("../helpers/sanitize.js"),b=require("./BikEditor.styles.js"),K=require("./BikEditor.types.js"),r=require("./BikEditor.utils.js"),pe=require("./extensions/buildExtensions.js"),Ce=require("./floating/LinkBubbleMenu.js"),ke=require("../icons/BIK AI specific/WandSparkles.js"),Se=require("../icons/Actions/Formatting/Copy.js");function xe(S){return Object.entries(S).map(([x,p])=>`${x.replace(/([A-Z])/g,C=>`-${C.toLowerCase()}`)}:${p}`).join(";")}const ye=(S,x)=>{const{initialContent:p,sections:C,features:k,disabled:Y,maxCharacters:T,characterLimit:ee,shortcuts:te,sendShortcut:ne,mentions:d,slashCommands:h,link:oe,onPaste:se,onReady:R,onChange:E,onSend:y,onFocus:v,onBlur:A,onSelectionChange:j,minHeight:re,maxHeight:ie,style:ce,className:ae,editorClassName:J,editorStyle:I,renderJsonError:M}=S,g=!!k?.jsonMode,L=!!k?.richPaste?G.sanitizeEmailHtml:G.sanitizeBasicHtml,a=c.useCallback(e=>r.normalizeHtml(e,L),[L]),[m,O]=c.useState(null),[le,q]=c.useState(!1),ue=g?r.buildJsonCodeBlockHtml(p??""):C?.length?r.buildSectionedContent(a(p??""),C.map(e=>({...e,content:a(e.content)}))):a(p??""),B=c.useRef([]),F=c.useRef(!1),z=c.useRef(R);z.current=R;const P=c.useRef(E);P.current=E;const H=c.useRef(j);H.current=j;const N=c.useRef(K.DEFAULT_FORMAT_STATE),w=c.useRef(v);w.current=v;const D=c.useRef(A);D.current=A;const U=c.useRef(y);U.current=y;const _=c.useRef(d?.agents??[]);_.current=d?.agents??[];const W=c.useRef(d?.teams??[]);W.current=d?.teams??[];const $=c.useRef(h?.items??[]);$.current=h?.items??[];const n=Q.useEditor({extensions:pe.buildExtensions({features:k,placeholder:S.placeholder,maxCharacters:T,characterLimit:ee,hasSections:(C?.length??0)>0,mentions:{agents:d?_:void 0,teams:d?W:void 0},slashCommands:h?$:void 0,onPaste:se,onSend:y?e=>U.current?.(e):void 0,sendShortcut:ne,shortcuts:te,onMentionSelected:d?.onSelect,onSlashCommandSelected:h?.onSelect,renderMentionItem:d?.renderItem,renderMentionDropdown:d?.renderDropdown,removeMentionTriggerOnDismiss:d?.removeTriggerOnDismiss,renderSlashCommandItem:h?.renderItem,renderSlashCommandDropdown:h?.renderDropdown}),content:ue,editable:!Y,immediatelyRender:!1,editorProps:{attributes:{...J?{class:J}:{},...I?{style:xe(I)}:{}}},onUpdate:({editor:e})=>{if(P.current?.(r.extractContent(e)),g){const t=r.parseJson(r.getCodeBlockText(e));O(t.valid?null:t)}},onTransaction:({editor:e})=>{const t=r.extractActiveFormats(e),o=N.current;(o.bold!==t.bold||o.italic!==t.italic||o.underline!==t.underline||o.strike!==t.strike||o.bulletList!==t.bulletList||o.orderedList!==t.orderedList||o.blockquote!==t.blockquote||o.codeBlock!==t.codeBlock||o.superscript!==t.superscript||o.subscript!==t.subscript||o.textAlign!==t.textAlign||o.fontFamily!==t.fontFamily||o.fontSize!==t.fontSize||o.color!==t.color||o.highlight!==t.highlight||o.link?.href!==t.link?.href)&&(N.current=t,H.current?.(t))},onFocus:()=>w.current?.(),onBlur:()=>D.current?.()});function i(e){n?e(n):B.current.push(e)}c.useEffect(()=>{if(n&&(B.current.length>0&&B.current.splice(0).forEach(t=>t(n)),F.current||(F.current=!0,z.current?.()),g)){const e=r.parseJson(r.getCodeBlockText(n));O(e.valid?null:e)}},[n,g]),c.useImperativeHandle(x,()=>({focus:e=>i(t=>t.commands.focus(e)),blur:()=>i(e=>e.commands.blur()),clearContent:()=>i(e=>e.commands.clearContent(!0)),setContent:e=>{const t=a(e);i(o=>o.commands.setContent(t,{emitUpdate:!0}))},insertContent:e=>{const t=a(e);i(o=>o.commands.insertContent(t))},insertInlineContent:e=>{i(t=>r.insertInlineHtml(t,e))},insertAtStart:e=>{const t=a(e);i(o=>o.commands.insertContentAt(1,t))},insertBlock:e=>{const t=a(e);i(o=>o.commands.insertContentAt(o.state.doc.content.size,t))},appendInline:e=>{const t=a(e);i(o=>o.commands.insertContentAt(o.state.doc.content.size-1,t))},insertAtEnd(e){this.insertBlock(e)},appendContent(e){this.appendInline(e)},getContent:()=>n?r.extractContent(n):{html:"",text:"",isEmpty:!0,characterCount:0},getJSON:()=>n?.getJSON()??null,getMentions:()=>{const e=new Set,t=new Set;return n?(n.state.doc.descendants(o=>{o.type.name==="mentionAgent"&&o.attrs.id!=null?e.add(String(o.attrs.id)):o.type.name==="mentionTeam"&&o.attrs.id!=null&&t.add(String(o.attrs.id))}),{agentIds:Array.from(e),teamIds:Array.from(t)}):{agentIds:[],teamIds:[]}},getCursorPosition:()=>{if(!n)return{from:0,to:0};const{from:e,to:t}=n.state.selection;return{from:e,to:t}},insertAtPosition:(e,t)=>{const o=a(t);i(s=>s.commands.insertContentAt(e,o))},getSelectedText:()=>{if(!n)return"";const{state:e}=n,{from:t,to:o,empty:s}=e.selection;if(!s)return e.doc.textBetween(t,o," ");const u=e.schema.marks.link;if(u){const f=he.getMarkRange(e.doc.resolve(t),u);if(f)return e.doc.textBetween(f.from,f.to," ")}return""},getCharacterCount:()=>({count:n?.storage.characterCount?.characters?.()??n?.getText().length??0,limit:T??null}),getSectionContent:e=>n?r.extractSectionContent(n,e):{html:"",text:"",isEmpty:!0,characterCount:0},setSectionContent:(e,t)=>{const o=a(t);i(s=>r.setSectionContentInEditor(s,e,o))},focusSection:e=>{i(t=>{if(e==="body"){let s=t.state.doc.content.size-1;t.state.doc.descendants((u,f)=>(u.type.name==="sectionDivider"&&s===t.state.doc.content.size-1&&(s=f-1),s===t.state.doc.content.size-1)),s<1&&(s=1),t.chain().focus().setTextSelection(s).run();return}let o=-1;t.state.doc.descendants((s,u)=>{if(o!==-1)return!1;s.type.name==="sectionDivider"&&s.attrs.sectionId===e&&(o=u+s.nodeSize+1)}),o!==-1&&t.chain().focus().setTextSelection(o).run()})},clearSection:e=>{i(t=>r.setSectionContentInEditor(t,e,"<p></p>"))},getBodyContent:()=>n?r.extractBodyContent(n):{html:"",text:"",isEmpty:!0,characterCount:0},setBodyContent:e=>{const t=a(e);i(o=>r.setSectionContentInEditor(o,"body",t))},setBodyAndSections:(e,t)=>{const o=r.buildSectionedContent(a(e),t.map(s=>({id:s.id,content:a(s.content)})));i(s=>s.commands.setContent(o,{emitUpdate:!0}))},appendBodyContent:e=>{const t=a(e);i(o=>{const s=r.findSectionEndPos(o,"body");o.commands.insertContentAt(s-1,t,{parseOptions:{preserveWhitespace:!0}})})},insertAtSectionStart:(e,t)=>{const o=a(t);i(s=>{const u=r.findSectionStartPos(s,e);u!==-1&&s.commands.insertContentAt(u,o,{parseOptions:{preserveWhitespace:!0}})})},insertAtSectionEnd:(e,t)=>{const o=a(t);i(s=>{const u=r.findSectionEndPos(s,e);s.commands.insertContentAt(u,o,{parseOptions:{preserveWhitespace:!0}})})},getActiveFormats:()=>n?r.extractActiveFormats(n):K.DEFAULT_FORMAT_STATE,actions:{toggleBold:()=>n?.chain().focus().toggleBold().run(),toggleItalic:()=>n?.chain().focus().toggleItalic().run(),toggleUnderline:()=>n?.chain().focus().toggleUnderline().run(),toggleStrike:()=>n?.chain().focus().toggleStrike().run(),toggleBulletList:()=>n?.chain().focus().toggleBulletList().run(),toggleOrderedList:()=>n?.chain().focus().toggleOrderedList().run(),toggleBlockquote:()=>n?.chain().focus().toggleBlockquote().run(),toggleCodeBlock:()=>n?.chain().focus().toggleCodeBlock().run(),setTextAlign:e=>n?.chain().focus().setTextAlign(e).run(),setFontFamily:e=>n?.chain().focus().setFontFamily(e).run(),setFontSize:e=>n?.chain().focus().setFontSize(e).run(),setColor:e=>n?.chain().focus().setColor(e).run(),setHighlight:e=>n?.chain().focus().toggleHighlight({color:e}).run(),unsetColor:()=>n?.chain().focus().unsetColor().run(),unsetHighlight:()=>n?.chain().focus().unsetHighlight().run(),setLink:(e,t)=>{n&&(t!==void 0?n.chain().focus().extendMarkRange("link").command(({tr:o,state:s})=>{const{from:u,to:f}=o.selection,V=s.schema.marks.link;if(!V)return!1;const ge=s.schema.text(t,[V.create({href:e})]),fe=s.schema.text(" ");return o.replaceWith(u,f,[ge,fe]),!0}).run():n.chain().focus().extendMarkRange("link").setLink({href:e}).insertContent(" ").run())},updateLink:e=>n?.chain().focus().extendMarkRange("link").setLink({href:e}).run(),removeLink:()=>n?.chain().focus().extendMarkRange("link").unsetLink().run(),insertEmoji:e=>n?.chain().focus().insertContent(e).run(),insertVariable:e=>n?.chain().focus().insertContent(`{{${e}}}`).run(),insertHtml:e=>n?.commands.insertContent(a(e)),undo:()=>n?.chain().focus().undo().run(),redo:()=>n?.chain().focus().redo().run(),canUndo:()=>n?.can().undo()??!1,canRedo:()=>n?.can().redo()??!1,toggleSuperscript:()=>n?.chain().focus().toggleSuperscript().run(),toggleSubscript:()=>n?.chain().focus().toggleSubscript().run(),insertImage:e=>n?.chain().focus().setImage({src:e}).run()},json:k?.jsonMode?{getText:()=>n?r.getCodeBlockText(n):"",setText:e=>i(t=>r.setCodeBlockText(t,e)),parse:()=>r.parseJson(n?r.getCodeBlockText(n):""),isValid:()=>r.parseJson(n?r.getCodeBlockText(n):"").valid,format:(e=2)=>i(t=>{const{valid:o,value:s}=r.parseJson(r.getCodeBlockText(t));!o||s===null||r.setCodeBlockText(t,JSON.stringify(s,null,e))}),minify:()=>i(e=>{const{valid:t,value:o}=r.parseJson(r.getCodeBlockText(e));!t||o===null||r.setCodeBlockText(e,JSON.stringify(o))})}:void 0}),[n]);const de=()=>{if(!n)return;const{valid:e,value:t}=r.parseJson(r.getCodeBlockText(n));!e||t===null||r.setCodeBlockText(n,JSON.stringify(t,null,2))},me=()=>{n&&(navigator.clipboard?.writeText(r.getCodeBlockText(n)),q(!0),setTimeout(()=>q(!1),1500))};return n?l.jsxs(b.BikEditorShell,{minHeight:re,maxHeight:ie,tightParagraphs:!k?.richPaste,jsonMode:g,style:ce,className:ae,children:[g&&l.jsxs(b.BikJsonHeader,{children:[l.jsx("span",{className:"bik-json-header-label",children:"JSON"}),l.jsxs("div",{className:"bik-json-header-actions",children:[l.jsxs("button",{type:"button",onClick:de,disabled:!!m,title:"Format JSON",children:[l.jsx(ke.default,{size:16}),l.jsx(Z.BodyCaption,{children:"Beautify"})]}),l.jsxs("button",{type:"button",onClick:me,title:"Copy JSON",children:[l.jsx(Se.default,{size:16}),le&&l.jsx(Z.BodyCaption,{children:"Copied"})]})]})]}),l.jsx(Q.EditorContent,{editor:n}),l.jsx(Ce.LinkBubbleMenu,{editor:n,renderLinkTooltip:oe?.renderTooltip}),g&&m?M?M(m):l.jsxs(b.BikJsonError,{children:[m.line!=null&&l.jsxs("strong",{children:["Line ",m.line,m.column!=null?`, column ${m.column}`:"",":"," "]}),m.error]}):null]}):null},X=c.forwardRef(ye);X.displayName="BikEditor";exports.BikEditor=X;
|
|
2
2
|
//# sourceMappingURL=BikEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BikEditor.js","sources":["../../../src/editor/BikEditor.tsx"],"sourcesContent":["'use client';\n\n/**\n * IMPLEMENTATION LAYER — TipTap-specific.\n * If the underlying editor is swapped, this file changes; BikEditor.types.ts and\n * src/editor/index.ts (the consumer contract) do NOT change.\n */\nimport { Editor, getMarkRange } from '@tiptap/core';\nimport { EditorContent, useEditor } from '@tiptap/react';\nimport React, {\n\tforwardRef,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport { BodyCaption } from '@src/components/TypographyStyle';\nimport { Copy, WandSparkles } from '../icons';\nimport {\n\tBikEditorShell,\n\tBikJsonError,\n\tBikJsonHeader,\n} from './BikEditor.styles';\nimport {\n\tBikEditorProps,\n\tBikEditorRef,\n\tDEFAULT_FORMAT_STATE,\n\tFormatState,\n\tJsonParseResult,\n} from './BikEditor.types';\nimport {\n\tbuildJsonCodeBlockHtml,\n\tbuildSectionedContent,\n\textractActiveFormats,\n\textractBodyContent,\n\textractContent,\n\textractSectionContent,\n\tfindSectionEndPos,\n\tfindSectionStartPos,\n\tgetCodeBlockText,\n\tinsertInlineHtml,\n\tnormalizeHtml,\n\tparseJson,\n\tsetCodeBlockText,\n\tsetSectionContentInEditor,\n} from './BikEditor.utils';\nimport { buildExtensions } from './extensions/buildExtensions';\nimport { LinkBubbleMenu } from './floating/LinkBubbleMenu';\n\n/** Convert React.CSSProperties to an inline CSS string for editorProps.attributes. */\nfunction cssToString(style: React.CSSProperties): string {\n\treturn Object.entries(style)\n\t\t.map(\n\t\t\t([k, v]) => `${k.replace(/([A-Z])/g, (c) => `-${c.toLowerCase()}`)}:${v}`,\n\t\t)\n\t\t.join(';');\n}\n\nconst BikEditorInner = (\n\tprops: BikEditorProps,\n\tref: React.Ref<BikEditorRef>,\n) => {\n\tconst {\n\t\tinitialContent,\n\t\tsections,\n\t\tfeatures,\n\t\tdisabled,\n\t\tmaxCharacters,\n\t\tcharacterLimit,\n\t\tshortcuts,\n\t\tsendShortcut,\n\t\tmentions,\n\t\tslashCommands,\n\t\tlink,\n\t\tonPaste,\n\t\tonReady,\n\t\tonChange,\n\t\tonSend,\n\t\tonFocus,\n\t\tonBlur,\n\t\tonSelectionChange,\n\t\tminHeight,\n\t\tmaxHeight,\n\t\tstyle,\n\t\tclassName,\n\t\teditorClassName,\n\t\teditorStyle,\n\t\trenderJsonError,\n\t} = props;\n\n\tconst isJsonMode = !!features?.jsonMode;\n\n\t// Live JSON parse error, shown inside the editor when jsonMode is on.\n\t// null = valid (or not applicable) → nothing rendered.\n\tconst [jsonError, setJsonError] = useState<JsonParseResult | null>(null);\n\t// Transient \"Copied\" state for the jsonMode copy button.\n\tconst [jsonCopied, setJsonCopied] = useState(false);\n\n\t// JSON body mode: treat initialContent as raw JSON text and wrap it in a code\n\t// block. Skips section/HTML normalisation entirely.\n\tconst initialEditorContent = isJsonMode\n\t\t? buildJsonCodeBlockHtml(initialContent ?? '')\n\t\t: sections?.length\n\t\t? buildSectionedContent(\n\t\t\t\tnormalizeHtml(initialContent ?? ''),\n\t\t\t\tsections.map((s) => ({ ...s, content: normalizeHtml(s.content) })),\n\t\t )\n\t\t: normalizeHtml(initialContent ?? '');\n\n\t// ── Command queue ─────────────────────────────────────────────────────────\n\t// TipTap's useEditor initializes asynchronously; the editor instance is null\n\t// until the first commit. Any imperative method called before the editor is\n\t// ready is enqueued here and flushed automatically once it becomes non-null.\n\t// Consumers never need setTimeout or readiness guards.\n\tconst pendingQueue = useRef<Array<(e: Editor) => void>>([]);\n\tconst hasCalledOnReady = useRef(false);\n\t// Keep stable refs to all callbacks so useEditor receives the same function\n\t// identity on every render — prevents TipTap from re-registering event\n\t// handlers every time the parent re-renders with new inline function props.\n\tconst onReadyRef = useRef(onReady);\n\tonReadyRef.current = onReady;\n\tconst onChangeRef = useRef(onChange);\n\tonChangeRef.current = onChange;\n\tconst onSelectionChangeRef = useRef(onSelectionChange);\n\tonSelectionChangeRef.current = onSelectionChange;\n\tconst prevFormatsRef = useRef<FormatState>(DEFAULT_FORMAT_STATE);\n\tconst onFocusRef = useRef(onFocus);\n\tonFocusRef.current = onFocus;\n\tconst onBlurRef = useRef(onBlur);\n\tonBlurRef.current = onBlur;\n\tconst onSendRef = useRef(onSend);\n\tonSendRef.current = onSend;\n\tconst agentMentionsRef = useRef(mentions?.agents ?? []);\n\tagentMentionsRef.current = mentions?.agents ?? [];\n\tconst teamMentionsRef = useRef(mentions?.teams ?? []);\n\tteamMentionsRef.current = mentions?.teams ?? [];\n\tconst slashCommandsRef = useRef(slashCommands?.items ?? []);\n\tslashCommandsRef.current = slashCommands?.items ?? [];\n\n\tconst editor = useEditor({\n\t\textensions: buildExtensions({\n\t\t\tfeatures,\n\t\t\tplaceholder: props.placeholder,\n\t\t\tmaxCharacters,\n\t\t\tcharacterLimit,\n\t\t\thasSections: (sections?.length ?? 0) > 0,\n\t\t\tmentions: {\n\t\t\t\tagents: mentions ? agentMentionsRef : undefined,\n\t\t\t\tteams: mentions ? teamMentionsRef : undefined,\n\t\t\t},\n\t\t\tslashCommands: slashCommands ? slashCommandsRef : undefined,\n\t\t\tonPaste,\n\t\t\tonSend: onSend ? (snapshot) => onSendRef.current?.(snapshot) : undefined,\n\t\t\tsendShortcut,\n\t\t\tshortcuts,\n\t\t\tonMentionSelected: mentions?.onSelect,\n\t\t\tonSlashCommandSelected: slashCommands?.onSelect,\n\t\t\trenderMentionItem: mentions?.renderItem,\n\t\t\trenderMentionDropdown: mentions?.renderDropdown,\n\t\t\tremoveMentionTriggerOnDismiss: mentions?.removeTriggerOnDismiss,\n\t\t\trenderSlashCommandItem: slashCommands?.renderItem,\n\t\t\trenderSlashCommandDropdown: slashCommands?.renderDropdown,\n\t\t}),\n\t\tcontent: initialEditorContent,\n\t\teditable: !disabled,\n\t\timmediatelyRender: false, // SSR-safe — NEVER remove this\n\t\teditorProps: {\n\t\t\tattributes: {\n\t\t\t\t...(editorClassName ? { class: editorClassName } : {}),\n\t\t\t\t...(editorStyle ? { style: cssToString(editorStyle) } : {}),\n\t\t\t},\n\t\t},\n\t\tonUpdate: ({ editor: e }) => {\n\t\t\tonChangeRef.current?.(extractContent(e));\n\t\t\tif (isJsonMode) {\n\t\t\t\tconst result = parseJson(getCodeBlockText(e));\n\t\t\t\tsetJsonError(result.valid ? null : result);\n\t\t\t}\n\t\t},\n\t\tonTransaction: ({ editor: e }) => {\n\t\t\tconst next = extractActiveFormats(e);\n\t\t\tconst prev = prevFormatsRef.current;\n\t\t\tconst changed =\n\t\t\t\tprev.bold !== next.bold ||\n\t\t\t\tprev.italic !== next.italic ||\n\t\t\t\tprev.underline !== next.underline ||\n\t\t\t\tprev.strike !== next.strike ||\n\t\t\t\tprev.bulletList !== next.bulletList ||\n\t\t\t\tprev.orderedList !== next.orderedList ||\n\t\t\t\tprev.blockquote !== next.blockquote ||\n\t\t\t\tprev.codeBlock !== next.codeBlock ||\n\t\t\t\tprev.superscript !== next.superscript ||\n\t\t\t\tprev.subscript !== next.subscript ||\n\t\t\t\tprev.textAlign !== next.textAlign ||\n\t\t\t\tprev.fontFamily !== next.fontFamily ||\n\t\t\t\tprev.fontSize !== next.fontSize ||\n\t\t\t\tprev.color !== next.color ||\n\t\t\t\tprev.highlight !== next.highlight ||\n\t\t\t\tprev.link?.href !== next.link?.href;\n\t\t\tif (changed) {\n\t\t\t\tprevFormatsRef.current = next;\n\t\t\t\tonSelectionChangeRef.current?.(next);\n\t\t\t}\n\t\t},\n\t\tonFocus: () => onFocusRef.current?.(),\n\t\tonBlur: () => onBlurRef.current?.(),\n\t});\n\n\t// ── enqueue ───────────────────────────────────────────────────────────────\n\t// Run immediately if the editor is ready; otherwise defer to the queue.\n\t// Closures passed to enqueue MUST capture all parameters explicitly —\n\t// they must NOT close over `editor` (which would be null at enqueue time).\n\tfunction enqueue(op: (e: Editor) => void): void {\n\t\tif (editor) {\n\t\t\top(editor);\n\t\t} else {\n\t\t\tpendingQueue.current.push(op);\n\t\t}\n\t}\n\n\t// Flush the pending queue and fire onReady when editor transitions null → ready.\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\t\tif (pendingQueue.current.length > 0) {\n\t\t\tconst queue = pendingQueue.current.splice(0);\n\t\t\tqueue.forEach((op) => op(editor));\n\t\t}\n\t\tif (!hasCalledOnReady.current) {\n\t\t\thasCalledOnReady.current = true;\n\t\t\tonReadyRef.current?.();\n\t\t}\n\t\t// Surface an error for invalid initialContent immediately on mount.\n\t\tif (isJsonMode) {\n\t\t\tconst result = parseJson(getCodeBlockText(editor));\n\t\t\tsetJsonError(result.valid ? null : result);\n\t\t}\n\t}, [editor, isJsonMode]);\n\n\tuseImperativeHandle(\n\t\tref,\n\t\t() => ({\n\t\t\t// ── Focus ────────────────────────────────────────────────────────\n\t\t\tfocus: (position) => enqueue((e) => e.commands.focus(position)),\n\t\t\tblur: () => enqueue((e) => e.commands.blur()),\n\n\t\t\t// ── Content ──────────────────────────────────────────────────────\n\t\t\tclearContent: () => enqueue((e) => e.commands.clearContent(true)),\n\t\t\tsetContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.setContent(normalised, { emitUpdate: true }));\n\t\t\t},\n\t\t\tinsertContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.insertContent(normalised));\n\t\t\t},\n\t\t\tinsertInlineContent: (html) => {\n\t\t\t\tenqueue((e) => insertInlineHtml(e, html));\n\t\t\t},\n\t\t\tinsertAtStart: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.insertContentAt(1, normalised));\n\t\t\t},\n\t\t\tinsertBlock: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) =>\n\t\t\t\t\te.commands.insertContentAt(e.state.doc.content.size, normalised),\n\t\t\t\t);\n\t\t\t},\n\t\t\tappendInline: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\t// doc.content.size is after the last </p> (block boundary).\n\t\t\t\t// Subtract 1 to land inside the last paragraph so text appends\n\t\t\t\t// inline rather than being wrapped in a new paragraph each call.\n\t\t\t\tenqueue((e) =>\n\t\t\t\t\te.commands.insertContentAt(e.state.doc.content.size - 1, normalised),\n\t\t\t\t);\n\t\t\t},\n\t\t\t// Backwards-compatible aliases\n\t\t\tinsertAtEnd(html) {\n\t\t\t\tthis.insertBlock(html);\n\t\t\t},\n\t\t\tappendContent(html) {\n\t\t\t\tthis.appendInline(html);\n\t\t\t},\n\t\t\tgetContent: () =>\n\t\t\t\teditor\n\t\t\t\t\t? extractContent(editor)\n\t\t\t\t\t: { html: '', text: '', isEmpty: true, characterCount: 0 },\n\t\t\tgetJSON: () => editor?.getJSON() ?? null,\n\t\t\tgetMentions: () => {\n\t\t\t\tconst agentIds = new Set<string>();\n\t\t\t\tconst teamIds = new Set<string>();\n\t\t\t\tif (!editor) return { agentIds: [], teamIds: [] };\n\t\t\t\teditor.state.doc.descendants((node) => {\n\t\t\t\t\tif (node.type.name === 'mentionAgent' && node.attrs['id'] != null) {\n\t\t\t\t\t\tagentIds.add(String(node.attrs['id']));\n\t\t\t\t\t} else if (\n\t\t\t\t\t\tnode.type.name === 'mentionTeam' &&\n\t\t\t\t\t\tnode.attrs['id'] != null\n\t\t\t\t\t) {\n\t\t\t\t\t\tteamIds.add(String(node.attrs['id']));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn { agentIds: Array.from(agentIds), teamIds: Array.from(teamIds) };\n\t\t\t},\n\n\t\t\t// ── Selection ────────────────────────────────────────────────────\n\t\t\tgetCursorPosition: () => {\n\t\t\t\tif (!editor) return { from: 0, to: 0 };\n\t\t\t\tconst { from, to } = editor.state.selection;\n\t\t\t\treturn { from, to };\n\t\t\t},\n\t\t\tinsertAtPosition: (pos, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.insertContentAt(pos, normalised));\n\t\t\t},\n\t\t\tgetSelectedText: () => {\n\t\t\t\tif (!editor) return '';\n\t\t\t\tconst { state } = editor;\n\t\t\t\tconst { from, to, empty } = state.selection;\n\t\t\t\tif (!empty) {\n\t\t\t\t\treturn state.doc.textBetween(from, to, ' ');\n\t\t\t\t}\n\t\t\t\t// When the cursor is inside a link with nothing selected, return the\n\t\t\t\t// full link text — useful for pre-filling a link modal's text field.\n\t\t\t\tconst linkMarkType = state.schema.marks['link'];\n\t\t\t\tif (linkMarkType) {\n\t\t\t\t\tconst range = getMarkRange(state.doc.resolve(from), linkMarkType);\n\t\t\t\t\tif (range) {\n\t\t\t\t\t\treturn state.doc.textBetween(range.from, range.to, ' ');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn '';\n\t\t\t},\n\n\t\t\t// ── Character count ───────────────────────────────────────────────\n\t\t\tgetCharacterCount: () => ({\n\t\t\t\tcount:\n\t\t\t\t\teditor?.storage.characterCount?.characters?.() ??\n\t\t\t\t\teditor?.getText().length ??\n\t\t\t\t\t0,\n\t\t\t\tlimit: maxCharacters ?? null,\n\t\t\t}),\n\n\t\t\t// ── Sections ─────────────────────────────────────────────────────\n\t\t\tgetSectionContent: (sectionId) =>\n\t\t\t\teditor\n\t\t\t\t\t? extractSectionContent(editor, sectionId)\n\t\t\t\t\t: { html: '', text: '', isEmpty: true, characterCount: 0 },\n\n\t\t\tsetSectionContent: (sectionId, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => setSectionContentInEditor(e, sectionId, normalised));\n\t\t\t},\n\n\t\t\tfocusSection: (sectionId) => {\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tif (sectionId === 'body') {\n\t\t\t\t\t\tlet endOfBody = e.state.doc.content.size - 1;\n\t\t\t\t\t\te.state.doc.descendants((node, pos) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\t\t\t\t\t\tendOfBody === e.state.doc.content.size - 1\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tendOfBody = pos - 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn endOfBody === e.state.doc.content.size - 1;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (endOfBody < 1) endOfBody = 1;\n\t\t\t\t\t\te.chain().focus().setTextSelection(endOfBody).run();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlet targetPos = -1;\n\t\t\t\t\te.state.doc.descendants((node, pos) => {\n\t\t\t\t\t\tif (targetPos !== -1) return false;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\t\t\t\t\tnode.attrs['sectionId'] === sectionId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// pos + nodeSize lands right after the divider;\n\t\t\t\t\t\t\t// +1 more puts us inside the first paragraph of that section.\n\t\t\t\t\t\t\ttargetPos = pos + node.nodeSize + 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tif (targetPos !== -1) {\n\t\t\t\t\t\te.chain().focus().setTextSelection(targetPos).run();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\n\t\t\tclearSection: (sectionId) => {\n\t\t\t\tenqueue((e) => setSectionContentInEditor(e, sectionId, '<p></p>'));\n\t\t\t},\n\n\t\t\t// ── Convenience body shorthands ───────────────────────────────────\n\t\t\tgetBodyContent: () =>\n\t\t\t\teditor\n\t\t\t\t\t? extractBodyContent(editor)\n\t\t\t\t\t: { html: '', text: '', isEmpty: true, characterCount: 0 },\n\t\t\tsetBodyContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => setSectionContentInEditor(e, 'body', normalised));\n\t\t\t},\n\t\t\tsetBodyAndSections: (body, sections) => {\n\t\t\t\tconst html = buildSectionedContent(\n\t\t\t\t\tnormalizeHtml(body),\n\t\t\t\t\tsections.map((s) => ({\n\t\t\t\t\t\tid: s.id,\n\t\t\t\t\t\tcontent: normalizeHtml(s.content),\n\t\t\t\t\t})),\n\t\t\t\t);\n\t\t\t\tenqueue((e) => e.commands.setContent(html, { emitUpdate: true }));\n\t\t\t},\n\t\t\tappendBodyContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\t// findSectionEndPos returns the position of the first divider (or\n\t\t\t\t// doc.content.size), which is the block boundary after the last </p>.\n\t\t\t\t// Subtract 1 to stay inside the last paragraph so successive calls\n\t\t\t\t// append inline text rather than creating a new paragraph each time.\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tconst boundaryPos = findSectionEndPos(e, 'body');\n\t\t\t\t\te.commands.insertContentAt(boundaryPos - 1, normalised, {\n\t\t\t\t\t\tparseOptions: { preserveWhitespace: true },\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tinsertAtSectionStart: (sectionId, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tconst pos = findSectionStartPos(e, sectionId);\n\t\t\t\t\tif (pos !== -1)\n\t\t\t\t\t\te.commands.insertContentAt(pos, normalised, {\n\t\t\t\t\t\t\tparseOptions: { preserveWhitespace: true },\n\t\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tinsertAtSectionEnd: (sectionId, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tconst pos = findSectionEndPos(e, sectionId);\n\t\t\t\t\te.commands.insertContentAt(pos, normalised, {\n\t\t\t\t\t\tparseOptions: { preserveWhitespace: true },\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\t// ── Formats & actions ─────────────────────────────────────────────\n\t\t\tgetActiveFormats: () =>\n\t\t\t\teditor ? extractActiveFormats(editor) : DEFAULT_FORMAT_STATE,\n\t\t\tactions: {\n\t\t\t\ttoggleBold: () => editor?.chain().focus().toggleBold().run(),\n\t\t\t\ttoggleItalic: () => editor?.chain().focus().toggleItalic().run(),\n\t\t\t\ttoggleUnderline: () => editor?.chain().focus().toggleUnderline().run(),\n\t\t\t\ttoggleStrike: () => editor?.chain().focus().toggleStrike().run(),\n\t\t\t\ttoggleBulletList: () =>\n\t\t\t\t\teditor?.chain().focus().toggleBulletList().run(),\n\t\t\t\ttoggleOrderedList: () =>\n\t\t\t\t\teditor?.chain().focus().toggleOrderedList().run(),\n\t\t\t\ttoggleBlockquote: () =>\n\t\t\t\t\teditor?.chain().focus().toggleBlockquote().run(),\n\t\t\t\ttoggleCodeBlock: () => editor?.chain().focus().toggleCodeBlock().run(),\n\t\t\t\tsetTextAlign: (align) =>\n\t\t\t\t\teditor?.chain().focus().setTextAlign(align).run(),\n\t\t\t\tsetFontFamily: (font) =>\n\t\t\t\t\teditor?.chain().focus().setFontFamily(font).run(),\n\t\t\t\tsetFontSize: (size) => editor?.chain().focus().setFontSize(size).run(),\n\t\t\t\tsetColor: (color) => editor?.chain().focus().setColor(color).run(),\n\t\t\t\tsetHighlight: (color) =>\n\t\t\t\t\teditor?.chain().focus().toggleHighlight({ color }).run(),\n\t\t\t\tunsetColor: () => editor?.chain().focus().unsetColor().run(),\n\t\t\t\tunsetHighlight: () => editor?.chain().focus().unsetHighlight().run(),\n\t\t\t\tsetLink: (href, text) => {\n\t\t\t\t\tif (!editor) return;\n\t\t\t\t\tif (text !== undefined) {\n\t\t\t\t\t\teditor\n\t\t\t\t\t\t\t.chain()\n\t\t\t\t\t\t\t.focus()\n\t\t\t\t\t\t\t.extendMarkRange('link')\n\t\t\t\t\t\t\t.command(({ tr, state }) => {\n\t\t\t\t\t\t\t\tconst { from, to } = tr.selection;\n\t\t\t\t\t\t\t\tconst linkMarkType = state.schema.marks['link'];\n\t\t\t\t\t\t\t\tif (!linkMarkType) return false;\n\t\t\t\t\t\t\t\tconst linkNode = state.schema.text(text, [\n\t\t\t\t\t\t\t\t\tlinkMarkType.create({ href }),\n\t\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\t\tconst space = state.schema.text(' ');\n\t\t\t\t\t\t\t\ttr.replaceWith(from, to, [linkNode, space]);\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.run();\n\t\t\t\t\t} else {\n\t\t\t\t\t\teditor\n\t\t\t\t\t\t\t.chain()\n\t\t\t\t\t\t\t.focus()\n\t\t\t\t\t\t\t.extendMarkRange('link')\n\t\t\t\t\t\t\t.setLink({ href })\n\t\t\t\t\t\t\t.insertContent(' ')\n\t\t\t\t\t\t\t.run();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tupdateLink: (href) =>\n\t\t\t\t\teditor\n\t\t\t\t\t\t?.chain()\n\t\t\t\t\t\t.focus()\n\t\t\t\t\t\t.extendMarkRange('link')\n\t\t\t\t\t\t.setLink({ href })\n\t\t\t\t\t\t.run(),\n\t\t\t\tremoveLink: () =>\n\t\t\t\t\teditor?.chain().focus().extendMarkRange('link').unsetLink().run(),\n\t\t\t\tinsertEmoji: (emoji) =>\n\t\t\t\t\teditor?.chain().focus().insertContent(emoji).run(),\n\t\t\t\tinsertVariable: (variableName) =>\n\t\t\t\t\teditor?.chain().focus().insertContent(`{{${variableName}}}`).run(),\n\t\t\t\tinsertHtml: (html) =>\n\t\t\t\t\teditor?.commands.insertContent(normalizeHtml(html)),\n\t\t\t\tundo: () => editor?.chain().focus().undo().run(),\n\t\t\t\tredo: () => editor?.chain().focus().redo().run(),\n\t\t\t\tcanUndo: () => editor?.can().undo() ?? false,\n\t\t\t\tcanRedo: () => editor?.can().redo() ?? false,\n\t\t\t\ttoggleSuperscript: () =>\n\t\t\t\t\teditor?.chain().focus().toggleSuperscript().run(),\n\t\t\t\ttoggleSubscript: () => editor?.chain().focus().toggleSubscript().run(),\n\t\t\t\tinsertImage: (src) => editor?.chain().focus().setImage({ src }).run(),\n\t\t\t},\n\n\t\t\t// ── JSON body ─────────────────────────────────────────────────────\n\t\t\tjson: features?.jsonMode\n\t\t\t\t? {\n\t\t\t\t\t\tgetText: () => (editor ? getCodeBlockText(editor) : ''),\n\t\t\t\t\t\tsetText: (raw) => enqueue((e) => setCodeBlockText(e, raw)),\n\t\t\t\t\t\tparse: () => parseJson(editor ? getCodeBlockText(editor) : ''),\n\t\t\t\t\t\tisValid: () =>\n\t\t\t\t\t\t\tparseJson(editor ? getCodeBlockText(editor) : '').valid,\n\t\t\t\t\t\tformat: (indent = 2) =>\n\t\t\t\t\t\t\tenqueue((e) => {\n\t\t\t\t\t\t\t\tconst { valid, value } = parseJson(getCodeBlockText(e));\n\t\t\t\t\t\t\t\tif (!valid || value === null) return;\n\t\t\t\t\t\t\t\tsetCodeBlockText(e, JSON.stringify(value, null, indent));\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\tminify: () =>\n\t\t\t\t\t\t\tenqueue((e) => {\n\t\t\t\t\t\t\t\tconst { valid, value } = parseJson(getCodeBlockText(e));\n\t\t\t\t\t\t\t\tif (!valid || value === null) return;\n\t\t\t\t\t\t\t\tsetCodeBlockText(e, JSON.stringify(value));\n\t\t\t\t\t\t\t}),\n\t\t\t\t }\n\t\t\t\t: undefined,\n\t\t}),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[editor],\n\t);\n\n\t// ── jsonMode floating actions ────────────────────────────────────────────\n\t// Beautify pretty-prints in place (no-op / disabled while the JSON is broken);\n\t// Copy writes the raw text to the clipboard with transient feedback.\n\tconst handleJsonBeautify = () => {\n\t\tif (!editor) return;\n\t\tconst { valid, value } = parseJson(getCodeBlockText(editor));\n\t\tif (!valid || value === null) return;\n\t\tsetCodeBlockText(editor, JSON.stringify(value, null, 2));\n\t};\n\tconst handleJsonCopy = () => {\n\t\tif (!editor) return;\n\t\tvoid navigator.clipboard?.writeText(getCodeBlockText(editor));\n\t\tsetJsonCopied(true);\n\t\tsetTimeout(() => setJsonCopied(false), 1500);\n\t};\n\n\tif (!editor) return null;\n\n\treturn (\n\t\t<BikEditorShell\n\t\t\tminHeight={minHeight}\n\t\t\tmaxHeight={maxHeight}\n\t\t\ttightParagraphs={!features?.richPaste}\n\t\t\tjsonMode={isJsonMode}\n\t\t\tstyle={style}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t{isJsonMode && (\n\t\t\t\t<BikJsonHeader>\n\t\t\t\t\t<span className=\"bik-json-header-label\">JSON</span>\n\t\t\t\t\t<div className=\"bik-json-header-actions\">\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tonClick={handleJsonBeautify}\n\t\t\t\t\t\t\tdisabled={!!jsonError}\n\t\t\t\t\t\t\ttitle=\"Format JSON\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<WandSparkles size={16} />\n\t\t\t\t\t\t\t<BodyCaption>Beautify</BodyCaption>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t\t<button type=\"button\" onClick={handleJsonCopy} title=\"Copy JSON\">\n\t\t\t\t\t\t\t<Copy size={16} />\n\t\t\t\t\t\t\t{jsonCopied && <BodyCaption>Copied</BodyCaption>}\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</div>\n\t\t\t\t</BikJsonHeader>\n\t\t\t)}\n\t\t\t<EditorContent editor={editor} />\n\t\t\t<LinkBubbleMenu editor={editor} renderLinkTooltip={link?.renderTooltip} />\n\t\t\t{isJsonMode && jsonError ? (\n\t\t\t\trenderJsonError ? (\n\t\t\t\t\trenderJsonError(jsonError)\n\t\t\t\t) : (\n\t\t\t\t\t<BikJsonError>\n\t\t\t\t\t\t{jsonError.line != null && (\n\t\t\t\t\t\t\t<strong>\n\t\t\t\t\t\t\t\tLine {jsonError.line}\n\t\t\t\t\t\t\t\t{jsonError.column != null ? `, column ${jsonError.column}` : ''}\n\t\t\t\t\t\t\t\t:{' '}\n\t\t\t\t\t\t\t</strong>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{jsonError.error}\n\t\t\t\t\t</BikJsonError>\n\t\t\t\t)\n\t\t\t) : null}\n\t\t</BikEditorShell>\n\t);\n};\n\nexport const BikEditor = forwardRef<BikEditorRef, BikEditorProps>(\n\tBikEditorInner,\n);\nBikEditor.displayName = 'BikEditor';\n"],"names":["cssToString","style","k","v","c","BikEditorInner","props","ref","initialContent","sections","features","disabled","maxCharacters","characterLimit","shortcuts","sendShortcut","mentions","slashCommands","link","onPaste","onReady","onChange","onSend","onFocus","onBlur","onSelectionChange","minHeight","maxHeight","className","editorClassName","editorStyle","renderJsonError","isJsonMode","jsonError","setJsonError","useState","jsonCopied","setJsonCopied","initialEditorContent","buildJsonCodeBlockHtml","buildSectionedContent","normalizeHtml","s","pendingQueue","useRef","hasCalledOnReady","onReadyRef","onChangeRef","onSelectionChangeRef","prevFormatsRef","DEFAULT_FORMAT_STATE","onFocusRef","onBlurRef","onSendRef","agentMentionsRef","teamMentionsRef","slashCommandsRef","editor","useEditor","buildExtensions","snapshot","extractContent","result","parseJson","getCodeBlockText","next","extractActiveFormats","prev","enqueue","op","useEffect","useImperativeHandle","position","e","html","normalised","insertInlineHtml","agentIds","teamIds","node","from","to","pos","state","empty","linkMarkType","range","getMarkRange","sectionId","extractSectionContent","setSectionContentInEditor","endOfBody","targetPos","extractBodyContent","body","boundaryPos","findSectionEndPos","findSectionStartPos","align","font","size","color","href","text","tr","linkNode","space","emoji","variableName","src","raw","setCodeBlockText","indent","valid","value","handleJsonBeautify","handleJsonCopy","jsxs","BikEditorShell","BikJsonHeader","jsx","WandSparkles","BodyCaption","Copy","EditorContent","LinkBubbleMenu","BikJsonError","BikEditor","forwardRef"],"mappings":"mjBAkDA,SAASA,GAAYC,EAAoC,CACxD,OAAO,OAAO,QAAQA,CAAK,EACzB,IACA,CAAC,CA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IAACK,GAAAA,eAAA,CAAe,OAAApE,EAAgB,kBAAmBvC,IAAM,cAAe,EACvEc,GAAcC,EACdF,EACCA,EAAgBE,CAAS,SAExB6F,eAAA,CACC,SAAA,CAAA7F,EAAU,MAAQ,MAClBoF,EAAAA,KAAC,SAAA,CAAO,SAAA,CAAA,QACDpF,EAAU,KACfA,EAAU,QAAU,KAAO,YAAYA,EAAU,MAAM,GAAK,GAAG,IAC9D,GAAA,EACH,EAEAA,EAAU,KAAA,CAAA,CACZ,EAEE,IAAA,CAAA,CAAA,EAhDc,IAmDrB,EAEa8F,EAAYC,EAAAA,WACxB3H,EACD,EACA0H,EAAU,YAAc"}
|
|
1
|
+
{"version":3,"file":"BikEditor.js","sources":["../../../src/editor/BikEditor.tsx"],"sourcesContent":["'use client';\n\n/**\n * IMPLEMENTATION LAYER — TipTap-specific.\n * If the underlying editor is swapped, this file changes; BikEditor.types.ts and\n * src/editor/index.ts (the consumer contract) do NOT change.\n */\nimport { Editor, getMarkRange } from '@tiptap/core';\nimport { EditorContent, useEditor } from '@tiptap/react';\nimport React, {\n\tforwardRef,\n\tuseCallback,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport { BodyCaption } from '@src/components/TypographyStyle';\nimport { sanitizeBasicHtml, sanitizeEmailHtml } from '../helpers/sanitize';\nimport { Copy, WandSparkles } from '../icons';\nimport {\n\tBikEditorShell,\n\tBikJsonError,\n\tBikJsonHeader,\n} from './BikEditor.styles';\nimport {\n\tBikEditorProps,\n\tBikEditorRef,\n\tDEFAULT_FORMAT_STATE,\n\tFormatState,\n\tJsonParseResult,\n} from './BikEditor.types';\nimport {\n\tbuildJsonCodeBlockHtml,\n\tbuildSectionedContent,\n\textractActiveFormats,\n\textractBodyContent,\n\textractContent,\n\textractSectionContent,\n\tfindSectionEndPos,\n\tfindSectionStartPos,\n\tgetCodeBlockText,\n\tinsertInlineHtml,\n\tnormalizeHtml,\n\tparseJson,\n\tsetCodeBlockText,\n\tsetSectionContentInEditor,\n} from './BikEditor.utils';\nimport { buildExtensions } from './extensions/buildExtensions';\nimport { LinkBubbleMenu } from './floating/LinkBubbleMenu';\n\n/** Convert React.CSSProperties to an inline CSS string for editorProps.attributes. */\nfunction cssToString(style: React.CSSProperties): string {\n\treturn Object.entries(style)\n\t\t.map(\n\t\t\t([k, v]) => `${k.replace(/([A-Z])/g, (c) => `-${c.toLowerCase()}`)}:${v}`,\n\t\t)\n\t\t.join(';');\n}\n\nconst BikEditorInner = (\n\tprops: BikEditorProps,\n\tref: React.Ref<BikEditorRef>,\n) => {\n\tconst {\n\t\tinitialContent,\n\t\tsections,\n\t\tfeatures,\n\t\tdisabled,\n\t\tmaxCharacters,\n\t\tcharacterLimit,\n\t\tshortcuts,\n\t\tsendShortcut,\n\t\tmentions,\n\t\tslashCommands,\n\t\tlink,\n\t\tonPaste,\n\t\tonReady,\n\t\tonChange,\n\t\tonSend,\n\t\tonFocus,\n\t\tonBlur,\n\t\tonSelectionChange,\n\t\tminHeight,\n\t\tmaxHeight,\n\t\tstyle,\n\t\tclassName,\n\t\teditorClassName,\n\t\teditorStyle,\n\t\trenderJsonError,\n\t} = props;\n\n\tconst isJsonMode = !!features?.jsonMode;\n\tconst isRichPaste = !!features?.richPaste;\n\n\t// Pick the right sanitizer: email channels (richPaste) get the full email\n\t// allowlist; non-email channels get the basic formatting allowlist.\n\tconst sanitizer = isRichPaste ? sanitizeEmailHtml : sanitizeBasicHtml;\n\tconst normalize = useCallback(\n\t\t(html: string) => normalizeHtml(html, sanitizer),\n\t\t[sanitizer],\n\t);\n\n\t// Live JSON parse error, shown inside the editor when jsonMode is on.\n\t// null = valid (or not applicable) → nothing rendered.\n\tconst [jsonError, setJsonError] = useState<JsonParseResult | null>(null);\n\t// Transient \"Copied\" state for the jsonMode copy button.\n\tconst [jsonCopied, setJsonCopied] = useState(false);\n\n\t// JSON body mode: treat initialContent as raw JSON text and wrap it in a code\n\t// block. Skips section/HTML normalisation entirely.\n\tconst initialEditorContent = isJsonMode\n\t\t? buildJsonCodeBlockHtml(initialContent ?? '')\n\t\t: sections?.length\n\t\t? buildSectionedContent(\n\t\t\t\tnormalize(initialContent ?? ''),\n\t\t\t\tsections.map((s) => ({ ...s, content: normalize(s.content) })),\n\t\t )\n\t\t: normalize(initialContent ?? '');\n\n\t// ── Command queue ─────────────────────────────────────────────────────────\n\t// TipTap's useEditor initializes asynchronously; the editor instance is null\n\t// until the first commit. Any imperative method called before the editor is\n\t// ready is enqueued here and flushed automatically once it becomes non-null.\n\t// Consumers never need setTimeout or readiness guards.\n\tconst pendingQueue = useRef<Array<(e: Editor) => void>>([]);\n\tconst hasCalledOnReady = useRef(false);\n\t// Keep stable refs to all callbacks so useEditor receives the same function\n\t// identity on every render — prevents TipTap from re-registering event\n\t// handlers every time the parent re-renders with new inline function props.\n\tconst onReadyRef = useRef(onReady);\n\tonReadyRef.current = onReady;\n\tconst onChangeRef = useRef(onChange);\n\tonChangeRef.current = onChange;\n\tconst onSelectionChangeRef = useRef(onSelectionChange);\n\tonSelectionChangeRef.current = onSelectionChange;\n\tconst prevFormatsRef = useRef<FormatState>(DEFAULT_FORMAT_STATE);\n\tconst onFocusRef = useRef(onFocus);\n\tonFocusRef.current = onFocus;\n\tconst onBlurRef = useRef(onBlur);\n\tonBlurRef.current = onBlur;\n\tconst onSendRef = useRef(onSend);\n\tonSendRef.current = onSend;\n\tconst agentMentionsRef = useRef(mentions?.agents ?? []);\n\tagentMentionsRef.current = mentions?.agents ?? [];\n\tconst teamMentionsRef = useRef(mentions?.teams ?? []);\n\tteamMentionsRef.current = mentions?.teams ?? [];\n\tconst slashCommandsRef = useRef(slashCommands?.items ?? []);\n\tslashCommandsRef.current = slashCommands?.items ?? [];\n\n\tconst editor = useEditor({\n\t\textensions: buildExtensions({\n\t\t\tfeatures,\n\t\t\tplaceholder: props.placeholder,\n\t\t\tmaxCharacters,\n\t\t\tcharacterLimit,\n\t\t\thasSections: (sections?.length ?? 0) > 0,\n\t\t\tmentions: {\n\t\t\t\tagents: mentions ? agentMentionsRef : undefined,\n\t\t\t\tteams: mentions ? teamMentionsRef : undefined,\n\t\t\t},\n\t\t\tslashCommands: slashCommands ? slashCommandsRef : undefined,\n\t\t\tonPaste,\n\t\t\tonSend: onSend ? (snapshot) => onSendRef.current?.(snapshot) : undefined,\n\t\t\tsendShortcut,\n\t\t\tshortcuts,\n\t\t\tonMentionSelected: mentions?.onSelect,\n\t\t\tonSlashCommandSelected: slashCommands?.onSelect,\n\t\t\trenderMentionItem: mentions?.renderItem,\n\t\t\trenderMentionDropdown: mentions?.renderDropdown,\n\t\t\tremoveMentionTriggerOnDismiss: mentions?.removeTriggerOnDismiss,\n\t\t\trenderSlashCommandItem: slashCommands?.renderItem,\n\t\t\trenderSlashCommandDropdown: slashCommands?.renderDropdown,\n\t\t}),\n\t\tcontent: initialEditorContent,\n\t\teditable: !disabled,\n\t\timmediatelyRender: false, // SSR-safe — NEVER remove this\n\t\teditorProps: {\n\t\t\tattributes: {\n\t\t\t\t...(editorClassName ? { class: editorClassName } : {}),\n\t\t\t\t...(editorStyle ? { style: cssToString(editorStyle) } : {}),\n\t\t\t},\n\t\t},\n\t\tonUpdate: ({ editor: e }) => {\n\t\t\tonChangeRef.current?.(extractContent(e));\n\t\t\tif (isJsonMode) {\n\t\t\t\tconst result = parseJson(getCodeBlockText(e));\n\t\t\t\tsetJsonError(result.valid ? null : result);\n\t\t\t}\n\t\t},\n\t\tonTransaction: ({ editor: e }) => {\n\t\t\tconst next = extractActiveFormats(e);\n\t\t\tconst prev = prevFormatsRef.current;\n\t\t\tconst changed =\n\t\t\t\tprev.bold !== next.bold ||\n\t\t\t\tprev.italic !== next.italic ||\n\t\t\t\tprev.underline !== next.underline ||\n\t\t\t\tprev.strike !== next.strike ||\n\t\t\t\tprev.bulletList !== next.bulletList ||\n\t\t\t\tprev.orderedList !== next.orderedList ||\n\t\t\t\tprev.blockquote !== next.blockquote ||\n\t\t\t\tprev.codeBlock !== next.codeBlock ||\n\t\t\t\tprev.superscript !== next.superscript ||\n\t\t\t\tprev.subscript !== next.subscript ||\n\t\t\t\tprev.textAlign !== next.textAlign ||\n\t\t\t\tprev.fontFamily !== next.fontFamily ||\n\t\t\t\tprev.fontSize !== next.fontSize ||\n\t\t\t\tprev.color !== next.color ||\n\t\t\t\tprev.highlight !== next.highlight ||\n\t\t\t\tprev.link?.href !== next.link?.href;\n\t\t\tif (changed) {\n\t\t\t\tprevFormatsRef.current = next;\n\t\t\t\tonSelectionChangeRef.current?.(next);\n\t\t\t}\n\t\t},\n\t\tonFocus: () => onFocusRef.current?.(),\n\t\tonBlur: () => onBlurRef.current?.(),\n\t});\n\n\t// ── enqueue ───────────────────────────────────────────────────────────────\n\t// Run immediately if the editor is ready; otherwise defer to the queue.\n\t// Closures passed to enqueue MUST capture all parameters explicitly —\n\t// they must NOT close over `editor` (which would be null at enqueue time).\n\tfunction enqueue(op: (e: Editor) => void): void {\n\t\tif (editor) {\n\t\t\top(editor);\n\t\t} else {\n\t\t\tpendingQueue.current.push(op);\n\t\t}\n\t}\n\n\t// Flush the pending queue and fire onReady when editor transitions null → ready.\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\t\tif (pendingQueue.current.length > 0) {\n\t\t\tconst queue = pendingQueue.current.splice(0);\n\t\t\tqueue.forEach((op) => op(editor));\n\t\t}\n\t\tif (!hasCalledOnReady.current) {\n\t\t\thasCalledOnReady.current = true;\n\t\t\tonReadyRef.current?.();\n\t\t}\n\t\t// Surface an error for invalid initialContent immediately on mount.\n\t\tif (isJsonMode) {\n\t\t\tconst result = parseJson(getCodeBlockText(editor));\n\t\t\tsetJsonError(result.valid ? null : result);\n\t\t}\n\t}, [editor, isJsonMode]);\n\n\tuseImperativeHandle(\n\t\tref,\n\t\t() => ({\n\t\t\t// ── Focus ────────────────────────────────────────────────────────\n\t\t\tfocus: (position) => enqueue((e) => e.commands.focus(position)),\n\t\t\tblur: () => enqueue((e) => e.commands.blur()),\n\n\t\t\t// ── Content ──────────────────────────────────────────────────────\n\t\t\tclearContent: () => enqueue((e) => e.commands.clearContent(true)),\n\t\t\tsetContent: (html) => {\n\t\t\t\tconst normalised = normalize(html);\n\t\t\t\tenqueue((e) => e.commands.setContent(normalised, { emitUpdate: true }));\n\t\t\t},\n\t\t\tinsertContent: (html) => {\n\t\t\t\tconst normalised = normalize(html);\n\t\t\t\tenqueue((e) => e.commands.insertContent(normalised));\n\t\t\t},\n\t\t\tinsertInlineContent: (html) => {\n\t\t\t\tenqueue((e) => insertInlineHtml(e, html));\n\t\t\t},\n\t\t\tinsertAtStart: (html) => {\n\t\t\t\tconst normalised = normalize(html);\n\t\t\t\tenqueue((e) => e.commands.insertContentAt(1, normalised));\n\t\t\t},\n\t\t\tinsertBlock: (html) => {\n\t\t\t\tconst normalised = normalize(html);\n\t\t\t\tenqueue((e) =>\n\t\t\t\t\te.commands.insertContentAt(e.state.doc.content.size, normalised),\n\t\t\t\t);\n\t\t\t},\n\t\t\tappendInline: (html) => {\n\t\t\t\tconst normalised = normalize(html);\n\t\t\t\t// doc.content.size is after the last </p> (block boundary).\n\t\t\t\t// Subtract 1 to land inside the last paragraph so text appends\n\t\t\t\t// inline rather than being wrapped in a new paragraph each call.\n\t\t\t\tenqueue((e) =>\n\t\t\t\t\te.commands.insertContentAt(e.state.doc.content.size - 1, normalised),\n\t\t\t\t);\n\t\t\t},\n\t\t\t// Backwards-compatible aliases\n\t\t\tinsertAtEnd(html) {\n\t\t\t\tthis.insertBlock(html);\n\t\t\t},\n\t\t\tappendContent(html) {\n\t\t\t\tthis.appendInline(html);\n\t\t\t},\n\t\t\tgetContent: () =>\n\t\t\t\teditor\n\t\t\t\t\t? extractContent(editor)\n\t\t\t\t\t: { html: '', text: '', isEmpty: true, characterCount: 0 },\n\t\t\tgetJSON: () => editor?.getJSON() ?? null,\n\t\t\tgetMentions: () => {\n\t\t\t\tconst agentIds = new Set<string>();\n\t\t\t\tconst teamIds = new Set<string>();\n\t\t\t\tif (!editor) return { agentIds: [], teamIds: [] };\n\t\t\t\teditor.state.doc.descendants((node) => {\n\t\t\t\t\tif (node.type.name === 'mentionAgent' && node.attrs['id'] != null) {\n\t\t\t\t\t\tagentIds.add(String(node.attrs['id']));\n\t\t\t\t\t} else if (\n\t\t\t\t\t\tnode.type.name === 'mentionTeam' &&\n\t\t\t\t\t\tnode.attrs['id'] != null\n\t\t\t\t\t) {\n\t\t\t\t\t\tteamIds.add(String(node.attrs['id']));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn { agentIds: Array.from(agentIds), teamIds: Array.from(teamIds) };\n\t\t\t},\n\n\t\t\t// ── Selection ────────────────────────────────────────────────────\n\t\t\tgetCursorPosition: () => {\n\t\t\t\tif (!editor) return { from: 0, to: 0 };\n\t\t\t\tconst { from, to } = editor.state.selection;\n\t\t\t\treturn { from, to };\n\t\t\t},\n\t\t\tinsertAtPosition: (pos, html) => {\n\t\t\t\tconst normalised = normalize(html);\n\t\t\t\tenqueue((e) => e.commands.insertContentAt(pos, normalised));\n\t\t\t},\n\t\t\tgetSelectedText: () => {\n\t\t\t\tif (!editor) return '';\n\t\t\t\tconst { state } = editor;\n\t\t\t\tconst { from, to, empty } = state.selection;\n\t\t\t\tif (!empty) {\n\t\t\t\t\treturn state.doc.textBetween(from, to, ' ');\n\t\t\t\t}\n\t\t\t\t// When the cursor is inside a link with nothing selected, return the\n\t\t\t\t// full link text — useful for pre-filling a link modal's text field.\n\t\t\t\tconst linkMarkType = state.schema.marks['link'];\n\t\t\t\tif (linkMarkType) {\n\t\t\t\t\tconst range = getMarkRange(state.doc.resolve(from), linkMarkType);\n\t\t\t\t\tif (range) {\n\t\t\t\t\t\treturn state.doc.textBetween(range.from, range.to, ' ');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn '';\n\t\t\t},\n\n\t\t\t// ── Character count ───────────────────────────────────────────────\n\t\t\tgetCharacterCount: () => ({\n\t\t\t\tcount:\n\t\t\t\t\teditor?.storage.characterCount?.characters?.() ??\n\t\t\t\t\teditor?.getText().length ??\n\t\t\t\t\t0,\n\t\t\t\tlimit: maxCharacters ?? null,\n\t\t\t}),\n\n\t\t\t// ── Sections ─────────────────────────────────────────────────────\n\t\t\tgetSectionContent: (sectionId) =>\n\t\t\t\teditor\n\t\t\t\t\t? extractSectionContent(editor, sectionId)\n\t\t\t\t\t: { html: '', text: '', isEmpty: true, characterCount: 0 },\n\n\t\t\tsetSectionContent: (sectionId, html) => {\n\t\t\t\tconst normalised = normalize(html);\n\t\t\t\tenqueue((e) => setSectionContentInEditor(e, sectionId, normalised));\n\t\t\t},\n\n\t\t\tfocusSection: (sectionId) => {\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tif (sectionId === 'body') {\n\t\t\t\t\t\tlet endOfBody = e.state.doc.content.size - 1;\n\t\t\t\t\t\te.state.doc.descendants((node, pos) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\t\t\t\t\t\tendOfBody === e.state.doc.content.size - 1\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tendOfBody = pos - 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn endOfBody === e.state.doc.content.size - 1;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (endOfBody < 1) endOfBody = 1;\n\t\t\t\t\t\te.chain().focus().setTextSelection(endOfBody).run();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlet targetPos = -1;\n\t\t\t\t\te.state.doc.descendants((node, pos) => {\n\t\t\t\t\t\tif (targetPos !== -1) return false;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\t\t\t\t\tnode.attrs['sectionId'] === sectionId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// pos + nodeSize lands right after the divider;\n\t\t\t\t\t\t\t// +1 more puts us inside the first paragraph of that section.\n\t\t\t\t\t\t\ttargetPos = pos + node.nodeSize + 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tif (targetPos !== -1) {\n\t\t\t\t\t\te.chain().focus().setTextSelection(targetPos).run();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\n\t\t\tclearSection: (sectionId) => {\n\t\t\t\tenqueue((e) => setSectionContentInEditor(e, sectionId, '<p></p>'));\n\t\t\t},\n\n\t\t\t// ── Convenience body shorthands ───────────────────────────────────\n\t\t\tgetBodyContent: () =>\n\t\t\t\teditor\n\t\t\t\t\t? extractBodyContent(editor)\n\t\t\t\t\t: { html: '', text: '', isEmpty: true, characterCount: 0 },\n\t\t\tsetBodyContent: (html) => {\n\t\t\t\tconst normalised = normalize(html);\n\t\t\t\tenqueue((e) => setSectionContentInEditor(e, 'body', normalised));\n\t\t\t},\n\t\t\tsetBodyAndSections: (body, sections) => {\n\t\t\t\tconst html = buildSectionedContent(\n\t\t\t\t\tnormalize(body),\n\t\t\t\t\tsections.map((s) => ({\n\t\t\t\t\t\tid: s.id,\n\t\t\t\t\t\tcontent: normalize(s.content),\n\t\t\t\t\t})),\n\t\t\t\t);\n\t\t\t\tenqueue((e) => e.commands.setContent(html, { emitUpdate: true }));\n\t\t\t},\n\t\t\tappendBodyContent: (html) => {\n\t\t\t\tconst normalised = normalize(html);\n\t\t\t\t// findSectionEndPos returns the position of the first divider (or\n\t\t\t\t// doc.content.size), which is the block boundary after the last </p>.\n\t\t\t\t// Subtract 1 to stay inside the last paragraph so successive calls\n\t\t\t\t// append inline text rather than creating a new paragraph each time.\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tconst boundaryPos = findSectionEndPos(e, 'body');\n\t\t\t\t\te.commands.insertContentAt(boundaryPos - 1, normalised, {\n\t\t\t\t\t\tparseOptions: { preserveWhitespace: true },\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tinsertAtSectionStart: (sectionId, html) => {\n\t\t\t\tconst normalised = normalize(html);\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tconst pos = findSectionStartPos(e, sectionId);\n\t\t\t\t\tif (pos !== -1)\n\t\t\t\t\t\te.commands.insertContentAt(pos, normalised, {\n\t\t\t\t\t\t\tparseOptions: { preserveWhitespace: true },\n\t\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tinsertAtSectionEnd: (sectionId, html) => {\n\t\t\t\tconst normalised = normalize(html);\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tconst pos = findSectionEndPos(e, sectionId);\n\t\t\t\t\te.commands.insertContentAt(pos, normalised, {\n\t\t\t\t\t\tparseOptions: { preserveWhitespace: true },\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\t// ── Formats & actions ─────────────────────────────────────────────\n\t\t\tgetActiveFormats: () =>\n\t\t\t\teditor ? extractActiveFormats(editor) : DEFAULT_FORMAT_STATE,\n\t\t\tactions: {\n\t\t\t\ttoggleBold: () => editor?.chain().focus().toggleBold().run(),\n\t\t\t\ttoggleItalic: () => editor?.chain().focus().toggleItalic().run(),\n\t\t\t\ttoggleUnderline: () => editor?.chain().focus().toggleUnderline().run(),\n\t\t\t\ttoggleStrike: () => editor?.chain().focus().toggleStrike().run(),\n\t\t\t\ttoggleBulletList: () =>\n\t\t\t\t\teditor?.chain().focus().toggleBulletList().run(),\n\t\t\t\ttoggleOrderedList: () =>\n\t\t\t\t\teditor?.chain().focus().toggleOrderedList().run(),\n\t\t\t\ttoggleBlockquote: () =>\n\t\t\t\t\teditor?.chain().focus().toggleBlockquote().run(),\n\t\t\t\ttoggleCodeBlock: () => editor?.chain().focus().toggleCodeBlock().run(),\n\t\t\t\tsetTextAlign: (align) =>\n\t\t\t\t\teditor?.chain().focus().setTextAlign(align).run(),\n\t\t\t\tsetFontFamily: (font) =>\n\t\t\t\t\teditor?.chain().focus().setFontFamily(font).run(),\n\t\t\t\tsetFontSize: (size) => editor?.chain().focus().setFontSize(size).run(),\n\t\t\t\tsetColor: (color) => editor?.chain().focus().setColor(color).run(),\n\t\t\t\tsetHighlight: (color) =>\n\t\t\t\t\teditor?.chain().focus().toggleHighlight({ color }).run(),\n\t\t\t\tunsetColor: () => editor?.chain().focus().unsetColor().run(),\n\t\t\t\tunsetHighlight: () => editor?.chain().focus().unsetHighlight().run(),\n\t\t\t\tsetLink: (href, text) => {\n\t\t\t\t\tif (!editor) return;\n\t\t\t\t\tif (text !== undefined) {\n\t\t\t\t\t\teditor\n\t\t\t\t\t\t\t.chain()\n\t\t\t\t\t\t\t.focus()\n\t\t\t\t\t\t\t.extendMarkRange('link')\n\t\t\t\t\t\t\t.command(({ tr, state }) => {\n\t\t\t\t\t\t\t\tconst { from, to } = tr.selection;\n\t\t\t\t\t\t\t\tconst linkMarkType = state.schema.marks['link'];\n\t\t\t\t\t\t\t\tif (!linkMarkType) return false;\n\t\t\t\t\t\t\t\tconst linkNode = state.schema.text(text, [\n\t\t\t\t\t\t\t\t\tlinkMarkType.create({ href }),\n\t\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\t\tconst space = state.schema.text(' ');\n\t\t\t\t\t\t\t\ttr.replaceWith(from, to, [linkNode, space]);\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.run();\n\t\t\t\t\t} else {\n\t\t\t\t\t\teditor\n\t\t\t\t\t\t\t.chain()\n\t\t\t\t\t\t\t.focus()\n\t\t\t\t\t\t\t.extendMarkRange('link')\n\t\t\t\t\t\t\t.setLink({ href })\n\t\t\t\t\t\t\t.insertContent(' ')\n\t\t\t\t\t\t\t.run();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tupdateLink: (href) =>\n\t\t\t\t\teditor\n\t\t\t\t\t\t?.chain()\n\t\t\t\t\t\t.focus()\n\t\t\t\t\t\t.extendMarkRange('link')\n\t\t\t\t\t\t.setLink({ href })\n\t\t\t\t\t\t.run(),\n\t\t\t\tremoveLink: () =>\n\t\t\t\t\teditor?.chain().focus().extendMarkRange('link').unsetLink().run(),\n\t\t\t\tinsertEmoji: (emoji) =>\n\t\t\t\t\teditor?.chain().focus().insertContent(emoji).run(),\n\t\t\t\tinsertVariable: (variableName) =>\n\t\t\t\t\teditor?.chain().focus().insertContent(`{{${variableName}}}`).run(),\n\t\t\t\tinsertHtml: (html) => editor?.commands.insertContent(normalize(html)),\n\t\t\t\tundo: () => editor?.chain().focus().undo().run(),\n\t\t\t\tredo: () => editor?.chain().focus().redo().run(),\n\t\t\t\tcanUndo: () => editor?.can().undo() ?? false,\n\t\t\t\tcanRedo: () => editor?.can().redo() ?? false,\n\t\t\t\ttoggleSuperscript: () =>\n\t\t\t\t\teditor?.chain().focus().toggleSuperscript().run(),\n\t\t\t\ttoggleSubscript: () => editor?.chain().focus().toggleSubscript().run(),\n\t\t\t\tinsertImage: (src) => editor?.chain().focus().setImage({ src }).run(),\n\t\t\t},\n\n\t\t\t// ── JSON body ─────────────────────────────────────────────────────\n\t\t\tjson: features?.jsonMode\n\t\t\t\t? {\n\t\t\t\t\t\tgetText: () => (editor ? getCodeBlockText(editor) : ''),\n\t\t\t\t\t\tsetText: (raw) => enqueue((e) => setCodeBlockText(e, raw)),\n\t\t\t\t\t\tparse: () => parseJson(editor ? getCodeBlockText(editor) : ''),\n\t\t\t\t\t\tisValid: () =>\n\t\t\t\t\t\t\tparseJson(editor ? getCodeBlockText(editor) : '').valid,\n\t\t\t\t\t\tformat: (indent = 2) =>\n\t\t\t\t\t\t\tenqueue((e) => {\n\t\t\t\t\t\t\t\tconst { valid, value } = parseJson(getCodeBlockText(e));\n\t\t\t\t\t\t\t\tif (!valid || value === null) return;\n\t\t\t\t\t\t\t\tsetCodeBlockText(e, JSON.stringify(value, null, indent));\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\tminify: () =>\n\t\t\t\t\t\t\tenqueue((e) => {\n\t\t\t\t\t\t\t\tconst { valid, value } = parseJson(getCodeBlockText(e));\n\t\t\t\t\t\t\t\tif (!valid || value === null) return;\n\t\t\t\t\t\t\t\tsetCodeBlockText(e, JSON.stringify(value));\n\t\t\t\t\t\t\t}),\n\t\t\t\t }\n\t\t\t\t: undefined,\n\t\t}),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[editor],\n\t);\n\n\t// ── jsonMode floating actions ────────────────────────────────────────────\n\t// Beautify pretty-prints in place (no-op / disabled while the JSON is broken);\n\t// Copy writes the raw text to the clipboard with transient feedback.\n\tconst handleJsonBeautify = () => {\n\t\tif (!editor) return;\n\t\tconst { valid, value } = parseJson(getCodeBlockText(editor));\n\t\tif (!valid || value === null) return;\n\t\tsetCodeBlockText(editor, JSON.stringify(value, null, 2));\n\t};\n\tconst handleJsonCopy = () => {\n\t\tif (!editor) return;\n\t\tvoid navigator.clipboard?.writeText(getCodeBlockText(editor));\n\t\tsetJsonCopied(true);\n\t\tsetTimeout(() => setJsonCopied(false), 1500);\n\t};\n\n\tif (!editor) return null;\n\n\treturn (\n\t\t<BikEditorShell\n\t\t\tminHeight={minHeight}\n\t\t\tmaxHeight={maxHeight}\n\t\t\ttightParagraphs={!features?.richPaste}\n\t\t\tjsonMode={isJsonMode}\n\t\t\tstyle={style}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t{isJsonMode && (\n\t\t\t\t<BikJsonHeader>\n\t\t\t\t\t<span className=\"bik-json-header-label\">JSON</span>\n\t\t\t\t\t<div className=\"bik-json-header-actions\">\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tonClick={handleJsonBeautify}\n\t\t\t\t\t\t\tdisabled={!!jsonError}\n\t\t\t\t\t\t\ttitle=\"Format JSON\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<WandSparkles size={16} />\n\t\t\t\t\t\t\t<BodyCaption>Beautify</BodyCaption>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t\t<button type=\"button\" onClick={handleJsonCopy} title=\"Copy JSON\">\n\t\t\t\t\t\t\t<Copy size={16} />\n\t\t\t\t\t\t\t{jsonCopied && <BodyCaption>Copied</BodyCaption>}\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</div>\n\t\t\t\t</BikJsonHeader>\n\t\t\t)}\n\t\t\t<EditorContent editor={editor} />\n\t\t\t<LinkBubbleMenu editor={editor} renderLinkTooltip={link?.renderTooltip} />\n\t\t\t{isJsonMode && jsonError ? (\n\t\t\t\trenderJsonError ? (\n\t\t\t\t\trenderJsonError(jsonError)\n\t\t\t\t) : (\n\t\t\t\t\t<BikJsonError>\n\t\t\t\t\t\t{jsonError.line != null && (\n\t\t\t\t\t\t\t<strong>\n\t\t\t\t\t\t\t\tLine {jsonError.line}\n\t\t\t\t\t\t\t\t{jsonError.column != null ? `, column ${jsonError.column}` : ''}\n\t\t\t\t\t\t\t\t:{' '}\n\t\t\t\t\t\t\t</strong>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{jsonError.error}\n\t\t\t\t\t</BikJsonError>\n\t\t\t\t)\n\t\t\t) : null}\n\t\t</BikEditorShell>\n\t);\n};\n\nexport const BikEditor = forwardRef<BikEditorRef, BikEditorProps>(\n\tBikEditorInner,\n);\nBikEditor.displayName = 'BikEditor';\n"],"names":["cssToString","style","k","v","c","BikEditorInner","props","ref","initialContent","sections","features","disabled","maxCharacters","characterLimit","shortcuts","sendShortcut","mentions","slashCommands","link","onPaste","onReady","onChange","onSend","onFocus","onBlur","onSelectionChange","minHeight","maxHeight","className","editorClassName","editorStyle","renderJsonError","isJsonMode","sanitizer","sanitizeEmailHtml","sanitizeBasicHtml","normalize","useCallback","html","normalizeHtml","jsonError","setJsonError","useState","jsonCopied","setJsonCopied","initialEditorContent","buildJsonCodeBlockHtml","buildSectionedContent","s","pendingQueue","useRef","hasCalledOnReady","onReadyRef","onChangeRef","onSelectionChangeRef","prevFormatsRef","DEFAULT_FORMAT_STATE","onFocusRef","onBlurRef","onSendRef","agentMentionsRef","teamMentionsRef","slashCommandsRef","editor","useEditor","buildExtensions","snapshot","extractContent","result","parseJson","getCodeBlockText","next","extractActiveFormats","prev","enqueue","op","useEffect","useImperativeHandle","position","e","normalised","insertInlineHtml","agentIds","teamIds","node","from","to","pos","state","empty","linkMarkType","range","getMarkRange","sectionId","extractSectionContent","setSectionContentInEditor","endOfBody","targetPos","extractBodyContent","body","boundaryPos","findSectionEndPos","findSectionStartPos","align","font","size","color","href","text","tr","linkNode","space","emoji","variableName","src","raw","setCodeBlockText","indent","valid","value","handleJsonBeautify","handleJsonCopy","jsxs","BikEditorShell","BikJsonHeader","jsx","WandSparkles","BodyCaption","Copy","EditorContent","LinkBubbleMenu","BikJsonError","BikEditor","forwardRef"],"mappings":"ulBAoDA,SAASA,GAAYC,EAAoC,CACxD,OAAO,OAAO,QAAQA,CAAK,EACzB,IACA,CAAC,CAACC,EAAGC,CAAC,IAAM,GAAGD,EAAE,QAAQ,WAAaE,GAAM,IAAIA,EAAE,YAAA,CAAa,EAAE,CAAC,IAAID,CAAC,EAAA,EAEvE,KAAK,GAAG,CACX,CAEA,MAAME,GAAiB,CACtBC,EACAC,IACI,CACJ,KAAM,CACL,eAAAC,EACA,SAAAC,EACA,SAAAC,EACA,SAAAC,EACA,cAAAC,EACA,eAAAC,GACA,UAAAC,GACA,aAAAC,GACA,SAAAC,EACA,cAAAC,EACA,KAAAC,GACA,QAAAC,GACA,QAAAC,EACA,SAAAC,EACA,OAAAC,EACA,QAAAC,EACA,OAAAC,EACA,kBAAAC,EACA,UAAAC,GACA,UAAAC,GACA,MAAA1B,GACA,UAAA2B,GACA,gBAAAC,EACA,YAAAC,EACA,gBAAAC,CAAA,EACGzB,EAEE0B,EAAa,CAAC,CAACtB,GAAU,SAKzBuB,EAJc,CAAC,CAACvB,GAAU,UAIAwB,EAAAA,kBAAoBC,EAAAA,kBAC9CC,EAAYC,EAAAA,YAChBC,GAAiBC,EAAAA,cAAcD,EAAML,CAAS,EAC/C,CAACA,CAAS,CAAA,EAKL,CAACO,EAAWC,CAAY,EAAIC,EAAAA,SAAiC,IAAI,EA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