@noego/forge 0.1.25 → 0.1.27
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/README.md +2 -0
- package/dist/client.cjs +2 -2
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +25 -0
- package/dist/client.mjs +603 -583
- package/dist/client.mjs.map +1 -1
- package/dist/page.svelte-4uv4nQ2i.js.map +1 -1
- package/dist/page.svelte-CW8PJDdH.cjs.map +1 -1
- package/dist-ssr/{path-BqcF5dbs.js → path-2bYzpvRB.js} +3 -1
- package/dist-ssr/{path-BqcF5dbs.js.map → path-2bYzpvRB.js.map} +1 -1
- package/dist-ssr/{path-sxXxpB6R.cjs → path-DCxJMpj7.cjs} +3 -1
- package/dist-ssr/{path-sxXxpB6R.cjs.map → path-DCxJMpj7.cjs.map} +1 -1
- package/dist-ssr/server.cjs +4 -3
- package/dist-ssr/server.cjs.map +1 -1
- package/dist-ssr/server.js +4 -3
- package/dist-ssr/server.js.map +1 -1
- package/dist-ssr/shared.cjs +1 -1
- package/dist-ssr/shared.js +1 -1
- package/dist-ssr/static.cjs +1 -1
- package/dist-ssr/static.d.ts +1 -0
- package/dist-ssr/static.js +1 -1
- package/dist-ssr/test.d.ts +1 -0
- package/dist-ssr/{url_parser-BX00zzMP.js → url_parser-B6dvK0DX.js} +2 -2
- package/dist-ssr/{url_parser-BX00zzMP.js.map → url_parser-B6dvK0DX.js.map} +1 -1
- package/dist-ssr/{url_parser-Dipo_fiS.cjs → url_parser-D7ZqJUTw.cjs} +2 -2
- package/dist-ssr/{url_parser-Dipo_fiS.cjs.map → url_parser-D7ZqJUTw.cjs.map} +1 -1
- package/package.json +1 -1
- package/src/components/RecursiveRender.svelte +37 -16
package/README.md
CHANGED
|
@@ -246,6 +246,7 @@ Forge extends OpenAPI 3 with custom `x-*` vendor extensions to define your appli
|
|
|
246
246
|
|-----------|-------------|
|
|
247
247
|
| `x-view` | Path to the Svelte component that renders the page view |
|
|
248
248
|
| `x-layout` | Array of layout components (rendered outside-in) that wrap the view |
|
|
249
|
+
| `x-controller` | Path to a PageController class for client-side state/input/events (optional) |
|
|
249
250
|
| `x-fallback-view` | Component to render for 404 errors |
|
|
250
251
|
| `x-fallback-layout` | Default layout when none is specified |
|
|
251
252
|
| `x-middleware` | Array of middleware functions to run before rendering |
|
|
@@ -717,6 +718,7 @@ For deeper topics, check the documentation in [`/docs`](./docs):
|
|
|
717
718
|
| **state_sharing.md** | Reactive global state with Svelte 5 context and `$state` |
|
|
718
719
|
| **tailwind-layouts.md** | Design layouts with Tailwind CSS |
|
|
719
720
|
| **FETCH_MIDDLEWARE.md** | Client-side fetch middleware, authentication, security |
|
|
721
|
+
| **page_controllers.md** | Client-side PageController pattern (state, input, events) |
|
|
720
722
|
| **server_middleware.md** | Per-route server middleware and request context |
|
|
721
723
|
|
|
722
724
|
|
package/dist/client.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var nt=Object.defineProperty;var ot=(e,t,r)=>t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ie=(e,t,r)=>ot(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("./page.svelte-CW8PJDdH.cjs");require("svelte/internal/client");const it=require("svelte"),at=require("../src/components/RecursiveRender.svelte"),A=require("svelte/store");function st(e){const t=new I.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 ut(e){return e.map(t=>{const r=t.path,n=st(r);return{pattern:r,parser:n}})}var fe=function(e,t){return fe=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])},fe(e,t)};function V(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");fe(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function ct(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(p){a(p)}}function s(l){try{c(n.throw(l))}catch(p){a(p)}}function c(l){l.done?o(l.value):i(l.value).then(u,s)}c((n=n.apply(e,t||[])).next())})}function Ce(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 z(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 B(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 Y(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 W(e){return this instanceof W?(this.v=e,this):new W(e)}function lt(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(v){return Promise.resolve(v).then(d,p)}}function u(d,v){n[d]&&(i[d]=function(f){return new Promise(function(S,w){o.push([d,f,S,w])>1||s(d,f)})},v&&(i[d]=v(i[d])))}function s(d,v){try{c(n[d](v))}catch(f){h(o[0][3],f)}}function c(d){d.value instanceof W?Promise.resolve(d.value.v).then(l,p):h(o[0][2],d)}function l(d){s("next",d)}function p(d){s("throw",d)}function h(d,v){d(v),o.shift(),o.length&&s(o[0][0],o[0][1])}}function ft(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 z=="function"?z(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 b(e){return typeof e=="function"}function me(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 ae=me(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription:
|
|
2
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;
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=r}});function de(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var re=(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=z(a),s=u.next();!s.done;s=u.next()){var c=s.value;c.remove(this)}}catch(f){t={error:f}}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(b(l))try{l()}catch(f){o=f instanceof ae?f.errors:[f]}var p=this._finalizers;if(p){this._finalizers=null;try{for(var h=z(p),d=h.next();!d.done;d=h.next()){var v=d.value;try{Ee(v)}catch(f){o=o??[],f instanceof ae?o=Y(Y([],B(o)),B(f.errors)):o.push(f)}}}catch(f){n={error:f}}finally{try{d&&!d.done&&(i=h.return)&&i.call(h)}finally{if(n)throw n.error}}}if(o)throw new ae(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)Ee(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)&&de(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&de(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),je=re.EMPTY;function Le(e){return e instanceof re||e&&"closed"in e&&b(e.remove)&&b(e.add)&&b(e.unsubscribe)}function Ee(e){b(e)?e():e.unsubscribe()}var dt={Promise:void 0},ht={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,Y([e,t],B(r)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function Ne(e){ht.setTimeout(function(){throw e})}function Oe(){}function Z(e){e()}var ye=(function(e){V(t,e);function t(r){var n=e.call(this)||this;return n.isStopped=!1,r?(n.destination=r,Le(r)&&r.add(n)):n.destination=mt,n}return t.create=function(r,n,i){return new G(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})(re),pt=(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){K(n)}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t)}catch(n){K(n)}else K(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(r){K(r)}},e})(),G=(function(e){V(t,e);function t(r,n,i){var o=e.call(this)||this,a;return b(r)||!r?a={next:r??void 0,error:n??void 0,complete:i??void 0}:a=r,o.destination=new pt(a),o}return t})(ye);function K(e){Ne(e)}function vt(e){throw e}var mt={closed:!0,next:Oe,error:vt,complete:Oe},be=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function we(e){return e}function yt(e){return e.length===0?we:e.length===1?e[0]:function(r){return e.reduce(function(n,i){return i(n)},r)}}var x=(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=wt(t)?t:new G(t,r,n);return Z(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=xe(r),new r(function(i,o){var a=new G({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[be]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return yt(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=xe(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 xe(e){var t;return(t=e??dt.Promise)!==null&&t!==void 0?t:Promise}function bt(e){return e&&b(e.next)&&b(e.error)&&b(e.complete)}function wt(e){return e&&e instanceof ye||bt(e)&&Le(e)}function gt(e){return b(e==null?void 0:e.lift)}function L(e){return function(t){if(gt(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 j(e,t,r,n,i){return new St(e,t,r,n,i)}var St=(function(e){V(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})(ye),_t=me(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ne=(function(e){V(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 Ae(this,this);return n.operator=r,n},t.prototype._throwIfClosed=function(){if(this.closed)throw new _t},t.prototype.next=function(r){var n=this;Z(function(){var i,o;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var a=z(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;Z(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;Z(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?je:(this.currentObservers=null,u.push(r),new re(function(){n.currentObservers=null,de(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 x;return r.source=this,r},t.create=function(r,n){return new Ae(r,n)},t})(x),Ae=(function(e){V(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:je},t})(ne),Fe={now:function(){return(Fe.delegate||Date).now()},delegate:void 0},Et=(function(e){V(t,e);function t(r,n,i){r===void 0&&(r=1/0),n===void 0&&(n=1/0),i===void 0&&(i=Fe);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})(ne),ge=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function Ue(e){return b(e==null?void 0:e.then)}function ke(e){return b(e[be])}function $e(e){return Symbol.asyncIterator&&b(e==null?void 0:e[Symbol.asyncIterator])}function Me(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 Ot(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var De=Ot();function We(e){return b(e==null?void 0:e[De])}function qe(e){return lt(this,arguments,function(){var r,n,i,o;return Ce(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,W(r.read())];case 3:return n=a.sent(),i=n.value,o=n.done,o?[4,W(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,W(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 ze(e){return b(e==null?void 0:e.getReader)}function N(e){if(e instanceof x)return e;if(e!=null){if(ke(e))return xt(e);if(ge(e))return At(e);if(Ue(e))return Tt(e);if($e(e))return Be(e);if(We(e))return It(e);if(ze(e))return Pt(e)}throw Me(e)}function xt(e){return new x(function(t){var r=e[be]();if(b(r.subscribe))return r.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function At(e){return new x(function(t){for(var r=0;r<e.length&&!t.closed;r++)t.next(e[r]);t.complete()})}function Tt(e){return new x(function(t){e.then(function(r){t.closed||(t.next(r),t.complete())},function(r){return t.error(r)}).then(null,Ne)})}function It(e){return new x(function(t){var r,n;try{for(var i=z(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 Be(e){return new x(function(t){Rt(e,t).catch(function(r){return t.error(r)})})}function Pt(e){return Be(qe(e))}function Rt(e,t){var r,n,i,o;return ct(this,void 0,void 0,function(){var a,u;return Ce(this,function(s){switch(s.label){case 0:s.trys.push([0,5,6,11]),r=ft(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 $(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 Ge(e,t){return t===void 0&&(t=0),L(function(r,n){r.subscribe(j(n,function(i){return $(n,e,function(){return n.next(i)},t)},function(){return $(n,e,function(){return n.complete()},t)},function(i){return $(n,e,function(){return n.error(i)},t)}))})}function Ve(e,t){return t===void 0&&(t=0),L(function(r,n){n.add(e.schedule(function(){return r.subscribe(n)},t))})}function Ct(e,t){return N(e).pipe(Ve(t),Ge(t))}function jt(e,t){return N(e).pipe(Ve(t),Ge(t))}function Lt(e,t){return new x(function(r){var n=0;return t.schedule(function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())})})}function Nt(e,t){return new x(function(r){var n;return $(r,t,function(){n=e[De](),$(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 b(n==null?void 0:n.return)&&n.return()}})}function He(e,t){if(!e)throw new Error("Iterable cannot be null");return new x(function(r){$(r,t,function(){var n=e[Symbol.asyncIterator]();$(r,t,function(){n.next().then(function(i){i.done?r.complete():r.next(i.value)})},0,!0)})})}function Ft(e,t){return He(qe(e),t)}function Ut(e,t){if(e!=null){if(ke(e))return Ct(e,t);if(ge(e))return Lt(e,t);if(Ue(e))return jt(e,t);if($e(e))return He(e,t);if(We(e))return Nt(e,t);if(ze(e))return Ft(e,t)}throw Me(e)}function Ye(e,t){return t?Ut(e,t):N(e)}var kt=me(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function $t(e,t){return new Promise(function(r,n){var i=new G({next:function(o){r(o),i.unsubscribe()},error:n,complete:function(){n(new kt)}});e.subscribe(i)})}function Se(e,t){return L(function(r,n){var i=0;r.subscribe(j(n,function(o){n.next(e.call(t,o,i++))}))})}var Mt=Array.isArray;function Dt(e,t){return Mt(t)?e.apply(void 0,Y([],B(t))):e(t)}function Wt(e){return Se(function(t){return Dt(e,t)})}function qt(e,t,r,n,i,o,a,u){var s=[],c=0,l=0,p=!1,h=function(){p&&!s.length&&!c&&t.complete()},d=function(f){return c<n?v(f):s.push(f)},v=function(f){c++;var S=!1;N(r(f,l++)).subscribe(j(t,function(w){t.next(w)},function(){S=!0},void 0,function(){if(S)try{c--;for(var w=function(){var g=s.shift();a||v(g)};s.length&&c<n;)w();h()}catch(g){t.error(g)}}))};return e.subscribe(j(t,d,function(){p=!0,h()})),function(){}}function Je(e,t,r){return r===void 0&&(r=1/0),b(t)?Je(function(n,i){return Se(function(o,a){return t(n,o,i,a)})(N(e(n,i)))},r):(typeof t=="number"&&(r=t),L(function(n,i){return qt(n,i,e,r)}))}var zt=["addListener","removeListener"],Bt=["addEventListener","removeEventListener"],Gt=["on","off"];function he(e,t,r,n){if(b(r)&&(n=r,r=void 0),n)return he(e,t,r).pipe(Wt(n));var i=B(Yt(e)?Bt.map(function(u){return function(s){return e[u](t,s,r)}}):Vt(e)?zt.map(Te(e,t)):Ht(e)?Gt.map(Te(e,t)):[],2),o=i[0],a=i[1];if(!o&&ge(e))return Je(function(u){return he(u,t,r)})(N(e));if(!o)throw new TypeError("Invalid event target");return new x(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 Te(e,t){return function(r){return function(n){return e[r](t,n)}}}function Vt(e){return b(e.addListener)&&b(e.removeListener)}function Ht(e){return b(e.on)&&b(e.off)}function Yt(e){return b(e.addEventListener)&&b(e.removeEventListener)}function se(e,t){return L(function(r,n){var i=0;r.subscribe(j(n,function(o){return e.call(t,o,i++)&&n.next(o)}))})}function Jt(e,t){return t===void 0&&(t=we),e=e??Kt,L(function(r,n){var i,o=!0;r.subscribe(j(n,function(a){var u=t(a);(o||!e(i,u))&&(o=!1,i=u,n.next(a))}))})}function Kt(e,t){return e===t}function Xt(e){e===void 0&&(e={});var t=e.connector,r=t===void 0?function(){return new ne}: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,p,h,d=0,v=!1,f=!1,S=function(){p==null||p.unsubscribe(),p=void 0},w=function(){S(),l=h=void 0,v=f=!1},g=function(){var _=l;w(),_==null||_.unsubscribe()};return L(function(_,P){d++,!f&&!v&&S();var R=h=h??r();P.add(function(){d--,d===0&&!f&&!v&&(p=ue(g,s))}),R.subscribe(P),!l&&d>0&&(l=new G({next:function(C){return R.next(C)},error:function(C){f=!0,S(),p=ue(w,i,C),R.error(C)},complete:function(){v=!0,S(),p=ue(w,a),R.complete()}}),N(_).subscribe(l))})(c)}}function ue(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 G({next:function(){i.unsubscribe(),e()}});return N(t.apply(void 0,Y([],B(r)))).subscribe(i)}}function Ke(e,t){return L(function(r,n){var i=null,o=0,a=!1,u=function(){return a&&!i&&n.complete()};r.subscribe(j(n,function(s){i==null||i.unsubscribe();var c=0,l=o++;N(e(s,l)).subscribe(i=j(n,function(p){return n.next(t?t(s,p,l,c++):p)},function(){i=null,u()}))},function(){a=!0,u()}))})}function Zt(e,t,r){var n=b(e)||t||r?{next:e,error:t,complete:r}:e;return n?L(function(i,o){var a;(a=n.subscribe)===null||a===void 0||a.call(n);var u=!0;i.subscribe(j(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)}))}):we}const q=A.writable({});async function Xe(){q.update(e=>(Object.assign(e,window.__MANIFEST__),e))}const F=new Map,Q=5e3;function Qt(e){const t=F.get(e);return t?(F.delete(e),Date.now()-t.createdAt>Q?(t.abortController.abort(),null):t.response$):null}function er(e,t){he(document,"mouseover").pipe(Xt()).pipe(Se(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}),se(i=>i!==null),se(i=>i!==window.location.pathname),Jt(),se(i=>{const o=i.split("?")[0],a="get",u=e.find(l=>l.method.toLowerCase()===a&&t.find(p=>p.parser(o)&&p.pattern===l.path));if(!u)return!1;const s=t.find(l=>l.parser(o)&&l.pattern===u.path);return!!A.get(q)[s==null?void 0:s.pattern]}),Ke(i=>{const o=F.get(i);if(o&&Date.now()-o.createdAt<Q)return[];const a=new AbortController,u=new Et(1),s={response$:u,createdAt:Date.now(),abortController:a};F.set(i,s);const c={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:a.signal};return c[oe]=!0,Ye(fetch(i,c).then(l=>(u.next(l),u.complete(),i),l=>(u.error(l),F.delete(i),null))).pipe(Zt({unsubscribe:()=>{a.abort(),F.delete(i)}}))})).subscribe(),setInterval(()=>{const i=Date.now();for(const[o,a]of F)i-a.createdAt>Q&&(a.abortController.abort(),F.delete(o))},Q)}var k=(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))(k||{});const tr={trace:0,debug:1,info:2,warn:3,error:4,fatal:5};function rr(e){if(!e)return 2;const t=e.trim().toLowerCase(),r=tr[t];if(typeof r=="number")return r;const n=Number(t);return Number.isFinite(n)&&n>=0&&n<=5?n:2}function Ze(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 Ie(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 nr{constructor(t,r,n){this.name=t,this.manager=r,this.contextData=n}named(t){return new pe(t,this.manager,this.contextData)}withContext(t){const r=this.contextData?{...this.contextData,...t}:t;return new pe(this.name,this.manager,r)}trace(t,...r){this.log(k.TRACE,t,r)}debug(t,...r){this.log(k.DEBUG,t,r)}info(t,...r){this.log(k.INFO,t,r)}warn(t,...r){this.log(k.WARN,t,r)}error(t,...r){this.log(k.ERROR,t,r)}fatal(t,...r){this.log(k.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?Ie(n[0]):n.map(Ie):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:Ze(t),logger:this.name,message:r,context:a})}}class pe extends nr{constructor(t,r,n){super(t,r,n)}}class or{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 ce=Symbol.for("@noego/logger");class ir{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=rr(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}] [${Ze(t)}] ${n}`}}function Qe(){const e=globalThis;if(!e[ce]){const t=new ir;t.addTransport(new or),e[ce]=t}return e[ce]}function _e(e){return new pe(e,Qe())}const m=_e("forge:nav"),ar=1e4;function sr(e,t,r){let n=null,i=!1;const o=new Promise((a,u)=>{n=setTimeout(()=>{i=!0,m.error("Timeout fired after",t,"ms"),r(),u(new Error(`Navigation timed out after ${t}ms`))},t),m.debug("Timeout scheduled for",t,"ms, timeoutId:",n)});return Promise.race([e.finally(()=>{n!==null&&(i?m.warn("Promise settled AFTER timeout already fired"):(m.debug("Clearing timeout",n,"- promise settled successfully"),clearTimeout(n)))}),o])}const ve=new ne;let E=0,H=null;function ur(e){e&&e.redirectPath&&(m.debug("Handling redirect to",e.redirectPath),setTimeout(()=>{window.dispatchEvent(new CustomEvent("forge-redirect",{detail:{path:e.redirectPath}}))},0))}ve.pipe(Ke(e=>Ye(sr(fr(e),ar,()=>{m.error("Navigation timed out"),E++,H&&(H.abort(),H=null)}).catch(t=>{m.error("Navigation failed:",t)})))).subscribe({next:ur,error:e=>{m.error("Stream error:",e)}});function cr(e){var t;m.debug("Pushing navigation event to stream",{url:e.url,currentNavigationId:E,subscriberCount:((t=ve.observers)==null?void 0:t.length)||0}),ve.next(e)}const T=A.writable({active:{layouts:[],view:null,viewPath:null,layoutPaths:[],data:{layout:[],view:{}},params:{},urlParams:{},query:{}},phase:"idle",navigationId:0,page:I.page}),lr=async()=>{const e=A.get(T).navigationId;try{const t=window.location.pathname+window.location.search,r={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"}};r[oe]=!0;const n=await fetch(t,r);if(!n.ok)return!1;const i=await n.json(),o=A.get(T).navigationId;return e!==o?(m.debug("Discarding stale poll response",{pollNavigationId:e,currentNavigationId:o}),!1):(T.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}};I.page.update(e=>(e.poll=lr,e));async function et(e,t,r,n,i){if(!t.controller)return;let o=J(e,t.controller).toString();i&&(o=o.replace(/\.svelte\.ts$/,".js").replace(/\.ts$/,".js"),/\.[a-z]+$/.test(o)||(o+=".js")),o.startsWith("/")||(o="/"+o);const u=(await import(o)).default,s=new u;return typeof s.initialize=="function"&&await Promise.resolve(s.initialize(r,n)),s}function J(...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 tt(e,t,r,n,i,o){try{const a=typeof t=="string"&&t.indexOf("assets")!==-1,u=(r.layout||[]).map(w=>{let g=J(t,w).toString();return a&&(g=g.endsWith(".svelte")?g.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(g)?g:g+".js"),g});let s=J(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(w=>import(w).then(g=>g.default)));s.startsWith("/")||(s="/"+s);const l=await import(s).then(w=>w.default),p=window.__INITIAL_DATA__||{layout:[],view:{}},h=typeof t=="string"&&t.indexOf("assets")!==-1,d=A.get(I.page),v={params:n,urlParams:i,query:o,page:d},f=await et(t,r,p.view,v,h),S={layouts:c,view:l,viewPath:r.view||null,layoutPaths:r.layout||[],data:p,params:n,urlParams:i,query:o,controller:f};T.update(w=>(w.active=S,w.phase="idle",w)),it.hydrate(at,{target:e,props:{root:T}})}catch(a){m.error("Client-side route loading failed:",a)}}function ee(e,t,r,n,i,o,a=!1,u=!0){cr({url:e,base_path:t,route:r,params:n,urlParams:i,query:o,server_loading:a,updateUrl:u})}async function fr(e){var p;const{url:t,base_path:r,route:n,params:i,urlParams:o,query:a,server_loading:u,updateUrl:s}=e,c=++E,l=new AbortController;H=l,m.debug("Starting navigation",{navigationId:c,url:t,updateUrl:s,server_loading:u,currentNavigationId:E,hasAbortController:!!H}),T.update(h=>(h.phase="loading",h.navigationId=c,h));try{let h={layout:[],view:{}};if(u){m.debug("Fetching server data",{navigationId:c,url:t});let y=null;const O=Qt(t);if(O)try{m.debug("Using prefetched response for",t),y=await $t(O)}catch{m.debug("Prefetch failed, falling back to fetch",t),y=null}if(!y){const M={method:n.method,headers:{"Content-Type":"application/json",Accept:"application/json"},signal:l.signal};M[oe]=!0,y=await fetch(t,M)}if(m.debug("Fetch response received",{navigationId:c,url:t,ok:y.ok,status:y.status,redirected:y.redirected,currentNavigationId:E}),y.redirected||y.headers.get("X-Forge-Redirect")==="true")return m.debug("Redirect detected"),T.update(M=>(M.phase="idle",M)),{redirectPath:y.headers.get("X-Forge-Redirect-Path")||void 0};if(!y.ok)throw new Error(`Network response was not ok: ${y.status}`);h=await y.json(),m.debug("Server data received:",h)}if(c!==E){m.debug("Stale navigation after fetch, aborting",{navigationId:c,currentNavigationId:E});return}m.debug("Loading components",{navigationId:c,view:n.view,layouts:n.layout});const d=typeof r=="string"&&r.indexOf("assets")!==-1,v=(n.layout||[]).map(y=>{let O=J(r,y).toString();return d&&(O=O.endsWith(".svelte")?O.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(O)?O:O+".js"),O});let f=J(r,n.view).toString();d&&(f=f.endsWith(".svelte")?f.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(f)?f:f+".js"),f.startsWith("/")||(f="/"+f);const S=await Promise.all(v.map(y=>import(y).then(O=>O.default))),w=await import(f).then(y=>y.default);if(m.debug("Components loaded",{navigationId:c,currentNavigationId:E,layoutsCount:S.length,viewLoaded:!!w}),c!==E){m.debug("Stale navigation after component load, aborting",{navigationId:c,currentNavigationId:E});return}const g=A.get(I.page),_={params:i,urlParams:o,query:a,page:g},P=await et(r,n,h.view,_,d);if(c!==E){m.debug("Stale navigation after controller resolution, aborting",{navigationId:c,currentNavigationId:E}),(p=P==null?void 0:P.destroy)==null||p.call(P);return}const R=A.get(T).active.controller;R!=null&&R.destroy&&R.destroy();const C={layouts:S,view:w,viewPath:n.view||null,layoutPaths:n.layout||[],data:h,params:i,urlParams:o,query:a,controller:P};m.debug("Committing new state",{navigationId:c,currentNavigationId:E,layoutsCount:C.layouts.length,viewSet:!!C.view,dataKeys:Object.keys(C.data||{})}),T.update(y=>(y.active=C,y.phase="idle",m.debug("ROOT.active updated",{navigationId:c,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&&(m.debug("Updating browser URL",{url:t}),window.history.pushState({},"",t)),m.debug("Navigation complete",{navigationId:c,url:t})}catch(h){if(m.error("Navigation failed",{navigationId:c,currentNavigationId:E,url:t,error:h instanceof Error?h.message:String(h)}),T.update(d=>(d.phase="idle",d)),h.name==="AbortError"){m.debug("Navigation aborted");return}throw h}}const U=_e("forge:events");function rt(e,t,r){if(!document){U.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",p=t.find(h=>h.method.toLowerCase()===l&&r.find(d=>d.parser(c)&&d.pattern===h.path));if(p){n.preventDefault();const h=r.find(_=>_.parser(c)&&_.pattern===p.path),d=(h==null?void 0:h.parser(c))||{},v=new URLSearchParams(s.split("?")[1]||""),f=Object.fromEntries(v.entries())||{},S={...d,...f},g=A.get(q)[h==null?void 0:h.pattern];I.page.update(_=>(_.url=s,_.pathname=c,_.params=d,_.query=f,_)),U.debug("Click navigation to",s),ee(s,e,p,S,d,f,g,!0)}else U.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(f=>f.parser(i)&&f.pattern===u.path),c=(s==null?void 0:s.parser(i))||{},l=new URLSearchParams(window.location.search),p=Object.fromEntries(l.entries())||{};I.page.update(f=>(f.url=o,f.pathname=window.location.pathname,f.params=c,f.query=p,f));const h={...c,...p},v=A.get(q)[s==null?void 0:s.pattern];U.debug("Popstate navigation to",o),ee(o,e,u,h,c,p,v,!1)}else U.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];U.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(f=>f.parser(o)&&f.pattern===u.path),c=(s==null?void 0:s.parser(o))||{},l=new URLSearchParams(i.split("?")[1]||""),p=Object.fromEntries(l.entries())||{},h={...c,...p},v=A.get(q)[s==null?void 0:s.pattern];I.page.update(f=>(f.url=i,f.pathname=o,f.params=c,f.query=p,f)),ee(i,e,u,h,c,p,v,!0)}else U.warn("No matching route found",o,"- using fallback navigation"),window.location.href=o})),er(t,r)}const Pe="/__forge/dev-logs",dr=100,hr=20;class pr{constructor(){ie(this,"buffer",[]);ie(this,"timer",null);typeof window<"u"&&window.addEventListener("beforeunload",()=>{this.beaconFlush()})}log(t){if(this.buffer.push(t),this.buffer.length>=hr){this.flush();return}this.timer||(this.timer=setTimeout(()=>this.flush(),dr))}flush(){if(this.timer&&(clearTimeout(this.timer),this.timer=null),this.buffer.length===0)return;const t=this.buffer;this.buffer=[];try{fetch(Pe,{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(Pe,JSON.stringify(t))}catch{}}}const D=_e("forge:client"),oe=Symbol("forge-load-function");let te=[],X=null;function vr(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 mr(){typeof window<"u"&&!X&&(X=window.fetch,window.fetch=async function(e,t={}){if((typeof e=="string"?e:e instanceof URL?e.toString():e.url)==="/__forge/dev-logs")return X(e,t);let n={...t};for(const a of te)try{if(a.length===2){const u=new Headers(n.headers),s=Object.fromEntries(u.entries());await new Promise((c,l)=>{try{a(s,p=>{if(p)l(p);else{const h=new Headers;Object.entries(s).forEach(([d,v])=>{v!==void 0&&h.set(d,v)}),n.headers=h,c()}})}catch(p){l(p)}})}else{const u=await a(n,e);u&&typeof u=="object"&&(n=u)}}catch(u){throw D.error("Middleware error",u),u}const i=n==null?void 0:n[oe];D.debug("Fetch override request",{url:e,hasForgeSymbol:i,headers:n==null?void 0:n.headers});const o=await X(e,n);if(D.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(D.debug("Redirect detected",{requested:a,final:u,redirected:o.redirected}),vr(u)){const s=new URL(u),c=s.pathname+s.search;return D.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})}mr();var Re;if(typeof window<"u"){const e=window.__CONFIGURATION__;(Re=e==null?void 0:e.dev)!=null&&Re.enable_debug_log&&Qe().addTransport(new pr)}const yr={configUpdate(e){if(typeof e!="function")throw new Error("Middleware must be a function");te.push(e)},reset(){te.length=0},getMiddlewareCount(){return te.length}};let le;async function br(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(le=ut(n),window&&window.location){const i=(window.location.pathname||"/").split("?")[0],o=le.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};Xe(),tt(e,r,a,l,u,c),rt(r,n,le)}else D.warn("No matching route",i)}}exports.page=I.page;exports.shadowUrl=I.shadowUrl;exports.MANIFEST_STORE=q;exports.bootstrap_events=rt;exports.createApp=br;exports.fetch=yr;exports.loadRoute=tt;exports.updateManifestStore=Xe;exports.updateRoute=ee;
|
|
4
4
|
//# sourceMappingURL=client.cjs.map
|