@devwareng/vanilla-ts 1.9.104 → 1.9.105
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 +5 -5
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -11
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Me=Object.create;var G=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Fe=Object.getPrototypeOf,Ie=Object.prototype.hasOwnProperty;var at=(s,t)=>()=>(s&&(t=s(s=0)),t);var Bt=(s,t)=>{for(var e in t)G(s,e,{get:t[e],enumerable:!0})},Gt=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Oe(t))!Ie.call(s,r)&&r!==e&&G(s,r,{get:()=>t[r],enumerable:!(n=Ce(t,r))||n.enumerable});return s};var v=(s,t,e)=>(e=s!=null?Me(Fe(s)):{},Gt(t||!s||!s.__esModule?G(e,"default",{value:s,enumerable:!0}):e,s)),He=s=>Gt(G({},"__esModule",{value:!0}),s);function le(s,t={}){let e=t.entryType||t.type;if(e==="both"&&(e=R.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&&!ne.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${ne.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=s,new kt(t)}var M,ae,C,R,Ht,ce,Ue,ne,qe,Ye,Be,Ge,ie,oe,kt,ue=at(()=>{"use strict";M=require("fs/promises"),ae=require("stream"),C=require("path"),R={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},Ht={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:R.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(Ht);ce="READDIRP_RECURSIVE_ERROR",Ue=new Set(["ENOENT","EPERM","EACCES","ELOOP",ce]),ne=[R.DIR_TYPE,R.EVERYTHING_TYPE,R.FILE_DIR_TYPE,R.FILE_TYPE],qe=new Set([R.DIR_TYPE,R.EVERYTHING_TYPE,R.FILE_DIR_TYPE]),Ye=new Set([R.EVERYTHING_TYPE,R.FILE_DIR_TYPE,R.FILE_TYPE]),Be=s=>Ue.has(s.code),Ge=process.platform==="win32",ie=s=>!0,oe=s=>{if(s===void 0)return ie;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 ie},kt=class extends ae.Readable{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...Ht,...t},{root:n,type:r}=e;this._fileFilter=oe(e.fileFilter),this._directoryFilter=oe(e.directoryFilter);let i=e.lstat?M.lstat:M.stat;Ge?this._stat=a=>i(a,{bigint:!0}):this._stat=i,this._maxDepth=e.depth??Ht.depth,this._wantsDir=r?qe.has(r):!1,this._wantsFile=r?Ye.has(r):!1,this._wantsEverything=r===R.EVERYTHING_TYPE,this._root=(0,C.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,M.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,C.resolve)((0,C.join)(e,r));n={path:(0,C.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){Be(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,M.realpath)(n),i=await(0,M.lstat)(r);if(i.isFile())return"file";if(i.isDirectory()){let a=r.length;if(n.startsWith(r)&&n.substr(a,1)===C.sep){let o=new Error(`Circular symlink detected: "${n}" points to "${r}"`);return o.code=ce,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 de(s,t,e,n,r){let i=(a,o)=>{e(s),r(a,o,{watchedPath:s}),o&&s!==o&&X(E.resolve(s,o),F,E.join(s,o))};try{return(0,I.watch)(s,{persistent:t.persistent},i)}catch(a){n(a);return}}var I,L,E,he,Ve,zt,fe,et,st,Wt,Ke,Qe,Ze,me,y,b,Je,Xe,F,Z,N,ts,es,ss,$t,j,rs,U,pe,J,X,ns,Nt,is,tt,ge=at(()=>{"use strict";I=require("fs"),L=require("fs/promises"),E=v(require("path"),1),he=require("os"),Ve="data",zt="end",fe="close",et=()=>{},st=process.platform,Wt=st==="win32",Ke=st==="darwin",Qe=st==="linux",Ze=st==="freebsd",me=(0,he.type)()==="OS400",y={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},b=y,Je="watch",Xe={lstat:L.lstat,stat:L.stat},F="listeners",Z="errHandlers",N="rawEmitters",ts=[F,Z,N],es=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"]),ss=s=>es.has(E.extname(s).slice(1).toLowerCase()),$t=(s,t)=>{s instanceof Set?s.forEach(t):t(s)},j=(s,t,e)=>{let n=s[t];n instanceof Set||(s[t]=n=new Set([n])),n.add(e)},rs=s=>t=>{let e=s[t];e instanceof Set?e.clear():delete s[t]},U=(s,t,e)=>{let n=s[t];n instanceof Set?n.delete(e):n===e&&delete s[t]},pe=s=>s instanceof Set?s.size===0:!s,J=new Map;X=(s,t,e,n,r)=>{let i=J.get(s);i&&$t(i[t],a=>{a(e,n,r)})},ns=(s,t,e,n)=>{let{listener:r,errHandler:i,rawEmitter:a}=n,o=J.get(t),c;if(!e.persistent)return c=de(s,e,r,i,a),c?c.close.bind(c):void 0;if(o)j(o,F,r),j(o,Z,i),j(o,N,a);else{if(c=de(s,e,X.bind(null,t,F),i,X.bind(null,t,N)),!c)return;c.on(b.ERROR,async l=>{let u=X.bind(null,t,Z);if(o&&(o.watcherUnusable=!0),Wt&&l.code==="EPERM")try{await(await(0,L.open)(s,"r")).close(),u(l)}catch{}else u(l)}),o={listeners:r,errHandlers:i,rawEmitters:a,watcher:c},J.set(t,o)}return()=>{U(o,F,r),U(o,Z,i),U(o,N,a),pe(o.listeners)&&(o.watcher.close(),J.delete(t),ts.forEach(rs(o)),o.watcher=void 0,Object.freeze(o))}},Nt=new Map,is=(s,t,e,n)=>{let{listener:r,rawEmitter:i}=n,a=Nt.get(t),o=a&&a.options;return o&&(o.persistent<e.persistent||o.interval>e.interval)&&((0,I.unwatchFile)(t),a=void 0),a?(j(a,F,r),j(a,N,i)):(a={listeners:r,rawEmitters:i,options:e,watcher:(0,I.watchFile)(t,e,(c,l)=>{$t(a.rawEmitters,d=>{d(b.CHANGE,t,{curr:c,prev:l})});let u=c.mtimeMs;(c.size!==l.size||u>l.mtimeMs||u===0)&&$t(a.listeners,d=>d(s,c))})},Nt.set(t,a)),()=>{U(a,F,r),U(a,N,i),pe(a.listeners)&&(Nt.delete(t),(0,I.unwatchFile)(t),a.options=a.watcher=void 0,Object.freeze(a))}},tt=class{constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let n=this.fsw.options,r=E.dirname(t),i=E.basename(t);this.fsw._getWatchedDir(r).add(i);let o=E.resolve(t),c={persistent:n.persistent};e||(e=et);let l;if(n.usePolling){let u=n.interval!==n.binaryInterval;c.interval=u&&ss(i)?n.binaryInterval:n.interval,l=is(t,o,c,{listener:e,rawEmitter:this.fsw._emitRaw})}else l=ns(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=E.dirname(t),i=E.basename(t),a=this.fsw._getWatchedDir(r),o=e;if(a.has(i))return;let c=async(u,d)=>{if(this.fsw._throttle(Je,t,5)){if(!d||d.mtimeMs===0)try{let h=await(0,L.stat)(t);if(this.fsw.closed)return;let f=h.atimeMs,w=h.mtimeMs;if((!f||f<=w||w!==o.mtimeMs)&&this.fsw._emit(b.CHANGE,t,h),(Ke||Qe||Ze)&&o.ino!==h.ino){this.fsw._closeFile(u),o=h;let p=this._watchWithNodeFs(t,c);p&&this.fsw._addPathCloser(u,p)}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(b.CHANGE,t,d),o=d}}},l=this._watchWithNodeFs(t,c);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(b.ADD,t,0))return;this.fsw._emit(b.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,L.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(b.CHANGE,n,t.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,o),this.fsw._emit(b.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=E.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(Ve,async d=>{if(this.fsw.closed){u=void 0;return}let h=d.path,f=E.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=E.join(i,E.relative(i,f)),this._addToNodeFs(f,e,n,a+1))}}).on(b.ERROR,this._boundHandleError),new Promise((d,h)=>{if(!u)return h();u.once(zt,()=>{if(this.fsw.closed){u=void 0;return}let f=o?o.clear():!1;d(void 0),c.getChildren().filter(w=>w!==t&&!l.has(w)).forEach(w=>{this.fsw._remove(t,w)}),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(E.dirname(t)),l=c.has(E.basename(t));!(n&&this.fsw.options.ignoreInitial)&&!i&&!l&&this.fsw._emit(b.ADD_DIR,t,e),c.add(E.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,w)=>{w&&w.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 Xe[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=E.resolve(t),h=l?await(0,L.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,L.realpath)(t):t;if(this.fsw.closed)return;let h=E.dirname(o.watchPath);if(this.fsw._getWatchedDir(h).add(o.watchPath),this.fsw._emit(b.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(E.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 Le={};Bt(Le,{FSWatcher:()=>q,WatchHelper:()=>nt,default:()=>ys,watch:()=>be});function rt(s){return Array.isArray(s)?s:[s]}function hs(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 fs(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 Ee(s,t,e){let n=fs(t);for(let r=0;r<s.length;r++){let i=s[r];if(i(n,e))return!0}return!1}function ms(s,t){if(s==null)throw new TypeError("anymatch: specify first argument");let n=rt(s).map(r=>hs(r));return t==null?(r,i)=>Ee(n,r,i):Ee(n,t)}function be(s,t={}){let e=new q(t);return e.add(s),e}var Se,it,Pe,m,jt,os,ve,as,cs,ls,we,us,ds,Ut,ye,Te,Re,_e,ps,gs,qt,ws,Es,nt,q,ys,xe=at(()=>{"use strict";Se=require("fs"),it=require("fs/promises"),Pe=require("events"),m=v(require("path"),1);ue();ge();jt="/",os="//",ve=".",as="..",cs="string",ls=/\\/g,we=/\/\//,us=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,ds=/^\.[/\\]/;Ut=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);ye=s=>{let t=rt(s).flat();if(!t.every(e=>typeof e===cs))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(Re)},Te=s=>{let t=s.replace(ls,jt),e=!1;for(t.startsWith(os)&&(e=!0);t.match(we);)t=t.replace(we,jt);return e&&(t=jt+t),t},Re=s=>Te(m.normalize(Te(s))),_e=(s="")=>t=>typeof t=="string"?Re(m.isAbsolute(t)?t:m.join(s,t)):t,ps=(s,t)=>m.isAbsolute(s)?s:m.join(t,s),gs=Object.freeze(new Set),qt=class{constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&t!==ve&&t!==as&&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,it.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=et,this.items=gs,Object.freeze(this)}},ws="stat",Es="lstat",nt=class{constructor(t,e,n){this.fsw=n;let r=t;this.path=t=t.replace(ds,""),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?ws:Es}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)}},q=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?rt(t.ignored):rt([]),awaitWriteFinish:e===!0?n:typeof e=="object"?{...n,...e}:!1};me&&(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=et,this._readyEmitted=!0,process.nextTick(()=>this.emit(y.READY)))},this._emitRaw=(...c)=>this.emit(y.RAW,...c),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new tt(this),Object.freeze(r)}_addIgnoredPath(t){if(Ut(t)){for(let e of this._ignoredPaths)if(Ut(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)Ut(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=ye(t);return r&&(i=i.map(a=>ps(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=ye(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)||ve;t[i]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==y.ERROR&&this.emit(y.ALL,t,...e)}async _emit(t,e,n){if(this.closed)return;let r=this.options;Wt&&(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===y.UNLINK)return this._pendingUnlinks.set(e,[t,...i]),setTimeout(()=>{this._pendingUnlinks.forEach((c,l)=>{this.emit(...c),this.emit(y.ALL,...c),this._pendingUnlinks.delete(l)})},typeof r.atomic=="number"?r.atomic:100),this;t===y.ADD&&this._pendingUnlinks.has(e)&&(t=y.CHANGE,this._pendingUnlinks.delete(e))}if(a&&(t===y.ADD||t===y.CHANGE)&&this._readyEmitted){let c=(l,u)=>{l?(t=y.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===y.CHANGE&&!this._throttle(y.CHANGE,e,50))return this;if(r.alwaysStat&&n===void 0&&(t===y.ADD||t===y.ADD_DIR||t===y.CHANGE)){let c=r.cwd?m.join(r.cwd,e):e,l;try{l=await(0,it.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(y.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,Se.stat)(c,(f,w)=>{if(f||!u.has(t)){f&&f.code!=="ENOENT"&&r(f);return}let p=Number(new Date);h&&w.size!==h.size&&(u.get(t).lastChange=p);let S=u.get(t);p-S.lastChange>=e?(u.delete(t),r(void 0,w)):o=setTimeout(d,a,w)})}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&&us.test(t))return!0;if(!this._userIgnored){let{cwd:n}=this.options,i=(this.options.ignored||[]).map(_e(n)),o=[...[...this._ignoredPaths].map(_e(n)),...i];this._userIgnored=ms(o,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new nt(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=m.resolve(t);return this._watched.has(e)||this._watched.set(e,new qt(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()===y.ADD)return;this._watched.delete(r),this._watched.delete(i);let d=n?y.UNLINK_DIR:y.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:y.ALL,alwaysStat:!0,lstat:!0,...e,depth:0},r=le(t,n);return this._streams.add(r),r.once(fe,()=>{r=void 0}),r.once(zt,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};ys={watch:be,FSWatcher:q}});var Ts={};Bt(Ts,{TSFilebasedRouter:()=>Ae,TSRouter:()=>Q,createEffect:()=>xt,createSignal:()=>Lt,html:()=>ct,loadPyFiles:()=>Dt,mapper:()=>Vt,renderChildRoutes:()=>bt,useAnchor:()=>W,useAnchorSingle:()=>Tt,useInitialDOM:()=>Et,useTSAuth:()=>Pt,useTSCollection:()=>St,useTSComponent:()=>z,useTSElementEach:()=>K,useTSElements:()=>gt,useTSEvent:()=>dt,useTSEventAll:()=>mt,useTSExtractParams:()=>ft,useTSLazy:()=>Mt,useTSMetaData:()=>_t,useTSNavigate:()=>vt,useTSNoReload:()=>Ft,useTSOutlet:()=>Rt,useTSParams:()=>$,useTSPurifier:()=>ut,useTSSSRHydration:()=>Ct,useTSSelect:()=>k,useTSloadBrython:()=>At});module.exports=He(Ts);function ke(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 ct(s,...t){return s.reduce((e,n,r)=>{let i=r<t.length?ke(t[r]):"";return e+n+i},"")}var Ne=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=>Ne(t)).join("")??"";var lt=v(require("dompurify"),1),ut=(s,t)=>{let n={...{ADD_TAGS:["my-custom-tag"]},...t};return typeof s=="string"?lt.default.sanitize(s,n):lt.default.sanitize(s.innerHTML,n)};var dt=(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"),ht=v(require("dompurify"),1);function $e(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]=ht.default.sanitize(i[c+1]??"")}),a}function ze(s){let t={},e=new URLSearchParams(s);for(let[n,r]of e.entries())t[n]=ht.default.sanitize(r);return t}var $=(0,Kt.createStore)((s,t)=>({params:{},query:{},setFromPattern:e=>{let n=window.location.pathname,r=$e(e,n),i=ze(window.location.search);s({params:r,query:i})},getParam:e=>t().params[e],getQuery:e=>t().query[e]}));function ft(s){let t=$.getState();t.setFromPattern(s);let e=t.params,n=t.query;return{...e,...n}}var mt=(s,t,e)=>{let n=document.querySelectorAll(s);return n.forEach(r=>{r.addEventListener(t,e)}),()=>{n.forEach(r=>{r.removeEventListener(t,e)})}};var pt=v(require("dompurify"),1),gt=(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};pt.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 w=f.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return w===""||/^https?:\/\//i.test(w)||/^\/(?!\/)/.test(w)||/^\.{0,2}\//.test(w)}return/^bg-\[\]$/.test(f),!0}return!1});c.attrValue=h.join(" ");return}});let i=pt.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 wt=v(require("dompurify"),1),V=null,Et=(s,t)=>{if(typeof document>"u")return;let e=document.getElementById(s);if(!e)return;wt.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=wt.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(V!==null&&i!==V){let a=document.createElement("div");t(a);let c=new DOMParser().parseFromString(V,"text/html");for(;e.firstChild;)e.removeChild(e.firstChild);c.body.childNodes.forEach(l=>e.appendChild(l.cloneNode(!0)))}else{for(V=i;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(r),t(e)}};var yt=v(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 Tt=(s,t,e,n="",r=null)=>{if(!s)return;let i=yt.default.sanitize(t,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=yt.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 A=v(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 _t=(s,t)=>{let e={name:A.default.sanitize(s.name||""),title:A.default.sanitize(s.title||""),description:A.default.sanitize(s.description||"Default description"),author:A.default.sanitize(s.author||""),favicon:s.favicon},n=g=>{e.name=A.default.sanitize(g),p("name",e.name)},r=g=>{e.title=A.default.sanitize(g),document.title=e.title},i=g=>{e.description=A.default.sanitize(g),p("description",e.description)},a=g=>{e.author=A.default.sanitize(g),p("author",e.author)},o=g=>{e.favicon=A.default.sanitize(g);let T=document.querySelector('link[rel="icon"]');T||(T=document.createElement("link"),T.rel="icon",document.head.appendChild(T)),T.href=e.favicon},c=()=>e.name,l=()=>e.title,u=()=>e.description,d=()=>e.author,h=()=>e.favicon,f=()=>e,w=(g,T)=>{let _=document.createElement("meta");_.setAttribute("name",g),_.setAttribute("content",T),document.head.appendChild(_)},p=(g,T)=>{let _=document.querySelector(`meta[name="${g}"]`);_?_.setAttribute("content",T):w(g,T)},S=()=>{e.title&&(document.title=e.title),e.name&&p("name",e.name),e.description&&p("description",e.description),e.author&&p("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),S(),{setName:n,setTitle:r,setDescription:i,setAuthor:a,setFavicon:o,getName:c,getTitle:l,getDescription:u,getAuthor:d,getFavicon:h,getAllMetaData:f,appendMetaTagsToHead:S}};var Zt=v(require("dompurify"),1),z=(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 St=(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"?z(i,t,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var k=(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 K=(s,t,e)=>{s.forEach(n=>{t.forEach(r=>{n.addEventListener(r,i=>{e(n,i)})})})};var vt=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var Rt=(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 Lt(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 xt(s){let t=s();typeof t=="function"&&t()}var At=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.")},Dt=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 Mt(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"),Ot=s=>s;typeof window<"u"&&typeof document<"u"&&(Ot=s=>{let t=document.createElement("div");return t.innerText=s,t.innerHTML});var We=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",Ot(n));let r=e.getAttribute("aria-label");r&&e.setAttribute("aria-label",Ot(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)}})}})},je=(0,te.debounce)(We,50),W=s=>{je(s)};var Ft=s=>{if(!s)return;let t=k("a",s);W(t)};var It=v(require("dompurify"),1);var se=require("zustand/vanilla"),re=v(require("dompurify"),1),O=(0,se.createStore)(s=>({params:{},query:{},setParams:t=>s(()=>({params:ee(t)})),setQuery:t=>s(()=>({query:ee(t)}))}));function ee(s){let t={};for(let e in s)t[e]=re.default.sanitize(s[e]);return t}var Q=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);O.getState().setParams(i),O.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);O.getState().setParams(a),O.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(O.getState().setParams(l),O.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]=It.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]=It.default.sanitize(t[n]??""));return e}navigate(t){history.pushState(null,"",t),this.handlePopState()}addRoute(t){this.routes.push(t)}};var x=v(require("path"),1),Ae=()=>({name:"ts-filebased-router",async buildStart(){if(typeof process>"u"||!process.versions?.node)return;let s=await import("fs/promises"),t=await Promise.resolve().then(()=>(xe(),Le)),e=x.default.resolve("src/pages"),n=x.default.resolve("src/gen"),r=x.default.resolve("src/routes"),i=x.default.join(n,"tsrouter.gen.ts"),a=x.default.join(r,"__root.ts"),o=process.env.NODE_ENV!=="production";async function c(p){try{await s.mkdir(p,{recursive:!0})}catch{}}function l(p,S){let g="/"+x.default.relative(S,p).replace(/\\/g,"/");return g=g.replace(/\.ts$/,"").replace(/\/index$/,"")||"/",g.replace(/\[(.+?)\]/g,":$1")}function u(p){return p.replace(/^\//,"").split("/").map(S=>S.startsWith(":")?S.slice(1):S).filter(Boolean).join("-")||"index"}function d(p,S){let T=x.default.relative(S,p).replace(/\\/g,"/").split("/").filter(Boolean),_=T[T.length-1].replace(".ts",""),D=T.length>1?T[T.length-2]:"";if(_==="index")return D?D.charAt(0).toUpperCase()+D.slice(1):"Index";if(_.startsWith("[")&&_.endsWith("]")){let H=_.slice(1,-1);return D.charAt(0).toUpperCase()+H.charAt(0).toUpperCase()+H.slice(1)}return _.charAt(0).toUpperCase()+_.slice(1)}async function h(p){let S=await s.readdir(p,{withFileTypes:!0}),g=[];for(let T of S){let _=x.default.join(p,T.name);if(T.isDirectory())g=g.concat(await h(_));else if(T.isFile()&&T.name.endsWith(".ts")){let D=l(_,e),H=u(D),ot=d(_,e);g.push({file:_,route:D,routeName:H,importName:ot})}}return g}function f(){return`import { createRouter } from "@/gen/tsrouter.gen";
|
|
1
|
+
"use strict";var Ce=Object.create;var G=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,Ie=Object.prototype.hasOwnProperty;var at=(s,t)=>()=>(s&&(t=s(s=0)),t);var Bt=(s,t)=>{for(var e in t)G(s,e,{get:t[e],enumerable:!0})},Gt=(s,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Fe(t))!Ie.call(s,n)&&n!==e&&G(s,n,{get:()=>t[n],enumerable:!(r=Oe(t,n))||r.enumerable});return s};var v=(s,t,e)=>(e=s!=null?Ce(He(s)):{},Gt(t||!s||!s.__esModule?G(e,"default",{value:s,enumerable:!0}):e,s)),Ne=s=>Gt(G({},"__esModule",{value:!0}),s);function ue(s,t={}){let e=t.entryType||t.type;if(e==="both"&&(e=R.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 Nt(t)}var M,ce,C,R,It,le,qe,ie,Ye,Be,Ge,Ve,oe,ae,Nt,de=at(()=>{"use strict";M=require("fs/promises"),ce=require("stream"),C=require("path"),R={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},It={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:R.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(It);le="READDIRP_RECURSIVE_ERROR",qe=new Set(["ENOENT","EPERM","EACCES","ELOOP",le]),ie=[R.DIR_TYPE,R.EVERYTHING_TYPE,R.FILE_DIR_TYPE,R.FILE_TYPE],Ye=new Set([R.DIR_TYPE,R.EVERYTHING_TYPE,R.FILE_DIR_TYPE]),Be=new Set([R.EVERYTHING_TYPE,R.FILE_DIR_TYPE,R.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(r=>e.basename===r)}return oe},Nt=class extends ce.Readable{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...It,...t},{root:r,type:n}=e;this._fileFilter=ae(e.fileFilter),this._directoryFilter=ae(e.directoryFilter);let o=e.lstat?M.lstat:M.stat;Ve?this._stat=a=>o(a,{bigint:!0}):this._stat=o,this._maxDepth=e.depth??It.depth,this._wantsDir=n?Ye.has(n):!1,this._wantsFile=n?Be.has(n):!1,this._wantsEverything=n===R.EVERYTHING_TYPE,this._root=(0,C.resolve)(r),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(r,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,r=e&&e.files;if(r&&r.length>0){let{path:n,depth:o}=e,a=r.splice(0,t).map(c=>this._formatEntry(c,n)),i=await Promise.all(a);for(let c of i){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(o<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,o+1)),this._wantsDir&&(this.push(c),t--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),t--)}}else{let n=this.parents.pop();if(!n){this.push(null);break}if(this.parent=await n,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(t,e){let r;try{r=await(0,M.readdir)(t,this._rdOptions)}catch(n){this._onError(n)}return{files:r,depth:e,path:t}}async _formatEntry(t,e){let r,n=this._isDirent?t.name:t;try{let o=(0,C.resolve)((0,C.join)(e,n));r={path:(0,C.relative)(this._root,o),fullPath:o,basename:n},r[this._statsProp]=this._isDirent?t:await this._stat(o)}catch(o){this._onError(o);return}return r}_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 r=t.fullPath;try{let n=await(0,M.realpath)(r),o=await(0,M.lstat)(n);if(o.isFile())return"file";if(o.isDirectory()){let a=n.length;if(r.startsWith(n)&&r.substr(a,1)===C.sep){let i=new Error(`Circular symlink detected: "${r}" points to "${n}"`);return i.code=le,this._onError(i)}return"directory"}}catch(n){return this._onError(n),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}}});function he(s,t,e,r,n){let o=(a,i)=>{e(s),n(a,i,{watchedPath:s}),i&&s!==i&&X(w.resolve(s,i),F,w.join(s,i))};try{return(0,H.watch)(s,{persistent:t.persistent},o)}catch(a){r(a);return}}var H,b,w,fe,Ke,zt,me,et,st,Wt,Qe,Ze,Je,pe,y,L,Xe,ts,F,Z,k,es,ss,ns,$t,j,rs,U,ge,J,X,is,kt,os,tt,Ee=at(()=>{"use strict";H=require("fs"),b=require("fs/promises"),w=v(require("path"),1),fe=require("os"),Ke="data",zt="end",me="close",et=()=>{},st=process.platform,Wt=st==="win32",Qe=st==="darwin",Ze=st==="linux",Je=st==="freebsd",pe=(0,fe.type)()==="OS400",y={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},L=y,Xe="watch",ts={lstat:b.lstat,stat:b.stat},F="listeners",Z="errHandlers",k="rawEmitters",es=[F,Z,k],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"]),ns=s=>ss.has(w.extname(s).slice(1).toLowerCase()),$t=(s,t)=>{s instanceof Set?s.forEach(t):t(s)},j=(s,t,e)=>{let r=s[t];r instanceof Set||(s[t]=r=new Set([r])),r.add(e)},rs=s=>t=>{let e=s[t];e instanceof Set?e.clear():delete s[t]},U=(s,t,e)=>{let r=s[t];r instanceof Set?r.delete(e):r===e&&delete s[t]},ge=s=>s instanceof Set?s.size===0:!s,J=new Map;X=(s,t,e,r,n)=>{let o=J.get(s);o&&$t(o[t],a=>{a(e,r,n)})},is=(s,t,e,r)=>{let{listener:n,errHandler:o,rawEmitter:a}=r,i=J.get(t),c;if(!e.persistent)return c=he(s,e,n,o,a),c?c.close.bind(c):void 0;if(i)j(i,F,n),j(i,Z,o),j(i,k,a);else{if(c=he(s,e,X.bind(null,t,F),o,X.bind(null,t,k)),!c)return;c.on(L.ERROR,async l=>{let u=X.bind(null,t,Z);if(i&&(i.watcherUnusable=!0),Wt&&l.code==="EPERM")try{await(await(0,b.open)(s,"r")).close(),u(l)}catch{}else u(l)}),i={listeners:n,errHandlers:o,rawEmitters:a,watcher:c},J.set(t,i)}return()=>{U(i,F,n),U(i,Z,o),U(i,k,a),ge(i.listeners)&&(i.watcher.close(),J.delete(t),es.forEach(rs(i)),i.watcher=void 0,Object.freeze(i))}},kt=new Map,os=(s,t,e,r)=>{let{listener:n,rawEmitter:o}=r,a=kt.get(t),i=a&&a.options;return i&&(i.persistent<e.persistent||i.interval>e.interval)&&((0,H.unwatchFile)(t),a=void 0),a?(j(a,F,n),j(a,k,o)):(a={listeners:n,rawEmitters:o,options:e,watcher:(0,H.watchFile)(t,e,(c,l)=>{$t(a.rawEmitters,d=>{d(L.CHANGE,t,{curr:c,prev:l})});let u=c.mtimeMs;(c.size!==l.size||u>l.mtimeMs||u===0)&&$t(a.listeners,d=>d(s,c))})},kt.set(t,a)),()=>{U(a,F,n),U(a,k,o),ge(a.listeners)&&(kt.delete(t),(0,H.unwatchFile)(t),a.options=a.watcher=void 0,Object.freeze(a))}},tt=class{constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let r=this.fsw.options,n=w.dirname(t),o=w.basename(t);this.fsw._getWatchedDir(n).add(o);let i=w.resolve(t),c={persistent:r.persistent};e||(e=et);let l;if(r.usePolling){let u=r.interval!==r.binaryInterval;c.interval=u&&ns(o)?r.binaryInterval:r.interval,l=os(t,i,c,{listener:e,rawEmitter:this.fsw._emitRaw})}else l=is(t,i,c,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return l}_handleFile(t,e,r){if(this.fsw.closed)return;let n=w.dirname(t),o=w.basename(t),a=this.fsw._getWatchedDir(n),i=e;if(a.has(o))return;let c=async(u,d)=>{if(this.fsw._throttle(Xe,t,5)){if(!d||d.mtimeMs===0)try{let h=await(0,b.stat)(t);if(this.fsw.closed)return;let f=h.atimeMs,E=h.mtimeMs;if((!f||f<=E||E!==i.mtimeMs)&&this.fsw._emit(L.CHANGE,t,h),(Qe||Ze||Je)&&i.ino!==h.ino){this.fsw._closeFile(u),i=h;let p=this._watchWithNodeFs(t,c);p&&this.fsw._addPathCloser(u,p)}else i=h}catch{this.fsw._remove(n,o)}else if(a.has(o)){let h=d.atimeMs,f=d.mtimeMs;(!h||h<=f||f!==i.mtimeMs)&&this.fsw._emit(L.CHANGE,t,d),i=d}}},l=this._watchWithNodeFs(t,c);if(!(r&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(L.ADD,t,0))return;this.fsw._emit(L.ADD,t,e)}return l}async _handleSymlink(t,e,r,n){if(this.fsw.closed)return;let o=t.fullPath,a=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let i;try{i=await(0,b.realpath)(r)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(n)?this.fsw._symlinkPaths.get(o)!==i&&(this.fsw._symlinkPaths.set(o,i),this.fsw._emit(L.CHANGE,r,t.stats)):(a.add(n),this.fsw._symlinkPaths.set(o,i),this.fsw._emit(L.ADD,r,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(o))return!0;this.fsw._symlinkPaths.set(o,!0)}_handleRead(t,e,r,n,o,a,i){if(t=w.join(t,""),i=this.fsw._throttle("readdir",t,1e3),!i)return;let c=this.fsw._getWatchedDir(r.path),l=new Set,u=this.fsw._readdirp(t,{fileFilter:d=>r.filterPath(d),directoryFilter:d=>r.filterDir(d)});if(u)return u.on(Ke,async d=>{if(this.fsw.closed){u=void 0;return}let h=d.path,f=w.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===n||!n&&!c.has(h))&&(this.fsw._incrReadyCount(),f=w.join(o,w.relative(o,f)),this._addToNodeFs(f,e,r,a+1))}}).on(L.ERROR,this._boundHandleError),new Promise((d,h)=>{if(!u)return h();u.once(zt,()=>{if(this.fsw.closed){u=void 0;return}let f=i?i.clear():!1;d(void 0),c.getChildren().filter(E=>E!==t&&!l.has(E)).forEach(E=>{this.fsw._remove(t,E)}),u=void 0,f&&this._handleRead(t,!1,r,n,o,a,i)})})}async _handleDir(t,e,r,n,o,a,i){let c=this.fsw._getWatchedDir(w.dirname(t)),l=c.has(w.basename(t));!(r&&this.fsw.options.ignoreInitial)&&!o&&!l&&this.fsw._emit(L.ADD_DIR,t,e),c.add(w.basename(t)),this.fsw._getWatchedDir(t);let u,d,h=this.fsw.options.depth;if((h==null||n<=h)&&!this.fsw._symlinkPaths.has(i)){if(!o&&(await this._handleRead(t,r,a,o,t,n,u),this.fsw.closed))return;d=this._watchWithNodeFs(t,(f,E)=>{E&&E.mtimeMs===0||this._handleRead(f,!1,a,o,t,n,u)})}return d}async _addToNodeFs(t,e,r,n,o){let a=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return a(),!1;let i=this.fsw._getWatchHelpers(t);r&&(i.filterPath=c=>r.filterPath(c),i.filterDir=c=>r.filterDir(c));try{let c=await ts[i.statMethod](i.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(i.watchPath,c))return a(),!1;let l=this.fsw.options.followSymlinks,u;if(c.isDirectory()){let d=w.resolve(t),h=l?await(0,b.realpath)(t):t;if(this.fsw.closed||(u=await this._handleDir(i.watchPath,c,e,n,o,i,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,b.realpath)(t):t;if(this.fsw.closed)return;let h=w.dirname(i.watchPath);if(this.fsw._getWatchedDir(h).add(i.watchPath),this.fsw._emit(L.ADD,i.watchPath,c),u=await this._handleDir(h,c,e,n,t,i,d),this.fsw.closed)return;d!==void 0&&this.fsw._symlinkPaths.set(w.resolve(t),d)}else u=this._handleFile(i.watchPath,c,e);return a(),u&&this.fsw._addPathCloser(t,u),!1}catch(c){if(this.fsw._handleError(c))return a(),t}}}});var xe={};Bt(xe,{FSWatcher:()=>q,WatchHelper:()=>rt,default:()=>Ts,watch:()=>be});function nt(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 r=ms(t);for(let n=0;n<s.length;n++){let o=s[n];if(o(r,e))return!0}return!1}function ps(s,t){if(s==null)throw new TypeError("anymatch: specify first argument");let r=nt(s).map(n=>fs(n));return t==null?(n,o)=>ye(r,n,o):ye(r,t)}function be(s,t={}){let e=new q(t);return e.add(s),e}var Pe,it,ve,m,jt,as,Re,cs,ls,us,we,ds,hs,Ut,Te,_e,Le,Se,gs,Es,qt,ws,ys,rt,q,Ts,Ae=at(()=>{"use strict";Pe=require("fs"),it=require("fs/promises"),ve=require("events"),m=v(require("path"),1);de();Ee();jt="/",as="//",Re=".",cs="..",ls="string",us=/\\/g,we=/\/\//,ds=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,hs=/^\.[/\\]/;Ut=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);Te=s=>{let t=nt(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,jt),e=!1;for(t.startsWith(as)&&(e=!0);t.match(we);)t=t.replace(we,jt);return e&&(t=jt+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),Es=Object.freeze(new Set),qt=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 r=this.path;try{await(0,it.readdir)(r)}catch{this._removeWatcher&&this._removeWatcher(m.dirname(r),m.basename(r))}}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=et,this.items=Es,Object.freeze(this)}},ws="stat",ys="lstat",rt=class{constructor(t,e,r){this.fsw=r;let n=t;this.path=t=t.replace(hs,""),this.watchPath=n,this.fullWatchPath=m.resolve(n),this.dirParts=[],this.dirParts.forEach(o=>{o.length>1&&o.pop()}),this.followSymlinks=e,this.statMethod=e?ws: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 r=this.entryPath(t);return this.fsw._isntIgnored(r,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},q=class extends ve.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,r={stabilityThreshold:2e3,pollInterval:100},n={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?nt(t.ignored):nt([]),awaitWriteFinish:e===!0?r:typeof e=="object"?{...r,...e}:!1};pe&&(n.usePolling=!0),n.atomic===void 0&&(n.atomic=!n.usePolling);let o=process.env.CHOKIDAR_USEPOLLING;if(o!==void 0){let c=o.toLowerCase();c==="false"||c==="0"?n.usePolling=!1:c==="true"||c==="1"?n.usePolling=!0:n.usePolling=!!c}let a=process.env.CHOKIDAR_INTERVAL;a&&(n.interval=Number.parseInt(a,10));let i=0;this._emitReady=()=>{i++,i>=this._readyCount&&(this._emitReady=et,this._readyEmitted=!0,process.nextTick(()=>this.emit(y.READY)))},this._emitRaw=(...c)=>this.emit(y.RAW,...c),this._boundRemove=this._remove.bind(this),this.options=n,this._nodeFsHandler=new tt(this),Object.freeze(n)}_addIgnoredPath(t){if(Ut(t)){for(let e of this._ignoredPaths)if(Ut(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)Ut(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,r){let{cwd:n}=this.options;this.closed=!1,this._closePromise=void 0;let o=Te(t);return n&&(o=o.map(a=>gs(a,n))),o.forEach(a=>{this._removeIgnoredPath(a)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=o.length,Promise.all(o.map(async a=>{let i=await this._nodeFsHandler._addToNodeFs(a,!r,void 0,0,e);return i&&this._emitReady(),i})).then(a=>{this.closed||a.forEach(i=>{i&&this.add(m.dirname(i),m.basename(e||i))})}),this}unwatch(t){if(this.closed)return this;let e=Te(t),{cwd:r}=this.options;return e.forEach(n=>{!m.isAbsolute(n)&&!this._closers.has(n)&&(r&&(n=m.join(r,n)),n=m.resolve(n)),this._closePath(n),this._addIgnoredPath(n),this._watched.has(n)&&this._addIgnoredPath({path:n,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(r=>{let n=r();n instanceof Promise&&t.push(n)})),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,r)=>{let o=(this.options.cwd?m.relative(this.options.cwd,r):r)||Re;t[o]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==y.ERROR&&this.emit(y.ALL,t,...e)}async _emit(t,e,r){if(this.closed)return;let n=this.options;Wt&&(e=m.normalize(e)),n.cwd&&(e=m.relative(n.cwd,e));let o=[e];r!=null&&o.push(r);let a=n.awaitWriteFinish,i;if(a&&(i=this._pendingWrites.get(e)))return i.lastChange=new Date,this;if(n.atomic){if(t===y.UNLINK)return this._pendingUnlinks.set(e,[t,...o]),setTimeout(()=>{this._pendingUnlinks.forEach((c,l)=>{this.emit(...c),this.emit(y.ALL,...c),this._pendingUnlinks.delete(l)})},typeof n.atomic=="number"?n.atomic:100),this;t===y.ADD&&this._pendingUnlinks.has(e)&&(t=y.CHANGE,this._pendingUnlinks.delete(e))}if(a&&(t===y.ADD||t===y.CHANGE)&&this._readyEmitted){let c=(l,u)=>{l?(t=y.ERROR,o[0]=l,this.emitWithAll(t,o)):u&&(o.length>1?o[1]=u:o.push(u),this.emitWithAll(t,o))};return this._awaitWriteFinish(e,a.stabilityThreshold,t,c),this}if(t===y.CHANGE&&!this._throttle(y.CHANGE,e,50))return this;if(n.alwaysStat&&r===void 0&&(t===y.ADD||t===y.ADD_DIR||t===y.CHANGE)){let c=n.cwd?m.join(n.cwd,e):e,l;try{l=await(0,it.stat)(c)}catch{}if(!l||this.closed)return;o.push(l)}return this.emitWithAll(t,o),this}_handleError(t){let e=t&&t.code;return t&&e!=="ENOENT"&&e!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||e!=="EPERM"&&e!=="EACCES")&&this.emit(y.ERROR,t),t||this.closed}_throttle(t,e,r){this._throttled.has(t)||this._throttled.set(t,new Map);let n=this._throttled.get(t);if(!n)throw new Error("invalid throttle");let o=n.get(e);if(o)return o.count++,!1;let a,i=()=>{let l=n.get(e),u=l?l.count:0;return n.delete(e),clearTimeout(a),l&&clearTimeout(l.timeoutObject),u};a=setTimeout(i,r);let c={timeoutObject:a,clear:i,count:0};return n.set(e,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,r,n){let o=this.options.awaitWriteFinish;if(typeof o!="object")return;let a=o.pollInterval,i,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,Pe.stat)(c,(f,E)=>{if(f||!u.has(t)){f&&f.code!=="ENOENT"&&n(f);return}let p=Number(new Date);h&&E.size!==h.size&&(u.get(t).lastChange=p);let S=u.get(t);p-S.lastChange>=e?(u.delete(t),n(void 0,E)):i=setTimeout(d,a,E)})}u.has(t)||(u.set(t,{lastChange:l,cancelWait:()=>(u.delete(t),clearTimeout(i),r)}),i=setTimeout(d,a))}_isIgnored(t,e){if(this.options.atomic&&ds.test(t))return!0;if(!this._userIgnored){let{cwd:r}=this.options,o=(this.options.ignored||[]).map(Se(r)),i=[...[...this._ignoredPaths].map(Se(r)),...o];this._userIgnored=ps(i,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new rt(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=m.resolve(t);return this._watched.has(e)||this._watched.set(e,new qt(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,e,r){let n=m.join(t,e),o=m.resolve(n);if(r=r??(this._watched.has(n)||this._watched.has(o)),!this._throttle("remove",n,100))return;!r&&this._watched.size===1&&this.add(t,e,!0),this._getWatchedDir(n).getChildren().forEach(h=>this._remove(n,h));let c=this._getWatchedDir(t),l=c.has(e);c.remove(e),this._symlinkPaths.has(o)&&this._symlinkPaths.delete(o);let u=n;if(this.options.cwd&&(u=m.relative(this.options.cwd,n)),this.options.awaitWriteFinish&&this._pendingWrites.has(u)&&this._pendingWrites.get(u).cancelWait()===y.ADD)return;this._watched.delete(n),this._watched.delete(o);let d=r?y.UNLINK_DIR:y.UNLINK;l&&!this._isIgnored(n)&&this._emit(d,n),this._closePath(n)}_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(r=>r()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let r=this._closers.get(t);r||(r=[],this._closers.set(t,r)),r.push(e)}_readdirp(t,e){if(this.closed)return;let r={type:y.ALL,alwaysStat:!0,lstat:!0,...e,depth:0},n=ue(t,r);return this._streams.add(n),n.once(me,()=>{n=void 0}),n.once(zt,()=>{n&&(this._streams.delete(n),n=void 0)}),n}};Ts={watch:be,FSWatcher:q}});var _s={};Bt(_s,{TSFilebasedRouter:()=>De,TSRouter:()=>Q,createEffect:()=>xt,createSignal:()=>bt,html:()=>ct,loadPyFiles:()=>Dt,mapper:()=>Kt,renderChildRoutes:()=>Lt,useAnchor:()=>W,useAnchorSingle:()=>Tt,useInitialDOM:()=>wt,useTSAuth:()=>Pt,useTSCollection:()=>St,useTSComponent:()=>z,useTSElementEach:()=>K,useTSElements:()=>gt,useTSEvent:()=>dt,useTSEventAll:()=>mt,useTSExtractParams:()=>ft,useTSLazy:()=>Mt,useTSMetaData:()=>_t,useTSNavigate:()=>vt,useTSNoReload:()=>Ft,useTSOutlet:()=>Rt,useTSParams:()=>$,useTSPurifier:()=>ut,useTSSSRHydration:()=>Ct,useTSSelect:()=>N,useTSloadBrython:()=>At});module.exports=Ne(_s);function ke(s){return(s==null?"":String(s)).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Vt(s,t){if(t==null)return;if(t instanceof Node){s.appendChild(t);return}if(Array.isArray(t)){t.forEach(r=>Vt(s,r));return}let e=document.createTextNode(ke(t));s.appendChild(e)}function ct(s,...t){let e=document.createElement("template");e.innerHTML=s.join("<!--slot-->");let r=e.content,n=document.createTreeWalker(r,NodeFilter.SHOW_COMMENT),o=0,a;for(;a=n.nextNode();){let i=t[o++],c=a.parentNode,l=document.createDocumentFragment();Vt(l,i),c.replaceChild(l,a)}return r.firstElementChild}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(),Kt=s=>s?.map(t=>$e(t)).join("")??"";var lt=v(require("dompurify"),1),ut=(s,t)=>{let r={...{ADD_TAGS:["my-custom-tag"]},...t};return typeof s=="string"?lt.default.sanitize(s,r):lt.default.sanitize(s.innerHTML,r)};var dt=(s,t,e)=>{if(typeof s=="string"){let r=document.getElementById(s);r?r.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 Qt=require("zustand/vanilla"),ht=v(require("dompurify"),1);function ze(s,t){let e=[],r=s.replace(/:[^/]+/g,i=>(e.push(i.slice(1)),"([^/]+)")),n=new RegExp(`^${r}$`),o=t.match(n),a={};return o&&e.forEach((i,c)=>{a[i]=ht.default.sanitize(o[c+1]??"")}),a}function We(s){let t={},e=new URLSearchParams(s);for(let[r,n]of e.entries())t[r]=ht.default.sanitize(n);return t}var $=(0,Qt.createStore)((s,t)=>({params:{},query:{},setFromPattern:e=>{let r=window.location.pathname,n=ze(e,r),o=We(window.location.search);s({params:n,query:o})},getParam:e=>t().params[e],getQuery:e=>t().query[e]}));function ft(s){let t=$.getState();t.setFromPattern(s);let e=t.params,r=t.query;return{...e,...r}}var mt=(s,t,e)=>{let r=document.querySelectorAll(s);return r.forEach(n=>{n.addEventListener(t,e)}),()=>{r.forEach(n=>{n.removeEventListener(t,e)})}};var pt=v(require("dompurify"),1),gt=(s,t,e={},r)=>{let n={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};pt.default.addHook("uponSanitizeAttribute",(i,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(i.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 E=f.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return E===""||/^https?:\/\//i.test(E)||/^\/(?!\/)/.test(E)||/^\.{0,2}\//.test(E)}return/^bg-\[\]$/.test(f),!0}return!1});c.attrValue=h.join(" ");return}});let o=pt.default.sanitize(t,{...n,RETURN_DOM_FRAGMENT:!0});for(;s.firstChild;)s.removeChild(s.firstChild);s.appendChild(o);let a=(i,c)=>{s.querySelectorAll(`[${i}]`).forEach(l=>{let u=l.getAttribute(i);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(i=>{let c=i.dataset.key,l=i.dataset.event??"click";c&&Object.prototype.hasOwnProperty.call(e,c)&&i.addEventListener(l,e[c])}),s.querySelectorAll("[data-hover]").forEach(i=>{let c=i.dataset.hover;c&&Object.prototype.hasOwnProperty.call(e,c)&&(i.addEventListener("mouseenter",e[c]),i.addEventListener("mouseleave",e[c]))}),s.querySelectorAll("[data-classlist]").forEach(i=>{let c=i.dataset.classlist;/^[a-zA-Z0-9\-\s:_]+$/.test(c)&&i.classList.add(...c.split(/\s+/))})};var Et=v(require("dompurify"),1),V=null,wt=(s,t)=>{if(typeof document>"u")return;let e=document.getElementById(s);if(!e)return;Et.default.addHook("uponSanitizeAttribute",(a,i)=>{let c=(i.attrName||"").toLowerCase(),l=(i.attrValue??"").toString().trim();if(c.startsWith("on")){i.keepAttr=!1;return}if((c==="href"||c==="src")&&/^(javascript:|vbscript:|data:|file:|about:)/i.test(l)){i.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});i.attrValue=d.join(" ");return}if(c==="style"){i.keepAttr=!1;return}});let r=e.cloneNode(!0),n=Et.default.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}),o=Array.from(n.childNodes).map(a=>a.outerHTML||a.textContent||"").join("");if(V!==null&&o!==V){let a=document.createElement("div");t(a);let c=new DOMParser().parseFromString(V,"text/html");for(;e.firstChild;)e.removeChild(e.firstChild);c.body.childNodes.forEach(l=>e.appendChild(l.cloneNode(!0)))}else{for(V=o;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(n),t(e)}};var yt=v(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 Tt=(s,t,e,r="",n=null)=>{if(!s)return;let o=yt.default.sanitize(t,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=yt.default.sanitize(e,{USE_PROFILES:{html:!1}});s.setAttribute("href",o),s.setAttribute("aria-label",a),r&&(s.className=r.trim()),n&&s.replaceChildren(n),typeof window<"u"&&s.addEventListener("click",i=>{i.preventDefault();let l=i.currentTarget.getAttribute("href");if(l){let u=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:u},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};var A=v(require("dompurify"),1);var Zt=(s="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",t="'self' 'nonce-rAnd0m123'",e="'none'",r="'self' https://fonts.googleapis.com https://fonts.gstatic.com",n="'self' https://blogger.googleusercontent.com",o=["'self'","https://fonts.googleapis.com","https://fonts.gstatic.com","https://www.google.com/maps/"],a="'self' https://www.youtube.com",i="'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 ${r}; img-src ${n}; connect-src ${o.join(" ")}; frame-src ${a}; base-uri ${i}; ${h}`)}catch(d){console.error("Error adding CSP meta element:",d)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",u):u()};var _t=(s,t)=>{let e={name:A.default.sanitize(s.name||""),title:A.default.sanitize(s.title||""),description:A.default.sanitize(s.description||"Default description"),author:A.default.sanitize(s.author||""),favicon:s.favicon},r=g=>{e.name=A.default.sanitize(g),p("name",e.name)},n=g=>{e.title=A.default.sanitize(g),document.title=e.title},o=g=>{e.description=A.default.sanitize(g),p("description",e.description)},a=g=>{e.author=A.default.sanitize(g),p("author",e.author)},i=g=>{e.favicon=A.default.sanitize(g);let T=document.querySelector('link[rel="icon"]');T||(T=document.createElement("link"),T.rel="icon",document.head.appendChild(T)),T.href=e.favicon},c=()=>e.name,l=()=>e.title,u=()=>e.description,d=()=>e.author,h=()=>e.favicon,f=()=>e,E=(g,T)=>{let _=document.createElement("meta");_.setAttribute("name",g),_.setAttribute("content",T),document.head.appendChild(_)},p=(g,T)=>{let _=document.querySelector(`meta[name="${g}"]`);_?_.setAttribute("content",T):E(g,T)},S=()=>{e.title&&(document.title=e.title),e.name&&p("name",e.name),e.description&&p("description",e.description),e.author&&p("author",e.author),e.favicon&&i(e.favicon)};return t&&Zt(t.scriptSrc,t.styleSrc,t.objectSrc,Array.isArray(t.connectSrc)?t.connectSrc.join(" "):t.connectSrc,t.reportOnly!==void 0?String(t.reportOnly):void 0),S(),{setName:r,setTitle:n,setDescription:o,setAuthor:a,setFavicon:i,getName:c,getTitle:l,getDescription:u,getAuthor:d,getFavicon:h,getAllMetaData:f,appendMetaTagsToHead:S}};var Jt=v(require("dompurify"),1),z=(s,t,e,r,n)=>{let o=`#${s}`,a=t.querySelectorAll(o);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 i=a[0];i.innerHTML=Jt.default.sanitize(i.innerHTML,{USE_PROFILES:{html:!0}}),e(i,r,n)};var St=(s,t,e,r=[])=>{let n=new Set;s.forEach((o,a)=>{if(n.has(o)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${o}" \u2014 skipping.`);return}n.add(o);let i=t.querySelectorAll(`#${o}`);if(i.length>1){console.warn(`[useTSCollection] Duplicate ID in DOM: "${o}" (${i.length} elements found) \u2014 skipping component mount.`);return}let c=e[a],l=Array.isArray(r)?r[a]:void 0;typeof c=="function"?z(o,t,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${o}"`)})};var N=(s,t)=>{let r=(t??document).querySelectorAll(s);if(r.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${s}'`),null;if(s.startsWith("#")&&r.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${s}'. 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: '${s}'. Returning the first one.`),r[0]};var Xt=require("jwt-decode"),Pt=(s,t)=>{let e=localStorage.getItem("token");if(!e)return window.location.href=t,null;try{let r=(0,Xt.jwtDecode)(e),n=Date.now()/1e3;return r.exp&&r.exp<n&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=t),null}catch(r){return console.error("Invalid token:",r),window.location.href=t,null}};var K=(s,t,e)=>{s.forEach(r=>{t.forEach(n=>{r.addEventListener(n,o=>{e(r,o)})})})};var vt=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var Rt=(s,t)=>{let e=document.querySelector(`#${s}`)||document.querySelector(`.${s}`);if(!e)return;let r=window.location.pathname.replace(/\/$/,"");for(let n of t){let o=n.path.replace(/\/$/,"");if(r===o||r.startsWith(`${o}/`)){n.component(e);break}}};function Lt(s,t){let e=window.location.pathname.replace(/\/$/,"");t.routes.forEach(r=>{r.children?.length&&r.children.forEach(n=>{let o=n.path.replace(/\/$/,"");if(e===o||e.startsWith(`${o}/`)){let a=s.querySelector(`#${n.outlet}`)||s.querySelector(`.${n.outlet}`);a instanceof HTMLElement&&n.element&&n.element(a)}})})}var te=require("zustand/vanilla");function bt(s){let t=(0,te.createStore)(()=>({value:s})),e=new Set;return{get:()=>t.getState().value,set:r=>{t.setState({value:r}),e.forEach(n=>n(r))},subscribe:r=>(e.add(r),r(t.getState().value),()=>e.delete(r))}}function xt(s){let t=s();typeof t=="function"&&t()}var At=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=r=>new Promise((n,o)=>{let a=document.createElement("script");a.src=r,a.onload=()=>n(),a.onerror=()=>o(new Error(`Failed to load ${r}`)),document.head.appendChild(a)});await e(s),await e(t),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},Dt=s=>new Promise((t,e)=>{let r=document.createElement("script");r.type="text/python",r.src=`/src/python/${s}`,r.onload=()=>t(),r.onerror=()=>e(new Error(`Failed to load ${s}`)),document.body.appendChild(r)});function Mt(s){let t=null;return async(e,r)=>{try{if(!t){let n=await s();t=n.default||n}if(typeof t=="function")return t(e,r);if(t instanceof HTMLElement){let n=t.cloneNode(!0);return e?.appendChild(n),n}if(typeof t=="object"&&t!==null&&"render"in t&&typeof t.render=="function")return t.render(e,r);console.warn("useTSLazy: Unsupported module type",t)}catch(n){console.error("useTSLazy failed:",n)}}}var Ct=s=>typeof window>"u"?{isDOM:null}:{isDOM:s||document.body};var ee=require("lodash-es"),Ot=s=>s;typeof window<"u"&&typeof document<"u"&&(Ot=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 r=e.getAttribute("class")||"";e.setAttribute("class",Ot(r));let n=e.getAttribute("aria-label");n&&e.setAttribute("aria-label",Ot(n));let o=e.querySelector(":scope > *");o&&(e.innerHTML="",e.appendChild(o));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",i=>{i.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,ee.debounce)(je,50),W=s=>{Ue(s)};var Ft=s=>{if(!s)return;let t=N("a",s);W(t)};var Ht=v(require("dompurify"),1);var ne=require("zustand/vanilla"),re=v(require("dompurify"),1),O=(0,ne.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]=re.default.sanitize(s[e]);return t}var Q=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,r=this.parseQueryParams(e),n=this.findMatchingRoute(t,this.routes);if(n){if(n.routeto){this.navigate(n.routeto);return}let o=this.filterAndSanitizeParams(n.params);O.getState().setParams(o),O.getState().setQuery(r);let a=document.createElement("div");if(n.element?.(a,o,r),n.children){let i=t.slice(n.path.length),c=a.querySelector("#child");c&&this.renderChildren(n.children,i,c,o,r)}}else{let o=this.findMatchingRoute("*",this.routes);if(o){let a=this.filterAndSanitizeParams(o.params);O.getState().setParams(a),O.getState().setQuery(r);let i=document.createElement("div");o.element?.(i,a,r)}}}renderChildren(t,e,r,n,o){if(!t||t.length===0){let i=r.querySelector("#child");i&&i.remove();return}let a=this.findMatchingRoute(e,t);if(a){let i=document.createElement("div");i.id="child";let c={...n,...a.params},l=this.filterAndSanitizeParams(c);if(O.getState().setParams(l),O.getState().setQuery(o),a.element?.(i,l,o),r.appendChild(i),a.children){let u=e.slice(a.path.length);this.renderChildren(a.children,u,i,l,o)}}}parseQueryParams(t){let e={},r=new URLSearchParams(t);for(let[n,o]of r.entries())this.expectedParams.has(n)&&(e[n]=Ht.default.sanitize(o));return e}findMatchingRoute(t,e,r={}){for(let n of e){let o=n.path;if(o==="*")return n;{let i=[],c=o.replace(/:[^\s/]+/g,d=>(i.push(d.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),u=t.match(l);if(u){let d={...r};if(i.forEach((h,f)=>{d[h]=u[f+1]??""}),n.children){let h=t.slice(u[0].length),f=this.findMatchingRoute(h,n.children,d);if(f)return f}return{...n,params:d}}}}}filterAndSanitizeParams(t){if(!t)return{};let e={};for(let r in t)this.expectedParams.has(r)&&(e[r]=Ht.default.sanitize(t[r]??""));return e}navigate(t){history.pushState(null,"",t),this.handlePopState()}addRoute(t){this.routes.push(t)}};var x=v(require("path"),1),De=()=>({name:"ts-filebased-router",async buildStart(){if(typeof process>"u"||!process.versions?.node)return;let s=await import("fs/promises"),t=await Promise.resolve().then(()=>(Ae(),xe)),e=x.default.resolve("src/pages"),r=x.default.resolve("src/gen"),n=x.default.resolve("src/routes"),o=x.default.join(r,"tsrouter.gen.ts"),a=x.default.join(n,"__root.ts"),i=process.env.NODE_ENV!=="production";async function c(p){try{await s.mkdir(p,{recursive:!0})}catch{}}function l(p,S){let g="/"+x.default.relative(S,p).replace(/\\/g,"/");return g=g.replace(/\.ts$/,"").replace(/\/index$/,"")||"/",g.replace(/\[(.+?)\]/g,":$1")}function u(p){return p.replace(/^\//,"").split("/").map(S=>S.startsWith(":")?S.slice(1):S).filter(Boolean).join("-")||"index"}function d(p,S){let T=x.default.relative(S,p).replace(/\\/g,"/").split("/").filter(Boolean),_=T[T.length-1].replace(".ts",""),D=T.length>1?T[T.length-2]:"";if(_==="index")return D?D.charAt(0).toUpperCase()+D.slice(1):"Index";if(_.startsWith("[")&&_.endsWith("]")){let I=_.slice(1,-1);return D.charAt(0).toUpperCase()+I.charAt(0).toUpperCase()+I.slice(1)}return _.charAt(0).toUpperCase()+_.slice(1)}async function h(p){let S=await s.readdir(p,{withFileTypes:!0}),g=[];for(let T of S){let _=x.default.join(p,T.name);if(T.isDirectory())g=g.concat(await h(_));else if(T.isFile()&&T.name.endsWith(".ts")){let D=l(_,e),I=u(D),ot=d(_,e);g.push({file:_,route:D,routeName:I,importName:ot})}}return g}function f(){return`import { createRouter } from "@/gen/tsrouter.gen";
|
|
2
2
|
|
|
3
3
|
export const Router = async (DOM: HTMLElement) => {
|
|
4
4
|
const router = await createRouter(DOM);
|
|
@@ -8,7 +8,7 @@ export const Router = async (DOM: HTMLElement) => {
|
|
|
8
8
|
window.addEventListener("popstate", () => {
|
|
9
9
|
void router.navigate(window.location.pathname + window.location.search, false);
|
|
10
10
|
});
|
|
11
|
-
};`}async function
|
|
11
|
+
};`}async function E(){let p=await h(e),S=p.find(P=>P.route==="/notfound"),g=p.filter(P=>P.route!=="/notfound");for(let P of p)if(!(await s.readFile(P.file,"utf-8")).trim()){let Y=P.importName,B=P.route.includes(":"),Me=["html","useTSElements","useTSMetaData",...B?["useTSExtractParams"]:[]].join(", ");await s.writeFile(P.file,`import { ${Me} } from "@devwareng/vanilla-ts";
|
|
12
12
|
|
|
13
13
|
export default function ${Y}(DOM: HTMLElement) {
|
|
14
14
|
useTSMetaData({
|
|
@@ -34,7 +34,7 @@ export default function ${Y}(DOM: HTMLElement) {
|
|
|
34
34
|
|
|
35
35
|
return ui;
|
|
36
36
|
}`,"utf-8")}let _=["useTSLazy",...!S?["html","useTSElements"]:[]].join(", "),D=g.map(P=>{let Yt="../pages/"+x.default.relative(e,P.file).replace(/\\/g,"/").replace(/\.ts$/,"");return`{ path: "${P.route}", name: "${P.routeName}", component: useTSLazy(() => import("${Yt}")) }`}).join(`,
|
|
37
|
-
`),
|
|
37
|
+
`),I=S?`export const NotFound = useTSLazy(() => import("../pages/${x.default.relative(e,S.file).replace(/\\/g,"/").replace(/\.ts$/,"")}"))`:`export function NotFound(DOM: HTMLElement) {
|
|
38
38
|
return useTSElements(
|
|
39
39
|
DOM,
|
|
40
40
|
html\`<div><h1>404 - Page Not Found</h1></div>\`
|
|
@@ -48,7 +48,7 @@ type Route = {
|
|
|
48
48
|
component: (DOM: HTMLElement) => Promise<any>;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
${
|
|
51
|
+
${I}
|
|
52
52
|
|
|
53
53
|
export const routeTree: Route[] = [
|
|
54
54
|
${D}
|
|
@@ -78,7 +78,7 @@ export async function createRouter(DOM: HTMLElement) {
|
|
|
78
78
|
|
|
79
79
|
return { navigate, routes: routeTree };
|
|
80
80
|
}
|
|
81
|
-
`;await c(
|
|
81
|
+
`;await c(r),await s.writeFile(o,ot,"utf-8"),await s.writeFile(a,f(),"utf-8")}await c(r),await c(n),await c(e),await E(),i&&(t.watch(e).on("all",async(S,g)=>{g.endsWith(".ts")&&await E()}),t.watch(a).on("unlink",async()=>{await s.writeFile(a,f(),"utf-8")})),console.log("\u{1F7E2} TS Router Generated (Smart + Clean Mode)")}});0&&(module.exports={TSFilebasedRouter,TSRouter,createEffect,createSignal,html,loadPyFiles,mapper,renderChildRoutes,useAnchor,useAnchorSingle,useInitialDOM,useTSAuth,useTSCollection,useTSComponent,useTSElementEach,useTSElements,useTSEvent,useTSEventAll,useTSExtractParams,useTSLazy,useTSMetaData,useTSNavigate,useTSNoReload,useTSOutlet,useTSParams,useTSPurifier,useTSSSRHydration,useTSSelect,useTSloadBrython});
|
|
82
82
|
/*! Bundled license information:
|
|
83
83
|
|
|
84
84
|
chokidar/esm/index.js:
|
package/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { Plugin } from 'vite';
|
|
|
2
2
|
import { Config } from 'dompurify';
|
|
3
3
|
import * as zustand_vanilla from 'zustand/vanilla';
|
|
4
4
|
|
|
5
|
-
declare function html(strings: TemplateStringsArray, ...values: unknown[]):
|
|
5
|
+
declare function html(strings: TemplateStringsArray, ...values: unknown[]): HTMLElement;
|
|
6
6
|
|
|
7
7
|
declare const mapper: (arr: string[] | undefined) => string;
|
|
8
8
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Plugin } from 'vite';
|
|
|
2
2
|
import { Config } from 'dompurify';
|
|
3
3
|
import * as zustand_vanilla from 'zustand/vanilla';
|
|
4
4
|
|
|
5
|
-
declare function html(strings: TemplateStringsArray, ...values: unknown[]):
|
|
5
|
+
declare function html(strings: TemplateStringsArray, ...values: unknown[]): HTMLElement;
|
|
6
6
|
|
|
7
7
|
declare const mapper: (arr: string[] | undefined) => string;
|
|
8
8
|
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function fe(n){let t=n==null?"":String(n),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 z(n,...t){return n.reduce((e,r,o)=>{let i=o<t.length?fe(t[o]):"";return e+r+i},"")}var he=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(),ge=n=>n?.map(t=>he(t)).join("")??"";import _ from"dompurify";var I=(n,t)=>{let r={...{ADD_TAGS:["my-custom-tag"]},...t};return typeof n=="string"?_.sanitize(n,r):_.sanitize(n.innerHTML,r)};var q=(n,t,e)=>{if(typeof n=="string"){let r=document.getElementById(n);r?r.addEventListener(t,e):console.warn(`Element with id '${n}' not found.`)}else n instanceof HTMLElement?n.addEventListener(t,e):n===document?document.addEventListener(t,e):console.warn("Invalid target parameter provided.")};import{createStore as Te}from"zustand/vanilla";import j from"dompurify";function Se(n,t){let e=[],r=n.replace(/:[^/]+/g,s=>(e.push(s.slice(1)),"([^/]+)")),o=new RegExp(`^${r}$`),i=t.match(o),a={};return i&&e.forEach((s,c)=>{a[s]=j.sanitize(i[c+1]??"")}),a}function Ee(n){let t={},e=new URLSearchParams(n);for(let[r,o]of e.entries())t[r]=j.sanitize(o);return t}var x=Te((n,t)=>({params:{},query:{},setFromPattern:e=>{let r=window.location.pathname,o=Se(e,r),i=Ee(window.location.search);n({params:o,query:i})},getParam:e=>t().params[e],getQuery:e=>t().query[e]}));function U(n){let t=x.getState();t.setFromPattern(n);let e=t.params,r=t.query;return{...e,...r}}var B=(n,t,e)=>{let r=document.querySelectorAll(n);return r.forEach(o=>{o.addEventListener(t,e)}),()=>{r.forEach(o=>{o.removeEventListener(t,e)})}};import W from"dompurify";var G=(n,t,e={},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(),d=(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(d)||/^\/(?!\/)/.test(d)||/^data:image\/(png|jpeg|jpg|gif|webp);base64,/i.test(d)||(c.keepAttr=!1);return}if(l==="class"){let S=d.split(/\s+/).filter(Boolean).filter(g=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]*$/.test(g)){if(/^bg-\[url\(.*\)\]$/.test(g)){let v=g.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return v===""||/^https?:\/\//i.test(v)||/^\/(?!\/)/.test(v)||/^\.{0,2}\//.test(v)}return/^bg-\[\]$/.test(g),!0}return!1});c.attrValue=S.join(" ");return}});let i=W.sanitize(t,{...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 d=l.getAttribute(s);d&&Object.prototype.hasOwnProperty.call(e,d)&&l.addEventListener(c,m=>{c==="submit"&&m.preventDefault(),e[d](m)})})};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(e,c)&&s.addEventListener(l,e[c])}),n.querySelectorAll("[data-hover]").forEach(s=>{let c=s.dataset.hover;c&&Object.prototype.hasOwnProperty.call(e,c)&&(s.addEventListener("mouseenter",e[c]),s.addEventListener("mouseleave",e[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 C=null,Q=(n,t)=>{if(typeof document>"u")return;let e=document.getElementById(n);if(!e)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 m=l.split(/\s+/).filter(Boolean).filter(S=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]+$/.test(S)){if(/^bg-\[url\(.*\)\]$/.test(S)){let g=S.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return g===""||/^https?:\/\//i.test(g)||/^\/(?!\/)/.test(g)||/^\.{0,2}\//.test(g)}return!0}return!1});s.attrValue=m.join(" ");return}if(c==="style"){s.keepAttr=!1;return}});let r=e.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(C!==null&&i!==C){let a=document.createElement("div");t(a);let c=new DOMParser().parseFromString(C,"text/html");for(;e.firstChild;)e.removeChild(e.firstChild);c.body.childNodes.forEach(l=>e.appendChild(l.cloneNode(!0)))}else{for(C=i;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(o),t(e)}};import K from"dompurify";typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",n=>{let t=n.state;t?.scrollPosition!==void 0&&window.scrollTo(0,t.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var Z=(n,t,e,r="",o=null)=>{if(!n)return;let i=K.sanitize(t,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=K.sanitize(e,{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 d=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:d},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};import L from"dompurify";var J=(n="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",t="'self' 'nonce-rAnd0m123'",e="'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 d=()=>{try{let m=document.querySelector('meta[http-equiv="Content-Security-Policy"]');m||(m=document.createElement("meta"),m.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(m));let S=l?`report-uri ${c};`:"";m.setAttribute("content",`default-src 'self'; script-src ${n}; style-src ${t}; object-src ${e}; font-src ${r}; img-src ${o}; connect-src ${i.join(" ")}; frame-src ${a}; base-uri ${s}; ${S}`)}catch(m){console.error("Error adding CSP meta element:",m)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",d):d()};var X=(n,t)=>{let e={name:L.sanitize(n.name||""),title:L.sanitize(n.title||""),description:L.sanitize(n.description||"Default description"),author:L.sanitize(n.author||""),favicon:n.favicon},r=u=>{e.name=L.sanitize(u),p("name",e.name)},o=u=>{e.title=L.sanitize(u),document.title=e.title},i=u=>{e.description=L.sanitize(u),p("description",e.description)},a=u=>{e.author=L.sanitize(u),p("author",e.author)},s=u=>{e.favicon=L.sanitize(u);let f=document.querySelector('link[rel="icon"]');f||(f=document.createElement("link"),f.rel="icon",document.head.appendChild(f)),f.href=e.favicon},c=()=>e.name,l=()=>e.title,d=()=>e.description,m=()=>e.author,S=()=>e.favicon,g=()=>e,v=(u,f)=>{let h=document.createElement("meta");h.setAttribute("name",u),h.setAttribute("content",f),document.head.appendChild(h)},p=(u,f)=>{let h=document.querySelector(`meta[name="${u}"]`);h?h.setAttribute("content",f):v(u,f)},T=()=>{e.title&&(document.title=e.title),e.name&&p("name",e.name),e.description&&p("description",e.description),e.author&&p("author",e.author),e.favicon&&s(e.favicon)};return t&&J(t.scriptSrc,t.styleSrc,t.objectSrc,Array.isArray(t.connectSrc)?t.connectSrc.join(" "):t.connectSrc,t.reportOnly!==void 0?String(t.reportOnly):void 0),T(),{setName:r,setTitle:o,setDescription:i,setAuthor:a,setFavicon:s,getName:c,getTitle:l,getDescription:d,getAuthor:m,getFavicon:S,getAllMetaData:g,appendMetaTagsToHead:T}};import ye from"dompurify";var D=(n,t,e,r,o)=>{let i=`#${n}`,a=t.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=ye.sanitize(s.innerHTML,{USE_PROFILES:{html:!0}}),e(s,r,o)};var Y=(n,t,e,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=t.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=e[a],l=Array.isArray(r)?r[a]:void 0;typeof c=="function"?D(i,t,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var b=(n,t)=>{let r=(t??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 ve}from"jwt-decode";var ee=(n,t)=>{let e=localStorage.getItem("token");if(!e)return window.location.href=t,null;try{let r=ve(e),o=Date.now()/1e3;return r.exp&&r.exp<o&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=t),null}catch(r){return console.error("Invalid token:",r),window.location.href=t,null}};var $=(n,t,e)=>{n.forEach(r=>{t.forEach(o=>{r.addEventListener(o,i=>{e(r,i)})})})};var te=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var ne=(n,t)=>{let e=document.querySelector(`#${n}`)||document.querySelector(`.${n}`);if(!e)return;let r=window.location.pathname.replace(/\/$/,"");for(let o of t){let i=o.path.replace(/\/$/,"");if(r===i||r.startsWith(`${i}/`)){o.component(e);break}}};function re(n,t){let e=window.location.pathname.replace(/\/$/,"");t.routes.forEach(r=>{r.children?.length&&r.children.forEach(o=>{let i=o.path.replace(/\/$/,"");if(e===i||e.startsWith(`${i}/`)){let a=n.querySelector(`#${o.outlet}`)||n.querySelector(`.${o.outlet}`);a instanceof HTMLElement&&o.element&&o.element(a)}})})}import{createStore as we}from"zustand/vanilla";function oe(n){let t=we(()=>({value:n})),e=new Set;return{get:()=>t.getState().value,set:r=>{t.setState({value:r}),e.forEach(o=>o(r))},subscribe:r=>(e.add(r),r(t.getState().value),()=>e.delete(r))}}function se(n){let t=n();typeof t=="function"&&t()}var ie=async()=>{let n="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",t="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",e=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 e(n),await e(t),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},ae=n=>new Promise((t,e)=>{let r=document.createElement("script");r.type="text/python",r.src=`/src/python/${n}`,r.onload=()=>t(),r.onerror=()=>e(new Error(`Failed to load ${n}`)),document.body.appendChild(r)});function ce(n){let t=null;return async(e,r)=>{try{if(!t){let o=await n();t=o.default||o}if(typeof t=="function")return t(e,r);if(t instanceof HTMLElement){let o=t.cloneNode(!0);return e?.appendChild(o),o}if(typeof t=="object"&&t!==null&&"render"in t&&typeof t.render=="function")return t.render(e,r);console.warn("useTSLazy: Unsupported module type",t)}catch(o){console.error("useTSLazy failed:",o)}}}var le=n=>typeof window>"u"?{isDOM:null}:{isDOM:n||document.body};import{debounce as Le}from"lodash-es";var k=n=>n;typeof window<"u"&&typeof document<"u"&&(k=n=>{let t=document.createElement("div");return t.innerText=n,t.innerHTML});var Me=n=>{(n?Array.isArray(n)?n:n instanceof HTMLAnchorElement?[n]:Array.from(n):Array.from(document.querySelectorAll("a"))).forEach(e=>{if(!e||e.dataset.anchorEnhanced==="true")return;e.dataset.anchorEnhanced="true";let r=e.getAttribute("class")||"";e.setAttribute("class",k(r));let o=e.getAttribute("aria-label");o&&e.setAttribute("aria-label",k(o));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",s=>{s.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)}})}})},Re=Le(Me,50),O=n=>{Re(n)};var ue=n=>{if(!n)return;let t=b("a",n);O(t)};import me from"dompurify";import{createStore as be}from"zustand/vanilla";import Ae from"dompurify";var M=be(n=>({params:{},query:{},setParams:t=>n(()=>({params:de(t)})),setQuery:t=>n(()=>({query:de(t)}))}));function de(n){let t={};for(let e in n)t[e]=Ae.sanitize(n[e]);return t}var N=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,r=this.parseQueryParams(e),o=this.findMatchingRoute(t,this.routes);if(o){if(o.routeto){this.navigate(o.routeto);return}let i=this.filterAndSanitizeParams(o.params);M.getState().setParams(i),M.getState().setQuery(r);let a=document.createElement("div");if(o.element?.(a,i,r),o.children){let s=t.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);M.getState().setParams(a),M.getState().setQuery(r);let s=document.createElement("div");i.element?.(s,a,r)}}}renderChildren(t,e,r,o,i){if(!t||t.length===0){let s=r.querySelector("#child");s&&s.remove();return}let a=this.findMatchingRoute(e,t);if(a){let s=document.createElement("div");s.id="child";let c={...o,...a.params},l=this.filterAndSanitizeParams(c);if(M.getState().setParams(l),M.getState().setQuery(i),a.element?.(s,l,i),r.appendChild(s),a.children){let d=e.slice(a.path.length);this.renderChildren(a.children,d,s,l,i)}}}parseQueryParams(t){let e={},r=new URLSearchParams(t);for(let[o,i]of r.entries())this.expectedParams.has(o)&&(e[o]=me.sanitize(i));return e}findMatchingRoute(t,e,r={}){for(let o of e){let i=o.path;if(i==="*")return o;{let s=[],c=i.replace(/:[^\s/]+/g,m=>(s.push(m.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),d=t.match(l);if(d){let m={...r};if(s.forEach((S,g)=>{m[S]=d[g+1]??""}),o.children){let S=t.slice(d[0].length),g=this.findMatchingRoute(S,o.children,m);if(g)return g}return{...o,params:m}}}}}filterAndSanitizeParams(t){if(!t)return{};let e={};for(let r in t)this.expectedParams.has(r)&&(e[r]=me.sanitize(t[r]??""));return e}navigate(t){history.pushState(null,"",t),this.handlePopState()}addRoute(t){this.routes.push(t)}};import y from"path";var Pe=()=>({name:"ts-filebased-router",async buildStart(){if(typeof process>"u"||!process.versions?.node)return;let n=await import("fs/promises"),t=await import("./esm-KRNKVVL7.js"),e=y.resolve("src/pages"),r=y.resolve("src/gen"),o=y.resolve("src/routes"),i=y.join(r,"tsrouter.gen.ts"),a=y.join(o,"__root.ts"),s=process.env.NODE_ENV!=="production";async function c(p){try{await n.mkdir(p,{recursive:!0})}catch{}}function l(p,T){let u="/"+y.relative(T,p).replace(/\\/g,"/");return u=u.replace(/\.ts$/,"").replace(/\/index$/,"")||"/",u.replace(/\[(.+?)\]/g,":$1")}function d(p){return p.replace(/^\//,"").split("/").map(T=>T.startsWith(":")?T.slice(1):T).filter(Boolean).join("-")||"index"}function m(p,T){let f=y.relative(T,p).replace(/\\/g,"/").split("/").filter(Boolean),h=f[f.length-1].replace(".ts",""),w=f.length>1?f[f.length-2]:"";if(h==="index")return w?w.charAt(0).toUpperCase()+w.slice(1):"Index";if(h.startsWith("[")&&h.endsWith("]")){let R=h.slice(1,-1);return w.charAt(0).toUpperCase()+R.charAt(0).toUpperCase()+R.slice(1)}return h.charAt(0).toUpperCase()+h.slice(1)}async function S(p){let T=await n.readdir(p,{withFileTypes:!0}),u=[];for(let f of T){let h=y.join(p,f.name);if(f.isDirectory())u=u.concat(await S(h));else if(f.isFile()&&f.name.endsWith(".ts")){let w=l(h,e),R=d(w),H=m(h,e);u.push({file:h,route:w,routeName:R,importName:H})}}return u}function g(){return`import { createRouter } from "@/gen/tsrouter.gen";
|
|
1
|
+
function he(n){return(n==null?"":String(n)).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function z(n,t){if(t==null)return;if(t instanceof Node){n.appendChild(t);return}if(Array.isArray(t)){t.forEach(r=>z(n,r));return}let e=document.createTextNode(he(t));n.appendChild(e)}function _(n,...t){let e=document.createElement("template");e.innerHTML=n.join("<!--slot-->");let r=e.content,o=document.createTreeWalker(r,NodeFilter.SHOW_COMMENT),a=0,i;for(;i=o.nextNode();){let s=t[a++],c=i.parentNode,l=document.createDocumentFragment();z(l,s),c.replaceChild(l,i)}return r.firstElementChild}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(t=>ge(t)).join("")??"";import I from"dompurify";var q=(n,t)=>{let r={...{ADD_TAGS:["my-custom-tag"]},...t};return typeof n=="string"?I.sanitize(n,r):I.sanitize(n.innerHTML,r)};var U=(n,t,e)=>{if(typeof n=="string"){let r=document.getElementById(n);r?r.addEventListener(t,e):console.warn(`Element with id '${n}' not found.`)}else n instanceof HTMLElement?n.addEventListener(t,e):n===document?document.addEventListener(t,e):console.warn("Invalid target parameter provided.")};import{createStore as Se}from"zustand/vanilla";import j from"dompurify";function Ee(n,t){let e=[],r=n.replace(/:[^/]+/g,s=>(e.push(s.slice(1)),"([^/]+)")),o=new RegExp(`^${r}$`),a=t.match(o),i={};return a&&e.forEach((s,c)=>{i[s]=j.sanitize(a[c+1]??"")}),i}function ye(n){let t={},e=new URLSearchParams(n);for(let[r,o]of e.entries())t[r]=j.sanitize(o);return t}var x=Se((n,t)=>({params:{},query:{},setFromPattern:e=>{let r=window.location.pathname,o=Ee(e,r),a=ye(window.location.search);n({params:o,query:a})},getParam:e=>t().params[e],getQuery:e=>t().query[e]}));function W(n){let t=x.getState();t.setFromPattern(n);let e=t.params,r=t.query;return{...e,...r}}var B=(n,t,e)=>{let r=document.querySelectorAll(n);return r.forEach(o=>{o.addEventListener(t,e)}),()=>{r.forEach(o=>{o.removeEventListener(t,e)})}};import G from"dompurify";var V=(n,t,e={},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};G.addHook("uponSanitizeAttribute",(s,c)=>{let l=(c.attrName||"").toLowerCase(),d=(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(d)||/^\/(?!\/)/.test(d)||/^data:image\/(png|jpeg|jpg|gif|webp);base64,/i.test(d)||(c.keepAttr=!1);return}if(l==="class"){let S=d.split(/\s+/).filter(Boolean).filter(g=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]*$/.test(g)){if(/^bg-\[url\(.*\)\]$/.test(g)){let v=g.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return v===""||/^https?:\/\//i.test(v)||/^\/(?!\/)/.test(v)||/^\.{0,2}\//.test(v)}return/^bg-\[\]$/.test(g),!0}return!1});c.attrValue=S.join(" ");return}});let a=G.sanitize(t,{...o,RETURN_DOM_FRAGMENT:!0});for(;n.firstChild;)n.removeChild(n.firstChild);n.appendChild(a);let i=(s,c)=>{n.querySelectorAll(`[${s}]`).forEach(l=>{let d=l.getAttribute(s);d&&Object.prototype.hasOwnProperty.call(e,d)&&l.addEventListener(c,m=>{c==="submit"&&m.preventDefault(),e[d](m)})})};i("data-click","click"),i("data-change","change"),i("data-select","select"),i("data-submit","submit"),n.querySelectorAll("[data-key]").forEach(s=>{let c=s.dataset.key,l=s.dataset.event??"click";c&&Object.prototype.hasOwnProperty.call(e,c)&&s.addEventListener(l,e[c])}),n.querySelectorAll("[data-hover]").forEach(s=>{let c=s.dataset.hover;c&&Object.prototype.hasOwnProperty.call(e,c)&&(s.addEventListener("mouseenter",e[c]),s.addEventListener("mouseleave",e[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 Q from"dompurify";var C=null,K=(n,t)=>{if(typeof document>"u")return;let e=document.getElementById(n);if(!e)return;Q.addHook("uponSanitizeAttribute",(i,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 m=l.split(/\s+/).filter(Boolean).filter(S=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]+$/.test(S)){if(/^bg-\[url\(.*\)\]$/.test(S)){let g=S.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return g===""||/^https?:\/\//i.test(g)||/^\/(?!\/)/.test(g)||/^\.{0,2}\//.test(g)}return!0}return!1});s.attrValue=m.join(" ");return}if(c==="style"){s.keepAttr=!1;return}});let r=e.cloneNode(!0),o=Q.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}),a=Array.from(o.childNodes).map(i=>i.outerHTML||i.textContent||"").join("");if(C!==null&&a!==C){let i=document.createElement("div");t(i);let c=new DOMParser().parseFromString(C,"text/html");for(;e.firstChild;)e.removeChild(e.firstChild);c.body.childNodes.forEach(l=>e.appendChild(l.cloneNode(!0)))}else{for(C=a;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(o),t(e)}};import Z from"dompurify";typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",n=>{let t=n.state;t?.scrollPosition!==void 0&&window.scrollTo(0,t.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var J=(n,t,e,r="",o=null)=>{if(!n)return;let a=Z.sanitize(t,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),i=Z.sanitize(e,{USE_PROFILES:{html:!1}});n.setAttribute("href",a),n.setAttribute("aria-label",i),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 d=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:d},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};import L from"dompurify";var X=(n="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",t="'self' 'nonce-rAnd0m123'",e="'none'",r="'self' https://fonts.googleapis.com https://fonts.gstatic.com",o="'self' https://blogger.googleusercontent.com",a=["'self'","https://fonts.googleapis.com","https://fonts.gstatic.com","https://www.google.com/maps/"],i="'self' https://www.youtube.com",s="'self'",c="/csp-report",l=!1)=>{let d=()=>{try{let m=document.querySelector('meta[http-equiv="Content-Security-Policy"]');m||(m=document.createElement("meta"),m.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(m));let S=l?`report-uri ${c};`:"";m.setAttribute("content",`default-src 'self'; script-src ${n}; style-src ${t}; object-src ${e}; font-src ${r}; img-src ${o}; connect-src ${a.join(" ")}; frame-src ${i}; base-uri ${s}; ${S}`)}catch(m){console.error("Error adding CSP meta element:",m)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",d):d()};var Y=(n,t)=>{let e={name:L.sanitize(n.name||""),title:L.sanitize(n.title||""),description:L.sanitize(n.description||"Default description"),author:L.sanitize(n.author||""),favicon:n.favicon},r=u=>{e.name=L.sanitize(u),p("name",e.name)},o=u=>{e.title=L.sanitize(u),document.title=e.title},a=u=>{e.description=L.sanitize(u),p("description",e.description)},i=u=>{e.author=L.sanitize(u),p("author",e.author)},s=u=>{e.favicon=L.sanitize(u);let f=document.querySelector('link[rel="icon"]');f||(f=document.createElement("link"),f.rel="icon",document.head.appendChild(f)),f.href=e.favicon},c=()=>e.name,l=()=>e.title,d=()=>e.description,m=()=>e.author,S=()=>e.favicon,g=()=>e,v=(u,f)=>{let h=document.createElement("meta");h.setAttribute("name",u),h.setAttribute("content",f),document.head.appendChild(h)},p=(u,f)=>{let h=document.querySelector(`meta[name="${u}"]`);h?h.setAttribute("content",f):v(u,f)},T=()=>{e.title&&(document.title=e.title),e.name&&p("name",e.name),e.description&&p("description",e.description),e.author&&p("author",e.author),e.favicon&&s(e.favicon)};return t&&X(t.scriptSrc,t.styleSrc,t.objectSrc,Array.isArray(t.connectSrc)?t.connectSrc.join(" "):t.connectSrc,t.reportOnly!==void 0?String(t.reportOnly):void 0),T(),{setName:r,setTitle:o,setDescription:a,setAuthor:i,setFavicon:s,getName:c,getTitle:l,getDescription:d,getAuthor:m,getFavicon:S,getAllMetaData:g,appendMetaTagsToHead:T}};import ve from"dompurify";var D=(n,t,e,r,o)=>{let a=`#${n}`,i=t.querySelectorAll(a);if(i.length===0)throw new Error(`[useTSComponent] No element found with id '${n}' in the given parent.`);if(i.length>1)throw new Error(`[useTSComponent] Duplicate id '${n}' detected. Found ${i.length} elements.`);let s=i[0];s.innerHTML=ve.sanitize(s.innerHTML,{USE_PROFILES:{html:!0}}),e(s,r,o)};var ee=(n,t,e,r=[])=>{let o=new Set;n.forEach((a,i)=>{if(o.has(a)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${a}" \u2014 skipping.`);return}o.add(a);let s=t.querySelectorAll(`#${a}`);if(s.length>1){console.warn(`[useTSCollection] Duplicate ID in DOM: "${a}" (${s.length} elements found) \u2014 skipping component mount.`);return}let c=e[i],l=Array.isArray(r)?r[i]:void 0;typeof c=="function"?D(a,t,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${a}"`)})};var A=(n,t)=>{let r=(t??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 te=(n,t)=>{let e=localStorage.getItem("token");if(!e)return window.location.href=t,null;try{let r=we(e),o=Date.now()/1e3;return r.exp&&r.exp<o&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=t),null}catch(r){return console.error("Invalid token:",r),window.location.href=t,null}};var $=(n,t,e)=>{n.forEach(r=>{t.forEach(o=>{r.addEventListener(o,a=>{e(r,a)})})})};var ne=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var re=(n,t)=>{let e=document.querySelector(`#${n}`)||document.querySelector(`.${n}`);if(!e)return;let r=window.location.pathname.replace(/\/$/,"");for(let o of t){let a=o.path.replace(/\/$/,"");if(r===a||r.startsWith(`${a}/`)){o.component(e);break}}};function oe(n,t){let e=window.location.pathname.replace(/\/$/,"");t.routes.forEach(r=>{r.children?.length&&r.children.forEach(o=>{let a=o.path.replace(/\/$/,"");if(e===a||e.startsWith(`${a}/`)){let i=n.querySelector(`#${o.outlet}`)||n.querySelector(`.${o.outlet}`);i instanceof HTMLElement&&o.element&&o.element(i)}})})}import{createStore as Le}from"zustand/vanilla";function se(n){let t=Le(()=>({value:n})),e=new Set;return{get:()=>t.getState().value,set:r=>{t.setState({value:r}),e.forEach(o=>o(r))},subscribe:r=>(e.add(r),r(t.getState().value),()=>e.delete(r))}}function ie(n){let t=n();typeof t=="function"&&t()}var ae=async()=>{let n="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",t="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",e=r=>new Promise((o,a)=>{let i=document.createElement("script");i.src=r,i.onload=()=>o(),i.onerror=()=>a(new Error(`Failed to load ${r}`)),document.head.appendChild(i)});await e(n),await e(t),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},ce=n=>new Promise((t,e)=>{let r=document.createElement("script");r.type="text/python",r.src=`/src/python/${n}`,r.onload=()=>t(),r.onerror=()=>e(new Error(`Failed to load ${n}`)),document.body.appendChild(r)});function le(n){let t=null;return async(e,r)=>{try{if(!t){let o=await n();t=o.default||o}if(typeof t=="function")return t(e,r);if(t instanceof HTMLElement){let o=t.cloneNode(!0);return e?.appendChild(o),o}if(typeof t=="object"&&t!==null&&"render"in t&&typeof t.render=="function")return t.render(e,r);console.warn("useTSLazy: Unsupported module type",t)}catch(o){console.error("useTSLazy failed:",o)}}}var ue=n=>typeof window>"u"?{isDOM:null}:{isDOM:n||document.body};import{debounce as Me}from"lodash-es";var k=n=>n;typeof window<"u"&&typeof document<"u"&&(k=n=>{let t=document.createElement("div");return t.innerText=n,t.innerHTML});var Re=n=>{(n?Array.isArray(n)?n:n instanceof HTMLAnchorElement?[n]:Array.from(n):Array.from(document.querySelectorAll("a"))).forEach(e=>{if(!e||e.dataset.anchorEnhanced==="true")return;e.dataset.anchorEnhanced="true";let r=e.getAttribute("class")||"";e.setAttribute("class",k(r));let o=e.getAttribute("aria-label");o&&e.setAttribute("aria-label",k(o));let a=e.querySelector(":scope > *");a&&(e.innerHTML="",e.appendChild(a));let i=e.getAttribute("href")||"";if(!i.startsWith("#")){try{if(new URL(i,window.location.href).origin!==window.location.origin)return}catch{return}e.addEventListener("click",s=>{s.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)}})}})},Ae=Me(Re,50),H=n=>{Ae(n)};var de=n=>{if(!n)return;let t=A("a",n);H(t)};import pe from"dompurify";import{createStore as Pe}from"zustand/vanilla";import be from"dompurify";var M=Pe(n=>({params:{},query:{},setParams:t=>n(()=>({params:me(t)})),setQuery:t=>n(()=>({query:me(t)}))}));function me(n){let t={};for(let e in n)t[e]=be.sanitize(n[e]);return t}var N=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,r=this.parseQueryParams(e),o=this.findMatchingRoute(t,this.routes);if(o){if(o.routeto){this.navigate(o.routeto);return}let a=this.filterAndSanitizeParams(o.params);M.getState().setParams(a),M.getState().setQuery(r);let i=document.createElement("div");if(o.element?.(i,a,r),o.children){let s=t.slice(o.path.length),c=i.querySelector("#child");c&&this.renderChildren(o.children,s,c,a,r)}}else{let a=this.findMatchingRoute("*",this.routes);if(a){let i=this.filterAndSanitizeParams(a.params);M.getState().setParams(i),M.getState().setQuery(r);let s=document.createElement("div");a.element?.(s,i,r)}}}renderChildren(t,e,r,o,a){if(!t||t.length===0){let s=r.querySelector("#child");s&&s.remove();return}let i=this.findMatchingRoute(e,t);if(i){let s=document.createElement("div");s.id="child";let c={...o,...i.params},l=this.filterAndSanitizeParams(c);if(M.getState().setParams(l),M.getState().setQuery(a),i.element?.(s,l,a),r.appendChild(s),i.children){let d=e.slice(i.path.length);this.renderChildren(i.children,d,s,l,a)}}}parseQueryParams(t){let e={},r=new URLSearchParams(t);for(let[o,a]of r.entries())this.expectedParams.has(o)&&(e[o]=pe.sanitize(a));return e}findMatchingRoute(t,e,r={}){for(let o of e){let a=o.path;if(a==="*")return o;{let s=[],c=a.replace(/:[^\s/]+/g,m=>(s.push(m.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),d=t.match(l);if(d){let m={...r};if(s.forEach((S,g)=>{m[S]=d[g+1]??""}),o.children){let S=t.slice(d[0].length),g=this.findMatchingRoute(S,o.children,m);if(g)return g}return{...o,params:m}}}}}filterAndSanitizeParams(t){if(!t)return{};let e={};for(let r in t)this.expectedParams.has(r)&&(e[r]=pe.sanitize(t[r]??""));return e}navigate(t){history.pushState(null,"",t),this.handlePopState()}addRoute(t){this.routes.push(t)}};import y from"path";var xe=()=>({name:"ts-filebased-router",async buildStart(){if(typeof process>"u"||!process.versions?.node)return;let n=await import("fs/promises"),t=await import("./esm-KRNKVVL7.js"),e=y.resolve("src/pages"),r=y.resolve("src/gen"),o=y.resolve("src/routes"),a=y.join(r,"tsrouter.gen.ts"),i=y.join(o,"__root.ts"),s=process.env.NODE_ENV!=="production";async function c(p){try{await n.mkdir(p,{recursive:!0})}catch{}}function l(p,T){let u="/"+y.relative(T,p).replace(/\\/g,"/");return u=u.replace(/\.ts$/,"").replace(/\/index$/,"")||"/",u.replace(/\[(.+?)\]/g,":$1")}function d(p){return p.replace(/^\//,"").split("/").map(T=>T.startsWith(":")?T.slice(1):T).filter(Boolean).join("-")||"index"}function m(p,T){let f=y.relative(T,p).replace(/\\/g,"/").split("/").filter(Boolean),h=f[f.length-1].replace(".ts",""),w=f.length>1?f[f.length-2]:"";if(h==="index")return w?w.charAt(0).toUpperCase()+w.slice(1):"Index";if(h.startsWith("[")&&h.endsWith("]")){let R=h.slice(1,-1);return w.charAt(0).toUpperCase()+R.charAt(0).toUpperCase()+R.slice(1)}return h.charAt(0).toUpperCase()+h.slice(1)}async function S(p){let T=await n.readdir(p,{withFileTypes:!0}),u=[];for(let f of T){let h=y.join(p,f.name);if(f.isDirectory())u=u.concat(await S(h));else if(f.isFile()&&f.name.endsWith(".ts")){let w=l(h,e),R=d(w),O=m(h,e);u.push({file:h,route:w,routeName:R,importName:O})}}return u}function g(){return`import { createRouter } from "@/gen/tsrouter.gen";
|
|
2
2
|
|
|
3
3
|
export const Router = async (DOM: HTMLElement) => {
|
|
4
4
|
const router = await createRouter(DOM);
|
|
@@ -8,26 +8,26 @@ export const Router = async (DOM: HTMLElement) => {
|
|
|
8
8
|
window.addEventListener("popstate", () => {
|
|
9
9
|
void router.navigate(window.location.pathname + window.location.search, false);
|
|
10
10
|
});
|
|
11
|
-
};`}async function v(){let p=await S(e),T=p.find(E=>E.route==="/notfound"),u=p.filter(E=>E.route!=="/notfound");for(let E of p)if(!(await n.readFile(E.file,"utf-8")).trim()){let
|
|
11
|
+
};`}async function v(){let p=await S(e),T=p.find(E=>E.route==="/notfound"),u=p.filter(E=>E.route!=="/notfound");for(let E of p)if(!(await n.readFile(E.file,"utf-8")).trim()){let P=E.importName,b=E.route.includes(":"),fe=["html","useTSElements","useTSMetaData",...b?["useTSExtractParams"]:[]].join(", ");await n.writeFile(E.file,`import { ${fe} } from "@devwareng/vanilla-ts";
|
|
12
12
|
|
|
13
|
-
export default function ${
|
|
13
|
+
export default function ${P}(DOM: HTMLElement) {
|
|
14
14
|
useTSMetaData({
|
|
15
|
-
title: "${
|
|
16
|
-
description: "${
|
|
15
|
+
title: "${P}",
|
|
16
|
+
description: "${P}",
|
|
17
17
|
author: "Your name here",
|
|
18
18
|
favicon: "/favicon.ico",
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
${
|
|
21
|
+
${b?`const params = useTSExtractParams("${E.route}");`:""}
|
|
22
22
|
|
|
23
|
-
${
|
|
23
|
+
${b?"if (Object.values(params).some(v => !v)) return;":""}
|
|
24
24
|
|
|
25
25
|
const ui = useTSElements(
|
|
26
26
|
DOM,
|
|
27
27
|
html\`
|
|
28
28
|
<div>
|
|
29
|
-
<h1>${
|
|
30
|
-
${
|
|
29
|
+
<h1>${P}</h1>
|
|
30
|
+
${b?"<pre>${JSON.stringify(params, null, 2)}</pre>":""}
|
|
31
31
|
</div>
|
|
32
32
|
\`
|
|
33
33
|
);
|
|
@@ -39,7 +39,7 @@ export default function ${A}(DOM: HTMLElement) {
|
|
|
39
39
|
DOM,
|
|
40
40
|
html\`<div><h1>404 - Page Not Found</h1></div>\`
|
|
41
41
|
);
|
|
42
|
-
}`,
|
|
42
|
+
}`,O=`// AUTO-GENERATED FILE
|
|
43
43
|
import { ${h} } from "@devwareng/vanilla-ts";
|
|
44
44
|
|
|
45
45
|
type Route = {
|
|
@@ -78,4 +78,4 @@ export async function createRouter(DOM: HTMLElement) {
|
|
|
78
78
|
|
|
79
79
|
return { navigate, routes: routeTree };
|
|
80
80
|
}
|
|
81
|
-
`;await c(r),await n.writeFile(
|
|
81
|
+
`;await c(r),await n.writeFile(a,O,"utf-8"),await n.writeFile(i,g(),"utf-8")}await c(r),await c(o),await c(e),await v(),s&&(t.watch(e).on("all",async(T,u)=>{u.endsWith(".ts")&&await v()}),t.watch(i).on("unlink",async()=>{await n.writeFile(i,g(),"utf-8")})),console.log("\u{1F7E2} TS Router Generated (Smart + Clean Mode)")}});export{xe as TSFilebasedRouter,N as TSRouter,ie as createEffect,se as createSignal,_ as html,ce as loadPyFiles,Te as mapper,oe as renderChildRoutes,H as useAnchor,J as useAnchorSingle,K as useInitialDOM,te as useTSAuth,ee as useTSCollection,D as useTSComponent,$ as useTSElementEach,V as useTSElements,U as useTSEvent,B as useTSEventAll,W as useTSExtractParams,le as useTSLazy,Y as useTSMetaData,ne as useTSNavigate,de as useTSNoReload,re as useTSOutlet,x as useTSParams,q as useTSPurifier,ue as useTSSSRHydration,A as useTSSelect,ae as useTSloadBrython};
|