@mcp-graph-workflow/mcp-graph 5.31.1 → 5.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +2 -0
- package/dist/api/router.js.map +1 -1
- package/dist/api/routes/davinci.d.ts +3 -0
- package/dist/api/routes/davinci.d.ts.map +1 -0
- package/dist/api/routes/davinci.js +188 -0
- package/dist/api/routes/davinci.js.map +1 -0
- package/dist/api/routes/translation-project.js +2 -2
- package/dist/api/routes/translation-project.js.map +1 -1
- package/dist/api/routes/translation.js +2 -2
- package/dist/api/routes/translation.js.map +1 -1
- package/dist/core/davinci/build-runner.d.ts +37 -0
- package/dist/core/davinci/build-runner.d.ts.map +1 -0
- package/dist/core/davinci/build-runner.js +239 -0
- package/dist/core/davinci/build-runner.js.map +1 -0
- package/dist/core/davinci/davinci-parser.d.ts +6 -0
- package/dist/core/davinci/davinci-parser.d.ts.map +1 -0
- package/dist/core/davinci/davinci-parser.js +218 -0
- package/dist/core/davinci/davinci-parser.js.map +1 -0
- package/dist/core/davinci/davinci-store.d.ts +49 -0
- package/dist/core/davinci/davinci-store.d.ts.map +1 -0
- package/dist/core/davinci/davinci-store.js +121 -0
- package/dist/core/davinci/davinci-store.js.map +1 -0
- package/dist/core/davinci/davinci-types.d.ts +241 -0
- package/dist/core/davinci/davinci-types.d.ts.map +1 -0
- package/dist/core/davinci/davinci-types.js +123 -0
- package/dist/core/davinci/davinci-types.js.map +1 -0
- package/dist/core/davinci/davinci-validators.d.ts +16 -0
- package/dist/core/davinci/davinci-validators.d.ts.map +1 -0
- package/dist/core/davinci/davinci-validators.js +86 -0
- package/dist/core/davinci/davinci-validators.js.map +1 -0
- package/dist/core/davinci/descriptor-generator.d.ts +19 -0
- package/dist/core/davinci/descriptor-generator.d.ts.map +1 -0
- package/dist/core/davinci/descriptor-generator.js +52 -0
- package/dist/core/davinci/descriptor-generator.js.map +1 -0
- package/dist/core/davinci/plugin-generator.d.ts +29 -0
- package/dist/core/davinci/plugin-generator.d.ts.map +1 -0
- package/dist/core/davinci/plugin-generator.js +86 -0
- package/dist/core/davinci/plugin-generator.js.map +1 -0
- package/dist/core/davinci/plugin-type-detector.d.ts +15 -0
- package/dist/core/davinci/plugin-type-detector.d.ts.map +1 -0
- package/dist/core/davinci/plugin-type-detector.js +114 -0
- package/dist/core/davinci/plugin-type-detector.js.map +1 -0
- package/dist/core/davinci/pom-generator.d.ts +4 -0
- package/dist/core/davinci/pom-generator.d.ts.map +1 -0
- package/dist/core/davinci/pom-generator.js +179 -0
- package/dist/core/davinci/pom-generator.js.map +1 -0
- package/dist/core/davinci/template-registry.d.ts +25 -0
- package/dist/core/davinci/template-registry.d.ts.map +1 -0
- package/dist/core/davinci/template-registry.js +280 -0
- package/dist/core/davinci/template-registry.js.map +1 -0
- package/dist/core/davinci/variable-resolver.d.ts +9 -0
- package/dist/core/davinci/variable-resolver.d.ts.map +1 -0
- package/dist/core/davinci/variable-resolver.js +62 -0
- package/dist/core/davinci/variable-resolver.js.map +1 -0
- package/dist/core/parser/read-swagger.d.ts.map +1 -1
- package/dist/core/parser/read-swagger.js +6 -0
- package/dist/core/parser/read-swagger.js.map +1 -1
- package/dist/core/siebel/sif-parser.d.ts.map +1 -1
- package/dist/core/siebel/sif-parser.js +6 -0
- package/dist/core/siebel/sif-parser.js.map +1 -1
- package/dist/core/siebel/wsdl-parser.d.ts.map +1 -1
- package/dist/core/siebel/wsdl-parser.js +6 -0
- package/dist/core/siebel/wsdl-parser.js.map +1 -1
- package/dist/core/translation/generators/ast-placeholder-extractor.d.ts +20 -0
- package/dist/core/translation/generators/ast-placeholder-extractor.d.ts.map +1 -0
- package/dist/core/translation/generators/ast-placeholder-extractor.js +215 -0
- package/dist/core/translation/generators/ast-placeholder-extractor.js.map +1 -0
- package/dist/core/translation/generators/placeholder-resolver.d.ts +18 -0
- package/dist/core/translation/generators/placeholder-resolver.d.ts.map +1 -0
- package/dist/core/translation/generators/placeholder-resolver.js +487 -0
- package/dist/core/translation/generators/placeholder-resolver.js.map +1 -0
- package/dist/core/translation/generators/source-text-extractor.d.ts +20 -0
- package/dist/core/translation/generators/source-text-extractor.d.ts.map +1 -0
- package/dist/core/translation/generators/source-text-extractor.js +190 -0
- package/dist/core/translation/generators/source-text-extractor.js.map +1 -0
- package/dist/core/translation/generators/universal-generator.d.ts +23 -0
- package/dist/core/translation/generators/universal-generator.d.ts.map +1 -0
- package/dist/core/translation/generators/universal-generator.js +315 -0
- package/dist/core/translation/generators/universal-generator.js.map +1 -0
- package/dist/core/translation/language-detect.d.ts.map +1 -1
- package/dist/core/translation/language-detect.js +37 -14
- package/dist/core/translation/language-detect.js.map +1 -1
- package/dist/core/translation/parsers/parser-adapter.d.ts +4 -0
- package/dist/core/translation/parsers/parser-adapter.d.ts.map +1 -1
- package/dist/core/translation/project-translation-orchestrator.d.ts +3 -3
- package/dist/core/translation/project-translation-orchestrator.d.ts.map +1 -1
- package/dist/core/translation/project-translation-orchestrator.js +4 -4
- package/dist/core/translation/project-translation-orchestrator.js.map +1 -1
- package/dist/core/translation/prompt-builder.d.ts +4 -0
- package/dist/core/translation/prompt-builder.d.ts.map +1 -1
- package/dist/core/translation/prompt-builder.js +13 -3
- package/dist/core/translation/prompt-builder.js.map +1 -1
- package/dist/core/translation/translation-orchestrator.d.ts +2 -1
- package/dist/core/translation/translation-orchestrator.d.ts.map +1 -1
- package/dist/core/translation/translation-orchestrator.js +21 -2
- package/dist/core/translation/translation-orchestrator.js.map +1 -1
- package/dist/docs-manifest.json +64 -2
- package/dist/mcp/app-factory.js +1 -1
- package/dist/mcp/app-factory.js.map +1 -1
- package/dist/mcp/tools/davinci-analyze.d.ts +4 -0
- package/dist/mcp/tools/davinci-analyze.d.ts.map +1 -0
- package/dist/mcp/tools/davinci-analyze.js +31 -0
- package/dist/mcp/tools/davinci-analyze.js.map +1 -0
- package/dist/mcp/tools/davinci-build.d.ts +4 -0
- package/dist/mcp/tools/davinci-build.d.ts.map +1 -0
- package/dist/mcp/tools/davinci-build.js +43 -0
- package/dist/mcp/tools/davinci-build.js.map +1 -0
- package/dist/mcp/tools/davinci-convert.d.ts +4 -0
- package/dist/mcp/tools/davinci-convert.d.ts.map +1 -0
- package/dist/mcp/tools/davinci-convert.js +61 -0
- package/dist/mcp/tools/davinci-convert.js.map +1 -0
- package/dist/mcp/tools/index.d.ts.map +1 -1
- package/dist/mcp/tools/index.js +8 -0
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/mcp/tools/translate-code.js +1 -1
- package/dist/mcp/tools/translate-code.js.map +1 -1
- package/dist/web/dashboard/dist/assets/{benchmark-tab-GHO9Ji5M.js → benchmark-tab-BezNQCQh.js} +1 -1
- package/dist/web/dashboard/dist/assets/{circle-alert-CfDAmNcO.js → circle-alert-DKsqBTgC.js} +1 -1
- package/dist/web/dashboard/dist/assets/{context-tab-B_6B65lw.js → context-tab-Cmar9i-X.js} +1 -1
- package/dist/web/dashboard/dist/assets/davinci-tab-CkWYkDsy.js +10 -0
- package/dist/web/dashboard/dist/assets/{docs-tab-Dq7rtZol.js → docs-tab-CYpDJ3Rl.js} +1 -1
- package/dist/web/dashboard/dist/assets/file-code-B0t0xVTk.js +11 -0
- package/dist/web/dashboard/dist/assets/{gitnexus-tab-DAPpyAe_.js → gitnexus-tab-COEhhMeC.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-section-O0mwo9kz.js → graph-section-CheOuwv_.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-tab-CAx8lu7Z.js → graph-tab-B52UV5KP.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-utils-BwdXFM9h.js → graph-utils-D5HpaYbf.js} +1 -1
- package/dist/web/dashboard/dist/assets/{index-f0wNMEe_.js → index--SYA0Gq0.js} +1 -1
- package/dist/web/dashboard/dist/assets/index-BcMjWikL.css +1 -0
- package/dist/web/dashboard/dist/assets/{index-BxYtgAYc.js → index-DFMBuNWV.js} +1 -1
- package/dist/web/dashboard/dist/assets/{index-D_SBClB-.js → index-DdenFaJ5.js} +24 -19
- package/dist/web/dashboard/dist/assets/{insights-tab-DfH4O_Gj.js → insights-tab-sPgv-iwt.js} +1 -1
- package/dist/web/dashboard/dist/assets/{journey-tab-D2_EXArZ.js → journey-tab-CS416bwg.js} +1 -1
- package/dist/web/dashboard/dist/assets/languages-tab-CcB_s-Ic.js +108 -0
- package/dist/web/dashboard/dist/assets/{loader-circle-D5Z5DuF4.js → loader-circle-BSNUICqd.js} +1 -1
- package/dist/web/dashboard/dist/assets/{logs-tab-DwVCJxNs.js → logs-tab-BbDXtvmz.js} +1 -1
- package/dist/web/dashboard/dist/assets/{lsp-tab-D_3asNom.js → lsp-tab-BrytF6mP.js} +3 -3
- package/dist/web/dashboard/dist/assets/{memories-tab-BVe3nUf6.js → memories-tab-qCFdXJIV.js} +1 -1
- package/dist/web/dashboard/dist/assets/{prd-backlog-tab-DmeNjNES.js → prd-backlog-tab-BiNvyICT.js} +1 -1
- package/dist/web/dashboard/dist/assets/{refresh-cw-dY_ihv6e.js → refresh-cw-CqVWFFCW.js} +1 -1
- package/dist/web/dashboard/dist/assets/{siebel-tab-CUO3fUiF.js → siebel-tab-DFNHIBbS.js} +3 -3
- package/dist/web/dashboard/dist/assets/{sif-parse.worker-DZrybOHz.js → sif-parse.worker-Cty_N-lP.js} +3 -3
- package/dist/web/dashboard/dist/assets/{skills-tab-lUKwXrZi.js → skills-tab-DlInZCyj.js} +1 -1
- package/dist/web/dashboard/dist/assets/{style-Chqa3iIg.js → style-B4jQtUGE.js} +1 -1
- package/dist/web/dashboard/dist/assets/triangle-alert-CqXtIU3H.js +16 -0
- package/dist/web/dashboard/dist/assets/upload-Cb3pIYT5.js +16 -0
- package/dist/web/dashboard/dist/index.html +2 -2
- package/package.json +2 -2
- package/dist/web/dashboard/dist/assets/index-BVhCKhGJ.css +0 -1
- package/dist/web/dashboard/dist/assets/languages-tab-Cs-EF0mT.js +0 -123
- package/dist/web/dashboard/dist/assets/triangle-alert-CkVvjxDP.js +0 -26
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-section-
|
|
2
|
-
import{r as s,j as e,a as S,_ as L}from"./index-D_SBClB-.js";import{e as k}from"./constants-Dd6A34aQ.js";const D=[{id:"upload",label:"Upload",icon:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"},{id:"objects",label:"Objects",icon:"M3.75 12h16.5m-16.5 3.75h16.5M3.75 19.5h16.5M5.625 4.5h12.75a1.875 1.875 0 010 3.75H5.625a1.875 1.875 0 010-3.75z"},{id:"graph",label:"Graph",icon:"M7.5 14.25v2.25m3-4.5v4.5m3-6.75v6.75m3-9v9M6 20.25h12A2.25 2.25 0 0020.25 18V6A2.25 2.25 0 0018 3.75H6A2.25 2.25 0 003.75 6v12A2.25 2.25 0 006 20.25z"},{id:"generation",label:"Generation",icon:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456z"}],T=s.memo(function({activeSection:t,onSectionChange:a,objectCount:d}){return e.jsxs("nav",{className:"w-48 flex-shrink-0 border-r border-edge bg-surface-alt flex flex-col","aria-label":"Siebel sections",children:[e.jsx("div",{className:"px-3 py-3 border-b border-edge",children:e.jsx("h2",{className:"text-xs font-semibold uppercase text-muted tracking-wider",children:"Siebel"})}),e.jsx("div",{className:"flex-1 py-1",children:D.map(u=>e.jsxs("button",{onClick:()=>a(u.id),"aria-label":`Navigate to ${u.label}`,className:`w-full flex items-center gap-2.5 px-3 py-2 text-xs font-medium transition-colors cursor-pointer ${t===u.id?"bg-accent/10 text-accent border-r-2 border-accent":"text-muted hover:text-foreground hover:bg-surface"}`,children:[e.jsx("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:u.icon})}),e.jsx("span",{children:u.label}),u.id==="objects"&&d>0&&e.jsx("span",{className:"ml-auto text-[10px] px-1.5 py-0.5 rounded-full bg-surface text-muted",children:d})]},u.id))})]})});function E(){const[o,t]=s.useState([]),[a,d]=s.useState([]),[u,x]=s.useState(!0),[b,h]=s.useState(null),c=s.useCallback(async()=>{try{x(!0),h(null);const[m,l]=await Promise.all([S.siebelGetObjects({limit:100}).catch(()=>({objects:[],total:0})),S.siebelGetTemplates().catch(()=>({templates:[]}))]);t(m.objects),d(l.templates)}catch(m){h(m instanceof Error?m.message:"Failed to load Siebel data")}finally{x(!1)}},[]);return s.useEffect(()=>{c()},[c]),{objects:o,templates:a,loading:u,error:b,refresh:c}}function P(o){const[t,a]=s.useState(""),[d,u]=s.useState(["business_component"]),[x,b]=s.useState(""),[h,c]=s.useState(null),[m,l]=s.useState(""),[n,i]=s.useState(null),[g,v]=s.useState(!1),N=s.useCallback(f=>{u(y=>y.includes(f)?y.filter(w=>w!==f):[...y,f])},[]),j=s.useCallback(async()=>{if(t.trim()){v(!0),i(null);try{const f=await S.siebelPrepareGeneration({description:t,objectTypes:d,basedOnProject:x||void 0});c(f.prompt)}catch(f){c(`Error: ${f instanceof Error?f.message:String(f)}`)}finally{v(!1)}}},[t,d,x]),r=s.useCallback(async()=>{if(m.trim()){v(!0);try{const f=await S.siebelFinalizeGeneration({generatedXml:m,description:t,objectTypes:d});i(f),o==null||o()}catch(f){i({sifContent:"",objects:[],validation:{status:"invalid",messages:[{level:"error",message:f instanceof Error?f.message:String(f)}],score:0},metadata:{generatedAt:new Date().toISOString(),requestDescription:t,objectCount:0}})}finally{v(!1)}}},[m,t,d,o]),p=s.useCallback(()=>{if(!(n!=null&&n.sifContent))return;const f=new Blob([n.sifContent],{type:"application/xml"}),y=URL.createObjectURL(f),w=document.createElement("a");w.href=y,w.download="generated.sif",w.click(),URL.revokeObjectURL(y)},[n]);return{description:t,setDescription:a,selectedTypes:d,toggleType:N,project:x,setProject:b,prompt:h,xml:m,setXml:l,result:n,loading:g,prepare:j,finalize:r,download:p}}function I(){const[o,t]=s.useState(null),[a,d]=s.useState(0),[u,x]=s.useState("idle"),[b,h]=s.useState(null),c=s.useRef(null);s.useEffect(()=>()=>{var n;(n=c.current)==null||n.terminate()},[]);const m=s.useCallback(n=>{t(null),h(null),d(0),x("reading"),n.text().then(i=>{var v;d(10),x("parsing"),(v=c.current)==null||v.terminate();const g=new Worker(new URL("/assets/sif-parse.worker-DZrybOHz.js",import.meta.url),{type:"module"});c.current=g,g.onmessage=N=>{const j=N.data;j.type==="progress"?(d(j.progress),x(j.status)):j.type==="result"?(t(j.data),x("done"),d(100),g.terminate(),c.current=null):j.type==="error"&&(h(j.message),x("error"),g.terminate(),c.current=null)},g.onerror=N=>{h(N.message||"Worker error"),x("error"),g.terminate(),c.current=null},g.postMessage({type:"parse",content:i,fileName:n.name})}).catch(i=>{h(i instanceof Error?i.message:"Failed to read file"),x("error")})},[]),l=s.useCallback(()=>{var n;(n=c.current)==null||n.terminate(),c.current=null,t(null),d(0),x("idle"),h(null)},[]);return{parse:m,result:o,progress:a,status:u,error:b,reset:l}}const F={idle:"",reading:"Reading file...",parsing:"Parsing XML...",extracting:"Extracting objects...",inferring:"Inferring dependencies...",done:"Done!",error:"Error"},R=s.memo(function({status:t,progress:a,error:d}){if(t==="idle")return null;const u=t==="error",x=t==="done";return e.jsxs("div",{className:"space-y-1.5",role:"status","aria-live":"polite",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:u?"text-red-500":x?"text-green-500":"text-muted",children:u?d:F[t]}),!u&&e.jsxs("span",{className:"text-[10px] text-muted",children:[a,"%"]})]}),!u&&e.jsx("div",{className:"h-1.5 rounded-full bg-surface overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-300 ${x?"bg-green-500":"bg-accent"}`,style:{width:`${a}%`}})})]})});function $({onUploaded:o}){const[t,a]=s.useState(null),[d,u]=s.useState(!1),[x,b]=s.useState(!1),h=s.useRef(null),c=s.useRef(null),m=I();s.useEffect(()=>{if(m.status!=="done"||!m.result)return;const r=m.result.metadata.fileName;(async()=>{try{l.current&&(await S.siebelImportSif(l.current,r,!0),l.current=null,o())}catch{}})()},[m.status,m.result,o]);const l=s.useRef(null),n=s.useCallback(r=>{r.text().then(p=>{l.current=p,m.parse(r)}).catch(()=>{(async()=>{try{const p=await r.text();await S.siebelImportSif(p,r.name,!0),o()}catch{}})()})},[m,o]),i=s.useCallback(async r=>{try{a("Uploading documentation...");const p=await S.siebelUploadDocs(r);a(`Indexed: ${p.fileName} (${p.chunksIndexed} chunks)`),o()}catch(p){a(`Error: ${p instanceof Error?p.message:String(p)}`)}},[o]),g=s.useCallback(r=>{var f;const p=(f=r.target.files)==null?void 0:f[0];p&&n(p),h.current&&(h.current.value="")},[n]),v=s.useCallback(r=>{var f;const p=(f=r.target.files)==null?void 0:f[0];p&&i(p),c.current&&(c.current.value="")},[i]),N=s.useCallback((r,p,f)=>{r.preventDefault(),f(!1);const y=r.dataTransfer.files[0];y&&p(y)},[]),j=s.useCallback(r=>{r.preventDefault(),r.stopPropagation()},[]);return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",children:"Upload & Context"}),e.jsx("p",{className:"text-xs text-muted",children:"Upload SIF files and documentation to build RAG context for generation"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer ${d?"border-accent bg-accent/5":"border-edge hover:border-accent/50"}`,onDragEnter:r=>{j(r),u(!0)},onDragOver:r=>{j(r),u(!0)},onDragLeave:r=>{j(r),u(!1)},onDrop:r=>N(r,n,u),onClick:()=>{var r;return(r=h.current)==null?void 0:r.click()},role:"button",tabIndex:0,onKeyDown:r=>{var p;(r.key==="Enter"||r.key===" ")&&((p=h.current)==null||p.click())},"aria-label":"Upload SIF file",children:[e.jsx("input",{ref:h,type:"file",accept:".sif,.xml",onChange:g,className:"hidden",tabIndex:-1}),e.jsx("svg",{className:"w-8 h-8 mx-auto mb-2 text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m6.75 12l-3-3m0 0l-3 3m3-3v6m-1.5-15H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),e.jsx("p",{className:"text-xs font-medium",children:"SIF File (.sif, .xml)"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"Drop here or click to browse"})]}),e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer ${x?"border-accent bg-accent/5":"border-edge hover:border-accent/50"}`,onDragEnter:r=>{j(r),b(!0)},onDragOver:r=>{j(r),b(!0)},onDragLeave:r=>{j(r),b(!1)},onDrop:r=>N(r,i,b),onClick:()=>{var r;return(r=c.current)==null?void 0:r.click()},role:"button",tabIndex:0,onKeyDown:r=>{var p;(r.key==="Enter"||r.key===" ")&&((p=c.current)==null||p.click())},"aria-label":"Upload documentation file",children:[e.jsx("input",{ref:c,type:"file",accept:".pdf,.html,.htm,.txt,.md,.doc,.docx",onChange:v,className:"hidden",tabIndex:-1}),e.jsx("svg",{className:"w-8 h-8 mx-auto mb-2 text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25"})}),e.jsx("p",{className:"text-xs font-medium",children:"Documentation"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"PDF, HTML, DOC, DOCX, TXT, MD"})]})]}),m.status!=="idle"&&e.jsx(R,{status:m.status,progress:m.progress,error:m.error}),t&&e.jsx("div",{className:`px-3 py-2 rounded-md text-xs ${t.startsWith("Error")?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-500"}`,role:"status","aria-live":"polite",children:t})]})}const C=36;function M({objects:o}){const[t,a]=s.useState(""),[d,u]=s.useState(new Set),x=s.useDeferredValue(t),b=s.useDeferredValue(d),h=s.useMemo(()=>{const l=new Set;for(const n of o)n.siebelType&&l.add(n.siebelType);return[...l].sort()},[o]),c=s.useMemo(()=>{let l=o;if(x){const n=x.toLowerCase();l=l.filter(i=>{var g;return i.title.toLowerCase().includes(n)||((g=i.siebelProject)==null?void 0:g.toLowerCase().includes(n))||i.contentPreview.toLowerCase().includes(n)})}return b.size>0&&(l=l.filter(n=>n.siebelType&&b.has(n.siebelType))),l},[o,x,b]),m=l=>{u(n=>{const i=new Set(n);return i.has(l)?i.delete(l):i.add(l),i})};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"p-4 space-y-3 border-b border-edge",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h3",{className:"text-sm font-semibold",children:["Indexed Siebel Objects",e.jsxs("span",{className:"ml-2 text-xs font-normal text-muted",children:[c.length,c.length!==o.length?` / ${o.length}`:""," objects"]})]})}),e.jsx("input",{type:"text",value:t,onChange:l=>a(l.target.value),placeholder:"Search objects...","aria-label":"Search Siebel objects",className:"w-full px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"}),h.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:h.map(l=>{const n=k[l]||"#6b7280",i=d.has(l);return e.jsx("button",{onClick:()=>m(l),"aria-label":`Filter by ${l}`,"aria-pressed":i,className:"px-2 py-0.5 text-[10px] rounded-md border transition-colors cursor-pointer",style:{borderColor:i?n:"var(--color-border)",backgroundColor:i?`${n}15`:"transparent",color:i?n:"var(--color-text-muted)"},children:l.replace(/_/g," ")},l)})})]}),c.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-muted",children:o.length===0?"No Siebel objects indexed yet. Upload a .sif file.":"No objects match the current filters."}):e.jsx("div",{className:"flex-1 overflow-auto",style:{contentVisibility:"auto",containIntrinsicSize:`0 ${c.length*C}px`},children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-alt z-10",children:e.jsxs("tr",{className:"border-b border-edge",children:[e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Name"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Type"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Project"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Preview"})]})}),e.jsx("tbody",{children:c.map((l,n)=>{const i=k[l.siebelType??""]||"#6b7280";return e.jsxs("tr",{className:"border-b border-edge hover:bg-surface transition-colors",style:{height:C},children:[e.jsx("td",{className:"px-4 py-1.5 font-mono",children:l.title}),e.jsx("td",{className:"px-4 py-1.5",children:e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{backgroundColor:`${i}15`,color:i},children:l.siebelType??l.sourceType})}),e.jsx("td",{className:"px-4 py-1.5 text-muted",children:l.siebelProject??"-"}),e.jsx("td",{className:"px-4 py-1.5 text-muted truncate max-w-xs",children:l.contentPreview})]},n)})})]})})]})}function O({templates:o,gen:t}){return e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",children:"SIF Generation"}),e.jsx("p",{className:"text-xs text-muted",children:"Describe what you need, generate context for the LLM, then validate the output"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-description",children:"Description"}),e.jsx("textarea",{id:"gen-description",value:t.description,onChange:a=>t.setDescription(a.target.value),placeholder:"e.g., Create a Business Component for Service Requests with fields: SR Number, Status, Priority",rows:3,className:"w-full px-3 py-2 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1.5",children:"Object Types"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:o.map(a=>e.jsx("button",{onClick:()=>t.toggleType(a.type),"aria-label":`Toggle ${a.type}`,"aria-pressed":t.selectedTypes.includes(a.type),className:`px-2 py-1 text-[10px] rounded-md border transition-colors cursor-pointer ${t.selectedTypes.includes(a.type)?"bg-accent text-white border-accent":"bg-transparent text-muted border-edge hover:border-accent"}`,children:a.type.replace(/_/g," ")},a.type))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-project",children:"Base Project (optional)"}),e.jsx("input",{id:"gen-project",value:t.project,onChange:a=>t.setProject(a.target.value),placeholder:"e.g., Account (SSE)",className:"w-full px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"})]}),e.jsx("button",{onClick:t.prepare,disabled:!t.description.trim()||t.loading,className:"px-4 py-1.5 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 disabled:opacity-50 transition-opacity cursor-pointer disabled:cursor-not-allowed",children:t.loading&&!t.prompt?"Generating Context...":"Generate Context & Prompt"}),t.prompt&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"text-xs font-medium",children:"Generated Prompt (copy to LLM)"}),e.jsx("button",{onClick:()=>navigator.clipboard.writeText(t.prompt??""),"aria-label":"Copy prompt to clipboard",className:"text-[10px] px-2 py-0.5 rounded bg-surface text-muted hover:text-foreground border border-edge cursor-pointer transition-colors",children:"Copy"})]}),e.jsxs("pre",{className:"text-[10px] p-3 rounded-md bg-surface border border-edge max-h-48 overflow-auto whitespace-pre-wrap text-muted",children:[t.prompt.slice(0,3e3),t.prompt.length>3e3&&`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-section-CheOuwv_.js","assets/index-DdenFaJ5.js","assets/index-BcMjWikL.css","assets/style-B4jQtUGE.js","assets/index-DFMBuNWV.js","assets/style-BZV40eAE.css","assets/constants-Dd6A34aQ.js","assets/index--SYA0Gq0.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as s,j as e,a as S,_ as L}from"./index-DdenFaJ5.js";import{e as k}from"./constants-Dd6A34aQ.js";const D=[{id:"upload",label:"Upload",icon:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"},{id:"objects",label:"Objects",icon:"M3.75 12h16.5m-16.5 3.75h16.5M3.75 19.5h16.5M5.625 4.5h12.75a1.875 1.875 0 010 3.75H5.625a1.875 1.875 0 010-3.75z"},{id:"graph",label:"Graph",icon:"M7.5 14.25v2.25m3-4.5v4.5m3-6.75v6.75m3-9v9M6 20.25h12A2.25 2.25 0 0020.25 18V6A2.25 2.25 0 0018 3.75H6A2.25 2.25 0 003.75 6v12A2.25 2.25 0 006 20.25z"},{id:"generation",label:"Generation",icon:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456z"}],T=s.memo(function({activeSection:t,onSectionChange:a,objectCount:d}){return e.jsxs("nav",{className:"w-48 flex-shrink-0 border-r border-edge bg-surface-alt flex flex-col","aria-label":"Siebel sections",children:[e.jsx("div",{className:"px-3 py-3 border-b border-edge",children:e.jsx("h2",{className:"text-xs font-semibold uppercase text-muted tracking-wider",children:"Siebel"})}),e.jsx("div",{className:"flex-1 py-1",children:D.map(u=>e.jsxs("button",{onClick:()=>a(u.id),"aria-label":`Navigate to ${u.label}`,className:`w-full flex items-center gap-2.5 px-3 py-2 text-xs font-medium transition-colors cursor-pointer ${t===u.id?"bg-accent/10 text-accent border-r-2 border-accent":"text-muted hover:text-foreground hover:bg-surface"}`,children:[e.jsx("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:u.icon})}),e.jsx("span",{children:u.label}),u.id==="objects"&&d>0&&e.jsx("span",{className:"ml-auto text-[10px] px-1.5 py-0.5 rounded-full bg-surface text-muted",children:d})]},u.id))})]})});function E(){const[o,t]=s.useState([]),[a,d]=s.useState([]),[u,x]=s.useState(!0),[b,h]=s.useState(null),c=s.useCallback(async()=>{try{x(!0),h(null);const[m,l]=await Promise.all([S.siebelGetObjects({limit:100}).catch(()=>({objects:[],total:0})),S.siebelGetTemplates().catch(()=>({templates:[]}))]);t(m.objects),d(l.templates)}catch(m){h(m instanceof Error?m.message:"Failed to load Siebel data")}finally{x(!1)}},[]);return s.useEffect(()=>{c()},[c]),{objects:o,templates:a,loading:u,error:b,refresh:c}}function P(o){const[t,a]=s.useState(""),[d,u]=s.useState(["business_component"]),[x,b]=s.useState(""),[h,c]=s.useState(null),[m,l]=s.useState(""),[n,i]=s.useState(null),[g,v]=s.useState(!1),N=s.useCallback(f=>{u(y=>y.includes(f)?y.filter(w=>w!==f):[...y,f])},[]),j=s.useCallback(async()=>{if(t.trim()){v(!0),i(null);try{const f=await S.siebelPrepareGeneration({description:t,objectTypes:d,basedOnProject:x||void 0});c(f.prompt)}catch(f){c(`Error: ${f instanceof Error?f.message:String(f)}`)}finally{v(!1)}}},[t,d,x]),r=s.useCallback(async()=>{if(m.trim()){v(!0);try{const f=await S.siebelFinalizeGeneration({generatedXml:m,description:t,objectTypes:d});i(f),o==null||o()}catch(f){i({sifContent:"",objects:[],validation:{status:"invalid",messages:[{level:"error",message:f instanceof Error?f.message:String(f)}],score:0},metadata:{generatedAt:new Date().toISOString(),requestDescription:t,objectCount:0}})}finally{v(!1)}}},[m,t,d,o]),p=s.useCallback(()=>{if(!(n!=null&&n.sifContent))return;const f=new Blob([n.sifContent],{type:"application/xml"}),y=URL.createObjectURL(f),w=document.createElement("a");w.href=y,w.download="generated.sif",w.click(),URL.revokeObjectURL(y)},[n]);return{description:t,setDescription:a,selectedTypes:d,toggleType:N,project:x,setProject:b,prompt:h,xml:m,setXml:l,result:n,loading:g,prepare:j,finalize:r,download:p}}function I(){const[o,t]=s.useState(null),[a,d]=s.useState(0),[u,x]=s.useState("idle"),[b,h]=s.useState(null),c=s.useRef(null);s.useEffect(()=>()=>{var n;(n=c.current)==null||n.terminate()},[]);const m=s.useCallback(n=>{t(null),h(null),d(0),x("reading"),n.text().then(i=>{var v;d(10),x("parsing"),(v=c.current)==null||v.terminate();const g=new Worker(new URL("/assets/sif-parse.worker-Cty_N-lP.js",import.meta.url),{type:"module"});c.current=g,g.onmessage=N=>{const j=N.data;j.type==="progress"?(d(j.progress),x(j.status)):j.type==="result"?(t(j.data),x("done"),d(100),g.terminate(),c.current=null):j.type==="error"&&(h(j.message),x("error"),g.terminate(),c.current=null)},g.onerror=N=>{h(N.message||"Worker error"),x("error"),g.terminate(),c.current=null},g.postMessage({type:"parse",content:i,fileName:n.name})}).catch(i=>{h(i instanceof Error?i.message:"Failed to read file"),x("error")})},[]),l=s.useCallback(()=>{var n;(n=c.current)==null||n.terminate(),c.current=null,t(null),d(0),x("idle"),h(null)},[]);return{parse:m,result:o,progress:a,status:u,error:b,reset:l}}const F={idle:"",reading:"Reading file...",parsing:"Parsing XML...",extracting:"Extracting objects...",inferring:"Inferring dependencies...",done:"Done!",error:"Error"},R=s.memo(function({status:t,progress:a,error:d}){if(t==="idle")return null;const u=t==="error",x=t==="done";return e.jsxs("div",{className:"space-y-1.5",role:"status","aria-live":"polite",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:u?"text-red-500":x?"text-green-500":"text-muted",children:u?d:F[t]}),!u&&e.jsxs("span",{className:"text-[10px] text-muted",children:[a,"%"]})]}),!u&&e.jsx("div",{className:"h-1.5 rounded-full bg-surface overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-300 ${x?"bg-green-500":"bg-accent"}`,style:{width:`${a}%`}})})]})});function $({onUploaded:o}){const[t,a]=s.useState(null),[d,u]=s.useState(!1),[x,b]=s.useState(!1),h=s.useRef(null),c=s.useRef(null),m=I();s.useEffect(()=>{if(m.status!=="done"||!m.result)return;const r=m.result.metadata.fileName;(async()=>{try{l.current&&(await S.siebelImportSif(l.current,r,!0),l.current=null,o())}catch{}})()},[m.status,m.result,o]);const l=s.useRef(null),n=s.useCallback(r=>{r.text().then(p=>{l.current=p,m.parse(r)}).catch(()=>{(async()=>{try{const p=await r.text();await S.siebelImportSif(p,r.name,!0),o()}catch{}})()})},[m,o]),i=s.useCallback(async r=>{try{a("Uploading documentation...");const p=await S.siebelUploadDocs(r);a(`Indexed: ${p.fileName} (${p.chunksIndexed} chunks)`),o()}catch(p){a(`Error: ${p instanceof Error?p.message:String(p)}`)}},[o]),g=s.useCallback(r=>{var f;const p=(f=r.target.files)==null?void 0:f[0];p&&n(p),h.current&&(h.current.value="")},[n]),v=s.useCallback(r=>{var f;const p=(f=r.target.files)==null?void 0:f[0];p&&i(p),c.current&&(c.current.value="")},[i]),N=s.useCallback((r,p,f)=>{r.preventDefault(),f(!1);const y=r.dataTransfer.files[0];y&&p(y)},[]),j=s.useCallback(r=>{r.preventDefault(),r.stopPropagation()},[]);return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",children:"Upload & Context"}),e.jsx("p",{className:"text-xs text-muted",children:"Upload SIF files and documentation to build RAG context for generation"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer ${d?"border-accent bg-accent/5":"border-edge hover:border-accent/50"}`,onDragEnter:r=>{j(r),u(!0)},onDragOver:r=>{j(r),u(!0)},onDragLeave:r=>{j(r),u(!1)},onDrop:r=>N(r,n,u),onClick:()=>{var r;return(r=h.current)==null?void 0:r.click()},role:"button",tabIndex:0,onKeyDown:r=>{var p;(r.key==="Enter"||r.key===" ")&&((p=h.current)==null||p.click())},"aria-label":"Upload SIF file",children:[e.jsx("input",{ref:h,type:"file",accept:".sif,.xml",onChange:g,className:"hidden",tabIndex:-1}),e.jsx("svg",{className:"w-8 h-8 mx-auto mb-2 text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m6.75 12l-3-3m0 0l-3 3m3-3v6m-1.5-15H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),e.jsx("p",{className:"text-xs font-medium",children:"SIF File (.sif, .xml)"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"Drop here or click to browse"})]}),e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer ${x?"border-accent bg-accent/5":"border-edge hover:border-accent/50"}`,onDragEnter:r=>{j(r),b(!0)},onDragOver:r=>{j(r),b(!0)},onDragLeave:r=>{j(r),b(!1)},onDrop:r=>N(r,i,b),onClick:()=>{var r;return(r=c.current)==null?void 0:r.click()},role:"button",tabIndex:0,onKeyDown:r=>{var p;(r.key==="Enter"||r.key===" ")&&((p=c.current)==null||p.click())},"aria-label":"Upload documentation file",children:[e.jsx("input",{ref:c,type:"file",accept:".pdf,.html,.htm,.txt,.md,.doc,.docx",onChange:v,className:"hidden",tabIndex:-1}),e.jsx("svg",{className:"w-8 h-8 mx-auto mb-2 text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25"})}),e.jsx("p",{className:"text-xs font-medium",children:"Documentation"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"PDF, HTML, DOC, DOCX, TXT, MD"})]})]}),m.status!=="idle"&&e.jsx(R,{status:m.status,progress:m.progress,error:m.error}),t&&e.jsx("div",{className:`px-3 py-2 rounded-md text-xs ${t.startsWith("Error")?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-500"}`,role:"status","aria-live":"polite",children:t})]})}const C=36;function M({objects:o}){const[t,a]=s.useState(""),[d,u]=s.useState(new Set),x=s.useDeferredValue(t),b=s.useDeferredValue(d),h=s.useMemo(()=>{const l=new Set;for(const n of o)n.siebelType&&l.add(n.siebelType);return[...l].sort()},[o]),c=s.useMemo(()=>{let l=o;if(x){const n=x.toLowerCase();l=l.filter(i=>{var g;return i.title.toLowerCase().includes(n)||((g=i.siebelProject)==null?void 0:g.toLowerCase().includes(n))||i.contentPreview.toLowerCase().includes(n)})}return b.size>0&&(l=l.filter(n=>n.siebelType&&b.has(n.siebelType))),l},[o,x,b]),m=l=>{u(n=>{const i=new Set(n);return i.has(l)?i.delete(l):i.add(l),i})};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"p-4 space-y-3 border-b border-edge",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h3",{className:"text-sm font-semibold",children:["Indexed Siebel Objects",e.jsxs("span",{className:"ml-2 text-xs font-normal text-muted",children:[c.length,c.length!==o.length?` / ${o.length}`:""," objects"]})]})}),e.jsx("input",{type:"text",value:t,onChange:l=>a(l.target.value),placeholder:"Search objects...","aria-label":"Search Siebel objects",className:"w-full px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"}),h.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:h.map(l=>{const n=k[l]||"#6b7280",i=d.has(l);return e.jsx("button",{onClick:()=>m(l),"aria-label":`Filter by ${l}`,"aria-pressed":i,className:"px-2 py-0.5 text-[10px] rounded-md border transition-colors cursor-pointer",style:{borderColor:i?n:"var(--color-border)",backgroundColor:i?`${n}15`:"transparent",color:i?n:"var(--color-text-muted)"},children:l.replace(/_/g," ")},l)})})]}),c.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-muted",children:o.length===0?"No Siebel objects indexed yet. Upload a .sif file.":"No objects match the current filters."}):e.jsx("div",{className:"flex-1 overflow-auto",style:{contentVisibility:"auto",containIntrinsicSize:`0 ${c.length*C}px`},children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-alt z-10",children:e.jsxs("tr",{className:"border-b border-edge",children:[e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Name"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Type"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Project"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Preview"})]})}),e.jsx("tbody",{children:c.map((l,n)=>{const i=k[l.siebelType??""]||"#6b7280";return e.jsxs("tr",{className:"border-b border-edge hover:bg-surface transition-colors",style:{height:C},children:[e.jsx("td",{className:"px-4 py-1.5 font-mono",children:l.title}),e.jsx("td",{className:"px-4 py-1.5",children:e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{backgroundColor:`${i}15`,color:i},children:l.siebelType??l.sourceType})}),e.jsx("td",{className:"px-4 py-1.5 text-muted",children:l.siebelProject??"-"}),e.jsx("td",{className:"px-4 py-1.5 text-muted truncate max-w-xs",children:l.contentPreview})]},n)})})]})})]})}function O({templates:o,gen:t}){return e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",children:"SIF Generation"}),e.jsx("p",{className:"text-xs text-muted",children:"Describe what you need, generate context for the LLM, then validate the output"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-description",children:"Description"}),e.jsx("textarea",{id:"gen-description",value:t.description,onChange:a=>t.setDescription(a.target.value),placeholder:"e.g., Create a Business Component for Service Requests with fields: SR Number, Status, Priority",rows:3,className:"w-full px-3 py-2 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1.5",children:"Object Types"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:o.map(a=>e.jsx("button",{onClick:()=>t.toggleType(a.type),"aria-label":`Toggle ${a.type}`,"aria-pressed":t.selectedTypes.includes(a.type),className:`px-2 py-1 text-[10px] rounded-md border transition-colors cursor-pointer ${t.selectedTypes.includes(a.type)?"bg-accent text-white border-accent":"bg-transparent text-muted border-edge hover:border-accent"}`,children:a.type.replace(/_/g," ")},a.type))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-project",children:"Base Project (optional)"}),e.jsx("input",{id:"gen-project",value:t.project,onChange:a=>t.setProject(a.target.value),placeholder:"e.g., Account (SSE)",className:"w-full px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"})]}),e.jsx("button",{onClick:t.prepare,disabled:!t.description.trim()||t.loading,className:"px-4 py-1.5 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 disabled:opacity-50 transition-opacity cursor-pointer disabled:cursor-not-allowed",children:t.loading&&!t.prompt?"Generating Context...":"Generate Context & Prompt"}),t.prompt&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"text-xs font-medium",children:"Generated Prompt (copy to LLM)"}),e.jsx("button",{onClick:()=>navigator.clipboard.writeText(t.prompt??""),"aria-label":"Copy prompt to clipboard",className:"text-[10px] px-2 py-0.5 rounded bg-surface text-muted hover:text-foreground border border-edge cursor-pointer transition-colors",children:"Copy"})]}),e.jsxs("pre",{className:"text-[10px] p-3 rounded-md bg-surface border border-edge max-h-48 overflow-auto whitespace-pre-wrap text-muted",children:[t.prompt.slice(0,3e3),t.prompt.length>3e3&&`
|
|
3
3
|
|
|
4
|
-
... (truncated for display)`]})]}),t.prompt&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-xml",children:"Paste LLM-generated SIF XML"}),e.jsx("textarea",{id:"gen-xml",value:t.xml,onChange:a=>t.setXml(a.target.value),placeholder:'Paste the XML output from the LLM here (starting with <?xml version="1.0"...)',rows:8,className:"w-full px-3 py-2 text-xs font-mono rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsx("button",{onClick:t.finalize,disabled:!t.xml.trim()||t.loading,className:"mt-2 px-4 py-1.5 text-xs font-medium rounded-md bg-green-600 text-white hover:opacity-90 disabled:opacity-50 transition-opacity cursor-pointer disabled:cursor-not-allowed",children:t.loading?"Validating...":"Validate & Finalize"})]}),t.result&&e.jsxs("div",{className:`rounded-md border p-4 space-y-2 ${t.result.validation.status==="valid"?"border-green-500/30 bg-green-500/5":t.result.validation.status==="warnings"?"border-yellow-500/30 bg-yellow-500/5":"border-red-500/30 bg-red-500/5"}`,role:"status",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-sm font-bold ${t.result.validation.status==="valid"?"text-green-500":t.result.validation.status==="warnings"?"text-yellow-500":"text-red-500"}`,children:t.result.validation.status==="valid"?"Valid":t.result.validation.status==="warnings"?"Warnings":"Invalid"}),e.jsxs("span",{className:"text-xs text-muted",children:["Score: ",t.result.validation.score,"/100"]}),e.jsxs("span",{className:"text-xs text-muted",children:[t.result.metadata.objectCount," objects"]})]}),t.result.validation.status!=="invalid"&&e.jsx("button",{onClick:t.download,"aria-label":"Download generated SIF file",className:"px-3 py-1 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 cursor-pointer transition-opacity",children:"Download SIF"})]}),t.result.objects.length>0&&e.jsxs("div",{className:"text-xs text-muted",children:["Objects: ",t.result.objects.map(a=>`${a.type}:${a.name}`).join(", ")]}),t.result.validation.messages.length>0&&e.jsx("ul",{className:"space-y-0.5",children:t.result.validation.messages.map((a,d)=>e.jsxs("li",{className:`text-[10px] ${a.level==="error"?"text-red-500":a.level==="warning"?"text-yellow-600":"text-muted"}`,children:["[",a.level,"] ",a.message,a.objectName&&` (${a.objectName})`]},d))})]})]})})}const G=s.lazy(()=>L(()=>import("./graph-section-
|
|
4
|
+
... (truncated for display)`]})]}),t.prompt&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-xml",children:"Paste LLM-generated SIF XML"}),e.jsx("textarea",{id:"gen-xml",value:t.xml,onChange:a=>t.setXml(a.target.value),placeholder:'Paste the XML output from the LLM here (starting with <?xml version="1.0"...)',rows:8,className:"w-full px-3 py-2 text-xs font-mono rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsx("button",{onClick:t.finalize,disabled:!t.xml.trim()||t.loading,className:"mt-2 px-4 py-1.5 text-xs font-medium rounded-md bg-green-600 text-white hover:opacity-90 disabled:opacity-50 transition-opacity cursor-pointer disabled:cursor-not-allowed",children:t.loading?"Validating...":"Validate & Finalize"})]}),t.result&&e.jsxs("div",{className:`rounded-md border p-4 space-y-2 ${t.result.validation.status==="valid"?"border-green-500/30 bg-green-500/5":t.result.validation.status==="warnings"?"border-yellow-500/30 bg-yellow-500/5":"border-red-500/30 bg-red-500/5"}`,role:"status",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-sm font-bold ${t.result.validation.status==="valid"?"text-green-500":t.result.validation.status==="warnings"?"text-yellow-500":"text-red-500"}`,children:t.result.validation.status==="valid"?"Valid":t.result.validation.status==="warnings"?"Warnings":"Invalid"}),e.jsxs("span",{className:"text-xs text-muted",children:["Score: ",t.result.validation.score,"/100"]}),e.jsxs("span",{className:"text-xs text-muted",children:[t.result.metadata.objectCount," objects"]})]}),t.result.validation.status!=="invalid"&&e.jsx("button",{onClick:t.download,"aria-label":"Download generated SIF file",className:"px-3 py-1 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 cursor-pointer transition-opacity",children:"Download SIF"})]}),t.result.objects.length>0&&e.jsxs("div",{className:"text-xs text-muted",children:["Objects: ",t.result.objects.map(a=>`${a.type}:${a.name}`).join(", ")]}),t.result.validation.messages.length>0&&e.jsx("ul",{className:"space-y-0.5",children:t.result.validation.messages.map((a,d)=>e.jsxs("li",{className:`text-[10px] ${a.level==="error"?"text-red-500":a.level==="warning"?"text-yellow-600":"text-muted"}`,children:["[",a.level,"] ",a.message,a.objectName&&` (${a.objectName})`]},d))})]})]})})}const G=s.lazy(()=>L(()=>import("./graph-section-CheOuwv_.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])).then(o=>({default:o.GraphSection})));function A(){return e.jsx("div",{className:"flex items-center justify-center h-full text-muted text-xs",children:"Loading..."})}function z(){const[o,t]=s.useState("upload"),{objects:a,templates:d,loading:u,error:x,refresh:b}=E(),h=P(b),[c,m]=s.useState([]),[l,n]=s.useState([]),i=s.useCallback(async()=>{try{const v=await S.siebelGetGraph();m(v.objects),n(v.dependencies)}catch{}},[]);s.useEffect(()=>{i()},[i]);const g=s.useCallback(()=>{b(),i()},[b,i]);return u?e.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:"Loading Siebel..."}):x?e.jsx("div",{className:"flex items-center justify-center h-full text-danger",children:x}):e.jsxs("div",{className:"h-full flex",children:[e.jsx(T,{activeSection:o,onSectionChange:t,objectCount:a.length}),e.jsxs("main",{className:"flex-1 min-w-0 overflow-hidden",children:[o==="upload"&&e.jsx($,{onUploaded:g}),o==="objects"&&e.jsx(M,{objects:a}),o==="graph"&&e.jsx(s.Suspense,{fallback:e.jsx(A,{}),children:e.jsx(G,{objects:c,dependencies:l})}),o==="generation"&&e.jsx(O,{templates:d,gen:h})]})]})}export{z as SiebelTab};
|
package/dist/web/dashboard/dist/assets/{sif-parse.worker-DZrybOHz.js → sif-parse.worker-Cty_N-lP.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){"use strict";const U=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",te=U+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",ne="["+U+"]["+te+"]*",se=new RegExp("^"+ne+"$");function W(n,e){const t=[];let s=e.exec(n);for(;s;){const i=[];i.startIndex=e.lastIndex-s[0].length;const r=s.length;for(let u=0;u<r;u++)i.push(s[u]);t.push(i),s=e.exec(n)}return t}const
|
|
1
|
+
(function(){"use strict";const U=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",te=U+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",ne="["+U+"]["+te+"]*",se=new RegExp("^"+ne+"$");function W(n,e){const t=[];let s=e.exec(n);for(;s;){const i=[];i.startIndex=e.lastIndex-s[0].length;const r=s.length;for(let u=0;u<r;u++)i.push(s[u]);t.push(i),s=e.exec(n)}return t}const M=function(n){const e=se.exec(n);return!(e===null||typeof e>"u")};function re(n){return typeof n<"u"}const k=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],Y=["__proto__","constructor","prototype"],ie={allowBooleanAttributes:!1,unpairedTags:[]};function oe(n,e){e=Object.assign({},ie,e);const t=[];let s=!1,i=!1;n[0]==="\uFEFF"&&(n=n.substr(1));for(let r=0;r<n.length;r++)if(n[r]==="<"&&n[r+1]==="?"){if(r+=2,r=G(n,r),r.err)return r}else if(n[r]==="<"){let u=r;if(r++,n[r]==="!"){r=X(n,r);continue}else{let a=!1;n[r]==="/"&&(a=!0,r++);let o="";for(;r<n.length&&n[r]!==">"&&n[r]!==" "&&n[r]!==" "&&n[r]!==`
|
|
2
2
|
`&&n[r]!=="\r";r++)o+=n[r];if(o=o.trim(),o[o.length-1]==="/"&&(o=o.substring(0,o.length-1),r--),!de(o)){let c;return o.trim().length===0?c="Invalid space after '<'.":c="Tag '"+o+"' is an invalid name.",h("InvalidTag",c,g(n,r))}const f=le(n,r);if(f===!1)return h("InvalidAttr","Attributes for '"+o+"' have open quote.",g(n,r));let l=f.value;if(r=f.index,l[l.length-1]==="/"){const c=r-l.length;l=l.substring(0,l.length-1);const p=Z(l,e);if(p===!0)s=!0;else return h(p.err.code,p.err.msg,g(n,c+p.err.line))}else if(a)if(f.tagClosed){if(l.trim().length>0)return h("InvalidTag","Closing tag '"+o+"' can't have attributes or invalid starting.",g(n,u));if(t.length===0)return h("InvalidTag","Closing tag '"+o+"' has not been opened.",g(n,u));{const c=t.pop();if(o!==c.tagName){let p=g(n,c.tagStartPos);return h("InvalidTag","Expected closing tag '"+c.tagName+"' (opened in line "+p.line+", col "+p.col+") instead of closing tag '"+o+"'.",g(n,u))}t.length==0&&(i=!0)}}else return h("InvalidTag","Closing tag '"+o+"' doesn't have proper closing.",g(n,r));else{const c=Z(l,e);if(c!==!0)return h(c.err.code,c.err.msg,g(n,r-l.length+c.err.line));if(i===!0)return h("InvalidXml","Multiple possible root nodes found.",g(n,r));e.unpairedTags.indexOf(o)!==-1||t.push({tagName:o,tagStartPos:u}),s=!0}for(r++;r<n.length;r++)if(n[r]==="<")if(n[r+1]==="!"){r++,r=X(n,r);continue}else if(n[r+1]==="?"){if(r=G(n,++r),r.err)return r}else break;else if(n[r]==="&"){const c=he(n,r);if(c==-1)return h("InvalidChar","char '&' is not expected.",g(n,r));r=c}else if(i===!0&&!z(n[r]))return h("InvalidXml","Extra text at the end",g(n,r));n[r]==="<"&&r--}}else{if(z(n[r]))continue;return h("InvalidChar","char '"+n[r]+"' is not expected.",g(n,r))}if(s){if(t.length==1)return h("InvalidTag","Unclosed tag '"+t[0].tagName+"'.",g(n,t[0].tagStartPos));if(t.length>0)return h("InvalidXml","Invalid '"+JSON.stringify(t.map(r=>r.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return h("InvalidXml","Start tag expected.",1);return!0}function z(n){return n===" "||n===" "||n===`
|
|
3
|
-
`||n==="\r"}function G(n,e){const t=e;for(;e<n.length;e++)if(n[e]=="?"||n[e]==" "){const s=n.substr(t,e-t);if(e>5&&s==="xml")return h("InvalidXml","XML declaration allowed only at the start of the document.",g(n,e));if(n[e]=="?"&&n[e+1]==">"){e++;break}else continue}return e}function X(n,e){if(n.length>e+5&&n[e+1]==="-"&&n[e+2]==="-"){for(e+=3;e<n.length;e++)if(n[e]==="-"&&n[e+1]==="-"&&n[e+2]===">"){e+=2;break}}else if(n.length>e+8&&n[e+1]==="D"&&n[e+2]==="O"&&n[e+3]==="C"&&n[e+4]==="T"&&n[e+5]==="Y"&&n[e+6]==="P"&&n[e+7]==="E"){let t=1;for(e+=8;e<n.length;e++)if(n[e]==="<")t++;else if(n[e]===">"&&(t--,t===0))break}else if(n.length>e+9&&n[e+1]==="["&&n[e+2]==="C"&&n[e+3]==="D"&&n[e+4]==="A"&&n[e+5]==="T"&&n[e+6]==="A"&&n[e+7]==="["){for(e+=8;e<n.length;e++)if(n[e]==="]"&&n[e+1]==="]"&&n[e+2]===">"){e+=2;break}}return e}const ae='"',ue="'";function le(n,e){let t="",s="",i=!1;for(;e<n.length;e++){if(n[e]===ae||n[e]===ue)s===""?s=n[e]:s!==n[e]||(s="");else if(n[e]===">"&&s===""){i=!0;break}t+=n[e]}return s!==""?!1:{value:t,index:e,tagClosed:i}}const fe=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Z(n,e){const t=W(n,fe),s={};for(let i=0;i<t.length;i++){if(t[i][1].length===0)return h("InvalidAttr","Attribute '"+t[i][2]+"' has no space in starting.",_(t[i]));if(t[i][3]!==void 0&&t[i][4]===void 0)return h("InvalidAttr","Attribute '"+t[i][2]+"' is without value.",_(t[i]));if(t[i][3]===void 0&&!e.allowBooleanAttributes)return h("InvalidAttr","boolean attribute '"+t[i][2]+"' is not allowed.",_(t[i]));const r=t[i][2];if(!pe(r))return h("InvalidAttr","Attribute '"+r+"' is an invalid name.",_(t[i]));if(!Object.prototype.hasOwnProperty.call(s,r))s[r]=1;else return h("InvalidAttr","Attribute '"+r+"' is repeated.",_(t[i]))}return!0}function ce(n,e){let t=/\d/;for(n[e]==="x"&&(e++,t=/[\da-fA-F]/);e<n.length;e++){if(n[e]===";")return e;if(!n[e].match(t))break}return-1}function he(n,e){if(e++,n[e]===";")return-1;if(n[e]==="#")return e++,ce(n,e);let t=0;for(;e<n.length;e++,t++)if(!(n[e].match(/\w/)&&t<20)){if(n[e]===";")break;return-1}return e}function h(n,e,t){return{err:{code:n,msg:e,line:t.line||t,col:t.col}}}function pe(n){return x(n)}function de(n){return x(n)}function g(n,e){const t=n.substring(0,e).split(/\r?\n/);return{line:t.length,col:t[t.length-1].length+1}}function _(n){return n.startIndex+n[1].length}const J=n=>k.includes(n)?"__"+n:n,ge={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(n,e){return e},attributeValueProcessor:function(n,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(n,e,t){return n},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:J};function Ee(n,e){if(typeof n!="string")return;const t=n.toLowerCase();if(k.some(s=>t===s.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${n}" is a reserved JavaScript keyword that could cause prototype pollution`);if(Y.some(s=>t===s.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${n}" is a reserved JavaScript keyword that could cause prototype pollution`)}function K(n){return typeof n=="boolean"?{enabled:n,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,maxEntityCount:100,allowedTags:null,tagFilter:null}:typeof n=="object"&&n!==null?{enabled:n.enabled!==!1,maxEntitySize:Math.max(1,n.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,n.maxExpansionDepth??10),maxTotalExpansions:Math.max(1,n.maxTotalExpansions??1e3),maxExpandedLength:Math.max(1,n.maxExpandedLength??1e5),maxEntityCount:Math.max(1,n.maxEntityCount??100),allowedTags:n.allowedTags??null,tagFilter:n.tagFilter??null}:K(!0)}const be=function(n){const e=Object.assign({},ge,n),t=[{value:e.attributeNamePrefix,name:"attributeNamePrefix"},{value:e.attributesGroupName,name:"attributesGroupName"},{value:e.textNodeName,name:"textNodeName"},{value:e.cdataPropName,name:"cdataPropName"},{value:e.commentPropName,name:"commentPropName"}];for(const{value:s,name:i}of t)s&&Ee(s,i);return e.onDangerousProperty===null&&(e.onDangerousProperty=J),e.processEntities=K(e.processEntities),e.stopNodes&&Array.isArray(e.stopNodes)&&(e.stopNodes=e.stopNodes.map(s=>typeof s=="string"&&s.startsWith("*.")?".."+s.substring(2):s)),e};let v;typeof Symbol!="function"?v="@@xmlMetadata":v=Symbol("XML Node Metadata");class m{constructor(e){this.tagname=e,this.child=[],this[":@"]=Object.create(null)}add(e,t){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e,t){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child}),t!==void 0&&(this.child[this.child.length-1][v]={startIndex:t})}static getMetaDataSymbol(){return v}}class ye{constructor(e){this.suppressValidationErr=!e,this.options=e}readDocType(e,t){const s=Object.create(null);let i=0;if(e[t+3]==="O"&&e[t+4]==="C"&&e[t+5]==="T"&&e[t+6]==="Y"&&e[t+7]==="P"&&e[t+8]==="E"){t=t+9;let r=1,u=!1,a=!1,o="";for(;t<e.length;t++)if(e[t]==="<"&&!a){if(u&&T(e,"!ENTITY",t)){t+=7;let f,l;if([f,l,t]=this.readEntityExp(e,t+1,this.suppressValidationErr),l.indexOf("&")===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&i>=this.options.maxEntityCount)throw new Error(`Entity count (${i+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);const c=f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");s[f]={regx:RegExp(`&${c};`,"g"),val:l},i++}}else if(u&&T(e,"!ELEMENT",t)){t+=8;const{index:f}=this.readElementExp(e,t+1);t=f}else if(u&&T(e,"!ATTLIST",t))t+=8;else if(u&&T(e,"!NOTATION",t)){t+=9;const{index:f}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=f}else if(T(e,"!--",t))a=!0;else throw new Error("Invalid DOCTYPE");r++,o=""}else if(e[t]===">"){if(a?e[t-1]==="-"&&e[t-2]==="-"&&(a=!1,r--):r--,r===0)break}else e[t]==="["?u=!0:o+=e[t];if(r!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:s,i:t}}readEntityExp(e,t){t=b(e,t);const s=t;for(;t<e.length&&!/\s/.test(e[t])&&e[t]!=='"'&&e[t]!=="'";)t++;let i=e.substring(s,t);if(C(i),t=b(e,t),!this.suppressValidationErr){if(e.substring(t,t+6).toUpperCase()==="SYSTEM")throw new Error("External entities are not supported");if(e[t]==="%")throw new Error("Parameter entities are not supported")}let r="";if([t,r]=this.readIdentifierVal(e,t,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&r.length>this.options.maxEntitySize)throw new Error(`Entity "${i}" size (${r.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return t--,[i,r,t]}readNotationExp(e,t){t=b(e,t);const s=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(s,t);!this.suppressValidationErr&&C(i),t=b(e,t);const r=e.substring(t,t+6).toUpperCase();if(!this.suppressValidationErr&&r!=="SYSTEM"&&r!=="PUBLIC")throw new Error(`Expected SYSTEM or PUBLIC, found "${r}"`);t+=r.length,t=b(e,t);let u=null,a=null;if(r==="PUBLIC")[t,u]=this.readIdentifierVal(e,t,"publicIdentifier"),t=b(e,t),(e[t]==='"'||e[t]==="'")&&([t,a]=this.readIdentifierVal(e,t,"systemIdentifier"));else if(r==="SYSTEM"&&([t,a]=this.readIdentifierVal(e,t,"systemIdentifier"),!this.suppressValidationErr&&!a))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:i,publicIdentifier:u,systemIdentifier:a,index:--t}}readIdentifierVal(e,t,s){let i="";const r=e[t];if(r!=='"'&&r!=="'")throw new Error(`Expected quoted string, found "${r}"`);t++;const u=t;for(;t<e.length&&e[t]!==r;)t++;if(i=e.substring(u,t),e[t]!==r)throw new Error(`Unterminated ${s} value`);return t++,[t,i]}readElementExp(e,t){t=b(e,t);const s=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(s,t);if(!this.suppressValidationErr&&!x(i))throw new Error(`Invalid element name: "${i}"`);t=b(e,t);let r="";if(e[t]==="E"&&T(e,"MPTY",t))t+=4;else if(e[t]==="A"&&T(e,"NY",t))t+=2;else if(e[t]==="("){t++;const u=t;for(;t<e.length&&e[t]!==")";)t++;if(r=e.substring(u,t),e[t]!==")")throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[t]}"`);return{elementName:i,contentModel:r.trim(),index:t}}readAttlistExp(e,t){t=b(e,t);let s=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(s,t);for(C(i),t=b(e,t),s=t;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(s,t);if(!C(r))throw new Error(`Invalid attribute name: "${r}"`);t=b(e,t);let u="";if(e.substring(t,t+8).toUpperCase()==="NOTATION"){if(u="NOTATION",t+=8,t=b(e,t),e[t]!=="(")throw new Error(`Expected '(', found "${e[t]}"`);t++;let o=[];for(;t<e.length&&e[t]!==")";){const f=t;for(;t<e.length&&e[t]!=="|"&&e[t]!==")";)t++;let l=e.substring(f,t);if(l=l.trim(),!C(l))throw new Error(`Invalid notation name: "${l}"`);o.push(l),e[t]==="|"&&(t++,t=b(e,t))}if(e[t]!==")")throw new Error("Unterminated list of notations");t++,u+=" ("+o.join("|")+")"}else{const o=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;u+=e.substring(o,t);const f=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!f.includes(u.toUpperCase()))throw new Error(`Invalid attribute type: "${u}"`)}t=b(e,t);let a="";return e.substring(t,t+8).toUpperCase()==="#REQUIRED"?(a="#REQUIRED",t+=8):e.substring(t,t+7).toUpperCase()==="#IMPLIED"?(a="#IMPLIED",t+=7):[t,a]=this.readIdentifierVal(e,t,"ATTLIST"),{elementName:i,attributeName:r,attributeType:u,defaultValue:a,index:t}}}const b=(n,e)=>{for(;e<n.length&&/\s/.test(n[e]);)e++;return e};function T(n,e,t){for(let s=0;s<e.length;s++)if(e[s]!==n[t+s+1])return!1;return!0}function C(n){if(x(n))return n;throw new Error(`Invalid entity name ${n}`)}const Ne=/^[-+]?0x[a-fA-F0-9]+$/,me=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Te={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original"};function we(n,e={}){if(e=Object.assign({},Te,e),!n||typeof n!="string")return n;let t=n.trim();if(t.length===0)return n;if(e.skipLike!==void 0&&e.skipLike.test(t))return n;if(t==="0")return 0;if(e.hex&&Ne.test(t))return Ce(t,16);if(isFinite(t)){if(t.includes("e")||t.includes("E"))return Se(n,t,e);{const s=me.exec(t);if(s){const i=s[1]||"",r=s[2];let u=_e(s[3]);const a=i?n[r.length+1]===".":n[r.length]===".";if(!e.leadingZeros&&(r.length>1||r.length===1&&!a))return n;{const o=Number(t),f=String(o);if(o===0)return o;if(f.search(/[eE]/)!==-1)return e.eNotation?o:n;if(t.indexOf(".")!==-1)return f==="0"||f===u||f===`${i}${u}`?o:n;let l=r?u:t;return r?l===f||i+l===f?o:n:l===f||l===i+f?o:n}}else return n}}else return Pe(n,Number(t),e)}const Ie=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function Se(n,e,t){if(!t.eNotation)return n;const s=e.match(Ie);if(s){let i=s[1]||"";const r=s[3].indexOf("e")===-1?"E":"e",u=s[2],a=i?n[u.length+1]===r:n[u.length]===r;return u.length>1&&a?n:u.length===1&&(s[3].startsWith(`.${r}`)||s[3][0]===r)?Number(e):u.length>0?t.leadingZeros&&!a?(e=(s[1]||"")+s[3],Number(e)):n:Number(e)}else return n}function _e(n){return n&&n.indexOf(".")!==-1&&(n=n.replace(/0+$/,""),n==="."?n="0":n[0]==="."?n="0"+n:n[n.length-1]==="."&&(n=n.substring(0,n.length-1))),n}function Ce(n,e){if(parseInt)return parseInt(n,e);if(Number.parseInt)return Number.parseInt(n,e);if(window&&window.parseInt)return window.parseInt(n,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}function Pe(n,e,t){const s=e===1/0;switch(t.infinity.toLowerCase()){case"null":return null;case"infinity":return e;case"string":return s?"Infinity":"-Infinity";case"original":default:return n}}function Oe(n){return typeof n=="function"?n:Array.isArray(n)?e=>{for(const t of n)if(typeof t=="string"&&e===t||t instanceof RegExp&&t.test(e))return!0}:()=>!1}class q{constructor(e,t={}){this.pattern=e,this.separator=t.separator||".",this.segments=this._parse(e),this._hasDeepWildcard=this.segments.some(s=>s.type==="deep-wildcard"),this._hasAttributeCondition=this.segments.some(s=>s.attrName!==void 0),this._hasPositionSelector=this.segments.some(s=>s.position!==void 0)}_parse(e){const t=[];let s=0,i="";for(;s<e.length;)e[s]===this.separator?s+1<e.length&&e[s+1]===this.separator?(i.trim()&&(t.push(this._parseSegment(i.trim())),i=""),t.push({type:"deep-wildcard"}),s+=2):(i.trim()&&t.push(this._parseSegment(i.trim())),i="",s++):(i+=e[s],s++);return i.trim()&&t.push(this._parseSegment(i.trim())),t}_parseSegment(e){const t={type:"tag"};let s=null,i=e;const r=e.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(r&&(i=r[1]+r[3],r[2])){const l=r[2].slice(1,-1);l&&(s=l)}let u,a=i;if(i.includes("::")){const l=i.indexOf("::");if(u=i.substring(0,l).trim(),a=i.substring(l+2).trim(),!u)throw new Error(`Invalid namespace in pattern: ${e}`)}let o,f=null;if(a.includes(":")){const l=a.lastIndexOf(":"),c=a.substring(0,l).trim(),p=a.substring(l+1).trim();["first","last","odd","even"].includes(p)||/^nth\(\d+\)$/.test(p)?(o=c,f=p):o=a}else o=a;if(!o)throw new Error(`Invalid segment pattern: ${e}`);if(t.tag=o,u&&(t.namespace=u),s)if(s.includes("=")){const l=s.indexOf("=");t.attrName=s.substring(0,l).trim(),t.attrValue=s.substring(l+1).trim()}else t.attrName=s.trim();if(f){const l=f.match(/^nth\((\d+)\)$/);l?(t.position="nth",t.positionValue=parseInt(l[1],10)):t.position=f}return t}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}const Ae=new Set(["push","pop","reset","updateCurrent","restore"]);class Me{constructor(e={}){this.separator=e.separator||".",this.path=[],this.siblingStacks=[]}push(e,t=null,s=null){if(this.path.length>0){const l=this.path[this.path.length-1];l.values=void 0}const i=this.path.length;this.siblingStacks[i]||(this.siblingStacks[i]=new Map);const r=this.siblingStacks[i],u=s?`${s}:${e}`:e,a=r.get(u)||0;let o=0;for(const l of r.values())o+=l;r.set(u,a+1);const f={tag:e,position:o,counter:a};s!=null&&(f.namespace=s),t!=null&&(f.values=t),this.path.push(f)}pop(){if(this.path.length===0)return;const e=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),e}updateCurrent(e){if(this.path.length>0){const t=this.path[this.path.length-1];e!=null&&(t.values=e)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(e){var s;return this.path.length===0||(s=this.path[this.path.length-1].values)==null?void 0:s[e]}hasAttr(e){if(this.path.length===0)return!1;const t=this.path[this.path.length-1];return t.values!==void 0&&e in t.values}getPosition(){return this.path.length===0?-1:this.path[this.path.length-1].position??0}getCounter(){return this.path.length===0?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(e,t=!0){const s=e||this.separator;return this.path.map(i=>t&&i.namespace?`${i.namespace}:${i.tag}`:i.tag).join(s)}toArray(){return this.path.map(e=>e.tag)}reset(){this.path=[],this.siblingStacks=[]}matches(e){const t=e.segments;return t.length===0?!1:e.hasDeepWildcard()?this._matchWithDeepWildcard(t):this._matchSimple(t)}_matchSimple(e){if(this.path.length!==e.length)return!1;for(let t=0;t<e.length;t++){const s=e[t],i=this.path[t],r=t===this.path.length-1;if(!this._matchSegment(s,i,r))return!1}return!0}_matchWithDeepWildcard(e){let t=this.path.length-1,s=e.length-1;for(;s>=0&&t>=0;){const i=e[s];if(i.type==="deep-wildcard"){if(s--,s<0)return!0;const r=e[s];let u=!1;for(let a=t;a>=0;a--){const o=a===this.path.length-1;if(this._matchSegment(r,this.path[a],o)){t=a-1,s--,u=!0;break}}if(!u)return!1}else{const r=t===this.path.length-1;if(!this._matchSegment(i,this.path[t],r))return!1;t--,s--}}return s<0}_matchSegment(e,t,s){if(e.tag!=="*"&&e.tag!==t.tag||e.namespace!==void 0&&e.namespace!=="*"&&e.namespace!==t.namespace)return!1;if(e.attrName!==void 0){if(!s||!t.values||!(e.attrName in t.values))return!1;if(e.attrValue!==void 0){const i=t.values[e.attrName];if(String(i)!==String(e.attrValue))return!1}}if(e.position!==void 0){if(!s)return!1;const i=t.counter??0;if(e.position==="first"&&i!==0)return!1;if(e.position==="odd"&&i%2!==1)return!1;if(e.position==="even"&&i%2!==0)return!1;if(e.position==="nth"&&i!==e.positionValue)return!1}return!0}snapshot(){return{path:this.path.map(e=>({...e})),siblingStacks:this.siblingStacks.map(e=>new Map(e))}}restore(e){this.path=e.path.map(t=>({...t})),this.siblingStacks=e.siblingStacks.map(t=>new Map(t))}readOnly(){const e=this;return new Proxy(e,{get(t,s,i){if(Ae.has(s))return()=>{throw new TypeError(`Cannot call '${s}' on a read-only Matcher. Obtain a writable instance to mutate state.`)};const r=Reflect.get(t,s,i);return s==="path"||s==="siblingStacks"?Object.freeze(Array.isArray(r)?r.map(u=>u instanceof Map?Object.freeze(new Map(u)):Object.freeze({...u})):r):typeof r=="function"?r.bind(t):r},set(t,s){throw new TypeError(`Cannot set property '${String(s)}' on a read-only Matcher.`)},deleteProperty(t,s){throw new TypeError(`Cannot delete property '${String(s)}' from a read-only Matcher.`)}})}}function xe(n,e){if(!n)return{};const t=e.attributesGroupName?n[e.attributesGroupName]:n;if(!t)return{};const s={};for(const i in t)if(i.startsWith(e.attributeNamePrefix)){const r=i.substring(e.attributeNamePrefix.length);s[r]=t[i]}else s[i]=t[i];return s}function ve(n){if(!n||typeof n!="string")return;const e=n.indexOf(":");if(e!==-1&&e>0){const t=n.substring(0,e);if(t!=="xmlns")return t}}class $e{constructor(e){if(this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(t,s)=>H(s,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(t,s)=>H(s,16,"&#x")}},this.addExternalEntities=je,this.parseXml=Fe,this.parseTextData=ke,this.resolveNameSpace=Ve,this.buildAttributesMap=Re,this.isItStopNode=Ye,this.replaceEntitiesValue=Ue,this.readStopNodeData=Ge,this.saveTextToParentTag=We,this.addChild=Be,this.ignoreAttributesFn=Oe(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.matcher=new Me,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodeExpressions=[];for(let t=0;t<this.options.stopNodes.length;t++){const s=this.options.stopNodes[t];typeof s=="string"?this.stopNodeExpressions.push(new q(s)):s instanceof q&&this.stopNodeExpressions.push(s)}}}}function je(n){const e=Object.keys(n);for(let t=0;t<e.length;t++){const s=e[t],i=s.replace(/[.\-+*:]/g,"\\.");this.lastEntities[s]={regex:new RegExp("&"+i+";","g"),val:n[s]}}}function ke(n,e,t,s,i,r,u){if(n!==void 0&&(this.options.trimValues&&!s&&(n=n.trim()),n.length>0)){u||(n=this.replaceEntitiesValue(n,e,t));const a=this.options.jPath?t.toString():t,o=this.options.tagValueProcessor(e,n,a,i,r);return o==null?n:typeof o!=typeof n||o!==n?o:this.options.trimValues?L(n,this.options.parseTagValue,this.options.numberParseOptions):n.trim()===n?L(n,this.options.parseTagValue,this.options.numberParseOptions):n}}function Ve(n){if(this.options.removeNSPrefix){const e=n.split(":"),t=n.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(n=t+e[1])}return n}const Le=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function Re(n,e,t){if(this.options.ignoreAttributes!==!0&&typeof n=="string"){const s=W(n,Le),i=s.length,r={},u={};for(let a=0;a<i;a++){const o=this.resolveNameSpace(s[a][1]),f=s[a][4];if(o.length&&f!==void 0){let l=f;this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l,t,this.readonlyMatcher),u[o]=l}}Object.keys(u).length>0&&typeof e=="object"&&e.updateCurrent&&e.updateCurrent(u);for(let a=0;a<i;a++){const o=this.resolveNameSpace(s[a][1]),f=this.options.jPath?e.toString():this.readonlyMatcher;if(this.ignoreAttributesFn(o,f))continue;let l=s[a][4],c=this.options.attributeNamePrefix+o;if(o.length)if(this.options.transformAttributeName&&(c=this.options.transformAttributeName(c)),c=Q(c,this.options),l!==void 0){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l,t,this.readonlyMatcher);const p=this.options.jPath?e.toString():this.readonlyMatcher,y=this.options.attributeValueProcessor(o,l,p);y==null?r[c]=l:typeof y!=typeof l||y!==l?r[c]=y:r[c]=L(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(r[c]=!0)}if(!Object.keys(r).length)return;if(this.options.attributesGroupName){const a={};return a[this.options.attributesGroupName]=r,a}return r}}const Fe=function(n){n=n.replace(/\r\n?/g,`
|
|
4
|
-
`);const e=new m("!xml");let t=e,s="";this.matcher.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0;const i=new ye(this.options.processEntities);for(let r=0;r<n.length;r++)if(n[r]==="<")if(n[r+1]==="/"){const a=w(n,">",r,"Closing Tag is not closed.");let o=n.substring(r+2,a).trim();if(this.options.removeNSPrefix){const l=o.indexOf(":");l!==-1&&(o=o.substr(l+1))}o=R(this.options.transformTagName,o,"",this.options).tagName,t&&(s=this.saveTextToParentTag(s,t,this.readonlyMatcher));const f=this.matcher.getCurrentTag();if(o&&this.options.unpairedTags.indexOf(o)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${o}>`);f&&this.options.unpairedTags.indexOf(f)!==-1&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,t=this.tagsNodeStack.pop(),s="",r=a}else if(n[r+1]==="?"){let a=V(n,r,!1,"?>");if(!a)throw new Error("Pi Tag is not closed.");if(s=this.saveTextToParentTag(s,t,this.readonlyMatcher),!(this.options.ignoreDeclaration&&a.tagName==="?xml"||this.options.ignorePiTags)){const o=new m(a.tagName);o.add(this.options.textNodeName,""),a.tagName!==a.tagExp&&a.attrExpPresent&&(o[":@"]=this.buildAttributesMap(a.tagExp,this.matcher,a.tagName)),this.addChild(t,o,this.readonlyMatcher,r)}r=a.closeIndex+1}else if(n.substr(r+1,3)==="!--"){const a=w(n,"-->",r+4,"Comment is not closed.");if(this.options.commentPropName){const o=n.substring(r+4,a-2);s=this.saveTextToParentTag(s,t,this.readonlyMatcher),t.add(this.options.commentPropName,[{[this.options.textNodeName]:o}])}r=a}else if(n.substr(r+1,2)==="!D"){const a=i.readDocType(n,r);this.docTypeEntities=a.entities,r=a.i}else if(n.substr(r+1,2)==="!["){const a=w(n,"]]>",r,"CDATA is not closed.")-2,o=n.substring(r+9,a);s=this.saveTextToParentTag(s,t,this.readonlyMatcher);let f=this.parseTextData(o,t.tagname,this.readonlyMatcher,!0,!1,!0,!0);f==null&&(f=""),this.options.cdataPropName?t.add(this.options.cdataPropName,[{[this.options.textNodeName]:o}]):t.add(this.options.textNodeName,f),r=a+2}else{let a=V(n,r,this.options.removeNSPrefix);if(!a){const d=n.substring(Math.max(0,r-50),Math.min(n.length,r+50));throw new Error(`readTagExp returned undefined at position ${r}. Context: "${d}"`)}let o=a.tagName;const f=a.rawTagName;let l=a.tagExp,c=a.attrExpPresent,p=a.closeIndex;if({tagName:o,tagExp:l}=R(this.options.transformTagName,o,l,this.options),this.options.strictReservedNames&&(o===this.options.commentPropName||o===this.options.cdataPropName||o===this.options.textNodeName||o===this.options.attributesGroupName))throw new Error(`Invalid tag name: ${o}`);t&&s&&t.tagname!=="!xml"&&(s=this.saveTextToParentTag(s,t,this.readonlyMatcher,!1));const y=t;y&&this.options.unpairedTags.indexOf(y.tagname)!==-1&&(t=this.tagsNodeStack.pop(),this.matcher.pop());let P=!1;l.length>0&&l.lastIndexOf("/")===l.length-1&&(P=!0,o[o.length-1]==="/"?(o=o.substr(0,o.length-1),l=o):l=l.substr(0,l.length-1),c=o!==l);let E=null,O;O=ve(f),o!==e.tagname&&this.matcher.push(o,{},O),o!==l&&c&&(E=this.buildAttributesMap(l,this.matcher,o),E&&xe(E,this.options)),o!==e.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode(this.stopNodeExpressions,this.matcher));const S=r;if(this.isCurrentNodeStopNode){let d="";if(P)r=a.closeIndex;else if(this.options.unpairedTags.indexOf(o)!==-1)r=a.closeIndex;else{const M=this.readStopNodeData(n,f,p+1);if(!M)throw new Error(`Unexpected end of ${f}`);r=M.i,d=M.tagContent}const A=new m(o);E&&(A[":@"]=E),A.add(this.options.textNodeName,d),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(t,A,this.readonlyMatcher,S)}else{if(P){({tagName:o,tagExp:l}=R(this.options.transformTagName,o,l,this.options));const d=new m(o);E&&(d[":@"]=E),this.addChild(t,d,this.readonlyMatcher,S),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(this.options.unpairedTags.indexOf(o)!==-1){const d=new m(o);E&&(d[":@"]=E),this.addChild(t,d,this.readonlyMatcher,S),this.matcher.pop(),this.isCurrentNodeStopNode=!1,r=a.closeIndex;continue}else{const d=new m(o);if(this.tagsNodeStack.length>this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(t),E&&(d[":@"]=E),this.addChild(t,d,this.readonlyMatcher,S),t=d}s="",r=p}}else s+=n[r];return e.child};function Be(n,e,t,s){this.options.captureMetaData||(s=void 0);const i=this.options.jPath?t.toString():t,r=this.options.updateTag(e.tagname,i,e[":@"]);r===!1||(typeof r=="string"&&(e.tagname=r),n.addChild(e,s))}function Ue(n,e,t){const s=this.options.processEntities;if(!s||!s.enabled)return n;if(s.allowedTags){const i=this.options.jPath?t.toString():t;if(!(Array.isArray(s.allowedTags)?s.allowedTags.includes(e):s.allowedTags(e,i)))return n}if(s.tagFilter){const i=this.options.jPath?t.toString():t;if(!s.tagFilter(e,i))return n}for(const i of Object.keys(this.docTypeEntities)){const r=this.docTypeEntities[i],u=n.match(r.regx);if(u){if(this.entityExpansionCount+=u.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);const a=n.length;if(n=n.replace(r.regx,r.val),s.maxExpandedLength&&(this.currentExpandedLength+=n.length-a,this.currentExpandedLength>s.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${s.maxExpandedLength}`)}}for(const i of Object.keys(this.lastEntities)){const r=this.lastEntities[i],u=n.match(r.regex);if(u&&(this.entityExpansionCount+=u.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);n=n.replace(r.regex,r.val)}if(n.indexOf("&")===-1)return n;if(this.options.htmlEntities)for(const i of Object.keys(this.htmlEntities)){const r=this.htmlEntities[i],u=n.match(r.regex);if(u&&(this.entityExpansionCount+=u.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);n=n.replace(r.regex,r.val)}return n=n.replace(this.ampEntity.regex,this.ampEntity.val),n}function We(n,e,t,s){return n&&(s===void 0&&(s=e.child.length===0),n=this.parseTextData(n,e.tagname,t,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,s),n!==void 0&&n!==""&&e.add(this.options.textNodeName,n),n=""),n}function Ye(n,e){if(!n||n.length===0)return!1;for(let t=0;t<n.length;t++)if(e.matches(n[t]))return!0;return!1}function ze(n,e,t=">"){let s,i="";for(let r=e;r<n.length;r++){let u=n[r];if(s)u===s&&(s="");else if(u==='"'||u==="'")s=u;else if(u===t[0])if(t[1]){if(n[r+1]===t[1])return{data:i,index:r}}else return{data:i,index:r};else u===" "&&(u=" ");i+=u}}function w(n,e,t,s){const i=n.indexOf(e,t);if(i===-1)throw new Error(s);return i+e.length-1}function V(n,e,t,s=">"){const i=ze(n,e+1,s);if(!i)return;let r=i.data;const u=i.index,a=r.search(/\s/);let o=r,f=!0;a!==-1&&(o=r.substring(0,a),r=r.substring(a+1).trimStart());const l=o;if(t){const c=o.indexOf(":");c!==-1&&(o=o.substr(c+1),f=o!==i.data.substr(c+1))}return{tagName:o,tagExp:r,closeIndex:u,attrExpPresent:f,rawTagName:l}}function Ge(n,e,t){const s=t;let i=1;for(;t<n.length;t++)if(n[t]==="<")if(n[t+1]==="/"){const r=w(n,">",t,`${e} is not closed`);if(n.substring(t+2,r).trim()===e&&(i--,i===0))return{tagContent:n.substring(s,t),i:r};t=r}else if(n[t+1]==="?")t=w(n,"?>",t+1,"StopNode is not closed.");else if(n.substr(t+1,3)==="!--")t=w(n,"-->",t+3,"StopNode is not closed.");else if(n.substr(t+1,2)==="![")t=w(n,"]]>",t,"StopNode is not closed.")-2;else{const r=V(n,t,">");r&&((r&&r.tagName)===e&&r.tagExp[r.tagExp.length-1]!=="/"&&i++,t=r.closeIndex)}}function L(n,e,t){if(e&&typeof n=="string"){const s=n.trim();return s==="true"?!0:s==="false"?!1:we(n,t)}else return re(n)?n:""}function H(n,e,t){const s=Number.parseInt(n,e);return s>=0&&s<=1114111?String.fromCodePoint(s):t+n+";"}function R(n,e,t,s){if(n){const i=n(e);t===e&&(t=i),e=i}return e=Q(e,s),{tagName:e,tagExp:t}}function Q(n,e){if(Y.includes(n))throw new Error(`[SECURITY] Invalid name: "${n}" is a reserved JavaScript keyword that could cause prototype pollution`);return k.includes(n)?e.onDangerousProperty(n):n}const F=m.getMetaDataSymbol();function Xe(n,e){if(!n||typeof n!="object")return{};if(!e)return n;const t={};for(const s in n)if(s.startsWith(e)){const i=s.substring(e.length);t[i]=n[s]}else t[s]=n[s];return t}function Ze(n,e,t,s){return D(n,e,t,s)}function D(n,e,t,s){let i;const r={};for(let u=0;u<n.length;u++){const a=n[u],o=Je(a);if(o!==void 0&&o!==e.textNodeName){const f=Xe(a[":@"]||{},e.attributeNamePrefix);t.push(o,f)}if(o===e.textNodeName)i===void 0?i=a[o]:i+=""+a[o];else{if(o===void 0)continue;if(a[o]){let f=D(a[o],e,t,s);const l=qe(f,e);if(a[":@"]?Ke(f,a[":@"],s,e):Object.keys(f).length===1&&f[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?f=f[e.textNodeName]:Object.keys(f).length===0&&(e.alwaysCreateTextNode?f[e.textNodeName]="":f=""),a[F]!==void 0&&typeof f=="object"&&f!==null&&(f[F]=a[F]),r[o]!==void 0&&Object.prototype.hasOwnProperty.call(r,o))Array.isArray(r[o])||(r[o]=[r[o]]),r[o].push(f);else{const c=e.jPath?s.toString():s;e.isArray(o,c,l)?r[o]=[f]:r[o]=f}o!==void 0&&o!==e.textNodeName&&t.pop()}}}return typeof i=="string"?i.length>0&&(r[e.textNodeName]=i):i!==void 0&&(r[e.textNodeName]=i),r}function Je(n){const e=Object.keys(n);for(let t=0;t<e.length;t++){const s=e[t];if(s!==":@")return s}}function Ke(n,e,t,s){if(e){const i=Object.keys(e),r=i.length;for(let u=0;u<r;u++){const a=i[u],o=a.startsWith(s.attributeNamePrefix)?a.substring(s.attributeNamePrefix.length):a,f=s.jPath?t.toString()+"."+o:t;s.isArray(a,f,!0,!0)?n[a]=[e[a]]:n[a]=e[a]}}}function qe(n,e){const{textNodeName:t}=e,s=Object.keys(n).length;return!!(s===0||s===1&&(n[t]||typeof n[t]=="boolean"||n[t]===0))}class He{constructor(e){this.externalEntities={},this.options=be(e)}parse(e,t){if(typeof e!="string"&&e.toString)e=e.toString();else if(typeof e!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(t){t===!0&&(t={});const r=oe(e,t);if(r!==!0)throw Error(`${r.err.msg}:${r.err.line}:${r.err.col}`)}const s=new $e(this.options);s.addExternalEntities(this.externalEntities);const i=s.parseXml(e);return this.options.preserveOrder||i===void 0?i:Ze(i,this.options,s.matcher,s.readonlyMatcher)}addEntity(e,t){if(t.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if(t==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=t}static getMetaDataSymbol(){return m.getMetaDataSymbol()}}const Qe={APPLET:"applet",BUSINESS_COMPONENT:"business_component",BUSINESS_OBJECT:"business_object",VIEW:"view",SCREEN:"screen",WORKFLOW:"workflow",INTEGRATION_OBJECT:"integration_object",BUSINESS_SERVICE:"business_service",WEB_TEMPLATE:"web_template",PICK_LIST:"pick_list",TABLE:"table"},De={FIELD:"field",COLUMN:"column",CONTROL:"control",LIST_COLUMN:"list_column",LINK:"link",APPLET_WEB_TEMPLATE:"web_template",VIEW_WEB_TEMPLATE:"web_template",VIEW_APPLET:"applet",SCREEN_VIEW:"view",APPLET_METHOD_MENU_ITEM:"menu_item",BUSINESS_OBJECT_COMPONENT:"business_component",BUSINESS_SERVICE_METHOD:"business_service",WORKFLOW_STEP:"workflow",INTEGRATION_COMPONENT:"business_component"},et=new Set(["NAME","INACTIVE"]);function $(n,e){const t=n[e];return Array.isArray(t)?t:t!=null?[t]:[]}function I(n,e){const t=n[`@_${e}`];return t!=null?String(t):void 0}function ee(n){const e=[];for(const[t,s]of Object.entries(n))t.startsWith("@_")&&!et.has(t.slice(2))&&e.push({name:t.slice(2),value:String(s)});return e}function tt(n,e){const t=[];for(const[s,i]of Object.entries(De))for(const r of $(n,s)){const u=r,a=I(u,"NAME");a&&t.push({name:a,type:i,properties:ee(u),children:[],parentName:e})}return t}function N(n,e){var t;return(t=n.properties.find(s=>s.name===e))==null?void 0:t.value}function nt(n){const e=[],t=new Map;for(const s of n)t.set(`${s.type}:${s.name}`,s);for(const s of n){if(s.type==="applet"){const i=N(s,"BUS_COMP");i&&t.has(`business_component:${i}`)&&e.push({from:{name:s.name,type:"applet"},to:{name:i,type:"business_component"},relationType:"references",inferred:!0})}if(s.type==="view"){const i=N(s,"BUS_OBJECT");i&&t.has(`business_object:${i}`)&&e.push({from:{name:s.name,type:"view"},to:{name:i,type:"business_object"},relationType:"references",inferred:!0});for(const r of s.children)if(r.type==="applet"){const u=N(r,"APPLET")??r.name;t.has(`applet:${u}`)&&e.push({from:{name:s.name,type:"view"},to:{name:u,type:"applet"},relationType:"contains",inferred:!0})}}if(s.type==="screen"){for(const i of s.children)if(i.type==="view"){const r=N(i,"VIEW")??i.name;t.has(`view:${r}`)&&e.push({from:{name:s.name,type:"screen"},to:{name:r,type:"view"},relationType:"contains",inferred:!0})}}if(s.type==="business_object"){for(const i of s.children)if(i.type==="business_component"){const r=N(i,"BUS_COMP")??i.name;t.has(`business_component:${r}`)&&e.push({from:{name:s.name,type:"business_object"},to:{name:r,type:"business_component"},relationType:"contains",inferred:!0})}}if(s.type==="workflow"){const i=N(s,"BUS_OBJECT");i&&t.has(`business_object:${i}`)&&e.push({from:{name:s.name,type:"workflow"},to:{name:i,type:"business_object"},relationType:"references",inferred:!0});for(const r of s.children){const u=N(r,"BUS_SERVICE");u&&t.has(`business_service:${u}`)&&e.push({from:{name:s.name,type:"workflow"},to:{name:u,type:"business_service"},relationType:"uses",inferred:!0})}}if(s.type==="integration_object"){const i=N(s,"BUS_COMP");i&&t.has(`business_component:${i}`)&&e.push({from:{name:s.name,type:"integration_object"},to:{name:i,type:"business_component"},relationType:"references",inferred:!0})}if(s.type==="business_component"){const i=N(s,"TABLE");i&&e.push({from:{name:s.name,type:"business_component"},to:{name:i,type:"table"},relationType:"based_on",inferred:!0});for(const r of s.children)if(r.type==="link"){const u=N(r,"CHILD_BC");u&&t.has(`business_component:${u}`)&&e.push({from:{name:s.name,type:"business_component"},to:{name:u,type:"business_component"},relationType:"linked_to",inferred:!0})}}}return e}self.onmessage=n=>{const{type:e,content:t,fileName:s}=n.data;if(e==="parse")try{self.postMessage({type:"progress",status:"parsing",progress:20});const r=new He({ignoreAttributes:!1,attributeNamePrefix:"@_",allowBooleanAttributes:!0,parseAttributeValue:!1,isArray:()=>!0}).parse(t);self.postMessage({type:"progress",status:"extracting",progress:50});const u=$(r,"REPOSITORY");if(u.length===0){self.postMessage({type:"error",message:"SIF file missing REPOSITORY root element"});return}const a=u[0],o=I(a,"NAME")??"Unknown",f=$(a,"PROJECT"),l=f.length>0?I(f[0],"NAME"):void 0,c=[];for(const E of f){const O=E,S=I(O,"NAME")??"Unknown";for(const[d,A]of Object.entries(Qe))for(const M of $(O,d)){const j=M,B=I(j,"NAME");B&&c.push({name:B,type:A,project:S,properties:ee(j),children:tt(j,B),inactive:I(j,"INACTIVE")==="Y"||void 0})}}self.postMessage({type:"progress",status:"inferring",progress:80});const p=nt(c),y=[...new Set(c.map(E=>E.type))],P={metadata:{fileName:s,repositoryName:o,projectName:l,objectCount:c.length,objectTypes:y,extractedAt:new Date().toISOString()},objects:c,dependencies:p};self.postMessage({type:"progress",status:"done",progress:100}),self.postMessage({type:"result",data:P})}catch(i){self.postMessage({type:"error",message:i instanceof Error?i.message:String(i)})}}})();
|
|
3
|
+
`||n==="\r"}function G(n,e){const t=e;for(;e<n.length;e++)if(n[e]=="?"||n[e]==" "){const s=n.substr(t,e-t);if(e>5&&s==="xml")return h("InvalidXml","XML declaration allowed only at the start of the document.",g(n,e));if(n[e]=="?"&&n[e+1]==">"){e++;break}else continue}return e}function X(n,e){if(n.length>e+5&&n[e+1]==="-"&&n[e+2]==="-"){for(e+=3;e<n.length;e++)if(n[e]==="-"&&n[e+1]==="-"&&n[e+2]===">"){e+=2;break}}else if(n.length>e+8&&n[e+1]==="D"&&n[e+2]==="O"&&n[e+3]==="C"&&n[e+4]==="T"&&n[e+5]==="Y"&&n[e+6]==="P"&&n[e+7]==="E"){let t=1;for(e+=8;e<n.length;e++)if(n[e]==="<")t++;else if(n[e]===">"&&(t--,t===0))break}else if(n.length>e+9&&n[e+1]==="["&&n[e+2]==="C"&&n[e+3]==="D"&&n[e+4]==="A"&&n[e+5]==="T"&&n[e+6]==="A"&&n[e+7]==="["){for(e+=8;e<n.length;e++)if(n[e]==="]"&&n[e+1]==="]"&&n[e+2]===">"){e+=2;break}}return e}const ae='"',ue="'";function le(n,e){let t="",s="",i=!1;for(;e<n.length;e++){if(n[e]===ae||n[e]===ue)s===""?s=n[e]:s!==n[e]||(s="");else if(n[e]===">"&&s===""){i=!0;break}t+=n[e]}return s!==""?!1:{value:t,index:e,tagClosed:i}}const fe=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Z(n,e){const t=W(n,fe),s={};for(let i=0;i<t.length;i++){if(t[i][1].length===0)return h("InvalidAttr","Attribute '"+t[i][2]+"' has no space in starting.",_(t[i]));if(t[i][3]!==void 0&&t[i][4]===void 0)return h("InvalidAttr","Attribute '"+t[i][2]+"' is without value.",_(t[i]));if(t[i][3]===void 0&&!e.allowBooleanAttributes)return h("InvalidAttr","boolean attribute '"+t[i][2]+"' is not allowed.",_(t[i]));const r=t[i][2];if(!pe(r))return h("InvalidAttr","Attribute '"+r+"' is an invalid name.",_(t[i]));if(!Object.prototype.hasOwnProperty.call(s,r))s[r]=1;else return h("InvalidAttr","Attribute '"+r+"' is repeated.",_(t[i]))}return!0}function ce(n,e){let t=/\d/;for(n[e]==="x"&&(e++,t=/[\da-fA-F]/);e<n.length;e++){if(n[e]===";")return e;if(!n[e].match(t))break}return-1}function he(n,e){if(e++,n[e]===";")return-1;if(n[e]==="#")return e++,ce(n,e);let t=0;for(;e<n.length;e++,t++)if(!(n[e].match(/\w/)&&t<20)){if(n[e]===";")break;return-1}return e}function h(n,e,t){return{err:{code:n,msg:e,line:t.line||t,col:t.col}}}function pe(n){return M(n)}function de(n){return M(n)}function g(n,e){const t=n.substring(0,e).split(/\r?\n/);return{line:t.length,col:t[t.length-1].length+1}}function _(n){return n.startIndex+n[1].length}const J=n=>k.includes(n)?"__"+n:n,ge={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(n,e){return e},attributeValueProcessor:function(n,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(n,e,t){return n},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:J};function Ee(n,e){if(typeof n!="string")return;const t=n.toLowerCase();if(k.some(s=>t===s.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${n}" is a reserved JavaScript keyword that could cause prototype pollution`);if(Y.some(s=>t===s.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${n}" is a reserved JavaScript keyword that could cause prototype pollution`)}function K(n){return typeof n=="boolean"?{enabled:n,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,maxEntityCount:100,allowedTags:null,tagFilter:null}:typeof n=="object"&&n!==null?{enabled:n.enabled!==!1,maxEntitySize:Math.max(1,n.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,n.maxExpansionDepth??10),maxTotalExpansions:Math.max(1,n.maxTotalExpansions??1e3),maxExpandedLength:Math.max(1,n.maxExpandedLength??1e5),maxEntityCount:Math.max(1,n.maxEntityCount??100),allowedTags:n.allowedTags??null,tagFilter:n.tagFilter??null}:K(!0)}const be=function(n){const e=Object.assign({},ge,n),t=[{value:e.attributeNamePrefix,name:"attributeNamePrefix"},{value:e.attributesGroupName,name:"attributesGroupName"},{value:e.textNodeName,name:"textNodeName"},{value:e.cdataPropName,name:"cdataPropName"},{value:e.commentPropName,name:"commentPropName"}];for(const{value:s,name:i}of t)s&&Ee(s,i);return e.onDangerousProperty===null&&(e.onDangerousProperty=J),e.processEntities=K(e.processEntities),e.stopNodes&&Array.isArray(e.stopNodes)&&(e.stopNodes=e.stopNodes.map(s=>typeof s=="string"&&s.startsWith("*.")?".."+s.substring(2):s)),e};let v;typeof Symbol!="function"?v="@@xmlMetadata":v=Symbol("XML Node Metadata");class N{constructor(e){this.tagname=e,this.child=[],this[":@"]=Object.create(null)}add(e,t){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e,t){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child}),t!==void 0&&(this.child[this.child.length-1][v]={startIndex:t})}static getMetaDataSymbol(){return v}}class ye{constructor(e){this.suppressValidationErr=!e,this.options=e}readDocType(e,t){const s=Object.create(null);let i=0;if(e[t+3]==="O"&&e[t+4]==="C"&&e[t+5]==="T"&&e[t+6]==="Y"&&e[t+7]==="P"&&e[t+8]==="E"){t=t+9;let r=1,u=!1,a=!1,o="";for(;t<e.length;t++)if(e[t]==="<"&&!a){if(u&&T(e,"!ENTITY",t)){t+=7;let f,l;if([f,l,t]=this.readEntityExp(e,t+1,this.suppressValidationErr),l.indexOf("&")===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&i>=this.options.maxEntityCount)throw new Error(`Entity count (${i+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);const c=f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");s[f]={regx:RegExp(`&${c};`,"g"),val:l},i++}}else if(u&&T(e,"!ELEMENT",t)){t+=8;const{index:f}=this.readElementExp(e,t+1);t=f}else if(u&&T(e,"!ATTLIST",t))t+=8;else if(u&&T(e,"!NOTATION",t)){t+=9;const{index:f}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=f}else if(T(e,"!--",t))a=!0;else throw new Error("Invalid DOCTYPE");r++,o=""}else if(e[t]===">"){if(a?e[t-1]==="-"&&e[t-2]==="-"&&(a=!1,r--):r--,r===0)break}else e[t]==="["?u=!0:o+=e[t];if(r!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:s,i:t}}readEntityExp(e,t){t=b(e,t);const s=t;for(;t<e.length&&!/\s/.test(e[t])&&e[t]!=='"'&&e[t]!=="'";)t++;let i=e.substring(s,t);if(C(i),t=b(e,t),!this.suppressValidationErr){if(e.substring(t,t+6).toUpperCase()==="SYSTEM")throw new Error("External entities are not supported");if(e[t]==="%")throw new Error("Parameter entities are not supported")}let r="";if([t,r]=this.readIdentifierVal(e,t,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&r.length>this.options.maxEntitySize)throw new Error(`Entity "${i}" size (${r.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return t--,[i,r,t]}readNotationExp(e,t){t=b(e,t);const s=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(s,t);!this.suppressValidationErr&&C(i),t=b(e,t);const r=e.substring(t,t+6).toUpperCase();if(!this.suppressValidationErr&&r!=="SYSTEM"&&r!=="PUBLIC")throw new Error(`Expected SYSTEM or PUBLIC, found "${r}"`);t+=r.length,t=b(e,t);let u=null,a=null;if(r==="PUBLIC")[t,u]=this.readIdentifierVal(e,t,"publicIdentifier"),t=b(e,t),(e[t]==='"'||e[t]==="'")&&([t,a]=this.readIdentifierVal(e,t,"systemIdentifier"));else if(r==="SYSTEM"&&([t,a]=this.readIdentifierVal(e,t,"systemIdentifier"),!this.suppressValidationErr&&!a))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:i,publicIdentifier:u,systemIdentifier:a,index:--t}}readIdentifierVal(e,t,s){let i="";const r=e[t];if(r!=='"'&&r!=="'")throw new Error(`Expected quoted string, found "${r}"`);t++;const u=t;for(;t<e.length&&e[t]!==r;)t++;if(i=e.substring(u,t),e[t]!==r)throw new Error(`Unterminated ${s} value`);return t++,[t,i]}readElementExp(e,t){t=b(e,t);const s=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(s,t);if(!this.suppressValidationErr&&!M(i))throw new Error(`Invalid element name: "${i}"`);t=b(e,t);let r="";if(e[t]==="E"&&T(e,"MPTY",t))t+=4;else if(e[t]==="A"&&T(e,"NY",t))t+=2;else if(e[t]==="("){t++;const u=t;for(;t<e.length&&e[t]!==")";)t++;if(r=e.substring(u,t),e[t]!==")")throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[t]}"`);return{elementName:i,contentModel:r.trim(),index:t}}readAttlistExp(e,t){t=b(e,t);let s=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;let i=e.substring(s,t);for(C(i),t=b(e,t),s=t;t<e.length&&!/\s/.test(e[t]);)t++;let r=e.substring(s,t);if(!C(r))throw new Error(`Invalid attribute name: "${r}"`);t=b(e,t);let u="";if(e.substring(t,t+8).toUpperCase()==="NOTATION"){if(u="NOTATION",t+=8,t=b(e,t),e[t]!=="(")throw new Error(`Expected '(', found "${e[t]}"`);t++;let o=[];for(;t<e.length&&e[t]!==")";){const f=t;for(;t<e.length&&e[t]!=="|"&&e[t]!==")";)t++;let l=e.substring(f,t);if(l=l.trim(),!C(l))throw new Error(`Invalid notation name: "${l}"`);o.push(l),e[t]==="|"&&(t++,t=b(e,t))}if(e[t]!==")")throw new Error("Unterminated list of notations");t++,u+=" ("+o.join("|")+")"}else{const o=t;for(;t<e.length&&!/\s/.test(e[t]);)t++;u+=e.substring(o,t);const f=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!f.includes(u.toUpperCase()))throw new Error(`Invalid attribute type: "${u}"`)}t=b(e,t);let a="";return e.substring(t,t+8).toUpperCase()==="#REQUIRED"?(a="#REQUIRED",t+=8):e.substring(t,t+7).toUpperCase()==="#IMPLIED"?(a="#IMPLIED",t+=7):[t,a]=this.readIdentifierVal(e,t,"ATTLIST"),{elementName:i,attributeName:r,attributeType:u,defaultValue:a,index:t}}}const b=(n,e)=>{for(;e<n.length&&/\s/.test(n[e]);)e++;return e};function T(n,e,t){for(let s=0;s<e.length;s++)if(e[s]!==n[t+s+1])return!1;return!0}function C(n){if(M(n))return n;throw new Error(`Invalid entity name ${n}`)}const me=/^[-+]?0x[a-fA-F0-9]+$/,Ne=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Te={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original"};function we(n,e={}){if(e=Object.assign({},Te,e),!n||typeof n!="string")return n;let t=n.trim();if(t.length===0)return n;if(e.skipLike!==void 0&&e.skipLike.test(t))return n;if(t==="0")return 0;if(e.hex&&me.test(t))return Ce(t,16);if(isFinite(t)){if(t.includes("e")||t.includes("E"))return Se(n,t,e);{const s=Ne.exec(t);if(s){const i=s[1]||"",r=s[2];let u=_e(s[3]);const a=i?n[r.length+1]===".":n[r.length]===".";if(!e.leadingZeros&&(r.length>1||r.length===1&&!a))return n;{const o=Number(t),f=String(o);if(o===0)return o;if(f.search(/[eE]/)!==-1)return e.eNotation?o:n;if(t.indexOf(".")!==-1)return f==="0"||f===u||f===`${i}${u}`?o:n;let l=r?u:t;return r?l===f||i+l===f?o:n:l===f||l===i+f?o:n}}else return n}}else return Pe(n,Number(t),e)}const Ie=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function Se(n,e,t){if(!t.eNotation)return n;const s=e.match(Ie);if(s){let i=s[1]||"";const r=s[3].indexOf("e")===-1?"E":"e",u=s[2],a=i?n[u.length+1]===r:n[u.length]===r;return u.length>1&&a?n:u.length===1&&(s[3].startsWith(`.${r}`)||s[3][0]===r)?Number(e):u.length>0?t.leadingZeros&&!a?(e=(s[1]||"")+s[3],Number(e)):n:Number(e)}else return n}function _e(n){return n&&n.indexOf(".")!==-1&&(n=n.replace(/0+$/,""),n==="."?n="0":n[0]==="."?n="0"+n:n[n.length-1]==="."&&(n=n.substring(0,n.length-1))),n}function Ce(n,e){if(parseInt)return parseInt(n,e);if(Number.parseInt)return Number.parseInt(n,e);if(window&&window.parseInt)return window.parseInt(n,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}function Pe(n,e,t){const s=e===1/0;switch(t.infinity.toLowerCase()){case"null":return null;case"infinity":return e;case"string":return s?"Infinity":"-Infinity";case"original":default:return n}}function Oe(n){return typeof n=="function"?n:Array.isArray(n)?e=>{for(const t of n)if(typeof t=="string"&&e===t||t instanceof RegExp&&t.test(e))return!0}:()=>!1}class q{constructor(e,t={}){this.pattern=e,this.separator=t.separator||".",this.segments=this._parse(e),this._hasDeepWildcard=this.segments.some(s=>s.type==="deep-wildcard"),this._hasAttributeCondition=this.segments.some(s=>s.attrName!==void 0),this._hasPositionSelector=this.segments.some(s=>s.position!==void 0)}_parse(e){const t=[];let s=0,i="";for(;s<e.length;)e[s]===this.separator?s+1<e.length&&e[s+1]===this.separator?(i.trim()&&(t.push(this._parseSegment(i.trim())),i=""),t.push({type:"deep-wildcard"}),s+=2):(i.trim()&&t.push(this._parseSegment(i.trim())),i="",s++):(i+=e[s],s++);return i.trim()&&t.push(this._parseSegment(i.trim())),t}_parseSegment(e){const t={type:"tag"};let s=null,i=e;const r=e.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(r&&(i=r[1]+r[3],r[2])){const l=r[2].slice(1,-1);l&&(s=l)}let u,a=i;if(i.includes("::")){const l=i.indexOf("::");if(u=i.substring(0,l).trim(),a=i.substring(l+2).trim(),!u)throw new Error(`Invalid namespace in pattern: ${e}`)}let o,f=null;if(a.includes(":")){const l=a.lastIndexOf(":"),c=a.substring(0,l).trim(),p=a.substring(l+1).trim();["first","last","odd","even"].includes(p)||/^nth\(\d+\)$/.test(p)?(o=c,f=p):o=a}else o=a;if(!o)throw new Error(`Invalid segment pattern: ${e}`);if(t.tag=o,u&&(t.namespace=u),s)if(s.includes("=")){const l=s.indexOf("=");t.attrName=s.substring(0,l).trim(),t.attrValue=s.substring(l+1).trim()}else t.attrName=s.trim();if(f){const l=f.match(/^nth\((\d+)\)$/);l?(t.position="nth",t.positionValue=parseInt(l[1],10)):t.position=f}return t}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}const Ae=new Set(["push","pop","reset","updateCurrent","restore"]);class xe{constructor(e={}){this.separator=e.separator||".",this.path=[],this.siblingStacks=[]}push(e,t=null,s=null){if(this.path.length>0){const l=this.path[this.path.length-1];l.values=void 0}const i=this.path.length;this.siblingStacks[i]||(this.siblingStacks[i]=new Map);const r=this.siblingStacks[i],u=s?`${s}:${e}`:e,a=r.get(u)||0;let o=0;for(const l of r.values())o+=l;r.set(u,a+1);const f={tag:e,position:o,counter:a};s!=null&&(f.namespace=s),t!=null&&(f.values=t),this.path.push(f)}pop(){if(this.path.length===0)return;const e=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),e}updateCurrent(e){if(this.path.length>0){const t=this.path[this.path.length-1];e!=null&&(t.values=e)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(e){var s;return this.path.length===0||(s=this.path[this.path.length-1].values)==null?void 0:s[e]}hasAttr(e){if(this.path.length===0)return!1;const t=this.path[this.path.length-1];return t.values!==void 0&&e in t.values}getPosition(){return this.path.length===0?-1:this.path[this.path.length-1].position??0}getCounter(){return this.path.length===0?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(e,t=!0){const s=e||this.separator;return this.path.map(i=>t&&i.namespace?`${i.namespace}:${i.tag}`:i.tag).join(s)}toArray(){return this.path.map(e=>e.tag)}reset(){this.path=[],this.siblingStacks=[]}matches(e){const t=e.segments;return t.length===0?!1:e.hasDeepWildcard()?this._matchWithDeepWildcard(t):this._matchSimple(t)}_matchSimple(e){if(this.path.length!==e.length)return!1;for(let t=0;t<e.length;t++){const s=e[t],i=this.path[t],r=t===this.path.length-1;if(!this._matchSegment(s,i,r))return!1}return!0}_matchWithDeepWildcard(e){let t=this.path.length-1,s=e.length-1;for(;s>=0&&t>=0;){const i=e[s];if(i.type==="deep-wildcard"){if(s--,s<0)return!0;const r=e[s];let u=!1;for(let a=t;a>=0;a--){const o=a===this.path.length-1;if(this._matchSegment(r,this.path[a],o)){t=a-1,s--,u=!0;break}}if(!u)return!1}else{const r=t===this.path.length-1;if(!this._matchSegment(i,this.path[t],r))return!1;t--,s--}}return s<0}_matchSegment(e,t,s){if(e.tag!=="*"&&e.tag!==t.tag||e.namespace!==void 0&&e.namespace!=="*"&&e.namespace!==t.namespace)return!1;if(e.attrName!==void 0){if(!s||!t.values||!(e.attrName in t.values))return!1;if(e.attrValue!==void 0){const i=t.values[e.attrName];if(String(i)!==String(e.attrValue))return!1}}if(e.position!==void 0){if(!s)return!1;const i=t.counter??0;if(e.position==="first"&&i!==0)return!1;if(e.position==="odd"&&i%2!==1)return!1;if(e.position==="even"&&i%2!==0)return!1;if(e.position==="nth"&&i!==e.positionValue)return!1}return!0}snapshot(){return{path:this.path.map(e=>({...e})),siblingStacks:this.siblingStacks.map(e=>new Map(e))}}restore(e){this.path=e.path.map(t=>({...t})),this.siblingStacks=e.siblingStacks.map(t=>new Map(t))}readOnly(){const e=this;return new Proxy(e,{get(t,s,i){if(Ae.has(s))return()=>{throw new TypeError(`Cannot call '${s}' on a read-only Matcher. Obtain a writable instance to mutate state.`)};const r=Reflect.get(t,s,i);return s==="path"||s==="siblingStacks"?Object.freeze(Array.isArray(r)?r.map(u=>u instanceof Map?Object.freeze(new Map(u)):Object.freeze({...u})):r):typeof r=="function"?r.bind(t):r},set(t,s){throw new TypeError(`Cannot set property '${String(s)}' on a read-only Matcher.`)},deleteProperty(t,s){throw new TypeError(`Cannot delete property '${String(s)}' from a read-only Matcher.`)}})}}function Me(n,e){if(!n)return{};const t=e.attributesGroupName?n[e.attributesGroupName]:n;if(!t)return{};const s={};for(const i in t)if(i.startsWith(e.attributeNamePrefix)){const r=i.substring(e.attributeNamePrefix.length);s[r]=t[i]}else s[i]=t[i];return s}function ve(n){if(!n||typeof n!="string")return;const e=n.indexOf(":");if(e!==-1&&e>0){const t=n.substring(0,e);if(t!=="xmlns")return t}}class $e{constructor(e){if(this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(t,s)=>H(s,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(t,s)=>H(s,16,"&#x")}},this.addExternalEntities=je,this.parseXml=Fe,this.parseTextData=ke,this.resolveNameSpace=Ve,this.buildAttributesMap=Re,this.isItStopNode=Ye,this.replaceEntitiesValue=Ue,this.readStopNodeData=Ge,this.saveTextToParentTag=We,this.addChild=Be,this.ignoreAttributesFn=Oe(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.matcher=new xe,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodeExpressions=[];for(let t=0;t<this.options.stopNodes.length;t++){const s=this.options.stopNodes[t];typeof s=="string"?this.stopNodeExpressions.push(new q(s)):s instanceof q&&this.stopNodeExpressions.push(s)}}}}function je(n){const e=Object.keys(n);for(let t=0;t<e.length;t++){const s=e[t],i=s.replace(/[.\-+*:]/g,"\\.");this.lastEntities[s]={regex:new RegExp("&"+i+";","g"),val:n[s]}}}function ke(n,e,t,s,i,r,u){if(n!==void 0&&(this.options.trimValues&&!s&&(n=n.trim()),n.length>0)){u||(n=this.replaceEntitiesValue(n,e,t));const a=this.options.jPath?t.toString():t,o=this.options.tagValueProcessor(e,n,a,i,r);return o==null?n:typeof o!=typeof n||o!==n?o:this.options.trimValues?L(n,this.options.parseTagValue,this.options.numberParseOptions):n.trim()===n?L(n,this.options.parseTagValue,this.options.numberParseOptions):n}}function Ve(n){if(this.options.removeNSPrefix){const e=n.split(":"),t=n.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(n=t+e[1])}return n}const Le=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function Re(n,e,t){if(this.options.ignoreAttributes!==!0&&typeof n=="string"){const s=W(n,Le),i=s.length,r={},u={};for(let a=0;a<i;a++){const o=this.resolveNameSpace(s[a][1]),f=s[a][4];if(o.length&&f!==void 0){let l=f;this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l,t,this.readonlyMatcher),u[o]=l}}Object.keys(u).length>0&&typeof e=="object"&&e.updateCurrent&&e.updateCurrent(u);for(let a=0;a<i;a++){const o=this.resolveNameSpace(s[a][1]),f=this.options.jPath?e.toString():this.readonlyMatcher;if(this.ignoreAttributesFn(o,f))continue;let l=s[a][4],c=this.options.attributeNamePrefix+o;if(o.length)if(this.options.transformAttributeName&&(c=this.options.transformAttributeName(c)),c=Q(c,this.options),l!==void 0){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l,t,this.readonlyMatcher);const p=this.options.jPath?e.toString():this.readonlyMatcher,y=this.options.attributeValueProcessor(o,l,p);y==null?r[c]=l:typeof y!=typeof l||y!==l?r[c]=y:r[c]=L(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(r[c]=!0)}if(!Object.keys(r).length)return;if(this.options.attributesGroupName){const a={};return a[this.options.attributesGroupName]=r,a}return r}}const Fe=function(n){n=n.replace(/\r\n?/g,`
|
|
4
|
+
`);const e=new N("!xml");let t=e,s="";this.matcher.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0;const i=new ye(this.options.processEntities);for(let r=0;r<n.length;r++)if(n[r]==="<")if(n[r+1]==="/"){const a=w(n,">",r,"Closing Tag is not closed.");let o=n.substring(r+2,a).trim();if(this.options.removeNSPrefix){const l=o.indexOf(":");l!==-1&&(o=o.substr(l+1))}o=R(this.options.transformTagName,o,"",this.options).tagName,t&&(s=this.saveTextToParentTag(s,t,this.readonlyMatcher));const f=this.matcher.getCurrentTag();if(o&&this.options.unpairedTags.indexOf(o)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${o}>`);f&&this.options.unpairedTags.indexOf(f)!==-1&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,t=this.tagsNodeStack.pop(),s="",r=a}else if(n[r+1]==="?"){let a=V(n,r,!1,"?>");if(!a)throw new Error("Pi Tag is not closed.");if(s=this.saveTextToParentTag(s,t,this.readonlyMatcher),!(this.options.ignoreDeclaration&&a.tagName==="?xml"||this.options.ignorePiTags)){const o=new N(a.tagName);o.add(this.options.textNodeName,""),a.tagName!==a.tagExp&&a.attrExpPresent&&(o[":@"]=this.buildAttributesMap(a.tagExp,this.matcher,a.tagName)),this.addChild(t,o,this.readonlyMatcher,r)}r=a.closeIndex+1}else if(n.substr(r+1,3)==="!--"){const a=w(n,"-->",r+4,"Comment is not closed.");if(this.options.commentPropName){const o=n.substring(r+4,a-2);s=this.saveTextToParentTag(s,t,this.readonlyMatcher),t.add(this.options.commentPropName,[{[this.options.textNodeName]:o}])}r=a}else if(n.substr(r+1,2)==="!D"){const a=i.readDocType(n,r);this.docTypeEntities=a.entities,r=a.i}else if(n.substr(r+1,2)==="!["){const a=w(n,"]]>",r,"CDATA is not closed.")-2,o=n.substring(r+9,a);s=this.saveTextToParentTag(s,t,this.readonlyMatcher);let f=this.parseTextData(o,t.tagname,this.readonlyMatcher,!0,!1,!0,!0);f==null&&(f=""),this.options.cdataPropName?t.add(this.options.cdataPropName,[{[this.options.textNodeName]:o}]):t.add(this.options.textNodeName,f),r=a+2}else{let a=V(n,r,this.options.removeNSPrefix);if(!a){const d=n.substring(Math.max(0,r-50),Math.min(n.length,r+50));throw new Error(`readTagExp returned undefined at position ${r}. Context: "${d}"`)}let o=a.tagName;const f=a.rawTagName;let l=a.tagExp,c=a.attrExpPresent,p=a.closeIndex;if({tagName:o,tagExp:l}=R(this.options.transformTagName,o,l,this.options),this.options.strictReservedNames&&(o===this.options.commentPropName||o===this.options.cdataPropName||o===this.options.textNodeName||o===this.options.attributesGroupName))throw new Error(`Invalid tag name: ${o}`);t&&s&&t.tagname!=="!xml"&&(s=this.saveTextToParentTag(s,t,this.readonlyMatcher,!1));const y=t;y&&this.options.unpairedTags.indexOf(y.tagname)!==-1&&(t=this.tagsNodeStack.pop(),this.matcher.pop());let P=!1;l.length>0&&l.lastIndexOf("/")===l.length-1&&(P=!0,o[o.length-1]==="/"?(o=o.substr(0,o.length-1),l=o):l=l.substr(0,l.length-1),c=o!==l);let E=null,O;O=ve(f),o!==e.tagname&&this.matcher.push(o,{},O),o!==l&&c&&(E=this.buildAttributesMap(l,this.matcher,o),E&&Me(E,this.options)),o!==e.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode(this.stopNodeExpressions,this.matcher));const S=r;if(this.isCurrentNodeStopNode){let d="";if(P)r=a.closeIndex;else if(this.options.unpairedTags.indexOf(o)!==-1)r=a.closeIndex;else{const x=this.readStopNodeData(n,f,p+1);if(!x)throw new Error(`Unexpected end of ${f}`);r=x.i,d=x.tagContent}const A=new N(o);E&&(A[":@"]=E),A.add(this.options.textNodeName,d),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(t,A,this.readonlyMatcher,S)}else{if(P){({tagName:o,tagExp:l}=R(this.options.transformTagName,o,l,this.options));const d=new N(o);E&&(d[":@"]=E),this.addChild(t,d,this.readonlyMatcher,S),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if(this.options.unpairedTags.indexOf(o)!==-1){const d=new N(o);E&&(d[":@"]=E),this.addChild(t,d,this.readonlyMatcher,S),this.matcher.pop(),this.isCurrentNodeStopNode=!1,r=a.closeIndex;continue}else{const d=new N(o);if(this.tagsNodeStack.length>this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(t),E&&(d[":@"]=E),this.addChild(t,d,this.readonlyMatcher,S),t=d}s="",r=p}}else s+=n[r];return e.child};function Be(n,e,t,s){this.options.captureMetaData||(s=void 0);const i=this.options.jPath?t.toString():t,r=this.options.updateTag(e.tagname,i,e[":@"]);r===!1||(typeof r=="string"&&(e.tagname=r),n.addChild(e,s))}function Ue(n,e,t){const s=this.options.processEntities;if(!s||!s.enabled)return n;if(s.allowedTags){const i=this.options.jPath?t.toString():t;if(!(Array.isArray(s.allowedTags)?s.allowedTags.includes(e):s.allowedTags(e,i)))return n}if(s.tagFilter){const i=this.options.jPath?t.toString():t;if(!s.tagFilter(e,i))return n}for(const i of Object.keys(this.docTypeEntities)){const r=this.docTypeEntities[i],u=n.match(r.regx);if(u){if(this.entityExpansionCount+=u.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);const a=n.length;if(n=n.replace(r.regx,r.val),s.maxExpandedLength&&(this.currentExpandedLength+=n.length-a,this.currentExpandedLength>s.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${s.maxExpandedLength}`)}}for(const i of Object.keys(this.lastEntities)){const r=this.lastEntities[i],u=n.match(r.regex);if(u&&(this.entityExpansionCount+=u.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);n=n.replace(r.regex,r.val)}if(n.indexOf("&")===-1)return n;if(this.options.htmlEntities)for(const i of Object.keys(this.htmlEntities)){const r=this.htmlEntities[i],u=n.match(r.regex);if(u&&(this.entityExpansionCount+=u.length,s.maxTotalExpansions&&this.entityExpansionCount>s.maxTotalExpansions))throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${s.maxTotalExpansions}`);n=n.replace(r.regex,r.val)}return n=n.replace(this.ampEntity.regex,this.ampEntity.val),n}function We(n,e,t,s){return n&&(s===void 0&&(s=e.child.length===0),n=this.parseTextData(n,e.tagname,t,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,s),n!==void 0&&n!==""&&e.add(this.options.textNodeName,n),n=""),n}function Ye(n,e){if(!n||n.length===0)return!1;for(let t=0;t<n.length;t++)if(e.matches(n[t]))return!0;return!1}function ze(n,e,t=">"){let s,i="";for(let r=e;r<n.length;r++){let u=n[r];if(s)u===s&&(s="");else if(u==='"'||u==="'")s=u;else if(u===t[0])if(t[1]){if(n[r+1]===t[1])return{data:i,index:r}}else return{data:i,index:r};else u===" "&&(u=" ");i+=u}}function w(n,e,t,s){const i=n.indexOf(e,t);if(i===-1)throw new Error(s);return i+e.length-1}function V(n,e,t,s=">"){const i=ze(n,e+1,s);if(!i)return;let r=i.data;const u=i.index,a=r.search(/\s/);let o=r,f=!0;a!==-1&&(o=r.substring(0,a),r=r.substring(a+1).trimStart());const l=o;if(t){const c=o.indexOf(":");c!==-1&&(o=o.substr(c+1),f=o!==i.data.substr(c+1))}return{tagName:o,tagExp:r,closeIndex:u,attrExpPresent:f,rawTagName:l}}function Ge(n,e,t){const s=t;let i=1;for(;t<n.length;t++)if(n[t]==="<")if(n[t+1]==="/"){const r=w(n,">",t,`${e} is not closed`);if(n.substring(t+2,r).trim()===e&&(i--,i===0))return{tagContent:n.substring(s,t),i:r};t=r}else if(n[t+1]==="?")t=w(n,"?>",t+1,"StopNode is not closed.");else if(n.substr(t+1,3)==="!--")t=w(n,"-->",t+3,"StopNode is not closed.");else if(n.substr(t+1,2)==="![")t=w(n,"]]>",t,"StopNode is not closed.")-2;else{const r=V(n,t,">");r&&((r&&r.tagName)===e&&r.tagExp[r.tagExp.length-1]!=="/"&&i++,t=r.closeIndex)}}function L(n,e,t){if(e&&typeof n=="string"){const s=n.trim();return s==="true"?!0:s==="false"?!1:we(n,t)}else return re(n)?n:""}function H(n,e,t){const s=Number.parseInt(n,e);return s>=0&&s<=1114111?String.fromCodePoint(s):t+n+";"}function R(n,e,t,s){if(n){const i=n(e);t===e&&(t=i),e=i}return e=Q(e,s),{tagName:e,tagExp:t}}function Q(n,e){if(Y.includes(n))throw new Error(`[SECURITY] Invalid name: "${n}" is a reserved JavaScript keyword that could cause prototype pollution`);return k.includes(n)?e.onDangerousProperty(n):n}const F=N.getMetaDataSymbol();function Xe(n,e){if(!n||typeof n!="object")return{};if(!e)return n;const t={};for(const s in n)if(s.startsWith(e)){const i=s.substring(e.length);t[i]=n[s]}else t[s]=n[s];return t}function Ze(n,e,t,s){return D(n,e,t,s)}function D(n,e,t,s){let i;const r={};for(let u=0;u<n.length;u++){const a=n[u],o=Je(a);if(o!==void 0&&o!==e.textNodeName){const f=Xe(a[":@"]||{},e.attributeNamePrefix);t.push(o,f)}if(o===e.textNodeName)i===void 0?i=a[o]:i+=""+a[o];else{if(o===void 0)continue;if(a[o]){let f=D(a[o],e,t,s);const l=qe(f,e);if(a[":@"]?Ke(f,a[":@"],s,e):Object.keys(f).length===1&&f[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?f=f[e.textNodeName]:Object.keys(f).length===0&&(e.alwaysCreateTextNode?f[e.textNodeName]="":f=""),a[F]!==void 0&&typeof f=="object"&&f!==null&&(f[F]=a[F]),r[o]!==void 0&&Object.prototype.hasOwnProperty.call(r,o))Array.isArray(r[o])||(r[o]=[r[o]]),r[o].push(f);else{const c=e.jPath?s.toString():s;e.isArray(o,c,l)?r[o]=[f]:r[o]=f}o!==void 0&&o!==e.textNodeName&&t.pop()}}}return typeof i=="string"?i.length>0&&(r[e.textNodeName]=i):i!==void 0&&(r[e.textNodeName]=i),r}function Je(n){const e=Object.keys(n);for(let t=0;t<e.length;t++){const s=e[t];if(s!==":@")return s}}function Ke(n,e,t,s){if(e){const i=Object.keys(e),r=i.length;for(let u=0;u<r;u++){const a=i[u],o=a.startsWith(s.attributeNamePrefix)?a.substring(s.attributeNamePrefix.length):a,f=s.jPath?t.toString()+"."+o:t;s.isArray(a,f,!0,!0)?n[a]=[e[a]]:n[a]=e[a]}}}function qe(n,e){const{textNodeName:t}=e,s=Object.keys(n).length;return!!(s===0||s===1&&(n[t]||typeof n[t]=="boolean"||n[t]===0))}class He{constructor(e){this.externalEntities={},this.options=be(e)}parse(e,t){if(typeof e!="string"&&e.toString)e=e.toString();else if(typeof e!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(t){t===!0&&(t={});const r=oe(e,t);if(r!==!0)throw Error(`${r.err.msg}:${r.err.line}:${r.err.col}`)}const s=new $e(this.options);s.addExternalEntities(this.externalEntities);const i=s.parseXml(e);return this.options.preserveOrder||i===void 0?i:Ze(i,this.options,s.matcher,s.readonlyMatcher)}addEntity(e,t){if(t.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if(t==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=t}static getMetaDataSymbol(){return N.getMetaDataSymbol()}}const Qe={APPLET:"applet",BUSINESS_COMPONENT:"business_component",BUSINESS_OBJECT:"business_object",VIEW:"view",SCREEN:"screen",WORKFLOW:"workflow",INTEGRATION_OBJECT:"integration_object",BUSINESS_SERVICE:"business_service",WEB_TEMPLATE:"web_template",PICK_LIST:"pick_list",TABLE:"table"},De={FIELD:"field",COLUMN:"column",CONTROL:"control",LIST_COLUMN:"list_column",LINK:"link",APPLET_WEB_TEMPLATE:"web_template",VIEW_WEB_TEMPLATE:"web_template",VIEW_APPLET:"applet",SCREEN_VIEW:"view",APPLET_METHOD_MENU_ITEM:"menu_item",BUSINESS_OBJECT_COMPONENT:"business_component",BUSINESS_SERVICE_METHOD:"business_service",WORKFLOW_STEP:"workflow",INTEGRATION_COMPONENT:"business_component"},et=new Set(["NAME","INACTIVE"]);function $(n,e){const t=n[e];return Array.isArray(t)?t:t!=null?[t]:[]}function I(n,e){const t=n[`@_${e}`];return t!=null?String(t):void 0}function ee(n){const e=[];for(const[t,s]of Object.entries(n))t.startsWith("@_")&&!et.has(t.slice(2))&&e.push({name:t.slice(2),value:String(s)});return e}function tt(n,e){const t=[];for(const[s,i]of Object.entries(De))for(const r of $(n,s)){const u=r,a=I(u,"NAME");a&&t.push({name:a,type:i,properties:ee(u),children:[],parentName:e})}return t}function m(n,e){var t;return(t=n.properties.find(s=>s.name===e))==null?void 0:t.value}function nt(n){const e=[],t=new Map;for(const s of n)t.set(`${s.type}:${s.name}`,s);for(const s of n){if(s.type==="applet"){const i=m(s,"BUS_COMP");i&&t.has(`business_component:${i}`)&&e.push({from:{name:s.name,type:"applet"},to:{name:i,type:"business_component"},relationType:"references",inferred:!0})}if(s.type==="view"){const i=m(s,"BUS_OBJECT");i&&t.has(`business_object:${i}`)&&e.push({from:{name:s.name,type:"view"},to:{name:i,type:"business_object"},relationType:"references",inferred:!0});for(const r of s.children)if(r.type==="applet"){const u=m(r,"APPLET")??r.name;t.has(`applet:${u}`)&&e.push({from:{name:s.name,type:"view"},to:{name:u,type:"applet"},relationType:"contains",inferred:!0})}}if(s.type==="screen"){for(const i of s.children)if(i.type==="view"){const r=m(i,"VIEW")??i.name;t.has(`view:${r}`)&&e.push({from:{name:s.name,type:"screen"},to:{name:r,type:"view"},relationType:"contains",inferred:!0})}}if(s.type==="business_object"){for(const i of s.children)if(i.type==="business_component"){const r=m(i,"BUS_COMP")??i.name;t.has(`business_component:${r}`)&&e.push({from:{name:s.name,type:"business_object"},to:{name:r,type:"business_component"},relationType:"contains",inferred:!0})}}if(s.type==="workflow"){const i=m(s,"BUS_OBJECT");i&&t.has(`business_object:${i}`)&&e.push({from:{name:s.name,type:"workflow"},to:{name:i,type:"business_object"},relationType:"references",inferred:!0});for(const r of s.children){const u=m(r,"BUS_SERVICE");u&&t.has(`business_service:${u}`)&&e.push({from:{name:s.name,type:"workflow"},to:{name:u,type:"business_service"},relationType:"uses",inferred:!0})}}if(s.type==="integration_object"){const i=m(s,"BUS_COMP");i&&t.has(`business_component:${i}`)&&e.push({from:{name:s.name,type:"integration_object"},to:{name:i,type:"business_component"},relationType:"references",inferred:!0})}if(s.type==="business_component"){const i=m(s,"TABLE");i&&e.push({from:{name:s.name,type:"business_component"},to:{name:i,type:"table"},relationType:"based_on",inferred:!0});for(const r of s.children)if(r.type==="link"){const u=m(r,"CHILD_BC");u&&t.has(`business_component:${u}`)&&e.push({from:{name:s.name,type:"business_component"},to:{name:u,type:"business_component"},relationType:"linked_to",inferred:!0})}}}return e}self.onmessage=n=>{const{type:e,content:t,fileName:s}=n.data;if(e==="parse")try{self.postMessage({type:"progress",status:"parsing",progress:20});const r=new He({ignoreAttributes:!1,attributeNamePrefix:"@_",allowBooleanAttributes:!0,parseAttributeValue:!1,processEntities:{maxEntityCount:1e5,maxTotalExpansions:1e5,maxExpandedLength:1e7,maxEntitySize:1e5},isArray:()=>!0}).parse(t);self.postMessage({type:"progress",status:"extracting",progress:50});const u=$(r,"REPOSITORY");if(u.length===0){self.postMessage({type:"error",message:"SIF file missing REPOSITORY root element"});return}const a=u[0],o=I(a,"NAME")??"Unknown",f=$(a,"PROJECT"),l=f.length>0?I(f[0],"NAME"):void 0,c=[];for(const E of f){const O=E,S=I(O,"NAME")??"Unknown";for(const[d,A]of Object.entries(Qe))for(const x of $(O,d)){const j=x,B=I(j,"NAME");B&&c.push({name:B,type:A,project:S,properties:ee(j),children:tt(j,B),inactive:I(j,"INACTIVE")==="Y"||void 0})}}self.postMessage({type:"progress",status:"inferring",progress:80});const p=nt(c),y=[...new Set(c.map(E=>E.type))],P={metadata:{fileName:s,repositoryName:o,projectName:l,objectCount:c.length,objectTypes:y,extractedAt:new Date().toISOString()},objects:c,dependencies:p};self.postMessage({type:"progress",status:"done",progress:100}),self.postMessage({type:"result",data:P})}catch(i){self.postMessage({type:"error",message:i instanceof Error?i.message:String(i)})}}})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,a as k,j as e}from"./index-D_SBClB-.js";import{P,L as B}from"./constants-Dd6A34aQ.js";function $(){const[t,s]=l.useState([]),[u,n]=l.useState([]),[i,c]=l.useState(0),[x,b]=l.useState(!0),[h,f]=l.useState(null),d=l.useCallback(async()=>{b(!0),f(null);try{const[r,m]=await Promise.all([k.getSkills(),k.getRecommendations().catch(()=>({recommendations:[]}))]);s(r.skills),c(r.totalTokens),n(m.recommendations)}catch(r){f(r instanceof Error?r.message:"Failed to load skills")}finally{b(!1)}},[]);l.useEffect(()=>{d()},[d]);const N=l.useCallback(async(r,m)=>{s(C=>C.map(w=>w.name===r?{...w,enabled:m}:w));try{await k.toggleSkill(r,m)}catch{d()}},[d]),p=l.useCallback(async r=>{await k.createCustomSkill(r),d()},[d]),y=l.useCallback(async(r,m)=>{await k.updateCustomSkill(r,m),d()},[d]),j=l.useCallback(async r=>{await k.deleteCustomSkill(r),d()},[d]),g=t.filter(r=>r.enabled).reduce((r,m)=>r+m.estimatedTokens,0);return{skills:t,recommendations:u,totalTokens:i,activeTokens:g,loading:x,error:h,refresh:d,toggleSkill:N,createSkill:p,updateSkill:y,deleteSkill:j}}function D({skill:t,onClose:s,onToggle:u,onDelete:n,onEdit:i}){return t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:c=>{c.target===c.currentTarget&&s()},children:e.jsxs("div",{className:"bg-surface rounded-lg shadow-xl w-full max-w-lg p-6 max-h-[80vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold truncate",children:t.name}),e.jsx("button",{onClick:s,className:"text-muted hover:text-foreground text-xl",children:"×"})]}),e.jsx("p",{className:"text-sm text-muted mb-4",children:t.description}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-medium ${t.source==="built-in"?"bg-blue-500/10 text-blue-500":t.source==="custom"?"bg-purple-500/10 text-purple-500":"bg-gray-500/10 text-gray-500"}`,children:t.source}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium bg-edge text-muted",children:t.category}),e.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium bg-edge text-muted",children:[t.estimatedTokens.toLocaleString()," tokens"]})]}),t.phases&&t.phases.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-4",children:t.phases.map(c=>{const x=P[c]??"#6b7280";return e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium",style:{background:`${x}20`,color:x},children:c},c)})}),e.jsx("div",{className:"flex items-center gap-3 mb-4 p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:c=>u(t.name,c.target.checked),className:"w-4 h-4 accent-accent"}),t.enabled?"Enabled":"Disabled"]})}),t.source==="custom"&&e.jsxs("div",{className:"flex gap-2",children:[i&&e.jsx("button",{onClick:()=>i(t),className:"px-3 py-1.5 text-sm border border-edge rounded hover:bg-surface-elevated",children:"Edit"}),n&&t.id&&e.jsx("button",{onClick:()=>n(t.id),className:"px-3 py-1.5 text-sm text-red-500 border border-red-500/30 rounded hover:bg-red-500/10",children:"Delete"})]})]})}):null}const _=["know-me","software-design","security","testing","cost-reducer","research","ddd","frontend-design","other"];function F({open:t,onClose:s,onSubmit:u,editSkill:n}){const[i,c]=l.useState(""),[x,b]=l.useState(""),[h,f]=l.useState("know-me"),[d,N]=l.useState(["IMPLEMENT"]),[p,y]=l.useState(""),[j,g]=l.useState(!1),[r,m]=l.useState(null);l.useEffect(()=>{n?(c(n.name),b(n.description),f(n.category),N(n.phases??["IMPLEMENT"]),y("")):(c(""),b(""),f("know-me"),N(["IMPLEMENT"]),y("")),m(null)},[n,t]);const C=l.useCallback(a=>{N(S=>S.includes(a)?S.filter(T=>T!==a):[...S,a])},[]),w=l.useCallback(async()=>{if(!i.trim()||!x.trim()||!p.trim()||d.length===0){m("All fields are required and at least one phase must be selected.");return}g(!0),m(null);try{await u({name:i.trim(),description:x.trim(),category:h,phases:d,instructions:p.trim()}),s()}catch(a){m(a instanceof Error?a.message:"Failed to save skill")}finally{g(!1)}},[i,x,h,d,p,u,s]);return t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:a=>{a.target===a.currentTarget&&s()},children:e.jsxs("div",{className:"bg-surface rounded-lg shadow-xl w-full max-w-lg p-6 max-h-[85vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:n?"Edit Skill":"Create Custom Skill"}),e.jsx("button",{onClick:s,className:"text-muted hover:text-foreground text-xl",children:"×"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Name"}),e.jsx("input",{type:"text",value:i,onChange:a=>c(a.target.value),placeholder:"my-workflow",disabled:!!n,className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt disabled:opacity-50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Description"}),e.jsx("input",{type:"text",value:x,onChange:a=>b(a.target.value),placeholder:"What does this skill do?",className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Category"}),e.jsx("select",{value:h,onChange:a=>f(a.target.value),className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:_.map(a=>e.jsx("option",{value:a,children:a},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Phases"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:B.map(a=>e.jsx("button",{type:"button",onClick:()=>C(a),className:`px-2 py-1 text-[10px] font-medium rounded-full border transition-colors ${d.includes(a)?"bg-accent/10 border-accent text-accent":"border-edge text-muted hover:border-foreground"}`,children:a},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Instructions"}),e.jsx("textarea",{value:p,onChange:a=>y(a.target.value),rows:6,placeholder:"Instructions for the AI agent when this skill is active...",className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt resize-y"})]}),r&&e.jsx("div",{className:"text-sm p-2 rounded bg-red-500/10 text-red-500",children:r}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:s,className:"px-3 py-1.5 text-sm border border-edge rounded hover:bg-surface-elevated",children:"Cancel"}),e.jsx("button",{onClick:w,disabled:j,className:"px-3 py-1.5 text-sm bg-accent text-white rounded hover:opacity-90 disabled:opacity-50",children:j?"Saving...":n?"Update":"Create"})]})]})]})}):null}const I=4e3;function E({value:t,label:s}){return e.jsxs("div",{className:"p-3 rounded-xl border border-edge bg-surface-alt text-center","data-testid":"metric-card",children:[e.jsx("div",{className:"text-xl font-bold",children:t}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:s})]})}function z({phase:t}){const s=P[t]??"#6b7280";return e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium",style:{background:`${s}20`,color:s},children:t})}function G({source:t}){const s={"built-in":"bg-accent/10 text-accent",filesystem:"bg-muted/10 text-muted",custom:"bg-purple-500/10 text-purple-500"};return e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${s[t]}`,children:t})}function H({skill:t,onToggle:s,onClick:u}){return e.jsxs("div",{className:`p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt cursor-pointer hover:border-accent/50 transition-all ${t.enabled?"":"opacity-50"}`,onClick:()=>u(t),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-medium truncate",children:t.name}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:n=>{n.stopPropagation(),s(t.name,n.target.checked)},onClick:n=>n.stopPropagation(),className:"w-3.5 h-3.5 accent-accent"}),e.jsx(G,{source:t.source}),e.jsxs("span",{className:"text-[10px] text-muted",children:[t.estimatedTokens.toLocaleString()," tok"]})]})]}),e.jsx("p",{className:"text-xs text-muted line-clamp-2",children:t.description})]})}function A({phase:t,skills:s,onToggle:u,onSkillClick:n}){const[i,c]=l.useState(!0),x=P[t]??"#6b7280",b=s.filter(h=>h.enabled).length;return e.jsxs("div",{className:"rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>c(!i),className:"w-full flex items-center justify-between px-3 py-2 text-xs font-medium hover:bg-surface-elevated transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:x}}),t,e.jsxs("span",{className:"px-1.5 py-0.5 rounded-full bg-edge text-[10px]",children:[b,"/",s.length]})]}),e.jsx("span",{className:"text-muted",children:i?"▲":"▼"})]}),i&&e.jsx("div",{className:"px-3 pb-3 space-y-2",children:s.map(h=>e.jsx(H,{skill:h,onToggle:u,onClick:n},h.name))})]})}function U({rec:t}){return e.jsxs("div",{className:"p-3 rounded-lg bg-surface-alt border border-accent/30",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-medium",children:t.skill}),e.jsx(z,{phase:t.phase})]}),e.jsx("p",{className:"text-xs text-muted",children:t.reason})]})}function q({totalTokens:t,activeTokens:s}){const u=Math.min(s/I,1),n=Math.min(t/I,1),i=Math.round(u*100),c=u>.8?"#ef4444":u>.5?"#f59e0b":"#10b981";return e.jsxs("div",{"data-testid":"token-budget-bar",className:"p-4 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Token Budget"}),e.jsxs("span",{className:"text-xs text-muted",children:[s.toLocaleString()," active / ",t.toLocaleString()," total (",i,"%)"]})]}),e.jsxs("div",{className:"w-full h-2 rounded-full bg-edge relative",children:[e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 opacity-30",style:{width:`${Math.round(n*100)}%`,background:"#6b7280"}}),e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 transition-all",style:{width:`${i}%`,background:c}})]})]})}function Y(){const{skills:t,recommendations:s,totalTokens:u,activeTokens:n,loading:i,error:c,refresh:x,toggleSkill:b,createSkill:h,updateSkill:f,deleteSkill:d}=$(),[N,p]=l.useState(null),[y,j]=l.useState(!1),[g,r]=l.useState(null),m=l.useCallback(async o=>{await d(o),p(null)},[d]),C=l.useCallback(o=>{p(null),r(o),j(!0)},[]),w=l.useCallback(async o=>{g!=null&&g.id?await f(g.id,o):await h(o),r(null)},[g,h,f]);if(c)return e.jsxs("div",{className:"flex items-center justify-center h-full text-danger",children:["Failed to load skills: ",c]});if(i)return e.jsxs("div",{className:"p-6 max-w-5xl mx-auto space-y-6",children:[e.jsx("div",{className:"h-5 w-32 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-3",children:Array.from({length:5}).map((o,v)=>e.jsx("div",{className:"h-20 rounded-xl border border-edge bg-surface-alt animate-pulse"},v))}),e.jsx("div",{className:"h-8 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:4}).map((o,v)=>e.jsx("div",{className:"h-16 rounded-xl border border-edge bg-surface-alt animate-pulse"},v))})]});const a=t.filter(o=>o.source==="built-in").length,S=t.filter(o=>o.source==="custom").length,T=t.filter(o=>o.enabled).length,M=new Map;for(const o of B){const v=t.filter(O=>{var R;return(R=O.phases)==null?void 0:R.includes(o)});v.length>0&&M.set(o,v)}const L=t.filter(o=>!o.phases||o.phases.length===0);return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6 overflow-y-auto h-full",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Skills"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{r(null),j(!0)},className:"text-xs px-3 py-1.5 rounded-lg border border-accent text-accent hover:bg-accent/10 transition-colors",children:"+ Custom Skill"}),e.jsx("button",{onClick:()=>void x(),className:"text-xs px-3 py-1.5 rounded-lg bg-accent text-white hover:opacity-90 transition-opacity",children:"Refresh"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-5 gap-3","data-testid":"skills-stats",children:[e.jsx(E,{value:t.length,label:"Total Skills"}),e.jsx(E,{value:a,label:"Built-in"}),e.jsx(E,{value:S,label:"Custom"}),e.jsx(E,{value:T,label:"Enabled"}),e.jsx(E,{value:n.toLocaleString(),label:"Active Tokens"})]}),e.jsx(q,{totalTokens:u,activeTokens:n}),s.length>0&&e.jsxs("div",{"data-testid":"recommendations-section",className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted uppercase",children:["Recommendations (",s.length,")"]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-2",children:s.map(o=>e.jsx(U,{rec:o},o.skill))})]}),e.jsxs("div",{"data-testid":"skills-by-phase",className:"space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Skills by Lifecycle Phase"}),[...M.entries()].map(([o,v])=>e.jsx(A,{phase:o,skills:v,onToggle:b,onSkillClick:p},o)),L.length>0&&e.jsx(A,{phase:"Other",skills:L,onToggle:b,onSkillClick:p})]}),e.jsx(D,{skill:N,onClose:()=>p(null),onToggle:b,onDelete:m,onEdit:C}),e.jsx(F,{open:y,onClose:()=>{j(!1),r(null)},onSubmit:w,editSkill:g})]})}export{Y as SkillsTab};
|
|
1
|
+
import{r as l,a as k,j as e}from"./index-DdenFaJ5.js";import{P,L as B}from"./constants-Dd6A34aQ.js";function $(){const[t,s]=l.useState([]),[u,n]=l.useState([]),[i,c]=l.useState(0),[x,b]=l.useState(!0),[h,f]=l.useState(null),d=l.useCallback(async()=>{b(!0),f(null);try{const[r,m]=await Promise.all([k.getSkills(),k.getRecommendations().catch(()=>({recommendations:[]}))]);s(r.skills),c(r.totalTokens),n(m.recommendations)}catch(r){f(r instanceof Error?r.message:"Failed to load skills")}finally{b(!1)}},[]);l.useEffect(()=>{d()},[d]);const N=l.useCallback(async(r,m)=>{s(C=>C.map(w=>w.name===r?{...w,enabled:m}:w));try{await k.toggleSkill(r,m)}catch{d()}},[d]),p=l.useCallback(async r=>{await k.createCustomSkill(r),d()},[d]),y=l.useCallback(async(r,m)=>{await k.updateCustomSkill(r,m),d()},[d]),j=l.useCallback(async r=>{await k.deleteCustomSkill(r),d()},[d]),g=t.filter(r=>r.enabled).reduce((r,m)=>r+m.estimatedTokens,0);return{skills:t,recommendations:u,totalTokens:i,activeTokens:g,loading:x,error:h,refresh:d,toggleSkill:N,createSkill:p,updateSkill:y,deleteSkill:j}}function D({skill:t,onClose:s,onToggle:u,onDelete:n,onEdit:i}){return t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:c=>{c.target===c.currentTarget&&s()},children:e.jsxs("div",{className:"bg-surface rounded-lg shadow-xl w-full max-w-lg p-6 max-h-[80vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold truncate",children:t.name}),e.jsx("button",{onClick:s,className:"text-muted hover:text-foreground text-xl",children:"×"})]}),e.jsx("p",{className:"text-sm text-muted mb-4",children:t.description}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-medium ${t.source==="built-in"?"bg-blue-500/10 text-blue-500":t.source==="custom"?"bg-purple-500/10 text-purple-500":"bg-gray-500/10 text-gray-500"}`,children:t.source}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium bg-edge text-muted",children:t.category}),e.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium bg-edge text-muted",children:[t.estimatedTokens.toLocaleString()," tokens"]})]}),t.phases&&t.phases.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-4",children:t.phases.map(c=>{const x=P[c]??"#6b7280";return e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium",style:{background:`${x}20`,color:x},children:c},c)})}),e.jsx("div",{className:"flex items-center gap-3 mb-4 p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:c=>u(t.name,c.target.checked),className:"w-4 h-4 accent-accent"}),t.enabled?"Enabled":"Disabled"]})}),t.source==="custom"&&e.jsxs("div",{className:"flex gap-2",children:[i&&e.jsx("button",{onClick:()=>i(t),className:"px-3 py-1.5 text-sm border border-edge rounded hover:bg-surface-elevated",children:"Edit"}),n&&t.id&&e.jsx("button",{onClick:()=>n(t.id),className:"px-3 py-1.5 text-sm text-red-500 border border-red-500/30 rounded hover:bg-red-500/10",children:"Delete"})]})]})}):null}const _=["know-me","software-design","security","testing","cost-reducer","research","ddd","frontend-design","other"];function F({open:t,onClose:s,onSubmit:u,editSkill:n}){const[i,c]=l.useState(""),[x,b]=l.useState(""),[h,f]=l.useState("know-me"),[d,N]=l.useState(["IMPLEMENT"]),[p,y]=l.useState(""),[j,g]=l.useState(!1),[r,m]=l.useState(null);l.useEffect(()=>{n?(c(n.name),b(n.description),f(n.category),N(n.phases??["IMPLEMENT"]),y("")):(c(""),b(""),f("know-me"),N(["IMPLEMENT"]),y("")),m(null)},[n,t]);const C=l.useCallback(a=>{N(S=>S.includes(a)?S.filter(T=>T!==a):[...S,a])},[]),w=l.useCallback(async()=>{if(!i.trim()||!x.trim()||!p.trim()||d.length===0){m("All fields are required and at least one phase must be selected.");return}g(!0),m(null);try{await u({name:i.trim(),description:x.trim(),category:h,phases:d,instructions:p.trim()}),s()}catch(a){m(a instanceof Error?a.message:"Failed to save skill")}finally{g(!1)}},[i,x,h,d,p,u,s]);return t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:a=>{a.target===a.currentTarget&&s()},children:e.jsxs("div",{className:"bg-surface rounded-lg shadow-xl w-full max-w-lg p-6 max-h-[85vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:n?"Edit Skill":"Create Custom Skill"}),e.jsx("button",{onClick:s,className:"text-muted hover:text-foreground text-xl",children:"×"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Name"}),e.jsx("input",{type:"text",value:i,onChange:a=>c(a.target.value),placeholder:"my-workflow",disabled:!!n,className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt disabled:opacity-50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Description"}),e.jsx("input",{type:"text",value:x,onChange:a=>b(a.target.value),placeholder:"What does this skill do?",className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Category"}),e.jsx("select",{value:h,onChange:a=>f(a.target.value),className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:_.map(a=>e.jsx("option",{value:a,children:a},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Phases"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:B.map(a=>e.jsx("button",{type:"button",onClick:()=>C(a),className:`px-2 py-1 text-[10px] font-medium rounded-full border transition-colors ${d.includes(a)?"bg-accent/10 border-accent text-accent":"border-edge text-muted hover:border-foreground"}`,children:a},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Instructions"}),e.jsx("textarea",{value:p,onChange:a=>y(a.target.value),rows:6,placeholder:"Instructions for the AI agent when this skill is active...",className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt resize-y"})]}),r&&e.jsx("div",{className:"text-sm p-2 rounded bg-red-500/10 text-red-500",children:r}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:s,className:"px-3 py-1.5 text-sm border border-edge rounded hover:bg-surface-elevated",children:"Cancel"}),e.jsx("button",{onClick:w,disabled:j,className:"px-3 py-1.5 text-sm bg-accent text-white rounded hover:opacity-90 disabled:opacity-50",children:j?"Saving...":n?"Update":"Create"})]})]})]})}):null}const I=4e3;function E({value:t,label:s}){return e.jsxs("div",{className:"p-3 rounded-xl border border-edge bg-surface-alt text-center","data-testid":"metric-card",children:[e.jsx("div",{className:"text-xl font-bold",children:t}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:s})]})}function z({phase:t}){const s=P[t]??"#6b7280";return e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium",style:{background:`${s}20`,color:s},children:t})}function G({source:t}){const s={"built-in":"bg-accent/10 text-accent",filesystem:"bg-muted/10 text-muted",custom:"bg-purple-500/10 text-purple-500"};return e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${s[t]}`,children:t})}function H({skill:t,onToggle:s,onClick:u}){return e.jsxs("div",{className:`p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt cursor-pointer hover:border-accent/50 transition-all ${t.enabled?"":"opacity-50"}`,onClick:()=>u(t),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-medium truncate",children:t.name}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:n=>{n.stopPropagation(),s(t.name,n.target.checked)},onClick:n=>n.stopPropagation(),className:"w-3.5 h-3.5 accent-accent"}),e.jsx(G,{source:t.source}),e.jsxs("span",{className:"text-[10px] text-muted",children:[t.estimatedTokens.toLocaleString()," tok"]})]})]}),e.jsx("p",{className:"text-xs text-muted line-clamp-2",children:t.description})]})}function A({phase:t,skills:s,onToggle:u,onSkillClick:n}){const[i,c]=l.useState(!0),x=P[t]??"#6b7280",b=s.filter(h=>h.enabled).length;return e.jsxs("div",{className:"rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>c(!i),className:"w-full flex items-center justify-between px-3 py-2 text-xs font-medium hover:bg-surface-elevated transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:x}}),t,e.jsxs("span",{className:"px-1.5 py-0.5 rounded-full bg-edge text-[10px]",children:[b,"/",s.length]})]}),e.jsx("span",{className:"text-muted",children:i?"▲":"▼"})]}),i&&e.jsx("div",{className:"px-3 pb-3 space-y-2",children:s.map(h=>e.jsx(H,{skill:h,onToggle:u,onClick:n},h.name))})]})}function U({rec:t}){return e.jsxs("div",{className:"p-3 rounded-lg bg-surface-alt border border-accent/30",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-medium",children:t.skill}),e.jsx(z,{phase:t.phase})]}),e.jsx("p",{className:"text-xs text-muted",children:t.reason})]})}function q({totalTokens:t,activeTokens:s}){const u=Math.min(s/I,1),n=Math.min(t/I,1),i=Math.round(u*100),c=u>.8?"#ef4444":u>.5?"#f59e0b":"#10b981";return e.jsxs("div",{"data-testid":"token-budget-bar",className:"p-4 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Token Budget"}),e.jsxs("span",{className:"text-xs text-muted",children:[s.toLocaleString()," active / ",t.toLocaleString()," total (",i,"%)"]})]}),e.jsxs("div",{className:"w-full h-2 rounded-full bg-edge relative",children:[e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 opacity-30",style:{width:`${Math.round(n*100)}%`,background:"#6b7280"}}),e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 transition-all",style:{width:`${i}%`,background:c}})]})]})}function Y(){const{skills:t,recommendations:s,totalTokens:u,activeTokens:n,loading:i,error:c,refresh:x,toggleSkill:b,createSkill:h,updateSkill:f,deleteSkill:d}=$(),[N,p]=l.useState(null),[y,j]=l.useState(!1),[g,r]=l.useState(null),m=l.useCallback(async o=>{await d(o),p(null)},[d]),C=l.useCallback(o=>{p(null),r(o),j(!0)},[]),w=l.useCallback(async o=>{g!=null&&g.id?await f(g.id,o):await h(o),r(null)},[g,h,f]);if(c)return e.jsxs("div",{className:"flex items-center justify-center h-full text-danger",children:["Failed to load skills: ",c]});if(i)return e.jsxs("div",{className:"p-6 max-w-5xl mx-auto space-y-6",children:[e.jsx("div",{className:"h-5 w-32 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-3",children:Array.from({length:5}).map((o,v)=>e.jsx("div",{className:"h-20 rounded-xl border border-edge bg-surface-alt animate-pulse"},v))}),e.jsx("div",{className:"h-8 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:4}).map((o,v)=>e.jsx("div",{className:"h-16 rounded-xl border border-edge bg-surface-alt animate-pulse"},v))})]});const a=t.filter(o=>o.source==="built-in").length,S=t.filter(o=>o.source==="custom").length,T=t.filter(o=>o.enabled).length,M=new Map;for(const o of B){const v=t.filter(O=>{var R;return(R=O.phases)==null?void 0:R.includes(o)});v.length>0&&M.set(o,v)}const L=t.filter(o=>!o.phases||o.phases.length===0);return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6 overflow-y-auto h-full",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Skills"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{r(null),j(!0)},className:"text-xs px-3 py-1.5 rounded-lg border border-accent text-accent hover:bg-accent/10 transition-colors",children:"+ Custom Skill"}),e.jsx("button",{onClick:()=>void x(),className:"text-xs px-3 py-1.5 rounded-lg bg-accent text-white hover:opacity-90 transition-opacity",children:"Refresh"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-5 gap-3","data-testid":"skills-stats",children:[e.jsx(E,{value:t.length,label:"Total Skills"}),e.jsx(E,{value:a,label:"Built-in"}),e.jsx(E,{value:S,label:"Custom"}),e.jsx(E,{value:T,label:"Enabled"}),e.jsx(E,{value:n.toLocaleString(),label:"Active Tokens"})]}),e.jsx(q,{totalTokens:u,activeTokens:n}),s.length>0&&e.jsxs("div",{"data-testid":"recommendations-section",className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted uppercase",children:["Recommendations (",s.length,")"]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-2",children:s.map(o=>e.jsx(U,{rec:o},o.skill))})]}),e.jsxs("div",{"data-testid":"skills-by-phase",className:"space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Skills by Lifecycle Phase"}),[...M.entries()].map(([o,v])=>e.jsx(A,{phase:o,skills:v,onToggle:b,onSkillClick:p},o)),L.length>0&&e.jsx(A,{phase:"Other",skills:L,onToggle:b,onSkillClick:p})]}),e.jsx(D,{skill:N,onClose:()=>p(null),onToggle:b,onDelete:m,onEdit:C}),e.jsx(F,{open:y,onClose:()=>{j(!1),r(null)},onSubmit:w,editSkill:g})]})}export{Y as SkillsTab};
|