@bikdotai/bik-component-library 0.0.823 → 0.0.824

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/dist/cjs/components/adbanner/AdBanner.js.map +1 -0
  2. package/dist/cjs/components/{banner → adbanner}/Banner.styled.js +13 -9
  3. package/dist/cjs/components/adbanner/Banner.styled.js.map +1 -0
  4. package/dist/cjs/components/adbanner/BannerInline.js.map +1 -0
  5. package/dist/cjs/components/adbanner/BannerWithImage.js.map +1 -0
  6. package/dist/cjs/components/adbanner/CardBanner.js.map +1 -0
  7. package/dist/cjs/components/adbanner/CardBannerWithImage.js.map +1 -0
  8. package/dist/cjs/components/adbanner/model.js.map +1 -0
  9. package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js +1 -1
  10. package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
  11. package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js +1 -1
  12. package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
  13. package/dist/cjs/components/agent-builder/utils/mentionSerialization.js +2 -2
  14. package/dist/cjs/components/agent-builder/utils/mentionSerialization.js.map +1 -1
  15. package/dist/cjs/editor/BikEditor.js +1 -1
  16. package/dist/cjs/editor/BikEditor.js.map +1 -1
  17. package/dist/cjs/editor/BikEditor.styles.js +143 -5
  18. package/dist/cjs/editor/BikEditor.styles.js.map +1 -1
  19. package/dist/cjs/editor/BikEditor.types.js.map +1 -1
  20. package/dist/cjs/editor/BikEditor.utils.js +3 -2
  21. package/dist/cjs/editor/BikEditor.utils.js.map +1 -1
  22. package/dist/cjs/editor/extensions/buildExtensions.js +3 -1
  23. package/dist/cjs/editor/extensions/buildExtensions.js.map +1 -1
  24. package/dist/cjs/editor/extensions/jsonHighlight/JsonHighlightExtension.js +4 -0
  25. package/dist/cjs/editor/extensions/jsonHighlight/JsonHighlightExtension.js.map +1 -0
  26. package/dist/cjs/editor/extensions/jsonHighlight/tokenizeJson.js +2 -0
  27. package/dist/cjs/editor/extensions/jsonHighlight/tokenizeJson.js.map +1 -0
  28. package/dist/cjs/icons/Actions/Common actions/ProductTour.js +2 -0
  29. package/dist/cjs/icons/Actions/Common actions/ProductTour.js.map +1 -0
  30. package/dist/cjs/icons/Actions/Common actions/RestApi.js +2 -0
  31. package/dist/cjs/icons/Actions/Common actions/RestApi.js.map +1 -0
  32. package/dist/cjs/icons/Actions/Common actions/Save.js +2 -0
  33. package/dist/cjs/icons/Actions/Common actions/Save.js.map +1 -0
  34. package/dist/cjs/icons/Actions/Common actions/Shortcut.js +2 -0
  35. package/dist/cjs/icons/Actions/Common actions/Shortcut.js.map +1 -0
  36. package/dist/cjs/icons/BIK AI specific/WandSparkles.js +2 -0
  37. package/dist/cjs/icons/BIK AI specific/WandSparkles.js.map +1 -0
  38. package/dist/cjs/icons/BIK AI specific/Webhook.js +2 -0
  39. package/dist/cjs/icons/BIK AI specific/Webhook.js.map +1 -0
  40. package/dist/cjs/icons/Informational/Store related/TicketForm.js +2 -0
  41. package/dist/cjs/icons/Informational/Store related/TicketForm.js.map +1 -0
  42. package/dist/cjs/icons/Legacy - Bikayi specific/Services/LoudSpeaker.js +2 -0
  43. package/dist/cjs/icons/Legacy - Bikayi specific/Services/LoudSpeaker.js.map +1 -0
  44. package/dist/cjs/icons/index.js +1 -1
  45. package/dist/cjs/index.js +1 -1
  46. package/dist/esm/components/adbanner/AdBanner.js.map +1 -0
  47. package/dist/esm/components/{banner → adbanner}/Banner.styled.js +18 -14
  48. package/dist/esm/components/adbanner/Banner.styled.js.map +1 -0
  49. package/dist/esm/components/adbanner/BannerInline.js.map +1 -0
  50. package/dist/esm/components/adbanner/BannerWithImage.js.map +1 -0
  51. package/dist/esm/components/adbanner/CardBanner.js.map +1 -0
  52. package/dist/esm/components/adbanner/CardBannerWithImage.js.map +1 -0
  53. package/dist/esm/components/adbanner/model.js.map +1 -0
  54. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js +24 -24
  55. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
  56. package/dist/esm/components/agent-builder/context/AgentBuilderContext.js +98 -101
  57. package/dist/esm/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
  58. package/dist/esm/components/agent-builder/utils/mentionSerialization.d.ts +5 -7
  59. package/dist/esm/components/agent-builder/utils/mentionSerialization.js +40 -37
  60. package/dist/esm/components/agent-builder/utils/mentionSerialization.js.map +1 -1
  61. package/dist/esm/editor/BikEditor.js +247 -181
  62. package/dist/esm/editor/BikEditor.js.map +1 -1
  63. package/dist/esm/editor/BikEditor.styles.d.ts +9 -0
  64. package/dist/esm/editor/BikEditor.styles.js +147 -7
  65. package/dist/esm/editor/BikEditor.styles.js.map +1 -1
  66. package/dist/esm/editor/BikEditor.types.d.ts +76 -0
  67. package/dist/esm/editor/BikEditor.types.js.map +1 -1
  68. package/dist/esm/editor/BikEditor.utils.d.ts +15 -1
  69. package/dist/esm/editor/BikEditor.utils.js +155 -92
  70. package/dist/esm/editor/BikEditor.utils.js.map +1 -1
  71. package/dist/esm/editor/extensions/buildExtensions.d.ts +1 -1
  72. package/dist/esm/editor/extensions/buildExtensions.js +86 -55
  73. package/dist/esm/editor/extensions/buildExtensions.js.map +1 -1
  74. package/dist/esm/editor/extensions/jsonHighlight/JsonHighlightExtension.d.ts +14 -0
  75. package/dist/esm/editor/extensions/jsonHighlight/JsonHighlightExtension.js +132 -0
  76. package/dist/esm/editor/extensions/jsonHighlight/JsonHighlightExtension.js.map +1 -0
  77. package/dist/esm/editor/extensions/jsonHighlight/tokenizeJson.d.ts +18 -0
  78. package/dist/esm/editor/extensions/jsonHighlight/tokenizeJson.js +21 -0
  79. package/dist/esm/editor/extensions/jsonHighlight/tokenizeJson.js.map +1 -0
  80. package/dist/esm/editor/index.d.ts +1 -1
  81. package/dist/esm/icons/Actions/Common actions/ProductTour.d.ts +7 -0
  82. package/dist/esm/icons/Actions/Common actions/ProductTour.js +51 -0
  83. package/dist/esm/icons/Actions/Common actions/ProductTour.js.map +1 -0
  84. package/dist/esm/icons/Actions/Common actions/RestApi.d.ts +7 -0
  85. package/dist/esm/icons/Actions/Common actions/RestApi.js +29 -0
  86. package/dist/esm/icons/Actions/Common actions/RestApi.js.map +1 -0
  87. package/dist/esm/icons/Actions/Common actions/Save.d.ts +7 -0
  88. package/dist/esm/icons/Actions/Common actions/Save.js +40 -0
  89. package/dist/esm/icons/Actions/Common actions/Save.js.map +1 -0
  90. package/dist/esm/icons/Actions/Common actions/Shortcut.d.ts +7 -0
  91. package/dist/esm/icons/Actions/Common actions/Shortcut.js +40 -0
  92. package/dist/esm/icons/Actions/Common actions/Shortcut.js.map +1 -0
  93. package/dist/esm/icons/Actions/Common actions/index.d.ts +4 -0
  94. package/dist/esm/icons/BIK AI specific/WandSparkles.d.ts +7 -0
  95. package/dist/esm/icons/BIK AI specific/WandSparkles.js +39 -0
  96. package/dist/esm/icons/BIK AI specific/WandSparkles.js.map +1 -0
  97. package/dist/esm/icons/BIK AI specific/Webhook.d.ts +7 -0
  98. package/dist/esm/icons/BIK AI specific/Webhook.js +32 -0
  99. package/dist/esm/icons/BIK AI specific/Webhook.js.map +1 -0
  100. package/dist/esm/icons/BIK AI specific/index.d.ts +2 -0
  101. package/dist/esm/icons/Informational/Store related/TicketForm.d.ts +7 -0
  102. package/dist/esm/icons/Informational/Store related/TicketForm.js +65 -0
  103. package/dist/esm/icons/Informational/Store related/TicketForm.js.map +1 -0
  104. package/dist/esm/icons/Informational/Store related/index.d.ts +1 -0
  105. package/dist/esm/icons/Legacy - Bikayi specific/Services/LoudSpeaker.d.ts +7 -0
  106. package/dist/esm/icons/Legacy - Bikayi specific/Services/LoudSpeaker.js +35 -0
  107. package/dist/esm/icons/Legacy - Bikayi specific/Services/LoudSpeaker.js.map +1 -0
  108. package/dist/esm/icons/Legacy - Bikayi specific/Services/index.d.ts +1 -0
  109. package/dist/esm/icons/index.d.ts +4 -4
  110. package/dist/esm/icons/index.js +284 -268
  111. package/dist/esm/icons/index.js.map +1 -1
  112. package/dist/esm/index.d.ts +1 -1
  113. package/dist/esm/index.js +2 -2
  114. package/package.json +1 -1
  115. package/dist/cjs/components/banner/AdBanner.js.map +0 -1
  116. package/dist/cjs/components/banner/Banner.styled.js.map +0 -1
  117. package/dist/cjs/components/banner/BannerInline.js.map +0 -1
  118. package/dist/cjs/components/banner/BannerWithImage.js.map +0 -1
  119. package/dist/cjs/components/banner/CardBanner.js.map +0 -1
  120. package/dist/cjs/components/banner/CardBannerWithImage.js.map +0 -1
  121. package/dist/cjs/components/banner/model.js.map +0 -1
  122. package/dist/esm/components/banner/AdBanner.js.map +0 -1
  123. package/dist/esm/components/banner/Banner.stories.d.ts +0 -39
  124. package/dist/esm/components/banner/Banner.styled.js.map +0 -1
  125. package/dist/esm/components/banner/BannerInline.js.map +0 -1
  126. package/dist/esm/components/banner/BannerWithImage.js.map +0 -1
  127. package/dist/esm/components/banner/CardBanner.js.map +0 -1
  128. package/dist/esm/components/banner/CardBannerWithImage.js.map +0 -1
  129. package/dist/esm/components/banner/model.js.map +0 -1
  130. /package/dist/cjs/components/{banner → adbanner}/AdBanner.js +0 -0
  131. /package/dist/cjs/components/{banner → adbanner}/BannerInline.js +0 -0
  132. /package/dist/cjs/components/{banner → adbanner}/BannerWithImage.js +0 -0
  133. /package/dist/cjs/components/{banner → adbanner}/CardBanner.js +0 -0
  134. /package/dist/cjs/components/{banner → adbanner}/CardBannerWithImage.js +0 -0
  135. /package/dist/cjs/components/{banner → adbanner}/model.js +0 -0
  136. /package/dist/esm/components/{banner → adbanner}/AdBanner.d.ts +0 -0
  137. /package/dist/esm/components/{banner → adbanner}/AdBanner.js +0 -0
  138. /package/dist/esm/components/{banner → adbanner}/Banner.styled.d.ts +0 -0
  139. /package/dist/esm/components/{banner → adbanner}/BannerInline.d.ts +0 -0
  140. /package/dist/esm/components/{banner → adbanner}/BannerInline.js +0 -0
  141. /package/dist/esm/components/{banner → adbanner}/BannerWithImage.d.ts +0 -0
  142. /package/dist/esm/components/{banner → adbanner}/BannerWithImage.js +0 -0
  143. /package/dist/esm/components/{banner → adbanner}/CardBanner.d.ts +0 -0
  144. /package/dist/esm/components/{banner → adbanner}/CardBanner.js +0 -0
  145. /package/dist/esm/components/{banner → adbanner}/CardBannerWithImage.d.ts +0 -0
  146. /package/dist/esm/components/{banner → adbanner}/CardBannerWithImage.js +0 -0
  147. /package/dist/esm/components/{banner → adbanner}/index.d.ts +0 -0
  148. /package/dist/esm/components/{banner → adbanner}/model.d.ts +0 -0
  149. /package/dist/esm/components/{banner → adbanner}/model.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdBanner.js","sources":["../../../../src/components/adbanner/AdBanner.tsx"],"sourcesContent":["import React from 'react';\nimport BannerInline from './BannerInline';\nimport BannerWithImage from './BannerWithImage';\nimport CardBanner from './CardBanner';\nimport CardBannerWithImage from './CardBannerWithImage';\nimport { AdBannerProps, BannerType } from './model';\n\nconst AdBanner: React.FC<AdBannerProps> = (props) => {\n\tswitch (props.bannerType) {\n\t\tcase BannerType.CARD_BANNER:\n\t\t\treturn <CardBanner {...props} />;\n\t\tcase BannerType.CARD_BANNER_WITH_IMAGE:\n\t\t\treturn <CardBannerWithImage {...props} />;\n\t\tcase BannerType.BANNER_INLINE:\n\t\t\treturn <BannerInline {...props} />;\n\t\tcase BannerType.BANNER_WITH_IMAGE:\n\t\t\treturn <BannerWithImage {...props} />;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n};\n\nexport default AdBanner;\n"],"names":["AdBanner","props","BannerType","jsx","CardBanner","CardBannerWithImage","BannerInline","BannerWithImage"],"mappings":"6SAOMA,EAAqCC,GAAU,CACpD,OAAQA,EAAM,WAAA,CACb,KAAKC,EAAAA,WAAW,YACf,OAAOC,MAACC,EAAAA,QAAA,CAAY,GAAGH,CAAA,CAAO,EAC/B,KAAKC,EAAAA,WAAW,uBACf,OAAOC,MAACE,EAAAA,QAAA,CAAqB,GAAGJ,CAAA,CAAO,EACxC,KAAKC,EAAAA,WAAW,cACf,OAAOC,MAACG,EAAAA,QAAA,CAAc,GAAGL,CAAA,CAAO,EACjC,KAAKC,EAAAA,WAAW,kBACf,OAAOC,MAACI,EAAAA,QAAA,CAAiB,GAAGN,CAAA,CAAO,EACpC,QACC,OAAO,IAAA,CAEV"}
@@ -36,7 +36,7 @@
36
36
  width: 100%;
37
37
  height: auto;
38
38
  }
39
- `,u=e.default.div`
39
+ `,x=e.default.div`
40
40
  width: 100%;
41
41
  height: auto;
42
42
  max-height: 303px;
@@ -48,7 +48,7 @@
48
48
  border: 1px solid ${a.COLORS.stroke.primary};
49
49
  background-color: #fff;
50
50
  overflow: hidden;
51
- `,g=e.default.div`
51
+ `,u=e.default.div`
52
52
  width: 100%;
53
53
  height: 72px;
54
54
  display: flex;
@@ -56,8 +56,9 @@
56
56
  justify-content: space-between;
57
57
  padding: 16px;
58
58
  gap: 16px;
59
- `,x=e.default(n)``,c=e.default(r)``,h=e.default.div`
59
+ `,g=e.default(n)``,c=e.default(r)``,h=e.default.div`
60
60
  width: 100%;
61
+ box-sizing: border-box;
61
62
  padding: 16px;
62
63
  border: 1px solid ${a.COLORS.stroke.brandLightAlt};
63
64
  border-radius: 8px;
@@ -70,19 +71,20 @@
70
71
  flex-direction: column;
71
72
  gap: 16px;
72
73
  flex-grow: 1;
74
+ min-width: 0;
73
75
  `,W=e.default.div`
74
76
  display: flex;
75
77
  flex-direction: column;
76
78
  gap: 4px;
77
- `,C=e.default.div`
79
+ `,b=e.default.div`
78
80
  display: flex;
79
81
  gap: 8px;
80
- `,B=e.default.div`
82
+ `,C=e.default.div`
81
83
  width: fit-content;
82
84
  display: flex;
83
85
  align-items: end;
84
86
  gap: 8px;
85
- `,b=e.default.div`
87
+ `,B=e.default.div`
86
88
  width: 100%;
87
89
  height: 170px;
88
90
  display: flex;
@@ -90,14 +92,16 @@
90
92
  justify-content: space-between;
91
93
  border: 1px solid #e0e0e0;
92
94
  border-radius: 8px;
93
- background-color: ${a.COLORS.background.brandLight};
95
+ background-color: ${a.COLORS.background.brandVeryLight};
94
96
  `,y=e.default.div`
95
97
  display: flex;
96
98
  flex-direction: column;
97
99
  gap: 24px;
98
- flex-grow: 1;
100
+ flex: 0 0 50%;
101
+ max-width: 50%;
99
102
  padding: 24px;
100
103
  z-index: 1;
104
+ box-sizing: border-box;
101
105
  `,v=e.default.div`
102
106
  height: 170px;
103
107
  position: relative;
@@ -114,5 +118,5 @@
114
118
  button {
115
119
  border-radius: 32px;
116
120
  }
117
- `;exports.BannerContainer=h;exports.BannerImageWrapper=v;exports.BannerWithImageButtonWrapper=w;exports.BannerWithImageContainer=b;exports.BottomButtonWrapper=B;exports.ButtonWrapper=r;exports.CardBannerButtonWrapper=s;exports.CardBannerContent=o;exports.CardBannerIconsWrapper=l;exports.CardBannerWrapper=i;exports.CardButtonWrapper=c;exports.CardFooterWrapper=g;exports.CardImageWrapper=x;exports.CardWrapper=u;exports.CompanyImageWrapper=f;exports.ContentWrapper=y;exports.ImageWrapper=n;exports.MainContentWrapper=m;exports.TagWrapper=C;exports.TextWrapper=W;
121
+ `;exports.BannerContainer=h;exports.BannerImageWrapper=v;exports.BannerWithImageButtonWrapper=w;exports.BannerWithImageContainer=B;exports.BottomButtonWrapper=C;exports.ButtonWrapper=r;exports.CardBannerButtonWrapper=s;exports.CardBannerContent=o;exports.CardBannerIconsWrapper=l;exports.CardBannerWrapper=i;exports.CardButtonWrapper=c;exports.CardFooterWrapper=u;exports.CardImageWrapper=g;exports.CardWrapper=x;exports.CompanyImageWrapper=f;exports.ContentWrapper=y;exports.ImageWrapper=n;exports.MainContentWrapper=m;exports.TagWrapper=b;exports.TextWrapper=W;
118
122
  //# sourceMappingURL=Banner.styled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Banner.styled.js","sources":["../../../../src/components/adbanner/Banner.styled.tsx"],"sourcesContent":["import styled from 'styled-components';\nimport { COLORS } from '../../constants/Theme';\n\nexport const CardBannerWrapper = styled.div`\n\tborder: 1px solid #e0e0e0;\n\tborder-radius: 8px;\n\tbackground: rgba(239, 230, 249, 0.2);\n\tpadding: 24px;\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n`;\n\nexport const CardBannerContent = styled.div`\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 8px;\n`;\n\nexport const CardBannerIconsWrapper = styled.div`\n\tdisplay: flex;\n\tgap: 8px;\n`;\n\nexport const CardBannerButtonWrapper = styled.div`\n\tdisplay: flex;\n\tgap: 8px;\n\tmargin-top: 16px;\n`;\n\n// ==================== Common Shared Styles ====================\nexport const CompanyImageWrapper = styled.div`\n\twidth: 40px;\n\taspect-ratio: 1;\n\toverflow: hidden;\n\tflex-shrink: 0;\n\timg {\n\t\twidth: 100%;\n\t\theight: auto;\n\t\tborder-radius: 8px;\n\t}\n`;\n\nexport const ButtonWrapper = styled.div`\n\twidth: fit-content;\n`;\n\nexport const ImageWrapper = styled.div`\n\twidth: 100%;\n\theight: auto;\n\timg {\n\t\twidth: 100%;\n\t\theight: auto;\n\t}\n`;\n\n// ==================== CardBanner Styles ====================\nexport const CardWrapper = styled.div`\n\twidth: 100%;\n\theight: auto;\n\tmax-height: 303px;\n\tmax-width: 440px;\n\tborder-radius: 8px;\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: center;\n\tborder: 1px solid ${COLORS.stroke.primary};\n\tbackground-color: #fff;\n\toverflow: hidden;\n`;\n\nexport const CardFooterWrapper = styled.div`\n\twidth: 100%;\n\theight: 72px;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n\tpadding: 16px;\n\tgap: 16px;\n`;\n\nexport const CardImageWrapper = styled(ImageWrapper)``;\n\nexport const CardButtonWrapper = styled(ButtonWrapper)``;\n\n// ==================== BannerInline Styles ====================\nexport const BannerContainer = styled.div`\n\twidth: 100%;\n\tbox-sizing: border-box;\n\tpadding: 16px;\n\tborder: 1px solid ${COLORS.stroke.brandLightAlt};\n\tborder-radius: 8px;\n\tdisplay: flex;\n\talign-items: stretch;\n\tgap: 16px;\n\tbackground: linear-gradient(180deg, #f8f6ff 0%, #ffffff 100%);\n`;\n\nexport const MainContentWrapper = styled.div`\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 16px;\n\tflex-grow: 1;\n\tmin-width: 0;\n`;\n\nexport const TextWrapper = styled.div`\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 4px;\n`;\n\nexport const TagWrapper = styled.div`\n\tdisplay: flex;\n\tgap: 8px;\n`;\n\nexport const BottomButtonWrapper = styled.div`\n\twidth: fit-content;\n\tdisplay: flex;\n\talign-items: end;\n\tgap: 8px;\n`;\n\n// ==================== BannerWithImage Styles ====================\nexport const BannerWithImageContainer = styled.div`\n\twidth: 100%;\n\theight: 170px;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: space-between;\n\tborder: 1px solid #e0e0e0;\n\tborder-radius: 8px;\n\tbackground-color: ${COLORS.background.brandVeryLight};\n`;\n\nexport const ContentWrapper = styled.div`\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 24px;\n\tflex: 0 0 50%;\n\tmax-width: 50%;\n\tpadding: 24px;\n\tz-index: 1;\n\tbox-sizing: border-box;\n`;\n\nexport const BannerImageWrapper = styled.div`\n\theight: 170px;\n\tposition: relative;\n\timg {\n\t\tposition: absolute;\n\t\theight: 170px;\n\t\tbottom: 0;\n\t\tright: 0;\n\t}\n`;\n\nexport const BannerWithImageButtonWrapper = styled(ButtonWrapper)`\n\tdisplay: flex;\n\tjustify-content: start;\n\tgap: 8px;\n\tbutton {\n\t\tborder-radius: 32px;\n\t}\n`;\n"],"names":["CardBannerWrapper","styled","CardBannerContent","CardBannerIconsWrapper","CardBannerButtonWrapper","CompanyImageWrapper","ButtonWrapper","ImageWrapper","CardWrapper","COLORS","CardFooterWrapper","CardImageWrapper","CardButtonWrapper","BannerContainer","MainContentWrapper","TextWrapper","TagWrapper","BottomButtonWrapper","BannerWithImageContainer","Cont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OAAO,WAAW,cAAc;AAAA,EAGxCU,EAAiBlB,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWxBmB,EAAqBnB,EAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAW5BoB,EAA+BpB,EAAAA,QAAOK,CAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BannerInline.js","sources":["../../../../src/components/adbanner/BannerInline.tsx"],"sourcesContent":["import { Button } from '../button';\nimport { Tag } from '../tag';\nimport { BodyCaption, TitleRegular } from '../TypographyStyle';\nimport {\n\tBannerContainer,\n\tBottomButtonWrapper,\n\tCompanyImageWrapper,\n\tMainContentWrapper,\n\tTagWrapper,\n\tTextWrapper,\n} from './Banner.styled';\nimport { AdBannerProps } from './model';\n\n/**\n * BannerInline component - An inline banner with company logo, title, subtitle, tags, and button\n */\nfunction BannerInline(props: AdBannerProps) {\n\treturn (\n\t\t<BannerContainer style={props?.containerStyle}>\n\t\t\t<CompanyImageWrapper>\n\t\t\t\t<img\n\t\t\t\t\tsrc={props.companyImageUrl}\n\t\t\t\t\talt=\"Company Img\"\n\t\t\t\t\tstyle={{ aspectRatio: 'auto' }}\n\t\t\t\t/>\n\t\t\t</CompanyImageWrapper>\n\t\t\t<MainContentWrapper>\n\t\t\t\t<TextWrapper>\n\t\t\t\t\t<TitleRegular>{props.title}</TitleRegular>\n\t\t\t\t\t<BodyCaption>{props.subTitle}</BodyCaption>\n\t\t\t\t</TextWrapper>\n\t\t\t\t{props?.tags && props?.tags?.length > 0 && (\n\t\t\t\t\t<TagWrapper>\n\t\t\t\t\t\t{props?.tags?.map((tag, index) => (\n\t\t\t\t\t\t\t<Tag\n\t\t\t\t\t\t\t\tkey={index}\n\t\t\t\t\t\t\t\ttagText={tag}\n\t\t\t\t\t\t\t\tvariant=\"circle\"\n\t\t\t\t\t\t\t\ttype=\"purple\"\n\t\t\t\t\t\t\t\ttagColor=\"#212121\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</TagWrapper>\n\t\t\t\t)}\n\t\t\t</MainContentWrapper>\n\t\t\t<BottomButtonWrapper>\n\t\t\t\t<Button\n\t\t\t\t\tbuttonText={props.buttonText}\n\t\t\t\t\tbuttonType={props.buttonType || 'secondary'}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tborderRadius: '32px',\n\t\t\t\t\t\twidth: 'fit-content',\n\t\t\t\t\t\twhiteSpace: 'nowrap',\n\t\t\t\t\t}}\n\t\t\t\t\tonClick={props.onClick}\n\t\t\t\t/>\n\t\t\t\t{props?.buttonSecondaryText && props?.onClickSecondary && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tbuttonText={props.buttonSecondaryText}\n\t\t\t\t\t\tbuttonType={props.buttonTypeSecondary || 'primary'}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tborderRadius: '32px',\n\t\t\t\t\t\t\twidth: 'fit-content',\n\t\t\t\t\t\t\twhiteSpace: 'nowrap',\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonClick={props.onClickSecondary}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</BottomButtonWrapper>\n\t\t</BannerContainer>\n\t);\n}\n\nexport default BannerInline;\n"],"names":["BannerInline","props","jsxs","BannerContainer","jsx","CompanyImageWrapper","MainContentWrapper","TextWrapper","TitleRegular","BodyCaption","TagWrapper","tag","index","Tag","BottomButtonWrapper","Button"],"mappings":"gRAgBA,SAASA,EAAaC,EAAsB,CAC3C,OACCC,EAAAA,KAACC,EAAAA,gBAAA,CAAgB,MAAOF,GAAO,eAC9B,SAAA,CAAAG,MAACC,EAAAA,oBAAA,CACA,SAAAD,EAAAA,IAAC,MAAA,CACA,IAAKH,EAAM,gBACX,IAAI,cACJ,MAAO,CAAE,YAAa,MAAA,CAAO,CAAA,EAE/B,SACCK,EAAAA,mBAAA,CACA,SAAA,CAAAJ,OAACK,EAAAA,YAAA,CACA,SAAA,CAAAH,EAAAA,IAACI,EAAAA,aAAA,CAAc,WAAM,KAAA,CAAM,EAC3BJ,EAAAA,IAACK,EAAAA,YAAA,CAAa,SAAAR,EAAM,QAAA,CAAS,CAAA,EAC9B,EACCA,GAAO,MAAQA,GAAO,MAAM,OAAS,GACrCG,MAACM,EAAAA,WAAA,CACC,SAAAT,GAAO,MAAM,IAAI,CAACU,EAAKC,IACvBR,EAAAA,IAACS,EAAAA,IAAA,CAEA,QAASF,EACT,QAAQ,SACR,KAAK,SACL,SAAS,SAAA,EAJJC,CAAA,CAMN,CAAA,CACF,CAAA,EAEF,SACCE,EAAAA,oBAAA,CACA,SAAA,CAAAV,EAAAA,IAACW,EAAAA,OAAA,CACA,WAAYd,EAAM,WAClB,WAAYA,EAAM,YAAc,YAChC,MAAO,CACN,aAAc,OACd,MAAO,cACP,WAAY,QAAA,EAEb,QAASA,EAAM,OAAA,CAAA,EAEfA,GAAO,qBAAuBA,GAAO,kBACrCG,EAAAA,IAACW,EAAAA,OAAA,CACA,WAAYd,EAAM,oBAClB,WAAYA,EAAM,qBAAuB,UACzC,MAAO,CACN,aAAc,OACd,MAAO,cACP,WAAY,QAAA,EAEb,QAASA,EAAM,gBAAA,CAAA,CAChB,CAAA,CAEF,CAAA,EACD,CAEF"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BannerWithImage.js","sources":["../../../../src/components/adbanner/BannerWithImage.tsx"],"sourcesContent":["import { Button } from '../button';\nimport { BodyPrimary, TitleMedium } from '../TypographyStyle';\nimport {\n\tBannerImageWrapper,\n\tBannerWithImageButtonWrapper,\n\tBannerWithImageContainer,\n\tContentWrapper,\n} from './Banner.styled';\nimport { AdBannerProps } from './model';\n\n/**\n * BannerWithImage component - A full-width banner with background image, title, subtitle, and action buttons\n */\nfunction BannerWithImage(props: AdBannerProps) {\n\treturn (\n\t\t<BannerWithImageContainer style={props?.containerStyle}>\n\t\t\t<ContentWrapper>\n\t\t\t\t<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>\n\t\t\t\t\t<TitleMedium color={'#28034e'}>{props?.title} </TitleMedium>\n\t\t\t\t\t<BodyPrimary>{props?.subTitle} </BodyPrimary>\n\t\t\t\t</div>\n\t\t\t\t{props?.buttonText && (\n\t\t\t\t\t<BannerWithImageButtonWrapper>\n\t\t\t\t\t\t{props?.onClickSecondary && props?.buttonSecondaryText && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tonClick={props?.onClickSecondary}\n\t\t\t\t\t\t\t\tbuttonText={props?.buttonSecondaryText}\n\t\t\t\t\t\t\t\tbuttonType={props?.buttonTypeSecondary || 'secondary'}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tonClick={props?.onClick}\n\t\t\t\t\t\t\tbuttonText={props?.buttonText}\n\t\t\t\t\t\t\tbuttonType={props?.buttonType || 'primary'}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BannerWithImageButtonWrapper>\n\t\t\t\t)}\n\t\t\t</ContentWrapper>\n\t\t\t<BannerImageWrapper>\n\t\t\t\t<img src={props?.bannerWithImageUrl} alt=\"Banner image\" />\n\t\t\t</BannerImageWrapper>\n\t\t</BannerWithImageContainer>\n\t);\n}\n\nexport default BannerWithImage;\n"],"names":["BannerWithImage","props","jsxs","BannerWithImageContainer","ContentWrapper","TitleMedium","BodyPrimary","BannerWithImageButtonWrapper","jsx","Button","BannerImageWrapper"],"mappings":"qPAaA,SAASA,EAAgBC,EAAsB,CAC9C,OACCC,EAAAA,KAACC,EAAAA,yBAAA,CAAyB,MAAOF,GAAO,eACvC,SAAA,CAAAC,OAACE,EAAAA,eAAA,CACA,SAAA,CAAAF,EAAAA,KAAC,MAAA,CAAI,MAAO,CAAE,QAAS,OAAQ,cAAe,SAAU,IAAK,CAAA,EAC5D,SAAA,CAAAA,EAAAA,KAACG,EAAAA,YAAA,CAAY,MAAO,UAAY,SAAA,CAAAJ,GAAO,MAAM,GAAA,EAAC,SAC7CK,EAAAA,YAAA,CAAa,SAAA,CAAAL,GAAO,SAAS,GAAA,CAAA,CAAC,CAAA,EAChC,EACCA,GAAO,YACPC,EAAAA,KAACK,EAAAA,6BAAA,CACC,SAAA,CAAAN,GAAO,kBAAoBA,GAAO,qBAClCO,EAAAA,IAACC,EAAAA,OAAA,CACA,QAASR,GAAO,iBAChB,WAAYA,GAAO,oBACnB,WAAYA,GAAO,qBAAuB,WAAA,CAAA,EAG5CO,EAAAA,IAACC,EAAAA,OAAA,CACA,QAASR,GAAO,QAChB,WAAYA,GAAO,WACnB,WAAYA,GAAO,YAAc,SAAA,CAAA,CAClC,CAAA,CACD,CAAA,EAEF,EACAO,EAAAA,IAACE,EAAAA,oBACA,SAAAF,EAAAA,IAAC,MAAA,CAAI,IAAKP,GAAO,mBAAoB,IAAI,cAAA,CAAe,CAAA,CACzD,CAAA,EACD,CAEF"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardBanner.js","sources":["../../../../src/components/adbanner/CardBanner.tsx"],"sourcesContent":["import { useCallback } from 'react';\nimport { Button } from '../button';\nimport { BodyCaption, TitleSmall } from '../TypographyStyle';\nimport {\n\tCardBannerButtonWrapper,\n\tCardBannerContent,\n\tCardBannerIconsWrapper,\n\tCardBannerWrapper,\n} from './Banner.styled';\nimport {\n\tAdBannerProps,\n\tBannerThirdPartyIcon,\n\tgetUrlForBannerThirdPartyIcon,\n} from './model';\n\n/**\n * CardBanner - Banner with TitleSmall, BodyCaption, 3 icons, and button\n */\n\nfunction CardBanner(props: AdBannerProps) {\n\tconst imgUrlForIcons = useCallback((icon: BannerThirdPartyIcon) => {\n\t\treturn getUrlForBannerThirdPartyIcon(icon);\n\t}, []);\n\n\treturn (\n\t\t<CardBannerWrapper style={props?.containerStyle}>\n\t\t\t<CardBannerContent>\n\t\t\t\t<TitleSmall>{props.title}</TitleSmall>\n\t\t\t\t<BodyCaption>{props.subTitle}</BodyCaption>\n\t\t\t\t<CardBannerIconsWrapper>\n\t\t\t\t\t{props.icons?.map((icon, idx) => (\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tkey={idx}\n\t\t\t\t\t\t\tsrc={imgUrlForIcons(icon)}\n\t\t\t\t\t\t\talt={`icon-${idx}`}\n\t\t\t\t\t\t\t// width={32}\n\t\t\t\t\t\t\t// height={32}\n\t\t\t\t\t\t\tstyle={{ width: 32, height: 32, aspectRatio: 1 }}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t\t</CardBannerIconsWrapper>\n\t\t\t</CardBannerContent>\n\t\t\t<CardBannerButtonWrapper>\n\t\t\t\t<Button\n\t\t\t\t\tbuttonText={props.buttonText}\n\t\t\t\t\tbuttonType={props.buttonType || 'secondary'}\n\t\t\t\t\tonClick={props.onClick}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tborderRadius: '32px',\n\t\t\t\t\t\twidth: 'fit-content',\n\t\t\t\t\t\twhiteSpace: 'nowrap',\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t\t{props?.buttonSecondaryText && props?.onClickSecondary && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tbuttonText={props.buttonSecondaryText}\n\t\t\t\t\t\tbuttonType={props.buttonTypeSecondary || 'primary'}\n\t\t\t\t\t\tonClick={props.onClickSecondary}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tborderRadius: '32px',\n\t\t\t\t\t\t\twidth: 'fit-content',\n\t\t\t\t\t\t\twhiteSpace: 'nowrap',\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</CardBannerButtonWrapper>\n\t\t</CardBannerWrapper>\n\t);\n}\n\nexport default CardBanner;\n"],"names":["CardBanner","props","imgUrlForIcons","useCallback","icon","getUrlForBannerThirdPartyIcon","jsxs","CardBannerWrapper","CardBannerContent","jsx","TitleSmall","BodyCaption","CardBannerIconsWrapper","idx","CardBannerButtonWrapper","Button"],"mappings":"gSAmBA,SAASA,EAAWC,EAAsB,CACzC,MAAMC,EAAiBC,cAAaC,GAC5BC,EAAAA,8BAA8BD,CAAI,EACvC,CAAA,CAAE,EAEL,OACCE,EAAAA,KAACC,EAAAA,kBAAA,CAAkB,MAAON,GAAO,eAChC,SAAA,CAAAK,OAACE,EAAAA,kBAAA,CACA,SAAA,CAAAC,EAAAA,IAACC,EAAAA,WAAA,CAAY,WAAM,KAAA,CAAM,EACzBD,EAAAA,IAACE,EAAAA,YAAA,CAAa,SAAAV,EAAM,QAAA,CAAS,QAC5BW,EAAAA,uBAAA,CACC,SAAAX,EAAM,OAAO,IAAI,CAACG,EAAMS,IACxBJ,EAAAA,IAAC,MAAA,CAEA,IAAKP,EAAeE,CAAI,EACxB,IAAK,QAAQS,CAAG,GAGhB,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,YAAa,CAAA,CAAE,EAL1CA,CAAA,CAON,CAAA,CACF,CAAA,EACD,SACCC,EAAAA,wBAAA,CACA,SAAA,CAAAL,EAAAA,IAACM,EAAAA,OAAA,CACA,WAAYd,EAAM,WAClB,WAAYA,EAAM,YAAc,YAChC,QAASA,EAAM,QACf,MAAO,CACN,aAAc,OACd,MAAO,cACP,WAAY,QAAA,CACb,CAAA,EAEAA,GAAO,qBAAuBA,GAAO,kBACrCQ,EAAAA,IAACM,EAAAA,OAAA,CACA,WAAYd,EAAM,oBAClB,WAAYA,EAAM,qBAAuB,UACzC,QAASA,EAAM,iBACf,MAAO,CACN,aAAc,OACd,MAAO,cACP,WAAY,QAAA,CACb,CAAA,CACD,CAAA,CAEF,CAAA,EACD,CAEF"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardBannerWithImage.js","sources":["../../../../src/components/adbanner/CardBannerWithImage.tsx"],"sourcesContent":["import { Button } from '../button';\nimport { TitleSmall } from '../TypographyStyle';\nimport {\n\tCardButtonWrapper,\n\tCardFooterWrapper,\n\tCardImageWrapper,\n\tCardWrapper,\n\tCompanyImageWrapper,\n} from './Banner.styled';\nimport { AdBannerProps } from './model';\n\n/**\n * CardBanner component - A banner with a card-style layout featuring an image, company logo, title, and button\n */\nfunction CardBanner(props: AdBannerProps) {\n\treturn (\n\t\t<CardWrapper style={props?.containerStyle}>\n\t\t\t<CardImageWrapper>\n\t\t\t\t<img\n\t\t\t\t\tsrc={props?.cardImageUrl}\n\t\t\t\t\talt=\"Card Img\"\n\t\t\t\t\tstyle={{ aspectRatio: 'auto' }}\n\t\t\t\t/>\n\t\t\t</CardImageWrapper>\n\t\t\t<CardFooterWrapper>\n\t\t\t\t<CompanyImageWrapper>\n\t\t\t\t\t<img\n\t\t\t\t\t\tsrc={props.companyImageUrl}\n\t\t\t\t\t\talt=\"Company Img\"\n\t\t\t\t\t\tstyle={{ aspectRatio: 'auto' }}\n\t\t\t\t\t/>\n\t\t\t\t</CompanyImageWrapper>\n\t\t\t\t<TitleSmall>{props?.title}</TitleSmall>\n\t\t\t\t<CardButtonWrapper>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tonClick={props?.onClick}\n\t\t\t\t\t\tbuttonType={props?.buttonType || 'secondary'}\n\t\t\t\t\t\tbuttonText={props?.buttonText}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\twidth: 'fit-content',\n\t\t\t\t\t\t\twhiteSpace: 'nowrap',\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t</CardButtonWrapper>\n\t\t\t</CardFooterWrapper>\n\t\t</CardWrapper>\n\t);\n}\n\nexport default CardBanner;\n"],"names":["CardBanner","props","jsxs","CardWrapper","jsx","CardImageWrapper","CardFooterWrapper","CompanyImageWrapper","TitleSmall","CardButtonWrapper","Button"],"mappings":"qPAcA,SAASA,EAAWC,EAAsB,CACzC,OACCC,EAAAA,KAACC,EAAAA,YAAA,CAAY,MAAOF,GAAO,eAC1B,SAAA,CAAAG,MAACC,EAAAA,iBAAA,CACA,SAAAD,EAAAA,IAAC,MAAA,CACA,IAAKH,GAAO,aACZ,IAAI,WACJ,MAAO,CAAE,YAAa,MAAA,CAAO,CAAA,EAE/B,SACCK,EAAAA,kBAAA,CACA,SAAA,CAAAF,MAACG,EAAAA,oBAAA,CACA,SAAAH,EAAAA,IAAC,MAAA,CACA,IAAKH,EAAM,gBACX,IAAI,cACJ,MAAO,CAAE,YAAa,MAAA,CAAO,CAAA,EAE/B,EACAG,EAAAA,IAACI,EAAAA,WAAA,CAAY,SAAAP,GAAO,KAAA,CAAM,QACzBQ,EAAAA,kBAAA,CACA,SAAAL,EAAAA,IAACM,EAAAA,OAAA,CACA,QAAST,GAAO,QAChB,WAAYA,GAAO,YAAc,YACjC,WAAYA,GAAO,WACnB,MAAO,CACN,MAAO,cACP,WAAY,QAAA,CACb,CAAA,CACD,CACD,CAAA,CAAA,CACD,CAAA,EACD,CAEF"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sources":["../../../../src/components/adbanner/model.ts"],"sourcesContent":["import React from 'react';\nimport { Type } from '../button/model';\n\nexport enum BannerType {\n\tCARD_BANNER = 'CARD_BANNER',\n\tCARD_BANNER_WITH_IMAGE = 'CARD_BANNER_WITH_IMAGE',\n\tBANNER_INLINE = 'BANNER_INLINE',\n\tBANNER_WITH_IMAGE = 'BANNER_WITH_IMAGE',\n}\n\nexport enum BannerThirdPartyIcon {\n\tWHATSAPP = 'WHATSAPP',\n\tINSTAGRAM = 'INSTAGRAM',\n\tEMAIL = 'EMAIL',\n}\n\nexport const getUrlForBannerThirdPartyIcon = (\n\ticon: BannerThirdPartyIcon,\n): string => {\n\tswitch (icon) {\n\t\tcase BannerThirdPartyIcon.WHATSAPP:\n\t\t\treturn 'https://firebasestorage.googleapis.com/v0/b/bikayi-chat.appspot.com/o/images-uid%2Fe106cfaf-05f5-455a-90db-e03f73840879?alt=media&token=2ad25cc1-c9c9-4b4c-9273-7654fe4ab802';\n\t\tcase BannerThirdPartyIcon.INSTAGRAM:\n\t\t\treturn 'https://firebasestorage.googleapis.com/v0/b/bikayi-chat.appspot.com/o/images-uid%2Fbdcc71a8-f505-4549-8278-d6e7a95e1e19?alt=media&token=1729b489-3eb6-4dd3-b74d-e7115afdb2af';\n\t\tcase BannerThirdPartyIcon.EMAIL:\n\t\t\treturn 'https://firebasestorage.googleapis.com/v0/b/bikayi-chat.appspot.com/o/images-uid%2F00910e7b-2ce2-4b14-aea1-543a138c1653?alt=media&token=93e3e15e-4a0f-4737-b9a1-c9b0168a7d62';\n\t\tdefault:\n\t\t\treturn '';\n\t}\n};\n\nexport interface AdBannerProps {\n\t/**\n\t * Type of banner to render\n\t */\n\tbannerType: BannerType;\n\n\t/**\n\t * Title text for the banner\n\t */\n\ttitle: string;\n\n\t/**\n\t * Subtitle or description text\n\t */\n\tsubTitle?: React.ReactNode;\n\n\t/**\n\t * Primary button click handler\n\t */\n\tonClick: () => void;\n\n\t/**\n\t * Type/variant of the primary button\n\t * @default 'secondary'\n\t */\n\tbuttonType?: Type;\n\n\t/**\n\t * Text for the primary button\n\t */\n\tbuttonText: string;\n\n\t/**\n\t * Text for the secondary button\n\t */\n\tbuttonSecondaryText?: string;\n\n\t/**\n\t * Secondary button click handler\n\t */\n\tonClickSecondary?: () => void;\n\n\t/**\n\t * Type/variant of the secondary button\n\t */\n\tbuttonTypeSecondary?: Type;\n\n\t/**\n\t * Array of tag labels\n\t */\n\ttags?: string[];\n\n\t/**\n\t * URL for the card image (CardBanner)\n\t */\n\tcardImageUrl?: string;\n\n\t/**\n\t * URL for the company/brand logo image\n\t */\n\tcompanyImageUrl?: string;\n\n\t/**\n\t * URL for the banner background image (BannerWithImage)\n\t */\n\tbannerWithImageUrl?: string;\n\n\t/**\n\t * Custom styles for the banner container\n\t */\n\tcontainerStyle?: React.CSSProperties;\n\n\t/**\n\t * Icons array for CardBanner\n\t */\n\ticons?: BannerThirdPartyIcon[];\n}\n"],"names":["BannerType","BannerThirdPartyIcon","getUrlForBannerThirdPartyIcon","icon"],"mappings":"gFAGO,IAAKA,GAAAA,IACXA,EAAA,YAAc,cACdA,EAAA,uBAAyB,yBACzBA,EAAA,cAAgB,gBAChBA,EAAA,kBAAoB,oBAJTA,IAAAA,GAAA,CAAA,CAAA,EAOAC,GAAAA,IACXA,EAAA,SAAW,WACXA,EAAA,UAAY,YACZA,EAAA,MAAQ,QAHGA,IAAAA,GAAA,CAAA,CAAA,EAML,MAAMC,EACZC,GACY,CACZ,OAAQA,EAAA,CACP,IAAK,WACJ,MAAO,+KACR,IAAK,YACJ,MAAO,+KACR,IAAK,QACJ,MAAO,+KACR,QACC,MAAO,EAAA,CAEV"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),oe=require("../../../assets/icons/cross.svg.js"),n=require("react"),E=require("../../TypographyStyle.js"),L=require("../../../utils/arrayUtils.js"),q=require("../../../constants/Theme.js"),u=require("../AgentBuilder.styled.js"),se=require("../constants/charLimits.js"),G=require("../utils/mentionSerialization.js"),c=require("../utils/sourceIcons.js"),U=require("./MentionEditor.js"),re=require("./SelectableListSection.js"),ae=require("../../input/Input.js"),N=require("../../button/Button.js"),ie=require("../../toaster/Toaster.js"),ue=({onClose:h,onSave:H,availableTools:a,onImprove:ce,title:K="Create sub-agent",initial:l,appLabel:v="Manifest",charLimits:p=se.AGENT_CHAR_LIMITS})=>{const[b,F]=n.useState(l?.name??""),[d,y]=n.useState(l?.instructions??""),[g,f]=n.useState(l?.guardrail??""),[x,m]=n.useState(l?.tools??[]),[A,O]=n.useState(!1),[w,_]=n.useState(0),[z,k]=n.useState(0),[le,de]=n.useState(null),C=n.useMemo(()=>G.buildAgentMentionItems(a,[],v),[a,v]),S=n.useRef({}),I=n.useRef("instructions"),$=n.useCallback(e=>{S.current.instructions=e??void 0},[]),W=n.useCallback(e=>{S.current.guardrail=e??void 0},[]),D=n.useCallback(()=>{I.current="instructions"},[]),J=n.useCallback(()=>{I.current="guardrail"},[]),M=n.useCallback((e,t)=>{e==="tool"&&m(s=>L.addUnique(s,t))},[]),Q=n.useCallback(e=>{(S.current[I.current]??S.current.instructions)?.("tool",e)},[]),[T,j]=n.useState(null),R=n.useRef(null),P=n.useRef(0),V=e=>{const t=a.find(r=>r.tool_id===e),s=t?`{{tool:${t.function_key}}}`:null,i=r=>s?r.split(s).join(""):r;R.current={instructions:d,guardrail:g,tools:x},y(r=>i(r)),f(r=>i(r)),m(r=>r.filter(ne=>ne!==e)),_(r=>r+1),k(r=>r+1),P.current+=1,j({id:P.current,message:`Tool "${t?.display_name??"Tool"}" removed`})},X=()=>{const e=R.current;e&&(y(e.instructions),f(e.guardrail),m(e.tools),_(t=>t+1),k(t=>t+1),R.current=null),j(null)},B=b.trim().length>0&&(d.trim().length>0||g.trim().length>0),Y=x.map(e=>{const t=a.find(s=>s.tool_id===e);return t?{id:e,label:t.display_name,icon:c.SOURCE_ICONS[t.source??"manifest"]}:null}).filter(e=>e!==null),Z=a.map(e=>({label:e.display_name,value:e.tool_id,leadingIcon:c.renderSourceIcon(c.SOURCE_ICONS[e.source??"manifest"])??void 0})),ee=(()=>{const e=[],t=new Map;return a.forEach(s=>{const i=s.source??"manifest";t.has(i)||(t.set(i,[]),e.push(i)),t.get(i)?.push({label:s.display_name,value:s.tool_id,leadingIcon:c.renderSourceIcon(c.SOURCE_ICONS[s.source??"manifest"])??void 0})}),e.map(s=>({source:s,label:G.toolSourceLabel(s),options:t.get(s)??[]}))})(),te=async()=>{if(!B||A)return;const e=H({name:b.trim(),instructions:d,guardrail:g,tools:x});if(e&&typeof e.then=="function"){O(!0);try{await e}finally{O(!1)}}};return o.jsxs(o.Fragment,{children:[o.jsx(u.SubAgentScrim,{onClick:h,"data-test":"subagent-scrim"}),o.jsxs(u.SubAgentPanel,{"data-test":"create-subagent-panel",children:[o.jsxs(u.SubAgentPanelHeader,{children:[o.jsxs(u.SubAgentPanelHeaderText,{children:[o.jsx(E.TitleRegular,{color:q.COLORS.content.primary,children:K}),o.jsx(E.BodySecondary,{color:q.COLORS.content.secondary,children:"Each sub-agent handles one piece of the job. Use @ in the main instructions to call them."})]}),o.jsx(u.SubAgentCloseButton,{onClick:h,"aria-label":"Close",children:o.jsx(oe.default,{width:20,height:20,color:q.COLORS.content.secondary})})]}),o.jsxs(u.SubAgentPanelBody,{children:[o.jsx(ae.Input,{"data-test":"subagent-name",labelText:"Agent name",labelTextBold:!0,placeholder:"Enter agent name",value:b,maxCharLimit:p.name,maxCharLimitPosition:"TOP",maxCharStyle:{fontSize:12,lineHeight:"16px"},onChangeText:F}),o.jsx(U.MentionEditor,{"data-test":"subagent-instructions",label:"Instructions",value:d,onChange:y,maxLength:p.instructions,placeholder:"Write the steps in plain English. Type @ to reference a tool.",minHeight:"160px",resetKey:`instr-${w}`,mentionItems:C,tools:a,onMentionSelect:M,onFocus:D,registerInsert:$}),o.jsx(U.MentionEditor,{"data-test":"subagent-guardrail",label:"Guardrails",value:g,onChange:f,maxLength:p.guardrail,placeholder:"e.g. Never discuss competitor pricing. Type @ to reference a tool.",minHeight:"160px",resetKey:`guard-${z}`,mentionItems:C,tools:a,onMentionSelect:M,onFocus:J,registerInsert:W}),o.jsx(re.SelectableListSection,{title:"Tools this agent can use",dataTestPrefix:"subagent-tools",items:Y,addableOptions:Z,sourceGroups:ee,mentionItems:C,emptyText:"No tools added yet.",onAdd:e=>{Q(e),m(t=>L.addUnique(t,e))},onRemove:V})]}),o.jsxs(u.SubAgentPanelFooter,{children:[o.jsx(N.Button,{"data-test":"subagent-save",buttonType:"primary",size:"small",buttonText:"Save",disabled:!B,isLoading:A,onClick:te}),o.jsx(N.Button,{"data-test":"subagent-cancel",buttonType:"tertiaryGray",size:"small",buttonText:"Cancel",onClick:h})]})]}),T&&o.jsx(ie.Toaster,{text:T.message,type:"info",position:"top-right",autoClose:5e3,hideCloseButton:!0,buttonProps:{buttonText:"Undo",showButton:!0,onButtonClick:()=>(X(),{})},onCloseToast:()=>j(null)},T.id)]})};exports.CreateSubAgentPanel=ue;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),oe=require("../../../assets/icons/cross.svg.js"),t=require("react"),E=require("../../TypographyStyle.js"),L=require("../../../utils/arrayUtils.js"),q=require("../../../constants/Theme.js"),u=require("../AgentBuilder.styled.js"),se=require("../constants/charLimits.js"),G=require("../utils/mentionSerialization.js"),c=require("../utils/sourceIcons.js"),U=require("./MentionEditor.js"),re=require("./SelectableListSection.js"),ae=require("../../input/Input.js"),N=require("../../button/Button.js"),ie=require("../../toaster/Toaster.js"),ue=({onClose:h,onSave:H,availableTools:a,onImprove:ce,title:K="Create sub-agent",initial:l,appLabel:v="Manifest",charLimits:p=se.AGENT_CHAR_LIMITS})=>{const[b,F]=t.useState(l?.name??""),[d,y]=t.useState(l?.instructions??""),[g,f]=t.useState(l?.guardrail??""),[x,m]=t.useState(l?.tools??[]),[A,O]=t.useState(!1),[w,_]=t.useState(0),[z,k]=t.useState(0),[le,de]=t.useState(null),C=t.useMemo(()=>G.buildAgentMentionItems(a,[],v),[a,v]),S=t.useRef({}),I=t.useRef("instructions"),$=t.useCallback(e=>{S.current.instructions=e??void 0},[]),W=t.useCallback(e=>{S.current.guardrail=e??void 0},[]),D=t.useCallback(()=>{I.current="instructions"},[]),J=t.useCallback(()=>{I.current="guardrail"},[]),M=t.useCallback((e,n)=>{e==="tool"&&m(s=>L.addUnique(s,n))},[]),Q=t.useCallback(e=>{(S.current[I.current]??S.current.instructions)?.("tool",e)},[]),[T,j]=t.useState(null),R=t.useRef(null),P=t.useRef(0),V=e=>{const n=a.find(r=>r.tool_id===e),s=`{{tool:${e}}}`,i=r=>r.split(s).join("");R.current={instructions:d,guardrail:g,tools:x},y(r=>i(r)),f(r=>i(r)),m(r=>r.filter(ne=>ne!==e)),_(r=>r+1),k(r=>r+1),P.current+=1,j({id:P.current,message:`Tool "${n?.display_name??"Tool"}" removed`})},X=()=>{const e=R.current;e&&(y(e.instructions),f(e.guardrail),m(e.tools),_(n=>n+1),k(n=>n+1),R.current=null),j(null)},B=b.trim().length>0&&(d.trim().length>0||g.trim().length>0),Y=x.map(e=>{const n=a.find(s=>s.tool_id===e);return n?{id:e,label:n.display_name,icon:c.SOURCE_ICONS[n.source??"manifest"]}:null}).filter(e=>e!==null),Z=a.map(e=>({label:e.display_name,value:e.tool_id,leadingIcon:c.renderSourceIcon(c.SOURCE_ICONS[e.source??"manifest"])??void 0})),ee=(()=>{const e=[],n=new Map;return a.forEach(s=>{const i=s.source??"manifest";n.has(i)||(n.set(i,[]),e.push(i)),n.get(i)?.push({label:s.display_name,value:s.tool_id,leadingIcon:c.renderSourceIcon(c.SOURCE_ICONS[s.source??"manifest"])??void 0})}),e.map(s=>({source:s,label:G.toolSourceLabel(s),options:n.get(s)??[]}))})(),te=async()=>{if(!B||A)return;const e=H({name:b.trim(),instructions:d,guardrail:g,tools:x});if(e&&typeof e.then=="function"){O(!0);try{await e}finally{O(!1)}}};return o.jsxs(o.Fragment,{children:[o.jsx(u.SubAgentScrim,{onClick:h,"data-test":"subagent-scrim"}),o.jsxs(u.SubAgentPanel,{"data-test":"create-subagent-panel",children:[o.jsxs(u.SubAgentPanelHeader,{children:[o.jsxs(u.SubAgentPanelHeaderText,{children:[o.jsx(E.TitleRegular,{color:q.COLORS.content.primary,children:K}),o.jsx(E.BodySecondary,{color:q.COLORS.content.secondary,children:"Each sub-agent handles one piece of the job. Use @ in the main instructions to call them."})]}),o.jsx(u.SubAgentCloseButton,{onClick:h,"aria-label":"Close",children:o.jsx(oe.default,{width:20,height:20,color:q.COLORS.content.secondary})})]}),o.jsxs(u.SubAgentPanelBody,{children:[o.jsx(ae.Input,{"data-test":"subagent-name",labelText:"Agent name",labelTextBold:!0,placeholder:"Enter agent name",value:b,maxCharLimit:p.name,maxCharLimitPosition:"TOP",maxCharStyle:{fontSize:12,lineHeight:"16px"},onChangeText:F}),o.jsx(U.MentionEditor,{"data-test":"subagent-instructions",label:"Instructions",value:d,onChange:y,maxLength:p.instructions,placeholder:"Write the steps in plain English. Type @ to reference a tool.",minHeight:"160px",resetKey:`instr-${w}`,mentionItems:C,tools:a,onMentionSelect:M,onFocus:D,registerInsert:$}),o.jsx(U.MentionEditor,{"data-test":"subagent-guardrail",label:"Guardrails",value:g,onChange:f,maxLength:p.guardrail,placeholder:"e.g. Never discuss competitor pricing. Type @ to reference a tool.",minHeight:"160px",resetKey:`guard-${z}`,mentionItems:C,tools:a,onMentionSelect:M,onFocus:J,registerInsert:W}),o.jsx(re.SelectableListSection,{title:"Tools this agent can use",dataTestPrefix:"subagent-tools",items:Y,addableOptions:Z,sourceGroups:ee,mentionItems:C,emptyText:"No tools added yet.",onAdd:e=>{Q(e),m(n=>L.addUnique(n,e))},onRemove:V})]}),o.jsxs(u.SubAgentPanelFooter,{children:[o.jsx(N.Button,{"data-test":"subagent-save",buttonType:"primary",size:"small",buttonText:"Save",disabled:!B,isLoading:A,onClick:te}),o.jsx(N.Button,{"data-test":"subagent-cancel",buttonType:"tertiaryGray",size:"small",buttonText:"Cancel",onClick:h})]})]}),T&&o.jsx(ie.Toaster,{text:T.message,type:"info",position:"top-right",autoClose:5e3,hideCloseButton:!0,buttonProps:{buttonText:"Undo",showButton:!0,onButtonClick:()=>(X(),{})},onCloseToast:()=>j(null)},T.id)]})};exports.CreateSubAgentPanel=ue;
2
2
  //# sourceMappingURL=CreateSubAgentPanel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CreateSubAgentPanel.js","sources":["../../../../../src/components/agent-builder/components/CreateSubAgentPanel.tsx"],"sourcesContent":["import CrossIcon from '@src/assets/icons/cross.svg';\nimport React, { useCallback, useMemo, useRef, useState } from 'react';\nimport { Button } from '@src/components/button';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { Input } from '@src/components/input';\nimport { Toaster } from '@src/components/toaster';\nimport { BodySecondary, TitleRegular } from '@src/components/TypographyStyle';\nimport { addUnique } from '@src/utils/arrayUtils';\nimport { COLORS } from '@src/constants/Theme';\nimport { AgentTool, SubAgentDraft } from '../AgentBuilder.model';\nimport {\n\tSubAgentCloseButton,\n\tSubAgentPanel,\n\tSubAgentPanelBody,\n\tSubAgentPanelFooter,\n\tSubAgentPanelHeader,\n\tSubAgentPanelHeaderText,\n\tSubAgentScrim,\n} from '../AgentBuilder.styled';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport type { AgentCharLimits } from '../constants/charLimits';\nimport {\n\tbuildAgentMentionItems,\n\ttoolSourceLabel,\n} from '../utils/mentionSerialization';\nimport { renderSourceIcon, SOURCE_ICONS } from '../utils/sourceIcons';\nimport { MentionEditor } from './MentionEditor';\nimport {\n\tSelectableItem,\n\tSelectableListSection,\n\tSourceGroup,\n} from './SelectableListSection';\n\ntype InsertFn = (kind: 'tool' | 'subagent', id: string, label?: string) => void;\n\ninterface CreateSubAgentPanelProps {\n\tonClose: () => void;\n\t/** Persist the draft. The drawer shows a loader while the returned promise is pending. */\n\tonSave: (draft: SubAgentDraft) => void | Promise<void>;\n\tavailableTools: AgentTool[];\n\t/** Optional \"Improve with AI\" for instructions / guardrails. Omit to hide the buttons. */\n\tonImprove?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n\t/** Header title — \"Create sub-agent\" (default) or \"Edit sub-agent\". */\n\ttitle?: string;\n\t/** Initial values, e.g. when configuring an existing sub-agent. */\n\tinitial?: SubAgentDraft;\n\t/** Tool-source fallback label for chips (host app). */\n\tappLabel?: string;\n\t/** Resolved character limits (defaults to {@link AGENT_CHAR_LIMITS}). */\n\tcharLimits?: AgentCharLimits;\n}\n\n/**\n * Right-side drawer for creating / editing a sub-agent (name, instructions,\n * guardrails, tools). Instructions & Guardrails are `@`-mention editors (tools\n * only — sub-agents can't nest); adding a tool from the list inserts it at the\n * last-focused field's cursor. Mount it fresh per open (key it) so `initial`\n * seeds the draft.\n */\nexport const CreateSubAgentPanel: React.FC<CreateSubAgentPanelProps> = ({\n\tonClose,\n\tonSave,\n\tavailableTools,\n\tonImprove,\n\ttitle = 'Create sub-agent',\n\tinitial,\n\tappLabel = 'Manifest',\n\tcharLimits = AGENT_CHAR_LIMITS,\n}) => {\n\tconst [name, setName] = useState(initial?.name ?? '');\n\tconst [instructions, setInstructions] = useState(initial?.instructions ?? '');\n\tconst [guardrail, setGuardrail] = useState(initial?.guardrail ?? '');\n\tconst [tools, setTools] = useState<string[]>(initial?.tools ?? []);\n\tconst [saving, setSaving] = useState(false);\n\t// Bumped to remount a field after its text is replaced (e.g. by Improve).\n\tconst [instrKey, setInstrKey] = useState(0);\n\tconst [guardKey, setGuardKey] = useState(0);\n\tconst [improving, setImproving] = useState<\n\t\t'instructions' | 'guardrail' | null\n\t>(null);\n\n\t// Tools-only mention list (sub-agents can't reference other sub-agents).\n\tconst mentionItems = useMemo(\n\t\t() => buildAgentMentionItems(availableTools, [], appLabel),\n\t\t[availableTools, appLabel],\n\t);\n\n\t// Per-field insert + focus registry, so the Tools list inserts a chip into the\n\t// last-focused editor at its cursor.\n\tconst insertersRef = useRef<\n\t\tPartial<Record<'instructions' | 'guardrail', InsertFn>>\n\t>({});\n\tconst lastFocusedRef = useRef<'instructions' | 'guardrail'>('instructions');\n\tconst registerInstr = useCallback((fn: InsertFn | null) => {\n\t\tinsertersRef.current.instructions = fn ?? undefined;\n\t}, []);\n\tconst registerGuard = useCallback((fn: InsertFn | null) => {\n\t\tinsertersRef.current.guardrail = fn ?? undefined;\n\t}, []);\n\tconst focusInstr = useCallback(() => {\n\t\tlastFocusedRef.current = 'instructions';\n\t}, []);\n\tconst focusGuard = useCallback(() => {\n\t\tlastFocusedRef.current = 'guardrail';\n\t}, []);\n\tconst addToolMention = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\tif (kind === 'tool') {\n\t\t\t\tsetTools((prev) => addUnique(prev, id));\n\t\t\t}\n\t\t},\n\t\t[],\n\t);\n\tconst insertToolAtCursor = useCallback((id: string) => {\n\t\tconst target =\n\t\t\tinsertersRef.current[lastFocusedRef.current] ??\n\t\t\tinsertersRef.current.instructions;\n\t\ttarget?.('tool', id);\n\t}, []);\n\n\t// Local undo toast for tool removal (drawer state isn't in AgentValue).\n\tconst [undo, setUndo] = useState<{ id: number; message: string } | null>(\n\t\tnull,\n\t);\n\tconst undoSnapshotRef = useRef<{\n\t\tinstructions: string;\n\t\tguardrail: string;\n\t\ttools: string[];\n\t} | null>(null);\n\tconst undoIdRef = useRef(0);\n\n\tconst removeTool = (id: string) => {\n\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\tconst token = tool ? `{{tool:${tool.function_key}}}` : null;\n\t\tconst strip = (text: string) => (token ? text.split(token).join('') : text);\n\t\tundoSnapshotRef.current = { instructions, guardrail, tools };\n\t\tsetInstructions((prev) => strip(prev));\n\t\tsetGuardrail((prev) => strip(prev));\n\t\tsetTools((prev) => prev.filter((t) => t !== id));\n\t\tsetInstrKey((k) => k + 1);\n\t\tsetGuardKey((k) => k + 1);\n\t\tundoIdRef.current += 1;\n\t\tsetUndo({\n\t\t\tid: undoIdRef.current,\n\t\t\tmessage: `Tool \"${tool?.display_name ?? 'Tool'}\" removed`,\n\t\t});\n\t};\n\n\tconst undoRemove = () => {\n\t\tconst snap = undoSnapshotRef.current;\n\t\tif (snap) {\n\t\t\tsetInstructions(snap.instructions);\n\t\t\tsetGuardrail(snap.guardrail);\n\t\t\tsetTools(snap.tools);\n\t\t\tsetInstrKey((k) => k + 1);\n\t\t\tsetGuardKey((k) => k + 1);\n\t\t\tundoSnapshotRef.current = null;\n\t\t}\n\t\tsetUndo(null);\n\t};\n\n\tconst canSave =\n\t\tname.trim().length > 0 &&\n\t\t(instructions.trim().length > 0 || guardrail.trim().length > 0);\n\n\tconst toolItems: SelectableItem[] = tools\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\t\treturn tool\n\t\t\t\t? {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tlabel: tool.display_name,\n\t\t\t\t\t\ticon: SOURCE_ICONS[tool.source ?? 'manifest'],\n\t\t\t\t }\n\t\t\t\t: null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\t// Offer all tools (re-add allowed); the chip list stays deduped. Icon left of\n\t// the name, no description.\n\tconst toolOptions: SingleOption[] = availableTools.map((t) => ({\n\t\tlabel: t.display_name,\n\t\tvalue: t.tool_id,\n\t\tleadingIcon:\n\t\t\trenderSourceIcon(SOURCE_ICONS[t.source ?? 'manifest']) ?? undefined,\n\t}));\n\n\t// Group tools by source (Manifest / Shopify / …) so the empty state shows the\n\t// same per-source buttons as the main builder's side panel.\n\tconst toolSourceGroups: SourceGroup[] = (() => {\n\t\tconst order: string[] = [];\n\t\tconst bySource = new Map<string, SingleOption[]>();\n\t\tavailableTools.forEach((t) => {\n\t\t\tconst src = t.source ?? 'manifest';\n\t\t\tif (!bySource.has(src)) {\n\t\t\t\tbySource.set(src, []);\n\t\t\t\torder.push(src);\n\t\t\t}\n\t\t\tbySource.get(src)?.push({\n\t\t\t\tlabel: t.display_name,\n\t\t\t\tvalue: t.tool_id,\n\t\t\t\tleadingIcon:\n\t\t\t\t\trenderSourceIcon(SOURCE_ICONS[t.source ?? 'manifest']) ?? undefined,\n\t\t\t});\n\t\t});\n\t\treturn order.map((src) => ({\n\t\t\tsource: src,\n\t\t\tlabel: toolSourceLabel(src),\n\t\t\toptions: bySource.get(src) ?? [],\n\t\t}));\n\t})();\n\n\tconst handleSave = async () => {\n\t\tif (!canSave || saving) {\n\t\t\treturn;\n\t\t}\n\t\tconst result = onSave({\n\t\t\tname: name.trim(),\n\t\t\tinstructions,\n\t\t\tguardrail,\n\t\t\ttools,\n\t\t});\n\t\tif (result && typeof (result as Promise<void>).then === 'function') {\n\t\t\tsetSaving(true);\n\t\t\ttry {\n\t\t\t\tawait result;\n\t\t\t} finally {\n\t\t\t\tsetSaving(false);\n\t\t\t}\n\t\t}\n\t};\n\n\tconst handleImprove = async (kind: 'instructions' | 'guardrail') => {\n\t\tif (!onImprove || improving) {\n\t\t\treturn;\n\t\t}\n\t\tsetImproving(kind);\n\t\ttry {\n\t\t\tconst current = kind === 'instructions' ? instructions : guardrail;\n\t\t\tconst improved = await onImprove(kind, current);\n\t\t\tif (kind === 'instructions') {\n\t\t\t\tsetInstructions(improved);\n\t\t\t\tsetInstrKey((k) => k + 1);\n\t\t\t} else {\n\t\t\t\tsetGuardrail(improved);\n\t\t\t\tsetGuardKey((k) => k + 1);\n\t\t\t}\n\t\t} finally {\n\t\t\tsetImproving(null);\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<SubAgentScrim onClick={onClose} data-test=\"subagent-scrim\" />\n\t\t\t<SubAgentPanel data-test=\"create-subagent-panel\">\n\t\t\t\t<SubAgentPanelHeader>\n\t\t\t\t\t<SubAgentPanelHeaderText>\n\t\t\t\t\t\t<TitleRegular color={COLORS.content.primary}>{title}</TitleRegular>\n\t\t\t\t\t\t<BodySecondary color={COLORS.content.secondary}>\n\t\t\t\t\t\t\tEach sub-agent handles one piece of the job. Use @ in the main\n\t\t\t\t\t\t\tinstructions to call them.\n\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t</SubAgentPanelHeaderText>\n\t\t\t\t\t<SubAgentCloseButton onClick={onClose} aria-label=\"Close\">\n\t\t\t\t\t\t<CrossIcon\n\t\t\t\t\t\t\twidth={20}\n\t\t\t\t\t\t\theight={20}\n\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</SubAgentCloseButton>\n\t\t\t\t</SubAgentPanelHeader>\n\n\t\t\t\t<SubAgentPanelBody>\n\t\t\t\t\t<Input\n\t\t\t\t\t\tdata-test=\"subagent-name\"\n\t\t\t\t\t\tlabelText=\"Agent name\"\n\t\t\t\t\t\tlabelTextBold\n\t\t\t\t\t\tplaceholder=\"Enter agent name\"\n\t\t\t\t\t\tvalue={name}\n\t\t\t\t\t\tmaxCharLimit={charLimits.name}\n\t\t\t\t\t\tmaxCharLimitPosition=\"TOP\"\n\t\t\t\t\t\tmaxCharStyle={{ fontSize: 12, lineHeight: '16px' }}\n\t\t\t\t\t\tonChangeText={setName}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<MentionEditor\n\t\t\t\t\t\tdata-test=\"subagent-instructions\"\n\t\t\t\t\t\tlabel=\"Instructions\"\n\t\t\t\t\t\tvalue={instructions}\n\t\t\t\t\t\tonChange={setInstructions}\n\t\t\t\t\t\tmaxLength={charLimits.instructions}\n\t\t\t\t\t\tplaceholder=\"Write the steps in plain English. Type @ to reference a tool.\"\n\t\t\t\t\t\tminHeight=\"160px\"\n\t\t\t\t\t\tresetKey={`instr-${instrKey}`}\n\t\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\t\ttools={availableTools}\n\t\t\t\t\t\tonMentionSelect={addToolMention}\n\t\t\t\t\t\tonFocus={focusInstr}\n\t\t\t\t\t\tregisterInsert={registerInstr}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<MentionEditor\n\t\t\t\t\t\tdata-test=\"subagent-guardrail\"\n\t\t\t\t\t\tlabel=\"Guardrails\"\n\t\t\t\t\t\tvalue={guardrail}\n\t\t\t\t\t\tonChange={setGuardrail}\n\t\t\t\t\t\tmaxLength={charLimits.guardrail}\n\t\t\t\t\t\tplaceholder=\"e.g. Never discuss competitor pricing. Type @ to reference a tool.\"\n\t\t\t\t\t\tminHeight=\"160px\"\n\t\t\t\t\t\tresetKey={`guard-${guardKey}`}\n\t\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\t\ttools={availableTools}\n\t\t\t\t\t\tonMentionSelect={addToolMention}\n\t\t\t\t\t\tonFocus={focusGuard}\n\t\t\t\t\t\tregisterInsert={registerGuard}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<SelectableListSection\n\t\t\t\t\t\ttitle=\"Tools this agent can use\"\n\t\t\t\t\t\tdataTestPrefix=\"subagent-tools\"\n\t\t\t\t\t\titems={toolItems}\n\t\t\t\t\t\taddableOptions={toolOptions}\n\t\t\t\t\t\tsourceGroups={toolSourceGroups}\n\t\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\t\temptyText=\"No tools added yet.\"\n\t\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\t\tinsertToolAtCursor(id);\n\t\t\t\t\t\t\tsetTools((prev) => addUnique(prev, id));\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonRemove={removeTool}\n\t\t\t\t\t/>\n\t\t\t\t</SubAgentPanelBody>\n\n\t\t\t\t<SubAgentPanelFooter>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tdata-test=\"subagent-save\"\n\t\t\t\t\t\tbuttonType=\"primary\"\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\tbuttonText=\"Save\"\n\t\t\t\t\t\tdisabled={!canSave}\n\t\t\t\t\t\tisLoading={saving}\n\t\t\t\t\t\tonClick={handleSave}\n\t\t\t\t\t/>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tdata-test=\"subagent-cancel\"\n\t\t\t\t\t\tbuttonType=\"tertiaryGray\"\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\tbuttonText=\"Cancel\"\n\t\t\t\t\t\tonClick={onClose}\n\t\t\t\t\t/>\n\t\t\t\t</SubAgentPanelFooter>\n\t\t\t</SubAgentPanel>\n\n\t\t\t{undo && (\n\t\t\t\t<Toaster\n\t\t\t\t\tkey={undo.id}\n\t\t\t\t\ttext={undo.message}\n\t\t\t\t\ttype=\"info\"\n\t\t\t\t\tposition=\"top-right\"\n\t\t\t\t\tautoClose={5000}\n\t\t\t\t\thideCloseButton\n\t\t\t\t\tbuttonProps={{\n\t\t\t\t\t\tbuttonText: 'Undo',\n\t\t\t\t\t\tshowButton: true,\n\t\t\t\t\t\tonButtonClick: () => {\n\t\t\t\t\t\t\tundoRemove();\n\t\t\t\t\t\t\treturn {} as Record<string, never>;\n\t\t\t\t\t\t},\n\t\t\t\t\t}}\n\t\t\t\t\tonCloseToast={() => setUndo(null)}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</>\n\t);\n};\n"],"names":["CreateSubAgentPanel","onClose","onSave","availableTools","onImprove","title","initial","appLabel","charLimits","AGENT_CHAR_LIMITS","name","setName","useState","instructions","setInstructions","guardrail","setGuardrail","tools","setTools","saving","setSaving","instrKey","setInstrKey","guardKey","setGuardKey","improving","setImproving","mentionItems","useMemo","buildAgentMentionItems","insertersRef","useRef","lastFocusedRef","registerInstr","useCallback","fn","registerGuard","focusInstr","focusGuard","addToolMention","kind","id","prev","addUnique","insertToolAtCursor","undo","setUndo","undoSnapshotRef","undoIdRef","removeTool","tool","t","token","strip","text","k","undoRemove","snap","canSave","toolItems","SOURCE_ICONS","x","toolOptions","renderSourceIcon","toolSourceGroups","order","bySource","src","toolSourceLabel","handleSave","result","jsxs","Fragment","jsx","SubAgentScrim","SubAgentPanel","SubAgentPanelHeader","SubAgentPanelHeaderText","TitleRegular","COLORS","BodySecondary","SubAgentCloseButton","CrossIcon","SubAgentPanelBody","Input","MentionEditor","SelectableListSection","SubAgentPanelFooter","Button","Toaster"],"mappings":"4oBA8DaA,GAA0D,CAAC,CACvE,QAAAC,EACA,OAAAC,EACA,eAAAC,EACA,UAAAC,GACA,MAAAC,EAAQ,mBACR,QAAAC,EACA,SAAAC,EAAW,WAAA,WACXC,EAAaC,GAAAA,iBACd,IAAM,CACL,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAAAA,SAASN,GAAS,MAAQ,EAAE,EAC9C,CAACO,EAAcC,CAAe,EAAIF,EAAAA,SAASN,GAAS,cAAgB,EAAE,EACtE,CAACS,EAAWC,CAAY,EAAIJ,EAAAA,SAASN,GAAS,WAAa,EAAE,EAC7D,CAACW,EAAOC,CAAQ,EAAIN,EAAAA,SAAmBN,GAAS,OAAS,EAAE,EAC3D,CAACa,EAAQC,CAAS,EAAIR,EAAAA,SAAS,EAAK,EAEpC,CAACS,EAAUC,CAAW,EAAIV,EAAAA,SAAS,CAAC,EACpC,CAACW,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VI,EAAAA,IAACe,EAAAA,OAAA,CACA,YAAU,kBACV,WAAW,eACX,KAAK,QACL,WAAW,SACX,QAASvF,CAAA,CAAA,CACV,CAAA,CACD,CAAA,EACD,EAEC4C,GACA4B,EAAAA,IAACgB,GAAAA,QAAA,CAEA,KAAM5C,EAAK,QACX,KAAK,OACL,SAAS,YACT,UAAW,IACX,gBAAe,GACf,YAAa,CACZ,WAAY,OACZ,WAAY,GACZ,cAAe,KACdW,EAAA,EACO,CAAA,EACR,EAED,aAAc,IAAMV,EAAQ,IAAI,CAAA,EAd3BD,EAAK,EAAA,CAeX,EAEF,CAEF"}
1
+ {"version":3,"file":"CreateSubAgentPanel.js","sources":["../../../../../src/components/agent-builder/components/CreateSubAgentPanel.tsx"],"sourcesContent":["import CrossIcon from '@src/assets/icons/cross.svg';\nimport React, { useCallback, useMemo, useRef, useState } from 'react';\nimport { Button } from '@src/components/button';\nimport { SingleOption } from '@src/components/dropdown/type';\nimport { Input } from '@src/components/input';\nimport { Toaster } from '@src/components/toaster';\nimport { BodySecondary, TitleRegular } from '@src/components/TypographyStyle';\nimport { addUnique } from '@src/utils/arrayUtils';\nimport { COLORS } from '@src/constants/Theme';\nimport { AgentTool, SubAgentDraft } from '../AgentBuilder.model';\nimport {\n\tSubAgentCloseButton,\n\tSubAgentPanel,\n\tSubAgentPanelBody,\n\tSubAgentPanelFooter,\n\tSubAgentPanelHeader,\n\tSubAgentPanelHeaderText,\n\tSubAgentScrim,\n} from '../AgentBuilder.styled';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport type { AgentCharLimits } from '../constants/charLimits';\nimport {\n\tbuildAgentMentionItems,\n\ttoolSourceLabel,\n} from '../utils/mentionSerialization';\nimport { renderSourceIcon, SOURCE_ICONS } from '../utils/sourceIcons';\nimport { MentionEditor } from './MentionEditor';\nimport {\n\tSelectableItem,\n\tSelectableListSection,\n\tSourceGroup,\n} from './SelectableListSection';\n\ntype InsertFn = (kind: 'tool' | 'subagent', id: string, label?: string) => void;\n\ninterface CreateSubAgentPanelProps {\n\tonClose: () => void;\n\t/** Persist the draft. The drawer shows a loader while the returned promise is pending. */\n\tonSave: (draft: SubAgentDraft) => void | Promise<void>;\n\tavailableTools: AgentTool[];\n\t/** Optional \"Improve with AI\" for instructions / guardrails. Omit to hide the buttons. */\n\tonImprove?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n\t/** Header title — \"Create sub-agent\" (default) or \"Edit sub-agent\". */\n\ttitle?: string;\n\t/** Initial values, e.g. when configuring an existing sub-agent. */\n\tinitial?: SubAgentDraft;\n\t/** Tool-source fallback label for chips (host app). */\n\tappLabel?: string;\n\t/** Resolved character limits (defaults to {@link AGENT_CHAR_LIMITS}). */\n\tcharLimits?: AgentCharLimits;\n}\n\n/**\n * Right-side drawer for creating / editing a sub-agent (name, instructions,\n * guardrails, tools). Instructions & Guardrails are `@`-mention editors (tools\n * only — sub-agents can't nest); adding a tool from the list inserts it at the\n * last-focused field's cursor. Mount it fresh per open (key it) so `initial`\n * seeds the draft.\n */\nexport const CreateSubAgentPanel: React.FC<CreateSubAgentPanelProps> = ({\n\tonClose,\n\tonSave,\n\tavailableTools,\n\tonImprove,\n\ttitle = 'Create sub-agent',\n\tinitial,\n\tappLabel = 'Manifest',\n\tcharLimits = AGENT_CHAR_LIMITS,\n}) => {\n\tconst [name, setName] = useState(initial?.name ?? '');\n\tconst [instructions, setInstructions] = useState(initial?.instructions ?? '');\n\tconst [guardrail, setGuardrail] = useState(initial?.guardrail ?? '');\n\tconst [tools, setTools] = useState<string[]>(initial?.tools ?? []);\n\tconst [saving, setSaving] = useState(false);\n\t// Bumped to remount a field after its text is replaced (e.g. by Improve).\n\tconst [instrKey, setInstrKey] = useState(0);\n\tconst [guardKey, setGuardKey] = useState(0);\n\tconst [improving, setImproving] = useState<\n\t\t'instructions' | 'guardrail' | null\n\t>(null);\n\n\t// Tools-only mention list (sub-agents can't reference other sub-agents).\n\tconst mentionItems = useMemo(\n\t\t() => buildAgentMentionItems(availableTools, [], appLabel),\n\t\t[availableTools, appLabel],\n\t);\n\n\t// Per-field insert + focus registry, so the Tools list inserts a chip into the\n\t// last-focused editor at its cursor.\n\tconst insertersRef = useRef<\n\t\tPartial<Record<'instructions' | 'guardrail', InsertFn>>\n\t>({});\n\tconst lastFocusedRef = useRef<'instructions' | 'guardrail'>('instructions');\n\tconst registerInstr = useCallback((fn: InsertFn | null) => {\n\t\tinsertersRef.current.instructions = fn ?? undefined;\n\t}, []);\n\tconst registerGuard = useCallback((fn: InsertFn | null) => {\n\t\tinsertersRef.current.guardrail = fn ?? undefined;\n\t}, []);\n\tconst focusInstr = useCallback(() => {\n\t\tlastFocusedRef.current = 'instructions';\n\t}, []);\n\tconst focusGuard = useCallback(() => {\n\t\tlastFocusedRef.current = 'guardrail';\n\t}, []);\n\tconst addToolMention = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\tif (kind === 'tool') {\n\t\t\t\tsetTools((prev) => addUnique(prev, id));\n\t\t\t}\n\t\t},\n\t\t[],\n\t);\n\tconst insertToolAtCursor = useCallback((id: string) => {\n\t\tconst target =\n\t\t\tinsertersRef.current[lastFocusedRef.current] ??\n\t\t\tinsertersRef.current.instructions;\n\t\ttarget?.('tool', id);\n\t}, []);\n\n\t// Local undo toast for tool removal (drawer state isn't in AgentValue).\n\tconst [undo, setUndo] = useState<{ id: number; message: string } | null>(\n\t\tnull,\n\t);\n\tconst undoSnapshotRef = useRef<{\n\t\tinstructions: string;\n\t\tguardrail: string;\n\t\ttools: string[];\n\t} | null>(null);\n\tconst undoIdRef = useRef(0);\n\n\tconst removeTool = (id: string) => {\n\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\t// The token stores the tool id (a tool's id is its tool_id).\n\t\tconst token = `{{tool:${id}}}`;\n\t\tconst strip = (text: string) => text.split(token).join('');\n\t\tundoSnapshotRef.current = { instructions, guardrail, tools };\n\t\tsetInstructions((prev) => strip(prev));\n\t\tsetGuardrail((prev) => strip(prev));\n\t\tsetTools((prev) => prev.filter((t) => t !== id));\n\t\tsetInstrKey((k) => k + 1);\n\t\tsetGuardKey((k) => k + 1);\n\t\tundoIdRef.current += 1;\n\t\tsetUndo({\n\t\t\tid: undoIdRef.current,\n\t\t\tmessage: `Tool \"${tool?.display_name ?? 'Tool'}\" removed`,\n\t\t});\n\t};\n\n\tconst undoRemove = () => {\n\t\tconst snap = undoSnapshotRef.current;\n\t\tif (snap) {\n\t\t\tsetInstructions(snap.instructions);\n\t\t\tsetGuardrail(snap.guardrail);\n\t\t\tsetTools(snap.tools);\n\t\t\tsetInstrKey((k) => k + 1);\n\t\t\tsetGuardKey((k) => k + 1);\n\t\t\tundoSnapshotRef.current = null;\n\t\t}\n\t\tsetUndo(null);\n\t};\n\n\tconst canSave =\n\t\tname.trim().length > 0 &&\n\t\t(instructions.trim().length > 0 || guardrail.trim().length > 0);\n\n\tconst toolItems: SelectableItem[] = tools\n\t\t.map((id): SelectableItem | null => {\n\t\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\t\treturn tool\n\t\t\t\t? {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tlabel: tool.display_name,\n\t\t\t\t\t\ticon: SOURCE_ICONS[tool.source ?? 'manifest'],\n\t\t\t\t }\n\t\t\t\t: null;\n\t\t})\n\t\t.filter((x): x is SelectableItem => x !== null);\n\n\t// Offer all tools (re-add allowed); the chip list stays deduped. Icon left of\n\t// the name, no description.\n\tconst toolOptions: SingleOption[] = availableTools.map((t) => ({\n\t\tlabel: t.display_name,\n\t\tvalue: t.tool_id,\n\t\tleadingIcon:\n\t\t\trenderSourceIcon(SOURCE_ICONS[t.source ?? 'manifest']) ?? undefined,\n\t}));\n\n\t// Group tools by source (Manifest / Shopify / …) so the empty state shows the\n\t// same per-source buttons as the main builder's side panel.\n\tconst toolSourceGroups: SourceGroup[] = (() => {\n\t\tconst order: string[] = [];\n\t\tconst bySource = new Map<string, SingleOption[]>();\n\t\tavailableTools.forEach((t) => {\n\t\t\tconst src = t.source ?? 'manifest';\n\t\t\tif (!bySource.has(src)) {\n\t\t\t\tbySource.set(src, []);\n\t\t\t\torder.push(src);\n\t\t\t}\n\t\t\tbySource.get(src)?.push({\n\t\t\t\tlabel: t.display_name,\n\t\t\t\tvalue: t.tool_id,\n\t\t\t\tleadingIcon:\n\t\t\t\t\trenderSourceIcon(SOURCE_ICONS[t.source ?? 'manifest']) ?? undefined,\n\t\t\t});\n\t\t});\n\t\treturn order.map((src) => ({\n\t\t\tsource: src,\n\t\t\tlabel: toolSourceLabel(src),\n\t\t\toptions: bySource.get(src) ?? [],\n\t\t}));\n\t})();\n\n\tconst handleSave = async () => {\n\t\tif (!canSave || saving) {\n\t\t\treturn;\n\t\t}\n\t\tconst result = onSave({\n\t\t\tname: name.trim(),\n\t\t\tinstructions,\n\t\t\tguardrail,\n\t\t\ttools,\n\t\t});\n\t\tif (result && typeof (result as Promise<void>).then === 'function') {\n\t\t\tsetSaving(true);\n\t\t\ttry {\n\t\t\t\tawait result;\n\t\t\t} finally {\n\t\t\t\tsetSaving(false);\n\t\t\t}\n\t\t}\n\t};\n\n\tconst handleImprove = async (kind: 'instructions' | 'guardrail') => {\n\t\tif (!onImprove || improving) {\n\t\t\treturn;\n\t\t}\n\t\tsetImproving(kind);\n\t\ttry {\n\t\t\tconst current = kind === 'instructions' ? instructions : guardrail;\n\t\t\tconst improved = await onImprove(kind, current);\n\t\t\tif (kind === 'instructions') {\n\t\t\t\tsetInstructions(improved);\n\t\t\t\tsetInstrKey((k) => k + 1);\n\t\t\t} else {\n\t\t\t\tsetGuardrail(improved);\n\t\t\t\tsetGuardKey((k) => k + 1);\n\t\t\t}\n\t\t} finally {\n\t\t\tsetImproving(null);\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<SubAgentScrim onClick={onClose} data-test=\"subagent-scrim\" />\n\t\t\t<SubAgentPanel data-test=\"create-subagent-panel\">\n\t\t\t\t<SubAgentPanelHeader>\n\t\t\t\t\t<SubAgentPanelHeaderText>\n\t\t\t\t\t\t<TitleRegular color={COLORS.content.primary}>{title}</TitleRegular>\n\t\t\t\t\t\t<BodySecondary color={COLORS.content.secondary}>\n\t\t\t\t\t\t\tEach sub-agent handles one piece of the job. Use @ in the main\n\t\t\t\t\t\t\tinstructions to call them.\n\t\t\t\t\t\t</BodySecondary>\n\t\t\t\t\t</SubAgentPanelHeaderText>\n\t\t\t\t\t<SubAgentCloseButton onClick={onClose} aria-label=\"Close\">\n\t\t\t\t\t\t<CrossIcon\n\t\t\t\t\t\t\twidth={20}\n\t\t\t\t\t\t\theight={20}\n\t\t\t\t\t\t\tcolor={COLORS.content.secondary}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</SubAgentCloseButton>\n\t\t\t\t</SubAgentPanelHeader>\n\n\t\t\t\t<SubAgentPanelBody>\n\t\t\t\t\t<Input\n\t\t\t\t\t\tdata-test=\"subagent-name\"\n\t\t\t\t\t\tlabelText=\"Agent name\"\n\t\t\t\t\t\tlabelTextBold\n\t\t\t\t\t\tplaceholder=\"Enter agent name\"\n\t\t\t\t\t\tvalue={name}\n\t\t\t\t\t\tmaxCharLimit={charLimits.name}\n\t\t\t\t\t\tmaxCharLimitPosition=\"TOP\"\n\t\t\t\t\t\tmaxCharStyle={{ fontSize: 12, lineHeight: '16px' }}\n\t\t\t\t\t\tonChangeText={setName}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<MentionEditor\n\t\t\t\t\t\tdata-test=\"subagent-instructions\"\n\t\t\t\t\t\tlabel=\"Instructions\"\n\t\t\t\t\t\tvalue={instructions}\n\t\t\t\t\t\tonChange={setInstructions}\n\t\t\t\t\t\tmaxLength={charLimits.instructions}\n\t\t\t\t\t\tplaceholder=\"Write the steps in plain English. Type @ to reference a tool.\"\n\t\t\t\t\t\tminHeight=\"160px\"\n\t\t\t\t\t\tresetKey={`instr-${instrKey}`}\n\t\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\t\ttools={availableTools}\n\t\t\t\t\t\tonMentionSelect={addToolMention}\n\t\t\t\t\t\tonFocus={focusInstr}\n\t\t\t\t\t\tregisterInsert={registerInstr}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<MentionEditor\n\t\t\t\t\t\tdata-test=\"subagent-guardrail\"\n\t\t\t\t\t\tlabel=\"Guardrails\"\n\t\t\t\t\t\tvalue={guardrail}\n\t\t\t\t\t\tonChange={setGuardrail}\n\t\t\t\t\t\tmaxLength={charLimits.guardrail}\n\t\t\t\t\t\tplaceholder=\"e.g. Never discuss competitor pricing. Type @ to reference a tool.\"\n\t\t\t\t\t\tminHeight=\"160px\"\n\t\t\t\t\t\tresetKey={`guard-${guardKey}`}\n\t\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\t\ttools={availableTools}\n\t\t\t\t\t\tonMentionSelect={addToolMention}\n\t\t\t\t\t\tonFocus={focusGuard}\n\t\t\t\t\t\tregisterInsert={registerGuard}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<SelectableListSection\n\t\t\t\t\t\ttitle=\"Tools this agent can use\"\n\t\t\t\t\t\tdataTestPrefix=\"subagent-tools\"\n\t\t\t\t\t\titems={toolItems}\n\t\t\t\t\t\taddableOptions={toolOptions}\n\t\t\t\t\t\tsourceGroups={toolSourceGroups}\n\t\t\t\t\t\tmentionItems={mentionItems}\n\t\t\t\t\t\temptyText=\"No tools added yet.\"\n\t\t\t\t\t\tonAdd={(id) => {\n\t\t\t\t\t\t\tinsertToolAtCursor(id);\n\t\t\t\t\t\t\tsetTools((prev) => addUnique(prev, id));\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonRemove={removeTool}\n\t\t\t\t\t/>\n\t\t\t\t</SubAgentPanelBody>\n\n\t\t\t\t<SubAgentPanelFooter>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tdata-test=\"subagent-save\"\n\t\t\t\t\t\tbuttonType=\"primary\"\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\tbuttonText=\"Save\"\n\t\t\t\t\t\tdisabled={!canSave}\n\t\t\t\t\t\tisLoading={saving}\n\t\t\t\t\t\tonClick={handleSave}\n\t\t\t\t\t/>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tdata-test=\"subagent-cancel\"\n\t\t\t\t\t\tbuttonType=\"tertiaryGray\"\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\tbuttonText=\"Cancel\"\n\t\t\t\t\t\tonClick={onClose}\n\t\t\t\t\t/>\n\t\t\t\t</SubAgentPanelFooter>\n\t\t\t</SubAgentPanel>\n\n\t\t\t{undo && (\n\t\t\t\t<Toaster\n\t\t\t\t\tkey={undo.id}\n\t\t\t\t\ttext={undo.message}\n\t\t\t\t\ttype=\"info\"\n\t\t\t\t\tposition=\"top-right\"\n\t\t\t\t\tautoClose={5000}\n\t\t\t\t\thideCloseButton\n\t\t\t\t\tbuttonProps={{\n\t\t\t\t\t\tbuttonText: 'Undo',\n\t\t\t\t\t\tshowButton: true,\n\t\t\t\t\t\tonButtonClick: () => {\n\t\t\t\t\t\t\tundoRemove();\n\t\t\t\t\t\t\treturn {} as Record<string, never>;\n\t\t\t\t\t\t},\n\t\t\t\t\t}}\n\t\t\t\t\tonCloseToast={() => setUndo(null)}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</>\n\t);\n};\n"],"names":["CreateSubAgentPanel","onClose","onSave","availableTools","onImprove","title","initial","appLabel","charLimits","AGENT_CHAR_LIMITS","name","setName","useState","instructions","setInstructions","guardrail","setGuardrail","tools","setTools","saving","setSaving","instrKey","setInstrKey","guardKey","setGuardKey","improving","setImproving","mentionItems","useMemo","buildAgentMentionItems","insertersRef","useRef","lastFocusedRef","registerInstr","useCallback","fn","registerGuard","focusInstr","focusGuard","addToolMention","kind","id","prev","addUnique","insertToolAtCursor","undo","setUndo","undoSnapshotRef","undoIdRef","removeTool","tool","t","token","strip","text","k","undoRemove","snap","canSave","toolItems","SOURCE_ICONS","x","toolOptions","renderSourceIcon","toolSourceGroups","order","bySource","src","toolSourceLabel","handleSave","result","jsxs","Fragment","jsx","SubAgentScrim","SubAgentPanel","SubAgentPanelHeader","SubAgentPanelHeaderText","TitleRegular","COLORS","BodySecondary","SubAgentCloseButton","CrossIcon","SubAgentPanelBody","Input","MentionEditor","SelectableListSection","SubAgentPanelFooter","Button","Toaster"],"mappings":"4oBA8DaA,GAA0D,CAAC,CACvE,QAAAC,EACA,OAAAC,EACA,eAAAC,EACA,UAAAC,GACA,MAAAC,EAAQ,mBACR,QAAAC,EACA,SAAAC,EAAW,WAAA,WACXC,EAAaC,GAAAA,iBACd,IAAM,CACL,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAAAA,SAASN,GAAS,MAAQ,EAAE,EAC9C,CAACO,EAAcC,CAAe,EAAIF,EAAAA,SAASN,GAAS,cAAgB,EAAE,EACtE,CAACS,EAAWC,CAAY,EAAIJ,EAAAA,SAASN,GAAS,WAAa,EAAE,EAC7D,CAACW,EAAOC,CAAQ,EAAIN,EAAAA,SAAmBN,GAAS,OAAS,EAAE,EAC3D,CAACa,EAAQC,CAAS,EAAIR,EAAAA,SAAS,EAAK,EAEpC,CAACS,EAAUC,CAAW,EAAIV,EAAAA,SAAS,CAAC,EACpC,CAACW,EAAUC,CAAW,EAAIZ,EAAAA,SAAS,CAAC,EACpC,CAACa,GAAWC,EAAY,EAAId,EAAAA,SAEhC,IAAI,EAGAe,EAAeC,EAAAA,QACpB,IAAMC,yBAAuB1B,EAAgB,CAAA,EAAII,CAAQ,EACzD,CAACJ,EAAgBI,CAAQ,CAAA,EAKpBuB,EAAeC,EAAAA,OAEnB,EAAE,EACEC,EAAiBD,EAAAA,OAAqC,cAAc,EACpEE,EAAgBC,cAAaC,GAAwB,CAC1DL,EAAa,QAAQ,aAAeK,GAAM,MAC3C,EAAG,CAAA,CAAE,EACCC,EAAgBF,cAAaC,GAAwB,CAC1DL,EAAa,QAAQ,UAAYK,GAAM,MACxC,EAAG,CAAA,CAAE,EACCE,EAAaH,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AAM,EACA,MAAOxB,EACP,gBAAiBoC,EACjB,QAASF,EACT,eAAgBJ,CAAA,CAAA,EAGjBwC,EAAAA,IAACY,EAAAA,cAAA,CACA,YAAU,qBACV,MAAM,aACN,MAAOtE,EACP,SAAUC,EACV,UAAWR,EAAW,UACtB,YAAY,qEACZ,UAAU,QACV,SAAU,SAASe,CAAQ,GAC3B,aAAAI,EACA,MAAOxB,EACP,gBAAiBoC,EACjB,QAASD,EACT,eAAgBF,CAAA,CAAA,EAGjBqC,EAAAA,IAACa,GAAAA,sBAAA,CACA,MAAM,2BACN,eAAe,iBACf,MAAO3B,EACP,eAAgBG,EAChB,aAAcE,GACd,aAAArC,EACA,UAAU,sBACV,MAAQc,GAAO,CACdG,EAAmBH,CAAE,EACrBvB,EAAUwB,GAASC,EAAAA,UAAUD,EAAMD,CAAE,CAAC,CACvC,EACA,SAAUQ,CAAA,CAAA,CACX,EACD,SAECsC,EAAAA,oBAAA,CACA,SAAA,CAAAd,EAAAA,IAACe,EAAAA,OAAA,CACA,YAAU,gBACV,WAAW,UACX,KAAK,QACL,WAAW,OACX,SAAU,CAAC9B,EACX,UAAWvC,EACX,QAASkD,EAAA,CAAA,EAEVI,EAAAA,IAACe,EAAAA,OAAA,CACA,YAAU,kBACV,WAAW,eACX,KAAK,QACL,WAAW,SACX,QAASvF,CAAA,CAAA,CACV,CAAA,CACD,CAAA,EACD,EAEC4C,GACA4B,EAAAA,IAACgB,GAAAA,QAAA,CAEA,KAAM5C,EAAK,QACX,KAAK,OACL,SAAS,YACT,UAAW,IACX,gBAAe,GACf,YAAa,CACZ,WAAY,OACZ,WAAY,GACZ,cAAe,KACdW,EAAA,EACO,CAAA,EACR,EAED,aAAc,IAAMV,EAAQ,IAAI,CAAA,EAd3BD,EAAK,EAAA,CAeX,EAEF,CAEF"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ot=require("react/jsx-runtime"),s=require("react"),ct=require("../constants/charLimits.js"),g=require("../constants/steps.js"),ut=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},it=ut(s),O=it.default.createContext(null),lt=()=>{const t=s.useContext(O);if(!t)throw new Error("useAgentBuilderContext must be used within an AgentBuilderProvider");return t},dt=(t,o)=>{const l=t.trigger.mode==="custom_intent"?(t.trigger.custom_intent??"").trim().length>0:t.trigger.intents.length>0;return{about:t.name.trim().length>0&&t.name.length<=o.name&&t.description.length<=o.description,trigger:l,response:t.instructions.trim().length>0||(t.guardrail??"").trim().length>0,handover:!0}},at=({value:t,onChange:o,activeStep:l,onStepChange:p,availableTools:d,availableSubAgents:f,availableIntents:k,availableModels:C,validation:E,applicationType:M,charLimits:P,disableStepNavigation:h=!0,onCreateSubAgent:B,onFetchSubAgent:T,onUpdateSubAgent:y,onImproveSubAgent:A,children:v})=>{const[tt,et]=s.useState("about"),m=l??tt,u=g.getStepIndex(m),j=s.useRef(t);j.current=t;const[q,F]=s.useState(0),S=s.useRef({}),I=s.useRef("instructions"),K=s.useCallback((e,n)=>{n?S.current[e]=n:delete S.current[e]},[]),L=s.useCallback(e=>{I.current=e},[]),$=s.useRef(null),Y=s.useCallback(e=>{$.current=e},[]),w=s.useCallback(()=>{$.current?.()},[]),V=s.useCallback((e,n,c)=>{const a=S.current;(a[I.current]??a.instructions)?.(e,n,c)},[]),[D,x]=s.useState(null),R=s.useRef(null),G=s.useRef(0),i=s.useCallback(e=>{l===void 0&&et(e),p?.(e)},[l,p]),H=s.useCallback(()=>{const e=g.STEP_KEYS[Math.min(u+1,g.STEP_KEYS.length-1)];i(e)},[u,i]),N=s.useCallback(()=>{const e=g.STEP_KEYS[Math.max(u-1,0)];i(e)},[u,i]),U=s.useCallback(e=>o(e),[o]),z=s.useCallback((e,n)=>o({[e]:n}),[o]),J=s.useCallback((e,n)=>{const c=j.current;e==="tool"?c.tools.includes(n)||o({tools:[...c.tools,n]}):c.subagents.includes(n)||o({subagents:[...c.subagents,n]})},[o]),Q=s.useCallback((e,n)=>{const c=e==="tool"?(()=>{const r=d.find(rt=>rt.tool_id===n);return r?`{{tool:${r.function_key}}}`:null})():`{{subagent:${n}}}`,a=r=>c?r.split(c).join(""):r;R.current={tools:t.tools,subagents:t.subagents,instructions:t.instructions,guardrail:t.guardrail};const Z={instructions:a(t.instructions),guardrail:a(t.guardrail??""),...e==="tool"?{tools:t.tools.filter(r=>r!==n)}:{subagents:t.subagents.filter(r=>r!==n)}};o(Z),F(r=>r+1);const nt=e==="tool"?d.find(r=>r.tool_id===n)?.display_name??"Tool":f.find(r=>r.id===n)?.name??"Sub-agent";G.current+=1,x({id:G.current,message:`${e==="tool"?"Tool":"Sub-agent"} "${nt}" removed`})},[d,f,t,o]),W=s.useCallback(()=>{R.current&&(o(R.current),R.current=null,F(e=>e+1)),x(null)},[o]),X=s.useCallback(()=>x(null),[]),b=s.useMemo(()=>({...ct.AGENT_CHAR_LIMITS,...P}),[P]),_=s.useMemo(()=>({...dt(t,b),...E}),[t,b,E]),st=s.useMemo(()=>({value:t,patch:U,updateField:z,addReference:J,removeReference:Q,mentionResetKey:q,insertMention:V,registerMentionField:K,notifyMentionFocus:L,undoToast:D,undoRemoval:W,dismissUndo:X,activeStep:m,activeIndex:u,goToStep:i,goNext:H,goPrev:N,isFirstStep:u===0,isLastStep:u===g.STEP_KEYS.length-1,validation:_,isActiveStepValid:_[m],availableTools:d,availableSubAgents:f,availableIntents:k,availableModels:C,applicationType:M,charLimits:b,disableStepNavigation:h,onCreateSubAgent:B,registerSubAgentCreator:Y,requestCreateSubAgent:w,onFetchSubAgent:T,onUpdateSubAgent:y,onImproveSubAgent:A}),[t,U,z,J,Q,q,V,K,L,D,W,X,m,u,i,H,N,_,d,f,k,C,M,b,h,B,Y,w,T,y,A]);return ot.jsx(O.Provider,{value:st,children:v})};exports.AgentBuilderProvider=at;exports.useAgentBuilderContext=lt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const rt=require("react/jsx-runtime"),s=require("react"),ot=require("../constants/charLimits.js"),d=require("../constants/steps.js"),ct=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},ut=ct(s),O=ut.default.createContext(null),it=()=>{const t=s.useContext(O);if(!t)throw new Error("useAgentBuilderContext must be used within an AgentBuilderProvider");return t},lt=(t,r)=>{const l=t.trigger.mode==="custom_intent"?(t.trigger.custom_intent??"").trim().length>0:t.trigger.intents.length>0;return{about:t.name.trim().length>0&&t.name.length<=r.name&&t.description.length<=r.description,trigger:l,response:t.instructions.trim().length>0||(t.guardrail??"").trim().length>0,handover:!0}},at=({value:t,onChange:r,activeStep:l,onStepChange:C,availableTools:g,availableSubAgents:f,availableIntents:_,availableModels:k,validation:E,applicationType:M,charLimits:P,disableStepNavigation:T=!0,onCreateSubAgent:h,onFetchSubAgent:B,onUpdateSubAgent:A,onImproveSubAgent:j,children:v})=>{const[tt,et]=s.useState("about"),m=l??tt,c=d.getStepIndex(m),q=s.useRef(t);q.current=t;const[y,F]=s.useState(0),S=s.useRef({}),I=s.useRef("instructions"),K=s.useCallback((e,n)=>{n?S.current[e]=n:delete S.current[e]},[]),L=s.useCallback(e=>{I.current=e},[]),$=s.useRef(null),Y=s.useCallback(e=>{$.current=e},[]),w=s.useCallback(()=>{$.current?.()},[]),V=s.useCallback((e,n,u)=>{const a=S.current;(a[I.current]??a.instructions)?.(e,n,u)},[]),[D,x]=s.useState(null),R=s.useRef(null),G=s.useRef(0),i=s.useCallback(e=>{l===void 0&&et(e),C?.(e)},[l,C]),H=s.useCallback(()=>{const e=d.STEP_KEYS[Math.min(c+1,d.STEP_KEYS.length-1)];i(e)},[c,i]),N=s.useCallback(()=>{const e=d.STEP_KEYS[Math.max(c-1,0)];i(e)},[c,i]),U=s.useCallback(e=>r(e),[r]),z=s.useCallback((e,n)=>r({[e]:n}),[r]),J=s.useCallback((e,n)=>{const u=q.current;e==="tool"?u.tools.includes(n)||r({tools:[...u.tools,n]}):u.subagents.includes(n)||r({subagents:[...u.subagents,n]})},[r]),Q=s.useCallback((e,n)=>{const u=e==="tool"?`{{tool:${n}}}`:`{{subagent:${n}}}`,a=o=>o.split(u).join("");R.current={tools:t.tools,subagents:t.subagents,instructions:t.instructions,guardrail:t.guardrail};const Z={instructions:a(t.instructions),guardrail:a(t.guardrail??""),...e==="tool"?{tools:t.tools.filter(o=>o!==n)}:{subagents:t.subagents.filter(o=>o!==n)}};r(Z),F(o=>o+1);const nt=e==="tool"?g.find(o=>o.tool_id===n)?.display_name??"Tool":f.find(o=>o.id===n)?.name??"Sub-agent";G.current+=1,x({id:G.current,message:`${e==="tool"?"Tool":"Sub-agent"} "${nt}" removed`})},[g,f,t,r]),W=s.useCallback(()=>{R.current&&(r(R.current),R.current=null,F(e=>e+1)),x(null)},[r]),X=s.useCallback(()=>x(null),[]),b=s.useMemo(()=>({...ot.AGENT_CHAR_LIMITS,...P}),[P]),p=s.useMemo(()=>({...lt(t,b),...E}),[t,b,E]),st=s.useMemo(()=>({value:t,patch:U,updateField:z,addReference:J,removeReference:Q,mentionResetKey:y,insertMention:V,registerMentionField:K,notifyMentionFocus:L,undoToast:D,undoRemoval:W,dismissUndo:X,activeStep:m,activeIndex:c,goToStep:i,goNext:H,goPrev:N,isFirstStep:c===0,isLastStep:c===d.STEP_KEYS.length-1,validation:p,isActiveStepValid:p[m],availableTools:g,availableSubAgents:f,availableIntents:_,availableModels:k,applicationType:M,charLimits:b,disableStepNavigation:T,onCreateSubAgent:h,registerSubAgentCreator:Y,requestCreateSubAgent:w,onFetchSubAgent:B,onUpdateSubAgent:A,onImproveSubAgent:j}),[t,U,z,J,Q,y,V,K,L,D,W,X,m,c,i,H,N,p,g,f,_,k,M,b,T,h,Y,w,B,A,j]);return rt.jsx(O.Provider,{value:st,children:v})};exports.AgentBuilderProvider=at;exports.useAgentBuilderContext=it;
2
2
  //# sourceMappingURL=AgentBuilderContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AgentBuilderContext.js","sources":["../../../../../src/components/agent-builder/context/AgentBuilderContext.tsx"],"sourcesContent":["import type { ApplicationType } from '@bikdotai/bik-models/growth';\nimport React, {\n\tuseCallback,\n\tuseContext,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport {\n\tAgentTool,\n\tAgentValue,\n\tIntentOption,\n\tModelOption,\n\tStepKey,\n\tStepValidation,\n\tSubAgentDraft,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport type { AgentCharLimits } from '../constants/charLimits';\nimport { getStepIndex, STEP_KEYS } from '../constants/steps';\n\n/** Mention-capable text fields in Step 3 (both store firebase token text). */\nexport type MentionFieldKey = 'instructions' | 'guardrail';\ntype MentionInsertFn = (\n\tkind: 'tool' | 'subagent',\n\tid: string,\n\tlabel?: string,\n) => void;\n\n/** Toast shown after a tool / sub-agent is removed, offering an undo. */\nexport interface UndoToastState {\n\t/** Bumped per removal so the toast timer restarts. */\n\tid: number;\n\tmessage: string;\n}\n\nexport interface AgentBuilderContextShape {\n\t/** Controlled value relayed from props. */\n\tvalue: AgentValue;\n\t/** Patch one or more fields. */\n\tpatch: (partial: Partial<AgentValue>) => void;\n\t/** Patch a single field. */\n\tupdateField: <K extends keyof AgentValue>(key: K, val: AgentValue[K]) => void;\n\t/**\n\t * Remove a tool / sub-agent everywhere: drops it from the list AND strips ALL\n\t * its `{{tool:KEY}}` / `{{subagent:ID}}` tokens from BOTH the instructions and\n\t * the guardrails, remounts the editors, and raises an undo toast.\n\t */\n\tremoveReference: (kind: 'tool' | 'subagent', id: string) => void;\n\t/**\n\t * Append a tool / sub-agent id to its list (deduped), reading the LATEST value\n\t * via a ref. Use this instead of `patch({ tools: [...value.tools, id] })` from\n\t * any handler that may be captured with a stale `value` — notably the `@`\n\t * editor's mount-time `onSelect`, which would otherwise keep only the last pick.\n\t */\n\taddReference: (kind: 'tool' | 'subagent', id: string) => void;\n\t/** Remount signal for the mention editors after an external edit. */\n\tmentionResetKey: number;\n\t/**\n\t * Insert a tool / sub-agent mention chip at the last cursor position of\n\t * whichever mention field was focused most recently (Instructions or\n\t * Guardrails). `label` overrides the chip text (e.g. a just-created sub-agent\n\t * not yet in the available list).\n\t */\n\tinsertMention: (\n\t\tkind: 'tool' | 'subagent',\n\t\tid: string,\n\t\tlabel?: string,\n\t) => void;\n\t/** A mention field registers its editor-backed insert here (internal). */\n\tregisterMentionField: (\n\t\tfieldKey: MentionFieldKey,\n\t\tfn: MentionInsertFn | null,\n\t) => void;\n\t/** A mention field reports focus so inserts target it (internal). */\n\tnotifyMentionFocus: (fieldKey: MentionFieldKey) => void;\n\n\t// Undo (post-removal)\n\t/** Non-null while the undo toast should be visible. */\n\tundoToast: UndoToastState | null;\n\t/** Restore the last removed tool / sub-agent (list + stripped tokens). */\n\tundoRemoval: () => void;\n\t/** Dismiss the undo toast without restoring. */\n\tdismissUndo: () => void;\n\n\t// Navigation\n\tactiveStep: StepKey;\n\tactiveIndex: number;\n\tgoToStep: (step: StepKey) => void;\n\tgoNext: () => void;\n\tgoPrev: () => void;\n\tisFirstStep: boolean;\n\tisLastStep: boolean;\n\n\t// Validation\n\tvalidation: StepValidation;\n\tisActiveStepValid: boolean;\n\n\t// Reference data\n\tavailableTools: AgentTool[];\n\tavailableSubAgents: SubAgentRef[];\n\tavailableIntents: IntentOption[];\n\tavailableModels: ModelOption[];\n\t/** Host application context (e.g. MANIFEST) — drives tool-chip labelling. */\n\tapplicationType?: ApplicationType;\n\t/** Resolved per-field character limits (consumer overrides merged over defaults). */\n\tcharLimits: AgentCharLimits;\n\t/** When true, step-rail items are not clickable (Back / Next only). */\n\tdisableStepNavigation: boolean;\n\n\t// Sub-agent creation (Step 3 drawer)\n\t/** Persist a new sub-agent and resolve with its ref. Omit to hide the create flow. */\n\tonCreateSubAgent?: (draft: SubAgentDraft) => Promise<SubAgentRef>;\n\t/**\n\t * Step 3 registers its \"open create-sub-agent drawer\" action here so the `@`\n\t * picker's \"Create new\" row can trigger it. Pass `null` to unregister.\n\t */\n\tregisterSubAgentCreator: (fn: (() => void) | null) => void;\n\t/** Open the create-sub-agent drawer (no-op until Step 3 registers it). */\n\trequestCreateSubAgent: () => void;\n\t/** Fetch a sub-agent's editable data (Configure). Omit to hide Configure. */\n\tonFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;\n\t/** Persist edits to an existing sub-agent. */\n\tonUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;\n\t/** Optional \"Improve with AI\" for the drawer's instructions / guardrails. */\n\tonImproveSubAgent?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n}\n\nconst AgentBuilderContext =\n\tReact.createContext<AgentBuilderContextShape | null>(null);\n\nexport const useAgentBuilderContext = (): AgentBuilderContextShape => {\n\tconst ctx = useContext(AgentBuilderContext);\n\tif (!ctx) {\n\t\tthrow new Error(\n\t\t\t'useAgentBuilderContext must be used within an AgentBuilderProvider',\n\t\t);\n\t}\n\treturn ctx;\n};\n\n/** Validity derived purely from the current value (no effects). */\nconst deriveValidation = (\n\tvalue: AgentValue,\n\tlimits: AgentCharLimits,\n): StepValidation => {\n\tconst triggerValid =\n\t\tvalue.trigger.mode === 'custom_intent'\n\t\t\t? (value.trigger.custom_intent ?? '').trim().length > 0\n\t\t\t: value.trigger.intents.length > 0;\n\n\treturn {\n\t\tabout:\n\t\t\tvalue.name.trim().length > 0 &&\n\t\t\tvalue.name.length <= limits.name &&\n\t\t\tvalue.description.length <= limits.description,\n\t\ttrigger: triggerValid,\n\t\t// At least one of Instructions / Guardrails must be filled.\n\t\tresponse:\n\t\t\tvalue.instructions.trim().length > 0 ||\n\t\t\t(value.guardrail ?? '').trim().length > 0,\n\t\t// Optional until specced further — never blocks go-live.\n\t\thandover: true,\n\t};\n};\n\ninterface ProviderProps {\n\tvalue: AgentValue;\n\tonChange: (patch: Partial<AgentValue>) => void;\n\tactiveStep?: StepKey;\n\tonStepChange?: (step: StepKey) => void;\n\tavailableTools: AgentTool[];\n\tavailableSubAgents: SubAgentRef[];\n\tavailableIntents: IntentOption[];\n\tavailableModels: ModelOption[];\n\tvalidation?: Partial<StepValidation>;\n\tapplicationType?: ApplicationType;\n\tcharLimits?: Partial<AgentCharLimits>;\n\tdisableStepNavigation?: boolean;\n\tonCreateSubAgent?: (draft: SubAgentDraft) => Promise<SubAgentRef>;\n\tonFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;\n\tonUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;\n\tonImproveSubAgent?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n\tchildren: React.ReactNode;\n}\n\nexport const AgentBuilderProvider: React.FC<ProviderProps> = ({\n\tvalue,\n\tonChange,\n\tactiveStep: controlledStep,\n\tonStepChange,\n\tavailableTools,\n\tavailableSubAgents,\n\tavailableIntents,\n\tavailableModels,\n\tvalidation: validationOverride,\n\tapplicationType,\n\tcharLimits: charLimitsOverride,\n\tdisableStepNavigation = true,\n\tonCreateSubAgent,\n\tonFetchSubAgent,\n\tonUpdateSubAgent,\n\tonImproveSubAgent,\n\tchildren,\n}) => {\n\tconst [internalStep, setInternalStep] = useState<StepKey>('about');\n\tconst activeStep = controlledStep ?? internalStep;\n\tconst activeIndex = getStepIndex(activeStep);\n\n\t// Latest value, so closure-captured handlers (e.g. the `@` editor's mount-time\n\t// mention onSelect) append against the current lists, not a stale snapshot.\n\tconst valueRef = useRef(value);\n\tvalueRef.current = value;\n\n\t// Bumped when a mention field is edited from OUTSIDE its editor (removing a\n\t// tool from the side list, undo), forcing the mention editors to remount.\n\tconst [mentionResetKey, setMentionResetKey] = useState(0);\n\n\t// Each mention field registers an editor-backed insert fn + reports focus, so\n\t// side-panel adds drop a chip into the last-focused field at its cursor.\n\tconst mentionInsertersRef = useRef<\n\t\tPartial<Record<MentionFieldKey, MentionInsertFn>>\n\t>({});\n\tconst lastFocusedFieldRef = useRef<MentionFieldKey>('instructions');\n\tconst registerMentionField = useCallback(\n\t\t(fieldKey: MentionFieldKey, fn: MentionInsertFn | null) => {\n\t\t\tif (fn) {\n\t\t\t\tmentionInsertersRef.current[fieldKey] = fn;\n\t\t\t} else {\n\t\t\t\tdelete mentionInsertersRef.current[fieldKey];\n\t\t\t}\n\t\t},\n\t\t[],\n\t);\n\tconst notifyMentionFocus = useCallback((fieldKey: MentionFieldKey) => {\n\t\tlastFocusedFieldRef.current = fieldKey;\n\t}, []);\n\n\t// Step 3 registers its drawer opener here; the `@` picker's \"Create new\" calls it.\n\tconst subAgentCreatorRef = useRef<(() => void) | null>(null);\n\tconst registerSubAgentCreator = useCallback((fn: (() => void) | null) => {\n\t\tsubAgentCreatorRef.current = fn;\n\t}, []);\n\tconst requestCreateSubAgent = useCallback(() => {\n\t\tsubAgentCreatorRef.current?.();\n\t}, []);\n\tconst insertMention = useCallback<MentionInsertFn>((kind, id, label) => {\n\t\tconst inserters = mentionInsertersRef.current;\n\t\tconst target =\n\t\t\tinserters[lastFocusedFieldRef.current] ?? inserters.instructions;\n\t\ttarget?.(kind, id, label);\n\t}, []);\n\n\t// Undo state for the most recent removal.\n\tconst [undoToast, setUndoToast] = useState<UndoToastState | null>(null);\n\tconst undoSnapshotRef = useRef<Partial<AgentValue> | null>(null);\n\tconst undoIdRef = useRef(0);\n\n\tconst goToStep = useCallback(\n\t\t(step: StepKey) => {\n\t\t\tif (controlledStep === undefined) {\n\t\t\t\tsetInternalStep(step);\n\t\t\t}\n\t\t\tonStepChange?.(step);\n\t\t},\n\t\t[controlledStep, onStepChange],\n\t);\n\n\tconst goNext = useCallback(() => {\n\t\tconst next = STEP_KEYS[Math.min(activeIndex + 1, STEP_KEYS.length - 1)];\n\t\tgoToStep(next);\n\t}, [activeIndex, goToStep]);\n\n\tconst goPrev = useCallback(() => {\n\t\tconst prev = STEP_KEYS[Math.max(activeIndex - 1, 0)];\n\t\tgoToStep(prev);\n\t}, [activeIndex, goToStep]);\n\n\tconst patch = useCallback(\n\t\t(partial: Partial<AgentValue>) => onChange(partial),\n\t\t[onChange],\n\t);\n\n\tconst updateField = useCallback(\n\t\t<K extends keyof AgentValue>(key: K, val: AgentValue[K]) =>\n\t\t\tonChange({ [key]: val } as Partial<AgentValue>),\n\t\t[onChange],\n\t);\n\n\tconst addReference = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\tconst v = valueRef.current;\n\t\t\tif (kind === 'tool') {\n\t\t\t\tif (!v.tools.includes(id)) {\n\t\t\t\t\tonChange({ tools: [...v.tools, id] });\n\t\t\t\t}\n\t\t\t} else if (!v.subagents.includes(id)) {\n\t\t\t\tonChange({ subagents: [...v.subagents, id] });\n\t\t\t}\n\t\t},\n\t\t[onChange],\n\t);\n\n\tconst removeReference = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\tconst token =\n\t\t\t\tkind === 'tool'\n\t\t\t\t\t? (() => {\n\t\t\t\t\t\t\tconst tool = availableTools.find((t) => t.tool_id === id);\n\t\t\t\t\t\t\treturn tool ? `{{tool:${tool.function_key}}}` : null;\n\t\t\t\t\t })()\n\t\t\t\t\t: `{{subagent:${id}}}`;\n\t\t\tconst strip = (text: string) =>\n\t\t\t\ttoken ? text.split(token).join('') : text;\n\n\t\t\t// Snapshot the four fields a removal touches, for undo.\n\t\t\tundoSnapshotRef.current = {\n\t\t\t\ttools: value.tools,\n\t\t\t\tsubagents: value.subagents,\n\t\t\t\tinstructions: value.instructions,\n\t\t\t\tguardrail: value.guardrail,\n\t\t\t};\n\n\t\t\tconst next: Partial<AgentValue> = {\n\t\t\t\tinstructions: strip(value.instructions),\n\t\t\t\tguardrail: strip(value.guardrail ?? ''),\n\t\t\t\t...(kind === 'tool'\n\t\t\t\t\t? { tools: value.tools.filter((t) => t !== id) }\n\t\t\t\t\t: { subagents: value.subagents.filter((s) => s !== id) }),\n\t\t\t};\n\t\t\tonChange(next);\n\t\t\tsetMentionResetKey((k) => k + 1);\n\n\t\t\tconst label =\n\t\t\t\tkind === 'tool'\n\t\t\t\t\t? availableTools.find((t) => t.tool_id === id)?.display_name ?? 'Tool'\n\t\t\t\t\t: availableSubAgents.find((s) => s.id === id)?.name ?? 'Sub-agent';\n\t\t\tundoIdRef.current += 1;\n\t\t\tsetUndoToast({\n\t\t\t\tid: undoIdRef.current,\n\t\t\t\tmessage: `${kind === 'tool' ? 'Tool' : 'Sub-agent'} \"${label}\" removed`,\n\t\t\t});\n\t\t},\n\t\t[availableTools, availableSubAgents, value, onChange],\n\t);\n\n\tconst undoRemoval = useCallback(() => {\n\t\tif (undoSnapshotRef.current) {\n\t\t\tonChange(undoSnapshotRef.current);\n\t\t\tundoSnapshotRef.current = null;\n\t\t\tsetMentionResetKey((k) => k + 1);\n\t\t}\n\t\tsetUndoToast(null);\n\t}, [onChange]);\n\n\tconst dismissUndo = useCallback(() => setUndoToast(null), []);\n\n\t// Consumer overrides merged over the built-in defaults (name 60, rest 1000).\n\tconst charLimits = useMemo<AgentCharLimits>(\n\t\t() => ({ ...AGENT_CHAR_LIMITS, ...charLimitsOverride }),\n\t\t[charLimitsOverride],\n\t);\n\n\tconst validation: StepValidation = useMemo(\n\t\t() => ({ ...deriveValidation(value, charLimits), ...validationOverride }),\n\t\t[value, charLimits, validationOverride],\n\t);\n\n\tconst ctx = useMemo<AgentBuilderContextShape>(\n\t\t() => ({\n\t\t\tvalue,\n\t\t\tpatch,\n\t\t\tupdateField,\n\t\t\taddReference,\n\t\t\tremoveReference,\n\t\t\tmentionResetKey,\n\t\t\tinsertMention,\n\t\t\tregisterMentionField,\n\t\t\tnotifyMentionFocus,\n\t\t\tundoToast,\n\t\t\tundoRemoval,\n\t\t\tdismissUndo,\n\t\t\tactiveStep,\n\t\t\tactiveIndex,\n\t\t\tgoToStep,\n\t\t\tgoNext,\n\t\t\tgoPrev,\n\t\t\tisFirstStep: activeIndex === 0,\n\t\t\tisLastStep: activeIndex === STEP_KEYS.length - 1,\n\t\t\tvalidation,\n\t\t\tisActiveStepValid: validation[activeStep],\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tavailableIntents,\n\t\t\tavailableModels,\n\t\t\tapplicationType,\n\t\t\tcharLimits,\n\t\t\tdisableStepNavigation,\n\t\t\tonCreateSubAgent,\n\t\t\tregisterSubAgentCreator,\n\t\t\trequestCreateSubAgent,\n\t\t\tonFetchSubAgent,\n\t\t\tonUpdateSubAgent,\n\t\t\tonImproveSubAgent,\n\t\t}),\n\t\t[\n\t\t\tvalue,\n\t\t\tpatch,\n\t\t\tupdateField,\n\t\t\taddReference,\n\t\t\tremoveReference,\n\t\t\tmentionResetKey,\n\t\t\tinsertMention,\n\t\t\tregisterMentionField,\n\t\t\tnotifyMentionFocus,\n\t\t\tundoToast,\n\t\t\tundoRemoval,\n\t\t\tdismissUndo,\n\t\t\tactiveStep,\n\t\t\tactiveIndex,\n\t\t\tgoToStep,\n\t\t\tgoNext,\n\t\t\tgoPrev,\n\t\t\tvalidation,\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tavailableIntents,\n\t\t\tavailableModels,\n\t\t\tapplicationType,\n\t\t\tcharLimits,\n\t\t\tdisableStepNavigation,\n\t\t\tonCreateSubAgent,\n\t\t\tregisterSubAgentCreator,\n\t\t\trequestCreateSubAgent,\n\t\t\tonFetchSubAgent,\n\t\t\tonUpdateSubAgent,\n\t\t\tonImproveSubAgent,\n\t\t],\n\t);\n\n\treturn (\n\t\t<AgentBuilderContext.Provider value={ctx}>\n\t\t\t{children}\n\t\t</AgentBuilderContext.Provider>\n\t);\n};\n"],"names":["AgentBuilderContext","React","useAgentBuilderContext","ctx","useContext","deriveValidation","value","limits","triggerValid","AgentBuilderProvider","onChange","controlledStep","onStepChange","availableTools","availableSubAgents","availableIntents","availableModels","validationOverride","applicationType","charLimitsOverride","disableStepNavigation","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","children","internalStep","setInternalStep","useState","activeStep","activeIndex","getStepIndex","valueRef","useRef","mentionResetKey","setMentionResetKey","mentionInsertersRef","lastFocusedFieldRef","registerMentionField","useCallback","fieldKey","fn","notifyMentionFocus","subAgentCreatorRef","registerSubAgentCreator","requestCreateSubAgent","insertMention","kind","id","label","inserters","undoToast","setUndoToast","undoSnapshotRef","undoIdRef","goToStep","step","goNext","next","STEP_KEYS","goPrev","prev","patch","partial","updateField","key","val","addReference","v","removeReference","token","tool","t","strip","text","s","k","undoRemoval","dismissUndo","charLimits","useMemo","AGENT_CHAR_LIMITS","validation"],"mappings":"uRAoIMA,EACLC,GAAAA,QAAM,cAA+C,IAAI,EAE7CC,GAAyB,IAAgC,CACrE,MAAMC,EAAMC,EAAAA,WAAWJ,CAAmB,EAC1C,GAAI,CAACG,EACJ,MAAM,IAAI,MACT,oEAAA,EAGF,OAAOA,CACR,EAGME,GAAmB,CACxBC,EACAC,IACoB,CACpB,MAAMC,EACLF,EAAM,QAAQ,OAAS,iBACnBA,EAAM,QAAQ,eAAiB,IAAI,KAAA,EAAO,OAAS,EACpDA,EAAM,QAAQ,QAAQ,OAAS,EAEnC,MAAO,CACN,MACCA,EAAM,KAAK,KAAA,EAAO,OAAS,GAC3BA,EAAM,KAAK,QAAUC,EAAO,MAC5BD,EAAM,YAAY,QAAUC,EAAO,YACpC,QAASC,EAET,SACCF,EAAM,aAAa,KAAA,EAAO,OAAS,IAClCA,EAAM,WAAa,IAAI,KAAA,EAAO,OAAS,EAEzC,SAAU,EAAA,CAEZ,EAyBaG,GAAgD,CAAC,CAC7D,MAAAH,EACA,SAAAI,EACA,WAAYC,EACZ,aAAAC,EACA,eAAAC,EACA,mBAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,WAAYC,EACZ,gBAAAC,EACA,WAAYC,EACZ,sBAAAC,EAAwB,GACxB,iBAAAC,EACA,gBAAAC,EACA,iBAAAC,EACA,kBAAAC,EACA,SAAAC,CACD,IAAM,CACL,KAAM,CAACC,GAAcC,EAAe,EAAIC,EAAAA,SAAkB,OAAO,EAC3DC,EAAalB,GAAkBe,GAC/BI,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EACA,YAAAC,EACA,WAAAjD,EACA,YAAAC,EACA,SAAAyB,EACA,OAAAE,EACA,OAAAG,EACA,YAAa9B,IAAgB,EAC7B,WAAYA,IAAgB6B,YAAU,OAAS,EAC/C,WAAAuB,EACA,kBAAmBA,EAAWrD,CAAU,EACxC,eAAAhB,EACA,mBAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,gBAAAE,EAAA,WACA6D,EACA,sBAAA3D,EACA,iBAAAC,EACA,wBAAAuB,EACA,sBAAAC,EACA,gBAAAvB,EACA,iBAAAC,EACA,kBAAAC,CAAA,GAED,CACClB,EACAwD,EACAE,EACAG,EACAE,EACAnC,EACAY,EACAR,EACAI,EACAS,EACA0B,EACAC,EACAjD,EACAC,EACAyB,EACAE,EACAG,EACAsB,EACArE,EACAC,EACAC,EACAC,EACAE,EACA6D,EACA3D,EACAC,EACAuB,EACAC,EACAvB,EACAC,EACAC,CAAA,CACD,EAGD,cACExB,EAAoB,SAApB,CAA6B,MAAOG,GACnC,SAAAsB,EACF,CAEF"}
1
+ {"version":3,"file":"AgentBuilderContext.js","sources":["../../../../../src/components/agent-builder/context/AgentBuilderContext.tsx"],"sourcesContent":["import type { ApplicationType } from '@bikdotai/bik-models/growth';\nimport React, {\n\tuseCallback,\n\tuseContext,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport {\n\tAgentTool,\n\tAgentValue,\n\tIntentOption,\n\tModelOption,\n\tStepKey,\n\tStepValidation,\n\tSubAgentDraft,\n\tSubAgentRef,\n} from '../AgentBuilder.model';\nimport { AGENT_CHAR_LIMITS } from '../constants/charLimits';\nimport type { AgentCharLimits } from '../constants/charLimits';\nimport { getStepIndex, STEP_KEYS } from '../constants/steps';\n\n/** Mention-capable text fields in Step 3 (both store firebase token text). */\nexport type MentionFieldKey = 'instructions' | 'guardrail';\ntype MentionInsertFn = (\n\tkind: 'tool' | 'subagent',\n\tid: string,\n\tlabel?: string,\n) => void;\n\n/** Toast shown after a tool / sub-agent is removed, offering an undo. */\nexport interface UndoToastState {\n\t/** Bumped per removal so the toast timer restarts. */\n\tid: number;\n\tmessage: string;\n}\n\nexport interface AgentBuilderContextShape {\n\t/** Controlled value relayed from props. */\n\tvalue: AgentValue;\n\t/** Patch one or more fields. */\n\tpatch: (partial: Partial<AgentValue>) => void;\n\t/** Patch a single field. */\n\tupdateField: <K extends keyof AgentValue>(key: K, val: AgentValue[K]) => void;\n\t/**\n\t * Remove a tool / sub-agent everywhere: drops it from the list AND strips ALL\n\t * its `{{tool:KEY}}` / `{{subagent:ID}}` tokens from BOTH the instructions and\n\t * the guardrails, remounts the editors, and raises an undo toast.\n\t */\n\tremoveReference: (kind: 'tool' | 'subagent', id: string) => void;\n\t/**\n\t * Append a tool / sub-agent id to its list (deduped), reading the LATEST value\n\t * via a ref. Use this instead of `patch({ tools: [...value.tools, id] })` from\n\t * any handler that may be captured with a stale `value` — notably the `@`\n\t * editor's mount-time `onSelect`, which would otherwise keep only the last pick.\n\t */\n\taddReference: (kind: 'tool' | 'subagent', id: string) => void;\n\t/** Remount signal for the mention editors after an external edit. */\n\tmentionResetKey: number;\n\t/**\n\t * Insert a tool / sub-agent mention chip at the last cursor position of\n\t * whichever mention field was focused most recently (Instructions or\n\t * Guardrails). `label` overrides the chip text (e.g. a just-created sub-agent\n\t * not yet in the available list).\n\t */\n\tinsertMention: (\n\t\tkind: 'tool' | 'subagent',\n\t\tid: string,\n\t\tlabel?: string,\n\t) => void;\n\t/** A mention field registers its editor-backed insert here (internal). */\n\tregisterMentionField: (\n\t\tfieldKey: MentionFieldKey,\n\t\tfn: MentionInsertFn | null,\n\t) => void;\n\t/** A mention field reports focus so inserts target it (internal). */\n\tnotifyMentionFocus: (fieldKey: MentionFieldKey) => void;\n\n\t// Undo (post-removal)\n\t/** Non-null while the undo toast should be visible. */\n\tundoToast: UndoToastState | null;\n\t/** Restore the last removed tool / sub-agent (list + stripped tokens). */\n\tundoRemoval: () => void;\n\t/** Dismiss the undo toast without restoring. */\n\tdismissUndo: () => void;\n\n\t// Navigation\n\tactiveStep: StepKey;\n\tactiveIndex: number;\n\tgoToStep: (step: StepKey) => void;\n\tgoNext: () => void;\n\tgoPrev: () => void;\n\tisFirstStep: boolean;\n\tisLastStep: boolean;\n\n\t// Validation\n\tvalidation: StepValidation;\n\tisActiveStepValid: boolean;\n\n\t// Reference data\n\tavailableTools: AgentTool[];\n\tavailableSubAgents: SubAgentRef[];\n\tavailableIntents: IntentOption[];\n\tavailableModels: ModelOption[];\n\t/** Host application context (e.g. MANIFEST) — drives tool-chip labelling. */\n\tapplicationType?: ApplicationType;\n\t/** Resolved per-field character limits (consumer overrides merged over defaults). */\n\tcharLimits: AgentCharLimits;\n\t/** When true, step-rail items are not clickable (Back / Next only). */\n\tdisableStepNavigation: boolean;\n\n\t// Sub-agent creation (Step 3 drawer)\n\t/** Persist a new sub-agent and resolve with its ref. Omit to hide the create flow. */\n\tonCreateSubAgent?: (draft: SubAgentDraft) => Promise<SubAgentRef>;\n\t/**\n\t * Step 3 registers its \"open create-sub-agent drawer\" action here so the `@`\n\t * picker's \"Create new\" row can trigger it. Pass `null` to unregister.\n\t */\n\tregisterSubAgentCreator: (fn: (() => void) | null) => void;\n\t/** Open the create-sub-agent drawer (no-op until Step 3 registers it). */\n\trequestCreateSubAgent: () => void;\n\t/** Fetch a sub-agent's editable data (Configure). Omit to hide Configure. */\n\tonFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;\n\t/** Persist edits to an existing sub-agent. */\n\tonUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;\n\t/** Optional \"Improve with AI\" for the drawer's instructions / guardrails. */\n\tonImproveSubAgent?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n}\n\nconst AgentBuilderContext =\n\tReact.createContext<AgentBuilderContextShape | null>(null);\n\nexport const useAgentBuilderContext = (): AgentBuilderContextShape => {\n\tconst ctx = useContext(AgentBuilderContext);\n\tif (!ctx) {\n\t\tthrow new Error(\n\t\t\t'useAgentBuilderContext must be used within an AgentBuilderProvider',\n\t\t);\n\t}\n\treturn ctx;\n};\n\n/** Validity derived purely from the current value (no effects). */\nconst deriveValidation = (\n\tvalue: AgentValue,\n\tlimits: AgentCharLimits,\n): StepValidation => {\n\tconst triggerValid =\n\t\tvalue.trigger.mode === 'custom_intent'\n\t\t\t? (value.trigger.custom_intent ?? '').trim().length > 0\n\t\t\t: value.trigger.intents.length > 0;\n\n\treturn {\n\t\tabout:\n\t\t\tvalue.name.trim().length > 0 &&\n\t\t\tvalue.name.length <= limits.name &&\n\t\t\tvalue.description.length <= limits.description,\n\t\ttrigger: triggerValid,\n\t\t// At least one of Instructions / Guardrails must be filled.\n\t\tresponse:\n\t\t\tvalue.instructions.trim().length > 0 ||\n\t\t\t(value.guardrail ?? '').trim().length > 0,\n\t\t// Optional until specced further — never blocks go-live.\n\t\thandover: true,\n\t};\n};\n\ninterface ProviderProps {\n\tvalue: AgentValue;\n\tonChange: (patch: Partial<AgentValue>) => void;\n\tactiveStep?: StepKey;\n\tonStepChange?: (step: StepKey) => void;\n\tavailableTools: AgentTool[];\n\tavailableSubAgents: SubAgentRef[];\n\tavailableIntents: IntentOption[];\n\tavailableModels: ModelOption[];\n\tvalidation?: Partial<StepValidation>;\n\tapplicationType?: ApplicationType;\n\tcharLimits?: Partial<AgentCharLimits>;\n\tdisableStepNavigation?: boolean;\n\tonCreateSubAgent?: (draft: SubAgentDraft) => Promise<SubAgentRef>;\n\tonFetchSubAgent?: (id: string) => Promise<SubAgentDraft>;\n\tonUpdateSubAgent?: (id: string, draft: SubAgentDraft) => Promise<SubAgentRef>;\n\tonImproveSubAgent?: (\n\t\tkind: 'instructions' | 'guardrail',\n\t\ttext: string,\n\t) => Promise<string>;\n\tchildren: React.ReactNode;\n}\n\nexport const AgentBuilderProvider: React.FC<ProviderProps> = ({\n\tvalue,\n\tonChange,\n\tactiveStep: controlledStep,\n\tonStepChange,\n\tavailableTools,\n\tavailableSubAgents,\n\tavailableIntents,\n\tavailableModels,\n\tvalidation: validationOverride,\n\tapplicationType,\n\tcharLimits: charLimitsOverride,\n\tdisableStepNavigation = true,\n\tonCreateSubAgent,\n\tonFetchSubAgent,\n\tonUpdateSubAgent,\n\tonImproveSubAgent,\n\tchildren,\n}) => {\n\tconst [internalStep, setInternalStep] = useState<StepKey>('about');\n\tconst activeStep = controlledStep ?? internalStep;\n\tconst activeIndex = getStepIndex(activeStep);\n\n\t// Latest value, so closure-captured handlers (e.g. the `@` editor's mount-time\n\t// mention onSelect) append against the current lists, not a stale snapshot.\n\tconst valueRef = useRef(value);\n\tvalueRef.current = value;\n\n\t// Bumped when a mention field is edited from OUTSIDE its editor (removing a\n\t// tool from the side list, undo), forcing the mention editors to remount.\n\tconst [mentionResetKey, setMentionResetKey] = useState(0);\n\n\t// Each mention field registers an editor-backed insert fn + reports focus, so\n\t// side-panel adds drop a chip into the last-focused field at its cursor.\n\tconst mentionInsertersRef = useRef<\n\t\tPartial<Record<MentionFieldKey, MentionInsertFn>>\n\t>({});\n\tconst lastFocusedFieldRef = useRef<MentionFieldKey>('instructions');\n\tconst registerMentionField = useCallback(\n\t\t(fieldKey: MentionFieldKey, fn: MentionInsertFn | null) => {\n\t\t\tif (fn) {\n\t\t\t\tmentionInsertersRef.current[fieldKey] = fn;\n\t\t\t} else {\n\t\t\t\tdelete mentionInsertersRef.current[fieldKey];\n\t\t\t}\n\t\t},\n\t\t[],\n\t);\n\tconst notifyMentionFocus = useCallback((fieldKey: MentionFieldKey) => {\n\t\tlastFocusedFieldRef.current = fieldKey;\n\t}, []);\n\n\t// Step 3 registers its drawer opener here; the `@` picker's \"Create new\" calls it.\n\tconst subAgentCreatorRef = useRef<(() => void) | null>(null);\n\tconst registerSubAgentCreator = useCallback((fn: (() => void) | null) => {\n\t\tsubAgentCreatorRef.current = fn;\n\t}, []);\n\tconst requestCreateSubAgent = useCallback(() => {\n\t\tsubAgentCreatorRef.current?.();\n\t}, []);\n\tconst insertMention = useCallback<MentionInsertFn>((kind, id, label) => {\n\t\tconst inserters = mentionInsertersRef.current;\n\t\tconst target =\n\t\t\tinserters[lastFocusedFieldRef.current] ?? inserters.instructions;\n\t\ttarget?.(kind, id, label);\n\t}, []);\n\n\t// Undo state for the most recent removal.\n\tconst [undoToast, setUndoToast] = useState<UndoToastState | null>(null);\n\tconst undoSnapshotRef = useRef<Partial<AgentValue> | null>(null);\n\tconst undoIdRef = useRef(0);\n\n\tconst goToStep = useCallback(\n\t\t(step: StepKey) => {\n\t\t\tif (controlledStep === undefined) {\n\t\t\t\tsetInternalStep(step);\n\t\t\t}\n\t\t\tonStepChange?.(step);\n\t\t},\n\t\t[controlledStep, onStepChange],\n\t);\n\n\tconst goNext = useCallback(() => {\n\t\tconst next = STEP_KEYS[Math.min(activeIndex + 1, STEP_KEYS.length - 1)];\n\t\tgoToStep(next);\n\t}, [activeIndex, goToStep]);\n\n\tconst goPrev = useCallback(() => {\n\t\tconst prev = STEP_KEYS[Math.max(activeIndex - 1, 0)];\n\t\tgoToStep(prev);\n\t}, [activeIndex, goToStep]);\n\n\tconst patch = useCallback(\n\t\t(partial: Partial<AgentValue>) => onChange(partial),\n\t\t[onChange],\n\t);\n\n\tconst updateField = useCallback(\n\t\t<K extends keyof AgentValue>(key: K, val: AgentValue[K]) =>\n\t\t\tonChange({ [key]: val } as Partial<AgentValue>),\n\t\t[onChange],\n\t);\n\n\tconst addReference = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\tconst v = valueRef.current;\n\t\t\tif (kind === 'tool') {\n\t\t\t\tif (!v.tools.includes(id)) {\n\t\t\t\t\tonChange({ tools: [...v.tools, id] });\n\t\t\t\t}\n\t\t\t} else if (!v.subagents.includes(id)) {\n\t\t\t\tonChange({ subagents: [...v.subagents, id] });\n\t\t\t}\n\t\t},\n\t\t[onChange],\n\t);\n\n\tconst removeReference = useCallback(\n\t\t(kind: 'tool' | 'subagent', id: string) => {\n\t\t\t// Tokens store the id for both kinds (a tool's id is its tool_id).\n\t\t\tconst token = kind === 'tool' ? `{{tool:${id}}}` : `{{subagent:${id}}}`;\n\t\t\tconst strip = (text: string) => text.split(token).join('');\n\n\t\t\t// Snapshot the four fields a removal touches, for undo.\n\t\t\tundoSnapshotRef.current = {\n\t\t\t\ttools: value.tools,\n\t\t\t\tsubagents: value.subagents,\n\t\t\t\tinstructions: value.instructions,\n\t\t\t\tguardrail: value.guardrail,\n\t\t\t};\n\n\t\t\tconst next: Partial<AgentValue> = {\n\t\t\t\tinstructions: strip(value.instructions),\n\t\t\t\tguardrail: strip(value.guardrail ?? ''),\n\t\t\t\t...(kind === 'tool'\n\t\t\t\t\t? { tools: value.tools.filter((t) => t !== id) }\n\t\t\t\t\t: { subagents: value.subagents.filter((s) => s !== id) }),\n\t\t\t};\n\t\t\tonChange(next);\n\t\t\tsetMentionResetKey((k) => k + 1);\n\n\t\t\tconst label =\n\t\t\t\tkind === 'tool'\n\t\t\t\t\t? availableTools.find((t) => t.tool_id === id)?.display_name ?? 'Tool'\n\t\t\t\t\t: availableSubAgents.find((s) => s.id === id)?.name ?? 'Sub-agent';\n\t\t\tundoIdRef.current += 1;\n\t\t\tsetUndoToast({\n\t\t\t\tid: undoIdRef.current,\n\t\t\t\tmessage: `${kind === 'tool' ? 'Tool' : 'Sub-agent'} \"${label}\" removed`,\n\t\t\t});\n\t\t},\n\t\t[availableTools, availableSubAgents, value, onChange],\n\t);\n\n\tconst undoRemoval = useCallback(() => {\n\t\tif (undoSnapshotRef.current) {\n\t\t\tonChange(undoSnapshotRef.current);\n\t\t\tundoSnapshotRef.current = null;\n\t\t\tsetMentionResetKey((k) => k + 1);\n\t\t}\n\t\tsetUndoToast(null);\n\t}, [onChange]);\n\n\tconst dismissUndo = useCallback(() => setUndoToast(null), []);\n\n\t// Consumer overrides merged over the built-in defaults (name 60, rest 1000).\n\tconst charLimits = useMemo<AgentCharLimits>(\n\t\t() => ({ ...AGENT_CHAR_LIMITS, ...charLimitsOverride }),\n\t\t[charLimitsOverride],\n\t);\n\n\tconst validation: StepValidation = useMemo(\n\t\t() => ({ ...deriveValidation(value, charLimits), ...validationOverride }),\n\t\t[value, charLimits, validationOverride],\n\t);\n\n\tconst ctx = useMemo<AgentBuilderContextShape>(\n\t\t() => ({\n\t\t\tvalue,\n\t\t\tpatch,\n\t\t\tupdateField,\n\t\t\taddReference,\n\t\t\tremoveReference,\n\t\t\tmentionResetKey,\n\t\t\tinsertMention,\n\t\t\tregisterMentionField,\n\t\t\tnotifyMentionFocus,\n\t\t\tundoToast,\n\t\t\tundoRemoval,\n\t\t\tdismissUndo,\n\t\t\tactiveStep,\n\t\t\tactiveIndex,\n\t\t\tgoToStep,\n\t\t\tgoNext,\n\t\t\tgoPrev,\n\t\t\tisFirstStep: activeIndex === 0,\n\t\t\tisLastStep: activeIndex === STEP_KEYS.length - 1,\n\t\t\tvalidation,\n\t\t\tisActiveStepValid: validation[activeStep],\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tavailableIntents,\n\t\t\tavailableModels,\n\t\t\tapplicationType,\n\t\t\tcharLimits,\n\t\t\tdisableStepNavigation,\n\t\t\tonCreateSubAgent,\n\t\t\tregisterSubAgentCreator,\n\t\t\trequestCreateSubAgent,\n\t\t\tonFetchSubAgent,\n\t\t\tonUpdateSubAgent,\n\t\t\tonImproveSubAgent,\n\t\t}),\n\t\t[\n\t\t\tvalue,\n\t\t\tpatch,\n\t\t\tupdateField,\n\t\t\taddReference,\n\t\t\tremoveReference,\n\t\t\tmentionResetKey,\n\t\t\tinsertMention,\n\t\t\tregisterMentionField,\n\t\t\tnotifyMentionFocus,\n\t\t\tundoToast,\n\t\t\tundoRemoval,\n\t\t\tdismissUndo,\n\t\t\tactiveStep,\n\t\t\tactiveIndex,\n\t\t\tgoToStep,\n\t\t\tgoNext,\n\t\t\tgoPrev,\n\t\t\tvalidation,\n\t\t\tavailableTools,\n\t\t\tavailableSubAgents,\n\t\t\tavailableIntents,\n\t\t\tavailableModels,\n\t\t\tapplicationType,\n\t\t\tcharLimits,\n\t\t\tdisableStepNavigation,\n\t\t\tonCreateSubAgent,\n\t\t\tregisterSubAgentCreator,\n\t\t\trequestCreateSubAgent,\n\t\t\tonFetchSubAgent,\n\t\t\tonUpdateSubAgent,\n\t\t\tonImproveSubAgent,\n\t\t],\n\t);\n\n\treturn (\n\t\t<AgentBuilderContext.Provider value={ctx}>\n\t\t\t{children}\n\t\t</AgentBuilderContext.Provider>\n\t);\n};\n"],"names":["AgentBuilderContext","React","useAgentBuilderContext","ctx","useContext","deriveValidation","value","limits","triggerValid","AgentBuilderProvider","onChange","controlledStep","onStepChange","availableTools","availableSubAgents","availableIntents","availableModels","validationOverride","applicationType","charLimitsOverride","disableStepNavigation","onCreateSubAgent","onFetchSubAgent","onUpdateSubAgent","onImproveSubAgent","children","internalStep","setInternalStep","useState","activeStep","activeIndex","getStepIndex","valueRef","useRef","mentionResetKey","setMentionResetKey","mentionInsertersRef","lastFocusedFieldRef","registerMentionField","useCallback","fieldKey","fn","notifyMentionFocus","subAgentCreatorRef","registerSubAgentCreator","requestCreateSubAgent","insertMention","kind","id","label","inserters","undoToast","setUndoToast","undoSnapshotRef","undoIdRef","goToStep","step","goNext","next","STEP_KEYS","goPrev","prev","patch","partial","updateField","key","val","addReference","v","removeReference","token","strip","text","t","s","k","undoRemoval","dismissUndo","charLimits","useMemo","AGENT_CHAR_LIMITS","validation"],"mappings":"uRAoIMA,EACLC,GAAAA,QAAM,cAA+C,IAAI,EAE7CC,GAAyB,IAAgC,CACrE,MAAMC,EAAMC,EAAAA,WAAWJ,CAAmB,EAC1C,GAAI,CAACG,EACJ,MAAM,IAAI,MACT,oEAAA,EAGF,OAAOA,CACR,EAGME,GAAmB,CACxBC,EACAC,IACoB,CACpB,MAAMC,EACLF,EAAM,QAAQ,OAAS,iBACnBA,EAAM,QAAQ,eAAiB,IAAI,KAAA,EAAO,OAAS,EACpDA,EAAM,QAAQ,QAAQ,OAAS,EAEnC,M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AC,EAEPmE,EAActC,EAAAA,YAAY,IAAMa,EAAa,IAAI,EAAG,CAAA,CAAE,EAGtD0B,EAAaC,EAAAA,QAClB,KAAO,CAAE,GAAGC,GAAAA,kBAAmB,GAAG7D,IAClC,CAACA,CAAkB,CAAA,EAGd8D,EAA6BF,EAAAA,QAClC,KAAO,CAAE,GAAG1E,GAAiBC,EAAOwE,CAAU,EAAG,GAAG7D,IACpD,CAACX,EAAOwE,EAAY7D,CAAkB,CAAA,EAGjCd,GAAM4E,EAAAA,QACX,KAAO,CACN,MAAAzE,EACA,MAAAwD,EACA,YAAAE,EACA,aAAAG,EACA,gBAAAE,EACA,gBAAAnC,EACA,cAAAY,EACA,qBAAAR,EACA,mBAAAI,EACA,UAAAS,EACA,YAAAyB,EACA,YAAAC,EACA,WAAAhD,EACA,YAAAC,EACA,SAAAyB,EACA,OAAAE,EACA,OAAAG,EACA,YAAa9B,IAAgB,EAC7B,WAAYA,IAAgB6B,YAAU,OAAS,EAC/C,WAAAsB,EACA,kBAAmBA,EAAWpD,CAAU,EACxC,eAAAhB,EACA,mBAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,gBAAAE,EAAA,WACA4D,EACA,sBAAA1D,EACA,iBAAAC,EACA,wBAAAuB,EACA,sBAAAC,EACA,gBAAAvB,EACA,iBAAAC,EACA,kBAAAC,CAAA,GAED,CACClB,EACAwD,EACAE,EACAG,EACAE,EACAnC,EACAY,EACAR,EACAI,EACAS,EACAyB,EACAC,EACAhD,EACAC,EACAyB,EACAE,EACAG,EACAqB,EACApE,EACAC,EACAC,EACAC,EACAE,EACA4D,EACA1D,EACAC,EACAuB,EACAC,EACAvB,EACAC,EACAC,CAAA,CACD,EAGD,cACExB,EAAoB,SAApB,CAA6B,MAAOG,GACnC,SAAAsB,EACF,CAEF"}
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c={manifest:"Manifest",shopify:"Shopify",integration:"Integration"},u=(t,n="Manifest")=>t?c[t]??t:n,b=t=>{const n=t?String(t):"";return n==="BIK"?"BIK":n==="BSP"?"BSP":"Manifest"},g=(t,n,e="Manifest")=>[...t.map(o=>({id:o.tool_id,label:`${u(o.source,e)} : ${o.display_name}`,meta:{kind:"tool",functionKey:o.function_key,plainLabel:o.display_name,source:o.source}})),...n.map(o=>({id:o.id,label:`sub-agent: ${o.name}`,meta:{kind:"subagent",plainLabel:o.name}}))],a=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),s=t=>a(t).replace(/"/g,"&quot;"),d=(t,n,e)=>`<span data-type="mentionAgent" class="bik-mention bik-mention--agent" data-id="${s(t)}" data-label="${s(n)}" data-kind="${s(e)}">${a(n)}</span>`,f=(t,n,e)=>d(t,n,e),k=t=>{const n=new Map;for(const e of t){const o=e.meta;o?.kind==="tool"&&o.functionKey?n.set(`tool:${o.functionKey}`,e):o?.kind==="subagent"&&n.set(`subagent:${String(e.id)}`,e)}return n},l=/\{\{(tool:[^}]+|subagent:[^}]+)\}\}/g,y=(t,n)=>{let e="",o=0;l.lastIndex=0;let i;for(;(i=l.exec(t))!==null;){e+=a(t.slice(o,i.index));const r=n.get(i[1]);if(r){const m=r.meta.kind;e+=d(String(r.id),r.label,m)}else e+=a(i[0]);o=l.lastIndex}return e+=a(t.slice(o)),e.replace(/\n/g,"<br>")},S=(t,n=[])=>{if(!t)return"";const e=k(n);return t.split(/\n{2,}/).map(o=>`<p>${y(o,e)}</p>`).join("")},T=(t,n)=>{const e=n[t];return e?`{{tool:${e}}}`:`{{subagent:${t}}}`},p=(t,n)=>{switch(t.type){case"text":return t.text??"";case"mentionAgent":case"mentionTeam":{const e=t.attrs?.id;return e==null?"":T(String(e),n)}case"variable":return`{{${String(t.attrs?.variableName??"")}}}`;case"hardBreak":return`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c={manifest:"Manifest",shopify:"Shopify",integration:"Integration"},u=(t,n="Manifest")=>t?c[t]??t:n,b=t=>{const n=t?String(t):"";return n==="BIK"?"BIK":n==="BSP"?"BSP":"Manifest"},g=(t,n,e="Manifest")=>[...t.map(o=>({id:o.tool_id,label:`${u(o.source,e)} : ${o.display_name}`,meta:{kind:"tool",plainLabel:o.display_name,source:o.source}})),...n.map(o=>({id:o.id,label:`sub-agent: ${o.name}`,meta:{kind:"subagent",plainLabel:o.name}}))],a=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),r=t=>a(t).replace(/"/g,"&quot;"),d=(t,n,e)=>`<span data-type="mentionAgent" class="bik-mention bik-mention--agent" data-id="${r(t)}" data-label="${r(n)}" data-kind="${r(e)}">${a(n)}</span>`,S=(t,n,e)=>d(t,n,e),f=t=>{const n=new Map;for(const e of t){const o=e.meta;o?.kind==="tool"?n.set(`tool:${String(e.id)}`,e):o?.kind==="subagent"&&n.set(`subagent:${String(e.id)}`,e)}return n},l=/\{\{(tool:[^}]+|subagent:[^}]+)\}\}/g,k=(t,n)=>{let e="",o=0;l.lastIndex=0;let i;for(;(i=l.exec(t))!==null;){e+=a(t.slice(o,i.index));const s=n.get(i[1]);if(s){const m=s.meta.kind;e+=d(String(s.id),s.label,m)}else e+=a(i[0]);o=l.lastIndex}return e+=a(t.slice(o)),e.replace(/\n/g,"<br>")},T=(t,n=[])=>{if(!t)return"";const e=f(n);return t.split(/\n{2,}/).map(o=>`<p>${k(o,e)}</p>`).join("")},L=(t,n,e)=>(n??(e.has(t)?"tool":"subagent"))==="tool"?`{{tool:${t}}}`:`{{subagent:${t}}}`,p=(t,n)=>{switch(t.type){case"text":return t.text??"";case"mentionAgent":case"mentionTeam":{const e=t.attrs?.id;if(e==null)return"";const o=t.attrs?.kind;return L(String(e),o==null?null:String(o),n)}case"variable":return`{{${String(t.attrs?.variableName??"")}}}`;case"hardBreak":return`
2
2
  `;default:{const e=(t.content??[]).map(i=>p(i,n)).join("");return["paragraph","heading","listItem","blockquote"].includes(t.type)?`${e}
3
- `:e}}},L=(t,n)=>{if(!t)return"";const e=n.reduce((o,i)=>(o[i.tool_id]=i.function_key,o),{});return p(t,e).replace(/\n+$/,"")};exports.TOOL_SOURCE_LABELS=c;exports.appTypeLabel=b;exports.buildAgentMentionItems=g;exports.buildMentionHtml=f;exports.editorDocToInstructions=L;exports.instructionsToEditorHtml=S;exports.toolSourceLabel=u;
3
+ `:e}}},$=(t,n)=>{if(!t)return"";const e=new Set(n.map(o=>o.tool_id));return p(t,e).replace(/\n+$/,"")};exports.TOOL_SOURCE_LABELS=c;exports.appTypeLabel=b;exports.buildAgentMentionItems=g;exports.buildMentionHtml=S;exports.editorDocToInstructions=$;exports.instructionsToEditorHtml=T;exports.toolSourceLabel=u;
4
4
  //# sourceMappingURL=mentionSerialization.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mentionSerialization.js","sources":["../../../../../src/components/agent-builder/utils/mentionSerialization.ts"],"sourcesContent":["import type { ApplicationType } from '@bikdotai/bik-models/growth';\nimport { MentionItem } from '@src/editor';\nimport { AgentTool, SubAgentRef } from '../AgentBuilder.model';\n\n/**\n * Serialization helpers between the BikEditor document and the firebase\n * `instructions` string.\n *\n * Firebase stores `instructions` as PLAIN TEXT with inline reference tokens:\n * - `{{subagent:<agentId>}}` — hand-off to another agent\n * - `{{tool:<function_key>}}` — an action the agent can call\n * - `{{<variableName>}}` — a template variable\n *\n * In the editor those references are inserted via the `@` mention menu (which we\n * populate with BOTH tools and sub-agents). Mention nodes keep their `id` in the\n * ProseMirror doc JSON (the rendered HTML drops it), so we serialize from the doc\n * JSON — not from HTML.\n */\n\nexport interface MentionKindMeta {\n\t/** Distinguishes a tool reference from a sub-agent reference. */\n\tkind: 'tool' | 'subagent';\n\t/** For tools: the function_key used in the `{{tool:KEY}}` token. */\n\tfunctionKey?: string;\n\t/** Plain item name (no prefix) shown in the picker dropdown rows. */\n\tplainLabel?: string;\n\t/** For tools: the source bucket (manifest / shopify / …) the picker groups by. */\n\tsource?: string;\n}\n\n/** Display labels for the known tool sources (drives picker headers + chip prefix). */\nexport const TOOL_SOURCE_LABELS: Record<string, string> = {\n\tmanifest: 'Manifest',\n\tshopify: 'Shopify',\n\tintegration: 'Integration',\n};\n\n/** Human label for a tool source; falls back to the host-app label, then the raw key. */\nexport const toolSourceLabel = (\n\tsource: string | undefined,\n\tfallback = 'Manifest',\n): string => {\n\tif (!source) {\n\t\treturn fallback;\n\t}\n\treturn TOOL_SOURCE_LABELS[source] ?? source;\n};\n\n/** Human label for the host application, used as the tool-chip prefix. */\nexport const appTypeLabel = (applicationType?: ApplicationType): string => {\n\tconst key = applicationType ? String(applicationType) : '';\n\tif (key === 'BIK') {\n\t\treturn 'BIK';\n\t}\n\tif (key === 'BSP') {\n\t\treturn 'BSP';\n\t}\n\treturn 'Manifest';\n};\n\n/**\n * Build the combined `@` mention list from the available tools + sub-agents.\n *\n * The `label` is the CHIP text shown once inserted — tools read\n * `\"<App> : <tool name>\"` (e.g. \"Manifest : Look up order\"), sub-agents read\n * `\"sub-agent: <name>\"`. `meta.plainLabel` is the un-prefixed name for the\n * picker rows, and `meta.kind` drives the `{{tool}}` / `{{subagent}}` colour.\n */\nexport const buildAgentMentionItems = (\n\ttools: AgentTool[],\n\tsubAgents: SubAgentRef[],\n\tappLabel = 'Manifest',\n): MentionItem[] => [\n\t...tools.map(\n\t\t(t): MentionItem => ({\n\t\t\tid: t.tool_id,\n\t\t\tlabel: `${toolSourceLabel(t.source, appLabel)} : ${t.display_name}`,\n\t\t\tmeta: {\n\t\t\t\tkind: 'tool',\n\t\t\t\tfunctionKey: t.function_key,\n\t\t\t\tplainLabel: t.display_name,\n\t\t\t\tsource: t.source,\n\t\t\t},\n\t\t}),\n\t),\n\t...subAgents.map(\n\t\t(s): MentionItem => ({\n\t\t\tid: s.id,\n\t\t\tlabel: `sub-agent: ${s.name}`,\n\t\t\tmeta: { kind: 'subagent', plainLabel: s.name },\n\t\t}),\n\t),\n];\n\nconst escapeHtml = (raw: string): string =>\n\traw.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n\nconst escapeAttr = (raw: string): string =>\n\tescapeHtml(raw).replace(/\"/g, '&quot;');\n\n/**\n * The HTML for a single mention chip. Must round-trip through the TipTap mention\n * extension's `parseHTML` (`span[data-type=\"mentionAgent\"]`, reading\n * `data-id`/`data-label`/`data-kind`) — see MentionExtension.ts. `normalizeHtml`\n * is taught to keep `data-type=\"mention…\"` spans so this survives to the parser.\n */\nconst mentionSpanHtml = (id: string, label: string, kind: string): string =>\n\t`<span data-type=\"mentionAgent\" class=\"bik-mention bik-mention--agent\"` +\n\t` data-id=\"${escapeAttr(id)}\" data-label=\"${escapeAttr(label)}\"` +\n\t` data-kind=\"${escapeAttr(kind)}\">${escapeHtml(label)}</span>`;\n\n/**\n * Public: HTML for one mention chip, for inserting at the cursor (e.g. when a\n * tool / sub-agent is added from the Step-3 side panel). Round-trips through the\n * same parser path as the rehydrated chips.\n */\nexport const buildMentionHtml = (\n\tid: string,\n\tlabel: string,\n\tkind: 'tool' | 'subagent',\n): string => mentionSpanHtml(id, label, kind);\n\n/** `{{tool:KEY}}` / `{{subagent:ID}}` → the mention item that produced them. */\nconst buildTokenLookup = (\n\tmentionItems: MentionItem[],\n): Map<string, MentionItem> => {\n\tconst byToken = new Map<string, MentionItem>();\n\tfor (const item of mentionItems) {\n\t\tconst meta = item.meta as unknown as MentionKindMeta | undefined;\n\t\tif (meta?.kind === 'tool' && meta.functionKey) {\n\t\t\tbyToken.set(`tool:${meta.functionKey}`, item);\n\t\t} else if (meta?.kind === 'subagent') {\n\t\t\tbyToken.set(`subagent:${String(item.id)}`, item);\n\t\t}\n\t}\n\treturn byToken;\n};\n\n// Matches the reference tokens we render as chips. Other `{{var}}` tokens fall\n// through untouched (left as literal text for the variable decoration).\nconst REFERENCE_TOKEN = /\\{\\{(tool:[^}]+|subagent:[^}]+)\\}\\}/g;\n\n/** Escape plain text, swapping recognised reference tokens for mention spans. */\nconst inlineToHtml = (\n\tsegment: string,\n\tbyToken: Map<string, MentionItem>,\n): string => {\n\tlet out = '';\n\tlet lastIndex = 0;\n\tREFERENCE_TOKEN.lastIndex = 0;\n\tlet match: RegExpExecArray | null;\n\twhile ((match = REFERENCE_TOKEN.exec(segment)) !== null) {\n\t\tout += escapeHtml(segment.slice(lastIndex, match.index));\n\t\tconst item = byToken.get(match[1]);\n\t\tif (item) {\n\t\t\tconst kind = (item.meta as unknown as MentionKindMeta).kind;\n\t\t\tout += mentionSpanHtml(String(item.id), item.label, kind);\n\t\t} else {\n\t\t\t// Tool/sub-agent no longer in the available list → keep the raw token.\n\t\t\tout += escapeHtml(match[0]);\n\t\t}\n\t\tlastIndex = REFERENCE_TOKEN.lastIndex;\n\t}\n\tout += escapeHtml(segment.slice(lastIndex));\n\treturn out.replace(/\\n/g, '<br>');\n};\n\n/**\n * Convert the stored instructions string into HTML for `BikEditor.initialContent`.\n * `{{tool:KEY}}` / `{{subagent:ID}}` tokens are rehydrated into mention chips\n * (resolved via `mentionItems`); any other `{{…}}` token is left as literal text\n * for the editor's variable decoration. Newlines become paragraph / line breaks.\n */\nexport const instructionsToEditorHtml = (\n\ttext: string,\n\tmentionItems: MentionItem[] = [],\n): string => {\n\tif (!text) {\n\t\treturn '';\n\t}\n\tconst byToken = buildTokenLookup(mentionItems);\n\treturn text\n\t\t.split(/\\n{2,}/)\n\t\t.map((para) => `<p>${inlineToHtml(para, byToken)}</p>`)\n\t\t.join('');\n};\n\ninterface ProseMirrorNode {\n\ttype: string;\n\ttext?: string;\n\tattrs?: Record<string, unknown>;\n\tcontent?: ProseMirrorNode[];\n}\n\n/** Map of mention node id → token, derived from the available tools. */\nconst resolveMentionToken = (\n\tid: string,\n\ttoolKeyById: Record<string, string>,\n): string => {\n\tconst functionKey = toolKeyById[id];\n\tif (functionKey) {\n\t\treturn `{{tool:${functionKey}}}`;\n\t}\n\treturn `{{subagent:${id}}}`;\n};\n\nconst nodeToText = (\n\tnode: ProseMirrorNode,\n\ttoolKeyById: Record<string, string>,\n): string => {\n\tswitch (node.type) {\n\t\tcase 'text':\n\t\t\treturn node.text ?? '';\n\t\tcase 'mentionAgent':\n\t\tcase 'mentionTeam': {\n\t\t\tconst id = node.attrs?.['id'];\n\t\t\treturn id == null ? '' : resolveMentionToken(String(id), toolKeyById);\n\t\t}\n\t\tcase 'variable':\n\t\t\treturn `{{${String(node.attrs?.['variableName'] ?? '')}}}`;\n\t\tcase 'hardBreak':\n\t\t\treturn '\\n';\n\t\tdefault: {\n\t\t\tconst inner = (node.content ?? [])\n\t\t\t\t.map((child) => nodeToText(child, toolKeyById))\n\t\t\t\t.join('');\n\t\t\t// Block nodes terminate with a newline so paragraphs stay separated.\n\t\t\tconst BLOCK_NODES = ['paragraph', 'heading', 'listItem', 'blockquote'];\n\t\t\treturn BLOCK_NODES.includes(node.type) ? `${inner}\\n` : inner;\n\t\t}\n\t}\n};\n\n/**\n * Convert a BikEditor document (from `ref.getJSON()`) into the firebase\n * instructions string, replacing mention nodes with `{{subagent:ID}}` /\n * `{{tool:KEY}}` tokens.\n */\nexport const editorDocToInstructions = (\n\tdoc: Record<string, unknown> | null,\n\ttools: AgentTool[],\n): string => {\n\tif (!doc) {\n\t\treturn '';\n\t}\n\tconst toolKeyById = tools.reduce<Record<string, string>>((acc, t) => {\n\t\tacc[t.tool_id] = t.function_key;\n\t\treturn acc;\n\t}, {});\n\treturn nodeToText(doc as unknown as ProseMirrorNode, toolKeyById).replace(\n\t\t/\\n+$/,\n\t\t'',\n\t);\n};\n"],"names":["TOOL_SOURCE_LABELS","toolSourceLabel","source","fallback","appTypeLabel","applicationType","key","buildAgentMentionItems","tools","subAgents","appLabel","t","s","escapeHtml","raw","escapeAttr","mentionSpanHtml","id","label","kind","buildMentionHtml","buildTokenLookup","mentionItems","byToken","item","meta","REFERENCE_TOKEN","inlineToHtml","segment","out","lastIndex","match","instructionsToEditorHtml","text","para","resolveMentionToken","toolKeyById","functionKey","nodeToText","node","inner","child","editorDocToInstructions","doc","acc"],"mappings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AAKkB,EAAoB,OAAOlB,CAAE,EAAGmB,CAAW,CACrE,CACA,IAAK,WACJ,MAAO,KAAK,OAAOG,EAAK,OAAQ,cAAmB,EAAE,CAAC,KACvD,IAAK,YACJ,MAAO;AAAA,EACR,QAAS,CACR,MAAMC,GAASD,EAAK,SAAW,CAAA,GAC7B,IAAKE,GAAUH,EAAWG,EAAOL,CAAW,CAAC,EAC7C,KAAK,EAAE,EAGT,MADoB,CAAC,YAAa,UAAW,WAAY,YAAY,EAClD,SAASG,EAAK,IAAI,EAAI,GAAGC,CAAK;AAAA,EAAOA,CACzD,CAAA,CAEF,EAOaE,EAA0B,CACtCC,EACAnC,IACY,CACZ,GAAI,CAACmC,EACJ,MAAO,GAER,MAAMP,EAAc5B,EAAM,OAA+B,CAACoC,EAAKjC,KAC9DiC,EAAIjC,EAAE,OAAO,EAAIA,EAAE,aACZiC,GACL,CAAA,CAAE,EACL,OAAON,EAAWK,EAAmCP,CAAW,EAAE,QACjE,OACA,EAAA,CAEF"}
1
+ {"version":3,"file":"mentionSerialization.js","sources":["../../../../../src/components/agent-builder/utils/mentionSerialization.ts"],"sourcesContent":["import type { ApplicationType } from '@bikdotai/bik-models/growth';\nimport { MentionItem } from '@src/editor';\nimport { AgentTool, SubAgentRef } from '../AgentBuilder.model';\n\n/**\n * Serialization helpers between the BikEditor document and the firebase\n * `instructions` string.\n *\n * Firebase stores `instructions` as PLAIN TEXT with inline reference tokens:\n * - `{{subagent:<agentId>}}` — hand-off to another agent\n * - `{{tool:<tool_id>}}` — an action the agent can call\n * - `{{<variableName>}}` — a template variable\n *\n * In the editor those references are inserted via the `@` mention menu (which we\n * populate with BOTH tools and sub-agents). Mention nodes keep their `id` in the\n * ProseMirror doc JSON (the rendered HTML drops it), so we serialize from the doc\n * JSON — not from HTML.\n */\n\nexport interface MentionKindMeta {\n\t/** Distinguishes a tool reference from a sub-agent reference. */\n\tkind: 'tool' | 'subagent';\n\t/** Plain item name (no prefix) shown in the picker dropdown rows. */\n\tplainLabel?: string;\n\t/** For tools: the source bucket (manifest / shopify / …) the picker groups by. */\n\tsource?: string;\n}\n\n/** Display labels for the known tool sources (drives picker headers + chip prefix). */\nexport const TOOL_SOURCE_LABELS: Record<string, string> = {\n\tmanifest: 'Manifest',\n\tshopify: 'Shopify',\n\tintegration: 'Integration',\n};\n\n/** Human label for a tool source; falls back to the host-app label, then the raw key. */\nexport const toolSourceLabel = (\n\tsource: string | undefined,\n\tfallback = 'Manifest',\n): string => {\n\tif (!source) {\n\t\treturn fallback;\n\t}\n\treturn TOOL_SOURCE_LABELS[source] ?? source;\n};\n\n/** Human label for the host application, used as the tool-chip prefix. */\nexport const appTypeLabel = (applicationType?: ApplicationType): string => {\n\tconst key = applicationType ? String(applicationType) : '';\n\tif (key === 'BIK') {\n\t\treturn 'BIK';\n\t}\n\tif (key === 'BSP') {\n\t\treturn 'BSP';\n\t}\n\treturn 'Manifest';\n};\n\n/**\n * Build the combined `@` mention list from the available tools + sub-agents.\n *\n * The `label` is the CHIP text shown once inserted — tools read\n * `\"<App> : <tool name>\"` (e.g. \"Manifest : Look up order\"), sub-agents read\n * `\"sub-agent: <name>\"`. `meta.plainLabel` is the un-prefixed name for the\n * picker rows, and `meta.kind` drives the `{{tool}}` / `{{subagent}}` colour.\n */\nexport const buildAgentMentionItems = (\n\ttools: AgentTool[],\n\tsubAgents: SubAgentRef[],\n\tappLabel = 'Manifest',\n): MentionItem[] => [\n\t...tools.map(\n\t\t(t): MentionItem => ({\n\t\t\tid: t.tool_id,\n\t\t\tlabel: `${toolSourceLabel(t.source, appLabel)} : ${t.display_name}`,\n\t\t\tmeta: {\n\t\t\t\tkind: 'tool',\n\t\t\t\tplainLabel: t.display_name,\n\t\t\t\tsource: t.source,\n\t\t\t},\n\t\t}),\n\t),\n\t...subAgents.map(\n\t\t(s): MentionItem => ({\n\t\t\tid: s.id,\n\t\t\tlabel: `sub-agent: ${s.name}`,\n\t\t\tmeta: { kind: 'subagent', plainLabel: s.name },\n\t\t}),\n\t),\n];\n\nconst escapeHtml = (raw: string): string =>\n\traw.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n\nconst escapeAttr = (raw: string): string =>\n\tescapeHtml(raw).replace(/\"/g, '&quot;');\n\n/**\n * The HTML for a single mention chip. Must round-trip through the TipTap mention\n * extension's `parseHTML` (`span[data-type=\"mentionAgent\"]`, reading\n * `data-id`/`data-label`/`data-kind`) — see MentionExtension.ts. `normalizeHtml`\n * is taught to keep `data-type=\"mention…\"` spans so this survives to the parser.\n */\nconst mentionSpanHtml = (id: string, label: string, kind: string): string =>\n\t`<span data-type=\"mentionAgent\" class=\"bik-mention bik-mention--agent\"` +\n\t` data-id=\"${escapeAttr(id)}\" data-label=\"${escapeAttr(label)}\"` +\n\t` data-kind=\"${escapeAttr(kind)}\">${escapeHtml(label)}</span>`;\n\n/**\n * Public: HTML for one mention chip, for inserting at the cursor (e.g. when a\n * tool / sub-agent is added from the Step-3 side panel). Round-trips through the\n * same parser path as the rehydrated chips.\n */\nexport const buildMentionHtml = (\n\tid: string,\n\tlabel: string,\n\tkind: 'tool' | 'subagent',\n): string => mentionSpanHtml(id, label, kind);\n\n/** `{{tool:<id>}}` / `{{subagent:<id>}}` → the mention item that produced them. */\nconst buildTokenLookup = (\n\tmentionItems: MentionItem[],\n): Map<string, MentionItem> => {\n\tconst byToken = new Map<string, MentionItem>();\n\tfor (const item of mentionItems) {\n\t\tconst meta = item.meta as unknown as MentionKindMeta | undefined;\n\t\t// Both tools and sub-agents are keyed by their id (a tool's id is its tool_id).\n\t\tif (meta?.kind === 'tool') {\n\t\t\tbyToken.set(`tool:${String(item.id)}`, item);\n\t\t} else if (meta?.kind === 'subagent') {\n\t\t\tbyToken.set(`subagent:${String(item.id)}`, item);\n\t\t}\n\t}\n\treturn byToken;\n};\n\n// Matches the reference tokens we render as chips. Other `{{var}}` tokens fall\n// through untouched (left as literal text for the variable decoration).\nconst REFERENCE_TOKEN = /\\{\\{(tool:[^}]+|subagent:[^}]+)\\}\\}/g;\n\n/** Escape plain text, swapping recognised reference tokens for mention spans. */\nconst inlineToHtml = (\n\tsegment: string,\n\tbyToken: Map<string, MentionItem>,\n): string => {\n\tlet out = '';\n\tlet lastIndex = 0;\n\tREFERENCE_TOKEN.lastIndex = 0;\n\tlet match: RegExpExecArray | null;\n\twhile ((match = REFERENCE_TOKEN.exec(segment)) !== null) {\n\t\tout += escapeHtml(segment.slice(lastIndex, match.index));\n\t\tconst item = byToken.get(match[1]);\n\t\tif (item) {\n\t\t\tconst kind = (item.meta as unknown as MentionKindMeta).kind;\n\t\t\tout += mentionSpanHtml(String(item.id), item.label, kind);\n\t\t} else {\n\t\t\t// Tool/sub-agent no longer in the available list → keep the raw token.\n\t\t\tout += escapeHtml(match[0]);\n\t\t}\n\t\tlastIndex = REFERENCE_TOKEN.lastIndex;\n\t}\n\tout += escapeHtml(segment.slice(lastIndex));\n\treturn out.replace(/\\n/g, '<br>');\n};\n\n/**\n * Convert the stored instructions string into HTML for `BikEditor.initialContent`.\n * `{{tool:KEY}}` / `{{subagent:ID}}` tokens are rehydrated into mention chips\n * (resolved via `mentionItems`); any other `{{…}}` token is left as literal text\n * for the editor's variable decoration. Newlines become paragraph / line breaks.\n */\nexport const instructionsToEditorHtml = (\n\ttext: string,\n\tmentionItems: MentionItem[] = [],\n): string => {\n\tif (!text) {\n\t\treturn '';\n\t}\n\tconst byToken = buildTokenLookup(mentionItems);\n\treturn text\n\t\t.split(/\\n{2,}/)\n\t\t.map((para) => `<p>${inlineToHtml(para, byToken)}</p>`)\n\t\t.join('');\n};\n\ninterface ProseMirrorNode {\n\ttype: string;\n\ttext?: string;\n\tattrs?: Record<string, unknown>;\n\tcontent?: ProseMirrorNode[];\n}\n\n/**\n * The token for a mention node. Both tools and sub-agents store their id in the\n * node, so the token value is just that id — the kind only picks the prefix. The\n * node's `kind` attr is authoritative; `toolIds` is a fallback for older content\n * saved before the kind attr existed.\n */\nconst resolveMentionToken = (\n\tid: string,\n\tkind: string | null,\n\ttoolIds: Set<string>,\n): string => {\n\tconst resolved = kind ?? (toolIds.has(id) ? 'tool' : 'subagent');\n\treturn resolved === 'tool' ? `{{tool:${id}}}` : `{{subagent:${id}}}`;\n};\n\nconst nodeToText = (node: ProseMirrorNode, toolIds: Set<string>): string => {\n\tswitch (node.type) {\n\t\tcase 'text':\n\t\t\treturn node.text ?? '';\n\t\tcase 'mentionAgent':\n\t\tcase 'mentionTeam': {\n\t\t\tconst id = node.attrs?.['id'];\n\t\t\tif (id == null) {\n\t\t\t\treturn '';\n\t\t\t}\n\t\t\tconst kind = node.attrs?.['kind'];\n\t\t\treturn resolveMentionToken(\n\t\t\t\tString(id),\n\t\t\t\tkind == null ? null : String(kind),\n\t\t\t\ttoolIds,\n\t\t\t);\n\t\t}\n\t\tcase 'variable':\n\t\t\treturn `{{${String(node.attrs?.['variableName'] ?? '')}}}`;\n\t\tcase 'hardBreak':\n\t\t\treturn '\\n';\n\t\tdefault: {\n\t\t\tconst inner = (node.content ?? [])\n\t\t\t\t.map((child) => nodeToText(child, toolIds))\n\t\t\t\t.join('');\n\t\t\t// Block nodes terminate with a newline so paragraphs stay separated.\n\t\t\tconst BLOCK_NODES = ['paragraph', 'heading', 'listItem', 'blockquote'];\n\t\t\treturn BLOCK_NODES.includes(node.type) ? `${inner}\\n` : inner;\n\t\t}\n\t}\n};\n\n/**\n * Convert a BikEditor document (from `ref.getJSON()`) into the firebase\n * instructions string, replacing mention nodes with `{{subagent:<id>}}` /\n * `{{tool:<tool_id>}}` tokens.\n */\nexport const editorDocToInstructions = (\n\tdoc: Record<string, unknown> | null,\n\ttools: AgentTool[],\n): string => {\n\tif (!doc) {\n\t\treturn '';\n\t}\n\tconst toolIds = new Set(tools.map((t) => t.tool_id));\n\treturn nodeToText(doc as unknown as ProseMirrorNode, toolIds).replace(\n\t\t/\\n+$/,\n\t\t'',\n\t);\n};\n"],"names":["TOOL_SOURCE_LABELS","toolSourceLabel","source","fallback","appTypeLabel","applicationType","key","buildAgentMentionItems","tools","subAgents","appLabel","t","s","escapeHtml","raw","escapeAttr","mentionSpanHtml","id","label","kind","buildMentionHtml","buildTokenLookup","mentionItems","byToken","item","meta","REFERENCE_TOKEN","inlineToHtml","segment","out","lastIndex","match","instructionsToEditorHtml","text","para","resolveMentionToken","toolIds","nodeToText","node","inner","child","editorDocToInstructions","doc"],"mappings":"gFA6BO,MAAMA,EAA6C,CACzD,SAAU,WACV,QAAS,UACT,YAAa,aACd,EAGaC,EAAkB,CAC9BC,EACAC,EAAW,aAEND,EAGEF,EAAmBE,CAAM,GAAKA,EAF7BC,EAMIC,EAAgBC,GAA8C,CAC1E,MAAMC,EAAMD,EAAkB,OAAOA,CAAe,EAAI,GACxD,OAAIC,IAAQ,MACJ,MAEJA,IAAQ,MACJ,MAED,UACR,EAUaC,EAAyB,CACrCC,EACAC,EACAC,EAAW,aACQ,CACnB,GAAGF,EAAM,IACPG,IAAoB,CACpB,GAAIA,EAAE,QACN,MAAO,GAAGV,EAAgBU,EAAE,OAAQD,CAAQ,CAAC,MAAMC,EAAE,YAAY,GACjE,KAAM,CACL,KAAM,OACN,WAAYA,EAAE,aACd,OAAQA,EAAE,MAAA,CACX,EACD,EAED,GAAGF,EAAU,IACXG,IAAoB,CACpB,GAAIA,EAAE,GACN,MAAO,cAAcA,EAAE,IAAI,GAC3B,KAAM,CAAE,KAAM,WAAY,WAAYA,EAAE,IAAA,CAAK,EAC9C,CAEF,EAEMC,EAAcC,GACnBA,EAAI,QAAQ,KAAM,OAAO,EAAE,QAAQ,KAAM,MAAM,EAAE,QAAQ,KAAM,MAAM,EAEhEC,EAAcD,GACnBD,EAAWC,CAAG,EAAE,QAAQ,KAAM,QAAQ,EAQjCE,EAAkB,CAACC,EAAYC,EAAeC,IACnD,kFACaJ,EAAWE,CAAE,CAAC,iBAAiBF,EAAWG,CAAK,CAAC,gBAC9CH,EAAWI,CAAI,CAAC,KAAKN,EAAWK,CAAK,CAAC,UAOzCE,EAAmB,CAC/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UA,CAAE,KAAO,cAAcA,CAAE,KAG3DoB,EAAa,CAACC,EAAuBF,IAAiC,CAC3E,OAAQE,EAAK,KAAA,CACZ,IAAK,OACJ,OAAOA,EAAK,MAAQ,GACrB,IAAK,eACL,IAAK,cAAe,CACnB,MAAMrB,EAAKqB,EAAK,OAAQ,GACxB,GAAIrB,GAAM,KACT,MAAO,GAER,MAAME,EAAOmB,EAAK,OAAQ,KAC1B,OAAOH,EACN,OAAOlB,CAAE,EACTE,GAAQ,KAAO,KAAO,OAAOA,CAAI,EACjCiB,CAAA,CAEF,CACA,IAAK,WACJ,MAAO,KAAK,OAAOE,EAAK,OAAQ,cAAmB,EAAE,CAAC,KACvD,IAAK,YACJ,MAAO;AAAA,EACR,QAAS,CACR,MAAMC,GAASD,EAAK,SAAW,CAAA,GAC7B,IAAKE,GAAUH,EAAWG,EAAOJ,CAAO,CAAC,EACzC,KAAK,EAAE,EAGT,MADoB,CAAC,YAAa,UAAW,WAAY,YAAY,EAClD,SAASE,EAAK,IAAI,EAAI,GAAGC,CAAK;AAAA,EAAOA,CACzD,CAAA,CAEF,EAOaE,EAA0B,CACtCC,EACAlC,IACY,CACZ,GAAI,CAACkC,EACJ,MAAO,GAER,MAAMN,EAAU,IAAI,IAAI5B,EAAM,IAAKG,GAAMA,EAAE,OAAO,CAAC,EACnD,OAAO0B,EAAWK,EAAmCN,CAAO,EAAE,QAC7D,OACA,EAAA,CAEF"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react/jsx-runtime"),te=require("../node_modules/@tiptap/core/dist/index.js"),j=require("@tiptap/react"),c=require("react"),ne=require("./BikEditor.styles.js"),U=require("./BikEditor.types.js"),s=require("./BikEditor.utils.js"),oe=require("./extensions/buildExtensions.js"),re=require("./floating/LinkBubbleMenu.js");function se(g){return Object.entries(g).map(([h,f])=>`${h.replace(/([A-Z])/g,m=>`-${m.toLowerCase()}`)}:${f}`).join(";")}const ie=(g,h)=>{const{initialContent:f,sections:m,features:k,disabled:N,maxCharacters:y,shortcuts:W,sendShortcut:$,mentions:l,slashCommands:d,link:J,onPaste:Q,onReady:R,onChange:x,onSend:p,onFocus:B,onBlur:b,onSelectionChange:A,minHeight:V,maxHeight:Z,style:G,className:K,editorClassName:E,editorStyle:z}=g,X=m?.length?s.buildSectionedContent(s.normalizeHtml(f??""),m.map(e=>({...e,content:s.normalizeHtml(e.content)}))):s.normalizeHtml(f??""),C=c.useRef([]),H=c.useRef(!1),T=c.useRef(R);T.current=R;const I=c.useRef(x);I.current=x;const v=c.useRef(A);v.current=A;const L=c.useRef(U.DEFAULT_FORMAT_STATE),F=c.useRef(B);F.current=B;const M=c.useRef(b);M.current=b;const q=c.useRef(p);q.current=p;const O=c.useRef(l?.agents??[]);O.current=l?.agents??[];const P=c.useRef(l?.teams??[]);P.current=l?.teams??[];const w=c.useRef(d?.items??[]);w.current=d?.items??[];const o=j.useEditor({extensions:oe.buildExtensions({features:k,placeholder:g.placeholder,maxCharacters:y,hasSections:(m?.length??0)>0,mentions:{agents:l?O:void 0,teams:l?P:void 0},slashCommands:d?w:void 0,onPaste:Q,onSend:p?e=>q.current?.(e):void 0,sendShortcut:$,shortcuts:W,onMentionSelected:l?.onSelect,onSlashCommandSelected:d?.onSelect,renderMentionItem:l?.renderItem,renderMentionDropdown:l?.renderDropdown,removeMentionTriggerOnDismiss:l?.removeTriggerOnDismiss,renderSlashCommandItem:d?.renderItem,renderSlashCommandDropdown:d?.renderDropdown}),content:X,editable:!N,immediatelyRender:!1,editorProps:{attributes:{...E?{class:E}:{},...z?{style:se(z)}:{}}},onUpdate:({editor:e})=>{I.current?.(s.extractContent(e))},onTransaction:({editor:e})=>{const t=s.extractActiveFormats(e),n=L.current;(n.bold!==t.bold||n.italic!==t.italic||n.underline!==t.underline||n.strike!==t.strike||n.bulletList!==t.bulletList||n.orderedList!==t.orderedList||n.blockquote!==t.blockquote||n.codeBlock!==t.codeBlock||n.superscript!==t.superscript||n.subscript!==t.subscript||n.textAlign!==t.textAlign||n.fontFamily!==t.fontFamily||n.fontSize!==t.fontSize||n.color!==t.color||n.highlight!==t.highlight||n.link?.href!==t.link?.href)&&(L.current=t,v.current?.(t))},onFocus:()=>F.current?.(),onBlur:()=>M.current?.()});function i(e){o?e(o):C.current.push(e)}return c.useEffect(()=>{o&&(C.current.length>0&&C.current.splice(0).forEach(t=>t(o)),H.current||(H.current=!0,T.current?.()))},[o]),c.useImperativeHandle(h,()=>({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(n=>n.commands.setContent(t,{emitUpdate:!0}))},insertContent:e=>{const t=s.normalizeHtml(e);i(n=>n.commands.insertContent(t))},insertInlineContent:e=>{i(t=>s.insertInlineHtml(t,e))},insertAtStart:e=>{const t=s.normalizeHtml(e);i(n=>n.commands.insertContentAt(1,t))},insertBlock:e=>{const t=s.normalizeHtml(e);i(n=>n.commands.insertContentAt(n.state.doc.content.size,t))},appendInline:e=>{const t=s.normalizeHtml(e);i(n=>n.commands.insertContentAt(n.state.doc.content.size-1,t))},insertAtEnd(e){this.insertBlock(e)},appendContent(e){this.appendInline(e)},getContent:()=>o?s.extractContent(o):{html:"",text:"",isEmpty:!0,characterCount:0},getJSON:()=>o?.getJSON()??null,getMentions:()=>{const e=new Set,t=new Set;return o?(o.state.doc.descendants(n=>{n.type.name==="mentionAgent"&&n.attrs.id!=null?e.add(String(n.attrs.id)):n.type.name==="mentionTeam"&&n.attrs.id!=null&&t.add(String(n.attrs.id))}),{agentIds:Array.from(e),teamIds:Array.from(t)}):{agentIds:[],teamIds:[]}},getCursorPosition:()=>{if(!o)return{from:0,to:0};const{from:e,to:t}=o.state.selection;return{from:e,to:t}},insertAtPosition:(e,t)=>{const n=s.normalizeHtml(t);i(r=>r.commands.insertContentAt(e,n))},getSelectedText:()=>{if(!o)return"";const{state:e}=o,{from:t,to:n,empty:r}=e.selection;if(!r)return e.doc.textBetween(t,n," ");const a=e.schema.marks.link;if(a){const u=te.getMarkRange(e.doc.resolve(t),a);if(u)return e.doc.textBetween(u.from,u.to," ")}return""},getCharacterCount:()=>({count:o?.storage.characterCount?.characters?.()??o?.getText().length??0,limit:y??null}),getSectionContent:e=>o?s.extractSectionContent(o,e):{html:"",text:"",isEmpty:!0,characterCount:0},setSectionContent:(e,t)=>{const n=s.normalizeHtml(t);i(r=>s.setSectionContentInEditor(r,e,n))},focusSection:e=>{i(t=>{if(e==="body"){let r=t.state.doc.content.size-1;t.state.doc.descendants((a,u)=>(a.type.name==="sectionDivider"&&r===t.state.doc.content.size-1&&(r=u-1),r===t.state.doc.content.size-1)),r<1&&(r=1),t.chain().focus().setTextSelection(r).run();return}let n=-1;t.state.doc.descendants((r,a)=>{if(n!==-1)return!1;r.type.name==="sectionDivider"&&r.attrs.sectionId===e&&(n=a+r.nodeSize+1)}),n!==-1&&t.chain().focus().setTextSelection(n).run()})},clearSection:e=>{i(t=>s.setSectionContentInEditor(t,e,"<p></p>"))},getBodyContent:()=>o?s.extractBodyContent(o):{html:"",text:"",isEmpty:!0,characterCount:0},setBodyContent:e=>{const t=s.normalizeHtml(e);i(n=>s.setSectionContentInEditor(n,"body",t))},setBodyAndSections:(e,t)=>{const n=s.buildSectionedContent(s.normalizeHtml(e),t.map(r=>({id:r.id,content:s.normalizeHtml(r.content)})));i(r=>r.commands.setContent(n,{emitUpdate:!0}))},appendBodyContent:e=>{const t=s.normalizeHtml(e);i(n=>{const r=s.findSectionEndPos(n,"body");n.commands.insertContentAt(r-1,t,{parseOptions:{preserveWhitespace:!0}})})},insertAtSectionStart:(e,t)=>{const n=s.normalizeHtml(t);i(r=>{const a=s.findSectionStartPos(r,e);a!==-1&&r.commands.insertContentAt(a,n,{parseOptions:{preserveWhitespace:!0}})})},insertAtSectionEnd:(e,t)=>{const n=s.normalizeHtml(t);i(r=>{const a=s.findSectionEndPos(r,e);r.commands.insertContentAt(a,n,{parseOptions:{preserveWhitespace:!0}})})},getActiveFormats:()=>o?s.extractActiveFormats(o):U.DEFAULT_FORMAT_STATE,actions:{toggleBold:()=>o?.chain().focus().toggleBold().run(),toggleItalic:()=>o?.chain().focus().toggleItalic().run(),toggleUnderline:()=>o?.chain().focus().toggleUnderline().run(),toggleStrike:()=>o?.chain().focus().toggleStrike().run(),toggleBulletList:()=>o?.chain().focus().toggleBulletList().run(),toggleOrderedList:()=>o?.chain().focus().toggleOrderedList().run(),toggleBlockquote:()=>o?.chain().focus().toggleBlockquote().run(),toggleCodeBlock:()=>o?.chain().focus().toggleCodeBlock().run(),setTextAlign:e=>o?.chain().focus().setTextAlign(e).run(),setFontFamily:e=>o?.chain().focus().setFontFamily(e).run(),setFontSize:e=>o?.chain().focus().setFontSize(e).run(),setColor:e=>o?.chain().focus().setColor(e).run(),setHighlight:e=>o?.chain().focus().toggleHighlight({color:e}).run(),unsetColor:()=>o?.chain().focus().unsetColor().run(),unsetHighlight:()=>o?.chain().focus().unsetHighlight().run(),setLink:(e,t)=>{o&&(t!==void 0?o.chain().focus().extendMarkRange("link").command(({tr:n,state:r})=>{const{from:a,to:u}=n.selection,D=r.schema.marks.link;if(!D)return!1;const Y=r.schema.text(t,[D.create({href:e})]),ee=r.schema.text(" ");return n.replaceWith(a,u,[Y,ee]),!0}).run():o.chain().focus().extendMarkRange("link").setLink({href:e}).insertContent(" ").run())},updateLink:e=>o?.chain().focus().extendMarkRange("link").setLink({href:e}).run(),removeLink:()=>o?.chain().focus().extendMarkRange("link").unsetLink().run(),insertEmoji:e=>o?.chain().focus().insertContent(e).run(),insertVariable:e=>o?.chain().focus().insertContent(`{{${e}}}`).run(),insertHtml:e=>o?.commands.insertContent(s.normalizeHtml(e)),undo:()=>o?.chain().focus().undo().run(),redo:()=>o?.chain().focus().redo().run(),canUndo:()=>o?.can().undo()??!1,canRedo:()=>o?.can().redo()??!1,toggleSuperscript:()=>o?.chain().focus().toggleSuperscript().run(),toggleSubscript:()=>o?.chain().focus().toggleSubscript().run(),insertImage:e=>o?.chain().focus().setImage({src:e}).run()}}),[o]),o?S.jsxs(ne.BikEditorShell,{minHeight:V,maxHeight:Z,tightParagraphs:!k?.richPaste,style:G,className:K,children:[S.jsx(j.EditorContent,{editor:o}),S.jsx(re.LinkBubbleMenu,{editor:o,renderLinkTooltip:J?.renderTooltip})]}):null},_=c.forwardRef(ie);_.displayName="BikEditor";exports.BikEditor=_;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),de=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"),me=require("./extensions/buildExtensions.js"),ge=require("./floating/LinkBubbleMenu.js"),fe=require("../icons/BIK AI specific/WandSparkles.js"),he=require("../icons/Actions/Formatting/Copy.js");function pe(C){return Object.entries(C).map(([S,h])=>`${S.replace(/([A-Z])/g,p=>`-${p.toLowerCase()}`)}:${h}`).join(";")}const Ce=(C,S)=>{const{initialContent:h,sections:p,features:k,disabled:G,maxCharacters:T,shortcuts:K,sendShortcut:X,mentions:u,slashCommands:f,link:Y,onPaste:ee,onReady:b,onChange:R,onSend:x,onFocus:v,onBlur:E,onSelectionChange:A,minHeight:te,maxHeight:ne,style:oe,className:se,editorClassName:z,editorStyle:H,renderJsonError:j}=C,m=!!k?.jsonMode,[d,J]=c.useState(null),[re,I]=c.useState(!1),ie=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:me.buildExtensions({features:k,placeholder:C.placeholder,maxCharacters:T,hasSections:(p?.length??0)>0,mentions:{agents:u?D:void 0,teams:u?U:void 0},slashCommands:f?_:void 0,onPaste:ee,onSend:x?e=>w.current?.(e):void 0,sendShortcut:X,shortcuts:K,onMentionSelected:u?.onSelect,onSlashCommandSelected:f?.onSelect,renderMentionItem:u?.renderItem,renderMentionDropdown:u?.renderDropdown,removeMentionTriggerOnDismiss:u?.removeTriggerOnDismiss,renderSlashCommandItem:f?.renderItem,renderSlashCommandDropdown:f?.renderDropdown}),content:ie,editable:!G,immediatelyRender:!1,editorProps:{attributes:{...z?{class:z}:{},...H?{style:pe(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=de.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 le=r.schema.text(t,[W.create({href:e})]),ue=r.schema.text(" ");return o.replaceWith(l,g,[le,ue]),!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 ce=()=>{if(!n)return;const{valid:e,value:t}=s.parseJson(s.getCodeBlockText(n));!e||t===null||s.setCodeBlockText(n,JSON.stringify(t,null,2))},ae=()=>{n&&(navigator.clipboard?.writeText(s.getCodeBlockText(n)),I(!0),setTimeout(()=>I(!1),1500))};return n?a.jsxs(B.BikEditorShell,{minHeight:te,maxHeight:ne,tightParagraphs:!k?.richPaste,jsonMode:m,style:oe,className:se,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:ce,disabled:!!d,title:"Format JSON",children:[a.jsx(fe.default,{size:16}),a.jsx(V.BodyCaption,{children:"Beautify"})]}),a.jsxs("button",{type:"button",onClick:ae,title:"Copy JSON",children:[a.jsx(he.default,{size:16}),re&&a.jsx(V.BodyCaption,{children:"Copied"})]})]})]}),a.jsx($.EditorContent,{editor:n}),a.jsx(ge.LinkBubbleMenu,{editor:n,renderLinkTooltip:Y?.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(Ce);Z.displayName="BikEditor";exports.BikEditor=Z;
2
2
  //# sourceMappingURL=BikEditor.js.map