@noego/forge 0.1.20 → 0.1.22

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/client.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("./page.svelte-CW8PJDdH.cjs");require("svelte/internal/client");const qe=require("svelte"),$e=require("../src/components/RecursiveRender.svelte"),R=require("svelte/store");function We(e){const r=new x.path_to_regex(e);return t=>{const n=r.match(t);if(!n)return null;const o={};for(const[i,a]of Object.entries(n))o[i]=decodeURIComponent(a);return o}}function De(e){return e.map(r=>{const t=r.path,n=We(t);return{pattern:t,parser:n}})}var re=function(e,r){return re=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])},re(e,r)};function M(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");re(e,r);function t(){this.constructor=e}e.prototype=r===null?Object.create(r):(t.prototype=r.prototype,new t)}function ze(e,r,t,n){function o(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,a){function c(l){try{u(n.next(l))}catch(f){a(f)}}function s(l){try{u(n.throw(l))}catch(f){a(f)}}function u(l){l.done?i(l.value):o(l.value).then(c,s)}u((n=n.apply(e,r||[])).next())})}function me(e,r){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(u){return function(l){return s([u,l])}}function s(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(t=0)),t;)try{if(n=1,o&&(i=u[0]&2?o.return:u[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,u[1])).done)return i;switch(o=0,i&&(u=[u[0]&2,i.value]),u[0]){case 0:case 1:i=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,o=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){t.label=u[1];break}if(u[0]===6&&t.label<i[1]){t.label=i[1],i=u;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(u);break}i[2]&&t.ops.pop(),t.trys.pop();continue}u=r.call(e,t)}catch(l){u=[6,l],o=0}finally{n=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function U(e){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function L(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var n=t.call(e),o,i=[],a;try{for(;(r===void 0||r-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(c){a={error:c}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return i}function F(e,r,t){if(t||arguments.length===2)for(var n=0,o=r.length,i;n<o;n++)(i||!(n in r))&&(i||(i=Array.prototype.slice.call(r,0,n)),i[n]=r[n]);return e.concat(i||Array.prototype.slice.call(r))}function j(e){return this instanceof j?(this.v=e,this):new j(e)}function Ge(e,r,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(e,r||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",a),o[Symbol.asyncIterator]=function(){return this},o;function a(d){return function(p){return Promise.resolve(p).then(d,f)}}function c(d,p){n[d]&&(o[d]=function(h){return new Promise(function(g,b){i.push([d,h,g,b])>1||s(d,h)})},p&&(o[d]=p(o[d])))}function s(d,p){try{u(n[d](p))}catch(h){v(i[0][3],h)}}function u(d){d.value instanceof j?Promise.resolve(d.value.v).then(l,f):v(i[0][2],d)}function l(d){s("next",d)}function f(d){s("throw",d)}function v(d,p){d(p),i.shift(),i.length&&s(i[0][0],i[0][1])}}function He(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e[Symbol.asyncIterator],t;return r?r.call(e):(e=typeof U=="function"?U(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(i){t[i]=e[i]&&function(a){return new Promise(function(c,s){a=e[i](a),o(c,s,a.done,a.value)})}}function o(i,a,c,s){Promise.resolve(s).then(function(u){i({value:u,done:c})},a)}}function w(e){return typeof e=="function"}function ae(e){var r=function(n){Error.call(n),n.stack=new Error().stack},t=e(r);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var J=ae(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
2
- `+t.map(function(n,o){return o+1+") "+n.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=t}});function ne(e,r){if(e){var t=e.indexOf(r);0<=t&&e.splice(t,1)}}var Y=(function(){function e(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var r,t,n,o,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var c=U(a),s=c.next();!s.done;s=c.next()){var u=s.value;u.remove(this)}}catch(h){r={error:h}}finally{try{s&&!s.done&&(t=c.return)&&t.call(c)}finally{if(r)throw r.error}}else a.remove(this);var l=this.initialTeardown;if(w(l))try{l()}catch(h){i=h instanceof J?h.errors:[h]}var f=this._finalizers;if(f){this._finalizers=null;try{for(var v=U(f),d=v.next();!d.done;d=v.next()){var p=d.value;try{de(p)}catch(h){i=i??[],h instanceof J?i=F(F([],L(i)),L(h.errors)):i.push(h)}}}catch(h){n={error:h}}finally{try{d&&!d.done&&(o=v.return)&&o.call(v)}finally{if(n)throw n.error}}}if(i)throw new J(i)}},e.prototype.add=function(r){var t;if(r&&r!==this)if(this.closed)de(r);else{if(r instanceof e){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(r)}},e.prototype._hasParent=function(r){var t=this._parentage;return t===r||Array.isArray(t)&&t.includes(r)},e.prototype._addParent=function(r){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(r),t):t?[t,r]:r},e.prototype._removeParent=function(r){var t=this._parentage;t===r?this._parentage=null:Array.isArray(t)&&ne(t,r)},e.prototype.remove=function(r){var t=this._finalizers;t&&ne(t,r),r instanceof e&&r._removeParent(this)},e.EMPTY=(function(){var r=new e;return r.closed=!0,r})(),e})(),we=Y.EMPTY;function be(e){return e instanceof Y||e&&"closed"in e&&w(e.remove)&&w(e.add)&&w(e.unsubscribe)}function de(e){w(e)?e():e.unsubscribe()}var Be={Promise:void 0},Ye={setTimeout:function(e,r){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];return setTimeout.apply(void 0,F([e,r],L(t)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function ge(e){Ye.setTimeout(function(){throw e})}function he(){}function D(e){e()}var se=(function(e){M(r,e);function r(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,be(t)&&t.add(n)):n.destination=Je,n}return r.create=function(t,n,o){return new k(t,n,o)},r.prototype.next=function(t){this.isStopped||this._next(t)},r.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(t){this.destination.next(t)},r.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r})(Y),Ke=(function(){function e(r){this.partialObserver=r}return e.prototype.next=function(r){var t=this.partialObserver;if(t.next)try{t.next(r)}catch(n){W(n)}},e.prototype.error=function(r){var t=this.partialObserver;if(t.error)try{t.error(r)}catch(n){W(n)}else W(r)},e.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(t){W(t)}},e})(),k=(function(e){M(r,e);function r(t,n,o){var i=e.call(this)||this,a;return w(t)||!t?a={next:t??void 0,error:n??void 0,complete:o??void 0}:a=t,i.destination=new Ke(a),i}return r})(se);function W(e){ge(e)}function Xe(e){throw e}var Je={closed:!0,next:he,error:Xe,complete:he},ue=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function ce(e){return e}function Ze(e){return e.length===0?ce:e.length===1?e[0]:function(t){return e.reduce(function(n,o){return o(n)},t)}}var _=(function(){function e(r){r&&(this._subscribe=r)}return e.prototype.lift=function(r){var t=new e;return t.source=this,t.operator=r,t},e.prototype.subscribe=function(r,t,n){var o=this,i=et(r)?r:new k(r,t,n);return D(function(){var a=o,c=a.operator,s=a.source;i.add(c?c.call(i,s):s?o._subscribe(i):o._trySubscribe(i))}),i},e.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(t){r.error(t)}},e.prototype.forEach=function(r,t){var n=this;return t=pe(t),new t(function(o,i){var a=new k({next:function(c){try{r(c)}catch(s){i(s),a.unsubscribe()}},error:i,complete:o});n.subscribe(a)})},e.prototype._subscribe=function(r){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(r)},e.prototype[ue]=function(){return this},e.prototype.pipe=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return Ze(r)(this)},e.prototype.toPromise=function(r){var t=this;return r=pe(r),new r(function(n,o){var i;t.subscribe(function(a){return i=a},function(a){return o(a)},function(){return n(i)})})},e.create=function(r){return new e(r)},e})();function pe(e){var r;return(r=e??Be.Promise)!==null&&r!==void 0?r:Promise}function Qe(e){return e&&w(e.next)&&w(e.error)&&w(e.complete)}function et(e){return e&&e instanceof se||Qe(e)&&be(e)}function tt(e){return w(e==null?void 0:e.lift)}function P(e){return function(r){if(tt(r))return r.lift(function(t){try{return e(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function A(e,r,t,n,o){return new rt(e,r,t,n,o)}var rt=(function(e){M(r,e);function r(t,n,o,i,a,c){var s=e.call(this,t)||this;return s.onFinalize=a,s.shouldUnsubscribe=c,s._next=n?function(u){try{n(u)}catch(l){t.error(l)}}:e.prototype._next,s._error=i?function(u){try{i(u)}catch(l){t.error(l)}finally{this.unsubscribe()}}:e.prototype._error,s._complete=o?function(){try{o()}catch(u){t.error(u)}finally{this.unsubscribe()}}:e.prototype._complete,s}return r.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},r})(se),nt=ae(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),K=(function(e){M(r,e);function r(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return r.prototype.lift=function(t){var n=new ve(this,this);return n.operator=t,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new nt},r.prototype.next=function(t){var n=this;D(function(){var o,i;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var a=U(n.currentObservers),c=a.next();!c.done;c=a.next()){var s=c.value;s.next(t)}}catch(u){o={error:u}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}}})},r.prototype.error=function(t){var n=this;D(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var o=n.observers;o.length;)o.shift().error(t)}})},r.prototype.complete=function(){var t=this;D(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},r.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},r.prototype._innerSubscribe=function(t){var n=this,o=this,i=o.hasError,a=o.isStopped,c=o.observers;return i||a?we:(this.currentObservers=null,c.push(t),new Y(function(){n.currentObservers=null,ne(c,t)}))},r.prototype._checkFinalizedStatuses=function(t){var n=this,o=n.hasError,i=n.thrownError,a=n.isStopped;o?t.error(i):a&&t.complete()},r.prototype.asObservable=function(){var t=new _;return t.source=this,t},r.create=function(t,n){return new ve(t,n)},r})(_),ve=(function(e){M(r,e);function r(t,n){var o=e.call(this)||this;return o.destination=t,o.source=n,o}return r.prototype.next=function(t){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,t)},r.prototype.error=function(t){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,t)},r.prototype.complete=function(){var t,n;(n=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||n===void 0||n.call(t)},r.prototype._subscribe=function(t){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(t))!==null&&o!==void 0?o:we},r})(K),Se={now:function(){return(Se.delegate||Date).now()},delegate:void 0},ot=(function(e){M(r,e);function r(t,n,o){t===void 0&&(t=1/0),n===void 0&&(n=1/0),o===void 0&&(o=Se);var i=e.call(this)||this;return i._bufferSize=t,i._windowTime=n,i._timestampProvider=o,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,n),i}return r.prototype.next=function(t){var n=this,o=n.isStopped,i=n._buffer,a=n._infiniteTimeWindow,c=n._timestampProvider,s=n._windowTime;o||(i.push(t),!a&&i.push(c.now()+s)),this._trimBuffer(),e.prototype.next.call(this,t)},r.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(t),o=this,i=o._infiniteTimeWindow,a=o._buffer,c=a.slice(),s=0;s<c.length&&!t.closed;s+=i?1:2)t.next(c[s]);return this._checkFinalizedStatuses(t),n},r.prototype._trimBuffer=function(){var t=this,n=t._bufferSize,o=t._timestampProvider,i=t._buffer,a=t._infiniteTimeWindow,c=(a?1:2)*n;if(n<1/0&&c<i.length&&i.splice(0,i.length-c),!a){for(var s=o.now(),u=0,l=1;l<i.length&&i[l]<=s;l+=2)u=l;u&&i.splice(0,u+1)}},r})(K),le=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function _e(e){return w(e==null?void 0:e.then)}function Ee(e){return w(e[ue])}function Oe(e){return Symbol.asyncIterator&&w(e==null?void 0:e[Symbol.asyncIterator])}function Ae(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function it(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Pe=it();function Te(e){return w(e==null?void 0:e[Pe])}function Ie(e){return Ge(this,arguments,function(){var t,n,o,i;return me(this,function(a){switch(a.label){case 0:t=e.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,j(t.read())];case 3:return n=a.sent(),o=n.value,i=n.done,i?[4,j(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,j(o)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function xe(e){return w(e==null?void 0:e.getReader)}function T(e){if(e instanceof _)return e;if(e!=null){if(Ee(e))return at(e);if(le(e))return st(e);if(_e(e))return ut(e);if(Oe(e))return Re(e);if(Te(e))return ct(e);if(xe(e))return lt(e)}throw Ae(e)}function at(e){return new _(function(r){var t=e[ue]();if(w(t.subscribe))return t.subscribe(r);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function st(e){return new _(function(r){for(var t=0;t<e.length&&!r.closed;t++)r.next(e[t]);r.complete()})}function ut(e){return new _(function(r){e.then(function(t){r.closed||(r.next(t),r.complete())},function(t){return r.error(t)}).then(null,ge)})}function ct(e){return new _(function(r){var t,n;try{for(var o=U(e),i=o.next();!i.done;i=o.next()){var a=i.value;if(r.next(a),r.closed)return}}catch(c){t={error:c}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}r.complete()})}function Re(e){return new _(function(r){ft(e,r).catch(function(t){return r.error(t)})})}function lt(e){return Re(Ie(e))}function ft(e,r){var t,n,o,i;return ze(this,void 0,void 0,function(){var a,c;return me(this,function(s){switch(s.label){case 0:s.trys.push([0,5,6,11]),t=He(e),s.label=1;case 1:return[4,t.next()];case 2:if(n=s.sent(),!!n.done)return[3,4];if(a=n.value,r.next(a),r.closed)return[2];s.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=s.sent(),o={error:c},[3,11];case 6:return s.trys.push([6,,9,10]),n&&!n.done&&(i=t.return)?[4,i.call(t)]:[3,8];case 7:s.sent(),s.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return r.complete(),[2]}})})}function C(e,r,t,n,o){n===void 0&&(n=0),o===void 0&&(o=!1);var i=r.schedule(function(){t(),o?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(i),!o)return i}function Ce(e,r){return r===void 0&&(r=0),P(function(t,n){t.subscribe(A(n,function(o){return C(n,e,function(){return n.next(o)},r)},function(){return C(n,e,function(){return n.complete()},r)},function(o){return C(n,e,function(){return n.error(o)},r)}))})}function je(e,r){return r===void 0&&(r=0),P(function(t,n){n.add(e.schedule(function(){return t.subscribe(n)},r))})}function dt(e,r){return T(e).pipe(je(r),Ce(r))}function ht(e,r){return T(e).pipe(je(r),Ce(r))}function pt(e,r){return new _(function(t){var n=0;return r.schedule(function(){n===e.length?t.complete():(t.next(e[n++]),t.closed||this.schedule())})})}function vt(e,r){return new _(function(t){var n;return C(t,r,function(){n=e[Pe](),C(t,r,function(){var o,i,a;try{o=n.next(),i=o.value,a=o.done}catch(c){t.error(c);return}a?t.complete():t.next(i)},0,!0)}),function(){return w(n==null?void 0:n.return)&&n.return()}})}function Ne(e,r){if(!e)throw new Error("Iterable cannot be null");return new _(function(t){C(t,r,function(){var n=e[Symbol.asyncIterator]();C(t,r,function(){n.next().then(function(o){o.done?t.complete():t.next(o.value)})},0,!0)})})}function yt(e,r){return Ne(Ie(e),r)}function mt(e,r){if(e!=null){if(Ee(e))return dt(e,r);if(le(e))return pt(e,r);if(_e(e))return ht(e,r);if(Oe(e))return Ne(e,r);if(Te(e))return vt(e,r);if(xe(e))return yt(e,r)}throw Ae(e)}function Ue(e,r){return r?mt(e,r):T(e)}var wt=ae(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function bt(e,r){return new Promise(function(t,n){var o=new k({next:function(i){t(i),o.unsubscribe()},error:n,complete:function(){n(new wt)}});e.subscribe(o)})}function fe(e,r){return P(function(t,n){var o=0;t.subscribe(A(n,function(i){n.next(e.call(r,i,o++))}))})}var gt=Array.isArray;function St(e,r){return gt(r)?e.apply(void 0,F([],L(r))):e(r)}function _t(e){return fe(function(r){return St(e,r)})}function Et(e,r,t,n,o,i,a,c){var s=[],u=0,l=0,f=!1,v=function(){f&&!s.length&&!u&&r.complete()},d=function(h){return u<n?p(h):s.push(h)},p=function(h){u++;var g=!1;T(t(h,l++)).subscribe(A(r,function(b){r.next(b)},function(){g=!0},void 0,function(){if(g)try{u--;for(var b=function(){var y=s.shift();a||p(y)};s.length&&u<n;)b();v()}catch(y){r.error(y)}}))};return e.subscribe(A(r,d,function(){f=!0,v()})),function(){}}function Le(e,r,t){return t===void 0&&(t=1/0),w(r)?Le(function(n,o){return fe(function(i,a){return r(n,i,o,a)})(T(e(n,o)))},t):(typeof r=="number"&&(t=r),P(function(n,o){return Et(n,o,e,t)}))}var Ot=["addListener","removeListener"],At=["addEventListener","removeEventListener"],Pt=["on","off"];function oe(e,r,t,n){if(w(t)&&(n=t,t=void 0),n)return oe(e,r,t).pipe(_t(n));var o=L(xt(e)?At.map(function(c){return function(s){return e[c](r,s,t)}}):Tt(e)?Ot.map(ye(e,r)):It(e)?Pt.map(ye(e,r)):[],2),i=o[0],a=o[1];if(!i&&le(e))return Le(function(c){return oe(c,r,t)})(T(e));if(!i)throw new TypeError("Invalid event target");return new _(function(c){var s=function(){for(var u=[],l=0;l<arguments.length;l++)u[l]=arguments[l];return c.next(1<u.length?u:u[0])};return i(s),function(){return a(s)}})}function ye(e,r){return function(t){return function(n){return e[t](r,n)}}}function Tt(e){return w(e.addListener)&&w(e.removeListener)}function It(e){return w(e.on)&&w(e.off)}function xt(e){return w(e.addEventListener)&&w(e.removeEventListener)}function Z(e,r){return P(function(t,n){var o=0;t.subscribe(A(n,function(i){return e.call(r,i,o++)&&n.next(i)}))})}function Rt(e,r){return r===void 0&&(r=ce),e=e??Ct,P(function(t,n){var o,i=!0;t.subscribe(A(n,function(a){var c=r(a);(i||!e(o,c))&&(i=!1,o=c,n.next(a))}))})}function Ct(e,r){return e===r}function jt(e){e===void 0&&(e={});var r=e.connector,t=r===void 0?function(){return new K}:r,n=e.resetOnError,o=n===void 0?!0:n,i=e.resetOnComplete,a=i===void 0?!0:i,c=e.resetOnRefCountZero,s=c===void 0?!0:c;return function(u){var l,f,v,d=0,p=!1,h=!1,g=function(){f==null||f.unsubscribe(),f=void 0},b=function(){g(),l=v=void 0,p=h=!1},y=function(){var m=l;b(),m==null||m.unsubscribe()};return P(function(m,E){d++,!h&&!p&&g();var q=v=v??t();E.add(function(){d--,d===0&&!h&&!p&&(f=Q(y,s))}),q.subscribe(E),!l&&d>0&&(l=new k({next:function($){return q.next($)},error:function($){h=!0,g(),f=Q(b,o,$),q.error($)},complete:function(){p=!0,g(),f=Q(b,a),q.complete()}}),T(m).subscribe(l))})(u)}}function Q(e,r){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];if(r===!0){e();return}if(r!==!1){var o=new k({next:function(){o.unsubscribe(),e()}});return T(r.apply(void 0,F([],L(t)))).subscribe(o)}}function ke(e,r){return P(function(t,n){var o=null,i=0,a=!1,c=function(){return a&&!o&&n.complete()};t.subscribe(A(n,function(s){o==null||o.unsubscribe();var u=0,l=i++;T(e(s,l)).subscribe(o=A(n,function(f){return n.next(r?r(s,f,l,u++):f)},function(){o=null,c()}))},function(){a=!0,c()}))})}function Nt(e,r,t){var n=w(e)||r||t?{next:e,error:r,complete:t}:e;return n?P(function(o,i){var a;(a=n.subscribe)===null||a===void 0||a.call(n);var c=!0;o.subscribe(A(i,function(s){var u;(u=n.next)===null||u===void 0||u.call(n,s),i.next(s)},function(){var s;c=!1,(s=n.complete)===null||s===void 0||s.call(n),i.complete()},function(s){var u;c=!1,(u=n.error)===null||u===void 0||u.call(n,s),i.error(s)},function(){var s,u;c&&((s=n.unsubscribe)===null||s===void 0||s.call(n)),(u=n.finalize)===null||u===void 0||u.call(n)}))}):ce}const N=R.writable({});async function Me(){N.update(e=>(Object.assign(e,window.__MANIFEST__),e))}const I=new Map,z=5e3;function Ut(e){const r=I.get(e);return r?(I.delete(e),Date.now()-r.createdAt>z?(r.abortController.abort(),null):r.response$):null}function Lt(e,r){oe(document,"mouseover").pipe(jt()).pipe(fe(o=>{const i=o.target,a=(i==null?void 0:i.tagName)==="A"?i:i==null?void 0:i.closest("A");if(!a)return null;const c=a.getAttribute("href");return!c||!c.startsWith("/")&&!c.startsWith(".")?null:c}),Z(o=>o!==null),Z(o=>o!==window.location.pathname),Rt(),Z(o=>{const i=o.split("?")[0],a="get",c=e.find(l=>l.method.toLowerCase()===a&&r.find(f=>f.parser(i)&&f.pattern===l.path));if(!c)return!1;const s=r.find(l=>l.parser(i)&&l.pattern===c.path);return!!R.get(N)[s==null?void 0:s.pattern]}),ke(o=>{const i=I.get(o);if(i&&Date.now()-i.createdAt<z)return[];const a=new AbortController,c=new ot(1),s={response$:c,createdAt:Date.now(),abortController:a};I.set(o,s);const u={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:a.signal};return u[X]=!0,Ue(fetch(o,u).then(l=>(c.next(l),c.complete(),o),l=>(c.error(l),I.delete(o),null))).pipe(Nt({unsubscribe:()=>{a.abort(),I.delete(o)}}))})).subscribe(),setInterval(()=>{const o=Date.now();for(const[i,a]of I)o-a.createdAt>z&&(a.abortController.abort(),I.delete(i))},z)}const kt=1e4;function Mt(e,r,t){let n=null,o=!1;const i=new Promise((a,c)=>{n=setTimeout(()=>{o=!0,console.error("[TIMEOUT] Timeout fired after",r,"ms"),t(),c(new Error(`Navigation timed out after ${r}ms`))},r),console.log("[TIMEOUT] Timeout scheduled for",r,"ms, timeoutId:",n)});return Promise.race([e.finally(()=>{n!==null&&(o?console.warn("[TIMEOUT] Promise settled AFTER timeout already fired"):(console.log("[TIMEOUT] Clearing timeout",n,"- promise settled successfully"),clearTimeout(n)))}),i])}const ie=new K;let S=0,V=null;function Vt(e){e&&e.redirectPath&&(console.log("[NAV] Handling redirect to",e.redirectPath),setTimeout(()=>{window.dispatchEvent(new CustomEvent("forge-redirect",{detail:{path:e.redirectPath}}))},0))}ie.pipe(ke(e=>Ue(Mt($t(e),kt,()=>{console.error("[NAV] Navigation timed out"),S++,V&&(V.abort(),V=null)}).catch(r=>{console.error("[NAV] Navigation failed:",r)})))).subscribe({next:Vt,error:e=>{console.error("[NAV] Stream error:",e)}});function Ft(e){var r;console.log("[NAV STREAM] Pushing navigation event to stream",{url:e.url,currentNavigationId:S,subscriberCount:((r=ie.observers)==null?void 0:r.length)||0}),ie.next(e)}const O=R.writable({active:{layouts:[],view:null,viewPath:null,layoutPaths:[],data:{layout:[],view:{}},params:{},urlParams:{},query:{}},phase:"idle",navigationId:0,page:x.page}),qt=async()=>{const e=R.get(O).navigationId;try{const r=window.location.pathname+window.location.search,t={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"}};t[X]=!0;const n=await fetch(r,t);if(!n.ok)return!1;const o=await n.json(),i=R.get(O).navigationId;return e!==i?(console.log("[NAV POLL] Discarding stale poll response",{pollNavigationId:e,currentNavigationId:i}),!1):(O.update(a=>{var c;return a.active.data={layout:((c=a.active.data)==null?void 0:c.layout)||[],view:o.view},a}),!0)}catch{return!1}};x.page.update(e=>(e.poll=qt,e));function B(...e){let r=e.map((t,n)=>n===0?t.replace(/\/+$/,""):t.replace(/^\/+|\/+$/g,"")).join("/");return r.startsWith("/")||(r="/"+r),r.split("?")[0]}async function Ve(e,r,t,n,o,i){try{const a=typeof r=="string"&&r.indexOf("assets")!==-1,c=(t.layout||[]).map(d=>{let p=B(r,d).toString();return a&&(p=p.endsWith(".svelte")?p.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(p)?p:p+".js"),p});let s=B(r,t.view).toString();a&&(s=s.endsWith(".svelte")?s.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(s)?s:s+".js");const u=await Promise.all(c.map(d=>import(d).then(p=>p.default)));s.startsWith("/")||(s="/"+s);const l=await import(s).then(d=>d.default),f=window.__INITIAL_DATA__||{layout:[],view:{}},v={layouts:u,view:l,viewPath:t.view||null,layoutPaths:t.layout||[],data:f,params:n,urlParams:o,query:i};O.update(d=>(d.active=v,d.phase="idle",d)),qe.hydrate($e,{target:e,props:{root:O}})}catch(a){console.error("Client-side route loading failed:",a)}}function G(e,r,t,n,o,i,a=!1,c=!0){Ft({url:e,base_path:r,route:t,params:n,urlParams:o,query:i,server_loading:a,updateUrl:c})}async function $t(e){const{url:r,base_path:t,route:n,params:o,urlParams:i,query:a,server_loading:c,updateUrl:s}=e,u=++S,l=new AbortController;V=l,console.log("[NAV] Starting navigation",{navigationId:u,url:r,updateUrl:s,server_loading:c,currentNavigationId:S,hasAbortController:!!V}),O.update(f=>(f.phase="loading",f.navigationId=u,f));try{let f={layout:[],view:{}};if(c){console.log("[NAV] Fetching server data",{navigationId:u,url:r});let y=null;const m=Ut(r);if(m)try{console.log("[NAV] Using prefetched response for",r),y=await bt(m)}catch{console.log("[NAV] Prefetch failed, falling back to fetch",r),y=null}if(!y){const E={method:n.method,headers:{"Content-Type":"application/json",Accept:"application/json"},signal:l.signal};E[X]=!0,y=await fetch(r,E)}if(console.log("[NAV] Fetch response received",{navigationId:u,url:r,ok:y.ok,status:y.status,redirected:y.redirected,currentNavigationId:S}),y.redirected||y.headers.get("X-Forge-Redirect")==="true")return console.log("[NAV] Redirect detected"),O.update(E=>(E.phase="idle",E)),{redirectPath:y.headers.get("X-Forge-Redirect-Path")||void 0};if(!y.ok)throw new Error(`Network response was not ok: ${y.status}`);f=await y.json(),console.log("[NAV] Server data received:",f)}if(u!==S){console.log("[NAV] Stale navigation after fetch, aborting",{navigationId:u,currentNavigationId:S});return}console.log("[NAV] Loading components",{navigationId:u,view:n.view,layouts:n.layout});const v=typeof t=="string"&&t.indexOf("assets")!==-1,d=(n.layout||[]).map(y=>{let m=B(t,y).toString();return v&&(m=m.endsWith(".svelte")?m.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(m)?m:m+".js"),m});let p=B(t,n.view).toString();v&&(p=p.endsWith(".svelte")?p.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(p)?p:p+".js"),p.startsWith("/")||(p="/"+p);const h=await Promise.all(d.map(y=>import(y).then(m=>m.default))),g=await import(p).then(y=>y.default);if(console.log("[NAV] Components loaded",{navigationId:u,currentNavigationId:S,layoutsCount:h.length,viewLoaded:!!g}),u!==S){console.log("[NAV] Stale navigation after component load, aborting",{navigationId:u,currentNavigationId:S});return}const b={layouts:h,view:g,viewPath:n.view||null,layoutPaths:n.layout||[],data:f,params:o,urlParams:i,query:a};console.log("[NAV] Committing new state",{navigationId:u,currentNavigationId:S,layoutsCount:b.layouts.length,viewSet:!!b.view,dataKeys:Object.keys(b.data||{})}),O.update(y=>(y.active=b,y.phase="idle",console.log("[NAV] ROOT.active updated",{navigationId:u,layoutsCount:y.active.layouts.length,viewSet:!!y.active.view,dataKeys:Object.keys(y.active.data||{}),paramsKeys:Object.keys(y.active.params||{})}),y)),typeof window<"u"&&window.scroll(0,0),s&&(console.log("[NAV] Updating browser URL",{url:r}),window.history.pushState({},"",r)),console.log("[NAV] Navigation complete",{navigationId:u,url:r})}catch(f){if(console.error("[NAV] Navigation failed",{navigationId:u,currentNavigationId:S,url:r,error:f instanceof Error?f.message:String(f)}),O.update(v=>(v.phase="idle",v)),f.name==="AbortError"){console.log("[NAV] Navigation aborted");return}throw f}}function Fe(e,r,t){if(!document){console.error("Document not found");return}document.addEventListener("click",n=>{var a,c;const o=window.location.pathname,i=((a=n.target)==null?void 0:a.tagName)==="A"?n.target:(c=n.target)==null?void 0:c.closest("A");if(i){let s=i.getAttribute("href");if(o===s){n.preventDefault();return}if(s&&s.startsWith("/")||s.startsWith(".")){const u=s.split("?")[0],l=i.getAttribute("method")||"get",f=r.find(v=>v.method.toLowerCase()===l&&t.find(d=>d.parser(u)&&d.pattern===v.path));if(f){n.preventDefault();const v=t.find(m=>m.parser(u)&&m.pattern===f.path),d=(v==null?void 0:v.parser(u))||{},p=new URLSearchParams(s.split("?")[1]||""),h=Object.fromEntries(p.entries())||{},g={...d,...h},y=R.get(N)[v==null?void 0:v.pattern];x.page.update(m=>(m.url=s,m.pathname=u,m.params=d,m.query=h,m)),console.log("[EVENTS] Click navigation to",s),G(s,e,f,g,d,h,y,!0)}else console.log("No matching route found for URL:",s,"- using fallback navigation")}}}),window.addEventListener("popstate",n=>{const o=window.location.pathname,i=window.location.pathname+window.location.search,a="get",c=r.find(s=>s.method.toLowerCase()===a&&t.find(u=>u.parser(o)&&u.pattern===s.path));if(c){const s=t.find(h=>h.parser(o)&&h.pattern===c.path),u=(s==null?void 0:s.parser(o))||{},l=new URLSearchParams(window.location.search),f=Object.fromEntries(l.entries())||{};x.page.update(h=>(h.url=i,h.pathname=window.location.pathname,h.params=u,h.query=f,h));const v={...u,...f},p=R.get(N)[s==null?void 0:s.pattern];console.log("[EVENTS] Popstate navigation to",i),G(i,e,c,v,u,f,p,!1)}else console.log("No matching route found for popstate navigation to:",o,"- using fallback navigation"),window.location.href=o}),window.addEventListener("forge-redirect",(n=>{const o=n.detail.path,i=o.split("?")[0];console.log("[EVENTS] Handling forge-redirect to:",o);const a="get",c=r.find(s=>s.method.toLowerCase()===a&&t.find(u=>u.parser(i)&&u.pattern===s.path));if(c){const s=t.find(h=>h.parser(i)&&h.pattern===c.path),u=(s==null?void 0:s.parser(i))||{},l=new URLSearchParams(o.split("?")[1]||""),f=Object.fromEntries(l.entries())||{},v={...u,...f},p=R.get(N)[s==null?void 0:s.pattern];x.page.update(h=>(h.url=o,h.pathname=i,h.params=u,h.query=f,h)),G(o,e,c,v,u,f,p,!0)}else console.log("No matching route found for redirect to:",i,"- using fallback navigation"),window.location.href=i})),Lt(r,t)}const X=Symbol("forge-load-function");let H=[],ee=null;function Wt(e){try{const r=new URL(e,window.location.origin);return r.origin===window.location.origin&&!r.pathname.startsWith("/api/")}catch{return!e.startsWith("/api/")}}function Dt(){typeof window<"u"&&!ee&&(ee=window.fetch,window.fetch=async function(e,r={}){let t={...r};for(const i of H)try{if(i.length===2){const a=new Headers(t.headers),c=Object.fromEntries(a.entries());await new Promise((s,u)=>{try{i(c,l=>{if(l)u(l);else{const f=new Headers;Object.entries(c).forEach(([v,d])=>{d!==void 0&&f.set(v,d)}),t.headers=f,s()}})}catch(l){u(l)}})}else{const a=await i(t,e);a&&typeof a=="object"&&(t=a)}}catch(a){throw console.error("🔴 Middleware error:",a),a}const n=t==null?void 0:t[X];console.log("[FETCH OVERRIDE] Request",{url:e,hasForgeSymbol:n,headers:t==null?void 0:t.headers});const o=await ee(e,t);if(console.log("[FETCH OVERRIDE] Response",{url:e,responseUrl:o.url,redirected:o.redirected,status:o.status,type:o.type,hasForgeSymbol:n}),n&&o.redirected){const i=typeof e=="string"?e:e.url,a=o.url;if(console.log("[FORGE REDIRECT] Detected redirect",{requested:i,final:a,redirected:o.redirected}),Wt(a)){const c=new URL(a),s=c.pathname+c.search;return console.log("[FORGE REDIRECT] Detected redirect to:",s,"- will navigate after current request completes"),new Response(JSON.stringify({layout:[],view:{}}),{status:200,headers:{"Content-Type":"application/json","X-Forge-Redirect":"true","X-Forge-Redirect-Path":s}})}}return o})}Dt();const zt={configUpdate(e){if(typeof e!="function")throw new Error("Middleware must be a function");H.push(e)},reset(){H.length=0},getMiddlewareCount(){return H.length}};let te;async function Gt(e,r){let t=window.__COMPONENT_DIR__||r.component_dir;if(!t&&typeof t!="string")throw new Error("No component directory provided");let n=window.__ROUTING__;if(te=De(n),window&&window.location){const o=(window.location.pathname||"/").split("?")[0],i=te.find(c=>c.parser(o));let a=i?n.find(c=>c.path===i.pattern):null;if(i&&a){const c=i.parser(o)||{},s=new URLSearchParams(window.location.search),u=Object.fromEntries(s.entries())||{},l={...c,...u};Me(),Ve(e,t,a,l,c,u),Fe(t,n,te)}else console.warn("No matching route found for:",o)}}exports.page=x.page;exports.shadowUrl=x.shadowUrl;exports.MANIFEST_STORE=N;exports.bootstrap_events=Fe;exports.createApp=Gt;exports.fetch=zt;exports.loadRoute=Ve;exports.updateManifestStore=Me;exports.updateRoute=G;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("./page.svelte-CW8PJDdH.cjs");require("svelte/internal/client");const Ke=require("svelte"),Je=require("../src/components/RecursiveRender.svelte"),C=require("svelte/store");function Xe(e){const t=new R.path_to_regex(e);return r=>{const n=t.match(r);if(!n)return null;const o={};for(const[i,a]of Object.entries(n))o[i]=decodeURIComponent(a);return o}}function Ze(e){return e.map(t=>{const r=t.path,n=Xe(r);return{pattern:r,parser:n}})}var se=function(e,t){return se=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=n[o])},se(e,t)};function W(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");se(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Qe(e,t,r,n){function o(i){return i instanceof r?i:new r(function(a){a(i)})}return new(r||(r=Promise))(function(i,a){function c(l){try{u(n.next(l))}catch(f){a(f)}}function s(l){try{u(n.throw(l))}catch(f){a(f)}}function u(l){l.done?i(l.value):o(l.value).then(c,s)}u((n=n.apply(e,t||[])).next())})}function xe(e,t){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(u){return function(l){return s([u,l])}}function s(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(r=0)),r;)try{if(n=1,o&&(i=u[0]&2?o.return:u[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,u[1])).done)return i;switch(o=0,i&&(u=[u[0]&2,i.value]),u[0]){case 0:case 1:i=u;break;case 4:return r.label++,{value:u[1],done:!1};case 5:r.label++,o=u[1],u=[0];continue;case 7:u=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){r.label=u[1];break}if(u[0]===6&&r.label<i[1]){r.label=i[1],i=u;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(u);break}i[2]&&r.ops.pop(),r.trys.pop();continue}u=t.call(e,r)}catch(l){u=[6,l],o=0}finally{n=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function $(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function M(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),o,i=[],a;try{for(;(t===void 0||t-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(c){a={error:c}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return i}function G(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,i;n<o;n++)(i||!(n in t))&&(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))}function F(e){return this instanceof F?(this.v=e,this):new F(e)}function et(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",a),o[Symbol.asyncIterator]=function(){return this},o;function a(d){return function(p){return Promise.resolve(p).then(d,f)}}function c(d,p){n[d]&&(o[d]=function(h){return new Promise(function(S,g){i.push([d,h,S,g])>1||s(d,h)})},p&&(o[d]=p(o[d])))}function s(d,p){try{u(n[d](p))}catch(h){v(i[0][3],h)}}function u(d){d.value instanceof F?Promise.resolve(d.value.v).then(l,f):v(i[0][2],d)}function l(d){s("next",d)}function f(d){s("throw",d)}function v(d,p){d(p),i.shift(),i.length&&s(i[0][0],i[0][1])}}function tt(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof $=="function"?$(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(i){r[i]=e[i]&&function(a){return new Promise(function(c,s){a=e[i](a),o(c,s,a.done,a.value)})}}function o(i,a,c,s){Promise.resolve(s).then(function(u){i({value:u,done:c})},a)}}function w(e){return typeof e=="function"}function de(e){var t=function(n){Error.call(n),n.stack=new Error().stack},r=e(t);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var te=de(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription:
2
+ `+r.map(function(n,o){return o+1+") "+n.toString()}).join(`
3
+ `):"",this.name="UnsubscriptionError",this.errors=r}});function ue(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var Z=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,n,o,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var c=$(a),s=c.next();!s.done;s=c.next()){var u=s.value;u.remove(this)}}catch(h){t={error:h}}finally{try{s&&!s.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}else a.remove(this);var l=this.initialTeardown;if(w(l))try{l()}catch(h){i=h instanceof te?h.errors:[h]}var f=this._finalizers;if(f){this._finalizers=null;try{for(var v=$(f),d=v.next();!d.done;d=v.next()){var p=d.value;try{we(p)}catch(h){i=i??[],h instanceof te?i=G(G([],M(i)),M(h.errors)):i.push(h)}}}catch(h){n={error:h}}finally{try{d&&!d.done&&(o=v.return)&&o.call(v)}finally{if(n)throw n.error}}}if(i)throw new te(i)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)we(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&ue(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&ue(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),Ae=Z.EMPTY;function Pe(e){return e instanceof Z||e&&"closed"in e&&w(e.remove)&&w(e.add)&&w(e.unsubscribe)}function we(e){w(e)?e():e.unsubscribe()}var rt={Promise:void 0},nt={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,G([e,t],M(r)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function Te(e){nt.setTimeout(function(){throw e})}function ge(){}function H(e){e()}var he=(function(e){W(t,e);function t(r){var n=e.call(this)||this;return n.isStopped=!1,r?(n.destination=r,Pe(r)&&r.add(n)):n.destination=at,n}return t.create=function(r,n,o){return new D(r,n,o)},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(Z),ot=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var r=this.partialObserver;if(r.next)try{r.next(t)}catch(n){Y(n)}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t)}catch(n){Y(n)}else Y(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(r){Y(r)}},e})(),D=(function(e){W(t,e);function t(r,n,o){var i=e.call(this)||this,a;return w(r)||!r?a={next:r??void 0,error:n??void 0,complete:o??void 0}:a=r,i.destination=new ot(a),i}return t})(he);function Y(e){Te(e)}function it(e){throw e}var at={closed:!0,next:ge,error:it,complete:ge},pe=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function ve(e){return e}function st(e){return e.length===0?ve:e.length===1?e[0]:function(r){return e.reduce(function(n,o){return o(n)},r)}}var E=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(t,r,n){var o=this,i=ct(t)?t:new D(t,r,n);return H(function(){var a=o,c=a.operator,s=a.source;i.add(c?c.call(i,s):s?o._subscribe(i):o._trySubscribe(i))}),i},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(r){t.error(r)}},e.prototype.forEach=function(t,r){var n=this;return r=Se(r),new r(function(o,i){var a=new D({next:function(c){try{t(c)}catch(s){i(s),a.unsubscribe()}},error:i,complete:o});n.subscribe(a)})},e.prototype._subscribe=function(t){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(t)},e.prototype[pe]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return st(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=Se(t),new t(function(n,o){var i;r.subscribe(function(a){return i=a},function(a){return o(a)},function(){return n(i)})})},e.create=function(t){return new e(t)},e})();function Se(e){var t;return(t=e??rt.Promise)!==null&&t!==void 0?t:Promise}function ut(e){return e&&w(e.next)&&w(e.error)&&w(e.complete)}function ct(e){return e&&e instanceof he||ut(e)&&Pe(e)}function lt(e){return w(e==null?void 0:e.lift)}function P(e){return function(t){if(lt(t))return t.lift(function(r){try{return e(r,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function A(e,t,r,n,o){return new ft(e,t,r,n,o)}var ft=(function(e){W(t,e);function t(r,n,o,i,a,c){var s=e.call(this,r)||this;return s.onFinalize=a,s.shouldUnsubscribe=c,s._next=n?function(u){try{n(u)}catch(l){r.error(l)}}:e.prototype._next,s._error=i?function(u){try{i(u)}catch(l){r.error(l)}finally{this.unsubscribe()}}:e.prototype._error,s._complete=o?function(){try{o()}catch(u){r.error(u)}finally{this.unsubscribe()}}:e.prototype._complete,s}return t.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((r=this.onFinalize)===null||r===void 0||r.call(this))}},t})(he),dt=de(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Q=(function(e){W(t,e);function t(){var r=e.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return t.prototype.lift=function(r){var n=new _e(this,this);return n.operator=r,n},t.prototype._throwIfClosed=function(){if(this.closed)throw new dt},t.prototype.next=function(r){var n=this;H(function(){var o,i;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var a=$(n.currentObservers),c=a.next();!c.done;c=a.next()){var s=c.value;s.next(r)}}catch(u){o={error:u}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}}})},t.prototype.error=function(r){var n=this;H(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var o=n.observers;o.length;)o.shift().error(r)}})},t.prototype.complete=function(){var r=this;H(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var n=this,o=this,i=o.hasError,a=o.isStopped,c=o.observers;return i||a?Ae:(this.currentObservers=null,c.push(r),new Z(function(){n.currentObservers=null,ue(c,r)}))},t.prototype._checkFinalizedStatuses=function(r){var n=this,o=n.hasError,i=n.thrownError,a=n.isStopped;o?r.error(i):a&&r.complete()},t.prototype.asObservable=function(){var r=new E;return r.source=this,r},t.create=function(r,n){return new _e(r,n)},t})(E),_e=(function(e){W(t,e);function t(r,n){var o=e.call(this)||this;return o.destination=r,o.source=n,o}return t.prototype.next=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,r)},t.prototype.error=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,r)},t.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},t.prototype._subscribe=function(r){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&o!==void 0?o:Ae},t})(Q),Ie={now:function(){return(Ie.delegate||Date).now()},delegate:void 0},ht=(function(e){W(t,e);function t(r,n,o){r===void 0&&(r=1/0),n===void 0&&(n=1/0),o===void 0&&(o=Ie);var i=e.call(this)||this;return i._bufferSize=r,i._windowTime=n,i._timestampProvider=o,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,r),i._windowTime=Math.max(1,n),i}return t.prototype.next=function(r){var n=this,o=n.isStopped,i=n._buffer,a=n._infiniteTimeWindow,c=n._timestampProvider,s=n._windowTime;o||(i.push(r),!a&&i.push(c.now()+s)),this._trimBuffer(),e.prototype.next.call(this,r)},t.prototype._subscribe=function(r){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(r),o=this,i=o._infiniteTimeWindow,a=o._buffer,c=a.slice(),s=0;s<c.length&&!r.closed;s+=i?1:2)r.next(c[s]);return this._checkFinalizedStatuses(r),n},t.prototype._trimBuffer=function(){var r=this,n=r._bufferSize,o=r._timestampProvider,i=r._buffer,a=r._infiniteTimeWindow,c=(a?1:2)*n;if(n<1/0&&c<i.length&&i.splice(0,i.length-c),!a){for(var s=o.now(),u=0,l=1;l<i.length&&i[l]<=s;l+=2)u=l;u&&i.splice(0,u+1)}},t})(Q),me=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function Re(e){return w(e==null?void 0:e.then)}function Ce(e){return w(e[pe])}function je(e){return Symbol.asyncIterator&&w(e==null?void 0:e[Symbol.asyncIterator])}function Le(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function pt(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ne=pt();function Ue(e){return w(e==null?void 0:e[Ne])}function Fe(e){return et(this,arguments,function(){var r,n,o,i;return xe(this,function(a){switch(a.label){case 0:r=e.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,F(r.read())];case 3:return n=a.sent(),o=n.value,i=n.done,i?[4,F(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,F(o)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function ke(e){return w(e==null?void 0:e.getReader)}function T(e){if(e instanceof E)return e;if(e!=null){if(Ce(e))return vt(e);if(me(e))return mt(e);if(Re(e))return yt(e);if(je(e))return $e(e);if(Ue(e))return bt(e);if(ke(e))return wt(e)}throw Le(e)}function vt(e){return new E(function(t){var r=e[pe]();if(w(r.subscribe))return r.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function mt(e){return new E(function(t){for(var r=0;r<e.length&&!t.closed;r++)t.next(e[r]);t.complete()})}function yt(e){return new E(function(t){e.then(function(r){t.closed||(t.next(r),t.complete())},function(r){return t.error(r)}).then(null,Te)})}function bt(e){return new E(function(t){var r,n;try{for(var o=$(e),i=o.next();!i.done;i=o.next()){var a=i.value;if(t.next(a),t.closed)return}}catch(c){r={error:c}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}t.complete()})}function $e(e){return new E(function(t){gt(e,t).catch(function(r){return t.error(r)})})}function wt(e){return $e(Fe(e))}function gt(e,t){var r,n,o,i;return Qe(this,void 0,void 0,function(){var a,c;return xe(this,function(s){switch(s.label){case 0:s.trys.push([0,5,6,11]),r=tt(e),s.label=1;case 1:return[4,r.next()];case 2:if(n=s.sent(),!!n.done)return[3,4];if(a=n.value,t.next(a),t.closed)return[2];s.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=s.sent(),o={error:c},[3,11];case 6:return s.trys.push([6,,9,10]),n&&!n.done&&(i=r.return)?[4,i.call(r)]:[3,8];case 7:s.sent(),s.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function N(e,t,r,n,o){n===void 0&&(n=0),o===void 0&&(o=!1);var i=t.schedule(function(){r(),o?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(i),!o)return i}function Me(e,t){return t===void 0&&(t=0),P(function(r,n){r.subscribe(A(n,function(o){return N(n,e,function(){return n.next(o)},t)},function(){return N(n,e,function(){return n.complete()},t)},function(o){return N(n,e,function(){return n.error(o)},t)}))})}function De(e,t){return t===void 0&&(t=0),P(function(r,n){n.add(e.schedule(function(){return r.subscribe(n)},t))})}function St(e,t){return T(e).pipe(De(t),Me(t))}function _t(e,t){return T(e).pipe(De(t),Me(t))}function Et(e,t){return new E(function(r){var n=0;return t.schedule(function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())})})}function Ot(e,t){return new E(function(r){var n;return N(r,t,function(){n=e[Ne](),N(r,t,function(){var o,i,a;try{o=n.next(),i=o.value,a=o.done}catch(c){r.error(c);return}a?r.complete():r.next(i)},0,!0)}),function(){return w(n==null?void 0:n.return)&&n.return()}})}function We(e,t){if(!e)throw new Error("Iterable cannot be null");return new E(function(r){N(r,t,function(){var n=e[Symbol.asyncIterator]();N(r,t,function(){n.next().then(function(o){o.done?r.complete():r.next(o.value)})},0,!0)})})}function xt(e,t){return We(Fe(e),t)}function At(e,t){if(e!=null){if(Ce(e))return St(e,t);if(me(e))return Et(e,t);if(Re(e))return _t(e,t);if(je(e))return We(e,t);if(Ue(e))return Ot(e,t);if(ke(e))return xt(e,t)}throw Le(e)}function qe(e,t){return t?At(e,t):T(e)}var Pt=de(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Tt(e,t){return new Promise(function(r,n){var o=new D({next:function(i){r(i),o.unsubscribe()},error:n,complete:function(){n(new Pt)}});e.subscribe(o)})}function ye(e,t){return P(function(r,n){var o=0;r.subscribe(A(n,function(i){n.next(e.call(t,i,o++))}))})}var It=Array.isArray;function Rt(e,t){return It(t)?e.apply(void 0,G([],M(t))):e(t)}function Ct(e){return ye(function(t){return Rt(e,t)})}function jt(e,t,r,n,o,i,a,c){var s=[],u=0,l=0,f=!1,v=function(){f&&!s.length&&!u&&t.complete()},d=function(h){return u<n?p(h):s.push(h)},p=function(h){u++;var S=!1;T(r(h,l++)).subscribe(A(t,function(g){t.next(g)},function(){S=!0},void 0,function(){if(S)try{u--;for(var g=function(){var m=s.shift();a||p(m)};s.length&&u<n;)g();v()}catch(m){t.error(m)}}))};return e.subscribe(A(t,d,function(){f=!0,v()})),function(){}}function Ge(e,t,r){return r===void 0&&(r=1/0),w(t)?Ge(function(n,o){return ye(function(i,a){return t(n,i,o,a)})(T(e(n,o)))},r):(typeof t=="number"&&(r=t),P(function(n,o){return jt(n,o,e,r)}))}var Lt=["addListener","removeListener"],Nt=["addEventListener","removeEventListener"],Ut=["on","off"];function ce(e,t,r,n){if(w(r)&&(n=r,r=void 0),n)return ce(e,t,r).pipe(Ct(n));var o=M($t(e)?Nt.map(function(c){return function(s){return e[c](t,s,r)}}):Ft(e)?Lt.map(Ee(e,t)):kt(e)?Ut.map(Ee(e,t)):[],2),i=o[0],a=o[1];if(!i&&me(e))return Ge(function(c){return ce(c,t,r)})(T(e));if(!i)throw new TypeError("Invalid event target");return new E(function(c){var s=function(){for(var u=[],l=0;l<arguments.length;l++)u[l]=arguments[l];return c.next(1<u.length?u:u[0])};return i(s),function(){return a(s)}})}function Ee(e,t){return function(r){return function(n){return e[r](t,n)}}}function Ft(e){return w(e.addListener)&&w(e.removeListener)}function kt(e){return w(e.on)&&w(e.off)}function $t(e){return w(e.addEventListener)&&w(e.removeEventListener)}function re(e,t){return P(function(r,n){var o=0;r.subscribe(A(n,function(i){return e.call(t,i,o++)&&n.next(i)}))})}function Mt(e,t){return t===void 0&&(t=ve),e=e??Dt,P(function(r,n){var o,i=!0;r.subscribe(A(n,function(a){var c=t(a);(i||!e(o,c))&&(i=!1,o=c,n.next(a))}))})}function Dt(e,t){return e===t}function Wt(e){e===void 0&&(e={});var t=e.connector,r=t===void 0?function(){return new Q}:t,n=e.resetOnError,o=n===void 0?!0:n,i=e.resetOnComplete,a=i===void 0?!0:i,c=e.resetOnRefCountZero,s=c===void 0?!0:c;return function(u){var l,f,v,d=0,p=!1,h=!1,S=function(){f==null||f.unsubscribe(),f=void 0},g=function(){S(),l=v=void 0,p=h=!1},m=function(){var b=l;g(),b==null||b.unsubscribe()};return P(function(b,O){d++,!h&&!p&&S();var B=v=v??r();O.add(function(){d--,d===0&&!h&&!p&&(f=ne(m,s))}),B.subscribe(O),!l&&d>0&&(l=new D({next:function(z){return B.next(z)},error:function(z){h=!0,S(),f=ne(g,o,z),B.error(z)},complete:function(){p=!0,S(),f=ne(g,a),B.complete()}}),T(b).subscribe(l))})(u)}}function ne(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];if(t===!0){e();return}if(t!==!1){var o=new D({next:function(){o.unsubscribe(),e()}});return T(t.apply(void 0,G([],M(r)))).subscribe(o)}}function Be(e,t){return P(function(r,n){var o=null,i=0,a=!1,c=function(){return a&&!o&&n.complete()};r.subscribe(A(n,function(s){o==null||o.unsubscribe();var u=0,l=i++;T(e(s,l)).subscribe(o=A(n,function(f){return n.next(t?t(s,f,l,u++):f)},function(){o=null,c()}))},function(){a=!0,c()}))})}function qt(e,t,r){var n=w(e)||t||r?{next:e,error:t,complete:r}:e;return n?P(function(o,i){var a;(a=n.subscribe)===null||a===void 0||a.call(n);var c=!0;o.subscribe(A(i,function(s){var u;(u=n.next)===null||u===void 0||u.call(n,s),i.next(s)},function(){var s;c=!1,(s=n.complete)===null||s===void 0||s.call(n),i.complete()},function(s){var u;c=!1,(u=n.error)===null||u===void 0||u.call(n,s),i.error(s)},function(){var s,u;c&&((s=n.unsubscribe)===null||s===void 0||s.call(n)),(u=n.finalize)===null||u===void 0||u.call(n)}))}):ve}const k=C.writable({});async function ze(){k.update(e=>(Object.assign(e,window.__MANIFEST__),e))}const I=new Map,V=5e3;function Gt(e){const t=I.get(e);return t?(I.delete(e),Date.now()-t.createdAt>V?(t.abortController.abort(),null):t.response$):null}function Bt(e,t){ce(document,"mouseover").pipe(Wt()).pipe(ye(o=>{const i=o.target,a=(i==null?void 0:i.tagName)==="A"?i:i==null?void 0:i.closest("A");if(!a)return null;const c=a.getAttribute("href");return!c||!c.startsWith("/")&&!c.startsWith(".")?null:c}),re(o=>o!==null),re(o=>o!==window.location.pathname),Mt(),re(o=>{const i=o.split("?")[0],a="get",c=e.find(l=>l.method.toLowerCase()===a&&t.find(f=>f.parser(i)&&f.pattern===l.path));if(!c)return!1;const s=t.find(l=>l.parser(i)&&l.pattern===c.path);return!!C.get(k)[s==null?void 0:s.pattern]}),Be(o=>{const i=I.get(o);if(i&&Date.now()-i.createdAt<V)return[];const a=new AbortController,c=new ht(1),s={response$:c,createdAt:Date.now(),abortController:a};I.set(o,s);const u={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:a.signal};return u[ee]=!0,qe(fetch(o,u).then(l=>(c.next(l),c.complete(),o),l=>(c.error(l),I.delete(o),null))).pipe(qt({unsubscribe:()=>{a.abort(),I.delete(o)}}))})).subscribe(),setInterval(()=>{const o=Date.now();for(const[i,a]of I)o-a.createdAt>V&&(a.abortController.abort(),I.delete(i))},V)}var L=(e=>(e[e.TRACE=0]="TRACE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.FATAL=5]="FATAL",e))(L||{});const zt={trace:0,debug:1,info:2,warn:3,error:4,fatal:5};function Yt(e){if(!e)return 2;const t=e.trim().toLowerCase(),r=zt[t];if(typeof r=="number")return r;const n=Number(t);return Number.isFinite(n)&&n>=0&&n<=5?n:2}function Ye(e){switch(e){case 0:return"TRACE";case 1:return"DEBUG";case 2:return"INFO";case 3:return"WARN";case 4:return"ERROR";case 5:return"FATAL";default:return"INFO"}}function Oe(e){if(e===void 0)return"undefined";if(e===null)return null;if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};switch(typeof e){case"string":case"number":case"boolean":return e;case"bigint":return e.toString();case"symbol":return String(e);case"function":return`[Function${e.name?`: ${e.name}`:""}]`;default:return e}}class Ht{constructor(t,r,n){this.name=t,this.manager=r,this.contextData=n}named(t){return new le(t,this.manager,this.contextData)}withContext(t){const r=this.contextData?{...this.contextData,...t}:t;return new le(this.name,this.manager,r)}trace(t,...r){this.log(L.TRACE,t,r)}debug(t,...r){this.log(L.DEBUG,t,r)}info(t,...r){this.log(L.INFO,t,r)}warn(t,...r){this.log(L.WARN,t,r)}error(t,...r){this.log(L.ERROR,t,r)}fatal(t,...r){this.log(L.FATAL,t,r)}log(t,r,n){if(!this.manager.shouldLog(t,this.name))return;const o=new Date().toISOString();let i=n.length>0?n.length===1?Oe(n[0]):n.map(Oe):void 0,a;this.contextData&&i!==void 0?a={...this.contextData,args:i}:this.contextData?a=this.contextData:a=i,this.manager.log({timestamp:o,level:Ye(t),logger:this.name,message:r,context:a})}}class le extends Ht{constructor(t,r,n){super(t,r,n)}}class Vt{log(t){const r=t.context!==void 0?` ${JSON.stringify(t.context)}`:"",n=`[${t.timestamp}] [${t.logger}] [${t.level}] ${t.message}${r}`;switch(t.level){case"ERROR":case"FATAL":console.error(n);break;case"WARN":console.warn(n);break;default:console.log(n);break}}}const oe=Symbol.for("@noego/logger");class Kt{constructor(){var o,i,a;this.transports=[],this.loggerLevels=new Map;const t=typeof process<"u"?(o=process.env)==null?void 0:o.LOG_LEVEL:void 0,r=typeof process<"u"?(i=process.env)==null?void 0:i.SERVICE_NAME:void 0,n=typeof process<"u"?(a=process.env)==null?void 0:a.NODE_ENV:void 0;this.level=Yt(t),this.service=r??"noego",this.environment=n??"development"}getLevel(){return this.level}setLevel(t){this.level=t}setLoggerLevel(t,r){this.loggerLevels.set(t,r)}shouldLog(t,r){if(r){const n=this.loggerLevels.get(r);if(n!==void 0)return t>=n}return t>=this.level}addTransport(t){this.transports.push(t)}setTransports(t){this.transports=[...t]}clearTransports(){this.transports=[]}setServiceName(t){this.service=t}log(t){const r={...t,environment:this.environment,service:this.service};for(const n of this.transports)n.log(r)}async closeAll(){for(const t of this.transports)t.close&&await t.close()}formatMessage(t,r,n){return`[${new Date().toISOString()}] [${r}] [${Ye(t)}] ${n}`}}function Jt(){const e=globalThis;if(!e[oe]){const t=new Kt;t.addTransport(new Vt),e[oe]=t}return e[oe]}function be(e){return new le(e,Jt())}const y=be("forge:nav"),Xt=1e4;function Zt(e,t,r){let n=null,o=!1;const i=new Promise((a,c)=>{n=setTimeout(()=>{o=!0,y.error("Timeout fired after",t,"ms"),r(),c(new Error(`Navigation timed out after ${t}ms`))},t),y.debug("Timeout scheduled for",t,"ms, timeoutId:",n)});return Promise.race([e.finally(()=>{n!==null&&(o?y.warn("Promise settled AFTER timeout already fired"):(y.debug("Clearing timeout",n,"- promise settled successfully"),clearTimeout(n)))}),i])}const fe=new Q;let _=0,q=null;function Qt(e){e&&e.redirectPath&&(y.debug("Handling redirect to",e.redirectPath),setTimeout(()=>{window.dispatchEvent(new CustomEvent("forge-redirect",{detail:{path:e.redirectPath}}))},0))}fe.pipe(Be(e=>qe(Zt(rr(e),Xt,()=>{y.error("Navigation timed out"),_++,q&&(q.abort(),q=null)}).catch(t=>{y.error("Navigation failed:",t)})))).subscribe({next:Qt,error:e=>{y.error("Stream error:",e)}});function er(e){var t;y.debug("Pushing navigation event to stream",{url:e.url,currentNavigationId:_,subscriberCount:((t=fe.observers)==null?void 0:t.length)||0}),fe.next(e)}const x=C.writable({active:{layouts:[],view:null,viewPath:null,layoutPaths:[],data:{layout:[],view:{}},params:{},urlParams:{},query:{}},phase:"idle",navigationId:0,page:R.page}),tr=async()=>{const e=C.get(x).navigationId;try{const t=window.location.pathname+window.location.search,r={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"}};r[ee]=!0;const n=await fetch(t,r);if(!n.ok)return!1;const o=await n.json(),i=C.get(x).navigationId;return e!==i?(y.debug("Discarding stale poll response",{pollNavigationId:e,currentNavigationId:i}),!1):(x.update(a=>{var c;return a.active.data={layout:((c=a.active.data)==null?void 0:c.layout)||[],view:o.view},a}),!0)}catch{return!1}};R.page.update(e=>(e.poll=tr,e));function X(...e){let t=e.map((r,n)=>n===0?r.replace(/\/+$/,""):r.replace(/^\/+|\/+$/g,"")).join("/");return t.startsWith("/")||(t="/"+t),t.split("?")[0]}async function He(e,t,r,n,o,i){try{const a=typeof t=="string"&&t.indexOf("assets")!==-1,c=(r.layout||[]).map(d=>{let p=X(t,d).toString();return a&&(p=p.endsWith(".svelte")?p.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(p)?p:p+".js"),p});let s=X(t,r.view).toString();a&&(s=s.endsWith(".svelte")?s.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(s)?s:s+".js");const u=await Promise.all(c.map(d=>import(d).then(p=>p.default)));s.startsWith("/")||(s="/"+s);const l=await import(s).then(d=>d.default),f=window.__INITIAL_DATA__||{layout:[],view:{}},v={layouts:u,view:l,viewPath:r.view||null,layoutPaths:r.layout||[],data:f,params:n,urlParams:o,query:i};x.update(d=>(d.active=v,d.phase="idle",d)),Ke.hydrate(Je,{target:e,props:{root:x}})}catch(a){y.error("Client-side route loading failed:",a)}}function K(e,t,r,n,o,i,a=!1,c=!0){er({url:e,base_path:t,route:r,params:n,urlParams:o,query:i,server_loading:a,updateUrl:c})}async function rr(e){const{url:t,base_path:r,route:n,params:o,urlParams:i,query:a,server_loading:c,updateUrl:s}=e,u=++_,l=new AbortController;q=l,y.debug("Starting navigation",{navigationId:u,url:t,updateUrl:s,server_loading:c,currentNavigationId:_,hasAbortController:!!q}),x.update(f=>(f.phase="loading",f.navigationId=u,f));try{let f={layout:[],view:{}};if(c){y.debug("Fetching server data",{navigationId:u,url:t});let m=null;const b=Gt(t);if(b)try{y.debug("Using prefetched response for",t),m=await Tt(b)}catch{y.debug("Prefetch failed, falling back to fetch",t),m=null}if(!m){const O={method:n.method,headers:{"Content-Type":"application/json",Accept:"application/json"},signal:l.signal};O[ee]=!0,m=await fetch(t,O)}if(y.debug("Fetch response received",{navigationId:u,url:t,ok:m.ok,status:m.status,redirected:m.redirected,currentNavigationId:_}),m.redirected||m.headers.get("X-Forge-Redirect")==="true")return y.debug("Redirect detected"),x.update(O=>(O.phase="idle",O)),{redirectPath:m.headers.get("X-Forge-Redirect-Path")||void 0};if(!m.ok)throw new Error(`Network response was not ok: ${m.status}`);f=await m.json(),y.debug("Server data received:",f)}if(u!==_){y.debug("Stale navigation after fetch, aborting",{navigationId:u,currentNavigationId:_});return}y.debug("Loading components",{navigationId:u,view:n.view,layouts:n.layout});const v=typeof r=="string"&&r.indexOf("assets")!==-1,d=(n.layout||[]).map(m=>{let b=X(r,m).toString();return v&&(b=b.endsWith(".svelte")?b.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(b)?b:b+".js"),b});let p=X(r,n.view).toString();v&&(p=p.endsWith(".svelte")?p.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(p)?p:p+".js"),p.startsWith("/")||(p="/"+p);const h=await Promise.all(d.map(m=>import(m).then(b=>b.default))),S=await import(p).then(m=>m.default);if(y.debug("Components loaded",{navigationId:u,currentNavigationId:_,layoutsCount:h.length,viewLoaded:!!S}),u!==_){y.debug("Stale navigation after component load, aborting",{navigationId:u,currentNavigationId:_});return}const g={layouts:h,view:S,viewPath:n.view||null,layoutPaths:n.layout||[],data:f,params:o,urlParams:i,query:a};y.debug("Committing new state",{navigationId:u,currentNavigationId:_,layoutsCount:g.layouts.length,viewSet:!!g.view,dataKeys:Object.keys(g.data||{})}),x.update(m=>(m.active=g,m.phase="idle",y.debug("ROOT.active updated",{navigationId:u,layoutsCount:m.active.layouts.length,viewSet:!!m.active.view,dataKeys:Object.keys(m.active.data||{}),paramsKeys:Object.keys(m.active.params||{})}),m)),typeof window<"u"&&window.scroll(0,0),s&&(y.debug("Updating browser URL",{url:t}),window.history.pushState({},"",t)),y.debug("Navigation complete",{navigationId:u,url:t})}catch(f){if(y.error("Navigation failed",{navigationId:u,currentNavigationId:_,url:t,error:f instanceof Error?f.message:String(f)}),x.update(v=>(v.phase="idle",v)),f.name==="AbortError"){y.debug("Navigation aborted");return}throw f}}const j=be("forge:events");function Ve(e,t,r){if(!document){j.error("Document not found");return}document.addEventListener("click",n=>{var a,c;const o=window.location.pathname,i=((a=n.target)==null?void 0:a.tagName)==="A"?n.target:(c=n.target)==null?void 0:c.closest("A");if(i){let s=i.getAttribute("href");if(o===s){n.preventDefault();return}if(s&&s.startsWith("/")||s.startsWith(".")){const u=s.split("?")[0],l=i.getAttribute("method")||"get",f=t.find(v=>v.method.toLowerCase()===l&&r.find(d=>d.parser(u)&&d.pattern===v.path));if(f){n.preventDefault();const v=r.find(b=>b.parser(u)&&b.pattern===f.path),d=(v==null?void 0:v.parser(u))||{},p=new URLSearchParams(s.split("?")[1]||""),h=Object.fromEntries(p.entries())||{},S={...d,...h},m=C.get(k)[v==null?void 0:v.pattern];R.page.update(b=>(b.url=s,b.pathname=u,b.params=d,b.query=h,b)),j.debug("Click navigation to",s),K(s,e,f,S,d,h,m,!0)}else j.warn("No matching route found",s,"- using fallback navigation")}}}),window.addEventListener("popstate",n=>{const o=window.location.pathname,i=window.location.pathname+window.location.search,a="get",c=t.find(s=>s.method.toLowerCase()===a&&r.find(u=>u.parser(o)&&u.pattern===s.path));if(c){const s=r.find(h=>h.parser(o)&&h.pattern===c.path),u=(s==null?void 0:s.parser(o))||{},l=new URLSearchParams(window.location.search),f=Object.fromEntries(l.entries())||{};R.page.update(h=>(h.url=i,h.pathname=window.location.pathname,h.params=u,h.query=f,h));const v={...u,...f},p=C.get(k)[s==null?void 0:s.pattern];j.debug("Popstate navigation to",i),K(i,e,c,v,u,f,p,!1)}else j.warn("No matching route found",o,"- using fallback navigation"),window.location.href=o}),window.addEventListener("forge-redirect",(n=>{const o=n.detail.path,i=o.split("?")[0];j.debug("Handling forge-redirect to:",o);const a="get",c=t.find(s=>s.method.toLowerCase()===a&&r.find(u=>u.parser(i)&&u.pattern===s.path));if(c){const s=r.find(h=>h.parser(i)&&h.pattern===c.path),u=(s==null?void 0:s.parser(i))||{},l=new URLSearchParams(o.split("?")[1]||""),f=Object.fromEntries(l.entries())||{},v={...u,...f},p=C.get(k)[s==null?void 0:s.pattern];R.page.update(h=>(h.url=o,h.pathname=i,h.params=u,h.query=f,h)),K(o,e,c,v,u,f,p,!0)}else j.warn("No matching route found",i,"- using fallback navigation"),window.location.href=i})),Bt(t,r)}const U=be("forge:client"),ee=Symbol("forge-load-function");let J=[],ie=null;function nr(e){try{const t=new URL(e,window.location.origin);return t.origin===window.location.origin&&!t.pathname.startsWith("/api/")}catch{return!e.startsWith("/api/")}}function or(){typeof window<"u"&&!ie&&(ie=window.fetch,window.fetch=async function(e,t={}){let r={...t};for(const i of J)try{if(i.length===2){const a=new Headers(r.headers),c=Object.fromEntries(a.entries());await new Promise((s,u)=>{try{i(c,l=>{if(l)u(l);else{const f=new Headers;Object.entries(c).forEach(([v,d])=>{d!==void 0&&f.set(v,d)}),r.headers=f,s()}})}catch(l){u(l)}})}else{const a=await i(r,e);a&&typeof a=="object"&&(r=a)}}catch(a){throw U.error("Middleware error",a),a}const n=r==null?void 0:r[ee];U.debug("Fetch override request",{url:e,hasForgeSymbol:n,headers:r==null?void 0:r.headers});const o=await ie(e,r);if(U.debug("Fetch override response",{url:e,responseUrl:o.url,redirected:o.redirected,status:o.status,type:o.type,hasForgeSymbol:n}),n&&o.redirected){const i=typeof e=="string"?e:e.url,a=o.url;if(U.debug("Redirect detected",{requested:i,final:a,redirected:o.redirected}),nr(a)){const c=new URL(a),s=c.pathname+c.search;return U.debug("Redirect detected to:",s,"- will navigate after current request completes"),new Response(JSON.stringify({layout:[],view:{}}),{status:200,headers:{"Content-Type":"application/json","X-Forge-Redirect":"true","X-Forge-Redirect-Path":s}})}}return o})}or();const ir={configUpdate(e){if(typeof e!="function")throw new Error("Middleware must be a function");J.push(e)},reset(){J.length=0},getMiddlewareCount(){return J.length}};let ae;async function ar(e,t){let r=window.__COMPONENT_DIR__||t.component_dir;if(!r&&typeof r!="string")throw new Error("No component directory provided");let n=window.__ROUTING__;if(ae=Ze(n),window&&window.location){const o=(window.location.pathname||"/").split("?")[0],i=ae.find(c=>c.parser(o));let a=i?n.find(c=>c.path===i.pattern):null;if(i&&a){const c=i.parser(o)||{},s=new URLSearchParams(window.location.search),u=Object.fromEntries(s.entries())||{},l={...c,...u};ze(),He(e,r,a,l,c,u),Ve(r,n,ae)}else U.warn("No matching route",o)}}exports.page=R.page;exports.shadowUrl=R.shadowUrl;exports.MANIFEST_STORE=k;exports.bootstrap_events=Ve;exports.createApp=ar;exports.fetch=ir;exports.loadRoute=He;exports.updateManifestStore=ze;exports.updateRoute=K;
4
4
  //# sourceMappingURL=client.cjs.map