@e-llm-studio/citation 0.0.250 → 0.0.251

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Internaleditor.js","sources":["../../../src/features/SPBAnalysisPanel/Internaleditor.tsx"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { Box } from \"@mui/material\";\nimport Editor, { OnMount, Monaco } from \"@monaco-editor/react\";\nimport type * as monaco from \"monaco-editor\";\n\n// ─── NOTE ────────────────────────────────────────────────────────────────────\n// Extracted verbatim from PromptemonViewer.tsx's local `InternalEditor` so it can\n// be shared between PromptemonViewer (FPB) and SPBAnalysisPanel (SPB) without\n// duplicating the Monaco tokenizer/theme/highlight logic. If you already have\n// InternalEditor living inline in PromptemonViewer.tsx, delete that local copy\n// and import from here instead — the props are unchanged.\n\nconst DARK_THEME = {\n base: \"vs-dark\" as const,\n inherit: true,\n rules: [\n { token: \"tag\", foreground: \"714be3\", fontStyle: \"bold\" },\n { token: \"attribute.name\", foreground: \"87CEFA\" },\n { token: \"attribute.value\", foreground: \"98FB98\" },\n { token: \"variable\", foreground: \"00FFFF\" },\n { token: \"delimiter\", foreground: \"888888\" },\n { token: \"white\", foreground: \"AAAAAA\" },\n ],\n colors: {\n \"editor.foreground\": \"#FFFFFF\",\n \"editor.background\": \"#030202\",\n \"editorLineNumber.foreground\": \"#858585\",\n \"editorCursor.foreground\": \"#FFFFFF\",\n \"editorIndentGuide.background\": \"#404040\",\n \"editorIndentGuide.activeBackground\": \"#707070\",\n },\n};\n\nconst LIGHT_THEME = {\n base: \"vs\" as const,\n inherit: true,\n rules: [\n { token: \"tag\", foreground: \"5928ED\", fontStyle: \"bold\" },\n { token: \"attribute.name\", foreground: \"AF00DB\" },\n { token: \"attribute.value\", foreground: \"008000\" },\n { token: \"variable\", foreground: \"B000B0\" },\n { token: \"delimiter\", foreground: \"808080\" },\n { token: \"white\", foreground: \"000000\" },\n ],\n colors: {\n \"editor.foreground\": \"#000000\",\n \"editor.background\": \"#FFFFFF\",\n \"editorLineNumber.foreground\": \"#999999\",\n \"editorCursor.foreground\": \"#000000\",\n \"editorIndentGuide.background\": \"#CCCCCC\",\n \"editorIndentGuide.activeBackground\": \"#999999\",\n },\n};\n\nexport interface InternalEditorProps {\n content: string;\n selectedTag?: string;\n highlightVariable?: string;\n isDarkMode: boolean;\n height?: number | string;\n fontSize?: number;\n}\n\nexport const InternalEditor = ({\n content,\n selectedTag,\n highlightVariable,\n isDarkMode,\n height = 250,\n fontSize = 12,\n}: InternalEditorProps) => {\n const editorRef = useRef<monaco.editor.IStandaloneCodeEditor>();\n const monacoRef = useRef<Monaco>();\n const decorationIdsRef = useRef<string[]>([]);\n\n const handleBeforeMount = (monacoInstance: Monaco) => {\n // @ts-ignore\n monacoInstance.editor.defineTheme(\"promptemonViewerDark\", DARK_THEME);\n // @ts-ignore\n monacoInstance.editor.defineTheme(\"promptemonViewerLight\", LIGHT_THEME);\n monacoInstance.editor.setTheme(isDarkMode ? \"promptemonViewerDark\" : \"promptemonViewerLight\");\n };\n\n const handleEditorMount: OnMount = (editor, monacoInstance) => {\n editorRef.current = editor;\n monacoRef.current = monacoInstance;\n\n // @ts-ignore\n monacoInstance.editor.defineTheme(\"promptemonViewerDark\", DARK_THEME);\n // @ts-ignore\n monacoInstance.editor.defineTheme(\"promptemonViewerLight\", LIGHT_THEME);\n monacoInstance.editor.setTheme(isDarkMode ? \"promptemonViewerDark\" : \"promptemonViewerLight\");\n\n monacoInstance.languages.register({ id: \"promptemonViewerLang\" });\n monacoInstance.languages.setMonarchTokensProvider(\"promptemonViewerLang\", {\n tokenizer: {\n root: [\n [/(<)([a-zA-Z0-9\\-]+)(\\s*)/, [\"delimiter\", \"tag\", \"white\"], \"@tagBody\"],\n [/(<\\/)([a-zA-Z0-9\\-]+)(\\s*)(>)/, [\"delimiter\", \"tag\", \"white\", \"delimiter\"]],\n [/{{[^}]+}}/, \"variable\"],\n ],\n tagBody: [\n [/[a-zA-Z0-9\\:\\-]+(?=\\=)/, \"attribute.name\"],\n [/=/, \"delimiter\"],\n [/(\".*?\"|'.*?')/, \"attribute.value\"],\n [/\\s+/, \"white\"],\n [/(\\/?>)/, { token: \"delimiter\", next: \"@pop\" }],\n ],\n },\n });\n\n monacoInstance.languages.registerFoldingRangeProvider(\"promptemonViewerLang\", {\n provideFoldingRanges: (model) => {\n const lines = model.getLinesContent();\n const foldingRanges: any[] = [];\n const stack: { tag: string; start: number }[] = [];\n lines.forEach((line, index) => {\n const lineNumber = index + 1;\n const openTagMatch = line.match(/<([a-zA-Z0-9\\-]+)(\\s[^>]*)?>/);\n const closeTagMatch = line.match(/<\\/([a-zA-Z0-9\\-]+)>/);\n if (openTagMatch && !line.includes(\"/>\")) {\n stack.push({ tag: openTagMatch[1], start: lineNumber });\n }\n if (closeTagMatch) {\n const tag = closeTagMatch[1];\n for (let i = stack.length - 1; i >= 0; i--) {\n if (stack[i].tag === tag) {\n foldingRanges.push({ start: stack[i].start, end: lineNumber });\n stack.splice(i, 1);\n break;\n }\n }\n }\n });\n return foldingRanges;\n },\n });\n };\n\n useEffect(() => {\n if (!selectedTag || !editorRef.current || !monacoRef.current) return;\n const editor = editorRef.current;\n const model = editor.getModel();\n if (!model) return;\n const lines = model.getValue().split(\"\\n\");\n let targetLine = -1;\n for (let i = 0; i < lines.length; i++) {\n const tagMatch = lines[i].match(/<([^\\s>\\/]+(?:\\s[^\\s>\\/]+)*)/);\n if (tagMatch && tagMatch[1].trim().toLowerCase() === selectedTag.toLowerCase()) {\n targetLine = i + 1;\n break;\n }\n }\n if (targetLine > 0) {\n let closingLine = targetLine;\n const closingTagLower = `</${selectedTag.toLowerCase()}>`;\n for (let i = targetLine; i < lines.length; i++) {\n if (lines[i].toLowerCase().includes(closingTagLower)) {\n closingLine = i + 1;\n break;\n }\n }\n editor.setSelection(new monacoRef.current.Selection(targetLine, 1, targetLine, 1));\n editor.trigger(null, \"editor.unfold\", {});\n editor.revealLineInCenterIfOutsideViewport(targetLine);\n const decorations = editor.deltaDecorations([], [{\n range: new monacoRef.current.Range(targetLine, 1, closingLine, lines[closingLine - 1].length + 1),\n options: { isWholeLine: true, className: \"promptemon-viewer-highlight\", inlineClassName: \"promptemon-viewer-highlight\" },\n }]);\n setTimeout(() => editor.deltaDecorations(decorations, []), 2000);\n }\n }, [selectedTag,content]);\n\n useEffect(() => {\n if (!highlightVariable || !editorRef.current || !monacoRef.current) {\n return;\n }\n\n const editor = editorRef.current;\n const model = editor.getModel();\n\n if (!model) return;\n\n const content = model.getValue();\n\n const normalize = (value: string) =>\n value\n .replace(/\\r\\n/g, \"\\n\")\n .replace(/\\\\([<>])/g, \"$1\")\n .replace(/\\*\\*/g, \"\")\n .replace(/\\s+/g, \" \")\n .trim()\n .toLowerCase();\n\n const target = normalize(highlightVariable);\n\n if (!target) return;\n\n const ranges: monaco.Range[] = [];\n\n // --------------------------------------------------\n // 1. Exact match\n // --------------------------------------------------\n\n const exactIndex = content.indexOf(highlightVariable);\n\n if (exactIndex !== -1) {\n const before = content.slice(0, exactIndex);\n\n const startLine = before.split(\"\\n\").length;\n const startColumn =\n before.lastIndexOf(\"\\n\") === -1\n ? exactIndex + 1\n : exactIndex - before.lastIndexOf(\"\\n\");\n\n const matchedText = highlightVariable;\n const matchLines = matchedText.split(\"\\n\");\n\n const endLine = startLine + matchLines.length - 1;\n\n const endColumn =\n matchLines.length === 1\n ? startColumn + matchedText.length\n : matchLines[matchLines.length - 1].length + 1;\n\n ranges.push(\n new monacoRef.current.Range(\n startLine,\n startColumn,\n endLine,\n endColumn\n )\n );\n }\n\n // --------------------------------------------------\n // 2. Normalized multiline match\n // --------------------------------------------------\n\n if (ranges.length === 0) {\n const normalizedContent = normalize(content);\n\n const normalizedIndex = normalizedContent.indexOf(target);\n\n if (normalizedIndex !== -1) {\n const lines = content.split(\"\\n\");\n\n let accumulated = 0;\n\n for (let i = 0; i < lines.length; i++) {\n const normalizedLine = normalize(lines[i]);\n\n if (!normalizedLine) {\n accumulated += 1;\n continue;\n }\n\n const lineStart = accumulated;\n const lineEnd =\n accumulated + normalizedLine.length;\n\n if (\n normalizedIndex < lineEnd &&\n normalizedIndex + target.length > lineStart\n ) {\n ranges.push(\n new monacoRef.current.Range(\n i + 1,\n 1,\n i + 1,\n lines[i].length + 1\n )\n );\n\n break;\n }\n\n accumulated += normalizedLine.length + 1;\n }\n }\n }\n\n // --------------------------------------------------\n // 3. Safe string fallback\n // --------------------------------------------------\n\n if (ranges.length === 0) {\n const targetLines = highlightVariable\n .split(\"\\n\")\n .map((line) => normalize(line))\n .filter((line) => line.length > 10);\n\n let bestMatch = {\n line: -1,\n score: 0,\n };\n\n const lines = content.split(\"\\n\");\n\n lines.forEach((line, index) => {\n const normalizedLine = normalize(line);\n\n if (!normalizedLine) return;\n\n let score = 0;\n\n targetLines.forEach((targetLine) => {\n if (normalizedLine.includes(targetLine)) {\n score = Math.max(\n score,\n targetLine.length / normalizedLine.length\n );\n }\n });\n\n if (score > bestMatch.score) {\n bestMatch = {\n line: index,\n score,\n };\n }\n });\n\n // Only accept a reasonably strong match.\n if (bestMatch.score >= 0.5) {\n const line = lines[bestMatch.line];\n\n ranges.push(\n new monacoRef.current.Range(\n bestMatch.line + 1,\n 1,\n bestMatch.line + 1,\n line.length + 1\n )\n );\n }\n }\n\n // --------------------------------------------------\n // No reliable match\n // --------------------------------------------------\n\n if (ranges.length === 0) {\n return;\n }\n\n editor.revealLineInCenterIfOutsideViewport(\n ranges[0].startLineNumber\n );\n\n decorationIdsRef.current = editor.deltaDecorations(\n decorationIdsRef.current,\n ranges.map((range) => ({\n range,\n options: {\n inlineClassName: \"promptemon-viewer-variable-highlight\",\n },\n }))\n );\n\n const timeout = setTimeout(() => {\n if (editorRef.current) {\n decorationIdsRef.current = editorRef.current.deltaDecorations(\n decorationIdsRef.current,\n []\n );\n }\n }, 2000);\n\n return () => clearTimeout(timeout);\n }, [highlightVariable, content]);\n\n useEffect(() => {\n if (!monacoRef.current) return;\n monacoRef.current.editor.setTheme(isDarkMode ? \"promptemonViewerDark\" : \"promptemonViewerLight\");\n }, [isDarkMode]);\n\n return (\n <>\n <style>{`\n .promptemon-viewer-highlight { background-color: rgba(89, 40, 237, 0.15); }\n .promptemon-viewer-variable-highlight { background-color: rgba(0, 255, 255, 0.2); border-radius: 2px; }\n `}</style>\n <Box sx={{ width: \"100%\", height, display: \"flex\", flexDirection: \"column\" }}>\n <Box sx={{ width: \"100%\", height: 20, bgcolor: isDarkMode ? \"#030202\" : \"#fff\", borderTopLeftRadius: 8, borderTopRightRadius: 8 }} />\n <Box sx={{ flex: 1, minHeight: 0, overflow: \"hidden\" }}>\n <Editor\n onMount={handleEditorMount}\n beforeMount={handleBeforeMount}\n theme={isDarkMode ? \"promptemonViewerDark\" : \"promptemonViewerLight\"}\n value={content}\n language=\"promptemonViewerLang\"\n onChange={() => {}}\n options={{\n fontSize,\n minimap: { enabled: false },\n wordWrap: \"on\",\n lineNumbers: \"on\",\n readOnly: true,\n domReadOnly: true,\n scrollBeyondLastLine: false,\n padding: { top: 4, bottom: 12 },\n folding: true,\n automaticLayout: true,\n scrollbar: { vertical: \"visible\", horizontal: \"visible\", verticalScrollbarSize: 8 },\n }}\n />\n </Box>\n <Box sx={{ width: \"100%\", height: 20, bgcolor: isDarkMode ? \"#030202\" : \"#fff\", borderBottomLeftRadius: 8, borderBottomRightRadius: 8 }} />\n </Box>\n </>\n );\n};\n\nexport default InternalEditor;"],"names":["DARK_THEME","base","inherit","rules","token","foreground","fontStyle","colors","LIGHT_THEME","InternalEditor","content","selectedTag","highlightVariable","isDarkMode","height","fontSize","editorRef","useRef","monacoRef","decorationIdsRef","useEffect","current","editor","model","getModel","lines","getValue","split","targetLine","i","length","tagMatch","match","trim","toLowerCase","closingLine","closingTagLower","includes","setSelection","Selection","trigger","revealLineInCenterIfOutsideViewport","decorations","deltaDecorations","range","Range","options","isWholeLine","className","inlineClassName","setTimeout","normalize","value","replace","target","ranges","exactIndex","indexOf","before","slice","startLine","startColumn","lastIndexOf","matchedText","matchLines","endLine","endColumn","push","normalizedIndex","accumulated","normalizedLine","lineStart","targetLines","map","line","filter","bestMatch","score","forEach","index","Math","max","startLineNumber","timeout","clearTimeout","setTheme","jsxs","Fragment","children","jsx","Box","sx","width","display","flexDirection","bgcolor","borderTopLeftRadius","borderTopRightRadius","flex","minHeight","overflow","Editor","onMount","monacoInstance","defineTheme","languages","register","id","setMonarchTokensProvider","tokenizer","root","tagBody","next","registerFoldingRangeProvider","provideFoldingRanges","getLinesContent","foldingRanges","stack","lineNumber","openTagMatch","closeTagMatch","tag","start","end","splice","beforeMount","theme","language","onChange","minimap","enabled","wordWrap","lineNumbers","readOnly","domReadOnly","scrollBeyondLastLine","padding","top","bottom","folding","automaticLayout","scrollbar","vertical","horizontal","verticalScrollbarSize","borderBottomLeftRadius","borderBottomRightRadius"],"mappings":"sLAYA,MAAMA,EAAa,CACfC,KAAM,UACNC,SAAS,EACTC,MAAO,CACH,CAAEC,MAAO,MAAOC,WAAY,SAAUC,UAAW,QACjD,CAAEF,MAAO,iBAAkBC,WAAY,UACvC,CAAED,MAAO,kBAAmBC,WAAY,UACxC,CAAED,MAAO,WAAYC,WAAY,UACjC,CAAED,MAAO,YAAaC,WAAY,UAClC,CAAED,MAAO,QAASC,WAAY,WAElCE,OAAQ,CACJ,oBAAqB,UACrB,oBAAqB,UACrB,8BAA+B,UAC/B,0BAA2B,UAC3B,+BAAgC,UAChC,qCAAsC,YAIxCC,EAAc,CAChBP,KAAM,KACNC,SAAS,EACTC,MAAO,CACH,CAAEC,MAAO,MAAOC,WAAY,SAAUC,UAAW,QACjD,CAAEF,MAAO,iBAAkBC,WAAY,UACvC,CAAED,MAAO,kBAAmBC,WAAY,UACxC,CAAED,MAAO,WAAYC,WAAY,UACjC,CAAED,MAAO,YAAaC,WAAY,UAClC,CAAED,MAAO,QAASC,WAAY,WAElCE,OAAQ,CACJ,oBAAqB,UACrB,oBAAqB,UACrB,8BAA+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CAC1BwF,EAAgB9C,EAAK1C,MAAM,wBAIjC,GAHIuF,IAAiB7C,EAAKrC,SAAS,OACzBgF,EAAAlD,KAAK,CAAEsD,IAAKF,EAAa,GAAIG,MAAOJ,IAE1CE,EAAe,CACT,MAAAC,EAAMD,EAAc,GAC1B,IAAA,IAAS3F,EAAIwF,EAAMvF,OAAS,EAAGD,GAAK,EAAGA,IACnC,GAAIwF,EAAMxF,GAAG4F,MAAQA,EAAK,CACRL,EAAAjD,KAAK,CAAEuD,MAAOL,EAAMxF,GAAG6F,MAAOC,IAAKL,IAC3CD,EAAAO,OAAO/F,EAAG,GAChB,KACJ,CAER,IAEGuF,MA8PCS,YAzTOtB,IAERA,EAAAjF,OAAOkF,YAAY,uBAAwBxG,GAE3CuG,EAAAjF,OAAOkF,YAAY,wBAAyBhG,GAC3D+F,EAAejF,OAAO+D,SAASxE,EAAa,uBAAyB,0BAqTrDiH,MAAOjH,EAAa,uBAAyB,wBAC7CuC,MAAO1C,EACPqH,SAAS,uBACTC,SAAU,OACVlF,QAAS,CACL/B,WACAkH,QAAS,CAAEC,SAAS,GACpBC,SAAU,KACVC,YAAa,KACbC,UAAU,EACVC,aAAa,EACbC,sBAAsB,EACtBC,QAAS,CAAEC,IAAK,EAAGC,OAAQ,IAC3BC,SAAS,EACTC,iBAAiB,EACjBC,UAAW,CAAEC,SAAU,UAAWC,WAAY,UAAWC,sBAAuB,UAI3FtD,EAAI,CAAAC,GAAI,CAAEC,MAAO,OAAQ9E,OAAQ,GAAIiF,QAASlF,EAAa,UAAY,OAAQoI,uBAAwB,EAAGC,wBAAyB"}
1
+ {"version":3,"file":"Internaleditor.js","sources":["../../../src/features/SPBAnalysisPanel/Internaleditor.tsx"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { Box } from \"@mui/material\";\nimport Editor, { OnMount, Monaco } from \"@monaco-editor/react\";\nimport type * as monaco from \"monaco-editor\";\nimport { buildNormalizedMap } from '../../utils/helper'\n\n// ─── NOTE ────────────────────────────────────────────────────────────────────\n// Extracted verbatim from PromptemonViewer.tsx's local `InternalEditor` so it can\n// be shared between PromptemonViewer (FPB) and SPBAnalysisPanel (SPB) without\n// duplicating the Monaco tokenizer/theme/highlight logic. If you already have\n// InternalEditor living inline in PromptemonViewer.tsx, delete that local copy\n// and import from here instead — the props are unchanged.\n\nconst DARK_THEME = {\n base: \"vs-dark\" as const,\n inherit: true,\n rules: [\n { token: \"tag\", foreground: \"714be3\", fontStyle: \"bold\" },\n { token: \"attribute.name\", foreground: \"87CEFA\" },\n { token: \"attribute.value\", foreground: \"98FB98\" },\n { token: \"variable\", foreground: \"00FFFF\" },\n { token: \"delimiter\", foreground: \"888888\" },\n { token: \"white\", foreground: \"AAAAAA\" },\n ],\n colors: {\n \"editor.foreground\": \"#FFFFFF\",\n \"editor.background\": \"#030202\",\n \"editorLineNumber.foreground\": \"#858585\",\n \"editorCursor.foreground\": \"#FFFFFF\",\n \"editorIndentGuide.background\": \"#404040\",\n \"editorIndentGuide.activeBackground\": \"#707070\",\n },\n};\n\nconst LIGHT_THEME = {\n base: \"vs\" as const,\n inherit: true,\n rules: [\n { token: \"tag\", foreground: \"5928ED\", fontStyle: \"bold\" },\n { token: \"attribute.name\", foreground: \"AF00DB\" },\n { token: \"attribute.value\", foreground: \"008000\" },\n { token: \"variable\", foreground: \"B000B0\" },\n { token: \"delimiter\", foreground: \"808080\" },\n { token: \"white\", foreground: \"000000\" },\n ],\n colors: {\n \"editor.foreground\": \"#000000\",\n \"editor.background\": \"#FFFFFF\",\n \"editorLineNumber.foreground\": \"#999999\",\n \"editorCursor.foreground\": \"#000000\",\n \"editorIndentGuide.background\": \"#CCCCCC\",\n \"editorIndentGuide.activeBackground\": \"#999999\",\n },\n};\n\nexport interface InternalEditorProps {\n content: string;\n selectedTag?: string;\n highlightVariable?: string | string[]; // CHANGED: now accepts array of segments\n highlightNonce?: number;\n\n isDarkMode: boolean;\n height?: number | string;\n fontSize?: number;\n}\n\nexport const InternalEditor = ({\n content,\n selectedTag,\n highlightVariable,\n highlightNonce,\n isDarkMode,\n height = 250,\n fontSize = 12,\n}: InternalEditorProps) => {\n const editorRef = useRef<monaco.editor.IStandaloneCodeEditor>();\n const monacoRef = useRef<Monaco>();\n const decorationIdsRef = useRef<string[]>([]);\n\n const handleBeforeMount = (monacoInstance: Monaco) => {\n // @ts-ignore\n monacoInstance.editor.defineTheme(\"promptemonViewerDark\", DARK_THEME);\n // @ts-ignore\n monacoInstance.editor.defineTheme(\"promptemonViewerLight\", LIGHT_THEME);\n monacoInstance.editor.setTheme(isDarkMode ? \"promptemonViewerDark\" : \"promptemonViewerLight\");\n };\n\n const handleEditorMount: OnMount = (editor, monacoInstance) => {\n editorRef.current = editor;\n monacoRef.current = monacoInstance;\n\n // @ts-ignore\n monacoInstance.editor.defineTheme(\"promptemonViewerDark\", DARK_THEME);\n // @ts-ignore\n monacoInstance.editor.defineTheme(\"promptemonViewerLight\", LIGHT_THEME);\n monacoInstance.editor.setTheme(isDarkMode ? \"promptemonViewerDark\" : \"promptemonViewerLight\");\n\n monacoInstance.languages.register({ id: \"promptemonViewerLang\" });\n monacoInstance.languages.setMonarchTokensProvider(\"promptemonViewerLang\", {\n tokenizer: {\n root: [\n [/(<)([a-zA-Z0-9\\-]+)(\\s*)/, [\"delimiter\", \"tag\", \"white\"], \"@tagBody\"],\n [/(<\\/)([a-zA-Z0-9\\-]+)(\\s*)(>)/, [\"delimiter\", \"tag\", \"white\", \"delimiter\"]],\n [/{{[^}]+}}/, \"variable\"],\n ],\n tagBody: [\n [/[a-zA-Z0-9\\:\\-]+(?=\\=)/, \"attribute.name\"],\n [/=/, \"delimiter\"],\n [/(\".*?\"|'.*?')/, \"attribute.value\"],\n [/\\s+/, \"white\"],\n [/(\\/?>)/, { token: \"delimiter\", next: \"@pop\" }],\n ],\n },\n });\n\n monacoInstance.languages.registerFoldingRangeProvider(\"promptemonViewerLang\", {\n provideFoldingRanges: (model) => {\n const lines = model.getLinesContent();\n const foldingRanges: any[] = [];\n const stack: { tag: string; start: number }[] = [];\n lines.forEach((line, index) => {\n const lineNumber = index + 1;\n const openTagMatch = line.match(/<([a-zA-Z0-9\\-]+)(\\s[^>]*)?>/);\n const closeTagMatch = line.match(/<\\/([a-zA-Z0-9\\-]+)>/);\n if (openTagMatch && !line.includes(\"/>\")) {\n stack.push({ tag: openTagMatch[1], start: lineNumber });\n }\n if (closeTagMatch) {\n const tag = closeTagMatch[1];\n for (let i = stack.length - 1; i >= 0; i--) {\n if (stack[i].tag === tag) {\n foldingRanges.push({ start: stack[i].start, end: lineNumber });\n stack.splice(i, 1);\n break;\n }\n }\n }\n });\n return foldingRanges;\n },\n });\n };\n\n useEffect(() => {\n if (!selectedTag || !editorRef.current || !monacoRef.current) return;\n const editor = editorRef.current;\n const model = editor.getModel();\n if (!model) return;\n const lines = model.getValue().split(\"\\n\");\n let targetLine = -1;\n for (let i = 0; i < lines.length; i++) {\n const tagMatch = lines[i].match(/<([^\\s>\\/]+(?:\\s[^\\s>\\/]+)*)/);\n if (tagMatch && tagMatch[1].trim().toLowerCase() === selectedTag.toLowerCase()) {\n targetLine = i + 1;\n break;\n }\n }\n if (targetLine > 0) {\n let closingLine = targetLine;\n const closingTagLower = `</${selectedTag.toLowerCase()}>`;\n for (let i = targetLine; i < lines.length; i++) {\n if (lines[i].toLowerCase().includes(closingTagLower)) {\n closingLine = i + 1;\n break;\n }\n }\n editor.setSelection(new monacoRef.current.Selection(targetLine, 1, targetLine, 1));\n editor.trigger(null, \"editor.unfold\", {});\n editor.revealLineInCenterIfOutsideViewport(targetLine);\n const decorations = editor.deltaDecorations([], [{\n range: new monacoRef.current.Range(targetLine, 1, closingLine, lines[closingLine - 1].length + 1),\n options: { isWholeLine: true, className: \"promptemon-viewer-highlight\", inlineClassName: \"promptemon-viewer-highlight\" },\n }]);\n setTimeout(() => editor.deltaDecorations(decorations, []), 2000);\n }\n }, [selectedTag,content]);\n\n useEffect(() => {\n if (!highlightVariable || !editorRef.current || !monacoRef.current) {\n return;\n }\n\n const editor = editorRef.current;\n const model = editor.getModel();\n if (!model) return;\n\n const content = model.getValue();\n\n const normalize = (value: string) => buildNormalizedMap(value).normalized;\n\n // Normalize input to always be an array of segments to highlight.\n const segments = Array.isArray(highlightVariable) ? highlightVariable : [highlightVariable];\n const allRanges: monaco.Range[] = [];\n\n for (const segment of segments) {\n if (!segment) continue;\n const target = normalize(segment);\n if (!target) continue;\n\n const ranges: monaco.Range[] = [];\n\n // 1. Exact match\n const exactIndex = content.indexOf(segment);\n if (exactIndex !== -1) {\n const before = content.slice(0, exactIndex);\n const startLine = before.split(\"\\n\").length;\n const startColumn =\n before.lastIndexOf(\"\\n\") === -1\n ? exactIndex + 1\n : exactIndex - before.lastIndexOf(\"\\n\");\n\n const matchLines = segment.split(\"\\n\");\n const endLine = startLine + matchLines.length - 1;\n const endColumn =\n matchLines.length === 1\n ? startColumn + segment.length\n : matchLines[matchLines.length - 1].length + 1;\n\n ranges.push(new monacoRef.current.Range(startLine, startColumn, endLine, endColumn));\n }\n\n // 2. Normalized offset-mapped match (no drift)\n if (ranges.length === 0) {\n const { normalized: normalizedContent, map } = buildNormalizedMap(content);\n const normalizedIndex = normalizedContent.indexOf(target);\n\n if (normalizedIndex !== -1 && map.length > 0) {\n const startOffset = map[normalizedIndex];\n const endOffset =\n map[Math.min(normalizedIndex + target.length - 1, map.length - 1)] + 1;\n\n const before = content.slice(0, startOffset);\n const startLine = before.split(\"\\n\").length;\n const startColumn =\n before.lastIndexOf(\"\\n\") === -1\n ? startOffset + 1\n : startOffset - before.lastIndexOf(\"\\n\");\n\n const upToEnd = content.slice(0, endOffset);\n const endLine = upToEnd.split(\"\\n\").length;\n const endColumn =\n upToEnd.lastIndexOf(\"\\n\") === -1\n ? endOffset + 1\n : endOffset - upToEnd.lastIndexOf(\"\\n\");\n\n ranges.push(new monacoRef.current.Range(startLine, startColumn, endLine, endColumn));\n }\n }\n\n // 3. Safe fuzzy fallback\n if (ranges.length === 0) {\n const targetLines = segment\n .split(\"\\n\")\n .map((line) => normalize(line))\n .filter((line) => line.length > 10);\n\n let bestMatch = { line: -1, score: 0 };\n const lines = content.split(\"\\n\");\n\n lines.forEach((line, index) => {\n const normalizedLine = normalize(line);\n if (!normalizedLine) return;\n\n let score = 0;\n targetLines.forEach((targetLine) => {\n if (normalizedLine.includes(targetLine)) {\n score = Math.max(score, targetLine.length / normalizedLine.length);\n }\n });\n\n if (score > bestMatch.score) {\n bestMatch = { line: index, score };\n }\n });\n\n if (bestMatch.score >= 0.5) {\n const line = lines[bestMatch.line];\n ranges.push(\n new monacoRef.current.Range(bestMatch.line + 1, 1, bestMatch.line + 1, line.length + 1)\n );\n }\n }\n\n allRanges.push(...ranges);\n }\n\n if (allRanges.length === 0) return;\n\n editor.revealLineInCenterIfOutsideViewport(allRanges[0].startLineNumber);\n\n decorationIdsRef.current = editor.deltaDecorations(\n decorationIdsRef.current,\n allRanges.map((range) => ({\n range,\n options: {\n inlineClassName: isDarkMode\n ? \"promptemon-viewer-variable-highlight-dark\"\n : \"promptemon-viewer-variable-highlight\",\n },\n }))\n );\n }, [highlightVariable, highlightNonce, content, isDarkMode]);\n\n useEffect(() => {\n if (!monacoRef.current) return;\n monacoRef.current.editor.setTheme(isDarkMode ? \"promptemonViewerDark\" : \"promptemonViewerLight\");\n }, [isDarkMode]);\n\n return (\n <>\n <style>{`\n .promptemon-viewer-highlight { background-color: rgba(89, 40, 237, 0.15); }\n .promptemon-viewer-variable-highlight { background-color: rgba(173, 214, 255); border-radius: 2px; }\n.promptemon-viewer-variable-highlight-dark { background-color: rgba(38, 79, 120, 0.55); border-radius: 2px; }\n `}</style>\n <Box sx={{ width: \"100%\", height, display: \"flex\", flexDirection: \"column\" }}>\n <Box sx={{ width: \"100%\", height: 20, bgcolor: isDarkMode ? \"#030202\" : \"#fff\", borderTopLeftRadius: 8, borderTopRightRadius: 8 }} />\n <Box sx={{ flex: 1, minHeight: 0, overflow: \"hidden\" }}>\n <Editor\n onMount={handleEditorMount}\n beforeMount={handleBeforeMount}\n theme={isDarkMode ? \"promptemonViewerDark\" : \"promptemonViewerLight\"}\n value={content}\n language=\"promptemonViewerLang\"\n onChange={() => {}}\n options={{\n fontSize,\n minimap: { enabled: false },\n wordWrap: \"on\",\n lineNumbers: \"on\",\n readOnly: true,\n domReadOnly: true,\n scrollBeyondLastLine: false,\n padding: { top: 4, bottom: 12 },\n folding: true,\n automaticLayout: true,\n scrollbar: { vertical: \"visible\", horizontal: \"visible\", verticalScrollbarSize: 8 },\n }}\n />\n </Box>\n <Box sx={{ width: \"100%\", height: 20, bgcolor: isDarkMode ? \"#030202\" : \"#fff\", borderBottomLeftRadius: 8, borderBottomRightRadius: 8 }} />\n </Box>\n </>\n );\n};\n\nexport default InternalEditor;"],"names":["DARK_THEME","base","inherit","rules","token","foreground","fontStyle","colors","LIGHT_THEME","InternalEditor","content","selectedTag","highlightVariable","highlightNonce","isDarkMode","height","fontSize","editorRef","useRef","monacoRef","decorationIdsRef","useEffect","current","editor","model","getModel","lines","getValue","split","targetLine","i","length","tagMatch","match","trim","toLowerCase","closingLine","closingTagLower","includes","setSelection","Selection","trigger","revealLineInCenterIfOutsideViewport","decorations","deltaDecorations","range","Range","options","isWholeLine","className","inlineClassName","setTimeout","normalize","value","buildNormalizedMap","normalized","segments","Array","isArray","allRanges","segment","target","ranges","exactIndex","indexOf","before","slice","startLine","startColumn","lastIndexOf","matchLines","endLine","endColumn","push","normalizedContent","map","normalizedIndex","startOffset","endOffset","Math","min","upToEnd","targetLines","line","filter","bestMatch","score","forEach","index","normalizedLine","max","startLineNumber","setTheme","jsxs","Fragment","children","jsx","Box","sx","width","display","flexDirection","bgcolor","borderTopLeftRadius","borderTopRightRadius","flex","minHeight","overflow","Editor","onMount","monacoInstance","defineTheme","languages","register","id","setMonarchTokensProvider","tokenizer","root","tagBody","next","registerFoldingRangeProvider","provideFoldingRanges","getLinesContent","foldingRanges","stack","lineNumber","openTagMatch","closeTagMatch","tag","start","end","splice","beforeMount","theme","language","onChange","minimap","enabled","wordWrap","lineNumbers","readOnly","domReadOnly","scrollBeyondLastLine","padding","top","bottom","folding","automaticLayout","scrollbar","vertical","horizontal","verticalScrollbarSize","borderBottomLeftRadius","borderBottomRightRadius"],"mappings":"iPAaA,MAAMA,EAAa,CACfC,KAAM,UACNC,SAAS,EACTC,MAAO,CACH,CAAEC,MAAO,MAAOC,WAAY,SAAUC,UAAW,QACjD,CAAEF,MAAO,iBAAkBC,WAAY,UACvC,CAAED,MAAO,kBAAmBC,WAAY,UACxC,CAAED,MAAO,WAAYC,WAAY,UACjC,CAAED,MAAO,YAAaC,WAAY,UAClC,CAAED,MAAO,QAASC,WAAY,WAElCE,OAAQ,CACJ,oBAAqB,UACrB,oBAAqB,UACrB,8BAA+B,UAC/B,0BAA2B,UAC3B,+BAAgC,UAChC,qCAAsC,YAIxCC,EAAc,CAChBP,KAAM,KACNC,SAAS,EACTC,MAAO,CACH,CAAEC,MAAO,MAAOC,WAAY,SAAUC,UAAW,QACjD,CAAEF,MAAO,iBAAkBC,WAAY,UACvC,CAAED,MAAO,kBAAmBC,WAAY,UACxC,CAAED,MAAO,WAAYC,WAAY,UACjC,CAAED,MAAO,YAAaC,WAAY,UAClC,CAAED,MAAO,QAASC,WAAY,WAElCE,OAAQ,CACJ,oBAAqB,UACrB,oBAAqB,UACrB,8BAA+B,UAC/B,0BAA2B,UAC3B,+BAAgC,UAChC,qCAAsC,YAejCE,EAAiB,EAC1BC,UACAC,cACAC,oBACAC,iBACAC,aACAC,SAAS,IACTC,WAAW,OAEX,MAAMC,EAAYC,IACZC,EAAYD,IACZE,EAAmBF,EAAiB,IAuO1C,OArKAG,EAAU,KACN,IAAKV,IAAgBM,EAAUK,UAAYH,EAAUG,QAAS,OAC9D,MAAMC,EAASN,EAAUK,QACnBE,EAAQD,EAAOE,WACrB,IAAKD,EAAO,OACZ,MAAME,EAAQF,EAAMG,WAAWC,MAAM,MACrC,IAAIC,GAAa,EACjB,IAAA,IAASC,EAAI,E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AAKL,IAC3CD,EAAAO,OAAOrG,EAAG,GAChB,KACJ,CAER,IAEG6F,MAsLCS,YAjPOtB,IAERA,EAAAvF,OAAOwF,YAAY,uBAAwB/G,GAE3C8G,EAAAvF,OAAOwF,YAAY,wBAAyBvG,GAC3DsG,EAAevF,OAAOqE,SAAS9E,EAAa,uBAAyB,0BA6OrDuH,MAAOvH,EAAa,uBAAyB,wBAC7CuC,MAAO3C,EACP4H,SAAS,uBACTC,SAAU,OACVxF,QAAS,CACL/B,WACAwH,QAAS,CAAEC,SAAS,GACpBC,SAAU,KACVC,YAAa,KACbC,UAAU,EACVC,aAAa,EACbC,sBAAsB,EACtBC,QAAS,CAAEC,IAAK,EAAGC,OAAQ,IAC3BC,SAAS,EACTC,iBAAiB,EACjBC,UAAW,CAAEC,SAAU,UAAWC,WAAY,UAAWC,sBAAuB,UAI3FtD,EAAI,CAAAC,GAAI,CAAEC,MAAO,OAAQpF,OAAQ,GAAIuF,QAASxF,EAAa,UAAY,OAAQ0I,uBAAwB,EAAGC,wBAAyB"}
@@ -1,2 +1,2 @@
1
- import{jsxs as e,jsx as i,Fragment as t}from"react/jsx-runtime";import{useState as o,useEffect as n,useRef as r}from"react";import{Box as l,Typography as c,Skeleton as d,Accordion as a,AccordionSummary as s,AccordionDetails as p,Tooltip as h,IconButton as x,Switch as f,Dialog as m,Chip as g}from"@mui/material";import u from"@mui/icons-material/ExpandMore";import b from"@mui/icons-material/Fullscreen";import y from"@mui/icons-material/Close";import S from"@mui/icons-material/NearMeOutlined";import v from"@mui/icons-material/ChevronLeft";import w from"@mui/icons-material/ChevronRight";import D from"./DependencyGraph.js";import{MarkdownRenderer as z}from"./Markdownrenderer.js";import{InternalEditor as E}from"./Internaleditor.js";import{PromptBlockTree as B}from"@e-llm-studio/prompt-block-tree";const k=({text:t,detailedSummary:n,extraMetaData:r,isDarkMode:d=!1,markdownRendererStyle:a,cognitiveDecisioningStyles:s})=>{const[p,h]=o(!1),{preview:x,truncated:f}=((e,i=220)=>{const t=e.replace(/<!--\s*<ai_reasoning>[\s\S]*?<\/ai_reasoning>\s*-->/g,"").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();if(t.length<=i)return{preview:t,truncated:!1};const o=t.slice(0,i),n=o.lastIndexOf(" ");return{preview:(n>0?o.slice(0,n):o).trim(),truncated:!0}})(t);return i(l,{children:e(l,p?{children:[i(z,{message:t,fontSize:"0.8rem",extraMetaData:r,isDarkMode:d,cognitiveDecisioningStyles:s,style:a}),n?.trim()&&i(z,{message:n,fontSize:"0.8rem",extraMetaData:r,isDarkMode:d,cognitiveDecisioningStyles:s,style:a}),i(c,{component:"span",onClick:()=>h(!1),sx:{fontSize:"0.72rem",color:d?"#a78bfa":"#5928ed",fontWeight:600,cursor:"pointer"},children:"view less"})]}:{sx:{display:"flex",flexDirection:"column"},children:[e(c,{sx:{fontSize:"0.8rem",color:d?"#cbd5e1":"#4B5563",lineHeight:1.6},children:[x,f&&"…"]}),(f||n?.trim())&&i(l,{sx:{display:"flex",justifyContent:"flex-end"},children:i(c,{component:"span",onClick:()=>h(!0),sx:{fontSize:"0.72rem",color:d?"#a78bfa":"#5928ed",fontWeight:600,cursor:"pointer"},children:"...view more"})})]})})},M=({text:t,extraMetaData:d,cognitiveDecisioningStyles:a})=>{const[s,p]=o(!1),[h,x]=o(!1),f=r(null);return n(()=>{const e=f.current;e&&x(e.scrollWidth>e.clientWidth)},[t]),i(l,{sx:{pl:1},children:e(l,s?{sx:{fontSize:"0.68rem",color:"#9CA3AF",lineHeight:1.4},children:[i(z,{message:t,fontSize:"0.68rem",extraMetaData:d,cognitiveDecisioningStyles:a}),i(c,{component:"span",onClick:()=>p(!1),sx:{fontSize:"0.65rem",color:"#5928ed",cursor:"pointer",fontWeight:600},children:"view less"})]}:{sx:{display:"flex",alignItems:"baseline",gap:.5},children:[i(c,{ref:f,sx:{fontSize:"0.68rem",color:"#9CA3AF",lineHeight:1.4,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",flex:1,minWidth:0},children:t}),h&&i(c,{component:"span",onClick:()=>p(!0),sx:{fontSize:"0.65rem",color:"#5928ed",cursor:"pointer",fontWeight:600,flexShrink:0},children:"view more"})]})})},C=({promptContent:C,promptTitle:F,isLoading:A=!1,overviewSummary:R,functionalityOfSPB:W=[],functionalityOfFPB:I,showfunctionalityofFPB:P=!1,spbAdditionalInfo:H,lastAnalyzedAt:T,extraMetaData:_,showCodePanel:L=!0,showInlineApbEditor:O=!0,disableApbNavigation:j=!1,showCollapseStrip:G=!0,showFullscreenButton:N=!0,showFullscreenModal:X=!0,showThemeToggle:Y=!0,isDarkMode:$=!0,styles:V,className:q,style:J,sx:K})=>{const[Q,U]=o(null),[Z,ee]=o(null),[ie,te]=o(""),[oe,ne]=o(""),re=void 0!==V?.isDarkMode?V.isDarkMode:$,[le,ce]=o(re),[de,ae]=o(null);n(()=>{void 0!==V?.isDarkMode&&ce(V.isDarkMode)},[V?.isDarkMode]);const[se,pe]=o(!1),[he,xe]=o(480),fe=r(!1),me=r(null);n(()=>{var e;T?U(T):W.length>0&&U(`${(e=new Date).toLocaleTimeString("en-IN",{hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0})||""} | ${e.toLocaleDateString("en-IN",{day:"numeric",month:"short",year:"numeric"})||""}`)},[W,T]),n(()=>{A&&U(null)},[A]),n(()=>{de&&(te(""),setTimeout(()=>te(de.ref),500))},[de]);return e(l,{className:q,style:{...V?.root,...J},sx:{height:"100%",display:"flex",flexDirection:"column",width:"100%",minHeight:0,overflow:"hidden",...K},children:[i(l,{sx:{px:2.5,py:1.5,borderBottom:"1px solid #e5e7eb",display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#fff",flexShrink:0,...V?.header},children:e(l,{sx:{display:"flex",flexDirection:"column",gap:.25},children:[i(c,{sx:{fontWeight:700,fontSize:"0.9rem",color:"#111827",...V?.headerTitle},children:F||"SPB Analysis"}),i(c,{sx:{fontSize:"0.7rem",color:"#9CA3AF",...V?.headerSubtitle},children:Q?`Last Analyzed at ${Q}`:""})]})}),e(l,{ref:me,sx:{display:"flex",flex:1,minHeight:0,overflow:"hidden",position:"relative"},children:[i(l,{sx:{width:L?se&&G?0:he:"100%",flexShrink:0,minHeight:0,overflow:"hidden",transition:fe.current?"none":"width 0.15s",borderRight:!L||se&&G?"none":"1px solid #e5e7eb",...V?.leftPanel},children:e(l,{sx:{width:"100%",height:"100%",minHeight:0,overflowY:"auto",display:"flex",flexDirection:"column",gap:1,px:1.25,py:1.25,pb:2},children:[e(l,{sx:{border:"1px solid #E5E7EB",borderRadius:"8px",bgcolor:"#F8FAFC",p:1.5,...V?.overviewSection},children:[i(c,{sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827",mb:1,...V?.overviewTitle},children:"Overview"}),i(l,{sx:{bgcolor:"#fff",border:"1px solid #E5E7EB",borderRadius:"8px",p:1.5,...V?.overviewContent},children:R?.overallSummary?.trim()?i(k,{text:R.overallSummary,detailedSummary:R.detailedSummary,extraMetaData:_,isDarkMode:le,markdownRendererStyle:V?.markdownRenderer,cognitiveDecisioningStyles:V?.cognitiveDecisioning}):e(l,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[i(d,{variant:"text",width:"100%",height:14}),i(d,{variant:"text",width:"90%",height:14}),i(d,{variant:"text",width:"95%",height:14})]})})]}),e(a,{disableGutters:!0,elevation:0,sx:{border:"1px solid #E5E7EB",borderRadius:"8px !important","&:before":{display:"none"},"&.Mui-expanded":{bgcolor:"#F8FAFC"},bgcolor:"#fff",...V?.functionalitySection},children:[i(s,{expandIcon:i(u,{sx:{fontSize:"1rem",color:"#6B7280"}}),sx:{px:1.5,minHeight:"unset","& .MuiAccordionSummary-content":{my:.75}},children:i(c,{sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827",...V?.functionalityTitle},children:"Functionality of SPB"})}),i(p,{sx:{px:1.5,pb:1.5,pt:0,bgcolor:"#F8FAFC",display:"flex",flexDirection:"column",gap:1},children:W.length>0?W.map((t,o)=>e(a,{disableGutters:!0,elevation:0,defaultExpanded:0===o,sx:{bgcolor:"#fff",border:"1px solid #E5E7EB",borderRadius:"8px !important","&:before":{display:"none"},overflow:"hidden",...V?.functionalityItem},children:[i(s,{expandIcon:i(u,{sx:{fontSize:"1rem",color:"#6B7280"}}),sx:{px:1.5,minHeight:38,"& .MuiAccordionSummary-content":{my:.5}},children:e(c,{sx:{fontWeight:600,fontSize:"0.8rem",color:"#111827"},children:[o+1,". ",t.name||t.section_name]})}),e(p,{sx:{px:1.5,pb:1.5,pt:0,display:"flex",flexDirection:"column",gap:.75},children:[i(z,{fontSize:"0.74rem",message:t.description||t.reason_for_inclusion||"",extraMetaData:_,cognitiveDecisioningStyles:V?.cognitiveDecisioning}),i(c,{sx:{fontSize:"0.72rem",color:"#9CA3AF",fontWeight:500,mt:.25},children:"APB References"}),i(l,{sx:{display:"flex",flexDirection:"column",gap:.75},children:t.apb_references.map((t,o)=>{const n="string"==typeof t?t:t.apb_name,r=Z===n;return e(l,{sx:{display:"flex",flexDirection:"column",gap:.15},children:[e(l,{onClick:j?void 0:()=>(e=>{Z===e?(ee(null),te("")):(ee(e),te(""),setTimeout(()=>te(e),50))})(n),sx:{display:"flex",alignItems:"center",gap:.25,cursor:j?"default":"pointer"},children:[e(c,{sx:{fontSize:"0.78rem",color:r?"#5928ed":"#DB2877",fontWeight:500},children:[o+1,". ",n]}),!j&&i(S,{sx:{fontSize:"0.75rem",color:r?"#5928ed":"#DB2877"}})]}),"string"!=typeof t&&(t.description||t.context)&&i(M,{text:t.description||t.context||"",extraMetaData:_,cognitiveDecisioningStyles:V?.cognitiveDecisioning}),O&&r&&i(l,{sx:{mt:1,height:260,border:"1px solid #e5e7eb",borderRadius:"8px",overflow:"hidden"},children:i(E,{content:C,selectedTag:ie,isDarkMode:le,height:"100%",fontSize:12})})]},o)})})]})]},o)):i(l,{sx:{display:"flex",flexDirection:"column",gap:1},children:[1,2,3].map(t=>e(l,{sx:{bgcolor:"#fff",border:"1px solid #E5E7EB",borderRadius:"8px",p:1.5,display:"flex",flexDirection:"column",gap:.5},children:[i(d,{variant:"text",width:"40%",height:16}),i(d,{variant:"text",width:"90%",height:14}),i(d,{variant:"text",width:"80%",height:14}),i(d,{variant:"text",width:"30%",height:14})]},t))})})]}),P&&e(a,{disableGutters:!0,elevation:0,sx:{border:"1px solid #E5E7EB",borderRadius:"8px !important","&:before":{display:"none"},"&.Mui-expanded":{bgcolor:"#F8FAFC"},bgcolor:"#fff",...V?.fpbSection},children:[e(s,{expandIcon:i(u,{sx:{fontSize:"1rem",color:"#6B7280"}}),sx:{px:1.5,minHeight:"unset","& .MuiAccordionSummary-content":{my:.75,alignItems:"center",gap:1}},children:[i(c,{sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827",...V?.fpbTitle},children:I?.fpbTitle||"Functionality of FPB"}),i(c,{sx:{fontSize:"0.7rem",color:"#9CA3AF"}})]}),i(p,{sx:{px:1.5,pb:1.5,pt:0,bgcolor:"#F8FAFC"},children:I?.treeProps?i(B,{...I.treeProps,onNodeOpen:e=>{const i=e.meta?.rawPrompt;"string"==typeof i&&i.trim()&&ne(i),I?.treeProps.onNodeOpen?.(e)}}):i(l,{sx:{display:"flex",flexDirection:"column",gap:1},children:[1,2,3].map(t=>e(l,{sx:{bgcolor:"#fff",border:"1px solid #E5E7EB",borderRadius:"8px",p:1.5,display:"flex",flexDirection:"column",gap:.5},children:[i(d,{variant:"text",width:"40%",height:16}),i(d,{variant:"text",width:"90%",height:14}),i(d,{variant:"text",width:"80%",height:14}),i(d,{variant:"text",width:"30%",height:14})]},t))})})]}),e(a,{disableGutters:!0,elevation:0,sx:{border:"1px solid #E5E7EB",borderRadius:"8px !important","&:before":{display:"none"},"&.Mui-expanded":{bgcolor:"#F8FAFC"},bgcolor:"#fff",...V?.applicabilitySection},children:[e(s,{expandIcon:i(u,{sx:{fontSize:"1rem",color:"#6B7280"}}),sx:{px:1.5,minHeight:"unset","& .MuiAccordionSummary-content":{my:.75,alignItems:"center",gap:1}},children:[i(c,{sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827",...V?.applicabilityTitle},children:"Applicability"}),i(c,{sx:{fontSize:"0.7rem",color:"#9CA3AF"},children:"When to Apply this SPB / When Not Apply"})]}),i(p,{sx:{px:1.5,pb:1.5,pt:0,bgcolor:"#F8FAFC"},children:i(l,{sx:{display:"flex",gap:1},children:[{label:"When to apply",content:H?.when_to_apply},{label:"When NOT to apply",content:H?.when_not_to_apply}].map(({label:t,content:o})=>e(l,{sx:{flex:1,bgcolor:"#fff",border:"1px solid #E5E7EB",borderRadius:"6px",p:1.25},children:[i(c,{sx:{fontWeight:600,fontSize:"0.76rem",color:"#374151",mb:.75},children:t}),o?i(z,{fontSize:"0.8rem",message:o,isDarkMode:le,style:V?.markdownRenderer,extraMetaData:_,cognitiveDecisioningStyles:V?.cognitiveDecisioning}):A?e(l,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[i(d,{variant:"text",width:"100%",height:14}),i(d,{variant:"text",width:"80%",height:14}),i(d,{variant:"text",width:"90%",height:14})]}):i(c,{sx:{fontSize:"0.8rem",color:"#6B7280",lineHeight:1.5},children:"— Not yet available"})]},t))})})]}),e(a,{disableGutters:!0,elevation:0,sx:{border:"1px solid #E5E7EB",borderRadius:"8px !important","&:before":{display:"none"},"&.Mui-expanded":{bgcolor:"#F8FAFC"},bgcolor:"#fff",...V?.specificationsSection},children:[e(s,{expandIcon:i(u,{sx:{fontSize:"1rem",color:"#6B7280"}}),sx:{px:1.5,minHeight:"unset","& .MuiAccordionSummary-content":{my:.75,alignItems:"center",gap:1}},children:[i(c,{sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827",...V?.specificationsTitle},children:"Specifications"}),i(c,{sx:{fontSize:"0.7rem",color:"#9CA3AF"},children:"Strict Rules / Input / Output"})]}),i(p,{sx:{px:1.5,pb:1.5,pt:0,bgcolor:"#F8FAFC",display:"flex",flexDirection:"column",gap:1},children:[{label:"Strict Rules",tooltip:null,content:H?.constraints_and_rules},{label:"Input",tooltip:"Input specification for this SPB",content:H?.input_analysis},{label:"Output",tooltip:"Output specification for this SPB",content:H?.output_analysis}].map(({label:o,tooltip:n,content:r})=>{const f="Output"===o,m=f&&r?(e=>{const i=[];return{text:e.replace(/<code>([\s\S]*?)<\/code>/g,(e,t)=>(i.push(t.trim()),"")).trim(),code:i.join("\n\n")}})(r):null,g=m?m.text:r,b=m?m.code:"";return e(a,{disableGutters:!0,elevation:0,defaultExpanded:"Strict Rules"===o,sx:{bgcolor:"#fff",border:"1px solid #E5E7EB",borderRadius:"6px !important","&:before":{display:"none"},overflow:"hidden"},children:[i(s,{expandIcon:i(u,{sx:{fontSize:"1rem"}}),sx:{minHeight:34,px:1.25,"& .MuiAccordionSummary-content":{my:.4}},children:e(l,{sx:{display:"flex",alignItems:"center",gap:.5},children:[i(c,{sx:{fontWeight:600,fontSize:"0.76rem",color:"#374151"},children:o}),n&&i(h,{title:n,placement:"top",children:i(l,{component:"span",sx:{width:13,height:13,borderRadius:"50%",background:"#E5E7EB",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"0.58rem",color:"#6B7280",fontWeight:700,cursor:"default",flexShrink:0},children:"i"})})]})}),i(p,{sx:{px:1.25,pb:1.25,pt:0},children:r?e(t,{children:[g&&i(z,{fontSize:"0.8rem",message:g,isDarkMode:le,style:V?.markdownRenderer,extraMetaData:_,cognitiveDecisioningStyles:V?.cognitiveDecisioning}),f&&b&&e(l,{sx:{width:"100%",height:"35vh",mt:1.5},children:[e(l,{sx:{display:"flex",gap:.1,backgroundColor:"black",flexDirection:"row",alignItems:"center",justifyContent:"space-between",p:1,borderTopLeftRadius:"8px",borderTopRightRadius:"8px"},children:[i(c,{sx:{color:"white",fontWeight:500,fontSize:"0.8rem"},children:"Output preview"}),i(h,{title:"Copy Code to clipboard",children:i(x,{size:"small",onClick:()=>{return e=b,navigator.clipboard.writeText(e);var e},children:i(c,{sx:{fontSize:"0.7rem",color:"white"},children:"Copy"})})})]}),i(l,{sx:{mt:-1,height:"calc(100% - 40px)",borderBottomLeftRadius:"8px",borderBottomRightRadius:"8px",overflow:"hidden"},children:i(E,{content:b,isDarkMode:le,height:"100%",fontSize:10})})]})]}):A?e(l,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[i(d,{variant:"text",width:"100%",height:14}),i(d,{variant:"text",width:"90%",height:14}),i(d,{variant:"text",width:"75%",height:14})]}):i(c,{sx:{fontSize:"0.74rem",color:"#6B7280",lineHeight:1.5},children:"— Not yet available"})})]},o)})})]}),e(a,{defaultExpanded:!0,disableGutters:!0,elevation:0,sx:{border:"1px solid #E5E7EB",borderRadius:"8px !important","&:before":{display:"none"},bgcolor:"#fff",...V?.dependencyGraphSection},children:[i(s,{expandIcon:i(u,{sx:{fontSize:"1rem",color:"#6B7280"}}),sx:{px:1.5,minHeight:"unset","& .MuiAccordionSummary-content":{my:.75},"&.Mui-expanded":{bgcolor:"#F8FAFC",borderRadius:"8px 8px 0 0"}},children:i(c,{sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827",...V?.dependencyGraphTitle},children:"Dependency Graph"})}),i(p,{sx:{px:0,pb:0,pt:0},children:e(l,H?.dependency_graph?{sx:{bgcolor:"#F8FAFC",borderRadius:"0 0 8px 8px",p:1.5,display:"flex",flexDirection:"column",gap:1.5},children:[i(l,{sx:{height:500,borderRadius:"8px",overflow:"hidden"},children:i(D,{data:H.dependency_graph,isDarkMode:le,style:V?.dependencyGraph})}),i(c,{sx:{fontSize:"0.72rem",color:"#64748B",lineHeight:1.6},children:"This graph visualises how Atomic Prompt Blocks (APBs) depend on, influence, or exchange information with one another within the prompt architecture."})]}:{sx:{bgcolor:"#fff",borderRadius:"0 0 8px 8px",p:1.5,display:"flex",flexDirection:"column",gap:1},children:[i(d,{variant:"rectangular",width:"100%",height:400,sx:{borderRadius:"8px"}}),i(d,{variant:"text",width:"100%",height:14}),i(d,{variant:"text",width:"80%",height:14})]})})]})]})}),L&&G&&i(l,{onClick:()=>pe(e=>!e),sx:{width:20,flexShrink:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",cursor:"pointer",borderRight:"1px solid #e5e7eb",borderLeft:"1px solid #e5e7eb",bgcolor:"#f9fafb",position:"relative",py:2,"&:hover":{bgcolor:"#f0f0f0"},...V?.collapseStrip},children:i(c,{sx:{fontSize:10,fontWeight:600,color:"#6b7280",writingMode:"vertical-rl",textOrientation:"mixed",transform:"rotate(180deg)",letterSpacing:"0.05em",userSelect:"none"},children:"SPB Details"})}),L&&G&&i(l,{onClick:()=>pe(e=>!e),onMouseDown:e=>{e.preventDefault(),fe.current=!0;const i=e=>{if(!fe.current||!me.current)return;const o=me.current.getBoundingClientRect(),n=o.left,r=o.width,l=e.clientX-n;if(l<200)return pe(!0),fe.current=!1,document.removeEventListener("mousemove",i),void document.removeEventListener("mouseup",t);l>.7*r||(pe(!1),xe(l))},t=()=>{fe.current=!1,document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",t)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",t)},sx:{position:"absolute",left:se?20:he+20,top:"50%",transform:"translateY(-50%)",width:18,height:28,bgcolor:"#fff",border:"1px solid #e5e7eb",borderRadius:"0 6px 6px 0",display:"flex",alignItems:"center",justifyContent:"center",cursor:"col-resize",zIndex:5,boxShadow:"2px 0 4px rgba(0,0,0,0.06)","&:hover":{bgcolor:"#f9fafb"},...V?.dragHandle},children:i(se?w:v,{sx:{fontSize:12,color:"#6b7280"}})}),L&&e(l,{sx:{flex:1,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden",p:2,gap:1.5,bgcolor:"#f8fafc",...V?.codePanel},children:[e(l,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0,...V?.codePanelHeader},children:[i(c,{sx:{fontSize:13,fontWeight:600,color:"#374151",...V?.codePanelTitle},children:F||"SPB Analysis"}),e(l,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[Y&&i(f,{checked:le,onChange:e=>ce(e.target.checked),size:"small",sx:{width:36,height:20,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"2px","&.Mui-checked":{transform:"translateX(16px)",color:"#fff","& + .MuiSwitch-track":{bgcolor:"#5928ed",opacity:1}}},"& .MuiSwitch-thumb":{width:16,height:16,bgcolor:"#fff"},"& .MuiSwitch-track":{borderRadius:10,bgcolor:"#d1d5db",opacity:1}}}),N&&X&&i(h,{title:"Fullscreen",placement:"top",children:i(x,{size:"small",onClick:()=>ae({ref:ie||"",description:""}),sx:{color:"#6b7280"},children:i(b,{sx:{fontSize:16}})})})]})]}),i(l,{sx:{flex:1,minHeight:0,border:"1px solid #30363d",borderRadius:1,overflow:"hidden",...V?.editorContainer},children:i(E,{content:C,selectedTag:ie,isDarkMode:le,height:"100%",fontSize:13,highlightVariable:oe})})]})]}),X&&e(m,{open:!!de,onClose:()=>ae(null),maxWidth:!1,PaperProps:{sx:{width:"82vw",height:"80vh",maxWidth:"none",borderRadius:"12px",overflow:"hidden",display:"flex",flexDirection:"column",...V?.fullscreenModal}},children:[e(l,{sx:{px:2.5,py:1.5,borderBottom:"1px solid #E5E7EB",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[i(c,{sx:{fontWeight:700,fontSize:"1rem",color:"#111827"},children:"Promptemon"}),i(x,{size:"small",onClick:()=>ae(null),children:i(y,{sx:{fontSize:"1.1rem",color:"#6B7280"}})})]}),e(l,{sx:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[e(l,{sx:{width:"40%",flexShrink:0,borderRight:"1px solid #E5E7EB",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e(l,{sx:{px:2,py:1.25,borderBottom:"1px solid #E5E7EB",display:"flex",alignItems:"center",gap:1},children:[i(h,{title:"Atomic Prompt Block",placement:"top",children:i(g,{label:"APB",size:"small",sx:{bgcolor:"#f1f5f9",color:"#475569",fontWeight:700,fontSize:10,height:20,borderRadius:1}})}),i(c,{sx:{fontWeight:600,fontSize:"0.9rem",color:"#111827"},children:de?.ref})]}),e(l,{sx:{flex:1,p:2,display:"flex",flexDirection:"column",gap:1.5,overflowY:"auto"},children:[e(l,{sx:{border:"1px solid #E5E7EB",borderRadius:"8px",p:1.5},children:[i(c,{sx:{fontWeight:600,fontSize:"0.8rem",color:"#111827",mb:.75},children:"Description"}),i(c,{sx:{fontSize:"0.73rem",color:"#6B7280",lineHeight:1.6},children:de?.description})]}),e(l,{sx:{border:"1px solid #E5E7EB",borderRadius:"8px",p:1.25,display:"flex",alignItems:"center",gap:.5},children:[i(c,{sx:{fontSize:"0.73rem",color:"#6B7280"},children:"Total Lines"}),i(c,{sx:{fontSize:"0.73rem",fontWeight:700,color:"#111827"},children:C.split("\n").length})]})]})]}),e(l,{sx:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e(l,{sx:{px:2,py:1.25,borderBottom:"1px solid #E5E7EB",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[i(c,{sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827"},children:"Prompt Preview"}),i(f,{checked:le,onChange:e=>ce(e.target.checked),size:"small",sx:{width:36,height:20,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"2px","&.Mui-checked":{transform:"translateX(16px)",color:"#fff","& + .MuiSwitch-track":{bgcolor:"#5928ed",opacity:1}}},"& .MuiSwitch-thumb":{width:16,height:16,bgcolor:"#fff"},"& .MuiSwitch-track":{borderRadius:10,bgcolor:"#d1d5db",opacity:1}}})]}),i(l,{sx:{flex:1,minHeight:0,p:1.5},children:i(E,{content:C,selectedTag:ie,isDarkMode:le,highlightVariable:oe,height:"100%",fontSize:13})})]})]})]})]})};export{C as default};
1
+ import{jsxs as e,jsx as i,Fragment as t}from"react/jsx-runtime";import{useState as o,useEffect as n,useRef as r}from"react";import{Box as l,Typography as c,Skeleton as d,Accordion as a,AccordionSummary as s,AccordionDetails as h,Tooltip as p,IconButton as x,Switch as f,Dialog as m,Chip as g}from"@mui/material";import u from"@mui/icons-material/ExpandMore";import b from"@mui/icons-material/Fullscreen";import y from"@mui/icons-material/Close";import S from"@mui/icons-material/NearMeOutlined";import v from"@mui/icons-material/ChevronLeft";import w from"@mui/icons-material/ChevronRight";import D from"./DependencyGraph.js";import{MarkdownRenderer as z}from"./Markdownrenderer.js";import{InternalEditor as E}from"./Internaleditor.js";import{PromptBlockTree as B}from"@e-llm-studio/prompt-block-tree";const k=({text:t,detailedSummary:n,extraMetaData:r,isDarkMode:d=!1,markdownRendererStyle:a,cognitiveDecisioningStyles:s})=>{const[h,p]=o(!1),{preview:x,truncated:f}=((e,i=220)=>{const t=e.replace(/<!--\s*<ai_reasoning>[\s\S]*?<\/ai_reasoning>\s*-->/g,"").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();if(t.length<=i)return{preview:t,truncated:!1};const o=t.slice(0,i),n=o.lastIndexOf(" ");return{preview:(n>0?o.slice(0,n):o).trim(),truncated:!0}})(t);return i(l,{children:e(l,h?{children:[i(z,{message:t,fontSize:"0.8rem",extraMetaData:r,isDarkMode:d,cognitiveDecisioningStyles:s,style:a}),n?.trim()&&i(z,{message:n,fontSize:"0.8rem",extraMetaData:r,isDarkMode:d,cognitiveDecisioningStyles:s,style:a}),i(c,{component:"span",onClick:()=>p(!1),sx:{fontSize:"0.72rem",color:d?"#a78bfa":"#5928ed",fontWeight:600,cursor:"pointer"},children:"view less"})]}:{sx:{display:"flex",flexDirection:"column"},children:[e(c,{sx:{fontSize:"0.8rem",color:d?"#cbd5e1":"#4B5563",lineHeight:1.6},children:[x,f&&"…"]}),(f||n?.trim())&&i(l,{sx:{display:"flex",justifyContent:"flex-end"},children:i(c,{component:"span",onClick:()=>p(!0),sx:{fontSize:"0.72rem",color:d?"#a78bfa":"#5928ed",fontWeight:600,cursor:"pointer"},children:"...view more"})})]})})},M=({text:t,extraMetaData:d,cognitiveDecisioningStyles:a})=>{const[s,h]=o(!1),[p,x]=o(!1),f=r(null);return n(()=>{const e=f.current;e&&x(e.scrollWidth>e.clientWidth)},[t]),i(l,{sx:{pl:1},children:e(l,s?{sx:{fontSize:"0.68rem",color:"#9CA3AF",lineHeight:1.4},children:[i(z,{message:t,fontSize:"0.68rem",extraMetaData:d,cognitiveDecisioningStyles:a}),i(c,{component:"span",onClick:()=>h(!1),sx:{fontSize:"0.65rem",color:"#5928ed",cursor:"pointer",fontWeight:600},children:"view less"})]}:{sx:{display:"flex",alignItems:"baseline",gap:.5},children:[i(c,{ref:f,sx:{fontSize:"0.68rem",color:"#9CA3AF",lineHeight:1.4,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",flex:1,minWidth:0},children:t}),p&&i(c,{component:"span",onClick:()=>h(!0),sx:{fontSize:"0.65rem",color:"#5928ed",cursor:"pointer",fontWeight:600,flexShrink:0},children:"view more"})]})})},C=({promptContent:C,promptTitle:A,isLoading:F=!1,overviewSummary:R,functionalityOfSPB:W=[],functionalityOfFPB:I,showfunctionalityofFPB:P=!1,spbAdditionalInfo:H,lastAnalyzedAt:T,extraMetaData:_,showCodePanel:L=!0,showInlineApbEditor:O=!0,disableApbNavigation:j=!1,showCollapseStrip:N=!0,showFullscreenButton:G=!0,showFullscreenModal:X=!0,showThemeToggle:Y=!0,isDarkMode:$=!0,styles:V,className:q,style:J,sx:K})=>{const[Q,U]=o(null),[Z,ee]=o(null),[ie,te]=o(""),[oe,ne]=o(void 0),[re,le]=o(0),ce=void 0!==V?.isDarkMode?V.isDarkMode:$,[de,ae]=o(ce),[se,he]=o(null);n(()=>{void 0!==V?.isDarkMode&&ae(V.isDarkMode)},[V?.isDarkMode]);const[pe,xe]=o(!1),[fe,me]=o(480),ge=r(!1),ue=r(null);n(()=>{var e;T?U(T):W.length>0&&U(`${(e=new Date).toLocaleTimeString("en-IN",{hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0})||""} | ${e.toLocaleDateString("en-IN",{day:"numeric",month:"short",year:"numeric"})||""}`)},[W,T]),n(()=>{F&&U(null)},[F]),n(()=>{se&&(te(""),setTimeout(()=>te(se.ref),500))},[se]);return e(l,{className:q,style:{...V?.root,...J},sx:{height:"100%",display:"flex",flexDirection:"column",width:"100%",minHeight:0,overflow:"hidden",...K},children:[i(l,{sx:{px:2.5,py:1.5,borderBottom:"1px solid #e5e7eb",display:"flex",alignItems:"center",justifyContent:"space-between",bgcolor:"#fff",flexShrink:0,...V?.header},children:e(l,{sx:{display:"flex",flexDirection:"column",gap:.25},children:[i(c,{sx:{fontWeight:700,fontSize:"0.9rem",color:"#111827",...V?.headerTitle},children:A||"SPB Analysis"}),i(c,{sx:{fontSize:"0.7rem",color:"#9CA3AF",...V?.headerSubtitle},children:Q?`Last Analyzed at ${Q}`:""})]})}),e(l,{ref:ue,sx:{display:"flex",flex:1,minHeight:0,overflow:"hidden",position:"relative"},children:[i(l,{sx:{width:L?pe&&N?0:fe:"100%",flexShrink:0,minHeight:0,overflow:"hidden",transition:ge.current?"none":"width 0.15s",borderRight:!L||pe&&N?"none":"1px solid #e5e7eb",...V?.leftPanel},children:e(l,{sx:{width:"100%",height:"100%",minHeight:0,overflowY:"auto",display:"flex",flexDirection:"column",gap:1,px:1.25,py:1.25,pb:2},children:[e(l,{sx:{border:"1px solid #E5E7EB",borderRadius:"8px",bgcolor:"#F8FAFC",p:1.5,...V?.overviewSection},children:[i(c,{sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827",mb:1,...V?.overviewTitle},children:"Overview"}),i(l,{sx:{bgcolor:"#fff",border:"1px solid #E5E7EB",borderRadius:"8px",p:1.5,...V?.overviewContent},children:R?.overallSummary?.trim()?i(k,{text:R.overallSummary,detailedSummary:R.detailedSummary,extraMetaData:_,isDarkMode:de,markdownRendererStyle:V?.markdownRenderer,cognitiveDecisioningStyles:V?.cognitiveDecisioning}):e(l,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[i(d,{variant:"text",width:"100%",height:14}),i(d,{variant:"text",width:"90%",height:14}),i(d,{variant:"text",width:"95%",height:14})]})})]}),e(a,{disableGutters:!0,elevation:0,sx:{border:"1px solid #E5E7EB",borderRadius:"8px !important","&:before":{display:"none"},"&.Mui-expanded":{bgcolor:"#F8FAFC"},bgcolor:"#fff",...V?.functionalitySection},children:[i(s,{expandIcon:i(u,{sx:{fontSize:"1rem",color:"#6B7280"}}),sx:{px:1.5,minHeight:"unset","& .MuiAccordionSummary-content":{my:.75}},children:i(c,{sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827",...V?.functionalityTitle},children:"Functionality of SPB"})}),i(h,{sx:{px:1.5,pb:1.5,pt:0,bgcolor:"#F8FAFC",display:"flex",flexDirection:"column",gap:1},children:W.length>0?W.map((t,o)=>e(a,{disableGutters:!0,elevation:0,defaultExpanded:0===o,sx:{bgcolor:"#fff",border:"1px solid #E5E7EB",borderRadius:"8px !important","&:before":{display:"none"},overflow:"hidden",...V?.functionalityItem},children:[i(s,{expandIcon:i(u,{sx:{fontSize:"1rem",color:"#6B7280"}}),sx:{px:1.5,minHeight:38,"& .MuiAccordionSummary-content":{my:.5}},children:e(c,{sx:{fontWeight:600,fontSize:"0.8rem",color:"#111827"},children:[o+1,". ",t.name||t.section_name]})}),e(h,{sx:{px:1.5,pb:1.5,pt:0,display:"flex",flexDirection:"column",gap:.75},children:[i(z,{fontSize:"0.74rem",message:t.description||t.reason_for_inclusion||"",extraMetaData:_,cognitiveDecisioningStyles:V?.cognitiveDecisioning}),i(c,{sx:{fontSize:"0.72rem",color:"#9CA3AF",fontWeight:500,mt:.25},children:"APB References"}),i(l,{sx:{display:"flex",flexDirection:"column",gap:.75},children:t.apb_references.map((t,o)=>{const n="string"==typeof t?t:t.apb_name,r=Z===n;return e(l,{sx:{display:"flex",flexDirection:"column",gap:.15},children:[e(l,{onClick:j?void 0:()=>(e=>{Z===e?(ee(null),te("")):(ee(e),te(""),setTimeout(()=>te(e),50))})(n),sx:{display:"flex",alignItems:"center",gap:.25,cursor:j?"default":"pointer"},children:[e(c,{sx:{fontSize:"0.78rem",color:r?"#5928ed":"#DB2877",fontWeight:500},children:[o+1,". ",n]}),!j&&i(S,{sx:{fontSize:"0.75rem",color:r?"#5928ed":"#DB2877"}})]}),"string"!=typeof t&&(t.description||t.context)&&i(M,{text:t.description||t.context||"",extraMetaData:_,cognitiveDecisioningStyles:V?.cognitiveDecisioning}),O&&r&&i(l,{sx:{mt:1,height:260,border:"1px solid #e5e7eb",borderRadius:"8px",overflow:"hidden"},children:i(E,{content:C,selectedTag:ie,isDarkMode:de,height:"100%",fontSize:12})})]},o)})})]})]},o)):i(l,{sx:{display:"flex",flexDirection:"column",gap:1},children:[1,2,3].map(t=>e(l,{sx:{bgcolor:"#fff",border:"1px solid #E5E7EB",borderRadius:"8px",p:1.5,display:"flex",flexDirection:"column",gap:.5},children:[i(d,{variant:"text",width:"40%",height:16}),i(d,{variant:"text",width:"90%",height:14}),i(d,{variant:"text",width:"80%",height:14}),i(d,{variant:"text",width:"30%",height:14})]},t))})})]}),P&&e(a,{disableGutters:!0,elevation:0,sx:{border:"1px solid #E5E7EB",borderRadius:"8px !important","&:before":{display:"none"},"&.Mui-expanded":{bgcolor:"#F8FAFC"},bgcolor:"#fff",...V?.fpbSection},children:[e(s,{expandIcon:i(u,{sx:{fontSize:"1rem",color:"#6B7280"}}),sx:{px:1.5,minHeight:"unset","& .MuiAccordionSummary-content":{my:.75,alignItems:"center",gap:1}},children:[i(c,{sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827",...V?.fpbTitle},children:I?.fpbTitle||"Functionality of FPB"}),i(c,{sx:{fontSize:"0.7rem",color:"#9CA3AF"}})]}),i(h,{sx:{px:1.5,pb:1.5,pt:0,bgcolor:"#F8FAFC"},children:I?.treeProps?i(B,{...I.treeProps,onNodeOpen:e=>{const i=e.meta?.rawPromptSegments,t=e.meta?.rawPrompt;Array.isArray(i)&&i.length>0?(ne(i),le(e=>e+1)):"string"==typeof t&&t.trim()?(ne(t),le(e=>e+1)):(ne(void 0),le(e=>e+1)),I?.treeProps.onNodeOpen?.(e)}}):i(l,{sx:{display:"flex",flexDirection:"column",gap:1},children:[1,2,3].map(t=>e(l,{sx:{bgcolor:"#fff",border:"1px solid #E5E7EB",borderRadius:"8px",p:1.5,display:"flex",flexDirection:"column",gap:.5},children:[i(d,{variant:"text",width:"40%",height:16}),i(d,{variant:"text",width:"90%",height:14}),i(d,{variant:"text",width:"80%",height:14}),i(d,{variant:"text",width:"30%",height:14})]},t))})})]}),e(a,{disableGutters:!0,elevation:0,sx:{border:"1px solid #E5E7EB",borderRadius:"8px !important","&:before":{display:"none"},"&.Mui-expanded":{bgcolor:"#F8FAFC"},bgcolor:"#fff",...V?.applicabilitySection},children:[e(s,{expandIcon:i(u,{sx:{fontSize:"1rem",color:"#6B7280"}}),sx:{px:1.5,minHeight:"unset","& .MuiAccordionSummary-content":{my:.75,alignItems:"center",gap:1}},children:[i(c,{sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827",...V?.applicabilityTitle},children:"Applicability"}),i(c,{sx:{fontSize:"0.7rem",color:"#9CA3AF"},children:"When to Apply this SPB / When Not Apply"})]}),i(h,{sx:{px:1.5,pb:1.5,pt:0,bgcolor:"#F8FAFC"},children:i(l,{sx:{display:"flex",gap:1},children:[{label:"When to apply",content:H?.when_to_apply},{label:"When NOT to apply",content:H?.when_not_to_apply}].map(({label:t,content:o})=>e(l,{sx:{flex:1,bgcolor:"#fff",border:"1px solid #E5E7EB",borderRadius:"6px",p:1.25},children:[i(c,{sx:{fontWeight:600,fontSize:"0.76rem",color:"#374151",mb:.75},children:t}),o?i(z,{fontSize:"0.8rem",message:o,isDarkMode:de,style:V?.markdownRenderer,extraMetaData:_,cognitiveDecisioningStyles:V?.cognitiveDecisioning}):F?e(l,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[i(d,{variant:"text",width:"100%",height:14}),i(d,{variant:"text",width:"80%",height:14}),i(d,{variant:"text",width:"90%",height:14})]}):i(c,{sx:{fontSize:"0.8rem",color:"#6B7280",lineHeight:1.5},children:"— Not yet available"})]},t))})})]}),e(a,{disableGutters:!0,elevation:0,sx:{border:"1px solid #E5E7EB",borderRadius:"8px !important","&:before":{display:"none"},"&.Mui-expanded":{bgcolor:"#F8FAFC"},bgcolor:"#fff",...V?.specificationsSection},children:[e(s,{expandIcon:i(u,{sx:{fontSize:"1rem",color:"#6B7280"}}),sx:{px:1.5,minHeight:"unset","& .MuiAccordionSummary-content":{my:.75,alignItems:"center",gap:1}},children:[i(c,{sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827",...V?.specificationsTitle},children:"Specifications"}),i(c,{sx:{fontSize:"0.7rem",color:"#9CA3AF"},children:"Strict Rules / Input / Output"})]}),i(h,{sx:{px:1.5,pb:1.5,pt:0,bgcolor:"#F8FAFC",display:"flex",flexDirection:"column",gap:1},children:[{label:"Strict Rules",tooltip:null,content:H?.constraints_and_rules},{label:"Input",tooltip:"Input specification for this SPB",content:H?.input_analysis},{label:"Output",tooltip:"Output specification for this SPB",content:H?.output_analysis}].map(({label:o,tooltip:n,content:r})=>{const f="Output"===o,m=f&&r?(e=>{const i=[];return{text:e.replace(/<code>([\s\S]*?)<\/code>/g,(e,t)=>(i.push(t.trim()),"")).trim(),code:i.join("\n\n")}})(r):null,g=m?m.text:r,b=m?m.code:"";return e(a,{disableGutters:!0,elevation:0,defaultExpanded:"Strict Rules"===o,sx:{bgcolor:"#fff",border:"1px solid #E5E7EB",borderRadius:"6px !important","&:before":{display:"none"},overflow:"hidden"},children:[i(s,{expandIcon:i(u,{sx:{fontSize:"1rem"}}),sx:{minHeight:34,px:1.25,"& .MuiAccordionSummary-content":{my:.4}},children:e(l,{sx:{display:"flex",alignItems:"center",gap:.5},children:[i(c,{sx:{fontWeight:600,fontSize:"0.76rem",color:"#374151"},children:o}),n&&i(p,{title:n,placement:"top",children:i(l,{component:"span",sx:{width:13,height:13,borderRadius:"50%",background:"#E5E7EB",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"0.58rem",color:"#6B7280",fontWeight:700,cursor:"default",flexShrink:0},children:"i"})})]})}),i(h,{sx:{px:1.25,pb:1.25,pt:0},children:r?e(t,{children:[g&&i(z,{fontSize:"0.8rem",message:g,isDarkMode:de,style:V?.markdownRenderer,extraMetaData:_,cognitiveDecisioningStyles:V?.cognitiveDecisioning}),f&&b&&e(l,{sx:{width:"100%",height:"35vh",mt:1.5},children:[e(l,{sx:{display:"flex",gap:.1,backgroundColor:"black",flexDirection:"row",alignItems:"center",justifyContent:"space-between",p:1,borderTopLeftRadius:"8px",borderTopRightRadius:"8px"},children:[i(c,{sx:{color:"white",fontWeight:500,fontSize:"0.8rem"},children:"Output preview"}),i(p,{title:"Copy Code to clipboard",children:i(x,{size:"small",onClick:()=>{return e=b,navigator.clipboard.writeText(e);var e},children:i(c,{sx:{fontSize:"0.7rem",color:"white"},children:"Copy"})})})]}),i(l,{sx:{mt:-1,height:"calc(100% - 40px)",borderBottomLeftRadius:"8px",borderBottomRightRadius:"8px",overflow:"hidden"},children:i(E,{content:b,isDarkMode:de,height:"100%",fontSize:10})})]})]}):F?e(l,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[i(d,{variant:"text",width:"100%",height:14}),i(d,{variant:"text",width:"90%",height:14}),i(d,{variant:"text",width:"75%",height:14})]}):i(c,{sx:{fontSize:"0.74rem",color:"#6B7280",lineHeight:1.5},children:"— Not yet available"})})]},o)})})]}),e(a,{defaultExpanded:!0,disableGutters:!0,elevation:0,sx:{border:"1px solid #E5E7EB",borderRadius:"8px !important","&:before":{display:"none"},bgcolor:"#fff",...V?.dependencyGraphSection},children:[i(s,{expandIcon:i(u,{sx:{fontSize:"1rem",color:"#6B7280"}}),sx:{px:1.5,minHeight:"unset","& .MuiAccordionSummary-content":{my:.75},"&.Mui-expanded":{bgcolor:"#F8FAFC",borderRadius:"8px 8px 0 0"}},children:i(c,{sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827",...V?.dependencyGraphTitle},children:"Dependency Graph"})}),i(h,{sx:{px:0,pb:0,pt:0},children:e(l,H?.dependency_graph?{sx:{bgcolor:"#F8FAFC",borderRadius:"0 0 8px 8px",p:1.5,display:"flex",flexDirection:"column",gap:1.5},children:[i(l,{sx:{height:500,borderRadius:"8px",overflow:"hidden"},children:i(D,{data:H.dependency_graph,isDarkMode:de,style:V?.dependencyGraph})}),i(c,{sx:{fontSize:"0.72rem",color:"#64748B",lineHeight:1.6},children:"This graph visualises how Atomic Prompt Blocks (APBs) depend on, influence, or exchange information with one another within the prompt architecture."})]}:{sx:{bgcolor:"#fff",borderRadius:"0 0 8px 8px",p:1.5,display:"flex",flexDirection:"column",gap:1},children:[i(d,{variant:"rectangular",width:"100%",height:400,sx:{borderRadius:"8px"}}),i(d,{variant:"text",width:"100%",height:14}),i(d,{variant:"text",width:"80%",height:14})]})})]})]})}),L&&N&&i(l,{onClick:()=>xe(e=>!e),sx:{width:20,flexShrink:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",cursor:"pointer",borderRight:"1px solid #e5e7eb",borderLeft:"1px solid #e5e7eb",bgcolor:"#f9fafb",position:"relative",py:2,"&:hover":{bgcolor:"#f0f0f0"},...V?.collapseStrip},children:i(c,{sx:{fontSize:10,fontWeight:600,color:"#6b7280",writingMode:"vertical-rl",textOrientation:"mixed",transform:"rotate(180deg)",letterSpacing:"0.05em",userSelect:"none"},children:"SPB Details"})}),L&&N&&i(l,{onClick:()=>xe(e=>!e),onMouseDown:e=>{e.preventDefault(),ge.current=!0;const i=e=>{if(!ge.current||!ue.current)return;const o=ue.current.getBoundingClientRect(),n=o.left,r=o.width,l=e.clientX-n;if(l<200)return xe(!0),ge.current=!1,document.removeEventListener("mousemove",i),void document.removeEventListener("mouseup",t);l>.7*r||(xe(!1),me(l))},t=()=>{ge.current=!1,document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",t)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",t)},sx:{position:"absolute",left:pe?20:fe+20,top:"50%",transform:"translateY(-50%)",width:18,height:28,bgcolor:"#fff",border:"1px solid #e5e7eb",borderRadius:"0 6px 6px 0",display:"flex",alignItems:"center",justifyContent:"center",cursor:"col-resize",zIndex:5,boxShadow:"2px 0 4px rgba(0,0,0,0.06)","&:hover":{bgcolor:"#f9fafb"},...V?.dragHandle},children:i(pe?w:v,{sx:{fontSize:12,color:"#6b7280"}})}),L&&e(l,{sx:{flex:1,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden",p:2,gap:1.5,bgcolor:"#f8fafc",...V?.codePanel},children:[e(l,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0,...V?.codePanelHeader},children:[i(c,{sx:{fontSize:13,fontWeight:600,color:"#374151",...V?.codePanelTitle},children:A||"SPB Analysis"}),e(l,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[Y&&i(f,{checked:de,onChange:e=>ae(e.target.checked),size:"small",sx:{width:36,height:20,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"2px","&.Mui-checked":{transform:"translateX(16px)",color:"#fff","& + .MuiSwitch-track":{bgcolor:"#5928ed",opacity:1}}},"& .MuiSwitch-thumb":{width:16,height:16,bgcolor:"#fff"},"& .MuiSwitch-track":{borderRadius:10,bgcolor:"#d1d5db",opacity:1}}}),G&&X&&i(p,{title:"Fullscreen",placement:"top",children:i(x,{size:"small",onClick:()=>he({ref:ie||"",description:""}),sx:{color:"#6b7280"},children:i(b,{sx:{fontSize:16}})})})]})]}),i(l,{sx:{flex:1,minHeight:0,border:"1px solid #30363d",borderRadius:1,overflow:"hidden",...V?.editorContainer},children:i(E,{content:C,selectedTag:ie,isDarkMode:de,height:"100%",fontSize:13,highlightVariable:oe,highlightNonce:re})})]})]}),X&&e(m,{open:!!se,onClose:()=>he(null),maxWidth:!1,PaperProps:{sx:{width:"82vw",height:"80vh",maxWidth:"none",borderRadius:"12px",overflow:"hidden",display:"flex",flexDirection:"column",...V?.fullscreenModal}},children:[e(l,{sx:{px:2.5,py:1.5,borderBottom:"1px solid #E5E7EB",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[i(c,{sx:{fontWeight:700,fontSize:"1rem",color:"#111827"},children:"Promptemon"}),i(x,{size:"small",onClick:()=>he(null),children:i(y,{sx:{fontSize:"1.1rem",color:"#6B7280"}})})]}),e(l,{sx:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[e(l,{sx:{width:"40%",flexShrink:0,borderRight:"1px solid #E5E7EB",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e(l,{sx:{px:2,py:1.25,borderBottom:"1px solid #E5E7EB",display:"flex",alignItems:"center",gap:1},children:[i(p,{title:"Atomic Prompt Block",placement:"top",children:i(g,{label:"APB",size:"small",sx:{bgcolor:"#f1f5f9",color:"#475569",fontWeight:700,fontSize:10,height:20,borderRadius:1}})}),i(c,{sx:{fontWeight:600,fontSize:"0.9rem",color:"#111827"},children:se?.ref})]}),e(l,{sx:{flex:1,p:2,display:"flex",flexDirection:"column",gap:1.5,overflowY:"auto"},children:[e(l,{sx:{border:"1px solid #E5E7EB",borderRadius:"8px",p:1.5},children:[i(c,{sx:{fontWeight:600,fontSize:"0.8rem",color:"#111827",mb:.75},children:"Description"}),i(c,{sx:{fontSize:"0.73rem",color:"#6B7280",lineHeight:1.6},children:se?.description})]}),e(l,{sx:{border:"1px solid #E5E7EB",borderRadius:"8px",p:1.25,display:"flex",alignItems:"center",gap:.5},children:[i(c,{sx:{fontSize:"0.73rem",color:"#6B7280"},children:"Total Lines"}),i(c,{sx:{fontSize:"0.73rem",fontWeight:700,color:"#111827"},children:C.split("\n").length})]})]})]}),e(l,{sx:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e(l,{sx:{px:2,py:1.25,borderBottom:"1px solid #E5E7EB",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[i(c,{sx:{fontWeight:600,fontSize:"0.85rem",color:"#111827"},children:"Prompt Preview"}),i(f,{checked:de,onChange:e=>ae(e.target.checked),size:"small",sx:{width:36,height:20,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"2px","&.Mui-checked":{transform:"translateX(16px)",color:"#fff","& + .MuiSwitch-track":{bgcolor:"#5928ed",opacity:1}}},"& .MuiSwitch-thumb":{width:16,height:16,bgcolor:"#fff"},"& .MuiSwitch-track":{borderRadius:10,bgcolor:"#d1d5db",opacity:1}}})]}),i(l,{sx:{flex:1,minHeight:0,p:1.5},children:i(E,{content:C,selectedTag:ie,isDarkMode:de,highlightVariable:oe,height:"100%",fontSize:13,highlightNonce:re})})]})]})]})]})};export{C as default};
2
2
  //# sourceMappingURL=Spbanalysispanel.js.map