Chris4K/diffusiondb
0
1function noop() { }2function run(fn) {3 return fn();4}5function blank_object() {6 return Object.create(null);7}8function run_all(fns) {9 fns.forEach(run);10}11function is_function(thing) {12 return typeof thing === 'function';13}14function safe_not_equal(a, b) {15 return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');16}17let src_url_equal_anchor;18function src_url_equal(element_src, url) {19 if (!src_url_equal_anchor) {20 src_url_equal_anchor = document.createElement('a');21 }22 src_url_equal_anchor.href = url;23 return element_src === src_url_equal_anchor.href;24}25function is_empty(obj) {26 return Object.keys(obj).length === 0;27}28 29// Track which nodes are claimed during hydration. Unclaimed nodes can then be removed from the DOM30// at the end of hydration without touching the remaining nodes.31let is_hydrating = false;32function start_hydrating() {33 is_hydrating = true;34}35function end_hydrating() {36 is_hydrating = false;37}38function upper_bound(low, high, key, value) {39 // Return first index of value larger than input value in the range [low, high)40 while (low < high) {41 const mid = low + ((high - low) >> 1);42 if (key(mid) <= value) {43 low = mid + 1;44 }45 else {46 high = mid;47 }48 }49 return low;50}51function init_hydrate(target) {52 if (target.hydrate_init)53 return;54 target.hydrate_init = true;55 // We know that all children have claim_order values since the unclaimed have been detached if target is not <head>56 let children = target.childNodes;57 // If target is <head>, there may be children without claim_order58 if (target.nodeName === 'HEAD') {59 const myChildren = [];60 for (let i = 0; i < children.length; i++) {61 const node = children[i];62 if (node.claim_order !== undefined) {63 myChildren.push(node);64 }65 }66 children = myChildren;67 }68 /*69 * Reorder claimed children optimally.70 * We can reorder claimed children optimally by finding the longest subsequence of71 * nodes that are already claimed in order and only moving the rest. The longest72 * subsequence subsequence of nodes that are claimed in order can be found by73 * computing the longest increasing subsequence of .claim_order values.74 *75 * This algorithm is optimal in generating the least amount of reorder operations76 * possible.77 *78 * Proof:79 * We know that, given a set of reordering operations, the nodes that do not move80 * always form an increasing subsequence, since they do not move among each other81 * meaning that they must be already ordered among each other. Thus, the maximal82 * set of nodes that do not move form a longest increasing subsequence.83 */84 // Compute longest increasing subsequence85 // m: subsequence length j => index k of smallest value that ends an increasing subsequence of length j86 const m = new Int32Array(children.length + 1);87 // Predecessor indices + 188 const p = new Int32Array(children.length);89 m[0] = -1;90 let longest = 0;91 for (let i = 0; i < children.length; i++) {92 const current = children[i].claim_order;93 // Find the largest subsequence length such that it ends in a value less than our current value94 // upper_bound returns first greater value, so we subtract one95 // with fast path for when we are on the current longest subsequence96 const seqLen = ((longest > 0 && children[m[longest]].claim_order <= current) ? longest + 1 : upper_bound(1, longest, idx => children[m[idx]].claim_order, current)) - 1;97 p[i] = m[seqLen] + 1;98 const newLen = seqLen + 1;99 // We can guarantee that current is the smallest value. Otherwise, we would have generated a longer sequence.100 m[newLen] = i;101 longest = Math.max(newLen, longest);102 }103 // The longest increasing subsequence of nodes (initially reversed)104 const lis = [];105 // The rest of the nodes, nodes that will be moved106 const toMove = [];107 let last = children.length - 1;108 for (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) {109 lis.push(children[cur - 1]);110 for (; last >= cur; last--) {111 toMove.push(children[last]);112 }113 last--;114 }115 for (; last >= 0; last--) {116 toMove.push(children[last]);117 }118 lis.reverse();119 // We sort the nodes being moved to guarantee that their insertion order matches the claim order120 toMove.sort((a, b) => a.claim_order - b.claim_order);121 // Finally, we move the nodes122 for (let i = 0, j = 0; i < toMove.length; i++) {123 while (j < lis.length && toMove[i].claim_order >= lis[j].claim_order) {124 j++;125 }126 const anchor = j < lis.length ? lis[j] : null;127 target.insertBefore(toMove[i], anchor);128 }129}130function append(target, node) {131 target.appendChild(node);132}133function append_styles(target, style_sheet_id, styles) {134 const append_styles_to = get_root_for_style(target);135 if (!append_styles_to.getElementById(style_sheet_id)) {136 const style = element('style');137 style.id = style_sheet_id;138 style.textContent = styles;139 append_stylesheet(append_styles_to, style);140 }141}142function get_root_for_style(node) {143 if (!node)144 return document;145 const root = node.getRootNode ? node.getRootNode() : node.ownerDocument;146 if (root && root.host) {147 return root;148 }149 return node.ownerDocument;150}151function append_stylesheet(node, style) {152 append(node.head || node, style);153}154function append_hydration(target, node) {155 if (is_hydrating) {156 init_hydrate(target);157 if ((target.actual_end_child === undefined) || ((target.actual_end_child !== null) && (target.actual_end_child.parentElement !== target))) {158 target.actual_end_child = target.firstChild;159 }160 // Skip nodes of undefined ordering161 while ((target.actual_end_child !== null) && (target.actual_end_child.claim_order === undefined)) {162 target.actual_end_child = target.actual_end_child.nextSibling;163 }164 if (node !== target.actual_end_child) {165 // We only insert if the ordering of this node should be modified or the parent node is not target166 if (node.claim_order !== undefined || node.parentNode !== target) {167 target.insertBefore(node, target.actual_end_child);168 }169 }170 else {171 target.actual_end_child = node.nextSibling;172 }173 }174 else if (node.parentNode !== target || node.nextSibling !== null) {175 target.appendChild(node);176 }177}178function insert_hydration(target, node, anchor) {179 if (is_hydrating && !anchor) {180 append_hydration(target, node);181 }182 else if (node.parentNode !== target || node.nextSibling != anchor) {183 target.insertBefore(node, anchor || null);184 }185}186function detach(node) {187 node.parentNode.removeChild(node);188}189function element(name) {190 return document.createElement(name);191}192function text(data) {193 return document.createTextNode(data);194}195function space() {196 return text(' ');197}198function attr(node, attribute, value) {199 if (value == null)200 node.removeAttribute(attribute);201 else if (node.getAttribute(attribute) !== value)202 node.setAttribute(attribute, value);203}204function children(element) {205 return Array.from(element.childNodes);206}207function init_claim_info(nodes) {208 if (nodes.claim_info === undefined) {209 nodes.claim_info = { last_index: 0, total_claimed: 0 };210 }211}212function claim_node(nodes, predicate, processNode, createNode, dontUpdateLastIndex = false) {213 // Try to find nodes in an order such that we lengthen the longest increasing subsequence214 init_claim_info(nodes);215 const resultNode = (() => {216 // We first try to find an element after the previous one217 for (let i = nodes.claim_info.last_index; i < nodes.length; i++) {218 const node = nodes[i];219 if (predicate(node)) {220 const replacement = processNode(node);221 if (replacement === undefined) {222 nodes.splice(i, 1);223 }224 else {225 nodes[i] = replacement;226 }227 if (!dontUpdateLastIndex) {228 nodes.claim_info.last_index = i;229 }230 return node;231 }232 }233 // Otherwise, we try to find one before234 // We iterate in reverse so that we don't go too far back235 for (let i = nodes.claim_info.last_index - 1; i >= 0; i--) {236 const node = nodes[i];237 if (predicate(node)) {238 const replacement = processNode(node);239 if (replacement === undefined) {240 nodes.splice(i, 1);241 }242 else {243 nodes[i] = replacement;244 }245 if (!dontUpdateLastIndex) {246 nodes.claim_info.last_index = i;247 }248 else if (replacement === undefined) {249 // Since we spliced before the last_index, we decrease it250 nodes.claim_info.last_index--;251 }252 return node;253 }254 }255 // If we can't find any matching node, we create a new one256 return createNode();257 })();258 resultNode.claim_order = nodes.claim_info.total_claimed;259 nodes.claim_info.total_claimed += 1;260 return resultNode;261}262function claim_element_base(nodes, name, attributes, create_element) {263 return claim_node(nodes, (node) => node.nodeName === name, (node) => {264 const remove = [];265 for (let j = 0; j < node.attributes.length; j++) {266 const attribute = node.attributes[j];267 if (!attributes[attribute.name]) {268 remove.push(attribute.name);269 }270 }271 remove.forEach(v => node.removeAttribute(v));272 return undefined;273 }, () => create_element(name));274}275function claim_element(nodes, name, attributes) {276 return claim_element_base(nodes, name, attributes, element);277}278function claim_text(nodes, data) {279 return claim_node(nodes, (node) => node.nodeType === 3, (node) => {280 const dataStr = '' + data;281 if (node.data.startsWith(dataStr)) {282 if (node.data.length !== dataStr.length) {283 return node.splitText(dataStr.length);284 }285 }286 else {287 node.data = dataStr;288 }289 }, () => text(data), true // Text nodes should not update last index since it is likely not worth it to eliminate an increasing subsequence of actual elements290 );291}292function claim_space(nodes) {293 return claim_text(nodes, ' ');294}295function set_data(text, data) {296 data = '' + data;297 if (text.wholeText !== data)298 text.data = data;299}300function set_style(node, key, value, important) {301 if (value === null) {302 node.style.removeProperty(key);303 }304 else {305 node.style.setProperty(key, value, important ? 'important' : '');306 }307}308 309let current_component;310function set_current_component(component) {311 current_component = component;312}313 314const dirty_components = [];315const binding_callbacks = [];316const render_callbacks = [];317const flush_callbacks = [];318const resolved_promise = Promise.resolve();319let update_scheduled = false;320function schedule_update() {321 if (!update_scheduled) {322 update_scheduled = true;323 resolved_promise.then(flush);324 }325}326function add_render_callback(fn) {327 render_callbacks.push(fn);328}329// flush() calls callbacks in this order:330// 1. All beforeUpdate callbacks, in order: parents before children331// 2. All bind:this callbacks, in reverse order: children before parents.332// 3. All afterUpdate callbacks, in order: parents before children. EXCEPT333// for afterUpdates called during the initial onMount, which are called in334// reverse order: children before parents.335// Since callbacks might update component values, which could trigger another336// call to flush(), the following steps guard against this:337// 1. During beforeUpdate, any updated components will be added to the338// dirty_components array and will cause a reentrant call to flush(). Because339// the flush index is kept outside the function, the reentrant call will pick340// up where the earlier call left off and go through all dirty components. The341// current_component value is saved and restored so that the reentrant call will342// not interfere with the "parent" flush() call.343// 2. bind:this callbacks cannot trigger new flush() calls.344// 3. During afterUpdate, any updated components will NOT have their afterUpdate345// callback called a second time; the seen_callbacks set, outside the flush()346// function, guarantees this behavior.347const seen_callbacks = new Set();348let flushidx = 0; // Do *not* move this inside the flush() function349function flush() {350 const saved_component = current_component;351 do {352 // first, call beforeUpdate functions353 // and update components354 while (flushidx < dirty_components.length) {355 const component = dirty_components[flushidx];356 flushidx++;357 set_current_component(component);358 update(component.$$);359 }360 set_current_component(null);361 dirty_components.length = 0;362 flushidx = 0;363 while (binding_callbacks.length)364 binding_callbacks.pop()();365 // then, once components are updated, call366 // afterUpdate functions. This may cause367 // subsequent updates...368 for (let i = 0; i < render_callbacks.length; i += 1) {369 const callback = render_callbacks[i];370 if (!seen_callbacks.has(callback)) {371 // ...so guard against infinite loops372 seen_callbacks.add(callback);373 callback();374 }375 }376 render_callbacks.length = 0;377 } while (dirty_components.length);378 while (flush_callbacks.length) {379 flush_callbacks.pop()();380 }381 update_scheduled = false;382 seen_callbacks.clear();383 set_current_component(saved_component);384}385function update($$) {386 if ($$.fragment !== null) {387 $$.update();388 run_all($$.before_update);389 const dirty = $$.dirty;390 $$.dirty = [-1];391 $$.fragment && $$.fragment.p($$.ctx, dirty);392 $$.after_update.forEach(add_render_callback);393 }394}395const outroing = new Set();396function transition_in(block, local) {397 if (block && block.i) {398 outroing.delete(block);399 block.i(local);400 }401}402function mount_component(component, target, anchor, customElement) {403 const { fragment, on_mount, on_destroy, after_update } = component.$$;404 fragment && fragment.m(target, anchor);405 if (!customElement) {406 // onMount happens before the initial afterUpdate407 add_render_callback(() => {408 const new_on_destroy = on_mount.map(run).filter(is_function);409 if (on_destroy) {410 on_destroy.push(...new_on_destroy);411 }412 else {413 // Edge case - component was destroyed immediately,414 // most likely as a result of a binding initialising415 run_all(new_on_destroy);416 }417 component.$$.on_mount = [];418 });419 }420 after_update.forEach(add_render_callback);421}422function destroy_component(component, detaching) {423 const $$ = component.$$;424 if ($$.fragment !== null) {425 run_all($$.on_destroy);426 $$.fragment && $$.fragment.d(detaching);427 // TODO null out other refs, including component.$$ (but need to428 // preserve final state?)429 $$.on_destroy = $$.fragment = null;430 $$.ctx = [];431 }432}433function make_dirty(component, i) {434 if (component.$$.dirty[0] === -1) {435 dirty_components.push(component);436 schedule_update();437 component.$$.dirty.fill(0);438 }439 component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31));440}441function init(component, options, instance, create_fragment, not_equal, props, append_styles, dirty = [-1]) {442 const parent_component = current_component;443 set_current_component(component);444 const $$ = component.$$ = {445 fragment: null,446 ctx: null,447 // state448 props,449 update: noop,450 not_equal,451 bound: blank_object(),452 // lifecycle453 on_mount: [],454 on_destroy: [],455 on_disconnect: [],456 before_update: [],457 after_update: [],458 context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),459 // everything else460 callbacks: blank_object(),461 dirty,462 skip_bound: false,463 root: options.target || parent_component.$$.root464 };465 append_styles && append_styles($$.root);466 let ready = false;467 $$.ctx = instance468 ? instance(component, options.props || {}, (i, ret, ...rest) => {469 const value = rest.length ? rest[0] : ret;470 if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {471 if (!$$.skip_bound && $$.bound[i])472 $$.bound[i](value);473 if (ready)474 make_dirty(component, i);475 }476 return ret;477 })478 : [];479 $$.update();480 ready = true;481 run_all($$.before_update);482 // `false` as a special case of no DOM component483 $$.fragment = create_fragment ? create_fragment($$.ctx) : false;484 if (options.target) {485 if (options.hydrate) {486 start_hydrating();487 const nodes = children(options.target);488 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion489 $$.fragment && $$.fragment.l(nodes);490 nodes.forEach(detach);491 }492 else {493 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion494 $$.fragment && $$.fragment.c();495 }496 if (options.intro)497 transition_in(component.$$.fragment);498 mount_component(component, options.target, options.anchor, options.customElement);499 end_hydrating();500 flush();501 }502 set_current_component(parent_component);503}504/**505 * Base class for Svelte components. Used when dev=false.506 */507class SvelteComponent {508 $destroy() {509 destroy_component(this, 1);510 this.$destroy = noop;511 }512 $on(type, callback) {513 const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));514 callbacks.push(callback);515 return () => {516 const index = callbacks.indexOf(callback);517 if (index !== -1)518 callbacks.splice(index, 1);519 };520 }521 $set($$props) {522 if (this.$$set && !is_empty($$props)) {523 this.$$.skip_bound = true;524 this.$$set($$props);525 this.$$.skip_bound = false;526 }527 }528}529 530/* src/InstanceView.svelte generated by Svelte v3.49.0 */531 532function add_css(target) {533 append_styles(target, "svelte-8lajst", ".label.svelte-8lajst{margin-right:5px;font-size:10px;color:rgba(0, 0, 0, 0.5);font-variant:small-caps}.text.svelte-8lajst{display:flex;flex-direction:row}.value.svelte-8lajst{font-size:10px}.box.svelte-8lajst{width:min-content;padding:5px;border:0.5px solid rgb(224, 224, 224)}");534}535 536// (21:2) {#if modelColumn && entry[modelColumn]}537function create_if_block(ctx) {538 let div;539 let span0;540 let t0;541 let t1;542 let span1;543 let t2_value = /*entry*/ ctx[0][/*modelColumn*/ ctx[1]] + "";544 let t2;545 546 return {547 c() {548 div = element("div");549 span0 = element("span");550 t0 = text("output:");551 t1 = space();552 span1 = element("span");553 t2 = text(t2_value);554 this.h();555 },556 l(nodes) {557 div = claim_element(nodes, "DIV", { class: true });558 var div_nodes = children(div);559 span0 = claim_element(div_nodes, "SPAN", { class: true });560 var span0_nodes = children(span0);561 t0 = claim_text(span0_nodes, "output:");562 span0_nodes.forEach(detach);563 t1 = claim_space(div_nodes);564 span1 = claim_element(div_nodes, "SPAN", { class: true });565 var span1_nodes = children(span1);566 t2 = claim_text(span1_nodes, t2_value);567 span1_nodes.forEach(detach);568 div_nodes.forEach(detach);569 this.h();570 },571 h() {572 attr(span0, "class", "label svelte-8lajst");573 attr(span1, "class", "value svelte-8lajst");574 attr(div, "class", "text svelte-8lajst");575 },576 m(target, anchor) {577 insert_hydration(target, div, anchor);578 append_hydration(div, span0);579 append_hydration(span0, t0);580 append_hydration(div, t1);581 append_hydration(div, span1);582 append_hydration(span1, t2);583 },584 p(ctx, dirty) {585 if (dirty & /*entry, modelColumn*/ 3 && t2_value !== (t2_value = /*entry*/ ctx[0][/*modelColumn*/ ctx[1]] + "")) set_data(t2, t2_value);586 },587 d(detaching) {588 if (detaching) detach(div);589 }590 };591}592 593function create_fragment(ctx) {594 let div1;595 let img;596 let img_src_value;597 let img_alt_value;598 let t0;599 let br;600 let t1;601 let div0;602 let span0;603 let t2;604 let t3;605 let span1;606 let t4_value = /*entry*/ ctx[0][/*labelColumn*/ ctx[2]] + "";607 let t4;608 let t5;609 let if_block = /*modelColumn*/ ctx[1] && /*entry*/ ctx[0][/*modelColumn*/ ctx[1]] && create_if_block(ctx);610 611 return {612 c() {613 div1 = element("div");614 img = element("img");615 t0 = space();616 br = element("br");617 t1 = space();618 div0 = element("div");619 span0 = element("span");620 t2 = text("label:");621 t3 = space();622 span1 = element("span");623 t4 = text(t4_value);624 t5 = space();625 if (if_block) if_block.c();626 this.h();627 },628 l(nodes) {629 div1 = claim_element(nodes, "DIV", { class: true });630 var div1_nodes = children(div1);631 img = claim_element(div1_nodes, "IMG", { src: true, alt: true });632 t0 = claim_space(div1_nodes);633 br = claim_element(div1_nodes, "BR", {});634 t1 = claim_space(div1_nodes);635 div0 = claim_element(div1_nodes, "DIV", { class: true });636 var div0_nodes = children(div0);637 span0 = claim_element(div0_nodes, "SPAN", { class: true });638 var span0_nodes = children(span0);639 t2 = claim_text(span0_nodes, "label:");640 span0_nodes.forEach(detach);641 t3 = claim_space(div0_nodes);642 span1 = claim_element(div0_nodes, "SPAN", { class: true });643 var span1_nodes = children(span1);644 t4 = claim_text(span1_nodes, t4_value);645 span1_nodes.forEach(detach);646 div0_nodes.forEach(detach);647 t5 = claim_space(div1_nodes);648 if (if_block) if_block.l(div1_nodes);649 div1_nodes.forEach(detach);650 this.h();651 },652 h() {653 if (!src_url_equal(img.src, img_src_value = /*entry*/ ctx[0][/*dataColumn*/ ctx[3]])) attr(img, "src", img_src_value);654 attr(img, "alt", img_alt_value = "Image thumbnail for instance " + /*entry*/ ctx[0][/*idColumn*/ ctx[4]]);655 set_style(img, "max-width", `200px`, false);656 attr(span0, "class", "label svelte-8lajst");657 attr(span1, "class", "value svelte-8lajst");658 attr(div0, "class", "text svelte-8lajst");659 attr(div1, "class", "box svelte-8lajst");660 set_style(div1, "background-color", `white`, false);661 },662 m(target, anchor) {663 insert_hydration(target, div1, anchor);664 append_hydration(div1, img);665 append_hydration(div1, t0);666 append_hydration(div1, br);667 append_hydration(div1, t1);668 append_hydration(div1, div0);669 append_hydration(div0, span0);670 append_hydration(span0, t2);671 append_hydration(div0, t3);672 append_hydration(div0, span1);673 append_hydration(span1, t4);674 append_hydration(div1, t5);675 if (if_block) if_block.m(div1, null);676 },677 p(ctx, [dirty]) {678 if (dirty & /*entry, dataColumn*/ 9 && !src_url_equal(img.src, img_src_value = /*entry*/ ctx[0][/*dataColumn*/ ctx[3]])) {679 attr(img, "src", img_src_value);680 }681 682 if (dirty & /*entry, idColumn*/ 17 && img_alt_value !== (img_alt_value = "Image thumbnail for instance " + /*entry*/ ctx[0][/*idColumn*/ ctx[4]])) {683 attr(img, "alt", img_alt_value);684 }685 686 if (dirty & /*entry, labelColumn*/ 5 && t4_value !== (t4_value = /*entry*/ ctx[0][/*labelColumn*/ ctx[2]] + "")) set_data(t4, t4_value);687 688 if (/*modelColumn*/ ctx[1] && /*entry*/ ctx[0][/*modelColumn*/ ctx[1]]) {689 if (if_block) {690 if_block.p(ctx, dirty);691 } else {692 if_block = create_if_block(ctx);693 if_block.c();694 if_block.m(div1, null);695 }696 } else if (if_block) {697 if_block.d(1);698 if_block = null;699 }700 },701 i: noop,702 o: noop,703 d(detaching) {704 if (detaching) detach(div1);705 if (if_block) if_block.d();706 }707 };708}709 710function instance($$self, $$props, $$invalidate) {711 let { entry } = $$props;712 let { options } = $$props;713 let { modelColumn } = $$props;714 let { labelColumn } = $$props;715 let { dataColumn } = $$props;716 let { idColumn } = $$props;717 718 $$self.$$set = $$props => {719 if ('entry' in $$props) $$invalidate(0, entry = $$props.entry);720 if ('options' in $$props) $$invalidate(5, options = $$props.options);721 if ('modelColumn' in $$props) $$invalidate(1, modelColumn = $$props.modelColumn);722 if ('labelColumn' in $$props) $$invalidate(2, labelColumn = $$props.labelColumn);723 if ('dataColumn' in $$props) $$invalidate(3, dataColumn = $$props.dataColumn);724 if ('idColumn' in $$props) $$invalidate(4, idColumn = $$props.idColumn);725 };726 727 return [entry, modelColumn, labelColumn, dataColumn, idColumn, options];728}729 730class InstanceView extends SvelteComponent {731 constructor(options) {732 super();733 734 init(735 this,736 options,737 instance,738 create_fragment,739 safe_not_equal,740 {741 entry: 0,742 options: 5,743 modelColumn: 1,744 labelColumn: 2,745 dataColumn: 3,746 idColumn: 4747 },748 add_css749 );750 }751}752 753function getInstance(754 div,755 options,756 entry,757 modelColumn,758 labelColumn,759 dataColumn,760 idColumn761) {762 new InstanceView({763 target: div,764 props: {765 entry: entry,766 options: options,767 modelColumn: modelColumn,768 labelColumn: labelColumn,769 dataColumn: dataColumn,770 idColumn: idColumn,771 },772 hydrate: true,773 });774}775 776export { getInstance };777 