liveroom-client-element 0.0.39 → 0.0.40
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.
- package/dist/{constants-c295aa34.js → constants-eb4cd3ce.js} +1 -1
- package/dist/{constants-58223755.cjs → constants-f9ac3da1.cjs} +1 -1
- package/dist/liveroom-client-element.cjs +1 -1
- package/dist/liveroom-client-element.js +1 -1
- package/dist/main.cjs +1 -1
- package/dist/main.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e = "liveroom-client-element", t = "0.0.
|
|
1
|
+
const e = "liveroom-client-element", t = "0.0.40", s = "module", i = "./dist/main.js", o = "./dist/main.cjs", n = [
|
|
2
2
|
"dist",
|
|
3
3
|
"!dist/vite.svg"
|
|
4
4
|
], c = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e="liveroom-client-element",t="0.0.
|
|
1
|
+
"use strict";const e="liveroom-client-element",t="0.0.40",i="module",s="./dist/main.js",o="./dist/main.cjs",n=["dist","!dist/vite.svg"],_={".":{import:"./dist/main.js",require:"./dist/main.cjs"},"./liveroom-client-element":{import:"./dist/liveroom-client-element.js",require:"./dist/liveroom-client-element.cjs"}},c={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"},E={"livekit-client":"1.13.4","phx-live-state":"0.10.2"},r={"@sveltejs/vite-plugin-svelte":"2.4.6","@tsconfig/svelte":"5.0.2",prettier:"3.0.3",svelte:"4.2.1","svelte-check":"3.5.2",tslib:"2.6.2",typescript:"5.2.2",vite:"4.4.9"},l={name:e,private:!1,version:t,type:i,module:s,main:o,files:n,exports:_,scripts:c,dependencies:E,devDependencies:r},m=l.version,R="liveroom-client-element",v="_liveroom",S="_liveroom_user_name",O="_liveroom_user_color",p="liveroom-room-id",A="liveroom-user-name",d="liveroom-user-color";exports.ELEMENT_TAG=R;exports.QUERY_PARAM_KEY_ROOM_ID=v;exports.QUERY_PARAM_KEY_USER_COLOR=O;exports.QUERY_PARAM_KEY_USER_NAME=S;exports.SESSION_STORAGE_KEY_ROOM_ID=p;exports.SESSION_STORAGE_KEY_USER_COLOR=d;exports.SESSION_STORAGE_KEY_USER_NAME=A;exports.VERSION=m;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Fo=Object.defineProperty;var Bo=(i,e,t)=>e in i?Fo(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var x=(i,e,t)=>(Bo(i,typeof e!="symbol"?e+"":e,t),t);const $s=require("./constants-58223755.cjs");function Wi(){}function qr(i){return i()}function qs(){return Object.create(null)}function tn(i){i.forEach(qr)}function Hr(i){return typeof i=="function"}function Jo(i,e){return i!=i?e==e:i!==e||i&&typeof i=="object"||typeof i=="function"}function jo(i){return Object.keys(i).length===0}function Ne(i,e){i.appendChild(e)}function Vo(i,e,t){const n=$o(i);if(!n.getElementById(e)){const s=Xe("style");s.id=e,s.textContent=t,qo(n,s)}}function $o(i){if(!i)return document;const e=i.getRootNode?i.getRootNode():i.ownerDocument;return e&&e.host?e:i.ownerDocument}function qo(i,e){return Ne(i.head||i,e),e.sheet}function Nn(i,e,t){i.insertBefore(e,t||null)}function nn(i){i.parentNode&&i.parentNode.removeChild(i)}function Xe(i){return document.createElement(i)}function Hs(i){return document.createElementNS("http://www.w3.org/2000/svg",i)}function zr(i){return document.createTextNode(i)}function cn(){return zr(" ")}function G(i,e,t){t==null?i.removeAttribute(e):i.getAttribute(e)!==t&&i.setAttribute(e,t)}function Ho(i){return Array.from(i.childNodes)}function zo(i,e){e=""+e,i.data!==e&&(i.data=e)}function Ye(i,e,t,n){t==null?i.style.removeProperty(e):i.style.setProperty(e,t,n?"important":"")}function Wo(i){const e={};return i.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let Gi;function Fi(i){Gi=i}function Wr(){if(!Gi)throw new Error("Function called outside component initialization");return Gi}function Go(i){Wr().$$.on_mount.push(i)}function Ko(i){Wr().$$.on_destroy.push(i)}const mi=[],is=[];let yi=[];const zs=[],Yo=Promise.resolve();let ns=!1;function Xo(){ns||(ns=!0,Yo.then(ni))}function ss(i){yi.push(i)}const $n=new Set;let fi=0;function ni(){if(fi!==0)return;const i=Gi;do{try{for(;fi<mi.length;){const e=mi[fi];fi++,Fi(e),Qo(e.$$)}}catch(e){throw mi.length=0,fi=0,e}for(Fi(null),mi.length=0,fi=0;is.length;)is.pop()();for(let e=0;e<yi.length;e+=1){const t=yi[e];$n.has(t)||($n.add(t),t())}yi.length=0}while(mi.length);for(;zs.length;)zs.pop()();ns=!1,$n.clear(),Fi(i)}function Qo(i){if(i.fragment!==null){i.update(),tn(i.before_update);const e=i.dirty;i.dirty=[-1],i.fragment&&i.fragment.p(i.ctx,e),i.after_update.forEach(ss)}}function Zo(i){const e=[],t=[];yi.forEach(n=>i.indexOf(n)===-1?e.push(n):t.push(n)),t.forEach(n=>n()),yi=e}const ec=new Set;function Gr(i,e){i&&i.i&&(ec.delete(i),i.i(e))}function Ws(i){return(i==null?void 0:i.length)!==void 0?i:Array.from(i)}function tc(i,e){i.d(1),e.delete(i.key)}function ic(i,e,t,n,s,r,a,o,c,u,d,h){let f=i.length,p=r.length,b=f;const T={};for(;b--;)T[i[b].key]=b;const w=[],_=new Map,M=new Map,Q=[];for(b=p;b--;){const q=h(s,r,b),K=t(q);let I=a.get(K);I?n&&Q.push(()=>I.p(q,e)):(I=u(K,q),I.c()),_.set(K,w[b]=I),K in T&&M.set(K,Math.abs(b-T[K]))}const j=new Set,he=new Set;function ae(q){Gr(q,1),q.m(o,d),a.set(q.key,q),d=q.first,p--}for(;f&&p;){const q=w[p-1],K=i[f-1],I=q.key,F=K.key;q===K?(d=q.first,f--,p--):_.has(F)?!a.has(I)||j.has(I)?ae(q):he.has(F)?f--:M.get(I)>M.get(F)?(he.add(I),ae(q)):(j.add(F),f--):(c(K,a),f--)}for(;f--;){const q=i[f];_.has(q.key)||c(q,a)}for(;p;)ae(w[p-1]);return tn(Q),w}function nc(i,e,t){const{fragment:n,after_update:s}=i.$$;n&&n.m(e,t),ss(()=>{const r=i.$$.on_mount.map(qr).filter(Hr);i.$$.on_destroy?i.$$.on_destroy.push(...r):tn(r),i.$$.on_mount=[]}),s.forEach(ss)}function sc(i,e){const t=i.$$;t.fragment!==null&&(Zo(t.after_update),tn(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function rc(i,e){i.$$.dirty[0]===-1&&(mi.push(i),Xo(),i.$$.dirty.fill(0)),i.$$.dirty[e/31|0]|=1<<e%31}function ac(i,e,t,n,s,r,a=null,o=[-1]){const c=Gi;Fi(i);const u=i.$$={fragment:null,ctx:[],props:r,update:Wi,not_equal:s,bound:qs(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(c?c.$$.context:[])),callbacks:qs(),dirty:o,skip_bound:!1,root:e.target||c.$$.root};a&&a(u.root);let d=!1;if(u.ctx=t?t(i,e.props||{},(h,f,...p)=>{const b=p.length?p[0]:f;return u.ctx&&s(u.ctx[h],u.ctx[h]=b)&&(!u.skip_bound&&u.bound[h]&&u.bound[h](b),d&&rc(i,h)),f}):[],u.update(),d=!0,tn(u.before_update),u.fragment=n?n(u.ctx):!1,e.target){if(e.hydrate){const h=Ho(e.target);u.fragment&&u.fragment.l(h),h.forEach(nn)}else u.fragment&&u.fragment.c();e.intro&&Gr(i.$$.fragment),nc(i,e.target,e.anchor),ni()}Fi(c)}let Kr;typeof HTMLElement=="function"&&(Kr=class extends HTMLElement{constructor(e,t,n){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,n&&this.attachShadow({mode:"open"})}addEventListener(e,t,n){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,n)}removeEventListener(e,t,n){if(super.removeEventListener(e,t,n),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=Xe("slot"),r!=="default"&&G(a,"name",r)},m:function(u,d){Nn(u,a,d)},d:function(u){u&&nn(a)}}}};if(await Promise.resolve(),!this.$$cn)return;const t={},n=Wo(this);for(const r of this.$$s)r in n&&(t[r]=[e(r)]);for(const r of this.attributes){const a=this.$$g_p(r.name);a in this.$$d||(this.$$d[a]=pn(a,r.value,this.$$p_d,"toProp"))}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=pn(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,n){var s;this.$$r||(e=this.$$g_p(e),this.$$d[e]=pn(e,n,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 pn(i,e,t,n){var r;const s=(r=t[i])==null?void 0:r.type;if(e=s==="Boolean"&&typeof e!="boolean"?e!=null:e,!n||!t[i])return e;if(n==="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 oc(i,e,t,n,s,r){let a=class extends Kr{constructor(){super(i,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 u;c=pn(o,c,e),this.$$d[o]=c,(u=this.$$c)==null||u.$set({[o]:c})}})}),n.forEach(o=>{Object.defineProperty(a.prototype,o,{get(){var c;return(c=this.$$c)==null?void 0:c[o]}})}),r&&(a=r(a)),i.element=a,a}class cc{constructor(){x(this,"$$");x(this,"$$set")}$destroy(){sc(this,1),this.$destroy=Wi}$on(e,t){if(!Hr(t))return Wi;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const s=n.indexOf(t);s!==-1&&n.splice(s,1)}}$set(e){this.$$set&&!jo(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const uc="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(uc);const{isArray:dc}=Array,lc=Object.keys,Ki=i=>{if(!i)return i;if(dc(i)){const e=[],t=i.length;for(let n=0;n<t;n++)e.push(Ki(i[n]));return e}else if(typeof i=="object"){const e=lc(i),t=e.length,n={};for(let s=0;s<t;s++){const r=e[s];n[r]=Ki(i[r])}return n}return i};class Ue{constructor(e){x(this,"path");x(this,"from");this.path=e}}const hc=/~1/g,fc=/~0/g,pc=/~/g,mc=/\//g;function gc(i){return i.indexOf("~")===-1?i:i.replace(hc,"/").replace(fc,"~")}function vc(i){return i.indexOf("/")===-1&&i.indexOf("~")===-1?i:i.replace(pc,"~0").replace(mc,"~1")}function yc(i){return i?i.slice(1).split("/").map(gc):[]}function W(i){return bc(i)?"":"/"+i.map(e=>vc(String(e))).join("/")}const $=i=>typeof i=="string"?yc(i):i,bc=i=>!i.length,kc=Object.prototype.hasOwnProperty;function Tc(i,e){return kc.call(i,e)}const{isArray:Yr}=Array,te=(i,e)=>{const t=e.length;if(!t)return{val:i};let n,s;for(let a=0;a<t;a++)if(n=i,s=e[a],Yr(n)){const o=n.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")}i=n[s]}else if(typeof n=="object"&&n)i=Tc(n,s)?n[s]:void 0;else throw new Error("NOT_FOUND");return{val:i,obj:n,key:s}},sn=i=>Yr(i.obj)&&typeof i.key=="number",xn=i=>typeof i.obj=="object"&&typeof i.key=="string";class Is extends Ue{constructor(t,n){super(t);x(this,"value");this.value=n}op(){return"add"}code(){return 0}apply(t){const{val:n,key:s,obj:r}=te(t,this.path),a=Ki(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:n}}toJson(t){return{op:"add",path:W(this.path),value:this.value}}toCompact(t,n){return[n?"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 Ue{constructor(t,n){super(t);x(this,"oldValue");this.oldValue=n}op(){return"remove"}code(){return 1}apply(t){const n=te(t,this.path);if(n.val===void 0)throw new Error("NOT_FOUND");return xn(n)?delete n.obj[n.key]:sn(n)?n.val!==void 0&&n.obj.splice(n.key,1):t=null,{doc:t,old:n.val}}toJson(t){const n={op:"remove",path:W(this.path)};return this.oldValue!==void 0&&(n.oldValue=this.oldValue),n}toCompact(t,n){const s=n?"remove":1;return this.oldValue===void 0?[s,this.path]:[s,this.path,this.oldValue]}encode(t,n){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 Sc extends Ue{constructor(t,n,s){super(t);x(this,"value");x(this,"oldValue");this.value=n,this.oldValue=s}op(){return"replace"}code(){return 2}apply(t){const n=te(t,this.path);if(n.val===void 0)throw new Error("NOT_FOUND");return xn(n)?n.obj[n.key]=this.value:sn(n)?n.obj[n.key]=this.value:t=this.value,{doc:t,old:n.val}}toJson(t){const n={op:"replace",path:W(this.path),value:this.value};return this.oldValue!==void 0&&(n.oldValue=this.oldValue),n}toCompact(t,n){const s=n?"replace":2;return this.oldValue===void 0?[s,this.path,this.value]:[s,this.path,this.value,this.oldValue]}encode(t,n){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 Cc extends Ue{constructor(t,n){super(t);x(this,"from");this.from=n}op(){return"move"}code(){return 4}apply(t){const n=new Xr($(this.from),void 0).apply(t);return new Is(this.path,n.old).apply(n.doc)}toJson(t){return{op:"move",path:W(this.path),from:W(this.from)}}toCompact(t,n){return[n?"move":4,this.path,this.from]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(4),t.encodeArray(this.path),t.encodeArray(this.from)}}class wc extends Ue{constructor(t,n){super(t);x(this,"from");this.from=n}op(){return"copy"}code(){return 3}apply(t){const{val:n}=te(t,this.from);if(n===void 0)throw new Error("NOT_FOUND");return new Is(this.path,Ki(n)).apply(t)}toJson(t){return{op:"copy",path:W(this.path),from:W(this.from)}}toCompact(t,n){return[n?"copy":3,this.path,this.from]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(3),t.encodeArray(this.path),t.encodeArray(this.from)}}class Ce extends Ue{apply(e){if(!this.test(e))throw new Error("TEST");return{doc:e}}}const Pn=(i,e)=>{if(i===e)return!0;if(i&&e&&typeof i=="object"&&typeof e=="object"){if(i.constructor!==e.constructor)return!1;let t,n,s;if(Array.isArray(i)){if(t=i.length,t!==e.length)return!1;for(n=t;n--!==0;)if(!Pn(i[n],e[n]))return!1;return!0}if(s=Object.keys(i),t=s.length,t!==Object.keys(e).length)return!1;for(n=t;n--!==0;){const r=s[n];if(!Pn(i[r],e[r]))return!1}return!0}return!1};class Ec extends Ce{constructor(t,n,s){super(t);x(this,"value");x(this,"not");this.value=n,this.not=s}op(){return"test"}code(){return 5}test(t){const{val:n}=te(t,this.path);if(n===void 0)return!!this.not;const s=Pn(n,this.value);return this.not?!s:s}toJson(t){const n={op:"test",path:W(t?this.path.slice(t.path.length):this.path),value:this.value};return this.not&&(n.not=this.not),n}toCompact(t,n){const s=t?this.path.slice(t.path.length):this.path,r=n?"test":5;return this.not?[r,s,this.value,1]:[r,s,this.value]}encode(t,n){t.encodeArrayHeader(this.not?4:3),t.writer.u8(5),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeAny(this.value),this.not&&t.writer.u8(1)}}class Pc extends Ue{constructor(e){super(e)}op(){return"flip"}code(){return 8}apply(e){const t=te(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:W(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 Rc extends Ue{constructor(t,n){super(t);x(this,"inc");this.inc=n}op(){return"inc"}code(){return 9}apply(t){const n=te(t,this.path),s=this.inc+Number(n.val);return n.obj?n.obj[n.key]=s:t=s,{doc:t,old:n.val}}toJson(t){return{op:"inc",path:W(this.path),inc:this.inc}}toCompact(t,n){return[n?"inc":9,this.path,this.inc]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(9),t.encodeArray(this.path),t.encodeNumber(this.inc)}}class _c extends Ue{constructor(t,n,s){super(t);x(this,"pos");x(this,"str");this.pos=n,this.str=s}op(){return"str_ins"}code(){return 6}apply(t){const{val:n,key:s,obj:r}=te(t,this.path);if(typeof n!="string"){if(n!==void 0)throw new Error("NOT_A_STRING");if(this.pos!==0)throw new Error("POS")}const a=typeof n=="string"?n:"",o=Math.min(this.pos,a.length),c=a.slice(0,o),u=a.slice(o),d=c+this.str+u;return r?r[s]=d:t=d,{doc:t,old:n}}toJson(t){return{op:"str_ins",path:W(this.path),pos:this.pos,str:this.str}}toCompact(t,n){return[n?"str_ins":6,this.path,this.pos,this.str]}encode(t,n){t.encodeArrayHeader(4),t.writer.u8(6),t.encodeArray(this.path),t.encodeNumber(this.pos),t.encodeString(this.str)}}class Ic extends Ue{constructor(t,n,s,r){super(t);x(this,"pos");x(this,"str");x(this,"len");this.pos=n,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:n,key:s,obj:r}=te(t,this.path);if(typeof n!="string")throw new Error("NOT_A_STRING");const a=n.length,o=Math.min(this.pos,n.length),c=Math.min(o,a),u=this.str!==void 0?this.str.length:this.len,d=Math.min(o+u,a),h=n.slice(0,c),f=n.substr(d),p=h+f;return r?r[s]=p:t=p,{doc:t,old:n}}toJson(t){return typeof this.str=="string"?{op:"str_del",path:W(this.path),pos:this.pos,str:this.str}:{op:"str_del",path:W(this.path),pos:this.pos,len:this.len}}toCompact(t,n){const s=n?"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,n){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:Ac}=Array,rs=i=>!!i&&typeof i=="object"&&typeof i.text=="string",as=i=>!!i&&typeof i=="object"&&Ac(i.children),Oc=(i,e)=>{const t=new RegExp(i,e?"i":void 0);return n=>t.test(n)};class Lc extends Ue{constructor(t,n,s){super(t);x(this,"pos");x(this,"props");this.pos=n,this.props=s}op(){return"split"}code(){return 10}apply(t){const n=te(t,this.path);if(n.val===void 0)throw new Error("NOT_FOUND");const s=this.split(n.val);return xn(n)?n.obj[n.key]=s:sn(n)?(n.obj[n.key]=s[0],n.obj.splice(n.key+1,0,s[1])):t=s,{doc:t,old:n.val}}split(t){if(typeof t=="string"){const{pos:n,props:s}=this,r=t.slice(0,n),a=t.slice(n);return s?[{...s,text:r},{...s,text:a}]:[r,a]}else if(rs(t)){const{pos:n,props:s}=this,r=t.text.slice(0,n),a=t.text.slice(n);return[{...t,...s,text:r},{...t,...s,text:a}]}else if(as(t)){const{pos:n,props:s}=this,r=t.children.slice(0,n),a=t.children.slice(n);return[{...t,...s,children:r},{...t,...s,children:a}]}else if(typeof t=="number"){const{pos:n}=this;return[n,t-n]}else return[t,t]}toJson(t){const n={op:"split",path:W(this.path),pos:this.pos};return this.props&&(n.props=this.props),n}toCompact(t,n){const s=n?"split":10;return this.props?[s,this.path,this.pos,this.props]:[s,this.path,this.pos]}encode(t,n){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 Nc extends Ue{constructor(t,n,s){super(t);x(this,"pos");x(this,"props");this.pos=n,this.props=s}op(){return"merge"}code(){return 11}apply(t){const n=te(t,this.path);if(!sn(n))throw new Error("INVALID_TARGET");if(n.key<=0)throw new Error("INVALID_KEY");const s=n.obj[n.key-1],r=n.obj[n.key],a=this.merge(s,r);return n.obj[n.key-1]=a,n.obj.splice(n.key,1),{doc:t,old:[s,r]}}merge(t,n){return typeof t=="string"&&typeof n=="string"||typeof t=="number"&&typeof n=="number"?t+n:rs(t)&&rs(n)?{...t,...n,text:t.text+n.text}:as(t)&&as(n)?{...t,...n,children:[...t.children,...n.children]}:[t,n]}toJson(t){const n={op:"merge",path:W(this.path),pos:this.pos};return this.props&&(n.props=this.props),n}toCompact(t,n){const s=n?"merge":11;return this.props?[s,this.path,this.pos,this.props]:[s,this.path,this.pos]}encode(t,n){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:xc}=Array;class Dc extends Ue{constructor(t,n,s){super(t);x(this,"props");x(this,"deleteNull");this.props=n,this.deleteNull=s}op(){return"extend"}code(){return 12}apply(t){const n=te(t,this.path);return sn(n)?n.val!==void 0&&(n.obj[n.key]=this.extend(n.val)):xn(n)?n.obj[n.key]=this.extend(n.val):t=this.extend(t),{doc:t}}extend(t){if(xc(t)||typeof t!="object"||!t)return t;for(const[n,s]of Object.entries(this.props)){if(n==="__proto__")throw new Error("NO_PROTO");if(s===null&&this.deleteNull){delete t[n];continue}t[n]=s}return t}toJson(t){const n={op:"extend",path:W(this.path),props:this.props};return this.deleteNull&&(n.deleteNull=this.deleteNull),n}toCompact(t,n){const s=n?"extend":12;return this.deleteNull?[s,this.path,this.props,1]:[s,this.path,this.props]}encode(t,n){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 Mc extends Ce{constructor(e){super(e)}op(){return"defined"}code(){return 31}test(e){const{val:t}=te(e,this.path);return t!==void 0}toJson(e){return{op:"defined",path:W(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 Uc extends Ce{constructor(e){super(e)}op(){return"undefined"}code(){return 38}test(e){try{const{val:t}=te(e,this.path);return t===void 0}catch(t){if(t.message==="NOT_FOUND")return!0;throw t}}toJson(e){return{op:"undefined",path:W(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:Fc}=Array;class Bc extends Ce{constructor(t,n){super(t);x(this,"type");this.type=n}op(){return"test_type"}code(){return 39}test(t){const{val:n}=te(t,this.path);return n===null?this.type.indexOf("null")>-1:Fc(n)?this.type.indexOf("array")>-1:this.type.indexOf(typeof n)>-1||typeof n=="number"&&n===Math.round(n)&&this.type.indexOf("integer")>-1}toJson(t){return{op:"test_type",path:W(t?this.path.slice(t.path.length):this.path),type:this.type}}toCompact(t,n){return[n?"test_type":39,t?this.path.slice(t.path.length):this.path,this.type]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(39),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeArray(this.type)}}class Jc extends Ce{constructor(t,n,s,r){super(t);x(this,"pos");x(this,"str");x(this,"not");this.pos=n,this.str=s,this.not=r}op(){return"test_string"}code(){return 40}test(t){const{val:n}=te(t,this.path);if(typeof n!="string")return!1;const s=n.length,r=Math.min(this.pos,s),a=Math.min(this.pos+this.str.length,s),o=n.substring(r,a)===this.str;return this.not?!o:o}toJson(t){const n={op:"test_string",path:W(t?this.path.slice(t.path.length):this.path),pos:this.pos,str:this.str};return this.not&&(n.not=this.not),n}toCompact(t,n){const s=n?"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,n){t.encodeArrayHeader(this.not?5:4),t.writer.u8(40),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeNumber(this.pos),t.encodeString(this.str),this.not&&t.writer.u8(1)}}class jc extends Ce{constructor(t,n,s){super(t);x(this,"len");x(this,"not");this.len=n,this.not=s}op(){return"test_string_len"}code(){return 41}test(t){const{val:n}=te(t,this.path);if(typeof n!="string")return!1;const r=n.length>=this.len;return this.not?!r:r}toJson(t){const n={op:"test_string_len",path:W(t?this.path.slice(t.path.length):this.path),len:this.len};return this.not&&(n.not=this.not),n}toCompact(t,n){const s=n?"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,n){t.encodeArrayHeader(this.not?4:3),t.writer.u8(41),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeNumber(this.len),this.not&&t.writer.u8(1)}}class Vc extends Ce{constructor(t,n,s){super(t);x(this,"value");x(this,"ignore_case");this.value=n,this.ignore_case=s}op(){return"contains"}code(){return 30}test(t){const{val:n}=te(t,this.path);if(typeof n!="string")return!1;const s=this.ignore_case?n.toLowerCase():n,r=this.ignore_case?this.value.toLowerCase():this.value;return s.indexOf(r)>-1}toJson(t){const n={op:"contains",path:W(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(n.ignore_case=this.ignore_case),n}toCompact(t,n){const s=n?"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,n){const s=this.ignore_case;t.encodeArrayHeader(s?4:3),t.writer.u8(30),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeString(this.value),s&&t.writer.u8(1)}}class $c extends Ce{constructor(t,n,s){super(t);x(this,"value");x(this,"ignore_case");this.value=n,this.ignore_case=s}op(){return"ends"}code(){return 32}test(t){const{val:n}=te(t,this.path);if(typeof n!="string")return!1;const s=this.ignore_case?n.toLowerCase():n,r=this.ignore_case?this.value.toLowerCase():this.value;return s.endsWith(r)}toJson(t){const n={op:"ends",path:W(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(n.ignore_case=this.ignore_case),n}toCompact(t,n){const s=n?"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,n){const s=this.ignore_case;t.encodeArrayHeader(s?4:3),t.writer.u8(32),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeString(this.value),s&&t.writer.u8(1)}}class qc extends Ce{constructor(t,n,s){super(t);x(this,"value");x(this,"ignore_case");this.value=n,this.ignore_case=s}op(){return"starts"}code(){return 37}test(t){const{val:n}=te(t,this.path);if(typeof n!="string")return!1;const s=this.ignore_case?n.toLowerCase():n,r=this.ignore_case?this.value.toLowerCase():this.value;return s.startsWith(r)}toJson(t){const n={op:"starts",path:W(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(n.ignore_case=this.ignore_case),n}toCompact(t,n){const s=n?"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,n){const s=this.ignore_case;t.encodeArrayHeader(s?4:3),t.writer.u8(37),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeString(this.value),s&&t.writer.u8(1)}}class Hc extends Ce{constructor(t,n){super(t);x(this,"value");this.value=n}op(){return"in"}code(){return 33}test(t){const{val:n}=te(t,this.path);for(const s of this.value)if(Pn(n,s))return!0;return!1}toJson(t){return{op:"in",path:W(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,n){return[n?"in":33,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(33),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeArray(this.value)}}class zc extends Ce{constructor(t,n){super(t);x(this,"value");this.value=n}op(){return"less"}code(){return 34}test(t){const{val:n}=te(t,this.path);return typeof n!="number"?!1:n<this.value}toJson(t){return{op:"less",path:W(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,n){return[n?"less":34,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(34),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeNumber(this.value)}}class Wc extends Ce{constructor(t,n){super(t);x(this,"value");this.value=n}op(){return"more"}code(){return 36}test(t){const{val:n}=te(t,this.path);return typeof n!="number"?!1:n>this.value}toJson(t){return{op:"more",path:W(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,n){return[n?"more":36,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(36),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeNumber(this.value)}}class As extends Ce{constructor(t,n){super(t);x(this,"ops");this.ops=n}}class Gc extends As{constructor(t,n){super(t,n);x(this,"ops");this.ops=n}op(){return"and"}code(){return 43}test(t){for(const n of this.ops)if(!n.test(t))return!1;return!0}toJson(t){return{op:"and",path:W(t?this.path.slice(t.path.length):this.path),apply:this.ops.map(s=>s.toJson(this))}}toCompact(t,n){return[n?"and":43,t?this.path.slice(t.path.length):this.path,this.ops.map(r=>r.toCompact(this,n))]}encode(t,n){const s=n?this.path.slice(n.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 Kc extends As{constructor(t,n){super(t,n);x(this,"ops");this.ops=n}op(){return"or"}code(){return 45}test(t){for(const n of this.ops)if(n.test(t))return!0;return!1}toJson(t){return{op:"or",path:W(t?this.path.slice(t.path.length):this.path),apply:this.ops.map(s=>s.toJson(this))}}toCompact(t,n){return[n?"or":45,t?this.path.slice(t.path.length):this.path,this.ops.map(r=>r.toCompact(this,n))]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(45),t.encodeArray(n?this.path.slice(n.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 Yc extends As{constructor(t,n){super(t,n);x(this,"ops");this.ops=n}op(){return"not"}code(){return 44}test(t){for(const n of this.ops)if(n.test(t))return!1;return!0}toJson(t){return{op:"not",path:W(t?this.path.slice(t.path.length):this.path),apply:this.ops.map(s=>s.toJson(this))}}toCompact(t,n){return[n?"not":44,t?this.path.slice(t.path.length):this.path,this.ops.map(r=>r.toCompact(this,n))]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(44),t.encodeArray(n?this.path.slice(n.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 Xc extends Ce{constructor(t,n,s,r){super(t);x(this,"value");x(this,"ignore_case");x(this,"matcher");this.value=n,this.ignore_case=s,this.matcher=r(n,s)}op(){return"matches"}code(){return 35}test(t){const{val:n}=te(t,this.path);return typeof n!="string"?!1:this.matcher(n)}toJson(t){const n={op:"matches",path:W(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(n.ignore_case=this.ignore_case),n}toCompact(t,n){const s=n?"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,n){const s=this.ignore_case;t.encodeArrayHeader(s?4:3),t.writer.u8(35),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeString(this.value),s&&t.writer.u8(1)}}const{isArray:Qc}=Array;class Zc extends Ce{constructor(t,n){super(t);x(this,"value");this.value=n}op(){return"type"}code(){return 42}test(t){const{val:n}=te(t,this.path);return n===null?this.value==="null":Qc(n)?this.value==="array":typeof n===this.value||typeof n=="number"&&n===Math.round(n)&&this.value==="integer"}toJson(t){return{op:"type",path:W(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,n){return[n?"type":42,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(42),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeString(this.value)}}const eu=(i,e)=>{switch(i.op){case"add":return new Is($(i.path),i.value);case"remove":return new Xr($(i.path),i.oldValue);case"replace":return new Sc($(i.path),i.value,i.oldValue);case"move":return new Cc($(i.path),$(i.from));case"copy":return new wc($(i.path),$(i.from));case"flip":return new Pc($(i.path));case"inc":return new Rc($(i.path),i.inc);case"str_ins":return new _c($(i.path),i.pos,i.str);case"str_del":return new Ic($(i.path),i.pos,i.str,i.len);case"split":return new Lc($(i.path),i.pos,i.props||null);case"merge":return new Nc($(i.path),i.pos,i.props||null);case"extend":return new Dc($(i.path),i.props,!!i.deleteNull);default:return mn(i,e)}},mn=(i,e)=>{switch(i.op){case"test":return new Ec($(i.path),i.value,!!i.not);case"defined":return new Mc($(i.path));case"undefined":return new Uc($(i.path));case"type":return new Zc($(i.path),i.value);case"test_type":return new Bc($(i.path),i.type);case"test_string":return new Jc($(i.path),i.pos,i.str,!!i.not);case"test_string_len":return new jc($(i.path),i.len,!!i.not);case"contains":return new Vc($(i.path),i.value,!!i.ignore_case);case"ends":return new $c($(i.path),i.value,!!i.ignore_case);case"starts":return new qc($(i.path),i.value,!!i.ignore_case);case"matches":return new Xc($(i.path),i.value,!!i.ignore_case,e.createMatcher||Oc);case"in":return new Hc($(i.path),i.value);case"less":return new zc($(i.path),i.value);case"more":return new Wc($(i.path),i.value);case"and":{const t=$(i.path);return new Gc(t,i.apply.map(n=>mn({...n,path:[...t,...$(n.path)]},e)))}case"or":{const t=$(i.path);return new Kc(t,i.apply.map(n=>mn({...n,path:[...t,...$(n.path)]},e)))}case"not":{const t=$(i.path);return new Yc(t,i.apply.map(n=>mn({...n,path:[...t,...$(n.path)]},e)))}default:throw new Error("OP_UNKNOWN")}};function tu(i,e,t){t.mutate||(i=Ki(i));const n=[],s=e.length;for(let r=0;r<s;r++){const o=eu(e[r],t).apply(i);i=o.doc,n.push(o)}return{doc:i,res:n}}var Bi=i=>typeof i=="function"?i:function(){return i},iu=typeof self<"u"?self:null,Di=typeof window<"u"?window:null,Ji=iu||Di||Ji,nu="2.0.0",Qe={connecting:0,open:1,closing:2,closed:3},su=1e4,ru=1e3,Le={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},bt={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},os={longpoll:"longpoll",websocket:"websocket"},au={complete:4},un=class{constructor(i,e,t,n){this.channel=i,this.event=e,this.payload=t||function(){return{}},this.receivedResp=null,this.timeout=n,this.timeoutTimer=null,this.recHooks=[],this.sent=!1}resend(i){this.timeout=i,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(i,e){return this.hasReceived(i)&&e(this.receivedResp.response),this.recHooks.push({status:i,callback:e}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}matchReceive({status:i,response:e,_ref:t}){this.recHooks.filter(n=>n.status===i).forEach(n=>n.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,i=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=i,this.matchReceive(i)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(i){return this.receivedResp&&this.receivedResp.status===i}trigger(i,e){this.channel.trigger(this.refEvent,{status:i,response:e})}},Qr=class{constructor(i,e){this.callback=i,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))}},ou=class{constructor(i,e,t){this.state=Le.closed,this.topic=i,this.params=Bi(e||{}),this.socket=t,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new un(this,bt.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new Qr(()=>{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=Le.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(n=>n.send()),this.pushBuffer=[]}),this.joinPush.receive("error",()=>{this.state=Le.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=Le.closed,this.socket.remove(this)}),this.onError(n=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,n),this.isJoining()&&this.joinPush.reset(),this.state=Le.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 un(this,bt.leave,Bi({}),this.timeout).send(),this.state=Le.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(bt.reply,(n,s)=>{this.trigger(this.replyEventName(s),n)})}join(i=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=i,this.joinedOnce=!0,this.rejoin(),this.joinPush}onClose(i){this.on(bt.close,i)}onError(i){return this.on(bt.error,e=>i(e))}on(i,e){let t=this.bindingRef++;return this.bindings.push({event:i,ref:t,callback:e}),t}off(i,e){this.bindings=this.bindings.filter(t=>!(t.event===i&&(typeof e>"u"||e===t.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(i,e,t=this.timeout){if(e=e||{},!this.joinedOnce)throw new Error(`tried to push '${i}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let n=new un(this,i,function(){return e},t);return this.canPush()?n.send():(n.startTimeout(),this.pushBuffer.push(n)),n}leave(i=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=Le.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(bt.close,"leave")},t=new un(this,bt.leave,Bi({}),i);return t.receive("ok",()=>e()).receive("timeout",()=>e()),t.send(),this.canPush()||t.trigger("ok",{}),t}onMessage(i,e,t){return e}isMember(i,e,t,n){return this.topic!==i?!1:n&&n!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:i,event:e,payload:t,joinRef:n}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(i=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=Le.joining,this.joinPush.resend(i))}trigger(i,e,t,n){let s=this.onMessage(i,e,t,n);if(e&&!s)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let r=this.bindings.filter(a=>a.event===i);for(let a=0;a<r.length;a++)r[a].callback(s,t,n||this.joinRef())}replyEventName(i){return`chan_reply_${i}`}isClosed(){return this.state===Le.closed}isErrored(){return this.state===Le.errored}isJoined(){return this.state===Le.joined}isJoining(){return this.state===Le.joining}isLeaving(){return this.state===Le.leaving}},Rn=class{static request(i,e,t,n,s,r,a){if(Ji.XDomainRequest){let o=new Ji.XDomainRequest;return this.xdomainRequest(o,i,e,n,s,r,a)}else{let o=new Ji.XMLHttpRequest;return this.xhrRequest(o,i,e,t,n,s,r,a)}}static xdomainRequest(i,e,t,n,s,r,a){return i.timeout=s,i.open(e,t),i.onload=()=>{let o=this.parseJSON(i.responseText);a&&a(o)},r&&(i.ontimeout=r),i.onprogress=()=>{},i.send(n),i}static xhrRequest(i,e,t,n,s,r,a,o){return i.open(e,t,!0),i.timeout=r,i.setRequestHeader("Content-Type",n),i.onerror=()=>o&&o(null),i.onreadystatechange=()=>{if(i.readyState===au.complete&&o){let c=this.parseJSON(i.responseText);o(c)}},a&&(i.ontimeout=a),i.send(s),i}static parseJSON(i){if(!i||i==="")return null;try{return JSON.parse(i)}catch{return console&&console.log("failed to parse JSON response",i),null}}static serialize(i,e){let t=[];for(var n in i){if(!Object.prototype.hasOwnProperty.call(i,n))continue;let s=e?`${e}[${n}]`:n,r=i[n];typeof r=="object"?t.push(this.serialize(r,s)):t.push(encodeURIComponent(s)+"="+encodeURIComponent(r))}return t.join("&")}static appendParams(i,e){if(Object.keys(e).length===0)return i;let t=i.match(/\?/)?"&":"?";return`${i}${t}${this.serialize(e)}`}},qn=class{constructor(i){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(i),this.readyState=Qe.connecting,this.poll()}normalizeEndpoint(i){return i.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+os.websocket),"$1/"+os.longpoll)}endpointURL(){return Rn.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(i,e,t){this.close(i,e,t),this.readyState=Qe.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===Qe.open||this.readyState===Qe.connecting}poll(){this.ajax("GET",null,()=>this.ontimeout(),i=>{if(i){var{status:e,token:t,messages:n}=i;this.token=t}else e=0;switch(e){case 200:n.forEach(s=>{setTimeout(()=>this.onmessage({data:s}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=Qe.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(i){this.ajax("POST",i,()=>this.onerror("timeout"),e=>{(!e||e.status!==200)&&(this.onerror(e&&e.status),this.closeAndRetry(1011,"internal server error",!1))})}close(i,e,t){for(let s of this.reqs)s.abort();this.readyState=Qe.closed;let n=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:i,reason:e,wasClean:t});typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",n)):this.onclose(n)}ajax(i,e,t,n){let s,r=()=>{this.reqs.delete(s),t()};s=Rn.request(i,this.endpointURL(),"application/json",e,this.timeout,r,a=>{this.reqs.delete(s),this.isActive()&&n(a)}),this.reqs.add(s)}},dn={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(i,e){if(i.payload.constructor===ArrayBuffer)return e(this.binaryEncode(i));{let t=[i.join_ref,i.ref,i.topic,i.event,i.payload];return e(JSON.stringify(t))}},decode(i,e){if(i.constructor===ArrayBuffer)return e(this.binaryDecode(i));{let[t,n,s,r,a]=JSON.parse(i);return e({join_ref:t,ref:n,topic:s,event:r,payload:a})}},binaryEncode(i){let{join_ref:e,ref:t,event:n,topic:s,payload:r}=i,a=this.META_LENGTH+e.length+t.length+s.length+n.length,o=new ArrayBuffer(this.HEADER_LENGTH+a),c=new DataView(o),u=0;c.setUint8(u++,this.KINDS.push),c.setUint8(u++,e.length),c.setUint8(u++,t.length),c.setUint8(u++,s.length),c.setUint8(u++,n.length),Array.from(e,h=>c.setUint8(u++,h.charCodeAt(0))),Array.from(t,h=>c.setUint8(u++,h.charCodeAt(0))),Array.from(s,h=>c.setUint8(u++,h.charCodeAt(0))),Array.from(n,h=>c.setUint8(u++,h.charCodeAt(0)));var d=new Uint8Array(o.byteLength+r.byteLength);return d.set(new Uint8Array(o),0),d.set(new Uint8Array(r),o.byteLength),d.buffer},binaryDecode(i){let e=new DataView(i),t=e.getUint8(0),n=new TextDecoder;switch(t){case this.KINDS.push:return this.decodePush(i,e,n);case this.KINDS.reply:return this.decodeReply(i,e,n);case this.KINDS.broadcast:return this.decodeBroadcast(i,e,n)}},decodePush(i,e,t){let n=e.getUint8(1),s=e.getUint8(2),r=e.getUint8(3),a=this.HEADER_LENGTH+this.META_LENGTH-1,o=t.decode(i.slice(a,a+n));a=a+n;let c=t.decode(i.slice(a,a+s));a=a+s;let u=t.decode(i.slice(a,a+r));a=a+r;let d=i.slice(a,i.byteLength);return{join_ref:o,ref:null,topic:c,event:u,payload:d}},decodeReply(i,e,t){let n=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(i.slice(o,o+n));o=o+n;let u=t.decode(i.slice(o,o+s));o=o+s;let d=t.decode(i.slice(o,o+r));o=o+r;let h=t.decode(i.slice(o,o+a));o=o+a;let f=i.slice(o,i.byteLength),p={status:h,response:f};return{join_ref:c,ref:u,topic:d,event:bt.reply,payload:p}},decodeBroadcast(i,e,t){let n=e.getUint8(1),s=e.getUint8(2),r=this.HEADER_LENGTH+2,a=t.decode(i.slice(r,r+n));r=r+n;let o=t.decode(i.slice(r,r+s));r=r+s;let c=i.slice(r,i.byteLength);return{join_ref:null,ref:null,topic:a,event:o,payload:c}}},cu=class{constructor(i,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=e.timeout||su,this.transport=e.transport||Ji.WebSocket||qn,this.establishedConnections=0,this.defaultEncoder=dn.encode.bind(dn),this.defaultDecoder=dn.decode.bind(dn),this.closeWasClean=!1,this.binaryType=e.binaryType||"arraybuffer",this.connectClock=1,this.transport!==qn?(this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let t=null;Di&&Di.addEventListener&&(Di.addEventListener("pagehide",n=>{this.conn&&(this.disconnect(),t=this.connectClock)}),Di.addEventListener("pageshow",n=>{t===this.connectClock&&(t=null,this.connect())})),this.heartbeatIntervalMs=e.heartbeatIntervalMs||3e4,this.rejoinAfterMs=n=>e.rejoinAfterMs?e.rejoinAfterMs(n):[1e3,2e3,5e3][n-1]||1e4,this.reconnectAfterMs=n=>e.reconnectAfterMs?e.reconnectAfterMs(n):[10,50,100,150,200,250,500,1e3,2e3][n-1]||5e3,this.logger=e.logger||null,this.longpollerTimeout=e.longpollerTimeout||2e4,this.params=Bi(e.params||{}),this.endPoint=`${i}/${os.websocket}`,this.vsn=e.vsn||nu,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new Qr(()=>{this.teardown(()=>this.connect())},this.reconnectAfterMs)}getLongPollTransport(){return qn}replaceTransport(i){this.connectClock++,this.closeWasClean=!0,this.reconnectTimer.reset(),this.sendBuffer=[],this.conn&&(this.conn.close(),this.conn=null),this.transport=i}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let i=Rn.appendParams(Rn.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return i.charAt(0)!=="/"?i:i.charAt(1)==="/"?`${this.protocol()}:${i}`:`${this.protocol()}://${location.host}${i}`}disconnect(i,e,t){this.connectClock++,this.closeWasClean=!0,this.reconnectTimer.reset(),this.teardown(i,e,t)}connect(i){i&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=Bi(i)),!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(i,e,t){this.logger(i,e,t)}hasLogger(){return this.logger!==null}onOpen(i){let e=this.makeRef();return this.stateChangeCallbacks.open.push([e,i]),e}onClose(i){let e=this.makeRef();return this.stateChangeCallbacks.close.push([e,i]),e}onError(i){let e=this.makeRef();return this.stateChangeCallbacks.error.push([e,i]),e}onMessage(i){let e=this.makeRef();return this.stateChangeCallbacks.message.push([e,i]),e}ping(i){if(!this.isConnected())return!1;let e=this.makeRef(),t=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:e});let n=this.onMessage(s=>{s.ref===e&&(this.off([n]),i(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(([,i])=>i())}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(),ru,"heartbeat timeout"))}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(i,e,t){if(!this.conn)return i&&i();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),i&&i()})})}waitForBufferDone(i,e=1){if(e===5||!this.conn||!this.conn.bufferedAmount){i();return}setTimeout(()=>{this.waitForBufferDone(i,e+1)},150*e)}waitForSocketClosed(i,e=1){if(e===5||!this.conn||this.conn.readyState===Qe.closed){i();return}setTimeout(()=>{this.waitForSocketClosed(i,e+1)},150*e)}onConnClose(i){let e=i&&i.code;this.hasLogger()&&this.log("transport","close",i),this.triggerChanError(),this.clearHeartbeats(),!this.closeWasClean&&e!==1e3&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,t])=>t(i))}onConnError(i){this.hasLogger()&&this.log("transport",i);let e=this.transport,t=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,n])=>{n(i,e,t)}),(e===this.transport||t>0)&&this.triggerChanError()}triggerChanError(){this.channels.forEach(i=>{i.isErrored()||i.isLeaving()||i.isClosed()||i.trigger(bt.error)})}connectionState(){switch(this.conn&&this.conn.readyState){case Qe.connecting:return"connecting";case Qe.open:return"open";case Qe.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(i){this.off(i.stateChangeRefs),this.channels=this.channels.filter(e=>e.joinRef()!==i.joinRef())}off(i){for(let e in this.stateChangeCallbacks)this.stateChangeCallbacks[e]=this.stateChangeCallbacks[e].filter(([t])=>i.indexOf(t)===-1)}channel(i,e={}){let t=new ou(i,e,this);return this.channels.push(t),t}push(i){if(this.hasLogger()){let{topic:e,event:t,payload:n,ref:s,join_ref:r}=i;this.log("push",`${e} ${t} (${r}, ${s})`,n)}this.isConnected()?this.encode(i,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(i,e=>this.conn.send(e)))}makeRef(){let i=this.ref+1;return i===this.ref?this.ref=0:this.ref=i,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(i=>i()),this.sendBuffer=[])}onConnMessage(i){this.decode(i.data,e=>{let{topic:t,event:n,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} ${n} ${r&&"("+r+")"||""}`,s);for(let o=0;o<this.channels.length;o++){const c=this.channels[o];c.isMember(t,n,s,a)&&c.trigger(n,s,r,a)}for(let o=0;o<this.stateChangeCallbacks.message.length;o++){let[,c]=this.stateChangeCallbacks.message[o];c(e)}})}leaveOpenTopic(i){let e=this.channels.find(t=>t.topic===i&&(t.isJoined()||t.isJoining()));e&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${i}"`),e.leave())}};class uu{constructor(e){this.connected=!1,this.config=e,this.socket=new cu(this.config.url,this.config.socketOptions||{logger:(t,n,s)=>{console.debug(`${t}: ${n}`,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.connected=!0)}disconnect(){this.channel&&this.channel.leave(),this.socket.disconnect(),this.connected=!1}addEventListener(e,t,n){var s;this.eventTarget.addEventListener(e,t,n),e.startsWith("livestate-")||(s=this.channel)==null||s.on(e,r=>{this.eventTarget.dispatchEvent(new CustomEvent(e,{detail:r}))})}removeEventListener(e,t,n){return this.eventTarget.removeEventListener(e,t,n)}subscribe(e){this.addEventListener("livestate-change",e)}unsubscribe(e){this.removeEventListener("livestate-change",e)}emitError(e,t){this.eventTarget.dispatchEvent(new CustomEvent("livestate-error",{detail:{kind:e,error:t}}))}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:n,res:s}=tu(this.state,e,{mutate:!1});this.state=n,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)}}Promise.resolve();var Gs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/*! *****************************************************************************
|
|
1
|
+
"use strict";var Fo=Object.defineProperty;var Bo=(i,e,t)=>e in i?Fo(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var x=(i,e,t)=>(Bo(i,typeof e!="symbol"?e+"":e,t),t);const $s=require("./constants-f9ac3da1.cjs");function Wi(){}function qr(i){return i()}function qs(){return Object.create(null)}function tn(i){i.forEach(qr)}function Hr(i){return typeof i=="function"}function Jo(i,e){return i!=i?e==e:i!==e||i&&typeof i=="object"||typeof i=="function"}function jo(i){return Object.keys(i).length===0}function Ne(i,e){i.appendChild(e)}function Vo(i,e,t){const n=$o(i);if(!n.getElementById(e)){const s=Xe("style");s.id=e,s.textContent=t,qo(n,s)}}function $o(i){if(!i)return document;const e=i.getRootNode?i.getRootNode():i.ownerDocument;return e&&e.host?e:i.ownerDocument}function qo(i,e){return Ne(i.head||i,e),e.sheet}function Nn(i,e,t){i.insertBefore(e,t||null)}function nn(i){i.parentNode&&i.parentNode.removeChild(i)}function Xe(i){return document.createElement(i)}function Hs(i){return document.createElementNS("http://www.w3.org/2000/svg",i)}function zr(i){return document.createTextNode(i)}function cn(){return zr(" ")}function G(i,e,t){t==null?i.removeAttribute(e):i.getAttribute(e)!==t&&i.setAttribute(e,t)}function Ho(i){return Array.from(i.childNodes)}function zo(i,e){e=""+e,i.data!==e&&(i.data=e)}function Ye(i,e,t,n){t==null?i.style.removeProperty(e):i.style.setProperty(e,t,n?"important":"")}function Wo(i){const e={};return i.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}let Gi;function Fi(i){Gi=i}function Wr(){if(!Gi)throw new Error("Function called outside component initialization");return Gi}function Go(i){Wr().$$.on_mount.push(i)}function Ko(i){Wr().$$.on_destroy.push(i)}const mi=[],is=[];let yi=[];const zs=[],Yo=Promise.resolve();let ns=!1;function Xo(){ns||(ns=!0,Yo.then(ni))}function ss(i){yi.push(i)}const $n=new Set;let fi=0;function ni(){if(fi!==0)return;const i=Gi;do{try{for(;fi<mi.length;){const e=mi[fi];fi++,Fi(e),Qo(e.$$)}}catch(e){throw mi.length=0,fi=0,e}for(Fi(null),mi.length=0,fi=0;is.length;)is.pop()();for(let e=0;e<yi.length;e+=1){const t=yi[e];$n.has(t)||($n.add(t),t())}yi.length=0}while(mi.length);for(;zs.length;)zs.pop()();ns=!1,$n.clear(),Fi(i)}function Qo(i){if(i.fragment!==null){i.update(),tn(i.before_update);const e=i.dirty;i.dirty=[-1],i.fragment&&i.fragment.p(i.ctx,e),i.after_update.forEach(ss)}}function Zo(i){const e=[],t=[];yi.forEach(n=>i.indexOf(n)===-1?e.push(n):t.push(n)),t.forEach(n=>n()),yi=e}const ec=new Set;function Gr(i,e){i&&i.i&&(ec.delete(i),i.i(e))}function Ws(i){return(i==null?void 0:i.length)!==void 0?i:Array.from(i)}function tc(i,e){i.d(1),e.delete(i.key)}function ic(i,e,t,n,s,r,a,o,c,u,d,h){let f=i.length,p=r.length,b=f;const T={};for(;b--;)T[i[b].key]=b;const w=[],_=new Map,M=new Map,Q=[];for(b=p;b--;){const q=h(s,r,b),K=t(q);let I=a.get(K);I?n&&Q.push(()=>I.p(q,e)):(I=u(K,q),I.c()),_.set(K,w[b]=I),K in T&&M.set(K,Math.abs(b-T[K]))}const j=new Set,he=new Set;function ae(q){Gr(q,1),q.m(o,d),a.set(q.key,q),d=q.first,p--}for(;f&&p;){const q=w[p-1],K=i[f-1],I=q.key,F=K.key;q===K?(d=q.first,f--,p--):_.has(F)?!a.has(I)||j.has(I)?ae(q):he.has(F)?f--:M.get(I)>M.get(F)?(he.add(I),ae(q)):(j.add(F),f--):(c(K,a),f--)}for(;f--;){const q=i[f];_.has(q.key)||c(q,a)}for(;p;)ae(w[p-1]);return tn(Q),w}function nc(i,e,t){const{fragment:n,after_update:s}=i.$$;n&&n.m(e,t),ss(()=>{const r=i.$$.on_mount.map(qr).filter(Hr);i.$$.on_destroy?i.$$.on_destroy.push(...r):tn(r),i.$$.on_mount=[]}),s.forEach(ss)}function sc(i,e){const t=i.$$;t.fragment!==null&&(Zo(t.after_update),tn(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function rc(i,e){i.$$.dirty[0]===-1&&(mi.push(i),Xo(),i.$$.dirty.fill(0)),i.$$.dirty[e/31|0]|=1<<e%31}function ac(i,e,t,n,s,r,a=null,o=[-1]){const c=Gi;Fi(i);const u=i.$$={fragment:null,ctx:[],props:r,update:Wi,not_equal:s,bound:qs(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(c?c.$$.context:[])),callbacks:qs(),dirty:o,skip_bound:!1,root:e.target||c.$$.root};a&&a(u.root);let d=!1;if(u.ctx=t?t(i,e.props||{},(h,f,...p)=>{const b=p.length?p[0]:f;return u.ctx&&s(u.ctx[h],u.ctx[h]=b)&&(!u.skip_bound&&u.bound[h]&&u.bound[h](b),d&&rc(i,h)),f}):[],u.update(),d=!0,tn(u.before_update),u.fragment=n?n(u.ctx):!1,e.target){if(e.hydrate){const h=Ho(e.target);u.fragment&&u.fragment.l(h),h.forEach(nn)}else u.fragment&&u.fragment.c();e.intro&&Gr(i.$$.fragment),nc(i,e.target,e.anchor),ni()}Fi(c)}let Kr;typeof HTMLElement=="function"&&(Kr=class extends HTMLElement{constructor(e,t,n){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,n&&this.attachShadow({mode:"open"})}addEventListener(e,t,n){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,n)}removeEventListener(e,t,n){if(super.removeEventListener(e,t,n),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=Xe("slot"),r!=="default"&&G(a,"name",r)},m:function(u,d){Nn(u,a,d)},d:function(u){u&&nn(a)}}}};if(await Promise.resolve(),!this.$$cn)return;const t={},n=Wo(this);for(const r of this.$$s)r in n&&(t[r]=[e(r)]);for(const r of this.attributes){const a=this.$$g_p(r.name);a in this.$$d||(this.$$d[a]=pn(a,r.value,this.$$p_d,"toProp"))}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=pn(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,n){var s;this.$$r||(e=this.$$g_p(e),this.$$d[e]=pn(e,n,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 pn(i,e,t,n){var r;const s=(r=t[i])==null?void 0:r.type;if(e=s==="Boolean"&&typeof e!="boolean"?e!=null:e,!n||!t[i])return e;if(n==="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 oc(i,e,t,n,s,r){let a=class extends Kr{constructor(){super(i,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 u;c=pn(o,c,e),this.$$d[o]=c,(u=this.$$c)==null||u.$set({[o]:c})}})}),n.forEach(o=>{Object.defineProperty(a.prototype,o,{get(){var c;return(c=this.$$c)==null?void 0:c[o]}})}),r&&(a=r(a)),i.element=a,a}class cc{constructor(){x(this,"$$");x(this,"$$set")}$destroy(){sc(this,1),this.$destroy=Wi}$on(e,t){if(!Hr(t))return Wi;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const s=n.indexOf(t);s!==-1&&n.splice(s,1)}}$set(e){this.$$set&&!jo(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const uc="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(uc);const{isArray:dc}=Array,lc=Object.keys,Ki=i=>{if(!i)return i;if(dc(i)){const e=[],t=i.length;for(let n=0;n<t;n++)e.push(Ki(i[n]));return e}else if(typeof i=="object"){const e=lc(i),t=e.length,n={};for(let s=0;s<t;s++){const r=e[s];n[r]=Ki(i[r])}return n}return i};class Ue{constructor(e){x(this,"path");x(this,"from");this.path=e}}const hc=/~1/g,fc=/~0/g,pc=/~/g,mc=/\//g;function gc(i){return i.indexOf("~")===-1?i:i.replace(hc,"/").replace(fc,"~")}function vc(i){return i.indexOf("/")===-1&&i.indexOf("~")===-1?i:i.replace(pc,"~0").replace(mc,"~1")}function yc(i){return i?i.slice(1).split("/").map(gc):[]}function W(i){return bc(i)?"":"/"+i.map(e=>vc(String(e))).join("/")}const $=i=>typeof i=="string"?yc(i):i,bc=i=>!i.length,kc=Object.prototype.hasOwnProperty;function Tc(i,e){return kc.call(i,e)}const{isArray:Yr}=Array,te=(i,e)=>{const t=e.length;if(!t)return{val:i};let n,s;for(let a=0;a<t;a++)if(n=i,s=e[a],Yr(n)){const o=n.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")}i=n[s]}else if(typeof n=="object"&&n)i=Tc(n,s)?n[s]:void 0;else throw new Error("NOT_FOUND");return{val:i,obj:n,key:s}},sn=i=>Yr(i.obj)&&typeof i.key=="number",xn=i=>typeof i.obj=="object"&&typeof i.key=="string";class Is extends Ue{constructor(t,n){super(t);x(this,"value");this.value=n}op(){return"add"}code(){return 0}apply(t){const{val:n,key:s,obj:r}=te(t,this.path),a=Ki(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:n}}toJson(t){return{op:"add",path:W(this.path),value:this.value}}toCompact(t,n){return[n?"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 Ue{constructor(t,n){super(t);x(this,"oldValue");this.oldValue=n}op(){return"remove"}code(){return 1}apply(t){const n=te(t,this.path);if(n.val===void 0)throw new Error("NOT_FOUND");return xn(n)?delete n.obj[n.key]:sn(n)?n.val!==void 0&&n.obj.splice(n.key,1):t=null,{doc:t,old:n.val}}toJson(t){const n={op:"remove",path:W(this.path)};return this.oldValue!==void 0&&(n.oldValue=this.oldValue),n}toCompact(t,n){const s=n?"remove":1;return this.oldValue===void 0?[s,this.path]:[s,this.path,this.oldValue]}encode(t,n){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 Sc extends Ue{constructor(t,n,s){super(t);x(this,"value");x(this,"oldValue");this.value=n,this.oldValue=s}op(){return"replace"}code(){return 2}apply(t){const n=te(t,this.path);if(n.val===void 0)throw new Error("NOT_FOUND");return xn(n)?n.obj[n.key]=this.value:sn(n)?n.obj[n.key]=this.value:t=this.value,{doc:t,old:n.val}}toJson(t){const n={op:"replace",path:W(this.path),value:this.value};return this.oldValue!==void 0&&(n.oldValue=this.oldValue),n}toCompact(t,n){const s=n?"replace":2;return this.oldValue===void 0?[s,this.path,this.value]:[s,this.path,this.value,this.oldValue]}encode(t,n){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 Cc extends Ue{constructor(t,n){super(t);x(this,"from");this.from=n}op(){return"move"}code(){return 4}apply(t){const n=new Xr($(this.from),void 0).apply(t);return new Is(this.path,n.old).apply(n.doc)}toJson(t){return{op:"move",path:W(this.path),from:W(this.from)}}toCompact(t,n){return[n?"move":4,this.path,this.from]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(4),t.encodeArray(this.path),t.encodeArray(this.from)}}class wc extends Ue{constructor(t,n){super(t);x(this,"from");this.from=n}op(){return"copy"}code(){return 3}apply(t){const{val:n}=te(t,this.from);if(n===void 0)throw new Error("NOT_FOUND");return new Is(this.path,Ki(n)).apply(t)}toJson(t){return{op:"copy",path:W(this.path),from:W(this.from)}}toCompact(t,n){return[n?"copy":3,this.path,this.from]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(3),t.encodeArray(this.path),t.encodeArray(this.from)}}class Ce extends Ue{apply(e){if(!this.test(e))throw new Error("TEST");return{doc:e}}}const Pn=(i,e)=>{if(i===e)return!0;if(i&&e&&typeof i=="object"&&typeof e=="object"){if(i.constructor!==e.constructor)return!1;let t,n,s;if(Array.isArray(i)){if(t=i.length,t!==e.length)return!1;for(n=t;n--!==0;)if(!Pn(i[n],e[n]))return!1;return!0}if(s=Object.keys(i),t=s.length,t!==Object.keys(e).length)return!1;for(n=t;n--!==0;){const r=s[n];if(!Pn(i[r],e[r]))return!1}return!0}return!1};class Ec extends Ce{constructor(t,n,s){super(t);x(this,"value");x(this,"not");this.value=n,this.not=s}op(){return"test"}code(){return 5}test(t){const{val:n}=te(t,this.path);if(n===void 0)return!!this.not;const s=Pn(n,this.value);return this.not?!s:s}toJson(t){const n={op:"test",path:W(t?this.path.slice(t.path.length):this.path),value:this.value};return this.not&&(n.not=this.not),n}toCompact(t,n){const s=t?this.path.slice(t.path.length):this.path,r=n?"test":5;return this.not?[r,s,this.value,1]:[r,s,this.value]}encode(t,n){t.encodeArrayHeader(this.not?4:3),t.writer.u8(5),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeAny(this.value),this.not&&t.writer.u8(1)}}class Pc extends Ue{constructor(e){super(e)}op(){return"flip"}code(){return 8}apply(e){const t=te(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:W(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 Rc extends Ue{constructor(t,n){super(t);x(this,"inc");this.inc=n}op(){return"inc"}code(){return 9}apply(t){const n=te(t,this.path),s=this.inc+Number(n.val);return n.obj?n.obj[n.key]=s:t=s,{doc:t,old:n.val}}toJson(t){return{op:"inc",path:W(this.path),inc:this.inc}}toCompact(t,n){return[n?"inc":9,this.path,this.inc]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(9),t.encodeArray(this.path),t.encodeNumber(this.inc)}}class _c extends Ue{constructor(t,n,s){super(t);x(this,"pos");x(this,"str");this.pos=n,this.str=s}op(){return"str_ins"}code(){return 6}apply(t){const{val:n,key:s,obj:r}=te(t,this.path);if(typeof n!="string"){if(n!==void 0)throw new Error("NOT_A_STRING");if(this.pos!==0)throw new Error("POS")}const a=typeof n=="string"?n:"",o=Math.min(this.pos,a.length),c=a.slice(0,o),u=a.slice(o),d=c+this.str+u;return r?r[s]=d:t=d,{doc:t,old:n}}toJson(t){return{op:"str_ins",path:W(this.path),pos:this.pos,str:this.str}}toCompact(t,n){return[n?"str_ins":6,this.path,this.pos,this.str]}encode(t,n){t.encodeArrayHeader(4),t.writer.u8(6),t.encodeArray(this.path),t.encodeNumber(this.pos),t.encodeString(this.str)}}class Ic extends Ue{constructor(t,n,s,r){super(t);x(this,"pos");x(this,"str");x(this,"len");this.pos=n,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:n,key:s,obj:r}=te(t,this.path);if(typeof n!="string")throw new Error("NOT_A_STRING");const a=n.length,o=Math.min(this.pos,n.length),c=Math.min(o,a),u=this.str!==void 0?this.str.length:this.len,d=Math.min(o+u,a),h=n.slice(0,c),f=n.substr(d),p=h+f;return r?r[s]=p:t=p,{doc:t,old:n}}toJson(t){return typeof this.str=="string"?{op:"str_del",path:W(this.path),pos:this.pos,str:this.str}:{op:"str_del",path:W(this.path),pos:this.pos,len:this.len}}toCompact(t,n){const s=n?"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,n){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:Ac}=Array,rs=i=>!!i&&typeof i=="object"&&typeof i.text=="string",as=i=>!!i&&typeof i=="object"&&Ac(i.children),Oc=(i,e)=>{const t=new RegExp(i,e?"i":void 0);return n=>t.test(n)};class Lc extends Ue{constructor(t,n,s){super(t);x(this,"pos");x(this,"props");this.pos=n,this.props=s}op(){return"split"}code(){return 10}apply(t){const n=te(t,this.path);if(n.val===void 0)throw new Error("NOT_FOUND");const s=this.split(n.val);return xn(n)?n.obj[n.key]=s:sn(n)?(n.obj[n.key]=s[0],n.obj.splice(n.key+1,0,s[1])):t=s,{doc:t,old:n.val}}split(t){if(typeof t=="string"){const{pos:n,props:s}=this,r=t.slice(0,n),a=t.slice(n);return s?[{...s,text:r},{...s,text:a}]:[r,a]}else if(rs(t)){const{pos:n,props:s}=this,r=t.text.slice(0,n),a=t.text.slice(n);return[{...t,...s,text:r},{...t,...s,text:a}]}else if(as(t)){const{pos:n,props:s}=this,r=t.children.slice(0,n),a=t.children.slice(n);return[{...t,...s,children:r},{...t,...s,children:a}]}else if(typeof t=="number"){const{pos:n}=this;return[n,t-n]}else return[t,t]}toJson(t){const n={op:"split",path:W(this.path),pos:this.pos};return this.props&&(n.props=this.props),n}toCompact(t,n){const s=n?"split":10;return this.props?[s,this.path,this.pos,this.props]:[s,this.path,this.pos]}encode(t,n){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 Nc extends Ue{constructor(t,n,s){super(t);x(this,"pos");x(this,"props");this.pos=n,this.props=s}op(){return"merge"}code(){return 11}apply(t){const n=te(t,this.path);if(!sn(n))throw new Error("INVALID_TARGET");if(n.key<=0)throw new Error("INVALID_KEY");const s=n.obj[n.key-1],r=n.obj[n.key],a=this.merge(s,r);return n.obj[n.key-1]=a,n.obj.splice(n.key,1),{doc:t,old:[s,r]}}merge(t,n){return typeof t=="string"&&typeof n=="string"||typeof t=="number"&&typeof n=="number"?t+n:rs(t)&&rs(n)?{...t,...n,text:t.text+n.text}:as(t)&&as(n)?{...t,...n,children:[...t.children,...n.children]}:[t,n]}toJson(t){const n={op:"merge",path:W(this.path),pos:this.pos};return this.props&&(n.props=this.props),n}toCompact(t,n){const s=n?"merge":11;return this.props?[s,this.path,this.pos,this.props]:[s,this.path,this.pos]}encode(t,n){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:xc}=Array;class Dc extends Ue{constructor(t,n,s){super(t);x(this,"props");x(this,"deleteNull");this.props=n,this.deleteNull=s}op(){return"extend"}code(){return 12}apply(t){const n=te(t,this.path);return sn(n)?n.val!==void 0&&(n.obj[n.key]=this.extend(n.val)):xn(n)?n.obj[n.key]=this.extend(n.val):t=this.extend(t),{doc:t}}extend(t){if(xc(t)||typeof t!="object"||!t)return t;for(const[n,s]of Object.entries(this.props)){if(n==="__proto__")throw new Error("NO_PROTO");if(s===null&&this.deleteNull){delete t[n];continue}t[n]=s}return t}toJson(t){const n={op:"extend",path:W(this.path),props:this.props};return this.deleteNull&&(n.deleteNull=this.deleteNull),n}toCompact(t,n){const s=n?"extend":12;return this.deleteNull?[s,this.path,this.props,1]:[s,this.path,this.props]}encode(t,n){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 Mc extends Ce{constructor(e){super(e)}op(){return"defined"}code(){return 31}test(e){const{val:t}=te(e,this.path);return t!==void 0}toJson(e){return{op:"defined",path:W(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 Uc extends Ce{constructor(e){super(e)}op(){return"undefined"}code(){return 38}test(e){try{const{val:t}=te(e,this.path);return t===void 0}catch(t){if(t.message==="NOT_FOUND")return!0;throw t}}toJson(e){return{op:"undefined",path:W(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:Fc}=Array;class Bc extends Ce{constructor(t,n){super(t);x(this,"type");this.type=n}op(){return"test_type"}code(){return 39}test(t){const{val:n}=te(t,this.path);return n===null?this.type.indexOf("null")>-1:Fc(n)?this.type.indexOf("array")>-1:this.type.indexOf(typeof n)>-1||typeof n=="number"&&n===Math.round(n)&&this.type.indexOf("integer")>-1}toJson(t){return{op:"test_type",path:W(t?this.path.slice(t.path.length):this.path),type:this.type}}toCompact(t,n){return[n?"test_type":39,t?this.path.slice(t.path.length):this.path,this.type]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(39),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeArray(this.type)}}class Jc extends Ce{constructor(t,n,s,r){super(t);x(this,"pos");x(this,"str");x(this,"not");this.pos=n,this.str=s,this.not=r}op(){return"test_string"}code(){return 40}test(t){const{val:n}=te(t,this.path);if(typeof n!="string")return!1;const s=n.length,r=Math.min(this.pos,s),a=Math.min(this.pos+this.str.length,s),o=n.substring(r,a)===this.str;return this.not?!o:o}toJson(t){const n={op:"test_string",path:W(t?this.path.slice(t.path.length):this.path),pos:this.pos,str:this.str};return this.not&&(n.not=this.not),n}toCompact(t,n){const s=n?"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,n){t.encodeArrayHeader(this.not?5:4),t.writer.u8(40),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeNumber(this.pos),t.encodeString(this.str),this.not&&t.writer.u8(1)}}class jc extends Ce{constructor(t,n,s){super(t);x(this,"len");x(this,"not");this.len=n,this.not=s}op(){return"test_string_len"}code(){return 41}test(t){const{val:n}=te(t,this.path);if(typeof n!="string")return!1;const r=n.length>=this.len;return this.not?!r:r}toJson(t){const n={op:"test_string_len",path:W(t?this.path.slice(t.path.length):this.path),len:this.len};return this.not&&(n.not=this.not),n}toCompact(t,n){const s=n?"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,n){t.encodeArrayHeader(this.not?4:3),t.writer.u8(41),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeNumber(this.len),this.not&&t.writer.u8(1)}}class Vc extends Ce{constructor(t,n,s){super(t);x(this,"value");x(this,"ignore_case");this.value=n,this.ignore_case=s}op(){return"contains"}code(){return 30}test(t){const{val:n}=te(t,this.path);if(typeof n!="string")return!1;const s=this.ignore_case?n.toLowerCase():n,r=this.ignore_case?this.value.toLowerCase():this.value;return s.indexOf(r)>-1}toJson(t){const n={op:"contains",path:W(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(n.ignore_case=this.ignore_case),n}toCompact(t,n){const s=n?"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,n){const s=this.ignore_case;t.encodeArrayHeader(s?4:3),t.writer.u8(30),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeString(this.value),s&&t.writer.u8(1)}}class $c extends Ce{constructor(t,n,s){super(t);x(this,"value");x(this,"ignore_case");this.value=n,this.ignore_case=s}op(){return"ends"}code(){return 32}test(t){const{val:n}=te(t,this.path);if(typeof n!="string")return!1;const s=this.ignore_case?n.toLowerCase():n,r=this.ignore_case?this.value.toLowerCase():this.value;return s.endsWith(r)}toJson(t){const n={op:"ends",path:W(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(n.ignore_case=this.ignore_case),n}toCompact(t,n){const s=n?"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,n){const s=this.ignore_case;t.encodeArrayHeader(s?4:3),t.writer.u8(32),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeString(this.value),s&&t.writer.u8(1)}}class qc extends Ce{constructor(t,n,s){super(t);x(this,"value");x(this,"ignore_case");this.value=n,this.ignore_case=s}op(){return"starts"}code(){return 37}test(t){const{val:n}=te(t,this.path);if(typeof n!="string")return!1;const s=this.ignore_case?n.toLowerCase():n,r=this.ignore_case?this.value.toLowerCase():this.value;return s.startsWith(r)}toJson(t){const n={op:"starts",path:W(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(n.ignore_case=this.ignore_case),n}toCompact(t,n){const s=n?"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,n){const s=this.ignore_case;t.encodeArrayHeader(s?4:3),t.writer.u8(37),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeString(this.value),s&&t.writer.u8(1)}}class Hc extends Ce{constructor(t,n){super(t);x(this,"value");this.value=n}op(){return"in"}code(){return 33}test(t){const{val:n}=te(t,this.path);for(const s of this.value)if(Pn(n,s))return!0;return!1}toJson(t){return{op:"in",path:W(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,n){return[n?"in":33,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(33),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeArray(this.value)}}class zc extends Ce{constructor(t,n){super(t);x(this,"value");this.value=n}op(){return"less"}code(){return 34}test(t){const{val:n}=te(t,this.path);return typeof n!="number"?!1:n<this.value}toJson(t){return{op:"less",path:W(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,n){return[n?"less":34,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(34),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeNumber(this.value)}}class Wc extends Ce{constructor(t,n){super(t);x(this,"value");this.value=n}op(){return"more"}code(){return 36}test(t){const{val:n}=te(t,this.path);return typeof n!="number"?!1:n>this.value}toJson(t){return{op:"more",path:W(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,n){return[n?"more":36,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(36),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeNumber(this.value)}}class As extends Ce{constructor(t,n){super(t);x(this,"ops");this.ops=n}}class Gc extends As{constructor(t,n){super(t,n);x(this,"ops");this.ops=n}op(){return"and"}code(){return 43}test(t){for(const n of this.ops)if(!n.test(t))return!1;return!0}toJson(t){return{op:"and",path:W(t?this.path.slice(t.path.length):this.path),apply:this.ops.map(s=>s.toJson(this))}}toCompact(t,n){return[n?"and":43,t?this.path.slice(t.path.length):this.path,this.ops.map(r=>r.toCompact(this,n))]}encode(t,n){const s=n?this.path.slice(n.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 Kc extends As{constructor(t,n){super(t,n);x(this,"ops");this.ops=n}op(){return"or"}code(){return 45}test(t){for(const n of this.ops)if(n.test(t))return!0;return!1}toJson(t){return{op:"or",path:W(t?this.path.slice(t.path.length):this.path),apply:this.ops.map(s=>s.toJson(this))}}toCompact(t,n){return[n?"or":45,t?this.path.slice(t.path.length):this.path,this.ops.map(r=>r.toCompact(this,n))]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(45),t.encodeArray(n?this.path.slice(n.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 Yc extends As{constructor(t,n){super(t,n);x(this,"ops");this.ops=n}op(){return"not"}code(){return 44}test(t){for(const n of this.ops)if(n.test(t))return!1;return!0}toJson(t){return{op:"not",path:W(t?this.path.slice(t.path.length):this.path),apply:this.ops.map(s=>s.toJson(this))}}toCompact(t,n){return[n?"not":44,t?this.path.slice(t.path.length):this.path,this.ops.map(r=>r.toCompact(this,n))]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(44),t.encodeArray(n?this.path.slice(n.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 Xc extends Ce{constructor(t,n,s,r){super(t);x(this,"value");x(this,"ignore_case");x(this,"matcher");this.value=n,this.ignore_case=s,this.matcher=r(n,s)}op(){return"matches"}code(){return 35}test(t){const{val:n}=te(t,this.path);return typeof n!="string"?!1:this.matcher(n)}toJson(t){const n={op:"matches",path:W(t?this.path.slice(t.path.length):this.path),value:this.value};return this.ignore_case&&(n.ignore_case=this.ignore_case),n}toCompact(t,n){const s=n?"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,n){const s=this.ignore_case;t.encodeArrayHeader(s?4:3),t.writer.u8(35),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeString(this.value),s&&t.writer.u8(1)}}const{isArray:Qc}=Array;class Zc extends Ce{constructor(t,n){super(t);x(this,"value");this.value=n}op(){return"type"}code(){return 42}test(t){const{val:n}=te(t,this.path);return n===null?this.value==="null":Qc(n)?this.value==="array":typeof n===this.value||typeof n=="number"&&n===Math.round(n)&&this.value==="integer"}toJson(t){return{op:"type",path:W(t?this.path.slice(t.path.length):this.path),value:this.value}}toCompact(t,n){return[n?"type":42,t?this.path.slice(t.path.length):this.path,this.value]}encode(t,n){t.encodeArrayHeader(3),t.writer.u8(42),t.encodeArray(n?this.path.slice(n.path.length):this.path),t.encodeString(this.value)}}const eu=(i,e)=>{switch(i.op){case"add":return new Is($(i.path),i.value);case"remove":return new Xr($(i.path),i.oldValue);case"replace":return new Sc($(i.path),i.value,i.oldValue);case"move":return new Cc($(i.path),$(i.from));case"copy":return new wc($(i.path),$(i.from));case"flip":return new Pc($(i.path));case"inc":return new Rc($(i.path),i.inc);case"str_ins":return new _c($(i.path),i.pos,i.str);case"str_del":return new Ic($(i.path),i.pos,i.str,i.len);case"split":return new Lc($(i.path),i.pos,i.props||null);case"merge":return new Nc($(i.path),i.pos,i.props||null);case"extend":return new Dc($(i.path),i.props,!!i.deleteNull);default:return mn(i,e)}},mn=(i,e)=>{switch(i.op){case"test":return new Ec($(i.path),i.value,!!i.not);case"defined":return new Mc($(i.path));case"undefined":return new Uc($(i.path));case"type":return new Zc($(i.path),i.value);case"test_type":return new Bc($(i.path),i.type);case"test_string":return new Jc($(i.path),i.pos,i.str,!!i.not);case"test_string_len":return new jc($(i.path),i.len,!!i.not);case"contains":return new Vc($(i.path),i.value,!!i.ignore_case);case"ends":return new $c($(i.path),i.value,!!i.ignore_case);case"starts":return new qc($(i.path),i.value,!!i.ignore_case);case"matches":return new Xc($(i.path),i.value,!!i.ignore_case,e.createMatcher||Oc);case"in":return new Hc($(i.path),i.value);case"less":return new zc($(i.path),i.value);case"more":return new Wc($(i.path),i.value);case"and":{const t=$(i.path);return new Gc(t,i.apply.map(n=>mn({...n,path:[...t,...$(n.path)]},e)))}case"or":{const t=$(i.path);return new Kc(t,i.apply.map(n=>mn({...n,path:[...t,...$(n.path)]},e)))}case"not":{const t=$(i.path);return new Yc(t,i.apply.map(n=>mn({...n,path:[...t,...$(n.path)]},e)))}default:throw new Error("OP_UNKNOWN")}};function tu(i,e,t){t.mutate||(i=Ki(i));const n=[],s=e.length;for(let r=0;r<s;r++){const o=eu(e[r],t).apply(i);i=o.doc,n.push(o)}return{doc:i,res:n}}var Bi=i=>typeof i=="function"?i:function(){return i},iu=typeof self<"u"?self:null,Di=typeof window<"u"?window:null,Ji=iu||Di||Ji,nu="2.0.0",Qe={connecting:0,open:1,closing:2,closed:3},su=1e4,ru=1e3,Le={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},bt={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},os={longpoll:"longpoll",websocket:"websocket"},au={complete:4},un=class{constructor(i,e,t,n){this.channel=i,this.event=e,this.payload=t||function(){return{}},this.receivedResp=null,this.timeout=n,this.timeoutTimer=null,this.recHooks=[],this.sent=!1}resend(i){this.timeout=i,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(i,e){return this.hasReceived(i)&&e(this.receivedResp.response),this.recHooks.push({status:i,callback:e}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}matchReceive({status:i,response:e,_ref:t}){this.recHooks.filter(n=>n.status===i).forEach(n=>n.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,i=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=i,this.matchReceive(i)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(i){return this.receivedResp&&this.receivedResp.status===i}trigger(i,e){this.channel.trigger(this.refEvent,{status:i,response:e})}},Qr=class{constructor(i,e){this.callback=i,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))}},ou=class{constructor(i,e,t){this.state=Le.closed,this.topic=i,this.params=Bi(e||{}),this.socket=t,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new un(this,bt.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new Qr(()=>{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=Le.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(n=>n.send()),this.pushBuffer=[]}),this.joinPush.receive("error",()=>{this.state=Le.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=Le.closed,this.socket.remove(this)}),this.onError(n=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,n),this.isJoining()&&this.joinPush.reset(),this.state=Le.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 un(this,bt.leave,Bi({}),this.timeout).send(),this.state=Le.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(bt.reply,(n,s)=>{this.trigger(this.replyEventName(s),n)})}join(i=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=i,this.joinedOnce=!0,this.rejoin(),this.joinPush}onClose(i){this.on(bt.close,i)}onError(i){return this.on(bt.error,e=>i(e))}on(i,e){let t=this.bindingRef++;return this.bindings.push({event:i,ref:t,callback:e}),t}off(i,e){this.bindings=this.bindings.filter(t=>!(t.event===i&&(typeof e>"u"||e===t.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(i,e,t=this.timeout){if(e=e||{},!this.joinedOnce)throw new Error(`tried to push '${i}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let n=new un(this,i,function(){return e},t);return this.canPush()?n.send():(n.startTimeout(),this.pushBuffer.push(n)),n}leave(i=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=Le.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(bt.close,"leave")},t=new un(this,bt.leave,Bi({}),i);return t.receive("ok",()=>e()).receive("timeout",()=>e()),t.send(),this.canPush()||t.trigger("ok",{}),t}onMessage(i,e,t){return e}isMember(i,e,t,n){return this.topic!==i?!1:n&&n!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:i,event:e,payload:t,joinRef:n}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(i=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=Le.joining,this.joinPush.resend(i))}trigger(i,e,t,n){let s=this.onMessage(i,e,t,n);if(e&&!s)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let r=this.bindings.filter(a=>a.event===i);for(let a=0;a<r.length;a++)r[a].callback(s,t,n||this.joinRef())}replyEventName(i){return`chan_reply_${i}`}isClosed(){return this.state===Le.closed}isErrored(){return this.state===Le.errored}isJoined(){return this.state===Le.joined}isJoining(){return this.state===Le.joining}isLeaving(){return this.state===Le.leaving}},Rn=class{static request(i,e,t,n,s,r,a){if(Ji.XDomainRequest){let o=new Ji.XDomainRequest;return this.xdomainRequest(o,i,e,n,s,r,a)}else{let o=new Ji.XMLHttpRequest;return this.xhrRequest(o,i,e,t,n,s,r,a)}}static xdomainRequest(i,e,t,n,s,r,a){return i.timeout=s,i.open(e,t),i.onload=()=>{let o=this.parseJSON(i.responseText);a&&a(o)},r&&(i.ontimeout=r),i.onprogress=()=>{},i.send(n),i}static xhrRequest(i,e,t,n,s,r,a,o){return i.open(e,t,!0),i.timeout=r,i.setRequestHeader("Content-Type",n),i.onerror=()=>o&&o(null),i.onreadystatechange=()=>{if(i.readyState===au.complete&&o){let c=this.parseJSON(i.responseText);o(c)}},a&&(i.ontimeout=a),i.send(s),i}static parseJSON(i){if(!i||i==="")return null;try{return JSON.parse(i)}catch{return console&&console.log("failed to parse JSON response",i),null}}static serialize(i,e){let t=[];for(var n in i){if(!Object.prototype.hasOwnProperty.call(i,n))continue;let s=e?`${e}[${n}]`:n,r=i[n];typeof r=="object"?t.push(this.serialize(r,s)):t.push(encodeURIComponent(s)+"="+encodeURIComponent(r))}return t.join("&")}static appendParams(i,e){if(Object.keys(e).length===0)return i;let t=i.match(/\?/)?"&":"?";return`${i}${t}${this.serialize(e)}`}},qn=class{constructor(i){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(i),this.readyState=Qe.connecting,this.poll()}normalizeEndpoint(i){return i.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+os.websocket),"$1/"+os.longpoll)}endpointURL(){return Rn.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(i,e,t){this.close(i,e,t),this.readyState=Qe.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===Qe.open||this.readyState===Qe.connecting}poll(){this.ajax("GET",null,()=>this.ontimeout(),i=>{if(i){var{status:e,token:t,messages:n}=i;this.token=t}else e=0;switch(e){case 200:n.forEach(s=>{setTimeout(()=>this.onmessage({data:s}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=Qe.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(i){this.ajax("POST",i,()=>this.onerror("timeout"),e=>{(!e||e.status!==200)&&(this.onerror(e&&e.status),this.closeAndRetry(1011,"internal server error",!1))})}close(i,e,t){for(let s of this.reqs)s.abort();this.readyState=Qe.closed;let n=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:i,reason:e,wasClean:t});typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",n)):this.onclose(n)}ajax(i,e,t,n){let s,r=()=>{this.reqs.delete(s),t()};s=Rn.request(i,this.endpointURL(),"application/json",e,this.timeout,r,a=>{this.reqs.delete(s),this.isActive()&&n(a)}),this.reqs.add(s)}},dn={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(i,e){if(i.payload.constructor===ArrayBuffer)return e(this.binaryEncode(i));{let t=[i.join_ref,i.ref,i.topic,i.event,i.payload];return e(JSON.stringify(t))}},decode(i,e){if(i.constructor===ArrayBuffer)return e(this.binaryDecode(i));{let[t,n,s,r,a]=JSON.parse(i);return e({join_ref:t,ref:n,topic:s,event:r,payload:a})}},binaryEncode(i){let{join_ref:e,ref:t,event:n,topic:s,payload:r}=i,a=this.META_LENGTH+e.length+t.length+s.length+n.length,o=new ArrayBuffer(this.HEADER_LENGTH+a),c=new DataView(o),u=0;c.setUint8(u++,this.KINDS.push),c.setUint8(u++,e.length),c.setUint8(u++,t.length),c.setUint8(u++,s.length),c.setUint8(u++,n.length),Array.from(e,h=>c.setUint8(u++,h.charCodeAt(0))),Array.from(t,h=>c.setUint8(u++,h.charCodeAt(0))),Array.from(s,h=>c.setUint8(u++,h.charCodeAt(0))),Array.from(n,h=>c.setUint8(u++,h.charCodeAt(0)));var d=new Uint8Array(o.byteLength+r.byteLength);return d.set(new Uint8Array(o),0),d.set(new Uint8Array(r),o.byteLength),d.buffer},binaryDecode(i){let e=new DataView(i),t=e.getUint8(0),n=new TextDecoder;switch(t){case this.KINDS.push:return this.decodePush(i,e,n);case this.KINDS.reply:return this.decodeReply(i,e,n);case this.KINDS.broadcast:return this.decodeBroadcast(i,e,n)}},decodePush(i,e,t){let n=e.getUint8(1),s=e.getUint8(2),r=e.getUint8(3),a=this.HEADER_LENGTH+this.META_LENGTH-1,o=t.decode(i.slice(a,a+n));a=a+n;let c=t.decode(i.slice(a,a+s));a=a+s;let u=t.decode(i.slice(a,a+r));a=a+r;let d=i.slice(a,i.byteLength);return{join_ref:o,ref:null,topic:c,event:u,payload:d}},decodeReply(i,e,t){let n=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(i.slice(o,o+n));o=o+n;let u=t.decode(i.slice(o,o+s));o=o+s;let d=t.decode(i.slice(o,o+r));o=o+r;let h=t.decode(i.slice(o,o+a));o=o+a;let f=i.slice(o,i.byteLength),p={status:h,response:f};return{join_ref:c,ref:u,topic:d,event:bt.reply,payload:p}},decodeBroadcast(i,e,t){let n=e.getUint8(1),s=e.getUint8(2),r=this.HEADER_LENGTH+2,a=t.decode(i.slice(r,r+n));r=r+n;let o=t.decode(i.slice(r,r+s));r=r+s;let c=i.slice(r,i.byteLength);return{join_ref:null,ref:null,topic:a,event:o,payload:c}}},cu=class{constructor(i,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=e.timeout||su,this.transport=e.transport||Ji.WebSocket||qn,this.establishedConnections=0,this.defaultEncoder=dn.encode.bind(dn),this.defaultDecoder=dn.decode.bind(dn),this.closeWasClean=!1,this.binaryType=e.binaryType||"arraybuffer",this.connectClock=1,this.transport!==qn?(this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let t=null;Di&&Di.addEventListener&&(Di.addEventListener("pagehide",n=>{this.conn&&(this.disconnect(),t=this.connectClock)}),Di.addEventListener("pageshow",n=>{t===this.connectClock&&(t=null,this.connect())})),this.heartbeatIntervalMs=e.heartbeatIntervalMs||3e4,this.rejoinAfterMs=n=>e.rejoinAfterMs?e.rejoinAfterMs(n):[1e3,2e3,5e3][n-1]||1e4,this.reconnectAfterMs=n=>e.reconnectAfterMs?e.reconnectAfterMs(n):[10,50,100,150,200,250,500,1e3,2e3][n-1]||5e3,this.logger=e.logger||null,this.longpollerTimeout=e.longpollerTimeout||2e4,this.params=Bi(e.params||{}),this.endPoint=`${i}/${os.websocket}`,this.vsn=e.vsn||nu,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new Qr(()=>{this.teardown(()=>this.connect())},this.reconnectAfterMs)}getLongPollTransport(){return qn}replaceTransport(i){this.connectClock++,this.closeWasClean=!0,this.reconnectTimer.reset(),this.sendBuffer=[],this.conn&&(this.conn.close(),this.conn=null),this.transport=i}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let i=Rn.appendParams(Rn.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return i.charAt(0)!=="/"?i:i.charAt(1)==="/"?`${this.protocol()}:${i}`:`${this.protocol()}://${location.host}${i}`}disconnect(i,e,t){this.connectClock++,this.closeWasClean=!0,this.reconnectTimer.reset(),this.teardown(i,e,t)}connect(i){i&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=Bi(i)),!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(i,e,t){this.logger(i,e,t)}hasLogger(){return this.logger!==null}onOpen(i){let e=this.makeRef();return this.stateChangeCallbacks.open.push([e,i]),e}onClose(i){let e=this.makeRef();return this.stateChangeCallbacks.close.push([e,i]),e}onError(i){let e=this.makeRef();return this.stateChangeCallbacks.error.push([e,i]),e}onMessage(i){let e=this.makeRef();return this.stateChangeCallbacks.message.push([e,i]),e}ping(i){if(!this.isConnected())return!1;let e=this.makeRef(),t=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:e});let n=this.onMessage(s=>{s.ref===e&&(this.off([n]),i(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(([,i])=>i())}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(),ru,"heartbeat timeout"))}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(i,e,t){if(!this.conn)return i&&i();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),i&&i()})})}waitForBufferDone(i,e=1){if(e===5||!this.conn||!this.conn.bufferedAmount){i();return}setTimeout(()=>{this.waitForBufferDone(i,e+1)},150*e)}waitForSocketClosed(i,e=1){if(e===5||!this.conn||this.conn.readyState===Qe.closed){i();return}setTimeout(()=>{this.waitForSocketClosed(i,e+1)},150*e)}onConnClose(i){let e=i&&i.code;this.hasLogger()&&this.log("transport","close",i),this.triggerChanError(),this.clearHeartbeats(),!this.closeWasClean&&e!==1e3&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,t])=>t(i))}onConnError(i){this.hasLogger()&&this.log("transport",i);let e=this.transport,t=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,n])=>{n(i,e,t)}),(e===this.transport||t>0)&&this.triggerChanError()}triggerChanError(){this.channels.forEach(i=>{i.isErrored()||i.isLeaving()||i.isClosed()||i.trigger(bt.error)})}connectionState(){switch(this.conn&&this.conn.readyState){case Qe.connecting:return"connecting";case Qe.open:return"open";case Qe.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(i){this.off(i.stateChangeRefs),this.channels=this.channels.filter(e=>e.joinRef()!==i.joinRef())}off(i){for(let e in this.stateChangeCallbacks)this.stateChangeCallbacks[e]=this.stateChangeCallbacks[e].filter(([t])=>i.indexOf(t)===-1)}channel(i,e={}){let t=new ou(i,e,this);return this.channels.push(t),t}push(i){if(this.hasLogger()){let{topic:e,event:t,payload:n,ref:s,join_ref:r}=i;this.log("push",`${e} ${t} (${r}, ${s})`,n)}this.isConnected()?this.encode(i,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(i,e=>this.conn.send(e)))}makeRef(){let i=this.ref+1;return i===this.ref?this.ref=0:this.ref=i,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(i=>i()),this.sendBuffer=[])}onConnMessage(i){this.decode(i.data,e=>{let{topic:t,event:n,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} ${n} ${r&&"("+r+")"||""}`,s);for(let o=0;o<this.channels.length;o++){const c=this.channels[o];c.isMember(t,n,s,a)&&c.trigger(n,s,r,a)}for(let o=0;o<this.stateChangeCallbacks.message.length;o++){let[,c]=this.stateChangeCallbacks.message[o];c(e)}})}leaveOpenTopic(i){let e=this.channels.find(t=>t.topic===i&&(t.isJoined()||t.isJoining()));e&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${i}"`),e.leave())}};class uu{constructor(e){this.connected=!1,this.config=e,this.socket=new cu(this.config.url,this.config.socketOptions||{logger:(t,n,s)=>{console.debug(`${t}: ${n}`,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.connected=!0)}disconnect(){this.channel&&this.channel.leave(),this.socket.disconnect(),this.connected=!1}addEventListener(e,t,n){var s;this.eventTarget.addEventListener(e,t,n),e.startsWith("livestate-")||(s=this.channel)==null||s.on(e,r=>{this.eventTarget.dispatchEvent(new CustomEvent(e,{detail:r}))})}removeEventListener(e,t,n){return this.eventTarget.removeEventListener(e,t,n)}subscribe(e){this.addEventListener("livestate-change",e)}unsubscribe(e){this.removeEventListener("livestate-change",e)}emitError(e,t){this.eventTarget.dispatchEvent(new CustomEvent("livestate-error",{detail:{kind:e,error:t}}))}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:n,res:s}=tu(this.state,e,{mutate:!1});this.state=n,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)}}Promise.resolve();var Gs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/*! *****************************************************************************
|
|
2
2
|
Copyright (C) Microsoft. All rights reserved.
|
|
3
3
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
4
4
|
this file except in compliance with the License. You may obtain a copy of the
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Mo = Object.defineProperty;
|
|
2
2
|
var Uo = (i, e, t) => e in i ? Mo(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
3
|
var x = (i, e, t) => (Uo(i, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
-
import { a as Fo, c as Bo } from "./constants-
|
|
4
|
+
import { a as Fo, c as Bo } from "./constants-eb4cd3ce.js";
|
|
5
5
|
function Wi() {
|
|
6
6
|
}
|
|
7
7
|
function $r(i) {
|
package/dist/main.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const s=require("./constants-
|
|
1
|
+
"use strict";const s=require("./constants-f9ac3da1.cjs"),l=e=>Object.freeze(Object.defineProperty({__proto__:null,default:e},Symbol.toStringTag,{value:"Module"}));let a,n;c();i();function i(){window.addEventListener("popstate",c)}async function c(){const e=document.querySelector("script[src*='/liveroom-client-element']");e==null||e.setAttribute("version",s.VERSION);const t=S(e);if(t&&t!=a){a=t,sessionStorage==null||sessionStorage.setItem(s.SESSION_STORAGE_KEY_ROOM_ID,a),n&&(n.remove(),n=void 0);const o=e==null?void 0:e.getAttribute("data-url");await _(o||"wss://liveroom.app/client_socket",a)}}async function _(e,t){if(!t)return!1;await Promise.resolve().then(()=>l(require("./liveroom-client-element.cjs"))),console.log(`[Liveroom] Installed successfully (v${s.VERSION})`),n=document.createElement(s.ELEMENT_TAG),n.setAttribute("url",e),n.setAttribute("version",s.VERSION),t&&n.setAttribute("room_id",t);const o=m();o&&n.setAttribute("user_name",o);const r=E();return r&&n.setAttribute("user_color",r),document.body.appendChild(n),console.log("[Liveroom] Injected successfully"),!0}function m(){const t=new URLSearchParams(window.location.search).get(s.QUERY_PARAM_KEY_USER_NAME),o=sessionStorage==null?void 0:sessionStorage.getItem(s.SESSION_STORAGE_KEY_USER_NAME);return t||o||null}function E(){const t=new URLSearchParams(window.location.search).get(s.QUERY_PARAM_KEY_USER_COLOR),o=sessionStorage==null?void 0:sessionStorage.getItem(s.SESSION_STORAGE_KEY_USER_COLOR);return t||o||null}function S(e){const o=new URLSearchParams(window.location.search).get(s.QUERY_PARAM_KEY_ROOM_ID),r=sessionStorage==null?void 0:sessionStorage.getItem(s.SESSION_STORAGE_KEY_ROOM_ID),u=(e==null?void 0:e.getAttribute("data-roomid"))||null;return R(o||r||u)}function R(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