@noego/forge 0.1.24 → 0.1.25

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