mailcow/data/web/_apidocs.html

24116 lines
912 KiB
HTML
Raw Normal View History

2019-10-03 04:13:12 +08:00
<!DOCTYPE html>
<html lang="en">
<head>
<title>API</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.5/css/bulma.min.css" integrity="sha256-vK3UTo/8wHbaUn+dTQD0X6dzidqc5l7gczvH+Bnowwk=" crossorigin="anonymous" id="bulma-theme-light" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulmaswatch@0.7.5/cyborg/bulmaswatch.min.css" integrity="sha256-NEPZJFJGDcH6K+NW0Ij8VtItmbltoDzXHaZ4oBQzuvU=" crossorigin="anonymous" media="none" id="bulma-theme-dark" />
2019-10-03 04:13:12 +08:00
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/fontawesome.min.css" integrity="sha256-AaQqnjfGDRZd/lUp0Dvy7URGOyRsh8g9JdWUkyYxNfI=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/solid.min.css" integrity="sha256-3FfMfpeajSEpxWZTFowWZPTv7k3GEu7w4rQv49EWsEY=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prism-themes@1.1.0/themes/prism-a11y-dark.css" integrity="sha256-d2qy226pP+oHAtEQPujaiXPslYW1Rmtla3Ivu1fFYxU=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma-switch@2.0.0/dist/css/bulma-switch.min.css" integrity="sha256-jCV/cXwP13w0GNHLgFx6SFgTNAvJPvS5MIhuE30Ng08=" crossorigin="anonymous">
<style>
@media screen and (min-width: 768px) {
.navbar-burger {
display: none;
}
}
</style>
</head>
<body class="has-navbar-fixed-top">
<script>var main = (function () {
'use strict';
function noop() { }
const identity = x => x;
function assign(tar, src) {
// @ts-ignore
for (const k in src)
tar[k] = src[k];
return tar;
}
function is_promise(value) {
return value && typeof value === 'object' && typeof value.then === 'function';
}
function add_location(element, file, line, column, char) {
element.__svelte_meta = {
loc: { file, line, column, char }
};
}
function run(fn) {
return fn();
}
function blank_object() {
return Object.create(null);
}
function run_all(fns) {
fns.forEach(run);
}
function is_function(thing) {
return typeof thing === 'function';
}
function safe_not_equal(a, b) {
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
}
function not_equal(a, b) {
return a != a ? b == b : a !== b;
}
function validate_store(store, name) {
2020-05-30 21:19:58 +08:00
if (store != null && typeof store.subscribe !== 'function') {
2019-10-03 04:13:12 +08:00
throw new Error(`'${name}' is not a store with a 'subscribe' method`);
}
}
2020-05-30 21:19:58 +08:00
function subscribe(store, ...callbacks) {
if (store == null) {
return noop;
}
const unsub = store.subscribe(...callbacks);
2019-10-03 04:13:12 +08:00
return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
}
function get_store_value(store) {
let value;
subscribe(store, _ => value = _)();
return value;
}
function component_subscribe(component, store, callback) {
component.$$.on_destroy.push(subscribe(store, callback));
}
function create_slot(definition, ctx, $$scope, fn) {
2019-10-03 04:13:12 +08:00
if (definition) {
const slot_ctx = get_slot_context(definition, ctx, $$scope, fn);
2019-10-03 04:13:12 +08:00
return definition[0](slot_ctx);
}
}
function get_slot_context(definition, ctx, $$scope, fn) {
return definition[1] && fn
? assign($$scope.ctx.slice(), definition[1](fn(ctx)))
: $$scope.ctx;
}
function get_slot_changes(definition, $$scope, dirty, fn) {
if (definition[2] && fn) {
const lets = definition[2](fn(dirty));
2020-05-30 21:19:58 +08:00
if ($$scope.dirty === undefined) {
return lets;
}
if (typeof lets === 'object') {
const merged = [];
const len = Math.max($$scope.dirty.length, lets.length);
for (let i = 0; i < len; i += 1) {
merged[i] = $$scope.dirty[i] | lets[i];
}
return merged;
}
return $$scope.dirty | lets;
}
return $$scope.dirty;
2019-10-03 04:13:12 +08:00
}
function exclude_internal_props(props) {
const result = {};
for (const k in props)
if (k[0] !== '$')
result[k] = props[k];
return result;
}
function once(fn) {
let ran = false;
return function (...args) {
if (ran)
return;
ran = true;
fn.call(this, ...args);
};
}
function null_to_empty(value) {
return value == null ? '' : value;
}
function set_store_value(store, ret, value = ret) {
store.set(value);
return ret;
}
const has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
2020-05-30 21:19:58 +08:00
function action_destroyer(action_result) {
return action_result && is_function(action_result.destroy) ? action_result.destroy : noop;
}
2019-10-03 04:13:12 +08:00
const is_client = typeof window !== 'undefined';
let now = is_client
? () => window.performance.now()
: () => Date.now();
let raf = is_client ? cb => requestAnimationFrame(cb) : noop;
// used internally for testing
function set_now(fn) {
now = fn;
}
function set_raf(fn) {
raf = fn;
}
const tasks = new Set();
function run_tasks(now) {
2019-10-03 04:13:12 +08:00
tasks.forEach(task => {
if (!task.c(now)) {
2019-10-03 04:13:12 +08:00
tasks.delete(task);
task.f();
2019-10-03 04:13:12 +08:00
}
});
if (tasks.size !== 0)
2019-10-03 04:13:12 +08:00
raf(run_tasks);
}
/**
* For testing purposes only!
*/
2019-10-03 04:13:12 +08:00
function clear_loops() {
tasks.clear();
2019-10-03 04:13:12 +08:00
}
/**
* Creates a new task that runs on each raf frame
* until it returns a falsy value or is aborted
*/
function loop(callback) {
2019-10-03 04:13:12 +08:00
let task;
if (tasks.size === 0)
2019-10-03 04:13:12 +08:00
raf(run_tasks);
return {
promise: new Promise(fulfill => {
tasks.add(task = { c: callback, f: fulfill });
2019-10-03 04:13:12 +08:00
}),
abort() {
tasks.delete(task);
}
};
}
function append(target, node) {
target.appendChild(node);
}
function insert(target, node, anchor) {
target.insertBefore(node, anchor || null);
}
function detach(node) {
node.parentNode.removeChild(node);
}
function destroy_each(iterations, detaching) {
for (let i = 0; i < iterations.length; i += 1) {
if (iterations[i])
iterations[i].d(detaching);
}
}
function element(name) {
return document.createElement(name);
}
function element_is(name, is) {
return document.createElement(name, { is });
}
function object_without_properties(obj, exclude) {
const target = {};
for (const k in obj) {
if (has_prop(obj, k)
2019-10-03 04:13:12 +08:00
// @ts-ignore
&& exclude.indexOf(k) === -1) {
// @ts-ignore
target[k] = obj[k];
}
}
return target;
}
function svg_element(name) {
return document.createElementNS('http://www.w3.org/2000/svg', name);
}
function text(data) {
return document.createTextNode(data);
}
function space() {
return text(' ');
}
function empty() {
return text('');
}
function listen(node, event, handler, options) {
node.addEventListener(event, handler, options);
return () => node.removeEventListener(event, handler, options);
}
function prevent_default(fn) {
return function (event) {
event.preventDefault();
// @ts-ignore
return fn.call(this, event);
};
}
function stop_propagation(fn) {
return function (event) {
event.stopPropagation();
// @ts-ignore
return fn.call(this, event);
};
}
function self$1(fn) {
return function (event) {
// @ts-ignore
if (event.target === this)
fn.call(this, event);
};
}
function attr(node, attribute, value) {
if (value == null)
node.removeAttribute(attribute);
else if (node.getAttribute(attribute) !== value)
2019-10-03 04:13:12 +08:00
node.setAttribute(attribute, value);
}
function set_attributes(node, attributes) {
// @ts-ignore
const descriptors = Object.getOwnPropertyDescriptors(node.__proto__);
2019-10-03 04:13:12 +08:00
for (const key in attributes) {
if (attributes[key] == null) {
node.removeAttribute(key);
}
else if (key === 'style') {
2019-10-03 04:13:12 +08:00
node.style.cssText = attributes[key];
}
2020-05-30 21:19:58 +08:00
else if (key === '__value' || descriptors[key] && descriptors[key].set) {
2019-10-03 04:13:12 +08:00
node[key] = attributes[key];
}
else {
attr(node, key, attributes[key]);
}
}
}
function set_svg_attributes(node, attributes) {
for (const key in attributes) {
attr(node, key, attributes[key]);
}
}
function set_custom_element_data(node, prop, value) {
if (prop in node) {
node[prop] = value;
}
else {
attr(node, prop, value);
}
}
function xlink_attr(node, attribute, value) {
node.setAttributeNS('http://www.w3.org/1999/xlink', attribute, value);
}
function get_binding_group_value(group) {
const value = [];
for (let i = 0; i < group.length; i += 1) {
if (group[i].checked)
value.push(group[i].__value);
}
return value;
}
function to_number(value) {
return value === '' ? undefined : +value;
}
function time_ranges_to_array(ranges) {
const array = [];
for (let i = 0; i < ranges.length; i += 1) {
array.push({ start: ranges.start(i), end: ranges.end(i) });
}
return array;
}
function children(element) {
return Array.from(element.childNodes);
}
function claim_element(nodes, name, attributes, svg) {
for (let i = 0; i < nodes.length; i += 1) {
const node = nodes[i];
if (node.nodeName === name) {
2020-05-30 21:19:58 +08:00
let j = 0;
while (j < node.attributes.length) {
2019-10-03 04:13:12 +08:00
const attribute = node.attributes[j];
2020-05-30 21:19:58 +08:00
if (attributes[attribute.name]) {
j++;
}
else {
2019-10-03 04:13:12 +08:00
node.removeAttribute(attribute.name);
2020-05-30 21:19:58 +08:00
}
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
return nodes.splice(i, 1)[0];
2019-10-03 04:13:12 +08:00
}
}
return svg ? svg_element(name) : element(name);
}
function claim_text(nodes, data) {
for (let i = 0; i < nodes.length; i += 1) {
const node = nodes[i];
if (node.nodeType === 3) {
node.data = '' + data;
return nodes.splice(i, 1)[0];
}
}
return text(data);
}
function claim_space(nodes) {
return claim_text(nodes, ' ');
}
function set_data(text, data) {
data = '' + data;
if (text.data !== data)
text.data = data;
}
function set_input_value(input, value) {
if (value != null || input.value) {
input.value = value;
}
}
function set_input_type(input, type) {
try {
input.type = type;
}
catch (e) {
// do nothing
}
}
function set_style(node, key, value, important) {
node.style.setProperty(key, value, important ? 'important' : '');
}
function select_option(select, value) {
for (let i = 0; i < select.options.length; i += 1) {
const option = select.options[i];
if (option.__value === value) {
option.selected = true;
return;
}
}
}
function select_options(select, value) {
for (let i = 0; i < select.options.length; i += 1) {
const option = select.options[i];
option.selected = ~value.indexOf(option.__value);
}
}
function select_value(select) {
const selected_option = select.querySelector(':checked') || select.options[0];
return selected_option && selected_option.__value;
}
function select_multiple_value(select) {
return [].map.call(select.querySelectorAll(':checked'), option => option.__value);
}
function add_resize_listener(element, fn) {
if (getComputedStyle(element).position === 'static') {
element.style.position = 'relative';
}
const object = document.createElement('object');
object.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;');
object.setAttribute('aria-hidden', 'true');
2019-10-03 04:13:12 +08:00
object.type = 'text/html';
object.tabIndex = -1;
let win;
object.onload = () => {
win = object.contentDocument.defaultView;
win.addEventListener('resize', fn);
};
if (/Trident/.test(navigator.userAgent)) {
element.appendChild(object);
object.data = 'about:blank';
}
else {
object.data = 'about:blank';
element.appendChild(object);
}
return {
cancel: () => {
win && win.removeEventListener && win.removeEventListener('resize', fn);
element.removeChild(object);
}
};
}
function toggle_class(element, name, toggle) {
element.classList[toggle ? 'add' : 'remove'](name);
}
function custom_event(type, detail) {
const e = document.createEvent('CustomEvent');
e.initCustomEvent(type, false, false, detail);
return e;
}
2020-05-30 21:19:58 +08:00
function query_selector_all(selector, parent = document.body) {
return Array.from(parent.querySelectorAll(selector));
}
2019-10-03 04:13:12 +08:00
class HtmlTag {
constructor(html, anchor = null) {
this.e = element('div');
this.a = anchor;
this.u(html);
}
m(target, anchor = null) {
for (let i = 0; i < this.n.length; i += 1) {
insert(target, this.n[i], anchor);
}
this.t = target;
}
u(html) {
this.e.innerHTML = html;
this.n = Array.from(this.e.childNodes);
}
p(html) {
this.d();
this.u(html);
this.m(this.t, this.a);
}
d() {
this.n.forEach(detach);
}
}
let stylesheet;
let active = 0;
let current_rules = {};
// https://github.com/darkskyapp/string-hash/blob/master/index.js
function hash(str) {
let hash = 5381;
let i = str.length;
while (i--)
hash = ((hash << 5) - hash) ^ str.charCodeAt(i);
return hash >>> 0;
}
function create_rule(node, a, b, duration, delay, ease, fn, uid = 0) {
const step = 16.666 / duration;
let keyframes = '{\n';
for (let p = 0; p <= 1; p += step) {
const t = a + (b - a) * ease(p);
keyframes += p * 100 + `%{${fn(t, 1 - t)}}\n`;
}
const rule = keyframes + `100% {${fn(b, 1 - b)}}\n}`;
const name = `__svelte_${hash(rule)}_${uid}`;
if (!current_rules[name]) {
if (!stylesheet) {
const style = element('style');
document.head.appendChild(style);
stylesheet = style.sheet;
}
current_rules[name] = true;
stylesheet.insertRule(`@keyframes ${name} ${rule}`, stylesheet.cssRules.length);
}
const animation = node.style.animation || '';
node.style.animation = `${animation ? `${animation}, ` : ``}${name} ${duration}ms linear ${delay}ms 1 both`;
active += 1;
return name;
}
function delete_rule(node, name) {
node.style.animation = (node.style.animation || '')
.split(', ')
.filter(name
? anim => anim.indexOf(name) < 0 // remove specific animation
: anim => anim.indexOf('__svelte') === -1 // remove all Svelte animations
)
.join(', ');
if (name && !--active)
clear_rules();
}
function clear_rules() {
raf(() => {
if (active)
return;
let i = stylesheet.cssRules.length;
while (i--)
stylesheet.deleteRule(i);
current_rules = {};
});
}
function create_animation(node, from, fn, params) {
if (!from)
return noop;
const to = node.getBoundingClientRect();
if (from.left === to.left && from.right === to.right && from.top === to.top && from.bottom === to.bottom)
return noop;
const { delay = 0, duration = 300, easing = identity,
// @ts-ignore todo: should this be separated from destructuring? Or start/end added to public api and documentation?
start: start_time = now() + delay,
// @ts-ignore todo:
end = start_time + duration, tick = noop, css } = fn(node, { from, to }, params);
let running = true;
let started = false;
let name;
function start() {
if (css) {
name = create_rule(node, 0, 1, duration, delay, easing, css);
}
if (!delay) {
started = true;
}
}
function stop() {
if (css)
delete_rule(node, name);
running = false;
}
loop(now => {
if (!started && now >= start_time) {
started = true;
}
if (started && now >= end) {
tick(1, 0);
stop();
}
if (!running) {
return false;
}
if (started) {
const p = now - start_time;
const t = 0 + 1 * easing(p / duration);
tick(t, 1 - t);
}
return true;
});
start();
tick(0, 1);
return stop;
}
function fix_position(node) {
const style = getComputedStyle(node);
if (style.position !== 'absolute' && style.position !== 'fixed') {
const { width, height } = style;
const a = node.getBoundingClientRect();
node.style.position = 'absolute';
node.style.width = width;
node.style.height = height;
add_transform(node, a);
}
}
function add_transform(node, a) {
const b = node.getBoundingClientRect();
if (a.left !== b.left || a.top !== b.top) {
const style = getComputedStyle(node);
const transform = style.transform === 'none' ? '' : style.transform;
node.style.transform = `${transform} translate(${a.left - b.left}px, ${a.top - b.top}px)`;
}
}
let current_component;
function set_current_component(component) {
current_component = component;
}
function get_current_component() {
if (!current_component)
throw new Error(`Function called outside component initialization`);
return current_component;
}
function beforeUpdate(fn) {
get_current_component().$$.before_update.push(fn);
}
function onMount(fn) {
get_current_component().$$.on_mount.push(fn);
}
function afterUpdate(fn) {
get_current_component().$$.after_update.push(fn);
}
function onDestroy(fn) {
get_current_component().$$.on_destroy.push(fn);
}
function createEventDispatcher() {
const component = get_current_component();
2019-10-03 04:13:12 +08:00
return (type, detail) => {
const callbacks = component.$$.callbacks[type];
if (callbacks) {
// TODO are there situations where events could be dispatched
// in a server (non-DOM) environment?
const event = custom_event(type, detail);
callbacks.slice().forEach(fn => {
fn.call(component, event);
});
}
};
}
function setContext(key, context) {
get_current_component().$$.context.set(key, context);
}
function getContext(key) {
return get_current_component().$$.context.get(key);
}
// TODO figure out if we still want to support
// shorthand events, or if we want to implement
// a real bubbling mechanism
function bubble(component, event) {
const callbacks = component.$$.callbacks[event.type];
if (callbacks) {
callbacks.slice().forEach(fn => fn(event));
}
}
const dirty_components = [];
const intros = { enabled: false };
const binding_callbacks = [];
const render_callbacks = [];
const flush_callbacks = [];
const resolved_promise = Promise.resolve();
let update_scheduled = false;
function schedule_update() {
if (!update_scheduled) {
update_scheduled = true;
resolved_promise.then(flush);
}
}
function tick() {
schedule_update();
return resolved_promise;
}
function add_render_callback(fn) {
render_callbacks.push(fn);
}
function add_flush_callback(fn) {
flush_callbacks.push(fn);
}
2020-05-30 21:19:58 +08:00
let flushing = false;
const seen_callbacks = new Set();
2019-10-03 04:13:12 +08:00
function flush() {
2020-05-30 21:19:58 +08:00
if (flushing)
return;
flushing = true;
2019-10-03 04:13:12 +08:00
do {
// first, call beforeUpdate functions
// and update components
2020-05-30 21:19:58 +08:00
for (let i = 0; i < dirty_components.length; i += 1) {
const component = dirty_components[i];
2019-10-03 04:13:12 +08:00
set_current_component(component);
update(component.$$);
}
2020-05-30 21:19:58 +08:00
dirty_components.length = 0;
2019-10-03 04:13:12 +08:00
while (binding_callbacks.length)
binding_callbacks.pop()();
// then, once components are updated, call
// afterUpdate functions. This may cause
// subsequent updates...
for (let i = 0; i < render_callbacks.length; i += 1) {
const callback = render_callbacks[i];
if (!seen_callbacks.has(callback)) {
// ...so guard against infinite loops
seen_callbacks.add(callback);
2020-05-30 21:19:58 +08:00
callback();
2019-10-03 04:13:12 +08:00
}
}
render_callbacks.length = 0;
} while (dirty_components.length);
while (flush_callbacks.length) {
flush_callbacks.pop()();
}
update_scheduled = false;
2020-05-30 21:19:58 +08:00
flushing = false;
seen_callbacks.clear();
2019-10-03 04:13:12 +08:00
}
function update($$) {
if ($$.fragment !== null) {
$$.update();
2019-10-03 04:13:12 +08:00
run_all($$.before_update);
const dirty = $$.dirty;
$$.dirty = [-1];
$$.fragment && $$.fragment.p($$.ctx, dirty);
2019-10-03 04:13:12 +08:00
$$.after_update.forEach(add_render_callback);
}
}
let promise;
function wait() {
if (!promise) {
promise = Promise.resolve();
promise.then(() => {
promise = null;
});
}
return promise;
}
function dispatch(node, direction, kind) {
node.dispatchEvent(custom_event(`${direction ? 'intro' : 'outro'}${kind}`));
}
const outroing = new Set();
let outros;
function group_outros() {
outros = {
r: 0,
c: [],
p: outros // parent group
};
}
function check_outros() {
if (!outros.r) {
run_all(outros.c);
}
outros = outros.p;
}
function transition_in(block, local) {
if (block && block.i) {
outroing.delete(block);
block.i(local);
}
}
function transition_out(block, local, detach, callback) {
if (block && block.o) {
if (outroing.has(block))
return;
outroing.add(block);
outros.c.push(() => {
outroing.delete(block);
if (callback) {
if (detach)
block.d(1);
callback();
}
});
block.o(local);
}
}
const null_transition = { duration: 0 };
function create_in_transition(node, fn, params) {
let config = fn(node, params);
let running = false;
let animation_name;
let task;
let uid = 0;
function cleanup() {
if (animation_name)
delete_rule(node, animation_name);
}
function go() {
const { delay = 0, duration = 300, easing = identity, tick = noop, css } = config || null_transition;
if (css)
animation_name = create_rule(node, 0, 1, duration, delay, easing, css, uid++);
tick(0, 1);
const start_time = now() + delay;
const end_time = start_time + duration;
if (task)
task.abort();
running = true;
add_render_callback(() => dispatch(node, true, 'start'));
task = loop(now => {
if (running) {
if (now >= end_time) {
tick(1, 0);
dispatch(node, true, 'end');
cleanup();
return running = false;
}
if (now >= start_time) {
const t = easing((now - start_time) / duration);
tick(t, 1 - t);
}
}
return running;
});
}
let started = false;
return {
start() {
if (started)
return;
delete_rule(node);
if (is_function(config)) {
config = config();
wait().then(go);
}
else {
go();
}
},
invalidate() {
started = false;
},
end() {
if (running) {
cleanup();
running = false;
}
}
};
}
function create_out_transition(node, fn, params) {
let config = fn(node, params);
let running = true;
let animation_name;
const group = outros;
group.r += 1;
function go() {
const { delay = 0, duration = 300, easing = identity, tick = noop, css } = config || null_transition;
if (css)
animation_name = create_rule(node, 1, 0, duration, delay, easing, css);
const start_time = now() + delay;
const end_time = start_time + duration;
add_render_callback(() => dispatch(node, false, 'start'));
loop(now => {
if (running) {
if (now >= end_time) {
tick(0, 1);
dispatch(node, false, 'end');
if (!--group.r) {
// this will result in `end()` being called,
// so we don't need to clean up here
run_all(group.c);
}
return false;
}
if (now >= start_time) {
const t = easing((now - start_time) / duration);
tick(1 - t, t);
}
}
return running;
});
}
if (is_function(config)) {
wait().then(() => {
// @ts-ignore
config = config();
go();
});
}
else {
go();
}
return {
end(reset) {
if (reset && config.tick) {
config.tick(1, 0);
}
if (running) {
if (animation_name)
delete_rule(node, animation_name);
running = false;
}
}
};
}
function create_bidirectional_transition(node, fn, params, intro) {
let config = fn(node, params);
let t = intro ? 0 : 1;
let running_program = null;
let pending_program = null;
let animation_name = null;
function clear_animation() {
if (animation_name)
delete_rule(node, animation_name);
}
function init(program, duration) {
const d = program.b - t;
duration *= Math.abs(d);
return {
a: t,
b: program.b,
d,
duration,
start: program.start,
end: program.start + duration,
group: program.group
};
}
function go(b) {
const { delay = 0, duration = 300, easing = identity, tick = noop, css } = config || null_transition;
const program = {
start: now() + delay,
b
};
if (!b) {
// @ts-ignore todo: improve typings
program.group = outros;
outros.r += 1;
}
if (running_program) {
pending_program = program;
}
else {
// if this is an intro, and there's a delay, we need to do
// an initial tick and/or apply CSS animation immediately
if (css) {
clear_animation();
animation_name = create_rule(node, t, b, duration, delay, easing, css);
}
if (b)
tick(0, 1);
running_program = init(program, duration);
add_render_callback(() => dispatch(node, b, 'start'));
loop(now => {
if (pending_program && now > pending_program.start) {
running_program = init(pending_program, duration);
pending_program = null;
dispatch(node, running_program.b, 'start');
if (css) {
clear_animation();
animation_name = create_rule(node, t, running_program.b, running_program.duration, 0, easing, config.css);
}
}
if (running_program) {
if (now >= running_program.end) {
tick(t = running_program.b, 1 - t);
dispatch(node, running_program.b, 'end');
if (!pending_program) {
// we're done
if (running_program.b) {
// intro — we can tidy up immediately
clear_animation();
}
else {
// outro — needs to be coordinated
if (!--running_program.group.r)
run_all(running_program.group.c);
}
}
running_program = null;
}
else if (now >= running_program.start) {
const p = now - running_program.start;
t = running_program.a + running_program.d * easing(p / running_program.duration);
tick(t, 1 - t);
}
}
return !!(running_program || pending_program);
});
}
}
return {
run(b) {
if (is_function(config)) {
wait().then(() => {
// @ts-ignore
config = config();
go(b);
});
}
else {
go(b);
}
},
end() {
clear_animation();
running_program = pending_program = null;
}
};
}
function handle_promise(promise, info) {
const token = info.token = {};
function update(type, index, key, value) {
if (info.token !== token)
return;
info.resolved = value;
let child_ctx = info.ctx;
if (key !== undefined) {
child_ctx = child_ctx.slice();
child_ctx[key] = value;
}
2019-10-03 04:13:12 +08:00
const block = type && (info.current = type)(child_ctx);
let needs_flush = false;
2019-10-03 04:13:12 +08:00
if (info.block) {
if (info.blocks) {
info.blocks.forEach((block, i) => {
if (i !== index && block) {
group_outros();
transition_out(block, 1, 1, () => {
info.blocks[i] = null;
});
check_outros();
}
});
}
else {
info.block.d(1);
}
block.c();
transition_in(block, 1);
block.m(info.mount(), info.anchor);
needs_flush = true;
2019-10-03 04:13:12 +08:00
}
info.block = block;
if (info.blocks)
info.blocks[index] = block;
if (needs_flush) {
flush();
}
2019-10-03 04:13:12 +08:00
}
if (is_promise(promise)) {
const current_component = get_current_component();
promise.then(value => {
set_current_component(current_component);
update(info.then, 1, info.value, value);
set_current_component(null);
}, error => {
set_current_component(current_component);
update(info.catch, 2, info.error, error);
set_current_component(null);
});
// if we previously had a then/catch block, destroy it
if (info.current !== info.pending) {
update(info.pending, 0);
return true;
}
}
else {
if (info.current !== info.then) {
update(info.then, 1, info.value, promise);
return true;
}
info.resolved = promise;
2019-10-03 04:13:12 +08:00
}
}
const globals = (typeof window !== 'undefined' ? window : global);
function destroy_block(block, lookup) {
block.d(1);
lookup.delete(block.key);
}
function outro_and_destroy_block(block, lookup) {
transition_out(block, 1, 1, () => {
lookup.delete(block.key);
});
}
function fix_and_destroy_block(block, lookup) {
block.f();
destroy_block(block, lookup);
}
function fix_and_outro_and_destroy_block(block, lookup) {
block.f();
outro_and_destroy_block(block, lookup);
}
function update_keyed_each(old_blocks, dirty, get_key, dynamic, ctx, list, lookup, node, destroy, create_each_block, next, get_context) {
2019-10-03 04:13:12 +08:00
let o = old_blocks.length;
let n = list.length;
let i = o;
const old_indexes = {};
while (i--)
old_indexes[old_blocks[i].key] = i;
const new_blocks = [];
const new_lookup = new Map();
const deltas = new Map();
i = n;
while (i--) {
const child_ctx = get_context(ctx, list, i);
const key = get_key(child_ctx);
let block = lookup.get(key);
if (!block) {
block = create_each_block(key, child_ctx);
block.c();
}
else if (dynamic) {
block.p(child_ctx, dirty);
2019-10-03 04:13:12 +08:00
}
new_lookup.set(key, new_blocks[i] = block);
if (key in old_indexes)
deltas.set(key, Math.abs(i - old_indexes[key]));
}
const will_move = new Set();
const did_move = new Set();
function insert(block) {
transition_in(block, 1);
block.m(node, next);
lookup.set(block.key, block);
next = block.first;
n--;
}
while (o && n) {
const new_block = new_blocks[n - 1];
const old_block = old_blocks[o - 1];
const new_key = new_block.key;
const old_key = old_block.key;
if (new_block === old_block) {
// do nothing
next = new_block.first;
o--;
n--;
}
else if (!new_lookup.has(old_key)) {
// remove old block
destroy(old_block, lookup);
o--;
}
else if (!lookup.has(new_key) || will_move.has(new_key)) {
insert(new_block);
}
else if (did_move.has(old_key)) {
o--;
}
else if (deltas.get(new_key) > deltas.get(old_key)) {
did_move.add(new_key);
insert(new_block);
}
else {
will_move.add(old_key);
o--;
}
}
while (o--) {
const old_block = old_blocks[o];
if (!new_lookup.has(old_block.key))
destroy(old_block, lookup);
}
while (n)
insert(new_blocks[n - 1]);
return new_blocks;
}
2020-05-30 21:19:58 +08:00
function validate_each_keys(ctx, list, get_context, get_key) {
const keys = new Set();
for (let i = 0; i < list.length; i++) {
const key = get_key(get_context(ctx, list, i));
if (keys.has(key)) {
throw new Error(`Cannot have duplicate keys in a keyed each`);
}
keys.add(key);
}
2019-10-03 04:13:12 +08:00
}
function get_spread_update(levels, updates) {
const update = {};
const to_null_out = {};
const accounted_for = { $$scope: 1 };
let i = levels.length;
while (i--) {
const o = levels[i];
const n = updates[i];
if (n) {
for (const key in o) {
if (!(key in n))
to_null_out[key] = 1;
}
for (const key in n) {
if (!accounted_for[key]) {
update[key] = n[key];
accounted_for[key] = 1;
}
}
levels[i] = n;
}
else {
for (const key in o) {
accounted_for[key] = 1;
}
}
}
for (const key in to_null_out) {
if (!(key in update))
update[key] = undefined;
}
return update;
}
function get_spread_object(spread_props) {
return typeof spread_props === 'object' && spread_props !== null ? spread_props : {};
}
// source: https://html.spec.whatwg.org/multipage/indices.html
const boolean_attributes = new Set([
'allowfullscreen',
'allowpaymentrequest',
'async',
'autofocus',
'autoplay',
'checked',
'controls',
'default',
'defer',
'disabled',
'formnovalidate',
'hidden',
'ismap',
'loop',
'multiple',
'muted',
'nomodule',
'novalidate',
'open',
'playsinline',
'readonly',
'required',
'reversed',
'selected'
]);
2019-10-03 04:13:12 +08:00
const invalid_attribute_name_character = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
// https://infra.spec.whatwg.org/#noncharacter
function spread(args, classes_to_add) {
2019-10-03 04:13:12 +08:00
const attributes = Object.assign({}, ...args);
if (classes_to_add) {
if (attributes.class == null) {
attributes.class = classes_to_add;
}
else {
attributes.class += ' ' + classes_to_add;
}
}
2019-10-03 04:13:12 +08:00
let str = '';
Object.keys(attributes).forEach(name => {
if (invalid_attribute_name_character.test(name))
return;
const value = attributes[name];
if (value === true)
str += " " + name;
else if (boolean_attributes.has(name.toLowerCase())) {
if (value)
str += " " + name;
}
else if (value != null) {
2020-05-30 21:19:58 +08:00
str += ` ${name}="${String(value).replace(/"/g, '&#34;').replace(/'/g, '&#39;')}"`;
}
2019-10-03 04:13:12 +08:00
});
return str;
}
const escaped = {
'"': '&quot;',
"'": '&#39;',
'&': '&amp;',
'<': '&lt;',
'>': '&gt;'
};
function escape$1(html) {
return String(html).replace(/["'&<>]/g, match => escaped[match]);
}
function each(items, fn) {
let str = '';
for (let i = 0; i < items.length; i += 1) {
str += fn(items[i], i);
}
return str;
}
const missing_component = {
$$render: () => ''
};
function validate_component(component, name) {
if (!component || !component.$$render) {
if (name === 'svelte:component')
name += ' this={...}';
throw new Error(`<${name}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`);
}
return component;
}
function debug(file, line, column, values) {
console.log(`{@debug} ${file ? file + ' ' : ''}(${line}:${column})`); // eslint-disable-line no-console
console.log(values); // eslint-disable-line no-console
return '';
}
let on_destroy;
function create_ssr_component(fn) {
function $$render(result, props, bindings, slots) {
const parent_component = current_component;
const $$ = {
on_destroy,
context: new Map(parent_component ? parent_component.$$.context : []),
// these will be immediately discarded
on_mount: [],
before_update: [],
after_update: [],
callbacks: blank_object()
};
set_current_component({ $$ });
const html = fn(result, props, bindings, slots);
set_current_component(parent_component);
return html;
}
return {
render: (props = {}, options = {}) => {
on_destroy = [];
2020-05-30 21:19:58 +08:00
const result = { title: '', head: '', css: new Set() };
2019-10-03 04:13:12 +08:00
const html = $$render(result, props, {}, options);
run_all(on_destroy);
return {
html,
css: {
code: Array.from(result.css).map(css => css.code).join('\n'),
map: null // TODO
},
2020-05-30 21:19:58 +08:00
head: result.title + result.head
2019-10-03 04:13:12 +08:00
};
},
$$render
};
}
function add_attribute(name, value, boolean) {
if (value == null || (boolean && !value))
return '';
return ` ${name}${value === true ? '' : `=${typeof value === 'string' ? JSON.stringify(escape$1(value)) : `"${value}"`}`}`;
}
function add_classes(classes) {
return classes ? ` class="${classes}"` : ``;
}
function bind(component, name, callback) {
const index = component.$$.props[name];
if (index !== undefined) {
component.$$.bound[index] = callback;
callback(component.$$.ctx[index]);
}
}
function create_component(block) {
block && block.c();
}
function claim_component(block, parent_nodes) {
block && block.l(parent_nodes);
2019-10-03 04:13:12 +08:00
}
function mount_component(component, target, anchor) {
const { fragment, on_mount, on_destroy, after_update } = component.$$;
fragment && fragment.m(target, anchor);
2019-10-03 04:13:12 +08:00
// onMount happens before the initial afterUpdate
add_render_callback(() => {
const new_on_destroy = on_mount.map(run).filter(is_function);
if (on_destroy) {
on_destroy.push(...new_on_destroy);
}
else {
// Edge case - component was destroyed immediately,
// most likely as a result of a binding initialising
run_all(new_on_destroy);
}
component.$$.on_mount = [];
});
after_update.forEach(add_render_callback);
}
function destroy_component(component, detaching) {
const $$ = component.$$;
if ($$.fragment !== null) {
run_all($$.on_destroy);
$$.fragment && $$.fragment.d(detaching);
2019-10-03 04:13:12 +08:00
// TODO null out other refs, including component.$$ (but need to
// preserve final state?)
$$.on_destroy = $$.fragment = null;
$$.ctx = [];
2019-10-03 04:13:12 +08:00
}
}
function make_dirty(component, i) {
if (component.$$.dirty[0] === -1) {
2019-10-03 04:13:12 +08:00
dirty_components.push(component);
schedule_update();
component.$$.dirty.fill(0);
2019-10-03 04:13:12 +08:00
}
component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31));
2019-10-03 04:13:12 +08:00
}
function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) {
2019-10-03 04:13:12 +08:00
const parent_component = current_component;
set_current_component(component);
const prop_values = options.props || {};
2019-10-03 04:13:12 +08:00
const $$ = component.$$ = {
fragment: null,
ctx: null,
// state
props,
2019-10-03 04:13:12 +08:00
update: noop,
not_equal,
bound: blank_object(),
// lifecycle
on_mount: [],
on_destroy: [],
before_update: [],
after_update: [],
context: new Map(parent_component ? parent_component.$$.context : []),
// everything else
callbacks: blank_object(),
dirty
2019-10-03 04:13:12 +08:00
};
let ready = false;
$$.ctx = instance
2020-05-30 21:19:58 +08:00
? instance(component, prop_values, (i, ret, ...rest) => {
const value = rest.length ? rest[0] : ret;
if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
if ($$.bound[i])
$$.bound[i](value);
2019-10-03 04:13:12 +08:00
if (ready)
make_dirty(component, i);
2019-10-03 04:13:12 +08:00
}
return ret;
})
: [];
2019-10-03 04:13:12 +08:00
$$.update();
ready = true;
run_all($$.before_update);
// `false` as a special case of no DOM component
$$.fragment = create_fragment ? create_fragment($$.ctx) : false;
2019-10-03 04:13:12 +08:00
if (options.target) {
if (options.hydrate) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
$$.fragment && $$.fragment.l(children(options.target));
2019-10-03 04:13:12 +08:00
}
else {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
$$.fragment && $$.fragment.c();
2019-10-03 04:13:12 +08:00
}
if (options.intro)
transition_in(component.$$.fragment);
mount_component(component, options.target, options.anchor);
flush();
}
set_current_component(parent_component);
}
let SvelteElement;
if (typeof HTMLElement === 'function') {
2019-10-03 04:13:12 +08:00
SvelteElement = class extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
// @ts-ignore todo: improve typings
for (const key in this.$$.slotted) {
// @ts-ignore todo: improve typings
this.appendChild(this.$$.slotted[key]);
}
}
attributeChangedCallback(attr, _oldValue, newValue) {
this[attr] = newValue;
}
$destroy() {
destroy_component(this, 1);
this.$destroy = noop;
}
$on(type, callback) {
// TODO should this delegate to addEventListener?
const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
callbacks.push(callback);
return () => {
const index = callbacks.indexOf(callback);
if (index !== -1)
callbacks.splice(index, 1);
};
}
$set() {
// overridden by instance, if it has props
}
};
}
class SvelteComponent {
$destroy() {
destroy_component(this, 1);
this.$destroy = noop;
}
$on(type, callback) {
const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
callbacks.push(callback);
return () => {
const index = callbacks.indexOf(callback);
if (index !== -1)
callbacks.splice(index, 1);
};
}
$set() {
// overridden by instance, if it has props
}
}
function dispatch_dev(type, detail) {
2020-05-30 21:19:58 +08:00
document.dispatchEvent(custom_event(type, Object.assign({ version: '3.19.2' }, detail)));
2019-10-03 04:13:12 +08:00
}
function append_dev(target, node) {
dispatch_dev("SvelteDOMInsert", { target, node });
append(target, node);
}
function insert_dev(target, node, anchor) {
dispatch_dev("SvelteDOMInsert", { target, node, anchor });
insert(target, node, anchor);
}
function detach_dev(node) {
dispatch_dev("SvelteDOMRemove", { node });
detach(node);
}
function detach_between_dev(before, after) {
while (before.nextSibling && before.nextSibling !== after) {
detach_dev(before.nextSibling);
}
}
function detach_before_dev(after) {
while (after.previousSibling) {
detach_dev(after.previousSibling);
}
}
function detach_after_dev(before) {
while (before.nextSibling) {
detach_dev(before.nextSibling);
}
}
function listen_dev(node, event, handler, options, has_prevent_default, has_stop_propagation) {
const modifiers = options === true ? ["capture"] : options ? Array.from(Object.keys(options)) : [];
if (has_prevent_default)
modifiers.push('preventDefault');
if (has_stop_propagation)
modifiers.push('stopPropagation');
dispatch_dev("SvelteDOMAddEventListener", { node, event, handler, modifiers });
const dispose = listen(node, event, handler, options);
return () => {
dispatch_dev("SvelteDOMRemoveEventListener", { node, event, handler, modifiers });
dispose();
};
}
function attr_dev(node, attribute, value) {
attr(node, attribute, value);
if (value == null)
dispatch_dev("SvelteDOMRemoveAttribute", { node, attribute });
else
dispatch_dev("SvelteDOMSetAttribute", { node, attribute, value });
}
function prop_dev(node, property, value) {
node[property] = value;
dispatch_dev("SvelteDOMSetProperty", { node, property, value });
}
function dataset_dev(node, property, value) {
node.dataset[property] = value;
dispatch_dev("SvelteDOMSetDataset", { node, property, value });
}
function set_data_dev(text, data) {
data = '' + data;
if (text.data === data)
return;
dispatch_dev("SvelteDOMSetData", { node: text, data });
text.data = data;
}
2020-05-30 21:19:58 +08:00
function validate_each_argument(arg) {
if (typeof arg !== 'string' && !(arg && typeof arg === 'object' && 'length' in arg)) {
let msg = '{#each} only iterates over array-like objects.';
if (typeof Symbol === 'function' && arg && Symbol.iterator in arg) {
msg += ' You can use a spread to convert this iterable into an array.';
}
throw new Error(msg);
}
}
function validate_slots(name, slot, keys) {
for (const slot_key of Object.keys(slot)) {
if (!~keys.indexOf(slot_key)) {
console.warn(`<${name}> received an unexpected slot "${slot_key}".`);
}
}
}
2019-10-03 04:13:12 +08:00
class SvelteComponentDev extends SvelteComponent {
constructor(options) {
if (!options || (!options.target && !options.$$inline)) {
throw new Error(`'target' is a required option`);
}
super();
}
$destroy() {
super.$destroy();
this.$destroy = () => {
console.warn(`Component was already destroyed`); // eslint-disable-line no-console
};
}
2020-05-30 21:19:58 +08:00
$capture_state() { }
$inject_state() { }
2019-10-03 04:13:12 +08:00
}
function loop_guard(timeout) {
const start = Date.now();
return () => {
if (Date.now() - start > timeout) {
throw new Error(`Infinite loop detected`);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function commonjsRequire () {
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
function unwrapExports (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function getCjsExportFromNamespace (n) {
return n && n['default'] || n;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
'use strict';
var strictUriEncode = str => encodeURIComponent(str).replace(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
'use strict';
var token = '%[a-f0-9]{2}';
var singleMatcher = new RegExp(token, 'gi');
var multiMatcher = new RegExp('(' + token + ')+', 'gi');
function decodeComponents(components, split) {
try {
// Try to decode the entire string first
return decodeURIComponent(components.join(''));
} catch (err) {
// Do nothing
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (components.length === 1) {
return components;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
split = split || 1;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Split the array in 2 parts
var left = components.slice(0, split);
var right = components.slice(split);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function decode(input) {
try {
return decodeURIComponent(input);
} catch (err) {
var tokens = input.match(singleMatcher);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (var i = 1; i < tokens.length; i++) {
input = decodeComponents(tokens, i).join('');
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
tokens = input.match(singleMatcher);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return input;
}
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
function customDecodeURIComponent(input) {
// Keep track of all the replacements and prefill the map with the `BOM`
var replaceMap = {
'%FE%FF': '\uFFFD\uFFFD',
'%FF%FE': '\uFFFD\uFFFD'
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var match = multiMatcher.exec(input);
while (match) {
try {
// Decode as big chunks as possible
replaceMap[match[0]] = decodeURIComponent(match[0]);
} catch (err) {
var result = decode(match[0]);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (result !== match[0]) {
replaceMap[match[0]] = result;
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
match = multiMatcher.exec(input);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else
replaceMap['%C2'] = '\uFFFD';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var entries = Object.keys(replaceMap);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (var i = 0; i < entries.length; i++) {
// Replace all decoded components
var key = entries[i];
input = input.replace(new RegExp(key, 'g'), replaceMap[key]);
}
return input;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
var decodeUriComponent = function (encodedURI) {
if (typeof encodedURI !== 'string') {
throw new TypeError('Expected `encodedURI` to be of type `string`, got `' + typeof encodedURI + '`');
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
try {
encodedURI = encodedURI.replace(/\+/g, ' ');
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Try the built in decoder first
return decodeURIComponent(encodedURI);
} catch (err) {
// Fallback to a more advanced decoder
return customDecodeURIComponent(encodedURI);
}
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
'use strict';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var splitOnFirst = (string, separator) => {
if (!(typeof string === 'string' && typeof separator === 'string')) {
throw new TypeError('Expected the arguments to be of type `string`');
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (separator === '') {
return [string];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const separatorIndex = string.indexOf(separator);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (separatorIndex === -1) {
return [string];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return [
string.slice(0, separatorIndex),
string.slice(separatorIndex + separator.length)
];
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var queryString = createCommonjsModule(function (module, exports) {
'use strict';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function encoderForArrayFormat(options) {
switch (options.arrayFormat) {
case 'index':
return key => (result, value) => {
const index = result.length;
if (value === undefined || (options.skipNull && value === null)) {
return result;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (value === null) {
return [...result, [encode(key, options), '[', index, ']'].join('')];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return [
...result,
[encode(key, options), '[', encode(index, options), ']=', encode(value, options)].join('')
];
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
case 'bracket':
return key => (result, value) => {
if (value === undefined || (options.skipNull && value === null)) {
return result;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (value === null) {
return [...result, [encode(key, options), '[]'].join('')];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return [...result, [encode(key, options), '[]=', encode(value, options)].join('')];
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
case 'comma':
case 'separator':
return key => (result, value) => {
if (value === null || value === undefined || value.length === 0) {
return result;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (result.length === 0) {
return [[encode(key, options), '=', encode(value, options)].join('')];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return [[result, encode(value, options)].join(options.arrayFormatSeparator)];
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
default:
return key => (result, value) => {
if (value === undefined || (options.skipNull && value === null)) {
return result;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (value === null) {
return [...result, encode(key, options)];
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
return [...result, [encode(key, options), '=', encode(value, options)].join('')];
};
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function parserForArrayFormat(options) {
let result;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
switch (options.arrayFormat) {
case 'index':
return (key, value, accumulator) => {
result = /\[(\d*)\]$/.exec(key);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
key = key.replace(/\[\d*\]$/, '');
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!result) {
accumulator[key] = value;
return;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (accumulator[key] === undefined) {
accumulator[key] = {};
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
accumulator[key][result[1]] = value;
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
case 'bracket':
return (key, value, accumulator) => {
result = /(\[\])$/.exec(key);
key = key.replace(/\[\]$/, '');
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!result) {
accumulator[key] = value;
return;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (accumulator[key] === undefined) {
accumulator[key] = [value];
return;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
accumulator[key] = [].concat(accumulator[key], value);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
case 'comma':
case 'separator':
return (key, value, accumulator) => {
const isArray = typeof value === 'string' && value.split('').indexOf(options.arrayFormatSeparator) > -1;
const newValue = isArray ? value.split(options.arrayFormatSeparator).map(item => decode(item, options)) : value === null ? value : decode(value, options);
accumulator[key] = newValue;
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
default:
return (key, value, accumulator) => {
if (accumulator[key] === undefined) {
accumulator[key] = value;
return;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
accumulator[key] = [].concat(accumulator[key], value);
};
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function validateArrayFormatSeparator(value) {
if (typeof value !== 'string' || value.length !== 1) {
throw new TypeError('arrayFormatSeparator must be single character string');
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function encode(value, options) {
if (options.encode) {
return options.strict ? strictUriEncode(value) : encodeURIComponent(value);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return value;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function decode(value, options) {
if (options.decode) {
return decodeUriComponent(value);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return value;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function keysSorter(input) {
if (Array.isArray(input)) {
return input.sort();
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (typeof input === 'object') {
return keysSorter(Object.keys(input))
.sort((a, b) => Number(a) - Number(b))
.map(key => input[key]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return input;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function removeHash(input) {
const hashStart = input.indexOf('#');
if (hashStart !== -1) {
input = input.slice(0, hashStart);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return input;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function getHash(url) {
let hash = '';
const hashStart = url.indexOf('#');
if (hashStart !== -1) {
hash = url.slice(hashStart);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return hash;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function extract(input) {
input = removeHash(input);
const queryStart = input.indexOf('?');
if (queryStart === -1) {
return '';
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return input.slice(queryStart + 1);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function parseValue(value, options) {
if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === 'string' && value.trim() !== '')) {
value = Number(value);
} else if (options.parseBooleans && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
value = value.toLowerCase() === 'true';
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return value;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function parse(input, options) {
options = Object.assign({
decode: true,
sort: true,
arrayFormat: 'none',
arrayFormatSeparator: ',',
parseNumbers: false,
parseBooleans: false
}, options);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
validateArrayFormatSeparator(options.arrayFormatSeparator);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const formatter = parserForArrayFormat(options);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Create an object with no prototype
const ret = Object.create(null);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (typeof input !== 'string') {
return ret;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
input = input.trim().replace(/^[?#&]/, '');
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!input) {
return ret;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (const param of input.split('&')) {
let [key, value] = splitOnFirst(options.decode ? param.replace(/\+/g, ' ') : param, '=');
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Missing `=` should be `null`:
// http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
value = value === undefined ? null : options.arrayFormat === 'comma' ? value : decode(value, options);
formatter(decode(key, options), value, ret);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (const key of Object.keys(ret)) {
const value = ret[key];
if (typeof value === 'object' && value !== null) {
for (const k of Object.keys(value)) {
value[k] = parseValue(value[k], options);
}
} else {
ret[key] = parseValue(value, options);
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (options.sort === false) {
return ret;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => {
const value = ret[key];
if (Boolean(value) && typeof value === 'object' && !Array.isArray(value)) {
// Sort object keys, not values
result[key] = keysSorter(value);
} else {
result[key] = value;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return result;
}, Object.create(null));
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
exports.extract = extract;
exports.parse = parse;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
exports.stringify = (object, options) => {
if (!object) {
return '';
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
options = Object.assign({
encode: true,
strict: true,
arrayFormat: 'none',
arrayFormatSeparator: ','
}, options);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
validateArrayFormatSeparator(options.arrayFormatSeparator);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const formatter = encoderForArrayFormat(options);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const objectCopy = Object.assign({}, object);
if (options.skipNull) {
for (const key of Object.keys(objectCopy)) {
if (objectCopy[key] === undefined || objectCopy[key] === null) {
delete objectCopy[key];
}
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const keys = Object.keys(objectCopy);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (options.sort !== false) {
keys.sort(options.sort);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return keys.map(key => {
const value = object[key];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (value === undefined) {
return '';
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (value === null) {
return encode(key, options);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (Array.isArray(value)) {
return value
.reduce(formatter(key), [])
.join('&');
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return encode(key, options) + '=' + encode(value, options);
}).filter(x => x.length > 0).join('&');
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
exports.parseUrl = (input, options) => {
return {
url: removeHash(input).split('?')[0] || '',
query: parse(extract(input), options)
};
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
exports.stringifyUrl = (input, options) => {
const url = removeHash(input.url).split('?')[0] || '';
const queryFromUrl = exports.extract(input.url);
const parsedQueryFromUrl = exports.parse(queryFromUrl);
const hash = getHash(input.url);
const query = Object.assign(parsedQueryFromUrl, input.query);
let queryString = exports.stringify(query, options);
if (queryString) {
queryString = `?${queryString}`;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return `${url}${queryString}${hash}`;
};
});
var queryString_1 = queryString.extract;
var queryString_2 = queryString.parse;
var queryString_3 = queryString.stringify;
var queryString_4 = queryString.parseUrl;
var queryString_5 = queryString.stringifyUrl;
var index_umd = createCommonjsModule(function (module, exports) {
(function (global, factory) {
'object' === 'object' && 'object' !== 'undefined' ? module.exports = factory() :
typeof undefined === 'function' && undefined.amd ? undefined(factory) :
(global = global || self, global.AbstractNestedRouter = factory());
}(commonjsGlobal, function () { 'use strict';
var defaultExport = /*@__PURE__*/(function (Error) {
function defaultExport(route, path) {
var message = "Unreachable '" + route + "', segment '" + path + "' is not defined";
Error.call(this, message);
this.message = message;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if ( Error ) defaultExport.__proto__ = Error;
defaultExport.prototype = Object.create( Error && Error.prototype );
defaultExport.prototype.constructor = defaultExport;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return defaultExport;
}(Error));
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function buildMatcher(path, parent) {
var regex;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var _isSplat;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var _priority = -100;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var keys = [];
regex = path.replace(/[-$.]/g, '\\$&').replace(/\(/g, '(?:').replace(/\)/g, ')?').replace(/([:*]\w+)(?:<([^<>]+?)>)?/g, function (_, key, expr) {
keys.push(key.substr(1));
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (key.charAt() === ':') {
_priority += 100;
return ("((?!#)" + (expr || '[^#/]+?') + ")");
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
_isSplat = true;
_priority += 500;
return ("((?!#)" + (expr || '[^#]+?') + ")");
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
try {
regex = new RegExp(("^" + regex + "$"));
} catch (e) {
throw new TypeError(("Invalid route expression, given '" + parent + "'"));
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var _hashed = path.includes('#') ? 0.5 : 1;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var _depth = path.length * _priority * _hashed;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
keys: keys,
regex: regex,
_depth: _depth,
_isSplat: _isSplat
};
}
var PathMatcher = function PathMatcher(path, parent) {
var ref = buildMatcher(path, parent);
var keys = ref.keys;
var regex = ref.regex;
var _depth = ref._depth;
var _isSplat = ref._isSplat;
return {
_isSplat: _isSplat,
_depth: _depth,
match: function (value) {
var matches = value.match(regex);
if (matches) {
return keys.reduce(function (prev, cur, i) {
prev[cur] = typeof matches[i + 1] === 'string' ? decodeURIComponent(matches[i + 1]) : null;
return prev;
}, {});
}
}
};
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
PathMatcher.push = function push (key, prev, leaf, parent) {
var root = prev[key] || (prev[key] = {});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!root.pattern) {
root.pattern = new PathMatcher(key, parent);
root.route = (leaf || '').replace(/\/$/, '') || '/';
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
prev.keys = prev.keys || [];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!prev.keys.includes(key)) {
prev.keys.push(key);
PathMatcher.sort(prev);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return root;
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
PathMatcher.sort = function sort (root) {
root.keys.sort(function (a, b) {
return root[a].pattern._depth - root[b].pattern._depth;
});
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function merge(path, parent) {
return ("" + (parent && parent !== '/' ? parent : '') + (path || ''));
}
function walk(path, cb) {
var matches = path.match(/<[^<>]*\/[^<>]*>/);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (matches) {
throw new TypeError(("RegExp cannot contain slashes, given '" + matches + "'"));
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var parts = path.split(/(?=\/|#)/);
var root = [];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (parts[0] !== '/') {
parts.unshift('/');
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
parts.some(function (x, i) {
var parent = root.slice(1).concat(x).join('') || null;
var segment = parts.slice(i + 1).join('') || null;
var retval = cb(x, parent, segment ? ("" + (x !== '/' ? x : '') + segment) : null);
root.push(x);
return retval;
});
}
function reduce(key, root, _seen) {
var params = {};
var out = [];
var splat;
walk(key, function (x, leaf, extra) {
var found;
if (!root.keys) {
throw new defaultExport(key, x);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
root.keys.some(function (k) {
if (_seen.includes(k)) { return false; }
var ref = root[k].pattern;
var match = ref.match;
var _isSplat = ref._isSplat;
var matches = match(_isSplat ? extra || x : x);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (matches) {
Object.assign(params, matches);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (root[k].route) {
var routeInfo = Object.assign({}, root[k].info); // properly handle exact-routes!
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var hasMatch = false;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (routeInfo.exact) {
hasMatch = extra === null;
} else {
hasMatch = !(x && leaf === null) || x === leaf || _isSplat || !extra;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
routeInfo.matches = hasMatch;
routeInfo.params = Object.assign({}, params);
routeInfo.route = root[k].route;
routeInfo.path = _isSplat && extra || leaf || x;
out.push(routeInfo);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (extra === null && !root[k].keys) {
return true;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (k !== '/') { _seen.push(k); }
splat = _isSplat;
root = root[k];
found = true;
return true;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return false;
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!(found || root.keys.some(function (k) { return root[k].pattern.match(x); }))) {
throw new defaultExport(key, x);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return splat || !found;
});
return out;
}
function find(path, routes, retries) {
var get = reduce.bind(null, path, routes);
var set = [];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
while (retries > 0) {
retries -= 1;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
try {
return get(set);
} catch (e) {
if (retries > 0) {
return get(set);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
throw e;
}
}
}
function add(path, routes, parent, routeInfo) {
var fullpath = merge(path, parent);
var root = routes;
var key;
if (routeInfo && routeInfo.nested !== true) {
key = routeInfo.key;
delete routeInfo.key;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
walk(fullpath, function (x, leaf) {
root = PathMatcher.push(x, root, leaf, fullpath);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (x !== '/') {
root.info = root.info || Object.assign({}, routeInfo);
}
});
root.info = root.info || Object.assign({}, routeInfo);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (key) {
root.info.key = key;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return fullpath;
}
function rm(path, routes, parent) {
var fullpath = merge(path, parent);
var root = routes;
var leaf = null;
var key = null;
walk(fullpath, function (x) {
if (!root) {
leaf = null;
return true;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!root.keys) {
throw new defaultExport(path, x);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
key = x;
leaf = root;
root = root[key];
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!(leaf && key)) {
throw new defaultExport(path, key);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (leaf === routes) {
leaf = routes['/'];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (leaf.route !== key) {
var offset = leaf.keys.indexOf(key);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (offset === -1) {
throw new defaultExport(path, key);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
leaf.keys.splice(offset, 1);
PathMatcher.sort(leaf);
delete leaf[key];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (root.route === leaf.route) {
delete leaf.info;
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var Router = function Router() {
var routes = {};
var stack = [];
return {
resolve: function (path, cb) {
var url = path.split('?')[0];
var seen = [];
walk(url, function (x, leaf, extra) {
try {
cb(null, find(leaf, routes, 1).filter(function (r) {
if (!seen.includes(r.route)) {
seen.push(r.route);
return true;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return false;
}));
} catch (e) {
cb(e, []);
}
});
},
mount: function (path, cb) {
if (path !== '/') {
stack.push(path);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
cb();
stack.pop();
},
find: function (path, retries) { return find(path, routes, retries === true ? 2 : retries || 1); },
add: function (path, routeInfo) { return add(path, routes, stack.join(''), routeInfo); },
rm: function (path) { return rm(path, routes, stack.join('')); }
};
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Router.matches = function matches (uri, path) {
return buildMatcher(uri, path).regex.test(path);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return Router;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
}));
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const subscriber_queue = [];
/**
* Creates a `Readable` store that allows reading by subscription.
* @param value initial value
* @param {StartStopNotifier}start start and stop notifications for subscriptions
*/
function readable(value, start) {
return {
subscribe: writable(value, start).subscribe,
};
}
/**
* Create a `Writable` store that allows both updating and reading by subscription.
* @param {*=}value initial value
* @param {StartStopNotifier=}start start and stop notifications for subscriptions
*/
function writable(value, start = noop) {
let stop;
const subscribers = [];
function set(new_value) {
if (safe_not_equal(value, new_value)) {
value = new_value;
if (stop) { // store is ready
const run_queue = !subscriber_queue.length;
for (let i = 0; i < subscribers.length; i += 1) {
const s = subscribers[i];
s[1]();
subscriber_queue.push(s, value);
}
if (run_queue) {
for (let i = 0; i < subscriber_queue.length; i += 2) {
subscriber_queue[i][0](subscriber_queue[i + 1]);
}
subscriber_queue.length = 0;
}
}
}
}
function update(fn) {
set(fn(value));
}
function subscribe(run, invalidate = noop) {
const subscriber = [run, invalidate];
subscribers.push(subscriber);
if (subscribers.length === 1) {
stop = start(set) || noop;
}
run(value);
return () => {
const index = subscribers.indexOf(subscriber);
if (index !== -1) {
subscribers.splice(index, 1);
}
if (subscribers.length === 0) {
stop();
stop = null;
}
};
}
return { set, update, subscribe };
}
function derived(stores, fn, initial_value) {
const single = !Array.isArray(stores);
const stores_array = single
? [stores]
: stores;
const auto = fn.length < 2;
return readable(initial_value, (set) => {
let inited = false;
const values = [];
let pending = 0;
let cleanup = noop;
const sync = () => {
if (pending) {
return;
}
cleanup();
const result = fn(single ? values[0] : values, set);
if (auto) {
set(result);
}
else {
cleanup = is_function(result) ? result : noop;
}
};
const unsubscribers = stores_array.map((store, i) => subscribe(store, (value) => {
values[i] = value;
pending &= ~(1 << i);
if (inited) {
sync();
}
}, () => {
pending |= (1 << i);
}));
inited = true;
sync();
return function stop() {
run_all(unsubscribers);
cleanup();
};
});
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const cache = {};
const baseTag = document.getElementsByTagName('base');
const basePrefix = (baseTag[0] && baseTag[0].href.replace(/\/$/, '')) || '/';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const ROOT_URL = basePrefix.replace(window.location.origin, '');
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const router = writable({
path: '/',
query: {},
params: {},
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const CTX_ROUTER = {};
const CTX_ROUTE = {};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// use location.hash on embedded pages, e.g. Svelte REPL
let HASHCHANGE = window.location.origin === 'null';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function hashchangeEnable(value) {
if (typeof value === 'boolean') {
HASHCHANGE = !!value;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return HASHCHANGE;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
function fixedLocation(path, callback) {
const baseUri = hashchangeEnable() ? window.location.hash.replace('#', '') : window.location.pathname;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// this will rebase anchors to avoid location changes
if (path.charAt() !== '/') {
path = baseUri + path;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const currentURL = baseUri + window.location.hash + window.location.search;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// do not change location et all...
if (currentURL !== path) {
callback(path);
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function navigateTo(path, options) {
const {
reload, replace,
params, queryParams,
} = options || {};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// If path empty or no string, throws error
if (!path || typeof path !== 'string' || (path[0] !== '/' && path[0] !== '#')) {
throw new Error(`Expecting '/${path}' or '#${path}', given '${path}'`);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (params) {
path = path.replace(/:([a-zA-Z][a-zA-Z0-9_-]*)/g, (_, key) => params[key]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// rebase active URL
if (ROOT_URL !== '/' && path.indexOf(ROOT_URL) !== 0) {
path = ROOT_URL + path;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (queryParams) {
const qs = queryString.stringify(queryParams);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (qs) {
path += `?${qs}`;
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (hashchangeEnable()) {
window.location.hash = path.replace(/^#/, '');
return;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// If no History API support, fallbacks to URL redirect
if (reload || !window.history.pushState || !window.dispatchEvent) {
window.location.href = path;
return;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// If has History API support, uses it
fixedLocation(path, nextURL => {
window.history[replace ? 'replaceState' : 'pushState'](null, '', nextURL);
window.dispatchEvent(new Event('popstate'));
});
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function getProps(given, required) {
const { props: sub, ...others } = given;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// prune all declared props from this component
required = !Array.isArray(required)
? Object.keys(required)
: required;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
required.forEach(k => {
delete others[k];
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
...sub,
...others,
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function isActive(uri, path, exact) {
if (!cache[[uri, path, exact]]) {
if (exact !== true && path.indexOf(uri) === 0) {
cache[[uri, path, exact]] = /^[#/?]?$/.test(path.substr(uri.length, 1));
} else if (uri.includes('*') || uri.includes(':')) {
cache[[uri, path, exact]] = index_umd.matches(uri, path);
} else {
cache[[uri, path, exact]] = path === uri;
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return cache[[uri, path, exact]];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const baseRouter = new index_umd();
const routeInfo = writable({});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// private registries
const onError = {};
const shared = {};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
let errors = [];
let routers = 0;
let interval;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// take snapshot from current state...
router.subscribe(value => { shared.router = value; });
routeInfo.subscribe(value => { shared.routeInfo = value; });
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function doFallback(failure, fallback) {
routeInfo.update(defaults => ({
...defaults,
[fallback]: {
...shared.router,
failure,
},
}));
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function handleRoutes(map, params) {
const keys = [];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
map.some(x => {
if (x.key && x.matches && !x.fallback && !shared.routeInfo[x.key]) {
if (x.redirect && (x.condition === null || x.condition(shared.router) !== true)) {
if (x.exact && shared.router.path !== x.path) return false;
navigateTo(x.redirect);
return true;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (x.exact) {
keys.push(x.key);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// extend shared params...
Object.assign(params, x.params);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// upgrade matching routes!
routeInfo.update(defaults => ({
...defaults,
[x.key]: {
...shared.router,
...x,
},
}));
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return false;
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return keys;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function evtHandler() {
let baseUri = !hashchangeEnable() ? window.location.href.replace(window.location.origin, '') : window.location.hash || '/';
let failure;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// unprefix active URL
if (ROOT_URL !== '/') {
baseUri = baseUri.replace(ROOT_URL, '');
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const [fullpath, qs] = baseUri.replace('/#', '#').replace(/^#\//, '/').split('?');
const query = queryString.parse(qs);
const params = {};
const keys = [];
// reset current state
routeInfo.set({});
router.set({
query,
params,
path: fullpath,
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// load all matching routes...
baseRouter.resolve(fullpath, (err, result) => {
if (err) {
failure = err;
return;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// save exact-keys for deletion after failures!
keys.push(...handleRoutes(result, params));
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const toDelete = {};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (failure) {
keys.reduce((prev, cur) => {
prev[cur] = null;
return prev;
}, toDelete);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
// clear previously failed handlers
errors.forEach(cb => cb());
errors = [];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
try {
// clear routes that not longer matches!
baseRouter.find(fullpath).forEach(sub => {
if (sub.exact && !sub.matches) {
toDelete[sub.key] = null;
}
});
} catch (e) {
// this is fine
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// drop unwanted routes...
routeInfo.update(defaults => ({
...defaults,
...toDelete,
}));
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
let fallback;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// invoke error-handlers to clear out previous state!
Object.keys(onError).forEach(root => {
if (isActive(root, fullpath, false)) {
const fn = onError[root].callback;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
fn(failure);
errors.push(fn);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (!fallback && onError[root].fallback) {
fallback = onError[root].fallback;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// handle unmatched fallbacks
if (failure && fallback) {
doFallback(failure, fallback);
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function findRoutes() {
clearTimeout(interval);
interval = setTimeout(evtHandler);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function addRouter(root, fallback, callback) {
if (!routers) {
window.addEventListener('popstate', findRoutes, false);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// register error-handlers
onError[root] = { fallback, callback };
routers += 1;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return () => {
delete onError[root];
routers -= 1;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!routers) {
window.removeEventListener('popstate', findRoutes, false);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/* usr/local/lib/node_modules/snowboard/node_modules/yrv/src/Router.svelte generated by Svelte v3.19.2 */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function add_css() {
var style = element("style");
style.id = "svelte-kx2cky-style";
style.textContent = "[data-failure].svelte-kx2cky{border:1px dashed silver}";
append(document.head, style);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// (99:0) {#if !disabled}
function create_if_block_1(ctx) {
let current;
const default_slot_template = /*$$slots*/ ctx[15].default;
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[14], null);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
if (default_slot) default_slot.c();
},
m(target, anchor) {
if (default_slot) {
default_slot.m(target, anchor);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
current = true;
},
p(ctx, dirty) {
if (default_slot && default_slot.p && dirty & /*$$scope*/ 16384) {
default_slot.p(get_slot_context(default_slot_template, ctx, /*$$scope*/ ctx[14], null), get_slot_changes(default_slot_template, /*$$scope*/ ctx[14], dirty, null));
}
},
i(local) {
if (current) return;
transition_in(default_slot, local);
current = true;
},
o(local) {
transition_out(default_slot, local);
current = false;
},
d(detaching) {
if (default_slot) default_slot.d(detaching);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// (103:0) {#if failure && !fallback && !nofallback}
function create_if_block(ctx) {
let fieldset;
let legend;
let t0;
let t1;
let t2;
let pre;
let t3;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
fieldset = element("fieldset");
legend = element("legend");
t0 = text("Router failure: ");
t1 = text(/*path*/ ctx[1]);
t2 = space();
pre = element("pre");
t3 = text(/*failure*/ ctx[3]);
attr(fieldset, "data-failure", "");
attr(fieldset, "class", "svelte-kx2cky");
},
m(target, anchor) {
insert(target, fieldset, anchor);
append(fieldset, legend);
append(legend, t0);
append(legend, t1);
append(fieldset, t2);
append(fieldset, pre);
append(pre, t3);
},
p(ctx, dirty) {
if (dirty & /*path*/ 2) set_data(t1, /*path*/ ctx[1]);
if (dirty & /*failure*/ 8) set_data(t3, /*failure*/ ctx[3]);
},
d(detaching) {
if (detaching) detach(fieldset);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function create_fragment(ctx) {
let t;
let if_block1_anchor;
let current;
let if_block0 = !/*disabled*/ ctx[0] && create_if_block_1(ctx);
let if_block1 = /*failure*/ ctx[3] && !/*fallback*/ ctx[4] && !/*nofallback*/ ctx[2] && create_if_block(ctx);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
if (if_block0) if_block0.c();
t = space();
if (if_block1) if_block1.c();
if_block1_anchor = empty();
},
m(target, anchor) {
if (if_block0) if_block0.m(target, anchor);
insert(target, t, anchor);
if (if_block1) if_block1.m(target, anchor);
insert(target, if_block1_anchor, anchor);
current = true;
},
p(ctx, [dirty]) {
if (!/*disabled*/ ctx[0]) {
if (if_block0) {
if_block0.p(ctx, dirty);
transition_in(if_block0, 1);
} else {
if_block0 = create_if_block_1(ctx);
if_block0.c();
transition_in(if_block0, 1);
if_block0.m(t.parentNode, t);
}
} else if (if_block0) {
group_outros();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
transition_out(if_block0, 1, 1, () => {
if_block0 = null;
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
check_outros();
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (/*failure*/ ctx[3] && !/*fallback*/ ctx[4] && !/*nofallback*/ ctx[2]) {
if (if_block1) {
if_block1.p(ctx, dirty);
} else {
if_block1 = create_if_block(ctx);
if_block1.c();
if_block1.m(if_block1_anchor.parentNode, if_block1_anchor);
}
} else if (if_block1) {
if_block1.d(1);
if_block1 = null;
}
},
i(local) {
if (current) return;
transition_in(if_block0);
current = true;
},
o(local) {
transition_out(if_block0);
current = false;
},
d(detaching) {
if (if_block0) if_block0.d(detaching);
if (detaching) detach(t);
if (if_block1) if_block1.d(detaching);
if (detaching) detach(if_block1_anchor);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function unassignRoute(route) {
baseRouter.rm(route);
findRoutes();
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function instance($$self, $$props, $$invalidate) {
let $basePath;
let $router;
component_subscribe($$self, router, $$value => $$invalidate(9, $router = $$value));
let cleanup;
let failure;
let fallback;
let { path = "/" } = $$props;
let { disabled = false } = $$props;
let { condition = null } = $$props;
let { nofallback = false } = $$props;
const routerContext = getContext(CTX_ROUTER);
const basePath = routerContext ? routerContext.basePath : writable(path);
component_subscribe($$self, basePath, value => $$invalidate(8, $basePath = value));
const fixedRoot = $basePath !== path && $basePath !== "/"
? `${$basePath}${path !== "/" ? path : ""}`
: path;
try {
if (condition !== null && typeof condition !== "function") {
throw new TypeError(`Expecting condition to be a function, given '${condition}'`);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (path.charAt() !== "#" && path.charAt() !== "/") {
throw new TypeError(`Expecting a leading slash or hash, given '${path}'`);
}
} catch(e) {
failure = e;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function assignRoute(key, route, detail) {
key = key || Math.random().toString(36).substr(2);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// consider as nested routes if they does not have any segment
const nested = !route.substr(1).includes("/");
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const handler = { key, nested, ...detail };
let fullpath;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
baseRouter.mount(fixedRoot, () => {
fullpath = baseRouter.add(route, handler);
$$invalidate(4, fallback = handler.fallback && key || fallback);
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
findRoutes();
return [key, fullpath];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function onError(err) {
$$invalidate(3, failure = err);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (failure && fallback) {
doFallback(failure, fallback);
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
onMount(() => {
cleanup = addRouter(fixedRoot, fallback, onError);
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
onDestroy(() => {
if (cleanup) cleanup();
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
setContext(CTX_ROUTER, { basePath, assignRoute, unassignRoute });
let { $$slots = {}, $$scope } = $$props;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$set = $$props => {
if ("path" in $$props) $$invalidate(1, path = $$props.path);
if ("disabled" in $$props) $$invalidate(0, disabled = $$props.disabled);
if ("condition" in $$props) $$invalidate(6, condition = $$props.condition);
if ("nofallback" in $$props) $$invalidate(2, nofallback = $$props.nofallback);
if ("$$scope" in $$props) $$invalidate(14, $$scope = $$props.$$scope);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$$.update = () => {
if ($$self.$$.dirty & /*condition, $router*/ 576) {
if (condition) {
$$invalidate(0, disabled = !condition($router));
}
}
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return [
disabled,
path,
nofallback,
failure,
fallback,
basePath,
condition,
cleanup,
$basePath,
$router,
routerContext,
fixedRoot,
assignRoute,
onError,
$$scope,
$$slots
];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
class Router extends SvelteComponent {
constructor(options) {
super();
if (!document.getElementById("svelte-kx2cky-style")) add_css();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
init(this, options, instance, create_fragment, safe_not_equal, {
path: 1,
disabled: 0,
condition: 6,
nofallback: 2
});
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/* usr/local/lib/node_modules/snowboard/node_modules/yrv/src/Route.svelte generated by Svelte v3.19.2 */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function add_css$1() {
var style = element("style");
style.id = "svelte-7lze0z-style";
style.textContent = "[data-failure].svelte-7lze0z{color:red}";
append(document.head, style);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const get_default_slot_changes = dirty => ({
router: dirty & /*activeRouter*/ 2,
props: dirty & /*activeProps*/ 4
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const get_default_slot_context = ctx => ({
router: /*activeRouter*/ ctx[1],
props: /*activeProps*/ ctx[2]
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// (82:0) {#if failure}
function create_if_block_2(ctx) {
let p;
let t;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
p = element("p");
t = text(/*failure*/ ctx[3]);
attr(p, "data-failure", "");
attr(p, "class", "svelte-7lze0z");
},
m(target, anchor) {
insert(target, p, anchor);
append(p, t);
},
p(ctx, dirty) {
if (dirty & /*failure*/ 8) set_data(t, /*failure*/ ctx[3]);
},
d(detaching) {
if (detaching) detach(p);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// (86:0) {#if activeRouter}
function create_if_block$1(ctx) {
let current_block_type_index;
let if_block;
let if_block_anchor;
let current;
const if_block_creators = [create_if_block_1$1, create_else_block];
const if_blocks = [];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function select_block_type(ctx, dirty) {
if (/*component*/ ctx[0]) return 0;
return 1;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
current_block_type_index = select_block_type(ctx, -1);
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
if_block.c();
if_block_anchor = empty();
},
m(target, anchor) {
if_blocks[current_block_type_index].m(target, anchor);
insert(target, if_block_anchor, anchor);
current = true;
},
p(ctx, dirty) {
let previous_block_index = current_block_type_index;
current_block_type_index = select_block_type(ctx, dirty);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (current_block_type_index === previous_block_index) {
if_blocks[current_block_type_index].p(ctx, dirty);
} else {
group_outros();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
transition_out(if_blocks[previous_block_index], 1, 1, () => {
if_blocks[previous_block_index] = null;
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
check_outros();
if_block = if_blocks[current_block_type_index];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!if_block) {
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
if_block.c();
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
transition_in(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
},
i(local) {
if (current) return;
transition_in(if_block);
current = true;
},
o(local) {
transition_out(if_block);
current = false;
},
d(detaching) {
if_blocks[current_block_type_index].d(detaching);
if (detaching) detach(if_block_anchor);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// (89:2) {:else}
function create_else_block(ctx) {
let current;
const default_slot_template = /*$$slots*/ ctx[22].default;
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[21], get_default_slot_context);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
if (default_slot) default_slot.c();
},
m(target, anchor) {
if (default_slot) {
default_slot.m(target, anchor);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
current = true;
},
p(ctx, dirty) {
if (default_slot && default_slot.p && dirty & /*$$scope, activeRouter, activeProps*/ 2097158) {
default_slot.p(get_slot_context(default_slot_template, ctx, /*$$scope*/ ctx[21], get_default_slot_context), get_slot_changes(default_slot_template, /*$$scope*/ ctx[21], dirty, get_default_slot_changes));
}
},
i(local) {
if (current) return;
transition_in(default_slot, local);
current = true;
},
o(local) {
transition_out(default_slot, local);
current = false;
},
d(detaching) {
if (default_slot) default_slot.d(detaching);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// (87:2) {#if component}
function create_if_block_1$1(ctx) {
let switch_instance_anchor;
let current;
const switch_instance_spread_levels = [{ router: /*activeRouter*/ ctx[1] }, /*activeProps*/ ctx[2]];
var switch_value = /*component*/ ctx[0];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function switch_props(ctx) {
let switch_instance_props = {};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (let i = 0; i < switch_instance_spread_levels.length; i += 1) {
switch_instance_props = assign(switch_instance_props, switch_instance_spread_levels[i]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return { props: switch_instance_props };
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (switch_value) {
var switch_instance = new switch_value(switch_props(ctx));
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
if (switch_instance) create_component(switch_instance.$$.fragment);
switch_instance_anchor = empty();
},
m(target, anchor) {
if (switch_instance) {
mount_component(switch_instance, target, anchor);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
insert(target, switch_instance_anchor, anchor);
current = true;
},
p(ctx, dirty) {
const switch_instance_changes = (dirty & /*activeRouter, activeProps*/ 6)
? get_spread_update(switch_instance_spread_levels, [
dirty & /*activeRouter*/ 2 && { router: /*activeRouter*/ ctx[1] },
dirty & /*activeProps*/ 4 && get_spread_object(/*activeProps*/ ctx[2])
])
: {};
if (switch_value !== (switch_value = /*component*/ ctx[0])) {
if (switch_instance) {
group_outros();
const old_component = switch_instance;
transition_out(old_component.$$.fragment, 1, 0, () => {
destroy_component(old_component, 1);
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
check_outros();
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (switch_value) {
switch_instance = new switch_value(switch_props(ctx));
create_component(switch_instance.$$.fragment);
transition_in(switch_instance.$$.fragment, 1);
mount_component(switch_instance, switch_instance_anchor.parentNode, switch_instance_anchor);
} else {
switch_instance = null;
}
} else if (switch_value) {
switch_instance.$set(switch_instance_changes);
}
},
i(local) {
if (current) return;
if (switch_instance) transition_in(switch_instance.$$.fragment, local);
current = true;
},
o(local) {
if (switch_instance) transition_out(switch_instance.$$.fragment, local);
current = false;
},
d(detaching) {
if (detaching) detach(switch_instance_anchor);
if (switch_instance) destroy_component(switch_instance, detaching);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function create_fragment$1(ctx) {
let t;
let if_block1_anchor;
let current;
let if_block0 = /*failure*/ ctx[3] && create_if_block_2(ctx);
let if_block1 = /*activeRouter*/ ctx[1] && create_if_block$1(ctx);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
if (if_block0) if_block0.c();
t = space();
if (if_block1) if_block1.c();
if_block1_anchor = empty();
},
m(target, anchor) {
if (if_block0) if_block0.m(target, anchor);
insert(target, t, anchor);
if (if_block1) if_block1.m(target, anchor);
insert(target, if_block1_anchor, anchor);
current = true;
},
p(ctx, [dirty]) {
if (/*failure*/ ctx[3]) {
if (if_block0) {
if_block0.p(ctx, dirty);
} else {
if_block0 = create_if_block_2(ctx);
if_block0.c();
if_block0.m(t.parentNode, t);
}
} else if (if_block0) {
if_block0.d(1);
if_block0 = null;
}
if (/*activeRouter*/ ctx[1]) {
if (if_block1) {
if_block1.p(ctx, dirty);
transition_in(if_block1, 1);
} else {
if_block1 = create_if_block$1(ctx);
if_block1.c();
transition_in(if_block1, 1);
if_block1.m(if_block1_anchor.parentNode, if_block1_anchor);
}
} else if (if_block1) {
group_outros();
transition_out(if_block1, 1, 1, () => {
if_block1 = null;
});
check_outros();
}
},
i(local) {
if (current) return;
transition_in(if_block1);
current = true;
},
o(local) {
transition_out(if_block1);
current = false;
},
d(detaching) {
if (if_block0) if_block0.d(detaching);
if (detaching) detach(t);
if (if_block1) if_block1.d(detaching);
if (detaching) detach(if_block1_anchor);
}
};
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
function instance$1($$self, $$props, $$invalidate) {
let $routePath;
let $routeInfo;
component_subscribe($$self, routeInfo, $$value => $$invalidate(14, $routeInfo = $$value));
let { key = null } = $$props;
let { path = "/" } = $$props;
let { exact = null } = $$props;
let { disabled = false } = $$props;
let { fallback = null } = $$props;
let { component = null } = $$props;
let { condition = null } = $$props;
let { redirect = null } = $$props;
const routeContext = getContext(CTX_ROUTE);
const routerContext = getContext(CTX_ROUTER);
const { assignRoute, unassignRoute } = routerContext || {};
const routePath = routeContext ? routeContext.routePath : writable(path);
component_subscribe($$self, routePath, value => $$invalidate(13, $routePath = value));
let activeRouter = null;
let activeProps = {};
let fullpath;
let failure;
const fixedRoot = $routePath !== path && $routePath !== "/"
? `${$routePath}${path !== "/" ? path : ""}`
: path;
try {
if (redirect !== null && !(/^(?:\w+:\/\/|\/)/).test(redirect)) {
throw new TypeError(`Expecting valid URL to redirect, given '${redirect}'`);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (condition !== null && typeof condition !== "function") {
throw new TypeError(`Expecting condition to be a function, given '${condition}'`);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (path.charAt() !== "#" && path.charAt() !== "/") {
throw new TypeError(`Expecting a leading slash or hash, given '${path}'`);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!assignRoute) {
throw new TypeError(`Missing top-level <Router>, given route: ${path}`);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
[key, fullpath] = assignRoute(key, fixedRoot, { condition, redirect, fallback, exact });
} catch(e) {
failure = e;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
onDestroy(() => {
if (unassignRoute) {
unassignRoute(fullpath);
}
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
setContext(CTX_ROUTE, { routePath });
let { $$slots = {}, $$scope } = $$props;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$set = $$new_props => {
$$invalidate(20, $$props = assign(assign({}, $$props), exclude_internal_props($$new_props)));
if ("key" in $$new_props) $$invalidate(5, key = $$new_props.key);
if ("path" in $$new_props) $$invalidate(6, path = $$new_props.path);
if ("exact" in $$new_props) $$invalidate(7, exact = $$new_props.exact);
if ("disabled" in $$new_props) $$invalidate(8, disabled = $$new_props.disabled);
if ("fallback" in $$new_props) $$invalidate(9, fallback = $$new_props.fallback);
if ("component" in $$new_props) $$invalidate(0, component = $$new_props.component);
if ("condition" in $$new_props) $$invalidate(10, condition = $$new_props.condition);
if ("redirect" in $$new_props) $$invalidate(11, redirect = $$new_props.redirect);
if ("$$scope" in $$new_props) $$invalidate(21, $$scope = $$new_props.$$scope);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$$.update = () => {
if (key) {
/* global arguments */
$$invalidate(1, activeRouter = !disabled && $routeInfo[key]);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$invalidate(2, activeProps = getProps($$props, arguments[0].$$.props));
}
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$props = exclude_internal_props($$props);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return [
component,
activeRouter,
activeProps,
failure,
routePath,
key,
path,
exact,
disabled,
fallback,
condition,
redirect,
fullpath,
$routePath,
$routeInfo,
routeContext,
routerContext,
assignRoute,
unassignRoute,
fixedRoot,
$$props,
$$scope,
$$slots
];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
class Route extends SvelteComponent {
constructor(options) {
super();
if (!document.getElementById("svelte-7lze0z-style")) add_css$1();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
init(this, options, instance$1, create_fragment$1, safe_not_equal, {
key: 5,
path: 6,
exact: 7,
disabled: 8,
fallback: 9,
component: 0,
condition: 10,
redirect: 11
});
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/* usr/local/lib/node_modules/snowboard/node_modules/yrv/src/Link.svelte generated by Svelte v3.19.2 */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function create_else_block$1(ctx) {
let a;
let current;
let dispose;
const default_slot_template = /*$$slots*/ ctx[18].default;
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[17], null);
let a_levels = [
/*fixedProps*/ ctx[5],
{ href: /*fixedHref*/ ctx[4] },
{ class: /*className*/ ctx[0] },
{ title: /*title*/ ctx[1] }
];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
let a_data = {};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (let i = 0; i < a_levels.length; i += 1) {
a_data = assign(a_data, a_levels[i]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
a = element("a");
if (default_slot) default_slot.c();
set_attributes(a, a_data);
},
m(target, anchor) {
insert(target, a, anchor);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (default_slot) {
default_slot.m(a, null);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/*a_binding*/ ctx[20](a);
current = true;
dispose = listen(a, "click", prevent_default(/*onClick*/ ctx[6]));
},
p(ctx, dirty) {
if (default_slot && default_slot.p && dirty & /*$$scope*/ 131072) {
default_slot.p(get_slot_context(default_slot_template, ctx, /*$$scope*/ ctx[17], null), get_slot_changes(default_slot_template, /*$$scope*/ ctx[17], dirty, null));
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
set_attributes(a, get_spread_update(a_levels, [
dirty & /*fixedProps*/ 32 && /*fixedProps*/ ctx[5],
dirty & /*fixedHref*/ 16 && { href: /*fixedHref*/ ctx[4] },
dirty & /*className*/ 1 && { class: /*className*/ ctx[0] },
dirty & /*title*/ 2 && { title: /*title*/ ctx[1] }
]));
},
i(local) {
if (current) return;
transition_in(default_slot, local);
current = true;
},
o(local) {
transition_out(default_slot, local);
current = false;
},
d(detaching) {
if (detaching) detach(a);
if (default_slot) default_slot.d(detaching);
/*a_binding*/ ctx[20](null);
dispose();
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// (73:0) {#if button}
function create_if_block$2(ctx) {
let button_1;
let current;
let dispose;
const default_slot_template = /*$$slots*/ ctx[18].default;
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[17], null);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
let button_1_levels = [
/*fixedProps*/ ctx[5],
{ class: /*className*/ ctx[0] },
{ title: /*title*/ ctx[1] }
];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
let button_1_data = {};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (let i = 0; i < button_1_levels.length; i += 1) {
button_1_data = assign(button_1_data, button_1_levels[i]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
button_1 = element("button");
if (default_slot) default_slot.c();
set_attributes(button_1, button_1_data);
},
m(target, anchor) {
insert(target, button_1, anchor);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (default_slot) {
default_slot.m(button_1, null);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/*button_1_binding*/ ctx[19](button_1);
current = true;
dispose = listen(button_1, "click", prevent_default(/*onClick*/ ctx[6]));
},
p(ctx, dirty) {
if (default_slot && default_slot.p && dirty & /*$$scope*/ 131072) {
default_slot.p(get_slot_context(default_slot_template, ctx, /*$$scope*/ ctx[17], null), get_slot_changes(default_slot_template, /*$$scope*/ ctx[17], dirty, null));
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
set_attributes(button_1, get_spread_update(button_1_levels, [
dirty & /*fixedProps*/ 32 && /*fixedProps*/ ctx[5],
dirty & /*className*/ 1 && { class: /*className*/ ctx[0] },
dirty & /*title*/ 2 && { title: /*title*/ ctx[1] }
]));
},
i(local) {
if (current) return;
transition_in(default_slot, local);
current = true;
},
o(local) {
transition_out(default_slot, local);
current = false;
},
d(detaching) {
if (detaching) detach(button_1);
if (default_slot) default_slot.d(detaching);
/*button_1_binding*/ ctx[19](null);
dispose();
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function create_fragment$2(ctx) {
let current_block_type_index;
let if_block;
let if_block_anchor;
let current;
const if_block_creators = [create_if_block$2, create_else_block$1];
const if_blocks = [];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function select_block_type(ctx, dirty) {
if (/*button*/ ctx[2]) return 0;
return 1;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
current_block_type_index = select_block_type(ctx, -1);
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
if_block.c();
if_block_anchor = empty();
},
m(target, anchor) {
if_blocks[current_block_type_index].m(target, anchor);
insert(target, if_block_anchor, anchor);
current = true;
},
p(ctx, [dirty]) {
let previous_block_index = current_block_type_index;
current_block_type_index = select_block_type(ctx, dirty);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (current_block_type_index === previous_block_index) {
if_blocks[current_block_type_index].p(ctx, dirty);
} else {
group_outros();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
transition_out(if_blocks[previous_block_index], 1, 1, () => {
if_blocks[previous_block_index] = null;
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
check_outros();
if_block = if_blocks[current_block_type_index];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!if_block) {
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
if_block.c();
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
transition_in(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
},
i(local) {
if (current) return;
transition_in(if_block);
current = true;
},
o(local) {
transition_out(if_block);
current = false;
},
d(detaching) {
if_blocks[current_block_type_index].d(detaching);
if (detaching) detach(if_block_anchor);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function instance$2($$self, $$props, $$invalidate) {
let $router;
component_subscribe($$self, router, $$value => $$invalidate(14, $router = $$value));
let ref;
let active;
let { class: cssClass = "" } = $$props;
let fixedHref = null;
let { go = null } = $$props;
let { href = "/" } = $$props;
let { title = "" } = $$props;
let { button = false } = $$props;
let { exact = false } = $$props;
let { reload = false } = $$props;
let { replace = false } = $$props;
let { className = "" } = $$props;
onMount(() => {
$$invalidate(0, className = className || cssClass);
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const dispatch = createEventDispatcher();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// this will enable `<Link on:click={...} />` calls
function onClick(e) {
if (typeof go === "string" && window.history.length > 1) {
if (go === "back") window.history.back(); else if (go === "fwd") window.history.forward(); else window.history.go(parseInt(go, 10));
return;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
fixedLocation(href, nextURL => {
navigateTo(nextURL, { reload, replace });
dispatch("click", e);
});
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
let { $$slots = {}, $$scope } = $$props;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function button_1_binding($$value) {
binding_callbacks[$$value ? "unshift" : "push"](() => {
$$invalidate(3, ref = $$value);
});
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function a_binding($$value) {
binding_callbacks[$$value ? "unshift" : "push"](() => {
$$invalidate(3, ref = $$value);
});
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$set = $$new_props => {
$$invalidate(16, $$props = assign(assign({}, $$props), exclude_internal_props($$new_props)));
if ("class" in $$new_props) $$invalidate(7, cssClass = $$new_props.class);
if ("go" in $$new_props) $$invalidate(8, go = $$new_props.go);
if ("href" in $$new_props) $$invalidate(9, href = $$new_props.href);
if ("title" in $$new_props) $$invalidate(1, title = $$new_props.title);
if ("button" in $$new_props) $$invalidate(2, button = $$new_props.button);
if ("exact" in $$new_props) $$invalidate(10, exact = $$new_props.exact);
if ("reload" in $$new_props) $$invalidate(11, reload = $$new_props.reload);
if ("replace" in $$new_props) $$invalidate(12, replace = $$new_props.replace);
if ("className" in $$new_props) $$invalidate(0, className = $$new_props.className);
if ("$$scope" in $$new_props) $$invalidate(17, $$scope = $$new_props.$$scope);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
let fixedProps;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$$.update = () => {
if ($$self.$$.dirty & /*href*/ 512) {
// rebase active URL
if (ROOT_URL !== "/") {
$$invalidate(4, fixedHref = ROOT_URL + href);
} else {
$$invalidate(4, fixedHref = href);
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if ($$self.$$.dirty & /*ref, $router, href, exact, active, button*/ 26124) {
if (ref && $router.path) {
if (isActive(href, $router.path, exact)) {
if (!active) {
$$invalidate(13, active = true);
ref.setAttribute("aria-current", "page");
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (button) {
ref.setAttribute("disabled", true);
}
}
} else if (active) {
$$invalidate(13, active = false);
ref.removeAttribute("disabled");
ref.removeAttribute("aria-current");
}
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// extract additional props
/* global arguments */
$$invalidate(5, fixedProps = getProps($$props, arguments[0].$$.props));
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$props = exclude_internal_props($$props);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return [
className,
title,
button,
ref,
fixedHref,
fixedProps,
onClick,
cssClass,
go,
href,
exact,
reload,
replace,
active,
$router,
dispatch,
$$props,
$$scope,
$$slots,
button_1_binding,
a_binding
];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
class Link extends SvelteComponent {
constructor(options) {
super();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
init(this, options, instance$2, create_fragment$2, safe_not_equal, {
class: 7,
go: 8,
href: 9,
title: 1,
button: 2,
exact: 10,
reload: 11,
replace: 12,
className: 0
});
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Object.defineProperty(Router, 'hashchange', {
set: value => hashchangeEnable(value),
get: () => hashchangeEnable(),
configurable: false,
enumerable: false,
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
'use strict';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var has = Object.prototype.hasOwnProperty
, undef;
2019-10-03 04:13:12 +08:00
/**
2020-05-30 21:19:58 +08:00
* Decode a URI encoded string.
*
* @param {String} input The URI encoded string.
* @returns {String|Null} The decoded string.
* @api private
2019-10-03 04:13:12 +08:00
*/
2020-05-30 21:19:58 +08:00
function decode$1(input) {
try {
return decodeURIComponent(input.replace(/\+/g, ' '));
} catch (e) {
return null;
}
2019-10-03 04:13:12 +08:00
}
/**
2020-05-30 21:19:58 +08:00
* Attempts to encode a given input.
*
* @param {String} input The string that needs to be encoded.
* @returns {String|Null} The encoded string.
* @api private
2019-10-03 04:13:12 +08:00
*/
2020-05-30 21:19:58 +08:00
function encode(input) {
try {
return encodeURIComponent(input);
} catch (e) {
return null;
}
}
2019-10-03 04:13:12 +08:00
/**
2020-05-30 21:19:58 +08:00
* Simple query string parser.
*
* @param {String} query The query string that needs to be parsed.
* @returns {Object}
* @api public
2019-10-03 04:13:12 +08:00
*/
2020-05-30 21:19:58 +08:00
function querystring(query) {
var parser = /([^=?&]+)=?([^&]*)/g
, result = {}
, part;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
while (part = parser.exec(query)) {
var key = decode$1(part[1])
, value = decode$1(part[2]);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
//
// Prevent overriding of existing properties. This ensures that build-in
// methods like `toString` or __proto__ are not overriden by malicious
// querystrings.
//
// In the case if failed decoding, we want to omit the key/value pairs
// from the result.
//
if (key === null || value === null || key in result) continue;
result[key] = value;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
return result;
}
2019-10-03 04:13:12 +08:00
/**
2020-05-30 21:19:58 +08:00
* Transform a query string to an object.
*
* @param {Object} obj Object that should be transformed.
* @param {String} prefix Optional prefix.
* @returns {String}
* @api public
2019-10-03 04:13:12 +08:00
*/
2020-05-30 21:19:58 +08:00
function querystringify(obj, prefix) {
prefix = prefix || '';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var pairs = []
, value
, key;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
//
// Optionally prefix with a '?' if needed
//
if ('string' !== typeof prefix) prefix = '?';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (key in obj) {
if (has.call(obj, key)) {
value = obj[key];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
//
// Edge cases where we actually want to encode the value to an empty
// string instead of the stringified value.
//
if (!value && (value === null || value === undef || isNaN(value))) {
value = '';
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
key = encodeURIComponent(key);
value = encodeURIComponent(value);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
//
// If we failed to encode the strings, we should bail out as we don't
// want to add invalid strings to the query.
//
if (key === null || value === null) continue;
pairs.push(key +'='+ value);
}
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
return pairs.length ? prefix + pairs.join('&') : '';
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
//
// Expose the module.
//
var stringify = querystringify;
var parse = querystring;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var querystringify_1 = {
stringify: stringify,
parse: parse
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var prism = createCommonjsModule(function (module) {
/* **********************************************
Begin prism-core.js
********************************************** */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var _self = (typeof window !== 'undefined')
? window // if in browser
: (
(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
? self // if in worker
: {} // if in node js
);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Prism: Lightweight, robust, elegant syntax highlighting
* MIT license http://www.opensource.org/licenses/mit-license.php/
* @author Lea Verou http://lea.verou.me
*/
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var Prism = (function (_self){
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Private helper vars
var lang = /\blang(?:uage)?-([\w-]+)\b/i;
var uniqueId = 0;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var _ = {
manual: _self.Prism && _self.Prism.manual,
disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
util: {
encode: function (tokens) {
if (tokens instanceof Token) {
return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
} else if (Array.isArray(tokens)) {
return tokens.map(_.util.encode);
} else {
return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
}
},
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
type: function (o) {
return Object.prototype.toString.call(o).slice(8, -1);
},
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
objId: function (obj) {
if (!obj['__id']) {
Object.defineProperty(obj, '__id', { value: ++uniqueId });
}
return obj['__id'];
},
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Deep clone a language definition (e.g. to extend it)
clone: function deepClone(o, visited) {
var clone, id, type = _.util.type(o);
visited = visited || {};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
switch (type) {
case 'Object':
id = _.util.objId(o);
if (visited[id]) {
return visited[id];
}
clone = {};
visited[id] = clone;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (var key in o) {
if (o.hasOwnProperty(key)) {
clone[key] = deepClone(o[key], visited);
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return clone;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
case 'Array':
id = _.util.objId(o);
if (visited[id]) {
return visited[id];
}
clone = [];
visited[id] = clone;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
o.forEach(function (v, i) {
clone[i] = deepClone(v, visited);
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return clone;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
default:
return o;
}
},
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
*
* If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
*
* @param {Element} element
* @returns {string}
*/
getLanguage: function (element) {
while (element && !lang.test(element.className)) {
element = element.parentElement;
}
if (element) {
return (element.className.match(lang) || [, 'none'])[1].toLowerCase();
}
return 'none';
},
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Returns the script element that is currently executing.
*
* This does __not__ work for line script element.
*
* @returns {HTMLScriptElement | null}
*/
currentScript: function () {
if (typeof document === 'undefined') {
return null;
}
if ('currentScript' in document) {
return document.currentScript;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// IE11 workaround
// we'll get the src of the current script by parsing IE11's error stack trace
// this will not work for inline scripts
try {
throw new Error();
} catch (err) {
// Get file src url from stack. Specifically works with the format of stack traces in IE.
// A stack will look like this:
//
// Error
// at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
// at Global code (http://localhost/components/prism-core.js:606:1)
var src = (/at [^(\r\n]*\((.*):.+:.+\)$/i.exec(err.stack) || [])[1];
if (src) {
var scripts = document.getElementsByTagName('script');
for (var i in scripts) {
if (scripts[i].src == src) {
return scripts[i];
}
}
}
return null;
}
}
},
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
languages: {
extend: function (id, redef) {
var lang = _.util.clone(_.languages[id]);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (var key in redef) {
lang[key] = redef[key];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return lang;
},
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Insert a token before another token in a language literal
* As this needs to recreate the object (we cannot actually insert before keys in object literals),
* we cannot just provide an object, we need an object and a key.
* @param inside The key (or language id) of the parent
* @param before The key to insert before.
* @param insert Object with the key/value pairs to insert
* @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted.
*/
insertBefore: function (inside, before, insert, root) {
root = root || _.languages;
var grammar = root[inside];
var ret = {};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (var token in grammar) {
if (grammar.hasOwnProperty(token)) {
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (token == before) {
for (var newToken in insert) {
if (insert.hasOwnProperty(newToken)) {
ret[newToken] = insert[newToken];
}
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Do not insert token which also occur in insert. See #1525
if (!insert.hasOwnProperty(token)) {
ret[token] = grammar[token];
}
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var old = root[inside];
root[inside] = ret;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Update references in other language definitions
_.languages.DFS(_.languages, function(key, value) {
if (value === old && key != inside) {
this[key] = ret;
}
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return ret;
},
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Traverse a language definition with Depth First Search
DFS: function DFS(o, callback, type, visited) {
visited = visited || {};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var objId = _.util.objId;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (var i in o) {
if (o.hasOwnProperty(i)) {
callback.call(o, i, o[i], type || i);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var property = o[i],
propertyType = _.util.type(property);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (propertyType === 'Object' && !visited[objId(property)]) {
visited[objId(property)] = true;
DFS(property, callback, null, visited);
}
else if (propertyType === 'Array' && !visited[objId(property)]) {
visited[objId(property)] = true;
DFS(property, callback, i, visited);
}
}
}
}
},
plugins: {},
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
highlightAll: function(async, callback) {
_.highlightAllUnder(document, async, callback);
},
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
highlightAllUnder: function(container, async, callback) {
var env = {
callback: callback,
container: container,
selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
_.hooks.run('before-highlightall', env);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
_.hooks.run('before-all-elements-highlight', env);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (var i = 0, element; element = env.elements[i++];) {
_.highlightElement(element, async === true, env.callback);
}
},
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
highlightElement: function(element, async, callback) {
// Find language
var language = _.util.getLanguage(element);
var grammar = _.languages[language];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Set language on the element, if not present
element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Set language on the parent, for styling
var parent = element.parentNode;
if (parent && parent.nodeName.toLowerCase() === 'pre') {
parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var code = element.textContent;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var env = {
element: element,
language: language,
grammar: grammar,
code: code
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function insertHighlightedCode(highlightedCode) {
env.highlightedCode = highlightedCode;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
_.hooks.run('before-insert', env);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
env.element.innerHTML = env.highlightedCode;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
_.hooks.run('after-highlight', env);
_.hooks.run('complete', env);
callback && callback.call(env.element);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
_.hooks.run('before-sanity-check', env);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!env.code) {
_.hooks.run('complete', env);
callback && callback.call(env.element);
return;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
_.hooks.run('before-highlight', env);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!env.grammar) {
insertHighlightedCode(_.util.encode(env.code));
return;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (async && _self.Worker) {
var worker = new Worker(_.filename);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
worker.onmessage = function(evt) {
insertHighlightedCode(evt.data);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
worker.postMessage(JSON.stringify({
language: env.language,
code: env.code,
immediateClose: true
}));
}
else {
insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
}
},
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
highlight: function (text, grammar, language) {
var env = {
code: text,
grammar: grammar,
language: language
};
_.hooks.run('before-tokenize', env);
env.tokens = _.tokenize(env.code, env.grammar);
_.hooks.run('after-tokenize', env);
return Token.stringify(_.util.encode(env.tokens), env.language);
},
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) {
for (var token in grammar) {
if (!grammar.hasOwnProperty(token) || !grammar[token]) {
continue;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var patterns = grammar[token];
patterns = Array.isArray(patterns) ? patterns : [patterns];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (var j = 0; j < patterns.length; ++j) {
if (target && target == token + ',' + j) {
return;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var pattern = patterns[j],
inside = pattern.inside,
lookbehind = !!pattern.lookbehind,
greedy = !!pattern.greedy,
lookbehindLength = 0,
alias = pattern.alias;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (greedy && !pattern.pattern.global) {
// Without the global flag, lastIndex won't work
var flags = pattern.pattern.toString().match(/[imsuy]*$/)[0];
pattern.pattern = RegExp(pattern.pattern.source, flags + 'g');
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
pattern = pattern.pattern || pattern;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Dont cache length as it changes during the loop
for (var i = index, pos = startPos; i < strarr.length; pos += strarr[i].length, ++i) {
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var str = strarr[i];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (strarr.length > text.length) {
// Something went terribly wrong, ABORT, ABORT!
return;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (str instanceof Token) {
continue;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (greedy && i != strarr.length - 1) {
pattern.lastIndex = pos;
var match = pattern.exec(text);
if (!match) {
break;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var from = match.index + (lookbehind && match[1] ? match[1].length : 0),
to = match.index + match[0].length,
k = i,
p = pos;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (var len = strarr.length; k < len && (p < to || (!strarr[k].type && !strarr[k - 1].greedy)); ++k) {
p += strarr[k].length;
// Move the index i to the element in strarr that is closest to from
if (from >= p) {
++i;
pos = p;
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// If strarr[i] is a Token, then the match starts inside another Token, which is invalid
if (strarr[i] instanceof Token) {
continue;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Number of tokens to delete and replace with the new match
delNum = k - i;
str = text.slice(pos, p);
match.index -= pos;
} else {
pattern.lastIndex = 0;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var match = pattern.exec(str),
delNum = 1;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!match) {
if (oneshot) {
break;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
continue;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if(lookbehind) {
lookbehindLength = match[1] ? match[1].length : 0;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var from = match.index + lookbehindLength,
match = match[0].slice(lookbehindLength),
to = from + match.length,
before = str.slice(0, from),
after = str.slice(to);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var args = [i, delNum];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (before) {
++i;
pos += before.length;
args.push(before);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match, greedy);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
args.push(wrapped);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (after) {
args.push(after);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Array.prototype.splice.apply(strarr, args);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (delNum != 1)
_.matchGrammar(text, strarr, grammar, i, pos, true, token + ',' + j);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (oneshot)
break;
}
}
}
},
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
tokenize: function(text, grammar) {
var strarr = [text];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var rest = grammar.rest;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (rest) {
for (var token in rest) {
grammar[token] = rest[token];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
delete grammar.rest;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
_.matchGrammar(text, strarr, grammar, 0, 0, false);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return strarr;
},
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
hooks: {
all: {},
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
add: function (name, callback) {
var hooks = _.hooks.all;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
hooks[name] = hooks[name] || [];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
hooks[name].push(callback);
},
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
run: function (name, env) {
var callbacks = _.hooks.all[name];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!callbacks || !callbacks.length) {
return;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (var i=0, callback; callback = callbacks[i++];) {
callback(env);
}
}
},
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Token: Token
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
_self.Prism = _;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function Token(type, content, alias, matchedStr, greedy) {
this.type = type;
this.content = content;
this.alias = alias;
// Copy of the full string this token was created from
this.length = (matchedStr || '').length|0;
this.greedy = !!greedy;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Token.stringify = function(o, language) {
if (typeof o == 'string') {
return o;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (Array.isArray(o)) {
return o.map(function(element) {
return Token.stringify(element, language);
}).join('');
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var env = {
type: o.type,
content: Token.stringify(o.content, language),
tag: 'span',
classes: ['token', o.type],
attributes: {},
language: language
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (o.alias) {
var aliases = Array.isArray(o.alias) ? o.alias : [o.alias];
Array.prototype.push.apply(env.classes, aliases);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
_.hooks.run('wrap', env);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var attributes = Object.keys(env.attributes).map(function(name) {
return name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
}).join(' ');
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>';
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!_self.document) {
if (!_self.addEventListener) {
// in Node.js
return _;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!_.disableWorkerMessageHandler) {
// In worker
_self.addEventListener('message', function (evt) {
var message = JSON.parse(evt.data),
lang = message.language,
code = message.code,
immediateClose = message.immediateClose;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
_self.postMessage(_.highlight(code, _.languages[lang], lang));
if (immediateClose) {
_self.close();
}
}, false);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return _;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
//Get current script and highlight
var script = _.util.currentScript();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (script) {
_.filename = script.src;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (script.hasAttribute('data-manual')) {
_.manual = true;
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!_.manual) {
function highlightAutomaticallyCallback() {
if (!_.manual) {
_.highlightAll();
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// If the document state is "loading", then we'll use DOMContentLoaded.
// If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
// DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
// might take longer one animation frame to execute which can create a race condition where only some plugins have
// been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
// See https://github.com/PrismJS/prism/issues/2102
var readyState = document.readyState;
if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
} else {
if (window.requestAnimationFrame) {
window.requestAnimationFrame(highlightAutomaticallyCallback);
} else {
window.setTimeout(highlightAutomaticallyCallback, 16);
}
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return _;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
})(_self);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if ('object' !== 'undefined' && module.exports) {
module.exports = Prism;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// hack for components to work correctly in node.js
if (typeof commonjsGlobal !== 'undefined') {
commonjsGlobal.Prism = Prism;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/* **********************************************
Begin prism-markup.js
********************************************** */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Prism.languages.markup = {
'comment': /<!--[\s\S]*?-->/,
'prolog': /<\?[\s\S]+?\?>/,
'doctype': {
pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:(?!<!--)[^"'\]]|"[^"]*"|'[^']*'|<!--[\s\S]*?-->)*\]\s*)?>/i,
greedy: true
},
'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
'tag': {
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/i,
greedy: true,
inside: {
'tag': {
pattern: /^<\/?[^\s>\/]+/i,
inside: {
'punctuation': /^<\/?/,
'namespace': /^[^\s>\/:]+:/
}
},
'attr-value': {
pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i,
inside: {
'punctuation': [
/^=/,
{
pattern: /^(\s*)["']|["']$/,
lookbehind: true
}
]
}
},
'punctuation': /\/?>/,
'attr-name': {
pattern: /[^\s>\/]+/,
inside: {
'namespace': /^[^\s>\/:]+:/
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
}
},
'entity': /&#?[\da-z]{1,8};/i
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
Prism.languages.markup['entity'];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Plugin to make entity title show the real entity, idea by Roman Komarov
Prism.hooks.add('wrap', function(env) {
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (env.type === 'entity') {
env.attributes['title'] = env.content.replace(/&amp;/, '&');
}
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
/**
* Adds an inlined language to markup.
*
* An example of an inlined language is CSS with `<style>` tags.
*
* @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
* case insensitive.
* @param {string} lang The language key.
* @example
* addInlined('style', 'css');
*/
value: function addInlined(tagName, lang) {
var includedCdataInside = {};
includedCdataInside['language-' + lang] = {
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
lookbehind: true,
inside: Prism.languages[lang]
};
includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var inside = {
'included-cdata': {
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
inside: includedCdataInside
}
};
inside['language-' + lang] = {
pattern: /[\s\S]+/,
inside: Prism.languages[lang]
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var def = {};
def[tagName] = {
pattern: RegExp(/(<__[\s\S]*?>)(?:<!\[CDATA\[[\s\S]*?\]\]>\s*|[\s\S])*?(?=<\/__>)/.source.replace(/__/g, tagName), 'i'),
lookbehind: true,
greedy: true,
inside: inside
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Prism.languages.insertBefore('markup', 'cdata', def);
}
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Prism.languages.xml = Prism.languages.extend('markup', {});
Prism.languages.html = Prism.languages.markup;
Prism.languages.mathml = Prism.languages.markup;
Prism.languages.svg = Prism.languages.markup;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/* **********************************************
Begin prism-css.js
********************************************** */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
(function (Prism) {
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var string = /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Prism.languages.css = {
'comment': /\/\*[\s\S]*?\*\//,
'atrule': {
pattern: /@[\w-]+[\s\S]*?(?:;|(?=\s*\{))/,
inside: {
'rule': /@[\w-]+/
// See rest below
}
},
'url': {
pattern: RegExp('url\\((?:' + string.source + '|[^\n\r()]*)\\)', 'i'),
inside: {
'function': /^url/i,
'punctuation': /^\(|\)$/
}
},
'selector': RegExp('[^{}\\s](?:[^{};"\']|' + string.source + ')*?(?=\\s*\\{)'),
'string': {
pattern: string,
greedy: true
},
'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,
'important': /!important\b/i,
'function': /[-a-z0-9]+(?=\()/i,
'punctuation': /[(){};:,]/
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var markup = Prism.languages.markup;
if (markup) {
markup.tag.addInlined('style', 'css');
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Prism.languages.insertBefore('inside', 'attr-value', {
'style-attr': {
pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,
inside: {
'attr-name': {
pattern: /^\s*style/i,
inside: markup.tag.inside
},
'punctuation': /^\s*=\s*['"]|['"]\s*$/,
'attr-value': {
pattern: /.+/i,
inside: Prism.languages.css
}
},
alias: 'language-css'
}
}, markup.tag);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
}(Prism));
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/* **********************************************
Begin prism-clike.js
********************************************** */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Prism.languages.clike = {
'comment': [
{
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
lookbehind: true
},
{
pattern: /(^|[^\\:])\/\/.*/,
lookbehind: true,
greedy: true
}
],
'string': {
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
greedy: true
},
'class-name': {
pattern: /(\b(?:class|interface|extends|implements|trait|instanceof|new)\s+|\bcatch\s+\()[\w.\\]+/i,
lookbehind: true,
inside: {
'punctuation': /[.\\]/
}
},
'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
'boolean': /\b(?:true|false)\b/,
'function': /\w+(?=\()/,
'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,
'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
'punctuation': /[{}[\];(),.:]/
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/* **********************************************
Begin prism-javascript.js
********************************************** */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Prism.languages.javascript = Prism.languages.extend('clike', {
'class-name': [
Prism.languages.clike['class-name'],
{
pattern: /(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,
lookbehind: true
}
],
'keyword': [
{
pattern: /((?:^|})\s*)(?:catch|finally)\b/,
lookbehind: true
},
{
pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
lookbehind: true
},
],
'number': /\b(?:(?:0[xX](?:[\dA-Fa-f](?:_[\dA-Fa-f])?)+|0[bB](?:[01](?:_[01])?)+|0[oO](?:[0-7](?:_[0-7])?)+)n?|(?:\d(?:_\d)?)+n|NaN|Infinity)\b|(?:\b(?:\d(?:_\d)?)+\.?(?:\d(?:_\d)?)*|\B\.(?:\d(?:_\d)?)+)(?:[Ee][+-]?(?:\d(?:_\d)?)+)?/,
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
'function': /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
'operator': /--|\+\+|\*\*=?|=>|&&|\|\||[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?[.?]?|[~:]/
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Prism.languages.insertBefore('javascript', 'keyword', {
'regex': {
pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyus]{0,6}(?=(?:\s|\/\*[\s\S]*?\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,
lookbehind: true,
greedy: true
},
// This must be declared before keyword because we use "function" inside the look-forward
'function-variable': {
pattern: /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/,
alias: 'function'
},
'parameter': [
{
pattern: /(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/,
lookbehind: true,
inside: Prism.languages.javascript
},
{
pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i,
inside: Prism.languages.javascript
},
{
pattern: /(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/,
lookbehind: true,
inside: Prism.languages.javascript
},
{
pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/,
lookbehind: true,
inside: Prism.languages.javascript
}
],
'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Prism.languages.insertBefore('javascript', 'string', {
'template-string': {
pattern: /`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}|(?!\${)[^\\`])*`/,
greedy: true,
inside: {
'template-punctuation': {
pattern: /^`|`$/,
alias: 'string'
},
'interpolation': {
pattern: /((?:^|[^\\])(?:\\{2})*)\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}/,
lookbehind: true,
inside: {
'interpolation-punctuation': {
pattern: /^\${|}$/,
alias: 'punctuation'
},
rest: Prism.languages.javascript
}
},
'string': /[\s\S]+/
}
}
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (Prism.languages.markup) {
Prism.languages.markup.tag.addInlined('script', 'javascript');
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Prism.languages.js = Prism.languages.javascript;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/* **********************************************
Begin prism-file-highlight.js
********************************************** */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
(function () {
if (typeof self === 'undefined' || !self.Prism || !self.document || !document.querySelector) {
return;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* @param {Element} [container=document]
*/
self.Prism.fileHighlight = function(container) {
container = container || document;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var Extensions = {
'js': 'javascript',
'py': 'python',
'rb': 'ruby',
'ps1': 'powershell',
'psm1': 'powershell',
'sh': 'bash',
'bat': 'batch',
'h': 'c',
'tex': 'latex'
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Array.prototype.slice.call(container.querySelectorAll('pre[data-src]')).forEach(function (pre) {
// ignore if already loaded
if (pre.hasAttribute('data-src-loaded')) {
return;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// load current
var src = pre.getAttribute('data-src');
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var language, parent = pre;
var lang = /\blang(?:uage)?-([\w-]+)\b/i;
while (parent && !lang.test(parent.className)) {
parent = parent.parentNode;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (parent) {
language = (pre.className.match(lang) || [, ''])[1];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!language) {
var extension = (src.match(/\.(\w+)$/) || [, ''])[1];
language = Extensions[extension] || extension;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var code = document.createElement('code');
code.className = 'language-' + language;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
pre.textContent = '';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
code.textContent = 'Loading…';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
pre.appendChild(code);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var xhr = new XMLHttpRequest();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
xhr.open('GET', src, true);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (xhr.status < 400 && xhr.responseText) {
code.textContent = xhr.responseText;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Prism.highlightElement(code);
// mark as loaded
pre.setAttribute('data-src-loaded', '');
}
else if (xhr.status >= 400) {
code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
}
else {
code.textContent = '✖ Error: File does not exist or is empty';
}
}
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
xhr.send(null);
});
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
document.addEventListener('DOMContentLoaded', function () {
// execute inside handler, for dropping Event as argument
self.Prism.fileHighlight();
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
})();
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var marked = createCommonjsModule(function (module, exports) {
/**
* marked - a markdown parser
* Copyright (c) 2011-2018, Christopher Jeffrey. (MIT Licensed)
* https://github.com/markedjs/marked
*/
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
;(function(root) {
'use strict';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Block-Level Grammar
*/
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var block = {
newline: /^\n+/,
code: /^( {4}[^\n]+\n*)+/,
fences: /^ {0,3}(`{3,}|~{3,})([^`~\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
heading: /^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
html: '^ {0,3}(?:' // optional indentation
+ '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
+ '|comment[^\\n]*(\\n+|$)' // (2)
+ '|<\\?[\\s\\S]*?\\?>\\n*' // (3)
+ '|<![A-Z][\\s\\S]*?>\\n*' // (4)
+ '|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*' // (5)
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' // (6)
+ '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag
+ '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
+ ')',
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
nptable: noop,
table: noop,
lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
// regex template, placeholders will be replaced according to different paragraph
// interruption rules of commonmark and the original markdown spec:
_paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,
text: /^[^\n]+/
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
block.def = edit(block.def)
.replace('label', block._label)
.replace('title', block._title)
.getRegex();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
block.bullet = /(?:[*+-]|\d{1,9}\.)/;
block.item = /^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/;
block.item = edit(block.item, 'gm')
.replace(/bull/g, block.bullet)
.getRegex();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
block.list = edit(block.list)
.replace(/bull/g, block.bullet)
.replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
.replace('def', '\\n+(?=' + block.def.source + ')')
.getRegex();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
block._tag = 'address|article|aside|base|basefont|blockquote|body|caption'
+ '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
+ '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
+ '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
+ '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr'
+ '|track|ul';
block._comment = /<!--(?!-?>)[\s\S]*?-->/;
block.html = edit(block.html, 'i')
.replace('comment', block._comment)
.replace('tag', block._tag)
.replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/)
.getRegex();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
block.paragraph = edit(block._paragraph)
.replace('hr', block.hr)
.replace('heading', ' {0,3}#{1,6} +')
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
.replace('blockquote', ' {0,3}>')
.replace('fences', ' {0,3}(?:`{3,}|~{3,})[^`\\n]*\\n')
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
.replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
.getRegex();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
block.blockquote = edit(block.blockquote)
.replace('paragraph', block.paragraph)
.getRegex();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Normal Block Grammar
*/
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
block.normal = merge({}, block);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* GFM Block Grammar
*/
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
block.gfm = merge({}, block.normal, {
nptable: /^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,
table: /^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Pedantic grammar (original John Gruber's loose markdown specification)
*/
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
block.pedantic = merge({}, block.normal, {
html: edit(
'^ *(?:comment *(?:\\n|\\s*$)'
+ '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
.replace('comment', block._comment)
.replace(/tag/g, '(?!(?:'
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
+ '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
+ '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
.getRegex(),
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
fences: noop, // fences not supported
paragraph: edit(block.normal._paragraph)
.replace('hr', block.hr)
.replace('heading', ' *#{1,6} *[^\n]')
.replace('lheading', block.lheading)
.replace('blockquote', ' {0,3}>')
.replace('|fences', '')
.replace('|list', '')
.replace('|html', '')
.getRegex()
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Block Lexer
*/
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function Lexer(options) {
this.tokens = [];
this.tokens.links = Object.create(null);
this.options = options || marked.defaults;
this.rules = block.normal;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (this.options.pedantic) {
this.rules = block.pedantic;
} else if (this.options.gfm) {
this.rules = block.gfm;
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Expose Block Rules
*/
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Lexer.rules = block;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Static Lex Method
*/
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Lexer.lex = function(src, options) {
var lexer = new Lexer(options);
return lexer.lex(src);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Preprocessing
*/
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Lexer.prototype.lex = function(src) {
src = src
.replace(/\r\n|\r/g, '\n')
.replace(/\t/g, ' ')
.replace(/\u00a0/g, ' ')
.replace(/\u2424/g, '\n');
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this.token(src, true);
};
/**
* Lexing
*/
Lexer.prototype.token = function(src, top) {
src = src.replace(/^ +$/gm, '');
var next,
loose,
cap,
bull,
b,
item,
listStart,
listItems,
t,
space,
i,
tag,
l,
isordered,
istask,
ischecked;
while (src) {
// newline
if (cap = this.rules.newline.exec(src)) {
src = src.substring(cap[0].length);
if (cap[0].length > 1) {
this.tokens.push({
type: 'space'
});
}
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
// code
if (cap = this.rules.code.exec(src)) {
var lastToken = this.tokens[this.tokens.length - 1];
src = src.substring(cap[0].length);
// An indented code block cannot interrupt a paragraph.
if (lastToken && lastToken.type === 'paragraph') {
lastToken.text += '\n' + cap[0].trimRight();
} else {
cap = cap[0].replace(/^ {4}/gm, '');
this.tokens.push({
type: 'code',
codeBlockStyle: 'indented',
text: !this.options.pedantic
? rtrim(cap, '\n')
: cap
});
}
continue;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// fences
if (cap = this.rules.fences.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: 'code',
lang: cap[2] ? cap[2].trim() : cap[2],
text: cap[3] || ''
});
continue;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// heading
if (cap = this.rules.heading.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: 'heading',
depth: cap[1].length,
text: cap[2]
});
continue;
}
// table no leading pipe (gfm)
if (cap = this.rules.nptable.exec(src)) {
item = {
type: 'table',
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
};
if (item.header.length === item.align.length) {
src = src.substring(cap[0].length);
for (i = 0; i < item.align.length; i++) {
if (/^ *-+: *$/.test(item.align[i])) {
item.align[i] = 'right';
} else if (/^ *:-+: *$/.test(item.align[i])) {
item.align[i] = 'center';
} else if (/^ *:-+ *$/.test(item.align[i])) {
item.align[i] = 'left';
} else {
item.align[i] = null;
}
}
for (i = 0; i < item.cells.length; i++) {
item.cells[i] = splitCells(item.cells[i], item.header.length);
}
this.tokens.push(item);
continue;
}
}
// hr
if (cap = this.rules.hr.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: 'hr'
});
continue;
}
// blockquote
if (cap = this.rules.blockquote.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: 'blockquote_start'
});
cap = cap[0].replace(/^ *> ?/gm, '');
// Pass `top` to keep the current
// "toplevel" state. This is exactly
// how markdown.pl works.
this.token(cap, top);
this.tokens.push({
type: 'blockquote_end'
});
continue;
}
// list
if (cap = this.rules.list.exec(src)) {
src = src.substring(cap[0].length);
bull = cap[2];
isordered = bull.length > 1;
listStart = {
type: 'list_start',
ordered: isordered,
start: isordered ? +bull : '',
loose: false
};
this.tokens.push(listStart);
// Get each top-level item.
cap = cap[0].match(this.rules.item);
listItems = [];
next = false;
l = cap.length;
i = 0;
for (; i < l; i++) {
item = cap[i];
// Remove the list item's bullet
// so it is seen as the next token.
space = item.length;
item = item.replace(/^ *([*+-]|\d+\.) */, '');
// Outdent whatever the
// list item contains. Hacky.
if (~item.indexOf('\n ')) {
space -= item.length;
item = !this.options.pedantic
? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
: item.replace(/^ {1,4}/gm, '');
}
// Determine whether the next list item belongs here.
// Backpedal if it does not belong in this list.
if (i !== l - 1) {
b = block.bullet.exec(cap[i + 1])[0];
if (bull.length > 1 ? b.length === 1
: (b.length > 1 || (this.options.smartLists && b !== bull))) {
src = cap.slice(i + 1).join('\n') + src;
i = l - 1;
}
}
// Determine whether item is loose or not.
// Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
// for discount behavior.
loose = next || /\n\n(?!\s*$)/.test(item);
if (i !== l - 1) {
next = item.charAt(item.length - 1) === '\n';
if (!loose) loose = next;
}
if (loose) {
listStart.loose = true;
}
// Check for task list items
istask = /^\[[ xX]\] /.test(item);
ischecked = undefined;
if (istask) {
ischecked = item[1] !== ' ';
item = item.replace(/^\[[ xX]\] +/, '');
}
t = {
type: 'list_item_start',
task: istask,
checked: ischecked,
loose: loose
};
listItems.push(t);
this.tokens.push(t);
// Recurse.
this.token(item, false);
this.tokens.push({
type: 'list_item_end'
});
}
if (listStart.loose) {
l = listItems.length;
i = 0;
for (; i < l; i++) {
listItems[i].loose = true;
}
}
this.tokens.push({
type: 'list_end'
});
continue;
}
// html
if (cap = this.rules.html.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: this.options.sanitize
? 'paragraph'
: 'html',
pre: !this.options.sanitizer
&& (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
text: this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0])) : cap[0]
});
continue;
}
// def
if (top && (cap = this.rules.def.exec(src))) {
src = src.substring(cap[0].length);
if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
if (!this.tokens.links[tag]) {
this.tokens.links[tag] = {
href: cap[2],
title: cap[3]
};
}
continue;
}
// table (gfm)
if (cap = this.rules.table.exec(src)) {
item = {
type: 'table',
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
};
if (item.header.length === item.align.length) {
src = src.substring(cap[0].length);
for (i = 0; i < item.align.length; i++) {
if (/^ *-+: *$/.test(item.align[i])) {
item.align[i] = 'right';
} else if (/^ *:-+: *$/.test(item.align[i])) {
item.align[i] = 'center';
} else if (/^ *:-+ *$/.test(item.align[i])) {
item.align[i] = 'left';
} else {
item.align[i] = null;
}
}
for (i = 0; i < item.cells.length; i++) {
item.cells[i] = splitCells(
item.cells[i].replace(/^ *\| *| *\| *$/g, ''),
item.header.length);
}
this.tokens.push(item);
continue;
}
}
// lheading
if (cap = this.rules.lheading.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: 'heading',
depth: cap[2].charAt(0) === '=' ? 1 : 2,
text: cap[1]
});
continue;
}
// top-level paragraph
if (top && (cap = this.rules.paragraph.exec(src))) {
src = src.substring(cap[0].length);
this.tokens.push({
type: 'paragraph',
text: cap[1].charAt(cap[1].length - 1) === '\n'
? cap[1].slice(0, -1)
: cap[1]
});
continue;
}
// text
if (cap = this.rules.text.exec(src)) {
// Top-level should never reach here.
src = src.substring(cap[0].length);
this.tokens.push({
type: 'text',
text: cap[0]
});
continue;
}
if (src) {
throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
}
}
return this.tokens;
};
/**
* Inline-Level Grammar
*/
var inline = {
escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
url: noop,
tag: '^comment'
+ '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
+ '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
+ '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
+ '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
+ '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>', // CDATA section
link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
strong: /^__([^\s_])__(?!_)|^\*\*([^\s*])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,
em: /^_([^\s_])_(?!_)|^\*([^\s*<\[])\*(?!\*)|^_([^\s<][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_<][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s<"][\s\S]*?[^\s\*])\*(?!\*|[^\spunctuation])|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
br: /^( {2,}|\\)\n(?!\s*$)/,
del: noop,
text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/
};
// list of punctuation marks from common mark spec
// without ` and ] to workaround Rule 17 (inline code blocks/links)
inline._punctuation = '!"#$%&\'()*+,\\-./:;<=>?@\\[^_{|}~';
inline.em = edit(inline.em).replace(/punctuation/g, inline._punctuation).getRegex();
inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
inline.autolink = edit(inline.autolink)
.replace('scheme', inline._scheme)
.replace('email', inline._email)
.getRegex();
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
inline.tag = edit(inline.tag)
.replace('comment', block._comment)
.replace('attribute', inline._attribute)
.getRegex();
inline._label = /(?:\[[^\[\]]*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
inline._href = /<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/;
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
inline.link = edit(inline.link)
.replace('label', inline._label)
.replace('href', inline._href)
.replace('title', inline._title)
.getRegex();
inline.reflink = edit(inline.reflink)
.replace('label', inline._label)
.getRegex();
/**
* Normal Inline Grammar
*/
inline.normal = merge({}, inline);
/**
* Pedantic Inline Grammar
*/
inline.pedantic = merge({}, inline.normal, {
strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,
link: edit(/^!?\[(label)\]\((.*?)\)/)
.replace('label', inline._label)
.getRegex(),
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
.replace('label', inline._label)
.getRegex()
});
/**
* GFM Inline Grammar
*/
inline.gfm = merge({}, inline.normal, {
escape: edit(inline.escape).replace('])', '~|])').getRegex(),
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
del: /^~+(?=\S)([\s\S]*?\S)~+/,
text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/
});
inline.gfm.url = edit(inline.gfm.url, 'i')
.replace('email', inline.gfm._extended_email)
.getRegex();
/**
* GFM + Line Breaks Inline Grammar
*/
inline.breaks = merge({}, inline.gfm, {
br: edit(inline.br).replace('{2,}', '*').getRegex(),
text: edit(inline.gfm.text)
.replace('\\b_', '\\b_| {2,}\\n')
.replace(/\{2,\}/g, '*')
.getRegex()
});
/**
* Inline Lexer & Compiler
*/
function InlineLexer(links, options) {
this.options = options || marked.defaults;
this.links = links;
this.rules = inline.normal;
this.renderer = this.options.renderer || new Renderer();
this.renderer.options = this.options;
if (!this.links) {
throw new Error('Tokens array requires a `links` property.');
}
if (this.options.pedantic) {
this.rules = inline.pedantic;
} else if (this.options.gfm) {
if (this.options.breaks) {
this.rules = inline.breaks;
} else {
this.rules = inline.gfm;
}
}
}
/**
* Expose Inline Rules
*/
InlineLexer.rules = inline;
/**
* Static Lexing/Compiling Method
*/
InlineLexer.output = function(src, links, options) {
var inline = new InlineLexer(links, options);
return inline.output(src);
};
/**
* Lexing/Compiling
*/
InlineLexer.prototype.output = function(src) {
var out = '',
link,
text,
href,
title,
cap,
prevCapZero;
while (src) {
// escape
if (cap = this.rules.escape.exec(src)) {
src = src.substring(cap[0].length);
out += escape(cap[1]);
continue;
}
// tag
if (cap = this.rules.tag.exec(src)) {
if (!this.inLink && /^<a /i.test(cap[0])) {
this.inLink = true;
} else if (this.inLink && /^<\/a>/i.test(cap[0])) {
this.inLink = false;
}
if (!this.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
this.inRawBlock = true;
} else if (this.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
this.inRawBlock = false;
}
src = src.substring(cap[0].length);
out += this.options.sanitize
? this.options.sanitizer
? this.options.sanitizer(cap[0])
: escape(cap[0])
: cap[0];
continue;
}
// link
if (cap = this.rules.link.exec(src)) {
var lastParenIndex = findClosingBracket(cap[2], '()');
if (lastParenIndex > -1) {
var linkLen = 4 + cap[1].length + lastParenIndex;
cap[2] = cap[2].substring(0, lastParenIndex);
cap[0] = cap[0].substring(0, linkLen).trim();
cap[3] = '';
}
src = src.substring(cap[0].length);
this.inLink = true;
href = cap[2];
if (this.options.pedantic) {
link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
if (link) {
href = link[1];
title = link[3];
} else {
title = '';
}
} else {
title = cap[3] ? cap[3].slice(1, -1) : '';
}
href = href.trim().replace(/^<([\s\S]*)>$/, '$1');
out += this.outputLink(cap, {
href: InlineLexer.escapes(href),
title: InlineLexer.escapes(title)
});
this.inLink = false;
continue;
}
// reflink, nolink
if ((cap = this.rules.reflink.exec(src))
|| (cap = this.rules.nolink.exec(src))) {
src = src.substring(cap[0].length);
link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
link = this.links[link.toLowerCase()];
if (!link || !link.href) {
out += cap[0].charAt(0);
src = cap[0].substring(1) + src;
continue;
}
this.inLink = true;
out += this.outputLink(cap, link);
this.inLink = false;
continue;
}
// strong
if (cap = this.rules.strong.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.strong(this.output(cap[4] || cap[3] || cap[2] || cap[1]));
continue;
}
// em
if (cap = this.rules.em.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.em(this.output(cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1]));
continue;
}
// code
if (cap = this.rules.code.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.codespan(escape(cap[2].trim(), true));
continue;
}
// br
if (cap = this.rules.br.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.br();
continue;
}
// del (gfm)
if (cap = this.rules.del.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.del(this.output(cap[1]));
continue;
}
// autolink
if (cap = this.rules.autolink.exec(src)) {
src = src.substring(cap[0].length);
if (cap[2] === '@') {
text = escape(this.mangle(cap[1]));
href = 'mailto:' + text;
} else {
text = escape(cap[1]);
href = text;
}
out += this.renderer.link(href, null, text);
continue;
}
// url (gfm)
if (!this.inLink && (cap = this.rules.url.exec(src))) {
if (cap[2] === '@') {
text = escape(cap[0]);
href = 'mailto:' + text;
} else {
// do extended autolink path validation
do {
prevCapZero = cap[0];
cap[0] = this.rules._backpedal.exec(cap[0])[0];
} while (prevCapZero !== cap[0]);
text = escape(cap[0]);
if (cap[1] === 'www.') {
href = 'http://' + text;
} else {
href = text;
}
}
src = src.substring(cap[0].length);
out += this.renderer.link(href, null, text);
continue;
}
// text
if (cap = this.rules.text.exec(src)) {
src = src.substring(cap[0].length);
if (this.inRawBlock) {
out += this.renderer.text(this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0])) : cap[0]);
} else {
out += this.renderer.text(escape(this.smartypants(cap[0])));
}
continue;
}
if (src) {
throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
}
}
return out;
};
InlineLexer.escapes = function(text) {
return text ? text.replace(InlineLexer.rules._escapes, '$1') : text;
};
/**
* Compile Link
*/
InlineLexer.prototype.outputLink = function(cap, link) {
var href = link.href,
title = link.title ? escape(link.title) : null;
return cap[0].charAt(0) !== '!'
? this.renderer.link(href, title, this.output(cap[1]))
: this.renderer.image(href, title, escape(cap[1]));
};
/**
* Smartypants Transformations
*/
InlineLexer.prototype.smartypants = function(text) {
if (!this.options.smartypants) return text;
return text
// em-dashes
.replace(/---/g, '\u2014')
// en-dashes
.replace(/--/g, '\u2013')
// opening singles
.replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
// closing singles & apostrophes
.replace(/'/g, '\u2019')
// opening doubles
.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
// closing doubles
.replace(/"/g, '\u201d')
// ellipses
.replace(/\.{3}/g, '\u2026');
};
/**
* Mangle Links
*/
InlineLexer.prototype.mangle = function(text) {
if (!this.options.mangle) return text;
var out = '',
l = text.length,
i = 0,
ch;
for (; i < l; i++) {
ch = text.charCodeAt(i);
if (Math.random() > 0.5) {
ch = 'x' + ch.toString(16);
}
out += '&#' + ch + ';';
}
return out;
};
/**
* Renderer
*/
function Renderer(options) {
this.options = options || marked.defaults;
}
Renderer.prototype.code = function(code, infostring, escaped) {
var lang = (infostring || '').match(/\S*/)[0];
if (this.options.highlight) {
var out = this.options.highlight(code, lang);
if (out != null && out !== code) {
escaped = true;
code = out;
}
}
if (!lang) {
return '<pre><code>'
+ (escaped ? code : escape(code, true))
+ '</code></pre>';
}
return '<pre><code class="'
+ this.options.langPrefix
+ escape(lang, true)
+ '">'
+ (escaped ? code : escape(code, true))
+ '</code></pre>\n';
};
Renderer.prototype.blockquote = function(quote) {
return '<blockquote>\n' + quote + '</blockquote>\n';
};
Renderer.prototype.html = function(html) {
return html;
};
Renderer.prototype.heading = function(text, level, raw, slugger) {
if (this.options.headerIds) {
return '<h'
+ level
+ ' id="'
+ this.options.headerPrefix
+ slugger.slug(raw)
+ '">'
+ text
+ '</h'
+ level
+ '>\n';
}
// ignore IDs
return '<h' + level + '>' + text + '</h' + level + '>\n';
};
Renderer.prototype.hr = function() {
return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
};
Renderer.prototype.list = function(body, ordered, start) {
var type = ordered ? 'ol' : 'ul',
startatt = (ordered && start !== 1) ? (' start="' + start + '"') : '';
return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
};
Renderer.prototype.listitem = function(text) {
return '<li>' + text + '</li>\n';
};
Renderer.prototype.checkbox = function(checked) {
return '<input '
+ (checked ? 'checked="" ' : '')
+ 'disabled="" type="checkbox"'
+ (this.options.xhtml ? ' /' : '')
+ '> ';
};
Renderer.prototype.paragraph = function(text) {
return '<p>' + text + '</p>\n';
};
Renderer.prototype.table = function(header, body) {
if (body) body = '<tbody>' + body + '</tbody>';
return '<table>\n'
+ '<thead>\n'
+ header
+ '</thead>\n'
+ body
+ '</table>\n';
};
Renderer.prototype.tablerow = function(content) {
return '<tr>\n' + content + '</tr>\n';
};
Renderer.prototype.tablecell = function(content, flags) {
var type = flags.header ? 'th' : 'td';
var tag = flags.align
? '<' + type + ' align="' + flags.align + '">'
: '<' + type + '>';
return tag + content + '</' + type + '>\n';
};
// span level renderer
Renderer.prototype.strong = function(text) {
return '<strong>' + text + '</strong>';
};
Renderer.prototype.em = function(text) {
return '<em>' + text + '</em>';
};
Renderer.prototype.codespan = function(text) {
return '<code>' + text + '</code>';
};
Renderer.prototype.br = function() {
return this.options.xhtml ? '<br/>' : '<br>';
};
Renderer.prototype.del = function(text) {
return '<del>' + text + '</del>';
};
Renderer.prototype.link = function(href, title, text) {
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
if (href === null) {
return text;
}
var out = '<a href="' + escape(href) + '"';
if (title) {
out += ' title="' + title + '"';
}
out += '>' + text + '</a>';
return out;
};
Renderer.prototype.image = function(href, title, text) {
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
if (href === null) {
return text;
}
var out = '<img src="' + href + '" alt="' + text + '"';
if (title) {
out += ' title="' + title + '"';
}
out += this.options.xhtml ? '/>' : '>';
return out;
};
Renderer.prototype.text = function(text) {
return text;
};
/**
* TextRenderer
* returns only the textual part of the token
*/
function TextRenderer() {}
// no need for block level renderers
TextRenderer.prototype.strong =
TextRenderer.prototype.em =
TextRenderer.prototype.codespan =
TextRenderer.prototype.del =
TextRenderer.prototype.text = function(text) {
return text;
};
TextRenderer.prototype.link =
TextRenderer.prototype.image = function(href, title, text) {
return '' + text;
};
TextRenderer.prototype.br = function() {
return '';
};
/**
* Parsing & Compiling
*/
function Parser(options) {
this.tokens = [];
this.token = null;
this.options = options || marked.defaults;
this.options.renderer = this.options.renderer || new Renderer();
this.renderer = this.options.renderer;
this.renderer.options = this.options;
this.slugger = new Slugger();
}
/**
* Static Parse Method
*/
Parser.parse = function(src, options) {
var parser = new Parser(options);
return parser.parse(src);
};
/**
* Parse Loop
*/
Parser.prototype.parse = function(src) {
this.inline = new InlineLexer(src.links, this.options);
// use an InlineLexer with a TextRenderer to extract pure text
this.inlineText = new InlineLexer(
src.links,
merge({}, this.options, { renderer: new TextRenderer() })
);
this.tokens = src.reverse();
var out = '';
while (this.next()) {
out += this.tok();
}
return out;
};
/**
* Next Token
*/
Parser.prototype.next = function() {
this.token = this.tokens.pop();
return this.token;
};
/**
* Preview Next Token
*/
Parser.prototype.peek = function() {
return this.tokens[this.tokens.length - 1] || 0;
};
/**
* Parse Text Tokens
*/
Parser.prototype.parseText = function() {
var body = this.token.text;
while (this.peek().type === 'text') {
body += '\n' + this.next().text;
}
return this.inline.output(body);
};
/**
* Parse Current Token
*/
Parser.prototype.tok = function() {
switch (this.token.type) {
case 'space': {
return '';
}
case 'hr': {
return this.renderer.hr();
}
case 'heading': {
return this.renderer.heading(
this.inline.output(this.token.text),
this.token.depth,
unescape(this.inlineText.output(this.token.text)),
this.slugger);
}
case 'code': {
return this.renderer.code(this.token.text,
this.token.lang,
this.token.escaped);
}
case 'table': {
var header = '',
body = '',
i,
row,
cell,
j;
// header
cell = '';
for (i = 0; i < this.token.header.length; i++) {
cell += this.renderer.tablecell(
this.inline.output(this.token.header[i]),
{ header: true, align: this.token.align[i] }
);
}
header += this.renderer.tablerow(cell);
for (i = 0; i < this.token.cells.length; i++) {
row = this.token.cells[i];
cell = '';
for (j = 0; j < row.length; j++) {
cell += this.renderer.tablecell(
this.inline.output(row[j]),
{ header: false, align: this.token.align[j] }
);
}
body += this.renderer.tablerow(cell);
}
return this.renderer.table(header, body);
}
case 'blockquote_start': {
body = '';
while (this.next().type !== 'blockquote_end') {
body += this.tok();
}
return this.renderer.blockquote(body);
}
case 'list_start': {
body = '';
var ordered = this.token.ordered,
start = this.token.start;
while (this.next().type !== 'list_end') {
body += this.tok();
}
return this.renderer.list(body, ordered, start);
}
case 'list_item_start': {
body = '';
var loose = this.token.loose;
var checked = this.token.checked;
var task = this.token.task;
if (this.token.task) {
body += this.renderer.checkbox(checked);
}
while (this.next().type !== 'list_item_end') {
body += !loose && this.token.type === 'text'
? this.parseText()
: this.tok();
}
return this.renderer.listitem(body, task, checked);
}
case 'html': {
// TODO parse inline content if parameter markdown=1
return this.renderer.html(this.token.text);
}
case 'paragraph': {
return this.renderer.paragraph(this.inline.output(this.token.text));
}
case 'text': {
return this.renderer.paragraph(this.parseText());
}
default: {
var errMsg = 'Token with "' + this.token.type + '" type was not found.';
if (this.options.silent) {
console.log(errMsg);
} else {
throw new Error(errMsg);
}
}
}
};
/**
* Slugger generates header id
*/
function Slugger() {
this.seen = {};
}
/**
* Convert string to unique id
*/
Slugger.prototype.slug = function(value) {
var slug = value
.toLowerCase()
.trim()
.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
.replace(/\s/g, '-');
if (this.seen.hasOwnProperty(slug)) {
var originalSlug = slug;
do {
this.seen[originalSlug]++;
slug = originalSlug + '-' + this.seen[originalSlug];
} while (this.seen.hasOwnProperty(slug));
}
this.seen[slug] = 0;
return slug;
};
/**
* Helpers
*/
function escape(html, encode) {
if (encode) {
if (escape.escapeTest.test(html)) {
return html.replace(escape.escapeReplace, function(ch) { return escape.replacements[ch]; });
}
} else {
if (escape.escapeTestNoEncode.test(html)) {
return html.replace(escape.escapeReplaceNoEncode, function(ch) { return escape.replacements[ch]; });
}
}
return html;
}
escape.escapeTest = /[&<>"']/;
escape.escapeReplace = /[&<>"']/g;
escape.replacements = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;'
};
escape.escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
escape.escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
function unescape(html) {
// explicitly match decimal, hex, and named HTML entities
return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function(_, n) {
n = n.toLowerCase();
if (n === 'colon') return ':';
if (n.charAt(0) === '#') {
return n.charAt(1) === 'x'
? String.fromCharCode(parseInt(n.substring(2), 16))
: String.fromCharCode(+n.substring(1));
}
return '';
});
}
function edit(regex, opt) {
regex = regex.source || regex;
opt = opt || '';
return {
replace: function(name, val) {
val = val.source || val;
val = val.replace(/(^|[^\[])\^/g, '$1');
regex = regex.replace(name, val);
return this;
},
getRegex: function() {
return new RegExp(regex, opt);
}
};
}
function cleanUrl(sanitize, base, href) {
if (sanitize) {
try {
var prot = decodeURIComponent(unescape(href))
.replace(/[^\w:]/g, '')
.toLowerCase();
} catch (e) {
return null;
}
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
return null;
}
}
if (base && !originIndependentUrl.test(href)) {
href = resolveUrl(base, href);
}
try {
href = encodeURI(href).replace(/%25/g, '%');
} catch (e) {
return null;
}
return href;
}
function resolveUrl(base, href) {
if (!baseUrls[' ' + base]) {
// we can ignore everything in base after the last slash of its path component,
// but we might need to add _that_
// https://tools.ietf.org/html/rfc3986#section-3
if (/^[^:]+:\/*[^/]*$/.test(base)) {
baseUrls[' ' + base] = base + '/';
} else {
baseUrls[' ' + base] = rtrim(base, '/', true);
}
}
base = baseUrls[' ' + base];
if (href.slice(0, 2) === '//') {
return base.replace(/:[\s\S]*/, ':') + href;
} else if (href.charAt(0) === '/') {
return base.replace(/(:\/*[^/]*)[\s\S]*/, '$1') + href;
} else {
return base + href;
}
}
var baseUrls = {};
var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
function noop() {}
noop.exec = noop;
function merge(obj) {
var i = 1,
target,
key;
for (; i < arguments.length; i++) {
target = arguments[i];
for (key in target) {
if (Object.prototype.hasOwnProperty.call(target, key)) {
obj[key] = target[key];
}
}
}
return obj;
}
function splitCells(tableRow, count) {
// ensure that every cell-delimiting pipe has a space
// before it to distinguish it from an escaped pipe
var row = tableRow.replace(/\|/g, function(match, offset, str) {
var escaped = false,
curr = offset;
while (--curr >= 0 && str[curr] === '\\') escaped = !escaped;
if (escaped) {
// odd number of slashes means | is escaped
// so we leave it alone
return '|';
} else {
// add space before unescaped |
return ' |';
}
}),
cells = row.split(/ \|/),
i = 0;
if (cells.length > count) {
cells.splice(count);
} else {
while (cells.length < count) cells.push('');
}
for (; i < cells.length; i++) {
// leading or trailing whitespace is ignored per the gfm spec
cells[i] = cells[i].trim().replace(/\\\|/g, '|');
}
return cells;
}
// Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
// /c*$/ is vulnerable to REDOS.
// invert: Remove suffix of non-c chars instead. Default falsey.
function rtrim(str, c, invert) {
if (str.length === 0) {
return '';
}
// Length of suffix matching the invert condition.
var suffLen = 0;
// Step left until we fail to match the invert condition.
while (suffLen < str.length) {
var currChar = str.charAt(str.length - suffLen - 1);
if (currChar === c && !invert) {
suffLen++;
} else if (currChar !== c && invert) {
suffLen++;
} else {
break;
}
}
return str.substr(0, str.length - suffLen);
}
function findClosingBracket(str, b) {
if (str.indexOf(b[1]) === -1) {
return -1;
}
var level = 0;
for (var i = 0; i < str.length; i++) {
if (str[i] === '\\') {
i++;
} else if (str[i] === b[0]) {
level++;
} else if (str[i] === b[1]) {
level--;
if (level < 0) {
return i;
}
}
}
return -1;
}
function checkSanitizeDeprecation(opt) {
if (opt && opt.sanitize && !opt.silent) {
console.warn('marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options');
}
}
/**
* Marked
*/
function marked(src, opt, callback) {
// throw error in case of non string input
if (typeof src === 'undefined' || src === null) {
throw new Error('marked(): input parameter is undefined or null');
}
if (typeof src !== 'string') {
throw new Error('marked(): input parameter is of type '
+ Object.prototype.toString.call(src) + ', string expected');
}
if (callback || typeof opt === 'function') {
if (!callback) {
callback = opt;
opt = null;
}
opt = merge({}, marked.defaults, opt || {});
checkSanitizeDeprecation(opt);
var highlight = opt.highlight,
tokens,
pending,
i = 0;
try {
tokens = Lexer.lex(src, opt);
} catch (e) {
return callback(e);
}
pending = tokens.length;
var done = function(err) {
if (err) {
opt.highlight = highlight;
return callback(err);
}
var out;
try {
out = Parser.parse(tokens, opt);
} catch (e) {
err = e;
}
opt.highlight = highlight;
return err
? callback(err)
: callback(null, out);
};
if (!highlight || highlight.length < 3) {
return done();
}
delete opt.highlight;
if (!pending) return done();
for (; i < tokens.length; i++) {
(function(token) {
if (token.type !== 'code') {
return --pending || done();
}
return highlight(token.text, token.lang, function(err, code) {
if (err) return done(err);
if (code == null || code === token.text) {
return --pending || done();
}
token.text = code;
token.escaped = true;
--pending || done();
});
})(tokens[i]);
}
return;
}
try {
if (opt) opt = merge({}, marked.defaults, opt);
checkSanitizeDeprecation(opt);
return Parser.parse(Lexer.lex(src, opt), opt);
} catch (e) {
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
if ((opt || marked.defaults).silent) {
return '<p>An error occurred:</p><pre>'
+ escape(e.message + '', true)
+ '</pre>';
}
throw e;
}
}
/**
* Options
*/
marked.options =
marked.setOptions = function(opt) {
merge(marked.defaults, opt);
return marked;
};
marked.getDefaults = function() {
return {
baseUrl: null,
breaks: false,
gfm: true,
headerIds: true,
headerPrefix: '',
highlight: null,
langPrefix: 'language-',
mangle: true,
pedantic: false,
renderer: new Renderer(),
sanitize: false,
sanitizer: null,
silent: false,
smartLists: false,
smartypants: false,
xhtml: false
};
};
marked.defaults = marked.getDefaults();
/**
* Expose
*/
marked.Parser = Parser;
marked.parser = Parser.parse;
marked.Renderer = Renderer;
marked.TextRenderer = TextRenderer;
marked.Lexer = Lexer;
marked.lexer = Lexer.lex;
marked.InlineLexer = InlineLexer;
marked.inlineLexer = InlineLexer.output;
marked.Slugger = Slugger;
marked.parse = marked;
if ('object' !== 'undefined' && 'object' === 'object') {
module.exports = marked;
} else if (typeof undefined === 'function' && undefined.amd) {
undefined(function() { return marked; });
} else {
root.marked = marked;
}
})(commonjsGlobal || (typeof window !== 'undefined' ? window : commonjsGlobal));
});
var speakingurl = createCommonjsModule(function (module) {
(function (root) {
'use strict';
/**
* charMap
* @type {Object}
*/
var charMap = {
// latin
'À': 'A',
'Á': 'A',
'Â': 'A',
'Ã': 'A',
'Ä': 'Ae',
'Å': 'A',
'Æ': 'AE',
'Ç': 'C',
'È': 'E',
'É': 'E',
'Ê': 'E',
'Ë': 'E',
'Ì': 'I',
'Í': 'I',
'Î': 'I',
'Ï': 'I',
'Ð': 'D',
'Ñ': 'N',
'Ò': 'O',
'Ó': 'O',
'Ô': 'O',
'Õ': 'O',
'Ö': 'Oe',
'Ő': 'O',
'Ø': 'O',
'Ù': 'U',
'Ú': 'U',
'Û': 'U',
'Ü': 'Ue',
'Ű': 'U',
'Ý': 'Y',
'Þ': 'TH',
'ß': 'ss',
'à': 'a',
'á': 'a',
'â': 'a',
'ã': 'a',
'ä': 'ae',
'å': 'a',
'æ': 'ae',
'ç': 'c',
'è': 'e',
'é': 'e',
'ê': 'e',
'ë': 'e',
'ì': 'i',
'í': 'i',
'î': 'i',
'ï': 'i',
'ð': 'd',
'ñ': 'n',
'ò': 'o',
'ó': 'o',
'ô': 'o',
'õ': 'o',
'ö': 'oe',
'ő': 'o',
'ø': 'o',
'ù': 'u',
'ú': 'u',
'û': 'u',
'ü': 'ue',
'ű': 'u',
'ý': 'y',
'þ': 'th',
'ÿ': 'y',
'ẞ': 'SS',
// language specific
// Arabic
'ا': 'a',
'أ': 'a',
'إ': 'i',
'آ': 'aa',
'ؤ': 'u',
'ئ': 'e',
'ء': 'a',
'ب': 'b',
'ت': 't',
'ث': 'th',
'ج': 'j',
'ح': 'h',
'خ': 'kh',
'د': 'd',
'ذ': 'th',
'ر': 'r',
'ز': 'z',
'س': 's',
'ش': 'sh',
'ص': 's',
'ض': 'dh',
'ط': 't',
'ظ': 'z',
'ع': 'a',
'غ': 'gh',
'ف': 'f',
'ق': 'q',
'ك': 'k',
'ل': 'l',
'م': 'm',
'ن': 'n',
'ه': 'h',
'و': 'w',
'ي': 'y',
'ى': 'a',
'ة': 'h',
'ﻻ': 'la',
'ﻷ': 'laa',
'ﻹ': 'lai',
'ﻵ': 'laa',
// Persian additional characters than Arabic
'گ': 'g',
'چ': 'ch',
'پ': 'p',
'ژ': 'zh',
'ک': 'k',
'ی': 'y',
// Arabic diactrics
'َ': 'a',
'ً': 'an',
'ِ': 'e',
'ٍ': 'en',
'ُ': 'u',
'ٌ': 'on',
'ْ': '',
// Arabic numbers
'٠': '0',
'١': '1',
'٢': '2',
'٣': '3',
'٤': '4',
'٥': '5',
'٦': '6',
'٧': '7',
'٨': '8',
'٩': '9',
// Persian numbers
'۰': '0',
'۱': '1',
'۲': '2',
'۳': '3',
'۴': '4',
'۵': '5',
'۶': '6',
'۷': '7',
'۸': '8',
'۹': '9',
// Burmese consonants
'က': 'k',
'ခ': 'kh',
'ဂ': 'g',
'ဃ': 'ga',
'င': 'ng',
'စ': 's',
'ဆ': 'sa',
'ဇ': 'z',
'စျ': 'za',
'ည': 'ny',
'ဋ': 't',
'ဌ': 'ta',
'ဍ': 'd',
'ဎ': 'da',
'ဏ': 'na',
'တ': 't',
'ထ': 'ta',
'ဒ': 'd',
'ဓ': 'da',
'န': 'n',
'ပ': 'p',
'ဖ': 'pa',
'ဗ': 'b',
'ဘ': 'ba',
'မ': 'm',
'ယ': 'y',
'ရ': 'ya',
'လ': 'l',
'': 'w',
'သ': 'th',
'ဟ': 'h',
'ဠ': 'la',
'အ': 'a',
// consonant character combos
'ြ': 'y',
'ျ': 'ya',
'ွ': 'w',
'ြွ': 'yw',
'ျွ': 'ywa',
'ှ': 'h',
// independent vowels
'ဧ': 'e',
'၏': '-e',
'ဣ': 'i',
'ဤ': '-i',
'ဉ': 'u',
'ဦ': '-u',
'ဩ': 'aw',
'သြော': 'aw',
'ဪ': 'aw',
// numbers
'': '0',
'၁': '1',
'၂': '2',
'၃': '3',
'၄': '4',
'၅': '5',
'၆': '6',
'၇': '7',
'၈': '8',
'၉': '9',
// virama and tone marks which are silent in transliteration
'္': '',
'့': '',
'း': '',
// Czech
'č': 'c',
'ď': 'd',
'ě': 'e',
'ň': 'n',
'ř': 'r',
'š': 's',
'ť': 't',
'ů': 'u',
'ž': 'z',
'Č': 'C',
'Ď': 'D',
'Ě': 'E',
'Ň': 'N',
'Ř': 'R',
'Š': 'S',
'Ť': 'T',
'Ů': 'U',
'Ž': 'Z',
// Dhivehi
'ހ': 'h',
'ށ': 'sh',
'ނ': 'n',
'ރ': 'r',
'ބ': 'b',
'ޅ': 'lh',
'ކ': 'k',
'އ': 'a',
'ވ': 'v',
'މ': 'm',
'ފ': 'f',
'ދ': 'dh',
'ތ': 'th',
'ލ': 'l',
'ގ': 'g',
'ޏ': 'gn',
'ސ': 's',
'ޑ': 'd',
'ޒ': 'z',
'ޓ': 't',
'ޔ': 'y',
'ޕ': 'p',
'ޖ': 'j',
'ޗ': 'ch',
'ޘ': 'tt',
'ޙ': 'hh',
'ޚ': 'kh',
'ޛ': 'th',
'ޜ': 'z',
'ޝ': 'sh',
'ޞ': 's',
'ޟ': 'd',
'ޠ': 't',
'ޡ': 'z',
'ޢ': 'a',
'ޣ': 'gh',
'ޤ': 'q',
'ޥ': 'w',
'ަ': 'a',
'ާ': 'aa',
'ި': 'i',
'ީ': 'ee',
'ު': 'u',
'ޫ': 'oo',
'ެ': 'e',
'ޭ': 'ey',
'ޮ': 'o',
'ޯ': 'oa',
'ް': '',
// Georgian https://en.wikipedia.org/wiki/Romanization_of_Georgian
// National system (2002)
'ა': 'a',
'ბ': 'b',
'გ': 'g',
'დ': 'd',
'ე': 'e',
'ვ': 'v',
'ზ': 'z',
'თ': 't',
'ი': 'i',
'კ': 'k',
'ლ': 'l',
'მ': 'm',
'ნ': 'n',
'ო': 'o',
'პ': 'p',
'ჟ': 'zh',
'რ': 'r',
'ს': 's',
'ტ': 't',
'უ': 'u',
'ფ': 'p',
'ქ': 'k',
'ღ': 'gh',
'': 'q',
'შ': 'sh',
'ჩ': 'ch',
'ც': 'ts',
'ძ': 'dz',
'წ': 'ts',
'ჭ': 'ch',
'ხ': 'kh',
'ჯ': 'j',
'ჰ': 'h',
// Greek
'α': 'a',
'β': 'v',
'γ': 'g',
'δ': 'd',
'ε': 'e',
'ζ': 'z',
'η': 'i',
'θ': 'th',
'ι': 'i',
'κ': 'k',
'λ': 'l',
'μ': 'm',
'ν': 'n',
'ξ': 'ks',
'ο': 'o',
'π': 'p',
'ρ': 'r',
'σ': 's',
'τ': 't',
'υ': 'y',
'φ': 'f',
'χ': 'x',
'ψ': 'ps',
'ω': 'o',
'ά': 'a',
'έ': 'e',
'ί': 'i',
'ό': 'o',
'ύ': 'y',
'ή': 'i',
'ώ': 'o',
'ς': 's',
'ϊ': 'i',
'ΰ': 'y',
'ϋ': 'y',
'ΐ': 'i',
'Α': 'A',
'Β': 'B',
'Γ': 'G',
'Δ': 'D',
'Ε': 'E',
'Ζ': 'Z',
'Η': 'I',
'Θ': 'TH',
'Ι': 'I',
'Κ': 'K',
'Λ': 'L',
'Μ': 'M',
'Ν': 'N',
'Ξ': 'KS',
'Ο': 'O',
'Π': 'P',
'Ρ': 'R',
'Σ': 'S',
'Τ': 'T',
'Υ': 'Y',
'Φ': 'F',
'Χ': 'X',
'Ψ': 'PS',
'Ω': 'O',
'Ά': 'A',
'Έ': 'E',
'Ί': 'I',
'Ό': 'O',
'Ύ': 'Y',
'Ή': 'I',
'Ώ': 'O',
'Ϊ': 'I',
'Ϋ': 'Y',
// Latvian
'ā': 'a',
// 'č': 'c', // duplicate
'ē': 'e',
'ģ': 'g',
'ī': 'i',
'ķ': 'k',
'ļ': 'l',
'ņ': 'n',
// 'š': 's', // duplicate
'ū': 'u',
// 'ž': 'z', // duplicate
'Ā': 'A',
// 'Č': 'C', // duplicate
'Ē': 'E',
'Ģ': 'G',
'Ī': 'I',
'Ķ': 'k',
'Ļ': 'L',
'Ņ': 'N',
// 'Š': 'S', // duplicate
'Ū': 'U',
// 'Ž': 'Z', // duplicate
// Macedonian
'Ќ': 'Kj',
'ќ': 'kj',
'Љ': 'Lj',
'љ': 'lj',
'Њ': 'Nj',
'њ': 'nj',
'Тс': 'Ts',
'тс': 'ts',
// Polish
'ą': 'a',
'ć': 'c',
'ę': 'e',
'ł': 'l',
'ń': 'n',
// 'ó': 'o', // duplicate
'ś': 's',
'ź': 'z',
'ż': 'z',
'Ą': 'A',
'Ć': 'C',
'Ę': 'E',
'Ł': 'L',
'Ń': 'N',
'Ś': 'S',
'Ź': 'Z',
'Ż': 'Z',
// Ukranian
'Є': 'Ye',
'І': 'I',
'Ї': 'Yi',
'Ґ': 'G',
'є': 'ye',
'і': 'i',
'ї': 'yi',
'ґ': 'g',
// Romanian
'ă': 'a',
'Ă': 'A',
'ș': 's',
'Ș': 'S',
// 'ş': 's', // duplicate
// 'Ş': 'S', // duplicate
'ț': 't',
'Ț': 'T',
'ţ': 't',
'Ţ': 'T',
// Russian https://en.wikipedia.org/wiki/Romanization_of_Russian
// ICAO
'а': 'a',
'б': 'b',
'в': 'v',
'г': 'g',
'д': 'd',
'е': 'e',
'ё': 'yo',
'ж': 'zh',
'з': 'z',
'и': 'i',
'й': 'i',
'к': 'k',
'л': 'l',
'м': 'm',
'н': 'n',
'о': 'o',
'п': 'p',
'р': 'r',
'с': 's',
'т': 't',
'у': 'u',
'ф': 'f',
'х': 'kh',
'ц': 'c',
'ч': 'ch',
'ш': 'sh',
'щ': 'sh',
'ъ': '',
'ы': 'y',
'ь': '',
'э': 'e',
'ю': 'yu',
'я': 'ya',
'А': 'A',
'Б': 'B',
'В': 'V',
'Г': 'G',
'Д': 'D',
'Е': 'E',
'Ё': 'Yo',
'Ж': 'Zh',
'З': 'Z',
'И': 'I',
'Й': 'I',
'К': 'K',
'Л': 'L',
'М': 'M',
'Н': 'N',
'О': 'O',
'П': 'P',
'Р': 'R',
'С': 'S',
'Т': 'T',
'У': 'U',
'Ф': 'F',
'Х': 'Kh',
'Ц': 'C',
'Ч': 'Ch',
'Ш': 'Sh',
'Щ': 'Sh',
'Ъ': '',
'Ы': 'Y',
'Ь': '',
'Э': 'E',
'Ю': 'Yu',
'Я': 'Ya',
// Serbian
'ђ': 'dj',
'ј': 'j',
// 'љ': 'lj', // duplicate
// 'њ': 'nj', // duplicate
'ћ': 'c',
'џ': 'dz',
'Ђ': 'Dj',
'Ј': 'j',
// 'Љ': 'Lj', // duplicate
// 'Њ': 'Nj', // duplicate
'Ћ': 'C',
'Џ': 'Dz',
// Slovak
'ľ': 'l',
'ĺ': 'l',
'ŕ': 'r',
'Ľ': 'L',
'Ĺ': 'L',
'Ŕ': 'R',
// Turkish
'ş': 's',
'Ş': 'S',
'ı': 'i',
'İ': 'I',
// 'ç': 'c', // duplicate
// 'Ç': 'C', // duplicate
// 'ü': 'u', // duplicate, see langCharMap
// 'Ü': 'U', // duplicate, see langCharMap
// 'ö': 'o', // duplicate, see langCharMap
// 'Ö': 'O', // duplicate, see langCharMap
'ğ': 'g',
'Ğ': 'G',
// Vietnamese
'ả': 'a',
'Ả': 'A',
'ẳ': 'a',
'Ẳ': 'A',
'ẩ': 'a',
'Ẩ': 'A',
'đ': 'd',
'Đ': 'D',
'ẹ': 'e',
'Ẹ': 'E',
'ẽ': 'e',
'Ẽ': 'E',
'ẻ': 'e',
'Ẻ': 'E',
'ế': 'e',
'Ế': 'E',
'ề': 'e',
'Ề': 'E',
'ệ': 'e',
'Ệ': 'E',
'ễ': 'e',
'Ễ': 'E',
'ể': 'e',
'Ể': 'E',
'ỏ': 'o',
'ọ': 'o',
'Ọ': 'o',
'ố': 'o',
'Ố': 'O',
'ồ': 'o',
'Ồ': 'O',
'ổ': 'o',
'Ổ': 'O',
'ộ': 'o',
'Ộ': 'O',
'ỗ': 'o',
'Ỗ': 'O',
'ơ': 'o',
'Ơ': 'O',
'ớ': 'o',
'Ớ': 'O',
'ờ': 'o',
'Ờ': 'O',
'ợ': 'o',
'Ợ': 'O',
'ỡ': 'o',
'Ỡ': 'O',
'Ở': 'o',
'ở': 'o',
'ị': 'i',
'Ị': 'I',
'ĩ': 'i',
'Ĩ': 'I',
'ỉ': 'i',
'Ỉ': 'i',
'ủ': 'u',
'Ủ': 'U',
'ụ': 'u',
'Ụ': 'U',
'ũ': 'u',
'Ũ': 'U',
'ư': 'u',
'Ư': 'U',
'ứ': 'u',
'Ứ': 'U',
'ừ': 'u',
'Ừ': 'U',
'ự': 'u',
'Ự': 'U',
'ữ': 'u',
'Ữ': 'U',
'ử': 'u',
'Ử': 'ư',
'ỷ': 'y',
'Ỷ': 'y',
'ỳ': 'y',
'Ỳ': 'Y',
'ỵ': 'y',
'Ỵ': 'Y',
'ỹ': 'y',
'Ỹ': 'Y',
'ạ': 'a',
'Ạ': 'A',
'ấ': 'a',
'Ấ': 'A',
'ầ': 'a',
'Ầ': 'A',
'ậ': 'a',
'Ậ': 'A',
'ẫ': 'a',
'Ẫ': 'A',
// 'ă': 'a', // duplicate
// 'Ă': 'A', // duplicate
'ắ': 'a',
'Ắ': 'A',
'ằ': 'a',
'Ằ': 'A',
'ặ': 'a',
'Ặ': 'A',
'ẵ': 'a',
'Ẵ': 'A',
"⓪": "0",
"①": "1",
"②": "2",
"③": "3",
"④": "4",
"⑤": "5",
"⑥": "6",
"⑦": "7",
"⑧": "8",
"⑨": "9",
"⑩": "10",
"⑪": "11",
"⑫": "12",
"⑬": "13",
"⑭": "14",
"⑮": "15",
"⑯": "16",
"⑰": "17",
"⑱": "18",
"⑲": "18",
"⑳": "18",
"⓵": "1",
"⓶": "2",
"⓷": "3",
"⓸": "4",
"⓹": "5",
"⓺": "6",
"⓻": "7",
"⓼": "8",
"⓽": "9",
"⓾": "10",
"⓿": "0",
"⓫": "11",
"⓬": "12",
"⓭": "13",
"⓮": "14",
"⓯": "15",
"⓰": "16",
"⓱": "17",
"⓲": "18",
"⓳": "19",
"⓴": "20",
"Ⓐ": "A",
"Ⓑ": "B",
"Ⓒ": "C",
"Ⓓ": "D",
"Ⓔ": "E",
"Ⓕ": "F",
"Ⓖ": "G",
"Ⓗ": "H",
"Ⓘ": "I",
"Ⓙ": "J",
"Ⓚ": "K",
"Ⓛ": "L",
"Ⓜ": "M",
"Ⓝ": "N",
"Ⓞ": "O",
"Ⓟ": "P",
"Ⓠ": "Q",
"Ⓡ": "R",
"Ⓢ": "S",
"Ⓣ": "T",
"Ⓤ": "U",
"Ⓥ": "V",
"Ⓦ": "W",
"Ⓧ": "X",
"Ⓨ": "Y",
"Ⓩ": "Z",
"ⓐ": "a",
"ⓑ": "b",
"ⓒ": "c",
"ⓓ": "d",
"ⓔ": "e",
"ⓕ": "f",
"ⓖ": "g",
"ⓗ": "h",
"ⓘ": "i",
"ⓙ": "j",
"ⓚ": "k",
"ⓛ": "l",
"ⓜ": "m",
"ⓝ": "n",
"ⓞ": "o",
"ⓟ": "p",
"ⓠ": "q",
"ⓡ": "r",
"ⓢ": "s",
"ⓣ": "t",
"ⓤ": "u",
"ⓦ": "v",
"ⓥ": "w",
"ⓧ": "x",
"ⓨ": "y",
"ⓩ": "z",
// symbols
'“': '"',
'”': '"',
'': "'",
'': "'",
'∂': 'd',
'ƒ': 'f',
'™': '(TM)',
'©': '(C)',
'œ': 'oe',
'Œ': 'OE',
'®': '(R)',
'†': '+',
'℠': '(SM)',
'…': '...',
'˚': 'o',
'º': 'o',
'ª': 'a',
'•': '*',
'၊': ',',
'။': '.',
// currency
'$': 'USD',
'€': 'EUR',
'₢': 'BRN',
'₣': 'FRF',
'£': 'GBP',
'₤': 'ITL',
'₦': 'NGN',
'₧': 'ESP',
'₩': 'KRW',
'₪': 'ILS',
'₫': 'VND',
'₭': 'LAK',
'₮': 'MNT',
'₯': 'GRD',
'₱': 'ARS',
'₲': 'PYG',
'₳': 'ARA',
'₴': 'UAH',
'₵': 'GHS',
'¢': 'cent',
'¥': 'CNY',
'元': 'CNY',
'円': 'YEN',
'﷼': 'IRR',
'₠': 'EWE',
'฿': 'THB',
'₨': 'INR',
'₹': 'INR',
'₰': 'PF',
'₺': 'TRY',
'؋': 'AFN',
'₼': 'AZN',
'лв': 'BGN',
'៛': 'KHR',
'₡': 'CRC',
'₸': 'KZT',
'ден': 'MKD',
'zł': 'PLN',
'₽': 'RUB',
'₾': 'GEL'
};
/**
* special look ahead character array
* These characters form with consonants to become 'single'/consonant combo
* @type [Array]
*/
var lookAheadCharArray = [
// burmese
'်',
// Dhivehi
'ް'
];
/**
* diatricMap for languages where transliteration changes entirely as more diatrics are added
* @type {Object}
*/
var diatricMap = {
// Burmese
// dependent vowels
'ာ': 'a',
'ါ': 'a',
'ေ': 'e',
'ဲ': 'e',
'ိ': 'i',
'ီ': 'i',
'ို': 'o',
'ု': 'u',
'ူ': 'u',
'ေါင်': 'aung',
'ော': 'aw',
'ော်': 'aw',
'ေါ': 'aw',
'ေါ်': 'aw',
'်': '်', // this is special case but the character will be converted to latin in the code
'က်': 'et',
'ိုက်': 'aik',
'ောက်': 'auk',
'င်': 'in',
'ိုင်': 'aing',
'ောင်': 'aung',
'စ်': 'it',
'ည်': 'i',
'တ်': 'at',
'ိတ်': 'eik',
'ုတ်': 'ok',
'ွတ်': 'ut',
'ေတ်': 'it',
'ဒ်': 'd',
'ိုဒ်': 'ok',
'ုဒ်': 'ait',
'န်': 'an',
'ာန်': 'an',
'ိန်': 'ein',
'ုန်': 'on',
'ွန်': 'un',
'ပ်': 'at',
'ိပ်': 'eik',
'ုပ်': 'ok',
'ွပ်': 'ut',
'န်ုပ်': 'nub',
'မ်': 'an',
'ိမ်': 'ein',
'ုမ်': 'on',
'ွမ်': 'un',
'ယ်': 'e',
'ိုလ်': 'ol',
'ဉ်': 'in',
'ံ': 'an',
'ိံ': 'ein',
'ုံ': 'on',
// Dhivehi
'ައް': 'ah',
'ަށް': 'ah'
};
/**
* langCharMap language specific characters translations
* @type {Object}
*/
var langCharMap = {
'en': {}, // default language
'az': { // Azerbaijani
'ç': 'c',
'ə': 'e',
'ğ': 'g',
'ı': 'i',
'ö': 'o',
'ş': 's',
'ü': 'u',
'Ç': 'C',
'Ə': 'E',
'Ğ': 'G',
'İ': 'I',
'Ö': 'O',
'Ş': 'S',
'Ü': 'U'
},
'cs': { // Czech
'č': 'c',
'ď': 'd',
'ě': 'e',
'ň': 'n',
'ř': 'r',
'š': 's',
'ť': 't',
'ů': 'u',
'ž': 'z',
'Č': 'C',
'Ď': 'D',
'Ě': 'E',
'Ň': 'N',
'Ř': 'R',
'Š': 'S',
'Ť': 'T',
'Ů': 'U',
'Ž': 'Z'
},
'fi': { // Finnish
// 'å': 'a', duplicate see charMap/latin
// 'Å': 'A', duplicate see charMap/latin
'ä': 'a', // ok
'Ä': 'A', // ok
'ö': 'o', // ok
'Ö': 'O' // ok
},
'hu': { // Hungarian
'ä': 'a', // ok
'Ä': 'A', // ok
// 'á': 'a', duplicate see charMap/latin
// 'Á': 'A', duplicate see charMap/latin
'ö': 'o', // ok
'Ö': 'O', // ok
// 'ő': 'o', duplicate see charMap/latin
// 'Ő': 'O', duplicate see charMap/latin
'ü': 'u',
'Ü': 'U',
'ű': 'u',
'Ű': 'U'
},
'lt': { // Lithuanian
'ą': 'a',
'č': 'c',
'ę': 'e',
'ė': 'e',
'į': 'i',
'š': 's',
'ų': 'u',
'ū': 'u',
'ž': 'z',
'Ą': 'A',
'Č': 'C',
'Ę': 'E',
'Ė': 'E',
'Į': 'I',
'Š': 'S',
'Ų': 'U',
'Ū': 'U'
},
'lv': { // Latvian
'ā': 'a',
'č': 'c',
'ē': 'e',
'ģ': 'g',
'ī': 'i',
'ķ': 'k',
'ļ': 'l',
'ņ': 'n',
'š': 's',
'ū': 'u',
'ž': 'z',
'Ā': 'A',
'Č': 'C',
'Ē': 'E',
'Ģ': 'G',
'Ī': 'i',
'Ķ': 'k',
'Ļ': 'L',
'Ņ': 'N',
'Š': 'S',
'Ū': 'u',
'Ž': 'Z'
},
'pl': { // Polish
'ą': 'a',
'ć': 'c',
'ę': 'e',
'ł': 'l',
'ń': 'n',
'ó': 'o',
'ś': 's',
'ź': 'z',
'ż': 'z',
'Ą': 'A',
'Ć': 'C',
'Ę': 'e',
'Ł': 'L',
'Ń': 'N',
'Ó': 'O',
'Ś': 'S',
'Ź': 'Z',
'Ż': 'Z'
},
'sv': { // Swedish
// 'å': 'a', duplicate see charMap/latin
// 'Å': 'A', duplicate see charMap/latin
'ä': 'a', // ok
'Ä': 'A', // ok
'ö': 'o', // ok
'Ö': 'O' // ok
},
'sk': { // Slovak
'ä': 'a',
'Ä': 'A'
},
'sr': { // Serbian
'љ': 'lj',
'њ': 'nj',
'Љ': 'Lj',
'Њ': 'Nj',
'đ': 'dj',
'Đ': 'Dj'
},
'tr': { // Turkish
'Ü': 'U',
'Ö': 'O',
'ü': 'u',
'ö': 'o'
}
};
/**
* symbolMap language specific symbol translations
* translations must be transliterated already
* @type {Object}
*/
var symbolMap = {
'ar': {
'∆': 'delta',
'∞': 'la-nihaya',
'♥': 'hob',
'&': 'wa',
'|': 'aw',
'<': 'aqal-men',
'>': 'akbar-men',
'∑': 'majmou',
'¤': 'omla'
},
'az': {},
'ca': {
'∆': 'delta',
'∞': 'infinit',
'♥': 'amor',
'&': 'i',
'|': 'o',
'<': 'menys que',
'>': 'mes que',
'∑': 'suma dels',
'¤': 'moneda'
},
'cs': {
'∆': 'delta',
'∞': 'nekonecno',
'♥': 'laska',
'&': 'a',
'|': 'nebo',
'<': 'mensi nez',
'>': 'vetsi nez',
'∑': 'soucet',
'¤': 'mena'
},
'de': {
'∆': 'delta',
'∞': 'unendlich',
'♥': 'Liebe',
'&': 'und',
'|': 'oder',
'<': 'kleiner als',
'>': 'groesser als',
'∑': 'Summe von',
'¤': 'Waehrung'
},
'dv': {
'∆': 'delta',
'∞': 'kolunulaa',
'♥': 'loabi',
'&': 'aai',
'|': 'noonee',
'<': 'ah vure kuda',
'>': 'ah vure bodu',
'∑': 'jumula',
'¤': 'faisaa'
},
'en': {
'∆': 'delta',
'∞': 'infinity',
'♥': 'love',
'&': 'and',
'|': 'or',
'<': 'less than',
'>': 'greater than',
'∑': 'sum',
'¤': 'currency'
},
'es': {
'∆': 'delta',
'∞': 'infinito',
'♥': 'amor',
'&': 'y',
'|': 'u',
'<': 'menos que',
'>': 'mas que',
'∑': 'suma de los',
'¤': 'moneda'
},
'fa': {
'∆': 'delta',
'∞': 'bi-nahayat',
'♥': 'eshgh',
'&': 'va',
'|': 'ya',
'<': 'kamtar-az',
'>': 'bishtar-az',
'∑': 'majmooe',
'¤': 'vahed'
},
'fi': {
'∆': 'delta',
'∞': 'aarettomyys',
'♥': 'rakkaus',
'&': 'ja',
'|': 'tai',
'<': 'pienempi kuin',
'>': 'suurempi kuin',
'∑': 'summa',
'¤': 'valuutta'
},
'fr': {
'∆': 'delta',
'∞': 'infiniment',
'♥': 'Amour',
'&': 'et',
'|': 'ou',
'<': 'moins que',
'>': 'superieure a',
'∑': 'somme des',
'¤': 'monnaie'
},
'ge': {
'∆': 'delta',
'∞': 'usasruloba',
'♥': 'siqvaruli',
'&': 'da',
'|': 'an',
'<': 'naklebi',
'>': 'meti',
'∑': 'jami',
'¤': 'valuta'
},
'gr': {},
'hu': {
'∆': 'delta',
'∞': 'vegtelen',
'♥': 'szerelem',
'&': 'es',
'|': 'vagy',
'<': 'kisebb mint',
'>': 'nagyobb mint',
'∑': 'szumma',
'¤': 'penznem'
},
'it': {
'∆': 'delta',
'∞': 'infinito',
'♥': 'amore',
'&': 'e',
'|': 'o',
'<': 'minore di',
'>': 'maggiore di',
'∑': 'somma',
'¤': 'moneta'
},
'lt': {
'∆': 'delta',
'∞': 'begalybe',
'♥': 'meile',
'&': 'ir',
'|': 'ar',
'<': 'maziau nei',
'>': 'daugiau nei',
'∑': 'suma',
'¤': 'valiuta'
},
'lv': {
'∆': 'delta',
'∞': 'bezgaliba',
'♥': 'milestiba',
'&': 'un',
'|': 'vai',
'<': 'mazak neka',
'>': 'lielaks neka',
'∑': 'summa',
'¤': 'valuta'
},
'my': {
'∆': 'kwahkhyaet',
'∞': 'asaonasme',
'♥': 'akhyait',
'&': 'nhin',
'|': 'tho',
'<': 'ngethaw',
'>': 'kyithaw',
'∑': 'paungld',
'¤': 'ngwekye'
},
'mk': {},
'nl': {
'∆': 'delta',
'∞': 'oneindig',
'♥': 'liefde',
'&': 'en',
'|': 'of',
'<': 'kleiner dan',
'>': 'groter dan',
'∑': 'som',
'¤': 'valuta'
},
'pl': {
'∆': 'delta',
'∞': 'nieskonczonosc',
'♥': 'milosc',
'&': 'i',
'|': 'lub',
'<': 'mniejsze niz',
'>': 'wieksze niz',
'∑': 'suma',
'¤': 'waluta'
},
'pt': {
'∆': 'delta',
'∞': 'infinito',
'♥': 'amor',
'&': 'e',
'|': 'ou',
'<': 'menor que',
'>': 'maior que',
'∑': 'soma',
'¤': 'moeda'
},
'ro': {
'∆': 'delta',
'∞': 'infinit',
'♥': 'dragoste',
'&': 'si',
'|': 'sau',
'<': 'mai mic ca',
'>': 'mai mare ca',
'∑': 'suma',
'¤': 'valuta'
},
'ru': {
'∆': 'delta',
'∞': 'beskonechno',
'♥': 'lubov',
'&': 'i',
'|': 'ili',
'<': 'menshe',
'>': 'bolshe',
'∑': 'summa',
'¤': 'valjuta'
},
'sk': {
'∆': 'delta',
'∞': 'nekonecno',
'♥': 'laska',
'&': 'a',
'|': 'alebo',
'<': 'menej ako',
'>': 'viac ako',
'∑': 'sucet',
'¤': 'mena'
},
'sr': {},
'tr': {
'∆': 'delta',
'∞': 'sonsuzluk',
'♥': 'ask',
'&': 've',
'|': 'veya',
'<': 'kucuktur',
'>': 'buyuktur',
'∑': 'toplam',
'¤': 'para birimi'
},
'uk': {
'∆': 'delta',
'∞': 'bezkinechnist',
'♥': 'lubov',
'&': 'i',
'|': 'abo',
'<': 'menshe',
'>': 'bilshe',
'∑': 'suma',
'¤': 'valjuta'
},
'vn': {
'∆': 'delta',
'∞': 'vo cuc',
'♥': 'yeu',
'&': 'va',
'|': 'hoac',
'<': 'nho hon',
'>': 'lon hon',
'∑': 'tong',
'¤': 'tien te'
}
};
var uricChars = [';', '?', ':', '@', '&', '=', '+', '$', ',', '/'].join('');
var uricNoSlashChars = [';', '?', ':', '@', '&', '=', '+', '$', ','].join('');
var markChars = ['.', '!', '~', '*', "'", '(', ')'].join('');
/**
* getSlug
* @param {string} input input string
* @param {object|string} opts config object or separator string/char
* @api public
* @return {string} sluggified string
*/
var getSlug = function getSlug(input, opts) {
var separator = '-';
var result = '';
var diatricString = '';
var convertSymbols = true;
var customReplacements = {};
var maintainCase;
var titleCase;
var truncate;
var uricFlag;
var uricNoSlashFlag;
var markFlag;
var symbol;
var langChar;
var lucky;
var i;
var ch;
var l;
var lastCharWasSymbol;
var lastCharWasDiatric;
var allowedChars = '';
if (typeof input !== 'string') {
return '';
}
if (typeof opts === 'string') {
separator = opts;
}
symbol = symbolMap.en;
langChar = langCharMap.en;
if (typeof opts === 'object') {
maintainCase = opts.maintainCase || false;
customReplacements = (opts.custom && typeof opts.custom === 'object') ? opts.custom : customReplacements;
truncate = (+opts.truncate > 1 && opts.truncate) || false;
uricFlag = opts.uric || false;
uricNoSlashFlag = opts.uricNoSlash || false;
markFlag = opts.mark || false;
convertSymbols = (opts.symbols === false || opts.lang === false) ? false : true;
separator = opts.separator || separator;
if (uricFlag) {
allowedChars += uricChars;
}
if (uricNoSlashFlag) {
allowedChars += uricNoSlashChars;
}
if (markFlag) {
allowedChars += markChars;
}
symbol = (opts.lang && symbolMap[opts.lang] && convertSymbols) ?
symbolMap[opts.lang] : (convertSymbols ? symbolMap.en : {});
langChar = (opts.lang && langCharMap[opts.lang]) ?
langCharMap[opts.lang] :
opts.lang === false || opts.lang === true ? {} : langCharMap.en;
// if titleCase config is an Array, rewrite to object format
if (opts.titleCase && typeof opts.titleCase.length === 'number' && Array.prototype.toString.call(opts.titleCase)) {
opts.titleCase.forEach(function (v) {
customReplacements[v + ''] = v + '';
});
titleCase = true;
} else {
titleCase = !!opts.titleCase;
}
// if custom config is an Array, rewrite to object format
if (opts.custom && typeof opts.custom.length === 'number' && Array.prototype.toString.call(opts.custom)) {
opts.custom.forEach(function (v) {
customReplacements[v + ''] = v + '';
});
}
// custom replacements
Object.keys(customReplacements).forEach(function (v) {
var r;
if (v.length > 1) {
r = new RegExp('\\b' + escapeChars(v) + '\\b', 'gi');
} else {
r = new RegExp(escapeChars(v), 'gi');
}
input = input.replace(r, customReplacements[v]);
});
// add all custom replacement to allowed charlist
for (ch in customReplacements) {
allowedChars += ch;
}
}
allowedChars += separator;
// escape all necessary chars
allowedChars = escapeChars(allowedChars);
// trim whitespaces
input = input.replace(/(^\s+|\s+$)/g, '');
lastCharWasSymbol = false;
lastCharWasDiatric = false;
for (i = 0, l = input.length; i < l; i++) {
ch = input[i];
if (isReplacedCustomChar(ch, customReplacements)) {
// don't convert a already converted char
lastCharWasSymbol = false;
} else if (langChar[ch]) {
// process language specific diactrics chars conversion
ch = lastCharWasSymbol && langChar[ch].match(/[A-Za-z0-9]/) ? ' ' + langChar[ch] : langChar[ch];
lastCharWasSymbol = false;
} else if (ch in charMap) {
// the transliteration changes entirely when some special characters are added
if (i + 1 < l && lookAheadCharArray.indexOf(input[i + 1]) >= 0) {
diatricString += ch;
ch = '';
} else if (lastCharWasDiatric === true) {
ch = diatricMap[diatricString] + charMap[ch];
diatricString = '';
} else {
// process diactrics chars
ch = lastCharWasSymbol && charMap[ch].match(/[A-Za-z0-9]/) ? ' ' + charMap[ch] : charMap[ch];
}
lastCharWasSymbol = false;
lastCharWasDiatric = false;
} else if (ch in diatricMap) {
diatricString += ch;
ch = '';
// end of string, put the whole meaningful word
if (i === l - 1) {
ch = diatricMap[diatricString];
}
lastCharWasDiatric = true;
} else if (
// process symbol chars
symbol[ch] && !(uricFlag && uricChars
.indexOf(ch) !== -1) && !(uricNoSlashFlag && uricNoSlashChars
// .indexOf(ch) !== -1) && !(markFlag && markChars
.indexOf(ch) !== -1)) {
ch = lastCharWasSymbol || result.substr(-1).match(/[A-Za-z0-9]/) ? separator + symbol[ch] : symbol[ch];
ch += input[i + 1] !== void 0 && input[i + 1].match(/[A-Za-z0-9]/) ? separator : '';
lastCharWasSymbol = true;
} else {
if (lastCharWasDiatric === true) {
ch = diatricMap[diatricString] + ch;
diatricString = '';
lastCharWasDiatric = false;
} else if (lastCharWasSymbol && (/[A-Za-z0-9]/.test(ch) || result.substr(-1).match(/A-Za-z0-9]/))) {
// process latin chars
ch = ' ' + ch;
}
lastCharWasSymbol = false;
}
// add allowed chars
result += ch.replace(new RegExp('[^\\w\\s' + allowedChars + '_-]', 'g'), separator);
}
if (titleCase) {
result = result.replace(/(\w)(\S*)/g, function (_, i, r) {
var j = i.toUpperCase() + (r !== null ? r : '');
return (Object.keys(customReplacements).indexOf(j.toLowerCase()) < 0) ? j : j.toLowerCase();
});
}
// eliminate duplicate separators
// add separator
// trim separators from start and end
result = result.replace(/\s+/g, separator)
.replace(new RegExp('\\' + separator + '+', 'g'), separator)
.replace(new RegExp('(^\\' + separator + '+|\\' + separator + '+$)', 'g'), '');
if (truncate && result.length > truncate) {
lucky = result.charAt(truncate) === separator;
result = result.slice(0, truncate);
if (!lucky) {
result = result.slice(0, result.lastIndexOf(separator));
}
}
if (!maintainCase && !titleCase) {
result = result.toLowerCase();
}
return result;
};
/**
* createSlug curried(opts)(input)
* @param {object|string} opts config object or input string
* @return {Function} function getSlugWithConfig()
**/
var createSlug = function createSlug(opts) {
/**
* getSlugWithConfig
* @param {string} input string
* @return {string} slug string
*/
return function getSlugWithConfig(input) {
return getSlug(input, opts);
};
};
/**
* escape Chars
* @param {string} input string
*/
var escapeChars = function escapeChars(input) {
return input.replace(/[-\\^$*+?.()|[\]{}\/]/g, '\\$&');
};
/**
* check if the char is an already converted char from custom list
* @param {char} ch character to check
* @param {object} customReplacements custom translation map
*/
var isReplacedCustomChar = function (ch, customReplacements) {
for (var c in customReplacements) {
if (customReplacements[c] === ch) {
return true;
}
}
};
if ('object' !== 'undefined' && module.exports) {
// export functions for use in Node
module.exports = getSlug;
module.exports.createSlug = createSlug;
} else if (typeof undefined !== 'undefined' && undefined.amd) {
// export function for use in AMD
undefined([], function () {
return getSlug;
});
} else {
// don't overwrite global if exists
try {
if (root.getSlug || root.createSlug) {
throw 'speakingurl: globals exists /(getSlug|createSlug)/';
} else {
root.getSlug = getSlug;
root.createSlug = createSlug;
}
} catch (e) {}
}
})(commonjsGlobal);
});
var speakingurl_1 = speakingurl.createSlug;
var speakingurl$1 = speakingurl;
var urlJoin = createCommonjsModule(function (module) {
(function (name, context, definition) {
if ('object' !== 'undefined' && module.exports) module.exports = definition();
else if (typeof undefined === 'function' && undefined.amd) undefined(definition);
else context[name] = definition();
})('urljoin', commonjsGlobal, function () {
function normalize (strArray) {
var resultArray = [];
if (strArray.length === 0) { return ''; }
if (typeof strArray[0] !== 'string') {
throw new TypeError('Url must be a string. Received ' + strArray[0]);
}
// If the first part is a plain protocol, we combine it with the next part.
if (strArray[0].match(/^[^/:]+:\/*$/) && strArray.length > 1) {
var first = strArray.shift();
strArray[0] = first + strArray[0];
}
// There must be two or three slashes in the file protocol, two slashes in anything else.
if (strArray[0].match(/^file:\/\/\//)) {
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1:///');
} else {
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1://');
}
for (var i = 0; i < strArray.length; i++) {
var component = strArray[i];
if (typeof component !== 'string') {
throw new TypeError('Url must be a string. Received ' + component);
}
if (component === '') { continue; }
if (i > 0) {
// Removing the starting slashes for each component but the first.
component = component.replace(/^[\/]+/, '');
}
if (i < strArray.length - 1) {
// Removing the ending slashes for each component but the last.
component = component.replace(/[\/]+$/, '');
} else {
// For the last component we will combine multiple slashes to a single one.
component = component.replace(/[\/]+$/, '/');
}
resultArray.push(component);
}
var str = resultArray.join('/');
// Each input component is now separated by a single slash except the possible first plain protocol part.
// remove trailing slash before parameters or hash
str = str.replace(/\/(\?|&|#[^!])/g, '$1');
// replace ? in parameters with &
var parts = str.split('?');
str = parts.shift() + (parts.length > 0 ? '?': '') + parts.join('&');
return str;
}
return function () {
var input;
if (typeof arguments[0] === 'object') {
input = arguments[0];
} else {
input = [].slice.call(arguments);
}
return normalize(input);
};
});
});
var uritemplate = createCommonjsModule(function (module) {
/*global unescape, module, define, window, global*/
/*
UriTemplate Copyright (c) 2012-2013 Franz Antesberger. All Rights Reserved.
Available via the MIT license.
*/
(function (exportCallback) {
"use strict";
var UriTemplateError = (function () {
function UriTemplateError (options) {
this.options = options;
}
UriTemplateError.prototype.toString = function () {
if (JSON && JSON.stringify) {
return JSON.stringify(this.options);
}
else {
return this.options;
}
};
return UriTemplateError;
}());
var objectHelper = (function () {
function isArray (value) {
return Object.prototype.toString.apply(value) === '[object Array]';
}
function isString (value) {
return Object.prototype.toString.apply(value) === '[object String]';
}
function isNumber (value) {
return Object.prototype.toString.apply(value) === '[object Number]';
}
function isBoolean (value) {
return Object.prototype.toString.apply(value) === '[object Boolean]';
}
function join (arr, separator) {
var
result = '',
first = true,
index;
for (index = 0; index < arr.length; index += 1) {
if (first) {
first = false;
}
else {
result += separator;
}
result += arr[index];
}
return result;
}
function map (arr, mapper) {
var
result = [],
index = 0;
for (; index < arr.length; index += 1) {
result.push(mapper(arr[index]));
}
return result;
}
function filter (arr, predicate) {
var
result = [],
index = 0;
for (; index < arr.length; index += 1) {
if (predicate(arr[index])) {
result.push(arr[index]);
}
}
return result;
}
function deepFreezeUsingObjectFreeze (object) {
if (typeof object !== "object" || object === null) {
return object;
}
Object.freeze(object);
var property, propertyName;
for (propertyName in object) {
if (object.hasOwnProperty(propertyName)) {
property = object[propertyName];
// be aware, arrays are 'object', too
if (typeof property === "object") {
deepFreeze(property);
}
}
}
return object;
}
function deepFreeze (object) {
if (typeof Object.freeze === 'function') {
return deepFreezeUsingObjectFreeze(object);
}
return object;
}
return {
isArray: isArray,
isString: isString,
isNumber: isNumber,
isBoolean: isBoolean,
join: join,
map: map,
filter: filter,
deepFreeze: deepFreeze
};
}());
var charHelper = (function () {
function isAlpha (chr) {
return (chr >= 'a' && chr <= 'z') || ((chr >= 'A' && chr <= 'Z'));
}
function isDigit (chr) {
return chr >= '0' && chr <= '9';
}
function isHexDigit (chr) {
return isDigit(chr) || (chr >= 'a' && chr <= 'f') || (chr >= 'A' && chr <= 'F');
}
return {
isAlpha: isAlpha,
isDigit: isDigit,
isHexDigit: isHexDigit
};
}());
var pctEncoder = (function () {
var utf8 = {
encode: function (chr) {
// see http://ecmanaut.blogspot.de/2006/07/encoding-decoding-utf8-in-javascript.html
return unescape(encodeURIComponent(chr));
},
numBytes: function (firstCharCode) {
if (firstCharCode <= 0x7F) {
return 1;
}
else if (0xC2 <= firstCharCode && firstCharCode <= 0xDF) {
return 2;
}
else if (0xE0 <= firstCharCode && firstCharCode <= 0xEF) {
return 3;
}
else if (0xF0 <= firstCharCode && firstCharCode <= 0xF4) {
return 4;
}
// no valid first octet
return 0;
},
isValidFollowingCharCode: function (charCode) {
return 0x80 <= charCode && charCode <= 0xBF;
}
};
/**
* encodes a character, if needed or not.
* @param chr
* @return pct-encoded character
*/
function encodeCharacter (chr) {
var
result = '',
octets = utf8.encode(chr),
octet,
index;
for (index = 0; index < octets.length; index += 1) {
octet = octets.charCodeAt(index);
result += '%' + (octet < 0x10 ? '0' : '') + octet.toString(16).toUpperCase();
}
return result;
}
/**
* Returns, whether the given text at start is in the form 'percent hex-digit hex-digit', like '%3F'
* @param text
* @param start
* @return {boolean|*|*}
*/
function isPercentDigitDigit (text, start) {
return text.charAt(start) === '%' && charHelper.isHexDigit(text.charAt(start + 1)) && charHelper.isHexDigit(text.charAt(start + 2));
}
/**
* Parses a hex number from start with length 2.
* @param text a string
* @param start the start index of the 2-digit hex number
* @return {Number}
*/
function parseHex2 (text, start) {
return parseInt(text.substr(start, 2), 16);
}
/**
* Returns whether or not the given char sequence is a correctly pct-encoded sequence.
* @param chr
* @return {boolean}
*/
function isPctEncoded (chr) {
if (!isPercentDigitDigit(chr, 0)) {
return false;
}
var firstCharCode = parseHex2(chr, 1);
var numBytes = utf8.numBytes(firstCharCode);
if (numBytes === 0) {
return false;
}
for (var byteNumber = 1; byteNumber < numBytes; byteNumber += 1) {
if (!isPercentDigitDigit(chr, 3*byteNumber) || !utf8.isValidFollowingCharCode(parseHex2(chr, 3*byteNumber + 1))) {
return false;
}
}
return true;
}
/**
* Reads as much as needed from the text, e.g. '%20' or '%C3%B6'. It does not decode!
* @param text
* @param startIndex
* @return the character or pct-string of the text at startIndex
*/
function pctCharAt(text, startIndex) {
var chr = text.charAt(startIndex);
if (!isPercentDigitDigit(text, startIndex)) {
return chr;
}
var utf8CharCode = parseHex2(text, startIndex + 1);
var numBytes = utf8.numBytes(utf8CharCode);
if (numBytes === 0) {
return chr;
}
for (var byteNumber = 1; byteNumber < numBytes; byteNumber += 1) {
if (!isPercentDigitDigit(text, startIndex + 3 * byteNumber) || !utf8.isValidFollowingCharCode(parseHex2(text, startIndex + 3 * byteNumber + 1))) {
return chr;
}
}
return text.substr(startIndex, 3 * numBytes);
}
return {
encodeCharacter: encodeCharacter,
isPctEncoded: isPctEncoded,
pctCharAt: pctCharAt
};
}());
var rfcCharHelper = (function () {
/**
* Returns if an character is an varchar character according 2.3 of rfc 6570
* @param chr
* @return (Boolean)
*/
function isVarchar (chr) {
return charHelper.isAlpha(chr) || charHelper.isDigit(chr) || chr === '_' || pctEncoder.isPctEncoded(chr);
}
/**
* Returns if chr is an unreserved character according 1.5 of rfc 6570
* @param chr
* @return {Boolean}
*/
function isUnreserved (chr) {
return charHelper.isAlpha(chr) || charHelper.isDigit(chr) || chr === '-' || chr === '.' || chr === '_' || chr === '~';
}
/**
* Returns if chr is an reserved character according 1.5 of rfc 6570
* or the percent character mentioned in 3.2.1.
* @param chr
* @return {Boolean}
*/
function isReserved (chr) {
return chr === ':' || chr === '/' || chr === '?' || chr === '#' || chr === '[' || chr === ']' || chr === '@' || chr === '!' || chr === '$' || chr === '&' || chr === '(' ||
chr === ')' || chr === '*' || chr === '+' || chr === ',' || chr === ';' || chr === '=' || chr === "'";
}
return {
isVarchar: isVarchar,
isUnreserved: isUnreserved,
isReserved: isReserved
};
}());
/**
* encoding of rfc 6570
*/
var encodingHelper = (function () {
function encode (text, passReserved) {
var
result = '',
index,
chr = '';
if (typeof text === "number" || typeof text === "boolean") {
text = text.toString();
}
for (index = 0; index < text.length; index += chr.length) {
chr = text.charAt(index);
result += rfcCharHelper.isUnreserved(chr) || (passReserved && rfcCharHelper.isReserved(chr)) ? chr : pctEncoder.encodeCharacter(chr);
}
return result;
}
function encodePassReserved (text) {
return encode(text, true);
}
function encodeLiteralCharacter (literal, index) {
var chr = pctEncoder.pctCharAt(literal, index);
if (chr.length > 1) {
return chr;
}
else {
return rfcCharHelper.isReserved(chr) || rfcCharHelper.isUnreserved(chr) ? chr : pctEncoder.encodeCharacter(chr);
}
}
function encodeLiteral (literal) {
var
result = '',
index,
chr = '';
for (index = 0; index < literal.length; index += chr.length) {
chr = pctEncoder.pctCharAt(literal, index);
if (chr.length > 1) {
result += chr;
}
else {
result += rfcCharHelper.isReserved(chr) || rfcCharHelper.isUnreserved(chr) ? chr : pctEncoder.encodeCharacter(chr);
}
}
return result;
}
return {
encode: encode,
encodePassReserved: encodePassReserved,
encodeLiteral: encodeLiteral,
encodeLiteralCharacter: encodeLiteralCharacter
};
}());
// the operators defined by rfc 6570
var operators = (function () {
var
bySymbol = {};
function create (symbol) {
bySymbol[symbol] = {
symbol: symbol,
separator: (symbol === '?') ? '&' : (symbol === '' || symbol === '+' || symbol === '#') ? ',' : symbol,
named: symbol === ';' || symbol === '&' || symbol === '?',
ifEmpty: (symbol === '&' || symbol === '?') ? '=' : '',
first: (symbol === '+' ) ? '' : symbol,
encode: (symbol === '+' || symbol === '#') ? encodingHelper.encodePassReserved : encodingHelper.encode,
toString: function () {
return this.symbol;
}
};
}
create('');
create('+');
create('#');
create('.');
create('/');
create(';');
create('?');
create('&');
return {
valueOf: function (chr) {
if (bySymbol[chr]) {
return bySymbol[chr];
}
if ("=,!@|".indexOf(chr) >= 0) {
return null;
}
return bySymbol[''];
}
};
}());
/**
* Detects, whether a given element is defined in the sense of rfc 6570
* Section 2.3 of the RFC makes clear defintions:
* * undefined and null are not defined.
* * the empty string is defined
* * an array ("list") is defined, if it is not empty (even if all elements are not defined)
* * an object ("map") is defined, if it contains at least one property with defined value
* @param object
* @return {Boolean}
*/
function isDefined (object) {
var
propertyName;
if (object === null || object === undefined) {
return false;
}
if (objectHelper.isArray(object)) {
// Section 2.3: A variable defined as a list value is considered undefined if the list contains zero members
return object.length > 0;
}
if (typeof object === "string" || typeof object === "number" || typeof object === "boolean") {
// falsy values like empty strings, false or 0 are "defined"
return true;
}
// else Object
for (propertyName in object) {
if (object.hasOwnProperty(propertyName) && isDefined(object[propertyName])) {
return true;
}
}
return false;
}
var LiteralExpression = (function () {
function LiteralExpression (literal) {
this.literal = encodingHelper.encodeLiteral(literal);
}
LiteralExpression.prototype.expand = function () {
return this.literal;
};
LiteralExpression.prototype.toString = LiteralExpression.prototype.expand;
return LiteralExpression;
}());
var parse = (function () {
function parseExpression (expressionText) {
var
operator,
varspecs = [],
varspec = null,
varnameStart = null,
maxLengthStart = null,
index,
chr = '';
function closeVarname () {
var varname = expressionText.substring(varnameStart, index);
if (varname.length === 0) {
throw new UriTemplateError({expressionText: expressionText, message: "a varname must be specified", position: index});
}
varspec = {varname: varname, exploded: false, maxLength: null};
varnameStart = null;
}
function closeMaxLength () {
if (maxLengthStart === index) {
throw new UriTemplateError({expressionText: expressionText, message: "after a ':' you have to specify the length", position: index});
}
varspec.maxLength = parseInt(expressionText.substring(maxLengthStart, index), 10);
maxLengthStart = null;
}
operator = (function (operatorText) {
var op = operators.valueOf(operatorText);
if (op === null) {
throw new UriTemplateError({expressionText: expressionText, message: "illegal use of reserved operator", position: index, operator: operatorText});
}
return op;
}(expressionText.charAt(0)));
index = operator.symbol.length;
varnameStart = index;
for (; index < expressionText.length; index += chr.length) {
chr = pctEncoder.pctCharAt(expressionText, index);
if (varnameStart !== null) {
// the spec says: varname = varchar *( ["."] varchar )
// so a dot is allowed except for the first char
if (chr === '.') {
if (varnameStart === index) {
throw new UriTemplateError({expressionText: expressionText, message: "a varname MUST NOT start with a dot", position: index});
}
continue;
}
if (rfcCharHelper.isVarchar(chr)) {
continue;
}
closeVarname();
}
if (maxLengthStart !== null) {
if (index === maxLengthStart && chr === '0') {
throw new UriTemplateError({expressionText: expressionText, message: "A :prefix must not start with digit 0", position: index});
}
if (charHelper.isDigit(chr)) {
if (index - maxLengthStart >= 4) {
throw new UriTemplateError({expressionText: expressionText, message: "A :prefix must have max 4 digits", position: index});
}
continue;
}
closeMaxLength();
}
if (chr === ':') {
if (varspec.maxLength !== null) {
throw new UriTemplateError({expressionText: expressionText, message: "only one :maxLength is allowed per varspec", position: index});
}
if (varspec.exploded) {
throw new UriTemplateError({expressionText: expressionText, message: "an exploeded varspec MUST NOT be varspeced", position: index});
}
maxLengthStart = index + 1;
continue;
}
if (chr === '*') {
if (varspec === null) {
throw new UriTemplateError({expressionText: expressionText, message: "exploded without varspec", position: index});
}
if (varspec.exploded) {
throw new UriTemplateError({expressionText: expressionText, message: "exploded twice", position: index});
}
if (varspec.maxLength) {
throw new UriTemplateError({expressionText: expressionText, message: "an explode (*) MUST NOT follow to a prefix", position: index});
}
varspec.exploded = true;
continue;
}
// the only legal character now is the comma
if (chr === ',') {
varspecs.push(varspec);
varspec = null;
varnameStart = index + 1;
continue;
}
throw new UriTemplateError({expressionText: expressionText, message: "illegal character", character: chr, position: index});
} // for chr
if (varnameStart !== null) {
closeVarname();
}
if (maxLengthStart !== null) {
closeMaxLength();
}
varspecs.push(varspec);
return new VariableExpression(expressionText, operator, varspecs);
}
function parse (uriTemplateText) {
// assert filled string
var
index,
chr,
expressions = [],
braceOpenIndex = null,
literalStart = 0;
for (index = 0; index < uriTemplateText.length; index += 1) {
chr = uriTemplateText.charAt(index);
if (literalStart !== null) {
if (chr === '}') {
throw new UriTemplateError({templateText: uriTemplateText, message: "unopened brace closed", position: index});
}
if (chr === '{') {
if (literalStart < index) {
expressions.push(new LiteralExpression(uriTemplateText.substring(literalStart, index)));
}
literalStart = null;
braceOpenIndex = index;
}
continue;
}
if (braceOpenIndex !== null) {
// here just { is forbidden
if (chr === '{') {
throw new UriTemplateError({templateText: uriTemplateText, message: "brace already opened", position: index});
}
if (chr === '}') {
if (braceOpenIndex + 1 === index) {
throw new UriTemplateError({templateText: uriTemplateText, message: "empty braces", position: braceOpenIndex});
}
try {
expressions.push(parseExpression(uriTemplateText.substring(braceOpenIndex + 1, index)));
}
catch (error) {
if (error.prototype === UriTemplateError.prototype) {
throw new UriTemplateError({templateText: uriTemplateText, message: error.options.message, position: braceOpenIndex + error.options.position, details: error.options});
}
throw error;
}
braceOpenIndex = null;
literalStart = index + 1;
}
continue;
}
throw new Error('reached unreachable code');
}
if (braceOpenIndex !== null) {
throw new UriTemplateError({templateText: uriTemplateText, message: "unclosed brace", position: braceOpenIndex});
}
if (literalStart < uriTemplateText.length) {
expressions.push(new LiteralExpression(uriTemplateText.substr(literalStart)));
}
return new UriTemplate(uriTemplateText, expressions);
}
return parse;
}());
var VariableExpression = (function () {
// helper function if JSON is not available
function prettyPrint (value) {
return (JSON && JSON.stringify) ? JSON.stringify(value) : value;
}
function isEmpty (value) {
if (!isDefined(value)) {
return true;
}
if (objectHelper.isString(value)) {
return value === '';
}
if (objectHelper.isNumber(value) || objectHelper.isBoolean(value)) {
return false;
}
if (objectHelper.isArray(value)) {
return value.length === 0;
}
for (var propertyName in value) {
if (value.hasOwnProperty(propertyName)) {
return false;
}
}
return true;
}
function propertyArray (object) {
var
result = [],
propertyName;
for (propertyName in object) {
if (object.hasOwnProperty(propertyName)) {
result.push({name: propertyName, value: object[propertyName]});
}
}
return result;
}
function VariableExpression (templateText, operator, varspecs) {
this.templateText = templateText;
this.operator = operator;
this.varspecs = varspecs;
}
VariableExpression.prototype.toString = function () {
return this.templateText;
};
function expandSimpleValue(varspec, operator, value) {
var result = '';
value = value.toString();
if (operator.named) {
result += encodingHelper.encodeLiteral(varspec.varname);
if (value === '') {
result += operator.ifEmpty;
return result;
}
result += '=';
}
if (varspec.maxLength !== null) {
value = value.substr(0, varspec.maxLength);
}
result += operator.encode(value);
return result;
}
function valueDefined (nameValue) {
return isDefined(nameValue.value);
}
function expandNotExploded(varspec, operator, value) {
var
arr = [],
result = '';
if (operator.named) {
result += encodingHelper.encodeLiteral(varspec.varname);
if (isEmpty(value)) {
result += operator.ifEmpty;
return result;
}
result += '=';
}
if (objectHelper.isArray(value)) {
arr = value;
arr = objectHelper.filter(arr, isDefined);
arr = objectHelper.map(arr, operator.encode);
result += objectHelper.join(arr, ',');
}
else {
arr = propertyArray(value);
arr = objectHelper.filter(arr, valueDefined);
arr = objectHelper.map(arr, function (nameValue) {
return operator.encode(nameValue.name) + ',' + operator.encode(nameValue.value);
});
result += objectHelper.join(arr, ',');
}
return result;
}
function expandExplodedNamed (varspec, operator, value) {
var
isArray = objectHelper.isArray(value),
arr = [];
if (isArray) {
arr = value;
arr = objectHelper.filter(arr, isDefined);
arr = objectHelper.map(arr, function (listElement) {
var tmp = encodingHelper.encodeLiteral(varspec.varname);
if (isEmpty(listElement)) {
tmp += operator.ifEmpty;
}
else {
tmp += '=' + operator.encode(listElement);
}
return tmp;
});
}
else {
arr = propertyArray(value);
arr = objectHelper.filter(arr, valueDefined);
arr = objectHelper.map(arr, function (nameValue) {
var tmp = encodingHelper.encodeLiteral(nameValue.name);
if (isEmpty(nameValue.value)) {
tmp += operator.ifEmpty;
}
else {
tmp += '=' + operator.encode(nameValue.value);
}
return tmp;
});
}
return objectHelper.join(arr, operator.separator);
}
function expandExplodedUnnamed (operator, value) {
var
arr = [],
result = '';
if (objectHelper.isArray(value)) {
arr = value;
arr = objectHelper.filter(arr, isDefined);
arr = objectHelper.map(arr, operator.encode);
result += objectHelper.join(arr, operator.separator);
}
else {
arr = propertyArray(value);
arr = objectHelper.filter(arr, function (nameValue) {
return isDefined(nameValue.value);
});
arr = objectHelper.map(arr, function (nameValue) {
return operator.encode(nameValue.name) + '=' + operator.encode(nameValue.value);
});
result += objectHelper.join(arr, operator.separator);
}
return result;
}
VariableExpression.prototype.expand = function (variables) {
var
expanded = [],
index,
varspec,
value,
valueIsArr,
oneExploded = false,
operator = this.operator;
// expand each varspec and join with operator's separator
for (index = 0; index < this.varspecs.length; index += 1) {
varspec = this.varspecs[index];
value = variables[varspec.varname];
// if (!isDefined(value)) {
// if (variables.hasOwnProperty(varspec.name)) {
if (value === null || value === undefined) {
continue;
}
if (varspec.exploded) {
oneExploded = true;
}
valueIsArr = objectHelper.isArray(value);
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
expanded.push(expandSimpleValue(varspec, operator, value));
}
else if (varspec.maxLength && isDefined(value)) {
// 2.4.1 of the spec says: "Prefix modifiers are not applicable to variables that have composite values."
throw new Error('Prefix modifiers are not applicable to variables that have composite values. You tried to expand ' + this + " with " + prettyPrint(value));
}
else if (!varspec.exploded) {
if (operator.named || !isEmpty(value)) {
expanded.push(expandNotExploded(varspec, operator, value));
}
}
else if (isDefined(value)) {
if (operator.named) {
expanded.push(expandExplodedNamed(varspec, operator, value));
}
else {
expanded.push(expandExplodedUnnamed(operator, value));
}
}
}
if (expanded.length === 0) {
return "";
}
else {
return operator.first + objectHelper.join(expanded, operator.separator);
}
};
return VariableExpression;
}());
var UriTemplate = (function () {
function UriTemplate (templateText, expressions) {
this.templateText = templateText;
this.expressions = expressions;
objectHelper.deepFreeze(this);
}
UriTemplate.prototype.toString = function () {
return this.templateText;
};
UriTemplate.prototype.expand = function (variables) {
// this.expressions.map(function (expression) {return expression.expand(variables);}).join('');
var
index,
result = '';
for (index = 0; index < this.expressions.length; index += 1) {
result += this.expressions[index].expand(variables);
}
return result;
};
UriTemplate.parse = parse;
UriTemplate.UriTemplateError = UriTemplateError;
return UriTemplate;
}());
exportCallback(UriTemplate);
}(function (UriTemplate) {
"use strict";
// export UriTemplate, when module is present, or pass it to window or global
if ('object' !== "undefined") {
module.exports = UriTemplate;
}
else if (typeof undefined === "function") {
undefined([],function() {
return UriTemplate;
});
}
else if (typeof window !== "undefined") {
window.UriTemplate = UriTemplate;
}
else {
commonjsGlobal.UriTemplate = UriTemplate;
}
}
2019-10-03 04:13:12 +08:00
));
});
2020-05-30 21:19:58 +08:00
var store2 = createCommonjsModule(function (module) {
/*! store2 - v2.10.0 - 2019-09-27
* Copyright (c) 2019 Nathan Bubna; Licensed (MIT OR GPL-3.0) */
;(function(window, define) {
var _ = {
version: "2.10.0",
areas: {},
apis: {},
// utilities
inherit: function(api, o) {
for (var p in api) {
if (!o.hasOwnProperty(p)) {
Object.defineProperty(o, p, Object.getOwnPropertyDescriptor(api, p));
}
}
return o;
},
stringify: function(d) {
return d === undefined || typeof d === "function" ? d+'' : JSON.stringify(d);
},
parse: function(s) {
// if it doesn't parse, return as is
try{ return JSON.parse(s); }catch(e){ return s; }
},
// extension hooks
fn: function(name, fn) {
_.storeAPI[name] = fn;
for (var api in _.apis) {
_.apis[api][name] = fn;
}
},
get: function(area, key){ return area.getItem(key); },
set: function(area, key, string){ area.setItem(key, string); },
remove: function(area, key){ area.removeItem(key); },
key: function(area, i){ return area.key(i); },
length: function(area){ return area.length; },
clear: function(area){ area.clear(); },
// core functions
Store: function(id, area, namespace) {
var store = _.inherit(_.storeAPI, function(key, data, overwrite) {
if (arguments.length === 0){ return store.getAll(); }
if (typeof data === "function"){ return store.transact(key, data, overwrite); }// fn=data, alt=overwrite
if (data !== undefined){ return store.set(key, data, overwrite); }
if (typeof key === "string" || typeof key === "number"){ return store.get(key); }
if (typeof key === "function"){ return store.each(key); }
if (!key){ return store.clear(); }
return store.setAll(key, data);// overwrite=data, data=key
});
store._id = id;
try {
var testKey = '_-bad-_';
area.setItem(testKey, 'wolf');
store._area = area;
area.removeItem(testKey);
} catch (e) {}
if (!store._area) {
store._area = _.storage('fake');
}
store._ns = namespace || '';
if (!_.areas[id]) {
_.areas[id] = store._area;
}
if (!_.apis[store._ns+store._id]) {
_.apis[store._ns+store._id] = store;
}
return store;
},
storeAPI: {
// admin functions
area: function(id, area) {
var store = this[id];
if (!store || !store.area) {
store = _.Store(id, area, this._ns);//new area-specific api in this namespace
if (!this[id]){ this[id] = store; }
}
return store;
},
namespace: function(namespace, singleArea) {
if (!namespace){
return this._ns ? this._ns.substring(0,this._ns.length-1) : '';
}
var ns = namespace, store = this[ns];
if (!store || !store.namespace) {
store = _.Store(this._id, this._area, this._ns+ns+'.');//new namespaced api
if (!this[ns]){ this[ns] = store; }
if (!singleArea) {
for (var name in _.areas) {
store.area(name, _.areas[name]);
}
}
}
return store;
},
isFake: function(){ return this._area.name === 'fake'; },
toString: function() {
return 'store'+(this._ns?'.'+this.namespace():'')+'['+this._id+']';
},
// storage functions
has: function(key) {
if (this._area.has) {
return this._area.has(this._in(key));//extension hook
}
return !!(this._in(key) in this._area);
},
size: function(){ return this.keys().length; },
each: function(fn, fill) {// fill is used by keys(fillList) and getAll(fillList))
for (var i=0, m=_.length(this._area); i<m; i++) {
var key = this._out(_.key(this._area, i));
if (key !== undefined) {
if (fn.call(this, key, this.get(key), fill) === false) {
break;
}
}
if (m > _.length(this._area)) { m--; i--; }// in case of removeItem
}
return fill || this;
},
keys: function(fillList) {
return this.each(function(k, v, list){ list.push(k); }, fillList || []);
},
get: function(key, alt) {
var s = _.get(this._area, this._in(key));
return s !== null ? _.parse(s) : alt || s;// support alt for easy default mgmt
},
getAll: function(fillObj) {
return this.each(function(k, v, all){ all[k] = v; }, fillObj || {});
},
transact: function(key, fn, alt) {
var val = this.get(key, alt),
ret = fn(val);
this.set(key, ret === undefined ? val : ret);
return this;
},
set: function(key, data, overwrite) {
var d = this.get(key);
if (d != null && overwrite === false) {
return data;
}
return _.set(this._area, this._in(key), _.stringify(data), overwrite) || d;
},
setAll: function(data, overwrite) {
var changed, val;
for (var key in data) {
val = data[key];
if (this.set(key, val, overwrite) !== val) {
changed = true;
}
}
return changed;
},
add: function(key, data) {
var d = this.get(key);
if (d instanceof Array) {
data = d.concat(data);
} else if (d !== null) {
var type = typeof d;
if (type === typeof data && type === 'object') {
for (var k in data) {
d[k] = data[k];
}
data = d;
} else {
data = d + data;
}
}
_.set(this._area, this._in(key), _.stringify(data));
return data;
},
remove: function(key, alt) {
var d = this.get(key, alt);
_.remove(this._area, this._in(key));
return d;
},
clear: function() {
if (!this._ns) {
_.clear(this._area);
} else {
this.each(function(k){ _.remove(this._area, this._in(k)); }, 1);
}
return this;
},
clearAll: function() {
var area = this._area;
for (var id in _.areas) {
if (_.areas.hasOwnProperty(id)) {
this._area = _.areas[id];
this.clear();
}
}
this._area = area;
return this;
},
// internal use functions
_in: function(k) {
if (typeof k !== "string"){ k = _.stringify(k); }
return this._ns ? this._ns + k : k;
},
_out: function(k) {
return this._ns ?
k && k.indexOf(this._ns) === 0 ?
k.substring(this._ns.length) :
undefined : // so each() knows to skip it
k;
}
},// end _.storeAPI
storage: function(name) {
return _.inherit(_.storageAPI, { items: {}, name: name });
},
storageAPI: {
length: 0,
has: function(k){ return this.items.hasOwnProperty(k); },
key: function(i) {
var c = 0;
for (var k in this.items){
if (this.has(k) && i === c++) {
return k;
}
}
},
setItem: function(k, v) {
if (!this.has(k)) {
this.length++;
}
this.items[k] = v;
},
removeItem: function(k) {
if (this.has(k)) {
delete this.items[k];
this.length--;
}
},
getItem: function(k){ return this.has(k) ? this.items[k] : null; },
clear: function(){ for (var k in this.items){ this.removeItem(k); } }
}// end _.storageAPI
};
var store =
// safely set this up (throws error in IE10/32bit mode for local files)
_.Store("local", (function(){try{ return localStorage; }catch(e){}})());
store.local = store;// for completeness
store._ = _;// for extenders and debuggers...
// safely setup store.session (throws exception in FF for file:/// urls)
store.area("session", (function(){try{ return sessionStorage; }catch(e){}})());
store.area("page", _.storage("page"));
if (typeof define === 'function' && define.amd !== undefined) {
define('store2', [], function () {
return store;
});
} else if ('object' !== 'undefined' && module.exports) {
module.exports = store;
} else {
// expose the primary store fn to the global object and save conflicts
if (window.store){ _.conflict = window.store; }
window.store = store;
}
})(commonjsGlobal, commonjsGlobal && commonjsGlobal.define);
});
'use strict';
var bind$1 = function bind(fn, thisArg) {
return function wrap() {
var args = new Array(arguments.length);
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i];
}
return fn.apply(thisArg, args);
};
};
'use strict';
/*global toString:true*/
// utils is a library of generic helper functions non-specific to axios
var toString = Object.prototype.toString;
/**
* Determine if a value is an Array
*
* @param {Object} val The value to test
* @returns {boolean} True if value is an Array, otherwise false
*/
function isArray(val) {
return toString.call(val) === '[object Array]';
}
/**
* Determine if a value is undefined
*
* @param {Object} val The value to test
* @returns {boolean} True if the value is undefined, otherwise false
*/
function isUndefined(val) {
return typeof val === 'undefined';
}
/**
* Determine if a value is a Buffer
*
* @param {Object} val The value to test
* @returns {boolean} True if value is a Buffer, otherwise false
*/
function isBuffer(val) {
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
&& typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
}
/**
* Determine if a value is an ArrayBuffer
*
* @param {Object} val The value to test
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
*/
function isArrayBuffer(val) {
return toString.call(val) === '[object ArrayBuffer]';
}
/**
* Determine if a value is a FormData
*
* @param {Object} val The value to test
* @returns {boolean} True if value is an FormData, otherwise false
*/
function isFormData(val) {
return (typeof FormData !== 'undefined') && (val instanceof FormData);
}
/**
* Determine if a value is a view on an ArrayBuffer
*
* @param {Object} val The value to test
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
*/
function isArrayBufferView(val) {
var result;
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
result = ArrayBuffer.isView(val);
} else {
result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
}
return result;
}
/**
* Determine if a value is a String
*
* @param {Object} val The value to test
* @returns {boolean} True if value is a String, otherwise false
*/
function isString(val) {
return typeof val === 'string';
}
/**
* Determine if a value is a Number
*
* @param {Object} val The value to test
* @returns {boolean} True if value is a Number, otherwise false
*/
function isNumber(val) {
return typeof val === 'number';
}
/**
* Determine if a value is an Object
*
* @param {Object} val The value to test
* @returns {boolean} True if value is an Object, otherwise false
*/
function isObject(val) {
return val !== null && typeof val === 'object';
}
/**
* Determine if a value is a Date
*
* @param {Object} val The value to test
* @returns {boolean} True if value is a Date, otherwise false
*/
function isDate(val) {
return toString.call(val) === '[object Date]';
}
/**
* Determine if a value is a File
*
* @param {Object} val The value to test
* @returns {boolean} True if value is a File, otherwise false
*/
function isFile(val) {
return toString.call(val) === '[object File]';
}
/**
* Determine if a value is a Blob
*
* @param {Object} val The value to test
* @returns {boolean} True if value is a Blob, otherwise false
*/
function isBlob(val) {
return toString.call(val) === '[object Blob]';
}
/**
* Determine if a value is a Function
*
* @param {Object} val The value to test
* @returns {boolean} True if value is a Function, otherwise false
*/
function isFunction(val) {
return toString.call(val) === '[object Function]';
}
/**
* Determine if a value is a Stream
*
* @param {Object} val The value to test
* @returns {boolean} True if value is a Stream, otherwise false
*/
function isStream(val) {
return isObject(val) && isFunction(val.pipe);
}
/**
* Determine if a value is a URLSearchParams object
*
* @param {Object} val The value to test
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
*/
function isURLSearchParams(val) {
return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
}
/**
* Trim excess whitespace off the beginning and end of a string
*
* @param {String} str The String to trim
* @returns {String} The String freed of excess whitespace
*/
function trim(str) {
return str.replace(/^\s*/, '').replace(/\s*$/, '');
}
/**
* Determine if we're running in a standard browser environment
*
* This allows axios to run in a web worker, and react-native.
* Both environments support XMLHttpRequest, but not fully standard globals.
*
* web workers:
* typeof window -> undefined
* typeof document -> undefined
*
* react-native:
* navigator.product -> 'ReactNative'
* nativescript
* navigator.product -> 'NativeScript' or 'NS'
*/
function isStandardBrowserEnv() {
if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
navigator.product === 'NativeScript' ||
navigator.product === 'NS')) {
return false;
}
return (
typeof window !== 'undefined' &&
typeof document !== 'undefined'
);
}
/**
* Iterate over an Array or an Object invoking a function for each item.
*
* If `obj` is an Array callback will be called passing
* the value, index, and complete array for each item.
*
* If 'obj' is an Object callback will be called passing
* the value, key, and complete object for each property.
*
* @param {Object|Array} obj The object to iterate
* @param {Function} fn The callback to invoke for each item
*/
function forEach(obj, fn) {
// Don't bother if no value provided
if (obj === null || typeof obj === 'undefined') {
return;
}
// Force an array if not already something iterable
if (typeof obj !== 'object') {
/*eslint no-param-reassign:0*/
obj = [obj];
}
if (isArray(obj)) {
// Iterate over array values
for (var i = 0, l = obj.length; i < l; i++) {
fn.call(null, obj[i], i, obj);
}
} else {
// Iterate over object keys
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
fn.call(null, obj[key], key, obj);
}
}
}
}
/**
* Accepts varargs expecting each argument to be an object, then
* immutably merges the properties of each object and returns result.
*
* When multiple objects contain the same key the later object in
* the arguments list will take precedence.
*
* Example:
*
* ```js
* var result = merge({foo: 123}, {foo: 456});
* console.log(result.foo); // outputs 456
* ```
*
* @param {Object} obj1 Object to merge
* @returns {Object} Result of all merge properties
*/
function merge(/* obj1, obj2, obj3, ... */) {
var result = {};
function assignValue(val, key) {
if (typeof result[key] === 'object' && typeof val === 'object') {
result[key] = merge(result[key], val);
} else {
result[key] = val;
}
}
for (var i = 0, l = arguments.length; i < l; i++) {
forEach(arguments[i], assignValue);
}
return result;
}
/**
* Function equal to merge with the difference being that no reference
* to original objects is kept.
*
* @see merge
* @param {Object} obj1 Object to merge
* @returns {Object} Result of all merge properties
*/
function deepMerge(/* obj1, obj2, obj3, ... */) {
var result = {};
function assignValue(val, key) {
if (typeof result[key] === 'object' && typeof val === 'object') {
result[key] = deepMerge(result[key], val);
} else if (typeof val === 'object') {
result[key] = deepMerge({}, val);
} else {
result[key] = val;
}
}
for (var i = 0, l = arguments.length; i < l; i++) {
forEach(arguments[i], assignValue);
}
return result;
}
/**
* Extends object a by mutably adding to it the properties of object b.
*
* @param {Object} a The object to be extended
* @param {Object} b The object to copy properties from
* @param {Object} thisArg The object to bind function to
* @return {Object} The resulting value of object a
*/
function extend(a, b, thisArg) {
forEach(b, function assignValue(val, key) {
if (thisArg && typeof val === 'function') {
a[key] = bind$1(val, thisArg);
} else {
a[key] = val;
}
});
return a;
}
var utils = {
isArray: isArray,
isArrayBuffer: isArrayBuffer,
isBuffer: isBuffer,
isFormData: isFormData,
isArrayBufferView: isArrayBufferView,
isString: isString,
isNumber: isNumber,
isObject: isObject,
isUndefined: isUndefined,
isDate: isDate,
isFile: isFile,
isBlob: isBlob,
isFunction: isFunction,
isStream: isStream,
isURLSearchParams: isURLSearchParams,
isStandardBrowserEnv: isStandardBrowserEnv,
forEach: forEach,
merge: merge,
deepMerge: deepMerge,
extend: extend,
trim: trim
};
var utils_1 = utils.isArray;
var utils_2 = utils.isArrayBuffer;
var utils_3 = utils.isBuffer;
var utils_4 = utils.isFormData;
var utils_5 = utils.isArrayBufferView;
var utils_6 = utils.isString;
var utils_7 = utils.isNumber;
var utils_8 = utils.isObject;
var utils_9 = utils.isUndefined;
var utils_10 = utils.isDate;
var utils_11 = utils.isFile;
var utils_12 = utils.isBlob;
var utils_13 = utils.isFunction;
var utils_14 = utils.isStream;
var utils_15 = utils.isURLSearchParams;
var utils_16 = utils.isStandardBrowserEnv;
var utils_17 = utils.forEach;
var utils_18 = utils.merge;
var utils_19 = utils.deepMerge;
var utils_20 = utils.extend;
var utils_21 = utils.trim;
'use strict';
function encode$1(val) {
return encodeURIComponent(val).
replace(/%40/gi, '@').
replace(/%3A/gi, ':').
replace(/%24/g, '$').
replace(/%2C/gi, ',').
replace(/%20/g, '+').
replace(/%5B/gi, '[').
replace(/%5D/gi, ']');
}
/**
* Build a URL by appending params to the end
*
* @param {string} url The base of the url (e.g., http://www.google.com)
* @param {object} [params] The params to be appended
* @returns {string} The formatted url
*/
var buildURL = function buildURL(url, params, paramsSerializer) {
/*eslint no-param-reassign:0*/
if (!params) {
return url;
}
var serializedParams;
if (paramsSerializer) {
serializedParams = paramsSerializer(params);
} else if (utils.isURLSearchParams(params)) {
serializedParams = params.toString();
} else {
var parts = [];
utils.forEach(params, function serialize(val, key) {
if (val === null || typeof val === 'undefined') {
return;
}
if (utils.isArray(val)) {
key = key + '[]';
} else {
val = [val];
}
utils.forEach(val, function parseValue(v) {
if (utils.isDate(v)) {
v = v.toISOString();
} else if (utils.isObject(v)) {
v = JSON.stringify(v);
}
parts.push(encode$1(key) + '=' + encode$1(v));
});
});
serializedParams = parts.join('&');
}
if (serializedParams) {
var hashmarkIndex = url.indexOf('#');
if (hashmarkIndex !== -1) {
url = url.slice(0, hashmarkIndex);
}
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
}
return url;
};
'use strict';
function InterceptorManager() {
this.handlers = [];
}
/**
* Add a new interceptor to the stack
*
* @param {Function} fulfilled The function to handle `then` for a `Promise`
* @param {Function} rejected The function to handle `reject` for a `Promise`
*
* @return {Number} An ID used to remove interceptor later
*/
InterceptorManager.prototype.use = function use(fulfilled, rejected) {
this.handlers.push({
fulfilled: fulfilled,
rejected: rejected
});
return this.handlers.length - 1;
};
/**
* Remove an interceptor from the stack
*
* @param {Number} id The ID that was returned by `use`
*/
InterceptorManager.prototype.eject = function eject(id) {
if (this.handlers[id]) {
this.handlers[id] = null;
}
};
/**
* Iterate over all the registered interceptors
*
* This method is particularly useful for skipping over any
* interceptors that may have become `null` calling `eject`.
*
* @param {Function} fn The function to call for each interceptor
*/
InterceptorManager.prototype.forEach = function forEach(fn) {
utils.forEach(this.handlers, function forEachHandler(h) {
if (h !== null) {
fn(h);
}
});
};
var InterceptorManager_1 = InterceptorManager;
'use strict';
/**
* Transform the data for a request or a response
*
* @param {Object|String} data The data to be transformed
* @param {Array} headers The headers for the request or response
* @param {Array|Function} fns A single function or Array of functions
* @returns {*} The resulting transformed data
*/
var transformData = function transformData(data, headers, fns) {
/*eslint no-param-reassign:0*/
utils.forEach(fns, function transform(fn) {
data = fn(data, headers);
});
return data;
};
'use strict';
var isCancel = function isCancel(value) {
return !!(value && value.__CANCEL__);
};
'use strict';
var normalizeHeaderName = function normalizeHeaderName(headers, normalizedName) {
utils.forEach(headers, function processHeader(value, name) {
if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
headers[normalizedName] = value;
delete headers[name];
}
});
};
'use strict';
/**
* Update an Error with the specified config, error code, and response.
*
* @param {Error} error The error to update.
* @param {Object} config The config.
* @param {string} [code] The error code (for example, 'ECONNABORTED').
* @param {Object} [request] The request.
* @param {Object} [response] The response.
* @returns {Error} The error.
*/
var enhanceError = function enhanceError(error, config, code, request, response) {
error.config = config;
if (code) {
error.code = code;
}
error.request = request;
error.response = response;
error.isAxiosError = true;
error.toJSON = function() {
return {
// Standard
message: this.message,
name: this.name,
// Microsoft
description: this.description,
number: this.number,
// Mozilla
fileName: this.fileName,
lineNumber: this.lineNumber,
columnNumber: this.columnNumber,
stack: this.stack,
// Axios
config: this.config,
code: this.code
};
};
return error;
};
'use strict';
/**
* Create an Error with the specified message, config, error code, request and response.
*
* @param {string} message The error message.
* @param {Object} config The config.
* @param {string} [code] The error code (for example, 'ECONNABORTED').
* @param {Object} [request] The request.
* @param {Object} [response] The response.
* @returns {Error} The created error.
*/
var createError = function createError(message, config, code, request, response) {
var error = new Error(message);
return enhanceError(error, config, code, request, response);
};
'use strict';
/**
* Resolve or reject a Promise based on response status.
*
* @param {Function} resolve A function that resolves the promise.
* @param {Function} reject A function that rejects the promise.
* @param {object} response The response.
*/
var settle = function settle(resolve, reject, response) {
var validateStatus = response.config.validateStatus;
if (!validateStatus || validateStatus(response.status)) {
resolve(response);
} else {
reject(createError(
'Request failed with status code ' + response.status,
response.config,
null,
response.request,
response
));
}
};
'use strict';
/**
* Determines whether the specified URL is absolute
*
* @param {string} url The URL to test
* @returns {boolean} True if the specified URL is absolute, otherwise false
*/
var isAbsoluteURL = function isAbsoluteURL(url) {
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
// by any combination of letters, digits, plus, period, or hyphen.
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
};
'use strict';
/**
* Creates a new URL by combining the specified URLs
*
* @param {string} baseURL The base URL
* @param {string} relativeURL The relative URL
* @returns {string} The combined URL
*/
var combineURLs = function combineURLs(baseURL, relativeURL) {
return relativeURL
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
: baseURL;
};
'use strict';
/**
* Creates a new URL by combining the baseURL with the requestedURL,
* only when the requestedURL is not already an absolute URL.
* If the requestURL is absolute, this function returns the requestedURL untouched.
*
* @param {string} baseURL The base URL
* @param {string} requestedURL Absolute or relative URL to combine
* @returns {string} The combined full path
*/
var buildFullPath = function buildFullPath(baseURL, requestedURL) {
if (baseURL && !isAbsoluteURL(requestedURL)) {
return combineURLs(baseURL, requestedURL);
}
return requestedURL;
};
'use strict';
// Headers whose duplicates are ignored by node
// c.f. https://nodejs.org/api/http.html#http_message_headers
var ignoreDuplicateOf = [
'age', 'authorization', 'content-length', 'content-type', 'etag',
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
'referer', 'retry-after', 'user-agent'
];
/**
* Parse headers into an object
*
* ```
* Date: Wed, 27 Aug 2014 08:58:49 GMT
* Content-Type: application/json
* Connection: keep-alive
* Transfer-Encoding: chunked
* ```
*
* @param {String} headers Headers needing to be parsed
* @returns {Object} Headers parsed into an object
*/
var parseHeaders = function parseHeaders(headers) {
var parsed = {};
var key;
var val;
var i;
if (!headers) { return parsed; }
utils.forEach(headers.split('\n'), function parser(line) {
i = line.indexOf(':');
key = utils.trim(line.substr(0, i)).toLowerCase();
val = utils.trim(line.substr(i + 1));
if (key) {
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
return;
}
if (key === 'set-cookie') {
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
} else {
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
}
}
});
return parsed;
};
'use strict';
var isURLSameOrigin = (
utils.isStandardBrowserEnv() ?
// Standard browser envs have full support of the APIs needed to test
// whether the request URL is of the same origin as current location.
(function standardBrowserEnv() {
var msie = /(msie|trident)/i.test(navigator.userAgent);
var urlParsingNode = document.createElement('a');
var originURL;
/**
* Parse a URL to discover it's components
*
* @param {String} url The URL to be parsed
* @returns {Object}
*/
function resolveURL(url) {
var href = url;
if (msie) {
// IE needs attribute set twice to normalize properties
urlParsingNode.setAttribute('href', href);
href = urlParsingNode.href;
}
urlParsingNode.setAttribute('href', href);
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
return {
href: urlParsingNode.href,
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
host: urlParsingNode.host,
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
hostname: urlParsingNode.hostname,
port: urlParsingNode.port,
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
urlParsingNode.pathname :
'/' + urlParsingNode.pathname
};
}
originURL = resolveURL(window.location.href);
/**
* Determine if a URL shares the same origin as the current location
*
* @param {String} requestURL The URL to test
* @returns {boolean} True if URL shares the same origin, otherwise false
*/
return function isURLSameOrigin(requestURL) {
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
return (parsed.protocol === originURL.protocol &&
parsed.host === originURL.host);
};
})() :
// Non standard browser envs (web workers, react-native) lack needed support.
(function nonStandardBrowserEnv() {
return function isURLSameOrigin() {
return true;
};
})()
);
'use strict';
var cookies = (
utils.isStandardBrowserEnv() ?
// Standard browser envs support document.cookie
(function standardBrowserEnv() {
return {
write: function write(name, value, expires, path, domain, secure) {
var cookie = [];
cookie.push(name + '=' + encodeURIComponent(value));
if (utils.isNumber(expires)) {
cookie.push('expires=' + new Date(expires).toGMTString());
}
if (utils.isString(path)) {
cookie.push('path=' + path);
}
if (utils.isString(domain)) {
cookie.push('domain=' + domain);
}
if (secure === true) {
cookie.push('secure');
}
document.cookie = cookie.join('; ');
},
read: function read(name) {
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
return (match ? decodeURIComponent(match[3]) : null);
},
remove: function remove(name) {
this.write(name, '', Date.now() - 86400000);
}
};
})() :
// Non standard browser env (web workers, react-native) lack needed support.
(function nonStandardBrowserEnv() {
return {
write: function write() {},
read: function read() { return null; },
remove: function remove() {}
};
})()
);
'use strict';
var xhr = function xhrAdapter(config) {
return new Promise(function dispatchXhrRequest(resolve, reject) {
var requestData = config.data;
var requestHeaders = config.headers;
if (utils.isFormData(requestData)) {
delete requestHeaders['Content-Type']; // Let the browser set it
}
var request = new XMLHttpRequest();
// HTTP basic authentication
if (config.auth) {
var username = config.auth.username || '';
var password = config.auth.password || '';
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
}
var fullPath = buildFullPath(config.baseURL, config.url);
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
// Set the request timeout in MS
request.timeout = config.timeout;
// Listen for ready state
request.onreadystatechange = function handleLoad() {
if (!request || request.readyState !== 4) {
return;
}
// The request errored out and we didn't get a response, this will be
// handled by onerror instead
// With one exception: request that using file: protocol, most browsers
// will return status as 0 even though it's a successful request
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
return;
}
// Prepare the response
var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
var response = {
data: responseData,
status: request.status,
statusText: request.statusText,
headers: responseHeaders,
config: config,
request: request
};
settle(resolve, reject, response);
// Clean up request
request = null;
};
// Handle browser request cancellation (as opposed to a manual cancellation)
request.onabort = function handleAbort() {
if (!request) {
return;
}
reject(createError('Request aborted', config, 'ECONNABORTED', request));
// Clean up request
request = null;
};
// Handle low level network errors
request.onerror = function handleError() {
// Real errors are hidden from us by the browser
// onerror should only fire if it's a network error
reject(createError('Network Error', config, null, request));
// Clean up request
request = null;
};
// Handle timeout
request.ontimeout = function handleTimeout() {
var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
if (config.timeoutErrorMessage) {
timeoutErrorMessage = config.timeoutErrorMessage;
}
reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
request));
// Clean up request
request = null;
};
// Add xsrf header
// This is only done if running in a standard browser environment.
// Specifically not if we're in a web worker, or react-native.
if (utils.isStandardBrowserEnv()) {
var cookies$1 = cookies;
// Add xsrf header
var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
cookies$1.read(config.xsrfCookieName) :
undefined;
if (xsrfValue) {
requestHeaders[config.xsrfHeaderName] = xsrfValue;
}
}
// Add headers to the request
if ('setRequestHeader' in request) {
utils.forEach(requestHeaders, function setRequestHeader(val, key) {
if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
// Remove Content-Type if data is undefined
delete requestHeaders[key];
} else {
// Otherwise add header to the request
request.setRequestHeader(key, val);
}
});
}
// Add withCredentials to request if needed
if (!utils.isUndefined(config.withCredentials)) {
request.withCredentials = !!config.withCredentials;
}
// Add responseType to request if needed
if (config.responseType) {
try {
request.responseType = config.responseType;
} catch (e) {
// Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
// But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
if (config.responseType !== 'json') {
throw e;
}
}
}
// Handle progress if needed
if (typeof config.onDownloadProgress === 'function') {
request.addEventListener('progress', config.onDownloadProgress);
}
// Not all browsers support upload events
if (typeof config.onUploadProgress === 'function' && request.upload) {
request.upload.addEventListener('progress', config.onUploadProgress);
}
if (config.cancelToken) {
// Handle cancellation
config.cancelToken.promise.then(function onCanceled(cancel) {
if (!request) {
return;
}
request.abort();
reject(cancel);
// Clean up request
request = null;
});
}
if (requestData === undefined) {
requestData = null;
}
// Send the request
request.send(requestData);
});
};
'use strict';
var DEFAULT_CONTENT_TYPE = {
'Content-Type': 'application/x-www-form-urlencoded'
};
function setContentTypeIfUnset(headers, value) {
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
headers['Content-Type'] = value;
}
}
function getDefaultAdapter() {
var adapter;
if (typeof XMLHttpRequest !== 'undefined') {
// For browsers use XHR adapter
adapter = xhr;
} else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
// For node use HTTP adapter
adapter = xhr;
}
return adapter;
}
var defaults = {
adapter: getDefaultAdapter(),
transformRequest: [function transformRequest(data, headers) {
normalizeHeaderName(headers, 'Accept');
normalizeHeaderName(headers, 'Content-Type');
if (utils.isFormData(data) ||
utils.isArrayBuffer(data) ||
utils.isBuffer(data) ||
utils.isStream(data) ||
utils.isFile(data) ||
utils.isBlob(data)
) {
return data;
}
if (utils.isArrayBufferView(data)) {
return data.buffer;
}
if (utils.isURLSearchParams(data)) {
setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
return data.toString();
}
if (utils.isObject(data)) {
setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
return JSON.stringify(data);
}
return data;
}],
transformResponse: [function transformResponse(data) {
/*eslint no-param-reassign:0*/
if (typeof data === 'string') {
try {
data = JSON.parse(data);
} catch (e) { /* Ignore */ }
}
return data;
}],
/**
* A timeout in milliseconds to abort a request. If set to 0 (default) a
* timeout is not created.
*/
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
validateStatus: function validateStatus(status) {
return status >= 200 && status < 300;
}
};
defaults.headers = {
common: {
'Accept': 'application/json, text/plain, */*'
}
};
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
defaults.headers[method] = {};
});
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
});
var defaults_1 = defaults;
'use strict';
/**
* Throws a `Cancel` if cancellation has been requested.
*/
function throwIfCancellationRequested(config) {
if (config.cancelToken) {
config.cancelToken.throwIfRequested();
}
}
/**
* Dispatch a request to the server using the configured adapter.
*
* @param {object} config The config that is to be used for the request
* @returns {Promise} The Promise to be fulfilled
*/
var dispatchRequest = function dispatchRequest(config) {
throwIfCancellationRequested(config);
// Ensure headers exist
config.headers = config.headers || {};
// Transform request data
config.data = transformData(
config.data,
config.headers,
config.transformRequest
);
// Flatten headers
config.headers = utils.merge(
config.headers.common || {},
config.headers[config.method] || {},
config.headers
);
utils.forEach(
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
function cleanHeaderConfig(method) {
delete config.headers[method];
}
);
var adapter = config.adapter || defaults_1.adapter;
return adapter(config).then(function onAdapterResolution(response) {
throwIfCancellationRequested(config);
// Transform response data
response.data = transformData(
response.data,
response.headers,
config.transformResponse
);
return response;
}, function onAdapterRejection(reason) {
if (!isCancel(reason)) {
throwIfCancellationRequested(config);
// Transform response data
if (reason && reason.response) {
reason.response.data = transformData(
reason.response.data,
reason.response.headers,
config.transformResponse
);
}
}
return Promise.reject(reason);
});
};
'use strict';
/**
* Config-specific merge-function which creates a new config-object
* by merging two configuration objects together.
*
* @param {Object} config1
* @param {Object} config2
* @returns {Object} New object resulting from merging config2 to config1
*/
var mergeConfig = function mergeConfig(config1, config2) {
// eslint-disable-next-line no-param-reassign
config2 = config2 || {};
var config = {};
var valueFromConfig2Keys = ['url', 'method', 'params', 'data'];
var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy'];
var defaultToConfig2Keys = [
'baseURL', 'url', 'transformRequest', 'transformResponse', 'paramsSerializer',
'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress',
'maxContentLength', 'validateStatus', 'maxRedirects', 'httpAgent',
'httpsAgent', 'cancelToken', 'socketPath'
];
utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
if (typeof config2[prop] !== 'undefined') {
config[prop] = config2[prop];
}
});
utils.forEach(mergeDeepPropertiesKeys, function mergeDeepProperties(prop) {
if (utils.isObject(config2[prop])) {
config[prop] = utils.deepMerge(config1[prop], config2[prop]);
} else if (typeof config2[prop] !== 'undefined') {
config[prop] = config2[prop];
} else if (utils.isObject(config1[prop])) {
config[prop] = utils.deepMerge(config1[prop]);
} else if (typeof config1[prop] !== 'undefined') {
config[prop] = config1[prop];
}
});
utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
if (typeof config2[prop] !== 'undefined') {
config[prop] = config2[prop];
} else if (typeof config1[prop] !== 'undefined') {
config[prop] = config1[prop];
}
});
var axiosKeys = valueFromConfig2Keys
.concat(mergeDeepPropertiesKeys)
.concat(defaultToConfig2Keys);
var otherKeys = Object
.keys(config2)
.filter(function filterAxiosKeys(key) {
return axiosKeys.indexOf(key) === -1;
});
utils.forEach(otherKeys, function otherKeysDefaultToConfig2(prop) {
if (typeof config2[prop] !== 'undefined') {
config[prop] = config2[prop];
} else if (typeof config1[prop] !== 'undefined') {
config[prop] = config1[prop];
}
});
return config;
};
'use strict';
/**
* Create a new instance of Axios
*
* @param {Object} instanceConfig The default config for the instance
*/
function Axios(instanceConfig) {
this.defaults = instanceConfig;
this.interceptors = {
request: new InterceptorManager_1(),
response: new InterceptorManager_1()
};
}
/**
* Dispatch a request
*
* @param {Object} config The config specific for this request (merged with this.defaults)
*/
Axios.prototype.request = function request(config) {
/*eslint no-param-reassign:0*/
// Allow for axios('example/url'[, config]) a la fetch API
if (typeof config === 'string') {
config = arguments[1] || {};
config.url = arguments[0];
} else {
config = config || {};
}
config = mergeConfig(this.defaults, config);
// Set config.method
if (config.method) {
config.method = config.method.toLowerCase();
} else if (this.defaults.method) {
config.method = this.defaults.method.toLowerCase();
} else {
config.method = 'get';
}
// Hook up interceptors middleware
var chain = [dispatchRequest, undefined];
var promise = Promise.resolve(config);
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
chain.unshift(interceptor.fulfilled, interceptor.rejected);
});
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
chain.push(interceptor.fulfilled, interceptor.rejected);
});
while (chain.length) {
promise = promise.then(chain.shift(), chain.shift());
}
return promise;
};
Axios.prototype.getUri = function getUri(config) {
config = mergeConfig(this.defaults, config);
return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
};
// Provide aliases for supported request methods
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
/*eslint func-names:0*/
Axios.prototype[method] = function(url, config) {
return this.request(utils.merge(config || {}, {
method: method,
url: url
}));
};
});
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
/*eslint func-names:0*/
Axios.prototype[method] = function(url, data, config) {
return this.request(utils.merge(config || {}, {
method: method,
url: url,
data: data
}));
};
});
var Axios_1 = Axios;
'use strict';
/**
* A `Cancel` is an object that is thrown when an operation is canceled.
*
* @class
* @param {string=} message The message.
*/
function Cancel(message) {
this.message = message;
}
Cancel.prototype.toString = function toString() {
return 'Cancel' + (this.message ? ': ' + this.message : '');
};
Cancel.prototype.__CANCEL__ = true;
var Cancel_1 = Cancel;
'use strict';
/**
* A `CancelToken` is an object that can be used to request cancellation of an operation.
*
* @class
* @param {Function} executor The executor function.
*/
function CancelToken(executor) {
if (typeof executor !== 'function') {
throw new TypeError('executor must be a function.');
}
var resolvePromise;
this.promise = new Promise(function promiseExecutor(resolve) {
resolvePromise = resolve;
});
var token = this;
executor(function cancel(message) {
if (token.reason) {
// Cancellation has already been requested
return;
}
token.reason = new Cancel_1(message);
resolvePromise(token.reason);
});
}
/**
* Throws a `Cancel` if cancellation has been requested.
*/
CancelToken.prototype.throwIfRequested = function throwIfRequested() {
if (this.reason) {
throw this.reason;
}
};
/**
* Returns an object that contains a new `CancelToken` and a function that, when called,
* cancels the `CancelToken`.
*/
CancelToken.source = function source() {
var cancel;
var token = new CancelToken(function executor(c) {
cancel = c;
});
return {
token: token,
cancel: cancel
};
};
var CancelToken_1 = CancelToken;
'use strict';
/**
* Syntactic sugar for invoking a function and expanding an array for arguments.
*
* Common use case would be to use `Function.prototype.apply`.
*
* ```js
* function f(x, y, z) {}
* var args = [1, 2, 3];
* f.apply(null, args);
* ```
*
* With `spread` this example can be re-written.
*
* ```js
* spread(function(x, y, z) {})([1, 2, 3]);
* ```
*
* @param {Function} callback
* @returns {Function}
*/
var spread$1 = function spread(callback) {
return function wrap(arr) {
return callback.apply(null, arr);
};
};
'use strict';
/**
* Create an instance of Axios
*
* @param {Object} defaultConfig The default config for the instance
* @return {Axios} A new instance of Axios
*/
function createInstance(defaultConfig) {
var context = new Axios_1(defaultConfig);
var instance = bind$1(Axios_1.prototype.request, context);
// Copy axios.prototype to instance
utils.extend(instance, Axios_1.prototype, context);
// Copy context to instance
utils.extend(instance, context);
return instance;
}
// Create the default instance to be exported
var axios = createInstance(defaults_1);
// Expose Axios class to allow class inheritance
axios.Axios = Axios_1;
// Factory for creating new instances
axios.create = function create(instanceConfig) {
return createInstance(mergeConfig(axios.defaults, instanceConfig));
};
// Expose Cancel & CancelToken
axios.Cancel = Cancel_1;
axios.CancelToken = CancelToken_1;
axios.isCancel = isCancel;
// Expose all/spread
axios.all = function all(promises) {
return Promise.all(promises);
};
axios.spread = spread$1;
var axios_1 = axios;
// Allow use of default import syntax in TypeScript
var default_1 = axios;
axios_1.default = default_1;
var axios$1 = axios_1;
'use strict';
var has$1 = Object.prototype.hasOwnProperty;
var isArray$1 = Array.isArray;
var hexTable = (function () {
var array = [];
for (var i = 0; i < 256; ++i) {
array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
}
return array;
}());
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var compactQueue = function compactQueue(queue) {
while (queue.length > 1) {
var item = queue.pop();
var obj = item.obj[item.prop];
if (isArray$1(obj)) {
var compacted = [];
for (var j = 0; j < obj.length; ++j) {
if (typeof obj[j] !== 'undefined') {
compacted.push(obj[j]);
2019-10-03 04:13:12 +08:00
}
}
2020-05-30 21:19:58 +08:00
item.obj[item.prop] = compacted;
}
}
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var arrayToObject = function arrayToObject(source, options) {
var obj = options && options.plainObjects ? Object.create(null) : {};
for (var i = 0; i < source.length; ++i) {
if (typeof source[i] !== 'undefined') {
obj[i] = source[i];
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return obj;
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var merge$1 = function merge(target, source, options) {
/* eslint no-param-reassign: 0 */
if (!source) {
return target;
}
if (typeof source !== 'object') {
if (isArray$1(target)) {
target.push(source);
} else if (target && typeof target === 'object') {
if ((options && (options.plainObjects || options.allowPrototypes)) || !has$1.call(Object.prototype, source)) {
target[source] = true;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
} else {
return [target, source];
}
return target;
}
if (!target || typeof target !== 'object') {
return [target].concat(source);
}
var mergeTarget = target;
if (isArray$1(target) && !isArray$1(source)) {
mergeTarget = arrayToObject(target, options);
}
if (isArray$1(target) && isArray$1(source)) {
source.forEach(function (item, i) {
if (has$1.call(target, i)) {
var targetItem = target[i];
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
target[i] = merge(targetItem, item, options);
} else {
target.push(item);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
} else {
target[i] = item;
}
});
return target;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return Object.keys(source).reduce(function (acc, key) {
var value = source[key];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (has$1.call(acc, key)) {
acc[key] = merge(acc[key], value, options);
} else {
acc[key] = value;
}
return acc;
}, mergeTarget);
};
var assign$1 = function assignSingleSource(target, source) {
return Object.keys(source).reduce(function (acc, key) {
acc[key] = source[key];
return acc;
}, target);
};
var decode$2 = function (str, decoder, charset) {
var strWithoutPlus = str.replace(/\+/g, ' ');
if (charset === 'iso-8859-1') {
// unescape never throws, no try...catch needed:
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
}
// utf-8
try {
return decodeURIComponent(strWithoutPlus);
} catch (e) {
return strWithoutPlus;
}
};
var encode$2 = function encode(str, defaultEncoder, charset) {
// This code was originally written by Brian White (mscdex) for the io.js core querystring library.
// It has been adapted here for stricter adherence to RFC 3986
if (str.length === 0) {
return str;
}
var string = str;
if (typeof str === 'symbol') {
string = Symbol.prototype.toString.call(str);
} else if (typeof str !== 'string') {
string = String(str);
}
if (charset === 'iso-8859-1') {
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
2019-10-03 04:13:12 +08:00
});
}
2020-05-30 21:19:58 +08:00
var out = '';
for (var i = 0; i < string.length; ++i) {
var c = string.charCodeAt(i);
if (
c === 0x2D // -
|| c === 0x2E // .
|| c === 0x5F // _
|| c === 0x7E // ~
|| (c >= 0x30 && c <= 0x39) // 0-9
|| (c >= 0x41 && c <= 0x5A) // a-z
|| (c >= 0x61 && c <= 0x7A) // A-Z
) {
out += string.charAt(i);
continue;
}
if (c < 0x80) {
out = out + hexTable[c];
continue;
}
if (c < 0x800) {
out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
continue;
}
if (c < 0xD800 || c >= 0xE000) {
out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
continue;
}
i += 1;
c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
out += hexTable[0xF0 | (c >> 18)]
+ hexTable[0x80 | ((c >> 12) & 0x3F)]
+ hexTable[0x80 | ((c >> 6) & 0x3F)]
+ hexTable[0x80 | (c & 0x3F)];
}
return out;
};
var compact = function compact(value) {
var queue = [{ obj: { o: value }, prop: 'o' }];
var refs = [];
for (var i = 0; i < queue.length; ++i) {
var item = queue[i];
var obj = item.obj[item.prop];
var keys = Object.keys(obj);
for (var j = 0; j < keys.length; ++j) {
var key = keys[j];
var val = obj[key];
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
queue.push({ obj: obj, prop: key });
refs.push(val);
}
}
}
compactQueue(queue);
return value;
};
var isRegExp = function isRegExp(obj) {
return Object.prototype.toString.call(obj) === '[object RegExp]';
};
var isBuffer$1 = function isBuffer(obj) {
if (!obj || typeof obj !== 'object') {
return false;
}
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
};
var combine = function combine(a, b) {
return [].concat(a, b);
};
var utils$1 = {
arrayToObject: arrayToObject,
assign: assign$1,
combine: combine,
compact: compact,
decode: decode$2,
encode: encode$2,
isBuffer: isBuffer$1,
isRegExp: isRegExp,
merge: merge$1
};
var utils_1$1 = utils$1.arrayToObject;
var utils_2$1 = utils$1.assign;
var utils_3$1 = utils$1.combine;
var utils_4$1 = utils$1.compact;
var utils_5$1 = utils$1.decode;
var utils_6$1 = utils$1.encode;
var utils_7$1 = utils$1.isBuffer;
var utils_8$1 = utils$1.isRegExp;
var utils_9$1 = utils$1.merge;
2019-10-03 04:13:12 +08:00
'use strict';
2020-05-30 21:19:58 +08:00
var replace = String.prototype.replace;
var percentTwenties = /%20/g;
var Format = {
RFC1738: 'RFC1738',
RFC3986: 'RFC3986'
};
var formats = utils$1.assign(
{
'default': Format.RFC3986,
formatters: {
RFC1738: function (value) {
return replace.call(value, percentTwenties, '+');
},
RFC3986: function (value) {
return String(value);
}
}
},
Format
);
'use strict';
var has$2 = Object.prototype.hasOwnProperty;
var arrayPrefixGenerators = {
brackets: function brackets(prefix) {
return prefix + '[]';
},
comma: 'comma',
indices: function indices(prefix, key) {
return prefix + '[' + key + ']';
},
repeat: function repeat(prefix) {
return prefix;
2019-10-03 04:13:12 +08:00
}
};
2020-05-30 21:19:58 +08:00
var isArray$2 = Array.isArray;
var push = Array.prototype.push;
var pushToArray = function (arr, valueOrArray) {
push.apply(arr, isArray$2(valueOrArray) ? valueOrArray : [valueOrArray]);
};
var toISO = Date.prototype.toISOString;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var defaultFormat = formats['default'];
var defaults$1 = {
addQueryPrefix: false,
allowDots: false,
charset: 'utf-8',
charsetSentinel: false,
delimiter: '&',
encode: true,
encoder: utils$1.encode,
encodeValuesOnly: false,
format: defaultFormat,
formatter: formats.formatters[defaultFormat],
// deprecated
indices: false,
serializeDate: function serializeDate(date) {
return toISO.call(date);
},
skipNulls: false,
strictNullHandling: false
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
return typeof v === 'string'
|| typeof v === 'number'
|| typeof v === 'boolean'
|| typeof v === 'symbol'
|| typeof v === 'bigint';
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var stringify$1 = function stringify(
object,
prefix,
generateArrayPrefix,
strictNullHandling,
skipNulls,
encoder,
filter,
sort,
allowDots,
serializeDate,
formatter,
encodeValuesOnly,
charset
) {
var obj = object;
if (typeof filter === 'function') {
obj = filter(prefix, obj);
} else if (obj instanceof Date) {
obj = serializeDate(obj);
} else if (generateArrayPrefix === 'comma' && isArray$2(obj)) {
obj = obj.join(',');
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (obj === null) {
if (strictNullHandling) {
return encoder && !encodeValuesOnly ? encoder(prefix, defaults$1.encoder, charset, 'key') : prefix;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
obj = '';
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (isNonNullishPrimitive(obj) || utils$1.isBuffer(obj)) {
if (encoder) {
var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults$1.encoder, charset, 'key');
return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults$1.encoder, charset, 'value'))];
}
return [formatter(prefix) + '=' + formatter(String(obj))];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var values = [];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (typeof obj === 'undefined') {
return values;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var objKeys;
if (isArray$2(filter)) {
objKeys = filter;
} else {
var keys = Object.keys(obj);
objKeys = sort ? keys.sort(sort) : keys;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (var i = 0; i < objKeys.length; ++i) {
var key = objKeys[i];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (skipNulls && obj[key] === null) {
continue;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (isArray$2(obj)) {
pushToArray(values, stringify(
obj[key],
typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix,
generateArrayPrefix,
strictNullHandling,
skipNulls,
encoder,
filter,
sort,
allowDots,
serializeDate,
formatter,
encodeValuesOnly,
charset
));
} else {
pushToArray(values, stringify(
obj[key],
prefix + (allowDots ? '.' + key : '[' + key + ']'),
generateArrayPrefix,
strictNullHandling,
skipNulls,
encoder,
filter,
sort,
allowDots,
serializeDate,
formatter,
encodeValuesOnly,
charset
));
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return values;
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
if (!opts) {
return defaults$1;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') {
throw new TypeError('Encoder has to be a function.');
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var charset = opts.charset || defaults$1.charset;
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var format = formats['default'];
if (typeof opts.format !== 'undefined') {
if (!has$2.call(formats.formatters, opts.format)) {
throw new TypeError('Unknown format option provided.');
}
format = opts.format;
}
var formatter = formats.formatters[format];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var filter = defaults$1.filter;
if (typeof opts.filter === 'function' || isArray$2(opts.filter)) {
filter = opts.filter;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults$1.addQueryPrefix,
allowDots: typeof opts.allowDots === 'undefined' ? defaults$1.allowDots : !!opts.allowDots,
charset: charset,
charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults$1.charsetSentinel,
delimiter: typeof opts.delimiter === 'undefined' ? defaults$1.delimiter : opts.delimiter,
encode: typeof opts.encode === 'boolean' ? opts.encode : defaults$1.encode,
encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults$1.encoder,
encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults$1.encodeValuesOnly,
filter: filter,
formatter: formatter,
serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults$1.serializeDate,
skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults$1.skipNulls,
sort: typeof opts.sort === 'function' ? opts.sort : null,
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults$1.strictNullHandling
};
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var stringify_1 = function (object, opts) {
var obj = object;
var options = normalizeStringifyOptions(opts);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var objKeys;
var filter;
if (typeof options.filter === 'function') {
filter = options.filter;
obj = filter('', obj);
} else if (isArray$2(options.filter)) {
filter = options.filter;
objKeys = filter;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
var keys = [];
if (typeof obj !== 'object' || obj === null) {
return '';
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
var arrayFormat;
if (opts && opts.arrayFormat in arrayPrefixGenerators) {
arrayFormat = opts.arrayFormat;
} else if (opts && 'indices' in opts) {
arrayFormat = opts.indices ? 'indices' : 'repeat';
2019-10-03 04:13:12 +08:00
} else {
2020-05-30 21:19:58 +08:00
arrayFormat = 'indices';
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!objKeys) {
objKeys = Object.keys(obj);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (options.sort) {
objKeys.sort(options.sort);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
for (var i = 0; i < objKeys.length; ++i) {
var key = objKeys[i];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (options.skipNulls && obj[key] === null) {
continue;
}
pushToArray(keys, stringify$1(
obj[key],
key,
generateArrayPrefix,
options.strictNullHandling,
options.skipNulls,
options.encode ? options.encoder : null,
options.filter,
options.sort,
options.allowDots,
options.serializeDate,
options.formatter,
options.encodeValuesOnly,
options.charset
));
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var joined = keys.join(options.delimiter);
var prefix = options.addQueryPrefix === true ? '?' : '';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (options.charsetSentinel) {
if (options.charset === 'iso-8859-1') {
// encodeURIComponent('&#10003;'), the "numeric entity" representation of a checkmark
prefix += 'utf8=%26%2310003%3B&';
} else {
// encodeURIComponent('✓')
prefix += 'utf8=%E2%9C%93&';
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return joined.length > 0 ? prefix + joined : '';
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
'use strict';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var has$3 = Object.prototype.hasOwnProperty;
var isArray$3 = Array.isArray;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var defaults$2 = {
allowDots: false,
allowPrototypes: false,
arrayLimit: 20,
charset: 'utf-8',
charsetSentinel: false,
comma: false,
decoder: utils$1.decode,
delimiter: '&',
depth: 5,
ignoreQueryPrefix: false,
interpretNumericEntities: false,
parameterLimit: 1000,
parseArrays: true,
plainObjects: false,
strictNullHandling: false
};
var interpretNumericEntities = function (str) {
return str.replace(/&#(\d+);/g, function ($0, numberStr) {
return String.fromCharCode(parseInt(numberStr, 10));
2019-10-03 04:13:12 +08:00
});
2020-05-30 21:19:58 +08:00
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// This is what browsers will submit when the ✓ character occurs in an
// application/x-www-form-urlencoded body and the encoding of the page containing
// the form is iso-8859-1, or when the submitted form has an accept-charset
// attribute of iso-8859-1. Presumably also with other charsets that do not contain
// the ✓ character, such as us-ascii.
var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('&#10003;')
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.
var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓')
var parseValues = function parseQueryStringValues(str, options) {
var obj = {};
var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
var parts = cleanStr.split(options.delimiter, limit);
var skipIndex = -1; // Keep track of where the utf8 sentinel was found
var i;
var charset = options.charset;
if (options.charsetSentinel) {
for (i = 0; i < parts.length; ++i) {
if (parts[i].indexOf('utf8=') === 0) {
if (parts[i] === charsetSentinel) {
charset = 'utf-8';
} else if (parts[i] === isoSentinel) {
charset = 'iso-8859-1';
}
skipIndex = i;
i = parts.length; // The eslint settings do not allow break;
}
}
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
for (i = 0; i < parts.length; ++i) {
if (i === skipIndex) {
continue;
}
var part = parts[i];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var bracketEqualsPos = part.indexOf(']=');
var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var key, val;
if (pos === -1) {
key = options.decoder(part, defaults$2.decoder, charset, 'key');
val = options.strictNullHandling ? null : '';
} else {
key = options.decoder(part.slice(0, pos), defaults$2.decoder, charset, 'key');
val = options.decoder(part.slice(pos + 1), defaults$2.decoder, charset, 'value');
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
val = interpretNumericEntities(val);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
val = val.split(',');
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (part.indexOf('[]=') > -1) {
val = isArray$3(val) ? [val] : val;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (has$3.call(obj, key)) {
obj[key] = utils$1.combine(obj[key], val);
} else {
obj[key] = val;
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return obj;
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
var parseObject = function (chain, val, options) {
var leaf = val;
for (var i = chain.length - 1; i >= 0; --i) {
var obj;
var root = chain[i];
if (root === '[]' && options.parseArrays) {
obj = [].concat(leaf);
} else {
obj = options.plainObjects ? Object.create(null) : {};
var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
var index = parseInt(cleanRoot, 10);
if (!options.parseArrays && cleanRoot === '') {
obj = { 0: leaf };
} else if (
!isNaN(index)
&& root !== cleanRoot
&& String(index) === cleanRoot
&& index >= 0
&& (options.parseArrays && index <= options.arrayLimit)
) {
obj = [];
obj[index] = leaf;
} else {
obj[cleanRoot] = leaf;
}
}
leaf = obj;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
return leaf;
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
if (!givenKey) {
return;
}
// Transform dot notation to bracket notation
var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// The regex chunks
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var brackets = /(\[[^[\]]*])/;
var child = /(\[[^[\]]*])/g;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Get the parent
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var segment = options.depth > 0 && brackets.exec(key);
var parent = segment ? key.slice(0, segment.index) : key;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Stash the parent if it exists
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var keys = [];
if (parent) {
// If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
if (!options.plainObjects && has$3.call(Object.prototype, parent)) {
if (!options.allowPrototypes) {
return;
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
keys.push(parent);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Loop through children appending to the array until we hit depth
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var i = 0;
while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {
i += 1;
if (!options.plainObjects && has$3.call(Object.prototype, segment[1].slice(1, -1))) {
if (!options.allowPrototypes) {
return;
}
}
keys.push(segment[1]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// If there's a remainder, just add whatever is left
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (segment) {
keys.push('[' + key.slice(segment.index) + ']');
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
return parseObject(keys, val, options);
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
var normalizeParseOptions = function normalizeParseOptions(opts) {
if (!opts) {
return defaults$2;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {
throw new TypeError('Decoder has to be a function.');
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
throw new Error('The charset option must be either utf-8, iso-8859-1, or undefined');
}
var charset = typeof opts.charset === 'undefined' ? defaults$2.charset : opts.charset;
2019-10-03 04:13:12 +08:00
return {
2020-05-30 21:19:58 +08:00
allowDots: typeof opts.allowDots === 'undefined' ? defaults$2.allowDots : !!opts.allowDots,
allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults$2.allowPrototypes,
arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults$2.arrayLimit,
charset: charset,
charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults$2.charsetSentinel,
comma: typeof opts.comma === 'boolean' ? opts.comma : defaults$2.comma,
decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults$2.decoder,
delimiter: typeof opts.delimiter === 'string' || utils$1.isRegExp(opts.delimiter) ? opts.delimiter : defaults$2.delimiter,
// eslint-disable-next-line no-implicit-coercion, no-extra-parens
depth: (typeof opts.depth === 'number' || opts.depth === false) ? +opts.depth : defaults$2.depth,
ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults$2.interpretNumericEntities,
parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults$2.parameterLimit,
parseArrays: opts.parseArrays !== false,
plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults$2.plainObjects,
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults$2.strictNullHandling
2019-10-03 04:13:12 +08:00
};
};
2020-05-30 21:19:58 +08:00
var parse$1 = function (str, opts) {
var options = normalizeParseOptions(opts);
if (str === '' || str === null || typeof str === 'undefined') {
return options.plainObjects ? Object.create(null) : {};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
var obj = options.plainObjects ? Object.create(null) : {};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Iterate over the keys and setup the new object
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var keys = Object.keys(tempObj);
for (var i = 0; i < keys.length; ++i) {
var key = keys[i];
var newObj = parseKeys(key, tempObj[key], options);
obj = utils$1.merge(obj, newObj, options);
}
return utils$1.compact(obj);
2019-10-03 04:13:12 +08:00
};
'use strict';
2020-05-30 21:19:58 +08:00
var lib = {
formats: formats,
parse: parse$1,
stringify: stringify_1
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
var lib_1 = lib.formats;
var lib_2 = lib.parse;
var lib_3 = lib.stringify;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var client = function(axios, { url, ...credentials }) {
const config = {
url,
method: 'post',
data: lib.stringify(credentials)
};
return () => axios(config).then(res => res.data);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function getMaxAge(res) {
return res.expires_in;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function headerFormatter(res) {
return 'Bearer ' + res.access_token;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var interceptor = function (tokenProvider, authenticate) {
const getToken = tokenProvider.tokenCache(authenticate, { getMaxAge });
return tokenProvider({ getToken, headerFormatter });
};
var src = {
client: client,
interceptor: interceptor
};
var src_1 = src.client;
var src_2 = src.interceptor;
'use strict';
2019-10-03 04:13:12 +08:00
/**
2020-05-30 21:19:58 +08:00
* Check if we're required to add a port number.
2019-10-03 04:13:12 +08:00
*
2020-05-30 21:19:58 +08:00
* @see https://url.spec.whatwg.org/#default-port
* @param {Number|String} port Port number we need to check
* @param {String} protocol Protocol we need to check against.
* @returns {Boolean} Is it a default port for the given protocol
* @api private
2019-10-03 04:13:12 +08:00
*/
2020-05-30 21:19:58 +08:00
var requiresPort = function required(port, protocol) {
protocol = protocol.split(':')[0];
port = +port;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!port) return false;
switch (protocol) {
case 'http':
case 'ws':
return port !== 80;
case 'https':
case 'wss':
return port !== 443;
case 'ftp':
return port !== 21;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
case 'gopher':
return port !== 70;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
case 'file':
return false;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return port !== 0;
2019-10-03 04:13:12 +08:00
};
'use strict';
2020-05-30 21:19:58 +08:00
var slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//
, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i
, whitespace = '[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]'
, left = new RegExp('^'+ whitespace +'+');
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Trim a given string.
*
* @param {String} str String to trim.
* @public
*/
function trimLeft(str) {
return (str ? str : '').toString().replace(left, '');
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* These are the parse rules for the URL parser, it informs the parser
* about:
*
* 0. The char it Needs to parse, if it's a string it should be done using
* indexOf, RegExp using exec and NaN means set as current value.
* 1. The property we should set when parsing this value.
* 2. Indication if it's backwards or forward parsing, when set as number it's
* the value of extra chars that should be split off.
* 3. Inherit from location if non existing in the parser.
* 4. `toLowerCase` the resulting value.
*/
var rules = [
['#', 'hash'], // Extract from the back.
['?', 'query'], // Extract from the back.
function sanitize(address) { // Sanitize what is left of the address
return address.replace('\\', '/');
},
['/', 'pathname'], // Extract from the back.
['@', 'auth', 1], // Extract from the front.
[NaN, 'host', undefined, 1, 1], // Set left over value.
[/:(\d+)$/, 'port', undefined, 1], // RegExp the back.
[NaN, 'hostname', undefined, 1, 1] // Set left over.
];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* These properties should not be copied or inherited from. This is only needed
* for all non blob URL's as a blob URL does not include a hash, only the
* origin.
*
* @type {Object}
* @private
*/
var ignore = { hash: 1, query: 1 };
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* The location object differs when your code is loaded through a normal page,
* Worker or through a worker using a blob. And with the blobble begins the
* trouble as the location object will contain the URL of the blob, not the
* location of the page where our code is loaded in. The actual origin is
* encoded in the `pathname` so we can thankfully generate a good "default"
* location from it so we can generate proper relative URL's again.
*
* @param {Object|String} loc Optional default location object.
* @returns {Object} lolcation object.
* @public
*/
function lolcation(loc) {
var globalVar;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (typeof window !== 'undefined') globalVar = window;
else if (typeof commonjsGlobal !== 'undefined') globalVar = commonjsGlobal;
else if (typeof self !== 'undefined') globalVar = self;
else globalVar = {};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var location = globalVar.location || {};
loc = loc || location;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var finaldestination = {}
, type = typeof loc
, key;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if ('blob:' === loc.protocol) {
finaldestination = new Url(unescape(loc.pathname), {});
} else if ('string' === type) {
finaldestination = new Url(loc, {});
for (key in ignore) delete finaldestination[key];
} else if ('object' === type) {
for (key in loc) {
if (key in ignore) continue;
finaldestination[key] = loc[key];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (finaldestination.slashes === undefined) {
finaldestination.slashes = slashes.test(loc.href);
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return finaldestination;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* @typedef ProtocolExtract
* @type Object
* @property {String} protocol Protocol matched in the URL, in lowercase.
* @property {Boolean} slashes `true` if protocol is followed by "//", else `false`.
* @property {String} rest Rest of the URL that is not part of the protocol.
*/
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Extract protocol information from a URL with/without double slash ("//").
*
* @param {String} address URL we want to extract from.
* @return {ProtocolExtract} Extracted information.
* @private
*/
function extractProtocol(address) {
address = trimLeft(address);
var match = protocolre.exec(address);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
protocol: match[1] ? match[1].toLowerCase() : '',
slashes: !!match[2],
rest: match[3]
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Resolve a relative URL pathname against a base URL pathname.
*
* @param {String} relative Pathname of the relative URL.
* @param {String} base Pathname of the base URL.
* @return {String} Resolved pathname.
* @private
*/
function resolve(relative, base) {
if (relative === '') return base;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/'))
, i = path.length
, last = path[i - 1]
, unshift = false
, up = 0;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
while (i--) {
if (path[i] === '.') {
path.splice(i, 1);
} else if (path[i] === '..') {
path.splice(i, 1);
up++;
} else if (up) {
if (i === 0) unshift = true;
path.splice(i, 1);
up--;
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (unshift) path.unshift('');
if (last === '.' || last === '..') path.push('');
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return path.join('/');
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* The actual URL instance. Instead of returning an object we've opted-in to
* create an actual constructor as it's much more memory efficient and
* faster and it pleases my OCD.
*
* It is worth noting that we should not use `URL` as class name to prevent
* clashes with the global URL instance that got introduced in browsers.
*
* @constructor
* @param {String} address URL we want to parse.
* @param {Object|String} [location] Location defaults for relative paths.
* @param {Boolean|Function} [parser] Parser for the query string.
* @private
*/
function Url(address, location, parser) {
address = trimLeft(address);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!(this instanceof Url)) {
return new Url(address, location, parser);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var relative, extracted, parse, instruction, index, key
, instructions = rules.slice()
, type = typeof location
, url = this
, i = 0;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
//
// The following if statements allows this module two have compatibility with
// 2 different API:
//
// 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments
// where the boolean indicates that the query string should also be parsed.
//
// 2. The `URL` interface of the browser which accepts a URL, object as
// arguments. The supplied object will be used as default values / fall-back
// for relative paths.
//
if ('object' !== type && 'string' !== type) {
parser = location;
location = null;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (parser && 'function' !== typeof parser) parser = querystringify_1.parse;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
location = lolcation(location);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
//
// Extract protocol information before running the instructions.
//
extracted = extractProtocol(address || '');
relative = !extracted.protocol && !extracted.slashes;
url.slashes = extracted.slashes || relative && location.slashes;
url.protocol = extracted.protocol || location.protocol || '';
address = extracted.rest;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
//
// When the authority component is absent the URL starts with a path
// component.
//
if (!extracted.slashes) instructions[3] = [/(.*)/, 'pathname'];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (; i < instructions.length; i++) {
instruction = instructions[i];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (typeof instruction === 'function') {
address = instruction(address);
continue;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
parse = instruction[0];
key = instruction[1];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (parse !== parse) {
url[key] = address;
} else if ('string' === typeof parse) {
if (~(index = address.indexOf(parse))) {
if ('number' === typeof instruction[2]) {
url[key] = address.slice(0, index);
address = address.slice(index + instruction[2]);
} else {
url[key] = address.slice(index);
address = address.slice(0, index);
}
}
} else if ((index = parse.exec(address))) {
url[key] = index[1];
address = address.slice(0, index.index);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
url[key] = url[key] || (
relative && instruction[3] ? location[key] || '' : ''
);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
//
// Hostname, host and protocol should be lowercased so they can be used to
// create a proper `origin`.
//
if (instruction[4]) url[key] = url[key].toLowerCase();
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
//
// Also parse the supplied query string in to an object. If we're supplied
// with a custom parser as function use that instead of the default build-in
// parser.
//
if (parser) url.query = parser(url.query);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
//
// If the URL is relative, resolve the pathname against the base URL.
//
if (
relative
&& location.slashes
&& url.pathname.charAt(0) !== '/'
&& (url.pathname !== '' || location.pathname !== '')
) {
url.pathname = resolve(url.pathname, location.pathname);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
//
// We should not add port numbers if they are already the default port number
// for a given protocol. As the host also contains the port number we're going
// override it with the hostname which contains no port number.
//
if (!requiresPort(url.port, url.protocol)) {
url.host = url.hostname;
url.port = '';
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
//
// Parse down the `auth` for the username and password.
//
url.username = url.password = '';
if (url.auth) {
instruction = url.auth.split(':');
url.username = instruction[0] || '';
url.password = instruction[1] || '';
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
url.origin = url.protocol && url.host && url.protocol !== 'file:'
? url.protocol +'//'+ url.host
: 'null';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
//
// The href is just the compiled result.
//
url.href = url.toString();
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* This is convenience method for changing properties in the URL instance to
* insure that they all propagate correctly.
*
* @param {String} part Property we need to adjust.
* @param {Mixed} value The newly assigned value.
* @param {Boolean|Function} fn When setting the query, it will be the function
* used to parse the query.
* When setting the protocol, double slash will be
* removed from the final url if it is true.
* @returns {URL} URL instance for chaining.
* @public
*/
function set(part, value, fn) {
var url = this;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
switch (part) {
case 'query':
if ('string' === typeof value && value.length) {
value = (fn || querystringify_1.parse)(value);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
url[part] = value;
break;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
case 'port':
url[part] = value;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!requiresPort(value, url.protocol)) {
url.host = url.hostname;
url[part] = '';
} else if (value) {
url.host = url.hostname +':'+ value;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
break;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
case 'hostname':
url[part] = value;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (url.port) value += ':'+ url.port;
url.host = value;
break;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
case 'host':
url[part] = value;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (/:\d+$/.test(value)) {
value = value.split(':');
url.port = value.pop();
url.hostname = value.join(':');
} else {
url.hostname = value;
url.port = '';
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
break;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
case 'protocol':
url.protocol = value.toLowerCase();
url.slashes = !fn;
break;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
case 'pathname':
case 'hash':
if (value) {
var char = part === 'pathname' ? '/' : '#';
url[part] = value.charAt(0) !== char ? char + value : value;
} else {
url[part] = value;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
break;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
default:
url[part] = value;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (var i = 0; i < rules.length; i++) {
var ins = rules[i];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
url.origin = url.protocol && url.host && url.protocol !== 'file:'
? url.protocol +'//'+ url.host
: 'null';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
url.href = url.toString();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return url;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Transform the properties back in to a valid and full URL string.
*
* @param {Function} stringify Optional query stringify function.
* @returns {String} Compiled version of the URL.
* @public
*/
function toString$1(stringify) {
if (!stringify || 'function' !== typeof stringify) stringify = querystringify_1.stringify;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var query
, url = this
, protocol = url.protocol;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var result = protocol + (url.slashes ? '//' : '');
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (url.username) {
result += url.username;
if (url.password) result += ':'+ url.password;
result += '@';
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
result += url.host + url.pathname;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
query = 'object' === typeof url.query ? stringify(url.query) : url.query;
if (query) result += '?' !== query.charAt(0) ? '?'+ query : query;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (url.hash) result += url.hash;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return result;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
Url.prototype = { set: set, toString: toString$1 };
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
//
// Expose the URL parser and some additional properties that might be useful for
// others or testing.
//
Url.extractProtocol = extractProtocol;
Url.location = lolcation;
Url.trimLeft = trimLeft;
Url.qs = querystringify_1;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var urlParse = Url;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var index_min = createCommonjsModule(function (module) {
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n});},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0});},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";r.r(t);var n={statusCodes:[401]};t.default=function e(t,r){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},u=t.interceptors.response.use(function(e){return e},function(s){var i=o.hasOwnProperty("statusCodes")&&o.statusCodes.length?o.statusCodes:n.statusCodes;if(!s.response||s.response.status&&-1===i.indexOf(+s.response.status))return Promise.reject(s);t.interceptors.response.eject(u);var c=r(s),f=t.interceptors.request.use(function(e){return c.then(function(){return e})});return c.then(function(){return t.interceptors.request.eject(f),t(s.response.config)}).catch(function(e){return t.interceptors.request.eject(f),Promise.reject(e)}).finally(function(){return e(t,r,o)})});return t};}]);
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var createAuthRefreshInterceptor = unwrapExports(index_min);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/* global DOMException */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var clipboardCopy_1 = clipboardCopy;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function clipboardCopy (text) {
// Use the Async Clipboard API when available. Requires a secure browing
// context (i.e. HTTPS)
if (navigator.clipboard) {
return navigator.clipboard.writeText(text).catch(function (err) {
throw (err !== undefined ? err : new DOMException('The request is not allowed', 'NotAllowedError'))
})
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
// ...Otherwise, use document.execCommand() fallback
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Put the text to copy into a <span>
var span = document.createElement('span');
span.textContent = text;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Preserve consecutive spaces and newlines
span.style.whiteSpace = 'pre';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Add the <span> to the page
document.body.appendChild(span);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Make a selection object representing the range of text selected by the user
var selection = window.getSelection();
var range = window.document.createRange();
selection.removeAllRanges();
range.selectNode(span);
selection.addRange(range);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Copy text to the clipboard
var success = false;
try {
success = window.document.execCommand('copy');
} catch (err) {
console.log('error', err);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Cleanup
selection.removeAllRanges();
window.document.body.removeChild(span);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return success
? Promise.resolve()
: Promise.reject(new DOMException('The request is not allowed', 'NotAllowedError'))
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var core = createCommonjsModule(function (module, exports) {
;(function (root, factory) {
if ('object' === "object") {
// CommonJS
module.exports = exports = factory();
}
else if (typeof undefined === "function" && undefined.amd) {
// AMD
undefined([], factory);
}
else {
// Global (browser)
root.CryptoJS = factory();
}
}(commonjsGlobal, function () {
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* CryptoJS core components.
*/
var CryptoJS = CryptoJS || (function (Math, undefined$1) {
/*
* Local polyfil of Object.create
*/
var create = Object.create || (function () {
function F() {};
return function (obj) {
var subtype;
F.prototype = obj;
subtype = new F();
F.prototype = null;
return subtype;
};
}());
/**
* CryptoJS namespace.
*/
var C = {};
/**
* Library namespace.
*/
var C_lib = C.lib = {};
/**
* Base object for prototypal inheritance.
*/
var Base = C_lib.Base = (function () {
return {
/**
* Creates a new object that inherits from this object.
*
* @param {Object} overrides Properties to copy into the new object.
*
* @return {Object} The new object.
*
* @static
*
* @example
*
* var MyType = CryptoJS.lib.Base.extend({
* field: 'value',
*
* method: function () {
* }
* });
*/
extend: function (overrides) {
// Spawn
var subtype = create(this);
// Augment
if (overrides) {
subtype.mixIn(overrides);
}
// Create default initializer
if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
subtype.init = function () {
subtype.$super.init.apply(this, arguments);
};
}
// Initializer's prototype is the subtype object
subtype.init.prototype = subtype;
// Reference supertype
subtype.$super = this;
return subtype;
},
/**
* Extends this object and runs the init method.
* Arguments to create() will be passed to init().
*
* @return {Object} The new object.
*
* @static
*
* @example
*
* var instance = MyType.create();
*/
create: function () {
var instance = this.extend();
instance.init.apply(instance, arguments);
return instance;
},
/**
* Initializes a newly created object.
* Override this method to add some logic when your objects are created.
*
* @example
*
* var MyType = CryptoJS.lib.Base.extend({
* init: function () {
* // ...
* }
* });
*/
init: function () {
},
/**
* Copies properties into this object.
*
* @param {Object} properties The properties to mix in.
*
* @example
*
* MyType.mixIn({
* field: 'value'
* });
*/
mixIn: function (properties) {
for (var propertyName in properties) {
if (properties.hasOwnProperty(propertyName)) {
this[propertyName] = properties[propertyName];
}
}
// IE won't copy toString using the loop above
if (properties.hasOwnProperty('toString')) {
this.toString = properties.toString;
}
},
/**
* Creates a copy of this object.
*
* @return {Object} The clone.
*
* @example
*
* var clone = instance.clone();
*/
clone: function () {
return this.init.prototype.extend(this);
}
};
}());
/**
* An array of 32-bit words.
*
* @property {Array} words The array of 32-bit words.
* @property {number} sigBytes The number of significant bytes in this word array.
*/
var WordArray = C_lib.WordArray = Base.extend({
/**
* Initializes a newly created word array.
*
* @param {Array} words (Optional) An array of 32-bit words.
* @param {number} sigBytes (Optional) The number of significant bytes in the words.
*
* @example
*
* var wordArray = CryptoJS.lib.WordArray.create();
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
*/
init: function (words, sigBytes) {
words = this.words = words || [];
if (sigBytes != undefined$1) {
this.sigBytes = sigBytes;
} else {
this.sigBytes = words.length * 4;
}
},
/**
* Converts this word array to a string.
*
* @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
*
* @return {string} The stringified word array.
*
* @example
*
* var string = wordArray + '';
* var string = wordArray.toString();
* var string = wordArray.toString(CryptoJS.enc.Utf8);
*/
toString: function (encoder) {
return (encoder || Hex).stringify(this);
},
/**
* Concatenates a word array to this word array.
*
* @param {WordArray} wordArray The word array to append.
*
* @return {WordArray} This word array.
*
* @example
*
* wordArray1.concat(wordArray2);
*/
concat: function (wordArray) {
// Shortcuts
var thisWords = this.words;
var thatWords = wordArray.words;
var thisSigBytes = this.sigBytes;
var thatSigBytes = wordArray.sigBytes;
// Clamp excess bits
this.clamp();
// Concat
if (thisSigBytes % 4) {
// Copy one byte at a time
for (var i = 0; i < thatSigBytes; i++) {
var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
}
} else {
// Copy one word at a time
for (var i = 0; i < thatSigBytes; i += 4) {
thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
}
}
this.sigBytes += thatSigBytes;
// Chainable
return this;
},
/**
* Removes insignificant bits.
*
* @example
*
* wordArray.clamp();
*/
clamp: function () {
// Shortcuts
var words = this.words;
var sigBytes = this.sigBytes;
// Clamp
words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
words.length = Math.ceil(sigBytes / 4);
},
/**
* Creates a copy of this word array.
*
* @return {WordArray} The clone.
*
* @example
*
* var clone = wordArray.clone();
*/
clone: function () {
var clone = Base.clone.call(this);
clone.words = this.words.slice(0);
return clone;
},
/**
* Creates a word array filled with random bytes.
*
* @param {number} nBytes The number of random bytes to generate.
*
* @return {WordArray} The random word array.
*
* @static
*
* @example
*
* var wordArray = CryptoJS.lib.WordArray.random(16);
*/
random: function (nBytes) {
var words = [];
var r = (function (m_w) {
var m_w = m_w;
var m_z = 0x3ade68b1;
var mask = 0xffffffff;
return function () {
m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
var result = ((m_z << 0x10) + m_w) & mask;
result /= 0x100000000;
result += 0.5;
return result * (Math.random() > .5 ? 1 : -1);
}
});
for (var i = 0, rcache; i < nBytes; i += 4) {
var _r = r((rcache || Math.random()) * 0x100000000);
rcache = _r() * 0x3ade67b7;
words.push((_r() * 0x100000000) | 0);
}
return new WordArray.init(words, nBytes);
}
});
/**
* Encoder namespace.
*/
var C_enc = C.enc = {};
/**
* Hex encoding strategy.
*/
var Hex = C_enc.Hex = {
/**
* Converts a word array to a hex string.
*
* @param {WordArray} wordArray The word array.
*
* @return {string} The hex string.
*
* @static
*
* @example
*
* var hexString = CryptoJS.enc.Hex.stringify(wordArray);
*/
stringify: function (wordArray) {
// Shortcuts
var words = wordArray.words;
var sigBytes = wordArray.sigBytes;
// Convert
var hexChars = [];
for (var i = 0; i < sigBytes; i++) {
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
hexChars.push((bite >>> 4).toString(16));
hexChars.push((bite & 0x0f).toString(16));
}
return hexChars.join('');
},
/**
* Converts a hex string to a word array.
*
* @param {string} hexStr The hex string.
*
* @return {WordArray} The word array.
*
* @static
*
* @example
*
* var wordArray = CryptoJS.enc.Hex.parse(hexString);
*/
parse: function (hexStr) {
// Shortcut
var hexStrLength = hexStr.length;
// Convert
var words = [];
for (var i = 0; i < hexStrLength; i += 2) {
words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
}
return new WordArray.init(words, hexStrLength / 2);
}
};
/**
* Latin1 encoding strategy.
*/
var Latin1 = C_enc.Latin1 = {
/**
* Converts a word array to a Latin1 string.
*
* @param {WordArray} wordArray The word array.
*
* @return {string} The Latin1 string.
*
* @static
*
* @example
*
* var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
*/
stringify: function (wordArray) {
// Shortcuts
var words = wordArray.words;
var sigBytes = wordArray.sigBytes;
// Convert
var latin1Chars = [];
for (var i = 0; i < sigBytes; i++) {
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
latin1Chars.push(String.fromCharCode(bite));
}
return latin1Chars.join('');
},
/**
* Converts a Latin1 string to a word array.
*
* @param {string} latin1Str The Latin1 string.
*
* @return {WordArray} The word array.
*
* @static
*
* @example
*
* var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
*/
parse: function (latin1Str) {
// Shortcut
var latin1StrLength = latin1Str.length;
// Convert
var words = [];
for (var i = 0; i < latin1StrLength; i++) {
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
}
return new WordArray.init(words, latin1StrLength);
}
};
/**
* UTF-8 encoding strategy.
*/
var Utf8 = C_enc.Utf8 = {
/**
* Converts a word array to a UTF-8 string.
*
* @param {WordArray} wordArray The word array.
*
* @return {string} The UTF-8 string.
*
* @static
*
* @example
*
* var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
*/
stringify: function (wordArray) {
try {
return decodeURIComponent(escape(Latin1.stringify(wordArray)));
} catch (e) {
throw new Error('Malformed UTF-8 data');
}
},
/**
* Converts a UTF-8 string to a word array.
*
* @param {string} utf8Str The UTF-8 string.
*
* @return {WordArray} The word array.
*
* @static
*
* @example
*
* var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
*/
parse: function (utf8Str) {
return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
}
};
/**
* Abstract buffered block algorithm template.
*
* The property blockSize must be implemented in a concrete subtype.
*
* @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
*/
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
/**
* Resets this block algorithm's data buffer to its initial state.
*
* @example
*
* bufferedBlockAlgorithm.reset();
*/
reset: function () {
// Initial values
this._data = new WordArray.init();
this._nDataBytes = 0;
},
/**
* Adds new data to this block algorithm's buffer.
*
* @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
*
* @example
*
* bufferedBlockAlgorithm._append('data');
* bufferedBlockAlgorithm._append(wordArray);
*/
_append: function (data) {
// Convert string to WordArray, else assume WordArray already
if (typeof data == 'string') {
data = Utf8.parse(data);
}
// Append
this._data.concat(data);
this._nDataBytes += data.sigBytes;
},
/**
* Processes available data blocks.
*
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
*
* @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
*
* @return {WordArray} The processed data.
*
* @example
*
* var processedData = bufferedBlockAlgorithm._process();
* var processedData = bufferedBlockAlgorithm._process(!!'flush');
*/
_process: function (doFlush) {
// Shortcuts
var data = this._data;
var dataWords = data.words;
var dataSigBytes = data.sigBytes;
var blockSize = this.blockSize;
var blockSizeBytes = blockSize * 4;
// Count blocks ready
var nBlocksReady = dataSigBytes / blockSizeBytes;
if (doFlush) {
// Round up to include partial blocks
nBlocksReady = Math.ceil(nBlocksReady);
} else {
// Round down to include only full blocks,
// less the number of blocks that must remain in the buffer
nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
}
// Count words ready
var nWordsReady = nBlocksReady * blockSize;
// Count bytes ready
var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
// Process blocks
if (nWordsReady) {
for (var offset = 0; offset < nWordsReady; offset += blockSize) {
// Perform concrete-algorithm logic
this._doProcessBlock(dataWords, offset);
}
// Remove processed words
var processedWords = dataWords.splice(0, nWordsReady);
data.sigBytes -= nBytesReady;
}
// Return processed words
return new WordArray.init(processedWords, nBytesReady);
},
/**
* Creates a copy of this object.
*
* @return {Object} The clone.
*
* @example
*
* var clone = bufferedBlockAlgorithm.clone();
*/
clone: function () {
var clone = Base.clone.call(this);
clone._data = this._data.clone();
return clone;
},
_minBufferSize: 0
});
/**
* Abstract hasher template.
*
* @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
*/
var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
/**
* Configuration options.
*/
cfg: Base.extend(),
/**
* Initializes a newly created hasher.
*
* @param {Object} cfg (Optional) The configuration options to use for this hash computation.
*
* @example
*
* var hasher = CryptoJS.algo.SHA256.create();
*/
init: function (cfg) {
// Apply config defaults
this.cfg = this.cfg.extend(cfg);
// Set initial values
this.reset();
},
/**
* Resets this hasher to its initial state.
*
* @example
*
* hasher.reset();
*/
reset: function () {
// Reset data buffer
BufferedBlockAlgorithm.reset.call(this);
// Perform concrete-hasher logic
this._doReset();
},
/**
* Updates this hasher with a message.
*
* @param {WordArray|string} messageUpdate The message to append.
*
* @return {Hasher} This hasher.
*
* @example
*
* hasher.update('message');
* hasher.update(wordArray);
*/
update: function (messageUpdate) {
// Append
this._append(messageUpdate);
// Update the hash
this._process();
// Chainable
return this;
},
/**
* Finalizes the hash computation.
* Note that the finalize operation is effectively a destructive, read-once operation.
*
* @param {WordArray|string} messageUpdate (Optional) A final message update.
*
* @return {WordArray} The hash.
*
* @example
*
* var hash = hasher.finalize();
* var hash = hasher.finalize('message');
* var hash = hasher.finalize(wordArray);
*/
finalize: function (messageUpdate) {
// Final message update
if (messageUpdate) {
this._append(messageUpdate);
}
// Perform concrete-hasher logic
var hash = this._doFinalize();
return hash;
},
blockSize: 512/32,
/**
* Creates a shortcut function to a hasher's object interface.
*
* @param {Hasher} hasher The hasher to create a helper for.
*
* @return {Function} The shortcut function.
*
* @static
*
* @example
*
* var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
*/
_createHelper: function (hasher) {
return function (message, cfg) {
return new hasher.init(cfg).finalize(message);
};
},
/**
* Creates a shortcut function to the HMAC's object interface.
*
* @param {Hasher} hasher The hasher to use in this HMAC helper.
*
* @return {Function} The shortcut function.
*
* @static
*
* @example
*
* var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
*/
_createHmacHelper: function (hasher) {
return function (message, key) {
return new C_algo.HMAC.init(hasher, key).finalize(message);
};
}
});
/**
* Algorithm namespace.
*/
var C_algo = C.algo = {};
return C;
}(Math));
return CryptoJS;
}));
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var sha256 = createCommonjsModule(function (module, exports) {
;(function (root, factory) {
if ('object' === "object") {
// CommonJS
module.exports = exports = factory(core);
}
else if (typeof undefined === "function" && undefined.amd) {
// AMD
undefined(["./core"], factory);
}
else {
// Global (browser)
factory(root.CryptoJS);
}
}(commonjsGlobal, function (CryptoJS) {
(function (Math) {
// Shortcuts
var C = CryptoJS;
var C_lib = C.lib;
var WordArray = C_lib.WordArray;
var Hasher = C_lib.Hasher;
var C_algo = C.algo;
// Initialization and round constants tables
var H = [];
var K = [];
// Compute constants
(function () {
function isPrime(n) {
var sqrtN = Math.sqrt(n);
for (var factor = 2; factor <= sqrtN; factor++) {
if (!(n % factor)) {
return false;
}
}
return true;
}
function getFractionalBits(n) {
return ((n - (n | 0)) * 0x100000000) | 0;
}
var n = 2;
var nPrime = 0;
while (nPrime < 64) {
if (isPrime(n)) {
if (nPrime < 8) {
H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
}
K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
nPrime++;
}
n++;
}
}());
// Reusable object
var W = [];
/**
* SHA-256 hash algorithm.
*/
var SHA256 = C_algo.SHA256 = Hasher.extend({
_doReset: function () {
this._hash = new WordArray.init(H.slice(0));
},
_doProcessBlock: function (M, offset) {
// Shortcut
var H = this._hash.words;
// Working variables
var a = H[0];
var b = H[1];
var c = H[2];
var d = H[3];
var e = H[4];
var f = H[5];
var g = H[6];
var h = H[7];
// Computation
for (var i = 0; i < 64; i++) {
if (i < 16) {
W[i] = M[offset + i] | 0;
} else {
var gamma0x = W[i - 15];
var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
((gamma0x << 14) | (gamma0x >>> 18)) ^
(gamma0x >>> 3);
var gamma1x = W[i - 2];
var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
((gamma1x << 13) | (gamma1x >>> 19)) ^
(gamma1x >>> 10);
W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
}
var ch = (e & f) ^ (~e & g);
var maj = (a & b) ^ (a & c) ^ (b & c);
var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
var t1 = h + sigma1 + ch + K[i] + W[i];
var t2 = sigma0 + maj;
h = g;
g = f;
f = e;
e = (d + t1) | 0;
d = c;
c = b;
b = a;
a = (t1 + t2) | 0;
}
// Intermediate hash value
H[0] = (H[0] + a) | 0;
H[1] = (H[1] + b) | 0;
H[2] = (H[2] + c) | 0;
H[3] = (H[3] + d) | 0;
H[4] = (H[4] + e) | 0;
H[5] = (H[5] + f) | 0;
H[6] = (H[6] + g) | 0;
H[7] = (H[7] + h) | 0;
},
_doFinalize: function () {
// Shortcuts
var data = this._data;
var dataWords = data.words;
var nBitsTotal = this._nDataBytes * 8;
var nBitsLeft = data.sigBytes * 8;
// Add padding
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
data.sigBytes = dataWords.length * 4;
// Hash final blocks
this._process();
// Return final computed hash
return this._hash;
},
clone: function () {
var clone = Hasher.clone.call(this);
clone._hash = this._hash.clone();
return clone;
}
});
/**
* Shortcut function to the hasher's object interface.
*
* @param {WordArray|string} message The message to hash.
*
* @return {WordArray} The hash.
*
* @static
*
* @example
*
* var hash = CryptoJS.SHA256('message');
* var hash = CryptoJS.SHA256(wordArray);
*/
C.SHA256 = Hasher._createHelper(SHA256);
/**
* Shortcut function to the HMAC's object interface.
*
* @param {WordArray|string} message The message to hash.
* @param {WordArray|string} key The secret key.
*
* @return {WordArray} The HMAC.
*
* @static
*
* @example
*
* var hmac = CryptoJS.HmacSHA256(message, key);
*/
C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
}(Math));
return CryptoJS.SHA256;
}));
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var encBase64 = createCommonjsModule(function (module, exports) {
;(function (root, factory) {
if ('object' === "object") {
// CommonJS
module.exports = exports = factory(core);
}
else if (typeof undefined === "function" && undefined.amd) {
// AMD
undefined(["./core"], factory);
}
else {
// Global (browser)
factory(root.CryptoJS);
}
}(commonjsGlobal, function (CryptoJS) {
(function () {
// Shortcuts
var C = CryptoJS;
var C_lib = C.lib;
var WordArray = C_lib.WordArray;
var C_enc = C.enc;
/**
* Base64 encoding strategy.
*/
var Base64 = C_enc.Base64 = {
/**
* Converts a word array to a Base64 string.
*
* @param {WordArray} wordArray The word array.
*
* @return {string} The Base64 string.
*
* @static
*
* @example
*
* var base64String = CryptoJS.enc.Base64.stringify(wordArray);
*/
stringify: function (wordArray) {
// Shortcuts
var words = wordArray.words;
var sigBytes = wordArray.sigBytes;
var map = this._map;
// Clamp excess bits
wordArray.clamp();
// Convert
var base64Chars = [];
for (var i = 0; i < sigBytes; i += 3) {
var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
}
}
// Add padding
var paddingChar = map.charAt(64);
if (paddingChar) {
while (base64Chars.length % 4) {
base64Chars.push(paddingChar);
}
}
return base64Chars.join('');
},
/**
* Converts a Base64 string to a word array.
*
* @param {string} base64Str The Base64 string.
*
* @return {WordArray} The word array.
*
* @static
*
* @example
*
* var wordArray = CryptoJS.enc.Base64.parse(base64String);
*/
parse: function (base64Str) {
// Shortcuts
var base64StrLength = base64Str.length;
var map = this._map;
var reverseMap = this._reverseMap;
if (!reverseMap) {
reverseMap = this._reverseMap = [];
for (var j = 0; j < map.length; j++) {
reverseMap[map.charCodeAt(j)] = j;
}
}
// Ignore padding
var paddingChar = map.charAt(64);
if (paddingChar) {
var paddingIndex = base64Str.indexOf(paddingChar);
if (paddingIndex !== -1) {
base64StrLength = paddingIndex;
}
}
// Convert
return parseLoop(base64Str, base64StrLength, reverseMap);
},
_map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
};
function parseLoop(base64Str, base64StrLength, reverseMap) {
var words = [];
var nBytes = 0;
for (var i = 0; i < base64StrLength; i++) {
if (i % 4) {
var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
nBytes++;
}
}
return WordArray.create(words, nBytes);
}
}());
return CryptoJS.enc.Base64;
}));
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var _nodeResolve_empty = {};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({
__proto__: null,
'default': _nodeResolve_empty
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var require$$0 = getCjsExportFromNamespace(_nodeResolve_empty$1);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var secureRandom = createCommonjsModule(function (module) {
!function(globals){
'use strict';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
//*** UMD BEGIN
if (typeof undefined !== 'undefined' && undefined.amd) { //require.js / AMD
undefined([], function() {
return secureRandom
});
} else if ('object' !== 'undefined' && module.exports) { //CommonJS
module.exports = secureRandom;
} else { //script / browser
globals.secureRandom = secureRandom;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
//*** UMD END
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
//options.type is the only valid option
function secureRandom(count, options) {
options = options || {type: 'Array'};
//we check for process.pid to prevent browserify from tricking us
if (
typeof process != 'undefined'
&& typeof process.pid == 'number'
&& process.versions
&& process.versions.node
) {
return nodeRandom(count, options)
} else {
var crypto = window.crypto || window.msCrypto;
if (!crypto) throw new Error("Your browser does not support window.crypto.")
return browserRandom(count, options)
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function nodeRandom(count, options) {
var crypto = require$$0;
var buf = crypto.randomBytes(count);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
switch (options.type) {
case 'Array':
return [].slice.call(buf)
case 'Buffer':
return buf
case 'Uint8Array':
var arr = new Uint8Array(count);
for (var i = 0; i < count; ++i) { arr[i] = buf.readUInt8(i); }
return arr
default:
throw new Error(options.type + " is unsupported.")
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function browserRandom(count, options) {
var nativeArr = new Uint8Array(count);
var crypto = window.crypto || window.msCrypto;
crypto.getRandomValues(nativeArr);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
switch (options.type) {
case 'Array':
return [].slice.call(nativeArr)
case 'Buffer':
try { var b = new Buffer(1); } catch(e) { throw new Error('Buffer not supported in this environment. Use Node.js or Browserify for browser support.')}
return new Buffer(nativeArr)
case 'Uint8Array':
return nativeArr
default:
throw new Error(options.type + " is unsupported.")
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
secureRandom.randomArray = function(byteCount) {
return secureRandom(byteCount, {type: 'Array'})
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
secureRandom.randomUint8Array = function(byteCount) {
return secureRandom(byteCount, {type: 'Uint8Array'})
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
secureRandom.randomBuffer = function(byteCount) {
return secureRandom(byteCount, {type: 'Buffer'})
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
}(commonjsGlobal);
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var lib$1 = createCommonjsModule(function (module, exports) {
"use strict";
exports.__esModule = true;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var mask = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";
function random(size) {
var value = "";
var bytes = secureRandom(size);
var scale = 256 / mask.length; // 256 = 0 to 0xFF (randomBytes)
for (var i = 0; i < size; i++) {
value += mask.charAt(Math.floor(bytes[i] / scale));
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
return value;
}
exports.random = random;
function hash(str) {
return encBase64.stringify(sha256(str));
}
function base64url(str) {
return str
.replace(/=/g, "")
.replace(/\+/g, "-")
.replace(/\//g, "_");
}
function createVerifier(length) {
if (length === void 0) { length = 128; }
if (length < 43 || length > 128) {
throw new Error("expected length " + length + " between 43 and 128");
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
return random(length);
}
exports.createVerifier = createVerifier;
function createChallenge(verifier) {
return base64url(hash(verifier));
}
exports.createChallenge = createChallenge;
function create(length) {
if (length === void 0) { length = 128; }
var verifier = createVerifier(length);
var challenge = createChallenge(verifier);
return {
codeVerifier: verifier,
codeChallenge: challenge
};
}
exports.create = create;
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var pkce = unwrapExports(lib$1);
var lib_1$1 = lib$1.random;
var lib_2$1 = lib$1.createVerifier;
var lib_3$1 = lib$1.createChallenge;
var lib_4 = lib$1.create;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const env = writable("");
const token$1 = writable("");
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
env.subscribe(val => {
if (val != "") {
store2.set("env", val);
}
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function unique(value, index, self) {
return self.indexOf(value) === index;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function add(data, val) {
const arr = data.split(";");
arr.push(val);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return arr
.filter(unique)
.filter(String)
.join(";");
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function remove(data, val) {
return data
.split(";")
.filter(v => v != val)
.join(";");
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function createAuth() {
const { subscribe, update } = writable("");
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
subscribe,
add: val => update(data => add(data, val)),
remove: val => update(data => remove(data, val))
2019-10-03 04:13:12 +08:00
};
}
2020-05-30 21:19:58 +08:00
const auth = createAuth();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
prism.languages.json = {
property: {
pattern: /"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
greedy: true
},
string: {
pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
greedy: true
},
comment: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
number: /-?\d+\.?\d*(e[+-]?\d+)?/i,
punctuation: /[{}[\],]/,
operator: /:/,
boolean: /\b(?:true|false)\b/,
null: {
pattern: /\bnull\b/,
alias: "keyword"
2019-10-03 04:13:12 +08:00
}
};
2020-05-30 21:19:58 +08:00
const highlight = function(code, lang) {
const supported = ["xml", "json"];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!supported.includes(lang)) {
lang = "markup";
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return prism.highlight(code, prism.languages[lang], lang);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
marked.setOptions({
highlight
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const renderer = new marked.Renderer();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
renderer.pre = renderer.code;
renderer.code = function(code, infostring, escaped) {
const out = this.pre(code, infostring, escaped);
return out.replace("<pre>", `<pre class="language-${infostring}">`);
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
const markdown = function(source) {
return source ? marked(source, { renderer: renderer }) : "";
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const toc = function(source) {
if (!source) {
return [];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const tokens = marked.lexer(source);
const headings = tokens.filter(elem => elem.type === "heading");
const depths = headings.map(head => head.depth);
const minDepth = Math.min(...depths);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return headings.map(head => ({
text: head.text,
level: head.depth - minDepth
}));
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const colorize = function(str, prefix = "is-") {
switch (str) {
case "get":
return `${prefix}success`;
case "post":
return `${prefix}link`;
case "put":
return `${prefix}primary`;
case "patch":
return `${prefix}info`;
case "delete":
return `${prefix}danger`;
case 200:
case 201:
case 202:
case 204:
return `${prefix}info`;
case 401:
case 403:
case 404:
case 422:
return `${prefix}warning`;
case 500:
return `${prefix}danger`;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const slugify = function(str) {
return speakingurl$1(str, "-");
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const alias = str => {
return str && str.match("json") ? "json" : "markup";
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const stringify$2 = obj => {
if (typeof obj === "string") {
return obj;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (obj) {
return JSON.stringify(obj, null, " ");
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
return "";
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
const expandUrl = (uri, obj) => {
const tpl = uritemplate.parse(uri);
return tpl.expand(obj);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const actionFilter = (act, regex) => {
return (
act.path.match(regex) || act.method.match(regex) || act.title.match(regex)
);
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
const filteredItem = (title, key, items) => {
if (items.length === 0) {
return false;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return { title: title, [key]: items };
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function escape$2(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const filterActions = (tagActions, query) => {
if (query.startsWith("g:")) {
const slugs = query.substr(2).split("~");
return tagActions
.map(tag => {
const children = tag.children.filter(child => {
return (
slugify(child.title) === slugs[1] && slugify(tag.title) === slugs[0]
);
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return filteredItem(tag.title, "children", children.filter(Boolean));
})
.filter(Boolean);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (query.startsWith("rg:")) {
return tagActions
.map(tag => {
const children = tag.children.filter(
() => slugify(tag.title) === query.substr(3)
);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return filteredItem(tag.title, "children", children.filter(Boolean));
})
.filter(Boolean);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const regex = new RegExp(escape$2(query), "gi");
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return tagActions
.map(tag => {
const children = tag.children.map(child => {
const actions = child.actions.filter(act => actionFilter(act, regex));
return filteredItem(child.title, "actions", actions);
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return filteredItem(tag.title, "children", children.filter(Boolean));
})
.filter(Boolean);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const tokenStore = store2.namespace("token");
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const setToken = (env, token) => tokenStore.set(env, token);
const getToken = env => tokenStore.get(env);
const removeToken = env => tokenStore.remove(env);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const refreshTokenStore = store2.namespace("refresh-token");
const setRefreshToken = (env, token) => refreshTokenStore.set(env, token);
const getRefreshToken = env => refreshTokenStore.get(env);
const removeRefreshToken = env => refreshTokenStore.remove(env);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const isAuth = (environment, name) => {
return environment.auth && environment.auth.name === name;
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
const isPKCE = environment => {
if (isAuth(environment, "oauth2")) {
return environment.auth.options.clientSecret === undefined;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return false;
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
const requestToken = async (client, options) => {
const authRequest = src.client(client, options);
const authCode = await authRequest();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (typeof authCode === "string") {
const authParsed = querystringify_1.parse(authCode);
return {
accessToken: authParsed.access_token,
refreshToken: authParsed.refresh_token
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
accessToken: authCode.access_token,
refreshToken: authCode.refresh_token
};
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const exchangeToken = async (code, options, isPKCE, pkceChallenge) => {
if (isPKCE) {
return requestToken(axios$1.create(), {
url: options.tokenUrl,
grant_type: "authorization_code",
state: getState(),
client_id: options.clientId,
redirect_uri: options.callbackUrl,
code: code,
code_verifier: pkceChallenge.codeVerifier
});
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return requestToken(axios$1.create(), {
url: options.tokenUrl,
grant_type: "authorization_code",
state: getState(),
client_id: options.clientId,
client_secret: options.clientSecret,
redirect_uri: options.callbackUrl,
code: code
});
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const populate = arr => {
return arr
.filter(Boolean)
.filter(obj => obj.used)
.reduce((prev, cur) => {
prev[cur.name] = cur.value;
return prev;
}, {});
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const allowBody = action => {
return ["put", "post", "patch"].includes(action.method);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const refreshInterceptor = (env, options) => {
const refreshToken = getRefreshToken(env);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return async failedRequest => {
const {
accessToken: newAccessToken,
refreshToken: newRefreshToken
} = await requestToken(axios$1, {
url: options.tokenUrl,
grant_type: "refresh_token",
state: getState(),
client_id: options.clientId,
client_secret: options.clientSecret,
refresh_token: refreshToken
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (newAccessToken) {
token$1.set(newAccessToken);
setToken(env, newAccessToken);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (newRefreshToken) {
setRefreshToken(env, newRefreshToken);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
failedRequest.response.config.headers[
"Authorization"
] = `Bearer ${newAccessToken}`;
};
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
const sendRequest = (
env,
environment,
action,
{ headers, parameters, body }
) => {
const client = axios$1.create({
baseURL: environment.url
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const options = {
method: action.method,
headers: populate(headers)
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const expandedUrl = expandUrl(action.pathTemplate, populate(parameters));
const destUrl = urlParse(expandedUrl, true);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
options.params = destUrl.query;
options.url = destUrl.pathname;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (allowBody(action)) {
options.data = body;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (isAuth(environment, "oauth2")) {
createAuthRefreshInterceptor(
client,
refreshInterceptor(env, environment.auth.options)
);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return client.request(options);
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
const copyUrl = (url, parameters) => {
const expandedUrl = expandUrl(url.pathname, populate(parameters));
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
clipboardCopy_1(url.origin + expandedUrl);
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
const getEnv = () => store2.get("env");
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const pkceStore = store2.namespace("pkce");
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const getPKCE = () => {
const existing = pkceStore.getAll();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (Object.keys(existing).length === 0) {
const challengePair = pkce.create();
pkceStore.setAll(challengePair);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return challengePair;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return existing;
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const getState = () => {
const existing = store2.get("state");
if (existing) return existing;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const state = pkce.random(16);
store2.set("state", state);
return state;
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
const clearPKCE = () => pkceStore.clear();
const clearState = () => store2.remove("state");
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const buildHref = path => {
const pathname = window.location.pathname;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!path) {
return pathname;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return `${pathname}${path}`.replace("//", "/");
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
const handleLink = event => {
const pathname = window.location.pathname;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
let href = event.target.getAttribute("href");
if (!href) {
href = event.target.parentElement.getAttribute("href");
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const cleanHref = href.replace(pathname, "");
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
navigateTo(cleanHref);
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
/* usr/local/lib/node_modules/snowboard/templates/winter/pages/Home.svelte generated by Svelte v3.19.2 */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function create_fragment$3(ctx) {
let h1;
let t0;
let t1;
let div;
let raw_value = markdown(/*description*/ ctx[1]) + "";
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
h1 = element("h1");
t0 = text(/*title*/ ctx[0]);
t1 = space();
div = element("div");
attr(h1, "class", "title");
attr(div, "class", "content");
},
m(target, anchor) {
insert(target, h1, anchor);
append(h1, t0);
insert(target, t1, anchor);
insert(target, div, anchor);
div.innerHTML = raw_value;
},
p(ctx, [dirty]) {
if (dirty & /*title*/ 1) set_data(t0, /*title*/ ctx[0]);
if (dirty & /*description*/ 2 && raw_value !== (raw_value = markdown(/*description*/ ctx[1]) + "")) div.innerHTML = raw_value;;
},
i: noop,
o: noop,
d(detaching) {
if (detaching) detach(h1);
if (detaching) detach(t1);
if (detaching) detach(div);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function instance$3($$self, $$props, $$invalidate) {
let { title } = $$props;
let { description } = $$props;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$set = $$props => {
if ("title" in $$props) $$invalidate(0, title = $$props.title);
if ("description" in $$props) $$invalidate(1, description = $$props.description);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return [title, description];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
class Home extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance$3, create_fragment$3, safe_not_equal, { title: 0, description: 1 });
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var uint32 = createCommonjsModule(function (module) {
/**
C-like unsigned 32 bits integers in Javascript
Copyright (C) 2013, Pierre Curto
MIT license
*/
;(function (root) {
// Local cache for typical radices
var radixPowerCache = {
36: UINT32( Math.pow(36, 5) )
, 16: UINT32( Math.pow(16, 7) )
, 10: UINT32( Math.pow(10, 9) )
, 2: UINT32( Math.pow(2, 30) )
};
var radixCache = {
36: UINT32(36)
, 16: UINT32(16)
, 10: UINT32(10)
, 2: UINT32(2)
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Represents an unsigned 32 bits integer
* @constructor
* @param {Number|String|Number} low bits | integer as a string | integer as a number
* @param {Number|Number|Undefined} high bits | radix (optional, default=10)
* @return
*/
function UINT32 (l, h) {
if ( !(this instanceof UINT32) )
return new UINT32(l, h)
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
this._low = 0;
this._high = 0;
this.remainder = null;
if (typeof h == 'undefined')
return fromNumber.call(this, l)
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (typeof l == 'string')
return fromString.call(this, l, h)
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
fromBits.call(this, l, h);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Set the current _UINT32_ object with its low and high bits
* @method fromBits
* @param {Number} low bits
* @param {Number} high bits
* @return ThisExpression
*/
function fromBits (l, h) {
this._low = l | 0;
this._high = h | 0;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
}
UINT32.prototype.fromBits = fromBits;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Set the current _UINT32_ object from a number
* @method fromNumber
* @param {Number} number
* @return ThisExpression
*/
function fromNumber (value) {
this._low = value & 0xFFFF;
this._high = value >>> 16;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
}
UINT32.prototype.fromNumber = fromNumber;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Set the current _UINT32_ object from a string
* @method fromString
* @param {String} integer as a string
* @param {Number} radix (optional, default=10)
* @return ThisExpression
*/
function fromString (s, radix) {
var value = parseInt(s, radix || 10);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
this._low = value & 0xFFFF;
this._high = value >>> 16;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
}
UINT32.prototype.fromString = fromString;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Convert this _UINT32_ to a number
* @method toNumber
* @return {Number} the converted UINT32
*/
UINT32.prototype.toNumber = function () {
return (this._high * 65536) + this._low
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Convert this _UINT32_ to a string
* @method toString
* @param {Number} radix (optional, default=10)
* @return {String} the converted UINT32
*/
UINT32.prototype.toString = function (radix) {
return this.toNumber().toString(radix || 10)
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Add two _UINT32_. The current _UINT32_ stores the result
* @method add
* @param {Object} other UINT32
* @return ThisExpression
*/
UINT32.prototype.add = function (other) {
var a00 = this._low + other._low;
var a16 = a00 >>> 16;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
a16 += this._high + other._high;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
this._low = a00 & 0xFFFF;
this._high = a16 & 0xFFFF;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Subtract two _UINT32_. The current _UINT32_ stores the result
* @method subtract
* @param {Object} other UINT32
* @return ThisExpression
*/
UINT32.prototype.subtract = function (other) {
//TODO inline
return this.add( other.clone().negate() )
};
/**
* Multiply two _UINT32_. The current _UINT32_ stores the result
* @method multiply
* @param {Object} other UINT32
* @return ThisExpression
*/
UINT32.prototype.multiply = function (other) {
/*
a = a00 + a16
b = b00 + b16
a*b = (a00 + a16)(b00 + b16)
= a00b00 + a00b16 + a16b00 + a16b16
a16b16 overflows the 32bits
*/
var a16 = this._high;
var a00 = this._low;
var b16 = other._high;
var b00 = other._low;
/* Removed to increase speed under normal circumstances (i.e. not multiplying by 0 or 1)
// this == 0 or other == 1: nothing to do
if ((a00 == 0 && a16 == 0) || (b00 == 1 && b16 == 0)) return this
// other == 0 or this == 1: this = other
if ((b00 == 0 && b16 == 0) || (a00 == 1 && a16 == 0)) {
this._low = other._low
this._high = other._high
return this
}
*/
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var c16, c00;
c00 = a00 * b00;
c16 = c00 >>> 16;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
c16 += a16 * b00;
c16 &= 0xFFFF; // Not required but improves performance
c16 += a00 * b16;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
this._low = c00 & 0xFFFF;
this._high = c16 & 0xFFFF;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Divide two _UINT32_. The current _UINT32_ stores the result.
* The remainder is made available as the _remainder_ property on
* the _UINT32_ object. It can be null, meaning there are no remainder.
* @method div
* @param {Object} other UINT32
* @return ThisExpression
*/
UINT32.prototype.div = function (other) {
if ( (other._low == 0) && (other._high == 0) ) throw Error('division by zero')
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// other == 1
if (other._high == 0 && other._low == 1) {
this.remainder = new UINT32(0);
return this
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// other > this: 0
if ( other.gt(this) ) {
this.remainder = this.clone();
this._low = 0;
this._high = 0;
return this
}
// other == this: 1
if ( this.eq(other) ) {
this.remainder = new UINT32(0);
this._low = 1;
this._high = 0;
return this
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Shift the divisor left until it is higher than the dividend
var _other = other.clone();
var i = -1;
while ( !this.lt(_other) ) {
// High bit can overflow the default 16bits
// Its ok since we right shift after this loop
// The overflown bit must be kept though
_other.shiftLeft(1, true);
i++;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Set the remainder
this.remainder = this.clone();
// Initialize the current result to 0
this._low = 0;
this._high = 0;
for (; i >= 0; i--) {
_other.shiftRight(1);
// If shifted divisor is smaller than the dividend
// then subtract it from the dividend
if ( !this.remainder.lt(_other) ) {
this.remainder.subtract(_other);
// Update the current result
if (i >= 16) {
this._high |= 1 << (i - 16);
} else {
this._low |= 1 << i;
}
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Negate the current _UINT32_
* @method negate
* @return ThisExpression
*/
UINT32.prototype.negate = function () {
var v = ( ~this._low & 0xFFFF ) + 1;
this._low = v & 0xFFFF;
this._high = (~this._high + (v >>> 16)) & 0xFFFF;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Equals
* @method eq
* @param {Object} other UINT32
* @return {Boolean}
*/
UINT32.prototype.equals = UINT32.prototype.eq = function (other) {
return (this._low == other._low) && (this._high == other._high)
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Greater than (strict)
* @method gt
* @param {Object} other UINT32
* @return {Boolean}
*/
UINT32.prototype.greaterThan = UINT32.prototype.gt = function (other) {
if (this._high > other._high) return true
if (this._high < other._high) return false
return this._low > other._low
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Less than (strict)
* @method lt
* @param {Object} other UINT32
* @return {Boolean}
*/
UINT32.prototype.lessThan = UINT32.prototype.lt = function (other) {
if (this._high < other._high) return true
if (this._high > other._high) return false
return this._low < other._low
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Bitwise OR
* @method or
* @param {Object} other UINT32
* @return ThisExpression
*/
UINT32.prototype.or = function (other) {
this._low |= other._low;
this._high |= other._high;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Bitwise AND
* @method and
* @param {Object} other UINT32
* @return ThisExpression
*/
UINT32.prototype.and = function (other) {
this._low &= other._low;
this._high &= other._high;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Bitwise NOT
* @method not
* @return ThisExpression
*/
UINT32.prototype.not = function() {
this._low = ~this._low & 0xFFFF;
this._high = ~this._high & 0xFFFF;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Bitwise XOR
* @method xor
* @param {Object} other UINT32
* @return ThisExpression
*/
UINT32.prototype.xor = function (other) {
this._low ^= other._low;
this._high ^= other._high;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Bitwise shift right
* @method shiftRight
* @param {Number} number of bits to shift
* @return ThisExpression
*/
UINT32.prototype.shiftRight = UINT32.prototype.shiftr = function (n) {
if (n > 16) {
this._low = this._high >> (n - 16);
this._high = 0;
} else if (n == 16) {
this._low = this._high;
this._high = 0;
} else {
this._low = (this._low >> n) | ( (this._high << (16-n)) & 0xFFFF );
this._high >>= n;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Bitwise shift left
* @method shiftLeft
* @param {Number} number of bits to shift
* @param {Boolean} allow overflow
* @return ThisExpression
*/
UINT32.prototype.shiftLeft = UINT32.prototype.shiftl = function (n, allowOverflow) {
if (n > 16) {
this._high = this._low << (n - 16);
this._low = 0;
if (!allowOverflow) {
this._high &= 0xFFFF;
}
} else if (n == 16) {
this._high = this._low;
this._low = 0;
} else {
this._high = (this._high << n) | (this._low >> (16-n));
this._low = (this._low << n) & 0xFFFF;
if (!allowOverflow) {
// Overflow only allowed on the high bits...
this._high &= 0xFFFF;
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Bitwise rotate left
* @method rotl
* @param {Number} number of bits to rotate
* @return ThisExpression
*/
UINT32.prototype.rotateLeft = UINT32.prototype.rotl = function (n) {
var v = (this._high << 16) | this._low;
v = (v << n) | (v >>> (32 - n));
this._low = v & 0xFFFF;
this._high = v >>> 16;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Bitwise rotate right
* @method rotr
* @param {Number} number of bits to rotate
* @return ThisExpression
*/
UINT32.prototype.rotateRight = UINT32.prototype.rotr = function (n) {
var v = (this._high << 16) | this._low;
v = (v >>> n) | (v << (32 - n));
this._low = v & 0xFFFF;
this._high = v >>> 16;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Clone the current _UINT32_
* @method clone
* @return {Object} cloned UINT32
*/
UINT32.prototype.clone = function () {
return new UINT32(this._low, this._high)
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (typeof undefined != 'undefined' && undefined.amd) {
// AMD / RequireJS
undefined([], function () {
return UINT32
});
} else if ('object' != 'undefined' && module.exports) {
// Node.js
module.exports = UINT32;
} else {
// Browser
root['UINT32'] = UINT32;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
})(commonjsGlobal);
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var uint64 = createCommonjsModule(function (module) {
/**
C-like unsigned 64 bits integers in Javascript
Copyright (C) 2013, Pierre Curto
MIT license
*/
;(function (root) {
// Local cache for typical radices
var radixPowerCache = {
16: UINT64( Math.pow(16, 5) )
, 10: UINT64( Math.pow(10, 5) )
, 2: UINT64( Math.pow(2, 5) )
};
var radixCache = {
16: UINT64(16)
, 10: UINT64(10)
, 2: UINT64(2)
};
/**
* Represents an unsigned 64 bits integer
* @constructor
* @param {Number} first low bits (8)
* @param {Number} second low bits (8)
* @param {Number} first high bits (8)
* @param {Number} second high bits (8)
* or
* @param {Number} low bits (32)
* @param {Number} high bits (32)
* or
* @param {String|Number} integer as a string | integer as a number
* @param {Number|Undefined} radix (optional, default=10)
* @return
*/
function UINT64 (a00, a16, a32, a48) {
if ( !(this instanceof UINT64) )
return new UINT64(a00, a16, a32, a48)
this.remainder = null;
if (typeof a00 == 'string')
return fromString.call(this, a00, a16)
if (typeof a16 == 'undefined')
return fromNumber.call(this, a00)
fromBits.apply(this, arguments);
}
/**
* Set the current _UINT64_ object with its low and high bits
* @method fromBits
* @param {Number} first low bits (8)
* @param {Number} second low bits (8)
* @param {Number} first high bits (8)
* @param {Number} second high bits (8)
* or
* @param {Number} low bits (32)
* @param {Number} high bits (32)
* @return ThisExpression
*/
function fromBits (a00, a16, a32, a48) {
if (typeof a32 == 'undefined') {
this._a00 = a00 & 0xFFFF;
this._a16 = a00 >>> 16;
this._a32 = a16 & 0xFFFF;
this._a48 = a16 >>> 16;
return this
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
this._a00 = a00 | 0;
this._a16 = a16 | 0;
this._a32 = a32 | 0;
this._a48 = a48 | 0;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
}
UINT64.prototype.fromBits = fromBits;
2020-05-30 21:19:58 +08:00
/**
* Set the current _UINT64_ object from a number
* @method fromNumber
* @param {Number} number
* @return ThisExpression
*/
function fromNumber (value) {
this._a00 = value & 0xFFFF;
this._a16 = value >>> 16;
this._a32 = 0;
this._a48 = 0;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
}
UINT64.prototype.fromNumber = fromNumber;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Set the current _UINT64_ object from a string
* @method fromString
* @param {String} integer as a string
* @param {Number} radix (optional, default=10)
* @return ThisExpression
*/
function fromString (s, radix) {
radix = radix || 10;
this._a00 = 0;
this._a16 = 0;
this._a32 = 0;
this._a48 = 0;
/*
In Javascript, bitwise operators only operate on the first 32 bits
of a number, even though parseInt() encodes numbers with a 53 bits
mantissa.
Therefore UINT64(<Number>) can only work on 32 bits.
The radix maximum value is 36 (as per ECMA specs) (26 letters + 10 digits)
maximum input value is m = 32bits as 1 = 2^32 - 1
So the maximum substring length n is:
36^(n+1) - 1 = 2^32 - 1
36^(n+1) = 2^32
(n+1)ln(36) = 32ln(2)
n = 32ln(2)/ln(36) - 1
n = 5.189644915687692
n = 5
*/
var radixUint = radixPowerCache[radix] || new UINT64( Math.pow(radix, 5) );
for (var i = 0, len = s.length; i < len; i += 5) {
var size = Math.min(5, len - i);
var value = parseInt( s.slice(i, i + size), radix );
this.multiply(
size < 5
? new UINT64( Math.pow(radix, size) )
: radixUint
)
.add( new UINT64(value) );
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
}
UINT64.prototype.fromString = fromString;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Convert this _UINT64_ to a number (last 32 bits are dropped)
* @method toNumber
* @return {Number} the converted UINT64
*/
UINT64.prototype.toNumber = function () {
return (this._a16 * 65536) + this._a00
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Convert this _UINT64_ to a string
* @method toString
* @param {Number} radix (optional, default=10)
* @return {String} the converted UINT64
*/
UINT64.prototype.toString = function (radix) {
radix = radix || 10;
var radixUint = radixCache[radix] || new UINT64(radix);
if ( !this.gt(radixUint) ) return this.toNumber().toString(radix)
var self = this.clone();
var res = new Array(64);
for (var i = 63; i >= 0; i--) {
self.div(radixUint);
res[i] = self.remainder.toNumber().toString(radix);
if ( !self.gt(radixUint) ) break
}
res[i-1] = self.toNumber().toString(radix);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return res.join('')
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Add two _UINT64_. The current _UINT64_ stores the result
* @method add
* @param {Object} other UINT64
* @return ThisExpression
*/
UINT64.prototype.add = function (other) {
var a00 = this._a00 + other._a00;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var a16 = a00 >>> 16;
a16 += this._a16 + other._a16;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var a32 = a16 >>> 16;
a32 += this._a32 + other._a32;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var a48 = a32 >>> 16;
a48 += this._a48 + other._a48;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
this._a00 = a00 & 0xFFFF;
this._a16 = a16 & 0xFFFF;
this._a32 = a32 & 0xFFFF;
this._a48 = a48 & 0xFFFF;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Subtract two _UINT64_. The current _UINT64_ stores the result
* @method subtract
* @param {Object} other UINT64
* @return ThisExpression
*/
UINT64.prototype.subtract = function (other) {
return this.add( other.clone().negate() )
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Multiply two _UINT64_. The current _UINT64_ stores the result
* @method multiply
* @param {Object} other UINT64
* @return ThisExpression
*/
UINT64.prototype.multiply = function (other) {
/*
a = a00 + a16 + a32 + a48
b = b00 + b16 + b32 + b48
a*b = (a00 + a16 + a32 + a48)(b00 + b16 + b32 + b48)
= a00b00 + a00b16 + a00b32 + a00b48
+ a16b00 + a16b16 + a16b32 + a16b48
+ a32b00 + a32b16 + a32b32 + a32b48
+ a48b00 + a48b16 + a48b32 + a48b48
a16b48, a32b32, a48b16, a48b32 and a48b48 overflow the 64 bits
so it comes down to:
a*b = a00b00 + a00b16 + a00b32 + a00b48
+ a16b00 + a16b16 + a16b32
+ a32b00 + a32b16
+ a48b00
= a00b00
+ a00b16 + a16b00
+ a00b32 + a16b16 + a32b00
+ a00b48 + a16b32 + a32b16 + a48b00
*/
var a00 = this._a00;
var a16 = this._a16;
var a32 = this._a32;
var a48 = this._a48;
var b00 = other._a00;
var b16 = other._a16;
var b32 = other._a32;
var b48 = other._a48;
var c00 = a00 * b00;
var c16 = c00 >>> 16;
c16 += a00 * b16;
var c32 = c16 >>> 16;
c16 &= 0xFFFF;
c16 += a16 * b00;
c32 += c16 >>> 16;
c32 += a00 * b32;
var c48 = c32 >>> 16;
c32 &= 0xFFFF;
c32 += a16 * b16;
c48 += c32 >>> 16;
c32 &= 0xFFFF;
c32 += a32 * b00;
c48 += c32 >>> 16;
c48 += a00 * b48;
c48 &= 0xFFFF;
c48 += a16 * b32;
c48 &= 0xFFFF;
c48 += a32 * b16;
c48 &= 0xFFFF;
c48 += a48 * b00;
this._a00 = c00 & 0xFFFF;
this._a16 = c16 & 0xFFFF;
this._a32 = c32 & 0xFFFF;
this._a48 = c48 & 0xFFFF;
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Divide two _UINT64_. The current _UINT64_ stores the result.
* The remainder is made available as the _remainder_ property on
* the _UINT64_ object. It can be null, meaning there are no remainder.
* @method div
* @param {Object} other UINT64
* @return ThisExpression
*/
UINT64.prototype.div = function (other) {
if ( (other._a16 == 0) && (other._a32 == 0) && (other._a48 == 0) ) {
if (other._a00 == 0) throw Error('division by zero')
// other == 1: this
if (other._a00 == 1) {
this.remainder = new UINT64(0);
return this
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// other > this: 0
if ( other.gt(this) ) {
this.remainder = this.clone();
this._a00 = 0;
this._a16 = 0;
this._a32 = 0;
this._a48 = 0;
return this
}
// other == this: 1
if ( this.eq(other) ) {
this.remainder = new UINT64(0);
this._a00 = 1;
this._a16 = 0;
this._a32 = 0;
this._a48 = 0;
return this
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Shift the divisor left until it is higher than the dividend
var _other = other.clone();
var i = -1;
while ( !this.lt(_other) ) {
// High bit can overflow the default 16bits
// Its ok since we right shift after this loop
// The overflown bit must be kept though
_other.shiftLeft(1, true);
i++;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Set the remainder
this.remainder = this.clone();
// Initialize the current result to 0
this._a00 = 0;
this._a16 = 0;
this._a32 = 0;
this._a48 = 0;
for (; i >= 0; i--) {
_other.shiftRight(1);
// If shifted divisor is smaller than the dividend
// then subtract it from the dividend
if ( !this.remainder.lt(_other) ) {
this.remainder.subtract(_other);
// Update the current result
if (i >= 48) {
this._a48 |= 1 << (i - 48);
} else if (i >= 32) {
this._a32 |= 1 << (i - 32);
} else if (i >= 16) {
this._a16 |= 1 << (i - 16);
} else {
this._a00 |= 1 << i;
}
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Negate the current _UINT64_
* @method negate
* @return ThisExpression
*/
UINT64.prototype.negate = function () {
var v = ( ~this._a00 & 0xFFFF ) + 1;
this._a00 = v & 0xFFFF;
v = (~this._a16 & 0xFFFF) + (v >>> 16);
this._a16 = v & 0xFFFF;
v = (~this._a32 & 0xFFFF) + (v >>> 16);
this._a32 = v & 0xFFFF;
this._a48 = (~this._a48 + (v >>> 16)) & 0xFFFF;
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
* @method eq
* @param {Object} other UINT64
* @return {Boolean}
*/
UINT64.prototype.equals = UINT64.prototype.eq = function (other) {
return (this._a48 == other._a48) && (this._a00 == other._a00)
&& (this._a32 == other._a32) && (this._a16 == other._a16)
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Greater than (strict)
* @method gt
* @param {Object} other UINT64
* @return {Boolean}
*/
UINT64.prototype.greaterThan = UINT64.prototype.gt = function (other) {
if (this._a48 > other._a48) return true
if (this._a48 < other._a48) return false
if (this._a32 > other._a32) return true
if (this._a32 < other._a32) return false
if (this._a16 > other._a16) return true
if (this._a16 < other._a16) return false
return this._a00 > other._a00
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Less than (strict)
* @method lt
* @param {Object} other UINT64
* @return {Boolean}
*/
UINT64.prototype.lessThan = UINT64.prototype.lt = function (other) {
if (this._a48 < other._a48) return true
if (this._a48 > other._a48) return false
if (this._a32 < other._a32) return true
if (this._a32 > other._a32) return false
if (this._a16 < other._a16) return true
if (this._a16 > other._a16) return false
return this._a00 < other._a00
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Bitwise OR
* @method or
* @param {Object} other UINT64
* @return ThisExpression
*/
UINT64.prototype.or = function (other) {
this._a00 |= other._a00;
this._a16 |= other._a16;
this._a32 |= other._a32;
this._a48 |= other._a48;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Bitwise AND
* @method and
* @param {Object} other UINT64
* @return ThisExpression
*/
UINT64.prototype.and = function (other) {
this._a00 &= other._a00;
this._a16 &= other._a16;
this._a32 &= other._a32;
this._a48 &= other._a48;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Bitwise XOR
* @method xor
* @param {Object} other UINT64
* @return ThisExpression
*/
UINT64.prototype.xor = function (other) {
this._a00 ^= other._a00;
this._a16 ^= other._a16;
this._a32 ^= other._a32;
this._a48 ^= other._a48;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Bitwise NOT
* @method not
* @return ThisExpression
*/
UINT64.prototype.not = function() {
this._a00 = ~this._a00 & 0xFFFF;
this._a16 = ~this._a16 & 0xFFFF;
this._a32 = ~this._a32 & 0xFFFF;
this._a48 = ~this._a48 & 0xFFFF;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Bitwise shift right
* @method shiftRight
* @param {Number} number of bits to shift
* @return ThisExpression
*/
UINT64.prototype.shiftRight = UINT64.prototype.shiftr = function (n) {
n %= 64;
if (n >= 48) {
this._a00 = this._a48 >> (n - 48);
this._a16 = 0;
this._a32 = 0;
this._a48 = 0;
} else if (n >= 32) {
n -= 32;
this._a00 = ( (this._a32 >> n) | (this._a48 << (16-n)) ) & 0xFFFF;
this._a16 = (this._a48 >> n) & 0xFFFF;
this._a32 = 0;
this._a48 = 0;
} else if (n >= 16) {
n -= 16;
this._a00 = ( (this._a16 >> n) | (this._a32 << (16-n)) ) & 0xFFFF;
this._a16 = ( (this._a32 >> n) | (this._a48 << (16-n)) ) & 0xFFFF;
this._a32 = (this._a48 >> n) & 0xFFFF;
this._a48 = 0;
} else {
this._a00 = ( (this._a00 >> n) | (this._a16 << (16-n)) ) & 0xFFFF;
this._a16 = ( (this._a16 >> n) | (this._a32 << (16-n)) ) & 0xFFFF;
this._a32 = ( (this._a32 >> n) | (this._a48 << (16-n)) ) & 0xFFFF;
this._a48 = (this._a48 >> n) & 0xFFFF;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Bitwise shift left
* @method shiftLeft
* @param {Number} number of bits to shift
* @param {Boolean} allow overflow
* @return ThisExpression
*/
UINT64.prototype.shiftLeft = UINT64.prototype.shiftl = function (n, allowOverflow) {
n %= 64;
if (n >= 48) {
this._a48 = this._a00 << (n - 48);
this._a32 = 0;
this._a16 = 0;
this._a00 = 0;
} else if (n >= 32) {
n -= 32;
this._a48 = (this._a16 << n) | (this._a00 >> (16-n));
this._a32 = (this._a00 << n) & 0xFFFF;
this._a16 = 0;
this._a00 = 0;
} else if (n >= 16) {
n -= 16;
this._a48 = (this._a32 << n) | (this._a16 >> (16-n));
this._a32 = ( (this._a16 << n) | (this._a00 >> (16-n)) ) & 0xFFFF;
this._a16 = (this._a00 << n) & 0xFFFF;
this._a00 = 0;
} else {
this._a48 = (this._a48 << n) | (this._a32 >> (16-n));
this._a32 = ( (this._a32 << n) | (this._a16 >> (16-n)) ) & 0xFFFF;
this._a16 = ( (this._a16 << n) | (this._a00 >> (16-n)) ) & 0xFFFF;
this._a00 = (this._a00 << n) & 0xFFFF;
}
if (!allowOverflow) {
this._a48 &= 0xFFFF;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Bitwise rotate left
* @method rotl
* @param {Number} number of bits to rotate
* @return ThisExpression
*/
UINT64.prototype.rotateLeft = UINT64.prototype.rotl = function (n) {
n %= 64;
if (n == 0) return this
if (n >= 32) {
// A.B.C.D
// B.C.D.A rotl(16)
// C.D.A.B rotl(32)
var v = this._a00;
this._a00 = this._a32;
this._a32 = v;
v = this._a48;
this._a48 = this._a16;
this._a16 = v;
if (n == 32) return this
n -= 32;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var high = (this._a48 << 16) | this._a32;
var low = (this._a16 << 16) | this._a00;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var _high = (high << n) | (low >>> (32 - n));
var _low = (low << n) | (high >>> (32 - n));
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
this._a00 = _low & 0xFFFF;
this._a16 = _low >>> 16;
this._a32 = _high & 0xFFFF;
this._a48 = _high >>> 16;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Bitwise rotate right
* @method rotr
* @param {Number} number of bits to rotate
* @return ThisExpression
*/
UINT64.prototype.rotateRight = UINT64.prototype.rotr = function (n) {
n %= 64;
if (n == 0) return this
if (n >= 32) {
// A.B.C.D
// D.A.B.C rotr(16)
// C.D.A.B rotr(32)
var v = this._a00;
this._a00 = this._a32;
this._a32 = v;
v = this._a48;
this._a48 = this._a16;
this._a16 = v;
if (n == 32) return this
n -= 32;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var high = (this._a48 << 16) | this._a32;
var low = (this._a16 << 16) | this._a00;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var _high = (high >>> n) | (low << (32 - n));
var _low = (low >>> n) | (high << (32 - n));
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
this._a00 = _low & 0xFFFF;
this._a16 = _low >>> 16;
this._a32 = _high & 0xFFFF;
this._a48 = _high >>> 16;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Clone the current _UINT64_
* @method clone
* @return {Object} cloned UINT64
*/
UINT64.prototype.clone = function () {
return new UINT64(this._a00, this._a16, this._a32, this._a48)
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (typeof undefined != 'undefined' && undefined.amd) {
// AMD / RequireJS
undefined([], function () {
return UINT64
});
} else if ('object' != 'undefined' && module.exports) {
// Node.js
module.exports = UINT64;
} else {
// Browser
root['UINT64'] = UINT64;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
})(commonjsGlobal);
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var UINT32 = uint32;
var UINT64 = uint64;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var cuint = {
UINT32: UINT32,
UINT64: UINT64
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
/**
xxHash implementation in pure Javascript
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Copyright (C) 2013, Pierre Curto
MIT license
*/
var UINT32$1 = cuint.UINT32;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/*
Merged this sequence of method calls as it speeds up
the calculations by a factor of 2
2019-10-03 04:13:12 +08:00
*/
2020-05-30 21:19:58 +08:00
// this.v1.add( other.multiply(PRIME32_2) ).rotl(13).multiply(PRIME32_1);
UINT32$1.prototype.xxh_update = function (low, high) {
var b00 = PRIME32_2._low;
var b16 = PRIME32_2._high;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var c16, c00;
c00 = low * b00;
c16 = c00 >>> 16;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
c16 += high * b00;
c16 &= 0xFFFF; // Not required but improves performance
c16 += low * b16;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var a00 = this._low + (c00 & 0xFFFF);
var a16 = a00 >>> 16;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
a16 += this._high + (c16 & 0xFFFF);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var v = (a16 << 16) | (a00 & 0xFFFF);
v = (v << 13) | (v >>> 19);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
a00 = v & 0xFFFF;
a16 = v >>> 16;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
b00 = PRIME32_1._low;
b16 = PRIME32_1._high;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
c00 = a00 * b00;
c16 = c00 >>> 16;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
c16 += a16 * b00;
c16 &= 0xFFFF; // Not required but improves performance
c16 += a00 * b16;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
this._low = c00 & 0xFFFF;
this._high = c16 & 0xFFFF;
};
/*
* Constants
2019-10-03 04:13:12 +08:00
*/
2020-05-30 21:19:58 +08:00
var PRIME32_1 = UINT32$1( '2654435761' );
var PRIME32_2 = UINT32$1( '2246822519' );
var PRIME32_3 = UINT32$1( '3266489917' );
var PRIME32_4 = UINT32$1( '668265263' );
var PRIME32_5 = UINT32$1( '374761393' );
2019-10-03 04:13:12 +08:00
/**
2020-05-30 21:19:58 +08:00
* Convert string to proper UTF-8 array
* @param str Input string
* @returns {Uint8Array} UTF8 array is returned as uint8 array
*/
function toUTF8Array (str) {
var utf8 = [];
for (var i=0, n=str.length; i < n; i++) {
var charcode = str.charCodeAt(i);
if (charcode < 0x80) utf8.push(charcode);
else if (charcode < 0x800) {
utf8.push(0xc0 | (charcode >> 6),
0x80 | (charcode & 0x3f));
}
else if (charcode < 0xd800 || charcode >= 0xe000) {
utf8.push(0xe0 | (charcode >> 12),
0x80 | ((charcode>>6) & 0x3f),
0x80 | (charcode & 0x3f));
}
// surrogate pair
else {
i++;
// UTF-16 encodes 0x10000-0x10FFFF by
// subtracting 0x10000 and splitting the
// 20 bits of 0x0-0xFFFFF into two halves
charcode = 0x10000 + (((charcode & 0x3ff)<<10)
| (str.charCodeAt(i) & 0x3ff));
utf8.push(0xf0 | (charcode >>18),
0x80 | ((charcode>>12) & 0x3f),
0x80 | ((charcode>>6) & 0x3f),
0x80 | (charcode & 0x3f));
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return new Uint8Array(utf8)
2019-10-03 04:13:12 +08:00
}
/**
2020-05-30 21:19:58 +08:00
* XXH object used as a constructor or a function
* @constructor
* or
* @param {Object|String} input data
* @param {Number|UINT32} seed
* @return ThisExpression
* or
* @return {UINT32} xxHash
2019-10-03 04:13:12 +08:00
*/
2020-05-30 21:19:58 +08:00
function XXH () {
if (arguments.length == 2)
return new XXH( arguments[1] ).update( arguments[0] ).digest()
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!(this instanceof XXH))
return new XXH( arguments[0] )
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
init$1.call(this, arguments[0]);
2019-10-03 04:13:12 +08:00
}
/**
2020-05-30 21:19:58 +08:00
* Initialize the XXH instance with the given seed
* @method init
* @param {Number|Object} seed as a number or an unsigned 32 bits integer
* @return ThisExpression
2019-10-03 04:13:12 +08:00
*/
2020-05-30 21:19:58 +08:00
function init$1 (seed) {
this.seed = seed instanceof UINT32$1 ? seed.clone() : UINT32$1(seed);
this.v1 = this.seed.clone().add(PRIME32_1).add(PRIME32_2);
this.v2 = this.seed.clone().add(PRIME32_2);
this.v3 = this.seed.clone();
this.v4 = this.seed.clone().subtract(PRIME32_1);
this.total_len = 0;
this.memsize = 0;
this.memory = null;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
}
XXH.prototype.init = init$1;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Add data to be computed for the XXH hash
* @method update
* @param {String|Buffer|ArrayBuffer} input as a string or nodejs Buffer or ArrayBuffer
* @return ThisExpression
*/
XXH.prototype.update = function (input) {
var isString = typeof input == 'string';
var isArrayBuffer;
// Convert all strings to utf-8 first (issue #5)
if (isString) {
input = toUTF8Array(input);
isString = false;
isArrayBuffer = true;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (typeof ArrayBuffer !== "undefined" && input instanceof ArrayBuffer)
{
isArrayBuffer = true;
input = new Uint8Array(input);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var p = 0;
var len = input.length;
var bEnd = p + len;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (len == 0) return this
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
this.total_len += len;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (this.memsize == 0)
{
if (isString) {
this.memory = '';
} else if (isArrayBuffer) {
this.memory = new Uint8Array(16);
} else {
this.memory = new Buffer(16);
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (this.memsize + len < 16) // fill in tmp buffer
{
// XXH_memcpy(this.memory + this.memsize, input, len)
if (isString) {
this.memory += input;
} else if (isArrayBuffer) {
this.memory.set( input.subarray(0, len), this.memsize );
} else {
input.copy( this.memory, this.memsize, 0, len );
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
this.memsize += len;
return this
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (this.memsize > 0) // some data left from previous update
{
// XXH_memcpy(this.memory + this.memsize, input, 16-this.memsize);
if (isString) {
this.memory += input.slice(0, 16 - this.memsize);
} else if (isArrayBuffer) {
this.memory.set( input.subarray(0, 16 - this.memsize), this.memsize );
} else {
input.copy( this.memory, this.memsize, 0, 16 - this.memsize );
}
var p32 = 0;
if (isString) {
this.v1.xxh_update(
(this.memory.charCodeAt(p32+1) << 8) | this.memory.charCodeAt(p32)
, (this.memory.charCodeAt(p32+3) << 8) | this.memory.charCodeAt(p32+2)
);
p32 += 4;
this.v2.xxh_update(
(this.memory.charCodeAt(p32+1) << 8) | this.memory.charCodeAt(p32)
, (this.memory.charCodeAt(p32+3) << 8) | this.memory.charCodeAt(p32+2)
);
p32 += 4;
this.v3.xxh_update(
(this.memory.charCodeAt(p32+1) << 8) | this.memory.charCodeAt(p32)
, (this.memory.charCodeAt(p32+3) << 8) | this.memory.charCodeAt(p32+2)
);
p32 += 4;
this.v4.xxh_update(
(this.memory.charCodeAt(p32+1) << 8) | this.memory.charCodeAt(p32)
, (this.memory.charCodeAt(p32+3) << 8) | this.memory.charCodeAt(p32+2)
);
} else {
this.v1.xxh_update(
(this.memory[p32+1] << 8) | this.memory[p32]
, (this.memory[p32+3] << 8) | this.memory[p32+2]
);
p32 += 4;
this.v2.xxh_update(
(this.memory[p32+1] << 8) | this.memory[p32]
, (this.memory[p32+3] << 8) | this.memory[p32+2]
);
p32 += 4;
this.v3.xxh_update(
(this.memory[p32+1] << 8) | this.memory[p32]
, (this.memory[p32+3] << 8) | this.memory[p32+2]
);
p32 += 4;
this.v4.xxh_update(
(this.memory[p32+1] << 8) | this.memory[p32]
, (this.memory[p32+3] << 8) | this.memory[p32+2]
);
}
p += 16 - this.memsize;
this.memsize = 0;
if (isString) this.memory = '';
}
if (p <= bEnd - 16)
{
var limit = bEnd - 16;
do
{
if (isString) {
this.v1.xxh_update(
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p)
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2)
);
p += 4;
this.v2.xxh_update(
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p)
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2)
);
p += 4;
this.v3.xxh_update(
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p)
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2)
);
p += 4;
this.v4.xxh_update(
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p)
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2)
);
} else {
this.v1.xxh_update(
(input[p+1] << 8) | input[p]
, (input[p+3] << 8) | input[p+2]
);
p += 4;
this.v2.xxh_update(
(input[p+1] << 8) | input[p]
, (input[p+3] << 8) | input[p+2]
);
p += 4;
this.v3.xxh_update(
(input[p+1] << 8) | input[p]
, (input[p+3] << 8) | input[p+2]
);
p += 4;
this.v4.xxh_update(
(input[p+1] << 8) | input[p]
, (input[p+3] << 8) | input[p+2]
);
}
p += 4;
} while (p <= limit)
}
if (p < bEnd)
{
// XXH_memcpy(this.memory, p, bEnd-p);
if (isString) {
this.memory += input.slice(p);
} else if (isArrayBuffer) {
this.memory.set( input.subarray(p, bEnd), this.memsize );
} else {
input.copy( this.memory, this.memsize, p, bEnd );
}
this.memsize = bEnd - p;
}
return this
};
2019-10-03 04:13:12 +08:00
/**
2020-05-30 21:19:58 +08:00
* Finalize the XXH computation. The XXH instance is ready for reuse for the given seed
* @method digest
* @return {UINT32} xxHash
2019-10-03 04:13:12 +08:00
*/
2020-05-30 21:19:58 +08:00
XXH.prototype.digest = function () {
var input = this.memory;
var isString = typeof input == 'string';
var p = 0;
var bEnd = this.memsize;
var h32, h;
var u = new UINT32$1;
if (this.total_len >= 16)
{
h32 = this.v1.rotl(1).add( this.v2.rotl(7).add( this.v3.rotl(12).add( this.v4.rotl(18) ) ) );
}
else
{
h32 = this.seed.clone().add( PRIME32_5 );
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
h32.add( u.fromNumber(this.total_len) );
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
while (p <= bEnd - 4)
{
if (isString) {
u.fromBits(
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p)
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2)
);
} else {
u.fromBits(
(input[p+1] << 8) | input[p]
, (input[p+3] << 8) | input[p+2]
);
}
h32
.add( u.multiply(PRIME32_3) )
.rotl(17)
.multiply( PRIME32_4 );
p += 4;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
while (p < bEnd)
{
u.fromBits( isString ? input.charCodeAt(p++) : input[p++], 0 );
h32
.add( u.multiply(PRIME32_5) )
.rotl(11)
.multiply(PRIME32_1);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
h = h32.clone().shiftRight(15);
h32.xor(h).multiply(PRIME32_2);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
h = h32.clone().shiftRight(13);
h32.xor(h).multiply(PRIME32_3);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
h = h32.clone().shiftRight(16);
h32.xor(h);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Reset the state
this.init( this.seed );
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return h32
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var xxhash = XXH;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
xxHash64 implementation in pure Javascript
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
Copyright (C) 2016, Pierre Curto
MIT license
*/
var UINT64$1 = cuint.UINT64;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/*
* Constants
*/
var PRIME64_1 = UINT64$1( '11400714785074694791' );
var PRIME64_2 = UINT64$1( '14029467366897019727' );
var PRIME64_3 = UINT64$1( '1609587929392839161' );
var PRIME64_4 = UINT64$1( '9650029242287828579' );
var PRIME64_5 = UINT64$1( '2870177450012600261' );
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Convert string to proper UTF-8 array
* @param str Input string
* @returns {Uint8Array} UTF8 array is returned as uint8 array
*/
function toUTF8Array$1 (str) {
var utf8 = [];
for (var i=0, n=str.length; i < n; i++) {
var charcode = str.charCodeAt(i);
if (charcode < 0x80) utf8.push(charcode);
else if (charcode < 0x800) {
utf8.push(0xc0 | (charcode >> 6),
0x80 | (charcode & 0x3f));
}
else if (charcode < 0xd800 || charcode >= 0xe000) {
utf8.push(0xe0 | (charcode >> 12),
0x80 | ((charcode>>6) & 0x3f),
0x80 | (charcode & 0x3f));
}
// surrogate pair
else {
i++;
// UTF-16 encodes 0x10000-0x10FFFF by
// subtracting 0x10000 and splitting the
// 20 bits of 0x0-0xFFFFF into two halves
charcode = 0x10000 + (((charcode & 0x3ff)<<10)
| (str.charCodeAt(i) & 0x3ff));
utf8.push(0xf0 | (charcode >>18),
0x80 | ((charcode>>12) & 0x3f),
0x80 | ((charcode>>6) & 0x3f),
0x80 | (charcode & 0x3f));
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return new Uint8Array(utf8)
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* XXH64 object used as a constructor or a function
* @constructor
* or
* @param {Object|String} input data
* @param {Number|UINT64} seed
* @return ThisExpression
* or
* @return {UINT64} xxHash
*/
function XXH64 () {
if (arguments.length == 2)
return new XXH64( arguments[1] ).update( arguments[0] ).digest()
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!(this instanceof XXH64))
return new XXH64( arguments[0] )
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
init$2.call(this, arguments[0]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Initialize the XXH64 instance with the given seed
* @method init
* @param {Number|Object} seed as a number or an unsigned 32 bits integer
* @return ThisExpression
*/
function init$2 (seed) {
this.seed = seed instanceof UINT64$1 ? seed.clone() : UINT64$1(seed);
this.v1 = this.seed.clone().add(PRIME64_1).add(PRIME64_2);
this.v2 = this.seed.clone().add(PRIME64_2);
this.v3 = this.seed.clone();
this.v4 = this.seed.clone().subtract(PRIME64_1);
this.total_len = 0;
this.memsize = 0;
this.memory = null;
return this
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
XXH64.prototype.init = init$2;
2019-10-03 04:13:12 +08:00
/**
2020-05-30 21:19:58 +08:00
* Add data to be computed for the XXH64 hash
* @method update
* @param {String|Buffer|ArrayBuffer} input as a string or nodejs Buffer or ArrayBuffer
* @return ThisExpression
2019-10-03 04:13:12 +08:00
*/
2020-05-30 21:19:58 +08:00
XXH64.prototype.update = function (input) {
var isString = typeof input == 'string';
var isArrayBuffer;
// Convert all strings to utf-8 first (issue #5)
if (isString) {
input = toUTF8Array$1(input);
isString = false;
isArrayBuffer = true;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (typeof ArrayBuffer !== "undefined" && input instanceof ArrayBuffer)
{
isArrayBuffer = true;
input = new Uint8Array(input);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var p = 0;
var len = input.length;
var bEnd = p + len;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (len == 0) return this
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
this.total_len += len;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (this.memsize == 0)
{
if (isString) {
this.memory = '';
} else if (isArrayBuffer) {
this.memory = new Uint8Array(32);
} else {
this.memory = new Buffer(32);
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (this.memsize + len < 32) // fill in tmp buffer
{
// XXH64_memcpy(this.memory + this.memsize, input, len)
if (isString) {
this.memory += input;
} else if (isArrayBuffer) {
this.memory.set( input.subarray(0, len), this.memsize );
} else {
input.copy( this.memory, this.memsize, 0, len );
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
this.memsize += len;
return this
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (this.memsize > 0) // some data left from previous update
{
// XXH64_memcpy(this.memory + this.memsize, input, 16-this.memsize);
if (isString) {
this.memory += input.slice(0, 32 - this.memsize);
} else if (isArrayBuffer) {
this.memory.set( input.subarray(0, 32 - this.memsize), this.memsize );
} else {
input.copy( this.memory, this.memsize, 0, 32 - this.memsize );
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var p64 = 0;
if (isString) {
var other;
other = UINT64$1(
(this.memory.charCodeAt(p64+1) << 8) | this.memory.charCodeAt(p64)
, (this.memory.charCodeAt(p64+3) << 8) | this.memory.charCodeAt(p64+2)
, (this.memory.charCodeAt(p64+5) << 8) | this.memory.charCodeAt(p64+4)
, (this.memory.charCodeAt(p64+7) << 8) | this.memory.charCodeAt(p64+6)
);
this.v1.add( other.multiply(PRIME64_2) ).rotl(31).multiply(PRIME64_1);
p64 += 8;
other = UINT64$1(
(this.memory.charCodeAt(p64+1) << 8) | this.memory.charCodeAt(p64)
, (this.memory.charCodeAt(p64+3) << 8) | this.memory.charCodeAt(p64+2)
, (this.memory.charCodeAt(p64+5) << 8) | this.memory.charCodeAt(p64+4)
, (this.memory.charCodeAt(p64+7) << 8) | this.memory.charCodeAt(p64+6)
);
this.v2.add( other.multiply(PRIME64_2) ).rotl(31).multiply(PRIME64_1);
p64 += 8;
other = UINT64$1(
(this.memory.charCodeAt(p64+1) << 8) | this.memory.charCodeAt(p64)
, (this.memory.charCodeAt(p64+3) << 8) | this.memory.charCodeAt(p64+2)
, (this.memory.charCodeAt(p64+5) << 8) | this.memory.charCodeAt(p64+4)
, (this.memory.charCodeAt(p64+7) << 8) | this.memory.charCodeAt(p64+6)
);
this.v3.add( other.multiply(PRIME64_2) ).rotl(31).multiply(PRIME64_1);
p64 += 8;
other = UINT64$1(
(this.memory.charCodeAt(p64+1) << 8) | this.memory.charCodeAt(p64)
, (this.memory.charCodeAt(p64+3) << 8) | this.memory.charCodeAt(p64+2)
, (this.memory.charCodeAt(p64+5) << 8) | this.memory.charCodeAt(p64+4)
, (this.memory.charCodeAt(p64+7) << 8) | this.memory.charCodeAt(p64+6)
);
this.v4.add( other.multiply(PRIME64_2) ).rotl(31).multiply(PRIME64_1);
} else {
var other;
other = UINT64$1(
(this.memory[p64+1] << 8) | this.memory[p64]
, (this.memory[p64+3] << 8) | this.memory[p64+2]
, (this.memory[p64+5] << 8) | this.memory[p64+4]
, (this.memory[p64+7] << 8) | this.memory[p64+6]
);
this.v1.add( other.multiply(PRIME64_2) ).rotl(31).multiply(PRIME64_1);
p64 += 8;
other = UINT64$1(
(this.memory[p64+1] << 8) | this.memory[p64]
, (this.memory[p64+3] << 8) | this.memory[p64+2]
, (this.memory[p64+5] << 8) | this.memory[p64+4]
, (this.memory[p64+7] << 8) | this.memory[p64+6]
);
this.v2.add( other.multiply(PRIME64_2) ).rotl(31).multiply(PRIME64_1);
p64 += 8;
other = UINT64$1(
(this.memory[p64+1] << 8) | this.memory[p64]
, (this.memory[p64+3] << 8) | this.memory[p64+2]
, (this.memory[p64+5] << 8) | this.memory[p64+4]
, (this.memory[p64+7] << 8) | this.memory[p64+6]
);
this.v3.add( other.multiply(PRIME64_2) ).rotl(31).multiply(PRIME64_1);
p64 += 8;
other = UINT64$1(
(this.memory[p64+1] << 8) | this.memory[p64]
, (this.memory[p64+3] << 8) | this.memory[p64+2]
, (this.memory[p64+5] << 8) | this.memory[p64+4]
, (this.memory[p64+7] << 8) | this.memory[p64+6]
);
this.v4.add( other.multiply(PRIME64_2) ).rotl(31).multiply(PRIME64_1);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
p += 32 - this.memsize;
this.memsize = 0;
if (isString) this.memory = '';
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (p <= bEnd - 32)
{
var limit = bEnd - 32;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
do
{
if (isString) {
var other;
other = UINT64$1(
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p)
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2)
, (input.charCodeAt(p+5) << 8) | input.charCodeAt(p+4)
, (input.charCodeAt(p+7) << 8) | input.charCodeAt(p+6)
);
this.v1.add( other.multiply(PRIME64_2) ).rotl(31).multiply(PRIME64_1);
p += 8;
other = UINT64$1(
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p)
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2)
, (input.charCodeAt(p+5) << 8) | input.charCodeAt(p+4)
, (input.charCodeAt(p+7) << 8) | input.charCodeAt(p+6)
);
this.v2.add( other.multiply(PRIME64_2) ).rotl(31).multiply(PRIME64_1);
p += 8;
other = UINT64$1(
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p)
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2)
, (input.charCodeAt(p+5) << 8) | input.charCodeAt(p+4)
, (input.charCodeAt(p+7) << 8) | input.charCodeAt(p+6)
);
this.v3.add( other.multiply(PRIME64_2) ).rotl(31).multiply(PRIME64_1);
p += 8;
other = UINT64$1(
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p)
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2)
, (input.charCodeAt(p+5) << 8) | input.charCodeAt(p+4)
, (input.charCodeAt(p+7) << 8) | input.charCodeAt(p+6)
);
this.v4.add( other.multiply(PRIME64_2) ).rotl(31).multiply(PRIME64_1);
} else {
var other;
other = UINT64$1(
(input[p+1] << 8) | input[p]
, (input[p+3] << 8) | input[p+2]
, (input[p+5] << 8) | input[p+4]
, (input[p+7] << 8) | input[p+6]
);
this.v1.add( other.multiply(PRIME64_2) ).rotl(31).multiply(PRIME64_1);
p += 8;
other = UINT64$1(
(input[p+1] << 8) | input[p]
, (input[p+3] << 8) | input[p+2]
, (input[p+5] << 8) | input[p+4]
, (input[p+7] << 8) | input[p+6]
);
this.v2.add( other.multiply(PRIME64_2) ).rotl(31).multiply(PRIME64_1);
p += 8;
other = UINT64$1(
(input[p+1] << 8) | input[p]
, (input[p+3] << 8) | input[p+2]
, (input[p+5] << 8) | input[p+4]
, (input[p+7] << 8) | input[p+6]
);
this.v3.add( other.multiply(PRIME64_2) ).rotl(31).multiply(PRIME64_1);
p += 8;
other = UINT64$1(
(input[p+1] << 8) | input[p]
, (input[p+3] << 8) | input[p+2]
, (input[p+5] << 8) | input[p+4]
, (input[p+7] << 8) | input[p+6]
);
this.v4.add( other.multiply(PRIME64_2) ).rotl(31).multiply(PRIME64_1);
}
p += 8;
} while (p <= limit)
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (p < bEnd)
{
// XXH64_memcpy(this.memory, p, bEnd-p);
if (isString) {
this.memory += input.slice(p);
} else if (isArrayBuffer) {
this.memory.set( input.subarray(p, bEnd), this.memsize );
} else {
input.copy( this.memory, this.memsize, p, bEnd );
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
this.memsize = bEnd - p;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return this
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/**
* Finalize the XXH64 computation. The XXH64 instance is ready for reuse for the given seed
* @method digest
* @return {UINT64} xxHash
*/
XXH64.prototype.digest = function () {
var input = this.memory;
var isString = typeof input == 'string';
var p = 0;
var bEnd = this.memsize;
var h64, h;
var u = new UINT64$1;
if (this.total_len >= 32)
{
h64 = this.v1.clone().rotl(1);
h64.add( this.v2.clone().rotl(7) );
h64.add( this.v3.clone().rotl(12) );
h64.add( this.v4.clone().rotl(18) );
h64.xor( this.v1.multiply(PRIME64_2).rotl(31).multiply(PRIME64_1) );
h64.multiply(PRIME64_1).add(PRIME64_4);
h64.xor( this.v2.multiply(PRIME64_2).rotl(31).multiply(PRIME64_1) );
h64.multiply(PRIME64_1).add(PRIME64_4);
h64.xor( this.v3.multiply(PRIME64_2).rotl(31).multiply(PRIME64_1) );
h64.multiply(PRIME64_1).add(PRIME64_4);
h64.xor( this.v4.multiply(PRIME64_2).rotl(31).multiply(PRIME64_1) );
h64.multiply(PRIME64_1).add(PRIME64_4);
}
else
{
h64 = this.seed.clone().add( PRIME64_5 );
}
h64.add( u.fromNumber(this.total_len) );
while (p <= bEnd - 8)
{
if (isString) {
u.fromBits(
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p)
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2)
, (input.charCodeAt(p+5) << 8) | input.charCodeAt(p+4)
, (input.charCodeAt(p+7) << 8) | input.charCodeAt(p+6)
);
} else {
u.fromBits(
(input[p+1] << 8) | input[p]
, (input[p+3] << 8) | input[p+2]
, (input[p+5] << 8) | input[p+4]
, (input[p+7] << 8) | input[p+6]
);
}
u.multiply(PRIME64_2).rotl(31).multiply(PRIME64_1);
h64
.xor(u)
.rotl(27)
.multiply( PRIME64_1 )
.add( PRIME64_4 );
p += 8;
}
if (p + 4 <= bEnd) {
if (isString) {
u.fromBits(
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p)
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2)
, 0
, 0
);
} else {
u.fromBits(
(input[p+1] << 8) | input[p]
, (input[p+3] << 8) | input[p+2]
, 0
, 0
);
}
h64
.xor( u.multiply(PRIME64_1) )
.rotl(23)
.multiply( PRIME64_2 )
.add( PRIME64_3 );
p += 4;
}
while (p < bEnd)
{
u.fromBits( isString ? input.charCodeAt(p++) : input[p++], 0, 0, 0 );
h64
.xor( u.multiply(PRIME64_5) )
.rotl(11)
.multiply(PRIME64_1);
}
h = h64.clone().shiftRight(33);
h64.xor(h).multiply(PRIME64_2);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
h = h64.clone().shiftRight(29);
h64.xor(h).multiply(PRIME64_3);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
h = h64.clone().shiftRight(32);
h64.xor(h);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// Reset the state
this.init( this.seed );
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return h64
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var xxhash64 = XXH64;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var lib$2 = {
h32: xxhash
, h64: xxhash64
};
var lib_1$2 = lib$2.h32;
var lib_2$2 = lib$2.h64;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
'use strict';
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var fastJsonStableStringify = function (data, opts) {
if (!opts) opts = {};
if (typeof opts === 'function') opts = { cmp: opts };
var cycles = (typeof opts.cycles === 'boolean') ? opts.cycles : false;
var cmp = opts.cmp && (function (f) {
return function (node) {
return function (a, b) {
var aobj = { key: a, value: node[a] };
var bobj = { key: b, value: node[b] };
return f(aobj, bobj);
};
};
})(opts.cmp);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
var seen = [];
return (function stringify (node) {
if (node && node.toJSON && typeof node.toJSON === 'function') {
node = node.toJSON();
}
if (node === undefined) return;
if (typeof node == 'number') return isFinite(node) ? '' + node : 'null';
if (typeof node !== 'object') return JSON.stringify(node);
var i, out;
if (Array.isArray(node)) {
out = '[';
for (i = 0; i < node.length; i++) {
if (i) out += ',';
out += stringify(node[i]) || 'null';
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
return out + ']';
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (node === null) return 'null';
if (seen.indexOf(node) !== -1) {
if (cycles) return JSON.stringify('__cycle__');
throw new TypeError('Converting circular structure to JSON');
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
var seenIndex = seen.push(node) - 1;
var keys = Object.keys(node).sort(cmp && cmp(node));
out = '';
for (i = 0; i < keys.length; i++) {
var key = keys[i];
var value = stringify(node[key]);
if (!value) continue;
if (out) out += ',';
out += JSON.stringify(key) + ':' + value;
}
seen.splice(seenIndex, 1);
return '{' + out + '}';
})(data);
};
/* usr/local/lib/node_modules/snowboard/templates/winter/tables/ParameterTable.svelte generated by Svelte v3.19.2 */
function get_each_context(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[2] = list[i].name;
child_ctx[3] = list[i].example;
child_ctx[4] = list[i].required;
child_ctx[5] = list[i].description;
child_ctx[6] = list[i].schema;
return child_ctx;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
// (36:10) {:else}
function create_else_block$2(ctx) {
let div;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
div = element("div");
div.textContent = "-";
attr(div, "class", "content");
},
m(target, anchor) {
insert(target, div, anchor);
},
p: noop,
d(detaching) {
if (detaching) detach(div);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// (32:10) {#if description}
function create_if_block_2$1(ctx) {
let div;
let raw_value = markdown(/*description*/ ctx[5]) + "";
return {
c() {
div = element("div");
attr(div, "class", "content");
},
m(target, anchor) {
insert(target, div, anchor);
div.innerHTML = raw_value;
},
p(ctx, dirty) {
if (dirty & /*parameters*/ 2 && raw_value !== (raw_value = markdown(/*description*/ ctx[5]) + "")) div.innerHTML = raw_value;;
},
d(detaching) {
if (detaching) detach(div);
}
};
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
// (40:10) {#if example}
function create_if_block_1$2(ctx) {
let div;
let span;
let t1;
let code;
let t2_value = /*example*/ ctx[3] + "";
let t2;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
div = element("div");
span = element("span");
span.textContent = "Example:";
t1 = space();
code = element("code");
t2 = text(t2_value);
attr(code, "class", "tag");
},
m(target, anchor) {
insert(target, div, anchor);
append(div, span);
append(div, t1);
append(div, code);
append(code, t2);
},
p(ctx, dirty) {
if (dirty & /*parameters*/ 2 && t2_value !== (t2_value = /*example*/ ctx[3] + "")) set_data(t2, t2_value);
},
d(detaching) {
if (detaching) detach(div);
}
};
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
// (47:10) {#if schema.enum}
function create_if_block$3(ctx) {
let div;
let span;
let t1;
let code;
let t2_value = /*schema*/ ctx[6].enum + "";
let t2;
return {
c() {
div = element("div");
span = element("span");
span.textContent = "Values:";
t1 = space();
code = element("code");
t2 = text(t2_value);
},
m(target, anchor) {
insert(target, div, anchor);
append(div, span);
append(div, t1);
append(div, code);
append(code, t2);
},
p(ctx, dirty) {
if (dirty & /*parameters*/ 2 && t2_value !== (t2_value = /*schema*/ ctx[6].enum + "")) set_data(t2, t2_value);
},
d(detaching) {
if (detaching) detach(div);
}
};
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
// (15:4) {#each parameters as { name, example, required, description, schema }}
function create_each_block(ctx) {
let tr;
let td0;
let code;
let t0_value = /*name*/ ctx[2] + "";
let t0;
let t1;
let td1;
let div;
let span0;
let t2_value = /*schema*/ ctx[6].type + "";
let t2;
let t3;
let span1;
let t4_value = (/*required*/ ctx[4] ? "required" : "optional") + "";
let t4;
let t5;
let td2;
let t6;
let t7;
let t8;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function select_block_type(ctx, dirty) {
if (/*description*/ ctx[5]) return create_if_block_2$1;
return create_else_block$2;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
let current_block_type = select_block_type(ctx, -1);
let if_block0 = current_block_type(ctx);
let if_block1 = /*example*/ ctx[3] && create_if_block_1$2(ctx);
let if_block2 = /*schema*/ ctx[6].enum && create_if_block$3(ctx);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
tr = element("tr");
td0 = element("td");
code = element("code");
t0 = text(t0_value);
t1 = space();
td1 = element("td");
div = element("div");
span0 = element("span");
t2 = text(t2_value);
t3 = space();
span1 = element("span");
t4 = text(t4_value);
t5 = space();
td2 = element("td");
if_block0.c();
t6 = space();
if (if_block1) if_block1.c();
t7 = space();
if (if_block2) if_block2.c();
t8 = space();
attr(span0, "class", "tag");
attr(span1, "class", "tag");
toggle_class(span1, "is-dark", /*required*/ ctx[4]);
toggle_class(span1, "is-white", !/*required*/ ctx[4]);
attr(div, "class", "tags has-addons");
},
m(target, anchor) {
insert(target, tr, anchor);
append(tr, td0);
append(td0, code);
append(code, t0);
append(tr, t1);
append(tr, td1);
append(td1, div);
append(div, span0);
append(span0, t2);
append(div, t3);
append(div, span1);
append(span1, t4);
append(tr, t5);
append(tr, td2);
if_block0.m(td2, null);
append(td2, t6);
if (if_block1) if_block1.m(td2, null);
append(td2, t7);
if (if_block2) if_block2.m(td2, null);
append(tr, t8);
},
p(ctx, dirty) {
if (dirty & /*parameters*/ 2 && t0_value !== (t0_value = /*name*/ ctx[2] + "")) set_data(t0, t0_value);
if (dirty & /*parameters*/ 2 && t2_value !== (t2_value = /*schema*/ ctx[6].type + "")) set_data(t2, t2_value);
if (dirty & /*parameters*/ 2 && t4_value !== (t4_value = (/*required*/ ctx[4] ? "required" : "optional") + "")) set_data(t4, t4_value);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*parameters*/ 2) {
toggle_class(span1, "is-dark", /*required*/ ctx[4]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*parameters*/ 2) {
toggle_class(span1, "is-white", !/*required*/ ctx[4]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (current_block_type === (current_block_type = select_block_type(ctx, dirty)) && if_block0) {
if_block0.p(ctx, dirty);
} else {
if_block0.d(1);
if_block0 = current_block_type(ctx);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (if_block0) {
if_block0.c();
if_block0.m(td2, t6);
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (/*example*/ ctx[3]) {
if (if_block1) {
if_block1.p(ctx, dirty);
} else {
if_block1 = create_if_block_1$2(ctx);
if_block1.c();
if_block1.m(td2, t7);
}
} else if (if_block1) {
if_block1.d(1);
if_block1 = null;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (/*schema*/ ctx[6].enum) {
if (if_block2) {
if_block2.p(ctx, dirty);
} else {
if_block2 = create_if_block$3(ctx);
if_block2.c();
if_block2.m(td2, null);
}
} else if (if_block2) {
if_block2.d(1);
if_block2 = null;
}
},
d(detaching) {
if (detaching) detach(tr);
if_block0.d();
if (if_block1) if_block1.d();
if (if_block2) if_block2.d();
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function create_fragment$4(ctx) {
let table;
let thead;
let tr;
let th;
let t0;
let t1;
let tbody;
let each_value = /*parameters*/ ctx[1];
let each_blocks = [];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
table = element("table");
thead = element("thead");
tr = element("tr");
th = element("th");
t0 = text(/*title*/ ctx[0]);
t1 = space();
tbody = element("tbody");
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
attr(th, "colspan", "3");
attr(table, "class", "table table-bordered is-bordered is-fullwidth");
},
m(target, anchor) {
insert(target, table, anchor);
append(table, thead);
append(thead, tr);
append(tr, th);
append(th, t0);
append(table, t1);
append(table, tbody);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(tbody, null);
}
},
p(ctx, [dirty]) {
if (dirty & /*title*/ 1) set_data(t0, /*title*/ ctx[0]);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*parameters, markdown*/ 2) {
each_value = /*parameters*/ ctx[1];
let i;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context(ctx, each_value, i);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
} else {
each_blocks[i] = create_each_block(child_ctx);
each_blocks[i].c();
each_blocks[i].m(tbody, null);
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
each_blocks.length = each_value.length;
}
},
i: noop,
o: noop,
d(detaching) {
if (detaching) detach(table);
destroy_each(each_blocks, detaching);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function instance$4($$self, $$props, $$invalidate) {
let { title } = $$props;
let { parameters } = $$props;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$set = $$props => {
if ("title" in $$props) $$invalidate(0, title = $$props.title);
if ("parameters" in $$props) $$invalidate(1, parameters = $$props.parameters);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return [title, parameters];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
class ParameterTable extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance$4, create_fragment$4, safe_not_equal, { title: 0, parameters: 1 });
}
}
2020-05-30 21:19:58 +08:00
/* usr/local/lib/node_modules/snowboard/templates/winter/panels/ParameterPanel.svelte generated by Svelte v3.19.2 */
2020-05-30 21:19:58 +08:00
function create_if_block_1$3(ctx) {
let current;
2020-05-30 21:19:58 +08:00
const parametertable = new ParameterTable({
props: {
parameters: /*pathParameters*/ ctx[0],
title: "Path Parameters"
}
});
2020-05-30 21:19:58 +08:00
return {
c() {
create_component(parametertable.$$.fragment);
},
m(target, anchor) {
mount_component(parametertable, target, anchor);
current = true;
},
p(ctx, dirty) {
const parametertable_changes = {};
if (dirty & /*pathParameters*/ 1) parametertable_changes.parameters = /*pathParameters*/ ctx[0];
parametertable.$set(parametertable_changes);
},
i(local) {
if (current) return;
transition_in(parametertable.$$.fragment, local);
current = true;
},
o(local) {
transition_out(parametertable.$$.fragment, local);
current = false;
},
d(detaching) {
destroy_component(parametertable, detaching);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// (14:0) {#if queryParameters.length > 0}
function create_if_block$4(ctx) {
let current;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const parametertable = new ParameterTable({
props: {
parameters: /*queryParameters*/ ctx[1],
title: "Query Parameters"
}
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
create_component(parametertable.$$.fragment);
},
m(target, anchor) {
mount_component(parametertable, target, anchor);
current = true;
},
p(ctx, dirty) {
const parametertable_changes = {};
if (dirty & /*queryParameters*/ 2) parametertable_changes.parameters = /*queryParameters*/ ctx[1];
parametertable.$set(parametertable_changes);
},
i(local) {
if (current) return;
transition_in(parametertable.$$.fragment, local);
current = true;
},
o(local) {
transition_out(parametertable.$$.fragment, local);
current = false;
},
d(detaching) {
destroy_component(parametertable, detaching);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function create_fragment$5(ctx) {
let t;
let if_block1_anchor;
let current;
let if_block0 = /*pathParameters*/ ctx[0].length > 0 && create_if_block_1$3(ctx);
let if_block1 = /*queryParameters*/ ctx[1].length > 0 && create_if_block$4(ctx);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
if (if_block0) if_block0.c();
t = space();
if (if_block1) if_block1.c();
if_block1_anchor = empty();
},
m(target, anchor) {
if (if_block0) if_block0.m(target, anchor);
insert(target, t, anchor);
if (if_block1) if_block1.m(target, anchor);
insert(target, if_block1_anchor, anchor);
current = true;
},
p(ctx, [dirty]) {
if (/*pathParameters*/ ctx[0].length > 0) {
if (if_block0) {
if_block0.p(ctx, dirty);
transition_in(if_block0, 1);
} else {
if_block0 = create_if_block_1$3(ctx);
if_block0.c();
transition_in(if_block0, 1);
if_block0.m(t.parentNode, t);
}
} else if (if_block0) {
group_outros();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
transition_out(if_block0, 1, 1, () => {
if_block0 = null;
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
check_outros();
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (/*queryParameters*/ ctx[1].length > 0) {
if (if_block1) {
if_block1.p(ctx, dirty);
transition_in(if_block1, 1);
} else {
if_block1 = create_if_block$4(ctx);
if_block1.c();
transition_in(if_block1, 1);
if_block1.m(if_block1_anchor.parentNode, if_block1_anchor);
}
} else if (if_block1) {
group_outros();
transition_out(if_block1, 1, 1, () => {
if_block1 = null;
});
check_outros();
}
},
i(local) {
if (current) return;
transition_in(if_block0);
transition_in(if_block1);
current = true;
},
o(local) {
transition_out(if_block0);
transition_out(if_block1);
current = false;
},
d(detaching) {
if (if_block0) if_block0.d(detaching);
if (detaching) detach(t);
if (if_block1) if_block1.d(detaching);
if (detaching) detach(if_block1_anchor);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function instance$5($$self, $$props, $$invalidate) {
let { parameters = [] } = $$props;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$set = $$props => {
if ("parameters" in $$props) $$invalidate(2, parameters = $$props.parameters);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
let pathParameters;
let queryParameters;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$$.update = () => {
if ($$self.$$.dirty & /*parameters*/ 4) {
$$invalidate(0, pathParameters = parameters.filter(param => param.location === "path"));
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if ($$self.$$.dirty & /*parameters*/ 4) {
$$invalidate(1, queryParameters = parameters.filter(param => param.location === "query"));
}
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return [pathParameters, queryParameters, parameters];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
class ParameterPanel extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance$5, create_fragment$5, safe_not_equal, { parameters: 2 });
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/* usr/local/lib/node_modules/snowboard/templates/winter/components/ToggleIcon.svelte generated by Svelte v3.19.2 */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function add_css$2() {
var style = element("style");
style.id = "svelte-o7a14x-style";
style.textContent = ".toggle-icon.svelte-o7a14x{cursor:pointer}";
append(document.head, style);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function create_fragment$6(ctx) {
let span;
let i;
let span_class_value;
let dispose;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
span = element("span");
i = element("i");
attr(i, "class", "fas");
toggle_class(i, "fa-chevron-up", !/*show*/ ctx[0]);
toggle_class(i, "fa-chevron-down", /*show*/ ctx[0]);
attr(span, "class", span_class_value = "toggle-icon icon " + /*additionalClass*/ ctx[2] + " svelte-o7a14x");
toggle_class(span, "has-text-grey", !/*dark*/ ctx[1]);
},
m(target, anchor) {
insert(target, span, anchor);
append(span, i);
dispose = listen(span, "click", /*toggle*/ ctx[3]);
},
p(ctx, [dirty]) {
if (dirty & /*show*/ 1) {
toggle_class(i, "fa-chevron-up", !/*show*/ ctx[0]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*show*/ 1) {
toggle_class(i, "fa-chevron-down", /*show*/ ctx[0]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*additionalClass*/ 4 && span_class_value !== (span_class_value = "toggle-icon icon " + /*additionalClass*/ ctx[2] + " svelte-o7a14x")) {
attr(span, "class", span_class_value);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*additionalClass, dark*/ 6) {
toggle_class(span, "has-text-grey", !/*dark*/ ctx[1]);
}
},
i: noop,
o: noop,
d(detaching) {
if (detaching) detach(span);
dispose();
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function instance$6($$self, $$props, $$invalidate) {
let { dark = false } = $$props;
let { show = false } = $$props;
let { additionalClass = "" } = $$props;
let { handleClick } = $$props;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function toggle(event) {
$$invalidate(0, show = !show);
handleClick(event);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$set = $$props => {
if ("dark" in $$props) $$invalidate(1, dark = $$props.dark);
if ("show" in $$props) $$invalidate(0, show = $$props.show);
if ("additionalClass" in $$props) $$invalidate(2, additionalClass = $$props.additionalClass);
if ("handleClick" in $$props) $$invalidate(4, handleClick = $$props.handleClick);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return [show, dark, additionalClass, toggle, handleClick];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
class ToggleIcon extends SvelteComponent {
constructor(options) {
super();
if (!document.getElementById("svelte-o7a14x-style")) add_css$2();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
init(this, options, instance$6, create_fragment$6, safe_not_equal, {
dark: 1,
show: 0,
additionalClass: 2,
handleClick: 4
});
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/* usr/local/lib/node_modules/snowboard/templates/winter/panels/CollapsiblePanel.svelte generated by Svelte v3.19.2 */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function add_css$3() {
2019-10-03 04:13:12 +08:00
var style = element("style");
2020-05-30 21:19:58 +08:00
style.id = "svelte-1hkyt70-style";
style.textContent = ".panel-section.svelte-1hkyt70{padding:1em;border:1px solid #dbdbdb;border-top:none}.panel-button.svelte-1hkyt70{border-radius:4px}.panel-dark.svelte-1hkyt70{border:1px solid #363636}.panel-section.is-darkmode.svelte-1hkyt70{background-color:#222 !important;border-color:#333}";
2019-10-03 04:13:12 +08:00
append(document.head, style);
}
2020-05-30 21:19:58 +08:00
const get_body_slot_changes = dirty => ({});
const get_body_slot_context = ctx => ({});
const get_heading_slot_changes = dirty => ({});
const get_heading_slot_context = ctx => ({});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function create_fragment$7(ctx) {
let div2;
let div0;
let t0;
let t1;
2020-05-30 21:19:58 +08:00
let div1;
let current;
const heading_slot_template = /*$$slots*/ ctx[4].heading;
const heading_slot = create_slot(heading_slot_template, ctx, /*$$scope*/ ctx[3], get_heading_slot_context);
const toggleicon = new ToggleIcon({
props: {
dark: /*dark*/ ctx[1],
show: /*show*/ ctx[0],
additionalClass: "is-pulled-right",
handleClick: /*func*/ ctx[5]
}
});
const body_slot_template = /*$$slots*/ ctx[4].body;
const body_slot = create_slot(body_slot_template, ctx, /*$$scope*/ ctx[3], get_body_slot_context);
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
div2 = element("div");
div0 = element("div");
if (heading_slot) heading_slot.c();
t0 = space();
create_component(toggleicon.$$.fragment);
t1 = space();
div1 = element("div");
if (body_slot) body_slot.c();
attr(div0, "class", "panel-heading svelte-1hkyt70");
toggle_class(div0, "has-background-dark", /*dark*/ ctx[1]);
toggle_class(div0, "has-text-white", /*dark*/ ctx[1]);
toggle_class(div0, "panel-dark", /*dark*/ ctx[1]);
toggle_class(div0, "panel-button", !/*show*/ ctx[0]);
attr(div1, "class", "panel-section has-background-white svelte-1hkyt70");
toggle_class(div1, "is-hidden", !/*show*/ ctx[0]);
toggle_class(div1, "is-darkmode", /*isDarkmode*/ ctx[2]);
attr(div2, "class", "panel");
},
2019-10-03 04:13:12 +08:00
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, div2, anchor);
append(div2, div0);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (heading_slot) {
heading_slot.m(div0, null);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
append(div0, t0);
mount_component(toggleicon, div0, null);
append(div2, t1);
append(div2, div1);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (body_slot) {
body_slot.m(div1, null);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
current = true;
},
2020-05-30 21:19:58 +08:00
p(ctx, [dirty]) {
if (heading_slot && heading_slot.p && dirty & /*$$scope*/ 8) {
heading_slot.p(get_slot_context(heading_slot_template, ctx, /*$$scope*/ ctx[3], get_heading_slot_context), get_slot_changes(heading_slot_template, /*$$scope*/ ctx[3], dirty, get_heading_slot_changes));
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const toggleicon_changes = {};
if (dirty & /*dark*/ 2) toggleicon_changes.dark = /*dark*/ ctx[1];
if (dirty & /*show*/ 1) toggleicon_changes.show = /*show*/ ctx[0];
if (dirty & /*show*/ 1) toggleicon_changes.handleClick = /*func*/ ctx[5];
toggleicon.$set(toggleicon_changes);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*dark*/ 2) {
toggle_class(div0, "has-background-dark", /*dark*/ ctx[1]);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (dirty & /*dark*/ 2) {
toggle_class(div0, "has-text-white", /*dark*/ ctx[1]);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (dirty & /*dark*/ 2) {
toggle_class(div0, "panel-dark", /*dark*/ ctx[1]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*show*/ 1) {
toggle_class(div0, "panel-button", !/*show*/ ctx[0]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (body_slot && body_slot.p && dirty & /*$$scope*/ 8) {
body_slot.p(get_slot_context(body_slot_template, ctx, /*$$scope*/ ctx[3], get_body_slot_context), get_slot_changes(body_slot_template, /*$$scope*/ ctx[3], dirty, get_body_slot_changes));
}
2020-05-30 21:19:58 +08:00
if (dirty & /*show*/ 1) {
toggle_class(div1, "is-hidden", !/*show*/ ctx[0]);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (dirty & /*isDarkmode*/ 4) {
toggle_class(div1, "is-darkmode", /*isDarkmode*/ ctx[2]);
2019-10-03 04:13:12 +08:00
}
},
2020-05-30 21:19:58 +08:00
i(local) {
if (current) return;
transition_in(heading_slot, local);
transition_in(toggleicon.$$.fragment, local);
transition_in(body_slot, local);
current = true;
},
o(local) {
transition_out(heading_slot, local);
transition_out(toggleicon.$$.fragment, local);
transition_out(body_slot, local);
current = false;
},
2019-10-03 04:13:12 +08:00
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(div2);
if (heading_slot) heading_slot.d(detaching);
destroy_component(toggleicon);
if (body_slot) body_slot.d(detaching);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function instance$7($$self, $$props, $$invalidate) {
let { dark = false } = $$props;
let { show = false } = $$props;
let { isDarkmode } = $$props;
let { $$slots = {}, $$scope } = $$props;
const func = () => $$invalidate(0, show = !show);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$set = $$props => {
if ("dark" in $$props) $$invalidate(1, dark = $$props.dark);
if ("show" in $$props) $$invalidate(0, show = $$props.show);
if ("isDarkmode" in $$props) $$invalidate(2, isDarkmode = $$props.isDarkmode);
if ("$$scope" in $$props) $$invalidate(3, $$scope = $$props.$$scope);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return [show, dark, isDarkmode, $$scope, $$slots, func];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
class CollapsiblePanel extends SvelteComponent {
constructor(options) {
super();
if (!document.getElementById("svelte-1hkyt70-style")) add_css$3();
init(this, options, instance$7, create_fragment$7, safe_not_equal, { dark: 1, show: 0, isDarkmode: 2 });
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/* usr/local/lib/node_modules/snowboard/templates/winter/components/FieldDisabled.svelte generated by Svelte v3.19.2 */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function add_css$4() {
var style = element("style");
style.id = "svelte-a7ak6u-style";
style.textContent = ".control-switch.svelte-a7ak6u{padding-top:0.4rem}.has-border.svelte-a7ak6u{border-color:#dbdbdb}";
append(document.head, style);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
function create_fragment$8(ctx) {
let div;
let p0;
let input0;
let input0_id_value;
let t0;
let label;
let label_for_value;
let t1;
let p1;
let input1;
let t2;
let p2;
let input2;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
div = element("div");
p0 = element("p");
input0 = element("input");
t0 = space();
label = element("label");
t1 = space();
p1 = element("p");
input1 = element("input");
t2 = space();
p2 = element("p");
input2 = element("input");
attr(input0, "class", "switch is-rounded is-success");
attr(input0, "id", input0_id_value = "h-" + /*name*/ ctx[0]);
attr(input0, "type", "checkbox");
input0.checked = true;
input0.disabled = true;
attr(label, "for", label_for_value = "h-" + /*name*/ ctx[0]);
attr(p0, "class", "control control-switch svelte-a7ak6u");
attr(input1, "class", "input is-rounded has-border svelte-a7ak6u");
attr(input1, "type", "text");
attr(input1, "placeholder", /*placeholder*/ ctx[1]);
input1.disabled = true;
attr(p1, "class", "control");
attr(input2, "class", "input is-rounded has-border is-family-code svelte-a7ak6u");
attr(input2, "type", "text");
input2.value = /*value*/ ctx[2];
input2.disabled = true;
attr(p2, "class", "control is-expanded");
attr(div, "class", "field has-addons");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, div, anchor);
append(div, p0);
append(p0, input0);
append(p0, t0);
append(p0, label);
append(div, t1);
append(div, p1);
append(p1, input1);
append(div, t2);
append(div, p2);
append(p2, input2);
2019-10-03 04:13:12 +08:00
},
p(ctx, [dirty]) {
2020-05-30 21:19:58 +08:00
if (dirty & /*name*/ 1 && input0_id_value !== (input0_id_value = "h-" + /*name*/ ctx[0])) {
attr(input0, "id", input0_id_value);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (dirty & /*name*/ 1 && label_for_value !== (label_for_value = "h-" + /*name*/ ctx[0])) {
attr(label, "for", label_for_value);
}
if (dirty & /*placeholder*/ 2) {
attr(input1, "placeholder", /*placeholder*/ ctx[1]);
}
if (dirty & /*value*/ 4 && input2.value !== /*value*/ ctx[2]) {
input2.value = /*value*/ ctx[2];
2019-10-03 04:13:12 +08:00
}
},
i: noop,
o: noop,
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(div);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function instance$8($$self, $$props, $$invalidate) {
let { name } = $$props;
let { placeholder } = $$props;
let { value } = $$props;
2019-10-03 04:13:12 +08:00
$$self.$set = $$props => {
2020-05-30 21:19:58 +08:00
if ("name" in $$props) $$invalidate(0, name = $$props.name);
if ("placeholder" in $$props) $$invalidate(1, placeholder = $$props.placeholder);
if ("value" in $$props) $$invalidate(2, value = $$props.value);
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
return [name, placeholder, value];
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
class FieldDisabled extends SvelteComponent {
2019-10-03 04:13:12 +08:00
constructor(options) {
super();
2020-05-30 21:19:58 +08:00
if (!document.getElementById("svelte-a7ak6u-style")) add_css$4();
init(this, options, instance$8, create_fragment$8, safe_not_equal, { name: 0, placeholder: 1, value: 2 });
2019-10-03 04:13:12 +08:00
}
}
2020-05-30 21:19:58 +08:00
/* usr/local/lib/node_modules/snowboard/templates/winter/components/FieldSwitch.svelte generated by Svelte v3.19.2 */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function add_css$5() {
2019-10-03 04:13:12 +08:00
var style = element("style");
2020-05-30 21:19:58 +08:00
style.id = "svelte-a7ak6u-style";
style.textContent = ".control-switch.svelte-a7ak6u{padding-top:0.4rem}.has-border.svelte-a7ak6u{border-color:#dbdbdb}";
2019-10-03 04:13:12 +08:00
append(document.head, style);
}
2020-05-30 21:19:58 +08:00
function create_fragment$9(ctx) {
let div;
let p0;
let input0;
let input0_id_value;
let t0;
2020-05-30 21:19:58 +08:00
let label;
let label_for_value;
let t1;
2020-05-30 21:19:58 +08:00
let p1;
let input1;
let t2;
let p2;
let input2;
let dispose;
return {
c() {
2020-05-30 21:19:58 +08:00
div = element("div");
p0 = element("p");
input0 = element("input");
t0 = space();
label = element("label");
t1 = space();
2020-05-30 21:19:58 +08:00
p1 = element("p");
input1 = element("input");
t2 = space();
p2 = element("p");
input2 = element("input");
attr(input0, "class", "switch is-rounded is-success");
attr(input0, "id", input0_id_value = "p-" + /*name*/ ctx[3]);
attr(input0, "type", "checkbox");
input0.disabled = /*required*/ ctx[2];
attr(label, "for", label_for_value = "p-" + /*name*/ ctx[3]);
attr(p0, "class", "control control-switch svelte-a7ak6u");
attr(input1, "class", "input is-rounded has-border svelte-a7ak6u");
attr(input1, "type", "text");
attr(input1, "placeholder", /*name*/ ctx[3]);
input1.disabled = true;
attr(p1, "class", "control");
attr(input2, "class", "input has-border is-family-code svelte-a7ak6u");
attr(input2, "type", "text");
toggle_class(input2, "is-rounded", /*rounded*/ ctx[4]);
attr(p2, "class", "control is-expanded");
attr(div, "class", "field has-addons");
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, div, anchor);
append(div, p0);
append(p0, input0);
input0.checked = /*used*/ ctx[0];
append(p0, t0);
append(p0, label);
append(div, t1);
append(div, p1);
append(p1, input1);
append(div, t2);
append(div, p2);
append(p2, input2);
set_input_value(input2, /*value*/ ctx[1]);
dispose = [
listen(input0, "change", /*input0_change_handler*/ ctx[5]),
listen(input2, "input", /*input2_input_handler*/ ctx[6])
];
},
2020-05-30 21:19:58 +08:00
p(ctx, [dirty]) {
if (dirty & /*name*/ 8 && input0_id_value !== (input0_id_value = "p-" + /*name*/ ctx[3])) {
attr(input0, "id", input0_id_value);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*required*/ 4) {
input0.disabled = /*required*/ ctx[2];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*used*/ 1) {
input0.checked = /*used*/ ctx[0];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*name*/ 8 && label_for_value !== (label_for_value = "p-" + /*name*/ ctx[3])) {
attr(label, "for", label_for_value);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*name*/ 8) {
attr(input1, "placeholder", /*name*/ ctx[3]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*value*/ 2 && input2.value !== /*value*/ ctx[1]) {
set_input_value(input2, /*value*/ ctx[1]);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (dirty & /*rounded*/ 16) {
toggle_class(input2, "is-rounded", /*rounded*/ ctx[4]);
2019-10-03 04:13:12 +08:00
}
},
2020-05-30 21:19:58 +08:00
i: noop,
o: noop,
d(detaching) {
if (detaching) detach(div);
run_all(dispose);
}
};
}
function instance$9($$self, $$props, $$invalidate) {
let { used } = $$props;
let { required } = $$props;
let { name } = $$props;
let { value } = $$props;
let { rounded } = $$props;
function input0_change_handler() {
used = this.checked;
$$invalidate(0, used);
}
2020-05-30 21:19:58 +08:00
function input2_input_handler() {
value = this.value;
$$invalidate(1, value);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$set = $$props => {
if ("used" in $$props) $$invalidate(0, used = $$props.used);
if ("required" in $$props) $$invalidate(2, required = $$props.required);
if ("name" in $$props) $$invalidate(3, name = $$props.name);
if ("value" in $$props) $$invalidate(1, value = $$props.value);
if ("rounded" in $$props) $$invalidate(4, rounded = $$props.rounded);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return [
used,
value,
required,
name,
rounded,
input0_change_handler,
input2_input_handler
];
}
2020-05-30 21:19:58 +08:00
class FieldSwitch extends SvelteComponent {
constructor(options) {
super();
if (!document.getElementById("svelte-a7ak6u-style")) add_css$5();
init(this, options, instance$9, create_fragment$9, safe_not_equal, {
used: 0,
required: 2,
name: 3,
value: 1,
rounded: 4
});
}
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
/* usr/local/lib/node_modules/snowboard/templates/winter/components/CodeBlock.svelte generated by Svelte v3.19.2 */
function create_if_block$5(ctx) {
let pre;
let code;
let raw_value = highlight(stringify$2(/*body*/ ctx[0]), /*mime*/ ctx[1]) + "";
let code_class_value;
let pre_class_value;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
pre = element("pre");
code = element("code");
attr(code, "class", code_class_value = "language-" + /*mime*/ ctx[1]);
attr(pre, "class", pre_class_value = "language-" + /*mime*/ ctx[1]);
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, pre, anchor);
append(pre, code);
code.innerHTML = raw_value;
2019-10-03 04:13:12 +08:00
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
if (dirty & /*body, mime*/ 3 && raw_value !== (raw_value = highlight(stringify$2(/*body*/ ctx[0]), /*mime*/ ctx[1]) + "")) code.innerHTML = raw_value;;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*mime*/ 2 && code_class_value !== (code_class_value = "language-" + /*mime*/ ctx[1])) {
attr(code, "class", code_class_value);
}
if (dirty & /*mime*/ 2 && pre_class_value !== (pre_class_value = "language-" + /*mime*/ ctx[1])) {
attr(pre, "class", pre_class_value);
2019-10-03 04:13:12 +08:00
}
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(pre);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function create_fragment$a(ctx) {
let if_block_anchor;
2020-05-30 21:19:58 +08:00
let if_block = /*body*/ ctx[0] && create_if_block$5(ctx);
2019-10-03 04:13:12 +08:00
return {
c() {
if (if_block) if_block.c();
if_block_anchor = empty();
},
m(target, anchor) {
if (if_block) if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
},
2020-05-30 21:19:58 +08:00
p(ctx, [dirty]) {
if (/*body*/ ctx[0]) {
2019-10-03 04:13:12 +08:00
if (if_block) {
if_block.p(ctx, dirty);
2019-10-03 04:13:12 +08:00
} else {
2020-05-30 21:19:58 +08:00
if_block = create_if_block$5(ctx);
2019-10-03 04:13:12 +08:00
if_block.c();
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
},
2020-05-30 21:19:58 +08:00
i: noop,
o: noop,
2019-10-03 04:13:12 +08:00
d(detaching) {
if (if_block) if_block.d(detaching);
if (detaching) detach(if_block_anchor);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function instance$a($$self, $$props, $$invalidate) {
let { type } = $$props;
let { body } = $$props;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$set = $$props => {
if ("type" in $$props) $$invalidate(2, type = $$props.type);
if ("body" in $$props) $$invalidate(0, body = $$props.body);
};
let mime;
$$self.$$.update = () => {
if ($$self.$$.dirty & /*type*/ 4) {
$$invalidate(1, mime = alias(type));
2019-10-03 04:13:12 +08:00
}
};
2020-05-30 21:19:58 +08:00
return [body, mime, type];
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
class CodeBlock extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance$a, create_fragment$a, safe_not_equal, { type: 2, body: 0 });
}
}
2020-05-30 21:19:58 +08:00
/* usr/local/lib/node_modules/snowboard/templates/winter/components/LoginButton.svelte generated by Svelte v3.19.2 */
function create_fragment$b(ctx) {
let a;
let span0;
let t0;
let span1;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
a = element("a");
span0 = element("span");
span0.innerHTML = `<i class="fas fa-sign-in-alt" aria-hidden="true"></i>`;
t0 = space();
span1 = element("span");
span1.textContent = "Login";
attr(span0, "class", "icon");
attr(a, "href", /*authorizeUrl*/ ctx[1]);
attr(a, "class", "button is-dark is-rounded");
toggle_class(a, "is-fullwidth", /*fullWidth*/ ctx[0]);
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, a, anchor);
append(a, span0);
append(a, t0);
append(a, span1);
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
p(ctx, [dirty]) {
if (dirty & /*authorizeUrl*/ 2) {
attr(a, "href", /*authorizeUrl*/ ctx[1]);
}
if (dirty & /*fullWidth*/ 1) {
toggle_class(a, "is-fullwidth", /*fullWidth*/ ctx[0]);
}
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
i: noop,
o: noop,
2019-10-03 04:13:12 +08:00
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(a);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function instance$b($$self, $$props, $$invalidate) {
let { authOptions } = $$props;
let { fullWidth } = $$props;
let { pkceChallenge } = $$props;
let { isPKCE } = $$props;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$set = $$props => {
if ("authOptions" in $$props) $$invalidate(2, authOptions = $$props.authOptions);
if ("fullWidth" in $$props) $$invalidate(0, fullWidth = $$props.fullWidth);
if ("pkceChallenge" in $$props) $$invalidate(3, pkceChallenge = $$props.pkceChallenge);
if ("isPKCE" in $$props) $$invalidate(4, isPKCE = $$props.isPKCE);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
let authorizeParams;
let authorizeUrl;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$$.update = () => {
if ($$self.$$.dirty & /*isPKCE, authOptions, pkceChallenge*/ 28) {
$$invalidate(5, authorizeParams = isPKCE
? querystringify_1.stringify(
{
client_id: authOptions.clientId,
redirect_uri: authOptions.callbackUrl,
response_type: "code",
state: getState(),
scope: authOptions.scopes || "",
code_challenge: pkceChallenge.codeChallenge,
code_challenge_method: "S256"
},
true
)
: querystringify_1.stringify(
{
client_id: authOptions.clientId,
redirect_uri: authOptions.callbackUrl,
response_type: "code",
scope: authOptions.scopes || ""
},
true
));
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if ($$self.$$.dirty & /*authOptions, authorizeParams*/ 36) {
$$invalidate(1, authorizeUrl = `${authOptions.authorizeUrl}${authorizeParams}`);
}
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return [fullWidth, authorizeUrl, authOptions, pkceChallenge, isPKCE];
}
2020-05-30 21:19:58 +08:00
class LoginButton extends SvelteComponent {
constructor(options) {
super();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
init(this, options, instance$b, create_fragment$b, safe_not_equal, {
authOptions: 2,
fullWidth: 0,
pkceChallenge: 3,
isPKCE: 4
});
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/* usr/local/lib/node_modules/snowboard/templates/winter/panels/PlaygroundPanel.svelte generated by Svelte v3.19.2 */
2020-05-30 21:19:58 +08:00
function add_css$6() {
var style = element("style");
style.id = "svelte-c3oocm-style";
style.textContent = ".small-section.svelte-c3oocm{padding-top:0.5rem}.button-left.svelte-c3oocm{justify-content:left}.control-switch.svelte-c3oocm{padding-top:0.4rem}.container-content.svelte-c3oocm{padding:0.5rem 1rem;border-radius:4px;margin-top:0.5rem;background-color:#2b2b2b}.content-header.svelte-c3oocm{color:#fff;border-bottom:dashed 1px #777;padding-top:0.5rem;padding-bottom:1rem}.hero-small.svelte-c3oocm{padding:1.5rem}.has-border.svelte-c3oocm{border-color:#dbdbdb}.hero-rounded.svelte-c3oocm{border-radius:4px}";
append(document.head, style);
}
2020-05-30 21:19:58 +08:00
function get_each_context$1(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[31] = list[i][0];
child_ctx[32] = list[i][1];
return child_ctx;
}
2020-05-30 21:19:58 +08:00
function get_each_context_1(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[35] = list[i];
child_ctx[36] = list;
child_ctx[37] = i;
return child_ctx;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function get_each_context_2(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[38] = list[i];
child_ctx[39] = list;
child_ctx[40] = i;
return child_ctx;
}
2020-05-30 21:19:58 +08:00
// (119:2) <span slot="heading">
function create_heading_slot(ctx) {
let span;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
span = element("span");
span.textContent = "Playground";
attr(span, "slot", "heading");
},
m(target, anchor) {
insert(target, span, anchor);
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(span);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (128:8) {:else}
function create_else_block_4(ctx) {
let a;
let span0;
let t0_value = /*currentAction*/ ctx[6].method + "";
let t0;
let t1;
2020-05-30 21:19:58 +08:00
let span1;
let t2_value = /*currentUrl*/ ctx[13].origin + "";
let t2;
let t3;
2020-05-30 21:19:58 +08:00
let span2;
let t4_value = /*currentUrl*/ ctx[13].pathname + "";
let t4;
let dispose;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
a = element("a");
span0 = element("span");
t0 = text(t0_value);
t1 = text("\n  \n ");
span1 = element("span");
t2 = text(t2_value);
2019-10-03 04:13:12 +08:00
t3 = space();
2020-05-30 21:19:58 +08:00
span2 = element("span");
t4 = text(t4_value);
attr(span0, "class", "is-uppercase has-text-weight-bold");
attr(span2, "class", "has-text-weight-bold");
attr(a, "href", "javascript:void(0)");
attr(a, "class", "button button-left is-warning is-family-code is-fullwidth svelte-c3oocm");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, a, anchor);
append(a, span0);
append(span0, t0);
append(a, t1);
append(a, span1);
append(span1, t2);
append(a, t3);
append(a, span2);
append(span2, t4);
dispose = listen(a, "click", /*handleCopy*/ ctx[17]);
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
p(ctx, dirty) {
if (dirty[0] & /*currentAction*/ 64 && t0_value !== (t0_value = /*currentAction*/ ctx[6].method + "")) set_data(t0, t0_value);
if (dirty[0] & /*currentUrl*/ 8192 && t2_value !== (t2_value = /*currentUrl*/ ctx[13].origin + "")) set_data(t2, t2_value);
if (dirty[0] & /*currentUrl*/ 8192 && t4_value !== (t4_value = /*currentUrl*/ ctx[13].pathname + "")) set_data(t4, t4_value);
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
d(detaching) {
if (detaching) detach(a);
dispose();
}
};
}
2020-05-30 21:19:58 +08:00
// (123:8) {#if copying}
function create_if_block_7(ctx) {
let button;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
button = element("button");
button.innerHTML = `<span>URL has been copied to clipboard.</span>`;
attr(button, "class", "button button-left is-warning is-family-code is-fullwidth svelte-c3oocm");
},
m(target, anchor) {
insert(target, button, anchor);
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
p: noop,
2019-10-03 04:13:12 +08:00
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(button);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (149:8) {:else}
function create_else_block_3(ctx) {
let button;
let dispose;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
button = element("button");
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
button.innerHTML = `<span class="icon"><i class="fas fa-paper-plane"></i></span>
<span>Send</span>`;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
attr(button, "class", "button is-success is-fullwidth");
},
m(target, anchor) {
insert(target, button, anchor);
dispose = listen(button, "click", /*handleClick*/ ctx[15]);
},
p: noop,
i: noop,
o: noop,
d(detaching) {
if (detaching) detach(button);
dispose();
}
2019-10-03 04:13:12 +08:00
};
}
2020-05-30 21:19:58 +08:00
// (143:8) {#if isAuth(environment, 'oauth2') && !$auth.split(';').includes($env)}
function create_if_block_6(ctx) {
let current;
2020-05-30 21:19:58 +08:00
const loginbutton = new LoginButton({
props: {
authOptions: /*environment*/ ctx[11].auth.options,
isPKCE: isPKCE(/*environment*/ ctx[11]),
pkceChallenge: /*pkceChallenge*/ ctx[7],
fullWidth: true
}
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
create_component(loginbutton.$$.fragment);
},
m(target, anchor) {
mount_component(loginbutton, target, anchor);
current = true;
},
p(ctx, dirty) {
const loginbutton_changes = {};
if (dirty[0] & /*environment*/ 2048) loginbutton_changes.authOptions = /*environment*/ ctx[11].auth.options;
if (dirty[0] & /*environment*/ 2048) loginbutton_changes.isPKCE = isPKCE(/*environment*/ ctx[11]);
if (dirty[0] & /*pkceChallenge*/ 128) loginbutton_changes.pkceChallenge = /*pkceChallenge*/ ctx[7];
loginbutton.$set(loginbutton_changes);
},
i(local) {
if (current) return;
transition_in(loginbutton.$$.fragment, local);
current = true;
},
o(local) {
transition_out(loginbutton.$$.fragment, local);
current = false;
},
d(detaching) {
destroy_component(loginbutton, detaching);
}
};
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
// (181:6) {:else}
function create_else_block_2(ctx) {
let t;
let if_block_anchor;
let current;
let each_value_2 = /*requestHeaders*/ ctx[0];
2019-10-03 04:13:12 +08:00
let each_blocks = [];
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_value_2.length; i += 1) {
each_blocks[i] = create_each_block_2(get_each_context_2(ctx, each_value_2, i));
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
const out = i => transition_out(each_blocks[i], 1, 1, () => {
each_blocks[i] = null;
});
let if_block = /*requestAuthHeader*/ ctx[1] && create_if_block_5(ctx);
2019-10-03 04:13:12 +08:00
return {
c() {
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
2020-05-30 21:19:58 +08:00
t = space();
if (if_block) if_block.c();
if_block_anchor = empty();
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
for (let i = 0; i < each_blocks.length; i += 1) {
2020-05-30 21:19:58 +08:00
each_blocks[i].m(target, anchor);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
insert(target, t, anchor);
if (if_block) if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
current = true;
2019-10-03 04:13:12 +08:00
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
if (dirty[0] & /*requestHeaders*/ 1) {
each_value_2 = /*requestHeaders*/ ctx[0];
2019-10-03 04:13:12 +08:00
let i;
2020-05-30 21:19:58 +08:00
for (i = 0; i < each_value_2.length; i += 1) {
const child_ctx = get_each_context_2(ctx, each_value_2, i);
2019-10-03 04:13:12 +08:00
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
2020-05-30 21:19:58 +08:00
transition_in(each_blocks[i], 1);
2019-10-03 04:13:12 +08:00
} else {
2020-05-30 21:19:58 +08:00
each_blocks[i] = create_each_block_2(child_ctx);
2019-10-03 04:13:12 +08:00
each_blocks[i].c();
2020-05-30 21:19:58 +08:00
transition_in(each_blocks[i], 1);
each_blocks[i].m(t.parentNode, t);
2019-10-03 04:13:12 +08:00
}
}
2020-05-30 21:19:58 +08:00
group_outros();
for (i = each_value_2.length; i < each_blocks.length; i += 1) {
out(i);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
check_outros();
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (/*requestAuthHeader*/ ctx[1]) {
if (if_block) {
if_block.p(ctx, dirty);
transition_in(if_block, 1);
} else {
if_block = create_if_block_5(ctx);
if_block.c();
transition_in(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
group_outros();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
transition_out(if_block, 1, 1, () => {
if_block = null;
});
check_outros();
}
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
i(local) {
if (current) return;
for (let i = 0; i < each_value_2.length; i += 1) {
transition_in(each_blocks[i]);
}
transition_in(if_block);
current = true;
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
o(local) {
each_blocks = each_blocks.filter(Boolean);
for (let i = 0; i < each_blocks.length; i += 1) {
transition_out(each_blocks[i]);
}
transition_out(if_block);
current = false;
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
destroy_each(each_blocks, detaching);
if (detaching) detach(t);
if (if_block) if_block.d(detaching);
if (detaching) detach(if_block_anchor);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (177:6) {#if requestHeaders.length === 0 && !environment.auth}
function create_if_block_4(ctx) {
let p;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
p = element("p");
p.innerHTML = `<em>No configurable headers.</em>`;
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, p, anchor);
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
p: noop,
2019-10-03 04:13:12 +08:00
i: noop,
o: noop,
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(p);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (182:8) {#each requestHeaders as header}
function create_each_block_2(ctx) {
let updating_used;
let updating_value;
let current;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function fieldswitch_used_binding(value) {
/*fieldswitch_used_binding*/ ctx[23].call(null, value, /*header*/ ctx[38]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function fieldswitch_value_binding(value) {
/*fieldswitch_value_binding*/ ctx[24].call(null, value, /*header*/ ctx[38]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
let fieldswitch_props = {
name: /*header*/ ctx[38].name,
required: /*header*/ ctx[38].required,
rounded: true
};
if (/*header*/ ctx[38].used !== void 0) {
fieldswitch_props.used = /*header*/ ctx[38].used;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (/*header*/ ctx[38].value !== void 0) {
fieldswitch_props.value = /*header*/ ctx[38].value;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const fieldswitch = new FieldSwitch({ props: fieldswitch_props });
binding_callbacks.push(() => bind(fieldswitch, "used", fieldswitch_used_binding));
binding_callbacks.push(() => bind(fieldswitch, "value", fieldswitch_value_binding));
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
create_component(fieldswitch.$$.fragment);
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
mount_component(fieldswitch, target, anchor);
current = true;
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
p(new_ctx, dirty) {
ctx = new_ctx;
const fieldswitch_changes = {};
if (dirty[0] & /*requestHeaders*/ 1) fieldswitch_changes.name = /*header*/ ctx[38].name;
if (dirty[0] & /*requestHeaders*/ 1) fieldswitch_changes.required = /*header*/ ctx[38].required;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!updating_used && dirty[0] & /*requestHeaders*/ 1) {
updating_used = true;
fieldswitch_changes.used = /*header*/ ctx[38].used;
add_flush_callback(() => updating_used = false);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (!updating_value && dirty[0] & /*requestHeaders*/ 1) {
updating_value = true;
fieldswitch_changes.value = /*header*/ ctx[38].value;
add_flush_callback(() => updating_value = false);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
fieldswitch.$set(fieldswitch_changes);
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
i(local) {
if (current) return;
transition_in(fieldswitch.$$.fragment, local);
current = true;
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
o(local) {
transition_out(fieldswitch.$$.fragment, local);
current = false;
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
destroy_component(fieldswitch, detaching);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (191:8) {#if requestAuthHeader}
function create_if_block_5(ctx) {
let updating_value;
let current;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function fieldswitch_value_binding_1(value) {
/*fieldswitch_value_binding_1*/ ctx[25].call(null, value);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
let fieldswitch_props = {
name: /*requestAuthHeader*/ ctx[1].name,
required: /*requestAuthHeader*/ ctx[1].required,
used: /*requestAuthHeader*/ ctx[1].used,
rounded: true
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
if (/*requestAuthHeader*/ ctx[1].value !== void 0) {
fieldswitch_props.value = /*requestAuthHeader*/ ctx[1].value;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
const fieldswitch = new FieldSwitch({ props: fieldswitch_props });
binding_callbacks.push(() => bind(fieldswitch, "value", fieldswitch_value_binding_1));
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
create_component(fieldswitch.$$.fragment);
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
mount_component(fieldswitch, target, anchor);
2019-10-03 04:13:12 +08:00
current = true;
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
const fieldswitch_changes = {};
if (dirty[0] & /*requestAuthHeader*/ 2) fieldswitch_changes.name = /*requestAuthHeader*/ ctx[1].name;
if (dirty[0] & /*requestAuthHeader*/ 2) fieldswitch_changes.required = /*requestAuthHeader*/ ctx[1].required;
if (dirty[0] & /*requestAuthHeader*/ 2) fieldswitch_changes.used = /*requestAuthHeader*/ ctx[1].used;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!updating_value && dirty[0] & /*requestAuthHeader*/ 2) {
updating_value = true;
fieldswitch_changes.value = /*requestAuthHeader*/ ctx[1].value;
add_flush_callback(() => updating_value = false);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
fieldswitch.$set(fieldswitch_changes);
2019-10-03 04:13:12 +08:00
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(fieldswitch.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(fieldswitch.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
destroy_component(fieldswitch, detaching);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (207:6) {:else}
function create_else_block_1(ctx) {
let each_1_anchor;
let current;
2020-05-30 21:19:58 +08:00
let each_value_1 = /*requestParameters*/ ctx[2];
let each_blocks = [];
for (let i = 0; i < each_value_1.length; i += 1) {
each_blocks[i] = create_each_block_1(get_each_context_1(ctx, each_value_1, i));
}
const out = i => transition_out(each_blocks[i], 1, 1, () => {
each_blocks[i] = null;
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
each_1_anchor = empty();
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(target, anchor);
}
insert(target, each_1_anchor, anchor);
2019-10-03 04:13:12 +08:00
current = true;
},
2020-05-30 21:19:58 +08:00
p(ctx, dirty) {
if (dirty[0] & /*requestParameters*/ 4) {
each_value_1 = /*requestParameters*/ ctx[2];
let i;
for (i = 0; i < each_value_1.length; i += 1) {
const child_ctx = get_each_context_1(ctx, each_value_1, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
transition_in(each_blocks[i], 1);
} else {
each_blocks[i] = create_each_block_1(child_ctx);
each_blocks[i].c();
transition_in(each_blocks[i], 1);
each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
}
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
2019-10-03 04:13:12 +08:00
group_outros();
2020-05-30 21:19:58 +08:00
for (i = each_value_1.length; i < each_blocks.length; i += 1) {
out(i);
}
2019-10-03 04:13:12 +08:00
check_outros();
}
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_value_1.length; i += 1) {
transition_in(each_blocks[i]);
}
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
each_blocks = each_blocks.filter(Boolean);
for (let i = 0; i < each_blocks.length; i += 1) {
transition_out(each_blocks[i]);
}
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
destroy_each(each_blocks, detaching);
if (detaching) detach(each_1_anchor);
}
2019-10-03 04:13:12 +08:00
};
}
2020-05-30 21:19:58 +08:00
// (203:6) {#if requestParameters.length === 0}
function create_if_block_3(ctx) {
let p;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
p = element("p");
p.innerHTML = `<em>No configurable parameters.</em>`;
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, p, anchor);
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
p: noop,
i: noop,
o: noop,
2019-10-03 04:13:12 +08:00
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(p);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (208:8) {#each requestParameters as param}
function create_each_block_1(ctx) {
let updating_used;
let updating_value;
let current;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function fieldswitch_used_binding_1(value) {
/*fieldswitch_used_binding_1*/ ctx[26].call(null, value, /*param*/ ctx[35]);
}
function fieldswitch_value_binding_2(value) {
/*fieldswitch_value_binding_2*/ ctx[27].call(null, value, /*param*/ ctx[35]);
}
let fieldswitch_props = {
name: /*param*/ ctx[35].name,
required: /*param*/ ctx[35].required,
rounded: false
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
if (/*param*/ ctx[35].used !== void 0) {
fieldswitch_props.used = /*param*/ ctx[35].used;
}
2020-05-30 21:19:58 +08:00
if (/*param*/ ctx[35].value !== void 0) {
fieldswitch_props.value = /*param*/ ctx[35].value;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const fieldswitch = new FieldSwitch({ props: fieldswitch_props });
binding_callbacks.push(() => bind(fieldswitch, "used", fieldswitch_used_binding_1));
binding_callbacks.push(() => bind(fieldswitch, "value", fieldswitch_value_binding_2));
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
create_component(fieldswitch.$$.fragment);
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
mount_component(fieldswitch, target, anchor);
2019-10-03 04:13:12 +08:00
current = true;
},
2020-05-30 21:19:58 +08:00
p(new_ctx, dirty) {
ctx = new_ctx;
const fieldswitch_changes = {};
if (dirty[0] & /*requestParameters*/ 4) fieldswitch_changes.name = /*param*/ ctx[35].name;
if (dirty[0] & /*requestParameters*/ 4) fieldswitch_changes.required = /*param*/ ctx[35].required;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!updating_used && dirty[0] & /*requestParameters*/ 4) {
updating_used = true;
fieldswitch_changes.used = /*param*/ ctx[35].used;
add_flush_callback(() => updating_used = false);
}
if (!updating_value && dirty[0] & /*requestParameters*/ 4) {
updating_value = true;
fieldswitch_changes.value = /*param*/ ctx[35].value;
add_flush_callback(() => updating_value = false);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
fieldswitch.$set(fieldswitch_changes);
2019-10-03 04:13:12 +08:00
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(fieldswitch.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(fieldswitch.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
destroy_component(fieldswitch, detaching);
}
2019-10-03 04:13:12 +08:00
};
}
2020-05-30 21:19:58 +08:00
// (225:6) {:else}
function create_else_block$3(ctx) {
let p;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
p = element("p");
p.innerHTML = `<i>Body is only available for POST, PUT and PATCH.</i>`;
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, p, anchor);
},
2020-05-30 21:19:58 +08:00
p: noop,
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(p);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// (220:6) {#if allowBody(currentAction)}
function create_if_block_2$2(ctx) {
let textarea;
let dispose;
return {
c() {
2020-05-30 21:19:58 +08:00
textarea = element("textarea");
attr(textarea, "class", "textarea is-family-code");
attr(textarea, "rows", "8");
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, textarea, anchor);
set_input_value(textarea, /*requestBody*/ ctx[3]);
dispose = listen(textarea, "input", /*textarea_input_handler*/ ctx[28]);
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
if (dirty[0] & /*requestBody*/ 8) {
set_input_value(textarea, /*requestBody*/ ctx[3]);
}
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(textarea);
dispose();
}
};
}
2020-05-30 21:19:58 +08:00
// (265:4) {:catch error}
function create_catch_block(ctx) {
let div1;
let section1;
let section0;
let div0;
let p;
let t_value = /*error*/ ctx[30] + "";
let t;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
div1 = element("div");
section1 = element("section");
section0 = element("section");
div0 = element("div");
p = element("p");
t = text(t_value);
2020-05-30 21:19:58 +08:00
attr(p, "class", "subtitle");
attr(div0, "class", "container");
attr(section0, "class", "hero-body");
attr(section1, "class", "hero is-danger");
attr(div1, "class", "small-section svelte-c3oocm");
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, div1, anchor);
append(div1, section1);
append(section1, section0);
append(section0, div0);
append(div0, p);
append(p, t);
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
if (dirty[0] & /*response*/ 256 && t_value !== (t_value = /*error*/ ctx[30] + "")) set_data(t, t_value);
},
2020-05-30 21:19:58 +08:00
i: noop,
o: noop,
2019-10-03 04:13:12 +08:00
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(div1);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (238:4) {:then value}
function create_then_block(ctx) {
let show_if = Object.keys(/*value*/ ctx[29] || {}).length > 0;
let if_block_anchor;
let current;
let if_block = show_if && create_if_block$6(ctx);
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
if (if_block) if_block.c();
if_block_anchor = empty();
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
if (if_block) if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
current = true;
2019-10-03 04:13:12 +08:00
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
if (dirty[0] & /*response*/ 256) show_if = Object.keys(/*value*/ ctx[29] || {}).length > 0;
if (show_if) {
if (if_block) {
if_block.p(ctx, dirty);
transition_in(if_block, 1);
} else {
if_block = create_if_block$6(ctx);
if_block.c();
transition_in(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
group_outros();
transition_out(if_block, 1, 1, () => {
if_block = null;
});
check_outros();
}
},
i(local) {
if (current) return;
transition_in(if_block);
current = true;
},
o(local) {
transition_out(if_block);
current = false;
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (if_block) if_block.d(detaching);
if (detaching) detach(if_block_anchor);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (239:6) {#if Object.keys(value || {}).length > 0}
function create_if_block$6(ctx) {
let div1;
2020-05-30 21:19:58 +08:00
let section1;
let section0;
let div0;
let h1;
let t0_value = /*value*/ ctx[29].status + "";
let t0;
let t1;
2020-05-30 21:19:58 +08:00
let t2_value = /*value*/ ctx[29].statusText + "";
let t2;
2020-05-30 21:19:58 +08:00
let section1_class_value;
let t3;
2020-05-30 21:19:58 +08:00
let show_if = Object.keys(/*value*/ ctx[29].headers).length > 0;
let current;
2020-05-30 21:19:58 +08:00
let if_block = show_if && create_if_block_1$4(ctx);
2019-10-03 04:13:12 +08:00
return {
c() {
div1 = element("div");
2020-05-30 21:19:58 +08:00
section1 = element("section");
section0 = element("section");
div0 = element("div");
h1 = element("h1");
t0 = text(t0_value);
t1 = space();
2020-05-30 21:19:58 +08:00
t2 = text(t2_value);
t3 = space();
2020-05-30 21:19:58 +08:00
if (if_block) if_block.c();
attr(h1, "class", "title");
attr(div0, "class", "container has-text-centered");
attr(section0, "class", "hero-body hero-small svelte-c3oocm");
attr(section1, "class", section1_class_value = "hero hero-rounded " + colorize(/*value*/ ctx[29].status) + " svelte-c3oocm");
attr(div1, "class", "small-section svelte-c3oocm");
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
m(target, anchor) {
insert(target, div1, anchor);
append(div1, section1);
append(section1, section0);
append(section0, div0);
append(div0, h1);
append(h1, t0);
append(h1, t1);
append(h1, t2);
append(div1, t3);
2020-05-30 21:19:58 +08:00
if (if_block) if_block.m(div1, null);
2019-10-03 04:13:12 +08:00
current = true;
},
2020-05-30 21:19:58 +08:00
p(ctx, dirty) {
if ((!current || dirty[0] & /*response*/ 256) && t0_value !== (t0_value = /*value*/ ctx[29].status + "")) set_data(t0, t0_value);
if ((!current || dirty[0] & /*response*/ 256) && t2_value !== (t2_value = /*value*/ ctx[29].statusText + "")) set_data(t2, t2_value);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!current || dirty[0] & /*response*/ 256 && section1_class_value !== (section1_class_value = "hero hero-rounded " + colorize(/*value*/ ctx[29].status) + " svelte-c3oocm")) {
attr(section1, "class", section1_class_value);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (dirty[0] & /*response*/ 256) show_if = Object.keys(/*value*/ ctx[29].headers).length > 0;
if (show_if) {
if (if_block) {
if_block.p(ctx, dirty);
transition_in(if_block, 1);
} else {
2020-05-30 21:19:58 +08:00
if_block = create_if_block_1$4(ctx);
if_block.c();
transition_in(if_block, 1);
if_block.m(div1, null);
}
2020-05-30 21:19:58 +08:00
} else if (if_block) {
group_outros();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
transition_out(if_block, 1, 1, () => {
if_block = null;
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
check_outros();
2019-10-03 04:13:12 +08:00
}
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(if_block);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(if_block);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
if (detaching) detach(div1);
2020-05-30 21:19:58 +08:00
if (if_block) if_block.d();
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (249:10) {#if Object.keys(value.headers).length > 0}
function create_if_block_1$4(ctx) {
let div1;
let div0;
let t;
let current;
let each_value = Object.entries(/*value*/ ctx[29].headers);
let each_blocks = [];
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block$1(get_each_context$1(ctx, each_value, i));
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
const codeblock = new CodeBlock({
props: {
type: contentType(/*value*/ ctx[29].headers),
body: /*value*/ ctx[29].data
}
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
div1 = element("div");
div0 = element("div");
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
t = space();
create_component(codeblock.$$.fragment);
attr(div0, "class", "content-header svelte-c3oocm");
attr(div1, "class", "container container-content svelte-c3oocm");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, div1, anchor);
append(div1, div0);
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(div0, null);
}
append(div1, t);
mount_component(codeblock, div1, null);
current = true;
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
p(ctx, dirty) {
if (dirty[0] & /*response*/ 256) {
each_value = Object.entries(/*value*/ ctx[29].headers);
let i;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context$1(ctx, each_value, i);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
} else {
each_blocks[i] = create_each_block$1(child_ctx);
each_blocks[i].c();
each_blocks[i].m(div0, null);
}
}
for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
}
each_blocks.length = each_value.length;
}
const codeblock_changes = {};
if (dirty[0] & /*response*/ 256) codeblock_changes.type = contentType(/*value*/ ctx[29].headers);
if (dirty[0] & /*response*/ 256) codeblock_changes.body = /*value*/ ctx[29].data;
codeblock.$set(codeblock_changes);
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
i(local) {
if (current) return;
transition_in(codeblock.$$.fragment, local);
current = true;
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
o(local) {
transition_out(codeblock.$$.fragment, local);
current = false;
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(div1);
destroy_each(each_blocks, detaching);
destroy_component(codeblock);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (252:16) {#each Object.entries(value.headers) as [key, val]}
function create_each_block$1(ctx) {
let p;
let span;
2020-05-30 21:19:58 +08:00
let t0_value = /*key*/ ctx[31] + "";
let t0;
let t1;
2020-05-30 21:19:58 +08:00
let t2_value = /*val*/ ctx[32] + "";
let t2;
2020-05-30 21:19:58 +08:00
let t3;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
p = element("p");
2019-10-03 04:13:12 +08:00
span = element("span");
2020-05-30 21:19:58 +08:00
t0 = text(t0_value);
t1 = text("\n : ");
2019-10-03 04:13:12 +08:00
t2 = text(t2_value);
2020-05-30 21:19:58 +08:00
t3 = space();
attr(span, "class", "is-capitalized");
attr(p, "class", "is-family-code");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, p, anchor);
append(p, span);
append(span, t0);
append(p, t1);
append(p, t2);
append(p, t3);
2019-10-03 04:13:12 +08:00
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
if (dirty[0] & /*response*/ 256 && t0_value !== (t0_value = /*key*/ ctx[31] + "")) set_data(t0, t0_value);
if (dirty[0] & /*response*/ 256 && t2_value !== (t2_value = /*val*/ ctx[32] + "")) set_data(t2, t2_value);
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(p);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (232:21) <div class="section has-text-centered"> <span class="icon is-medium has-text-danger"> <i class="fas fa-2x fa-spinner fa-pulse" /> </span> </div> {:then value}
function create_pending_block(ctx) {
let div;
2019-10-03 04:13:12 +08:00
return {
c() {
div = element("div");
2020-05-30 21:19:58 +08:00
div.innerHTML = `<span class="icon is-medium has-text-danger"><i class="fas fa-2x fa-spinner fa-pulse"></i></span>`;
attr(div, "class", "section has-text-centered");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
insert(target, div, anchor);
},
2020-05-30 21:19:58 +08:00
p: noop,
i: noop,
o: noop,
2019-10-03 04:13:12 +08:00
d(detaching) {
if (detaching) detach(div);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (120:2) <div slot="body">
function create_body_slot(ctx) {
let div0;
let div3;
let div1;
let t0;
2020-05-30 21:19:58 +08:00
let div2;
let show_if_1;
let current_block_type_index;
let if_block1;
let t1;
2020-05-30 21:19:58 +08:00
let div4;
let ul;
let li0;
let a0;
let t3;
2020-05-30 21:19:58 +08:00
let li1;
let a1;
let t5;
2020-05-30 21:19:58 +08:00
let li2;
let a2;
let t7;
2020-05-30 21:19:58 +08:00
let div5;
let current_block_type_index_1;
let if_block2;
let t8;
2020-05-30 21:19:58 +08:00
let div6;
let current_block_type_index_2;
let if_block3;
let t9;
let div7;
let show_if;
let t10;
let promise;
let current;
let dispose;
function select_block_type(ctx, dirty) {
2020-05-30 21:19:58 +08:00
if (/*copying*/ ctx[10]) return create_if_block_7;
return create_else_block_4;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
let current_block_type = select_block_type(ctx, [-1]);
let if_block0 = current_block_type(ctx);
2020-05-30 21:19:58 +08:00
const if_block_creators = [create_if_block_6, create_else_block_3];
const if_blocks = [];
function select_block_type_1(ctx, dirty) {
if (dirty[0] & /*environment, $auth, $env*/ 22528) show_if_1 = !!(isAuth(/*environment*/ ctx[11], "oauth2") && !/*$auth*/ ctx[14].split(";").includes(/*$env*/ ctx[12]));
if (show_if_1) return 0;
return 1;
}
current_block_type_index = select_block_type_1(ctx, [-1]);
if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
const if_block_creators_1 = [create_if_block_4, create_else_block_2];
const if_blocks_1 = [];
function select_block_type_2(ctx, dirty) {
if (/*requestHeaders*/ ctx[0].length === 0 && !/*environment*/ ctx[11].auth) return 0;
return 1;
}
current_block_type_index_1 = select_block_type_2(ctx, [-1]);
if_block2 = if_blocks_1[current_block_type_index_1] = if_block_creators_1[current_block_type_index_1](ctx);
const if_block_creators_2 = [create_if_block_3, create_else_block_1];
const if_blocks_2 = [];
function select_block_type_3(ctx, dirty) {
if (/*requestParameters*/ ctx[2].length === 0) return 0;
return 1;
}
current_block_type_index_2 = select_block_type_3(ctx, [-1]);
if_block3 = if_blocks_2[current_block_type_index_2] = if_block_creators_2[current_block_type_index_2](ctx);
function select_block_type_4(ctx, dirty) {
if (show_if == null || dirty[0] & /*currentAction*/ 64) show_if = !!allowBody(/*currentAction*/ ctx[6]);
if (show_if) return create_if_block_2$2;
return create_else_block$3;
}
let current_block_type_1 = select_block_type_4(ctx, [-1]);
let if_block4 = current_block_type_1(ctx);
let info = {
ctx,
current: null,
token: null,
pending: create_pending_block,
then: create_then_block,
catch: create_catch_block,
value: 29,
error: 30,
blocks: [,,,]
};
handle_promise(promise = /*response*/ ctx[8], info);
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
div0 = element("div");
div3 = element("div");
div1 = element("div");
if_block0.c();
t0 = space();
div2 = element("div");
if_block1.c();
2019-10-03 04:13:12 +08:00
t1 = space();
2020-05-30 21:19:58 +08:00
div4 = element("div");
ul = element("ul");
li0 = element("li");
a0 = element("a");
a0.textContent = "Headers";
2019-10-03 04:13:12 +08:00
t3 = space();
2020-05-30 21:19:58 +08:00
li1 = element("li");
a1 = element("a");
a1.textContent = "Parameters";
2019-10-03 04:13:12 +08:00
t5 = space();
2020-05-30 21:19:58 +08:00
li2 = element("li");
a2 = element("a");
a2.textContent = "Body";
2019-10-03 04:13:12 +08:00
t7 = space();
2020-05-30 21:19:58 +08:00
div5 = element("div");
if_block2.c();
2019-10-03 04:13:12 +08:00
t8 = space();
2020-05-30 21:19:58 +08:00
div6 = element("div");
if_block3.c();
t9 = space();
div7 = element("div");
if_block4.c();
t10 = space();
info.block.c();
attr(div1, "class", "column");
attr(div2, "class", "column is-one-fifth");
attr(div3, "class", "columns");
attr(a0, "href", "javascript:void(0)");
toggle_class(li0, "is-active", /*requestTab*/ ctx[9] === 0);
attr(a1, "href", "javascript:void(0)");
toggle_class(li1, "is-active", /*requestTab*/ ctx[9] === 1);
attr(a2, "href", "javascript:void(0)");
toggle_class(li2, "is-active", /*requestTab*/ ctx[9] === 2);
attr(div4, "class", "tabs is-boxed");
attr(div5, "class", "section-headers");
toggle_class(div5, "is-hidden", /*requestTab*/ ctx[9] != 0);
attr(div6, "class", "section-parameters");
toggle_class(div6, "is-hidden", /*requestTab*/ ctx[9] != 1);
attr(div7, "class", "section-body");
toggle_class(div7, "is-hidden", /*requestTab*/ ctx[9] != 2);
attr(div0, "slot", "body");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, div0, anchor);
append(div0, div3);
append(div3, div1);
if_block0.m(div1, null);
append(div3, t0);
append(div3, div2);
if_blocks[current_block_type_index].m(div2, null);
append(div0, t1);
append(div0, div4);
append(div4, ul);
append(ul, li0);
append(li0, a0);
append(ul, t3);
append(ul, li1);
append(li1, a1);
append(ul, t5);
append(ul, li2);
append(li2, a2);
append(div0, t7);
append(div0, div5);
if_blocks_1[current_block_type_index_1].m(div5, null);
append(div0, t8);
append(div0, div6);
if_blocks_2[current_block_type_index_2].m(div6, null);
append(div0, t9);
append(div0, div7);
if_block4.m(div7, null);
append(div0, t10);
info.block.m(div0, info.anchor = null);
info.mount = () => div0;
info.anchor = null;
current = true;
dispose = [
listen(a0, "click", /*click_handler*/ ctx[20]),
listen(a1, "click", /*click_handler_1*/ ctx[21]),
listen(a2, "click", /*click_handler_2*/ ctx[22])
];
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
p(new_ctx, dirty) {
ctx = new_ctx;
if (current_block_type === (current_block_type = select_block_type(ctx, dirty)) && if_block0) {
if_block0.p(ctx, dirty);
} else {
if_block0.d(1);
if_block0 = current_block_type(ctx);
if (if_block0) {
if_block0.c();
if_block0.m(div1, null);
}
}
let previous_block_index = current_block_type_index;
current_block_type_index = select_block_type_1(ctx, dirty);
if (current_block_type_index === previous_block_index) {
if_blocks[current_block_type_index].p(ctx, dirty);
} else {
group_outros();
transition_out(if_blocks[previous_block_index], 1, 1, () => {
if_blocks[previous_block_index] = null;
});
check_outros();
if_block1 = if_blocks[current_block_type_index];
if (!if_block1) {
if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
if_block1.c();
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
transition_in(if_block1, 1);
if_block1.m(div2, null);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (dirty[0] & /*requestTab*/ 512) {
toggle_class(li0, "is-active", /*requestTab*/ ctx[9] === 0);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (dirty[0] & /*requestTab*/ 512) {
toggle_class(li1, "is-active", /*requestTab*/ ctx[9] === 1);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (dirty[0] & /*requestTab*/ 512) {
toggle_class(li2, "is-active", /*requestTab*/ ctx[9] === 2);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
let previous_block_index_1 = current_block_type_index_1;
current_block_type_index_1 = select_block_type_2(ctx, dirty);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (current_block_type_index_1 === previous_block_index_1) {
if_blocks_1[current_block_type_index_1].p(ctx, dirty);
} else {
group_outros();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
transition_out(if_blocks_1[previous_block_index_1], 1, 1, () => {
if_blocks_1[previous_block_index_1] = null;
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
check_outros();
if_block2 = if_blocks_1[current_block_type_index_1];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!if_block2) {
if_block2 = if_blocks_1[current_block_type_index_1] = if_block_creators_1[current_block_type_index_1](ctx);
if_block2.c();
}
2020-05-30 21:19:58 +08:00
transition_in(if_block2, 1);
if_block2.m(div5, null);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty[0] & /*requestTab*/ 512) {
toggle_class(div5, "is-hidden", /*requestTab*/ ctx[9] != 0);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
let previous_block_index_2 = current_block_type_index_2;
current_block_type_index_2 = select_block_type_3(ctx, dirty);
2020-05-30 21:19:58 +08:00
if (current_block_type_index_2 === previous_block_index_2) {
if_blocks_2[current_block_type_index_2].p(ctx, dirty);
} else {
group_outros();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
transition_out(if_blocks_2[previous_block_index_2], 1, 1, () => {
if_blocks_2[previous_block_index_2] = null;
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
check_outros();
if_block3 = if_blocks_2[current_block_type_index_2];
if (!if_block3) {
if_block3 = if_blocks_2[current_block_type_index_2] = if_block_creators_2[current_block_type_index_2](ctx);
if_block3.c();
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
transition_in(if_block3, 1);
if_block3.m(div6, null);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (dirty[0] & /*requestTab*/ 512) {
toggle_class(div6, "is-hidden", /*requestTab*/ ctx[9] != 1);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (current_block_type_1 === (current_block_type_1 = select_block_type_4(ctx, dirty)) && if_block4) {
if_block4.p(ctx, dirty);
} else {
if_block4.d(1);
if_block4 = current_block_type_1(ctx);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (if_block4) {
if_block4.c();
if_block4.m(div7, null);
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty[0] & /*requestTab*/ 512) {
toggle_class(div7, "is-hidden", /*requestTab*/ ctx[9] != 2);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
info.ctx = ctx;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty[0] & /*response*/ 256 && promise !== (promise = /*response*/ ctx[8]) && handle_promise(promise, info)) {
} else {
const child_ctx = ctx.slice();
child_ctx[29] = info.resolved;
info.block.p(child_ctx, dirty);
}
2019-10-03 04:13:12 +08:00
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(if_block1);
transition_in(if_block2);
transition_in(if_block3);
transition_in(info.block);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(if_block1);
transition_out(if_block2);
transition_out(if_block3);
for (let i = 0; i < 3; i += 1) {
const block = info.blocks[i];
transition_out(block);
}
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(div0);
if_block0.d();
if_blocks[current_block_type_index].d();
if_blocks_1[current_block_type_index_1].d();
if_blocks_2[current_block_type_index_2].d();
if_block4.d();
info.block.d();
info.token = null;
info = null;
run_all(dispose);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (118:0) <CollapsiblePanel dark={true} {isDarkmode} {show}>
function create_default_slot(ctx) {
let t;
let current;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
t = space();
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, t, anchor);
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
p: noop,
i: noop,
o: noop,
2019-10-03 04:13:12 +08:00
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(t);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function create_fragment$c(ctx) {
let current;
2020-05-30 21:19:58 +08:00
const collapsiblepanel = new CollapsiblePanel({
props: {
dark: true,
isDarkmode: /*isDarkmode*/ ctx[5],
show: /*show*/ ctx[4],
$$slots: {
default: [create_default_slot],
body: [create_body_slot],
heading: [create_heading_slot]
},
$$scope: { ctx }
}
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
create_component(collapsiblepanel.$$.fragment);
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
mount_component(collapsiblepanel, target, anchor);
2019-10-03 04:13:12 +08:00
current = true;
},
2020-05-30 21:19:58 +08:00
p(ctx, dirty) {
const collapsiblepanel_changes = {};
if (dirty[0] & /*isDarkmode*/ 32) collapsiblepanel_changes.isDarkmode = /*isDarkmode*/ ctx[5];
if (dirty[0] & /*show*/ 16) collapsiblepanel_changes.show = /*show*/ ctx[4];
2020-05-30 21:19:58 +08:00
if (dirty[0] & /*response, requestTab, requestBody, currentAction, requestParameters, requestHeaders, environment, requestAuthHeader, pkceChallenge, $auth, $env, copying, currentUrl*/ 32719 | dirty[1] & /*$$scope*/ 1024) {
collapsiblepanel_changes.$$scope = { dirty, ctx };
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
collapsiblepanel.$set(collapsiblepanel_changes);
2019-10-03 04:13:12 +08:00
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(collapsiblepanel.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(collapsiblepanel.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
destroy_component(collapsiblepanel, detaching);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function contentType(headers) {
return headers && headers["content-type"];
}
function basicAuth$1(username, password) {
return btoa(`${username}:${password}`);
}
function instance$c($$self, $$props, $$invalidate) {
let $env;
let $router;
let $auth;
component_subscribe($$self, env, $$value => $$invalidate(12, $env = $$value));
component_subscribe($$self, router, $$value => $$invalidate(19, $router = $$value));
component_subscribe($$self, auth, $$value => $$invalidate(14, $auth = $$value));
let { show = true } = $$props;
let { isDarkmode } = $$props;
let { environments } = $$props;
let { currentAction } = $$props;
let { requestHeaders } = $$props;
let { requestAuthHeader } = $$props;
let { requestParameters } = $$props;
let { requestBody } = $$props;
let { pkceChallenge } = $$props;
let response;
let requestTab = 0;
let copying = false;
function handleClick() {
$$invalidate(8, response = sendRequest($env, environment, currentAction, {
headers: requestHeaders.concat(requestAuthHeader),
parameters: requestParameters,
body: requestBody
}));
}
function handleTab(index) {
$$invalidate(9, requestTab = index);
}
function handleCopy() {
$$invalidate(10, copying = true);
setTimeout(
() => {
$$invalidate(10, copying = false);
},
2000
);
copyUrl(currentUrl, requestParameters);
}
const click_handler = () => handleTab(0);
const click_handler_1 = () => handleTab(1);
const click_handler_2 = () => handleTab(2);
function fieldswitch_used_binding(value, header) {
header.used = value;
$$invalidate(0, requestHeaders);
}
function fieldswitch_value_binding(value, header) {
header.value = value;
$$invalidate(0, requestHeaders);
}
function fieldswitch_value_binding_1(value) {
requestAuthHeader.value = value;
$$invalidate(1, requestAuthHeader);
}
function fieldswitch_used_binding_1(value, param) {
param.used = value;
$$invalidate(2, requestParameters);
}
function fieldswitch_value_binding_2(value, param) {
param.value = value;
$$invalidate(2, requestParameters);
}
function textarea_input_handler() {
requestBody = this.value;
$$invalidate(3, requestBody);
}
2019-10-03 04:13:12 +08:00
$$self.$set = $$props => {
2020-05-30 21:19:58 +08:00
if ("show" in $$props) $$invalidate(4, show = $$props.show);
if ("isDarkmode" in $$props) $$invalidate(5, isDarkmode = $$props.isDarkmode);
if ("environments" in $$props) $$invalidate(18, environments = $$props.environments);
if ("currentAction" in $$props) $$invalidate(6, currentAction = $$props.currentAction);
if ("requestHeaders" in $$props) $$invalidate(0, requestHeaders = $$props.requestHeaders);
if ("requestAuthHeader" in $$props) $$invalidate(1, requestAuthHeader = $$props.requestAuthHeader);
if ("requestParameters" in $$props) $$invalidate(2, requestParameters = $$props.requestParameters);
if ("requestBody" in $$props) $$invalidate(3, requestBody = $$props.requestBody);
if ("pkceChallenge" in $$props) $$invalidate(7, pkceChallenge = $$props.pkceChallenge);
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
let environment;
let currentUrl;
2019-10-03 04:13:12 +08:00
$$self.$$.update = () => {
2020-05-30 21:19:58 +08:00
if ($$self.$$.dirty[0] & /*environments, $env*/ 266240) {
$$invalidate(11, environment = environments[$env]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if ($$self.$$.dirty[0] & /*environment, currentAction*/ 2112) {
$$invalidate(13, currentUrl = urlParse(urlJoin(environment.url, currentAction.path)));
}
if ($$self.$$.dirty[0] & /*$router*/ 524288) {
$$invalidate(8, response = $router && undefined);
}
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
return [
requestHeaders,
requestAuthHeader,
requestParameters,
requestBody,
show,
isDarkmode,
currentAction,
pkceChallenge,
response,
requestTab,
copying,
environment,
$env,
currentUrl,
$auth,
handleClick,
handleTab,
handleCopy,
environments,
$router,
click_handler,
click_handler_1,
click_handler_2,
fieldswitch_used_binding,
fieldswitch_value_binding,
fieldswitch_value_binding_1,
fieldswitch_used_binding_1,
fieldswitch_value_binding_2,
textarea_input_handler
];
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
class PlaygroundPanel extends SvelteComponent {
2019-10-03 04:13:12 +08:00
constructor(options) {
super();
2020-05-30 21:19:58 +08:00
if (!document.getElementById("svelte-c3oocm-style")) add_css$6();
init(
this,
options,
instance$c,
create_fragment$c,
safe_not_equal,
{
show: 4,
isDarkmode: 5,
environments: 18,
currentAction: 6,
requestHeaders: 0,
requestAuthHeader: 1,
requestParameters: 2,
requestBody: 3,
pkceChallenge: 7
},
[-1, -1]
);
2019-10-03 04:13:12 +08:00
}
}
2020-05-30 21:19:58 +08:00
/* usr/local/lib/node_modules/snowboard/templates/winter/tables/HeaderTable.svelte generated by Svelte v3.19.2 */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function get_each_context$2(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[1] = list[i].name;
child_ctx[2] = list[i].example;
return child_ctx;
}
// (5:0) {#if headers.length > 0}
function create_if_block$7(ctx) {
let table;
let thead;
let t1;
let tbody;
let each_value = /*headers*/ ctx[0];
let each_blocks = [];
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block$2(get_each_context$2(ctx, each_value, i));
}
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
table = element("table");
thead = element("thead");
thead.innerHTML = `<tr><th colspan="2">Headers</th></tr>`;
t1 = space();
tbody = element("tbody");
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
attr(table, "class", "table is-stripped is-fullwidth");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, table, anchor);
append(table, thead);
append(table, t1);
append(table, tbody);
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(tbody, null);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
},
p(ctx, dirty) {
if (dirty & /*headers*/ 1) {
each_value = /*headers*/ ctx[0];
let i;
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context$2(ctx, each_value, i);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
} else {
each_blocks[i] = create_each_block$2(child_ctx);
each_blocks[i].c();
each_blocks[i].m(tbody, null);
}
}
for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
}
each_blocks.length = each_value.length;
2019-10-03 04:13:12 +08:00
}
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(table);
destroy_each(each_blocks, detaching);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (13:6) {#each headers as { name, example }}
function create_each_block$2(ctx) {
let tr;
let td0;
let t0_value = /*name*/ ctx[1] + "";
let t0;
let t1;
let td1;
let code;
let t2_value = /*example*/ ctx[2] + "";
let t2;
let t3;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
tr = element("tr");
td0 = element("td");
t0 = text(t0_value);
t1 = space();
td1 = element("td");
code = element("code");
t2 = text(t2_value);
t3 = space();
},
m(target, anchor) {
insert(target, tr, anchor);
append(tr, td0);
append(td0, t0);
append(tr, t1);
append(tr, td1);
append(td1, code);
append(code, t2);
append(tr, t3);
},
p(ctx, dirty) {
if (dirty & /*headers*/ 1 && t0_value !== (t0_value = /*name*/ ctx[1] + "")) set_data(t0, t0_value);
if (dirty & /*headers*/ 1 && t2_value !== (t2_value = /*example*/ ctx[2] + "")) set_data(t2, t2_value);
},
d(detaching) {
if (detaching) detach(tr);
}
2019-10-03 04:13:12 +08:00
};
}
2020-05-30 21:19:58 +08:00
function create_fragment$d(ctx) {
let if_block_anchor;
let if_block = /*headers*/ ctx[0].length > 0 && create_if_block$7(ctx);
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
if (if_block) if_block.c();
if_block_anchor = empty();
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
if (if_block) if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
},
p(ctx, [dirty]) {
if (/*headers*/ ctx[0].length > 0) {
if (if_block) {
if_block.p(ctx, dirty);
} else {
if_block = create_if_block$7(ctx);
if_block.c();
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
2019-10-03 04:13:12 +08:00
},
i: noop,
o: noop,
d(detaching) {
2020-05-30 21:19:58 +08:00
if (if_block) if_block.d(detaching);
if (detaching) detach(if_block_anchor);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function instance$d($$self, $$props, $$invalidate) {
let { headers = [] } = $$props;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$set = $$props => {
if ("headers" in $$props) $$invalidate(0, headers = $$props.headers);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return [headers];
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
class HeaderTable extends SvelteComponent {
2019-10-03 04:13:12 +08:00
constructor(options) {
super();
2020-05-30 21:19:58 +08:00
init(this, options, instance$d, create_fragment$d, safe_not_equal, { headers: 0 });
2019-10-03 04:13:12 +08:00
}
}
2020-05-30 21:19:58 +08:00
/* usr/local/lib/node_modules/snowboard/templates/winter/panels/CodePanel.svelte generated by Svelte v3.19.2 */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function add_css$7() {
2019-10-03 04:13:12 +08:00
var style = element("style");
2020-05-30 21:19:58 +08:00
style.id = "svelte-15v28ah-style";
style.textContent = ".tab-content.svelte-15v28ah{display:none}.tab-content.is-active.svelte-15v28ah{display:block}";
2019-10-03 04:13:12 +08:00
append(document.head, style);
}
2020-05-30 21:19:58 +08:00
// (32:0) {#if example || schema}
function create_if_block$8(ctx) {
let div2;
let div0;
let ul;
let li;
let a;
let t1;
let t2;
let div1;
let section;
let section_class_value;
let t3;
let current;
2020-05-30 21:19:58 +08:00
let dispose;
let if_block0 = /*schema*/ ctx[2] && create_if_block_2$3(ctx);
2020-05-30 21:19:58 +08:00
const codeblock = new CodeBlock({
props: {
type: /*contentType*/ ctx[0],
body: /*example*/ ctx[1]
}
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
let if_block1 = /*schema*/ ctx[2] && create_if_block_1$5(ctx);
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
div2 = element("div");
div0 = element("div");
ul = element("ul");
li = element("li");
a = element("a");
a.textContent = "Body";
t1 = space();
if (if_block0) if_block0.c();
t2 = space();
div1 = element("div");
section = element("section");
create_component(codeblock.$$.fragment);
t3 = space();
if (if_block1) if_block1.c();
attr(a, "data-index", "0");
attr(a, "href", "javascript:void(0)");
toggle_class(li, "is-active", /*tabIndex*/ ctx[7] === 0);
attr(div0, "class", "tabs is-fullwidth");
toggle_class(div0, "is-toggle", /*asToggle*/ ctx[3]);
attr(section, "class", section_class_value = "tab-content " + /*activeBody*/ ctx[5] + " svelte-15v28ah");
attr(div2, "class", "tabs-with-content");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, div2, anchor);
append(div2, div0);
append(div0, ul);
append(ul, li);
append(li, a);
append(ul, t1);
if (if_block0) if_block0.m(ul, null);
append(div2, t2);
append(div2, div1);
append(div1, section);
mount_component(codeblock, section, null);
append(div1, t3);
if (if_block1) if_block1.m(div1, null);
2019-10-03 04:13:12 +08:00
current = true;
2020-05-30 21:19:58 +08:00
dispose = listen(a, "click", /*tabSelect*/ ctx[4]);
2019-10-03 04:13:12 +08:00
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
if (dirty & /*tabIndex*/ 128) {
toggle_class(li, "is-active", /*tabIndex*/ ctx[7] === 0);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (/*schema*/ ctx[2]) {
if (if_block0) {
if_block0.p(ctx, dirty);
} else {
if_block0 = create_if_block_2$3(ctx);
if_block0.c();
if_block0.m(ul, null);
}
} else if (if_block0) {
if_block0.d(1);
if_block0 = null;
}
2020-05-30 21:19:58 +08:00
if (dirty & /*asToggle*/ 8) {
toggle_class(div0, "is-toggle", /*asToggle*/ ctx[3]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const codeblock_changes = {};
if (dirty & /*contentType*/ 1) codeblock_changes.type = /*contentType*/ ctx[0];
if (dirty & /*example*/ 2) codeblock_changes.body = /*example*/ ctx[1];
codeblock.$set(codeblock_changes);
2020-05-30 21:19:58 +08:00
if (!current || dirty & /*activeBody*/ 32 && section_class_value !== (section_class_value = "tab-content " + /*activeBody*/ ctx[5] + " svelte-15v28ah")) {
attr(section, "class", section_class_value);
}
if (/*schema*/ ctx[2]) {
if (if_block1) {
if_block1.p(ctx, dirty);
transition_in(if_block1, 1);
} else {
if_block1 = create_if_block_1$5(ctx);
if_block1.c();
transition_in(if_block1, 1);
if_block1.m(div1, null);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
} else if (if_block1) {
group_outros();
2020-05-30 21:19:58 +08:00
transition_out(if_block1, 1, 1, () => {
if_block1 = null;
});
check_outros();
2019-10-03 04:13:12 +08:00
}
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(codeblock.$$.fragment, local);
transition_in(if_block1);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(codeblock.$$.fragment, local);
transition_out(if_block1);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(div2);
if (if_block0) if_block0.d();
destroy_component(codeblock);
if (if_block1) if_block1.d();
dispose();
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (42:8) {#if schema}
function create_if_block_2$3(ctx) {
let li;
let a;
let dispose;
return {
c() {
li = element("li");
a = element("a");
a.textContent = "Schema";
attr(a, "data-index", "1");
attr(a, "href", "javascript:void(0)");
toggle_class(li, "is-active", /*tabIndex*/ ctx[7] === 1);
},
m(target, anchor) {
insert(target, li, anchor);
append(li, a);
dispose = listen(a, "click", /*tabSelect*/ ctx[4]);
},
p(ctx, dirty) {
if (dirty & /*tabIndex*/ 128) {
toggle_class(li, "is-active", /*tabIndex*/ ctx[7] === 1);
}
},
d(detaching) {
if (detaching) detach(li);
dispose();
}
};
}
// (55:6) {#if schema}
function create_if_block_1$5(ctx) {
let section;
let section_class_value;
let current;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const codeblock = new CodeBlock({
props: {
2020-05-30 21:19:58 +08:00
type: "application/json",
body: /*schema*/ ctx[2]
}
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
section = element("section");
create_component(codeblock.$$.fragment);
attr(section, "class", section_class_value = "tab-content " + /*activeSchema*/ ctx[6] + " svelte-15v28ah");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, section, anchor);
mount_component(codeblock, section, null);
2019-10-03 04:13:12 +08:00
current = true;
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
const codeblock_changes = {};
if (dirty & /*schema*/ 4) codeblock_changes.body = /*schema*/ ctx[2];
codeblock.$set(codeblock_changes);
if (!current || dirty & /*activeSchema*/ 64 && section_class_value !== (section_class_value = "tab-content " + /*activeSchema*/ ctx[6] + " svelte-15v28ah")) {
attr(section, "class", section_class_value);
}
2019-10-03 04:13:12 +08:00
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(codeblock.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(codeblock.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(section);
destroy_component(codeblock);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function create_fragment$e(ctx) {
let if_block_anchor;
let current;
2020-05-30 21:19:58 +08:00
let if_block = (/*example*/ ctx[1] || /*schema*/ ctx[2]) && create_if_block$8(ctx);
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
if (if_block) if_block.c();
if_block_anchor = empty();
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
if (if_block) if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
2019-10-03 04:13:12 +08:00
current = true;
},
2020-05-30 21:19:58 +08:00
p(ctx, [dirty]) {
if (/*example*/ ctx[1] || /*schema*/ ctx[2]) {
if (if_block) {
if_block.p(ctx, dirty);
transition_in(if_block, 1);
} else {
if_block = create_if_block$8(ctx);
if_block.c();
transition_in(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
group_outros();
transition_out(if_block, 1, 1, () => {
if_block = null;
});
check_outros();
}
},
2019-10-03 04:13:12 +08:00
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(if_block);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(if_block);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (if_block) if_block.d(detaching);
if (detaching) detach(if_block_anchor);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function instance$e($$self, $$props, $$invalidate) {
let { contentType } = $$props;
let { example } = $$props;
let { schema } = $$props;
let { asToggle } = $$props;
let activeBody = "is-active";
let activeSchema = "";
let tabIndex = 0;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const tabSelect = event => {
const index = event.target.dataset["index"];
$$invalidate(7, tabIndex = parseInt(index, 10));
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
$$self.$set = $$props => {
if ("contentType" in $$props) $$invalidate(0, contentType = $$props.contentType);
if ("example" in $$props) $$invalidate(1, example = $$props.example);
if ("schema" in $$props) $$invalidate(2, schema = $$props.schema);
if ("asToggle" in $$props) $$invalidate(3, asToggle = $$props.asToggle);
};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$$.update = () => {
if ($$self.$$.dirty & /*tabIndex*/ 128) {
$$invalidate(5, activeBody = tabIndex === 0 ? "is-active" : "");
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if ($$self.$$.dirty & /*tabIndex*/ 128) {
$$invalidate(6, activeSchema = tabIndex === 1 ? "is-active" : "");
2019-10-03 04:13:12 +08:00
}
};
2020-05-30 21:19:58 +08:00
return [
contentType,
example,
schema,
asToggle,
tabSelect,
activeBody,
activeSchema,
tabIndex
];
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
class CodePanel extends SvelteComponent {
constructor(options) {
super();
if (!document.getElementById("svelte-15v28ah-style")) add_css$7();
init(this, options, instance$e, create_fragment$e, safe_not_equal, {
contentType: 0,
example: 1,
schema: 2,
asToggle: 3,
tabSelect: 4
});
}
get tabSelect() {
return this.$$.ctx[4];
}
}
/* usr/local/lib/node_modules/snowboard/templates/winter/panels/RequestPanel.svelte generated by Svelte v3.19.2 */
function create_if_block_1$6(ctx) {
let div;
let raw_value = markdown(/*description*/ ctx[0]) + "";
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
div = element("div");
attr(div, "class", "content");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, div, anchor);
div.innerHTML = raw_value;
},
p(ctx, dirty) {
if (dirty & /*description*/ 1 && raw_value !== (raw_value = markdown(/*description*/ ctx[0]) + "")) div.innerHTML = raw_value;;
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(div);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (26:0) {#if showRequest}
2019-10-03 04:13:12 +08:00
function create_if_block$9(ctx) {
2020-05-30 21:19:58 +08:00
let hr;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
hr = element("hr");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, hr, anchor);
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(hr);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function create_fragment$f(ctx) {
let t0;
let t1;
let t2;
2020-05-30 21:19:58 +08:00
let if_block1_anchor;
let current;
2020-05-30 21:19:58 +08:00
let if_block0 = /*description*/ ctx[0] && create_if_block_1$6(ctx);
const headertable = new HeaderTable({ props: { headers: /*headers*/ ctx[1] } });
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const codepanel = new CodePanel({
props: {
contentType: /*contentType*/ ctx[2],
example: /*example*/ ctx[3],
schema: /*schema*/ ctx[4],
asToggle: true
}
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
let if_block1 = /*showRequest*/ ctx[5] && create_if_block$9(ctx);
2019-10-03 04:13:12 +08:00
return {
c() {
if (if_block0) if_block0.c();
t0 = space();
2020-05-30 21:19:58 +08:00
create_component(headertable.$$.fragment);
t1 = space();
create_component(codepanel.$$.fragment);
2019-10-03 04:13:12 +08:00
t2 = space();
2020-05-30 21:19:58 +08:00
if (if_block1) if_block1.c();
if_block1_anchor = empty();
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
if (if_block0) if_block0.m(target, anchor);
insert(target, t0, anchor);
2020-05-30 21:19:58 +08:00
mount_component(headertable, target, anchor);
insert(target, t1, anchor);
mount_component(codepanel, target, anchor);
insert(target, t2, anchor);
if (if_block1) if_block1.m(target, anchor);
insert(target, if_block1_anchor, anchor);
2019-10-03 04:13:12 +08:00
current = true;
},
p(ctx, [dirty]) {
2020-05-30 21:19:58 +08:00
if (/*description*/ ctx[0]) {
2019-10-03 04:13:12 +08:00
if (if_block0) {
if_block0.p(ctx, dirty);
2019-10-03 04:13:12 +08:00
} else {
if_block0 = create_if_block_1$6(ctx);
if_block0.c();
if_block0.m(t0.parentNode, t0);
}
} else if (if_block0) {
2020-05-30 21:19:58 +08:00
if_block0.d(1);
if_block0 = null;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
const headertable_changes = {};
if (dirty & /*headers*/ 2) headertable_changes.headers = /*headers*/ ctx[1];
headertable.$set(headertable_changes);
const codepanel_changes = {};
if (dirty & /*contentType*/ 4) codepanel_changes.contentType = /*contentType*/ ctx[2];
if (dirty & /*example*/ 8) codepanel_changes.example = /*example*/ ctx[3];
if (dirty & /*schema*/ 16) codepanel_changes.schema = /*schema*/ ctx[4];
codepanel.$set(codepanel_changes);
2020-05-30 21:19:58 +08:00
if (/*showRequest*/ ctx[5]) {
if (!if_block1) {
if_block1 = create_if_block$9(ctx);
2019-10-03 04:13:12 +08:00
if_block1.c();
2020-05-30 21:19:58 +08:00
if_block1.m(if_block1_anchor.parentNode, if_block1_anchor);
} else {
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
} else if (if_block1) {
if_block1.d(1);
if_block1 = null;
2019-10-03 04:13:12 +08:00
}
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(headertable.$$.fragment, local);
transition_in(codepanel.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(headertable.$$.fragment, local);
transition_out(codepanel.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
if (if_block0) if_block0.d(detaching);
if (detaching) detach(t0);
2020-05-30 21:19:58 +08:00
destroy_component(headertable, detaching);
if (detaching) detach(t1);
destroy_component(codepanel, detaching);
if (detaching) detach(t2);
if (if_block1) if_block1.d(detaching);
if (detaching) detach(if_block1_anchor);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function instance$f($$self, $$props, $$invalidate) {
let { description } = $$props;
let { headers } = $$props;
let { contentType } = $$props;
let { example } = $$props;
let { schema } = $$props;
2019-10-03 04:13:12 +08:00
$$self.$set = $$props => {
2020-05-30 21:19:58 +08:00
if ("description" in $$props) $$invalidate(0, description = $$props.description);
if ("headers" in $$props) $$invalidate(1, headers = $$props.headers);
if ("contentType" in $$props) $$invalidate(2, contentType = $$props.contentType);
if ("example" in $$props) $$invalidate(3, example = $$props.example);
if ("schema" in $$props) $$invalidate(4, schema = $$props.schema);
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
let showRequest;
2019-10-03 04:13:12 +08:00
$$self.$$.update = () => {
2020-05-30 21:19:58 +08:00
if ($$self.$$.dirty & /*description, headers, example*/ 11) {
$$invalidate(5, showRequest = !!(description || headers.length !== 0 || example));
}
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
return [description, headers, contentType, example, schema, showRequest];
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
class RequestPanel extends SvelteComponent {
2019-10-03 04:13:12 +08:00
constructor(options) {
super();
2020-05-30 21:19:58 +08:00
init(this, options, instance$f, create_fragment$f, safe_not_equal, {
description: 0,
headers: 1,
contentType: 2,
example: 3,
schema: 4
});
2019-10-03 04:13:12 +08:00
}
}
2020-05-30 21:19:58 +08:00
/* usr/local/lib/node_modules/snowboard/templates/winter/panels/ResponsePanel.svelte generated by Svelte v3.19.2 */
function create_else_block$4(ctx) {
let t_value = (/*contentType*/ ctx[4] || "Response") + "";
let t;
return {
c() {
t = text(t_value);
},
m(target, anchor) {
insert(target, t, anchor);
},
p(ctx, dirty) {
if (dirty & /*contentType*/ 16 && t_value !== (t_value = (/*contentType*/ ctx[4] || "Response") + "")) set_data(t, t_value);
},
d(detaching) {
if (detaching) detach(t);
}
};
}
// (19:6) {#if title}
function create_if_block_2$4(ctx) {
let t0;
let t1;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
t0 = text("Response ");
t1 = text(/*title*/ ctx[0]);
},
m(target, anchor) {
insert(target, t0, anchor);
insert(target, t1, anchor);
},
p(ctx, dirty) {
if (dirty & /*title*/ 1) set_data(t1, /*title*/ ctx[0]);
},
d(detaching) {
if (detaching) detach(t0);
if (detaching) detach(t1);
}
};
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
// (23:6) {#if title !== ''}
function create_if_block_1$7(ctx) {
let span;
2020-05-30 21:19:58 +08:00
let t_value = (/*contentType*/ ctx[4] || "") + "";
let t;
2019-10-03 04:13:12 +08:00
return {
c() {
span = element("span");
2020-05-30 21:19:58 +08:00
t = text(t_value);
attr(span, "class", "tag is-medium is-white");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
insert(target, span, anchor);
2020-05-30 21:19:58 +08:00
append(span, t);
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
p(ctx, dirty) {
if (dirty & /*contentType*/ 16 && t_value !== (t_value = (/*contentType*/ ctx[4] || "") + "")) set_data(t, t_value);
2019-10-03 04:13:12 +08:00
},
d(detaching) {
if (detaching) detach(span);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (30:4) {#if description}
function create_if_block$a(ctx) {
let div;
let raw_value = markdown(/*description*/ ctx[1]) + "";
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
div = element("div");
attr(div, "class", "content");
},
m(target, anchor) {
insert(target, div, anchor);
div.innerHTML = raw_value;
},
p(ctx, dirty) {
if (dirty & /*description*/ 2 && raw_value !== (raw_value = markdown(/*description*/ ctx[1]) + "")) div.innerHTML = raw_value;;
},
d(detaching) {
if (detaching) detach(div);
}
2019-10-03 04:13:12 +08:00
};
}
2020-05-30 21:19:58 +08:00
function create_fragment$g(ctx) {
let div1;
let header;
let p;
let t0;
2020-05-30 21:19:58 +08:00
let a;
let t1;
2020-05-30 21:19:58 +08:00
let code;
let t2;
let code_class_value;
let t3;
let div0;
let t4;
let t5;
let current;
2020-05-30 21:19:58 +08:00
function select_block_type(ctx, dirty) {
if (/*title*/ ctx[0]) return create_if_block_2$4;
return create_else_block$4;
}
let current_block_type = select_block_type(ctx, -1);
let if_block0 = current_block_type(ctx);
let if_block1 = /*title*/ ctx[0] !== "" && create_if_block_1$7(ctx);
let if_block2 = /*description*/ ctx[1] && create_if_block$a(ctx);
const headertable = new HeaderTable({ props: { headers: /*headers*/ ctx[2] } });
const codepanel = new CodePanel({
props: {
2020-05-30 21:19:58 +08:00
contentType: /*contentType*/ ctx[4],
example: /*example*/ ctx[5],
schema: /*schema*/ ctx[6]
}
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
div1 = element("div");
header = element("header");
p = element("p");
if_block0.c();
2019-10-03 04:13:12 +08:00
t0 = space();
2020-05-30 21:19:58 +08:00
a = element("a");
if (if_block1) if_block1.c();
2019-10-03 04:13:12 +08:00
t1 = space();
2020-05-30 21:19:58 +08:00
code = element("code");
t2 = text(/*statusCode*/ ctx[3]);
t3 = space();
div0 = element("div");
if (if_block2) if_block2.c();
t4 = space();
create_component(headertable.$$.fragment);
t5 = space();
create_component(codepanel.$$.fragment);
attr(p, "class", "card-header-title");
attr(code, "class", code_class_value = "tag is-medium " + colorize(/*statusCode*/ ctx[3]));
attr(a, "href", "javascript:void(0)");
attr(a, "class", "card-header-icon is-family-code");
attr(header, "class", "card-header");
attr(div0, "class", "card-content");
attr(div1, "class", "card");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, div1, anchor);
append(div1, header);
append(header, p);
if_block0.m(p, null);
append(header, t0);
append(header, a);
if (if_block1) if_block1.m(a, null);
append(a, t1);
append(a, code);
append(code, t2);
append(div1, t3);
append(div1, div0);
if (if_block2) if_block2.m(div0, null);
append(div0, t4);
mount_component(headertable, div0, null);
append(div0, t5);
mount_component(codepanel, div0, null);
current = true;
},
p(ctx, [dirty]) {
if (current_block_type === (current_block_type = select_block_type(ctx, dirty)) && if_block0) {
if_block0.p(ctx, dirty);
} else {
if_block0.d(1);
if_block0 = current_block_type(ctx);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (if_block0) {
if_block0.c();
if_block0.m(p, null);
}
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (/*title*/ ctx[0] !== "") {
if (if_block1) {
if_block1.p(ctx, dirty);
} else {
if_block1 = create_if_block_1$7(ctx);
if_block1.c();
if_block1.m(a, t1);
}
} else if (if_block1) {
if_block1.d(1);
if_block1 = null;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (!current || dirty & /*statusCode*/ 8) set_data(t2, /*statusCode*/ ctx[3]);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!current || dirty & /*statusCode*/ 8 && code_class_value !== (code_class_value = "tag is-medium " + colorize(/*statusCode*/ ctx[3]))) {
attr(code, "class", code_class_value);
}
2020-05-30 21:19:58 +08:00
if (/*description*/ ctx[1]) {
if (if_block2) {
if_block2.p(ctx, dirty);
} else {
if_block2 = create_if_block$a(ctx);
if_block2.c();
if_block2.m(div0, t4);
}
} else if (if_block2) {
if_block2.d(1);
if_block2 = null;
}
2020-05-30 21:19:58 +08:00
const headertable_changes = {};
if (dirty & /*headers*/ 4) headertable_changes.headers = /*headers*/ ctx[2];
headertable.$set(headertable_changes);
const codepanel_changes = {};
if (dirty & /*contentType*/ 16) codepanel_changes.contentType = /*contentType*/ ctx[4];
if (dirty & /*example*/ 32) codepanel_changes.example = /*example*/ ctx[5];
if (dirty & /*schema*/ 64) codepanel_changes.schema = /*schema*/ ctx[6];
codepanel.$set(codepanel_changes);
},
2019-10-03 04:13:12 +08:00
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(headertable.$$.fragment, local);
transition_in(codepanel.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(headertable.$$.fragment, local);
transition_out(codepanel.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(div1);
if_block0.d();
if (if_block1) if_block1.d();
if (if_block2) if_block2.d();
destroy_component(headertable);
destroy_component(codepanel);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function instance$g($$self, $$props, $$invalidate) {
let { title } = $$props;
let { description } = $$props;
let { headers } = $$props;
let { statusCode } = $$props;
let { contentType } = $$props;
let { example } = $$props;
let { schema } = $$props;
2019-10-03 04:13:12 +08:00
$$self.$set = $$props => {
2020-05-30 21:19:58 +08:00
if ("title" in $$props) $$invalidate(0, title = $$props.title);
if ("description" in $$props) $$invalidate(1, description = $$props.description);
if ("headers" in $$props) $$invalidate(2, headers = $$props.headers);
if ("statusCode" in $$props) $$invalidate(3, statusCode = $$props.statusCode);
if ("contentType" in $$props) $$invalidate(4, contentType = $$props.contentType);
if ("example" in $$props) $$invalidate(5, example = $$props.example);
if ("schema" in $$props) $$invalidate(6, schema = $$props.schema);
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
return [title, description, headers, statusCode, contentType, example, schema];
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
class ResponsePanel extends SvelteComponent {
2019-10-03 04:13:12 +08:00
constructor(options) {
super();
2020-05-30 21:19:58 +08:00
init(this, options, instance$g, create_fragment$g, safe_not_equal, {
title: 0,
description: 1,
headers: 2,
statusCode: 3,
contentType: 4,
example: 5,
schema: 6
});
2019-10-03 04:13:12 +08:00
}
}
2020-05-30 21:19:58 +08:00
/* usr/local/lib/node_modules/snowboard/templates/winter/panels/ScenarioPanel.svelte generated by Svelte v3.19.2 */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function get_each_context_1$1(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[7] = list[i];
child_ctx[4] = i;
return child_ctx;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
function get_each_context$3(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[7] = list[i];
child_ctx[4] = i;
return child_ctx;
}
// (50:0) {:else}
function create_else_block$5(ctx) {
let current;
const collapsiblepanel = new CollapsiblePanel({
props: {
isDarkmode: /*isDarkmode*/ ctx[3],
show: /*show*/ ctx[0],
$$slots: {
default: [create_default_slot$1],
body: [create_body_slot$1],
heading: [create_heading_slot$1]
},
$$scope: { ctx }
}
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
create_component(collapsiblepanel.$$.fragment);
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
mount_component(collapsiblepanel, target, anchor);
current = true;
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
p(ctx, dirty) {
const collapsiblepanel_changes = {};
if (dirty & /*isDarkmode*/ 8) collapsiblepanel_changes.isDarkmode = /*isDarkmode*/ ctx[3];
if (dirty & /*show*/ 1) collapsiblepanel_changes.show = /*show*/ ctx[0];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*$$scope, responses, request, index*/ 1046) {
collapsiblepanel_changes.$$scope = { dirty, ctx };
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
collapsiblepanel.$set(collapsiblepanel_changes);
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
i(local) {
if (current) return;
transition_in(collapsiblepanel.$$.fragment, local);
current = true;
},
o(local) {
transition_out(collapsiblepanel.$$.fragment, local);
current = false;
},
d(detaching) {
destroy_component(collapsiblepanel, detaching);
}
};
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
// (30:0) {#if request.title === ''}
function create_if_block$b(ctx) {
let t0;
let t1;
2020-05-30 21:19:58 +08:00
let div;
let current;
let if_block = /*show*/ ctx[0] && create_if_block_1$8(ctx);
let each_value = /*responses*/ ctx[2];
let each_blocks = [];
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block$3(get_each_context$3(ctx, each_value, i));
}
const out = i => transition_out(each_blocks[i], 1, 1, () => {
each_blocks[i] = null;
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
if (if_block) if_block.c();
2019-10-03 04:13:12 +08:00
t0 = space();
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
t1 = space();
div = element("div");
attr(div, "class", "panel");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
if (if_block) if_block.m(target, anchor);
insert(target, t0, anchor);
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(target, anchor);
}
insert(target, t1, anchor);
2019-10-03 04:13:12 +08:00
insert(target, div, anchor);
2020-05-30 21:19:58 +08:00
current = true;
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
p(ctx, dirty) {
if (/*show*/ ctx[0]) {
if (if_block) {
if_block.p(ctx, dirty);
transition_in(if_block, 1);
} else {
if_block = create_if_block_1$8(ctx);
if_block.c();
transition_in(if_block, 1);
if_block.m(t0.parentNode, t0);
}
} else if (if_block) {
group_outros();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
transition_out(if_block, 1, 1, () => {
if_block = null;
});
2020-05-30 21:19:58 +08:00
check_outros();
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (dirty & /*responses*/ 4) {
each_value = /*responses*/ ctx[2];
let i;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context$3(ctx, each_value, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
transition_in(each_blocks[i], 1);
} else {
each_blocks[i] = create_each_block$3(child_ctx);
each_blocks[i].c();
transition_in(each_blocks[i], 1);
each_blocks[i].m(t1.parentNode, t1);
}
}
group_outros();
for (i = each_value.length; i < each_blocks.length; i += 1) {
out(i);
}
check_outros();
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
},
i(local) {
if (current) return;
transition_in(if_block);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_value.length; i += 1) {
transition_in(each_blocks[i]);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
current = true;
},
o(local) {
transition_out(if_block);
each_blocks = each_blocks.filter(Boolean);
for (let i = 0; i < each_blocks.length; i += 1) {
transition_out(each_blocks[i]);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
current = false;
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (if_block) if_block.d(detaching);
if (detaching) detach(t0);
destroy_each(each_blocks, detaching);
if (detaching) detach(t1);
if (detaching) detach(div);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (52:4) <span slot="heading">
function create_heading_slot$1(ctx) {
let span;
let t_value = /*title*/ ctx[5](/*index*/ ctx[4]) + "";
let t;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
span = element("span");
t = text(t_value);
attr(span, "slot", "heading");
},
m(target, anchor) {
insert(target, span, anchor);
append(span, t);
},
p(ctx, dirty) {
if (dirty & /*index*/ 16 && t_value !== (t_value = /*title*/ ctx[5](/*index*/ ctx[4]) + "")) set_data(t, t_value);
},
d(detaching) {
if (detaching) detach(span);
}
2019-10-03 04:13:12 +08:00
};
}
2020-05-30 21:19:58 +08:00
// (61:6) {#each responses as response, index}
function create_each_block_1$1(ctx) {
let current;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const responsepanel = new ResponsePanel({
props: {
title: /*response*/ ctx[7].title,
description: /*response*/ ctx[7].description,
statusCode: /*response*/ ctx[7].statusCode,
headers: /*response*/ ctx[7].headers,
contentType: /*response*/ ctx[7].contentType,
example: /*response*/ ctx[7].example,
schema: /*response*/ ctx[7].schema
}
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
create_component(responsepanel.$$.fragment);
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
mount_component(responsepanel, target, anchor);
current = true;
},
p(ctx, dirty) {
const responsepanel_changes = {};
if (dirty & /*responses*/ 4) responsepanel_changes.title = /*response*/ ctx[7].title;
if (dirty & /*responses*/ 4) responsepanel_changes.description = /*response*/ ctx[7].description;
if (dirty & /*responses*/ 4) responsepanel_changes.statusCode = /*response*/ ctx[7].statusCode;
if (dirty & /*responses*/ 4) responsepanel_changes.headers = /*response*/ ctx[7].headers;
if (dirty & /*responses*/ 4) responsepanel_changes.contentType = /*response*/ ctx[7].contentType;
if (dirty & /*responses*/ 4) responsepanel_changes.example = /*response*/ ctx[7].example;
if (dirty & /*responses*/ 4) responsepanel_changes.schema = /*response*/ ctx[7].schema;
responsepanel.$set(responsepanel_changes);
},
i(local) {
if (current) return;
transition_in(responsepanel.$$.fragment, local);
current = true;
},
o(local) {
transition_out(responsepanel.$$.fragment, local);
current = false;
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
destroy_component(responsepanel, detaching);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (53:4) <div slot="body">
function create_body_slot$1(ctx) {
let div;
let t;
let current;
const requestpanel = new RequestPanel({
props: {
description: /*request*/ ctx[1].description,
headers: /*request*/ ctx[1].headers,
contentType: /*request*/ ctx[1].contentType,
example: /*request*/ ctx[1].example,
schema: /*request*/ ctx[1].schema
}
});
let each_value_1 = /*responses*/ ctx[2];
let each_blocks = [];
for (let i = 0; i < each_value_1.length; i += 1) {
each_blocks[i] = create_each_block_1$1(get_each_context_1$1(ctx, each_value_1, i));
}
const out = i => transition_out(each_blocks[i], 1, 1, () => {
each_blocks[i] = null;
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
div = element("div");
create_component(requestpanel.$$.fragment);
t = space();
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
attr(div, "slot", "body");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, div, anchor);
mount_component(requestpanel, div, null);
append(div, t);
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(div, null);
}
current = true;
2019-10-03 04:13:12 +08:00
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
const requestpanel_changes = {};
if (dirty & /*request*/ 2) requestpanel_changes.description = /*request*/ ctx[1].description;
if (dirty & /*request*/ 2) requestpanel_changes.headers = /*request*/ ctx[1].headers;
if (dirty & /*request*/ 2) requestpanel_changes.contentType = /*request*/ ctx[1].contentType;
if (dirty & /*request*/ 2) requestpanel_changes.example = /*request*/ ctx[1].example;
if (dirty & /*request*/ 2) requestpanel_changes.schema = /*request*/ ctx[1].schema;
requestpanel.$set(requestpanel_changes);
if (dirty & /*responses*/ 4) {
each_value_1 = /*responses*/ ctx[2];
let i;
for (i = 0; i < each_value_1.length; i += 1) {
const child_ctx = get_each_context_1$1(ctx, each_value_1, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
transition_in(each_blocks[i], 1);
} else {
each_blocks[i] = create_each_block_1$1(child_ctx);
each_blocks[i].c();
transition_in(each_blocks[i], 1);
each_blocks[i].m(div, null);
}
}
group_outros();
for (i = each_value_1.length; i < each_blocks.length; i += 1) {
out(i);
}
check_outros();
}
},
i(local) {
if (current) return;
transition_in(requestpanel.$$.fragment, local);
for (let i = 0; i < each_value_1.length; i += 1) {
transition_in(each_blocks[i]);
}
current = true;
},
o(local) {
transition_out(requestpanel.$$.fragment, local);
each_blocks = each_blocks.filter(Boolean);
for (let i = 0; i < each_blocks.length; i += 1) {
transition_out(each_blocks[i]);
}
current = false;
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(div);
destroy_component(requestpanel);
destroy_each(each_blocks, detaching);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (51:2) <CollapsiblePanel {isDarkmode} {show}>
function create_default_slot$1(ctx) {
let t;
let current;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
t = space();
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, t, anchor);
2019-10-03 04:13:12 +08:00
},
p: noop,
2020-05-30 21:19:58 +08:00
i: noop,
o: noop,
2019-10-03 04:13:12 +08:00
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(t);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (31:2) {#if show}
function create_if_block_1$8(ctx) {
let current;
const requestpanel = new RequestPanel({
props: {
description: /*request*/ ctx[1].description,
headers: /*request*/ ctx[1].headers,
contentType: /*request*/ ctx[1].contentType,
example: /*request*/ ctx[1].example,
schema: /*request*/ ctx[1].schema
}
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
create_component(requestpanel.$$.fragment);
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
mount_component(requestpanel, target, anchor);
current = true;
},
p(ctx, dirty) {
const requestpanel_changes = {};
if (dirty & /*request*/ 2) requestpanel_changes.description = /*request*/ ctx[1].description;
if (dirty & /*request*/ 2) requestpanel_changes.headers = /*request*/ ctx[1].headers;
if (dirty & /*request*/ 2) requestpanel_changes.contentType = /*request*/ ctx[1].contentType;
if (dirty & /*request*/ 2) requestpanel_changes.example = /*request*/ ctx[1].example;
if (dirty & /*request*/ 2) requestpanel_changes.schema = /*request*/ ctx[1].schema;
requestpanel.$set(requestpanel_changes);
},
i(local) {
if (current) return;
transition_in(requestpanel.$$.fragment, local);
current = true;
},
o(local) {
transition_out(requestpanel.$$.fragment, local);
current = false;
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
destroy_component(requestpanel, detaching);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (39:2) {#each responses as response, index}
function create_each_block$3(ctx) {
let current;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const responsepanel = new ResponsePanel({
props: {
2020-05-30 21:19:58 +08:00
title: /*response*/ ctx[7].title,
description: /*response*/ ctx[7].description,
statusCode: /*response*/ ctx[7].statusCode,
headers: /*response*/ ctx[7].headers,
contentType: /*response*/ ctx[7].contentType,
example: /*response*/ ctx[7].example,
schema: /*response*/ ctx[7].schema
}
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
create_component(responsepanel.$$.fragment);
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
mount_component(responsepanel, target, anchor);
2019-10-03 04:13:12 +08:00
current = true;
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
const responsepanel_changes = {};
if (dirty & /*responses*/ 4) responsepanel_changes.title = /*response*/ ctx[7].title;
if (dirty & /*responses*/ 4) responsepanel_changes.description = /*response*/ ctx[7].description;
if (dirty & /*responses*/ 4) responsepanel_changes.statusCode = /*response*/ ctx[7].statusCode;
if (dirty & /*responses*/ 4) responsepanel_changes.headers = /*response*/ ctx[7].headers;
if (dirty & /*responses*/ 4) responsepanel_changes.contentType = /*response*/ ctx[7].contentType;
if (dirty & /*responses*/ 4) responsepanel_changes.example = /*response*/ ctx[7].example;
if (dirty & /*responses*/ 4) responsepanel_changes.schema = /*response*/ ctx[7].schema;
responsepanel.$set(responsepanel_changes);
2019-10-03 04:13:12 +08:00
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(responsepanel.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(responsepanel.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
destroy_component(responsepanel, detaching);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function create_fragment$h(ctx) {
let current_block_type_index;
let if_block;
let if_block_anchor;
let current;
2020-05-30 21:19:58 +08:00
const if_block_creators = [create_if_block$b, create_else_block$5];
const if_blocks = [];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function select_block_type(ctx, dirty) {
if (/*request*/ ctx[1].title === "") return 0;
return 1;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
current_block_type_index = select_block_type(ctx, -1);
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
if_block.c();
if_block_anchor = empty();
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
if_blocks[current_block_type_index].m(target, anchor);
insert(target, if_block_anchor, anchor);
2019-10-03 04:13:12 +08:00
current = true;
},
2020-05-30 21:19:58 +08:00
p(ctx, [dirty]) {
let previous_block_index = current_block_type_index;
current_block_type_index = select_block_type(ctx, dirty);
2020-05-30 21:19:58 +08:00
if (current_block_type_index === previous_block_index) {
if_blocks[current_block_type_index].p(ctx, dirty);
} else {
group_outros();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
transition_out(if_blocks[previous_block_index], 1, 1, () => {
if_blocks[previous_block_index] = null;
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
check_outros();
if_block = if_blocks[current_block_type_index];
2020-05-30 21:19:58 +08:00
if (!if_block) {
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
if_block.c();
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
transition_in(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
2019-10-03 04:13:12 +08:00
}
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(if_block);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(if_block);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if_blocks[current_block_type_index].d(detaching);
if (detaching) detach(if_block_anchor);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function instance$h($$self, $$props, $$invalidate) {
let { show } = $$props;
let { count } = $$props;
let { index } = $$props;
let { request } = $$props;
let { responses } = $$props;
let { isDarkmode } = $$props;
function title(index) {
if (request.title) {
return `Request ${request.title}`;
}
if (count === 1) {
return "Request";
} else {
return `Request ${index + 1}`;
}
}
$$self.$set = $$props => {
if ("show" in $$props) $$invalidate(0, show = $$props.show);
if ("count" in $$props) $$invalidate(6, count = $$props.count);
if ("index" in $$props) $$invalidate(4, index = $$props.index);
if ("request" in $$props) $$invalidate(1, request = $$props.request);
if ("responses" in $$props) $$invalidate(2, responses = $$props.responses);
if ("isDarkmode" in $$props) $$invalidate(3, isDarkmode = $$props.isDarkmode);
};
return [show, request, responses, isDarkmode, index, title, count];
}
class ScenarioPanel extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance$h, create_fragment$h, safe_not_equal, {
show: 0,
count: 6,
index: 4,
request: 1,
responses: 2,
isDarkmode: 3
});
}
}
/* usr/local/lib/node_modules/snowboard/templates/winter/pages/Action.svelte generated by Svelte v3.19.2 */
function add_css$8() {
var style = element("style");
style.id = "svelte-1kw1ago-style";
style.textContent = ".breadcrumb-right.svelte-1kw1ago{margin-top:0.3em}.box-wrapper.svelte-1kw1ago{border-radius:0}";
append(document.head, style);
}
function get_each_context$4(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[11] = list[i].request;
child_ctx[12] = list[i].responses;
child_ctx[14] = i;
return child_ctx;
}
function get_each_context_1$2(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[15] = list[i];
child_ctx[14] = i;
return child_ctx;
}
// (192:0) {:else}
function create_else_block_1$1(ctx) {
let h3;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
h3 = element("h3");
h3.textContent = "404 - Not Found";
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, h3, anchor);
2019-10-03 04:13:12 +08:00
},
p: noop,
i: noop,
o: noop,
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(h3);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (126:0) {#if action}
function create_if_block$c(ctx) {
let div2;
let div0;
let h1;
let t0_value = /*action*/ ctx[0].title + "";
let t0;
let t1;
let div1;
let nav;
let ul;
let t2;
let hr;
let t3;
let div3;
let code0;
let t4_value = /*action*/ ctx[0].method + "";
let t4;
let code0_class_value;
let t5;
let code1;
let t6_value = /*action*/ ctx[0].pathTemplate + "";
let t6;
let t7;
let div4;
let raw_value = markdown(/*action*/ ctx[0].description) + "";
let t8;
let t9;
let t10;
let each1_anchor;
let current;
2020-05-30 21:19:58 +08:00
let each_value_1 = /*action*/ ctx[0].tags;
let each_blocks_1 = [];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_value_1.length; i += 1) {
each_blocks_1[i] = create_each_block_1$2(get_each_context_1$2(ctx, each_value_1, i));
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
let if_block = /*config*/ ctx[1].playground.enabled && create_if_block_1$9(ctx);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const parameterpanel = new ParameterPanel({
props: { parameters: /*action*/ ctx[0].parameters }
});
2020-05-30 21:19:58 +08:00
let each_value = /*transactions*/ ctx[5];
let each_blocks = [];
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block$4(get_each_context$4(ctx, each_value, i));
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
const out = i => transition_out(each_blocks[i], 1, 1, () => {
each_blocks[i] = null;
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
div2 = element("div");
div0 = element("div");
h1 = element("h1");
t0 = text(t0_value);
t1 = space();
div1 = element("div");
nav = element("nav");
ul = element("ul");
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_blocks_1.length; i += 1) {
each_blocks_1[i].c();
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
t2 = space();
hr = element("hr");
t3 = space();
div3 = element("div");
code0 = element("code");
t4 = text(t4_value);
t5 = space();
code1 = element("code");
t6 = text(t6_value);
t7 = space();
div4 = element("div");
t8 = space();
if (if_block) if_block.c();
t9 = space();
create_component(parameterpanel.$$.fragment);
t10 = space();
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
each1_anchor = empty();
attr(h1, "class", "title is-4");
attr(div0, "class", "column");
attr(nav, "class", "breadcrumb breadcrumb-right is-pulled-right svelte-1kw1ago");
attr(nav, "aria-label", "breadcrumbs");
attr(div1, "class", "column");
attr(div2, "class", "columns");
attr(code0, "class", code0_class_value = "tag is-uppercase " + colorize(/*action*/ ctx[0].method) + " svelte-1kw1ago");
attr(code1, "class", "tag ");
attr(div3, "class", "tags has-addons are-large");
attr(div4, "class", "content");
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
m(target, anchor) {
insert(target, div2, anchor);
append(div2, div0);
append(div0, h1);
append(h1, t0);
append(div2, t1);
append(div2, div1);
append(div1, nav);
append(nav, ul);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_blocks_1.length; i += 1) {
each_blocks_1[i].m(ul, null);
}
insert(target, t2, anchor);
insert(target, hr, anchor);
insert(target, t3, anchor);
insert(target, div3, anchor);
append(div3, code0);
append(code0, t4);
append(div3, t5);
append(div3, code1);
append(code1, t6);
insert(target, t7, anchor);
insert(target, div4, anchor);
div4.innerHTML = raw_value;
insert(target, t8, anchor);
if (if_block) if_block.m(target, anchor);
insert(target, t9, anchor);
mount_component(parameterpanel, target, anchor);
insert(target, t10, anchor);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(target, anchor);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
insert(target, each1_anchor, anchor);
2019-10-03 04:13:12 +08:00
current = true;
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
if ((!current || dirty & /*action*/ 1) && t0_value !== (t0_value = /*action*/ ctx[0].title + "")) set_data(t0, t0_value);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*action, slugify, handleLink*/ 1) {
each_value_1 = /*action*/ ctx[0].tags;
let i;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (i = 0; i < each_value_1.length; i += 1) {
const child_ctx = get_each_context_1$2(ctx, each_value_1, i);
if (each_blocks_1[i]) {
each_blocks_1[i].p(child_ctx, dirty);
} else {
each_blocks_1[i] = create_each_block_1$2(child_ctx);
each_blocks_1[i].c();
each_blocks_1[i].m(ul, null);
}
}
for (; i < each_blocks_1.length; i += 1) {
each_blocks_1[i].d(1);
}
each_blocks_1.length = each_value_1.length;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if ((!current || dirty & /*action*/ 1) && t4_value !== (t4_value = /*action*/ ctx[0].method + "")) set_data(t4, t4_value);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (!current || dirty & /*action*/ 1 && code0_class_value !== (code0_class_value = "tag is-uppercase " + colorize(/*action*/ ctx[0].method) + " svelte-1kw1ago")) {
attr(code0, "class", code0_class_value);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if ((!current || dirty & /*action*/ 1) && t6_value !== (t6_value = /*action*/ ctx[0].pathTemplate + "")) set_data(t6, t6_value);
if ((!current || dirty & /*action*/ 1) && raw_value !== (raw_value = markdown(/*action*/ ctx[0].description) + "")) div4.innerHTML = raw_value;;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (/*config*/ ctx[1].playground.enabled) {
2019-10-03 04:13:12 +08:00
if (if_block) {
if_block.p(ctx, dirty);
2019-10-03 04:13:12 +08:00
transition_in(if_block, 1);
} else {
2020-05-30 21:19:58 +08:00
if_block = create_if_block_1$9(ctx);
2019-10-03 04:13:12 +08:00
if_block.c();
transition_in(if_block, 1);
2020-05-30 21:19:58 +08:00
if_block.m(t9.parentNode, t9);
2019-10-03 04:13:12 +08:00
}
} else if (if_block) {
group_outros();
2019-10-03 04:13:12 +08:00
transition_out(if_block, 1, 1, () => {
if_block = null;
});
2019-10-03 04:13:12 +08:00
check_outros();
}
2020-05-30 21:19:58 +08:00
const parameterpanel_changes = {};
if (dirty & /*action*/ 1) parameterpanel_changes.parameters = /*action*/ ctx[0].parameters;
parameterpanel.$set(parameterpanel_changes);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*darkMode, transactions*/ 48) {
each_value = /*transactions*/ ctx[5];
2019-10-03 04:13:12 +08:00
let i;
2020-05-30 21:19:58 +08:00
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context$4(ctx, each_value, i);
2019-10-03 04:13:12 +08:00
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
2019-10-03 04:13:12 +08:00
transition_in(each_blocks[i], 1);
} else {
2020-05-30 21:19:58 +08:00
each_blocks[i] = create_each_block$4(child_ctx);
2019-10-03 04:13:12 +08:00
each_blocks[i].c();
transition_in(each_blocks[i], 1);
2020-05-30 21:19:58 +08:00
each_blocks[i].m(each1_anchor.parentNode, each1_anchor);
2019-10-03 04:13:12 +08:00
}
}
group_outros();
2020-05-30 21:19:58 +08:00
for (i = each_value.length; i < each_blocks.length; i += 1) {
2019-10-03 04:13:12 +08:00
out(i);
}
2019-10-03 04:13:12 +08:00
check_outros();
}
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(if_block);
transition_in(parameterpanel.$$.fragment, local);
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_value.length; i += 1) {
2019-10-03 04:13:12 +08:00
transition_in(each_blocks[i]);
}
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(if_block);
transition_out(parameterpanel.$$.fragment, local);
2019-10-03 04:13:12 +08:00
each_blocks = each_blocks.filter(Boolean);
2019-10-03 04:13:12 +08:00
for (let i = 0; i < each_blocks.length; i += 1) {
transition_out(each_blocks[i]);
}
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(div2);
destroy_each(each_blocks_1, detaching);
if (detaching) detach(t2);
if (detaching) detach(hr);
if (detaching) detach(t3);
if (detaching) detach(div3);
if (detaching) detach(t7);
if (detaching) detach(div4);
if (detaching) detach(t8);
if (if_block) if_block.d(detaching);
if (detaching) detach(t9);
destroy_component(parameterpanel, detaching);
if (detaching) detach(t10);
destroy_each(each_blocks, detaching);
if (detaching) detach(each1_anchor);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (140:14) {:else}
function create_else_block$6(ctx) {
let a;
let t_value = /*tag*/ ctx[15] + "";
let t;
let a_href_value;
let dispose;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
a = element("a");
t = text(t_value);
attr(a, "href", a_href_value = "/#/g~" + slugify(/*action*/ ctx[0].tags[0]) + "~" + slugify(/*tag*/ ctx[15]));
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, a, anchor);
append(a, t);
dispose = listen(a, "click", handleLink);
},
p(ctx, dirty) {
if (dirty & /*action*/ 1 && t_value !== (t_value = /*tag*/ ctx[15] + "")) set_data(t, t_value);
if (dirty & /*action*/ 1 && a_href_value !== (a_href_value = "/#/g~" + slugify(/*action*/ ctx[0].tags[0]) + "~" + slugify(/*tag*/ ctx[15]))) {
attr(a, "href", a_href_value);
}
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(a);
dispose();
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (138:14) {#if index === 0}
function create_if_block_3$1(ctx) {
let a;
let t_value = /*tag*/ ctx[15] + "";
let t;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
a = element("a");
t = text(t_value);
attr(a, "href", "javascript:void(0)");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, a, anchor);
append(a, t);
2019-10-03 04:13:12 +08:00
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
if (dirty & /*action*/ 1 && t_value !== (t_value = /*tag*/ ctx[15] + "")) set_data(t, t_value);
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(a);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (136:10) {#each action.tags as tag, index}
function create_each_block_1$2(ctx) {
let li;
let t;
function select_block_type_1(ctx, dirty) {
if (/*index*/ ctx[14] === 0) return create_if_block_3$1;
return create_else_block$6;
}
let current_block_type = select_block_type_1(ctx, -1);
let if_block = current_block_type(ctx);
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
li = element("li");
if_block.c();
t = space();
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, li, anchor);
if_block.m(li, null);
append(li, t);
},
p(ctx, dirty) {
if_block.p(ctx, dirty);
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(li);
if_block.d();
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (167:2) {#if config.playground.enabled}
function create_if_block_1$9(ctx) {
let if_block_anchor;
let current;
2020-05-30 21:19:58 +08:00
let if_block = /*environment*/ ctx[2].playground !== false && create_if_block_2$5(ctx);
2019-10-03 04:13:12 +08:00
return {
c() {
if (if_block) if_block.c();
if_block_anchor = empty();
},
m(target, anchor) {
if (if_block) if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
current = true;
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
if (/*environment*/ ctx[2].playground !== false) {
2019-10-03 04:13:12 +08:00
if (if_block) {
if_block.p(ctx, dirty);
2019-10-03 04:13:12 +08:00
transition_in(if_block, 1);
} else {
2020-05-30 21:19:58 +08:00
if_block = create_if_block_2$5(ctx);
2019-10-03 04:13:12 +08:00
if_block.c();
transition_in(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
group_outros();
2019-10-03 04:13:12 +08:00
transition_out(if_block, 1, 1, () => {
if_block = null;
});
2019-10-03 04:13:12 +08:00
check_outros();
}
},
i(local) {
if (current) return;
transition_in(if_block);
current = true;
},
o(local) {
transition_out(if_block);
current = false;
},
d(detaching) {
if (if_block) if_block.d(detaching);
if (detaching) detach(if_block_anchor);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (168:4) {#if environment.playground !== false}
function create_if_block_2$5(ctx) {
let current;
2020-05-30 21:19:58 +08:00
const playgroundpanel = new PlaygroundPanel({
props: {
currentAction: /*action*/ ctx[0],
pkceChallenge: /*challengePair*/ ctx[3],
environments: /*config*/ ctx[1].playground.environments,
requestHeaders: headersMap(/*action*/ ctx[0]),
requestAuthHeader: /*authHeader*/ ctx[6](/*action*/ ctx[0], /*environment*/ ctx[2]),
requestParameters: parametersMap(/*action*/ ctx[0]),
requestBody: bodyMap(/*action*/ ctx[0]),
isDarkmode: /*darkMode*/ ctx[4].active
}
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
create_component(playgroundpanel.$$.fragment);
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
mount_component(playgroundpanel, target, anchor);
2019-10-03 04:13:12 +08:00
current = true;
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
const playgroundpanel_changes = {};
if (dirty & /*action*/ 1) playgroundpanel_changes.currentAction = /*action*/ ctx[0];
if (dirty & /*challengePair*/ 8) playgroundpanel_changes.pkceChallenge = /*challengePair*/ ctx[3];
if (dirty & /*config*/ 2) playgroundpanel_changes.environments = /*config*/ ctx[1].playground.environments;
if (dirty & /*action*/ 1) playgroundpanel_changes.requestHeaders = headersMap(/*action*/ ctx[0]);
if (dirty & /*action, environment*/ 5) playgroundpanel_changes.requestAuthHeader = /*authHeader*/ ctx[6](/*action*/ ctx[0], /*environment*/ ctx[2]);
if (dirty & /*action*/ 1) playgroundpanel_changes.requestParameters = parametersMap(/*action*/ ctx[0]);
if (dirty & /*action*/ 1) playgroundpanel_changes.requestBody = bodyMap(/*action*/ ctx[0]);
if (dirty & /*darkMode*/ 16) playgroundpanel_changes.isDarkmode = /*darkMode*/ ctx[4].active;
playgroundpanel.$set(playgroundpanel_changes);
2019-10-03 04:13:12 +08:00
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(playgroundpanel.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(playgroundpanel.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
destroy_component(playgroundpanel, detaching);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (183:2) {#each transactions as { request, responses }
function create_each_block$4(ctx) {
let current;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const scenariopanel = new ScenarioPanel({
props: {
2020-05-30 21:19:58 +08:00
show: /*index*/ ctx[14] === 0,
isDarkmode: /*darkMode*/ ctx[4].active,
request: /*request*/ ctx[11],
responses: /*responses*/ ctx[12],
index: /*index*/ ctx[14],
count: /*transactions*/ ctx[5].length
}
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
create_component(scenariopanel.$$.fragment);
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
mount_component(scenariopanel, target, anchor);
current = true;
},
p(ctx, dirty) {
const scenariopanel_changes = {};
if (dirty & /*darkMode*/ 16) scenariopanel_changes.isDarkmode = /*darkMode*/ ctx[4].active;
if (dirty & /*transactions*/ 32) scenariopanel_changes.request = /*request*/ ctx[11];
if (dirty & /*transactions*/ 32) scenariopanel_changes.responses = /*responses*/ ctx[12];
if (dirty & /*transactions*/ 32) scenariopanel_changes.count = /*transactions*/ ctx[5].length;
scenariopanel.$set(scenariopanel_changes);
},
i(local) {
if (current) return;
transition_in(scenariopanel.$$.fragment, local);
current = true;
},
o(local) {
transition_out(scenariopanel.$$.fragment, local);
current = false;
},
d(detaching) {
destroy_component(scenariopanel, detaching);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function create_fragment$i(ctx) {
let current_block_type_index;
let if_block;
let if_block_anchor;
let current;
const if_block_creators = [create_if_block$c, create_else_block_1$1];
const if_blocks = [];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function select_block_type(ctx, dirty) {
if (/*action*/ ctx[0]) return 0;
return 1;
}
current_block_type_index = select_block_type(ctx, -1);
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
return {
c() {
if_block.c();
if_block_anchor = empty();
},
m(target, anchor) {
if_blocks[current_block_type_index].m(target, anchor);
insert(target, if_block_anchor, anchor);
2019-10-03 04:13:12 +08:00
current = true;
},
2020-05-30 21:19:58 +08:00
p(ctx, [dirty]) {
let previous_block_index = current_block_type_index;
current_block_type_index = select_block_type(ctx, dirty);
2020-05-30 21:19:58 +08:00
if (current_block_type_index === previous_block_index) {
if_blocks[current_block_type_index].p(ctx, dirty);
} else {
group_outros();
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
transition_out(if_blocks[previous_block_index], 1, 1, () => {
if_blocks[previous_block_index] = null;
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
check_outros();
if_block = if_blocks[current_block_type_index];
if (!if_block) {
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
if_block.c();
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
transition_in(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
2019-10-03 04:13:12 +08:00
}
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(if_block);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(if_block);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if_blocks[current_block_type_index].d(detaching);
if (detaching) detach(if_block_anchor);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function sample(action) {
return action.transactions[0].request;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function headersMap(action) {
return sample(action).headers.filter(header => header.name != "Authorization").map(header => {
return {
used: true,
required: false,
name: header.name,
value: header.example || ""
};
});
}
function parametersMap(action) {
return action.parameters.map(param => {
return {
used: param.required,
required: param.required,
name: param.name,
value: param.example || ""
};
});
}
function bodyMap(action) {
const example = sample(action).example;
return stringify$2(example);
}
function instance$i($$self, $$props, $$invalidate) {
let $auth;
let $env;
let $token;
component_subscribe($$self, auth, $$value => $$invalidate(7, $auth = $$value));
component_subscribe($$self, env, $$value => $$invalidate(8, $env = $$value));
component_subscribe($$self, token$1, $$value => $$invalidate(9, $token = $$value));
let { action } = $$props;
let { config } = $$props;
let { environment } = $$props;
let { challengePair } = $$props;
let { darkMode } = $$props;
function authHeader(action, environment) {
const header = sample(action).headers.find(header => header.name === "Authorization");
if (!header) return;
header.value = header.example;
header.used = true;
if (isAuth(environment, "basic")) {
header.value = `Basic ${basicAuth(environment.auth.options.username, environment.auth.options.password)}`;
}
if (isAuth(environment, "apikey")) {
header.name = environment.auth.options.header;
header.value = environment.auth.options.key;
}
if (isAuth(environment, "oauth2")) {
if ($auth.split(";").includes($env)) {
header.value = `Bearer ${$token}`;
}
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
return header;
}
function toTransactions(transactions) {
if (!transactions) return [];
const items = {};
transactions.forEach(transaction => {
const { request, response } = transaction;
const requestHash = lib$2.h32(fastJsonStableStringify(request), 703710).toString(16);
if (!Object.keys(items).includes(requestHash)) {
items[requestHash] = { request, responses: [response] };
} else {
items[requestHash].responses.push(response);
}
});
return Object.values(items);
}
$$self.$set = $$props => {
if ("action" in $$props) $$invalidate(0, action = $$props.action);
if ("config" in $$props) $$invalidate(1, config = $$props.config);
if ("environment" in $$props) $$invalidate(2, environment = $$props.environment);
if ("challengePair" in $$props) $$invalidate(3, challengePair = $$props.challengePair);
if ("darkMode" in $$props) $$invalidate(4, darkMode = $$props.darkMode);
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
let transactions;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$self.$$.update = () => {
if ($$self.$$.dirty & /*action*/ 1) {
$$invalidate(5, transactions = toTransactions(action && action.transactions));
2019-10-03 04:13:12 +08:00
}
};
2020-05-30 21:19:58 +08:00
return [action, config, environment, challengePair, darkMode, transactions, authHeader];
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
class Action extends SvelteComponent {
constructor(options) {
super();
if (!document.getElementById("svelte-1kw1ago-style")) add_css$8();
init(this, options, instance$i, create_fragment$i, safe_not_equal, {
action: 0,
config: 1,
environment: 2,
challengePair: 3,
darkMode: 4
});
}
}
/* usr/local/lib/node_modules/snowboard/templates/winter/components/MenuItem.svelte generated by Svelte v3.19.2 */
function add_css$9() {
var style = element("style");
style.id = "svelte-39af3j-style";
style.textContent = ".tag.svelte-39af3j{width:3.5rem}.menu-ellipsis.svelte-39af3j{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;padding:0.25em 0.75em}.menu-action.svelte-39af3j{vertical-align:middle}";
append(document.head, style);
}
function get_each_context$5(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[6] = list[i];
return child_ctx;
}
// (28:0) {#if title}
function create_if_block_1$a(ctx) {
let li;
let a0;
let t0;
let a0_href_value;
let t1;
let a1;
let span;
let i;
let dispose;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
li = element("li");
a0 = element("a");
t0 = text(/*title*/ ctx[1]);
t1 = space();
a1 = element("a");
span = element("span");
i = element("i");
attr(a0, "href", a0_href_value = buildHref(`#/g~${/*parentSlug*/ ctx[3]}~${slugify(/*title*/ ctx[1])}`));
attr(a0, "class", "is-inline-block");
attr(i, "class", "fas");
toggle_class(i, "fa-chevron-right", /*hidden*/ ctx[0]);
toggle_class(i, "fa-chevron-down", !/*hidden*/ ctx[0]);
attr(span, "class", "icon is-small has-text-grey-light");
attr(a1, "href", "javascript:void(0)");
attr(a1, "class", "is-inline-block is-pulled-right");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, li, anchor);
append(li, a0);
append(a0, t0);
append(li, t1);
append(li, a1);
append(a1, span);
append(span, i);
dispose = [
listen(a0, "click", handleLink),
listen(a1, "click", /*click_handler*/ ctx[5])
];
2019-10-03 04:13:12 +08:00
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
if (dirty & /*title*/ 2) set_data(t0, /*title*/ ctx[1]);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*parentSlug, title*/ 10 && a0_href_value !== (a0_href_value = buildHref(`#/g~${/*parentSlug*/ ctx[3]}~${slugify(/*title*/ ctx[1])}`))) {
attr(a0, "href", a0_href_value);
}
2020-05-30 21:19:58 +08:00
if (dirty & /*hidden*/ 1) {
toggle_class(i, "fa-chevron-right", /*hidden*/ ctx[0]);
}
if (dirty & /*hidden*/ 1) {
toggle_class(i, "fa-chevron-down", !/*hidden*/ ctx[0]);
}
},
d(detaching) {
if (detaching) detach(li);
run_all(dispose);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// (50:0) {#if actions.length > 0}
function create_if_block$d(ctx) {
let li;
let ul;
let each_value = /*actions*/ ctx[2];
let each_blocks = [];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block$5(get_each_context$5(ctx, each_value, i));
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
return {
c() {
li = element("li");
ul = element("ul");
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
toggle_class(li, "is-hidden", /*hidden*/ ctx[0]);
},
m(target, anchor) {
insert(target, li, anchor);
append(li, ul);
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(ul, null);
}
},
p(ctx, dirty) {
if (dirty & /*buildHref, actions, $router, handleLink, colorize*/ 20) {
each_value = /*actions*/ ctx[2];
let i;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context$5(ctx, each_value, i);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
} else {
each_blocks[i] = create_each_block$5(child_ctx);
each_blocks[i].c();
each_blocks[i].m(ul, null);
}
}
for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
each_blocks.length = each_value.length;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*hidden*/ 1) {
toggle_class(li, "is-hidden", /*hidden*/ ctx[0]);
}
},
d(detaching) {
if (detaching) detach(li);
destroy_each(each_blocks, detaching);
}
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// (53:6) {#each actions as action}
function create_each_block$5(ctx) {
let li;
let a;
let code;
let t0_value = /*action*/ ctx[6].method + "";
let t0;
let code_class_value;
let t1;
let span;
let t2_value = /*action*/ ctx[6].title + "";
let t2;
let a_href_value;
let t3;
let dispose;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
li = element("li");
a = element("a");
code = element("code");
t0 = text(t0_value);
2019-10-03 04:13:12 +08:00
t1 = space();
2020-05-30 21:19:58 +08:00
span = element("span");
t2 = text(t2_value);
2019-10-03 04:13:12 +08:00
t3 = space();
2020-05-30 21:19:58 +08:00
attr(code, "class", code_class_value = "tag " + colorize(/*action*/ ctx[6].method) + " is-uppercase" + " svelte-39af3j");
attr(span, "class", "menu-action svelte-39af3j");
attr(a, "href", a_href_value = buildHref(`#/${/*action*/ ctx[6].slug}`));
attr(a, "class", "menu-ellipsis svelte-39af3j");
toggle_class(a, "is-active", /*action*/ ctx[6].slug === /*$router*/ ctx[4].params.slug);
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, li, anchor);
append(li, a);
append(a, code);
append(code, t0);
append(a, t1);
append(a, span);
append(span, t2);
append(li, t3);
dispose = listen(a, "click", handleLink);
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
p(ctx, dirty) {
if (dirty & /*actions*/ 4 && t0_value !== (t0_value = /*action*/ ctx[6].method + "")) set_data(t0, t0_value);
2020-05-30 21:19:58 +08:00
if (dirty & /*actions*/ 4 && code_class_value !== (code_class_value = "tag " + colorize(/*action*/ ctx[6].method) + " is-uppercase" + " svelte-39af3j")) {
attr(code, "class", code_class_value);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (dirty & /*actions*/ 4 && t2_value !== (t2_value = /*action*/ ctx[6].title + "")) set_data(t2, t2_value);
2020-05-30 21:19:58 +08:00
if (dirty & /*actions*/ 4 && a_href_value !== (a_href_value = buildHref(`#/${/*action*/ ctx[6].slug}`))) {
attr(a, "href", a_href_value);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (dirty & /*actions, $router*/ 20) {
toggle_class(a, "is-active", /*action*/ ctx[6].slug === /*$router*/ ctx[4].params.slug);
}
2020-05-30 21:19:58 +08:00
},
d(detaching) {
if (detaching) detach(li);
dispose();
}
};
}
function create_fragment$j(ctx) {
let t;
let if_block1_anchor;
let if_block0 = /*title*/ ctx[1] && create_if_block_1$a(ctx);
let if_block1 = /*actions*/ ctx[2].length > 0 && create_if_block$d(ctx);
2020-05-30 21:19:58 +08:00
return {
c() {
if (if_block0) if_block0.c();
t = space();
if (if_block1) if_block1.c();
if_block1_anchor = empty();
},
m(target, anchor) {
if (if_block0) if_block0.m(target, anchor);
insert(target, t, anchor);
if (if_block1) if_block1.m(target, anchor);
insert(target, if_block1_anchor, anchor);
},
p(ctx, [dirty]) {
if (/*title*/ ctx[1]) {
if (if_block0) {
if_block0.p(ctx, dirty);
} else {
if_block0 = create_if_block_1$a(ctx);
if_block0.c();
if_block0.m(t.parentNode, t);
}
} else if (if_block0) {
if_block0.d(1);
if_block0 = null;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (/*actions*/ ctx[2].length > 0) {
if (if_block1) {
if_block1.p(ctx, dirty);
} else {
if_block1 = create_if_block$d(ctx);
if_block1.c();
if_block1.m(if_block1_anchor.parentNode, if_block1_anchor);
}
} else if (if_block1) {
if_block1.d(1);
if_block1 = null;
}
2020-05-30 21:19:58 +08:00
},
i: noop,
o: noop,
d(detaching) {
if (if_block0) if_block0.d(detaching);
if (detaching) detach(t);
if (if_block1) if_block1.d(detaching);
if (detaching) detach(if_block1_anchor);
}
};
}
2020-05-30 21:19:58 +08:00
function instance$j($$self, $$props, $$invalidate) {
let $router;
component_subscribe($$self, router, $$value => $$invalidate(4, $router = $$value));
let { title } = $$props;
let { actions } = $$props;
let { parentSlug } = $$props;
let { hidden = false } = $$props;
const click_handler = () => $$invalidate(0, hidden = !hidden);
2020-05-30 21:19:58 +08:00
$$self.$set = $$props => {
if ("title" in $$props) $$invalidate(1, title = $$props.title);
if ("actions" in $$props) $$invalidate(2, actions = $$props.actions);
if ("parentSlug" in $$props) $$invalidate(3, parentSlug = $$props.parentSlug);
if ("hidden" in $$props) $$invalidate(0, hidden = $$props.hidden);
};
2020-05-30 21:19:58 +08:00
return [hidden, title, actions, parentSlug, $router, click_handler];
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
class MenuItem extends SvelteComponent {
constructor(options) {
super();
if (!document.getElementById("svelte-39af3j-style")) add_css$9();
2020-05-30 21:19:58 +08:00
init(this, options, instance$j, create_fragment$j, safe_not_equal, {
title: 1,
actions: 2,
parentSlug: 3,
hidden: 0
});
}
}
2020-05-30 21:19:58 +08:00
/* usr/local/lib/node_modules/snowboard/templates/winter/panels/MenuPanel.svelte generated by Svelte v3.19.2 */
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function add_css$a() {
var style = element("style");
style.id = "svelte-fvssqr-style";
style.textContent = ".hero.svelte-fvssqr.svelte-fvssqr,.menu-wrapper.svelte-fvssqr.svelte-fvssqr{padding:0 2.75rem 0 2rem}.hero.svelte-fvssqr.svelte-fvssqr{position:sticky;top:54px;background-color:#fafafa;margin-bottom:1.5rem}.hero.is-darkmode.svelte-fvssqr.svelte-fvssqr{background-color:#000}.hero-body.svelte-fvssqr.svelte-fvssqr{padding:1.5rem 0;box-shadow:0 2px 0 0 #f5f5f5}.hero-body.is-darkmode.svelte-fvssqr.svelte-fvssqr{box-shadow:0 2px 0 0 #363636}.menu-wrapper.svelte-fvssqr.svelte-fvssqr::-webkit-scrollbar{display:none}@media screen and (min-width: 768px){.hero.svelte-fvssqr.svelte-fvssqr,.menu-wrapper.svelte-fvssqr.svelte-fvssqr{width:-moz-calc(25% - 0.5rem);width:-webkit-calc(25% - 0.5rem);width:-o-calc(25% - 0.5rem);width:calc(25% - 0.5rem)}.hero.svelte-fvssqr.svelte-fvssqr{position:fixed;padding:0 1.25rem}.menu-wrapper.svelte-fvssqr.svelte-fvssqr{position:fixed;top:140px;padding:1.5rem 1.25rem 1.25rem;height:-moz-calc(100% - 150px - 2.5rem);height:-webkit-calc(100% - 150px - 2.5rem);height:-o-calc(100% - 150px - 2.5rem);height:calc(100% - 150px - 2.5rem);overflow:-moz-scrollbars-none;-ms-overflow-style:none;overflow-x:hidden;overflow-y:auto;transition:opacity 0.3s, left 0.3s}.menu.is-collapsed.svelte-fvssqr.svelte-fvssqr{width:3rem}.is-collapsed.svelte-fvssqr .hero.svelte-fvssqr,.is-collapsed.svelte-fvssqr .hero-body.svelte-fvssqr{width:calc(3rem - 2px)}.is-collapsed.svelte-fvssqr .hero.svelte-fvssqr{padding-left:0;padding-right:0}.is-collapsed.svelte-fvssqr .hero-body.svelte-fvssqr{padding-left:0.3175rem;padding-right:0.3175rem;box-shadow:none}.is-collapsed.svelte-fvssqr .input.is-rounded.svelte-fvssqr{padding-left:0;padding-right:0;opacity:0}.is-collapsed.svelte-fvssqr .icon-input-search.svelte-fvssqr{color:#b5b5b5;background-color:#eee;-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%;cursor:pointer;pointer-events:auto}.is-collapsed.svelte-fvssqr .icon-input-search.svelte-fvssqr:hover{color:#999;background-color:#e0e0e0}.is-collapsed.svelte-fvssqr .is-darkmode .icon-input-search.svelte-fvssqr{color:#ccc;background-color:#484848}.is-collapsed.svelte-fvssqr .is-darkmode .icon-input-search.svelte-fvssqr:hover{color:#fff;background-color:#484848}.is-collapsed.svelte-fvssqr .menu-wrapper.svelte-fvssqr{left:-30%;opacity:0}}";
append(document.head, style);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function get_each_context_1$3(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[13] = list[i];
return child_ctx;
}
2020-05-30 21:19:58 +08:00
function get_each_context$6(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[10] = list[i];
return child_ctx;
}
2020-05-30 21:19:58 +08:00
function get_each_context_2$1(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[16] = list[i];
return child_ctx;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// (169:4) {#if query === ''}
function create_if_block_1$b(ctx) {
let if_block_anchor;
let if_block = /*tagHeaders*/ ctx[3] && create_if_block_2$6(ctx);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
if (if_block) if_block.c();
if_block_anchor = empty();
},
m(target, anchor) {
if (if_block) if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
},
p(ctx, dirty) {
if (/*tagHeaders*/ ctx[3]) {
if (if_block) {
if_block.p(ctx, dirty);
2019-10-03 04:13:12 +08:00
} else {
2020-05-30 21:19:58 +08:00
if_block = create_if_block_2$6(ctx);
if_block.c();
if_block.m(if_block_anchor.parentNode, if_block_anchor);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
} else if (if_block) {
if_block.d(1);
if_block = null;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
},
d(detaching) {
if (if_block) if_block.d(detaching);
if (detaching) detach(if_block_anchor);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// (170:6) {#if tagHeaders}
function create_if_block_2$6(ctx) {
let ul1;
let li;
let ul0;
let each_value_2 = /*tagHeaders*/ ctx[3];
let each_blocks = [];
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_value_2.length; i += 1) {
each_blocks[i] = create_each_block_2$1(get_each_context_2$1(ctx, each_value_2, i));
}
2020-05-30 21:19:58 +08:00
return {
c() {
ul1 = element("ul");
li = element("li");
ul0 = element("ul");
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
attr(ul1, "class", "menu-list");
},
m(target, anchor) {
insert(target, ul1, anchor);
append(ul1, li);
append(li, ul0);
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(ul0, null);
}
},
p(ctx, dirty) {
if (dirty & /*headerLink, tagHeaders, tocClick*/ 136) {
each_value_2 = /*tagHeaders*/ ctx[3];
let i;
2020-05-30 21:19:58 +08:00
for (i = 0; i < each_value_2.length; i += 1) {
const child_ctx = get_each_context_2$1(ctx, each_value_2, i);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
} else {
each_blocks[i] = create_each_block_2$1(child_ctx);
each_blocks[i].c();
each_blocks[i].m(ul0, null);
}
}
2020-05-30 21:19:58 +08:00
for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
each_blocks.length = each_value_2.length;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
},
d(detaching) {
if (detaching) detach(ul1);
destroy_each(each_blocks, detaching);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// (175:16) {#if header.level === 0}
function create_if_block_3$2(ctx) {
let li;
let a;
let t0_value = /*header*/ ctx[16].text + "";
let t0;
let a_href_value;
let t1;
let dispose;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
li = element("li");
a = element("a");
t0 = text(t0_value);
t1 = space();
attr(a, "href", a_href_value = "#" + headerLink(/*header*/ ctx[16].text));
},
m(target, anchor) {
insert(target, li, anchor);
append(li, a);
append(a, t0);
append(li, t1);
2020-05-30 21:19:58 +08:00
dispose = listen(a, "click", prevent_default(function () {
if (is_function(/*tocClick*/ ctx[7])) /*tocClick*/ ctx[7].apply(this, arguments);
}));
},
p(new_ctx, dirty) {
ctx = new_ctx;
if (dirty & /*tagHeaders*/ 8 && t0_value !== (t0_value = /*header*/ ctx[16].text + "")) set_data(t0, t0_value);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*tagHeaders*/ 8 && a_href_value !== (a_href_value = "#" + headerLink(/*header*/ ctx[16].text))) {
attr(a, "href", a_href_value);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
},
d(detaching) {
if (detaching) detach(li);
dispose();
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// (174:14) {#each tagHeaders as header}
function create_each_block_2$1(ctx) {
let if_block_anchor;
let if_block = /*header*/ ctx[16].level === 0 && create_if_block_3$2(ctx);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
if (if_block) if_block.c();
if_block_anchor = empty();
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
m(target, anchor) {
if (if_block) if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
2019-10-03 04:13:12 +08:00
},
2020-05-30 21:19:58 +08:00
p(ctx, dirty) {
if (/*header*/ ctx[16].level === 0) {
if (if_block) {
if_block.p(ctx, dirty);
} else {
if_block = create_if_block_3$2(ctx);
if_block.c();
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
2019-10-03 04:13:12 +08:00
}
},
2020-05-30 21:19:58 +08:00
d(detaching) {
if (if_block) if_block.d(detaching);
if (detaching) detach(if_block_anchor);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (192:6) {#if tag.title}
function create_if_block$e(ctx) {
let p;
let a;
let t_value = /*tag*/ ctx[10].title + "";
let t;
2020-05-30 21:19:58 +08:00
let a_href_value;
let dispose;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
p = element("p");
a = element("a");
t = text(t_value);
attr(a, "href", a_href_value = buildHref(`#/rg~${slugify(/*tag*/ ctx[10].title)}`));
attr(a, "class", "is-inline-block");
attr(p, "class", "menu-label");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, p, anchor);
append(p, a);
append(a, t);
dispose = listen(a, "click", handleLink);
},
p(ctx, dirty) {
if (dirty & /*tagActions*/ 4 && t_value !== (t_value = /*tag*/ ctx[10].title + "")) set_data(t, t_value);
if (dirty & /*tagActions*/ 4 && a_href_value !== (a_href_value = buildHref(`#/rg~${slugify(/*tag*/ ctx[10].title)}`))) {
attr(a, "href", a_href_value);
}
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(p);
dispose();
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (204:8) {#each tag.children as child}
function create_each_block_1$3(ctx) {
let current;
2020-05-30 21:19:58 +08:00
const menuitem = new MenuItem({
props: {
2020-05-30 21:19:58 +08:00
title: /*child*/ ctx[13].title,
actions: /*child*/ ctx[13].actions,
hidden: /*actionsCount*/ ctx[4] > 50,
parentSlug: slugify(/*tag*/ ctx[10].title)
}
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
create_component(menuitem.$$.fragment);
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
mount_component(menuitem, target, anchor);
2019-10-03 04:13:12 +08:00
current = true;
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
const menuitem_changes = {};
if (dirty & /*tagActions*/ 4) menuitem_changes.title = /*child*/ ctx[13].title;
if (dirty & /*tagActions*/ 4) menuitem_changes.actions = /*child*/ ctx[13].actions;
if (dirty & /*actionsCount*/ 16) menuitem_changes.hidden = /*actionsCount*/ ctx[4] > 50;
if (dirty & /*tagActions*/ 4) menuitem_changes.parentSlug = slugify(/*tag*/ ctx[10].title);
menuitem.$set(menuitem_changes);
2019-10-03 04:13:12 +08:00
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(menuitem.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(menuitem.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
destroy_component(menuitem, detaching);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (191:4) {#each tagActions as tag}
function create_each_block$6(ctx) {
let t0;
let ul;
let t1;
let current;
let if_block = /*tag*/ ctx[10].title && create_if_block$e(ctx);
let each_value_1 = /*tag*/ ctx[10].children;
let each_blocks = [];
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_value_1.length; i += 1) {
each_blocks[i] = create_each_block_1$3(get_each_context_1$3(ctx, each_value_1, i));
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
const out = i => transition_out(each_blocks[i], 1, 1, () => {
each_blocks[i] = null;
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return {
c() {
if (if_block) if_block.c();
t0 = space();
ul = element("ul");
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
2020-05-30 21:19:58 +08:00
t1 = space();
attr(ul, "class", "menu-list");
},
m(target, anchor) {
if (if_block) if_block.m(target, anchor);
insert(target, t0, anchor);
insert(target, ul, anchor);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(ul, null);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
append(ul, t1);
current = true;
},
p(ctx, dirty) {
if (/*tag*/ ctx[10].title) {
if (if_block) {
if_block.p(ctx, dirty);
} else {
if_block = create_if_block$e(ctx);
if_block.c();
if_block.m(t0.parentNode, t0);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
2020-05-30 21:19:58 +08:00
if (dirty & /*tagActions, actionsCount, slugify*/ 20) {
each_value_1 = /*tag*/ ctx[10].children;
let i;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (i = 0; i < each_value_1.length; i += 1) {
const child_ctx = get_each_context_1$3(ctx, each_value_1, i);
2020-05-30 21:19:58 +08:00
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
transition_in(each_blocks[i], 1);
} else {
each_blocks[i] = create_each_block_1$3(child_ctx);
each_blocks[i].c();
transition_in(each_blocks[i], 1);
each_blocks[i].m(ul, t1);
}
}
2020-05-30 21:19:58 +08:00
group_outros();
2020-05-30 21:19:58 +08:00
for (i = each_value_1.length; i < each_blocks.length; i += 1) {
out(i);
}
2020-05-30 21:19:58 +08:00
check_outros();
}
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_value_1.length; i += 1) {
transition_in(each_blocks[i]);
}
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
each_blocks = each_blocks.filter(Boolean);
for (let i = 0; i < each_blocks.length; i += 1) {
transition_out(each_blocks[i]);
}
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (if_block) if_block.d(detaching);
if (detaching) detach(t0);
if (detaching) detach(ul);
destroy_each(each_blocks, detaching);
}
};
}
2020-05-30 21:19:58 +08:00
function create_fragment$k(ctx) {
let aside;
let section;
let div1;
let div0;
let p0;
let input;
let t0;
let span;
let t1;
let div2;
let p1;
let a;
let t2;
let a_href_value;
let t3;
let t4;
let current;
2020-05-30 21:19:58 +08:00
let dispose;
let if_block = /*query*/ ctx[0] === "" && create_if_block_1$b(ctx);
let each_value = /*tagActions*/ ctx[2];
let each_blocks = [];
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block$6(get_each_context$6(ctx, each_value, i));
}
const out = i => transition_out(each_blocks[i], 1, 1, () => {
each_blocks[i] = null;
});
return {
c() {
2020-05-30 21:19:58 +08:00
aside = element("aside");
section = element("section");
div1 = element("div");
div0 = element("div");
p0 = element("p");
input = element("input");
t0 = space();
span = element("span");
span.innerHTML = `<i class="fas fa-search"></i>`;
t1 = space();
div2 = element("div");
p1 = element("p");
a = element("a");
t2 = text(/*title*/ ctx[1]);
t3 = space();
if (if_block) if_block.c();
t4 = space();
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
attr(input, "id", "search-input-text");
attr(input, "class", "input is-rounded svelte-fvssqr");
attr(input, "placeholder", "Filter by path, method, and title...");
attr(span, "class", "icon is-right icon-input-search svelte-fvssqr");
attr(p0, "class", "control has-icons-right");
attr(div0, "class", "field");
attr(div1, "class", "hero-body svelte-fvssqr");
toggle_class(div1, "is-darkmode", /*isDarkmode*/ ctx[6]);
attr(section, "class", "hero is-sticky svelte-fvssqr");
toggle_class(section, "is-darkmode", /*isDarkmode*/ ctx[6]);
attr(a, "href", a_href_value = buildHref(""));
attr(p1, "class", "menu-label");
attr(div2, "class", "menu-wrapper svelte-fvssqr");
attr(aside, "class", "menu svelte-fvssqr");
toggle_class(aside, "is-collapsed", /*isCollapsed*/ ctx[5]);
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, aside, anchor);
append(aside, section);
append(section, div1);
append(div1, div0);
append(div0, p0);
append(p0, input);
set_input_value(input, /*query*/ ctx[0]);
append(p0, t0);
append(p0, span);
append(aside, t1);
append(aside, div2);
append(div2, p1);
append(p1, a);
append(a, t2);
append(div2, t3);
if (if_block) if_block.m(div2, null);
append(div2, t4);
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(div2, null);
}
current = true;
2020-05-30 21:19:58 +08:00
dispose = [
listen(input, "input", /*input_input_handler*/ ctx[9]),
listen(span, "click", function () {
if (is_function(/*searchClick*/ ctx[8])) /*searchClick*/ ctx[8].apply(this, arguments);
}),
listen(a, "click", prevent_default(function () {
if (is_function(/*tocClick*/ ctx[7])) /*tocClick*/ ctx[7].apply(this, arguments);
}))
];
},
2020-05-30 21:19:58 +08:00
p(new_ctx, [dirty]) {
ctx = new_ctx;
if (dirty & /*query*/ 1 && input.value !== /*query*/ ctx[0]) {
set_input_value(input, /*query*/ ctx[0]);
}
if (dirty & /*isDarkmode*/ 64) {
toggle_class(div1, "is-darkmode", /*isDarkmode*/ ctx[6]);
}
if (dirty & /*isDarkmode*/ 64) {
toggle_class(section, "is-darkmode", /*isDarkmode*/ ctx[6]);
}
if (!current || dirty & /*title*/ 2) set_data(t2, /*title*/ ctx[1]);
if (/*query*/ ctx[0] === "") {
if (if_block) {
if_block.p(ctx, dirty);
} else {
if_block = create_if_block_1$b(ctx);
if_block.c();
if_block.m(div2, t4);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
if (dirty & /*tagActions, actionsCount, slugify, buildHref, handleLink*/ 20) {
each_value = /*tagActions*/ ctx[2];
let i;
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context$6(ctx, each_value, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
transition_in(each_blocks[i], 1);
} else {
each_blocks[i] = create_each_block$6(child_ctx);
each_blocks[i].c();
transition_in(each_blocks[i], 1);
each_blocks[i].m(div2, null);
}
}
group_outros();
for (i = each_value.length; i < each_blocks.length; i += 1) {
out(i);
}
check_outros();
}
if (dirty & /*isCollapsed*/ 32) {
toggle_class(aside, "is-collapsed", /*isCollapsed*/ ctx[5]);
}
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_value.length; i += 1) {
transition_in(each_blocks[i]);
}
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
each_blocks = each_blocks.filter(Boolean);
for (let i = 0; i < each_blocks.length; i += 1) {
transition_out(each_blocks[i]);
}
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(aside);
if (if_block) if_block.d();
destroy_each(each_blocks, detaching);
run_all(dispose);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function headerLink(text) {
return text.toLowerCase().replace(/\s/g, "-");
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function instance$k($$self, $$props, $$invalidate) {
let { title } = $$props;
let { tagActions = [] } = $$props;
let { tagHeaders = [] } = $$props;
let { actionsCount } = $$props;
let { isCollapsed } = $$props;
let { isDarkmode } = $$props;
let { tocClick } = $$props;
let { searchClick } = $$props;
let { query } = $$props;
function input_input_handler() {
query = this.value;
$$invalidate(0, query);
}
$$self.$set = $$props => {
if ("title" in $$props) $$invalidate(1, title = $$props.title);
if ("tagActions" in $$props) $$invalidate(2, tagActions = $$props.tagActions);
if ("tagHeaders" in $$props) $$invalidate(3, tagHeaders = $$props.tagHeaders);
if ("actionsCount" in $$props) $$invalidate(4, actionsCount = $$props.actionsCount);
if ("isCollapsed" in $$props) $$invalidate(5, isCollapsed = $$props.isCollapsed);
if ("isDarkmode" in $$props) $$invalidate(6, isDarkmode = $$props.isDarkmode);
if ("tocClick" in $$props) $$invalidate(7, tocClick = $$props.tocClick);
if ("searchClick" in $$props) $$invalidate(8, searchClick = $$props.searchClick);
if ("query" in $$props) $$invalidate(0, query = $$props.query);
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
return [
query,
title,
tagActions,
tagHeaders,
actionsCount,
isCollapsed,
isDarkmode,
tocClick,
searchClick,
input_input_handler
];
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
class MenuPanel extends SvelteComponent {
constructor(options) {
super();
if (!document.getElementById("svelte-fvssqr-style")) add_css$a();
2020-05-30 21:19:58 +08:00
init(this, options, instance$k, create_fragment$k, safe_not_equal, {
title: 1,
tagActions: 2,
tagHeaders: 3,
actionsCount: 4,
isCollapsed: 5,
isDarkmode: 6,
tocClick: 7,
searchClick: 8,
query: 0
});
2020-05-30 21:19:58 +08:00
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
/* usr/local/lib/node_modules/snowboard/templates/winter/components/LogoutButton.svelte generated by Svelte v3.19.2 */
function create_fragment$l(ctx) {
let a;
let dispose;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
a = element("a");
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
a.innerHTML = `<span class="icon has-text-grey"><i class="fas fa-sign-out-alt" aria-hidden="true"></i></span>
<span>Logout</span>`;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
attr(a, "href", "javascript:void(0)");
attr(a, "class", "button is-light");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, a, anchor);
dispose = listen(a, "click", /*handleClick*/ ctx[0]);
2019-10-03 04:13:12 +08:00
},
p: noop,
i: noop,
o: noop,
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(a);
dispose();
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function instance$l($$self, $$props, $$invalidate) {
let $env;
component_subscribe($$self, env, $$value => $$invalidate(1, $env = $$value));
function handleClick() {
auth.remove($env);
removeToken($env);
removeRefreshToken($env);
}
return [handleClick];
}
class LogoutButton extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance$l, create_fragment$l, safe_not_equal, {});
}
}
/* usr/local/lib/node_modules/snowboard/templates/winter/panels/SelectorPanel.svelte generated by Svelte v3.19.2 */
function add_css$b() {
var style = element("style");
style.id = "svelte-cjzzpf-style";
style.textContent = ".icon-info.svelte-cjzzpf{cursor:pointer}.content.svelte-cjzzpf{padding:1rem 1.5rem}";
append(document.head, style);
}
function get_each_context$7(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[10] = list[i];
return child_ctx;
}
// (52:0) {#if isAuth(environment, 'oauth2')}
function create_if_block_1$c(ctx) {
let current_block_type_index;
let if_block;
let if_block_anchor;
let current;
2020-05-30 21:19:58 +08:00
const if_block_creators = [create_if_block_2$7, create_if_block_3$3, create_else_block_1$2];
const if_blocks = [];
function select_block_type(ctx, dirty) {
2020-05-30 21:19:58 +08:00
if (/*authenticating*/ ctx[1]) return 0;
if (/*authenticated*/ ctx[3]) return 1;
return 2;
2019-10-03 04:13:12 +08:00
}
current_block_type_index = select_block_type(ctx, -1);
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
2019-10-03 04:13:12 +08:00
return {
c() {
if_block.c();
if_block_anchor = empty();
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
if_blocks[current_block_type_index].m(target, anchor);
insert(target, if_block_anchor, anchor);
2019-10-03 04:13:12 +08:00
current = true;
},
2020-05-30 21:19:58 +08:00
p(ctx, dirty) {
let previous_block_index = current_block_type_index;
current_block_type_index = select_block_type(ctx, dirty);
2019-10-03 04:13:12 +08:00
if (current_block_type_index === previous_block_index) {
if_blocks[current_block_type_index].p(ctx, dirty);
} else {
group_outros();
transition_out(if_blocks[previous_block_index], 1, 1, () => {
if_blocks[previous_block_index] = null;
});
check_outros();
if_block = if_blocks[current_block_type_index];
if (!if_block) {
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
if_block.c();
}
2019-10-03 04:13:12 +08:00
transition_in(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
},
2019-10-03 04:13:12 +08:00
i(local) {
if (current) return;
transition_in(if_block);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
transition_out(if_block);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
if_blocks[current_block_type_index].d(detaching);
if (detaching) detach(if_block_anchor);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (67:2) {:else}
function create_else_block_1$2(ctx) {
let div1;
let div0;
let p;
let current;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const loginbutton = new LoginButton({
props: {
2020-05-30 21:19:58 +08:00
authOptions: /*environment*/ ctx[5].auth.options,
isPKCE: isPKCE(/*environment*/ ctx[5]),
pkceChallenge: /*pkceChallenge*/ ctx[2]
}
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
div1 = element("div");
div0 = element("div");
p = element("p");
create_component(loginbutton.$$.fragment);
attr(p, "class", "control");
attr(div0, "class", "field is-grouped");
attr(div1, "class", "navbar-item");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, div1, anchor);
append(div1, div0);
append(div0, p);
mount_component(loginbutton, p, null);
2019-10-03 04:13:12 +08:00
current = true;
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
const loginbutton_changes = {};
if (dirty & /*environment*/ 32) loginbutton_changes.authOptions = /*environment*/ ctx[5].auth.options;
if (dirty & /*environment*/ 32) loginbutton_changes.isPKCE = isPKCE(/*environment*/ ctx[5]);
if (dirty & /*pkceChallenge*/ 4) loginbutton_changes.pkceChallenge = /*pkceChallenge*/ ctx[2];
loginbutton.$set(loginbutton_changes);
2019-10-03 04:13:12 +08:00
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(loginbutton.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(loginbutton.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(div1);
destroy_component(loginbutton);
}
};
}
// (59:26)
function create_if_block_3$3(ctx) {
let div1;
let div0;
let p;
let current;
const logoutbutton = new LogoutButton({});
return {
c() {
div1 = element("div");
div0 = element("div");
p = element("p");
create_component(logoutbutton.$$.fragment);
attr(p, "class", "control");
attr(div0, "class", "field is-grouped");
attr(div1, "class", "navbar-item");
},
m(target, anchor) {
insert(target, div1, anchor);
append(div1, div0);
append(div0, p);
mount_component(logoutbutton, p, null);
current = true;
},
p: noop,
i(local) {
if (current) return;
transition_in(logoutbutton.$$.fragment, local);
current = true;
},
o(local) {
transition_out(logoutbutton.$$.fragment, local);
current = false;
},
d(detaching) {
if (detaching) detach(div1);
destroy_component(logoutbutton);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (53:2) {#if authenticating}
function create_if_block_2$7(ctx) {
let div;
return {
c() {
div = element("div");
2020-05-30 21:19:58 +08:00
div.innerHTML = `<span class="icon is-medium has-text-danger"><i class="fas fa-2x fa-spinner fa-pulse"></i></span>`;
attr(div, "class", "navbar-item");
},
m(target, anchor) {
insert(target, div, anchor);
},
p: noop,
i: noop,
o: noop,
d(detaching) {
if (detaching) detach(div);
}
};
}
// (87:4) {#each Object.keys(environments) as envName}
function create_each_block$7(ctx) {
let a;
let t0_value = /*envName*/ ctx[10] + "";
let t0;
let t1;
let a_data_name_value;
let dispose;
return {
c() {
a = element("a");
t0 = text(t0_value);
t1 = space();
attr(a, "data-name", a_data_name_value = /*envName*/ ctx[10]);
attr(a, "href", "javascript:void(0)");
2020-05-30 21:19:58 +08:00
attr(a, "class", "navbar-item");
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, a, anchor);
append(a, t0);
append(a, t1);
dispose = listen(a, "click", /*handleClick*/ ctx[7]);
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
if (dirty & /*environments*/ 1 && t0_value !== (t0_value = /*envName*/ ctx[10] + "")) set_data(t0, t0_value);
2020-05-30 21:19:58 +08:00
if (dirty & /*environments*/ 1 && a_data_name_value !== (a_data_name_value = /*envName*/ ctx[10])) {
attr(a, "data-name", a_data_name_value);
}
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(a);
dispose();
}
};
}
2020-05-30 21:19:58 +08:00
// (113:8) {:else}
function create_else_block$7(ctx) {
let span;
2019-10-03 04:13:12 +08:00
return {
c() {
span = element("span");
2020-05-30 21:19:58 +08:00
span.textContent = "None";
attr(span, "class", "is-capitalized");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
insert(target, span, anchor);
},
2020-05-30 21:19:58 +08:00
p: noop,
2019-10-03 04:13:12 +08:00
d(detaching) {
if (detaching) detach(span);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (111:8) {#if environment.auth}
function create_if_block$f(ctx) {
let span;
let t_value = /*environment*/ ctx[5].auth.name + "";
let t;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
span = element("span");
t = text(t_value);
attr(span, "class", "is-capitalized");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, span, anchor);
append(span, t);
2019-10-03 04:13:12 +08:00
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
if (dirty & /*environment*/ 32 && t_value !== (t_value = /*environment*/ ctx[5].auth.name + "")) set_data(t, t_value);
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(span);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function create_fragment$m(ctx) {
let show_if = isAuth(/*environment*/ ctx[5], "oauth2");
let t0;
let div1;
2020-05-30 21:19:58 +08:00
let a0;
let t1;
let t2;
2020-05-30 21:19:58 +08:00
let div0;
let t3;
2020-05-30 21:19:58 +08:00
let div4;
let a1;
let t4;
2020-05-30 21:19:58 +08:00
let div3;
let div2;
let p0;
let t5;
2020-05-30 21:19:58 +08:00
let t6_value = /*environment*/ ctx[5].url + "";
let t6;
let t7;
2020-05-30 21:19:58 +08:00
let p1;
let t8;
let current;
2020-05-30 21:19:58 +08:00
let dispose;
let if_block0 = show_if && create_if_block_1$c(ctx);
let each_value = Object.keys(/*environments*/ ctx[0]);
2019-10-03 04:13:12 +08:00
let each_blocks = [];
for (let i = 0; i < each_value.length; i += 1) {
2020-05-30 21:19:58 +08:00
each_blocks[i] = create_each_block$7(get_each_context$7(ctx, each_value, i));
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
function select_block_type_1(ctx, dirty) {
if (/*environment*/ ctx[5].auth) return create_if_block$f;
return create_else_block$7;
}
let current_block_type = select_block_type_1(ctx, -1);
let if_block1 = current_block_type(ctx);
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
if (if_block0) if_block0.c();
t0 = space();
2019-10-03 04:13:12 +08:00
div1 = element("div");
2020-05-30 21:19:58 +08:00
a0 = element("a");
t1 = text(/*$env*/ ctx[6]);
t2 = space();
div0 = element("div");
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
2019-10-03 04:13:12 +08:00
}
t3 = space();
2020-05-30 21:19:58 +08:00
div4 = element("div");
a1 = element("a");
a1.innerHTML = `<span class="icon icon-info is-medium has-text-grey-light svelte-cjzzpf"><i class="fas fa-lg fa-info-circle"></i></span>`;
t4 = space();
2019-10-03 04:13:12 +08:00
div3 = element("div");
2020-05-30 21:19:58 +08:00
div2 = element("div");
p0 = element("p");
t5 = text("BaseURL: ");
2019-10-03 04:13:12 +08:00
t6 = text(t6_value);
t7 = space();
2020-05-30 21:19:58 +08:00
p1 = element("p");
t8 = text("Auth:\n ");
if_block1.c();
attr(a0, "href", "javascript:void(0)");
attr(a0, "class", "navbar-link");
attr(div0, "class", "navbar-dropdown is-right");
attr(div1, "class", "navbar-item has-dropdown is-capitalized");
toggle_class(div1, "is-active", /*show*/ ctx[4]);
attr(a1, "href", "javascript:void(0)");
attr(a1, "class", "navbar-link is-arrowless");
attr(div2, "class", "content svelte-cjzzpf");
attr(div3, "class", "navbar-dropdown is-right");
attr(div4, "class", "navbar-item has-dropdown is-hoverable");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
if (if_block0) if_block0.m(target, anchor);
insert(target, t0, anchor);
insert(target, div1, anchor);
append(div1, a0);
append(a0, t1);
append(div1, t2);
append(div1, div0);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(div0, null);
2019-10-03 04:13:12 +08:00
}
insert(target, t3, anchor);
insert(target, div4, anchor);
2020-05-30 21:19:58 +08:00
append(div4, a1);
append(div4, t4);
append(div4, div3);
append(div3, div2);
append(div2, p0);
append(p0, t5);
append(p0, t6);
append(div2, t7);
append(div2, p1);
append(p1, t8);
if_block1.m(p1, null);
2019-10-03 04:13:12 +08:00
current = true;
2020-05-30 21:19:58 +08:00
dispose = listen(a0, "click", /*toggleClick*/ ctx[8]);
},
p(ctx, [dirty]) {
if (dirty & /*environment*/ 32) show_if = isAuth(/*environment*/ ctx[5], "oauth2");
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (show_if) {
if (if_block0) {
if_block0.p(ctx, dirty);
transition_in(if_block0, 1);
2019-10-03 04:13:12 +08:00
} else {
2020-05-30 21:19:58 +08:00
if_block0 = create_if_block_1$c(ctx);
if_block0.c();
transition_in(if_block0, 1);
if_block0.m(t0.parentNode, t0);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
} else if (if_block0) {
2019-10-03 04:13:12 +08:00
group_outros();
2020-05-30 21:19:58 +08:00
transition_out(if_block0, 1, 1, () => {
if_block0 = null;
2019-10-03 04:13:12 +08:00
});
2019-10-03 04:13:12 +08:00
check_outros();
}
2020-05-30 21:19:58 +08:00
if (!current || dirty & /*$env*/ 64) set_data(t1, /*$env*/ ctx[6]);
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*Object, environments, handleClick*/ 129) {
each_value = Object.keys(/*environments*/ ctx[0]);
2019-10-03 04:13:12 +08:00
let i;
2019-10-03 04:13:12 +08:00
for (i = 0; i < each_value.length; i += 1) {
2020-05-30 21:19:58 +08:00
const child_ctx = get_each_context$7(ctx, each_value, i);
2019-10-03 04:13:12 +08:00
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
2019-10-03 04:13:12 +08:00
} else {
2020-05-30 21:19:58 +08:00
each_blocks[i] = create_each_block$7(child_ctx);
2019-10-03 04:13:12 +08:00
each_blocks[i].c();
2020-05-30 21:19:58 +08:00
each_blocks[i].m(div0, null);
2019-10-03 04:13:12 +08:00
}
}
2020-05-30 21:19:58 +08:00
for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
each_blocks.length = each_value.length;
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (dirty & /*show*/ 16) {
toggle_class(div1, "is-active", /*show*/ ctx[4]);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if ((!current || dirty & /*environment*/ 32) && t6_value !== (t6_value = /*environment*/ ctx[5].url + "")) set_data(t6, t6_value);
if (current_block_type === (current_block_type = select_block_type_1(ctx, dirty)) && if_block1) {
if_block1.p(ctx, dirty);
} else {
if_block1.d(1);
if_block1 = current_block_type(ctx);
if (if_block1) {
if_block1.c();
if_block1.m(p1, null);
}
}
},
i(local) {
if (current) return;
transition_in(if_block0);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(if_block0);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (if_block0) if_block0.d(detaching);
if (detaching) detach(t0);
if (detaching) detach(div1);
destroy_each(each_blocks, detaching);
if (detaching) detach(t3);
if (detaching) detach(div4);
2020-05-30 21:19:58 +08:00
if_block1.d();
dispose();
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function instance$m($$self, $$props, $$invalidate) {
let $env;
let $auth;
component_subscribe($$self, env, $$value => $$invalidate(6, $env = $$value));
component_subscribe($$self, auth, $$value => $$invalidate(9, $auth = $$value));
let { environments } = $$props;
let { authenticating } = $$props;
let { pkceChallenge } = $$props;
let authenticated = false;
let show = false;
function handleClick(event) {
$$invalidate(4, show = false);
const envName = event.target.dataset["name"];
env.set(envName);
const authToken = getToken($env);
if (authToken) {
auth.add(envName);
token$1.set(authToken);
} else {
auth.remove(envName);
token$1.set(null);
}
}
function toggleClick() {
$$invalidate(4, show = !show);
}
$$self.$set = $$props => {
if ("environments" in $$props) $$invalidate(0, environments = $$props.environments);
if ("authenticating" in $$props) $$invalidate(1, authenticating = $$props.authenticating);
if ("pkceChallenge" in $$props) $$invalidate(2, pkceChallenge = $$props.pkceChallenge);
};
let environment;
$$self.$$.update = () => {
if ($$self.$$.dirty & /*environments, $env*/ 65) {
$$invalidate(5, environment = environments[$env]);
}
if ($$self.$$.dirty & /*$auth, $env*/ 576) {
{
$$invalidate(3, authenticated = $auth.split(";").includes($env));
}
}
};
return [
environments,
authenticating,
pkceChallenge,
authenticated,
show,
environment,
$env,
handleClick,
toggleClick
];
}
class SelectorPanel extends SvelteComponent {
constructor(options) {
super();
if (!document.getElementById("svelte-cjzzpf-style")) add_css$b();
init(this, options, instance$m, create_fragment$m, safe_not_equal, {
environments: 0,
authenticating: 1,
pkceChallenge: 2
});
}
}
/* usr/local/lib/node_modules/snowboard/templates/winter.svelte generated by Svelte v3.19.2 */
const { document: document_1 } = globals;
function add_css$c() {
var style = element("style");
style.id = "svelte-1s8fs56-style";
style.textContent = "html{height:100%}body{min-height:100%}.sidenav.svelte-1s8fs56.svelte-1s8fs56{padding:1rem 0 1rem 0.75rem}.main.svelte-1s8fs56.svelte-1s8fs56{padding:3rem;background-color:#fff;box-shadow:0 2px 0 2px #f5f5f5}.main.is-darkmode.svelte-1s8fs56.svelte-1s8fs56{background-color:#000;box-shadow:0 2px 0 2px #363636}.body-inner.svelte-1s8fs56.svelte-1s8fs56{min-height:100vh;background-color:#fafafa}.body-inner.is-darkmode.svelte-1s8fs56.svelte-1s8fs56{background-color:#000}.is-darkmode .input, .is-darkmode .select select, .is-darkmode\n .textarea{background-color:#484848;border-color:#484848;color:#fff}.is-darkmode .input:hover, .is-darkmode\n .is-hovered.input, .is-darkmode .is-hovered.textarea, .is-darkmode\n .select\n select.is-hovered, .is-darkmode .select select:hover, .is-darkmode\n .textarea:hover{border-color:#666}.is-darkmode .select select.is-focused, .is-darkmode\n .select\n select:active, .is-darkmode .select select:focus, .is-darkmode\n .textarea:active, .is-darkmode .textarea:focus{border-color:#888}.is-darkmode .input::placeholder, .is-darkmode\n .select\n select::placeholder, .is-darkmode .textarea::placeholder{color:#ccc}code[class*=\"language-\"], pre[class*=\"language-\"]{font-family:monospace}.token.number, .token.tag{display:inline;padding:inherit;font-size:inherit;line-height:inherit;text-align:inherit;vertical-align:inherit;border-radius:inherit;font-weight:inherit;white-space:inherit;background:inherit;margin:inherit}.icon-brand.svelte-1s8fs56.svelte-1s8fs56{margin-right:0.5rem}.menu-collapsible.svelte-1s8fs56.svelte-1s8fs56{display:none;position:fixed;width:calc(25% - 0.5rem);height:calc(2.5rem + 10px);left:0;bottom:0;font-size:1.33333em;line-height:calc(2.5rem + 5px);text-align:center;color:#b5b5b5;font-weight:300;border-top:1px solid #eee;box-shadow:2px 0 0 #f5f5f5;cursor:pointer}.menu-collapsible.svelte-1s8fs56.svelte-1s8fs56:hover{background:rgba(0, 0, 0, 0.05);box-shadow:2px 0 0 #eee;border-color:#e8e8e8}.menu-collapsible.is-darkmode.svelte-1s8fs56.svelte-1s8fs56{border-color:#363636;box-shadow:2px 0 0 #363636}.menu-collapsible.is-darkmode.svelte-1s8fs56.svelte-1s8fs56:hover{background:rgba(255, 255, 255, 0.2);border-color:#363636;box-shadow:2px 0 0 #363636}.footer.is-darkmode.svelte-1s8fs56.svelte-1s8fs56{background-color:#000}.footer.svelte-1s8fs56 .content.svelte-1s8fs56{transition:margin 0.3s}@media screen and (min-width: 768px){.menu-collapsible.svelte-1s8fs56.svelte-1s8fs56{display:block}.is-collapsed.svelte-1s8fs56 .sidenav.svelte-1s8fs56{width:3.75rem}.is-collapsed.svelte-1s8fs56 .main.svelte-1s8fs56{width:calc(100% - 4.5rem)}.is-collapsed.svelte-1s8fs56 .menu-collapsible.svelte-1s8fs56{width:calc(3rem - 2px)}.menu-collapsible.svelte-1s8fs56.svelte-1s8fs56,.sidenav.svelte-1s8fs56.svelte-1s8fs56,.main.svelte-1s8fs56.svelte-1s8fs56{transition:width 0.3s}.content.svelte-1s8fs56.svelte-1s8fs56{scroll-margin:200px}}";
append(document_1.head, style);
}
// (412:6) <Link href="/" class="navbar-item">
function create_default_slot_3(ctx) {
let span0;
let t0;
let span1;
let t1;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
span0 = element("span");
span0.innerHTML = `<i class="fas fa-lg fa-chalkboard"></i>`;
t0 = space();
span1 = element("span");
t1 = text(/*title*/ ctx[0]);
attr(span0, "class", "icon icon-brand is-medium has-text-grey-light svelte-1s8fs56");
attr(span1, "class", "title is-4");
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, span0, anchor);
insert(target, t0, anchor);
insert(target, span1, anchor);
append(span1, t1);
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
if (dirty & /*title*/ 1) set_data(t1, /*title*/ ctx[0]);
},
d(detaching) {
if (detaching) detach(span0);
if (detaching) detach(t0);
if (detaching) detach(span1);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// (435:8) {#if config.playground.enabled}
function create_if_block_3$4(ctx) {
let current;
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
const selectorpanel = new SelectorPanel({
props: {
environments: /*config*/ ctx[3].playground.environments,
pkceChallenge: /*challengePair*/ ctx[12],
authenticating: /*authenticating*/ ctx[6]
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
});
return {
c() {
create_component(selectorpanel.$$.fragment);
},
m(target, anchor) {
mount_component(selectorpanel, target, anchor);
current = true;
},
p(ctx, dirty) {
const selectorpanel_changes = {};
if (dirty & /*config*/ 8) selectorpanel_changes.environments = /*config*/ ctx[3].playground.environments;
if (dirty & /*authenticating*/ 64) selectorpanel_changes.authenticating = /*authenticating*/ ctx[6];
selectorpanel.$set(selectorpanel_changes);
},
i(local) {
if (current) return;
transition_in(selectorpanel.$$.fragment, local);
current = true;
},
o(local) {
transition_out(selectorpanel.$$.fragment, local);
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
destroy_component(selectorpanel, detaching);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (441:8) {#if darkMode.enable}
function create_if_block_2$8(ctx) {
let div;
let a;
2020-05-30 21:19:58 +08:00
let span;
let i;
let dispose;
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
div = element("div");
2019-10-03 04:13:12 +08:00
a = element("a");
2020-05-30 21:19:58 +08:00
span = element("span");
i = element("i");
attr(i, "class", "fas fa-lg");
toggle_class(i, "fa-moon", /*darkMode*/ ctx[7].active);
toggle_class(i, "fa-sun", !/*darkMode*/ ctx[7].active);
attr(span, "class", "icon is-medium has-text-grey-light");
2019-10-03 04:13:12 +08:00
attr(a, "href", "javascript:void(0)");
2020-05-30 21:19:58 +08:00
attr(a, "title", "Dark Mode");
attr(a, "class", "navbar-link is-arrowless");
attr(div, "class", "navbar-item has-dropdown is-hoverable");
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, div, anchor);
append(div, a);
append(a, span);
append(span, i);
dispose = listen(a, "click", /*darkToggle*/ ctx[16]);
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
if (dirty & /*darkMode*/ 128) {
toggle_class(i, "fa-moon", /*darkMode*/ ctx[7].active);
}
if (dirty & /*darkMode*/ 128) {
toggle_class(i, "fa-sun", !/*darkMode*/ ctx[7].active);
}
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(div);
dispose();
}
};
}
2020-05-30 21:19:58 +08:00
// (481:8) {#if collapsed}
function create_if_block_1$d(ctx) {
let span;
2020-05-30 21:19:58 +08:00
return {
c() {
span = element("span");
span.textContent = "»";
attr(span, "class", "icon");
attr(span, "title", "Expand [");
},
m(target, anchor) {
insert(target, span, anchor);
},
d(detaching) {
if (detaching) detach(span);
}
};
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
// (484:8) {#if !collapsed}
function create_if_block$g(ctx) {
let span0;
let t1;
let span1;
return {
c() {
2020-05-30 21:19:58 +08:00
span0 = element("span");
span0.textContent = "«";
t1 = space();
span1 = element("span");
span1.textContent = "Collapse sidebar";
attr(span0, "class", "icon");
attr(span1, "class", "fa-xs");
},
2019-10-03 04:13:12 +08:00
m(target, anchor) {
2020-05-30 21:19:58 +08:00
insert(target, span0, anchor);
insert(target, t1, anchor);
insert(target, span1, anchor);
2019-10-03 04:13:12 +08:00
},
d(detaching) {
2020-05-30 21:19:58 +08:00
if (detaching) detach(span0);
if (detaching) detach(t1);
if (detaching) detach(span1);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (495:8) <Route exact>
function create_default_slot_2(ctx) {
let current;
2020-05-30 21:19:58 +08:00
const home = new Home({
props: {
title: /*title*/ ctx[0],
description: /*description*/ ctx[1]
}
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
create_component(home.$$.fragment);
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
mount_component(home, target, anchor);
2019-10-03 04:13:12 +08:00
current = true;
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
const home_changes = {};
if (dirty & /*title*/ 1) home_changes.title = /*title*/ ctx[0];
if (dirty & /*description*/ 2) home_changes.description = /*description*/ ctx[1];
home.$set(home_changes);
2019-10-03 04:13:12 +08:00
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(home.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(home.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
destroy_component(home, detaching);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (498:8) <Route exact path="/:slug">
function create_default_slot_1(ctx) {
let current;
2020-05-30 21:19:58 +08:00
const action_1 = new Action({
props: {
2020-05-30 21:19:58 +08:00
action: /*action*/ ctx[8],
config: /*config*/ ctx[3],
environment: /*environment*/ ctx[11],
challengePair: /*challengePair*/ ctx[12],
darkMode: /*darkMode*/ ctx[7]
}
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
create_component(action_1.$$.fragment);
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
mount_component(action_1, target, anchor);
2019-10-03 04:13:12 +08:00
current = true;
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
const action_1_changes = {};
if (dirty & /*action*/ 256) action_1_changes.action = /*action*/ ctx[8];
if (dirty & /*config*/ 8) action_1_changes.config = /*config*/ ctx[3];
if (dirty & /*environment*/ 2048) action_1_changes.environment = /*environment*/ ctx[11];
if (dirty & /*darkMode*/ 128) action_1_changes.darkMode = /*darkMode*/ ctx[7];
action_1.$set(action_1_changes);
2019-10-03 04:13:12 +08:00
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(action_1.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(action_1.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
destroy_component(action_1, detaching);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
// (494:6) <Router>
function create_default_slot$2(ctx) {
let t;
let current;
2020-05-30 21:19:58 +08:00
const route0 = new Route({
props: {
exact: true,
$$slots: { default: [create_default_slot_2] },
$$scope: { ctx }
}
});
const route1 = new Route({
props: {
2020-05-30 21:19:58 +08:00
exact: true,
path: "/:slug",
$$slots: { default: [create_default_slot_1] },
$$scope: { ctx }
}
});
2019-10-03 04:13:12 +08:00
return {
c() {
2020-05-30 21:19:58 +08:00
create_component(route0.$$.fragment);
t = space();
create_component(route1.$$.fragment);
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
2020-05-30 21:19:58 +08:00
mount_component(route0, target, anchor);
insert(target, t, anchor);
mount_component(route1, target, anchor);
2019-10-03 04:13:12 +08:00
current = true;
},
p(ctx, dirty) {
2020-05-30 21:19:58 +08:00
const route0_changes = {};
if (dirty & /*$$scope, title, description*/ 16777219) {
route0_changes.$$scope = { dirty, ctx };
}
route0.$set(route0_changes);
const route1_changes = {};
if (dirty & /*$$scope, action, config, environment, darkMode*/ 16779656) {
route1_changes.$$scope = { dirty, ctx };
}
route1.$set(route1_changes);
2019-10-03 04:13:12 +08:00
},
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(route0.$$.fragment, local);
transition_in(route1.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(route0.$$.fragment, local);
transition_out(route1.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
2020-05-30 21:19:58 +08:00
destroy_component(route0, detaching);
if (detaching) detach(t);
destroy_component(route1, detaching);
2019-10-03 04:13:12 +08:00
}
};
}
2020-05-30 21:19:58 +08:00
function create_fragment$n(ctx) {
let div8;
let nav;
let div0;
let t0;
2020-05-30 21:19:58 +08:00
let a0;
let t3;
let div2;
let div1;
2020-05-30 21:19:58 +08:00
let t4;
let t5;
let div6;
let div4;
2020-05-30 21:19:58 +08:00
let t6;
let div3;
2020-05-30 21:19:58 +08:00
let t7;
let t8;
let div5;
2020-05-30 21:19:58 +08:00
let t9;
let footer;
let div7;
let p;
let strong0;
2020-05-30 21:19:58 +08:00
let t10;
let t11;
let a1;
let current;
let dispose;
2020-05-30 21:19:58 +08:00
const link = new Link({
props: {
href: "/",
class: "navbar-item",
$$slots: { default: [create_default_slot_3] },
$$scope: { ctx }
}
});
let if_block0 = /*config*/ ctx[3].playground.enabled && create_if_block_3$4(ctx);
let if_block1 = /*darkMode*/ ctx[7].enable && create_if_block_2$8(ctx);
const menupanel = new MenuPanel({
props: {
2020-05-30 21:19:58 +08:00
title: /*title*/ ctx[0],
tagActions: /*filteredActions*/ ctx[10],
tagHeaders: toc(/*description*/ ctx[1]),
2020-05-30 21:19:58 +08:00
currentSlug: /*action*/ ctx[8] && /*action*/ ctx[8].slug,
actionsCount: /*actions*/ ctx[2].length,
2020-05-30 21:19:58 +08:00
isCollapsed: /*collapsed*/ ctx[5],
isDarkmode: /*darkMode*/ ctx[7].active,
query: /*query*/ ctx[9],
tocClick,
searchClick: /*searchClick*/ ctx[15]
}
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
let if_block2 = /*collapsed*/ ctx[5] && create_if_block_1$d(ctx);
let if_block3 = !/*collapsed*/ ctx[5] && create_if_block$g(ctx);
const router_1 = new Router({
props: {
$$slots: { default: [create_default_slot$2] },
$$scope: { ctx }
}
});
2019-10-03 04:13:12 +08:00
return {
c() {
div8 = element("div");
2019-10-03 04:13:12 +08:00
nav = element("nav");
div0 = element("div");
2020-05-30 21:19:58 +08:00
create_component(link.$$.fragment);
2019-10-03 04:13:12 +08:00
t0 = space();
2020-05-30 21:19:58 +08:00
a0 = element("a");
2020-05-30 21:19:58 +08:00
a0.innerHTML = `<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>`;
2020-05-30 21:19:58 +08:00
t3 = space();
2019-10-03 04:13:12 +08:00
div2 = element("div");
div1 = element("div");
if (if_block0) if_block0.c();
2020-05-30 21:19:58 +08:00
t4 = space();
if (if_block1) if_block1.c();
2020-05-30 21:19:58 +08:00
t5 = space();
2019-10-03 04:13:12 +08:00
div6 = element("div");
div4 = element("div");
create_component(menupanel.$$.fragment);
2020-05-30 21:19:58 +08:00
t6 = space();
div3 = element("div");
2019-10-03 04:13:12 +08:00
if (if_block2) if_block2.c();
2020-05-30 21:19:58 +08:00
t7 = space();
2019-10-03 04:13:12 +08:00
if (if_block3) if_block3.c();
2020-05-30 21:19:58 +08:00
t8 = space();
div5 = element("div");
2020-05-30 21:19:58 +08:00
create_component(router_1.$$.fragment);
t9 = space();
2019-10-03 04:13:12 +08:00
footer = element("footer");
div7 = element("div");
p = element("p");
strong0 = element("strong");
2020-05-30 21:19:58 +08:00
t10 = text(/*title*/ ctx[0]);
t11 = text("\n powered by\n ");
a1 = element("a");
a1.innerHTML = `<strong>Snowboard.</strong>`;
2019-10-03 04:13:12 +08:00
attr(a0, "href", "javascript:void(0)");
2020-05-30 21:19:58 +08:00
attr(a0, "role", "button");
attr(a0, "class", "navbar-burger");
attr(a0, "aria-label", "menu");
attr(a0, "aria-expanded", "false");
attr(a0, "data-target", "mainnav");
2019-10-03 04:13:12 +08:00
attr(div0, "class", "navbar-brand");
attr(div1, "class", "navbar-end");
attr(div2, "class", "navbar-menu");
attr(nav, "class", "navbar is-fixed-top has-shadow");
attr(nav, "role", "navigation");
attr(nav, "aria-label", "main navigation");
2020-05-30 21:19:58 +08:00
attr(div3, "class", "menu-collapsible svelte-1s8fs56");
toggle_class(div3, "is-darkmode", /*darkMode*/ ctx[7].active);
attr(div4, "class", "column is-one-quarter sidenav svelte-1s8fs56");
2019-10-03 04:13:12 +08:00
attr(div4, "id", "mainnav");
2020-05-30 21:19:58 +08:00
toggle_class(div4, "is-hidden-mobile", /*showMenu*/ ctx[4]);
attr(div5, "class", "column is-three-quarters main svelte-1s8fs56");
toggle_class(div5, "is-darkmode", /*darkMode*/ ctx[7].active);
attr(div6, "class", "columns svelte-1s8fs56");
toggle_class(div6, "is-collapsed", /*collapsed*/ ctx[5]);
attr(a1, "href", "https://github.com/bukalapak/snowboard");
attr(a1, "target", "_blank");
attr(div7, "class", "content column is-paddingless has-text-centered svelte-1s8fs56");
toggle_class(div7, "is-offset-one-quarter", !/*collapsed*/ ctx[5]);
attr(footer, "class", "footer svelte-1s8fs56");
toggle_class(footer, "is-darkmode", /*darkMode*/ ctx[7].active);
attr(div8, "class", "body-inner svelte-1s8fs56");
toggle_class(div8, "is-darkmode", /*darkMode*/ ctx[7].active);
2019-10-03 04:13:12 +08:00
},
m(target, anchor) {
insert(target, div8, anchor);
append(div8, nav);
2019-10-03 04:13:12 +08:00
append(nav, div0);
2020-05-30 21:19:58 +08:00
mount_component(link, div0, null);
append(div0, t0);
2019-10-03 04:13:12 +08:00
append(div0, a0);
2020-05-30 21:19:58 +08:00
append(nav, t3);
2019-10-03 04:13:12 +08:00
append(nav, div2);
append(div2, div1);
if (if_block0) if_block0.m(div1, null);
2020-05-30 21:19:58 +08:00
append(div1, t4);
if (if_block1) if_block1.m(div1, null);
2020-05-30 21:19:58 +08:00
append(div8, t5);
append(div8, div6);
2019-10-03 04:13:12 +08:00
append(div6, div4);
mount_component(menupanel, div4, null);
2020-05-30 21:19:58 +08:00
append(div4, t6);
2019-10-03 04:13:12 +08:00
append(div4, div3);
if (if_block2) if_block2.m(div3, null);
2020-05-30 21:19:58 +08:00
append(div3, t7);
if (if_block3) if_block3.m(div3, null);
2020-05-30 21:19:58 +08:00
append(div6, t8);
2019-10-03 04:13:12 +08:00
append(div6, div5);
2020-05-30 21:19:58 +08:00
mount_component(router_1, div5, null);
append(div8, t9);
append(div8, footer);
2019-10-03 04:13:12 +08:00
append(footer, div7);
append(div7, p);
append(p, strong0);
2020-05-30 21:19:58 +08:00
append(strong0, t10);
append(p, t11);
append(p, a1);
2019-10-03 04:13:12 +08:00
current = true;
2020-05-30 21:19:58 +08:00
dispose = [
listen(a0, "click", /*burgerClick*/ ctx[13]),
listen(div3, "click", /*collapseToggle*/ ctx[14])
];
2019-10-03 04:13:12 +08:00
},
p(ctx, [dirty]) {
2020-05-30 21:19:58 +08:00
const link_changes = {};
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (dirty & /*$$scope, title*/ 16777217) {
link_changes.$$scope = { dirty, ctx };
}
link.$set(link_changes);
if (/*config*/ ctx[3].playground.enabled) {
2019-10-03 04:13:12 +08:00
if (if_block0) {
if_block0.p(ctx, dirty);
2019-10-03 04:13:12 +08:00
transition_in(if_block0, 1);
} else {
2020-05-30 21:19:58 +08:00
if_block0 = create_if_block_3$4(ctx);
2019-10-03 04:13:12 +08:00
if_block0.c();
transition_in(if_block0, 1);
2020-05-30 21:19:58 +08:00
if_block0.m(div1, t4);
2019-10-03 04:13:12 +08:00
}
} else if (if_block0) {
group_outros();
2019-10-03 04:13:12 +08:00
transition_out(if_block0, 1, 1, () => {
if_block0 = null;
});
2019-10-03 04:13:12 +08:00
check_outros();
}
2020-05-30 21:19:58 +08:00
if (/*darkMode*/ ctx[7].enable) {
if (if_block1) {
if_block1.p(ctx, dirty);
} else {
2020-05-30 21:19:58 +08:00
if_block1 = create_if_block_2$8(ctx);
2019-10-03 04:13:12 +08:00
if_block1.c();
if_block1.m(div1, null);
2019-10-03 04:13:12 +08:00
}
} else if (if_block1) {
if_block1.d(1);
if_block1 = null;
}
const menupanel_changes = {};
2020-05-30 21:19:58 +08:00
if (dirty & /*title*/ 1) menupanel_changes.title = /*title*/ ctx[0];
if (dirty & /*filteredActions*/ 1024) menupanel_changes.tagActions = /*filteredActions*/ ctx[10];
if (dirty & /*description*/ 2) menupanel_changes.tagHeaders = toc(/*description*/ ctx[1]);
2020-05-30 21:19:58 +08:00
if (dirty & /*action*/ 256) menupanel_changes.currentSlug = /*action*/ ctx[8] && /*action*/ ctx[8].slug;
if (dirty & /*actions*/ 4) menupanel_changes.actionsCount = /*actions*/ ctx[2].length;
2020-05-30 21:19:58 +08:00
if (dirty & /*collapsed*/ 32) menupanel_changes.isCollapsed = /*collapsed*/ ctx[5];
if (dirty & /*darkMode*/ 128) menupanel_changes.isDarkmode = /*darkMode*/ ctx[7].active;
if (dirty & /*query*/ 512) menupanel_changes.query = /*query*/ ctx[9];
menupanel.$set(menupanel_changes);
2020-05-30 21:19:58 +08:00
if (/*collapsed*/ ctx[5]) {
2019-10-03 04:13:12 +08:00
if (!if_block2) {
2020-05-30 21:19:58 +08:00
if_block2 = create_if_block_1$d(ctx);
2019-10-03 04:13:12 +08:00
if_block2.c();
2020-05-30 21:19:58 +08:00
if_block2.m(div3, t7);
} else {
2019-10-03 04:13:12 +08:00
}
} else if (if_block2) {
if_block2.d(1);
if_block2 = null;
}
2020-05-30 21:19:58 +08:00
if (!/*collapsed*/ ctx[5]) {
if (!if_block3) {
2020-05-30 21:19:58 +08:00
if_block3 = create_if_block$g(ctx);
2019-10-03 04:13:12 +08:00
if_block3.c();
if_block3.m(div3, null);
} else {
2019-10-03 04:13:12 +08:00
}
} else if (if_block3) {
if_block3.d(1);
if_block3 = null;
}
2020-05-30 21:19:58 +08:00
if (dirty & /*darkMode*/ 128) {
toggle_class(div3, "is-darkmode", /*darkMode*/ ctx[7].active);
}
2020-05-30 21:19:58 +08:00
if (dirty & /*showMenu*/ 16) {
toggle_class(div4, "is-hidden-mobile", /*showMenu*/ ctx[4]);
}
2020-05-30 21:19:58 +08:00
const router_1_changes = {};
2020-05-30 21:19:58 +08:00
if (dirty & /*$$scope, action, config, environment, darkMode, title, description*/ 16779659) {
router_1_changes.$$scope = { dirty, ctx };
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
router_1.$set(router_1_changes);
if (dirty & /*darkMode*/ 128) {
toggle_class(div5, "is-darkmode", /*darkMode*/ ctx[7].active);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (dirty & /*collapsed*/ 32) {
toggle_class(div6, "is-collapsed", /*collapsed*/ ctx[5]);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (!current || dirty & /*title*/ 1) set_data(t10, /*title*/ ctx[0]);
2020-05-30 21:19:58 +08:00
if (dirty & /*collapsed*/ 32) {
toggle_class(div7, "is-offset-one-quarter", !/*collapsed*/ ctx[5]);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
if (dirty & /*darkMode*/ 128) {
toggle_class(footer, "is-darkmode", /*darkMode*/ ctx[7].active);
}
2020-05-30 21:19:58 +08:00
if (dirty & /*darkMode*/ 128) {
toggle_class(div8, "is-darkmode", /*darkMode*/ ctx[7].active);
}
},
2019-10-03 04:13:12 +08:00
i(local) {
if (current) return;
2020-05-30 21:19:58 +08:00
transition_in(link.$$.fragment, local);
2019-10-03 04:13:12 +08:00
transition_in(if_block0);
transition_in(menupanel.$$.fragment, local);
2020-05-30 21:19:58 +08:00
transition_in(router_1.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = true;
},
o(local) {
2020-05-30 21:19:58 +08:00
transition_out(link.$$.fragment, local);
2019-10-03 04:13:12 +08:00
transition_out(if_block0);
transition_out(menupanel.$$.fragment, local);
2020-05-30 21:19:58 +08:00
transition_out(router_1.$$.fragment, local);
2019-10-03 04:13:12 +08:00
current = false;
},
d(detaching) {
if (detaching) detach(div8);
2020-05-30 21:19:58 +08:00
destroy_component(link);
2019-10-03 04:13:12 +08:00
if (if_block0) if_block0.d();
if (if_block1) if_block1.d();
destroy_component(menupanel);
2019-10-03 04:13:12 +08:00
if (if_block2) if_block2.d();
if (if_block3) if_block3.d();
2020-05-30 21:19:58 +08:00
destroy_component(router_1);
2019-10-03 04:13:12 +08:00
run_all(dispose);
}
};
}
2020-05-30 21:19:58 +08:00
function getQuery(slug) {
if (!slug) return "";
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (slug.startsWith("rg~")) {
const tagPrefix = slug.substr(0, 2);
const tagSlug = slug.substr(3);
return `${tagPrefix}:${tagSlug}`;
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (slug.startsWith("g~")) {
const groupPrefix = slug.substr(0, 1);
const groupSlug = slug.substr(2);
return `${groupPrefix}:${groupSlug}`;
}
return "";
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
function tocClick(event) {
navigateTo("/");
let href = event.target.getAttribute("href");
const target = document.getElementById(href.substr(1));
window.scrollTo(0, target ? target.offsetTop - 80 : 20);
2019-10-03 04:13:12 +08:00
}
2020-05-30 21:19:58 +08:00
function instance$n($$self, $$props, $$invalidate) {
let $router;
2019-10-03 04:13:12 +08:00
let $env;
2020-05-30 21:19:58 +08:00
component_subscribe($$self, router, $$value => $$invalidate(18, $router = $$value));
component_subscribe($$self, env, $$value => $$invalidate(19, $env = $$value));
Router.hashchange = true;
let { title } = $$props;
let { description } = $$props;
let { actions } = $$props;
let { tagActions } = $$props;
let { config } = $$props;
2020-05-30 21:19:58 +08:00
function findAction(slug) {
return actions.find(el => el.slug === slug);
}
function getAction(slug) {
if (!slug) return;
if (slug.startsWith("rg~")) {
const tagSlug = slug.substr(3);
const firstGroup = firstTagGroup(tagSlug);
if (firstGroup) {
const groupSlug = `${tagSlug}~${slugify(firstGroup.title)}`;
const selected = firstGroupAction(groupSlug);
return findAction(selected.slug);
}
2020-05-30 21:19:58 +08:00
return;
}
if (slug.startsWith("g~")) {
const groupSlug = slug.substr(2);
const selected = firstGroupAction(groupSlug);
return findAction(selected.slug);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
return findAction(slug);
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
function firstTagGroup(tagSlug) {
let matches = [];
tagActions.forEach(tag => {
if (slugify(tag.title) === tagSlug) {
matches.push(tag);
}
});
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if (matches.length > 0) {
return matches[0].children[0];
}
}
2019-10-03 04:13:12 +08:00
function firstGroupAction(groupSlug) {
let matches = [];
2020-05-30 21:19:58 +08:00
const slugs = groupSlug.split("~");
2019-10-03 04:13:12 +08:00
tagActions.forEach(tag => {
2020-05-30 21:19:58 +08:00
matches = matches.concat(tag.children.filter(child => slugify(child.title) === slugs[1] && slugify(tag.title) === slugs[0]));
});
2019-10-03 04:13:12 +08:00
if (matches.length > 0) {
return matches[0].actions[0];
}
}
2019-10-03 04:13:12 +08:00
if (config.playground.enabled) {
const savedEnv = getEnv();
2019-10-03 04:13:12 +08:00
if (savedEnv && Object.keys(config.playground.environments).includes(savedEnv)) {
env.set(savedEnv);
} else {
env.set(config.playground.env);
}
2019-10-03 04:13:12 +08:00
const authToken = getToken($env);
2019-10-03 04:13:12 +08:00
if (authToken) {
auth.add($env);
2020-05-30 21:19:58 +08:00
token$1.set(authToken);
}
}
2019-10-03 04:13:12 +08:00
let showMenu = true;
let collapsed = false;
let authenticating = false;
2020-05-30 21:19:58 +08:00
let challengePair = getPKCE();
2019-10-03 04:13:12 +08:00
function burgerClick() {
2020-05-30 21:19:58 +08:00
$$invalidate(4, showMenu = !showMenu);
}
2019-10-03 04:13:12 +08:00
function collapseToggle() {
2020-05-30 21:19:58 +08:00
$$invalidate(5, collapsed = !collapsed);
}
2019-10-03 04:13:12 +08:00
function searchClick() {
collapseToggle();
const searchInput = document.getElementById("search-input-text");
2019-10-03 04:13:12 +08:00
if (searchInput) {
searchInput.focus();
}
}
2019-10-03 04:13:12 +08:00
const darkMode = {
enable: true,
store: window.localStorage,
toggle: "darkmode-toggle",
mode: ["light", "dark"],
active: false
};
2019-10-03 04:13:12 +08:00
function darkToggle() {
2020-05-30 21:19:58 +08:00
$$invalidate(7, darkMode.active = !darkMode.active, darkMode);
document.getElementById(`bulma-theme-${darkMode.mode[Number(!darkMode.active)]}`).media = "none";
document.getElementById(`bulma-theme-${darkMode.mode[Number(darkMode.active)]}`).media = "";
darkMode.store.setItem(darkMode.toggle, darkMode.mode[Number(darkMode.active)]);
}
2019-10-03 04:13:12 +08:00
if (darkMode.store.getItem(darkMode.toggle) === darkMode.mode[1]) {
darkToggle();
}
2019-10-03 04:13:12 +08:00
onMount(async () => {
if (isAuth(environment, "oauth2")) {
const authParam = querystringify_1.parse(location.search);
2019-10-03 04:13:12 +08:00
if (authParam.code) {
2020-05-30 21:19:58 +08:00
$$invalidate(6, authenticating = true);
navigateTo(config.basePath);
const { accessToken, refreshToken } = await exchangeToken(authParam.code, environment.auth.options, isPKCE(environment), challengePair);
2019-10-03 04:13:12 +08:00
if (accessToken) {
setToken($env, accessToken);
auth.add($env);
2020-05-30 21:19:58 +08:00
token$1.set(accessToken);
2019-10-03 04:13:12 +08:00
if (refreshToken) {
setRefreshToken($env, refreshToken);
}
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
$$invalidate(6, authenticating = false);
clearPKCE();
clearState();
}
}
});
document.onkeyup = function (e) {
if ((e.which || e.keyCode) == 219) {
collapseToggle();
}
};
2019-10-03 04:13:12 +08:00
$$self.$set = $$props => {
if ("title" in $$props) $$invalidate(0, title = $$props.title);
if ("description" in $$props) $$invalidate(1, description = $$props.description);
if ("actions" in $$props) $$invalidate(2, actions = $$props.actions);
2020-05-30 21:19:58 +08:00
if ("tagActions" in $$props) $$invalidate(17, tagActions = $$props.tagActions);
if ("config" in $$props) $$invalidate(3, config = $$props.config);
2019-10-03 04:13:12 +08:00
};
2020-05-30 21:19:58 +08:00
let action;
let query;
let filteredActions;
let environment;
$$self.$$.update = () => {
2020-05-30 21:19:58 +08:00
if ($$self.$$.dirty & /*$router*/ 262144) {
$$invalidate(8, action = getAction($router.params.slug));
}
if ($$self.$$.dirty & /*$router*/ 262144) {
$$invalidate(9, query = getQuery($router.params.slug));
}
if ($$self.$$.dirty & /*tagActions, query*/ 131584) {
$$invalidate(10, filteredActions = filterActions(tagActions, query));
}
2019-10-03 04:13:12 +08:00
2020-05-30 21:19:58 +08:00
if ($$self.$$.dirty & /*action, title*/ 257) {
{
2020-05-30 21:19:58 +08:00
document.title = action && `${action.title} - ${title}` || title;
}
}
2020-05-30 21:19:58 +08:00
if ($$self.$$.dirty & /*config, $env*/ 524296) {
$$invalidate(11, environment = config.playground.enabled && config.playground.environments[$env]);
}
2019-10-03 04:13:12 +08:00
};
return [
2019-10-03 04:13:12 +08:00
title,
description,
actions,
config,
showMenu,
collapsed,
authenticating,
darkMode,
2020-05-30 21:19:58 +08:00
action,
query,
filteredActions,
environment,
2020-05-30 21:19:58 +08:00
challengePair,
2019-10-03 04:13:12 +08:00
burgerClick,
collapseToggle,
searchClick,
2020-05-30 21:19:58 +08:00
darkToggle,
tagActions
];
2019-10-03 04:13:12 +08:00
}
class Winter extends SvelteComponent {
constructor(options) {
super();
2020-05-30 21:19:58 +08:00
if (!document_1.getElementById("svelte-1s8fs56-style")) add_css$c();
2020-05-30 21:19:58 +08:00
init(this, options, instance$n, create_fragment$n, safe_not_equal, {
title: 0,
description: 1,
actions: 2,
2020-05-30 21:19:58 +08:00
tagActions: 17,
config: 3
});
2019-10-03 04:13:12 +08:00
}
}
const app = new Winter({
target: document.body,
2020-05-30 21:19:58 +08:00
props: {"title":"mailcow API","description":"mailcow is complete e-mailing solution with advanced antispam, antivirus, nice UI and API.\n\nIn order to use this API you have to create a API key and add your IP address to the whitelist of allowed IPs this can be done by logging into the Mailcow UI using your admin account, then go to Configuration > Access > Edit administrator details > API. There you will find a collapsed API menu.\n\n**This documentation is in Work In Progress status. It contains only few endpoints.**","version":"","servers":[{"url":"https://mailcow.host/"}],"tags":[{"title":"Domains","description":"","children":[{"title":"Get domains","description":"","children":[]},{"title":"Create domain","description":"","children":[]},{"title":"Update domain","description":"","children":[]},{"title":"Delete domain","description":"","children":[]}]},{"title":"Domain antispam policies","description":"You can create antispam whitelist and blacklist policies","children":[{"title":"List whitelist domain policy","description":"","children":[]},{"title":"List blacklist domain policy","description":"","children":[]},{"title":"Create domain policy","description":"","children":[]},{"title":"Delete domain policy","description":"","children":[]}]},{"title":"Mailboxes","description":"","children":[{"title":"Get mailboxes","description":"","children":[]},{"title":"Create mailbox","description":"","children":[]},{"title":"Update mailbox","description":"","children":[]},{"title":"Update mailbox ACL","description":"","children":[]},{"title":"Update Pushover settings","description":"","children":[]},{"title":"Delete mailbox","description":"","children":[]},{"title":"Quarantine Notifications","description":"","children":[]}]},{"title":"Aliases","description":"","children":[{"title":"Get aliases","description":"","children":[]},{"title":"Create alias","description":"","children":[]},{"title":"Update alias","description":"","children":[]},{"title":"Delete alias","description":"","children":[]}]},{"title":"Sync jobs","description":"","children":[{"title":"Get sync jobs","description":"","children":[]},{"title":"Create sync job","description":"","children":[]},{"title":"Update sync job","description":"","children":[]},{"title":"Delete sync job","description":"","children":[]}]},{"title":"Fordwarding Hosts","description":"","children":[{"title":"Get Forwarding Hosts","description":"","children":[]},{"title":"Add Forward Host","description":"","children":[]},{"title":"Delete Forward Host","description":"","children":[]}]},{"title":"Logs","description":"","children":[{"title":"Get Postfix logs","description":"","children":[]},{"title":"Get Rspamd logs","description":"","children":[]},{"title":"Get Dovecot logs","description":"","children":[]},{"title":"Get ACME logs","description":"","children":[]},{"title":"Get SOGo logs","description":"","children":[]},{"title":"Get Watchdog logs","description":"","children":[]},{"title":"Get Api logs","description":"","children":[]},{"title":"Get Ratelimit logs","description":"","children":[]},{"title":"Get Netfilter logs","description":"","children":[]},{"title":"Get Autodiscover logs","description":"","children":[]}]},{"title":"Queue Manager","description":"","children":[{"title":"Get Queue","description":"","children":[]},{"title":"Flush Queue","description":"","children":[]},{"title":"Delete Queue","description":"","children":[]}]},{"title":"Quarantine","description":"","children":[{"title":"Get mails in Quarantine","description":"","children":[]},{"title":"Delete mails in Quarantine","description":"","children":[]}]},{"title":"Fail2Ban","description":"","children":[{"title":"Get Fail2Ban Config","description":"","children":[]},{"title":"Edit Fail2Ban","description":"","children":[]}]},{"title":"DKIM","description":"","children":[{"title":"Get DKIM Key","description":"","children":[]},{"title":"Generate DKIM Key","description":"","children":[]},{"title":"Duplicate DKIM Key","description":"","children":[]},{"title":"Delete DKIM Key","description":"","children":[]}]},{"title":"Domain admin","desc
2019-10-03 04:13:12 +08:00
});
return app;
}());
</script>
</body>
</html>