@devwareng/vanilla-ts 1.7.6 → 1.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Oe=Object.create;var K=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var Ie=Object.getPrototypeOf,Ne=Object.prototype.hasOwnProperty;var ct=(s,t)=>()=>(s&&(t=s(s=0)),t);var Bt=(s,t)=>{for(var e in t)K(s,e,{get:t[e],enumerable:!0})},Gt=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Fe(t))!Ne.call(s,r)&&r!==e&&K(s,r,{get:()=>t[r],enumerable:!(n=Ce(t,r))||n.enumerable});return s};var D=(s,t,e)=>(e=s!=null?Oe(Ie(s)):{},Gt(t||!s||!s.__esModule?K(e,"default",{value:s,enumerable:!0}):e,s)),ke=s=>Gt(K({},"__esModule",{value:!0}),s);function ue(s,t={}){let e=t.entryType||t.type;if(e==="both"&&(e=A.FILE_DIR_TYPE),e&&(t.type=e),s){if(typeof s!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(e&&!ie.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${ie.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=s,new Ht(t)}var F,ce,I,A,kt,le,qe,ie,Ye,Be,Ge,Ve,oe,ae,Ht,de=ct(()=>{"use strict";F=require("fs/promises"),ce=require("stream"),I=require("path"),A={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},kt={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:A.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(kt);le="READDIRP_RECURSIVE_ERROR",qe=new Set(["ENOENT","EPERM","EACCES","ELOOP",le]),ie=[A.DIR_TYPE,A.EVERYTHING_TYPE,A.FILE_DIR_TYPE,A.FILE_TYPE],Ye=new Set([A.DIR_TYPE,A.EVERYTHING_TYPE,A.FILE_DIR_TYPE]),Be=new Set([A.EVERYTHING_TYPE,A.FILE_DIR_TYPE,A.FILE_TYPE]),Ge=s=>qe.has(s.code),Ve=process.platform==="win32",oe=s=>!0,ae=s=>{if(s===void 0)return oe;if(typeof s=="function")return s;if(typeof s=="string"){let t=s.trim();return e=>e.basename===t}if(Array.isArray(s)){let t=s.map(e=>e.trim());return e=>t.some(n=>e.basename===n)}return oe},Ht=class extends ce.Readable{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...kt,...t},{root:n,type:r}=e;this._fileFilter=ae(e.fileFilter),this._directoryFilter=ae(e.directoryFilter);let i=e.lstat?F.lstat:F.stat;Ve?this._stat=a=>i(a,{bigint:!0}):this._stat=i,this._maxDepth=e.depth??kt.depth,this._wantsDir=r?Ye.has(r):!1,this._wantsFile=r?Be.has(r):!1,this._wantsEverything=r===A.EVERYTHING_TYPE,this._root=(0,I.resolve)(n),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let e=this.parent,n=e&&e.files;if(n&&n.length>0){let{path:r,depth:i}=e,a=n.splice(0,t).map(c=>this._formatEntry(c,r)),o=await Promise.all(a);for(let c of o){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,i+1)),this._wantsDir&&(this.push(c),t--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),t--)}}else{let r=this.parents.pop();if(!r){this.push(null);break}if(this.parent=await r,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(t,e){let n;try{n=await(0,F.readdir)(t,this._rdOptions)}catch(r){this._onError(r)}return{files:n,depth:e,path:t}}async _formatEntry(t,e){let n,r=this._isDirent?t.name:t;try{let i=(0,I.resolve)((0,I.join)(e,r));n={path:(0,I.relative)(this._root,i),fullPath:i,basename:r},n[this._statsProp]=this._isDirent?t:await this._stat(i)}catch(i){this._onError(i);return}return n}_onError(t){Ge(t)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let e=t[this._statsProp];if(e.isFile())return"file";if(e.isDirectory())return"directory";if(e&&e.isSymbolicLink()){let n=t.fullPath;try{let r=await(0,F.realpath)(n),i=await(0,F.lstat)(r);if(i.isFile())return"file";if(i.isDirectory()){let a=r.length;if(n.startsWith(r)&&n.substr(a,1)===I.sep){let o=new Error(`Circular symlink detected: "${n}" points to "${r}"`);return o.code=le,this._onError(o)}return"directory"}}catch(r){return this._onError(r),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}}});function he(s,t,e,n,r){let i=(a,o)=>{e(s),r(a,o,{watchedPath:s}),o&&s!==o&&et(p.resolve(s,o),H,p.join(s,o))};try{return(0,$.watch)(s,{persistent:t.persistent},i)}catch(a){n(a);return}}var $,O,p,fe,Ke,Wt,me,rt,nt,jt,Qe,Ze,Je,pe,w,M,Xe,ts,H,X,j,es,ss,rs,zt,Y,ns,B,ge,tt,et,is,$t,os,st,we=ct(()=>{"use strict";$=require("fs"),O=require("fs/promises"),p=D(require("path"),1),fe=require("os"),Ke="data",Wt="end",me="close",rt=()=>{},nt=process.platform,jt=nt==="win32",Qe=nt==="darwin",Ze=nt==="linux",Je=nt==="freebsd",pe=(0,fe.type)()==="OS400",w={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},M=w,Xe="watch",ts={lstat:O.lstat,stat:O.stat},H="listeners",X="errHandlers",j="rawEmitters",es=[H,X,j],ss=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),rs=s=>ss.has(p.extname(s).slice(1).toLowerCase()),zt=(s,t)=>{s instanceof Set?s.forEach(t):t(s)},Y=(s,t,e)=>{let n=s[t];n instanceof Set||(s[t]=n=new Set([n])),n.add(e)},ns=s=>t=>{let e=s[t];e instanceof Set?e.clear():delete s[t]},B=(s,t,e)=>{let n=s[t];n instanceof Set?n.delete(e):n===e&&delete s[t]},ge=s=>s instanceof Set?s.size===0:!s,tt=new Map;et=(s,t,e,n,r)=>{let i=tt.get(s);i&&zt(i[t],a=>{a(e,n,r)})},is=(s,t,e,n)=>{let{listener:r,errHandler:i,rawEmitter:a}=n,o=tt.get(t),c;if(!e.persistent)return c=he(s,e,r,i,a),c?c.close.bind(c):void 0;if(o)Y(o,H,r),Y(o,X,i),Y(o,j,a);else{if(c=he(s,e,et.bind(null,t,H),i,et.bind(null,t,j)),!c)return;c.on(M.ERROR,async l=>{let u=et.bind(null,t,X);if(o&&(o.watcherUnusable=!0),jt&&l.code==="EPERM")try{await(await(0,O.open)(s,"r")).close(),u(l)}catch{}else u(l)}),o={listeners:r,errHandlers:i,rawEmitters:a,watcher:c},tt.set(t,o)}return()=>{B(o,H,r),B(o,X,i),B(o,j,a),ge(o.listeners)&&(o.watcher.close(),tt.delete(t),es.forEach(ns(o)),o.watcher=void 0,Object.freeze(o))}},$t=new Map,os=(s,t,e,n)=>{let{listener:r,rawEmitter:i}=n,a=$t.get(t),o=a&&a.options;return o&&(o.persistent<e.persistent||o.interval>e.interval)&&((0,$.unwatchFile)(t),a=void 0),a?(Y(a,H,r),Y(a,j,i)):(a={listeners:r,rawEmitters:i,options:e,watcher:(0,$.watchFile)(t,e,(c,l)=>{zt(a.rawEmitters,d=>{d(M.CHANGE,t,{curr:c,prev:l})});let u=c.mtimeMs;(c.size!==l.size||u>l.mtimeMs||u===0)&&zt(a.listeners,d=>d(s,c))})},$t.set(t,a)),()=>{B(a,H,r),B(a,j,i),ge(a.listeners)&&($t.delete(t),(0,$.unwatchFile)(t),a.options=a.watcher=void 0,Object.freeze(a))}},st=class{constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let n=this.fsw.options,r=p.dirname(t),i=p.basename(t);this.fsw._getWatchedDir(r).add(i);let o=p.resolve(t),c={persistent:n.persistent};e||(e=rt);let l;if(n.usePolling){let u=n.interval!==n.binaryInterval;c.interval=u&&rs(i)?n.binaryInterval:n.interval,l=os(t,o,c,{listener:e,rawEmitter:this.fsw._emitRaw})}else l=is(t,o,c,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return l}_handleFile(t,e,n){if(this.fsw.closed)return;let r=p.dirname(t),i=p.basename(t),a=this.fsw._getWatchedDir(r),o=e;if(a.has(i))return;let c=async(u,d)=>{if(this.fsw._throttle(Xe,t,5)){if(!d||d.mtimeMs===0)try{let h=await(0,O.stat)(t);if(this.fsw.closed)return;let f=h.atimeMs,g=h.mtimeMs;if((!f||f<=g||g!==o.mtimeMs)&&this.fsw._emit(M.CHANGE,t,h),(Qe||Ze||Je)&&o.ino!==h.ino){this.fsw._closeFile(u),o=h;let L=this._watchWithNodeFs(t,c);L&&this.fsw._addPathCloser(u,L)}else o=h}catch{this.fsw._remove(r,i)}else if(a.has(i)){let h=d.atimeMs,f=d.mtimeMs;(!h||h<=f||f!==o.mtimeMs)&&this.fsw._emit(M.CHANGE,t,d),o=d}}},l=this._watchWithNodeFs(t,c);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(M.ADD,t,0))return;this.fsw._emit(M.ADD,t,e)}return l}async _handleSymlink(t,e,n,r){if(this.fsw.closed)return;let i=t.fullPath,a=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let o;try{o=await(0,O.realpath)(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(r)?this.fsw._symlinkPaths.get(i)!==o&&(this.fsw._symlinkPaths.set(i,o),this.fsw._emit(M.CHANGE,n,t.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,o),this.fsw._emit(M.ADD,n,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(t,e,n,r,i,a,o){if(t=p.join(t,""),o=this.fsw._throttle("readdir",t,1e3),!o)return;let c=this.fsw._getWatchedDir(n.path),l=new Set,u=this.fsw._readdirp(t,{fileFilter:d=>n.filterPath(d),directoryFilter:d=>n.filterDir(d)});if(u)return u.on(Ke,async d=>{if(this.fsw.closed){u=void 0;return}let h=d.path,f=p.join(t,h);if(l.add(h),!(d.stats.isSymbolicLink()&&await this._handleSymlink(d,t,f,h))){if(this.fsw.closed){u=void 0;return}(h===r||!r&&!c.has(h))&&(this.fsw._incrReadyCount(),f=p.join(i,p.relative(i,f)),this._addToNodeFs(f,e,n,a+1))}}).on(M.ERROR,this._boundHandleError),new Promise((d,h)=>{if(!u)return h();u.once(Wt,()=>{if(this.fsw.closed){u=void 0;return}let f=o?o.clear():!1;d(void 0),c.getChildren().filter(g=>g!==t&&!l.has(g)).forEach(g=>{this.fsw._remove(t,g)}),u=void 0,f&&this._handleRead(t,!1,n,r,i,a,o)})})}async _handleDir(t,e,n,r,i,a,o){let c=this.fsw._getWatchedDir(p.dirname(t)),l=c.has(p.basename(t));!(n&&this.fsw.options.ignoreInitial)&&!i&&!l&&this.fsw._emit(M.ADD_DIR,t,e),c.add(p.basename(t)),this.fsw._getWatchedDir(t);let u,d,h=this.fsw.options.depth;if((h==null||r<=h)&&!this.fsw._symlinkPaths.has(o)){if(!i&&(await this._handleRead(t,n,a,i,t,r,u),this.fsw.closed))return;d=this._watchWithNodeFs(t,(f,g)=>{g&&g.mtimeMs===0||this._handleRead(f,!1,a,i,t,r,u)})}return d}async _addToNodeFs(t,e,n,r,i){let a=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(t);n&&(o.filterPath=c=>n.filterPath(c),o.filterDir=c=>n.filterDir(c));try{let c=await ts[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,c))return a(),!1;let l=this.fsw.options.followSymlinks,u;if(c.isDirectory()){let d=p.resolve(t),h=l?await(0,O.realpath)(t):t;if(this.fsw.closed||(u=await this._handleDir(o.watchPath,c,e,r,i,o,h),this.fsw.closed))return;d!==h&&h!==void 0&&this.fsw._symlinkPaths.set(d,h)}else if(c.isSymbolicLink()){let d=l?await(0,O.realpath)(t):t;if(this.fsw.closed)return;let h=p.dirname(o.watchPath);if(this.fsw._getWatchedDir(h).add(o.watchPath),this.fsw._emit(M.ADD,o.watchPath,c),u=await this._handleDir(h,c,e,r,t,o,d),this.fsw.closed)return;d!==void 0&&this.fsw._symlinkPaths.set(p.resolve(t),d)}else u=this._handleFile(o.watchPath,c,e);return a(),u&&this.fsw._addPathCloser(t,u),!1}catch(c){if(this.fsw._handleError(c))return a(),t}}}});var De={};Bt(De,{FSWatcher:()=>G,WatchHelper:()=>ot,default:()=>Ts,watch:()=>be});function it(s){return Array.isArray(s)?s:[s]}function fs(s){return typeof s=="function"?s:typeof s=="string"?t=>s===t:s instanceof RegExp?t=>s.test(t):typeof s=="object"&&s!==null?t=>{if(s.path===t)return!0;if(s.recursive){let e=m.relative(s.path,t);return e?!e.startsWith("..")&&!m.isAbsolute(e):!1}return!1}:()=>!1}function ms(s){if(typeof s!="string")throw new Error("string expected");s=m.normalize(s),s=s.replace(/\\/g,"/");let t=!1;s.startsWith("//")&&(t=!0);let e=/\/\//;for(;s.match(e);)s=s.replace(e,"/");return t&&(s="/"+s),s}function ye(s,t,e){let n=ms(t);for(let r=0;r<s.length;r++){let i=s[r];if(i(n,e))return!0}return!1}function ps(s,t){if(s==null)throw new TypeError("anymatch: specify first argument");let n=it(s).map(r=>fs(r));return t==null?(r,i)=>ye(n,r,i):ye(n,t)}function be(s,t={}){let e=new G(t);return e.add(s),e}var ve,at,Pe,m,Ut,as,Re,cs,ls,us,Ee,ds,hs,qt,Te,_e,Le,Se,gs,ws,Yt,Es,ys,ot,G,Ts,Ae=ct(()=>{"use strict";ve=require("fs"),at=require("fs/promises"),Pe=require("events"),m=D(require("path"),1);de();we();Ut="/",as="//",Re=".",cs="..",ls="string",us=/\\/g,Ee=/\/\//,ds=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,hs=/^\.[/\\]/;qt=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);Te=s=>{let t=it(s).flat();if(!t.every(e=>typeof e===ls))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(Le)},_e=s=>{let t=s.replace(us,Ut),e=!1;for(t.startsWith(as)&&(e=!0);t.match(Ee);)t=t.replace(Ee,Ut);return e&&(t=Ut+t),t},Le=s=>_e(m.normalize(_e(s))),Se=(s="")=>t=>typeof t=="string"?Le(m.isAbsolute(t)?t:m.join(s,t)):t,gs=(s,t)=>m.isAbsolute(s)?s:m.join(t,s),ws=Object.freeze(new Set),Yt=class{constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&t!==Re&&t!==cs&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let n=this.path;try{await(0,at.readdir)(n)}catch{this._removeWatcher&&this._removeWatcher(m.dirname(n),m.basename(n))}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=rt,this.items=ws,Object.freeze(this)}},Es="stat",ys="lstat",ot=class{constructor(t,e,n){this.fsw=n;let r=t;this.path=t=t.replace(hs,""),this.watchPath=r,this.fullWatchPath=m.resolve(r),this.dirParts=[],this.dirParts.forEach(i=>{i.length>1&&i.pop()}),this.followSymlinks=e,this.statMethod=e?Es:ys}entryPath(t){return m.join(this.watchPath,m.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let n=this.entryPath(t);return this.fsw._isntIgnored(n,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},G=class extends Pe.EventEmitter{constructor(t={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let e=t.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?it(t.ignored):it([]),awaitWriteFinish:e===!0?n:typeof e=="object"?{...n,...e}:!1};pe&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let c=i.toLowerCase();c==="false"||c==="0"?r.usePolling=!1:c==="true"||c==="1"?r.usePolling=!0:r.usePolling=!!c}let a=process.env.CHOKIDAR_INTERVAL;a&&(r.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=rt,this._readyEmitted=!0,process.nextTick(()=>this.emit(w.READY)))},this._emitRaw=(...c)=>this.emit(w.RAW,...c),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new st(this),Object.freeze(r)}_addIgnoredPath(t){if(qt(t)){for(let e of this._ignoredPaths)if(qt(e)&&e.path===t.path&&e.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),typeof t=="string")for(let e of this._ignoredPaths)qt(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,n){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let i=Te(t);return r&&(i=i.map(a=>gs(a,r))),i.forEach(a=>{this._removeIgnoredPath(a)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=i.length,Promise.all(i.map(async a=>{let o=await this._nodeFsHandler._addToNodeFs(a,!n,void 0,0,e);return o&&this._emitReady(),o})).then(a=>{this.closed||a.forEach(o=>{o&&this.add(m.dirname(o),m.basename(e||o))})}),this}unwatch(t){if(this.closed)return this;let e=Te(t),{cwd:n}=this.options;return e.forEach(r=>{!m.isAbsolute(r)&&!this._closers.has(r)&&(n&&(r=m.join(n,r)),r=m.resolve(r)),this._closePath(r),this._addIgnoredPath(r),this._watched.has(r)&&this._addIgnoredPath({path:r,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let t=[];return this._closers.forEach(e=>e.forEach(n=>{let r=n();r instanceof Promise&&t.push(r)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,n)=>{let i=(this.options.cwd?m.relative(this.options.cwd,n):n)||Re;t[i]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==w.ERROR&&this.emit(w.ALL,t,...e)}async _emit(t,e,n){if(this.closed)return;let r=this.options;jt&&(e=m.normalize(e)),r.cwd&&(e=m.relative(r.cwd,e));let i=[e];n!=null&&i.push(n);let a=r.awaitWriteFinish,o;if(a&&(o=this._pendingWrites.get(e)))return o.lastChange=new Date,this;if(r.atomic){if(t===w.UNLINK)return this._pendingUnlinks.set(e,[t,...i]),setTimeout(()=>{this._pendingUnlinks.forEach((c,l)=>{this.emit(...c),this.emit(w.ALL,...c),this._pendingUnlinks.delete(l)})},typeof r.atomic=="number"?r.atomic:100),this;t===w.ADD&&this._pendingUnlinks.has(e)&&(t=w.CHANGE,this._pendingUnlinks.delete(e))}if(a&&(t===w.ADD||t===w.CHANGE)&&this._readyEmitted){let c=(l,u)=>{l?(t=w.ERROR,i[0]=l,this.emitWithAll(t,i)):u&&(i.length>1?i[1]=u:i.push(u),this.emitWithAll(t,i))};return this._awaitWriteFinish(e,a.stabilityThreshold,t,c),this}if(t===w.CHANGE&&!this._throttle(w.CHANGE,e,50))return this;if(r.alwaysStat&&n===void 0&&(t===w.ADD||t===w.ADD_DIR||t===w.CHANGE)){let c=r.cwd?m.join(r.cwd,e):e,l;try{l=await(0,at.stat)(c)}catch{}if(!l||this.closed)return;i.push(l)}return this.emitWithAll(t,i),this}_handleError(t){let e=t&&t.code;return t&&e!=="ENOENT"&&e!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||e!=="EPERM"&&e!=="EACCES")&&this.emit(w.ERROR,t),t||this.closed}_throttle(t,e,n){this._throttled.has(t)||this._throttled.set(t,new Map);let r=this._throttled.get(t);if(!r)throw new Error("invalid throttle");let i=r.get(e);if(i)return i.count++,!1;let a,o=()=>{let l=r.get(e),u=l?l.count:0;return r.delete(e),clearTimeout(a),l&&clearTimeout(l.timeoutObject),u};a=setTimeout(o,n);let c={timeoutObject:a,clear:o,count:0};return r.set(e,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,n,r){let i=this.options.awaitWriteFinish;if(typeof i!="object")return;let a=i.pollInterval,o,c=t;this.options.cwd&&!m.isAbsolute(t)&&(c=m.join(this.options.cwd,t));let l=new Date,u=this._pendingWrites;function d(h){(0,ve.stat)(c,(f,g)=>{if(f||!u.has(t)){f&&f.code!=="ENOENT"&&r(f);return}let L=Number(new Date);h&&g.size!==h.size&&(u.get(t).lastChange=L);let z=u.get(t);L-z.lastChange>=e?(u.delete(t),r(void 0,g)):o=setTimeout(d,a,g)})}u.has(t)||(u.set(t,{lastChange:l,cancelWait:()=>(u.delete(t),clearTimeout(o),n)}),o=setTimeout(d,a))}_isIgnored(t,e){if(this.options.atomic&&ds.test(t))return!0;if(!this._userIgnored){let{cwd:n}=this.options,i=(this.options.ignored||[]).map(Se(n)),o=[...[...this._ignoredPaths].map(Se(n)),...i];this._userIgnored=ps(o,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new ot(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=m.resolve(t);return this._watched.has(e)||this._watched.set(e,new Yt(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,e,n){let r=m.join(t,e),i=m.resolve(r);if(n=n??(this._watched.has(r)||this._watched.has(i)),!this._throttle("remove",r,100))return;!n&&this._watched.size===1&&this.add(t,e,!0),this._getWatchedDir(r).getChildren().forEach(h=>this._remove(r,h));let c=this._getWatchedDir(t),l=c.has(e);c.remove(e),this._symlinkPaths.has(i)&&this._symlinkPaths.delete(i);let u=r;if(this.options.cwd&&(u=m.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(u)&&this._pendingWrites.get(u).cancelWait()===w.ADD)return;this._watched.delete(r),this._watched.delete(i);let d=n?w.UNLINK_DIR:w.UNLINK;l&&!this._isIgnored(r)&&this._emit(d,r),this._closePath(r)}_closePath(t){this._closeFile(t);let e=m.dirname(t);this._getWatchedDir(e).remove(m.basename(t))}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(n=>n()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let n=this._closers.get(t);n||(n=[],this._closers.set(t,n)),n.push(e)}_readdirp(t,e){if(this.closed)return;let n={type:w.ALL,alwaysStat:!0,lstat:!0,...e,depth:0},r=ue(t,n);return this._streams.add(r),r.once(me,()=>{r=void 0}),r.once(Wt,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};Ts={watch:be,FSWatcher:G}});var _s={};Bt(_s,{TSFilebasedRouter:()=>xe,TSRouter:()=>J,createEffect:()=>At,createSignal:()=>Dt,html:()=>lt,loadPyFiles:()=>Mt,mapper:()=>Vt,renderChildRoutes:()=>bt,useAnchorSingle:()=>_t,useInitialDOM:()=>yt,useTSAuth:()=>Pt,useTSCollection:()=>vt,useTSComponent:()=>q,useTSElementEach:()=>Z,useTSElements:()=>wt,useTSEvent:()=>ht,useTSEventAll:()=>pt,useTSExtractParams:()=>mt,useTSLazy:()=>Ot,useTSMetaData:()=>St,useTSNavigate:()=>Rt,useTSNoReload:()=>It,useTSOutlet:()=>Lt,useTSParams:()=>U,useTSPurifier:()=>dt,useTSSSRHydration:()=>Ct,useTSSelect:()=>W,useTSloadBrython:()=>xt});module.exports=ke(_s);function He(s){let t=s==null?"":String(s),e=t.toLowerCase();return(e.includes("<script")||e.includes("javascript:"))&&(t=""),t=t.replace(/url\(\s*(['"])?\s*\1?\s*\)/gi,""),t.replace(/<\s*(script|iframe|object|embed|link|style|meta|body)[^>]*>.*?<\s*\/\s*\1\s*>/gi,"").replace(/<\s*(script|iframe|object|embed|link|style|meta)[^>]*>/gi,"").replace(/\s+on\w+\s*=\s*(['"]).*?\1/gi,"").replace(/\s+on\w+\s*=\s*[^\s>]+/gi,"").replace(/\s(href|src)\s*=\s*(['"]?)\s*(javascript:|vbscript:|data:|file:)[^'">\s]*\2/gi,'$1="#"')}function lt(s,...t){return s.reduce((e,n,r)=>{let i=r<t.length?He(t[r]):"";return e+n+i},"")}var $e=s=>s.replace(/<\/?(script|iframe|object|embed|link|meta|style|form|textarea|svg|math|body)[^>]*>/gi,"").replace(/<(?!\/?(b|i|em|strong|p|br|ul|ol|li|a|div|span|h1|h2|h3|h4|h5|h6|section|article|input|button)\b)[^>]*>/gi,"").replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/\s*style\s*=\s*("[^"]*"|'[^']*')/gi,"").replace(/<a\b([^>]*)href\s*=\s*(['"]?)(?!https?:|#)[^'"\s>]+(['"]?)([^>]*)>/gi,"<a$1$4>").replace(/\s+(href|src)\s*=\s*(['"]?)\s*(javascript:|data:)[^'"\s>]*/gi,"").replace(/<a\b([^>]*)\bhref\s*=\s*(['"])(\/blog|#blog)\2([^>]*)>/gi,'<a$1 href=$2$3$2 href-line="true"$4>').trim(),Vt=s=>s?.map(t=>$e(t)).join("")??"";var ut=D(require("dompurify"),1),dt=(s,t)=>{let n={...{ADD_TAGS:["my-custom-tag"]},...t};return typeof s=="string"?ut.default.sanitize(s,n):ut.default.sanitize(s.innerHTML,n)};var ht=(s,t,e)=>{if(typeof s=="string"){let n=document.getElementById(s);n?n.addEventListener(t,e):console.warn(`Element with id '${s}' not found.`)}else s instanceof HTMLElement?s.addEventListener(t,e):s===document?document.addEventListener(t,e):console.warn("Invalid id parameter provided.")};var Kt=require("zustand/vanilla"),ft=D(require("dompurify"),1);function ze(s,t){let e=[],n=s.replace(/:[^/]+/g,o=>(e.push(o.slice(1)),"([^/]+)")),r=new RegExp(`^${n}$`),i=t.match(r),a={};return i&&e.forEach((o,c)=>{a[o]=ft.default.sanitize(i[c+1]??"")}),a}function We(s){let t={},e=new URLSearchParams(s);for(let[n,r]of e.entries())t[n]=ft.default.sanitize(r);return t}var U=(0,Kt.createStore)((s,t)=>({params:{},query:{},setFromPattern:e=>{let n=window.location.pathname,r=ze(e,n),i=We(window.location.search);s({params:r,query:i})},getParam:e=>t().params[e],getQuery:e=>t().query[e]}));function mt(s){let t=U.getState();t.setFromPattern(s);let e=t.params,n=t.query;return{...e,...n}}var pt=(s,t,e)=>{let n=document.querySelectorAll(s);return n.forEach(r=>{r.addEventListener(t,e)}),()=>{n.forEach(r=>{r.removeEventListener(t,e)})}};var gt=D(require("dompurify"),1),wt=(s,t,e={},n)=>{let r={USE_PROFILES:{svg:!0,html:!0},ALLOWED_TAGS:["svg","path","circle","rect","line","polyline","polygon","g","main","div","h1","h2","h3","h4","h5","h6","p","button","span","a","img","input","ul","li","i","label","form"],ALLOWED_ATTR:["class","id","href","src","alt","title","fill","stroke","stroke-width","viewBox","xmlns","d","x","y","cx","cy","r","width","height","type","name","value","placeholder","data-click","data-change","data-select","data-classlist","data-hover","data-submit","data-key","data-event"],FORBID_TAGS:["script","iframe","foreignObject","body","html"],FORBID_ATTR:["style","xlink:href"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|ftp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,...n};gt.default.addHook("uponSanitizeAttribute",(o,c)=>{let l=(c.attrName||"").toLowerCase(),u=(c.attrValue??"").toString().trim();if(l.startsWith("on")){c.keepAttr=!1;return}if(/^data-(click|change|submit|select|hover|classlist|key|event)$/.test(l)){c.keepAttr=!0;return}if(o.nodeName.toLowerCase()==="img"&&l==="src"){/^https?:\/\//i.test(u)||/^\/(?!\/)/.test(u)||/^data:image\/(png|jpeg|jpg|gif|webp);base64,/i.test(u)||(c.keepAttr=!1);return}if(l==="class"){let h=u.split(/\s+/).filter(Boolean).filter(f=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]*$/.test(f)){if(/^bg-\[url\(.*\)\]$/.test(f)){let g=f.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return g===""||/^https?:\/\//i.test(g)||/^\/(?!\/)/.test(g)||/^\.{0,2}\//.test(g)}return/^bg-\[\]$/.test(f),!0}return!1});c.attrValue=h.join(" ");return}});let i=gt.default.sanitize(t,{...r,RETURN_DOM_FRAGMENT:!0});for(;s.firstChild;)s.removeChild(s.firstChild);s.appendChild(i);let a=(o,c)=>{s.querySelectorAll(`[${o}]`).forEach(l=>{let u=l.getAttribute(o);u&&Object.prototype.hasOwnProperty.call(e,u)&&l.addEventListener(c,d=>{c==="submit"&&d.preventDefault(),e[u](d)})})};a("data-click","click"),a("data-change","change"),a("data-select","select"),a("data-submit","submit"),s.querySelectorAll("[data-key]").forEach(o=>{let c=o.dataset.key,l=o.dataset.event??"click";c&&Object.prototype.hasOwnProperty.call(e,c)&&o.addEventListener(l,e[c])}),s.querySelectorAll("[data-hover]").forEach(o=>{let c=o.dataset.hover;c&&Object.prototype.hasOwnProperty.call(e,c)&&(o.addEventListener("mouseenter",e[c]),o.addEventListener("mouseleave",e[c]))}),s.querySelectorAll("[data-classlist]").forEach(o=>{let c=o.dataset.classlist;/^[a-zA-Z0-9\-\s:_]+$/.test(c)&&o.classList.add(...c.split(/\s+/))})};var Et=D(require("dompurify"),1),Q=null,yt=(s,t)=>{if(typeof document>"u")return;let e=document.getElementById(s);if(!e)return;Et.default.addHook("uponSanitizeAttribute",(a,o)=>{let c=(o.attrName||"").toLowerCase(),l=(o.attrValue??"").toString().trim();if(c.startsWith("on")){o.keepAttr=!1;return}if((c==="href"||c==="src")&&/^(javascript:|vbscript:|data:|file:|about:)/i.test(l)){o.keepAttr=!1;return}if(c==="class"){let d=l.split(/\s+/).filter(Boolean).filter(h=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]+$/.test(h)){if(/^bg-\[url\(.*\)\]$/.test(h)){let f=h.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return f===""||/^https?:\/\//i.test(f)||/^\/(?!\/)/.test(f)||/^\.{0,2}\//.test(f)}return!0}return!1});o.attrValue=d.join(" ");return}if(c==="style"){o.keepAttr=!1;return}});let n=e.cloneNode(!0),r=Et.default.sanitize(n.innerHTML,{USE_PROFILES:{html:!0},ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br","form","button","input","label"],ALLOWED_ATTR:["href","src","alt","title","class","id","type","name","value","placeholder","data-click","data-change","data-submit","data-select","data-hover","data-classlist"],FORBID_TAGS:["script","iframe","object","embed","body","html","svg","math","link","meta"],ALLOW_DATA_ATTR:!0,KEEP_CONTENT:!1,RETURN_DOM_FRAGMENT:!0}),i=Array.from(r.childNodes).map(a=>a.outerHTML||a.textContent||"").join("");if(Q!==null&&i!==Q){let a=document.createElement("div");t(a);let c=new DOMParser().parseFromString(Q,"text/html");for(;e.firstChild;)e.removeChild(e.firstChild);c.body.childNodes.forEach(l=>e.appendChild(l.cloneNode(!0)))}else{for(Q=i;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(r),t(e)}};var Tt=D(require("dompurify"),1);typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",s=>{let t=s.state;t?.scrollPosition!==void 0&&window.scrollTo(0,t.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var _t=(s,t,e,n="",r=null)=>{if(!s)return;let i=Tt.default.sanitize(t,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=Tt.default.sanitize(e,{USE_PROFILES:{html:!1}});s.setAttribute("href",i),s.setAttribute("aria-label",a),n&&(s.className=n.trim()),r&&s.replaceChildren(r),typeof window<"u"&&s.addEventListener("click",o=>{o.preventDefault();let l=o.currentTarget.getAttribute("href");if(l){let u=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:u},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};var C=D(require("dompurify"),1);var Qt=(s="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",t="'self' 'nonce-rAnd0m123'",e="'none'",n="'self' https://fonts.googleapis.com https://fonts.gstatic.com",r="'self' https://blogger.googleusercontent.com",i=["'self'","https://fonts.googleapis.com","https://fonts.gstatic.com","https://www.google.com/maps/"],a="'self' https://www.youtube.com",o="'self'",c="/csp-report",l=!1)=>{let u=()=>{try{let d=document.querySelector('meta[http-equiv="Content-Security-Policy"]');d||(d=document.createElement("meta"),d.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(d));let h=l?`report-uri ${c};`:"";d.setAttribute("content",`default-src 'self'; script-src ${s}; style-src ${t}; object-src ${e}; font-src ${n}; img-src ${r}; connect-src ${i.join(" ")}; frame-src ${a}; base-uri ${o}; ${h}`)}catch(d){console.error("Error adding CSP meta element:",d)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",u):u()};var St=(s,t)=>{let e={name:C.default.sanitize(s.name||""),title:C.default.sanitize(s.title||""),description:C.default.sanitize(s.description||"Default description"),author:C.default.sanitize(s.author||""),favicon:s.favicon},n=S=>{e.name=C.default.sanitize(S),L("name",e.name)},r=S=>{e.title=C.default.sanitize(S),document.title=e.title},i=S=>{e.description=C.default.sanitize(S),L("description",e.description)},a=S=>{e.author=C.default.sanitize(S),L("author",e.author)},o=S=>{e.favicon=C.default.sanitize(S);let b=document.querySelector('link[rel="icon"]');b||(b=document.createElement("link"),b.rel="icon",document.head.appendChild(b)),b.href=e.favicon},c=()=>e.name,l=()=>e.title,u=()=>e.description,d=()=>e.author,h=()=>e.favicon,f=()=>e,g=(S,b)=>{let x=document.createElement("meta");x.setAttribute("name",S),x.setAttribute("content",b),document.head.appendChild(x)},L=(S,b)=>{let x=document.querySelector(`meta[name="${S}"]`);x?x.setAttribute("content",b):g(S,b)},z=()=>{e.title&&(document.title=e.title),e.name&&L("name",e.name),e.description&&L("description",e.description),e.author&&L("author",e.author),e.favicon&&o(e.favicon)};return t&&Qt(t.scriptSrc,t.styleSrc,t.objectSrc,Array.isArray(t.connectSrc)?t.connectSrc.join(" "):t.connectSrc,t.reportOnly!==void 0?String(t.reportOnly):void 0),z(),{setName:n,setTitle:r,setDescription:i,setAuthor:a,setFavicon:o,getName:c,getTitle:l,getDescription:u,getAuthor:d,getFavicon:h,getAllMetaData:f,appendMetaTagsToHead:z}};var Zt=D(require("dompurify"),1),q=(s,t,e,n,r)=>{let i=`#${s}`,a=t.querySelectorAll(i);if(a.length===0)throw new Error(`[useTSComponent] No element found with id '${s}' in the given parent.`);if(a.length>1)throw new Error(`[useTSComponent] Duplicate id '${s}' detected. Found ${a.length} elements.`);let o=a[0];o.innerHTML=Zt.default.sanitize(o.innerHTML,{USE_PROFILES:{html:!0}}),e(o,n,r)};var vt=(s,t,e,n=[])=>{let r=new Set;s.forEach((i,a)=>{if(r.has(i)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${i}" \u2014 skipping.`);return}r.add(i);let o=t.querySelectorAll(`#${i}`);if(o.length>1){console.warn(`[useTSCollection] Duplicate ID in DOM: "${i}" (${o.length} elements found) \u2014 skipping component mount.`);return}let c=e[a],l=Array.isArray(n)?n[a]:void 0;typeof c=="function"?q(i,t,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var W=(s,t)=>{let n=(t??document).querySelectorAll(s);if(n.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${s}'`),null;if(s.startsWith("#")&&n.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${s}'. Found ${n.length} elements with this ID.`);return n[0]}return n.length>1&&process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] Multiple elements found for selector: '${s}'. Returning the first one.`),n[0]};var Jt=require("jwt-decode"),Pt=(s,t)=>{let e=localStorage.getItem("token");if(!e)return window.location.href=t,null;try{let n=(0,Jt.jwtDecode)(e),r=Date.now()/1e3;return n.exp&&n.exp<r&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=t),null}catch(n){return console.error("Invalid token:",n),window.location.href=t,null}};var Z=(s,t,e)=>{s.forEach(n=>{t.forEach(r=>{n.addEventListener(r,i=>{e(n,i)})})})};var Rt=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var Lt=(s,t)=>{let e=document.querySelector(`#${s}`)||document.querySelector(`.${s}`);if(!e)return;let n=window.location.pathname.replace(/\/$/,"");for(let r of t){let i=r.path.replace(/\/$/,"");if(n===i||n.startsWith(`${i}/`)){r.component(e);break}}};function bt(s,t){let e=window.location.pathname.replace(/\/$/,"");t.routes.forEach(n=>{n.children?.length&&n.children.forEach(r=>{let i=r.path.replace(/\/$/,"");if(e===i||e.startsWith(`${i}/`)){let a=s.querySelector(`#${r.outlet}`)||s.querySelector(`.${r.outlet}`);a instanceof HTMLElement&&r.element&&r.element(a)}})})}var Xt=require("zustand/vanilla");function Dt(s){let t=(0,Xt.createStore)(()=>({value:s})),e=new Set;return{get:()=>t.getState().value,set:n=>{t.setState({value:n}),e.forEach(r=>r(n))},subscribe:n=>(e.add(n),n(t.getState().value),()=>e.delete(n))}}function At(s){let t=s();typeof t=="function"&&t()}var xt=async()=>{let s="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",t="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",e=n=>new Promise((r,i)=>{let a=document.createElement("script");a.src=n,a.onload=()=>r(),a.onerror=()=>i(new Error(`Failed to load ${n}`)),document.head.appendChild(a)});await e(s),await e(t),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},Mt=s=>new Promise((t,e)=>{let n=document.createElement("script");n.type="text/python",n.src=`/src/python/${s}`,n.onload=()=>t(),n.onerror=()=>e(new Error(`Failed to load ${s}`)),document.body.appendChild(n)});function Ot(s){let t=null;return async(e,n)=>{try{if(!t){let r=await s();t=r.default||r}if(typeof t=="function")return t(e,n);if(t instanceof HTMLElement){let r=t.cloneNode(!0);return e?.appendChild(r),r}if(typeof t=="object"&&t!==null&&"render"in t&&typeof t.render=="function")return t.render(e,n);console.warn("useTSLazy: Unsupported module type",t)}catch(r){console.error("useTSLazy failed:",r)}}}var Ct=s=>typeof window>"u"?{isDOM:null}:{isDOM:s||document.body};var te=require("lodash-es"),Ft=s=>s;typeof window<"u"&&typeof document<"u"&&(Ft=s=>{let t=document.createElement("div");return t.innerText=s,t.innerHTML});var je=s=>{(s?Array.isArray(s)?s:s instanceof HTMLAnchorElement?[s]:Array.from(s):Array.from(document.querySelectorAll("a"))).forEach(e=>{if(!e||e.dataset.anchorEnhanced==="true")return;e.dataset.anchorEnhanced="true";let n=e.getAttribute("class")||"";e.setAttribute("class",Ft(n));let r=e.getAttribute("aria-label");r&&e.setAttribute("aria-label",Ft(r));let i=e.querySelector(":scope > *");i&&(e.innerHTML="",e.appendChild(i));let a=e.getAttribute("href")||"";if(!a.startsWith("#")){try{if(new URL(a,window.location.href).origin!==window.location.origin)return}catch{return}e.addEventListener("click",o=>{o.preventDefault();let c=e.getAttribute("href")||"";try{let l=new URL(c,window.location.href);window.history.pushState({},"",l.pathname+l.search+l.hash),window.dispatchEvent(new PopStateEvent("popstate"))}catch(l){console.error("Invalid URL in anchor:",c,l)}})}})},Ue=(0,te.debounce)(je,50),ee=s=>{Ue(s)};var It=s=>{if(!s)return;let t=W("a",s);ee(t)};var Nt=D(require("dompurify"),1);var re=require("zustand/vanilla"),ne=D(require("dompurify"),1),N=(0,re.createStore)(s=>({params:{},query:{},setParams:t=>s(()=>({params:se(t)})),setQuery:t=>s(()=>({query:se(t)}))}));function se(s){let t={};for(let e in s)t[e]=ne.default.sanitize(s[e]);return t}var J=class{constructor(t,e){this.routes=[];this.routes=t,this.expectedParams=new Set(e),window.addEventListener("popstate",this.handlePopState.bind(this)),this.handlePopState()}handlePopState(){let t=window.location.pathname,e=window.location.search,n=this.parseQueryParams(e),r=this.findMatchingRoute(t,this.routes);if(r){if(r.routeto){this.navigate(r.routeto);return}let i=this.filterAndSanitizeParams(r.params);N.getState().setParams(i),N.getState().setQuery(n);let a=document.createElement("div");if(r.element?.(a,i,n),r.children){let o=t.slice(r.path.length),c=a.querySelector("#child");c&&this.renderChildren(r.children,o,c,i,n)}}else{let i=this.findMatchingRoute("*",this.routes);if(i){let a=this.filterAndSanitizeParams(i.params);N.getState().setParams(a),N.getState().setQuery(n);let o=document.createElement("div");i.element?.(o,a,n)}}}renderChildren(t,e,n,r,i){if(!t||t.length===0){let o=n.querySelector("#child");o&&o.remove();return}let a=this.findMatchingRoute(e,t);if(a){let o=document.createElement("div");o.id="child";let c={...r,...a.params},l=this.filterAndSanitizeParams(c);if(N.getState().setParams(l),N.getState().setQuery(i),a.element?.(o,l,i),n.appendChild(o),a.children){let u=e.slice(a.path.length);this.renderChildren(a.children,u,o,l,i)}}}parseQueryParams(t){let e={},n=new URLSearchParams(t);for(let[r,i]of n.entries())this.expectedParams.has(r)&&(e[r]=Nt.default.sanitize(i));return e}findMatchingRoute(t,e,n={}){for(let r of e){let i=r.path;if(i==="*")return r;{let o=[],c=i.replace(/:[^\s/]+/g,d=>(o.push(d.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),u=t.match(l);if(u){let d={...n};if(o.forEach((h,f)=>{d[h]=u[f+1]??""}),r.children){let h=t.slice(u[0].length),f=this.findMatchingRoute(h,r.children,d);if(f)return f}return{...r,params:d}}}}}filterAndSanitizeParams(t){if(!t)return{};let e={};for(let n in t)this.expectedParams.has(n)&&(e[n]=Nt.default.sanitize(t[n]??""));return e}navigate(t){history.pushState(null,"",t),this.handlePopState()}addRoute(t){this.routes.push(t)}};var xe=()=>({name:"ts-filebased-router",async buildStart(){if(typeof process>"u"||!process.versions?.node)return;let s=await import("fs/promises"),t=await import("path"),e=await Promise.resolve().then(()=>(Ae(),De)),n=t.resolve("src/pages"),r=t.resolve("src/gen"),i=t.resolve("src/routes"),a=t.join(r,"tsrouter.gen.ts"),o=t.join(i,"__root.ts"),c=process.env.NODE_ENV!=="production";async function l(E){try{await s.mkdir(E,{recursive:!0})}catch{}}function u(E,y){let T="/"+t.relative(y,E).replace(/\\/g,"/");return T=T.replace(/\.ts$/,"").replace(/\/index$/,"")||"/",T.replace(/\[(.+?)\]/g,":$1")}function d(E){return E.replace(/^\//,"").split("/").map(y=>y.startsWith(":")?y.slice(1):y).filter(Boolean).join("-")||"index"}function h(E,y){let v=t.relative(y,E).replace(/\\/g,"/").split("/").filter(Boolean),P=v[v.length-1].replace(".ts",""),R=v.length>1?v[v.length-2]:"";if(P==="index")return R?R.charAt(0).toUpperCase()+R.slice(1):"Index";if(P.startsWith("[")&&P.endsWith("]")){let k=P.slice(1,-1);return R.charAt(0).toUpperCase()+k.charAt(0).toUpperCase()+k.slice(1)}return P.charAt(0).toUpperCase()+P.slice(1)}async function f(E){let y=await s.readdir(E,{withFileTypes:!0}),T=[];for(let v of y){let P=t.join(E,v.name);if(v.isDirectory())T=T.concat(await f(P));else if(v.isFile()&&v.name.endsWith(".ts")){let R=u(P,n),k=d(R),_=h(P,n);T.push({file:P,route:R,routeName:k,importName:_})}}return T}function g(){return`import { useInitialDOM } from "@devwareng/vanilla-ts";
|
|
1
|
+
"use strict";var Ce=Object.create;var K=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var Ie=Object.getPrototypeOf,Ne=Object.prototype.hasOwnProperty;var ct=(s,t)=>()=>(s&&(t=s(s=0)),t);var Bt=(s,t)=>{for(var e in t)K(s,e,{get:t[e],enumerable:!0})},Gt=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Fe(t))!Ne.call(s,r)&&r!==e&&K(s,r,{get:()=>t[r],enumerable:!(n=Oe(t,r))||n.enumerable});return s};var D=(s,t,e)=>(e=s!=null?Ce(Ie(s)):{},Gt(t||!s||!s.__esModule?K(e,"default",{value:s,enumerable:!0}):e,s)),ke=s=>Gt(K({},"__esModule",{value:!0}),s);function ue(s,t={}){let e=t.entryType||t.type;if(e==="both"&&(e=A.FILE_DIR_TYPE),e&&(t.type=e),s){if(typeof s!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(e&&!ie.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${ie.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=s,new Ht(t)}var F,ce,I,A,kt,le,qe,ie,Ye,Be,Ge,Ve,oe,ae,Ht,de=ct(()=>{"use strict";F=require("fs/promises"),ce=require("stream"),I=require("path"),A={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},kt={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:A.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(kt);le="READDIRP_RECURSIVE_ERROR",qe=new Set(["ENOENT","EPERM","EACCES","ELOOP",le]),ie=[A.DIR_TYPE,A.EVERYTHING_TYPE,A.FILE_DIR_TYPE,A.FILE_TYPE],Ye=new Set([A.DIR_TYPE,A.EVERYTHING_TYPE,A.FILE_DIR_TYPE]),Be=new Set([A.EVERYTHING_TYPE,A.FILE_DIR_TYPE,A.FILE_TYPE]),Ge=s=>qe.has(s.code),Ve=process.platform==="win32",oe=s=>!0,ae=s=>{if(s===void 0)return oe;if(typeof s=="function")return s;if(typeof s=="string"){let t=s.trim();return e=>e.basename===t}if(Array.isArray(s)){let t=s.map(e=>e.trim());return e=>t.some(n=>e.basename===n)}return oe},Ht=class extends ce.Readable{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...kt,...t},{root:n,type:r}=e;this._fileFilter=ae(e.fileFilter),this._directoryFilter=ae(e.directoryFilter);let i=e.lstat?F.lstat:F.stat;Ve?this._stat=a=>i(a,{bigint:!0}):this._stat=i,this._maxDepth=e.depth??kt.depth,this._wantsDir=r?Ye.has(r):!1,this._wantsFile=r?Be.has(r):!1,this._wantsEverything=r===A.EVERYTHING_TYPE,this._root=(0,I.resolve)(n),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let e=this.parent,n=e&&e.files;if(n&&n.length>0){let{path:r,depth:i}=e,a=n.splice(0,t).map(c=>this._formatEntry(c,r)),o=await Promise.all(a);for(let c of o){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,i+1)),this._wantsDir&&(this.push(c),t--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),t--)}}else{let r=this.parents.pop();if(!r){this.push(null);break}if(this.parent=await r,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(t,e){let n;try{n=await(0,F.readdir)(t,this._rdOptions)}catch(r){this._onError(r)}return{files:n,depth:e,path:t}}async _formatEntry(t,e){let n,r=this._isDirent?t.name:t;try{let i=(0,I.resolve)((0,I.join)(e,r));n={path:(0,I.relative)(this._root,i),fullPath:i,basename:r},n[this._statsProp]=this._isDirent?t:await this._stat(i)}catch(i){this._onError(i);return}return n}_onError(t){Ge(t)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let e=t[this._statsProp];if(e.isFile())return"file";if(e.isDirectory())return"directory";if(e&&e.isSymbolicLink()){let n=t.fullPath;try{let r=await(0,F.realpath)(n),i=await(0,F.lstat)(r);if(i.isFile())return"file";if(i.isDirectory()){let a=r.length;if(n.startsWith(r)&&n.substr(a,1)===I.sep){let o=new Error(`Circular symlink detected: "${n}" points to "${r}"`);return o.code=le,this._onError(o)}return"directory"}}catch(r){return this._onError(r),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}}});function he(s,t,e,n,r){let i=(a,o)=>{e(s),r(a,o,{watchedPath:s}),o&&s!==o&&et(p.resolve(s,o),H,p.join(s,o))};try{return(0,$.watch)(s,{persistent:t.persistent},i)}catch(a){n(a);return}}var $,C,p,fe,Ke,Wt,me,rt,nt,jt,Qe,Ze,Je,pe,w,M,Xe,ts,H,X,j,es,ss,rs,zt,Y,ns,B,ge,tt,et,is,$t,os,st,we=ct(()=>{"use strict";$=require("fs"),C=require("fs/promises"),p=D(require("path"),1),fe=require("os"),Ke="data",Wt="end",me="close",rt=()=>{},nt=process.platform,jt=nt==="win32",Qe=nt==="darwin",Ze=nt==="linux",Je=nt==="freebsd",pe=(0,fe.type)()==="OS400",w={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},M=w,Xe="watch",ts={lstat:C.lstat,stat:C.stat},H="listeners",X="errHandlers",j="rawEmitters",es=[H,X,j],ss=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),rs=s=>ss.has(p.extname(s).slice(1).toLowerCase()),zt=(s,t)=>{s instanceof Set?s.forEach(t):t(s)},Y=(s,t,e)=>{let n=s[t];n instanceof Set||(s[t]=n=new Set([n])),n.add(e)},ns=s=>t=>{let e=s[t];e instanceof Set?e.clear():delete s[t]},B=(s,t,e)=>{let n=s[t];n instanceof Set?n.delete(e):n===e&&delete s[t]},ge=s=>s instanceof Set?s.size===0:!s,tt=new Map;et=(s,t,e,n,r)=>{let i=tt.get(s);i&&zt(i[t],a=>{a(e,n,r)})},is=(s,t,e,n)=>{let{listener:r,errHandler:i,rawEmitter:a}=n,o=tt.get(t),c;if(!e.persistent)return c=he(s,e,r,i,a),c?c.close.bind(c):void 0;if(o)Y(o,H,r),Y(o,X,i),Y(o,j,a);else{if(c=he(s,e,et.bind(null,t,H),i,et.bind(null,t,j)),!c)return;c.on(M.ERROR,async l=>{let u=et.bind(null,t,X);if(o&&(o.watcherUnusable=!0),jt&&l.code==="EPERM")try{await(await(0,C.open)(s,"r")).close(),u(l)}catch{}else u(l)}),o={listeners:r,errHandlers:i,rawEmitters:a,watcher:c},tt.set(t,o)}return()=>{B(o,H,r),B(o,X,i),B(o,j,a),ge(o.listeners)&&(o.watcher.close(),tt.delete(t),es.forEach(ns(o)),o.watcher=void 0,Object.freeze(o))}},$t=new Map,os=(s,t,e,n)=>{let{listener:r,rawEmitter:i}=n,a=$t.get(t),o=a&&a.options;return o&&(o.persistent<e.persistent||o.interval>e.interval)&&((0,$.unwatchFile)(t),a=void 0),a?(Y(a,H,r),Y(a,j,i)):(a={listeners:r,rawEmitters:i,options:e,watcher:(0,$.watchFile)(t,e,(c,l)=>{zt(a.rawEmitters,d=>{d(M.CHANGE,t,{curr:c,prev:l})});let u=c.mtimeMs;(c.size!==l.size||u>l.mtimeMs||u===0)&&zt(a.listeners,d=>d(s,c))})},$t.set(t,a)),()=>{B(a,H,r),B(a,j,i),ge(a.listeners)&&($t.delete(t),(0,$.unwatchFile)(t),a.options=a.watcher=void 0,Object.freeze(a))}},st=class{constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let n=this.fsw.options,r=p.dirname(t),i=p.basename(t);this.fsw._getWatchedDir(r).add(i);let o=p.resolve(t),c={persistent:n.persistent};e||(e=rt);let l;if(n.usePolling){let u=n.interval!==n.binaryInterval;c.interval=u&&rs(i)?n.binaryInterval:n.interval,l=os(t,o,c,{listener:e,rawEmitter:this.fsw._emitRaw})}else l=is(t,o,c,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return l}_handleFile(t,e,n){if(this.fsw.closed)return;let r=p.dirname(t),i=p.basename(t),a=this.fsw._getWatchedDir(r),o=e;if(a.has(i))return;let c=async(u,d)=>{if(this.fsw._throttle(Xe,t,5)){if(!d||d.mtimeMs===0)try{let h=await(0,C.stat)(t);if(this.fsw.closed)return;let f=h.atimeMs,g=h.mtimeMs;if((!f||f<=g||g!==o.mtimeMs)&&this.fsw._emit(M.CHANGE,t,h),(Qe||Ze||Je)&&o.ino!==h.ino){this.fsw._closeFile(u),o=h;let L=this._watchWithNodeFs(t,c);L&&this.fsw._addPathCloser(u,L)}else o=h}catch{this.fsw._remove(r,i)}else if(a.has(i)){let h=d.atimeMs,f=d.mtimeMs;(!h||h<=f||f!==o.mtimeMs)&&this.fsw._emit(M.CHANGE,t,d),o=d}}},l=this._watchWithNodeFs(t,c);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(M.ADD,t,0))return;this.fsw._emit(M.ADD,t,e)}return l}async _handleSymlink(t,e,n,r){if(this.fsw.closed)return;let i=t.fullPath,a=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let o;try{o=await(0,C.realpath)(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(r)?this.fsw._symlinkPaths.get(i)!==o&&(this.fsw._symlinkPaths.set(i,o),this.fsw._emit(M.CHANGE,n,t.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,o),this.fsw._emit(M.ADD,n,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(t,e,n,r,i,a,o){if(t=p.join(t,""),o=this.fsw._throttle("readdir",t,1e3),!o)return;let c=this.fsw._getWatchedDir(n.path),l=new Set,u=this.fsw._readdirp(t,{fileFilter:d=>n.filterPath(d),directoryFilter:d=>n.filterDir(d)});if(u)return u.on(Ke,async d=>{if(this.fsw.closed){u=void 0;return}let h=d.path,f=p.join(t,h);if(l.add(h),!(d.stats.isSymbolicLink()&&await this._handleSymlink(d,t,f,h))){if(this.fsw.closed){u=void 0;return}(h===r||!r&&!c.has(h))&&(this.fsw._incrReadyCount(),f=p.join(i,p.relative(i,f)),this._addToNodeFs(f,e,n,a+1))}}).on(M.ERROR,this._boundHandleError),new Promise((d,h)=>{if(!u)return h();u.once(Wt,()=>{if(this.fsw.closed){u=void 0;return}let f=o?o.clear():!1;d(void 0),c.getChildren().filter(g=>g!==t&&!l.has(g)).forEach(g=>{this.fsw._remove(t,g)}),u=void 0,f&&this._handleRead(t,!1,n,r,i,a,o)})})}async _handleDir(t,e,n,r,i,a,o){let c=this.fsw._getWatchedDir(p.dirname(t)),l=c.has(p.basename(t));!(n&&this.fsw.options.ignoreInitial)&&!i&&!l&&this.fsw._emit(M.ADD_DIR,t,e),c.add(p.basename(t)),this.fsw._getWatchedDir(t);let u,d,h=this.fsw.options.depth;if((h==null||r<=h)&&!this.fsw._symlinkPaths.has(o)){if(!i&&(await this._handleRead(t,n,a,i,t,r,u),this.fsw.closed))return;d=this._watchWithNodeFs(t,(f,g)=>{g&&g.mtimeMs===0||this._handleRead(f,!1,a,i,t,r,u)})}return d}async _addToNodeFs(t,e,n,r,i){let a=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(t);n&&(o.filterPath=c=>n.filterPath(c),o.filterDir=c=>n.filterDir(c));try{let c=await ts[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,c))return a(),!1;let l=this.fsw.options.followSymlinks,u;if(c.isDirectory()){let d=p.resolve(t),h=l?await(0,C.realpath)(t):t;if(this.fsw.closed||(u=await this._handleDir(o.watchPath,c,e,r,i,o,h),this.fsw.closed))return;d!==h&&h!==void 0&&this.fsw._symlinkPaths.set(d,h)}else if(c.isSymbolicLink()){let d=l?await(0,C.realpath)(t):t;if(this.fsw.closed)return;let h=p.dirname(o.watchPath);if(this.fsw._getWatchedDir(h).add(o.watchPath),this.fsw._emit(M.ADD,o.watchPath,c),u=await this._handleDir(h,c,e,r,t,o,d),this.fsw.closed)return;d!==void 0&&this.fsw._symlinkPaths.set(p.resolve(t),d)}else u=this._handleFile(o.watchPath,c,e);return a(),u&&this.fsw._addPathCloser(t,u),!1}catch(c){if(this.fsw._handleError(c))return a(),t}}}});var De={};Bt(De,{FSWatcher:()=>G,WatchHelper:()=>ot,default:()=>Ts,watch:()=>be});function it(s){return Array.isArray(s)?s:[s]}function fs(s){return typeof s=="function"?s:typeof s=="string"?t=>s===t:s instanceof RegExp?t=>s.test(t):typeof s=="object"&&s!==null?t=>{if(s.path===t)return!0;if(s.recursive){let e=m.relative(s.path,t);return e?!e.startsWith("..")&&!m.isAbsolute(e):!1}return!1}:()=>!1}function ms(s){if(typeof s!="string")throw new Error("string expected");s=m.normalize(s),s=s.replace(/\\/g,"/");let t=!1;s.startsWith("//")&&(t=!0);let e=/\/\//;for(;s.match(e);)s=s.replace(e,"/");return t&&(s="/"+s),s}function ye(s,t,e){let n=ms(t);for(let r=0;r<s.length;r++){let i=s[r];if(i(n,e))return!0}return!1}function ps(s,t){if(s==null)throw new TypeError("anymatch: specify first argument");let n=it(s).map(r=>fs(r));return t==null?(r,i)=>ye(n,r,i):ye(n,t)}function be(s,t={}){let e=new G(t);return e.add(s),e}var ve,at,Pe,m,Ut,as,Re,cs,ls,us,Ee,ds,hs,qt,Te,_e,Le,Se,gs,ws,Yt,Es,ys,ot,G,Ts,Ae=ct(()=>{"use strict";ve=require("fs"),at=require("fs/promises"),Pe=require("events"),m=D(require("path"),1);de();we();Ut="/",as="//",Re=".",cs="..",ls="string",us=/\\/g,Ee=/\/\//,ds=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,hs=/^\.[/\\]/;qt=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);Te=s=>{let t=it(s).flat();if(!t.every(e=>typeof e===ls))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(Le)},_e=s=>{let t=s.replace(us,Ut),e=!1;for(t.startsWith(as)&&(e=!0);t.match(Ee);)t=t.replace(Ee,Ut);return e&&(t=Ut+t),t},Le=s=>_e(m.normalize(_e(s))),Se=(s="")=>t=>typeof t=="string"?Le(m.isAbsolute(t)?t:m.join(s,t)):t,gs=(s,t)=>m.isAbsolute(s)?s:m.join(t,s),ws=Object.freeze(new Set),Yt=class{constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&t!==Re&&t!==cs&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let n=this.path;try{await(0,at.readdir)(n)}catch{this._removeWatcher&&this._removeWatcher(m.dirname(n),m.basename(n))}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=rt,this.items=ws,Object.freeze(this)}},Es="stat",ys="lstat",ot=class{constructor(t,e,n){this.fsw=n;let r=t;this.path=t=t.replace(hs,""),this.watchPath=r,this.fullWatchPath=m.resolve(r),this.dirParts=[],this.dirParts.forEach(i=>{i.length>1&&i.pop()}),this.followSymlinks=e,this.statMethod=e?Es:ys}entryPath(t){return m.join(this.watchPath,m.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let n=this.entryPath(t);return this.fsw._isntIgnored(n,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},G=class extends Pe.EventEmitter{constructor(t={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let e=t.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?it(t.ignored):it([]),awaitWriteFinish:e===!0?n:typeof e=="object"?{...n,...e}:!1};pe&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let c=i.toLowerCase();c==="false"||c==="0"?r.usePolling=!1:c==="true"||c==="1"?r.usePolling=!0:r.usePolling=!!c}let a=process.env.CHOKIDAR_INTERVAL;a&&(r.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=rt,this._readyEmitted=!0,process.nextTick(()=>this.emit(w.READY)))},this._emitRaw=(...c)=>this.emit(w.RAW,...c),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new st(this),Object.freeze(r)}_addIgnoredPath(t){if(qt(t)){for(let e of this._ignoredPaths)if(qt(e)&&e.path===t.path&&e.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),typeof t=="string")for(let e of this._ignoredPaths)qt(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,n){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let i=Te(t);return r&&(i=i.map(a=>gs(a,r))),i.forEach(a=>{this._removeIgnoredPath(a)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=i.length,Promise.all(i.map(async a=>{let o=await this._nodeFsHandler._addToNodeFs(a,!n,void 0,0,e);return o&&this._emitReady(),o})).then(a=>{this.closed||a.forEach(o=>{o&&this.add(m.dirname(o),m.basename(e||o))})}),this}unwatch(t){if(this.closed)return this;let e=Te(t),{cwd:n}=this.options;return e.forEach(r=>{!m.isAbsolute(r)&&!this._closers.has(r)&&(n&&(r=m.join(n,r)),r=m.resolve(r)),this._closePath(r),this._addIgnoredPath(r),this._watched.has(r)&&this._addIgnoredPath({path:r,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let t=[];return this._closers.forEach(e=>e.forEach(n=>{let r=n();r instanceof Promise&&t.push(r)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,n)=>{let i=(this.options.cwd?m.relative(this.options.cwd,n):n)||Re;t[i]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==w.ERROR&&this.emit(w.ALL,t,...e)}async _emit(t,e,n){if(this.closed)return;let r=this.options;jt&&(e=m.normalize(e)),r.cwd&&(e=m.relative(r.cwd,e));let i=[e];n!=null&&i.push(n);let a=r.awaitWriteFinish,o;if(a&&(o=this._pendingWrites.get(e)))return o.lastChange=new Date,this;if(r.atomic){if(t===w.UNLINK)return this._pendingUnlinks.set(e,[t,...i]),setTimeout(()=>{this._pendingUnlinks.forEach((c,l)=>{this.emit(...c),this.emit(w.ALL,...c),this._pendingUnlinks.delete(l)})},typeof r.atomic=="number"?r.atomic:100),this;t===w.ADD&&this._pendingUnlinks.has(e)&&(t=w.CHANGE,this._pendingUnlinks.delete(e))}if(a&&(t===w.ADD||t===w.CHANGE)&&this._readyEmitted){let c=(l,u)=>{l?(t=w.ERROR,i[0]=l,this.emitWithAll(t,i)):u&&(i.length>1?i[1]=u:i.push(u),this.emitWithAll(t,i))};return this._awaitWriteFinish(e,a.stabilityThreshold,t,c),this}if(t===w.CHANGE&&!this._throttle(w.CHANGE,e,50))return this;if(r.alwaysStat&&n===void 0&&(t===w.ADD||t===w.ADD_DIR||t===w.CHANGE)){let c=r.cwd?m.join(r.cwd,e):e,l;try{l=await(0,at.stat)(c)}catch{}if(!l||this.closed)return;i.push(l)}return this.emitWithAll(t,i),this}_handleError(t){let e=t&&t.code;return t&&e!=="ENOENT"&&e!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||e!=="EPERM"&&e!=="EACCES")&&this.emit(w.ERROR,t),t||this.closed}_throttle(t,e,n){this._throttled.has(t)||this._throttled.set(t,new Map);let r=this._throttled.get(t);if(!r)throw new Error("invalid throttle");let i=r.get(e);if(i)return i.count++,!1;let a,o=()=>{let l=r.get(e),u=l?l.count:0;return r.delete(e),clearTimeout(a),l&&clearTimeout(l.timeoutObject),u};a=setTimeout(o,n);let c={timeoutObject:a,clear:o,count:0};return r.set(e,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,n,r){let i=this.options.awaitWriteFinish;if(typeof i!="object")return;let a=i.pollInterval,o,c=t;this.options.cwd&&!m.isAbsolute(t)&&(c=m.join(this.options.cwd,t));let l=new Date,u=this._pendingWrites;function d(h){(0,ve.stat)(c,(f,g)=>{if(f||!u.has(t)){f&&f.code!=="ENOENT"&&r(f);return}let L=Number(new Date);h&&g.size!==h.size&&(u.get(t).lastChange=L);let z=u.get(t);L-z.lastChange>=e?(u.delete(t),r(void 0,g)):o=setTimeout(d,a,g)})}u.has(t)||(u.set(t,{lastChange:l,cancelWait:()=>(u.delete(t),clearTimeout(o),n)}),o=setTimeout(d,a))}_isIgnored(t,e){if(this.options.atomic&&ds.test(t))return!0;if(!this._userIgnored){let{cwd:n}=this.options,i=(this.options.ignored||[]).map(Se(n)),o=[...[...this._ignoredPaths].map(Se(n)),...i];this._userIgnored=ps(o,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new ot(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=m.resolve(t);return this._watched.has(e)||this._watched.set(e,new Yt(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,e,n){let r=m.join(t,e),i=m.resolve(r);if(n=n??(this._watched.has(r)||this._watched.has(i)),!this._throttle("remove",r,100))return;!n&&this._watched.size===1&&this.add(t,e,!0),this._getWatchedDir(r).getChildren().forEach(h=>this._remove(r,h));let c=this._getWatchedDir(t),l=c.has(e);c.remove(e),this._symlinkPaths.has(i)&&this._symlinkPaths.delete(i);let u=r;if(this.options.cwd&&(u=m.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(u)&&this._pendingWrites.get(u).cancelWait()===w.ADD)return;this._watched.delete(r),this._watched.delete(i);let d=n?w.UNLINK_DIR:w.UNLINK;l&&!this._isIgnored(r)&&this._emit(d,r),this._closePath(r)}_closePath(t){this._closeFile(t);let e=m.dirname(t);this._getWatchedDir(e).remove(m.basename(t))}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(n=>n()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let n=this._closers.get(t);n||(n=[],this._closers.set(t,n)),n.push(e)}_readdirp(t,e){if(this.closed)return;let n={type:w.ALL,alwaysStat:!0,lstat:!0,...e,depth:0},r=ue(t,n);return this._streams.add(r),r.once(me,()=>{r=void 0}),r.once(Wt,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};Ts={watch:be,FSWatcher:G}});var _s={};Bt(_s,{TSFilebasedRouter:()=>xe,TSRouter:()=>J,createEffect:()=>At,createSignal:()=>Dt,html:()=>lt,loadPyFiles:()=>Mt,mapper:()=>Vt,renderChildRoutes:()=>bt,useAnchorSingle:()=>_t,useInitialDOM:()=>yt,useTSAuth:()=>Pt,useTSCollection:()=>vt,useTSComponent:()=>q,useTSElementEach:()=>Z,useTSElements:()=>wt,useTSEvent:()=>ht,useTSEventAll:()=>pt,useTSExtractParams:()=>mt,useTSLazy:()=>Ct,useTSMetaData:()=>St,useTSNavigate:()=>Rt,useTSNoReload:()=>It,useTSOutlet:()=>Lt,useTSParams:()=>U,useTSPurifier:()=>dt,useTSSSRHydration:()=>Ot,useTSSelect:()=>W,useTSloadBrython:()=>xt});module.exports=ke(_s);function He(s){let t=s==null?"":String(s),e=t.toLowerCase();return(e.includes("<script")||e.includes("javascript:"))&&(t=""),t=t.replace(/url\(\s*(['"])?\s*\1?\s*\)/gi,""),t.replace(/<\s*(script|iframe|object|embed|link|style|meta|body)[^>]*>.*?<\s*\/\s*\1\s*>/gi,"").replace(/<\s*(script|iframe|object|embed|link|style|meta)[^>]*>/gi,"").replace(/\s+on\w+\s*=\s*(['"]).*?\1/gi,"").replace(/\s+on\w+\s*=\s*[^\s>]+/gi,"").replace(/\s(href|src)\s*=\s*(['"]?)\s*(javascript:|vbscript:|data:|file:)[^'">\s]*\2/gi,'$1="#"')}function lt(s,...t){return s.reduce((e,n,r)=>{let i=r<t.length?He(t[r]):"";return e+n+i},"")}var $e=s=>s.replace(/<\/?(script|iframe|object|embed|link|meta|style|form|textarea|svg|math|body)[^>]*>/gi,"").replace(/<(?!\/?(b|i|em|strong|p|br|ul|ol|li|a|div|span|h1|h2|h3|h4|h5|h6|section|article|input|button)\b)[^>]*>/gi,"").replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/\s*style\s*=\s*("[^"]*"|'[^']*')/gi,"").replace(/<a\b([^>]*)href\s*=\s*(['"]?)(?!https?:|#)[^'"\s>]+(['"]?)([^>]*)>/gi,"<a$1$4>").replace(/\s+(href|src)\s*=\s*(['"]?)\s*(javascript:|data:)[^'"\s>]*/gi,"").replace(/<a\b([^>]*)\bhref\s*=\s*(['"])(\/blog|#blog)\2([^>]*)>/gi,'<a$1 href=$2$3$2 href-line="true"$4>').trim(),Vt=s=>s?.map(t=>$e(t)).join("")??"";var ut=D(require("dompurify"),1),dt=(s,t)=>{let n={...{ADD_TAGS:["my-custom-tag"]},...t};return typeof s=="string"?ut.default.sanitize(s,n):ut.default.sanitize(s.innerHTML,n)};var ht=(s,t,e)=>{if(typeof s=="string"){let n=document.getElementById(s);n?n.addEventListener(t,e):console.warn(`Element with id '${s}' not found.`)}else s instanceof HTMLElement?s.addEventListener(t,e):s===document?document.addEventListener(t,e):console.warn("Invalid target parameter provided.")};var Kt=require("zustand/vanilla"),ft=D(require("dompurify"),1);function ze(s,t){let e=[],n=s.replace(/:[^/]+/g,o=>(e.push(o.slice(1)),"([^/]+)")),r=new RegExp(`^${n}$`),i=t.match(r),a={};return i&&e.forEach((o,c)=>{a[o]=ft.default.sanitize(i[c+1]??"")}),a}function We(s){let t={},e=new URLSearchParams(s);for(let[n,r]of e.entries())t[n]=ft.default.sanitize(r);return t}var U=(0,Kt.createStore)((s,t)=>({params:{},query:{},setFromPattern:e=>{let n=window.location.pathname,r=ze(e,n),i=We(window.location.search);s({params:r,query:i})},getParam:e=>t().params[e],getQuery:e=>t().query[e]}));function mt(s){let t=U.getState();t.setFromPattern(s);let e=t.params,n=t.query;return{...e,...n}}var pt=(s,t,e)=>{let n=document.querySelectorAll(s);return n.forEach(r=>{r.addEventListener(t,e)}),()=>{n.forEach(r=>{r.removeEventListener(t,e)})}};var gt=D(require("dompurify"),1),wt=(s,t,e={},n)=>{let r={USE_PROFILES:{svg:!0,html:!0},ALLOWED_TAGS:["svg","path","circle","rect","line","polyline","polygon","g","main","div","h1","h2","h3","h4","h5","h6","p","button","span","a","img","input","ul","li","i","label","form"],ALLOWED_ATTR:["class","id","href","src","alt","title","fill","stroke","stroke-width","viewBox","xmlns","d","x","y","cx","cy","r","width","height","type","name","value","placeholder","data-click","data-change","data-select","data-classlist","data-hover","data-submit","data-key","data-event"],FORBID_TAGS:["script","iframe","foreignObject","body","html"],FORBID_ATTR:["style","xlink:href"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|ftp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,...n};gt.default.addHook("uponSanitizeAttribute",(o,c)=>{let l=(c.attrName||"").toLowerCase(),u=(c.attrValue??"").toString().trim();if(l.startsWith("on")){c.keepAttr=!1;return}if(/^data-(click|change|submit|select|hover|classlist|key|event)$/.test(l)){c.keepAttr=!0;return}if(o.nodeName.toLowerCase()==="img"&&l==="src"){/^https?:\/\//i.test(u)||/^\/(?!\/)/.test(u)||/^data:image\/(png|jpeg|jpg|gif|webp);base64,/i.test(u)||(c.keepAttr=!1);return}if(l==="class"){let h=u.split(/\s+/).filter(Boolean).filter(f=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]*$/.test(f)){if(/^bg-\[url\(.*\)\]$/.test(f)){let g=f.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return g===""||/^https?:\/\//i.test(g)||/^\/(?!\/)/.test(g)||/^\.{0,2}\//.test(g)}return/^bg-\[\]$/.test(f),!0}return!1});c.attrValue=h.join(" ");return}});let i=gt.default.sanitize(t,{...r,RETURN_DOM_FRAGMENT:!0});for(;s.firstChild;)s.removeChild(s.firstChild);s.appendChild(i);let a=(o,c)=>{s.querySelectorAll(`[${o}]`).forEach(l=>{let u=l.getAttribute(o);u&&Object.prototype.hasOwnProperty.call(e,u)&&l.addEventListener(c,d=>{c==="submit"&&d.preventDefault(),e[u](d)})})};a("data-click","click"),a("data-change","change"),a("data-select","select"),a("data-submit","submit"),s.querySelectorAll("[data-key]").forEach(o=>{let c=o.dataset.key,l=o.dataset.event??"click";c&&Object.prototype.hasOwnProperty.call(e,c)&&o.addEventListener(l,e[c])}),s.querySelectorAll("[data-hover]").forEach(o=>{let c=o.dataset.hover;c&&Object.prototype.hasOwnProperty.call(e,c)&&(o.addEventListener("mouseenter",e[c]),o.addEventListener("mouseleave",e[c]))}),s.querySelectorAll("[data-classlist]").forEach(o=>{let c=o.dataset.classlist;/^[a-zA-Z0-9\-\s:_]+$/.test(c)&&o.classList.add(...c.split(/\s+/))})};var Et=D(require("dompurify"),1),Q=null,yt=(s,t)=>{if(typeof document>"u")return;let e=document.getElementById(s);if(!e)return;Et.default.addHook("uponSanitizeAttribute",(a,o)=>{let c=(o.attrName||"").toLowerCase(),l=(o.attrValue??"").toString().trim();if(c.startsWith("on")){o.keepAttr=!1;return}if((c==="href"||c==="src")&&/^(javascript:|vbscript:|data:|file:|about:)/i.test(l)){o.keepAttr=!1;return}if(c==="class"){let d=l.split(/\s+/).filter(Boolean).filter(h=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]+$/.test(h)){if(/^bg-\[url\(.*\)\]$/.test(h)){let f=h.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return f===""||/^https?:\/\//i.test(f)||/^\/(?!\/)/.test(f)||/^\.{0,2}\//.test(f)}return!0}return!1});o.attrValue=d.join(" ");return}if(c==="style"){o.keepAttr=!1;return}});let n=e.cloneNode(!0),r=Et.default.sanitize(n.innerHTML,{USE_PROFILES:{html:!0},ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br","form","button","input","label"],ALLOWED_ATTR:["href","src","alt","title","class","id","type","name","value","placeholder","data-click","data-change","data-submit","data-select","data-hover","data-classlist"],FORBID_TAGS:["script","iframe","object","embed","body","html","svg","math","link","meta"],ALLOW_DATA_ATTR:!0,KEEP_CONTENT:!1,RETURN_DOM_FRAGMENT:!0}),i=Array.from(r.childNodes).map(a=>a.outerHTML||a.textContent||"").join("");if(Q!==null&&i!==Q){let a=document.createElement("div");t(a);let c=new DOMParser().parseFromString(Q,"text/html");for(;e.firstChild;)e.removeChild(e.firstChild);c.body.childNodes.forEach(l=>e.appendChild(l.cloneNode(!0)))}else{for(Q=i;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(r),t(e)}};var Tt=D(require("dompurify"),1);typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",s=>{let t=s.state;t?.scrollPosition!==void 0&&window.scrollTo(0,t.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var _t=(s,t,e,n="",r=null)=>{if(!s)return;let i=Tt.default.sanitize(t,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=Tt.default.sanitize(e,{USE_PROFILES:{html:!1}});s.setAttribute("href",i),s.setAttribute("aria-label",a),n&&(s.className=n.trim()),r&&s.replaceChildren(r),typeof window<"u"&&s.addEventListener("click",o=>{o.preventDefault();let l=o.currentTarget.getAttribute("href");if(l){let u=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:u},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};var O=D(require("dompurify"),1);var Qt=(s="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",t="'self' 'nonce-rAnd0m123'",e="'none'",n="'self' https://fonts.googleapis.com https://fonts.gstatic.com",r="'self' https://blogger.googleusercontent.com",i=["'self'","https://fonts.googleapis.com","https://fonts.gstatic.com","https://www.google.com/maps/"],a="'self' https://www.youtube.com",o="'self'",c="/csp-report",l=!1)=>{let u=()=>{try{let d=document.querySelector('meta[http-equiv="Content-Security-Policy"]');d||(d=document.createElement("meta"),d.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(d));let h=l?`report-uri ${c};`:"";d.setAttribute("content",`default-src 'self'; script-src ${s}; style-src ${t}; object-src ${e}; font-src ${n}; img-src ${r}; connect-src ${i.join(" ")}; frame-src ${a}; base-uri ${o}; ${h}`)}catch(d){console.error("Error adding CSP meta element:",d)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",u):u()};var St=(s,t)=>{let e={name:O.default.sanitize(s.name||""),title:O.default.sanitize(s.title||""),description:O.default.sanitize(s.description||"Default description"),author:O.default.sanitize(s.author||""),favicon:s.favicon},n=S=>{e.name=O.default.sanitize(S),L("name",e.name)},r=S=>{e.title=O.default.sanitize(S),document.title=e.title},i=S=>{e.description=O.default.sanitize(S),L("description",e.description)},a=S=>{e.author=O.default.sanitize(S),L("author",e.author)},o=S=>{e.favicon=O.default.sanitize(S);let b=document.querySelector('link[rel="icon"]');b||(b=document.createElement("link"),b.rel="icon",document.head.appendChild(b)),b.href=e.favicon},c=()=>e.name,l=()=>e.title,u=()=>e.description,d=()=>e.author,h=()=>e.favicon,f=()=>e,g=(S,b)=>{let x=document.createElement("meta");x.setAttribute("name",S),x.setAttribute("content",b),document.head.appendChild(x)},L=(S,b)=>{let x=document.querySelector(`meta[name="${S}"]`);x?x.setAttribute("content",b):g(S,b)},z=()=>{e.title&&(document.title=e.title),e.name&&L("name",e.name),e.description&&L("description",e.description),e.author&&L("author",e.author),e.favicon&&o(e.favicon)};return t&&Qt(t.scriptSrc,t.styleSrc,t.objectSrc,Array.isArray(t.connectSrc)?t.connectSrc.join(" "):t.connectSrc,t.reportOnly!==void 0?String(t.reportOnly):void 0),z(),{setName:n,setTitle:r,setDescription:i,setAuthor:a,setFavicon:o,getName:c,getTitle:l,getDescription:u,getAuthor:d,getFavicon:h,getAllMetaData:f,appendMetaTagsToHead:z}};var Zt=D(require("dompurify"),1),q=(s,t,e,n,r)=>{let i=`#${s}`,a=t.querySelectorAll(i);if(a.length===0)throw new Error(`[useTSComponent] No element found with id '${s}' in the given parent.`);if(a.length>1)throw new Error(`[useTSComponent] Duplicate id '${s}' detected. Found ${a.length} elements.`);let o=a[0];o.innerHTML=Zt.default.sanitize(o.innerHTML,{USE_PROFILES:{html:!0}}),e(o,n,r)};var vt=(s,t,e,n=[])=>{let r=new Set;s.forEach((i,a)=>{if(r.has(i)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${i}" \u2014 skipping.`);return}r.add(i);let o=t.querySelectorAll(`#${i}`);if(o.length>1){console.warn(`[useTSCollection] Duplicate ID in DOM: "${i}" (${o.length} elements found) \u2014 skipping component mount.`);return}let c=e[a],l=Array.isArray(n)?n[a]:void 0;typeof c=="function"?q(i,t,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var W=(s,t)=>{let n=(t??document).querySelectorAll(s);if(n.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${s}'`),null;if(s.startsWith("#")&&n.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${s}'. Found ${n.length} elements with this ID.`);return n[0]}return n.length>1&&process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] Multiple elements found for selector: '${s}'. Returning the first one.`),n[0]};var Jt=require("jwt-decode"),Pt=(s,t)=>{let e=localStorage.getItem("token");if(!e)return window.location.href=t,null;try{let n=(0,Jt.jwtDecode)(e),r=Date.now()/1e3;return n.exp&&n.exp<r&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=t),null}catch(n){return console.error("Invalid token:",n),window.location.href=t,null}};var Z=(s,t,e)=>{s.forEach(n=>{t.forEach(r=>{n.addEventListener(r,i=>{e(n,i)})})})};var Rt=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var Lt=(s,t)=>{let e=document.querySelector(`#${s}`)||document.querySelector(`.${s}`);if(!e)return;let n=window.location.pathname.replace(/\/$/,"");for(let r of t){let i=r.path.replace(/\/$/,"");if(n===i||n.startsWith(`${i}/`)){r.component(e);break}}};function bt(s,t){let e=window.location.pathname.replace(/\/$/,"");t.routes.forEach(n=>{n.children?.length&&n.children.forEach(r=>{let i=r.path.replace(/\/$/,"");if(e===i||e.startsWith(`${i}/`)){let a=s.querySelector(`#${r.outlet}`)||s.querySelector(`.${r.outlet}`);a instanceof HTMLElement&&r.element&&r.element(a)}})})}var Xt=require("zustand/vanilla");function Dt(s){let t=(0,Xt.createStore)(()=>({value:s})),e=new Set;return{get:()=>t.getState().value,set:n=>{t.setState({value:n}),e.forEach(r=>r(n))},subscribe:n=>(e.add(n),n(t.getState().value),()=>e.delete(n))}}function At(s){let t=s();typeof t=="function"&&t()}var xt=async()=>{let s="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",t="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",e=n=>new Promise((r,i)=>{let a=document.createElement("script");a.src=n,a.onload=()=>r(),a.onerror=()=>i(new Error(`Failed to load ${n}`)),document.head.appendChild(a)});await e(s),await e(t),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},Mt=s=>new Promise((t,e)=>{let n=document.createElement("script");n.type="text/python",n.src=`/src/python/${s}`,n.onload=()=>t(),n.onerror=()=>e(new Error(`Failed to load ${s}`)),document.body.appendChild(n)});function Ct(s){let t=null;return async(e,n)=>{try{if(!t){let r=await s();t=r.default||r}if(typeof t=="function")return t(e,n);if(t instanceof HTMLElement){let r=t.cloneNode(!0);return e?.appendChild(r),r}if(typeof t=="object"&&t!==null&&"render"in t&&typeof t.render=="function")return t.render(e,n);console.warn("useTSLazy: Unsupported module type",t)}catch(r){console.error("useTSLazy failed:",r)}}}var Ot=s=>typeof window>"u"?{isDOM:null}:{isDOM:s||document.body};var te=require("lodash-es"),Ft=s=>s;typeof window<"u"&&typeof document<"u"&&(Ft=s=>{let t=document.createElement("div");return t.innerText=s,t.innerHTML});var je=s=>{(s?Array.isArray(s)?s:s instanceof HTMLAnchorElement?[s]:Array.from(s):Array.from(document.querySelectorAll("a"))).forEach(e=>{if(!e||e.dataset.anchorEnhanced==="true")return;e.dataset.anchorEnhanced="true";let n=e.getAttribute("class")||"";e.setAttribute("class",Ft(n));let r=e.getAttribute("aria-label");r&&e.setAttribute("aria-label",Ft(r));let i=e.querySelector(":scope > *");i&&(e.innerHTML="",e.appendChild(i));let a=e.getAttribute("href")||"";if(!a.startsWith("#")){try{if(new URL(a,window.location.href).origin!==window.location.origin)return}catch{return}e.addEventListener("click",o=>{o.preventDefault();let c=e.getAttribute("href")||"";try{let l=new URL(c,window.location.href);window.history.pushState({},"",l.pathname+l.search+l.hash),window.dispatchEvent(new PopStateEvent("popstate"))}catch(l){console.error("Invalid URL in anchor:",c,l)}})}})},Ue=(0,te.debounce)(je,50),ee=s=>{Ue(s)};var It=s=>{if(!s)return;let t=W("a",s);ee(t)};var Nt=D(require("dompurify"),1);var re=require("zustand/vanilla"),ne=D(require("dompurify"),1),N=(0,re.createStore)(s=>({params:{},query:{},setParams:t=>s(()=>({params:se(t)})),setQuery:t=>s(()=>({query:se(t)}))}));function se(s){let t={};for(let e in s)t[e]=ne.default.sanitize(s[e]);return t}var J=class{constructor(t,e){this.routes=[];this.routes=t,this.expectedParams=new Set(e),window.addEventListener("popstate",this.handlePopState.bind(this)),this.handlePopState()}handlePopState(){let t=window.location.pathname,e=window.location.search,n=this.parseQueryParams(e),r=this.findMatchingRoute(t,this.routes);if(r){if(r.routeto){this.navigate(r.routeto);return}let i=this.filterAndSanitizeParams(r.params);N.getState().setParams(i),N.getState().setQuery(n);let a=document.createElement("div");if(r.element?.(a,i,n),r.children){let o=t.slice(r.path.length),c=a.querySelector("#child");c&&this.renderChildren(r.children,o,c,i,n)}}else{let i=this.findMatchingRoute("*",this.routes);if(i){let a=this.filterAndSanitizeParams(i.params);N.getState().setParams(a),N.getState().setQuery(n);let o=document.createElement("div");i.element?.(o,a,n)}}}renderChildren(t,e,n,r,i){if(!t||t.length===0){let o=n.querySelector("#child");o&&o.remove();return}let a=this.findMatchingRoute(e,t);if(a){let o=document.createElement("div");o.id="child";let c={...r,...a.params},l=this.filterAndSanitizeParams(c);if(N.getState().setParams(l),N.getState().setQuery(i),a.element?.(o,l,i),n.appendChild(o),a.children){let u=e.slice(a.path.length);this.renderChildren(a.children,u,o,l,i)}}}parseQueryParams(t){let e={},n=new URLSearchParams(t);for(let[r,i]of n.entries())this.expectedParams.has(r)&&(e[r]=Nt.default.sanitize(i));return e}findMatchingRoute(t,e,n={}){for(let r of e){let i=r.path;if(i==="*")return r;{let o=[],c=i.replace(/:[^\s/]+/g,d=>(o.push(d.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),u=t.match(l);if(u){let d={...n};if(o.forEach((h,f)=>{d[h]=u[f+1]??""}),r.children){let h=t.slice(u[0].length),f=this.findMatchingRoute(h,r.children,d);if(f)return f}return{...r,params:d}}}}}filterAndSanitizeParams(t){if(!t)return{};let e={};for(let n in t)this.expectedParams.has(n)&&(e[n]=Nt.default.sanitize(t[n]??""));return e}navigate(t){history.pushState(null,"",t),this.handlePopState()}addRoute(t){this.routes.push(t)}};var xe=()=>({name:"ts-filebased-router",async buildStart(){if(typeof process>"u"||!process.versions?.node)return;let s=await import("fs/promises"),t=await import("path"),e=await Promise.resolve().then(()=>(Ae(),De)),n=t.resolve("src/pages"),r=t.resolve("src/gen"),i=t.resolve("src/routes"),a=t.join(r,"tsrouter.gen.ts"),o=t.join(i,"__root.ts"),c=process.env.NODE_ENV!=="production";async function l(E){try{await s.mkdir(E,{recursive:!0})}catch{}}function u(E,y){let T="/"+t.relative(y,E).replace(/\\/g,"/");return T=T.replace(/\.ts$/,"").replace(/\/index$/,"")||"/",T.replace(/\[(.+?)\]/g,":$1")}function d(E){return E.replace(/^\//,"").split("/").map(y=>y.startsWith(":")?y.slice(1):y).filter(Boolean).join("-")||"index"}function h(E,y){let v=t.relative(y,E).replace(/\\/g,"/").split("/").filter(Boolean),P=v[v.length-1].replace(".ts",""),R=v.length>1?v[v.length-2]:"";if(P==="index")return R?R.charAt(0).toUpperCase()+R.slice(1):"Index";if(P.startsWith("[")&&P.endsWith("]")){let k=P.slice(1,-1);return R.charAt(0).toUpperCase()+k.charAt(0).toUpperCase()+k.slice(1)}return P.charAt(0).toUpperCase()+P.slice(1)}async function f(E){let y=await s.readdir(E,{withFileTypes:!0}),T=[];for(let v of y){let P=t.join(E,v.name);if(v.isDirectory())T=T.concat(await f(P));else if(v.isFile()&&v.name.endsWith(".ts")){let R=u(P,n),k=d(R),_=h(P,n);T.push({file:P,route:R,routeName:k,importName:_})}}return T}function g(){return`import { useInitialDOM } from "@devwareng/vanilla-ts";
|
|
2
2
|
import App from "./App";
|
|
3
3
|
|
|
4
4
|
useInitialDOM("app", App)`}function L(){return`import App from './App'
|
package/dist/index.d.cts
CHANGED
|
@@ -11,7 +11,7 @@ declare const TSFilebasedRouter: () => Plugin;
|
|
|
11
11
|
type TSPurifier = (input: string | HTMLElement, config?: Config) => string;
|
|
12
12
|
declare const useTSPurifier: TSPurifier;
|
|
13
13
|
|
|
14
|
-
type TSEvent = (
|
|
14
|
+
type TSEvent = <K extends keyof HTMLElementEventMap>(target: string | HTMLElement | Document, eventType: K, handler: (event: HTMLElementEventMap[K]) => void) => void;
|
|
15
15
|
declare const useTSEvent: TSEvent;
|
|
16
16
|
|
|
17
17
|
type MustURL$1 = `/${string}`;
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ declare const TSFilebasedRouter: () => Plugin;
|
|
|
11
11
|
type TSPurifier = (input: string | HTMLElement, config?: Config) => string;
|
|
12
12
|
declare const useTSPurifier: TSPurifier;
|
|
13
13
|
|
|
14
|
-
type TSEvent = (
|
|
14
|
+
type TSEvent = <K extends keyof HTMLElementEventMap>(target: string | HTMLElement | Document, eventType: K, handler: (event: HTMLElementEventMap[K]) => void) => void;
|
|
15
15
|
declare const useTSEvent: TSEvent;
|
|
16
16
|
|
|
17
17
|
type MustURL$1 = `/${string}`;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function he(n){let e=n==null?"":String(n),t=e.toLowerCase();return(t.includes("<script")||t.includes("javascript:"))&&(e=""),e=e.replace(/url\(\s*(['"])?\s*\1?\s*\)/gi,""),e.replace(/<\s*(script|iframe|object|embed|link|style|meta|body)[^>]*>.*?<\s*\/\s*\1\s*>/gi,"").replace(/<\s*(script|iframe|object|embed|link|style|meta)[^>]*>/gi,"").replace(/\s+on\w+\s*=\s*(['"]).*?\1/gi,"").replace(/\s+on\w+\s*=\s*[^\s>]+/gi,"").replace(/\s(href|src)\s*=\s*(['"]?)\s*(javascript:|vbscript:|data:|file:)[^'">\s]*\2/gi,'$1="#"')}function _(n,...e){return n.reduce((t,r,o)=>{let i=o<e.length?he(e[o]):"";return t+r+i},"")}var ge=n=>n.replace(/<\/?(script|iframe|object|embed|link|meta|style|form|textarea|svg|math|body)[^>]*>/gi,"").replace(/<(?!\/?(b|i|em|strong|p|br|ul|ol|li|a|div|span|h1|h2|h3|h4|h5|h6|section|article|input|button)\b)[^>]*>/gi,"").replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/\s*style\s*=\s*("[^"]*"|'[^']*')/gi,"").replace(/<a\b([^>]*)href\s*=\s*(['"]?)(?!https?:|#)[^'"\s>]+(['"]?)([^>]*)>/gi,"<a$1$4>").replace(/\s+(href|src)\s*=\s*(['"]?)\s*(javascript:|data:)[^'"\s>]*/gi,"").replace(/<a\b([^>]*)\bhref\s*=\s*(['"])(\/blog|#blog)\2([^>]*)>/gi,'<a$1 href=$2$3$2 href-line="true"$4>').trim(),Te=n=>n?.map(e=>ge(e)).join("")??"";import I from"dompurify";var z=(n,e)=>{let r={...{ADD_TAGS:["my-custom-tag"]},...e};return typeof n=="string"?I.sanitize(n,r):I.sanitize(n.innerHTML,r)};var j=(n,e,t)=>{if(typeof n=="string"){let r=document.getElementById(n);r?r.addEventListener(e,t):console.warn(`Element with id '${n}' not found.`)}else n instanceof HTMLElement?n.addEventListener(e,t):n===document?document.addEventListener(e,t):console.warn("Invalid id parameter provided.")};import{createStore as Ee}from"zustand/vanilla";import q from"dompurify";function Se(n,e){let t=[],r=n.replace(/:[^/]+/g,s=>(t.push(s.slice(1)),"([^/]+)")),o=new RegExp(`^${r}$`),i=e.match(o),a={};return i&&t.forEach((s,c)=>{a[s]=q.sanitize(i[c+1]??"")}),a}function ye(n){let e={},t=new URLSearchParams(n);for(let[r,o]of t.entries())e[r]=q.sanitize(o);return e}var C=Ee((n,e)=>({params:{},query:{},setFromPattern:t=>{let r=window.location.pathname,o=Se(t,r),i=ye(window.location.search);n({params:o,query:i})},getParam:t=>e().params[t],getQuery:t=>e().query[t]}));function U(n){let e=C.getState();e.setFromPattern(n);let t=e.params,r=e.query;return{...t,...r}}var B=(n,e,t)=>{let r=document.querySelectorAll(n);return r.forEach(o=>{o.addEventListener(e,t)}),()=>{r.forEach(o=>{o.removeEventListener(e,t)})}};import W from"dompurify";var G=(n,e,t={},r)=>{let o={USE_PROFILES:{svg:!0,html:!0},ALLOWED_TAGS:["svg","path","circle","rect","line","polyline","polygon","g","main","div","h1","h2","h3","h4","h5","h6","p","button","span","a","img","input","ul","li","i","label","form"],ALLOWED_ATTR:["class","id","href","src","alt","title","fill","stroke","stroke-width","viewBox","xmlns","d","x","y","cx","cy","r","width","height","type","name","value","placeholder","data-click","data-change","data-select","data-classlist","data-hover","data-submit","data-key","data-event"],FORBID_TAGS:["script","iframe","foreignObject","body","html"],FORBID_ATTR:["style","xlink:href"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|ftp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,...r};W.addHook("uponSanitizeAttribute",(s,c)=>{let l=(c.attrName||"").toLowerCase(),u=(c.attrValue??"").toString().trim();if(l.startsWith("on")){c.keepAttr=!1;return}if(/^data-(click|change|submit|select|hover|classlist|key|event)$/.test(l)){c.keepAttr=!0;return}if(s.nodeName.toLowerCase()==="img"&&l==="src"){/^https?:\/\//i.test(u)||/^\/(?!\/)/.test(u)||/^data:image\/(png|jpeg|jpg|gif|webp);base64,/i.test(u)||(c.keepAttr=!1);return}if(l==="class"){let v=u.split(/\s+/).filter(Boolean).filter(p=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]*$/.test(p)){if(/^bg-\[url\(.*\)\]$/.test(p)){let A=p.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return A===""||/^https?:\/\//i.test(A)||/^\/(?!\/)/.test(A)||/^\.{0,2}\//.test(A)}return/^bg-\[\]$/.test(p),!0}return!1});c.attrValue=v.join(" ");return}});let i=W.sanitize(e,{...o,RETURN_DOM_FRAGMENT:!0});for(;n.firstChild;)n.removeChild(n.firstChild);n.appendChild(i);let a=(s,c)=>{n.querySelectorAll(`[${s}]`).forEach(l=>{let u=l.getAttribute(s);u&&Object.prototype.hasOwnProperty.call(t,u)&&l.addEventListener(c,d=>{c==="submit"&&d.preventDefault(),t[u](d)})})};a("data-click","click"),a("data-change","change"),a("data-select","select"),a("data-submit","submit"),n.querySelectorAll("[data-key]").forEach(s=>{let c=s.dataset.key,l=s.dataset.event??"click";c&&Object.prototype.hasOwnProperty.call(t,c)&&s.addEventListener(l,t[c])}),n.querySelectorAll("[data-hover]").forEach(s=>{let c=s.dataset.hover;c&&Object.prototype.hasOwnProperty.call(t,c)&&(s.addEventListener("mouseenter",t[c]),s.addEventListener("mouseleave",t[c]))}),n.querySelectorAll("[data-classlist]").forEach(s=>{let c=s.dataset.classlist;/^[a-zA-Z0-9\-\s:_]+$/.test(c)&&s.classList.add(...c.split(/\s+/))})};import V from"dompurify";var H=null,Q=(n,e)=>{if(typeof document>"u")return;let t=document.getElementById(n);if(!t)return;V.addHook("uponSanitizeAttribute",(a,s)=>{let c=(s.attrName||"").toLowerCase(),l=(s.attrValue??"").toString().trim();if(c.startsWith("on")){s.keepAttr=!1;return}if((c==="href"||c==="src")&&/^(javascript:|vbscript:|data:|file:|about:)/i.test(l)){s.keepAttr=!1;return}if(c==="class"){let d=l.split(/\s+/).filter(Boolean).filter(v=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]+$/.test(v)){if(/^bg-\[url\(.*\)\]$/.test(v)){let p=v.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return p===""||/^https?:\/\//i.test(p)||/^\/(?!\/)/.test(p)||/^\.{0,2}\//.test(p)}return!0}return!1});s.attrValue=d.join(" ");return}if(c==="style"){s.keepAttr=!1;return}});let r=t.cloneNode(!0),o=V.sanitize(r.innerHTML,{USE_PROFILES:{html:!0},ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br","form","button","input","label"],ALLOWED_ATTR:["href","src","alt","title","class","id","type","name","value","placeholder","data-click","data-change","data-submit","data-select","data-hover","data-classlist"],FORBID_TAGS:["script","iframe","object","embed","body","html","svg","math","link","meta"],ALLOW_DATA_ATTR:!0,KEEP_CONTENT:!1,RETURN_DOM_FRAGMENT:!0}),i=Array.from(o.childNodes).map(a=>a.outerHTML||a.textContent||"").join("");if(H!==null&&i!==H){let a=document.createElement("div");e(a);let c=new DOMParser().parseFromString(H,"text/html");for(;t.firstChild;)t.removeChild(t.firstChild);c.body.childNodes.forEach(l=>t.appendChild(l.cloneNode(!0)))}else{for(H=i;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(o),e(t)}};import Y from"dompurify";typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",n=>{let e=n.state;e?.scrollPosition!==void 0&&window.scrollTo(0,e.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var Z=(n,e,t,r="",o=null)=>{if(!n)return;let i=Y.sanitize(e,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=Y.sanitize(t,{USE_PROFILES:{html:!1}});n.setAttribute("href",i),n.setAttribute("aria-label",a),r&&(n.className=r.trim()),o&&n.replaceChildren(o),typeof window<"u"&&n.addEventListener("click",s=>{s.preventDefault();let l=s.currentTarget.getAttribute("href");if(l){let u=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:u},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};import R from"dompurify";var J=(n="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",e="'self' 'nonce-rAnd0m123'",t="'none'",r="'self' https://fonts.googleapis.com https://fonts.gstatic.com",o="'self' https://blogger.googleusercontent.com",i=["'self'","https://fonts.googleapis.com","https://fonts.gstatic.com","https://www.google.com/maps/"],a="'self' https://www.youtube.com",s="'self'",c="/csp-report",l=!1)=>{let u=()=>{try{let d=document.querySelector('meta[http-equiv="Content-Security-Policy"]');d||(d=document.createElement("meta"),d.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(d));let v=l?`report-uri ${c};`:"";d.setAttribute("content",`default-src 'self'; script-src ${n}; style-src ${e}; object-src ${t}; font-src ${r}; img-src ${o}; connect-src ${i.join(" ")}; frame-src ${a}; base-uri ${s}; ${v}`)}catch(d){console.error("Error adding CSP meta element:",d)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",u):u()};var K=(n,e)=>{let t={name:R.sanitize(n.name||""),title:R.sanitize(n.title||""),description:R.sanitize(n.description||"Default description"),author:R.sanitize(n.author||""),favicon:n.favicon},r=T=>{t.name=R.sanitize(T),M("name",t.name)},o=T=>{t.title=R.sanitize(T),document.title=t.title},i=T=>{t.description=R.sanitize(T),M("description",t.description)},a=T=>{t.author=R.sanitize(T),M("author",t.author)},s=T=>{t.favicon=R.sanitize(T);let w=document.querySelector('link[rel="icon"]');w||(w=document.createElement("link"),w.rel="icon",document.head.appendChild(w)),w.href=t.favicon},c=()=>t.name,l=()=>t.title,u=()=>t.description,d=()=>t.author,v=()=>t.favicon,p=()=>t,A=(T,w)=>{let L=document.createElement("meta");L.setAttribute("name",T),L.setAttribute("content",w),document.head.appendChild(L)},M=(T,w)=>{let L=document.querySelector(`meta[name="${T}"]`);L?L.setAttribute("content",w):A(T,w)},O=()=>{t.title&&(document.title=t.title),t.name&&M("name",t.name),t.description&&M("description",t.description),t.author&&M("author",t.author),t.favicon&&s(t.favicon)};return e&&J(e.scriptSrc,e.styleSrc,e.objectSrc,Array.isArray(e.connectSrc)?e.connectSrc.join(" "):e.connectSrc,e.reportOnly!==void 0?String(e.reportOnly):void 0),O(),{setName:r,setTitle:o,setDescription:i,setAuthor:a,setFavicon:s,getName:c,getTitle:l,getDescription:u,getAuthor:d,getFavicon:v,getAllMetaData:p,appendMetaTagsToHead:O}};import ve from"dompurify";var $=(n,e,t,r,o)=>{let i=`#${n}`,a=e.querySelectorAll(i);if(a.length===0)throw new Error(`[useTSComponent] No element found with id '${n}' in the given parent.`);if(a.length>1)throw new Error(`[useTSComponent] Duplicate id '${n}' detected. Found ${a.length} elements.`);let s=a[0];s.innerHTML=ve.sanitize(s.innerHTML,{USE_PROFILES:{html:!0}}),t(s,r,o)};var X=(n,e,t,r=[])=>{let o=new Set;n.forEach((i,a)=>{if(o.has(i)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${i}" \u2014 skipping.`);return}o.add(i);let s=e.querySelectorAll(`#${i}`);if(s.length>1){console.warn(`[useTSCollection] Duplicate ID in DOM: "${i}" (${s.length} elements found) \u2014 skipping component mount.`);return}let c=t[a],l=Array.isArray(r)?r[a]:void 0;typeof c=="function"?$(i,e,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var P=(n,e)=>{let r=(e??document).querySelectorAll(n);if(r.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${n}'`),null;if(n.startsWith("#")&&r.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${n}'. Found ${r.length} elements with this ID.`);return r[0]}return r.length>1&&process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] Multiple elements found for selector: '${n}'. Returning the first one.`),r[0]};import{jwtDecode as we}from"jwt-decode";var ee=(n,e)=>{let t=localStorage.getItem("token");if(!t)return window.location.href=e,null;try{let r=we(t),o=Date.now()/1e3;return r.exp&&r.exp<o&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=e),null}catch(r){return console.error("Invalid token:",r),window.location.href=e,null}};var k=(n,e,t)=>{n.forEach(r=>{e.forEach(o=>{r.addEventListener(o,i=>{t(r,i)})})})};var te=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var ne=(n,e)=>{let t=document.querySelector(`#${n}`)||document.querySelector(`.${n}`);if(!t)return;let r=window.location.pathname.replace(/\/$/,"");for(let o of e){let i=o.path.replace(/\/$/,"");if(r===i||r.startsWith(`${i}/`)){o.component(t);break}}};function re(n,e){let t=window.location.pathname.replace(/\/$/,"");e.routes.forEach(r=>{r.children?.length&&r.children.forEach(o=>{let i=o.path.replace(/\/$/,"");if(t===i||t.startsWith(`${i}/`)){let a=n.querySelector(`#${o.outlet}`)||n.querySelector(`.${o.outlet}`);a instanceof HTMLElement&&o.element&&o.element(a)}})})}import{createStore as Le}from"zustand/vanilla";function oe(n){let e=Le(()=>({value:n})),t=new Set;return{get:()=>e.getState().value,set:r=>{e.setState({value:r}),t.forEach(o=>o(r))},subscribe:r=>(t.add(r),r(e.getState().value),()=>t.delete(r))}}function se(n){let e=n();typeof e=="function"&&e()}var ie=async()=>{let n="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",e="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",t=r=>new Promise((o,i)=>{let a=document.createElement("script");a.src=r,a.onload=()=>o(),a.onerror=()=>i(new Error(`Failed to load ${r}`)),document.head.appendChild(a)});await t(n),await t(e),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},ae=n=>new Promise((e,t)=>{let r=document.createElement("script");r.type="text/python",r.src=`/src/python/${n}`,r.onload=()=>e(),r.onerror=()=>t(new Error(`Failed to load ${n}`)),document.body.appendChild(r)});function ce(n){let e=null;return async(t,r)=>{try{if(!e){let o=await n();e=o.default||o}if(typeof e=="function")return e(t,r);if(e instanceof HTMLElement){let o=e.cloneNode(!0);return t?.appendChild(o),o}if(typeof e=="object"&&e!==null&&"render"in e&&typeof e.render=="function")return e.render(t,r);console.warn("useTSLazy: Unsupported module type",e)}catch(o){console.error("useTSLazy failed:",o)}}}var le=n=>typeof window>"u"?{isDOM:null}:{isDOM:n||document.body};import{debounce as Me}from"lodash-es";var N=n=>n;typeof window<"u"&&typeof document<"u"&&(N=n=>{let e=document.createElement("div");return e.innerText=n,e.innerHTML});var Re=n=>{(n?Array.isArray(n)?n:n instanceof HTMLAnchorElement?[n]:Array.from(n):Array.from(document.querySelectorAll("a"))).forEach(t=>{if(!t||t.dataset.anchorEnhanced==="true")return;t.dataset.anchorEnhanced="true";let r=t.getAttribute("class")||"";t.setAttribute("class",N(r));let o=t.getAttribute("aria-label");o&&t.setAttribute("aria-label",N(o));let i=t.querySelector(":scope > *");i&&(t.innerHTML="",t.appendChild(i));let a=t.getAttribute("href")||"";if(!a.startsWith("#")){try{if(new URL(a,window.location.href).origin!==window.location.origin)return}catch{return}t.addEventListener("click",s=>{s.preventDefault();let c=t.getAttribute("href")||"";try{let l=new URL(c,window.location.href);window.history.pushState({},"",l.pathname+l.search+l.hash),window.dispatchEvent(new PopStateEvent("popstate"))}catch(l){console.error("Invalid URL in anchor:",c,l)}})}})},Ae=Me(Re,50),ue=n=>{Ae(n)};var de=n=>{if(!n)return;let e=P("a",n);ue(e)};import pe from"dompurify";import{createStore as be}from"zustand/vanilla";import xe from"dompurify";var b=be(n=>({params:{},query:{},setParams:e=>n(()=>({params:me(e)})),setQuery:e=>n(()=>({query:me(e)}))}));function me(n){let e={};for(let t in n)e[t]=xe.sanitize(n[t]);return e}var F=class{constructor(e,t){this.routes=[];this.routes=e,this.expectedParams=new Set(t),window.addEventListener("popstate",this.handlePopState.bind(this)),this.handlePopState()}handlePopState(){let e=window.location.pathname,t=window.location.search,r=this.parseQueryParams(t),o=this.findMatchingRoute(e,this.routes);if(o){if(o.routeto){this.navigate(o.routeto);return}let i=this.filterAndSanitizeParams(o.params);b.getState().setParams(i),b.getState().setQuery(r);let a=document.createElement("div");if(o.element?.(a,i,r),o.children){let s=e.slice(o.path.length),c=a.querySelector("#child");c&&this.renderChildren(o.children,s,c,i,r)}}else{let i=this.findMatchingRoute("*",this.routes);if(i){let a=this.filterAndSanitizeParams(i.params);b.getState().setParams(a),b.getState().setQuery(r);let s=document.createElement("div");i.element?.(s,a,r)}}}renderChildren(e,t,r,o,i){if(!e||e.length===0){let s=r.querySelector("#child");s&&s.remove();return}let a=this.findMatchingRoute(t,e);if(a){let s=document.createElement("div");s.id="child";let c={...o,...a.params},l=this.filterAndSanitizeParams(c);if(b.getState().setParams(l),b.getState().setQuery(i),a.element?.(s,l,i),r.appendChild(s),a.children){let u=t.slice(a.path.length);this.renderChildren(a.children,u,s,l,i)}}}parseQueryParams(e){let t={},r=new URLSearchParams(e);for(let[o,i]of r.entries())this.expectedParams.has(o)&&(t[o]=pe.sanitize(i));return t}findMatchingRoute(e,t,r={}){for(let o of t){let i=o.path;if(i==="*")return o;{let s=[],c=i.replace(/:[^\s/]+/g,d=>(s.push(d.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),u=e.match(l);if(u){let d={...r};if(s.forEach((v,p)=>{d[v]=u[p+1]??""}),o.children){let v=e.slice(u[0].length),p=this.findMatchingRoute(v,o.children,d);if(p)return p}return{...o,params:d}}}}}filterAndSanitizeParams(e){if(!e)return{};let t={};for(let r in e)this.expectedParams.has(r)&&(t[r]=pe.sanitize(e[r]??""));return t}navigate(e){history.pushState(null,"",e),this.handlePopState()}addRoute(e){this.routes.push(e)}};var Pe=()=>({name:"ts-filebased-router",async buildStart(){if(typeof process>"u"||!process.versions?.node)return;let n=await import("fs/promises"),e=await import("path"),t=await import("./esm-KRNKVVL7.js"),r=e.resolve("src/pages"),o=e.resolve("src/gen"),i=e.resolve("src/routes"),a=e.join(o,"tsrouter.gen.ts"),s=e.join(i,"__root.ts"),c=process.env.NODE_ENV!=="production";async function l(m){try{await n.mkdir(m,{recursive:!0})}catch{}}function u(m,f){let h="/"+e.relative(f,m).replace(/\\/g,"/");return h=h.replace(/\.ts$/,"").replace(/\/index$/,"")||"/",h.replace(/\[(.+?)\]/g,":$1")}function d(m){return m.replace(/^\//,"").split("/").map(f=>f.startsWith(":")?f.slice(1):f).filter(Boolean).join("-")||"index"}function v(m,f){let E=e.relative(f,m).replace(/\\/g,"/").split("/").filter(Boolean),S=E[E.length-1].replace(".ts",""),y=E.length>1?E[E.length-2]:"";if(S==="index")return y?y.charAt(0).toUpperCase()+y.slice(1):"Index";if(S.startsWith("[")&&S.endsWith("]")){let x=S.slice(1,-1);return y.charAt(0).toUpperCase()+x.charAt(0).toUpperCase()+x.slice(1)}return S.charAt(0).toUpperCase()+S.slice(1)}async function p(m){let f=await n.readdir(m,{withFileTypes:!0}),h=[];for(let E of f){let S=e.join(m,E.name);if(E.isDirectory())h=h.concat(await p(S));else if(E.isFile()&&E.name.endsWith(".ts")){let y=u(S,r),x=d(y),g=v(S,r);h.push({file:S,route:y,routeName:x,importName:g})}}return h}function A(){return`import { useInitialDOM } from "@devwareng/vanilla-ts";
|
|
1
|
+
function he(n){let e=n==null?"":String(n),t=e.toLowerCase();return(t.includes("<script")||t.includes("javascript:"))&&(e=""),e=e.replace(/url\(\s*(['"])?\s*\1?\s*\)/gi,""),e.replace(/<\s*(script|iframe|object|embed|link|style|meta|body)[^>]*>.*?<\s*\/\s*\1\s*>/gi,"").replace(/<\s*(script|iframe|object|embed|link|style|meta)[^>]*>/gi,"").replace(/\s+on\w+\s*=\s*(['"]).*?\1/gi,"").replace(/\s+on\w+\s*=\s*[^\s>]+/gi,"").replace(/\s(href|src)\s*=\s*(['"]?)\s*(javascript:|vbscript:|data:|file:)[^'">\s]*\2/gi,'$1="#"')}function _(n,...e){return n.reduce((t,r,o)=>{let i=o<e.length?he(e[o]):"";return t+r+i},"")}var ge=n=>n.replace(/<\/?(script|iframe|object|embed|link|meta|style|form|textarea|svg|math|body)[^>]*>/gi,"").replace(/<(?!\/?(b|i|em|strong|p|br|ul|ol|li|a|div|span|h1|h2|h3|h4|h5|h6|section|article|input|button)\b)[^>]*>/gi,"").replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/\s*style\s*=\s*("[^"]*"|'[^']*')/gi,"").replace(/<a\b([^>]*)href\s*=\s*(['"]?)(?!https?:|#)[^'"\s>]+(['"]?)([^>]*)>/gi,"<a$1$4>").replace(/\s+(href|src)\s*=\s*(['"]?)\s*(javascript:|data:)[^'"\s>]*/gi,"").replace(/<a\b([^>]*)\bhref\s*=\s*(['"])(\/blog|#blog)\2([^>]*)>/gi,'<a$1 href=$2$3$2 href-line="true"$4>').trim(),Te=n=>n?.map(e=>ge(e)).join("")??"";import I from"dompurify";var z=(n,e)=>{let r={...{ADD_TAGS:["my-custom-tag"]},...e};return typeof n=="string"?I.sanitize(n,r):I.sanitize(n.innerHTML,r)};var q=(n,e,t)=>{if(typeof n=="string"){let r=document.getElementById(n);r?r.addEventListener(e,t):console.warn(`Element with id '${n}' not found.`)}else n instanceof HTMLElement?n.addEventListener(e,t):n===document?document.addEventListener(e,t):console.warn("Invalid target parameter provided.")};import{createStore as Se}from"zustand/vanilla";import U from"dompurify";function Ee(n,e){let t=[],r=n.replace(/:[^/]+/g,s=>(t.push(s.slice(1)),"([^/]+)")),o=new RegExp(`^${r}$`),i=e.match(o),a={};return i&&t.forEach((s,c)=>{a[s]=U.sanitize(i[c+1]??"")}),a}function ye(n){let e={},t=new URLSearchParams(n);for(let[r,o]of t.entries())e[r]=U.sanitize(o);return e}var C=Se((n,e)=>({params:{},query:{},setFromPattern:t=>{let r=window.location.pathname,o=Ee(t,r),i=ye(window.location.search);n({params:o,query:i})},getParam:t=>e().params[t],getQuery:t=>e().query[t]}));function j(n){let e=C.getState();e.setFromPattern(n);let t=e.params,r=e.query;return{...t,...r}}var B=(n,e,t)=>{let r=document.querySelectorAll(n);return r.forEach(o=>{o.addEventListener(e,t)}),()=>{r.forEach(o=>{o.removeEventListener(e,t)})}};import W from"dompurify";var G=(n,e,t={},r)=>{let o={USE_PROFILES:{svg:!0,html:!0},ALLOWED_TAGS:["svg","path","circle","rect","line","polyline","polygon","g","main","div","h1","h2","h3","h4","h5","h6","p","button","span","a","img","input","ul","li","i","label","form"],ALLOWED_ATTR:["class","id","href","src","alt","title","fill","stroke","stroke-width","viewBox","xmlns","d","x","y","cx","cy","r","width","height","type","name","value","placeholder","data-click","data-change","data-select","data-classlist","data-hover","data-submit","data-key","data-event"],FORBID_TAGS:["script","iframe","foreignObject","body","html"],FORBID_ATTR:["style","xlink:href"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|ftp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,...r};W.addHook("uponSanitizeAttribute",(s,c)=>{let l=(c.attrName||"").toLowerCase(),u=(c.attrValue??"").toString().trim();if(l.startsWith("on")){c.keepAttr=!1;return}if(/^data-(click|change|submit|select|hover|classlist|key|event)$/.test(l)){c.keepAttr=!0;return}if(s.nodeName.toLowerCase()==="img"&&l==="src"){/^https?:\/\//i.test(u)||/^\/(?!\/)/.test(u)||/^data:image\/(png|jpeg|jpg|gif|webp);base64,/i.test(u)||(c.keepAttr=!1);return}if(l==="class"){let v=u.split(/\s+/).filter(Boolean).filter(p=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]*$/.test(p)){if(/^bg-\[url\(.*\)\]$/.test(p)){let A=p.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return A===""||/^https?:\/\//i.test(A)||/^\/(?!\/)/.test(A)||/^\.{0,2}\//.test(A)}return/^bg-\[\]$/.test(p),!0}return!1});c.attrValue=v.join(" ");return}});let i=W.sanitize(e,{...o,RETURN_DOM_FRAGMENT:!0});for(;n.firstChild;)n.removeChild(n.firstChild);n.appendChild(i);let a=(s,c)=>{n.querySelectorAll(`[${s}]`).forEach(l=>{let u=l.getAttribute(s);u&&Object.prototype.hasOwnProperty.call(t,u)&&l.addEventListener(c,d=>{c==="submit"&&d.preventDefault(),t[u](d)})})};a("data-click","click"),a("data-change","change"),a("data-select","select"),a("data-submit","submit"),n.querySelectorAll("[data-key]").forEach(s=>{let c=s.dataset.key,l=s.dataset.event??"click";c&&Object.prototype.hasOwnProperty.call(t,c)&&s.addEventListener(l,t[c])}),n.querySelectorAll("[data-hover]").forEach(s=>{let c=s.dataset.hover;c&&Object.prototype.hasOwnProperty.call(t,c)&&(s.addEventListener("mouseenter",t[c]),s.addEventListener("mouseleave",t[c]))}),n.querySelectorAll("[data-classlist]").forEach(s=>{let c=s.dataset.classlist;/^[a-zA-Z0-9\-\s:_]+$/.test(c)&&s.classList.add(...c.split(/\s+/))})};import V from"dompurify";var H=null,Q=(n,e)=>{if(typeof document>"u")return;let t=document.getElementById(n);if(!t)return;V.addHook("uponSanitizeAttribute",(a,s)=>{let c=(s.attrName||"").toLowerCase(),l=(s.attrValue??"").toString().trim();if(c.startsWith("on")){s.keepAttr=!1;return}if((c==="href"||c==="src")&&/^(javascript:|vbscript:|data:|file:|about:)/i.test(l)){s.keepAttr=!1;return}if(c==="class"){let d=l.split(/\s+/).filter(Boolean).filter(v=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]+$/.test(v)){if(/^bg-\[url\(.*\)\]$/.test(v)){let p=v.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return p===""||/^https?:\/\//i.test(p)||/^\/(?!\/)/.test(p)||/^\.{0,2}\//.test(p)}return!0}return!1});s.attrValue=d.join(" ");return}if(c==="style"){s.keepAttr=!1;return}});let r=t.cloneNode(!0),o=V.sanitize(r.innerHTML,{USE_PROFILES:{html:!0},ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br","form","button","input","label"],ALLOWED_ATTR:["href","src","alt","title","class","id","type","name","value","placeholder","data-click","data-change","data-submit","data-select","data-hover","data-classlist"],FORBID_TAGS:["script","iframe","object","embed","body","html","svg","math","link","meta"],ALLOW_DATA_ATTR:!0,KEEP_CONTENT:!1,RETURN_DOM_FRAGMENT:!0}),i=Array.from(o.childNodes).map(a=>a.outerHTML||a.textContent||"").join("");if(H!==null&&i!==H){let a=document.createElement("div");e(a);let c=new DOMParser().parseFromString(H,"text/html");for(;t.firstChild;)t.removeChild(t.firstChild);c.body.childNodes.forEach(l=>t.appendChild(l.cloneNode(!0)))}else{for(H=i;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(o),e(t)}};import K from"dompurify";typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",n=>{let e=n.state;e?.scrollPosition!==void 0&&window.scrollTo(0,e.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var Y=(n,e,t,r="",o=null)=>{if(!n)return;let i=K.sanitize(e,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=K.sanitize(t,{USE_PROFILES:{html:!1}});n.setAttribute("href",i),n.setAttribute("aria-label",a),r&&(n.className=r.trim()),o&&n.replaceChildren(o),typeof window<"u"&&n.addEventListener("click",s=>{s.preventDefault();let l=s.currentTarget.getAttribute("href");if(l){let u=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:u},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};import R from"dompurify";var Z=(n="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",e="'self' 'nonce-rAnd0m123'",t="'none'",r="'self' https://fonts.googleapis.com https://fonts.gstatic.com",o="'self' https://blogger.googleusercontent.com",i=["'self'","https://fonts.googleapis.com","https://fonts.gstatic.com","https://www.google.com/maps/"],a="'self' https://www.youtube.com",s="'self'",c="/csp-report",l=!1)=>{let u=()=>{try{let d=document.querySelector('meta[http-equiv="Content-Security-Policy"]');d||(d=document.createElement("meta"),d.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(d));let v=l?`report-uri ${c};`:"";d.setAttribute("content",`default-src 'self'; script-src ${n}; style-src ${e}; object-src ${t}; font-src ${r}; img-src ${o}; connect-src ${i.join(" ")}; frame-src ${a}; base-uri ${s}; ${v}`)}catch(d){console.error("Error adding CSP meta element:",d)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",u):u()};var J=(n,e)=>{let t={name:R.sanitize(n.name||""),title:R.sanitize(n.title||""),description:R.sanitize(n.description||"Default description"),author:R.sanitize(n.author||""),favicon:n.favicon},r=T=>{t.name=R.sanitize(T),M("name",t.name)},o=T=>{t.title=R.sanitize(T),document.title=t.title},i=T=>{t.description=R.sanitize(T),M("description",t.description)},a=T=>{t.author=R.sanitize(T),M("author",t.author)},s=T=>{t.favicon=R.sanitize(T);let w=document.querySelector('link[rel="icon"]');w||(w=document.createElement("link"),w.rel="icon",document.head.appendChild(w)),w.href=t.favicon},c=()=>t.name,l=()=>t.title,u=()=>t.description,d=()=>t.author,v=()=>t.favicon,p=()=>t,A=(T,w)=>{let L=document.createElement("meta");L.setAttribute("name",T),L.setAttribute("content",w),document.head.appendChild(L)},M=(T,w)=>{let L=document.querySelector(`meta[name="${T}"]`);L?L.setAttribute("content",w):A(T,w)},D=()=>{t.title&&(document.title=t.title),t.name&&M("name",t.name),t.description&&M("description",t.description),t.author&&M("author",t.author),t.favicon&&s(t.favicon)};return e&&Z(e.scriptSrc,e.styleSrc,e.objectSrc,Array.isArray(e.connectSrc)?e.connectSrc.join(" "):e.connectSrc,e.reportOnly!==void 0?String(e.reportOnly):void 0),D(),{setName:r,setTitle:o,setDescription:i,setAuthor:a,setFavicon:s,getName:c,getTitle:l,getDescription:u,getAuthor:d,getFavicon:v,getAllMetaData:p,appendMetaTagsToHead:D}};import ve from"dompurify";var $=(n,e,t,r,o)=>{let i=`#${n}`,a=e.querySelectorAll(i);if(a.length===0)throw new Error(`[useTSComponent] No element found with id '${n}' in the given parent.`);if(a.length>1)throw new Error(`[useTSComponent] Duplicate id '${n}' detected. Found ${a.length} elements.`);let s=a[0];s.innerHTML=ve.sanitize(s.innerHTML,{USE_PROFILES:{html:!0}}),t(s,r,o)};var X=(n,e,t,r=[])=>{let o=new Set;n.forEach((i,a)=>{if(o.has(i)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${i}" \u2014 skipping.`);return}o.add(i);let s=e.querySelectorAll(`#${i}`);if(s.length>1){console.warn(`[useTSCollection] Duplicate ID in DOM: "${i}" (${s.length} elements found) \u2014 skipping component mount.`);return}let c=t[a],l=Array.isArray(r)?r[a]:void 0;typeof c=="function"?$(i,e,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var P=(n,e)=>{let r=(e??document).querySelectorAll(n);if(r.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${n}'`),null;if(n.startsWith("#")&&r.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${n}'. Found ${r.length} elements with this ID.`);return r[0]}return r.length>1&&process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] Multiple elements found for selector: '${n}'. Returning the first one.`),r[0]};import{jwtDecode as we}from"jwt-decode";var ee=(n,e)=>{let t=localStorage.getItem("token");if(!t)return window.location.href=e,null;try{let r=we(t),o=Date.now()/1e3;return r.exp&&r.exp<o&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=e),null}catch(r){return console.error("Invalid token:",r),window.location.href=e,null}};var k=(n,e,t)=>{n.forEach(r=>{e.forEach(o=>{r.addEventListener(o,i=>{t(r,i)})})})};var te=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var ne=(n,e)=>{let t=document.querySelector(`#${n}`)||document.querySelector(`.${n}`);if(!t)return;let r=window.location.pathname.replace(/\/$/,"");for(let o of e){let i=o.path.replace(/\/$/,"");if(r===i||r.startsWith(`${i}/`)){o.component(t);break}}};function re(n,e){let t=window.location.pathname.replace(/\/$/,"");e.routes.forEach(r=>{r.children?.length&&r.children.forEach(o=>{let i=o.path.replace(/\/$/,"");if(t===i||t.startsWith(`${i}/`)){let a=n.querySelector(`#${o.outlet}`)||n.querySelector(`.${o.outlet}`);a instanceof HTMLElement&&o.element&&o.element(a)}})})}import{createStore as Le}from"zustand/vanilla";function oe(n){let e=Le(()=>({value:n})),t=new Set;return{get:()=>e.getState().value,set:r=>{e.setState({value:r}),t.forEach(o=>o(r))},subscribe:r=>(t.add(r),r(e.getState().value),()=>t.delete(r))}}function se(n){let e=n();typeof e=="function"&&e()}var ie=async()=>{let n="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",e="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",t=r=>new Promise((o,i)=>{let a=document.createElement("script");a.src=r,a.onload=()=>o(),a.onerror=()=>i(new Error(`Failed to load ${r}`)),document.head.appendChild(a)});await t(n),await t(e),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},ae=n=>new Promise((e,t)=>{let r=document.createElement("script");r.type="text/python",r.src=`/src/python/${n}`,r.onload=()=>e(),r.onerror=()=>t(new Error(`Failed to load ${n}`)),document.body.appendChild(r)});function ce(n){let e=null;return async(t,r)=>{try{if(!e){let o=await n();e=o.default||o}if(typeof e=="function")return e(t,r);if(e instanceof HTMLElement){let o=e.cloneNode(!0);return t?.appendChild(o),o}if(typeof e=="object"&&e!==null&&"render"in e&&typeof e.render=="function")return e.render(t,r);console.warn("useTSLazy: Unsupported module type",e)}catch(o){console.error("useTSLazy failed:",o)}}}var le=n=>typeof window>"u"?{isDOM:null}:{isDOM:n||document.body};import{debounce as Me}from"lodash-es";var N=n=>n;typeof window<"u"&&typeof document<"u"&&(N=n=>{let e=document.createElement("div");return e.innerText=n,e.innerHTML});var Re=n=>{(n?Array.isArray(n)?n:n instanceof HTMLAnchorElement?[n]:Array.from(n):Array.from(document.querySelectorAll("a"))).forEach(t=>{if(!t||t.dataset.anchorEnhanced==="true")return;t.dataset.anchorEnhanced="true";let r=t.getAttribute("class")||"";t.setAttribute("class",N(r));let o=t.getAttribute("aria-label");o&&t.setAttribute("aria-label",N(o));let i=t.querySelector(":scope > *");i&&(t.innerHTML="",t.appendChild(i));let a=t.getAttribute("href")||"";if(!a.startsWith("#")){try{if(new URL(a,window.location.href).origin!==window.location.origin)return}catch{return}t.addEventListener("click",s=>{s.preventDefault();let c=t.getAttribute("href")||"";try{let l=new URL(c,window.location.href);window.history.pushState({},"",l.pathname+l.search+l.hash),window.dispatchEvent(new PopStateEvent("popstate"))}catch(l){console.error("Invalid URL in anchor:",c,l)}})}})},Ae=Me(Re,50),ue=n=>{Ae(n)};var de=n=>{if(!n)return;let e=P("a",n);ue(e)};import pe from"dompurify";import{createStore as be}from"zustand/vanilla";import xe from"dompurify";var b=be(n=>({params:{},query:{},setParams:e=>n(()=>({params:me(e)})),setQuery:e=>n(()=>({query:me(e)}))}));function me(n){let e={};for(let t in n)e[t]=xe.sanitize(n[t]);return e}var F=class{constructor(e,t){this.routes=[];this.routes=e,this.expectedParams=new Set(t),window.addEventListener("popstate",this.handlePopState.bind(this)),this.handlePopState()}handlePopState(){let e=window.location.pathname,t=window.location.search,r=this.parseQueryParams(t),o=this.findMatchingRoute(e,this.routes);if(o){if(o.routeto){this.navigate(o.routeto);return}let i=this.filterAndSanitizeParams(o.params);b.getState().setParams(i),b.getState().setQuery(r);let a=document.createElement("div");if(o.element?.(a,i,r),o.children){let s=e.slice(o.path.length),c=a.querySelector("#child");c&&this.renderChildren(o.children,s,c,i,r)}}else{let i=this.findMatchingRoute("*",this.routes);if(i){let a=this.filterAndSanitizeParams(i.params);b.getState().setParams(a),b.getState().setQuery(r);let s=document.createElement("div");i.element?.(s,a,r)}}}renderChildren(e,t,r,o,i){if(!e||e.length===0){let s=r.querySelector("#child");s&&s.remove();return}let a=this.findMatchingRoute(t,e);if(a){let s=document.createElement("div");s.id="child";let c={...o,...a.params},l=this.filterAndSanitizeParams(c);if(b.getState().setParams(l),b.getState().setQuery(i),a.element?.(s,l,i),r.appendChild(s),a.children){let u=t.slice(a.path.length);this.renderChildren(a.children,u,s,l,i)}}}parseQueryParams(e){let t={},r=new URLSearchParams(e);for(let[o,i]of r.entries())this.expectedParams.has(o)&&(t[o]=pe.sanitize(i));return t}findMatchingRoute(e,t,r={}){for(let o of t){let i=o.path;if(i==="*")return o;{let s=[],c=i.replace(/:[^\s/]+/g,d=>(s.push(d.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),u=e.match(l);if(u){let d={...r};if(s.forEach((v,p)=>{d[v]=u[p+1]??""}),o.children){let v=e.slice(u[0].length),p=this.findMatchingRoute(v,o.children,d);if(p)return p}return{...o,params:d}}}}}filterAndSanitizeParams(e){if(!e)return{};let t={};for(let r in e)this.expectedParams.has(r)&&(t[r]=pe.sanitize(e[r]??""));return t}navigate(e){history.pushState(null,"",e),this.handlePopState()}addRoute(e){this.routes.push(e)}};var Pe=()=>({name:"ts-filebased-router",async buildStart(){if(typeof process>"u"||!process.versions?.node)return;let n=await import("fs/promises"),e=await import("path"),t=await import("./esm-KRNKVVL7.js"),r=e.resolve("src/pages"),o=e.resolve("src/gen"),i=e.resolve("src/routes"),a=e.join(o,"tsrouter.gen.ts"),s=e.join(i,"__root.ts"),c=process.env.NODE_ENV!=="production";async function l(m){try{await n.mkdir(m,{recursive:!0})}catch{}}function u(m,f){let h="/"+e.relative(f,m).replace(/\\/g,"/");return h=h.replace(/\.ts$/,"").replace(/\/index$/,"")||"/",h.replace(/\[(.+?)\]/g,":$1")}function d(m){return m.replace(/^\//,"").split("/").map(f=>f.startsWith(":")?f.slice(1):f).filter(Boolean).join("-")||"index"}function v(m,f){let S=e.relative(f,m).replace(/\\/g,"/").split("/").filter(Boolean),E=S[S.length-1].replace(".ts",""),y=S.length>1?S[S.length-2]:"";if(E==="index")return y?y.charAt(0).toUpperCase()+y.slice(1):"Index";if(E.startsWith("[")&&E.endsWith("]")){let x=E.slice(1,-1);return y.charAt(0).toUpperCase()+x.charAt(0).toUpperCase()+x.slice(1)}return E.charAt(0).toUpperCase()+E.slice(1)}async function p(m){let f=await n.readdir(m,{withFileTypes:!0}),h=[];for(let S of f){let E=e.join(m,S.name);if(S.isDirectory())h=h.concat(await p(E));else if(S.isFile()&&S.name.endsWith(".ts")){let y=u(E,r),x=d(y),g=v(E,r);h.push({file:E,route:y,routeName:x,importName:g})}}return h}function A(){return`import { useInitialDOM } from "@devwareng/vanilla-ts";
|
|
2
2
|
import App from "./App";
|
|
3
3
|
|
|
4
4
|
useInitialDOM("app", App)`}function M(){return`import App from './App'
|
|
@@ -6,7 +6,7 @@ useInitialDOM("app", App)`}function M(){return`import App from './App'
|
|
|
6
6
|
export function render(_url: string) {
|
|
7
7
|
const html = App()
|
|
8
8
|
return { html }
|
|
9
|
-
}`}function
|
|
9
|
+
}`}function D(){return`import { html, useTSComponent, useTSElements, useTSNoReload, useTSSSRHydration } from '@devwareng/vanilla-ts'
|
|
10
10
|
import { Router } from './routes/__root';
|
|
11
11
|
import "tailwindcss/index.css"
|
|
12
12
|
import "animate.css"
|
|
@@ -28,7 +28,7 @@ export default function App(DOM?: HTMLElement) {
|
|
|
28
28
|
useTSComponent("routes", isDOM, Router)
|
|
29
29
|
|
|
30
30
|
return ui
|
|
31
|
-
}`}function T(m,f){let h=f.includes(":"),
|
|
31
|
+
}`}function T(m,f){let h=f.includes(":"),S=h?f.match(/:([^/]+)/)?.[1]:null;return`import { html, useTSElements, useTSMetaData${h?", useTSExtractParams":""} } from '@devwareng/vanilla-ts';
|
|
32
32
|
|
|
33
33
|
export default function ${m}(DOM: HTMLElement) {
|
|
34
34
|
useTSMetaData({
|
|
@@ -38,7 +38,7 @@ export default function ${m}(DOM: HTMLElement) {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
${h?`const params = useTSExtractParams("${f}");
|
|
41
|
-
if (!params.${
|
|
41
|
+
if (!params.${S}) return;`:""}
|
|
42
42
|
const ui = useTSElements(
|
|
43
43
|
DOM,
|
|
44
44
|
html\`
|
|
@@ -63,12 +63,12 @@ export const Router = (DOM: HTMLElement) => {
|
|
|
63
63
|
window.addEventListener("popstate", () => {
|
|
64
64
|
router.navigate(window.location.pathname);
|
|
65
65
|
});
|
|
66
|
-
};`}async function L(){let m=await p(r),f=m.find(g=>g.route==="/notfound"),h=m.filter(g=>g.route!=="/notfound");for(let g of m)(await n.readFile(g.file,"utf-8")).trim()||await n.writeFile(g.file,T(g.importName,g.route),"utf-8");let
|
|
67
|
-
`),
|
|
66
|
+
};`}async function L(){let m=await p(r),f=m.find(g=>g.route==="/notfound"),h=m.filter(g=>g.route!=="/notfound");for(let g of m)(await n.readFile(g.file,"utf-8")).trim()||await n.writeFile(g.file,T(g.importName,g.route),"utf-8");let S=m.map(g=>{let O="../pages/"+e.relative(r,g.file).replace(/\\/g,"/").replace(/\.ts$/,"");return`import ${g.importName} from "${O}";`}).join(`
|
|
67
|
+
`),E=h.map(g=>`{ path: "${g.route}", name: "${g.routeName}", component: (DOM: HTMLElement) => ${g.importName}(DOM) }`).join(`,
|
|
68
68
|
`),y=f?`export const NotFound = ${f.importName}`:'export function NotFound(DOM: HTMLElement) {\n return useTSElements(DOM, html`<div class="animate__animated animate__fadeIn duration-300 p-4"><h1>404 - Page Not Found</h1></div>`)\n}',x=`// AUTO-GENERATED FILE. DO NOT EDIT MANUALLY.
|
|
69
69
|
import { html, useTSElements } from "@devwareng/vanilla-ts"
|
|
70
70
|
|
|
71
|
-
${
|
|
71
|
+
${S}
|
|
72
72
|
|
|
73
73
|
${y}
|
|
74
74
|
|
|
@@ -77,7 +77,7 @@ export function RootDocument(DOM: HTMLElement) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
export const routeTree = [
|
|
80
|
-
${
|
|
80
|
+
${E}
|
|
81
81
|
]
|
|
82
82
|
|
|
83
83
|
export function createRouter(DOM: HTMLElement) {
|
|
@@ -115,4 +115,4 @@ export function createRouter(DOM: HTMLElement) {
|
|
|
115
115
|
navigate(window.location.pathname + window.location.search)
|
|
116
116
|
return { navigate, routes: routeTree }
|
|
117
117
|
}
|
|
118
|
-
`;await l(o),await n.writeFile(a,x,"utf-8"),await n.writeFile(s,w(),"utf-8")}if(await l(o),await l(i),await l(r),await L(),c){t.watch(r).on("all",async(
|
|
118
|
+
`;await l(o),await n.writeFile(a,x,"utf-8"),await n.writeFile(s,w(),"utf-8")}if(await l(o),await l(i),await l(r),await L(),c){t.watch(r).on("all",async(E,y)=>{if(y.endsWith(".ts"))if(E==="add"){let g=e.basename(y,".ts").replace(/\[|\]/g,"Param").replace(/(^\w|-\w)/g,fe=>fe.replace("-","").toUpperCase()),O=u(y,r);(await n.readFile(y,"utf-8")).trim()||await n.writeFile(y,T(g,O),"utf-8"),await L()}else E==="unlink"?(console.log(`\u26A0\uFE0F File removed: ${y}`),await L()):E==="change"&&await L()});let f=e.resolve("src/entry-client.ts"),h=e.resolve("src/entry-server.ts");try{await n.access(f)}catch{await n.writeFile(f,A(),"utf-8"),console.log("\u{1F7E2} Created default src/entry-client.ts")}try{await n.access(h)}catch{await n.writeFile(h,M(),"utf-8"),console.log("\u{1F7E2} Created default src/entry-server.ts")}let S=e.resolve("src/App.ts");try{await n.access(S)}catch{await n.writeFile(S,D(),"utf-8"),console.log("\u{1F7E2} Created default src/App.ts")}t.watch(s).on("unlink",async()=>{console.log("\u26A0\uFE0F Root file removed: regenerating..."),await n.writeFile(s,w(),"utf-8")})}console.log("\u{1F7E2} TS Filebased Router Generated Successfully...")}});export{Pe as TSFilebasedRouter,F as TSRouter,se as createEffect,oe as createSignal,_ as html,ae as loadPyFiles,Te as mapper,re as renderChildRoutes,Y as useAnchorSingle,Q as useInitialDOM,ee as useTSAuth,X as useTSCollection,$ as useTSComponent,k as useTSElementEach,G as useTSElements,q as useTSEvent,B as useTSEventAll,j as useTSExtractParams,ce as useTSLazy,J as useTSMetaData,te as useTSNavigate,de as useTSNoReload,ne as useTSOutlet,C as useTSParams,z as useTSPurifier,le as useTSSSRHydration,P as useTSSelect,ie as useTSloadBrython};
|