kritzel-stencil 0.2.2 → 0.2.3

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.
Files changed (72) hide show
  1. package/dist/cjs/index.cjs.js +1 -1
  2. package/dist/cjs/kritzel-active-users_42.cjs.entry.js +30 -25
  3. package/dist/cjs/{workspace.migrations-BPwtowiJ.js → workspace.migrations-CYeB_XRB.js} +8 -0
  4. package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +5 -5
  5. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +7 -0
  6. package/dist/collection/components/shared/kritzel-dialog/kritzel-dialog.css +3 -2
  7. package/dist/collection/components/shared/kritzel-dialog/kritzel-dialog.js +3 -2
  8. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +7 -10
  9. package/dist/collection/components/ui/kritzel-current-user/kritzel-current-user.js +1 -1
  10. package/dist/collection/components/ui/kritzel-current-user-dialog/kritzel-current-user-dialog.js +1 -1
  11. package/dist/collection/components/ui/kritzel-export/kritzel-export.js +1 -1
  12. package/dist/collection/components/ui/kritzel-login-dialog/kritzel-login-dialog.js +1 -1
  13. package/dist/collection/components/ui/kritzel-more-menu/kritzel-more-menu.js +1 -1
  14. package/dist/collection/components/ui/kritzel-settings/kritzel-settings.js +1 -1
  15. package/dist/collection/components/ui/kritzel-share-dialog/kritzel-share-dialog.js +2 -2
  16. package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +1 -1
  17. package/dist/collection/constants/version.js +1 -1
  18. package/dist/collection/themes/dark-theme.js +4 -0
  19. package/dist/collection/themes/light-theme.js +4 -0
  20. package/dist/components/index.js +1 -1
  21. package/dist/components/kritzel-awareness-cursors.js +1 -1
  22. package/dist/components/kritzel-color-palette.js +1 -1
  23. package/dist/components/kritzel-color.js +1 -1
  24. package/dist/components/kritzel-controls.js +1 -1
  25. package/dist/components/kritzel-current-user-dialog.js +1 -1
  26. package/dist/components/kritzel-current-user.js +1 -1
  27. package/dist/components/kritzel-dialog.js +1 -1
  28. package/dist/components/kritzel-editor.js +1 -1
  29. package/dist/components/kritzel-engine.js +1 -1
  30. package/dist/components/kritzel-export.js +1 -1
  31. package/dist/components/kritzel-login-dialog.js +1 -1
  32. package/dist/components/kritzel-more-menu.js +1 -1
  33. package/dist/components/kritzel-settings.js +1 -1
  34. package/dist/components/kritzel-share-dialog.js +1 -1
  35. package/dist/components/kritzel-stroke-size.js +1 -1
  36. package/dist/components/kritzel-tool-config.js +1 -1
  37. package/dist/components/kritzel-utility-panel.js +1 -1
  38. package/dist/components/p-0F9_lw6l.js +1 -0
  39. package/dist/components/{p-mYhFNPgz.js → p-BAjrJjMX.js} +1 -1
  40. package/dist/components/{p-R9M5PnAz.js → p-BDOSy6zd.js} +1 -1
  41. package/dist/components/{p-574MVXxi.js → p-Be6E_RMf.js} +1 -1
  42. package/dist/components/p-BeeKeeeo.js +1 -0
  43. package/dist/components/{p-CoyqJSjT.js → p-BmYsz1bP.js} +1 -1
  44. package/dist/components/{p-DFeyobdy.js → p-Bs7lEBy5.js} +2 -2
  45. package/dist/components/p-C-qyWv4d.js +1 -0
  46. package/dist/components/{p-BYOIzv_f.js → p-C1Fv9rVN.js} +1 -1
  47. package/dist/components/{p-C6Td7I4k.js → p-C1UNiqO2.js} +1 -1
  48. package/dist/components/{p-Bfa-Amjn.js → p-C2MdRsg6.js} +1 -1
  49. package/dist/components/{p-DE2xDwUM.js → p-CdaOQi45.js} +1 -1
  50. package/dist/components/{p-u-827ZX7.js → p-CsMMZSAP.js} +1 -1
  51. package/dist/components/{p-Dxb22STM.js → p-DYHF_MSN.js} +1 -1
  52. package/dist/components/{p-BWrxz4mM.js → p-Dg_nGsFe.js} +1 -1
  53. package/dist/components/{p-BtJB7FsW.js → p-DoDI-v-H.js} +1 -1
  54. package/dist/components/p-R60vdaIY.js +1 -0
  55. package/dist/components/{p-CU6kJPth.js → p-ZpItdhxS.js} +1 -1
  56. package/dist/components/{p-DfB7uJ0N.js → p-yX5Zk5pS.js} +1 -1
  57. package/dist/esm/index.js +2 -2
  58. package/dist/esm/kritzel-active-users_42.entry.js +30 -25
  59. package/dist/esm/{workspace.migrations-C_uxbvuH.js → workspace.migrations-BrA5xRPn.js} +8 -0
  60. package/dist/stencil/index.esm.js +1 -1
  61. package/dist/stencil/p-56b81681.entry.js +9 -0
  62. package/dist/stencil/p-BrA5xRPn.js +1 -0
  63. package/dist/stencil/stencil.esm.js +1 -1
  64. package/dist/types/constants/version.d.ts +1 -1
  65. package/dist/types/interfaces/theme.interface.d.ts +5 -5
  66. package/package.json +1 -1
  67. package/dist/components/p-BCzbwL4m.js +0 -1
  68. package/dist/components/p-BfJav4Zz.js +0 -1
  69. package/dist/components/p-BmcAX-1k.js +0 -1
  70. package/dist/components/p-CqYIRmoh.js +0 -1
  71. package/dist/stencil/p-4d28c496.entry.js +0 -9
  72. package/dist/stencil/p-C_uxbvuH.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, h, H as Host, c as createEvent, g as getElement } from './index-D9HaikfQ.js';
2
- import { b as KritzelPath, d as KritzelLine, G as KritzelColorHelper, n as KritzelSelectionTool, g as KritzelBrushTool, h as KritzelLineTool, l as KritzelShapeTool, k as KritzelTextTool, J as KritzelDevicesHelper, L as KritzelMouseButton, M as DEFAULT_COLOR_PALETTE, S as ShapeType, I as IndexedDBSyncProvider, D as DEFAULT_BRUSH_CONFIG, i as KritzelEraserTool, u as DEFAULT_LINE_TOOL_CONFIG, t as DEFAULT_TEXT_CONFIG, j as KritzelImageTool, y as KritzelAlignment, v as DEFAULT_ASSET_STORAGE_CONFIG, N as KritzelSelectionGroup, O as KritzelSelectionBox, P as KritzelIconRegistry, Q as KritzelKeyboardHelper, R as KritzelBaseHandler, T as KritzelToolRegistry, U as KritzelBaseObject, q as KritzelWorkspace, e as KritzelGroup, c as KritzelImage, f as KritzelShape, K as KritzelText, B as runMigrations, z as CURRENT_WORKSPACE_SCHEMA_VERSION, F as WORKSPACE_MIGRATIONS, C as CURRENT_APP_STATE_SCHEMA_VERSION, E as APP_STATE_MIGRATIONS, V as ObjectHelper, m as KritzelCursorHelper, r as KritzelAnchorManager, s as KritzelThemeManager, o as KritzelAssetResolver, X as KritzelClassHelper, Y as KritzelEventHelper, Z as KritzelBaseTool, W as WORKSPACE_EXPORT_VERSION } from './workspace.migrations-C_uxbvuH.js';
2
+ import { b as KritzelPath, d as KritzelLine, G as KritzelColorHelper, n as KritzelSelectionTool, g as KritzelBrushTool, h as KritzelLineTool, l as KritzelShapeTool, k as KritzelTextTool, J as KritzelDevicesHelper, L as KritzelMouseButton, M as DEFAULT_COLOR_PALETTE, S as ShapeType, I as IndexedDBSyncProvider, D as DEFAULT_BRUSH_CONFIG, i as KritzelEraserTool, u as DEFAULT_LINE_TOOL_CONFIG, t as DEFAULT_TEXT_CONFIG, j as KritzelImageTool, y as KritzelAlignment, v as DEFAULT_ASSET_STORAGE_CONFIG, N as KritzelSelectionGroup, O as KritzelSelectionBox, P as KritzelIconRegistry, Q as KritzelKeyboardHelper, R as KritzelBaseHandler, T as KritzelToolRegistry, U as KritzelBaseObject, q as KritzelWorkspace, e as KritzelGroup, c as KritzelImage, f as KritzelShape, K as KritzelText, B as runMigrations, z as CURRENT_WORKSPACE_SCHEMA_VERSION, F as WORKSPACE_MIGRATIONS, C as CURRENT_APP_STATE_SCHEMA_VERSION, E as APP_STATE_MIGRATIONS, V as ObjectHelper, m as KritzelCursorHelper, r as KritzelAnchorManager, s as KritzelThemeManager, o as KritzelAssetResolver, X as KritzelClassHelper, Y as KritzelEventHelper, Z as KritzelBaseTool, W as WORKSPACE_EXPORT_VERSION } from './workspace.migrations-BrA5xRPn.js';
3
3
  import * as Y from 'yjs';
4
4
  import 'y-indexeddb';
5
5
  import 'y-websocket';
@@ -935,10 +935,7 @@ const KritzelControls = class {
935
935
  }
936
936
  handleDisplayValuesChange = (event) => {
937
937
  const newVal = event.detail;
938
- if (this.displayValues &&
939
- this.displayValues.color === newVal.color &&
940
- this.displayValues.size === newVal.size &&
941
- this.displayValues.fontFamily === newVal.fontFamily) {
938
+ if (this.displayValues && this.displayValues.color === newVal.color && this.displayValues.size === newVal.size && this.displayValues.fontFamily === newVal.fontFamily) {
942
939
  return;
943
940
  }
944
941
  this.displayValues = newVal;
@@ -1070,13 +1067,13 @@ const KritzelControls = class {
1070
1067
  // Separate tool controls from config control
1071
1068
  const toolControls = this.controls.filter(c => c.type === 'tool' || c.type === 'separator');
1072
1069
  const configControl = this.controls.find(c => c.type === 'config' && c.name === this.firstConfig?.name);
1073
- return (h(Host, { key: 'ea5e17d6995c228862b6d3375213b8f4ff05f04b', class: {
1070
+ return (h(Host, { key: '93d08a3268edb67fc4cccb291b6e0aff6cf5a4bd', class: {
1074
1071
  mobile: this.isTouchDevice,
1075
- } }, this.isUtilityPanelVisible && (h("kritzel-utility-panel", { key: '3296551d078f9d358efff1438fdcf723349fa5e1', style: {
1072
+ } }, this.isUtilityPanelVisible && (h("kritzel-utility-panel", { key: '8862ea7e524b3e23d87ffea2929e04df7231bb0c', style: {
1076
1073
  position: 'absolute',
1077
1074
  bottom: '56px',
1078
1075
  left: '12px',
1079
- }, undoState: this.undoState, onUndo: () => this.kritzelEngine?.undo(), onRedo: () => this.kritzelEngine?.redo(), onDelete: () => this.kritzelEngine?.delete() })), h("div", { key: '9cbea189d5875cda4f09dc7228345e0cb268d47d', class: "kritzel-controls" }, h("div", { key: '0df655a7ac5bd6bc164b82703bc212b480058ba2', class: { 'scroll-indicator-left': true, 'visible': this.canScrollLeft } }), h("div", { key: 'bc16b645b6c6a12ec6bd8420a8d84aee83d2b6d2', class: "kritzel-tools-scroll", ref: el => this.toolsScrollRef = el, onScroll: this.handleToolsScroll }, toolControls.map(control => {
1076
+ }, undoState: this.undoState, onUndo: () => this.kritzelEngine?.undo(), onRedo: () => this.kritzelEngine?.redo(), onDelete: () => this.kritzelEngine?.delete() })), h("div", { key: '2ea2a41ba4cda77f5abde9231d293da181a2a568', class: "kritzel-controls" }, h("div", { key: '6bd4f6d930a0a51d5549b6dbae1e7be14cbe7822', class: { 'scroll-indicator-left': true, 'visible': this.canScrollLeft } }), h("div", { key: 'c712ca502a4ebd244394158b39391a49839bc386', class: "kritzel-tools-scroll", ref: el => (this.toolsScrollRef = el), onScroll: this.handleToolsScroll }, toolControls.map(control => {
1080
1077
  // Check if this control has sub-options (split-button)
1081
1078
  if (control.subOptions?.length) {
1082
1079
  const selectedSubOption = this.getSelectedSubOption(control);
@@ -1106,10 +1103,10 @@ const KritzelControls = class {
1106
1103
  'kritzel-control': true,
1107
1104
  'selected': this.activeControl?.name === control?.name,
1108
1105
  }, key: control.name, "data-testid": `tool-${control.name}`, onClick: _event => this.handleControlClick?.(control) }, h("kritzel-icon", { name: control.icon })));
1109
- })), h("div", { key: '2e0824a991997d52168a3d922c2214ed66f5bf57', class: { 'scroll-indicator-right': true, 'visible': this.canScrollRight && !(configControl && this.activeControl && hasConfigUI) } }), configControl && this.activeControl && (h("div", { class: {
1106
+ })), h("div", { key: '6ca260915b2880443a324855a1de96d10affd256', class: { 'scroll-indicator-right': true, 'visible': this.canScrollRight && !(configControl && this.activeControl && hasConfigUI) } }), configControl && this.activeControl && (h("div", { class: {
1110
1107
  'kritzel-config-container': true,
1111
1108
  'visible': hasConfigUI,
1112
- }, key: configControl.name }, h("div", { key: 'd2cb554f56ce0f3bfe72e85fcbb506199387c15f', class: { 'config-gradient-left': true, 'visible': this.needsScrolling } }), h("kritzel-tooltip", { key: '39412859a99c71b536e0b2ed0045b671a975af7e', anchorElement: this.host.shadowRoot?.querySelector('.kritzel-config-container'), triggerElement: this.configTriggerRef }, h("kritzel-tool-config", { key: '1977ceddd337df53e8636e2bddd1d928aca3a1ff', tool: this.activeControl.tool, theme: this.theme, onToolChange: event => this.handleToolChange?.(event), onDisplayValuesChange: this.handleDisplayValuesChange, style: { width: '100%', height: '100%' } })), h("div", { key: '06bd3bf3558931a0c2317e149d8990f42e77adae', tabIndex: hasConfigUI ? 0 : -1, class: "kritzel-config", "data-testid": "tool-config", ref: el => {
1109
+ }, key: configControl.name }, h("div", { key: '984d30bd7f508d2fc56a9e81692fdf05dfb852c9', class: { 'config-gradient-left': true, 'visible': this.needsScrolling } }), h("kritzel-tooltip", { key: '90c59995d229c606b9bf3b625f6eefc0632371c6', anchorElement: this.host.shadowRoot?.querySelector('.kritzel-config-container'), triggerElement: this.configTriggerRef }, h("kritzel-tool-config", { key: 'cdb56f983e1f6840b11d06d166f982a93c07331b', tool: this.activeControl.tool, theme: this.theme, onToolChange: event => this.handleToolChange?.(event), onDisplayValuesChange: this.handleDisplayValuesChange, style: { width: '100%', height: '100%' } })), h("div", { key: 'c79db07dd02995d3ee105e8d7a773f89cd7072a5', tabIndex: hasConfigUI ? 0 : -1, class: "kritzel-config", "data-testid": "tool-config", ref: el => {
1113
1110
  if (el)
1114
1111
  this.configTriggerRef = el;
1115
1112
  }, onKeyDown: event => {
@@ -1118,7 +1115,7 @@ const KritzelControls = class {
1118
1115
  }
1119
1116
  }, style: {
1120
1117
  cursor: 'pointer',
1121
- } }, this.activeControl.tool instanceof KritzelTextTool && this.displayValues ? (h("div", { class: "font-container" }, h("kritzel-font", { fontFamily: this.displayValues.fontFamily, size: this.displayValues.size, color: this.displayValues.color }))) : this.displayValues && (h("div", { class: "color-container" }, h("kritzel-color", { value: this.displayValues.color, theme: this.theme, size: this.displayValues.size, style: {
1118
+ } }, this.displayValues && (h("div", { key: '0573a22c3105076729eb986c98b7e8644392f767', class: "color-container" }, h("kritzel-color", { key: '1e9711c219a5c520873b3206072957f2d406c56c', value: this.displayValues.color, theme: this.theme, size: 18, style: {
1122
1119
  borderRadius: '50%',
1123
1120
  border: 'none',
1124
1121
  } })))))))));
@@ -1153,7 +1150,7 @@ const KritzelCurrentUser = class {
1153
1150
  this.dialogRef?.open();
1154
1151
  };
1155
1152
  render() {
1156
- return (h(Host, { key: 'a735cb9f16f4898fde0b52573affa2d270a8f1de' }, h("kritzel-avatar", { key: 'd449a515182718ab4ef3b26b2277696bbc7ab46f', user: this.user, size: this.avatarSize, onClick: this.handleAvatarClick }), h("kritzel-current-user-dialog", { key: '3542f6df43c9924218e344f70bdc398c74a8eae6', ref: el => (this.dialogRef = el), user: this.user })));
1153
+ return (h(Host, { key: 'c392caf731f8352fd8e2a95918fe48a2f00dd9e5' }, h("kritzel-avatar", { key: 'b3bdce0efa0c0610aa028303386c643d53bc8300', user: this.user, size: this.avatarSize, onClick: this.handleAvatarClick }), h("kritzel-current-user-dialog", { key: '5e7af1aea468028e091ad8f461e4352cb9f9636b', ref: el => (this.dialogRef = el), user: this.user })));
1157
1154
  }
1158
1155
  };
1159
1156
  KritzelCurrentUser.style = kritzelCurrentUserCss();
@@ -1185,7 +1182,7 @@ const KritzelCurrentUserDialog = class {
1185
1182
  }
1186
1183
  render() {
1187
1184
  const displayName = this.getDisplayName();
1188
- return (h(Host, { key: '40c1a1bed0ddf02f9835199b5f7d2363e4d1902b' }, h("kritzel-dialog", { key: '8d10cd2dbdec06c0519f5a8f6f0f113d30b978aa', dialogTitle: "Account", isOpen: this.isDialogOpen, onDialogClose: this.closeDialog, size: "small" }, h("div", { key: '24d8267d37fde77ce1a26efb84a9eaa3320dd6b7', class: "user-info" }, h("kritzel-avatar", { key: '282153dea220d8aa4a509764e2dcbcf20a6f2682', user: this.user, size: 80 }), displayName && h("div", { key: '3a908e583a8eb0aca4020eb78d76821b82b1c643', class: "user-name" }, displayName), this.user?.email && h("div", { key: '2aadf821b6f91c6bd76f10ff234d94ab8b79dd9c', class: "user-email" }, this.user.email)))));
1185
+ return (h(Host, { key: 'e1dd44cdfdbaebfe886fed0d9feba2ef232b6615' }, h("kritzel-dialog", { key: '49dd037cca0741cc949f20d9d44cfd028492dc60', dialogTitle: "Account", isOpen: this.isDialogOpen, onDialogClose: this.closeDialog, size: "small" }, h("div", { key: 'ddcdfb82cc0c896025559888d475ab5c9ad59b4c', class: "user-info" }, h("kritzel-avatar", { key: '4d164b784cde6787d26ac164c7450c0352e6a7cb', user: this.user, size: 80 }), displayName && h("div", { key: '13ad719d8bd90cd608c78438fccbb38ed1d5e5ba', class: "user-name" }, displayName), this.user?.email && h("div", { key: 'df360afd434293d9c9d5fcf114713e0a6925a78e', class: "user-email" }, this.user.email)))));
1189
1186
  }
1190
1187
  };
1191
1188
  KritzelCurrentUserDialog.style = kritzelCurrentUserDialogCss();
@@ -1346,7 +1343,7 @@ class KritzelHTMLHelper {
1346
1343
  }
1347
1344
  }
1348
1345
 
1349
- const kritzelDialogCss = () => `:host{display:contents}.backdrop{position:fixed;top:0;left:0;right:0;bottom:0;z-index:10002;display:flex;align-items:center;justify-content:center;background-color:var(--kritzel-dialog-backdrop-color, rgba(0, 0, 0, 0.5));opacity:1;transition:opacity 150ms ease-out}.backdrop.is-animating{opacity:0}.dialog-content{position:relative;display:flex;flex-direction:column;background-color:var(--kritzel-dialog-background-color, #ffffff);border-radius:var(--kritzel-dialog-border-radius, 12px);box-shadow:var(--kritzel-dialog-box-shadow, 0 4px 20px rgba(0, 0, 0, 0.15));border:var(--kritzel-dialog-border, 1px solid #ebebeb);max-height:var(--kritzel-dialog-max-height, 90vh);max-width:var(--kritzel-dialog-max-width, 90vw);overflow:hidden;transform:scale(1);opacity:1;transition:transform 200ms ease-out, opacity 200ms ease-out;font-family:var(--kritzel-dialog-font-family, sans-serif)}.dialog-content.is-animating{transform:scale(0.95);opacity:0}.dialog-content.size-small{width:var(--kritzel-dialog-width-small, 320px);height:var(--kritzel-dialog-height-small, auto)}.dialog-content.size-medium{width:var(--kritzel-dialog-width-medium, 480px);height:var(--kritzel-dialog-height-medium, auto)}.dialog-content.size-large{width:var(--kritzel-dialog-width-large, 640px);height:var(--kritzel-dialog-height-large, auto)}.dialog-content.size-fullscreen{width:100vw;height:100vh;height:100dvh;max-width:100vw;max-height:100vh;max-height:100dvh;border-radius:0}@media (max-width: 576px){.backdrop:has(.fullscreen-on-mobile){background-color:transparent}.dialog-content.fullscreen-on-mobile{width:100vw;height:100vh;height:100dvh;max-width:100vw;max-height:100vh;max-height:100dvh;border-radius:0}.dialog-content.fullscreen-on-mobile .dialog-body{display:flex;flex-direction:column}.dialog-content.fullscreen-on-mobile .dialog-body ::slotted(*){flex:1;min-height:0}}.dialog-header{display:flex;align-items:center;justify-content:space-between;padding:var(--kritzel-dialog-header-padding, 16px 20px);border-bottom:var(--kritzel-dialog-header-border, 1px solid #ebebeb);gap:12px}.dialog-title{margin:0;font-size:var(--kritzel-dialog-title-font-size, 18px);font-weight:var(--kritzel-dialog-title-font-weight, 600);color:var(--kritzel-dialog-title-color, #1a1a1a);flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.close-button{display:flex;align-items:center;justify-content:center;width:32px;height:32px;padding:0;border:none;border-radius:var(--kritzel-dialog-close-button-border-radius, 6px);background-color:var(--kritzel-dialog-close-button-background, transparent);color:var(--kritzel-dialog-close-button-color, #666666);cursor:var(--kritzel-global-pointer-cursor, pointer);transition:background-color 150ms ease, color 150ms ease;flex-shrink:0;-webkit-tap-highlight-color:transparent}.close-button:hover{background-color:var(--kritzel-dialog-close-button-hover-background, #f5f5f5);color:var(--kritzel-dialog-close-button-hover-color, #1a1a1a)}.close-button:active{background-color:var(--kritzel-dialog-close-button-active-background, #ebebeb)}.close-button:focus-visible{outline:revert;outline-offset:revert}.dialog-body{padding:var(--kritzel-dialog-body-padding, 20px);overflow-y:auto;flex:1;min-height:0;scrollbar-color:var(--kritzel-global-scrollbar-thumb-color, #ebebeb) transparent;scrollbar-width:thin}.dialog-footer{display:flex;align-items:center;justify-content:flex-end;gap:var(--kritzel-dialog-footer-gap, 8px);padding:var(--kritzel-dialog-footer-padding, 16px 20px);border-top:var(--kritzel-dialog-footer-border, 1px solid #ebebeb)}::slotted([slot='header']){flex:1}::slotted([slot='footer']){display:contents}`;
1346
+ const kritzelDialogCss = () => `:host{display:contents}.backdrop{position:fixed;top:0;left:0;right:0;bottom:0;z-index:10002;display:flex;align-items:center;justify-content:center;background-color:var(--kritzel-dialog-backdrop-color, rgba(0, 0, 0, 0.5));opacity:1;transition:opacity 150ms ease-out}.backdrop.is-animating{opacity:0}.dialog-content{position:relative;display:flex;flex-direction:column;background-color:var(--kritzel-dialog-background-color, #ffffff);border-radius:var(--kritzel-dialog-border-radius, 12px);box-shadow:var(--kritzel-dialog-box-shadow, 0 4px 20px rgba(0, 0, 0, 0.15));border:var(--kritzel-dialog-border, 1px solid #ebebeb);max-height:var(--kritzel-dialog-max-height, 90vh);max-width:var(--kritzel-dialog-max-width, 90vw);overflow:hidden;transform:scale(1);opacity:1;transition:transform 200ms ease-out, opacity 200ms ease-out;font-family:var(--kritzel-dialog-font-family, sans-serif)}.dialog-content.is-animating{transform:scale(0.95);opacity:0}.dialog-content.size-small{width:var(--kritzel-dialog-width-small, 320px);height:var(--kritzel-dialog-height-small, auto)}.dialog-content.size-medium{width:var(--kritzel-dialog-width-medium, 480px);height:var(--kritzel-dialog-height-medium, auto)}.dialog-content.size-large{width:var(--kritzel-dialog-width-large, 640px);height:var(--kritzel-dialog-height-large, auto)}.dialog-content.size-fullscreen{width:100vw;height:100vh;height:100dvh;max-width:100vw;max-height:100vh;max-height:100dvh;border-radius:0}@media (max-width: 576px), (max-height: 576px) and (orientation: landscape){.backdrop:has(.fullscreen-on-mobile){background-color:transparent}.dialog-content.fullscreen-on-mobile{width:100vw;height:100vh;height:100dvh;max-width:100vw;max-height:100vh;max-height:100dvh;border-radius:0}.dialog-content.fullscreen-on-mobile .dialog-body{display:flex;flex-direction:column}.dialog-content.fullscreen-on-mobile .dialog-body ::slotted(*){flex:1;min-height:0}}.dialog-header{display:flex;align-items:center;justify-content:space-between;padding:var(--kritzel-dialog-header-padding, 16px 20px);border-bottom:var(--kritzel-dialog-header-border, 1px solid #ebebeb);gap:12px}.dialog-title{margin:0;font-size:var(--kritzel-dialog-title-font-size, 18px);font-weight:var(--kritzel-dialog-title-font-weight, 600);color:var(--kritzel-dialog-title-color, #1a1a1a);flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.close-button{display:flex;align-items:center;justify-content:center;width:32px;height:32px;padding:0;border:none;border-radius:var(--kritzel-dialog-close-button-border-radius, 6px);background-color:var(--kritzel-dialog-close-button-background, transparent);color:var(--kritzel-dialog-close-button-color, #666666);cursor:var(--kritzel-global-pointer-cursor, pointer);transition:background-color 150ms ease, color 150ms ease;flex-shrink:0;-webkit-tap-highlight-color:transparent}.close-button:hover{background-color:var(--kritzel-dialog-close-button-hover-background, #f5f5f5);color:var(--kritzel-dialog-close-button-hover-color, #1a1a1a)}.close-button:active{background-color:var(--kritzel-dialog-close-button-active-background, #ebebeb)}.close-button:focus-visible{outline:revert;outline-offset:revert}.dialog-body{padding:var(--kritzel-dialog-body-padding, 20px);overflow-y:auto;flex:1;min-height:0;scrollbar-color:var(--kritzel-global-scrollbar-thumb-color, #ebebeb) transparent;scrollbar-width:thin}.dialog-footer{display:flex;align-items:center;justify-content:flex-end;gap:var(--kritzel-dialog-footer-gap, 8px);padding:var(--kritzel-dialog-footer-padding, 16px 20px);border-top:var(--kritzel-dialog-footer-border, 1px solid #ebebeb)}::slotted([slot='header']){flex:1}::slotted([slot='footer']){display:contents}`;
1350
1347
 
1351
1348
  const KritzelDialog = class {
1352
1349
  constructor(hostRef) {
@@ -1448,8 +1445,9 @@ const KritzelDialog = class {
1448
1445
  document.body.style.overflow = 'hidden';
1449
1446
  }
1450
1447
  lockMobileViewportHeight() {
1451
- // Only lock height on mobile when fullscreenOnMobile is enabled
1452
- if (!this.fullscreenOnMobile || window.innerWidth > 576) {
1448
+ // Only lock height on mobile when fullscreenOnMobile is enabled.
1449
+ // Use the smaller dimension so landscape phones (wide but short) are also detected.
1450
+ if (!this.fullscreenOnMobile || Math.min(window.innerWidth, window.innerHeight) > 576) {
1453
1451
  this.mobileLockedHeight = null;
1454
1452
  return;
1455
1453
  }
@@ -25756,7 +25754,7 @@ async function toPng(node, options = {}) {
25756
25754
  return canvas.toDataURL();
25757
25755
  }
25758
25756
 
25759
- const kritzelEngineCss = () => `:host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}:host,:host *{touch-action:none;user-select:none}.ProseMirror{outline:none}p,h1,h2,h3,h4,h5,h6,blockquote,pre{margin:0;padding:0}.workspace-loading-overlay{position:absolute;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;gap:10px;background-color:var(--kritzel-loading-overlay-background, rgba(255, 255, 255, 0.6));color:var(--kritzel-loading-overlay-color, #333);font-family:var(--kritzel-font-family, sans-serif);font-size:1.25rem;pointer-events:all;animation:workspace-loading-fade-in 200ms ease-out var(--kritzel-loading-overlay-delay, 300ms) forwards;opacity:0}.workspace-loading-spinner{width:20px;height:20px;box-sizing:border-box;display:block;flex-shrink:0;border:2px solid var(--kritzel-loading-overlay-spinner-color, #cccccc);border-top-color:var(--kritzel-loading-overlay-spinner-active-color, #333333);border-radius:50%;animation:workspace-loading-spin 0.6s linear infinite}@keyframes workspace-loading-spin{to{transform:rotate(360deg)}}@keyframes workspace-loading-fade-in{to{opacity:1}}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}.PlaygroundEditorTheme__quote{margin:0;margin-left:20px;margin-bottom:10px;font-size:15px;color:rgb(101, 103, 107);border-left-color:rgb(206, 208, 212);border-left-width:4px;border-left-style:solid;padding-left:16px}`;
25757
+ const kritzelEngineCss = () => `:host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}:host,:host *{touch-action:none;user-select:none}.ProseMirror{outline:none}p,h1,h2,h3,h4,h5,h6,blockquote,pre{margin:0;padding:0}.workspace-loading-overlay{position:absolute;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;gap:10px;background-color:var(--kritzel-engine-loading-overlay-background, rgba(255, 255, 255, 0.6));color:var(--kritzel-engine-loading-overlay-color, #333);font-family:var(--kritzel-font-family, sans-serif);font-size:1.25rem;pointer-events:all;animation:workspace-loading-fade-in 200ms ease-out var(--kritzel-engine-loading-overlay-delay, 300ms) forwards;opacity:0}.workspace-loading-spinner{width:20px;height:20px;box-sizing:border-box;display:block;flex-shrink:0;border:2px solid var(--kritzel-engine-loading-overlay-spinner-color, #cccccc);border-top-color:var(--kritzel-engine-loading-overlay-spinner-active-color, #333333);border-radius:50%;animation:workspace-loading-spin 0.6s linear infinite}@keyframes workspace-loading-spin{to{transform:rotate(360deg)}}@keyframes workspace-loading-fade-in{to{opacity:1}}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}.PlaygroundEditorTheme__quote{margin:0;margin-left:20px;margin-bottom:10px;font-size:15px;color:rgb(101, 103, 107);border-left-color:rgb(206, 208, 212);border-left-width:4px;border-left-style:solid;padding-left:16px}`;
25760
25758
 
25761
25759
  const KritzelEngine = class {
25762
25760
  get host() { return getElement(this); }
@@ -25987,6 +25985,7 @@ const KritzelEngine = class {
25987
25985
  if (this.core.store.isDisabled) {
25988
25986
  return;
25989
25987
  }
25988
+ const wasTracked = this.core.store.state.pointers.has(ev.pointerId);
25990
25989
  this.core.store.state.pointers.delete(ev.pointerId);
25991
25990
  if (this.host.hasPointerCapture(ev.pointerId)) {
25992
25991
  this.host.releasePointerCapture(ev.pointerId);
@@ -25995,6 +25994,12 @@ const KritzelEngine = class {
25995
25994
  if (this.core.store.state.pointers.size === 0) {
25996
25995
  this.core.cursorManager.resetToDefault();
25997
25996
  }
25997
+ // If the corresponding pointerdown was never processed (e.g. consumed by a capture-phase
25998
+ // listener like a tooltip close handler), skip tool logic to avoid spurious interactions
25999
+ // such as a selected text object entering edit mode when clicking to dismiss a popup.
26000
+ if (!wasTracked) {
26001
+ return;
26002
+ }
25998
26003
  this.viewport.handlePointerUp(ev);
25999
26004
  this.core.store.state?.activeTool?.handlePointerUp(ev);
26000
26005
  }
@@ -27846,7 +27851,7 @@ const KritzelExport = class {
27846
27851
  return (h("div", { class: "export-tab-content" }, h("kritzel-input", { label: "Filename", value: this.exportFilename, placeholder: "Enter filename", suffix: ".json", onValueChange: this.handleFilenameChange })));
27847
27852
  }
27848
27853
  render() {
27849
- return (h(Host, { key: 'efeea781325e672e3f4c1579a50da1c928dc88b5' }, h("kritzel-dialog", { key: 'c5e60559a3022eec7d13a73b5ec858edb8e7ce1d', isOpen: this.isDialogOpen, dialogTitle: "Export", closable: true, onDialogClose: this.closeDialog }, h("div", { key: '1508001914a22cbb944502be7d33a04128548842', class: "export-content" }, h("kritzel-pill-tabs", { key: '9b0a21140fef986344d98b688729017cb66da493', tabs: this.tabs, value: this.activeTab, onValueChange: this.handleTabChange }), this.activeTab === 'viewport' && this.renderViewportExport(), this.activeTab === 'workspace' && this.renderWorkspaceExport(), h("button", { key: '70021cadab8b2840bbcf66afcd38c28c419facfe', class: "export-primary-button", onClick: this.handleExport }, "Export")))));
27854
+ return (h(Host, { key: '5178e66f75b94697c771e2dc6fe7ce317e21cd1a' }, h("kritzel-dialog", { key: '01aae6955be6828945b20e8a8a4d7c49eb92b2e2', isOpen: this.isDialogOpen, dialogTitle: "Export", closable: true, onDialogClose: this.closeDialog }, h("div", { key: '57c6f6de2917fb51201d737c4d0e1877f5671466', class: "export-content" }, h("kritzel-pill-tabs", { key: '800b8c058078ba1bba06b5edbaf370c4fa3c6806', tabs: this.tabs, value: this.activeTab, onValueChange: this.handleTabChange }), this.activeTab === 'viewport' && this.renderViewportExport(), this.activeTab === 'workspace' && this.renderWorkspaceExport(), h("button", { key: '99fb3b3d8dc42fdb47a3110e8403dde4e508e6cd', class: "export-primary-button", onClick: this.handleExport }, "Export")))));
27850
27855
  }
27851
27856
  };
27852
27857
  KritzelExport.style = kritzelExportCss();
@@ -28143,7 +28148,7 @@ const KritzelLoginDialog = class {
28143
28148
  this.dialogClosed.emit();
28144
28149
  };
28145
28150
  render() {
28146
- return (h(Host, { key: '8cac83db48fef2531f1669c3f601526b1e5cdefa' }, h("kritzel-dialog", { key: '72e0f2eb8e19f3c1081bfd5e1183aa9ed1bc678a', dialogTitle: this.dialogTitle, isOpen: this.isDialogOpen, onDialogClose: this.closeDialog, size: "small" }, h("div", { key: 'bb17bcf6f3486000c9056b3983810e016b0f05a3', class: "login-content" }, this.subtitle && (h("p", { key: 'cef17bc6f5078769b8deed6ec1c615a71fe0c611', class: "login-subtitle" }, this.subtitle)), h("div", { key: '8462ef9a62201cb15f8911432ca188cf49bc8a8d', class: "login-providers" }, this.providers.map(provider => (h("button", { key: provider.name, class: {
28151
+ return (h(Host, { key: '1a664868b840030a773f61c2a0f4388dfb014675' }, h("kritzel-dialog", { key: '09ece6fb5949fc8b204f29cd931c583e525590e1', dialogTitle: this.dialogTitle, isOpen: this.isDialogOpen, onDialogClose: this.closeDialog, size: "small" }, h("div", { key: '57218d7762734929691b82700c31922f5a4991c8', class: "login-content" }, this.subtitle && (h("p", { key: '9ee071786f393857cd6a666e395526a139359d60', class: "login-subtitle" }, this.subtitle)), h("div", { key: 'a487687345aabcfb55976437ddc85feb464f0cae', class: "login-providers" }, this.providers.map(provider => (h("button", { key: provider.name, class: {
28147
28152
  'provider-button': true,
28148
28153
  'is-loading': this.loadingProvider === provider.name,
28149
28154
  'is-disabled': this.loadingProvider !== null && this.loadingProvider !== provider.name,
@@ -28511,7 +28516,7 @@ const KritzelMoreMenu = class {
28511
28516
  this.closeMenu();
28512
28517
  };
28513
28518
  render() {
28514
- return (h(Host, { key: '1bf8b30bc9c958911e544121db01d74948fb2695', class: { mobile: this.isTouchDevice } }, h("div", { key: '3aab8140694f15db066f7c46f243ebc29fb698c1', class: { 'more-menu-wrapper': true, visible: this.visible } }, h("button", { key: '55799f62f7bf72af751362315d38dc8b226c0950', class: "more-menu-button", onClick: this.toggleMenu }, h("kritzel-icon", { key: 'ee627acfcad95a1a978fb3c46d428181bbcb98c1', name: this.icon, size: this.iconSize })), h("kritzel-portal", { key: 'e4116b6583e34dd915ffb46ee3b7377ea2ff10e8', anchor: this.menuAnchor, offsetY: this.offsetY, onClose: this.closeMenu }, h("kritzel-menu", { key: 'a9f50ddf822b14bad8723c67a202dcaa257b817a', items: this.visibleItems, onItemSelect: this.handleMenuItemSelect })))));
28519
+ return (h(Host, { key: '0e12ffc8c72566ec92080e6a19bd1d929795bef9', class: { mobile: this.isTouchDevice } }, h("div", { key: 'cc73b51c5aa39522a7ab7ec23d5c0a2732ed7acc', class: { 'more-menu-wrapper': true, visible: this.visible } }, h("button", { key: 'c35b8c7aa56e5e0e2773fed9fbbbead0b6b01a71', class: "more-menu-button", onClick: this.toggleMenu }, h("kritzel-icon", { key: '8b3261da5a10371a17b2562b71fde48dd0ba8ccd', name: this.icon, size: this.iconSize })), h("kritzel-portal", { key: 'be4a42061f27bbca3d435dec8e4dd25fc78febb0', anchor: this.menuAnchor, offsetY: this.offsetY, onClose: this.closeMenu }, h("kritzel-menu", { key: '763043f4d02819097396ce1baa85f398695e38b5', items: this.visibleItems, onItemSelect: this.handleMenuItemSelect })))));
28515
28520
  }
28516
28521
  };
28517
28522
  KritzelMoreMenu.style = kritzelMoreMenuCss();
@@ -29014,7 +29019,7 @@ const KritzelPortal = class {
29014
29019
  * This file is auto-generated by the version bump scripts.
29015
29020
  * Do not modify manually.
29016
29021
  */
29017
- const KRITZEL_VERSION = '0.2.2';
29022
+ const KRITZEL_VERSION = '0.2.3';
29018
29023
 
29019
29024
  const kritzelSettingsCss = () => `: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)}`;
29020
29025
 
@@ -29209,7 +29214,7 @@ const KritzelSettings = class {
29209
29214
  }
29210
29215
  }
29211
29216
  render() {
29212
- return (h(Host, { key: '33618317a3d4a60cda4369cde1e694cd13116d0a' }, h("kritzel-dialog", { key: '274de12d633d430628c1ac2f1ac9779596d0d249', isOpen: this.isDialogOpen, dialogTitle: "Settings", size: "large", onDialogClose: this.closeDialog }, h("kritzel-master-detail", { key: 'd771531248ec5db38b2d711334c74dde28985f91', items: SETTINGS_CATEGORIES, selectedItemId: this.selectedCategoryId, onItemSelect: this.handleCategorySelect }, this.renderCategoryContent()))));
29217
+ return (h(Host, { key: '78a4eb80f2a4d9e7ef67d06bb39137dbde3a3301' }, h("kritzel-dialog", { key: '1adf437125186758f75dc085db9a4e0c572fccd9', isOpen: this.isDialogOpen, dialogTitle: "Settings", size: "large", onDialogClose: this.closeDialog }, h("kritzel-master-detail", { key: '68ed27f5c9c03589d0444c02ff0524dfcaa053a3', items: SETTINGS_CATEGORIES, selectedItemId: this.selectedCategoryId, onItemSelect: this.handleCategorySelect }, this.renderCategoryContent()))));
29213
29218
  }
29214
29219
  };
29215
29220
  KritzelSettings.style = kritzelSettingsCss();
@@ -29335,9 +29340,9 @@ const KritzelShareDialog = class {
29335
29340
  this.dialogClosed.emit();
29336
29341
  };
29337
29342
  render() {
29338
- return (h(Host, { key: 'a104c14b2492d97f3ada98c9eaaa845d63074063' }, h("kritzel-dialog", { key: 'ae2155436f9dc7530dadfed5da92b2ae8781c3f5', dialogTitle: "Share Workspace", isOpen: this.isDialogOpen, onDialogClose: this.closeDialog, size: "small" }, h("div", { key: 'd419303e63e8183fec99ad2743d5d377c6b2b642', class: "share-content" }, h("div", { key: '913ee65831ff47e6d4d4ba2e26426892bc583827', class: "share-section" }, h("div", { key: 'c32d489e5f7891d23d133c1677c6022e9fc365ab', class: "share-row" }, h("div", { key: '1aa00b5578c657c20910bd1af44d166806d2fe3d', class: "share-label-group" }, h("label", { key: '2d00004314e0d1141397ee7af4e7f923e3182ebf', class: "share-label" }, "Link sharing"), h("p", { key: 'c698ba01de2b252cf6453e0d339044d78c0a701e', class: "share-description" }, this.internalIsPublic
29343
+ return (h(Host, { key: 'bd58f146337b3eca96ca34408a3d30621f01765a' }, h("kritzel-dialog", { key: 'c152f4ec5739a18b265f9a8b161ec8501c1a053b', dialogTitle: "Share Workspace", isOpen: this.isDialogOpen, onDialogClose: this.closeDialog, size: "small" }, h("div", { key: '2810061b1c99e4f4644342453de693e1cddf9a27', class: "share-content" }, h("div", { key: 'bc56de53fd6136c6867018af24019383094cab0d', class: "share-section" }, h("div", { key: '43464ffd61e5a19653cc081e823f01c0eb17e454', class: "share-row" }, h("div", { key: 'ed83ea6684695d09dc6af82b3367fbbff6e4c7e2', class: "share-label-group" }, h("label", { key: 'fe2eaf501dd80ad0b8d83f93a2dcdd18bc093d3b', class: "share-label" }, "Link sharing"), h("p", { key: '738f1a6afc0421380164b9d270920631cefdfd78', class: "share-description" }, this.internalIsPublic
29339
29344
  ? 'Anyone with the link can access this workspace.'
29340
- : 'Link sharing is disabled. Only you can access this workspace.')), h("kritzel-slide-toggle", { key: 'dcc56bf4644c2c56438115b0e9efae7e74ac77d7', checked: this.internalIsPublic, onCheckedChange: this.handleToggleChange, label: "Enable link sharing" }))), this.internalIsPublic && (h("div", { key: '73c72ec32b5fdd74e333594d37aa9601ce274121', class: "share-section" }, h("div", { key: 'f7cf9d1f4c1680ed35c0751df8abf46fbaec2f52', class: "share-url-container" }, h("input", { key: '971c49e294ecf0d95854f54a42b1d45c6bd2c3ae', type: "text", class: "share-url-input", value: this.getShareUrl(), readOnly: true, onClick: (e) => e.target.select() }), h("button", { key: 'ff40fb3e0cc45b5b9d99b0b7f0ff7c3939f7ecb6', class: { 'copy-button': true, 'copy-success': this.copySuccess }, onClick: this.handleCopyUrl, title: this.copySuccess ? 'Copied!' : 'Copy link' }, h("kritzel-icon", { key: 'b299bb0c2a03f5522134f5b3cee5de6cc1d4df5d', name: this.copySuccess ? 'check' : 'copy', size: 18 })))))))));
29345
+ : 'Link sharing is disabled. Only you can access this workspace.')), h("kritzel-slide-toggle", { key: '60f0200ea8f9c207cd5ee76f5a86f82707bb724b', checked: this.internalIsPublic, onCheckedChange: this.handleToggleChange, label: "Enable link sharing" }))), this.internalIsPublic && (h("div", { key: '83212a2a996b85996eee119d5535203f77d3c8dd', class: "share-section" }, h("div", { key: '297031b5aef2018f7aa33c32fd0f8c82f1ddb4cb', class: "share-url-container" }, h("input", { key: '467cca4a8c31b75daa82670f64b562730c241f52', type: "text", class: "share-url-input", value: this.getShareUrl(), readOnly: true, onClick: (e) => e.target.select() }), h("button", { key: 'fdc0f490339cb7050fb020cb1e83e51f6374b183', class: { 'copy-button': true, 'copy-success': this.copySuccess }, onClick: this.handleCopyUrl, title: this.copySuccess ? 'Copied!' : 'Copy link' }, h("kritzel-icon", { key: '5ff1a76d7977c75ea7bc8c339bdf515ba102e511', name: this.copySuccess ? 'check' : 'copy', size: 18 })))))))));
29341
29346
  }
29342
29347
  static get watchers() { return {
29343
29348
  "isPublic": [{
@@ -29885,7 +29890,7 @@ const KritzelUtilityPanel = class {
29885
29890
  this.redo.emit();
29886
29891
  }
29887
29892
  render() {
29888
- return (h(Host, { key: 'b49f6db6c0e574dc8a5a733c749ecda6f24f9d25' }, h("button", { key: 'f65be4fff352b55087f9cb880b9139802b4969e6', class: "utility-button", "data-testid": "utility-undo", disabled: !this.undoState?.canUndo, onClick: event => this.handleUndo(event) }, h("kritzel-icon", { key: 'd58906a4f105923237a98fe2e6b16a53dcccc3f6', name: "undo" })), h("button", { key: '2b7cf2235902920d6b18fe76d0ba2d1d70e4b2c8', class: "utility-button", "data-testid": "utility-redo", disabled: !this.undoState?.canRedo, onClick: event => this.handleRedo(event) }, h("kritzel-icon", { key: '9588ded274449358024e16e8783d30ef451a3a7c', name: "redo" })), h("div", { key: '6ab6db05e2ec35aa59524c41ccb7b339819c9d14', class: "utility-separator" }), h("button", { key: '0eb06eebbda95cebc4ea932b9ec45b2c06324f80', class: "utility-button", "data-testid": "utility-delete", onClick: () => this.delete.emit() }, h("kritzel-icon", { key: '10b51caad06e0a7489c6ef7155073891edad4b63', name: "delete" }))));
29893
+ return (h(Host, { key: 'f800ea5843cf73ae132b56396ad05d664043f789' }, h("button", { key: 'd5dd4dc6e91c106eced7551c02d5f12a915b1d22', class: "utility-button", "data-testid": "utility-undo", disabled: !this.undoState?.canUndo, onClick: event => this.handleUndo(event) }, h("kritzel-icon", { key: '64ac3c8f118c991b50dc99e70d4b952fc759c958', name: "undo" })), h("button", { key: '97a8d694fd999eb505fdcdb532d4476ce369e60d', class: "utility-button", "data-testid": "utility-redo", disabled: !this.undoState?.canRedo, onClick: event => this.handleRedo(event) }, h("kritzel-icon", { key: 'ba22d5c6b246967b00112dc2efeb26920187d88f', name: "redo" })), h("div", { key: 'a4aa6a3202640742826d2217f2bbae9ebd2b84da', class: "utility-separator" }), h("button", { key: '1de2a896a6a70c22f9fa16a21af10f07f4b0303a', class: "utility-button", "data-testid": "utility-delete", onClick: () => this.delete.emit() }, h("kritzel-icon", { key: '202612645c1a3e8ee7e4cc01a0305d4e673874e4', name: "delete" }))));
29889
29894
  }
29890
29895
  };
29891
29896
  KritzelUtilityPanel.style = kritzelUtilityPanelCss();
@@ -14489,6 +14489,10 @@ const lightTheme = {
14489
14489
  },
14490
14490
  engine: {
14491
14491
  backgroundColor: '#ffffff',
14492
+ loadingOverlayBackground: 'rgba(255, 255, 255, 0.85)',
14493
+ loadingOverlayColor: '#333333',
14494
+ loadingOverlaySpinnerActiveColor: '#333333',
14495
+ loadingOverlaySpinnerColor: '#cccccc',
14492
14496
  },
14493
14497
  snap: {
14494
14498
  indicatorFill: 'rgba(59, 130, 246, 0.3)',
@@ -14758,6 +14762,10 @@ const darkTheme = {
14758
14762
  },
14759
14763
  engine: {
14760
14764
  backgroundColor: '#1a1a1a',
14765
+ loadingOverlayBackground: 'rgba(26, 26, 26, 0.85)',
14766
+ loadingOverlayColor: '#e0e0e0',
14767
+ loadingOverlaySpinnerActiveColor: '#e0e0e0',
14768
+ loadingOverlaySpinnerColor: '#555555',
14761
14769
  },
14762
14770
  snap: {
14763
14771
  indicatorFill: 'rgba(10, 132, 255, 0.35)',
@@ -1 +1 @@
1
- import{H as a,a as T}from"./p-C_uxbvuH.js";export{E as APP_STATE_MIGRATIONS,A as AssetNotFoundError,C as CURRENT_APP_STATE_SCHEMA_VERSION,z as CURRENT_WORKSPACE_SCHEMA_VERSION,v as DEFAULT_ASSET_STORAGE_CONFIG,D as DEFAULT_BRUSH_CONFIG,u as DEFAULT_LINE_TOOL_CONFIG,t as DEFAULT_TEXT_CONFIG,p as IndexedDBAssetProvider,I as IndexedDBSyncProvider,y as KritzelAlignment,r as KritzelAnchorManager,o as KritzelAssetResolver,g as KritzelBrushTool,m as KritzelCursorHelper,i as KritzelEraserTool,e as KritzelGroup,c as KritzelImage,j as KritzelImageTool,d as KritzelLine,h as KritzelLineTool,b as KritzelPath,n as KritzelSelectionTool,f as KritzelShape,l as KritzelShapeTool,K as KritzelText,k as KritzelTextTool,s as KritzelThemeManager,q as KritzelWorkspace,S as ShapeType,W as WORKSPACE_EXPORT_VERSION,F as WORKSPACE_MIGRATIONS,x as darkTheme,w as lightTheme,B as runMigrations}from"./p-C_uxbvuH.js";import*as P from"yjs";import{WebsocketProvider as $}from"y-websocket";import"y-indexeddb";const _=Math.floor,H=127,U=Number.MAX_SAFE_INTEGER;class R{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const O=()=>new R,N=t=>{const e=new Uint8Array((t=>{let e=t.cpos;for(let s=0;s<t.bufs.length;s++)e+=t.bufs[s].length;return e})(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},M=(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},L=(t,e)=>{for(;e>H;)M(t,128|H&e),e=_(e/128);M(t,H&e)},G=(t,e)=>{L(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)},V=t=>new Error(t),X=V("Unexpected end of array"),J=V("Integer out of Range");class Q{constructor(t){this.arr=t,this.pos=0}}const Y=t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,Z(t)),Z=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&H)*s,s*=128,i<128)return e;if(e>U)throw J}throw X};class tt{type="local";doc;channel;_synced=!1;constructor(t,e,s){this.doc=e,this.channel=new BroadcastChannel(t),this.channel.onmessage=t=>{this.handleMessage(t.data)},this.doc.on("update",this.handleDocUpdate),this.broadcastSync(),setTimeout((()=>{this._synced=!0}),100),s?.quiet||console.info(`BroadcastChannel Provider initialized: ${t}`)}handleDocUpdate=(t,e)=>{if(e!==this){const e=O();L(e,0),G(e,t),this.channel.postMessage(N(e))}};handleMessage(t){const e=(s=new Uint8Array(t),new Q(s));var s;switch(Z(e)){case 0:const t=Y(e);P.applyUpdate(this.doc,t,this);break;case 1:this.broadcastSync();break;case 2:const s=Y(e),i=P.encodeStateAsUpdate(this.doc,s);if(i.length>0){const t=O();L(t,0),G(t,i),this.channel.postMessage(N(t))}}}broadcastSync(){const t=O();L(t,2),G(t,P.encodeStateVector(this.doc)),this.channel.postMessage(N(t))}async connect(){if(!this._synced)return new Promise((t=>{const e=()=>{this._synced?t():setTimeout(e,50)};e()}))}disconnect(){}async reconnect(){return this.disconnect(),this.connect()}destroy(){this.doc.off("update",this.handleDocUpdate),this.channel.close()}}class et{type="network";provider;isConnected=!1;_quiet=!1;get awareness(){return this.provider.awareness}constructor(t,e,s){const i=s?.url||"ws://localhost:1234",n=s?.roomName||t;this.provider=new $(i,n,e,{params:s?.params,protocols:s?.protocols,WebSocketPolyfill:s?.WebSocketPolyfill,awareness:s?.awareness,maxBackoffTime:s?.maxBackoffTime,disableBc:!0}),this._quiet=s?.quiet??!1,this.setupEventListeners(),this._quiet||console.info(`WebSocket Provider initialized: ${i}/${n}`)}static with(t){return{create:(e,s,i)=>{const n=i?{...t,...i}:t;return new et(e,s,n)}}}setupEventListeners(){this.provider.on("status",(({status:t})=>{"connected"===t?(this.isConnected=!0,this._quiet||console.info("WebSocket connected")):"disconnected"===t&&(this.isConnected=!1,this._quiet||console.info("WebSocket disconnected"))})),this.provider.on("sync",(t=>{t&&!this._quiet&&console.info("WebSocket synced")}))}async connect(){if(!this.isConnected)return new Promise(((t,e)=>{const s=setTimeout((()=>{e(new Error("WebSocket connection timeout"))}),1e4),i=({status:e})=>{"connected"===e&&(clearTimeout(s),this.provider.off("status",i),this.isConnected=!0,t())};this.provider.on("status",i),this.provider.wsconnected&&(clearTimeout(s),this.provider.off("status",i),this.isConnected=!0,t())}))}disconnect(){this.provider&&this.provider.disconnect(),this.isConnected=!1}async reconnect(){return this.disconnect(),this.connect()}destroy(){this.provider&&this.provider.destroy(),this.isConnected=!1}}class st{type="network";provider;isConnected=!1;isSynced=!1;usesSharedSocket=!1;isDestroyed=!1;connectTimeout=null;pendingConnectReject=null;connectionTimeoutMs;_connectionStatus="disconnected";visibilityHandler=null;onlineHandler=null;get awareness(){return this.provider.awareness}get connectionStatus(){return this._connectionStatus}static sharedWebSocketProvider=null;constructor(t,e,s){const i=s?.name||t,n=s?.url||"ws://localhost:1234";this.connectionTimeoutMs=s?.connectionTimeout??1e4;const o=s?.websocketProvider||st.sharedWebSocketProvider,r={};void 0!==s?.delay&&(r.delay=s.delay),void 0!==s?.factor&&(r.factor=s.factor),void 0!==s?.maxAttempts&&(r.maxAttempts=s.maxAttempts),void 0!==s?.minDelay&&(r.minDelay=s.minDelay),void 0!==s?.maxDelay&&(r.maxDelay=s.maxDelay);const c=()=>{this.isDestroyed||(this.isConnected=!0,this._connectionStatus="connected",s?.quiet||console.info(`Hocuspocus connected: ${i}`),s?.onConnect&&s.onConnect())},h=()=>{this.isDestroyed||(this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected",s?.quiet||console.info(`Hocuspocus disconnected: ${i}`),s?.onDisconnect&&s.onDisconnect())},d=()=>{this.isDestroyed||(this.isSynced=!0,this._connectionStatus="synced",s?.quiet||console.info(`Hocuspocus synced: ${i}`),s?.onSynced&&s.onSynced())},l=t=>{this.isDestroyed||("connecting"===t.status&&(this._connectionStatus="connecting"),s?.onStatus&&s.onStatus(t))};if(o){this.usesSharedSocket=!0;const t={websocketProvider:o,name:i,document:e,token:s?.token||null,onStatus:l,onConnect:c,onDisconnect:h,onSynced:d,...r};void 0!==s?.forceSyncInterval&&(t.forceSyncInterval=s.forceSyncInterval),s?.onAuthenticationFailed&&(t.onAuthenticationFailed=s.onAuthenticationFailed),this.provider=new a(t),this.provider.attach(),s?.quiet||console.info(`Hocuspocus Provider initialized (multiplexed): ${i}`)}else{this.usesSharedSocket=!1;const t={url:n,name:i,document:e,token:s?.token||null,autoConnect:!1,onStatus:l,onConnect:c,onDisconnect:h,onSynced:d,...r};void 0!==s?.forceSyncInterval&&(t.forceSyncInterval=s.forceSyncInterval),s?.onAuthenticationFailed&&(t.onAuthenticationFailed=s.onAuthenticationFailed),s?.WebSocketPolyfill&&(t.WebSocketPolyfill=s.WebSocketPolyfill),this.provider=new a(t),s?.quiet||console.info(`Hocuspocus Provider initialized: ${n}/${i}`)}this.setupBrowserEventListeners()}setupBrowserEventListeners(){"undefined"!=typeof document&&(this.visibilityHandler=()=>{"visible"!==document.visibilityState||this.isConnected||this.isDestroyed||this.provider.connect()},document.addEventListener("visibilitychange",this.visibilityHandler)),"undefined"!=typeof window&&(this.onlineHandler=()=>{this.isConnected||this.isDestroyed||this.provider.connect()},window.addEventListener("online",this.onlineHandler))}removeBrowserEventListeners(){this.visibilityHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null),this.onlineHandler&&"undefined"!=typeof window&&(window.removeEventListener("online",this.onlineHandler),this.onlineHandler=null)}static createSharedWebSocket(t){if(st.sharedWebSocketProvider)return console.warn("Shared WebSocket already exists. Returning existing instance."),st.sharedWebSocketProvider;const e={url:t.url};return t.WebSocketPolyfill&&(e.WebSocketPolyfill=t.WebSocketPolyfill),t.onConnect&&(e.onConnect=t.onConnect),t.onDisconnect&&(e.onDisconnect=t.onDisconnect),t.onStatus&&(e.onStatus=t.onStatus),st.sharedWebSocketProvider=new T(e),console.info(`Shared Hocuspocus WebSocket created: ${t.url}`),st.sharedWebSocketProvider}static destroySharedWebSocket(){st.sharedWebSocketProvider&&(st.sharedWebSocketProvider.destroy(),st.sharedWebSocketProvider=null,console.info("Shared Hocuspocus WebSocket destroyed"))}static getSharedWebSocket(){return st.sharedWebSocketProvider}static with(t){return{create:(e,s,i)=>{const n=i?{...t,...i}:t;return new st(e,s,n)}}}async connect(){if(!this.isSynced&&!this.isDestroyed)return this._connectionStatus="connecting",new Promise(((t,e)=>{this.pendingConnectReject=e,this.connectTimeout=setTimeout((()=>{this.pendingConnectReject=null,this.connectTimeout=null,e(new Error("Hocuspocus connection timeout"))}),this.connectionTimeoutMs);const s=()=>{this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject=null,this.provider.off("synced",s),this.isDestroyed||t()};if(this.provider.on("synced",s),this.provider.isSynced)return this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject=null,this.provider.off("synced",s),void t();this.isConnected||this.usesSharedSocket||this.provider.connect()}))}async reconnect(){return this.disconnect(),this.connect()}disconnect(){this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject&&(this.pendingConnectReject=null),this.provider&&(this.usesSharedSocket?this.provider.detach():this.provider.disconnect()),this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected"}destroy(){this.isDestroyed=!0,this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject&&(this.pendingConnectReject=null),this.removeBrowserEventListeners(),this.provider&&this.provider.destroy(),this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected"}}class it{type="remote";name="HttpAssetProvider";_options;constructor(t){this._options=t}static with(t){return{create:()=>new it(t)}}async init(){this._options.quiet||console.info("HttpAssetProvider initialized")}destroy(){}canResolve(t){return!0}async put(t,e){const s=e.id??this.generateUuid(),i={...e,id:s},n=await(this._options.headers?.())??{},o=await this._options.uploadUrl(i),r=this._options.upload??this.defaultUpload;return{id:(await r(o,t,i,n)).id??s,kind:e.kind??"file",mimeType:e.mimeType,size:t.size,createdAt:Date.now(),width:e.width,height:e.height,durationMs:e.durationMs,originalFilename:e.originalFilename}}async resolve(t){return this._options.resolveUrl(t)}async fetch(t){const e=await this._options.resolveUrl(t),s=await(this._options.headers?.())??{},i=await fetch(e,{headers:s});if(!i.ok)throw new Error(`[HttpAssetProvider] Failed to fetch asset ${t}: ${i.status} ${i.statusText}`);return i.blob()}async delete(t){if(!this._options.deleteUrl)return;const e=await this._options.deleteUrl(t),s=await(this._options.headers?.())??{},i=await fetch(e,{method:"DELETE",headers:s});if(!i.ok)throw new Error(`[HttpAssetProvider] Failed to delete asset ${t}: ${i.status} ${i.statusText}`);this._options.quiet||console.info(`HttpAssetProvider: deleted asset ${t}`)}defaultUpload=async(t,e,s,i)=>{const n=new FormData;n.append("metadata",JSON.stringify(s)),n.append("file",e,s.originalFilename||`${s.id}.${this.extensionFromMime(s.mimeType)}`);const o=await fetch(t,{method:"POST",headers:i,body:n});if(!o.ok)throw new Error(`[HttpAssetProvider] Upload failed: ${o.status} ${o.statusText}`);return(o.headers.get("content-type")||"").includes("application/json")?await o.json():{}};extensionFromMime(t){const e=t.indexOf("/");return e>=0?t.slice(e+1):"bin"}generateUuid(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=crypto.getRandomValues(new Uint8Array(16));t[6]=15&t[6]|64,t[8]=63&t[8]|128;const e=Array.from(t,(t=>t.toString(16).padStart(2,"0"))).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}}class nt{type="remote";name="PresignedAssetProvider";_options;constructor(t){this._options=t}static with(t){return{create:()=>new nt(t)}}async init(){this._options.quiet||console.info("PresignedAssetProvider initialized")}destroy(){}canResolve(t){return!0}async put(t,e){const s=await this._options.getUploadDescriptor(e),i=s.method??"PUT",n={...s.headers??{}};let o;if(n["Content-Type"]||n["content-type"]||(n["Content-Type"]=e.mimeType),"POST"===i&&s.fields){const e=new FormData;for(const[t,i]of Object.entries(s.fields))e.append(t,i);e.append("file",t),o=e,delete n["Content-Type"],delete n["content-type"]}else o=t;const r=await fetch(s.url,{method:i,headers:n,body:o});if(!r.ok)throw new Error(`[PresignedAssetProvider] Upload failed: ${r.status} ${r.statusText}`);return{id:s.id,kind:e.kind??"file",mimeType:e.mimeType,size:t.size,createdAt:Date.now(),width:e.width,height:e.height,durationMs:e.durationMs,originalFilename:e.originalFilename}}async resolve(t){return this._options.getDownloadUrl(t)}async fetch(t){const e=await this._options.getDownloadUrl(t),s=await fetch(e);if(!s.ok)throw new Error(`[PresignedAssetProvider] Failed to fetch asset ${t}: ${s.status} ${s.statusText}`);return s.blob()}async delete(t){this._options.deleteAsset&&(await this._options.deleteAsset(t),this._options.quiet||console.info(`PresignedAssetProvider: deleted asset ${t}`))}}export{tt as BroadcastSyncProvider,st as HocuspocusSyncProvider,it as HttpAssetProvider,nt as PresignedAssetProvider,et as WebSocketSyncProvider}
1
+ import{H as a,a as T}from"./p-BrA5xRPn.js";export{E as APP_STATE_MIGRATIONS,A as AssetNotFoundError,C as CURRENT_APP_STATE_SCHEMA_VERSION,z as CURRENT_WORKSPACE_SCHEMA_VERSION,v as DEFAULT_ASSET_STORAGE_CONFIG,D as DEFAULT_BRUSH_CONFIG,u as DEFAULT_LINE_TOOL_CONFIG,t as DEFAULT_TEXT_CONFIG,p as IndexedDBAssetProvider,I as IndexedDBSyncProvider,y as KritzelAlignment,r as KritzelAnchorManager,o as KritzelAssetResolver,g as KritzelBrushTool,m as KritzelCursorHelper,i as KritzelEraserTool,e as KritzelGroup,c as KritzelImage,j as KritzelImageTool,d as KritzelLine,h as KritzelLineTool,b as KritzelPath,n as KritzelSelectionTool,f as KritzelShape,l as KritzelShapeTool,K as KritzelText,k as KritzelTextTool,s as KritzelThemeManager,q as KritzelWorkspace,S as ShapeType,W as WORKSPACE_EXPORT_VERSION,F as WORKSPACE_MIGRATIONS,x as darkTheme,w as lightTheme,B as runMigrations}from"./p-BrA5xRPn.js";import*as P from"yjs";import{WebsocketProvider as $}from"y-websocket";import"y-indexeddb";const _=Math.floor,R=127,U=Number.MAX_SAFE_INTEGER;class H{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const O=()=>new H,N=t=>{const e=new Uint8Array((t=>{let e=t.cpos;for(let s=0;s<t.bufs.length;s++)e+=t.bufs[s].length;return e})(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},M=(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},L=(t,e)=>{for(;e>R;)M(t,128|R&e),e=_(e/128);M(t,R&e)},G=(t,e)=>{L(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)},V=t=>new Error(t),X=V("Unexpected end of array"),J=V("Integer out of Range");class Q{constructor(t){this.arr=t,this.pos=0}}const Y=t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,Z(t)),Z=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&R)*s,s*=128,i<128)return e;if(e>U)throw J}throw X};class tt{type="local";doc;channel;_synced=!1;constructor(t,e,s){this.doc=e,this.channel=new BroadcastChannel(t),this.channel.onmessage=t=>{this.handleMessage(t.data)},this.doc.on("update",this.handleDocUpdate),this.broadcastSync(),setTimeout((()=>{this._synced=!0}),100),s?.quiet||console.info(`BroadcastChannel Provider initialized: ${t}`)}handleDocUpdate=(t,e)=>{if(e!==this){const e=O();L(e,0),G(e,t),this.channel.postMessage(N(e))}};handleMessage(t){const e=(s=new Uint8Array(t),new Q(s));var s;switch(Z(e)){case 0:const t=Y(e);P.applyUpdate(this.doc,t,this);break;case 1:this.broadcastSync();break;case 2:const s=Y(e),i=P.encodeStateAsUpdate(this.doc,s);if(i.length>0){const t=O();L(t,0),G(t,i),this.channel.postMessage(N(t))}}}broadcastSync(){const t=O();L(t,2),G(t,P.encodeStateVector(this.doc)),this.channel.postMessage(N(t))}async connect(){if(!this._synced)return new Promise((t=>{const e=()=>{this._synced?t():setTimeout(e,50)};e()}))}disconnect(){}async reconnect(){return this.disconnect(),this.connect()}destroy(){this.doc.off("update",this.handleDocUpdate),this.channel.close()}}class et{type="network";provider;isConnected=!1;_quiet=!1;get awareness(){return this.provider.awareness}constructor(t,e,s){const i=s?.url||"ws://localhost:1234",n=s?.roomName||t;this.provider=new $(i,n,e,{params:s?.params,protocols:s?.protocols,WebSocketPolyfill:s?.WebSocketPolyfill,awareness:s?.awareness,maxBackoffTime:s?.maxBackoffTime,disableBc:!0}),this._quiet=s?.quiet??!1,this.setupEventListeners(),this._quiet||console.info(`WebSocket Provider initialized: ${i}/${n}`)}static with(t){return{create:(e,s,i)=>{const n=i?{...t,...i}:t;return new et(e,s,n)}}}setupEventListeners(){this.provider.on("status",(({status:t})=>{"connected"===t?(this.isConnected=!0,this._quiet||console.info("WebSocket connected")):"disconnected"===t&&(this.isConnected=!1,this._quiet||console.info("WebSocket disconnected"))})),this.provider.on("sync",(t=>{t&&!this._quiet&&console.info("WebSocket synced")}))}async connect(){if(!this.isConnected)return new Promise(((t,e)=>{const s=setTimeout((()=>{e(new Error("WebSocket connection timeout"))}),1e4),i=({status:e})=>{"connected"===e&&(clearTimeout(s),this.provider.off("status",i),this.isConnected=!0,t())};this.provider.on("status",i),this.provider.wsconnected&&(clearTimeout(s),this.provider.off("status",i),this.isConnected=!0,t())}))}disconnect(){this.provider&&this.provider.disconnect(),this.isConnected=!1}async reconnect(){return this.disconnect(),this.connect()}destroy(){this.provider&&this.provider.destroy(),this.isConnected=!1}}class st{type="network";provider;isConnected=!1;isSynced=!1;usesSharedSocket=!1;isDestroyed=!1;connectTimeout=null;pendingConnectReject=null;connectionTimeoutMs;_connectionStatus="disconnected";visibilityHandler=null;onlineHandler=null;get awareness(){return this.provider.awareness}get connectionStatus(){return this._connectionStatus}static sharedWebSocketProvider=null;constructor(t,e,s){const i=s?.name||t,n=s?.url||"ws://localhost:1234";this.connectionTimeoutMs=s?.connectionTimeout??1e4;const o=s?.websocketProvider||st.sharedWebSocketProvider,r={};void 0!==s?.delay&&(r.delay=s.delay),void 0!==s?.factor&&(r.factor=s.factor),void 0!==s?.maxAttempts&&(r.maxAttempts=s.maxAttempts),void 0!==s?.minDelay&&(r.minDelay=s.minDelay),void 0!==s?.maxDelay&&(r.maxDelay=s.maxDelay);const c=()=>{this.isDestroyed||(this.isConnected=!0,this._connectionStatus="connected",s?.quiet||console.info(`Hocuspocus connected: ${i}`),s?.onConnect&&s.onConnect())},h=()=>{this.isDestroyed||(this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected",s?.quiet||console.info(`Hocuspocus disconnected: ${i}`),s?.onDisconnect&&s.onDisconnect())},d=()=>{this.isDestroyed||(this.isSynced=!0,this._connectionStatus="synced",s?.quiet||console.info(`Hocuspocus synced: ${i}`),s?.onSynced&&s.onSynced())},l=t=>{this.isDestroyed||("connecting"===t.status&&(this._connectionStatus="connecting"),s?.onStatus&&s.onStatus(t))};if(o){this.usesSharedSocket=!0;const t={websocketProvider:o,name:i,document:e,token:s?.token||null,onStatus:l,onConnect:c,onDisconnect:h,onSynced:d,...r};void 0!==s?.forceSyncInterval&&(t.forceSyncInterval=s.forceSyncInterval),s?.onAuthenticationFailed&&(t.onAuthenticationFailed=s.onAuthenticationFailed),this.provider=new a(t),this.provider.attach(),s?.quiet||console.info(`Hocuspocus Provider initialized (multiplexed): ${i}`)}else{this.usesSharedSocket=!1;const t={url:n,name:i,document:e,token:s?.token||null,autoConnect:!1,onStatus:l,onConnect:c,onDisconnect:h,onSynced:d,...r};void 0!==s?.forceSyncInterval&&(t.forceSyncInterval=s.forceSyncInterval),s?.onAuthenticationFailed&&(t.onAuthenticationFailed=s.onAuthenticationFailed),s?.WebSocketPolyfill&&(t.WebSocketPolyfill=s.WebSocketPolyfill),this.provider=new a(t),s?.quiet||console.info(`Hocuspocus Provider initialized: ${n}/${i}`)}this.setupBrowserEventListeners()}setupBrowserEventListeners(){"undefined"!=typeof document&&(this.visibilityHandler=()=>{"visible"!==document.visibilityState||this.isConnected||this.isDestroyed||this.provider.connect()},document.addEventListener("visibilitychange",this.visibilityHandler)),"undefined"!=typeof window&&(this.onlineHandler=()=>{this.isConnected||this.isDestroyed||this.provider.connect()},window.addEventListener("online",this.onlineHandler))}removeBrowserEventListeners(){this.visibilityHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null),this.onlineHandler&&"undefined"!=typeof window&&(window.removeEventListener("online",this.onlineHandler),this.onlineHandler=null)}static createSharedWebSocket(t){if(st.sharedWebSocketProvider)return console.warn("Shared WebSocket already exists. Returning existing instance."),st.sharedWebSocketProvider;const e={url:t.url};return t.WebSocketPolyfill&&(e.WebSocketPolyfill=t.WebSocketPolyfill),t.onConnect&&(e.onConnect=t.onConnect),t.onDisconnect&&(e.onDisconnect=t.onDisconnect),t.onStatus&&(e.onStatus=t.onStatus),st.sharedWebSocketProvider=new T(e),console.info(`Shared Hocuspocus WebSocket created: ${t.url}`),st.sharedWebSocketProvider}static destroySharedWebSocket(){st.sharedWebSocketProvider&&(st.sharedWebSocketProvider.destroy(),st.sharedWebSocketProvider=null,console.info("Shared Hocuspocus WebSocket destroyed"))}static getSharedWebSocket(){return st.sharedWebSocketProvider}static with(t){return{create:(e,s,i)=>{const n=i?{...t,...i}:t;return new st(e,s,n)}}}async connect(){if(!this.isSynced&&!this.isDestroyed)return this._connectionStatus="connecting",new Promise(((t,e)=>{this.pendingConnectReject=e,this.connectTimeout=setTimeout((()=>{this.pendingConnectReject=null,this.connectTimeout=null,e(new Error("Hocuspocus connection timeout"))}),this.connectionTimeoutMs);const s=()=>{this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject=null,this.provider.off("synced",s),this.isDestroyed||t()};if(this.provider.on("synced",s),this.provider.isSynced)return this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject=null,this.provider.off("synced",s),void t();this.isConnected||this.usesSharedSocket||this.provider.connect()}))}async reconnect(){return this.disconnect(),this.connect()}disconnect(){this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject&&(this.pendingConnectReject=null),this.provider&&(this.usesSharedSocket?this.provider.detach():this.provider.disconnect()),this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected"}destroy(){this.isDestroyed=!0,this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject&&(this.pendingConnectReject=null),this.removeBrowserEventListeners(),this.provider&&this.provider.destroy(),this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected"}}class it{type="remote";name="HttpAssetProvider";_options;constructor(t){this._options=t}static with(t){return{create:()=>new it(t)}}async init(){this._options.quiet||console.info("HttpAssetProvider initialized")}destroy(){}canResolve(t){return!0}async put(t,e){const s=e.id??this.generateUuid(),i={...e,id:s},n=await(this._options.headers?.())??{},o=await this._options.uploadUrl(i),r=this._options.upload??this.defaultUpload;return{id:(await r(o,t,i,n)).id??s,kind:e.kind??"file",mimeType:e.mimeType,size:t.size,createdAt:Date.now(),width:e.width,height:e.height,durationMs:e.durationMs,originalFilename:e.originalFilename}}async resolve(t){return this._options.resolveUrl(t)}async fetch(t){const e=await this._options.resolveUrl(t),s=await(this._options.headers?.())??{},i=await fetch(e,{headers:s});if(!i.ok)throw new Error(`[HttpAssetProvider] Failed to fetch asset ${t}: ${i.status} ${i.statusText}`);return i.blob()}async delete(t){if(!this._options.deleteUrl)return;const e=await this._options.deleteUrl(t),s=await(this._options.headers?.())??{},i=await fetch(e,{method:"DELETE",headers:s});if(!i.ok)throw new Error(`[HttpAssetProvider] Failed to delete asset ${t}: ${i.status} ${i.statusText}`);this._options.quiet||console.info(`HttpAssetProvider: deleted asset ${t}`)}defaultUpload=async(t,e,s,i)=>{const n=new FormData;n.append("metadata",JSON.stringify(s)),n.append("file",e,s.originalFilename||`${s.id}.${this.extensionFromMime(s.mimeType)}`);const o=await fetch(t,{method:"POST",headers:i,body:n});if(!o.ok)throw new Error(`[HttpAssetProvider] Upload failed: ${o.status} ${o.statusText}`);return(o.headers.get("content-type")||"").includes("application/json")?await o.json():{}};extensionFromMime(t){const e=t.indexOf("/");return e>=0?t.slice(e+1):"bin"}generateUuid(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=crypto.getRandomValues(new Uint8Array(16));t[6]=15&t[6]|64,t[8]=63&t[8]|128;const e=Array.from(t,(t=>t.toString(16).padStart(2,"0"))).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}}class nt{type="remote";name="PresignedAssetProvider";_options;constructor(t){this._options=t}static with(t){return{create:()=>new nt(t)}}async init(){this._options.quiet||console.info("PresignedAssetProvider initialized")}destroy(){}canResolve(t){return!0}async put(t,e){const s=await this._options.getUploadDescriptor(e),i=s.method??"PUT",n={...s.headers??{}};let o;if(n["Content-Type"]||n["content-type"]||(n["Content-Type"]=e.mimeType),"POST"===i&&s.fields){const e=new FormData;for(const[t,i]of Object.entries(s.fields))e.append(t,i);e.append("file",t),o=e,delete n["Content-Type"],delete n["content-type"]}else o=t;const r=await fetch(s.url,{method:i,headers:n,body:o});if(!r.ok)throw new Error(`[PresignedAssetProvider] Upload failed: ${r.status} ${r.statusText}`);return{id:s.id,kind:e.kind??"file",mimeType:e.mimeType,size:t.size,createdAt:Date.now(),width:e.width,height:e.height,durationMs:e.durationMs,originalFilename:e.originalFilename}}async resolve(t){return this._options.getDownloadUrl(t)}async fetch(t){const e=await this._options.getDownloadUrl(t),s=await fetch(e);if(!s.ok)throw new Error(`[PresignedAssetProvider] Failed to fetch asset ${t}: ${s.status} ${s.statusText}`);return s.blob()}async delete(t){this._options.deleteAsset&&(await this._options.deleteAsset(t),this._options.quiet||console.info(`PresignedAssetProvider: deleted asset ${t}`))}}export{tt as BroadcastSyncProvider,st as HocuspocusSyncProvider,it as HttpAssetProvider,nt as PresignedAssetProvider,et as WebSocketSyncProvider}