@powerhousedao/powerhouse-vetra-packages 6.2.3-dev.90 → 6.2.3-dev.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/node/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["initialGlobalState","initialLocalState","isDocumentAction","createReducer","baseCreateDocument","baseSaveToFileHandle","createState","defaultBaseState","ReactorGroupV1","manifestJson"],"sources":["../../powerhouse.manifest.json","../../../reactor-drive/dist/constants-DfSjC49y.js","../../../reactor-drive/dist/index.js","../../../reactor-group/dist/rolldown-runtime-D7D4PA-g.js","../../../reactor-group/dist/module-1TFqLbxn.js","../../document-models/document-models.ts","../../editors/editors.ts","../../index.ts"],"sourcesContent":["","//#region src/constants.ts\nconst REACTOR_DRIVE_DOCUMENT_TYPE = \"powerhouse/reactor-drive\";\nconst DRIVE_CHILD_RELATIONSHIP_TYPE = \"drive/child\";\nconst REACTOR_DRIVE_FILE_EXTENSION = \"phrd\";\n//#endregion\nexport { REACTOR_DRIVE_DOCUMENT_TYPE as n, REACTOR_DRIVE_FILE_EXTENSION as r, DRIVE_CHILD_RELATIONSHIP_TYPE as t };\n\n//# sourceMappingURL=constants-DfSjC49y.js.map","import { n as REACTOR_DRIVE_DOCUMENT_TYPE, r as REACTOR_DRIVE_FILE_EXTENSION, t as DRIVE_CHILD_RELATIONSHIP_TYPE } from \"./constants-DfSjC49y.js\";\nimport { assertAuthPreservedOnDuplicate, baseCreateDocument, baseLoadFromInput, baseSaveToFileHandle, createCopyHeader, createReducer, createState, createVersionsOf, creationActions, defaultBaseState, generateActionId, generateId, isDenied, isDocumentAction, replayDocumentVersioned } from \"@powerhousedao/shared/document-model\";\nimport { Migrator, sql } from \"kysely\";\nimport { BaseReadModel, REACTOR_SCHEMA, addRelationshipAction, findPurged, isPurgeMarker, mergeConsistencyTokens, removeRelationshipAction, unchunkedReadModelIndexingConfig } from \"@powerhousedao/reactor\";\nimport { getNextCopyNumber } from \"@powerhousedao/shared/document-drive\";\nimport { childLogger } from \"document-model\";\n//#region \\0rolldown/runtime.js\nvar __defProp = Object.defineProperty;\nvar __exportAll = (all, no_symbols) => {\n\tlet target = {};\n\tfor (var name in all) __defProp(target, name, {\n\t\tget: all[name],\n\t\tenumerable: true\n\t});\n\tif (!no_symbols) __defProp(target, Symbol.toStringTag, { value: \"Module\" });\n\treturn target;\n};\n//#endregion\n//#region src/actions.ts\nfunction setDriveNameAction(input) {\n\treturn {\n\t\tid: generateActionId(),\n\t\ttype: \"SET_DRIVE_NAME\",\n\t\tscope: \"global\",\n\t\ttimestampUtcMs: (/* @__PURE__ */ new Date()).toISOString(),\n\t\tinput\n\t};\n}\nfunction setDriveIconAction(input) {\n\treturn {\n\t\tid: generateActionId(),\n\t\ttype: \"SET_DRIVE_ICON\",\n\t\tscope: \"global\",\n\t\ttimestampUtcMs: (/* @__PURE__ */ new Date()).toISOString(),\n\t\tinput\n\t};\n}\nfunction setSharingTypeAction(input) {\n\treturn {\n\t\tid: generateActionId(),\n\t\ttype: \"SET_SHARING_TYPE\",\n\t\tscope: \"local\",\n\t\ttimestampUtcMs: (/* @__PURE__ */ new Date()).toISOString(),\n\t\tinput\n\t};\n}\nfunction setAvailableOfflineAction(input) {\n\treturn {\n\t\tid: generateActionId(),\n\t\ttype: \"SET_AVAILABLE_OFFLINE\",\n\t\tscope: \"local\",\n\t\ttimestampUtcMs: (/* @__PURE__ */ new Date()).toISOString(),\n\t\tinput\n\t};\n}\nfunction addFolderAction(input) {\n\treturn {\n\t\tid: generateActionId(),\n\t\ttype: \"ADD_FOLDER\",\n\t\tscope: \"document\",\n\t\ttimestampUtcMs: (/* @__PURE__ */ new Date()).toISOString(),\n\t\tinput\n\t};\n}\nfunction updateFolderAction(input) {\n\treturn {\n\t\tid: generateActionId(),\n\t\ttype: \"UPDATE_FOLDER\",\n\t\tscope: \"document\",\n\t\ttimestampUtcMs: (/* @__PURE__ */ new Date()).toISOString(),\n\t\tinput\n\t};\n}\nfunction removeFolderAction(input) {\n\treturn {\n\t\tid: generateActionId(),\n\t\ttype: \"REMOVE_FOLDER\",\n\t\tscope: \"document\",\n\t\ttimestampUtcMs: (/* @__PURE__ */ new Date()).toISOString(),\n\t\tinput\n\t};\n}\nconst reactorDriveActions = {\n\tsetDriveName: setDriveNameAction,\n\tsetDriveIcon: setDriveIconAction,\n\tsetSharingType: setSharingTypeAction,\n\tsetAvailableOffline: setAvailableOfflineAction,\n\taddFolder: addFolderAction,\n\tupdateFolder: updateFolderAction,\n\tremoveFolder: removeFolderAction\n};\n//#endregion\n//#region src/reducer/drive.ts\nconst reactorDriveStateReducer = (state, action) => {\n\tif (isDocumentAction(action)) return state;\n\tconst typedAction = action;\n\tswitch (typedAction.type) {\n\t\tcase \"SET_DRIVE_NAME\": {\n\t\t\tconst input = typedAction.input;\n\t\t\tstate.global.name = input.name;\n\t\t\treturn state;\n\t\t}\n\t\tcase \"SET_DRIVE_ICON\": {\n\t\t\tconst input = typedAction.input;\n\t\t\tstate.global.icon = input.icon;\n\t\t\treturn state;\n\t\t}\n\t\tcase \"SET_SHARING_TYPE\": {\n\t\t\tconst input = typedAction.input;\n\t\t\tstate.local.sharingType = input.sharingType;\n\t\t\treturn state;\n\t\t}\n\t\tcase \"SET_AVAILABLE_OFFLINE\": {\n\t\t\tconst input = typedAction.input;\n\t\t\tstate.local.availableOffline = input.availableOffline;\n\t\t\treturn state;\n\t\t}\n\t\tcase \"ADD_FOLDER\":\n\t\tcase \"UPDATE_FOLDER\":\n\t\tcase \"REMOVE_FOLDER\": return state;\n\t\tdefault: return state;\n\t}\n};\n//#endregion\n//#region src/module.ts\nconst initialGlobalState = {\n\tname: \"\",\n\ticon: null\n};\nconst initialLocalState = {\n\tsharingType: \"private\",\n\tavailableOffline: false\n};\nconst reactorDriveCreateState = (state) => {\n\treturn {\n\t\t...defaultBaseState(),\n\t\tglobal: {\n\t\t\t...initialGlobalState,\n\t\t\t...state?.global\n\t\t},\n\t\tlocal: {\n\t\t\t...initialLocalState,\n\t\t\t...state?.local\n\t\t}\n\t};\n};\nconst reactorDriveCreateDocument = (state) => {\n\treturn baseCreateDocument(reactorDriveCreateState, state, REACTOR_DRIVE_DOCUMENT_TYPE);\n};\nconst reactorDriveSaveToFileHandle = (document, input) => {\n\treturn baseSaveToFileHandle(document, input);\n};\nconst reactorDriveLoadFromInput = (input) => {\n\treturn baseLoadFromInput(input, reactorDriveDocumentReducer);\n};\nconst isReactorDriveState = (state) => {\n\treturn typeof state === \"object\" && state !== null && \"global\" in state && \"local\" in state;\n};\nconst assertIsReactorDriveState = (state) => {\n\tif (!isReactorDriveState(state)) throw new Error(\"Not a reactor-drive state\");\n};\nconst isReactorDriveDocument = (document) => {\n\treturn typeof document === \"object\" && document !== null && \"header\" in document && document.header.documentType === \"powerhouse/reactor-drive\";\n};\nconst assertIsReactorDriveDocument = (document) => {\n\tif (!isReactorDriveDocument(document)) throw new Error(\"Not a reactor-drive document\");\n};\nconst reactorDriveDocumentReducer = createReducer(reactorDriveStateReducer);\nconst reactorDriveDocumentGlobalState = {\n\tid: REACTOR_DRIVE_DOCUMENT_TYPE,\n\tname: \"ReactorDrive\",\n\textension: REACTOR_DRIVE_FILE_EXTENSION,\n\tdescription: \"\",\n\tauthor: {\n\t\tname: \"Powerhouse Inc\",\n\t\twebsite: \"https://www.powerhouse.inc/\"\n\t},\n\tspecifications: [{\n\t\tversion: 1,\n\t\tchangeLog: [],\n\t\tstate: {\n\t\t\tglobal: {\n\t\t\t\tschema: \"type ReactorDriveState {\\n name: String!\\n icon: String\\n}\",\n\t\t\t\tinitialValue: JSON.stringify(JSON.stringify(initialGlobalState)),\n\t\t\t\texamples: []\n\t\t\t},\n\t\t\tlocal: {\n\t\t\t\tschema: \"type ReactorDriveLocalState {\\n sharingType: String!\\n availableOffline: Boolean!\\n}\",\n\t\t\t\tinitialValue: JSON.stringify(JSON.stringify(initialLocalState)),\n\t\t\t\texamples: []\n\t\t\t}\n\t\t},\n\t\tmodules: [{\n\t\t\tid: \"reactor-drive/base-operations\",\n\t\t\tname: \"base_operations\",\n\t\t\tdescription: \"\",\n\t\t\toperations: [\n\t\t\t\t{\n\t\t\t\t\tid: \"SET_DRIVE_NAME\",\n\t\t\t\t\tname: \"SET_DRIVE_NAME\",\n\t\t\t\t\tdescription: \"\",\n\t\t\t\t\tschema: \"input SetDriveNameInput { name: String! }\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"global\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"SET_DRIVE_ICON\",\n\t\t\t\t\tname: \"SET_DRIVE_ICON\",\n\t\t\t\t\tdescription: \"\",\n\t\t\t\t\tschema: \"input SetDriveIconInput { icon: String }\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"global\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"SET_SHARING_TYPE\",\n\t\t\t\t\tname: \"SET_SHARING_TYPE\",\n\t\t\t\t\tdescription: \"\",\n\t\t\t\t\tschema: \"input SetSharingTypeInput { sharingType: String! }\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"local\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"SET_AVAILABLE_OFFLINE\",\n\t\t\t\t\tname: \"SET_AVAILABLE_OFFLINE\",\n\t\t\t\t\tdescription: \"\",\n\t\t\t\t\tschema: \"input SetAvailableOfflineInput { availableOffline: Boolean! }\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"local\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"ADD_FOLDER\",\n\t\t\t\t\tname: \"ADD_FOLDER\",\n\t\t\t\t\tdescription: \"\",\n\t\t\t\t\tschema: \"input AddFolderInput { folderId: String! parentFolderId: String name: String! }\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"document\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"UPDATE_FOLDER\",\n\t\t\t\t\tname: \"UPDATE_FOLDER\",\n\t\t\t\t\tdescription: \"\",\n\t\t\t\t\tschema: \"input UpdateFolderInput { folderId: String! name: String parentFolderId: String }\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"document\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"REMOVE_FOLDER\",\n\t\t\t\t\tname: \"REMOVE_FOLDER\",\n\t\t\t\t\tdescription: \"\",\n\t\t\t\t\tschema: \"input RemoveFolderInput { folderId: String! }\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"document\"\n\t\t\t\t}\n\t\t\t]\n\t\t}]\n\t}]\n};\nconst reactorDriveDocumentModelModule = {\n\tactions: reactorDriveActions,\n\treducer: reactorDriveDocumentReducer,\n\tdocumentModel: createState(defaultBaseState(), reactorDriveDocumentGlobalState),\n\tutils: {\n\t\tfileExtension: REACTOR_DRIVE_FILE_EXTENSION,\n\t\tcreateState: reactorDriveCreateState,\n\t\tcreateDocument: reactorDriveCreateDocument,\n\t\tloadFromInput: reactorDriveLoadFromInput,\n\t\tsaveToFileHandle: reactorDriveSaveToFileHandle,\n\t\tisStateOfType: isReactorDriveState,\n\t\tassertIsStateOfType: assertIsReactorDriveState,\n\t\tisDocumentOfType: isReactorDriveDocument,\n\t\tassertIsDocumentOfType: assertIsReactorDriveDocument\n\t}\n};\n//#endregion\n//#region src/schema/migrations/0001_drive_node.ts\nvar _0001_drive_node_exports = /* @__PURE__ */ __exportAll({\n\tdown: () => down$4,\n\tup: () => up$4\n});\nasync function up$4(db) {\n\tawait db.schema.createTable(\"DriveNode\").ifNotExists().addColumn(\"driveId\", \"text\", (col) => col.notNull()).addColumn(\"id\", \"text\", (col) => col.notNull()).addColumn(\"kind\", \"text\", (col) => col.notNull()).addColumn(\"name\", \"text\", (col) => col.notNull()).addColumn(\"requestedName\", \"text\", (col) => col.notNull()).addColumn(\"parentFolder\", \"text\").addColumn(\"documentType\", \"text\").addColumn(\"createdAt\", \"timestamptz\", (col) => col.notNull().defaultTo(sql`NOW()`)).addColumn(\"updatedAt\", \"timestamptz\", (col) => col.notNull().defaultTo(sql`NOW()`)).addPrimaryKeyConstraint(\"pk_drive_node\", [\"driveId\", \"id\"]).addCheckConstraint(\"chk_drive_node_document_type\", sql`(kind = 'file' AND \"documentType\" IS NOT NULL) OR (kind = 'folder' AND \"documentType\" IS NULL)`).execute();\n\tawait db.schema.createIndex(\"idx_drive_node_parent_name\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"parentFolder\",\n\t\t\"name\"\n\t]).execute();\n\tawait db.schema.createIndex(\"idx_drive_node_parent_kind_id\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"parentFolder\",\n\t\t\"kind\",\n\t\t\"id\"\n\t]).execute();\n}\nasync function down$4(db) {\n\tawait db.schema.dropTable(\"DriveNode\").execute();\n}\n//#endregion\n//#region src/schema/migrations/0002_document_name.ts\nvar _0002_document_name_exports = /* @__PURE__ */ __exportAll({\n\tdown: () => down$3,\n\tup: () => up$3\n});\nasync function up$3(db) {\n\tawait db.schema.createTable(\"DocumentName\").ifNotExists().addColumn(\"docId\", \"text\", (col) => col.primaryKey()).addColumn(\"name\", \"text\", (col) => col.notNull()).addColumn(\"updatedAt\", \"timestamptz\", (col) => col.notNull().defaultTo(sql`NOW()`)).execute();\n}\nasync function down$3(db) {\n\tawait db.schema.dropTable(\"DocumentName\").execute();\n}\n//#endregion\n//#region src/schema/migrations/0003_drive_node_listing_indexes.ts\nvar _0003_drive_node_listing_indexes_exports = /* @__PURE__ */ __exportAll({\n\tdown: () => down$2,\n\tup: () => up$2\n});\nconst LISTING_INDEXES = [\n\t\"idx_drive_node_parent_created_id\",\n\t\"idx_drive_node_parent_kind_created_id\",\n\t\"idx_drive_node_root_created_id\",\n\t\"idx_drive_node_root_kind_created_id\",\n\t\"idx_drive_node_created_id\"\n];\nasync function up$2(db) {\n\tawait db.schema.createIndex(\"idx_drive_node_parent_created_id\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"parentFolder\",\n\t\t\"createdAt\",\n\t\t\"id\"\n\t]).execute();\n\tawait db.schema.createIndex(\"idx_drive_node_parent_kind_created_id\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"parentFolder\",\n\t\t\"kind\",\n\t\t\"createdAt\",\n\t\t\"id\"\n\t]).execute();\n\tawait db.schema.createIndex(\"idx_drive_node_root_created_id\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"createdAt\",\n\t\t\"id\"\n\t]).where(sql.ref(\"parentFolder\"), \"is\", null).execute();\n\tawait db.schema.createIndex(\"idx_drive_node_root_kind_created_id\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"kind\",\n\t\t\"createdAt\",\n\t\t\"id\"\n\t]).where(sql.ref(\"parentFolder\"), \"is\", null).execute();\n\tawait db.schema.createIndex(\"idx_drive_node_created_id\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"createdAt\",\n\t\t\"id\"\n\t]).execute();\n\tawait db.schema.dropIndex(\"idx_drive_node_parent_kind_id\").ifExists().execute();\n}\nasync function down$2(db) {\n\tawait db.schema.createIndex(\"idx_drive_node_parent_kind_id\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"parentFolder\",\n\t\t\"kind\",\n\t\t\"id\"\n\t]).execute();\n\tfor (const name of LISTING_INDEXES) await db.schema.dropIndex(name).ifExists().execute();\n}\n//#endregion\n//#region src/schema/migrations/0004_drop_drive_node_parent_name.ts\nvar _0004_drop_drive_node_parent_name_exports = /* @__PURE__ */ __exportAll({\n\tdown: () => down$1,\n\tup: () => up$1\n});\nasync function up$1(db) {\n\tawait db.schema.dropIndex(\"idx_drive_node_parent_name\").ifExists().execute();\n}\nasync function down$1(db) {\n\tawait db.schema.createIndex(\"idx_drive_node_parent_name\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"parentFolder\",\n\t\t\"name\"\n\t]).execute();\n}\n//#endregion\n//#region src/schema/migrations/0005_drive_node_sibling_name_index.ts\nvar _0005_drive_node_sibling_name_index_exports = /* @__PURE__ */ __exportAll({\n\tdown: () => down,\n\tup: () => up\n});\n/**\n* Sibling-name resolution checks candidate names one at a time instead of\n* loading every sibling, so (driveId, parentFolder, name) is a filter again.\n*/\nasync function up(db) {\n\tawait db.schema.createIndex(\"idx_drive_node_parent_name\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"parentFolder\",\n\t\t\"name\"\n\t]).execute();\n}\nasync function down(db) {\n\tawait db.schema.dropIndex(\"idx_drive_node_parent_name\").ifExists().execute();\n}\n//#endregion\n//#region src/schema/migrations/migrator.ts\nconst migrations = {\n\t\"0001_drive_node\": _0001_drive_node_exports,\n\t\"0002_document_name\": _0002_document_name_exports,\n\t\"0003_drive_node_listing_indexes\": _0003_drive_node_listing_indexes_exports,\n\t\"0004_drop_drive_node_parent_name\": _0004_drop_drive_node_parent_name_exports,\n\t\"0005_drive_node_sibling_name_index\": _0005_drive_node_sibling_name_index_exports\n};\nconst REACTOR_DRIVE_MIGRATION_TABLE = \"kysely_migration_reactor_drive\";\nconst REACTOR_DRIVE_MIGRATION_LOCK_TABLE = \"kysely_migration_reactor_drive_lock\";\nvar ProgrammaticMigrationProvider = class {\n\tgetMigrations() {\n\t\treturn Promise.resolve(migrations);\n\t}\n};\nasync function runReactorDriveMigrations(db, schema) {\n\ttry {\n\t\tawait sql`CREATE SCHEMA IF NOT EXISTS ${sql.id(schema)}`.execute(db);\n\t} catch (error) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tmigrationsExecuted: [],\n\t\t\terror: error instanceof Error ? error : /* @__PURE__ */ new Error(\"Failed to create schema\")\n\t\t};\n\t}\n\tconst migrator = new Migrator({\n\t\tdb: db.withSchema(schema),\n\t\tprovider: new ProgrammaticMigrationProvider(),\n\t\tmigrationTableSchema: schema,\n\t\tmigrationTableName: REACTOR_DRIVE_MIGRATION_TABLE,\n\t\tmigrationLockTableName: REACTOR_DRIVE_MIGRATION_LOCK_TABLE\n\t});\n\tlet error;\n\tlet results;\n\ttry {\n\t\tconst result = await migrator.migrateToLatest();\n\t\terror = result.error;\n\t\tresults = result.results;\n\t} catch (e) {\n\t\terror = e;\n\t\tresults = [];\n\t}\n\tconst migrationsExecuted = results?.map((result) => result.migrationName) ?? [];\n\tif (error) return {\n\t\tsuccess: false,\n\t\tmigrationsExecuted,\n\t\terror: error instanceof Error ? error : /* @__PURE__ */ new Error(\"Unknown migration error\")\n\t};\n\treturn {\n\t\tsuccess: true,\n\t\tmigrationsExecuted\n\t};\n}\nasync function getReactorDriveMigrationStatus(db, schema) {\n\treturn await new Migrator({\n\t\tdb: db.withSchema(schema),\n\t\tprovider: new ProgrammaticMigrationProvider(),\n\t\tmigrationTableSchema: schema,\n\t\tmigrationTableName: REACTOR_DRIVE_MIGRATION_TABLE,\n\t\tmigrationLockTableName: REACTOR_DRIVE_MIGRATION_LOCK_TABLE\n\t}).getMigrations();\n}\n//#endregion\n//#region src/processors/utils/collisions.ts\n/**\n* Deterministic per-folder name collision rule. Given a desired name and the\n* set of names already taken by siblings, returns the next available name as\n* `requested`, `requested (2)`, `requested (3)`, etc.\n*\n* The rule matches the legacy document-drive module so that migration from\n* the legacy state produces stable suffixes.\n*/\nfunction resolveCollision(requested, takenNames) {\n\tconst taken = /* @__PURE__ */ new Set();\n\tfor (const name of takenNames) taken.add(name);\n\tif (!taken.has(requested)) return requested;\n\tlet suffix = 2;\n\twhile (taken.has(`${requested} (${suffix})`)) suffix += 1;\n\treturn `${requested} (${suffix})`;\n}\n//#endregion\n//#region src/processors/node-processor.ts\nconst LEGACY_DRIVE_DOCUMENT_TYPE = \"powerhouse/document-drive\";\nconst NAME_ACTION_TYPES = /* @__PURE__ */ new Set([\n\t\"CREATE_DOCUMENT\",\n\t\"UPGRADE_DOCUMENT\",\n\t\"SET_NAME\"\n]);\nconst STRUCTURE_ACTION_TYPES = /* @__PURE__ */ new Set([\n\t\"ADD_RELATIONSHIP\",\n\t\"REMOVE_RELATIONSHIP\",\n\t\"ADD_FOLDER\",\n\t\"UPDATE_FOLDER\",\n\t\"REMOVE_FOLDER\"\n]);\nconst LEGACY_NODE_ACTION_TYPES = /* @__PURE__ */ new Set([\n\t\"ADD_FILE\",\n\t\"ADD_FOLDER\",\n\t\"UPDATE_FILE\",\n\t\"UPDATE_NODE\",\n\t\"MOVE_NODE\",\n\t\"COPY_NODE\",\n\t\"DELETE_NODE\"\n]);\n/** Candidates the indexed sibling check tries before scanning the folder. */\nconst SIBLING_NAME_CANDIDATES = 50;\nconst BACKFILL_BATCH_SIZE = 500;\n/**\n* Projects drive structure operations into the DriveNode tree.\n*\n* Reactor-drive rows get the per-folder collision rule. Legacy\n* `powerhouse/document-drive` rows mirror the legacy node reducer, including\n* its own `(copy) N` collision rule, so the rows equal the drive's state.\n*\n* Indexes a batch unchunked: a single job may carry one action per descendant\n* of a copied subtree, and a partially committed copy is a half-built tree that\n* readers can see. Chunked commits would only be repaired at the next init(),\n* so the whole batch commits or none of it does.\n*/\nvar NodeProcessor = class extends BaseReadModel {\n\tstatic commitsInFenceTransaction = true;\n\tdriveDb;\n\tbaseDb;\n\tschema;\n\treactorSchema;\n\tlogger = childLogger([\"reactor-drive\", \"node-processor\"]);\n\tconstructor(baseDb, schema, operationIndex, writeCache, consistencyTracker, reactorSchema = REACTOR_SCHEMA) {\n\t\tconst scopedDb = baseDb.withSchema(schema);\n\t\tsuper(scopedDb, operationIndex, writeCache, consistencyTracker, {\n\t\t\treadModelId: \"reactor-drive-node-processor\",\n\t\t\trebuildStateOnInit: false,\n\t\t\tindexing: unchunkedReadModelIndexingConfig,\n\t\t\tpurgeFence: \"locked\"\n\t\t});\n\t\tthis.driveDb = scopedDb;\n\t\tthis.baseDb = baseDb;\n\t\tthis.schema = schema;\n\t\tthis.reactorSchema = reactorSchema;\n\t}\n\tpurgeLookup(db) {\n\t\treturn db.withSchema(this.reactorSchema);\n\t}\n\tasync init() {\n\t\tconst result = await runReactorDriveMigrations(this.baseDb, this.schema);\n\t\tif (!result.success && result.error) throw new Error(`Reactor drive migrations failed: ${result.error.message}`);\n\t\tawait this.backfillLegacyDrives();\n\t\tawait super.init();\n\t}\n\tasync commitOperations(items, fenceTrx) {\n\t\tif (fenceTrx) {\n\t\t\tawait this.applyAll(items, fenceTrx);\n\t\t\treturn;\n\t\t}\n\t\tif (!this.writesRows(items)) return;\n\t\tawait this.driveDb.transaction().execute((trx) => this.applyAll(items, trx));\n\t}\n\twritesRows(items) {\n\t\treturn items.some((item) => {\n\t\t\tconst actionType = item.operation.action.type;\n\t\t\treturn NAME_ACTION_TYPES.has(actionType) || STRUCTURE_ACTION_TYPES.has(actionType) || LEGACY_NODE_ACTION_TYPES.has(actionType) || actionType === \"DELETE_DOCUMENT\" || isPurgeMarker(item.operation);\n\t\t});\n\t}\n\t/**\n\t* Seeds rows for every live legacy drive that has none, from its global\n\t* snapshot. One transaction per drive; re-running skips drives with rows.\n\t*\n\t* Only a snapshot at or behind the resume cursor is seeded: catch-up\n\t* replays every operation past the cursor, and replaying operations the\n\t* snapshot already holds over its rows would rename and duplicate nodes.\n\t*/\n\tasync backfillLegacyDrives() {\n\t\tconst resumeFrom = await this.loadState() ?? 0;\n\t\tconst drives = await this.purgeLookup(this.baseDb).selectFrom(\"DocumentSnapshot\").select([\"documentId\", \"lastOperationOrdinal\"]).where(\"documentType\", \"=\", LEGACY_DRIVE_DOCUMENT_TYPE).where(\"scope\", \"=\", \"global\").where(\"branch\", \"=\", \"main\").where(\"isDeleted\", \"=\", false).execute();\n\t\tfor (const { documentId: driveId, lastOperationOrdinal } of drives) {\n\t\t\tif (lastOperationOrdinal > resumeFrom) {\n\t\t\t\tif (!await this.driveDb.selectFrom(\"DriveNode\").select(\"id\").where(\"driveId\", \"=\", driveId).limit(1).executeTakeFirst()) this.logger.info(\"legacy drive @driveId snapshot at ordinal @snapshot is past cursor @cursor; replay will build it\", driveId, lastOperationOrdinal, resumeFrom);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst count = await this.driveDb.transaction().execute((trx) => this.backfillLegacyDrive(trx, driveId));\n\t\t\tif (count > 0) this.logger.info(\"backfilled legacy drive @driveId with @count nodes\", driveId, count);\n\t\t}\n\t}\n\tasync backfillLegacyDrive(trx, driveId) {\n\t\tif (await trx.selectFrom(\"DriveNode\").select(\"id\").where(\"driveId\", \"=\", driveId).limit(1).executeTakeFirst()) return 0;\n\t\tconst rows = legacySnapshotRows(driveId, (await this.purgeLookup(trx).selectFrom(\"DocumentSnapshot\").select(\"content\").where(\"documentId\", \"=\", driveId).where(\"scope\", \"=\", \"global\").where(\"branch\", \"=\", \"main\").executeTakeFirst())?.content);\n\t\tfor (let i = 0; i < rows.length; i += BACKFILL_BATCH_SIZE) await trx.insertInto(\"DriveNode\").values(rows.slice(i, i + BACKFILL_BATCH_SIZE)).onConflict((oc) => oc.columns([\"driveId\", \"id\"]).doNothing()).execute();\n\t\treturn rows.length;\n\t}\n\tasync applyAll(items, trx) {\n\t\tconst purgedTargets = await this.findPurgedTargets(trx, items);\n\t\tfor (const item of items) {\n\t\t\tconst actionType = item.operation.action.type;\n\t\t\tconst legacyRule = this.legacyShapeRule(item);\n\t\t\tif (legacyRule) {\n\t\t\t\tif (item.operation.error || isDenied(item.operation)) continue;\n\t\t\t\tawait this.applyLegacyNodeOperation(trx, item, legacyRule);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (isPurgeMarker(item.operation)) {\n\t\t\t\tconst input = item.operation.action.input;\n\t\t\t\tawait this.eraseDocument(trx, input.documentId || item.context.documentId);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (NAME_ACTION_TYPES.has(actionType)) {\n\t\t\t\tawait this.applyNameOperation(trx, item);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (STRUCTURE_ACTION_TYPES.has(actionType)) {\n\t\t\t\tif (this.namesPurgedTarget(item, purgedTargets)) continue;\n\t\t\t\tawait this.applyStructureOperation(trx, item);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (actionType === \"DELETE_DOCUMENT\") await this.applyDeleteDocument(trx, item);\n\t\t}\n\t}\n\t/** Tombstoned targets of this batch's drive-child ADD_RELATIONSHIPs. */\n\tasync findPurgedTargets(trx, items) {\n\t\tconst targets = [];\n\t\tfor (const item of items) {\n\t\t\tconst target = this.addedChildOf(item);\n\t\t\tif (target !== void 0) targets.push(target);\n\t\t}\n\t\treturn findPurged(this.purgeLookup(trx), targets);\n\t}\n\tnamesPurgedTarget(item, purgedTargets) {\n\t\tconst target = this.addedChildOf(item);\n\t\treturn target !== void 0 && purgedTargets.has(target);\n\t}\n\taddedChildOf(item) {\n\t\tconst action = item.operation.action;\n\t\tif (action.type !== \"ADD_RELATIONSHIP\") return void 0;\n\t\tif (item.context.documentType !== \"powerhouse/reactor-drive\") return;\n\t\tconst input = action.input;\n\t\tif (input.relationshipType !== \"drive/child\") return;\n\t\treturn input.targetId;\n\t}\n\tasync applyNameOperation(trx, item) {\n\t\tconst action = item.operation.action;\n\t\tconst docId = item.context.documentId;\n\t\tlet name;\n\t\tif (action.type === \"CREATE_DOCUMENT\") name = action.input.name;\n\t\telse if (action.type === \"UPGRADE_DOCUMENT\") name = (action.input.initialState ?? {}).header?.name;\n\t\telse if (action.type === \"SET_NAME\") name = action.input.name;\n\t\tif (name === void 0) return;\n\t\tawait this.upsertDocumentName(trx, docId, name);\n\t\tconst linkedRows = await trx.selectFrom(\"DriveNode\").selectAll().where(\"id\", \"=\", docId).where(\"kind\", \"=\", \"file\").execute();\n\t\tconst legacyDrives = await this.legacyDrivesAmong(trx, linkedRows.map((row) => row.driveId));\n\t\tfor (const row of linkedRows) {\n\t\t\tif (legacyDrives.has(row.driveId)) continue;\n\t\t\tconst resolved = await this.resolveSiblingName(trx, row.driveId, row.parentFolder, name, docId);\n\t\t\tawait trx.updateTable(\"DriveNode\").set({\n\t\t\t\tname: resolved,\n\t\t\t\trequestedName: name,\n\t\t\t\tupdatedAt: /* @__PURE__ */ new Date()\n\t\t\t}).where(\"driveId\", \"=\", row.driveId).where(\"id\", \"=\", docId).execute();\n\t\t}\n\t}\n\tasync applyStructureOperation(trx, item) {\n\t\tif (item.context.documentType !== \"powerhouse/reactor-drive\") return;\n\t\tconst action = item.operation.action;\n\t\tconst driveId = item.context.documentId;\n\t\tif (action.type === \"ADD_RELATIONSHIP\") {\n\t\t\tconst input = action.input;\n\t\t\tif (input.relationshipType !== \"drive/child\") return;\n\t\t\tawait this.handleAddFileRelationship(trx, driveId, input);\n\t\t\treturn;\n\t\t}\n\t\tif (action.type === \"REMOVE_RELATIONSHIP\") {\n\t\t\tconst input = action.input;\n\t\t\tif (input.relationshipType !== \"drive/child\") return;\n\t\t\tawait trx.deleteFrom(\"DriveNode\").where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", input.targetId).execute();\n\t\t\treturn;\n\t\t}\n\t\tif (action.type === \"ADD_FOLDER\") {\n\t\t\tawait this.handleAddFolder(trx, driveId, action.input);\n\t\t\treturn;\n\t\t}\n\t\tif (action.type === \"UPDATE_FOLDER\") {\n\t\t\tconst input = action.input;\n\t\t\tif (!isNonEmptyString(input.folderId)) return;\n\t\t\tawait this.handleUpdateFolder(trx, driveId, input);\n\t\t\treturn;\n\t\t}\n\t\tif (action.type === \"REMOVE_FOLDER\") {\n\t\t\tconst input = action.input;\n\t\t\tif (!isNonEmptyString(input.folderId)) return;\n\t\t\tawait trx.deleteFrom(\"DriveNode\").where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", input.folderId).execute();\n\t\t}\n\t}\n\t/**\n\t* The collision rule for an operation in the legacy node shape: a\n\t* document-drive's own, or a reactor-drive's for a legacy-shaped write\n\t* against one. Undefined for every other operation.\n\t*/\n\tlegacyShapeRule(item) {\n\t\tconst action = item.operation.action;\n\t\tif (!LEGACY_NODE_ACTION_TYPES.has(action.type)) return void 0;\n\t\tif (item.context.documentType === \"powerhouse/document-drive\") return \"legacy\";\n\t\tif (item.context.documentType !== \"powerhouse/reactor-drive\") return;\n\t\tif (action.type === \"ADD_FOLDER\") {\n\t\t\tconst input = action.input;\n\t\t\tif (isNonEmptyString(input?.folderId)) return void 0;\n\t\t}\n\t\treturn \"reactor\";\n\t}\n\t/**\n\t* Mirrors the legacy node reducer (document-drive src/reducers/node.ts).\n\t* An add without a usable id is skipped with a warning: a read model never\n\t* stops on an operation's shape.\n\t*/\n\tasync applyLegacyNodeOperation(trx, item, rule) {\n\t\tconst action = item.operation.action;\n\t\tconst driveId = item.context.documentId;\n\t\tswitch (action.type) {\n\t\t\tcase \"ADD_FILE\": {\n\t\t\t\tconst input = action.input;\n\t\t\t\tif (!isNonEmptyString(input.id) || !isNonEmptyString(input.documentType)) {\n\t\t\t\t\tthis.warnSkipped(item, \"no usable id or documentType\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tawait this.upsertLegacyNode(trx, driveId, rule, {\n\t\t\t\t\tid: input.id,\n\t\t\t\t\tkind: \"file\",\n\t\t\t\t\tsrcName: input.name ?? \"\",\n\t\t\t\t\tcollisionFolder: input.parentFolder || null,\n\t\t\t\t\tparentFolder: input.parentFolder ?? null,\n\t\t\t\t\tdocumentType: input.documentType\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"ADD_FOLDER\": {\n\t\t\t\tconst input = action.input;\n\t\t\t\tif (!isNonEmptyString(input.id)) {\n\t\t\t\t\tthis.warnSkipped(item, \"no usable id\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tawait this.upsertLegacyNode(trx, driveId, rule, {\n\t\t\t\t\tid: input.id,\n\t\t\t\t\tkind: \"folder\",\n\t\t\t\t\tsrcName: input.name ?? \"\",\n\t\t\t\t\tcollisionFolder: input.parentFolder || null,\n\t\t\t\t\tparentFolder: input.parentFolder ?? null,\n\t\t\t\t\tdocumentType: null\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"UPDATE_FILE\":\n\t\t\tcase \"UPDATE_NODE\": {\n\t\t\t\tconst input = action.input;\n\t\t\t\tif (!isNonEmptyString(input.id)) return;\n\t\t\t\tawait this.updateLegacyNode(trx, driveId, rule, action.type, input);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"MOVE_NODE\": {\n\t\t\t\tconst input = action.input;\n\t\t\t\tif (!isNonEmptyString(input.srcFolder)) return;\n\t\t\t\tawait this.moveLegacyNode(trx, driveId, rule, input);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"COPY_NODE\": {\n\t\t\t\tconst input = action.input;\n\t\t\t\tif (!isNonEmptyString(input.srcId)) return;\n\t\t\t\tif (!isNonEmptyString(input.targetId)) {\n\t\t\t\t\tthis.warnSkipped(item, \"no usable targetId\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst src = await this.findNode(trx, driveId, input.srcId);\n\t\t\t\tif (!src) return;\n\t\t\t\tawait this.upsertLegacyNode(trx, driveId, rule, {\n\t\t\t\t\tid: input.targetId,\n\t\t\t\t\tkind: src.kind,\n\t\t\t\t\tsrcName: input.targetName || (rule === \"legacy\" ? src.name : src.requestedName),\n\t\t\t\t\tcollisionFolder: input.targetParentFolder || null,\n\t\t\t\t\tparentFolder: input.targetParentFolder || null,\n\t\t\t\t\tdocumentType: src.documentType\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"DELETE_NODE\": {\n\t\t\t\tconst input = action.input;\n\t\t\t\tif (!isNonEmptyString(input.id)) return;\n\t\t\t\tconst ids = await this.subtreeIds(trx, driveId, input.id);\n\t\t\t\tif (ids.length === 0) return;\n\t\t\t\tawait trx.deleteFrom(\"DriveNode\").where(\"driveId\", \"=\", driveId).where(\"id\", \"in\", ids).execute();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t* ADD_FILE, ADD_FOLDER and COPY_NODE. The reducer rejects an existing id, so\n\t* the node itself is left out of the collision check and a replay over the\n\t* same row is an upsert to the same values.\n\t*/\n\tasync upsertLegacyNode(trx, driveId, rule, node) {\n\t\tconst { name, requestedName } = await this.nodeName(trx, rule, {\n\t\t\tdriveId,\n\t\t\tfolder: rule === \"legacy\" ? node.collisionFolder : node.parentFolder,\n\t\t\tsrcName: node.srcName,\n\t\t\tkind: node.kind,\n\t\t\texcludeId: node.id\n\t\t});\n\t\tconst values = {\n\t\t\tkind: node.kind,\n\t\t\tname,\n\t\t\trequestedName,\n\t\t\tparentFolder: node.parentFolder,\n\t\t\tdocumentType: node.kind === \"file\" ? node.documentType : null\n\t\t};\n\t\tawait trx.insertInto(\"DriveNode\").values({\n\t\t\tdriveId,\n\t\t\tid: node.id,\n\t\t\t...values\n\t\t}).onConflict((oc) => oc.columns([\"driveId\", \"id\"]).doUpdateSet({\n\t\t\t...values,\n\t\t\tupdatedAt: /* @__PURE__ */ new Date()\n\t\t})).execute();\n\t}\n\t/**\n\t* UPDATE_FILE never moves the node (its parentFolder only picks the folder\n\t* for the collision check); UPDATE_NODE moves it only to the root, on null.\n\t*/\n\tasync updateLegacyNode(trx, driveId, rule, actionType, input) {\n\t\tconst row = await this.findNode(trx, driveId, input.id);\n\t\tif (!row) return;\n\t\tconst nextParentFolder = actionType === \"UPDATE_NODE\" && input.parentFolder === null ? null : row.parentFolder;\n\t\tconst { name, requestedName } = await this.nodeName(trx, rule, {\n\t\t\tdriveId,\n\t\t\tfolder: rule === \"legacy\" ? input.parentFolder ?? row.parentFolder : nextParentFolder,\n\t\t\tsrcName: input.name ?? (rule === \"legacy\" ? row.name : row.requestedName),\n\t\t\tkind: actionType === \"UPDATE_FILE\" ? \"file\" : row.kind,\n\t\t\texcludeId: input.id\n\t\t});\n\t\tif (actionType === \"UPDATE_FILE\") {\n\t\t\tconst documentType = input.documentType;\n\t\t\tawait trx.updateTable(\"DriveNode\").set({\n\t\t\t\tname,\n\t\t\t\trequestedName,\n\t\t\t\tdocumentType: row.kind === \"file\" ? documentType ?? row.documentType : null,\n\t\t\t\tupdatedAt: /* @__PURE__ */ new Date()\n\t\t\t}).where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", input.id).execute();\n\t\t\treturn;\n\t\t}\n\t\tawait trx.updateTable(\"DriveNode\").set({\n\t\t\tname,\n\t\t\trequestedName,\n\t\t\tparentFolder: nextParentFolder,\n\t\t\tupdatedAt: /* @__PURE__ */ new Date()\n\t\t}).where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", input.id).execute();\n\t}\n\tasync moveLegacyNode(trx, driveId, rule, input) {\n\t\tif (input.srcFolder === input.targetParentFolder) return;\n\t\tconst row = await this.findNode(trx, driveId, input.srcFolder);\n\t\tif (!row) return;\n\t\tconst target = input.targetParentFolder || null;\n\t\tif (row.kind === \"folder\" && target !== null) {\n\t\t\tif ((await this.subtreeIds(trx, driveId, row.id)).includes(target)) return;\n\t\t}\n\t\tconst { name, requestedName } = await this.nodeName(trx, rule, {\n\t\t\tdriveId,\n\t\t\tfolder: target,\n\t\t\tsrcName: rule === \"legacy\" ? row.name : row.requestedName,\n\t\t\tkind: row.kind,\n\t\t\texcludeId: rule === \"legacy\" ? null : row.id\n\t\t});\n\t\tawait trx.updateTable(\"DriveNode\").set({\n\t\t\tname,\n\t\t\trequestedName,\n\t\t\tparentFolder: target,\n\t\t\tupdatedAt: /* @__PURE__ */ new Date()\n\t\t}).where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", row.id).execute();\n\t}\n\t/**\n\t* A legacy row's name is whatever the legacy reducer would produce, and is\n\t* also its requested name; a reactor-drive row keeps the requested name and\n\t* resolves the displayed one with the reactor-drive rule.\n\t*/\n\tasync nodeName(trx, rule, target) {\n\t\tif (rule === \"legacy\") {\n\t\t\tconst name = await this.legacySiblingName(trx, target.driveId, target.folder, target.srcName, target.kind, target.excludeId);\n\t\t\treturn {\n\t\t\t\tname,\n\t\t\t\trequestedName: name\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tname: await this.resolveSiblingName(trx, target.driveId, target.folder, target.srcName, target.excludeId ?? \"\"),\n\t\t\trequestedName: target.srcName\n\t\t};\n\t}\n\twarnSkipped(item, reason) {\n\t\tthis.logger.warn(\"skipped @actionType on drive @driveId at ordinal @ordinal (index @index): @reason\", item.operation.action.type, item.context.documentId, item.context.ordinal, item.operation.index, reason);\n\t}\n\t/**\n\t* The legacy handleTargetNameCollisions: a same-kind sibling with the name\n\t* gives `name (copy) N`, N one past the highest existing copy number.\n\t*/\n\tasync legacySiblingName(trx, driveId, targetFolder, srcName, kind, excludeId) {\n\t\tconst folder = targetFolder === \"\" ? null : targetFolder;\n\t\tlet siblings = trx.selectFrom(\"DriveNode\").select(\"name\").where(\"driveId\", \"=\", driveId).where(\"kind\", \"=\", kind);\n\t\tsiblings = folder === null ? siblings.where(\"parentFolder\", \"is\", null) : siblings.where(\"parentFolder\", \"=\", folder);\n\t\tif (excludeId !== null) siblings = siblings.where(\"id\", \"!=\", excludeId);\n\t\tif (!await siblings.where(\"name\", \"=\", srcName).limit(1).executeTakeFirst()) return srcName;\n\t\tconst copies = await siblings.where(\"name\", \"like\", `${escapeLike(srcName)} (copy)%`).execute();\n\t\treturn `${srcName} (copy) ${getNextCopyNumber(copies.map((row) => row.name), srcName)}`;\n\t}\n\tasync findNode(trx, driveId, id) {\n\t\treturn trx.selectFrom(\"DriveNode\").select([\n\t\t\t\"id\",\n\t\t\t\"kind\",\n\t\t\t\"name\",\n\t\t\t\"requestedName\",\n\t\t\t\"parentFolder\",\n\t\t\t\"documentType\"\n\t\t]).where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", id).executeTakeFirst();\n\t}\n\t/** The node and its descendants; empty when the node does not exist. */\n\tasync subtreeIds(trx, driveId, root) {\n\t\treturn (await trx.withRecursive(\"subtree\", (qb) => qb.selectFrom(\"DriveNode\").select(\"id\").where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", root).union(qb.selectFrom(\"DriveNode\").innerJoin(\"subtree\", \"DriveNode.parentFolder\", \"subtree.id\").where(\"DriveNode.driveId\", \"=\", driveId).select(\"DriveNode.id\"))).selectFrom(\"subtree\").select(\"id\").execute()).map((row) => row.id);\n\t}\n\tasync applyDeleteDocument(trx, item) {\n\t\tconst docId = item.operation.action.input.documentId || item.context.documentId;\n\t\tconst linked = await trx.selectFrom(\"DriveNode\").select(\"driveId\").where(\"id\", \"=\", docId).execute();\n\t\tconst legacyDrives = await this.legacyDrivesAmong(trx, linked.map((row) => row.driveId));\n\t\tif (legacyDrives.size === 0) {\n\t\t\tawait this.eraseDocument(trx, docId);\n\t\t\treturn;\n\t\t}\n\t\tawait trx.deleteFrom(\"DriveNode\").where((eb) => eb.or([eb.and([eb(\"id\", \"=\", docId), eb(\"driveId\", \"not in\", [...legacyDrives])]), eb(\"driveId\", \"=\", docId)])).execute();\n\t\tawait trx.deleteFrom(\"DocumentName\").where(\"docId\", \"=\", docId).execute();\n\t}\n\t/** The legacy drives among the given ids, from the write identity table. */\n\tasync legacyDrivesAmong(trx, driveIds) {\n\t\tif (driveIds.length === 0) return /* @__PURE__ */ new Set();\n\t\tconst rows = await this.purgeLookup(trx).selectFrom(\"WriteIdentity\").select(\"documentId\").where(\"documentId\", \"in\", [...new Set(driveIds)]).where(\"documentType\", \"=\", LEGACY_DRIVE_DOCUMENT_TYPE).execute();\n\t\treturn new Set(rows.map((row) => row.documentId));\n\t}\n\t/** The id's nodes in every drive, a drive's own tree, and its name. */\n\tasync eraseDocument(trx, docId) {\n\t\tawait trx.deleteFrom(\"DriveNode\").where((eb) => eb.or([eb(\"id\", \"=\", docId), eb(\"driveId\", \"=\", docId)])).execute();\n\t\tawait trx.deleteFrom(\"DocumentName\").where(\"docId\", \"=\", docId).execute();\n\t}\n\tasync handleAddFileRelationship(trx, driveId, input) {\n\t\tconst metadata = this.parseFileMetadata(input);\n\t\tconst parentFolder = metadata.parentFolderId ?? null;\n\t\tconst documentType = metadata.documentType;\n\t\tconst requestedName = metadata.name ?? await this.lookupDocumentName(trx, input.targetId) ?? await this.lookupSnapshotName(trx, input.targetId) ?? \"\";\n\t\tconst resolved = await this.resolveSiblingName(trx, driveId, parentFolder, requestedName, input.targetId);\n\t\tawait trx.insertInto(\"DriveNode\").values({\n\t\t\tdriveId,\n\t\t\tid: input.targetId,\n\t\t\tkind: \"file\",\n\t\t\tname: resolved,\n\t\t\trequestedName,\n\t\t\tparentFolder,\n\t\t\tdocumentType\n\t\t}).onConflict((oc) => oc.columns([\"driveId\", \"id\"]).doUpdateSet({\n\t\t\tparentFolder,\n\t\t\tname: resolved,\n\t\t\trequestedName,\n\t\t\tkind: \"file\",\n\t\t\tdocumentType,\n\t\t\tupdatedAt: /* @__PURE__ */ new Date()\n\t\t})).execute();\n\t}\n\tasync handleAddFolder(trx, driveId, input) {\n\t\tconst parentFolder = input.parentFolderId ?? null;\n\t\tconst resolved = await this.resolveSiblingName(trx, driveId, parentFolder, input.name, input.folderId);\n\t\tawait trx.insertInto(\"DriveNode\").values({\n\t\t\tdriveId,\n\t\t\tid: input.folderId,\n\t\t\tkind: \"folder\",\n\t\t\tname: resolved,\n\t\t\trequestedName: input.name,\n\t\t\tparentFolder,\n\t\t\tdocumentType: null\n\t\t}).onConflict((oc) => oc.columns([\"driveId\", \"id\"]).doUpdateSet({\n\t\t\tparentFolder,\n\t\t\tname: resolved,\n\t\t\trequestedName: input.name,\n\t\t\tkind: \"folder\",\n\t\t\tdocumentType: null,\n\t\t\tupdatedAt: /* @__PURE__ */ new Date()\n\t\t})).execute();\n\t}\n\tasync handleUpdateFolder(trx, driveId, input) {\n\t\tconst row = await trx.selectFrom(\"DriveNode\").selectAll().where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", input.folderId).executeTakeFirst();\n\t\tif (!row) return;\n\t\tconst nextParentFolder = input.parentFolderId === void 0 ? row.parentFolder : input.parentFolderId ?? null;\n\t\tconst nextRequestedName = typeof input.name === \"string\" ? input.name : row.requestedName;\n\t\tconst resolved = await this.resolveSiblingName(trx, driveId, nextParentFolder, nextRequestedName, input.folderId);\n\t\tawait trx.updateTable(\"DriveNode\").set({\n\t\t\tparentFolder: nextParentFolder,\n\t\t\tname: resolved,\n\t\t\trequestedName: nextRequestedName,\n\t\t\tupdatedAt: /* @__PURE__ */ new Date()\n\t\t}).where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", input.folderId).execute();\n\t}\n\t/**\n\t* The name resolveCollision would pick, from an indexed check of the first\n\t* candidates it would try; a folder with all of them taken is scanned.\n\t*/\n\tasync resolveSiblingName(trx, driveId, parentFolder, requested, excludeId) {\n\t\tconst candidates = [requested];\n\t\tfor (let suffix = 2; suffix <= SIBLING_NAME_CANDIDATES; suffix++) candidates.push(`${requested} (${suffix})`);\n\t\tlet siblings = trx.selectFrom(\"DriveNode\").select(\"name\").where(\"driveId\", \"=\", driveId).where(\"id\", \"!=\", excludeId);\n\t\tsiblings = parentFolder === null ? siblings.where(\"parentFolder\", \"is\", null) : siblings.where(\"parentFolder\", \"=\", parentFolder);\n\t\tconst takenRows = await siblings.where(\"name\", \"in\", candidates).execute();\n\t\tconst taken = new Set(takenRows.map((r) => r.name));\n\t\tconst free = candidates.find((candidate) => !taken.has(candidate));\n\t\tif (free !== void 0) return free;\n\t\treturn resolveCollision(requested, (await siblings.execute()).map((r) => r.name));\n\t}\n\tasync lookupDocumentName(trx, docId) {\n\t\treturn (await trx.selectFrom(\"DocumentName\").select(\"name\").where(\"docId\", \"=\", docId).executeTakeFirst())?.name;\n\t}\n\t/** The document view's name for a document, preferring its header row. */\n\tasync lookupSnapshotName(trx, docId) {\n\t\tconst rows = await this.purgeLookup(trx).selectFrom(\"DocumentSnapshot\").select([\"scope\", \"name\"]).where(\"documentId\", \"=\", docId).where(\"name\", \"is not\", null).where(\"name\", \"!=\", \"\").execute();\n\t\treturn (rows.find((row) => row.scope === \"header\") ?? rows.at(0))?.name;\n\t}\n\tparseFileMetadata(input) {\n\t\tconst metadata = input.metadata;\n\t\tif (!metadata || typeof metadata !== \"object\" || metadata.kind !== \"file\" || typeof metadata.documentType !== \"string\") throw new Error(`ADD_RELATIONSHIP for target ${input.targetId}: missing or invalid drive/child file metadata (expected { kind: \"file\", parentFolderId, documentType })`);\n\t\tconst typed = metadata;\n\t\treturn {\n\t\t\tkind: \"file\",\n\t\t\tparentFolderId: typed.parentFolderId ?? null,\n\t\t\tdocumentType: typed.documentType,\n\t\t\t...typeof typed.name === \"string\" && typed.name !== \"\" ? { name: typed.name } : {}\n\t\t};\n\t}\n\tasync upsertDocumentName(trx, docId, name) {\n\t\tawait trx.insertInto(\"DocumentName\").values({\n\t\t\tdocId,\n\t\t\tname\n\t\t}).onConflict((oc) => oc.column(\"docId\").doUpdateSet({\n\t\t\tname,\n\t\t\tupdatedAt: /* @__PURE__ */ new Date()\n\t\t})).execute();\n\t}\n};\nfunction legacySnapshotRows(driveId, content) {\n\tconst nodes = content?.nodes;\n\tif (!Array.isArray(nodes)) return [];\n\tconst rows = [];\n\tfor (const node of nodes) {\n\t\tif (typeof node.id !== \"string\" || typeof node.name !== \"string\") continue;\n\t\tconst parentFolder = typeof node.parentFolder === \"string\" ? node.parentFolder : null;\n\t\tconst base = {\n\t\t\tdriveId,\n\t\t\tid: node.id,\n\t\t\tname: node.name,\n\t\t\trequestedName: node.name,\n\t\t\tparentFolder\n\t\t};\n\t\tif (node.kind === \"folder\") rows.push({\n\t\t\t...base,\n\t\t\tkind: \"folder\",\n\t\t\tdocumentType: null\n\t\t});\n\t\telse if (node.kind === \"file\" && typeof node.documentType === \"string\") rows.push({\n\t\t\t...base,\n\t\t\tkind: \"file\",\n\t\t\tdocumentType: node.documentType\n\t\t});\n\t}\n\treturn rows;\n}\nfunction isNonEmptyString(value) {\n\treturn typeof value === \"string\" && value !== \"\";\n}\nfunction escapeLike(value) {\n\treturn value.replace(/[\\\\%_]/g, (char) => `\\\\${char}`);\n}\n//#endregion\n//#region src/read-model/drive-node-view.ts\nconst DEFAULT_LIMIT = 100;\nfunction parseListChildrenPaging(paging) {\n\tif (paging === void 0) return {\n\t\tlimit: DEFAULT_LIMIT,\n\t\tcursor: null\n\t};\n\tif (!Number.isInteger(paging.limit) || paging.limit < 1) throw new Error(`Invalid paging limit: ${String(paging.limit)} (must be an integer >= 1)`);\n\tif (paging.cursor === \"\") return {\n\t\tlimit: paging.limit,\n\t\tcursor: null\n\t};\n\treturn {\n\t\tlimit: paging.limit,\n\t\tcursor: decodeKeysetCursor(paging.cursor)\n\t};\n}\nfunction encodeKeysetCursor(createdAt, id) {\n\treturn globalThis.btoa(JSON.stringify({\n\t\tcreatedAt,\n\t\tid\n\t}));\n}\nfunction decodeKeysetCursor(cursor) {\n\tlet decoded;\n\ttry {\n\t\tdecoded = globalThis.atob(cursor);\n\t} catch {\n\t\tthrow new Error(`Invalid paging cursor: ${JSON.stringify(cursor)} (must be a keyset cursor returned by a prior page)`);\n\t}\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(decoded);\n\t} catch {\n\t\tthrow new Error(`Invalid paging cursor: ${JSON.stringify(cursor)} (must be a keyset cursor returned by a prior page)`);\n\t}\n\tif (parsed === null || typeof parsed !== \"object\" || typeof parsed.createdAt !== \"string\" || typeof parsed.id !== \"string\") throw new Error(`Invalid paging cursor: ${JSON.stringify(cursor)} (must be a keyset cursor returned by a prior page)`);\n\tconst createdAt = parsed.createdAt;\n\tif (Number.isNaN(new Date(createdAt).getTime())) throw new Error(`Invalid paging cursor: ${JSON.stringify(cursor)} (createdAt is not a valid timestamp)`);\n\treturn {\n\t\tcreatedAt,\n\t\tid: parsed.id\n\t};\n}\nvar DriveNodeView = class {\n\tdb;\n\tconstructor(db) {\n\t\tthis.db = db;\n\t}\n\tasync getNode(driveId, nodeId) {\n\t\tconst row = await this.db.selectFrom(\"DriveNode\").selectAll().where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", nodeId).executeTakeFirst();\n\t\tif (!row) return void 0;\n\t\treturn rowToNode(row);\n\t}\n\tasync listChildren(driveId, parentFolder, paging, _signal, kind) {\n\t\tconst { limit, cursor } = parseListChildrenPaging(paging);\n\t\tlet query = this.db.selectFrom(\"DriveNode\").selectAll().select(sql`to_char(\"createdAt\" AT TIME ZONE 'UTC', 'YYYY-MM-DD\"T\"HH24:MI:SS.US\"Z\"')`.as(\"createdAtKey\")).where(\"driveId\", \"=\", driveId);\n\t\tif (parentFolder === null) query = query.where(\"parentFolder\", \"is\", null);\n\t\telse if (parentFolder !== void 0) query = query.where(\"parentFolder\", \"=\", parentFolder);\n\t\tif (kind !== void 0) query = query.where(\"kind\", \"=\", kind);\n\t\tif (cursor !== null) query = query.where((eb) => eb(eb.refTuple(\"createdAt\", \"id\"), \">\", eb.tuple(sql`${cursor.createdAt}::timestamptz`, sql`${cursor.id}`)));\n\t\tconst rows = await query.orderBy(\"createdAt\", \"asc\").orderBy(\"id\", \"asc\").limit(limit + 1).execute();\n\t\tconst hasMore = rows.length > limit;\n\t\tconst sliced = hasMore ? rows.slice(0, limit) : rows;\n\t\tconst cursors = sliced.map((row) => encodeKeysetCursor(row.createdAtKey, row.id));\n\t\treturn {\n\t\t\tresults: sliced.map(rowToNode),\n\t\t\tcursors,\n\t\t\toptions: {\n\t\t\t\tcursor: paging?.cursor ?? \"\",\n\t\t\t\tlimit\n\t\t\t},\n\t\t\tnextCursor: hasMore ? cursors[cursors.length - 1] : void 0\n\t\t};\n\t}\n\tasync listAll(driveId) {\n\t\treturn (await this.db.selectFrom(\"DriveNode\").selectAll().where(\"driveId\", \"=\", driveId).orderBy(\"createdAt\", \"asc\").orderBy(\"id\", \"asc\").execute()).map(rowToNode);\n\t}\n\tasync getDescendants(driveId, root) {\n\t\treturn (await this.db.withRecursive(\"descendants\", (qb) => qb.selectFrom(\"DriveNode\").select([\n\t\t\t\"driveId\",\n\t\t\t\"id\",\n\t\t\t\"kind\",\n\t\t\t\"name\",\n\t\t\t\"requestedName\",\n\t\t\t\"parentFolder\",\n\t\t\t\"documentType\",\n\t\t\t\"createdAt\"\n\t\t]).where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", root).unionAll(qb.selectFrom(\"DriveNode\").innerJoin(\"descendants\", \"DriveNode.parentFolder\", \"descendants.id\").where(\"DriveNode.driveId\", \"=\", driveId).select([\n\t\t\t\"DriveNode.driveId\",\n\t\t\t\"DriveNode.id\",\n\t\t\t\"DriveNode.kind\",\n\t\t\t\"DriveNode.name\",\n\t\t\t\"DriveNode.requestedName\",\n\t\t\t\"DriveNode.parentFolder\",\n\t\t\t\"DriveNode.documentType\",\n\t\t\t\"DriveNode.createdAt\"\n\t\t]))).selectFrom(\"descendants\").select([\n\t\t\t\"driveId\",\n\t\t\t\"id\",\n\t\t\t\"kind\",\n\t\t\t\"name\",\n\t\t\t\"requestedName\",\n\t\t\t\"parentFolder\",\n\t\t\t\"documentType\"\n\t\t]).orderBy(\"createdAt\", \"asc\").orderBy(\"id\", \"asc\").execute()).map(rowToNode);\n\t}\n};\nfunction rowToNode(row) {\n\tif (row.kind === \"file\") {\n\t\tif (row.documentType === null) throw new Error(`DriveNode ${row.driveId}/${row.id}: file row has null documentType, which violates the schema CHECK constraint`);\n\t\treturn {\n\t\t\tkind: \"file\",\n\t\t\tid: row.id,\n\t\t\tdriveId: row.driveId,\n\t\t\tparentFolder: row.parentFolder,\n\t\t\tname: row.name,\n\t\t\tdocumentType: row.documentType\n\t\t};\n\t}\n\treturn {\n\t\tkind: \"folder\",\n\t\tid: row.id,\n\t\tdriveId: row.driveId,\n\t\tparentFolder: row.parentFolder,\n\t\tname: row.name\n\t};\n}\n//#endregion\n//#region src/client/reactor-drive-write-strategy.ts\n/**\n* A handle over one write made of several: `primary` names the document and\n* the read-back; each stage settles when every part has, rejecting with the\n* first failure in the order given, and the receipt carries a token over all.\n*/\nvar CompositeWriteHandle = class {\n\tprimary;\n\tparts;\n\twrittenReceipt;\n\treadableReceipt;\n\tconstructor(primary, parts) {\n\t\tthis.primary = primary;\n\t\tthis.parts = parts;\n\t}\n\tget jobId() {\n\t\treturn this.primary.jobId;\n\t}\n\tget documentId() {\n\t\treturn this.primary.documentId;\n\t}\n\tget branch() {\n\t\treturn this.primary.branch;\n\t}\n\tget written() {\n\t\tthis.writtenReceipt ??= this.receiptAt(\"written\");\n\t\treturn this.writtenReceipt;\n\t}\n\tget readable() {\n\t\tthis.readableReceipt ??= this.receiptAt(\"readable\");\n\t\treturn this.readableReceipt;\n\t}\n\tasync document(view, signal) {\n\t\tawait this.readable;\n\t\treturn this.primary.document(view, signal);\n\t}\n\tasync receiptAt(stage) {\n\t\tconst receipts = [];\n\t\tfor (const handle of [this.primary, ...this.parts]) receipts.push(stage === \"written\" ? await handle.written : await handle.readable);\n\t\treturn {\n\t\t\t...receipts[0],\n\t\t\ttoken: mergeConsistencyTokens(receipts.map((receipt) => receipt.token))\n\t\t};\n\t}\n};\n/** A write handle that also names the node the write made or changed. */\nvar NodeHandle = class {\n\thandle;\n\tnodeId;\n\tconstructor(handle, nodeId) {\n\t\tthis.handle = handle;\n\t\tthis.nodeId = nodeId;\n\t}\n\tget jobId() {\n\t\treturn this.handle.jobId;\n\t}\n\tget documentId() {\n\t\treturn this.handle.documentId;\n\t}\n\tget branch() {\n\t\treturn this.handle.branch;\n\t}\n\tget written() {\n\t\treturn this.handle.written;\n\t}\n\tget readable() {\n\t\treturn this.handle.readable;\n\t}\n\tdocument(view, signal) {\n\t\treturn this.handle.document(view, signal);\n\t}\n};\n/**\n* The node writes of reactor-drives: folders are drive-scoped actions, files\n* are `drive/child` relationships carrying their parent folder, and nodes are\n* read from the `DriveNode` projection. Each write returns once its last step\n* is accepted; a step a later step depends on is waited for here.\n*/\nvar ReactorDriveWriteStrategy = class {\n\tread;\n\twrite;\n\tnodes;\n\tconstructor(read, write, nodes) {\n\t\tthis.read = read;\n\t\tthis.write = write;\n\t\tthis.nodes = nodes;\n\t}\n\tasync addFile(driveIdentifier, document, parentFolder, signal) {\n\t\tconst documentId = document.header.id;\n\t\tconst protocolVersions = await createVersionsOf(document, (options) => this.read.getCreateProtocolVersions(options, signal), driveIdentifier);\n\t\tconst metadata = {\n\t\t\tkind: \"file\",\n\t\t\tparentFolderId: parentFolder ?? null,\n\t\t\tdocumentType: document.header.documentType\n\t\t};\n\t\tconst request = { jobs: [{\n\t\t\tkey: \"create\",\n\t\t\tdocumentId,\n\t\t\tscope: \"document\",\n\t\t\tbranch: \"main\",\n\t\t\tactions: creationActions(document, protocolVersions),\n\t\t\tdependsOn: []\n\t\t}, {\n\t\t\tkey: \"link\",\n\t\t\tdocumentId: driveIdentifier,\n\t\t\tscope: \"document\",\n\t\t\tbranch: \"main\",\n\t\t\tactions: [addRelationshipAction(driveIdentifier, documentId, DRIVE_CHILD_RELATIONSHIP_TYPE, metadata)],\n\t\t\tdependsOn: [\"create\"]\n\t\t}] };\n\t\tconst batch = await this.write.executeBatch(request, signal);\n\t\treturn new CompositeWriteHandle(batch.handles.create, [batch.handles.link]);\n\t}\n\tasync addFolder(driveIdentifier, name, parentFolder, signal) {\n\t\tconst folderId = generateId();\n\t\treturn new NodeHandle(await this.write.execute(driveIdentifier, \"main\", [addFolderAction({\n\t\t\tfolderId,\n\t\t\tparentFolderId: parentFolder ?? null,\n\t\t\tname\n\t\t})], signal), folderId);\n\t}\n\tasync removeNode(driveIdentifier, nodeId, signal) {\n\t\tif ((await this.requireNode(driveIdentifier, nodeId, signal)).kind === \"folder\") {\n\t\t\tconst subtree = await this.nodes.getDescendants(driveIdentifier, nodeId, signal);\n\t\t\tconst fileDescendants = subtree.filter((n) => n.kind === \"file\");\n\t\t\tconst subFolders = subtree.filter((n) => n.kind === \"folder\" && n.id !== nodeId);\n\t\t\tconst batch = [\n\t\t\t\t...fileDescendants.map((f) => removeRelationshipAction(driveIdentifier, f.id, DRIVE_CHILD_RELATIONSHIP_TYPE)),\n\t\t\t\t...orderDeepestFirst(subFolders, nodeId).map((f) => removeFolderAction({ folderId: f.id })),\n\t\t\t\tremoveFolderAction({ folderId: nodeId })\n\t\t\t];\n\t\t\tconst driveHandle = await this.write.execute(driveIdentifier, \"main\", batch, signal);\n\t\t\tawait driveHandle.readable;\n\t\t\tconst deletes = [];\n\t\t\tfor (const file of fileDescendants) deletes.push(await this.write.deleteDocument(file.id, \"cascade\", signal));\n\t\t\treturn new CompositeWriteHandle(driveHandle, deletes);\n\t\t}\n\t\tconst unlinked = await this.write.execute(driveIdentifier, \"main\", [removeRelationshipAction(driveIdentifier, nodeId, DRIVE_CHILD_RELATIONSHIP_TYPE)], signal);\n\t\tawait unlinked.readable;\n\t\treturn new CompositeWriteHandle(unlinked, [await this.write.deleteDocument(nodeId, void 0, signal)]);\n\t}\n\tasync renameNode(driveIdentifier, nodeId, name, signal) {\n\t\tif ((await this.requireNode(driveIdentifier, nodeId, signal)).kind === \"file\") return new NodeHandle(await this.write.rename(nodeId, name, \"main\", signal), nodeId);\n\t\treturn new NodeHandle(await this.write.execute(driveIdentifier, \"main\", [updateFolderAction({\n\t\t\tfolderId: nodeId,\n\t\t\tname\n\t\t})], signal), nodeId);\n\t}\n\tasync setPreferredEditorOnNode(nodeId, preferredEditor, signal) {\n\t\treturn this.write.setPreferredEditor(nodeId, preferredEditor, \"main\", signal);\n\t}\n\tasync moveNode(driveIdentifier, srcNodeId, targetParentFolderId, signal) {\n\t\tconst node = await this.requireNode(driveIdentifier, srcNodeId, signal);\n\t\tif (node.kind === \"folder\") return this.write.execute(driveIdentifier, \"main\", [updateFolderAction({\n\t\t\tfolderId: srcNodeId,\n\t\t\tparentFolderId: targetParentFolderId ?? null\n\t\t})], signal);\n\t\tconst metadata = {\n\t\t\tkind: \"file\",\n\t\t\tparentFolderId: targetParentFolderId ?? null,\n\t\t\tdocumentType: node.documentType ?? \"\"\n\t\t};\n\t\treturn this.write.execute(driveIdentifier, \"main\", [removeRelationshipAction(driveIdentifier, srcNodeId, DRIVE_CHILD_RELATIONSHIP_TYPE), addRelationshipAction(driveIdentifier, srcNodeId, DRIVE_CHILD_RELATIONSHIP_TYPE, metadata)], signal);\n\t}\n\tasync copyNode(driveIdentifier, srcNodeId, targetParentFolderId, signal, options) {\n\t\tif (options?.protocolVersions) throw new Error(\"ReactorDriveClient.copyNode replays the source's operations and cannot override its protocolVersions\");\n\t\tawait this.requireNode(driveIdentifier, srcNodeId, signal);\n\t\tconst subtree = await this.nodes.getDescendants(driveIdentifier, srcNodeId, signal);\n\t\tif (targetParentFolderId !== void 0 && subtree.some((n) => n.id === targetParentFolderId)) throw new Error(`Cannot copy node ${srcNodeId} into itself or one of its descendants (target: ${targetParentFolderId})`);\n\t\tconst idMap = /* @__PURE__ */ new Map();\n\t\tfor (const node of subtree) idMap.set(node.id, generateId());\n\t\tconst policy = await this.read.getCreateSignaturePolicy();\n\t\tconst selectedByType = /* @__PURE__ */ new Map();\n\t\tconst jobs = [];\n\t\tconst driveActions = [];\n\t\tconst fileCreateKeys = [];\n\t\tfor (const node of subtree) {\n\t\t\tlet newId = idMap.get(node.id);\n\t\t\tlet newParent;\n\t\t\tif (node.id === srcNodeId) newParent = targetParentFolderId ?? null;\n\t\t\telse {\n\t\t\t\tif (node.parentFolder == null) throw new Error(`copyNode: descendant ${node.id} has no parentFolder`);\n\t\t\t\tconst mapped = idMap.get(node.parentFolder);\n\t\t\t\tif (mapped === void 0) throw new Error(`copyNode: descendant ${node.id} parent ${node.parentFolder} missing from idMap`);\n\t\t\t\tnewParent = mapped;\n\t\t\t}\n\t\t\tif (node.kind === \"folder\") {\n\t\t\t\tdriveActions.push(addFolderAction({\n\t\t\t\t\tfolderId: newId,\n\t\t\t\t\tparentFolderId: newParent,\n\t\t\t\t\tname: node.name\n\t\t\t\t}));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst srcDoc = await this.read.get(node.id, void 0, signal);\n\t\t\tconst documentType = srcDoc.header.documentType;\n\t\t\tconst { results: allModules } = await this.read.getDocumentModelModules();\n\t\t\tconst modulesForType = allModules.filter((m) => m.documentModel.global.id === documentType);\n\t\t\tif (modulesForType.length === 0) throw new Error(`Document model module not found for type: ${documentType}`);\n\t\t\tconst reducers = {};\n\t\t\tfor (const m of modulesForType) reducers[m.version ?? 1] = m.reducer;\n\t\t\tconst config = { reducers };\n\t\t\tlet selected = selectedByType.get(documentType);\n\t\t\tif (selected === void 0) {\n\t\t\t\tselected = await this.read.getCreateProtocolVersions({\n\t\t\t\t\tdocumentType,\n\t\t\t\t\tparentIdentifier: driveIdentifier\n\t\t\t\t}, signal);\n\t\t\t\tselectedByType.set(documentType, selected);\n\t\t\t}\n\t\t\tconst replayHeader = createCopyHeader({\n\t\t\t\tdocumentType,\n\t\t\t\tprotocolVersions: {\n\t\t\t\t\t...selected,\n\t\t\t\t\t...srcDoc.header.protocolVersions\n\t\t\t\t}\n\t\t\t}, newId, policy);\n\t\t\tnewId = replayHeader.id;\n\t\t\tconst duplicated = replayDocumentVersioned(srcDoc.initialState, srcDoc.operations, config, replayHeader);\n\t\t\tassertAuthPreservedOnDuplicate(node.id, srcDoc.state.auth, duplicated.state.auth);\n\t\t\tduplicated.header.name = node.name;\n\t\t\tconst createKey = `create:${newId}`;\n\t\t\tjobs.push({\n\t\t\t\tkey: createKey,\n\t\t\t\tdocumentId: newId,\n\t\t\t\tscope: \"document\",\n\t\t\t\tbranch: \"main\",\n\t\t\t\tactions: creationActions(duplicated, duplicated.header.protocolVersions ?? selected),\n\t\t\t\tdependsOn: []\n\t\t\t});\n\t\t\tfileCreateKeys.push(createKey);\n\t\t\tconst metadata = {\n\t\t\t\tkind: \"file\",\n\t\t\t\tparentFolderId: newParent,\n\t\t\t\tdocumentType: duplicated.header.documentType\n\t\t\t};\n\t\t\tdriveActions.push(addRelationshipAction(driveIdentifier, newId, DRIVE_CHILD_RELATIONSHIP_TYPE, metadata));\n\t\t}\n\t\tjobs.push({\n\t\t\tkey: \"drive\",\n\t\t\tdocumentId: driveIdentifier,\n\t\t\tscope: \"document\",\n\t\t\tbranch: \"main\",\n\t\t\tactions: driveActions,\n\t\t\tdependsOn: fileCreateKeys\n\t\t});\n\t\tconst batch = await this.write.executeBatch({ jobs }, signal);\n\t\treturn new CompositeWriteHandle(batch.handles.drive, fileCreateKeys.map((key) => batch.handles[key]));\n\t}\n\tasync requireNode(driveIdentifier, nodeId, signal) {\n\t\tconst node = await this.nodes.getNode(driveIdentifier, nodeId, signal);\n\t\tif (!node) throw new Error(`Node ${nodeId} not found in drive ${driveIdentifier}`);\n\t\treturn node;\n\t}\n};\nfunction orderDeepestFirst(folders, rootId) {\n\tconst depthById = /* @__PURE__ */ new Map();\n\tconst compute = (id) => {\n\t\tif (id === rootId) return 0;\n\t\tconst cached = depthById.get(id);\n\t\tif (cached !== void 0) return cached;\n\t\tconst folder = folders.find((f) => f.id === id);\n\t\tif (!folder) return 0;\n\t\tconst parent = folder.parentFolder ?? rootId;\n\t\tconst depth = compute(parent) + 1;\n\t\tdepthById.set(id, depth);\n\t\treturn depth;\n\t};\n\treturn folders.slice().sort((a, b) => compute(b.id) - compute(a.id));\n}\n/**\n* The write strategy for drives of `REACTOR_DRIVE_DOCUMENT_TYPE`. Registered on\n* the client builder with `withDriveWriteStrategy`; needs the `DriveNode`\n* projection as its node source.\n*/\nfunction createReactorDriveWriteStrategy(args) {\n\tif (!args.nodes) throw new Error(\"The reactor-drive write strategy needs a drive node source (withDriveNodeSource)\");\n\treturn new ReactorDriveWriteStrategy(args.read, args.write, args.nodes);\n}\n//#endregion\n//#region src/client/reactor-drive-client.ts\n/**\n* Implementation of {@link IDriveClient} backed by the reactor's relationship\n* primitives and the drive-scoped folder actions. Folder structure lives in\n* the operation log (ADD_FOLDER/UPDATE_FOLDER/REMOVE_FOLDER + ADD_RELATIONSHIP\n* for files) and is materialised by `NodeProcessor` into the `DriveNode`\n* table consumed via {@link IDriveReadModel}.\n*/\nvar ReactorDriveClient = class {\n\tread;\n\twrite;\n\treadModel;\n\tstrategy;\n\tconstructor(args) {\n\t\tif (\"reactor\" in args) {\n\t\t\tthis.read = args.reactor.read;\n\t\t\tthis.write = args.reactor.write;\n\t\t} else {\n\t\t\tthis.read = args.read;\n\t\t\tthis.write = args.write;\n\t\t}\n\t\tthis.readModel = args.readModel;\n\t\tthis.strategy = createReactorDriveWriteStrategy({\n\t\t\tread: this.read,\n\t\t\twrite: this.write,\n\t\t\tnodes: this.readModel\n\t\t});\n\t}\n\tasync create(input, signal) {\n\t\tconst driveDoc = await this.read.newDocument(REACTOR_DRIVE_DOCUMENT_TYPE, {\n\t\t\tinitialState: { global: {\n\t\t\t\tname: input.global.name,\n\t\t\t\ticon: input.global.icon ?? null\n\t\t\t} },\n\t\t\tsignaturePolicy: input.signaturePolicy,\n\t\t\tprotocolVersions: input.protocolVersions\n\t\t}, signal);\n\t\tif (input.local) {\n\t\t\tif (typeof input.local.sharingType === \"string\") driveDoc.state.local.sharingType = input.local.sharingType;\n\t\t\tif (typeof input.local.availableOffline === \"boolean\") driveDoc.state.local.availableOffline = input.local.availableOffline;\n\t\t}\n\t\tif (input.preferredEditor) driveDoc.header.meta = {\n\t\t\t...driveDoc.header.meta,\n\t\t\tpreferredEditor: input.preferredEditor\n\t\t};\n\t\tconst created = await (await this.write.create(driveDoc, void 0, signal)).document(void 0, signal);\n\t\treturn this.toLegacyDriveDocument(created, created.header.id);\n\t}\n\tasync addFile(driveIdentifier, document, parentFolder, signal) {\n\t\tconst receipt = await (await this.strategy.addFile(driveIdentifier, document, parentFolder, signal)).readable;\n\t\treturn this.read.get(document.header.id, void 0, signal, receipt.token);\n\t}\n\tasync addFolder(driveIdentifier, name, parentFolder, signal) {\n\t\tconst handle = await this.strategy.addFolder(driveIdentifier, name, parentFolder, signal);\n\t\tawait handle.readable;\n\t\treturn {\n\t\t\tid: handle.nodeId,\n\t\t\tkind: \"folder\",\n\t\t\tname,\n\t\t\tparentFolder: parentFolder ?? null\n\t\t};\n\t}\n\tasync removeNode(driveIdentifier, nodeId, signal) {\n\t\tawait (await this.strategy.removeNode(driveIdentifier, nodeId, signal)).readable;\n\t}\n\tasync renameNode(driveIdentifier, nodeId, name, signal) {\n\t\tawait (await this.strategy.renameNode(driveIdentifier, nodeId, name, signal)).readable;\n\t\tconst updated = await this.readModel.getNode(driveIdentifier, nodeId, signal);\n\t\tif (!updated) throw new Error(\"Node missing from drive after rename\");\n\t\treturn this.toLegacyNode(updated);\n\t}\n\tasync setPreferredEditorOnNode(nodeId, preferredEditor, signal) {\n\t\treturn (await this.strategy.setPreferredEditorOnNode(nodeId, preferredEditor, signal)).document(void 0, signal);\n\t}\n\tasync moveNode(driveIdentifier, srcNodeId, targetParentFolderId, signal) {\n\t\tconst handle = await this.strategy.moveNode(driveIdentifier, srcNodeId, targetParentFolderId, signal);\n\t\treturn this.readDriveAfter(handle, driveIdentifier, signal);\n\t}\n\tasync copyNode(driveIdentifier, srcNodeId, targetParentFolderId, signal, options) {\n\t\tconst handle = await this.strategy.copyNode(driveIdentifier, srcNodeId, targetParentFolderId, signal, options);\n\t\treturn this.readDriveAfter(handle, driveIdentifier, signal);\n\t}\n\tasync getNode(driveIdentifier, nodeId, signal) {\n\t\tconst node = await this.readModel.getNode(driveIdentifier, nodeId, signal);\n\t\tif (!node) throw new Error(`Node ${nodeId} not found in drive ${driveIdentifier}`);\n\t\treturn this.toLegacyNode(node);\n\t}\n\tasync listNodes(driveIdentifier, parentFolder, paging, signal) {\n\t\tconst page = await this.readModel.listChildren(driveIdentifier, parentFolder, paging, signal);\n\t\treturn {\n\t\t\tresults: page.results.map((node) => this.toLegacyNode(node)),\n\t\t\toptions: page.options,\n\t\t\t...page.nextCursor !== void 0 ? { nextCursor: page.nextCursor } : {}\n\t\t};\n\t}\n\t/** Waits for the write, then reads the drive back in the legacy shape. */\n\tasync readDriveAfter(handle, driveIdentifier, signal) {\n\t\tconst receipt = await handle.readable;\n\t\tconst drive = await this.read.get(driveIdentifier, void 0, signal, receipt.token);\n\t\treturn this.toLegacyDriveDocument(drive, driveIdentifier);\n\t}\n\ttoLegacyNode(node) {\n\t\tif (node.kind === \"file\") {\n\t\t\tconst file = node;\n\t\t\treturn {\n\t\t\t\tid: file.id,\n\t\t\t\tkind: \"file\",\n\t\t\t\tname: file.name,\n\t\t\t\tparentFolder: file.parentFolder,\n\t\t\t\tdocumentType: file.documentType\n\t\t\t};\n\t\t}\n\t\tconst folder = node;\n\t\treturn {\n\t\t\tid: folder.id,\n\t\t\tkind: \"folder\",\n\t\t\tname: folder.name,\n\t\t\tparentFolder: folder.parentFolder\n\t\t};\n\t}\n\tasync toLegacyDriveDocument(doc, driveId) {\n\t\tif (doc.header.documentType !== \"powerhouse/reactor-drive\") throw new Error(`Document ${doc.header.id} is not a reactor-drive document`);\n\t\tconst allNodes = await this.readModel.listAll(driveId);\n\t\tconst legacy = structuredClone(doc);\n\t\tconst existingGlobal = legacy.state.global;\n\t\tlegacy.state.global = {\n\t\t\tname: existingGlobal.name ?? \"\",\n\t\t\ticon: existingGlobal.icon ?? null,\n\t\t\tnodes: allNodes.map((n) => this.toLegacyNode(n))\n\t\t};\n\t\treturn legacy;\n\t}\n};\n//#endregion\n//#region src/migration/migrate-legacy-state.ts\n/**\n* Translates a legacy `document-drive` `state.global.nodes` array into the\n* action vocabulary used by the new reactor-drive module.\n*\n* Folder nodes are emitted as `ADD_FOLDER` actions targeting the drive\n* document. File nodes are emitted as `ADD_RELATIONSHIP` actions on the drive\n* with `drive/child` metadata carrying the parent folder id. File nodes\n* assume the underlying PHDocument still exists under the same id — the\n* migration only re-links it into the new drive, it does not recreate\n* documents.\n*\n* Re-running the migration is safe: existing `DriveNode` rows are skipped\n* so already-migrated nodes are left untouched.\n*/\nasync function migrateLegacyDriveState(args) {\n\tconst { reactor, readModel, driveId, nodes, signal } = args;\n\tconst branch = args.branch ?? \"main\";\n\tconst ordered = orderLegacyNodes(nodes);\n\tconst actions = [];\n\tlet skippedExisting = 0;\n\tfor (const node of ordered) {\n\t\tif (await readModel.getNode(driveId, node.id, signal)) {\n\t\t\tskippedExisting += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tactions.push(toAction(driveId, node));\n\t}\n\tif (actions.length === 0) return {\n\t\temittedActions: 0,\n\t\tskippedExisting\n\t};\n\tawait reactor.execute(driveId, branch, actions, signal);\n\treturn {\n\t\temittedActions: actions.length,\n\t\tskippedExisting\n\t};\n}\nfunction toAction(driveId, node) {\n\tif (node.kind === \"folder\") return addFolderAction({\n\t\tfolderId: node.id,\n\t\tparentFolderId: node.parentFolder ?? null,\n\t\tname: node.name\n\t});\n\tconst fileNode = node;\n\tconst metadata = {\n\t\tkind: \"file\",\n\t\tparentFolderId: fileNode.parentFolder ?? null,\n\t\tdocumentType: fileNode.documentType\n\t};\n\treturn addRelationshipAction(driveId, fileNode.id, DRIVE_CHILD_RELATIONSHIP_TYPE, metadata);\n}\n/**\n* Sorts legacy nodes so that any folder appears before its children. The\n* legacy state stores nodes in insertion order, which usually already\n* satisfies that property, but defensive sorting keeps replay deterministic\n* if the input was constructed out of order.\n*/\nfunction orderLegacyNodes(nodes) {\n\tconst byId = /* @__PURE__ */ new Map();\n\tfor (const node of nodes) byId.set(node.id, node);\n\tconst visited = /* @__PURE__ */ new Set();\n\tconst ordered = [];\n\tfor (const start of nodes) {\n\t\tif (visited.has(start.id)) continue;\n\t\tconst chain = [];\n\t\tconst seenInWalk = /* @__PURE__ */ new Set();\n\t\tlet current = start;\n\t\twhile (current && !visited.has(current.id) && !seenInWalk.has(current.id)) {\n\t\t\tseenInWalk.add(current.id);\n\t\t\tchain.push(current);\n\t\t\tconst parentId = current.parentFolder;\n\t\t\tcurrent = parentId ? byId.get(parentId) : void 0;\n\t\t}\n\t\twhile (chain.length > 0) {\n\t\t\tconst node = chain.pop();\n\t\t\tif (visited.has(node.id)) continue;\n\t\t\tvisited.add(node.id);\n\t\t\tordered.push(node);\n\t\t}\n\t}\n\treturn ordered;\n}\n//#endregion\nexport { DRIVE_CHILD_RELATIONSHIP_TYPE, DriveNodeView, NodeProcessor, REACTOR_DRIVE_DOCUMENT_TYPE, REACTOR_DRIVE_FILE_EXTENSION, ReactorDriveClient, addFolderAction, createReactorDriveWriteStrategy, getReactorDriveMigrationStatus, migrateLegacyDriveState, reactorDriveActions, reactorDriveCreateDocument, reactorDriveCreateState, reactorDriveDocumentModelModule, reactorDriveDocumentReducer, reactorDriveStateReducer, removeFolderAction, resolveCollision, runReactorDriveMigrations, setAvailableOfflineAction, setDriveIconAction, setDriveNameAction, setSharingTypeAction, updateFolderAction };\n\n//# sourceMappingURL=index.js.map","//#region \\0rolldown/runtime.js\nvar __defProp = Object.defineProperty;\nvar __exportAll = (all, no_symbols) => {\n\tlet target = {};\n\tfor (var name in all) __defProp(target, name, {\n\t\tget: all[name],\n\t\tenumerable: true\n\t});\n\tif (!no_symbols) __defProp(target, Symbol.toStringTag, { value: \"Module\" });\n\treturn target;\n};\n//#endregion\nexport { __exportAll as t };\n","import { t as __exportAll } from \"./rolldown-runtime-D7D4PA-g.js\";\nimport { BaseDocumentHeaderSchema, BaseDocumentStateSchema, baseActions, baseCreateDocument, baseLoadFromInputVersioned, baseSaveToFileHandle, createAction, createBaseState, createReducer, createState, defaultBaseState, isDocumentAction } from \"document-model\";\nimport * as z$1 from \"zod\";\nimport { z } from \"zod\";\n//#region document-models/reactor-group/v1/gen/schema/zod.ts\nconst isDefinedNonNullAny = (v) => v !== void 0 && v !== null;\nconst definedNonNullAnySchema = z$1.any().refine((v) => isDefinedNonNullAny(v));\nfunction AddMemberInputSchema() {\n\treturn z$1.object({ address: z$1.string() });\n}\nfunction ReactorGroupStateSchema() {\n\treturn z$1.object({\n\t\t__typename: z$1.literal(\"ReactorGroupState\").optional(),\n\t\tdescription: z$1.string(),\n\t\tmembers: z$1.array(z$1.string()),\n\t\tname: z$1.string()\n\t});\n}\nfunction RemoveMemberInputSchema() {\n\treturn z$1.object({ address: z$1.string() });\n}\nfunction SetGroupDescriptionInputSchema() {\n\treturn z$1.object({ description: z$1.string() });\n}\nfunction SetGroupNameInputSchema() {\n\treturn z$1.object({ name: z$1.string() });\n}\n//#endregion\n//#region document-models/reactor-group/v1/gen/group/creators.ts\n/**\n* WARNING: DO NOT EDIT\n* This file is auto-generated and updated by codegen\n*/\nvar creators_exports = /* @__PURE__ */ __exportAll({\n\taddMember: () => addMember,\n\tremoveMember: () => removeMember,\n\tsetGroupDescription: () => setGroupDescription,\n\tsetGroupName: () => setGroupName\n});\nconst setGroupName = (input) => createAction(\"SET_GROUP_NAME\", { ...input }, void 0, SetGroupNameInputSchema, \"global\");\nconst setGroupDescription = (input) => createAction(\"SET_GROUP_DESCRIPTION\", { ...input }, void 0, SetGroupDescriptionInputSchema, \"global\");\nconst addMember = (input) => createAction(\"ADD_MEMBER\", { ...input }, void 0, AddMemberInputSchema, \"global\");\nconst removeMember = (input) => createAction(\"REMOVE_MEMBER\", { ...input }, void 0, RemoveMemberInputSchema, \"global\");\n//#endregion\n//#region document-models/reactor-group/v1/actions.ts\n/**\n* WARNING: DO NOT EDIT\n* This file is auto-generated and updated by codegen\n*/\n/** Actions for the ReactorGroup document model */\nconst actions = {\n\t...baseActions,\n\t...creators_exports\n};\n//#endregion\n//#region document-models/reactor-group/v1/gen/document-model.ts\nconst documentModel = {\n\tid: \"powerhouse/reactor-group\",\n\tname: \"Reactor Group\",\n\tauthor: {\n\t\tname: \"Powerhouse\",\n\t\twebsite: \"https://powerhouse.inc\"\n\t},\n\textension: \".phrg\",\n\tdescription: \"A group of member addresses referenced by { group } principals in the auth scope. Group membership is folded at an operation's position during auth evaluation, so reducers are strict and deterministic: duplicate or unknown members are errors, and membership is capped.\",\n\tspecifications: [{\n\t\tstate: {\n\t\t\tlocal: {\n\t\t\t\tschema: \"\",\n\t\t\t\texamples: [],\n\t\t\t\tinitialValue: \"\"\n\t\t\t},\n\t\t\tglobal: {\n\t\t\t\tschema: \"\\\"\\\"\\\"\\nA member address list gated by the group document's own auth scope. Addresses\\nare stored as given and compared case-insensitively, matching how { address }\\nprincipals are compared during auth evaluation.\\n\\\"\\\"\\\"\\ntype ReactorGroupState {\\n \\\"\\\"\\\"Display name of the group.\\\"\\\"\\\"\\n name: String!\\n \\\"\\\"\\\"Free-text description of the group's purpose.\\\"\\\"\\\"\\n description: String!\\n \\\"\\\"\\\"Member wallet addresses. No duplicates under case-insensitive comparison.\\\"\\\"\\\"\\n members: [String!]!\\n}\",\n\t\t\t\texamples: [],\n\t\t\t\tinitialValue: \"{\\n \\\"name\\\": \\\"\\\",\\n \\\"description\\\": \\\"\\\",\\n \\\"members\\\": []\\n}\"\n\t\t\t}\n\t\t},\n\t\tmodules: [{\n\t\t\tid: \"efd6d9bb-869e-4565-b1ca-d9b74385eaf7\",\n\t\t\tname: \"group\",\n\t\t\tdescription: \"Manage the group's identity and its member address list.\",\n\t\t\toperations: [\n\t\t\t\t{\n\t\t\t\t\tid: \"43da2b3d-bad7-40b8-8a84-4cdf892f1519\",\n\t\t\t\t\tname: \"SET_GROUP_NAME\",\n\t\t\t\t\tdescription: \"Set the display name of the group. The name must be non-empty after trimming and at most 200 characters.\",\n\t\t\t\t\tschema: \"input SetGroupNameInput {\\n name: String!\\n}\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [{\n\t\t\t\t\t\tid: \"8be0d16c-1f21-4d95-9536-c5a5867d2ba1\",\n\t\t\t\t\t\tcode: \"InvalidGroupName\",\n\t\t\t\t\t\tname: \"InvalidGroupName\",\n\t\t\t\t\t\tdescription: \"The group name is empty after trimming or longer than 200 characters.\",\n\t\t\t\t\t\ttemplate: \"\"\n\t\t\t\t\t}],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"global\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"aa493898-ce6b-4b28-baf3-1b6fd8425138\",\n\t\t\t\t\tname: \"SET_GROUP_DESCRIPTION\",\n\t\t\t\t\tdescription: \"Set the free-text description of the group. The description is at most 2000 characters.\",\n\t\t\t\t\tschema: \"input SetGroupDescriptionInput {\\n description: String!\\n}\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [{\n\t\t\t\t\t\tid: \"9f0f77a4-6a86-4f5c-9a3f-13a44be29de3\",\n\t\t\t\t\t\tcode: \"InvalidGroupDescription\",\n\t\t\t\t\t\tname: \"InvalidGroupDescription\",\n\t\t\t\t\t\tdescription: \"The group description is longer than 2000 characters.\",\n\t\t\t\t\t\ttemplate: \"\"\n\t\t\t\t\t}],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"global\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"e7990be2-2e40-4624-9f96-df759703ba6b\",\n\t\t\t\t\tname: \"ADD_MEMBER\",\n\t\t\t\t\tdescription: \"Add a member address to the group. The address must be non-empty after trimming, must not already be a member under case-insensitive comparison, and the group must be below the member cap.\",\n\t\t\t\t\tschema: \"input AddMemberInput {\\n address: String!\\n}\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: \"3f2504e0-4f89-41d3-9a0c-0305e82c3301\",\n\t\t\t\t\t\t\tcode: \"InvalidMemberAddress\",\n\t\t\t\t\t\t\tname: \"InvalidMemberAddress\",\n\t\t\t\t\t\t\tdescription: \"The member address is empty after trimming.\",\n\t\t\t\t\t\t\ttemplate: \"\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: \"b2c1a9de-58e6-4f3f-9f2a-7f6b1e2d4c5a\",\n\t\t\t\t\t\t\tcode: \"DuplicateMember\",\n\t\t\t\t\t\t\tname: \"DuplicateMember\",\n\t\t\t\t\t\t\tdescription: \"The address is already a member of the group under case-insensitive comparison.\",\n\t\t\t\t\t\t\ttemplate: \"\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: \"c4d5e6f7-0a1b-4c2d-8e3f-9a0b1c2d3e4f\",\n\t\t\t\t\t\t\tcode: \"GroupMemberLimitExceeded\",\n\t\t\t\t\t\t\tname: \"GroupMemberLimitExceeded\",\n\t\t\t\t\t\t\tdescription: \"The group already holds the maximum number of members.\",\n\t\t\t\t\t\t\ttemplate: \"\"\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"global\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"b1309319-48b7-42b2-a40e-1fecef9a09a4\",\n\t\t\t\t\tname: \"REMOVE_MEMBER\",\n\t\t\t\t\tdescription: \"Remove a member address from the group, matched case-insensitively. Removing an address that is not a member is an error.\",\n\t\t\t\t\tschema: \"input RemoveMemberInput {\\n address: String!\\n}\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [{\n\t\t\t\t\t\tid: \"d6e7f8a9-1b2c-4d3e-9f4a-0b1c2d3e4f5a\",\n\t\t\t\t\t\tcode: \"MemberNotFound\",\n\t\t\t\t\t\tname: \"MemberNotFound\",\n\t\t\t\t\t\tdescription: \"The address is not a member of the group under case-insensitive comparison.\",\n\t\t\t\t\t\ttemplate: \"\"\n\t\t\t\t\t}],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"global\"\n\t\t\t\t}\n\t\t\t]\n\t\t}],\n\t\tversion: 1,\n\t\tchangeLog: []\n\t}]\n};\n//#endregion\n//#region document-models/reactor-group/v1/gen/group/error.ts\nvar InvalidGroupName = class extends Error {\n\terrorCode = \"InvalidGroupName\";\n\tconstructor(message = \"InvalidGroupName\") {\n\t\tsuper(message);\n\t}\n};\nvar InvalidGroupDescription = class extends Error {\n\terrorCode = \"InvalidGroupDescription\";\n\tconstructor(message = \"InvalidGroupDescription\") {\n\t\tsuper(message);\n\t}\n};\nvar InvalidMemberAddress = class extends Error {\n\terrorCode = \"InvalidMemberAddress\";\n\tconstructor(message = \"InvalidMemberAddress\") {\n\t\tsuper(message);\n\t}\n};\nvar DuplicateMember = class extends Error {\n\terrorCode = \"DuplicateMember\";\n\tconstructor(message = \"DuplicateMember\") {\n\t\tsuper(message);\n\t}\n};\nvar GroupMemberLimitExceeded = class extends Error {\n\terrorCode = \"GroupMemberLimitExceeded\";\n\tconstructor(message = \"GroupMemberLimitExceeded\") {\n\t\tsuper(message);\n\t}\n};\nvar MemberNotFound = class extends Error {\n\terrorCode = \"MemberNotFound\";\n\tconstructor(message = \"MemberNotFound\") {\n\t\tsuper(message);\n\t}\n};\n//#endregion\n//#region document-models/reactor-group/v1/src/reducers/group.ts\n/** Every replica folds group state during auth evaluation, so membership is capped. */\nconst MAX_GROUP_MEMBERS = 1e3;\nconst MAX_GROUP_DESCRIPTION_LENGTH = 2e3;\n/** Addresses are compared case-insensitively, matching { address } principals. */\nfunction sameAddress(a, b) {\n\treturn a.toLowerCase() === b.toLowerCase();\n}\nconst reactorGroupGroupOperations = {\n\tsetGroupNameOperation(state, action) {\n\t\tconst name = action.input.name.trim();\n\t\tif (name === \"\" || name.length > 200) throw new InvalidGroupName(`Group name must be non-empty and at most 200 characters`);\n\t\tstate.name = name;\n\t},\n\tsetGroupDescriptionOperation(state, action) {\n\t\tconst description = action.input.description;\n\t\tif (description.length > 2e3) throw new InvalidGroupDescription(`Group description must be at most ${MAX_GROUP_DESCRIPTION_LENGTH} characters`);\n\t\tstate.description = description;\n\t},\n\taddMemberOperation(state, action) {\n\t\tconst address = action.input.address.trim();\n\t\tif (address === \"\") throw new InvalidMemberAddress(\"Member address must be non-empty\");\n\t\tif (state.members.some((member) => sameAddress(member, address))) throw new DuplicateMember(`Address is already a member: ${address}`);\n\t\tif (state.members.length >= 1e3) throw new GroupMemberLimitExceeded(`A group holds at most ${MAX_GROUP_MEMBERS} members`);\n\t\tstate.members.push(address);\n\t},\n\tremoveMemberOperation(state, action) {\n\t\tconst address = action.input.address.trim();\n\t\tconst index = state.members.findIndex((member) => sameAddress(member, address));\n\t\tif (index === -1) throw new MemberNotFound(`Address is not a member: ${address}`);\n\t\tstate.members.splice(index, 1);\n\t}\n};\n//#endregion\n//#region document-models/reactor-group/v1/gen/reducer.ts\nconst stateReducer = (state, action, dispatch) => {\n\tif (isDocumentAction(action)) return state;\n\tswitch (action.type) {\n\t\tcase \"SET_GROUP_NAME\":\n\t\t\tSetGroupNameInputSchema().parse(action.input);\n\t\t\treactorGroupGroupOperations.setGroupNameOperation(state[action.scope], action, dispatch);\n\t\t\tbreak;\n\t\tcase \"SET_GROUP_DESCRIPTION\":\n\t\t\tSetGroupDescriptionInputSchema().parse(action.input);\n\t\t\treactorGroupGroupOperations.setGroupDescriptionOperation(state[action.scope], action, dispatch);\n\t\t\tbreak;\n\t\tcase \"ADD_MEMBER\":\n\t\t\tAddMemberInputSchema().parse(action.input);\n\t\t\treactorGroupGroupOperations.addMemberOperation(state[action.scope], action, dispatch);\n\t\t\tbreak;\n\t\tcase \"REMOVE_MEMBER\":\n\t\t\tRemoveMemberInputSchema().parse(action.input);\n\t\t\treactorGroupGroupOperations.removeMemberOperation(state[action.scope], action, dispatch);\n\t\t\tbreak;\n\t\tdefault: return state;\n\t}\n};\nconst reducer = createReducer(stateReducer);\n//#endregion\n//#region document-models/reactor-group/upgrades/versions.ts\nconst supportedVersions = [1];\nconst latestVersion = supportedVersions[0];\n//#endregion\n//#region document-models/reactor-group/upgrades/upgrade-manifest.ts\nconst reactorGroupUpgradeManifest = {\n\tdocumentType: \"powerhouse/reactor-group\",\n\tlatestVersion,\n\tsupportedVersions,\n\tupgrades: {}\n};\n//#endregion\n//#region document-models/reactor-group/v1/gen/document-type.ts\n/**\n* WARNING: DO NOT EDIT\n* This file is auto-generated and updated by codegen\n*/\nconst reactorGroupDocumentType = \"powerhouse/reactor-group\";\n//#endregion\n//#region document-models/reactor-group/v1/gen/document-schema.ts\n/**\n* WARNING: DO NOT EDIT\n* This file is auto-generated and updated by codegen\n*/\n/** Schema for validating the header object of a ReactorGroup document */\nconst ReactorGroupDocumentHeaderSchema = BaseDocumentHeaderSchema.extend({ documentType: z.literal(reactorGroupDocumentType) });\n/** Schema for validating the state object of a ReactorGroup document */\nconst ReactorGroupPHStateSchema = BaseDocumentStateSchema.extend({ global: ReactorGroupStateSchema() });\nconst ReactorGroupDocumentSchema = z.object({\n\theader: ReactorGroupDocumentHeaderSchema,\n\tstate: ReactorGroupPHStateSchema,\n\tinitialState: ReactorGroupPHStateSchema\n});\n/** Simple helper function to check if a state object is a ReactorGroup document state object */\nfunction isReactorGroupState(state) {\n\treturn ReactorGroupPHStateSchema.safeParse(state).success;\n}\n/** Simple helper function to assert that a document state object is a ReactorGroup document state object */\nfunction assertIsReactorGroupState(state) {\n\tReactorGroupPHStateSchema.parse(state);\n}\n/** Simple helper function to check if a document is a ReactorGroup document */\nfunction isReactorGroupDocument(document) {\n\treturn ReactorGroupDocumentSchema.safeParse(document).success;\n}\n/** Simple helper function to assert that a document is a ReactorGroup document */\nfunction assertIsReactorGroupDocument(document) {\n\tReactorGroupDocumentSchema.parse(document);\n}\n//#endregion\n//#region document-models/reactor-group/v1/gen/utils.ts\nconst initialGlobalState = {\n\tname: \"\",\n\tdescription: \"\",\n\tmembers: []\n};\nconst initialLocalState = {};\nconst utils$1 = {\n\tfileExtension: \".phrg\",\n\tcreateState(state) {\n\t\treturn {\n\t\t\t...createBaseState(state?.auth, {\n\t\t\t\tversion: 1,\n\t\t\t\t...state?.document\n\t\t\t}),\n\t\t\tglobal: {\n\t\t\t\t...initialGlobalState,\n\t\t\t\t...state?.global\n\t\t\t},\n\t\t\tlocal: {\n\t\t\t\t...initialLocalState,\n\t\t\t\t...state?.local\n\t\t\t}\n\t\t};\n\t},\n\tcreateDocument(state) {\n\t\treturn baseCreateDocument(utils$1.createState, state, reactorGroupDocumentType);\n\t},\n\tsaveToFileHandle(document, input) {\n\t\treturn baseSaveToFileHandle(document, input);\n\t},\n\tloadFromInput(input) {\n\t\treturn baseLoadFromInputVersioned(input, {\n\t\t\treducers: { 1: reducer },\n\t\t\tupgradeManifest: reactorGroupUpgradeManifest\n\t\t});\n\t},\n\tisStateOfType(state) {\n\t\treturn isReactorGroupState(state);\n\t},\n\tassertIsStateOfType(state) {\n\t\treturn assertIsReactorGroupState(state);\n\t},\n\tisDocumentOfType(document) {\n\t\treturn isReactorGroupDocument(document);\n\t},\n\tassertIsDocumentOfType(document) {\n\t\treturn assertIsReactorGroupDocument(document);\n\t}\n};\n//#endregion\n//#region document-models/reactor-group/v1/src/utils.ts\nvar utils_exports = /* @__PURE__ */ __exportAll({});\n//#endregion\n//#region document-models/reactor-group/v1/utils.ts\n/** Utils for the ReactorGroup document model */\nconst utils = {\n\t...utils$1,\n\t...utils_exports\n};\n//#endregion\n//#region document-models/reactor-group/v1/module.ts\n/** Document model module for the ReactorGroup document type */\nconst ReactorGroup = {\n\tversion: 1,\n\treducer,\n\tactions,\n\tutils,\n\tdocumentModel: createState(defaultBaseState(), documentModel)\n};\n//#endregion\nexport { definedNonNullAnySchema as A, setGroupDescription as C, RemoveMemberInputSchema as D, ReactorGroupStateSchema as E, SetGroupDescriptionInputSchema as O, removeMember as S, AddMemberInputSchema as T, reducer as _, utils$1 as a, addMember as b, ReactorGroupPHStateSchema as c, isReactorGroupDocument as d, isReactorGroupState as f, supportedVersions as g, latestVersion as h, initialLocalState as i, isDefinedNonNullAny as j, SetGroupNameInputSchema as k, assertIsReactorGroupDocument as l, reactorGroupUpgradeManifest as m, utils as n, ReactorGroupDocumentHeaderSchema as o, reactorGroupDocumentType as p, initialGlobalState as r, ReactorGroupDocumentSchema as s, ReactorGroup as t, assertIsReactorGroupState as u, documentModel as v, setGroupName as w, creators_exports as x, actions as y };\n\n//# sourceMappingURL=module-1TFqLbxn.js.map","import { reactorDriveDocumentModelModule } from \"@powerhousedao/reactor-drive\";\nimport { ReactorGroupV1 } from \"@powerhousedao/reactor-group\";\nimport { driveDocumentModelModule } from \"@powerhousedao/shared/document-drive\";\nimport { type DocumentModelModule } from \"@powerhousedao/shared/document-model\";\nimport { documentModelDocumentModelModule } from \"document-model\";\nexport const documentModels: DocumentModelModule<any>[] = [\n documentModelDocumentModelModule,\n driveDocumentModelModule,\n reactorDriveDocumentModelModule,\n ReactorGroupV1 as unknown as DocumentModelModule<any>,\n];\n","export const editors = [];","import type { Manifest } from \"@powerhousedao/shared/document-model\";\nimport manifestJson from \"./powerhouse.manifest.json\" with { type: \"json\" };\nexport { documentModels } from \"./document-models/document-models.js\";\nexport { editors } from \"./editors/editors.js\";\nexport const manifest: Manifest = manifestJson;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACCA,MAAM,8BAA8B;AAEpC,MAAM,+BAA+B;;;ACgBrC,SAAS,mBAAmB,OAAO;CAClC,OAAO;EACN,IAAI,iBAAiB;EACrB,MAAM;EACN,OAAO;EACP,iCAAiC,IAAI,KAAK,EAAA,CAAG,YAAY;EACzD;CACD;AACD;AACA,SAAS,mBAAmB,OAAO;CAClC,OAAO;EACN,IAAI,iBAAiB;EACrB,MAAM;EACN,OAAO;EACP,iCAAiC,IAAI,KAAK,EAAA,CAAG,YAAY;EACzD;CACD;AACD;AACA,SAAS,qBAAqB,OAAO;CACpC,OAAO;EACN,IAAI,iBA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,uBAAqB,UAAU,KAAK;CAC5C;CACA,cAAc,OAAO;EACpB,OAAO,2BAA2B,OAAO;GACxC,UAAU,EAAE,GAAG,QAAQ;GACvB,iBAAiB;EAClB,CAAC;CACF;CACA,cAAc,OAAO;EACpB,OAAO,oBAAoB,KAAK;CACjC;CACA,oBAAoB,OAAO;EAC1B,OAAO,0BAA0B,KAAK;CACvC;CACA,iBAAiB,UAAU;EAC1B,OAAO,uBAAuB,QAAQ;CACvC;CACA,uBAAuB,UAAU;EAChC,OAAO,6BAA6B,QAAQ;CAC7C;AACD;AAGA,IAAI,gBAAgC,4BAAY,CAAC,CAAC;;AAWlD,MAAM,eAAe;CACpB,SAAS;CACT;CACA;CACA;EAVA,GAAG;EACH,GAAG;CASH;CACA,eAAeC,cAAYC,mBAAiB,GAAG,aAAa;AAC7D;;;ACjYA,MAAa,iBAA6C;CACxD;CACA;CACA;CACAC;AACF;;;ACVA,MAAa,UAAU,CAAC;;;ACIxB,MAAa,WAAqBC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["initialGlobalState","initialLocalState","isDocumentAction","createReducer","baseCreateDocument","baseSaveToFileHandle","createState","defaultBaseState","ReactorGroupV1","manifestJson"],"sources":["../../powerhouse.manifest.json","../../../reactor-drive/dist/constants-DfSjC49y.js","../../../reactor-drive/dist/index.js","../../../reactor-group/dist/rolldown-runtime-D7D4PA-g.js","../../../reactor-group/dist/module-1TFqLbxn.js","../../document-models/document-models.ts","../../editors/editors.ts","../../index.ts"],"sourcesContent":["","//#region src/constants.ts\nconst REACTOR_DRIVE_DOCUMENT_TYPE = \"powerhouse/reactor-drive\";\nconst DRIVE_CHILD_RELATIONSHIP_TYPE = \"drive/child\";\nconst REACTOR_DRIVE_FILE_EXTENSION = \"phrd\";\n//#endregion\nexport { REACTOR_DRIVE_DOCUMENT_TYPE as n, REACTOR_DRIVE_FILE_EXTENSION as r, DRIVE_CHILD_RELATIONSHIP_TYPE as t };\n\n//# sourceMappingURL=constants-DfSjC49y.js.map","import { n as REACTOR_DRIVE_DOCUMENT_TYPE, r as REACTOR_DRIVE_FILE_EXTENSION, t as DRIVE_CHILD_RELATIONSHIP_TYPE } from \"./constants-DfSjC49y.js\";\nimport { assertAuthPreservedOnDuplicate, baseCreateDocument, baseLoadFromInput, baseSaveToFileHandle, createCopyHeader, createReducer, createState, createVersionsOf, creationActions, defaultBaseState, generateActionId, generateId, isDenied, isDocumentAction, replayDocumentVersioned } from \"@powerhousedao/shared/document-model\";\nimport { Migrator, sql } from \"kysely\";\nimport { BaseReadModel, REACTOR_SCHEMA, addRelationshipAction, findPurged, isPurgeMarker, mergeConsistencyTokens, removeRelationshipAction, unchunkedReadModelIndexingConfig } from \"@powerhousedao/reactor\";\nimport { getNextCopyNumber } from \"@powerhousedao/shared/document-drive\";\nimport { childLogger } from \"document-model\";\n//#region \\0rolldown/runtime.js\nvar __defProp = Object.defineProperty;\nvar __exportAll = (all, no_symbols) => {\n\tlet target = {};\n\tfor (var name in all) __defProp(target, name, {\n\t\tget: all[name],\n\t\tenumerable: true\n\t});\n\tif (!no_symbols) __defProp(target, Symbol.toStringTag, { value: \"Module\" });\n\treturn target;\n};\n//#endregion\n//#region src/actions.ts\nfunction setDriveNameAction(input) {\n\treturn {\n\t\tid: generateActionId(),\n\t\ttype: \"SET_DRIVE_NAME\",\n\t\tscope: \"global\",\n\t\ttimestampUtcMs: (/* @__PURE__ */ new Date()).toISOString(),\n\t\tinput\n\t};\n}\nfunction setDriveIconAction(input) {\n\treturn {\n\t\tid: generateActionId(),\n\t\ttype: \"SET_DRIVE_ICON\",\n\t\tscope: \"global\",\n\t\ttimestampUtcMs: (/* @__PURE__ */ new Date()).toISOString(),\n\t\tinput\n\t};\n}\nfunction setSharingTypeAction(input) {\n\treturn {\n\t\tid: generateActionId(),\n\t\ttype: \"SET_SHARING_TYPE\",\n\t\tscope: \"local\",\n\t\ttimestampUtcMs: (/* @__PURE__ */ new Date()).toISOString(),\n\t\tinput\n\t};\n}\nfunction setAvailableOfflineAction(input) {\n\treturn {\n\t\tid: generateActionId(),\n\t\ttype: \"SET_AVAILABLE_OFFLINE\",\n\t\tscope: \"local\",\n\t\ttimestampUtcMs: (/* @__PURE__ */ new Date()).toISOString(),\n\t\tinput\n\t};\n}\nfunction addFolderAction(input) {\n\treturn {\n\t\tid: generateActionId(),\n\t\ttype: \"ADD_FOLDER\",\n\t\tscope: \"document\",\n\t\ttimestampUtcMs: (/* @__PURE__ */ new Date()).toISOString(),\n\t\tinput\n\t};\n}\nfunction updateFolderAction(input) {\n\treturn {\n\t\tid: generateActionId(),\n\t\ttype: \"UPDATE_FOLDER\",\n\t\tscope: \"document\",\n\t\ttimestampUtcMs: (/* @__PURE__ */ new Date()).toISOString(),\n\t\tinput\n\t};\n}\nfunction removeFolderAction(input) {\n\treturn {\n\t\tid: generateActionId(),\n\t\ttype: \"REMOVE_FOLDER\",\n\t\tscope: \"document\",\n\t\ttimestampUtcMs: (/* @__PURE__ */ new Date()).toISOString(),\n\t\tinput\n\t};\n}\nconst reactorDriveActions = {\n\tsetDriveName: setDriveNameAction,\n\tsetDriveIcon: setDriveIconAction,\n\tsetSharingType: setSharingTypeAction,\n\tsetAvailableOffline: setAvailableOfflineAction,\n\taddFolder: addFolderAction,\n\tupdateFolder: updateFolderAction,\n\tremoveFolder: removeFolderAction\n};\n//#endregion\n//#region src/reducer/drive.ts\nconst reactorDriveStateReducer = (state, action) => {\n\tif (isDocumentAction(action)) return state;\n\tconst typedAction = action;\n\tswitch (typedAction.type) {\n\t\tcase \"SET_DRIVE_NAME\": {\n\t\t\tconst input = typedAction.input;\n\t\t\tstate.global.name = input.name;\n\t\t\treturn state;\n\t\t}\n\t\tcase \"SET_DRIVE_ICON\": {\n\t\t\tconst input = typedAction.input;\n\t\t\tstate.global.icon = input.icon;\n\t\t\treturn state;\n\t\t}\n\t\tcase \"SET_SHARING_TYPE\": {\n\t\t\tconst input = typedAction.input;\n\t\t\tstate.local.sharingType = input.sharingType;\n\t\t\treturn state;\n\t\t}\n\t\tcase \"SET_AVAILABLE_OFFLINE\": {\n\t\t\tconst input = typedAction.input;\n\t\t\tstate.local.availableOffline = input.availableOffline;\n\t\t\treturn state;\n\t\t}\n\t\tcase \"ADD_FOLDER\":\n\t\tcase \"UPDATE_FOLDER\":\n\t\tcase \"REMOVE_FOLDER\": return state;\n\t\tdefault: return state;\n\t}\n};\n//#endregion\n//#region src/module.ts\nconst initialGlobalState = {\n\tname: \"\",\n\ticon: null\n};\nconst initialLocalState = {\n\tsharingType: \"private\",\n\tavailableOffline: false\n};\nconst reactorDriveCreateState = (state) => {\n\treturn {\n\t\t...defaultBaseState(),\n\t\tglobal: {\n\t\t\t...initialGlobalState,\n\t\t\t...state?.global\n\t\t},\n\t\tlocal: {\n\t\t\t...initialLocalState,\n\t\t\t...state?.local\n\t\t}\n\t};\n};\nconst reactorDriveCreateDocument = (state) => {\n\treturn baseCreateDocument(reactorDriveCreateState, state, REACTOR_DRIVE_DOCUMENT_TYPE);\n};\nconst reactorDriveSaveToFileHandle = (document, input) => {\n\treturn baseSaveToFileHandle(document, input);\n};\nconst reactorDriveLoadFromInput = (input) => {\n\treturn baseLoadFromInput(input, reactorDriveDocumentReducer);\n};\nconst isReactorDriveState = (state) => {\n\treturn typeof state === \"object\" && state !== null && \"global\" in state && \"local\" in state;\n};\nconst assertIsReactorDriveState = (state) => {\n\tif (!isReactorDriveState(state)) throw new Error(\"Not a reactor-drive state\");\n};\nconst isReactorDriveDocument = (document) => {\n\treturn typeof document === \"object\" && document !== null && \"header\" in document && document.header.documentType === \"powerhouse/reactor-drive\";\n};\nconst assertIsReactorDriveDocument = (document) => {\n\tif (!isReactorDriveDocument(document)) throw new Error(\"Not a reactor-drive document\");\n};\nconst reactorDriveDocumentReducer = createReducer(reactorDriveStateReducer);\nconst reactorDriveDocumentGlobalState = {\n\tid: REACTOR_DRIVE_DOCUMENT_TYPE,\n\tname: \"ReactorDrive\",\n\textension: REACTOR_DRIVE_FILE_EXTENSION,\n\tdescription: \"\",\n\tauthor: {\n\t\tname: \"Powerhouse Inc\",\n\t\twebsite: \"https://www.powerhouse.inc/\"\n\t},\n\tspecifications: [{\n\t\tversion: 1,\n\t\tchangeLog: [],\n\t\tstate: {\n\t\t\tglobal: {\n\t\t\t\tschema: \"type ReactorDriveState {\\n name: String!\\n icon: String\\n}\",\n\t\t\t\tinitialValue: JSON.stringify(JSON.stringify(initialGlobalState)),\n\t\t\t\texamples: []\n\t\t\t},\n\t\t\tlocal: {\n\t\t\t\tschema: \"type ReactorDriveLocalState {\\n sharingType: String!\\n availableOffline: Boolean!\\n}\",\n\t\t\t\tinitialValue: JSON.stringify(JSON.stringify(initialLocalState)),\n\t\t\t\texamples: []\n\t\t\t}\n\t\t},\n\t\tmodules: [{\n\t\t\tid: \"reactor-drive/base-operations\",\n\t\t\tname: \"base_operations\",\n\t\t\tdescription: \"\",\n\t\t\toperations: [\n\t\t\t\t{\n\t\t\t\t\tid: \"SET_DRIVE_NAME\",\n\t\t\t\t\tname: \"SET_DRIVE_NAME\",\n\t\t\t\t\tdescription: \"\",\n\t\t\t\t\tschema: \"input SetDriveNameInput { name: String! }\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"global\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"SET_DRIVE_ICON\",\n\t\t\t\t\tname: \"SET_DRIVE_ICON\",\n\t\t\t\t\tdescription: \"\",\n\t\t\t\t\tschema: \"input SetDriveIconInput { icon: String }\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"global\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"SET_SHARING_TYPE\",\n\t\t\t\t\tname: \"SET_SHARING_TYPE\",\n\t\t\t\t\tdescription: \"\",\n\t\t\t\t\tschema: \"input SetSharingTypeInput { sharingType: String! }\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"local\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"SET_AVAILABLE_OFFLINE\",\n\t\t\t\t\tname: \"SET_AVAILABLE_OFFLINE\",\n\t\t\t\t\tdescription: \"\",\n\t\t\t\t\tschema: \"input SetAvailableOfflineInput { availableOffline: Boolean! }\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"local\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"ADD_FOLDER\",\n\t\t\t\t\tname: \"ADD_FOLDER\",\n\t\t\t\t\tdescription: \"\",\n\t\t\t\t\tschema: \"input AddFolderInput { folderId: String! parentFolderId: String name: String! }\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"document\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"UPDATE_FOLDER\",\n\t\t\t\t\tname: \"UPDATE_FOLDER\",\n\t\t\t\t\tdescription: \"\",\n\t\t\t\t\tschema: \"input UpdateFolderInput { folderId: String! name: String parentFolderId: String }\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"document\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"REMOVE_FOLDER\",\n\t\t\t\t\tname: \"REMOVE_FOLDER\",\n\t\t\t\t\tdescription: \"\",\n\t\t\t\t\tschema: \"input RemoveFolderInput { folderId: String! }\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"document\"\n\t\t\t\t}\n\t\t\t]\n\t\t}]\n\t}]\n};\nconst reactorDriveDocumentModelModule = {\n\tactions: reactorDriveActions,\n\treducer: reactorDriveDocumentReducer,\n\tdocumentModel: createState(defaultBaseState(), reactorDriveDocumentGlobalState),\n\tutils: {\n\t\tfileExtension: REACTOR_DRIVE_FILE_EXTENSION,\n\t\tcreateState: reactorDriveCreateState,\n\t\tcreateDocument: reactorDriveCreateDocument,\n\t\tloadFromInput: reactorDriveLoadFromInput,\n\t\tsaveToFileHandle: reactorDriveSaveToFileHandle,\n\t\tisStateOfType: isReactorDriveState,\n\t\tassertIsStateOfType: assertIsReactorDriveState,\n\t\tisDocumentOfType: isReactorDriveDocument,\n\t\tassertIsDocumentOfType: assertIsReactorDriveDocument\n\t}\n};\n//#endregion\n//#region src/schema/migrations/0001_drive_node.ts\nvar _0001_drive_node_exports = /* @__PURE__ */ __exportAll({\n\tdown: () => down$4,\n\tup: () => up$4\n});\nasync function up$4(db) {\n\tawait db.schema.createTable(\"DriveNode\").ifNotExists().addColumn(\"driveId\", \"text\", (col) => col.notNull()).addColumn(\"id\", \"text\", (col) => col.notNull()).addColumn(\"kind\", \"text\", (col) => col.notNull()).addColumn(\"name\", \"text\", (col) => col.notNull()).addColumn(\"requestedName\", \"text\", (col) => col.notNull()).addColumn(\"parentFolder\", \"text\").addColumn(\"documentType\", \"text\").addColumn(\"createdAt\", \"timestamptz\", (col) => col.notNull().defaultTo(sql`NOW()`)).addColumn(\"updatedAt\", \"timestamptz\", (col) => col.notNull().defaultTo(sql`NOW()`)).addPrimaryKeyConstraint(\"pk_drive_node\", [\"driveId\", \"id\"]).addCheckConstraint(\"chk_drive_node_document_type\", sql`(kind = 'file' AND \"documentType\" IS NOT NULL) OR (kind = 'folder' AND \"documentType\" IS NULL)`).execute();\n\tawait db.schema.createIndex(\"idx_drive_node_parent_name\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"parentFolder\",\n\t\t\"name\"\n\t]).execute();\n\tawait db.schema.createIndex(\"idx_drive_node_parent_kind_id\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"parentFolder\",\n\t\t\"kind\",\n\t\t\"id\"\n\t]).execute();\n}\nasync function down$4(db) {\n\tawait db.schema.dropTable(\"DriveNode\").execute();\n}\n//#endregion\n//#region src/schema/migrations/0002_document_name.ts\nvar _0002_document_name_exports = /* @__PURE__ */ __exportAll({\n\tdown: () => down$3,\n\tup: () => up$3\n});\nasync function up$3(db) {\n\tawait db.schema.createTable(\"DocumentName\").ifNotExists().addColumn(\"docId\", \"text\", (col) => col.primaryKey()).addColumn(\"name\", \"text\", (col) => col.notNull()).addColumn(\"updatedAt\", \"timestamptz\", (col) => col.notNull().defaultTo(sql`NOW()`)).execute();\n}\nasync function down$3(db) {\n\tawait db.schema.dropTable(\"DocumentName\").execute();\n}\n//#endregion\n//#region src/schema/migrations/0003_drive_node_listing_indexes.ts\nvar _0003_drive_node_listing_indexes_exports = /* @__PURE__ */ __exportAll({\n\tdown: () => down$2,\n\tup: () => up$2\n});\nconst LISTING_INDEXES = [\n\t\"idx_drive_node_parent_created_id\",\n\t\"idx_drive_node_parent_kind_created_id\",\n\t\"idx_drive_node_root_created_id\",\n\t\"idx_drive_node_root_kind_created_id\",\n\t\"idx_drive_node_created_id\"\n];\nasync function up$2(db) {\n\tawait db.schema.createIndex(\"idx_drive_node_parent_created_id\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"parentFolder\",\n\t\t\"createdAt\",\n\t\t\"id\"\n\t]).execute();\n\tawait db.schema.createIndex(\"idx_drive_node_parent_kind_created_id\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"parentFolder\",\n\t\t\"kind\",\n\t\t\"createdAt\",\n\t\t\"id\"\n\t]).execute();\n\tawait db.schema.createIndex(\"idx_drive_node_root_created_id\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"createdAt\",\n\t\t\"id\"\n\t]).where(sql.ref(\"parentFolder\"), \"is\", null).execute();\n\tawait db.schema.createIndex(\"idx_drive_node_root_kind_created_id\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"kind\",\n\t\t\"createdAt\",\n\t\t\"id\"\n\t]).where(sql.ref(\"parentFolder\"), \"is\", null).execute();\n\tawait db.schema.createIndex(\"idx_drive_node_created_id\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"createdAt\",\n\t\t\"id\"\n\t]).execute();\n\tawait db.schema.dropIndex(\"idx_drive_node_parent_kind_id\").ifExists().execute();\n}\nasync function down$2(db) {\n\tawait db.schema.createIndex(\"idx_drive_node_parent_kind_id\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"parentFolder\",\n\t\t\"kind\",\n\t\t\"id\"\n\t]).execute();\n\tfor (const name of LISTING_INDEXES) await db.schema.dropIndex(name).ifExists().execute();\n}\n//#endregion\n//#region src/schema/migrations/0004_drop_drive_node_parent_name.ts\nvar _0004_drop_drive_node_parent_name_exports = /* @__PURE__ */ __exportAll({\n\tdown: () => down$1,\n\tup: () => up$1\n});\nasync function up$1(db) {\n\tawait db.schema.dropIndex(\"idx_drive_node_parent_name\").ifExists().execute();\n}\nasync function down$1(db) {\n\tawait db.schema.createIndex(\"idx_drive_node_parent_name\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"parentFolder\",\n\t\t\"name\"\n\t]).execute();\n}\n//#endregion\n//#region src/schema/migrations/0005_drive_node_sibling_name_index.ts\nvar _0005_drive_node_sibling_name_index_exports = /* @__PURE__ */ __exportAll({\n\tdown: () => down,\n\tup: () => up\n});\n/**\n* Sibling-name resolution checks candidate names one at a time instead of\n* loading every sibling, so (driveId, parentFolder, name) is a filter again.\n*/\nasync function up(db) {\n\tawait db.schema.createIndex(\"idx_drive_node_parent_name\").ifNotExists().on(\"DriveNode\").columns([\n\t\t\"driveId\",\n\t\t\"parentFolder\",\n\t\t\"name\"\n\t]).execute();\n}\nasync function down(db) {\n\tawait db.schema.dropIndex(\"idx_drive_node_parent_name\").ifExists().execute();\n}\n//#endregion\n//#region src/schema/migrations/migrator.ts\nconst migrations = {\n\t\"0001_drive_node\": _0001_drive_node_exports,\n\t\"0002_document_name\": _0002_document_name_exports,\n\t\"0003_drive_node_listing_indexes\": _0003_drive_node_listing_indexes_exports,\n\t\"0004_drop_drive_node_parent_name\": _0004_drop_drive_node_parent_name_exports,\n\t\"0005_drive_node_sibling_name_index\": _0005_drive_node_sibling_name_index_exports\n};\nconst REACTOR_DRIVE_MIGRATION_TABLE = \"kysely_migration_reactor_drive\";\nconst REACTOR_DRIVE_MIGRATION_LOCK_TABLE = \"kysely_migration_reactor_drive_lock\";\nvar ProgrammaticMigrationProvider = class {\n\tgetMigrations() {\n\t\treturn Promise.resolve(migrations);\n\t}\n};\n/** Migrates to the latest, or up or down to `upTo` when given. */\nasync function runReactorDriveMigrations(db, schema, upTo) {\n\ttry {\n\t\tawait sql`CREATE SCHEMA IF NOT EXISTS ${sql.id(schema)}`.execute(db);\n\t} catch (error) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tmigrationsExecuted: [],\n\t\t\terror: error instanceof Error ? error : /* @__PURE__ */ new Error(\"Failed to create schema\")\n\t\t};\n\t}\n\tconst migrator = new Migrator({\n\t\tdb: db.withSchema(schema),\n\t\tprovider: new ProgrammaticMigrationProvider(),\n\t\tmigrationTableSchema: schema,\n\t\tmigrationTableName: REACTOR_DRIVE_MIGRATION_TABLE,\n\t\tmigrationLockTableName: REACTOR_DRIVE_MIGRATION_LOCK_TABLE\n\t});\n\tlet error;\n\tlet results;\n\ttry {\n\t\tconst result = upTo ? await migrator.migrateTo(upTo) : await migrator.migrateToLatest();\n\t\terror = result.error;\n\t\tresults = result.results;\n\t} catch (e) {\n\t\terror = e;\n\t\tresults = [];\n\t}\n\tconst migrationsExecuted = results?.map((result) => result.migrationName) ?? [];\n\tif (error) return {\n\t\tsuccess: false,\n\t\tmigrationsExecuted,\n\t\terror: error instanceof Error ? error : /* @__PURE__ */ new Error(\"Unknown migration error\")\n\t};\n\treturn {\n\t\tsuccess: true,\n\t\tmigrationsExecuted\n\t};\n}\nasync function getReactorDriveMigrationStatus(db, schema) {\n\treturn await new Migrator({\n\t\tdb: db.withSchema(schema),\n\t\tprovider: new ProgrammaticMigrationProvider(),\n\t\tmigrationTableSchema: schema,\n\t\tmigrationTableName: REACTOR_DRIVE_MIGRATION_TABLE,\n\t\tmigrationLockTableName: REACTOR_DRIVE_MIGRATION_LOCK_TABLE\n\t}).getMigrations();\n}\n//#endregion\n//#region src/processors/utils/collisions.ts\n/**\n* Deterministic per-folder name collision rule. Given a desired name and the\n* set of names already taken by siblings, returns the next available name as\n* `requested`, `requested (2)`, `requested (3)`, etc.\n*\n* The rule matches the legacy document-drive module so that migration from\n* the legacy state produces stable suffixes.\n*/\nfunction resolveCollision(requested, takenNames) {\n\tconst taken = /* @__PURE__ */ new Set();\n\tfor (const name of takenNames) taken.add(name);\n\tif (!taken.has(requested)) return requested;\n\tlet suffix = 2;\n\twhile (taken.has(`${requested} (${suffix})`)) suffix += 1;\n\treturn `${requested} (${suffix})`;\n}\n//#endregion\n//#region src/processors/node-processor.ts\nconst LEGACY_DRIVE_DOCUMENT_TYPE = \"powerhouse/document-drive\";\nconst NAME_ACTION_TYPES = /* @__PURE__ */ new Set([\n\t\"CREATE_DOCUMENT\",\n\t\"UPGRADE_DOCUMENT\",\n\t\"SET_NAME\"\n]);\nconst STRUCTURE_ACTION_TYPES = /* @__PURE__ */ new Set([\n\t\"ADD_RELATIONSHIP\",\n\t\"REMOVE_RELATIONSHIP\",\n\t\"ADD_FOLDER\",\n\t\"UPDATE_FOLDER\",\n\t\"REMOVE_FOLDER\"\n]);\nconst LEGACY_NODE_ACTION_TYPES = /* @__PURE__ */ new Set([\n\t\"ADD_FILE\",\n\t\"ADD_FOLDER\",\n\t\"UPDATE_FILE\",\n\t\"UPDATE_NODE\",\n\t\"MOVE_NODE\",\n\t\"COPY_NODE\",\n\t\"DELETE_NODE\"\n]);\n/** Candidates the indexed sibling check tries before scanning the folder. */\nconst SIBLING_NAME_CANDIDATES = 50;\nconst BACKFILL_BATCH_SIZE = 500;\n/**\n* Projects drive structure operations into the DriveNode tree.\n*\n* Reactor-drive rows get the per-folder collision rule. Legacy\n* `powerhouse/document-drive` rows mirror the legacy node reducer, including\n* its own `(copy) N` collision rule, so the rows equal the drive's state.\n*\n* Indexes a batch unchunked: a single job may carry one action per descendant\n* of a copied subtree, and a partially committed copy is a half-built tree that\n* readers can see. Chunked commits would only be repaired at the next init(),\n* so the whole batch commits or none of it does.\n*/\nvar NodeProcessor = class extends BaseReadModel {\n\tstatic commitsInFenceTransaction = true;\n\tdriveDb;\n\tbaseDb;\n\tschema;\n\treactorSchema;\n\tlogger = childLogger([\"reactor-drive\", \"node-processor\"]);\n\tconstructor(baseDb, schema, operationIndex, writeCache, consistencyTracker, reactorSchema = REACTOR_SCHEMA) {\n\t\tconst scopedDb = baseDb.withSchema(schema);\n\t\tsuper(scopedDb, operationIndex, writeCache, consistencyTracker, {\n\t\t\treadModelId: \"reactor-drive-node-processor\",\n\t\t\trebuildStateOnInit: false,\n\t\t\tindexing: unchunkedReadModelIndexingConfig,\n\t\t\tpurgeFence: \"locked\"\n\t\t});\n\t\tthis.driveDb = scopedDb;\n\t\tthis.baseDb = baseDb;\n\t\tthis.schema = schema;\n\t\tthis.reactorSchema = reactorSchema;\n\t}\n\tpurgeLookup(db) {\n\t\treturn db.withSchema(this.reactorSchema);\n\t}\n\tasync init() {\n\t\tconst result = await runReactorDriveMigrations(this.baseDb, this.schema);\n\t\tif (!result.success && result.error) throw new Error(`Reactor drive migrations failed: ${result.error.message}`);\n\t\tawait this.backfillLegacyDrives();\n\t\tawait super.init();\n\t}\n\tasync commitOperations(items, fenceTrx) {\n\t\tif (fenceTrx) {\n\t\t\tawait this.applyAll(items, fenceTrx);\n\t\t\treturn;\n\t\t}\n\t\tif (!this.writesRows(items)) return;\n\t\tawait this.driveDb.transaction().execute((trx) => this.applyAll(items, trx));\n\t}\n\twritesRows(items) {\n\t\treturn items.some((item) => {\n\t\t\tconst actionType = item.operation.action.type;\n\t\t\treturn NAME_ACTION_TYPES.has(actionType) || STRUCTURE_ACTION_TYPES.has(actionType) || LEGACY_NODE_ACTION_TYPES.has(actionType) || actionType === \"DELETE_DOCUMENT\" || isPurgeMarker(item.operation);\n\t\t});\n\t}\n\t/**\n\t* Seeds rows for every live legacy drive that has none, from its global\n\t* snapshot. One transaction per drive; re-running skips drives with rows.\n\t*\n\t* Only a snapshot at or behind the resume cursor is seeded: catch-up\n\t* replays every operation past the cursor, and replaying operations the\n\t* snapshot already holds over its rows would rename and duplicate nodes.\n\t*/\n\tasync backfillLegacyDrives() {\n\t\tconst resumeFrom = await this.loadState() ?? 0;\n\t\tconst drives = await this.purgeLookup(this.baseDb).selectFrom(\"DocumentSnapshot\").select([\"documentId\", \"lastOperationOrdinal\"]).where(\"documentType\", \"=\", LEGACY_DRIVE_DOCUMENT_TYPE).where(\"scope\", \"=\", \"global\").where(\"branch\", \"=\", \"main\").where(\"isDeleted\", \"=\", false).execute();\n\t\tfor (const { documentId: driveId, lastOperationOrdinal } of drives) {\n\t\t\tif (lastOperationOrdinal > resumeFrom) {\n\t\t\t\tif (!await this.driveDb.selectFrom(\"DriveNode\").select(\"id\").where(\"driveId\", \"=\", driveId).limit(1).executeTakeFirst()) this.logger.info(\"legacy drive @driveId snapshot at ordinal @snapshot is past cursor @cursor; replay will build it\", driveId, lastOperationOrdinal, resumeFrom);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst count = await this.driveDb.transaction().execute((trx) => this.backfillLegacyDrive(trx, driveId));\n\t\t\tif (count > 0) this.logger.info(\"backfilled legacy drive @driveId with @count nodes\", driveId, count);\n\t\t}\n\t}\n\tasync backfillLegacyDrive(trx, driveId) {\n\t\tif (await trx.selectFrom(\"DriveNode\").select(\"id\").where(\"driveId\", \"=\", driveId).limit(1).executeTakeFirst()) return 0;\n\t\tconst rows = legacySnapshotRows(driveId, (await this.purgeLookup(trx).selectFrom(\"DocumentSnapshot\").select(\"content\").where(\"documentId\", \"=\", driveId).where(\"scope\", \"=\", \"global\").where(\"branch\", \"=\", \"main\").executeTakeFirst())?.content);\n\t\tfor (let i = 0; i < rows.length; i += BACKFILL_BATCH_SIZE) await trx.insertInto(\"DriveNode\").values(rows.slice(i, i + BACKFILL_BATCH_SIZE)).onConflict((oc) => oc.columns([\"driveId\", \"id\"]).doNothing()).execute();\n\t\treturn rows.length;\n\t}\n\tasync applyAll(items, trx) {\n\t\tconst purgedTargets = await this.findPurgedTargets(trx, items);\n\t\tfor (const item of items) {\n\t\t\tconst actionType = item.operation.action.type;\n\t\t\tconst legacyRule = this.legacyShapeRule(item);\n\t\t\tif (legacyRule) {\n\t\t\t\tif (item.operation.error || isDenied(item.operation)) continue;\n\t\t\t\tawait this.applyLegacyNodeOperation(trx, item, legacyRule);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (isPurgeMarker(item.operation)) {\n\t\t\t\tconst input = item.operation.action.input;\n\t\t\t\tawait this.eraseDocument(trx, input.documentId || item.context.documentId);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (NAME_ACTION_TYPES.has(actionType)) {\n\t\t\t\tawait this.applyNameOperation(trx, item);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (STRUCTURE_ACTION_TYPES.has(actionType)) {\n\t\t\t\tif (this.namesPurgedTarget(item, purgedTargets)) continue;\n\t\t\t\tawait this.applyStructureOperation(trx, item);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (actionType === \"DELETE_DOCUMENT\") await this.applyDeleteDocument(trx, item);\n\t\t}\n\t}\n\t/** Tombstoned targets of this batch's drive-child ADD_RELATIONSHIPs. */\n\tasync findPurgedTargets(trx, items) {\n\t\tconst targets = [];\n\t\tfor (const item of items) {\n\t\t\tconst target = this.addedChildOf(item);\n\t\t\tif (target !== void 0) targets.push(target);\n\t\t}\n\t\treturn findPurged(this.purgeLookup(trx), targets);\n\t}\n\tnamesPurgedTarget(item, purgedTargets) {\n\t\tconst target = this.addedChildOf(item);\n\t\treturn target !== void 0 && purgedTargets.has(target);\n\t}\n\taddedChildOf(item) {\n\t\tconst action = item.operation.action;\n\t\tif (action.type !== \"ADD_RELATIONSHIP\") return void 0;\n\t\tif (item.context.documentType !== \"powerhouse/reactor-drive\") return;\n\t\tconst input = action.input;\n\t\tif (input.relationshipType !== \"drive/child\") return;\n\t\treturn input.targetId;\n\t}\n\tasync applyNameOperation(trx, item) {\n\t\tconst action = item.operation.action;\n\t\tconst docId = item.context.documentId;\n\t\tlet name;\n\t\tif (action.type === \"CREATE_DOCUMENT\") name = action.input.name;\n\t\telse if (action.type === \"UPGRADE_DOCUMENT\") name = (action.input.initialState ?? {}).header?.name;\n\t\telse if (action.type === \"SET_NAME\") name = action.input.name;\n\t\tif (name === void 0) return;\n\t\tawait this.upsertDocumentName(trx, docId, name);\n\t\tconst linkedRows = await trx.selectFrom(\"DriveNode\").selectAll().where(\"id\", \"=\", docId).where(\"kind\", \"=\", \"file\").execute();\n\t\tconst legacyDrives = await this.legacyDrivesAmong(trx, linkedRows.map((row) => row.driveId));\n\t\tfor (const row of linkedRows) {\n\t\t\tif (legacyDrives.has(row.driveId)) continue;\n\t\t\tconst resolved = await this.resolveSiblingName(trx, row.driveId, row.parentFolder, name, docId);\n\t\t\tawait trx.updateTable(\"DriveNode\").set({\n\t\t\t\tname: resolved,\n\t\t\t\trequestedName: name,\n\t\t\t\tupdatedAt: /* @__PURE__ */ new Date()\n\t\t\t}).where(\"driveId\", \"=\", row.driveId).where(\"id\", \"=\", docId).execute();\n\t\t}\n\t}\n\tasync applyStructureOperation(trx, item) {\n\t\tif (item.context.documentType !== \"powerhouse/reactor-drive\") return;\n\t\tconst action = item.operation.action;\n\t\tconst driveId = item.context.documentId;\n\t\tif (action.type === \"ADD_RELATIONSHIP\") {\n\t\t\tconst input = action.input;\n\t\t\tif (input.relationshipType !== \"drive/child\") return;\n\t\t\tawait this.handleAddFileRelationship(trx, driveId, input);\n\t\t\treturn;\n\t\t}\n\t\tif (action.type === \"REMOVE_RELATIONSHIP\") {\n\t\t\tconst input = action.input;\n\t\t\tif (input.relationshipType !== \"drive/child\") return;\n\t\t\tawait trx.deleteFrom(\"DriveNode\").where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", input.targetId).execute();\n\t\t\treturn;\n\t\t}\n\t\tif (action.type === \"ADD_FOLDER\") {\n\t\t\tawait this.handleAddFolder(trx, driveId, action.input);\n\t\t\treturn;\n\t\t}\n\t\tif (action.type === \"UPDATE_FOLDER\") {\n\t\t\tconst input = action.input;\n\t\t\tif (!isNonEmptyString(input.folderId)) return;\n\t\t\tawait this.handleUpdateFolder(trx, driveId, input);\n\t\t\treturn;\n\t\t}\n\t\tif (action.type === \"REMOVE_FOLDER\") {\n\t\t\tconst input = action.input;\n\t\t\tif (!isNonEmptyString(input.folderId)) return;\n\t\t\tawait trx.deleteFrom(\"DriveNode\").where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", input.folderId).execute();\n\t\t}\n\t}\n\t/**\n\t* The collision rule for an operation in the legacy node shape: a\n\t* document-drive's own, or a reactor-drive's for a legacy-shaped write\n\t* against one. Undefined for every other operation.\n\t*/\n\tlegacyShapeRule(item) {\n\t\tconst action = item.operation.action;\n\t\tif (!LEGACY_NODE_ACTION_TYPES.has(action.type)) return void 0;\n\t\tif (item.context.documentType === \"powerhouse/document-drive\") return \"legacy\";\n\t\tif (item.context.documentType !== \"powerhouse/reactor-drive\") return;\n\t\tif (action.type === \"ADD_FOLDER\") {\n\t\t\tconst input = action.input;\n\t\t\tif (isNonEmptyString(input?.folderId)) return void 0;\n\t\t}\n\t\treturn \"reactor\";\n\t}\n\t/**\n\t* Mirrors the legacy node reducer (document-drive src/reducers/node.ts).\n\t* An add without a usable id is skipped with a warning: a read model never\n\t* stops on an operation's shape.\n\t*/\n\tasync applyLegacyNodeOperation(trx, item, rule) {\n\t\tconst action = item.operation.action;\n\t\tconst driveId = item.context.documentId;\n\t\tswitch (action.type) {\n\t\t\tcase \"ADD_FILE\": {\n\t\t\t\tconst input = action.input;\n\t\t\t\tif (!isNonEmptyString(input.id) || !isNonEmptyString(input.documentType)) {\n\t\t\t\t\tthis.warnSkipped(item, \"no usable id or documentType\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tawait this.upsertLegacyNode(trx, driveId, rule, {\n\t\t\t\t\tid: input.id,\n\t\t\t\t\tkind: \"file\",\n\t\t\t\t\tsrcName: input.name ?? \"\",\n\t\t\t\t\tcollisionFolder: input.parentFolder || null,\n\t\t\t\t\tparentFolder: input.parentFolder ?? null,\n\t\t\t\t\tdocumentType: input.documentType\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"ADD_FOLDER\": {\n\t\t\t\tconst input = action.input;\n\t\t\t\tif (!isNonEmptyString(input.id)) {\n\t\t\t\t\tthis.warnSkipped(item, \"no usable id\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tawait this.upsertLegacyNode(trx, driveId, rule, {\n\t\t\t\t\tid: input.id,\n\t\t\t\t\tkind: \"folder\",\n\t\t\t\t\tsrcName: input.name ?? \"\",\n\t\t\t\t\tcollisionFolder: input.parentFolder || null,\n\t\t\t\t\tparentFolder: input.parentFolder ?? null,\n\t\t\t\t\tdocumentType: null\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"UPDATE_FILE\":\n\t\t\tcase \"UPDATE_NODE\": {\n\t\t\t\tconst input = action.input;\n\t\t\t\tif (!isNonEmptyString(input.id)) return;\n\t\t\t\tawait this.updateLegacyNode(trx, driveId, rule, action.type, input);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"MOVE_NODE\": {\n\t\t\t\tconst input = action.input;\n\t\t\t\tif (!isNonEmptyString(input.srcFolder)) return;\n\t\t\t\tawait this.moveLegacyNode(trx, driveId, rule, input);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"COPY_NODE\": {\n\t\t\t\tconst input = action.input;\n\t\t\t\tif (!isNonEmptyString(input.srcId)) return;\n\t\t\t\tif (!isNonEmptyString(input.targetId)) {\n\t\t\t\t\tthis.warnSkipped(item, \"no usable targetId\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst src = await this.findNode(trx, driveId, input.srcId);\n\t\t\t\tif (!src) return;\n\t\t\t\tawait this.upsertLegacyNode(trx, driveId, rule, {\n\t\t\t\t\tid: input.targetId,\n\t\t\t\t\tkind: src.kind,\n\t\t\t\t\tsrcName: input.targetName || (rule === \"legacy\" ? src.name : src.requestedName),\n\t\t\t\t\tcollisionFolder: input.targetParentFolder || null,\n\t\t\t\t\tparentFolder: input.targetParentFolder || null,\n\t\t\t\t\tdocumentType: src.documentType\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"DELETE_NODE\": {\n\t\t\t\tconst input = action.input;\n\t\t\t\tif (!isNonEmptyString(input.id)) return;\n\t\t\t\tconst ids = await this.subtreeIds(trx, driveId, input.id);\n\t\t\t\tif (ids.length === 0) return;\n\t\t\t\tawait trx.deleteFrom(\"DriveNode\").where(\"driveId\", \"=\", driveId).where(\"id\", \"in\", ids).execute();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t* ADD_FILE, ADD_FOLDER and COPY_NODE. The reducer rejects an existing id, so\n\t* the node itself is left out of the collision check and a replay over the\n\t* same row is an upsert to the same values.\n\t*/\n\tasync upsertLegacyNode(trx, driveId, rule, node) {\n\t\tconst { name, requestedName } = await this.nodeName(trx, rule, {\n\t\t\tdriveId,\n\t\t\tfolder: rule === \"legacy\" ? node.collisionFolder : node.parentFolder,\n\t\t\tsrcName: node.srcName,\n\t\t\tkind: node.kind,\n\t\t\texcludeId: node.id\n\t\t});\n\t\tconst values = {\n\t\t\tkind: node.kind,\n\t\t\tname,\n\t\t\trequestedName,\n\t\t\tparentFolder: node.parentFolder,\n\t\t\tdocumentType: node.kind === \"file\" ? node.documentType : null\n\t\t};\n\t\tawait trx.insertInto(\"DriveNode\").values({\n\t\t\tdriveId,\n\t\t\tid: node.id,\n\t\t\t...values\n\t\t}).onConflict((oc) => oc.columns([\"driveId\", \"id\"]).doUpdateSet({\n\t\t\t...values,\n\t\t\tupdatedAt: /* @__PURE__ */ new Date()\n\t\t})).execute();\n\t}\n\t/**\n\t* UPDATE_FILE never moves the node (its parentFolder only picks the folder\n\t* for the collision check); UPDATE_NODE moves it only to the root, on null.\n\t*/\n\tasync updateLegacyNode(trx, driveId, rule, actionType, input) {\n\t\tconst row = await this.findNode(trx, driveId, input.id);\n\t\tif (!row) return;\n\t\tconst nextParentFolder = actionType === \"UPDATE_NODE\" && input.parentFolder === null ? null : row.parentFolder;\n\t\tconst { name, requestedName } = await this.nodeName(trx, rule, {\n\t\t\tdriveId,\n\t\t\tfolder: rule === \"legacy\" ? input.parentFolder ?? row.parentFolder : nextParentFolder,\n\t\t\tsrcName: input.name ?? (rule === \"legacy\" ? row.name : row.requestedName),\n\t\t\tkind: actionType === \"UPDATE_FILE\" ? \"file\" : row.kind,\n\t\t\texcludeId: input.id\n\t\t});\n\t\tif (actionType === \"UPDATE_FILE\") {\n\t\t\tconst documentType = input.documentType;\n\t\t\tawait trx.updateTable(\"DriveNode\").set({\n\t\t\t\tname,\n\t\t\t\trequestedName,\n\t\t\t\tdocumentType: row.kind === \"file\" ? documentType ?? row.documentType : null,\n\t\t\t\tupdatedAt: /* @__PURE__ */ new Date()\n\t\t\t}).where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", input.id).execute();\n\t\t\treturn;\n\t\t}\n\t\tawait trx.updateTable(\"DriveNode\").set({\n\t\t\tname,\n\t\t\trequestedName,\n\t\t\tparentFolder: nextParentFolder,\n\t\t\tupdatedAt: /* @__PURE__ */ new Date()\n\t\t}).where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", input.id).execute();\n\t}\n\tasync moveLegacyNode(trx, driveId, rule, input) {\n\t\tif (input.srcFolder === input.targetParentFolder) return;\n\t\tconst row = await this.findNode(trx, driveId, input.srcFolder);\n\t\tif (!row) return;\n\t\tconst target = input.targetParentFolder || null;\n\t\tif (row.kind === \"folder\" && target !== null) {\n\t\t\tif ((await this.subtreeIds(trx, driveId, row.id)).includes(target)) return;\n\t\t}\n\t\tconst { name, requestedName } = await this.nodeName(trx, rule, {\n\t\t\tdriveId,\n\t\t\tfolder: target,\n\t\t\tsrcName: rule === \"legacy\" ? row.name : row.requestedName,\n\t\t\tkind: row.kind,\n\t\t\texcludeId: rule === \"legacy\" ? null : row.id\n\t\t});\n\t\tawait trx.updateTable(\"DriveNode\").set({\n\t\t\tname,\n\t\t\trequestedName,\n\t\t\tparentFolder: target,\n\t\t\tupdatedAt: /* @__PURE__ */ new Date()\n\t\t}).where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", row.id).execute();\n\t}\n\t/**\n\t* A legacy row's name is whatever the legacy reducer would produce, and is\n\t* also its requested name; a reactor-drive row keeps the requested name and\n\t* resolves the displayed one with the reactor-drive rule.\n\t*/\n\tasync nodeName(trx, rule, target) {\n\t\tif (rule === \"legacy\") {\n\t\t\tconst name = await this.legacySiblingName(trx, target.driveId, target.folder, target.srcName, target.kind, target.excludeId);\n\t\t\treturn {\n\t\t\t\tname,\n\t\t\t\trequestedName: name\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tname: await this.resolveSiblingName(trx, target.driveId, target.folder, target.srcName, target.excludeId ?? \"\"),\n\t\t\trequestedName: target.srcName\n\t\t};\n\t}\n\twarnSkipped(item, reason) {\n\t\tthis.logger.warn(\"skipped @actionType on drive @driveId at ordinal @ordinal (index @index): @reason\", item.operation.action.type, item.context.documentId, item.context.ordinal, item.operation.index, reason);\n\t}\n\t/**\n\t* The legacy handleTargetNameCollisions: a same-kind sibling with the name\n\t* gives `name (copy) N`, N one past the highest existing copy number.\n\t*/\n\tasync legacySiblingName(trx, driveId, targetFolder, srcName, kind, excludeId) {\n\t\tconst folder = targetFolder === \"\" ? null : targetFolder;\n\t\tlet siblings = trx.selectFrom(\"DriveNode\").select(\"name\").where(\"driveId\", \"=\", driveId).where(\"kind\", \"=\", kind);\n\t\tsiblings = folder === null ? siblings.where(\"parentFolder\", \"is\", null) : siblings.where(\"parentFolder\", \"=\", folder);\n\t\tif (excludeId !== null) siblings = siblings.where(\"id\", \"!=\", excludeId);\n\t\tif (!await siblings.where(\"name\", \"=\", srcName).limit(1).executeTakeFirst()) return srcName;\n\t\tconst copies = await siblings.where(\"name\", \"like\", `${escapeLike(srcName)} (copy)%`).execute();\n\t\treturn `${srcName} (copy) ${getNextCopyNumber(copies.map((row) => row.name), srcName)}`;\n\t}\n\tasync findNode(trx, driveId, id) {\n\t\treturn trx.selectFrom(\"DriveNode\").select([\n\t\t\t\"id\",\n\t\t\t\"kind\",\n\t\t\t\"name\",\n\t\t\t\"requestedName\",\n\t\t\t\"parentFolder\",\n\t\t\t\"documentType\"\n\t\t]).where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", id).executeTakeFirst();\n\t}\n\t/** The node and its descendants; empty when the node does not exist. */\n\tasync subtreeIds(trx, driveId, root) {\n\t\treturn (await trx.withRecursive(\"subtree\", (qb) => qb.selectFrom(\"DriveNode\").select(\"id\").where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", root).union(qb.selectFrom(\"DriveNode\").innerJoin(\"subtree\", \"DriveNode.parentFolder\", \"subtree.id\").where(\"DriveNode.driveId\", \"=\", driveId).select(\"DriveNode.id\"))).selectFrom(\"subtree\").select(\"id\").execute()).map((row) => row.id);\n\t}\n\tasync applyDeleteDocument(trx, item) {\n\t\tconst docId = item.operation.action.input.documentId || item.context.documentId;\n\t\tconst linked = await trx.selectFrom(\"DriveNode\").select(\"driveId\").where(\"id\", \"=\", docId).execute();\n\t\tconst legacyDrives = await this.legacyDrivesAmong(trx, linked.map((row) => row.driveId));\n\t\tif (legacyDrives.size === 0) {\n\t\t\tawait this.eraseDocument(trx, docId);\n\t\t\treturn;\n\t\t}\n\t\tawait trx.deleteFrom(\"DriveNode\").where((eb) => eb.or([eb.and([eb(\"id\", \"=\", docId), eb(\"driveId\", \"not in\", [...legacyDrives])]), eb(\"driveId\", \"=\", docId)])).execute();\n\t\tawait trx.deleteFrom(\"DocumentName\").where(\"docId\", \"=\", docId).execute();\n\t}\n\t/** The legacy drives among the given ids, from the write identity table. */\n\tasync legacyDrivesAmong(trx, driveIds) {\n\t\tif (driveIds.length === 0) return /* @__PURE__ */ new Set();\n\t\tconst rows = await this.purgeLookup(trx).selectFrom(\"WriteIdentity\").select(\"documentId\").where(\"documentId\", \"in\", [...new Set(driveIds)]).where(\"documentType\", \"=\", LEGACY_DRIVE_DOCUMENT_TYPE).execute();\n\t\treturn new Set(rows.map((row) => row.documentId));\n\t}\n\t/** The id's nodes in every drive, a drive's own tree, and its name. */\n\tasync eraseDocument(trx, docId) {\n\t\tawait trx.deleteFrom(\"DriveNode\").where((eb) => eb.or([eb(\"id\", \"=\", docId), eb(\"driveId\", \"=\", docId)])).execute();\n\t\tawait trx.deleteFrom(\"DocumentName\").where(\"docId\", \"=\", docId).execute();\n\t}\n\tasync handleAddFileRelationship(trx, driveId, input) {\n\t\tconst metadata = this.parseFileMetadata(input);\n\t\tconst parentFolder = metadata.parentFolderId ?? null;\n\t\tconst documentType = metadata.documentType;\n\t\tconst requestedName = metadata.name ?? await this.lookupDocumentName(trx, input.targetId) ?? await this.lookupSnapshotName(trx, input.targetId) ?? \"\";\n\t\tconst resolved = await this.resolveSiblingName(trx, driveId, parentFolder, requestedName, input.targetId);\n\t\tawait trx.insertInto(\"DriveNode\").values({\n\t\t\tdriveId,\n\t\t\tid: input.targetId,\n\t\t\tkind: \"file\",\n\t\t\tname: resolved,\n\t\t\trequestedName,\n\t\t\tparentFolder,\n\t\t\tdocumentType\n\t\t}).onConflict((oc) => oc.columns([\"driveId\", \"id\"]).doUpdateSet({\n\t\t\tparentFolder,\n\t\t\tname: resolved,\n\t\t\trequestedName,\n\t\t\tkind: \"file\",\n\t\t\tdocumentType,\n\t\t\tupdatedAt: /* @__PURE__ */ new Date()\n\t\t})).execute();\n\t}\n\tasync handleAddFolder(trx, driveId, input) {\n\t\tconst parentFolder = input.parentFolderId ?? null;\n\t\tconst resolved = await this.resolveSiblingName(trx, driveId, parentFolder, input.name, input.folderId);\n\t\tawait trx.insertInto(\"DriveNode\").values({\n\t\t\tdriveId,\n\t\t\tid: input.folderId,\n\t\t\tkind: \"folder\",\n\t\t\tname: resolved,\n\t\t\trequestedName: input.name,\n\t\t\tparentFolder,\n\t\t\tdocumentType: null\n\t\t}).onConflict((oc) => oc.columns([\"driveId\", \"id\"]).doUpdateSet({\n\t\t\tparentFolder,\n\t\t\tname: resolved,\n\t\t\trequestedName: input.name,\n\t\t\tkind: \"folder\",\n\t\t\tdocumentType: null,\n\t\t\tupdatedAt: /* @__PURE__ */ new Date()\n\t\t})).execute();\n\t}\n\tasync handleUpdateFolder(trx, driveId, input) {\n\t\tconst row = await trx.selectFrom(\"DriveNode\").selectAll().where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", input.folderId).executeTakeFirst();\n\t\tif (!row) return;\n\t\tconst nextParentFolder = input.parentFolderId === void 0 ? row.parentFolder : input.parentFolderId ?? null;\n\t\tconst nextRequestedName = typeof input.name === \"string\" ? input.name : row.requestedName;\n\t\tconst resolved = await this.resolveSiblingName(trx, driveId, nextParentFolder, nextRequestedName, input.folderId);\n\t\tawait trx.updateTable(\"DriveNode\").set({\n\t\t\tparentFolder: nextParentFolder,\n\t\t\tname: resolved,\n\t\t\trequestedName: nextRequestedName,\n\t\t\tupdatedAt: /* @__PURE__ */ new Date()\n\t\t}).where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", input.folderId).execute();\n\t}\n\t/**\n\t* The name resolveCollision would pick, from an indexed check of the first\n\t* candidates it would try; a folder with all of them taken is scanned.\n\t*/\n\tasync resolveSiblingName(trx, driveId, parentFolder, requested, excludeId) {\n\t\tconst candidates = [requested];\n\t\tfor (let suffix = 2; suffix <= SIBLING_NAME_CANDIDATES; suffix++) candidates.push(`${requested} (${suffix})`);\n\t\tlet siblings = trx.selectFrom(\"DriveNode\").select(\"name\").where(\"driveId\", \"=\", driveId).where(\"id\", \"!=\", excludeId);\n\t\tsiblings = parentFolder === null ? siblings.where(\"parentFolder\", \"is\", null) : siblings.where(\"parentFolder\", \"=\", parentFolder);\n\t\tconst takenRows = await siblings.where(\"name\", \"in\", candidates).execute();\n\t\tconst taken = new Set(takenRows.map((r) => r.name));\n\t\tconst free = candidates.find((candidate) => !taken.has(candidate));\n\t\tif (free !== void 0) return free;\n\t\treturn resolveCollision(requested, (await siblings.execute()).map((r) => r.name));\n\t}\n\tasync lookupDocumentName(trx, docId) {\n\t\treturn (await trx.selectFrom(\"DocumentName\").select(\"name\").where(\"docId\", \"=\", docId).executeTakeFirst())?.name;\n\t}\n\t/** The document view's name for a document, preferring its header row. */\n\tasync lookupSnapshotName(trx, docId) {\n\t\tconst rows = await this.purgeLookup(trx).selectFrom(\"DocumentSnapshot\").select([\"scope\", \"name\"]).where(\"documentId\", \"=\", docId).where(\"name\", \"is not\", null).where(\"name\", \"!=\", \"\").execute();\n\t\treturn (rows.find((row) => row.scope === \"header\") ?? rows.at(0))?.name;\n\t}\n\tparseFileMetadata(input) {\n\t\tconst metadata = input.metadata;\n\t\tif (!metadata || typeof metadata !== \"object\" || metadata.kind !== \"file\" || typeof metadata.documentType !== \"string\") throw new Error(`ADD_RELATIONSHIP for target ${input.targetId}: missing or invalid drive/child file metadata (expected { kind: \"file\", parentFolderId, documentType })`);\n\t\tconst typed = metadata;\n\t\treturn {\n\t\t\tkind: \"file\",\n\t\t\tparentFolderId: typed.parentFolderId ?? null,\n\t\t\tdocumentType: typed.documentType,\n\t\t\t...typeof typed.name === \"string\" && typed.name !== \"\" ? { name: typed.name } : {}\n\t\t};\n\t}\n\tasync upsertDocumentName(trx, docId, name) {\n\t\tawait trx.insertInto(\"DocumentName\").values({\n\t\t\tdocId,\n\t\t\tname\n\t\t}).onConflict((oc) => oc.column(\"docId\").doUpdateSet({\n\t\t\tname,\n\t\t\tupdatedAt: /* @__PURE__ */ new Date()\n\t\t})).execute();\n\t}\n};\nfunction legacySnapshotRows(driveId, content) {\n\tconst nodes = content?.nodes;\n\tif (!Array.isArray(nodes)) return [];\n\tconst rows = [];\n\tfor (const node of nodes) {\n\t\tif (typeof node.id !== \"string\" || typeof node.name !== \"string\") continue;\n\t\tconst parentFolder = typeof node.parentFolder === \"string\" ? node.parentFolder : null;\n\t\tconst base = {\n\t\t\tdriveId,\n\t\t\tid: node.id,\n\t\t\tname: node.name,\n\t\t\trequestedName: node.name,\n\t\t\tparentFolder\n\t\t};\n\t\tif (node.kind === \"folder\") rows.push({\n\t\t\t...base,\n\t\t\tkind: \"folder\",\n\t\t\tdocumentType: null\n\t\t});\n\t\telse if (node.kind === \"file\" && typeof node.documentType === \"string\") rows.push({\n\t\t\t...base,\n\t\t\tkind: \"file\",\n\t\t\tdocumentType: node.documentType\n\t\t});\n\t}\n\treturn rows;\n}\nfunction isNonEmptyString(value) {\n\treturn typeof value === \"string\" && value !== \"\";\n}\nfunction escapeLike(value) {\n\treturn value.replace(/[\\\\%_]/g, (char) => `\\\\${char}`);\n}\n//#endregion\n//#region src/read-model/drive-node-view.ts\nconst DEFAULT_LIMIT = 100;\nfunction parseListChildrenPaging(paging) {\n\tif (paging === void 0) return {\n\t\tlimit: DEFAULT_LIMIT,\n\t\tcursor: null\n\t};\n\tif (!Number.isInteger(paging.limit) || paging.limit < 1) throw new Error(`Invalid paging limit: ${String(paging.limit)} (must be an integer >= 1)`);\n\tif (paging.cursor === \"\") return {\n\t\tlimit: paging.limit,\n\t\tcursor: null\n\t};\n\treturn {\n\t\tlimit: paging.limit,\n\t\tcursor: decodeKeysetCursor(paging.cursor)\n\t};\n}\nfunction encodeKeysetCursor(createdAt, id) {\n\treturn globalThis.btoa(JSON.stringify({\n\t\tcreatedAt,\n\t\tid\n\t}));\n}\nfunction decodeKeysetCursor(cursor) {\n\tlet decoded;\n\ttry {\n\t\tdecoded = globalThis.atob(cursor);\n\t} catch {\n\t\tthrow new Error(`Invalid paging cursor: ${JSON.stringify(cursor)} (must be a keyset cursor returned by a prior page)`);\n\t}\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(decoded);\n\t} catch {\n\t\tthrow new Error(`Invalid paging cursor: ${JSON.stringify(cursor)} (must be a keyset cursor returned by a prior page)`);\n\t}\n\tif (parsed === null || typeof parsed !== \"object\" || typeof parsed.createdAt !== \"string\" || typeof parsed.id !== \"string\") throw new Error(`Invalid paging cursor: ${JSON.stringify(cursor)} (must be a keyset cursor returned by a prior page)`);\n\tconst createdAt = parsed.createdAt;\n\tif (Number.isNaN(new Date(createdAt).getTime())) throw new Error(`Invalid paging cursor: ${JSON.stringify(cursor)} (createdAt is not a valid timestamp)`);\n\treturn {\n\t\tcreatedAt,\n\t\tid: parsed.id\n\t};\n}\nvar DriveNodeView = class {\n\tdb;\n\tconstructor(db) {\n\t\tthis.db = db;\n\t}\n\tasync getNode(driveId, nodeId) {\n\t\tconst row = await this.db.selectFrom(\"DriveNode\").selectAll().where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", nodeId).executeTakeFirst();\n\t\tif (!row) return void 0;\n\t\treturn rowToNode(row);\n\t}\n\tasync listChildren(driveId, parentFolder, paging, _signal, kind) {\n\t\tconst { limit, cursor } = parseListChildrenPaging(paging);\n\t\tlet query = this.db.selectFrom(\"DriveNode\").selectAll().select(sql`to_char(\"createdAt\" AT TIME ZONE 'UTC', 'YYYY-MM-DD\"T\"HH24:MI:SS.US\"Z\"')`.as(\"createdAtKey\")).where(\"driveId\", \"=\", driveId);\n\t\tif (parentFolder === null) query = query.where(\"parentFolder\", \"is\", null);\n\t\telse if (parentFolder !== void 0) query = query.where(\"parentFolder\", \"=\", parentFolder);\n\t\tif (kind !== void 0) query = query.where(\"kind\", \"=\", kind);\n\t\tif (cursor !== null) query = query.where((eb) => eb(eb.refTuple(\"createdAt\", \"id\"), \">\", eb.tuple(sql`${cursor.createdAt}::timestamptz`, sql`${cursor.id}`)));\n\t\tconst rows = await query.orderBy(\"createdAt\", \"asc\").orderBy(\"id\", \"asc\").limit(limit + 1).execute();\n\t\tconst hasMore = rows.length > limit;\n\t\tconst sliced = hasMore ? rows.slice(0, limit) : rows;\n\t\tconst cursors = sliced.map((row) => encodeKeysetCursor(row.createdAtKey, row.id));\n\t\treturn {\n\t\t\tresults: sliced.map(rowToNode),\n\t\t\tcursors,\n\t\t\toptions: {\n\t\t\t\tcursor: paging?.cursor ?? \"\",\n\t\t\t\tlimit\n\t\t\t},\n\t\t\tnextCursor: hasMore ? cursors[cursors.length - 1] : void 0\n\t\t};\n\t}\n\tasync listAll(driveId) {\n\t\treturn (await this.db.selectFrom(\"DriveNode\").selectAll().where(\"driveId\", \"=\", driveId).orderBy(\"createdAt\", \"asc\").orderBy(\"id\", \"asc\").execute()).map(rowToNode);\n\t}\n\tasync getDescendants(driveId, root) {\n\t\treturn (await this.db.withRecursive(\"descendants\", (qb) => qb.selectFrom(\"DriveNode\").select([\n\t\t\t\"driveId\",\n\t\t\t\"id\",\n\t\t\t\"kind\",\n\t\t\t\"name\",\n\t\t\t\"requestedName\",\n\t\t\t\"parentFolder\",\n\t\t\t\"documentType\",\n\t\t\t\"createdAt\"\n\t\t]).where(\"driveId\", \"=\", driveId).where(\"id\", \"=\", root).unionAll(qb.selectFrom(\"DriveNode\").innerJoin(\"descendants\", \"DriveNode.parentFolder\", \"descendants.id\").where(\"DriveNode.driveId\", \"=\", driveId).select([\n\t\t\t\"DriveNode.driveId\",\n\t\t\t\"DriveNode.id\",\n\t\t\t\"DriveNode.kind\",\n\t\t\t\"DriveNode.name\",\n\t\t\t\"DriveNode.requestedName\",\n\t\t\t\"DriveNode.parentFolder\",\n\t\t\t\"DriveNode.documentType\",\n\t\t\t\"DriveNode.createdAt\"\n\t\t]))).selectFrom(\"descendants\").select([\n\t\t\t\"driveId\",\n\t\t\t\"id\",\n\t\t\t\"kind\",\n\t\t\t\"name\",\n\t\t\t\"requestedName\",\n\t\t\t\"parentFolder\",\n\t\t\t\"documentType\"\n\t\t]).orderBy(\"createdAt\", \"asc\").orderBy(\"id\", \"asc\").execute()).map(rowToNode);\n\t}\n};\nfunction rowToNode(row) {\n\tif (row.kind === \"file\") {\n\t\tif (row.documentType === null) throw new Error(`DriveNode ${row.driveId}/${row.id}: file row has null documentType, which violates the schema CHECK constraint`);\n\t\treturn {\n\t\t\tkind: \"file\",\n\t\t\tid: row.id,\n\t\t\tdriveId: row.driveId,\n\t\t\tparentFolder: row.parentFolder,\n\t\t\tname: row.name,\n\t\t\tdocumentType: row.documentType\n\t\t};\n\t}\n\treturn {\n\t\tkind: \"folder\",\n\t\tid: row.id,\n\t\tdriveId: row.driveId,\n\t\tparentFolder: row.parentFolder,\n\t\tname: row.name\n\t};\n}\n//#endregion\n//#region src/client/reactor-drive-write-strategy.ts\n/**\n* A handle over one write made of several: `primary` names the document and\n* the read-back; each stage settles when every part has, rejecting with the\n* first failure in the order given, and the receipt carries a token over all.\n*/\nvar CompositeWriteHandle = class {\n\tprimary;\n\tparts;\n\twrittenReceipt;\n\treadableReceipt;\n\tconstructor(primary, parts) {\n\t\tthis.primary = primary;\n\t\tthis.parts = parts;\n\t}\n\tget jobId() {\n\t\treturn this.primary.jobId;\n\t}\n\tget documentId() {\n\t\treturn this.primary.documentId;\n\t}\n\tget branch() {\n\t\treturn this.primary.branch;\n\t}\n\tget written() {\n\t\tthis.writtenReceipt ??= this.receiptAt(\"written\");\n\t\treturn this.writtenReceipt;\n\t}\n\tget readable() {\n\t\tthis.readableReceipt ??= this.receiptAt(\"readable\");\n\t\treturn this.readableReceipt;\n\t}\n\tasync document(view, signal) {\n\t\tawait this.readable;\n\t\treturn this.primary.document(view, signal);\n\t}\n\tasync receiptAt(stage) {\n\t\tconst receipts = [];\n\t\tfor (const handle of [this.primary, ...this.parts]) receipts.push(stage === \"written\" ? await handle.written : await handle.readable);\n\t\treturn {\n\t\t\t...receipts[0],\n\t\t\ttoken: mergeConsistencyTokens(receipts.map((receipt) => receipt.token))\n\t\t};\n\t}\n};\n/** A write handle that also names the node the write made or changed. */\nvar NodeHandle = class {\n\thandle;\n\tnodeId;\n\tconstructor(handle, nodeId) {\n\t\tthis.handle = handle;\n\t\tthis.nodeId = nodeId;\n\t}\n\tget jobId() {\n\t\treturn this.handle.jobId;\n\t}\n\tget documentId() {\n\t\treturn this.handle.documentId;\n\t}\n\tget branch() {\n\t\treturn this.handle.branch;\n\t}\n\tget written() {\n\t\treturn this.handle.written;\n\t}\n\tget readable() {\n\t\treturn this.handle.readable;\n\t}\n\tdocument(view, signal) {\n\t\treturn this.handle.document(view, signal);\n\t}\n};\n/**\n* The node writes of reactor-drives: folders are drive-scoped actions, files\n* are `drive/child` relationships carrying their parent folder, and nodes are\n* read from the `DriveNode` projection. Each write returns once its last step\n* is accepted; a step a later step depends on is waited for here.\n*/\nvar ReactorDriveWriteStrategy = class {\n\tread;\n\twrite;\n\tnodes;\n\tconstructor(read, write, nodes) {\n\t\tthis.read = read;\n\t\tthis.write = write;\n\t\tthis.nodes = nodes;\n\t}\n\tasync addFile(driveIdentifier, document, parentFolder, signal) {\n\t\tconst documentId = document.header.id;\n\t\tconst protocolVersions = await createVersionsOf(document, (options) => this.read.getCreateProtocolVersions(options, signal), driveIdentifier);\n\t\tconst metadata = {\n\t\t\tkind: \"file\",\n\t\t\tparentFolderId: parentFolder ?? null,\n\t\t\tdocumentType: document.header.documentType\n\t\t};\n\t\tconst request = { jobs: [{\n\t\t\tkey: \"create\",\n\t\t\tdocumentId,\n\t\t\tscope: \"document\",\n\t\t\tbranch: \"main\",\n\t\t\tactions: creationActions(document, protocolVersions),\n\t\t\tdependsOn: []\n\t\t}, {\n\t\t\tkey: \"link\",\n\t\t\tdocumentId: driveIdentifier,\n\t\t\tscope: \"document\",\n\t\t\tbranch: \"main\",\n\t\t\tactions: [addRelationshipAction(driveIdentifier, documentId, DRIVE_CHILD_RELATIONSHIP_TYPE, metadata)],\n\t\t\tdependsOn: [\"create\"]\n\t\t}] };\n\t\tconst batch = await this.write.executeBatch(request, signal);\n\t\treturn new CompositeWriteHandle(batch.handles.create, [batch.handles.link]);\n\t}\n\tasync addFolder(driveIdentifier, name, parentFolder, signal) {\n\t\tconst folderId = generateId();\n\t\treturn new NodeHandle(await this.write.execute(driveIdentifier, \"main\", [addFolderAction({\n\t\t\tfolderId,\n\t\t\tparentFolderId: parentFolder ?? null,\n\t\t\tname\n\t\t})], signal), folderId);\n\t}\n\tasync removeNode(driveIdentifier, nodeId, signal) {\n\t\tif ((await this.requireNode(driveIdentifier, nodeId, signal)).kind === \"folder\") {\n\t\t\tconst subtree = await this.nodes.getDescendants(driveIdentifier, nodeId, signal);\n\t\t\tconst fileDescendants = subtree.filter((n) => n.kind === \"file\");\n\t\t\tconst subFolders = subtree.filter((n) => n.kind === \"folder\" && n.id !== nodeId);\n\t\t\tconst batch = [\n\t\t\t\t...fileDescendants.map((f) => removeRelationshipAction(driveIdentifier, f.id, DRIVE_CHILD_RELATIONSHIP_TYPE)),\n\t\t\t\t...orderDeepestFirst(subFolders, nodeId).map((f) => removeFolderAction({ folderId: f.id })),\n\t\t\t\tremoveFolderAction({ folderId: nodeId })\n\t\t\t];\n\t\t\tconst driveHandle = await this.write.execute(driveIdentifier, \"main\", batch, signal);\n\t\t\tawait driveHandle.readable;\n\t\t\tconst deletes = [];\n\t\t\tfor (const file of fileDescendants) deletes.push(await this.write.deleteDocument(file.id, \"cascade\", signal));\n\t\t\treturn new CompositeWriteHandle(driveHandle, deletes);\n\t\t}\n\t\tconst unlinked = await this.write.execute(driveIdentifier, \"main\", [removeRelationshipAction(driveIdentifier, nodeId, DRIVE_CHILD_RELATIONSHIP_TYPE)], signal);\n\t\tawait unlinked.readable;\n\t\treturn new CompositeWriteHandle(unlinked, [await this.write.deleteDocument(nodeId, void 0, signal)]);\n\t}\n\tasync renameNode(driveIdentifier, nodeId, name, signal) {\n\t\tif ((await this.requireNode(driveIdentifier, nodeId, signal)).kind === \"file\") return new NodeHandle(await this.write.rename(nodeId, name, \"main\", signal), nodeId);\n\t\treturn new NodeHandle(await this.write.execute(driveIdentifier, \"main\", [updateFolderAction({\n\t\t\tfolderId: nodeId,\n\t\t\tname\n\t\t})], signal), nodeId);\n\t}\n\tasync setPreferredEditorOnNode(nodeId, preferredEditor, signal) {\n\t\treturn this.write.setPreferredEditor(nodeId, preferredEditor, \"main\", signal);\n\t}\n\tasync moveNode(driveIdentifier, srcNodeId, targetParentFolderId, signal) {\n\t\tconst node = await this.requireNode(driveIdentifier, srcNodeId, signal);\n\t\tif (node.kind === \"folder\") return this.write.execute(driveIdentifier, \"main\", [updateFolderAction({\n\t\t\tfolderId: srcNodeId,\n\t\t\tparentFolderId: targetParentFolderId ?? null\n\t\t})], signal);\n\t\tconst metadata = {\n\t\t\tkind: \"file\",\n\t\t\tparentFolderId: targetParentFolderId ?? null,\n\t\t\tdocumentType: node.documentType ?? \"\"\n\t\t};\n\t\treturn this.write.execute(driveIdentifier, \"main\", [removeRelationshipAction(driveIdentifier, srcNodeId, DRIVE_CHILD_RELATIONSHIP_TYPE), addRelationshipAction(driveIdentifier, srcNodeId, DRIVE_CHILD_RELATIONSHIP_TYPE, metadata)], signal);\n\t}\n\tasync copyNode(driveIdentifier, srcNodeId, targetParentFolderId, signal, options) {\n\t\tif (options?.protocolVersions) throw new Error(\"ReactorDriveClient.copyNode replays the source's operations and cannot override its protocolVersions\");\n\t\tawait this.requireNode(driveIdentifier, srcNodeId, signal);\n\t\tconst subtree = await this.nodes.getDescendants(driveIdentifier, srcNodeId, signal);\n\t\tif (targetParentFolderId !== void 0 && subtree.some((n) => n.id === targetParentFolderId)) throw new Error(`Cannot copy node ${srcNodeId} into itself or one of its descendants (target: ${targetParentFolderId})`);\n\t\tconst idMap = /* @__PURE__ */ new Map();\n\t\tfor (const node of subtree) idMap.set(node.id, generateId());\n\t\tconst policy = await this.read.getCreateSignaturePolicy();\n\t\tconst selectedByType = /* @__PURE__ */ new Map();\n\t\tconst jobs = [];\n\t\tconst driveActions = [];\n\t\tconst fileCreateKeys = [];\n\t\tfor (const node of subtree) {\n\t\t\tlet newId = idMap.get(node.id);\n\t\t\tlet newParent;\n\t\t\tif (node.id === srcNodeId) newParent = targetParentFolderId ?? null;\n\t\t\telse {\n\t\t\t\tif (node.parentFolder == null) throw new Error(`copyNode: descendant ${node.id} has no parentFolder`);\n\t\t\t\tconst mapped = idMap.get(node.parentFolder);\n\t\t\t\tif (mapped === void 0) throw new Error(`copyNode: descendant ${node.id} parent ${node.parentFolder} missing from idMap`);\n\t\t\t\tnewParent = mapped;\n\t\t\t}\n\t\t\tif (node.kind === \"folder\") {\n\t\t\t\tdriveActions.push(addFolderAction({\n\t\t\t\t\tfolderId: newId,\n\t\t\t\t\tparentFolderId: newParent,\n\t\t\t\t\tname: node.name\n\t\t\t\t}));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst srcDoc = await this.read.get(node.id, void 0, signal);\n\t\t\tconst documentType = srcDoc.header.documentType;\n\t\t\tconst { results: allModules } = await this.read.getDocumentModelModules();\n\t\t\tconst modulesForType = allModules.filter((m) => m.documentModel.global.id === documentType);\n\t\t\tif (modulesForType.length === 0) throw new Error(`Document model module not found for type: ${documentType}`);\n\t\t\tconst reducers = {};\n\t\t\tfor (const m of modulesForType) reducers[m.version ?? 1] = m.reducer;\n\t\t\tconst config = { reducers };\n\t\t\tlet selected = selectedByType.get(documentType);\n\t\t\tif (selected === void 0) {\n\t\t\t\tselected = await this.read.getCreateProtocolVersions({\n\t\t\t\t\tdocumentType,\n\t\t\t\t\tparentIdentifier: driveIdentifier\n\t\t\t\t}, signal);\n\t\t\t\tselectedByType.set(documentType, selected);\n\t\t\t}\n\t\t\tconst replayHeader = createCopyHeader({\n\t\t\t\tdocumentType,\n\t\t\t\tprotocolVersions: {\n\t\t\t\t\t...selected,\n\t\t\t\t\t...srcDoc.header.protocolVersions\n\t\t\t\t}\n\t\t\t}, newId, policy);\n\t\t\tnewId = replayHeader.id;\n\t\t\tconst duplicated = replayDocumentVersioned(srcDoc.initialState, srcDoc.operations, config, replayHeader);\n\t\t\tassertAuthPreservedOnDuplicate(node.id, srcDoc.state.auth, duplicated.state.auth);\n\t\t\tduplicated.header.name = node.name;\n\t\t\tconst createKey = `create:${newId}`;\n\t\t\tjobs.push({\n\t\t\t\tkey: createKey,\n\t\t\t\tdocumentId: newId,\n\t\t\t\tscope: \"document\",\n\t\t\t\tbranch: \"main\",\n\t\t\t\tactions: creationActions(duplicated, duplicated.header.protocolVersions ?? selected),\n\t\t\t\tdependsOn: []\n\t\t\t});\n\t\t\tfileCreateKeys.push(createKey);\n\t\t\tconst metadata = {\n\t\t\t\tkind: \"file\",\n\t\t\t\tparentFolderId: newParent,\n\t\t\t\tdocumentType: duplicated.header.documentType\n\t\t\t};\n\t\t\tdriveActions.push(addRelationshipAction(driveIdentifier, newId, DRIVE_CHILD_RELATIONSHIP_TYPE, metadata));\n\t\t}\n\t\tjobs.push({\n\t\t\tkey: \"drive\",\n\t\t\tdocumentId: driveIdentifier,\n\t\t\tscope: \"document\",\n\t\t\tbranch: \"main\",\n\t\t\tactions: driveActions,\n\t\t\tdependsOn: fileCreateKeys\n\t\t});\n\t\tconst batch = await this.write.executeBatch({ jobs }, signal);\n\t\treturn new CompositeWriteHandle(batch.handles.drive, fileCreateKeys.map((key) => batch.handles[key]));\n\t}\n\tasync requireNode(driveIdentifier, nodeId, signal) {\n\t\tconst node = await this.nodes.getNode(driveIdentifier, nodeId, signal);\n\t\tif (!node) throw new Error(`Node ${nodeId} not found in drive ${driveIdentifier}`);\n\t\treturn node;\n\t}\n};\nfunction orderDeepestFirst(folders, rootId) {\n\tconst depthById = /* @__PURE__ */ new Map();\n\tconst compute = (id) => {\n\t\tif (id === rootId) return 0;\n\t\tconst cached = depthById.get(id);\n\t\tif (cached !== void 0) return cached;\n\t\tconst folder = folders.find((f) => f.id === id);\n\t\tif (!folder) return 0;\n\t\tconst parent = folder.parentFolder ?? rootId;\n\t\tconst depth = compute(parent) + 1;\n\t\tdepthById.set(id, depth);\n\t\treturn depth;\n\t};\n\treturn folders.slice().sort((a, b) => compute(b.id) - compute(a.id));\n}\n/**\n* The write strategy for drives of `REACTOR_DRIVE_DOCUMENT_TYPE`. Registered on\n* the client builder with `withDriveWriteStrategy`; needs the `DriveNode`\n* projection as its node source.\n*/\nfunction createReactorDriveWriteStrategy(args) {\n\tif (!args.nodes) throw new Error(\"The reactor-drive write strategy needs a drive node source (withDriveNodeSource)\");\n\treturn new ReactorDriveWriteStrategy(args.read, args.write, args.nodes);\n}\n//#endregion\n//#region src/client/reactor-drive-client.ts\n/**\n* Implementation of {@link IDriveClient} backed by the reactor's relationship\n* primitives and the drive-scoped folder actions. Folder structure lives in\n* the operation log (ADD_FOLDER/UPDATE_FOLDER/REMOVE_FOLDER + ADD_RELATIONSHIP\n* for files) and is materialised by `NodeProcessor` into the `DriveNode`\n* table consumed via {@link IDriveReadModel}.\n*/\nvar ReactorDriveClient = class {\n\tread;\n\twrite;\n\treadModel;\n\tstrategy;\n\tconstructor(args) {\n\t\tif (\"reactor\" in args) {\n\t\t\tthis.read = args.reactor.read;\n\t\t\tthis.write = args.reactor.write;\n\t\t} else {\n\t\t\tthis.read = args.read;\n\t\t\tthis.write = args.write;\n\t\t}\n\t\tthis.readModel = args.readModel;\n\t\tthis.strategy = createReactorDriveWriteStrategy({\n\t\t\tread: this.read,\n\t\t\twrite: this.write,\n\t\t\tnodes: this.readModel\n\t\t});\n\t}\n\tasync create(input, signal) {\n\t\tconst driveDoc = await this.read.newDocument(REACTOR_DRIVE_DOCUMENT_TYPE, {\n\t\t\tinitialState: { global: {\n\t\t\t\tname: input.global.name,\n\t\t\t\ticon: input.global.icon ?? null\n\t\t\t} },\n\t\t\tsignaturePolicy: input.signaturePolicy,\n\t\t\tprotocolVersions: input.protocolVersions\n\t\t}, signal);\n\t\tif (input.local) {\n\t\t\tif (typeof input.local.sharingType === \"string\") driveDoc.state.local.sharingType = input.local.sharingType;\n\t\t\tif (typeof input.local.availableOffline === \"boolean\") driveDoc.state.local.availableOffline = input.local.availableOffline;\n\t\t}\n\t\tif (input.preferredEditor) driveDoc.header.meta = {\n\t\t\t...driveDoc.header.meta,\n\t\t\tpreferredEditor: input.preferredEditor\n\t\t};\n\t\tconst created = await (await this.write.create(driveDoc, void 0, signal)).document(void 0, signal);\n\t\treturn this.toLegacyDriveDocument(created, created.header.id);\n\t}\n\tasync addFile(driveIdentifier, document, parentFolder, signal) {\n\t\tconst receipt = await (await this.strategy.addFile(driveIdentifier, document, parentFolder, signal)).readable;\n\t\treturn this.read.get(document.header.id, void 0, signal, receipt.token);\n\t}\n\tasync addFolder(driveIdentifier, name, parentFolder, signal) {\n\t\tconst handle = await this.strategy.addFolder(driveIdentifier, name, parentFolder, signal);\n\t\tawait handle.readable;\n\t\treturn {\n\t\t\tid: handle.nodeId,\n\t\t\tkind: \"folder\",\n\t\t\tname,\n\t\t\tparentFolder: parentFolder ?? null\n\t\t};\n\t}\n\tasync removeNode(driveIdentifier, nodeId, signal) {\n\t\tawait (await this.strategy.removeNode(driveIdentifier, nodeId, signal)).readable;\n\t}\n\tasync renameNode(driveIdentifier, nodeId, name, signal) {\n\t\tawait (await this.strategy.renameNode(driveIdentifier, nodeId, name, signal)).readable;\n\t\tconst updated = await this.readModel.getNode(driveIdentifier, nodeId, signal);\n\t\tif (!updated) throw new Error(\"Node missing from drive after rename\");\n\t\treturn this.toLegacyNode(updated);\n\t}\n\tasync setPreferredEditorOnNode(nodeId, preferredEditor, signal) {\n\t\treturn (await this.strategy.setPreferredEditorOnNode(nodeId, preferredEditor, signal)).document(void 0, signal);\n\t}\n\tasync moveNode(driveIdentifier, srcNodeId, targetParentFolderId, signal) {\n\t\tconst handle = await this.strategy.moveNode(driveIdentifier, srcNodeId, targetParentFolderId, signal);\n\t\treturn this.readDriveAfter(handle, driveIdentifier, signal);\n\t}\n\tasync copyNode(driveIdentifier, srcNodeId, targetParentFolderId, signal, options) {\n\t\tconst handle = await this.strategy.copyNode(driveIdentifier, srcNodeId, targetParentFolderId, signal, options);\n\t\treturn this.readDriveAfter(handle, driveIdentifier, signal);\n\t}\n\tasync getNode(driveIdentifier, nodeId, signal) {\n\t\tconst node = await this.readModel.getNode(driveIdentifier, nodeId, signal);\n\t\tif (!node) throw new Error(`Node ${nodeId} not found in drive ${driveIdentifier}`);\n\t\treturn this.toLegacyNode(node);\n\t}\n\tasync listNodes(driveIdentifier, parentFolder, paging, signal) {\n\t\tconst page = await this.readModel.listChildren(driveIdentifier, parentFolder, paging, signal);\n\t\treturn {\n\t\t\tresults: page.results.map((node) => this.toLegacyNode(node)),\n\t\t\toptions: page.options,\n\t\t\t...page.nextCursor !== void 0 ? { nextCursor: page.nextCursor } : {}\n\t\t};\n\t}\n\t/** Waits for the write, then reads the drive back in the legacy shape. */\n\tasync readDriveAfter(handle, driveIdentifier, signal) {\n\t\tconst receipt = await handle.readable;\n\t\tconst drive = await this.read.get(driveIdentifier, void 0, signal, receipt.token);\n\t\treturn this.toLegacyDriveDocument(drive, driveIdentifier);\n\t}\n\ttoLegacyNode(node) {\n\t\tif (node.kind === \"file\") {\n\t\t\tconst file = node;\n\t\t\treturn {\n\t\t\t\tid: file.id,\n\t\t\t\tkind: \"file\",\n\t\t\t\tname: file.name,\n\t\t\t\tparentFolder: file.parentFolder,\n\t\t\t\tdocumentType: file.documentType\n\t\t\t};\n\t\t}\n\t\tconst folder = node;\n\t\treturn {\n\t\t\tid: folder.id,\n\t\t\tkind: \"folder\",\n\t\t\tname: folder.name,\n\t\t\tparentFolder: folder.parentFolder\n\t\t};\n\t}\n\tasync toLegacyDriveDocument(doc, driveId) {\n\t\tif (doc.header.documentType !== \"powerhouse/reactor-drive\") throw new Error(`Document ${doc.header.id} is not a reactor-drive document`);\n\t\tconst allNodes = await this.readModel.listAll(driveId);\n\t\tconst legacy = structuredClone(doc);\n\t\tconst existingGlobal = legacy.state.global;\n\t\tlegacy.state.global = {\n\t\t\tname: existingGlobal.name ?? \"\",\n\t\t\ticon: existingGlobal.icon ?? null,\n\t\t\tnodes: allNodes.map((n) => this.toLegacyNode(n))\n\t\t};\n\t\treturn legacy;\n\t}\n};\n//#endregion\n//#region src/migration/migrate-legacy-state.ts\n/**\n* Translates a legacy `document-drive` `state.global.nodes` array into the\n* action vocabulary used by the new reactor-drive module.\n*\n* Folder nodes are emitted as `ADD_FOLDER` actions targeting the drive\n* document. File nodes are emitted as `ADD_RELATIONSHIP` actions on the drive\n* with `drive/child` metadata carrying the parent folder id. File nodes\n* assume the underlying PHDocument still exists under the same id — the\n* migration only re-links it into the new drive, it does not recreate\n* documents.\n*\n* Re-running the migration is safe: existing `DriveNode` rows are skipped\n* so already-migrated nodes are left untouched.\n*/\nasync function migrateLegacyDriveState(args) {\n\tconst { reactor, readModel, driveId, nodes, signal } = args;\n\tconst branch = args.branch ?? \"main\";\n\tconst ordered = orderLegacyNodes(nodes);\n\tconst actions = [];\n\tlet skippedExisting = 0;\n\tfor (const node of ordered) {\n\t\tif (await readModel.getNode(driveId, node.id, signal)) {\n\t\t\tskippedExisting += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tactions.push(toAction(driveId, node));\n\t}\n\tif (actions.length === 0) return {\n\t\temittedActions: 0,\n\t\tskippedExisting\n\t};\n\tawait reactor.execute(driveId, branch, actions, signal);\n\treturn {\n\t\temittedActions: actions.length,\n\t\tskippedExisting\n\t};\n}\nfunction toAction(driveId, node) {\n\tif (node.kind === \"folder\") return addFolderAction({\n\t\tfolderId: node.id,\n\t\tparentFolderId: node.parentFolder ?? null,\n\t\tname: node.name\n\t});\n\tconst fileNode = node;\n\tconst metadata = {\n\t\tkind: \"file\",\n\t\tparentFolderId: fileNode.parentFolder ?? null,\n\t\tdocumentType: fileNode.documentType\n\t};\n\treturn addRelationshipAction(driveId, fileNode.id, DRIVE_CHILD_RELATIONSHIP_TYPE, metadata);\n}\n/**\n* Sorts legacy nodes so that any folder appears before its children. The\n* legacy state stores nodes in insertion order, which usually already\n* satisfies that property, but defensive sorting keeps replay deterministic\n* if the input was constructed out of order.\n*/\nfunction orderLegacyNodes(nodes) {\n\tconst byId = /* @__PURE__ */ new Map();\n\tfor (const node of nodes) byId.set(node.id, node);\n\tconst visited = /* @__PURE__ */ new Set();\n\tconst ordered = [];\n\tfor (const start of nodes) {\n\t\tif (visited.has(start.id)) continue;\n\t\tconst chain = [];\n\t\tconst seenInWalk = /* @__PURE__ */ new Set();\n\t\tlet current = start;\n\t\twhile (current && !visited.has(current.id) && !seenInWalk.has(current.id)) {\n\t\t\tseenInWalk.add(current.id);\n\t\t\tchain.push(current);\n\t\t\tconst parentId = current.parentFolder;\n\t\t\tcurrent = parentId ? byId.get(parentId) : void 0;\n\t\t}\n\t\twhile (chain.length > 0) {\n\t\t\tconst node = chain.pop();\n\t\t\tif (visited.has(node.id)) continue;\n\t\t\tvisited.add(node.id);\n\t\t\tordered.push(node);\n\t\t}\n\t}\n\treturn ordered;\n}\n//#endregion\nexport { DRIVE_CHILD_RELATIONSHIP_TYPE, DriveNodeView, NodeProcessor, REACTOR_DRIVE_DOCUMENT_TYPE, REACTOR_DRIVE_FILE_EXTENSION, ReactorDriveClient, addFolderAction, createReactorDriveWriteStrategy, getReactorDriveMigrationStatus, migrateLegacyDriveState, reactorDriveActions, reactorDriveCreateDocument, reactorDriveCreateState, reactorDriveDocumentModelModule, reactorDriveDocumentReducer, reactorDriveStateReducer, removeFolderAction, resolveCollision, runReactorDriveMigrations, setAvailableOfflineAction, setDriveIconAction, setDriveNameAction, setSharingTypeAction, updateFolderAction };\n\n//# sourceMappingURL=index.js.map","//#region \\0rolldown/runtime.js\nvar __defProp = Object.defineProperty;\nvar __exportAll = (all, no_symbols) => {\n\tlet target = {};\n\tfor (var name in all) __defProp(target, name, {\n\t\tget: all[name],\n\t\tenumerable: true\n\t});\n\tif (!no_symbols) __defProp(target, Symbol.toStringTag, { value: \"Module\" });\n\treturn target;\n};\n//#endregion\nexport { __exportAll as t };\n","import { t as __exportAll } from \"./rolldown-runtime-D7D4PA-g.js\";\nimport { BaseDocumentHeaderSchema, BaseDocumentStateSchema, baseActions, baseCreateDocument, baseLoadFromInputVersioned, baseSaveToFileHandle, createAction, createBaseState, createReducer, createState, defaultBaseState, isDocumentAction } from \"document-model\";\nimport * as z$1 from \"zod\";\nimport { z } from \"zod\";\n//#region document-models/reactor-group/v1/gen/schema/zod.ts\nconst isDefinedNonNullAny = (v) => v !== void 0 && v !== null;\nconst definedNonNullAnySchema = z$1.any().refine((v) => isDefinedNonNullAny(v));\nfunction AddMemberInputSchema() {\n\treturn z$1.object({ address: z$1.string() });\n}\nfunction ReactorGroupStateSchema() {\n\treturn z$1.object({\n\t\t__typename: z$1.literal(\"ReactorGroupState\").optional(),\n\t\tdescription: z$1.string(),\n\t\tmembers: z$1.array(z$1.string()),\n\t\tname: z$1.string()\n\t});\n}\nfunction RemoveMemberInputSchema() {\n\treturn z$1.object({ address: z$1.string() });\n}\nfunction SetGroupDescriptionInputSchema() {\n\treturn z$1.object({ description: z$1.string() });\n}\nfunction SetGroupNameInputSchema() {\n\treturn z$1.object({ name: z$1.string() });\n}\n//#endregion\n//#region document-models/reactor-group/v1/gen/group/creators.ts\n/**\n* WARNING: DO NOT EDIT\n* This file is auto-generated and updated by codegen\n*/\nvar creators_exports = /* @__PURE__ */ __exportAll({\n\taddMember: () => addMember,\n\tremoveMember: () => removeMember,\n\tsetGroupDescription: () => setGroupDescription,\n\tsetGroupName: () => setGroupName\n});\nconst setGroupName = (input) => createAction(\"SET_GROUP_NAME\", { ...input }, void 0, SetGroupNameInputSchema, \"global\");\nconst setGroupDescription = (input) => createAction(\"SET_GROUP_DESCRIPTION\", { ...input }, void 0, SetGroupDescriptionInputSchema, \"global\");\nconst addMember = (input) => createAction(\"ADD_MEMBER\", { ...input }, void 0, AddMemberInputSchema, \"global\");\nconst removeMember = (input) => createAction(\"REMOVE_MEMBER\", { ...input }, void 0, RemoveMemberInputSchema, \"global\");\n//#endregion\n//#region document-models/reactor-group/v1/actions.ts\n/**\n* WARNING: DO NOT EDIT\n* This file is auto-generated and updated by codegen\n*/\n/** Actions for the ReactorGroup document model */\nconst actions = {\n\t...baseActions,\n\t...creators_exports\n};\n//#endregion\n//#region document-models/reactor-group/v1/gen/document-model.ts\nconst documentModel = {\n\tid: \"powerhouse/reactor-group\",\n\tname: \"Reactor Group\",\n\tauthor: {\n\t\tname: \"Powerhouse\",\n\t\twebsite: \"https://powerhouse.inc\"\n\t},\n\textension: \".phrg\",\n\tdescription: \"A group of member addresses referenced by { group } principals in the auth scope. Group membership is folded at an operation's position during auth evaluation, so reducers are strict and deterministic: duplicate or unknown members are errors, and membership is capped.\",\n\tspecifications: [{\n\t\tstate: {\n\t\t\tlocal: {\n\t\t\t\tschema: \"\",\n\t\t\t\texamples: [],\n\t\t\t\tinitialValue: \"\"\n\t\t\t},\n\t\t\tglobal: {\n\t\t\t\tschema: \"\\\"\\\"\\\"\\nA member address list gated by the group document's own auth scope. Addresses\\nare stored as given and compared case-insensitively, matching how { address }\\nprincipals are compared during auth evaluation.\\n\\\"\\\"\\\"\\ntype ReactorGroupState {\\n \\\"\\\"\\\"Display name of the group.\\\"\\\"\\\"\\n name: String!\\n \\\"\\\"\\\"Free-text description of the group's purpose.\\\"\\\"\\\"\\n description: String!\\n \\\"\\\"\\\"Member wallet addresses. No duplicates under case-insensitive comparison.\\\"\\\"\\\"\\n members: [String!]!\\n}\",\n\t\t\t\texamples: [],\n\t\t\t\tinitialValue: \"{\\n \\\"name\\\": \\\"\\\",\\n \\\"description\\\": \\\"\\\",\\n \\\"members\\\": []\\n}\"\n\t\t\t}\n\t\t},\n\t\tmodules: [{\n\t\t\tid: \"efd6d9bb-869e-4565-b1ca-d9b74385eaf7\",\n\t\t\tname: \"group\",\n\t\t\tdescription: \"Manage the group's identity and its member address list.\",\n\t\t\toperations: [\n\t\t\t\t{\n\t\t\t\t\tid: \"43da2b3d-bad7-40b8-8a84-4cdf892f1519\",\n\t\t\t\t\tname: \"SET_GROUP_NAME\",\n\t\t\t\t\tdescription: \"Set the display name of the group. The name must be non-empty after trimming and at most 200 characters.\",\n\t\t\t\t\tschema: \"input SetGroupNameInput {\\n name: String!\\n}\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [{\n\t\t\t\t\t\tid: \"8be0d16c-1f21-4d95-9536-c5a5867d2ba1\",\n\t\t\t\t\t\tcode: \"InvalidGroupName\",\n\t\t\t\t\t\tname: \"InvalidGroupName\",\n\t\t\t\t\t\tdescription: \"The group name is empty after trimming or longer than 200 characters.\",\n\t\t\t\t\t\ttemplate: \"\"\n\t\t\t\t\t}],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"global\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"aa493898-ce6b-4b28-baf3-1b6fd8425138\",\n\t\t\t\t\tname: \"SET_GROUP_DESCRIPTION\",\n\t\t\t\t\tdescription: \"Set the free-text description of the group. The description is at most 2000 characters.\",\n\t\t\t\t\tschema: \"input SetGroupDescriptionInput {\\n description: String!\\n}\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [{\n\t\t\t\t\t\tid: \"9f0f77a4-6a86-4f5c-9a3f-13a44be29de3\",\n\t\t\t\t\t\tcode: \"InvalidGroupDescription\",\n\t\t\t\t\t\tname: \"InvalidGroupDescription\",\n\t\t\t\t\t\tdescription: \"The group description is longer than 2000 characters.\",\n\t\t\t\t\t\ttemplate: \"\"\n\t\t\t\t\t}],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"global\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"e7990be2-2e40-4624-9f96-df759703ba6b\",\n\t\t\t\t\tname: \"ADD_MEMBER\",\n\t\t\t\t\tdescription: \"Add a member address to the group. The address must be non-empty after trimming, must not already be a member under case-insensitive comparison, and the group must be below the member cap.\",\n\t\t\t\t\tschema: \"input AddMemberInput {\\n address: String!\\n}\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: \"3f2504e0-4f89-41d3-9a0c-0305e82c3301\",\n\t\t\t\t\t\t\tcode: \"InvalidMemberAddress\",\n\t\t\t\t\t\t\tname: \"InvalidMemberAddress\",\n\t\t\t\t\t\t\tdescription: \"The member address is empty after trimming.\",\n\t\t\t\t\t\t\ttemplate: \"\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: \"b2c1a9de-58e6-4f3f-9f2a-7f6b1e2d4c5a\",\n\t\t\t\t\t\t\tcode: \"DuplicateMember\",\n\t\t\t\t\t\t\tname: \"DuplicateMember\",\n\t\t\t\t\t\t\tdescription: \"The address is already a member of the group under case-insensitive comparison.\",\n\t\t\t\t\t\t\ttemplate: \"\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: \"c4d5e6f7-0a1b-4c2d-8e3f-9a0b1c2d3e4f\",\n\t\t\t\t\t\t\tcode: \"GroupMemberLimitExceeded\",\n\t\t\t\t\t\t\tname: \"GroupMemberLimitExceeded\",\n\t\t\t\t\t\t\tdescription: \"The group already holds the maximum number of members.\",\n\t\t\t\t\t\t\ttemplate: \"\"\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"global\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: \"b1309319-48b7-42b2-a40e-1fecef9a09a4\",\n\t\t\t\t\tname: \"REMOVE_MEMBER\",\n\t\t\t\t\tdescription: \"Remove a member address from the group, matched case-insensitively. Removing an address that is not a member is an error.\",\n\t\t\t\t\tschema: \"input RemoveMemberInput {\\n address: String!\\n}\",\n\t\t\t\t\ttemplate: \"\",\n\t\t\t\t\treducer: \"\",\n\t\t\t\t\terrors: [{\n\t\t\t\t\t\tid: \"d6e7f8a9-1b2c-4d3e-9f4a-0b1c2d3e4f5a\",\n\t\t\t\t\t\tcode: \"MemberNotFound\",\n\t\t\t\t\t\tname: \"MemberNotFound\",\n\t\t\t\t\t\tdescription: \"The address is not a member of the group under case-insensitive comparison.\",\n\t\t\t\t\t\ttemplate: \"\"\n\t\t\t\t\t}],\n\t\t\t\t\texamples: [],\n\t\t\t\t\tscope: \"global\"\n\t\t\t\t}\n\t\t\t]\n\t\t}],\n\t\tversion: 1,\n\t\tchangeLog: []\n\t}]\n};\n//#endregion\n//#region document-models/reactor-group/v1/gen/group/error.ts\nvar InvalidGroupName = class extends Error {\n\terrorCode = \"InvalidGroupName\";\n\tconstructor(message = \"InvalidGroupName\") {\n\t\tsuper(message);\n\t}\n};\nvar InvalidGroupDescription = class extends Error {\n\terrorCode = \"InvalidGroupDescription\";\n\tconstructor(message = \"InvalidGroupDescription\") {\n\t\tsuper(message);\n\t}\n};\nvar InvalidMemberAddress = class extends Error {\n\terrorCode = \"InvalidMemberAddress\";\n\tconstructor(message = \"InvalidMemberAddress\") {\n\t\tsuper(message);\n\t}\n};\nvar DuplicateMember = class extends Error {\n\terrorCode = \"DuplicateMember\";\n\tconstructor(message = \"DuplicateMember\") {\n\t\tsuper(message);\n\t}\n};\nvar GroupMemberLimitExceeded = class extends Error {\n\terrorCode = \"GroupMemberLimitExceeded\";\n\tconstructor(message = \"GroupMemberLimitExceeded\") {\n\t\tsuper(message);\n\t}\n};\nvar MemberNotFound = class extends Error {\n\terrorCode = \"MemberNotFound\";\n\tconstructor(message = \"MemberNotFound\") {\n\t\tsuper(message);\n\t}\n};\n//#endregion\n//#region document-models/reactor-group/v1/src/reducers/group.ts\n/** Every replica folds group state during auth evaluation, so membership is capped. */\nconst MAX_GROUP_MEMBERS = 1e3;\nconst MAX_GROUP_DESCRIPTION_LENGTH = 2e3;\n/** Addresses are compared case-insensitively, matching { address } principals. */\nfunction sameAddress(a, b) {\n\treturn a.toLowerCase() === b.toLowerCase();\n}\nconst reactorGroupGroupOperations = {\n\tsetGroupNameOperation(state, action) {\n\t\tconst name = action.input.name.trim();\n\t\tif (name === \"\" || name.length > 200) throw new InvalidGroupName(`Group name must be non-empty and at most 200 characters`);\n\t\tstate.name = name;\n\t},\n\tsetGroupDescriptionOperation(state, action) {\n\t\tconst description = action.input.description;\n\t\tif (description.length > 2e3) throw new InvalidGroupDescription(`Group description must be at most ${MAX_GROUP_DESCRIPTION_LENGTH} characters`);\n\t\tstate.description = description;\n\t},\n\taddMemberOperation(state, action) {\n\t\tconst address = action.input.address.trim();\n\t\tif (address === \"\") throw new InvalidMemberAddress(\"Member address must be non-empty\");\n\t\tif (state.members.some((member) => sameAddress(member, address))) throw new DuplicateMember(`Address is already a member: ${address}`);\n\t\tif (state.members.length >= 1e3) throw new GroupMemberLimitExceeded(`A group holds at most ${MAX_GROUP_MEMBERS} members`);\n\t\tstate.members.push(address);\n\t},\n\tremoveMemberOperation(state, action) {\n\t\tconst address = action.input.address.trim();\n\t\tconst index = state.members.findIndex((member) => sameAddress(member, address));\n\t\tif (index === -1) throw new MemberNotFound(`Address is not a member: ${address}`);\n\t\tstate.members.splice(index, 1);\n\t}\n};\n//#endregion\n//#region document-models/reactor-group/v1/gen/reducer.ts\nconst stateReducer = (state, action, dispatch) => {\n\tif (isDocumentAction(action)) return state;\n\tswitch (action.type) {\n\t\tcase \"SET_GROUP_NAME\":\n\t\t\tSetGroupNameInputSchema().parse(action.input);\n\t\t\treactorGroupGroupOperations.setGroupNameOperation(state[action.scope], action, dispatch);\n\t\t\tbreak;\n\t\tcase \"SET_GROUP_DESCRIPTION\":\n\t\t\tSetGroupDescriptionInputSchema().parse(action.input);\n\t\t\treactorGroupGroupOperations.setGroupDescriptionOperation(state[action.scope], action, dispatch);\n\t\t\tbreak;\n\t\tcase \"ADD_MEMBER\":\n\t\t\tAddMemberInputSchema().parse(action.input);\n\t\t\treactorGroupGroupOperations.addMemberOperation(state[action.scope], action, dispatch);\n\t\t\tbreak;\n\t\tcase \"REMOVE_MEMBER\":\n\t\t\tRemoveMemberInputSchema().parse(action.input);\n\t\t\treactorGroupGroupOperations.removeMemberOperation(state[action.scope], action, dispatch);\n\t\t\tbreak;\n\t\tdefault: return state;\n\t}\n};\nconst reducer = createReducer(stateReducer);\n//#endregion\n//#region document-models/reactor-group/upgrades/versions.ts\nconst supportedVersions = [1];\nconst latestVersion = supportedVersions[0];\n//#endregion\n//#region document-models/reactor-group/upgrades/upgrade-manifest.ts\nconst reactorGroupUpgradeManifest = {\n\tdocumentType: \"powerhouse/reactor-group\",\n\tlatestVersion,\n\tsupportedVersions,\n\tupgrades: {}\n};\n//#endregion\n//#region document-models/reactor-group/v1/gen/document-type.ts\n/**\n* WARNING: DO NOT EDIT\n* This file is auto-generated and updated by codegen\n*/\nconst reactorGroupDocumentType = \"powerhouse/reactor-group\";\n//#endregion\n//#region document-models/reactor-group/v1/gen/document-schema.ts\n/**\n* WARNING: DO NOT EDIT\n* This file is auto-generated and updated by codegen\n*/\n/** Schema for validating the header object of a ReactorGroup document */\nconst ReactorGroupDocumentHeaderSchema = BaseDocumentHeaderSchema.extend({ documentType: z.literal(reactorGroupDocumentType) });\n/** Schema for validating the state object of a ReactorGroup document */\nconst ReactorGroupPHStateSchema = BaseDocumentStateSchema.extend({ global: ReactorGroupStateSchema() });\nconst ReactorGroupDocumentSchema = z.object({\n\theader: ReactorGroupDocumentHeaderSchema,\n\tstate: ReactorGroupPHStateSchema,\n\tinitialState: ReactorGroupPHStateSchema\n});\n/** Simple helper function to check if a state object is a ReactorGroup document state object */\nfunction isReactorGroupState(state) {\n\treturn ReactorGroupPHStateSchema.safeParse(state).success;\n}\n/** Simple helper function to assert that a document state object is a ReactorGroup document state object */\nfunction assertIsReactorGroupState(state) {\n\tReactorGroupPHStateSchema.parse(state);\n}\n/** Simple helper function to check if a document is a ReactorGroup document */\nfunction isReactorGroupDocument(document) {\n\treturn ReactorGroupDocumentSchema.safeParse(document).success;\n}\n/** Simple helper function to assert that a document is a ReactorGroup document */\nfunction assertIsReactorGroupDocument(document) {\n\tReactorGroupDocumentSchema.parse(document);\n}\n//#endregion\n//#region document-models/reactor-group/v1/gen/utils.ts\nconst initialGlobalState = {\n\tname: \"\",\n\tdescription: \"\",\n\tmembers: []\n};\nconst initialLocalState = {};\nconst utils$1 = {\n\tfileExtension: \".phrg\",\n\tcreateState(state) {\n\t\treturn {\n\t\t\t...createBaseState(state?.auth, {\n\t\t\t\tversion: 1,\n\t\t\t\t...state?.document\n\t\t\t}),\n\t\t\tglobal: {\n\t\t\t\t...initialGlobalState,\n\t\t\t\t...state?.global\n\t\t\t},\n\t\t\tlocal: {\n\t\t\t\t...initialLocalState,\n\t\t\t\t...state?.local\n\t\t\t}\n\t\t};\n\t},\n\tcreateDocument(state) {\n\t\treturn baseCreateDocument(utils$1.createState, state, reactorGroupDocumentType);\n\t},\n\tsaveToFileHandle(document, input) {\n\t\treturn baseSaveToFileHandle(document, input);\n\t},\n\tloadFromInput(input) {\n\t\treturn baseLoadFromInputVersioned(input, {\n\t\t\treducers: { 1: reducer },\n\t\t\tupgradeManifest: reactorGroupUpgradeManifest\n\t\t});\n\t},\n\tisStateOfType(state) {\n\t\treturn isReactorGroupState(state);\n\t},\n\tassertIsStateOfType(state) {\n\t\treturn assertIsReactorGroupState(state);\n\t},\n\tisDocumentOfType(document) {\n\t\treturn isReactorGroupDocument(document);\n\t},\n\tassertIsDocumentOfType(document) {\n\t\treturn assertIsReactorGroupDocument(document);\n\t}\n};\n//#endregion\n//#region document-models/reactor-group/v1/src/utils.ts\nvar utils_exports = /* @__PURE__ */ __exportAll({});\n//#endregion\n//#region document-models/reactor-group/v1/utils.ts\n/** Utils for the ReactorGroup document model */\nconst utils = {\n\t...utils$1,\n\t...utils_exports\n};\n//#endregion\n//#region document-models/reactor-group/v1/module.ts\n/** Document model module for the ReactorGroup document type */\nconst ReactorGroup = {\n\tversion: 1,\n\treducer,\n\tactions,\n\tutils,\n\tdocumentModel: createState(defaultBaseState(), documentModel)\n};\n//#endregion\nexport { definedNonNullAnySchema as A, setGroupDescription as C, RemoveMemberInputSchema as D, ReactorGroupStateSchema as E, SetGroupDescriptionInputSchema as O, removeMember as S, AddMemberInputSchema as T, reducer as _, utils$1 as a, addMember as b, ReactorGroupPHStateSchema as c, isReactorGroupDocument as d, isReactorGroupState as f, supportedVersions as g, latestVersion as h, initialLocalState as i, isDefinedNonNullAny as j, SetGroupNameInputSchema as k, assertIsReactorGroupDocument as l, reactorGroupUpgradeManifest as m, utils as n, ReactorGroupDocumentHeaderSchema as o, reactorGroupDocumentType as p, initialGlobalState as r, ReactorGroupDocumentSchema as s, ReactorGroup as t, assertIsReactorGroupState as u, documentModel as v, setGroupName as w, creators_exports as x, actions as y };\n\n//# sourceMappingURL=module-1TFqLbxn.js.map","import { reactorDriveDocumentModelModule } from \"@powerhousedao/reactor-drive\";\nimport { ReactorGroupV1 } from \"@powerhousedao/reactor-group\";\nimport { driveDocumentModelModule } from \"@powerhousedao/shared/document-drive\";\nimport { type DocumentModelModule } from \"@powerhousedao/shared/document-model\";\nimport { documentModelDocumentModelModule } from \"document-model\";\nexport const documentModels: DocumentModelModule<any>[] = [\n documentModelDocumentModelModule,\n driveDocumentModelModule,\n reactorDriveDocumentModelModule,\n ReactorGroupV1 as unknown as DocumentModelModule<any>,\n];\n","export const editors = [];","import type { Manifest } from \"@powerhousedao/shared/document-model\";\nimport manifestJson from \"./powerhouse.manifest.json\" with { type: \"json\" };\nexport { documentModels } from \"./document-models/document-models.js\";\nexport { editors } from \"./editors/editors.js\";\nexport const manifest: Manifest = manifestJson;\n"],"mappings":";;;;;;;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A2B,MAAM,QAAQ;AAC1C;AAGA,MAAM,qBAAqB;CAC1B,MAAM;CACN,aAAa;CACb,SAAS,CAAC;AACX;AACA,MAAM,oBAAoB,CAAC;AAC3B,MAAM,UAAU;CACf,eAAe;CACf,YAAY,OAAO;EAClB,OAAO;GACN,GAAG,gBAAgB,OAAO,MAAM;IAC/B,SAAS;IACT,GAAG,OAAO;GACX,CAAC;GACD,QAAQ;IACP,GAAG;IACH,GAAG,OAAO;GACX;GACA,OAAO;IACN,GAAG;IACH,GAAG,OAAO;GACX;EACD;CACD;CACA,eAAe,OAAO;EACrB,OAAOC,qBAAmB,QAAQ,aAAa,OAAO,wBAAwB;CAC/E;CACA,iBAAiB,UAAU,OAAO;EACjC,OAAOC,uBAAqB,UAAU,KAAK;CAC5C;CACA,cAAc,OAAO;EACpB,OAAO,2BAA2B,OAAO;GACxC,UAAU,EAAE,GAAG,QAAQ;GACvB,iBAAiB;EAClB,CAAC;CACF;CACA,cAAc,OAAO;EACpB,OAAO,oBAAoB,KAAK;CACjC;CACA,oBAAoB,OAAO;EAC1B,OAAO,0BAA0B,KAAK;CACvC;CACA,iBAAiB,UAAU;EAC1B,OAAO,uBAAuB,QAAQ;CACvC;CACA,uBAAuB,UAAU;EAChC,OAAO,6BAA6B,QAAQ;CAC7C;AACD;AAGA,IAAI,gBAAgC,4BAAY,CAAC,CAAC;;AAWlD,MAAM,eAAe;CACpB,SAAS;CACT;CACA;CACA;EAVA,GAAG;EACH,GAAG;CASH;CACA,eAAeC,cAAYC,mBAAiB,GAAG,aAAa;AAC7D;;;ACjYA,MAAa,iBAA6C;CACxD;CACA;CACA;CACAC;AACF;;;ACVA,MAAa,UAAU,CAAC;;;ACIxB,MAAa,WAAqBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/powerhouse-vetra-packages",
|
|
3
|
-
"version": "6.2.3-dev.
|
|
3
|
+
"version": "6.2.3-dev.92",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "",
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"@codemirror/view": "6.36.7",
|
|
81
81
|
"@graphql-tools/utils": "11.0.0",
|
|
82
82
|
"@hookform/resolvers": "^5.0.1",
|
|
83
|
-
"@powerhousedao/reactor-drive": "6.2.3-dev.
|
|
84
|
-
"@powerhousedao/reactor-group": "6.2.3-dev.
|
|
83
|
+
"@powerhousedao/reactor-drive": "6.2.3-dev.92",
|
|
84
|
+
"@powerhousedao/reactor-group": "6.2.3-dev.92",
|
|
85
85
|
"@radix-ui/react-label": "^2.1.4",
|
|
86
86
|
"@radix-ui/react-slot": "^1.2.0",
|
|
87
87
|
"@radix-ui/react-tabs": "^1.1.9",
|
|
@@ -95,15 +95,15 @@
|
|
|
95
95
|
"thememirror": "^2.0.1"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
|
-
"@powerhousedao/design-system": "6.2.3-dev.
|
|
99
|
-
"@powerhousedao/reactor-browser": "6.2.3-dev.
|
|
100
|
-
"@powerhousedao/shared": "6.2.3-dev.
|
|
98
|
+
"@powerhousedao/design-system": "6.2.3-dev.92",
|
|
99
|
+
"@powerhousedao/reactor-browser": "6.2.3-dev.92",
|
|
100
|
+
"@powerhousedao/shared": "6.2.3-dev.92",
|
|
101
101
|
"@tailwindcss/cli": "4.2.2",
|
|
102
102
|
"@testing-library/react": "^16.3.0",
|
|
103
103
|
"@types/react": "19.2.14",
|
|
104
104
|
"@types/react-dom": "19.2.3",
|
|
105
105
|
"clsx": "^2.1.1",
|
|
106
|
-
"document-model": "6.2.3-dev.
|
|
106
|
+
"document-model": "6.2.3-dev.92",
|
|
107
107
|
"graphql": "^16",
|
|
108
108
|
"happy-dom": "^20.8.9",
|
|
109
109
|
"react": "19.2.6",
|