kritzel-stencil 0.3.13 → 0.3.15
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.cjs.js +1 -1
- package/dist/cjs/kritzel-active-users_42.cjs.entry.js +156 -25
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{schema.constants-CMFOYyBj.js → schema.constants-DJQTjcy7.js} +62 -0
- package/dist/cjs/stencil.cjs.js +1 -1
- package/dist/collection/classes/core/viewport.class.js +81 -0
- package/dist/collection/classes/objects/image.class.js +62 -0
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +86 -18
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +169 -17
- package/dist/collection/constants/version.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-editor.js +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/kritzel-settings.js +1 -1
- package/dist/components/kritzel-tool-config.js +1 -1
- package/dist/components/p-BTEV1WwT.js +1 -0
- package/dist/components/{p-ijIqLY9g.js → p-CUFKqzMC.js} +1 -1
- package/dist/components/{p-B9hLySCl.js → p-CUPYGT8c.js} +1 -1
- package/dist/components/p-Dc0a_Hb-.js +9 -0
- package/dist/components/{p-CVzH1Oil.js → p-J9_SwObO.js} +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/kritzel-active-users_42.entry.js +156 -25
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{schema.constants-NrtFvKER.js → schema.constants-DiCnmIYK.js} +62 -0
- package/dist/esm/stencil.js +1 -1
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/{p-NrtFvKER.js → p-DiCnmIYK.js} +1 -1
- package/dist/stencil/p-bbebe56c.entry.js +9 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/core/viewport.class.d.ts +30 -0
- package/dist/types/classes/objects/image.class.d.ts +15 -0
- package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +11 -3
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +33 -5
- package/dist/types/components.d.ts +28 -6
- package/dist/types/constants/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/components/p-C-aFOO5p.js +0 -1
- package/dist/components/p-DplAQ6jk.js +0 -9
- package/dist/stencil/p-9adee165.entry.js +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as e,c as s,h as i,d as n,t as o}from"./p-B43upypT.js";import{K as r,d as a}from"./p-DbB730vO.js";import{D as c,g as h,S as l,e as d,d as u,h as p,i as m,j as g}from"./p-B9hLySCl.js";import{h as b,i as f,K as y,b as k,a as w,d as v,c as z,g as C,D as j,j as A}from"./p-DplAQ6jk.js";import{D as S,T as x,d as O,l as E}from"./p-2xYAGd0I.js";import{K as T}from"./p-jGOpkGDl.js";import"./p-CFgkUYoO.js";import*as I from"yjs";import"y-indexeddb";import"y-websocket";import{d as M}from"./p-BiG1dxPS.js";import{d as U}from"./p-BfNHpqQ8.js";import{d as D}from"./p-DM11KXUT.js";import{d as B}from"./p-Bj2laX89.js";import{d as R}from"./p-UoPj5QjH.js";import{d as W}from"./p-skWUIStn.js";import{d as V}from"./p-BFoK4W--.js";import{d as P}from"./p-B2w8X7vn.js";import{d as F}from"./p-CVzH1Oil.js";import{d as L}from"./p-DDYoDSrm.js";import{d as N}from"./p-BqwqGFQY.js";import{d as Y}from"./p-B4b6TDxp.js";import{d as H}from"./p-CHrSFOSI.js";import{d as J}from"./p-Df3BwVGy.js";import{d as K}from"./p-C0TN5IAi.js";import{d as G}from"./p-CmuNn1Tc.js";import{d as q}from"./p-JhOYwUOj.js";import{d as Q}from"./p-FK7b3BGt.js";import{d as $}from"./p-CJOhfMU5.js";import{d as X}from"./p-CXpv9Rxe.js";import{d as _}from"./p-BzYU3-MJ.js";import{d as Z}from"./p-D-sRVAbQ.js";import{d as tt,a as et}from"./p-SptaSMno.js";import{d as st}from"./p-DlwYHzSj.js";import{d as it}from"./p-B5xxfwKF.js";import{d as nt}from"./p-DEy7zJCe.js";import{d as ot}from"./p-C2SX-XRr.js";import{d as rt}from"./p-BYmp9Ovv.js";import{d as at}from"./p-ijIqLY9g.js";import{d as ct}from"./p-BFYtCsZu.js";import{d as ht}from"./p-COgo9OWy.js";import{d as lt}from"./p-x6doYeiI.js";import{d as dt}from"./p-COLHjboZ.js";import{d as ut}from"./p-B2Os1ya_.js";import{d as pt}from"./p-C-aFOO5p.js";import{d as mt}from"./p-dcAernE1.js";import{d as gt}from"./p-CcyIAi9S.js";import{d as bt}from"./p-BbactVA0.js";const ft=Math.floor,yt=127,kt=Number.MAX_SAFE_INTEGER,wt="undefined"!=typeof TextEncoder?new TextEncoder:null,vt=wt?t=>wt.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 zt="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});zt&&1===zt.decode(new Uint8Array).length&&(zt=null);const Ct=(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},jt=(t,e)=>{for(;e>yt;)Ct(t,128|yt&e),e=ft(e/128);Ct(t,yt&e)},At=new Uint8Array(3e4),St=At.length/3,xt=wt&&wt.encodeInto?(t,e)=>{if(e.length<St){const s=wt.encodeInto(e,At).written||0;jt(t,s);for(let e=0;e<s;e++)Ct(t,At[e])}else Ot(t,vt(e))}:(t,e)=>{const s=unescape(encodeURIComponent(e)),i=s.length;jt(t,i);for(let e=0;e<i;e++)Ct(t,s.codePointAt(e))},Ot=(t,e)=>{jt(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)},Et=t=>Error(t),Tt=Et("Unexpected end of array"),It=Et("Integer out of Range"),Mt=t=>t.arr[t.pos++],Ut=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&yt)*s,s*=128,i<128)return e;if(e>kt)throw It}throw Tt},Dt=zt?t=>zt.decode((t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,Ut(t)))(t)):t=>{let e=Ut(t);if(0===e)return"";{let s=String.fromCodePoint(Mt(t));if(--e<100)for(;e--;)s+=String.fromCodePoint(Mt(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 Bt;!function(t){t[t.Token=0]="Token",t[t.PermissionDenied=1]="PermissionDenied",t[t.Authenticated=2]="Authenticated"}(Bt||(Bt={}));const Rt=t=>Array.from(t.entries()).map((([t,e])=>({clientId:t,...e})));var Wt;async function Vt(t){return new Promise((e=>setTimeout(e,t)))}function Pt(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"}(Wt||(Wt={}));const Ft=Math.floor,Lt=128,Nt=127,Yt=Number.MAX_SAFE_INTEGER,Ht=()=>new Set,Jt=Array.from,Kt="undefined"!=typeof TextEncoder?new TextEncoder:null,Gt=Kt?t=>Kt.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 qt="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});qt&&1===qt.decode(new Uint8Array).length&&(qt=null);class Qt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const $t=()=>new Qt,Xt=t=>{let e=t.cpos;for(let s=0;s<t.bufs.length;s++)e+=t.bufs[s].length;return e},_t=t=>{const e=new Uint8Array(Xt(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},Zt=(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},te=(t,e)=>{for(;e>Nt;)Zt(t,Lt|Nt&e),e=Ft(e/128);Zt(t,Nt&e)},ee=new Uint8Array(3e4),se=ee.length/3,ie=Kt&&Kt.encodeInto?(t,e)=>{if(e.length<se){const s=Kt.encodeInto(e,ee).written||0;te(t,s);for(let e=0;e<s;e++)Zt(t,ee[e])}else ne(t,Gt(e))}:(t,e)=>{const s=unescape(encodeURIComponent(e)),i=s.length;te(t,i);for(let e=0;e<i;e++)Zt(t,s.codePointAt(e))},ne=(t,e)=>{te(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)},oe=t=>Error(t),re=oe("Unexpected end of array"),ae=oe("Integer out of Range");class ce{constructor(t){this.arr=t,this.pos=0}}const he=t=>new ce(t),le=t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,ue(t)),de=t=>t.arr[t.pos++],ue=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&Nt)*s,s*=128,i<Lt)return e;if(e>Yt)throw ae}throw re},pe=qt?t=>qt.decode(le(t)):t=>{let e=ue(t);if(0===e)return"";{let s=String.fromCodePoint(de(t));if(--e<100)for(;e--;)s+=String.fromCodePoint(de(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))}},me=Date.now,ge=()=>new Map;class be{constructor(){this._observers=ge()}on(t,e){((t,e,s)=>{let i=t.get(e);return void 0===i&&t.set(e,i=s()),i})(this._observers,t,Ht).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 Jt((this._observers.get(t)||ge()).values()).forEach((t=>t(...e)))}destroy(){this._observers=ge()}}const fe=Object.keys,ye=t=>fe(t).length,ke=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),we=(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)||!we(t.get(s),e.get(s)))return!1;break;case Object:if(ye(t)!==ye(e))return!1;for(const s in t)if(!ke(t,s)||!we(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(!we(t[s],e[s]))return!1;break;default:return!1}return!0};class ve extends be{constructor(t){super(),this.doc=t,this.clientID=t.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval((()=>{const t=me();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&&ze(this,e,"timeout")}),Ft(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:me()});const o=[],r=[],a=[],c=[];null===t?c.push(e):null==n?null!=t&&o.push(e):(r.push(e),we(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 ze=(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:me()})}i.push(n)}}i.length>0&&(t.emit("change",[{added:[],updated:[],removed:i},s]),t.emit("update",[{added:[],updated:[],removed:i},s]))},Ce=(t,e,s=t.states)=>{const i=e.length,n=$t();te(n,i);for(let o=0;o<i;o++){const i=e[o],r=s.get(i)||null,a=t.meta.get(i).clock;te(n,i),te(n,a),ie(n,JSON.stringify(r))}return _t(n)};class je{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 Ae{constructor(t){this.data=t,this.encoder=$t(),this.decoder=he(new Uint8Array(this.data))}peekVarString(){return(t=>{const e=t.pos,s=pe(t);return t.pos=e,s})(this.decoder)}readVarUint(){return ue(this.decoder)}readVarString(){return pe(this.decoder)}readVarUint8Array(){return le(this.decoder)}writeVarUint(t){return te(this.encoder,t)}writeVarString(t){return ie(this.encoder,t)}writeVarUint8Array(t){return ne(this.encoder,t)}length(){return Xt(this.encoder)}}var Se,xe;!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"}(Se||(Se={})),function(t){t.Connecting="connecting",t.Connected="connected",t.Disconnected="disconnected"}(xe||(xe={}));class Oe{constructor(){this.encoder=$t()}get(t){return t.encoder}toUint8Array(){return _t(this.encoder)}}class Ee extends Oe{constructor(){super(...arguments),this.type=Se.CLOSE,this.description="Ask the server to close the connection"}get(t){return ie(this.encoder,t.documentName),te(this.encoder,this.type),this.encoder}}class Te extends je{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=xe.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=xe.Connected,this.emit("status",{status:xe.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=t}attach(t){this.configuration.providerMap.set(t.configuration.name,t),this.status===xe.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===xe.Connected&&t.onOpen(this.receivedOnOpenPayload)}detach(t){this.configuration.providerMap.has(t.configuration.name)&&(t.send(Ee,{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===xe.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||Pt,o=s.calculateDelay?s.calculateDelay(i,s):s.initialDelay;if(o&&await Vt(o),i.attemptNum<1&&s.initialJitter){const t=n(i,s);t&&await Vt(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 Vt(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=xe.Connecting,this.emit("status",{status:xe.Connecting}),this.connectionAttempt={resolve:t,reject:e}}))}onMessage(t){var e;this.resolveConnectionAttempt(),this.lastMessageReceived=me();const s=new Ae(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=xe.Connected,this.emit("status",{status:xe.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===xe.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=me()-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)===Wt.Open?this.webSocket.send(t):this.messageQueue.push(t)}onClose({event:t}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=xe.Disconnected,this.emit("status",{status:xe.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 Ie=(t,e,s)=>{try{I.applyUpdate(e,le(t),s)}catch(t){console.error("Caught error while handling a Yjs update",t)}},Me=Ie;class Ue{constructor(t){this.message=t}apply(t,e){const{message:s}=this,i=s.readVarUint(),n=s.length();switch(i){case Se.Sync:this.applySyncMessage(t,e);break;case Se.Awareness:this.applyAwarenessMessage(t);break;case Se.Auth:this.applyAuthMessage(t);break;case Se.QueryAwareness:this.applyQueryAwarenessMessage(t);break;case Se.Stateless:t.receiveStateless(pe(s.decoder));break;case Se.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&Lt))return n*s;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],s+=(e&Nt)*i,i*=128,e<Lt)return n*s;if(s>Yt)throw ae}throw re})(s.decoder));break;case Se.CLOSE:const n={code:1e3,reason:pe(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(Oe,{encoder:s.encoder})}applySyncMessage(t,e){const{message:s}=this;s.writeVarUint(Se.Sync);const i=((t,e,s,i)=>{const n=ue(t);switch(n){case 0:((t,e,s)=>{((t,e,s)=>{te(t,1),ne(t,I.encodeStateAsUpdate(e,s))})(e,s,le(t))})(t,e,s);break;case 1:Ie(t,s,i);break;case 2:Me(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=he(e),n=me(),o=[],r=[],a=[],c=[],h=ue(i);for(let e=0;e<h;e++){const e=ue(i);let s=ue(i);const h=JSON.parse(pe(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&&(we(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(Ut(t)){case Bt.Token:e();break;case Bt.PermissionDenied:s(Dt(t));break;case Bt.Authenticated:i(Dt(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(Se.Awareness),e.writeVarUint8Array(Ce(t.awareness,Array.from(t.awareness.getStates().keys())))}}class De{constructor(t,e={}){this.message=new t,this.encoder=this.message.get(e)}create(){return _t(this.encoder)}send(t){null==t||t.send(this.create())}}class Be extends Oe{constructor(){super(...arguments),this.type=Se.Auth,this.description="Authentication"}get(t){if(void 0===t.token)throw Error("The authentication message requires `token` as an argument.");return ie(this.encoder,t.documentName),te(this.encoder,this.type),((t,e)=>{jt(t,Bt.Token),xt(t,e)})(this.encoder,t.token),this.encoder}}class Re extends Oe{constructor(){super(...arguments),this.type=Se.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 ie(this.encoder,t.documentName),te(this.encoder,this.type),e=void 0===t.states?Ce(t.awareness,t.clients):Ce(t.awareness,t.clients,t.states),ne(this.encoder,e),this.encoder}}class We extends Oe{constructor(){super(...arguments),this.type=Se.Stateless,this.description="A stateless message"}get(t){var e;return ie(this.encoder,t.documentName),te(this.encoder,this.type),ie(this.encoder,null!==(e=t.payload)&&void 0!==e?e:""),this.encoder}}class Ve extends Oe{constructor(){super(...arguments),this.type=Se.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 ie(this.encoder,t.documentName),te(this.encoder,this.type),((t,e)=>{te(t,0);const s=I.encodeStateVector(e);ne(t,s)})(this.encoder,t.document),this.encoder}}class Pe extends Oe{constructor(){super(...arguments),this.type=Se.Sync,this.description="A document update"}get(t){return ie(this.encoder,t.documentName),te(this.encoder,this.type),((t,e)=>{te(t,2),ne(t,e)})(this.encoder,t.update),this.encoder}}class Fe extends Error{constructor(){super(...arguments),this.code=1001}}class Le extends je{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 I.Doc,this.configuration.awareness=void 0!==t.awareness?t.awareness:new ve(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:Rt(this.awareness.getStates())})})),null===(s=this.awareness)||void 0===s||s.on("change",(()=>{this.emit("awarenessChange",{states:Rt(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 Te(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(Ve,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&ze(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){"undefined"!=typeof window&&"addEventListener"in window&&window.addEventListener("pagehide",this.boundPageHide)}sendStateless(t){this.send(We,{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(Be,{token:null!=t?t:"",documentName:this.configuration.name})}documentUpdateHandler(t,e){e!==this&&(this.incrementUnsyncedChanges(),this.send(Pe,{update:t,documentName:this.configuration.name}))}awarenessUpdateHandler({added:t,updated:e,removed:s},i){const n=t.concat(e).concat(s);this.send(Re,{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(Ve,{document:this.document,documentName:this.configuration.name}),this.awareness&&null!==this.awareness.getLocalState()&&this.send(Re,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(t,e){if(!this._isAttached)return;const s=new De(t,e);this.emit("outgoingMessage",{message:s.message}),s.send(this.configuration.websocketProvider)}onMessage(t){const e=new Ae(t.data),s=e.readVarString();e.writeVarString(s),this.emit("message",{event:t,message:new Ae(t.data)}),new Ue(e).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&ze(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&&(ze(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 Fe(`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 Ne={type:"pen",color:S[0],size:16,opacity:1,palettes:{pen:[...S]},sizes:{pen:[...c]}},Ye={color:S[0],size:8,opacity:1,fontFamily:"Arial",palette:[...S],sizes:[...h]},He={color:S[0],size:4,opacity:1,palette:[...S],sizes:[...c],arrows:{end:{enabled:!0,style:"triangle"}}},Je={providers:[]},Ke={shapeType:l.Rectangle,fillColor:{light:"transparent",dark:"transparent"},strokeColor:S[0],strokeWidth:4,opacity:1,fontColor:S[0],fontSize:16,fontFamily:"Arial",palette:[...S],sizes:[...c]},Ge=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=b;scaleMin=f;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:d,icon:"cursor"},{name:"brush",type:"tool",tool:y,icon:"pen",config:Ne},{name:"eraser",type:"tool",tool:k,icon:"eraser"},{name:"line",type:"tool",tool:w,icon:"arrow",config:He},{name:"shape",type:"tool",tool:v,icon:"shape-rectangle",config:Ke,subOptions:[{id:"rectangle",icon:"shape-rectangle",label:"Rectangle",value:l.Rectangle,toolProperty:"shapeType"},{id:"ellipse",icon:"shape-ellipse",label:"Ellipse",value:l.Ellipse,toolProperty:"shapeType"},{id:"triangle",icon:"shape-triangle",label:"Triangle",value:l.Triangle,toolProperty:"shapeType"}]},{name:"text",type:"tool",tool:u,icon:"type",config:Ye},{name:"image",type:"tool",tool:z,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:"Cut",icon:"cut",group:"clipboard",action:()=>this.engineRef.cut()},{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(C.StartHorizontal)},{label:"Align Center Horizontally",icon:"align-center-horizontal",action:()=>this.engineRef.alignObjects(C.CenterHorizontal)},{label:"Align Right",icon:"align-end-vertical",action:()=>this.engineRef.alignObjects(C.EndHorizontal)},{label:"Align Top",icon:"align-start-horizontal",action:()=>this.engineRef.alignObjects(C.StartVertical)},{label:"Align Center Vertically",icon:"align-center-vertical",action:()=>this.engineRef.alignObjects(C.CenterVertical)},{label:"Align Bottom",icon:"align-end-horizontal",action:()=>this.engineRef.alignObjects(C.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()}];themes;theme="light";customSvgIcons={};isControlsVisible=!0;isUtilityPanelVisible=!0;isWorkspaceManagerVisible=!0;isMoreMenuVisible=!0;isObjectDistanceFadingActive=!1;syncConfig=j;assetStorageConfig=Je;cursorTarget;loginConfig;isLoading=!1;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;shortcuts=[];currentIsPublic=!1;isEditorVisible=!1;onIsEngineReady(t){t&&this.isControlsReady&&this.checkIsReady()}onIsControlsReady(t){t&&this.isEngineReady&&this.checkIsReady()}onWorkspacesChange(t){const e=this.activeWorkspace;if(e){const s=t.find((t=>t.id===e.id));s&&s!==e&&(this.activeWorkspace=s)}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(){this.applyTheme(),setTimeout((()=>this.setOsSpecificCssVariables()),0),this.engineRef&&this.engineRef.saveSettings(this.currentSettingsConfig)}onThemesChange(){this.applyTheme()}onTouchStart(t){t.cancelable&&t.preventDefault()}async getObjectById(t){return this.engineRef.getObjectById(t)}async addObject(t){return this.engineRef.addObject(t)}async addObjects(t){return this.engineRef.addObjects(t)}async updateObject(t,e){return this.engineRef.updateObject(t,e)}async removeObject(t){return this.engineRef.removeObject(t)}async removeObjects(t){return this.engineRef.removeObjects(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 panToObject(t){return this.engineRef.panToObject(t)}async backToContent(){return this.engineRef.backToContent()}async centerAllObjects(t=!0){return this.engineRef.centerAllObjects(t)}async centerObjects(t,e=!0){return this.engineRef.centerObjects(t,e)}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 changeActiveToolByName(t){return this.engineRef.changeActiveToolByName(t)}async disable(){return this.engineRef.disable()}async enable(){return this.engineRef.enable()}async copy(){return this.engineRef.copy()}async cut(){return this.engineRef.cut()}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 exportSelectedObjectsAsPng(){return this.engineRef.exportSelectedObjectsAsPng()}async exportSelectedObjectsAsSvg(){return this.engineRef.exportSelectedObjectsAsSvg()}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 openContextMenu(t){return this.engineRef.openContextMenu(t)}async triggerSelectionChange(){return this.engineRef.triggerSelectionChange()}async getDisplayableShortcuts(){return this.engineRef.getDisplayableShortcuts()}engineRef;controlsRef;settingsRef;exportRef;splitButtonRef;shareDialogRef;loginDialogRef;componentWillLoad(){this.loadSettingsFromStorage(),this.applyTheme()}applyTheme(){const t=this.resolveThemeObject();x.applyThemeToElement(this.host,t)}resolveThemeObject(){return this.themes?.find((t=>t.name===this.theme))??("dark"===this.theme?O:E)}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&&this.activeWorkspace))return;this.isEditorVisible=!0;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,assetStorageConfig:this.assetStorageConfig,loginConfig:this.loginConfig,theme:this.theme})}async onEngineReady(t){this.isEngineReady=!0,t.detail.activeWorkspace&&(this.activeWorkspace=t.detail.activeWorkspace,this.workspaces=t.detail.workspaces,this.currentIsPublic=await this.engineRef.getIsPublic(),this.loadShortcuts())}handleWorkspacesChange(t){t.stopPropagation(),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){t.stopPropagation(),this.objectsChange.emit(t.detail)}handleObjectsAdded(t){t.stopPropagation(),this.objectsAdded.emit(t.detail)}handleObjectsRemoved(t){t.stopPropagation(),this.objectsRemoved.emit(t.detail)}handleObjectsUpdated(t){t.stopPropagation(),this.objectsUpdated.emit(t.detail)}handleUndoStateChange(t){t.stopPropagation(),this.undoStateChange.emit(t.detail),this.undoState=t.detail}async handleObjectsInViewportChange(t){t.stopPropagation();const e=this.getContentObjects(t.detail).length>0,s=this.getContentObjects(await this.engineRef.getAllObjects()).length>0;this.isBackToContentButtonVisible=!e&&s}handleViewportChange(t){t.stopPropagation(),this.viewportChange.emit(t.detail)}handleAwarenessChange(t){t.stopPropagation(),this.awarenessChange.emit(t.detail)}handleSettingsChange(t){this.scaleMin=t.detail.scaleMin,this.scaleMax=t.detail.scaleMax,this.lockDrawingScale=t.detail.lockDrawingScale,this.theme=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.engineRef&&this.engineRef.saveSettings(t.detail),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??void 0)}},{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:s.id})};updateCurrentIsPublic(){const t=this.activeWorkspace?.isPublic??!1,e=this.activeWorkspace?.id;this.currentIsPublic=t,e&&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),"string"==typeof e.theme&&(this.theme=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()}get currentSettingsConfig(){return{scaleMin:this.scaleMin,scaleMax:this.scaleMax,lockDrawingScale:this.lockDrawingScale,theme:this.theme,viewportBoundaryLeft:this.viewportBoundaryLeft,viewportBoundaryRight:this.viewportBoundaryRight,viewportBoundaryTop:this.viewportBoundaryTop,viewportBoundaryBottom:this.viewportBoundaryBottom,debugInfo:this.debugInfo}}getContentObjects(t){return t.filter((t=>!(t instanceof p||t instanceof m)))}registerCustomSvgIcons(){for(const[t,e]of Object.entries(this.customSvgIcons))r.register(t,e)}listenForMobileKeyboard(){g.onKeyboardVisibleChanged((t=>{this.isVirtualKeyboardOpen=t}))}setOsSpecificCssVariables(){switch(T.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.isReady&&!!this.loginConfig&&!t;return i(n,{key:"673bfb4d2d5224c3c3a11bada8afb1c3b90aa03d",style:{opacity:this.isEditorVisible?"1":"0",visibility:this.isEditorVisible?"visible":"hidden",transition:"opacity 0.2s ease-in-out, visibility 0.2s ease-in-out"}},i("div",{key:"cee9075de7a44953b3d017c334b19151ab7bb926",class:"top-left-buttons"},i("kritzel-workspace-manager",{key:"a7a6c246dabe3ddbab3d807a9f0c275bc621363f",visible:this.isWorkspaceManagerVisible,workspaces:this.workspaces,activeWorkspace:this.activeWorkspace,onWorkspaceChange:t=>this.activeWorkspace=t.detail,onIsWorkspaceManagerReady:()=>this.isWorkspaceManagerReady=!0}),i("kritzel-back-to-content",{key:"b5452a22f7fd434b8816bdaa117d457b2f1879f3",visible:this.isBackToContentButtonVisible,onBackToContent:()=>this.backToContent()})),i("kritzel-engine",{key:"a08648ec91f678724171238735b1073ffb53ca73",ref:t=>{t&&(this.engineRef=t)},workspace:this.activeWorkspace,activeWorkspaceId:this.activeWorkspaceId,editorId:this.editorId,syncConfig:this.syncConfig,assetStorageConfig:this.assetStorageConfig,user:this.user,scaleMax:this.scaleMax,lockDrawingScale:this.lockDrawingScale,isObjectDistanceFadingActive:this.isObjectDistanceFadingActive,scaleMin:this.scaleMin,cursorTarget:this.cursorTarget,isLoading:this.isLoading,viewportBoundaryLeft:this.viewportBoundaryLeft,viewportBoundaryRight:this.viewportBoundaryRight,viewportBoundaryTop:this.viewportBoundaryTop,viewportBoundaryBottom:this.viewportBoundaryBottom,wheelEnabled:this.wheelEnabled,theme:this.theme,themes:this.themes,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:"a7b78a31bda3fe2fe1def6be339894b83ea3ee38",visible:this.isControlsVisible,class:{"keyboard-open":this.isVirtualKeyboardOpen},ref:t=>{t&&(this.controlsRef=t)},controls:this.controls,isUtilityPanelVisible:this.isUtilityPanelVisible,undoState:this.undoState??void 0,theme:this.theme,onIsControlsReady:()=>this.isControlsReady=!0}),i("div",{key:"0b3f4879c44864661a5bf5f126da3a869fa808f5",class:"top-right-buttons"},i("kritzel-settings",{key:"7da7fb709f2e4a31a6df1f7382a91f4d78dc6e35",ref:t=>{t&&(this.settingsRef=t)},shortcuts:this.shortcuts,availableThemes:this.themes&&this.themes.length>0?this.themes.map((t=>t.name)):["light","dark"],settings:this.currentSettingsConfig,onSettingsChange:t=>this.handleSettingsChange(t)}),i("kritzel-export",{key:"f362b0181231da30efc927cbebd818a9a64991b0",ref:t=>{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:"1cf065fed9b27ffb19a3695425c797a3bc29fa51",users:this.activeUsers}),e&&i("kritzel-current-user",{key:"7d6e8e227f36164daed7303645bdd490b362b4d0",user:this.user}),s&&i("kritzel-button",{key:"1dcf1f5ae547f4c2c5b7ec88b34bcad0a2a4da28",onButtonClick:()=>this.loginDialogRef?.open()},"Sign in"),i("kritzel-more-menu",{key:"cb80dea4bb9861b6d627399c9aad64075cb8944b",items:this.moreMenuItems,visible:this.isMoreMenuVisible}),i("kritzel-share-dialog",{key:"d12bc96d7af23941e4e054dadfddcf6429de6208",ref:t=>{t&&(this.shareDialogRef=t)},isPublic:this.currentIsPublic,workspaceId:this.activeWorkspace?.id,onToggleIsPublic:this.handleToggleIsPublic}),this.loginConfig&&i("kritzel-login-dialog",{key:"6c29a13069cd74972e94bbc245f26375fa95f4cc",ref:t=>{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}],theme:[{onCurrentThemeChange:0}],themes:[{onThemesChange: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;text-align:start;line-height:normal}kritzel-controls{position:absolute;left:0;right:0;margin-inline:auto;width:max-content;max-width:calc(100% - 16px);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],themes:[16],theme:[1025],customSvgIcons:[16],isControlsVisible:[4,"is-controls-visible"],isUtilityPanelVisible:[4,"is-utility-panel-visible"],isWorkspaceManagerVisible:[4,"is-workspace-manager-visible"],isMoreMenuVisible:[4,"is-more-menu-visible"],isObjectDistanceFadingActive:[4,"is-object-distance-fading-active"],syncConfig:[16],assetStorageConfig:[16],cursorTarget:[16],loginConfig:[16],isLoading:[4,"is-loading"],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],shortcuts:[32],currentIsPublic:[32],isEditorVisible:[32],getObjectById:[64],addObject:[64],addObjects:[64],updateObject:[64],removeObject:[64],removeObjects:[64],getSelectedObjects:[64],selectObjects:[64],selectAllObjectsInViewport:[64],clearSelection:[64],centerObjectInViewport:[64],panToObject:[64],backToContent:[64],centerAllObjects:[64],centerObjects:[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],changeActiveToolByName:[64],disable:[64],enable:[64],copy:[64],cut:[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],exportSelectedObjectsAsPng:[64],exportSelectedObjectsAsSvg:[64],downloadAsJson:[64],importFromFile:[64],loadObjectsFromJson:[64],getObjectsTotalCount:[64],getAllObjects:[64],findObjects:[64],getCopiedObjects:[64],getObjectsInViewport:[64],hideContextMenu:[64],openContextMenu:[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}],theme:[{onCurrentThemeChange:0}],themes:[{onThemesChange:0}]}]),qe=Ge,Qe=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),Ge);break;case"kritzel-active-users":customElements.get(o(t))||M();break;case"kritzel-avatar":customElements.get(o(t))||U();break;case"kritzel-awareness-cursors":customElements.get(o(t))||D();break;case"kritzel-back-to-content":customElements.get(o(t))||B();break;case"kritzel-button":customElements.get(o(t))||R();break;case"kritzel-color":customElements.get(o(t))||W();break;case"kritzel-color-palette":customElements.get(o(t))||V();break;case"kritzel-context-menu":customElements.get(o(t))||P();break;case"kritzel-controls":customElements.get(o(t))||F();break;case"kritzel-current-user":customElements.get(o(t))||L();break;case"kritzel-current-user-dialog":customElements.get(o(t))||N();break;case"kritzel-cursor-trail":customElements.get(o(t))||Y();break;case"kritzel-dialog":customElements.get(o(t))||H();break;case"kritzel-dropdown":customElements.get(o(t))||J();break;case"kritzel-engine":customElements.get(o(t))||A();break;case"kritzel-export":customElements.get(o(t))||K();break;case"kritzel-font":customElements.get(o(t))||G();break;case"kritzel-font-family":customElements.get(o(t))||q();break;case"kritzel-font-size":customElements.get(o(t))||Q();break;case"kritzel-icon":customElements.get(o(t))||a();break;case"kritzel-input":customElements.get(o(t))||$();break;case"kritzel-line-endings":customElements.get(o(t))||X();break;case"kritzel-login-dialog":customElements.get(o(t))||_();break;case"kritzel-master-detail":customElements.get(o(t))||Z();break;case"kritzel-menu":customElements.get(o(t))||et();break;case"kritzel-menu-item":customElements.get(o(t))||tt();break;case"kritzel-more-menu":customElements.get(o(t))||st();break;case"kritzel-numeric-input":customElements.get(o(t))||it();break;case"kritzel-opacity-slider":customElements.get(o(t))||nt();break;case"kritzel-pill-tabs":customElements.get(o(t))||ot();break;case"kritzel-portal":customElements.get(o(t))||rt();break;case"kritzel-settings":customElements.get(o(t))||at();break;case"kritzel-shape-fill":customElements.get(o(t))||ct();break;case"kritzel-share-dialog":customElements.get(o(t))||ht();break;case"kritzel-slide-toggle":customElements.get(o(t))||lt();break;case"kritzel-split-button":customElements.get(o(t))||dt();break;case"kritzel-stroke-size":customElements.get(o(t))||ut();break;case"kritzel-tool-config":customElements.get(o(t))||pt();break;case"kritzel-tooltip":customElements.get(o(t))||mt();break;case"kritzel-utility-panel":customElements.get(o(t))||gt();break;case"kritzel-workspace-manager":customElements.get(o(t))||bt()}}))};export{Ne as D,Le as H,qe as KritzelEditor,Te as a,Ye as b,He as c,Je as d,Qe as defineCustomElement}
|
|
1
|
+
import{p as t,H as e,c as s,h as i,d as n,t as o}from"./p-B43upypT.js";import{K as r,d as a}from"./p-DbB730vO.js";import{D as c,g as h,S as l,e as d,d as u,h as p,i as m,j as g}from"./p-CUPYGT8c.js";import{h as b,i as f,K as y,b as k,a as w,d as v,c as z,g as C,D as j,j as A}from"./p-Dc0a_Hb-.js";import{D as S,T as x,d as O,l as E}from"./p-2xYAGd0I.js";import{K as T}from"./p-jGOpkGDl.js";import"./p-CFgkUYoO.js";import*as I from"yjs";import"y-indexeddb";import"y-websocket";import{d as M}from"./p-BiG1dxPS.js";import{d as U}from"./p-BfNHpqQ8.js";import{d as D}from"./p-DM11KXUT.js";import{d as B}from"./p-Bj2laX89.js";import{d as W}from"./p-UoPj5QjH.js";import{d as R}from"./p-skWUIStn.js";import{d as V}from"./p-BFoK4W--.js";import{d as P}from"./p-B2w8X7vn.js";import{d as F}from"./p-J9_SwObO.js";import{d as L}from"./p-DDYoDSrm.js";import{d as N}from"./p-BqwqGFQY.js";import{d as Y}from"./p-B4b6TDxp.js";import{d as H}from"./p-CHrSFOSI.js";import{d as J}from"./p-Df3BwVGy.js";import{d as K}from"./p-C0TN5IAi.js";import{d as G}from"./p-CmuNn1Tc.js";import{d as q}from"./p-JhOYwUOj.js";import{d as $}from"./p-FK7b3BGt.js";import{d as Q}from"./p-CJOhfMU5.js";import{d as X}from"./p-CXpv9Rxe.js";import{d as _}from"./p-BzYU3-MJ.js";import{d as Z}from"./p-D-sRVAbQ.js";import{d as tt,a as et}from"./p-SptaSMno.js";import{d as st}from"./p-DlwYHzSj.js";import{d as it}from"./p-B5xxfwKF.js";import{d as nt}from"./p-DEy7zJCe.js";import{d as ot}from"./p-C2SX-XRr.js";import{d as rt}from"./p-BYmp9Ovv.js";import{d as at}from"./p-CUFKqzMC.js";import{d as ct}from"./p-BFYtCsZu.js";import{d as ht}from"./p-COgo9OWy.js";import{d as lt}from"./p-x6doYeiI.js";import{d as dt}from"./p-COLHjboZ.js";import{d as ut}from"./p-B2Os1ya_.js";import{d as pt}from"./p-BTEV1WwT.js";import{d as mt}from"./p-dcAernE1.js";import{d as gt}from"./p-CcyIAi9S.js";import{d as bt}from"./p-BbactVA0.js";const ft=Math.floor,yt=127,kt=Number.MAX_SAFE_INTEGER,wt="undefined"!=typeof TextEncoder?new TextEncoder:null,vt=wt?t=>wt.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 zt="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});zt&&1===zt.decode(new Uint8Array).length&&(zt=null);const Ct=(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},jt=(t,e)=>{for(;e>yt;)Ct(t,128|yt&e),e=ft(e/128);Ct(t,yt&e)},At=new Uint8Array(3e4),St=At.length/3,xt=wt&&wt.encodeInto?(t,e)=>{if(e.length<St){const s=wt.encodeInto(e,At).written||0;jt(t,s);for(let e=0;e<s;e++)Ct(t,At[e])}else Ot(t,vt(e))}:(t,e)=>{const s=unescape(encodeURIComponent(e)),i=s.length;jt(t,i);for(let e=0;e<i;e++)Ct(t,s.codePointAt(e))},Ot=(t,e)=>{jt(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)},Et=t=>Error(t),Tt=Et("Unexpected end of array"),It=Et("Integer out of Range"),Mt=t=>t.arr[t.pos++],Ut=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&yt)*s,s*=128,i<128)return e;if(e>kt)throw It}throw Tt},Dt=zt?t=>zt.decode((t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,Ut(t)))(t)):t=>{let e=Ut(t);if(0===e)return"";{let s=String.fromCodePoint(Mt(t));if(--e<100)for(;e--;)s+=String.fromCodePoint(Mt(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 Bt;!function(t){t[t.Token=0]="Token",t[t.PermissionDenied=1]="PermissionDenied",t[t.Authenticated=2]="Authenticated"}(Bt||(Bt={}));const Wt=t=>Array.from(t.entries()).map((([t,e])=>({clientId:t,...e})));var Rt;async function Vt(t){return new Promise((e=>setTimeout(e,t)))}function Pt(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"}(Rt||(Rt={}));const Ft=Math.floor,Lt=128,Nt=127,Yt=Number.MAX_SAFE_INTEGER,Ht=()=>new Set,Jt=Array.from,Kt="undefined"!=typeof TextEncoder?new TextEncoder:null,Gt=Kt?t=>Kt.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 qt="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});qt&&1===qt.decode(new Uint8Array).length&&(qt=null);class $t{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Qt=()=>new $t,Xt=t=>{let e=t.cpos;for(let s=0;s<t.bufs.length;s++)e+=t.bufs[s].length;return e},_t=t=>{const e=new Uint8Array(Xt(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},Zt=(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},te=(t,e)=>{for(;e>Nt;)Zt(t,Lt|Nt&e),e=Ft(e/128);Zt(t,Nt&e)},ee=new Uint8Array(3e4),se=ee.length/3,ie=Kt&&Kt.encodeInto?(t,e)=>{if(e.length<se){const s=Kt.encodeInto(e,ee).written||0;te(t,s);for(let e=0;e<s;e++)Zt(t,ee[e])}else ne(t,Gt(e))}:(t,e)=>{const s=unescape(encodeURIComponent(e)),i=s.length;te(t,i);for(let e=0;e<i;e++)Zt(t,s.codePointAt(e))},ne=(t,e)=>{te(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)},oe=t=>Error(t),re=oe("Unexpected end of array"),ae=oe("Integer out of Range");class ce{constructor(t){this.arr=t,this.pos=0}}const he=t=>new ce(t),le=t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,ue(t)),de=t=>t.arr[t.pos++],ue=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&Nt)*s,s*=128,i<Lt)return e;if(e>Yt)throw ae}throw re},pe=qt?t=>qt.decode(le(t)):t=>{let e=ue(t);if(0===e)return"";{let s=String.fromCodePoint(de(t));if(--e<100)for(;e--;)s+=String.fromCodePoint(de(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))}},me=Date.now,ge=()=>new Map;class be{constructor(){this._observers=ge()}on(t,e){((t,e,s)=>{let i=t.get(e);return void 0===i&&t.set(e,i=s()),i})(this._observers,t,Ht).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 Jt((this._observers.get(t)||ge()).values()).forEach((t=>t(...e)))}destroy(){this._observers=ge()}}const fe=Object.keys,ye=t=>fe(t).length,ke=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),we=(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)||!we(t.get(s),e.get(s)))return!1;break;case Object:if(ye(t)!==ye(e))return!1;for(const s in t)if(!ke(t,s)||!we(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(!we(t[s],e[s]))return!1;break;default:return!1}return!0};class ve extends be{constructor(t){super(),this.doc=t,this.clientID=t.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval((()=>{const t=me();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&&ze(this,e,"timeout")}),Ft(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:me()});const o=[],r=[],a=[],c=[];null===t?c.push(e):null==n?null!=t&&o.push(e):(r.push(e),we(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 ze=(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:me()})}i.push(n)}}i.length>0&&(t.emit("change",[{added:[],updated:[],removed:i},s]),t.emit("update",[{added:[],updated:[],removed:i},s]))},Ce=(t,e,s=t.states)=>{const i=e.length,n=Qt();te(n,i);for(let o=0;o<i;o++){const i=e[o],r=s.get(i)||null,a=t.meta.get(i).clock;te(n,i),te(n,a),ie(n,JSON.stringify(r))}return _t(n)};class je{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 Ae{constructor(t){this.data=t,this.encoder=Qt(),this.decoder=he(new Uint8Array(this.data))}peekVarString(){return(t=>{const e=t.pos,s=pe(t);return t.pos=e,s})(this.decoder)}readVarUint(){return ue(this.decoder)}readVarString(){return pe(this.decoder)}readVarUint8Array(){return le(this.decoder)}writeVarUint(t){return te(this.encoder,t)}writeVarString(t){return ie(this.encoder,t)}writeVarUint8Array(t){return ne(this.encoder,t)}length(){return Xt(this.encoder)}}var Se,xe;!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"}(Se||(Se={})),function(t){t.Connecting="connecting",t.Connected="connected",t.Disconnected="disconnected"}(xe||(xe={}));class Oe{constructor(){this.encoder=Qt()}get(t){return t.encoder}toUint8Array(){return _t(this.encoder)}}class Ee extends Oe{constructor(){super(...arguments),this.type=Se.CLOSE,this.description="Ask the server to close the connection"}get(t){return ie(this.encoder,t.documentName),te(this.encoder,this.type),this.encoder}}class Te extends je{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=xe.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=xe.Connected,this.emit("status",{status:xe.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=t}attach(t){this.configuration.providerMap.set(t.configuration.name,t),this.status===xe.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===xe.Connected&&t.onOpen(this.receivedOnOpenPayload)}detach(t){this.configuration.providerMap.has(t.configuration.name)&&(t.send(Ee,{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===xe.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||Pt,o=s.calculateDelay?s.calculateDelay(i,s):s.initialDelay;if(o&&await Vt(o),i.attemptNum<1&&s.initialJitter){const t=n(i,s);t&&await Vt(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 Vt(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=xe.Connecting,this.emit("status",{status:xe.Connecting}),this.connectionAttempt={resolve:t,reject:e}}))}onMessage(t){var e;this.resolveConnectionAttempt(),this.lastMessageReceived=me();const s=new Ae(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=xe.Connected,this.emit("status",{status:xe.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===xe.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=me()-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)===Rt.Open?this.webSocket.send(t):this.messageQueue.push(t)}onClose({event:t}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=xe.Disconnected,this.emit("status",{status:xe.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 Ie=(t,e,s)=>{try{I.applyUpdate(e,le(t),s)}catch(t){console.error("Caught error while handling a Yjs update",t)}},Me=Ie;class Ue{constructor(t){this.message=t}apply(t,e){const{message:s}=this,i=s.readVarUint(),n=s.length();switch(i){case Se.Sync:this.applySyncMessage(t,e);break;case Se.Awareness:this.applyAwarenessMessage(t);break;case Se.Auth:this.applyAuthMessage(t);break;case Se.QueryAwareness:this.applyQueryAwarenessMessage(t);break;case Se.Stateless:t.receiveStateless(pe(s.decoder));break;case Se.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&Lt))return n*s;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],s+=(e&Nt)*i,i*=128,e<Lt)return n*s;if(s>Yt)throw ae}throw re})(s.decoder));break;case Se.CLOSE:const n={code:1e3,reason:pe(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(Oe,{encoder:s.encoder})}applySyncMessage(t,e){const{message:s}=this;s.writeVarUint(Se.Sync);const i=((t,e,s,i)=>{const n=ue(t);switch(n){case 0:((t,e,s)=>{((t,e,s)=>{te(t,1),ne(t,I.encodeStateAsUpdate(e,s))})(e,s,le(t))})(t,e,s);break;case 1:Ie(t,s,i);break;case 2:Me(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=he(e),n=me(),o=[],r=[],a=[],c=[],h=ue(i);for(let e=0;e<h;e++){const e=ue(i);let s=ue(i);const h=JSON.parse(pe(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&&(we(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(Ut(t)){case Bt.Token:e();break;case Bt.PermissionDenied:s(Dt(t));break;case Bt.Authenticated:i(Dt(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(Se.Awareness),e.writeVarUint8Array(Ce(t.awareness,Array.from(t.awareness.getStates().keys())))}}class De{constructor(t,e={}){this.message=new t,this.encoder=this.message.get(e)}create(){return _t(this.encoder)}send(t){null==t||t.send(this.create())}}class Be extends Oe{constructor(){super(...arguments),this.type=Se.Auth,this.description="Authentication"}get(t){if(void 0===t.token)throw Error("The authentication message requires `token` as an argument.");return ie(this.encoder,t.documentName),te(this.encoder,this.type),((t,e)=>{jt(t,Bt.Token),xt(t,e)})(this.encoder,t.token),this.encoder}}class We extends Oe{constructor(){super(...arguments),this.type=Se.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 ie(this.encoder,t.documentName),te(this.encoder,this.type),e=void 0===t.states?Ce(t.awareness,t.clients):Ce(t.awareness,t.clients,t.states),ne(this.encoder,e),this.encoder}}class Re extends Oe{constructor(){super(...arguments),this.type=Se.Stateless,this.description="A stateless message"}get(t){var e;return ie(this.encoder,t.documentName),te(this.encoder,this.type),ie(this.encoder,null!==(e=t.payload)&&void 0!==e?e:""),this.encoder}}class Ve extends Oe{constructor(){super(...arguments),this.type=Se.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 ie(this.encoder,t.documentName),te(this.encoder,this.type),((t,e)=>{te(t,0);const s=I.encodeStateVector(e);ne(t,s)})(this.encoder,t.document),this.encoder}}class Pe extends Oe{constructor(){super(...arguments),this.type=Se.Sync,this.description="A document update"}get(t){return ie(this.encoder,t.documentName),te(this.encoder,this.type),((t,e)=>{te(t,2),ne(t,e)})(this.encoder,t.update),this.encoder}}class Fe extends Error{constructor(){super(...arguments),this.code=1001}}class Le extends je{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 I.Doc,this.configuration.awareness=void 0!==t.awareness?t.awareness:new ve(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:Wt(this.awareness.getStates())})})),null===(s=this.awareness)||void 0===s||s.on("change",(()=>{this.emit("awarenessChange",{states:Wt(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 Te(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(Ve,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&ze(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){"undefined"!=typeof window&&"addEventListener"in window&&window.addEventListener("pagehide",this.boundPageHide)}sendStateless(t){this.send(Re,{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(Be,{token:null!=t?t:"",documentName:this.configuration.name})}documentUpdateHandler(t,e){e!==this&&(this.incrementUnsyncedChanges(),this.send(Pe,{update:t,documentName:this.configuration.name}))}awarenessUpdateHandler({added:t,updated:e,removed:s},i){const n=t.concat(e).concat(s);this.send(We,{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(Ve,{document:this.document,documentName:this.configuration.name}),this.awareness&&null!==this.awareness.getLocalState()&&this.send(We,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(t,e){if(!this._isAttached)return;const s=new De(t,e);this.emit("outgoingMessage",{message:s.message}),s.send(this.configuration.websocketProvider)}onMessage(t){const e=new Ae(t.data),s=e.readVarString();e.writeVarString(s),this.emit("message",{event:t,message:new Ae(t.data)}),new Ue(e).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&ze(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&&(ze(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 Fe(`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 Ne={type:"pen",color:S[0],size:16,opacity:1,palettes:{pen:[...S]},sizes:{pen:[...c]}},Ye={color:S[0],size:8,opacity:1,fontFamily:"Arial",palette:[...S],sizes:[...h]},He={color:S[0],size:4,opacity:1,palette:[...S],sizes:[...c],arrows:{end:{enabled:!0,style:"triangle"}}},Je={providers:[]},Ke={shapeType:l.Rectangle,fillColor:{light:"transparent",dark:"transparent"},strokeColor:S[0],strokeWidth:4,opacity:1,fontColor:S[0],fontSize:16,fontFamily:"Arial",palette:[...S],sizes:[...c]},Ge=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=b;scaleMin=f;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:d,icon:"cursor"},{name:"brush",type:"tool",tool:y,icon:"pen",config:Ne},{name:"eraser",type:"tool",tool:k,icon:"eraser"},{name:"line",type:"tool",tool:w,icon:"arrow",config:He},{name:"shape",type:"tool",tool:v,icon:"shape-rectangle",config:Ke,subOptions:[{id:"rectangle",icon:"shape-rectangle",label:"Rectangle",value:l.Rectangle,toolProperty:"shapeType"},{id:"ellipse",icon:"shape-ellipse",label:"Ellipse",value:l.Ellipse,toolProperty:"shapeType"},{id:"triangle",icon:"shape-triangle",label:"Triangle",value:l.Triangle,toolProperty:"shapeType"}]},{name:"text",type:"tool",tool:u,icon:"type",config:Ye},{name:"image",type:"tool",tool:z,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:"Cut",icon:"cut",group:"clipboard",action:()=>this.engineRef.cut()},{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(C.StartHorizontal)},{label:"Align Center Horizontally",icon:"align-center-horizontal",action:()=>this.engineRef.alignObjects(C.CenterHorizontal)},{label:"Align Right",icon:"align-end-vertical",action:()=>this.engineRef.alignObjects(C.EndHorizontal)},{label:"Align Top",icon:"align-start-horizontal",action:()=>this.engineRef.alignObjects(C.StartVertical)},{label:"Align Center Vertically",icon:"align-center-vertical",action:()=>this.engineRef.alignObjects(C.CenterVertical)},{label:"Align Bottom",icon:"align-end-horizontal",action:()=>this.engineRef.alignObjects(C.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()}];themes;theme="light";customSvgIcons={};isControlsVisible=!0;isUtilityPanelVisible=!0;isWorkspaceManagerVisible=!0;isMoreMenuVisible=!0;isObjectDistanceFadingActive=!1;syncConfig=j;assetStorageConfig=Je;cursorTarget;loginConfig;isLoading=!1;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;shortcuts=[];currentIsPublic=!1;isEditorVisible=!1;onIsEngineReady(t){t&&this.isControlsReady&&this.checkIsReady()}onIsControlsReady(t){t&&this.isEngineReady&&this.checkIsReady()}onWorkspacesChange(t){const e=this.activeWorkspace;if(e){const s=t.find((t=>t.id===e.id));s&&s!==e&&(this.activeWorkspace=s)}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(){this.applyTheme(),setTimeout((()=>this.setOsSpecificCssVariables()),0),this.engineRef&&this.engineRef.saveSettings(this.currentSettingsConfig)}onThemesChange(){this.applyTheme()}onTouchStart(t){t.cancelable&&t.preventDefault()}async getObjectById(t){return this.engineRef.getObjectById(t)}async addObject(t){return this.engineRef.addObject(t)}async addObjects(t){return this.engineRef.addObjects(t)}async updateObject(t,e){return this.engineRef.updateObject(t,e)}async removeObject(t){return this.engineRef.removeObject(t)}async removeObjects(t){return this.engineRef.removeObjects(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 panToObject(t){return this.engineRef.panToObject(t)}async backToContent(){return this.engineRef.backToContent()}async centerAllObjects(t=!0){return this.engineRef.centerAllObjects(t)}async centerObjects(t,e=!0){return this.engineRef.centerObjects(t,e)}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 zoomIn(t=1.6,e=200){return this.engineRef.zoomIn(t,e)}async zoomOut(t=1.6,e=200){return this.engineRef.zoomOut(t,e)}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 changeActiveToolByName(t){return this.engineRef.changeActiveToolByName(t)}async disable(){return this.engineRef.disable()}async enable(){return this.engineRef.enable()}async copy(){return this.engineRef.copy()}async cut(){return this.engineRef.cut()}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",e){return this.engineRef.getScreenshot(t,e)}async exportViewportAsPng(t){return this.engineRef.exportViewportAsPng(t)}async exportViewportAsSvg(t){return this.engineRef.exportViewportAsSvg(t)}async exportSelectedObjectsAsPng(){return this.engineRef.exportSelectedObjectsAsPng()}async exportSelectedObjectsAsSvg(){return this.engineRef.exportSelectedObjectsAsSvg()}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 openContextMenu(t){return this.engineRef.openContextMenu(t)}async triggerSelectionChange(){return this.engineRef.triggerSelectionChange()}async getDisplayableShortcuts(){return this.engineRef.getDisplayableShortcuts()}engineRef;controlsRef;settingsRef;exportRef;splitButtonRef;shareDialogRef;loginDialogRef;componentWillLoad(){this.loadSettingsFromStorage(),this.applyTheme()}applyTheme(){const t=this.resolveThemeObject();x.applyThemeToElement(this.host,t)}resolveThemeObject(){return this.themes?.find((t=>t.name===this.theme))??("dark"===this.theme?O:E)}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&&this.activeWorkspace))return;this.isEditorVisible=!0;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,assetStorageConfig:this.assetStorageConfig,loginConfig:this.loginConfig,theme:this.theme})}async onEngineReady(t){this.isEngineReady=!0,t.detail.activeWorkspace&&(this.activeWorkspace=t.detail.activeWorkspace,this.workspaces=t.detail.workspaces,this.currentIsPublic=await this.engineRef.getIsPublic(),this.loadShortcuts())}handleWorkspacesChange(t){t.stopPropagation(),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){t.stopPropagation(),this.objectsChange.emit(t.detail)}handleObjectsAdded(t){t.stopPropagation(),this.objectsAdded.emit(t.detail)}handleObjectsRemoved(t){t.stopPropagation(),this.objectsRemoved.emit(t.detail)}handleObjectsUpdated(t){t.stopPropagation(),this.objectsUpdated.emit(t.detail)}handleUndoStateChange(t){t.stopPropagation(),this.undoStateChange.emit(t.detail),this.undoState=t.detail}async handleObjectsInViewportChange(t){t.stopPropagation();const e=this.getContentObjects(t.detail).length>0,s=this.getContentObjects(await this.engineRef.getAllObjects()).length>0;this.isBackToContentButtonVisible=!e&&s}handleViewportChange(t){t.stopPropagation(),this.viewportChange.emit(t.detail)}handleAwarenessChange(t){t.stopPropagation(),this.awarenessChange.emit(t.detail)}handleSettingsChange(t){this.scaleMin=t.detail.scaleMin,this.scaleMax=t.detail.scaleMax,this.lockDrawingScale=t.detail.lockDrawingScale,this.theme=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.engineRef&&this.engineRef.saveSettings(t.detail),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??void 0)}},{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:s.id})};updateCurrentIsPublic(){const t=this.activeWorkspace?.isPublic??!1,e=this.activeWorkspace?.id;this.currentIsPublic=t,e&&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),"string"==typeof e.theme&&(this.theme=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()}get currentSettingsConfig(){return{scaleMin:this.scaleMin,scaleMax:this.scaleMax,lockDrawingScale:this.lockDrawingScale,theme:this.theme,viewportBoundaryLeft:this.viewportBoundaryLeft,viewportBoundaryRight:this.viewportBoundaryRight,viewportBoundaryTop:this.viewportBoundaryTop,viewportBoundaryBottom:this.viewportBoundaryBottom,debugInfo:this.debugInfo}}getContentObjects(t){return t.filter((t=>!(t instanceof p||t instanceof m)))}registerCustomSvgIcons(){for(const[t,e]of Object.entries(this.customSvgIcons))r.register(t,e)}listenForMobileKeyboard(){g.onKeyboardVisibleChanged((t=>{this.isVirtualKeyboardOpen=t}))}setOsSpecificCssVariables(){switch(T.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.isReady&&!!this.loginConfig&&!t;return i(n,{key:"ffacaea5d3df12a3a8b448d31db3c5949053156c",style:{opacity:this.isEditorVisible?"1":"0",visibility:this.isEditorVisible?"visible":"hidden",transition:"opacity 0.2s ease-in-out, visibility 0.2s ease-in-out"}},i("div",{key:"669eafee25b4f84c39469738a1337c21ab03e388",class:"top-left-buttons"},i("kritzel-workspace-manager",{key:"d6feb4a71c3286830fbe53a533f283c8af9a0385",visible:this.isWorkspaceManagerVisible,workspaces:this.workspaces,activeWorkspace:this.activeWorkspace,onWorkspaceChange:t=>this.activeWorkspace=t.detail,onIsWorkspaceManagerReady:()=>this.isWorkspaceManagerReady=!0}),i("kritzel-back-to-content",{key:"5bd0e6263d51119b197292b69879c1ae437f92fc",visible:this.isBackToContentButtonVisible,onBackToContent:()=>this.backToContent()})),i("kritzel-engine",{key:"468f17137c51c90fd61c9179d13c449b1ac8feb9",ref:t=>{t&&(this.engineRef=t)},workspace:this.activeWorkspace,activeWorkspaceId:this.activeWorkspaceId,editorId:this.editorId,syncConfig:this.syncConfig,assetStorageConfig:this.assetStorageConfig,user:this.user,scaleMax:this.scaleMax,lockDrawingScale:this.lockDrawingScale,isObjectDistanceFadingActive:this.isObjectDistanceFadingActive,scaleMin:this.scaleMin,cursorTarget:this.cursorTarget,isLoading:this.isLoading,viewportBoundaryLeft:this.viewportBoundaryLeft,viewportBoundaryRight:this.viewportBoundaryRight,viewportBoundaryTop:this.viewportBoundaryTop,viewportBoundaryBottom:this.viewportBoundaryBottom,wheelEnabled:this.wheelEnabled,theme:this.theme,themes:this.themes,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:"848c30b27fb916c8480b41745bd6ec844e0b23a2",visible:this.isControlsVisible,class:{"keyboard-open":this.isVirtualKeyboardOpen},ref:t=>{t&&(this.controlsRef=t)},controls:this.controls,isUtilityPanelVisible:this.isUtilityPanelVisible,undoState:this.undoState??void 0,theme:this.theme,onIsControlsReady:()=>this.isControlsReady=!0}),i("div",{key:"e998d60679c767d15617bd7ecde5ee77e781a92f",class:"top-right-buttons"},i("kritzel-settings",{key:"43b9cdb2d10de789cc03d2a9ef5df870b8ca7bfe",ref:t=>{t&&(this.settingsRef=t)},shortcuts:this.shortcuts,availableThemes:this.themes&&this.themes.length>0?this.themes.map((t=>t.name)):["light","dark"],settings:this.currentSettingsConfig,onSettingsChange:t=>this.handleSettingsChange(t)}),i("kritzel-export",{key:"74669624a1e5177125ef00e1667c880ce47cbce4",ref:t=>{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:"18d925f32d021ff6713accb22d0594d259d70f2e",users:this.activeUsers}),e&&i("kritzel-current-user",{key:"bddd5c29c5f17cced47276c237c04cfdb711da38",user:this.user}),s&&i("kritzel-button",{key:"4eb6c85459f59863d6e644ecf21c2295da71bafc",onButtonClick:()=>this.loginDialogRef?.open()},"Sign in"),i("kritzel-more-menu",{key:"a5a323ec248bebc7bc07898f344e0926fac8db17",items:this.moreMenuItems,visible:this.isMoreMenuVisible}),i("kritzel-share-dialog",{key:"8cb3ddad95d36f5b7ad59d8c4f057df93cb2bfe3",ref:t=>{t&&(this.shareDialogRef=t)},isPublic:this.currentIsPublic,workspaceId:this.activeWorkspace?.id,onToggleIsPublic:this.handleToggleIsPublic}),this.loginConfig&&i("kritzel-login-dialog",{key:"35395d0faadcfeb021fba685aa46e180e47d2be2",ref:t=>{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}],theme:[{onCurrentThemeChange:0}],themes:[{onThemesChange: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;text-align:start;line-height:normal}kritzel-controls{position:absolute;left:0;right:0;margin-inline:auto;width:max-content;max-width:calc(100% - 16px);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],themes:[16],theme:[1025],customSvgIcons:[16],isControlsVisible:[4,"is-controls-visible"],isUtilityPanelVisible:[4,"is-utility-panel-visible"],isWorkspaceManagerVisible:[4,"is-workspace-manager-visible"],isMoreMenuVisible:[4,"is-more-menu-visible"],isObjectDistanceFadingActive:[4,"is-object-distance-fading-active"],syncConfig:[16],assetStorageConfig:[16],cursorTarget:[16],loginConfig:[16],isLoading:[4,"is-loading"],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],shortcuts:[32],currentIsPublic:[32],isEditorVisible:[32],getObjectById:[64],addObject:[64],addObjects:[64],updateObject:[64],removeObject:[64],removeObjects:[64],getSelectedObjects:[64],selectObjects:[64],selectAllObjectsInViewport:[64],clearSelection:[64],centerObjectInViewport:[64],panToObject:[64],backToContent:[64],centerAllObjects:[64],centerObjects:[64],setViewport:[64],panTo:[64],zoomTo:[64],zoomIn:[64],zoomOut:[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],changeActiveToolByName:[64],disable:[64],enable:[64],copy:[64],cut:[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],exportSelectedObjectsAsPng:[64],exportSelectedObjectsAsSvg:[64],downloadAsJson:[64],importFromFile:[64],loadObjectsFromJson:[64],getObjectsTotalCount:[64],getAllObjects:[64],findObjects:[64],getCopiedObjects:[64],getObjectsInViewport:[64],hideContextMenu:[64],openContextMenu:[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}],theme:[{onCurrentThemeChange:0}],themes:[{onThemesChange:0}]}]),qe=Ge,$e=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),Ge);break;case"kritzel-active-users":customElements.get(o(t))||M();break;case"kritzel-avatar":customElements.get(o(t))||U();break;case"kritzel-awareness-cursors":customElements.get(o(t))||D();break;case"kritzel-back-to-content":customElements.get(o(t))||B();break;case"kritzel-button":customElements.get(o(t))||W();break;case"kritzel-color":customElements.get(o(t))||R();break;case"kritzel-color-palette":customElements.get(o(t))||V();break;case"kritzel-context-menu":customElements.get(o(t))||P();break;case"kritzel-controls":customElements.get(o(t))||F();break;case"kritzel-current-user":customElements.get(o(t))||L();break;case"kritzel-current-user-dialog":customElements.get(o(t))||N();break;case"kritzel-cursor-trail":customElements.get(o(t))||Y();break;case"kritzel-dialog":customElements.get(o(t))||H();break;case"kritzel-dropdown":customElements.get(o(t))||J();break;case"kritzel-engine":customElements.get(o(t))||A();break;case"kritzel-export":customElements.get(o(t))||K();break;case"kritzel-font":customElements.get(o(t))||G();break;case"kritzel-font-family":customElements.get(o(t))||q();break;case"kritzel-font-size":customElements.get(o(t))||$();break;case"kritzel-icon":customElements.get(o(t))||a();break;case"kritzel-input":customElements.get(o(t))||Q();break;case"kritzel-line-endings":customElements.get(o(t))||X();break;case"kritzel-login-dialog":customElements.get(o(t))||_();break;case"kritzel-master-detail":customElements.get(o(t))||Z();break;case"kritzel-menu":customElements.get(o(t))||et();break;case"kritzel-menu-item":customElements.get(o(t))||tt();break;case"kritzel-more-menu":customElements.get(o(t))||st();break;case"kritzel-numeric-input":customElements.get(o(t))||it();break;case"kritzel-opacity-slider":customElements.get(o(t))||nt();break;case"kritzel-pill-tabs":customElements.get(o(t))||ot();break;case"kritzel-portal":customElements.get(o(t))||rt();break;case"kritzel-settings":customElements.get(o(t))||at();break;case"kritzel-shape-fill":customElements.get(o(t))||ct();break;case"kritzel-share-dialog":customElements.get(o(t))||ht();break;case"kritzel-slide-toggle":customElements.get(o(t))||lt();break;case"kritzel-split-button":customElements.get(o(t))||dt();break;case"kritzel-stroke-size":customElements.get(o(t))||ut();break;case"kritzel-tool-config":customElements.get(o(t))||pt();break;case"kritzel-tooltip":customElements.get(o(t))||mt();break;case"kritzel-utility-panel":customElements.get(o(t))||gt();break;case"kritzel-workspace-manager":customElements.get(o(t))||bt()}}))};export{Ne as D,Le as H,qe as KritzelEditor,Te as a,Ye as b,He as c,Je as d,$e as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{k as o,j as
|
|
1
|
+
import{k as o,j as s}from"./p-Dc0a_Hb-.js";const a=o,p=s;export{a as KritzelEngine,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-CUFKqzMC.js";const p=o,r=s;export{p as KritzelSettings,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,d as
|
|
1
|
+
import{a as o,d as s}from"./p-BTEV1WwT.js";const a=o,p=s;export{a as KritzelToolConfig,p as defineCustomElement}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as e,H as t,c as s,h as i,d as o,t as r}from"./p-B43upypT.js";import{e as n,d as a}from"./p-CUPYGT8c.js";import{a as l}from"./p-2xYAGd0I.js";import{d as h}from"./p-skWUIStn.js";import{d as p}from"./p-BFoK4W--.js";import{d as c}from"./p-Df3BwVGy.js";import{d}from"./p-CmuNn1Tc.js";import{d as m}from"./p-JhOYwUOj.js";import{d as f}from"./p-FK7b3BGt.js";import{d as u}from"./p-DbB730vO.js";import{d as g}from"./p-CXpv9Rxe.js";import{d as z}from"./p-DEy7zJCe.js";import{d as y}from"./p-BFYtCsZu.js";import{d as k}from"./p-B2Os1ya_.js";class C{static getToolConfig(e){switch(e?.toolType){case"selection":return"getToolConfig"in e&&"function"==typeof e.getToolConfig?e.getToolConfig():null;case"brush":return{type:"brush",colorProperty:"color",sizeProperty:"size",opacityProperty:"opacity",paletteSource:"palette",sizesSource:"sizes",controls:[{type:"stroke-size",propertyName:"size"}]};case"line":return{type:"line",colorProperty:"color",sizeProperty:"size",opacityProperty:"opacity",paletteSource:"palette",sizesSource:"sizes",controls:[{type:"stroke-size",propertyName:"size"},{type:"line-endings",propertyName:"arrows",additionalProps:{}}]};case"shape":return{type:"shape",colorProperty:"strokeColor",sizeProperty:"strokeWidth",opacityProperty:"opacity",paletteSource:"palette",sizesSource:"sizes",controls:[{type:"stroke-size",propertyName:"strokeWidth"},{type:"shape-fill",propertyName:"fillColor",additionalProps:{}}]};case"text":return{type:"text",colorProperty:"fontColor",sizeProperty:"fontSize",opacityProperty:"opacity",paletteSource:"palette",sizesSource:"sizes",controls:[{type:"font-size",propertyName:"fontSize",additionalProps:{}},{type:"font-family",propertyName:"fontFamily"}]};default:return null}}}const x=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.toolChange=s(this,"toolChange"),this.displayValuesChange=s(this,"displayValuesChange")}tool;handleToolChange(e,t){const s=C.getToolConfig(e);if(t&&e&&"shape"===s?.type){const i=C.getToolConfig(t);"shape"===i?.type&&[s.colorProperty,s.sizeProperty,s.opacityProperty,"fillColor"].forEach((s=>{s&&void 0!==t[s]&&(e[s]=t[s])}))}this.config=s,this.config&&(this.updatePalette(),this.updateSizes(),this.currentOpacity=e[this.config.opacityProperty]??1,this.emitDisplayValues())}isExpanded=!1;theme;engine;handleSelectionChangeBound=this.handleSelectionChange.bind(this);onThemeChange(){this.emitDisplayValues()}handleEngineChange(e,t){t&&t.removeEventListener("objectsSelectionChange",this.handleSelectionChangeBound),e&&e.addEventListener("objectsSelectionChange",this.handleSelectionChangeBound)}toolChange;displayValuesChange;config;palette=[];sizes=[];currentOpacity=1;updateTrigger=0;handleSelectionChange(){this.tool instanceof n&&(this.config=C.getToolConfig(this.tool),this.config&&(this.updatePalette(),this.updateSizes(),this.currentOpacity=this.tool[this.config.opacityProperty]??1,this.emitDisplayValues()))}disconnectedCallback(){this.engine&&this.engine.removeEventListener("objectsSelectionChange",this.handleSelectionChangeBound)}componentWillLoad(){this.config=C.getToolConfig(this.tool),this.config&&(this.updatePalette(),this.updateSizes(),this.currentOpacity=this.tool[this.config.opacityProperty]??1,this.emitDisplayValues()),this.engine&&this.engine.addEventListener("objectsSelectionChange",this.handleSelectionChangeBound)}emitDisplayValues(){if(!this.config)return;const e=this.tool[this.config.sizeProperty],t={color:l.applyOpacity(this.tool[this.config.colorProperty],this.currentOpacity,this.theme),size:e};this.tool instanceof a&&(t.fontFamily=this.tool.fontFamily),this.displayValuesChange.emit(t)}updatePalette(){this.config&&(this.palette="none"===this.config.paletteSource?[]:this.tool.palette||[])}updateSizes(){this.config&&(this.sizes="none"===this.config.sizesSource?[]:this.tool.sizes||[])}handleToggleExpand=()=>{this.isExpanded=!this.isExpanded};handleColorChange=e=>{if(this.tool[this.config.colorProperty]=e.detail,"shape"===this.config.type||"selection"===this.config.type){const t=this.tool;("string"==typeof t.fillColor?"transparent"===t.fillColor:"transparent"===t.fillColor.light&&"transparent"===t.fillColor.dark)||(t.fillColor=e.detail)}this.emitDisplayValues(),this.toolChange.emit(this.tool),this.updateTrigger++};handleSizeChange=e=>{this.tool[this.config.sizeProperty]=e.detail,this.emitDisplayValues(),this.toolChange.emit(this.tool),this.updateTrigger++};handleOpacityChange=e=>{this.tool[this.config.opacityProperty]=e.detail,this.currentOpacity=e.detail,this.emitDisplayValues(),this.toolChange.emit(this.tool)};handlePropertyChange=(e,t)=>{if("shape"!==this.config.type&&"selection"!==this.config.type||"fillColor"!==e)this.tool[e]=t,"fontFamily"===e&&this.emitDisplayValues();else{const e="filled"===t?this.tool[this.config.colorProperty]:{light:"transparent",dark:"transparent"};this.tool.fillColor=e,"filled"===t&&(this.tool[this.config.colorProperty]=e)}this.toolChange.emit(this.tool),this.updateTrigger++};getShapeFillValue(){const e=this.tool.fillColor;return("string"==typeof e?"transparent"===e:"transparent"===e.light&&"transparent"===e.dark)?"transparent":"filled"}renderControl(e){const t=this.tool[e.propertyName];switch(e.type){case"stroke-size":return i("kritzel-stroke-size",{key:e.type,sizes:this.sizes.length>0?this.sizes:void 0,selectedSize:t,onSizeChange:this.handleSizeChange});case"font-size":return i("kritzel-font-size",{key:e.type,sizes:this.sizes.length>0?this.sizes:void 0,selectedSize:t,fontFamily:this.tool.fontFamily,onSizeChange:this.handleSizeChange});case"line-endings":return i("kritzel-line-endings",{key:e.type,value:t,onValueChange:t=>this.handlePropertyChange(e.propertyName,t.detail)});case"shape-fill":return i("kritzel-shape-fill",{key:e.type,value:this.getShapeFillValue(),onValueChange:t=>this.handlePropertyChange(e.propertyName,t.detail)});case"font-family":return i("kritzel-font-family",{key:e.type,selectedFontFamily:t,onFontFamilyChange:t=>this.handlePropertyChange(e.propertyName,t.detail)});default:return null}}render(){if(!this.config)return null;const e=this.palette.length>6||"text"===this.config.type,t=this.palette.length>0,s=this.config.controls.find((e=>"stroke-size"===e.type||"font-size"===e.type)),r=this.config.controls.filter((e=>"stroke-size"!==e.type&&"font-size"!==e.type));return i(o,null,i("div",{style:{display:"flex",flexDirection:"row",gap:"8px",width:"100%"}},i("div",{style:{display:"flex",flexDirection:"column",gap:"12px",flex:"1"}},t&&i("kritzel-color-palette",{colors:this.palette,selectedColor:this.tool[this.config.colorProperty],isExpanded:this.isExpanded,isOpaque:!0,opacity:this.currentOpacity,theme:this.theme,onColorChange:this.handleColorChange}),s&&this.renderControl(s),i("kritzel-opacity-slider",{value:this.tool[this.config.opacityProperty],previewColor:this.tool[this.config.colorProperty],onValueChange:this.handleOpacityChange}),r.map((e=>[i("div",{class:"divider"}),this.renderControl(e)]))),e&&i("div",{style:{display:"flex",alignItems:"flex-start"}},i("button",{class:"expand-toggle",onClick:this.handleToggleExpand,title:this.isExpanded?"Collapse":"Expand"},i("kritzel-icon",{name:this.isExpanded?"chevron-up":"chevron-down"})))))}static get watchers(){return{tool:[{handleToolChange:0}],theme:[{onThemeChange:0}],engine:[{handleEngineChange:0}]}}static get style(){return".expand-toggle{background:none;border:none;cursor:var(--kritzel-global-pointer-cursor, pointer);padding:0;margin:0;display:flex;align-items:center;justify-content:center;width:32px;height:32px;color:var(--kritzel-icon-color, currentColor);transition:transform 0.2s ease}.expand-toggle:hover{opacity:0.7}.expand-toggle:focus{outline:none}.expand-toggle:focus-visible{outline:2px solid var(--kritzel-focus-color, #007acc);outline-offset:2px}.expand-toggle:active{transform:scale(0.95)}.divider{height:1px;background-color:var(--kritzel-divider-color, #e0e0e0);margin:4px 0;width:100%}"}},[513,"kritzel-tool-config",{tool:[1040],isExpanded:[1028,"is-expanded"],theme:[1],engine:[16],config:[32],palette:[32],sizes:[32],currentOpacity:[32],updateTrigger:[32]},void 0,{tool:[{handleToolChange:0}],theme:[{onThemeChange:0}],engine:[{handleEngineChange:0}]}]);function b(){"undefined"!=typeof customElements&&["kritzel-tool-config","kritzel-color","kritzel-color-palette","kritzel-dropdown","kritzel-font","kritzel-font-family","kritzel-font-size","kritzel-icon","kritzel-line-endings","kritzel-opacity-slider","kritzel-shape-fill","kritzel-stroke-size"].forEach((e=>{switch(e){case"kritzel-tool-config":customElements.get(r(e))||customElements.define(r(e),x);break;case"kritzel-color":customElements.get(r(e))||h();break;case"kritzel-color-palette":customElements.get(r(e))||p();break;case"kritzel-dropdown":customElements.get(r(e))||c();break;case"kritzel-font":customElements.get(r(e))||d();break;case"kritzel-font-family":customElements.get(r(e))||m();break;case"kritzel-font-size":customElements.get(r(e))||f();break;case"kritzel-icon":customElements.get(r(e))||u();break;case"kritzel-line-endings":customElements.get(r(e))||g();break;case"kritzel-opacity-slider":customElements.get(r(e))||z();break;case"kritzel-shape-fill":customElements.get(r(e))||y();break;case"kritzel-stroke-size":customElements.get(r(e))||k()}}))}export{C as K,x as a,b as d}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e,H as t,c as s,h as i,d as o,t as n}from"./p-B43upypT.js";import{a,C as l}from"./p-CW-VyJgK.js";import{d as r}from"./p-CHrSFOSI.js";import{d as c}from"./p-Df3BwVGy.js";import{d as h}from"./p-DbB730vO.js";import{d}from"./p-D-sRVAbQ.js";import{d as g}from"./p-B5xxfwKF.js";import{d as p}from"./p-x6doYeiI.js";const u=-1/0,m=1/0,b=-1/0,f=1/0,v={showViewportInfo:!1,showObjectInfo:!1,showSyncProviderInfo:!0,showMigrationInfo:!0},w=[{id:"general",label:"General",icon:"settings"},{id:"viewport",label:"Viewport",icon:"viewport"},{id:"shortcuts",label:"Keyboard Shortcuts",icon:"command"},{id:"developer",label:"Developer Options",icon:"braces"},{id:"about",label:"About",icon:"info"}],y=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.settingsChange=s(this,"settingsChange")}get host(){return this}availableThemes=["light","dark"];shortcuts=[];settings;onSettingsPropChange(e){e&&this.applySettings(e)}isDialogOpen=!1;selectedCategoryId=w[0].id;scaleMin=1e-4;scaleMax=1e3;lockDrawingScale=!0;theme="light";viewportBoundaryLeft=u;viewportBoundaryRight=m;viewportBoundaryTop=b;viewportBoundaryBottom=f;debugInfo={...v};settingsChange;componentWillLoad(){this.settings&&this.applySettings(this.settings)}applySettings(e){"number"==typeof e.scaleMin&&(this.scaleMin=e.scaleMin),"number"==typeof e.scaleMax&&(this.scaleMax=e.scaleMax),"boolean"==typeof e.lockDrawingScale&&(this.lockDrawingScale=e.lockDrawingScale),"string"==typeof e.theme&&(this.theme=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={...v,...e.debugInfo})}emitSettings(){this.settingsChange.emit({scaleMin:this.scaleMin,scaleMax:this.scaleMax,lockDrawingScale:this.lockDrawingScale,theme:this.theme,viewportBoundaryLeft:this.viewportBoundaryLeft,viewportBoundaryRight:this.viewportBoundaryRight,viewportBoundaryTop:this.viewportBoundaryTop,viewportBoundaryBottom:this.viewportBoundaryBottom,debugInfo:this.debugInfo})}handleScaleMinChange=e=>{this.scaleMin=e.detail,this.emitSettings()};handleScaleMaxChange=e=>{this.scaleMax=e.detail,this.emitSettings()};handleLockDrawingScaleChange=e=>{this.lockDrawingScale=e.detail,this.emitSettings()};handleThemeChange=e=>{this.theme=e.detail,this.emitSettings()};handleViewportBoundaryLeftChange=e=>{this.viewportBoundaryLeft=e.detail??u,this.emitSettings()};handleViewportBoundaryRightChange=e=>{this.viewportBoundaryRight=e.detail??m,this.emitSettings()};handleViewportBoundaryTopChange=e=>{this.viewportBoundaryTop=e.detail??b,this.emitSettings()};handleViewportBoundaryBottomChange=e=>{this.viewportBoundaryBottom=e.detail??f,this.emitSettings()};handleDebugInfoChange=e=>t=>{this.debugInfo={...this.debugInfo,[e]:t.detail},this.emitSettings()};async open(){this.isDialogOpen=!0}closeDialog=()=>{this.isDialogOpen=!1};handleCategorySelect=e=>{this.selectedCategoryId=e.detail.item.id};formatKeyCombo(e){const t=[];return e.ctrl&&t.push("Ctrl"),e.shift&&t.push("Shift"),t.push(this.formatKey(e.key)),t.join("+")}formatKey(e){return{Escape:"Esc",Delete:"Del"," ":"Space"}[e]??e.toUpperCase()}groupShortcutsByCategory(){const e=new Map;for(const t of this.shortcuts){const s=e.get(t.category)||[];s.push(t),e.set(t.category,s)}return e}renderCategoryContent(){switch(this.selectedCategoryId){case"general":return i("div",{class:"settings-content"},i("h3",null,"General Settings"),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Theme"),i("p",{class:"settings-description"},"Select a registered color theme for the editor interface."),i("kritzel-dropdown",{options:this.availableThemes.map((e=>({value:e,label:e}))),value:this.theme,onValueChanged:this.handleThemeChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Lock Drawing Scale"),i("p",{class:"settings-description"},"When enabled, drawn objects maintain a fixed visual size regardless of the current zoom level."),i("kritzel-slide-toggle",{checked:this.lockDrawingScale,label:"Lock Drawing Scale",onCheckedChange:this.handleLockDrawingScaleChange}))));case"viewport":return i("div",{class:"settings-content"},i("h3",null,"Viewport Settings"),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Minimum Zoom Level"),i("p",{class:"settings-description"},"Sets the minimum zoom level. Lower values allow zooming out further to see more of the canvas."),i("kritzel-numeric-input",{value:this.scaleMin,min:1e-4,max:1,step:1e-4,onValueChange:this.handleScaleMinChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Maximum Zoom Level"),i("p",{class:"settings-description"},"Sets the maximum zoom level. Higher values allow zooming in closer for detailed work."),i("kritzel-numeric-input",{value:this.scaleMax,min:1,max:1e3,step:1,onValueChange:this.handleScaleMaxChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Left"),i("p",{class:"settings-description"},"Left boundary in world coordinates. Set to limit how far left the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryLeft,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryLeftChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Right"),i("p",{class:"settings-description"},"Right boundary in world coordinates. Set to limit how far right the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryRight,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryRightChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Top"),i("p",{class:"settings-description"},"Top boundary in world coordinates. Set to limit how far up the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryTop,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryTopChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Bottom"),i("p",{class:"settings-description"},"Bottom boundary in world coordinates. Set to limit how far down the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryBottom,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryBottomChange}))));case"shortcuts":return i("div",{class:"settings-content"},i("h3",null,"Keyboard Shortcuts"),i("div",{class:"shortcuts-list"},Array.from(this.groupShortcutsByCategory()).map((([e,t])=>i("div",{class:"shortcuts-category",key:e},i("h4",{class:"shortcuts-category-title"},e),i("div",{class:"shortcuts-group"},t.map((e=>i("div",{class:"shortcut-item",key:e.key+e.label},i("span",{class:"shortcut-label"},e.label),i("kbd",{class:"shortcut-key"},this.formatKeyCombo(e)))))))))));case"developer":return i("div",{class:"settings-content"},i("h3",null,"Developer Options"),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Viewport Info"),i("p",{class:"settings-description"},"Display viewport debug information such as position, zoom level, and boundaries."),i("kritzel-slide-toggle",{checked:this.debugInfo.showViewportInfo,label:"Show Viewport Info",onCheckedChange:this.handleDebugInfoChange("showViewportInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Object Info"),i("p",{class:"settings-description"},"Display debug information about objects on the canvas."),i("kritzel-slide-toggle",{checked:this.debugInfo.showObjectInfo,label:"Show Object Info",onCheckedChange:this.handleDebugInfoChange("showObjectInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Sync Provider Info"),i("p",{class:"settings-description"},"Display debug information about the sync provider connection status."),i("kritzel-slide-toggle",{checked:this.debugInfo.showSyncProviderInfo,label:"Show Sync Provider Info",onCheckedChange:this.handleDebugInfoChange("showSyncProviderInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Migration Info"),i("p",{class:"settings-description"},"Display debug information about data migrations."),i("kritzel-slide-toggle",{checked:this.debugInfo.showMigrationInfo,label:"Show Migration Info",onCheckedChange:this.handleDebugInfoChange("showMigrationInfo")}))));case"about":return i("div",{class:"settings-content"},i("h3",null,"About"),i("p",null,"Kritzel - A drawing application"),i("p",{class:"version-info"},"Version ","0.3.13"),i("p",{class:"version-info"},"App-State Schema v",l),i("p",{class:"version-info"},"Workspace Schema v",a));default:return null}}render(){return i(o,{key:"46c6792ae9cdd932d3dc71526862c9281c0cefc1"},i("kritzel-dialog",{key:"1cd288cdf8b26bea378665c54bfc14577597fe49",isOpen:this.isDialogOpen,dialogTitle:"Settings",size:"large",contained:!0,onDialogClose:this.closeDialog},i("kritzel-master-detail",{key:"4d07e94ebb09035807356bab4bc7eaca57c36c6c",items:w,selectedItemId:this.selectedCategoryId,onItemSelect:this.handleCategorySelect},this.renderCategoryContent())))}static get watchers(){return{settings:[{onSettingsPropChange:0}]}}static get style(){return":host{display:contents}kritzel-dialog{--kritzel-dialog-body-padding:0;--kritzel-dialog-width-large:800px;--kritzel-dialog-height-large:500px}.footer-button{padding:8px 16px;border-radius:6px;cursor:pointer;font-size:14px}.cancel-button{border:1px solid #ebebeb;background:#fff;color:inherit}.cancel-button:hover{background:#f5f5f5}.settings-content{padding:0}.settings-content h3{margin:0 0 16px 0;font-size:18px;font-weight:600;color:var(--kritzel-settings-content-heading-color, #333333)}.settings-content p{margin:0;font-size:14px;color:var(--kritzel-settings-content-text-color, #666666);line-height:1.5}.settings-group{display:flex;flex-direction:column;gap:24px}.settings-item{display:flex;flex-direction:column;gap:8px}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.settings-label{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.settings-description{font-size:12px;color:var(--kritzel-settings-description-color, #888888);margin:0;line-height:1.4}.shortcuts-list{display:flex;flex-direction:column;gap:24px}.shortcuts-category{display:flex;flex-direction:column;gap:8px}.shortcuts-category-title{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.shortcuts-group{display:flex;flex-direction:column;gap:4px}.shortcut-item{display:flex;justify-content:space-between;align-items:center;padding:6px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-item-bg, rgba(0, 0, 0, 0.02))}.shortcut-label{font-size:14px;color:var(--kritzel-settings-content-text-color, #666666)}.shortcut-key{font-family:monospace;font-size:12px;padding:2px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-key-bg, #f0f0f0);color:var(--kritzel-settings-shortcut-key-color, #333333);border:1px solid var(--kritzel-settings-shortcut-key-border, #ddd)}"}},[513,"kritzel-settings",{availableThemes:[16],shortcuts:[16],settings:[16],isDialogOpen:[32],selectedCategoryId:[32],scaleMin:[32],scaleMax:[32],lockDrawingScale:[32],theme:[32],viewportBoundaryLeft:[32],viewportBoundaryRight:[32],viewportBoundaryTop:[32],viewportBoundaryBottom:[32],debugInfo:[32],open:[64]},void 0,{settings:[{onSettingsPropChange:0}]}]);function k(){"undefined"!=typeof customElements&&["kritzel-settings","kritzel-dialog","kritzel-dropdown","kritzel-icon","kritzel-master-detail","kritzel-numeric-input","kritzel-slide-toggle"].forEach((e=>{switch(e){case"kritzel-settings":customElements.get(n(e))||customElements.define(n(e),y);break;case"kritzel-dialog":customElements.get(n(e))||r();break;case"kritzel-dropdown":customElements.get(n(e))||c();break;case"kritzel-icon":customElements.get(n(e))||h();break;case"kritzel-master-detail":customElements.get(n(e))||d();break;case"kritzel-numeric-input":customElements.get(n(e))||g();break;case"kritzel-slide-toggle":customElements.get(n(e))||p()}}))}export{y as K,k as d}
|
|
1
|
+
import{p as e,H as t,c as s,h as i,d as o,t as n}from"./p-B43upypT.js";import{a,C as l}from"./p-CW-VyJgK.js";import{d as r}from"./p-CHrSFOSI.js";import{d as c}from"./p-Df3BwVGy.js";import{d as h}from"./p-DbB730vO.js";import{d}from"./p-D-sRVAbQ.js";import{d as g}from"./p-B5xxfwKF.js";import{d as p}from"./p-x6doYeiI.js";const u=-1/0,m=1/0,b=-1/0,f=1/0,v={showViewportInfo:!1,showObjectInfo:!1,showSyncProviderInfo:!0,showMigrationInfo:!0},w=[{id:"general",label:"General",icon:"settings"},{id:"viewport",label:"Viewport",icon:"viewport"},{id:"shortcuts",label:"Keyboard Shortcuts",icon:"command"},{id:"developer",label:"Developer Options",icon:"braces"},{id:"about",label:"About",icon:"info"}],y=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.settingsChange=s(this,"settingsChange")}get host(){return this}availableThemes=["light","dark"];shortcuts=[];settings;onSettingsPropChange(e){e&&this.applySettings(e)}isDialogOpen=!1;selectedCategoryId=w[0].id;scaleMin=1e-4;scaleMax=1e3;lockDrawingScale=!0;theme="light";viewportBoundaryLeft=u;viewportBoundaryRight=m;viewportBoundaryTop=b;viewportBoundaryBottom=f;debugInfo={...v};settingsChange;componentWillLoad(){this.settings&&this.applySettings(this.settings)}applySettings(e){"number"==typeof e.scaleMin&&(this.scaleMin=e.scaleMin),"number"==typeof e.scaleMax&&(this.scaleMax=e.scaleMax),"boolean"==typeof e.lockDrawingScale&&(this.lockDrawingScale=e.lockDrawingScale),"string"==typeof e.theme&&(this.theme=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={...v,...e.debugInfo})}emitSettings(){this.settingsChange.emit({scaleMin:this.scaleMin,scaleMax:this.scaleMax,lockDrawingScale:this.lockDrawingScale,theme:this.theme,viewportBoundaryLeft:this.viewportBoundaryLeft,viewportBoundaryRight:this.viewportBoundaryRight,viewportBoundaryTop:this.viewportBoundaryTop,viewportBoundaryBottom:this.viewportBoundaryBottom,debugInfo:this.debugInfo})}handleScaleMinChange=e=>{this.scaleMin=e.detail,this.emitSettings()};handleScaleMaxChange=e=>{this.scaleMax=e.detail,this.emitSettings()};handleLockDrawingScaleChange=e=>{this.lockDrawingScale=e.detail,this.emitSettings()};handleThemeChange=e=>{this.theme=e.detail,this.emitSettings()};handleViewportBoundaryLeftChange=e=>{this.viewportBoundaryLeft=e.detail??u,this.emitSettings()};handleViewportBoundaryRightChange=e=>{this.viewportBoundaryRight=e.detail??m,this.emitSettings()};handleViewportBoundaryTopChange=e=>{this.viewportBoundaryTop=e.detail??b,this.emitSettings()};handleViewportBoundaryBottomChange=e=>{this.viewportBoundaryBottom=e.detail??f,this.emitSettings()};handleDebugInfoChange=e=>t=>{this.debugInfo={...this.debugInfo,[e]:t.detail},this.emitSettings()};async open(){this.isDialogOpen=!0}closeDialog=()=>{this.isDialogOpen=!1};handleCategorySelect=e=>{this.selectedCategoryId=e.detail.item.id};formatKeyCombo(e){const t=[];return e.ctrl&&t.push("Ctrl"),e.shift&&t.push("Shift"),t.push(this.formatKey(e.key)),t.join("+")}formatKey(e){return{Escape:"Esc",Delete:"Del"," ":"Space"}[e]??e.toUpperCase()}groupShortcutsByCategory(){const e=new Map;for(const t of this.shortcuts){const s=e.get(t.category)||[];s.push(t),e.set(t.category,s)}return e}renderCategoryContent(){switch(this.selectedCategoryId){case"general":return i("div",{class:"settings-content"},i("h3",null,"General Settings"),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Theme"),i("p",{class:"settings-description"},"Select a registered color theme for the editor interface."),i("kritzel-dropdown",{options:this.availableThemes.map((e=>({value:e,label:e}))),value:this.theme,onValueChanged:this.handleThemeChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Lock Drawing Scale"),i("p",{class:"settings-description"},"When enabled, drawn objects maintain a fixed visual size regardless of the current zoom level."),i("kritzel-slide-toggle",{checked:this.lockDrawingScale,label:"Lock Drawing Scale",onCheckedChange:this.handleLockDrawingScaleChange}))));case"viewport":return i("div",{class:"settings-content"},i("h3",null,"Viewport Settings"),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Minimum Zoom Level"),i("p",{class:"settings-description"},"Sets the minimum zoom level. Lower values allow zooming out further to see more of the canvas."),i("kritzel-numeric-input",{value:this.scaleMin,min:1e-4,max:1,step:1e-4,onValueChange:this.handleScaleMinChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Maximum Zoom Level"),i("p",{class:"settings-description"},"Sets the maximum zoom level. Higher values allow zooming in closer for detailed work."),i("kritzel-numeric-input",{value:this.scaleMax,min:1,max:1e3,step:1,onValueChange:this.handleScaleMaxChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Left"),i("p",{class:"settings-description"},"Left boundary in world coordinates. Set to limit how far left the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryLeft,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryLeftChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Right"),i("p",{class:"settings-description"},"Right boundary in world coordinates. Set to limit how far right the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryRight,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryRightChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Top"),i("p",{class:"settings-description"},"Top boundary in world coordinates. Set to limit how far up the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryTop,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryTopChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Bottom"),i("p",{class:"settings-description"},"Bottom boundary in world coordinates. Set to limit how far down the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryBottom,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryBottomChange}))));case"shortcuts":return i("div",{class:"settings-content"},i("h3",null,"Keyboard Shortcuts"),i("div",{class:"shortcuts-list"},Array.from(this.groupShortcutsByCategory()).map((([e,t])=>i("div",{class:"shortcuts-category",key:e},i("h4",{class:"shortcuts-category-title"},e),i("div",{class:"shortcuts-group"},t.map((e=>i("div",{class:"shortcut-item",key:e.key+e.label},i("span",{class:"shortcut-label"},e.label),i("kbd",{class:"shortcut-key"},this.formatKeyCombo(e)))))))))));case"developer":return i("div",{class:"settings-content"},i("h3",null,"Developer Options"),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Viewport Info"),i("p",{class:"settings-description"},"Display viewport debug information such as position, zoom level, and boundaries."),i("kritzel-slide-toggle",{checked:this.debugInfo.showViewportInfo,label:"Show Viewport Info",onCheckedChange:this.handleDebugInfoChange("showViewportInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Object Info"),i("p",{class:"settings-description"},"Display debug information about objects on the canvas."),i("kritzel-slide-toggle",{checked:this.debugInfo.showObjectInfo,label:"Show Object Info",onCheckedChange:this.handleDebugInfoChange("showObjectInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Sync Provider Info"),i("p",{class:"settings-description"},"Display debug information about the sync provider connection status."),i("kritzel-slide-toggle",{checked:this.debugInfo.showSyncProviderInfo,label:"Show Sync Provider Info",onCheckedChange:this.handleDebugInfoChange("showSyncProviderInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Migration Info"),i("p",{class:"settings-description"},"Display debug information about data migrations."),i("kritzel-slide-toggle",{checked:this.debugInfo.showMigrationInfo,label:"Show Migration Info",onCheckedChange:this.handleDebugInfoChange("showMigrationInfo")}))));case"about":return i("div",{class:"settings-content"},i("h3",null,"About"),i("p",null,"Kritzel - A drawing application"),i("p",{class:"version-info"},"Version ","0.3.15"),i("p",{class:"version-info"},"App-State Schema v",l),i("p",{class:"version-info"},"Workspace Schema v",a));default:return null}}render(){return i(o,{key:"46c6792ae9cdd932d3dc71526862c9281c0cefc1"},i("kritzel-dialog",{key:"1cd288cdf8b26bea378665c54bfc14577597fe49",isOpen:this.isDialogOpen,dialogTitle:"Settings",size:"large",contained:!0,onDialogClose:this.closeDialog},i("kritzel-master-detail",{key:"4d07e94ebb09035807356bab4bc7eaca57c36c6c",items:w,selectedItemId:this.selectedCategoryId,onItemSelect:this.handleCategorySelect},this.renderCategoryContent())))}static get watchers(){return{settings:[{onSettingsPropChange:0}]}}static get style(){return":host{display:contents}kritzel-dialog{--kritzel-dialog-body-padding:0;--kritzel-dialog-width-large:800px;--kritzel-dialog-height-large:500px}.footer-button{padding:8px 16px;border-radius:6px;cursor:pointer;font-size:14px}.cancel-button{border:1px solid #ebebeb;background:#fff;color:inherit}.cancel-button:hover{background:#f5f5f5}.settings-content{padding:0}.settings-content h3{margin:0 0 16px 0;font-size:18px;font-weight:600;color:var(--kritzel-settings-content-heading-color, #333333)}.settings-content p{margin:0;font-size:14px;color:var(--kritzel-settings-content-text-color, #666666);line-height:1.5}.settings-group{display:flex;flex-direction:column;gap:24px}.settings-item{display:flex;flex-direction:column;gap:8px}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.settings-label{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.settings-description{font-size:12px;color:var(--kritzel-settings-description-color, #888888);margin:0;line-height:1.4}.shortcuts-list{display:flex;flex-direction:column;gap:24px}.shortcuts-category{display:flex;flex-direction:column;gap:8px}.shortcuts-category-title{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.shortcuts-group{display:flex;flex-direction:column;gap:4px}.shortcut-item{display:flex;justify-content:space-between;align-items:center;padding:6px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-item-bg, rgba(0, 0, 0, 0.02))}.shortcut-label{font-size:14px;color:var(--kritzel-settings-content-text-color, #666666)}.shortcut-key{font-family:monospace;font-size:12px;padding:2px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-key-bg, #f0f0f0);color:var(--kritzel-settings-shortcut-key-color, #333333);border:1px solid var(--kritzel-settings-shortcut-key-border, #ddd)}"}},[513,"kritzel-settings",{availableThemes:[16],shortcuts:[16],settings:[16],isDialogOpen:[32],selectedCategoryId:[32],scaleMin:[32],scaleMax:[32],lockDrawingScale:[32],theme:[32],viewportBoundaryLeft:[32],viewportBoundaryRight:[32],viewportBoundaryTop:[32],viewportBoundaryBottom:[32],debugInfo:[32],open:[64]},void 0,{settings:[{onSettingsPropChange:0}]}]);function k(){"undefined"!=typeof customElements&&["kritzel-settings","kritzel-dialog","kritzel-dropdown","kritzel-icon","kritzel-master-detail","kritzel-numeric-input","kritzel-slide-toggle"].forEach((e=>{switch(e){case"kritzel-settings":customElements.get(n(e))||customElements.define(n(e),y);break;case"kritzel-dialog":customElements.get(n(e))||r();break;case"kritzel-dropdown":customElements.get(n(e))||c();break;case"kritzel-icon":customElements.get(n(e))||h();break;case"kritzel-master-detail":customElements.get(n(e))||d();break;case"kritzel-numeric-input":customElements.get(n(e))||g();break;case"kritzel-slide-toggle":customElements.get(n(e))||p()}}))}export{y as K,k as d}
|