liveroom-client-element 0.0.47 → 0.0.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";const e="liveroom-client-element",t="0.0.47",i="module",_="./dist/main.js",s="./dist/main.cjs",o=["dist","!dist/vite.svg"],n={".":{import:"./dist/main.js",require:"./dist/main.cjs"},"./liveroom-client-element":{import:"./dist/liveroom-client-element.js",require:"./dist/liveroom-client-element.cjs"}},E={dev:"vite",build:"vite build",preview:"vite preview",format:"prettier --write .","check-format":"prettier . --check",check:"svelte-check --tsconfig ./tsconfig.json",lint:"npm run check-format && npm run check"},c={"livekit-client":"2.0.10","phx-live-state":"0.11.2"},r={"@sveltejs/vite-plugin-svelte":"3.0.2","@tsconfig/svelte":"5.0.3",prettier:"3.2.5",svelte:"4.2.12","svelte-check":"3.6.8",tslib:"2.6.2",typescript:"5.4.3",vite:"5.2.6"},O={name:e,private:!1,version:t,type:i,module:_,main:s,files:o,exports:n,scripts:E,dependencies:c,devDependencies:r},R=O.version,l="liveroom-client-element",S="_liveroom_id",m="_liveroom_token",v="_liveroom_user_name",A="_liveroom_user_color",p="liveroom-id",d="liveroom-token",Y="liveroom-user-name",M="liveroom-user-color";exports.ELEMENT_TAG=l;exports.QUERY_PARAM_KEY_ROOM_ID=S;exports.QUERY_PARAM_KEY_ROOM_TOKEN=m;exports.QUERY_PARAM_KEY_USER_COLOR=A;exports.QUERY_PARAM_KEY_USER_NAME=v;exports.SESSION_STORAGE_KEY_ROOM_ID=p;exports.SESSION_STORAGE_KEY_ROOM_TOKEN=d;exports.SESSION_STORAGE_KEY_USER_COLOR=M;exports.SESSION_STORAGE_KEY_USER_NAME=Y;exports.VERSION=R;
1
+ "use strict";const e="liveroom-client-element",t="0.0.48",i="module",_="./dist/main.js",s="./dist/main.cjs",o=["dist","!dist/vite.svg"],n={".":{import:"./dist/main.js",require:"./dist/main.cjs"},"./liveroom-client-element":{import:"./dist/liveroom-client-element.js",require:"./dist/liveroom-client-element.cjs"}},E={dev:"vite",build:"vite build",preview:"vite preview",format:"prettier --write .","check-format":"prettier . --check",check:"svelte-check --tsconfig ./tsconfig.json",lint:"npm run check-format && npm run check"},c={"livekit-client":"2.0.10","phx-live-state":"0.11.2"},r={"@sveltejs/vite-plugin-svelte":"3.0.2","@tsconfig/svelte":"5.0.3",prettier:"3.2.5",svelte:"4.2.12","svelte-check":"3.6.8",tslib:"2.6.2",typescript:"5.4.3",vite:"5.2.6"},O={name:e,private:!1,version:t,type:i,module:_,main:s,files:o,exports:n,scripts:E,dependencies:c,devDependencies:r},R=O.version,l="liveroom-client-element",S="_liveroom_id",m="_liveroom_token",v="_liveroom_user_name",A="_liveroom_user_color",p="liveroom-id",d="liveroom-token",Y="liveroom-user-name",M="liveroom-user-color";exports.ELEMENT_TAG=l;exports.QUERY_PARAM_KEY_ROOM_ID=S;exports.QUERY_PARAM_KEY_ROOM_TOKEN=m;exports.QUERY_PARAM_KEY_USER_COLOR=A;exports.QUERY_PARAM_KEY_USER_NAME=v;exports.SESSION_STORAGE_KEY_ROOM_ID=p;exports.SESSION_STORAGE_KEY_ROOM_TOKEN=d;exports.SESSION_STORAGE_KEY_USER_COLOR=M;exports.SESSION_STORAGE_KEY_USER_NAME=Y;exports.VERSION=R;
@@ -1,4 +1,4 @@
1
- const e = "liveroom-client-element", t = "0.0.47", s = "module", i = "./dist/main.js", o = "./dist/main.cjs", n = [
1
+ const e = "liveroom-client-element", t = "0.0.48", s = "module", i = "./dist/main.js", o = "./dist/main.cjs", n = [
2
2
  "dist",
3
3
  "!dist/vite.svg"
4
4
  ], c = {
@@ -1,4 +1,4 @@
1
- "use strict";var Tc=Object.defineProperty;var Cc=(n,e,t)=>e in n?Tc(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var x=(n,e,t)=>(Cc(n,typeof e!="symbol"?e+"":e,t),t);const Fs=require("./constants-BimsT71j.cjs");function gn(){}function zr(n){return n()}function Bs(){return Object.create(null)}function Sn(n){n.forEach(zr)}function Wr(n){return typeof n=="function"}function Sc(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function _c(n){return Object.keys(n).length===0}function we(n,e){n.appendChild(e)}function Ec(n,e,t){const i=wc(n);if(!i.getElementById(e)){const s=Ne("style");s.id=e,s.textContent=t,Pc(i,s)}}function wc(n){if(!n)return document;const e=n.getRootNode?n.getRootNode():n.ownerDocument;return e&&e.host?e:n.ownerDocument}function Pc(n,e){return we(n.head||n,e),e.sheet}function Tt(n,e,t){n.insertBefore(e,t||null)}function ut(n){n.parentNode&&n.parentNode.removeChild(n)}function Ne(n){return document.createElement(n)}function Vs(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function ps(n){return document.createTextNode(n)}function tn(){return ps(" ")}function Rc(){return ps("")}function V(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Ic(n){return Array.from(n.childNodes)}function Oc(n,e){e=""+e,n.data!==e&&(n.data=e)}function Ve(n,e,t,i){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,i?"important":"")}function Mc(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let vn;function on(n){vn=n}function Jr(){if(!vn)throw new Error("Function called outside component initialization");return vn}function xc(n){Jr().$$.on_mount.push(n)}function Ac(n){Jr().$$.on_destroy.push(n)}const Dt=[],Ai=[];let Ut=[];const $s=[],Dc=Promise.resolve();let Di=!1;function Nc(){Di||(Di=!0,Dc.then(ct))}function Ni(n){Ut.push(n)}const bi=new Set;let Ot=0;function ct(){if(Ot!==0)return;const n=vn;do{try{for(;Ot<Dt.length;){const e=Dt[Ot];Ot++,on(e),Lc(e.$$)}}catch(e){throw Dt.length=0,Ot=0,e}for(on(null),Dt.length=0,Ot=0;Ai.length;)Ai.pop()();for(let e=0;e<Ut.length;e+=1){const t=Ut[e];bi.has(t)||(bi.add(t),t())}Ut.length=0}while(Dt.length);for(;$s.length;)$s.pop()();Di=!1,bi.clear(),on(n)}function Lc(n){if(n.fragment!==null){n.update(),Sn(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(Ni)}}function Uc(n){const e=[],t=[];Ut.forEach(i=>n.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),Ut=e}const jc=new Set;function Kr(n,e){n&&n.i&&(jc.delete(n),n.i(e))}function Hs(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Fc(n,e){n.d(1),e.delete(n.key)}function Bc(n,e,t,i,s,r,a,o,c,d,l,u){let p=n.length,m=r.length,k=p;const v={};for(;k--;)v[n[k].key]=k;const S=[],O=new Map,P=new Map,F=[];for(k=m;k--;){const N=u(s,r,k),X=t(N);let A=a.get(X);A?i&&F.push(()=>A.p(N,e)):(A=d(X,N),A.c()),O.set(X,S[k]=A),X in v&&P.set(X,Math.abs(k-v[X]))}const W=new Set,he=new Set;function le(N){Kr(N,1),N.m(o,l),a.set(N.key,N),l=N.first,m--}for(;p&&m;){const N=S[m-1],X=n[p-1],A=N.key,H=X.key;N===X?(l=N.first,p--,m--):O.has(H)?!a.has(A)||W.has(A)?le(N):he.has(H)?p--:P.get(A)>P.get(H)?(he.add(A),le(N)):(W.add(H),p--):(c(X,a),p--)}for(;p--;){const N=n[p];O.has(N.key)||c(N,a)}for(;m;)le(S[m-1]);return Sn(F),S}function Vc(n,e,t){const{fragment:i,after_update:s}=n.$$;i&&i.m(e,t),Ni(()=>{const r=n.$$.on_mount.map(zr).filter(Wr);n.$$.on_destroy?n.$$.on_destroy.push(...r):Sn(r),n.$$.on_mount=[]}),s.forEach(Ni)}function $c(n,e){const t=n.$$;t.fragment!==null&&(Uc(t.after_update),Sn(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Hc(n,e){n.$$.dirty[0]===-1&&(Dt.push(n),Nc(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function qc(n,e,t,i,s,r,a=null,o=[-1]){const c=vn;on(n);const d=n.$$={fragment:null,ctx:[],props:r,update:gn,not_equal:s,bound:Bs(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(c?c.$$.context:[])),callbacks:Bs(),dirty:o,skip_bound:!1,root:e.target||c.$$.root};a&&a(d.root);let l=!1;if(d.ctx=t?t(n,e.props||{},(u,p,...m)=>{const k=m.length?m[0]:p;return d.ctx&&s(d.ctx[u],d.ctx[u]=k)&&(!d.skip_bound&&d.bound[u]&&d.bound[u](k),l&&Hc(n,u)),p}):[],d.update(),l=!0,Sn(d.before_update),d.fragment=i?i(d.ctx):!1,e.target){if(e.hydrate){const u=Ic(e.target);d.fragment&&d.fragment.l(u),u.forEach(ut)}else d.fragment&&d.fragment.c();e.intro&&Kr(n.$$.fragment),Vc(n,e.target,e.anchor),ct()}on(c)}let Qr;typeof HTMLElement=="function"&&(Qr=class extends HTMLElement{constructor(e,t,i){super();x(this,"$$ctor");x(this,"$$s");x(this,"$$c");x(this,"$$cn",!1);x(this,"$$d",{});x(this,"$$r",!1);x(this,"$$p_d",{});x(this,"$$l",{});x(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,i&&this.attachShadow({mode:"open"})}addEventListener(e,t,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const s=this.$$c.$on(e,t);this.$$l_u.set(t,s)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){const s=this.$$l_u.get(t);s&&(s(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(r){return()=>{let a;return{c:function(){a=Ne("slot"),r!=="default"&&V(a,"name",r)},m:function(d,l){Tt(d,a,l)},d:function(d){d&&ut(a)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=Mc(this);for(const r of this.$$s)r in i&&(t[r]=[e(r)]);for(const r of this.attributes){const a=this.$$g_p(r.name);a in this.$$d||(this.$$d[a]=jn(a,r.value,this.$$p_d,"toProp"))}for(const r in this.$$p_d)!(r in this.$$d)&&this[r]!==void 0&&(this.$$d[r]=this[r],delete this[r]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const s=()=>{this.$$r=!0;for(const r in this.$$p_d)if(this.$$d[r]=this.$$c.$$.ctx[this.$$c.$$.props[r]],this.$$p_d[r].reflect){const a=jn(r,this.$$d[r],this.$$p_d,"toAttribute");a==null?this.removeAttribute(this.$$p_d[r].attribute||r):this.setAttribute(this.$$p_d[r].attribute||r,a)}this.$$r=!1};this.$$c.$$.after_update.push(s),s();for(const r in this.$$l)for(const a of this.$$l[r]){const o=this.$$c.$on(r,a);this.$$l_u.set(a,o)}this.$$l={}}}attributeChangedCallback(e,t,i){var s;this.$$r||(e=this.$$g_p(e),this.$$d[e]=jn(e,i,this.$$p_d,"toProp"),(s=this.$$c)==null||s.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function jn(n,e,t,i){var r;const s=(r=t[n])==null?void 0:r.type;if(e=s==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[n])return e;if(i==="toAttribute")switch(s){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(s){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function Gc(n,e,t,i,s,r){let a=class extends Qr{constructor(){super(n,t,s),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(o=>(e[o].attribute||o).toLowerCase())}};return Object.keys(e).forEach(o=>{Object.defineProperty(a.prototype,o,{get(){return this.$$c&&o in this.$$c?this.$$c[o]:this.$$d[o]},set(c){var d;c=jn(o,c,e),this.$$d[o]=c,(d=this.$$c)==null||d.$set({[o]:c})}})}),i.forEach(o=>{Object.defineProperty(a.prototype,o,{get(){var c;return(c=this.$$c)==null?void 0:c[o]}})}),r&&(a=r(a)),n.element=a,a}class zc{constructor(){x(this,"$$");x(this,"$$set")}$destroy(){$c(this,1),this.$destroy=gn}$on(e,t){if(!Wr(t))return gn;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}$set(e){this.$$set&&!_c(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Wc="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Wc);const{isArray:Jc}=Array,Kc=Object.keys,kn=n=>{if(!n)return n;if(Jc(n)){const e=[],t=n.length;for(let i=0;i<t;i++)e.push(kn(n[i]));return e}else if(typeof n=="object"){const e=Kc(n),t=e.length,i={};for(let s=0;s<t;s++){const r=e[s];i[r]=kn(n[r])}return i}return n};class Re{constructor(e){x(this,"path");x(this,"from");this.path=e}}const Qc=/~1/g,Yc=/~0/g,Xc=/~/g,Zc=/\//g;function ed(n){return n.indexOf("~")===-1?n:n.replace(Qc,"/").replace(Yc,"~")}function td(n){return n.indexOf("/")===-1&&n.indexOf("~")===-1?n:n.replace(Xc,"~0").replace(Zc,"~1")}function nd(n){return n?n.slice(1).split("/").map(ed):[]}function z(n){return id(n)?"":"/"+n.map(e=>td(String(e))).join("/")}const B=n=>typeof n=="string"?nd(n):n,id=n=>!n.length,sd=Object.prototype.hasOwnProperty;function rd(n,e){return sd.call(n,e)}const{isArray:Yr}=Array,ne=(n,e)=>{const t=e.length;if(!t)return{val:n};let i,s;for(let a=0;a<t;a++)if(i=n,s=e[a],Yr(i)){const o=i.length;if(s==="-")s=o;else if(typeof s=="string"){const c=~~s;if(""+c!==s)throw new Error("INVALID_INDEX");if(s=c,s<0)throw new Error("INVALID_INDEX")}n=i[s]}else if(typeof i=="object"&&i)n=rd(i,s)?i[s]:void 0;else throw new Error("NOT_FOUND");return{val:n,obj:i,key:s}},_n=n=>Yr(n.obj)&&typeof n.key=="number",ai=n=>typeof n.obj=="object"&&typeof n.key=="string";class fs extends Re{constructor(t,i){super(t);x(this,"value");this.value=i}op(){return"add"}code(){return 0}apply(t){const{val:i,key:s,obj:r}=ne(t,this.path),a=kn(this.value);if(!r)t=a;else if(typeof s=="string")r[s]=a;else{const o=r.length;if(s<o)r.splice(s,0,a);else{if(s>o)throw new Error("INVALID_INDEX");r.push(a)}}return{doc:t,old:i}}toJson(t){return{op:"add",path:z(this.path),value:this.value}}toCompact(t,i){return[i?"add":0,this.path,this.value]}encode(t){t.encodeArrayHeader(3),t.writer.u8(0),t.encodeArray(this.path),t.encodeAny(this.value)}}class Xr extends Re{constructor(t,i){super(t);x(this,"oldValue");this.oldValue=i}op(){return"remove"}code(){return 1}apply(t){const i=ne(t,this.path);if(i.val===void 0)throw new Error("NOT_FOUND");return ai(i)?delete i.obj[i.key]:_n(i)?i.val!==void 0&&i.obj.splice(i.key,1):t=null,{doc:t,old:i.val}}toJson(t){const i={op:"remove",path:z(this.path)};return this.oldValue!==void 0&&(i.oldValue=this.oldValue),i}toCompact(t,i){const s=i?"remove":1;return this.oldValue===void 0?[s,this.path]:[s,this.path,this.oldValue]}encode(t,i){const s=this.oldValue!==void 0;t.encodeArrayHeader(s?3:2),t.writer.u8(1),t.encodeArray(this.path),s&&t.encodeAny(this.oldValue)}}class ad extends Re{constructor(t,i,s){super(t);x(this,"value");x(this,"oldValue");this.value=i,this.oldValue=s}op(){return"replace"}code(){return 2}apply(t){const i=ne(t,this.path);if(i.val===void 0)throw new Error("NOT_FOUND");return ai(i)?i.obj[i.key]=this.value:_n(i)?i.obj[i.key]=this.value:t=this.value,{doc:t,old:i.val}}toJson(t){const i={op:"replace",path:z(this.path),value:this.value};return this.oldValue!==void 0&&(i.oldValue=this.oldValue),i}toCompact(t,i){const s=i?"replace":2;return this.oldValue===void 0?[s,this.path,this.value]:[s,this.path,this.value,this.oldValue]}encode(t,i){const s=this.oldValue!==void 0;t.encodeArrayHeader(s?4:3),t.writer.u8(2),t.encodeArray(this.path),t.encodeAny(this.value),s&&t.encodeAny(this.oldValue)}}class od extends Re{constructor(t,i){super(t);x(this,"from");this.from=i}op(){return"move"}code(){return 4}apply(t){const i=new Xr(B(this.from),void 0).apply(t);return new fs(this.path,i.old).apply(i.doc)}toJson(t){return{op:"move",path:z(this.path),from:z(this.from)}}toCompact(t,i){return[i?"move":4,this.path,this.from]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(4),t.encodeArray(this.path),t.encodeArray(this.from)}}class cd extends Re{constructor(t,i){super(t);x(this,"from");this.from=i}op(){return"copy"}code(){return 3}apply(t){const{val:i}=ne(t,this.from);if(i===void 0)throw new Error("NOT_FOUND");return new fs(this.path,kn(i)).apply(t)}toJson(t){return{op:"copy",path:z(this.path),from:z(this.from)}}toCompact(t,i){return[i?"copy":3,this.path,this.from]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(3),t.encodeArray(this.path),t.encodeArray(this.from)}}class Se extends Re{apply(e){if(!this.test(e))throw new Error("TEST");return{doc:e}}}const Qn=(n,e)=>{if(n===e)return!0;if(n&&e&&typeof n=="object"&&typeof e=="object"){if(n.constructor!==e.constructor)return!1;let t,i,s;if(Array.isArray(n)){if(t=n.length,t!==e.length)return!1;for(i=t;i--!==0;)if(!Qn(n[i],e[i]))return!1;return!0}if(s=Object.keys(n),t=s.length,t!==Object.keys(e).length)return!1;for(i=t;i--!==0;){const r=s[i];if(!Qn(n[r],e[r]))return!1}return!0}return!1};class dd extends Se{constructor(t,i,s){super(t);x(this,"value");x(this,"not");this.value=i,this.not=s}op(){return"test"}code(){return 5}test(t){const{val:i}=ne(t,this.path);if(i===void 0)return!!this.not;const s=Qn(i,this.value);return this.not?!s:s}toJson(t){const i={op:"test",path:z(t?this.path.slice(t.path.length):this.path),value:this.value};return this.not&&(i.not=this.not),i}toCompact(t,i){const s=t?this.path.slice(t.path.length):this.path,r=i?"test":5;return this.not?[r,s,this.value,1]:[r,s,this.value]}encode(t,i){t.encodeArrayHeader(this.not?4:3),t.writer.u8(5),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeAny(this.value),this.not&&t.writer.u8(1)}}class ld extends Re{constructor(e){super(e)}op(){return"flip"}code(){return 8}apply(e){const t=ne(e,this.path);return t.obj?t.obj[t.key]=!t.val:e=!t.val,{doc:e,old:t.val}}toJson(e){return{op:"flip",path:z(this.path)}}toCompact(e,t){return[t?"flip":8,this.path]}encode(e,t){e.encodeArrayHeader(2),e.writer.u8(8),e.encodeArray(this.path)}}class ud extends Re{constructor(t,i){super(t);x(this,"inc");this.inc=i}op(){return"inc"}code(){return 9}apply(t){const i=ne(t,this.path),s=this.inc+Number(i.val);return i.obj?i.obj[i.key]=s:t=s,{doc:t,old:i.val}}toJson(t){return{op:"inc",path:z(this.path),inc:this.inc}}toCompact(t,i){return[i?"inc":9,this.path,this.inc]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(9),t.encodeArray(this.path),t.encodeNumber(this.inc)}}class hd extends Re{constructor(t,i,s){super(t);x(this,"pos");x(this,"str");this.pos=i,this.str=s}op(){return"str_ins"}code(){return 6}apply(t){const{val:i,key:s,obj:r}=ne(t,this.path);if(typeof i!="string"){if(i!==void 0)throw new Error("NOT_A_STRING");if(this.pos!==0)throw new Error("POS")}const a=typeof i=="string"?i:"",o=Math.min(this.pos,a.length),c=a.slice(0,o),d=a.slice(o),l=c+this.str+d;return r?r[s]=l:t=l,{doc:t,old:i}}toJson(t){return{op:"str_ins",path:z(this.path),pos:this.pos,str:this.str}}toCompact(t,i){return[i?"str_ins":6,this.path,this.pos,this.str]}encode(t,i){t.encodeArrayHeader(4),t.writer.u8(6),t.encodeArray(this.path),t.encodeNumber(this.pos),t.encodeString(this.str)}}class pd extends Re{constructor(t,i,s,r){super(t);x(this,"pos");x(this,"str");x(this,"len");this.pos=i,this.str=s,this.len=r}op(){return"str_del"}code(){return 7}deleteLength(){return typeof this.str=="string"?this.str.length:this.len}apply(t){const{val:i,key:s,obj:r}=ne(t,this.path);if(typeof i!="string")throw new Error("NOT_A_STRING");const a=i.length,o=Math.min(this.pos,i.length),c=Math.min(o,a),d=this.str!==void 0?this.str.length:this.len,l=Math.min(o+d,a),u=i.slice(0,c),p=i.substr(l),m=u+p;return r?r[s]=m:t=m,{doc:t,old:i}}toJson(t){return typeof this.str=="string"?{op:"str_del",path:z(this.path),pos:this.pos,str:this.str}:{op:"str_del",path:z(this.path),pos:this.pos,len:this.len}}toCompact(t,i){const s=i?"str_del":7;return typeof this.str=="string"?[s,this.path,this.pos,this.str]:[s,this.path,this.pos,0,this.len]}encode(t,i){const s=typeof this.str=="string";t.encodeArrayHeader(s?4:5),t.writer.u8(7),t.encodeArray(this.path),t.encodeNumber(this.pos),s?t.encodeString(this.str):(t.writer.u8(0),t.encodeNumber(this.len))}}const{isArray:fd}=Array,Li=n=>!!n&&typeof n=="object"&&typeof n.text=="string",Ui=n=>!!n&&typeof n=="object"&&fd(n.children),md=(n,e)=>{const t=new RegExp(n,e?"i":void 0);return i=>t.test(i)};class gd extends Re{constructor(t,i,s){super(t);x(this,"pos");x(this,"props");this.pos=i,this.props=s}op(){return"split"}code(){return 10}apply(t){const i=ne(t,this.path);if(i.val===void 0)throw new Error("NOT_FOUND");const s=this.split(i.val);return ai(i)?i.obj[i.key]=s:_n(i)?(i.obj[i.key]=s[0],i.obj.splice(i.key+1,0,s[1])):t=s,{doc:t,old:i.val}}split(t){if(typeof t=="string"){const{pos:i,props:s}=this,r=t.slice(0,i),a=t.slice(i);return s?[{...s,text:r},{...s,text:a}]:[r,a]}else if(Li(t)){const{pos:i,props:s}=this,r=t.text.slice(0,i),a=t.text.slice(i);return[{...t,...s,text:r},{...t,...s,text:a}]}else if(Ui(t)){const{pos:i,props:s}=this,r=t.children.slice(0,i),a=t.children.slice(i);return[{...t,...s,children:r},{...t,...s,children:a}]}else if(typeof t=="number"){const{pos:i}=this;return[i,t-i]}else return[t,t]}toJson(t){const i={op:"split",path:z(this.path),pos:this.pos};return this.props&&(i.props=this.props),i}toCompact(t,i){const s=i?"split":10;return this.props?[s,this.path,this.pos,this.props]:[s,this.path,this.pos]}encode(t,i){t.encodeArrayHeader(this.props?4:3),t.writer.u8(10),t.encodeArray(this.path),t.encodeNumber(this.pos),this.props&&t.encodeObject(this.props)}}class vd extends Re{constructor(t,i,s){super(t);x(this,"pos");x(this,"props");this.pos=i,this.props=s}op(){return"merge"}code(){return 11}apply(t){const i=ne(t,this.path);if(!_n(i))throw new Error("INVALID_TARGET");if(i.key<=0)throw new Error("INVALID_KEY");const s=i.obj[i.key-1],r=i.obj[i.key],a=this.merge(s,r);return i.obj[i.key-1]=a,i.obj.splice(i.key,1),{doc:t,old:[s,r]}}merge(t,i){return typeof t=="string"&&typeof i=="string"||typeof t=="number"&&typeof i=="number"?t+i:Li(t)&&Li(i)?{...t,...i,text:t.text+i.text}:Ui(t)&&Ui(i)?{...t,...i,children:[...t.children,...i.children]}:[t,i]}toJson(t){const i={op:"merge",path:z(this.path),pos:this.pos};return this.props&&(i.props=this.props),i}toCompact(t,i){const s=i?"merge":11;return this.props?[s,this.path,this.pos,this.props]:[s,this.path,this.pos]}encode(t,i){t.encodeArrayHeader(this.props?4:3),t.writer.u8(11),t.encodeArray(this.path),t.encodeNumber(this.pos),this.props&&t.encodeAny(this.props)}}const{isArray:kd}=Array;class yd extends Re{constructor(t,i,s){super(t);x(this,"props");x(this,"deleteNull");this.props=i,this.deleteNull=s}op(){return"extend"}code(){return 12}apply(t){const i=ne(t,this.path);return _n(i)?i.val!==void 0&&(i.obj[i.key]=this.extend(i.val)):ai(i)?i.obj[i.key]=this.extend(i.val):t=this.extend(t),{doc:t}}extend(t){if(kd(t)||typeof t!="object"||!t)return t;for(const[i,s]of Object.entries(this.props)){if(i==="__proto__")throw new Error("NO_PROTO");if(s===null&&this.deleteNull){delete t[i];continue}t[i]=s}return t}toJson(t){const i={op:"extend",path:z(this.path),props:this.props};return this.deleteNull&&(i.deleteNull=this.deleteNull),i}toCompact(t,i){const s=i?"extend":12;return this.deleteNull?[s,this.path,this.props,1]:[s,this.path,this.props]}encode(t,i){const{deleteNull:s}=this;t.encodeArrayHeader(s?4:3),t.writer.u8(12),t.encodeArray(this.path),t.encodeObject(this.props),s&&t.writer.u8(1)}}class bd extends Se{constructor(e){super(e)}op(){return"defined"}code(){return 31}test(e){const{val:t}=ne(e,this.path);return t!==void 0}toJson(e){return{op:"defined",path:z(e?this.path.slice(e.path.length):this.path)}}toCompact(e,t){return[t?"defined":31,e?this.path.slice(e.path.length):this.path]}encode(e,t){e.encodeArrayHeader(2),e.writer.u8(31),e.encodeArray(t?this.path.slice(t.path.length):this.path)}}class Td extends Se{constructor(e){super(e)}op(){return"undefined"}code(){return 38}test(e){try{const{val:t}=ne(e,this.path);return t===void 0}catch(t){if(t.message==="NOT_FOUND")return!0;throw t}}toJson(e){return{op:"undefined",path:z(e?this.path.slice(e.path.length):this.path)}}toCompact(e,t){return[t?"undefined":38,e?this.path.slice(e.path.length):this.path]}encode(e,t){e.encodeArrayHeader(2),e.writer.u8(38),e.encodeArray(t?this.path.slice(t.path.length):this.path)}}const{isArray:Cd}=Array;class Sd extends Se{constructor(t,i){super(t);x(this,"type");this.type=i}op(){return"test_type"}code(){return 39}test(t){const{val:i}=ne(t,this.path);return i===null?this.type.indexOf("null")>-1:Cd(i)?this.type.indexOf("array")>-1:this.type.indexOf(typeof i)>-1||typeof i=="number"&&i===Math.round(i)&&this.type.indexOf("integer")>-1}toJson(t){return{op:"test_type",path:z(t?this.path.slice(t.path.length):this.path),type:this.type}}toCompact(t,i){return[i?"test_type":39,t?this.path.slice(t.path.length):this.path,this.type]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(39),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeArray(this.type)}}class _d extends Se{constructor(t,i,s,r){super(t);x(this,"pos");x(this,"str");x(this,"not");this.pos=i,this.str=s,this.not=r}op(){return"test_string"}code(){return 40}test(t){const{val:i}=ne(t,this.path);if(typeof i!="string")return!1;const s=i.length,r=Math.min(this.pos,s),a=Math.min(this.pos+this.str.length,s),o=i.substring(r,a)===this.str;return this.not?!o:o}toJson(t){const i={op:"test_string",path:z(t?this.path.slice(t.path.length):this.path),pos:this.pos,str:this.str};return this.not&&(i.not=this.not),i}toCompact(t,i){const s=i?"test_string":40,r=t?this.path.slice(t.path.length):this.path;return this.not?[s,r,this.pos,this.str,1]:[s,r,this.pos,this.str]}encode(t,i){t.encodeArrayHeader(this.not?5:4),t.writer.u8(40),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeNumber(this.pos),t.encodeString(this.str),this.not&&t.writer.u8(1)}}class Ed extends Se{constructor(t,i,s){super(t);x(this,"len");x(this,"not");this.len=i,this.not=s}op(){return"test_string_len"}code(){return 41}test(t){const{val:i}=ne(t,this.path);if(typeof i!="string")return!1;const r=i.length>=this.len;return this.not?!r:r}toJson(t){const i={op:"test_string_len",path:z(t?this.path.slice(t.path.length):this.path),len:this.len};return this.not&&(i.not=this.not),i}toCompact(t,i){const s=i?"test_string_len":41,r=t?this.path.slice(t.path.length):this.path;return this.not?[s,r,this.len,1]:[s,r,this.len]}encode(t,i){t.encodeArrayHeader(this.not?4:3),t.writer.u8(41),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeNumber(this.len),this.not&&t.writer.u8(1)}}class wd extends Se{constructor(t,i,s){super(t);x(this,"value");x(this,"ignore_case");this.value=i,this.ignore_case=s}op(){return"contains"}code(){return 30}test(t){const{val:i}=ne(t,this.path);if(typeof i!="string")return!1;const s=this.ignore_case?i.toLowerCase():i,r=this.ignore_case?this.value.toLowerCase():this.value;return s.indexOf(r)>-1}toJson(t){const i={op:"contains",path:z(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(i.ignore_case=this.ignore_case),i}toCompact(t,i){const s=i?"contains":30;return this.ignore_case?[s,t?this.path.slice(t.path.length):this.path,this.value,1]:[s,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,i){const s=this.ignore_case;t.encodeArrayHeader(s?4:3),t.writer.u8(30),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeString(this.value),s&&t.writer.u8(1)}}class Pd extends Se{constructor(t,i,s){super(t);x(this,"value");x(this,"ignore_case");this.value=i,this.ignore_case=s}op(){return"ends"}code(){return 32}test(t){const{val:i}=ne(t,this.path);if(typeof i!="string")return!1;const s=this.ignore_case?i.toLowerCase():i,r=this.ignore_case?this.value.toLowerCase():this.value;return s.endsWith(r)}toJson(t){const i={op:"ends",path:z(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(i.ignore_case=this.ignore_case),i}toCompact(t,i){const s=i?"ends":32;return this.ignore_case?[s,t?this.path.slice(t.path.length):this.path,this.value,1]:[s,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,i){const s=this.ignore_case;t.encodeArrayHeader(s?4:3),t.writer.u8(32),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeString(this.value),s&&t.writer.u8(1)}}class Rd extends Se{constructor(t,i,s){super(t);x(this,"value");x(this,"ignore_case");this.value=i,this.ignore_case=s}op(){return"starts"}code(){return 37}test(t){const{val:i}=ne(t,this.path);if(typeof i!="string")return!1;const s=this.ignore_case?i.toLowerCase():i,r=this.ignore_case?this.value.toLowerCase():this.value;return s.startsWith(r)}toJson(t){const i={op:"starts",path:z(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(i.ignore_case=this.ignore_case),i}toCompact(t,i){const s=i?"starts":37;return this.ignore_case?[s,t?this.path.slice(t.path.length):this.path,this.value,1]:[s,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,i){const s=this.ignore_case;t.encodeArrayHeader(s?4:3),t.writer.u8(37),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeString(this.value),s&&t.writer.u8(1)}}class Id extends Se{constructor(t,i){super(t);x(this,"value");this.value=i}op(){return"in"}code(){return 33}test(t){const{val:i}=ne(t,this.path);for(const s of this.value)if(Qn(i,s))return!0;return!1}toJson(t){return{op:"in",path:z(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,i){return[i?"in":33,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(33),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeArray(this.value)}}class Od extends Se{constructor(t,i){super(t);x(this,"value");this.value=i}op(){return"less"}code(){return 34}test(t){const{val:i}=ne(t,this.path);return typeof i!="number"?!1:i<this.value}toJson(t){return{op:"less",path:z(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,i){return[i?"less":34,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(34),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeNumber(this.value)}}class Md extends Se{constructor(t,i){super(t);x(this,"value");this.value=i}op(){return"more"}code(){return 36}test(t){const{val:i}=ne(t,this.path);return typeof i!="number"?!1:i>this.value}toJson(t){return{op:"more",path:z(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,i){return[i?"more":36,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(36),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeNumber(this.value)}}class ms extends Se{constructor(t,i){super(t);x(this,"ops");this.ops=i}}class xd extends ms{constructor(t,i){super(t,i);x(this,"ops");this.ops=i}op(){return"and"}code(){return 43}test(t){for(const i of this.ops)if(!i.test(t))return!1;return!0}toJson(t){return{op:"and",path:z(t?this.path.slice(t.path.length):this.path),apply:this.ops.map(s=>s.toJson(this))}}toCompact(t,i){return[i?"and":43,t?this.path.slice(t.path.length):this.path,this.ops.map(r=>r.toCompact(this,i))]}encode(t,i){const s=i?this.path.slice(i.path.length):this.path;t.encodeArrayHeader(3),t.writer.u8(43),t.encodeArray(s);const r=this.ops.length;t.encodeArrayHeader(r);for(let a=0;a<r;a++)this.ops[a].encode(t,this)}}class Ad extends ms{constructor(t,i){super(t,i);x(this,"ops");this.ops=i}op(){return"or"}code(){return 45}test(t){for(const i of this.ops)if(i.test(t))return!0;return!1}toJson(t){return{op:"or",path:z(t?this.path.slice(t.path.length):this.path),apply:this.ops.map(s=>s.toJson(this))}}toCompact(t,i){return[i?"or":45,t?this.path.slice(t.path.length):this.path,this.ops.map(r=>r.toCompact(this,i))]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(45),t.encodeArray(i?this.path.slice(i.path.length):this.path);const s=this.ops.length;t.encodeArrayHeader(s);for(let r=0;r<s;r++)this.ops[r].encode(t,this)}}class Dd extends ms{constructor(t,i){super(t,i);x(this,"ops");this.ops=i}op(){return"not"}code(){return 44}test(t){for(const i of this.ops)if(i.test(t))return!1;return!0}toJson(t){return{op:"not",path:z(t?this.path.slice(t.path.length):this.path),apply:this.ops.map(s=>s.toJson(this))}}toCompact(t,i){return[i?"not":44,t?this.path.slice(t.path.length):this.path,this.ops.map(r=>r.toCompact(this,i))]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(44),t.encodeArray(i?this.path.slice(i.path.length):this.path);const s=this.ops.length;t.encodeArrayHeader(s);for(let r=0;r<s;r++)this.ops[r].encode(t,this)}}class Nd extends Se{constructor(t,i,s,r){super(t);x(this,"value");x(this,"ignore_case");x(this,"matcher");this.value=i,this.ignore_case=s,this.matcher=r(i,s)}op(){return"matches"}code(){return 35}test(t){const{val:i}=ne(t,this.path);return typeof i!="string"?!1:this.matcher(i)}toJson(t){const i={op:"matches",path:z(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(i.ignore_case=this.ignore_case),i}toCompact(t,i){const s=i?"matches":35;return this.ignore_case?[s,t?this.path.slice(t.path.length):this.path,this.value,1]:[s,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,i){const s=this.ignore_case;t.encodeArrayHeader(s?4:3),t.writer.u8(35),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeString(this.value),s&&t.writer.u8(1)}}const{isArray:Ld}=Array;class Ud extends Se{constructor(t,i){super(t);x(this,"value");this.value=i}op(){return"type"}code(){return 42}test(t){const{val:i}=ne(t,this.path);return i===null?this.value==="null":Ld(i)?this.value==="array":typeof i===this.value||typeof i=="number"&&i===Math.round(i)&&this.value==="integer"}toJson(t){return{op:"type",path:z(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,i){return[i?"type":42,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(42),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeString(this.value)}}const jd=(n,e)=>{switch(n.op){case"add":return new fs(B(n.path),n.value);case"remove":return new Xr(B(n.path),n.oldValue);case"replace":return new ad(B(n.path),n.value,n.oldValue);case"move":return new od(B(n.path),B(n.from));case"copy":return new cd(B(n.path),B(n.from));case"flip":return new ld(B(n.path));case"inc":return new ud(B(n.path),n.inc);case"str_ins":return new hd(B(n.path),n.pos,n.str);case"str_del":return new pd(B(n.path),n.pos,n.str,n.len);case"split":return new gd(B(n.path),n.pos,n.props||null);case"merge":return new vd(B(n.path),n.pos,n.props||null);case"extend":return new yd(B(n.path),n.props,!!n.deleteNull);default:return Fn(n,e)}},Fn=(n,e)=>{switch(n.op){case"test":return new dd(B(n.path),n.value,!!n.not);case"defined":return new bd(B(n.path));case"undefined":return new Td(B(n.path));case"type":return new Ud(B(n.path),n.value);case"test_type":return new Sd(B(n.path),n.type);case"test_string":return new _d(B(n.path),n.pos,n.str,!!n.not);case"test_string_len":return new Ed(B(n.path),n.len,!!n.not);case"contains":return new wd(B(n.path),n.value,!!n.ignore_case);case"ends":return new Pd(B(n.path),n.value,!!n.ignore_case);case"starts":return new Rd(B(n.path),n.value,!!n.ignore_case);case"matches":return new Nd(B(n.path),n.value,!!n.ignore_case,e.createMatcher||md);case"in":return new Id(B(n.path),n.value);case"less":return new Od(B(n.path),n.value);case"more":return new Md(B(n.path),n.value);case"and":{const t=B(n.path);return new xd(t,n.apply.map(i=>Fn({...i,path:[...t,...B(i.path)]},e)))}case"or":{const t=B(n.path);return new Ad(t,n.apply.map(i=>Fn({...i,path:[...t,...B(i.path)]},e)))}case"not":{const t=B(n.path);return new Dd(t,n.apply.map(i=>Fn({...i,path:[...t,...B(i.path)]},e)))}default:throw new Error("OP_UNKNOWN")}};function Fd(n,e,t){t.mutate||(n=kn(n));const i=[],s=e.length;for(let r=0;r<s;r++){const o=jd(e[r],t).apply(n);n=o.doc,i.push(o)}return{doc:n,res:i}}var cn=n=>typeof n=="function"?n:function(){return n},Bd=typeof self<"u"?self:null,nn=typeof window<"u"?window:null,dn=Bd||nn||dn,Vd="2.0.0",He={connecting:0,open:1,closing:2,closed:3},$d=1e4,Hd=1e3,Ee={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},Qe={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},ji={longpoll:"longpoll",websocket:"websocket"},qd={complete:4},Dn=class{constructor(n,e,t,i){this.channel=n,this.event=e,this.payload=t||function(){return{}},this.receivedResp=null,this.timeout=i,this.timeoutTimer=null,this.recHooks=[],this.sent=!1}resend(n){this.timeout=n,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(n,e){return this.hasReceived(n)&&e(this.receivedResp.response),this.recHooks.push({status:n,callback:e}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}matchReceive({status:n,response:e,_ref:t}){this.recHooks.filter(i=>i.status===n).forEach(i=>i.callback(e))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,n=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=n,this.matchReceive(n)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(n){return this.receivedResp&&this.receivedResp.status===n}trigger(n,e){this.channel.trigger(this.refEvent,{status:n,response:e})}},Zr=class{constructor(n,e){this.callback=n,this.timerCalc=e,this.timer=null,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},Gd=class{constructor(n,e,t){this.state=Ee.closed,this.topic=n,this.params=cn(e||{}),this.socket=t,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Dn(this,Qe.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new Zr(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=Ee.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(i=>i.send()),this.pushBuffer=[]}),this.joinPush.receive("error",()=>{this.state=Ee.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic} ${this.joinRef()}`),this.state=Ee.closed,this.socket.remove(this)}),this.onError(i=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,i),this.isJoining()&&this.joinPush.reset(),this.state=Ee.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic} (${this.joinRef()})`,this.joinPush.timeout),new Dn(this,Qe.leave,cn({}),this.timeout).send(),this.state=Ee.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(Qe.reply,(i,s)=>{this.trigger(this.replyEventName(s),i)})}join(n=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=n,this.joinedOnce=!0,this.rejoin(),this.joinPush}onClose(n){this.on(Qe.close,n)}onError(n){return this.on(Qe.error,e=>n(e))}on(n,e){let t=this.bindingRef++;return this.bindings.push({event:n,ref:t,callback:e}),t}off(n,e){this.bindings=this.bindings.filter(t=>!(t.event===n&&(typeof e>"u"||e===t.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(n,e,t=this.timeout){if(e=e||{},!this.joinedOnce)throw new Error(`tried to push '${n}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let i=new Dn(this,n,function(){return e},t);return this.canPush()?i.send():(i.startTimeout(),this.pushBuffer.push(i)),i}leave(n=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=Ee.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(Qe.close,"leave")},t=new Dn(this,Qe.leave,cn({}),n);return t.receive("ok",()=>e()).receive("timeout",()=>e()),t.send(),this.canPush()||t.trigger("ok",{}),t}onMessage(n,e,t){return e}isMember(n,e,t,i){return this.topic!==n?!1:i&&i!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:n,event:e,payload:t,joinRef:i}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(n=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=Ee.joining,this.joinPush.resend(n))}trigger(n,e,t,i){let s=this.onMessage(n,e,t,i);if(e&&!s)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let r=this.bindings.filter(a=>a.event===n);for(let a=0;a<r.length;a++)r[a].callback(s,t,i||this.joinRef())}replyEventName(n){return`chan_reply_${n}`}isClosed(){return this.state===Ee.closed}isErrored(){return this.state===Ee.errored}isJoined(){return this.state===Ee.joined}isJoining(){return this.state===Ee.joining}isLeaving(){return this.state===Ee.leaving}},Yn=class{static request(n,e,t,i,s,r,a){if(dn.XDomainRequest){let o=new dn.XDomainRequest;return this.xdomainRequest(o,n,e,i,s,r,a)}else{let o=new dn.XMLHttpRequest;return this.xhrRequest(o,n,e,t,i,s,r,a)}}static xdomainRequest(n,e,t,i,s,r,a){return n.timeout=s,n.open(e,t),n.onload=()=>{let o=this.parseJSON(n.responseText);a&&a(o)},r&&(n.ontimeout=r),n.onprogress=()=>{},n.send(i),n}static xhrRequest(n,e,t,i,s,r,a,o){return n.open(e,t,!0),n.timeout=r,n.setRequestHeader("Content-Type",i),n.onerror=()=>o&&o(null),n.onreadystatechange=()=>{if(n.readyState===qd.complete&&o){let c=this.parseJSON(n.responseText);o(c)}},a&&(n.ontimeout=a),n.send(s),n}static parseJSON(n){if(!n||n==="")return null;try{return JSON.parse(n)}catch{return console&&console.log("failed to parse JSON response",n),null}}static serialize(n,e){let t=[];for(var i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;let s=e?`${e}[${i}]`:i,r=n[i];typeof r=="object"?t.push(this.serialize(r,s)):t.push(encodeURIComponent(s)+"="+encodeURIComponent(r))}return t.join("&")}static appendParams(n,e){if(Object.keys(e).length===0)return n;let t=n.match(/\?/)?"&":"?";return`${n}${t}${this.serialize(e)}`}},Ti=class{constructor(n){this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(n),this.readyState=He.connecting,this.poll()}normalizeEndpoint(n){return n.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+ji.websocket),"$1/"+ji.longpoll)}endpointURL(){return Yn.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(n,e,t){this.close(n,e,t),this.readyState=He.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===He.open||this.readyState===He.connecting}poll(){this.ajax("GET",null,()=>this.ontimeout(),n=>{if(n){var{status:e,token:t,messages:i}=n;this.token=t}else e=0;switch(e){case 200:i.forEach(s=>{setTimeout(()=>this.onmessage({data:s}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=He.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${e}`)}})}send(n){this.ajax("POST",n,()=>this.onerror("timeout"),e=>{(!e||e.status!==200)&&(this.onerror(e&&e.status),this.closeAndRetry(1011,"internal server error",!1))})}close(n,e,t){for(let s of this.reqs)s.abort();this.readyState=He.closed;let i=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:n,reason:e,wasClean:t});typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",i)):this.onclose(i)}ajax(n,e,t,i){let s,r=()=>{this.reqs.delete(s),t()};s=Yn.request(n,this.endpointURL(),"application/json",e,this.timeout,r,a=>{this.reqs.delete(s),this.isActive()&&i(a)}),this.reqs.add(s)}},Nn={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(n,e){if(n.payload.constructor===ArrayBuffer)return e(this.binaryEncode(n));{let t=[n.join_ref,n.ref,n.topic,n.event,n.payload];return e(JSON.stringify(t))}},decode(n,e){if(n.constructor===ArrayBuffer)return e(this.binaryDecode(n));{let[t,i,s,r,a]=JSON.parse(n);return e({join_ref:t,ref:i,topic:s,event:r,payload:a})}},binaryEncode(n){let{join_ref:e,ref:t,event:i,topic:s,payload:r}=n,a=this.META_LENGTH+e.length+t.length+s.length+i.length,o=new ArrayBuffer(this.HEADER_LENGTH+a),c=new DataView(o),d=0;c.setUint8(d++,this.KINDS.push),c.setUint8(d++,e.length),c.setUint8(d++,t.length),c.setUint8(d++,s.length),c.setUint8(d++,i.length),Array.from(e,u=>c.setUint8(d++,u.charCodeAt(0))),Array.from(t,u=>c.setUint8(d++,u.charCodeAt(0))),Array.from(s,u=>c.setUint8(d++,u.charCodeAt(0))),Array.from(i,u=>c.setUint8(d++,u.charCodeAt(0)));var l=new Uint8Array(o.byteLength+r.byteLength);return l.set(new Uint8Array(o),0),l.set(new Uint8Array(r),o.byteLength),l.buffer},binaryDecode(n){let e=new DataView(n),t=e.getUint8(0),i=new TextDecoder;switch(t){case this.KINDS.push:return this.decodePush(n,e,i);case this.KINDS.reply:return this.decodeReply(n,e,i);case this.KINDS.broadcast:return this.decodeBroadcast(n,e,i)}},decodePush(n,e,t){let i=e.getUint8(1),s=e.getUint8(2),r=e.getUint8(3),a=this.HEADER_LENGTH+this.META_LENGTH-1,o=t.decode(n.slice(a,a+i));a=a+i;let c=t.decode(n.slice(a,a+s));a=a+s;let d=t.decode(n.slice(a,a+r));a=a+r;let l=n.slice(a,n.byteLength);return{join_ref:o,ref:null,topic:c,event:d,payload:l}},decodeReply(n,e,t){let i=e.getUint8(1),s=e.getUint8(2),r=e.getUint8(3),a=e.getUint8(4),o=this.HEADER_LENGTH+this.META_LENGTH,c=t.decode(n.slice(o,o+i));o=o+i;let d=t.decode(n.slice(o,o+s));o=o+s;let l=t.decode(n.slice(o,o+r));o=o+r;let u=t.decode(n.slice(o,o+a));o=o+a;let p=n.slice(o,n.byteLength),m={status:u,response:p};return{join_ref:c,ref:d,topic:l,event:Qe.reply,payload:m}},decodeBroadcast(n,e,t){let i=e.getUint8(1),s=e.getUint8(2),r=this.HEADER_LENGTH+2,a=t.decode(n.slice(r,r+i));r=r+i;let o=t.decode(n.slice(r,r+s));r=r+s;let c=n.slice(r,n.byteLength);return{join_ref:null,ref:null,topic:a,event:o,payload:c}}},zd=class{constructor(n,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=e.timeout||$d,this.transport=e.transport||dn.WebSocket||Ti,this.establishedConnections=0,this.defaultEncoder=Nn.encode.bind(Nn),this.defaultDecoder=Nn.decode.bind(Nn),this.closeWasClean=!1,this.binaryType=e.binaryType||"arraybuffer",this.connectClock=1,this.transport!==Ti?(this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let t=null;nn&&nn.addEventListener&&(nn.addEventListener("pagehide",i=>{this.conn&&(this.disconnect(),t=this.connectClock)}),nn.addEventListener("pageshow",i=>{t===this.connectClock&&(t=null,this.connect())})),this.heartbeatIntervalMs=e.heartbeatIntervalMs||3e4,this.rejoinAfterMs=i=>e.rejoinAfterMs?e.rejoinAfterMs(i):[1e3,2e3,5e3][i-1]||1e4,this.reconnectAfterMs=i=>e.reconnectAfterMs?e.reconnectAfterMs(i):[10,50,100,150,200,250,500,1e3,2e3][i-1]||5e3,this.logger=e.logger||null,this.longpollerTimeout=e.longpollerTimeout||2e4,this.params=cn(e.params||{}),this.endPoint=`${n}/${ji.websocket}`,this.vsn=e.vsn||Vd,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new Zr(()=>{this.teardown(()=>this.connect())},this.reconnectAfterMs)}getLongPollTransport(){return Ti}replaceTransport(n){this.connectClock++,this.closeWasClean=!0,this.reconnectTimer.reset(),this.sendBuffer=[],this.conn&&(this.conn.close(),this.conn=null),this.transport=n}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let n=Yn.appendParams(Yn.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return n.charAt(0)!=="/"?n:n.charAt(1)==="/"?`${this.protocol()}:${n}`:`${this.protocol()}://${location.host}${n}`}disconnect(n,e,t){this.connectClock++,this.closeWasClean=!0,this.reconnectTimer.reset(),this.teardown(n,e,t)}connect(n){n&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=cn(n)),!this.conn&&(this.connectClock++,this.closeWasClean=!1,this.conn=new this.transport(this.endPointURL()),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e))}log(n,e,t){this.logger(n,e,t)}hasLogger(){return this.logger!==null}onOpen(n){let e=this.makeRef();return this.stateChangeCallbacks.open.push([e,n]),e}onClose(n){let e=this.makeRef();return this.stateChangeCallbacks.close.push([e,n]),e}onError(n){let e=this.makeRef();return this.stateChangeCallbacks.error.push([e,n]),e}onMessage(n){let e=this.makeRef();return this.stateChangeCallbacks.message.push([e,n]),e}ping(n){if(!this.isConnected())return!1;let e=this.makeRef(),t=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:e});let i=this.onMessage(s=>{s.ref===e&&(this.off([i]),n(Date.now()-t))});return!0}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.resetHeartbeat(),this.stateChangeCallbacks.open.forEach(([,n])=>n())}heartbeatTimeout(){this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.triggerChanError(),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),Hd,"heartbeat timeout"))}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(n,e,t){if(!this.conn)return n&&n();this.waitForBufferDone(()=>{this.conn&&(e?this.conn.close(e,t||""):this.conn.close()),this.waitForSocketClosed(()=>{this.conn&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),n&&n()})})}waitForBufferDone(n,e=1){if(e===5||!this.conn||!this.conn.bufferedAmount){n();return}setTimeout(()=>{this.waitForBufferDone(n,e+1)},150*e)}waitForSocketClosed(n,e=1){if(e===5||!this.conn||this.conn.readyState===He.closed){n();return}setTimeout(()=>{this.waitForSocketClosed(n,e+1)},150*e)}onConnClose(n){let e=n&&n.code;this.hasLogger()&&this.log("transport","close",n),this.triggerChanError(),this.clearHeartbeats(),!this.closeWasClean&&e!==1e3&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,t])=>t(n))}onConnError(n){this.hasLogger()&&this.log("transport",n);let e=this.transport,t=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,i])=>{i(n,e,t)}),(e===this.transport||t>0)&&this.triggerChanError()}triggerChanError(){this.channels.forEach(n=>{n.isErrored()||n.isLeaving()||n.isClosed()||n.trigger(Qe.error)})}connectionState(){switch(this.conn&&this.conn.readyState){case He.connecting:return"connecting";case He.open:return"open";case He.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(n){this.off(n.stateChangeRefs),this.channels=this.channels.filter(e=>e.joinRef()!==n.joinRef())}off(n){for(let e in this.stateChangeCallbacks)this.stateChangeCallbacks[e]=this.stateChangeCallbacks[e].filter(([t])=>n.indexOf(t)===-1)}channel(n,e={}){let t=new Gd(n,e,this);return this.channels.push(t),t}push(n){if(this.hasLogger()){let{topic:e,event:t,payload:i,ref:s,join_ref:r}=n;this.log("push",`${e} ${t} (${r}, ${s})`,i)}this.isConnected()?this.encode(n,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(n,e=>this.conn.send(e)))}makeRef(){let n=this.ref+1;return n===this.ref?this.ref=0:this.ref=n,this.ref.toString()}sendHeartbeat(){this.pendingHeartbeatRef&&!this.isConnected()||(this.pendingHeartbeatRef=this.makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs))}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(n=>n()),this.sendBuffer=[])}onConnMessage(n){this.decode(n.data,e=>{let{topic:t,event:i,payload:s,ref:r,join_ref:a}=e;r&&r===this.pendingHeartbeatRef&&(this.clearHeartbeats(),this.pendingHeartbeatRef=null,this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)),this.hasLogger()&&this.log("receive",`${s.status||""} ${t} ${i} ${r&&"("+r+")"||""}`,s);for(let o=0;o<this.channels.length;o++){const c=this.channels[o];c.isMember(t,i,s,a)&&c.trigger(i,s,r,a)}for(let o=0;o<this.stateChangeCallbacks.message.length;o++){let[,c]=this.stateChangeCallbacks.message[o];c(e)}})}leaveOpenTopic(n){let e=this.channels.find(t=>t.topic===n&&(t.isJoined()||t.isJoining()));e&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${n}"`),e.leave())}};class Wd{constructor(e){this.connected=!1,this.config=e,this.socket=new zd(this.config.url,this.config.socketOptions||{logger:(t,i,s)=>{console.debug(`${t}: ${i}`,s)}}),this.channel=this.socket.channel(this.config.topic,this.config.params),this.eventTarget=new EventTarget}connect(){this.connected||(this.socket.onError(e=>this.emitError("socket error",e)),this.socket.connect(),this.channel.onError(e=>this.emitError("channel error",e)),this.channel.join().receive("ok",e=>{console.debug("channel joined",e)}).receive("error",e=>{this.emitError("channel join error",e)}),this.channel.on("state:change",e=>this.handleChange(e)),this.channel.on("state:patch",e=>this.handlePatch(e)),this.channel.on("error",e=>this.emitServerError(e)),this.connected=!0)}disconnect(){this.channel&&this.channel.leave(),this.socket.disconnect(),this.connected=!1}addEventListener(e,t,i){var s;this.eventTarget.addEventListener(e,t,i),e.startsWith("livestate-")||(s=this.channel)==null||s.on(e,r=>{this.eventTarget.dispatchEvent(new CustomEvent(e,{detail:r}))})}removeEventListener(e,t,i){return this.eventTarget.removeEventListener(e,t,i)}subscribe(e){this.addEventListener("livestate-change",e)}unsubscribe(e){this.removeEventListener("livestate-change",e)}emitServerError(e){this.eventTarget.dispatchEvent(new CustomEvent("livestate-error",{detail:e}))}emitError(e,t){this.eventTarget.dispatchEvent(new CustomEvent("livestate-error",{detail:{type:e,message:this.extractMessage(t)}}))}extractMessage(e){if(e&&typeof(e=="object")){const t=[e.reason,e.name,e.message].find(i=>i);return console.log(t),t}else if(typeof e=="string")return e}handleChange({state:e,version:t}){this.state=e,this.stateVersion=t,this.eventTarget.dispatchEvent(new CustomEvent("livestate-change",{detail:{state:this.state,version:this.stateVersion}}))}handlePatch({patch:e,version:t}){if(this.eventTarget.dispatchEvent(new CustomEvent("livestate-patch",{detail:{patch:e,version:t}})),this.versionMatches(t)){const{doc:i,res:s}=Fd(this.state,e,{mutate:!1});this.state=i,this.stateVersion=t,this.eventTarget.dispatchEvent(new CustomEvent("livestate-change",{detail:{state:this.state,version:this.stateVersion}}))}else this.channel.push("lvs_refresh")}versionMatches(e){return e===this.stateVersion+1||e===0}pushEvent(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}dispatchEvent(e){return this.channel.push(`lvs_evt:${e.type}`,e.detail),!0}pushCustomEvent(e){this.dispatchEvent(e)}}const ea=32;let de,je,Xn=n=>(de=0,je=n,n=rt(),je[de]?nt():n||""),nt=(n="Bad syntax",e=je[de],t=je.slice(0,de).split(`
1
+ "use strict";var Tc=Object.defineProperty;var Cc=(n,e,t)=>e in n?Tc(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var x=(n,e,t)=>(Cc(n,typeof e!="symbol"?e+"":e,t),t);const Fs=require("./constants-ClJvwRne.cjs");function gn(){}function zr(n){return n()}function Bs(){return Object.create(null)}function Sn(n){n.forEach(zr)}function Wr(n){return typeof n=="function"}function Sc(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function _c(n){return Object.keys(n).length===0}function we(n,e){n.appendChild(e)}function Ec(n,e,t){const i=wc(n);if(!i.getElementById(e)){const s=Ne("style");s.id=e,s.textContent=t,Pc(i,s)}}function wc(n){if(!n)return document;const e=n.getRootNode?n.getRootNode():n.ownerDocument;return e&&e.host?e:n.ownerDocument}function Pc(n,e){return we(n.head||n,e),e.sheet}function Tt(n,e,t){n.insertBefore(e,t||null)}function ut(n){n.parentNode&&n.parentNode.removeChild(n)}function Ne(n){return document.createElement(n)}function Vs(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function ps(n){return document.createTextNode(n)}function tn(){return ps(" ")}function Rc(){return ps("")}function V(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Ic(n){return Array.from(n.childNodes)}function Oc(n,e){e=""+e,n.data!==e&&(n.data=e)}function Ve(n,e,t,i){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,i?"important":"")}function Mc(n){const e={};return n.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let vn;function on(n){vn=n}function Jr(){if(!vn)throw new Error("Function called outside component initialization");return vn}function xc(n){Jr().$$.on_mount.push(n)}function Ac(n){Jr().$$.on_destroy.push(n)}const Dt=[],Ai=[];let Ut=[];const $s=[],Dc=Promise.resolve();let Di=!1;function Nc(){Di||(Di=!0,Dc.then(ct))}function Ni(n){Ut.push(n)}const bi=new Set;let Ot=0;function ct(){if(Ot!==0)return;const n=vn;do{try{for(;Ot<Dt.length;){const e=Dt[Ot];Ot++,on(e),Lc(e.$$)}}catch(e){throw Dt.length=0,Ot=0,e}for(on(null),Dt.length=0,Ot=0;Ai.length;)Ai.pop()();for(let e=0;e<Ut.length;e+=1){const t=Ut[e];bi.has(t)||(bi.add(t),t())}Ut.length=0}while(Dt.length);for(;$s.length;)$s.pop()();Di=!1,bi.clear(),on(n)}function Lc(n){if(n.fragment!==null){n.update(),Sn(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(Ni)}}function Uc(n){const e=[],t=[];Ut.forEach(i=>n.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),Ut=e}const jc=new Set;function Kr(n,e){n&&n.i&&(jc.delete(n),n.i(e))}function Hs(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Fc(n,e){n.d(1),e.delete(n.key)}function Bc(n,e,t,i,s,r,a,o,c,d,l,u){let p=n.length,m=r.length,k=p;const v={};for(;k--;)v[n[k].key]=k;const S=[],O=new Map,P=new Map,F=[];for(k=m;k--;){const N=u(s,r,k),X=t(N);let A=a.get(X);A?i&&F.push(()=>A.p(N,e)):(A=d(X,N),A.c()),O.set(X,S[k]=A),X in v&&P.set(X,Math.abs(k-v[X]))}const W=new Set,he=new Set;function le(N){Kr(N,1),N.m(o,l),a.set(N.key,N),l=N.first,m--}for(;p&&m;){const N=S[m-1],X=n[p-1],A=N.key,H=X.key;N===X?(l=N.first,p--,m--):O.has(H)?!a.has(A)||W.has(A)?le(N):he.has(H)?p--:P.get(A)>P.get(H)?(he.add(A),le(N)):(W.add(H),p--):(c(X,a),p--)}for(;p--;){const N=n[p];O.has(N.key)||c(N,a)}for(;m;)le(S[m-1]);return Sn(F),S}function Vc(n,e,t){const{fragment:i,after_update:s}=n.$$;i&&i.m(e,t),Ni(()=>{const r=n.$$.on_mount.map(zr).filter(Wr);n.$$.on_destroy?n.$$.on_destroy.push(...r):Sn(r),n.$$.on_mount=[]}),s.forEach(Ni)}function $c(n,e){const t=n.$$;t.fragment!==null&&(Uc(t.after_update),Sn(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Hc(n,e){n.$$.dirty[0]===-1&&(Dt.push(n),Nc(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function qc(n,e,t,i,s,r,a=null,o=[-1]){const c=vn;on(n);const d=n.$$={fragment:null,ctx:[],props:r,update:gn,not_equal:s,bound:Bs(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(c?c.$$.context:[])),callbacks:Bs(),dirty:o,skip_bound:!1,root:e.target||c.$$.root};a&&a(d.root);let l=!1;if(d.ctx=t?t(n,e.props||{},(u,p,...m)=>{const k=m.length?m[0]:p;return d.ctx&&s(d.ctx[u],d.ctx[u]=k)&&(!d.skip_bound&&d.bound[u]&&d.bound[u](k),l&&Hc(n,u)),p}):[],d.update(),l=!0,Sn(d.before_update),d.fragment=i?i(d.ctx):!1,e.target){if(e.hydrate){const u=Ic(e.target);d.fragment&&d.fragment.l(u),u.forEach(ut)}else d.fragment&&d.fragment.c();e.intro&&Kr(n.$$.fragment),Vc(n,e.target,e.anchor),ct()}on(c)}let Qr;typeof HTMLElement=="function"&&(Qr=class extends HTMLElement{constructor(e,t,i){super();x(this,"$$ctor");x(this,"$$s");x(this,"$$c");x(this,"$$cn",!1);x(this,"$$d",{});x(this,"$$r",!1);x(this,"$$p_d",{});x(this,"$$l",{});x(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,i&&this.attachShadow({mode:"open"})}addEventListener(e,t,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const s=this.$$c.$on(e,t);this.$$l_u.set(t,s)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){const s=this.$$l_u.get(t);s&&(s(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(r){return()=>{let a;return{c:function(){a=Ne("slot"),r!=="default"&&V(a,"name",r)},m:function(d,l){Tt(d,a,l)},d:function(d){d&&ut(a)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},i=Mc(this);for(const r of this.$$s)r in i&&(t[r]=[e(r)]);for(const r of this.attributes){const a=this.$$g_p(r.name);a in this.$$d||(this.$$d[a]=jn(a,r.value,this.$$p_d,"toProp"))}for(const r in this.$$p_d)!(r in this.$$d)&&this[r]!==void 0&&(this.$$d[r]=this[r],delete this[r]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});const s=()=>{this.$$r=!0;for(const r in this.$$p_d)if(this.$$d[r]=this.$$c.$$.ctx[this.$$c.$$.props[r]],this.$$p_d[r].reflect){const a=jn(r,this.$$d[r],this.$$p_d,"toAttribute");a==null?this.removeAttribute(this.$$p_d[r].attribute||r):this.setAttribute(this.$$p_d[r].attribute||r,a)}this.$$r=!1};this.$$c.$$.after_update.push(s),s();for(const r in this.$$l)for(const a of this.$$l[r]){const o=this.$$c.$on(r,a);this.$$l_u.set(a,o)}this.$$l={}}}attributeChangedCallback(e,t,i){var s;this.$$r||(e=this.$$g_p(e),this.$$d[e]=jn(e,i,this.$$p_d,"toProp"),(s=this.$$c)==null||s.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function jn(n,e,t,i){var r;const s=(r=t[n])==null?void 0:r.type;if(e=s==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[n])return e;if(i==="toAttribute")switch(s){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(s){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function Gc(n,e,t,i,s,r){let a=class extends Qr{constructor(){super(n,t,s),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(o=>(e[o].attribute||o).toLowerCase())}};return Object.keys(e).forEach(o=>{Object.defineProperty(a.prototype,o,{get(){return this.$$c&&o in this.$$c?this.$$c[o]:this.$$d[o]},set(c){var d;c=jn(o,c,e),this.$$d[o]=c,(d=this.$$c)==null||d.$set({[o]:c})}})}),i.forEach(o=>{Object.defineProperty(a.prototype,o,{get(){var c;return(c=this.$$c)==null?void 0:c[o]}})}),r&&(a=r(a)),n.element=a,a}class zc{constructor(){x(this,"$$");x(this,"$$set")}$destroy(){$c(this,1),this.$destroy=gn}$on(e,t){if(!Wr(t))return gn;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}$set(e){this.$$set&&!_c(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Wc="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Wc);const{isArray:Jc}=Array,Kc=Object.keys,kn=n=>{if(!n)return n;if(Jc(n)){const e=[],t=n.length;for(let i=0;i<t;i++)e.push(kn(n[i]));return e}else if(typeof n=="object"){const e=Kc(n),t=e.length,i={};for(let s=0;s<t;s++){const r=e[s];i[r]=kn(n[r])}return i}return n};class Re{constructor(e){x(this,"path");x(this,"from");this.path=e}}const Qc=/~1/g,Yc=/~0/g,Xc=/~/g,Zc=/\//g;function ed(n){return n.indexOf("~")===-1?n:n.replace(Qc,"/").replace(Yc,"~")}function td(n){return n.indexOf("/")===-1&&n.indexOf("~")===-1?n:n.replace(Xc,"~0").replace(Zc,"~1")}function nd(n){return n?n.slice(1).split("/").map(ed):[]}function z(n){return id(n)?"":"/"+n.map(e=>td(String(e))).join("/")}const B=n=>typeof n=="string"?nd(n):n,id=n=>!n.length,sd=Object.prototype.hasOwnProperty;function rd(n,e){return sd.call(n,e)}const{isArray:Yr}=Array,ne=(n,e)=>{const t=e.length;if(!t)return{val:n};let i,s;for(let a=0;a<t;a++)if(i=n,s=e[a],Yr(i)){const o=i.length;if(s==="-")s=o;else if(typeof s=="string"){const c=~~s;if(""+c!==s)throw new Error("INVALID_INDEX");if(s=c,s<0)throw new Error("INVALID_INDEX")}n=i[s]}else if(typeof i=="object"&&i)n=rd(i,s)?i[s]:void 0;else throw new Error("NOT_FOUND");return{val:n,obj:i,key:s}},_n=n=>Yr(n.obj)&&typeof n.key=="number",ai=n=>typeof n.obj=="object"&&typeof n.key=="string";class fs extends Re{constructor(t,i){super(t);x(this,"value");this.value=i}op(){return"add"}code(){return 0}apply(t){const{val:i,key:s,obj:r}=ne(t,this.path),a=kn(this.value);if(!r)t=a;else if(typeof s=="string")r[s]=a;else{const o=r.length;if(s<o)r.splice(s,0,a);else{if(s>o)throw new Error("INVALID_INDEX");r.push(a)}}return{doc:t,old:i}}toJson(t){return{op:"add",path:z(this.path),value:this.value}}toCompact(t,i){return[i?"add":0,this.path,this.value]}encode(t){t.encodeArrayHeader(3),t.writer.u8(0),t.encodeArray(this.path),t.encodeAny(this.value)}}class Xr extends Re{constructor(t,i){super(t);x(this,"oldValue");this.oldValue=i}op(){return"remove"}code(){return 1}apply(t){const i=ne(t,this.path);if(i.val===void 0)throw new Error("NOT_FOUND");return ai(i)?delete i.obj[i.key]:_n(i)?i.val!==void 0&&i.obj.splice(i.key,1):t=null,{doc:t,old:i.val}}toJson(t){const i={op:"remove",path:z(this.path)};return this.oldValue!==void 0&&(i.oldValue=this.oldValue),i}toCompact(t,i){const s=i?"remove":1;return this.oldValue===void 0?[s,this.path]:[s,this.path,this.oldValue]}encode(t,i){const s=this.oldValue!==void 0;t.encodeArrayHeader(s?3:2),t.writer.u8(1),t.encodeArray(this.path),s&&t.encodeAny(this.oldValue)}}class ad extends Re{constructor(t,i,s){super(t);x(this,"value");x(this,"oldValue");this.value=i,this.oldValue=s}op(){return"replace"}code(){return 2}apply(t){const i=ne(t,this.path);if(i.val===void 0)throw new Error("NOT_FOUND");return ai(i)?i.obj[i.key]=this.value:_n(i)?i.obj[i.key]=this.value:t=this.value,{doc:t,old:i.val}}toJson(t){const i={op:"replace",path:z(this.path),value:this.value};return this.oldValue!==void 0&&(i.oldValue=this.oldValue),i}toCompact(t,i){const s=i?"replace":2;return this.oldValue===void 0?[s,this.path,this.value]:[s,this.path,this.value,this.oldValue]}encode(t,i){const s=this.oldValue!==void 0;t.encodeArrayHeader(s?4:3),t.writer.u8(2),t.encodeArray(this.path),t.encodeAny(this.value),s&&t.encodeAny(this.oldValue)}}class od extends Re{constructor(t,i){super(t);x(this,"from");this.from=i}op(){return"move"}code(){return 4}apply(t){const i=new Xr(B(this.from),void 0).apply(t);return new fs(this.path,i.old).apply(i.doc)}toJson(t){return{op:"move",path:z(this.path),from:z(this.from)}}toCompact(t,i){return[i?"move":4,this.path,this.from]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(4),t.encodeArray(this.path),t.encodeArray(this.from)}}class cd extends Re{constructor(t,i){super(t);x(this,"from");this.from=i}op(){return"copy"}code(){return 3}apply(t){const{val:i}=ne(t,this.from);if(i===void 0)throw new Error("NOT_FOUND");return new fs(this.path,kn(i)).apply(t)}toJson(t){return{op:"copy",path:z(this.path),from:z(this.from)}}toCompact(t,i){return[i?"copy":3,this.path,this.from]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(3),t.encodeArray(this.path),t.encodeArray(this.from)}}class Se extends Re{apply(e){if(!this.test(e))throw new Error("TEST");return{doc:e}}}const Qn=(n,e)=>{if(n===e)return!0;if(n&&e&&typeof n=="object"&&typeof e=="object"){if(n.constructor!==e.constructor)return!1;let t,i,s;if(Array.isArray(n)){if(t=n.length,t!==e.length)return!1;for(i=t;i--!==0;)if(!Qn(n[i],e[i]))return!1;return!0}if(s=Object.keys(n),t=s.length,t!==Object.keys(e).length)return!1;for(i=t;i--!==0;){const r=s[i];if(!Qn(n[r],e[r]))return!1}return!0}return!1};class dd extends Se{constructor(t,i,s){super(t);x(this,"value");x(this,"not");this.value=i,this.not=s}op(){return"test"}code(){return 5}test(t){const{val:i}=ne(t,this.path);if(i===void 0)return!!this.not;const s=Qn(i,this.value);return this.not?!s:s}toJson(t){const i={op:"test",path:z(t?this.path.slice(t.path.length):this.path),value:this.value};return this.not&&(i.not=this.not),i}toCompact(t,i){const s=t?this.path.slice(t.path.length):this.path,r=i?"test":5;return this.not?[r,s,this.value,1]:[r,s,this.value]}encode(t,i){t.encodeArrayHeader(this.not?4:3),t.writer.u8(5),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeAny(this.value),this.not&&t.writer.u8(1)}}class ld extends Re{constructor(e){super(e)}op(){return"flip"}code(){return 8}apply(e){const t=ne(e,this.path);return t.obj?t.obj[t.key]=!t.val:e=!t.val,{doc:e,old:t.val}}toJson(e){return{op:"flip",path:z(this.path)}}toCompact(e,t){return[t?"flip":8,this.path]}encode(e,t){e.encodeArrayHeader(2),e.writer.u8(8),e.encodeArray(this.path)}}class ud extends Re{constructor(t,i){super(t);x(this,"inc");this.inc=i}op(){return"inc"}code(){return 9}apply(t){const i=ne(t,this.path),s=this.inc+Number(i.val);return i.obj?i.obj[i.key]=s:t=s,{doc:t,old:i.val}}toJson(t){return{op:"inc",path:z(this.path),inc:this.inc}}toCompact(t,i){return[i?"inc":9,this.path,this.inc]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(9),t.encodeArray(this.path),t.encodeNumber(this.inc)}}class hd extends Re{constructor(t,i,s){super(t);x(this,"pos");x(this,"str");this.pos=i,this.str=s}op(){return"str_ins"}code(){return 6}apply(t){const{val:i,key:s,obj:r}=ne(t,this.path);if(typeof i!="string"){if(i!==void 0)throw new Error("NOT_A_STRING");if(this.pos!==0)throw new Error("POS")}const a=typeof i=="string"?i:"",o=Math.min(this.pos,a.length),c=a.slice(0,o),d=a.slice(o),l=c+this.str+d;return r?r[s]=l:t=l,{doc:t,old:i}}toJson(t){return{op:"str_ins",path:z(this.path),pos:this.pos,str:this.str}}toCompact(t,i){return[i?"str_ins":6,this.path,this.pos,this.str]}encode(t,i){t.encodeArrayHeader(4),t.writer.u8(6),t.encodeArray(this.path),t.encodeNumber(this.pos),t.encodeString(this.str)}}class pd extends Re{constructor(t,i,s,r){super(t);x(this,"pos");x(this,"str");x(this,"len");this.pos=i,this.str=s,this.len=r}op(){return"str_del"}code(){return 7}deleteLength(){return typeof this.str=="string"?this.str.length:this.len}apply(t){const{val:i,key:s,obj:r}=ne(t,this.path);if(typeof i!="string")throw new Error("NOT_A_STRING");const a=i.length,o=Math.min(this.pos,i.length),c=Math.min(o,a),d=this.str!==void 0?this.str.length:this.len,l=Math.min(o+d,a),u=i.slice(0,c),p=i.substr(l),m=u+p;return r?r[s]=m:t=m,{doc:t,old:i}}toJson(t){return typeof this.str=="string"?{op:"str_del",path:z(this.path),pos:this.pos,str:this.str}:{op:"str_del",path:z(this.path),pos:this.pos,len:this.len}}toCompact(t,i){const s=i?"str_del":7;return typeof this.str=="string"?[s,this.path,this.pos,this.str]:[s,this.path,this.pos,0,this.len]}encode(t,i){const s=typeof this.str=="string";t.encodeArrayHeader(s?4:5),t.writer.u8(7),t.encodeArray(this.path),t.encodeNumber(this.pos),s?t.encodeString(this.str):(t.writer.u8(0),t.encodeNumber(this.len))}}const{isArray:fd}=Array,Li=n=>!!n&&typeof n=="object"&&typeof n.text=="string",Ui=n=>!!n&&typeof n=="object"&&fd(n.children),md=(n,e)=>{const t=new RegExp(n,e?"i":void 0);return i=>t.test(i)};class gd extends Re{constructor(t,i,s){super(t);x(this,"pos");x(this,"props");this.pos=i,this.props=s}op(){return"split"}code(){return 10}apply(t){const i=ne(t,this.path);if(i.val===void 0)throw new Error("NOT_FOUND");const s=this.split(i.val);return ai(i)?i.obj[i.key]=s:_n(i)?(i.obj[i.key]=s[0],i.obj.splice(i.key+1,0,s[1])):t=s,{doc:t,old:i.val}}split(t){if(typeof t=="string"){const{pos:i,props:s}=this,r=t.slice(0,i),a=t.slice(i);return s?[{...s,text:r},{...s,text:a}]:[r,a]}else if(Li(t)){const{pos:i,props:s}=this,r=t.text.slice(0,i),a=t.text.slice(i);return[{...t,...s,text:r},{...t,...s,text:a}]}else if(Ui(t)){const{pos:i,props:s}=this,r=t.children.slice(0,i),a=t.children.slice(i);return[{...t,...s,children:r},{...t,...s,children:a}]}else if(typeof t=="number"){const{pos:i}=this;return[i,t-i]}else return[t,t]}toJson(t){const i={op:"split",path:z(this.path),pos:this.pos};return this.props&&(i.props=this.props),i}toCompact(t,i){const s=i?"split":10;return this.props?[s,this.path,this.pos,this.props]:[s,this.path,this.pos]}encode(t,i){t.encodeArrayHeader(this.props?4:3),t.writer.u8(10),t.encodeArray(this.path),t.encodeNumber(this.pos),this.props&&t.encodeObject(this.props)}}class vd extends Re{constructor(t,i,s){super(t);x(this,"pos");x(this,"props");this.pos=i,this.props=s}op(){return"merge"}code(){return 11}apply(t){const i=ne(t,this.path);if(!_n(i))throw new Error("INVALID_TARGET");if(i.key<=0)throw new Error("INVALID_KEY");const s=i.obj[i.key-1],r=i.obj[i.key],a=this.merge(s,r);return i.obj[i.key-1]=a,i.obj.splice(i.key,1),{doc:t,old:[s,r]}}merge(t,i){return typeof t=="string"&&typeof i=="string"||typeof t=="number"&&typeof i=="number"?t+i:Li(t)&&Li(i)?{...t,...i,text:t.text+i.text}:Ui(t)&&Ui(i)?{...t,...i,children:[...t.children,...i.children]}:[t,i]}toJson(t){const i={op:"merge",path:z(this.path),pos:this.pos};return this.props&&(i.props=this.props),i}toCompact(t,i){const s=i?"merge":11;return this.props?[s,this.path,this.pos,this.props]:[s,this.path,this.pos]}encode(t,i){t.encodeArrayHeader(this.props?4:3),t.writer.u8(11),t.encodeArray(this.path),t.encodeNumber(this.pos),this.props&&t.encodeAny(this.props)}}const{isArray:kd}=Array;class yd extends Re{constructor(t,i,s){super(t);x(this,"props");x(this,"deleteNull");this.props=i,this.deleteNull=s}op(){return"extend"}code(){return 12}apply(t){const i=ne(t,this.path);return _n(i)?i.val!==void 0&&(i.obj[i.key]=this.extend(i.val)):ai(i)?i.obj[i.key]=this.extend(i.val):t=this.extend(t),{doc:t}}extend(t){if(kd(t)||typeof t!="object"||!t)return t;for(const[i,s]of Object.entries(this.props)){if(i==="__proto__")throw new Error("NO_PROTO");if(s===null&&this.deleteNull){delete t[i];continue}t[i]=s}return t}toJson(t){const i={op:"extend",path:z(this.path),props:this.props};return this.deleteNull&&(i.deleteNull=this.deleteNull),i}toCompact(t,i){const s=i?"extend":12;return this.deleteNull?[s,this.path,this.props,1]:[s,this.path,this.props]}encode(t,i){const{deleteNull:s}=this;t.encodeArrayHeader(s?4:3),t.writer.u8(12),t.encodeArray(this.path),t.encodeObject(this.props),s&&t.writer.u8(1)}}class bd extends Se{constructor(e){super(e)}op(){return"defined"}code(){return 31}test(e){const{val:t}=ne(e,this.path);return t!==void 0}toJson(e){return{op:"defined",path:z(e?this.path.slice(e.path.length):this.path)}}toCompact(e,t){return[t?"defined":31,e?this.path.slice(e.path.length):this.path]}encode(e,t){e.encodeArrayHeader(2),e.writer.u8(31),e.encodeArray(t?this.path.slice(t.path.length):this.path)}}class Td extends Se{constructor(e){super(e)}op(){return"undefined"}code(){return 38}test(e){try{const{val:t}=ne(e,this.path);return t===void 0}catch(t){if(t.message==="NOT_FOUND")return!0;throw t}}toJson(e){return{op:"undefined",path:z(e?this.path.slice(e.path.length):this.path)}}toCompact(e,t){return[t?"undefined":38,e?this.path.slice(e.path.length):this.path]}encode(e,t){e.encodeArrayHeader(2),e.writer.u8(38),e.encodeArray(t?this.path.slice(t.path.length):this.path)}}const{isArray:Cd}=Array;class Sd extends Se{constructor(t,i){super(t);x(this,"type");this.type=i}op(){return"test_type"}code(){return 39}test(t){const{val:i}=ne(t,this.path);return i===null?this.type.indexOf("null")>-1:Cd(i)?this.type.indexOf("array")>-1:this.type.indexOf(typeof i)>-1||typeof i=="number"&&i===Math.round(i)&&this.type.indexOf("integer")>-1}toJson(t){return{op:"test_type",path:z(t?this.path.slice(t.path.length):this.path),type:this.type}}toCompact(t,i){return[i?"test_type":39,t?this.path.slice(t.path.length):this.path,this.type]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(39),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeArray(this.type)}}class _d extends Se{constructor(t,i,s,r){super(t);x(this,"pos");x(this,"str");x(this,"not");this.pos=i,this.str=s,this.not=r}op(){return"test_string"}code(){return 40}test(t){const{val:i}=ne(t,this.path);if(typeof i!="string")return!1;const s=i.length,r=Math.min(this.pos,s),a=Math.min(this.pos+this.str.length,s),o=i.substring(r,a)===this.str;return this.not?!o:o}toJson(t){const i={op:"test_string",path:z(t?this.path.slice(t.path.length):this.path),pos:this.pos,str:this.str};return this.not&&(i.not=this.not),i}toCompact(t,i){const s=i?"test_string":40,r=t?this.path.slice(t.path.length):this.path;return this.not?[s,r,this.pos,this.str,1]:[s,r,this.pos,this.str]}encode(t,i){t.encodeArrayHeader(this.not?5:4),t.writer.u8(40),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeNumber(this.pos),t.encodeString(this.str),this.not&&t.writer.u8(1)}}class Ed extends Se{constructor(t,i,s){super(t);x(this,"len");x(this,"not");this.len=i,this.not=s}op(){return"test_string_len"}code(){return 41}test(t){const{val:i}=ne(t,this.path);if(typeof i!="string")return!1;const r=i.length>=this.len;return this.not?!r:r}toJson(t){const i={op:"test_string_len",path:z(t?this.path.slice(t.path.length):this.path),len:this.len};return this.not&&(i.not=this.not),i}toCompact(t,i){const s=i?"test_string_len":41,r=t?this.path.slice(t.path.length):this.path;return this.not?[s,r,this.len,1]:[s,r,this.len]}encode(t,i){t.encodeArrayHeader(this.not?4:3),t.writer.u8(41),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeNumber(this.len),this.not&&t.writer.u8(1)}}class wd extends Se{constructor(t,i,s){super(t);x(this,"value");x(this,"ignore_case");this.value=i,this.ignore_case=s}op(){return"contains"}code(){return 30}test(t){const{val:i}=ne(t,this.path);if(typeof i!="string")return!1;const s=this.ignore_case?i.toLowerCase():i,r=this.ignore_case?this.value.toLowerCase():this.value;return s.indexOf(r)>-1}toJson(t){const i={op:"contains",path:z(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(i.ignore_case=this.ignore_case),i}toCompact(t,i){const s=i?"contains":30;return this.ignore_case?[s,t?this.path.slice(t.path.length):this.path,this.value,1]:[s,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,i){const s=this.ignore_case;t.encodeArrayHeader(s?4:3),t.writer.u8(30),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeString(this.value),s&&t.writer.u8(1)}}class Pd extends Se{constructor(t,i,s){super(t);x(this,"value");x(this,"ignore_case");this.value=i,this.ignore_case=s}op(){return"ends"}code(){return 32}test(t){const{val:i}=ne(t,this.path);if(typeof i!="string")return!1;const s=this.ignore_case?i.toLowerCase():i,r=this.ignore_case?this.value.toLowerCase():this.value;return s.endsWith(r)}toJson(t){const i={op:"ends",path:z(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(i.ignore_case=this.ignore_case),i}toCompact(t,i){const s=i?"ends":32;return this.ignore_case?[s,t?this.path.slice(t.path.length):this.path,this.value,1]:[s,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,i){const s=this.ignore_case;t.encodeArrayHeader(s?4:3),t.writer.u8(32),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeString(this.value),s&&t.writer.u8(1)}}class Rd extends Se{constructor(t,i,s){super(t);x(this,"value");x(this,"ignore_case");this.value=i,this.ignore_case=s}op(){return"starts"}code(){return 37}test(t){const{val:i}=ne(t,this.path);if(typeof i!="string")return!1;const s=this.ignore_case?i.toLowerCase():i,r=this.ignore_case?this.value.toLowerCase():this.value;return s.startsWith(r)}toJson(t){const i={op:"starts",path:z(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(i.ignore_case=this.ignore_case),i}toCompact(t,i){const s=i?"starts":37;return this.ignore_case?[s,t?this.path.slice(t.path.length):this.path,this.value,1]:[s,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,i){const s=this.ignore_case;t.encodeArrayHeader(s?4:3),t.writer.u8(37),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeString(this.value),s&&t.writer.u8(1)}}class Id extends Se{constructor(t,i){super(t);x(this,"value");this.value=i}op(){return"in"}code(){return 33}test(t){const{val:i}=ne(t,this.path);for(const s of this.value)if(Qn(i,s))return!0;return!1}toJson(t){return{op:"in",path:z(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,i){return[i?"in":33,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(33),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeArray(this.value)}}class Od extends Se{constructor(t,i){super(t);x(this,"value");this.value=i}op(){return"less"}code(){return 34}test(t){const{val:i}=ne(t,this.path);return typeof i!="number"?!1:i<this.value}toJson(t){return{op:"less",path:z(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,i){return[i?"less":34,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(34),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeNumber(this.value)}}class Md extends Se{constructor(t,i){super(t);x(this,"value");this.value=i}op(){return"more"}code(){return 36}test(t){const{val:i}=ne(t,this.path);return typeof i!="number"?!1:i>this.value}toJson(t){return{op:"more",path:z(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,i){return[i?"more":36,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(36),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeNumber(this.value)}}class ms extends Se{constructor(t,i){super(t);x(this,"ops");this.ops=i}}class xd extends ms{constructor(t,i){super(t,i);x(this,"ops");this.ops=i}op(){return"and"}code(){return 43}test(t){for(const i of this.ops)if(!i.test(t))return!1;return!0}toJson(t){return{op:"and",path:z(t?this.path.slice(t.path.length):this.path),apply:this.ops.map(s=>s.toJson(this))}}toCompact(t,i){return[i?"and":43,t?this.path.slice(t.path.length):this.path,this.ops.map(r=>r.toCompact(this,i))]}encode(t,i){const s=i?this.path.slice(i.path.length):this.path;t.encodeArrayHeader(3),t.writer.u8(43),t.encodeArray(s);const r=this.ops.length;t.encodeArrayHeader(r);for(let a=0;a<r;a++)this.ops[a].encode(t,this)}}class Ad extends ms{constructor(t,i){super(t,i);x(this,"ops");this.ops=i}op(){return"or"}code(){return 45}test(t){for(const i of this.ops)if(i.test(t))return!0;return!1}toJson(t){return{op:"or",path:z(t?this.path.slice(t.path.length):this.path),apply:this.ops.map(s=>s.toJson(this))}}toCompact(t,i){return[i?"or":45,t?this.path.slice(t.path.length):this.path,this.ops.map(r=>r.toCompact(this,i))]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(45),t.encodeArray(i?this.path.slice(i.path.length):this.path);const s=this.ops.length;t.encodeArrayHeader(s);for(let r=0;r<s;r++)this.ops[r].encode(t,this)}}class Dd extends ms{constructor(t,i){super(t,i);x(this,"ops");this.ops=i}op(){return"not"}code(){return 44}test(t){for(const i of this.ops)if(i.test(t))return!1;return!0}toJson(t){return{op:"not",path:z(t?this.path.slice(t.path.length):this.path),apply:this.ops.map(s=>s.toJson(this))}}toCompact(t,i){return[i?"not":44,t?this.path.slice(t.path.length):this.path,this.ops.map(r=>r.toCompact(this,i))]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(44),t.encodeArray(i?this.path.slice(i.path.length):this.path);const s=this.ops.length;t.encodeArrayHeader(s);for(let r=0;r<s;r++)this.ops[r].encode(t,this)}}class Nd extends Se{constructor(t,i,s,r){super(t);x(this,"value");x(this,"ignore_case");x(this,"matcher");this.value=i,this.ignore_case=s,this.matcher=r(i,s)}op(){return"matches"}code(){return 35}test(t){const{val:i}=ne(t,this.path);return typeof i!="string"?!1:this.matcher(i)}toJson(t){const i={op:"matches",path:z(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(i.ignore_case=this.ignore_case),i}toCompact(t,i){const s=i?"matches":35;return this.ignore_case?[s,t?this.path.slice(t.path.length):this.path,this.value,1]:[s,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,i){const s=this.ignore_case;t.encodeArrayHeader(s?4:3),t.writer.u8(35),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeString(this.value),s&&t.writer.u8(1)}}const{isArray:Ld}=Array;class Ud extends Se{constructor(t,i){super(t);x(this,"value");this.value=i}op(){return"type"}code(){return 42}test(t){const{val:i}=ne(t,this.path);return i===null?this.value==="null":Ld(i)?this.value==="array":typeof i===this.value||typeof i=="number"&&i===Math.round(i)&&this.value==="integer"}toJson(t){return{op:"type",path:z(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,i){return[i?"type":42,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,i){t.encodeArrayHeader(3),t.writer.u8(42),t.encodeArray(i?this.path.slice(i.path.length):this.path),t.encodeString(this.value)}}const jd=(n,e)=>{switch(n.op){case"add":return new fs(B(n.path),n.value);case"remove":return new Xr(B(n.path),n.oldValue);case"replace":return new ad(B(n.path),n.value,n.oldValue);case"move":return new od(B(n.path),B(n.from));case"copy":return new cd(B(n.path),B(n.from));case"flip":return new ld(B(n.path));case"inc":return new ud(B(n.path),n.inc);case"str_ins":return new hd(B(n.path),n.pos,n.str);case"str_del":return new pd(B(n.path),n.pos,n.str,n.len);case"split":return new gd(B(n.path),n.pos,n.props||null);case"merge":return new vd(B(n.path),n.pos,n.props||null);case"extend":return new yd(B(n.path),n.props,!!n.deleteNull);default:return Fn(n,e)}},Fn=(n,e)=>{switch(n.op){case"test":return new dd(B(n.path),n.value,!!n.not);case"defined":return new bd(B(n.path));case"undefined":return new Td(B(n.path));case"type":return new Ud(B(n.path),n.value);case"test_type":return new Sd(B(n.path),n.type);case"test_string":return new _d(B(n.path),n.pos,n.str,!!n.not);case"test_string_len":return new Ed(B(n.path),n.len,!!n.not);case"contains":return new wd(B(n.path),n.value,!!n.ignore_case);case"ends":return new Pd(B(n.path),n.value,!!n.ignore_case);case"starts":return new Rd(B(n.path),n.value,!!n.ignore_case);case"matches":return new Nd(B(n.path),n.value,!!n.ignore_case,e.createMatcher||md);case"in":return new Id(B(n.path),n.value);case"less":return new Od(B(n.path),n.value);case"more":return new Md(B(n.path),n.value);case"and":{const t=B(n.path);return new xd(t,n.apply.map(i=>Fn({...i,path:[...t,...B(i.path)]},e)))}case"or":{const t=B(n.path);return new Ad(t,n.apply.map(i=>Fn({...i,path:[...t,...B(i.path)]},e)))}case"not":{const t=B(n.path);return new Dd(t,n.apply.map(i=>Fn({...i,path:[...t,...B(i.path)]},e)))}default:throw new Error("OP_UNKNOWN")}};function Fd(n,e,t){t.mutate||(n=kn(n));const i=[],s=e.length;for(let r=0;r<s;r++){const o=jd(e[r],t).apply(n);n=o.doc,i.push(o)}return{doc:n,res:i}}var cn=n=>typeof n=="function"?n:function(){return n},Bd=typeof self<"u"?self:null,nn=typeof window<"u"?window:null,dn=Bd||nn||dn,Vd="2.0.0",He={connecting:0,open:1,closing:2,closed:3},$d=1e4,Hd=1e3,Ee={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},Qe={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},ji={longpoll:"longpoll",websocket:"websocket"},qd={complete:4},Dn=class{constructor(n,e,t,i){this.channel=n,this.event=e,this.payload=t||function(){return{}},this.receivedResp=null,this.timeout=i,this.timeoutTimer=null,this.recHooks=[],this.sent=!1}resend(n){this.timeout=n,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(n,e){return this.hasReceived(n)&&e(this.receivedResp.response),this.recHooks.push({status:n,callback:e}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}matchReceive({status:n,response:e,_ref:t}){this.recHooks.filter(i=>i.status===n).forEach(i=>i.callback(e))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,n=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=n,this.matchReceive(n)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(n){return this.receivedResp&&this.receivedResp.status===n}trigger(n,e){this.channel.trigger(this.refEvent,{status:n,response:e})}},Zr=class{constructor(n,e){this.callback=n,this.timerCalc=e,this.timer=null,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},Gd=class{constructor(n,e,t){this.state=Ee.closed,this.topic=n,this.params=cn(e||{}),this.socket=t,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Dn(this,Qe.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new Zr(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=Ee.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(i=>i.send()),this.pushBuffer=[]}),this.joinPush.receive("error",()=>{this.state=Ee.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic} ${this.joinRef()}`),this.state=Ee.closed,this.socket.remove(this)}),this.onError(i=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,i),this.isJoining()&&this.joinPush.reset(),this.state=Ee.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic} (${this.joinRef()})`,this.joinPush.timeout),new Dn(this,Qe.leave,cn({}),this.timeout).send(),this.state=Ee.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(Qe.reply,(i,s)=>{this.trigger(this.replyEventName(s),i)})}join(n=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=n,this.joinedOnce=!0,this.rejoin(),this.joinPush}onClose(n){this.on(Qe.close,n)}onError(n){return this.on(Qe.error,e=>n(e))}on(n,e){let t=this.bindingRef++;return this.bindings.push({event:n,ref:t,callback:e}),t}off(n,e){this.bindings=this.bindings.filter(t=>!(t.event===n&&(typeof e>"u"||e===t.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(n,e,t=this.timeout){if(e=e||{},!this.joinedOnce)throw new Error(`tried to push '${n}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let i=new Dn(this,n,function(){return e},t);return this.canPush()?i.send():(i.startTimeout(),this.pushBuffer.push(i)),i}leave(n=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=Ee.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(Qe.close,"leave")},t=new Dn(this,Qe.leave,cn({}),n);return t.receive("ok",()=>e()).receive("timeout",()=>e()),t.send(),this.canPush()||t.trigger("ok",{}),t}onMessage(n,e,t){return e}isMember(n,e,t,i){return this.topic!==n?!1:i&&i!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:n,event:e,payload:t,joinRef:i}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(n=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=Ee.joining,this.joinPush.resend(n))}trigger(n,e,t,i){let s=this.onMessage(n,e,t,i);if(e&&!s)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let r=this.bindings.filter(a=>a.event===n);for(let a=0;a<r.length;a++)r[a].callback(s,t,i||this.joinRef())}replyEventName(n){return`chan_reply_${n}`}isClosed(){return this.state===Ee.closed}isErrored(){return this.state===Ee.errored}isJoined(){return this.state===Ee.joined}isJoining(){return this.state===Ee.joining}isLeaving(){return this.state===Ee.leaving}},Yn=class{static request(n,e,t,i,s,r,a){if(dn.XDomainRequest){let o=new dn.XDomainRequest;return this.xdomainRequest(o,n,e,i,s,r,a)}else{let o=new dn.XMLHttpRequest;return this.xhrRequest(o,n,e,t,i,s,r,a)}}static xdomainRequest(n,e,t,i,s,r,a){return n.timeout=s,n.open(e,t),n.onload=()=>{let o=this.parseJSON(n.responseText);a&&a(o)},r&&(n.ontimeout=r),n.onprogress=()=>{},n.send(i),n}static xhrRequest(n,e,t,i,s,r,a,o){return n.open(e,t,!0),n.timeout=r,n.setRequestHeader("Content-Type",i),n.onerror=()=>o&&o(null),n.onreadystatechange=()=>{if(n.readyState===qd.complete&&o){let c=this.parseJSON(n.responseText);o(c)}},a&&(n.ontimeout=a),n.send(s),n}static parseJSON(n){if(!n||n==="")return null;try{return JSON.parse(n)}catch{return console&&console.log("failed to parse JSON response",n),null}}static serialize(n,e){let t=[];for(var i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;let s=e?`${e}[${i}]`:i,r=n[i];typeof r=="object"?t.push(this.serialize(r,s)):t.push(encodeURIComponent(s)+"="+encodeURIComponent(r))}return t.join("&")}static appendParams(n,e){if(Object.keys(e).length===0)return n;let t=n.match(/\?/)?"&":"?";return`${n}${t}${this.serialize(e)}`}},Ti=class{constructor(n){this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(n),this.readyState=He.connecting,this.poll()}normalizeEndpoint(n){return n.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+ji.websocket),"$1/"+ji.longpoll)}endpointURL(){return Yn.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(n,e,t){this.close(n,e,t),this.readyState=He.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===He.open||this.readyState===He.connecting}poll(){this.ajax("GET",null,()=>this.ontimeout(),n=>{if(n){var{status:e,token:t,messages:i}=n;this.token=t}else e=0;switch(e){case 200:i.forEach(s=>{setTimeout(()=>this.onmessage({data:s}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=He.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${e}`)}})}send(n){this.ajax("POST",n,()=>this.onerror("timeout"),e=>{(!e||e.status!==200)&&(this.onerror(e&&e.status),this.closeAndRetry(1011,"internal server error",!1))})}close(n,e,t){for(let s of this.reqs)s.abort();this.readyState=He.closed;let i=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:n,reason:e,wasClean:t});typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",i)):this.onclose(i)}ajax(n,e,t,i){let s,r=()=>{this.reqs.delete(s),t()};s=Yn.request(n,this.endpointURL(),"application/json",e,this.timeout,r,a=>{this.reqs.delete(s),this.isActive()&&i(a)}),this.reqs.add(s)}},Nn={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(n,e){if(n.payload.constructor===ArrayBuffer)return e(this.binaryEncode(n));{let t=[n.join_ref,n.ref,n.topic,n.event,n.payload];return e(JSON.stringify(t))}},decode(n,e){if(n.constructor===ArrayBuffer)return e(this.binaryDecode(n));{let[t,i,s,r,a]=JSON.parse(n);return e({join_ref:t,ref:i,topic:s,event:r,payload:a})}},binaryEncode(n){let{join_ref:e,ref:t,event:i,topic:s,payload:r}=n,a=this.META_LENGTH+e.length+t.length+s.length+i.length,o=new ArrayBuffer(this.HEADER_LENGTH+a),c=new DataView(o),d=0;c.setUint8(d++,this.KINDS.push),c.setUint8(d++,e.length),c.setUint8(d++,t.length),c.setUint8(d++,s.length),c.setUint8(d++,i.length),Array.from(e,u=>c.setUint8(d++,u.charCodeAt(0))),Array.from(t,u=>c.setUint8(d++,u.charCodeAt(0))),Array.from(s,u=>c.setUint8(d++,u.charCodeAt(0))),Array.from(i,u=>c.setUint8(d++,u.charCodeAt(0)));var l=new Uint8Array(o.byteLength+r.byteLength);return l.set(new Uint8Array(o),0),l.set(new Uint8Array(r),o.byteLength),l.buffer},binaryDecode(n){let e=new DataView(n),t=e.getUint8(0),i=new TextDecoder;switch(t){case this.KINDS.push:return this.decodePush(n,e,i);case this.KINDS.reply:return this.decodeReply(n,e,i);case this.KINDS.broadcast:return this.decodeBroadcast(n,e,i)}},decodePush(n,e,t){let i=e.getUint8(1),s=e.getUint8(2),r=e.getUint8(3),a=this.HEADER_LENGTH+this.META_LENGTH-1,o=t.decode(n.slice(a,a+i));a=a+i;let c=t.decode(n.slice(a,a+s));a=a+s;let d=t.decode(n.slice(a,a+r));a=a+r;let l=n.slice(a,n.byteLength);return{join_ref:o,ref:null,topic:c,event:d,payload:l}},decodeReply(n,e,t){let i=e.getUint8(1),s=e.getUint8(2),r=e.getUint8(3),a=e.getUint8(4),o=this.HEADER_LENGTH+this.META_LENGTH,c=t.decode(n.slice(o,o+i));o=o+i;let d=t.decode(n.slice(o,o+s));o=o+s;let l=t.decode(n.slice(o,o+r));o=o+r;let u=t.decode(n.slice(o,o+a));o=o+a;let p=n.slice(o,n.byteLength),m={status:u,response:p};return{join_ref:c,ref:d,topic:l,event:Qe.reply,payload:m}},decodeBroadcast(n,e,t){let i=e.getUint8(1),s=e.getUint8(2),r=this.HEADER_LENGTH+2,a=t.decode(n.slice(r,r+i));r=r+i;let o=t.decode(n.slice(r,r+s));r=r+s;let c=n.slice(r,n.byteLength);return{join_ref:null,ref:null,topic:a,event:o,payload:c}}},zd=class{constructor(n,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=e.timeout||$d,this.transport=e.transport||dn.WebSocket||Ti,this.establishedConnections=0,this.defaultEncoder=Nn.encode.bind(Nn),this.defaultDecoder=Nn.decode.bind(Nn),this.closeWasClean=!1,this.binaryType=e.binaryType||"arraybuffer",this.connectClock=1,this.transport!==Ti?(this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let t=null;nn&&nn.addEventListener&&(nn.addEventListener("pagehide",i=>{this.conn&&(this.disconnect(),t=this.connectClock)}),nn.addEventListener("pageshow",i=>{t===this.connectClock&&(t=null,this.connect())})),this.heartbeatIntervalMs=e.heartbeatIntervalMs||3e4,this.rejoinAfterMs=i=>e.rejoinAfterMs?e.rejoinAfterMs(i):[1e3,2e3,5e3][i-1]||1e4,this.reconnectAfterMs=i=>e.reconnectAfterMs?e.reconnectAfterMs(i):[10,50,100,150,200,250,500,1e3,2e3][i-1]||5e3,this.logger=e.logger||null,this.longpollerTimeout=e.longpollerTimeout||2e4,this.params=cn(e.params||{}),this.endPoint=`${n}/${ji.websocket}`,this.vsn=e.vsn||Vd,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new Zr(()=>{this.teardown(()=>this.connect())},this.reconnectAfterMs)}getLongPollTransport(){return Ti}replaceTransport(n){this.connectClock++,this.closeWasClean=!0,this.reconnectTimer.reset(),this.sendBuffer=[],this.conn&&(this.conn.close(),this.conn=null),this.transport=n}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let n=Yn.appendParams(Yn.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return n.charAt(0)!=="/"?n:n.charAt(1)==="/"?`${this.protocol()}:${n}`:`${this.protocol()}://${location.host}${n}`}disconnect(n,e,t){this.connectClock++,this.closeWasClean=!0,this.reconnectTimer.reset(),this.teardown(n,e,t)}connect(n){n&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=cn(n)),!this.conn&&(this.connectClock++,this.closeWasClean=!1,this.conn=new this.transport(this.endPointURL()),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e))}log(n,e,t){this.logger(n,e,t)}hasLogger(){return this.logger!==null}onOpen(n){let e=this.makeRef();return this.stateChangeCallbacks.open.push([e,n]),e}onClose(n){let e=this.makeRef();return this.stateChangeCallbacks.close.push([e,n]),e}onError(n){let e=this.makeRef();return this.stateChangeCallbacks.error.push([e,n]),e}onMessage(n){let e=this.makeRef();return this.stateChangeCallbacks.message.push([e,n]),e}ping(n){if(!this.isConnected())return!1;let e=this.makeRef(),t=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:e});let i=this.onMessage(s=>{s.ref===e&&(this.off([i]),n(Date.now()-t))});return!0}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.resetHeartbeat(),this.stateChangeCallbacks.open.forEach(([,n])=>n())}heartbeatTimeout(){this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.triggerChanError(),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),Hd,"heartbeat timeout"))}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(n,e,t){if(!this.conn)return n&&n();this.waitForBufferDone(()=>{this.conn&&(e?this.conn.close(e,t||""):this.conn.close()),this.waitForSocketClosed(()=>{this.conn&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),n&&n()})})}waitForBufferDone(n,e=1){if(e===5||!this.conn||!this.conn.bufferedAmount){n();return}setTimeout(()=>{this.waitForBufferDone(n,e+1)},150*e)}waitForSocketClosed(n,e=1){if(e===5||!this.conn||this.conn.readyState===He.closed){n();return}setTimeout(()=>{this.waitForSocketClosed(n,e+1)},150*e)}onConnClose(n){let e=n&&n.code;this.hasLogger()&&this.log("transport","close",n),this.triggerChanError(),this.clearHeartbeats(),!this.closeWasClean&&e!==1e3&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,t])=>t(n))}onConnError(n){this.hasLogger()&&this.log("transport",n);let e=this.transport,t=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,i])=>{i(n,e,t)}),(e===this.transport||t>0)&&this.triggerChanError()}triggerChanError(){this.channels.forEach(n=>{n.isErrored()||n.isLeaving()||n.isClosed()||n.trigger(Qe.error)})}connectionState(){switch(this.conn&&this.conn.readyState){case He.connecting:return"connecting";case He.open:return"open";case He.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(n){this.off(n.stateChangeRefs),this.channels=this.channels.filter(e=>e.joinRef()!==n.joinRef())}off(n){for(let e in this.stateChangeCallbacks)this.stateChangeCallbacks[e]=this.stateChangeCallbacks[e].filter(([t])=>n.indexOf(t)===-1)}channel(n,e={}){let t=new Gd(n,e,this);return this.channels.push(t),t}push(n){if(this.hasLogger()){let{topic:e,event:t,payload:i,ref:s,join_ref:r}=n;this.log("push",`${e} ${t} (${r}, ${s})`,i)}this.isConnected()?this.encode(n,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(n,e=>this.conn.send(e)))}makeRef(){let n=this.ref+1;return n===this.ref?this.ref=0:this.ref=n,this.ref.toString()}sendHeartbeat(){this.pendingHeartbeatRef&&!this.isConnected()||(this.pendingHeartbeatRef=this.makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs))}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(n=>n()),this.sendBuffer=[])}onConnMessage(n){this.decode(n.data,e=>{let{topic:t,event:i,payload:s,ref:r,join_ref:a}=e;r&&r===this.pendingHeartbeatRef&&(this.clearHeartbeats(),this.pendingHeartbeatRef=null,this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)),this.hasLogger()&&this.log("receive",`${s.status||""} ${t} ${i} ${r&&"("+r+")"||""}`,s);for(let o=0;o<this.channels.length;o++){const c=this.channels[o];c.isMember(t,i,s,a)&&c.trigger(i,s,r,a)}for(let o=0;o<this.stateChangeCallbacks.message.length;o++){let[,c]=this.stateChangeCallbacks.message[o];c(e)}})}leaveOpenTopic(n){let e=this.channels.find(t=>t.topic===n&&(t.isJoined()||t.isJoining()));e&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${n}"`),e.leave())}};class Wd{constructor(e){this.connected=!1,this.config=e,this.socket=new zd(this.config.url,this.config.socketOptions||{logger:(t,i,s)=>{console.debug(`${t}: ${i}`,s)}}),this.channel=this.socket.channel(this.config.topic,this.config.params),this.eventTarget=new EventTarget}connect(){this.connected||(this.socket.onError(e=>this.emitError("socket error",e)),this.socket.connect(),this.channel.onError(e=>this.emitError("channel error",e)),this.channel.join().receive("ok",e=>{console.debug("channel joined",e)}).receive("error",e=>{this.emitError("channel join error",e)}),this.channel.on("state:change",e=>this.handleChange(e)),this.channel.on("state:patch",e=>this.handlePatch(e)),this.channel.on("error",e=>this.emitServerError(e)),this.connected=!0)}disconnect(){this.channel&&this.channel.leave(),this.socket.disconnect(),this.connected=!1}addEventListener(e,t,i){var s;this.eventTarget.addEventListener(e,t,i),e.startsWith("livestate-")||(s=this.channel)==null||s.on(e,r=>{this.eventTarget.dispatchEvent(new CustomEvent(e,{detail:r}))})}removeEventListener(e,t,i){return this.eventTarget.removeEventListener(e,t,i)}subscribe(e){this.addEventListener("livestate-change",e)}unsubscribe(e){this.removeEventListener("livestate-change",e)}emitServerError(e){this.eventTarget.dispatchEvent(new CustomEvent("livestate-error",{detail:e}))}emitError(e,t){this.eventTarget.dispatchEvent(new CustomEvent("livestate-error",{detail:{type:e,message:this.extractMessage(t)}}))}extractMessage(e){if(e&&typeof(e=="object")){const t=[e.reason,e.name,e.message].find(i=>i);return console.log(t),t}else if(typeof e=="string")return e}handleChange({state:e,version:t}){this.state=e,this.stateVersion=t,this.eventTarget.dispatchEvent(new CustomEvent("livestate-change",{detail:{state:this.state,version:this.stateVersion}}))}handlePatch({patch:e,version:t}){if(this.eventTarget.dispatchEvent(new CustomEvent("livestate-patch",{detail:{patch:e,version:t}})),this.versionMatches(t)){const{doc:i,res:s}=Fd(this.state,e,{mutate:!1});this.state=i,this.stateVersion=t,this.eventTarget.dispatchEvent(new CustomEvent("livestate-change",{detail:{state:this.state,version:this.stateVersion}}))}else this.channel.push("lvs_refresh")}versionMatches(e){return e===this.stateVersion+1||e===0}pushEvent(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}dispatchEvent(e){return this.channel.push(`lvs_evt:${e.type}`,e.detail),!0}pushCustomEvent(e){this.dispatchEvent(e)}}const ea=32;let de,je,Xn=n=>(de=0,je=n,n=rt(),je[de]?nt():n||""),nt=(n="Bad syntax",e=je[de],t=je.slice(0,de).split(`
2
2
  `),i=t.pop())=>{let s=je.slice(de-108,de).split(`
3
3
  `).pop(),r=je.slice(de+1,de+108).split(`
4
4
  `).shift();throw EvalError(`${n} at ${t.length}:${i.length} \`${s+e+r}\``,"font-weight: bold")},ln=(n=1,e=de,t)=>{if(typeof n=="number")de+=n;else for(;t=n(je.charCodeAt(de));)de+=t;return je.slice(e,de)},rt=(n=0,e,t,i,s,r)=>{for(;(t=Xn.space())&&(s=((r=$t[t])&&r(i,n))??(!i&&Xn.id()));)i=s;return e&&(t==e?de++:nt()),i},ta=n=>n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122||n==36||n==95||n>=192&&n!=215&&n!=247;Xn.space=n=>{for(;(n=je.charCodeAt(de))<=ea;)de++;return n};Xn.id=n=>ln(ta);let $t=[],bt=(n,e=ea,t,i=n.charCodeAt(0),s=n.length,r=$t[i],a=n.toUpperCase()!==n)=>$t[i]=(o,c,d=de)=>c<e&&(s<2||je.substr(de,s)==n)&&(!a||!ta(je.charCodeAt(de+s)))&&(de+=s,t(o,c))||(de=d,r==null?void 0:r(o,c)),na=(n,e,t=0)=>bt(n,e,(i,s)=>i&&(s=rt(e-t/2))&&[n,i,s]),Jd=(n,e,t)=>bt(n,e,i=>t?i&&[n,i]:!i&&(i=rt(e-.5))&&[n,i]),Kd=(n,e,t)=>{bt(n,e,(i,s)=>(i||t)&&(s=rt(e),s||t)&&((!i||i[0]!==n)&&(i=[n,i]),(s||t)&&i.push(s),i))};const ce=n=>Array.isArray(n)?Fi[n[0]](...n.slice(1)):e=>e==null?void 0:e[n],Fi={},et=(n,e,t=Fi[n])=>Fi[n]=(...i)=>e(...i)||t&&t(...i),ia=41,Qd=93,qs=34,sa=46,ra=48,Yd=57,Xd=1,Zd=4,el=5,tl=6,nl=7,il=8,aa=9,oi=10,gs=11,oa=12,vs=13,En=15,yn=18,re=(n,e,t)=>t.length?t.length>1?(na(n,Math.abs(e),e<0),et(n,(i,s)=>s&&(i=ce(i),s=ce(s),!i.length&&!s.length?(i=t(i(),s()),()=>i):r=>t(i(r),s(r))))):(Jd(n,e),et(n,(i,s)=>!s&&(i=ce(i),i.length?r=>t(i(r)):(i=t(i()),()=>i)))):(Kd(n,Math.abs(e),e<0),et(n,(...i)=>(i=i.map(ce),s=>t(...i.map(r=>r(s)))))),ca=n=>n?nt():["",(n=+ln(e=>e===sa||e>=ra&&e<=Yd||(e===69||e===101?2:0)))!=n?nt():n],da=(n,e,t,i)=>(bt(n,e,s=>s?[n==="++"?"-":"+",[n,s],["",1]]:[n,rt(e-1)]),et(n,i=(s,r)=>s[0]==="("?i(s[1]):s[0]==="."?(r=s[2],s=ce(s[1]),a=>t(s(a),r)):s[0]==="["?([,s,r]=s,s=ce(s),r=ce(r),a=>t(s(a),r(a))):a=>t(a,s)));et("",n=>()=>n);$t[qs]=n=>n?nt():["",(ln()+ln(e=>e-qs?1:0)+(ln()||nt("Bad string"))).slice(1,-1)];$t[sa]=n=>!n&&ca();for(let n=0;n<=9;n++)$t[ra+n]=ca;re(",",Xd,(...n)=>n[n.length-1]);re("||",Zd,(...n)=>{let e=0,t;for(;!t&&e<n.length;)t=n[e++];return t});re("&&",el,(...n)=>{let e=0,t=!0;for(;t&&e<n.length;)t=n[e++];return t});na("=",10,!0);et("=",(n,e)=>{let t=ce(e),i,s,r=typeof n=="string"?(a,o)=>a[n]=o:n[0]==="."?(i=ce(n[1]),s=n[2],(a,o)=>i(a)[s]=o):n[0]==="["?(i=ce(n[1]),s=ce(n[2]),(a,o)=>i(a)[s(a)]=o):nt("Bad left value");return a=>r(a,t(a))});re("+",oa,(n,e)=>n+e);re("-",oa,(n,e)=>n-e);re("*",vs,(n,e)=>n*e);re("/",vs,(n,e)=>n/e);re("%",vs,(n,e)=>n%e);re("|",tl,(n,e)=>n|e);re("&",il,(n,e)=>n&e);re("^",nl,(n,e)=>n^e);re("==",aa,(n,e)=>n==e);re("!=",aa,(n,e)=>n!=e);re(">",oi,(n,e)=>n>e);re(">=",oi,(n,e)=>n>=e);re("<",oi,(n,e)=>n<e);re("<=",oi,(n,e)=>n<=e);re(">>",gs,(n,e)=>n>>e);re(">>>",gs,(n,e)=>n>>>e);re("<<",gs,(n,e)=>n<<e);re("+",En,n=>+n);re("-",En,n=>-n);re("!",En,n=>!n);da("++",En,(n,e)=>++n[e]);da("--",En,(n,e)=>--n[e]);bt("[",yn,n=>n&&["[",n,rt(0,Qd)||nt()]);et("[",(n,e)=>e&&(n=ce(n),e=ce(e),t=>n(t)[e(t)]));bt(".",yn,(n,e)=>n&&(e=rt(yn))&&[".",n,e]);et(".",(n,e)=>(n=ce(n),e=e[0]?e:e[1],t=>n(t)[e]));bt("(",yn,n=>!n&&["(",rt(0,ia)||nt()]);bt("(",yn,(n,e)=>n&&(e=rt(0,ia),e?["(",n,e]:["(",n,""]));et("(",(n,e,t,i,s)=>e==null?ce(n):(s=e==""?()=>[]:e[0]===","?(e=e.slice(1).map(ce),r=>e.map(a=>a(r))):(e=ce(e),r=>[e(r)]),n[0]==="."?(t=n[2],n=ce(n[1]),r=>n(r)[t](...s(r))):n[0]==="["?(t=ce(n[2]),n=ce(n[1]),r=>n(r)[t(r)](...s(r))):(n=ce(n),r=>n(r)(...s(r)))));Promise.resolve();var Gs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/*! *****************************************************************************
@@ -1,7 +1,7 @@
1
1
  var yc = Object.defineProperty;
2
2
  var bc = (n, e, t) => e in n ? yc(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
3
  var x = (n, e, t) => (bc(n, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { b as Tc, d as Cc } from "./constants-B_G5_Qdv.js";
4
+ import { b as Tc, d as Cc } from "./constants-DxKL5GJ4.js";
5
5
  function gn() {
6
6
  }
7
7
  function Gr(n) {
package/dist/main.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const n=require("./constants-BimsT71j.cjs"),E=e=>Object.freeze(Object.defineProperty({__proto__:null,default:e},Symbol.toStringTag,{value:"Module"}));let a,m,r;u();S();function S(){window.addEventListener("popstate",u)}async function u(){const e=document.querySelector("script[src*='/liveroom-client-element']");e==null||e.setAttribute("version",n.VERSION);const{roomId:t,roomToken:o}=A(e);if(t&&o&&(t!=a||o!=m)){a=t,m=o,sessionStorage==null||sessionStorage.setItem(n.SESSION_STORAGE_KEY_ROOM_ID,a),sessionStorage==null||sessionStorage.setItem(n.SESSION_STORAGE_KEY_ROOM_TOKEN,m),r&&(r.remove(),r=void 0);const s=e==null?void 0:e.getAttribute("data-url");await O(s||"wss://liveroom.app/room",a,m)}}async function O(e,t,o){if(!t||!o)return!1;await Promise.resolve().then(()=>E(require("./liveroom-client-element.cjs"))),console.log(`[Liveroom] Installed successfully (v${n.VERSION})`),r=document.createElement(n.ELEMENT_TAG),r.setAttribute("url",e),r.setAttribute("version",n.VERSION),t&&r.setAttribute("room_id",t),t&&r.setAttribute("room_token",o);const s=R();s&&r.setAttribute("user_name",s);const _=f();return _&&r.setAttribute("user_color",_),document.body.appendChild(r),console.log("[Liveroom] Injected successfully"),!0}function R(){const t=new URLSearchParams(window.location.search).get(n.QUERY_PARAM_KEY_USER_NAME),o=sessionStorage==null?void 0:sessionStorage.getItem(n.SESSION_STORAGE_KEY_USER_NAME);return t||o||null}function f(){const t=new URLSearchParams(window.location.search).get(n.QUERY_PARAM_KEY_USER_COLOR),o=sessionStorage==null?void 0:sessionStorage.getItem(n.SESSION_STORAGE_KEY_USER_COLOR);return t||o||null}function A(e){const t=new URLSearchParams(window.location.search),o=t.get(n.QUERY_PARAM_KEY_ROOM_ID),s=t.get(n.QUERY_PARAM_KEY_ROOM_TOKEN),_=sessionStorage==null?void 0:sessionStorage.getItem(n.SESSION_STORAGE_KEY_ROOM_ID),l=sessionStorage==null?void 0:sessionStorage.getItem(n.SESSION_STORAGE_KEY_ROOM_TOKEN),c=(e==null?void 0:e.getAttribute("data-roomid"))||null,i=(e==null?void 0:e.getAttribute("data-roomtoken"))||null;return{roomId:g(o||_||c),roomToken:s||l||i}}function g(e){const t=e==null?void 0:e.split("https://meet.google.com/"),o=t==null?void 0:t[1];return(o?o.split("?")[0]:t==null?void 0:t[0])||null}
1
+ "use strict";const n=require("./constants-ClJvwRne.cjs"),E=e=>Object.freeze(Object.defineProperty({__proto__:null,default:e},Symbol.toStringTag,{value:"Module"}));let a,m,r;u();S();function S(){window.addEventListener("popstate",u)}async function u(){const e=document.querySelector("script[src*='/liveroom-client-element']");e==null||e.setAttribute("version",n.VERSION);const{roomId:t,roomToken:o}=A(e);if(t&&o&&(t!=a||o!=m)){a=t,m=o,sessionStorage==null||sessionStorage.setItem(n.SESSION_STORAGE_KEY_ROOM_ID,a),sessionStorage==null||sessionStorage.setItem(n.SESSION_STORAGE_KEY_ROOM_TOKEN,m),r&&(r.remove(),r=void 0);const s=e==null?void 0:e.getAttribute("data-url");await O(s||"wss://liveroom.app/room",a,m)}}async function O(e,t,o){if(!t||!o)return!1;await Promise.resolve().then(()=>E(require("./liveroom-client-element.cjs"))),console.log(`[Liveroom] Installed successfully (v${n.VERSION})`),r=document.createElement(n.ELEMENT_TAG),r.setAttribute("url",e),r.setAttribute("version",n.VERSION),t&&r.setAttribute("room_id",t),t&&r.setAttribute("room_token",o);const s=R();s&&r.setAttribute("user_name",s);const _=f();return _&&r.setAttribute("user_color",_),document.body.appendChild(r),console.log("[Liveroom] Injected successfully"),!0}function R(){const t=new URLSearchParams(window.location.search).get(n.QUERY_PARAM_KEY_USER_NAME),o=sessionStorage==null?void 0:sessionStorage.getItem(n.SESSION_STORAGE_KEY_USER_NAME);return t||o||null}function f(){const t=new URLSearchParams(window.location.search).get(n.QUERY_PARAM_KEY_USER_COLOR),o=sessionStorage==null?void 0:sessionStorage.getItem(n.SESSION_STORAGE_KEY_USER_COLOR);return t||o||null}function A(e){const t=new URLSearchParams(window.location.search),o=t.get(n.QUERY_PARAM_KEY_ROOM_ID),s=t.get(n.QUERY_PARAM_KEY_ROOM_TOKEN),_=sessionStorage==null?void 0:sessionStorage.getItem(n.SESSION_STORAGE_KEY_ROOM_ID),l=sessionStorage==null?void 0:sessionStorage.getItem(n.SESSION_STORAGE_KEY_ROOM_TOKEN),c=(e==null?void 0:e.getAttribute("data-roomid"))||null,i=(e==null?void 0:e.getAttribute("data-roomtoken"))||null;return{roomId:g(o||c||_),roomToken:s||i||l}}function g(e){const t=e==null?void 0:e.split("https://meet.google.com/"),o=t==null?void 0:t[1];return(o?o.split("?")[0]:t==null?void 0:t[0])||null}
package/dist/main.js CHANGED
@@ -1,4 +1,4 @@
1
- import { V as _, S as u, a as c, E as f, Q as R, b as A, c as g, d, e as O, f as I } from "./constants-B_G5_Qdv.js";
1
+ import { V as _, S as u, a as c, E as f, Q as R, b as A, c as g, d, e as O, f as I } from "./constants-DxKL5GJ4.js";
2
2
  let a, m, s;
3
3
  l();
4
4
  b();
@@ -53,9 +53,9 @@ function Y(e) {
53
53
  ), E = (e == null ? void 0 : e.getAttribute("data-roomid")) || null, S = (e == null ? void 0 : e.getAttribute("data-roomtoken")) || null;
54
54
  return {
55
55
  roomId: M(
56
- o || r || E
56
+ o || E || r
57
57
  ),
58
- roomToken: n || i || S
58
+ roomToken: n || S || i
59
59
  };
60
60
  }
61
61
  function M(e) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "liveroom-client-element",
3
3
  "private": false,
4
- "version": "0.0.47",
4
+ "version": "0.0.48",
5
5
  "type": "module",
6
6
  "module": "./dist/main.js",
7
7
  "main": "./dist/main.cjs",