import{S as be,i as Ee,s as ke,C as tr,D as nr,E as rr,F as ir,f as X,t as W,I as di,J as pi,K as Bt,L as Q,M as ee,m as I,h as v,n as f,b as ne,G as m,B as ue,k as D,w as pe,l as U,x as me,y as _e,z as ge,a as ie,q,c as se,r as G,g as Le,d as Te,u as rt,N as Me,H as we,O as sr,o as Kt,P as or,Q as mt,R as Ae,T as Ls,U as ar,V as lr,W as Bn,e as Ye,X as Ts,Y as $s}from"../../chunks/index-4781a106.js";import{w as Ve}from"../../chunks/singletons-0553b75f.js";import{p as Ns}from"../../chunks/stores-61c8a5a1.js";var Rs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ms(e){var t=e.default;if(typeof t=="function"){var n=function(){return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}),n}var Be={},F={};Object.defineProperty(F,"__esModule",{value:!0});var Ds=Object.defineProperty,Us=Object.defineProperties,Hs=Object.getOwnPropertyDescriptors,cn=Object.getOwnPropertySymbols,mi=Object.prototype.hasOwnProperty,_i=Object.prototype.propertyIsEnumerable,Ar=(e,t,n)=>t in e?Ds(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,it=(e,t)=>{for(var n in t||(t={}))mi.call(t,n)&&Ar(e,n,t[n]);if(cn)for(var n of cn(t))_i.call(t,n)&&Ar(e,n,t[n]);return e},Ot=(e,t)=>Us(e,Hs(t)),zs=(e,t)=>{var n={};for(var r in e)mi.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&cn)for(var r of cn(e))t.indexOf(r)<0&&_i.call(e,r)&&(n[r]=e[r]);return n},cr=(e,t,n)=>new Promise((r,i)=>{var s=l=>{try{a(n.next(l))}catch(c){i(c)}},o=l=>{try{a(n.throw(l))}catch(c){i(c)}},a=l=>l.done?r(l.value):Promise.resolve(l.value).then(s,o);a((n=n.apply(e,t)).next())});function tt(e,t){throw new Error(t)}function re(e,t="Expected value to be non-nullable"){return e}var gi=(e=>(e[e.UPDATE_PRESENCE=100]="UPDATE_PRESENCE",e[e.BROADCAST_EVENT=103]="BROADCAST_EVENT",e[e.FETCH_STORAGE=200]="FETCH_STORAGE",e[e.UPDATE_STORAGE=201]="UPDATE_STORAGE",e))(gi||{}),vi=(e=>(e[e.INIT=0]="INIT",e[e.SET_PARENT_KEY=1]="SET_PARENT_KEY",e[e.CREATE_LIST=2]="CREATE_LIST",e[e.UPDATE_OBJECT=3]="UPDATE_OBJECT",e[e.CREATE_OBJECT=4]="CREATE_OBJECT",e[e.DELETE_CRDT=5]="DELETE_CRDT",e[e.DELETE_OBJECT_KEY=6]="DELETE_OBJECT_KEY",e[e.CREATE_MAP=7]="CREATE_MAP",e[e.CREATE_REGISTER=8]="CREATE_REGISTER",e))(vi||{}),yi=(e=>(e[e.OBJECT=0]="OBJECT",e[e.LIST=1]="LIST",e[e.MAP=2]="MAP",e[e.REGISTER=3]="REGISTER",e))(yi||{});function wi(e){return e.type===0&&!bi(e)}function bi(e){return e.parentId!==void 0&&e.parentKey!==void 0}var Ei=(e=>(e[e.UPDATE_PRESENCE=100]="UPDATE_PRESENCE",e[e.USER_JOINED=101]="USER_JOINED",e[e.USER_LEFT=102]="USER_LEFT",e[e.BROADCASTED_EVENT=103]="BROADCASTED_EVENT",e[e.ROOM_STATE=104]="ROOM_STATE",e[e.INITIAL_STORAGE_STATE=200]="INITIAL_STORAGE_STATE",e[e.UPDATE_STORAGE=201]="UPDATE_STORAGE",e))(Ei||{});function Vs(e){return e==="my-presence"||e==="others"||e==="event"||e==="error"||e==="connection"||e==="history"}var ki=(e=>(e[e.CLOSE_ABNORMAL=1006]="CLOSE_ABNORMAL",e[e.INVALID_MESSAGE_FORMAT=4e3]="INVALID_MESSAGE_FORMAT",e[e.NOT_ALLOWED=4001]="NOT_ALLOWED",e[e.MAX_NUMBER_OF_MESSAGES_PER_SECONDS=4002]="MAX_NUMBER_OF_MESSAGES_PER_SECONDS",e[e.MAX_NUMBER_OF_CONCURRENT_CONNECTIONS=4003]="MAX_NUMBER_OF_CONCURRENT_CONNECTIONS",e[e.MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP=4004]="MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP",e[e.MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM=4005]="MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM",e[e.CLOSE_WITHOUT_RETRY=4999]="CLOSE_WITHOUT_RETRY",e))(ki||{});function Cr(e,t){return Object.freeze({type:"HasParent",node:e,key:t})}var Sr=Object.freeze({type:"NoParent"});function Pr(e){return Object.freeze({type:"Orphaned",oldKey:e})}var yn=class{constructor(){this._parent=Sr}_getParentKeyOrThrow(){switch(this.parent.type){case"HasParent":return this.parent.key;case"NoParent":throw new Error("Parent key is missing");case"Orphaned":return this.parent.oldKey;default:return tt(this.parent,"Unknown state")}}get _pool(){return this.__pool}get roomId(){return this.__pool?this.__pool.roomId:null}get _id(){return this.__id}get parent(){return this._parent}get _parentNode(){switch(this.parent.type){case"HasParent":return this.parent.node;case"NoParent":return null;case"Orphaned":return null;default:return tt(this.parent,"Unknown state")}}get _parentKey(){switch(this.parent.type){case"HasParent":return this.parent.key;case"NoParent":return null;case"Orphaned":return this.parent.oldKey;default:return tt(this.parent,"Unknown state")}}_apply(e,t){switch(e.type){case 5:return this.parent.type==="HasParent"?this.parent.node._detachChild(this):{modified:!1}}return{modified:!1}}_setParentLink(e,t){switch(this.parent.type){case"HasParent":if(this.parent.node!==e)throw new Error("Cannot set parent: node already has a parent");this._parent=Cr(e,t);return;case"Orphaned":case"NoParent":{this._parent=Cr(e,t);return}default:return tt(this.parent,"Unknown state")}}_attach(e,t){if(this.__id||this.__pool)throw new Error("Cannot attach node: already attached");t.addNode(e,this),this.__id=e,this.__pool=t}_detach(){switch(this.__pool&&this.__id&&this.__pool.deleteNode(this.__id),this.parent.type){case"HasParent":{this._parent=Pr(this.parent.key);break}case"NoParent":{this._parent=Sr;break}case"Orphaned":{this._parent=Pr(this.parent.oldKey);break}default:tt(this.parent,"Unknown state")}this.__pool=void 0}invalidate(){this._cachedImmutable!==void 0&&(this._cachedImmutable=void 0,this.parent.type==="HasParent"&&this.parent.node.invalidate())}toImmutable(){return this._cachedImmutable===void 0&&(this._cachedImmutable=this._toImmutable()),this._cachedImmutable}},at=class extends yn{constructor(e){super(),this._data=e}get data(){return this._data}static _deserialize([e,t],n,r){const i=new at(t.data);return i._attach(e,r),i}_toOps(e,t,n){if(this._id===void 0)throw new Error("Cannot serialize register if parentId or parentKey is undefined");return[{type:8,opId:n==null?void 0:n.generateOpId(),id:this._id,parentId:e,parentKey:t,data:this.data}]}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveRegister if parent is missing");return{type:3,parentId:re(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key,data:this.data}}_attachChild(e){throw new Error("Method not implemented.")}_detachChild(e){throw new Error("Method not implemented.")}_apply(e,t){return super._apply(e,t)}_toImmutable(){return this._data}},_t=32,ur=126;function Xe(e,t){return e!==void 0&&t!==void 0?un(xi(kt(e),kt(t))):e!==void 0?Ks(e):t!==void 0?Bs(t):un([_t+1])}function Bs(e){const t=[],n=kt(e);for(let r=0;rs)throw new Error(`Impossible to generate position between ${e} and ${t}`);if(i===s){r.push(i),n++;continue}if(s-i===1){r.push(i),r.push(...xi(e.slice(n+1),[]));break}const o=s+i>>1;r.push(o);break}return r}function kt(e){const t=[];for(let n=0;nt._getParentKeyOrThrow()===e)}_attach(e,t){super._attach(e,t);for(const n of this._items)n._attach(t.generateId(),t)}_detach(){super._detach();for(const e of this._items)e._detach()}_applySetRemote(e){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:t,parentKey:n}=e,r=Lt(e);r._attach(t,this._pool),r._setParentLink(this,n);const i=e.deletedId,s=this._indexOfPosition(n);if(s!==-1){const o=this._items[s];if(o._id===i)return o._detach(),this._items[s]=r,{modified:ce(this,[yt(s,r)]),reverse:[]};{this._implicitlyDeletedItems.add(o),this._items[s]=r;const a=[yt(s,r)],l=this._detachItemAssociatedToSetOperation(e.deletedId);return l&&a.push(l),{modified:ce(this,a),reverse:[]}}}else{const o=[],a=this._detachItemAssociatedToSetOperation(e.deletedId);return a&&o.push(a),this._insertAndSort(r),o.push(je(this._indexOfPosition(n),r)),{reverse:[],modified:ce(this,o)}}}_applySetAck(e){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const t=[],n=this._detachItemAssociatedToSetOperation(e.deletedId);n&&t.push(n);const r=this._unacknowledgedSets.get(e.parentKey);if(r!==void 0){if(r!==e.opId)return t.length===0?{modified:!1}:{modified:ce(this,t),reverse:[]};this._unacknowledgedSets.delete(e.parentKey)}const i=this._indexOfPosition(e.parentKey),s=this._items.find(o=>o._id===e.id);if(s!==void 0){if(s._parentKey===e.parentKey)return{modified:t.length>0?ce(this,t):!1,reverse:[]};i!==-1&&(this._implicitlyDeletedItems.add(this._items[i]),this._items.splice(i,1),t.push(Yt(i)));const o=this._items.indexOf(s);s._setParentLink(this,e.parentKey),this._sortItems();const a=this._items.indexOf(s);return a!==o&&t.push(ut(o,a,s)),{modified:t.length>0?ce(this,t):!1,reverse:[]}}else{const o=this._pool.getNode(e.id);if(o&&this._implicitlyDeletedItems.has(o)){o._setParentLink(this,e.parentKey),this._implicitlyDeletedItems.delete(o),this._insertAndSort(o);const a=this._items.indexOf(o);return{modified:ce(this,[i===-1?je(a,o):yt(a,o),...t]),reverse:[]}}else{i!==-1&&this._items.splice(i,1);const{newItem:a,newIndex:l}=this._createAttachItemAndSort(e,e.parentKey);return{modified:ce(this,[i===-1?je(l,a):yt(l,a),...t]),reverse:[]}}}}_detachItemAssociatedToSetOperation(e){if(e===void 0||this._pool===void 0)return null;const t=this._pool.getNode(e);if(t===void 0)return null;const n=this._detachChild(t);return n.modified===!1?null:n.modified.updates[0]}_applyRemoteInsert(e){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const t=e.parentKey,n=this._indexOfPosition(t);n!==-1&&this._shiftItemPosition(n,t);const{newItem:r,newIndex:i}=this._createAttachItemAndSort(e,t);return{modified:ce(this,[je(i,r)]),reverse:[]}}_applyInsertAck(e){const t=this._items.find(i=>i._id===e.id),n=e.parentKey,r=this._indexOfPosition(n);if(t){if(t._parentKey===n)return{modified:!1};{const i=this._items.indexOf(t);r!==-1&&this._shiftItemPosition(r,n),t._setParentLink(this,n),this._sortItems();const s=this._indexOfPosition(n);return s===i?{modified:!1}:{modified:ce(this,[ut(i,s,t)]),reverse:[]}}}else{const i=re(this._pool).getNode(e.id);if(i&&this._implicitlyDeletedItems.has(i)){i._setParentLink(this,n),this._implicitlyDeletedItems.delete(i),this._insertAndSort(i);const s=this._indexOfPosition(n);return{modified:ce(this,[je(s,i)]),reverse:[]}}else{r!==-1&&this._shiftItemPosition(r,n);const{newItem:s,newIndex:o}=this._createAttachItemAndSort(e,n);return{modified:ce(this,[je(o,s)]),reverse:[]}}}}_applyInsertUndoRedo(e){var t,n,r;const{id:i,parentKey:s}=e,o=Lt(e);if(((t=this._pool)==null?void 0:t.getNode(i))!==void 0)return{modified:!1};o._attach(i,re(this._pool)),o._setParentLink(this,s);const a=this._indexOfPosition(s);let l=s;if(a!==-1){const u=(n=this._items[a])==null?void 0:n._getParentKeyOrThrow(),d=(r=this._items[a+1])==null?void 0:r._getParentKeyOrThrow();l=Xe(u,d),o._setParentLink(this,l)}this._insertAndSort(o);const c=this._indexOfPosition(l);return{modified:ce(this,[je(c,o)]),reverse:[{type:5,id:i}]}}_applySetUndoRedo(e){var t;const{id:n,parentKey:r}=e,i=Lt(e);if(((t=this._pool)==null?void 0:t.getNode(n))!==void 0)return{modified:!1};this._unacknowledgedSets.set(r,re(e.opId));const s=this._indexOfPosition(r);i._attach(n,re(this._pool)),i._setParentLink(this,r);const o=r;if(s!==-1){const a=this._items[s];a._detach(),this._items[s]=i;const l=a._toOps(re(this._id),r,this._pool);$n(l,e.id);const c=[yt(s,i)],u=this._detachItemAssociatedToSetOperation(e.deletedId);return u&&c.push(u),{modified:ce(this,c),reverse:l}}else{this._insertAndSort(i),this._detachItemAssociatedToSetOperation(e.deletedId);const a=this._indexOfPosition(o);return{reverse:[{type:5,id:n}],modified:ce(this,[je(a,i)])}}}_attachChild(e,t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");let n;return e.intent==="set"?t===1?n=this._applySetRemote(e):t===2?n=this._applySetAck(e):n=this._applySetUndoRedo(e):t===1?n=this._applyRemoteInsert(e):t===2?n=this._applyInsertAck(e):n=this._applyInsertUndoRedo(e),n.modified!==!1&&this.invalidate(),n}_detachChild(e){if(e){const t=re(e._parentKey),n=e._toOps(re(this._id),t,this._pool),r=this._items.indexOf(e);return r===-1?{modified:!1}:(this._items.splice(r,1),this.invalidate(),e._detach(),{modified:ce(this,[Yt(r)]),reverse:n})}return{modified:!1}}_applySetChildKeyRemote(e,t){var n;if(this._implicitlyDeletedItems.has(t)){this._implicitlyDeletedItems.delete(t),t._setParentLink(this,e),this._insertAndSort(t);const s=this._items.indexOf(t);return{modified:ce(this,[je(s,t)]),reverse:[]}}const r=t._parentKey;if(e===r)return{modified:!1};const i=this._indexOfPosition(e);if(i===-1){const s=this._items.indexOf(t);t._setParentLink(this,e),this._sortItems();const o=this._items.indexOf(t);return o===s?{modified:!1}:{modified:ce(this,[ut(s,o,t)]),reverse:[]}}else{this._items[i]._setParentLink(this,Xe(e,(n=this._items[i+1])==null?void 0:n._getParentKeyOrThrow()));const s=this._items.indexOf(t);t._setParentLink(this,e),this._sortItems();const o=this._items.indexOf(t);return o===s?{modified:!1}:{modified:ce(this,[ut(s,o,t)]),reverse:[]}}}_applySetChildKeyAck(e,t){var n,r;const i=re(t._parentKey);if(this._implicitlyDeletedItems.has(t)){const s=this._indexOfPosition(e);return this._implicitlyDeletedItems.delete(t),s!==-1&&this._items[s]._setParentLink(this,Xe(e,(n=this._items[s+1])==null?void 0:n._getParentKeyOrThrow())),t._setParentLink(this,e),this._insertAndSort(t),{modified:!1}}else{if(e===i)return{modified:!1};const s=this._items.indexOf(t),o=this._indexOfPosition(e);o!==-1&&this._items[o]._setParentLink(this,Xe(e,(r=this._items[o+1])==null?void 0:r._getParentKeyOrThrow())),t._setParentLink(this,e),this._sortItems();const a=this._items.indexOf(t);return s===a?{modified:!1}:{modified:ce(this,[ut(s,a,t)]),reverse:[]}}}_applySetChildKeyUndoRedo(e,t){var n;const r=re(t._parentKey),i=this._items.indexOf(t),s=this._indexOfPosition(e);s!==-1&&this._items[s]._setParentLink(this,Xe(e,(n=this._items[s+1])==null?void 0:n._getParentKeyOrThrow())),t._setParentLink(this,e),this._sortItems();const o=this._items.indexOf(t);return i===o?{modified:!1}:{modified:ce(this,[ut(i,o,t)]),reverse:[{type:1,id:re(t._id),parentKey:r}]}}_setChildKey(e,t,n){return n===1?this._applySetChildKeyRemote(e,t):n===2?this._applySetChildKeyAck(e,t):this._applySetChildKeyUndoRedo(e,t)}_apply(e,t){return super._apply(e,t)}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveList if parent is missing");return{type:1,parentId:re(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key}}get length(){return this._items.length}push(e){var t;return(t=this._pool)==null||t.assertStorageIsWritable(),this.insert(e,this.length)}insert(e,t){var n;if((n=this._pool)==null||n.assertStorageIsWritable(),t<0||t>this._items.length)throw new Error(`Cannot insert list item at index "${t}". index should be between 0 and ${this._items.length}`);const r=this._items[t-1]?this._items[t-1]._getParentKeyOrThrow():void 0,i=this._items[t]?this._items[t]._getParentKeyOrThrow():void 0,s=Xe(r,i),o=wt(e);if(o._setParentLink(this,s),this._insertAndSort(o),this._pool&&this._id){const a=this._pool.generateId();o._attach(a,this._pool),this._pool.dispatch(o._toOps(this._id,s,this._pool),[{type:5,id:a}],new Map([[this._id,ce(this,[je(t,o)])]]))}}move(e,t){var n;if((n=this._pool)==null||n.assertStorageIsWritable(),t<0)throw new Error("targetIndex cannot be less than 0");if(t>=this._items.length)throw new Error("targetIndex cannot be greater or equal than the list length");if(e<0)throw new Error("index cannot be less than 0");if(e>=this._items.length)throw new Error("index cannot be greater or equal than the list length");let r=null,i=null;e=this._items.length)throw new Error(`Cannot delete list item at index "${e}". index should be between 0 and ${this._items.length-1}`);const n=this._items[e];if(n._detach(),this._items.splice(e,1),this.invalidate(),this._pool){const r=n._id;if(r){const i=new Map;i.set(re(this._id),ce(this,[Yt(e)])),this._pool.dispatch([{id:r,opId:this._pool.generateOpId(),type:5}],n._toOps(re(this._id),n._getParentKeyOrThrow()),i)}}}clear(){var e;if((e=this._pool)==null||e.assertStorageIsWritable(),this._pool){const t=[],n=[],r=[];for(const s of this._items){s._detach();const o=s._id;o&&(t.push({type:5,id:o,opId:this._pool.generateOpId()}),n.push(...s._toOps(re(this._id),s._getParentKeyOrThrow())),r.push(Yt(0)))}this._items=[],this.invalidate();const i=new Map;i.set(re(this._id),ce(this,r)),this._pool.dispatch(t,n,i)}else{for(const t of this._items)t._detach();this._items=[],this.invalidate()}}set(e,t){var n;if((n=this._pool)==null||n.assertStorageIsWritable(),e<0||e>=this._items.length)throw new Error(`Cannot set list item at index "${e}". index should be between 0 and ${this._items.length-1}`);const r=this._items[e],i=r._getParentKeyOrThrow(),s=r._id;r._detach();const o=wt(t);if(o._setParentLink(this,i),this._items[e]=o,this.invalidate(),this._pool&&this._id){const a=this._pool.generateId();o._attach(a,this._pool);const l=new Map;l.set(this._id,ce(this,[yt(e,o)]));const c=o._toOps(this._id,i,this._pool);$n(c,s),this._unacknowledgedSets.set(i,re(c[0].opId));const u=r._toOps(this._id,i,void 0);$n(u,a),this._pool.dispatch(c,u,l)}}toArray(){return this._items.map(e=>ht(e))}every(e){return this.toArray().every(e)}filter(e){return this.toArray().filter(e)}find(e){return this.toArray().find(e)}findIndex(e){return this.toArray().findIndex(e)}forEach(e){return this.toArray().forEach(e)}get(e){if(!(e<0||e>=this._items.length))return ht(this._items[e])}indexOf(e,t){return this.toArray().indexOf(e,t)}lastIndexOf(e,t){return this.toArray().lastIndexOf(e,t)}map(e){return this._items.map((t,n)=>e(ht(t),n))}some(e){return this.toArray().some(e)}[Symbol.iterator](){return new js(this._items)}_createAttachItemAndSort(e,t){const n=Lt(e);n._attach(e.id,re(this._pool)),n._setParentLink(this,t),this._insertAndSort(n);const r=this._indexOfPosition(t);return{newItem:n,newIndex:r}}_shiftItemPosition(e,t){var n;const r=Xe(t,this._items.length>e+1?(n=this._items[e+1])==null?void 0:n._getParentKeyOrThrow():void 0);this._items[e]._setParentLink(this,r)}toImmutable(){return super.toImmutable()}_toImmutable(){return this._items.map(t=>t.toImmutable())}},js=class{constructor(e){this._innerIterator=e[Symbol.iterator]()}[Symbol.iterator](){return this}next(){const e=this._innerIterator.next();return e.done?{done:!0,value:void 0}:{value:ht(e.value)}}};function ce(e,t){return{node:e,type:"LiveList",updates:t}}function yt(e,t){return{index:e,type:"set",item:t instanceof at?t.data:t}}function Yt(e){return{index:e,type:"delete"}}function je(e,t){return{index:e,type:"insert",item:t instanceof at?t.data:t}}function ut(e,t,n){return{index:t,type:"move",previousIndex:e,item:n instanceof at?n.data:n}}function $n(e,t){if(e.length===0)throw new Error("Internal error. Serialized LiveStructure should have at least 1 operation");const n=e[0];n.intent="set",n.deletedId=t}var lt=class extends yn{constructor(e){if(super(),this.unacknowledgedSet=new Map,e){const t=[];for(const n of e){const r=wt(n[1]);r._setParentLink(this,n[0]),t.push([n[0],r])}this._map=new Map(t)}else this._map=new Map}_toOps(e,t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=[],i={id:this._id,opId:n==null?void 0:n.generateOpId(),type:7,parentId:e,parentKey:t};r.push(i);for(const[s,o]of this._map)r.push(...o._toOps(this._id,s,n));return r}static _deserialize([e,t],n,r){const i=new lt;i._attach(e,r);const s=n.get(e);if(s===void 0)return i;for(const[o,a]of s){const l=Ci([o,a],n,r);l._setParentLink(i,a.parentKey),i._map.set(a.parentKey,l),i.invalidate()}return i}_attach(e,t){super._attach(e,t);for(const[n,r]of this._map)Oe(r)&&r._attach(t.generateId(),t)}_attachChild(e,t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:n,parentKey:r,opId:i}=e,s=r,o=Lt(e);if(this._pool.getNode(n)!==void 0)return{modified:!1};if(t===2){const c=this.unacknowledgedSet.get(s);if(c===i)return this.unacknowledgedSet.delete(s),{modified:!1};if(c!==void 0)return{modified:!1}}else t===1&&this.unacknowledgedSet.delete(s);const a=this._map.get(s);let l;if(a){const c=re(this._id);l=a._toOps(c,s),a._detach()}else l=[{type:5,id:n}];return o._setParentLink(this,s),o._attach(n,this._pool),this._map.set(s,o),this.invalidate(),{modified:{node:this,type:"LiveMap",updates:{[s]:{type:"update"}}},reverse:l}}_detach(){super._detach();for(const e of this._map.values())e._detach()}_detachChild(e){const t=re(this._id),n=re(e._parentKey),r=e._toOps(t,n,this._pool);for(const[s,o]of this._map)o===e&&(this._map.delete(s),this.invalidate());return e._detach(),{modified:{node:this,type:"LiveMap",updates:{[n]:{type:"delete"}}},reverse:r}}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveMap if parent is missing");return{type:2,parentId:re(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key}}get(e){const t=this._map.get(e);if(t!==void 0)return ht(t)}set(e,t){var n;(n=this._pool)==null||n.assertStorageIsWritable();const r=this._map.get(e);r&&r._detach();const i=wt(t);if(i._setParentLink(this,e),this._map.set(e,i),this.invalidate(),this._pool&&this._id){const s=this._pool.generateId();i._attach(s,this._pool);const o=new Map;o.set(this._id,{node:this,type:"LiveMap",updates:{[e]:{type:"update"}}});const a=i._toOps(this._id,e,this._pool);this.unacknowledgedSet.set(e,re(a[0].opId)),this._pool.dispatch(i._toOps(this._id,e,this._pool),r?r._toOps(this._id,e):[{type:5,id:s}],o)}}get size(){return this._map.size}has(e){return this._map.has(e)}delete(e){var t;(t=this._pool)==null||t.assertStorageIsWritable();const n=this._map.get(e);if(n===void 0)return!1;if(n._detach(),this._map.delete(e),this.invalidate(),this._pool&&n._id){const r=re(this._id),i=new Map;i.set(r,{node:this,type:"LiveMap",updates:{[e]:{type:"delete"}}}),this._pool.dispatch([{type:5,id:n._id,opId:this._pool.generateOpId()}],n._toOps(r,e),i)}return!0}entries(){const e=this._map.entries();return{[Symbol.iterator](){return this},next(){const t=e.next();if(t.done)return{done:!0,value:void 0};const r=t.value[0],i=ht(t.value[1]);return{value:[r,i]}}}}[Symbol.iterator](){return this.entries()}keys(){return this._map.keys()}values(){const e=this._map.values();return{[Symbol.iterator](){return this},next(){const t=e.next();return t.done?{done:!0,value:void 0}:{value:ht(t.value)}}}}forEach(e){for(const t of this)e(t[1],t[0],this)}toImmutable(){return super.toImmutable()}_toImmutable(){const e=new Map;for(const[t,n]of this._map)e.set(t,n.toImmutable());return ze(e)}},Ke=class extends yn{constructor(e={}){super(),this._propToLastUpdate=new Map;for(const t in e){const n=e[t];n!==void 0&&Oe(n)&&n._setParentLink(this,t)}this._map=new Map(Object.entries(e))}_toOps(e,t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=n==null?void 0:n.generateOpId(),i=[],s=e!==void 0&&t!==void 0?{type:4,id:this._id,opId:r,parentId:e,parentKey:t,data:{}}:{type:4,id:this._id,opId:r,data:{}};i.push(s);for(const[o,a]of this._map)Oe(a)?i.push(...a._toOps(this._id,o,n)):s.data[o]=a;return i}static _deserialize([e,t],n,r){const i=new Ke(t.data);return i._attach(e,r),this._deserializeChildren(i,n,r)}static _deserializeChildren(e,t,n){const r=t.get(re(e._id));if(r===void 0)return e;for(const[i,s]of r){const o=Xs([i,s],t,n);nn(o)&&o._setParentLink(e,s.parentKey),e._map.set(s.parentKey,o),e.invalidate()}return e}_attach(e,t){super._attach(e,t);for(const[n,r]of this._map)Oe(r)&&r._attach(t.generateId(),t)}_attachChild(e,t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:n,opId:r,parentKey:i}=e,s=Oi(e);if(this._pool.getNode(n)!==void 0)return this._propToLastUpdate.get(i)===r&&this._propToLastUpdate.delete(i),{modified:!1};if(t===0)this._propToLastUpdate.set(i,re(r));else if(this._propToLastUpdate.get(i)!==void 0)return this._propToLastUpdate.get(i)===r?(this._propToLastUpdate.delete(i),{modified:!1}):{modified:!1};const o=re(this._id),a=this._map.get(i);let l;return Oe(a)?(l=a._toOps(o,i),a._detach()):a===void 0?l=[{type:6,id:o,key:i}]:l=[{type:3,id:o,data:{[i]:a}}],this._map.set(i,s),this.invalidate(),nn(s)&&(s._setParentLink(this,i),s._attach(n,this._pool)),{reverse:l,modified:{node:this,type:"LiveObject",updates:{[i]:{type:"update"}}}}}_detachChild(e){if(e){const t=re(this._id),n=re(e._parentKey),r=e._toOps(t,n,this._pool);for(const[s,o]of this._map)o===e&&(this._map.delete(s),this.invalidate());return e._detach(),{modified:{node:this,type:"LiveObject",updates:{[n]:{type:"delete"}}},reverse:r}}return{modified:!1}}_detach(){super._detach();for(const e of this._map.values())Oe(e)&&e._detach()}_apply(e,t){return e.type===3?this._applyUpdate(e,t):e.type===6?this._applyDeleteObjectKey(e):super._apply(e,t)}_serialize(){const e={};for(const[t,n]of this._map)Oe(n)||(e[t]=n);return this.parent.type==="HasParent"&&this.parent.node._id?{type:0,parentId:this.parent.node._id,parentKey:this.parent.key,data:e}:{type:0,data:e}}_applyUpdate(e,t){let n=!1;const r=re(this._id),i=[],s={type:3,id:r,data:{}};i.push(s);for(const a in e.data){const l=this._map.get(a);Oe(l)?(i.push(...l._toOps(r,a)),l._detach()):l!==void 0?s.data[a]=l:l===void 0&&i.push({type:6,id:r,key:a})}const o={};for(const a in e.data){const l=e.data[a];if(l===void 0)continue;if(t)this._propToLastUpdate.set(a,re(e.opId));else if(this._propToLastUpdate.get(a)===void 0)n=!0;else if(this._propToLastUpdate.get(a)===e.opId){this._propToLastUpdate.delete(a);continue}else continue;const c=this._map.get(a);Oe(c)&&c._detach(),n=!0,o[a]={type:"update"},this._map.set(a,l),this.invalidate()}return Object.keys(s.data).length!==0&&i.unshift(s),n?{modified:{node:this,type:"LiveObject",updates:o},reverse:i}:{modified:!1}}_applyDeleteObjectKey(e){const t=e.key;if(this._map.has(t)===!1)return{modified:!1};if(this._propToLastUpdate.get(t)!==void 0)return{modified:!1};const n=this._map.get(t),r=re(this._id);let i=[];return Oe(n)?(i=n._toOps(r,e.key),n._detach()):n!==void 0&&(i=[{type:3,id:r,data:{[t]:n}}]),this._map.delete(t),this.invalidate(),{modified:{node:this,type:"LiveObject",updates:{[e.key]:{type:"delete"}}},reverse:i}}toObject(){return Qs(this._map)}set(e,t){var n;(n=this._pool)==null||n.assertStorageIsWritable(),this.update({[e]:t})}get(e){return this._map.get(e)}delete(e){var t;(t=this._pool)==null||t.assertStorageIsWritable();const n=e,r=this._map.get(n);if(r===void 0)return;if(this._pool===void 0||this._id===void 0){Oe(r)&&r._detach(),this._map.delete(n),this.invalidate();return}let i;Oe(r)?(r._detach(),i=r._toOps(this._id,n)):i=[{type:3,data:{[n]:r},id:this._id}],this._map.delete(n),this.invalidate();const s=new Map;s.set(this._id,{node:this,type:"LiveObject",updates:{[e]:{type:"delete"}}}),this._pool.dispatch([{type:6,key:n,id:this._id,opId:this._pool.generateOpId()}],i,s)}update(e){var t;if((t=this._pool)==null||t.assertStorageIsWritable(),this._pool===void 0||this._id===void 0){for(const c in e){const u=e[c];if(u===void 0)continue;const d=this._map.get(c);Oe(d)&&d._detach(),Oe(u)&&u._setParentLink(this,c),this._map.set(c,u),this.invalidate()}return}const n=[],r=[],i=this._pool.generateOpId(),s={},o={id:this._id,type:3,data:{}},a={};for(const c in e){const u=e[c];if(u===void 0)continue;const d=this._map.get(c);if(Oe(d)?(r.push(...d._toOps(this._id,c)),d._detach()):d===void 0?r.push({type:6,id:this._id,key:c}):o.data[c]=d,Oe(u)){u._setParentLink(this,c),u._attach(this._pool.generateId(),this._pool);const h=u._toOps(this._id,c,this._pool),p=h.find(E=>E.parentId===this._id);p&&this._propToLastUpdate.set(c,re(p.opId)),n.push(...h)}else s[c]=u,this._propToLastUpdate.set(c,i);this._map.set(c,u),this.invalidate(),a[c]={type:"update"}}Object.keys(o.data).length!==0&&r.unshift(o),Object.keys(s).length!==0&&n.unshift({opId:i,id:this._id,type:3,data:s});const l=new Map;l.set(this._id,{node:this,type:"LiveObject",updates:a}),this._pool.dispatch(n,r,l)}toImmutable(){return super.toImmutable()}_toImmutable(){const e={};for(const[t,n]of this._map)e[t]=nn(n)?n.toImmutable():n;return e}},ze=e=>e;function Kn(e){return e.filter(t=>t!=null)}function wn(e){const t=it({},e);return Object.keys(e).forEach(n=>{const r=n;t[r]===void 0&&delete t[r]}),t}function Lt(e){return wt(Oi(e))}function Oi(e){switch(e.type){case 8:return e.data;case 4:return new Ke(e.data);case 7:return new lt;case 2:return new Ze;default:return tt(e,"Unknown creation Op")}}function Ai(e,t){return e===t?!0:e.parent.type==="HasParent"?Ai(e.parent.node,t):!1}function Ci([e,t],n,r){switch(t.type){case 0:return Ke._deserialize([e,t],n,r);case 1:return Ze._deserialize([e,t],n,r);case 2:return lt._deserialize([e,t],n,r);case 3:return at._deserialize([e,t],n,r);default:throw new Error("Unexpected CRDT type")}}function Xs([e,t],n,r){switch(t.type){case 0:return Ke._deserialize([e,t],n,r);case 1:return Ze._deserialize([e,t],n,r);case 2:return lt._deserialize([e,t],n,r);case 3:return t.data;default:throw new Error("Unexpected CRDT type")}}function nn(e){return bn(e)||Ys(e)||fr(e)}function Oe(e){return nn(e)||Js(e)}function bn(e){return e instanceof Ze}function Ys(e){return e instanceof lt}function fr(e){return e instanceof Ke}function Js(e){return e instanceof at}function ht(e){return e instanceof at?e.data:e instanceof Ze||e instanceof lt||e instanceof Ke?e:tt(e,"Unknown AbstractCrdt")}function wt(e){return e instanceof Ke||e instanceof lt||e instanceof Ze?e:new at(e)}function Zs(e,t){const n=[];return e.forEach((r,i)=>{t.get(i)||n.push({type:5,id:i})}),t.forEach((r,i)=>{const s=e.get(i);if(s)r.type===0&&(s.type!==0||JSON.stringify(r.data)!==JSON.stringify(s.data))&&n.push({type:3,id:i,data:r.data}),r.parentKey!==s.parentKey&&n.push({type:1,id:i,parentKey:re(r.parentKey,"Parent key must not be missing")});else switch(r.type){case 3:n.push({type:8,id:i,parentId:r.parentId,parentKey:r.parentKey,data:r.data});break;case 1:n.push({type:2,id:i,parentId:r.parentId,parentKey:r.parentKey});break;case 0:n.push(r.parentId?{type:4,id:i,parentId:r.parentId,parentKey:r.parentKey,data:r.data}:{type:4,id:i,data:r.data});break;case 2:n.push({type:7,id:i,parentId:r.parentId,parentKey:r.parentKey});break}}),n}function Ws(e,t){const n=e.updates;for(const[r,i]of Si(t.updates))n[r]=i;return Ot(it({},t),{updates:n})}function qs(e,t){const n=e.updates;for(const[r,i]of Si(t.updates))n[r]=i;return Ot(it({},t),{updates:n})}function Gs(e,t){const n=e.updates;return Ot(it({},t),{updates:n.concat(t.updates)})}function Nn(e,t){return e?e.type==="LiveObject"&&t.type==="LiveObject"?Ws(e,t):e.type==="LiveMap"&&t.type==="LiveMap"?qs(e,t):e.type==="LiveList"&&t.type==="LiveList"?Gs(e,t):t:t}function st(e){return e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function Qs(e){const t={};for(const[n,r]of e)t[n]=r;return t}function Si(e){return Object.entries(e)}function hr(e){try{return JSON.parse(e)}catch{return}}function Pi(e){try{const t=e.replace(/-/g,"+").replace(/_/g,"/");return decodeURIComponent(atob(t).split("").map(function(r){return"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)}).join(""))}catch{return atob(e)}}function eo(e){if(!st(e))return!1;const{iat:t,exp:n}=e;return typeof t=="number"&&typeof n=="number"}function to(e){const t=Date.now()/1e3;return t>e.exp-300||ttypeof t=="string")}function Ti(e){return typeof e.appId=="string"&&e.roomId===void 0&&Li(e.scopes)}function dr(e){return typeof e.appId=="string"&&typeof e.roomId=="string"&&typeof e.actor=="number"&&(e.id===void 0||typeof e.id=="string")&&Li(e.scopes)&&(e.maxConnectionsPerRoom===void 0||typeof e.maxConnectionsPerRoom=="number")}function no(e){return Ti(e)||dr(e)}function ro(e){const t=e.split(".");if(t.length!==3)throw new Error("Authentication error: invalid JWT token");const n=hr(Pi(t[1]));if(n&&eo(n))return n;throw new Error("Authentication error: missing JWT metadata")}function Lr(e){const t=ro(e);if(t&&dr(t))return zs(t,["maxConnections"]);throw new Error("Authentication error: we expected a room token but did not get one. Hint: if you are using a callback, ensure the room is passed when creating the token. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientCallback")}function io(e,t=e){}function so(e,t,n=t){}function oo(e){}function ao(e,t){}function Qe(){const e=new Set,t=new Set;function n(o){return t.add(o),()=>t.delete(o)}function r(o){return e.add(o),()=>e.delete(o)}function i(o){e.forEach(a=>a(o)),e.clear(),t.forEach(a=>a(o))}function s(){e.clear(),t.clear()}return{notify:i,subscribe:n,subscribeOnce:r,clear:s,observable:{subscribe:n,subscribeOnce:r}}}function $i(e,t){let n=!1;const r=it({},e);return Object.keys(t).forEach(i=>{const s=i,o=t[s];r[s]!==o&&(o===void 0?delete r[s]:r[s]=o,n=!0)}),n?r:e}var En=class{constructor(){this._ev=Qe()}get didInvalidate(){return this._ev.observable}invalidate(){this._cache!==void 0&&(this._cache=void 0,this._ev.notify())}get current(){var e;return(e=this._cache)!=null?e:this._cache=this._toImmutable()}},lo=class extends En{constructor(e){super(),this._me=ze(wn(e))}_toImmutable(){return this._me}patch(e){const t=this._me,n=$i(t,e);t!==n&&(this._me=ze(n),this.invalidate())}};function Ni(e){return Object.defineProperty(e,"count",{value:e.length,enumerable:!1}),Object.defineProperty(e,"toArray",{value:()=>e,enumerable:!1}),ze(e)}function co(e,t){return ze(wn(Ot(it({},e),{presence:t})))}var uo=class extends En{constructor(){super(),this._connections={},this._presences={},this._users={}}_toImmutable(){const e=Kn(Object.keys(this._presences).map(t=>this.getUser(Number(t))));return Ni(e)}clearOthers(){this._connections={},this._presences={},this._users={},this.invalidate()}_getUser(e){const t=this._connections[e],n=this._presences[e];if(t!==void 0&&n!==void 0)return co(t,n)}getUser(e){const t=this._users[e];if(t)return t;const n=this._getUser(e);if(n)return this._users[e]=n,n}_invalidateUser(e){this._users[e]!==void 0&&delete this._users[e],this.invalidate()}setConnection(e,t,n,r){this._connections[e]=ze({connectionId:e,id:t,info:n,isReadOnly:r}),this._presences[e]!==void 0&&this._invalidateUser(e)}removeConnection(e){delete this._connections[e],delete this._presences[e],this._invalidateUser(e)}setOther(e,t){this._presences[e]=ze(wn(t)),this._connections[e]!==void 0&&this._invalidateUser(e)}patchOther(e,t){const n=this._presences[e];if(n===void 0)return;const r=$i(n,t);n!==r&&(this._presences[e]=ze(r),this._invalidateUser(e))}};function Ri(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function pr(e){return Array.isArray(e)}function Mi(e){return!Ri(e)&&!pr(e)}var fo=class extends En{constructor(e){super(),this._value=ze(wn(e))}_toImmutable(){return this._value}set(e){this._value=ze(e),this.invalidate()}},ho=class extends En{constructor(e,t){super(),this._refs=e,this._refs.forEach(n=>{n.didInvalidate.subscribe(()=>this.invalidate())}),this._transform=t}_toImmutable(){return this._transform(this._refs[0].current,this._refs[1].current)}},Rn=[250,500,1e3,2e3,4e3,8e3,1e4],Mn=[2e3,3e4,6e4,3e5],po=3e4,mo=2e3;function _o(e){let t=0;return()=>`${e}:${t++}`}function Jt(e){return e.state==="open"||e.state==="connecting"}function go(e,t,n){var r;const i=g=>g(),s=(r=t.unstable_batchedUpdates)!=null?r:i,o={roomId:t.roomId,getNode:g=>e.nodes.get(g),addNode:(g,L)=>void e.nodes.set(g,L),deleteNode:g=>void e.nodes.delete(g),generateId:()=>`${_()}:${e.clock++}`,generateOpId:()=>`${_()}:${e.opClock++}`,dispatch(g,L,M){const K=e.activeBatch;K?(K.ops.push(...g),M.forEach((J,ve)=>{K.updates.storageUpdates.set(ve,Nn(K.updates.storageUpdates.get(ve),J))}),K.reverseOps.push(...L)):s(()=>{x(L,i),e.redoStack=[],kr(g),k({storageUpdates:M},i)})},assertStorageIsWritable:()=>{if(Jt(e.connection.current)&&e.connection.current.isReadOnly)throw new Error("Cannot write to storage with a read only user, please ensure the user has write permissions")}},a={customEvent:Qe(),me:Qe(),others:Qe(),error:Qe(),connection:Qe(),storage:Qe(),history:Qe(),storageDidLoad:Qe()},l=n||{authenticate(g,L){const M=e.token,K=M!==null&&Lr(M);if(K&&!to(K)){const J=L(M);Y(K,J);return}else return g(t.roomId).then(({token:J})=>{if(e.connection.current.state!=="authenticating")return;const ve=Lr(J),le=L(J);Y(ve,le),e.token=J}).catch(J=>Z())},send(g){if(e.socket===null)throw new Error("Can't send message if socket is null");e.socket.send(JSON.stringify(g))},delayFlush(g){return setTimeout(De,g)},startHeartbeatInterval(){return setInterval(Ce,po)},schedulePongTimeout(){return setTimeout(qe,mo)},scheduleReconnect(g){return setTimeout(V,g)}},c=new ho([e.connection,e.me],(g,L)=>Jt(g)?{connectionId:g.id,id:g.userId,info:g.userInfo,presence:L,isReadOnly:g.isReadOnly}:null);function u(g,L){if(g.items.length===0)throw new Error("Internal error: cannot load storage without items");e.root?h(g.items,L):e.root=p(g.items);for(const M in e.initialStorage)e.root.get(M)===void 0&&e.root.set(M,e.initialStorage[M])}function d(g){const L=new Map;let M=null;for(const[K,J]of g)if(wi(J))M=[K,J];else{const ve=[K,J],le=L.get(J.parentId);le!==void 0?le.push(ve):L.set(J.parentId,[ve])}if(M===null)throw new Error("Root can't be null");return[M,L]}function h(g,L){if(!e.root)return;const M=new Map;e.nodes.forEach((ve,le)=>{M.set(le,ve._serialize())});const K=Zs(M,new Map(g)),J=b(K,!1);k(J.updates,L)}function p(g){const[L,M]=d(g);return Ke._deserialize(L,M,o)}function E(g,L){e.undoStack.length>=50&&e.undoStack.shift(),e.undoStack.push(g),R(L)}function x(g,L){e.pausedHistory!==null?e.pausedHistory.unshift(...g):E(g,L)}function k({storageUpdates:g=new Map,presence:L=!1,others:M=[]},K){K(()=>{if(M.length>0){const J=e.others.current;for(const ve of M)a.others.notify({others:J,event:ve})}if(L&&a.me.notify(e.me.current),g.size>0){const J=Array.from(g.values());a.storage.notify(J)}})}function _(){const g=e.connection.current;if(Jt(g))return g.id;if(e.lastConnectionId!==null)return e.lastConnectionId;throw new Error("Internal. Tried to get connection id but connection was never open")}function b(g,L){const M={reverse:[],updates:{storageUpdates:new Map,presence:!1}},K=new Set;for(const J of g)if(J.type==="presence"){const ve={type:"presence",data:{}};for(const le in J.data)ve.data[le]=e.me.current[le];if(e.me.patch(J.data),e.buffer.me===null)e.buffer.me={type:"partial",data:J.data};else for(const le in J.data)e.buffer.me.data[le]=J.data[le];M.reverse.unshift(ve),M.updates.presence=!0}else{let ve;J.opId||(J.opId=o.generateOpId()),L?ve=0:ve=e.offlineOperations.delete(re(J.opId))?2:1;const le=S(J,ve);if(le.modified){const Tn=le.modified.node.parent.type==="HasParent"?re(le.modified.node.parent.node._id,"Expected parent node to have an ID"):void 0;(!Tn||!K.has(Tn))&&(M.updates.storageUpdates.set(re(le.modified.node._id),Nn(M.updates.storageUpdates.get(re(le.modified.node._id)),le.modified)),M.reverse.unshift(...le.reverse)),(J.type===2||J.type===7||J.type===4)&&K.add(re(le.modified.node._id))}}return M}function S(g,L){switch(g.type){case 6:case 3:case 5:{const M=e.nodes.get(g.id);return M===void 0?{modified:!1}:M._apply(g,L===0)}case 1:{const M=e.nodes.get(g.id);return M===void 0?{modified:!1}:M.parent.type==="HasParent"&&bn(M.parent.node)?M.parent.node._setChildKey(g.parentKey,M,L):{modified:!1}}case 4:case 2:case 7:case 8:{if(g.parentId===void 0)return{modified:!1};const M=e.nodes.get(g.parentId);return M===void 0?{modified:!1}:M._attachChild(g,L)}}}function w(g,L){return a.storage.subscribe(M=>{const K=M.filter(J=>Ai(J.node,g));K.length>0&&L(K)})}function N(g,L){return a.storage.subscribe(M=>{for(const K of M)K.node._id===g._id&&L(K.node)})}function A(g,L,M){if(typeof g=="string"&&Vs(g)){if(typeof L!="function")throw new Error("Second argument must be a callback function");const K=L;switch(g){case"event":return a.customEvent.subscribe(K);case"my-presence":return a.me.subscribe(K);case"others":{const J=K;return a.others.subscribe(({others:ve,event:le})=>J(ve,le))}case"error":return a.error.subscribe(K);case"connection":return a.connection.subscribe(K);case"storage":return a.storage.subscribe(K);case"history":return a.history.subscribe(K);default:return tt(g,"Unknown event")}}if(L===void 0||typeof g=="function")if(typeof g=="function"){const K=g;return a.storage.subscribe(K)}else throw new Error("Please specify a listener callback");if(Oe(g)){const K=g;return M!=null&&M.isDeep?w(K,L):N(K,L)}throw new Error(`"${g}" is not a valid event name`)}function $(){return e.connection.current.state}function V(){var g,L,M,K;if(e.connection.current.state!=="closed"&&e.connection.current.state!=="unavailable")return;const J=Eo(t.authentication,(L=(g=t.polyfills)==null?void 0:g.fetch)!=null?L:t.fetchPolyfill),ve=bo(t.liveblocksServer,(K=(M=t.polyfills)==null?void 0:M.WebSocket)!=null?K:t.WebSocketPolyfill);oe({state:"authenticating"},s),l.authenticate(J,ve)}function T(g,L){const M={};e.buffer.me===null&&(e.buffer.me={type:"partial",data:{}});for(const K in g){const J=g[K];J!==void 0&&(e.buffer.me.data[K]=J,M[K]=e.me.current[K])}e.me.patch(g),e.activeBatch?(L!=null&&L.addToHistory&&e.activeBatch.reverseOps.push({type:"presence",data:M}),e.activeBatch.updates.presence=!0):(De(),s(()=>{L!=null&&L.addToHistory&&x([{type:"presence",data:M}],i),k({presence:!0},i)}))}function H(g){return g.includes("room:read")&&g.includes("room:presence:write")&&!g.includes("room:write")}function Y(g,L){L.addEventListener("message",ae),L.addEventListener("open",Ie),L.addEventListener("close",fe),L.addEventListener("error",ye),oe({state:"connecting",id:g.actor,userInfo:g.info,userId:g.id,isReadOnly:H(g.scopes)},s),e.idFactory=_o(g.actor),e.socket=L}function Z(g){e.token=null,oe({state:"unavailable"},s),e.numberOfRetry++,e.timeoutHandles.reconnect=l.scheduleReconnect(xe())}function j(g){g==="visible"&&e.connection.current.state==="open"&&Ce()}function y(g){if(g.targetActor!==void 0){const M=e.others.getUser(g.actor);e.others.setOther(g.actor,g.data);const K=e.others.getUser(g.actor);if(M===void 0&&K!==void 0)return{type:"enter",user:K}}else e.others.patchOther(g.actor,g.data);const L=e.others.getUser(g.actor);if(L)return{type:"update",updates:g.data,user:L}}function O(g){const L=e.others.getUser(g.actor);return L?(e.others.removeConnection(g.actor),{type:"leave",user:L}):null}function C(g){for(const L in g.users){const M=g.users[L],K=Number(L);e.others.setConnection(K,M.id,M.info,H(M.scopes))}return{type:"reset"}}function P(){e.connection.current.state==="unavailable"&&At()}function R(g){g(()=>{a.history.notify({canUndo:Ir(),canRedo:Or()})})}function z(g){e.others.setConnection(g.actor,g.id,g.info,H(g.scopes)),e.buffer.messages.push({type:100,data:e.me.current,targetActor:g.actor}),De();const L=e.others.getUser(g.actor);return L?{type:"enter",user:L}:void 0}function B(g){return Mi(g)?g:null}function te(g){const L=hr(g);return L===void 0?null:pr(L)?Kn(L.map(M=>B(M))):Kn([B(L)])}function ae(g){if(g.data==="pong"){clearTimeout(e.timeoutHandles.pongTimeout);return}const L=te(g.data);if(L===null||L.length===0)return;const M={storageUpdates:new Map,others:[]};s(()=>{for(const K of L)switch(K.type){case 101:{const J=z(K);J&&M.others.push(J);break}case 100:{const J=y(K);J&&M.others.push(J);break}case 103:{a.customEvent.notify({connectionId:K.actor,event:K.event});break}case 102:{const J=O(K);J&&M.others.push(J);break}case 104:{M.others.push(C(K));break}case 200:{const J=new Map(e.offlineOperations);u(K,i),Ct(J,i),Ln==null||Ln(),a.storageDidLoad.notify();break}case 201:{b(K.ops,!1).updates.storageUpdates.forEach((ve,le)=>{M.storageUpdates.set(le,Nn(M.storageUpdates.get(le),ve))});break}}k(M,i)})}function fe(g){e.socket=null,clearTimeout(e.timeoutHandles.pongTimeout),clearInterval(e.intervalHandles.heartbeat),e.timeoutHandles.flush&&clearTimeout(e.timeoutHandles.flush),clearTimeout(e.timeoutHandles.reconnect),e.others.clearOthers(),s(()=>{if(k({others:[{type:"reset"}]},i),g.code>=4e3&&g.code<=4100){oe({state:"failed"},i);const L=new wo(g.reason,g.code);a.error.notify(L);const M=xe(!0);e.numberOfRetry++,oe({state:"unavailable"},i),e.timeoutHandles.reconnect=l.scheduleReconnect(M)}else if(g.code===4999)oe({state:"closed"},i);else{const L=xe();e.numberOfRetry++,oe({state:"unavailable"},i),e.timeoutHandles.reconnect=l.scheduleReconnect(L)}})}function oe(g,L){e.connection.set(g),L(()=>{a.connection.notify(g.state)})}function xe(g=!1){return g?Mn[e.numberOfRetry0&&g.forEach(K=>{e.offlineOperations.set(re(K.opId),K)}),e.socket===null||e.socket.readyState!==e.socket.OPEN){e.buffer.storageOperations=[];return}const L=Date.now();if(L-e.lastFlushTime>t.throttleDelay){const K=gs(e);if(K.length===0)return;l.send(K),e.buffer={messages:[],storageOperations:[],me:null},e.lastFlushTime=L}else e.timeoutHandles.flush!==null&&clearTimeout(e.timeoutHandles.flush),e.timeoutHandles.flush=l.delayFlush(t.throttleDelay-(L-e.lastFlushTime))}function gs(g){const L=[];g.buffer.me&&L.push(g.buffer.me.type==="full"?{type:100,targetActor:-1,data:g.buffer.me.data}:{type:100,data:g.buffer.me.data});for(const M of g.buffer.messages)L.push(M);return g.buffer.storageOperations.length>0&&L.push({type:201,ops:g.buffer.storageOperations}),L}function vs(){e.socket&&(e.socket.removeEventListener("open",Ie),e.socket.removeEventListener("message",ae),e.socket.removeEventListener("close",fe),e.socket.removeEventListener("error",ye),e.socket.close(),e.socket=null),s(()=>{oe({state:"closed"},i),e.timeoutHandles.flush&&clearTimeout(e.timeoutHandles.flush),clearTimeout(e.timeoutHandles.reconnect),clearTimeout(e.timeoutHandles.pongTimeout),clearInterval(e.intervalHandles.heartbeat),e.others.clearOthers(),k({others:[{type:"reset"}]},i),Object.values(a).forEach(g=>g.clear())})}function ys(){return e.me.current}function ws(){return e.others.current}function bs(g,L={shouldQueueEventIfNotReady:!1}){e.socket===null&&!L.shouldQueueEventIfNotReady||(e.buffer.messages.push({type:103,event:g}),De())}function kr(g){e.buffer.storageOperations.push(...g),De()}let Pn=null,Ln=null;function xr(){return Pn===null&&(e.buffer.messages.push({type:200}),De(),Pn=new Promise(g=>Ln=g)),Pn}function Es(){const g=e.root;return g!==void 0?g:(xr(),null)}function ks(){return cr(this,null,function*(){return e.root?Promise.resolve({root:e.root}):(yield xr(),{root:re(e.root)})})}function xs(){if(e.activeBatch)throw new Error("undo is not allowed during a batch");const g=e.undoStack.pop();if(g===void 0)return;e.pausedHistory=null;const L=b(g,!0);s(()=>{k(L.updates,i),e.redoStack.push(L.reverse),R(i)});for(const M of g)M.type!=="presence"&&e.buffer.storageOperations.push(M);De()}function Ir(){return e.undoStack.length>0}function Is(){if(e.activeBatch)throw new Error("redo is not allowed during a batch");const g=e.redoStack.pop();if(g===void 0)return;e.pausedHistory=null;const L=b(g,!0);s(()=>{k(L.updates,i),e.undoStack.push(L.reverse),R(i)});for(const M of g)M.type!=="presence"&&e.buffer.storageOperations.push(M);De()}function Or(){return e.redoStack.length>0}function Os(g){if(e.activeBatch)return g();let L;return s(()=>{e.activeBatch={ops:[],updates:{storageUpdates:new Map,presence:!1,others:[]},reverseOps:[]};try{L=g()}finally{const M=e.activeBatch;e.activeBatch=null,M.reverseOps.length>0&&x(M.reverseOps,i),M.ops.length>0&&(e.redoStack=[]),M.ops.length>0&&kr(M.ops),k(M.updates,i),De()}}),L}function As(){e.pausedHistory=[]}function Cs(){const g=e.pausedHistory;e.pausedHistory=null,g!==null&&g.length>0&&E(g,s)}function Ss(){e.socket&&(e.socket=null)}function Ps(g){fe(g)}return{onClose:fe,onMessage:ae,authenticationSuccess:Y,heartbeat:Ce,onNavigatorOnline:P,simulateSocketClose:Ss,simulateSendCloseEvent:Ps,onVisibilityChange:j,getUndoStack:()=>e.undoStack,getItemsCount:()=>e.nodes.size,connect:V,disconnect:vs,subscribe:A,updatePresence:T,broadcastEvent:bs,batch:Os,undo:xs,redo:Is,canUndo:Ir,canRedo:Or,pauseHistory:As,resumeHistory:Cs,getStorage:ks,getStorageSnapshot:Es,events:{customEvent:a.customEvent.observable,others:a.others.observable,me:a.me.observable,error:a.error.observable,connection:a.connection.observable,storage:a.storage.observable,history:a.history.observable,storageDidLoad:a.storageDidLoad.observable},getConnectionState:$,isSelfAware:()=>Jt(e.connection.current),getSelf:()=>c.current,getPresence:ys,getOthers:ws}}function vo(e,t){const n=new uo,r=new fo({state:"closed"});return{token:null,lastConnectionId:null,socket:null,numberOfRetry:0,lastFlushTime:0,timeoutHandles:{flush:null,reconnect:0,pongTimeout:0},buffer:{me:{type:"full",data:e},messages:[],storageOperations:[]},intervalHandles:{heartbeat:0},connection:r,me:new lo(e),others:n,initialStorage:t,idFactory:null,clock:0,opClock:0,nodes:new Map,root:void 0,undoStack:[],redoStack:[],pausedHistory:null,activeBatch:null,offlineOperations:new Map}}function yo(e,t){const{initialPresence:n,initialStorage:r}=e,i=vo(typeof n=="function"?n(t.roomId):n,typeof r=="function"?r(t.roomId):r),s=go(i,t),o={id:t.roomId,getConnectionState:s.getConnectionState,isSelfAware:s.isSelfAware,getSelf:s.getSelf,subscribe:s.subscribe,getPresence:s.getPresence,updatePresence:s.updatePresence,getOthers:s.getOthers,broadcastEvent:s.broadcastEvent,getStorage:s.getStorage,getStorageSnapshot:s.getStorageSnapshot,events:s.events,batch:s.batch,history:{undo:s.undo,redo:s.redo,canUndo:s.canUndo,canRedo:s.canRedo,pause:s.pauseHistory,resume:s.resumeHistory},__INTERNAL_DO_NOT_USE:{simulateCloseWebsocket:s.simulateSocketClose,simulateSendCloseEvent:s.simulateSendCloseEvent}};return{connect:s.connect,disconnect:s.disconnect,onNavigatorOnline:s.onNavigatorOnline,onVisibilityChange:s.onVisibilityChange,room:o}}var wo=class extends Error{constructor(e,t){super(e),this.code=t}};function bo(e,t){if(typeof window>"u"&&t===void 0)throw new Error("To use Liveblocks client in a non-dom environment, you need to provide a WebSocket polyfill.");const n=t||WebSocket;return r=>new n(`${e}/?token=${r}&version=0.18.5`)}function Eo(e,t){if(e.type==="public"){if(typeof window>"u"&&t===void 0)throw new Error("To use Liveblocks client in a non-dom environment with a publicApiKey, you need to provide a fetch polyfill.");return n=>Tr(t||fetch,e.url,{room:n,publicApiKey:e.publicApiKey})}if(e.type==="private"){if(typeof window>"u"&&t===void 0)throw new Error("To use Liveblocks client in a non-dom environment with a url as auth endpoint, you need to provide a fetch polyfill.");return n=>Tr(t||fetch,e.url,{room:n})}if(e.type==="custom")return n=>cr(this,null,function*(){const r=yield e.callback(n);if(!r||!r.token)throw new Error('Authentication error. We expect the authentication callback to return a token, but it does not. Hint: the return value should look like: { token: "..." }');return r});throw new Error("Internal error. Unexpected authentication type")}function Tr(e,t,n){return cr(this,null,function*(){const r=yield e(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Dn(`Expected a status 200 but got ${r.status} when doing a POST request on "${t}"`);let i;try{i=yield r.json()}catch(o){throw new Dn(`Expected a JSON response when doing a POST request on "${t}". ${o}`)}if(!st(i)||typeof i.token!="string")throw new Dn(`Expected a JSON response of the form \`{ token: "..." }\` when doing a POST request on "${t}", but got ${JSON.stringify(i)}`);const{token:s}=i;return{token:s}})}var Dn=class extends Error{constructor(e){super(e)}};function ko(e){const t=e,n=xo(e),r=new Map;function i(a){const l=r.get(a);return l?l.room:null}function s(a,l){var c,u;const d=l.shouldInitiallyConnect===void 0?!0:l.shouldInitiallyConnect;let h=r.get(a);if(h)return h.room;if(l.initialPresence===null||l.initialPresence,h=yo({initialPresence:(c=l.initialPresence)!=null?c:{},initialStorage:l.initialStorage},{roomId:a,throttleDelay:n,polyfills:t.polyfills,WebSocketPolyfill:t.WebSocketPolyfill,fetchPolyfill:t.fetchPolyfill,unstable_batchedUpdates:l==null?void 0:l.unstable_batchedUpdates,liveblocksServer:(t==null?void 0:t.liveblocksServer)||"wss://api.liveblocks.io/v6",authentication:Io(t,a)}),r.set(a,h),d){if(typeof atob>"u"){if(((u=t.polyfills)==null?void 0:u.atob)===void 0)throw new Error("You need to polyfill atob to use the client in your environment. Please follow the instructions at https://liveblocks.io/docs/errors/liveblocks-client/atob-polyfill");Rs.atob=t.polyfills.atob}h.connect()}return h.room}function o(a){const l=r.get(a);l&&(l.disconnect(),r.delete(a))}return typeof window<"u"&&typeof window.addEventListener<"u"&&window.addEventListener("online",()=>{for(const[,a]of r)a.onNavigatorOnline()}),typeof document<"u"&&document.addEventListener("visibilitychange",()=>{for(const[,a]of r)a.onVisibilityChange(document.visibilityState)}),{getRoom:i,enter:s,leave:o}}function xo(e){if(e.throttle===void 0)return 100;if(typeof e.throttle!="number"||e.throttle<80||e.throttle>1e3)throw new Error("throttle should be a number between 80 and 1000.");return e.throttle}function Io(e,t){const{publicApiKey:n,authEndpoint:r}=e;if(r!==void 0&&n!==void 0)throw new Error("You cannot use both publicApiKey and authEndpoint. Please use either publicApiKey or authEndpoint, but not both. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClient");if(typeof n=="string"){if(n.startsWith("sk_"))throw new Error("Invalid publicApiKey. You are using the secret key which is not supported. Please use the public key instead. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientPublicKey");if(!n.startsWith("pk_"))throw new Error("Invalid key. Please use the public key format: pk_. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientPublicKey");return{type:"public",publicApiKey:n,url:Oo(e,t)}}if(typeof r=="string")return{type:"private",url:r};if(typeof r=="function")return{type:"custom",callback:r};throw r!==void 0?new Error("authEndpoint must be a string or a function. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientAuthEndpoint"):new Error("Invalid Liveblocks client options. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClient")}function Oo(e,t){return e.publicAuthorizeEndpoint?e.publicAuthorizeEndpoint.replace("{roomId}",t):`https://api.liveblocks.io/v2/rooms/${encodeURIComponent(t)}/public/authorize`}function Di(e){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=Ue(r))}return t}function Ao(e){return Di(e.toObject())}function Co(e){const t={};for(const[n,r]of e.entries())t[n]=Ue(r);return t}function Ui(e){return e.map(Ue)}function So(e){return Ui(e.toArray())}function Ue(e){return e instanceof Ke?Ao(e):e instanceof Ze?So(e):e instanceof lt?Co(e):e instanceof at?e.data:Array.isArray(e)?Ui(e):st(e)?Di(e):e}function dt(e){if(Array.isArray(e))return new Ze(e.map(dt));if(st(e)){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=dt(r))}return new Ke(t)}else return e}function Po(e,t,n){let r=0,i=t.length-1,s=n.length-1,o=t[0],a=n[0];e:{for(;o===a;){if(++r,r>i||r>s)break e;o=t[r],a=n[r]}for(o=t[i],a=n[s];o===a;){if(i--,s--,r>i||r>s)break e;o=t[i],a=n[s]}}if(r>i){if(r<=s)for(;r<=s;)e.insert(dt(n[r]),r),r++}else if(r>s){let l=r;for(;l<=i;)e.delete(r),l++}else{for(;r<=i&&r<=s;){o=t[r],a=n[r];const c=e.get(r);fr(c)&&st(o)&&st(a)?zi(c,o,a):e.set(r,dt(a)),r++}for(;r<=s;)e.insert(dt(n[r]),r),r++;let l=r;for(;l<=i;)e.delete(r),l++}}function Hi(e,t,n,r){const i=e.get(t);if(r===void 0)e.delete(t);else if(i===void 0)e.set(t,dt(r));else{if(n===r)return;bn(i)&&Array.isArray(n)&&Array.isArray(r)?Po(i,n,r):fr(i)&&st(n)&&st(r)?zi(i,n,r):e.set(t,dt(r))}}function zi(e,t,n){const r={};for(const i in n)Hi(e,i,t[i],n[i]);for(const i in t)n[i]===void 0&&e.delete(i);Object.keys(r).length>0&&e.update(r)}function Lo(e){const t=[];for(;e.parent.type==="HasParent";)bn(e.parent.node)?t.push(e.parent.node._indexOfPosition(e.parent.key)):t.push(e.parent.key),e=e.parent.node;return t}function To(e,t){return t.reduce((n,r)=>$o(n,r),e)}function $o(e,t){const n=Lo(t.node);return Fn(e,n,t)}function Fn(e,t,n){var r,i,s,o;const a=t.pop();if(a===void 0)switch(n.type){case"LiveObject":{if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("Internal: received update on LiveObject but state was not an object");const l=Object.assign({},e);for(const c in n.updates)if(((r=n.updates[c])==null?void 0:r.type)==="update"){const u=n.node.get(c);u!==void 0&&(l[c]=Ue(u))}else((i=n.updates[c])==null?void 0:i.type)==="delete"&&delete l[c];return l}case"LiveList":{if(!Array.isArray(e))throw new Error("Internal: received update on LiveList but state was not an array");let l=e.map(c=>c);for(const c of n.updates)c.type==="set"?l=l.map((u,d)=>d===c.index?Ue(c.item):u):c.type==="insert"?c.index===l.length?l.push(Ue(c.item)):l=[...l.slice(0,c.index),Ue(c.item),...l.slice(c.index)]:c.type==="delete"?l.splice(c.index,1):c.type==="move"&&(c.previousIndex>c.index?l=[...l.slice(0,c.index),Ue(c.item),...l.slice(c.index,c.previousIndex),...l.slice(c.previousIndex+1)]:l=[...l.slice(0,c.previousIndex),...l.slice(c.previousIndex+1,c.index+1),Ue(c.item),...l.slice(c.index+1)]);return l}case"LiveMap":{if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("Internal: received update on LiveMap but state was not an object");const l=Object.assign({},e);for(const c in n.updates)if(((s=n.updates[c])==null?void 0:s.type)==="update"){const u=n.node.get(c);u!==void 0&&(l[c]=Ue(u))}else((o=n.updates[c])==null?void 0:o.type)==="delete"&&delete l[c];return l}}if(Array.isArray(e)){const l=[...e];return l[a]=Fn(e[a],t,n),l}else if(e!==null&&typeof e=="object"){const l=e[a];return l===void 0?e:Ot(it({},e),{[a]:Fn(l,t,n)})}else return e}function No(e,t){if(e.length!==t.length)return!1;for(let n=0;nObject.prototype.hasOwnProperty.call(t,r)&&Object.is(e[r],t[r]))}function Mo(e,t){if(Object.is(e,t))return!0;const n=Array.isArray(e),r=Array.isArray(t);return n||r?!n||!r?!1:No(e,t):Ro(e,t)}F.ClientMsgCode=gi;F.CrdtType=yi;F.LiveList=Ze;F.LiveMap=lt;F.LiveObject=Ke;F.OpCode=vi;F.ServerMsgCode=Ei;F.WebsocketCloseCodes=ki;F.asArrayWithLegacyMethods=Ni;F.assertNever=tt;F.b64decode=Pi;F.comparePosition=Ii;F.createClient=ko;F.deprecate=io;F.deprecateIf=so;F.errorIf=ao;F.freeze=ze;F.isAppOnlyAuthToken=Ti;F.isAuthToken=no;F.isChildCrdt=bi;F.isJsonArray=pr;F.isJsonObject=Mi;F.isJsonScalar=Ri;F.isPlainObject=st;F.isRoomAuthToken=dr;F.isRootCrdt=wi;F.legacy_patchImmutableObject=To;F.lsonToJson=Ue;F.makePosition=Xe;F.nn=re;F.patchLiveObjectKey=Hi;F.shallow=Mo;F.throwUsageError=oo;F.tryParseJson=hr;const Do=F.ClientMsgCode,Uo=F.CrdtType,Ho=F.LiveList,zo=F.LiveMap,Vo=F.LiveObject,Bo=F.OpCode,Ko=F.ServerMsgCode,Fo=F.WebsocketCloseCodes,jo=F.asArrayWithLegacyMethods,Xo=F.assertNever,Yo=F.b64decode,Jo=F.comparePosition,Zo=F.createClient,Wo=F.deprecate,qo=F.deprecateIf,Go=F.errorIf,Qo=F.freeze,ea=F.isAppOnlyAuthToken,ta=F.isAuthToken,na=F.isChildCrdt,ra=F.isJsonArray,ia=F.isJsonObject,sa=F.isJsonScalar,oa=F.isPlainObject,aa=F.isRoomAuthToken,la=F.isRootCrdt,ca=F.legacy_patchImmutableObject,ua=F.lsonToJson,fa=F.makePosition,ha=F.nn,da=F.patchLiveObjectKey,pa=F.shallow,ma=F.throwUsageError,_a=F.tryParseJson,ga=Object.freeze(Object.defineProperty({__proto__:null,default:F,ClientMsgCode:Do,CrdtType:Uo,LiveList:Ho,LiveMap:zo,LiveObject:Vo,OpCode:Bo,ServerMsgCode:Ko,WebsocketCloseCodes:Fo,asArrayWithLegacyMethods:jo,assertNever:Xo,b64decode:Yo,comparePosition:Jo,createClient:Zo,deprecate:Wo,deprecateIf:qo,errorIf:Go,freeze:Qo,isAppOnlyAuthToken:ea,isAuthToken:ta,isChildCrdt:na,isJsonArray:ra,isJsonObject:ia,isJsonScalar:sa,isPlainObject:oa,isRoomAuthToken:aa,isRootCrdt:la,legacy_patchImmutableObject:ca,lsonToJson:ua,makePosition:fa,nn:ha,patchLiveObjectKey:da,shallow:pa,throwUsageError:ma,tryParseJson:_a},Symbol.toStringTag,{value:"Module"})),va=Ms(ga);Object.defineProperty(Be,"__esModule",{value:!0});var Ft=va;Be.LiveList=Ft.LiveList;Be.LiveMap=Ft.LiveMap;Be.LiveObject=Ft.LiveObject;Be.createClient=Ft.createClient;Be.shallow=Ft.shallow;Be.LiveList;Be.LiveMap;const ya=Be.LiveObject,wa=Be.createClient;Be.shallow;const Vi=Symbol(),Bi=Symbol();function ba(e){let t;const n=e[2].default,r=tr(n,e,e[1],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,s){r&&r.m(i,s),t=!0},p(i,[s]){r&&r.p&&(!t||s&2)&&nr(r,n,i,i[1],t?ir(n,i[1],s,null):rr(i[1]),null)},i(i){t||(X(r,i),t=!0)},o(i){W(r,i),t=!1},d(i){r&&r.d(i)}}}function Ea(e,t,n){let{$$slots:r={},$$scope:i}=t,{client:s}=t;if(!s)throw new Error("LiveblocksProvider requires a client");return di(Vi,s),e.$$set=o=>{"client"in o&&n(0,s=o.client),"$$scope"in o&&n(1,i=o.$$scope)},[s,i,r]}class ka extends be{constructor(t){super(),Ee(this,t,Ea,ba,ke,{client:0})}}function xa(e){let t;const n=e[3].default,r=tr(n,e,e[2],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,s){r&&r.m(i,s),t=!0},p(i,[s]){r&&r.p&&(!t||s&4)&&nr(r,n,i,i[2],t?ir(n,i[2],s,null):rr(i[2]),null)},i(i){t||(X(r,i),t=!0)},o(i){W(r,i),t=!1},d(i){r&&r.d(i)}}}function Ia(e,t,n){let{$$slots:r={},$$scope:i}=t,{id:s}=t,{initialPresence:o={}}=t;if(!s)throw new Error("RoomProvider requires an id");const a=pi(Vi);if(a){const l=a.enter(s,{initialPresence:o});di(Bi,l),Bt(()=>{a.leave(s)})}return e.$$set=l=>{"id"in l&&n(0,s=l.id),"initialPresence"in l&&n(1,o=l.initialPresence),"$$scope"in l&&n(2,i=l.$$scope)},[s,o,i,r]}class Oa extends be{constructor(t){super(),Ee(this,t,Ia,xa,ke,{id:0,initialPresence:1})}}function Aa(e){let t,n,r;return{c(){t=Q("svg"),n=Q("circle"),r=Q("path"),this.h()},l(i){t=ee(i,"svg",{class:!0,xmlns:!0,"xmlns:xlink":!0,"aria-hidden":!0,fill:!0,focusable:!0,role:!0,width:!0,height:!0,preserveAspectRatio:!0,viewBox:!0});var s=I(t);n=ee(s,"circle",{class:!0,cx:!0,cy:!0,r:!0,stroke:!0,"stroke-width":!0}),I(n).forEach(v),r=ee(s,"path",{fill:!0,d:!0}),I(r).forEach(v),s.forEach(v),this.h()},h(){f(n,"class","opacity-50"),f(n,"cx","12"),f(n,"cy","12"),f(n,"r","10"),f(n,"stroke","currentColor"),f(n,"stroke-width","4"),f(r,"fill","currentColor"),f(r,"d","M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"),f(t,"class",e[0]),f(t,"xmlns","http://www.w3.org/2000/svg"),f(t,"xmlns:xlink","http://www.w3.org/1999/xlink"),f(t,"aria-hidden","true"),f(t,"fill","none"),f(t,"focusable","false"),f(t,"role","img"),f(t,"width","1em"),f(t,"height","1em"),f(t,"preserveAspectRatio","xMidYMid meet"),f(t,"viewBox","0 0 24 24")},m(i,s){ne(i,t,s),m(t,n),m(t,r)},p(i,[s]){s&1&&f(t,"class",i[0])},i:ue,o:ue,d(i){i&&v(t)}}}function Ca(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class kn extends be{constructor(t){super(),Ee(this,t,Ca,Aa,ke,{classList:0})}}function Sa(e){let t,n,r;return{c(){t=Q("svg"),n=Q("path"),r=Q("path"),this.h()},l(i){t=ee(i,"svg",{class:!0,width:!0,height:!0,viewBox:!0,xmlns:!0});var s=I(t);n=ee(s,"path",{d:!0,fill:!0}),I(n).forEach(v),r=ee(s,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0,"fill-opacity":!0}),I(r).forEach(v),s.forEach(v),this.h()},h(){f(n,"d","M3.09022 1.77278C2.25499 1.40456 1.40358 2.25597 1.7718 3.0912L4.57875 9.45818C4.95365 10.3086 6.18455 10.2323 6.4516 9.34213L6.9637 7.63515C7.06029 7.31317 7.31219 7.06126 7.63417 6.96467L9.34117 6.45258C10.2313 6.18552 10.3076 4.95463 9.45722 4.57972L3.09022 1.77278Z"),f(n,"fill",e[1]),f(r,"fill-rule","evenodd"),f(r,"clip-rule","evenodd"),f(r,"d","M3.66305 9.86091L0.856101 3.49392C0.119663 1.82347 1.82248 0.120639 3.49294 0.857077L9.85994 3.66402C11.5607 4.41383 11.4082 6.87562 9.62784 7.40973L7.92085 7.92182L7.40875 9.62881C6.87465 11.4092 4.41286 11.5617 3.66305 9.86091ZM1.77113 3.09053C1.40291 2.2553 2.25432 1.40388 3.08955 1.7721L9.45654 4.57905C10.3069 4.95395 10.2307 6.18485 9.34049 6.4519L7.6335 6.964C7.31152 7.06059 7.05961 7.3125 6.96302 7.63448L6.45093 9.34146C6.18387 10.2316 4.95298 10.3079 4.57807 9.45751L1.77113 3.09053Z"),f(r,"fill","white"),f(r,"fill-opacity","0.8"),f(t,"class",e[0]),f(t,"width","1em"),f(t,"height","1em"),f(t,"viewBox","0 0 12 12"),f(t,"xmlns","http://www.w3.org/2000/svg")},m(i,s){ne(i,t,s),m(t,n),m(t,r)},p(i,[s]){s&2&&f(n,"fill",i[1]),s&1&&f(t,"class",i[0])},i:ue,o:ue,d(i){i&&v(t)}}}function Pa(e,t,n){let{classList:r=""}=t,{fill:i=""}=t;return e.$$set=s=>{"classList"in s&&n(0,r=s.classList),"fill"in s&&n(1,i=s.fill)},[r,i]}class La extends be{constructor(t){super(),Ee(this,t,Pa,Sa,ke,{classList:0,fill:1})}}function Ta(e){let t,n,r,i;return n=new La({props:{classList:"block z-0 col-span-2 row-span-2 text-8xl",fill:e[1]}}),{c(){t=D("div"),pe(n.$$.fragment),this.h()},l(s){t=U(s,"DIV",{class:!0,style:!0});var o=I(t);me(n.$$.fragment,o),o.forEach(v),this.h()},h(){f(t,"class","cursor text-4xl svelte-14ka0w3"),f(t,"style",r=`transform: translateX(${e[2].x}px) translateY(${e[2].y}px) scale(${e[0].k});`)},m(s,o){ne(s,t,o),_e(n,t,null),i=!0},p(s,[o]){const a={};o&2&&(a.fill=s[1]),n.$set(a),(!i||o&5&&r!==(r=`transform: translateX(${s[2].x}px) translateY(${s[2].y}px) scale(${s[0].k});`))&&f(t,"style",r)},i(s){i||(X(n.$$.fragment,s),i=!0)},o(s){W(n.$$.fragment,s),i=!1},d(s){s&&v(t),ge(n)}}}function $a(e,t,n){let r,{transform:i}=t,{color:s=""}=t,{position:o={x:0,y:0}}=t;return e.$$set=a=>{"transform"in a&&n(0,i=a.transform),"color"in a&&n(1,s=a.color),"position"in a&&n(3,o=a.position)},e.$$.update=()=>{e.$$.dirty&9&&n(2,r={x:i.applyX(o.x),y:i.applyY(o.y)})},[i,s,r,o]}class Na extends be{constructor(t){super(),Ee(this,t,$a,Ta,ke,{transform:0,color:1,position:3})}}const Zt=["#505669","#414AA6","#1C5B92","#216B44","#893301","#912728","#98184D","#743095","#5F4199","#8f3f94"],Rt=20,gt={width:512*6,height:512*6},$e=32,he=512;function Ra(e){let t,n;return{c(){t=D("p"),n=q("Someone is typing:"),this.h()},l(r){t=U(r,"P",{class:!0});var i=I(t);n=G(i,"Someone is typing:"),i.forEach(v),this.h()},h(){f(t,"class","text-4xl")},m(r,i){ne(r,t,i),m(t,n)},i:ue,o:ue,d(r){r&&v(t)}}}function Ma(e){let t,n,r,i,s;return t=new kn({props:{classList:"animate-spin text-4xl inline mr-2 mx-auto text-white mb-4"}}),{c(){pe(t.$$.fragment),n=ie(),r=D("p"),i=q("Someone is painting:"),this.h()},l(o){me(t.$$.fragment,o),n=se(o),r=U(o,"P",{class:!0});var a=I(r);i=G(a,"Someone is painting:"),a.forEach(v),this.h()},h(){f(r,"class","text-4xl")},m(o,a){_e(t,o,a),ne(o,n,a),ne(o,r,a),m(r,i),s=!0},i(o){s||(X(t.$$.fragment,o),s=!0)},o(o){W(t.$$.fragment,o),s=!1},d(o){ge(t,o),o&&v(n),o&&v(r)}}}function Da(e){let t,n,r,i,s,o,a,l,c,u,d,h;const p=[Ma,Ra],E=[];function x(k,_){return k[2]?0:1}return i=x(e),s=E[i]=p[i](e),{c(){t=D("div"),n=D("div"),r=D("div"),s.c(),o=ie(),a=D("span"),l=q('"'),c=q(e[1]),u=q('"'),this.h()},l(k){t=U(k,"DIV",{class:!0,style:!0});var _=I(t);n=U(_,"DIV",{class:!0});var b=I(n);r=U(b,"DIV",{class:!0});var S=I(r);s.l(S),o=se(S),a=U(S,"SPAN",{class:!0});var w=I(a);l=G(w,'"'),c=G(w,e[1]),u=G(w,'"'),w.forEach(v),S.forEach(v),b.forEach(v),_.forEach(v),this.h()},h(){f(a,"class","italic font-normal"),f(r,"class","font-bold !text-4xl text-white rounded-2xl text-center p-10 line-clamp-4 flex"),f(n,"class","pointer-events-none touch-none"),f(t,"class","absolute top-0 left-0 border-8 border-dashed border-black flex items-center justify-center bg-black/60"),f(t,"style",d=`width: ${he}px; height: ${he}px; transform: translateX(${e[3].x}px) translateY(${e[3].y}px) scale(${e[0].k}); transform-origin: 0 0;`)},m(k,_){ne(k,t,_),m(t,n),m(n,r),E[i].m(r,null),m(r,o),m(r,a),m(a,l),m(a,c),m(a,u),h=!0},p(k,[_]){let b=i;i=x(k),i!==b&&(Le(),W(E[b],1,1,()=>{E[b]=null}),Te(),s=E[i],s||(s=E[i]=p[i](k),s.c()),X(s,1),s.m(r,o)),(!h||_&2)&&rt(c,k[1]),(!h||_&9&&d!==(d=`width: ${he}px; height: ${he}px; transform: translateX(${k[3].x}px) translateY(${k[3].y}px) scale(${k[0].k}); transform-origin: 0 0;`))&&f(t,"style",d)},i(k){h||(X(s),h=!0)},o(k){W(s),h=!1},d(k){k&&v(t),E[i].d()}}}function Ua(e,t,n){let r,{transform:i}=t,{position:s={x:0,y:0}}=t,{prompt:o=""}=t,{isLoading:a=!1}=t;return e.$$set=l=>{"transform"in l&&n(0,i=l.transform),"position"in l&&n(4,s=l.position),"prompt"in l&&n(1,o=l.prompt),"isLoading"in l&&n(2,a=l.isLoading)},e.$$.update=()=>{e.$$.dirty&17&&n(3,r={x:i.applyX(s.x),y:i.applyY(s.y)})},[i,o,a,r,s]}class Ha extends be{constructor(t){super(),Ee(this,t,Ua,Da,ke,{transform:0,position:4,prompt:1,isLoading:2})}}var za={value:()=>{}};function xn(){for(var e=0,t=arguments.length,n={},r;e=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}rn.prototype=xn.prototype={constructor:rn,on:function(e,t){var n=this._,r=Va(e+"",n),i,s=-1,o=r.length;if(arguments.length<2){for(;++s0)for(var n=new Array(i),r=0,i,s;r=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Nr.hasOwnProperty(t)?{space:Nr[t],local:e}:e}function Ka(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===jn&&t.documentElement.namespaceURI===jn?t.createElement(e):t.createElementNS(n,e)}}function Fa(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ki(e){var t=In(e);return(t.local?Fa:Ka)(t)}function ja(){}function mr(e){return e==null?ja:function(){return this.querySelector(e)}}function Xa(e){typeof e!="function"&&(e=mr(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i=S&&(S=b+1);!(N=k[S])&&++S=0;)(o=r[i])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function gl(e){e||(e=vl);function t(d,h){return d&&h?e(d.__data__,h.__data__):!d-!h}for(var n=this._groups,r=n.length,i=new Array(r),s=0;st?1:e>=t?0:NaN}function yl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function wl(){return Array.from(this)}function bl(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Tl:typeof t=="function"?Nl:$l)(e,t,n==null?"":n)):xt(this.node(),e)}function xt(e,t){return e.style.getPropertyValue(t)||Ji(e).getComputedStyle(e,null).getPropertyValue(t)}function Ml(e){return function(){delete this[e]}}function Dl(e,t){return function(){this[e]=t}}function Ul(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Hl(e,t){return arguments.length>1?this.each((t==null?Ml:typeof t=="function"?Ul:Dl)(e,t)):this.node()[e]}function Zi(e){return e.trim().split(/^|\s+/)}function _r(e){return e.classList||new Wi(e)}function Wi(e){this._node=e,this._names=Zi(e.getAttribute("class")||"")}Wi.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function qi(e,t){for(var n=_r(e),r=-1,i=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function dc(e){return function(){var t=this.__on;if(!!t){for(var n=0,r=-1,i=t.length,s;n()=>e;function Xn(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:s,x:o,y:a,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}Xn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function kc(e){return!e.ctrlKey&&!e.button}function xc(){return this.parentNode}function Ic(e,t){return t==null?{x:e.x,y:e.y}:t}function Oc(){return navigator.maxTouchPoints||"ontouchstart"in this}function Rr(){var e=kc,t=xc,n=Ic,r=Oc,i={},s=xn("start","drag","end"),o=0,a,l,c,u,d=0;function h(w){w.on("mousedown.drag",p).filter(r).on("touchstart.drag",k).on("touchmove.drag",_,Ec).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(w,N){if(!(u||!e.call(this,w,N))){var A=S(this,t.call(this,w,N),w,N,"mouse");!A||(Re(w.view).on("mousemove.drag",E,Mt).on("mouseup.drag",x,Mt),ts(w.view),Un(w),c=!1,a=w.clientX,l=w.clientY,A("start",w))}}function E(w){if(bt(w),!c){var N=w.clientX-a,A=w.clientY-l;c=N*N+A*A>d}i.mouse("drag",w)}function x(w){Re(w.view).on("mousemove.drag mouseup.drag",null),ns(w.view,c),bt(w),i.mouse("end",w)}function k(w,N){if(!!e.call(this,w,N)){var A=w.changedTouches,$=t.call(this,w,N),V=A.length,T,H;for(T=0;T{const n=new Image;n.onload=async()=>{const r=n.width,i=n.height,s=document.createElement("canvas");s.width=r,s.height=i,s.getContext("2d").drawImage(n,0,0,r,i);const a=await new Promise(l=>s.toBlob(l,"image/jpeg",.95));t(a)},n.src=e})}async function Pc(e,t,n){const r=Tc(t),s=`color-palette-${crypto.randomUUID().split("-")[0]}-${r}-${n}.jpeg`,o=new File([e],s,{type:"image/jpeg"}),a=new FormData;return a.append("file",o),await(await fetch(hn+"/uploadfile",{method:"POST",body:a})).json()}const Lc=gt.width-he;function qt(e){const t=e%$e<$e/2?e-e%$e:e+$e-e%$e;return Math.max(0,Math.min(Math.round(t),Lc))}function Tc(e){return e?e.toString().toLowerCase().replace(/\s+/g,"-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,""):""}function On(){const e=pi(Bi);if(!e)throw new Error("Use RoomProvider as parent with id prop");return e}function An(){const e=On(),{subscribe:t,set:n}=Ve();function r(s){e.updatePresence(s)}const i=e.subscribe("my-presence",s=>{n(s)});return Bt(()=>{i()}),{subscribe:t,update:r}}function $c(){const e=On(),t=Ve(),n=e.subscribe("others",r=>{t.set(r)});return Bt(n),t}function Nc(){const e=On(),t=Ve();async function n(){const{root:r}=await e.getStorage();t.set(r)}return n(),t}function rs(e,t){const n=On(),r=Nc(),i=Ve();let s=()=>{};const o=r.subscribe(a=>{!a||(a.get(e)||a.set(e,new ya(t)),i.set(a.get(e)),s(),s=n.subscribe(a.get(e),l=>{i.set(l)}))});return Bt(o),i}const Rc=3e3;function Mc(){const e=Ve([]),t=setInterval(()=>{Dc().then(n=>e.set(n))},Rc);return Bt(()=>{clearInterval(t)}),e}async function Dc(){return fetch(hn+"/rooms").then(e=>e.json())}function gr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function is(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Xt(){}var Dt=.7,dn=1/Dt,Et="\\s*([+-]?\\d+)\\s*",Ut="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Je="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Uc=/^#([0-9a-f]{3,8})$/,Hc=new RegExp(`^rgb\\(${Et},${Et},${Et}\\)$`),zc=new RegExp(`^rgb\\(${Je},${Je},${Je}\\)$`),Vc=new RegExp(`^rgba\\(${Et},${Et},${Et},${Ut}\\)$`),Bc=new RegExp(`^rgba\\(${Je},${Je},${Je},${Ut}\\)$`),Kc=new RegExp(`^hsl\\(${Ut},${Je},${Je}\\)$`),Fc=new RegExp(`^hsla\\(${Ut},${Je},${Je},${Ut}\\)$`),Mr={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};gr(Xt,Ht,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Dr,formatHex:Dr,formatHex8:jc,formatHsl:Xc,formatRgb:Ur,toString:Ur});function Dr(){return this.rgb().formatHex()}function jc(){return this.rgb().formatHex8()}function Xc(){return ss(this).formatHsl()}function Ur(){return this.rgb().formatRgb()}function Ht(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Uc.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Hr(t):n===3?new Pe(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Gt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Gt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Hc.exec(e))?new Pe(t[1],t[2],t[3],1):(t=zc.exec(e))?new Pe(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Vc.exec(e))?Gt(t[1],t[2],t[3],t[4]):(t=Bc.exec(e))?Gt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Kc.exec(e))?Br(t[1],t[2]/100,t[3]/100,1):(t=Fc.exec(e))?Br(t[1],t[2]/100,t[3]/100,t[4]):Mr.hasOwnProperty(e)?Hr(Mr[e]):e==="transparent"?new Pe(NaN,NaN,NaN,0):null}function Hr(e){return new Pe(e>>16&255,e>>8&255,e&255,1)}function Gt(e,t,n,r){return r<=0&&(e=t=n=NaN),new Pe(e,t,n,r)}function Yc(e){return e instanceof Xt||(e=Ht(e)),e?(e=e.rgb(),new Pe(e.r,e.g,e.b,e.opacity)):new Pe}function Yn(e,t,n,r){return arguments.length===1?Yc(e):new Pe(e,t,n,r==null?1:r)}function Pe(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}gr(Pe,Yn,is(Xt,{brighter(e){return e=e==null?dn:Math.pow(dn,e),new Pe(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Dt:Math.pow(Dt,e),new Pe(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Pe(pt(this.r),pt(this.g),pt(this.b),pn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:zr,formatHex:zr,formatHex8:Jc,formatRgb:Vr,toString:Vr}));function zr(){return`#${ft(this.r)}${ft(this.g)}${ft(this.b)}`}function Jc(){return`#${ft(this.r)}${ft(this.g)}${ft(this.b)}${ft((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vr(){const e=pn(this.opacity);return`${e===1?"rgb(":"rgba("}${pt(this.r)}, ${pt(this.g)}, ${pt(this.b)}${e===1?")":`, ${e})`}`}function pn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function pt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ft(e){return e=pt(e),(e<16?"0":"")+e.toString(16)}function Br(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new He(e,t,n,r)}function ss(e){if(e instanceof He)return new He(e.h,e.s,e.l,e.opacity);if(e instanceof Xt||(e=Ht(e)),!e)return new He;if(e instanceof He)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),s=Math.max(t,n,r),o=NaN,a=s-i,l=(s+i)/2;return a?(t===s?o=(n-r)/a+(n0&&l<1?0:o,new He(o,a,l,e.opacity)}function Zc(e,t,n,r){return arguments.length===1?ss(e):new He(e,t,n,r==null?1:r)}function He(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}gr(He,Zc,is(Xt,{brighter(e){return e=e==null?dn:Math.pow(dn,e),new He(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Dt:Math.pow(Dt,e),new He(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new Pe(Hn(e>=240?e-240:e+120,i,r),Hn(e,i,r),Hn(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new He(Kr(this.h),Qt(this.s),Qt(this.l),pn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=pn(this.opacity);return`${e===1?"hsl(":"hsla("}${Kr(this.h)}, ${Qt(this.s)*100}%, ${Qt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Kr(e){return e=(e||0)%360,e<0?e+360:e}function Qt(e){return Math.max(0,Math.min(1,e||0))}function Hn(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const os=e=>()=>e;function Wc(e,t){return function(n){return e+n*t}}function qc(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function Gc(e){return(e=+e)==1?as:function(t,n){return n-t?qc(t,n,e):os(isNaN(t)?n:t)}}function as(e,t){var n=t-e;return n?Wc(e,n):os(isNaN(e)?t:e)}const Fr=function e(t){var n=Gc(t);function r(i,s){var o=n((i=Yn(i)).r,(s=Yn(s)).r),a=n(i.g,s.g),l=n(i.b,s.b),c=as(i.opacity,s.opacity);return function(u){return i.r=o(u),i.g=a(u),i.b=l(u),i.opacity=c(u),i+""}}return r.gamma=e,r}(1);function ct(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Jn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,zn=new RegExp(Jn.source,"g");function Qc(e){return function(){return e}}function eu(e){return function(t){return e(t)+""}}function tu(e,t){var n=Jn.lastIndex=zn.lastIndex=0,r,i,s,o=-1,a=[],l=[];for(e=e+"",t=t+"";(r=Jn.exec(e))&&(i=zn.exec(t));)(s=i.index)>n&&(s=t.slice(n,s),a[o]?a[o]+=s:a[++o]=s),(r=r[0])===(i=i[0])?a[o]?a[o]+=i:a[++o]=i:(a[++o]=null,l.push({i:o,x:ct(r,i)})),n=zn.lastIndex;return n180?u+=360:u-c>180&&(c+=360),h.push({i:d.push(i(d)+"rotate(",null,r)-2,x:ct(c,u)})):u&&d.push(i(d)+"rotate("+u+r)}function a(c,u,d,h){c!==u?h.push({i:d.push(i(d)+"skewX(",null,r)-2,x:ct(c,u)}):u&&d.push(i(d)+"skewX("+u+r)}function l(c,u,d,h,p,E){if(c!==d||u!==h){var x=p.push(i(p)+"scale(",null,",",null,")");E.push({i:x-4,x:ct(c,d)},{i:x-2,x:ct(u,h)})}else(d!==1||h!==1)&&p.push(i(p)+"scale("+d+","+h+")")}return function(c,u){var d=[],h=[];return c=e(c),u=e(u),s(c.translateX,c.translateY,u.translateX,u.translateY,d,h),o(c.rotate,u.rotate,d,h),a(c.skewX,u.skewX,d,h),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,d,h),c=u=null,function(p){for(var E=-1,x=h.length,k;++E=0&&e._call.call(void 0,t),e=e._next;--It}function Yr(){vt=(_n=zt.now())+Cn,It=Tt=0;try{fu()}finally{It=0,du(),vt=0}}function hu(){var e=zt.now(),t=e-_n;t>us&&(Cn-=t,_n=e)}function du(){for(var e,t=mn,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:mn=n);$t=e,Wn(r)}function Wn(e){if(!It){Tt&&(Tt=clearTimeout(Tt));var t=e-vt;t>24?(e<1/0&&(Tt=setTimeout(Yr,e-zt.now()-Cn)),St&&(St=clearInterval(St))):(St||(_n=zt.now(),St=setInterval(hu,us)),It=1,fs(Yr))}}function Jr(e,t,n){var r=new gn;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var pu=xn("start","end","cancel","interrupt"),mu=[],ds=0,Zr=1,qn=2,sn=3,Wr=4,Gn=5,on=6;function Sn(e,t,n,r,i,s){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;_u(e,n,{name:t,index:r,group:i,on:pu,tween:mu,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:ds})}function yr(e,t){var n=Fe(e,t);if(n.state>ds)throw new Error("too late; already scheduled");return n}function We(e,t){var n=Fe(e,t);if(n.state>sn)throw new Error("too late; already running");return n}function Fe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function _u(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=hs(s,0,n.time);function s(c){n.state=Zr,n.timer.restart(o,n.delay,n.time),n.delay<=c&&o(c-n.delay)}function o(c){var u,d,h,p;if(n.state!==Zr)return l();for(u in r)if(p=r[u],p.name===n.name){if(p.state===sn)return Jr(o);p.state===Wr?(p.state=on,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete r[u]):+uqn&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function Xu(e,t,n){var r,i,s=ju(t)?yr:We;return function(){var o=s(this,e),a=o.on;a!==r&&(i=(r=a).copy()).on(t,n),o.on=i}}function Yu(e,t){var n=this._id;return arguments.length<2?Fe(this.node(),n).on.on(e):this.each(Xu(n,e,t))}function Ju(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Zu(){return this.on("end.remove",Ju(this._id))}function Wu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=mr(e));for(var r=this._groups,i=r.length,s=new Array(i),o=0;o()=>e;function Ef(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function nt(e,t,n){this.k=e,this.x=t,this.y=n}nt.prototype={constructor:nt,scale:function(e){return e===1?this:new nt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new nt(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Vt=new nt(1,0,0);nt.prototype;function Vn(e){e.stopImmediatePropagation()}function Pt(e){e.preventDefault(),e.stopImmediatePropagation()}function kf(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function xf(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function qr(){return this.__zoom||Vt}function If(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Of(){return navigator.maxTouchPoints||"ontouchstart"in this}function Af(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function Cf(){var e=kf,t=xf,n=Af,r=If,i=Of,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=cu,c=xn("start","zoom","end"),u,d,h,p=500,E=150,x=0,k=10;function _(y){y.property("__zoom",qr).on("wheel.zoom",V,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",H).filter(i).on("touchstart.zoom",Y).on("touchmove.zoom",Z).on("touchend.zoom touchcancel.zoom",j).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(y,O,C,P){var R=y.selection?y.selection():y;R.property("__zoom",qr),y!==R?N(y,O,C,P):R.interrupt().each(function(){A(this,arguments).event(P).start().zoom(null,typeof O=="function"?O.apply(this,arguments):O).end()})},_.scaleBy=function(y,O,C,P){_.scaleTo(y,function(){var R=this.__zoom.k,z=typeof O=="function"?O.apply(this,arguments):O;return R*z},C,P)},_.scaleTo=function(y,O,C,P){_.transform(y,function(){var R=t.apply(this,arguments),z=this.__zoom,B=C==null?w(R):typeof C=="function"?C.apply(this,arguments):C,te=z.invert(B),ae=typeof O=="function"?O.apply(this,arguments):O;return n(S(b(z,ae),B,te),R,o)},C,P)},_.translateBy=function(y,O,C,P){_.transform(y,function(){return n(this.__zoom.translate(typeof O=="function"?O.apply(this,arguments):O,typeof C=="function"?C.apply(this,arguments):C),t.apply(this,arguments),o)},null,P)},_.translateTo=function(y,O,C,P,R){_.transform(y,function(){var z=t.apply(this,arguments),B=this.__zoom,te=P==null?w(z):typeof P=="function"?P.apply(this,arguments):P;return n(Vt.translate(te[0],te[1]).scale(B.k).translate(typeof O=="function"?-O.apply(this,arguments):-O,typeof C=="function"?-C.apply(this,arguments):-C),z,o)},P,R)};function b(y,O){return O=Math.max(s[0],Math.min(s[1],O)),O===y.k?y:new nt(O,y.x,y.y)}function S(y,O,C){var P=O[0]-C[0]*y.k,R=O[1]-C[1]*y.k;return P===y.x&&R===y.y?y:new nt(y.k,P,R)}function w(y){return[(+y[0][0]+ +y[1][0])/2,(+y[0][1]+ +y[1][1])/2]}function N(y,O,C,P){y.on("start.zoom",function(){A(this,arguments).event(P).start()}).on("interrupt.zoom end.zoom",function(){A(this,arguments).event(P).end()}).tween("zoom",function(){var R=this,z=arguments,B=A(R,z).event(P),te=t.apply(R,z),ae=C==null?w(te):typeof C=="function"?C.apply(R,z):C,fe=Math.max(te[1][0]-te[0][0],te[1][1]-te[0][1]),oe=R.__zoom,xe=typeof O=="function"?O.apply(R,z):O,ye=l(oe.invert(ae).concat(fe/oe.k),xe.invert(ae).concat(fe/xe.k));return function(Ie){if(Ie===1)Ie=xe;else{var Ce=ye(Ie),qe=fe/Ce[2];Ie=new nt(qe,ae[0]-Ce[0]*qe,ae[1]-Ce[1]*qe)}B.zoom(null,Ie)}})}function A(y,O,C){return!C&&y.__zooming||new $(y,O)}function $(y,O){this.that=y,this.args=O,this.active=0,this.sourceEvent=null,this.extent=t.apply(y,O),this.taps=0}$.prototype={event:function(y){return y&&(this.sourceEvent=y),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(y,O){return this.mouse&&y!=="mouse"&&(this.mouse[1]=O.invert(this.mouse[0])),this.touch0&&y!=="touch"&&(this.touch0[1]=O.invert(this.touch0[0])),this.touch1&&y!=="touch"&&(this.touch1[1]=O.invert(this.touch1[0])),this.that.__zoom=O,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(y){var O=Re(this.that).datum();c.call(y,this.that,new Ef(y,{sourceEvent:this.sourceEvent,target:_,type:y,transform:this.that.__zoom,dispatch:c}),O)}};function V(y,...O){if(!e.apply(this,arguments))return;var C=A(this,O).event(y),P=this.__zoom,R=Math.max(s[0],Math.min(s[1],P.k*Math.pow(2,r.apply(this,arguments)))),z=et(y);if(C.wheel)(C.mouse[0][0]!==z[0]||C.mouse[0][1]!==z[1])&&(C.mouse[1]=P.invert(C.mouse[0]=z)),clearTimeout(C.wheel);else{if(P.k===R)return;C.mouse=[z,P.invert(z)],an(this),C.start()}Pt(y),C.wheel=setTimeout(B,E),C.zoom("mouse",n(S(b(P,R),C.mouse[0],C.mouse[1]),C.extent,o));function B(){C.wheel=null,C.end()}}function T(y,...O){if(h||!e.apply(this,arguments))return;var C=y.currentTarget,P=A(this,O,!0).event(y),R=Re(y.view).on("mousemove.zoom",ae,!0).on("mouseup.zoom",fe,!0),z=et(y,C),B=y.clientX,te=y.clientY;ts(y.view),Vn(y),P.mouse=[z,this.__zoom.invert(z)],an(this),P.start();function ae(oe){if(Pt(oe),!P.moved){var xe=oe.clientX-B,ye=oe.clientY-te;P.moved=xe*xe+ye*ye>x}P.event(oe).zoom("mouse",n(S(P.that.__zoom,P.mouse[0]=et(oe,C),P.mouse[1]),P.extent,o))}function fe(oe){R.on("mousemove.zoom mouseup.zoom",null),ns(oe.view,P.moved),Pt(oe),P.event(oe).end()}}function H(y,...O){if(!!e.apply(this,arguments)){var C=this.__zoom,P=et(y.changedTouches?y.changedTouches[0]:y,this),R=C.invert(P),z=C.k*(y.shiftKey?.5:2),B=n(S(b(C,z),P,R),t.apply(this,O),o);Pt(y),a>0?Re(this).transition().duration(a).call(N,B,P,y):Re(this).call(_.transform,B,P,y)}}function Y(y,...O){if(!!e.apply(this,arguments)){var C=y.touches,P=C.length,R=A(this,O,y.changedTouches.length===P).event(y),z,B,te,ae;for(Vn(y),B=0;B(e.ready="ready",e.loading="loading",e.prompting="prompting",e.processing="processing",e.dragging="dragging",e.masking="masking",e))(de||{});function Gr(e){let t,n;return t=new kn({props:{classList:"absolute inset-0 m-auto animate-spin text-6xl text-black"}}),{c(){pe(t.$$.fragment)},l(r){me(t.$$.fragment,r)},m(r,i){_e(t,r,i),n=!0},i(r){n||(X(t.$$.fragment,r),n=!0)},o(r){W(t.$$.fragment,r),n=!1},d(r){ge(t,r)}}}function Qr(e){let t,n;return{c(){t=D("div"),this.h()},l(r){t=U(r,"DIV",{class:!0}),I(t).forEach(v),this.h()},h(){f(t,"class",n="absolute inset-0 bg-gradient-to-t "+(e[4]?"from-blue-700/40":"from-blue-700/90")+" to-blue-500/10")},m(r,i){ne(r,t,i)},p(r,i){i&16&&n!==(n="absolute inset-0 bg-gradient-to-t "+(r[4]?"from-blue-700/40":"from-blue-700/90")+" to-blue-500/10")&&f(t,"class",n)},d(r){r&&v(t)}}}function ei(e){let t,n,r;return{c(){t=D("div"),n=D("div"),r=q(e[7]),this.h()},l(i){t=U(i,"DIV",{class:!0});var s=I(t);n=U(s,"DIV",{class:!0});var o=I(n);r=G(o,e[7]),o.forEach(v),s.forEach(v),this.h()},h(){f(n,"class","font-bold text-4xl text-[#387CFF] text-center px-2 line-clamp-4"),f(t,"class","pointer-events-none touch-none")},m(i,s){ne(i,t,s),m(t,n),m(n,r)},p(i,s){s&128&&rt(r,i[7])},d(i){i&&v(t)}}}function Sf(e){let t,n=e[1]?"\u{1F91A} Drag me":"\u{1F91A} Enable Drag",r;return{c(){t=D("span"),r=q(n),this.h()},l(i){t=U(i,"SPAN",{class:!0});var s=I(t);r=G(s,n),s.forEach(v),this.h()},h(){f(t,"class","select-none")},m(i,s){ne(i,t,s),m(t,r)},p(i,s){s&2&&n!==(n=i[1]?"\u{1F91A} Drag me":"\u{1F91A} Enable Drag")&&rt(r,n)},d(i){i&&v(t)}}}function Pf(e){let t,n,r,i,s,o=e[9]==="NFSW"&&ti();return{c(){t=D("div"),o&&o.c(),n=ie(),r=D("p"),i=q(e[9]),s=q("..."),this.h()},l(a){t=U(a,"DIV",{class:!0});var l=I(t);o&&o.l(l),n=se(l),r=U(l,"P",{});var c=I(r);i=G(c,e[9]),s=G(c,"..."),c.forEach(v),l.forEach(v),this.h()},h(){f(t,"class","")},m(a,l){ne(a,t,l),o&&o.m(t,null),m(t,n),m(t,r),m(r,i),m(r,s)},p(a,l){a[9]==="NFSW"?o||(o=ti(),o.c(),o.m(t,n)):o&&(o.d(1),o=null),l&512&&rt(i,a[9])},d(a){a&&v(t),o&&o.d()}}}function ti(e){let t,n,r,i,s;return{c(){t=D("h2"),n=q("NSFW Alert"),r=ie(),i=D("h3"),s=q("Possible NSFW result detected, please try again"),this.h()},l(o){t=U(o,"H2",{class:!0});var a=I(t);n=G(a,"NSFW Alert"),a.forEach(v),r=se(o),i=U(o,"H3",{class:!0});var l=I(i);s=G(l,"Possible NSFW result detected, please try again"),l.forEach(v),this.h()},h(){f(t,"class","text-red-500 text-2xl font-bold"),f(i,"class","text-red-500 text-lg")},m(o,a){ne(o,t,a),m(t,n),ne(o,r,a),ne(o,i,a),m(i,s)},d(o){o&&v(t),o&&v(r),o&&v(i)}}}function ni(e){let t,n,r,i,s,o,a,l,c;return{c(){t=D("div"),n=D("button"),r=q("\u{1F58D}"),i=ie(),s=D("button"),o=Q("svg"),a=Q("path"),this.h()},l(u){t=U(u,"DIV",{class:!0});var d=I(t);n=U(d,"BUTTON",{class:!0});var h=I(n);r=G(h,"\u{1F58D}"),h.forEach(v),i=se(d),s=U(d,"BUTTON",{class:!0});var p=I(s);o=ee(p,"svg",{class:!0,width:!0,height:!0,viewBox:!0});var E=I(o);a=ee(E,"path",{fill:!0,d:!0,color:!0}),I(a).forEach(v),E.forEach(v),p.forEach(v),d.forEach(v),this.h()},h(){f(n,"class","w-10 h-10 bg-blue-600 hover:saturate-150 shadow-2xl shadow-blue-500 rounded-lg flex items-center justify-center text-3xl"),f(a,"fill","currentColor"),f(a,"d","m65.453 10.826l-.053 5c3.073.034 6.144.549 9.059 1.52l1.58-4.744a34.758 34.758 0 0 0-10.586-1.776zm-5.365.352a35.131 35.131 0 0 0-10.26 3.119l2.17 4.506a30.166 30.166 0 0 1 8.799-2.674l-.71-4.951zm20.908 3.51l-2.283 4.447a30.131 30.131 0 0 1 7.447 5.394l3.522-3.549a35.101 35.101 0 0 0-8.686-6.293zM35 19.125c-19.3 0-35 15.7-35 35s15.7 35 35 35c8.934 0 17.087-3.374 23.275-8.904c.005 0 .01 0 .014.002c.065-.059.127-.121.191-.18l.125-.115a34.677 34.677 0 0 0 2.461-2.496c.083-.092.167-.183.248-.276c.399-.455.79-.919 1.165-1.394c-.482-.04-.961-.092-1.436-.155c-.318-.041-.632-.094-.947-.146c-.158-.026-.316-.046-.473-.074a29.93 29.93 0 0 1-1.383-.283a29.851 29.851 0 0 1-1.183-.301c-.065-.018-.13-.033-.194-.051C44.234 71.216 35 59.651 35 45.875a29.876 29.876 0 0 1 9.557-21.955c.162-.151.324-.302.49-.45c.249-.22.504-.436.76-.65c.158-.131.313-.266.474-.394c.415-.332.837-.656 1.27-.965a35.075 35.075 0 0 0-2.867-.965l-.03-.008c-.287-.082-.577-.155-.867-.23c-.215-.056-.43-.118-.646-.17c-.349-.084-.701-.155-1.053-.229c-.126-.026-.25-.057-.377-.082l-.002.002A34.83 34.83 0 0 0 35 19.125zm58.2 5.928l-4.028 2.967a30.012 30.012 0 0 1 4.252 8.15l4.736-1.606a34.98 34.98 0 0 0-4.96-9.511zm6.294 14.717l-4.924.87c.536 3.029.603 6.145.194 9.19l4.955.666c.48-3.562.4-7.19-.225-10.726zM93.8 54.338a30.198 30.198 0 0 1-3.936 8.314l4.143 2.801a35.162 35.162 0 0 0 4.586-9.695l-4.793-1.42zm-6.803 11.928a29.79 29.79 0 0 1-7.213 5.687l2.451 4.358a34.776 34.776 0 0 0 8.428-6.647l-3.666-3.398zm-11.394 7.638a30.155 30.155 0 0 1-9.002 1.887l.265 4.992a35.12 35.12 0 0 0 10.498-2.199l-1.761-4.68z"),f(a,"color","currentColor"),f(o,"class","text-white"),f(o,"width","1em"),f(o,"height","1em"),f(o,"viewBox","0 0 100 100"),f(s,"class","w-10 h-10 bg-blue-600 hover:saturate-150 shadow-2xl shadow-blue-500 rounded-lg flex items-center justify-center text-3xl"),f(t,"class","mx-4 flex flex-col gap-2")},m(u,d){ne(u,t,d),m(t,n),m(n,r),m(t,i),m(t,s),m(s,o),m(o,a),l||(c=[Me(n,"click",e[17]),Me(s,"click",e[13])],l=!0)},p:ue,d(u){u&&v(t),l=!1,or(c)}}}function Lf(e){var C;let t,n,r,i,s,o,a,l,c,u,d,h,p,E,x,k,_,b,S,w,N,A,$,V,T=e[5]&&Gr(),H=((C=e[2])==null?void 0:C.status)!=="masking"&&Qr(e),Y=e[7]&&ei(e);function Z(P,R){return P[9]!==""?Pf:Sf}let j=Z(e),y=j(e),O=!e[5]&&ni(e);return{c(){t=D("div"),n=D("div"),r=D("div"),T&&T.c(),i=ie(),H&&H.c(),s=ie(),o=D("canvas"),l=ie(),c=D("div"),Y&&Y.c(),u=ie(),d=D("div"),h=D("div"),y.c(),E=ie(),x=D("div"),O&&O.c(),b=ie(),S=D("div"),this.h()},l(P){t=U(P,"DIV",{});var R=I(t);n=U(R,"DIV",{class:!0,style:!0});var z=I(n);r=U(z,"DIV",{class:!0,style:!0});var B=I(r);T&&T.l(B),i=se(B),H&&H.l(B),s=se(B),o=U(B,"CANVAS",{class:!0,width:!0,height:!0}),I(o).forEach(v),l=se(B),c=U(B,"DIV",{class:!0});var te=I(c);Y&&Y.l(te),te.forEach(v),u=se(B),d=U(B,"DIV",{class:!0,style:!0});var ae=I(d);h=U(ae,"DIV",{class:!0});var fe=I(h);y.l(fe),fe.forEach(v),ae.forEach(v),E=se(B),x=U(B,"DIV",{class:!0,style:!0});var oe=I(x);O&&O.l(oe),oe.forEach(v),B.forEach(v),z.forEach(v),b=se(R),S=U(R,"DIV",{class:!0,style:!0}),I(S).forEach(v),R.forEach(v),this.h()},h(){f(o,"class",a=e[1]?"":"bg-white"),f(o,"width",he),f(o,"height",he),f(c,"class","pointer-events-none touch-none"),f(h,"class","pl-3 pr-5 py-1 bg-blue-700/90 text-white text-lg xl:text-2xl rounded-tr-xl font-medium tracking-wide cursor-pointer"),f(d,"class","absolute bottom-0 origin-bottom-left"),f(d,"style",p=`transform: scale(${Math.max(2.5-e[0].k,1)});`),f(x,"class","absolute left-full"),f(x,"style",k=`transform: scale(${Math.max(2.5-e[0].k,1)}); transform-origin: 0 0;`),f(r,"class","frame relative svelte-1wvt719"),f(r,"style",`width: ${he}px;height: ${he}px;`),f(n,"class","absolute top-0 left-0 pen"),f(n,"style",_=`transform: translateX(${e[6].x}px) translateY(${e[6].y}px) scale(${e[0].k}); transform-origin: 0 0;`),f(S,"class",w="absolute top-0 left-0 ring-8 hand "+(e[1]?"block cursor-move":"hidden cursor-pointer")),f(S,"style",N=`width: ${he}px;height: ${he}px;transform: translateX(${e[6].x}px) translateY(${e[6].y}px) scale(${e[0].k}); transform-origin: 0 0;`)},m(P,R){ne(P,t,R),m(t,n),m(n,r),T&&T.m(r,null),m(r,i),H&&H.m(r,null),m(r,s),m(r,o),e[15](o),m(r,l),m(r,c),Y&&Y.m(c,null),m(r,u),m(r,d),m(d,h),y.m(h,null),m(r,E),m(r,x),O&&O.m(x,null),m(t,b),m(t,S),e[18](S),A=!0,$||(V=Me(h,"click",e[16]),$=!0)},p(P,[R]){var z;P[5]?T?R&32&&X(T,1):(T=Gr(),T.c(),X(T,1),T.m(r,i)):T&&(Le(),W(T,1,1,()=>{T=null}),Te()),((z=P[2])==null?void 0:z.status)!=="masking"?H?H.p(P,R):(H=Qr(P),H.c(),H.m(r,s)):H&&(H.d(1),H=null),(!A||R&2&&a!==(a=P[1]?"":"bg-white"))&&f(o,"class",a),P[7]?Y?Y.p(P,R):(Y=ei(P),Y.c(),Y.m(c,null)):Y&&(Y.d(1),Y=null),j===(j=Z(P))&&y?y.p(P,R):(y.d(1),y=j(P),y&&(y.c(),y.m(h,null))),(!A||R&1&&p!==(p=`transform: scale(${Math.max(2.5-P[0].k,1)});`))&&f(d,"style",p),P[5]?O&&(O.d(1),O=null):O?O.p(P,R):(O=ni(P),O.c(),O.m(x,null)),(!A||R&1&&k!==(k=`transform: scale(${Math.max(2.5-P[0].k,1)}); transform-origin: 0 0;`))&&f(x,"style",k),(!A||R&65&&_!==(_=`transform: translateX(${P[6].x}px) translateY(${P[6].y}px) scale(${P[0].k}); transform-origin: 0 0;`))&&f(n,"style",_),(!A||R&2&&w!==(w="absolute top-0 left-0 ring-8 hand "+(P[1]?"block cursor-move":"hidden cursor-pointer")))&&f(S,"class",w),(!A||R&65&&N!==(N=`width: ${he}px;height: ${he}px;transform: translateX(${P[6].x}px) translateY(${P[6].y}px) scale(${P[0].k}); transform-origin: 0 0;`))&&f(S,"style",N)},i(P){A||(X(T),A=!0)},o(P){W(T),A=!1},d(P){P&&v(t),T&&T.d(),H&&H.d(),e[15](null),Y&&Y.d(),y.d(),O&&O.d(),e[18](null),$=!1,V()}}}function Tf(e,t,n){let r,i,s,o,a,l,c;we(e,ln,O=>n(22,o=O)),we(e,er,O=>n(8,a=O)),we(e,Se,O=>n(9,c=O));const u=An();we(e,u,O=>n(2,l=O));const d=sr();let{transform:h}=t,p,E={x:gt.width/2-he/2,y:gt.height/2-he/2},x,k=!0,_=!1,b=0,S=0;function w(O){p.save(),p.clearRect(0,0,he,he),p.globalCompositeOperation="source-over",p.drawImage(o,O.x,O.y,he,he,0,0,he,he),p.restore()}function N(O){p.save(),p.globalCompositeOperation="destination-out",p.beginPath(),p.moveTo(O.lastx,O.lasty),p.lineTo(O.x,O.y),p.lineWidth=50,p.lineCap="round",p.strokeStyle="black",p.stroke(),p.restore()}Kt(()=>{p=a.getContext("2d"),Re(x).on("wheel",O=>{o.dispatchEvent(new WheelEvent("wheel",O))}).call(V()).call(A),Re(a).on("wheel",O=>{o.dispatchEvent(new WheelEvent("wheel",O))}).call($()).call(A)});function A(O){function C(R){u.update({cursor:{x:h.invertX(R.clientX),y:h.invertY(R.clientY)}})}function P(){u.update({cursor:null})}return O.on("pointermove",C).on("pointerleave",P)}function $(){let O,C;function P(z){if(i)return;const B=z.x/h.k,te=z.y/h.k;O=B,C=te}function R(z){if(i)return;const B=z.x/h.k,te=z.y/h.k;N({x:B,y:te,lastx:O,lasty:C}),O=B,C=te}return Rr().on("start",P).on("drag",R)}function V(){function O(R){if(i)return;const z=R.sourceEvent.target.getBoundingClientRect();typeof TouchEvent<"u"&&R.sourceEvent instanceof TouchEvent?(b=R.sourceEvent.targetTouches[0].pageX-z.left,S=R.sourceEvent.targetTouches[0].pageY-z.top):R.sourceEvent instanceof MouseEvent&&(b=R.sourceEvent.pageX-z.left,S=R.sourceEvent.pageY-z.top),n(4,_=!0)}function C(R){if(i)return;const z=qt(h.invertX(R.x-b)),B=qt(h.invertY(R.y-S));n(14,E={x:z,y:B}),u.update({cursor:{x:h.invertX(R.x),y:h.invertY(R.y)}}),w({x:z,y:B})}function P(R){if(i)return;n(4,_=!1);const z=qt(h.invertX(R.x-b)),B=qt(h.invertY(R.y-S));w({x:z,y:B}),u.update({frame:{x:z,y:B}})}return Rr().on("start",O).on("drag",C).on("end",P)}function T(){n(1,k=!0),u.update({status:de.dragging})}function H(){n(1,k=!1),w(E),u.update({status:de.masking})}function Y(O){mt[O?"unshift":"push"](()=>{a=O,er.set(a)})}const Z=()=>T(),j=()=>d("prompt");function y(O){mt[O?"unshift":"push"](()=>{x=O,n(3,x)})}return e.$$set=O=>{"transform"in O&&n(0,h=O.transform)},e.$$.update=()=>{e.$$.dirty&4&&n(7,r=l==null?void 0:l.currentPrompt),e.$$.dirty&4&&n(5,i=(l==null?void 0:l.status)===de.loading||(l==null?void 0:l.status)===de.prompting||!1),e.$$.dirty&6&&!k&&l.status===de.loading&&n(1,k=!0),e.$$.dirty&16385&&n(6,s={x:h.applyX(E.x),y:h.applyY(E.y)})},[h,k,l,x,_,i,s,r,a,c,u,d,T,H,E,Y,Z,j,y]}class $f extends be{constructor(t){super(),Ee(this,t,Tf,Lf,ke,{transform:0})}}function Nf(e){let t,n,r,i;const s=e[8].default,o=tr(s,e,e[7],null);return{c(){t=D("div"),n=D("canvas"),r=ie(),o&&o.c(),this.h()},l(a){t=U(a,"DIV",{class:!0});var l=I(t);n=U(l,"CANVAS",{width:!0,height:!0,class:!0}),I(n).forEach(v),r=se(l),o&&o.l(l),l.forEach(v),this.h()},h(){f(n,"width",e[4]),f(n,"height",e[3]),f(n,"class","absolute top-0 left-0 bg-white shadow-2xl shadow-blue-500/20 svelte-6dcxg7"),f(t,"class","absolute top-0 left-0 right-0 bottom-0 overflow-hidden z-0 bg-blue-200/20")},m(a,l){ne(a,t,l),m(t,n),e[9](n),m(t,r),o&&o.m(t,null),e[10](t),i=!0},p(a,[l]){o&&o.p&&(!i||l&128)&&nr(o,s,a,a[7],i?ir(s,a[7],l,null):rr(a[7]),null)},i(a){i||(X(o,a),i=!0)},o(a){W(o,a),i=!1},d(a){a&&v(t),e[9](null),o&&o.d(a),e[10](null)}}}function Rf(e,t,n){let r,i,s;we(e,Qn,$=>n(12,r=$)),we(e,ln,$=>n(1,i=$));let{$$slots:o={},$$scope:a}=t;const l=An(),c=rs("promptImgStorage");we(e,c,$=>n(6,s=$));const u=gt.height,d=gt.width;let h,p;const E=new Set;function x($){if($){const V=new Map;for(const Z of Array.from(Array(d/$e).keys()))for(const j of Array.from(Array(u/$e).keys()))V.set(`${Z*$e}_${j*$e}`,null);const T=Object.values($).sort((Z,j)=>j.date-Z.date);for(const Z of T){const j=Z.position.x,y=Z.position.y;for(const O of[...Array(he/$e).keys()])for(const C of[...Array(he/$e).keys()]){const P=`${j+O*$e}_${y+C*$e}`;V.get(P)||V.set(P,Z.id)}}const H=new Set([...V.values()]);return T.filter(Z=>H.has(Z.id)).reverse().filter(Z=>!E.has(Z.id))}return[]}let k=[];Kt(()=>{const V=(d+400)/(h.clientHeight>h.clientWidth?h.clientWidth:h.clientHeight),T=Cf().scaleExtent([1/V/2,3]).translateExtent([[-200,-200],[d+200,u+200]]).tapDistance(10).on("zoom",b),H=Re(i.parentElement).call(T).call(T.transform,Vt).call(T.scaleTo,1/V).on("pointermove",S).on("pointerleave",w);p=i.getContext("2d");function Y(){const Z=(d+400)/(h.clientHeight>h.clientWidth?h.clientWidth:h.clientHeight);H.call(T.transform,Vt),H.call(T.scaleTo,1/Z)}return window.addEventListener("resize",Y),()=>{window.removeEventListener("resize",Y)}});function _($){Promise.all($.map(({imgURL:V,position:T,id:H})=>new Promise(Y=>{const Z=new Image;Z.crossOrigin="anonymous",Z.onload=()=>{const j={img:Z,position:T,id:H};p.drawImage(Z,T.x,T.y,Z.width,Z.height),Y(j)},Z.src=`${Cc}/${V}`}))).then(V=>{V.forEach(({img:T,position:H,id:Y})=>{E.add(Y),p.drawImage(T,H.x,H.y,T.width,T.height)})})}function b($){const V=Ae(Qn,r=$.transform,r);Ae(ln,i.style.transform=`translate(${V.x}px, ${V.y}px) scale(${V.k})`,i)}function S($){$.preventDefault();const V=r.invertX($.clientX),T=r.invertY($.clientY);l.update({cursor:{x:V,y:T}})}function w(){l.update({cursor:null})}function N($){mt[$?"unshift":"push"](()=>{i=$,ln.set(i)})}function A($){mt[$?"unshift":"push"](()=>{h=$,n(0,h)})}return e.$$set=$=>{"$$scope"in $&&n(7,a=$.$$scope)},e.$$.update=()=>{e.$$.dirty&64&&n(5,k=x(s==null?void 0:s.toObject())),e.$$.dirty&32&&k&&_(k)},[h,i,c,u,d,k,s,a,o,N,A]}class Mf extends be{constructor(t){super(),Ee(this,t,Rf,Nf,ke,{})}}function Df(e){let t,n,r;return{c(){t=Q("svg"),n=Q("rect"),r=Q("rect"),this.h()},l(i){t=ee(i,"svg",{class:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var s=I(t);n=ee(s,"rect",{x:!0,y:!0,width:!0,height:!0,rx:!0,stroke:!0}),I(n).forEach(v),r=ee(s,"rect",{x:!0,y:!0,width:!0,height:!0,rx:!0,fill:!0,stroke:!0}),I(r).forEach(v),s.forEach(v),this.h()},h(){f(n,"x","1"),f(n,"y","1"),f(n,"width","7"),f(n,"height","7"),f(n,"rx","1"),f(n,"stroke","#2F6DCB"),f(r,"x","3.05566"),f(r,"y","3.05566"),f(r,"width","2.88889"),f(r,"height","2.88889"),f(r,"rx","0.5"),f(r,"fill","#2F6DCB"),f(r,"stroke","#2F6DCB"),f(t,"class",e[0]),f(t,"height","1em"),f(t,"viewBox","0 0 9 9"),f(t,"fill","none"),f(t,"xmlns","http://www.w3.org/2000/svg")},m(i,s){ne(i,t,s),m(t,n),m(t,r)},p(i,[s]){s&1&&f(t,"class",i[0])},i:ue,o:ue,d(i){i&&v(t)}}}function Uf(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class br extends be{constructor(t){super(),Ee(this,t,Uf,Df,ke,{classList:0})}}function Hf(e){let t,n;return{c(){t=Q("svg"),n=Q("path"),this.h()},l(r){t=ee(r,"svg",{class:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var i=I(t);n=ee(i,"path",{d:!0,fill:!0}),I(n).forEach(v),i.forEach(v),this.h()},h(){f(n,"d","M3.5 4.58599C3.74063 4.58599 3.94669 4.4961 4.11819 4.31633C4.2894 4.13687 4.375 3.92102 4.375 3.66879C4.375 3.41656 4.2894 3.20056 4.11819 3.02079C3.94669 2.84132 3.74063 2.75159 3.5 2.75159C3.25937 2.75159 3.05346 2.84132 2.88225 3.02079C2.71075 3.20056 2.625 3.41656 2.625 3.66879C2.625 3.92102 2.71075 4.13687 2.88225 4.31633C3.05346 4.4961 3.25937 4.58599 3.5 4.58599ZM3.5 7.95669C4.38958 7.10064 5.04948 6.32285 5.47969 5.62334C5.9099 4.92413 6.125 4.30318 6.125 3.76051C6.125 2.92739 5.87154 2.24515 5.36462 1.71378C4.858 1.18273 4.23646 0.917197 3.5 0.917197C2.76354 0.917197 2.14185 1.18273 1.63494 1.71378C1.12831 2.24515 0.875 2.92739 0.875 3.76051C0.875 4.30318 1.0901 4.92413 1.52031 5.62334C1.95052 6.32285 2.61042 7.10064 3.5 7.95669ZM3.5 9C3.44167 9 3.38333 8.98853 3.325 8.9656C3.26667 8.94267 3.21562 8.9121 3.17188 8.87389C2.10729 7.8879 1.3125 6.97269 0.7875 6.12825C0.2625 5.28352 0 4.49427 0 3.76051C0 2.61401 0.351896 1.70064 1.05569 1.02038C1.75919 0.340127 2.57396 0 3.5 0C4.42604 0 5.24081 0.340127 5.94431 1.02038C6.6481 1.70064 7 2.61401 7 3.76051C7 4.49427 6.7375 5.28352 6.2125 6.12825C5.6875 6.97269 4.89271 7.8879 3.82812 8.87389C3.78438 8.9121 3.73333 8.94267 3.675 8.9656C3.61667 8.98853 3.55833 9 3.5 9Z"),f(n,"fill","white"),f(t,"class",e[0]),f(t,"height","1em"),f(t,"viewBox","0 0 7 9"),f(t,"fill","none"),f(t,"xmlns","http://www.w3.org/2000/svg")},m(r,i){ne(r,t,i),m(t,n)},p(r,[i]){i&1&&f(t,"class",r[0])},i:ue,o:ue,d(r){r&&v(t)}}}function zf(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class Vf extends be{constructor(t){super(),Ee(this,t,zf,Hf,ke,{classList:0})}}function Bf(e){let t,n,r,i;return{c(){t=Q("svg"),n=Q("path"),r=Q("path"),i=Q("path"),this.h()},l(s){t=ee(s,"svg",{class:!0,height:!0,width:!0,viewBox:!0,fill:!0,xmlns:!0});var o=I(t);n=ee(o,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),I(n).forEach(v),r=ee(o,"path",{d:!0,fill:!0}),I(r).forEach(v),i=ee(o,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),I(i).forEach(v),o.forEach(v),this.h()},h(){f(n,"fill-rule","evenodd"),f(n,"clip-rule","evenodd"),f(n,"d","M6.41113 3.73486C6.97158 4.11531 7.3643 4.63076 7.3643 5.31801V6.54526H8.59155C8.81654 6.54526 9.00063 6.36118 9.00063 6.13618V5.31801C9.00063 4.42621 7.5402 3.8985 6.41113 3.73486Z"),f(n,"fill","currentColor"),f(r,"d","M3.27305 3.27266C4.17677 3.27266 4.90938 2.54005 4.90938 1.63633C4.90938 0.732611 4.17677 0 3.27305 0C2.36933 0 1.63672 0.732611 1.63672 1.63633C1.63672 2.54005 2.36933 3.27266 3.27305 3.27266Z"),f(r,"fill","currentColor"),f(i,"fill-rule","evenodd"),f(i,"clip-rule","evenodd"),f(i,"d","M5.72716 3.27266C6.63124 3.27266 7.36349 2.54041 7.36349 1.63633C7.36349 0.732258 6.63124 0 5.72716 0C5.53489 0 5.3549 0.0409082 5.18308 0.0981798C5.53511 0.533533 5.72715 1.07646 5.72715 1.63633C5.72715 2.1962 5.53511 2.73913 5.18308 3.17448C5.3549 3.23176 5.53489 3.27266 5.72716 3.27266ZM3.27266 3.68175C2.18041 3.68175 0 4.22992 0 5.31808V6.13624C0 6.36124 0.184087 6.54533 0.409083 6.54533H6.13625C6.36124 6.54533 6.54533 6.36124 6.54533 6.13624V5.31808C6.54533 4.22992 4.36492 3.68175 3.27266 3.68175Z"),f(i,"fill","currentColor"),f(t,"class",e[0]),f(t,"height","1em"),f(t,"width","1em"),f(t,"viewBox","0 0 9 7"),f(t,"fill","none"),f(t,"xmlns","http://www.w3.org/2000/svg")},m(s,o){ne(s,t,o),m(t,n),m(t,r),m(t,i)},p(s,[o]){o&1&&f(t,"class",s[0])},i:ue,o:ue,d(s){s&&v(t)}}}function Kf(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class Er extends be{constructor(t){super(),Ee(this,t,Kf,Bf,ke,{classList:0})}}function ri(e,t,n){const r=e.slice();return r[14]=t[n],r}function Ff(e){let t,n,r,i;return n=new kn({props:{classList:"animate-spin mr-2 text-sm"}}),{c(){t=D("div"),pe(n.$$.fragment),r=q(" loading rooms"),this.h()},l(s){t=U(s,"DIV",{class:!0});var o=I(t);me(n.$$.fragment,o),r=G(o," loading rooms"),o.forEach(v),this.h()},h(){f(t,"class","bg-gradient-to-r from-transparent via-blue-900/20 to-transparent py-1.5 text-blue-700 rounded-full flex justify-center items-center")},m(s,o){ne(s,t,o),_e(n,t,null),m(t,r),i=!0},p:ue,i(s){i||(X(n.$$.fragment,s),i=!0)},o(s){W(n.$$.fragment,s),i=!1},d(s){s&&v(t),ge(n)}}}function jf(e){let t,n,r,i,s,o,a,l,c,u=!e[4]&&ii(e);const d=[Yf,Xf],h=[];function p(E,x){return E[6]?0:1}return i=p(e),s=h[i]=d[i](e),{c(){t=D("div"),u&&u.c(),n=ie(),r=D("div"),s.c(),this.h()},l(E){t=U(E,"DIV",{class:!0,title:!0});var x=I(t);u&&u.l(x),n=se(x),r=U(x,"DIV",{class:!0});var k=I(r);s.l(k),k.forEach(v),x.forEach(v),this.h()},h(){f(r,"class",o=e[0]?"cursor-wait":"cursor-pointer"),f(t,"class","text-sm rounded md:text-smtext-gray-700 py-1 font-medium tracking-tight relative"),f(t,"title","Choose a different room")},m(E,x){ne(E,t,x),u&&u.m(t,null),m(t,n),m(t,r),h[i].m(r,null),e[11](t),a=!0,l||(c=Me(r,"click",e[10]),l=!0)},p(E,x){E[4]?u&&(Le(),W(u,1,1,()=>{u=null}),Te()):u?(u.p(E,x),x&16&&X(u,1)):(u=ii(E),u.c(),X(u,1),u.m(t,n));let k=i;i=p(E),i===k?h[i].p(E,x):(Le(),W(h[k],1,1,()=>{h[k]=null}),Te(),s=h[i],s?s.p(E,x):(s=h[i]=d[i](E),s.c()),X(s,1),s.m(r,null)),(!a||x&1&&o!==(o=E[0]?"cursor-wait":"cursor-pointer"))&&f(r,"class",o)},i(E){a||(X(u),X(s),a=!0)},o(E){W(u),W(s),a=!1},d(E){E&&v(t),u&&u.d(),h[i].d(),e[11](null),l=!1,c()}}}function ii(e){let t,n,r,i,s,o,a,l,c,u,d,h,p,E,x,k;i=new br({}),c=new Er({});let _=e[2],b=[];for(let w=0;w<_.length;w+=1)b[w]=oi(ri(e,_,w));const S=w=>W(b[w],1,1,()=>{b[w]=null});return{c(){t=D("div"),n=D("ul"),r=D("li"),pe(i.$$.fragment),s=ie(),o=D("span"),a=q("room"),l=ie(),pe(c.$$.fragment),u=ie(),d=D("span"),h=q("players"),p=ie();for(let w=0;w{A=null}),Te()),(!S||T&4)&&a!==(a=e[14].id+"")&&rt(l,a),(!S||T&4)&&p!==(p=e[14].users_count+"")&&rt(E,p),(!S||T&6&&_!==(_="grid-row gap-2 hover:bg-gray-300 "+(e[14].room_id===e[1]?"text-black":"")+" svelte-15fj2lr"))&&f(n,"class",_)},i(V){S||(X(A),S=!0)},o(V){W(A),S=!1},d(V){V&&v(t),A&&A.d(),w=!1,N()}}}function Xf(e){let t,n,r,i,s,o,a,l,c,u;return n=new br({}),o=new Er({}),{c(){t=D("div"),pe(n.$$.fragment),r=ie(),i=D("span"),s=q(`Loading... `),pe(o.$$.fragment),a=ie(),l=D("span"),c=q("... / ..."),this.h()},l(d){t=U(d,"DIV",{class:!0});var h=I(t);me(n.$$.fragment,h),r=se(h),i=U(h,"SPAN",{});var p=I(i);s=G(p,`Loading... `),me(o.$$.fragment,p),a=se(p),l=U(p,"SPAN",{});var E=I(l);c=G(E,"... / ..."),E.forEach(v),p.forEach(v),h.forEach(v),this.h()},h(){f(t,"class","grid-row gap-2 svelte-15fj2lr")},m(d,h){ne(d,t,h),_e(n,t,null),m(t,r),m(t,i),m(i,s),_e(o,i,null),m(i,a),m(i,l),m(l,c),u=!0},p:ue,i(d){u||(X(n.$$.fragment,d),X(o.$$.fragment,d),u=!0)},o(d){W(n.$$.fragment,d),W(o.$$.fragment,d),u=!1},d(d){d&&v(t),ge(n),ge(o)}}}function Yf(e){var _,b;let t,n,r,i,s,o=((_=e[6])==null?void 0:_.id)+"",a,l,c,u,d,h=((b=e[6])==null?void 0:b.users_count)+"",p,E,x,k;return n=new br({}),c=new Er({}),{c(){t=D("div"),pe(n.$$.fragment),r=ie(),i=D("span"),s=q("room "),a=q(o),l=ie(),pe(c.$$.fragment),u=ie(),d=D("span"),p=q(h),E=q(" / "),x=q(Rt),this.h()},l(S){t=U(S,"DIV",{class:!0});var w=I(t);me(n.$$.fragment,w),r=se(w),i=U(w,"SPAN",{});var N=I(i);s=G(N,"room "),a=G(N,o),N.forEach(v),l=se(w),me(c.$$.fragment,w),u=se(w),d=U(w,"SPAN",{});var A=I(d);p=G(A,h),E=G(A," / "),x=G(A,Rt),A.forEach(v),w.forEach(v),this.h()},h(){f(t,"class","grid-row gap-2 svelte-15fj2lr")},m(S,w){ne(S,t,w),_e(n,t,null),m(t,r),m(t,i),m(i,s),m(i,a),m(t,l),_e(c,t,null),m(t,u),m(t,d),m(d,p),m(d,E),m(d,x),k=!0},p(S,w){var N,A;(!k||w&64)&&o!==(o=((N=S[6])==null?void 0:N.id)+"")&&rt(a,o),(!k||w&64)&&h!==(h=((A=S[6])==null?void 0:A.users_count)+"")&&rt(p,h)},i(S){k||(X(n.$$.fragment,S),X(c.$$.fragment,S),k=!0)},o(S){W(n.$$.fragment,S),W(c.$$.fragment,S),k=!1},d(S){S&&v(t),ge(n),ge(c)}}}function Jf(e){let t,n,r,i;const s=[jf,Ff],o=[];function a(l,c){return l[5]?0:1}return n=a(e),r=o[n]=s[n](e),{c(){t=D("div"),r.c(),this.h()},l(l){t=U(l,"DIV",{class:!0});var c=I(t);r.l(c),c.forEach(v),this.h()},h(){f(t,"class","min-w-[25ch]")},m(l,c){ne(l,t,c),o[n].m(t,null),i=!0},p(l,[c]){let u=n;n=a(l),n===u?o[n].p(l,c):(Le(),W(o[u],1,1,()=>{o[u]=null}),Te(),r=o[n],r?r.p(l,c):(r=o[n]=s[n](l),r.c()),X(r,1),r.m(t,null))},i(l){i||(X(r),i=!0)},o(l){W(r),i=!1},d(l){l&&v(t),o[n].d()}}}function Zf(e,t,n){let r,i,s,o,a;we(e,Ns,_=>n(12,s=_)),we(e,Nt,_=>n(1,o=_));let{isLoading:l=!1}=t,c;const u=Mc();we(e,u,_=>n(2,a=_));let d=!0;function h(_){c.contains(_.target)||n(4,d=!0)}Kt(()=>(window.addEventListener("pointerdown",h,!0),()=>{window.removeEventListener("pointerdown",h,!0)}));function p(_){Ae(Nt,o=_.room_id,o),n(4,d=!0),s.url.searchParams.set("roomid",_.room_id),window.location.search=`?${s.url.searchParams.toString()}`}const E=_=>p(_),x=()=>l?null:n(4,d=!d);function k(_){mt[_?"unshift":"push"](()=>{c=_,n(3,c)})}return e.$$set=_=>{"isLoading"in _&&n(0,l=_.isLoading)},e.$$.update=()=>{e.$$.dirty&6&&n(6,r=a.find(_=>_.room_id===o)),e.$$.dirty&4&&n(5,i=a.length>0)},[l,o,a,c,d,i,r,u,p,E,x,k]}class Wf extends be{constructor(t){super(),Ee(this,t,Zf,Jf,ke,{isLoading:0})}}function qf(e){let t,n,r,i,s,o;return{c(){t=D("button"),n=Q("svg"),r=Q("path"),i=q(` About`),this.h()},l(a){t=U(a,"BUTTON",{class:!0});var l=I(t);n=ee(l,"svg",{width:!0,height:!0,viewBox:!0,class:!0});var c=I(n);r=ee(c,"path",{fill:!0,"fill-rule":!0,d:!0,"clip-rule":!0}),I(r).forEach(v),c.forEach(v),i=G(l,` About`),l.forEach(v),this.h()},h(){f(r,"fill","currentColor"),f(r,"fill-rule","evenodd"),f(r,"d","M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10s10-4.477 10-10S17.523 2 12 2zm0 7a1 1 0 0 0-1 1a1 1 0 1 1-2 0a3 3 0 1 1 4.44 2.633a1.404 1.404 0 0 0-.383.288a.303.303 0 0 0-.057.085v.494a1 1 0 1 1-2 0V13c0-.58.253-1.047.539-1.38c.281-.33.63-.572.94-.742A1 1 0 0 0 12 9zm.999 4.011v-.004v.005zM12 15a1 1 0 1 0 0 2h.01a1 1 0 1 0 0-2H12z"),f(r,"clip-rule","evenodd"),f(n,"width",".9em"),f(n,"height",".9em"),f(n,"viewBox","0 0 24 24"),f(n,"class","mr-1"),f(t,"class","md:w-[210px] text-sm flex items-center order-last md:order-none")},m(a,l){ne(a,t,l),m(t,n),m(n,r),m(t,i),s||(o=Me(t,"click",e[0]),s=!0)},p:ue,i:ue,o:ue,d(a){a&&v(t),s=!1,o()}}}function Gf(e){function t(n){lr.call(this,e,n)}return[t]}class Qf extends be{constructor(t){super(),Ee(this,t,Gf,qf,ke,{})}}function eh(e){let t,n,r,i,s,o,a,l,c,u,d,h,p,E,x,k;return n=new Qf({}),n.$on("click",e[4]),p=new Wf({props:{isLoading:e[0]}}),{c(){t=D("div"),pe(n.$$.fragment),r=ie(),i=D("button"),s=D("span"),o=q("\u{1F58D}"),a=q(`Paint `),l=D("span"),c=Q("svg"),u=Q("path"),d=q(` Enter`),h=ie(),pe(p.$$.fragment),this.h()},l(_){t=U(_,"DIV",{class:!0});var b=I(t);me(n.$$.fragment,b),r=se(b),i=U(b,"BUTTON",{class:!0});var S=I(i);s=U(S,"SPAN",{class:!0});var w=I(s);o=G(w,"\u{1F58D}"),w.forEach(v),a=G(S,`Paint `),l=U(S,"SPAN",{class:!0});var N=I(l);c=ee(N,"svg",{class:!0,width:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var A=I(c);u=ee(A,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),I(u).forEach(v),A.forEach(v),d=G(N,` Enter`),N.forEach(v),S.forEach(v),h=se(b),me(p.$$.fragment,b),b.forEach(v),this.h()},h(){f(s,"class","mr-3"),f(u,"fill-rule","evenodd"),f(u,"clip-rule","evenodd"),f(u,"d","M8.5 8.5V0H9.5V9.5H1.70711L4.03553 11.8284C4.2308 12.0237 4.2308 12.3403 4.03553 12.5355C3.84027 12.7308 3.52369 12.7308 3.32843 12.5355L0.146447 9.35355C-0.0488155 9.15829 -0.0488155 8.84171 0.146447 8.64645L3.32843 5.46447C3.52369 5.2692 3.84027 5.2692 4.03553 5.46447C4.2308 5.65973 4.2308 5.97631 4.03553 6.17157L1.70711 8.5H8.5Z"),f(u,"fill","currentColor"),f(c,"class","text-sm mr-1.5"),f(c,"width","1em"),f(c,"height","1em"),f(c,"viewBox","0 0 10 13"),f(c,"fill","currentColor"),f(c,"xmlns","http://www.w3.org/2000/svg"),f(l,"class","bg-blue-800 text-gray-300 rounded-lg px-2 py-0.5 text-base ml-4 hidden sm:flex items-center translate-y-[2px]"),f(i,"class","order-first md:order-none text-3xl bg-blue-600 text-white px-6 py-2 rounded-2xl ring ring-blue-500 font-semibold shadow-2xl self-center flex items-center hover:saturate-150"),f(t,"class","flex flex-col md:flex-row items-center justify-between px-12 gap-4 md:gap-0")},m(_,b){ne(_,t,b),_e(n,t,null),m(t,r),m(t,i),m(i,s),m(s,o),m(i,a),m(i,l),m(l,c),m(c,u),m(l,d),m(t,h),_e(p,t,null),E=!0,x||(k=[Me(window,"keyup",Bn(ar(e[3]))),Me(i,"click",e[5])],x=!0)},p(_,[b]){const S={};b&1&&(S.isLoading=_[0]),p.$set(S)},i(_){E||(X(n.$$.fragment,_),X(p.$$.fragment,_),E=!0)},o(_){W(n.$$.fragment,_),W(p.$$.fragment,_),E=!1},d(_){_&&v(t),ge(n),ge(p),x=!1,or(k)}}}function th(e,t,n){let r;we(e,vn,c=>n(1,r=c));const i=sr();let{isLoading:s=!1}=t;const o=c=>c.key==="Enter"&&i("prompt"),a=()=>{Ae(vn,r=!r,r)},l=()=>i("prompt");return e.$$set=c=>{"isLoading"in c&&n(0,s=c.isLoading)},[s,r,i,o,a,l]}class nh extends be{constructor(t){super(),Ee(this,t,th,eh,ke,{isLoading:0})}}function rh(e){let t,n,r,i,s,o,a,l,c,u;return{c(){t=D("form"),n=D("div"),r=D("input"),i=ie(),s=D("button"),o=D("span"),a=q("\u{1F58D}"),l=q(" Paint"),this.h()},l(d){t=U(d,"FORM",{class:!0});var h=I(t);n=U(h,"DIV",{class:!0});var p=I(n);r=U(p,"INPUT",{class:!0,placeholder:!0,title:!0,type:!0,name:!0}),i=se(p),s=U(p,"BUTTON",{class:!0,type:!0});var E=I(s);o=U(E,"SPAN",{class:!0});var x=I(o);a=G(x,"\u{1F58D}"),x.forEach(v),l=G(E," Paint"),E.forEach(v),p.forEach(v),h.forEach(v),this.h()},h(){r.value=e[0],f(r,"class","flex-1 outline-none ring-0 border-none text-xl 2xl:text-2xl py-3 px-3"),f(r,"placeholder","Describe your prompt"),f(r,"title","Input prompt to generate image and obtain palette"),f(r,"type","text"),f(r,"name","prompt"),f(o,"class","mr-2"),f(s,"class","font-semibold bg-blue-700 text-white border-l-2 px-5 text-xl 2xl:text-2xl spacing tracking-wide hover:saturate-150"),f(s,"type","submit"),f(n,"class","flex bg-white overflow-hidden rounded-2xl w-full max-w-lg 2xl:max-w-xl"),f(t,"class","fixed w-screen top-0 left-0 bottom-0 right-0 h-screen z-50 flex items-center justify-center bg-black bg-opacity-80")},m(d,h){ne(d,t,h),m(t,n),m(n,r),e[7](r),m(n,i),m(n,s),m(s,o),m(o,a),m(s,l),e[8](n),c||(u=[Me(r,"click",Bn(e[6])),Me(r,"input",e[4]),Me(t,"submit",Bn(ar(e[3])))],c=!0)},p(d,[h]){h&1&&r.value!==d[0]&&(r.value=d[0])},i:ue,o:ue,d(d){d&&v(t),e[7](null),e[8](null),c=!1,or(u)}}}function ih(e,t,n){const r=sr();let{initPrompt:i=""}=t,s,o,a;const l=An(),c=b=>{b.key==="Escape"&&(l.update({status:de.ready}),r("close"))};Kt(()=>(o.focus(),n(0,s=i),window.addEventListener("keyup",c),window.addEventListener("pointerdown",E,!0),()=>{window.removeEventListener("keyup",c),window.removeEventListener("pointerdown",E,!0)}));let u;function d(b){clearTimeout(u),u=setTimeout(()=>{n(0,s=b),l.update({currentPrompt:s,status:de.prompting})},100)}function h(){s.trim()!==""&&(r("paint"),r("close"))}function p(b){const S=b.target;d(S.value)}function E(b){a.contains(b.target)||(l.update({status:de.ready}),r("close"))}function x(b){lr.call(this,e,b)}function k(b){mt[b?"unshift":"push"](()=>{o=b,n(1,o)})}function _(b){mt[b?"unshift":"push"](()=>{a=b,n(2,a)})}return e.$$set=b=>{"initPrompt"in b&&n(5,i=b.initPrompt)},[s,o,a,h,p,i,x,k,_]}class sh extends be{constructor(t){super(),Ee(this,t,ih,rh,ke,{initPrompt:5})}}let oh=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");function ai(e,t,n){const r=e.slice();return r[15]=t[n].connectionId,r[16]=t[n].presence,r}function li(e){var r;let t,n;return t=new sh({props:{initPrompt:(r=e[0])==null?void 0:r.currentPrompt}}),t.$on("paint",e[11]),t.$on("close",e[10]),{c(){pe(t.$$.fragment)},l(i){me(t.$$.fragment,i)},m(i,s){_e(t,i,s),n=!0},p(i,s){var a;const o={};s&1&&(o.initPrompt=(a=i[0])==null?void 0:a.currentPrompt),t.$set(o)},i(i){n||(X(t.$$.fragment,i),n=!0)},o(i){W(t.$$.fragment,i),n=!1},d(i){ge(t,i)}}}function ci(e){let t=[],n=new Map,r,i,s=[...e[5]];const o=a=>a[15];for(let a=0;a{o=null}),Te()),(S=t[16])!=null&&S.cursor?a?(a.p(t,E),E&32&&X(a,1)):(a=fi(t),a.c(),X(a,1),a.m(i.parentNode,i)):a&&(Le(),W(a,1,1,()=>{a=null}),Te())},i(p){s||(X(o),X(a),s=!0)},o(p){W(o),W(a),s=!1},d(p){p&&v(n),o&&o.d(p),p&&v(r),a&&a.d(p),p&&v(i)}}}function ah(e){let t,n,r,i,s,o,a,l,c,u,d,h,p,E,x=e[1]&&li(e);o=new Mf({}),c=new $f({props:{transform:e[4]}}),c.$on("prompt",e[9]);let k=e[5]&&ci(e);return p=new nh({props:{isLoading:e[2]}}),p.$on("prompt",e[9]),{c(){t=D("div"),n=q(e[3]),r=ie(),x&&x.c(),i=ie(),s=D("div"),pe(o.$$.fragment),a=ie(),l=D("main"),pe(c.$$.fragment),u=ie(),k&&k.c(),d=ie(),h=D("div"),pe(p.$$.fragment),this.h()},l(_){t=U(_,"DIV",{class:!0});var b=I(t);n=G(b,e[3]),b.forEach(v),r=se(_),x&&x.l(_),i=se(_),s=U(_,"DIV",{class:!0});var S=I(s);me(o.$$.fragment,S),a=se(S),l=U(S,"MAIN",{class:!0});var w=I(l);me(c.$$.fragment,w),u=se(w),k&&k.l(w),w.forEach(v),S.forEach(v),d=se(_),h=U(_,"DIV",{class:!0});var N=I(h);me(p.$$.fragment,N),N.forEach(v),this.h()},h(){f(t,"class","text touch-none pointer-events-none"),f(l,"class","z-10 relative"),f(s,"class","fixed top-0 left-0 z-0 w-screen h-screen min-h-[600px]"),f(h,"class","fixed bottom-4 md:bottom-32 left-0 right-0 z-10 my-2")},m(_,b){ne(_,t,b),m(t,n),ne(_,r,b),x&&x.m(_,b),ne(_,i,b),ne(_,s,b),_e(o,s,null),m(s,a),m(s,l),_e(c,l,null),m(l,u),k&&k.m(l,null),ne(_,d,b),ne(_,h,b),_e(p,h,null),E=!0},p(_,[b]){(!E||b&8)&&rt(n,_[3]),_[1]?x?(x.p(_,b),b&2&&X(x,1)):(x=li(_),x.c(),X(x,1),x.m(i.parentNode,i)):x&&(Le(),W(x,1,1,()=>{x=null}),Te());const S={};b&16&&(S.transform=_[4]),c.$set(S),_[5]?k?(k.p(_,b),b&32&&X(k,1)):(k=ci(_),k.c(),X(k,1),k.m(l,null)):k&&(Le(),W(k,1,1,()=>{k=null}),Te());const w={};b&4&&(w.isLoading=_[2]),p.$set(w)},i(_){E||(X(x),X(o.$$.fragment,_),X(c.$$.fragment,_),X(k),X(p.$$.fragment,_),E=!0)},o(_){W(x),W(o.$$.fragment,_),W(c.$$.fragment,_),W(k),W(p.$$.fragment,_),E=!1},d(_){_&&v(t),_&&v(r),x&&x.d(_),_&&v(i),_&&v(s),ge(o),ge(c),k&&k.d(),_&&v(d),_&&v(h),ge(p)}}}function lh(e){return`${e.x}_${e.y}`}function ch(e,t,n){let r,i,s,o,a,l,c;we(e,Se,b=>n(3,i=b)),we(e,er,b=>n(13,o=b)),we(e,Qn,b=>n(4,l=b));const u=An();we(e,u,b=>n(0,a=b));const d=$c();we(e,d,b=>n(5,c=b));const h=rs("promptImgStorage");we(e,h,b=>n(12,s=b));let p=!1;function E(){!r&&!p&&(n(1,p=!0),u.update({status:de.prompting}))}function x(){n(1,p=!1)}function k(){_(),n(1,p=!1)}async function _(){if(r)return;Ae(Se,i="Pending",i);const b=a.currentPrompt,S=a.frame;console.log("Generating...",b,S),u.update({status:de.loading});const w=crypto.randomUUID(),N=o.toDataURL("image/png"),A={fn_index:0,session_hash:w},$={data:[N,b,.75,7.5,40,"patchmatch"]},V=new WebSocket(Ac);V.onclose=T=>{T.wasClean||(Ae(Se,i="Error",i),u.update({status:de.ready}))},V.onmessage=async function(T){try{const H=JSON.parse(T.data);switch(Ae(Se,i="",i),H.msg){case"send_hash":V.send(JSON.stringify(A));break;case"send_data":Ae(Se,i="Sending Data",i),V.send(JSON.stringify({...A,...$}));break;case"queue_full":Ae(Se,i="Queue full",i),V.close(),u.update({status:de.ready});return;case"estimation":const{rank:Y,queue_size:Z}=H;Ae(Se,i=`On queue ${Y}/${Z}`,i);break;case"process_generating":Ae(Se,i=H.success?"Generating":"Error",i);break;case"process_completed":try{const j=H.output.data[0];if(H.output.data[1])throw new Error("NFSW");const O=lh(S),C=await Sc(j),P=await Pc(C,b,O),R={prompt:b,imgURL:P.filename,position:S,date:new Date().getTime(),id:oh()};s.set(O,R),console.log(P),Ae(Se,i=H.success?"Complete":"Error",i),setTimeout(()=>{Ae(Se,i="",i)},2e3),u.update({status:de.ready,currentPrompt:""})}catch(j){const y=j;Ae(Se,i=y==null?void 0:y.message,i),u.update({status:de.ready})}V.close();return;case"process_starts":Ae(Se,i="Processing",i);break}}catch(H){console.error(H),Ae(Se,i="Error",i)}}}return e.$$.update=()=>{e.$$.dirty&1&&n(2,r=(a==null?void 0:a.status)===de.loading||!1)},[a,p,r,i,l,c,u,d,h,E,x,k]}class uh extends be{constructor(t){super(),Ee(this,t,ch,ah,ke,{})}}function fh(e){let t,n,r,i,s,o,a,l,c,u,d,h,p,E,x,k,_,b,S,w,N,A,$,V,T,H,Y;return{c(){t=Q("svg"),n=Q("rect"),r=Q("path"),i=Q("path"),s=Q("path"),o=Q("path"),a=Q("path"),l=Q("path"),c=Q("path"),u=Q("path"),d=Q("path"),h=Q("path"),p=Q("path"),E=Q("path"),x=Q("path"),k=Q("path"),_=Q("path"),b=Q("path"),S=Q("path"),w=Q("path"),N=Q("path"),A=Q("path"),$=Q("path"),V=Q("defs"),T=Q("radialGradient"),H=Q("stop"),Y=Q("stop"),this.h()},l(Z){t=ee(Z,"svg",{class:!0,width:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var j=I(t);n=ee(j,"rect",{opacity:!0,x:!0,y:!0,width:!0,height:!0,rx:!0,fill:!0,stroke:!0,"stroke-width":!0}),I(n).forEach(v),r=ee(j,"path",{d:!0,fill:!0}),I(r).forEach(v),i=ee(j,"path",{d:!0,fill:!0}),I(i).forEach(v),s=ee(j,"path",{d:!0,fill:!0}),I(s).forEach(v),o=ee(j,"path",{d:!0,fill:!0}),I(o).forEach(v),a=ee(j,"path",{d:!0,fill:!0}),I(a).forEach(v),l=ee(j,"path",{d:!0,fill:!0}),I(l).forEach(v),c=ee(j,"path",{d:!0,fill:!0}),I(c).forEach(v),u=ee(j,"path",{d:!0,fill:!0}),I(u).forEach(v),d=ee(j,"path",{d:!0,fill:!0}),I(d).forEach(v),h=ee(j,"path",{d:!0,fill:!0}),I(h).forEach(v),p=ee(j,"path",{d:!0,fill:!0}),I(p).forEach(v),E=ee(j,"path",{d:!0,fill:!0}),I(E).forEach(v),x=ee(j,"path",{d:!0,fill:!0}),I(x).forEach(v),k=ee(j,"path",{d:!0,fill:!0}),I(k).forEach(v),_=ee(j,"path",{d:!0,fill:!0}),I(_).forEach(v),b=ee(j,"path",{d:!0,fill:!0}),I(b).forEach(v),S=ee(j,"path",{d:!0,fill:!0}),I(S).forEach(v),w=ee(j,"path",{d:!0,fill:!0}),I(w).forEach(v),N=ee(j,"path",{d:!0,fill:!0}),I(N).forEach(v),A=ee(j,"path",{d:!0,fill:!0}),I(A).forEach(v),$=ee(j,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),I($).forEach(v),V=ee(j,"defs",{});var y=I(V);T=ee(y,"radialGradient",{id:!0,cx:!0,cy:!0,r:!0,gradientUnits:!0,gradientTransform:!0});var O=I(T);H=ee(O,"stop",{"stop-color":!0}),I(H).forEach(v),Y=ee(O,"stop",{offset:!0,"stop-color":!0}),I(Y).forEach(v),O.forEach(v),y.forEach(v),j.forEach(v),this.h()},h(){f(n,"opacity","0.5"),f(n,"x","0.25"),f(n,"y","0.25"),f(n,"width","122.5"),f(n,"height","43.5"),f(n,"rx","6.75"),f(n,"fill","#1F2937"),f(n,"stroke","#3A4C64"),f(n,"stroke-width","0.5"),f(r,"d","M44.9102 16.8569H45.8514V14.778H47.1691C48.364 14.778 49.1497 14.0577 49.1497 12.9528C49.1497 11.8397 48.364 11.1277 47.1691 11.1277H44.9102V16.8569ZM47.0954 11.9461C47.7666 11.9461 48.1921 12.3308 48.1921 12.9528C48.1921 13.5667 47.7584 13.9595 47.0872 13.9595H45.8514V11.9461H47.0954Z"),f(r,"fill","#A3BAD9"),f(i,"d","M51.5649 16.9059C52.8417 16.9059 53.701 16.0465 53.701 14.7615C53.701 13.4847 52.8417 12.6172 51.5649 12.6172C50.2881 12.6172 49.4287 13.4847 49.4287 14.7615C49.4287 16.0465 50.2881 16.9059 51.5649 16.9059ZM51.5649 16.1529C50.8201 16.1529 50.3372 15.5718 50.3372 14.7615C50.3372 13.9513 50.8201 13.3702 51.5649 13.3702C52.3097 13.3702 52.8007 13.9513 52.8007 14.7615C52.8007 15.5718 52.3097 16.1529 51.5649 16.1529Z"),f(i,"fill","#A3BAD9"),f(s,"d","M55.233 16.857H56.1906L57.1073 14.0088L57.9912 16.857H58.9406L60.332 12.6665H59.4317L58.4414 15.8748L57.5247 12.6665H56.7144L55.7568 15.8748L54.7992 12.6665H53.8662L55.233 16.857Z"),f(s,"fill","#A3BAD9"),f(o,"d","M62.6424 16.9059C63.6818 16.9059 64.3857 16.2757 64.533 15.449H63.6491C63.5263 15.9156 63.1335 16.1856 62.5933 16.1856C61.8976 16.1856 61.4475 15.7191 61.4229 15.0071V14.9498H64.5821C64.5985 14.8352 64.6067 14.7206 64.6067 14.6142C64.5821 13.3865 63.7719 12.6172 62.5605 12.6172C61.3247 12.6172 60.498 13.4766 60.498 14.7697C60.498 16.0547 61.3247 16.9059 62.6424 16.9059ZM61.4556 14.3032C61.5211 13.7057 62.004 13.3292 62.5687 13.3292C63.1826 13.3292 63.6164 13.6812 63.69 14.3032H61.4556Z"),f(o,"fill","#A3BAD9"),f(a,"d","M67.4411 12.6665C66.7536 12.6665 66.418 12.9448 66.2052 13.2967L66.107 12.6665H65.3213V16.857H66.2052V14.7536C66.2052 14.107 66.4589 13.4931 67.2447 13.4931H67.6375V12.6665H67.4411Z"),f(a,"fill","#A3BAD9"),f(l,"d","M69.9725 16.9059C71.0119 16.9059 71.7158 16.2757 71.8631 15.449H70.9792C70.8564 15.9156 70.4635 16.1856 69.9234 16.1856C69.2277 16.1856 68.7775 15.7191 68.753 15.0071V14.9498H71.9122C71.9286 14.8352 71.9368 14.7206 71.9368 14.6142C71.9122 13.3865 71.1019 12.6172 69.8906 12.6172C68.6548 12.6172 67.8281 13.4766 67.8281 14.7697C67.8281 16.0547 68.6548 16.9059 69.9725 16.9059ZM68.7857 14.3032C68.8512 13.7057 69.3341 13.3292 69.8988 13.3292C70.5127 13.3292 70.9464 13.6812 71.0201 14.3032H68.7857Z"),f(l,"fill","#A3BAD9"),f(c,"d","M75.8352 13.2475C75.5651 12.8792 75.1149 12.6173 74.4765 12.6173C73.3391 12.6173 72.4961 13.4685 72.4961 14.7616C72.4961 16.1039 73.3391 16.906 74.4765 16.906C75.1395 16.906 75.5733 16.5949 75.8433 16.2266L75.9497 16.8569H76.7191V11.1277H75.8352V13.2475ZM74.6238 16.1612C73.8875 16.1612 73.4046 15.5883 73.4046 14.7616C73.4046 13.9432 73.8875 13.3702 74.6238 13.3702C75.3605 13.3702 75.8433 13.9432 75.8433 14.778C75.8433 15.5883 75.3605 16.1612 74.6238 16.1612Z"),f(c,"fill","#A3BAD9"),f(u,"d","M81.9193 12.6173C81.2727 12.6173 80.839 12.9119 80.5607 13.2884V11.1277H79.6768V16.8569H80.4461L80.5525 16.2512C80.8144 16.6277 81.2646 16.906 81.9193 16.906C83.0652 16.906 83.9 16.0466 83.9 14.7616C83.9 13.4112 83.0652 12.6173 81.9193 12.6173ZM81.772 16.1612C81.0354 16.1612 80.5525 15.5801 80.5525 14.7534C80.5525 13.9432 81.0354 13.3702 81.772 13.3702C82.5086 13.3702 82.9997 13.9432 82.9997 14.7616C82.9997 15.5883 82.5086 16.1612 81.772 16.1612Z"),f(u,"fill","#A3BAD9"),f(d,"d","M85.6277 16.8815L85.4641 17.2908C85.3331 17.6345 85.2513 17.7164 84.9075 17.7164H84.2855V18.4939H85.2349C85.8487 18.4939 86.0288 18.1911 86.2907 17.5117L88.1895 12.6665H87.2483L86.1106 15.8503L84.9402 12.6665H83.999L85.6277 16.8815Z"),f(d,"fill","#A3BAD9"),f(h,"d","M45.1162 32.4821H47.2144V22.0654H45.1162V32.4821Z"),f(h,"fill","#A3BAD9"),f(p,"d","M49.7329 24.0148C50.4175 24.0148 50.9532 23.5088 50.9532 22.8392C50.9532 22.1546 50.4175 21.6487 49.7329 21.6487C49.0484 21.6487 48.5127 22.1546 48.5127 22.8392C48.5127 23.5088 49.0484 24.0148 49.7329 24.0148ZM48.6764 32.482H50.7895V24.8332H48.6764V32.482Z"),f(p,"fill","#A3BAD9"),f(E,"d","M54.2461 32.4823H56.8503L59.6033 24.8335H57.4009L55.5854 30.3394L53.7402 24.8335H51.4932L54.2461 32.4823Z"),f(E,"fill","#A3BAD9"),f(x,"d","M63.718 32.5713C65.7567 32.5713 67.0811 31.3808 67.3192 29.8927H65.2507C65.0722 30.607 64.4769 30.979 63.6287 30.979C62.5722 30.979 61.8728 30.3243 61.8281 29.2379V29.1338H67.3787C67.4234 28.8957 67.4382 28.6427 67.4382 28.4195C67.4085 26.1725 65.8609 24.7439 63.5692 24.7439C61.2031 24.7439 59.6406 26.2915 59.6406 28.6725C59.6406 31.0385 61.1734 32.5713 63.718 32.5713ZM61.8728 27.7647C61.9918 26.857 62.6763 26.3064 63.5841 26.3064C64.5365 26.3064 65.1763 26.8272 65.3251 27.7647H61.8728Z"),f(x,"fill","#A3BAD9"),f(k,"d","M72.9898 24.744C71.9332 24.744 71.1891 25.1904 70.6832 25.8005V22.0654H68.585V32.4821H70.4153L70.6237 31.4404C71.1148 32.0952 71.8737 32.5714 72.9749 32.5714C75.0434 32.5714 76.5315 31.0089 76.5315 28.6428C76.5315 26.2172 75.0434 24.744 72.9898 24.744ZM72.5136 30.8601C71.3678 30.8601 70.6534 29.9523 70.6534 28.6428C70.6534 27.3482 71.3678 26.4553 72.5136 26.4553C73.6594 26.4553 74.4035 27.3482 74.4035 28.6577C74.4035 29.9672 73.6594 30.8601 72.5136 30.8601Z"),f(k,"fill","#A3BAD9"),f(_,"d","M77.6973 32.4821H79.7955V22.0654H77.6973V32.4821Z"),f(_,"fill","#A3BAD9"),f(b,"d","M84.9927 32.5713C87.4332 32.5713 89.0254 31.0237 89.0254 28.6576C89.0254 26.3064 87.4332 24.7439 84.9927 24.7439C82.5522 24.7439 80.96 26.3064 80.96 28.6576C80.96 31.0088 82.5522 32.5713 84.9927 32.5713ZM84.9927 30.86C83.8171 30.86 83.1028 29.9522 83.1028 28.6576C83.1028 27.3629 83.8171 26.4552 84.9927 26.4552C86.1683 26.4552 86.8975 27.3629 86.8975 28.6576C86.8975 29.9522 86.1683 30.86 84.9927 30.86Z"),f(b,"fill","#A3BAD9"),f(S,"d","M93.7816 32.5713C95.865 32.5713 97.2489 31.4254 97.5465 29.5951H95.3441C95.1953 30.3689 94.6447 30.86 93.8263 30.86C92.7251 30.86 92.0257 29.9671 92.0257 28.6576C92.0257 27.3629 92.7251 26.4552 93.8263 26.4552C94.6447 26.4552 95.1655 26.9314 95.3441 27.6903H97.5316C97.234 25.8748 95.9394 24.7439 93.856 24.7439C91.4304 24.7439 89.8828 26.2915 89.8828 28.6576C89.8828 31.0683 91.356 32.5713 93.7816 32.5713Z"),f(S,"fill","#A3BAD9"),f(w,"d","M98.6514 32.4821H100.75V30.622L101.895 29.3869L103.83 32.4821H106.256L103.354 27.8392L106.107 24.8333H103.741L100.75 28.0773V22.0654H98.6514V32.4821Z"),f(w,"fill","#A3BAD9"),f(N,"d","M106.188 29.9375C106.277 31.5744 107.72 32.5714 109.848 32.5714C111.902 32.5714 113.33 31.6042 113.33 30.0863C113.33 28.3601 111.872 27.9583 110.116 27.7798C109.015 27.6458 108.36 27.5863 108.36 27.006C108.36 26.5149 108.896 26.2173 109.714 26.2173C110.562 26.2173 111.143 26.5893 111.202 27.1994H113.211C113.107 25.6369 111.693 24.7292 109.64 24.7292C107.676 24.7143 106.351 25.7113 106.351 27.2292C106.351 28.8065 107.735 29.2083 109.521 29.4167C110.756 29.5804 111.277 29.625 111.277 30.25C111.277 30.7857 110.741 31.0685 109.863 31.0685C108.836 31.0685 108.256 30.6071 108.182 29.9375H106.188Z"),f(N,"fill","#A3BAD9"),f(A,"d","M32.4824 8.67236H11.649C10.0053 8.67236 8.67285 10.0048 8.67285 11.6486V32.4819C8.67285 34.1256 10.0053 35.4581 11.649 35.4581H32.4824C34.1261 35.4581 35.4586 34.1256 35.4586 32.4819V11.6486C35.4586 10.0048 34.1261 8.67236 32.4824 8.67236Z"),f(A,"fill","url(#paint0_radial_253_107)"),f($,"fill-rule","evenodd"),f($,"clip-rule","evenodd"),f($,"d","M24.8953 17.78H15.0332L17.8712 20.7599V24.875L24.8953 17.78ZM19.2193 26.294H29.0814L26.2434 23.3141V19.199L19.2193 26.294Z"),f($,"fill","white"),f(H,"stop-color","#FF0099"),f(Y,"offset","1"),f(Y,"stop-color","#FF7A00"),f(T,"id","paint0_radial_253_107"),f(T,"cx","0"),f(T,"cy","0"),f(T,"r","1"),f(T,"gradientUnits","userSpaceOnUse"),f(T,"gradientTransform","translate(4.7524 1.97593) rotate(45.3703) scale(40.7748 35.4976)"),f(t,"class",e[0]),f(t,"width","123"),f(t,"height","44"),f(t,"viewBox","0 0 123 44"),f(t,"fill","none"),f(t,"xmlns","http://www.w3.org/2000/svg")},m(Z,j){ne(Z,t,j),m(t,n),m(t,r),m(t,i),m(t,s),m(t,o),m(t,a),m(t,l),m(t,c),m(t,u),m(t,d),m(t,h),m(t,p),m(t,E),m(t,x),m(t,k),m(t,_),m(t,b),m(t,S),m(t,w),m(t,N),m(t,A),m(t,$),m(t,V),m(V,T),m(T,H),m(T,Y)},p(Z,[j]){j&1&&f(t,"class",Z[0])},i:ue,o:ue,d(Z){Z&&v(t)}}}function hh(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class dh extends be{constructor(t){super(),Ee(this,t,hh,fh,ke,{classList:0})}}function ph(e){let t,n,r,i,s,o,a,l,c,u,d,h,p,E,x,k,_,b,S,w,N,A,$,V,T,H,Y,Z,j,y,O,C,P,R;return y=new dh({props:{classList:"ml-2"}}),{c(){t=D("div"),n=D("div"),r=D("h2"),i=q("Stable Difussion Multiplayer"),s=ie(),o=D("p"),a=q("Powered by Hugging Face face GPU Spaces "),l=D("a"),c=q("https://huggingface.co/docs/hub/spaces-gpus"),u=q(` Diffusers `),d=D("a"),h=q("https://huggingface.co/docs/diffusers/index"),p=ie(),E=D("p"),x=q("Thanks to "),k=D("a"),_=q("Lnyan"),b=q(` for the original outpaiting technique implemented on `),S=D("a"),w=q(`Stable Diffusion Infinity `),N=q("."),A=ie(),$=D("p"),V=q(`Runwayml Inpaiting Stable Diffusion `),T=D("a"),H=q("https://github.com/runwayml/stable-diffusion"),Y=ie(),Z=D("p"),j=q(`Multiplayer API by `),pe(y.$$.fragment),this.h()},l(z){t=U(z,"DIV",{class:!0});var B=I(t);n=U(B,"DIV",{class:!0});var te=I(n);r=U(te,"H2",{class:!0});var ae=I(r);i=G(ae,"Stable Difussion Multiplayer"),ae.forEach(v),s=se(te),o=U(te,"P",{});var fe=I(o);a=G(fe,"Powered by Hugging Face face GPU Spaces "),l=U(fe,"A",{href:!0,class:!0});var oe=I(l);c=G(oe,"https://huggingface.co/docs/hub/spaces-gpus"),oe.forEach(v),u=G(fe,` Diffusers `),d=U(fe,"A",{href:!0,class:!0});var xe=I(d);h=G(xe,"https://huggingface.co/docs/diffusers/index"),xe.forEach(v),fe.forEach(v),p=se(te),E=U(te,"P",{});var ye=I(E);x=G(ye,"Thanks to "),k=U(ye,"A",{href:!0,target:!0,rel:!0,class:!0});var Ie=I(k);_=G(Ie,"Lnyan"),Ie.forEach(v),b=G(ye,` for the original outpaiting technique implemented on `),S=U(ye,"A",{href:!0,target:!0,rel:!0,class:!0});var Ce=I(S);w=G(Ce,`Stable Diffusion Infinity `),Ce.forEach(v),N=G(ye,"."),ye.forEach(v),A=se(te),$=U(te,"P",{class:!0});var qe=I($);V=G(qe,`Runwayml Inpaiting Stable Diffusion `),T=U(qe,"A",{href:!0,target:!0,rel:!0});var At=I(T);H=G(At,"https://github.com/runwayml/stable-diffusion"),At.forEach(v),qe.forEach(v),Y=se(te),Z=U(te,"P",{class:!0});var Ct=I(Z);j=G(Ct,`Multiplayer API by `),me(y.$$.fragment,Ct),Ct.forEach(v),te.forEach(v),B.forEach(v),this.h()},h(){f(r,"class","font-bold text-xl font-mono mb-8"),f(l,"href","https://huggingface.co/docs/hub/spaces-gpus"),f(l,"class","text-blue-400 hover:text-blue-600 underline"),f(d,"href","https://huggingface.co/docs/diffusers/index"),f(d,"class","text-blue-400 hover:text-blue-600 underline"),f(k,"href","https://twitter.com/lkwq007"),f(k,"target","_blank"),f(k,"rel","noopener noreferrer"),f(k,"class","text-blue-400 hover:text-blue-600 underline"),f(S,"href","https://github.com/lkwq007/stablediffusion-infinity"),f(S,"target","_blank"),f(S,"rel","noopener noreferrer"),f(S,"class","text-blue-400 hover:text-blue-600 underline"),f(T,"href","https://github.com/runwayml/stable-diffusion"),f(T,"target","_blank"),f(T,"rel","noopener noreferrer"),f($,"class","mb-6"),f(Z,"class","text-base flex items-center"),f(n,"class","max-w-md"),f(t,"class",O="fixed "+e[0]+" w-screen h-screen top-0 left-0 bottom-0 right-0 z-50 items-center justify-center bg-black text-white bg-opacity-90 px-3 overflow-y-scroll")},m(z,B){ne(z,t,B),m(t,n),m(n,r),m(r,i),m(n,s),m(n,o),m(o,a),m(o,l),m(l,c),m(o,u),m(o,d),m(d,h),m(n,p),m(n,E),m(E,x),m(E,k),m(k,_),m(E,b),m(E,S),m(S,w),m(E,N),m(n,A),m(n,$),m($,V),m($,T),m(T,H),m(n,Y),m(n,Z),m(Z,j),_e(y,Z,null),C=!0,P||(R=Me(t,"click",e[1]),P=!0)},p(z,[B]){(!C||B&1&&O!==(O="fixed "+z[0]+" w-screen h-screen top-0 left-0 bottom-0 right-0 z-50 items-center justify-center bg-black text-white bg-opacity-90 px-3 overflow-y-scroll"))&&f(t,"class",O)},i(z){C||(X(y.$$.fragment,z),C=!0)},o(z){W(y.$$.fragment,z),C=!1},d(z){z&&v(t),ge(y),P=!1,R()}}}function mh(e,t,n){let{classList:r=""}=t;function i(s){lr.call(this,e,s)}return e.$$set=s=>{"classList"in s&&n(0,r=s.classList)},[r,i]}class _h extends be{constructor(t){super(),Ee(this,t,mh,ph,ke,{classList:0})}}function gh(e){let t,n;return t=new ka({props:{client:e[1],$$slots:{default:[Eh]},$$scope:{ctx:e}}}),{c(){pe(t.$$.fragment)},l(r){me(t.$$.fragment,r)},m(r,i){_e(t,r,i),n=!0},p(r,i){const s={};i&2&&(s.client=r[1]),i&260&&(s.$$scope={dirty:i,ctx:r}),t.$set(s)},i(r){n||(X(t.$$.fragment,r),n=!0)},o(r){W(t.$$.fragment,r),n=!1},d(r){ge(t,r)}}}function vh(e){let t,n,r,i,s,o;return n=new kn({props:{classList:"inline-block animate-spin p-1 mr-2"}}),{c(){t=D("div"),pe(n.$$.fragment),r=ie(),i=D("h1"),s=q("Loading..."),this.h()},l(a){t=U(a,"DIV",{class:!0});var l=I(t);me(n.$$.fragment,l),r=se(l),i=U(l,"H1",{class:!0});var c=I(i);s=G(c,"Loading..."),c.forEach(v),l.forEach(v),this.h()},h(){f(i,"class","font-bold inline-block"),f(t,"class","text-4xl text-black flex justify-center items-center mb-4 w-screen h-screen")},m(a,l){ne(a,t,l),_e(n,t,null),m(t,r),m(t,i),m(i,s),o=!0},p:ue,i(a){o||(X(n.$$.fragment,a),o=!0)},o(a){W(n.$$.fragment,a),o=!1},d(a){a&&v(t),ge(n)}}}function yh(e){let t,n,r,i,s,o;return{c(){t=D("div"),n=D("h1"),r=q("No room selected"),i=ie(),s=D("p"),o=q("Please select a room in the URL"),this.h()},l(a){t=U(a,"DIV",{class:!0});var l=I(t);n=U(l,"H1",{class:!0});var c=I(n);r=G(c,"No room selected"),c.forEach(v),i=se(l),s=U(l,"P",{class:!0});var u=I(s);o=G(u,"Please select a room in the URL"),u.forEach(v),l.forEach(v),this.h()},h(){f(n,"class","text-2xl font-bold"),f(s,"class","text-gray-500"),f(t,"class","flex flex-col items-center justify-center h-full")},m(a,l){ne(a,t,l),m(t,n),m(n,r),m(t,i),m(t,s),m(s,o)},p:ue,i:ue,o:ue,d(a){a&&v(t)}}}function wh(e){let t,n;return t=new Oa({props:{id:e[2],initialPresence:e[4],$$slots:{default:[bh]},$$scope:{ctx:e}}}),{c(){pe(t.$$.fragment)},l(r){me(t.$$.fragment,r)},m(r,i){_e(t,r,i),n=!0},p(r,i){const s={};i&4&&(s.id=r[2]),i&256&&(s.$$scope={dirty:i,ctx:r}),t.$set(s)},i(r){n||(X(t.$$.fragment,r),n=!0)},o(r){W(t.$$.fragment,r),n=!1},d(r){ge(t,r)}}}function bh(e){let t,n;return t=new uh({}),{c(){pe(t.$$.fragment)},l(r){me(t.$$.fragment,r)},m(r,i){_e(t,r,i),n=!0},i(r){n||(X(t.$$.fragment,r),n=!0)},o(r){W(t.$$.fragment,r),n=!1},d(r){ge(t,r)}}}function Eh(e){let t,n,r,i;const s=[wh,yh],o=[];function a(l,c){return l[2]?0:1}return t=a(e),n=o[t]=s[t](e),{c(){n.c(),r=Ye()},l(l){n.l(l),r=Ye()},m(l,c){o[t].m(l,c),ne(l,r,c),i=!0},p(l,c){let u=t;t=a(l),t===u?o[t].p(l,c):(Le(),W(o[u],1,1,()=>{o[u]=null}),Te(),n=o[t],n?n.p(l,c):(n=o[t]=s[t](l),n.c()),X(n,1),n.m(r.parentNode,r))},i(l){i||(X(n),i=!0)},o(l){W(n),i=!1},d(l){o[t].d(l),l&&v(r)}}}function kh(e){let t,n,r,i,s,o;t=new _h({props:{classList:e[3]?"flex":"hidden"}}),t.$on("click",e[6]);const a=[vh,gh],l=[];function c(u,d){return u[0]?0:1}return r=c(e),i=l[r]=a[r](e),{c(){pe(t.$$.fragment),n=ie(),i.c(),s=Ye()},l(u){me(t.$$.fragment,u),n=se(u),i.l(u),s=Ye()},m(u,d){_e(t,u,d),ne(u,n,d),l[r].m(u,d),ne(u,s,d),o=!0},p(u,[d]){const h={};d&8&&(h.classList=u[3]?"flex":"hidden"),t.$set(h);let p=r;r=c(u),r===p?l[r].p(u,d):(Le(),W(l[p],1,1,()=>{l[p]=null}),Te(),i=l[r],i?i.p(u,d):(i=l[r]=a[r](u),i.c()),X(i,1),i.m(s.parentNode,s))},i(u){o||(X(t.$$.fragment,u),X(i),o=!0)},o(u){W(t.$$.fragment,u),W(i),o=!1},d(u){ge(t,u),u&&v(n),l[r].d(u),u&&v(s)}}}function xh(e,t,n){let r,i,s;we(e,Nt,d=>n(5,i=d)),we(e,vn,d=>n(3,s=d));let o=!0,a;Kt(()=>{n(1,a=wa({authEndpoint:hn+"/auth"})),l()});async function l(){n(0,o=!0);const d=new URLSearchParams(window.location.search).get("roomid"),p=await(await fetch(hn+"/rooms")).json();if(d)p.find(x=>x.room_id===d)&&Nt.set(d);else{const E=p.find(x=>x.users_countAe(vn,s=!1,s);return e.$$.update=()=>{e.$$.dirty&32&&n(2,r=i)},[o,a,r,s,c,i,u]}class Ch extends be{constructor(t){super(),Ee(this,t,xh,kh,ke,{})}}export{Ch as default};