UNPKG

cell-router

Version:

Web Component Router based on WebCell & MobX

642 lines (615 loc) 31.1 kB
import "urlpattern-polyfill"; import {buildURLData as $dvphU$buildURLData, formToJSON as $dvphU$formToJSON, delegate as $dvphU$delegate, parseURLData as $dvphU$parseURLData, getVisibleText as $dvphU$getVisibleText, isXDomain as $dvphU$isXDomain, scrollTo as $dvphU$scrollTo} from "web-utility"; import {observable as $dvphU$observable, action as $dvphU$action} from "mobx"; import {jsx as $dvphU$jsx, Fragment as $dvphU$Fragment} from "dom-renderer/jsx-runtime"; import {DOMRenderer as $dvphU$DOMRenderer} from "dom-renderer"; import {component as $dvphU$component, observer as $dvphU$observer, attribute as $dvphU$attribute, reaction as $dvphU$reaction} from "web-cell"; function $parcel$export(e, n, v, s) { Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); } var $3a2ee75a1759d0d8$exports = {}; $parcel$export($3a2ee75a1759d0d8$exports, "RouterMode", () => $3a2ee75a1759d0d8$export$fc55ead6785c2297); $parcel$export($3a2ee75a1759d0d8$exports, "History", () => $3a2ee75a1759d0d8$export$84202caead5689ba); var $3a2ee75a1759d0d8$var$__runInitializers = undefined && undefined.__runInitializers || function(thisArg, initializers, value) { var useValue = arguments.length > 2; for(var i = 0; i < initializers.length; i++)value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); return useValue ? value : void 0; }; var $3a2ee75a1759d0d8$var$__esDecorate = undefined && undefined.__esDecorate || function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); var _, done = false; for(var i = decorators.length - 1; i >= 0; i--){ var context = {}; for(var p in contextIn)context[p] = p === "access" ? {} : contextIn[p]; for(var p in contextIn.access)context.access[p] = contextIn.access[p]; context.addInitializer = function(f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); if (kind === "accessor") { if (result === void 0) continue; if (result === null || typeof result !== "object") throw new TypeError("Object expected"); if (_ = accept(result.get)) descriptor.get = _; if (_ = accept(result.set)) descriptor.set = _; if (_ = accept(result.init)) initializers.unshift(_); } else if (_ = accept(result)) { if (kind === "field") initializers.unshift(_); else descriptor[key] = _; } } if (target) Object.defineProperty(target, contextIn.name, descriptor); done = true; }; var $3a2ee75a1759d0d8$var$__classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var $3a2ee75a1759d0d8$var$__classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value; }; var $3a2ee75a1759d0d8$var$_a, $3a2ee75a1759d0d8$var$_b; const { location: $3a2ee75a1759d0d8$var$location, history: $3a2ee75a1759d0d8$var$history } = window; const $3a2ee75a1759d0d8$var$basePath = ($3a2ee75a1759d0d8$var$_a = document.querySelector('base')) === null || $3a2ee75a1759d0d8$var$_a === void 0 ? void 0 : $3a2ee75a1759d0d8$var$_a.getAttribute('href'); const $3a2ee75a1759d0d8$var$defaultBaseURL = ($3a2ee75a1759d0d8$var$basePath ? new URL($3a2ee75a1759d0d8$var$basePath, $3a2ee75a1759d0d8$var$location.origin) + '' : $3a2ee75a1759d0d8$var$location.href.split(/\?|#/)[0]).replace(/\/$/, ''); const $3a2ee75a1759d0d8$var$originalTitle = ($3a2ee75a1759d0d8$var$_b = document.querySelector('title')) === null || $3a2ee75a1759d0d8$var$_b === void 0 ? void 0 : $3a2ee75a1759d0d8$var$_b.textContent.trim(); var $3a2ee75a1759d0d8$export$fc55ead6785c2297; (function(RouterMode) { RouterMode["hash"] = "#"; RouterMode["history"] = "/"; })($3a2ee75a1759d0d8$export$fc55ead6785c2297 || ($3a2ee75a1759d0d8$export$fc55ead6785c2297 = {})); let $3a2ee75a1759d0d8$export$84202caead5689ba = (()=>{ var _a, _History_path_accessor_storage, _History_oldPath_accessor_storage; let _instanceExtraInitializers = []; let _path_decorators; let _path_initializers = []; let _path_extraInitializers = []; let _oldPath_decorators; let _oldPath_initializers = []; let _oldPath_extraInitializers = []; let _push_decorators; return _a = class History { get path() { return $3a2ee75a1759d0d8$var$__classPrivateFieldGet(this, _History_path_accessor_storage, "f"); } set path(value) { $3a2ee75a1759d0d8$var$__classPrivateFieldSet(this, _History_path_accessor_storage, value, "f"); } get oldPath() { return $3a2ee75a1759d0d8$var$__classPrivateFieldGet(this, _History_oldPath_accessor_storage, "f"); } set oldPath(value) { $3a2ee75a1759d0d8$var$__classPrivateFieldSet(this, _History_oldPath_accessor_storage, value, "f"); } constructor(baseURL = $3a2ee75a1759d0d8$var$defaultBaseURL, delimiter = $3a2ee75a1759d0d8$export$fc55ead6785c2297.hash){ Object.defineProperty(this, "baseURL", { enumerable: true, configurable: true, writable: true, value: ($3a2ee75a1759d0d8$var$__runInitializers(this, _instanceExtraInitializers), baseURL) }); Object.defineProperty(this, "delimiter", { enumerable: true, configurable: true, writable: true, value: delimiter }); _History_path_accessor_storage.set(this, $3a2ee75a1759d0d8$var$__runInitializers(this, _path_initializers, void 0)); _History_oldPath_accessor_storage.set(this, ($3a2ee75a1759d0d8$var$__runInitializers(this, _path_extraInitializers), $3a2ee75a1759d0d8$var$__runInitializers(this, _oldPath_initializers, void 0))); Object.defineProperty(this, "restore", { enumerable: true, configurable: true, writable: true, value: ($3a2ee75a1759d0d8$var$__runInitializers(this, _oldPath_extraInitializers), ()=>{ const { state: state } = $3a2ee75a1759d0d8$var$history; this.push(); document.title = (state === null || state === void 0 ? void 0 : state.title) || this.titleOf() || $3a2ee75a1759d0d8$var$originalTitle || $3a2ee75a1759d0d8$var$location.href; }) }); Object.defineProperty(this, "handleForm", { enumerable: true, configurable: true, writable: true, value: (event, form)=>{ const { method: method, target: target } = form; if (method !== 'get' || (target || '_self') !== '_self') return; event.preventDefault(); const path = form.getAttribute('action'), data = (0, $dvphU$buildURLData)((0, $dvphU$formToJSON)(form)); this.push(`${path}?${data}`); } }); this.restore(); window.addEventListener('hashchange', this.restore); window.addEventListener('popstate', this.restore); document.addEventListener('click', (0, $dvphU$delegate)('a[href], area[href]', this.handleLink.bind(this))); document.addEventListener('submit', (0, $dvphU$delegate)('form[action]', this.handleForm)); } push(path = $3a2ee75a1759d0d8$var$location.href) { var _b; path = path.replace(this.baseURL, ''); if (this.delimiter === $3a2ee75a1759d0d8$export$fc55ead6785c2297.hash) path = ((_b = path.match(/#.*/)) === null || _b === void 0 ? void 0 : _b[0]) || $3a2ee75a1759d0d8$export$fc55ead6785c2297.hash; if (path === this.path) return path; this.oldPath = this.path; return this.path = path; } static dataOf(path) { const [before, after] = path.split('#'); return (0, $dvphU$parseURLData)(after || before); } match(pattern, path = this.path) { var _b; if (!path) return; const { pathname: pathname, hash: hash } = new URLPattern(pattern, this.baseURL).exec(new URL(path.split('?')[0], this.baseURL)) || {}; return (_b = hash || pathname) === null || _b === void 0 ? void 0 : _b.groups; } static getTitle(root) { return root.title || (0, $dvphU$getVisibleText)(root); } titleOf(path = this.path) { path = path.replace(/^\//, ''); if (path) for (const node of document.querySelectorAll(`a[href="${path}"], area[href="${path}"]`)){ const title = _a.getTitle(node); if (title) return title; } } handleLink(event, link) { const path = link.getAttribute('href'); if ((link.target || '_self') !== '_self' || (0, $dvphU$isXDomain)(path) || link.download) return; event.preventDefault(); if (path.startsWith('#')) try { if (document.querySelector(path) || path === '#top') return (0, $dvphU$scrollTo)(path, event.currentTarget); } catch (_b) {} const title = _a.getTitle(link); $3a2ee75a1759d0d8$var$history.pushState({ title: title }, document.title = title, path); this.push(path); } }, _History_path_accessor_storage = new WeakMap(), _History_oldPath_accessor_storage = new WeakMap(), (()=>{ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0; _path_decorators = [ (0, $dvphU$observable) ]; _oldPath_decorators = [ (0, $dvphU$observable) ]; _push_decorators = [ (0, $dvphU$action) ]; $3a2ee75a1759d0d8$var$__esDecorate(_a, null, _path_decorators, { kind: "accessor", name: "path", static: false, private: false, access: { has: (obj)=>"path" in obj, get: (obj)=>obj.path, set: (obj, value)=>{ obj.path = value; } }, metadata: _metadata }, _path_initializers, _path_extraInitializers); $3a2ee75a1759d0d8$var$__esDecorate(_a, null, _oldPath_decorators, { kind: "accessor", name: "oldPath", static: false, private: false, access: { has: (obj)=>"oldPath" in obj, get: (obj)=>obj.oldPath, set: (obj, value)=>{ obj.oldPath = value; } }, metadata: _metadata }, _oldPath_initializers, _oldPath_extraInitializers); $3a2ee75a1759d0d8$var$__esDecorate(_a, null, _push_decorators, { kind: "method", name: "push", static: false, private: false, access: { has: (obj)=>"push" in obj, get: (obj)=>obj.push }, metadata: _metadata }, null, _instanceExtraInitializers); if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); })(), _a; })(); var $0e8e8fd52ec9970a$exports = {}; $parcel$export($0e8e8fd52ec9970a$exports, "CellRoute", () => $0e8e8fd52ec9970a$export$d6c529ca17cdd16f); $parcel$export($0e8e8fd52ec9970a$exports, "CellRouter", () => $0e8e8fd52ec9970a$export$b1119cfa2764f723); var $0e8e8fd52ec9970a$var$__esDecorate = undefined && undefined.__esDecorate || function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); var _, done = false; for(var i = decorators.length - 1; i >= 0; i--){ var context = {}; for(var p in contextIn)context[p] = p === "access" ? {} : contextIn[p]; for(var p in contextIn.access)context.access[p] = contextIn.access[p]; context.addInitializer = function(f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); if (kind === "accessor") { if (result === void 0) continue; if (result === null || typeof result !== "object") throw new TypeError("Object expected"); if (_ = accept(result.get)) descriptor.get = _; if (_ = accept(result.set)) descriptor.set = _; if (_ = accept(result.init)) initializers.unshift(_); } else if (_ = accept(result)) { if (kind === "field") initializers.unshift(_); else descriptor[key] = _; } } if (target) Object.defineProperty(target, contextIn.name, descriptor); done = true; }; var $0e8e8fd52ec9970a$var$__runInitializers = undefined && undefined.__runInitializers || function(thisArg, initializers, value) { var useValue = arguments.length > 2; for(var i = 0; i < initializers.length; i++)value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); return useValue ? value : void 0; }; var $0e8e8fd52ec9970a$var$__setFunctionName = undefined && undefined.__setFunctionName || function(f, name, prefix) { if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); }; var $0e8e8fd52ec9970a$var$__classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var $0e8e8fd52ec9970a$var$__classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value; }; var $0e8e8fd52ec9970a$var$__rest = undefined && undefined.__rest || function(s, e) { var t = {}; for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") { for(var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; let $0e8e8fd52ec9970a$export$d6c529ca17cdd16f = (()=>{ var _CellRoute_path_accessor_storage; let _classDecorators = [ (0, $dvphU$component)({ tagName: 'cell-route' }), (0, $dvphU$observer) ]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; let _classSuper = HTMLElement; let _path_decorators; let _path_initializers = []; let _path_extraInitializers = []; var CellRoute = _classThis = class extends _classSuper { constructor(){ super(...arguments); _CellRoute_path_accessor_storage.set(this, $0e8e8fd52ec9970a$var$__runInitializers(this, _path_initializers, void 0)); Object.defineProperty(this, "component", { enumerable: true, configurable: true, writable: true, value: $0e8e8fd52ec9970a$var$__runInitializers(this, _path_extraInitializers) }); } get path() { return $0e8e8fd52ec9970a$var$__classPrivateFieldGet(this, _CellRoute_path_accessor_storage, "f"); } set path(value) { $0e8e8fd52ec9970a$var$__classPrivateFieldSet(this, _CellRoute_path_accessor_storage, value, "f"); } }; _CellRoute_path_accessor_storage = new WeakMap(); $0e8e8fd52ec9970a$var$__setFunctionName(_classThis, "CellRoute"); (()=>{ var _a; const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0; _path_decorators = [ (0, $dvphU$attribute), (0, $dvphU$observable) ]; $0e8e8fd52ec9970a$var$__esDecorate(_classThis, null, _path_decorators, { kind: "accessor", name: "path", static: false, private: false, access: { has: (obj)=>"path" in obj, get: (obj)=>obj.path, set: (obj, value)=>{ obj.path = value; } }, metadata: _metadata }, _path_initializers, _path_extraInitializers); $0e8e8fd52ec9970a$var$__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); CellRoute = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); $0e8e8fd52ec9970a$var$__runInitializers(_classThis, _classExtraInitializers); })(); return CellRoute = _classThis; })(); let $0e8e8fd52ec9970a$export$b1119cfa2764f723 = (()=>{ var _CellRouter_renderer, _CellRouter_history_accessor_storage, _CellRouter_routes_accessor_storage; var _a, _b; let _classDecorators = [ (0, $dvphU$component)({ tagName: 'cell-router', mode: 'open' }), (0, $dvphU$observer) ]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; let _classSuper = HTMLElement; let _instanceExtraInitializers = []; let _history_decorators; let _history_initializers = []; let _history_extraInitializers = []; let _routes_decorators; let _routes_initializers = []; let _routes_extraInitializers = []; let _renderChildren_decorators; var CellRouter = _classThis = class extends _classSuper { constructor(){ super(...arguments); _CellRouter_history_accessor_storage.set(this, ($0e8e8fd52ec9970a$var$__runInitializers(this, _instanceExtraInitializers), $0e8e8fd52ec9970a$var$__runInitializers(this, _history_initializers, void 0))); _CellRouter_routes_accessor_storage.set(this, ($0e8e8fd52ec9970a$var$__runInitializers(this, _history_extraInitializers), $0e8e8fd52ec9970a$var$__runInitializers(this, _routes_initializers, []))); _CellRouter_renderer.set(this, ($0e8e8fd52ec9970a$var$__runInitializers(this, _routes_extraInitializers), new (0, $dvphU$DOMRenderer)())); Object.defineProperty(this, "handleSlotChange", { enumerable: true, configurable: true, writable: true, value: ({ currentTarget: currentTarget })=>{ const routes = currentTarget.assignedElements().filter((node)=>node instanceof $0e8e8fd52ec9970a$export$d6c529ca17cdd16f).map(({ path: path, component: component })=>({ path: path, component: component })); if (routes[0]) this.routes = routes; } }); } get history() { return $0e8e8fd52ec9970a$var$__classPrivateFieldGet(this, _CellRouter_history_accessor_storage, "f"); } set history(value) { $0e8e8fd52ec9970a$var$__classPrivateFieldSet(this, _CellRouter_history_accessor_storage, value, "f"); } get routes() { return $0e8e8fd52ec9970a$var$__classPrivateFieldGet(this, _CellRouter_routes_accessor_storage, "f"); } set routes(value) { $0e8e8fd52ec9970a$var$__classPrivateFieldSet(this, _CellRouter_routes_accessor_storage, value, "f"); } mountedCallback() { this.history || (this.history = new (0, $3a2ee75a1759d0d8$export$84202caead5689ba)()); this.renderChildren(); } async renderChildren() { var _a; const { history: history, routes: routes } = this; if (!history) return; const { path: path } = history; const [_b] = [ ...routes ].sort(({ path: a }, { path: b })=>b.split('/').length - a.split('/').length).map(({ path: path, component: component })=>{ const matched = history.match(path); return matched && Object.assign({ component: component }, matched); }).filter(Boolean), _c = _b === void 0 ? {} : _b, { component: Tag } = _c, matched = $0e8e8fd52ec9970a$var$__rest(_c, [ "component" ]); const vNode = Tag ? (0, $dvphU$jsx)(Tag, Object.assign({}, matched, (0, $3a2ee75a1759d0d8$export$84202caead5689ba).dataOf(path), { path: path, history: history })) : (0, $dvphU$jsx)((0, $dvphU$Fragment), {}); const render = ()=>{ $0e8e8fd52ec9970a$var$__classPrivateFieldGet(this, _CellRouter_renderer, "f").render(vNode, this); return {}; }; const { finished: finished, updateCallbackDone: updateCallbackDone } = ((_a = document.startViewTransition) === null || _a === void 0 ? void 0 : _a.call(document, render)) || render(); try { await finished; } catch (_d) { return updateCallbackDone; } } render() { return (0, $dvphU$jsx)("slot", { onSlotChange: this.handleSlotChange }); } }; _CellRouter_renderer = new WeakMap(); _CellRouter_history_accessor_storage = new WeakMap(); _CellRouter_routes_accessor_storage = new WeakMap(); $0e8e8fd52ec9970a$var$__setFunctionName(_classThis, "CellRouter"); (()=>{ var _a; const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0; _history_decorators = [ (_a = (0, $dvphU$observable)).shallow.bind(_a) ]; _routes_decorators = [ (_b = (0, $dvphU$observable)).shallow.bind(_b) ]; _renderChildren_decorators = [ (0, $dvphU$reaction)(({ history: history })=>history === null || history === void 0 ? void 0 : history.path) ]; $0e8e8fd52ec9970a$var$__esDecorate(_classThis, null, _history_decorators, { kind: "accessor", name: "history", static: false, private: false, access: { has: (obj)=>"history" in obj, get: (obj)=>obj.history, set: (obj, value)=>{ obj.history = value; } }, metadata: _metadata }, _history_initializers, _history_extraInitializers); $0e8e8fd52ec9970a$var$__esDecorate(_classThis, null, _routes_decorators, { kind: "accessor", name: "routes", static: false, private: false, access: { has: (obj)=>"routes" in obj, get: (obj)=>obj.routes, set: (obj, value)=>{ obj.routes = value; } }, metadata: _metadata }, _routes_initializers, _routes_extraInitializers); $0e8e8fd52ec9970a$var$__esDecorate(_classThis, null, _renderChildren_decorators, { kind: "method", name: "renderChildren", static: false, private: false, access: { has: (obj)=>"renderChildren" in obj, get: (obj)=>obj.renderChildren }, metadata: _metadata }, null, _instanceExtraInitializers); $0e8e8fd52ec9970a$var$__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); CellRouter = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); $0e8e8fd52ec9970a$var$__runInitializers(_classThis, _classExtraInitializers); })(); return CellRouter = _classThis; })(); var $3d03e8579c0b9ff1$exports = {}; var $7b488c9460f448a0$exports = {}; $parcel$export($7b488c9460f448a0$exports, "createRouter", () => $7b488c9460f448a0$export$baddd0131ee8c05b); var $7b488c9460f448a0$var$__rest = undefined && undefined.__rest || function(s, e) { var t = {}; for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") { for(var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; function $7b488c9460f448a0$export$baddd0131ee8c05b({ mode: mode = 'hash', linkTags: linkTags } = {}) { const prefix = (0, $3a2ee75a1759d0d8$export$fc55ead6785c2297)[mode]; const extraComponentList = Object.entries(linkTags || {}).map(([name, Component])=>[ name, (_a)=>{ var { href: href } = _a, props = $7b488c9460f448a0$var$__rest(_a, [ "href" ]); return (0, $dvphU$jsx)(Component, Object.assign({}, props, { href: prefix + (href || '') })); } ]); const extraComponentMap = Object.fromEntries(extraComponentList); return Object.assign(Object.assign({}, extraComponentMap), { Router: (_a)=>{ var { routes: routes } = _a, props = $7b488c9460f448a0$var$__rest(_a, [ "routes" ]); return (0, $dvphU$jsx)((0, $0e8e8fd52ec9970a$export$b1119cfa2764f723), Object.assign({}, props, { routes: routes === null || routes === void 0 ? void 0 : routes.map((route)=>Object.assign(Object.assign({}, route), { path: prefix + route.path })) })); }, Route: (_a)=>{ var { path: path } = _a, props = $7b488c9460f448a0$var$__rest(_a, [ "path" ]); return (0, $dvphU$jsx)((0, $0e8e8fd52ec9970a$export$d6c529ca17cdd16f), Object.assign({}, props, { path: prefix + path })); }, Link: (_a)=>{ var { to: to, children: children } = _a, props = $7b488c9460f448a0$var$__rest(_a, [ "to", "children" ]); return (0, $dvphU$jsx)("a", Object.assign({}, props, { href: prefix + to, children: children })); }, Form: (_a)=>{ var { action: action, children: children } = _a, props = $7b488c9460f448a0$var$__rest(_a, [ "action", "children" ]); return (0, $dvphU$jsx)("form", Object.assign({}, props, { action: prefix + action, children: children })); } }); } export {$3a2ee75a1759d0d8$export$fc55ead6785c2297 as RouterMode, $3a2ee75a1759d0d8$export$84202caead5689ba as History, $0e8e8fd52ec9970a$export$d6c529ca17cdd16f as CellRoute, $0e8e8fd52ec9970a$export$b1119cfa2764f723 as CellRouter, $7b488c9460f448a0$export$baddd0131ee8c05b as createRouter}; //# sourceMappingURL=index.esm.js.map