@qiaolei81/copilot-session-viewer 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/bin/copilot-session-viewer +2 -2
  2. package/dist/server.min.js +99 -0
  3. package/package.json +5 -17
  4. package/public/vendor/marked.umd.min.js +8 -0
  5. package/public/vendor/purify.min.js +3 -0
  6. package/public/vendor/vue-virtual-scroller.css +1 -0
  7. package/public/vendor/vue-virtual-scroller.min.js +2 -0
  8. package/public/vendor/vue.global.prod.min.js +19 -0
  9. package/views/session-vue.ejs +5 -5
  10. package/views/time-analyze.ejs +2 -2
  11. package/lib/parsers/README.md +0 -239
  12. package/lib/parsers/base-parser.js +0 -53
  13. package/lib/parsers/claude-parser.js +0 -181
  14. package/lib/parsers/copilot-parser.js +0 -143
  15. package/lib/parsers/index.js +0 -15
  16. package/lib/parsers/parser-factory.js +0 -77
  17. package/lib/parsers/pi-mono-parser.js +0 -119
  18. package/lib/parsers/vscode-parser.js +0 -591
  19. package/server.js +0 -29
  20. package/src/app.js +0 -129
  21. package/src/config/index.js +0 -27
  22. package/src/controllers/insightController.js +0 -136
  23. package/src/controllers/sessionController.js +0 -449
  24. package/src/controllers/tagController.js +0 -113
  25. package/src/controllers/uploadController.js +0 -648
  26. package/src/middleware/common.js +0 -67
  27. package/src/middleware/rateLimiting.js +0 -62
  28. package/src/models/Session.js +0 -146
  29. package/src/routes/api.js +0 -11
  30. package/src/routes/insights.js +0 -12
  31. package/src/routes/pages.js +0 -12
  32. package/src/routes/uploads.js +0 -14
  33. package/src/schemas/event.schema.js +0 -73
  34. package/src/services/eventNormalizer.js +0 -291
  35. package/src/services/insightService.js +0 -535
  36. package/src/services/sessionRepository.js +0 -1092
  37. package/src/services/sessionService.js +0 -1919
  38. package/src/services/tagService.js +0 -205
  39. package/src/telemetry.js +0 -152
  40. package/src/utils/fileUtils.js +0 -305
  41. package/src/utils/helpers.js +0 -45
  42. package/src/utils/processManager.js +0 -85
@@ -3,8 +3,8 @@
3
3
  const path = require('path');
4
4
  const { spawn } = require('child_process');
5
5
 
6
- // Get the server.js path relative to this bin script
7
- const serverPath = path.join(__dirname, '..', 'server.js');
6
+ // Get the bundled server path relative to this bin script
7
+ const serverPath = path.join(__dirname, '..', 'dist', 'server.min.js');
8
8
 
9
9
  // Spawn the server
10
10
  const server = spawn('node', [serverPath], {
@@ -0,0 +1,99 @@
1
+ var b=(p,e)=>()=>(e||p((e={exports:{}}).exports,e),e.exports);var O=b((nn,We)=>{var ie=require("applicationinsights"),X=require("fs"),Q=require("path"),Vt=require("crypto"),ze=require("os");function Bt(){let p=Q.join(ze.homedir(),".copilot-session-viewer"),e=Q.join(p,"analytics-id");try{return X.readFileSync(e,"utf8").trim()}catch{let s=Vt.randomUUID();try{X.mkdirSync(p,{recursive:!0}),X.writeFileSync(e,s)}catch{}return s}}function Wt(){try{let p=[Q.join(__dirname,"..","package.json"),Q.join(__dirname,"package.json")];for(let e of p)try{return JSON.parse(X.readFileSync(e,"utf8")).version}catch{}}catch{}return"unknown"}var Ve=process.env.NODE_ENV==="test",Be=process.env.DISABLE_TELEMETRY==="true"||Ve,Gt="InstrumentationKey=39f4fbf1-d82f-42c3-b4ef-ea92a1fd82cb;IngestionEndpoint=https://eastus-8.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/;ApplicationId=7d4bb432-f2f5-4526-a5e6-31901e5a2db2",C=null;if(Be)C=Ue(),console.log(Ve?"\u{1F4CA} Telemetry disabled (test environment)":"\u{1F4CA} Telemetry disabled (DISABLE_TELEMETRY=true)");else try{let p=process.env.APPLICATIONINSIGHTS_CONNECTION_STRING||Gt;ie.setup(p).setAutoDependencyCorrelation(!0).setAutoCollectRequests(!0).setAutoCollectPerformance(!0,!0).setAutoCollectExceptions(!0).setAutoCollectDependencies(!0).setAutoCollectConsole(!1).setUseDiskRetryCaching(!0).setSendLiveMetrics(!1).setDistributedTracingMode(ie.DistributedTracingModes.AI_AND_W3C).start(),C=ie.defaultClient;let e=Wt(),s=Bt();C.context.tags[C.context.keys.cloudRole]="copilot-session-viewer",C.context.tags[C.context.keys.cloudRoleInstance]=ze.hostname(),C.context.tags[C.context.keys.applicationVersion]=e,C.context.tags[C.context.keys.userId]=s,C.addTelemetryProcessor(t=>(t.data.baseData.properties=t.data.baseData.properties||{},t.data.baseData.properties.appVersion=e,!0)),console.log("\u2705 Application Insights telemetry initialized")}catch(p){console.error("\u274C Failed to initialize Application Insights:",p.message),C=Ue()}function Ue(){return{trackEvent:()=>{},trackMetric:()=>{},trackException:()=>{},trackTrace:()=>{},trackDependency:()=>{},trackRequest:()=>{},flush:p=>{p&&p()}}}function Jt(p,e={}){C&&C.trackEvent&&C.trackEvent({name:p,properties:e})}function Ht(p,e,s={}){C&&C.trackMetric&&C.trackMetric({name:p,value:e,properties:s})}function Kt(p,e={}){C&&C.trackException&&C.trackException({exception:p,properties:e})}function Yt(){return new Promise(p=>{C&&C.flush?C.flush({callback:()=>p()}):p()})}We.exports={client:C,trackEvent:Jt,trackMetric:Ht,trackException:Kt,flush:Yt,isEnabled:!Be}});var q=b((on,Ge)=>{Ge.exports={PORT:process.env.PORT||3838,NODE_ENV:process.env.NODE_ENV||"production",LOG_LEVEL:process.env.LOG_LEVEL||(process.env.NODE_ENV==="development"?"DEBUG":"INFO"),INSIGHT_TIMEOUT_MS:300*1e3,INSIGHT_CACHE_TTL_MS:1440*60*1e3,MAX_UPLOAD_SIZE:10*1024*1024,SESSION_CACHE_TTL_MS:30*1e3,RATE_LIMIT_WINDOW_MS:900*1e3,RATE_LIMIT_MAX_REQUESTS:15,REQUEST_TIMEOUT_MS:30*1e3}});var Ke=b((rn,He)=>{var ae=q(),{trackException:Zt,isEnabled:Je}=O(),Xt=(p,e,s)=>{p.setTimeout(ae.REQUEST_TIMEOUT_MS),s()},Qt=(p,e,s)=>{e.locals.telemetryEnabled=Je,e.locals.telemetryConnectionString=Je?process.env.APPLICATIONINSIGHTS_CONNECTION_STRING||"InstrumentationKey=39f4fbf1-d82f-42c3-b4ef-ea92a1fd82cb;IngestionEndpoint=https://eastus-8.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/;ApplicationId=7d4bb432-f2f5-4526-a5e6-31901e5a2db2":null,s()},es=(p,e,s)=>{if(ae.NODE_ENV==="development"){let t=["http://localhost:3838","http://127.0.0.1:3838"],n=p.headers.origin;t.includes(n)&&(e.header("Access-Control-Allow-Origin",n),e.header("Access-Control-Allow-Methods","GET, POST, DELETE, OPTIONS"),e.header("Access-Control-Allow-Headers","Content-Type"))}s()},ts=(p,e,s,t)=>{console.error("Unhandled error:",p.stack),Zt(p,{url:e.url,method:e.method,statusCode:(p.status||500).toString(),userAgent:e.headers&&e.headers["user-agent"]||"unknown"});let n=p.status||500,o=ae.NODE_ENV==="development",r=o?p.message:"Internal server error";s.status(n).json({error:r,...o&&{stack:p.stack}})},ss=(p,e)=>{e.status(404).json({error:"Not found"})};He.exports={requestTimeout:Xt,developmentCors:es,errorHandler:ts,notFoundHandler:ss,telemetryLocals:Qt}});var L=b((an,Ye)=>{function ns(p){let e=p.toJSON?p.toJSON():{};return{type:p.type,source:p.source,sourceName:e.sourceName||p.source,sourceBadgeClass:e.sourceBadgeClass||"source-unknown",summary:p.summary,model:p.selectedModel||p.model,repo:p.workspace?.repository,branch:p.workspace?.branch,cwd:p.workspace?.cwd,created:p.createdAt,updated:p.updatedAt,copilotVersion:p.copilotVersion,sessionStatus:p.sessionStatus}}function os(p){return typeof p=="string"&&/^[a-zA-Z0-9_-]+$/.test(p)&&p.length<256}Ye.exports={buildMetadata:ns,isValidSessionId:os}});var Xe=b((ln,Ze)=>{var rs=require("path"),le=class p{constructor(e,s,t={}){this.id=e,this.type=s,this.source=t.source||"copilot",this.directory=t.directory||null,this.filePath=t.filePath||null,this.workspace=t.workspace||{},this.createdAt=t.createdAt,this.updatedAt=t.updatedAt,this.summary=t.summary||(s==="file"?"Legacy session":"No summary"),this.hasEvents=t.hasEvents||!1,this.eventCount=t.eventCount||0,this.duration=t.duration||null,this.isImported=t.isImported||!1,this.hasInsight=t.hasInsight||!1,this.copilotVersion=t.copilotVersion||null,this.selectedModel=t.selectedModel||null,this.sessionStatus=t.sessionStatus||"completed"}static fromDirectory(e,s,t,n,o,r,i,a,l,c,d){let u=n?.created_at?new Date(n.created_at):n?.startTime?new Date(n.startTime):t.birthtime,m=n?.updated_at?new Date(n.updated_at):n?.endTime?new Date(n.endTime):t.mtime;return new p(s,"directory",{directory:e,workspace:n,createdAt:u,updatedAt:m,summary:n?.summary||"No summary",hasEvents:o>0,eventCount:o,duration:r,isImported:i,hasInsight:a,copilotVersion:l,selectedModel:c,sessionStatus:d})}static fromFile(e,s,t,n,o,r,i,a,l){return new p(s,"file",{filePath:e,directory:rs.dirname(e),createdAt:t.birthtime,updatedAt:t.mtime,summary:o||"Legacy session",hasEvents:!0,eventCount:n,duration:r,isImported:!1,hasInsight:!1,copilotVersion:i,selectedModel:a,sessionStatus:l})}toJSON(){let e=this._getSourceDisplayMetadata(this.source);return{id:this.id,type:this.type,source:this.source,sourceName:e.name,sourceBadgeClass:e.badgeClass,directory:this.directory,workspace:this.workspace,createdAt:this.createdAt,updatedAt:this.updatedAt,summary:this.summary,hasEvents:this.hasEvents,eventCount:this.eventCount,duration:this.duration,isImported:this.isImported,hasInsight:this.hasInsight,copilotVersion:this.copilotVersion,selectedModel:this.selectedModel,sessionStatus:this.sessionStatus}}_getSourceDisplayMetadata(e){return{copilot:{name:"Copilot CLI",badgeClass:"source-copilot"},claude:{name:"Claude",badgeClass:"source-claude"},"pi-mono":{name:"Pi",badgeClass:"source-pi-mono"},vscode:{name:"Copilot Chat",badgeClass:"source-vscode"}}[e]||{name:e,badgeClass:"source-unknown"}}};Ze.exports=le});var tt=b((cn,et)=>{var Qe=require("fs").promises,J=require("fs"),H=require("readline");async function is(p){try{return await Qe.access(p),!0}catch{return!1}}async function as(p){try{let e=J.createReadStream(p,{encoding:"utf-8"}),s=H.createInterface({input:e,crlfDelay:1/0}),t=0;for await(let n of s)n.trim()&&t++;return t}catch(e){return console.error(`Error counting lines in ${p}:`,e.message),0}}async function ls(p){try{let s=(await Qe.readFile(p,"utf-8")).split(`
2
+ `),t={};for(let n of s){let o=n.match(/^(\w+):\s*(.+)$/);o&&(t[o[1]]=o[2].trim())}return t}catch(e){return console.error(`Error parsing YAML ${p}:`,e.message),{}}}async function cs(p,e=200){try{let s=J.createReadStream(p,{encoding:"utf-8"}),t=H.createInterface({input:s,crlfDelay:1/0}),n="",o=null,r=null,i=null,a=null,l=!1;for await(let d of t)if(d.trim())try{let u=JSON.parse(d);if(u.timestamp){let m=new Date(u.timestamp).getTime();isNaN(m)||(o||(o=m),r=m)}if(!n&&u.type==="user.message"){let m=u.data?.message||u.data?.content||u.data?.text||"";m&&(n=m.length>e?m.substring(0,e)+"...":m)}u.type==="session.end"&&(l=!0),u.type==="session.start"&&u.data?.copilotVersion&&!i&&(i=u.data.copilotVersion),(u.type==="session.start"||u.type==="session.model_change")&&!a&&(u.data?.selectedModel?a=u.data.selectedModel:u.data?.newModel?a=u.data.newModel:u.data?.model&&(a=u.data.model))}catch{}t.close(),s.destroy();let c=o&&r&&r>o?r-o:null;return{firstUserMessage:n||"",duration:c,copilotVersion:i||null,selectedModel:a||null,hasSessionEnd:l,lastEventTime:r,firstEventTime:o}}catch(s){return console.error(`Error reading session metadata from ${p}:`,s.message),{firstUserMessage:"",duration:null,copilotVersion:null,selectedModel:null,hasSessionEnd:!1,lastEventTime:null}}}async function us(p,e=200){try{let s=J.createReadStream(p,{encoding:"utf-8"}),t=H.createInterface({input:s,crlfDelay:1/0});for await(let n of t)if(n.trim())try{let o=JSON.parse(n);if(o.type==="user.message"){let r=o.data?.message||o.data?.content||o.data?.text||"";if(r)return t.close(),s.destroy(),r.length>e?r.substring(0,e)+"...":r}}catch{}return""}catch{return""}}async function ds(p){try{let e=J.createReadStream(p,{encoding:"utf-8"}),s=H.createInterface({input:e,crlfDelay:1/0}),t=null,n=null;for await(let o of s)if(o.trim())try{let r=JSON.parse(o);if(r.timestamp){let i=new Date(r.timestamp).getTime();t||(t=i),n=i}}catch{}return t&&n&&n>=t?n-t:null}catch(e){return console.error(`Error calculating session duration for ${p}:`,e.message),null}}async function ps(p){try{let e=J.createReadStream(p,{encoding:"utf-8"}),s=H.createInterface({input:e,crlfDelay:1/0}),t=null,n=null;for await(let o of s)if(o.trim())try{let r=JSON.parse(o);if(r.type==="session.start"&&r.data&&(t=r.data.copilotVersion||null,n=r.data.selectedModel||null,n))return s.close(),e.destroy(),{copilotVersion:t,selectedModel:n};if(!n&&r.type==="session.model_change"&&r.data)return n=r.data.newModel||null,s.close(),e.destroy(),{copilotVersion:t,selectedModel:n}}catch{}return{copilotVersion:t,selectedModel:n}}catch(e){return console.error(`Error reading session metadata from ${p}:`,e.message),{copilotVersion:null,selectedModel:null}}}function ms(p){return p===".DS_Store"||p.startsWith(".")}et.exports={fileExists:is,countLines:as,parseYAML:ls,getFirstUserMessage:us,getSessionDuration:ds,getSessionMetadata:ps,getSessionMetadataOptimized:cs,shouldSkipEntry:ms}});var U=b((un,st)=>{var ce=class{canParse(e){throw new Error("canParse() must be implemented")}parse(e){throw new Error("parse() must be implemented")}getMetadata(e){throw new Error("getMetadata() must be implemented")}extractTurns(e){throw new Error("extractTurns() must be implemented")}extractToolCalls(e){throw new Error("extractToolCalls() must be implemented")}};st.exports=ce});var de=b((dn,nt)=>{var fs=U(),ue=class extends fs{canParse(e){if(!e||e.length===0)return!1;let s=["session.start","user.message","assistant.turn_start","assistant.message","tool.execution_start"];return e.some(t=>t.type&&s.some(n=>t.type.startsWith(n)))}parse(e){return{metadata:this.getMetadata(e),turns:this.extractTurns(e),toolCalls:this.extractToolCalls(e),allEvents:e}}getMetadata(e){let s=e.find(n=>n.type==="session.start");if(!s)return null;let t=s.data||{};return{sessionId:t.sessionId,startTime:t.startTime,model:t.selectedModel,version:t.copilotVersion,producer:t.producer,cwd:t.context?.cwd,gitRoot:t.context?.gitRoot,branch:t.context?.branch,repository:t.context?.repository}}extractTurns(e){let s=[],t=null;for(let n of e)if(n.type==="user.message")t&&s.push(t),t={turnId:n.id,userMessage:{id:n.id,content:n.data?.content||"",transformedContent:n.data?.transformedContent,timestamp:n.timestamp},assistantMessages:[],toolCalls:[]};else if(n.type==="assistant.message"&&t)t.assistantMessages.push({id:n.id,messageId:n.data?.messageId,content:n.data?.content||"",toolRequests:n.data?.toolRequests||[],reasoningText:n.data?.reasoningText,timestamp:n.timestamp});else if(n.type.startsWith("tool.execution_")&&t){let o=n.data?.toolCallId,r=t.toolCalls.find(i=>i.toolCallId===o);r||(r={toolCallId:o,events:[]},t.toolCalls.push(r)),r.events.push(n),n.type==="tool.execution_start"?(r.name=n.data?.toolName,r.arguments=n.data?.arguments):n.type==="tool.execution_complete"&&(r.result=n.data?.result,r.exitCode=n.data?.exitCode)}return t&&s.push(t),s}extractToolCalls(e){let s=[],t=new Map;for(let n of e)if(n.type==="tool.execution_start"){let o=n.data?.toolCallId;t.set(o,{toolCallId:o,name:n.data?.toolName,arguments:n.data?.arguments,startEvent:n,completeEvent:null})}else if(n.type==="tool.execution_complete"){let o=n.data?.toolCallId,r=t.get(o);r&&(r.completeEvent=n,r.result=n.data?.result,r.exitCode=n.data?.exitCode,s.push(r))}return s}};nt.exports=ue});var me=b((pn,ot)=>{var gs=U(),pe=class extends gs{canParse(e){return!e||e.length===0?!1:e.some(s=>s.type&&["user","assistant"].includes(s.type)&&s.uuid&&Object.prototype.hasOwnProperty.call(s,"parentUuid")&&s.sessionId)}parse(e){return{metadata:this.getMetadata(e),turns:this.extractTurns(e),toolCalls:this.extractToolCalls(e),allEvents:e}}getMetadata(e){let s=e.find(o=>o.type==="user");if(!s)return null;let n=e.find(o=>o.type==="assistant"&&o.message?.model)?.message?.model||"unknown";return{sessionId:s.sessionId,startTime:s.timestamp,model:n,version:s.version,producer:"claude-code",cwd:s.cwd,gitRoot:null,branch:s.gitBranch,repository:null}}extractTurns(e){let s=[],t=e.filter(r=>["user","assistant"].includes(r.type)&&r.type!=="file-history-snapshot"&&r.type!=="queue-operation"),n=new Map;for(let r of t)n.set(r.uuid,r);let o=t.filter(r=>r.type==="user"&&(!r.parentUuid||!n.has(r.parentUuid)));for(let r of o){let i={turnId:r.uuid,userMessage:{id:r.uuid,content:this._extractMessageContent(r.message),timestamp:r.timestamp},assistantMessages:[],toolCalls:[]};this._collectAssistantResponses(r.uuid,n,i),s.push(i)}return s}_collectAssistantResponses(e,s,t){for(let[n,o]of s.entries())if(o.parentUuid===e&&o.type==="assistant"){let r={id:o.uuid,messageId:o.message?.id,content:this._extractMessageContent(o.message),model:o.message?.model,timestamp:o.timestamp},i=this._extractToolUse(o.message);i.length>0&&(r.toolRequests=i,t.toolCalls.push(...i.map(a=>({toolCallId:a.id,name:a.name,arguments:a.input,parentUuid:o.uuid})))),t.assistantMessages.push(r),this._collectAssistantResponses(o.uuid,s,t)}}_extractMessageContent(e){return!e||!e.content?"":typeof e.content=="string"?e.content:Array.isArray(e.content)?e.content.filter(s=>s.type==="text").map(s=>s.text).join(`
3
+ `):""}_extractToolUse(e){return!e||!e.content||!Array.isArray(e.content)?[]:e.content.filter(s=>s.type==="tool_use").map(s=>({id:s.id,name:s.name,input:s.input}))}extractToolCalls(e){let s=[];for(let t of e)if(t.type==="assistant"&&t.message?.content){let n=this._extractToolUse(t.message);for(let o of n)s.push({toolCallId:o.id,name:o.name,arguments:o.input,parentUuid:t.uuid,timestamp:t.timestamp,result:null,exitCode:null})}return s}};ot.exports=pe});var ge=b((mn,rt)=>{var hs=U(),fe=class extends hs{constructor(){super("pi-mono")}async parseSessionDir(e){let s=require("fs").promises,t=require("path");try{let o=(await s.readdir(e)).filter(d=>d.endsWith(".jsonl"));if(o.length===0)return null;o.sort().reverse();let r=t.join(e,o[0]),i=await this._readFirstLine(r);if(!i)return null;let a=JSON.parse(i);if(a.type!=="session")return console.warn(`Pi-Mono file ${r} doesn't start with session event`),null;let c=t.basename(e).replace(/^--/,"").replace(/--$/,"");return{id:a.id,type:"pi-mono",source:"pi-mono",cwd:a.cwd||c,createdAt:new Date(a.timestamp),updatedAt:new Date(a.timestamp),summary:`Pi-Mono: ${c}`,fileCount:o.length}}catch(n){return console.error(`Error parsing Pi-Mono session dir ${e}:`,n.message),null}}async _readFirstLine(e){let s=require("fs"),t=require("readline");return new Promise(n=>{let o=s.createReadStream(e,{encoding:"utf-8"}),r=t.createInterface({input:o,crlfDelay:1/0});r.on("line",i=>{r.close(),o.destroy(),n(i.trim())}),r.on("close",()=>n(null))})}async parseEvents(e){let s=require("fs"),t=require("readline"),n=[],o=s.createReadStream(e,{encoding:"utf-8"}),r=t.createInterface({input:o,crlfDelay:1/0}),i=0;for await(let a of r){i++;let l=a.trim();if(l)try{let c=JSON.parse(l);n.push(c)}catch(c){console.error(`Error parsing Pi-Mono line ${i}:`,c.message)}}return n}};rt.exports=fe});var at=b((fn,it)=>{var ys=U(),he=class extends ys{canParse(e){if(!Array.isArray(e)||e.length===0)return!1;let s=e[0];return!!(s&&typeof s=="object"&&s.kind===0&&s.v&&s.v.sessionId)}parseVsCode(e){let s=this._getMetadata(e),t=this._toEvents(e);return{metadata:s,turns:this._extractTurns(t),toolCalls:this._extractToolCalls(t),allEvents:t}}parseJsonl(e){let s=this.replayMutations(e),t=this._getMetadata(s),n=this._toEvents(s);return{metadata:t,turns:this._extractTurns(n),toolCalls:this._extractToolCalls(n),allEvents:n}}replayMutations(e){let s=null;for(let t of e){if(!t||typeof t!="object")continue;let{kind:n,k:o,v:r,i}=t;switch(n){case 0:s=r;break;case 1:o&&Array.isArray(o)&&this._applySet(s,o,r);break;case 2:o&&Array.isArray(o)&&this._applyPush(s,o,r,i);break;case 3:o&&Array.isArray(o)&&this._applyDelete(s,o);break;default:console.warn(`[VsCodeParser] Unknown mutation kind: ${n}`)}}return s}_applySet(e,s,t){if(!e||s.length===0)return;let n=e;for(let r=0;r<s.length-1;r++){let i=s[r];n[i]||(n[i]=typeof s[r+1]=="number"?[]:{}),n=n[i]}let o=s[s.length-1];n[o]=t}_applyPush(e,s,t,n){if(!e||s.length===0)return;let o=e;for(let a=0;a<s.length-1;a++){let l=s[a];o[l]||(o[l]=typeof s[a+1]=="number"?[]:{}),o=o[l]}let r=s[s.length-1];o[r]||(o[r]=[]);let i=o[r];if(!Array.isArray(i)){console.warn(`[VsCodeParser] Push target is not an array: ${s.join(".")}`);return}n!=null&&(i.length=n),t&&Array.isArray(t)&&t.length>0&&i.push(...t)}_applyDelete(e,s){if(!e||s.length===0)return;let t=e;for(let o=0;o<s.length-1;o++){let r=s[o];if(!t[r])return;t=t[r]}let n=s[s.length-1];delete t[n]}parse(e){return Array.isArray(e)&&e.length>0&&this.canParse(e)?this.parseJsonl(e):null}getMetadata(e){let s=this.parse(e);return s?s.metadata:null}extractTurns(e){let s=this.parse(e);return s?s.turns:[]}extractToolCalls(e){let s=this.parse(e);return s?s.toolCalls:[]}_getMetadata(e){let s=e.requests||[],t=s[0]||{},n=s[s.length-1]||{},o=t.agent?.name||t.agent?.id||"vscode-copilot";return{sessionId:e.sessionId,startTime:e.creationDate?new Date(e.creationDate).toISOString():t.timestamp?new Date(t.timestamp).toISOString():null,endTime:e.lastMessageDate?new Date(e.lastMessageDate).toISOString():n.timestamp?new Date(n.timestamp).toISOString():null,model:t.modelId||null,producer:"vscode-copilot-chat",version:t.agent?.extensionVersion||null,agentName:o,requestCount:s.length}}_toEvents(e){let s=[],t=e.requests||[];s.push({type:"session.start",id:`${e.sessionId}-start`,timestamp:e.creationDate?new Date(e.creationDate).toISOString():null,data:{sessionId:e.sessionId,producer:"vscode-copilot-chat",selectedModel:t[0]?.modelId||null}});for(let n of t){let o=n.timestamp?new Date(n.timestamp).toISOString():null,r=n.modelState?.completedAt?new Date(n.modelState.completedAt).toISOString():o,i=Array.isArray(n.response)?n.response:[],a=this._buildSubAgentNameMap(i),l=this._extractUserText(n.message);s.push({type:"user.message",id:n.requestId,timestamp:o,data:{message:l,content:l}}),s.push({type:"assistant.turn_start",id:`${n.requestId}-turn`,timestamp:o,parentId:n.requestId,data:{}});let c="",d=0,u=null,m=()=>{let f=c.trim().replace(/^`{3,}$/gm,"").trim();if(c="",!f)return;let g=u,S=g?a[g]||g.slice(0,8):null;s.push({type:"assistant.message",id:`${n.requestId}-text-${d}`,timestamp:r,parentId:n.requestId,data:{message:f,content:f,tools:[],subAgentId:g||null,subAgentName:S,parentToolCallId:null}})};for(let f of i)switch(d++,f.kind){case"thinking":{let g=f.content?.value||f.content||"";g&&(c+=g+`
4
+ `);break}case"markdownContent":{let g=f.content?.value||f.content||"";g&&(c+=g+`
5
+ `);break}case void 0:case null:{let g=f.value||"";g&&(c+=g);break}case"inlineReference":{let g=f.name||"";g&&(c+="`"+g+"`");break}case"toolInvocationSerialized":{m();let g=f.toolId==="runSubagent"?f.toolCallId:f.subAgentInvocationId;f.toolId==="runSubagent"&&(u=g),g&&(u=g);let S=this._normalizeTool(f);if(S){let _=g?a[g]||g.slice(0,8):null;s.push({type:"tool.invocation",id:S.id||`${n.requestId}-tool-${d}`,timestamp:r,parentId:n.requestId,data:{tool:S,subAgentId:g||null,subAgentName:_,parentToolCallId:g||null,badgeLabel:S.name,badgeClass:S.status==="error"?"badge-error":"badge-tool"}})}break}case"textEditGroup":{m();let g=f.edits||f.uri?[f]:[];s.push({type:"tool.invocation",id:`${n.requestId}-edit-${d}`,timestamp:r,parentId:n.requestId,data:{tool:{type:"tool_use",id:`${n.requestId}-edit-${d}`,name:"textEdit",startTime:o,endTime:o,status:"completed",input:{uri:f.uri,edits:g},result:"file edit",error:null},badgeLabel:"textEdit",badgeClass:"badge-tool"}});break}case"prepareToolInvocation":case"undoStop":case"codeblockUri":case"mcpServersStarting":break;default:break}m()}return s}_buildSubAgentNameMap(e){let s={};for(let t of e){if(!t||typeof t!="object"||t.kind!=="toolInvocationSerialized"||t.toolId!=="runSubagent")continue;let n=t.toolCallId;if(!n||s[n])continue;let o=t.toolSpecificData?.agentName;if(o){s[n]=o;continue}let r=t.invocationMessage,i=typeof r=="string"?r:r&&typeof r=="object"&&r.value||"";if(i){s[n]=i;continue}let a=i.match(/agents\/([^/\]]+?)\.agent\.md/);if(a){s[n]=a[1];continue}let l=t.resultDetails,c=Array.isArray(l)?l:l?[l]:[];for(let d of c){if(typeof d!="object")continue;if(a=(d.fsPath||d.path||"").match(/agents\/([^/]+?)\.agent\.md/),a){s[n]=a[1];break}}}return s}_extractUserText(e){return e?typeof e.text=="string"?e.text:Array.isArray(e.parts)?e.parts.filter(s=>s.kind==="text").map(s=>s.text||"").join(""):"":""}_normalizeTool(e){if(!e.toolCallId)return null;let s=e.toolSpecificData||{},t=s.input||s.parameters||s.request||{},n=s.output||s.result||null,o=e.isConfirmed===!1;if(!n&&(e.generatedTitle||e.resultDetails))if(e.resultDetails){let l=(Array.isArray(e.resultDetails)?e.resultDetails:[e.resultDetails]).map(c=>c.fsPath||c.path||c.external||JSON.stringify(c)).filter(Boolean);n=l.length>0?l.join(`
6
+ `):e.generatedTitle||null}else n=e.generatedTitle||null;if(Object.keys(t).length===0&&e.invocationMessage){let a=e.invocationMessage,l=typeof a=="string"?a:a&&typeof a=="object"&&a.value||"";l&&(t={description:l})}let r=a=>{if(!a||typeof a!="object")return a;let l=a.fsPath||a.path||a.external||"";return l?l.replace(/.*\//,""):JSON.stringify(a)},i=a=>{if(!a||typeof a!="object")return a;let l={};for(let[c,d]of Object.entries(a))if(!(c==="$mid"||c==="external"||c==="scheme")){if(c==="fsPath"||c==="path"){l.file=d.replace(/.*\//,"");continue}d&&typeof d=="object"&&("fsPath"in d||"$mid"in d)?l[c]=r(d):Array.isArray(d)&&c==="edits"?l.edits=`${d.length} edit(s)`:l[c]=d}return l};return t&&typeof t=="object"&&!t.description&&(t=i(t)),{type:"tool_use",id:e.toolCallId,name:e.toolId||"unknown",startTime:null,endTime:null,status:o?"error":e.isComplete?"completed":"pending",input:t,result:typeof n=="string"?n:JSON.stringify(n),error:o?e.resultDetails||"Tool invocation not confirmed":null}}_extractTurns(e){let s=[],t=null;for(let n of e)n.type==="user.message"?(t&&s.push(t),t={userMessage:n,assistantMessages:[],toolCalls:[]}):t&&(n.type==="assistant.message"?t.assistantMessages.push(n):n.type==="tool.invocation"&&t.toolCalls.push(n.data?.tool));return t&&s.push(t),s}_extractToolCalls(e){return e.filter(s=>s.type==="tool.invocation"&&s.data?.tool).map(s=>s.data.tool)}};it.exports=he});var ct=b((gn,lt)=>{var ye=de(),Se=me(),we=ge(),_e=class{constructor(){this.parsers=[new ye,new Se,new we],this.parserMap={copilot:new ye,claude:new Se,"pi-mono":new we}}getParser(e){if(typeof e=="string")return this.parserMap[e]||null;let s=e;for(let t of this.parsers)if(t.canParse(s))return t;return null}parse(e){let s=this.getParser(e);return s?s.parse(e):null}getParserType(e){let s=this.getParser(e);return s?s instanceof ye?"copilot":s instanceof Se?"claude":s instanceof we?"pi-mono":"unknown":null}};lt.exports=_e});var Ie=b((hn,ut)=>{var Ss=U(),ws=de(),_s=me(),Is=ge(),Ts=at(),Es=ct();ut.exports={BaseSessionParser:Ss,CopilotSessionParser:ws,ClaudeSessionParser:_s,PiMonoParser:Is,VsCodeParser:Ts,ParserFactory:Es}});var Ee=b((yn,pt)=>{var E=require("fs").promises,w=require("path"),ee=require("os"),R=Xe(),{fileExists:K,countLines:z,parseYAML:Cs,getSessionMetadataOptimized:dt,shouldSkipEntry:te}=tt(),{ParserFactory:bs}=Ie(),Te=class{constructor(e){typeof e=="string"?this.sources=[{type:"copilot",dir:e}]:Array.isArray(e)?this.sources=e:this.sources=[{type:"copilot",dir:process.env.COPILOT_SESSION_DIR||process.env.SESSION_DIR||w.join(ee.homedir(),".copilot","session-state")},{type:"claude",dir:process.env.CLAUDE_SESSION_DIR||w.join(ee.homedir(),".claude","projects")},{type:"pi-mono",dir:process.env.PI_MONO_SESSION_DIR||w.join(ee.homedir(),".pi","agent","sessions")},{type:"vscode",dir:process.env.VSCODE_WORKSPACE_STORAGE_DIR||w.join(ee.homedir(),"Library","Application Support","Code","User","workspaceStorage")}],this.parserFactory=new bs,this._cache=new Map,this._cacheTTL=60*1e3,this._pendingScans=new Map}invalidateCache(e=null){e?(this._cache.delete(e),this._cache.delete(null)):this._cache.clear()}async findAll(e=null){let s=e||"__all__",t=this._cache.get(s);if(t&&Date.now()-t.timestamp<this._cacheTTL)return t.data;if(this._pendingScans.has(s))return this._pendingScans.get(s);let n=this._doFindAll(e).then(o=>(this._cache.set(s,{data:o,timestamp:Date.now()}),this._pendingScans.delete(s),o)).catch(o=>{throw this._pendingScans.delete(s),o});return this._pendingScans.set(s,n),n}async _doFindAll(e=null){let s=[],t=e?this.sources.filter(n=>n.type===e):this.sources;for(let n of t)try{let o=await this._scanSource(n);s.push(...o)}catch(o){console.error(`Error reading ${n.type} sessions from ${n.dir}:`,o.message)}return this._sortByUpdatedAt(this._deduplicateSessions(s))}_deduplicateSessions(e){let s=new Map;for(let t of e){let n=s.get(t.id);(!n||t.updatedAt&&n.updatedAt&&new Date(t.updatedAt)>new Date(n.updatedAt))&&s.set(t.id,t)}return Array.from(s.values())}async _scanSource(e){try{await E.access(e.dir)}catch{return console.warn(`Source directory not found: ${e.dir}`),[]}let t=(await E.readdir(e.dir)).filter(o=>!te(o)).map(async o=>{let r=w.join(e.dir,o),i=await E.stat(r);if(e.type==="copilot"){if(i.isDirectory())return this._createDirectorySession(o,r,i,"copilot");if(o.endsWith(".jsonl"))return this._createFileSession(o,r,i,"copilot")}else if(e.type==="claude"){if(i.isDirectory())return this._scanClaudeProjectDir(r,o)}else if(e.type==="pi-mono"){if(i.isDirectory())return this._scanPiMonoDir(r,o)}else if(e.type==="vscode"&&i.isDirectory())return this._scanVsCodeWorkspaceDir(r);return null});return(await Promise.allSettled(t)).filter(o=>o.status==="fulfilled"&&o.value!==null&&o.value!==void 0).map(o=>o.value).flat()}async _scanClaudeProjectDir(e,s){try{let t=await E.readdir(e),n=[];for(let o of t){if(te(o))continue;let r=w.join(e,o),i=await E.stat(r);if(i.isFile()&&o.endsWith(".jsonl")){let a=await this._createClaudeSession(o,r,i,s);a&&n.push(a)}if(i.isDirectory()){let a=w.join(r,"subagents");try{if((await E.stat(a)).isDirectory()){let c=await this._createClaudeSubagentsSession(o,r,i,s);c&&n.push(c)}}catch{}}}return n}catch(t){return console.error(`Error scanning Claude project dir ${e}:`,t.message),[]}}async _createClaudeSession(e,s,t,n){let o=e.replace(".jsonl",""),r=await z(s);console.log(`[DEBUG] _createClaudeSession: ${e}, events: ${r}`);try{let l=(await E.readFile(s,"utf-8")).trim().split(`
7
+ `).filter(S=>S.trim()).map(S=>{try{return JSON.parse(S)}catch{return null}}).filter(S=>S!==null);console.log(`[DEBUG] Parsed ${l.length} events from ${e}`);let c=l.some(S=>S.type==="assistant"||S.type==="user"),d=l.some(S=>S.type==="assistant.message"||S.type==="user.message");if(console.log(`[DEBUG] ${e}: hasClaudeCoreEvents=${c}, hasCopilotCoreEvents=${d}`),!c&&d)return console.warn(`File ${s} contains only Copilot core events, skipping as Claude session`),null;if(!c)return console.warn(`File ${s} has no Claude core events (assistant/user), skipping`),null;if(console.log(`[DEBUG] ${e} passed validation, creating session...`),this.parserFactory.getParserType(l)!=="claude")return null;let m=this.parserFactory.parse(l),f=m.metadata||{},g=n.replace(/^-/,"/").replace(/-/g,"/");return new R(o,"file",{source:"claude",filePath:s,directory:w.dirname(s),workspace:{summary:f.model?`Claude Code session (${f.model})`:"Claude Code session",cwd:f.cwd||g},createdAt:f.startTime||t.birthtime,updatedAt:t.mtime,summary:m.turns[0]?.userMessage?.content?.substring(0,100)||"No summary",hasEvents:r>0,eventCount:r,duration:null,isImported:!1,hasInsight:!1,copilotVersion:f.version,selectedModel:f.model,sessionStatus:"completed"})}catch(i){return console.error(`Error creating Claude session ${o}:`,i.message),null}}async findById(e){if(te(e))return null;for(let s of this.sources){let t=null;if(s.type==="copilot"?t=await this._findCopilotSession(e,s.dir):s.type==="claude"?t=await this._findClaudeSession(e,s.dir):s.type==="pi-mono"?t=await this._findPiMonoSession(e,s.dir):s.type==="vscode"&&(t=await this._findVsCodeSession(e,s.dir)),t)return t}return null}async _findCopilotSession(e,s){try{let t=w.join(s,e),n=await E.stat(t);if(n.isDirectory())return await this._createDirectorySession(e,t,n,"copilot")}catch{}try{let t=w.join(s,`${e}.jsonl`),n=await E.stat(t);if(n.isFile())return await this._createFileSession(`${e}.jsonl`,t,n,"copilot")}catch{}return null}async _findClaudeSession(e,s){try{let t=await E.readdir(s);for(let n of t){let o=w.join(s,n),r=w.join(o,`${e}.jsonl`);try{let a=await E.stat(r);if(a.isFile()){console.log(`[DEBUG] Found file: ${r}`);let l=await this._createClaudeSession(`${e}.jsonl`,r,a,n);if(l)return console.log("[DEBUG] File validated as Claude session, returning"),l;console.log("[DEBUG] File validation failed, checking directory...")}}catch(a){console.log(`[DEBUG] File not found: ${r}, error: ${a.message}`)}let i=w.join(o,e);console.log(`[DEBUG] Checking directory: ${i}`);try{let a=await E.stat(i);if(a.isDirectory()){console.log("[DEBUG] Directory exists, checking for subagents...");let l=w.join(i,"subagents");try{if((await E.stat(l)).isDirectory()){console.log("[DEBUG] Found subagents directory, creating session...");let d=await this._createClaudeSubagentsSession(e,i,a,n);return console.log("[DEBUG] Created subagents session:",d?"SUCCESS":"FAILED"),d}}catch(c){console.log(`[DEBUG] No subagents directory: ${c.message}`)}}}catch(a){console.log(`[DEBUG] Directory not found: ${a.message}`)}}}catch(t){console.error(`[DEBUG] Projects dir error: ${t.message}`)}return console.log(`[DEBUG] Session ${e} not found in any project`),null}async _findPiMonoSession(e,s){try{let t=await E.readdir(s);for(let n of t){let o=w.join(s,n);try{let i=(await E.readdir(o)).find(a=>a.includes(`_${e}.jsonl`));if(i){let a=w.join(o,i),l=await E.stat(a),c=await this._readFirstLine(a);if(c){let d=JSON.parse(c);if(d.type==="session"){let u=n.replace(/^--/,"").replace(/--$/,""),m=await z(a);return new R(e,"directory",{source:"pi-mono",filePath:a,directory:o,workspace:{cwd:d.cwd||u},createdAt:new Date(d.timestamp),updatedAt:new Date(l.mtime),summary:`Pi-Mono: ${w.basename(d.cwd||u)}`,hasEvents:m>0,eventCount:m,duration:null,sessionStatus:"completed"})}}}}catch{}}}catch(t){console.error(`Error searching Pi-Mono sessions: ${t.message}`)}return null}async _findVsCodeSession(e,s){try{let t=await E.readdir(s),n=[];for(let o of t){let r=w.join(s,o,"chatSessions");try{let a=(await E.readdir(r)).find(l=>l===`${e}.json`||l===`${e}.jsonl`||l.replace(/\.jsonl?$/,"")===e);if(a){let l=w.join(r,a),c=await E.stat(l),d=await E.readFile(l,"utf-8"),u;if(a.endsWith(".jsonl")){if(u=this._parseVsCodeJsonl(d),!u)continue}else u=JSON.parse(d);let m=u.requests||[];if(m.length===0)continue;let f=await this._resolveVsCodeWorkspacePath(w.join(s,o)),g={...c,filePath:l};n.push(this._buildVsCodeSession(e,m,u,g,o,f||w.join(s,o)))}}catch{}}if(n.length>0)return n.sort((o,r)=>(r.updatedAt?.getTime?.()??0)-(o.updatedAt?.getTime?.()??0)),n[0]}catch(t){console.error(`[VSCode findById] Error searching VSCode sessions: ${t.message}`,t.stack)}return console.log(`[VSCode findById] Session ${e} not found in vscode sessions`),null}async _createClaudeSubagentsSession(e,s,t,n){try{let o=w.join(s,"subagents"),i=(await E.readdir(o)).filter(g=>g.startsWith("agent-")&&g.endsWith(".jsonl"));if(i.length===0)return null;let a=0;for(let g of i){let S=w.join(o,g);a+=await z(S)}let l=w.join(o,i[0]),d=(await E.readFile(l,"utf-8")).trim().split(`
8
+ `).filter(g=>g.trim()),u=d.length>0?JSON.parse(d[0]):null,m={cwd:u?.cwd||n,version:u?.version,model:u?.message?.model,startTime:u?.timestamp},f=n.replace(/^-/,"/").replace(/-/g,"/");return new R(e,"directory",{source:"claude",directory:s,workspace:{summary:`Claude session (${i.length} sub-agents)`,cwd:m.cwd||f},createdAt:m.startTime||t.birthtime,updatedAt:t.mtime,summary:u?.message?.content?.substring(0,100)||"Sub-agent tasks",hasEvents:a>0,eventCount:a,duration:null,isImported:!1,hasInsight:!1,copilotVersion:m.version,selectedModel:m.model,sessionStatus:"completed"})}catch(o){return console.error(`Error creating Claude subagents session ${e}:`,o.message),null}}async _createDirectorySession(e,s,t,n="copilot"){let o=w.join(s,"workspace.yaml"),r=w.join(s,"events.jsonl"),i=w.join(s,".imported"),a=w.join(s,`${e}.agent-review.md`),l=await K(o)?await Cs(o):{summary:e,repo:"unknown"},c=await K(r)?await z(r):0,d=await K(i),u=await K(a),m=null,f=null,g=null,S="completed";if(await K(r)){let y=await dt(r);if(m=y.duration,f=y.copilotVersion,g=y.selectedModel,S=this._computeSessionStatus(y),!l.summary&&y.firstUserMessage&&(l.summary=y.firstUserMessage),y.lastEventTime){let j=new Date(y.lastEventTime).getTime(),v=new Date(t.mtime).getTime();j>v&&(t={...t,mtime:new Date(j)})}}let _=R.fromDirectory(s,e,t,l,c,m,d,u,f,g,S);return _.source=n,_}async _createFileSession(e,s,t,n="copilot"){let o=e.replace(".jsonl",""),r=await z(s),i=await dt(s),a=this._computeSessionStatus(i),l=R.fromFile(s,o,t,r,i.firstUserMessage,i.duration,i.copilotVersion,i.selectedModel,a);return l.source=n,l}_computeSessionStatus(e){return e.hasSessionEnd?"completed":e.lastEventTime!==null&&e.lastEventTime!==void 0&&Date.now()-e.lastEventTime<3e5?"wip":"completed"}async _scanPiMonoDir(e,s){try{console.log(`[PI-MONO] Scanning directory: ${e}`);let n=(await E.readdir(e)).filter(r=>r.endsWith(".jsonl"));if(console.log(`[PI-MONO] Found ${n.length} .jsonl files in ${s}`),n.length===0)return[];let o=[];n.sort().reverse();for(let r of n){let i=w.join(e,r),a=await E.stat(i),l=r.match(/_([a-f0-9-]+)\.jsonl$/);if(!l){console.log(`[PI-MONO] Skipping ${r}: no UUID match`);continue}let c=l[1],d=await this._readFirstLine(i);if(!d){console.log(`[PI-MONO] Skipping ${r}: no first line`);continue}try{let u=JSON.parse(d);if(u.type!=="session"){console.log(`[PI-MONO] Skipping ${r}: first event type is ${u.type}, not 'session'`);continue}let m=await z(i),f=s.replace(/^--/,"").replace(/--$/,""),g=new R(c,"directory",{source:"pi-mono",directory:e,workspace:{cwd:u.cwd||f},createdAt:new Date(u.timestamp),updatedAt:new Date(a.mtime),summary:`Pi-Mono: ${w.basename(u.cwd||f)}`,hasEvents:m>0,eventCount:m,duration:null,sessionStatus:"completed"});console.log(`[PI-MONO] Created session: ${c} from ${r}`),o.push(g)}catch(u){console.error(`[PI-MONO] Error parsing session ${r}:`,u.message)}}return console.log(`[PI-MONO] Total sessions found in ${s}: ${o.length}`),o}catch(t){return console.error(`[PI-MONO] Error scanning dir ${e}:`,t.message),[]}}_parseVsCodeJsonl(e){let s=e.split(`
9
+ `).filter(o=>o.trim());if(s.length===0)return null;let t=JSON.parse(s[0]),n=t.v||t;for(let o=1;o<s.length;o++)try{let r=JSON.parse(s[o]),i=r.k||[],a=r.v;if(r.kind===2&&Array.isArray(a)){let l=n;for(let d=0;d<i.length-1;d++){let u=i[d];typeof u=="number"||l[u]||(l[u]={}),l=l[u]}let c=i[i.length-1];if(c!==void 0){l[c]||(l[c]=[]);let d=l[c],u=r.i;u==null?d.push(...a):d.splice(u,0,...a)}else{let d=r.i;d==null&&n.push?.(...a)}}else if(r.kind===1&&i.length>0){let l=n;for(let d=0;d<i.length-1;d++){let u=i[d];typeof u=="number"||l[u]||(l[u]={}),l=l[u]}let c=i[i.length-1];l[c]=a}}catch{}return n}async _resolveVsCodeWorkspacePath(e){try{let s=w.join(e,"workspace.json"),t=await E.readFile(s,"utf-8"),n=JSON.parse(t);if(n.folder)return decodeURIComponent(n.folder.replace("file://",""));if(n.workspace){let o=decodeURIComponent(n.workspace.replace("file://",""));try{let r=await E.readFile(o,"utf-8"),i=JSON.parse(r);if(Array.isArray(i.folders)&&i.folders.length>0){let a=w.dirname(o);return w.resolve(a,i.folders[0].path)}}catch{}}}catch{}return null}async _scanVsCodeWorkspaceDir(e){let s=w.join(e,"chatSessions");try{await E.access(s)}catch{return[]}let t=w.basename(e),n=await this._resolveVsCodeWorkspacePath(e),r=(await E.readdir(s)).filter(a=>(a.endsWith(".json")||a.endsWith(".jsonl"))&&!te(a));if(r.length===0)return[];let i=[];for(let a of r){let l=w.join(s,a);try{let c=await E.stat(l),d=await E.readFile(l,"utf-8"),u;if(a.endsWith(".jsonl")){if(u=this._parseVsCodeJsonl(d),!u)continue}else u=JSON.parse(d);let m=u.sessionId||w.basename(a).replace(/\.jsonl?$/,""),f=u.requests||[];if(f.length===0)continue;let g={...c,filePath:l},S=this._buildVsCodeSession(m,f,u,g,t,n||e);i.push(S)}catch{}}return i}_buildVsCodeSession(e,s,t,n,o,r){let i=s[0],a=s[s.length-1],l=t.creationDate?new Date(t.creationDate):i.timestamp?new Date(i.timestamp):n.birthtime,c=a.timestamp?new Date(a.timestamp):null,d=t.lastMessageDate?new Date(t.lastMessageDate):c||n.mtime,m=this._extractLastTerminalTimestamp(s)||c||d,f=Date.now()-m.getTime()<900*1e3,g=this._extractVsCodeUserText(i.message),S=s.reduce((_,y)=>_+(y.response||[]).filter(j=>j.kind==="toolInvocationSerialized").length,0);return new R(e,"file",{source:"vscode",filePath:n.filePath,workspaceHash:o,createdAt:l,updatedAt:m,summary:g?g.slice(0,120):`VSCode chat (${s.length} requests)`,hasEvents:!0,eventCount:s.reduce((_,y)=>_+(y.response||[]).length,0)+s.length*2+1,duration:m.getTime()-l.getTime(),sessionStatus:f?"wip":"completed",selectedModel:i.modelId||null,agentId:i.agent?.id||"vscode-copilot",toolCount:S,copilotVersion:i.agent?.extensionVersion||null,workspace:{cwd:r}})}_extractLastTerminalTimestamp(e){let s=0;function t(n){if(!(!n||typeof n!="object")){if(Array.isArray(n)){n.forEach(t);return}if(n.terminalCommandState&&typeof n.terminalCommandState.timestamp=="number"){let o=n.terminalCommandState.timestamp;o>1e12&&o<9999999999999&&o>s&&(s=o)}for(let o of Object.values(n))t(o)}}for(let n of e)t(n.response);return s>0?new Date(s):null}_extractVsCodeUserText(e){return e?typeof e.text=="string"?e.text:Array.isArray(e.parts)?e.parts.filter(s=>s.kind==="text").map(s=>s.text||"").join(""):"":""}async _readFirstLine(e){let s=require("fs"),t=require("readline");return new Promise((n,o)=>{let r=s.createReadStream(e,{encoding:"utf-8"}),i=t.createInterface({input:r,crlfDelay:1/0}),a=!1;i.on("line",l=>{a||(a=!0,i.close(),n(l.trim()))}),i.on("close",()=>{a||n(null)}),i.on("error",l=>{a||(a=!0,o(l))}),r.on("error",l=>{a||(a=!0,i.close(),o(l))})})}_sortByUpdatedAt(e){return e.sort((s,t)=>new Date(t.updatedAt)-new Date(s.updatedAt))}};pt.exports=Te});var ft=b((Sn,mt)=>{var Ce=class{normalizeEvents(e,s){return Array.isArray(e)?e.filter(t=>!t._isToolResultWrapper).map(t=>this.normalizeEvent(t,s)):(console.warn("[EventNormalizer] normalizeEvents: events is not an array",typeof e),[])}normalizeEvent(e,s){return!e||typeof e!="object"?(console.warn("[EventNormalizer] normalizeEvent: invalid event",e),e):this._isAssistantMessage(e)?this._normalizeAssistantMessage(e,s):this._isTimelineEvent(e)?this._normalizeTimelineEvent(e,s):e}_isAssistantMessage(e){return e.data?.tools&&Array.isArray(e.data.tools)&&e.data.tools.length>0?!0:e.type==="assistant.message"||e.type==="assistant"||e.type==="user.message"||e.type==="user"}_isTimelineEvent(e){return e.type?.startsWith("tool.")||e.type?.startsWith("subagent.")}_normalizeAssistantMessage(e,s){let t={...e};return e.data?.tools&&Array.isArray(e.data.tools)&&(t.data={...e.data,tools:e.data.tools.filter(n=>n.type!=="tool_result").map(n=>this._normalizeToolCall(n,s,e.timestamp))}),t}_normalizeToolCall(e,s,t){if(e.type==="tool_use"){let n=this._computeStatus(e),o=t,r=e._matched?t:null;return{type:"tool_use",id:e.id,name:e.name,startTime:o,endTime:r,status:n,input:e.input||{},result:e.result||null,error:e.error||null,metadata:{source:s,matched:e._matched,duration:this._computeDuration(o,r)}}}if(e.name&&e.status){let n=t,o=e.status==="success"?"completed":e.status,r=o==="completed"||o==="error"?t:null;return{id:e.id||this._generateToolId(),name:e.name,startTime:n,endTime:r,status:o,input:e.input||{},result:e.isError?null:e.result||null,error:e.isError?e.result:null,metadata:{source:s,duration:this._computeDuration(n,r)}}}return console.warn("[EventNormalizer] Unknown tool format, applying fallback normalization",e),{id:e.id||this._generateToolId(),name:e.name||"unknown",startTime:t,endTime:null,status:"running",input:e.input||{},result:null,error:null,metadata:{source:s,fallback:!0}}}_computeStatus(e){return e.error?"error":e.result!==void 0&&e.result!==null&&e.result!==""?"completed":e._matched===!1?"running":e._matched?"completed":"running"}_computeDuration(e,s){if(!(!e||!s))try{let t=new Date(e),n=new Date(s);if(isNaN(t.getTime())||isNaN(n.getTime()))return;let o=n.getTime()-t.getTime();return o>=0?o:void 0}catch{return}}_generateToolId(){return`tool-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}_normalizeTimelineEvent(e){return e.type==="tool.execution_start"||e.type==="tool.execution_complete"?{...e,data:{...e.data,toolCallId:e.data?.toolCallId||e.data?.id,toolName:e.data?.toolName||e.data?.tool||e.data?.name,...e.data}}:(e.type?.startsWith("subagent."),e)}};mt.exports=Ce});var je=b((wn,St)=>{var D=require("fs"),x=require("path"),gt=require("readline"),{isValidSessionId:ht,buildMetadata:js}=L(),yt=Ee(),vs=ft(),be=class{constructor(e){e?(this.SESSION_DIR=e,this.sessionRepository=new yt(e)):this.sessionRepository=new yt,this.eventNormalizer=new vs}async getAllSessions(e=null){return(await this.sessionRepository.findAll(e)).map(t=>t.toJSON())}async getPaginatedSessions(e=1,s=20,t=null){let o=(await this.sessionRepository.findAll(t)).map(l=>l.toJSON()),r=(e-1)*s,i=r+s;return{sessions:o.slice(r,i),totalSessions:o.length,currentPage:e,totalPages:Math.ceil(o.length/s),hasNextPage:i<o.length,hasPrevPage:e>1}}async getSessionById(e){return ht(e)?(await this.getAllSessions()).find(t=>t.id===e):null}async getSessionEvents(e,s=null){if(!ht(e))return s?{events:[],total:0}:[];let t=await this.sessionRepository.findById(e);if(!t)return s?{events:[],total:0}:[];let n;if(t.source==="copilot")if(this.SESSION_DIR){let r=x.join(this.SESSION_DIR,e);try{(await D.promises.stat(r)).isDirectory()?n=x.join(r,"events.jsonl"):n=x.join(this.SESSION_DIR,`${e}.jsonl`)}catch{n=x.join(this.SESSION_DIR,`${e}.jsonl`)}}else{let r=this.sessionRepository.sources.find(a=>a.type==="copilot");if(!r)return[];let i=x.join(r.dir,e);try{(await D.promises.stat(i)).isDirectory()?n=x.join(i,"events.jsonl"):n=x.join(r.dir,`${e}.jsonl`)}catch{n=x.join(r.dir,`${e}.jsonl`)}}else if(t.source==="claude"){let r=this.sessionRepository.sources.find(i=>i.type==="claude");if(!r)return[];if(t.type!=="directory")try{let i=await D.promises.readdir(r.dir);for(let a of i){let l=x.join(r.dir,a,`${e}.jsonl`);try{await D.promises.access(l),n=l;break}catch{}}}catch(i){return console.error("Error searching Claude projects:",i),[]}}else if(t.source==="pi-mono"){let r=this.sessionRepository.sources.find(i=>i.type==="pi-mono");if(!r)return[];try{let i=await D.promises.readdir(r.dir);for(let a of i){let l=x.join(r.dir,a);try{let d=(await D.promises.readdir(l)).find(u=>u.includes(`_${e}.jsonl`));if(d){n=x.join(l,d);break}}catch{}}}catch(i){return console.error("Error searching Pi-Mono sessions:",i),[]}}else if(t.source==="vscode"){let{VsCodeParser:r}=Ie(),i=new r;try{let a=await D.promises.readFile(t.filePath,"utf-8"),c=a.trim().split(`
10
+ `).filter(m=>m.trim()).map(m=>{try{return JSON.parse(m)}catch{return null}}).filter(m=>m!==null);if(c.length===0)return[];let d;if(i.canParse(c))d=i.parseJsonl(c);else{let m=JSON.parse(a);d=i.parseVsCode(m)}let u=this._expandVsCodeEvents(d.allEvents);if(u.length>0)try{let m=await D.promises.stat(t.filePath),f=new Date(m.mtime).toISOString(),g=u[u.length-1];if(g&&g.timestamp){let S=new Date(g.timestamp).getTime(),y=(new Date(f).getTime()-S)/1e3;y>10&&(g.timestamp=f,console.log(`[VSCode] Updated session ${t.id} end time to file mtime (${y.toFixed(0)}s difference)`))}}catch(m){console.error("[VSCode] Error getting file mtime:",m)}return u=this._expandVsCodeToTimelineFormat(u),u}catch(a){return console.error("Error reading VSCode session:",a),[]}}let o=[];if(n)try{await D.promises.access(n);let r=D.createReadStream(n,{encoding:"utf-8"}),i=gt.createInterface({input:r,crlfDelay:1/0}),a=0,l=[];for await(let d of i){let u=d.trim();if(u)try{let m=JSON.parse(u);m._fileIndex=a,l.push(m)}catch(m){console.error(`Error parsing line ${a+1}:`,m.message)}a++}o=l,o.sort((d,u)=>{let m=d.timestamp?new Date(d.timestamp).getTime():0,f=u.timestamp?new Date(u.timestamp).getTime():0;return m!==f?m-f:d._fileIndex-u._fileIndex}),o=o.map(d=>this._normalizeEvent(d,t.source)),t.source==="copilot"?this._matchCopilotToolCalls(o):t.source==="claude"&&this._matchClaudeToolResults(o)}catch(r){console.error("Error reading main events file:",r)}if(await this._mergeSubAgentEvents(o,n,e,t.source),t.source==="copilot"?(this._matchCopilotToolCalls(o),o=this._expandCopilotToTimelineFormat(o)):t.source==="claude"?(this._matchClaudeToolResults(o),o=this._expandClaudeToTimelineFormat(o)):t.source==="pi-mono"&&this._mergePiMonoToolResults(o),o=o.filter(r=>r.timestamp||r.snapshot?.timestamp?!0:(console.warn("[SessionService] Filtered event without timestamp:",r.type,r.id||r._fileIndex),!1)),o.forEach(r=>{r._fileIndex===999999&&r.timestamp&&delete r._fileIndex}),o=this.eventNormalizer.normalizeEvents(o,t.source),s&&typeof s.limit=="number"&&typeof s.offset=="number"){let r=o.length;return{events:o.slice(s.offset,s.offset+s.limit),total:r}}return o}async _mergeSubAgentEvents(e,s,t,n){let o;if(n==="claude"){let r=this.sessionRepository.sources.find(i=>i.type==="claude");if(!r)return;try{let i=await D.promises.readdir(r.dir);for(let a of i){let l=x.join(r.dir,a,t,"subagents");try{if((await D.promises.stat(l)).isDirectory()){o=l;break}}catch{}}}catch(i){console.error("Error searching Claude subagents:",i);return}}else if(n==="copilot"&&s){let r=x.dirname(s);x.basename(s)==="events.jsonl"?o=x.join(r,"subagents"):o=x.join(r,t,"subagents")}if(o){try{if(!(await D.promises.stat(o)).isDirectory())return}catch{return}try{let i=(await D.promises.readdir(o)).filter(a=>a.startsWith("agent-")&&a.endsWith(".jsonl"));if(i.length===0)return;for(let a of i){let l=a.replace(".jsonl",""),c=x.join(o,a);try{let d=D.createReadStream(c,{encoding:"utf-8"}),u=gt.createInterface({input:d,crlfDelay:1/0}),m=[];for await(let A of u){let $=A.trim();$&&m.push($)}if(m.length===0)continue;let f=l.replace("agent-",""),g=f.toUpperCase(),S=`Sub-agent ${l}`;try{let A=JSON.parse(m[0]);if(A.agentId&&(f=A.agentId,g=`agent-${A.agentId}`),A.message?.content){let $=typeof A.message.content=="string"?A.message.content:JSON.stringify(A.message.content);S=$.length>100?$.slice(0,100)+"...":$}}catch{}let _=m.map((A,$)=>{try{let G=JSON.parse(A);return G._fileIndex=1e6+$,G._subagent={id:l,name:f},G}catch(G){return console.error(`Error parsing sub-agent ${l} line ${$+1}:`,G.message),null}}).filter(A=>A!==null);if(_.length===0)continue;let y=_.map(A=>this._normalizeEvent(A,n)),j=y[0],v=y[y.length-1],F=j.timestamp||new Date().toISOString(),oe=v.timestamp||new Date().toISOString(),re={type:"subagent.started",id:`${l}-start`,timestamp:F,_fileIndex:j._fileIndex-1,_subagent:{id:l,name:f},data:{toolCallId:l,agentName:f,agentDisplayName:g,agentDescription:S}},Le={type:"subagent.completed",id:`${l}-end`,timestamp:oe,_fileIndex:v._fileIndex+1,_subagent:{id:l,name:f},data:{toolCallId:l,result:`Sub-agent ${g} completed`}};e.push(re,...y,Le)}catch(d){console.error(`Error reading sub-agent ${l}:`,d)}}e.sort((a,l)=>{let c=a.timestamp?new Date(a.timestamp).getTime():0,d=l.timestamp?new Date(l.timestamp).getTime():0;return c!==d?c-d:a._fileIndex-l._fileIndex})}catch(r){console.error("Error processing sub-agents:",r)}}}_matchClaudeToolResults(e){let s=new Map;e.forEach(t=>{t.data?.tools&&t.data.tools.forEach(n=>{n.type==="tool_result"&&(n.tool_use_id?s.set(n.tool_use_id,n):console.warn("[sessionService] tool_result missing tool_use_id:",n))})}),e.forEach(t=>{t.type==="user"&&Array.isArray(t.message?.content)&&t.message.content.length>0&&t.message.content.every(o=>o?.type==="tool_result")&&(t._isToolResultWrapper=!0)}),e.forEach(t=>{t.data?.tools&&(t.data.tools=t.data.tools.map(n=>{if(n.type==="tool_use"){let o=s.get(n.id);return o?{...n,result:o.content,_matched:!0}:{...n,_matched:!1}}return n}),t.type==="assistant"||t.type==="assistant.message"?t.data.tools=t.data.tools.filter(n=>n.type!=="tool_result"):(t.type==="user"||t.type==="user.message")&&t.data.tools.length>0&&t.data.tools.every(o=>o.type==="tool_result")&&(t._isToolResultWrapper=!0))})}_mergePiMonoToolResults(e){let s=new Set;e.forEach(n=>{if(n.type==="assistant.message"&&n.data.tools&&n.data.tools.length>0){let o=n.data.tools,r=[],i=n.id,a=!0;for(;a&&r.length<o.length;){a=!1;for(let l of e)if(l.type==="message"&&l.data.role==="toolResult"&&l.parentId===i&&!r.includes(l)){r.push(l),i=l.id,a=!0;break}}r.forEach((l,c)=>{if(c<o.length){let d=o[c];d.result=l.data.result,d.resultId=l.id,d.status="completed",s.add(l.id)}})}});let t=e.length;for(let n=e.length-1;n>=0;n--)e[n].type==="message"&&e[n].data.role==="toolResult"&&s.has(e[n].id)&&e.splice(n,1);s.size>0&&console.log(`[PI-MONO] Merged ${s.size} toolResult events into assistant messages (${t} \u2192 ${e.length} events)`)}_matchPiMonoToolResults_OLD(e){let s=new Set;e.forEach(n=>{if(n.type==="assistant.message"&&n.data.tools&&n.data.tools.length>0){let o=n.data.tools,r=[],i=n.id,a=!0;for(;a&&r.length<o.length;){a=!1;for(let l of e)if(l.type==="tool.result"&&l.parentId===i&&!r.includes(l)){r.push(l),i=l.id,a=!0;break}}r.forEach((l,c)=>{if(c<o.length){let d=o[c];d.status="completed",d._matched=!0,d.result=l.data.result,d.resultId=l.id,s.add(l.id)}})}});let t=e.length;for(let n=e.length-1;n>=0;n--)e[n].type==="tool.result"&&s.has(e[n].id)&&e.splice(n,1);s.size>0&&console.log(`[PI-MONO] Removed ${s.size} matched tool.result events (${t} \u2192 ${e.length} events)`)}_matchCopilotToolCalls(e){let s=new Map;e.forEach(t=>{if(t.type==="tool.execution_start"){let n=t.data?.toolCallId;n&&s.set(n,{name:t.data.toolName,input:t.data.arguments||{},start:t})}else if(t.type==="tool.execution_complete"){let n=t.data?.toolCallId;if(n)if(s.has(n)){let o=s.get(n);o.complete=t,o.result=t.data?.result,o.status=t.data?.error?"error":"completed",o.error=t.data?.error}else console.warn(`[sessionService] Orphaned tool.execution_complete for toolCallId=${n}`),s.set(n,{name:t.data.toolName||"unknown",input:{},start:null,complete:t,result:t.data?.result,status:t.data?.error?"error":"completed",error:t.data?.error})}}),e.forEach(t=>{if(t.type==="assistant.message"&&t.data?.toolRequests){let n=[];t.data.toolRequests.forEach(o=>{let r=o.toolCallId;if(s.has(r)){let i=s.get(r);n.push({type:"tool_use",id:r,name:o.name||i.name,input:o.arguments||i.input,result:i.result,status:i.status||"running",error:i.error,_matched:!!i.complete})}else n.push({type:"tool_use",id:r,name:o.name,input:o.arguments||{},status:"running",_matched:!1})}),n.length>0&&(t.data.tools=n)}})}_generateBadgeInfo(e){let s=e.type,t=e.data||{};if(s==="message"&&t.role==="toolResult"){e.data.badgeLabel="TOOL RESULT",e.data.badgeClass="badge-tool";return}if(s==="session.model_change"||s==="model.change"){e.data.badgeLabel="MODEL CHANGE",e.data.badgeClass="badge-session";return}if(s==="session.truncation"){e.data.badgeLabel="TRUNCATION",e.data.badgeClass="badge-truncation";return}if(s==="session.compaction_start"||s==="session.compaction_complete"||s==="compaction"){e.data.badgeLabel="COMPACTION",e.data.badgeClass="badge-compaction";return}if(s==="thinking.change"){e.data.badgeLabel="THINKING",e.data.badgeClass="badge-session";return}if(s==="system.notification"){e.data.badgeLabel="SYSTEM",e.data.badgeClass="badge-system";return}let o=(s||"").split(".")[0]||"unknown",i={user:{label:"USER",class:"badge-user"},assistant:{label:"ASSISTANT",class:"badge-assistant"},reasoning:{label:"REASONING",class:"badge-reasoning"},turn:{label:"TURN",class:"badge-turn"},tool:{label:"TOOL",class:"badge-tool"},subagent:{label:"SUBAGENT",class:"badge-subagent"},skill:{label:"SKILL",class:"badge-skill"},session:{label:"SESSION",class:"badge-session"},error:{label:"ERROR",class:"badge-error"},abort:{label:"ABORT",class:"badge-error"}}[o]||{label:o.toUpperCase(),class:"badge-info"};e.data.badgeLabel=i.label,e.data.badgeClass=i.class}_normalizeEvent(e,s){let t={...e};if(t.data=t.data||{},s==="copilot"){if(e.type==="user.message"&&e.data?.source==="system"){t.type="system.notification";let n=e.data.content||e.data.message||"",o=n.match(/<system_notification>([\s\S]*?)<\/system_notification>/);return t.data.message=o?o[1].trim():n.trim(),this._generateBadgeInfo(t),t}if(e.type==="request"){if(t.type="user",e.payload?.messages&&Array.isArray(e.payload.messages)){let n=e.payload.messages.find(o=>o.role==="user");n&&(t.message={role:"user",content:n.content||""})}}else if(e.type==="response"&&(t.type="assistant",e.payload?.content&&Array.isArray(e.payload.content))){let n=e.payload.content.filter(o=>o.type==="text");n.length>0&&(t.message={role:"assistant",content:n.map(o=>o.text).join(`
11
+ `)})}return e.type==="assistant.message"&&e.data?.content&&e.data.content.trim()&&(t.data.message=e.data.content),this._generateBadgeInfo(t),t}if(s==="pi-mono"){if(e.type==="message"){let{message:n}=e;if(n.role==="user"?t.type="user.message":n.role==="assistant"?t.type="assistant.message":n.role==="toolResult"&&(t.type="message"),t.data.role=n.role,Array.isArray(n.content)){let o=n.content.filter(r=>r.type==="text");if(o.length>0&&(t.data.message=o.map(r=>r.text).join(`
12
+ `)),n.role==="assistant"){let r=n.content.filter(i=>i.type==="toolCall");r.length>0&&(t.data.tools=r.map(i=>({type:"tool_use",id:i.id,name:i.name,input:i.arguments})))}n.role==="toolResult"&&(t.data.result=o.map(r=>r.text).join(`
13
+ `))}n.usage&&(t.usage=n.usage)}else if(e.type==="model_change")t.type="model.change",t.data={provider:e.provider,model:e.modelId},e.provider&&e.modelId?t.data.message=`Model changed to ${e.provider}/${e.modelId}`:e.modelId&&(t.data.message=`Model changed to ${e.modelId}`);else if(e.type==="thinking_level_change")t.type="thinking.change",t.data={level:e.thinkingLevel},e.thinkingLevel&&(t.data.message=`Thinking level: ${e.thinkingLevel}`);else if(e.type==="session"){t.data={cwd:e.cwd,version:e.version};let n=[];e.cwd&&n.push(`Working directory: ${e.cwd}`),e.version&&n.push(`Session version: ${e.version}`),n.length>0&&(t.data.message=n.join(`
14
+ `))}return this._generateBadgeInfo(t),t}switch(e.type){case"user":case"assistant":if(e.message){if(e.message.content){let n=this._extractClaudeTextContent(e.message.content);n&&(t.data.message=n)}if(Array.isArray(e.message.content)){let n=e.message.content.filter(o=>o&&typeof o=="object"&&(o.type==="tool_use"||o.type==="tool_result"));n.length>0&&(t.data.tools=n.map(o=>o.type==="tool_use"?{type:"tool_use",id:o.id,name:o.name,input:o.input}:{type:"tool_result",tool_use_id:o.tool_use_id,content:o.content}))}t._originalMessage=e.message}break;case"file-history-snapshot":if(e.snapshot?.trackedFileBackups){let n=Object.entries(e.snapshot.trackedFileBackups);if(n.length>0){let o=n.map(([r,i])=>`${r} (v${i.version})`).join(`
15
+ `);t.data.message=`Tracked files:
16
+ ${o}`}else t.data.message="No files tracked"}break;case"progress":if(e.data){let n=[];if(e.data.hookName&&n.push(`Hook: ${e.data.hookName}`),e.data.hookEvent&&n.push(`Event: ${e.data.hookEvent}`),e.data.command&&n.push(`Command: ${e.data.command}`),n.length>0&&(t.data.message=n.join(`
17
+ `)),e.data.message?.message?.content&&Array.isArray(e.data.message.message.content)){let o=e.data.message.message.content.filter(r=>r&&typeof r=="object"&&(r.type==="tool_use"||r.type==="tool_result"));o.length>0&&(t.data.tools=o.map(r=>r.type==="tool_use"?{type:"tool_use",id:r.id,name:r.name,input:r.input}:{type:"tool_result",tool_use_id:r.tool_use_id,content:r.content}))}}break;default:e.data?.message&&!t.data.message&&(t.data.message=e.data.message)}return this._generateBadgeInfo(t),t}_extractClaudeTextContent(e){if(typeof e=="string")return e;if(Array.isArray(e)){let s=[];for(let t of e)if(t.type==="text")s.push(t.text);else if(t.type==="tool_result"){if(typeof t.content=="string")s.push(t.content);else if(Array.isArray(t.content)){let n=t.content.filter(o=>o.type==="text").map(o=>o.text).join(`
18
+ `);n&&s.push(n)}}return s.join(`
19
+ `)}return""}async getSessionWithEvents(e){let s=await this.getSessionById(e);if(!s)return null;let t=await this.getSessionEvents(e),n=js(s),o=t.find(i=>i.type==="session.start");o?.data?.selectedModel&&(n.model=o.data.selectedModel);let r=t.find(i=>i.type==="session.model_change");if(r?.data&&(n.model=r.data.newModel||r.data.model),t.length){let i=t[t.length-1];i?.timestamp&&(n.updated=i.timestamp)}if(t.length){let i=t[0];i?.timestamp&&(n.created=i.timestamp)}return{session:s,events:t,metadata:n}}async getTimeline(e){let s=await this.getSessionById(e);if(!s)return null;let t=await this.getSessionEvents(e);return s.source==="copilot"?this._buildCopilotTimeline(t,s):s.source==="claude"?this._buildClaudeTimeline(t,s):s.source==="pi-mono"?this._buildPiMonoTimeline(t,s):{turns:[],summary:{}}}_buildPiMonoTimeline(e,s){let t=[],n=0;for(let i=0;i<e.length;i++){let a=e[i];if(a.type==="user.message"){n++;let l={id:`turn-${n}`,type:"user-request",message:a.data.message||"",startTime:a.timestamp,endTime:a.timestamp,assistantTurns:[],subagents:[]},c=i+1,d=0;for(;c<e.length&&e[c].type!=="user.message";){let u=e[c];if(u.type==="assistant.message"){d++,l.endTime=u.timestamp;let m={id:`assistant-${d}`,startTime:u.timestamp,endTime:u.timestamp,tools:[]};if(u.data.tools&&Array.isArray(u.data.tools))for(let f of u.data.tools)m.tools.push({name:f.name,startTime:u.timestamp,endTime:u.timestamp,status:f.status||"completed",input:f.input,result:f.result});l.assistantTurns.push(m)}c++}t.push(l)}}let o=t.reduce((i,a)=>i+a.assistantTurns.reduce((l,c)=>l+c.tools.length,0),0),r={totalTurns:t.length,totalAssistantTurns:t.reduce((i,a)=>i+a.assistantTurns.length,0),totalTools:o,totalSubagents:0,startTime:e[0]?.timestamp,endTime:e[e.length-1]?.timestamp};return{turns:t,summary:r}}_buildCopilotTimeline(e,s){let t=[],n=null,o=0;for(let i of e)if(i.type==="assistant.turn_start")o++,n={id:`turn-${o}`,type:"assistant-turn",message:i.data.message||"",startTime:i.timestamp,endTime:null,tools:[],subagents:[]};else if(i.type==="assistant.turn_complete"&&n)n.endTime=i.timestamp,t.push(n),n=null;else if(i.type==="tool.execution_start"&&n){let a={name:i.data.tool||i.data.name,startTime:i.timestamp,endTime:null,status:"running",input:i.data.arguments||i.data.input};n.tools.push(a)}else if(i.type==="tool.execution_complete"&&n){let a=n.tools.find(l=>l.name===(i.data.tool||i.data.name)&&!l.endTime);a&&(a.endTime=i.timestamp,a.status=i.data.error||i.data.isError?"error":"completed",a.result=i.data.result||i.data.output)}n&&(n.endTime=e[e.length-1]?.timestamp,t.push(n));let r={totalTurns:t.length,totalTools:t.reduce((i,a)=>i+a.tools.length,0),totalSubagents:0,startTime:e[0]?.timestamp,endTime:e[e.length-1]?.timestamp};return{turns:t,summary:r}}_buildClaudeTimeline(e,s){return this._buildPiMonoTimeline(e,s)}_expandPiMonoToCopilotFormat(e){let s=[],t=0,n=0;for(let o=0;o<e.length;o++){let r=e[o];if(r.type!=="user.message"&&r.type!=="assistant.message"){s.push(r);continue}if(r.type==="user.message"){t++,s.push({...r,_turnNumber:t});continue}if(r.type==="assistant.message"){let i=r.data.tools||[],a=r.timestamp,l=`pi-turn-${o}`;s.push({type:"assistant.turn_start",id:`${l}-start`,timestamp:a,parentId:r.parentId,data:{message:r.data.message||"",model:r.data.model,tools:i.length>0?i:void 0},_synthetic:!0,_turnNumber:t,_fileIndex:r._fileIndex}),s.push({...r,_fileIndex:r._fileIndex+.05}),i.forEach((c,d)=>{let u=`pi-tool-${n++}`,m=a,f=a;s.push({type:"tool.execution_start",id:`${u}-start`,timestamp:m,parentId:l,data:{toolCallId:u,toolName:c.name,tool:c.name,arguments:c.input||{}},_synthetic:!0,_fileIndex:r._fileIndex+.1+d*.01}),s.push({type:"tool.execution_complete",id:`${u}-complete`,timestamp:f,parentId:u,data:{toolCallId:u,toolName:c.name,tool:c.name,result:c.result,error:c.status==="error"?"Tool execution failed":null,isError:c.status==="error"},_synthetic:!0,_fileIndex:r._fileIndex+.15+d*.01})}),s.push({type:"assistant.turn_complete",id:`${l}-complete`,timestamp:r.timestamp,parentId:l,data:{message:r.data.message||""},_synthetic:!0,_turnNumber:t,_fileIndex:r._fileIndex+.9})}}return s}_expandVsCodeEvents(e){let s=[],t=[],n=null,o=null,r=0,i=null,a=null,l=()=>{t.length!==0&&(s.push({type:"assistant.message",id:`vscode-tools-${r}`,timestamp:o,parentId:n,data:{message:"",content:"",tools:t,subAgentId:i,subAgentName:a},_synthetic:!0}),t=[],i=null,a=null)};for(let c=0;c<e.length;c++){let d=e[c];if(d.type==="tool.invocation"){let u=d.data?.subAgentId||null;t.length>0&&u!==i&&l(),t.length===0&&(n=d.parentId,o=d.timestamp,r=c,i=u,a=d.data?.subAgentName||null),d.data?.tool&&t.push(d.data.tool)}else l(),s.push(d)}return l(),s}_expandCopilotToTimelineFormat(e){let s=[],t=0;for(let n=0;n<e.length;n++){let o=e[n];if(o.type==="user"){t++,s.push({...o,type:"user.message",_turnNumber:t,data:{...o.data,message:o.message?.content||o.data?.message||""}});continue}if(o.type==="assistant"){let r=o.uuid||`copilot-assistant-${n}`,i=o.timestamp,a="";o.message?.content?Array.isArray(o.message.content)?a=o.message.content.filter(l=>l&&l.type==="text").map(l=>l.text).join(`
20
+ `):typeof o.message.content=="string"&&(a=o.message.content):o.data?.message&&(a=o.data.message),s.push({type:"assistant.turn_start",id:`${r}-start`,timestamp:i,parentId:o.parentId,uuid:o.uuid,data:{message:a,turnId:r},_synthetic:!0,_turnNumber:t,_fileIndex:o._fileIndex}),s.push({type:"assistant.message",id:r,timestamp:i,parentId:o.parentId,uuid:o.uuid,data:{message:a,tools:o.data?.tools||[]},_synthetic:!0,_turnNumber:t,_fileIndex:o._fileIndex+.05}),o.data?.tools&&o.data.tools.length>0&&o.data.tools.forEach((l,c)=>{let d=l.toolId||`tool-${n}-${c}`;l.start&&s.push({...l.start,_fileIndex:o._fileIndex+.1+c*.02}),l.complete&&s.push({...l.complete,_fileIndex:o._fileIndex+.15+c*.02})}),s.push({type:"assistant.turn_complete",id:`${r}-complete`,timestamp:i,parentId:r,uuid:o.uuid,data:{message:a},_synthetic:!0,_turnNumber:t,_fileIndex:o._fileIndex+.9});continue}s.push(o)}return s}_expandClaudeToTimelineFormat(e){let s=[],t=0;for(let n=0;n<e.length;n++){let o=e[n];if(o.type==="user"){t++,s.push({...o,type:"user.message",_turnNumber:t,data:{...o.data,message:o.data?.message||""}});continue}if(o.type==="assistant"){let r=o.id||`claude-assistant-${n}`,i=o.timestamp,a=o.data?.message||"";s.push({type:"assistant.turn_start",id:`${r}-start`,timestamp:i,parentId:o.parentId,data:{message:a,turnId:r},_synthetic:!0,_turnNumber:t,_fileIndex:o._fileIndex}),s.push({type:"assistant.message",id:r,timestamp:i,parentId:o.parentId,data:{message:a,tools:o.data?.tools||[]},_synthetic:!0,_turnNumber:t,_fileIndex:o._fileIndex+.05}),o.data?.tools&&o.data.tools.length>0&&o.data.tools.forEach((l,c)=>{l.type==="tool_use"&&(s.push({type:"tool.execution_start",id:`${l.id}-start`,timestamp:i,data:{toolCallId:l.id,toolName:l.name,arguments:l.input||{}},_synthetic:!0,_fileIndex:o._fileIndex+.1+c*.02}),l.result&&s.push({type:"tool.execution_complete",id:`${l.id}-complete`,timestamp:i,data:{toolCallId:l.id,toolName:l.name,result:l.result,isError:!1},_synthetic:!0,_fileIndex:o._fileIndex+.15+c*.02}))}),s.push({type:"assistant.turn_complete",id:`${r}-complete`,timestamp:i,parentId:r,data:{message:a},_synthetic:!0,_turnNumber:t,_fileIndex:o._fileIndex+.9});continue}s.push(o)}return s}_expandVsCodeToTimelineFormat(e){let s=[];for(let t=0;t<e.length;t++){let n=e[t];s.push(n),n.type==="assistant.message"&&n.data?.tools&&n.data.tools.length>0&&n.data.tools.forEach((o,r)=>{if(!o.id||!o.name)return;let i=o.startTime||n.timestamp,a=o.endTime||n.timestamp;s.push({type:"tool.execution_start",id:`${o.id}-start`,timestamp:i,parentId:n.id,data:{toolCallId:o.id,toolName:o.name,tool:o.name,arguments:o.input||{}},_synthetic:!0,_fileIndex:n._fileIndex?n._fileIndex+.1+r*.02:void 0}),s.push({type:"tool.execution_complete",id:`${o.id}-complete`,timestamp:a,parentId:o.id,data:{toolCallId:o.id,toolName:o.name,tool:o.name,result:o.result||null,error:o.error||(o.status==="error"?"Tool execution failed":null),isError:o.status==="error"},_synthetic:!0,_fileIndex:n._fileIndex?n._fileIndex+.15+r*.02:void 0})})}return s}};St.exports=be});var xe=b((_n,wt)=>{var k=require("fs").promises,N=require("path"),xs=require("os"),ve=class{constructor(){this.knownTagsDir=N.join(xs.homedir(),".session-viewer"),this.knownTagsFilePath=N.join(this.knownTagsDir,"known-tags.json")}async ensureKnownTagsFile(){try{await k.access(this.knownTagsFilePath)}catch{await k.mkdir(this.knownTagsDir,{recursive:!0}),await k.writeFile(this.knownTagsFilePath,JSON.stringify([]),"utf8")}}async readKnownTagsFile(){await this.ensureKnownTagsFile();try{let e=await k.readFile(this.knownTagsFilePath,"utf8");return JSON.parse(e)}catch(e){return console.error("Error reading known tags file:",e),[]}}async writeKnownTagsFile(e){await this.ensureKnownTagsFile(),await k.writeFile(this.knownTagsFilePath,JSON.stringify(e,null,2),"utf8")}getSessionTagsFilePath(e){if(e.filePath){let s=N.dirname(e.filePath),t=N.basename(e.filePath,N.extname(e.filePath));return N.join(s,`${t}.tags.json`)}return e.directory?N.join(e.directory,"tags.json"):N.join(this.knownTagsDir,"session-tags",`${e.id}.tags.json`)}normalizeTag(e){return e.trim().toLowerCase().substring(0,30)}async getAllKnownTags(){return(await this.readKnownTagsFile()).sort()}async getSessionTags(e){let s=this.getSessionTagsFilePath(e);try{await k.access(s);let t=await k.readFile(s,"utf8");return JSON.parse(t)}catch{return[]}}async setSessionTags(e,s){if(!Array.isArray(s))throw new Error("Tags must be an array");let t=s.map(o=>this.normalizeTag(o)).filter(o=>o.length>0).filter((o,r,i)=>i.indexOf(o)===r);if(t.length>10)throw new Error("Maximum 10 tags per session");let n=this.getSessionTagsFilePath(e);if(t.length===0)try{await k.unlink(n)}catch{}else await k.mkdir(N.dirname(n),{recursive:!0}),await k.writeFile(n,JSON.stringify(t,null,2),"utf8"),await this.updateKnownTags(t);return t}async updateKnownTags(e){let t=[...await this.readKnownTagsFile(),...e],n=[...new Set(t)];await this.writeKnownTagsFile(n)}async addSessionTags(e,s){let n=[...await this.getSessionTags(e),...s];return await this.setSessionTags(e,n)}async removeSessionTags(e,s){let t=await this.getSessionTags(e),n=s.map(r=>this.normalizeTag(r)),o=t.filter(r=>!n.includes(r));return await this.setSessionTags(e,o)}async getMultipleSessionTags(e){let s={};for(let t of e)s[t.id]=await this.getSessionTags(t);return s}};wt.exports=ve});var Et=b((In,Tt)=>{var As=je(),{isValidSessionId:Y,buildMetadata:_t}=L(),{trackEvent:V,trackMetric:It}=O(),Ds=require("adm-zip"),B=require("path"),P=require("fs"),Ae=class{constructor(e=null){this.sessionService=e||new As}async getHomepage(e,s){try{let t=await this.sessionService.getPaginatedSessions(1,20,"copilot"),n={};if(this.sessionService.sessionRepository&&this.sessionService.sessionRepository.sources)for(let r of this.sessionService.sessionRepository.sources){let i=require("os").homedir(),a=r.dir;a.startsWith(i)&&(a="~"+a.slice(i.length)),a=a.replace(/\\/g,"/"),a.endsWith("/")||(a+="/"),n[r.type]=a}let o={sessions:t.sessions,hasMore:t.hasNextPage,totalSessions:t.totalSessions,sourceHints:JSON.stringify(n)};V("HomepageViewed",{sessionCount:t.totalSessions.toString(),sourceFilter:"copilot"}),s.render("index",o)}catch(t){console.error("Error loading sessions:",t),s.status(500).send("Error loading sessions")}}async getSessionDetail(e,s){try{let t=e.params.id;if(!Y(t))return s.status(400).json({error:"Invalid session ID"});let n=await this.sessionService.sessionRepository.findById(t);if(!n)return s.status(404).json({error:"Session not found"});let o=_t(n);V("SessionViewed",{sessionId:t,source:n.source||"unknown",eventCount:(n.eventCount||o.totalEvents||0).toString(),duration:(n.duration||o.duration||0).toString(),model:n.model||o.model||"unknown",sessionStatus:n.status||o.status||"unknown"});let r=n.eventCount||o.totalEvents||0;r>0&&It("SessionEventCount",r,{sessionId:t,source:n.source||"unknown"});let i=n.duration||o.duration||0;i>0&&It("SessionDuration",i,{sessionId:t,source:n.source||"unknown"}),s.render("session-vue",{sessionId:t,events:[],metadata:o})}catch(t){console.error("Error loading session:",t),s.status(500).json({error:"Error loading session"})}}async getTimeAnalysis(e,s){try{let t=e.params.id;if(!Y(t))return s.status(400).json({error:"Invalid session ID"});let n=await this.sessionService.sessionRepository.findById(t);if(!n)return s.status(404).json({error:"Session not found"});let o=_t(n);V("TimeAnalysisViewed",{sessionId:t,turnCount:(o.totalEvents||0).toString()}),s.render("time-analyze",{sessionId:t,events:[],metadata:o})}catch(t){console.error("Error loading time analysis:",t),s.status(500).json({error:"Error loading analysis"})}}async getSessions(e,s){try{let t=e.query.page?parseInt(e.query.page):null,n=e.query.limit?parseInt(e.query.limit):null,o=e.query.source||null;if(t&&n){if(t<1||n<1||n>100)return s.status(400).json({error:"Invalid pagination parameters"});let r=await this.sessionService.getPaginatedSessions(t,n,o);V("SessionListLoaded",{page:t.toString(),limit:n.toString(),totalSessions:r.totalSessions.toString()}),s.set({"Cache-Control":"public, max-age=60"}),s.json(r)}else if(o&&n){let r=await this.sessionService.getAllSessions(o),i=r.slice(0,n);s.set({"Cache-Control":"public, max-age=60"}),s.json({sessions:i,hasMore:r.length>n,totalSessions:r.length})}else{let r=await this.sessionService.getAllSessions(o);s.set({"Cache-Control":"public, max-age=300"}),s.json(r)}}catch(t){console.error("Error loading sessions:",t),s.status(500).json({error:"Error loading sessions"})}}async loadMoreSessions(e,s){try{let t=parseInt(e.query.offset)||0,n=parseInt(e.query.limit)||20,o=e.query.source||null;if(t<0||n<1||n>50)return s.status(400).json({error:"Invalid parameters"});let r=Math.floor(t/n)+1,i=await this.sessionService.getPaginatedSessions(r,n,o);V("SessionListLoaded",{page:r.toString(),limit:n.toString(),totalSessions:i.totalSessions.toString()}),s.json({sessions:i.sessions,hasMore:i.hasNextPage,totalSessions:i.totalSessions})}catch(t){console.error("Error loading more sessions:",t),s.status(500).json({error:"Error loading more sessions"})}}async getSessionEvents(e,s){try{let t=e.params.id;if(!Y(t))return s.status(400).json({error:"Invalid session ID"});let n=e.query.limit!==void 0||e.query.offset!==void 0,o,r,i;if(n){if(o=parseInt(e.query.limit)||100,r=parseInt(e.query.offset)||0,o<1||o>1e3)return s.status(400).json({error:"Limit must be between 1 and 1000"});if(r<0)return s.status(400).json({error:"Offset must be non-negative"})}if(!await this.sessionService.sessionRepository.findById(t))return s.status(404).json({error:"Session not found"});n?i=await this.sessionService.getSessionEvents(t,{limit:o,offset:r}):i=await this.sessionService.getSessionEvents(t),s.set({"Cache-Control":"no-store",Vary:"Accept-Encoding"}),n?s.json({events:i.events,pagination:{total:i.total,limit:o,offset:r,hasMore:r+o<i.total}}):s.json(i)}catch(t){console.error("Error loading events:",t),s.status(500).json({error:"Error loading events"})}}async getTimeline(e,s){try{let t=e.params.id;if(!Y(t))return s.status(400).json({error:"Invalid session ID"});let n=await this.sessionService.getSessionById(t);if(!n)return s.status(404).json({error:"Session not found"});let o=await this.sessionService.getTimeline(t),r=require("crypto"),i=`${t}-timeline-${n.updatedAt||n.createdAt}`,a=r.createHash("md5").update(i).digest("hex");s.set({ETag:a,"Cache-Control":"private, max-age=300",Vary:"Accept-Encoding"}),s.json(o)}catch(t){console.error("Error loading timeline:",t),s.status(500).json({error:"Error loading timeline"})}}async exportSession(e,s){let t=e.params.id;if(!Y(t))return s.status(400).json({error:"Invalid session ID"});try{let n=await this.sessionService.sessionRepository.findById(t);if(!n)return s.status(404).json({error:"Session not found"});let o,r=!1;if(n.directory)try{(await P.promises.stat(n.directory)).isDirectory()&&(o=n.directory,r=!0)}catch{}if(!o&&n.filePath)try{await P.promises.access(n.filePath),o=n.filePath}catch{}if(!o){if(n.source==="copilot"){let l=this.sessionService.sessionRepository.sources.find(c=>c.type==="copilot");if(l){let c=B.join(l.dir,t);try{(await P.promises.stat(c)).isDirectory()?(o=c,r=!0):o=`${c}.jsonl`}catch{o=`${c}.jsonl`}}}else if(n.source==="claude"){let l=this.sessionService.sessionRepository.sources.find(c=>c.type==="claude");if(l){let c=await P.promises.readdir(B.join(l.dir,"projects"));for(let d of c){let u=B.join(l.dir,"projects",d,`${t}.jsonl`);try{await P.promises.access(u),o=u;break}catch{}}}}else if(n.source==="pi-mono"){let l=this.sessionService.sessionRepository.sources.find(c=>c.type==="pi-mono");if(l){let d=(await P.promises.readdir(l.dir)).find(u=>u.includes(t)&&u.endsWith(".jsonl"));d&&(o=B.join(l.dir,d))}}}if(!o)return s.status(404).json({error:"Session file not found"});try{await P.promises.access(o)}catch{return s.status(404).json({error:"Session file not accessible"})}let i=new Ds;if(r)i.addLocalFolder(o,t);else{let l=B.basename(o);i.addLocalFile(o,"",l);let c=xe(),u=new c().getSessionTagsFilePath(n);try{await P.promises.access(u),i.addLocalFile(u,"",B.basename(u))}catch{}}let a=i.toBuffer();s.setHeader("Content-Type","application/zip"),s.setHeader("Content-Disposition",`attachment; filename="session-${t}.zip"`),V("SessionExported",{sessionId:t}),s.send(a)}catch(n){console.error("Error exporting session:",n),s.status(500).json({error:"Error exporting session"})}}};Tt.exports=Ae});var se=b((Tn,Ct)=>{var De=class{constructor(){this.activeProcesses=new Set,this.isShuttingDown=!1,this._setupCleanupHandlers()}register(e,s={}){let t={process:e,metadata:s,startTime:Date.now()};return this.activeProcesses.add(t),e.on("exit",()=>{this.activeProcesses.delete(t);let n=Date.now()-t.startTime;console.log(`\u{1F504} Process exited (${s.name||"unknown"}): ${n}ms`)}),t}killAll(){console.log(`\u{1F6D1} Killing ${this.activeProcesses.size} active processes...`);for(let{process:e,metadata:s}of this.activeProcesses)try{e.killed||(e.kill("SIGTERM"),console.log(` \u2713 Killed ${s.name||e.pid}`))}catch(t){console.error(` \u2717 Failed to kill ${s.name||e.pid}:`,t.message)}this.activeProcesses.clear()}getActiveCount(){return this.activeProcesses.size}_setupCleanupHandlers(){let e=(s,t=0)=>{this.isShuttingDown||(this.isShuttingDown=!0,console.log(`
21
+ \u{1F4DB} Received ${s}, shutting down gracefully...`),this.killAll(),setTimeout(()=>{process.exit(t)},1e3))};process.on("SIGTERM",()=>e("SIGTERM",0)),process.on("SIGINT",()=>e("SIGINT",0)),process.on("uncaughtException",s=>{console.error("\u{1F4A5} Uncaught exception:",s),e("uncaughtException",1)})}};Ct.exports=new De});var xt=b((En,vt)=>{var I=require("fs").promises,bt=require("fs"),M=require("path"),Ms=require("os"),{spawn:ks}=require("child_process"),jt=q(),$s=se(),Me=class{constructor(){}_getToolConfig(e,s){let t={copilot:{name:"Copilot",cli:"copilot",args:(n,o)=>["--config-dir",n,"--yolo","-p",o],cwd:s},vscode:{name:"Copilot",cli:"copilot",args:(n,o)=>["--config-dir",n,"--yolo","-p",o],cwd:s},claude:{name:"Claude Code",cli:"claude",args:(n,o)=>["-p",o,"--dangerously-skip-permissions"],cwd:s},"pi-mono":{name:"Pi",cli:"pi",args:(n,o)=>["-p",o],cwd:s}};return t[e]||t.copilot}async generateInsight(e,s,t="copilot",n=!1){let o=M.join(s,`${e}.agent-review.md`),r=M.join(s,`${e}.agent-review.md.lock`),i=M.join(s,"events.jsonl");try{await I.access(i)}catch{try{i=M.join(s,`${e}.jsonl`),await I.access(i)}catch{let d=(await I.readdir(s)).find(u=>u.endsWith(`_${e}.jsonl`));d&&(i=M.join(s,d))}}let a=this._getToolConfig(t,s),l=a.name;if(!n)try{let c=await I.readFile(o,"utf-8"),d=await I.stat(o);return{status:"completed",report:c,generatedAt:d.mtime}}catch{}try{await I.writeFile(r,JSON.stringify({sessionId:e,startTime:new Date().toISOString(),pid:process.pid}),{flag:"wx"})}catch(c){if(c.code==="EEXIST")try{let d=JSON.parse(await I.readFile(r,"utf-8")),u=await I.stat(r),m=Date.now()-u.mtime.getTime();if(m<jt.INSIGHT_TIMEOUT_MS)return{status:"generating",report:`# Generating ${l} Insight...
22
+
23
+ Another request is currently generating this insight. Please wait.`,startedAt:u.birthtime,lastUpdate:u.mtime,ageMs:Date.now()-u.birthtime.getTime()};console.log(`\u26A0\uFE0F Removing stale lock file (${Math.floor(m/1e3)}s old)`),await I.unlink(r),await I.writeFile(r,JSON.stringify({sessionId:e,startTime:new Date().toISOString(),pid:process.pid}),{flag:"wx"})}catch(d){throw new Error("Failed to acquire lock for insight generation",{cause:d})}else throw c}try{await I.access(i)}catch(c){throw await I.unlink(r),new Error("Events file not found",{cause:c})}if(n)try{await I.unlink(o)}catch{}return await this._spawnAnalysisProcess(s,i,o,r,a),{status:"generating",report:`# Generating ${l} Insight...
24
+
25
+ Analysis in progress. Please wait.`,startedAt:new Date}}async _spawnAnalysisProcess(e,s,t,n,o){let r=M.basename(e),i=M.join(Ms.tmpdir(),`agent-review-${r}-${Date.now()}`);await I.mkdir(i,{recursive:!0});let a=this._buildPrompt(t,s),l=M.join(e,`${r}.agent-review.md.tmp`),c=o.cli,d=o.args(i,a);console.log(`\u{1F916} Starting ${o.name} analysis: ${c} ${d.slice(0,2).join(" ")}...`),console.log(`\u{1F4CB} Args count: ${d.length}, prompt length: ${a.length} chars`);let u=ks(c,d,{env:{...process.env},cwd:e,stdio:["pipe","pipe","pipe"]});if($s.register(u,{name:`insight-${r}`}),o.cli==="copilot"){let _=bt.createReadStream(s);u.stdin.on("error",y=>{y.code==="EPIPE"?_.destroy():console.error("\u274C stdin error:",y)}),_.pipe(u.stdin)}else u.stdin.end();let m=bt.createWriteStream(l);u.stdout.pipe(m);let f=[],g=0,S=64*1024;u.stderr.on("data",_=>{g<S&&(f.push(_),g+=_.length)}),u.on("close",async _=>{try{m.end();let y=Buffer.concat(f).toString("utf-8").slice(0,S);if(console.log(`\u{1F4CB} ${o.name} process exited with code ${_}`),y&&console.log(`\u{1F4CB} ${o.name} stderr:`,y.substring(0,500)),_!==0)console.error(`\u274C ${o.name} CLI failed (code ${_}):`,y),await I.writeFile(t,`# \u274C Generation Failed
26
+
27
+ Exit code: ${_}
28
+
29
+ \`\`\`
30
+ ${y||"(no error output)"}
31
+ \`\`\`
32
+ `,"utf-8");else{let j=!1;try{let v=await I.readFile(t,"utf-8");v&&v.trim().length>50&&(j=!0,console.log(`\u2705 Insight generated for session ${r} (agent wrote directly)`))}catch{}if(!j){let v=await I.readFile(l,"utf-8");v=this._cleanReport(v),await I.writeFile(t,v,"utf-8"),console.log(`\u2705 Insight generated for session ${r} (cleaned from stdout)`)}}await I.unlink(l).catch(()=>{}),await I.unlink(n).catch(()=>{}),await I.rm(i,{recursive:!0,force:!0}).catch(()=>{}),await I.rm(M.join(e,".output"),{recursive:!0,force:!0}).catch(()=>{})}catch(y){console.error("\u274C Error finalizing insight:",y),await I.unlink(n).catch(()=>{}),await I.rm(i,{recursive:!0,force:!0}).catch(()=>{})}}),u.on("error",async _=>{console.error(`\u274C Failed to spawn ${o.name}:`,_),await I.unlink(n).catch(()=>{}),await I.rm(i,{recursive:!0,force:!0}).catch(()=>{})})}_buildPrompt(e,s){let t=M.dirname(e),n=M.basename(s),o=`${t}/.output`;return`You are an expert AI agent evaluator. The current working directory is an AI coding agent session folder. It contains the raw session data from an agent run.
33
+ ${n.includes("_")?`
34
+ **IMPORTANT**: This directory may contain multiple .jsonl files. You MUST analyze ONLY the file named \`${n}\`. Do NOT read or analyze any other .jsonl files in this directory.
35
+ `:""}
36
+ **Step 1 \u2014 Discover session files.** Run \`ls -la\` to see what's available, then note which files exist:
37
+ - \`${n}\` \u2014 the main session event log (JSONL, one JSON event per line). Primary data source. May be large. **This is the ONLY events file you should analyze.**
38
+ - \`plan.md\` \u2014 the agent's plan (if it exists).
39
+ - \`workspace.yaml\` \u2014 workspace configuration (if it exists).
40
+ - Any other relevant files.
41
+
42
+ **Step 2 \u2014 Spawn 3 sub-agents for parallel analysis.** First create the working directory: \`mkdir -p ${o}\`. Then use the Task tool to launch ALL of the following sub-agents simultaneously (in a single message with multiple Task tool calls). Each sub-agent should:
43
+ - Read \`${n}\` from \`${t}\` (use Bash: \`cat\`, \`jq\`, or \`python3\` to parse) **\u2014 ONLY this file, ignore others**
44
+ - Read other session files as needed
45
+ - Write its findings to an intermediate file in \`${o}/\`
46
+ - Return a summary of its findings
47
+
48
+ Sub-agents to spawn:
49
+
50
+ 1. **Tool Usage Analyst** \u2014 Analyze tool selection quality, redundant/wasted calls, error handling patterns, tool call counts and durations. Write findings to \`${o}/tools.md\`.
51
+
52
+ 2. **Workflow Strategist** \u2014 Evaluate planning quality, sequencing logic, sub-agent decomposition, backtracking/wandering patterns. Write findings to \`${o}/workflow.md\`.
53
+
54
+ 3. **Performance Profiler** \u2014 Calculate time distribution (LLM thinking vs tool execution vs idle gaps), identify bottlenecks, assess concurrency usage. Write findings to \`${o}/performance.md\`.
55
+
56
+ **CRITICAL: You MUST wait for ALL 3 sub-agents to complete before proceeding to Step 3.** Do NOT move on until every sub-agent has returned its results. After launching them, poll or wait for their completion.
57
+
58
+ **Step 3 \u2014 Synthesize the final report.** Once all sub-agents are done:
59
+ 1. Read the intermediate files from \`${o}/\`
60
+ 2. Synthesize a unified report
61
+ 3. Write the final report to \`${e}\`
62
+ 4. Clean up by removing the entire working directory: \`rm -rf ${o}\`
63
+
64
+ The final report must be a markdown file with these sections:
65
+
66
+ ## \u{1F3AF} Effectiveness Score: X/100
67
+ One-line verdict on how well the agent fulfilled the user's intent.
68
+
69
+ ## \u{1F527} Tool Usage Analysis
70
+ - **Tool selection quality**: Did the agent pick the right tools? Any unnecessary or redundant tool calls? (e.g. repeated Read calls on the same file, Grep when Glob would suffice, excessive Bash calls)
71
+ - **Error handling**: How did the agent recover from tool errors? Did it retry blindly or adapt?
72
+ - **Efficiency**: Tool call count vs. actual value delivered. Identify wasted calls.
73
+
74
+ ## \u{1F504} Workflow & Strategy
75
+ - **Planning quality**: Did the agent have a coherent strategy, or did it wander? Look for signs of backtracking, repeated attempts, or lack of direction.
76
+ - **Sub-agent usage** (if any): Were sub-agents spawned effectively? Was the decomposition logical? Any sub-agents that were unnecessary or too narrow/broad?
77
+ - **Sequencing**: Were operations done in a logical order, or was there unnecessary back-and-forth?
78
+
79
+ ## \u26A1 Performance
80
+ - **Time distribution**: Where did the wall-clock time actually go? (LLM thinking vs. tool execution vs. idle gaps)
81
+ - **Bottlenecks**: Identify the biggest time sinks and whether they were avoidable.
82
+ - **Concurrency**: Did the agent parallelize where it could? Missed opportunities?
83
+
84
+ ## \u{1F4A1} Top 3 Improvements
85
+ Specific, actionable recommendations to make this agent workflow better. Examples:
86
+ - "Batch the 12 sequential Read calls into a single Glob + targeted Reads"
87
+ - "The agent re-read file X 4 times \u2014 cache the content across turns"
88
+ - "Sub-agent 'code-explorer' ran for 45s but its output was barely used \u2014 consider inlining"
89
+
90
+ Be brutally honest. Generic advice like "add error handling" is useless \u2014 always tie recommendations to specific evidence from the session data.
91
+
92
+ IMPORTANT CONSTRAINTS:
93
+ - Be precise and concise. Every sentence must carry data or actionable insight \u2014 no filler, no fluff.
94
+ - The entire report MUST be under 3000 characters (including markdown formatting). Cut ruthlessly if needed.`}_cleanReport(e){e=e.replace(/<thinking>[\s\S]*?<\/thinking>/g,""),e=e.replace(/^(Let me analyze|I'll analyze|Analyzing|Here's my analysis of|I need the session data).*$/gm,"");let s=/^## 🎯\s*Effectiveness Score/m,t=[...e.matchAll(new RegExp(s.source,"gm"))];if(t.length>0){let n=t[t.length-1];e=e.slice(n.index)}else{let n=e.match(/^(## [🎯🔧🔄⚡💡#])/mu);if(n)e=e.slice(n.index);else{let o=e.split(`
95
+ `),r=[],i=!1;for(let a of o){if(/^● /.test(a)){i=!0;continue}if(/^ {2}\$ /.test(a)){i=!0;continue}if(/^ {2}└ /.test(a)){i=!1;continue}if(!/^\(\+\d+ lines?\)/.test(a)&&!/^ {2}└ \d+ lines/.test(a)){if(/^● Asked user:/.test(a)){i=!0;continue}if(/^ {2}└ User responded:/.test(a)){i=!1;continue}i&&/\S/.test(a)&&!/^ {2}/.test(a)&&(i=!1),!i&&r.push(a)}}e=r.join(`
96
+ `)}}return e=e.replace(/\n{3,}/g,`
97
+
98
+ `).trim(),e}async getInsightStatus(e,s,t="copilot"){return await this._getStatusForSource(e,s)}async _getStatusForSource(e,s){let t=M.join(s,`${e}.agent-review.md`),n=M.join(s,`${e}.agent-review.md.lock`),o=M.join(s,`${e}.agent-review.md.tmp`);try{let r=await I.readFile(t,"utf-8"),i=await I.stat(t);return{status:"completed",report:r,generatedAt:i.mtime}}catch{try{await I.access(n);let i=await I.stat(n),a=Date.now()-i.birthtime.getTime(),l=null;try{l=await I.readFile(o,"utf-8")}catch{}return a>=jt.INSIGHT_TIMEOUT_MS?{status:"timeout",log:l,startedAt:i.birthtime,lastUpdate:i.mtime,ageMs:a}:{status:"generating",log:l,startedAt:i.birthtime,lastUpdate:i.mtime,ageMs:a}}catch{return{status:"not_started"}}}}async deleteInsight(e,s,t="copilot"){let n=M.join(s,`${e}.agent-review.md`);try{return await I.unlink(n),{success:!0}}catch(o){if(o.code==="ENOENT")return{success:!0,message:"Insight file not found"};throw o}}};vt.exports=Me});var Dt=b((Cn,At)=>{var Ns=xt(),{isValidSessionId:ke}=L(),{trackEvent:$e,trackMetric:Ps,trackException:Os}=O(),Ne=class{constructor(e=null,s=null){if(e?this.insightService=e:this.insightService=new Ns,s)this.sessionService=s;else{let t=je();this.sessionService=new t}}async generateInsight(e,s){try{let t=e.params.id,n=e.body?.force===!0;if(!ke(t))return s.status(400).json({error:"Invalid session ID"});let o=await this.sessionService.getSessionById(t);if(!o)return s.status(404).json({error:"Session not found"});if(!o.directory)return s.status(400).json({error:"Session directory not available"});let r=Date.now(),i=await this.insightService.generateInsight(o.id,o.directory,o.source,n),a=Date.now()-r;$e("InsightGenerated",{sessionId:t,source:o.source||"unknown",durationMs:a.toString()}),Ps("InsightGenerationTime",a,{sessionId:t,source:o.source||"unknown"}),s.json(i)}catch(t){console.error("Error generating insight:",t),Os(t,{sessionId:e.params.id,operation:"generateInsight"}),s.status(500).json({error:t.message||"Error generating insight"})}}async getInsightStatus(e,s){try{let t=e.params.id;if(!ke(t))return s.status(400).json({error:"Invalid session ID"});let n=await this.sessionService.getSessionById(t);if(!n)return s.status(404).json({error:"Session not found"});if(!n.directory)return s.status(400).json({error:"Session directory not available"});let o=await this.insightService.getInsightStatus(n.id,n.directory,n.source);o.status==="ready"&&o.report&&$e("InsightViewed",{sessionId:t}),s.json(o)}catch(t){console.error("Error getting insight status:",t),s.status(500).json({error:"Error getting insight status"})}}async deleteInsight(e,s){try{let t=e.params.id;if(!ke(t))return s.status(400).json({error:"Invalid session ID"});let n=await this.sessionService.getSessionById(t);if(!n)return s.status(404).json({error:"Session not found"});if(!n.directory)return s.status(400).json({error:"Session directory not available"});let o=await this.insightService.deleteInsight(n.id,n.directory,n.source);$e("InsightDeleted",{sessionId:t}),s.json(o)}catch(t){console.error("Error deleting insight:",t),s.status(500).json({error:"Error deleting insight"})}}};At.exports=Ne});var Nt=b((bn,$t)=>{var h=require("fs"),T=require("path"),Z=require("os"),Rs=require("multer"),{spawn:Pe}=require("child_process"),{isValidSessionId:W}=L(),{trackEvent:Mt,trackException:Oe}=O(),kt=se(),Fs=q(),Re=class{constructor(){this.SESSION_DIR=process.env.SESSION_DIR||T.join(Z.homedir(),".copilot","session-state"),this.uploadDir=process.env.UPLOAD_DIR||T.join(Z.tmpdir(),"copilot-session-uploads"),this.SESSION_DIRS={copilot:this.SESSION_DIR,claude:T.join(Z.homedir(),".claude","projects"),"pi-mono":T.join(Z.homedir(),".pi","agent","sessions")},this.upload=this.createMulterInstance()}createMulterInstance(){return Rs({dest:this.uploadDir,limits:{fileSize:Fs.MAX_UPLOAD_SIZE},fileFilter:(e,s,t)=>{let n=s.originalname.toLowerCase().endsWith(".zip"),o=s.mimetype==="application/zip"||s.mimetype==="application/x-zip-compressed";if(!n||!o)return t(new Error("Only .zip files are allowed"));t(null,!0)}})}async shareSession(e,s){try{let t=e.params.id;if(!W(t))return s.status(400).json({error:"Invalid session ID"});let n=T.join(this.SESSION_DIR,t);try{await h.promises.access(n)}catch{return s.status(404).json({error:"Session not found"})}let o=T.join(Z.tmpdir(),`session-${t}.zip`),r=Pe("zip",["-r","-q",o,t],{cwd:this.SESSION_DIR});kt.register(r,{name:`zip-${t}`}),r.on("close",i=>{if(i!==0)return s.status(500).json({error:"Failed to create zip file"});Mt("SessionShared",{sessionId:t}),s.download(o,`session-${t}.zip`,a=>{h.promises.unlink(o).catch(()=>{}),a&&console.error("Error sending zip:",a)})}),r.on("error",i=>{console.error("Error creating zip:",i),s.status(500).json({error:"Failed to create zip file"})})}catch(t){console.error("Error sharing session:",t),s.status(500).json({error:"Error sharing session"})}}async importSession(e,s){try{if(!e.file)return s.status(400).json({error:"No file uploaded"});let t=e.file.path,n=T.join(this.uploadDir,`extract-${Date.now()}`);await h.promises.mkdir(n,{recursive:!0});let o=50*1024*1024,r=200*1024*1024,i=1e3,a=5;if((await h.promises.stat(t)).size>o)return await h.promises.unlink(t),s.status(400).json({error:"Compressed file too large (max 50MB)"});let c=Pe("unzip",["-l",t]),d="";c.stdout.on("data",_=>{d+=_.toString()}),await new Promise((_,y)=>{c.on("close",j=>{j!==0?y(new Error("Failed to list zip contents")):_()}),c.on("error",y)});let u=d.split(`
99
+ `),m=0,f=0,g=0;for(let _ of u){let y=_.trim().match(/^\s*(\d+)\s+\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}\s+(.+)$/);if(y){let j=parseInt(y[1]),v=y[2];m+=j,f++;let F=(v.match(/\//g)||[]).length;g=Math.max(g,F)}}if(m>r)return await h.promises.unlink(t),s.status(400).json({error:`Uncompressed size too large (${Math.round(m/1024/1024)}MB > ${r/1024/1024}MB)`});if(f>i)return await h.promises.unlink(t),s.status(400).json({error:`Too many files in archive (${f} > ${i})`});if(g>a)return await h.promises.unlink(t),s.status(400).json({error:`Directory nesting too deep (${g} > ${a})`});let S=Pe("unzip",["-q",t,"-d",n]);kt.register(S,{name:"unzip-import"}),S.on("close",async _=>{let y;try{if(await h.promises.unlink(t),_!==0)return await h.promises.rm(n,{recursive:!0,force:!0}),s.status(500).json({error:"Failed to extract zip file"});let j=await h.promises.readdir(n);if(j.length===0)return await h.promises.rm(n,{recursive:!0,force:!0}),s.status(400).json({error:"Empty zip file"});if(y=j[0],!W(y))return await h.promises.rm(n,{recursive:!0,force:!0}),s.status(400).json({error:"Invalid session directory name in zip file"});let v=T.join(n,y),F=T.join(this.SESSION_DIR,y),oe=T.join(v,"events.jsonl");try{await h.promises.access(oe)}catch{return await h.promises.rm(n,{recursive:!0,force:!0}),s.status(400).json({error:"Invalid session structure (no events.jsonl)"})}if(h.existsSync(F))return await h.promises.rm(n,{recursive:!0,force:!0}),s.status(409).json({error:"Session already exists"});await h.promises.rename(v,F),await h.promises.rm(n,{recursive:!0,force:!0});let re=await h.promises.stat(t).catch(()=>({size:0}));Mt("SessionImported",{format:"copilot",fileSize:re.size.toString()}),s.json({success:!0,sessionId:y})}catch(j){console.error("Error importing session:",j),Oe(j,{operation:"importSession",sessionId:y||"unknown"}),await h.promises.rm(n,{recursive:!0,force:!0}).catch(()=>{}),s.status(500).json({error:"Error importing session"})}}),S.on("error",async _=>{console.error("Error extracting zip:",_),Oe(_,{operation:"importSession_unzip"}),await h.promises.unlink(t).catch(()=>{}),await h.promises.rm(n,{recursive:!0,force:!0}).catch(()=>{}),s.status(500).json({error:"Failed to extract zip file"})})}catch(t){console.error("Error processing upload:",t),Oe(t,{operation:"importSession_upload"}),e.file&&await h.promises.unlink(e.file.path).catch(()=>{}),s.status(500).json({error:"Error processing upload"})}}getUploadMiddleware(){return this.upload.single("zipFile")}async _detectFormat(e){try{let s=await h.promises.readdir(e);if(s.length===0)return null;let t=/^\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-\d{3}Z_([a-zA-Z0-9_-]+)\.jsonl$/;for(let o of s){let r=o.match(t);if(r)return{format:"pi-mono",sessionId:r[1],fileName:o,extractDir:e}}for(let o of s){let r=T.join(e,o);if((await h.promises.stat(r)).isDirectory()){let a=T.join(r,"events.jsonl");if(h.existsSync(a))return{format:"copilot",sessionId:o,directoryName:o,extractDir:e}}}let n=/^([a-zA-Z0-9_-]+)\.jsonl$/;for(let o of s){let r=T.join(e,o);if((await h.promises.stat(r)).isFile()){let a=o.match(n);if(a){let l=a[1],c=T.join(e,l),d=h.existsSync(c);return{format:"claude",sessionId:l,fileName:o,hasDirectory:d,directoryName:d?l:void 0,extractDir:e}}}}return null}catch(s){return console.error("Error detecting format:",s),null}}async _importCopilotSession(e,s){try{let{sessionId:t,directoryName:n}=e;if(!W(t))return{success:!1,error:"Invalid session ID",statusCode:400};let o=T.join(s,n),r=T.join(this.SESSION_DIRS.copilot,t),i=T.join(o,"events.jsonl");return h.existsSync(i)?h.existsSync(r)?{success:!1,error:"Session already exists",statusCode:409}:(await h.promises.rename(o,r),await h.promises.writeFile(T.join(r,".imported"),""),{success:!0,sessionId:t,format:"copilot"}):{success:!1,error:"Invalid session structure (no events.jsonl)",statusCode:400}}catch(t){return console.error("Error importing Copilot session:",t),{success:!1,error:`Error importing Copilot session: ${t.message}`,statusCode:500}}}async _importClaudeSession(e,s,t){try{let{sessionId:n,fileName:o,hasDirectory:r,directoryName:i}=e;if(!W(n))return{success:!1,error:"Invalid session ID",statusCode:400};let a=t.query.project||"imported-sessions",l=T.join(this.SESSION_DIRS.claude,a);await h.promises.mkdir(l,{recursive:!0});let c=T.join(s,o),d=T.join(l,o);if(await h.promises.rename(c,d),r&&i){let u=T.join(s,i),m=T.join(l,i);await h.promises.rename(u,m)}return{success:!0,sessionId:n,format:"claude",project:a}}catch(n){return console.error("Error importing Claude session:",n),{success:!1,error:`Error importing Claude session: ${n.message}`,statusCode:500}}}async _importPiMonoSession(e,s,t){try{let{sessionId:n,fileName:o}=e;if(!W(n))return{success:!1,error:"Invalid session ID",statusCode:400};let r=t.query.project||"imported-sessions",i=T.join(this.SESSION_DIRS["pi-mono"],r);await h.promises.mkdir(i,{recursive:!0});let a=T.join(s,o),l=T.join(i,o);return await h.promises.rename(a,l),{success:!0,sessionId:n,format:"pi-mono",project:r}}catch(n){return console.error("Error importing Pi-Mono session:",n),{success:!1,error:`Error importing Pi-Mono session: ${n.message}`,statusCode:500}}}async _importByFormat(e,s,t){if(!W(e.sessionId))return{success:!1,error:"Invalid session ID",statusCode:400};switch(e.format){case"copilot":return await this._importCopilotSession(e,s);case"claude":return await this._importClaudeSession(e,s,t);case"pi-mono":return await this._importPiMonoSession(e,s,t);default:return{success:!1,error:`Unsupported format: ${e.format}`,statusCode:400}}}async _findSessionLocation(e,s=null){try{let t=s?[s,...Object.keys(this.SESSION_DIRS).filter(n=>n!==s)]:Object.keys(this.SESSION_DIRS);for(let n of t){let o=this.SESSION_DIRS[n];if(n==="copilot"){let r=T.join(o,e);if(h.existsSync(r)){let i=T.join(r,"events.jsonl");if(h.existsSync(i))return{source:"copilot",sessionId:e,sessionPath:r,baseDir:o}}}else if(n==="claude"){if(h.existsSync(o)){let r=await h.promises.readdir(o);for(let i of r){let a=T.join(o,i);if((await h.promises.stat(a)).isDirectory()){let c=T.join(a,`${e}.jsonl`);if(h.existsSync(c))return{source:"claude",sessionId:e,sessionFile:c,projectPath:a,project:i,baseDir:o}}}}}else if(n==="pi-mono"&&h.existsSync(o)){let r=await h.promises.readdir(o);for(let i of r){let a=T.join(o,i);if((await h.promises.stat(a)).isDirectory()){let c=await h.promises.readdir(a),d=new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}-\\d{2}-\\d{2}-\\d{3}Z_${e}\\.jsonl$`);for(let u of c)if(d.test(u))return{source:"pi-mono",sessionId:e,fileName:u,sessionFile:T.join(a,u),projectPath:a,project:i,baseDir:o}}}}}return null}catch(t){return console.error("Error finding session location:",t),null}}};$t.exports=Re});var Rt=b((jn,Ot)=>{var qs=xe(),Ls=Ee(),{isValidSessionId:Pt}=L(),{trackEvent:Us}=O(),Fe=class{constructor(e=null,s=null){this.tagService=e||new qs,this.sessionRepository=s||new Ls}async getAllTags(e,s){try{let t=await this.tagService.getAllKnownTags();s.json({tags:t})}catch(t){console.error("Error getting all tags:",t),s.status(500).json({error:"Error loading tags"})}}async getSessionTags(e,s){try{let t=e.params.id;if(!Pt(t))return s.status(400).json({error:"Invalid session ID"});let n=await this.sessionRepository.findById(t);if(!n)return s.status(404).json({error:"Session not found"});let o=await this.tagService.getSessionTags(n);s.json({tags:o})}catch(t){console.error("Error getting session tags:",t),s.status(500).json({error:"Error loading session tags"})}}async setSessionTags(e,s){try{let t=e.params.id,{tags:n}=e.body;if(!Pt(t))return s.status(400).json({error:"Invalid session ID"});if(!Array.isArray(n))return s.status(400).json({error:"Tags must be an array"});if(n.length>10)return s.status(400).json({error:"Maximum 10 tags per session"});for(let i of n){if(typeof i!="string"||i.trim().length===0)return s.status(400).json({error:"Tags must be non-empty strings"});if(i.length>30)return s.status(400).json({error:"Tag length must not exceed 30 characters"})}let o=await this.sessionRepository.findById(t);if(!o)return s.status(404).json({error:"Session not found"});let r=await this.tagService.setSessionTags(o,n);Us("TagUpdated",{sessionId:t,tagCount:r.length.toString()}),s.json({tags:r})}catch(t){if(console.error("Error setting session tags:",t),t.message==="Maximum 10 tags per session")return s.status(400).json({error:t.message});if(t.message==="Session must have a directory field")return s.status(400).json({error:"Session does not support tagging"});s.status(500).json({error:"Error saving session tags"})}}};Ot.exports=Fe});var Ut=b((vn,Lt)=>{var ne=require("express"),Ft=require("path"),qt=require("compression"),zs=require("helmet"),Vs=q(),{requestTimeout:Bs,developmentCors:Ws,errorHandler:Gs,notFoundHandler:Js,telemetryLocals:Hs}=Ke(),Ks=Et(),Ys=Dt(),Zs=Nt(),Xs=Rt();function Qs(p={}){let e=ne();e.set("etag",!1);let s=new Ks(p.sessionService),t=new Ys(p.insightService,p.sessionService),n=new Zs,o=new Xs(p.tagService);return e.use((r,i,a)=>{i.setHeader("Content-Security-Policy","default-src 'self'; style-src 'self' 'unsafe-inline' https: http:; font-src 'self' https: http:; script-src 'self' 'unsafe-inline' 'unsafe-eval' https: http:; img-src 'self' data: https: http:; connect-src 'self' https: http:"),a()}),e.use(zs({contentSecurityPolicy:!1,hsts:!1,referrerPolicy:!1,crossOriginEmbedderPolicy:!1,crossOriginOpenerPolicy:!1,crossOriginResourcePolicy:!1})),e.use(qt({level:1,threshold:1024,filter:(r,i)=>r.path.includes("/events")&&i.getHeader("Content-Type")?.includes("application/json")?!1:qt.filter(r,i)})),e.use(ne.json({limit:"1mb"})),e.use(ne.urlencoded({extended:!0})),e.use(Bs),e.use(Hs),Vs.NODE_ENV==="development"&&e.use(Ws),e.use("/public",ne.static(Ft.join(__dirname,"../public"))),e.set("view engine","ejs"),e.set("views",Ft.join(__dirname,"../views")),e.get("/",s.getHomepage.bind(s)),e.get("/session/:id",s.getSessionDetail.bind(s)),e.get("/session/:id/time-analyze",s.getTimeAnalysis.bind(s)),e.get("/session/:id/export",s.exportSession.bind(s)),e.get("/api/sessions/load-more",s.loadMoreSessions.bind(s)),e.get("/api/sessions",s.getSessions.bind(s)),e.get("/api/sessions/:id/events",s.getSessionEvents.bind(s)),e.get("/api/sessions/:id/timeline",s.getTimeline.bind(s)),e.get("/api/tags",o.getAllTags.bind(o)),e.get("/api/sessions/:id/tags",o.getSessionTags.bind(o)),e.put("/api/sessions/:id/tags",o.setSessionTags.bind(o)),e.get("/session/:id/share",n.shareSession.bind(n)),e.post("/session/import",(r,i,a)=>n.getUploadMiddleware()(r,i,a),n.importSession.bind(n)),e.post("/session/:id/insight",t.generateInsight.bind(t)),e.get("/session/:id/insight",t.getInsightStatus.bind(t)),e.delete("/session/:id/insight",t.deleteInsight.bind(t)),e.use(Js),e.use(Gs),e}Lt.exports=Qs});O();var en=Ut(),qe=q(),tn=se(),zt=en();module.exports=zt;if(require.main===module){let p=zt.listen(qe.PORT,()=>{console.log(`\u{1F680} Copilot Session Viewer running at http://localhost:${qe.PORT}`),console.log(`\u{1F527} Environment: ${qe.NODE_ENV}`),console.log(`\u26A1 Active processes: ${tn.getActiveCount()}`)});process.on("SIGTERM",()=>{console.log("\u{1F4DB} SIGTERM received, closing server..."),p.close(()=>{console.log("\u2705 Server closed")})})}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@qiaolei81/copilot-session-viewer",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Web UI for viewing GitHub Copilot CLI session logs",
5
5
  "author": "Lei Qiao <qiaolei81@gmail.com>",
6
6
  "license": "MIT",
7
- "main": "server.js",
7
+ "main": "dist/server.min.js",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/qiaolei81/copilot-session-viewer.git"
@@ -87,25 +87,13 @@
87
87
  },
88
88
  "files": [
89
89
  "bin/",
90
- "server.js",
91
- "lib/",
92
- "src/app.js",
93
- "src/config/",
94
- "src/controllers/",
95
- "src/middleware/",
96
- "src/models/",
97
- "src/routes/",
98
- "src/schemas/",
99
- "src/services/",
100
- "src/telemetry.js",
101
- "src/utils/",
102
- "!src/**/__tests__/",
103
- "!src/**/*.test.js",
90
+ "dist/server.min.js",
104
91
  "views/",
105
92
  "public/css/",
106
93
  "public/js/*.min.js",
107
94
  "public/img/",
108
95
  "LICENSE",
109
- "README.md"
96
+ "README.md",
97
+ "public/vendor/"
110
98
  ]
111
99
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Minified by jsDelivr using Terser v5.39.0.
3
+ * Original file: /npm/marked@17.0.4/lib/marked.umd.js
4
+ *
5
+ * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
6
+ */
7
+ !function(e,t){"object"==typeof exports&&typeof module<"u"?module.exports=t():"function"==typeof define&&define.amd?define("marked",t):e.marked=t()}(typeof globalThis<"u"?globalThis:typeof self<"u"?self:this,(function(){var e,t={},n=t,r={exports:t},s=Object.defineProperty,l=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o={};function c(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}((e,t)=>{for(var n in t)s(e,n,{get:t[n],enumerable:!0})})(o,{Hooks:()=>Re,Lexer:()=>me,Marked:()=>Te,Parser:()=>Se,Renderer:()=>ye,TextRenderer:()=>$e,Tokenizer:()=>we,defaults:()=>h,getDefaults:()=>c,lexer:()=>Ee,marked:()=>Ae,options:()=>_e,parse:()=>Ce,parseInline:()=>Be,parser:()=>qe,setOptions:()=>Pe,use:()=>Ie,walkTokens:()=>Le}),r.exports=(e=o,((e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of i(t))!a.call(e,o)&&o!==n&&s(e,o,{get:()=>t[o],enumerable:!(r=l(t,o))||r.enumerable});return e})(s({},"__esModule",{value:!0}),e));var h={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function p(e){h=e}var u={exec:()=>null};function g(e,t=""){let n="string"==typeof e?e:e.source,r={replace:(e,t)=>{let s="string"==typeof t?t:t.source;return s=s.replace(d.caret,"$1"),n=n.replace(e,s),r},getRegex:()=>new RegExp(n,t)};return r}var k=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),d={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}>`)},f=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,x=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,b=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,w=g(b).replace(/bull/g,x).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),m=g(b).replace(/bull/g,x).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),y=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,$=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,S=g(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",$).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),R=g(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,x).getRegex(),T="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",z=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,A=g("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",z).replace("tag",T).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),_=g(y).replace("hr",f).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",T).getRegex(),P={blockquote:g(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",_).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:S,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:f,html:A,lheading:w,list:R,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:_,table:u,text:/^[^\n]+/},I=g("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",f).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",T).getRegex(),L={...P,lheading:m,table:I,paragraph:g(y).replace("hr",f).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",I).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",T).getRegex()},B={...P,html:g("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",z).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:u,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:g(y).replace("hr",f).replace("heading"," *#{1,6} *[^\n]").replace("lheading",w).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},C=/^( {2,}|\\)\n(?!\s*$)/,q=/[\p{P}\p{S}]/u,E=/[\s\p{P}\p{S}]/u,v=/[^\s\p{P}\p{S}]/u,Z=g(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,E).getRegex(),D=/(?!~)[\p{P}\p{S}]/u,M=/(?![*_])[\p{P}\p{S}]/u,O=g(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",k?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),j=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Q=g(j,"u").replace(/punct/g,q).getRegex(),H=g(j,"u").replace(/punct/g,D).getRegex(),N="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",G=g(N,"gu").replace(/notPunctSpace/g,v).replace(/punctSpace/g,E).replace(/punct/g,q).getRegex(),X=g(N,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,D).getRegex(),W=g("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,v).replace(/punctSpace/g,E).replace(/punct/g,q).getRegex(),F=g(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,M).getRegex(),U=g("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|[*_])/u).replace(/punctSpace/g,/(?![*_])[\s\p{P}\p{S}]/u).replace(/punct/g,M).getRegex(),J=g(/\\(punct)/,"gu").replace(/punct/g,q).getRegex(),K=g(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),V=g(z).replace("(?:--\x3e|$)","--\x3e").getRegex(),Y=g("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",V).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ee=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,te=g(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ee).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ne=g(/^!?\[(label)\]\[(ref)\]/).replace("label",ee).replace("ref",$).getRegex(),re=g(/^!?\[(ref)\](?:\[\])?/).replace("ref",$).getRegex(),se=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,le={_backpedal:u,anyPunctuation:J,autolink:K,blockSkip:O,br:C,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:u,delLDelim:u,delRDelim:u,emStrongLDelim:Q,emStrongRDelimAst:G,emStrongRDelimUnd:W,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:te,nolink:re,punctuation:Z,reflink:ne,reflinkSearch:g("reflink|nolink(?!\\()","g").replace("reflink",ne).replace("nolink",re).getRegex(),tag:Y,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:u},ie={...le,link:g(/^!?\[(label)\]\((.*?)\)/).replace("label",ee).getRegex(),reflink:g(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ee).getRegex()},ae={...le,emStrongRDelimAst:X,emStrongLDelim:H,delLDelim:F,delRDelim:U,url:g(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",se).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:g(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",se).getRegex()},oe={...ae,br:g(C).replace("{2,}","*").getRegex(),text:g(ae.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ce={normal:P,gfm:L,pedantic:B},he={normal:le,gfm:ae,breaks:oe,pedantic:ie},pe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ue=e=>pe[e];function ge(e,t){if(t){if(d.escapeTest.test(e))return e.replace(d.escapeReplace,ue)}else if(d.escapeTestNoEncode.test(e))return e.replace(d.escapeReplaceNoEncode,ue);return e}function ke(e){try{e=encodeURI(e).replace(d.percentDecode,"%")}catch{return null}return e}function de(e,t){let n=e.replace(d.findPipe,((e,t,n)=>{let r=!1,s=t;for(;--s>=0&&"\\"===n[s];)r=!r;return r?"|":" |"})).split(d.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(d.slashPipe,"|");return n}function fe(e,t,n){let r=e.length;if(0===r)return"";let s=0;for(;s<r;){let l=e.charAt(r-s-1);if(l!==t||n){if(l===t||!n)break;s++}else s++}return e.slice(0,r-s)}function xe(e,t=0){let n=t,r="";for(let t of e)if("\t"===t){let e=4-n%4;r+=" ".repeat(e),n+=e}else r+=t,n++;return r}function be(e,t,n,r,s){let l=t.href,i=t.title||null,a=e[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;let o={type:"!"===e[0].charAt(0)?"image":"link",raw:n,href:l,title:i,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,o}var we=class{options;rules;lexer;constructor(e){this.options=e||h}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:fe(e,"\n")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(null===r)return t;let s=r[1];return t.split("\n").map((e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[r]=t;return r.length>=s.length?e.slice(s.length):e})).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=fe(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:fe(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=fe(t[0],"\n").split("\n"),n="",r="",s=[];for(;e.length>0;){let t,l=!1,i=[];for(t=0;t<e.length;t++)if(this.rules.other.blockquoteStart.test(e[t]))i.push(e[t]),l=!0;else{if(l)break;i.push(e[t])}e=e.slice(t);let a=i.join("\n"),o=a.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${a}`:a,r=r?`${r}\n${o}`:o;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(o,s,!0),this.lexer.state.top=c,0===e.length)break;let h=s.at(-1);if("code"===h?.type)break;if("blockquote"===h?.type){let t=h,l=t.raw+"\n"+e.join("\n"),i=this.blockquote(l);s[s.length-1]=i,n=n.substring(0,n.length-t.raw.length)+i.raw,r=r.substring(0,r.length-t.text.length)+i.text;break}if("list"!==h?.type);else{let t=h,l=t.raw+"\n"+e.join("\n"),i=this.list(l);s[s.length-1]=i,n=n.substring(0,n.length-h.raw.length)+i.raw,r=r.substring(0,r.length-t.raw.length)+i.raw,e=l.substring(s.at(-1).raw.length).split("\n")}}return{type:"blockquote",raw:n,tokens:s,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,s={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let l=this.rules.other.listItemRegex(n),i=!1;for(;e;){let n=!1,r="",a="";if(!(t=l.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let o=xe(t[2].split("\n",1)[0],t[1].length),c=e.split("\n",1)[0],h=!o.trim(),p=0;if(this.options.pedantic?(p=2,a=o.trimStart()):h?p=t[1].length+1:(p=o.search(this.rules.other.nonSpaceChar),p=p>4?1:p,a=o.slice(p),p+=t[1].length),h&&this.rules.other.blankLine.test(c)&&(r+=c+"\n",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(p),n=this.rules.other.hrRegex(p),s=this.rules.other.fencesBeginRegex(p),l=this.rules.other.headingBeginRegex(p),i=this.rules.other.htmlBeginRegex(p),u=this.rules.other.blockquoteBeginRegex(p);for(;e;){let g,k=e.split("\n",1)[0];if(c=k,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),g=c):g=c.replace(this.rules.other.tabCharGlobal," "),s.test(c)||l.test(c)||i.test(c)||u.test(c)||t.test(c)||n.test(c))break;if(g.search(this.rules.other.nonSpaceChar)>=p||!c.trim())a+="\n"+g.slice(p);else{if(h||o.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||s.test(o)||l.test(o)||n.test(o))break;a+="\n"+c}h=!c.trim(),r+=k+"\n",e=e.substring(k.length+1),o=g.slice(p)}}s.loose||(i?s.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(i=!0)),s.items.push({type:"list_item",raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(a),loose:!1,text:a,tokens:[]}),s.raw+=r}let a=s.items.at(-1);if(!a)return;a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd(),s.raw=s.raw.trimEnd();for(let e of s.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,""),"text"===e.tokens[0]?.type||"paragraph"===e.tokens[0]?.type){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:"checkbox",raw:t[0]+" ",checked:"[ ]"!==t[0]};e.checked=n.checked,s.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:"paragraph",raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!s.loose){let t=e.tokens.filter((e=>"space"===e.type)),n=t.length>0&&t.some((e=>this.rules.other.anyLine.test(e.raw)));s.loose=n}}if(s.loose)for(let e of s.items){e.loose=!0;for(let t of e.tokens)"text"===t.type&&(t.type="paragraph")}return s}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=de(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],l={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?l.align.push("right"):this.rules.other.tableAlignCenter.test(e)?l.align.push("center"):this.rules.other.tableAlignLeft.test(e)?l.align.push("left"):l.align.push(null);for(let e=0;e<n.length;e++)l.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:l.align[e]});for(let e of s)l.rows.push(de(e,l.header.length).map(((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:l.align[t]}))));return l}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=fe(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let r=0;r<e.length;r++)if("\\"===e[r])r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],r="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),be(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return be(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!r[1]&&!r[2]||!n||this.rules.inline.punctuation.exec(n))){let n,s,l=[...r[0]].length-1,i=l,a=0,o="*"===r[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(o.lastIndex=0,t=t.slice(-1*e.length+l);null!=(r=o.exec(t));){if(n=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!n)continue;if(s=[...n].length,r[3]||r[4]){i+=s;continue}if((r[5]||r[6])&&l%3&&!((l+s)%3)){a+=s;continue}if(i-=s,i>0)continue;s=Math.min(s,s+i+a);let t=[...r[0]][0].length,o=e.slice(0,l+r.index+t+s);if(Math.min(l,s)%2){let e=o.slice(1,-1);return{type:"em",raw:o,text:e,tokens:this.lexer.inlineTokens(e)}}let c=o.slice(2,-2);return{type:"strong",raw:o,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n,s,l=[...r[0]].length-1,i=l,a=this.rules.inline.delRDelim;for(a.lastIndex=0,t=t.slice(-1*e.length+l);null!=(r=a.exec(t));){if(n=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!n||(s=[...n].length,s!==l))continue;if(r[3]||r[4]){i+=s;continue}if(i-=s,i>0)continue;s=Math.min(s,s+i);let t=[...r[0]][0].length,a=e.slice(0,l+r.index+t+s),o=a.slice(l,-l);return{type:"del",raw:a,text:o,tokens:this.lexer.inlineTokens(o)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=t[0],n="mailto:"+e;else{let r;do{r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(r!==t[0]);e=t[0],n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},me=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||h,this.options.tokenizer=this.options.tokenizer||new we,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:d,block:ce.normal,inline:he.normal};this.options.pedantic?(t.block=ce.pedantic,t.inline=he.pedantic):this.options.gfm&&(t.block=ce.gfm,this.options.breaks?t.inline=he.breaks:t.inline=he.gfm),this.tokenizer.rules=t}static get rules(){return{block:ce,inline:he}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(d.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(d.tabCharGlobal," ").replace(d.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some((n=>!!(r=n.call({lexer:this},e,t))&&(e=e.substring(r.raw.length),t.push(r),!0))))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);1===r.raw.length&&void 0!==n?n.raw+="\n":t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let s=e;if(this.options.extensions?.startBlock){let t,n=1/0,r=e.slice(1);this.options.extensions.startBlock.forEach((e=>{t=e.call({lexer:this},r),"number"==typeof t&&t>=0&&(n=Math.min(n,t))})),n<1/0&&n>=0&&(s=e.substring(0,n+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){let l=t.at(-1);n&&"paragraph"===l?.type?(l.raw+=(l.raw.endsWith("\n")?"":"\n")+r.raw,l.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):t.push(r),n=s.length!==e.length,e=e.substring(r.raw.length)}else if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r)}else if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,r=e,s=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(s=this.tokenizer.rules.inline.reflinkSearch.exec(r));)e.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(s=this.tokenizer.rules.inline.anyPunctuation.exec(r));)r=r.slice(0,s.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(s=this.tokenizer.rules.inline.blockSkip.exec(r));)n=s[2]?s[2].length:0,r=r.slice(0,s.index+n)+"["+"a".repeat(s[0].length-n-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let l=!1,i="";for(;e;){let n;if(l||(i=""),l=!1,this.options.extensions?.inline?.some((r=>!!(n=r.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0))))continue;if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length);let r=t.at(-1);"text"===n.type&&"text"===r?.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,r,i)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e,r,i)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),t.push(n);continue}let s=e;if(this.options.extensions?.startInline){let t,n=1/0,r=e.slice(1);this.options.extensions.startInline.forEach((e=>{t=e.call({lexer:this},r),"number"==typeof t&&t>=0&&(n=Math.min(n,t))})),n<1/0&&n>=0&&(s=e.substring(0,n+1))}if(n=this.tokenizer.inlineText(s)){e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(i=n.raw.slice(-1)),l=!0;let r=t.at(-1);"text"===r?.type?(r.raw+=n.raw,r.text+=n.text):t.push(n)}else if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return t}},ye=class{options;parser;constructor(e){this.options=e||h}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(d.notSpaceStart)?.[0],s=e.replace(d.endingNewline,"")+"\n";return r?'<pre><code class="language-'+ge(r)+'">'+(n?s:ge(s,!0))+"</code></pre>\n":"<pre><code>"+(n?s:ge(s,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){let t=e.ordered,n=e.start,r="";for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let s=t?"ol":"ul";return"<"+s+(t&&1!==n?' start="'+n+'"':"")+">\n"+r+"</"+s+">\n"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let t="",n="";for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r="";for(let t=0;t<e.rows.length;t++){let s=e.rows[t];n="";for(let e=0;e<s.length;e++)n+=this.tablecell(s[e]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+r+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${ge(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),s=ke(e);if(null===s)return r;let l='<a href="'+(e=s)+'"';return t&&(l+=' title="'+ge(t)+'"'),l+=">"+r+"</a>",l}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=ke(e);if(null===s)return ge(n);let l=`<img src="${e=s}" alt="${ge(n)}"`;return t&&(l+=` title="${ge(t)}"`),l+=">",l}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:ge(e.text)}},$e=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Se=class e{options;renderer;textRenderer;constructor(e){this.options=e||h,this.options.renderer=this.options.renderer||new ye,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new $e}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==n||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){t+=n||"";continue}}let s=r;switch(s.type){case"space":t+=this.renderer.space(s);break;case"hr":t+=this.renderer.hr(s);break;case"heading":t+=this.renderer.heading(s);break;case"code":t+=this.renderer.code(s);break;case"table":t+=this.renderer.table(s);break;case"blockquote":t+=this.renderer.blockquote(s);break;case"list":t+=this.renderer.list(s);break;case"checkbox":t+=this.renderer.checkbox(s);break;case"html":t+=this.renderer.html(s);break;case"def":t+=this.renderer.def(s);break;case"paragraph":t+=this.renderer.paragraph(s);break;case"text":t+=this.renderer.text(s);break;default:{let e='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return t}parseInline(e,t=this.renderer){let n="";for(let r=0;r<e.length;r++){let s=e[r];if(this.options.extensions?.renderers?.[s.type]){let e=this.options.extensions.renderers[s.type].call({parser:this},s);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){n+=e||"";continue}}let l=s;switch(l.type){case"escape":case"text":n+=t.text(l);break;case"html":n+=t.html(l);break;case"link":n+=t.link(l);break;case"image":n+=t.image(l);break;case"checkbox":n+=t.checkbox(l);break;case"strong":n+=t.strong(l);break;case"em":n+=t.em(l);break;case"codespan":n+=t.codespan(l);break;case"br":n+=t.br(l);break;case"del":n+=t.del(l);break;default:{let e='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}},Re=class{options;block;constructor(e){this.options=e||h}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?me.lex:me.lexInline}provideParser(){return this.block?Se.parse:Se.parseInline}},Te=class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Se;Renderer=ye;TextRenderer=$e;Lexer=me;Tokenizer=we;Hooks=Re;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach((r=>{let s=e[r].flat(1/0);n=n.concat(this.walkTokens(s,t))})):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let r=e.renderer.apply(this,t);return!1===r&&(r=n.apply(this,t)),r}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),n.extensions=t),e.renderer){let t=this.defaults.renderer||new ye(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let r=n,s=e.renderer[r],l=t[r];t[r]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=l.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new we(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let r=n,s=e.tokenizer[r],l=t[r];t[r]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=l.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Re;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let r=n,s=e.hooks[r],l=t[r];Re.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&Re.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await s.call(t,e);return l.call(t,n)})();let r=s.call(t,e);return l.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await s.apply(t,e);return!1===n&&(n=await l.apply(t,e)),n})();let n=s.apply(t,e);return!1===n&&(n=l.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}})),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return me.lex(e,t??this.defaults)}parser(e,t){return Se.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},s={...this.defaults,...r},l=this.onError(!!s.silent,!!s.async);if(!0===this.defaults.async&&!1===r.async)return l(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return l(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let n=s.hooks?await s.hooks.preprocess(t):t,r=await(s.hooks?await s.hooks.provideLexer():e?me.lex:me.lexInline)(n,s),l=s.hooks?await s.hooks.processAllTokens(r):r;s.walkTokens&&await Promise.all(this.walkTokens(l,s.walkTokens));let i=await(s.hooks?await s.hooks.provideParser():e?Se.parse:Se.parseInline)(l,s);return s.hooks?await s.hooks.postprocess(i):i})().catch(l);try{s.hooks&&(t=s.hooks.preprocess(t));let n=(s.hooks?s.hooks.provideLexer():e?me.lex:me.lexInline)(t,s);s.hooks&&(n=s.hooks.processAllTokens(n)),s.walkTokens&&this.walkTokens(n,s.walkTokens);let r=(s.hooks?s.hooks.provideParser():e?Se.parse:Se.parseInline)(n,s);return s.hooks&&(r=s.hooks.postprocess(r)),r}catch(e){return l(e)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+ge(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},ze=new Te;function Ae(e,t){return ze.parse(e,t)}Ae.options=Ae.setOptions=function(e){return ze.setOptions(e),Ae.defaults=ze.defaults,p(Ae.defaults),Ae},Ae.getDefaults=c,Ae.defaults=h,Ae.use=function(...e){return ze.use(...e),Ae.defaults=ze.defaults,p(Ae.defaults),Ae},Ae.walkTokens=function(e,t){return ze.walkTokens(e,t)},Ae.parseInline=ze.parseInline,Ae.Parser=Se,Ae.parser=Se.parse,Ae.Renderer=ye,Ae.TextRenderer=$e,Ae.Lexer=me,Ae.lexer=me.lex,Ae.Tokenizer=we,Ae.Hooks=Re,Ae.parse=Ae;var _e=Ae.options,Pe=Ae.setOptions,Ie=Ae.use,Le=Ae.walkTokens,Be=Ae.parseInline,Ce=Ae,qe=Se.parse,Ee=me.lex;return n!=t&&(r.exports=t),r.exports}));
8
+ //# sourceMappingURL=/sm/b3c9371f48ff8cf2146ec585004376991527b30651871ab37188d3eb60f32cb5.map
@@ -0,0 +1,3 @@
1
+ /*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */
2
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DOMPurify=t()}(this,(function(){"use strict";const{entries:e,setPrototypeOf:t,isFrozen:n,getPrototypeOf:o,getOwnPropertyDescriptor:r}=Object;let{freeze:i,seal:a,create:l}=Object,{apply:c,construct:s}="undefined"!=typeof Reflect&&Reflect;i||(i=function(e){return e}),a||(a=function(e){return e}),c||(c=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];return e.apply(t,o)}),s||(s=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return new e(...n)});const u=D(Array.prototype.forEach),m=D(Array.prototype.lastIndexOf),p=D(Array.prototype.pop),f=D(Array.prototype.push),d=D(Array.prototype.splice),h=D(String.prototype.toLowerCase),g=D(String.prototype.toString),T=D(String.prototype.match),y=D(String.prototype.replace),E=D(String.prototype.indexOf),A=D(String.prototype.trim),_=D(Object.prototype.hasOwnProperty),b=D(RegExp.prototype.test),S=(N=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return s(N,t)});var N;function D(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return c(e,t,o)}}function R(e,o){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:h;t&&t(e,null);let i=o.length;for(;i--;){let t=o[i];if("string"==typeof t){const e=r(t);e!==t&&(n(o)||(o[i]=e),t=e)}e[t]=!0}return e}function w(e){for(let t=0;t<e.length;t++){_(e,t)||(e[t]=null)}return e}function C(t){const n=l(null);for(const[o,r]of e(t)){_(t,o)&&(Array.isArray(r)?n[o]=w(r):r&&"object"==typeof r&&r.constructor===Object?n[o]=C(r):n[o]=r)}return n}function O(e,t){for(;null!==e;){const n=r(e,t);if(n){if(n.get)return D(n.get);if("function"==typeof n.value)return D(n.value)}e=o(e)}return function(){return null}}const v=i(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),k=i(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),x=i(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),L=i(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),I=i(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),M=i(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),U=i(["#text"]),z=i(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),P=i(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),F=i(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),H=i(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),B=a(/\{\{[\w\W]*|[\w\W]*\}\}/gm),G=a(/<%[\w\W]*|[\w\W]*%>/gm),W=a(/\$\{[\w\W]*/gm),Y=a(/^data-[\-\w.\u00B7-\uFFFF]+$/),j=a(/^aria-[\-\w]+$/),X=a(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),q=a(/^(?:\w+script|data):/i),$=a(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),K=a(/^html$/i),V=a(/^[a-z][.\w]*(-[.\w]+)+$/i);var Z=Object.freeze({__proto__:null,ARIA_ATTR:j,ATTR_WHITESPACE:$,CUSTOM_ELEMENT:V,DATA_ATTR:Y,DOCTYPE_NAME:K,ERB_EXPR:G,IS_ALLOWED_URI:X,IS_SCRIPT_OR_DATA:q,MUSTACHE_EXPR:B,TMPLIT_EXPR:W});const J=1,Q=3,ee=7,te=8,ne=9,oe=function(){return"undefined"==typeof window?null:window};var re=function t(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:oe();const o=e=>t(e);if(o.version="3.3.3",o.removed=[],!n||!n.document||n.document.nodeType!==ne||!n.Element)return o.isSupported=!1,o;let{document:r}=n;const a=r,c=a.currentScript,{DocumentFragment:s,HTMLTemplateElement:N,Node:D,Element:w,NodeFilter:B,NamedNodeMap:G=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:W,DOMParser:Y,trustedTypes:j}=n,q=w.prototype,$=O(q,"cloneNode"),V=O(q,"remove"),re=O(q,"nextSibling"),ie=O(q,"childNodes"),ae=O(q,"parentNode");if("function"==typeof N){const e=r.createElement("template");e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}let le,ce="";const{implementation:se,createNodeIterator:ue,createDocumentFragment:me,getElementsByTagName:pe}=r,{importNode:fe}=a;let de={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};o.isSupported="function"==typeof e&&"function"==typeof ae&&se&&void 0!==se.createHTMLDocument;const{MUSTACHE_EXPR:he,ERB_EXPR:ge,TMPLIT_EXPR:Te,DATA_ATTR:ye,ARIA_ATTR:Ee,IS_SCRIPT_OR_DATA:Ae,ATTR_WHITESPACE:_e,CUSTOM_ELEMENT:be}=Z;let{IS_ALLOWED_URI:Se}=Z,Ne=null;const De=R({},[...v,...k,...x,...I,...U]);let Re=null;const we=R({},[...z,...P,...F,...H]);let Ce=Object.seal(l(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Oe=null,ve=null;const ke=Object.seal(l(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let xe=!0,Le=!0,Ie=!1,Me=!0,Ue=!1,ze=!0,Pe=!1,Fe=!1,He=!1,Be=!1,Ge=!1,We=!1,Ye=!0,je=!1,Xe=!0,qe=!1,$e={},Ke=null;const Ve=R({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ze=null;const Je=R({},["audio","video","img","source","image","track"]);let Qe=null;const et=R({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),tt="http://www.w3.org/1998/Math/MathML",nt="http://www.w3.org/2000/svg",ot="http://www.w3.org/1999/xhtml";let rt=ot,it=!1,at=null;const lt=R({},[tt,nt,ot],g);let ct=R({},["mi","mo","mn","ms","mtext"]),st=R({},["annotation-xml"]);const ut=R({},["title","style","font","a","script"]);let mt=null;const pt=["application/xhtml+xml","text/html"];let ft=null,dt=null;const ht=r.createElement("form"),gt=function(e){return e instanceof RegExp||e instanceof Function},Tt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!dt||dt!==e){if(e&&"object"==typeof e||(e={}),e=C(e),mt=-1===pt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,ft="application/xhtml+xml"===mt?g:h,Ne=_(e,"ALLOWED_TAGS")?R({},e.ALLOWED_TAGS,ft):De,Re=_(e,"ALLOWED_ATTR")?R({},e.ALLOWED_ATTR,ft):we,at=_(e,"ALLOWED_NAMESPACES")?R({},e.ALLOWED_NAMESPACES,g):lt,Qe=_(e,"ADD_URI_SAFE_ATTR")?R(C(et),e.ADD_URI_SAFE_ATTR,ft):et,Ze=_(e,"ADD_DATA_URI_TAGS")?R(C(Je),e.ADD_DATA_URI_TAGS,ft):Je,Ke=_(e,"FORBID_CONTENTS")?R({},e.FORBID_CONTENTS,ft):Ve,Oe=_(e,"FORBID_TAGS")?R({},e.FORBID_TAGS,ft):C({}),ve=_(e,"FORBID_ATTR")?R({},e.FORBID_ATTR,ft):C({}),$e=!!_(e,"USE_PROFILES")&&e.USE_PROFILES,xe=!1!==e.ALLOW_ARIA_ATTR,Le=!1!==e.ALLOW_DATA_ATTR,Ie=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Me=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Ue=e.SAFE_FOR_TEMPLATES||!1,ze=!1!==e.SAFE_FOR_XML,Pe=e.WHOLE_DOCUMENT||!1,Be=e.RETURN_DOM||!1,Ge=e.RETURN_DOM_FRAGMENT||!1,We=e.RETURN_TRUSTED_TYPE||!1,He=e.FORCE_BODY||!1,Ye=!1!==e.SANITIZE_DOM,je=e.SANITIZE_NAMED_PROPS||!1,Xe=!1!==e.KEEP_CONTENT,qe=e.IN_PLACE||!1,Se=e.ALLOWED_URI_REGEXP||X,rt=e.NAMESPACE||ot,ct=e.MATHML_TEXT_INTEGRATION_POINTS||ct,st=e.HTML_INTEGRATION_POINTS||st,Ce=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&gt(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Ce.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&gt(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Ce.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Ce.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ue&&(Le=!1),Ge&&(Be=!0),$e&&(Ne=R({},U),Re=l(null),!0===$e.html&&(R(Ne,v),R(Re,z)),!0===$e.svg&&(R(Ne,k),R(Re,P),R(Re,H)),!0===$e.svgFilters&&(R(Ne,x),R(Re,P),R(Re,H)),!0===$e.mathMl&&(R(Ne,I),R(Re,F),R(Re,H))),_(e,"ADD_TAGS")||(ke.tagCheck=null),_(e,"ADD_ATTR")||(ke.attributeCheck=null),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?ke.tagCheck=e.ADD_TAGS:(Ne===De&&(Ne=C(Ne)),R(Ne,e.ADD_TAGS,ft))),e.ADD_ATTR&&("function"==typeof e.ADD_ATTR?ke.attributeCheck=e.ADD_ATTR:(Re===we&&(Re=C(Re)),R(Re,e.ADD_ATTR,ft))),e.ADD_URI_SAFE_ATTR&&R(Qe,e.ADD_URI_SAFE_ATTR,ft),e.FORBID_CONTENTS&&(Ke===Ve&&(Ke=C(Ke)),R(Ke,e.FORBID_CONTENTS,ft)),e.ADD_FORBID_CONTENTS&&(Ke===Ve&&(Ke=C(Ke)),R(Ke,e.ADD_FORBID_CONTENTS,ft)),Xe&&(Ne["#text"]=!0),Pe&&R(Ne,["html","head","body"]),Ne.table&&(R(Ne,["tbody"]),delete Oe.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw S('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw S('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');le=e.TRUSTED_TYPES_POLICY,ce=le.createHTML("")}else void 0===le&&(le=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(j,c)),null!==le&&"string"==typeof ce&&(ce=le.createHTML(""));i&&i(e),dt=e}},yt=R({},[...k,...x,...L]),Et=R({},[...I,...M]),At=function(e){f(o.removed,{element:e});try{ae(e).removeChild(e)}catch(t){V(e)}},_t=function(e,t){try{f(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){f(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(Be||Ge)try{At(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},bt=function(e){let t=null,n=null;if(He)e="<remove></remove>"+e;else{const t=T(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===mt&&rt===ot&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const o=le?le.createHTML(e):e;if(rt===ot)try{t=(new Y).parseFromString(o,mt)}catch(e){}if(!t||!t.documentElement){t=se.createDocument(rt,"template",null);try{t.documentElement.innerHTML=it?ce:o}catch(e){}}const i=t.body||t.documentElement;return e&&n&&i.insertBefore(r.createTextNode(n),i.childNodes[0]||null),rt===ot?pe.call(t,Pe?"html":"body")[0]:Pe?t.documentElement:i},St=function(e){return ue.call(e.ownerDocument||e,e,B.SHOW_ELEMENT|B.SHOW_COMMENT|B.SHOW_TEXT|B.SHOW_PROCESSING_INSTRUCTION|B.SHOW_CDATA_SECTION,null)},Nt=function(e){return e instanceof W&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof G)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},Dt=function(e){return"function"==typeof D&&e instanceof D};function Rt(e,t,n){u(e,(e=>{e.call(o,t,n,dt)}))}const wt=function(e){let t=null;if(Rt(de.beforeSanitizeElements,e,null),Nt(e))return At(e),!0;const n=ft(e.nodeName);if(Rt(de.uponSanitizeElement,e,{tagName:n,allowedTags:Ne}),ze&&e.hasChildNodes()&&!Dt(e.firstElementChild)&&b(/<[/\w!]/g,e.innerHTML)&&b(/<[/\w!]/g,e.textContent))return At(e),!0;if(e.nodeType===ee)return At(e),!0;if(ze&&e.nodeType===te&&b(/<[/\w]/g,e.data))return At(e),!0;if(!(ke.tagCheck instanceof Function&&ke.tagCheck(n))&&(!Ne[n]||Oe[n])){if(!Oe[n]&&Ot(n)){if(Ce.tagNameCheck instanceof RegExp&&b(Ce.tagNameCheck,n))return!1;if(Ce.tagNameCheck instanceof Function&&Ce.tagNameCheck(n))return!1}if(Xe&&!Ke[n]){const t=ae(e)||e.parentNode,n=ie(e)||e.childNodes;if(n&&t){for(let o=n.length-1;o>=0;--o){const r=$(n[o],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,re(e))}}}return At(e),!0}return e instanceof w&&!function(e){let t=ae(e);t&&t.tagName||(t={namespaceURI:rt,tagName:"template"});const n=h(e.tagName),o=h(t.tagName);return!!at[e.namespaceURI]&&(e.namespaceURI===nt?t.namespaceURI===ot?"svg"===n:t.namespaceURI===tt?"svg"===n&&("annotation-xml"===o||ct[o]):Boolean(yt[n]):e.namespaceURI===tt?t.namespaceURI===ot?"math"===n:t.namespaceURI===nt?"math"===n&&st[o]:Boolean(Et[n]):e.namespaceURI===ot?!(t.namespaceURI===nt&&!st[o])&&!(t.namespaceURI===tt&&!ct[o])&&!Et[n]&&(ut[n]||!yt[n]):!("application/xhtml+xml"!==mt||!at[e.namespaceURI]))}(e)?(At(e),!0):"noscript"!==n&&"noembed"!==n&&"noframes"!==n||!b(/<\/no(script|embed|frames)/i,e.innerHTML)?(Ue&&e.nodeType===Q&&(t=e.textContent,u([he,ge,Te],(e=>{t=y(t,e," ")})),e.textContent!==t&&(f(o.removed,{element:e.cloneNode()}),e.textContent=t)),Rt(de.afterSanitizeElements,e,null),!1):(At(e),!0)},Ct=function(e,t,n){if(ve[t])return!1;if(Ye&&("id"===t||"name"===t)&&(n in r||n in ht))return!1;if(Le&&!ve[t]&&b(ye,t));else if(xe&&b(Ee,t));else if(ke.attributeCheck instanceof Function&&ke.attributeCheck(t,e));else if(!Re[t]||ve[t]){if(!(Ot(e)&&(Ce.tagNameCheck instanceof RegExp&&b(Ce.tagNameCheck,e)||Ce.tagNameCheck instanceof Function&&Ce.tagNameCheck(e))&&(Ce.attributeNameCheck instanceof RegExp&&b(Ce.attributeNameCheck,t)||Ce.attributeNameCheck instanceof Function&&Ce.attributeNameCheck(t,e))||"is"===t&&Ce.allowCustomizedBuiltInElements&&(Ce.tagNameCheck instanceof RegExp&&b(Ce.tagNameCheck,n)||Ce.tagNameCheck instanceof Function&&Ce.tagNameCheck(n))))return!1}else if(Qe[t]);else if(b(Se,y(n,_e,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==E(n,"data:")||!Ze[e]){if(Ie&&!b(Ae,y(n,_e,"")));else if(n)return!1}else;return!0},Ot=function(e){return"annotation-xml"!==e&&T(e,be)},vt=function(e){Rt(de.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||Nt(e))return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Re,forceKeepAttr:void 0};let r=t.length;for(;r--;){const i=t[r],{name:a,namespaceURI:l,value:c}=i,s=ft(a),m=c;let f="value"===a?m:A(m);if(n.attrName=s,n.attrValue=f,n.keepAttr=!0,n.forceKeepAttr=void 0,Rt(de.uponSanitizeAttribute,e,n),f=n.attrValue,!je||"id"!==s&&"name"!==s||(_t(a,e),f="user-content-"+f),ze&&b(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)){_t(a,e);continue}if("attributename"===s&&T(f,"href")){_t(a,e);continue}if(n.forceKeepAttr)continue;if(!n.keepAttr){_t(a,e);continue}if(!Me&&b(/\/>/i,f)){_t(a,e);continue}Ue&&u([he,ge,Te],(e=>{f=y(f,e," ")}));const d=ft(e.nodeName);if(Ct(d,s,f)){if(le&&"object"==typeof j&&"function"==typeof j.getAttributeType)if(l);else switch(j.getAttributeType(d,s)){case"TrustedHTML":f=le.createHTML(f);break;case"TrustedScriptURL":f=le.createScriptURL(f)}if(f!==m)try{l?e.setAttributeNS(l,a,f):e.setAttribute(a,f),Nt(e)?At(e):p(o.removed)}catch(t){_t(a,e)}}else _t(a,e)}Rt(de.afterSanitizeAttributes,e,null)},kt=function e(t){let n=null;const o=St(t);for(Rt(de.beforeSanitizeShadowDOM,t,null);n=o.nextNode();)Rt(de.uponSanitizeShadowNode,n,null),wt(n),vt(n),n.content instanceof s&&e(n.content);Rt(de.afterSanitizeShadowDOM,t,null)};return o.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,r=null,i=null,l=null;if(it=!e,it&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Dt(e)){if("function"!=typeof e.toString)throw S("toString is not a function");if("string"!=typeof(e=e.toString()))throw S("dirty is not a string, aborting")}if(!o.isSupported)return e;if(Fe||Tt(t),o.removed=[],"string"==typeof e&&(qe=!1),qe){if(e.nodeName){const t=ft(e.nodeName);if(!Ne[t]||Oe[t])throw S("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof D)n=bt("\x3c!----\x3e"),r=n.ownerDocument.importNode(e,!0),r.nodeType===J&&"BODY"===r.nodeName||"HTML"===r.nodeName?n=r:n.appendChild(r);else{if(!Be&&!Ue&&!Pe&&-1===e.indexOf("<"))return le&&We?le.createHTML(e):e;if(n=bt(e),!n)return Be?null:We?ce:""}n&&He&&At(n.firstChild);const c=St(qe?e:n);for(;i=c.nextNode();)wt(i),vt(i),i.content instanceof s&&kt(i.content);if(qe)return e;if(Be){if(Ge)for(l=me.call(n.ownerDocument);n.firstChild;)l.appendChild(n.firstChild);else l=n;return(Re.shadowroot||Re.shadowrootmode)&&(l=fe.call(a,l,!0)),l}let m=Pe?n.outerHTML:n.innerHTML;return Pe&&Ne["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&b(K,n.ownerDocument.doctype.name)&&(m="<!DOCTYPE "+n.ownerDocument.doctype.name+">\n"+m),Ue&&u([he,ge,Te],(e=>{m=y(m,e," ")})),le&&We?le.createHTML(m):m},o.setConfig=function(){Tt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Fe=!0},o.clearConfig=function(){dt=null,Fe=!1},o.isValidAttribute=function(e,t,n){dt||Tt({});const o=ft(e),r=ft(t);return Ct(o,r,n)},o.addHook=function(e,t){"function"==typeof t&&f(de[e],t)},o.removeHook=function(e,t){if(void 0!==t){const n=m(de[e],t);return-1===n?void 0:d(de[e],n,1)[0]}return p(de[e])},o.removeHooks=function(e){de[e]=[]},o.removeAllHooks=function(){de={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},o}();return re}));
3
+ //# sourceMappingURL=purify.min.js.map