kritzel-stencil 0.1.76 → 0.1.78
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/cjs/{index-Dc7LOVhs.js → index-BRZ6e6oa.js} +1 -1
- package/dist/cjs/index.cjs.js +2 -330
- package/dist/cjs/kritzel-active-users_42.cjs.entry.js +88 -50
- package/dist/cjs/kritzel-brush-style.cjs.entry.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/stencil.cjs.js +2 -2
- package/dist/cjs/{workspace.migrations-DkmVO6dE.js → workspace.migrations-sUPrO23c.js} +378 -13
- package/dist/collection/classes/objects/selection-group.class.js +2 -0
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/core/kritzel-awareness-cursors/kritzel-awareness-cursors.css +6 -1
- package/dist/collection/components/core/kritzel-awareness-cursors/kritzel-awareness-cursors.js +5 -2
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.css +2 -0
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +16 -6
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +21 -0
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +24 -10
- package/dist/collection/components/ui/kritzel-login-dialog/kritzel-login-dialog.css +3 -0
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.css +1 -0
- package/dist/collection/configs/default-engine-config.js +1 -0
- package/dist/collection/constants/version.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/kritzel-active-users.js +1 -1
- package/dist/components/kritzel-avatar.js +1 -1
- package/dist/components/kritzel-awareness-cursors.js +1 -1
- package/dist/components/kritzel-back-to-content.js +1 -1
- package/dist/components/kritzel-brush-style.js +1 -1
- package/dist/components/kritzel-button.js +1 -1
- package/dist/components/kritzel-color-palette.js +1 -1
- package/dist/components/kritzel-color.js +1 -1
- package/dist/components/kritzel-context-menu.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-current-user-dialog.js +1 -1
- package/dist/components/kritzel-current-user.js +1 -1
- package/dist/components/kritzel-cursor-trail.js +1 -1
- package/dist/components/kritzel-dialog.js +1 -1
- package/dist/components/kritzel-dropdown.js +1 -1
- package/dist/components/kritzel-editor.js +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/kritzel-export.js +1 -1
- package/dist/components/kritzel-font-family.js +1 -1
- package/dist/components/kritzel-font-size.js +1 -1
- package/dist/components/kritzel-font.js +1 -1
- package/dist/components/kritzel-icon.js +1 -1
- package/dist/components/kritzel-input.js +1 -1
- package/dist/components/kritzel-line-endings.js +1 -1
- package/dist/components/kritzel-login-dialog.js +1 -1
- package/dist/components/kritzel-master-detail.js +1 -1
- package/dist/components/kritzel-menu-item.js +1 -1
- package/dist/components/kritzel-menu.js +1 -1
- package/dist/components/kritzel-more-menu.js +1 -1
- package/dist/components/kritzel-numeric-input.js +1 -1
- package/dist/components/kritzel-opacity-slider.js +1 -1
- package/dist/components/kritzel-pill-tabs.js +1 -1
- package/dist/components/kritzel-portal.js +1 -1
- package/dist/components/kritzel-settings.js +1 -1
- package/dist/components/kritzel-shape-fill.js +1 -1
- package/dist/components/kritzel-share-dialog.js +1 -1
- package/dist/components/kritzel-slide-toggle.js +1 -1
- package/dist/components/kritzel-split-button.js +1 -1
- package/dist/components/kritzel-stroke-size.js +1 -1
- package/dist/components/kritzel-tool-config.js +1 -1
- package/dist/components/kritzel-tooltip.js +1 -1
- package/dist/components/kritzel-utility-panel.js +1 -1
- package/dist/components/kritzel-workspace-manager.js +1 -1
- package/dist/components/{p-Dt-J69xt.js → p-53di1Zko.js} +1 -1
- package/dist/components/{p-DS0xx1eT.js → p-6NFl6EB2.js} +1 -1
- package/dist/components/{p-DSzQ6H2j.js → p-76W5pG2O.js} +1 -1
- package/dist/components/{p-DRbG92F9.js → p-BLsH_Oi0.js} +1 -1
- package/dist/components/p-Ban3OlgZ.js +9 -0
- package/dist/components/{p-CUkKKbnu.js → p-BrZ_gL8Q.js} +1 -1
- package/dist/components/{p-kj9wbLY8.js → p-BuI6Gkzg.js} +1 -1
- package/dist/components/{p-BeFUNGEI.js → p-BueaqfA2.js} +1 -1
- package/dist/components/{p-BiByyU2C.js → p-C2l9mZ1P.js} +1 -1
- package/dist/components/{p-CsR4owzk.js → p-C4fKLlrd.js} +1 -1
- package/dist/components/{p-BA0ayKqO.js → p-CBslLN3-.js} +1 -1
- package/dist/components/p-CHY71o5B.js +1 -0
- package/dist/components/{p-KQzWumjB.js → p-CI9Nbh-x.js} +1 -1
- package/dist/components/{p-CsoDfhD5.js → p-CN8IxBlU.js} +1 -1
- package/dist/components/{p-2OYw6GJ7.js → p-CWMFGEe0.js} +1 -1
- package/dist/components/{p-Dj_Qjga5.js → p-CYh7yV-K.js} +1 -1
- package/dist/components/{p-xM-_OeRO.js → p-Ck1dhpUQ.js} +1 -1
- package/dist/components/{p-b4gyXoju.js → p-Cns7qSKS.js} +1 -1
- package/dist/components/{p-C69Stayh.js → p-D14QNK3X.js} +1 -1
- package/dist/components/{p-iRL0wQHQ.js → p-D3pNw-SV.js} +1 -1
- package/dist/components/{p-BEJQ2kP7.js → p-D5IhryUR.js} +1 -1
- package/dist/components/{p-CZhyKp-f.js → p-D7yzmu1l.js} +1 -1
- package/dist/components/{p-HLbqRJGs.js → p-DDKjsXCe.js} +1 -1
- package/dist/components/{p-TyR-YTXm.js → p-DV7Z_qfa.js} +1 -1
- package/dist/components/{p-ByR0VXeU.js → p-DWsCbu01.js} +1 -1
- package/dist/components/{p-31FVoNWR.js → p-DaGZEV0R.js} +1 -1
- package/dist/components/{p-Da46jw3N.js → p-DkWWzVg8.js} +1 -1
- package/dist/components/{p-D1O7DxL4.js → p-Dr3-pKVg.js} +1 -1
- package/dist/components/{p-JdNoaqqb.js → p-Dte67BWd.js} +1 -1
- package/dist/components/{p-CHmi1QWx.js → p-DxzDda_J.js} +1 -1
- package/dist/components/{p-CAIGuV2J.js → p-KJ4dHzrS.js} +1 -1
- package/dist/components/{p-BiouZo1q.js → p-Lhyh6KeB.js} +1 -1
- package/dist/components/{p-CFhp1W9F.js → p-Md9Y-b3d.js} +1 -1
- package/dist/components/{p-C1uR_ZNW.js → p-ZC5YELQJ.js} +1 -1
- package/dist/components/{p-C7SBI_0T.js → p-ZQ2bKafG.js} +1 -1
- package/dist/components/{p-0kShCfeb.js → p-_QEHfsIk.js} +1 -1
- package/dist/components/{p-DXjuuVq9.js → p-gtQlsorg.js} +1 -1
- package/dist/components/{p-GYI7sDxr.js → p-l_YGO7RB.js} +1 -1
- package/dist/components/{p-DvIEvoZu.js → p-m1nVDC3G.js} +1 -1
- package/dist/components/{p-7o2FWtFx.js → p-pCC6t6BH.js} +1 -1
- package/dist/components/p-pGzF7PUB.js +1 -0
- package/dist/esm/{index-MV-81ybv.js → index-BbOHefEf.js} +1 -1
- package/dist/esm/index.js +2 -331
- package/dist/esm/kritzel-active-users_42.entry.js +88 -50
- package/dist/esm/kritzel-brush-style.entry.js +1 -1
- package/dist/esm/loader.js +2 -2
- package/dist/esm/stencil.js +3 -3
- package/dist/esm/{workspace.migrations-D48_Bqvh.js → workspace.migrations-NhRgr2_H.js} +378 -12
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-4a4b38e4.entry.js +9 -0
- package/dist/stencil/{p-fc21e29c.entry.js → p-98238bf9.entry.js} +1 -1
- package/dist/stencil/p-NhRgr2_H.js +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/objects/selection-group.class.d.ts +1 -0
- package/dist/types/components.d.ts +4 -2
- package/dist/types/constants/version.d.ts +1 -1
- package/dist/types/interfaces/engine-state.interface.d.ts +1 -0
- package/package.json +2 -2
- package/dist/components/p-CJ2eHeoV.js +0 -1
- package/dist/components/p-jdYmu4SA.js +0 -9
- package/dist/components/p-xNwOWoiT.js +0 -1
- package/dist/stencil/p-775a7246.entry.js +0 -9
- package/dist/stencil/p-D48_Bqvh.js +0 -1
- /package/dist/components/{p-pebXO4LU.js → p-CGGiwvWZ.js} +0 -0
- /package/dist/stencil/{p-MV-81ybv.js → p-BbOHefEf.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as e,c as s,h as i,d as n,t as o}from"./p-pebXO4LU.js";import{K as r,d as a}from"./p-CHmi1QWx.js";import{S as h,h as c,d as l,e as d,g as u,f as p,i as m,j as g,k as b}from"./p-CJ2eHeoV.js";import{e as f,f as y,K as k,a as w,d as v,I as z,g as C}from"./p-jdYmu4SA.js";import{D as j}from"./p-CjazGGq3.js";import{K as A}from"./p-jGOpkGDl.js";import"./p-DXpYcAnT.js";import*as S from"yjs";import"y-websocket";import{d as x}from"./p-DSzQ6H2j.js";import{d as E}from"./p-BeFUNGEI.js";import{d as T}from"./p-xNwOWoiT.js";import{d as I}from"./p-BA0ayKqO.js";import{d as O}from"./p-DS0xx1eT.js";import{d as U}from"./p-C1uR_ZNW.js";import{d as R}from"./p-BEJQ2kP7.js";import{d as D}from"./p-CAIGuV2J.js";import{d as M}from"./p-CsoDfhD5.js";import{d as W}from"./p-iRL0wQHQ.js";import{d as P}from"./p-Dj_Qjga5.js";import{d as V}from"./p-BiByyU2C.js";import{d as B}from"./p-Dt-J69xt.js";import{d as F}from"./p-GYI7sDxr.js";import{d as L}from"./p-DRbG92F9.js";import{d as N}from"./p-HLbqRJGs.js";import{d as J}from"./p-TyR-YTXm.js";import{d as G}from"./p-CZhyKp-f.js";import{d as H}from"./p-C69Stayh.js";import{d as K}from"./p-CFhp1W9F.js";import{d as q}from"./p-DXjuuVq9.js";import{d as Y}from"./p-Da46jw3N.js";import{d as Q,a as $}from"./p-KQzWumjB.js";import{d as _}from"./p-b4gyXoju.js";import{d as X}from"./p-ByR0VXeU.js";import{d as Z}from"./p-C7SBI_0T.js";import{d as tt}from"./p-CUkKKbnu.js";import{d as et}from"./p-D1O7DxL4.js";import{d as st}from"./p-31FVoNWR.js";import{d as it}from"./p-JdNoaqqb.js";import{d as nt}from"./p-CsR4owzk.js";import{d as ot}from"./p-xM-_OeRO.js";import{d as rt}from"./p-7o2FWtFx.js";import{d as at}from"./p-BiouZo1q.js";import{d as ht}from"./p-2OYw6GJ7.js";import{d as ct}from"./p-kj9wbLY8.js";import{d as lt}from"./p-DvIEvoZu.js";import{d as dt}from"./p-0kShCfeb.js";const ut=Math.floor,pt=127,mt=Number.MAX_SAFE_INTEGER,gt="undefined"!=typeof TextEncoder?new TextEncoder:null,bt=gt?t=>gt.encode(t):t=>{const e=unescape(encodeURIComponent(t)),s=e.length,i=new Uint8Array(s);for(let t=0;t<s;t++)i[t]=e.codePointAt(t);return i};let ft="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});ft&&1===ft.decode(new Uint8Array).length&&(ft=null);const yt=(t,e)=>{const s=t.cbuf.length;t.cpos===s&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(2*s),t.cpos=0),t.cbuf[t.cpos++]=e},kt=(t,e)=>{for(;e>pt;)yt(t,128|pt&e),e=ut(e/128);yt(t,pt&e)},wt=new Uint8Array(3e4),vt=wt.length/3,zt=gt&>.encodeInto?(t,e)=>{if(e.length<vt){const s=gt.encodeInto(e,wt).written||0;kt(t,s);for(let e=0;e<s;e++)yt(t,wt[e])}else Ct(t,bt(e))}:(t,e)=>{const s=unescape(encodeURIComponent(e)),i=s.length;kt(t,i);for(let e=0;e<i;e++)yt(t,s.codePointAt(e))},Ct=(t,e)=>{kt(t,e.byteLength),((t,e)=>{const s=t.cbuf.length,i=t.cpos,n=((t,e)=>t<e?t:e)(s-i,e.length),o=e.length-n;t.cbuf.set(e.subarray(0,n),i),t.cpos+=n,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(((t,e)=>t>e?t:e)(2*s,o)),t.cbuf.set(e.subarray(n)),t.cpos=o)})(t,e)},jt=t=>Error(t),At=jt("Unexpected end of array"),St=jt("Integer out of Range"),xt=t=>t.arr[t.pos++],Et=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&pt)*s,s*=128,i<128)return e;if(e>mt)throw St}throw At},Tt=ft?t=>ft.decode((t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,Et(t)))(t)):t=>{let e=Et(t);if(0===e)return"";{let s=String.fromCodePoint(xt(t));if(--e<100)for(;e--;)s+=String.fromCodePoint(xt(t));else for(;e>0;){const i=e<1e4?e:1e4,n=t.arr.subarray(t.pos,t.pos+i);t.pos+=i,s+=String.fromCodePoint.apply(null,n),e-=i}return decodeURIComponent(escape(s))}};var It;!function(t){t[t.Token=0]="Token",t[t.PermissionDenied=1]="PermissionDenied",t[t.Authenticated=2]="Authenticated"}(It||(It={}));const Ot=t=>Array.from(t.entries()).map((([t,e])=>({clientId:t,...e})));var Ut;async function Rt(t){return new Promise((e=>setTimeout(e,t)))}function Dt(t,e){let s=e.delay;if(0===s)return 0;if(e.factor&&(s*=Math.pow(e.factor,t.attemptNum-1),0!==e.maxDelay&&(s=Math.min(s,e.maxDelay))),e.jitter){const t=Math.ceil(e.minDelay),i=Math.floor(s);s=Math.floor(Math.random()*(i-t+1))+t}return Math.round(s)}!function(t){t[t.Connecting=0]="Connecting",t[t.Open=1]="Open",t[t.Closing=2]="Closing",t[t.Closed=3]="Closed"}(Ut||(Ut={}));const Mt=Math.floor,Wt=128,Pt=127,Vt=Number.MAX_SAFE_INTEGER,Bt=()=>new Set,Ft=Array.from,Lt="undefined"!=typeof TextEncoder?new TextEncoder:null,Nt=Lt?t=>Lt.encode(t):t=>{const e=unescape(encodeURIComponent(t)),s=e.length,i=new Uint8Array(s);for(let t=0;t<s;t++)i[t]=e.codePointAt(t);return i};let Jt="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Jt&&1===Jt.decode(new Uint8Array).length&&(Jt=null);class Gt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Ht=()=>new Gt,Kt=t=>{let e=t.cpos;for(let s=0;s<t.bufs.length;s++)e+=t.bufs[s].length;return e},qt=t=>{const e=new Uint8Array(Kt(t));let s=0;for(let i=0;i<t.bufs.length;i++){const n=t.bufs[i];e.set(n,s),s+=n.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),s),e},Yt=(t,e)=>{const s=t.cbuf.length;t.cpos===s&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(2*s),t.cpos=0),t.cbuf[t.cpos++]=e},Qt=(t,e)=>{for(;e>Pt;)Yt(t,Wt|Pt&e),e=Mt(e/128);Yt(t,Pt&e)},$t=new Uint8Array(3e4),_t=$t.length/3,Xt=Lt&&Lt.encodeInto?(t,e)=>{if(e.length<_t){const s=Lt.encodeInto(e,$t).written||0;Qt(t,s);for(let e=0;e<s;e++)Yt(t,$t[e])}else Zt(t,Nt(e))}:(t,e)=>{const s=unescape(encodeURIComponent(e)),i=s.length;Qt(t,i);for(let e=0;e<i;e++)Yt(t,s.codePointAt(e))},Zt=(t,e)=>{Qt(t,e.byteLength),((t,e)=>{const s=t.cbuf.length,i=t.cpos,n=((t,e)=>t<e?t:e)(s-i,e.length),o=e.length-n;t.cbuf.set(e.subarray(0,n),i),t.cpos+=n,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(((t,e)=>t>e?t:e)(2*s,o)),t.cbuf.set(e.subarray(n)),t.cpos=o)})(t,e)},te=t=>Error(t),ee=te("Unexpected end of array"),se=te("Integer out of Range");class ie{constructor(t){this.arr=t,this.pos=0}}const ne=t=>new ie(t),oe=t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,ae(t)),re=t=>t.arr[t.pos++],ae=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&Pt)*s,s*=128,i<Wt)return e;if(e>Vt)throw se}throw ee},he=Jt?t=>Jt.decode(oe(t)):t=>{let e=ae(t);if(0===e)return"";{let s=String.fromCodePoint(re(t));if(--e<100)for(;e--;)s+=String.fromCodePoint(re(t));else for(;e>0;){const i=e<1e4?e:1e4,n=t.arr.subarray(t.pos,t.pos+i);t.pos+=i,s+=String.fromCodePoint.apply(null,n),e-=i}return decodeURIComponent(escape(s))}},ce=Date.now,le=()=>new Map;class de{constructor(){this._observers=le()}on(t,e){((t,e,s)=>{let i=t.get(e);return void 0===i&&t.set(e,i=s()),i})(this._observers,t,Bt).add(e)}once(t,e){const s=(...i)=>{this.off(t,s),e(...i)};this.on(t,s)}off(t,e){const s=this._observers.get(t);void 0!==s&&(s.delete(e),0===s.size&&this._observers.delete(t))}emit(t,e){return Ft((this._observers.get(t)||le()).values()).forEach((t=>t(...e)))}destroy(){this._observers=le()}}const ue=Object.keys,pe=t=>ue(t).length,me=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),ge=(t,e)=>{if(null==t||null==e)return((t,e)=>t===e)(t,e);if(t.constructor!==e.constructor)return!1;if(t===e)return!0;switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:if(t.byteLength!==e.byteLength)return!1;for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;break;case Set:if(t.size!==e.size)return!1;for(const s of t)if(!e.has(s))return!1;break;case Map:if(t.size!==e.size)return!1;for(const s of t.keys())if(!e.has(s)||!ge(t.get(s),e.get(s)))return!1;break;case Object:if(pe(t)!==pe(e))return!1;for(const s in t)if(!me(t,s)||!ge(t[s],e[s]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(!ge(t[s],e[s]))return!1;break;default:return!1}return!0};class be extends de{constructor(t){super(),this.doc=t,this.clientID=t.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval((()=>{const t=ce();null!==this.getLocalState()&&15e3<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const e=[];this.meta.forEach(((s,i)=>{i!==this.clientID&&3e4<=t-s.lastUpdated&&this.states.has(i)&&e.push(i)})),e.length>0&&fe(this,e,"timeout")}),Mt(3e3)),t.on("destroy",(()=>{this.destroy()})),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(t){const e=this.clientID,s=this.meta.get(e),i=void 0===s?0:s.clock+1,n=this.states.get(e);null===t?this.states.delete(e):this.states.set(e,t),this.meta.set(e,{clock:i,lastUpdated:ce()});const o=[],r=[],a=[],h=[];null===t?h.push(e):null==n?null!=t&&o.push(e):(r.push(e),ge(n,t)||a.push(e)),(o.length>0||a.length>0||h.length>0)&&this.emit("change",[{added:o,updated:a,removed:h},"local"]),this.emit("update",[{added:o,updated:r,removed:h},"local"])}setLocalStateField(t,e){const s=this.getLocalState();null!==s&&this.setLocalState({...s,[t]:e})}getStates(){return this.states}}const fe=(t,e,s)=>{const i=[];for(let s=0;s<e.length;s++){const n=e[s];if(t.states.has(n)){if(t.states.delete(n),n===t.clientID){const e=t.meta.get(n);t.meta.set(n,{clock:e.clock+1,lastUpdated:ce()})}i.push(n)}}i.length>0&&(t.emit("change",[{added:[],updated:[],removed:i},s]),t.emit("update",[{added:[],updated:[],removed:i},s]))},ye=(t,e,s=t.states)=>{const i=e.length,n=Ht();Qt(n,i);for(let o=0;o<i;o++){const i=e[o],r=s.get(i)||null,a=t.meta.get(i).clock;Qt(n,i),Qt(n,a),Xt(n,JSON.stringify(r))}return qt(n)};class ke{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const s=this.callbacks[t];return s&&s.forEach((t=>t.apply(this,e))),this}off(t,e){const s=this.callbacks[t];return s&&(e?this.callbacks[t]=s.filter((t=>t!==e)):delete this.callbacks[t]),this}removeAllListeners(){this.callbacks={}}}class we{constructor(t){this.data=t,this.encoder=Ht(),this.decoder=ne(new Uint8Array(this.data))}peekVarString(){return(t=>{const e=t.pos,s=he(t);return t.pos=e,s})(this.decoder)}readVarUint(){return ae(this.decoder)}readVarString(){return he(this.decoder)}readVarUint8Array(){return oe(this.decoder)}writeVarUint(t){return Qt(this.encoder,t)}writeVarString(t){return Xt(this.encoder,t)}writeVarUint8Array(t){return Zt(this.encoder,t)}length(){return Kt(this.encoder)}}var ve,ze;!function(t){t[t.Sync=0]="Sync",t[t.Awareness=1]="Awareness",t[t.Auth=2]="Auth",t[t.QueryAwareness=3]="QueryAwareness",t[t.Stateless=5]="Stateless",t[t.CLOSE=7]="CLOSE",t[t.SyncStatus=8]="SyncStatus"}(ve||(ve={})),function(t){t.Connecting="connecting",t.Connected="connected",t.Disconnected="disconnected"}(ze||(ze={}));class Ce{constructor(){this.encoder=Ht()}get(t){return t.encoder}toUint8Array(){return qt(this.encoder)}}class je extends Ce{constructor(){super(...arguments),this.type=ve.CLOSE,this.description="Ask the server to close the connection"}get(t){return Xt(this.encoder,t.documentName),Qt(this.encoder,this.type),this.encoder}}class Ae extends ke{constructor(t){super(),this.messageQueue=[],this.configuration={url:"",autoConnect:!0,preserveTrailingSlash:!1,document:void 0,WebSocketPolyfill:void 0,messageReconnectTimeout:3e4,delay:1e3,initialDelay:0,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0,timeout:0,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,handleTimeout:null,providerMap:new Map},this.webSocket=null,this.webSocketHandlers={},this.shouldConnect=!0,this.status=ze.Disconnected,this.lastMessageReceived=0,this.identifier=0,this.intervals={connectionChecker:null},this.connectionAttempt=null,this.receivedOnOpenPayload=void 0,this.closeTries=0,this.setConfiguration(t),this.configuration.WebSocketPolyfill=t.WebSocketPolyfill?t.WebSocketPolyfill:WebSocket,this.on("open",this.configuration.onOpen),this.on("open",this.onOpen.bind(this)),this.on("connect",this.configuration.onConnect),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("status",this.configuration.onStatus),this.on("disconnect",this.configuration.onDisconnect),this.on("close",this.configuration.onClose),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("close",this.onClose.bind(this)),this.on("message",this.onMessage.bind(this)),this.intervals.connectionChecker=setInterval(this.checkConnection.bind(this),this.configuration.messageReconnectTimeout/10),this.shouldConnect&&this.connect()}async onOpen(t){this.status=ze.Connected,this.emit("status",{status:ze.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=t}attach(t){this.configuration.providerMap.set(t.configuration.name,t),this.status===ze.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===ze.Connected&&t.onOpen(this.receivedOnOpenPayload)}detach(t){this.configuration.providerMap.has(t.configuration.name)&&(t.send(je,{documentName:t.configuration.name}),this.configuration.providerMap.delete(t.configuration.name))}setConfiguration(t={}){this.configuration={...this.configuration,...t},this.configuration.autoConnect||(this.shouldConnect=!1)}async connect(){if(this.status===ze.Connected)return;this.cancelWebsocketRetry&&(this.cancelWebsocketRetry(),this.cancelWebsocketRetry=void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;const{retryPromise:t,cancelFunc:e}=(()=>{let t=!1;return{retryPromise:async function(t,e){const s=function(t){return t||(t={}),{delay:void 0===t.delay?200:t.delay,initialDelay:void 0===t.initialDelay?0:t.initialDelay,minDelay:void 0===t.minDelay?0:t.minDelay,maxDelay:void 0===t.maxDelay?0:t.maxDelay,factor:void 0===t.factor?0:t.factor,maxAttempts:void 0===t.maxAttempts?3:t.maxAttempts,timeout:void 0===t.timeout?0:t.timeout,jitter:!0===t.jitter,initialJitter:!0===t.initialJitter,handleError:void 0===t.handleError?null:t.handleError,handleTimeout:void 0===t.handleTimeout?null:t.handleTimeout,beforeAttempt:void 0===t.beforeAttempt?null:t.beforeAttempt,calculateDelay:void 0===t.calculateDelay?null:t.calculateDelay}}(e);for(const t of["delay","initialDelay","minDelay","maxDelay","maxAttempts","timeout"]){const e=s[t];if(!Number.isInteger(e)||e<0)throw Error(`Value for ${t} must be an integer greater than or equal to 0`)}if(s.factor.constructor!==Number||s.factor<0)throw Error("Value for factor must be a number greater than or equal to 0");if(s.delay<s.minDelay)throw Error(`delay cannot be less than minDelay (delay: ${s.delay}, minDelay: ${s.minDelay}`);const i={attemptNum:0,attemptsRemaining:s.maxAttempts?s.maxAttempts:-1,aborted:!1,abort(){i.aborted=!0}},n=s.calculateDelay||Dt,o=s.calculateDelay?s.calculateDelay(i,s):s.initialDelay;if(o&&await Rt(o),i.attemptNum<1&&s.initialJitter){const t=n(i,s);t&&await Rt(t)}return async function e(){if(s.beforeAttempt&&s.beforeAttempt(i,s),i.aborted){const t=Error("Attempt aborted");throw t.code="ATTEMPT_ABORTED",t}const o=async t=>{if(s.handleError&&await s.handleError(t,i,s),i.aborted||0===i.attemptsRemaining)throw t;i.attemptNum++;const o=n(i,s);return o&&await Rt(o),e()};return i.attemptsRemaining>0&&i.attemptsRemaining--,s.timeout?new Promise(((e,n)=>{const r=setTimeout((()=>{if(s.handleTimeout)try{e(s.handleTimeout(i,s))}catch(t){n(t)}else{const t=Error(`Retry timeout (attemptNum: ${i.attemptNum}, timeout: ${s.timeout})`);t.code="ATTEMPT_TIMEOUT",n(t)}}),s.timeout);t(i,s).then((t=>{clearTimeout(r),e(t)})).catch((t=>{clearTimeout(r),o(t).then(e).catch(n)}))})):t(i,s).catch(o)}()}(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,handleTimeout:this.configuration.handleTimeout,beforeAttempt:e=>{this.shouldConnect&&!t||e.abort()}}).catch((t=>{if(t&&"ATTEMPT_ABORTED"!==t.code)throw t})),cancelFunc:()=>{t=!0}}})();return this.cancelWebsocketRetry=e,t}attachWebSocketListeners(t,e){const{identifier:s}=t;this.webSocketHandlers[s]={message:t=>this.emit("message",t),close:t=>this.emit("close",{event:t}),open:t=>this.emit("open",t),error:t=>{e(t)}};const i=this.webSocketHandlers[t.identifier];Object.keys(i).forEach((e=>{t.addEventListener(e,i[e])}))}cleanupWebSocket(){if(!this.webSocket)return;const{identifier:t}=this.webSocket,e=this.webSocketHandlers[t];Object.keys(e).forEach((s=>{var i;null===(i=this.webSocket)||void 0===i||i.removeEventListener(s,e[s]),delete this.webSocketHandlers[t]})),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise(((t,e)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;const s=new this.configuration.WebSocketPolyfill(this.url);s.binaryType="arraybuffer",s.identifier=this.identifier,this.attachWebSocketListeners(s,e),this.webSocket=s,this.status=ze.Connecting,this.emit("status",{status:ze.Connecting}),this.connectionAttempt={resolve:t,reject:e}}))}onMessage(t){var e;this.resolveConnectionAttempt(),this.lastMessageReceived=ce();const s=new we(t.data).peekVarString();null===(e=this.configuration.providerMap.get(s))||void 0===e||e.onMessage(t)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=ze.Connected,this.emit("status",{status:ze.Connected}),this.emit("connect"),this.messageQueue.forEach((t=>this.send(t))),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){var t;null===(t=this.connectionAttempt)||void 0===t||t.reject(),this.connectionAttempt=null}checkConnection(){var t;this.status===ze.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=ce()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:"forced"}}),this.closeTries=0):(null===(t=this.webSocket)||void 0===t||t.close(),this.messageQueue=[])))}get serverUrl(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let t=this.configuration.url;for(;"/"===t[t.length-1];)t=t.slice(0,t.length-1);return t}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,null!==this.webSocket)try{this.webSocket.close(),this.messageQueue=[]}catch(t){console.error(t)}}send(t){var e;(null===(e=this.webSocket)||void 0===e?void 0:e.readyState)===Ut.Open?this.webSocket.send(t):this.messageQueue.push(t)}onClose({event:t}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=ze.Disconnected,this.emit("status",{status:ze.Disconnected}),this.emit("disconnect",{event:t}),!this.cancelWebsocketRetry&&this.shouldConnect&&setTimeout((()=>{this.connect()}),this.configuration.delay)}destroy(){this.emit("destroy"),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}}const Se=(t,e,s)=>{try{S.applyUpdate(e,oe(t),s)}catch(t){console.error("Caught error while handling a Yjs update",t)}},xe=Se;class Ee{constructor(t){this.message=t}apply(t,e){const{message:s}=this,i=s.readVarUint(),n=s.length();switch(i){case ve.Sync:this.applySyncMessage(t,e);break;case ve.Awareness:this.applyAwarenessMessage(t);break;case ve.Auth:this.applyAuthMessage(t);break;case ve.QueryAwareness:this.applyQueryAwarenessMessage(t);break;case ve.Stateless:t.receiveStateless(he(s.decoder));break;case ve.SyncStatus:this.applySyncStatusMessage(t,1===(t=>{let e=t.arr[t.pos++],s=63&e,i=64;const n=(64&e)>0?-1:1;if(!(e&Wt))return n*s;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],s+=(e&Pt)*i,i*=128,e<Wt)return n*s;if(s>Vt)throw se}throw ee})(s.decoder));break;case ve.CLOSE:const n={code:1e3,reason:he(s.decoder),target:t.configuration.websocketProvider.webSocket,type:"close"};t.onClose(),t.configuration.onClose({event:n}),t.forwardClose({event:n});break;default:throw Error("Can’t apply message of unknown type: "+i)}s.length()>n+1&&t.send(Ce,{encoder:s.encoder})}applySyncMessage(t,e){const{message:s}=this;s.writeVarUint(ve.Sync);const i=((t,e,s,i)=>{const n=ae(t);switch(n){case 0:((t,e,s)=>{((t,e,s)=>{Qt(t,1),Zt(t,S.encodeStateAsUpdate(e,s))})(e,s,oe(t))})(t,e,s);break;case 1:Se(t,s,i);break;case 2:xe(t,s,i);break;default:throw Error("Unknown message type")}return n})(s.decoder,s.encoder,t.document,t);e&&1===i&&(t.synced=!0)}applySyncStatusMessage(t,e){e&&t.decrementUnsyncedChanges()}applyAwarenessMessage(t){if(!t.awareness)return;const{message:e}=this;((t,e,s)=>{const i=ne(e),n=ce(),o=[],r=[],a=[],h=[],c=ae(i);for(let e=0;e<c;e++){const e=ae(i);let s=ae(i);const c=JSON.parse(he(i)),l=t.meta.get(e),d=t.states.get(e),u=void 0===l?0:l.clock;(u<s||u===s&&null===c&&t.states.has(e))&&(null===c?e===t.clientID&&null!=t.getLocalState()?s++:t.states.delete(e):t.states.set(e,c),t.meta.set(e,{clock:s,lastUpdated:n}),void 0===l&&null!==c?o.push(e):void 0!==l&&null===c?h.push(e):null!==c&&(ge(c,d)||a.push(e),r.push(e)))}(o.length>0||a.length>0||h.length>0)&&t.emit("change",[{added:o,updated:a,removed:h},s]),(o.length>0||r.length>0||h.length>0)&&t.emit("update",[{added:o,updated:r,removed:h},s])})(t.awareness,e.readVarUint8Array(),t)}applyAuthMessage(t){const{message:e}=this;((t,e,s,i)=>{switch(Et(t)){case It.Token:e();break;case It.PermissionDenied:s(Tt(t));break;case It.Authenticated:i(Tt(t))}})(e.decoder,t.sendToken.bind(t),t.permissionDeniedHandler.bind(t),t.authenticatedHandler.bind(t))}applyQueryAwarenessMessage(t){if(!t.awareness)return;const{message:e}=this;e.writeVarUint(ve.Awareness),e.writeVarUint8Array(ye(t.awareness,Array.from(t.awareness.getStates().keys())))}}class Te{constructor(t,e={}){this.message=new t,this.encoder=this.message.get(e)}create(){return qt(this.encoder)}send(t){null==t||t.send(this.create())}}class Ie extends Ce{constructor(){super(...arguments),this.type=ve.Auth,this.description="Authentication"}get(t){if(void 0===t.token)throw Error("The authentication message requires `token` as an argument.");return Xt(this.encoder,t.documentName),Qt(this.encoder,this.type),((t,e)=>{kt(t,It.Token),zt(t,e)})(this.encoder,t.token),this.encoder}}class Oe extends Ce{constructor(){super(...arguments),this.type=ve.Awareness,this.description="Awareness states update"}get(t){if(void 0===t.awareness)throw Error("The awareness message requires awareness as an argument");if(void 0===t.clients)throw Error("The awareness message requires clients as an argument");let e;return Xt(this.encoder,t.documentName),Qt(this.encoder,this.type),e=void 0===t.states?ye(t.awareness,t.clients):ye(t.awareness,t.clients,t.states),Zt(this.encoder,e),this.encoder}}class Ue extends Ce{constructor(){super(...arguments),this.type=ve.Stateless,this.description="A stateless message"}get(t){var e;return Xt(this.encoder,t.documentName),Qt(this.encoder,this.type),Xt(this.encoder,null!==(e=t.payload)&&void 0!==e?e:""),this.encoder}}class Re extends Ce{constructor(){super(...arguments),this.type=ve.Sync,this.description="First sync step"}get(t){if(void 0===t.document)throw Error("The sync step one message requires document as an argument");return Xt(this.encoder,t.documentName),Qt(this.encoder,this.type),((t,e)=>{Qt(t,0);const s=S.encodeStateVector(e);Zt(t,s)})(this.encoder,t.document),this.encoder}}class De extends Ce{constructor(){super(...arguments),this.type=ve.Sync,this.description="A document update"}get(t){return Xt(this.encoder,t.documentName),Qt(this.encoder,this.type),((t,e)=>{Qt(t,2),Zt(t,e)})(this.encoder,t.update),this.encoder}}class Me extends Error{constructor(){super(...arguments),this.code=1001}}class We extends ke{constructor(t){var e,s,i;super(),this.configuration={name:"",document:void 0,awareness:void 0,token:null,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit("connect"),this.forwardStatus=t=>this.emit("status",t),this.forwardClose=t=>this.emit("close",t),this.forwardDisconnect=t=>this.emit("disconnect",t),this.forwardDestroy=()=>this.emit("destroy"),this.setConfiguration(t),this.configuration.document=t.document?t.document:new S.Doc,this.configuration.awareness=void 0!==t.awareness?t.awareness:new be(this.document),this.on("open",this.configuration.onOpen),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("synced",this.configuration.onSynced),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("stateless",this.configuration.onStateless),this.on("unsyncedChanges",this.configuration.onUnsyncedChanges),this.on("authenticated",this.configuration.onAuthenticated),this.on("authenticationFailed",this.configuration.onAuthenticationFailed),null===(e=this.awareness)||void 0===e||e.on("update",(()=>{this.emit("awarenessUpdate",{states:Ot(this.awareness.getStates())})})),null===(s=this.awareness)||void 0===s||s.on("change",(()=>{this.emit("awarenessChange",{states:Ot(this.awareness.getStates())})})),this.document.on("update",this.boundDocumentUpdateHandler),null===(i=this.awareness)||void 0===i||i.on("update",this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&"number"==typeof this.configuration.forceSyncInterval&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.manageSocket&&this.attach()}setConfiguration(t={}){t.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new Ae(t)),this.configuration={...this.configuration,...t}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit("unsyncedChanges",{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit("unsyncedChanges",{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&(this.unsyncedChanges-=1),0===this.unsyncedChanges&&(this.synced=!0),this.emit("unsyncedChanges",{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(Re,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&fe(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){"undefined"!=typeof window&&"addEventListener"in window&&window.addEventListener("pagehide",this.boundPageHide)}sendStateless(t){this.send(Ue,{documentName:this.configuration.name,payload:t})}async sendToken(){let t;try{t=await this.getToken()}catch(t){return void this.permissionDeniedHandler("Failed to get token during sendToken(): "+t)}this.send(Ie,{token:null!=t?t:"",documentName:this.configuration.name})}documentUpdateHandler(t,e){e!==this&&(this.incrementUnsyncedChanges(),this.send(De,{update:t,documentName:this.configuration.name}))}awarenessUpdateHandler({added:t,updated:e,removed:s},i){const n=t.concat(e).concat(s);this.send(Oe,{awareness:this.awareness,clients:n,documentName:this.configuration.name})}get synced(){return this.isSynced}set synced(t){this.isSynced!==t&&(this.isSynced=t,t&&this.emit("synced",{state:t}))}receiveStateless(t){this.emit("stateless",{payload:t})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn("HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.")}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn("HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.")}async onOpen(t){this.isAuthenticated=!1,this.emit("open",{event:t}),await this.sendToken(),this.startSync()}async getToken(){return"function"==typeof this.configuration.token?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(Re,{document:this.document,documentName:this.configuration.name}),this.awareness&&null!==this.awareness.getLocalState()&&this.send(Oe,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(t,e){if(!this._isAttached)return;const s=new Te(t,e);this.emit("outgoingMessage",{message:s.message}),s.send(this.configuration.websocketProvider)}onMessage(t){const e=new we(t.data),s=e.readVarString();e.writeVarString(s),this.emit("message",{event:t,message:new we(t.data)}),new Ee(e).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&fe(this.awareness,Array.from(this.awareness.getStates().keys()).filter((t=>t!==this.document.clientID)),this)}destroy(){this.emit("destroy"),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(fe(this.awareness,[this.document.clientID],"provider destroy"),this.awareness.off("update",this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off("update",this.boundDocumentUpdateHandler),this.removeAllListeners(),this.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),"undefined"!=typeof window&&"removeEventListener"in window&&window.removeEventListener("pagehide",this.boundPageHide)}detach(){this.configuration.websocketProvider.off("connect",this.configuration.onConnect),this.configuration.websocketProvider.off("connect",this.forwardConnect),this.configuration.websocketProvider.off("status",this.forwardStatus),this.configuration.websocketProvider.off("status",this.configuration.onStatus),this.configuration.websocketProvider.off("open",this.boundOnOpen),this.configuration.websocketProvider.off("close",this.boundOnClose),this.configuration.websocketProvider.off("close",this.configuration.onClose),this.configuration.websocketProvider.off("close",this.forwardClose),this.configuration.websocketProvider.off("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.off("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.off("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.off("destroy",this.forwardDestroy),this.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||(this.configuration.websocketProvider.on("connect",this.configuration.onConnect),this.configuration.websocketProvider.on("connect",this.forwardConnect),this.configuration.websocketProvider.on("status",this.configuration.onStatus),this.configuration.websocketProvider.on("status",this.forwardStatus),this.configuration.websocketProvider.on("open",this.boundOnOpen),this.configuration.websocketProvider.on("close",this.boundOnClose),this.configuration.websocketProvider.on("close",this.configuration.onClose),this.configuration.websocketProvider.on("close",this.forwardClose),this.configuration.websocketProvider.on("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.on("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.on("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.on("destroy",this.forwardDestroy),this.configuration.websocketProvider.attach(this),this._isAttached=!0)}permissionDeniedHandler(t){this.emit("authenticationFailed",{reason:t}),this.isAuthenticated=!1}authenticatedHandler(t){this.isAuthenticated=!0,this.authorizedScope=t,this.emit("authenticated",{scope:t})}setAwarenessField(t,e){if(!this.awareness)throw new Me(`Cannot set awareness field "${t}" to ${JSON.stringify(e)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(t,e)}}const Pe={type:"pen",color:j[0],size:16,palettes:{pen:[...j]}},Ve={color:j[0],size:8,fontFamily:"Arial",palette:[...j]},Be={color:j[0],size:4,palette:[...j],arrows:{end:{enabled:!0,style:"triangle"}}},Fe={shapeType:h.Rectangle,fillColor:{light:"transparent",dark:"transparent"},strokeColor:j[0],strokeWidth:4,fontColor:j[0],fontSize:16,fontFamily:"Arial",palette:[...j]},Le=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.isReady=s(this,"isReady"),this.activeWorkspaceChange=s(this,"activeWorkspaceChange"),this.objectsChange=s(this,"objectsChange"),this.objectsAdded=s(this,"objectsAdded"),this.objectsRemoved=s(this,"objectsRemoved"),this.objectsUpdated=s(this,"objectsUpdated"),this.undoStateChange=s(this,"undoStateChange"),this.themeChange=s(this,"themeChange"),this.viewportChange=s(this,"viewportChange"),this.logout=s(this,"logout"),this.login=s(this,"login"),this.isPublicChange=s(this,"isPublicChange"),this.awarenessChange=s(this,"awarenessChange")}get host(){return this}scaleMax=f;scaleMin=y;lockDrawingScale=!0;viewportBoundaryLeft=-1/0;viewportBoundaryRight=1/0;viewportBoundaryTop=-1/0;viewportBoundaryBottom=1/0;wheelEnabled=!0;debugInfo={showViewportInfo:!1,showObjectInfo:!1,showSyncProviderInfo:!0,showMigrationInfo:!0};user;activeUsers;controls=[{name:"selection",type:"tool",isDefault:!0,tool:c,icon:"cursor"},{name:"brush",type:"tool",tool:l,icon:"pen",config:Pe},{name:"eraser",type:"tool",tool:k,icon:"eraser"},{name:"line",type:"tool",tool:d,icon:"arrow",config:Be},{name:"shape",type:"tool",tool:u,icon:"shape-rectangle",config:Fe,subOptions:[{id:"rectangle",icon:"shape-rectangle",label:"Rectangle",value:h.Rectangle,toolProperty:"shapeType"},{id:"ellipse",icon:"shape-ellipse",label:"Ellipse",value:h.Ellipse,toolProperty:"shapeType"},{id:"triangle",icon:"shape-triangle",label:"Triangle",value:h.Triangle,toolProperty:"shapeType"}]},{name:"text",type:"tool",tool:p,icon:"type",config:Ve},{name:"image",type:"tool",tool:w,icon:"image"},{name:"config",type:"config"}];globalContextMenuItems=[{label:"Paste",icon:"paste",disabled:async()=>0===(await this.engineRef.getCopiedObjects()).length,action:t=>this.engineRef.paste(t.x,t.y)},{label:"Select All",icon:"select-all",disabled:async()=>0===(await this.engineRef.getObjectsInViewport()).length,action:()=>this.selectAllObjectsInViewport()}];objectContextMenuItems=[{label:"Copy",icon:"copy",group:"clipboard",action:()=>this.engineRef.copy()},{label:"Paste",icon:"paste",group:"clipboard",disabled:async()=>0===(await this.engineRef.getCopiedObjects()).length,action:t=>this.engineRef.paste(t.x,t.y)},{label:"Order",icon:"ordering",group:"other",children:[{label:"Bring to Front",icon:"bring-to-front",action:()=>this.engineRef.bringToFront()},{label:"Send to Back",icon:"send-to-back",action:()=>this.engineRef.sendToBack()},{label:"Move Up",icon:"arrow-up-from-dot",action:()=>this.engineRef.bringForward()},{label:"Move Down",icon:"arrow-down-from-dot",action:()=>this.engineRef.sendBackward()}]},{label:"Align",icon:"align",group:"other",disabled:async()=>(await this.engineRef.getSelectedObjects()).length<2,children:[{label:"Align Left",icon:"align-start-vertical",action:()=>this.engineRef.alignObjects(v.StartHorizontal)},{label:"Align Center Horizontally",icon:"align-center-horizontal",action:()=>this.engineRef.alignObjects(v.CenterHorizontal)},{label:"Align Right",icon:"align-end-vertical",action:()=>this.engineRef.alignObjects(v.EndHorizontal)},{label:"Align Top",icon:"align-start-horizontal",action:()=>this.engineRef.alignObjects(v.StartVertical)},{label:"Align Center Vertically",icon:"align-center-vertical",action:()=>this.engineRef.alignObjects(v.CenterVertical)},{label:"Align Bottom",icon:"align-end-horizontal",action:()=>this.engineRef.alignObjects(v.EndVertical)}]},{label:"Group",icon:"group",group:"other",children:[{label:"Group",icon:"group",disabled:async()=>(await this.engineRef.getSelectedObjects()).length<2,action:()=>this.engineRef.group()},{label:"Ungroup",icon:"ungroup",disabled:async()=>!(await this.engineRef.getSelectedObjects()).some((t=>"KritzelGroup"===t.__class__)),action:()=>this.engineRef.ungroup()}]},{label:"Export",icon:"download",group:"export",children:[{label:"Export as SVG",icon:"download",action:()=>this.engineRef.exportSelectedObjectsAsSvg()},{label:"Export as PNG",icon:"download",action:()=>this.engineRef.exportSelectedObjectsAsPng()}]},{label:"Delete",icon:"delete",group:"edit",action:()=>this.engineRef.delete()}];customSvgIcons={};isControlsVisible=!0;isUtilityPanelVisible=!0;syncConfig={providers:[z]};loginConfig;editorId;activeWorkspaceId;isReady;activeWorkspaceChange;objectsChange;objectsAdded;objectsRemoved;objectsUpdated;undoStateChange;themeChange;viewportChange;logout;login;isPublicChange;awarenessChange;isEngineReady=!1;isControlsReady=!1;isWorkspaceManagerReady=!1;workspaces=[];activeWorkspace;isVirtualKeyboardOpen=!1;undoState=null;isBackToContentButtonVisible=!1;currentTheme="light";shortcuts=[];currentIsPublic=!1;onIsEngineReady(t){t&&this.isControlsReady&&this.checkIsReady()}onIsControlsReady(t){t&&this.isEngineReady&&this.checkIsReady()}onWorkspacesChange(t){if(this.activeWorkspace){const e=t.find((t=>t.id===this.activeWorkspace.id));e&&e!==this.activeWorkspace&&(this.activeWorkspace=e)}if(this.activeWorkspaceId){const e=t.find((t=>t.id===this.activeWorkspaceId));e&&e!==this.activeWorkspace&&(this.activeWorkspace=e)}}onActiveWorkspaceChange(){this.updateCurrentIsPublic()}onActiveWorkspaceIdChange(t){if(!t)return;if(0===this.workspaces.length)return;const e=this.workspaces.find((e=>e.id===t));e?e!==this.activeWorkspace&&(this.activeWorkspace=e):console.warn("[KritzelEditor] No workspace found with ID: "+t)}onCurrentThemeChange(){setTimeout((()=>this.setOsSpecificCssVariables()),0)}onTouchStart(t){t.cancelable&&t.preventDefault()}async getObjectById(t){return this.engineRef.getObjectById(t)}async addObject(t){return this.engineRef.addObject(t)}async updateObject(t,e){return this.engineRef.updateObject(t,e)}async removeObject(t){return this.engineRef.removeObject(t)}async getSelectedObjects(){return this.engineRef.getSelectedObjects()}async selectObjects(t){return this.engineRef.selectObjects(t)}async selectAllObjectsInViewport(){return this.engineRef.selectAllObjectsInViewport()}async clearSelection(){this.engineRef.clearSelection()}async centerObjectInViewport(t){return this.engineRef.centerObjectInViewport(t)}async backToContent(){return this.engineRef.backToContent()}async centerAllObjects(t=!0){return this.engineRef.centerAllObjects(t)}async setViewport(t,e,s){return this.engineRef.setViewport(t,e,s)}async panTo(t,e){return this.engineRef.panTo(t,e)}async zoomTo(t,e,s){return this.engineRef.zoomTo(t,e,s)}async getViewport(){return this.engineRef.getViewport()}async screenToWorld(t,e){return this.engineRef.screenToWorld(t,e)}async worldToScreen(t,e){return this.engineRef.worldToScreen(t,e)}async createWorkspace(t){return this.engineRef.createWorkspace(t)}async updateWorkspace(t){return this.engineRef.updateWorkspace(t)}async deleteWorkspace(t){return this.engineRef.deleteWorkspace(t)}async getWorkspaces(){return this.engineRef.getWorkspaces()}async getActiveWorkspace(){return this.engineRef.getActiveWorkspace()}async loadSharedWorkspace(t){return this.engineRef.loadSharedWorkspace(t)}async reinitSync(){return this.engineRef.reinitSync()}async registerTool(t,e,s){return this.engineRef.registerTool(t,e,s)}async changeActiveTool(t){return this.engineRef.changeActiveTool(t)}async disable(){return this.engineRef.disable()}async enable(){return this.engineRef.enable()}async copy(){return this.engineRef.copy()}async paste(t,e){return this.engineRef.paste(t,e)}async delete(){return this.engineRef.delete()}async bringForward(t){return this.engineRef.bringForward(t)}async sendBackward(t){return this.engineRef.sendBackward(t)}async bringToFront(t){return this.engineRef.bringToFront(t)}async sendToBack(t){return this.engineRef.sendToBack(t)}async alignObjects(t){return this.engineRef.alignObjects(t)}async group(){return this.engineRef.group()}async ungroup(){return this.engineRef.ungroup()}async undo(){return this.engineRef.undo()}async redo(){return this.engineRef.redo()}async getScreenshot(t="png"){return this.engineRef.getScreenshot(t)}async exportViewportAsPng(){return this.engineRef.exportViewportAsPng()}async exportViewportAsSvg(){return this.engineRef.exportViewportAsSvg()}async downloadAsJson(t){return this.engineRef.downloadAsJson(t)}async importFromFile(){return this.engineRef.importFromFile()}async loadObjectsFromJson(t){return this.engineRef.loadObjectsFromJson(t)}async getObjectsTotalCount(){return this.engineRef.getObjectsTotalCount()}async getAllObjects(){return this.engineRef.getAllObjects()}async findObjects(t){return this.engineRef.findObjects(t)}async getCopiedObjects(){return this.engineRef.getCopiedObjects()}async getObjectsInViewport(){return this.engineRef.getObjectsInViewport()}async hideContextMenu(){return this.engineRef.hideContextMenu()}async triggerSelectionChange(){return this.engineRef.triggerSelectionChange()}async getDisplayableShortcuts(){return this.engineRef.getDisplayableShortcuts()}engineRef;controlsRef;settingsRef;exportRef;splitButtonRef;shareDialogRef;loginDialogRef;componentWillLoad(){this.loadSettingsFromStorage()}componentDidLoad(){this.registerCustomSvgIcons(),this.listenForMobileKeyboard(),this.setOsSpecificCssVariables()}async checkIsReady(){if(await customElements.whenDefined("kritzel-editor"),await customElements.whenDefined("kritzel-workspace-manager"),await customElements.whenDefined("kritzel-controls"),await customElements.whenDefined("kritzel-engine"),!this.isEngineReady||!this.isControlsReady||!this.isWorkspaceManagerReady)return;const{id:t,name:e,isPublic:s,createdAt:i,updatedAt:n}=this.activeWorkspace;this.isReady.emit({host:this.host,activeWorkspace:{id:t,name:e,isPublic:s,createdAt:i,updatedAt:n},syncConfig:this.syncConfig,loginConfig:this.loginConfig})}async onEngineReady(t){this.isEngineReady=!0,this.activeWorkspace=t.detail.activeWorkspace,this.workspaces=t.detail.workspaces,this.currentIsPublic=await this.engineRef.getIsPublic(),this.loadShortcuts()}handleWorkspacesChange(t){this.workspaces=t.detail}handleActiveWorkspaceChange(t){if(t.stopPropagation(),this.activeWorkspace=t.detail,!this.isEngineReady)return;const{id:e,name:s,isPublic:i,createdAt:n,updatedAt:o}=this.activeWorkspace;this.activeWorkspaceChange.emit({id:e,name:s,isPublic:i,createdAt:n,updatedAt:o})}handleObjectsChange(t){this.objectsChange.emit(t.detail)}handleObjectsAdded(t){this.objectsAdded.emit(t.detail)}handleObjectsRemoved(t){this.objectsRemoved.emit(t.detail)}handleObjectsUpdated(t){this.objectsUpdated.emit(t.detail)}handleUndoStateChange(t){this.undoStateChange.emit(t.detail),this.undoState=t.detail}async handleObjectsInViewportChange(t){const e=this.getContentObjects(t.detail).length>0,s=this.getContentObjects(await this.engineRef.getAllObjects()).length>0;this.isBackToContentButtonVisible=!e&&s}handleViewportChange(t){this.viewportChange.emit(t.detail)}handleAwarenessChange(t){this.awarenessChange.emit(t.detail)}handleSettingsChange(t){this.scaleMin=t.detail.scaleMin,this.scaleMax=t.detail.scaleMax,this.lockDrawingScale=t.detail.lockDrawingScale,this.currentTheme=t.detail.theme,this.viewportBoundaryLeft=t.detail.viewportBoundaryLeft??-1/0,this.viewportBoundaryRight=t.detail.viewportBoundaryRight??1/0,this.viewportBoundaryTop=t.detail.viewportBoundaryTop??-1/0,this.viewportBoundaryBottom=t.detail.viewportBoundaryBottom??1/0,this.debugInfo=t.detail.debugInfo,this.themeChange.emit(t.detail.theme)}get moreMenuItems(){return[{id:"share",label:"Share",icon:"share",action:()=>{this.isLoggedIn||!this.loginConfig?this.shareDialogRef.open():this.openLoginDialog()}},{id:"export",label:"Export",icon:"upload",action:async()=>{const t=await this.engineRef.getScreenshot("png");this.exportRef.open(t)}},{id:"import",label:"Import",icon:"download",action:()=>this.engineRef.importFromFile()},{id:"settings",label:"Settings",icon:"settings",action:()=>this.settingsRef.open()},{id:"logout",label:"Logout",icon:"log-out",color:"#ff3b30",isVisible:this.isLoggedIn,action:()=>this.logout.emit()}]}handleToggleIsPublic=async t=>{const e=t.detail,s=await this.engineRef.getActiveWorkspace();s.isPublic=e,await this.engineRef.updateWorkspace(s),this.activeWorkspace=s.clone(),this.isPublicChange.emit({isPublic:e,workspaceId:this.activeWorkspace?.id})};updateCurrentIsPublic(){const t=this.activeWorkspace?.isPublic??!1,e=this.activeWorkspace?.id;this.currentIsPublic=t,this.isPublicChange.emit({isPublic:t,workspaceId:e})}handleProviderLogin=t=>{this.login.emit(t.detail)};get isLoggedIn(){return!!this.user&&!this.user.isGuest}async openLoginDialog(){this.loginDialogRef?.open()}async setLoginLoading(t){this.loginDialogRef?.setLoading(t)}getSettingsStorageKey(){return this.editorId?"kritzel-settings-"+this.editorId:"kritzel-settings"}loadSettingsFromStorage(){const t=localStorage.getItem(this.getSettingsStorageKey());if(t)try{const e=JSON.parse(t);"number"==typeof e.scaleMin&&(this.scaleMin=e.scaleMin),"number"==typeof e.scaleMax&&(this.scaleMax=e.scaleMax),"boolean"==typeof e.lockDrawingScale&&(this.lockDrawingScale=e.lockDrawingScale),"light"!==e.theme&&"dark"!==e.theme||(this.currentTheme=e.theme),"number"==typeof e.viewportBoundaryLeft&&(this.viewportBoundaryLeft=e.viewportBoundaryLeft),"number"==typeof e.viewportBoundaryRight&&(this.viewportBoundaryRight=e.viewportBoundaryRight),"number"==typeof e.viewportBoundaryTop&&(this.viewportBoundaryTop=e.viewportBoundaryTop),"number"==typeof e.viewportBoundaryBottom&&(this.viewportBoundaryBottom=e.viewportBoundaryBottom),e.debugInfo&&(this.debugInfo={...this.debugInfo,...e.debugInfo})}catch{}}async loadShortcuts(){this.shortcuts=await this.engineRef.getDisplayableShortcuts()}getContentObjects(t){return t.filter((t=>!(t instanceof m||t instanceof g)))}registerCustomSvgIcons(){for(const[t,e]of Object.entries(this.customSvgIcons))r.register(t,e)}listenForMobileKeyboard(){b.onKeyboardVisibleChanged((t=>{this.isVirtualKeyboardOpen=t}))}setOsSpecificCssVariables(){switch(A.detectOS()){case"iOS":this.host.style.setProperty("--kritzel-editor-top-left-buttons-top","14px"),this.host.style.setProperty("--kritzel-editor-top-left-buttons-left","14px"),this.host.style.setProperty("--kritzel-editor-controls-bottom","14px"),this.host.style.setProperty("--kritzel-editor-controls-transition","cubic-bezier(0.25, 0.1, 0.25, 1.0)"),this.host.style.setProperty("--kritzel-editor-controls-transform","translateY(200%)"),this.host.style.setProperty("--kritzel-editor-controls-transition-duration","0.25s");break;case"Android":this.host.style.setProperty("--kritzel-editor-top-left-buttons-top","14px"),this.host.style.setProperty("--kritzel-editor-top-left-buttons-left","14px"),this.host.style.setProperty("--kritzel-editor-controls-bottom","24px"),this.host.style.setProperty("--kritzel-editor-controls-transition","cubic-bezier(0.25, 0.1, 0.25, 1.0)"),this.host.style.setProperty("--kritzel-editor-controls-transform","translateY(200%)"),this.host.style.setProperty("--kritzel-editor-controls-transition-duration","0.25s");break;default:this.host.style.setProperty("--kritzel-editor-top-left-buttons-top","14px"),this.host.style.setProperty("--kritzel-editor-top-left-buttons-left","14px"),this.host.style.setProperty("--kritzel-editor-controls-bottom","14px")}}render(){const t=this.isLoggedIn,e=t,s=!!this.loginConfig&&!t;return i(n,{key:"d1944655652eb2939e3696ed70050baaca0871e2"},i("div",{key:"ce5dfd9b8f8d9927e9a6ace4056f9053163c7e0a",class:"top-left-buttons"},i("kritzel-workspace-manager",{key:"e127a667c6e4e853bb4f0c9ffd0edaa6d80d9dfa",workspaces:this.workspaces,activeWorkspace:this.activeWorkspace,onWorkspaceChange:t=>this.activeWorkspace=t.detail,onIsWorkspaceManagerReady:()=>this.isWorkspaceManagerReady=!0}),i("kritzel-back-to-content",{key:"a9abb378f3c79f356d2164cbddf6badba10188a8",visible:this.isBackToContentButtonVisible,onBackToContent:()=>this.backToContent()})),i("kritzel-engine",{key:"c5f764580f3623eeb9381e54769a891a48c04620",ref:t=>this.engineRef=t,workspace:this.activeWorkspace,activeWorkspaceId:this.activeWorkspaceId,editorId:this.editorId,syncConfig:this.syncConfig,user:this.user,scaleMax:this.scaleMax,lockDrawingScale:this.lockDrawingScale,scaleMin:this.scaleMin,viewportBoundaryLeft:this.viewportBoundaryLeft,viewportBoundaryRight:this.viewportBoundaryRight,viewportBoundaryTop:this.viewportBoundaryTop,viewportBoundaryBottom:this.viewportBoundaryBottom,wheelEnabled:this.wheelEnabled,theme:this.currentTheme,debugInfo:this.debugInfo,globalContextMenuItems:this.globalContextMenuItems,objectContextMenuItems:this.objectContextMenuItems,onIsEngineReady:t=>this.onEngineReady(t),onWorkspacesChange:t=>this.handleWorkspacesChange(t),onActiveWorkspaceChange:t=>this.handleActiveWorkspaceChange(t),onObjectsChange:t=>this.handleObjectsChange(t),onObjectsAdded:t=>this.handleObjectsAdded(t),onObjectsRemoved:t=>this.handleObjectsRemoved(t),onObjectsUpdated:t=>this.handleObjectsUpdated(t),onUndoStateChange:t=>this.handleUndoStateChange(t),onObjectsInViewportChange:t=>this.handleObjectsInViewportChange(t),onViewportChange:t=>this.handleViewportChange(t),onAwarenessChange:t=>this.handleAwarenessChange(t)}),i("kritzel-controls",{key:"2479b6979d5b2b6c55a873bd1d8468b5fd967f72",class:{"keyboard-open":this.isVirtualKeyboardOpen},style:{display:this.isControlsVisible?"flex":"none"},ref:t=>this.controlsRef=t,controls:this.controls,isUtilityPanelVisible:this.isUtilityPanelVisible,undoState:this.undoState,theme:this.currentTheme,onIsControlsReady:()=>this.isControlsReady=!0}),i("div",{key:"ec6ac72ba154abe0738259464f20cae9e7dbdd9e",class:"top-right-buttons"},i("kritzel-settings",{key:"f68f791d673b30331e55f358b9c71b3e2a9a8388",ref:t=>this.settingsRef=t,shortcuts:this.shortcuts,editorId:this.editorId,onSettingsChange:t=>this.handleSettingsChange(t)}),i("kritzel-export",{key:"dfe5a051caccee504df4f347705303fa1f812556",ref:t=>this.exportRef=t,workspaceName:this.activeWorkspace?.name||"workspace",onExportPng:()=>this.engineRef.exportViewportAsPng(),onExportSvg:()=>this.engineRef.exportViewportAsSvg(),onExportJson:t=>this.engineRef.downloadAsJson(t.detail)}),i("kritzel-active-users",{key:"48983a14d3902cd238cf0d9ed302ed561a655a9a",users:this.activeUsers}),e&&i("kritzel-current-user",{key:"589bdc895741a2d17f60c4b549d14fe8fff74c17",user:this.user}),s&&i("kritzel-button",{key:"50414a9d7ade623678c767ce63c49f5e99336bed",onButtonClick:()=>this.loginDialogRef?.open()},"Sign in"),i("kritzel-more-menu",{key:"db3069ee0b093acd238750df81c6f426139c9b87",items:this.moreMenuItems}),i("kritzel-share-dialog",{key:"e16057838f00b2c3f239e794b4310bd2690d16e2",ref:t=>this.shareDialogRef=t,isPublic:this.currentIsPublic,workspaceId:this.activeWorkspace?.id,onToggleIsPublic:this.handleToggleIsPublic}),this.loginConfig&&i("kritzel-login-dialog",{key:"a6d1fc06c983542c6af95e7bb4b2b2d522a03605",ref:t=>this.loginDialogRef=t,providers:this.loginConfig.providers,dialogTitle:this.loginConfig.title,subtitle:this.loginConfig.subtitle,onProviderLogin:this.handleProviderLogin})))}static get watchers(){return{isEngineReady:[{onIsEngineReady:0}],isControlsReady:[{onIsControlsReady:0}],workspaces:[{onWorkspacesChange:0}],activeWorkspace:[{onActiveWorkspaceChange:0}],activeWorkspaceId:[{onActiveWorkspaceIdChange:0}],currentTheme:[{onCurrentThemeChange:0}]}}static get style(){return"kritzel-editor{display:flex;margin:0;position:relative;overflow:hidden;width:100%;height:100%;align-items:center;justify-content:center;touch-action:manipulation;user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}kritzel-controls{position:absolute;bottom:var(--kritzel-editor-controls-bottom, 14px);transition:transform var(--kritzel-editor-controls-transition-duration, 0.1s) var(--kritzel-editor-controls-transition, ease-in-out)}kritzel-controls.keyboard-open{transform:var(--kritzel-editor-controls-transform, translateY(300%))}.top-left-buttons{position:absolute;top:var(--kritzel-editor-top-left-buttons-top, 14px);left:var(--kritzel-editor-top-left-buttons-left, 14px);display:flex;align-items:flex-start;gap:8px}.top-right-buttons{position:absolute;top:var(--kritzel-editor-top-right-buttons-top, 14px);right:var(--kritzel-editor-top-right-buttons-right, 14px);display:flex;align-items:center;gap:8px}.top-right-button{display:flex;align-items:center;justify-content:center;width:50px;height:50px;padding:0;border:var(--kritzel-split-button-border, 1px solid #ebebeb);border-radius:var(--kritzel-split-button-border-radius, 12px);background-color:var(--kritzel-split-button-background-color, #ffffff);cursor:var(--kritzel-global-pointer-cursor, pointer);box-shadow:var(--kritzel-split-button-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));transition:background-color 150ms ease;-webkit-tap-highlight-color:transparent}.top-right-button:hover{background-color:#f5f5f5}.top-right-button:active{background-color:#ebebeb}"}},[512,"kritzel-editor",{scaleMax:[1026,"scale-max"],scaleMin:[1026,"scale-min"],lockDrawingScale:[1028,"lock-drawing-scale"],viewportBoundaryLeft:[1026,"viewport-boundary-left"],viewportBoundaryRight:[1026,"viewport-boundary-right"],viewportBoundaryTop:[1026,"viewport-boundary-top"],viewportBoundaryBottom:[1026,"viewport-boundary-bottom"],wheelEnabled:[1028,"wheel-enabled"],debugInfo:[1040],user:[16],activeUsers:[16],controls:[16],globalContextMenuItems:[16],objectContextMenuItems:[16],customSvgIcons:[16],isControlsVisible:[4,"is-controls-visible"],isUtilityPanelVisible:[4,"is-utility-panel-visible"],syncConfig:[16],loginConfig:[16],editorId:[1,"editor-id"],activeWorkspaceId:[1,"active-workspace-id"],isEngineReady:[32],isControlsReady:[32],isWorkspaceManagerReady:[32],workspaces:[32],activeWorkspace:[32],isVirtualKeyboardOpen:[32],undoState:[32],isBackToContentButtonVisible:[32],currentTheme:[32],shortcuts:[32],currentIsPublic:[32],getObjectById:[64],addObject:[64],updateObject:[64],removeObject:[64],getSelectedObjects:[64],selectObjects:[64],selectAllObjectsInViewport:[64],clearSelection:[64],centerObjectInViewport:[64],backToContent:[64],centerAllObjects:[64],setViewport:[64],panTo:[64],zoomTo:[64],getViewport:[64],screenToWorld:[64],worldToScreen:[64],createWorkspace:[64],updateWorkspace:[64],deleteWorkspace:[64],getWorkspaces:[64],getActiveWorkspace:[64],loadSharedWorkspace:[64],reinitSync:[64],registerTool:[64],changeActiveTool:[64],disable:[64],enable:[64],copy:[64],paste:[64],delete:[64],bringForward:[64],sendBackward:[64],bringToFront:[64],sendToBack:[64],alignObjects:[64],group:[64],ungroup:[64],undo:[64],redo:[64],getScreenshot:[64],exportViewportAsPng:[64],exportViewportAsSvg:[64],downloadAsJson:[64],importFromFile:[64],loadObjectsFromJson:[64],getObjectsTotalCount:[64],getAllObjects:[64],findObjects:[64],getCopiedObjects:[64],getObjectsInViewport:[64],hideContextMenu:[64],triggerSelectionChange:[64],getDisplayableShortcuts:[64],openLoginDialog:[64],setLoginLoading:[64]},[[0,"dblclick","onTouchStart"]],{isEngineReady:[{onIsEngineReady:0}],isControlsReady:[{onIsControlsReady:0}],workspaces:[{onWorkspacesChange:0}],activeWorkspace:[{onActiveWorkspaceChange:0}],activeWorkspaceId:[{onActiveWorkspaceIdChange:0}],currentTheme:[{onCurrentThemeChange:0}]}]),Ne=Le,Je=function(){"undefined"!=typeof customElements&&["kritzel-editor","kritzel-active-users","kritzel-avatar","kritzel-awareness-cursors","kritzel-back-to-content","kritzel-button","kritzel-color","kritzel-color-palette","kritzel-context-menu","kritzel-controls","kritzel-current-user","kritzel-current-user-dialog","kritzel-cursor-trail","kritzel-dialog","kritzel-dropdown","kritzel-engine","kritzel-export","kritzel-font","kritzel-font-family","kritzel-font-size","kritzel-icon","kritzel-input","kritzel-line-endings","kritzel-login-dialog","kritzel-master-detail","kritzel-menu","kritzel-menu-item","kritzel-more-menu","kritzel-numeric-input","kritzel-opacity-slider","kritzel-pill-tabs","kritzel-portal","kritzel-settings","kritzel-shape-fill","kritzel-share-dialog","kritzel-slide-toggle","kritzel-split-button","kritzel-stroke-size","kritzel-tool-config","kritzel-tooltip","kritzel-utility-panel","kritzel-workspace-manager"].forEach((t=>{switch(t){case"kritzel-editor":customElements.get(o(t))||customElements.define(o(t),Le);break;case"kritzel-active-users":customElements.get(o(t))||x();break;case"kritzel-avatar":customElements.get(o(t))||E();break;case"kritzel-awareness-cursors":customElements.get(o(t))||T();break;case"kritzel-back-to-content":customElements.get(o(t))||I();break;case"kritzel-button":customElements.get(o(t))||O();break;case"kritzel-color":customElements.get(o(t))||U();break;case"kritzel-color-palette":customElements.get(o(t))||R();break;case"kritzel-context-menu":customElements.get(o(t))||D();break;case"kritzel-controls":customElements.get(o(t))||M();break;case"kritzel-current-user":customElements.get(o(t))||W();break;case"kritzel-current-user-dialog":customElements.get(o(t))||P();break;case"kritzel-cursor-trail":customElements.get(o(t))||V();break;case"kritzel-dialog":customElements.get(o(t))||B();break;case"kritzel-dropdown":customElements.get(o(t))||F();break;case"kritzel-engine":customElements.get(o(t))||C();break;case"kritzel-export":customElements.get(o(t))||L();break;case"kritzel-font":customElements.get(o(t))||N();break;case"kritzel-font-family":customElements.get(o(t))||J();break;case"kritzel-font-size":customElements.get(o(t))||G();break;case"kritzel-icon":customElements.get(o(t))||a();break;case"kritzel-input":customElements.get(o(t))||H();break;case"kritzel-line-endings":customElements.get(o(t))||K();break;case"kritzel-login-dialog":customElements.get(o(t))||q();break;case"kritzel-master-detail":customElements.get(o(t))||Y();break;case"kritzel-menu":customElements.get(o(t))||$();break;case"kritzel-menu-item":customElements.get(o(t))||Q();break;case"kritzel-more-menu":customElements.get(o(t))||_();break;case"kritzel-numeric-input":customElements.get(o(t))||X();break;case"kritzel-opacity-slider":customElements.get(o(t))||Z();break;case"kritzel-pill-tabs":customElements.get(o(t))||tt();break;case"kritzel-portal":customElements.get(o(t))||et();break;case"kritzel-settings":customElements.get(o(t))||st();break;case"kritzel-shape-fill":customElements.get(o(t))||it();break;case"kritzel-share-dialog":customElements.get(o(t))||nt();break;case"kritzel-slide-toggle":customElements.get(o(t))||ot();break;case"kritzel-split-button":customElements.get(o(t))||rt();break;case"kritzel-stroke-size":customElements.get(o(t))||at();break;case"kritzel-tool-config":customElements.get(o(t))||ht();break;case"kritzel-tooltip":customElements.get(o(t))||ct();break;case"kritzel-utility-panel":customElements.get(o(t))||lt();break;case"kritzel-workspace-manager":customElements.get(o(t))||dt()}}))};export{Pe as D,We as H,Ne as KritzelEditor,Ae as a,Ve as b,Be as c,Je as defineCustomElement}
|
|
1
|
+
import{p as t,H as e,c as s,h as i,d as n,t as o}from"./p-CGGiwvWZ.js";import{K as r,d as a}from"./p-DxzDda_J.js";import{S as c,h,d as l,e as d,g as u,f as p,i as m,j as g,k as b}from"./p-pGzF7PUB.js";import{e as f,f as y,K as k,a as w,d as v,I as z,g as C}from"./p-Ban3OlgZ.js";import{D as S}from"./p-CjazGGq3.js";import{K as j}from"./p-jGOpkGDl.js";import"./p-DXpYcAnT.js";import*as A from"yjs";import"y-websocket";import{d as E}from"./p-76W5pG2O.js";import{d as x}from"./p-BueaqfA2.js";import{d as T}from"./p-CHY71o5B.js";import{d as I}from"./p-CBslLN3-.js";import{d as O}from"./p-6NFl6EB2.js";import{d as U}from"./p-ZC5YELQJ.js";import{d as W}from"./p-D5IhryUR.js";import{d as D}from"./p-KJ4dHzrS.js";import{d as M}from"./p-CN8IxBlU.js";import{d as R}from"./p-D3pNw-SV.js";import{d as B}from"./p-CYh7yV-K.js";import{d as P}from"./p-C2l9mZ1P.js";import{d as V}from"./p-53di1Zko.js";import{d as L}from"./p-l_YGO7RB.js";import{d as F}from"./p-BLsH_Oi0.js";import{d as N}from"./p-DDKjsXCe.js";import{d as H}from"./p-DV7Z_qfa.js";import{d as G}from"./p-D7yzmu1l.js";import{d as K}from"./p-D14QNK3X.js";import{d as J}from"./p-Md9Y-b3d.js";import{d as Y}from"./p-gtQlsorg.js";import{d as q}from"./p-DkWWzVg8.js";import{d as _,a as Q}from"./p-CI9Nbh-x.js";import{d as Z}from"./p-Cns7qSKS.js";import{d as $}from"./p-DWsCbu01.js";import{d as X}from"./p-ZQ2bKafG.js";import{d as tt}from"./p-BrZ_gL8Q.js";import{d as et}from"./p-Dr3-pKVg.js";import{d as st}from"./p-DaGZEV0R.js";import{d as it}from"./p-Dte67BWd.js";import{d as nt}from"./p-C4fKLlrd.js";import{d as ot}from"./p-Ck1dhpUQ.js";import{d as rt}from"./p-pCC6t6BH.js";import{d as at}from"./p-Lhyh6KeB.js";import{d as ct}from"./p-CWMFGEe0.js";import{d as ht}from"./p-BuI6Gkzg.js";import{d as lt}from"./p-m1nVDC3G.js";import{d as dt}from"./p-_QEHfsIk.js";const ut=Math.floor,pt=127,mt=Number.MAX_SAFE_INTEGER,gt="undefined"!=typeof TextEncoder?new TextEncoder:null,bt=gt?t=>gt.encode(t):t=>{const e=unescape(encodeURIComponent(t)),s=e.length,i=new Uint8Array(s);for(let t=0;t<s;t++)i[t]=e.codePointAt(t);return i};let ft="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});ft&&1===ft.decode(new Uint8Array).length&&(ft=null);const yt=(t,e)=>{const s=t.cbuf.length;t.cpos===s&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(2*s),t.cpos=0),t.cbuf[t.cpos++]=e},kt=(t,e)=>{for(;e>pt;)yt(t,128|pt&e),e=ut(e/128);yt(t,pt&e)},wt=new Uint8Array(3e4),vt=wt.length/3,zt=gt&>.encodeInto?(t,e)=>{if(e.length<vt){const s=gt.encodeInto(e,wt).written||0;kt(t,s);for(let e=0;e<s;e++)yt(t,wt[e])}else Ct(t,bt(e))}:(t,e)=>{const s=unescape(encodeURIComponent(e)),i=s.length;kt(t,i);for(let e=0;e<i;e++)yt(t,s.codePointAt(e))},Ct=(t,e)=>{kt(t,e.byteLength),((t,e)=>{const s=t.cbuf.length,i=t.cpos,n=((t,e)=>t<e?t:e)(s-i,e.length),o=e.length-n;t.cbuf.set(e.subarray(0,n),i),t.cpos+=n,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(((t,e)=>t>e?t:e)(2*s,o)),t.cbuf.set(e.subarray(n)),t.cpos=o)})(t,e)},St=t=>Error(t),jt=St("Unexpected end of array"),At=St("Integer out of Range"),Et=t=>t.arr[t.pos++],xt=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&pt)*s,s*=128,i<128)return e;if(e>mt)throw At}throw jt},Tt=ft?t=>ft.decode((t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,xt(t)))(t)):t=>{let e=xt(t);if(0===e)return"";{let s=String.fromCodePoint(Et(t));if(--e<100)for(;e--;)s+=String.fromCodePoint(Et(t));else for(;e>0;){const i=e<1e4?e:1e4,n=t.arr.subarray(t.pos,t.pos+i);t.pos+=i,s+=String.fromCodePoint.apply(null,n),e-=i}return decodeURIComponent(escape(s))}};var It;!function(t){t[t.Token=0]="Token",t[t.PermissionDenied=1]="PermissionDenied",t[t.Authenticated=2]="Authenticated"}(It||(It={}));const Ot=t=>Array.from(t.entries()).map((([t,e])=>({clientId:t,...e})));var Ut;async function Wt(t){return new Promise((e=>setTimeout(e,t)))}function Dt(t,e){let s=e.delay;if(0===s)return 0;if(e.factor&&(s*=Math.pow(e.factor,t.attemptNum-1),0!==e.maxDelay&&(s=Math.min(s,e.maxDelay))),e.jitter){const t=Math.ceil(e.minDelay),i=Math.floor(s);s=Math.floor(Math.random()*(i-t+1))+t}return Math.round(s)}!function(t){t[t.Connecting=0]="Connecting",t[t.Open=1]="Open",t[t.Closing=2]="Closing",t[t.Closed=3]="Closed"}(Ut||(Ut={}));const Mt=Math.floor,Rt=128,Bt=127,Pt=Number.MAX_SAFE_INTEGER,Vt=()=>new Set,Lt=Array.from,Ft="undefined"!=typeof TextEncoder?new TextEncoder:null,Nt=Ft?t=>Ft.encode(t):t=>{const e=unescape(encodeURIComponent(t)),s=e.length,i=new Uint8Array(s);for(let t=0;t<s;t++)i[t]=e.codePointAt(t);return i};let Ht="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Ht&&1===Ht.decode(new Uint8Array).length&&(Ht=null);class Gt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Kt=()=>new Gt,Jt=t=>{let e=t.cpos;for(let s=0;s<t.bufs.length;s++)e+=t.bufs[s].length;return e},Yt=t=>{const e=new Uint8Array(Jt(t));let s=0;for(let i=0;i<t.bufs.length;i++){const n=t.bufs[i];e.set(n,s),s+=n.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),s),e},qt=(t,e)=>{const s=t.cbuf.length;t.cpos===s&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(2*s),t.cpos=0),t.cbuf[t.cpos++]=e},_t=(t,e)=>{for(;e>Bt;)qt(t,Rt|Bt&e),e=Mt(e/128);qt(t,Bt&e)},Qt=new Uint8Array(3e4),Zt=Qt.length/3,$t=Ft&&Ft.encodeInto?(t,e)=>{if(e.length<Zt){const s=Ft.encodeInto(e,Qt).written||0;_t(t,s);for(let e=0;e<s;e++)qt(t,Qt[e])}else Xt(t,Nt(e))}:(t,e)=>{const s=unescape(encodeURIComponent(e)),i=s.length;_t(t,i);for(let e=0;e<i;e++)qt(t,s.codePointAt(e))},Xt=(t,e)=>{_t(t,e.byteLength),((t,e)=>{const s=t.cbuf.length,i=t.cpos,n=((t,e)=>t<e?t:e)(s-i,e.length),o=e.length-n;t.cbuf.set(e.subarray(0,n),i),t.cpos+=n,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(((t,e)=>t>e?t:e)(2*s,o)),t.cbuf.set(e.subarray(n)),t.cpos=o)})(t,e)},te=t=>Error(t),ee=te("Unexpected end of array"),se=te("Integer out of Range");class ie{constructor(t){this.arr=t,this.pos=0}}const ne=t=>new ie(t),oe=t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,ae(t)),re=t=>t.arr[t.pos++],ae=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&Bt)*s,s*=128,i<Rt)return e;if(e>Pt)throw se}throw ee},ce=Ht?t=>Ht.decode(oe(t)):t=>{let e=ae(t);if(0===e)return"";{let s=String.fromCodePoint(re(t));if(--e<100)for(;e--;)s+=String.fromCodePoint(re(t));else for(;e>0;){const i=e<1e4?e:1e4,n=t.arr.subarray(t.pos,t.pos+i);t.pos+=i,s+=String.fromCodePoint.apply(null,n),e-=i}return decodeURIComponent(escape(s))}},he=Date.now,le=()=>new Map;class de{constructor(){this._observers=le()}on(t,e){((t,e,s)=>{let i=t.get(e);return void 0===i&&t.set(e,i=s()),i})(this._observers,t,Vt).add(e)}once(t,e){const s=(...i)=>{this.off(t,s),e(...i)};this.on(t,s)}off(t,e){const s=this._observers.get(t);void 0!==s&&(s.delete(e),0===s.size&&this._observers.delete(t))}emit(t,e){return Lt((this._observers.get(t)||le()).values()).forEach((t=>t(...e)))}destroy(){this._observers=le()}}const ue=Object.keys,pe=t=>ue(t).length,me=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),ge=(t,e)=>{if(null==t||null==e)return((t,e)=>t===e)(t,e);if(t.constructor!==e.constructor)return!1;if(t===e)return!0;switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:if(t.byteLength!==e.byteLength)return!1;for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;break;case Set:if(t.size!==e.size)return!1;for(const s of t)if(!e.has(s))return!1;break;case Map:if(t.size!==e.size)return!1;for(const s of t.keys())if(!e.has(s)||!ge(t.get(s),e.get(s)))return!1;break;case Object:if(pe(t)!==pe(e))return!1;for(const s in t)if(!me(t,s)||!ge(t[s],e[s]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(!ge(t[s],e[s]))return!1;break;default:return!1}return!0};class be extends de{constructor(t){super(),this.doc=t,this.clientID=t.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval((()=>{const t=he();null!==this.getLocalState()&&15e3<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const e=[];this.meta.forEach(((s,i)=>{i!==this.clientID&&3e4<=t-s.lastUpdated&&this.states.has(i)&&e.push(i)})),e.length>0&&fe(this,e,"timeout")}),Mt(3e3)),t.on("destroy",(()=>{this.destroy()})),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(t){const e=this.clientID,s=this.meta.get(e),i=void 0===s?0:s.clock+1,n=this.states.get(e);null===t?this.states.delete(e):this.states.set(e,t),this.meta.set(e,{clock:i,lastUpdated:he()});const o=[],r=[],a=[],c=[];null===t?c.push(e):null==n?null!=t&&o.push(e):(r.push(e),ge(n,t)||a.push(e)),(o.length>0||a.length>0||c.length>0)&&this.emit("change",[{added:o,updated:a,removed:c},"local"]),this.emit("update",[{added:o,updated:r,removed:c},"local"])}setLocalStateField(t,e){const s=this.getLocalState();null!==s&&this.setLocalState({...s,[t]:e})}getStates(){return this.states}}const fe=(t,e,s)=>{const i=[];for(let s=0;s<e.length;s++){const n=e[s];if(t.states.has(n)){if(t.states.delete(n),n===t.clientID){const e=t.meta.get(n);t.meta.set(n,{clock:e.clock+1,lastUpdated:he()})}i.push(n)}}i.length>0&&(t.emit("change",[{added:[],updated:[],removed:i},s]),t.emit("update",[{added:[],updated:[],removed:i},s]))},ye=(t,e,s=t.states)=>{const i=e.length,n=Kt();_t(n,i);for(let o=0;o<i;o++){const i=e[o],r=s.get(i)||null,a=t.meta.get(i).clock;_t(n,i),_t(n,a),$t(n,JSON.stringify(r))}return Yt(n)};class ke{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const s=this.callbacks[t];return s&&s.forEach((t=>t.apply(this,e))),this}off(t,e){const s=this.callbacks[t];return s&&(e?this.callbacks[t]=s.filter((t=>t!==e)):delete this.callbacks[t]),this}removeAllListeners(){this.callbacks={}}}class we{constructor(t){this.data=t,this.encoder=Kt(),this.decoder=ne(new Uint8Array(this.data))}peekVarString(){return(t=>{const e=t.pos,s=ce(t);return t.pos=e,s})(this.decoder)}readVarUint(){return ae(this.decoder)}readVarString(){return ce(this.decoder)}readVarUint8Array(){return oe(this.decoder)}writeVarUint(t){return _t(this.encoder,t)}writeVarString(t){return $t(this.encoder,t)}writeVarUint8Array(t){return Xt(this.encoder,t)}length(){return Jt(this.encoder)}}var ve,ze;!function(t){t[t.Sync=0]="Sync",t[t.Awareness=1]="Awareness",t[t.Auth=2]="Auth",t[t.QueryAwareness=3]="QueryAwareness",t[t.Stateless=5]="Stateless",t[t.CLOSE=7]="CLOSE",t[t.SyncStatus=8]="SyncStatus"}(ve||(ve={})),function(t){t.Connecting="connecting",t.Connected="connected",t.Disconnected="disconnected"}(ze||(ze={}));class Ce{constructor(){this.encoder=Kt()}get(t){return t.encoder}toUint8Array(){return Yt(this.encoder)}}class Se extends Ce{constructor(){super(...arguments),this.type=ve.CLOSE,this.description="Ask the server to close the connection"}get(t){return $t(this.encoder,t.documentName),_t(this.encoder,this.type),this.encoder}}class je extends ke{constructor(t){super(),this.messageQueue=[],this.configuration={url:"",autoConnect:!0,preserveTrailingSlash:!1,document:void 0,WebSocketPolyfill:void 0,messageReconnectTimeout:3e4,delay:1e3,initialDelay:0,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0,timeout:0,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,handleTimeout:null,providerMap:new Map},this.webSocket=null,this.webSocketHandlers={},this.shouldConnect=!0,this.status=ze.Disconnected,this.lastMessageReceived=0,this.identifier=0,this.intervals={connectionChecker:null},this.connectionAttempt=null,this.receivedOnOpenPayload=void 0,this.closeTries=0,this.setConfiguration(t),this.configuration.WebSocketPolyfill=t.WebSocketPolyfill?t.WebSocketPolyfill:WebSocket,this.on("open",this.configuration.onOpen),this.on("open",this.onOpen.bind(this)),this.on("connect",this.configuration.onConnect),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("status",this.configuration.onStatus),this.on("disconnect",this.configuration.onDisconnect),this.on("close",this.configuration.onClose),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("close",this.onClose.bind(this)),this.on("message",this.onMessage.bind(this)),this.intervals.connectionChecker=setInterval(this.checkConnection.bind(this),this.configuration.messageReconnectTimeout/10),this.shouldConnect&&this.connect()}async onOpen(t){this.status=ze.Connected,this.emit("status",{status:ze.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=t}attach(t){this.configuration.providerMap.set(t.configuration.name,t),this.status===ze.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===ze.Connected&&t.onOpen(this.receivedOnOpenPayload)}detach(t){this.configuration.providerMap.has(t.configuration.name)&&(t.send(Se,{documentName:t.configuration.name}),this.configuration.providerMap.delete(t.configuration.name))}setConfiguration(t={}){this.configuration={...this.configuration,...t},this.configuration.autoConnect||(this.shouldConnect=!1)}async connect(){if(this.status===ze.Connected)return;this.cancelWebsocketRetry&&(this.cancelWebsocketRetry(),this.cancelWebsocketRetry=void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;const{retryPromise:t,cancelFunc:e}=(()=>{let t=!1;return{retryPromise:async function(t,e){const s=function(t){return t||(t={}),{delay:void 0===t.delay?200:t.delay,initialDelay:void 0===t.initialDelay?0:t.initialDelay,minDelay:void 0===t.minDelay?0:t.minDelay,maxDelay:void 0===t.maxDelay?0:t.maxDelay,factor:void 0===t.factor?0:t.factor,maxAttempts:void 0===t.maxAttempts?3:t.maxAttempts,timeout:void 0===t.timeout?0:t.timeout,jitter:!0===t.jitter,initialJitter:!0===t.initialJitter,handleError:void 0===t.handleError?null:t.handleError,handleTimeout:void 0===t.handleTimeout?null:t.handleTimeout,beforeAttempt:void 0===t.beforeAttempt?null:t.beforeAttempt,calculateDelay:void 0===t.calculateDelay?null:t.calculateDelay}}(e);for(const t of["delay","initialDelay","minDelay","maxDelay","maxAttempts","timeout"]){const e=s[t];if(!Number.isInteger(e)||e<0)throw Error(`Value for ${t} must be an integer greater than or equal to 0`)}if(s.factor.constructor!==Number||s.factor<0)throw Error("Value for factor must be a number greater than or equal to 0");if(s.delay<s.minDelay)throw Error(`delay cannot be less than minDelay (delay: ${s.delay}, minDelay: ${s.minDelay}`);const i={attemptNum:0,attemptsRemaining:s.maxAttempts?s.maxAttempts:-1,aborted:!1,abort(){i.aborted=!0}},n=s.calculateDelay||Dt,o=s.calculateDelay?s.calculateDelay(i,s):s.initialDelay;if(o&&await Wt(o),i.attemptNum<1&&s.initialJitter){const t=n(i,s);t&&await Wt(t)}return async function e(){if(s.beforeAttempt&&s.beforeAttempt(i,s),i.aborted){const t=Error("Attempt aborted");throw t.code="ATTEMPT_ABORTED",t}const o=async t=>{if(s.handleError&&await s.handleError(t,i,s),i.aborted||0===i.attemptsRemaining)throw t;i.attemptNum++;const o=n(i,s);return o&&await Wt(o),e()};return i.attemptsRemaining>0&&i.attemptsRemaining--,s.timeout?new Promise(((e,n)=>{const r=setTimeout((()=>{if(s.handleTimeout)try{e(s.handleTimeout(i,s))}catch(t){n(t)}else{const t=Error(`Retry timeout (attemptNum: ${i.attemptNum}, timeout: ${s.timeout})`);t.code="ATTEMPT_TIMEOUT",n(t)}}),s.timeout);t(i,s).then((t=>{clearTimeout(r),e(t)})).catch((t=>{clearTimeout(r),o(t).then(e).catch(n)}))})):t(i,s).catch(o)}()}(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,handleTimeout:this.configuration.handleTimeout,beforeAttempt:e=>{this.shouldConnect&&!t||e.abort()}}).catch((t=>{if(t&&"ATTEMPT_ABORTED"!==t.code)throw t})),cancelFunc:()=>{t=!0}}})();return this.cancelWebsocketRetry=e,t}attachWebSocketListeners(t,e){const{identifier:s}=t;this.webSocketHandlers[s]={message:t=>this.emit("message",t),close:t=>this.emit("close",{event:t}),open:t=>this.emit("open",t),error:t=>{e(t)}};const i=this.webSocketHandlers[t.identifier];Object.keys(i).forEach((e=>{t.addEventListener(e,i[e])}))}cleanupWebSocket(){if(!this.webSocket)return;const{identifier:t}=this.webSocket,e=this.webSocketHandlers[t];Object.keys(e).forEach((s=>{var i;null===(i=this.webSocket)||void 0===i||i.removeEventListener(s,e[s]),delete this.webSocketHandlers[t]})),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise(((t,e)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;const s=new this.configuration.WebSocketPolyfill(this.url);s.binaryType="arraybuffer",s.identifier=this.identifier,this.attachWebSocketListeners(s,e),this.webSocket=s,this.status=ze.Connecting,this.emit("status",{status:ze.Connecting}),this.connectionAttempt={resolve:t,reject:e}}))}onMessage(t){var e;this.resolveConnectionAttempt(),this.lastMessageReceived=he();const s=new we(t.data).peekVarString();null===(e=this.configuration.providerMap.get(s))||void 0===e||e.onMessage(t)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=ze.Connected,this.emit("status",{status:ze.Connected}),this.emit("connect"),this.messageQueue.forEach((t=>this.send(t))),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){var t;null===(t=this.connectionAttempt)||void 0===t||t.reject(),this.connectionAttempt=null}checkConnection(){var t;this.status===ze.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=he()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:"forced"}}),this.closeTries=0):(null===(t=this.webSocket)||void 0===t||t.close(),this.messageQueue=[])))}get serverUrl(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let t=this.configuration.url;for(;"/"===t[t.length-1];)t=t.slice(0,t.length-1);return t}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,null!==this.webSocket)try{this.webSocket.close(),this.messageQueue=[]}catch(t){console.error(t)}}send(t){var e;(null===(e=this.webSocket)||void 0===e?void 0:e.readyState)===Ut.Open?this.webSocket.send(t):this.messageQueue.push(t)}onClose({event:t}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=ze.Disconnected,this.emit("status",{status:ze.Disconnected}),this.emit("disconnect",{event:t}),!this.cancelWebsocketRetry&&this.shouldConnect&&setTimeout((()=>{this.connect()}),this.configuration.delay)}destroy(){this.emit("destroy"),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}}const Ae=(t,e,s)=>{try{A.applyUpdate(e,oe(t),s)}catch(t){console.error("Caught error while handling a Yjs update",t)}},Ee=Ae;class xe{constructor(t){this.message=t}apply(t,e){const{message:s}=this,i=s.readVarUint(),n=s.length();switch(i){case ve.Sync:this.applySyncMessage(t,e);break;case ve.Awareness:this.applyAwarenessMessage(t);break;case ve.Auth:this.applyAuthMessage(t);break;case ve.QueryAwareness:this.applyQueryAwarenessMessage(t);break;case ve.Stateless:t.receiveStateless(ce(s.decoder));break;case ve.SyncStatus:this.applySyncStatusMessage(t,1===(t=>{let e=t.arr[t.pos++],s=63&e,i=64;const n=(64&e)>0?-1:1;if(!(e&Rt))return n*s;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],s+=(e&Bt)*i,i*=128,e<Rt)return n*s;if(s>Pt)throw se}throw ee})(s.decoder));break;case ve.CLOSE:const n={code:1e3,reason:ce(s.decoder),target:t.configuration.websocketProvider.webSocket,type:"close"};t.onClose(),t.configuration.onClose({event:n}),t.forwardClose({event:n});break;default:throw Error("Can’t apply message of unknown type: "+i)}s.length()>n+1&&t.send(Ce,{encoder:s.encoder})}applySyncMessage(t,e){const{message:s}=this;s.writeVarUint(ve.Sync);const i=((t,e,s,i)=>{const n=ae(t);switch(n){case 0:((t,e,s)=>{((t,e,s)=>{_t(t,1),Xt(t,A.encodeStateAsUpdate(e,s))})(e,s,oe(t))})(t,e,s);break;case 1:Ae(t,s,i);break;case 2:Ee(t,s,i);break;default:throw Error("Unknown message type")}return n})(s.decoder,s.encoder,t.document,t);e&&1===i&&(t.synced=!0)}applySyncStatusMessage(t,e){e&&t.decrementUnsyncedChanges()}applyAwarenessMessage(t){if(!t.awareness)return;const{message:e}=this;((t,e,s)=>{const i=ne(e),n=he(),o=[],r=[],a=[],c=[],h=ae(i);for(let e=0;e<h;e++){const e=ae(i);let s=ae(i);const h=JSON.parse(ce(i)),l=t.meta.get(e),d=t.states.get(e),u=void 0===l?0:l.clock;(u<s||u===s&&null===h&&t.states.has(e))&&(null===h?e===t.clientID&&null!=t.getLocalState()?s++:t.states.delete(e):t.states.set(e,h),t.meta.set(e,{clock:s,lastUpdated:n}),void 0===l&&null!==h?o.push(e):void 0!==l&&null===h?c.push(e):null!==h&&(ge(h,d)||a.push(e),r.push(e)))}(o.length>0||a.length>0||c.length>0)&&t.emit("change",[{added:o,updated:a,removed:c},s]),(o.length>0||r.length>0||c.length>0)&&t.emit("update",[{added:o,updated:r,removed:c},s])})(t.awareness,e.readVarUint8Array(),t)}applyAuthMessage(t){const{message:e}=this;((t,e,s,i)=>{switch(xt(t)){case It.Token:e();break;case It.PermissionDenied:s(Tt(t));break;case It.Authenticated:i(Tt(t))}})(e.decoder,t.sendToken.bind(t),t.permissionDeniedHandler.bind(t),t.authenticatedHandler.bind(t))}applyQueryAwarenessMessage(t){if(!t.awareness)return;const{message:e}=this;e.writeVarUint(ve.Awareness),e.writeVarUint8Array(ye(t.awareness,Array.from(t.awareness.getStates().keys())))}}class Te{constructor(t,e={}){this.message=new t,this.encoder=this.message.get(e)}create(){return Yt(this.encoder)}send(t){null==t||t.send(this.create())}}class Ie extends Ce{constructor(){super(...arguments),this.type=ve.Auth,this.description="Authentication"}get(t){if(void 0===t.token)throw Error("The authentication message requires `token` as an argument.");return $t(this.encoder,t.documentName),_t(this.encoder,this.type),((t,e)=>{kt(t,It.Token),zt(t,e)})(this.encoder,t.token),this.encoder}}class Oe extends Ce{constructor(){super(...arguments),this.type=ve.Awareness,this.description="Awareness states update"}get(t){if(void 0===t.awareness)throw Error("The awareness message requires awareness as an argument");if(void 0===t.clients)throw Error("The awareness message requires clients as an argument");let e;return $t(this.encoder,t.documentName),_t(this.encoder,this.type),e=void 0===t.states?ye(t.awareness,t.clients):ye(t.awareness,t.clients,t.states),Xt(this.encoder,e),this.encoder}}class Ue extends Ce{constructor(){super(...arguments),this.type=ve.Stateless,this.description="A stateless message"}get(t){var e;return $t(this.encoder,t.documentName),_t(this.encoder,this.type),$t(this.encoder,null!==(e=t.payload)&&void 0!==e?e:""),this.encoder}}class We extends Ce{constructor(){super(...arguments),this.type=ve.Sync,this.description="First sync step"}get(t){if(void 0===t.document)throw Error("The sync step one message requires document as an argument");return $t(this.encoder,t.documentName),_t(this.encoder,this.type),((t,e)=>{_t(t,0);const s=A.encodeStateVector(e);Xt(t,s)})(this.encoder,t.document),this.encoder}}class De extends Ce{constructor(){super(...arguments),this.type=ve.Sync,this.description="A document update"}get(t){return $t(this.encoder,t.documentName),_t(this.encoder,this.type),((t,e)=>{_t(t,2),Xt(t,e)})(this.encoder,t.update),this.encoder}}class Me extends Error{constructor(){super(...arguments),this.code=1001}}class Re extends ke{constructor(t){var e,s,i;super(),this.configuration={name:"",document:void 0,awareness:void 0,token:null,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit("connect"),this.forwardStatus=t=>this.emit("status",t),this.forwardClose=t=>this.emit("close",t),this.forwardDisconnect=t=>this.emit("disconnect",t),this.forwardDestroy=()=>this.emit("destroy"),this.setConfiguration(t),this.configuration.document=t.document?t.document:new A.Doc,this.configuration.awareness=void 0!==t.awareness?t.awareness:new be(this.document),this.on("open",this.configuration.onOpen),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("synced",this.configuration.onSynced),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("stateless",this.configuration.onStateless),this.on("unsyncedChanges",this.configuration.onUnsyncedChanges),this.on("authenticated",this.configuration.onAuthenticated),this.on("authenticationFailed",this.configuration.onAuthenticationFailed),null===(e=this.awareness)||void 0===e||e.on("update",(()=>{this.emit("awarenessUpdate",{states:Ot(this.awareness.getStates())})})),null===(s=this.awareness)||void 0===s||s.on("change",(()=>{this.emit("awarenessChange",{states:Ot(this.awareness.getStates())})})),this.document.on("update",this.boundDocumentUpdateHandler),null===(i=this.awareness)||void 0===i||i.on("update",this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&"number"==typeof this.configuration.forceSyncInterval&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.manageSocket&&this.attach()}setConfiguration(t={}){t.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new je(t)),this.configuration={...this.configuration,...t}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit("unsyncedChanges",{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit("unsyncedChanges",{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&(this.unsyncedChanges-=1),0===this.unsyncedChanges&&(this.synced=!0),this.emit("unsyncedChanges",{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(We,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&fe(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){"undefined"!=typeof window&&"addEventListener"in window&&window.addEventListener("pagehide",this.boundPageHide)}sendStateless(t){this.send(Ue,{documentName:this.configuration.name,payload:t})}async sendToken(){let t;try{t=await this.getToken()}catch(t){return void this.permissionDeniedHandler("Failed to get token during sendToken(): "+t)}this.send(Ie,{token:null!=t?t:"",documentName:this.configuration.name})}documentUpdateHandler(t,e){e!==this&&(this.incrementUnsyncedChanges(),this.send(De,{update:t,documentName:this.configuration.name}))}awarenessUpdateHandler({added:t,updated:e,removed:s},i){const n=t.concat(e).concat(s);this.send(Oe,{awareness:this.awareness,clients:n,documentName:this.configuration.name})}get synced(){return this.isSynced}set synced(t){this.isSynced!==t&&(this.isSynced=t,t&&this.emit("synced",{state:t}))}receiveStateless(t){this.emit("stateless",{payload:t})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn("HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.")}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn("HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.")}async onOpen(t){this.isAuthenticated=!1,this.emit("open",{event:t}),await this.sendToken(),this.startSync()}async getToken(){return"function"==typeof this.configuration.token?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(We,{document:this.document,documentName:this.configuration.name}),this.awareness&&null!==this.awareness.getLocalState()&&this.send(Oe,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(t,e){if(!this._isAttached)return;const s=new Te(t,e);this.emit("outgoingMessage",{message:s.message}),s.send(this.configuration.websocketProvider)}onMessage(t){const e=new we(t.data),s=e.readVarString();e.writeVarString(s),this.emit("message",{event:t,message:new we(t.data)}),new xe(e).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&fe(this.awareness,Array.from(this.awareness.getStates().keys()).filter((t=>t!==this.document.clientID)),this)}destroy(){this.emit("destroy"),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(fe(this.awareness,[this.document.clientID],"provider destroy"),this.awareness.off("update",this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off("update",this.boundDocumentUpdateHandler),this.removeAllListeners(),this.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),"undefined"!=typeof window&&"removeEventListener"in window&&window.removeEventListener("pagehide",this.boundPageHide)}detach(){this.configuration.websocketProvider.off("connect",this.configuration.onConnect),this.configuration.websocketProvider.off("connect",this.forwardConnect),this.configuration.websocketProvider.off("status",this.forwardStatus),this.configuration.websocketProvider.off("status",this.configuration.onStatus),this.configuration.websocketProvider.off("open",this.boundOnOpen),this.configuration.websocketProvider.off("close",this.boundOnClose),this.configuration.websocketProvider.off("close",this.configuration.onClose),this.configuration.websocketProvider.off("close",this.forwardClose),this.configuration.websocketProvider.off("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.off("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.off("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.off("destroy",this.forwardDestroy),this.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||(this.configuration.websocketProvider.on("connect",this.configuration.onConnect),this.configuration.websocketProvider.on("connect",this.forwardConnect),this.configuration.websocketProvider.on("status",this.configuration.onStatus),this.configuration.websocketProvider.on("status",this.forwardStatus),this.configuration.websocketProvider.on("open",this.boundOnOpen),this.configuration.websocketProvider.on("close",this.boundOnClose),this.configuration.websocketProvider.on("close",this.configuration.onClose),this.configuration.websocketProvider.on("close",this.forwardClose),this.configuration.websocketProvider.on("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.on("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.on("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.on("destroy",this.forwardDestroy),this.configuration.websocketProvider.attach(this),this._isAttached=!0)}permissionDeniedHandler(t){this.emit("authenticationFailed",{reason:t}),this.isAuthenticated=!1}authenticatedHandler(t){this.isAuthenticated=!0,this.authorizedScope=t,this.emit("authenticated",{scope:t})}setAwarenessField(t,e){if(!this.awareness)throw new Me(`Cannot set awareness field "${t}" to ${JSON.stringify(e)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(t,e)}}class Be{type="network";provider;isConnected=!1;isSynced=!1;usesSharedSocket=!1;isDestroyed=!1;connectTimeout=null;pendingConnectReject=null;connectionTimeoutMs;_connectionStatus="disconnected";visibilityHandler=null;onlineHandler=null;get awareness(){return this.provider.awareness}get connectionStatus(){return this._connectionStatus}static sharedWebSocketProvider=null;constructor(t,e,s){const i=s?.name||t,n=s?.url||"ws://localhost:1234";this.connectionTimeoutMs=s?.connectionTimeout??1e4;const o=s?.websocketProvider||Be.sharedWebSocketProvider,r={};void 0!==s?.delay&&(r.delay=s.delay),void 0!==s?.factor&&(r.factor=s.factor),void 0!==s?.maxAttempts&&(r.maxAttempts=s.maxAttempts),void 0!==s?.minDelay&&(r.minDelay=s.minDelay),void 0!==s?.maxDelay&&(r.maxDelay=s.maxDelay);const a=()=>{this.isDestroyed||(this.isConnected=!0,this._connectionStatus="connected",s?.quiet||console.info("Hocuspocus connected: "+i),s?.onConnect&&s.onConnect())},c=()=>{this.isDestroyed||(this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected",s?.quiet||console.info("Hocuspocus disconnected: "+i),s?.onDisconnect&&s.onDisconnect())},h=()=>{this.isDestroyed||(this.isSynced=!0,this._connectionStatus="synced",s?.quiet||console.info("Hocuspocus synced: "+i),s?.onSynced&&s.onSynced())},l=t=>{this.isDestroyed||("connecting"===t.status&&(this._connectionStatus="connecting"),s?.onStatus&&s.onStatus(t))};if(o){this.usesSharedSocket=!0;const t={websocketProvider:o,name:i,document:e,token:s?.token||null,onStatus:l,onConnect:a,onDisconnect:c,onSynced:h,...r};void 0!==s?.forceSyncInterval&&(t.forceSyncInterval=s.forceSyncInterval),s?.onAuthenticationFailed&&(t.onAuthenticationFailed=s.onAuthenticationFailed),this.provider=new Re(t),this.provider.attach(),s?.quiet||console.info("Hocuspocus Provider initialized (multiplexed): "+i)}else{this.usesSharedSocket=!1;const t={url:n,name:i,document:e,token:s?.token||null,autoConnect:!1,onStatus:l,onConnect:a,onDisconnect:c,onSynced:h,...r};void 0!==s?.forceSyncInterval&&(t.forceSyncInterval=s.forceSyncInterval),s?.onAuthenticationFailed&&(t.onAuthenticationFailed=s.onAuthenticationFailed),s?.WebSocketPolyfill&&(t.WebSocketPolyfill=s.WebSocketPolyfill),this.provider=new Re(t),s?.quiet||console.info(`Hocuspocus Provider initialized: ${n}/${i}`)}this.setupBrowserEventListeners()}setupBrowserEventListeners(){"undefined"!=typeof document&&(this.visibilityHandler=()=>{"visible"!==document.visibilityState||this.isConnected||this.isDestroyed||this.provider.connect()},document.addEventListener("visibilitychange",this.visibilityHandler)),"undefined"!=typeof window&&(this.onlineHandler=()=>{this.isConnected||this.isDestroyed||this.provider.connect()},window.addEventListener("online",this.onlineHandler))}removeBrowserEventListeners(){this.visibilityHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null),this.onlineHandler&&"undefined"!=typeof window&&(window.removeEventListener("online",this.onlineHandler),this.onlineHandler=null)}static createSharedWebSocket(t){if(Be.sharedWebSocketProvider)return console.warn("Shared WebSocket already exists. Returning existing instance."),Be.sharedWebSocketProvider;const e={url:t.url};return t.WebSocketPolyfill&&(e.WebSocketPolyfill=t.WebSocketPolyfill),t.onConnect&&(e.onConnect=t.onConnect),t.onDisconnect&&(e.onDisconnect=t.onDisconnect),t.onStatus&&(e.onStatus=t.onStatus),Be.sharedWebSocketProvider=new je(e),console.info("Shared Hocuspocus WebSocket created: "+t.url),Be.sharedWebSocketProvider}static destroySharedWebSocket(){Be.sharedWebSocketProvider&&(Be.sharedWebSocketProvider.destroy(),Be.sharedWebSocketProvider=null,console.info("Shared Hocuspocus WebSocket destroyed"))}static getSharedWebSocket(){return Be.sharedWebSocketProvider}static with(t){return{create:(e,s,i)=>{const n=i?{...t,...i}:t;return new Be(e,s,n)}}}async connect(){if(!this.isSynced&&!this.isDestroyed)return this._connectionStatus="connecting",new Promise(((t,e)=>{this.pendingConnectReject=e,this.connectTimeout=setTimeout((()=>{this.pendingConnectReject=null,this.connectTimeout=null,e(Error("Hocuspocus connection timeout"))}),this.connectionTimeoutMs);const s=()=>{this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject=null,this.provider.off("synced",s),this.isDestroyed||t()};if(this.provider.on("synced",s),this.provider.isSynced)return this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject=null,this.provider.off("synced",s),void t();this.isConnected||this.usesSharedSocket||this.provider.connect()}))}async reconnect(){return this.disconnect(),this.connect()}disconnect(){this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject&&(this.pendingConnectReject=null),this.provider&&(this.usesSharedSocket?this.provider.detach():this.provider.disconnect()),this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected"}destroy(){this.isDestroyed=!0,this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject&&(this.pendingConnectReject=null),this.removeBrowserEventListeners(),this.provider&&this.provider.destroy(),this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected"}}const Pe={type:"pen",color:S[0],size:16,palettes:{pen:[...S]}},Ve={color:S[0],size:8,fontFamily:"Arial",palette:[...S]},Le={color:S[0],size:4,palette:[...S],arrows:{end:{enabled:!0,style:"triangle"}}},Fe={shapeType:c.Rectangle,fillColor:{light:"transparent",dark:"transparent"},strokeColor:S[0],strokeWidth:4,fontColor:S[0],fontSize:16,fontFamily:"Arial",palette:[...S]},Ne=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.isReady=s(this,"isReady"),this.activeWorkspaceChange=s(this,"activeWorkspaceChange"),this.objectsChange=s(this,"objectsChange"),this.objectsAdded=s(this,"objectsAdded"),this.objectsRemoved=s(this,"objectsRemoved"),this.objectsUpdated=s(this,"objectsUpdated"),this.undoStateChange=s(this,"undoStateChange"),this.themeChange=s(this,"themeChange"),this.viewportChange=s(this,"viewportChange"),this.logout=s(this,"logout"),this.login=s(this,"login"),this.isPublicChange=s(this,"isPublicChange"),this.awarenessChange=s(this,"awarenessChange")}get host(){return this}scaleMax=f;scaleMin=y;lockDrawingScale=!0;viewportBoundaryLeft=-1/0;viewportBoundaryRight=1/0;viewportBoundaryTop=-1/0;viewportBoundaryBottom=1/0;wheelEnabled=!0;debugInfo={showViewportInfo:!1,showObjectInfo:!1,showSyncProviderInfo:!0,showMigrationInfo:!0};user;activeUsers;controls=[{name:"selection",type:"tool",isDefault:!0,tool:h,icon:"cursor"},{name:"brush",type:"tool",tool:l,icon:"pen",config:Pe},{name:"eraser",type:"tool",tool:k,icon:"eraser"},{name:"line",type:"tool",tool:d,icon:"arrow",config:Le},{name:"shape",type:"tool",tool:u,icon:"shape-rectangle",config:Fe,subOptions:[{id:"rectangle",icon:"shape-rectangle",label:"Rectangle",value:c.Rectangle,toolProperty:"shapeType"},{id:"ellipse",icon:"shape-ellipse",label:"Ellipse",value:c.Ellipse,toolProperty:"shapeType"},{id:"triangle",icon:"shape-triangle",label:"Triangle",value:c.Triangle,toolProperty:"shapeType"}]},{name:"text",type:"tool",tool:p,icon:"type",config:Ve},{name:"image",type:"tool",tool:w,icon:"image"},{name:"config",type:"config"}];globalContextMenuItems=[{label:"Paste",icon:"paste",disabled:async()=>0===(await this.engineRef.getCopiedObjects()).length,action:t=>this.engineRef.paste(t.x,t.y)},{label:"Select All",icon:"select-all",disabled:async()=>0===(await this.engineRef.getObjectsInViewport()).length,action:()=>this.selectAllObjectsInViewport()}];objectContextMenuItems=[{label:"Copy",icon:"copy",group:"clipboard",action:()=>this.engineRef.copy()},{label:"Paste",icon:"paste",group:"clipboard",disabled:async()=>0===(await this.engineRef.getCopiedObjects()).length,action:t=>this.engineRef.paste(t.x,t.y)},{label:"Order",icon:"ordering",group:"other",children:[{label:"Bring to Front",icon:"bring-to-front",action:()=>this.engineRef.bringToFront()},{label:"Send to Back",icon:"send-to-back",action:()=>this.engineRef.sendToBack()},{label:"Move Up",icon:"arrow-up-from-dot",action:()=>this.engineRef.bringForward()},{label:"Move Down",icon:"arrow-down-from-dot",action:()=>this.engineRef.sendBackward()}]},{label:"Align",icon:"align",group:"other",disabled:async()=>(await this.engineRef.getSelectedObjects()).length<2,children:[{label:"Align Left",icon:"align-start-vertical",action:()=>this.engineRef.alignObjects(v.StartHorizontal)},{label:"Align Center Horizontally",icon:"align-center-horizontal",action:()=>this.engineRef.alignObjects(v.CenterHorizontal)},{label:"Align Right",icon:"align-end-vertical",action:()=>this.engineRef.alignObjects(v.EndHorizontal)},{label:"Align Top",icon:"align-start-horizontal",action:()=>this.engineRef.alignObjects(v.StartVertical)},{label:"Align Center Vertically",icon:"align-center-vertical",action:()=>this.engineRef.alignObjects(v.CenterVertical)},{label:"Align Bottom",icon:"align-end-horizontal",action:()=>this.engineRef.alignObjects(v.EndVertical)}]},{label:"Group",icon:"group",group:"other",children:[{label:"Group",icon:"group",disabled:async()=>(await this.engineRef.getSelectedObjects()).length<2,action:()=>this.engineRef.group()},{label:"Ungroup",icon:"ungroup",disabled:async()=>!(await this.engineRef.getSelectedObjects()).some((t=>"KritzelGroup"===t.__class__)),action:()=>this.engineRef.ungroup()}]},{label:"Export",icon:"download",group:"export",children:[{label:"Export as SVG",icon:"download",action:()=>this.engineRef.exportSelectedObjectsAsSvg()},{label:"Export as PNG",icon:"download",action:()=>this.engineRef.exportSelectedObjectsAsPng()}]},{label:"Delete",icon:"delete",group:"edit",action:()=>this.engineRef.delete()}];customSvgIcons={};isControlsVisible=!0;isUtilityPanelVisible=!0;syncConfig={appStateId:"kritzel-app-test",providers:[Be,z]};loginConfig={providers:[{label:"Sign in with Google",icon:"google",name:"Google"}]};editorId;activeWorkspaceId;isReady;activeWorkspaceChange;objectsChange;objectsAdded;objectsRemoved;objectsUpdated;undoStateChange;themeChange;viewportChange;logout;login;isPublicChange;awarenessChange;isEngineReady=!1;isControlsReady=!1;isWorkspaceManagerReady=!1;workspaces=[];activeWorkspace;isVirtualKeyboardOpen=!1;undoState=null;isBackToContentButtonVisible=!1;currentTheme="light";shortcuts=[];currentIsPublic=!1;onIsEngineReady(t){t&&this.isControlsReady&&this.checkIsReady()}onIsControlsReady(t){t&&this.isEngineReady&&this.checkIsReady()}onWorkspacesChange(t){if(this.activeWorkspace){const e=t.find((t=>t.id===this.activeWorkspace.id));e&&e!==this.activeWorkspace&&(this.activeWorkspace=e)}if(this.activeWorkspaceId){const e=t.find((t=>t.id===this.activeWorkspaceId));e&&e!==this.activeWorkspace&&(this.activeWorkspace=e)}}onActiveWorkspaceChange(){this.updateCurrentIsPublic()}onActiveWorkspaceIdChange(t){if(!t)return;if(0===this.workspaces.length)return;const e=this.workspaces.find((e=>e.id===t));e?e!==this.activeWorkspace&&(this.activeWorkspace=e):console.warn("[KritzelEditor] No workspace found with ID: "+t)}onCurrentThemeChange(){setTimeout((()=>this.setOsSpecificCssVariables()),0)}onTouchStart(t){t.cancelable&&t.preventDefault()}async getObjectById(t){return this.engineRef.getObjectById(t)}async addObject(t){return this.engineRef.addObject(t)}async updateObject(t,e){return this.engineRef.updateObject(t,e)}async removeObject(t){return this.engineRef.removeObject(t)}async getSelectedObjects(){return this.engineRef.getSelectedObjects()}async selectObjects(t){return this.engineRef.selectObjects(t)}async selectAllObjectsInViewport(){return this.engineRef.selectAllObjectsInViewport()}async clearSelection(){this.engineRef.clearSelection()}async centerObjectInViewport(t){return this.engineRef.centerObjectInViewport(t)}async backToContent(){return this.engineRef.backToContent()}async centerAllObjects(t=!0){return this.engineRef.centerAllObjects(t)}async setViewport(t,e,s){return this.engineRef.setViewport(t,e,s)}async panTo(t,e){return this.engineRef.panTo(t,e)}async zoomTo(t,e,s){return this.engineRef.zoomTo(t,e,s)}async getViewport(){return this.engineRef.getViewport()}async screenToWorld(t,e){return this.engineRef.screenToWorld(t,e)}async worldToScreen(t,e){return this.engineRef.worldToScreen(t,e)}async createWorkspace(t){return this.engineRef.createWorkspace(t)}async updateWorkspace(t){return this.engineRef.updateWorkspace(t)}async deleteWorkspace(t){return this.engineRef.deleteWorkspace(t)}async getWorkspaces(){return this.engineRef.getWorkspaces()}async getActiveWorkspace(){return this.engineRef.getActiveWorkspace()}async loadSharedWorkspace(t){return this.engineRef.loadSharedWorkspace(t)}async reinitSync(){return this.engineRef.reinitSync()}async registerTool(t,e,s){return this.engineRef.registerTool(t,e,s)}async changeActiveTool(t){return this.engineRef.changeActiveTool(t)}async disable(){return this.engineRef.disable()}async enable(){return this.engineRef.enable()}async copy(){return this.engineRef.copy()}async paste(t,e){return this.engineRef.paste(t,e)}async delete(){return this.engineRef.delete()}async bringForward(t){return this.engineRef.bringForward(t)}async sendBackward(t){return this.engineRef.sendBackward(t)}async bringToFront(t){return this.engineRef.bringToFront(t)}async sendToBack(t){return this.engineRef.sendToBack(t)}async alignObjects(t){return this.engineRef.alignObjects(t)}async group(){return this.engineRef.group()}async ungroup(){return this.engineRef.ungroup()}async undo(){return this.engineRef.undo()}async redo(){return this.engineRef.redo()}async getScreenshot(t="png"){return this.engineRef.getScreenshot(t)}async exportViewportAsPng(){return this.engineRef.exportViewportAsPng()}async exportViewportAsSvg(){return this.engineRef.exportViewportAsSvg()}async downloadAsJson(t){return this.engineRef.downloadAsJson(t)}async importFromFile(){return this.engineRef.importFromFile()}async loadObjectsFromJson(t){return this.engineRef.loadObjectsFromJson(t)}async getObjectsTotalCount(){return this.engineRef.getObjectsTotalCount()}async getAllObjects(){return this.engineRef.getAllObjects()}async findObjects(t){return this.engineRef.findObjects(t)}async getCopiedObjects(){return this.engineRef.getCopiedObjects()}async getObjectsInViewport(){return this.engineRef.getObjectsInViewport()}async hideContextMenu(){return this.engineRef.hideContextMenu()}async triggerSelectionChange(){return this.engineRef.triggerSelectionChange()}async getDisplayableShortcuts(){return this.engineRef.getDisplayableShortcuts()}engineRef;controlsRef;settingsRef;exportRef;splitButtonRef;shareDialogRef;loginDialogRef;componentWillLoad(){this.loadSettingsFromStorage()}componentDidLoad(){this.registerCustomSvgIcons(),this.listenForMobileKeyboard(),this.setOsSpecificCssVariables()}async checkIsReady(){if(await customElements.whenDefined("kritzel-editor"),await customElements.whenDefined("kritzel-workspace-manager"),await customElements.whenDefined("kritzel-controls"),await customElements.whenDefined("kritzel-engine"),!this.isEngineReady||!this.isControlsReady||!this.isWorkspaceManagerReady)return;const{id:t,name:e,isPublic:s,createdAt:i,updatedAt:n}=this.activeWorkspace;this.isReady.emit({host:this.host,activeWorkspace:{id:t,name:e,isPublic:s,createdAt:i,updatedAt:n},syncConfig:this.syncConfig,loginConfig:this.loginConfig})}async onEngineReady(t){this.isEngineReady=!0,this.activeWorkspace=t.detail.activeWorkspace,this.workspaces=t.detail.workspaces,this.currentIsPublic=await this.engineRef.getIsPublic(),this.loadShortcuts()}handleWorkspacesChange(t){this.workspaces=t.detail}handleActiveWorkspaceChange(t){if(t.stopPropagation(),this.activeWorkspace=t.detail,!this.isEngineReady)return;const{id:e,name:s,isPublic:i,createdAt:n,updatedAt:o}=this.activeWorkspace;this.activeWorkspaceChange.emit({id:e,name:s,isPublic:i,createdAt:n,updatedAt:o})}handleObjectsChange(t){this.objectsChange.emit(t.detail)}handleObjectsAdded(t){this.objectsAdded.emit(t.detail)}handleObjectsRemoved(t){this.objectsRemoved.emit(t.detail)}handleObjectsUpdated(t){this.objectsUpdated.emit(t.detail)}handleUndoStateChange(t){this.undoStateChange.emit(t.detail),this.undoState=t.detail}async handleObjectsInViewportChange(t){const e=this.getContentObjects(t.detail).length>0,s=this.getContentObjects(await this.engineRef.getAllObjects()).length>0;this.isBackToContentButtonVisible=!e&&s}handleViewportChange(t){this.viewportChange.emit(t.detail)}handleAwarenessChange(t){this.awarenessChange.emit(t.detail)}handleSettingsChange(t){this.scaleMin=t.detail.scaleMin,this.scaleMax=t.detail.scaleMax,this.lockDrawingScale=t.detail.lockDrawingScale,this.currentTheme=t.detail.theme,this.viewportBoundaryLeft=t.detail.viewportBoundaryLeft??-1/0,this.viewportBoundaryRight=t.detail.viewportBoundaryRight??1/0,this.viewportBoundaryTop=t.detail.viewportBoundaryTop??-1/0,this.viewportBoundaryBottom=t.detail.viewportBoundaryBottom??1/0,this.debugInfo=t.detail.debugInfo,this.themeChange.emit(t.detail.theme)}get moreMenuItems(){return[{id:"share",label:"Share",icon:"share",action:()=>{this.isLoggedIn||!this.loginConfig?this.shareDialogRef.open():this.openLoginDialog()}},{id:"export",label:"Export",icon:"upload",action:async()=>{const t=await this.engineRef.getScreenshot("png");this.exportRef.open(t)}},{id:"import",label:"Import",icon:"download",action:()=>this.engineRef.importFromFile()},{id:"settings",label:"Settings",icon:"settings",action:()=>this.settingsRef.open()},{id:"logout",label:"Logout",icon:"log-out",color:"#ff3b30",isVisible:this.isLoggedIn,action:()=>this.logout.emit()}]}handleToggleIsPublic=async t=>{const e=t.detail,s=await this.engineRef.getActiveWorkspace();s.isPublic=e,await this.engineRef.updateWorkspace(s),this.activeWorkspace=s.clone(),this.isPublicChange.emit({isPublic:e,workspaceId:this.activeWorkspace?.id})};updateCurrentIsPublic(){const t=this.activeWorkspace?.isPublic??!1,e=this.activeWorkspace?.id;this.currentIsPublic=t,this.isPublicChange.emit({isPublic:t,workspaceId:e})}handleProviderLogin=t=>{this.login.emit(t.detail)};get isLoggedIn(){return!!this.user&&!this.user.isGuest}async openLoginDialog(){this.loginDialogRef?.open()}async setLoginLoading(t){this.loginDialogRef?.setLoading(t)}getSettingsStorageKey(){return this.editorId?"kritzel-settings-"+this.editorId:"kritzel-settings"}loadSettingsFromStorage(){const t=localStorage.getItem(this.getSettingsStorageKey());if(t)try{const e=JSON.parse(t);"number"==typeof e.scaleMin&&(this.scaleMin=e.scaleMin),"number"==typeof e.scaleMax&&(this.scaleMax=e.scaleMax),"boolean"==typeof e.lockDrawingScale&&(this.lockDrawingScale=e.lockDrawingScale),"light"!==e.theme&&"dark"!==e.theme||(this.currentTheme=e.theme),"number"==typeof e.viewportBoundaryLeft&&(this.viewportBoundaryLeft=e.viewportBoundaryLeft),"number"==typeof e.viewportBoundaryRight&&(this.viewportBoundaryRight=e.viewportBoundaryRight),"number"==typeof e.viewportBoundaryTop&&(this.viewportBoundaryTop=e.viewportBoundaryTop),"number"==typeof e.viewportBoundaryBottom&&(this.viewportBoundaryBottom=e.viewportBoundaryBottom),e.debugInfo&&(this.debugInfo={...this.debugInfo,...e.debugInfo})}catch{}}async loadShortcuts(){this.shortcuts=await this.engineRef.getDisplayableShortcuts()}getContentObjects(t){return t.filter((t=>!(t instanceof m||t instanceof g)))}registerCustomSvgIcons(){for(const[t,e]of Object.entries(this.customSvgIcons))r.register(t,e)}listenForMobileKeyboard(){b.onKeyboardVisibleChanged((t=>{this.isVirtualKeyboardOpen=t}))}setOsSpecificCssVariables(){switch(j.detectOS()){case"iOS":this.host.style.setProperty("--kritzel-editor-top-left-buttons-top","14px"),this.host.style.setProperty("--kritzel-editor-top-left-buttons-left","14px"),this.host.style.setProperty("--kritzel-editor-controls-bottom","14px"),this.host.style.setProperty("--kritzel-editor-controls-transition","cubic-bezier(0.25, 0.1, 0.25, 1.0)"),this.host.style.setProperty("--kritzel-editor-controls-transform","translateY(200%)"),this.host.style.setProperty("--kritzel-editor-controls-transition-duration","0.25s");break;case"Android":this.host.style.setProperty("--kritzel-editor-top-left-buttons-top","14px"),this.host.style.setProperty("--kritzel-editor-top-left-buttons-left","14px"),this.host.style.setProperty("--kritzel-editor-controls-bottom","24px"),this.host.style.setProperty("--kritzel-editor-controls-transition","cubic-bezier(0.25, 0.1, 0.25, 1.0)"),this.host.style.setProperty("--kritzel-editor-controls-transform","translateY(200%)"),this.host.style.setProperty("--kritzel-editor-controls-transition-duration","0.25s");break;default:this.host.style.setProperty("--kritzel-editor-top-left-buttons-top","14px"),this.host.style.setProperty("--kritzel-editor-top-left-buttons-left","14px"),this.host.style.setProperty("--kritzel-editor-controls-bottom","14px")}}render(){const t=this.isLoggedIn,e=t,s=!!this.loginConfig&&!t;return i(n,{key:"6dbc3a8c64dd097ba82e46341b3fb97cbd0194db"},i("div",{key:"26ceb62f59ad830fd651a1712f57e5d711e7c6f4",class:"top-left-buttons"},i("kritzel-workspace-manager",{key:"afb4f5b87c5dc0a673444fb27930e43994df4e02",workspaces:this.workspaces,activeWorkspace:this.activeWorkspace,onWorkspaceChange:t=>this.activeWorkspace=t.detail,onIsWorkspaceManagerReady:()=>this.isWorkspaceManagerReady=!0}),i("kritzel-back-to-content",{key:"f3c0f31841cb819917c3277852bc9b5ce291c09a",visible:this.isBackToContentButtonVisible,onBackToContent:()=>this.backToContent()})),i("kritzel-engine",{key:"8a9e57132e6b74ec812ee516dc7f0d5fc6c8a2e1",ref:t=>this.engineRef=t,workspace:this.activeWorkspace,activeWorkspaceId:this.activeWorkspaceId,editorId:this.editorId,syncConfig:this.syncConfig,user:this.user,scaleMax:this.scaleMax,lockDrawingScale:this.lockDrawingScale,scaleMin:this.scaleMin,viewportBoundaryLeft:this.viewportBoundaryLeft,viewportBoundaryRight:this.viewportBoundaryRight,viewportBoundaryTop:this.viewportBoundaryTop,viewportBoundaryBottom:this.viewportBoundaryBottom,wheelEnabled:this.wheelEnabled,theme:this.currentTheme,debugInfo:this.debugInfo,globalContextMenuItems:this.globalContextMenuItems,objectContextMenuItems:this.objectContextMenuItems,onIsEngineReady:t=>this.onEngineReady(t),onWorkspacesChange:t=>this.handleWorkspacesChange(t),onActiveWorkspaceChange:t=>this.handleActiveWorkspaceChange(t),onObjectsChange:t=>this.handleObjectsChange(t),onObjectsAdded:t=>this.handleObjectsAdded(t),onObjectsRemoved:t=>this.handleObjectsRemoved(t),onObjectsUpdated:t=>this.handleObjectsUpdated(t),onUndoStateChange:t=>this.handleUndoStateChange(t),onObjectsInViewportChange:t=>this.handleObjectsInViewportChange(t),onViewportChange:t=>this.handleViewportChange(t),onAwarenessChange:t=>this.handleAwarenessChange(t)}),i("kritzel-controls",{key:"6caadf512a0208fecdb18b6d68b17daa522161a3",class:{"keyboard-open":this.isVirtualKeyboardOpen},style:{display:this.isControlsVisible?"flex":"none"},ref:t=>this.controlsRef=t,controls:this.controls,isUtilityPanelVisible:this.isUtilityPanelVisible,undoState:this.undoState,theme:this.currentTheme,onIsControlsReady:()=>this.isControlsReady=!0}),i("div",{key:"e27e5f3965be2fd15c83b91470ef87c4031dd7a2",class:"top-right-buttons"},i("kritzel-settings",{key:"57f8e75287402aecbb7740d46dfa15839de2169f",ref:t=>this.settingsRef=t,shortcuts:this.shortcuts,editorId:this.editorId,onSettingsChange:t=>this.handleSettingsChange(t)}),i("kritzel-export",{key:"5ccf176d4fe1221c5d7597bd1c8537cf3324d3ee",ref:t=>this.exportRef=t,workspaceName:this.activeWorkspace?.name||"workspace",onExportPng:()=>this.engineRef.exportViewportAsPng(),onExportSvg:()=>this.engineRef.exportViewportAsSvg(),onExportJson:t=>this.engineRef.downloadAsJson(t.detail)}),i("kritzel-active-users",{key:"44a334b808706e11163e89b91074ca4ea8ab4b18",users:this.activeUsers}),e&&i("kritzel-current-user",{key:"bcb3c966e630b1a8fc4ccd438fc8fbb11cd2b167",user:this.user}),s&&i("kritzel-button",{key:"f1957e56257b7c565311e41b770579f7e2bb910d",onButtonClick:()=>this.loginDialogRef?.open()},"Sign in"),i("kritzel-more-menu",{key:"d8c1d1b51cf87725d68aaf4457b88828986a40dc",items:this.moreMenuItems}),i("kritzel-share-dialog",{key:"f5840e7f56cf6897ec28b0f28d9b204037bf3348",ref:t=>this.shareDialogRef=t,isPublic:this.currentIsPublic,workspaceId:this.activeWorkspace?.id,onToggleIsPublic:this.handleToggleIsPublic}),this.loginConfig&&i("kritzel-login-dialog",{key:"cfdcc3d5e7a5e29b0a352f0d4423ae79195dbf69",ref:t=>this.loginDialogRef=t,providers:this.loginConfig.providers,dialogTitle:this.loginConfig.title,subtitle:this.loginConfig.subtitle,onProviderLogin:this.handleProviderLogin})))}static get watchers(){return{isEngineReady:[{onIsEngineReady:0}],isControlsReady:[{onIsControlsReady:0}],workspaces:[{onWorkspacesChange:0}],activeWorkspace:[{onActiveWorkspaceChange:0}],activeWorkspaceId:[{onActiveWorkspaceIdChange:0}],currentTheme:[{onCurrentThemeChange:0}]}}static get style(){return"kritzel-editor{display:flex;margin:0;position:relative;overflow:hidden;width:100%;height:100%;align-items:center;justify-content:center;touch-action:manipulation;user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}kritzel-controls{position:absolute;bottom:var(--kritzel-editor-controls-bottom, 14px);transition:transform var(--kritzel-editor-controls-transition-duration, 0.1s) var(--kritzel-editor-controls-transition, ease-in-out)}kritzel-controls.keyboard-open{transform:var(--kritzel-editor-controls-transform, translateY(300%))}.top-left-buttons{position:absolute;top:var(--kritzel-editor-top-left-buttons-top, 14px);left:var(--kritzel-editor-top-left-buttons-left, 14px);display:flex;align-items:flex-start;gap:8px;z-index:10000}.top-right-buttons{position:absolute;top:var(--kritzel-editor-top-right-buttons-top, 14px);right:var(--kritzel-editor-top-right-buttons-right, 14px);display:flex;align-items:center;gap:8px;z-index:10000}.top-right-button{display:flex;align-items:center;justify-content:center;width:50px;height:50px;padding:0;border:var(--kritzel-split-button-border, 1px solid #ebebeb);border-radius:var(--kritzel-split-button-border-radius, 12px);background-color:var(--kritzel-split-button-background-color, #ffffff);cursor:var(--kritzel-global-pointer-cursor, pointer);box-shadow:var(--kritzel-split-button-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));transition:background-color 150ms ease;-webkit-tap-highlight-color:transparent}.top-right-button:hover{background-color:#f5f5f5}.top-right-button:active{background-color:#ebebeb}"}},[512,"kritzel-editor",{scaleMax:[1026,"scale-max"],scaleMin:[1026,"scale-min"],lockDrawingScale:[1028,"lock-drawing-scale"],viewportBoundaryLeft:[1026,"viewport-boundary-left"],viewportBoundaryRight:[1026,"viewport-boundary-right"],viewportBoundaryTop:[1026,"viewport-boundary-top"],viewportBoundaryBottom:[1026,"viewport-boundary-bottom"],wheelEnabled:[1028,"wheel-enabled"],debugInfo:[1040],user:[16],activeUsers:[16],controls:[16],globalContextMenuItems:[16],objectContextMenuItems:[16],customSvgIcons:[16],isControlsVisible:[4,"is-controls-visible"],isUtilityPanelVisible:[4,"is-utility-panel-visible"],syncConfig:[16],loginConfig:[16],editorId:[1,"editor-id"],activeWorkspaceId:[1,"active-workspace-id"],isEngineReady:[32],isControlsReady:[32],isWorkspaceManagerReady:[32],workspaces:[32],activeWorkspace:[32],isVirtualKeyboardOpen:[32],undoState:[32],isBackToContentButtonVisible:[32],currentTheme:[32],shortcuts:[32],currentIsPublic:[32],getObjectById:[64],addObject:[64],updateObject:[64],removeObject:[64],getSelectedObjects:[64],selectObjects:[64],selectAllObjectsInViewport:[64],clearSelection:[64],centerObjectInViewport:[64],backToContent:[64],centerAllObjects:[64],setViewport:[64],panTo:[64],zoomTo:[64],getViewport:[64],screenToWorld:[64],worldToScreen:[64],createWorkspace:[64],updateWorkspace:[64],deleteWorkspace:[64],getWorkspaces:[64],getActiveWorkspace:[64],loadSharedWorkspace:[64],reinitSync:[64],registerTool:[64],changeActiveTool:[64],disable:[64],enable:[64],copy:[64],paste:[64],delete:[64],bringForward:[64],sendBackward:[64],bringToFront:[64],sendToBack:[64],alignObjects:[64],group:[64],ungroup:[64],undo:[64],redo:[64],getScreenshot:[64],exportViewportAsPng:[64],exportViewportAsSvg:[64],downloadAsJson:[64],importFromFile:[64],loadObjectsFromJson:[64],getObjectsTotalCount:[64],getAllObjects:[64],findObjects:[64],getCopiedObjects:[64],getObjectsInViewport:[64],hideContextMenu:[64],triggerSelectionChange:[64],getDisplayableShortcuts:[64],openLoginDialog:[64],setLoginLoading:[64]},[[0,"dblclick","onTouchStart"]],{isEngineReady:[{onIsEngineReady:0}],isControlsReady:[{onIsControlsReady:0}],workspaces:[{onWorkspacesChange:0}],activeWorkspace:[{onActiveWorkspaceChange:0}],activeWorkspaceId:[{onActiveWorkspaceIdChange:0}],currentTheme:[{onCurrentThemeChange:0}]}]),He=Ne,Ge=function(){"undefined"!=typeof customElements&&["kritzel-editor","kritzel-active-users","kritzel-avatar","kritzel-awareness-cursors","kritzel-back-to-content","kritzel-button","kritzel-color","kritzel-color-palette","kritzel-context-menu","kritzel-controls","kritzel-current-user","kritzel-current-user-dialog","kritzel-cursor-trail","kritzel-dialog","kritzel-dropdown","kritzel-engine","kritzel-export","kritzel-font","kritzel-font-family","kritzel-font-size","kritzel-icon","kritzel-input","kritzel-line-endings","kritzel-login-dialog","kritzel-master-detail","kritzel-menu","kritzel-menu-item","kritzel-more-menu","kritzel-numeric-input","kritzel-opacity-slider","kritzel-pill-tabs","kritzel-portal","kritzel-settings","kritzel-shape-fill","kritzel-share-dialog","kritzel-slide-toggle","kritzel-split-button","kritzel-stroke-size","kritzel-tool-config","kritzel-tooltip","kritzel-utility-panel","kritzel-workspace-manager"].forEach((t=>{switch(t){case"kritzel-editor":customElements.get(o(t))||customElements.define(o(t),Ne);break;case"kritzel-active-users":customElements.get(o(t))||E();break;case"kritzel-avatar":customElements.get(o(t))||x();break;case"kritzel-awareness-cursors":customElements.get(o(t))||T();break;case"kritzel-back-to-content":customElements.get(o(t))||I();break;case"kritzel-button":customElements.get(o(t))||O();break;case"kritzel-color":customElements.get(o(t))||U();break;case"kritzel-color-palette":customElements.get(o(t))||W();break;case"kritzel-context-menu":customElements.get(o(t))||D();break;case"kritzel-controls":customElements.get(o(t))||M();break;case"kritzel-current-user":customElements.get(o(t))||R();break;case"kritzel-current-user-dialog":customElements.get(o(t))||B();break;case"kritzel-cursor-trail":customElements.get(o(t))||P();break;case"kritzel-dialog":customElements.get(o(t))||V();break;case"kritzel-dropdown":customElements.get(o(t))||L();break;case"kritzel-engine":customElements.get(o(t))||C();break;case"kritzel-export":customElements.get(o(t))||F();break;case"kritzel-font":customElements.get(o(t))||N();break;case"kritzel-font-family":customElements.get(o(t))||H();break;case"kritzel-font-size":customElements.get(o(t))||G();break;case"kritzel-icon":customElements.get(o(t))||a();break;case"kritzel-input":customElements.get(o(t))||K();break;case"kritzel-line-endings":customElements.get(o(t))||J();break;case"kritzel-login-dialog":customElements.get(o(t))||Y();break;case"kritzel-master-detail":customElements.get(o(t))||q();break;case"kritzel-menu":customElements.get(o(t))||Q();break;case"kritzel-menu-item":customElements.get(o(t))||_();break;case"kritzel-more-menu":customElements.get(o(t))||Z();break;case"kritzel-numeric-input":customElements.get(o(t))||$();break;case"kritzel-opacity-slider":customElements.get(o(t))||X();break;case"kritzel-pill-tabs":customElements.get(o(t))||tt();break;case"kritzel-portal":customElements.get(o(t))||et();break;case"kritzel-settings":customElements.get(o(t))||st();break;case"kritzel-shape-fill":customElements.get(o(t))||it();break;case"kritzel-share-dialog":customElements.get(o(t))||nt();break;case"kritzel-slide-toggle":customElements.get(o(t))||ot();break;case"kritzel-split-button":customElements.get(o(t))||rt();break;case"kritzel-stroke-size":customElements.get(o(t))||at();break;case"kritzel-tool-config":customElements.get(o(t))||ct();break;case"kritzel-tooltip":customElements.get(o(t))||ht();break;case"kritzel-utility-panel":customElements.get(o(t))||lt();break;case"kritzel-workspace-manager":customElements.get(o(t))||dt()}}))};export{Pe as D,Be as H,He as KritzelEditor,Ve as a,Le as b,Ge as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as o,g as s}from"./p-
|
|
1
|
+
import{h as o,g as s}from"./p-Ban3OlgZ.js";const a=o,p=s;export{a as KritzelEngine,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as
|
|
1
|
+
import{K as s,d as o}from"./p-BLsH_Oi0.js";const p=s,r=o;export{p as KritzelExport,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as s}from"./p-
|
|
1
|
+
import{K as o,d as s}from"./p-DV7Z_qfa.js";const a=o,p=s;export{a as KritzelFontFamily,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as
|
|
1
|
+
import{K as o,d as s}from"./p-D7yzmu1l.js";const m=o,p=s;export{m as KritzelFontSize,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as s,d as o}from"./p-
|
|
1
|
+
import{K as s,d as o}from"./p-DDKjsXCe.js";const p=s,r=o;export{p as KritzelFont,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a
|
|
1
|
+
import{a,d as o}from"./p-DxzDda_J.js";const s=a,p=o;export{s as KritzelIcon,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as s}from"./p-
|
|
1
|
+
import{K as o,d as s}from"./p-D14QNK3X.js";const p=o,r=s;export{p as KritzelInput,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as
|
|
1
|
+
import{K as o,d as s}from"./p-Md9Y-b3d.js";const d=o,p=s;export{d as KritzelLineEndings,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as s}from"./p-
|
|
1
|
+
import{K as o,d as s}from"./p-gtQlsorg.js";const r=o,t=s;export{r as KritzelLoginDialog,t as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as s}from"./p-
|
|
1
|
+
import{K as o,d as s}from"./p-DkWWzVg8.js";const p=o,r=s;export{p as KritzelMasterDetail,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as o,d as s}from"./p-
|
|
1
|
+
import{b as o,d as s}from"./p-CI9Nbh-x.js";const p=o,r=s;export{p as KritzelMenuItem,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,a as s}from"./p-
|
|
1
|
+
import{K as o,a as s}from"./p-CI9Nbh-x.js";const a=o,p=s;export{a as KritzelMenu,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as
|
|
1
|
+
import{K as s,d as o}from"./p-Cns7qSKS.js";const p=s,r=o;export{p as KritzelMoreMenu,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as
|
|
1
|
+
import{K as s,d as o}from"./p-DWsCbu01.js";const p=s,r=o;export{p as KritzelNumericInput,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as s}from"./p-
|
|
1
|
+
import{K as o,d as s}from"./p-ZQ2bKafG.js";const a=o,p=s;export{a as KritzelOpacitySlider,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as
|
|
1
|
+
import{K as o,d as r}from"./p-BrZ_gL8Q.js";const s=o,p=r;export{s as KritzelPillTabs,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as
|
|
1
|
+
import{K as o,d as p}from"./p-Dr3-pKVg.js";const r=o,s=p;export{r as KritzelPortal,s as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as s}from"./p-
|
|
1
|
+
import{K as o,d as s}from"./p-DaGZEV0R.js";const a=o,p=s;export{a as KritzelSettings,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as s}from"./p-
|
|
1
|
+
import{K as o,d as s}from"./p-Dte67BWd.js";const t=o,p=s;export{t as KritzelShapeFill,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as
|
|
1
|
+
import{K as o,d as r}from"./p-C4fKLlrd.js";const s=o,p=r;export{s as KritzelShareDialog,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as
|
|
1
|
+
import{K as o,d as p}from"./p-Ck1dhpUQ.js";const s=o,r=p;export{s as KritzelSlideToggle,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as
|
|
1
|
+
import{K as o,d as p}from"./p-pCC6t6BH.js";const s=o,t=p;export{s as KritzelSplitButton,t as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as s}from"./p-
|
|
1
|
+
import{K as o,d as s}from"./p-Lhyh6KeB.js";const p=o,r=s;export{p as KritzelStrokeSize,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o,d as s}from"./p-
|
|
1
|
+
import{a as o,d as s}from"./p-CWMFGEe0.js";const a=o,p=s;export{a as KritzelToolConfig,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as s}from"./p-
|
|
1
|
+
import{K as o,d as s}from"./p-BuI6Gkzg.js";const p=o,r=s;export{p as KritzelTooltip,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as s}from"./p-
|
|
1
|
+
import{K as o,d as s}from"./p-m1nVDC3G.js";const m=o,p=s;export{m as KritzelUtilityPanel,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as
|
|
1
|
+
import{K as s,d as o}from"./p-_QEHfsIk.js";const p=s,r=o;export{p as KritzelWorkspaceManager,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e,H as t,c as o,h as i,d as l,t as a}from"./p-
|
|
1
|
+
import{p as e,H as t,c as o,h as i,d as l,t as a}from"./p-CGGiwvWZ.js";import{K as s}from"./p-BML28BJR.js";const r=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.dialogOpen=o(this,"dialogOpen"),this.dialogClose=o(this,"dialogClose")}get host(){return this}isOpen=!1;dialogTitle;closable=!0;closeOnBackdrop=!0;closeOnEscape=!0;autoFocus=!0;trapFocus=!0;size="medium";fullscreenOnMobile=!0;isAnimating=!1;mobileLockedHeight=null;dialogOpen;dialogClose;previousOverflow="";previousActiveElement=null;handleIsOpenChange(e){e?this.openDialog():this.closeDialog()}handleKeyDown(e){this.isOpen&&("Escape"===e.key&&this.closeOnEscape&&(e.preventDefault(),e.stopPropagation(),this.emitClose("escape")),"Tab"===e.key&&this.trapFocus&&this.handleTabKey(e))}async open(){this.isOpen||(this.isOpen=!0)}async close(e="programmatic"){this.emitClose(e)}async focusFirstElement(){this.focusFirst()}componentDidLoad(){this.isOpen&&this.openDialog()}disconnectedCallback(){this.restoreBodyScroll()}openDialog(){this.isAnimating=!0,this.previousActiveElement=document.activeElement,this.lockBodyScroll(),this.lockMobileViewportHeight(),this.dialogOpen.emit(),this.autoFocus&&requestAnimationFrame((()=>{this.focusFirst()})),requestAnimationFrame((()=>{this.isAnimating=!1}))}closeDialog(){this.restoreBodyScroll(),this.mobileLockedHeight=null,this.returnFocusToPreviousElement()}emitClose(e){this.dialogClose.emit({reason:e})}lockBodyScroll(){this.previousOverflow=document.body.style.overflow,document.body.style.overflow="hidden"}lockMobileViewportHeight(){this.mobileLockedHeight=!this.fullscreenOnMobile||window.innerWidth>576?null:`${window.innerHeight}px`}restoreBodyScroll(){document.body.style.overflow=this.previousOverflow}returnFocusToPreviousElement(){this.previousActiveElement?.focus&&this.previousActiveElement.focus()}focusFirst(){const e=this.host.shadowRoot?.querySelector(".dialog-content");if(!e)return;const t=[...s.getFocusableElements(e),...this.getSlottedFocusableElements()];t.length>0?t[0].focus():e.focus()}getSlottedFocusableElements(){const e=this.host.shadowRoot?.querySelectorAll("slot")??[],t=[];return e.forEach((e=>{e.assignedElements({flatten:!0}).forEach((e=>{const o=s.getFocusableElements(e);t.push(...o)}))})),t}handleTabKey(e){const t=this.getSlottedFocusableElements(),o=this.host.shadowRoot?.querySelector(".close-button");if(o&&this.closable&&t.unshift(o),0===t.length)return;const i=t[0],l=t[t.length-1],a=this.getDeepActiveElement();e.shiftKey?a===i&&(e.preventDefault(),l.focus()):a===l&&(e.preventDefault(),i.focus())}getDeepActiveElement(){let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e}handleBackdropClick=e=>{e.stopPropagation(),this.closeOnBackdrop&&this.emitClose("backdrop")};handleCloseButtonClick=e=>{e.stopPropagation(),this.emitClose("close-button")};handleContentClick=e=>{e.stopPropagation()};renderCloseButton(){return this.closable?i("button",{class:"close-button",type:"button","aria-label":"Close dialog",onClick:this.handleCloseButtonClick},i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},i("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i("line",{x1:"6",y1:"6",x2:"18",y2:"18"}))):null}renderHeader(){const e=null!==this.host.querySelector('[slot="header"]'),t=!!this.dialogTitle;return e||t||this.closable?i("div",{class:"dialog-header"},e?i("slot",{name:"header"}):t?i("h2",{class:"dialog-title"},this.dialogTitle):null,this.renderCloseButton()):null}renderFooter(){return null!==this.host.querySelector('[slot="footer"]')?i("div",{class:"dialog-footer"},i("slot",{name:"footer"})):null}render(){return this.isOpen?i(l,null,i("div",{class:{backdrop:!0,"is-animating":this.isAnimating},onClick:this.handleBackdropClick},i("div",{class:{"dialog-content":!0,"is-animating":this.isAnimating,[`size-${this.size}`]:!0,"fullscreen-on-mobile":this.fullscreenOnMobile},style:this.mobileLockedHeight?{height:this.mobileLockedHeight,maxHeight:this.mobileLockedHeight}:void 0,role:"dialog","aria-modal":"true","aria-labelledby":this.dialogTitle?"dialog-title":void 0,tabIndex:-1,onClick:this.handleContentClick},this.renderHeader(),i("div",{class:"dialog-body"},i("slot",null)),this.renderFooter()))):null}static get watchers(){return{isOpen:[{handleIsOpenChange:0}]}}static get style(){return":host{display:contents}.backdrop{position:fixed;top:0;left:0;right:0;bottom:0;z-index:10002;display:flex;align-items:center;justify-content:center;background-color:var(--kritzel-dialog-backdrop-color, rgba(0, 0, 0, 0.5));opacity:1;transition:opacity 150ms ease-out}.backdrop.is-animating{opacity:0}.dialog-content{position:relative;display:flex;flex-direction:column;background-color:var(--kritzel-dialog-background-color, #ffffff);border-radius:var(--kritzel-dialog-border-radius, 12px);box-shadow:var(--kritzel-dialog-box-shadow, 0 4px 20px rgba(0, 0, 0, 0.15));border:var(--kritzel-dialog-border, 1px solid #ebebeb);max-height:var(--kritzel-dialog-max-height, 90vh);max-width:var(--kritzel-dialog-max-width, 90vw);overflow:hidden;transform:scale(1);opacity:1;transition:transform 200ms ease-out, opacity 200ms ease-out;font-family:var(--kritzel-dialog-font-family, sans-serif)}.dialog-content.is-animating{transform:scale(0.95);opacity:0}.dialog-content.size-small{width:var(--kritzel-dialog-width-small, 320px);height:var(--kritzel-dialog-height-small, auto)}.dialog-content.size-medium{width:var(--kritzel-dialog-width-medium, 480px);height:var(--kritzel-dialog-height-medium, auto)}.dialog-content.size-large{width:var(--kritzel-dialog-width-large, 640px);height:var(--kritzel-dialog-height-large, auto)}.dialog-content.size-fullscreen{width:100vw;height:100vh;height:100dvh;max-width:100vw;max-height:100vh;max-height:100dvh;border-radius:0}@media (max-width: 576px){.backdrop:has(.fullscreen-on-mobile){background-color:transparent}.dialog-content.fullscreen-on-mobile{width:100vw;height:100vh;height:100dvh;max-width:100vw;max-height:100vh;max-height:100dvh;border-radius:0}.dialog-content.fullscreen-on-mobile .dialog-body{display:flex;flex-direction:column}.dialog-content.fullscreen-on-mobile .dialog-body ::slotted(*){flex:1;min-height:0}}.dialog-header{display:flex;align-items:center;justify-content:space-between;padding:var(--kritzel-dialog-header-padding, 16px 20px);border-bottom:var(--kritzel-dialog-header-border, 1px solid #ebebeb);gap:12px}.dialog-title{margin:0;font-size:var(--kritzel-dialog-title-font-size, 18px);font-weight:var(--kritzel-dialog-title-font-weight, 600);color:var(--kritzel-dialog-title-color, #1a1a1a);flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.close-button{display:flex;align-items:center;justify-content:center;width:32px;height:32px;padding:0;border:none;border-radius:var(--kritzel-dialog-close-button-border-radius, 6px);background-color:var(--kritzel-dialog-close-button-background, transparent);color:var(--kritzel-dialog-close-button-color, #666666);cursor:var(--kritzel-global-pointer-cursor, pointer);transition:background-color 150ms ease, color 150ms ease;flex-shrink:0;-webkit-tap-highlight-color:transparent}.close-button:hover{background-color:var(--kritzel-dialog-close-button-hover-background, #f5f5f5);color:var(--kritzel-dialog-close-button-hover-color, #1a1a1a)}.close-button:active{background-color:var(--kritzel-dialog-close-button-active-background, #ebebeb)}.close-button:focus-visible{outline:revert;outline-offset:revert}.dialog-body{padding:var(--kritzel-dialog-body-padding, 20px);overflow-y:auto;flex:1;min-height:0;scrollbar-color:var(--kritzel-global-scrollbar-thumb-color, #ebebeb) transparent;scrollbar-width:thin}.dialog-footer{display:flex;align-items:center;justify-content:flex-end;gap:var(--kritzel-dialog-footer-gap, 8px);padding:var(--kritzel-dialog-footer-padding, 16px 20px);border-top:var(--kritzel-dialog-footer-border, 1px solid #ebebeb)}::slotted([slot='header']){flex:1}::slotted([slot='footer']){display:contents}"}},[769,"kritzel-dialog",{isOpen:[516,"is-open"],dialogTitle:[1,"dialog-title"],closable:[4],closeOnBackdrop:[4,"close-on-backdrop"],closeOnEscape:[4,"close-on-escape"],autoFocus:[4,"auto-focus"],trapFocus:[4,"trap-focus"],size:[1],fullscreenOnMobile:[4,"fullscreen-on-mobile"],isAnimating:[32],mobileLockedHeight:[32],open:[64],close:[64],focusFirstElement:[64]},[[8,"keydown","handleKeyDown"]],{isOpen:[{handleIsOpenChange:0}]}]);function n(){"undefined"!=typeof customElements&&["kritzel-dialog"].forEach((e=>{"kritzel-dialog"===e&&(customElements.get(a(e))||customElements.define(a(e),r))}))}export{r as K,n as d}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as o,c as r,h as e,d as n,t as a}from"./p-
|
|
1
|
+
import{p as t,H as o,c as r,h as e,d as n,t as a}from"./p-CGGiwvWZ.js";const i=t(class extends o{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.buttonClick=r(this,"buttonClick")}variant="primary";disabled=!1;type="button";buttonClick;handleClick=t=>{this.disabled||(t.stopPropagation(),this.buttonClick.emit())};render(){return e(n,{key:"3a285bfdc1b336fb450304856aa81c1bd9c4e5e3"},e("button",{key:"f3119bfe9cf8ca1b6e031cdcc8bee9549c18e620",type:this.type,class:{"kritzel-button":!0,[this.variant]:!0,disabled:this.disabled},disabled:this.disabled,onClick:this.handleClick},e("slot",{key:"5a26eee0781c5fafc7a41260364b2a2c11f192a6"})))}static get style(){return":host{display:inline-block;font-family:sans-serif}button{border:none;background-color:transparent;padding:0;margin:0;font-family:inherit;font-size:inherit;-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:var(--kritzel-global-pointer-cursor, pointer);display:inline-flex;align-items:center;justify-content:center;gap:6px;border-radius:var(--kritzel-button-border-radius, 8px);padding:var(--kritzel-button-padding, 12px 20px);font-size:var(--kritzel-button-font-size, 14px);font-weight:var(--kritzel-button-font-weight, 500);transition:background-color 0.15s ease, opacity 0.15s ease;-webkit-tap-highlight-color:transparent}button.primary{background-color:var(--kritzel-button-primary-background-color, #007AFF);color:var(--kritzel-button-primary-color, #ffffff)}button.primary:hover{background-color:var(--kritzel-button-primary-hover-background-color, #006ae6)}button.primary:active{background-color:var(--kritzel-button-primary-active-background-color, #005bbf)}button.secondary{background-color:var(--kritzel-button-secondary-background-color, #f0f0f0);color:var(--kritzel-button-secondary-color, #333333)}button.secondary:hover{background-color:var(--kritzel-button-secondary-hover-background-color, #e0e0e0)}button.secondary:active{background-color:var(--kritzel-button-secondary-active-background-color, #d0d0d0)}button.text{background-color:transparent;color:var(--kritzel-button-text-color, #007AFF)}button.text:hover{background-color:var(--kritzel-button-text-hover-background-color, rgba(0, 122, 255, 0.08))}button.text:active{background-color:var(--kritzel-button-text-active-background-color, rgba(0, 122, 255, 0.15))}button.disabled{opacity:0.4;cursor:not-allowed;pointer-events:none}"}},[769,"kritzel-button",{variant:[1],disabled:[4],type:[1]}]);function c(){"undefined"!=typeof customElements&&["kritzel-button"].forEach((t=>{"kritzel-button"===t&&(customElements.get(a(t))||customElements.define(a(t),i))}))}export{i as K,c as d}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as a,t,H as e,h as r,d as s}from"./p-
|
|
1
|
+
import{p as a,t,H as e,h as r,d as s}from"./p-CGGiwvWZ.js";import{d as i}from"./p-BueaqfA2.js";const o=a(class extends e{constructor(a){super(),!1!==a&&this.__registerHost(),this.__attachShadow()}users=[];avatarSize=40;maxVisible=3;overlap=20;getDisplayName(a){return a.displayName??([a.firstName,a.lastName].filter(Boolean).join(" ")||a.email||"User")}render(){if(!this.users||0===this.users.length)return r(s,{style:{display:"none"}});const a=this.users.slice(0,this.maxVisible),t=this.users.length-this.maxVisible;return r(s,{style:{"--avatar-overlap":`-${this.overlap}px`}},r("div",{class:"avatars"},a.map(((t,e)=>r("div",{class:"avatar-wrapper",style:{marginLeft:e>0?"var(--avatar-overlap)":"0px",zIndex:""+(a.length-e)}},r("kritzel-avatar",{user:t,size:this.avatarSize}),r("span",{class:"avatar-tooltip"},this.getDisplayName(t)))))),t>0&&r("span",{class:"overflow-count"},"+",t,r("span",{class:"avatar-tooltip"},this.users.slice(this.maxVisible).map((a=>r("div",null,this.getDisplayName(a)))))))}static get style(){return":host{display:inline-flex;align-items:center}.avatars{display:flex;align-items:center}.avatar-wrapper{position:relative;transition:margin-left 200ms ease}.avatar-wrapper kritzel-avatar{border-radius:50%;box-shadow:0 0 0 2px var(--kritzel-active-users-avatar-border-color, #ffffff)}.avatars:hover .avatar-wrapper{margin-left:-6px !important}.avatar-tooltip{position:absolute;top:100%;left:50%;transform:translateX(-50%);margin-top:12px;padding:4px 8px;background-color:var(--kritzel-active-users-tooltip-background, #333333);color:var(--kritzel-active-users-tooltip-color, #ffffff);font-family:sans-serif;font-size:12px;font-weight:500;border-radius:4px;white-space:nowrap;width:max-content;pointer-events:none;opacity:0;transition:opacity 150ms ease}.avatar-wrapper:hover .avatar-tooltip,.overflow-count:hover .avatar-tooltip{opacity:1}.overflow-count{position:relative;margin-left:8px;font-family:sans-serif;font-size:var(--kritzel-active-users-overflow-font-size, 14px);font-weight:500;color:var(--kritzel-active-users-overflow-color, #666666);white-space:nowrap;cursor:default}.overflow-count .avatar-tooltip{white-space:nowrap;text-align:left;margin-top:20px}"}},[513,"kritzel-active-users",{users:[16],avatarSize:[2,"avatar-size"],maxVisible:[2,"max-visible"],overlap:[2]}]);function l(){"undefined"!=typeof customElements&&["kritzel-active-users","kritzel-avatar"].forEach((a=>{switch(a){case"kritzel-active-users":customElements.get(t(a))||customElements.define(t(a),o);break;case"kritzel-avatar":customElements.get(t(a))||i()}}))}export{o as K,l as d}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e,H as t,c as i,h as r,d as o,t as a}from"./p-
|
|
1
|
+
import{p as e,H as t,c as i,h as r,d as o,t as a}from"./p-CGGiwvWZ.js";import{d as s}from"./p-53di1Zko.js";import{d as l}from"./p-l_YGO7RB.js";import{d as n}from"./p-DxzDda_J.js";import{d as p}from"./p-D14QNK3X.js";import{d as c}from"./p-BrZ_gL8Q.js";const d=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.exportPng=i(this,"exportPng"),this.exportSvg=i(this,"exportSvg"),this.exportJson=i(this,"exportJson")}workspaceName="workspace";isDialogOpen=!1;previewUrl;isLoading=!1;activeTab="viewport";exportFilename="";viewportExportFormat="png";exportPng;exportSvg;exportJson;tabs=[{id:"viewport",label:"Export Viewport"},{id:"workspace",label:"Export Workspace"}];viewportFormatOptions=[{value:"png",label:"PNG"},{value:"svg",label:"SVG"}];async open(e){this.previewUrl=e,this.activeTab="viewport",this.viewportExportFormat="png",this.exportFilename=this.generateDefaultFilename(),this.isDialogOpen=!0}generateDefaultFilename(){const e=(new Date).toISOString().replace(/[:.]/g,"-").slice(0,-5);return`${this.workspaceName}-${e}`}handleFilenameChange=e=>{this.exportFilename=e.detail};closeDialog=()=>{this.isDialogOpen=!1};handleTabChange=e=>{this.activeTab=e.detail};handleViewportFormatChange=e=>{this.viewportExportFormat=e.detail};handleExport=()=>{"viewport"===this.activeTab?"png"===this.viewportExportFormat?this.exportPng.emit():this.exportSvg.emit():this.exportJson.emit(this.exportFilename||this.generateDefaultFilename()),this.closeDialog()};renderViewportExport(){return r("div",{class:"export-tab-content"},this.previewUrl&&r("div",{class:"preview-container"},r("img",{src:this.previewUrl,alt:"Viewport Preview"})),r("kritzel-input",{label:"Filename",value:this.exportFilename,placeholder:"Enter filename",suffix:`.${this.viewportExportFormat}`,onValueChange:this.handleFilenameChange}),r("div",{class:"format-selection"},r("label",null,"Format"),r("kritzel-dropdown",{options:this.viewportFormatOptions,value:this.viewportExportFormat,forceOpenDirection:"up",onValueChanged:this.handleViewportFormatChange})))}renderWorkspaceExport(){return r("div",{class:"export-tab-content"},r("kritzel-input",{label:"Filename",value:this.exportFilename,placeholder:"Enter filename",suffix:".json",onValueChange:this.handleFilenameChange}))}render(){return r(o,{key:"89824b452ccc845f4dfd1e13c01a24a72e5d9488"},r("kritzel-dialog",{key:"a9190d093e84b5850146db39e1016abce9de0d83",isOpen:this.isDialogOpen,dialogTitle:"Export",closable:!0,onDialogClose:this.closeDialog},r("div",{key:"3068dbb979a029bf580e2d00a721768bc08d12b3",class:"export-content"},r("kritzel-pill-tabs",{key:"6241491cc549f576b822bc9fda37c9edffd9143f",tabs:this.tabs,value:this.activeTab,onValueChange:this.handleTabChange}),"viewport"===this.activeTab&&this.renderViewportExport(),"workspace"===this.activeTab&&this.renderWorkspaceExport(),r("button",{key:"a9fe2a7ccb5b97095271a6e00fe9585f39b137fc",class:"export-primary-button",onClick:this.handleExport},"Export"))))}static get style(){return":host{display:flex;flex-direction:column;min-height:0}.export-content{display:flex;flex-direction:column;gap:16px;padding:0;flex:1}.export-content kritzel-pill-tabs{align-self:center}.export-tab-content{display:flex;flex-direction:column;gap:16px;min-height:330px}.format-selection{display:flex;flex-direction:column;gap:6px}.format-selection label{font-size:14px;font-weight:500;color:var(--kritzel-global-text-primary, #333)}.export-primary-button{width:100%;padding:12px 24px;background-color:var(--kritzel-global-primary-color, #007AFF);color:var(--kritzel-global-primary-text-color, #fff);border:none;border-radius:8px;font-size:14px;font-weight:600;cursor:pointer;transition:background-color 0.2s ease;-webkit-tap-highlight-color:transparent}.export-primary-button:hover{background-color:var(--kritzel-global-primary-hover-color, #0066d6)}.export-primary-button:focus-visible{outline:revert;outline-offset:revert}.preview-container{width:100%;display:flex;justify-content:center;align-items:center;box-sizing:border-box;margin-bottom:8px}.preview-container img{max-width:100%;max-height:250px;object-fit:contain;box-shadow:0 4px 8px rgba(0, 0, 0, 0.15);border-radius:4px;border:1px solid var(--kritzel-global-border-color, #dbdbdb)}.export-content p{margin:0;color:var(--kritzel-global-text-secondary, #666)}@media (max-width: 576px){.export-tab-content{flex:1;min-height:0}}"}},[513,"kritzel-export",{workspaceName:[1,"workspace-name"],isDialogOpen:[32],previewUrl:[32],isLoading:[32],activeTab:[32],exportFilename:[32],viewportExportFormat:[32],open:[64]}]);function h(){"undefined"!=typeof customElements&&["kritzel-export","kritzel-dialog","kritzel-dropdown","kritzel-icon","kritzel-input","kritzel-pill-tabs"].forEach((e=>{switch(e){case"kritzel-export":customElements.get(a(e))||customElements.define(a(e),d);break;case"kritzel-dialog":customElements.get(a(e))||s();break;case"kritzel-dropdown":customElements.get(a(e))||l();break;case"kritzel-icon":customElements.get(a(e))||n();break;case"kritzel-input":customElements.get(a(e))||p();break;case"kritzel-pill-tabs":customElements.get(a(e))||c()}}))}export{d as K,h as d}
|