@wsxjs/wsx-router 0.0.19 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +712 -929
- package/package.json +5 -5
- package/src/WsxLink.wsx +10 -6
- package/src/WsxView.wsx +19 -51
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("@wsxjs/wsx-core");function Be(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var le={exports:{}};function He(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var Ke=Je;function Je(t,e,n){var r=n&&n.stringify||He,s=1;if(typeof t=="object"&&t!==null){var l=e.length+s;if(l===1)return t;var m=new Array(l);m[0]=r(t);for(var p=1;p<l;p++)m[p]=r(e[p]);return m.join(" ")}if(typeof t!="string")return t;var u=e.length;if(u===0)return t;for(var i="",g=1-s,v=-1,z=t&&t.length||0,x=0;x<z;){if(t.charCodeAt(x)===37&&x+1<z){switch(v=v>-1?v:0,t.charCodeAt(x+1)){case 100:case 102:if(g>=u||e[g]==null)break;v<x&&(i+=t.slice(v,x)),i+=Number(e[g]),v=x+2,x++;break;case 105:if(g>=u||e[g]==null)break;v<x&&(i+=t.slice(v,x)),i+=Math.floor(Number(e[g])),v=x+2,x++;break;case 79:case 111:case 106:if(g>=u||e[g]===void 0)break;v<x&&(i+=t.slice(v,x));var o=typeof e[g];if(o==="string"){i+="'"+e[g]+"'",v=x+2,x++;break}if(o==="function"){i+=e[g].name||"<anonymous>",v=x+2,x++;break}i+=r(e[g]),v=x+2,x++;break;case 115:if(g>=u)break;v<x&&(i+=t.slice(v,x)),i+=String(e[g]),v=x+2,x++;break;case 37:v<x&&(i+=t.slice(v,x)),i+="%",v=x+2,x++,g--;break}++g}++x}return v===-1?t:(v<z&&(i+=t.slice(v)),i)}const xe=Ke;le.exports=J;const ie=lt().console||{},Ge={mapHttpRequest:oe,mapHttpResponse:oe,wrapRequestSerializer:he,wrapResponseSerializer:he,wrapErrorSerializer:he,req:oe,res:oe,err:Re,errWithCause:Re};function Z(t,e){return t==="silent"?1/0:e.levels.values[t]}const ye=Symbol("pino.logFuncs"),ve=Symbol("pino.hierarchy"),Qe={error:"log",fatal:"error",warn:"error",info:"log",debug:"log",trace:"log"};function Ee(t,e){const n={logger:e,parent:t[ve]};e[ve]=n}function Xe(t,e,n){const r={};e.forEach(s=>{r[s]=n[s]?n[s]:ie[s]||ie[Qe[s]||"log"]||re}),t[ye]=r}function Ye(t,e){return Array.isArray(t)?t.filter(function(r){return r!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function J(t){t=t||{},t.browser=t.browser||{};const e=t.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");const n=t.browser.write||ie;t.browser.write&&(t.browser.asObject=!0);const r=t.serializers||{},s=Ye(t.browser.serialize,r);let l=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(l=!1);const m=Object.keys(t.customLevels||{}),p=["error","fatal","warn","info","debug","trace"].concat(m);typeof n=="function"&&p.forEach(function(c){n[c]=n}),(t.enabled===!1||t.browser.disabled)&&(t.level="silent");const u=t.level||"info",i=Object.create(n);i.log||(i.log=re),Xe(i,p,n),Ee({},i),Object.defineProperty(i,"levelVal",{get:v}),Object.defineProperty(i,"level",{get:z,set:x});const g={transmit:e,serialize:s,asObject:t.browser.asObject,asObjectBindingsOnly:t.browser.asObjectBindingsOnly,formatters:t.browser.formatters,levels:p,timestamp:ot(t),messageKey:t.messageKey||"msg",onChild:t.onChild||re};i.levels=Ze(t),i.level=u,i.isLevelEnabled=function(c){return this.levels.values[c]?this.levels.values[c]>=this.levels.values[this.level]:!1},i.setMaxListeners=i.getMaxListeners=i.emit=i.addListener=i.on=i.prependListener=i.once=i.prependOnceListener=i.removeListener=i.removeAllListeners=i.listeners=i.listenerCount=i.eventNames=i.write=i.flush=re,i.serializers=r,i._serialize=s,i._stdErrSerialize=l,i.child=function(...c){return o.call(this,g,...c)},e&&(i._logEvent=be());function v(){return Z(this.level,this)}function z(){return this._level}function x(c){if(c!=="silent"&&!this.levels.values[c])throw Error("unknown level "+c);this._level=c,ee(this,g,i,"error"),ee(this,g,i,"fatal"),ee(this,g,i,"warn"),ee(this,g,i,"info"),ee(this,g,i,"debug"),ee(this,g,i,"trace"),m.forEach(f=>{ee(this,g,i,f)})}function o(c,f,h){if(!f)throw new Error("missing bindings for child Pino");h=h||{},s&&f.serializers&&(h.serializers=f.serializers);const d=h.serializers;if(s&&d){var T=Object.assign({},r,d),V=t.browser.serialize===!0?Object.keys(T):s;delete f.serializers,we([f],V,T,this._stdErrSerialize)}function A(C){this._childLevel=(C._childLevel|0)+1,this.bindings=f,T&&(this.serializers=T,this._serialize=V),e&&(this._logEvent=be([].concat(C._logEvent.bindings,f)))}A.prototype=this;const I=new A(this);return Ee(this,I),I.child=function(...C){return o.call(this,c,...C)},I.level=h.level||this.level,c.onChild(I),I}return i}function Ze(t){const e=t.customLevels||{},n=Object.assign({},J.levels.values,e),r=Object.assign({},J.levels.labels,et(e));return{values:n,labels:r}}function et(t){const e={};return Object.keys(t).forEach(function(n){e[t[n]]=n}),e}J.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};J.stdSerializers=Ge;J.stdTimeFunctions=Object.assign({},{nullTime:Ae,epochTime:Te,unixTime:at,isoTime:ct});function tt(t){const e=[];t.bindings&&e.push(t.bindings);let n=t[ve];for(;n.parent;)n=n.parent,n.logger.bindings&&e.push(n.logger.bindings);return e.reverse()}function ee(t,e,n,r){if(Object.defineProperty(t,r,{value:Z(t.level,n)>Z(r,n)?re:n[ye][r],writable:!0,enumerable:!0,configurable:!0}),t[r]===re){if(!e.transmit)return;const l=e.transmit.level||t.level,m=Z(l,n);if(Z(r,n)<m)return}t[r]=rt(t,e,n,r);const s=tt(t);s.length!==0&&(t[r]=nt(s,t[r]))}function nt(t,e){return function(){return e.apply(this,[...t,...arguments])}}function rt(t,e,n,r){return function(s){return function(){const m=e.timestamp(),p=new Array(arguments.length),u=Object.getPrototypeOf&&Object.getPrototypeOf(this)===ie?ie:this;for(var i=0;i<p.length;i++)p[i]=arguments[i];var g=!1;if(e.serialize&&(we(p,this._serialize,this.serializers,this._stdErrSerialize),g=!0),e.asObject||e.formatters?s.call(u,...it(this,r,p,m,e)):s.apply(u,p),e.transmit){const v=e.transmit.level||t._level,z=Z(v,n),x=Z(r,n);if(x<z)return;st(this,{ts:m,methodLevel:r,methodValue:x,transmitValue:n.levels.values[e.transmit.level||t._level],send:e.transmit.send,val:Z(t._level,n)},p,g)}}}(t[ye][r])}function it(t,e,n,r,s){const{level:l,log:m=v=>v}=s.formatters||{},p=n.slice();let u=p[0];const i={};let g=(t._childLevel|0)+1;if(g<1&&(g=1),r&&(i.time=r),l){const v=l(e,t.levels.values[e]);Object.assign(i,v)}else i.level=t.levels.values[e];if(s.asObjectBindingsOnly){if(u!==null&&typeof u=="object")for(;g--&&typeof p[0]=="object";)Object.assign(i,p.shift());return[m(i),...p]}else{if(u!==null&&typeof u=="object"){for(;g--&&typeof p[0]=="object";)Object.assign(i,p.shift());u=p.length?xe(p.shift(),p):void 0}else typeof u=="string"&&(u=xe(p.shift(),p));return u!==void 0&&(i[s.messageKey]=u),[m(i)]}}function we(t,e,n,r){for(const s in t)if(r&&t[s]instanceof Error)t[s]=J.stdSerializers.err(t[s]);else if(typeof t[s]=="object"&&!Array.isArray(t[s])&&e)for(const l in t[s])e.indexOf(l)>-1&&l in n&&(t[s][l]=n[l](t[s][l]))}function st(t,e,n,r=!1){const s=e.send,l=e.ts,m=e.methodLevel,p=e.methodValue,u=e.val,i=t._logEvent.bindings;r||we(n,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=l,t._logEvent.messages=n.filter(function(g){return i.indexOf(g)===-1}),t._logEvent.level.label=m,t._logEvent.level.value=p,s(m,t._logEvent,u),t._logEvent=be(i)}function be(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function Re(t){const e={type:t.constructor.name,msg:t.message,stack:t.stack};for(const n in t)e[n]===void 0&&(e[n]=t[n]);return e}function ot(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?Ae:Te}function oe(){return{}}function he(t){return t}function re(){}function Ae(){return!1}function Te(){return Date.now()}function at(){return Math.round(Date.now()/1e3)}function ct(){return new Date(Date.now()).toISOString()}function lt(){function t(e){return typeof e<"u"&&e}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return t(self)||t(window)||t(this)||{}}}le.exports.default=J;le.exports.pino=J;var ut=le.exports;const ae=Be(ut);function ce(){return typeof process<"u"&&process.env.NODE_ENV==="production"}function ht(){var t;return typeof process<"u"&&((t=process.versions)==null?void 0:t.node)!==void 0}function ft(){return typeof window<"u"&&typeof document<"u"}const fe={name:"WSX",level:ce()?"info":"debug",pretty:!ce()};function dt(t={}){const{name:e,level:n,pretty:r,pinoOptions:s}={...fe,...t},l={name:e||fe.name,level:n||fe.level,...s};if(ft()&&(l.browser={asObject:!1,write:void 0,...(s==null?void 0:s.browser)||{}}),r&&ht()&&!ce())try{return ae(l,ae.transport({target:"pino-pretty",options:{colorize:!0,translateTime:"HH:MM:ss.l",ignore:"pid,hostname",singleLine:!1}}))}catch{return console.warn("[wsx-logger] pino-pretty not available, using default formatter"),ae(l)}return ae(l)}class Ve{constructor(e={}){this.isProd=ce(),this.pinoLogger=dt(e)}debug(e,...n){this.isProd||(n.length>0?this.pinoLogger.debug({args:n},e):this.pinoLogger.debug(e))}info(e,...n){this.isProd?n.length>0?this.pinoLogger.info({args:n},e):this.pinoLogger.info(e):n.length>0?this.pinoLogger.info({args:n},e):this.pinoLogger.info(e)}warn(e,...n){n.length>0?this.pinoLogger.warn({args:n},e):this.pinoLogger.warn(e)}error(e,...n){n.length>0?this.pinoLogger.error({args:n},e):this.pinoLogger.error(e)}fatal(e,...n){n.length>0?this.pinoLogger.fatal({args:n},e):this.pinoLogger.fatal(e)}trace(e,...n){this.isProd||(n.length>0?this.pinoLogger.trace({args:n},e):this.pinoLogger.trace(e))}getPinoLogger(){return this.pinoLogger}}new Ve;function ue(t,e={}){return new Ve({...e,name:e.name||`WSX:${t}`})}const mt=ue("RouterUtils"),ne=class ne{static _setCurrentRoute(e){ne._currentRoute=e}static navigate(e,n=!1){n?window.history.replaceState(null,"",e):window.history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate")),mt.debug(`Navigated to: ${e} (replace: ${n})`)}static getCurrentRoute(){if(ne._currentRoute)return ne._currentRoute;const e=new URL(window.location.href);return{path:e.pathname,params:{},query:Object.fromEntries(e.searchParams.entries()),hash:e.hash.slice(1)}}static parseRoute(e,n){var r;if(e===n)return{route:e,params:{},exact:!0};if(e==="*")return{route:e,params:{},exact:!1};if(e.includes(":")){const s=((r=e.match(/:([^/]+)/g))==null?void 0:r.map(u=>u.slice(1)))||[],l=e.replace(/:[^/]+/g,"([^/]+)"),m=new RegExp(`^${l}$`),p=n.match(m);if(p&&s.length>0){const u={};return s.forEach((i,g)=>{u[i]=p[g+1]}),{route:e,params:u,exact:!0}}}if(e.endsWith("/*")){const s=e.slice(0,-2);if(n.startsWith(s))return{route:e,params:{},exact:!1}}return null}static buildPath(e,n={}){let r=e;return Object.entries(n).forEach(([s,l])=>{r=r.replace(`:${s}`,encodeURIComponent(l))}),r}static isRouteActive(e,n=!1){const r=window.location.pathname;return n?r===e:e==="/"?r==="/":r.startsWith(e)}static getRouteDepth(e){return e.split("/").filter(n=>n.length>0).length}static getParentRoute(e){const n=e.split("/").filter(r=>r.length>0);return n.length<=1?"/":(n.pop(),"/"+n.join("/"))}static joinPaths(...e){return e.map(n=>n.replace(/^\/+|\/+$/g,"")).filter(n=>n.length>0).join("/").replace(/^/,"/")}static isExternalUrl(e){return/^https?:\/\//.test(e)||/^mailto:/.test(e)||/^tel:/.test(e)}static getQueryParam(e){return new URL(window.location.href).searchParams.get(e)}static setQueryParam(e,n,r=!1){const s=new URL(window.location.href);s.searchParams.set(e,n);const l=s.pathname+s.search+s.hash;this.navigate(l,r)}static removeQueryParam(e,n=!1){const r=new URL(window.location.href);r.searchParams.delete(e);const s=r.pathname+r.search+r.hash;this.navigate(s,n)}static goBack(){window.history.back()}static goForward(){window.history.forward()}static replace(e){this.navigate(e,!0)}static getHistoryLength(){return window.history.length}static onRouteChange(e){const n=()=>{const r=this.getCurrentRoute();e(r)};return document.addEventListener("route-changed",n),()=>{document.removeEventListener("route-changed",n)}}};ne._currentRoute=null;let se=ne;const Le=":host{display:grid;width:100%}.router-outlet{width:100%}:host>wsx-view{grid-area:1 / 1}";var Ie;let Pe,De;function H(t,e,n){return(e=Me(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pt(t,e,n,r,s,l){function m(o,c,f){return function(h,d){return f&&f(h),o[c].call(h,d)}}function p(o,c){for(var f=0;f<o.length;f++)o[f].call(c);return c}function u(o,c,f,h){if(typeof o!="function"&&(h||o!==void 0))throw new TypeError(c+" must "+(f||"be")+" a function"+(h?"":" or undefined"));return o}function i(o,c,f,h,d,T,V,A,I,C,j,E,R){function $(b){if(!R(b))throw new TypeError("Attempted to access private element on non-instance")}var y,_=c[0],S=c[3],P=!A;if(!P){f||Array.isArray(_)||(_=[_]);var a={},O=[],L=d===3?"get":d===4||E?"set":"value";C?(j||E?a={get:je(function(){return S(this)},h,"get"),set:function(b){c[4](this,b)}}:a[L]=S,j||je(a[L],h,d===2?"":L)):j||(a=Object.getOwnPropertyDescriptor(o,h))}for(var w=o,F=_.length-1;F>=0;F-=f?2:1){var G=_[F],Q=f?_[F-1]:void 0,X={},D={kind:["field","accessor","method","getter","setter","class"][d],name:h,metadata:T,addInitializer:(function(b,W){if(b.v)throw Error("attempted to call addInitializer after decoration was finished");u(W,"An initializer","be",!0),V.push(W)}).bind(null,X)};try{if(P)(y=u(G.call(Q,w,D),"class decorators","return"))&&(w=y);else{var M,q;D.static=I,D.private=C,C?d===2?M=function(b){return $(b),a.value}:(d<4&&(M=m(a,"get",$)),d!==3&&(q=m(a,"set",$))):(M=function(b){return b[h]},(d<2||d===4)&&(q=function(b,W){b[h]=W}));var Y=D.access={has:C?R.bind():function(b){return h in b}};if(M&&(Y.get=M),q&&(Y.set=q),w=G.call(Q,E?{get:a.get,set:a.set}:a[L],D),E){if(typeof w=="object"&&w)(y=u(w.get,"accessor.get"))&&(a.get=y),(y=u(w.set,"accessor.set"))&&(a.set=y),(y=u(w.init,"accessor.init"))&&O.push(y);else if(w!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else u(w,(j?"field":"method")+" decorators","return")&&(j?O.push(w):a[L]=w)}}finally{X.v=!0}}return(j||E)&&A.push(function(b,W){for(var B=O.length-1;B>=0;B--)W=O[B].call(b,W);return W}),j||P||(C?E?A.push(m(a,"get"),m(a,"set")):A.push(d===2?a[L]:m.call.bind(a[L])):Object.defineProperty(o,h,a)),w}function g(o,c){return Object.defineProperty(o,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var v=l[Symbol.metadata||Symbol.for("Symbol.metadata")];var z=Object.create(v??null),x=function(o,c,f,h){var d,T,V=[],A=function(L){return vt(L)===o},I=new Map;function C(L){L&&V.push(p.bind(null,L))}for(var j=0;j<c.length;j++){var E=c[j];if(Array.isArray(E)){var R=E[1],$=E[2],y=E.length>3,_=16&R,S=!!(8&R),P=(R&=7)==0,a=$+"/"+S;if(!P&&!y){var O=I.get(a);if(O===!0||O===3&&R!==4||O===4&&R!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+$);I.set(a,!(R>2)||R)}i(S?o:o.prototype,E,_,y?"#"+$:Me($),R,h,S?T=T||[]:d=d||[],V,S,y,P,R===1,S&&y?A:f)}}return C(d),C(T),V}(t,e,s,z);return n.length||g(t,z),{e:x,get c(){var o=[];return n.length&&[g(i(t,[n],r,t.name,5,z,o),z),p.bind(null,o,t)]}}}function Me(t){var e=gt(t,"string");return typeof e=="symbol"?e:e+""}function gt(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function je(t,e,n){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:n?n+" "+e:e})}catch{}return t}function vt(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}const k=ue("WsxRouter");De=[U.autoRegister({tagName:"wsx-router"})];exports.WsxRouter=void 0;class bt extends U.LightComponent{constructor(){super({styles:Le,styleName:"wsx-router"}),H(this,"_autoStyles",Le),H(this,"views",new Map),H(this,"currentView",null),H(this,"currentPath",""),H(this,"isHandlingRoute",!1),H(this,"compiledRoutes",new Map),H(this,"matchCache",new Map),H(this,"enableViewTransitions",!0),H(this,"scrollRestoration","manual"),H(this,"handleRouteChange",()=>{if(this.isHandlingRoute){k.debug("Route change already in progress, skipping");return}this.views.size===0&&(this.collectViews(),k.debug(`WsxRouter re-collected views: ${this.views.size}`)),this.isHandlingRoute=!0;try{const e=window.location.pathname;k.debug(`WsxRouter: Route changed to: ${e}`);const n=new CustomEvent("before-navigate",{detail:{to:e,from:this.currentPath},bubbles:!0,cancelable:!0});if(!this.dispatchEvent(n)){k.debug(`Navigation to ${e} was cancelled`);return}this.performNavigation(e)}finally{requestAnimationFrame(()=>{this.isHandlingRoute=!1})}}),H(this,"interceptLinks",e=>{const n=e.target.closest("a");if(!n)return;const r=n.getAttribute("href");!r||r.startsWith("http")||r.startsWith("#")||(e.preventDefault(),this.navigate(r))})}render(){return U.jsx("div",{class:"router-outlet"})}onRendered(){this.views.size===0&&(this.collectViews(),k.debug("WsxRouter collected views in onRendered:",this.views.size)),this.views.size>0&&!this.currentView&&requestAnimationFrame(()=>{this.handleRouteChange()})}onConnected(){k.debug("WsxRouter connected to DOM"),"scrollRestoration"in history&&(history.scrollRestoration=this.scrollRestoration),window.addEventListener("popstate",this.handleRouteChange),this.addEventListener("click",this.interceptLinks),requestAnimationFrame(()=>{this.views.size===0&&(this.collectViews(),k.debug(`WsxRouter collected views in onConnected: ${this.views.size}`)),requestAnimationFrame(()=>{k.debug(`WsxRouter handling initial route: ${window.location.pathname}`),this.handleRouteChange()})})}onDisconnected(){window.removeEventListener("popstate",this.handleRouteChange)}collectViews(){const e=Array.from(this.children).filter(n=>n.tagName.toLowerCase()==="wsx-view");k.debug(`WsxRouter found ${e.length} views`),this.views.clear(),this.compiledRoutes.clear(),this.matchCache.clear(),e.forEach(n=>{const r=n.getAttribute("route")||"/";if(this.views.set(r,n),k.debug(`WsxRouter registered route: ${r}`),r.includes(":")){const s=r.replace(/:[^/]+/g,"([^/]+)"),l=new RegExp(`^${s}$`);this.compiledRoutes.set(r,l),k.debug(`WsxRouter compiled regex for route: ${r} -> ${l}`)}n.style.display="none"})}performNavigation(e){const n=()=>{const r=this.matchRoute(e);if(r){r.style.display="block",r.style.visibility="visible";const s=r.getAttribute("route")||"/";k.debug(`Showing view for route: ${s}`);for(const[g,v]of this.views)v!==r&&(v.style.display="none",v.style.visibility="");this.currentView=r;const l=this.extractParams(s,e);k.debug(`Extracted params for route ${s} and path ${e}:`,l),l&&requestAnimationFrame(()=>{r.setAttribute("params",JSON.stringify(l)),k.debug(`Set params attribute on view: ${JSON.stringify(l)}`)});const m=window.location.href||`${window.location.pathname}${window.location.search}${window.location.hash}`,p=new URL(m,window.location.origin||"http://localhost"),u={path:e,params:l||{},query:Object.fromEntries(p.searchParams.entries()),hash:p.hash.slice(1)};se._setCurrentRoute(u),k.debug("Updated RouterUtils._currentRoute:",u);const i=new CustomEvent("route-changed",{detail:u,bubbles:!0});document.dispatchEvent(i)}else{for(const[u,i]of this.views)i.style.display="none";this.currentView=null,k.warn(`No view found for path: ${e}`);const s=window.location.href||`${window.location.pathname}${window.location.search}${window.location.hash}`,l=new URL(s,window.location.origin||"http://localhost"),m={path:e,params:{},query:Object.fromEntries(l.searchParams.entries()),hash:l.hash.slice(1)};se._setCurrentRoute(m);const p=new CustomEvent("route-changed",{detail:m,bubbles:!0});document.dispatchEvent(p)}this.handleScrollRestoration(e),this.dispatchEvent(new CustomEvent("after-navigate",{detail:{to:e,from:this.currentPath},bubbles:!0})),this.currentPath=e};this.enableViewTransitions&&"startViewTransition"in document?document.startViewTransition(n):n()}handleScrollRestoration(e){this.scrollRestoration==="manual"&&(this.isBackNavigation()||(window.scrollTo(0,0),k.debug("Scrolled to top for forward navigation")))}isBackNavigation(){var e;return"navigation"in performance&&performance.navigation?performance.navigation.type===2:((e=window.history.state)==null?void 0:e.navigationType)==="back"}matchRoute(e){if(k.warn(`matchRoute called for path: ${e}, views count: ${this.views.size}`),this.matchCache.has(e)){const r=this.matchCache.get(e);return k.warn(`matchRoute: found in cache, route: ${r}`),this.views.get(r)||null}if(this.views.has(e))return this.matchCache.set(e,e),k.warn(`matchRoute: exact match found for ${e}`),this.views.get(e);k.warn(`matchRoute: checking parameter routes, compiledRoutes count: ${this.compiledRoutes.size}`);for(const[r,s]of this.views)if(r.includes(":")){const l=this.compiledRoutes.get(r);if(l){const m=l.test(e);if(k.warn(`matchRoute: testing route ${r} against ${e}, matches: ${m}`),m)return this.matchCache.set(e,r),k.warn(`matchRoute: parameter match found, route: ${r}, path: ${e}`),s}else k.warn(`matchRoute: route ${r} has ':' but no compiled regex found`)}const n=this.views.get("*")||null;return n?(this.matchCache.set(e,"*"),k.warn(`matchRoute: wildcard match found for ${e}`)):k.warn(`matchRoute: no match found for ${e}, no wildcard view available`),n}extractParams(e,n){var u;if(!e.includes(":"))return null;const r=((u=e.match(/:([^/]+)/g))==null?void 0:u.map(i=>i.slice(1)))||[],s=e.replace(/:[^/]+/g,"([^/]+)"),l=new RegExp(`^${s}$`),m=n.match(l);if(!m||!r.length)return null;const p={};return r.forEach((i,g)=>{p[i]=m[g+1]}),p}clearMatchCache(){this.matchCache.clear(),k.debug("WsxRouter cleared match cache")}setViewTransitions(e){this.enableViewTransitions=e,k.debug(`View Transitions ${e?"enabled":"disabled"}`)}setScrollRestoration(e){this.scrollRestoration=e,"scrollRestoration"in history&&(history.scrollRestoration=e),k.debug(`Scroll Restoration set to ${e}`)}navigate(e){window.history.pushState(null,"",e),this.handleRouteChange()}}Ie=bt;[exports.WsxRouter,Pe]=pt(Ie,[],De,0,void 0,U.LightComponent).c;Pe();const Ce=":host{display:block;width:100%;height:100%}.route-view{width:100%;height:100%;position:relative}:host([loading]) .route-view{opacity:.5;transition:opacity .3s ease}:host([error]) .route-view{border:1px solid var(--error-color, #ff0000);padding:1rem}.route-view.entering{animation:fadeIn .3s ease-out}.route-view.leaving{animation:fadeOut .3s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeOut{0%{opacity:1}to{opacity:0}}";var de,me;let ke,Ne,$e;function te(t,e,n){return(e=Fe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yt(t,e,n,r,s,l){function m(o,c,f){return function(h,d){return f&&f(h),o[c].call(h,d)}}function p(o,c){for(var f=0;f<o.length;f++)o[f].call(c);return c}function u(o,c,f,h){if(typeof o!="function"&&(h||o!==void 0))throw new TypeError(c+" must "+(f||"be")+" a function"+(h?"":" or undefined"));return o}function i(o,c,f,h,d,T,V,A,I,C,j,E,R){function $(b){if(!R(b))throw new TypeError("Attempted to access private element on non-instance")}var y,_=c[0],S=c[3],P=!A;if(!P){f||Array.isArray(_)||(_=[_]);var a={},O=[],L=d===3?"get":d===4||E?"set":"value";C?(j||E?a={get:_e(function(){return S(this)},h,"get"),set:function(b){c[4](this,b)}}:a[L]=S,j||_e(a[L],h,d===2?"":L)):j||(a=Object.getOwnPropertyDescriptor(o,h))}for(var w=o,F=_.length-1;F>=0;F-=f?2:1){var G=_[F],Q=f?_[F-1]:void 0,X={},D={kind:["field","accessor","method","getter","setter","class"][d],name:h,metadata:T,addInitializer:(function(b,W){if(b.v)throw Error("attempted to call addInitializer after decoration was finished");u(W,"An initializer","be",!0),V.push(W)}).bind(null,X)};try{if(P)(y=u(G.call(Q,w,D),"class decorators","return"))&&(w=y);else{var M,q;D.static=I,D.private=C,C?d===2?M=function(b){return $(b),a.value}:(d<4&&(M=m(a,"get",$)),d!==3&&(q=m(a,"set",$))):(M=function(b){return b[h]},(d<2||d===4)&&(q=function(b,W){b[h]=W}));var Y=D.access={has:C?R.bind():function(b){return h in b}};if(M&&(Y.get=M),q&&(Y.set=q),w=G.call(Q,E?{get:a.get,set:a.set}:a[L],D),E){if(typeof w=="object"&&w)(y=u(w.get,"accessor.get"))&&(a.get=y),(y=u(w.set,"accessor.set"))&&(a.set=y),(y=u(w.init,"accessor.init"))&&O.push(y);else if(w!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else u(w,(j?"field":"method")+" decorators","return")&&(j?O.push(w):a[L]=w)}}finally{X.v=!0}}return(j||E)&&A.push(function(b,W){for(var B=O.length-1;B>=0;B--)W=O[B].call(b,W);return W}),j||P||(C?E?A.push(m(a,"get"),m(a,"set")):A.push(d===2?a[L]:m.call.bind(a[L])):Object.defineProperty(o,h,a)),w}function g(o,c){return Object.defineProperty(o,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var v=l[Symbol.metadata||Symbol.for("Symbol.metadata")];var z=Object.create(v??null),x=function(o,c,f,h){var d,T,V=[],A=function(L){return xt(L)===o},I=new Map;function C(L){L&&V.push(p.bind(null,L))}for(var j=0;j<c.length;j++){var E=c[j];if(Array.isArray(E)){var R=E[1],$=E[2],y=E.length>3,_=16&R,S=!!(8&R),P=(R&=7)==0,a=$+"/"+S;if(!P&&!y){var O=I.get(a);if(O===!0||O===3&&R!==4||O===4&&R!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+$);I.set(a,!(R>2)||R)}i(S?o:o.prototype,E,_,y?"#"+$:Fe($),R,h,S?T=T||[]:d=d||[],V,S,y,P,R===1,S&&y?A:f)}}return C(d),C(T),V}(t,e,s,z);return n.length||g(t,z),{e:x,get c(){var o=[];return n.length&&[g(i(t,[n],r,t.name,5,z,o),z),p.bind(null,o,t)]}}}function Fe(t){var e=wt(t,"string");return typeof e=="symbol"?e:e+""}function wt(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function _e(t,e,n){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:n?n+" "+e:e})}catch{}return t}function xt(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}function Et(t){return t}const N=ue("WsxView");Ne=[U.autoRegister({tagName:"wsx-view"})];exports.WsxView=void 0;new($e=(me=class extends U.LightComponent{constructor(){super({styles:Ce,styleName:"wsx-view"}),te(this,"_autoStyles",Ce),te(this,"component",null),te(this,"params",{}),te(this,"componentInstance",null),te(this,"isLoading",!1)}render(){return U.jsx("div",{class:"route-view"})}onConnected(){requestAnimationFrame(()=>{if(!this.connected||this.isLoading||this.componentInstance)return;const e=this.getAttribute("component");e&&this.loadComponent(e)})}onAttributeChanged(e,n,r){if(this.connected){if(e==="component"&&r&&!this.componentInstance&&!this.isLoading)requestAnimationFrame(()=>{this.connected&&!this.componentInstance&&!this.isLoading&&this.loadComponent(r)});else if(e==="params"&&this.componentInstance)try{this.params=JSON.parse(r),N.debug("WsxView: params attribute changed, setting on component:",this.params),Object.entries(this.params).forEach(([s,l])=>{this.componentInstance.setAttribute(s,l)}),N.debug(`WsxView: params set on component ${this.componentInstance.tagName}`)}catch(s){N.warn("Failed to parse params:",s)}}}async loadComponent(e){if(!this.connected||this.isLoading||this.componentInstance){N.debug(`Skipping loadComponent for ${e}: connected=${this.connected}, isLoading=${this.isLoading}, hasInstance=${!!this.componentInstance}`);return}N.debug(`WsxView: Loading component ${e}`),this.isLoading=!0;try{const n=this.componentInstance;if(n&&(n.remove(),this.componentInstance=null),!customElements.get(e)){N.warn(`Component ${e} not found in customElements registry`),this.isLoading=!1;return}N.warn(`WsxView: Creating instance of ${e}`),this.componentInstance=document.createElement(e),Object.keys(this.params).length>0&&(N.warn(`WsxView: Setting initial params on ${e}:`,this.params),Object.entries(this.params).forEach(([l,m])=>{this.componentInstance.setAttribute(l,m)}));const s=this.querySelector(".route-view");if(s){if(N.warn(`WsxView: Appending ${e} to container`),!customElements.get(e)){N.error(`WsxView: Component ${e} is not registered in customElements registry!`),this.isLoading=!1,this.componentInstance=null;return}s.appendChild(this.componentInstance),N.warn(`WsxView: Component ${e} appended successfully, waiting for connectedCallback...`),setTimeout(()=>{this.componentInstance&&this.componentInstance.isConnected?N.warn(`WsxView: Component ${e} is now connected to DOM`):N.error(`WsxView: Component ${e} was not connected to DOM!`)},0)}else N.error("WsxView: Route view container not found"),this.componentInstance=null}catch(n){N.warn(`Error loading component ${e}:`,n),this.componentInstance=null}finally{this.isLoading=!1,N.warn(`WsxView: loadComponent for ${e} completed, isLoading=${this.isLoading}`)}}onDisconnected(){this.componentInstance&&(this.componentInstance.remove(),this.componentInstance=null)}},[exports.WsxView,ke]=yt(me,[],Ne,0,void 0,U.LightComponent).c,me),de=class extends Et{constructor(){super(exports.WsxView),te(this,"observedAttributes",["route","component","params"]),ke()}},te(de,$e,void 0),de);const Rt=':host{display:inline-block;min-width:fit-content;min-height:fit-content;width:auto;height:auto}.wsx-link{color:var(--link-color, #007bff);text-decoration:var(--link-decoration, underline);cursor:pointer;transition:color .2s ease;display:inline-block;min-height:1.2em;line-height:1.2}.wsx-link:hover{color:var(--link-hover-color, #0056b3);text-decoration:var(--link-hover-decoration, underline)}.wsx-link:focus{outline:2px solid var(--link-focus-color, var(--focus-color, #dc2626));outline-offset:2px}.wsx-link.active{color:var(--link-active-color, #6c757d);font-weight:var(--link-active-weight, bold)}:host([disabled]) .wsx-link{color:var(--link-disabled-color, #6c757d);cursor:not-allowed;pointer-events:none}:host([external]) .wsx-link:after{content:"↗";font-size:.8em;margin-left:.2em;opacity:.7}:host([variant="button"]) .wsx-link{background-color:var(--button-bg, #007bff);color:var(--button-color, white);padding:.5rem 1rem;border-radius:.25rem;text-decoration:none;display:inline-block}:host([variant="button"]) .wsx-link:hover{background-color:var(--button-hover-bg, #0056b3);color:var(--button-hover-color, white)}:host([variant="tab"]) .wsx-link{padding:.5rem 1rem;border-bottom:2px solid transparent;text-decoration:none}:host([variant="tab"]) .wsx-link.active{border-bottom-color:var(--tab-active-border, #007bff)}';var pe,ge;let Se,qe,Oe;function K(t,e,n){return(e=Ue(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Lt(t,e,n,r,s,l){function m(o,c,f){return function(h,d){return f&&f(h),o[c].call(h,d)}}function p(o,c){for(var f=0;f<o.length;f++)o[f].call(c);return c}function u(o,c,f,h){if(typeof o!="function"&&(h||o!==void 0))throw new TypeError(c+" must "+(f||"be")+" a function"+(h?"":" or undefined"));return o}function i(o,c,f,h,d,T,V,A,I,C,j,E,R){function $(b){if(!R(b))throw new TypeError("Attempted to access private element on non-instance")}var y,_=c[0],S=c[3],P=!A;if(!P){f||Array.isArray(_)||(_=[_]);var a={},O=[],L=d===3?"get":d===4||E?"set":"value";C?(j||E?a={get:We(function(){return S(this)},h,"get"),set:function(b){c[4](this,b)}}:a[L]=S,j||We(a[L],h,d===2?"":L)):j||(a=Object.getOwnPropertyDescriptor(o,h))}for(var w=o,F=_.length-1;F>=0;F-=f?2:1){var G=_[F],Q=f?_[F-1]:void 0,X={},D={kind:["field","accessor","method","getter","setter","class"][d],name:h,metadata:T,addInitializer:(function(b,W){if(b.v)throw Error("attempted to call addInitializer after decoration was finished");u(W,"An initializer","be",!0),V.push(W)}).bind(null,X)};try{if(P)(y=u(G.call(Q,w,D),"class decorators","return"))&&(w=y);else{var M,q;D.static=I,D.private=C,C?d===2?M=function(b){return $(b),a.value}:(d<4&&(M=m(a,"get",$)),d!==3&&(q=m(a,"set",$))):(M=function(b){return b[h]},(d<2||d===4)&&(q=function(b,W){b[h]=W}));var Y=D.access={has:C?R.bind():function(b){return h in b}};if(M&&(Y.get=M),q&&(Y.set=q),w=G.call(Q,E?{get:a.get,set:a.set}:a[L],D),E){if(typeof w=="object"&&w)(y=u(w.get,"accessor.get"))&&(a.get=y),(y=u(w.set,"accessor.set"))&&(a.set=y),(y=u(w.init,"accessor.init"))&&O.push(y);else if(w!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else u(w,(j?"field":"method")+" decorators","return")&&(j?O.push(w):a[L]=w)}}finally{X.v=!0}}return(j||E)&&A.push(function(b,W){for(var B=O.length-1;B>=0;B--)W=O[B].call(b,W);return W}),j||P||(C?E?A.push(m(a,"get"),m(a,"set")):A.push(d===2?a[L]:m.call.bind(a[L])):Object.defineProperty(o,h,a)),w}function g(o,c){return Object.defineProperty(o,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var v=l[Symbol.metadata||Symbol.for("Symbol.metadata")];var z=Object.create(v??null),x=function(o,c,f,h){var d,T,V=[],A=function(L){return Ct(L)===o},I=new Map;function C(L){L&&V.push(p.bind(null,L))}for(var j=0;j<c.length;j++){var E=c[j];if(Array.isArray(E)){var R=E[1],$=E[2],y=E.length>3,_=16&R,S=!!(8&R),P=(R&=7)==0,a=$+"/"+S;if(!P&&!y){var O=I.get(a);if(O===!0||O===3&&R!==4||O===4&&R!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+$);I.set(a,!(R>2)||R)}i(S?o:o.prototype,E,_,y?"#"+$:Ue($),R,h,S?T=T||[]:d=d||[],V,S,y,P,R===1,S&&y?A:f)}}return C(d),C(T),V}(t,e,s,z);return n.length||g(t,z),{e:x,get c(){var o=[];return n.length&&[g(i(t,[n],r,t.name,5,z,o),z),p.bind(null,o,t)]}}}function Ue(t){var e=jt(t,"string");return typeof e=="symbol"?e:e+""}function jt(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function We(t,e,n){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:n?n+" "+e:e})}catch{}return t}function Ct(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}function kt(t){return t}const ze=ue("WsxLink");qe=[U.autoRegister({tagName:"wsx-link"})];exports.WsxLink=void 0;new(Oe=(ge=class extends U.WebComponent{constructor(){super(),K(this,"_autoStyles",Rt),K(this,"to",void 0),K(this,"replace",void 0),K(this,"activeClass",void 0),K(this,"exact",void 0),K(this,"handleClick",i=>{if(i.preventDefault(),!this.to){ze.warn("No 'to' attribute specified");return}if(this.isExternalLink(this.to)){window.open(this.to,"_blank");return}this.replace?window.history.replaceState(null,"",this.to):window.history.pushState(null,"",this.to),window.dispatchEvent(new PopStateEvent("popstate")),ze.debug(`Navigated to: ${this.to}`)}),K(this,"updateActiveState",()=>{var z;const i=window.location.pathname,g=this.exact?i===this.to:i.startsWith(this.to)&&this.to!=="/",v=(z=this.shadowRoot)==null?void 0:z.querySelector("a");v&&(g?(v.classList.add(this.activeClass),this.setAttribute("active","")):(v.classList.remove(this.activeClass),this.removeAttribute("active")))});const[e,n]=this.useState("to","");Object.defineProperty(this,"to",{get:e,set:n,enumerable:!0,configurable:!0});const[r,s]=this.useState("replace",!1);Object.defineProperty(this,"replace",{get:r,set:s,enumerable:!0,configurable:!0});const[l,m]=this.useState("activeClass","active");Object.defineProperty(this,"activeClass",{get:l,set:m,enumerable:!0,configurable:!0});const[p,u]=this.useState("exact",!1);Object.defineProperty(this,"exact",{get:p,set:u,enumerable:!0,configurable:!0})}render(){return U.jsx("a",{href:this.to,class:"wsx-link",onClick:this.handleClick,part:"link"},U.jsx("slot",null))}onConnected(){this.to=this.getAttribute("to")||"",this.replace=this.hasAttribute("replace"),this.activeClass=this.getAttribute("active-class")||"active",this.exact=this.hasAttribute("exact");const e=this.shadowRoot.querySelector(".wsx-link");e&&(e.href=this.to),window.addEventListener("popstate",this.updateActiveState),document.addEventListener("route-changed",this.updateActiveState),this.updateActiveState()}onDisconnected(){window.removeEventListener("popstate",this.updateActiveState),document.removeEventListener("route-changed",this.updateActiveState)}onAttributeChanged(e,n,r){switch(e){case"to":this.to=r||"",this.updateActiveState();break;case"replace":this.replace=r!==null&&r!=="false";break;case"active-class":this.activeClass=r||"active",this.updateActiveState();break;case"exact":this.exact=r!==null&&r!=="false",this.updateActiveState();break}}isExternalLink(e){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("mailto:")||e.startsWith("tel:")}navigate(){this.to&&this.handleClick(new MouseEvent("click",{bubbles:!0,cancelable:!0}))}},[exports.WsxLink,Se]=Lt(ge,[],qe,0,void 0,U.WebComponent).c,ge),pe=class extends kt{constructor(){super(exports.WsxLink),K(this,"observedAttributes",["to","replace","active-class","exact"]),Se()}},K(pe,Oe,void 0),pe);exports.RouterUtils=se;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("@wsxjs/wsx-core");var _e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Se(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var ge={exports:{}};(function(n){(function(e,t){n.exports?n.exports=t():e.log=t()})(_e,function(){var e=function(){},t="undefined",r=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),g=["trace","debug","info","warn","error"],v={},f=null;function _(o,c){var i=o[c];if(typeof i.bind=="function")return i.bind(o);try{return Function.prototype.bind.call(i,o)}catch{return function(){return Function.prototype.apply.apply(i,[o,arguments])}}}function y(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function T(o){return o==="debug"&&(o="log"),typeof console===t?!1:o==="trace"&&r?y:console[o]!==void 0?_(console,o):console.log!==void 0?_(console,"log"):e}function j(){for(var o=this.getLevel(),c=0;c<g.length;c++){var i=g[c];this[i]=c<o?e:this.methodFactory(i,o,this.name)}if(this.log=this.debug,typeof console===t&&o<this.levels.SILENT)return"No console available for logging"}function V(o){return function(){typeof console!==t&&(j.call(this),this[o].apply(this,arguments))}}function P(o,c,i){return T(o)||V.apply(this,arguments)}function B(o,c){var i=this,u,A,k,R="loglevel";typeof o=="string"?R+=":"+o:typeof o=="symbol"&&(R=void 0);function D(h){var l=(g[h]||"silent").toUpperCase();if(!(typeof window===t||!R)){try{window.localStorage[R]=l;return}catch{}try{window.document.cookie=encodeURIComponent(R)+"="+l+";"}catch{}}}function E(){var h;if(!(typeof window===t||!R)){try{h=window.localStorage[R]}catch{}if(typeof h===t)try{var l=window.document.cookie,x=encodeURIComponent(R),C=l.indexOf(x+"=");C!==-1&&(h=/^([^;]+)/.exec(l.slice(C+x.length+1))[1])}catch{}return i.levels[h]===void 0&&(h=void 0),h}}function L(){if(!(typeof window===t||!R)){try{window.localStorage.removeItem(R)}catch{}try{window.document.cookie=encodeURIComponent(R)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function p(h){var l=h;if(typeof l=="string"&&i.levels[l.toUpperCase()]!==void 0&&(l=i.levels[l.toUpperCase()]),typeof l=="number"&&l>=0&&l<=i.levels.SILENT)return l;throw new TypeError("log.setLevel() called with invalid level: "+h)}i.name=o,i.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},i.methodFactory=c||P,i.getLevel=function(){return k??A??u},i.setLevel=function(h,l){return k=p(h),l!==!1&&D(k),j.call(i)},i.setDefaultLevel=function(h){A=p(h),E()||i.setLevel(h,!1)},i.resetLevel=function(){k=null,L(),j.call(i)},i.enableAll=function(h){i.setLevel(i.levels.TRACE,h)},i.disableAll=function(h){i.setLevel(i.levels.SILENT,h)},i.rebuild=function(){if(f!==i&&(u=p(f.getLevel())),j.call(i),f===i)for(var h in v)v[h].rebuild()},u=p(f?f.getLevel():"WARN");var m=E();m!=null&&(k=p(m)),j.call(i)}f=new B,f.getLogger=function(c){if(typeof c!="symbol"&&typeof c!="string"||c==="")throw new TypeError("You must supply a name when creating a logger.");var i=v[c];return i||(i=v[c]=new B(c,f.methodFactory)),i};var s=typeof window!==t?window.log:void 0;return f.noConflict=function(){return typeof window!==t&&window.log===f&&(window.log=s),f},f.getLoggers=function(){return v},f.default=f,f})})(ge);var Ie=ge.exports;const ke=Se(Ie),pe={trace:"trace",debug:"debug",info:"info",warn:"warn",error:"error",silent:"silent"},We={0:"trace",1:"debug",2:"info",3:"warn",4:"error",5:"silent"};function se(){var n,e;if(typeof process<"u")return process.env.NODE_ENV==="production"||process.env.MODE==="production";try{const t=globalThis;if((e=(n=t.import)==null?void 0:n.meta)!=null&&e.env){const r=t.import.meta.env;return r.MODE==="production"||r.PROD===!0}}catch{}return!1}const te={name:"WSX",level:se()?"info":"debug",pretty:!se()};function Ae(n={}){const{name:e,level:t}={...te,...n},r=e||te.name,g=ke.getLogger(r),v=t||te.level;return g.setLevel(pe[v]),g}function Y(n,e){return n?`[${n}] ${e}`:e}class ve{constructor(e={}){this.isProd=se(),this.name=e.name||te.name,this.currentLevel=e.level||te.level,this.logInstance=Ae(e)}debug(e,...t){if(!this.isProd||this.shouldLog("debug")){const r=Y(this.name,e);t.length>0?this.logInstance.debug(r,...t):this.logInstance.debug(r)}}info(e,...t){if(this.shouldLog("info")){const r=Y(this.name,e);t.length>0?this.logInstance.info(r,...t):this.logInstance.info(r)}}warn(e,...t){const r=Y(this.name,e);t.length>0?this.logInstance.warn(r,...t):this.logInstance.warn(r)}error(e,...t){const r=Y(this.name,e);t.length>0?this.logInstance.error(r,...t):this.logInstance.error(r)}fatal(e,...t){const r=Y(this.name,e);t.length>0?this.logInstance.error(`[FATAL] ${r}`,...t):this.logInstance.error(`[FATAL] ${r}`)}trace(e,...t){if(!this.isProd||this.shouldLog("trace")){const r=Y(this.name,e);t.length>0?this.logInstance.trace(r,...t):this.logInstance.trace(r)}}shouldLog(e){const t=["trace","debug","info","warn","error","silent"],r=t.indexOf(this.currentLevel);return t.indexOf(e)>=r}getLoglevelLogger(){return this.logInstance}setLevel(e){this.currentLevel=e,this.logInstance.setLevel(pe[e])}getLevel(){const e=this.logInstance.getLevel();return We[e]||this.currentLevel}}new ve;function re(n,e={}){return new ve({...e,name:e.name||`WSX:${n}`})}const Te=re("RouterUtils"),Z=class Z{static _setCurrentRoute(e){Z._currentRoute=e}static navigate(e,t=!1){t?window.history.replaceState(null,"",e):window.history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate")),Te.debug(`Navigated to: ${e} (replace: ${t})`)}static getCurrentRoute(){if(Z._currentRoute)return Z._currentRoute;const e=new URL(window.location.href);return{path:e.pathname,params:{},query:Object.fromEntries(e.searchParams.entries()),hash:e.hash.slice(1)}}static parseRoute(e,t){var r;if(e===t)return{route:e,params:{},exact:!0};if(e==="*")return{route:e,params:{},exact:!1};if(e.includes(":")){const g=((r=e.match(/:([^/]+)/g))==null?void 0:r.map(y=>y.slice(1)))||[],v=e.replace(/:[^/]+/g,"([^/]+)"),f=new RegExp(`^${v}$`),_=t.match(f);if(_&&g.length>0){const y={};return g.forEach((T,j)=>{y[T]=_[j+1]}),{route:e,params:y,exact:!0}}}if(e.endsWith("/*")){const g=e.slice(0,-2);if(t.startsWith(g))return{route:e,params:{},exact:!1}}return null}static buildPath(e,t={}){let r=e;return Object.entries(t).forEach(([g,v])=>{r=r.replace(`:${g}`,encodeURIComponent(v))}),r}static isRouteActive(e,t=!1){const r=window.location.pathname;return t?r===e:e==="/"?r==="/":r.startsWith(e)}static getRouteDepth(e){return e.split("/").filter(t=>t.length>0).length}static getParentRoute(e){const t=e.split("/").filter(r=>r.length>0);return t.length<=1?"/":(t.pop(),"/"+t.join("/"))}static joinPaths(...e){return e.map(t=>t.replace(/^\/+|\/+$/g,"")).filter(t=>t.length>0).join("/").replace(/^/,"/")}static isExternalUrl(e){return/^https?:\/\//.test(e)||/^mailto:/.test(e)||/^tel:/.test(e)}static getQueryParam(e){return new URL(window.location.href).searchParams.get(e)}static setQueryParam(e,t,r=!1){const g=new URL(window.location.href);g.searchParams.set(e,t);const v=g.pathname+g.search+g.hash;this.navigate(v,r)}static removeQueryParam(e,t=!1){const r=new URL(window.location.href);r.searchParams.delete(e);const g=r.pathname+r.search+r.hash;this.navigate(g,t)}static goBack(){window.history.back()}static goForward(){window.history.forward()}static replace(e){this.navigate(e,!0)}static getHistoryLength(){return window.history.length}static onRouteChange(e){const t=()=>{const r=this.getCurrentRoute();e(r)};return document.addEventListener("route-changed",t),()=>{document.removeEventListener("route-changed",t)}}};Z._currentRoute=null;let ne=Z;const ae=":host{display:grid;width:100%}.router-outlet{width:100%}:host>wsx-view{grid-area:1 / 1}";var me;let be,ye;function q(n,e,t){return(e=we(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function je(n,e,t,r,g,v){function f(s,o,c){return function(i,u){return c&&c(i),s[o].call(i,u)}}function _(s,o){for(var c=0;c<s.length;c++)s[c].call(o);return o}function y(s,o,c,i){if(typeof s!="function"&&(i||s!==void 0))throw new TypeError(o+" must "+(c||"be")+" a function"+(i?"":" or undefined"));return s}function T(s,o,c,i,u,A,k,R,D,E,L,p,m){function h(d){if(!m(d))throw new TypeError("Attempted to access private element on non-instance")}var l,x=o[0],C=o[3],W=!R;if(!W){c||Array.isArray(x)||(x=[x]);var a={},S=[],w=u===3?"get":u===4||p?"set":"value";E?(L||p?a={get:ce(function(){return C(this)},i,"get"),set:function(d){o[4](this,d)}}:a[w]=C,L||ce(a[w],i,u===2?"":w)):L||(a=Object.getOwnPropertyDescriptor(s,i))}for(var b=s,U=x.length-1;U>=0;U-=c?2:1){var G=x[U],K=c?x[U-1]:void 0,J={},O={kind:["field","accessor","method","getter","setter","class"][u],name:i,metadata:A,addInitializer:(function(d,I){if(d.v)throw Error("attempted to call addInitializer after decoration was finished");y(I,"An initializer","be",!0),k.push(I)}).bind(null,J)};try{if(W)(l=y(G.call(K,b,O),"class decorators","return"))&&(b=l);else{var M,z;O.static=D,O.private=E,E?u===2?M=function(d){return h(d),a.value}:(u<4&&(M=f(a,"get",h)),u!==3&&(z=f(a,"set",h))):(M=function(d){return d[i]},(u<2||u===4)&&(z=function(d,I){d[i]=I}));var Q=O.access={has:E?m.bind():function(d){return i in d}};if(M&&(Q.get=M),z&&(Q.set=z),b=G.call(K,p?{get:a.get,set:a.set}:a[w],O),p){if(typeof b=="object"&&b)(l=y(b.get,"accessor.get"))&&(a.get=l),(l=y(b.set,"accessor.set"))&&(a.set=l),(l=y(b.init,"accessor.init"))&&S.push(l);else if(b!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else y(b,(L?"field":"method")+" decorators","return")&&(L?S.push(b):a[w]=b)}}finally{J.v=!0}}return(L||p)&&R.push(function(d,I){for(var F=S.length-1;F>=0;F--)I=S[F].call(d,I);return I}),L||W||(E?p?R.push(f(a,"get"),f(a,"set")):R.push(u===2?a[w]:f.call.bind(a[w])):Object.defineProperty(s,i,a)),b}function j(s,o){return Object.defineProperty(s,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:o})}if(arguments.length>=6)var V=v[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(V??null),B=function(s,o,c,i){var u,A,k=[],R=function(w){return Me(w)===s},D=new Map;function E(w){w&&k.push(_.bind(null,w))}for(var L=0;L<o.length;L++){var p=o[L];if(Array.isArray(p)){var m=p[1],h=p[2],l=p.length>3,x=16&m,C=!!(8&m),W=(m&=7)==0,a=h+"/"+C;if(!W&&!l){var S=D.get(a);if(S===!0||S===3&&m!==4||S===4&&m!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+h);D.set(a,!(m>2)||m)}T(C?s:s.prototype,p,x,l?"#"+h:we(h),m,i,C?A=A||[]:u=u||[],k,C,l,W,m===1,C&&l?R:c)}}return E(u),E(A),k}(n,e,g,P);return t.length||j(n,P),{e:B,get c(){var s=[];return t.length&&[j(T(n,[t],r,n.name,5,P,s),P),_.bind(null,s,n)]}}}function we(n){var e=Oe(n,"string");return typeof e=="symbol"?e:e+""}function Oe(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function ce(n,e,t){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(n,"name",{configurable:!0,value:t?t+" "+e:e})}catch{}return n}function Me(n){if(Object(n)!==n)throw TypeError("right-hand side of 'in' should be an object, got "+(n!==null?typeof n:"null"));return n}const $=re("WsxRouter");ye=[N.autoRegister({tagName:"wsx-router"})];exports.WsxRouter=void 0;class Pe extends N.LightComponent{constructor(){super({styles:ae,styleName:"wsx-router"}),q(this,"_autoStyles",ae),q(this,"views",new Map),q(this,"currentView",null),q(this,"currentPath",""),q(this,"isHandlingRoute",!1),q(this,"compiledRoutes",new Map),q(this,"matchCache",new Map),q(this,"enableViewTransitions",!0),q(this,"scrollRestoration","manual"),q(this,"handleRouteChange",()=>{if(this.isHandlingRoute){$.debug("Route change already in progress, skipping");return}this.views.size===0&&(this.collectViews(),$.debug(`WsxRouter re-collected views: ${this.views.size}`)),this.isHandlingRoute=!0;try{const e=window.location.pathname;$.debug(`WsxRouter: Route changed to: ${e}`);const t=new CustomEvent("before-navigate",{detail:{to:e,from:this.currentPath},bubbles:!0,cancelable:!0});if(!this.dispatchEvent(t)){$.debug(`Navigation to ${e} was cancelled`);return}this.performNavigation(e)}finally{requestAnimationFrame(()=>{this.isHandlingRoute=!1})}}),q(this,"interceptLinks",e=>{const t=e.target.closest("a");if(!t)return;const r=t.getAttribute("href");!r||r.startsWith("http")||r.startsWith("#")||(e.preventDefault(),this.navigate(r))})}render(){return N.jsx("div",{class:"router-outlet"})}onRendered(){this.views.size===0&&(this.collectViews(),$.debug("WsxRouter collected views in onRendered:",this.views.size)),this.views.size>0&&!this.currentView&&requestAnimationFrame(()=>{this.handleRouteChange()})}onConnected(){$.debug("WsxRouter connected to DOM"),"scrollRestoration"in history&&(history.scrollRestoration=this.scrollRestoration),window.addEventListener("popstate",this.handleRouteChange),this.addEventListener("click",this.interceptLinks),requestAnimationFrame(()=>{this.views.size===0&&(this.collectViews(),$.debug(`WsxRouter collected views in onConnected: ${this.views.size}`)),requestAnimationFrame(()=>{$.debug(`WsxRouter handling initial route: ${window.location.pathname}`),this.handleRouteChange()})})}onDisconnected(){window.removeEventListener("popstate",this.handleRouteChange)}collectViews(){const e=Array.from(this.children).filter(t=>t.tagName.toLowerCase()==="wsx-view");$.debug(`WsxRouter found ${e.length} views`),this.views.clear(),this.compiledRoutes.clear(),this.matchCache.clear(),e.forEach(t=>{const r=t.getAttribute("route")||"/";if(this.views.set(r,t),$.debug(`WsxRouter registered route: ${r}`),r.includes(":")){const g=r.replace(/:[^/]+/g,"([^/]+)"),v=new RegExp(`^${g}$`);this.compiledRoutes.set(r,v),$.debug(`WsxRouter compiled regex for route: ${r} -> ${v}`)}t.style.display="none"})}performNavigation(e){const t=()=>{const r=this.matchRoute(e);if(r){r.style.display="block",r.style.visibility="visible";const g=r.getAttribute("route")||"/";$.debug(`Showing view for route: ${g}`);for(const[j,V]of this.views)V!==r&&(V.style.display="none",V.style.visibility="");this.currentView=r;const v=this.extractParams(g,e);$.debug(`Extracted params for route ${g} and path ${e}:`,v),v&&requestAnimationFrame(()=>{r.setAttribute("params",JSON.stringify(v)),$.debug(`Set params attribute on view: ${JSON.stringify(v)}`)});const f=window.location.href||`${window.location.pathname}${window.location.search}${window.location.hash}`,_=new URL(f,window.location.origin||"http://localhost"),y={path:e,params:v||{},query:Object.fromEntries(_.searchParams.entries()),hash:_.hash.slice(1)};ne._setCurrentRoute(y),$.debug("Updated RouterUtils._currentRoute:",y);const T=new CustomEvent("route-changed",{detail:y,bubbles:!0});document.dispatchEvent(T)}else{for(const[y,T]of this.views)T.style.display="none";this.currentView=null,$.warn(`No view found for path: ${e}`);const g=window.location.href||`${window.location.pathname}${window.location.search}${window.location.hash}`,v=new URL(g,window.location.origin||"http://localhost"),f={path:e,params:{},query:Object.fromEntries(v.searchParams.entries()),hash:v.hash.slice(1)};ne._setCurrentRoute(f);const _=new CustomEvent("route-changed",{detail:f,bubbles:!0});document.dispatchEvent(_)}this.handleScrollRestoration(e),this.dispatchEvent(new CustomEvent("after-navigate",{detail:{to:e,from:this.currentPath},bubbles:!0})),this.currentPath=e};this.enableViewTransitions&&"startViewTransition"in document?document.startViewTransition(t):t()}handleScrollRestoration(e){this.scrollRestoration==="manual"&&(this.isBackNavigation()||(window.scrollTo(0,0),$.debug("Scrolled to top for forward navigation")))}isBackNavigation(){var e;return"navigation"in performance&&performance.navigation?performance.navigation.type===2:((e=window.history.state)==null?void 0:e.navigationType)==="back"}matchRoute(e){if($.warn(`matchRoute called for path: ${e}, views count: ${this.views.size}`),this.matchCache.has(e)){const r=this.matchCache.get(e);return $.warn(`matchRoute: found in cache, route: ${r}`),this.views.get(r)||null}if(this.views.has(e))return this.matchCache.set(e,e),$.warn(`matchRoute: exact match found for ${e}`),this.views.get(e);$.warn(`matchRoute: checking parameter routes, compiledRoutes count: ${this.compiledRoutes.size}`);for(const[r,g]of this.views)if(r.includes(":")){const v=this.compiledRoutes.get(r);if(v){const f=v.test(e);if($.warn(`matchRoute: testing route ${r} against ${e}, matches: ${f}`),f)return this.matchCache.set(e,r),$.warn(`matchRoute: parameter match found, route: ${r}, path: ${e}`),g}else $.warn(`matchRoute: route ${r} has ':' but no compiled regex found`)}const t=this.views.get("*")||null;return t?(this.matchCache.set(e,"*"),$.warn(`matchRoute: wildcard match found for ${e}`)):$.warn(`matchRoute: no match found for ${e}, no wildcard view available`),t}extractParams(e,t){var y;if(!e.includes(":"))return null;const r=((y=e.match(/:([^/]+)/g))==null?void 0:y.map(T=>T.slice(1)))||[],g=e.replace(/:[^/]+/g,"([^/]+)"),v=new RegExp(`^${g}$`),f=t.match(v);if(!f||!r.length)return null;const _={};return r.forEach((T,j)=>{_[T]=f[j+1]}),_}clearMatchCache(){this.matchCache.clear(),$.debug("WsxRouter cleared match cache")}setViewTransitions(e){this.enableViewTransitions=e,$.debug(`View Transitions ${e?"enabled":"disabled"}`)}setScrollRestoration(e){this.scrollRestoration=e,"scrollRestoration"in history&&(history.scrollRestoration=e),$.debug(`Scroll Restoration set to ${e}`)}navigate(e){window.history.pushState(null,"",e),this.handleRouteChange()}}me=Pe;[exports.WsxRouter,be]=je(me,[],ye,0,void 0,N.LightComponent).c;be();const De=":host{display:block;width:100%;height:100%}.route-view{width:100%;height:100%;position:relative}:host([loading]) .route-view{opacity:.5;transition:opacity .3s ease}:host([error]) .route-view{border:1px solid var(--error-color, #ff0000);padding:1rem}.route-view.entering{animation:fadeIn .3s ease-out}.route-view.leaving{animation:fadeOut .3s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeOut{0%{opacity:1}to{opacity:0}}";var Le;let Re,xe;function ee(n,e,t){return(e=Ee(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Ve(n,e,t,r,g,v){function f(s,o,c){return function(i,u){return c&&c(i),s[o].call(i,u)}}function _(s,o){for(var c=0;c<s.length;c++)s[c].call(o);return o}function y(s,o,c,i){if(typeof s!="function"&&(i||s!==void 0))throw new TypeError(o+" must "+(c||"be")+" a function"+(i?"":" or undefined"));return s}function T(s,o,c,i,u,A,k,R,D,E,L,p,m){function h(d){if(!m(d))throw new TypeError("Attempted to access private element on non-instance")}var l,x=o[0],C=o[3],W=!R;if(!W){c||Array.isArray(x)||(x=[x]);var a={},S=[],w=u===3?"get":u===4||p?"set":"value";E?(L||p?a={get:le(function(){return C(this)},i,"get"),set:function(d){o[4](this,d)}}:a[w]=C,L||le(a[w],i,u===2?"":w)):L||(a=Object.getOwnPropertyDescriptor(s,i))}for(var b=s,U=x.length-1;U>=0;U-=c?2:1){var G=x[U],K=c?x[U-1]:void 0,J={},O={kind:["field","accessor","method","getter","setter","class"][u],name:i,metadata:A,addInitializer:(function(d,I){if(d.v)throw Error("attempted to call addInitializer after decoration was finished");y(I,"An initializer","be",!0),k.push(I)}).bind(null,J)};try{if(W)(l=y(G.call(K,b,O),"class decorators","return"))&&(b=l);else{var M,z;O.static=D,O.private=E,E?u===2?M=function(d){return h(d),a.value}:(u<4&&(M=f(a,"get",h)),u!==3&&(z=f(a,"set",h))):(M=function(d){return d[i]},(u<2||u===4)&&(z=function(d,I){d[i]=I}));var Q=O.access={has:E?m.bind():function(d){return i in d}};if(M&&(Q.get=M),z&&(Q.set=z),b=G.call(K,p?{get:a.get,set:a.set}:a[w],O),p){if(typeof b=="object"&&b)(l=y(b.get,"accessor.get"))&&(a.get=l),(l=y(b.set,"accessor.set"))&&(a.set=l),(l=y(b.init,"accessor.init"))&&S.push(l);else if(b!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else y(b,(L?"field":"method")+" decorators","return")&&(L?S.push(b):a[w]=b)}}finally{J.v=!0}}return(L||p)&&R.push(function(d,I){for(var F=S.length-1;F>=0;F--)I=S[F].call(d,I);return I}),L||W||(E?p?R.push(f(a,"get"),f(a,"set")):R.push(u===2?a[w]:f.call.bind(a[w])):Object.defineProperty(s,i,a)),b}function j(s,o){return Object.defineProperty(s,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:o})}if(arguments.length>=6)var V=v[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(V??null),B=function(s,o,c,i){var u,A,k=[],R=function(w){return ze(w)===s},D=new Map;function E(w){w&&k.push(_.bind(null,w))}for(var L=0;L<o.length;L++){var p=o[L];if(Array.isArray(p)){var m=p[1],h=p[2],l=p.length>3,x=16&m,C=!!(8&m),W=(m&=7)==0,a=h+"/"+C;if(!W&&!l){var S=D.get(a);if(S===!0||S===3&&m!==4||S===4&&m!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+h);D.set(a,!(m>2)||m)}T(C?s:s.prototype,p,x,l?"#"+h:Ee(h),m,i,C?A=A||[]:u=u||[],k,C,l,W,m===1,C&&l?R:c)}}return E(u),E(A),k}(n,e,g,P);return t.length||j(n,P),{e:B,get c(){var s=[];return t.length&&[j(T(n,[t],r,n.name,5,P,s),P),_.bind(null,s,n)]}}}function Ee(n){var e=Ue(n,"string");return typeof e=="symbol"?e:e+""}function Ue(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function le(n,e,t){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(n,"name",{configurable:!0,value:t?t+" "+e:e})}catch{}return n}function ze(n){if(Object(n)!==n)throw TypeError("right-hand side of 'in' should be an object, got "+(n!==null?typeof n:"null"));return n}const H=re("WsxView");xe=[N.autoRegister({tagName:"wsx-view"})];exports.WsxView=void 0;class Ne extends N.LightComponent{constructor(){super(),ee(this,"_autoStyles",De),ee(this,"_component",""),ee(this,"params",void 0),ee(this,"componentInstance",null),ee(this,"isLoading",!1);let e=this.reactive({});Object.defineProperty(this,"params",{get:()=>e,set:t=>{e=t!==null&&typeof t<"u"&&(Array.isArray(t)||typeof t=="object")?this.reactive(t):t,this.scheduleRerender()},enumerable:!0,configurable:!0})}get component(){return this._component}set component(e){this._component=e||"",this._component&&requestAnimationFrame(()=>{this.connected&&!this.componentInstance&&!this.isLoading&&this.loadComponent(this._component||"")})}render(){return N.jsx("div",{class:"route-view"})}onConnected(){requestAnimationFrame(()=>{!this.connected||this.isLoading||this.componentInstance||this.component&&this.loadComponent(this.component)})}async loadComponent(e){if(!(!this.connected||this.isLoading||this.componentInstance)){this.isLoading=!0;try{const t=this.componentInstance;if(t&&(t.remove(),this.componentInstance=null),!customElements.get(e)){H.warn(`Component ${e} not found in customElements registry`),this.isLoading=!1;return}H.warn(`WsxView: Creating instance of ${e}`),this.componentInstance=document.createElement(e),Object.keys(this.params).length>0&&(H.warn(`WsxView: Setting initial params on ${e}:`,this.params),Object.entries(this.params).forEach(([v,f])=>{this.componentInstance.setAttribute(v,f)}));const g=this.querySelector(".route-view");if(g){if(H.warn(`WsxView: Appending ${e} to container`),!customElements.get(e)){H.error(`WsxView: Component ${e} is not registered in customElements registry!`),this.isLoading=!1,this.componentInstance=null;return}g.appendChild(this.componentInstance),H.warn(`WsxView: Component ${e} appended successfully, waiting for connectedCallback...`),setTimeout(()=>{this.componentInstance&&this.componentInstance.isConnected?H.warn(`WsxView: Component ${e} is now connected to DOM`):H.error(`WsxView: Component ${e} was not connected to DOM!`)},0)}else H.error("WsxView: Route view container not found"),this.componentInstance=null}catch(t){H.warn(`Error loading component ${e}:`,t),this.componentInstance=null}finally{this.isLoading=!1,H.warn(`WsxView: loadComponent for ${e} completed, isLoading=${this.isLoading}`)}}}onDisconnected(){this.componentInstance&&(this.componentInstance.remove(),this.componentInstance=null)}}Le=Ne;[exports.WsxView,Re]=Ve(Le,[],xe,0,void 0,N.LightComponent).c;Re();const Fe=':host{display:inline-block;min-width:fit-content;min-height:fit-content;width:auto;height:auto}.wsx-link{color:var(--link-color, #007bff);text-decoration:var(--link-decoration, underline);cursor:pointer;transition:color .2s ease;display:inline-block;min-height:1.2em;line-height:1.2}.wsx-link:hover{color:var(--link-hover-color, #0056b3);text-decoration:var(--link-hover-decoration, underline)}.wsx-link:focus{outline:2px solid var(--link-focus-color, var(--focus-color, #dc2626));outline-offset:2px}.wsx-link.active{color:var(--link-active-color, #6c757d);font-weight:var(--link-active-weight, bold)}:host([disabled]) .wsx-link{color:var(--link-disabled-color, #6c757d);cursor:not-allowed;pointer-events:none}:host([external]) .wsx-link:after{content:"↗";font-size:.8em;margin-left:.2em;opacity:.7}:host([variant="button"]) .wsx-link{background-color:var(--button-bg, #007bff);color:var(--button-color, white);padding:.5rem 1rem;border-radius:.25rem;text-decoration:none;display:inline-block}:host([variant="button"]) .wsx-link:hover{background-color:var(--button-hover-bg, #0056b3);color:var(--button-hover-color, white)}:host([variant="tab"]) .wsx-link{padding:.5rem 1rem;border-bottom:2px solid transparent;text-decoration:none}:host([variant="tab"]) .wsx-link.active{border-bottom-color:var(--tab-active-border, #007bff)}';var ie,oe;let ue,Ce,he;function X(n,e,t){return(e=$e(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function qe(n,e,t,r,g,v){function f(s,o,c){return function(i,u){return c&&c(i),s[o].call(i,u)}}function _(s,o){for(var c=0;c<s.length;c++)s[c].call(o);return o}function y(s,o,c,i){if(typeof s!="function"&&(i||s!==void 0))throw new TypeError(o+" must "+(c||"be")+" a function"+(i?"":" or undefined"));return s}function T(s,o,c,i,u,A,k,R,D,E,L,p,m){function h(d){if(!m(d))throw new TypeError("Attempted to access private element on non-instance")}var l,x=o[0],C=o[3],W=!R;if(!W){c||Array.isArray(x)||(x=[x]);var a={},S=[],w=u===3?"get":u===4||p?"set":"value";E?(L||p?a={get:fe(function(){return C(this)},i,"get"),set:function(d){o[4](this,d)}}:a[w]=C,L||fe(a[w],i,u===2?"":w)):L||(a=Object.getOwnPropertyDescriptor(s,i))}for(var b=s,U=x.length-1;U>=0;U-=c?2:1){var G=x[U],K=c?x[U-1]:void 0,J={},O={kind:["field","accessor","method","getter","setter","class"][u],name:i,metadata:A,addInitializer:(function(d,I){if(d.v)throw Error("attempted to call addInitializer after decoration was finished");y(I,"An initializer","be",!0),k.push(I)}).bind(null,J)};try{if(W)(l=y(G.call(K,b,O),"class decorators","return"))&&(b=l);else{var M,z;O.static=D,O.private=E,E?u===2?M=function(d){return h(d),a.value}:(u<4&&(M=f(a,"get",h)),u!==3&&(z=f(a,"set",h))):(M=function(d){return d[i]},(u<2||u===4)&&(z=function(d,I){d[i]=I}));var Q=O.access={has:E?m.bind():function(d){return i in d}};if(M&&(Q.get=M),z&&(Q.set=z),b=G.call(K,p?{get:a.get,set:a.set}:a[w],O),p){if(typeof b=="object"&&b)(l=y(b.get,"accessor.get"))&&(a.get=l),(l=y(b.set,"accessor.set"))&&(a.set=l),(l=y(b.init,"accessor.init"))&&S.push(l);else if(b!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else y(b,(L?"field":"method")+" decorators","return")&&(L?S.push(b):a[w]=b)}}finally{J.v=!0}}return(L||p)&&R.push(function(d,I){for(var F=S.length-1;F>=0;F--)I=S[F].call(d,I);return I}),L||W||(E?p?R.push(f(a,"get"),f(a,"set")):R.push(u===2?a[w]:f.call.bind(a[w])):Object.defineProperty(s,i,a)),b}function j(s,o){return Object.defineProperty(s,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:o})}if(arguments.length>=6)var V=v[Symbol.metadata||Symbol.for("Symbol.metadata")];var P=Object.create(V??null),B=function(s,o,c,i){var u,A,k=[],R=function(w){return Be(w)===s},D=new Map;function E(w){w&&k.push(_.bind(null,w))}for(var L=0;L<o.length;L++){var p=o[L];if(Array.isArray(p)){var m=p[1],h=p[2],l=p.length>3,x=16&m,C=!!(8&m),W=(m&=7)==0,a=h+"/"+C;if(!W&&!l){var S=D.get(a);if(S===!0||S===3&&m!==4||S===4&&m!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+h);D.set(a,!(m>2)||m)}T(C?s:s.prototype,p,x,l?"#"+h:$e(h),m,i,C?A=A||[]:u=u||[],k,C,l,W,m===1,C&&l?R:c)}}return E(u),E(A),k}(n,e,g,P);return t.length||j(n,P),{e:B,get c(){var s=[];return t.length&&[j(T(n,[t],r,n.name,5,P,s),P),_.bind(null,s,n)]}}}function $e(n){var e=He(n,"string");return typeof e=="symbol"?e:e+""}function He(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function fe(n,e,t){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(n,"name",{configurable:!0,value:t?t+" "+e:e})}catch{}return n}function Be(n){if(Object(n)!==n)throw TypeError("right-hand side of 'in' should be an object, got "+(n!==null?typeof n:"null"));return n}function Ge(n){return n}const de=re("WsxLink");Ce=[N.autoRegister({tagName:"wsx-link"})];exports.WsxLink=void 0;new(he=(oe=class extends N.WebComponent{constructor(){super(),X(this,"_autoStyles",Fe),X(this,"to",void 0),X(this,"activeClass",void 0),X(this,"handleClick",v=>{if(v.preventDefault(),!this.to){de.warn("No 'to' attribute specified");return}if(this.isExternalLink(this.to)){window.open(this.to,"_blank");return}this.replace?window.history.replaceState(null,"",this.to):window.history.pushState(null,"",this.to),window.dispatchEvent(new PopStateEvent("popstate")),de.debug(`Navigated to: ${this.to}`)}),X(this,"updateActiveState",()=>{var y;const v=window.location.pathname,f=this.exact?v===this.to:v.startsWith(this.to)&&this.to!=="/",_=(y=this.shadowRoot)==null?void 0:y.querySelector("a");_&&(f?(_.classList.add(this.activeClass),this.setAttribute("active","")):(_.classList.remove(this.activeClass),this.removeAttribute("active")))});const[e,t]=this.useState("to","");Object.defineProperty(this,"to",{get:e,set:t,enumerable:!0,configurable:!0});const[r,g]=this.useState("activeClass","active");Object.defineProperty(this,"activeClass",{get:r,set:g,enumerable:!0,configurable:!0})}get replace(){return this.hasAttribute("replace")}get exact(){return this.hasAttribute("exact")}render(){return N.jsx("a",{href:this.to,class:"wsx-link",onClick:this.handleClick,part:"link"},N.jsx("slot",null))}onConnected(){this.to=this.to||"",this.activeClass=this.activeClass||"active";const e=this.shadowRoot.querySelector(".wsx-link");e&&(e.href=this.to),window.addEventListener("popstate",this.updateActiveState),document.addEventListener("route-changed",this.updateActiveState),this.updateActiveState()}onDisconnected(){window.removeEventListener("popstate",this.updateActiveState),document.removeEventListener("route-changed",this.updateActiveState)}onAttributeChanged(e,t,r){switch(e){case"to":this.to=r||"",this.updateActiveState();break;case"replace":this.replace=r!==null&&r!=="false";break;case"active-class":this.activeClass=r||"active",this.updateActiveState();break;case"exact":this.exact=r!==null&&r!=="false",this.updateActiveState();break}}isExternalLink(e){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("mailto:")||e.startsWith("tel:")}navigate(){this.to&&this.handleClick(new MouseEvent("click",{bubbles:!0,cancelable:!0}))}},[exports.WsxLink,ue]=qe(oe,[],Ce,0,void 0,N.WebComponent).c,oe),ie=class extends Ge{constructor(){super(exports.WsxLink),X(this,"observedAttributes",["to","replace","active-class","exact"]),ue()}},X(ie,he,void 0),ie);exports.RouterUtils=ne;
|