"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(e,o)=>{for(var r in o)__defProp(e,r,{get:o[r],enumerable:!0})},__copyProps=(o,r,n,t)=>{if(r&&"object"==typeof r||"function"==typeof r)for(let e of __getOwnPropNames(r))__hasOwnProp.call(o,e)||e===n||__defProp(o,e,{get:()=>r[e],enumerable:!(t=__getOwnPropDesc(r,e))||t.enumerable});return o},__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),changelog_exports={},CORS_HEADERS=(__export(changelog_exports,{handler:()=>handler,method:()=>method,path:()=>path}),module.exports=__toCommonJS(changelog_exports),{"Access-Control-Allow-Origin":"*"}),jsonHeaders=(e={})=>({"Content-Type":"application/json",...CORS_HEADERS,...e}),sendJson=(e,o,r,n={})=>{e.sendResponse(o,jsonHeaders(n),JSON.stringify(r))},sendError=(e,o,r)=>{sendJson(e,o,{success:!1,error:r})},sendInternalError=(e,o,r)=>{console.error(`[CPL-Server] Error in ${o}:`,r),sendError(e,500,"Internal server error")},decodeRouteParam=e=>decodeURIComponent(e??""),method="GET",path=/^\/cpl\/changelog\/(.+)$/,handler=(e,o,n)=>{try{var t,l=decodeRouteParam(n.params[0]);let e=null,o=null,r=null;for(const a of[l+"/changelog",l+"/ChangeLog",l+"/CHANGELOG",l+"/history",l+"/History",l+"/HISTORY"]){var s=n.wiki.getTiddler(a);if(s){e=s.fields.text,o=s.fields.title,r=s.fields.modified?String(s.fields.modified):null;break}}e||"string"==typeof(t=n.wiki.getTiddler(l))?.fields.changelog&&(e=t.fields.changelog),e?sendJson(n,200,{plugintitle:l,hasChangelog:!0,changelog:e,tiddlertitle:o,modified:r},{"Cache-Control":"public, max-age=3600"}):sendJson(n,200,{plugintitle:l,hasChangelog:!1,changelog:null,message:"No changelog found for this plugin"})}catch(r){sendInternalError(n,"changelog handler",r)}};