@inkandswitch/patchwork-pkg-base 0.0.41 → 0.0.43

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 (52) hide show
  1. package/package.json +1 -1
  2. package/packages/account/dist/{InlineContactAvatar-TVDLE2AV.js → InlineContactAvatar-6UAAJ73R.js} +2 -1
  3. package/packages/account/dist/InlineContactAvatar-6UAAJ73R.js.map +7 -0
  4. package/packages/account/dist/index.js +1 -1
  5. package/packages/chat/dist/{ChatRoot-DQkQQvPO.js → ChatRoot-WdCS4aLg.js} +3001 -2807
  6. package/packages/chat/dist/{context-tool-BuY29sJF.js → context-tool-KkwLFr2k.js} +2 -2
  7. package/packages/chat/dist/{index-NiYOPQzY.js → index-P8UuZ1jj.js} +3 -3
  8. package/packages/chat/dist/index.js +1 -1
  9. package/packages/chat/dist/{tool-He3mRTzT.js → tool-DWqQOW59.js} +2 -2
  10. package/packages/chat/package.json +1 -1
  11. package/packages/codemirror-base/dist/chunk-H5POLO74.js +2658 -0
  12. package/packages/codemirror-base/dist/chunk-H5POLO74.js.map +7 -0
  13. package/packages/codemirror-base/dist/lib/codemirror.js +1 -1
  14. package/packages/codemirror-base/dist/tool.js +9 -5
  15. package/packages/codemirror-base/dist/tool.js.map +2 -2
  16. package/packages/codemirror-base/package.json +1 -1
  17. package/packages/codemirror-markdown/dist/extensions/markdown.js +0 -94
  18. package/packages/codemirror-markdown/dist/extensions/markdown.js.map +3 -3
  19. package/packages/drafts/dist/assets/{DraftOverlayProvider-B0Mtq1UF.js → DraftOverlayProvider-VYKlzOy1.js} +85 -25
  20. package/packages/drafts/dist/assets/DraftOverlayProvider-VYKlzOy1.js.map +1 -0
  21. package/packages/drafts/dist/assets/{DraftListProvider-D41q9O5B.js → DraftStateProvider-DX8b_RgQ.js} +270 -39
  22. package/packages/drafts/dist/assets/DraftStateProvider-DX8b_RgQ.js.map +1 -0
  23. package/packages/drafts/dist/assets/{clone-policy-C4pVv5sr.js → clone-policy-CIdEhg7W.js} +5 -2
  24. package/packages/drafts/dist/assets/{clone-policy-C4pVv5sr.js.map → clone-policy-CIdEhg7W.js.map} +1 -1
  25. package/packages/drafts/dist/assets/draft-docs-Bi8K1y3a.js +554 -0
  26. package/packages/drafts/dist/assets/draft-docs-Bi8K1y3a.js.map +1 -0
  27. package/packages/drafts/dist/assets/main-BR_tW0sp.js +3105 -0
  28. package/packages/drafts/dist/assets/main-BR_tW0sp.js.map +1 -0
  29. package/packages/drafts/dist/index.js +14 -14
  30. package/packages/drafts/dist/index.js.map +1 -1
  31. package/packages/drafts/package.json +1 -1
  32. package/packages/raw/raw-editor.js +26 -11
  33. package/packages/threepane/dist/IsolatedDocumentArea-2JIBFDOX.js +2 -0
  34. package/packages/threepane/dist/{PatchworkFrame-4AEBOBRE.js → PatchworkFrame-P5P6JTJE.js} +2 -2
  35. package/packages/threepane/dist/chunk-CGHYPNSB.js +972 -0
  36. package/packages/threepane/dist/chunk-CGHYPNSB.js.map +7 -0
  37. package/packages/threepane/dist/index.js +1 -1
  38. package/packages/tldraw4/dist/tool.js +61 -10
  39. package/packages/tldraw4/dist/tool.js.map +2 -2
  40. package/packages/tldraw4/package.json +2 -2
  41. package/packages/account/dist/InlineContactAvatar-TVDLE2AV.js.map +0 -7
  42. package/packages/codemirror-base/dist/chunk-5IG5TKXV.js +0 -795
  43. package/packages/codemirror-base/dist/chunk-5IG5TKXV.js.map +0 -7
  44. package/packages/drafts/dist/assets/DraftListProvider-D41q9O5B.js.map +0 -1
  45. package/packages/drafts/dist/assets/DraftOverlayProvider-B0Mtq1UF.js.map +0 -1
  46. package/packages/drafts/dist/assets/main-Cp8VsNHh.js +0 -2331
  47. package/packages/drafts/dist/assets/main-Cp8VsNHh.js.map +0 -1
  48. package/packages/threepane/dist/IsolatedDocumentArea-MZBBRFMY.js +0 -2
  49. package/packages/threepane/dist/chunk-HNLVJAZZ.js +0 -972
  50. package/packages/threepane/dist/chunk-HNLVJAZZ.js.map +0 -7
  51. /package/packages/threepane/dist/{IsolatedDocumentArea-MZBBRFMY.js.map → IsolatedDocumentArea-2JIBFDOX.js.map} +0 -0
  52. /package/packages/threepane/dist/{PatchworkFrame-4AEBOBRE.js.map → PatchworkFrame-P5P6JTJE.js.map} +0 -0
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js", "../node_modules/.pnpm/debug@4.4.3_supports-color@7.2.0/node_modules/debug/src/common.js", "../node_modules/.pnpm/debug@4.4.3_supports-color@7.2.0/node_modules/debug/src/browser.js", "../src/components/IsolatedDocumentArea.tsx", "../src/components/DocumentAreaRoot.tsx", "../node_modules/.pnpm/@inkandswitch+patchwork-providers-solid@0.2.3_@automerge+automerge-repo-solid-primitive_3559b773f5c6859eec68b7cb4e30ec04/node_modules/@inkandswitch/patchwork-providers-solid/dist/index.js", "../node_modules/.pnpm/@automerge+automerge-repo-solid-primitives@2.6.0-subduction.29_@automerge+automerge@3.3.0-fragments.1_solid-js@1.9.13/node_modules/node_modules/.pnpm/@automerge+automerge@3.3.0-fragments.1/node_modules/@automerge/automerge/dist/mjs/constants.js", "../node_modules/.pnpm/@automerge+automerge-repo-solid-primitives@2.6.0-subduction.29_@automerge+automerge@3.3.0-fragments.1_solid-js@1.9.13/node_modules/node_modules/.pnpm/@automerge+automerge@3.3.0-fragments.1/node_modules/@automerge/automerge/dist/mjs/immutable_string.js", "../node_modules/.pnpm/@automerge+automerge-repo-solid-primitives@2.6.0-subduction.29_@automerge+automerge@3.3.0-fragments.1_solid-js@1.9.13/node_modules/node_modules/.pnpm/@automerge+automerge@3.3.0-fragments.1/node_modules/@automerge/automerge/dist/mjs/proxies.js", "../node_modules/.pnpm/@automerge+automerge-repo-solid-primitives@2.6.0-subduction.29_@automerge+automerge@3.3.0-fragments.1_solid-js@1.9.13/node_modules/node_modules/.pnpm/@automerge+automerge@3.3.0-fragments.1/node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/web/automerge_wasm.js", "../node_modules/.pnpm/@automerge+automerge-repo-solid-primitives@2.6.0-subduction.29_@automerge+automerge@3.3.0-fragments.1_solid-js@1.9.13/node_modules/node_modules/.pnpm/@automerge+automerge@3.3.0-fragments.1/node_modules/@automerge/automerge/dist/mjs/internal_state.js", "../node_modules/.pnpm/@automerge+automerge-repo-solid-primitives@2.6.0-subduction.29_@automerge+automerge@3.3.0-fragments.1_solid-js@1.9.13/node_modules/node_modules/.pnpm/@automerge+automerge@3.3.0-fragments.1/node_modules/@automerge/automerge/dist/mjs/apply_patches.js", "../node_modules/.pnpm/@automerge+automerge-repo-solid-primitives@2.6.0-subduction.29_@automerge+automerge@3.3.0-fragments.1_solid-js@1.9.13/node_modules/node_modules/.pnpm/@automerge+automerge@3.3.0-fragments.1/node_modules/@automerge/automerge/dist/mjs/implementation.js", "../node_modules/.pnpm/@automerge+automerge-repo-solid-primitives@2.6.0-subduction.29_@automerge+automerge@3.3.0-fragments.1_solid-js@1.9.13/node_modules/@automerge/automerge-repo-solid-primitives/src/autoproduce.ts", "../node_modules/.pnpm/@automerge+automerge-repo-solid-primitives@2.6.0-subduction.29_@automerge+automerge@3.3.0-fragments.1_solid-js@1.9.13/node_modules/@automerge/automerge-repo-solid-primitives/src/makeDocumentProjection.ts", "../node_modules/.pnpm/@automerge+automerge-repo-solid-primitives@2.6.0-subduction.29_@automerge+automerge@3.3.0-fragments.1_solid-js@1.9.13/node_modules/@automerge/automerge-repo-solid-primitives/src/createDocumentProjection.ts", "../node_modules/.pnpm/@automerge+automerge-repo-solid-primitives@2.6.0-subduction.29_@automerge+automerge@3.3.0-fragments.1_solid-js@1.9.13/node_modules/@automerge/automerge-repo-solid-primitives/src/context.ts", "../node_modules/.pnpm/@automerge+automerge-repo-solid-primitives@2.6.0-subduction.29_@automerge+automerge@3.3.0-fragments.1_solid-js@1.9.13/node_modules/@automerge/automerge-repo-solid-primitives/src/useDocHandle.ts", "../node_modules/.pnpm/@automerge+automerge-repo-solid-primitives@2.6.0-subduction.29_@automerge+automerge@3.3.0-fragments.1_solid-js@1.9.13/node_modules/@automerge/automerge-repo-solid-primitives/src/useDocument.ts", "../node_modules/.pnpm/@automerge+automerge-repo-solid-primitives@2.6.0-subduction.29_@automerge+automerge@3.3.0-fragments.1_solid-js@1.9.13/node_modules/@automerge/automerge-repo-solid-primitives/src/makeDocSignal.ts", "../node_modules/.pnpm/@automerge+automerge-repo-solid-primitives@2.6.0-subduction.29_@automerge+automerge@3.3.0-fragments.1_solid-js@1.9.13/node_modules/@automerge/automerge-repo-solid-primitives/src/createDocSignal.ts", "../node_modules/.pnpm/@automerge+automerge-repo-solid-primitives@2.6.0-subduction.29_@automerge+automerge@3.3.0-fragments.1_solid-js@1.9.13/node_modules/@automerge/automerge-repo-solid-primitives/src/useDocSignal.ts", "../node_modules/.pnpm/@automerge+automerge-repo-solid-primitives@2.6.0-subduction.29_@automerge+automerge@3.3.0-fragments.1_solid-js@1.9.13/node_modules/@automerge/automerge-repo-solid-primitives/src/useRepo.ts", "../node_modules/.pnpm/@inkandswitch+patchwork-providers@0.2.2_@automerge+automerge-repo@2.6.0-subduction.29_supports-color@7.2.0_/node_modules/@inkandswitch/patchwork-providers/dist/index.js", "../node_modules/.pnpm/@solid-primitives+storage@4.4.0_solid-js@1.9.13/node_modules/@solid-primitives/storage/dist/persisted.js", "../src/hooks/useSidebarState.ts", "../src/hooks/useSidebarResize.ts", "../src/hooks/useProviderReady.ts", "../src/hooks/useMainDocMounted.ts", "../src/hooks/useTaggedComponents.ts", "../src/hooks/useDebugRegistryToast.tsx", "../src/components/FrameTopBar.tsx", "../src/components/DocumentTitle.tsx", "../node_modules/.pnpm/cabbages@0.2.10_supports-color@7.2.0/node_modules/cabbages/output/cabbages.js", "../node_modules/.pnpm/solid-automerge@2.0.1_@automerge+automerge-repo@2.6.0-subduction.29_supports-color@7.2._bdfa3de96c3582381256a7821d64f5c1/node_modules/solid-automerge/src/autoproduce.ts", "../node_modules/.pnpm/solid-automerge@2.0.1_@automerge+automerge-repo@2.6.0-subduction.29_supports-color@7.2._bdfa3de96c3582381256a7821d64f5c1/node_modules/solid-automerge/src/createDocumentProjection.ts", "../node_modules/.pnpm/solid-automerge@2.0.1_@automerge+automerge-repo@2.6.0-subduction.29_supports-color@7.2._bdfa3de96c3582381256a7821d64f5c1/node_modules/solid-automerge/src/makeDocumentProjection.ts", "../node_modules/.pnpm/@solid-primitives+utils@6.4.1_solid-js@1.9.13/node_modules/@solid-primitives/utils/dist/index.js", "../node_modules/.pnpm/solid-automerge@2.0.1_@automerge+automerge-repo@2.6.0-subduction.29_supports-color@7.2._bdfa3de96c3582381256a7821d64f5c1/node_modules/solid-automerge/src/useDocHandle.ts", "../node_modules/.pnpm/solid-automerge@2.0.1_@automerge+automerge-repo@2.6.0-subduction.29_supports-color@7.2._bdfa3de96c3582381256a7821d64f5c1/node_modules/solid-automerge/src/context.ts", "../node_modules/.pnpm/solid-automerge@2.0.1_@automerge+automerge-repo@2.6.0-subduction.29_supports-color@7.2._bdfa3de96c3582381256a7821d64f5c1/node_modules/solid-automerge/src/useDocument.ts", "../node_modules/.pnpm/solid-automerge@2.0.1_@automerge+automerge-repo@2.6.0-subduction.29_supports-color@7.2._bdfa3de96c3582381256a7821d64f5c1/node_modules/solid-automerge/src/makeDocSignal.ts", "../node_modules/.pnpm/solid-automerge@2.0.1_@automerge+automerge-repo@2.6.0-subduction.29_supports-color@7.2._bdfa3de96c3582381256a7821d64f5c1/node_modules/solid-automerge/src/createDocSignal.ts", "../node_modules/.pnpm/solid-automerge@2.0.1_@automerge+automerge-repo@2.6.0-subduction.29_supports-color@7.2._bdfa3de96c3582381256a7821d64f5c1/node_modules/solid-automerge/src/useRepo.ts", "../src/components/ContextSidebar.tsx", "../src/components/Sidebar.tsx", "../src/components/ContextTabs.tsx", "../src/components/SlotView.tsx", "../src/components/MainDocumentView.tsx", "../src/styles.css", "../src/ensureFrameStyles.ts"],
4
- "sourcesContent": ["/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar w = d * 7;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function (val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isFinite(val)) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'weeks':\n case 'week':\n case 'w':\n return n * w;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (msAbs >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (msAbs >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (msAbs >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return plural(ms, msAbs, d, 'day');\n }\n if (msAbs >= h) {\n return plural(ms, msAbs, h, 'hour');\n }\n if (msAbs >= m) {\n return plural(ms, msAbs, m, 'minute');\n }\n if (msAbs >= s) {\n return plural(ms, msAbs, s, 'second');\n }\n return ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, msAbs, n, name) {\n var isPlural = msAbs >= n * 1.5;\n return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');\n}\n", "\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n */\n\nfunction setup(env) {\n\tcreateDebug.debug = createDebug;\n\tcreateDebug.default = createDebug;\n\tcreateDebug.coerce = coerce;\n\tcreateDebug.disable = disable;\n\tcreateDebug.enable = enable;\n\tcreateDebug.enabled = enabled;\n\tcreateDebug.humanize = require('ms');\n\tcreateDebug.destroy = destroy;\n\n\tObject.keys(env).forEach(key => {\n\t\tcreateDebug[key] = env[key];\n\t});\n\n\t/**\n\t* The currently active debug mode names, and names to skip.\n\t*/\n\n\tcreateDebug.names = [];\n\tcreateDebug.skips = [];\n\n\t/**\n\t* Map of special \"%n\" handling functions, for the debug \"format\" argument.\n\t*\n\t* Valid key names are a single, lower or upper-case letter, i.e. \"n\" and \"N\".\n\t*/\n\tcreateDebug.formatters = {};\n\n\t/**\n\t* Selects a color for a debug namespace\n\t* @param {String} namespace The namespace string for the debug instance to be colored\n\t* @return {Number|String} An ANSI color code for the given namespace\n\t* @api private\n\t*/\n\tfunction selectColor(namespace) {\n\t\tlet hash = 0;\n\n\t\tfor (let i = 0; i < namespace.length; i++) {\n\t\t\thash = ((hash << 5) - hash) + namespace.charCodeAt(i);\n\t\t\thash |= 0; // Convert to 32bit integer\n\t\t}\n\n\t\treturn createDebug.colors[Math.abs(hash) % createDebug.colors.length];\n\t}\n\tcreateDebug.selectColor = selectColor;\n\n\t/**\n\t* Create a debugger with the given `namespace`.\n\t*\n\t* @param {String} namespace\n\t* @return {Function}\n\t* @api public\n\t*/\n\tfunction createDebug(namespace) {\n\t\tlet prevTime;\n\t\tlet enableOverride = null;\n\t\tlet namespacesCache;\n\t\tlet enabledCache;\n\n\t\tfunction debug(...args) {\n\t\t\t// Disabled?\n\t\t\tif (!debug.enabled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst self = debug;\n\n\t\t\t// Set `diff` timestamp\n\t\t\tconst curr = Number(new Date());\n\t\t\tconst ms = curr - (prevTime || curr);\n\t\t\tself.diff = ms;\n\t\t\tself.prev = prevTime;\n\t\t\tself.curr = curr;\n\t\t\tprevTime = curr;\n\n\t\t\targs[0] = createDebug.coerce(args[0]);\n\n\t\t\tif (typeof args[0] !== 'string') {\n\t\t\t\t// Anything else let's inspect with %O\n\t\t\t\targs.unshift('%O');\n\t\t\t}\n\n\t\t\t// Apply any `formatters` transformations\n\t\t\tlet index = 0;\n\t\t\targs[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {\n\t\t\t\t// If we encounter an escaped % then don't increase the array index\n\t\t\t\tif (match === '%%') {\n\t\t\t\t\treturn '%';\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t\tconst formatter = createDebug.formatters[format];\n\t\t\t\tif (typeof formatter === 'function') {\n\t\t\t\t\tconst val = args[index];\n\t\t\t\t\tmatch = formatter.call(self, val);\n\n\t\t\t\t\t// Now we need to remove `args[index]` since it's inlined in the `format`\n\t\t\t\t\targs.splice(index, 1);\n\t\t\t\t\tindex--;\n\t\t\t\t}\n\t\t\t\treturn match;\n\t\t\t});\n\n\t\t\t// Apply env-specific formatting (colors, etc.)\n\t\t\tcreateDebug.formatArgs.call(self, args);\n\n\t\t\tconst logFn = self.log || createDebug.log;\n\t\t\tlogFn.apply(self, args);\n\t\t}\n\n\t\tdebug.namespace = namespace;\n\t\tdebug.useColors = createDebug.useColors();\n\t\tdebug.color = createDebug.selectColor(namespace);\n\t\tdebug.extend = extend;\n\t\tdebug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.\n\n\t\tObject.defineProperty(debug, 'enabled', {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: false,\n\t\t\tget: () => {\n\t\t\t\tif (enableOverride !== null) {\n\t\t\t\t\treturn enableOverride;\n\t\t\t\t}\n\t\t\t\tif (namespacesCache !== createDebug.namespaces) {\n\t\t\t\t\tnamespacesCache = createDebug.namespaces;\n\t\t\t\t\tenabledCache = createDebug.enabled(namespace);\n\t\t\t\t}\n\n\t\t\t\treturn enabledCache;\n\t\t\t},\n\t\t\tset: v => {\n\t\t\t\tenableOverride = v;\n\t\t\t}\n\t\t});\n\n\t\t// Env-specific initialization logic for debug instances\n\t\tif (typeof createDebug.init === 'function') {\n\t\t\tcreateDebug.init(debug);\n\t\t}\n\n\t\treturn debug;\n\t}\n\n\tfunction extend(namespace, delimiter) {\n\t\tconst newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);\n\t\tnewDebug.log = this.log;\n\t\treturn newDebug;\n\t}\n\n\t/**\n\t* Enables a debug mode by namespaces. This can include modes\n\t* separated by a colon and wildcards.\n\t*\n\t* @param {String} namespaces\n\t* @api public\n\t*/\n\tfunction enable(namespaces) {\n\t\tcreateDebug.save(namespaces);\n\t\tcreateDebug.namespaces = namespaces;\n\n\t\tcreateDebug.names = [];\n\t\tcreateDebug.skips = [];\n\n\t\tconst split = (typeof namespaces === 'string' ? namespaces : '')\n\t\t\t.trim()\n\t\t\t.replace(/\\s+/g, ',')\n\t\t\t.split(',')\n\t\t\t.filter(Boolean);\n\n\t\tfor (const ns of split) {\n\t\t\tif (ns[0] === '-') {\n\t\t\t\tcreateDebug.skips.push(ns.slice(1));\n\t\t\t} else {\n\t\t\t\tcreateDebug.names.push(ns);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks if the given string matches a namespace template, honoring\n\t * asterisks as wildcards.\n\t *\n\t * @param {String} search\n\t * @param {String} template\n\t * @return {Boolean}\n\t */\n\tfunction matchesTemplate(search, template) {\n\t\tlet searchIndex = 0;\n\t\tlet templateIndex = 0;\n\t\tlet starIndex = -1;\n\t\tlet matchIndex = 0;\n\n\t\twhile (searchIndex < search.length) {\n\t\t\tif (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {\n\t\t\t\t// Match character or proceed with wildcard\n\t\t\t\tif (template[templateIndex] === '*') {\n\t\t\t\t\tstarIndex = templateIndex;\n\t\t\t\t\tmatchIndex = searchIndex;\n\t\t\t\t\ttemplateIndex++; // Skip the '*'\n\t\t\t\t} else {\n\t\t\t\t\tsearchIndex++;\n\t\t\t\t\ttemplateIndex++;\n\t\t\t\t}\n\t\t\t} else if (starIndex !== -1) { // eslint-disable-line no-negated-condition\n\t\t\t\t// Backtrack to the last '*' and try to match more characters\n\t\t\t\ttemplateIndex = starIndex + 1;\n\t\t\t\tmatchIndex++;\n\t\t\t\tsearchIndex = matchIndex;\n\t\t\t} else {\n\t\t\t\treturn false; // No match\n\t\t\t}\n\t\t}\n\n\t\t// Handle trailing '*' in template\n\t\twhile (templateIndex < template.length && template[templateIndex] === '*') {\n\t\t\ttemplateIndex++;\n\t\t}\n\n\t\treturn templateIndex === template.length;\n\t}\n\n\t/**\n\t* Disable debug output.\n\t*\n\t* @return {String} namespaces\n\t* @api public\n\t*/\n\tfunction disable() {\n\t\tconst namespaces = [\n\t\t\t...createDebug.names,\n\t\t\t...createDebug.skips.map(namespace => '-' + namespace)\n\t\t].join(',');\n\t\tcreateDebug.enable('');\n\t\treturn namespaces;\n\t}\n\n\t/**\n\t* Returns true if the given mode name is enabled, false otherwise.\n\t*\n\t* @param {String} name\n\t* @return {Boolean}\n\t* @api public\n\t*/\n\tfunction enabled(name) {\n\t\tfor (const skip of createDebug.skips) {\n\t\t\tif (matchesTemplate(name, skip)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tfor (const ns of createDebug.names) {\n\t\t\tif (matchesTemplate(name, ns)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t* Coerce `val`.\n\t*\n\t* @param {Mixed} val\n\t* @return {Mixed}\n\t* @api private\n\t*/\n\tfunction coerce(val) {\n\t\tif (val instanceof Error) {\n\t\t\treturn val.stack || val.message;\n\t\t}\n\t\treturn val;\n\t}\n\n\t/**\n\t* XXX DO NOT USE. This is a temporary stub function.\n\t* XXX It WILL be removed in the next major release.\n\t*/\n\tfunction destroy() {\n\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t}\n\n\tcreateDebug.enable(createDebug.load());\n\n\treturn createDebug;\n}\n\nmodule.exports = setup;\n", "/* eslint-env browser */\n\n/**\n * This is the web browser implementation of `debug()`.\n */\n\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = localstorage();\nexports.destroy = (() => {\n\tlet warned = false;\n\n\treturn () => {\n\t\tif (!warned) {\n\t\t\twarned = true;\n\t\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t\t}\n\t};\n})();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n\t'#0000CC',\n\t'#0000FF',\n\t'#0033CC',\n\t'#0033FF',\n\t'#0066CC',\n\t'#0066FF',\n\t'#0099CC',\n\t'#0099FF',\n\t'#00CC00',\n\t'#00CC33',\n\t'#00CC66',\n\t'#00CC99',\n\t'#00CCCC',\n\t'#00CCFF',\n\t'#3300CC',\n\t'#3300FF',\n\t'#3333CC',\n\t'#3333FF',\n\t'#3366CC',\n\t'#3366FF',\n\t'#3399CC',\n\t'#3399FF',\n\t'#33CC00',\n\t'#33CC33',\n\t'#33CC66',\n\t'#33CC99',\n\t'#33CCCC',\n\t'#33CCFF',\n\t'#6600CC',\n\t'#6600FF',\n\t'#6633CC',\n\t'#6633FF',\n\t'#66CC00',\n\t'#66CC33',\n\t'#9900CC',\n\t'#9900FF',\n\t'#9933CC',\n\t'#9933FF',\n\t'#99CC00',\n\t'#99CC33',\n\t'#CC0000',\n\t'#CC0033',\n\t'#CC0066',\n\t'#CC0099',\n\t'#CC00CC',\n\t'#CC00FF',\n\t'#CC3300',\n\t'#CC3333',\n\t'#CC3366',\n\t'#CC3399',\n\t'#CC33CC',\n\t'#CC33FF',\n\t'#CC6600',\n\t'#CC6633',\n\t'#CC9900',\n\t'#CC9933',\n\t'#CCCC00',\n\t'#CCCC33',\n\t'#FF0000',\n\t'#FF0033',\n\t'#FF0066',\n\t'#FF0099',\n\t'#FF00CC',\n\t'#FF00FF',\n\t'#FF3300',\n\t'#FF3333',\n\t'#FF3366',\n\t'#FF3399',\n\t'#FF33CC',\n\t'#FF33FF',\n\t'#FF6600',\n\t'#FF6633',\n\t'#FF9900',\n\t'#FF9933',\n\t'#FFCC00',\n\t'#FFCC33'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\n// eslint-disable-next-line complexity\nfunction useColors() {\n\t// NB: In an Electron preload script, document will be defined but not fully\n\t// initialized. Since we know we're in Chrome, we'll just detect this case\n\t// explicitly\n\tif (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {\n\t\treturn true;\n\t}\n\n\t// Internet Explorer and Edge do not support colors.\n\tif (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)) {\n\t\treturn false;\n\t}\n\n\tlet m;\n\n\t// Is webkit? http://stackoverflow.com/a/16459606/376773\n\t// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632\n\t// eslint-disable-next-line no-return-assign\n\treturn (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||\n\t\t// Is firebug? http://stackoverflow.com/a/398120/376773\n\t\t(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||\n\t\t// Is firefox >= v31?\n\t\t// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)) && parseInt(m[1], 10) >= 31) ||\n\t\t// Double check webkit in userAgent just in case we are in a worker\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/));\n}\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n\targs[0] = (this.useColors ? '%c' : '') +\n\t\tthis.namespace +\n\t\t(this.useColors ? ' %c' : ' ') +\n\t\targs[0] +\n\t\t(this.useColors ? '%c ' : ' ') +\n\t\t'+' + module.exports.humanize(this.diff);\n\n\tif (!this.useColors) {\n\t\treturn;\n\t}\n\n\tconst c = 'color: ' + this.color;\n\targs.splice(1, 0, c, 'color: inherit');\n\n\t// The final \"%c\" is somewhat tricky, because there could be other\n\t// arguments passed either before or after the %c, so we need to\n\t// figure out the correct index to insert the CSS into\n\tlet index = 0;\n\tlet lastC = 0;\n\targs[0].replace(/%[a-zA-Z%]/g, match => {\n\t\tif (match === '%%') {\n\t\t\treturn;\n\t\t}\n\t\tindex++;\n\t\tif (match === '%c') {\n\t\t\t// We only are interested in the *last* %c\n\t\t\t// (the user may have provided their own)\n\t\t\tlastC = index;\n\t\t}\n\t});\n\n\targs.splice(lastC, 0, c);\n}\n\n/**\n * Invokes `console.debug()` when available.\n * No-op when `console.debug` is not a \"function\".\n * If `console.debug` is not available, falls back\n * to `console.log`.\n *\n * @api public\n */\nexports.log = console.debug || console.log || (() => {});\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\nfunction save(namespaces) {\n\ttry {\n\t\tif (namespaces) {\n\t\t\texports.storage.setItem('debug', namespaces);\n\t\t} else {\n\t\t\texports.storage.removeItem('debug');\n\t\t}\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\nfunction load() {\n\tlet r;\n\ttry {\n\t\tr = exports.storage.getItem('debug') || exports.storage.getItem('DEBUG') ;\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n\n\t// If debug isn't set in LS, and we're in Electron, try to load $DEBUG\n\tif (!r && typeof process !== 'undefined' && 'env' in process) {\n\t\tr = process.env.DEBUG;\n\t}\n\n\treturn r;\n}\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage() {\n\ttry {\n\t\t// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context\n\t\t// The Browser also has localStorage in the global context.\n\t\treturn localStorage;\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\nmodule.exports = require('./common')(exports);\n\nconst {formatters} = module.exports;\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nformatters.j = function (v) {\n\ttry {\n\t\treturn JSON.stringify(v);\n\t} catch (error) {\n\t\treturn '[UnexpectedJSONParseError]: ' + error.message;\n\t}\n};\n", "import { template as _$template } from \"solid-js/web\";\nimport { createComponent as _$createComponent } from \"solid-js/web\";\nimport { setAttribute as _$setAttribute } from \"solid-js/web\";\nimport { effect as _$effect } from \"solid-js/web\";\nimport { insert as _$insert } from \"solid-js/web\";\nimport { getOwner as _$getOwner } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<patchwork-view component=patchwork-isolation root-component=threepane-isolation-root shared-providers=patchwork:contact,patchwork:selected-doc style=display:contents><script type=application/json data-root-component-data>`, true, false, false),\n _tmpl$2 = /*#__PURE__*/_$template(`<div class=frame>`);\nimport { createMemo } from \"solid-js\";\nimport { createStore, reconcile } from \"solid-js/store\";\nimport { render } from \"solid-js/web\";\nimport { DocumentAreaRoot } from \"./DocumentAreaRoot\";\nimport { DEFAULT_SIDEBAR_WIDTH } from \"../hooks\";\nimport { ensureFrameStyles } from \"../ensureFrameStyles\";\nexport function IsolatedDocumentArea(props) {\n const rootUrls = createMemo(() => {\n const urls = /* @__PURE__ */new Set();\n const selected = props.selectedDocUrl();\n if (selected) urls.add(selected);\n if (props.contactUrl) urls.add(props.contactUrl);\n return [...urls];\n });\n const propsJson = createMemo(() => JSON.stringify({\n selectedDocUrl: props.selectedDocUrl(),\n selectedToolId: props.selectedToolId(),\n doctitleSlots: props.doctitleSlots(),\n isLeftCollapsed: props.isLeftCollapsed(),\n initialRightWidth: props.initialRightWidth(),\n initialRightCollapsed: props.initialRightCollapsed()\n }));\n return (() => {\n var _el$ = _tmpl$(),\n _el$2 = _el$.firstChild;\n _el$._$owner = _$getOwner();\n _$insert(_el$2, propsJson);\n _$effect(() => _$setAttribute(_el$, \"automerge-allowlist\", rootUrls().join(\",\")));\n return _el$;\n })();\n}\nfunction parseProps(script) {\n if (!script?.textContent) return {};\n try {\n return JSON.parse(script.textContent);\n } catch (err) {\n console.error(\"[threepane-isolation-root] bad props JSON:\", err);\n return {};\n }\n}\nexport function mountIsolationRoot(element) {\n ensureFrameStyles();\n const script = element.querySelector('script[type=\"application/json\"]');\n const [p, setP] = createStore(parseProps(script));\n const observer = new MutationObserver(() => {\n setP(reconcile(parseProps(script)));\n });\n if (script) {\n observer.observe(script, {\n characterData: true,\n childList: true,\n subtree: true\n });\n }\n const dispose = render(() => (() => {\n var _el$3 = _tmpl$2();\n _$insert(_el$3, _$createComponent(DocumentAreaRoot, {\n selectedDocUrl: () => p.selectedDocUrl,\n selectedToolId: () => p.selectedToolId,\n doctitleSlots: () => p.doctitleSlots,\n isLeftCollapsed: () => p.isLeftCollapsed ?? false,\n initialRightWidth: () => p.initialRightWidth ?? DEFAULT_SIDEBAR_WIDTH,\n initialRightCollapsed: () => p.initialRightCollapsed ?? false\n }));\n return _el$3;\n })(), element);\n return () => {\n observer.disconnect();\n dispose();\n };\n}", "import { template as _$template } from \"solid-js/web\";\nimport { insert as _$insert } from \"solid-js/web\";\nimport { getOwner as _$getOwner } from \"solid-js/web\";\nimport { use as _$use } from \"solid-js/web\";\nimport { createComponent as _$createComponent } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<patchwork-view component=patchwork-draft-list-provider>`, true, false, false),\n _tmpl$2 = /*#__PURE__*/_$template(`<div class=frame__main-column><div class=frame__doc-column><div class=main-area>`),\n _tmpl$3 = /*#__PURE__*/_$template(`<patchwork-view component=patchwork-draft-overlay-provider><patchwork-view component=patchwork-comments-provider><patchwork-view component=patchwork-focus-provider>`, true, false, false);\nimport { parseAutomergeUrl, stringifyAutomergeUrl } from \"@automerge/automerge-repo/slim\";\nimport { subscribeDoc } from \"@inkandswitch/patchwork-providers-solid\";\nimport { makePersisted } from \"@solid-primitives/storage\";\nimport { createEffect, createMemo, createSignal, on, onCleanup, onMount, Show } from \"solid-js\";\nimport { useProviderReady, useTaggedComponents, SIDEBAR_KEYS, COLLAPSE_CONTEXT_SIDEBAR_EVENT } from \"../hooks\";\nimport { useSidebarResize } from \"../hooks/useSidebarResize\";\nimport { FrameTopBar } from \"./FrameTopBar\";\nimport { ContextSidebar } from \"./ContextSidebar\";\nimport { MainDocumentView } from \"./MainDocumentView\";\nconst MIN_SIDEBAR_WIDTH = 180;\nconst MAX_SIDEBAR_WIDTH = 720;\nconst AUTO_CLOSE_WIDTH = 120;\nconst DRAG_THRESHOLD = 3;\nexport function DocumentAreaRoot(props) {\n const [isRightSidebarCollapsed, setIsRightSidebarCollapsed] = createSignal(props.initialRightCollapsed());\n const [rightSidebarWidth, setRightSidebarWidth] = createSignal(props.initialRightWidth());\n createEffect(on(isRightSidebarCollapsed, value => {\n try {\n localStorage.setItem(SIDEBAR_KEYS.rightCollapsed, String(value));\n } catch {}\n }, {\n defer: true\n }));\n createEffect(on(rightSidebarWidth, value => {\n try {\n localStorage.setItem(SIDEBAR_KEYS.rightWidth, String(value));\n } catch {}\n }, {\n defer: true\n }));\n const [, setUnusedLeftWidth] = createSignal(0);\n const [, setUnusedLeftCollapsed] = createSignal(false);\n const sidebarResize = useSidebarResize({\n setLeftSidebarWidth: setUnusedLeftWidth,\n setRightSidebarWidth,\n setIsSidebarCollapsed: setUnusedLeftCollapsed,\n setIsRightSidebarCollapsed,\n isLeftCollapsed: () => props.isLeftCollapsed(),\n isRightCollapsed: isRightSidebarCollapsed,\n minWidth: MIN_SIDEBAR_WIDTH,\n maxWidth: MAX_SIDEBAR_WIDTH,\n autoCloseWidth: AUTO_CLOSE_WIDTH,\n dragThreshold: DRAG_THRESHOLD\n });\n onMount(() => {\n const onCollapse = () => setIsRightSidebarCollapsed(true);\n window.addEventListener(COLLAPSE_CONTEXT_SIDEBAR_EVENT, onCollapse);\n onCleanup(() => window.removeEventListener(COLLAPSE_CONTEXT_SIDEBAR_EVENT, onCollapse));\n });\n const [selectedContextToolId, setSelectedContextToolId] = makePersisted(createSignal(), {\n name: SIDEBAR_KEYS.contextToolId\n });\n const [draftListProviderHost, setDraftListProviderHost] = createSignal();\n const isDraftListProviderReady = useProviderReady(\"patchwork-draft-list-provider\", draftListProviderHost);\n const readyDraftListHost = () => isDraftListProviderReady() ? draftListProviderHost() : void 0;\n return _$createComponent(Show, {\n get when() {\n return props.selectedDocUrl();\n },\n keyed: true,\n children: docUrl => (() => {\n var _el$ = _tmpl$();\n _$use(setDraftListProviderHost, _el$);\n _el$.docUrl = docUrl;\n _el$._$owner = _$getOwner();\n _$insert(_el$, _$createComponent(Show, {\n get when() {\n return readyDraftListHost();\n },\n children: host => _$createComponent(DraftDocumentArea, {\n get host() {\n return host();\n },\n get setMainDocElement() {\n return props.setMainDocElement;\n },\n get selectedDocUrl() {\n return props.selectedDocUrl;\n },\n get selectedToolId() {\n return props.selectedToolId;\n },\n get doctitleSlots() {\n return props.doctitleSlots;\n },\n get isLeftCollapsed() {\n return props.isLeftCollapsed;\n },\n isRightSidebarCollapsed: isRightSidebarCollapsed,\n setIsRightSidebarCollapsed: setIsRightSidebarCollapsed,\n rightSidebarWidth: rightSidebarWidth,\n get handleMouseDown() {\n return sidebarResize.handleMouseDown;\n },\n get handleToggleClick() {\n return sidebarResize.handleToggleClick;\n },\n selectedContextToolId: selectedContextToolId,\n setSelectedContextToolId: setSelectedContextToolId\n })\n }));\n return _el$;\n })()\n });\n}\nfunction DraftDocumentArea(props) {\n const [checkedOut] = subscribeDoc(props.host, {\n type: \"draft:checked-out\"\n });\n const draftProviderKey = createMemo(() => checkedOut()?.checkedOut ?? \"main\");\n const contextItems = useTaggedComponents(\"context-tool\");\n const hasContext = () => contextItems().length > 0;\n const pinnedDocUrl = createMemo(() => {\n const url = props.selectedDocUrl();\n if (!url) return url;\n const {\n documentId\n } = parseAutomergeUrl(url);\n const heads = checkedOut()?.at?.[stringifyAutomergeUrl({\n documentId\n })]?.to;\n return heads ? stringifyAutomergeUrl({\n documentId,\n heads\n }) : url;\n });\n const mainViewKey = createMemo(() => {\n const url = pinnedDocUrl();\n if (!url) return url;\n return `${url}|${JSON.stringify(checkedOut()?.at ?? null)}`;\n });\n const [draftOverlayProviderHost, setDraftOverlayProviderHost] = createSignal();\n const isDraftOverlayProviderReady = useProviderReady(\"patchwork-draft-overlay-provider\", draftOverlayProviderHost);\n const [commentsProviderElement, setCommentsProviderElement] = createSignal();\n const isCommentsProviderReady = useProviderReady(\"patchwork-comments-provider\", commentsProviderElement);\n const [focusProviderElement, setFocusProviderElement] = createSignal();\n const isFocusProviderReady = useProviderReady(\"patchwork-focus-provider\", focusProviderElement);\n const areDocProvidersReady = createMemo(() => isDraftOverlayProviderReady() && isCommentsProviderReady() && isFocusProviderReady());\n return _$createComponent(Show, {\n get when() {\n return draftProviderKey();\n },\n keyed: true,\n children: key => (() => {\n var _el$2 = _tmpl$3(),\n _el$3 = _el$2.firstChild,\n _el$4 = _el$3.firstChild;\n _$use(setDraftOverlayProviderHost, _el$2);\n _el$2.url = key === \"main\" ? \"\" : key;\n _el$2._$owner = _$getOwner();\n _$use(setCommentsProviderElement, _el$3);\n _el$3._$owner = _$getOwner();\n _$use(setFocusProviderElement, _el$4);\n _el$4._$owner = _$getOwner();\n _$insert(_el$4, _$createComponent(Show, {\n get when() {\n return areDocProvidersReady();\n },\n get children() {\n var _el$5 = _tmpl$2(),\n _el$6 = _el$5.firstChild,\n _el$7 = _el$6.firstChild;\n _$insert(_el$6, _$createComponent(FrameTopBar, {\n get docUrl() {\n return props.selectedDocUrl;\n },\n get toolSlots() {\n return props.doctitleSlots;\n },\n get isLeftCollapsed() {\n return props.isLeftCollapsed;\n },\n hasContext: hasContext,\n get isRightCollapsed() {\n return props.isRightSidebarCollapsed;\n },\n onToggleRight: () => props.setIsRightSidebarCollapsed(v => !v)\n }), _el$7);\n _$insert(_el$7, _$createComponent(MainDocumentView, {\n viewKey: mainViewKey,\n selectedDocUrl: pinnedDocUrl,\n get toolId() {\n return props.selectedToolId;\n },\n ref: el => props.setMainDocElement?.(el)\n }));\n _$insert(_el$5, _$createComponent(Show, {\n get when() {\n return hasContext();\n },\n get children() {\n return _$createComponent(ContextSidebar, {\n get selectedToolId() {\n return props.selectedContextToolId;\n },\n get setSelectedToolId() {\n return props.setSelectedContextToolId;\n },\n get isCollapsed() {\n return props.isRightSidebarCollapsed;\n },\n get width() {\n return props.rightSidebarWidth;\n },\n get onMouseDown() {\n return props.handleMouseDown;\n },\n get onToggleClick() {\n return props.handleToggleClick;\n },\n onCollapse: () => props.setIsRightSidebarCollapsed(true)\n });\n }\n }), null);\n return _el$5;\n }\n }));\n return _el$2;\n })()\n });\n}", "import { createSignal, onCleanup, onMount } from \"solid-js\";\nimport { createStore, reconcile } from \"solid-js/store\";\nimport { createDocumentProjection } from \"@automerge/automerge-repo-solid-primitives\";\nimport * as Providers from \"@inkandswitch/patchwork-providers\";\nfunction resolveElement(source) {\n return typeof source === \"function\" ? source() : source;\n}\n/**\n * Generic reactive request. Resolves the first value a provider emits for\n * `selector` (via the one-shot `request` helper) and returns an accessor that\n * reads `undefined` until then. `T` is the response type.\n */\nexport function request(element, selector) {\n const [value, setValue] = createSignal(undefined);\n onMount(() => {\n const target = resolveElement(element);\n if (!target)\n return;\n Providers.request(target, selector).then((v) => {\n if (v == null)\n return;\n setValue(() => v);\n });\n });\n return value;\n}\nexport function subscribe(element, selector, initialValue) {\n const [value, setValue] = createSignal(initialValue);\n onMount(() => {\n const target = resolveElement(element);\n if (!target)\n return;\n const unsubscribe = Providers.subscribe(target, selector, setValue);\n onCleanup(unsubscribe);\n });\n return value;\n}\n/**\n * Store-backed subscription. Use this when a consumer wants Solid's\n * fine-grained nested reactivity for incoming JSON object or array snapshots.\n * Requires an initial object/array so the store has a stable root.\n *\n * `reconcile` preserves stable object/array identity where possible, so this\n * helper is not a good fit when the top-level value is used as an identity key\n * for resources or memos.\n */\nexport function subscribeReconciled(element, selector, initialValue) {\n const [store, setStore] = createStore(initialValue);\n onMount(() => {\n const target = resolveElement(element);\n if (!target)\n return;\n const unsubscribe = Providers.subscribe(target, selector, (v) => {\n setStore(reconcile(v));\n });\n onCleanup(unsubscribe);\n });\n return store;\n}\n/**\n * Handle-specialized subscription. Use when the answering provider emits an\n * `AutomergeUrl`. The handle is recovered locally from the global repo\n * (`window.repo`), so it stays fully live \u2014 reads project reactively and writes go\n * straight back to the same repo. Returns `[doc, handle]` matching the shape\n * of solid-primitives' `useDocument`; both read `undefined` until the first\n * url arrives. `T` is the doc shape inside the handle.\n */\nexport function subscribeDoc(element, selector) {\n const [handle, setHandle] = createSignal(undefined);\n onMount(() => {\n const target = resolveElement(element);\n if (!target)\n return;\n let canceled = false;\n const unsubscribe = Providers.subscribe(target, selector, (url) => {\n if (!url)\n return;\n const repo = \"repo\" in window ? window.repo : undefined;\n if (!repo)\n return;\n void Promise.resolve(repo.find(url)).then((h) => {\n if (canceled)\n return;\n setHandle(() => h);\n });\n });\n onCleanup(() => {\n canceled = true;\n unsubscribe();\n });\n });\n const doc = createDocumentProjection(handle);\n return [doc, handle];\n}\n", "// Properties of the document root object\nexport const STATE = Symbol.for(\"_am_meta\"); // symbol used to hide application metadata on automerge objects\nexport const TRACE = Symbol.for(\"_am_trace\"); // used for debugging\nexport const OBJECT_ID = Symbol.for(\"_am_objectId\"); // symbol used to hide the object id on automerge objects\nexport const IS_PROXY = Symbol.for(\"_am_isProxy\"); // symbol used to test if the document is a proxy object\nexport const CLEAR_CACHE = Symbol.for(\"_am_clearCache\"); // symbol used to tell a proxy object to clear its cache\nexport const UINT = Symbol.for(\"_am_uint\");\nexport const INT = Symbol.for(\"_am_int\");\nexport const F64 = Symbol.for(\"_am_f64\");\nexport const COUNTER = Symbol.for(\"_am_counter\");\nexport const TEXT = Symbol.for(\"_am_text\");\nexport const IMMUTABLE_STRING = Symbol.for(\"_am_immutableString\");\n", "var _a;\nimport { IMMUTABLE_STRING } from \"./constants.js\";\nexport class ImmutableString {\n constructor(val) {\n // Used to detect whether a value is a ImmutableString object rather than using an instanceof check\n this[_a] = true;\n this.val = val;\n }\n /**\n * Returns the content of the ImmutableString object as a simple string\n */\n toString() {\n return this.val;\n }\n toJSON() {\n return this.val;\n }\n}\n_a = IMMUTABLE_STRING;\n", "const MAX_I64 = BigInt(\"9223372036854775807\"); // 2n ** 63n - 1n;\n/**\n * Recursively validate a value before batch insertion. Checks for\n * - undefined values\n * - proxy references to the same document (common footgun)\n */\nexport function validateForBatchInsert(value, context, path) {\n if (value === undefined) {\n throw new RangeError([\n `Cannot assign undefined value at ${printPath(path)}, `,\n \"You might consider setting the property's value to `null`, \",\n \"or using `delete` to remove it altogether.\",\n ].join(\"\"));\n }\n if (value === null)\n return;\n const type = typeof value;\n if (type !== \"object\")\n return;\n if (context && isSameDocument(value, context)) {\n throw new RangeError(\"Cannot create a reference to an existing document object\");\n }\n if (value instanceof Array) {\n for (let i = 0; i < value.length; i++) {\n validateForBatchInsert(value[i], context, [...path, i]);\n }\n }\n else if (Object.prototype.toString.call(value) === \"[object Object]\") {\n for (const k in value) {\n validateForBatchInsert(value[k], context, [...path, k]);\n }\n }\n}\nimport { getWriteableCounter } from \"./counter.js\";\nimport { STATE, TRACE, IS_PROXY, OBJECT_ID, CLEAR_CACHE, COUNTER, INT, UINT, F64, IMMUTABLE_STRING, } from \"./constants.js\";\nimport { ImmutableString } from \"./immutable_string.js\";\nfunction parseListIndex(key) {\n if (typeof key === \"string\" && /^[0-9]+$/.test(key))\n key = parseInt(key, 10);\n if (typeof key !== \"number\") {\n return key;\n }\n if (key < 0 || isNaN(key) || key === Infinity || key === -Infinity) {\n throw new RangeError(\"A list index must be positive, but you passed \" + key);\n }\n return key;\n}\nfunction valueAt(target, prop) {\n const { context, objectId, path } = target;\n const value = context.getWithType(objectId, prop);\n if (value === null) {\n return;\n }\n const datatype = value[0];\n const val = value[1];\n switch (datatype) {\n case undefined:\n return;\n case \"map\":\n return mapProxy(context, val, [...path, prop]);\n case \"list\":\n return listProxy(context, val, [...path, prop]);\n case \"text\":\n return context.text(val);\n case \"str\":\n return new ImmutableString(val);\n case \"uint\":\n return val;\n case \"int\":\n return val;\n case \"f64\":\n return val;\n case \"boolean\":\n return val;\n case \"null\":\n return null;\n case \"bytes\":\n return val;\n case \"timestamp\":\n return val;\n case \"counter\": {\n const counter = getWriteableCounter(val, context, path, objectId, prop);\n return counter;\n }\n default:\n throw RangeError(`datatype ${datatype} unimplemented`);\n }\n}\nfunction import_value(value, path, context) {\n const type = typeof value;\n switch (type) {\n case \"object\":\n if (value == null) {\n return [null, \"null\"];\n }\n else if (value[UINT]) {\n return [value.value, \"uint\"];\n }\n else if (value[INT]) {\n return [value.value, \"int\"];\n }\n else if (value[F64]) {\n return [value.value, \"f64\"];\n }\n else if (value[COUNTER]) {\n return [value.value, \"counter\"];\n }\n else if (value instanceof Date) {\n return [value.getTime(), \"timestamp\"];\n }\n else if (isImmutableString(value)) {\n return [value.toString(), \"str\"];\n }\n else if (value instanceof Uint8Array) {\n return [value, \"bytes\"];\n }\n else if (value instanceof Array) {\n return [value, \"list\"];\n }\n else if (Object.prototype.toString.call(value) === \"[object Object]\") {\n return [value, \"map\"];\n }\n else if (isSameDocument(value, context)) {\n throw new RangeError(\"Cannot create a reference to an existing document object\");\n }\n else {\n throw new RangeError(`Cannot assign unknown object: ${value}`);\n }\n case \"boolean\":\n return [value, \"boolean\"];\n case \"bigint\":\n if (value > MAX_I64) {\n return [value, \"uint\"];\n }\n else {\n return [value, \"int\"];\n }\n case \"number\":\n if (Number.isInteger(value)) {\n return [value, \"int\"];\n }\n else {\n return [value, \"f64\"];\n }\n case \"string\":\n return [value, \"text\"];\n case \"undefined\":\n throw new RangeError([\n `Cannot assign undefined value at ${printPath(path)}, `,\n \"because `undefined` is not a valid JSON data type. \",\n \"You might consider setting the property's value to `null`, \",\n \"or using `delete` to remove it altogether.\",\n ].join(\"\"));\n default:\n throw new RangeError([\n `Cannot assign ${type} value at ${printPath(path)}. `,\n `All JSON primitive datatypes (object, array, string, number, boolean, null) `,\n `are supported in an Automerge document; ${type} values are not. `,\n ].join(\"\"));\n }\n}\n// When we assign a value to a property in a proxy we recursively walk through\n// the value we are assigning and copy it into the document. This is generally\n// desirable behaviour. However, a very common bug is to accidentally assign a\n// value which is already in the document to another key within the same\n// document, this often leads to surprising behaviour where users expected to\n// _move_ the object, but it is instead copied. To avoid this we check if the\n// value is from the same document and if it is we throw an error, this means\n// we require an explicit Object.assign call to copy the object, thus avoiding\n// the footgun\nfunction isSameDocument(val, context) {\n var _b, _c;\n // Date is technically an object, but immutable, so allowing people to assign\n // a date from one place in the document to another place in the document is\n // not likely to be a bug\n if (val instanceof Date) {\n return false;\n }\n // this depends on __wbg_ptr being the wasm pointer\n // a new version of wasm-bindgen will break this\n // but the tests should expose the break\n if (val && ((_c = (_b = val[STATE]) === null || _b === void 0 ? void 0 : _b.handle) === null || _c === void 0 ? void 0 : _c.__wbg_ptr) === context.__wbg_ptr) {\n return true;\n }\n return false;\n}\nconst MapHandler = {\n get(target, key) {\n const { context, objectId, cache } = target;\n if (key === Symbol.toStringTag) {\n return target[Symbol.toStringTag];\n }\n if (key === OBJECT_ID)\n return objectId;\n if (key === IS_PROXY)\n return true;\n if (key === TRACE)\n return target.trace;\n if (key === STATE)\n return { handle: context };\n if (!cache[key]) {\n cache[key] = valueAt(target, key);\n }\n return cache[key];\n },\n set(target, key, val) {\n const { context, objectId, path } = target;\n target.cache = {}; // reset cache on set\n if (isSameDocument(val, context)) {\n throw new RangeError(\"Cannot create a reference to an existing document object\");\n }\n if (key === TRACE) {\n target.trace = val;\n return true;\n }\n if (key === CLEAR_CACHE) {\n return true;\n }\n const [value, datatype] = import_value(val, [...path, key], context);\n switch (datatype) {\n case \"list\":\n case \"map\": {\n validateForBatchInsert(value, context, [...path, key]);\n context.putObjectFromHydrate(objectId, key, value);\n break;\n }\n case \"text\": {\n context.putObject(objectId, key, value);\n break;\n }\n default:\n context.put(objectId, key, value, datatype);\n }\n return true;\n },\n deleteProperty(target, key) {\n const { context, objectId } = target;\n target.cache = {}; // reset cache on delete\n context.delete(objectId, key);\n return true;\n },\n has(target, key) {\n const value = this.get(target, key);\n return value !== undefined;\n },\n getOwnPropertyDescriptor(target, key) {\n // const { context, objectId } = target\n const value = this.get(target, key);\n if (typeof value !== \"undefined\") {\n return {\n configurable: true,\n enumerable: true,\n value,\n };\n }\n },\n ownKeys(target) {\n const { context, objectId } = target;\n // FIXME - this is a tmp workaround until fix the dupe key bug in keys()\n const keys = context.keys(objectId);\n return [...new Set(keys)];\n },\n};\nconst ListHandler = {\n get(target, index) {\n const { context, objectId } = target;\n index = parseListIndex(index);\n if (index === Symbol.hasInstance) {\n return (instance) => {\n return Array.isArray(instance);\n };\n }\n if (index === Symbol.toStringTag) {\n return target[Symbol.toStringTag];\n }\n if (index === OBJECT_ID)\n return objectId;\n if (index === IS_PROXY)\n return true;\n if (index === TRACE)\n return target.trace;\n if (index === STATE)\n return { handle: context };\n if (index === \"length\")\n return context.length(objectId);\n if (typeof index === \"number\") {\n return valueAt(target, index);\n }\n else {\n return listMethods(target)[index];\n }\n },\n set(target, index, val) {\n const { context, objectId, path } = target;\n index = parseListIndex(index);\n if (isSameDocument(val, context)) {\n throw new RangeError(\"Cannot create a reference to an existing document object\");\n }\n if (index === CLEAR_CACHE) {\n return true;\n }\n if (index === TRACE) {\n target.trace = val;\n return true;\n }\n if (typeof index == \"string\") {\n throw new RangeError(\"list index must be a number\");\n }\n const [value, datatype] = import_value(val, [...path, index], context);\n switch (datatype) {\n case \"list\":\n case \"map\": {\n validateForBatchInsert(value, context, [...path, index]);\n if (index >= context.length(objectId)) {\n context.insertObjectFromHydrate(objectId, index, value);\n }\n else {\n context.putObjectFromHydrate(objectId, index, value);\n }\n break;\n }\n case \"text\": {\n if (index >= context.length(objectId)) {\n context.insertObject(objectId, index, value);\n }\n else {\n context.putObject(objectId, index, value);\n }\n break;\n }\n default:\n if (index >= context.length(objectId)) {\n context.insert(objectId, index, value, datatype);\n }\n else {\n context.put(objectId, index, value, datatype);\n }\n }\n return true;\n },\n deleteProperty(target, index) {\n const { context, objectId } = target;\n index = parseListIndex(index);\n const elem = context.get(objectId, index);\n if (elem != null && elem[0] == \"counter\") {\n throw new TypeError(\"Unsupported operation: deleting a counter from a list\");\n }\n context.delete(objectId, index);\n return true;\n },\n has(target, index) {\n const { context, objectId } = target;\n index = parseListIndex(index);\n if (typeof index === \"number\") {\n return index < context.length(objectId);\n }\n return index === \"length\";\n },\n getOwnPropertyDescriptor(target, index) {\n const { context, objectId } = target;\n if (index === \"length\")\n return { writable: true, value: context.length(objectId) };\n if (index === OBJECT_ID)\n return { configurable: false, enumerable: false, value: objectId };\n index = parseListIndex(index);\n const value = valueAt(target, index);\n return { configurable: true, enumerable: true, value };\n },\n getPrototypeOf(target) {\n return Object.getPrototypeOf(target);\n },\n ownKeys( /*target*/) {\n const keys = [];\n // uncommenting this causes assert.deepEqual() to fail when comparing to a pojo array\n // but not uncommenting it causes for (i in list) {} to not enumerate values properly\n //const {context, objectId } = target\n //for (let i = 0; i < target.context.length(objectId); i++) { keys.push(i.toString()) }\n keys.push(\"length\");\n return keys;\n },\n};\nexport function mapProxy(context, objectId, path) {\n const target = {\n context,\n objectId,\n path: path || [],\n cache: {},\n };\n const proxied = {};\n Object.assign(proxied, target);\n const result = new Proxy(proxied, MapHandler);\n // conversion through unknown is necessary because the types are so different\n return result;\n}\nexport function listProxy(context, objectId, path) {\n const target = {\n context,\n objectId,\n path: path || [],\n cache: {},\n };\n const proxied = [];\n Object.assign(proxied, target);\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return new Proxy(proxied, ListHandler);\n}\nexport function rootProxy(context) {\n /* eslint-disable-next-line */\n return mapProxy(context, \"_root\", []);\n}\nfunction listMethods(target) {\n const { context, objectId, path } = target;\n const methods = {\n at(index) {\n return valueAt(target, index);\n },\n deleteAt(index, numDelete) {\n if (typeof numDelete === \"number\") {\n context.splice(objectId, index, numDelete);\n }\n else {\n context.delete(objectId, index);\n }\n return this;\n },\n fill(val, start, end) {\n const [value, datatype] = import_value(val, [...path, start], context);\n const length = context.length(objectId);\n start = parseListIndex(start || 0);\n end = parseListIndex(end || length);\n for (let i = start; i < Math.min(end, length); i++) {\n if (datatype === \"list\" || datatype === \"map\") {\n context.putObject(objectId, i, value);\n }\n else if (datatype === \"text\") {\n context.putObject(objectId, i, value);\n }\n else {\n context.put(objectId, i, value, datatype);\n }\n }\n return this;\n },\n indexOf(searchElement, start = 0) {\n const length = context.length(objectId);\n for (let i = start; i < length; i++) {\n const valueWithType = context.getWithType(objectId, i);\n if (!valueWithType) {\n continue;\n }\n const [valType, value] = valueWithType;\n // Either the target element is an object, and we return if we have found\n // the same object or it is a primitive value and we return if it matches\n // the current value\n const isObject = [\"map\", \"list\", \"text\"].includes(valType);\n if (!isObject) {\n // If the element is not an object, then check if the value is equal to the target\n if (value === searchElement) {\n return i;\n }\n else {\n continue;\n }\n }\n // if it's an object, but the type of the search element is a string, then we\n // need to check if the object is a text object with the same value as the search element\n if (valType === \"text\" && typeof searchElement === \"string\") {\n if (searchElement === valueAt(target, i)) {\n return i;\n }\n }\n // The only possible match now is if the searchElement is an object already in the\n // automerge document with the same object ID as the value\n if (searchElement[OBJECT_ID] === value) {\n return i;\n }\n }\n return -1;\n },\n insertAt(index, ...values) {\n this.splice(index, 0, ...values);\n return this;\n },\n pop() {\n const length = context.length(objectId);\n if (length == 0) {\n return undefined;\n }\n const last = valueAt(target, length - 1);\n context.delete(objectId, length - 1);\n return last;\n },\n push(...values) {\n const len = context.length(objectId);\n this.splice(len, 0, ...values);\n return context.length(objectId);\n },\n shift() {\n if (context.length(objectId) == 0)\n return;\n const first = valueAt(target, 0);\n context.delete(objectId, 0);\n return first;\n },\n splice(index, del, ...vals) {\n index = parseListIndex(index);\n // if del is undefined, delete until the end of the list\n if (typeof del !== \"number\") {\n del = context.length(objectId) - index;\n }\n del = parseListIndex(del);\n for (const val of vals) {\n if (isSameDocument(val, context)) {\n throw new RangeError(\"Cannot create a reference to an existing document object\");\n }\n }\n // Read values to be deleted (for return value) before mutating\n const result = [];\n for (let i = 0; i < del; i++) {\n const value = valueAt(target, index + i);\n if (value !== undefined) {\n result.push(value);\n }\n }\n // Validate all values before the WASM call\n for (let i = 0; i < vals.length; i++) {\n try {\n validateForBatchInsert(vals[i], context, [...path, index + i]);\n }\n catch (e) {\n if (e instanceof RangeError) {\n throw new RangeError(`${e.message} (at index ${i} in the input)`);\n }\n else {\n throw e;\n }\n }\n }\n // Single WASM call for both deletes and inserts\n context.spliceFromHydrate(objectId, index, del, vals);\n return result;\n },\n unshift(...values) {\n this.splice(0, 0, ...values);\n return context.length(objectId);\n },\n entries() {\n let i = 0;\n const iterator = {\n next: () => {\n const value = valueAt(target, i);\n if (value === undefined) {\n return { value: undefined, done: true };\n }\n else {\n return { value: [i++, value], done: false };\n }\n },\n [Symbol.iterator]() {\n return this;\n },\n };\n return iterator;\n },\n keys() {\n let i = 0;\n const len = context.length(objectId);\n const iterator = {\n next: () => {\n if (i < len) {\n return { value: i++, done: false };\n }\n return { value: undefined, done: true };\n },\n [Symbol.iterator]() {\n return this;\n },\n };\n return iterator;\n },\n values() {\n let i = 0;\n const iterator = {\n next: () => {\n const value = valueAt(target, i++);\n if (value === undefined) {\n return { value: undefined, done: true };\n }\n else {\n return { value, done: false };\n }\n },\n [Symbol.iterator]() {\n return this;\n },\n };\n return iterator;\n },\n toArray() {\n const list = [];\n let value;\n do {\n value = valueAt(target, list.length);\n if (value !== undefined) {\n list.push(value);\n }\n } while (value !== undefined);\n return list;\n },\n map(f) {\n return this.toArray().map(f);\n },\n toString() {\n return this.toArray().toString();\n },\n toLocaleString() {\n return this.toArray().toLocaleString();\n },\n forEach(f) {\n return this.toArray().forEach(f);\n },\n // todo: real concat function is different\n concat(other) {\n return this.toArray().concat(other);\n },\n every(f) {\n return this.toArray().every(f);\n },\n filter(f) {\n return this.toArray().filter(f);\n },\n find(f) {\n let index = 0;\n for (const v of this) {\n if (f(v, index)) {\n return v;\n }\n index += 1;\n }\n },\n findIndex(f) {\n let index = 0;\n for (const v of this) {\n if (f(v, index)) {\n return index;\n }\n index += 1;\n }\n return -1;\n },\n includes(elem) {\n return this.find(e => e === elem) !== undefined;\n },\n join(sep) {\n return this.toArray().join(sep);\n },\n reduce(f, initialValue) {\n return this.toArray().reduce(f, initialValue);\n },\n reduceRight(f, initialValue) {\n return this.toArray().reduceRight(f, initialValue);\n },\n lastIndexOf(search, fromIndex = +Infinity) {\n // this can be faster\n return this.toArray().lastIndexOf(search, fromIndex);\n },\n slice(index, num) {\n return this.toArray().slice(index, num);\n },\n some(f) {\n let index = 0;\n for (const v of this) {\n if (f(v, index)) {\n return true;\n }\n index += 1;\n }\n return false;\n },\n [Symbol.iterator]: function* () {\n let i = 0;\n let value = valueAt(target, i);\n while (value !== undefined) {\n yield value;\n i += 1;\n value = valueAt(target, i);\n }\n },\n };\n return methods;\n}\nfunction textMethods(target) {\n const { context, objectId } = target;\n const methods = {\n set(index, value) {\n return (this[index] = value);\n },\n get(index) {\n return this[index];\n },\n toString() {\n return context.text(objectId).replace(//g, \"\");\n },\n toSpans() {\n const spans = [];\n let chars = \"\";\n const length = context.length(objectId);\n for (let i = 0; i < length; i++) {\n const value = this[i];\n if (typeof value === \"string\") {\n chars += value;\n }\n else {\n if (chars.length > 0) {\n spans.push(chars);\n chars = \"\";\n }\n spans.push(value);\n }\n }\n if (chars.length > 0) {\n spans.push(chars);\n }\n return spans;\n },\n toJSON() {\n return this.toString();\n },\n indexOf(o, start = 0) {\n const text = context.text(objectId);\n return text.indexOf(o, start);\n },\n insertAt(index, ...values) {\n if (values.every(v => typeof v === \"string\")) {\n context.splice(objectId, index, 0, values.join(\"\"));\n }\n else {\n listMethods(target).insertAt(index, ...values);\n }\n },\n };\n return methods;\n}\nfunction printPath(path) {\n // print the path as a json pointer\n const jsonPointerComponents = path.map(component => {\n // if its a number just turn it into a string\n if (typeof component === \"number\") {\n return component.toString();\n }\n else if (typeof component === \"string\") {\n // otherwise we have to escape `/` and `~` characters\n return component.replace(/~/g, \"~0\").replace(/\\//g, \"~1\");\n }\n });\n if (path.length === 0) {\n return \"\";\n }\n else {\n return \"/\" + jsonPointerComponents.join(\"/\");\n }\n}\n/*\n * Check if an object is a {@link ImmutableString}\n */\nexport function isImmutableString(obj) {\n // We used to determine whether something was a ImmutableString by doing an instanceof check, but\n // this doesn't work if the automerge module is loaded twice somehow. Instead, use the presence\n // of a symbol to determine if something is a ImmutableString\n return (typeof obj === \"object\" &&\n obj !== null &&\n Object.prototype.hasOwnProperty.call(obj, IMMUTABLE_STRING));\n}\nexport function isCounter(obj) {\n // We used to determine whether something was a Counter by doing an instanceof check, but\n // this doesn't work if the automerge module is loaded twice somehow. Instead, use the presence\n // of a symbol to determine if something is a Counter\n return (typeof obj === \"object\" &&\n obj !== null &&\n Object.prototype.hasOwnProperty.call(obj, COUNTER));\n}\n", "/* @ts-self-types=\"./automerge_wasm.d.ts\" */\n\nexport class Automerge {\n static __wrap(ptr) {\n const obj = Object.create(Automerge.prototype);\n obj.__wbg_ptr = ptr;\n AutomergeFinalization.register(obj, obj.__wbg_ptr, obj);\n return obj;\n }\n __destroy_into_raw() {\n const ptr = this.__wbg_ptr;\n this.__wbg_ptr = 0;\n AutomergeFinalization.unregister(this);\n return ptr;\n }\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_automerge_free(ptr, 0);\n }\n /**\n * @param {Commit[]} commits\n */\n addCommits(commits) {\n const ret = wasm.automerge_addCommits(this.__wbg_ptr, commits);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @param {Fragment[]} fragments\n */\n addFragments(fragments) {\n const ret = wasm.automerge_addFragments(this.__wbg_ptr, fragments);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @param {any} object\n * @param {any} meta\n * @returns {any}\n */\n applyAndReturnPatches(object, meta) {\n const ret = wasm.automerge_applyAndReturnPatches(this.__wbg_ptr, object, meta);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {Change[]} changes\n */\n applyChanges(changes) {\n const ret = wasm.automerge_applyChanges(this.__wbg_ptr, changes);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @param {any} object\n * @param {any} meta\n * @returns {any}\n */\n applyPatches(object, meta) {\n const ret = wasm.automerge_applyPatches(this.__wbg_ptr, object, meta);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {FragmentMeta[]} fragments\n * @returns {Uint8Array[]}\n */\n bundleFragmentMetadata(fragments) {\n const ret = wasm.automerge_bundleFragmentMetadata(this.__wbg_ptr, fragments);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {string | null} [actor]\n * @returns {Automerge}\n */\n clone(actor) {\n var ptr0 = isLikeNone(actor) ? 0 : passStringToWasm0(actor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n const ret = wasm.automerge_clone(this.__wbg_ptr, ptr0, len0);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return Automerge.__wrap(ret[0]);\n }\n /**\n * @param {string | null} [message]\n * @param {number | null} [time]\n * @returns {Hash | null}\n */\n commit(message, time) {\n var ptr0 = isLikeNone(message) ? 0 : passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n const ret = wasm.automerge_commit(this.__wbg_ptr, ptr0, len0, !isLikeNone(time), isLikeNone(time) ? 0 : time);\n return ret;\n }\n /**\n * @param {ObjID} obj\n * @param {Prop} prop\n */\n delete(obj, prop) {\n const ret = wasm.automerge_delete(this.__wbg_ptr, obj, prop);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @param {Heads} before\n * @param {Heads} after\n * @returns {Patch[]}\n */\n diff(before, after) {\n const ret = wasm.automerge_diff(this.__wbg_ptr, before, after);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @returns {Patch[]}\n */\n diffIncremental() {\n const ret = wasm.automerge_diffIncremental(this.__wbg_ptr);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {Prop[] | string} path\n * @param {Heads} before\n * @param {Heads} after\n * @param {any} options\n * @returns {Array<any>}\n */\n diffPath(path, before, after, options) {\n const ret = wasm.automerge_diffPath(this.__wbg_ptr, path, before, after, options);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n dump() {\n wasm.automerge_dump(this.__wbg_ptr);\n }\n /**\n * @param {string | null} [message]\n * @param {number | null} [time]\n * @returns {Hash}\n */\n emptyChange(message, time) {\n var ptr0 = isLikeNone(message) ? 0 : passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n const ret = wasm.automerge_emptyChange(this.__wbg_ptr, ptr0, len0, !isLikeNone(time), isLikeNone(time) ? 0 : time);\n return ret;\n }\n /**\n * @param {boolean} enable\n * @returns {boolean}\n */\n enableFreeze(enable) {\n const ret = wasm.automerge_enableFreeze(this.__wbg_ptr, enable);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return ret[0] !== 0;\n }\n /**\n * @param {string | null | undefined} actor\n * @param {any} heads\n * @returns {Automerge}\n */\n fork(actor, heads) {\n var ptr0 = isLikeNone(actor) ? 0 : passStringToWasm0(actor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n const ret = wasm.automerge_fork(this.__wbg_ptr, ptr0, len0, heads);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return Automerge.__wrap(ret[0]);\n }\n /**\n * @param {SyncState} state\n * @returns {SyncMessage | null}\n */\n generateSyncMessage(state) {\n _assertClass(state, SyncState);\n const ret = wasm.automerge_generateSyncMessage(this.__wbg_ptr, state.__wbg_ptr);\n return ret;\n }\n /**\n * @param {any} obj\n * @param {any} prop\n * @param {any} heads\n * @returns {any}\n */\n get(obj, prop, heads) {\n const ret = wasm.automerge_get(this.__wbg_ptr, obj, prop, heads);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @returns {Actor}\n */\n getActorId() {\n let deferred1_0;\n let deferred1_1;\n try {\n const ret = wasm.automerge_getActorId(this.__wbg_ptr);\n deferred1_0 = ret[0];\n deferred1_1 = ret[1];\n return getStringFromWasm0(ret[0], ret[1]);\n } finally {\n wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);\n }\n }\n /**\n * @param {any} obj\n * @param {any} arg\n * @param {any} heads\n * @returns {Array<any>}\n */\n getAll(obj, arg, heads) {\n const ret = wasm.automerge_getAll(this.__wbg_ptr, obj, arg, heads);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {any} text\n * @param {number} index\n * @param {any} heads\n * @returns {any}\n */\n getBlock(text, index, heads) {\n const ret = wasm.automerge_getBlock(this.__wbg_ptr, text, index, heads);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {Hash} hash\n * @returns {Change | null}\n */\n getChangeByHash(hash) {\n const ret = wasm.automerge_getChangeByHash(this.__wbg_ptr, hash);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {Hash} hash\n * @returns {ChangeMetadata | null}\n */\n getChangeMetaByHash(hash) {\n const ret = wasm.automerge_getChangeMetaByHash(this.__wbg_ptr, hash);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {Heads} have_deps\n * @returns {Change[]}\n */\n getChanges(have_deps) {\n const ret = wasm.automerge_getChanges(this.__wbg_ptr, have_deps);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {Automerge} other\n * @returns {Change[]}\n */\n getChangesAdded(other) {\n _assertClass(other, Automerge);\n const ret = wasm.automerge_getChangesAdded(this.__wbg_ptr, other.__wbg_ptr);\n return ret;\n }\n /**\n * @param {Heads} have_deps\n * @returns {ChangeMetadata[]}\n */\n getChangesMeta(have_deps) {\n const ret = wasm.automerge_getChangesMeta(this.__wbg_ptr, have_deps);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {any} obj\n * @param {any} position\n * @param {any} heads\n * @param {any} move_cursor\n * @returns {string}\n */\n getCursor(obj, position, heads, move_cursor) {\n let deferred2_0;\n let deferred2_1;\n try {\n const ret = wasm.automerge_getCursor(this.__wbg_ptr, obj, position, heads, move_cursor);\n var ptr1 = ret[0];\n var len1 = ret[1];\n if (ret[3]) {\n ptr1 = 0; len1 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred2_0 = ptr1;\n deferred2_1 = len1;\n return getStringFromWasm0(ptr1, len1);\n } finally {\n wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);\n }\n }\n /**\n * @param {any} obj\n * @param {any} cursor\n * @param {any} heads\n * @returns {number}\n */\n getCursorPosition(obj, cursor, heads) {\n const ret = wasm.automerge_getCursorPosition(this.__wbg_ptr, obj, cursor, heads);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return ret[0];\n }\n /**\n * @param {Hash} hash\n * @returns {DecodedChange | null}\n */\n getDecodedChangeByHash(hash) {\n const ret = wasm.automerge_getDecodedChangeByHash(this.__wbg_ptr, hash);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {Hash} head\n * @returns {FragmentMeta | null}\n */\n getFragmentMeta(head) {\n const ret = wasm.automerge_getFragmentMeta(this.__wbg_ptr, head);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {FragmentLevelRange} levels\n * @returns {FragmentMeta[]}\n */\n getFragmentMetadata(levels) {\n const ret = wasm.automerge_getFragmentMetadata(this.__wbg_ptr, levels);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @returns {Heads}\n */\n getHeads() {\n const ret = wasm.automerge_getHeads(this.__wbg_ptr);\n return ret;\n }\n /**\n * @returns {Change | null}\n */\n getLastLocalChange() {\n const ret = wasm.automerge_getLastLocalChange(this.__wbg_ptr);\n return ret;\n }\n /**\n * @param {any} heads\n * @returns {Array<any>}\n */\n getMissingDeps(heads) {\n const ret = wasm.automerge_getMissingDeps(this.__wbg_ptr, heads);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {any} obj\n * @param {any} prop\n * @param {any} heads\n * @returns {any}\n */\n getWithType(obj, prop, heads) {\n const ret = wasm.automerge_getWithType(this.__wbg_ptr, obj, prop, heads);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {SyncState} state\n * @returns {boolean}\n */\n hasOurChanges(state) {\n _assertClass(state, SyncState);\n const ret = wasm.automerge_hasOurChanges(this.__wbg_ptr, state.__wbg_ptr);\n return ret !== 0;\n }\n /**\n * @param {ObjID} obj\n * @param {Prop} prop\n * @param {number} value\n */\n increment(obj, prop, value) {\n const ret = wasm.automerge_increment(this.__wbg_ptr, obj, prop, value);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * Initialize the root object of an empty document from a JS object.\n * This is much faster than setting keys one at a time for large initial states.\n * @param {any} value\n */\n initRootFromHydrate(value) {\n const ret = wasm.automerge_initRootFromHydrate(this.__wbg_ptr, value);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @param {any} obj\n * @param {number} index\n * @param {any} value\n * @param {any} datatype\n */\n insert(obj, index, value, datatype) {\n const ret = wasm.automerge_insert(this.__wbg_ptr, obj, index, value, datatype);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @param {ObjID} obj\n * @param {number} index\n * @param {ObjType} value\n * @returns {ObjID}\n */\n insertObject(obj, index, value) {\n let deferred2_0;\n let deferred2_1;\n try {\n const ret = wasm.automerge_insertObject(this.__wbg_ptr, obj, index, value);\n var ptr1 = ret[0];\n var len1 = ret[1];\n if (ret[3]) {\n ptr1 = 0; len1 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred2_0 = ptr1;\n deferred2_1 = len1;\n return getStringFromWasm0(ptr1, len1);\n } finally {\n wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);\n }\n }\n /**\n * Insert a nested JavaScript value into a list using batch insertion.\n * This is much faster than insertObject for large nested objects.\n * The value is inserted at the given index, shifting subsequent elements.\n * @param {ObjID} obj\n * @param {number} index\n * @param {any} value\n * @returns {ObjID}\n */\n insertObjectFromHydrate(obj, index, value) {\n const ret = wasm.automerge_insertObjectFromHydrate(this.__wbg_ptr, obj, index, value);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n integrate() {\n wasm.automerge_integrate(this.__wbg_ptr);\n }\n /**\n * @param {Heads} heads\n */\n isolate(heads) {\n const ret = wasm.automerge_isolate(this.__wbg_ptr, heads);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @param {ObjID} obj\n * @param {number} index\n */\n joinBlock(obj, index) {\n const ret = wasm.automerge_joinBlock(this.__wbg_ptr, obj, index);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @param {any} obj\n * @param {any} heads\n * @returns {Array<any>}\n */\n keys(obj, heads) {\n const ret = wasm.automerge_keys(this.__wbg_ptr, obj, heads);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {any} obj\n * @param {any} heads\n * @returns {number}\n */\n length(obj, heads) {\n const ret = wasm.automerge_length(this.__wbg_ptr, obj, heads);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return ret[0];\n }\n /**\n * @param {Uint8Array} data\n * @returns {number}\n */\n loadIncremental(data) {\n const ret = wasm.automerge_loadIncremental(this.__wbg_ptr, data);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return ret[0];\n }\n /**\n * @param {any} obj\n * @param {any} range\n * @param {any} name\n * @param {any} value\n * @param {any} datatype\n */\n mark(obj, range, name, value, datatype) {\n const ret = wasm.automerge_mark(this.__wbg_ptr, obj, range, name, value, datatype);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @param {any} obj\n * @param {any} heads\n * @returns {any}\n */\n marks(obj, heads) {\n const ret = wasm.automerge_marks(this.__wbg_ptr, obj, heads);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {any} obj\n * @param {number} index\n * @param {any} heads\n * @returns {object}\n */\n marksAt(obj, index, heads) {\n const ret = wasm.automerge_marksAt(this.__wbg_ptr, obj, index, heads);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {any} obj\n * @param {any} heads\n * @param {any} meta\n * @returns {any}\n */\n materialize(obj, heads, meta) {\n const ret = wasm.automerge_materialize(this.__wbg_ptr, obj, heads, meta);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {Automerge} other\n * @returns {Heads}\n */\n merge(other) {\n _assertClass(other, Automerge);\n const ret = wasm.automerge_merge(this.__wbg_ptr, other.__wbg_ptr);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {string | null} [actor]\n * @returns {Automerge}\n */\n static new(actor) {\n var ptr0 = isLikeNone(actor) ? 0 : passStringToWasm0(actor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len0 = WASM_VECTOR_LEN;\n const ret = wasm.automerge_new(ptr0, len0);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return Automerge.__wrap(ret[0]);\n }\n /**\n * @param {any} obj\n * @param {any} heads\n * @returns {object}\n */\n objInfo(obj, heads) {\n const ret = wasm.automerge_objInfo(this.__wbg_ptr, obj, heads);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @returns {number}\n */\n pendingOps() {\n const ret = wasm.automerge_pendingOps(this.__wbg_ptr);\n return ret;\n }\n /**\n * @param {any} obj\n * @param {any} value\n * @param {any} datatype\n */\n push(obj, value, datatype) {\n const ret = wasm.automerge_push(this.__wbg_ptr, obj, value, datatype);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @param {ObjID} obj\n * @param {ObjType} value\n * @returns {ObjID}\n */\n pushObject(obj, value) {\n let deferred2_0;\n let deferred2_1;\n try {\n const ret = wasm.automerge_pushObject(this.__wbg_ptr, obj, value);\n var ptr1 = ret[0];\n var len1 = ret[1];\n if (ret[3]) {\n ptr1 = 0; len1 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred2_0 = ptr1;\n deferred2_1 = len1;\n return getStringFromWasm0(ptr1, len1);\n } finally {\n wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);\n }\n }\n /**\n * @param {any} obj\n * @param {any} prop\n * @param {any} value\n * @param {any} datatype\n */\n put(obj, prop, value, datatype) {\n const ret = wasm.automerge_put(this.__wbg_ptr, obj, prop, value, datatype);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @param {ObjID} obj\n * @param {Prop} prop\n * @param {ObjType} value\n * @returns {ObjID}\n */\n putObject(obj, prop, value) {\n const ret = wasm.automerge_putObject(this.__wbg_ptr, obj, prop, value);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * Put a nested JavaScript value as a new object tree using batch insertion.\n * This is much faster than putObject for large nested objects.\n * For map keys this overwrites any existing value. For list indices this\n * overwrites the element at that index.\n * @param {ObjID} obj\n * @param {Prop} prop\n * @param {any} value\n * @returns {ObjID}\n */\n putObjectFromHydrate(obj, prop, value) {\n const ret = wasm.automerge_putObjectFromHydrate(this.__wbg_ptr, obj, prop, value);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {SyncState} state\n * @param {SyncMessage} message\n */\n receiveSyncMessage(state, message) {\n _assertClass(state, SyncState);\n const ret = wasm.automerge_receiveSyncMessage(this.__wbg_ptr, state.__wbg_ptr, message);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @param {string} datatype\n * @param {Function} construct\n * @param {(arg: any) => any | undefined} deconstruct\n */\n registerDatatype(datatype, construct, deconstruct) {\n const ret = wasm.automerge_registerDatatype(this.__wbg_ptr, datatype, construct, deconstruct);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n resetDiffCursor() {\n wasm.automerge_resetDiffCursor(this.__wbg_ptr);\n }\n /**\n * @returns {number}\n */\n rollback() {\n const ret = wasm.automerge_rollback(this.__wbg_ptr);\n return ret;\n }\n /**\n * @returns {Uint8Array}\n */\n save() {\n const ret = wasm.automerge_save(this.__wbg_ptr);\n return ret;\n }\n /**\n * @returns {Uint8Array}\n */\n saveAndVerify() {\n const ret = wasm.automerge_saveAndVerify(this.__wbg_ptr);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {any} hashes\n * @returns {Uint8Array}\n */\n saveBundle(hashes) {\n const ret = wasm.automerge_saveBundle(this.__wbg_ptr, hashes);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @returns {Uint8Array}\n */\n saveIncremental() {\n const ret = wasm.automerge_saveIncremental(this.__wbg_ptr);\n return ret;\n }\n /**\n * @returns {Uint8Array}\n */\n saveNoCompress() {\n const ret = wasm.automerge_saveNoCompress(this.__wbg_ptr);\n return ret;\n }\n /**\n * @param {Heads} heads\n * @returns {Uint8Array}\n */\n saveSince(heads) {\n const ret = wasm.automerge_saveSince(this.__wbg_ptr, heads);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {any} obj\n * @param {any} heads\n * @returns {Array<any>}\n */\n spans(obj, heads) {\n const ret = wasm.automerge_spans(this.__wbg_ptr, obj, heads);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @param {any} obj\n * @param {number} start\n * @param {number} delete_count\n * @param {any} text\n */\n splice(obj, start, delete_count, text) {\n const ret = wasm.automerge_splice(this.__wbg_ptr, obj, start, delete_count, text);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * Splice values into a list using batch insertion.\n * This is much faster than individual insert calls for multiple values.\n * @param {ObjID} obj\n * @param {number} index\n * @param {number} del\n * @param {any} values\n */\n spliceFromHydrate(obj, index, del, values) {\n const ret = wasm.automerge_spliceFromHydrate(this.__wbg_ptr, obj, index, del, values);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @param {ObjID} obj\n * @param {number} index\n * @param {{[key: string]: MaterializeValue}} block\n */\n splitBlock(obj, index, block) {\n const ret = wasm.automerge_splitBlock(this.__wbg_ptr, obj, index, block);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @returns {Stats}\n */\n stats() {\n const ret = wasm.automerge_stats(this.__wbg_ptr);\n return ret;\n }\n /**\n * @param {any} obj\n * @param {any} heads\n * @returns {string}\n */\n text(obj, heads) {\n let deferred2_0;\n let deferred2_1;\n try {\n const ret = wasm.automerge_text(this.__wbg_ptr, obj, heads);\n var ptr1 = ret[0];\n var len1 = ret[1];\n if (ret[3]) {\n ptr1 = 0; len1 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred2_0 = ptr1;\n deferred2_1 = len1;\n return getStringFromWasm0(ptr1, len1);\n } finally {\n wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);\n }\n }\n /**\n * @param {any} meta\n * @returns {MaterializeValue}\n */\n toJS(meta) {\n const ret = wasm.automerge_toJS(this.__wbg_ptr, meta);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n }\n /**\n * @returns {Hash[]}\n */\n topoHistoryTraversal() {\n const ret = wasm.automerge_topoHistoryTraversal(this.__wbg_ptr);\n return ret;\n }\n /**\n * @param {ObjID} obj\n * @param {MarkRange} range\n * @param {string} name\n */\n unmark(obj, range, name) {\n const ret = wasm.automerge_unmark(this.__wbg_ptr, obj, range, name);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @param {ObjID} obj\n * @param {number} index\n * @param {{[key: string]: MaterializeValue}} block\n */\n updateBlock(obj, index, block) {\n const ret = wasm.automerge_updateBlock(this.__wbg_ptr, obj, index, block);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n updateDiffCursor() {\n wasm.automerge_updateDiffCursor(this.__wbg_ptr);\n }\n /**\n * @param {ObjID} obj\n * @param {Span[]} args\n * @param {UpdateSpansConfig | undefined | null} config\n */\n updateSpans(obj, args, config) {\n const ret = wasm.automerge_updateSpans(this.__wbg_ptr, obj, args, config);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @param {ObjID} obj\n * @param {string} new_text\n */\n updateText(obj, new_text) {\n const ret = wasm.automerge_updateText(this.__wbg_ptr, obj, new_text);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n}\nif (Symbol.dispose) Automerge.prototype[Symbol.dispose] = Automerge.prototype.free;\n\nexport class SyncState {\n static __wrap(ptr) {\n const obj = Object.create(SyncState.prototype);\n obj.__wbg_ptr = ptr;\n SyncStateFinalization.register(obj, obj.__wbg_ptr, obj);\n return obj;\n }\n __destroy_into_raw() {\n const ptr = this.__wbg_ptr;\n this.__wbg_ptr = 0;\n SyncStateFinalization.unregister(this);\n return ptr;\n }\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_syncstate_free(ptr, 0);\n }\n /**\n * @returns {SyncState}\n */\n clone() {\n const ret = wasm.syncstate_clone(this.__wbg_ptr);\n return SyncState.__wrap(ret);\n }\n /**\n * @returns {Heads}\n */\n get lastSentHeads() {\n const ret = wasm.syncstate_lastSentHeads(this.__wbg_ptr);\n return ret;\n }\n /**\n * @returns {boolean}\n */\n get peerReadOnly() {\n const ret = wasm.syncstate_peerReadOnly(this.__wbg_ptr);\n return ret !== 0;\n }\n /**\n * @returns {boolean}\n */\n get readOnly() {\n const ret = wasm.syncstate_readOnly(this.__wbg_ptr);\n return ret !== 0;\n }\n /**\n * @param {Heads} heads\n */\n set lastSentHeads(heads) {\n const ret = wasm.syncstate_set_lastSentHeads(this.__wbg_ptr, heads);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @param {boolean} read_only\n */\n set readOnly(read_only) {\n wasm.syncstate_set_readOnly(this.__wbg_ptr, read_only);\n }\n /**\n * @param {Heads} hashes\n */\n set sentHashes(hashes) {\n const ret = wasm.syncstate_set_sentHashes(this.__wbg_ptr, hashes);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n }\n /**\n * @returns {Heads}\n */\n get sharedHeads() {\n const ret = wasm.syncstate_sharedHeads(this.__wbg_ptr);\n return ret;\n }\n}\nif (Symbol.dispose) SyncState.prototype[Symbol.dispose] = SyncState.prototype.free;\n\n/**\n * @param {any} options\n * @returns {Automerge}\n */\nexport function create(options) {\n const ret = wasm.create(options);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return Automerge.__wrap(ret[0]);\n}\n\n/**\n * @param {Uint8Array} change\n * @returns {DecodedChange}\n */\nexport function decodeChange(change) {\n const ret = wasm.decodeChange(change);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n}\n\n/**\n * @param {Uint8Array} msg\n * @returns {DecodedSyncMessage}\n */\nexport function decodeSyncMessage(msg) {\n const ret = wasm.decodeSyncMessage(msg);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n}\n\n/**\n * @param {Uint8Array} data\n * @returns {SyncState}\n */\nexport function decodeSyncState(data) {\n const ret = wasm.decodeSyncState(data);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return SyncState.__wrap(ret[0]);\n}\n\n/**\n * @param {any} change\n * @returns {Uint8Array}\n */\nexport function encodeChange(change) {\n const ret = wasm.encodeChange(change);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n}\n\n/**\n * @param {any} message\n * @returns {SyncMessage}\n */\nexport function encodeSyncMessage(message) {\n const ret = wasm.encodeSyncMessage(message);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n}\n\n/**\n * @param {SyncState} state\n * @returns {Uint8Array}\n */\nexport function encodeSyncState(state) {\n _assertClass(state, SyncState);\n const ret = wasm.encodeSyncState(state.__wbg_ptr);\n return ret;\n}\n\n/**\n * @param {SyncState} state\n * @returns {JsSyncState}\n */\nexport function exportSyncState(state) {\n _assertClass(state, SyncState);\n const ret = wasm.exportSyncState(state.__wbg_ptr);\n return ret;\n}\n\n/**\n * @param {any} state\n * @returns {SyncState}\n */\nexport function importSyncState(state) {\n const ret = wasm.importSyncState(state);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return SyncState.__wrap(ret[0]);\n}\n\n/**\n * @returns {SyncState}\n */\nexport function initSyncState() {\n const ret = wasm.initSyncState();\n return SyncState.__wrap(ret);\n}\n\n/**\n * @param {Uint8Array} data\n * @param {any} options\n * @returns {Automerge}\n */\nexport function load(data, options) {\n const ret = wasm.load(data, options);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return Automerge.__wrap(ret[0]);\n}\n\n/**\n * @param {Uint8Array} bundle\n * @returns {any}\n */\nexport function readBundle(bundle) {\n const ret = wasm.readBundle(bundle);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n}\n\n/**\n * @returns {WasmReleaseInfo}\n */\nexport function wasmReleaseInfo() {\n const ret = wasm.wasmReleaseInfo();\n return ret;\n}\nfunction __wbg_get_imports() {\n const import0 = {\n __proto__: null,\n __wbg_BigInt_783e2a7f4ba76bc4: function(arg0) {\n const ret = BigInt(arg0);\n return ret;\n },\n __wbg_Error_bce6d499ff0a4aff: function(arg0, arg1) {\n const ret = Error(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbg_String_8564e559799eccda: function(arg0, arg1) {\n const ret = String(arg1);\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg___wbindgen_boolean_get_2304fb8c853028c8: function(arg0) {\n const v = arg0;\n const ret = typeof(v) === 'boolean' ? v : undefined;\n return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;\n },\n __wbg___wbindgen_debug_string_edece8177ad01481: function(arg0, arg1) {\n const ret = debugString(arg1);\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg___wbindgen_gt_09497b4a65452cf9: function(arg0, arg1) {\n const ret = arg0 > arg1;\n return ret;\n },\n __wbg___wbindgen_is_bigint_aeae3893f30ed54e: function(arg0) {\n const ret = typeof(arg0) === 'bigint';\n return ret;\n },\n __wbg___wbindgen_is_function_5cd60d5cf78b4eef: function(arg0) {\n const ret = typeof(arg0) === 'function';\n return ret;\n },\n __wbg___wbindgen_is_null_2042690d351e14f0: function(arg0) {\n const ret = arg0 === null;\n return ret;\n },\n __wbg___wbindgen_is_object_b4593df85baada48: function(arg0) {\n const val = arg0;\n const ret = typeof(val) === 'object' && val !== null;\n return ret;\n },\n __wbg___wbindgen_is_string_dde0fd9020db4434: function(arg0) {\n const ret = typeof(arg0) === 'string';\n return ret;\n },\n __wbg___wbindgen_is_undefined_35bb9f4c7fd651d5: function(arg0) {\n const ret = arg0 === undefined;\n return ret;\n },\n __wbg___wbindgen_jsval_loose_eq_0ad77b7717db155c: function(arg0, arg1) {\n const ret = arg0 == arg1;\n return ret;\n },\n __wbg___wbindgen_lt_bf66da04b96dff63: function(arg0, arg1) {\n const ret = arg0 < arg1;\n return ret;\n },\n __wbg___wbindgen_neg_5c60abf0a760fcb3: function(arg0) {\n const ret = -arg0;\n return ret;\n },\n __wbg___wbindgen_number_get_f73a1244370fcc2c: function(arg0, arg1) {\n const obj = arg1;\n const ret = typeof(obj) === 'number' ? obj : undefined;\n getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);\n },\n __wbg___wbindgen_string_get_d109740c0d18f4d7: function(arg0, arg1) {\n const obj = arg1;\n const ret = typeof(obj) === 'string' ? obj : undefined;\n var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg___wbindgen_throw_9c31b086c2b26051: function(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n },\n __wbg_apply_345835e57390767e: function() { return handleError(function (arg0, arg1, arg2) {\n const ret = Reflect.apply(arg0, arg1, arg2);\n return ret;\n }, arguments); },\n __wbg_assign_6dc244143fa72f1f: function(arg0, arg1) {\n const ret = Object.assign(arg0, arg1);\n return ret;\n },\n __wbg_call_13665d9f14390edc: function() { return handleError(function (arg0, arg1) {\n const ret = arg0.call(arg1);\n return ret;\n }, arguments); },\n __wbg_call_dfde26266607c996: function() { return handleError(function (arg0, arg1, arg2) {\n const ret = arg0.call(arg1, arg2);\n return ret;\n }, arguments); },\n __wbg_concat_984be48c26a4a7d7: function(arg0, arg1) {\n const ret = arg0.concat(arg1);\n return ret;\n },\n __wbg_defineProperty_83586bc35b9ff065: function(arg0, arg1, arg2) {\n const ret = Object.defineProperty(arg0, arg1, arg2);\n return ret;\n },\n __wbg_deleteProperty_598e2c418b0266c8: function() { return handleError(function (arg0, arg1) {\n const ret = Reflect.deleteProperty(arg0, arg1);\n return ret;\n }, arguments); },\n __wbg_done_54b8da57023b7ed2: function(arg0) {\n const ret = arg0.done;\n return ret;\n },\n __wbg_entries_564a7e8b1e54ede5: function(arg0) {\n const ret = Object.entries(arg0);\n return ret;\n },\n __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {\n let deferred0_0;\n let deferred0_1;\n try {\n deferred0_0 = arg0;\n deferred0_1 = arg1;\n console.error(getStringFromWasm0(arg0, arg1));\n } finally {\n wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);\n }\n },\n __wbg_for_6670787dec82acd0: function(arg0, arg1) {\n const ret = Symbol.for(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbg_freeze_bb8e564173b3cad6: function(arg0) {\n const ret = Object.freeze(arg0);\n return ret;\n },\n __wbg_from_fa561fa561dc8031: function(arg0) {\n const ret = Array.from(arg0);\n return ret;\n },\n __wbg_getRandomValues_76dfc69825c9c552: function() { return handleError(function (arg0, arg1) {\n globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));\n }, arguments); },\n __wbg_getTime_09f1dd40a44edb30: function(arg0) {\n const ret = arg0.getTime();\n return ret;\n },\n __wbg_get_3e9a707ab7d352eb: function() { return handleError(function (arg0, arg1) {\n const ret = Reflect.get(arg0, arg1);\n return ret;\n }, arguments); },\n __wbg_get_98fdf51d029a75eb: function(arg0, arg1) {\n const ret = arg0[arg1 >>> 0];\n return ret;\n },\n __wbg_get_dcf82ab8aad1a593: function() { return handleError(function (arg0, arg1) {\n const ret = Reflect.get(arg0, arg1);\n return ret;\n }, arguments); },\n __wbg_get_unchecked_1dfe6d05ad91d9b7: function(arg0, arg1) {\n const ret = arg0[arg1 >>> 0];\n return ret;\n },\n __wbg_instanceof_ArrayBuffer_53db37b06f6b9afe: function(arg0) {\n let result;\n try {\n result = arg0 instanceof ArrayBuffer;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n },\n __wbg_instanceof_Date_699138a4c8668446: function(arg0) {\n let result;\n try {\n result = arg0 instanceof Date;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n },\n __wbg_instanceof_Object_03924e0dbda74bd8: function(arg0) {\n let result;\n try {\n result = arg0 instanceof Object;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n },\n __wbg_instanceof_Uint8Array_abd07d4bd221d50b: function(arg0) {\n let result;\n try {\n result = arg0 instanceof Uint8Array;\n } catch (_) {\n result = false;\n }\n const ret = result;\n return ret;\n },\n __wbg_isArray_74b636a53056fecb: function(arg0) {\n const ret = Array.isArray(arg0);\n return ret;\n },\n __wbg_isArray_94898ed3aad6947b: function(arg0) {\n const ret = Array.isArray(arg0);\n return ret;\n },\n __wbg_iterator_1441b47f341dc34f: function() {\n const ret = Symbol.iterator;\n return ret;\n },\n __wbg_keys_682010b680c9b1f8: function(arg0) {\n const ret = Object.keys(arg0);\n return ret;\n },\n __wbg_length_2591a0f4f659a55c: function(arg0) {\n const ret = arg0.length;\n return ret;\n },\n __wbg_length_56fcd3e2b7e0299d: function(arg0) {\n const ret = arg0.length;\n return ret;\n },\n __wbg_length_f83cc3ef069d6a23: function(arg0) {\n const ret = arg0.length;\n return ret;\n },\n __wbg_log_7befb5e25df658bf: function(arg0, arg1) {\n console.log(arg0, arg1);\n },\n __wbg_log_eb752234eec406d1: function(arg0) {\n console.log(arg0);\n },\n __wbg_new_02d162bc6cf02f60: function() {\n const ret = new Object();\n return ret;\n },\n __wbg_new_1f236d63ba0c4784: function(arg0, arg1) {\n const ret = new Error(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbg_new_227d7c05414eb861: function() {\n const ret = new Error();\n return ret;\n },\n __wbg_new_310879b66b6e95e1: function() {\n const ret = new Array();\n return ret;\n },\n __wbg_new_7ddec6de44ff8f5d: function(arg0) {\n const ret = new Uint8Array(arg0);\n return ret;\n },\n __wbg_new_859b9002e2668e82: function(arg0) {\n const ret = new Date(arg0);\n return ret;\n },\n __wbg_new_a4f7d7433843fa16: function(arg0, arg1) {\n const ret = new RangeError(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbg_new_from_slice_269e35316ed2d061: function(arg0, arg1) {\n const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));\n return ret;\n },\n __wbg_next_2a4e19f4f5083b0f: function(arg0) {\n const ret = arg0.next;\n return ret;\n },\n __wbg_next_6429a146bf756f93: function() { return handleError(function (arg0) {\n const ret = arg0.next();\n return ret;\n }, arguments); },\n __wbg_ownKeys_cb08d3d8561f661f: function() { return handleError(function (arg0) {\n const ret = Reflect.ownKeys(arg0);\n return ret;\n }, arguments); },\n __wbg_prototypesetcall_5f9bdc8d75e07276: function(arg0, arg1, arg2) {\n Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);\n },\n __wbg_push_b77c476b01548d0a: function(arg0, arg1) {\n const ret = arg0.push(arg1);\n return ret;\n },\n __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {\n arg0[arg1] = arg2;\n },\n __wbg_set_78ea6a19f4818587: function(arg0, arg1, arg2) {\n arg0[arg1 >>> 0] = arg2;\n },\n __wbg_set_a0e911be3da02782: function() { return handleError(function (arg0, arg1, arg2) {\n const ret = Reflect.set(arg0, arg1, arg2);\n return ret;\n }, arguments); },\n __wbg_slice_ec02e3c14d84ad90: function(arg0, arg1, arg2) {\n const ret = arg0.slice(arg1 >>> 0, arg2 >>> 0);\n return ret;\n },\n __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {\n const ret = arg1.stack;\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg_stringify_98fc97c9bbe0e3c0: function(arg0, arg1) {\n const ret = JSON.stringify(arg1);\n var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n var len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg_toString_30d9e686a1bd8b7e: function(arg0) {\n const ret = arg0.toString();\n return ret;\n },\n __wbg_toString_49bf30263e075265: function() { return handleError(function (arg0, arg1) {\n const ret = arg0.toString(arg1);\n return ret;\n }, arguments); },\n __wbg_toString_7b43db62ff51d976: function(arg0, arg1, arg2) {\n const ret = arg1.toString(arg2);\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg_unshift_ed6145d5628f7a55: function(arg0, arg1) {\n const ret = arg0.unshift(arg1);\n return ret;\n },\n __wbg_value_9cc0518af87a489c: function(arg0) {\n const ret = arg0.value;\n return ret;\n },\n __wbg_values_04e37d4db6696114: function(arg0) {\n const ret = Object.values(arg0);\n return ret;\n },\n __wbindgen_cast_0000000000000001: function(arg0) {\n // Cast intrinsic for `F64 -> Externref`.\n const ret = arg0;\n return ret;\n },\n __wbindgen_cast_0000000000000002: function(arg0) {\n // Cast intrinsic for `I64 -> Externref`.\n const ret = arg0;\n return ret;\n },\n __wbindgen_cast_0000000000000003: function(arg0, arg1) {\n // Cast intrinsic for `Ref(String) -> Externref`.\n const ret = getStringFromWasm0(arg0, arg1);\n return ret;\n },\n __wbindgen_cast_0000000000000004: function(arg0) {\n // Cast intrinsic for `U64 -> Externref`.\n const ret = BigInt.asUintN(64, arg0);\n return ret;\n },\n __wbindgen_init_externref_table: function() {\n const table = wasm.__wbindgen_externrefs;\n const offset = table.grow(4);\n table.set(0, undefined);\n table.set(offset + 0, undefined);\n table.set(offset + 1, null);\n table.set(offset + 2, true);\n table.set(offset + 3, false);\n },\n };\n return {\n __proto__: null,\n \"./automerge_wasm_bg.js\": import0,\n };\n}\n\nconst AutomergeFinalization = (typeof FinalizationRegistry === 'undefined')\n ? { register: () => {}, unregister: () => {} }\n : new FinalizationRegistry(ptr => wasm.__wbg_automerge_free(ptr, 1));\nconst SyncStateFinalization = (typeof FinalizationRegistry === 'undefined')\n ? { register: () => {}, unregister: () => {} }\n : new FinalizationRegistry(ptr => wasm.__wbg_syncstate_free(ptr, 1));\n\nfunction addToExternrefTable0(obj) {\n const idx = wasm.__externref_table_alloc();\n wasm.__wbindgen_externrefs.set(idx, obj);\n return idx;\n}\n\nfunction _assertClass(instance, klass) {\n if (!(instance instanceof klass)) {\n throw new Error(`expected instance of ${klass.name}`);\n }\n}\n\nfunction debugString(val) {\n // primitive types\n const type = typeof val;\n if (type == 'number' || type == 'boolean' || val == null) {\n return `${val}`;\n }\n if (type == 'string') {\n return `\"${val}\"`;\n }\n if (type == 'symbol') {\n const description = val.description;\n if (description == null) {\n return 'Symbol';\n } else {\n return `Symbol(${description})`;\n }\n }\n if (type == 'function') {\n const name = val.name;\n if (typeof name == 'string' && name.length > 0) {\n return `Function(${name})`;\n } else {\n return 'Function';\n }\n }\n // objects\n if (Array.isArray(val)) {\n const length = val.length;\n let debug = '[';\n if (length > 0) {\n debug += debugString(val[0]);\n }\n for(let i = 1; i < length; i++) {\n debug += ', ' + debugString(val[i]);\n }\n debug += ']';\n return debug;\n }\n // Test for built-in\n const builtInMatches = /\\[object ([^\\]]+)\\]/.exec(toString.call(val));\n let className;\n if (builtInMatches && builtInMatches.length > 1) {\n className = builtInMatches[1];\n } else {\n // Failed to match the standard '[object ClassName]'\n return toString.call(val);\n }\n if (className == 'Object') {\n // we're a user defined class or Object\n // JSON.stringify avoids problems with cycles, and is generally much\n // easier than looping through ownProperties of `val`.\n try {\n return 'Object(' + JSON.stringify(val) + ')';\n } catch (_) {\n return 'Object';\n }\n }\n // errors\n if (val instanceof Error) {\n return `${val.name}: ${val.message}\\n${val.stack}`;\n }\n // TODO we could test for more things here, like `Set`s and `Map`s.\n return className;\n}\n\nfunction getArrayU8FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);\n}\n\nlet cachedDataViewMemory0 = null;\nfunction getDataViewMemory0() {\n if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {\n cachedDataViewMemory0 = new DataView(wasm.memory.buffer);\n }\n return cachedDataViewMemory0;\n}\n\nfunction getStringFromWasm0(ptr, len) {\n return decodeText(ptr >>> 0, len);\n}\n\nlet cachedUint8ArrayMemory0 = null;\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nfunction handleError(f, args) {\n try {\n return f.apply(this, args);\n } catch (e) {\n const idx = addToExternrefTable0(e);\n wasm.__wbindgen_exn_store(idx);\n }\n}\n\nfunction isLikeNone(x) {\n return x === undefined || x === null;\n}\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = cachedTextEncoder.encodeInto(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nfunction takeFromExternrefTable0(idx) {\n const value = wasm.__wbindgen_externrefs.get(idx);\n wasm.__externref_table_dealloc(idx);\n return value;\n}\n\nlet cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\ncachedTextDecoder.decode();\nconst MAX_SAFARI_DECODE_BYTES = 2146435072;\nlet numBytesDecoded = 0;\nfunction decodeText(ptr, len) {\n numBytesDecoded += len;\n if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {\n cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n cachedTextDecoder.decode();\n numBytesDecoded = len;\n }\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n\nconst cachedTextEncoder = new TextEncoder();\n\nif (!('encodeInto' in cachedTextEncoder)) {\n cachedTextEncoder.encodeInto = function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n };\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nlet wasmModule, wasmInstance, wasm;\nfunction __wbg_finalize_init(instance, module) {\n wasmInstance = instance;\n wasm = instance.exports;\n wasmModule = module;\n cachedDataViewMemory0 = null;\n cachedUint8ArrayMemory0 = null;\n wasm.__wbindgen_start();\n return wasm;\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n } catch (e) {\n const validResponse = module.ok && expectedResponseType(module.type);\n\n if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else { throw e; }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n } else {\n return instance;\n }\n }\n\n function expectedResponseType(type) {\n switch (type) {\n case 'basic': case 'cors': case 'default': return true;\n }\n return false;\n }\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (module !== undefined) {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n const instance = new WebAssembly.Instance(module, imports);\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (module_or_path !== undefined) {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (module_or_path === undefined) {\n module_or_path = new /* @vite-ignore */ URL('automerge_wasm_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync, __wbg_init as default };\n", "import { CLEAR_CACHE, IS_PROXY, OBJECT_ID, STATE, TRACE } from \"./constants.js\";\nexport function _state(doc, checkroot = true) {\n if (typeof doc !== \"object\") {\n throw new RangeError(\"must be the document root\");\n }\n const state = Reflect.get(doc, STATE);\n if (state === undefined ||\n state == null ||\n (checkroot && _obj(doc) !== \"_root\")) {\n throw new RangeError(\"must be the document root\");\n }\n return state;\n}\nexport function _clear_cache(doc) {\n Reflect.set(doc, CLEAR_CACHE, true);\n}\nexport function _trace(doc) {\n return Reflect.get(doc, TRACE);\n}\nexport function _obj(doc) {\n if (!(typeof doc === \"object\") || doc === null) {\n return null;\n }\n return Reflect.get(doc, OBJECT_ID);\n}\nexport function _is_proxy(doc) {\n return !!Reflect.get(doc, IS_PROXY);\n}\n", "import { isAutomerge, isCounter, mark, splice, unmark, } from \"./implementation.js\";\nexport function applyPatch(doc, patch) {\n let path = resolvePath(doc, patch.path);\n if (patch.action === \"put\") {\n applyPutPatch(doc, path, patch);\n }\n else if (patch.action === \"insert\") {\n applyInsertPatch(doc, path, patch);\n }\n else if (patch.action === \"del\") {\n applyDelPatch(doc, path, patch);\n }\n else if (patch.action === \"splice\") {\n applySplicePatch(doc, path, patch);\n }\n else if (patch.action === \"inc\") {\n applyIncPatch(doc, path, patch);\n }\n else if (patch.action === \"mark\") {\n applyMarkPatch(doc, path, patch);\n }\n else if (patch.action === \"unmark\") {\n applyUnmarkPatch(doc, path, patch);\n }\n else if (patch.action === \"conflict\") {\n // Ignore conflict patches\n }\n else {\n throw new RangeError(`unsupported patch: ${patch}`);\n }\n}\nfunction applyPutPatch(doc, path, patch) {\n let { obj: parent, prop } = pathElemAt(path, -1);\n parent[prop] = patch.value;\n}\nfunction applyInsertPatch(doc, path, patch) {\n let { obj: parent, prop } = pathElemAt(path, -1);\n if (!Array.isArray(parent)) {\n throw new RangeError(`target is not an array for patch`);\n }\n if (!(typeof prop === \"number\")) {\n throw new RangeError(`index is not a number for patch`);\n }\n parent.splice(prop, 0, ...patch.values);\n}\nfunction applyDelPatch(doc, path, patch) {\n let { obj: parent, prop, parentPath } = pathElemAt(path, -1);\n if (!(typeof prop === \"number\")) {\n throw new RangeError(`index is not a number for patch`);\n }\n if (Array.isArray(parent)) {\n parent.splice(prop, patch.length || 1);\n }\n else if (typeof parent === \"string\") {\n if (isAutomerge(doc)) {\n splice(doc, parentPath, prop, patch.length || 1);\n }\n else {\n let { obj: grandParent, prop: grandParentProp } = pathElemAt(path, -2);\n if (typeof prop !== \"number\") {\n throw new RangeError(`index is not a number for patch`);\n }\n let target = grandParent[grandParentProp];\n if (target == null || typeof target !== \"string\") {\n throw new RangeError(`target is not a string for patch`);\n }\n let newString = target.slice(0, prop) + target.slice(prop + (patch.length || 1));\n grandParent[grandParentProp] = newString;\n }\n }\n else {\n throw new RangeError(`target is not an array or string for patch`);\n }\n}\nfunction applySplicePatch(doc, path, patch) {\n if (isAutomerge(doc)) {\n let { obj: parent, prop, parentPath } = pathElemAt(path, -1);\n if (!(typeof prop === \"number\")) {\n throw new RangeError(`index is not a number for patch`);\n }\n splice(doc, parentPath, prop, 0, patch.value);\n }\n else {\n let { obj: parent, prop } = pathElemAt(path, -1);\n let { obj: grandParent, prop: grandParentProp } = pathElemAt(path, -2);\n if (typeof prop !== \"number\") {\n throw new RangeError(`index is not a number for patch`);\n }\n let target = grandParent[grandParentProp];\n if (target == null || typeof target !== \"string\") {\n throw new RangeError(`target is not a string for patch`);\n }\n let newString = target.slice(0, prop) + patch.value + target.slice(prop);\n grandParent[grandParentProp] = newString;\n }\n}\nfunction applyIncPatch(doc, path, patch) {\n let { obj: parent, prop } = pathElemAt(path, -1);\n const counter = parent[prop];\n if (isAutomerge(doc)) {\n if (!isCounter(counter)) {\n throw new RangeError(`target is not a counter for patch`);\n }\n counter.increment(patch.value);\n }\n else {\n if (!(typeof counter === \"number\")) {\n throw new RangeError(`target is not a number for patch`);\n }\n parent[prop] = counter + patch.value;\n }\n}\nfunction applyMarkPatch(doc, path, patch) {\n let { obj: parent, prop } = pathElemAt(path, -1);\n if (!isAutomerge(doc)) {\n return;\n }\n for (const markSpec of patch.marks) {\n mark(doc, patch.path, \n // TODO: add mark expansion to patches. This will require emitting\n // the expand values in patches.\n { start: markSpec.start, end: markSpec.end, expand: \"none\" }, markSpec.name, markSpec.value);\n }\n}\nfunction applyUnmarkPatch(doc, path, patch) {\n if (!isAutomerge(doc)) {\n return;\n }\n unmark(doc, patch.path, { start: patch.start, end: patch.end, expand: \"none\" }, patch.name);\n}\nexport function applyPatches(doc, patches) {\n for (const patch of patches) {\n applyPatch(doc, patch);\n }\n}\n/**\n * Walk through a path with an object and for each element in the path return a resolved path element.\n *\n * A resolved path element looks like this:\n *\n * ```typescript\n * {\n * obj: any, // The object that this element in the path is a property of\n * prop: Prop, // The property within `obj` that this path element points at\n * parentPath: Prop[] // The path to `obj` within the original `doc` passed to `resolvePath`\n * }\n * ````\n *\n * For example, given an object like this:\n *\n * ```typescript\n * {\n * todos: [{ task: \"remember the milk\"}]\n * }\n * ```\n *\n * Then `resolvePath(doc, [\"todos\", 0, \"task\"])` would return:\n *\n * ```typescript\n * [\n * { obj: { todos: [{ task: \"remember the milk\"}] }, prop: \"todos\", parentPath: [] },\n * { obj: [{ task: \"remember the milk\"}], prop: 0, parentPath: [\"todos\"] },\n * { obj: { task: \"remember the milk\" }, prop: \"task\", parentPath: [\"todos\", 0] }\n * ]\n * ```\n */\nfunction resolvePath(doc, path) {\n const result = [];\n let current = doc;\n let currentPath = [];\n for (const [index, prop] of path.entries()) {\n result.push({ obj: current, prop, parentPath: currentPath.slice() });\n currentPath.push(prop);\n if (index !== path.length - 1) {\n if (current == null || typeof current != \"object\") {\n // If we're not the last item in the path then we need the current\n // object to be an object so we can access it in the next iteration\n throw new Error(`Invalid path: ${path}`);\n }\n current = current[prop];\n }\n else {\n break;\n }\n }\n return result;\n}\n/**\n * Get an element from a resolved path, throwing an exception if the element does not exist\n *\n * @param resolved - The path to lookup in\n * @param index - The index of the element to lookup, negative indices search backwards\n */\nfunction pathElemAt(resolved, index) {\n let result = resolved.at(index);\n if (result == undefined) {\n throw new Error(\"invalid path\");\n }\n return result;\n}\nfunction reversed(array) {\n return array.slice().reverse();\n}\n", "var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n};\nimport { isImmutableString, rootProxy, validateForBatchInsert, } from \"./proxies.js\";\nexport { isImmutableString, isCounter } from \"./proxies.js\";\nimport { STATE } from \"./constants.js\";\nimport { Counter, } from \"./types.js\";\nexport { Counter, Int, Uint, Float64, } from \"./types.js\";\nconst _SyncStateSymbol = Symbol(\"_syncstate\");\nimport { ApiHandler, UseApi } from \"./low_level.js\";\nimport { JS_GIT_HEAD } from \"./generated/release-info.js\";\nexport { initializeWasm, initializeBase64Wasm, wasmInitialized, isWasmInitialized, } from \"./low_level.js\";\nimport { ImmutableString } from \"./immutable_string.js\";\nexport { ImmutableString } from \"./immutable_string.js\";\nimport { _state, _is_proxy, _clear_cache, _trace, _obj, } from \"./internal_state.js\";\nexport { applyPatch, applyPatches } from \"./apply_patches.js\";\nimport { conflictAt } from \"./conflicts.js\";\n/**\n * Function for use in {@link change} which inserts values into a list at a given index\n * @param list\n * @param index\n * @param values\n */\nexport function insertAt(list, index, ...values) {\n if (!_is_proxy(list)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n //eslint-disable-next-line no-extra-semi\n ;\n list.insertAt(index, ...values);\n}\n/**\n * Function for use in {@link change} which deletes values from a list at a given index\n * @param list\n * @param index\n * @param numDelete\n */\nexport function deleteAt(list, index, numDelete) {\n if (!_is_proxy(list)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n //eslint-disable-next-line no-extra-semi\n ;\n list.deleteAt(index, numDelete);\n}\n/** @hidden **/\nexport function use(api) {\n UseApi(api);\n}\n/** @hidden */\nexport function getBackend(doc) {\n return _state(doc).handle;\n}\nfunction importOpts(_actor) {\n if (typeof _actor === \"object\") {\n return _actor;\n }\n else {\n return { actor: _actor };\n }\n}\nexport function getChangesSince(state, heads) {\n const n = _state(state);\n return n.handle.getChanges(heads);\n}\nexport function getChangesMetaSince(state, heads) {\n const n = _state(state);\n return n.handle.getChangesMeta(heads);\n}\nfunction cursorToIndex(state, value, index) {\n if (typeof index == \"string\") {\n if (/^-?[0-9]+@[0-9a-zA-Z]+$|^[se]$/.test(index)) {\n return state.handle.getCursorPosition(value, index);\n }\n else {\n throw new RangeError(\"index must be a number or cursor\");\n }\n }\n else {\n return index;\n }\n}\n/**\n * Create a new automerge document\n *\n * @typeParam T - The type of value contained in the document. This will be the\n * type that is passed to the change closure in {@link change}\n * @param _opts - Either an actorId or an {@link InitOptions} (which may\n * contain an actorId). If this is null the document will be initialised with a\n * random actor ID\n */\nexport function init(_opts) {\n const opts = importOpts(_opts);\n const freeze = !!opts.freeze;\n const patchCallback = opts.patchCallback;\n const actor = opts.actor;\n const handle = ApiHandler.create({ actor });\n handle.enableFreeze(!!opts.freeze);\n registerDatatypes(handle);\n const doc = handle.materialize(\"/\", undefined, {\n handle,\n heads: undefined,\n freeze,\n patchCallback,\n });\n return doc;\n}\n/**\n * Make an immutable view of an automerge document as at `heads`\n *\n * @remarks\n * The document returned from this function cannot be passed to {@link change}.\n * This is because it shares the same underlying memory as `doc`, but it is\n * consequently a very cheap copy.\n *\n * Note that this function will throw an error if any of the hashes in `heads`\n * are not in the document.\n *\n * @typeParam T - The type of the value contained in the document\n * @param doc - The document to create a view of\n * @param heads - The hashes of the heads to create a view at\n */\nexport function view(doc, heads) {\n const state = _state(doc);\n const handle = state.handle;\n return state.handle.materialize(\"/\", heads, Object.assign(Object.assign({}, state), { handle,\n heads }));\n}\n/**\n * Make a full writable copy of an automerge document\n *\n * @remarks\n * Unlike {@link view} this function makes a full copy of the memory backing\n * the document and can thus be passed to {@link change}. It also generates a\n * new actor ID so that changes made in the new document do not create duplicate\n * sequence numbers with respect to the old document. If you need control over\n * the actor ID which is generated you can pass the actor ID as the second\n * argument\n *\n * @typeParam T - The type of the value contained in the document\n * @param doc - The document to clone\n * @param _opts - Either an actor ID to use for the new doc or an {@link InitOptions}\n */\nexport function clone(doc, _opts) {\n const state = _state(doc);\n const heads = state.heads;\n const opts = importOpts(_opts);\n const handle = state.handle.fork(opts.actor, heads);\n handle.updateDiffCursor();\n // `change` uses the presence of state.heads to determine if we are in a view\n // set it to undefined to indicate that this is a full fat document\n const { heads: _oldHeads } = state, stateSansHeads = __rest(state, [\"heads\"]);\n stateSansHeads.patchCallback = opts.patchCallback;\n return handle.applyPatches(doc, Object.assign(Object.assign({}, stateSansHeads), { handle }));\n}\n/** Explicity free the memory backing a document. Note that this is note\n * necessary in environments which support\n * [`FinalizationRegistry`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry)\n */\nexport function free(doc) {\n return _state(doc).handle.free();\n}\n/**\n * Create an automerge document from a POJO\n *\n * @param initialState - The initial state which will be copied into the document\n * @typeParam T - The type of the value passed to `from` _and_ the type the resulting document will contain\n * @typeParam actor - The actor ID of the resulting document, if this is null a random actor ID will be used\n *\n * @example\n * ```\n * const doc = automerge.from({\n * tasks: [\n * {description: \"feed dogs\", done: false}\n * ]\n * })\n * ```\n */\nexport function from(initialState, _opts) {\n const opts = importOpts(_opts);\n if (typeof initialState !== \"object\" || Array.isArray(initialState)) {\n initialState = Object.assign({}, initialState);\n }\n validateForBatchInsert(initialState, null, []);\n const doc = init(_opts);\n return _change(doc, \"from\", {}, d => {\n _state(doc).handle.initRootFromHydrate(initialState);\n return d;\n }).newDoc;\n}\n/**\n * Update the contents of an automerge document\n * @typeParam T - The type of the value contained in the document\n * @param doc - The document to update\n * @param options - Either a message, an {@link ChangeOptions}, or a {@link ChangeFn}\n * @param callback - A `ChangeFn` to be used if `options` was a `string`\n *\n * Note that if the second argument is a function it will be used as the `ChangeFn` regardless of what the third argument is.\n *\n * @example A simple change\n * ```\n * let doc1 = automerge.init()\n * doc1 = automerge.change(doc1, d => {\n * d.key = \"value\"\n * })\n * assert.equal(doc1.key, \"value\")\n * ```\n *\n * @example A change with a message\n *\n * ```\n * doc1 = automerge.change(doc1, \"add another value\", d => {\n * d.key2 = \"value2\"\n * })\n * ```\n *\n * @example A change with a message and a timestamp\n *\n * ```\n * doc1 = automerge.change(doc1, {message: \"add another value\", time: 1640995200}, d => {\n * d.key2 = \"value2\"\n * })\n * ```\n *\n * @example responding to a patch callback\n * ```\n * let patchedPath\n * let patchCallback = patch => {\n * patchedPath = patch.path\n * }\n * doc1 = automerge.change(doc1, {message: \"add another value\", time: 1640995200, patchCallback}, d => {\n * d.key2 = \"value2\"\n * })\n * assert.equal(patchedPath, [\"key2\"])\n * ```\n */\nexport function change(doc, options, callback) {\n if (typeof options === \"function\") {\n return _change(doc, \"change\", {}, options).newDoc;\n }\n else if (typeof callback === \"function\") {\n if (typeof options === \"string\") {\n options = { message: options };\n }\n return _change(doc, \"change\", options, callback).newDoc;\n }\n else {\n throw RangeError(\"Invalid args for change\");\n }\n}\n/**\n * Make a change to the document as it was at a particular point in history\n * @typeParam T - The type of the value contained in the document\n * @param doc - The document to update\n * @param scope - The heads representing the point in history to make the change\n * @param options - Either a message or a {@link ChangeOptions} for the new change\n * @param callback - A `ChangeFn` to be used if `options` was a `string`\n *\n * @remarks\n * This function is similar to {@link change} but allows you to make changes to\n * the document as if it were at a particular point in time. To understand this\n * imagine a document created with the following history:\n *\n * ```ts\n * let doc = automerge.from({..})\n * doc = automerge.change(doc, () => {...})\n *\n * const heads = automerge.getHeads(doc)\n *\n * // fork the document make a change\n * let fork = automerge.fork(doc)\n * fork = automerge.change(fork, () => {...})\n * const headsOnFork = automerge.getHeads(fork)\n *\n * // make a change on the original doc\n * doc = automerge.change(doc, () => {...})\n * const headsOnOriginal = automerge.getHeads(doc)\n *\n * // now merge the changes back to the original document\n * doc = automerge.merge(doc, fork)\n *\n * // The heads of the document will now be (headsOnFork, headsOnOriginal)\n * ```\n *\n * {@link ChangeAt} produces an equivalent history, but without having to\n * create a fork of the document. In particular the `newHeads` field of the\n * returned {@link ChangeAtResult} will be the same as `headsOnFork`.\n *\n * Why would you want this? It's typically used in conjunction with {@link diff}\n * to reconcile state which is managed concurrently with the document. For\n * example, if you have a text editor component which the user is modifying\n * and you can't send the changes to the document synchronously you might follow\n * a workflow like this:\n *\n * * On initialization save the current heads of the document in the text editor state\n * * Every time the user makes a change record the change in the text editor state\n *\n * Now from time to time reconcile the editor state and the document\n * * Load the last saved heads from the text editor state, call them `oldHeads`\n * * Apply all the unreconciled changes to the document using `changeAt(doc, oldHeads, ...)`\n * * Get the diff from the resulting document to the current document using {@link diff}\n * passing the {@link ChangeAtResult.newHeads} as the `before` argument and the\n * heads of the entire document as the `after` argument.\n * * Apply the diff to the text editor state\n * * Save the current heads of the document in the text editor state\n */\nexport function changeAt(doc, scope, options, callback) {\n if (typeof options === \"function\") {\n return _change(doc, \"changeAt\", {}, options, scope);\n }\n else if (typeof callback === \"function\") {\n if (typeof options === \"string\") {\n options = { message: options };\n }\n return _change(doc, \"changeAt\", options, callback, scope);\n }\n else {\n throw RangeError(\"Invalid args for changeAt\");\n }\n}\nfunction progressDocument(doc, source, heads, callback) {\n if (heads == null) {\n return doc;\n }\n const state = _state(doc);\n const nextState = Object.assign(Object.assign({}, state), { heads: undefined });\n const { value: nextDoc, patches } = state.handle.applyAndReturnPatches(doc, nextState);\n if (patches.length > 0) {\n if (callback != null) {\n callback(patches, { before: doc, after: nextDoc, source });\n }\n const newState = _state(nextDoc);\n newState.mostRecentPatch = {\n before: _state(doc).heads,\n after: newState.handle.getHeads(),\n patches,\n };\n }\n state.heads = heads;\n return nextDoc;\n}\nfunction _change(doc, source, options, callback, scope) {\n if (typeof callback !== \"function\") {\n throw new RangeError(\"invalid change function\");\n }\n const state = _state(doc);\n if (doc === undefined || state === undefined) {\n throw new RangeError(\"must be the document root\");\n }\n if (state.heads) {\n throw new RangeError(\"Attempting to change an outdated document. Use Automerge.clone() if you wish to make a writable copy.\");\n }\n if (_is_proxy(doc)) {\n throw new RangeError(\"Calls to Automerge.change cannot be nested\");\n }\n let heads = state.handle.getHeads();\n if (scope && headsEqual(scope, heads)) {\n scope = undefined;\n }\n if (scope) {\n state.handle.isolate(scope);\n heads = scope;\n }\n if (!(\"time\" in options)) {\n options.time = Math.floor(Date.now() / 1000);\n }\n try {\n state.heads = heads;\n const root = rootProxy(state.handle);\n callback(root);\n if (state.handle.pendingOps() === 0) {\n state.heads = undefined;\n if (scope) {\n state.handle.integrate();\n }\n return {\n newDoc: doc,\n newHeads: null,\n };\n }\n else {\n const newHead = state.handle.commit(options.message, options.time);\n state.handle.integrate();\n return {\n newDoc: progressDocument(doc, source, heads, options.patchCallback || state.patchCallback),\n newHeads: newHead != null ? [newHead] : null,\n };\n }\n }\n catch (e) {\n state.heads = undefined;\n state.handle.rollback();\n throw e;\n }\n}\n/**\n * Make a change to a document which does not modify the document\n *\n * @param doc - The doc to add the empty change to\n * @param options - Either a message or a {@link ChangeOptions} for the new change\n *\n * Why would you want to do this? One reason might be that you have merged\n * changes from some other peers and you want to generate a change which\n * depends on those merged changes so that you can sign the new change with all\n * of the merged changes as part of the new change.\n */\nexport function emptyChange(doc, options) {\n if (options === undefined) {\n options = {};\n }\n if (typeof options === \"string\") {\n options = { message: options };\n }\n if (!(\"time\" in options)) {\n options.time = Math.floor(Date.now() / 1000);\n }\n const state = _state(doc);\n if (state.heads) {\n throw new RangeError(\"Attempting to change an outdated document. Use Automerge.clone() if you wish to make a writable copy.\");\n }\n if (_is_proxy(doc)) {\n throw new RangeError(\"Calls to Automerge.change cannot be nested\");\n }\n const heads = state.handle.getHeads();\n state.handle.emptyChange(options.message, options.time);\n return progressDocument(doc, \"emptyChange\", heads);\n}\n/**\n * Load an automerge document from a compressed document produce by {@link save}\n *\n * @typeParam T - The type of the value which is contained in the document.\n * Note that no validation is done to make sure this type is in\n * fact the type of the contained value so be a bit careful\n * @param data - The compressed document\n * @param _opts - Either an actor ID or some {@link InitOptions}, if the actor\n * ID is null a random actor ID will be created\n *\n * Note that `load` will throw an error if passed incomplete content (for\n * example if you are receiving content over the network and don't know if you\n * have the complete document yet). If you need to handle incomplete content use\n * {@link init} followed by {@link loadIncremental}.\n */\nexport function load(data, _opts) {\n const opts = importOpts(_opts);\n if (opts.patchCallback) {\n return loadIncremental(init(opts), data);\n }\n const actor = opts.actor;\n const patchCallback = opts.patchCallback;\n const unchecked = opts.unchecked || false;\n const allowMissingDeps = opts.allowMissingChanges || false;\n const convertImmutableStringsToText = opts.convertImmutableStringsToText || false;\n const handle = ApiHandler.load(data, {\n actor,\n unchecked,\n allowMissingDeps,\n convertImmutableStringsToText,\n });\n handle.enableFreeze(!!opts.freeze);\n registerDatatypes(handle);\n const doc = handle.materialize(\"/\", undefined, {\n handle,\n heads: undefined,\n patchCallback,\n });\n return doc;\n}\n/**\n * Load changes produced by {@link saveIncremental}, or partial changes\n *\n * @typeParam T - The type of the value which is contained in the document.\n * Note that no validation is done to make sure this type is in\n * fact the type of the contained value so be a bit careful\n * @param data - The compressedchanges\n * @param opts - an {@link ApplyOptions}\n *\n * This function is useful when staying up to date with a connected peer.\n * Perhaps the other end sent you a full compresed document which you loaded\n * with {@link load} and they're sending you the result of\n * {@link getLastLocalChange} every time they make a change.\n *\n * Note that this function will succesfully load the results of {@link save} as\n * well as {@link getLastLocalChange} or any other incremental change.\n */\nexport function loadIncremental(doc, data, opts) {\n if (!opts) {\n opts = {};\n }\n const state = _state(doc);\n if (state.heads) {\n throw new RangeError(\"Attempting to change an out of date document - set at: \" + _trace(doc));\n }\n if (_is_proxy(doc)) {\n throw new RangeError(\"Calls to Automerge.change cannot be nested\");\n }\n const heads = state.handle.getHeads();\n state.handle.loadIncremental(data);\n return progressDocument(doc, \"loadIncremental\", heads, opts.patchCallback || state.patchCallback);\n}\n/**\n * Create binary save data to be appended to a save file or fed into {@link loadIncremental}\n *\n * @typeParam T - The type of the value which is contained in the document.\n * Note that no validation is done to make sure this type is in\n * fact the type of the contained value so be a bit careful\n *\n * This function is useful for incrementally saving state. The data can be appended to a\n * automerge save file, or passed to a document replicating its state.\n *\n */\nexport function saveIncremental(doc) {\n const state = _state(doc);\n if (state.heads) {\n throw new RangeError(\"Attempting to change an out of date document - set at: \" + _trace(doc));\n }\n if (_is_proxy(doc)) {\n throw new RangeError(\"Calls to Automerge.change cannot be nested\");\n }\n return state.handle.saveIncremental();\n}\n/**\n * Export the contents of a document to a compressed format\n *\n * @param doc - The doc to save\n *\n * The returned bytes can be passed to {@link load} or {@link loadIncremental}\n */\nexport function save(doc) {\n return _state(doc).handle.save();\n}\n/**\n * Merge `remote` into `local`\n * @typeParam T - The type of values contained in each document\n * @param local - The document to merge changes into\n * @param remote - The document to merge changes from\n *\n * @returns - The merged document\n *\n * Often when you are merging documents you will also need to clone them. Both\n * arguments to `merge` are frozen after the call so you can no longer call\n * mutating methods (such as {@link change}) on them. The symtom of this will be\n * an error which says \"Attempting to change an out of date document\". To\n * overcome this call {@link clone} on the argument before passing it to {@link\n * merge}.\n */\nexport function merge(local, remote) {\n const localState = _state(local);\n if (localState.heads) {\n throw new RangeError(\"Attempting to change an out of date document - set at: \" + _trace(local));\n }\n const heads = localState.handle.getHeads();\n const remoteState = _state(remote);\n const changes = localState.handle.getChangesAdded(remoteState.handle);\n localState.handle.applyChanges(changes);\n return progressDocument(local, \"merge\", heads, localState.patchCallback);\n}\n/**\n * Get the actor ID associated with the document\n */\nexport function getActorId(doc) {\n const state = _state(doc);\n return state.handle.getActorId();\n}\n/**\n * Get the conflicts associated with a property\n *\n * The values of properties in a map in automerge can be conflicted if there\n * are concurrent \"put\" operations to the same key. Automerge chooses one value\n * arbitrarily (but deterministically, any two nodes who have the same set of\n * changes will choose the same value) from the set of conflicting values to\n * present as the value of the key.\n *\n * Sometimes you may want to examine these conflicts, in this case you can use\n * {@link getConflicts} to get the conflicts for the key.\n *\n * @example\n * ```\n * import * as automerge from \"@automerge/automerge\"\n *\n * type Profile = {\n * pets: Array<{name: string, type: string}>\n * }\n *\n * let doc1 = automerge.init<Profile>(\"aaaa\")\n * doc1 = automerge.change(doc1, d => {\n * d.pets = [{name: \"Lassie\", type: \"dog\"}]\n * })\n * let doc2 = automerge.init<Profile>(\"bbbb\")\n * doc2 = automerge.merge(doc2, automerge.clone(doc1))\n *\n * doc2 = automerge.change(doc2, d => {\n * d.pets[0].name = \"Beethoven\"\n * })\n *\n * doc1 = automerge.change(doc1, d => {\n * d.pets[0].name = \"Babe\"\n * })\n *\n * const doc3 = automerge.merge(doc1, doc2)\n *\n * // Note that here we pass `doc3.pets`, not `doc3`\n * let conflicts = automerge.getConflicts(doc3.pets[0], \"name\")\n *\n * // The two conflicting values are the keys of the conflicts object\n * assert.deepEqual(Object.values(conflicts), [\"Babe\", Beethoven\"])\n * ```\n */\nexport function getConflicts(doc, prop) {\n const state = _state(doc, false);\n const objectId = _obj(doc);\n if (objectId != null) {\n const withinChangeCallback = _is_proxy(doc);\n return conflictAt(state.handle, objectId, prop, withinChangeCallback);\n }\n else {\n return undefined;\n }\n}\n/**\n * Get the binary representation of the last change which was made to this doc\n *\n * This is most useful when staying in sync with other peers, every time you\n * make a change locally via {@link change} you immediately call {@link\n * getLastLocalChange} and send the result over the network to other peers.\n */\nexport function getLastLocalChange(doc) {\n const state = _state(doc);\n return state.handle.getLastLocalChange() || undefined;\n}\n/**\n * Return the object ID of an arbitrary javascript value\n *\n * This is useful to determine if something is actually an automerge document,\n * if `doc` is not an automerge document this will return null.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getObjectId(doc, prop) {\n if (prop) {\n const state = _state(doc, false);\n const objectId = _obj(doc);\n if (!state || !objectId) {\n return null;\n }\n return state.handle.get(objectId, prop);\n }\n else {\n return _obj(doc);\n }\n}\n/**\n * Get the changes which are in `newState` but not in `oldState`. The returned\n * changes can be loaded in `oldState` via {@link applyChanges}.\n *\n * Note that this will crash if there are changes in `oldState` which are not in `newState`.\n */\nexport function getChanges(oldState, newState) {\n const n = _state(newState);\n return n.handle.getChanges(getHeads(oldState));\n}\n/**\n * Get all the changes in a document\n *\n * This is different to {@link save} because the output is an array of changes\n * which can be individually applied via {@link applyChanges}`\n *\n */\nexport function getAllChanges(doc) {\n const state = _state(doc);\n return state.handle.getChanges([]);\n}\n/**\n * Apply changes received from another document\n *\n * `doc` will be updated to reflect the `changes`. If there are changes which\n * we do not have dependencies for yet those will be stored in the document and\n * applied when the depended on changes arrive.\n *\n * You can use the {@link ApplyOptions} to pass a patchcallback which will be\n * informed of any changes which occur as a result of applying the changes\n *\n */\nexport function applyChanges(doc, changes, opts) {\n const state = _state(doc);\n if (!opts) {\n opts = {};\n }\n if (state.heads) {\n throw new RangeError(\"Attempting to change an outdated document. Use Automerge.clone() if you wish to make a writable copy.\");\n }\n if (_is_proxy(doc)) {\n throw new RangeError(\"Calls to Automerge.change cannot be nested\");\n }\n const heads = state.handle.getHeads();\n state.handle.applyChanges(changes);\n state.heads = heads;\n return [\n progressDocument(doc, \"applyChanges\", heads, opts.patchCallback || state.patchCallback),\n ];\n}\n/** @hidden */\nexport function getHistory(doc) {\n const history = getAllChanges(doc);\n return history.map((change, index) => ({\n get change() {\n return decodeChange(change);\n },\n get snapshot() {\n const [state] = applyChanges(init(), history.slice(0, index + 1));\n return state;\n },\n }));\n}\n/**\n * Create a set of patches representing the change from one set of heads to another\n *\n * If either of the heads are missing from the document the returned set of patches will be empty\n */\nexport function diff(doc, before, after) {\n checkHeads(before, \"before heads\");\n checkHeads(after, \"after heads\");\n const state = _state(doc);\n if (state.mostRecentPatch &&\n equals(state.mostRecentPatch.before, before) &&\n equals(state.mostRecentPatch.after, after)) {\n return state.mostRecentPatch.patches;\n }\n return state.handle.diff(before, after);\n}\n/**\n * Create a set of patches representing the change from one set of heads to another at a given path\n * @experimental\n * @param doc - The document to update\n * @param path - path of the object to diff\n * @param before - before Heads for the diff\n * @param after - after Heads for the diff\n * @param opts - Options is { recursive: bool } to diff sub objects as well. Default is true\n *\n * This is an experimental API\n */\nexport function diffPath(doc, path, before, after, opts) {\n checkHeads(before, \"before\");\n checkHeads(after, \"after\");\n const state = _state(doc);\n const objPath = absoluteObjPath(doc, path, \"diff\");\n return state.handle.diffPath(objPath, before, after, opts);\n}\nfunction headsEqual(heads1, heads2) {\n if (heads1.length !== heads2.length) {\n return false;\n }\n for (let i = 0; i < heads1.length; i++) {\n if (heads1[i] !== heads2[i]) {\n return false;\n }\n }\n return true;\n}\nfunction checkHeads(heads, fieldname) {\n if (!Array.isArray(heads)) {\n throw new Error(`invalid ${fieldname}: must be an array`);\n }\n}\n/** @hidden */\n// FIXME : no tests\n// FIXME can we just use deep equals now?\nexport function equals(val1, val2) {\n if (!isObject(val1) || !isObject(val2))\n return val1 === val2;\n const keys1 = Object.keys(val1).sort(), keys2 = Object.keys(val2).sort();\n if (keys1.length !== keys2.length)\n return false;\n for (let i = 0; i < keys1.length; i++) {\n if (keys1[i] !== keys2[i])\n return false;\n if (!equals(val1[keys1[i]], val2[keys2[i]]))\n return false;\n }\n return true;\n}\n/**\n * encode a {@link SyncState} into binary to send over the network\n *\n * @group sync\n * */\nexport function encodeSyncState(state) {\n const sync = ApiHandler.importSyncState(state);\n const result = ApiHandler.encodeSyncState(sync);\n sync.free();\n return result;\n}\n/**\n * Decode some binary data into a {@link SyncState}\n *\n * @group sync\n */\nexport function decodeSyncState(state) {\n const sync = ApiHandler.decodeSyncState(state);\n const result = ApiHandler.exportSyncState(sync);\n sync.free();\n return result;\n}\n/**\n * Generate a sync message to send to the peer represented by `inState`\n * @param doc - The doc to generate messages about\n * @param inState - The {@link SyncState} representing the peer we are talking to\n *\n * @group sync\n *\n * @returns An array of `[newSyncState, syncMessage | null]` where\n * `newSyncState` should replace `inState` and `syncMessage` should be sent to\n * the peer if it is not null. If `syncMessage` is null then we are up to date.\n */\nexport function generateSyncMessage(doc, inState) {\n const state = _state(doc);\n const syncState = ApiHandler.importSyncState(inState);\n const message = state.handle.generateSyncMessage(syncState);\n const outState = ApiHandler.exportSyncState(syncState);\n return [outState, message];\n}\n/**\n * Update a document and our sync state on receiving a sync message\n *\n * @group sync\n *\n * @param doc - The doc the sync message is about\n * @param inState - The {@link SyncState} for the peer we are communicating with\n * @param message - The message which was received\n * @param opts - Any {@link ApplyOption}s, used for passing a\n * {@link PatchCallback} which will be informed of any changes\n * in `doc` which occur because of the received sync message.\n *\n * @returns An array of `[newDoc, newSyncState, null]` where\n * `newDoc` is the updated state of `doc`, `newSyncState` should replace\n * `inState`.\n *\n * @remarks Note that this function has three return values for legacy reasons.\n * The third value used to be a sync message to send back but this is now\n * always null and you should instead call `generateSyncMessage` after calling\n * `receiveSyncMessage` to see if there are new messages to send.\n */\nexport function receiveSyncMessage(doc, inState, message, opts) {\n const syncState = ApiHandler.importSyncState(inState);\n if (!opts) {\n opts = {};\n }\n const state = _state(doc);\n if (state.heads) {\n throw new RangeError(\"Attempting to change an outdated document. Use Automerge.clone() if you wish to make a writable copy.\");\n }\n if (_is_proxy(doc)) {\n throw new RangeError(\"Calls to Automerge.change cannot be nested\");\n }\n const heads = state.handle.getHeads();\n state.handle.receiveSyncMessage(syncState, message);\n const outSyncState = ApiHandler.exportSyncState(syncState);\n return [\n progressDocument(doc, \"receiveSyncMessage\", heads, opts.patchCallback || state.patchCallback),\n outSyncState,\n null,\n ];\n}\n/**\n * Check whether the replica represented by `remoteState` has all our changes\n *\n * @param doc - The doc to check whether the remote has changes for\n * @param remoteState - The {@link SyncState} representing the peer we are talking to\n *\n * @group sync\n *\n * @returns true if the remote has all of our changes\n */\nexport function hasOurChanges(doc, remoteState) {\n const state = _state(doc);\n const syncState = ApiHandler.importSyncState(remoteState);\n return state.handle.hasOurChanges(syncState);\n}\n/**\n * Create a new, blank {@link SyncState}\n *\n * When communicating with a peer for the first time use this to generate a new\n * {@link SyncState} for them\n *\n * @param options - Optional configuration for the sync state\n * @param options.readOnly - If true, incoming changes from the peer will not be\n * applied to the document. Our changes are still sent to the peer.\n *\n * @group sync\n */\nexport function initSyncState(options) {\n if (options === null || options === void 0 ? void 0 : options.readOnly) {\n const syncState = ApiHandler.initSyncState();\n syncState.readOnly = true;\n const result = ApiHandler.exportSyncState(syncState);\n syncState.free();\n return result;\n }\n return ApiHandler.exportSyncState(ApiHandler.initSyncState());\n}\n/** @hidden */\nexport function encodeChange(change) {\n return ApiHandler.encodeChange(change);\n}\n/** @hidden */\nexport function decodeChange(data) {\n return ApiHandler.decodeChange(data);\n}\n/** @hidden */\nexport function encodeSyncMessage(message) {\n return ApiHandler.encodeSyncMessage(message);\n}\n/** @hidden */\nexport function decodeSyncMessage(message) {\n return ApiHandler.decodeSyncMessage(message);\n}\n/**\n * Get any changes in `doc` which are not dependencies of `heads`\n */\nexport function getMissingDeps(doc, heads) {\n const state = _state(doc);\n return state.handle.getMissingDeps(heads);\n}\n/**\n * Get the hashes of the heads of this document\n */\nexport function getHeads(doc) {\n const state = _state(doc);\n return state.heads || state.handle.getHeads();\n}\n/** @hidden */\nexport function dump(doc) {\n const state = _state(doc);\n state.handle.dump();\n}\n/** @hidden */\nexport function toJS(doc) {\n const state = _state(doc);\n const enabled = state.handle.enableFreeze(false);\n const result = state.handle.materialize(\"/\", state.heads);\n state.handle.enableFreeze(enabled);\n return result;\n}\nexport function isAutomerge(doc) {\n if (typeof doc == \"object\" && doc !== null) {\n return getObjectId(doc) === \"_root\" && !!Reflect.get(doc, STATE);\n }\n else {\n return false;\n }\n}\nfunction isObject(obj) {\n return typeof obj === \"object\" && obj !== null;\n}\nexport function saveSince(doc, heads) {\n const state = _state(doc);\n const result = state.handle.saveSince(heads);\n return result;\n}\n/**\n * Returns true if the document has all of the given heads somewhere in its history\n */\nexport function hasHeads(doc, heads) {\n const state = _state(doc);\n for (const hash of heads) {\n if (!state.handle.getChangeByHash(hash)) {\n return false;\n }\n }\n return true;\n}\nfunction registerDatatypes(handle) {\n handle.registerDatatype(\"counter\", (n) => new Counter(n), n => {\n if (n instanceof Counter) {\n return n.value;\n }\n });\n handle.registerDatatype(\"str\", (n) => {\n return new ImmutableString(n);\n }, s => {\n if (isImmutableString(s)) {\n return s.val;\n }\n });\n}\n/**\n * @hidden\n */\nexport function topoHistoryTraversal(doc) {\n const state = _state(doc);\n return state.handle.topoHistoryTraversal();\n}\n/**\n * Decode a change hash into the details of this change\n *\n * This should be considered a semi-stable API. We try not to change the\n * encoding in backwards incompatible ways but we won't bump a major version if\n * we do have to change it\n */\nexport function inspectChange(doc, changeHash) {\n const state = _state(doc);\n return state.handle.getDecodedChangeByHash(changeHash);\n}\n/**\n * Return some internal statistics about the document\n */\nexport function stats(doc) {\n var _a, _b, _c, _d, _e, _f;\n const state = _state(doc);\n const wasmStats = state.handle.stats();\n const release = releaseInfo();\n return Object.assign(Object.assign({}, wasmStats), { cargoPackageName: (_b = (_a = release.wasm) === null || _a === void 0 ? void 0 : _a.cargoPackageName) !== null && _b !== void 0 ? _b : \"unknown\", cargoPackageVersion: (_d = (_c = release.wasm) === null || _c === void 0 ? void 0 : _c.cargoPackageVersion) !== null && _d !== void 0 ? _d : \"unknown\", rustcVersion: (_f = (_e = release.wasm) === null || _e === void 0 ? void 0 : _e.rustcVersion) !== null && _f !== void 0 ? _f : \"unknown\" });\n}\n/**\n * Get release information about the automerge library.\n *\n * Returns metadata about both the JavaScript wrapper and the WebAssembly\n * module, including git commit hashes. If js.gitHead !== wasm.gitHead,\n * the JS and WASM were built from different commits.\n *\n * If the WASM module has not been initialized, wasm will be null.\n */\nexport function releaseInfo() {\n let wasm = null;\n try {\n wasm = ApiHandler.wasmReleaseInfo();\n }\n catch (_a) {\n // WASM not initialized - leave as null\n }\n return {\n js: {\n gitHead: JS_GIT_HEAD,\n },\n wasm,\n };\n}\n/**\n * Modify a string\n *\n * @typeParam T - The type of the value contained in the document\n * @param doc - The document to modify\n * @param path - The path to the string to modify\n * @param index - The position (as a {@link Cursor} or index) to edit.\n * If a cursor is used then the edit happens such that the cursor will\n * now point to the end of the newText, so you can continue to reuse\n * the same cursor for multiple calls to splice.\n * @param del - The number of code units to delete, a positive number\n * deletes N characters after the cursor, a negative number deletes\n * N characters before the cursor.\n * @param newText - The string to insert (if any).\n */\nexport function splice(doc, path, index, del, newText) {\n const objPath = absoluteObjPath(doc, path, \"splice\");\n if (!_is_proxy(doc)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n const state = _state(doc, false);\n _clear_cache(doc);\n index = cursorToIndex(state, objPath, index);\n try {\n return state.handle.splice(objPath, index, del, newText);\n }\n catch (e) {\n throw new RangeError(`Cannot splice: ${e}`);\n }\n}\n/**\n * Update the value of a string\n *\n * @typeParam T - The type of the value contained in the document\n * @param doc - The document to modify\n * @param path - The path to the string to modify\n * @param newText - The new text to update the value to\n *\n * @remarks\n * This will calculate a diff between the current value and the new value and\n * then convert that diff into calls to {@link splice}. This will produce results\n * which don't merge as well as directly capturing the user input actions, but\n * sometimes it's not possible to capture user input and this is the best you\n * can do.\n *\n * This is an experimental API and may change in the future.\n *\n * @beta\n */\nexport function updateText(doc, path, newText) {\n const objPath = absoluteObjPath(doc, path, \"updateText\");\n if (!_is_proxy(doc)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n const state = _state(doc, false);\n _clear_cache(doc);\n try {\n return state.handle.updateText(objPath, newText);\n }\n catch (e) {\n throw new RangeError(`Cannot updateText: ${e}`);\n }\n}\n/**\n * Return the text + block markers at a given path\n *\n * @remarks\n * Rich text in automerge is represented as a sequence of characters with block\n * markers appearing inline with the text, and inline formatting spans overlaid\n * on the whole sequence. Block markers are normal automerge maps, but they are\n * only visible via either the {@link block} function or the {@link spans}\n * function. This function returns the current state of the spans\n */\nexport function spans(doc, path) {\n const state = _state(doc, false);\n const objPath = absoluteObjPath(doc, path, \"spans\");\n try {\n return state.handle.spans(objPath, state.heads);\n }\n catch (e) {\n throw new RangeError(`Cannot splice: ${e}`);\n }\n}\n/**\n * Get the block marker at the given index\n */\nexport function block(doc, path, index) {\n const objPath = absoluteObjPath(doc, path, \"splitBlock\");\n const state = _state(doc, false);\n index = cursorToIndex(state, objPath, index);\n try {\n return state.handle.getBlock(objPath, index);\n }\n catch (e) {\n throw new RangeError(`Cannot get block: ${e}`);\n }\n}\n/**\n * Insert a new block marker at the given index\n */\nexport function splitBlock(doc, path, index, block) {\n if (!_is_proxy(doc)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n const objPath = absoluteObjPath(doc, path, \"splitBlock\");\n const state = _state(doc, false);\n _clear_cache(doc);\n index = cursorToIndex(state, objPath, index);\n try {\n state.handle.splitBlock(objPath, index, block);\n }\n catch (e) {\n throw new RangeError(`Cannot splice: ${e}`);\n }\n}\n/**\n * Delete the block marker at the given index\n */\nexport function joinBlock(doc, path, index) {\n if (!_is_proxy(doc)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n const objPath = absoluteObjPath(doc, path, \"joinBlock\");\n const state = _state(doc, false);\n _clear_cache(doc);\n index = cursorToIndex(state, objPath, index);\n try {\n state.handle.joinBlock(objPath, index);\n }\n catch (e) {\n throw new RangeError(`Cannot joinBlock: ${e}`);\n }\n}\n/**\n * Update the block marker at the given index\n */\nexport function updateBlock(doc, path, index, block) {\n if (!_is_proxy(doc)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n const objPath = absoluteObjPath(doc, path, \"updateBlock\");\n const state = _state(doc, false);\n _clear_cache(doc);\n index = cursorToIndex(state, objPath, index);\n try {\n state.handle.updateBlock(objPath, index, block);\n }\n catch (e) {\n throw new RangeError(`Cannot updateBlock: ${e}`);\n }\n}\n/**\n * Update the spans at the given path\n *\n * @remarks\n * Like {@link updateText} this will diff `newSpans` against the current state\n * of the text at `path` and perform a reasonably minimal number of operations\n * required to update the spans to the new state.\n *\n * When updating spans, we need to know what to set the \"expand\" behavior of\n * newly created marks to. By default we set it to \"both\", meaning that the\n * spans will expand on either, but this can be overridden by passing\n * `{ defaultExpand: \"<expand>\"}` as the final `config` parameter. You\n * can also pass `{perMarkExpand: {\"<markname>\": \"<expand config>\"}` to\n * set the expand configuration for specific marks where it should be\n * different from the default.\n */\nexport function updateSpans(doc, path, newSpans, config) {\n if (!_is_proxy(doc)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n const objPath = absoluteObjPath(doc, path, \"updateSpans\");\n const state = _state(doc, false);\n _clear_cache(doc);\n try {\n state.handle.updateSpans(objPath, newSpans, config);\n }\n catch (e) {\n throw new RangeError(`Cannot updateSpans: ${e}`);\n }\n}\n/**\n * Returns a cursor for the given position in a string.\n *\n * @remarks\n * A cursor represents a relative position, \"before character X\",\n * rather than an absolute position. As the document is edited, the\n * cursor remains stable relative to its context, just as you'd expect\n * from a cursor in a concurrent text editor.\n *\n * The string representation is shareable, and so you can use this both\n * to edit the document yourself (using {@link splice}) or to share multiple\n * collaborator's current cursor positions over the network.\n *\n * The cursor's `position` can be an index in the string, `'start'` or `'end'`.\n * - `'start'` ensures this cursor always resolves to `0`\n * - `'end'` ensures this cursor always resolves to `string.length`\n *\n * Start cursors can be created by passing any negative number in `position`.\n *\n * End cursors can be created by passing a number `>= string.length` in `position`.\n *\n * `move` determines the position the cursor resolves to if the character at\n * `index` is removed:\n * - `'after'` causes the cursor to resolve towards `string.length`\n * - `'before'` causes the cursor to resolve towards `0`\n *\n * `move` is `'after'` by default.\n *\n * @typeParam T - The type of the value contained in the document\n * @param doc - The document\n * @param path - The path to the string\n * @param position - The position of the cursor, either an index, `'start'` or `'end'`\n * @param move - The direction the cursor should resolve to, defaults to 'after'\n */\nexport function getCursor(doc, path, position, move) {\n const objPath = absoluteObjPath(doc, path, \"getCursor\");\n const state = _state(doc, false);\n try {\n return state.handle.getCursor(objPath, position, state.heads, move);\n }\n catch (e) {\n throw new RangeError(`Cannot getCursor: ${e}`);\n }\n}\n/**\n * Returns the current index of the cursor.\n *\n * @typeParam T - The type of the value contained in the document\n *\n * @param doc - The document\n * @param path - The path to the string\n * @param index - The cursor\n */\nexport function getCursorPosition(doc, path, cursor) {\n const objPath = absoluteObjPath(doc, path, \"getCursorPosition\");\n const state = _state(doc, false);\n try {\n return state.handle.getCursorPosition(objPath, cursor, state.heads);\n }\n catch (e) {\n throw new RangeError(`Cannot getCursorPosition: ${e}`);\n }\n}\nexport function mark(doc, path, range, name, value) {\n const objPath = absoluteObjPath(doc, path, \"mark\");\n if (!_is_proxy(doc)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n const state = _state(doc, false);\n try {\n return state.handle.mark(objPath, range, name, value);\n }\n catch (e) {\n throw new RangeError(`Cannot mark: ${e}`);\n }\n}\nexport function unmark(doc, path, range, name) {\n const objPath = absoluteObjPath(doc, path, \"unmark\");\n if (!_is_proxy(doc)) {\n throw new RangeError(\"object cannot be modified outside of a change block\");\n }\n const state = _state(doc, false);\n try {\n return state.handle.unmark(objPath, range, name);\n }\n catch (e) {\n throw new RangeError(`Cannot unmark: ${e}`);\n }\n}\nexport function marks(doc, path) {\n const objPath = absoluteObjPath(doc, path, \"marks\");\n const state = _state(doc, false);\n try {\n return state.handle.marks(objPath);\n }\n catch (e) {\n throw new RangeError(`Cannot call marks(): ${e}`);\n }\n}\nexport function marksAt(doc, path, index) {\n const objPath = absoluteObjPath(doc, path, \"marksAt\");\n const state = _state(doc, false);\n try {\n return state.handle.marksAt(objPath, index);\n }\n catch (e) {\n throw new RangeError(`Cannot call marksAt(): ${e}`);\n }\n}\nfunction absoluteObjPath(doc, path, functionName) {\n path = path.slice();\n const objectId = _obj(doc);\n if (!objectId) {\n throw new RangeError(`invalid object for ${functionName}`);\n }\n path.unshift(objectId);\n return path.join(\"/\");\n}\n/**\n * @deprecated This method has been renamed to {@link isImmutableString}\n */\nexport const isRawString = isImmutableString;\n/**\n * @deprecated This type has been renamed to {@link ImmutableString}\n */\nexport const RawString = ImmutableString;\n/**\n * EXPERIMENTAL: save a bundle of changes from a document to an encoded form\n * @experimental\n * @param doc - The document containing the changes to save\n * @param hashes - The hashes of the changes to save to a bundle\n * @returns\n */\nexport function saveBundle(doc, hashes) {\n const state = _state(doc, false);\n return state.handle.saveBundle(hashes);\n}\n/**\n * Return the Automerge fragments currently covering the document history.\n *\n * Fragments are ordered oldest-to-newest. Passing a number returns only that\n * fragment level. Passing `{ start, end }` returns levels in the half-open range\n * `[start, end)`. Omitting `levels` returns all levels, including loose commits\n * at level 0.\n */\nexport function getFragmentMetadata(doc, levels) {\n const state = _state(doc, false);\n return state.handle.getFragmentMetadata(levels);\n}\n/**\n * Return a fragment by its head hash, or `null` if the hash is unknown or does\n * not identify an available fragment.\n */\nexport function getFragmentMeta(doc, head) {\n const state = _state(doc, false);\n return state.handle.getFragmentMeta(head);\n}\n/**\n * Encode fragments as the blob bytes expected by Subduction's `addFragments`\n * path. Level-0 fragments are encoded as individual Automerge changes; higher\n * level fragments are encoded as Automerge bundles.\n */\nexport function bundleFragmentMetadata(doc, fragments) {\n const state = _state(doc, false);\n return state.handle.bundleFragmentMetadata(fragments);\n}\n/**\n * Return level-0 fragments in the object shape expected by Subduction's\n * `addCommits` path.\n */\nexport function getCommits(doc) {\n const state = _state(doc, false);\n const commits = state.handle.getFragmentMetadata(0);\n const bytes = state.handle.bundleFragmentMetadata(commits);\n return commits.map((fragment, index) => ({\n head: fragment.head,\n parents: fragment.boundary,\n bytes: bytes[index],\n }));\n}\n/**\n * Return bundled Automerge fragments in the object shape expected by\n * Subduction's `addFragments` path. By default this excludes level-0 loose\n * commits; use {@link getCommits} for those.\n */\nexport function getFragments(doc, levels) {\n const state = _state(doc, false);\n const fragmentMetadata = state.handle.getFragmentMetadata(levels !== null && levels !== void 0 ? levels : { start: 1 });\n const bytes = state.handle.bundleFragmentMetadata(fragmentMetadata);\n return fragmentMetadata.map((fragment, index) => (Object.assign(Object.assign({}, fragment), { bytes: bytes[index] })));\n}\n/**\n * Add commit-shaped Automerge changes to a document.\n *\n * This mirrors Subduction's `addCommits` shape: each input carries the commit\n * head, its parents, and the encoded change bytes. The encoded bytes are\n * authoritative and are checked against the supplied metadata.\n */\nexport function addCommits(doc, commits, opts) {\n const state = _state(doc);\n if (!opts) {\n opts = {};\n }\n if (state.heads) {\n throw new RangeError(\"Attempting to change an outdated document. Use Automerge.clone() if you wish to make a writable copy.\");\n }\n if (_is_proxy(doc)) {\n throw new RangeError(\"Calls to Automerge.change cannot be nested\");\n }\n const heads = state.handle.getHeads();\n state.handle.addCommits(commits);\n state.heads = heads;\n return progressDocument(doc, \"addCommits\", heads, opts.patchCallback || state.patchCallback);\n}\n/**\n * Add fragment-shaped Automerge bundles to a document.\n *\n * This mirrors Subduction's `addFragments` shape: each input contains fragment\n * metadata plus encoded bytes from {@link bundleFragmentMetadata}. Fragment bytes are\n * loaded incrementally, so this can ingest bundles and loose level-0 changes.\n */\nexport function addFragments(doc, fragments, opts) {\n const state = _state(doc);\n if (!opts) {\n opts = {};\n }\n if (state.heads) {\n throw new RangeError(\"Attempting to change an outdated document. Use Automerge.clone() if you wish to make a writable copy.\");\n }\n if (_is_proxy(doc)) {\n throw new RangeError(\"Calls to Automerge.change cannot be nested\");\n }\n const heads = state.handle.getHeads();\n state.handle.addFragments(fragments);\n state.heads = heads;\n return progressDocument(doc, \"addFragments\", heads, opts.patchCallback || state.patchCallback);\n}\n/**\n * EXPERIMENTAL: Load a bundle of changes to examine them\n * @experimental\n * @param bundle - The encoded bundle to read\n */\nexport function readBundle(bundle) {\n return ApiHandler.readBundle(bundle);\n}\n", "import type { DocHandleChangePayload } from \"@automerge/automerge-repo/slim\"\nimport { applyPatches } from \"@automerge/automerge/slim\"\n\n/**\n * convert automerge patches to solid producer operations\n * @param payload the\n * [DocHandleChangePayload](https://automerge.org/automerge-repo/interfaces/_automerge_automerge_repo.DocHandleChangePayload.html)\n * from the handle.on(\"change\n * @returns a callback for an immer-like function. e.g.\n * [produce](https://docs.solidjs.com/reference/store-utilities/produce) for\n * [Solid\n * Stores](https://docs.solidjs.com/reference/store-utilities/create-store)\n */\nexport default function autoproduce<T>(\n payload: DocHandleChangePayload<T>\n): (doc: T) => void {\n return (doc: T) => applyPatches(doc, payload.patches)\n}\n", "import { onCleanup } from \"solid-js\"\nimport type {\n Doc,\n DocHandle,\n DocHandleChangePayload,\n UrlHeads,\n} from \"@automerge/automerge-repo/slim\"\nimport autoproduce from \"./autoproduce.js\"\nimport { createStore, produce, reconcile, type Store } from \"solid-js/store\"\nimport { applyPatches } from \"@automerge/automerge/slim\"\n\nconst cache = new WeakMap<\n DocHandle<unknown>,\n {\n refs: number\n store: Store<Doc<unknown>>\n cleanup(): void\n }\n>()\n\nfunction initial<T>(handle: DocHandle<T>): T {\n const template = {} as T\n applyPatches(template, handle.diff([] as unknown as UrlHeads, handle.heads()))\n return template\n}\n\n/**\n * make a fine-grained live view of a document from its handle.\n * @param handle an Automerge\n * [DocHandle](https://automerge.org/automerge-repo/classes/_automerge_automerge_repo.DocHandle.html)\n */\nexport default function makeDocumentProjection<T extends object>(\n handle: DocHandle<T>\n): Doc<T> {\n onCleanup(() => {\n const item = cache.get(handle)!\n if (!item) return\n if (!item.refs--) {\n item.cleanup()\n }\n })\n\n if (cache.has(handle)) {\n const item = cache.get(handle)!\n item.refs++\n return item.store as T\n }\n\n const [doc, set] = createStore<T>(initial(handle))\n\n cache.set(handle, {\n refs: 0,\n store: doc,\n cleanup() {\n handle.off(\"change\", patch)\n handle.off(\"delete\", ondelete)\n // https://github.com/chee/solid-automerge/pull/5\n cache.delete(handle)\n },\n })\n\n function patch(payload: DocHandleChangePayload<T>) {\n // `scopeReplaced` flags a wholesale change at/above a sub-document handle\n if (payload.scopeReplaced) {\n set(reconcile((payload.doc ?? {}) as T))\n return\n }\n set(produce(autoproduce(payload)))\n }\n\n function ondelete() {\n set(reconcile({} as T))\n }\n\n handle.on(\"change\", patch)\n handle.on(\"delete\", ondelete)\n\n return doc\n}\n", "import { createMemo, type Accessor } from \"solid-js\"\nimport { type DocHandle, type Doc } from \"@automerge/automerge-repo/slim\"\nimport makeDocumentProjection from \"./makeDocumentProjection.js\"\n\n/**\n * get a fine-grained live view of a document from a handle. works with\n * {@link useDocHandle}.\n * @param handle an accessor (signal/resource) of a\n * [DocHandle](https://automerge.org/automerge-repo/classes/_automerge_automerge_repo.DocHandle.html)\n */\nexport default function createDocumentProjection<T extends object>(\n handle: Accessor<DocHandle<T> | undefined>\n): Accessor<Doc<T> | undefined> {\n const projection = createMemo<Doc<T> | undefined>(() => {\n const unwrappedHandle = typeof handle == \"function\" ? handle() : handle\n return unwrappedHandle && makeDocumentProjection<T>(unwrappedHandle)\n })\n return projection\n}\n", "import type { Repo } from \"@automerge/automerge-repo/slim\"\nimport { createContext, type Context } from \"solid-js\"\n\n/**\n * a [context](https://docs.solidjs.com/concepts/context) that provides access\n * to an Automerge Repo. you don't need this, you can pass the repo in the\n * second arg to the functions that need it.\n */\nexport const RepoContext: Context<Repo | null> = createContext<Repo | null>(\n null\n)\n", "import type { AutomergeUrl, DocHandle } from \"@automerge/automerge-repo/slim\"\nimport {\n createEffect,\n createResource,\n useContext,\n type Resource,\n} from \"solid-js\"\nimport { RepoContext } from \"./context.js\"\nimport type { MaybeAccessor, UseDocHandleOptions } from \"./types.js\"\n\n/**\n * get a\n * [DocHandle](https://automerge.org/automerge-repo/classes/_automerge_automerge_repo.DocHandle.html)\n * from an\n * [AutomergeUrl](https://automerge.org/automerge-repo/types/_automerge_automerge_repo.AutomergeUrl.html)\n * as a\n * [Resource](https://docs.solidjs.com/reference/basic-reactivity/create-resource).\n * Waits for the handle to be ready.\n */\nexport default function useDocHandle<T>(\n url: MaybeAccessor<AutomergeUrl | undefined>,\n options?: UseDocHandleOptions\n): Resource<DocHandle<T> | undefined> {\n const contextRepo = useContext(RepoContext)\n\n if (!options?.repo && !contextRepo) {\n throw new Error(\"use outside <RepoContext> requires options.repo\")\n }\n\n const repo = (options?.repo || contextRepo)!\n\n function getExistingHandle() {\n if (options?.[\"~skipInitialValue\"]) return undefined\n const unwrappedURL = typeof url == \"function\" ? url() : url\n if (!unwrappedURL) return undefined\n const state = repo.findWithProgress<T>(unwrappedURL).peek()\n return state.state === \"ready\" ? state.handle : undefined\n }\n\n const [handle, { mutate }] = createResource(\n url,\n url => repo.findWithProgress<T>(url).whenReady(),\n {\n initialValue: getExistingHandle(),\n }\n )\n\n createEffect(() => {\n const unwrappedURL = typeof url == \"function\" ? url() : url\n if (!unwrappedURL) {\n mutate()\n }\n })\n\n return handle\n}\n", "import type {\n AutomergeUrl,\n Doc,\n DocHandle,\n} from \"@automerge/automerge-repo/slim\"\nimport createDocumentProjection from \"./createDocumentProjection.js\"\nimport useDocHandle from \"./useDocHandle.js\"\nimport type { MaybeAccessor, UseDocHandleOptions } from \"./types.js\"\nimport type { Accessor, Resource } from \"solid-js\"\n\n/**\n * get a fine-grained live view of a document, and its handle, from a URL.\n * @param url a function that returns a url\n */\nexport default function useDocument<T extends object>(\n url: MaybeAccessor<AutomergeUrl | undefined>,\n options?: UseDocHandleOptions\n): [Accessor<Doc<T> | undefined>, Resource<DocHandle<T> | undefined>] {\n const handle = useDocHandle<T>(url, options)\n return [createDocumentProjection<T>(handle), handle] as const\n}\n", "import { onCleanup, type Accessor } from \"solid-js\"\nimport { createSignal } from \"solid-js\"\nimport type { Doc, DocHandle } from \"@automerge/automerge-repo/slim\"\n\n/**\n * a light coarse-grained primitive when you care only _that_ a doc has changed,\n * and not _how_.\n * @param handle an Automerge\n * [DocHandle](https://automerge.org/automerge-repo/classes/_automerge_automerge_repo.DocHandle.html)\n */\nexport default function makeDocSignal<T extends object>(\n handle: DocHandle<T>\n): Accessor<Doc<T> | undefined> {\n const [signal, setSignal] = createSignal<Doc<T> | undefined>(handle.doc())\n\n function update() {\n setSignal(() => handle.doc() as Doc<T> | undefined)\n }\n\n handle.on(\"change\", update)\n onCleanup(() => handle.off(\"change\", update))\n\n return signal\n}\n", "import { createEffect, onCleanup, type Accessor } from \"solid-js\"\nimport { createSignal } from \"solid-js\"\nimport type { Doc, DocHandle } from \"@automerge/automerge-repo/slim\"\n\n/**\n * a light coarse-grained primitive when you care only _that_ a doc has changed,\n * and not _how_. works with {@link useDocHandle}.\n * @param handle an accessor (signal/resource) of a\n * [DocHandle](https://automerge.org/automerge-repo/classes/_automerge_automerge_repo.DocHandle.html)\n */\nexport default function createDocSignal<T extends object>(\n handle: Accessor<DocHandle<T> | undefined>\n): Accessor<Doc<T> | undefined> {\n const [signal, setSignal] = createSignal<Doc<T> | undefined>(handle()?.doc())\n\n createEffect(() => {\n const h = handle()\n\n function update() {\n setSignal(() => h?.doc() as Doc<T> | undefined)\n }\n\n // sync the signal with the current handle's doc\n update()\n\n if (h) {\n h.on(\"change\", update)\n onCleanup(() => h.off(\"change\", update))\n }\n })\n\n return signal\n}\n", "import type {\n AutomergeUrl,\n Doc,\n DocHandle,\n} from \"@automerge/automerge-repo/slim\"\nimport useDocHandle from \"./useDocHandle.js\"\nimport createDocSignal from \"./createDocSignal.js\"\nimport type { MaybeAccessor, UseDocHandleOptions } from \"./types.js\"\nimport type { Accessor, Resource } from \"solid-js\"\n\n/**\n * a light coarse-grained primitive when you care only _that_ a doc has changed,\n * and not _how_. returns [doc, handle] from a URL.\n * @param url a function that returns a url\n */\nexport default function useDocSignal<T extends object>(\n url: MaybeAccessor<AutomergeUrl | undefined>,\n options?: UseDocHandleOptions\n): [Accessor<Doc<T> | undefined>, Resource<DocHandle<T> | undefined>] {\n const handle = useDocHandle<T>(url, options)\n return [createDocSignal<T>(handle), handle] as const\n}\n", "import type { Repo } from \"@automerge/automerge-repo/slim\"\nimport { RepoContext } from \"./context.js\"\nimport { useContext } from \"solid-js\"\n\n/** grab the repo from the {@link RepoContext} */\nexport default function useRepo(): Repo {\n const repo = useContext(RepoContext)\n if (!repo) throw new Error(\"Please wrap me in a <RepoContext value={repo}>\")\n return repo\n}\n", "/**\n * Open a streaming subscription. Dispatches a `patchwork:subscribe` for the\n * given `selector` carrying a fresh `MessageChannel` port; the answering\n * provider pushes values back over that channel for as long as the\n * subscription is live. `listener` is invoked once per emission (the first\n * delivery is always async because `MessagePort.postMessage` queues a task).\n *\n * The event is dispatched from the nearest enclosing `<patchwork-view>` so\n * callers can pass any node inside a provider subtree. An unclaimed\n * subscription is never settled: if no provider answers, `listener` simply\n * never fires.\n *\n * Returns an unsubscribe function. Calling it tells the provider to tear down\n * (via an `unsubscribe` message) and closes the consumer's port; any values\n * the provider emits after that are dropped.\n */\nexport function subscribe(element, selector, listener) {\n const view = element.closest(\"patchwork-view\");\n const dispatchEl = view ?? element;\n const channel = new MessageChannel();\n const port = channel.port2;\n const controller = new AbortController();\n const { signal } = controller;\n port.addEventListener(\"message\", (event) => {\n if (event.data?.type === \"change\")\n listener(event.data.value);\n }, { signal });\n // addEventListener (unlike assigning onmessage) does not implicitly start\n // the port, so message delivery has to be kicked off explicitly.\n port.start();\n const detail = {\n selector,\n port: channel.port1,\n };\n dispatchEl.dispatchEvent(new CustomEvent(\"patchwork:subscribe\", {\n detail,\n bubbles: true,\n composed: true,\n }));\n return () => {\n if (signal.aborted)\n return;\n controller.abort();\n port.postMessage({ type: \"unsubscribe\" });\n port.close();\n };\n}\n/**\n * Answer a `patchwork:subscribe`. The `producer` receives a `respond`\n * callback it can call any number of times to push values to the consumer,\n * and may return a teardown that runs when the consumer unsubscribes. Stops\n * propagation so ancestor providers don't double-answer. Values emitted after\n * the consumer unsubscribes are dropped.\n */\nexport function accept(event, producer) {\n event.stopPropagation();\n const port = event.detail.port;\n let alive = true;\n const respond = (value) => {\n if (!alive)\n return;\n port.postMessage({ type: \"change\", value });\n };\n let teardown;\n try {\n teardown = producer(respond);\n }\n catch (err) {\n console.error(\"[patchwork-providers] subscribe producer threw:\", err);\n }\n const stop = () => {\n if (!alive)\n return;\n alive = false;\n try {\n teardown?.();\n }\n catch (err) {\n console.error(\"[patchwork-providers] subscribe teardown threw:\", err);\n }\n port.close();\n };\n port.onmessage = (event) => {\n if (event.data?.type === \"unsubscribe\")\n stop();\n };\n}\n/**\n * One-shot convenience wrapper over {@link subscribe}: opens a subscription\n * for `selector`, resolves with the first value a provider emits, then\n * immediately unsubscribes. Because there is no fallback provider, an\n * unclaimed selector never resolves \u2014 use `subscribe` directly if you need to\n * handle the \"no provider\" case.\n */\nexport function request(element, selector) {\n return new Promise((resolve) => {\n const unsubscribe = subscribe(element, selector, (value) => {\n // The first emission is always async (postMessage queues a task), so\n // `unsubscribe` is assigned by the time this fires.\n unsubscribe();\n resolve(value);\n });\n });\n}\nexport { registerRepoProviderElement, } from \"./repo-provider.js\";\n", "import { createUniqueId, untrack } from \"solid-js\";\nimport { isServer, isDev } from \"solid-js/web\";\nimport { reconcile } from \"solid-js/store\";\nexport function makePersisted(signal, options = {}) {\n const storage = options.storage || globalThis.localStorage;\n const name = options.name || `storage-${createUniqueId()}`;\n if (!storage) {\n return Object.assign(signal, { 2: null });\n }\n const storageOptions = options.storageOptions;\n const serialize = options.serialize || JSON.stringify.bind(JSON);\n const deserialize = options.deserialize || JSON.parse.bind(JSON);\n const init = storage.getItem(name, storageOptions);\n const set = typeof signal[0] === \"function\"\n ? (data) => {\n try {\n const value = deserialize(data);\n signal[1](() => value);\n }\n catch (e) {\n // eslint-disable-next-line no-console\n if (isDev)\n console.warn(e);\n }\n }\n : (data) => {\n try {\n const value = deserialize(data);\n signal[1](reconcile(value));\n }\n catch (e) {\n // eslint-disable-next-line no-console\n if (isDev)\n console.warn(e);\n }\n };\n let unchanged = true;\n if (init instanceof Promise)\n init.then(data => unchanged && data && set(data));\n else if (init)\n set(init);\n if (typeof options.sync?.[0] === \"function\") {\n const get = typeof signal[0] === \"function\" ? signal[0] : () => signal[0];\n options.sync[0]((data) => {\n if (data.key !== name ||\n (!isServer && (data.url || globalThis.location.href) !== globalThis.location.href) ||\n data.newValue === serialize(untrack(get))) {\n return;\n }\n set(data.newValue);\n });\n }\n return Object.assign([], signal, {\n 1: typeof signal[0] === \"function\"\n ? (value) => {\n const output = signal[1](value);\n const serialized = value != null ? serialize(output) : value;\n options.sync?.[1](name, serialized);\n if (serialized != null)\n storage.setItem(name, serialized, storageOptions);\n else\n storage.removeItem(name, storageOptions);\n unchanged = false;\n return output;\n }\n : (...args) => {\n signal[1](...args);\n const value = untrack(() => serialize(signal[0]));\n options.sync?.[1](name, value);\n storage.setItem(name, value, storageOptions);\n unchanged = false;\n },\n 2: init,\n });\n}\n/**\n * storageSync - synchronize localStorage\n * This does only work for { storage: localStorage }.\n * If you wish to use e.g. cookieStorage, you may use a different sync method\n */\nexport const storageSync = [\n (subscriber) => window.addEventListener(\"storage\", ev => subscriber(ev)),\n () => {\n /*storage already sends events fulfilling the PersistenceSyncData<T> conditions*/\n },\n];\n/**\n * messageSync - synchronize over post message or broadcast channel API\n */\nexport const messageSync = (channel = window) => [\n (subscriber) => channel.addEventListener(\"message\", ev => {\n subscriber(ev.data);\n }),\n (key, newValue) => channel.postMessage({ key, newValue, timeStamp: +new Date(), url: location.href }, location.origin),\n];\n/**\n * wsSync - syncronize persisted storage via web socket\n */\nexport const wsSync = (ws, warnOnError = isDev) => [\n (subscriber) => ws.addEventListener(\"message\", (ev) => {\n try {\n const data = JSON.parse(ev.data);\n if ([\"key\", \"newValue\", \"timeStamp\"].every(item => Object.hasOwn(data, item))) {\n subscriber(data);\n }\n }\n catch (e) {\n // eslint-disable-next-line no-console\n if (warnOnError)\n console.warn(e);\n }\n }),\n (key, newValue) => ws.send(JSON.stringify({\n key,\n newValue,\n timeStamp: +new Date(),\n ...(isServer ? {} : { url: location.href }),\n })),\n];\n/**\n * multiplex arbitrary sync APIs\n *\n * ```ts\n * makePersisted(createSignal(0), { sync: multiplexSync(messageSync(bc), wsSync(ws)) })\n * ```\n */\nexport const multiplexSync = (...syncAPIs) => [\n subscriber => syncAPIs.forEach(([subscribe]) => subscribe(subscriber)),\n (key, value) => syncAPIs.forEach(([_, updater]) => updater(key, value)),\n];\n", "import { createEffect, createSignal, on } from \"solid-js\";\n\n/**\n * The localStorage keys for persisted sidebar state. Defined here, the canonical\n * sidebar-persistence module, and imported wherever sidebar state is read/written\n * (e.g. the isolated document-area root seeds + persists the right-sidebar keys),\n * so the key strings live in exactly one place.\n */\nexport const SIDEBAR_KEYS = {\n leftCollapsed: \"patchwork:leftSidebarCollapsed\",\n rightCollapsed: \"patchwork:rightSidebarCollapsed\",\n leftWidth: \"patchwork:leftSidebarWidth\",\n rightWidth: \"patchwork:rightSidebarWidth\",\n contextToolId: \"patchwork:contextSidebarToolId\",\n} as const;\n\n/**\n * DOM event (dispatched on `window`) asking the context (right) sidebar to\n * collapse. The left sidebar is host-owned and collapsed directly, but the\n * right-sidebar collapse state lives inside `DocumentAreaRoot` (so it survives\n * the isolation boundary), so the host signals it out-of-band through this event.\n */\nexport const COLLAPSE_CONTEXT_SIDEBAR_EVENT =\n \"patchwork:collapse-context-sidebar\";\n\n/** Default sidebar width (px) when nothing is persisted. */\nexport const DEFAULT_SIDEBAR_WIDTH = 400;\n\n/**\n * Reads a number from localStorage with a default fallback\n */\nexport function getStoredNumber(key: string, defaultValue: number): number {\n const stored = localStorage.getItem(key);\n return stored ? parseInt(stored, 10) : defaultValue;\n}\n\n/**\n * Reads a boolean from localStorage (returns true if value is \"true\")\n */\nexport function getStoredBoolean(key: string): boolean {\n return localStorage.getItem(key) === \"true\";\n}\n\n/**\n * Manages sidebar collapse and width state with localStorage persistence\n */\nexport function useSidebarState() {\n // Sidebar collapse state with localStorage persistence\n const [isSidebarCollapsed, setIsSidebarCollapsed] = createSignal(\n getStoredBoolean(SIDEBAR_KEYS.leftCollapsed)\n );\n const [isRightSidebarCollapsed, setIsRightSidebarCollapsed] = createSignal(\n getStoredBoolean(SIDEBAR_KEYS.rightCollapsed)\n );\n\n // Resizable sidebar width state with localStorage persistence\n const [leftSidebarWidth, setLeftSidebarWidth] = createSignal(\n getStoredNumber(SIDEBAR_KEYS.leftWidth, DEFAULT_SIDEBAR_WIDTH)\n );\n const [rightSidebarWidth, setRightSidebarWidth] = createSignal(\n getStoredNumber(SIDEBAR_KEYS.rightWidth, DEFAULT_SIDEBAR_WIDTH)\n );\n\n // Persist each sidebar state to localStorage independently\n createEffect(\n on(isSidebarCollapsed, (value) => {\n localStorage.setItem(SIDEBAR_KEYS.leftCollapsed, String(value));\n })\n );\n\n createEffect(\n on(isRightSidebarCollapsed, (value) => {\n localStorage.setItem(SIDEBAR_KEYS.rightCollapsed, String(value));\n })\n );\n\n createEffect(\n on(leftSidebarWidth, (value) => {\n localStorage.setItem(SIDEBAR_KEYS.leftWidth, String(value));\n })\n );\n\n createEffect(\n on(rightSidebarWidth, (value) => {\n localStorage.setItem(SIDEBAR_KEYS.rightWidth, String(value));\n })\n );\n\n return {\n isSidebarCollapsed,\n setIsSidebarCollapsed,\n isRightSidebarCollapsed,\n setIsRightSidebarCollapsed,\n leftSidebarWidth,\n setLeftSidebarWidth,\n rightSidebarWidth,\n setRightSidebarWidth,\n };\n}\n", "import { onCleanup, onMount } from \"solid-js\";\nimport type { Setter } from \"solid-js\";\n\ninterface UseSidebarResizeParams {\n setLeftSidebarWidth: Setter<number>;\n setRightSidebarWidth: Setter<number>;\n setIsSidebarCollapsed: Setter<boolean>;\n setIsRightSidebarCollapsed: Setter<boolean>;\n isLeftCollapsed: () => boolean;\n isRightCollapsed: () => boolean;\n minWidth: number;\n maxWidth: number;\n /** Drag narrower than this and the sidebar snaps closed (and re-opens once\n * dragged back out past it). */\n autoCloseWidth: number;\n dragThreshold: number;\n}\n\n/**\n * Manages sidebar resize and toggle interactions\n */\nexport function useSidebarResize({\n setLeftSidebarWidth,\n setRightSidebarWidth,\n setIsSidebarCollapsed,\n setIsRightSidebarCollapsed,\n isLeftCollapsed,\n isRightCollapsed,\n minWidth,\n maxWidth,\n autoCloseWidth,\n dragThreshold,\n}: UseSidebarResizeParams) {\n // Non-reactive refs for drag state\n let isResizing: \"left\" | \"right\" | null = null;\n let dragStartPos: { x: number; y: number } | null = null;\n let hasDragged = false;\n // The last *open* width applied during the live drag (null while the drag is\n // previewing a collapse). Read on release to decide whether to spring back.\n let lastDragWidth: number | null = null;\n\n const setWidth = (side: \"left\" | \"right\", w: number) =>\n side === \"left\" ? setLeftSidebarWidth(w) : setRightSidebarWidth(w);\n\n const setCollapsed = (side: \"left\" | \"right\", value: boolean) =>\n side === \"left\"\n ? setIsSidebarCollapsed(value)\n : setIsRightSidebarCollapsed(value);\n\n const isCollapsed = (side: \"left\" | \"right\") =>\n side === \"left\" ? isLeftCollapsed() : isRightCollapsed();\n\n // Apply a candidate width from a live drag. The panel tracks the pointer to\n // *any* size (Things 3 / nextaction feel) - it is allowed below `minWidth` so\n // you can see it shrink past the limit; the over-shrink is rejected later, on\n // release (see `settleDrag`). Below the auto-close threshold it snaps shut\n // live (so it reads as \"let go here and it stays closed\", and so the collapsed\n // 1px strip can be grabbed and dragged back open).\n const applyDragWidth = (side: \"left\" | \"right\", raw: number) => {\n if (raw < autoCloseWidth) {\n if (!isCollapsed(side)) setCollapsed(side, true);\n lastDragWidth = null;\n return;\n }\n if (isCollapsed(side)) setCollapsed(side, false);\n const w = Math.min(maxWidth, raw);\n setWidth(side, w);\n lastDragWidth = w;\n };\n\n // Decide the resting state when a drag ends. The width transition is live\n // again by now (the resizing flag was cleared in `endDrag`), so any width we\n // set here animates: if the drag finished too small (in the [auto-close, min)\n // band) the panel springs back out to `minWidth`; if it finished below\n // auto-close it already snapped collapsed during the drag, so we leave it.\n const settleDrag = (side: \"left\" | \"right\") => {\n if (isCollapsed(side)) return;\n if (lastDragWidth !== null && lastDragWidth < minWidth) {\n setWidth(side, minWidth);\n }\n };\n\n // A full-window overlay, added the moment a real drag begins. It keeps every\n // pointer event (and the resize cursor) on the parent document even as the\n // cursor passes over a tool iframe - otherwise the iframe swallows the\n // mousemove/mouseup and the drag can never end (\"you can't let go\"). It's\n // added lazily (not on mousedown) so a plain click still lands on the handle\n // and toggles collapse.\n let dragOverlay: HTMLDivElement | null = null;\n\n const beginDragVisuals = (side: \"left\" | \"right\") => {\n // suppress the width transition so the panel tracks the pointer 1:1, and tag\n // which side is dragging so the divider glow can extend up through the top\n // bar on that side (see `[data-sidebar-resizing]` rules in the stylesheet).\n document.body.setAttribute(\"data-sidebar-resizing\", side);\n dragOverlay = document.createElement(\"div\");\n dragOverlay.style.cssText =\n \"position:fixed;inset:0;z-index:2147483647;cursor:col-resize;\";\n document.body.appendChild(dragOverlay);\n };\n\n const endDrag = () => {\n isResizing = null;\n dragStartPos = null;\n document.body.style.userSelect = \"\";\n document.body.removeAttribute(\"data-sidebar-resizing\");\n dragOverlay?.remove();\n dragOverlay = null;\n };\n\n const handleMouseDown = (side: \"left\" | \"right\", e: MouseEvent) => {\n e.preventDefault();\n dragStartPos = { x: e.clientX, y: e.clientY };\n hasDragged = false;\n lastDragWidth = null;\n isResizing = side;\n document.body.style.userSelect = \"none\";\n };\n\n const handleMouseUp = () => {\n // Capture the drag state before endDrag() clears it, then resolve the\n // resting size with the width transition restored so spring-backs animate.\n const side = isResizing;\n const dragged = hasDragged;\n endDrag();\n if (side && dragged) settleDrag(side);\n };\n\n const handleMouseMove = (e: MouseEvent) => {\n if (!isResizing || !dragStartPos) return;\n\n // Once past the threshold this is a drag: drop the overlay in now, before\n // the cursor can reach any iframe, and suppress the width transition.\n const deltaX = Math.abs(e.clientX - dragStartPos.x);\n const deltaY = Math.abs(e.clientY - dragStartPos.y);\n if (!hasDragged && (deltaX > dragThreshold || deltaY > dragThreshold)) {\n hasDragged = true;\n beginDragVisuals(isResizing);\n }\n\n if (isResizing === \"left\") {\n applyDragWidth(\"left\", e.clientX);\n } else if (isResizing === \"right\") {\n applyDragWidth(\"right\", window.innerWidth - e.clientX);\n }\n };\n\n const handleToggleClick = (side: \"left\" | \"right\", e: MouseEvent) => {\n // Only toggle if we didn't drag\n if (hasDragged) {\n e.preventDefault();\n e.stopPropagation();\n // Reset the flag for next interaction\n hasDragged = false;\n return;\n }\n\n if (side === \"left\") {\n setIsSidebarCollapsed((prev) => !prev);\n } else {\n setIsRightSidebarCollapsed((prev) => !prev);\n }\n };\n\n onMount(() => {\n document.addEventListener(\"mousemove\", handleMouseMove);\n document.addEventListener(\"mouseup\", handleMouseUp);\n onCleanup(() => {\n document.removeEventListener(\"mousemove\", handleMouseMove);\n document.removeEventListener(\"mouseup\", handleMouseUp);\n // Reset body styles if component unmounts during drag\n if (isResizing) {\n endDrag();\n }\n });\n });\n\n return {\n handleMouseDown,\n handleToggleClick,\n };\n}\n", "import {\n createEffect,\n createSignal,\n onCleanup,\n type Accessor,\n} from \"solid-js\";\n\n/**\n * Tracks whether a `<patchwork-view>` provider has dispatched its\n * `patchwork:mounted` event yet, so callers can gate consumers that fire\n * `patchwork:request` events on the host listener being attached.\n *\n * The caller owns the element binding (typically a signal). Pass an accessor\n * that returns the current element; the effect re-runs whenever that element\n * changes and rewires the listener.\n */\nexport const useProviderReady = (\n componentId: string,\n element: Accessor<HTMLElement | undefined>\n): Accessor<boolean> => {\n const [isReady, setReady] = createSignal(false);\n\n createEffect(() => {\n const el = element();\n if (!el) return;\n setReady(false);\n const onMounted = (event: Event) => {\n const detail = (event as CustomEvent<{ componentId?: string }>).detail;\n if (detail?.componentId !== componentId) return;\n setReady(true);\n };\n el.addEventListener(\"patchwork:mounted\", onMounted);\n onCleanup(() => el.removeEventListener(\"patchwork:mounted\", onMounted));\n });\n\n return isReady;\n};\n", "import {\n createEffect,\n createSignal,\n onCleanup,\n type Accessor,\n} from \"solid-js\";\n\n// Safety net for the \"failed to mount\" case: a tool whose module throws sets\n// the view's internal state to \"error\" without dispatching any settling event,\n// so without this the sidebar would suspend forever. Long enough that a slow\n// (but healthy) load still wins the race and settles via its real event.\nconst MOUNT_TIMEOUT_MS = 5000;\n\n/**\n * Tracks whether the main document `<patchwork-view>` has settled *at least\n * once* \u2014 either it dispatched `patchwork:mounted` (a tool rendered) or\n * `patchwork:no-tool` (no tool could be resolved). Used to defer the sidebar\n * widgets until the main column has loaded, so the primary document wins the\n * initial render race.\n *\n * The result LATCHES: once true it stays true. We only want to win the *first*\n * render race \u2014 re-suspending on every later doc switch would tear down and\n * rebuild the widgets each time. So once settled we stop listening and never go\n * back to false.\n *\n * Both events bubble, so we listen on a stable container that wraps the view.\n * Events are filtered by url so a sidebar widget mounting inside the same\n * container can't settle us early.\n *\n * A timeout backs the explicit \"failed to mount\" case (see MOUNT_TIMEOUT_MS):\n * the view's error path emits no event, so without a fallback the widgets would\n * never appear.\n */\nexport const useMainDocMounted = (\n element: Accessor<HTMLElement | undefined>,\n docUrl: Accessor<string | undefined>\n): Accessor<boolean> => {\n const [isMounted, setMounted] = createSignal(false);\n\n createEffect(() => {\n // Latched: stop watching (and stop re-arming the timeout) once settled.\n if (isMounted()) return;\n const el = element();\n const url = docUrl();\n if (!el || !url) return;\n\n const onSettled = (event: Event) => {\n const detail = (event as CustomEvent<{ url?: string }>).detail;\n // `patchwork:mounted` for a doc view carries the url; ignore events for\n // other documents that happen to bubble through this container.\n if (detail?.url && detail.url !== url) return;\n setMounted(true);\n };\n\n el.addEventListener(\"patchwork:mounted\", onSettled);\n el.addEventListener(\"patchwork:no-tool\", onSettled);\n const timer = setTimeout(() => setMounted(true), MOUNT_TIMEOUT_MS);\n\n onCleanup(() => {\n el.removeEventListener(\"patchwork:mounted\", onSettled);\n el.removeEventListener(\"patchwork:no-tool\", onSettled);\n clearTimeout(timer);\n });\n });\n\n return isMounted;\n};\n", "import {\n getRegistry,\n type ToolDescription,\n} from \"@inkandswitch/patchwork-plugins\";\nimport { createMemo, createSignal, onCleanup, type Accessor } from \"solid-js\";\n\nexport type TaggedComponent = {\n id: string;\n name: string;\n icon?: string;\n};\n\n/**\n * Live, registry-driven list of every `patchwork:component` carrying `tag`\n * (e.g. `\"context-tool\"` or `\"system-tray\"`), sorted by name. Replaces the old\n * model of a per-account configured array of ids: a component just declares\n * its tag and shows up everywhere that tag is rendered, with no curation step\n * and nothing to migrate.\n *\n * Reactive to the registry's `\"changed\"` event, so a late-registering or\n * hot-reloaded plugin appears without a remount. Safe to call from inside the\n * isolated iframe realm too \u2014 it mounts the same plugin set as the host (see\n * `registry.start` in `isolation/src/boot/iframe/main.ts`), so each realm\n * resolves its own local, equivalent list.\n */\nexport function useTaggedComponents(tag: string): Accessor<TaggedComponent[]> {\n const registry = getRegistry<ToolDescription>(\"patchwork:component\");\n\n const [version, setVersion] = createSignal(0);\n const off = registry.on(\"changed\", () => setVersion((v) => v + 1));\n onCleanup(off);\n\n return createMemo(() => {\n version();\n return (registry.all?.() ?? [])\n .filter((description) => (description.tags ?? []).includes(tag))\n .map((description) => ({\n id: description.id,\n name: description.name || description.id,\n icon: description.icon,\n }))\n .sort((a, b) => a.name.localeCompare(b.name));\n });\n}\n", "import { template as _$template } from \"solid-js/web\";\nimport { delegateEvents as _$delegateEvents } from \"solid-js/web\";\nimport { setStyleProperty as _$setStyleProperty } from \"solid-js/web\";\nimport { effect as _$effect } from \"solid-js/web\";\nimport { memo as _$memo } from \"solid-js/web\";\nimport { addEventListener as _$addEventListener } from \"solid-js/web\";\nimport { insert as _$insert } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<div class=debug-registry-toast><div class=debug-registry-toast__header><span class=debug-registry-toast__title>\uD83D\uDD27 Registry (<!>)</span><button class=debug-registry-toast__clear title=\"Clear all\">\u2715</button></div><div class=debug-registry-toast__list>`),\n _tmpl$2 = /*#__PURE__*/_$template(`<div class=debug-registry-toast__item><div class=debug-registry-toast__content><span class=debug-registry-toast__event-type></span><span class=debug-registry-toast__plugin-type>`),\n _tmpl$3 = /*#__PURE__*/_$template(`<span class=debug-registry-toast__plugin-id>`);\nimport { createEffect, createSignal, onCleanup } from \"solid-js\";\nimport { getAllRegistries } from \"@inkandswitch/patchwork-plugins\";\nconst DEBUG_MODAL_KEY = \"debugModal\";\nexport function isDebugModalEnabled() {\n try {\n return localStorage.getItem(DEBUG_MODAL_KEY) === \"true\";\n } catch {\n return false;\n }\n}\nexport function setDebugModalEnabled(enabled) {\n try {\n if (enabled) {\n localStorage.setItem(DEBUG_MODAL_KEY, \"true\");\n } else {\n localStorage.removeItem(DEBUG_MODAL_KEY);\n }\n } catch {}\n}\nconst DEFAULT_EVENTS = [\"changed\"];\nexport function useDebugRegistryToast(options = {}) {\n const {\n events: subscribedEvents = DEFAULT_EVENTS\n } = options;\n const [events, setEvents] = createSignal([]);\n const [isEnabled, setIsEnabled] = createSignal(isDebugModalEnabled());\n const timeouts = /* @__PURE__ */new Set();\n const addEvent = (type, event, pluginId, pluginName) => {\n const newEvent = {\n id: crypto.randomUUID(),\n type,\n event,\n pluginId,\n pluginName,\n timestamp: Date.now()\n };\n setEvents(prev => {\n const updated = [newEvent, ...prev].slice(0, 50);\n return updated;\n });\n const timeoutId = setTimeout(() => {\n setEvents(prev => prev.filter(e => e.id !== newEvent.id));\n timeouts.delete(timeoutId);\n }, 5e3);\n timeouts.add(timeoutId);\n };\n const dismissEvent = eventId => {\n setEvents(prev => prev.filter(e => e.id !== eventId));\n };\n const clearAll = () => {\n setEvents([]);\n };\n createEffect(() => {\n if (!isEnabled()) {\n setEvents([]);\n timeouts.forEach(id => clearTimeout(id));\n timeouts.clear();\n return;\n }\n const registries = getAllRegistries();\n const unsubscribes = [];\n const lastPluginInfo = /* @__PURE__ */new Map();\n registries.forEach((registry, type) => {\n const trackRegistered = registry.on(\"registered\", plugin => {\n lastPluginInfo.set(type, {\n id: plugin.id,\n name: plugin.name,\n action: \"registered\"\n });\n if (subscribedEvents.includes(\"registered\")) {\n addEvent(type, \"registered\", plugin.id, plugin.name);\n }\n });\n unsubscribes.push(trackRegistered);\n const trackLoaded = registry.on(\"loaded\", plugin => {\n lastPluginInfo.set(type, {\n id: plugin.id,\n name: plugin.name,\n action: \"loaded\"\n });\n if (subscribedEvents.includes(\"loaded\")) {\n addEvent(type, \"loaded\", plugin.id, plugin.name);\n }\n });\n unsubscribes.push(trackLoaded);\n const trackRemoved = registry.on(\"removed\", id => {\n lastPluginInfo.set(type, {\n id,\n action: \"removed\"\n });\n if (subscribedEvents.includes(\"removed\")) {\n addEvent(type, \"removed\", id);\n }\n });\n unsubscribes.push(trackRemoved);\n if (subscribedEvents.includes(\"changed\")) {\n const unsub = registry.on(\"changed\", () => {\n const info = lastPluginInfo.get(type);\n addEvent(type, \"changed\", info?.id, info?.name);\n lastPluginInfo.delete(type);\n });\n unsubscribes.push(unsub);\n }\n });\n onCleanup(() => {\n unsubscribes.forEach(unsub => unsub());\n timeouts.forEach(id => clearTimeout(id));\n timeouts.clear();\n });\n });\n createEffect(() => {\n const handleStorageChange = e => {\n if (e.key === DEBUG_MODAL_KEY) {\n setIsEnabled(e.newValue === \"true\");\n }\n };\n window.addEventListener(\"storage\", handleStorageChange);\n onCleanup(() => window.removeEventListener(\"storage\", handleStorageChange));\n });\n return {\n events,\n isEnabled,\n setIsEnabled: enabled => {\n setDebugModalEnabled(enabled);\n setIsEnabled(enabled);\n },\n dismissEvent,\n clearAll\n };\n}\nexport function DebugRegistryToast({\n events,\n onDismiss,\n onClearAll\n}) {\n if (events.length === 0) return null;\n const eventColor = event => {\n switch (event) {\n case \"registered\":\n return \"var(--debug-toast-registered, #3b82f6)\";\n case \"loaded\":\n return \"var(--debug-toast-loaded, #22c55e)\";\n case \"removed\":\n return \"var(--debug-toast-removed, #ef4444)\";\n case \"changed\":\n return \"var(--debug-toast-changed, #f59e0b)\";\n }\n };\n return (() => {\n var _el$ = _tmpl$(),\n _el$2 = _el$.firstChild,\n _el$3 = _el$2.firstChild,\n _el$4 = _el$3.firstChild,\n _el$6 = _el$4.nextSibling,\n _el$5 = _el$6.nextSibling,\n _el$7 = _el$3.nextSibling,\n _el$8 = _el$2.nextSibling;\n _$insert(_el$3, () => events.length, _el$6);\n _$addEventListener(_el$7, \"click\", onClearAll, true);\n _$insert(_el$8, () => events.map(event => (() => {\n var _el$9 = _tmpl$2(),\n _el$0 = _el$9.firstChild,\n _el$1 = _el$0.firstChild,\n _el$10 = _el$1.nextSibling;\n _el$9.$$click = () => onDismiss(event.id);\n _$insert(_el$1, () => event.event);\n _$insert(_el$10, () => event.type);\n _$insert(_el$0, (() => {\n var _c$ = _$memo(() => !!event.pluginId);\n return () => _c$() && (() => {\n var _el$11 = _tmpl$3();\n _$insert(_el$11, () => event.pluginId);\n return _el$11;\n })();\n })(), null);\n _$effect(_$p => _$setStyleProperty(_el$9, \"border-left-color\", eventColor(event.event)));\n return _el$9;\n })()));\n return _el$;\n })();\n}\n_$delegateEvents([\"click\"]);", "import { template as _$template } from \"solid-js/web\";\nimport { delegateEvents as _$delegateEvents } from \"solid-js/web\";\nimport { getOwner as _$getOwner } from \"solid-js/web\";\nimport { effect as _$effect } from \"solid-js/web\";\nimport { setAttribute as _$setAttribute } from \"solid-js/web\";\nimport { memo as _$memo } from \"solid-js/web\";\nimport { insert as _$insert } from \"solid-js/web\";\nimport { createComponent as _$createComponent } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<div class=threepane__title>`),\n _tmpl$2 = /*#__PURE__*/_$template(`<div class=threepane__doctitle-tools>`),\n _tmpl$3 = /*#__PURE__*/_$template(`<button type=button class=frame__sidebar-toggle title=\"Show context sidebar\"aria-label=\"Show context sidebar\">`),\n _tmpl$4 = /*#__PURE__*/_$template(`<div class=frame__topbar><div class=threepane__spacer>`),\n _tmpl$5 = /*#__PURE__*/_$template(`<patchwork-view>`, true, false, false);\nimport { For, Show } from \"solid-js\";\nimport { DocumentTitle } from \"./DocumentTitle\";\nimport { PanelRightIcon } from \"./ContextSidebar\";\nimport { slotId } from \"./SlotView\";\nexport function FrameTopBar(props) {\n const docToolSlots = () => props.toolSlots() ?? [];\n return (() => {\n var _el$ = _tmpl$4(),\n _el$3 = _el$.firstChild;\n _$insert(_el$, _$createComponent(Show, {\n get when() {\n return props.docUrl();\n },\n get children() {\n var _el$2 = _tmpl$();\n _$insert(_el$2, _$createComponent(DocumentTitle, {\n get docUrl() {\n return props.docUrl;\n }\n }));\n return _el$2;\n }\n }), _el$3);\n _$insert(_el$, _$createComponent(Show, {\n get when() {\n return _$memo(() => !!props.docUrl())() && docToolSlots().length;\n },\n get children() {\n var _el$4 = _tmpl$2();\n _$insert(_el$4, _$createComponent(For, {\n get each() {\n return docToolSlots();\n },\n children: slot => (() => {\n var _el$6 = _tmpl$5();\n _el$6._$owner = _$getOwner();\n _$effect(_p$ => {\n var _v$ = slotId(slot),\n _v$2 = props.docUrl();\n _v$ !== _p$.e && (_el$6.toolId = _p$.e = _v$);\n _v$2 !== _p$.t && (_el$6.docUrl = _p$.t = _v$2);\n return _p$;\n }, {\n e: undefined,\n t: undefined\n });\n return _el$6;\n })()\n }));\n return _el$4;\n }\n }), null);\n _$insert(_el$, _$createComponent(Show, {\n get when() {\n return _$memo(() => !!props.hasContext())() && props.isRightCollapsed();\n },\n get children() {\n var _el$5 = _tmpl$3();\n _el$5.$$click = () => props.onToggleRight();\n _$setAttribute(_el$5, \"aria-pressed\", false);\n _$insert(_el$5, _$createComponent(PanelRightIcon, {}));\n return _el$5;\n }\n }), null);\n _$effect(() => _el$.classList.toggle(\"frame__topbar--left-collapsed\", !!props.isLeftCollapsed()));\n return _el$;\n })();\n}\n_$delegateEvents([\"click\"]);", "import { template as _$template } from \"solid-js/web\";\nimport { delegateEvents as _$delegateEvents } from \"solid-js/web\";\nimport { setAttribute as _$setAttribute } from \"solid-js/web\";\nimport { insert as _$insert } from \"solid-js/web\";\nimport { memo as _$memo } from \"solid-js/web\";\nimport { effect as _$effect } from \"solid-js/web\";\nimport { use as _$use } from \"solid-js/web\";\nimport { createComponent as _$createComponent } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<span class=threepane__title-text>`),\n _tmpl$2 = /*#__PURE__*/_$template(`<input class=threepane__title-input type=text>`);\nimport { useDocument } from \"solid-automerge\";\nimport { getType } from \"@inkandswitch/patchwork-filesystem\";\nimport { getRegistry, isLoadedPlugin } from \"@inkandswitch/patchwork-plugins\";\nimport { createEffect, createMemo, createSignal, onCleanup, onMount, Show } from \"solid-js\";\nexport function DocumentTitle(props) {\n let anchor;\n const [repo, setRepo] = createSignal();\n onMount(() => {\n setRepo(anchor.closest(\"repo-provider\")?.repo);\n });\n return _$createComponent(Show, {\n get when() {\n return repo();\n },\n get fallback() {\n return (() => {\n var _el$ = _tmpl$();\n var _ref$ = anchor;\n typeof _ref$ === \"function\" ? _$use(_ref$, _el$) : anchor = _el$;\n return _el$;\n })();\n },\n children: resolvedRepo => _$createComponent(DocumentTitleInner, {\n get docUrl() {\n return props.docUrl;\n },\n get repo() {\n return resolvedRepo();\n }\n })\n });\n}\nfunction DocumentTitleInner(props) {\n const [doc, handle] = useDocument(() => props.docUrl(), {\n repo: props.repo\n });\n const registry = getRegistry(\"patchwork:datatype\");\n const [registryVersion, setRegistryVersion] = createSignal(0);\n onMount(() => {\n const off = registry.on(\"changed\", () => setRegistryVersion(v => v + 1));\n onCleanup(off);\n });\n const typeId = createMemo(() => {\n const d = doc();\n return d ? getType(d) : void 0;\n });\n createEffect(() => {\n const id = typeId();\n if (id) void registry.load(id);\n });\n const datatype = createMemo(() => {\n registryVersion();\n const id = typeId();\n if (!id) return void 0;\n const dt = registry.get(id);\n return dt && isLoadedPlugin(dt) ? dt : void 0;\n });\n const title = createMemo(() => {\n const d = doc();\n const dt = datatype();\n if (!d || !dt) return void 0;\n return dt.module.getTitle(d);\n });\n const canEdit = createMemo(() => !!handle() && typeof datatype()?.module.setTitle === \"function\");\n const [editing, setEditing] = createSignal(false);\n let inputRef;\n function startEditing() {\n if (!canEdit()) return;\n setEditing(true);\n queueMicrotask(() => {\n inputRef?.focus();\n inputRef?.select();\n });\n }\n function commit(save) {\n if (!editing()) return;\n setEditing(false);\n if (!save) return;\n const next = inputRef?.value.trim();\n if (!next || next === title()) return;\n const h = handle();\n const setTitle = datatype()?.module.setTitle;\n if (!h || !setTitle) return;\n h.change(d => {\n setTitle(d, next);\n const meta = d[\"@patchwork\"];\n if (meta) meta.title = next;\n });\n }\n return _$createComponent(Show, {\n get when() {\n return editing();\n },\n get fallback() {\n return (() => {\n var _el$3 = _tmpl$();\n _el$3.$$click = startEditing;\n _$insert(_el$3, () => title() ?? \"Untitled\");\n _$effect(_p$ => {\n var _v$ = !!canEdit(),\n _v$2 = canEdit() ? \"Rename\" : void 0;\n _v$ !== _p$.e && _el$3.classList.toggle(\"threepane__title-text--editable\", _p$.e = _v$);\n _v$2 !== _p$.t && _$setAttribute(_el$3, \"title\", _p$.t = _v$2);\n return _p$;\n }, {\n e: undefined,\n t: undefined\n });\n return _el$3;\n })();\n },\n get children() {\n var _el$2 = _tmpl$2();\n _el$2.$$keydown = e => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n commit(true);\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n commit(false);\n }\n };\n _el$2.addEventListener(\"blur\", () => commit(true));\n var _ref$2 = inputRef;\n typeof _ref$2 === \"function\" ? _$use(_ref$2, _el$2) : inputRef = _el$2;\n _$effect(() => _el$2.value = title() ?? \"\");\n return _el$2;\n }\n });\n}\n_$delegateEvents([\"keydown\", \"click\"]);", "// cabbages.ts\nimport debug from \"debug\";\nvar log = debug(\"cabbages\");\nfunction pojo(target) {\n return typeof target == \"object\" && typeof target != null && Object.getPrototypeOf(target) == Object.prototype;\n}\nvar BLOCK_MARKER = \"\\uFFFC\";\nfunction apply(target, ...rest) {\n if (rest.length == 0) {\n log(\"empty patch\");\n return;\n }\n const [path, range, val] = rest;\n let p = [...path];\n while (true) {\n let key = p.shift();\n if (!p.length) {\n const RANGE_ARRAY = Array.isArray(range);\n if (pojo(target) && RANGE_ARRAY && typeof key == \"undefined\" && typeof range[0] == \"string\") {\n delete target[range[0]];\n return;\n }\n if (RANGE_ARRAY || typeof range == \"number\") {\n if (typeof key == \"undefined\") {\n throw new Error(\"cant treat top level as a seq\");\n }\n key = key;\n let [start, end] = Array.isArray(range) ? range : [range, range + 1];\n const ZERO_LENGTH = Array.isArray(range) && range.length == 0;\n if (!ZERO_LENGTH && (start == null || end == null)) {\n throw new RangeError(\"it's all or nothing, no half measures\");\n }\n const DELETE = typeof val == \"undefined\";\n const INSERT = start === end && !DELETE;\n const APPEND = ZERO_LENGTH && !DELETE;\n const REPLACE = !INSERT && !DELETE && !APPEND;\n if (typeof target[key] == \"undefined\") {\n if (typeof target == \"string\") {\n return;\n } else if (typeof val == \"string\") {\n target[key] = \"\";\n } else {\n target[key] = [];\n }\n }\n let seq = target[key];\n if (Array.isArray(seq)) {\n if (APPEND) {\n Array.isArray(val) ? seq.push(...val) : seq.push(val);\n return;\n }\n if (INSERT || REPLACE) {\n Array.isArray(val) ? seq.splice(start, end - start, ...val) : seq.splice(start, end - start, val);\n return;\n }\n if (DELETE) {\n seq.splice(start, end - start);\n return;\n }\n throw new Error(\"i don't know what happened\");\n }\n if (typeof seq == \"string\") {\n if (APPEND) {\n target[key] = seq + val;\n return;\n }\n if (REPLACE || INSERT) {\n target[key] = seq.slice(0, start) + (typeof val == \"string\" ? val : val.map(\n (n) => typeof n == \"string\" ? n : BLOCK_MARKER\n ).join(\"\")) + seq.slice(end);\n return;\n }\n if (DELETE) {\n target[key] = seq.slice(0, start) + seq.slice(end);\n return;\n }\n throw new Error(\"i don't know what happened\");\n }\n if (pojo(seq) && RANGE_ARRAY && typeof range[0] == \"string\") {\n delete seq[range[0]];\n return;\n }\n throw new Error(\"not implemented\");\n }\n if (typeof key == \"undefined\") {\n if (typeof range != \"string\") {\n throw new Error(`can't index top-level map with ${range}`);\n }\n if (typeof val == \"undefined\") {\n delete target[range];\n } else {\n target[range] = val;\n }\n return;\n }\n if (typeof target[key] == \"undefined\") {\n target[key] = {};\n }\n if (RANGE_ARRAY) {\n let [a, b] = range;\n if (a != null && b != null) {\n if (typeof val == \"undefined\" && a != null && b != null) {\n delete target[key][a || b];\n } else {\n target[key][a || b] = val;\n }\n }\n } else {\n if (typeof val == \"undefined\") {\n delete target[key][range];\n } else if (typeof target[key] == \"string\") {\n return;\n } else {\n target[key][range] = val;\n }\n }\n return;\n }\n if (typeof key == \"undefined\") {\n throw new Error(\"cant treat top level as a seq\");\n }\n key = key;\n let nextkey = p[0];\n if (typeof target[key] == \"undefined\") {\n if (typeof nextkey == \"string\") {\n target[key] = {};\n } else if (typeof nextkey == \"number\") {\n target[key] = [];\n } else {\n throw new Error(`can't go down this road ${target}.${key}.${nextkey}`);\n }\n }\n target = target[key];\n }\n}\nvar patch = apply;\nfunction get(obj, key) {\n for (let p = 0; p < key.length; p++) {\n obj = obj ? obj[key[p]] : void 0;\n }\n return obj;\n}\nfunction fromAutomerge(autopatch, payload) {\n const path = autopatch.path.slice(0, -1);\n const key = autopatch.path[autopatch.path.length - 1];\n switch (autopatch.action) {\n case \"mark\":\n case \"unmark\":\n log(\n `skipping ${autopatch.action} because it doesn't affect material reality`\n );\n return [];\n case \"inc\":\n if (payload) {\n return [path, key, get(payload.patchInfo.after, autopatch.path)];\n } else {\n throw new Error(\n `can't apply ${autopatch.action} without payload argument`\n );\n }\n case \"conflict\":\n if (payload) {\n return [path, key, get(payload.patchInfo.after, autopatch.path)];\n } else {\n throw new Error(\n `can't apply ${autopatch.action} without payload argument`\n );\n }\n case \"del\": {\n return typeof key == \"string\" ? [path, key] : [path, [key, key + (autopatch.length || 1)]];\n }\n case \"insert\": {\n return [\n path,\n [key, key],\n structuredClone(autopatch.values)\n ];\n }\n case \"splice\": {\n return [path, [key, key], [autopatch.value]];\n }\n case \"put\": {\n return [path, key, structuredClone(autopatch.value)];\n }\n }\n}\nexport {\n apply,\n fromAutomerge,\n patch,\n pojo\n};\n", "import type {DocHandleChangePayload} from \"@automerge/automerge-repo/slim\"\nimport {apply, fromAutomerge} from \"cabbages\"\n\n/**\n * convert automerge patches to solid producer operations\n * @param payload the\n * [DocHandleChangePayload](https://automerge.org/automerge-repo/interfaces/_automerge_automerge_repo.DocHandleChangePayload.html)\n * from the handle.on(\"change\n * @returns a callback for an immer-like function. e.g.\n * [produce](https://docs.solidjs.com/reference/store-utilities/produce) for\n * [Solid\n * Stores](https://docs.solidjs.com/reference/store-utilities/create-store)\n */\nexport default function autoproduce<T>(\n\tpayload: DocHandleChangePayload<T>\n): (doc: T) => void {\n\treturn (doc: T) => {\n\t\tfor (let patch of payload.patches) {\n\t\t\tapply(doc, ...fromAutomerge(patch, payload))\n\t\t}\n\t}\n}\n", "import {createMemo, type Accessor} from \"solid-js\"\nimport {type DocHandle, type Doc} from \"@automerge/automerge-repo/slim\"\nimport makeDocumentProjection from \"./makeDocumentProjection.ts\"\nimport {access} from \"@solid-primitives/utils\"\n\n/**\n * get a fine-grained live view of a document from a handle. works with\n * {@link useDocHandle}.\n * @param handle an accessor (signal/resource) of a\n * [DocHandle](https://automerge.org/automerge-repo/classes/_automerge_automerge_repo.DocHandle.html)\n */\nexport default function createDocumentProjection<T extends object>(\n\thandle: Accessor<DocHandle<T> | undefined>\n): Accessor<Doc<T> | undefined> {\n\tconst projection = createMemo<Doc<T> | undefined>(\n\t\t() => access(handle) && makeDocumentProjection<T>(access(handle)!)\n\t)\n\treturn projection\n}\n", "import {onCleanup} from \"solid-js\"\nimport type {\n\tDoc,\n\tDocHandle,\n\tDocHandleChangePayload,\n} from \"@automerge/automerge-repo/slim\"\nimport autoproduce from \"./autoproduce.ts\"\nimport {createStore, produce, reconcile, type Store} from \"solid-js/store\"\n\nconst cache = new WeakMap<\n\tDocHandle<unknown>,\n\t{\n\t\trefs: number\n\t\tstore: Store<Doc<unknown>>\n\t\tcleanup(): void\n\t}\n>()\n\n/**\n * make a fine-grained live view of a document from its handle.\n * @param handle an Automerge\n * [DocHandle](https://automerge.org/automerge-repo/classes/_automerge_automerge_repo.DocHandle.html)\n */\nexport default function makeDocumentProjection<T extends object>(\n\thandle: DocHandle<T>\n): Doc<T> {\n\tonCleanup(() => {\n\t\tconst item = cache.get(handle)!\n\t\tif (!item) return\n\t\tif (!item.refs--) {\n\t\t\titem.cleanup()\n\t\t}\n\t})\n\n\tif (cache.has(handle)) {\n\t\tconst item = cache.get(handle)!\n\t\titem.refs++\n\t\treturn item.store as Doc<T>\n\t}\n\n\tconst [doc, set] = createStore<Doc<T>>(handle.doc()!)\n\n\tcache.set(handle, {\n\t\trefs: 0,\n\t\tstore: doc,\n\t\tcleanup() {\n\t\t\thandle.off(\"change\", patch)\n\t\t\thandle.off(\"delete\", ondelete)\n\t\t\tcache.delete(handle)\n\t\t},\n\t})\n\n\tfunction patch(payload: DocHandleChangePayload<T>) {\n\t\t// `scopeReplaced` means the change landed at or above this (sub-)handle's\n\t\t// scope boundary, so it can't be expressed as in-scope patches. The\n\t\t// payload still carries `doc` \u2014 the new value at the handle's path (the\n\t\t// part of the store this scope points at) \u2014 so we reconcile against that\n\t\t// instead of applying patches. `reconcile` structurally diffs it against\n\t\t// the current store, so unchanged subtrees keep their identity and only\n\t\t// the parts that actually changed notify. `doc` is undefined when the\n\t\t// scope was removed entirely.\n\t\tif (payload.scopeReplaced) {\n\t\t\tset(reconcile((payload.doc ?? {}) as Doc<T>))\n\t\t\treturn\n\t\t}\n\t\tset(produce(autoproduce(payload)))\n\t}\n\n\tfunction ondelete() {\n\t\tset(reconcile({} as Doc<T>))\n\t}\n\n\thandle.on(\"change\", patch)\n\thandle.on(\"delete\", ondelete)\n\n\thandle.whenReady().then(() => {\n\t\tset(handle.doc()!)\n\t})\n\n\treturn doc\n}\n", "import { getOwner, onCleanup, createSignal, untrack, sharedConfig, onMount, DEV, equalFn, } from \"solid-js\";\nimport { isServer } from \"solid-js/web\";\nexport * from \"./types.js\";\n//\n// GENERAL HELPERS:\n//\nexport { isServer };\nexport const isClient = !isServer;\nexport const isDev = isClient && !!DEV;\nexport const isProd = !isDev;\n/** no operation */\nexport const noop = (() => void 0);\nexport const trueFn = () => true;\nexport const falseFn = () => false;\n/** @deprecated use {@link equalFn} from \"solid-js\" */\nexport const defaultEquals = equalFn;\nexport const EQUALS_FALSE_OPTIONS = { equals: false };\nexport const INTERNAL_OPTIONS = { internal: true };\n/**\n * Check if the value is an instance of ___\n */\nexport const ofClass = (v, c) => v instanceof c || (v && v.constructor === c);\n/** Check if value is typeof \"object\" or \"function\" */\nexport function isObject(value) {\n return value !== null && (typeof value === \"object\" || typeof value === \"function\");\n}\nexport const isNonNullable = (i) => i != null;\nexport const filterNonNullable = (arr) => arr.filter(isNonNullable);\nexport const compare = (a, b) => (a < b ? -1 : a > b ? 1 : 0);\n/**\n * Check shallow array equality\n */\nexport const arrayEquals = (a, b) => a === b || (a.length === b.length && a.every((e, i) => e === b[i]));\n/**\n * Returns a function that will call all functions in the order they were chained with the same arguments.\n */\nexport function chain(callbacks) {\n return (...args) => {\n for (const callback of callbacks)\n callback && callback(...args);\n };\n}\n/**\n * Returns a function that will call all functions in the reversed order with the same arguments.\n */\nexport function reverseChain(callbacks) {\n return (...args) => {\n for (let i = callbacks.length - 1; i >= 0; i--) {\n const callback = callbacks[i];\n callback && callback(...args);\n }\n };\n}\nexport const clamp = (n, min, max) => Math.min(Math.max(n, min), max);\n/**\n * Accesses the value of a MaybeAccessor\n * @example\n * ```ts\n * access(\"foo\") // => \"foo\"\n * access(() => \"foo\") // => \"foo\"\n * ```\n */\nexport const access = (v) => typeof v === \"function\" && !v.length ? v() : v;\nexport const asArray = (value) => Array.isArray(value) ? value : value ? [value] : [];\n/**\n * Access an array of MaybeAccessors\n * @example\n * const list = [1, 2, () => 3)] // T: MaybeAccessor<number>[]\n * const newList = accessArray(list) // T: number[]\n */\nexport const accessArray = (list) => list.map(v => access(v));\n/**\n * Run the function if the accessed value is not `undefined` nor `null`\n * @param value\n * @param fn\n */\nexport const withAccess = (value, fn) => {\n const _value = access(value);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n typeof _value != null && fn(_value);\n};\nexport const asAccessor = (v) => (typeof v === \"function\" ? v : () => v);\n/** If value is a function \u2013 call it with a given arguments \u2013 otherwise get the value as is */\nexport function accessWith(valueOrFn, ...args) {\n return typeof valueOrFn === \"function\" ? valueOrFn(...args) : valueOrFn;\n}\nexport function defer(deps, fn, initialValue) {\n const isArray = Array.isArray(deps);\n let prevInput;\n let shouldDefer = true;\n return prevValue => {\n let input;\n if (isArray) {\n input = Array(deps.length);\n for (let i = 0; i < deps.length; i++)\n input[i] = deps[i]();\n }\n else\n input = deps();\n if (shouldDefer) {\n shouldDefer = false;\n prevInput = input;\n return initialValue;\n }\n const result = untrack(() => fn(input, prevInput, prevValue));\n prevInput = input;\n return result;\n };\n}\n/**\n * Get entries of an object\n */\nexport const entries = Object.entries;\n/**\n * Get keys of an object\n */\nexport const keys = Object.keys;\n/**\n * Solid's `onCleanup` that doesn't warn in development if used outside of a component.\n */\nexport const tryOnCleanup = isDev\n ? fn => (getOwner() ? onCleanup(fn) : fn)\n : onCleanup;\nexport const createCallbackStack = () => {\n let stack = [];\n const clear = () => (stack = []);\n return {\n push: (...callbacks) => stack.push(...callbacks),\n execute(arg0, arg1, arg2, arg3) {\n stack.forEach(cb => cb(arg0, arg1, arg2, arg3));\n clear();\n },\n clear,\n };\n};\n/**\n * Group synchronous function calls.\n * @param fn\n * @returns `fn`\n */\nexport function createMicrotask(fn) {\n let calls = 0;\n let args;\n onCleanup(() => (calls = 0));\n return (...a) => {\n (args = a), calls++;\n queueMicrotask(() => --calls === 0 && fn(...args));\n };\n}\n/**\n * A hydratable version of the {@link createSignal}. It will use the serverValue on the server and the update function on the client. If initialized during hydration it will use serverValue as the initial value and update it once hydration is complete.\n *\n * @param serverValue initial value of the state on the server\n * @param update called once on the client or on hydration to initialize the value\n * @param options {@link SignalOptions}\n * @returns\n * ```ts\n * [state: Accessor<T>, setState: Setter<T>]\n * ```\n * @see {@link createSignal}\n */\nexport function createHydratableSignal(serverValue, update, options) {\n if (isServer) {\n return createSignal(serverValue, options);\n }\n if (sharedConfig.context) {\n const [state, setState] = createSignal(serverValue, options);\n onMount(() => setState(() => update()));\n return [state, setState];\n }\n return createSignal(update(), options);\n}\n/** @deprecated use {@link createHydratableSignal} instead */\nexport const createHydrateSignal = createHydratableSignal;\n/**\n * Handle items removed and added to the array by diffing it by refference.\n *\n * @param current new array instance\n * @param prev previous array copy\n * @param handleAdded called once for every added item to array\n * @param handleRemoved called once for every removed from array\n */\nexport function handleDiffArray(current, prev, handleAdded, handleRemoved) {\n const currLength = current.length;\n const prevLength = prev.length;\n let i = 0;\n if (!prevLength) {\n for (; i < currLength; i++)\n handleAdded(current[i]);\n return;\n }\n if (!currLength) {\n for (; i < prevLength; i++)\n handleRemoved(prev[i]);\n return;\n }\n for (; i < prevLength; i++) {\n if (prev[i] !== current[i])\n break;\n }\n let prevEl;\n let currEl;\n prev = prev.slice(i);\n current = current.slice(i);\n for (prevEl of prev) {\n if (!current.includes(prevEl))\n handleRemoved(prevEl);\n }\n for (currEl of current) {\n if (!prev.includes(currEl))\n handleAdded(currEl);\n }\n}\n// \u2500\u2500\u2500 String transforms \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n/**\n * Parse a string as a single JSON value.\n *\n * ```ts\n * const { data } = createSSE<{ status: string }>(url, { transform: json });\n * ```\n */\nexport const json = (raw) => JSON.parse(raw);\n/**\n * Parse a string as newline-delimited JSON (NDJSON / JSON Lines).\n *\n * Each non-empty line is parsed as a separate JSON value and returned as an array.\n *\n * ```ts\n * const { data } = createSSE<TickEvent[]>(url, { transform: ndjson });\n * // data() === [{ id: 1, type: \"tick\" }, { id: 2, type: \"tick\" }]\n * ```\n */\nexport const ndjson = (raw) => raw\n .split(\"\\n\")\n .filter(line => line !== \"\")\n .map(line => JSON.parse(line));\n/**\n * Split a string into individual lines, returning a `string[]`. Empty lines are filtered out.\n *\n * ```ts\n * const { data } = createSSE<string[]>(url, { transform: lines });\n * // data() === [\"line one\", \"line two\"]\n * ```\n */\nexport const lines = (raw) => raw.split(\"\\n\").filter(line => line !== \"\");\n/**\n * Parse a string as a number using `Number()` semantics.\n *\n * Note: `\"\"` \u2192 `0`, non-numeric strings \u2192 `NaN`.\n *\n * ```ts\n * const { data } = createSSE<number>(url, { transform: number });\n * // data() === 42\n * ```\n */\nexport const number = (raw) => Number(raw);\nexport function safe(transform, fallback) {\n return (raw) => {\n try {\n return transform(raw);\n }\n catch {\n return fallback;\n }\n };\n}\n/**\n * Compose two transforms into one: the output of `a` is passed as the input of `b`.\n *\n * ```ts\n * const { data } = createSSE<RawEvent[]>(url, {\n * transform: pipe(ndjson<RawEvent>, rows => rows.filter(r => r.type === \"tick\")),\n * });\n * ```\n */\nexport function pipe(a, b) {\n return (raw) => b(a(raw));\n}\n", "import type {AutomergeUrl, DocHandle} from \"@automerge/automerge-repo/slim\"\nimport {createEffect, createResource, useContext, type Resource} from \"solid-js\"\nimport {access, type MaybeAccessor} from \"@solid-primitives/utils\"\nimport {RepoContext} from \"./context.ts\"\nimport type {UseDocHandleOptions} from \"./types.ts\"\n\n/**\n * get a\n * [DocHandle](https://automerge.org/automerge-repo/classes/_automerge_automerge_repo.DocHandle.html)\n * from an\n * [AutomergeUrl](https://automerge.org/automerge-repo/types/_automerge_automerge_repo.AutomergeUrl.html)\n * as a\n * [Resource](https://docs.solidjs.com/reference/basic-reactivity/create-resource).\n * Waits for the handle to be ready.\n */\nexport default function useDocHandle<T>(\n\turl: MaybeAccessor<AutomergeUrl | undefined>,\n\toptions?: UseDocHandleOptions\n): Resource<DocHandle<T> | undefined> {\n\tconst contextRepo = useContext(RepoContext)\n\n\tif (!options?.repo && !contextRepo) {\n\t\tthrow new Error(\"use outside <RepoContext> requires options.repo\")\n\t}\n\n\tconst repo = (options?.repo || contextRepo)!\n\n\tfunction getExistingHandle() {\n\t\tif (options?.[\"~skipInitialValue\"]) return undefined\n\t\tconst unwrappedURL = access(url)\n\t\tif (!unwrappedURL) return undefined\n\t\tconst state = repo.findWithProgress<T>(unwrappedURL).peek()\n\t\treturn state.state === \"ready\" ? state.handle : undefined\n\t}\n\n\tconst [handle, {mutate}] = createResource(\n\t\turl,\n\t\turl => repo.findWithProgress<T>(url).whenReady(),\n\t\t{\n\t\t\tinitialValue: getExistingHandle(),\n\t\t}\n\t)\n\n\tcreateEffect(() => {\n\t\tif (!access(url)) {\n\t\t\tmutate()\n\t\t}\n\t})\n\n\treturn handle\n}\n", "import type {Repo} from \"@automerge/automerge-repo/slim\"\nimport {createContext, type Context} from \"solid-js\"\n\n/**\n * a [context](https://docs.solidjs.com/concepts/context) that provides access\n * to an Automerge Repo. you don't need this, you can pass the repo in the\n * second arg to the functions that need it.\n */\nexport const RepoContext: Context<Repo | null> = createContext<Repo | null>(\n\tnull\n)\n", "import type {AutomergeUrl, Doc, DocHandle} from \"@automerge/automerge-repo/slim\"\nimport createDocumentProjection from \"./createDocumentProjection.ts\"\nimport type {MaybeAccessor} from \"@solid-primitives/utils\"\nimport useDocHandle from \"./useDocHandle.ts\"\nimport type {UseDocHandleOptions} from \"./types.ts\"\nimport type {Accessor, Resource} from \"solid-js\"\n\n/**\n * get a fine-grained live view of a document, and its handle, from a URL.\n * @param url a function that returns a url\n */\nexport default function useDocument<T extends object>(\n\turl: MaybeAccessor<AutomergeUrl | undefined>,\n\toptions?: UseDocHandleOptions\n): [Accessor<Doc<T> | undefined>, Resource<DocHandle<T> | undefined>] {\n\tconst handle = useDocHandle<T>(url, options)\n\treturn [createDocumentProjection<T>(handle), handle] as const\n}\n", "import {onCleanup, type Accessor} from \"solid-js\"\nimport {createSignal} from \"solid-js\"\nimport type {Doc, DocHandle} from \"@automerge/automerge-repo/slim\"\n\n/**\n * a light coarse-grained primitive when you care only _that_ a doc has changed,\n * and not _how_.\n * @param handle an Automerge\n * [DocHandle](https://automerge.org/automerge-repo/classes/_automerge_automerge_repo.DocHandle.html)\n */\nexport default function makeDocSignal<T extends object>(\n\thandle: DocHandle<T>\n): Accessor<Doc<T> | undefined> {\n\tconst [signal, setSignal] = createSignal<Doc<T> | undefined>(handle.doc())\n\n\tfunction update() {\n\t\tsetSignal(() => handle.doc() as Doc<T> | undefined)\n\t}\n\n\thandle.on(\"change\", update)\n\tonCleanup(() => handle.off(\"change\", update))\n\n\treturn signal\n}\n", "import {createEffect, onCleanup, type Accessor} from \"solid-js\"\nimport {createSignal} from \"solid-js\"\nimport type {Doc, DocHandle} from \"@automerge/automerge-repo/slim\"\n\n/**\n * a light coarse-grained primitive when you care only _that_ a doc has changed,\n * and not _how_. works with {@link useDocHandle}.\n * @param handle an accessor (signal/resource) of a\n * [DocHandle](https://automerge.org/automerge-repo/classes/_automerge_automerge_repo.DocHandle.html)\n */\nexport default function createDocSignal<T extends object>(\n\thandle: Accessor<DocHandle<T> | undefined>\n): Accessor<Doc<T> | undefined> {\n\tconst [signal, setSignal] = createSignal<Doc<T> | undefined>(handle()?.doc())\n\n\tcreateEffect(() => {\n\t\tconst h = handle()\n\n\t\tfunction update() {\n\t\t\tsetSignal(() => h?.doc() as Doc<T> | undefined)\n\t\t}\n\n\t\t// sync the signal with the current handle's doc\n\t\tupdate()\n\n\t\tif (h) {\n\t\t\th.on(\"change\", update)\n\t\t\tonCleanup(() => h.off(\"change\", update))\n\t\t}\n\t})\n\n\treturn signal\n}\n", "import type {Repo} from \"@automerge/automerge-repo/slim\"\nimport {RepoContext} from \"./context.ts\"\nimport {useContext} from \"solid-js\"\n\n/** grab the repo from the {@link RepoContext} */\nexport default function useRepo(): Repo {\n\tconst repo = useContext(RepoContext)\n\tif (!repo) throw new Error(\"Please wrap me in a <RepoContext value={repo}>\")\n\treturn repo\n}\n", "import { template as _$template } from \"solid-js/web\";\nimport { delegateEvents as _$delegateEvents } from \"solid-js/web\";\nimport { getOwner as _$getOwner } from \"solid-js/web\";\nimport { insert as _$insert } from \"solid-js/web\";\nimport { createComponent as _$createComponent } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<div class=context-sidebar__tabs><button type=button class=context-sidebar__close title=\"Hide context sidebar\"aria-label=\"Hide context sidebar\">`),\n _tmpl$2 = /*#__PURE__*/_$template(`<div class=context-sidebar__content>`),\n _tmpl$3 = /*#__PURE__*/_$template(`<div class=context-sidebar>`),\n _tmpl$4 = /*#__PURE__*/_$template(`<patchwork-view>`, true, false, false),\n _tmpl$5 = /*#__PURE__*/_$template(`<svg xmlns=http://www.w3.org/2000/svg width=18 height=18 viewBox=\"0 0 24 24\"fill=none stroke=var(--studio-chrome-line) stroke-width=1.75 stroke-linecap=round stroke-linejoin=round><rect width=18 height=18 x=3 y=3 rx=2></rect><path d=\"M15 3v18\">`);\nimport { Show } from \"solid-js\";\nimport { useTaggedComponents } from \"../hooks\";\nimport { Sidebar } from \"./Sidebar\";\nimport { ContextTabs } from \"./ContextTabs\";\nexport function ContextSidebar(props) {\n const items = useTaggedComponents(\"context-tool\");\n const activeToolId = () => {\n const ids = items().map(item => item.id);\n const selected = props.selectedToolId();\n return selected && ids.includes(selected) ? selected : ids[0];\n };\n return _$createComponent(Sidebar, {\n side: \"right\",\n get isCollapsed() {\n return props.isCollapsed;\n },\n get width() {\n return props.width;\n },\n get onMouseDown() {\n return props.onMouseDown;\n },\n get onToggleClick() {\n return props.onToggleClick;\n },\n get canExpand() {\n return props.canExpand;\n },\n get children() {\n var _el$ = _tmpl$3();\n _$insert(_el$, _$createComponent(Show, {\n get when() {\n return items().length;\n },\n get children() {\n var _el$2 = _tmpl$(),\n _el$3 = _el$2.firstChild;\n _$insert(_el$2, _$createComponent(ContextTabs, {\n items: items,\n get selectedToolId() {\n return props.selectedToolId;\n },\n get setSelectedToolId() {\n return props.setSelectedToolId;\n }\n }), _el$3);\n _el$3.$$click = () => props.onCollapse();\n _$insert(_el$3, _$createComponent(PanelRightIcon, {}));\n return _el$2;\n }\n }), null);\n _$insert(_el$, _$createComponent(Show, {\n get when() {\n return !props.isCollapsed();\n },\n get children() {\n var _el$4 = _tmpl$2();\n _$insert(_el$4, _$createComponent(Show, {\n get when() {\n return activeToolId();\n },\n keyed: true,\n children: id => (() => {\n var _el$5 = _tmpl$4();\n _el$5.component = id;\n _el$5._$owner = _$getOwner();\n return _el$5;\n })()\n }));\n return _el$4;\n }\n }), null);\n return _el$;\n }\n });\n}\nexport function PanelRightIcon() {\n return _tmpl$5();\n}\n_$delegateEvents([\"click\"]);", "import { template as _$template } from \"solid-js/web\";\nimport { delegateEvents as _$delegateEvents } from \"solid-js/web\";\nimport { setStyleProperty as _$setStyleProperty } from \"solid-js/web\";\nimport { setAttribute as _$setAttribute } from \"solid-js/web\";\nimport { insert as _$insert } from \"solid-js/web\";\nimport { memo as _$memo } from \"solid-js/web\";\nimport { effect as _$effect } from \"solid-js/web\";\nimport { getOwner as _$getOwner } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<patchwork-view>`, true, false, false),\n _tmpl$2 = /*#__PURE__*/_$template(`<div class=sidebar>`),\n _tmpl$3 = /*#__PURE__*/_$template(`<button class=\"sidebar-toggle sidebar-toggle--resizable\"aria-label=\"Toggle or resize sidebar\"title=\"Click to toggle, drag to resize\">`),\n _tmpl$4 = /*#__PURE__*/_$template(`<button class=\"sidebar-toggle sidebar-toggle--resizable\"aria-label=\"Expand sidebar\"title=\"Click to expand, drag to resize\">`);\nexport function Sidebar(props) {\n const widthStyle = () => `${props.isCollapsed() ? 0 : props.width()}px`;\n const content = () => {\n if (props.children !== void 0) return props.children;\n if (props.toolId && props.docUrl) {\n return (() => {\n var _el$ = _tmpl$();\n _el$._$owner = _$getOwner();\n _$effect(_p$ => {\n var _v$ = props.docUrl,\n _v$2 = props.toolId;\n _v$ !== _p$.e && (_el$.docUrl = _p$.e = _v$);\n _v$2 !== _p$.t && (_el$.toolId = _p$.t = _v$2);\n return _p$;\n }, {\n e: undefined,\n t: undefined\n });\n return _el$;\n })();\n }\n return null;\n };\n const canExpand = () => props.canExpand?.() ?? true;\n return (() => {\n var _el$2 = _tmpl$2();\n _$insert(_el$2, (() => {\n var _c$ = _$memo(() => !!(props.side === \"left\" && !props.isCollapsed()));\n return () => _c$() && content();\n })(), null);\n _$insert(_el$2, (() => {\n var _c$2 = _$memo(() => !!(props.side === \"left\" && !props.isCollapsed()));\n return () => _c$2() && (() => {\n var _el$3 = _tmpl$3();\n _el$3.$$mousedown = e => props.onMouseDown(props.side, e);\n _el$3.$$click = e => props.onToggleClick(props.side, e);\n return _el$3;\n })();\n })(), null);\n _$insert(_el$2, (() => {\n var _c$3 = _$memo(() => !!(props.side === \"left\" && props.isCollapsed() && canExpand()));\n return () => _c$3() && (() => {\n var _el$4 = _tmpl$4();\n _el$4.$$mousedown = e => props.onMouseDown(props.side, e);\n _el$4.$$click = e => props.onToggleClick(props.side, e);\n return _el$4;\n })();\n })(), null);\n _$insert(_el$2, (() => {\n var _c$4 = _$memo(() => !!(props.side === \"right\" && !props.isCollapsed()));\n return () => _c$4() && (() => {\n var _el$5 = _tmpl$3();\n _el$5.$$mousedown = e => props.onMouseDown(props.side, e);\n _el$5.$$click = e => props.onToggleClick(props.side, e);\n return _el$5;\n })();\n })(), null);\n _$insert(_el$2, (() => {\n var _c$5 = _$memo(() => !!(props.side === \"right\" && props.isCollapsed() && canExpand()));\n return () => _c$5() && (() => {\n var _el$6 = _tmpl$4();\n _el$6.$$mousedown = e => props.onMouseDown(props.side, e);\n _el$6.$$click = e => props.onToggleClick(props.side, e);\n return _el$6;\n })();\n })(), null);\n _$insert(_el$2, (() => {\n var _c$6 = _$memo(() => !!(props.side === \"right\" && !props.isCollapsed()));\n return () => _c$6() && content();\n })(), null);\n _$effect(_p$ => {\n var _v$3 = props.side,\n _v$4 = props.isCollapsed() ? \"\" : void 0,\n _v$5 = widthStyle();\n _v$3 !== _p$.e && _$setAttribute(_el$2, \"data-side\", _p$.e = _v$3);\n _v$4 !== _p$.t && _$setAttribute(_el$2, \"data-collapsed\", _p$.t = _v$4);\n _v$5 !== _p$.a && _$setStyleProperty(_el$2, \"width\", _p$.a = _v$5);\n return _p$;\n }, {\n e: undefined,\n t: undefined,\n a: undefined\n });\n return _el$2;\n })();\n}\n_$delegateEvents([\"click\", \"mousedown\"]);", "import { template as _$template } from \"solid-js/web\";\nimport { delegateEvents as _$delegateEvents } from \"solid-js/web\";\nimport { setAttribute as _$setAttribute } from \"solid-js/web\";\nimport { effect as _$effect } from \"solid-js/web\";\nimport { insert as _$insert } from \"solid-js/web\";\nimport { createComponent as _$createComponent } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<div role=tablist class=context-sidebar__tablist>`),\n _tmpl$2 = /*#__PURE__*/_$template(`<button type=button role=tab class=context-sidebar__tab>`);\nimport { For } from \"solid-js\";\nexport function ContextTabs(props) {\n const activeToolId = () => {\n const ids = props.items().map(item => item.id);\n const selected = props.selectedToolId();\n return selected && ids.includes(selected) ? selected : ids[0];\n };\n return (() => {\n var _el$ = _tmpl$();\n _$insert(_el$, _$createComponent(For, {\n get each() {\n return props.items();\n },\n children: item => (() => {\n var _el$2 = _tmpl$2();\n _el$2.$$click = () => props.setSelectedToolId(item.id);\n _$insert(_el$2, () => item.name);\n _$effect(() => _$setAttribute(_el$2, \"data-active\", activeToolId() === item.id ? \"\" : void 0));\n return _el$2;\n })()\n }));\n return _el$;\n })();\n}\n_$delegateEvents([\"click\"]);", "import { template as _$template } from \"solid-js/web\";\nimport { effect as _$effect } from \"solid-js/web\";\nimport { getOwner as _$getOwner } from \"solid-js/web\";\nimport { createComponent as _$createComponent } from \"solid-js/web\";\nimport { memo as _$memo } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<patchwork-view>`, true, false, false);\nimport { Show } from \"solid-js\";\nexport const slotId = slot => Array.isArray(slot) ? String(slot[0]) : String(slot);\nexport function SlotView(props) {\n return _$createComponent(Show, {\n get when() {\n return _$memo(() => !!Array.isArray(props.slot))() ? props.slot : false;\n },\n get fallback() {\n return (() => {\n var _el$ = _tmpl$();\n _el$._$owner = _$getOwner();\n _$effect(() => _el$.component = String(props.slot));\n return _el$;\n })();\n },\n children: tuple => (() => {\n var _el$2 = _tmpl$();\n _el$2._$owner = _$getOwner();\n _$effect(_p$ => {\n var _v$ = tuple()[1],\n _v$2 = tuple()[0];\n _v$ !== _p$.e && (_el$2.docUrl = _p$.e = _v$);\n _v$2 !== _p$.t && (_el$2.toolId = _p$.t = _v$2);\n return _p$;\n }, {\n e: undefined,\n t: undefined\n });\n return _el$2;\n })()\n });\n}", "import { template as _$template } from \"solid-js/web\";\nimport { effect as _$effect } from \"solid-js/web\";\nimport { getOwner as _$getOwner } from \"solid-js/web\";\nimport { insert as _$insert } from \"solid-js/web\";\nimport { memo as _$memo } from \"solid-js/web\";\nimport { createComponent as _$createComponent } from \"solid-js/web\";\nimport { use as _$use } from \"solid-js/web\";\nvar _tmpl$ = /*#__PURE__*/_$template(`<div class=document-view>`),\n _tmpl$2 = /*#__PURE__*/_$template(`<patchwork-view>`, true, false, false),\n _tmpl$3 = /*#__PURE__*/_$template(`<div class=placeholder>Select a document in the sidebar`);\nimport { Show } from \"solid-js\";\nexport function MainDocumentView({\n viewKey,\n selectedDocUrl,\n toolId,\n ref\n}) {\n return (() => {\n var _el$ = _tmpl$();\n var _ref$ = ref;\n typeof _ref$ === \"function\" ? _$use(_ref$, _el$) : ref = _el$;\n _$insert(_el$, _$createComponent(Show, {\n get when() {\n return viewKey();\n },\n keyed: true,\n children: key => {\n return (() => {\n var _el$2 = _tmpl$2();\n _el$2._$owner = _$getOwner();\n _$effect(_p$ => {\n var _v$ = selectedDocUrl(),\n _v$2 = toolId();\n _v$ !== _p$.e && (_el$2.docUrl = _p$.e = _v$);\n _v$2 !== _p$.t && (_el$2.toolId = _p$.t = _v$2);\n return _p$;\n }, {\n e: undefined,\n t: undefined\n });\n return _el$2;\n })();\n }\n }), null);\n _$insert(_el$, (() => {\n var _c$ = _$memo(() => !!!selectedDocUrl());\n return () => _c$() && _tmpl$3();\n })(), null);\n return _el$;\n })();\n}", ":root,\n:host,\n[theme] {\n --threepane-bg: var(--studio-fill, white);\n --threepane-sidebar-fill: var(--studio-chrome, var(--studio-fill, white));\n --threepane-fg: var(--studio-line, black);\n /* ink for text sitting ON the sidebar/account-bar chrome surface. mirrors the\n toolbar/context-sidebar fg: it rides --studio-chrome-line (the chrome's own\n ink) so it tracks the chrome palette, not the content page. --threepane-fg\n is content ink and only belongs on --threepane-bg surfaces. */\n --threepane-sidebar-fg: var(--studio-chrome-line, var(--studio-line, black));\n --threepane-muted: var(--studio-line-offset-50, #999);\n --threepane-family: var(--studio-family-sans, system-ui, sans-serif);\n --threepane-family-code: var(--studio-family-code, ui-monospace, monospace);\n\n /* spacing scale, aliased from the base theme */\n --threepane-space-3xs: var(--studio-space-3xs, 0.125rem);\n --threepane-space-2xs: var(--studio-space-2xs, 0.25rem);\n --threepane-space-xs: var(--studio-space-xs, 0.375rem);\n --threepane-space-sm: var(--studio-space-sm, 0.5rem);\n --threepane-space: var(--studio-space, 0.75rem);\n --threepane-space-md: var(--studio-space-md, 1rem);\n --threepane-space-2xl: var(--studio-space-2xl, 3rem);\n\n /* radius scale, aliased from the base theme */\n --threepane-radius-xs: var(--studio-radius-xs, 2px);\n --threepane-radius-sm: var(--studio-radius-sm, 4px);\n --threepane-radius-md: var(--studio-radius-md, 8px);\n --threepane-radius-round: var(--studio-radius-round, 9999px);\n\n /* Height of the frame's top strip: the top bar over the main column, and the\n matching empty space reserved above the left sidebar's widgets so the two\n line up and the left toggle has a home. */\n --threepane-header-height: calc(\n env(safe-area-inset-top, 0px) + var(--threepane-space-2xl)\n );\n\n /* the left footer and right tray boxes share one height so they line up. */\n --threepane-tray-height: var(--threepane-space-2xl);\n /* sidebar toggles ride a touch paler than the line (first ink offset). they\n sit on chrome (left toggle over the sidebar, right over the toolbar), so\n they use the chrome ink ramp, not the content one. */\n --threepane-toggle-fg: var(--studio-chrome-line-offset-10, var(--studio-line-offset-10, #333));\n\n --threepane-toolbar: var(--studio-chrome, white);\n /* toolbar text rides on the chrome surface, so it uses the chrome ink */\n --threepane-toolbar-fg: var(--studio-chrome-line, var(--studio-line, black));\n --threepane-toolbar-border: var(--studio-chrome-offset-10, #ddd);\n /* Resize handle: a faint 1px divider that tracks the chrome ramp's contrast\n (it mixes toward the chrome ink, so it reads darker on light themes and\n lighter on dark ones), plus a primary-tinted glow + grab pill on hover. */\n --threepane-sidebar-divider: var(--studio-chrome-offset-20, #d4d4d4);\n --threepane-resize-glow: color-mix(in oklch, var(--studio-primary-fill, var(--studio-primary, #35f7ca)), transparent 35%);\n --threepane-resize-pill: var(--studio-primary-fill, var(--studio-primary, #35f7ca));\n\n /* The context (right) sidebar sits on a chrome surface stepped one offset off\n the toolbar's flat chrome, so the two chrome regions read as distinct. */\n --threepane-context-sidebar-fill: var(--studio-chrome-offset-10, #ececec);\n\n /* Context sidebar (tabbed) */\n --context-sidebar-bg: var(--threepane-context-sidebar-fill);\n /* the tab-bar header rides on the same flat chrome as the toolbar above it,\n so the two chrome strips read as one continuous band */\n --context-sidebar-header-bg: var(--studio-chrome, #f2f2f2);\n --context-sidebar-fg: var(--studio-chrome-line, var(--studio-line, black));\n /* match the lines drawn around the document-view so tab/tray edges read as\n one continuous frame */\n --context-sidebar-border: var(--threepane-toolbar-border);\n --context-sidebar-tab-fg: var(--studio-chrome-line-offset-40, var(--studio-line-offset-40, #666));\n --context-sidebar-tab-hover: var(--studio-chrome-offset-10, #e5e5e5);\n --context-sidebar-tab-active-bg: var(--studio-fill, white);\n --context-sidebar-tab-active-fg: var(--studio-line, black);\n --context-sidebar-tab-active-accent: var(--studio-primary-line, var(--studio-primary, #35f7ca));\n /* the content panel shares the active tab's surface so the selected tab\n connects seamlessly into the tool view below it */\n --context-sidebar-content-bg: var(--context-sidebar-tab-active-bg);\n --context-sidebar-family: var(--studio-family-sans, system-ui, sans-serif);\n}\n\n.frame-shell {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n}\n\n.frame-warning-banner {\n flex: none;\n padding: var(--threepane-space-2xs) var(--threepane-space-sm);\n text-align: center;\n text-transform: uppercase;\n font-family: var(--studio-family-ui, var(--threepane-family));\n font-size: 0.75rem;\n background: var(--studio-warning-fill, yellow);\n color: var(--studio-warning-line);\n}\n\n.frame {\n position: relative;\n display: flex;\n width: 100%;\n flex: 1;\n min-height: 0;\n font-family: var(--threepane-family);\n color: var(--threepane-fg);\n background: var(--threepane-bg);\n}\n\n.frame__version {\n position: absolute;\n top: var(--threepane-space-2xs);\n right: var(--threepane-space-sm);\n z-index: 10;\n color: var(--threepane-muted);\n font-size: 0.75rem;\n font-weight: 500;\n pointer-events: none;\n user-select: none;\n}\n\n.sidebar {\n position: relative;\n display: flex;\n flex: none;\n /* visible so the resize handle can straddle the boundary (sit on *both*\n sides of the divider line); the content clips itself instead. z-index lifts\n the handle's outer half above the main area so it stays grabbable. */\n overflow: visible;\n z-index: 1;\n}\n\n.sidebar[data-collapsed] {\n overflow: visible;\n}\n\n.sidebar[data-side=\"left\"] {\n background: var(--threepane-sidebar-fill);\n color: var(--threepane-sidebar-fg);\n}\n\n.sidebar[data-side=\"right\"] {\n background: var(--threepane-context-sidebar-fill);\n}\n\n.main-area {\n flex: 1;\n min-width: 0;\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n}\n\n/* The main column (right of the left sidebar): a row of\n [document column | right sidebar], so the right sidebar spans the full frame\n height and its resize divider runs top-to-bottom exactly like the left one. */\n.frame__main-column {\n position: relative;\n flex: 1;\n min-width: 0;\n display: flex;\n flex-direction: row;\n height: 100%;\n overflow: hidden;\n}\n\n/* The document column: the top bar over the main document view. Sits left of the\n full-height context sidebar. */\n.frame__doc-column {\n flex: 1;\n min-width: 0;\n width: 100%;\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n}\n\n.frame__doc-column > patchwork-view,\n.frame__doc-column > patchwork-view > patchwork-view,\n.frame__doc-column > patchwork-view > patchwork-view > patchwork-view,\n.frame__doc-column\n > patchwork-view\n > patchwork-view\n > patchwork-view\n > patchwork-view {\n display: contents;\n}\n\n/* The full-width top toolbar. Its height + top safe-area inset match the\n sideboard's reserved top margin so the bar reads as continuous across the top\n (the left sidebar's empty top region lines up with it). */\n.frame__topbar {\n display: flex;\n align-items: stretch;\n box-sizing: border-box;\n min-height: var(--threepane-space-2xl);\n padding-top: env(safe-area-inset-top, 0px);\n padding-inline: var(--threepane-space-2xs);\n gap: var(--threepane-space-2xs);\n background: var(--threepane-toolbar);\n color: var(--threepane-toolbar-fg);\n /* A hairline along the bottom, in the same colour as the document-view's\n border, so the line under the bar runs unbroken across the whole width\n (document column + context tabs). The active tab pulls down 1px to break\n through it and connect to its panel below. */\n border-bottom: 1px solid var(--threepane-toolbar-border);\n /* Animate the collapsed left-slot in step with the sidebar's width transition\n so the title glides up against the pinned toggle instead of jumping. */\n transition: padding-left var(--studio-transition-slow, 0.25s ease);\n}\n\n/* When the left sidebar is collapsed the bar's left edge reaches the frame edge,\n where the pinned left toggle lives; reserve a matching slot so the title slides\n up against the toggle rather than under it. */\n.frame__topbar--left-collapsed {\n padding-left: var(--threepane-space-2xl);\n}\n\n/* The left sidebar toggle, pinned to the frame's top-left corner so it keeps the\n same spot whether the sidebar is open or closed. Square, filling the top strip;\n sits over the sidebar's reserved (empty) top area when open. */\n.frame__left-toggle {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 5;\n width: var(--threepane-space-2xl);\n height: var(--threepane-header-height);\n padding-top: env(safe-area-inset-top, 0px);\n}\n\n/* A sidebar toggle at either end of the top bar (always present). */\n.frame__sidebar-toggle {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n padding-inline: var(--threepane-space-sm);\n border: none;\n background: transparent;\n color: var(--threepane-toggle-fg);\n cursor: pointer;\n transition: color var(--studio-transition-fast, 0.1s ease);\n}\n\n.frame__sidebar-toggle:hover {\n color: var(--threepane-sidebar-fg);\n}\n\n/* The document title, rendered intrinsically: shrinks to the title's width but\n never past half the bar; ellipsis beyond. */\n.threepane__title {\n display: flex;\n align-items: center;\n flex: 0 1 auto;\n min-width: 0;\n max-width: 50%;\n overflow: hidden;\n padding-inline: var(--threepane-space-sm);\n}\n\n.threepane__title-text {\n font-weight: 600;\n white-space: nowrap;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.threepane__title-text--editable {\n cursor: text;\n}\n\n.threepane__title-text--editable:hover {\n opacity: 0.7;\n}\n\n.threepane__title-input {\n font: inherit;\n font-weight: 600;\n color: inherit;\n min-width: 0;\n width: 100%;\n padding: 0;\n margin: 0;\n border: none;\n outline: none;\n background: transparent;\n}\n\n/* built-in spacer between the title and the right-hand tools */\n.threepane__spacer {\n flex: 1;\n min-width: var(--threepane-space-sm);\n}\n\n/* configured doctitle tools at the right end; scroll horizontally when they\n overflow rather than squashing. */\n.threepane__doctitle-tools {\n display: flex;\n align-items: center;\n gap: var(--threepane-space-sm);\n min-width: 0;\n padding-inline: var(--threepane-space-sm);\n overflow-x: auto;\n overflow-y: hidden;\n scrollbar-width: none;\n}\n\n.threepane__doctitle-tools::-webkit-scrollbar {\n display: none;\n}\n\n.threepane__doctitle-tools patchwork-view {\n display: flex;\n align-items: center;\n height: 2rem;\n flex-shrink: 0;\n width: auto;\n}\n\n.document-view {\n flex: 1;\n min-height: 0;\n overflow: hidden;\n /* Left divider only, square corners. The top line is the top bar's\n border-bottom and the bottom is open to the frame edge. The right divider\n (to the context sidebar) is the sidebar's own full-height border-left, so\n it runs the whole frame height rather than just the document view. When the\n left sidebar is collapsed the left divider is dropped (see the :has rule\n below) so nothing rides the frame edge. */\n border-left: 1px solid var(--threepane-toolbar-border);\n}\n\n/* Left sidebar collapsed to 0: drop the document-view's left divider so there's\n no stray line hugging the frame's left edge. */\n.frame:has(.sidebar[data-side=\"left\"][data-collapsed]) .document-view {\n border-left: none;\n}\n\n.document-view patchwork-view {\n display: block;\n width: 100%;\n height: 100%;\n}\n\n.placeholder {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n color: var(--threepane-fg);\n}\n\n.sidebar patchwork-view {\n display: block;\n width: 100%;\n height: 100%;\n /* the sidebar itself no longer clips, so the content does */\n overflow: hidden;\n}\n\n/* Context sidebar (tabbed)\n Ported from the standalone `context-sidebar` tool (main): lifted tabs with a\n top accent bar and surface fill on the active tab, a hover surface, and a\n bottom-border separator between the tab bar and the mounted tool view. */\n.context-sidebar {\n flex: 1;\n min-width: 0;\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n font-family: var(--context-sidebar-family);\n color: var(--context-sidebar-fg);\n background: var(--context-sidebar-bg);\n /* The full-height divider between the document column and the sidebar. Lives\n here (not on the document view) so it runs the whole frame height \u2014 top bar\n level included \u2014 and the resize handle straddling this edge is grabbable end\n to end, matching the left sidebar. */\n border-left: 1px solid var(--context-sidebar-border);\n}\n\n/* Tab bar: the row holding the tab list and the collapse button. Its height +\n top safe-area inset match the document column's top bar so the two header\n strips line up and their bottom hairlines read as one continuous line across\n the divider. */\n.context-sidebar__tabs {\n display: flex;\n align-items: flex-end;\n box-sizing: border-box;\n min-height: var(--threepane-space-2xl);\n padding-top: env(safe-area-inset-top, 0px);\n background: var(--context-sidebar-header-bg);\n border-bottom: 1px solid var(--context-sidebar-border);\n}\n\n.context-sidebar__tablist {\n display: flex;\n flex: 1;\n min-width: 0;\n align-items: flex-end;\n gap: var(--threepane-space-2xs);\n padding-inline: var(--threepane-space-2xs);\n /* when there are more tabs than fit, scroll them horizontally rather than\n letting them shrink/wrap; scrollbar hidden for a clean header. */\n overflow-x: auto;\n overflow-y: hidden;\n scrollbar-width: none;\n /* extend the clip box 1px past the tab-bar border (compensated by the\n negative margin so layout is unchanged) so the active tab's -1px overflow\n isn't clipped by the horizontal scroll container, and it can still cover\n the border-bottom to connect into the panel. */\n padding-bottom: 1px;\n margin-bottom: -1px;\n}\n.context-sidebar__tablist::-webkit-scrollbar {\n display: none;\n}\n\n/* A single tab. */\n.context-sidebar__tab {\n display: flex;\n align-items: center;\n flex-shrink: 0;\n padding: var(--threepane-space-xs) var(--threepane-space-sm);\n border: 1px solid transparent;\n border-bottom: none;\n border-top-left-radius: var(--threepane-radius-xs);\n border-top-right-radius: var(--threepane-radius-xs);\n background: transparent;\n font-family: inherit;\n font-size: 0.875rem;\n white-space: nowrap;\n color: var(--context-sidebar-tab-fg);\n cursor: pointer;\n user-select: none;\n transition: background var(--studio-transition-fast, 0.1s ease),\n color var(--studio-transition-fast, 0.1s ease);\n}\n\n.context-sidebar__tab:hover {\n background: var(--context-sidebar-tab-hover);\n color: var(--context-sidebar-tab-active-fg);\n}\n\n/* Exception: the selected tab. Pulled down 1px so its fill covers the tab-bar's\n bottom border, connecting the tab seamlessly into the panel below. */\n.context-sidebar__tab[data-active] {\n position: relative;\n margin-bottom: -1px;\n background: var(--context-sidebar-tab-active-bg);\n color: var(--context-sidebar-tab-active-fg);\n border-color: var(--context-sidebar-border);\n box-shadow: inset 0 1px 0 0 var(--context-sidebar-tab-active-accent);\n}\n\n/* The close (collapse) button. Centred vertically in the tab header (the header\n is otherwise flex-end for the tabs) so it lands at the same height as the\n reopen toggle in the top bar when the sidebar is collapsed. */\n.context-sidebar__close {\n display: flex;\n align-items: center;\n justify-content: center;\n align-self: center;\n flex-shrink: 0;\n padding-inline: var(--threepane-space-sm);\n margin-right: var(--threepane-space-2xs);\n border: none;\n background: transparent;\n color: var(--context-sidebar-fg);\n cursor: pointer;\n opacity: 0.5;\n transition: opacity var(--studio-transition-fast, 0.1s ease);\n}\n\n.context-sidebar__close:hover {\n opacity: 1;\n}\n\n/* The mounted tool view. */\n.context-sidebar__content {\n flex: 1;\n min-height: 0;\n overflow: auto;\n background: var(--context-sidebar-content-bg);\n contain: content;\n}\n\n.context-sidebar__content patchwork-view {\n display: block;\n width: 100%;\n height: 100%;\n}\n\n/* Left sidebar body: a stack of widgets with the account footer pinned below. */\n.threepane-sidebar {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n min-height: 0;\n}\n\n/* Reserve the docked tray's height at the sidebar's bottom so the account bar\n sits above the tray (which is pinned outside this collapsing column). */\n.threepane-sidebar--has-tray {\n padding-bottom: calc(\n var(--threepane-tray-height) + env(safe-area-inset-bottom, 0px)\n );\n}\n\n/* account / packages / settings footer, pinned to the sidebar bottom */\n.threepane-sidebar--has-tray .threepane-sidebar__footer {\n flex: none;\n margin-bottom: calc(var(--threepane-tray-height) + env(safe-area-inset-bottom, 0px));\n}\n\n/* The inlined account bar: avatar (account picker) + Packages + Settings. Ported\n from the sideboard `account-bar` tool onto threepane tokens so the frame owns\n the markup directly. */\n.threepane-account-bar {\n container-type: inline-size;\n display: flex;\n align-items: center;\n gap: var(--threepane-space-md);\n min-height: var(--threepane-space-2xl);\n box-sizing: border-box;\n background: var(--threepane-sidebar-fill);\n color: var(--threepane-sidebar-fg);\n border-top: 1px solid var(--threepane-sidebar-divider);\n padding-block: var(--threepane-space-2xs);\n padding-bottom: calc(var(--threepane-space-2xs) + env(safe-area-inset-bottom));\n padding-left: calc(env(safe-area-inset-left) + var(--threepane-space-md));\n padding-right: calc(env(safe-area-inset-right) + var(--threepane-space-md));\n justify-content: space-between;\n overflow: hidden;\n}\n\n.threepane-account-bar__button {\n display: flex;\n align-items: center;\n border: 1px solid transparent;\n padding-inline: var(--threepane-space-2xs);\n padding-block: var(--threepane-space-3xs);\n border-radius: var(--threepane-radius-xs);\n background: transparent;\n color: inherit;\n font: inherit;\n white-space: nowrap;\n cursor: pointer;\n}\n\n.threepane-account-bar__button:hover {\n border-color: var(--threepane-sidebar-divider);\n}\n\n.threepane-account-bar__avatar {\n padding: 0;\n}\n\n.threepane-account-bar__avatar patchwork-view {\n display: block;\n width: 100%;\n height: 100%;\n}\n\n/* Left sidebar: a stack of configured widgets. The widgets start below the\n frame's top strip (the empty space matching the top bar), so the frame owns\n that spacing rather than each widget reserving its own top margin. */\n.threepane-widgets {\n flex: 1;\n display: flex;\n flex-direction: column;\n width: 100%;\n min-height: 0;\n padding-top: var(--threepane-header-height);\n gap: 1rem;\n}\n\n.threepane-widget {\n position: relative;\n flex: 1;\n min-height: 0;\n overflow: hidden;\n}\n\n.threepane-widget patchwork-view {\n display: block;\n width: 100%;\n height: 100%;\n}\n\n/* empty state: offer to add the document list */\n.threepane-widgets__empty {\n flex: 1;\n display: flex;\n align-items: flex-start;\n justify-content: center;\n}\n\n.threepane-widgets__add {\n padding: var(--threepane-space-xs) var(--threepane-space-sm);\n border: 1px dashed var(--threepane-sidebar-divider);\n border-radius: var(--threepane-radius-sm);\n background: transparent;\n color: var(--threepane-muted);\n font: inherit;\n cursor: pointer;\n white-space: nowrap;\n}\n\n.threepane-widgets__add:hover:not(:disabled) {\n color: var(--threepane-sidebar-fg);\n border-color: var(--threepane-sidebar-fg);\n}\n\n.threepane-widgets__add:disabled {\n opacity: 0.5;\n cursor: default;\n}\n\n/* System tray dock: pinned to the frame's bottom-left. Lives outside the\n collapsing left sidebar so it isn't torn down when the sidebar closes. When\n the sidebar is open the dock spans its width (set inline) and fills the space\n reserved by `threepane-sidebar--has-tray`; when the sidebar closes the dock is\n hidden (`display: none`) but stays mounted, so the tray is invisible while its\n tools keep running. */\n.frame__tray-dock {\n position: absolute;\n left: 0;\n bottom: 0;\n z-index: 4;\n box-sizing: border-box;\n /* Fade the tray in only *after* the sidebar's width animation completes, so it\n doesn't flash at full size over the still-expanding sidebar. The delay equals\n the sidebar's transition duration; collapsing overrides this to hide at once. */\n opacity: 1;\n transition: opacity 0.1s ease 0.25s;\n}\n\n.frame__tray-dock--collapsed {\n opacity: 0;\n pointer-events: none;\n /* Hide immediately on collapse \u2014 no wait, no fade. */\n transition: opacity 0s;\n}\n\n/* A row of tray-tagged tools, filling the dock. */\n.frame-tray {\n display: flex;\n align-items: center;\n gap: var(--threepane-space-2xs);\n box-sizing: border-box;\n /* min-height includes the safe-area inset (border-box), and the matching\n padding-bottom lifts the tray's contents clear of it while the tray's own\n background fills the inset down to the very bottom edge. */\n min-height: calc(\n var(--threepane-tray-height) + env(safe-area-inset-bottom, 0px)\n );\n padding-inline: var(--threepane-space-sm);\n padding-bottom: env(safe-area-inset-bottom, 0px);\n border-top: 1px solid var(--threepane-sidebar-divider);\n background: var(--threepane-sidebar-fill);\n}\n\n.frame-tray__item {\n display: flex;\n align-items: center;\n}\n\n.frame-tray patchwork-view {\n display: flex;\n width: auto;\n height: auto;\n}\n\n/* Debug Registry Toast */\n.debug-registry-toast {\n position: fixed;\n bottom: var(--threepane-space-md);\n right: var(--threepane-space-md);\n z-index: 9999;\n max-width: 360px;\n font-family: var(--threepane-family-code);\n font-size: 0.75rem;\n background: oklch(0.15 0.01 270);\n border: 1px solid oklch(0.35 0.03 270);\n border-radius: var(--threepane-radius-md);\n box-shadow:\n 0 8px 32px oklch(0 0 0 / 0.4),\n 0 0 0 1px oklch(1 0 0 / 0.05) inset;\n overflow: hidden;\n backdrop-filter: blur(12px);\n}\n\n.debug-registry-toast__header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: var(--threepane-space-sm) var(--threepane-space);\n background: oklch(0.2 0.02 270);\n border-bottom: 1px solid oklch(0.3 0.02 270);\n}\n\n.debug-registry-toast__title {\n color: oklch(0.85 0.1 270);\n font-weight: 600;\n letter-spacing: 0.02em;\n}\n\n.debug-registry-toast__clear {\n background: none;\n border: none;\n color: oklch(0.6 0.05 270);\n cursor: pointer;\n padding: var(--threepane-space-2xs) var(--threepane-space-sm);\n border-radius: var(--threepane-radius-sm);\n transition: all 0.15s ease;\n}\n\n.debug-registry-toast__clear:hover {\n background: oklch(0.25 0.02 270);\n color: oklch(0.9 0.05 0);\n}\n\n.debug-registry-toast__list {\n max-height: 300px;\n overflow-y: auto;\n}\n\n.debug-registry-toast__item {\n display: flex;\n align-items: flex-start;\n gap: var(--threepane-space-sm);\n padding: var(--threepane-space-sm) var(--threepane-space);\n border-left: 3px solid transparent;\n cursor: pointer;\n transition: all 0.15s ease;\n animation: toast-slide-in 0.2s ease-out;\n}\n\n.debug-registry-toast__item:hover {\n background: oklch(0.2 0.01 270);\n}\n\n.debug-registry-toast__item:not(:last-child) {\n border-bottom: 1px solid oklch(0.25 0.01 270);\n}\n\n.debug-registry-toast__icon {\n font-size: 0.875rem;\n line-height: 1;\n flex-shrink: 0;\n}\n\n.debug-registry-toast__content {\n display: flex;\n flex-direction: column;\n gap: var(--threepane-space-3xs);\n min-width: 0;\n}\n\n.debug-registry-toast__event-type {\n color: oklch(0.7 0.15 150);\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n font-size: 0.625rem;\n}\n\n.debug-registry-toast__plugin-type {\n color: oklch(0.6 0.1 60);\n font-size: 0.6875rem;\n}\n\n.debug-registry-toast__plugin-id {\n color: oklch(0.9 0.02 270);\n font-weight: 500;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n}\n@keyframes toast-slide-in {\n from {\n opacity: 0;\n transform: translateX(20px);\n }\n to {\n opacity: 1;\n transform: translateX(0);\n }\n}\n\n\n/* Isolation-mode chrome popover.\n In isolation the main document area is a sandboxed iframe, so host-realm tools\n opened from the account bar (account picker / Packages / Settings) are floated\n over the frame here instead of being routed into the iframe. The backdrop is a\n lowish-opacity, theme-tinted ink wash (dims the frame + picks up the theme's\n ink hue); the panel carries a soft drop shadow so it reads as lifted. Absolute\n inset:0 resolves to the `.frame` (its nearest positioned ancestor). */\n.frame__popover-backdrop {\n position: absolute;\n inset: 0;\n z-index: 1000;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: var(--threepane-space-2xl);\n background: color-mix(in oklch, var(--threepane-fg), transparent 82%);\n animation: frame-popover-fade var(--studio-transition, 0.15s ease);\n}\n\n.frame__popover {\n display: flex;\n flex-direction: column;\n width: min(1100px, 100%);\n height: min(900px, 100%);\n overflow: hidden;\n background: var(--threepane-bg);\n color: var(--threepane-fg);\n border: 1px solid var(--threepane-toolbar-border);\n border-radius: var(--threepane-radius-md);\n box-shadow:\n 0 32px 80px color-mix(in oklch, var(--threepane-fg), transparent 45%),\n 0 12px 32px color-mix(in oklch, var(--threepane-fg), transparent 60%),\n 0 2px 8px color-mix(in oklch, var(--threepane-fg), transparent 70%);\n animation: frame-popover-pop var(--studio-transition, 0.15s ease);\n}\n\n/* The \"Open with\" picker, docked to the popover's top. Sits at its natural\n height above the tool body; the doc-openwith tool renders a small titlebar\n button, so this is left-aligned chrome rather than a full-height view. */\n.frame__popover-toolbar {\n display: flex;\n align-items: center;\n flex: 0 0 auto;\n gap: var(--threepane-space-sm);\n padding: var(--threepane-space-sm) var(--threepane-space-md);\n border-bottom: 1px solid var(--threepane-toolbar-border);\n}\n\n.frame__popover-toolbar patchwork-view {\n display: block;\n}\n\n.frame__popover-body {\n flex: 1 1 auto;\n min-height: 0;\n overflow: auto;\n}\n\n.frame__popover-body patchwork-view {\n display: block;\n width: 100%;\n height: 100%;\n overflow: auto;\n}\n\n@keyframes frame-popover-fade {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n\n@keyframes frame-popover-pop {\n from {\n opacity: 0;\n transform: translateY(8px) scale(0.98);\n }\n to {\n opacity: 1;\n transform: none;\n }\n}\n\n/* Custom colors for event types */\n:root,\n:host,\n[theme] {\n --debug-toast-registered: var(--studio-secondary-text, color-mix(in oklch, var(--studio-secondary, #33ccf8), var(--studio-line, black) 20%));\n --debug-toast-loaded: color-mix(in oklch, var(--studio-added, #35f7ca), var(--studio-line, black) 10%);\n --debug-toast-removed: var(--studio-danger-text, color-mix(in oklch, var(--studio-danger, #ff6a90), var(--studio-line, black) 20%));\n --debug-toast-changed: var(--studio-warning-text, color-mix(in oklch, var(--studio-warning, #f8c43b), var(--studio-line, black) 10%));\n}\n\n.frame {\n.sidebar-toggle {\n position: relative;\n align-self: stretch;\n height: 100%;\n padding: 0;\n /* 1px wide, overlapping the divider border while reserving no layout column\n (content stays flush against the view's border - no offset-bg seam). The\n divider border is painted inside the following column, so a centered 2px\n strip reads half a pixel left of the line. */\n width: 1px;\n margin-inline: 0 -1px;\n margin-block: 0;\n border: 0;\n z-index: 1;\n cursor: pointer;\n /* transparent at rest - the visible divider is the main view's border; the\n handle lights up (full-height glow + pill) on hover to signal resize. */\n background: transparent;\n transition: background-color var(--studio-transition, 0.15s ease);\n /* invisible hit target straddling the divider. The toggle sits on opposite\n edges of the two sidebars (right edge of the left pane, left edge of the\n right pane), so the asymmetric grab margin is mirrored per side to stay\n centred over the divider line. */\n &::before {\n content: \"\";\n position: absolute;\n inset-block: 0;\n }\n &::after {\n content: \"\";\n position: absolute;\n top: 50%;\n left: 50%;\n width: 5px;\n height: 44px;\n border-radius: var(--threepane-radius-round);\n background: var(--threepane-resize-pill);\n opacity: 0;\n transform: translate(-50%, -50%) scaleY(0.55);\n transition: opacity var(--studio-transition, 0.15s ease),\n transform var(--studio-transition, 0.15s ease);\n pointer-events: none;\n }\n /* on hover the divider line lights up in the frame primary */\n &:hover,\n &:active {\n background: var(--threepane-resize-glow);\n }\n &:hover::after,\n &:active::after {\n opacity: 1;\n transform: translate(-50%, -50%) scaleY(1);\n }\n}\n\n.sidebar-toggle--resizable {\n cursor: col-resize;\n &:hover {\n cursor: col-resize;\n }\n &:active {\n cursor: col-resize;\n }\n}\n\n}\n\n/* Animate sidebar width on collapse/expand, but never while the handle is being\n actively dragged - the width must track the pointer 1:1 with no easing lag.\n The body flag is set for the duration of a drag by `useSidebarResize`. */\n.sidebar {\n transition: width var(--studio-transition-slow, 0.25s ease);\n}\nbody[data-sidebar-resizing] .sidebar {\n transition: none;\n}\n", "// Imported as a string (not a side-effect import) so the stylesheet is only\n// injected when the frame tool actually activates \u2014 not when index.js loads.\n// esbuild's `.css` text loader (esbuild/options.ts) returns the CSS source.\nimport frameStyles from \"./styles.css\";\n\n/**\n * Inject the threepane stylesheet into the current realm's document, once.\n *\n * Called from both realms: host-side by `PatchworkFrame`, and inside the isolated iframe by\n * `IsolationRoot`.\n */\nexport function ensureFrameStyles() {\n const id = \"patchwork-frame-styles\";\n const existing = document.getElementById(id);\n if (existing) {\n // Already injected in this realm. Refresh its contents if the bundled CSS\n // has changed (a remount after a rebuild) so a stale stylesheet from an\n // earlier mount can't shadow newer rules; otherwise leave it untouched.\n if (existing.textContent !== frameStyles) existing.textContent = frameStyles;\n return;\n }\n const el = document.createElement(\"style\");\n el.id = id;\n el.textContent = frameStyles;\n document.head.append(el);\n}\n"],
5
- "mappings": "iDAAA,IAAAA,GAAAC,GAAA,CAAAC,GAAAC,KAAA,CAIA,IAAIC,EAAI,IACJC,EAAID,EAAI,GACRE,EAAID,EAAI,GACRE,EAAID,EAAI,GACRE,GAAID,EAAI,EACRE,GAAIF,EAAI,OAgBZJ,GAAO,QAAU,SAAUO,EAAKC,EAAS,CACvCA,EAAUA,GAAW,CAAC,EACtB,IAAIC,EAAO,OAAOF,EAClB,GAAIE,IAAS,UAAYF,EAAI,OAAS,EACpC,OAAOG,GAAMH,CAAG,EACX,GAAIE,IAAS,UAAY,SAASF,CAAG,EAC1C,OAAOC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AAO,CAAC,EAClC,GAAI,CACF,OAAO,KAAK,MAAMA,EAAO,WAAW,CACtC,OAASC,EAAK,CACZ,eAAQ,MAAM,6CAA8CA,CAAG,EACxD,CAAC,CACV,CACF,CACO,SAASC,GAAmBC,EAAS,CAC1CC,GAAkB,EAClB,IAAMJ,EAASG,EAAQ,cAAc,iCAAiC,EAChE,CAACE,EAAGC,CAAI,EAAIC,GAAYR,GAAWC,CAAM,CAAC,EAC1CQ,EAAW,IAAI,iBAAiB,IAAM,CAC1CF,EAAKG,GAAUV,GAAWC,CAAM,CAAC,CAAC,CACpC,CAAC,EACGA,GACFQ,EAAS,QAAQR,EAAQ,CACvB,cAAe,GACf,UAAW,GACX,QAAS,EACX,CAAC,EAEH,IAAMU,EAAUC,GAAO,KAAO,IAAM,CAClC,IAAIC,EAAQ3B,GAAQ,EACpB,OAAAW,GAASgB,EAAOC,GAAkBC,GAAkB,CAClD,eAAgB,IAAMT,EAAE,eACxB,eAAgB,IAAMA,EAAE,eACxB,cAAe,IAAMA,EAAE,cACvB,gBAAiB,IAAMA,EAAE,iBAAmB,GAC5C,kBAAmB,IAAMA,EAAE,mBAAqBU,GAChD,sBAAuB,IAAMV,EAAE,uBAAyB,EAC1D,CAAC,CAAC,EACKO,CACT,GAAG,EAAGT,CAAO,EACb,MAAO,IAAM,CACXK,EAAS,WAAW,EACpBE,EAAQ,CACV,CACF",
6
- "names": ["require_ms", "__commonJSMin", "exports", "module", "s", "m", "h", "d", "w", "y", "val", "options", "type", "parse", "fmtLong", "fmtShort", "str", "match", "n", "ms", "msAbs", "plural", "name", "isPlural", "require_common", "__commonJSMin", "exports", "module", "setup", "env", "createDebug", "coerce", "disable", "enable", "enabled", "destroy", "key", "selectColor", "namespace", "hash", "i", "prevTime", "enableOverride", "namespacesCache", "enabledCache", "debug", "args", "self", "curr", "ms", "index", "match", "format", "formatter", "val", "extend", "v", "delimiter", "newDebug", "namespaces", "split", "ns", "matchesTemplate", "search", "template", "searchIndex", "templateIndex", "starIndex", "matchIndex", "name", "skip", "require_browser", "__commonJSMin", "exports", "module", "formatArgs", "save", "load", "useColors", "localstorage", "warned", "m", "args", "c", "index", "lastC", "match", "namespaces", "r", "formatters", "v", "error", "_$template", "_$createComponent", "_$setAttribute", "_$effect", "_$insert", "_$getOwner", "createMemo", "createStore", "reconcile", "render", "_$template", "_$insert", "_$getOwner", "_$use", "_$createComponent", "parseAutomergeUrl", "stringifyAutomergeUrl", "createSignal", "onCleanup", "onMount", "createStore", "reconcile", "STATE", "OBJECT_ID", "IS_PROXY", "CLEAR_CACHE", "COUNTER", "isCounter", "obj", "Automerge", "ptr", "AutomergeFinalization", "wasm", "commits", "ret", "takeFromExternrefTable0", "fragments", "object", "meta", "changes", "actor", "ptr0", "isLikeNone", "passStringToWasm0", "len0", "WASM_VECTOR_LEN", "message", "time", "prop", "before", "after", "path", "options", "enable", "heads", "state", "_assertClass", "SyncState", "deferred1_0", "deferred1_1", "getStringFromWasm0", "arg", "text", "index", "hash", "have_deps", "other", "position", "move_cursor", "deferred2_0", "deferred2_1", "ptr1", "len1", "cursor", "head", "levels", "value", "datatype", "data", "range", "name", "construct", "deconstruct", "hashes", "start", "delete_count", "del", "values", "block", "args", "config", "new_text", "SyncStateFinalization", "read_only", "instance", "klass", "len", "decodeText", "cachedUint8ArrayMemory0", "getUint8ArrayMemory0", "x", "malloc", "realloc", "buf", "cachedTextEncoder", "mem", "offset", "code", "view", "idx", "cachedTextDecoder", "MAX_SAFARI_DECODE_BYTES", "numBytesDecoded", "_state", "doc", "checkroot", "_obj", "_clear_cache", "_is_proxy", "applyPatch", "patch", "resolvePath", "applyPutPatch", "applyInsertPatch", "applyDelPatch", "applySplicePatch", "applyIncPatch", "applyMarkPatch", "applyUnmarkPatch", "parent", "pathElemAt", "parentPath", "isAutomerge", "splice", "grandParent", "grandParentProp", "target", "counter", "markSpec", "mark", "unmark", "applyPatches", "patches", "result", "current", "currentPath", "resolved", "cursorToIndex", "getObjectId", "objectId", "newText", "objPath", "absoluteObjPath", "e", "functionName", "autoproduce", "payload", "cache", "initial", "handle", "template", "makeDocumentProjection", "onCleanup", "item", "set", "createStore", "ondelete", "reconcile", "produce", "createDocumentProjection", "createMemo", "unwrappedHandle", "RepoContext", "createContext", "subscribe", "element", "selector", "listener", "dispatchEl", "channel", "port", "controller", "signal", "event", "detail", "resolveElement", "source", "subscribeDoc", "element", "selector", "handle", "setHandle", "createSignal", "onMount", "target", "resolveElement", "canceled", "unsubscribe", "subscribe", "url", "repo", "h", "onCleanup", "createDocumentProjection", "createUniqueId", "untrack", "isServer", "isDev", "reconcile", "makePersisted", "signal", "options", "storage", "name", "storageOptions", "serialize", "deserialize", "init", "set", "data", "value", "e", "unchanged", "get", "output", "serialized", "args", "createEffect", "createMemo", "createSignal", "on", "onCleanup", "onMount", "Show", "createEffect", "createSignal", "on", "SIDEBAR_KEYS", "COLLAPSE_CONTEXT_SIDEBAR_EVENT", "DEFAULT_SIDEBAR_WIDTH", "getStoredNumber", "key", "defaultValue", "stored", "getStoredBoolean", "useSidebarState", "isSidebarCollapsed", "setIsSidebarCollapsed", "isRightSidebarCollapsed", "setIsRightSidebarCollapsed", "leftSidebarWidth", "setLeftSidebarWidth", "rightSidebarWidth", "setRightSidebarWidth", "value", "onCleanup", "onMount", "useSidebarResize", "setLeftSidebarWidth", "setRightSidebarWidth", "setIsSidebarCollapsed", "setIsRightSidebarCollapsed", "isLeftCollapsed", "isRightCollapsed", "minWidth", "maxWidth", "autoCloseWidth", "dragThreshold", "isResizing", "dragStartPos", "hasDragged", "lastDragWidth", "setWidth", "side", "w", "setCollapsed", "value", "isCollapsed", "applyDragWidth", "raw", "settleDrag", "dragOverlay", "beginDragVisuals", "endDrag", "handleMouseDown", "e", "handleMouseUp", "dragged", "handleMouseMove", "deltaX", "deltaY", "handleToggleClick", "prev", "createEffect", "createSignal", "onCleanup", "useProviderReady", "componentId", "element", "isReady", "setReady", "el", "onMounted", "event", "createEffect", "createSignal", "onCleanup", "MOUNT_TIMEOUT_MS", "useMainDocMounted", "element", "docUrl", "isMounted", "setMounted", "el", "url", "onSettled", "event", "detail", "timer", "getRegistry", "createMemo", "createSignal", "onCleanup", "useTaggedComponents", "tag", "registry", "version", "setVersion", "off", "v", "description", "b", "_$template", "_$delegateEvents", "_$setStyleProperty", "_$effect", "_$memo", "_$addEventListener", "_$insert", "createEffect", "createSignal", "onCleanup", "getAllRegistries", "_tmpl$", "_tmpl$2", "_tmpl$3", "DEBUG_MODAL_KEY", "isDebugModalEnabled", "setDebugModalEnabled", "enabled", "DEFAULT_EVENTS", "useDebugRegistryToast", "options", "subscribedEvents", "events", "setEvents", "isEnabled", "setIsEnabled", "timeouts", "addEvent", "type", "event", "pluginId", "pluginName", "newEvent", "prev", "timeoutId", "e", "dismissEvent", "eventId", "clearAll", "id", "registries", "unsubscribes", "lastPluginInfo", "registry", "trackRegistered", "plugin", "trackLoaded", "trackRemoved", "unsub", "info", "handleStorageChange", "DebugRegistryToast", "onDismiss", "onClearAll", "eventColor", "_el$", "_el$2", "_el$3", "_el$4", "_el$6", "_el$5", "_el$7", "_el$8", "_el$9", "_el$0", "_el$1", "_el$10", "_c$", "_el$11", "_$p", "_$template", "_$delegateEvents", "_$getOwner", "_$effect", "_$setAttribute", "_$memo", "_$insert", "_$createComponent", "For", "Show", "_$template", "_$delegateEvents", "_$setAttribute", "_$insert", "_$effect", "_$use", "_$createComponent", "import_debug", "log", "debug", "pojo", "target", "BLOCK_MARKER", "apply", "rest", "path", "range", "val", "p", "key", "RANGE_ARRAY", "start", "end", "ZERO_LENGTH", "DELETE", "INSERT", "APPEND", "REPLACE", "seq", "n", "a", "b", "nextkey", "get", "obj", "key", "p", "fromAutomerge", "autopatch", "payload", "path", "log", "autoproduce", "payload", "doc", "patch", "apply", "fromAutomerge", "createMemo", "onCleanup", "createStore", "produce", "reconcile", "cache", "makeDocumentProjection", "handle", "onCleanup", "item", "doc", "set", "patch", "ondelete", "payload", "autoproduce", "getOwner", "onCleanup", "createSignal", "untrack", "sharedConfig", "onMount", "DEV", "equalFn", "isServer", "access", "v", "createDocumentProjection", "handle", "createMemo", "access", "makeDocumentProjection", "createEffect", "createResource", "useContext", "createContext", "RepoContext", "useDocHandle", "url", "options", "contextRepo", "useContext", "RepoContext", "repo", "getExistingHandle", "unwrappedURL", "access", "state", "handle", "mutate", "createResource", "createEffect", "useDocument", "url", "options", "handle", "useDocHandle", "createDocumentProjection", "onCleanup", "createSignal", "createEffect", "onCleanup", "createSignal", "useContext", "getType", "getRegistry", "isLoadedPlugin", "createEffect", "createMemo", "createSignal", "onCleanup", "onMount", "Show", "_tmpl$", "_$template", "_tmpl$2", "DocumentTitle", "props", "anchor", "repo", "setRepo", "_$createComponent", "_el$", "_ref$", "_$use", "resolvedRepo", "DocumentTitleInner", "doc", "handle", "useDocument", "registry", "registryVersion", "setRegistryVersion", "off", "v", "typeId", "d", "id", "datatype", "dt", "title", "canEdit", "editing", "setEditing", "inputRef", "startEditing", "commit", "save", "next", "h", "setTitle", "meta", "_el$3", "_$insert", "_$effect", "_p$", "_v$", "_v$2", "_$setAttribute", "_el$2", "e", "_ref$2", "_$delegateEvents", "_$template", "_$delegateEvents", "_$getOwner", "_$insert", "_$createComponent", "Show", "_$template", "_$delegateEvents", "_$setStyleProperty", "_$setAttribute", "_$insert", "_$memo", "_$effect", "_$getOwner", "_tmpl$", "_tmpl$2", "_tmpl$3", "_tmpl$4", "Sidebar", "props", "widthStyle", "content", "_el$", "_p$", "_v$", "_v$2", "canExpand", "_el$2", "_c$", "_c$2", "_el$3", "e", "_c$3", "_el$4", "_c$4", "_el$5", "_c$5", "_el$6", "_c$6", "_v$3", "_v$4", "_v$5", "_$template", "_$delegateEvents", "_$setAttribute", "_$effect", "_$insert", "_$createComponent", "For", "_tmpl$", "_tmpl$2", "ContextTabs", "props", "activeToolId", "ids", "item", "selected", "_el$", "_el$2", "_tmpl$", "_$template", "_tmpl$2", "_tmpl$3", "_tmpl$4", "_tmpl$5", "ContextSidebar", "props", "items", "useTaggedComponents", "activeToolId", "ids", "item", "selected", "_$createComponent", "Sidebar", "_el$", "_$insert", "Show", "_el$2", "_el$3", "ContextTabs", "PanelRightIcon", "_el$4", "id", "_el$5", "_$getOwner", "_$delegateEvents", "_$template", "_$effect", "_$getOwner", "_$createComponent", "_$memo", "Show", "_tmpl$", "slotId", "slot", "SlotView", "props", "_el$", "tuple", "_el$2", "_p$", "_v$", "_v$2", "_tmpl$", "_$template", "_tmpl$2", "_tmpl$3", "_tmpl$4", "_tmpl$5", "FrameTopBar", "props", "docToolSlots", "_el$", "_el$3", "_$insert", "_$createComponent", "Show", "_el$2", "DocumentTitle", "_$memo", "_el$4", "For", "slot", "_el$6", "_$getOwner", "_$effect", "_p$", "_v$", "slotId", "_v$2", "_el$5", "_$setAttribute", "PanelRightIcon", "_$delegateEvents", "_$template", "_$effect", "_$getOwner", "_$insert", "_$memo", "_$createComponent", "_$use", "Show", "_tmpl$", "_tmpl$2", "_tmpl$3", "MainDocumentView", "viewKey", "selectedDocUrl", "toolId", "ref", "_el$", "_ref$", "key", "_el$2", "_p$", "_v$", "_v$2", "_c$", "_tmpl$", "_$template", "_tmpl$2", "_tmpl$3", "MIN_SIDEBAR_WIDTH", "MAX_SIDEBAR_WIDTH", "AUTO_CLOSE_WIDTH", "DRAG_THRESHOLD", "DocumentAreaRoot", "props", "isRightSidebarCollapsed", "setIsRightSidebarCollapsed", "createSignal", "rightSidebarWidth", "setRightSidebarWidth", "createEffect", "on", "value", "SIDEBAR_KEYS", "setUnusedLeftWidth", "setUnusedLeftCollapsed", "sidebarResize", "useSidebarResize", "onMount", "onCollapse", "COLLAPSE_CONTEXT_SIDEBAR_EVENT", "onCleanup", "selectedContextToolId", "setSelectedContextToolId", "makePersisted", "draftListProviderHost", "setDraftListProviderHost", "isDraftListProviderReady", "useProviderReady", "readyDraftListHost", "_$createComponent", "Show", "docUrl", "_el$", "_$use", "_$getOwner", "_$insert", "host", "DraftDocumentArea", "checkedOut", "subscribeDoc", "draftProviderKey", "createMemo", "contextItems", "useTaggedComponents", "hasContext", "pinnedDocUrl", "url", "documentId", "parseAutomergeUrl", "heads", "stringifyAutomergeUrl", "mainViewKey", "draftOverlayProviderHost", "setDraftOverlayProviderHost", "isDraftOverlayProviderReady", "commentsProviderElement", "setCommentsProviderElement", "isCommentsProviderReady", "focusProviderElement", "setFocusProviderElement", "isFocusProviderReady", "areDocProvidersReady", "key", "_el$2", "_el$3", "_el$4", "_el$5", "_el$6", "_el$7", "FrameTopBar", "v", "MainDocumentView", "el", "ContextSidebar", "styles_default", "ensureFrameStyles", "id", "existing", "styles_default", "el", "_tmpl$", "_$template", "_tmpl$2", "IsolatedDocumentArea", "props", "rootUrls", "createMemo", "urls", "selected", "propsJson", "_el$", "_el$2", "_$getOwner", "_$insert", "_$effect", "_$setAttribute", "parseProps", "script", "err", "mountIsolationRoot", "element", "ensureFrameStyles", "p", "setP", "createStore", "observer", "reconcile", "dispose", "render", "_el$3", "_$createComponent", "DocumentAreaRoot", "DEFAULT_SIDEBAR_WIDTH"]
7
- }