(function(l, r) { if (!l || l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (self.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(self.document); (function (marked) { 'use strict'; function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var marked__default = /*#__PURE__*/_interopDefaultLegacy(marked); function noop() { } 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 is_empty(obj) { return Object.keys(obj).length === 0; } function insert(target, node, anchor) { target.insertBefore(node, anchor || null); } function detach(node) { node.parentNode.removeChild(node); } function element(name) { return document.createElement(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 attr(node, attribute, value) { if (value == null) node.removeAttribute(attribute); else if (node.getAttribute(attribute) !== value) node.setAttribute(attribute, value); } function children(element) { return Array.from(element.childNodes); } function set_input_value(input, value) { input.value = value == null ? '' : value; } function set_style(node, key, value, important) { node.style.setProperty(key, value, important ? 'important' : ''); } function custom_event(type, detail, bubbles = false) { const e = document.createEvent('CustomEvent'); e.initCustomEvent(type, bubbles, false, detail); return e; } class HtmlTag { constructor() { this.e = this.n = null; } c(html) { this.h(html); } m(html, target, anchor = null) { if (!this.e) { this.e = element(target.nodeName); this.t = target; this.c(html); } this.i(anchor); } h(html) { this.e.innerHTML = html; this.n = Array.from(this.e.childNodes); } i(anchor) { for (let i = 0; i < this.n.length; i += 1) { insert(this.t, this.n[i], anchor); } } p(html) { this.d(); this.h(html); this.i(this.a); } d() { this.n.forEach(detach); } } let current_component; function set_current_component(component) { current_component = component; } const dirty_components = []; 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 add_render_callback(fn) { render_callbacks.push(fn); } let flushing = false; const seen_callbacks = new Set(); function flush() { if (flushing) return; flushing = true; do { // first, call beforeUpdate functions // and update components for (let i = 0; i < dirty_components.length; i += 1) { const component = dirty_components[i]; set_current_component(component); update(component.$$); } set_current_component(null); dirty_components.length = 0; 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); callback(); } } render_callbacks.length = 0; } while (dirty_components.length); while (flush_callbacks.length) { flush_callbacks.pop()(); } update_scheduled = false; flushing = false; seen_callbacks.clear(); } function update($$) { if ($$.fragment !== null) { $$.update(); run_all($$.before_update); const dirty = $$.dirty; $$.dirty = [-1]; $$.fragment && $$.fragment.p($$.ctx, dirty); $$.after_update.forEach(add_render_callback); } } const outroing = new Set(); function transition_in(block, local) { if (block && block.i) { outroing.delete(block); block.i(local); } } function mount_component(component, target, anchor, customElement) { const { fragment, on_mount, on_destroy, after_update } = component.$$; fragment && fragment.m(target, anchor); if (!customElement) { // 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); // TODO null out other refs, including component.$$ (but need to // preserve final state?) $$.on_destroy = $$.fragment = null; $$.ctx = []; } } function make_dirty(component, i) { if (component.$$.dirty[0] === -1) { dirty_components.push(component); schedule_update(); component.$$.dirty.fill(0); } component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31)); } function init(component, options, instance, create_fragment, not_equal, props, append_styles, dirty = [-1]) { const parent_component = current_component; set_current_component(component); const $$ = component.$$ = { fragment: null, ctx: null, // state props, update: noop, not_equal, bound: blank_object(), // lifecycle on_mount: [], on_destroy: [], on_disconnect: [], before_update: [], after_update: [], context: new Map(parent_component ? parent_component.$$.context : options.context || []), // everything else callbacks: blank_object(), dirty, skip_bound: false, root: options.target || parent_component.$$.root }; append_styles && append_styles($$.root); let ready = false; $$.ctx = instance ? instance(component, options.props || {}, (i, ret, ...rest) => { const value = rest.length ? rest[0] : ret; if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) { if (!$$.skip_bound && $$.bound[i]) $$.bound[i](value); if (ready) make_dirty(component, i); } return ret; }) : []; $$.update(); ready = true; run_all($$.before_update); // `false` as a special case of no DOM component $$.fragment = create_fragment ? create_fragment($$.ctx) : false; if (options.target) { if (options.hydrate) { const nodes = children(options.target); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion $$.fragment && $$.fragment.l(nodes); nodes.forEach(detach); } else { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion $$.fragment && $$.fragment.c(); } if (options.intro) transition_in(component.$$.fragment); mount_component(component, options.target, options.anchor, options.customElement); flush(); } set_current_component(parent_component); } /** * Base class for Svelte components. Used when dev=false. */ 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($$props) { if (this.$$set && !is_empty($$props)) { this.$$.skip_bound = true; this.$$set($$props); this.$$.skip_bound = false; } } } function dispatch_dev(type, detail) { document.dispatchEvent(custom_event(type, Object.assign({ version: '3.42.6' }, detail), true)); } 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 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 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}".`); } } } /** * Base class for Svelte components with some minor dev-enhancements. Used when dev=true. */ 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 }; } $capture_state() { } $inject_state() { } } /* src\App.svelte generated by Svelte v3.42.6 */ const file = "src\\App.svelte"; // (27:1) {:else} function create_else_block(ctx) { let t; const block = { c: function create() { t = text("Show preview"); }, m: function mount(target, anchor) { insert_dev(target, t, anchor); }, d: function destroy(detaching) { if (detaching) detach_dev(t); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_else_block.name, type: "else", source: "(27:1) {:else}", ctx }); return block; } // (25:1) {#if show_preview} function create_if_block_1(ctx) { let t; const block = { c: function create() { t = text("Hide preview"); }, m: function mount(target, anchor) { insert_dev(target, t, anchor); }, d: function destroy(detaching) { if (detaching) detach_dev(t); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block_1.name, type: "if", source: "(25:1) {#if show_preview}", ctx }); return block; } // (34:0) {#if show_preview} function create_if_block(ctx) { let html_tag; let raw_value = marked__default['default'](marking(/*text*/ ctx[0])) + ""; let html_anchor; const block = { c: function create() { html_tag = new HtmlTag(); html_anchor = empty(); html_tag.a = html_anchor; }, m: function mount(target, anchor) { html_tag.m(raw_value, target, anchor); insert_dev(target, html_anchor, anchor); }, p: function update(ctx, dirty) { if (dirty & /*text*/ 1 && raw_value !== (raw_value = marked__default['default'](marking(/*text*/ ctx[0])) + "")) html_tag.p(raw_value); }, d: function destroy(detaching) { if (detaching) detach_dev(html_anchor); if (detaching) html_tag.d(); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block.name, type: "if", source: "(34:0) {#if show_preview}", ctx }); return block; } function create_fragment(ctx) { let textarea; let t0; let div; let t1; let pre; let t2; let t3; let span; let mounted; let dispose; function select_block_type(ctx, dirty) { if (/*show_preview*/ ctx[1]) return create_if_block_1; return create_else_block; } let current_block_type = select_block_type(ctx); let if_block0 = current_block_type(ctx); let if_block1 = /*show_preview*/ ctx[1] && create_if_block(ctx); const block = { c: function create() { textarea = element("textarea"); t0 = space(); div = element("div"); if_block0.c(); t1 = space(); pre = element("pre"); t2 = space(); if (if_block1) if_block1.c(); t3 = space(); span = element("span"); attr_dev(textarea, "form", "submitform"); attr_dev(textarea, "id", "post-text"); attr_dev(textarea, "class", "form-control rounded"); attr_dev(textarea, "aria-label", "With textarea"); attr_dev(textarea, "placeholder", "Optional if you have a link or an image."); attr_dev(textarea, "rows", "3"); attr_dev(textarea, "name", "body"); attr_dev(textarea, "oninput", "charLimit('post-text','character-count-submit-text-form');checkForRequired()"); attr_dev(textarea, "maxlength", "10000"); textarea.required = true; add_location(textarea, file, 21, 0, 468); attr_dev(div, "class", "btn btn-secondary"); set_style(div, "float", "right"); add_location(div, file, 23, 0, 788); add_location(pre, file, 31, 0, 943); attr_dev(span, "class", "position-absolute text-small font-weight-bold"); attr_dev(span, "id", "character-count-submit-text-form"); set_style(span, "right", "1rem"); set_style(span, "bottom", "0.5rem"); set_style(span, "z-index", "3"); add_location(span, file, 37, 0, 1013); }, l: function claim(nodes) { throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); }, m: function mount(target, anchor) { insert_dev(target, textarea, anchor); set_input_value(textarea, /*text*/ ctx[0]); insert_dev(target, t0, anchor); insert_dev(target, div, anchor); if_block0.m(div, null); insert_dev(target, t1, anchor); insert_dev(target, pre, anchor); insert_dev(target, t2, anchor); if (if_block1) if_block1.m(target, anchor); insert_dev(target, t3, anchor); insert_dev(target, span, anchor); if (!mounted) { dispose = [ listen_dev(textarea, "input", /*textarea_input_handler*/ ctx[3]), listen_dev(div, "click", /*togglePreview*/ ctx[2], false, false, false) ]; mounted = true; } }, p: function update(ctx, [dirty]) { if (dirty & /*text*/ 1) { set_input_value(textarea, /*text*/ ctx[0]); } if (current_block_type !== (current_block_type = select_block_type(ctx))) { if_block0.d(1); if_block0 = current_block_type(ctx); if (if_block0) { if_block0.c(); if_block0.m(div, null); } } if (/*show_preview*/ ctx[1]) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block(ctx); if_block1.c(); if_block1.m(t3.parentNode, t3); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } }, i: noop, o: noop, d: function destroy(detaching) { if (detaching) detach_dev(textarea); if (detaching) detach_dev(t0); if (detaching) detach_dev(div); if_block0.d(); if (detaching) detach_dev(t1); if (detaching) detach_dev(pre); if (detaching) detach_dev(t2); if (if_block1) if_block1.d(detaching); if (detaching) detach_dev(t3); if (detaching) detach_dev(span); mounted = false; run_all(dispose); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment.name, type: "component", source: "", ctx }); return block; } function marking(markdown) { let emojis = Array.from(markdown.matchAll(/:(.{1,30}?):/gi)); if (emojis != null) { for (let i = 0; i < emojis.length; i++) { markdown = markdown.replace(emojis[i][0], ""); } } return markdown; } function instance($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; validate_slots('App', slots, []); let text = ``; let show_preview = false; function togglePreview() { $$invalidate(1, show_preview = !show_preview); } const writable_props = []; Object.keys($$props).forEach(key => { if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console.warn(` was created with unknown prop '${key}'`); }); function textarea_input_handler() { text = this.value; $$invalidate(0, text); } $$self.$capture_state = () => ({ marked: marked__default['default'], text, show_preview, marking, togglePreview }); $$self.$inject_state = $$props => { if ('text' in $$props) $$invalidate(0, text = $$props.text); if ('show_preview' in $$props) $$invalidate(1, show_preview = $$props.show_preview); }; if ($$props && "$$inject" in $$props) { $$self.$inject_state($$props.$$inject); } return [text, show_preview, togglePreview, textarea_input_handler]; } class App extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance, create_fragment, safe_not_equal, {}); dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "App", options, id: create_fragment.name }); } } new App({ target: document.querySelector('#svelte-app') }); }(marked)); //# sourceMappingURL=bundle.js.map