(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); var app = (function () { 'use strict'; 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'); } let src_url_equal_anchor; function src_url_equal(element_src, url) { if (!src_url_equal_anchor) { src_url_equal_anchor = document.createElement('a'); } src_url_equal_anchor.href = url; return element_src === src_url_equal_anchor.href; } function is_empty(obj) { return Object.keys(obj).length === 0; } const globals = (typeof window !== 'undefined' ? window : typeof globalThis !== 'undefined' ? globalThis : global); function append(target, node) { target.appendChild(node); } function insert(target, node, anchor) { target.insertBefore(node, anchor || null); } function detach(node) { if (node.parentNode) { 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 text(data) { return document.createTextNode(data); } function space() { return text(' '); } function empty() { return text(''); } function comment(content) { return document.createComment(content); } 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) { if (value == null) { node.style.removeProperty(key); } else { node.style.setProperty(key, value, important ? 'important' : ''); } } function select_option(select, value, mounting) { for (let i = 0; i < select.options.length; i += 1) { const option = select.options[i]; if (option.__value === value) { option.selected = true; return; } } if (!mounting || value !== undefined) { select.selectedIndex = -1; // no option should be selected } } function select_value(select) { const selected_option = select.querySelector(':checked'); return selected_option && selected_option.__value; } function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) { const e = document.createEvent('CustomEvent'); e.initCustomEvent(type, bubbles, cancelable, detail); return e; } 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; } /** * The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM. * It must be called during the component's initialisation (but doesn't need to live *inside* the component; * it can be called from an external module). * * `onMount` does not run inside a [server-side component](/docs#run-time-server-side-component-api). * * https://svelte.dev/docs#run-time-svelte-onmount */ function onMount(fn) { get_current_component().$$.on_mount.push(fn); } const dirty_components = []; const binding_callbacks = []; let render_callbacks = []; const flush_callbacks = []; const resolved_promise = /* @__PURE__ */ 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); } // flush() calls callbacks in this order: // 1. All beforeUpdate callbacks, in order: parents before children // 2. All bind:this callbacks, in reverse order: children before parents. // 3. All afterUpdate callbacks, in order: parents before children. EXCEPT // for afterUpdates called during the initial onMount, which are called in // reverse order: children before parents. // Since callbacks might update component values, which could trigger another // call to flush(), the following steps guard against this: // 1. During beforeUpdate, any updated components will be added to the // dirty_components array and will cause a reentrant call to flush(). Because // the flush index is kept outside the function, the reentrant call will pick // up where the earlier call left off and go through all dirty components. The // current_component value is saved and restored so that the reentrant call will // not interfere with the "parent" flush() call. // 2. bind:this callbacks cannot trigger new flush() calls. // 3. During afterUpdate, any updated components will NOT have their afterUpdate // callback called a second time; the seen_callbacks set, outside the flush() // function, guarantees this behavior. const seen_callbacks = new Set(); let flushidx = 0; // Do *not* move this inside the flush() function function flush() { // Do not reenter flush while dirty components are updated, as this can // result in an infinite loop. Instead, let the inner flush handle it. // Reentrancy is ok afterwards for bindings etc. if (flushidx !== 0) { return; } const saved_component = current_component; do { // first, call beforeUpdate functions // and update components try { while (flushidx < dirty_components.length) { const component = dirty_components[flushidx]; flushidx++; set_current_component(component); update(component.$$); } } catch (e) { // reset dirty state to not end up in a deadlocked state and then rethrow dirty_components.length = 0; flushidx = 0; throw e; } set_current_component(null); dirty_components.length = 0; flushidx = 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; seen_callbacks.clear(); set_current_component(saved_component); } 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); } } /** * Useful for example to execute remaining `afterUpdate` callbacks before executing `destroy`. */ function flush_render_callbacks(fns) { const filtered = []; const targets = []; render_callbacks.forEach((c) => fns.indexOf(c) === -1 ? filtered.push(c) : targets.push(c)); targets.forEach((c) => c()); render_callbacks = filtered; } const outroing = new Set(); let outros; 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); } else if (callback) { callback(); } } function create_component(block) { block && block.c(); } function mount_component(component, target, anchor, customElement) { const { fragment, after_update } = component.$$; fragment && fragment.m(target, anchor); if (!customElement) { // onMount happens before the initial afterUpdate add_render_callback(() => { const new_on_destroy = component.$$.on_mount.map(run).filter(is_function); // if the component was destroyed immediately // it will update the `$$.on_destroy` reference to `null`. // the destructured on_destroy may still reference to the old array if (component.$$.on_destroy) { component.$$.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) { flush_render_callbacks($$.after_update); 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: [], // state props, update: noop, not_equal, bound: blank_object(), // lifecycle on_mount: [], on_destroy: [], on_disconnect: [], before_update: [], after_update: [], context: new Map(options.context || (parent_component ? parent_component.$$.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) { if (!is_function(callback)) { return noop; } 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.59.2' }, detail), { bubbles: true })); } 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 listen_dev(node, event, handler, options, has_prevent_default, has_stop_propagation, has_stop_immediate_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'); if (has_stop_immediate_propagation) modifiers.push('stopImmediatePropagation'); 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 set_data_dev(text, data) { data = '' + data; if (text.data === data) return; dispatch_dev('SvelteDOMSetData', { node: text, data }); text.data = data; } 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}".`); } } } /** * 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\VideoGradioComponentBrainstorming.svelte generated by Svelte v3.59.2 */ const { console: console_1 } = globals; const file$2 = "src\\VideoGradioComponentBrainstorming.svelte"; function get_each_context$1(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[15] = list[i]; return child_ctx; } // (85:4) {#each kitchenOptions as option} function create_each_block$1(ctx) { let option; let t_value = /*option*/ ctx[15] + ""; let t; const block = { c: function create() { option = element("option"); t = text(t_value); option.__value = /*option*/ ctx[15]; option.value = option.__value; add_location(option, file$2, 85, 6, 2561); }, m: function mount(target, anchor) { insert_dev(target, option, anchor); append_dev(option, t); }, p: noop, d: function destroy(detaching) { if (detaching) detach_dev(option); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_each_block$1.name, type: "each", source: "(85:4) {#each kitchenOptions as option}", ctx }); return block; } function create_fragment$2(ctx) { let h1; let t1; let div1; let video; let track; let track_src_value; let t2; let div0; let t3; let t4; let t5; let canvas_1; let t6; let input; let t7; let div2; let button; let t9; let select; let mounted; let dispose; let each_value = /*kitchenOptions*/ ctx[4]; validate_each_argument(each_value); let each_blocks = []; 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)); } const block = { c: function create() { h1 = element("h1"); h1.textContent = "AI Vision Assistant - Auto prompt HF agent + Cohere + Object detection - Text write on screen test"; t1 = space(); div1 = element("div"); video = element("video"); track = element("track"); t2 = space(); div0 = element("div"); t3 = text("Text Overlay Test and "); t4 = text(/*TestVerb*/ ctx[3]); t5 = space(); canvas_1 = element("canvas"); t6 = space(); input = element("input"); t7 = space(); div2 = element("div"); button = element("button"); button.textContent = "Verb Test"; t9 = space(); select = element("select"); for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].c(); } add_location(h1, file$2, 66, 0, 1800); attr_dev(track, "kind", "captions"); if (!src_url_equal(track.src, track_src_value = "path/to/your/captions/file.vtt")) attr_dev(track, "src", track_src_value); attr_dev(track, "srclang", "en"); attr_dev(track, "label", "English"); add_location(track, file$2, 72, 4, 2006); attr_dev(video, "id", "videoCanvas"); video.autoplay = true; attr_dev(video, "class", "svelte-ufd3fo"); add_location(video, file$2, 70, 2, 1965); attr_dev(div0, "id", "overlayText"); attr_dev(div0, "class", "svelte-ufd3fo"); add_location(div0, file$2, 74, 2, 2111); attr_dev(div1, "id", "videoContainer"); attr_dev(div1, "class", "svelte-ufd3fo"); add_location(div1, file$2, 68, 0, 1911); attr_dev(canvas_1, "id", "myCanvas"); set_style(canvas_1, "border", "2px solid black"); attr_dev(canvas_1, "width", "500"); attr_dev(canvas_1, "height", "500"); add_location(canvas_1, file$2, 77, 0, 2186); attr_dev(input, "type", "text"); add_location(input, file$2, 78, 0, 2294); add_location(button, file$2, 82, 2, 2429); if (/*selectedOption*/ ctx[0] === void 0) add_render_callback(() => /*select_change_handler*/ ctx[9].call(select)); add_location(select, file$2, 83, 2, 2479); attr_dev(div2, "id", "frameForButtons"); add_location(div2, file$2, 81, 0, 2399); }, 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, h1, anchor); insert_dev(target, t1, anchor); insert_dev(target, div1, anchor); append_dev(div1, video); append_dev(video, track); append_dev(div1, t2); append_dev(div1, div0); append_dev(div0, t3); append_dev(div0, t4); insert_dev(target, t5, anchor); insert_dev(target, canvas_1, anchor); /*canvas_1_binding*/ ctx[7](canvas_1); insert_dev(target, t6, anchor); insert_dev(target, input, anchor); set_input_value(input, /*textToDisplay*/ ctx[2]); insert_dev(target, t7, anchor); insert_dev(target, div2, anchor); append_dev(div2, button); append_dev(div2, t9); append_dev(div2, select); for (let i = 0; i < each_blocks.length; i += 1) { if (each_blocks[i]) { each_blocks[i].m(select, null); } } select_option(select, /*selectedOption*/ ctx[0], true); if (!mounted) { dispose = [ listen_dev(input, "input", /*input_input_handler*/ ctx[8]), listen_dev(input, "input", /*updateText*/ ctx[6], false, false, false, false), listen_dev(button, "click", /*testText*/ ctx[5], false, false, false, false), listen_dev(select, "change", /*select_change_handler*/ ctx[9]) ]; mounted = true; } }, p: function update(ctx, [dirty]) { if (dirty & /*TestVerb*/ 8) set_data_dev(t4, /*TestVerb*/ ctx[3]); if (dirty & /*textToDisplay*/ 4 && input.value !== /*textToDisplay*/ ctx[2]) { set_input_value(input, /*textToDisplay*/ ctx[2]); } if (dirty & /*kitchenOptions*/ 16) { each_value = /*kitchenOptions*/ ctx[4]; validate_each_argument(each_value); let i; for (i = 0; i < each_value.length; i += 1) { const child_ctx = get_each_context$1(ctx, each_value, i); 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(select, null); } } for (; i < each_blocks.length; i += 1) { each_blocks[i].d(1); } each_blocks.length = each_value.length; } if (dirty & /*selectedOption, kitchenOptions*/ 17) { select_option(select, /*selectedOption*/ ctx[0]); } }, i: noop, o: noop, d: function destroy(detaching) { if (detaching) detach_dev(h1); if (detaching) detach_dev(t1); if (detaching) detach_dev(div1); if (detaching) detach_dev(t5); if (detaching) detach_dev(canvas_1); /*canvas_1_binding*/ ctx[7](null); if (detaching) detach_dev(t6); if (detaching) detach_dev(input); if (detaching) detach_dev(t7); if (detaching) detach_dev(div2); destroy_each(each_blocks, detaching); mounted = false; run_all(dispose); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment$2.name, type: "component", source: "", ctx }); return block; } function ocrTest() { } // Logic for 'Test OCR' button function instance$2($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; validate_slots('VideoGradioComponentBrainstorming', slots, []); let selectedOption = 'Stove - lu'; // default value let kitchenOptions = ['Stove - lu', 'Refrigerator - bingxiang', 'Spoon - shao']; /* ... other options ... */ let canvas; let ctx; let textToDisplay = 'Initial Text'; let counter = 0; let hud_text; let TestVerb = "|Test verb|"; // Functions for button commands function testText() { // Logic for 'verb test' button const randomIndex = Math.floor(Math.random() * kitchenOptions.length); $$invalidate(3, TestVerb = kitchenOptions[randomIndex]); } // Image source let imageSrc = 'path_to_your_image/Blooms-Taxonomy-650x366.jpg'; // Video stream setup onMount(() => { // Initialize video stream here ctx = canvas.getContext('2d'); setInterval( () => { drawText(textToDisplay); }, 1000 ); // Update every second }); function drawText(hud_info) { if (ctx) { hud_text = "HUD Info Update: " + counter++ + " " + hud_info; ctx.clearRect(0, 0, canvas.width, canvas.height); // Clear the canvas ctx.font = '30px Arial'; ctx.fillStyle = 'black'; ctx.fillText(hud_text, 50, 50); } } function updateText(event) { $$invalidate(2, textToDisplay = event.target.value); drawText(); } // Camera as Video Stream navigator.mediaDevices.getUserMedia({ video: true }).then(stream => { const video = document.getElementById('videoCanvas'); video.srcObject = stream; }).catch(err => { console.error("Error accessing the camera: ", err); }); const writable_props = []; Object.keys($$props).forEach(key => { if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console_1.warn(` was created with unknown prop '${key}'`); }); function canvas_1_binding($$value) { binding_callbacks[$$value ? 'unshift' : 'push'](() => { canvas = $$value; $$invalidate(1, canvas); }); } function input_input_handler() { textToDisplay = this.value; $$invalidate(2, textToDisplay); } function select_change_handler() { selectedOption = select_value(this); $$invalidate(0, selectedOption); $$invalidate(4, kitchenOptions); } $$self.$capture_state = () => ({ onMount, selectedOption, kitchenOptions, canvas, ctx, textToDisplay, counter, hud_text, TestVerb, testText, ocrTest, imageSrc, drawText, updateText }); $$self.$inject_state = $$props => { if ('selectedOption' in $$props) $$invalidate(0, selectedOption = $$props.selectedOption); if ('kitchenOptions' in $$props) $$invalidate(4, kitchenOptions = $$props.kitchenOptions); if ('canvas' in $$props) $$invalidate(1, canvas = $$props.canvas); if ('ctx' in $$props) ctx = $$props.ctx; if ('textToDisplay' in $$props) $$invalidate(2, textToDisplay = $$props.textToDisplay); if ('counter' in $$props) counter = $$props.counter; if ('hud_text' in $$props) hud_text = $$props.hud_text; if ('TestVerb' in $$props) $$invalidate(3, TestVerb = $$props.TestVerb); if ('imageSrc' in $$props) imageSrc = $$props.imageSrc; }; if ($$props && "$$inject" in $$props) { $$self.$inject_state($$props.$$inject); } return [ selectedOption, canvas, textToDisplay, TestVerb, kitchenOptions, testText, updateText, canvas_1_binding, input_input_handler, select_change_handler ]; } class VideoGradioComponentBrainstorming extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance$2, create_fragment$2, safe_not_equal, {}); dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "VideoGradioComponentBrainstorming", options, id: create_fragment$2.name }); } } // Unique ID creation requires a high quality random # generator. In the browser we therefore // require the crypto API and do not support built-in fallback to lower quality random number // generators (like Math.random()). let getRandomValues; const rnds8 = new Uint8Array(16); function rng() { // lazy load so that environments that need to polyfill have a chance to do so if (!getRandomValues) { // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto); if (!getRandomValues) { throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); } } return getRandomValues(rnds8); } /** * Convert array of 16 byte values to UUID string format of the form: * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */ const byteToHex = []; for (let i = 0; i < 256; ++i) { byteToHex.push((i + 0x100).toString(16).slice(1)); } function unsafeStringify(arr, offset = 0) { // Note: Be careful editing this code! It's been tuned for performance // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]; } const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto); var native = { randomUUID }; function v4(options, buf, offset) { if (native.randomUUID && !buf && !options) { return native.randomUUID(); } options = options || {}; const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` rnds[6] = rnds[6] & 0x0f | 0x40; rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided if (buf) { offset = offset || 0; for (let i = 0; i < 16; ++i) { buf[offset + i] = rnds[i]; } return buf; } return unsafeStringify(rnds); } /* src\NestedCommentsTestfromReact.svelte generated by Svelte v3.59.2 */ const file$1 = "src\\NestedCommentsTestfromReact.svelte"; function get_each_context(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[6] = list[i]; return child_ctx; } function get_each_context_1(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[9] = list[i]; return child_ctx; } // (29:12) {#if comment.items} function create_if_block(ctx) { let each_1_anchor; let each_value_1 = /*comment*/ ctx[6].items; validate_each_argument(each_value_1); 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 block = { c: function create() { for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].c(); } each_1_anchor = empty(); }, m: function mount(target, anchor) { for (let i = 0; i < each_blocks.length; i += 1) { if (each_blocks[i]) { each_blocks[i].m(target, anchor); } } insert_dev(target, each_1_anchor, anchor); }, p: function update(ctx, dirty) { if (dirty & /*comments*/ 1) { each_value_1 = /*comment*/ ctx[6].items; validate_each_argument(each_value_1); 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); } else { each_blocks[i] = create_each_block_1(child_ctx); each_blocks[i].c(); each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor); } } for (; i < each_blocks.length; i += 1) { each_blocks[i].d(1); } each_blocks.length = each_value_1.length; } }, d: function destroy(detaching) { destroy_each(each_blocks, detaching); if (detaching) detach_dev(each_1_anchor); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_if_block.name, type: "if", source: "(29:12) {#if comment.items}", ctx }); return block; } // (30:16) {#each comment.items as item} function create_each_block_1(ctx) { let t0_value = /*item*/ ctx[9].title + ""; let t0; let t1; const block = { c: function create() { t0 = text(t0_value); t1 = text(" | \r\n "); }, m: function mount(target, anchor) { insert_dev(target, t0, anchor); insert_dev(target, t1, anchor); }, p: function update(ctx, dirty) { if (dirty & /*comments*/ 1 && t0_value !== (t0_value = /*item*/ ctx[9].title + "")) set_data_dev(t0, t0_value); }, d: function destroy(detaching) { if (detaching) detach_dev(t0); if (detaching) detach_dev(t1); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_each_block_1.name, type: "each", source: "(30:16) {#each comment.items as item}", ctx }); return block; } // (23:4) {#each comments as comment} function create_each_block(ctx) { let div1; let div0; let span; let t0_value = /*comment*/ ctx[6].title + ""; let t0; let t1; let button; let t3; let t4; let div1_key_value; let mounted; let dispose; function click_handler() { return /*click_handler*/ ctx[5](/*comment*/ ctx[6]); } let if_block = /*comment*/ ctx[6].items && create_if_block(ctx); const block = { c: function create() { div1 = element("div"); div0 = element("div"); span = element("span"); t0 = text(t0_value); t1 = space(); button = element("button"); button.textContent = "Add Reply"; t3 = space(); if (if_block) if_block.c(); t4 = space(); attr_dev(span, "class", "text"); add_location(span, file$1, 25, 16, 818); add_location(button, file$1, 26, 16, 877); attr_dev(div0, "class", "card"); add_location(div0, file$1, 24, 12, 782); attr_dev(div1, "key", div1_key_value = /*comment*/ ctx[6].id); set_style(div1, "margin-left", "20px"); add_location(div1, file$1, 23, 8, 719); }, m: function mount(target, anchor) { insert_dev(target, div1, anchor); append_dev(div1, div0); append_dev(div0, span); append_dev(span, t0); append_dev(div0, t1); append_dev(div0, button); append_dev(div1, t3); if (if_block) if_block.m(div1, null); append_dev(div1, t4); if (!mounted) { dispose = listen_dev(button, "click", click_handler, false, false, false, false); mounted = true; } }, p: function update(new_ctx, dirty) { ctx = new_ctx; if (dirty & /*comments*/ 1 && t0_value !== (t0_value = /*comment*/ ctx[6].title + "")) set_data_dev(t0, t0_value); if (/*comment*/ ctx[6].items) { if (if_block) { if_block.p(ctx, dirty); } else { if_block = create_if_block(ctx); if_block.c(); if_block.m(div1, t4); } } else if (if_block) { if_block.d(1); if_block = null; } if (dirty & /*comments*/ 1 && div1_key_value !== (div1_key_value = /*comment*/ ctx[6].id)) { attr_dev(div1, "key", div1_key_value); } }, d: function destroy(detaching) { if (detaching) detach_dev(div1); if (if_block) if_block.d(); mounted = false; dispose(); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_each_block.name, type: "each", source: "(23:4) {#each comments as comment}", ctx }); return block; } function create_fragment$1(ctx) { let div1; let div0; let input; let t0; let button; let t2; let mounted; let dispose; let each_value = /*comments*/ ctx[0]; validate_each_argument(each_value); let each_blocks = []; for (let i = 0; i < each_value.length; i += 1) { each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); } const block = { c: function create() { div1 = element("div"); div0 = element("div"); input = element("input"); t0 = space(); button = element("button"); button.textContent = "Post Comment"; t2 = space(); for (let i = 0; i < each_blocks.length; i += 1) { each_blocks[i].c(); } attr_dev(input, "type", "text"); attr_dev(input, "placeholder", "Add a comment"); add_location(input, file$1, 19, 8, 530); add_location(button, file$1, 20, 8, 613); add_location(div0, file$1, 18, 4, 515); attr_dev(div1, "id", "comment-container"); add_location(div1, file$1, 17, 0, 481); }, 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, div1, anchor); append_dev(div1, div0); append_dev(div0, input); set_input_value(input, /*newComment*/ ctx[1]); append_dev(div0, t0); append_dev(div0, button); append_dev(div1, t2); for (let i = 0; i < each_blocks.length; i += 1) { if (each_blocks[i]) { each_blocks[i].m(div1, null); } } if (!mounted) { dispose = [ listen_dev(input, "input", /*input_input_handler*/ ctx[4]), listen_dev(button, "click", /*addComment*/ ctx[2], false, false, false, false) ]; mounted = true; } }, p: function update(ctx, [dirty]) { if (dirty & /*newComment*/ 2 && input.value !== /*newComment*/ ctx[1]) { set_input_value(input, /*newComment*/ ctx[1]); } if (dirty & /*comments, addReply, prompt*/ 9) { each_value = /*comments*/ ctx[0]; validate_each_argument(each_value); let i; for (i = 0; i < each_value.length; i += 1) { const child_ctx = get_each_context(ctx, each_value, i); 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(div1, null); } } for (; i < each_blocks.length; i += 1) { each_blocks[i].d(1); } each_blocks.length = each_value.length; } }, i: noop, o: noop, d: function destroy(detaching) { if (detaching) detach_dev(div1); destroy_each(each_blocks, detaching); mounted = false; run_all(dispose); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment$1.name, type: "component", source: "", ctx }); return block; } function instance$1($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; validate_slots('NestedCommentsTestfromReact', slots, []); let comments = []; let newComment = ''; const addComment = () => { $$invalidate(0, comments = [ ...comments, { id: v4(), title: newComment, items: [] } ]); $$invalidate(1, newComment = ''); }; const addReply = (comment, replyText) => { comment.items.push({ id: v4(), title: replyText, items: [] }); $$invalidate(0, comments = [...comments]); }; 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 input_input_handler() { newComment = this.value; $$invalidate(1, newComment); } const click_handler = comment => addReply(comment, prompt('Enter your reply')); $$self.$capture_state = () => ({ comment, uuidv4: v4, comments, newComment, addComment, addReply }); $$self.$inject_state = $$props => { if ('comments' in $$props) $$invalidate(0, comments = $$props.comments); if ('newComment' in $$props) $$invalidate(1, newComment = $$props.newComment); }; if ($$props && "$$inject" in $$props) { $$self.$inject_state($$props.$$inject); } return [comments, newComment, addComment, addReply, input_input_handler, click_handler]; } class NestedCommentsTestfromReact extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance$1, create_fragment$1, safe_not_equal, {}); dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "NestedCommentsTestfromReact", options, id: create_fragment$1.name }); } } /* src\App.svelte generated by Svelte v3.59.2 */ const file = "src\\App.svelte"; function create_fragment(ctx) { let main; let h10; let t0; let t1; let t2; let t3; let p; let t4; let a; let t6; let t7; let h11; let t9; let nestedcommentstestfromreact; let t10; let videogradiocomponentbrainstorming; let current; nestedcommentstestfromreact = new NestedCommentsTestfromReact({ $$inline: true }); videogradiocomponentbrainstorming = new VideoGradioComponentBrainstorming({ $$inline: true }); const block = { c: function create() { main = element("main"); h10 = element("h1"); t0 = text("Hello "); t1 = text(/*name*/ ctx[0]); t2 = text("!"); t3 = space(); p = element("p"); t4 = text("Visit the "); a = element("a"); a.textContent = "Svelte tutorial"; t6 = text(" to learn how to build Svelte apps."); t7 = space(); h11 = element("h1"); h11.textContent = "My new component test"; t9 = space(); create_component(nestedcommentstestfromreact.$$.fragment); t10 = space(); create_component(videogradiocomponentbrainstorming.$$.fragment); attr_dev(h10, "class", "svelte-1tky8bj"); add_location(h10, file, 8, 1, 221); attr_dev(a, "href", "https://svelte.dev/tutorial"); add_location(a, file, 9, 14, 258); add_location(p, file, 9, 1, 245); attr_dev(h11, "class", "svelte-1tky8bj"); add_location(h11, file, 11, 1, 357); attr_dev(main, "class", "svelte-1tky8bj"); add_location(main, file, 7, 0, 213); }, 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, main, anchor); append_dev(main, h10); append_dev(h10, t0); append_dev(h10, t1); append_dev(h10, t2); append_dev(main, t3); append_dev(main, p); append_dev(p, t4); append_dev(p, a); append_dev(p, t6); append_dev(main, t7); append_dev(main, h11); append_dev(main, t9); mount_component(nestedcommentstestfromreact, main, null); append_dev(main, t10); mount_component(videogradiocomponentbrainstorming, main, null); current = true; }, p: function update(ctx, [dirty]) { if (!current || dirty & /*name*/ 1) set_data_dev(t1, /*name*/ ctx[0]); }, i: function intro(local) { if (current) return; transition_in(nestedcommentstestfromreact.$$.fragment, local); transition_in(videogradiocomponentbrainstorming.$$.fragment, local); current = true; }, o: function outro(local) { transition_out(nestedcommentstestfromreact.$$.fragment, local); transition_out(videogradiocomponentbrainstorming.$$.fragment, local); current = false; }, d: function destroy(detaching) { if (detaching) detach_dev(main); destroy_component(nestedcommentstestfromreact); destroy_component(videogradiocomponentbrainstorming); } }; dispatch_dev("SvelteRegisterBlock", { block, id: create_fragment.name, type: "component", source: "", ctx }); return block; } function instance($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; validate_slots('App', slots, []); let { name } = $$props; $$self.$$.on_mount.push(function () { if (name === undefined && !('name' in $$props || $$self.$$.bound[$$self.$$.props['name']])) { console.warn(" was created without expected prop 'name'"); } }); const writable_props = ['name']; Object.keys($$props).forEach(key => { if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console.warn(` was created with unknown prop '${key}'`); }); $$self.$$set = $$props => { if ('name' in $$props) $$invalidate(0, name = $$props.name); }; $$self.$capture_state = () => ({ name, VideoGradioComponentBrainstorming, NestedCommentsTestfromReact }); $$self.$inject_state = $$props => { if ('name' in $$props) $$invalidate(0, name = $$props.name); }; if ($$props && "$$inject" in $$props) { $$self.$inject_state($$props.$$inject); } return [name]; } class App extends SvelteComponentDev { constructor(options) { super(options); init(this, options, instance, create_fragment, safe_not_equal, { name: 0 }); dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "App", options, id: create_fragment.name }); } get name() { throw new Error(": Props cannot be read directly from the component instance unless compiling with 'accessors: true' or ''"); } set name(value) { throw new Error(": Props cannot be set directly on the component instance unless compiling with 'accessors: true' or ''"); } } const app = new App({ target: document.body, props: { name: 'world' } }); return app; })(); //# sourceMappingURL=bundle.js.map