@ibodr/schema 0.0.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/misc/id-validator.ts","../src/assets/DrBaseAsset.ts","../src/assets/DrBookmarkAsset.ts","../src/assets/DrImageAsset.ts","../src/assets/DrVideoAsset.ts","../src/misc/geometry-types.ts","../src/misc/DrOpacity.ts","../src/shapes/DrBaseShape.ts","../src/bindings/DrBaseBinding.ts","../src/records/DrBinding.ts","../src/misc/DrRichText.ts","../src/styles/StyleProp.ts","../src/records/DrShape.ts","../src/recordsWithProps.ts","../src/styles/DrColorStyle.ts","../src/styles/DrDashStyle.ts","../src/styles/DrFillStyle.ts","../src/styles/DrFontStyle.ts","../src/styles/DrSizeStyle.ts","../src/shapes/DrArrowShape.ts","../src/bindings/DrArrowBinding.ts","../src/records/DrCamera.ts","../src/misc/DrCursor.ts","../src/misc/DrColor.ts","../src/misc/DrScribble.ts","../src/records/DrPage.ts","../src/records/DrInstance.ts","../src/records/DrPageState.ts","../src/records/DrPointer.ts","../src/records/DrPresence.ts","../src/createPresenceStateDerivation.ts","../src/records/DrAsset.ts","../src/records/DrCustomRecord.ts","../src/records/DrDocument.ts","../src/records/DrUser.ts","../src/shapes/DrBookmarkShape.ts","../src/misc/b64Vecs.ts","../src/shapes/DrDrawShape.ts","../src/shapes/DrEmbedShape.ts","../src/shapes/DrFrameShape.ts","../src/styles/DrHorizontalAlignStyle.ts","../src/styles/DrVerticalAlignStyle.ts","../src/shapes/DrGeoShape.ts","../src/shapes/DrGroupShape.ts","../src/shapes/DrHighlightShape.ts","../src/shapes/DrImageShape.ts","../src/shapes/DrLineShape.ts","../src/shapes/DrNoteShape.ts","../src/styles/DrTextAlignStyle.ts","../src/shapes/DrTextShape.ts","../src/shapes/DrVideoShape.ts","../src/store-migrations.ts","../src/DrStore.ts","../src/createDrSchema.ts","../src/misc/DrHandle.ts","../src/translations/languages.ts","../src/translations/translations.ts","../src/index.ts"],"names":["T","Versions","createMigrationIds","createRecordMigrationSequence","text","uniqueId","mapObjectMapValues","createRecordType","result","createMigrationSequence","assert","frac","computed","structuredClone","sortByIndex"],"mappings":";;;;;;AAuBO,SAAS,YACf,MAAA,EACkB;AAClB,EAAA,OAAO,CAAA,CAAE,MAAA,CAAO,MAAA,CAAO,CAAC,EAAA,KAAO;AAC9B,IAAA,IAAI,CAAC,EAAA,CAAG,UAAA,CAAW,CAAA,EAAG,MAAM,GAAG,CAAA,EAAG;AACjC,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,EAAG,MAAM,CAAA,qBAAA,EAAwB,MAAM,CAAA,EAAA,CAAI,CAAA;AAAA,IAC5D;AACA,IAAA,OAAO,EAAA;AAAA,EACR,CAAC,CAAA;AACF;;;AC8BO,IAAM,gBAAA,GAAmB,YAAuB,OAAO;AAyCvD,SAAS,oBAAA,CAKf,IAAA,EACA,KAAA,EACA,IAAA,EACC;AAED,EAAA,MAAM,cAAA,GACL,KAAA,YAAiBA,CAAAA,CAAE,SAAA,GAAY,KAAA,GAAQ,QAAQA,CAAAA,CAAE,MAAA,CAAO,KAAK,CAAA,GAAKA,CAAAA,CAAE,SAAA;AAErE,EAAA,OAAOA,EAAE,MAAA,CAAiC;AAAA,IACzC,EAAA,EAAI,gBAAA;AAAA,IACJ,QAAA,EAAUA,CAAAA,CAAE,OAAA,CAAQ,OAAO,CAAA;AAAA,IAC3B,IAAA,EAAMA,CAAAA,CAAE,OAAA,CAAQ,IAAI,CAAA;AAAA,IACpB,KAAA,EAAO,cAAA;AAAA,IACP,MAAM,IAAA,GAAOA,CAAAA,CAAE,MAAA,CAAO,IAAI,IAAKA,CAAAA,CAAE;AAAA,GACjC,CAAA;AACF;ACtGO,IAAM,kBAAA,GAAqB;AAAA,EACjC,OAAOA,CAAAA,CAAE,MAAA;AAAA,EACT,aAAaA,CAAAA,CAAE,MAAA;AAAA,EACf,OAAOA,CAAAA,CAAE,MAAA;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AiB;AACpB,MAAA,OAAO,eAAA;AAAA,IACR;AAAA,EACD;AACA,EAAA,OAAO,IAAA;AACR;AAwBA,IAAM,sBAAA,GAAqE;AAAA,EAC1E,EAAA,EAAI,OAAA;AAAA,EACJ,EAAA,EAAI,OAAA;AAAA,EACJ,EAAA,EAAI,OAAA;AAAA,EACJ,EAAA,EAAI;AACL,CAAA;AA+CA,SAAS,mBAAmB,MAAA,EAA6C;AAIxE,EAAA,MAAM,UAAA,GAAa,UAAU,IAAA,CAAK,CAAC,MAAM,CAAA,CAAE,MAAA,KAAW,MAAA,CAAO,WAAA,EAAa,CAAA;AAC1E,EAAA,IAAI,UAAA,EAAY;AACf,IAAA,OAAO,UAAA,CAAW,MAAA;AAAA,EACnB;AAGA,EAAA,MAAM,CAAC,QAAA,EAAU,MAAM,CAAA,GAAI,MAAA,CAAO,KAAA,CAAM,MAAM,CAAA,CAAE,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,CAAE,aAAa,CAAA;AAK1E,EAAA,IAAI,MAAA,EAAQ;AACX,IAAA,MAAM,gBAAgB,SAAA,CAAU,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,WAAW,QAAQ,CAAA;AACjE,IAAA,IAAI,aAAA,EAAe;AAClB,MAAA,OAAO,aAAA,CAAc,MAAA;AAAA,IACtB;AAAA,EACD;AAOA,EAAA,IAAI,YAAY,sBAAA,EAAwB;AACvC,IAAA,OAAO,uBAAuB,QAAQ,CAAA;AAAA,EACvC;AAIA,EAAA,OAAO,IAAA;AACR;;;AC0IA,0BAAA;AAAA,EACE,eAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAAA","file":"index.mjs","sourcesContent":["import type { RecordId, UnknownRecord } from '@ibodr/store'\nimport { T } from '@ibodr/validate'\n\n/**\n * Creates a validator for typed record IDs that ensures they follow the correct\n * format with the specified prefix. Record IDs in tldraw follow the pattern\n * \"prefix:identifier\" where the prefix indicates the record type.\n *\n * @param prefix - The required prefix for the ID (e.g., 'shape', 'page', 'asset')\n * @returns A validator that checks the ID format and returns the typed ID\n * @public\n * @example\n * ```ts\n * const shapeIdValidator = idValidator<DrShapeId>('shape')\n * const validId = shapeIdValidator.validate('shape:abc123') // Returns 'shape:abc123' as DrShapeId\n *\n * const pageIdValidator = idValidator<DrPageId>('page')\n * const pageId = pageIdValidator.validate('page:main') // Returns 'page:main' as DrPageId\n *\n * // This would throw an error:\n * // shapeIdValidator.validate('page:abc123') // Error: shape ID must start with \"shape:\"\n * ```\n */\nexport function idValidator<Id extends RecordId<UnknownRecord>>(\n\tprefix: Id['__type__']['typeName']\n): T.Validator<Id> {\n\treturn T.string.refine((id) => {\n\t\tif (!id.startsWith(`${prefix}:`)) {\n\t\t\tthrow new Error(`${prefix} ID must start with \"${prefix}:\"`)\n\t\t}\n\t\treturn id as Id\n\t})\n}\n","import { BaseRecord } from '@ibodr/store'\nimport { JsonObject } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { idValidator } from '../misc/id-validator'\nimport { DrAssetId } from '../records/DrAsset'\n\n/**\n * Base interface for all asset records in tldraw. Assets represent external resources\n * like images, videos, or bookmarks that shapes can reference. This interface extends\n * the base record system with asset-specific typing.\n *\n * @param Type - The specific asset type identifier (e.g., 'image', 'video', 'bookmark')\n * @param Props - The properties object specific to this asset type\n *\n * @example\n * ```ts\n * // Define a custom asset type\n * interface MyCustomAsset extends DrBaseAsset<'custom', { url: string; title: string }> {}\n *\n * const customAsset: MyCustomAsset = {\n * id: 'asset:custom123',\n * typeName: 'asset',\n * type: 'custom',\n * props: {\n * url: 'https://example.com',\n * title: 'My Custom Asset'\n * },\n * meta: {}\n * }\n * ```\n *\n * @public\n */\nexport interface DrBaseAsset<Type extends string, Props> extends BaseRecord<'asset', DrAssetId> {\n\t/** The specific type of this asset (e.g., 'image', 'video', 'bookmark') */\n\ttype: Type\n\t/** Type-specific properties for this asset */\n\tprops: Props\n\t/** User-defined metadata that can be attached to this asset */\n\tmeta: JsonObject\n}\n\n/**\n * A validator for asset record type IDs. This validator ensures that asset IDs\n * follow the correct format and type structure required by tldraw's asset system.\n * Asset IDs are prefixed with 'asset:' followed by a unique identifier.\n *\n * @example\n * ```ts\n * import { assetIdValidator } from '@ibodr/schema'\n *\n * // Valid asset ID\n * const validId = 'asset:abc123'\n * console.log(assetIdValidator.isValid(validId)) // true\n *\n * // Invalid asset ID\n * const invalidId = 'shape:abc123'\n * console.log(assetIdValidator.isValid(invalidId)) // false\n * ```\n *\n * @public\n */\nexport const assetIdValidator = idValidator<DrAssetId>('asset')\n\n/**\n * Creates a validator for a specific asset record type. This factory function generates\n * a complete validator that validates the entire asset record structure including the\n * base properties (id, typeName, type, meta) and the type-specific props.\n *\n * @param type - The asset type identifier (e.g., 'image', 'video', 'bookmark')\n * @param props - A validator or per-key validator record for the asset's type-specific properties\n * @param meta - An optional per-key validator record for the asset's meta properties\n * @returns A complete validator for the asset record type\n *\n * @example\n * ```ts\n * import { createAssetValidator, DrBaseAsset } from '@ibodr/schema'\n * import { T } from '@ibodr/validate'\n *\n * // Define a custom asset type\n * type DrCustomAsset = DrBaseAsset<'custom', {\n * url: string\n * title: string\n * description?: string\n * }>\n *\n * // Create validator using a per-key record (recommended)\n * const customAssetValidator = createAssetValidator('custom', {\n * url: T.string,\n * title: T.string,\n * description: T.string.optional()\n * })\n *\n * // Or using a T.object validator\n * const customAssetValidator2 = createAssetValidator('custom', T.object({\n * url: T.string,\n * title: T.string,\n * description: T.string.optional()\n * }))\n * ```\n *\n * @public\n */\nexport function createAssetValidator<\n\tType extends string,\n\tProps extends JsonObject,\n\tMeta extends JsonObject = JsonObject,\n>(\n\ttype: Type,\n\tprops?: T.Validator<Props> | { [K in keyof Props]: T.Validatable<Props[K]> },\n\tmeta?: { [K in keyof Meta]: T.Validatable<Meta[K]> }\n) {\n\t// Determine if props is a Validator instance or a per-key record\n\tconst propsValidator =\n\t\tprops instanceof T.Validator ? props : props ? T.object(props) : (T.jsonValue as any)\n\n\treturn T.object<DrBaseAsset<Type, Props>>({\n\t\tid: assetIdValidator,\n\t\ttypeName: T.literal('asset'),\n\t\ttype: T.literal(type),\n\t\tprops: propsValidator,\n\t\tmeta: meta ? T.object(meta) : (T.jsonValue as T.ObjectValidator<JsonObject>),\n\t})\n}\n","import { createMigrationIds, createRecordMigrationSequence } from '@ibodr/store'\nimport { T } from '@ibodr/validate'\nimport { RecordProps } from '../recordsWithProps'\nimport { DrBaseAsset, createAssetValidator } from './DrBaseAsset'\n\n/**\n * An asset used for URL bookmarks, used by the DrBookmarkShape.\n *\n * @public */\nexport type DrBookmarkAsset = DrBaseAsset<\n\t'bookmark',\n\t{\n\t\ttitle: string\n\t\tdescription: string\n\t\timage: string\n\t\tfavicon: string\n\t\tsrc: string | null\n\t}\n>\n\n/** @public */\nexport const bookmarkAssetProps = {\n\ttitle: T.string,\n\tdescription: T.string,\n\timage: T.string,\n\tfavicon: T.string,\n\tsrc: T.srcUrl.nullable(),\n} satisfies RecordProps<DrBookmarkAsset>\n\n/** Validator for bookmark assets. @public */\nexport const bookmarkAssetValidator: T.Validator<DrBookmarkAsset> = createAssetValidator(\n\t'bookmark',\n\tT.object(bookmarkAssetProps)\n)\n\nconst Versions = createMigrationIds('com.draw.asset.bookmark', {\n\tMakeUrlsValid: 1,\n\tAddFavicon: 2,\n} as const)\n\n/**\n * Migration version identifiers for bookmark assets. These versions track\n * the evolution of the bookmark asset schema over time.\n *\n * Available versions:\n * - `MakeUrlsValid` (v1): Ensures src URLs are valid or empty\n * - `AddFavicon` (v2): Adds favicon property to bookmark assets\n *\n * @example\n * ```ts\n * import { bookmarkAssetVersions } from '@ibodr/schema'\n *\n * // Check if a migration exists\n * console.log(bookmarkAssetVersions.AddFavicon) // 2\n * ```\n *\n * @public\n */\nexport { Versions as bookmarkAssetVersions }\n\n/**\n * Migration sequence for bookmark assets. Handles the evolution of bookmark asset\n * data structure over time, ensuring backward and forward compatibility.\n *\n * The migration sequence includes:\n * 1. **MakeUrlsValid** (v1): Validates and cleans up src URLs, setting invalid URLs to empty string\n * 2. **AddFavicon** (v2): Adds the favicon property and validates it, setting invalid favicons to empty string\n *\n * @public\n */\nexport const bookmarkAssetMigrations = createRecordMigrationSequence({\n\tsequenceId: 'com.draw.asset.bookmark',\n\trecordType: 'asset',\n\tfilter: (asset) => (asset as DrBookmarkAsset).type === 'bookmark',\n\tsequence: [\n\t\t{\n\t\t\tid: Versions.MakeUrlsValid,\n\t\t\tup: (asset: any) => {\n\t\t\t\tif (!T.srcUrl.isValid(asset.props.src)) {\n\t\t\t\t\tasset.props.src = ''\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (_asset) => {\n\t\t\t\t// noop\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddFavicon,\n\t\t\tup: (asset: any) => {\n\t\t\t\tif (!T.srcUrl.isValid(asset.props.favicon)) {\n\t\t\t\t\tasset.props.favicon = ''\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (asset: any) => {\n\t\t\t\tdelete asset.props.favicon\n\t\t\t},\n\t\t},\n\t],\n})\n","import { createMigrationIds, createRecordMigrationSequence } from '@ibodr/store'\nimport { T } from '@ibodr/validate'\nimport { RecordProps } from '../recordsWithProps'\nimport { DrBaseAsset, createAssetValidator } from './DrBaseAsset'\n\n/**\n * An asset for images such as PNGs and JPEGs, used by the DrImageShape.\n *\n * @public */\nexport type DrImageAsset = DrBaseAsset<\n\t'image',\n\t{\n\t\tw: number\n\t\th: number\n\t\tname: string\n\t\tisAnimated: boolean\n\t\tmimeType: string | null\n\t\tsrc: string | null\n\t\tfileSize?: number\n\t\tpixelRatio?: number\n\t}\n>\n\n/** @public */\nexport const imageAssetProps = {\n\tw: T.number,\n\th: T.number,\n\tname: T.string,\n\tisAnimated: T.boolean,\n\tmimeType: T.string.nullable(),\n\tsrc: T.srcUrl.nullable(),\n\tfileSize: T.nonZeroNumber.optional(),\n\tpixelRatio: T.positiveNumber.optional(),\n} satisfies RecordProps<DrImageAsset>\n\n/** Validator for image assets. @public */\nexport const imageAssetValidator: T.Validator<DrImageAsset> = createAssetValidator(\n\t'image',\n\tT.object(imageAssetProps)\n)\n\nconst Versions = createMigrationIds('com.draw.asset.image', {\n\tAddIsAnimated: 1,\n\tRenameWidthHeight: 2,\n\tMakeUrlsValid: 3,\n\tAddFileSize: 4,\n\tMakeFileSizeOptional: 5,\n\tAddPixelRatio: 6,\n} as const)\n\n/**\n * Migration version identifiers for image assets. These define the different schema versions\n * that image assets have gone through during the evolution of the tldraw data model.\n *\n * @example\n * ```ts\n * import { imageAssetVersions } from '@ibodr/schema'\n *\n * // Access specific version IDs\n * console.log(imageAssetVersions.AddIsAnimated) // Version when isAnimated was added\n * console.log(imageAssetVersions.RenameWidthHeight) // Version when width/height became w/h\n * ```\n *\n * @public\n */\nexport { Versions as imageAssetVersions }\n\n/**\n * Migration sequence for image assets. Handles the evolution of the image asset schema\n * over time, providing both forward (up) and backward (down) migration functions to\n * maintain compatibility across different versions of the tldraw data model.\n *\n * The sequence includes migrations for:\n * - Adding the `isAnimated` property to track animated images\n * - Renaming `width`/`height` properties to shorter `w`/`h` names\n * - Ensuring URLs are valid format\n * - Adding file size tracking\n * - Making file size optional\n *\n *\n * @public\n */\nexport const imageAssetMigrations = createRecordMigrationSequence({\n\tsequenceId: 'com.draw.asset.image',\n\trecordType: 'asset',\n\tfilter: (asset) => (asset as DrImageAsset).type === 'image',\n\tsequence: [\n\t\t{\n\t\t\tid: Versions.AddIsAnimated,\n\t\t\tup: (asset: any) => {\n\t\t\t\tasset.props.isAnimated = false\n\t\t\t},\n\t\t\tdown: (asset: any) => {\n\t\t\t\tdelete asset.props.isAnimated\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.RenameWidthHeight,\n\t\t\tup: (asset: any) => {\n\t\t\t\tasset.props.w = asset.props.width\n\t\t\t\tasset.props.h = asset.props.height\n\t\t\t\tdelete asset.props.width\n\t\t\t\tdelete asset.props.height\n\t\t\t},\n\t\t\tdown: (asset: any) => {\n\t\t\t\tasset.props.width = asset.props.w\n\t\t\t\tasset.props.height = asset.props.h\n\t\t\t\tdelete asset.props.w\n\t\t\t\tdelete asset.props.h\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.MakeUrlsValid,\n\t\t\tup: (asset: any) => {\n\t\t\t\tif (!T.srcUrl.isValid(asset.props.src)) {\n\t\t\t\t\tasset.props.src = ''\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (_asset) => {\n\t\t\t\t// noop\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddFileSize,\n\t\t\tup: (asset: any) => {\n\t\t\t\tasset.props.fileSize = -1\n\t\t\t},\n\t\t\tdown: (asset: any) => {\n\t\t\t\tdelete asset.props.fileSize\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.MakeFileSizeOptional,\n\t\t\tup: (asset: any) => {\n\t\t\t\tif (asset.props.fileSize === -1) {\n\t\t\t\t\tasset.props.fileSize = undefined\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (asset: any) => {\n\t\t\t\tif (asset.props.fileSize === undefined) {\n\t\t\t\t\tasset.props.fileSize = -1\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddPixelRatio,\n\t\t\tup: (_asset: any) => {\n\t\t\t\t// noop — pixelRatio is optional and undefined by default\n\t\t\t},\n\t\t\tdown: (asset: any) => {\n\t\t\t\tdelete asset.props.pixelRatio\n\t\t\t},\n\t\t},\n\t],\n})\n","import { createMigrationIds, createRecordMigrationSequence } from '@ibodr/store'\nimport { T } from '@ibodr/validate'\nimport { RecordProps } from '../recordsWithProps'\nimport { DrBaseAsset, createAssetValidator } from './DrBaseAsset'\n\n/**\n * An asset record representing video files that can be displayed in video shapes.\n * Video assets store metadata about video files including dimensions, MIME type,\n * animation status, and file source information. They are referenced by DrVideoShape\n * instances to display video content on the canvas.\n *\n * @example\n * ```ts\n * import { DrVideoAsset } from '@ibodr/schema'\n *\n * const videoAsset: DrVideoAsset = {\n * id: 'asset:video123',\n * typeName: 'asset',\n * type: 'video',\n * props: {\n * w: 1920,\n * h: 1080,\n * name: 'my-video.mp4',\n * isAnimated: true,\n * mimeType: 'video/mp4',\n * src: 'https://example.com/video.mp4',\n * fileSize: 5242880\n * },\n * meta: {}\n * }\n * ```\n *\n * @public\n */\nexport type DrVideoAsset = DrBaseAsset<\n\t'video',\n\t{\n\t\t/** The width of the video in pixels */\n\t\tw: number\n\t\t/** The height of the video in pixels */\n\t\th: number\n\t\t/** The original filename or display name of the video */\n\t\tname: string\n\t\t/** Whether the video contains animation/motion (true for most videos) */\n\t\tisAnimated: boolean\n\t\t/** The MIME type of the video file (e.g., 'video/mp4', 'video/webm'), null if unknown */\n\t\tmimeType: string | null\n\t\t/** The source URL or data URI for the video file, null if not yet available */\n\t\tsrc: string | null\n\t\t/** The file size in bytes, optional for backward compatibility */\n\t\tfileSize?: number\n\t}\n>\n\n/** @public */\nexport const videoAssetProps = {\n\tw: T.number,\n\th: T.number,\n\tname: T.string,\n\tisAnimated: T.boolean,\n\tmimeType: T.string.nullable(),\n\tsrc: T.srcUrl.nullable(),\n\tfileSize: T.number.optional(),\n} satisfies RecordProps<DrVideoAsset>\n\n/** Validator for video assets. @public */\nexport const videoAssetValidator: T.Validator<DrVideoAsset> = createAssetValidator(\n\t'video',\n\tT.object(videoAssetProps)\n)\n\nconst Versions = createMigrationIds('com.draw.asset.video', {\n\tAddIsAnimated: 1,\n\tRenameWidthHeight: 2,\n\tMakeUrlsValid: 3,\n\tAddFileSize: 4,\n\tMakeFileSizeOptional: 5,\n} as const)\n\n/**\n * Version identifiers for video asset migration sequences. These versions track\n * the evolution of the video asset schema over time, enabling proper data migration\n * when the asset structure changes.\n *\n * @example\n * ```ts\n * import { videoAssetVersions } from '@ibodr/schema'\n *\n * // Check the current version of a specific migration\n * console.log(videoAssetVersions.AddFileSize) // 4\n * ```\n *\n * @public\n */\nexport { Versions as videoAssetVersions }\n\n/**\n * Migration sequence for video assets that handles schema evolution over time.\n * This sequence defines how video asset data should be transformed when upgrading\n * or downgrading between different schema versions. Each migration step handles\n * specific changes like adding properties, renaming fields, or changing data formats.\n *\n * The migrations handle:\n * - Adding animation detection (isAnimated property)\n * - Renaming width/height properties to w/h for consistency\n * - Ensuring URL validity for src properties\n * - Adding file size tracking\n * - Making file size optional for backward compatibility\n *\n * @public\n */\nexport const videoAssetMigrations = createRecordMigrationSequence({\n\tsequenceId: 'com.draw.asset.video',\n\trecordType: 'asset',\n\tfilter: (asset) => (asset as DrVideoAsset).type === 'video',\n\tsequence: [\n\t\t{\n\t\t\tid: Versions.AddIsAnimated,\n\t\t\tup: (asset: any) => {\n\t\t\t\tasset.props.isAnimated = false\n\t\t\t},\n\t\t\tdown: (asset: any) => {\n\t\t\t\tdelete asset.props.isAnimated\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.RenameWidthHeight,\n\t\t\tup: (asset: any) => {\n\t\t\t\tasset.props.w = asset.props.width\n\t\t\t\tasset.props.h = asset.props.height\n\t\t\t\tdelete asset.props.width\n\t\t\t\tdelete asset.props.height\n\t\t\t},\n\t\t\tdown: (asset: any) => {\n\t\t\t\tasset.props.width = asset.props.w\n\t\t\t\tasset.props.height = asset.props.h\n\t\t\t\tdelete asset.props.w\n\t\t\t\tdelete asset.props.h\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.MakeUrlsValid,\n\t\t\tup: (asset: any) => {\n\t\t\t\tif (!T.srcUrl.isValid(asset.props.src)) {\n\t\t\t\t\tasset.props.src = ''\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (_asset) => {\n\t\t\t\t// noop\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddFileSize,\n\t\t\tup: (asset: any) => {\n\t\t\t\tasset.props.fileSize = -1\n\t\t\t},\n\t\t\tdown: (asset: any) => {\n\t\t\t\tdelete asset.props.fileSize\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.MakeFileSizeOptional,\n\t\t\tup: (asset: any) => {\n\t\t\t\tif (asset.props.fileSize === -1) {\n\t\t\t\t\tasset.props.fileSize = undefined\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (asset: any) => {\n\t\t\t\tif (asset.props.fileSize === undefined) {\n\t\t\t\t\tasset.props.fileSize = -1\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t],\n})\n","import { T } from '@ibodr/validate'\n\n/**\n * A serializable model for 2D boxes.\n *\n * @public */\nexport interface BoxModel {\n\tx: number\n\ty: number\n\tw: number\n\th: number\n}\n\n/**\n * A serializable model for 2D vectors.\n *\n * @public */\nexport interface VecModel {\n\tx: number\n\ty: number\n\tz?: number\n}\n\n/**\n * Validator for VecModel objects that ensures they have numeric x and y coordinates,\n * with an optional z coordinate for 3D vectors. Used throughout the schema to\n * validate point and vector data structures.\n *\n * @public\n * @example\n * ```ts\n * const vector2D = { x: 10, y: 20 }\n * const isValid = vecModelValidator.check(vector2D) // true\n *\n * const vector3D = { x: 10, y: 20, z: 30 }\n * const isValid3D = vecModelValidator.check(vector3D) // true\n * ```\n */\nexport const vecModelValidator: T.ObjectValidator<VecModel> = T.object({\n\tx: T.number,\n\ty: T.number,\n\tz: T.number.optional(),\n})\n\n/**\n * Validator for BoxModel objects that ensures they have numeric x, y coordinates\n * for position and w, h values for width and height. Used throughout the schema\n * to validate bounding box and rectangular area data structures.\n *\n * @public\n * @example\n * ```ts\n * const box = { x: 10, y: 20, w: 100, h: 50 }\n * const isValid = boxModelValidator.check(box) // true\n *\n * const invalidBox = { x: 10, y: 20, w: -5, h: 50 }\n * const isValidNegative = boxModelValidator.check(invalidBox) // true (validator allows negative values)\n * ```\n */\nexport const boxModelValidator: T.ObjectValidator<BoxModel> = T.object({\n\tx: T.number,\n\ty: T.number,\n\tw: T.number,\n\th: T.number,\n})\n","import { T } from '@ibodr/validate'\n\n/**\n * A type representing opacity values in tldraw.\n *\n * Opacity values are numbers between 0 and 1, where 0 is fully transparent\n * and 1 is fully opaque. This type is used throughout the editor to control\n * the transparency of shapes, UI elements, and other visual components.\n *\n * @example\n * ```ts\n * const fullyOpaque: DrOpacityType = 1.0\n * const halfTransparent: DrOpacityType = 0.5\n * const fullyTransparent: DrOpacityType = 0.0\n * const quarterOpaque: DrOpacityType = 0.25\n * ```\n *\n * @public\n */\nexport type DrOpacityType = number\n\n/**\n * A validator for opacity values.\n *\n * This validator ensures that opacity values are numbers between 0 and 1 (inclusive).\n * Values outside this range will cause a validation error. The validator provides\n * runtime type checking for opacity properties throughout the editor.\n *\n * @param n - The number to validate as an opacity value\n * @throws T.ValidationError When the value is not between 0 and 1\n *\n * @example\n * ```ts\n * import { opacityValidator } from '@ibodr/schema'\n *\n * // Valid opacity values\n * try {\n * const validOpacity1 = opacityValidator.validate(0.5) // ✓\n * const validOpacity2 = opacityValidator.validate(1.0) // ✓\n * const validOpacity3 = opacityValidator.validate(0.0) // ✓\n * } catch (error) {\n * console.error('Validation failed:', error.message)\n * }\n *\n * // Invalid opacity values\n * try {\n * opacityValidator.validate(-0.1) // ✗ Throws error\n * opacityValidator.validate(1.5) // ✗ Throws error\n * } catch (error) {\n * console.error('Invalid opacity:', error.message)\n * }\n * ```\n *\n * @public\n */\nexport const opacityValidator = T.unitInterval\n","import { IndexKey, JsonObject } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { idValidator } from '../misc/id-validator'\nimport { DrOpacityType, opacityValidator } from '../misc/DrOpacity'\nimport { DrParentId, DrShapeId } from '../records/DrShape'\n\n/**\n * Base interface for all shapes in tldraw.\n *\n * This interface defines the common properties that all shapes share, regardless of their\n * specific type. Every default shape extends this base with additional type-specific properties.\n *\n * Custom shapes should be defined by augmenting the DrGlobalShapePropsMap type and getting the shape type from the DrShape type.\n *\n * @example\n * ```ts\n * // Define a default shape type\n * interface DrArrowShape extends DrBaseShape<'arrow', {\n * kind: DrArrowShapeKind\n * labelColor: DrDefaultColorStyle\n * color: DrDefaultColorStyle\n * fill: DrDefaultFillStyle\n * dash: DrDefaultDashStyle\n * size: DrDefaultSizeStyle\n * arrowheadStart: DrArrowShapeArrowheadStyle\n * arrowheadEnd: DrArrowShapeArrowheadStyle\n * font: DrDefaultFontStyle\n * start: VecModel\n * end: VecModel\n * bend: number\n * richText: DrRichText\n * labelPosition: number\n * scale: number\n * elbowMidPoint: number\n * }> {}\n *\n * // Create a shape instance\n * const arrowShape: DrArrowShape = {\n * id: 'shape:abc123',\n * typeName: 'shape',\n * type: 'arrow',\n * x: 100,\n * y: 200,\n * rotation: 0,\n * index: 'a1',\n * parentId: 'page:main',\n * isLocked: false,\n * opacity: 1,\n * props: {\n * kind: 'arc',\n * start: { x: 0, y: 0 },\n * end: { x: 100, y: 100 },\n * // ... other props\n * },\n * meta: {}\n * }\n * ```\n *\n * @public\n */\nexport interface DrBaseShape<Type extends string, Props extends object> {\n\t// using real `extends BaseRecord<'shape', DrShapeId>` introduces a circularity in the types\n\t// and for that reason those \"base members\" have to be declared manually here\n\treadonly id: DrShapeId\n\treadonly typeName: 'shape'\n\n\ttype: Type\n\tx: number\n\ty: number\n\trotation: number\n\tindex: IndexKey\n\tparentId: DrParentId\n\tisLocked: boolean\n\topacity: DrOpacityType\n\tprops: Props\n\tmeta: JsonObject\n}\n\n/**\n * Validator for parent IDs, ensuring they follow the correct format.\n *\n * Parent IDs must start with either \"page:\" (for shapes directly on a page)\n * or \"shape:\" (for shapes inside other shapes like frames or groups).\n *\n * @example\n * ```ts\n * // Valid parent IDs\n * const pageParent = parentIdValidator.validate('page:main') // ✓\n * const shapeParent = parentIdValidator.validate('shape:frame1') // ✓\n *\n * // Invalid parent ID (throws error)\n * const invalid = parentIdValidator.validate('invalid:123') // ✗\n * ```\n *\n * @public\n */\nexport const parentIdValidator = T.string.refine((id) => {\n\tif (!id.startsWith('page:') && !id.startsWith('shape:')) {\n\t\tthrow new Error('Parent ID must start with \"page:\" or \"shape:\"')\n\t}\n\treturn id as DrParentId\n})\n\n/**\n * Validator for shape IDs, ensuring they follow the \"shape:\" format.\n *\n * @example\n * ```ts\n * const validId = shapeIdValidator.validate('shape:abc123') // ✓\n * const invalidId = shapeIdValidator.validate('page:abc123') // ✗ throws error\n * ```\n *\n * @public\n */\nexport const shapeIdValidator = idValidator<DrShapeId>('shape')\n\n/**\n * Creates a validator for a specific shape type.\n *\n * This function generates a complete validator that can validate shape records\n * of the specified type, including both the base shape properties and any\n * custom properties and metadata specific to that shape type.\n *\n * @param type - The string literal type for this shape (e.g., 'geo', 'arrow')\n * @param props - Optional validator configuration for shape-specific properties\n * @param meta - Optional validator configuration for shape-specific metadata\n * @returns A validator that can validate complete shape records of the specified type\n *\n * @example\n * ```ts\n * // Create a validator for a custom shape type\n * const customShapeValidator = createShapeValidator('custom', {\n * width: T.number,\n * height: T.number,\n * color: T.string\n * })\n *\n * // Use the validator to validate shape data\n * const shapeData = {\n * id: 'shape:abc123',\n * typeName: 'shape',\n * type: 'custom',\n * x: 100,\n * y: 200,\n * // ... other base properties\n * props: {\n * width: 150,\n * height: 100,\n * color: 'red'\n * }\n * }\n *\n * const validatedShape = customShapeValidator.validate(shapeData)\n * ```\n *\n * @public\n */\nexport function createShapeValidator<\n\tType extends string,\n\tProps extends JsonObject,\n\tMeta extends JsonObject,\n>(\n\ttype: Type,\n\tprops?: { [K in keyof Props]: T.Validatable<Props[K]> },\n\tmeta?: { [K in keyof Meta]: T.Validatable<Meta[K]> }\n) {\n\treturn T.object<DrBaseShape<Type, Props>>({\n\t\tid: shapeIdValidator,\n\t\ttypeName: T.literal('shape'),\n\t\tx: T.number,\n\t\ty: T.number,\n\t\trotation: T.number,\n\t\tindex: T.indexKey,\n\t\tparentId: parentIdValidator,\n\t\ttype: T.literal(type),\n\t\tisLocked: T.boolean,\n\t\topacity: opacityValidator,\n\t\tprops: props ? T.object(props) : (T.jsonValue as any),\n\t\tmeta: meta ? T.object(meta) : (T.jsonValue as any),\n\t})\n}\n","import { JsonObject } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { idValidator } from '../misc/id-validator'\nimport { DrBindingId } from '../records/DrBinding'\nimport { DrShapeId } from '../records/DrShape'\nimport { shapeIdValidator } from '../shapes/DrBaseShape'\n\n/**\n * Base interface for all binding types in tldraw. Bindings represent relationships\n * between shapes, such as arrows connecting to other shapes or organizational connections.\n *\n * All default bindings extend this base interface with specific type and property definitions.\n * The binding system enables shapes to maintain relationships that persist through\n * transformations, movements, and other operations.\n *\n * Custom bindings should be defined by augmenting the DrGlobalBindingPropsMap type and getting the binding type from the DrBinding type.\n *\n * @param Type - String literal type identifying the specific binding type (e.g., 'arrow')\n * @param Props - Object containing binding-specific properties and configuration\n *\n * @example\n * ```ts\n * // Define a default binding type\n * interface DrArrowBinding extends DrBaseBinding<'arrow', DrArrowBindingProps> {}\n *\n * interface DrArrowBindingProps {\n * terminal: 'start' | 'end'\n * normalizedAnchor: VecModel\n * isExact: boolean\n * isPrecise: boolean\n * snap: ElbowArrowSnap\n * }\n *\n * // Create a binding instance\n * const arrowBinding: DrArrowBinding = {\n * id: 'binding:abc123',\n * typeName: 'binding',\n * type: 'arrow',\n * fromId: 'shape:source1',\n * toId: 'shape:target1',\n * props: {\n * terminal: 'end',\n * normalizedAnchor: { x: 0.5, y: 0.5 },\n * isExact: false,\n * isPrecise: true,\n * snap: 'edge'\n * },\n * meta: {}\n * }\n * ```\n *\n * @public\n */\nexport interface DrBaseBinding<Type extends string, Props extends object> {\n\t// using real `extends BaseRecord<'binding', DrBindingId>` introduces a circularity in the types\n\t// and for that reason those \"base members\" have to be declared manually here\n\treadonly id: DrBindingId\n\treadonly typeName: 'binding'\n\n\t/** The specific type of this binding (e.g., 'arrow', 'custom') */\n\ttype: Type\n\t/** ID of the source shape in this binding relationship */\n\tfromId: DrShapeId\n\t/** ID of the target shape in this binding relationship */\n\ttoId: DrShapeId\n\t/** Binding-specific properties that define behavior and appearance */\n\tprops: Props\n\t/** User-defined metadata for extending binding functionality */\n\tmeta: JsonObject\n}\n\n/**\n * Validator for binding IDs. Ensures that binding identifiers follow the correct\n * format and type constraints required by the tldraw schema system.\n *\n * Used internally by the schema validation system to verify binding IDs when\n * records are created or modified. All binding IDs must be prefixed with 'binding:'.\n *\n * @example\n * ```ts\n * import { bindingIdValidator } from '@ibodr/schema'\n *\n * // Validate a binding ID\n * const isValid = bindingIdValidator.isValid('binding:abc123') // true\n * const isInvalid = bindingIdValidator.isValid('shape:abc123') // false\n *\n * // Use in custom validation schema\n * const customBindingValidator = T.object({\n * id: bindingIdValidator,\n * // ... other properties\n * })\n * ```\n *\n * @public\n */\nexport const bindingIdValidator = idValidator<DrBindingId>('binding')\n\n/**\n * Creates a runtime validator for a specific binding type. This factory function\n * generates a complete validation schema for custom bindings that extends DrBaseBinding.\n *\n * The validator ensures all binding records conform to the expected structure with\n * proper type safety and runtime validation. It validates the base binding properties\n * (id, type, fromId, toId) along with custom props and meta fields.\n *\n * @param type - The string literal type identifier for this binding (e.g., 'arrow', 'custom')\n * @param props - Optional validation schema for binding-specific properties\n * @param meta - Optional validation schema for metadata fields\n *\n * @returns A validator object that can validate complete binding records\n *\n * @example\n * ```ts\n * import { createBindingValidator } from '@ibodr/schema'\n * import { T } from '@ibodr/validate'\n *\n * // Create validator for a custom binding type\n * const myBindingValidator = createBindingValidator(\n * 'myBinding',\n * {\n * strength: T.number,\n * color: T.string,\n * enabled: T.boolean\n * },\n * {\n * createdAt: T.number,\n * author: T.string\n * }\n * )\n *\n * // Validate a binding instance\n * const bindingData = {\n * id: 'binding:123',\n * typeName: 'binding',\n * type: 'myBinding',\n * fromId: 'shape:abc',\n * toId: 'shape:def',\n * props: {\n * strength: 0.8,\n * color: 'red',\n * enabled: true\n * },\n * meta: {\n * createdAt: Date.now(),\n * author: 'user123'\n * }\n * }\n *\n * const isValid = myBindingValidator.isValid(bindingData) // true\n * ```\n *\n * @example\n * ```ts\n * // Simple binding without custom props or meta\n * const simpleBindingValidator = createBindingValidator('simple')\n *\n * // This will use JsonValue validation for props and meta\n * const binding = {\n * id: 'binding:456',\n * typeName: 'binding',\n * type: 'simple',\n * fromId: 'shape:start',\n * toId: 'shape:end',\n * props: {}, // Any JSON value allowed\n * meta: {} // Any JSON value allowed\n * }\n * ```\n *\n * @public\n */\nexport function createBindingValidator<\n\tType extends string,\n\tProps extends JsonObject,\n\tMeta extends JsonObject,\n>(\n\ttype: Type,\n\tprops?: { [K in keyof Props]: T.Validatable<Props[K]> },\n\tmeta?: { [K in keyof Meta]: T.Validatable<Meta[K]> }\n) {\n\treturn T.object<DrBaseBinding<Type, Props>>({\n\t\tid: bindingIdValidator,\n\t\ttypeName: T.literal('binding'),\n\t\ttype: T.literal(type),\n\t\tfromId: shapeIdValidator,\n\t\ttoId: shapeIdValidator,\n\t\tprops: props ? T.object(props) : (T.jsonValue as any),\n\t\tmeta: meta ? T.object(meta) : (T.jsonValue as any),\n\t})\n}\n","import {\n\tRecordId,\n\tUnknownRecord,\n\tcreateMigrationIds,\n\tcreateRecordMigrationSequence,\n\tcreateRecordType,\n} from '@ibodr/store'\nimport { mapObjectMapValues, uniqueId } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { DrArrowBinding } from '../bindings/DrArrowBinding'\nimport { DrBaseBinding, createBindingValidator } from '../bindings/DrBaseBinding'\nimport { SchemaPropsInfo } from '../createDrSchema'\nimport { DrPropsMigrations } from '../recordsWithProps'\n\n/**\n * The default set of bindings that are available in the editor.\n * Currently includes only arrow bindings, but can be extended with custom bindings.\n *\n * @example\n * ```ts\n * // Arrow binding connects an arrow to shapes\n * const arrowBinding: DrDefaultBinding = {\n * id: 'binding:arrow1',\n * typeName: 'binding',\n * type: 'arrow',\n * fromId: 'shape:arrow1',\n * toId: 'shape:rectangle1',\n * props: {\n * terminal: 'end',\n * normalizedAnchor: { x: 0.5, y: 0.5 },\n * isExact: false,\n * isPrecise: true\n * }\n * }\n * ```\n *\n * @public\n */\nexport type DrDefaultBinding = DrArrowBinding\n\n/**\n * A type for a binding that is available in the editor but whose type is\n * unknown—either one of the editor's default bindings or else a custom binding.\n * Used internally for type-safe handling of bindings with unknown structure.\n *\n * @example\n * ```ts\n * // Function that works with any binding type\n * function processBinding(binding: DrUnknownBinding) {\n * console.log(`Processing ${binding.type} binding from ${binding.fromId} to ${binding.toId}`)\n * // Handle binding properties generically\n * }\n * ```\n *\n * @public\n */\nexport type DrUnknownBinding = DrBaseBinding<string, object>\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface DrGlobalBindingPropsMap {}\n\n/** @public */\n// prettier-ignore\nexport type DrIndexedBindings = {\n\t// We iterate over a union of augmented keys and default binding types.\n\t// This allows us to include (or conditionally exclude or override) the default bindings in one go.\n\t//\n\t// In the `as` clause we are filtering out disabled bindings.\n\t[K in keyof DrGlobalBindingPropsMap | DrDefaultBinding['type'] as K extends DrDefaultBinding['type']\n\t\t? K extends keyof DrGlobalBindingPropsMap\n\t\t\t? // if it extends a nullish value the user has disabled this binding type so we filter it out with never\n\t\t\t\tDrGlobalBindingPropsMap[K] extends null | undefined\n\t\t\t\t? never\n\t\t\t\t: K\n\t\t\t: K\n\t\t: K]: K extends DrDefaultBinding['type']\n\t\t\t? // if it's a default binding type we need to check if it's been overridden\n\t\t\t\tK extends keyof DrGlobalBindingPropsMap\n\t\t\t\t? // if it has been overriden then use the custom binding definition\n\t\t\t\t\tDrBaseBinding<K, DrGlobalBindingPropsMap[K]>\n\t\t\t\t: // if it has not been overriden then reuse existing type aliases for better type display\n\t\t\t\t\tExtract<DrDefaultBinding, { type: K }>\n\t\t\t: // use the custom binding definition\n\t\t\t\tDrBaseBinding<K, DrGlobalBindingPropsMap[K & keyof DrGlobalBindingPropsMap]>\n}\n\n/**\n * The set of all bindings that are available in the editor.\n * Bindings represent relationships between shapes, such as arrows connecting to other shapes.\n *\n * You can use this type without a type argument to work with any binding, or pass\n * a specific binding type string (e.g., `'arrow'`) to narrow down to that specific binding type.\n *\n * @example\n * ```ts\n * // Check binding type and handle accordingly\n * function handleBinding(binding: DrBinding) {\n * switch (binding.type) {\n * case 'arrow':\n * // Handle arrow binding\n * break\n * default:\n * // Handle unknown custom binding\n * break\n * }\n * }\n *\n * // Narrow to a specific binding type by passing the type as a generic argument\n * function getArrowSourceId(binding: DrBinding<'arrow'>) {\n * return binding.fromId // TypeScript knows this is a DrArrowBinding\n * }\n * ```\n *\n * @public\n */\nexport type DrBinding<K extends keyof DrIndexedBindings = keyof DrIndexedBindings> =\n\tDrIndexedBindings[K]\n\n/**\n * Type for updating existing bindings with partial properties.\n * Only the id and type are required, all other properties are optional.\n *\n * @example\n * ```ts\n * // Update arrow binding properties\n * const bindingUpdate: DrBindingUpdate<DrArrowBinding> = {\n * id: 'binding:arrow1',\n * type: 'arrow',\n * props: {\n * normalizedAnchor: { x: 0.7, y: 0.3 } // Only update anchor position\n * }\n * }\n *\n * editor.updateBindings([bindingUpdate])\n * ```\n *\n * @public\n */\nexport type DrBindingUpdate<T extends DrBinding = DrBinding> = T extends T\n\t? {\n\t\t\tid: DrBindingId\n\t\t\ttype: T['type']\n\t\t\ttypeName?: T['typeName']\n\t\t\tfromId?: T['fromId']\n\t\t\ttoId?: T['toId']\n\t\t\tprops?: Partial<T['props']>\n\t\t\tmeta?: Partial<T['meta']>\n\t\t}\n\t: never\n\n/**\n * Type for creating new bindings with required fromId and toId.\n * The id is optional and will be generated if not provided.\n *\n * @example\n * ```ts\n * // Create a new arrow binding\n * const newBinding: DrBindingCreate<DrArrowBinding> = {\n * type: 'arrow',\n * fromId: 'shape:arrow1',\n * toId: 'shape:rectangle1',\n * props: {\n * terminal: 'end',\n * normalizedAnchor: { x: 0.5, y: 0.5 },\n * isExact: false,\n * isPrecise: true\n * }\n * }\n *\n * editor.createBindings([newBinding])\n * ```\n *\n * @public\n */\nexport type DrBindingCreate<T extends DrBinding = DrBinding> = T extends T\n\t? {\n\t\t\tid?: DrBindingId\n\t\t\ttype: T['type']\n\t\t\ttypeName?: T['typeName']\n\t\t\tfromId: T['fromId']\n\t\t\ttoId: T['toId']\n\t\t\tprops?: Partial<T['props']>\n\t\t\tmeta?: Partial<T['meta']>\n\t\t}\n\t: never\n\n/**\n * Branded string type for binding record identifiers.\n * Prevents mixing binding IDs with other types of record IDs at compile time.\n *\n * @example\n * ```ts\n * import { createBindingId } from '@ibodr/schema'\n *\n * // Create a new binding ID\n * const bindingId: DrBindingId = createBindingId()\n *\n * // Use in binding records\n * const binding: DrBinding = {\n * id: bindingId,\n * type: 'arrow',\n * fromId: 'shape:arrow1',\n * toId: 'shape:rectangle1',\n * // ... other properties\n * }\n * ```\n *\n * @public\n */\nexport type DrBindingId = RecordId<DrBinding>\n\n/**\n * Migration version identifiers for the root binding record schema.\n * Currently empty as no migrations have been applied to the base binding structure.\n *\n * @example\n * ```ts\n * // Future migrations would be defined here\n * const rootBindingVersions = createMigrationIds('com.draw.binding', {\n * AddNewProperty: 1,\n * } as const)\n * ```\n *\n * @public\n */\nexport const rootBindingVersions = createMigrationIds('com.draw.binding', {} as const)\n\n/**\n * Migration sequence for the root binding record structure.\n * Currently empty as the binding schema has not required any migrations yet.\n *\n * @example\n * ```ts\n * // Migrations would be automatically applied when loading old documents\n * const migratedStore = migrator.migrateStoreSnapshot({\n * schema: oldSchema,\n * store: oldStoreSnapshot\n * })\n * ```\n *\n * @public\n */\nexport const rootBindingMigrations = createRecordMigrationSequence({\n\tsequenceId: 'com.draw.binding',\n\trecordType: 'binding',\n\tsequence: [],\n})\n\n/**\n * Type guard to check if a record is a DrBinding.\n * Useful for filtering or type narrowing when working with mixed record types.\n *\n * @param record - The record to check\n * @returns True if the record is a binding, false otherwise\n *\n * @example\n * ```ts\n * // Filter bindings from mixed records\n * const allRecords = store.allRecords()\n * const bindings = allRecords.filter(isBinding)\n *\n * // Type guard usage\n * function processRecord(record: UnknownRecord) {\n * if (isBinding(record)) {\n * // record is now typed as DrBinding\n * console.log(`Binding from ${record.fromId} to ${record.toId}`)\n * }\n * }\n * ```\n *\n * @public\n */\nexport function isBinding(record?: UnknownRecord): record is DrBinding {\n\tif (!record) return false\n\treturn record.typeName === 'binding'\n}\n\n/**\n * Type guard to check if a string is a valid DrBindingId.\n * Validates that the ID follows the correct format for binding identifiers.\n *\n * @param id - The string to check\n * @returns True if the string is a valid binding ID, false otherwise\n *\n * @example\n * ```ts\n * // Validate binding IDs\n * const maybeBindingId = 'binding:abc123'\n * if (isBindingId(maybeBindingId)) {\n * // maybeBindingId is now typed as DrBindingId\n * const binding = store.get(maybeBindingId)\n * }\n *\n * // Filter binding IDs from mixed ID array\n * const mixedIds = ['shape:1', 'binding:2', 'page:3']\n * const bindingIds = mixedIds.filter(isBindingId)\n * ```\n *\n * @public\n */\nexport function isBindingId(id?: string): id is DrBindingId {\n\tif (!id) return false\n\treturn id.startsWith('binding:')\n}\n\n/**\n * Creates a new DrBindingId with proper formatting.\n * Generates a unique ID if none is provided, or formats a provided ID correctly.\n *\n * @param id - Optional custom ID suffix. If not provided, a unique ID is generated\n * @returns A properly formatted binding ID\n *\n * @example\n * ```ts\n * // Create with auto-generated ID\n * const bindingId1 = createBindingId() // 'binding:abc123'\n *\n * // Create with custom ID\n * const bindingId2 = createBindingId('myCustomBinding') // 'binding:myCustomBinding'\n *\n * // Use in binding creation\n * const binding: DrBinding = {\n * id: createBindingId(),\n * type: 'arrow',\n * fromId: 'shape:arrow1',\n * toId: 'shape:rectangle1',\n * // ... other properties\n * }\n * ```\n *\n * @public\n */\nexport function createBindingId(id?: string): DrBindingId {\n\treturn `binding:${id ?? uniqueId()}` as DrBindingId\n}\n\n/**\n * Creates a migration sequence for binding properties.\n * This is a pass-through function that validates and returns the provided migrations.\n *\n * @param migrations - The migration sequence for binding properties\n * @returns The validated migration sequence\n *\n * @example\n * ```ts\n * // Define migrations for custom binding properties\n * const myBindingMigrations = createBindingPropsMigrationSequence({\n * sequence: [\n * {\n * id: 'com.myapp.binding.custom/1.0.0',\n * up: (props) => ({ ...props, newProperty: 'default' }),\n * down: ({ newProperty, ...props }) => props\n * }\n * ]\n * })\n * ```\n *\n * @public\n */\nexport function createBindingPropsMigrationSequence(\n\tmigrations: DrPropsMigrations\n): DrPropsMigrations {\n\treturn migrations\n}\n\n/**\n * Creates properly formatted migration IDs for binding property migrations.\n * Follows the convention: 'com.draw.binding.\\{bindingType\\}/\\{version\\}'\n *\n * @param bindingType - The type of binding these migrations apply to\n * @param ids - Object mapping migration names to version numbers\n * @returns Object with formatted migration IDs\n *\n * @example\n * ```ts\n * // Create migration IDs for custom binding\n * const myBindingVersions = createBindingPropsMigrationIds('myCustomBinding', {\n * AddNewProperty: 1,\n * UpdateProperty: 2\n * })\n *\n * // Result:\n * // {\n * // AddNewProperty: 'com.draw.binding.myCustomBinding/1',\n * // UpdateProperty: 'com.draw.binding.myCustomBinding/2'\n * // }\n * ```\n *\n * @public\n */\nexport function createBindingPropsMigrationIds<S extends string, T extends Record<string, number>>(\n\tbindingType: S,\n\tids: T\n): { [k in keyof T]: `com.draw.binding.${S}/${T[k]}` } {\n\treturn mapObjectMapValues(ids, (_k, v) => `com.draw.binding.${bindingType}/${v}`) as any\n}\n\n/**\n * Creates a record type for DrBinding with validation based on the provided binding schemas.\n * This function is used internally to configure the binding record type in the schema.\n *\n * @param bindings - Record mapping binding type names to their schema information\n * @returns A configured record type for bindings with validation\n *\n * @example\n * ```ts\n * // Used internally when creating schemas\n * const bindingRecordType = createBindingRecordType({\n * arrow: {\n * props: arrowBindingProps,\n * meta: arrowBindingMeta\n * }\n * })\n * ```\n *\n * @internal\n */\nexport function createBindingRecordType(bindings: Record<string, SchemaPropsInfo>) {\n\treturn createRecordType('binding', {\n\t\tscope: 'document',\n\t\tvalidator: T.model(\n\t\t\t'binding',\n\t\t\tT.union(\n\t\t\t\t'type',\n\t\t\t\tmapObjectMapValues(bindings, (type, { props, meta }) =>\n\t\t\t\t\tcreateBindingValidator(type, props, meta)\n\t\t\t\t)\n\t\t\t)\n\t\t),\n\t}).withDefaultProperties(() => ({\n\t\tmeta: {},\n\t}))\n}\n","import { T } from '@ibodr/validate'\n\n/**\n * Validator for DrRichText objects that ensures they have the correct structure\n * for document-based rich text content. Validates a document with a type field\n * and an array of content blocks.\n *\n * @public\n * @example\n * ```ts\n * const richText = { type: 'doc', content: [{ type: 'paragraph', content: [{ type: 'text', text: 'Hello' }] }] }\n * const isValid = richTextValidator.check(richText) // true\n * ```\n */\n\nexport const richTextValidator = T.object({\n\ttype: T.string,\n\tcontent: T.arrayOf(T.unknown),\n\tattrs: T.any.optional(),\n})\n\n/**\n * Type representing rich text content in tldraw. Rich text follows a document-based\n * structure with a root document containing an array of content blocks (paragraphs,\n * text nodes, etc.). This enables formatted text with support for multiple paragraphs,\n * styling, and other rich content.\n *\n * @public\n * @example\n * ```ts\n * const richText: DrRichText = {\n * type: 'doc',\n * content: [\n * {\n * type: 'paragraph',\n * content: [{ type: 'text', text: 'Hello world!' }]\n * }\n * ]\n * }\n * ```\n */\nexport type DrRichText = T.TypeOf<typeof richTextValidator>\n\n/**\n * Converts a plain text string into a DrRichText object. Each line of the input\n * text becomes a separate paragraph in the rich text document. Empty lines are\n * preserved as empty paragraphs to maintain the original text structure.\n *\n * @param text - The plain text string to convert to rich text\n * @returns A DrRichText object with the text content structured as paragraphs\n * @public\n * @example\n * ```ts\n * const richText = toRichText('Hello\\nWorld')\n * // Returns:\n * // {\n * // type: 'doc',\n * // content: [\n * // { type: 'paragraph', content: [{ type: 'text', text: 'Hello' }] },\n * // { type: 'paragraph', content: [{ type: 'text', text: 'World' }] }\n * // ]\n * // }\n *\n * const emptyLine = toRichText('Line 1\\n\\nLine 3')\n * // Creates three paragraphs, with the middle one being empty\n * ```\n */\nexport function toRichText(text: string): DrRichText {\n\tconst lines = text.split('\\n')\n\tconst content = lines.map((text) => {\n\t\tif (!text) {\n\t\t\treturn {\n\t\t\t\ttype: 'paragraph',\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\ttype: 'paragraph',\n\t\t\tcontent: [{ type: 'text', text }],\n\t\t}\n\t})\n\n\treturn {\n\t\ttype: 'doc',\n\t\tcontent,\n\t}\n}\n","import { T } from '@ibodr/validate'\n\n/**\n * A `StyleProp` is a property of a shape that follows some special rules.\n *\n * 1. The same value can be set on lots of shapes at the same time.\n *\n * 2. The last used value is automatically saved and applied to new shapes.\n *\n * For example, {@link DefaultColorStyle} is a style prop used by tldraw's default shapes to set\n * their color. If you try selecting several shapes on tldraw.com and changing their color, you'll\n * see that the color is applied to all of them. Then, if you draw a new shape, it'll have the same\n * color as the one you just set.\n *\n * You can use styles in your own shapes by either defining your own (see {@link StyleProp.define}\n * and {@link StyleProp.defineEnum}) or using tldraw's default ones, like {@link DefaultColorStyle}.\n * When you define a shape, pass a `props` object describing all of your shape's properties, using\n * `StyleProp`s for the ones you want to be styles. See the\n * {@link https://github.com/tldraw/tldraw/tree/main/apps/examples | custom styles example}\n * for more.\n *\n * @public\n */\nexport class StyleProp<Type> implements T.Validatable<Type> {\n\t/**\n\t * Define a new {@link StyleProp}.\n\t *\n\t * @param uniqueId - Each StyleProp must have a unique ID. We recommend you prefix this with\n\t * your app/library name.\n\t * @param options -\n\t * - `defaultValue`: The default value for this style prop.\n\t *\n\t * - `type`: Optionally, describe what type of data you expect for this style prop.\n\t *\n\t * @example\n\t * ```ts\n\t * import {T} from '@ibodr/validate'\n\t * import {StyleProp} from '@ibodr/schema'\n\t *\n\t * const MyLineWidthProp = StyleProp.define('myApp:lineWidth', {\n\t * defaultValue: 1,\n\t * type: T.number,\n\t * })\n\t * ```\n\t * @public\n\t */\n\tstatic define<Type>(\n\t\tuniqueId: string,\n\t\toptions: { defaultValue: Type; type?: T.Validatable<Type> }\n\t) {\n\t\tconst { defaultValue, type = T.any } = options\n\t\treturn new StyleProp<Type>(uniqueId, defaultValue, type)\n\t}\n\n\t/**\n\t * Define a new {@link StyleProp} as a list of possible values.\n\t *\n\t * @param uniqueId - Each StyleProp must have a unique ID. We recommend you prefix this with\n\t * your app/library name.\n\t * @param options -\n\t * - `defaultValue`: The default value for this style prop.\n\t *\n\t * - `values`: An array of possible values of this style prop.\n\t *\n\t * @example\n\t * ```ts\n\t * import {StyleProp} from '@ibodr/schema'\n\t *\n\t * const MySizeProp = StyleProp.defineEnum('myApp:size', {\n\t * defaultValue: 'medium',\n\t * values: ['small', 'medium', 'large'],\n\t * })\n\t * ```\n\t */\n\tstatic defineEnum<const Values extends readonly unknown[]>(\n\t\tuniqueId: string,\n\t\toptions: { defaultValue: Values[number]; values: Values }\n\t) {\n\t\tconst { defaultValue, values } = options\n\t\treturn new EnumStyleProp<Values[number]>(uniqueId, defaultValue, values)\n\t}\n\n\t/** @internal */\n\tprotected constructor(\n\t\treadonly id: string,\n\t\tpublic defaultValue: Type,\n\t\treadonly type: T.Validatable<Type>\n\t) {}\n\n\tsetDefaultValue(value: Type) {\n\t\tthis.defaultValue = value\n\t}\n\n\tvalidate(value: unknown) {\n\t\treturn this.type.validate(value)\n\t}\n\n\tvalidateUsingKnownGoodVersion(prevValue: Type, newValue: unknown) {\n\t\tif (this.type.validateUsingKnownGoodVersion) {\n\t\t\treturn this.type.validateUsingKnownGoodVersion(prevValue, newValue)\n\t\t} else {\n\t\t\treturn this.validate(newValue)\n\t\t}\n\t}\n}\n\n/**\n * See {@link StyleProp} & {@link StyleProp.defineEnum}\n *\n * @public\n */\nexport class EnumStyleProp<T> extends StyleProp<T> {\n\t/** @internal */\n\tconstructor(id: string, defaultValue: T, values: readonly T[]) {\n\t\tsuper(id, defaultValue, T.literalEnum(...values))\n\t\tthis.values = [...values]\n\t}\n\n\treadonly values: T[]\n\n\t/**\n\t * Add new values to this enum style prop at runtime. This is useful for extending\n\t * the built-in styles with custom values (e.g. adding custom colors). Be sure to\n\t * also modify the associated types.\n\t *\n\t * @param newValues - The new values to add.\n\t *\n\t * @public\n\t */\n\taddValues(...newValues: T[]): void {\n\t\tfor (const v of newValues) {\n\t\t\tif (!this.values.includes(v)) {\n\t\t\t\tthis.values.push(v)\n\t\t\t}\n\t\t}\n\t\t// Rebuild the validator with the updated values\n\t\t;(this as any).type = T.literalEnum(...this.values)\n\t}\n\n\t/**\n\t * Remove values from this enum style prop at runtime. This is useful for narrowing\n\t * the built-in styles with custom values (e.g. adding custom colors). Be sure to\n\t * also modify the associated types.\n\t *\n\t * @param valuesToRemove - The values to remove.\n\t *\n\t * @public\n\t */\n\tremoveValues(...valuesToRemove: T[]): void {\n\t\tfor (const v of valuesToRemove) {\n\t\t\tif (this.values.includes(v)) {\n\t\t\t\tthis.values.splice(this.values.indexOf(v), 1)\n\t\t\t}\n\t\t}\n\t\t// Rebuild the validator with the updated values\n\t\t;(this as any).type = T.literalEnum(...this.values)\n\t}\n}\n\n/**\n * @public\n */\nexport type StylePropValue<T extends StyleProp<any>> = T extends StyleProp<infer U> ? U : never\n","import {\n\tRecordId,\n\tUnknownRecord,\n\tcreateMigrationIds,\n\tcreateRecordMigrationSequence,\n\tcreateRecordType,\n} from '@ibodr/store'\nimport { mapObjectMapValues, uniqueId } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { SchemaPropsInfo } from '../createDrSchema'\nimport { DrPropsMigrations } from '../recordsWithProps'\nimport { DrArrowShape } from '../shapes/DrArrowShape'\nimport { DrBaseShape, createShapeValidator } from '../shapes/DrBaseShape'\nimport { DrBookmarkShape } from '../shapes/DrBookmarkShape'\nimport { DrDrawShape } from '../shapes/DrDrawShape'\nimport { DrEmbedShape } from '../shapes/DrEmbedShape'\nimport { DrFrameShape } from '../shapes/DrFrameShape'\nimport { DrGeoShape } from '../shapes/DrGeoShape'\nimport { DrGroupShape } from '../shapes/DrGroupShape'\nimport { DrHighlightShape } from '../shapes/DrHighlightShape'\nimport { DrImageShape } from '../shapes/DrImageShape'\nimport { DrLineShape } from '../shapes/DrLineShape'\nimport { DrNoteShape } from '../shapes/DrNoteShape'\nimport { DrTextShape } from '../shapes/DrTextShape'\nimport { DrVideoShape } from '../shapes/DrVideoShape'\nimport { StyleProp } from '../styles/StyleProp'\nimport { DrPageId } from './DrPage'\n\n/**\n * The default set of shapes that are available in the editor.\n *\n * This union type represents all the built-in shape types supported by tldraw,\n * including arrows, bookmarks, drawings, embeds, frames, geometry shapes,\n * groups, images, lines, notes, text, videos, and highlights.\n *\n * @example\n * ```ts\n * // Check if a shape is a default shape type\n * function isDefaultShape(shape: DrShape): shape is DrDefaultShape {\n * const defaultTypes = ['arrow', 'bookmark', 'draw', 'embed', 'frame', 'geo', 'group', 'image', 'line', 'note', 'text', 'video', 'highlight']\n * return defaultTypes.includes(shape.type)\n * }\n * ```\n *\n * @public\n */\nexport type DrDefaultShape =\n\t| DrArrowShape\n\t| DrBookmarkShape\n\t| DrDrawShape\n\t| DrEmbedShape\n\t| DrFrameShape\n\t| DrGeoShape\n\t| DrGroupShape\n\t| DrImageShape\n\t| DrLineShape\n\t| DrNoteShape\n\t| DrTextShape\n\t| DrVideoShape\n\t| DrHighlightShape\n\n/**\n * A type for a shape that is available in the editor but whose type is\n * unknown—either one of the editor's default shapes or else a custom shape.\n *\n * This is useful when working with shapes generically without knowing their specific type.\n * The shape type is a string and props are a generic object.\n *\n * @example\n * ```ts\n * // Handle any shape regardless of its specific type\n * function processUnknownShape(shape: DrUnknownShape) {\n * console.log(`Processing shape of type: ${shape.type}`)\n * console.log(`Position: (${shape.x}, ${shape.y})`)\n * }\n * ```\n *\n * @public\n */\nexport type DrUnknownShape = DrBaseShape<string, object>\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface DrGlobalShapePropsMap {}\n\n/** @public */\n// prettier-ignore\nexport type DrIndexedShapes = {\n\t// We iterate over a union of augmented keys and default shape types.\n\t// This allows us to include (or conditionally exclude or override) the default shapes in one go.\n\t//\n\t// In the `as` clause we are filtering out disabled shapes.\n\t[K in keyof DrGlobalShapePropsMap | DrDefaultShape['type'] as K extends DrDefaultShape['type']\n\t\t? // core shapes are always available and cannot be overridden so we just include them\n\t\t\tK extends 'group'\n\t\t\t? K\n\t\t\t: K extends keyof DrGlobalShapePropsMap\n\t\t\t\t? // if it extends a nullish value the user has disabled this shape type so we filter it out with never\n\t\t\t\t\tDrGlobalShapePropsMap[K] extends null | undefined\n\t\t\t\t\t? never\n\t\t\t\t\t: K\n\t\t\t\t: K\n\t\t: K]: K extends 'group'\n\t\t? // core shapes are always available and cannot be overridden so we just include them\n\t\t\tExtract<DrDefaultShape, { type: K }>\n\t\t: K extends DrDefaultShape['type']\n\t\t\t? // if it's a default shape type we need to check if it's been overridden\n\t\t\t\tK extends keyof DrGlobalShapePropsMap\n\t\t\t\t? // if it has been overriden then use the custom shape definition\n\t\t\t\t\tDrBaseShape<K, DrGlobalShapePropsMap[K]>\n\t\t\t\t: // if it has not been overriden then reuse existing type aliases for better type display\n\t\t\t\t\tExtract<DrDefaultShape, { type: K }>\n\t\t\t: // use the custom shape definition\n\t\t\t\tDrBaseShape<K, DrGlobalShapePropsMap[K & keyof DrGlobalShapePropsMap]>\n}\n\n/**\n * The set of all shapes that are available in the editor.\n *\n * This is the primary shape type used throughout tldraw. It includes both the\n * built-in default shapes and any custom shapes that might be added.\n *\n * You can use this type without a type argument to work with any shape, or pass\n * a specific shape type string (e.g., `'geo'`, `'arrow'`, `'text'`) to narrow\n * down to that specific shape type.\n *\n * @example\n * ```ts\n * // Work with any shape in the editor\n * function moveShape(shape: DrShape, deltaX: number, deltaY: number): DrShape {\n * return {\n * ...shape,\n * x: shape.x + deltaX,\n * y: shape.y + deltaY\n * }\n * }\n *\n * // Narrow to a specific shape type by passing the type as a generic argument\n * function getArrowLabel(shape: DrShape<'arrow'>): string {\n * return shape.props.text // TypeScript knows this is a DrArrowShape\n * }\n * ```\n *\n * @public\n */\nexport type DrShape<K extends keyof DrIndexedShapes = keyof DrIndexedShapes> = DrIndexedShapes[K]\n\n/**\n * A partial version of a shape, useful for updates and patches.\n *\n * This type represents a shape where all properties except `id` and `type` are optional.\n * It's commonly used when updating existing shapes or creating shape patches.\n *\n * @example\n * ```ts\n * // Update a shape's position\n * const shapeUpdate: DrShapePartial = {\n * id: 'shape:123',\n * type: 'geo',\n * x: 100,\n * y: 200\n * }\n *\n * // Update shape properties\n * const propsUpdate: DrShapePartial<DrGeoShape> = {\n * id: 'shape:123',\n * type: 'geo',\n * props: {\n * w: 150,\n * h: 100\n * }\n * }\n * ```\n *\n * @public\n */\nexport type DrShapePartial<T extends DrShape = DrShape> = T extends T\n\t? {\n\t\t\tid: DrShapeId\n\t\t\ttype: T['type']\n\t\t\tprops?: Partial<T['props']>\n\t\t\tmeta?: Partial<T['meta']>\n\t\t} & Partial<Omit<T, 'type' | 'id' | 'props' | 'meta'>>\n\t: never\n\n/**\n * A partial version of a shape, useful for creating shapes.\n *\n * This type represents a shape where all properties except `type` are optional.\n * It's commonly used when creating shapes.\n *\n * @example\n * ```ts\n * // Create a shape\n * const shapeCreate: DrCreateShapePartial = {\n * type: 'geo',\n * x: 100,\n * y: 200\n * }\n *\n * // Create shape properties\n * const propsCreate: DrCreateShapePartial<DrGeoShape> = {\n * type: 'geo',\n * props: {\n * w: 150,\n * h: 100\n * }\n * }\n * ```\n *\n * @public\n */\nexport type DrCreateShapePartial<T extends DrShape = DrShape> = T extends T\n\t? {\n\t\t\ttype: T['type']\n\t\t\tprops?: Partial<T['props']>\n\t\t\tmeta?: Partial<T['meta']>\n\t\t} & Partial<Omit<T, 'type' | 'props' | 'meta'>>\n\t: never\n\n/**\n * Extract a shape type by its props.\n *\n * This utility type takes a props object type and returns the corresponding shape type\n * from the DrShape union whose props match the given type.\n *\n * @example\n * ```ts\n * type MyShape = ExtractShapeByProps<{ w: number; h: number }>\n * // MyShape is now the type of shape(s) that have props with w and h as numbers\n * ```\n *\n * @public\n */\nexport type ExtractShapeByProps<P> = Extract<DrShape, { props: P }>\n\n/**\n * A unique identifier for a shape record.\n *\n * Shape IDs are branded strings that start with \"shape:\" followed by a unique identifier.\n * This type-safe approach prevents mixing up different types of record IDs.\n *\n * @example\n * ```ts\n * const shapeId: DrShapeId = createShapeId() // \"shape:abc123\"\n * const customId: DrShapeId = createShapeId('my-custom-id') // \"shape:my-custom-id\"\n * ```\n *\n * @public\n */\nexport type DrShapeId = RecordId<DrShape>\n\n/**\n * The ID of a shape's parent, which can be either a page or another shape.\n *\n * Shapes can be parented to pages (for top-level shapes) or to other shapes\n * (for shapes inside frames or groups).\n *\n * @example\n * ```ts\n * // Shape parented to a page\n * const pageParentId: DrParentId = 'page:main'\n *\n * // Shape parented to another shape (e.g., inside a frame)\n * const shapeParentId: DrParentId = 'shape:frame123'\n * ```\n *\n * @public\n */\nexport type DrParentId = DrPageId | DrShapeId\n\n/**\n * Migration version IDs for the root shape schema.\n *\n * These track the evolution of the base shape structure over time, ensuring\n * that shapes created in older versions can be migrated to newer formats.\n *\n * @example\n * ```ts\n * // Check if a migration needs to be applied\n * if (shapeVersion < rootShapeVersions.AddIsLocked) {\n * // Apply isLocked migration\n * }\n * ```\n *\n * @public\n */\nexport const rootShapeVersions = createMigrationIds('com.draw.shape', {\n\tAddIsLocked: 1,\n\tHoistOpacity: 2,\n\tAddMeta: 3,\n\tAddWhite: 4,\n})\n\n/**\n * Migration sequence for the root shape record type.\n *\n * This sequence defines how shape records should be transformed when migrating\n * between different schema versions. Each migration handles a specific version\n * upgrade, ensuring data compatibility across tldraw versions.\n *\n * @public\n */\nexport const rootShapeMigrations = createRecordMigrationSequence({\n\tsequenceId: 'com.draw.shape',\n\trecordType: 'shape',\n\tsequence: [\n\t\t{\n\t\t\tid: rootShapeVersions.AddIsLocked,\n\t\t\tup: (record: any) => {\n\t\t\t\trecord.isLocked = false\n\t\t\t},\n\t\t\tdown: (record: any) => {\n\t\t\t\tdelete record.isLocked\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: rootShapeVersions.HoistOpacity,\n\t\t\tup: (record: any) => {\n\t\t\t\trecord.opacity = Number(record.props.opacity ?? '1')\n\t\t\t\tdelete record.props.opacity\n\t\t\t},\n\t\t\tdown: (record: any) => {\n\t\t\t\tconst opacity = record.opacity\n\t\t\t\tdelete record.opacity\n\t\t\t\trecord.props.opacity =\n\t\t\t\t\topacity < 0.175\n\t\t\t\t\t\t? '0.1'\n\t\t\t\t\t\t: opacity < 0.375\n\t\t\t\t\t\t\t? '0.25'\n\t\t\t\t\t\t\t: opacity < 0.625\n\t\t\t\t\t\t\t\t? '0.5'\n\t\t\t\t\t\t\t\t: opacity < 0.875\n\t\t\t\t\t\t\t\t\t? '0.75'\n\t\t\t\t\t\t\t\t\t: '1'\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: rootShapeVersions.AddMeta,\n\t\t\tup: (record: any) => {\n\t\t\t\trecord.meta = {}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: rootShapeVersions.AddWhite,\n\t\t\tup: (_record) => {\n\t\t\t\t// noop\n\t\t\t},\n\t\t\tdown: (record: any) => {\n\t\t\t\tif (record.props.color === 'white') {\n\t\t\t\t\trecord.props.color = 'black'\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t],\n})\n\n/**\n * Type guard to check if a record is a shape.\n *\n * @param record - The record to check\n * @returns True if the record is a shape, false otherwise\n *\n * @example\n * ```ts\n * const record = store.get('shape:abc123')\n * if (isShape(record)) {\n * console.log(`Shape type: ${record.type}`)\n * console.log(`Position: (${record.x}, ${record.y})`)\n * }\n * ```\n *\n * @public\n */\nexport function isShape(record?: UnknownRecord): record is DrShape {\n\tif (!record) return false\n\treturn record.typeName === 'shape'\n}\n\n/**\n * Type guard to check if a string is a valid shape ID.\n *\n * @param id - The string to check\n * @returns True if the string is a valid shape ID, false otherwise\n *\n * @example\n * ```ts\n * const id = 'shape:abc123'\n * if (isShapeId(id)) {\n * const shape = store.get(id) // TypeScript knows id is DrShapeId\n * }\n *\n * // Check user input\n * function selectShape(id: string) {\n * if (isShapeId(id)) {\n * editor.selectShape(id)\n * } else {\n * console.error('Invalid shape ID format')\n * }\n * }\n * ```\n *\n * @public\n */\nexport function isShapeId(id?: string): id is DrShapeId {\n\tif (!id) return false\n\treturn id.startsWith('shape:')\n}\n\n/**\n * Creates a new shape ID.\n *\n * @param id - Optional custom ID suffix. If not provided, a unique ID will be generated\n * @returns A new shape ID with the \"shape:\" prefix\n *\n * @example\n * ```ts\n * // Create a shape with auto-generated ID\n * const shapeId = createShapeId() // \"shape:abc123\"\n *\n * // Create a shape with custom ID\n * const customShapeId = createShapeId('my-rectangle') // \"shape:my-rectangle\"\n *\n * // Use in shape creation\n * const newShape: DrGeoShape = {\n * id: createShapeId(),\n * type: 'geo',\n * x: 100,\n * y: 200,\n * // ... other properties\n * }\n * ```\n *\n * @public\n */\nexport function createShapeId(id?: string): DrShapeId {\n\treturn `shape:${id ?? uniqueId()}` as DrShapeId\n}\n\n/**\n * Extracts style properties from a shape's props definition and maps them to their property keys.\n *\n * This function analyzes shape property validators to identify which ones are style properties\n * and creates a mapping from StyleProp instances to their corresponding property keys.\n * It also validates that each style property is only used once per shape.\n *\n * @param props - Record of property validators for a shape type\n * @returns Map from StyleProp instances to their property keys\n * @throws Error if a style property is used more than once in the same shape\n *\n * @example\n * ```ts\n * const geoShapeProps = {\n * color: DefaultColorStyle,\n * fill: DefaultFillStyle,\n * width: T.number,\n * height: T.number\n * }\n *\n * const styleMap = getShapePropKeysByStyle(geoShapeProps)\n * // styleMap.get(DefaultColorStyle) === 'color'\n * // styleMap.get(DefaultFillStyle) === 'fill'\n * ```\n *\n * @internal\n */\nexport function getShapePropKeysByStyle(props: Record<string, T.Validatable<any>>) {\n\tconst propKeysByStyle = new Map<StyleProp<unknown>, string>()\n\tfor (const [key, prop] of Object.entries(props)) {\n\t\tif (prop instanceof StyleProp) {\n\t\t\tif (propKeysByStyle.has(prop)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Duplicate style prop ${prop.id}. Each style prop can only be used once within a shape.`\n\t\t\t\t)\n\t\t\t}\n\t\t\tpropKeysByStyle.set(prop, key)\n\t\t}\n\t}\n\treturn propKeysByStyle\n}\n\n/**\n * Creates a migration sequence for shape properties.\n *\n * This is a pass-through function that maintains the same structure as the input.\n * It's used for consistency and to provide a clear API for defining shape property migrations.\n *\n * @param migrations - The migration sequence to create\n * @returns The same migration sequence (pass-through)\n *\n * @example\n * ```ts\n * const myShapeMigrations = createShapePropsMigrationSequence({\n * sequence: [\n * {\n * id: 'com.myapp.shape.custom/1.0.0',\n * up: (props) => ({ ...props, newProperty: 'default' }),\n * down: ({ newProperty, ...props }) => props\n * }\n * ]\n * })\n * ```\n *\n * @public\n */\nexport function createShapePropsMigrationSequence(\n\tmigrations: DrPropsMigrations\n): DrPropsMigrations {\n\treturn migrations\n}\n\n/**\n * Creates properly formatted migration IDs for shape properties.\n *\n * Generates standardized migration IDs following the convention:\n * `com.draw.shape.{shapeType}/{version}`\n *\n * @param shapeType - The type of shape these migrations apply to\n * @param ids - Record mapping migration names to version numbers\n * @returns Record with the same keys but formatted migration ID values\n *\n * @example\n * ```ts\n * const myShapeVersions = createShapePropsMigrationIds('custom', {\n * AddColor: 1,\n * AddSize: 2,\n * RefactorProps: 3\n * })\n * // Result: {\n * // AddColor: 'com.draw.shape.custom/1',\n * // AddSize: 'com.draw.shape.custom/2',\n * // RefactorProps: 'com.draw.shape.custom/3'\n * // }\n * ```\n *\n * @public\n */\nexport function createShapePropsMigrationIds<\n\tconst S extends string,\n\tconst T extends Record<string, number>,\n>(shapeType: S, ids: T): { [k in keyof T]: `com.draw.shape.${S}/${T[k]}` } {\n\treturn mapObjectMapValues(ids, (_k, v) => `com.draw.shape.${shapeType}/${v}`) as any\n}\n\n/**\n * Creates the record type definition for shapes.\n *\n * This function generates a complete record type for shapes that includes validation\n * for all registered shape types. It combines the base shape properties with\n * type-specific properties and creates a union validator that can handle any\n * registered shape type.\n *\n * @param shapes - Record of shape type names to their schema configuration\n * @returns A complete RecordType for shapes with proper validation and default properties\n *\n * @example\n * ```ts\n * const shapeRecordType = createShapeRecordType({\n * geo: { props: geoShapeProps, migrations: geoMigrations },\n * arrow: { props: arrowShapeProps, migrations: arrowMigrations }\n * })\n * ```\n *\n * @internal\n */\nexport function createShapeRecordType(shapes: Record<string, SchemaPropsInfo>) {\n\treturn createRecordType('shape', {\n\t\tscope: 'document',\n\t\tvalidator: T.model(\n\t\t\t'shape',\n\t\t\tT.union(\n\t\t\t\t'type',\n\t\t\t\tmapObjectMapValues(shapes, (type, { props, meta }) =>\n\t\t\t\t\tcreateShapeValidator(type, props, meta)\n\t\t\t\t)\n\t\t\t)\n\t\t),\n\t}).withDefaultProperties(() => ({\n\t\tx: 0,\n\t\ty: 0,\n\t\trotation: 0,\n\t\tisLocked: false,\n\t\topacity: 1,\n\t\tmeta: {},\n\t}))\n}\n","import {\n\tMigration,\n\tMigrationId,\n\tMigrationSequence,\n\tRecordType,\n\tStandaloneDependsOn,\n\tUnknownRecord,\n\tcreateMigrationSequence,\n} from '@ibodr/store'\nimport { MakeUndefinedOptional, assert } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { SchemaPropsInfo } from './createDrSchema'\n\n/**\n * Maps a record's property types to their corresponding validators.\n *\n * This utility type takes a record type with a `props` object and creates\n * a mapping where each property key maps to a validator for that property's type.\n * This is used to define validation schemas for record properties.\n *\n * @example\n * ```ts\n * interface MyShape extends DrBaseShape<'custom', { width: number; color: string }> {}\n *\n * // Define validators for the shape properties\n * const myShapeProps: RecordProps<MyShape> = {\n * width: T.number,\n * color: T.string\n * }\n * ```\n *\n * @public\n */\nexport type RecordProps<R extends UnknownRecord & { props: object }> = {\n\t[K in keyof R['props']]: T.Validatable<R['props'][K]>\n}\n\n/**\n * Extracts the TypeScript types from a record properties configuration.\n *\n * Takes a configuration object where values are validators and returns the\n * corresponding TypeScript types, with undefined values made optional.\n *\n * @example\n * ```ts\n * const shapePropsConfig = {\n * width: T.number,\n * height: T.number,\n * color: T.optional(T.string)\n * }\n *\n * type ShapeProps = RecordPropsType<typeof shapePropsConfig>\n * // Result: { width: number; height: number; color?: string }\n * ```\n *\n * @public\n */\nexport type RecordPropsType<Config extends Record<string, T.Validatable<any>>> =\n\tMakeUndefinedOptional<{\n\t\t[K in keyof Config]: T.TypeOf<Config[K]>\n\t}>\n\n/**\n * A migration definition for shape or record properties.\n *\n * Defines how to transform record properties when migrating between schema versions.\n * Each migration has an `up` function to upgrade data and an optional `down` function\n * to downgrade data if needed.\n *\n * @example\n * ```ts\n * const addColorMigration: DrPropsMigration = {\n * id: 'com.myapp.shape.custom/1.0.0',\n * up: (props) => {\n * // Add a default color property\n * return { ...props, color: 'black' }\n * },\n * down: (props) => {\n * // Remove the color property\n * const { color, ...rest } = props\n * return rest\n * }\n * }\n * ```\n *\n * @public\n */\nexport interface DrPropsMigration {\n\treadonly id: MigrationId\n\treadonly dependsOn?: MigrationId[]\n\t// eslint-disable-next-line tldraw/method-signature-style\n\treadonly up: (props: any) => any\n\t/**\n\t * If a down migration was deployed more than a couple of months ago it should be safe to retire it.\n\t * We only really need them to smooth over the transition between versions, and some folks do keep\n\t * browser tabs open for months without refreshing, but at a certain point that kind of behavior is\n\t * on them. Plus anyway recently chrome has started to actually kill tabs that are open for too long\n\t * rather than just suspending them, so if other browsers follow suit maybe it's less of a concern.\n\t *\n\t * @public\n\t */\n\treadonly down?: 'none' | 'retired' | ((props: any) => any)\n}\n\n/**\n * A sequence of property migrations for a record type.\n *\n * Contains an ordered array of migrations that should be applied to transform\n * record properties from one version to another. Migrations can include both\n * property-specific migrations and standalone dependency declarations.\n *\n * @example\n * ```ts\n * const myShapeMigrations: DrPropsMigrations = {\n * sequence: [\n * {\n * id: 'com.myapp.shape.custom/1.0.0',\n * up: (props) => ({ ...props, version: 1 })\n * },\n * {\n * id: 'com.myapp.shape.custom/2.0.0',\n * up: (props) => ({ ...props, newFeature: true })\n * }\n * ]\n * }\n * ```\n *\n * @public\n */\nexport interface DrPropsMigrations {\n\treadonly sequence: Array<StandaloneDependsOn | DrPropsMigration>\n}\n\n/**\n * Processes property migrations for all record types in a schema.\n *\n * Takes a collection of record configurations and converts their migrations\n * into proper migration sequences that can be used by the store system.\n * Handles different migration formats including legacy migrations.\n *\n * @param typeName - The base type name for the records (e.g., 'shape', 'binding')\n * @param records - Record of type names to their schema configuration\n * @returns Array of processed migration sequences\n *\n * @example\n * ```ts\n * const shapeRecords = {\n * geo: { props: geoProps, migrations: geoMigrations },\n * arrow: { props: arrowProps, migrations: arrowMigrations }\n * }\n *\n * const sequences = processPropsMigrations('shape', shapeRecords)\n * ```\n *\n * @internal\n */\nexport function processPropsMigrations<R extends UnknownRecord & { type: string; props: object }>(\n\ttypeName: R['typeName'],\n\trecords: Record<string, SchemaPropsInfo>\n) {\n\tconst result: MigrationSequence[] = []\n\n\tfor (const [subType, { migrations }] of Object.entries(records)) {\n\t\tconst sequenceId = `com.draw.${typeName}.${subType}`\n\t\tif (!migrations) {\n\t\t\t// provide empty migrations sequence to allow for future migrations\n\t\t\tresult.push(\n\t\t\t\tcreateMigrationSequence({\n\t\t\t\t\tsequenceId,\n\t\t\t\t\tretroactive: true,\n\t\t\t\t\tsequence: [],\n\t\t\t\t})\n\t\t\t)\n\t\t} else if ('sequenceId' in migrations) {\n\t\t\tassert(\n\t\t\t\tsequenceId === migrations.sequenceId,\n\t\t\t\t`sequenceId mismatch for ${subType} ${RecordType} migrations. Expected '${sequenceId}', got '${migrations.sequenceId}'`\n\t\t\t)\n\t\t\tresult.push(migrations)\n\t\t} else if ('sequence' in migrations) {\n\t\t\tresult.push(\n\t\t\t\tcreateMigrationSequence({\n\t\t\t\t\tsequenceId,\n\t\t\t\t\tretroactive: true,\n\t\t\t\t\tsequence: migrations.sequence.map((m) =>\n\t\t\t\t\t\t'id' in m ? createPropsMigration(typeName, subType, m) : m\n\t\t\t\t\t),\n\t\t\t\t})\n\t\t\t)\n\t\t} else {\n\t\t\t// legacy migrations, will be removed in the future\n\t\t\tresult.push(\n\t\t\t\tcreateMigrationSequence({\n\t\t\t\t\tsequenceId,\n\t\t\t\t\tretroactive: true,\n\t\t\t\t\tsequence: Object.keys(migrations.migrators)\n\t\t\t\t\t\t.map((k) => Number(k))\n\t\t\t\t\t\t.sort((a: number, b: number) => a - b)\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t(version): Migration => ({\n\t\t\t\t\t\t\t\tid: `${sequenceId}/${version}`,\n\t\t\t\t\t\t\t\tscope: 'record',\n\t\t\t\t\t\t\t\tfilter: (r) => r.typeName === typeName && (r as R).type === subType,\n\t\t\t\t\t\t\t\tup: (record: any) => {\n\t\t\t\t\t\t\t\t\tconst result = migrations.migrators[version].up(record)\n\t\t\t\t\t\t\t\t\tif (result) {\n\t\t\t\t\t\t\t\t\t\treturn result\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tdown: (record: any) => {\n\t\t\t\t\t\t\t\t\tconst result = migrations.migrators[version].down(record)\n\t\t\t\t\t\t\t\t\tif (result) {\n\t\t\t\t\t\t\t\t\t\treturn result\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t),\n\t\t\t\t})\n\t\t\t)\n\t\t}\n\t}\n\n\treturn result\n}\n\n/**\n * Creates a store migration from a props migration definition.\n *\n * Converts a high-level property migration into a low-level store migration\n * that can be applied to records. The resulting migration will only affect\n * records of the specified type and subtype.\n *\n * @param typeName - The base type name (e.g., 'shape', 'binding')\n * @param subType - The specific subtype (e.g., 'geo', 'arrow')\n * @param m - The property migration definition\n * @returns A store migration that applies the property transformation\n *\n * @example\n * ```ts\n * const propsMigration: DrPropsMigration = {\n * id: 'com.myapp.shape.custom/1.0.0',\n * up: (props) => ({ ...props, color: 'blue' })\n * }\n *\n * const storeMigration = createPropsMigration('shape', 'custom', propsMigration)\n * ```\n *\n * @internal\n */\nexport function createPropsMigration<R extends UnknownRecord & { type: string; props: object }>(\n\ttypeName: R['typeName'],\n\tsubType: R['type'],\n\tm: DrPropsMigration\n): Migration {\n\treturn {\n\t\tid: m.id,\n\t\tdependsOn: m.dependsOn,\n\t\tscope: 'record',\n\t\tfilter: (r) => r.typeName === typeName && (r as R).type === subType,\n\t\tup: (record: any) => {\n\t\t\tconst result = m.up(record.props)\n\t\t\tif (result) {\n\t\t\t\trecord.props = result\n\t\t\t}\n\t\t},\n\t\tdown:\n\t\t\ttypeof m.down === 'function'\n\t\t\t\t? (record: any) => {\n\t\t\t\t\t\tconst result = (m.down as (props: any) => any)(record.props)\n\t\t\t\t\t\tif (result) {\n\t\t\t\t\t\t\trecord.props = result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t}\n}\n","import { StyleProp } from './StyleProp'\nimport { DrDefaultColor, DrThemeDefaultColors, DrThemes } from './DrTheme'\n\n/**\n * The names of all available shape colors, derived from {@link DrThemeDefaultColors}.\n * Extend {@link DrThemeDefaultColors} to add custom color names.\n *\n * @public\n */\nexport type DrDefaultColorStyle = {\n\t[K in keyof DrThemeDefaultColors]: DrThemeDefaultColors[K] extends DrDefaultColor ? K : never\n}[keyof DrThemeDefaultColors] &\n\tstring\n\n/**\n * Used only for initial values of the color style; the source of truth has moved to DrTheme.\n *\n * @internal\n */\nconst defaultColorNames: DrDefaultColorStyle[] = [\n\t'black',\n\t'grey',\n\t'light-violet',\n\t'violet',\n\t'blue',\n\t'light-blue',\n\t'yellow',\n\t'orange',\n\t'green',\n\t'light-green',\n\t'light-red',\n\t'red',\n\t'white',\n] as const\n\n/**\n * @public\n */\nexport const DefaultColorStyle = StyleProp.defineEnum('draw:color', {\n\tdefaultValue: 'black',\n\tvalues: defaultColorNames,\n})\n\n/**\n * @public\n */\nexport const DefaultLabelColorStyle = StyleProp.defineEnum('draw:labelColor', {\n\tdefaultValue: 'black',\n\tvalues: defaultColorNames,\n})\n\n/**\n * Scan theme definitions and sync color registrations to match.\n * A color entry is any key in `DrThemeColors` whose value is an object\n * (i.e. a {@link DrDefaultColor}), as opposed to utility strings like\n * `background` or `text`.\n *\n * Colors present in themes but not yet registered will be added.\n * Colors currently registered but absent from all themes will be removed.\n *\n * @public\n */\nexport function registerColorsFromThemes(definitions: DrThemes): void {\n\tconst colorNames = new Set<DrDefaultColorStyle>()\n\tfor (const def of Object.values(definitions)) {\n\t\tfor (const colorPalette of [def.colors.light, def.colors.dark]) {\n\t\t\tfor (const [key, value] of Object.entries(colorPalette)) {\n\t\t\t\tif (typeof value === 'object' && value !== null) {\n\t\t\t\t\tcolorNames.add(key as DrDefaultColorStyle)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (colorNames.size > 0) {\n\t\tDefaultColorStyle.addValues(...colorNames)\n\t\tDefaultLabelColorStyle.addValues(...colorNames)\n\t}\n\n\tconst toRemove = DefaultColorStyle.values.filter((v) => !colorNames.has(v as DrDefaultColorStyle))\n\tif (toRemove.length > 0) {\n\t\tDefaultColorStyle.removeValues(...toRemove)\n\t\tDefaultLabelColorStyle.removeValues(...toRemove)\n\t}\n\n\tif (process.env.NODE_ENV !== 'production') {\n\t\tfor (const def of Object.values(definitions)) {\n\t\t\tfor (const color of colorNames) {\n\t\t\t\tif (!(color in def.colors.light)) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`Theme '${def.id}' light palette is missing color '${color}'. Shapes using this color won't render correctly.`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (!(color in def.colors.dark)) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`Theme '${def.id}' dark palette is missing color '${color}'. Shapes using this color won't render correctly.`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n","import { T } from '@ibodr/validate'\nimport { StyleProp } from './StyleProp'\n\n/**\n * Default dash style property used by tldraw shapes for line styling.\n * Controls how shape outlines and lines are rendered with different dash patterns.\n *\n * Available values:\n * - `draw` - Hand-drawn, sketchy line style\n * - `solid` - Continuous solid line\n * - `dashed` - Evenly spaced dashes\n * - `dotted` - Evenly spaced dots\n *\n * @example\n * ```ts\n * import { DefaultDashStyle } from '@ibodr/schema'\n *\n * // Use in shape props definition\n * interface MyShapeProps {\n * dash: typeof DefaultDashStyle\n * // other props...\n * }\n *\n * // Create a shape with dashed outline\n * const shape = {\n * // ... other properties\n * props: {\n * dash: 'dashed' as const,\n * // ... other props\n * }\n * }\n * ```\n *\n * @public\n */\nexport const DefaultDashStyle = StyleProp.defineEnum('draw:dash', {\n\tdefaultValue: 'draw',\n\tvalues: ['draw', 'solid', 'dashed', 'dotted', 'none'],\n})\n\n/**\n * Type representing a default dash style value.\n * This is a union type of all available dash style options.\n *\n * @example\n * ```ts\n * import { DrDefaultDashStyle } from '@ibodr/schema'\n *\n * // Valid dash style values\n * const drawStyle: DrDefaultDashStyle = 'draw'\n * const solidStyle: DrDefaultDashStyle = 'solid'\n * const dashedStyle: DrDefaultDashStyle = 'dashed'\n * const dottedStyle: DrDefaultDashStyle = 'dotted'\n *\n * // Use in a function parameter\n * function setShapeDash(dash: DrDefaultDashStyle) {\n * // Apply dash style to shape\n * }\n * ```\n *\n * @public\n */\nexport type DrDefaultDashStyle = T.TypeOf<typeof DefaultDashStyle>\n","import { T } from '@ibodr/validate'\nimport { StyleProp } from './StyleProp'\n\n/**\n * Default fill style property used by tldraw shapes for interior styling.\n * Controls how the inside of shapes are filled or left empty.\n *\n * Available values:\n * - `none` - No fill, shape interior is transparent\n * - `semi` - Semi-transparent fill using the shape's color\n * - `solid` - Solid fill using the shape's color\n * - `pattern` - Crosshatch pattern fill using the shape's color\n * - `fill` - Alternative solid fill variant\n *\n * @example\n * ```ts\n * import { DefaultFillStyle } from '@ibodr/schema'\n *\n * // Use in shape props definition\n * interface MyShapeProps {\n * fill: typeof DefaultFillStyle\n * // other props...\n * }\n *\n * // Create a shape with solid fill\n * const shape = {\n * // ... other properties\n * props: {\n * fill: 'solid' as const,\n * // ... other props\n * }\n * }\n * ```\n *\n * @public\n */\nexport const DefaultFillStyle = StyleProp.defineEnum('draw:fill', {\n\tdefaultValue: 'none',\n\tvalues: ['none', 'semi', 'solid', 'pattern', 'fill', 'lined-fill'],\n})\n\n/**\n * Type representing a default fill style value.\n * This is a union type of all available fill style options.\n *\n * @example\n * ```ts\n * import { DrDefaultFillStyle } from '@ibodr/schema'\n *\n * // Valid fill style values\n * const noFill: DrDefaultFillStyle = 'none'\n * const solidFill: DrDefaultFillStyle = 'solid'\n * const patternFill: DrDefaultFillStyle = 'pattern'\n *\n * // Use in a function parameter\n * function setShapeFill(fill: DrDefaultFillStyle) {\n * // Apply fill style to shape\n * }\n * ```\n *\n * @public\n */\nexport type DrDefaultFillStyle = T.TypeOf<typeof DefaultFillStyle>\n","import { StyleProp } from './StyleProp'\nimport { DrThemeFont, DrThemeFonts, DrThemes } from './DrTheme'\n\n/**\n * Default font style property used by tldraw shapes for text styling.\n * Controls which typeface is used for text content within shapes.\n *\n * Available values:\n * - `draw` - Hand-drawn, sketchy font style\n * - `sans` - Clean sans-serif font\n * - `serif` - Traditional serif font\n * - `mono` - Monospace font for code-like text\n *\n * @example\n * ```ts\n * import { DefaultFontStyle } from '@ibodr/schema'\n *\n * // Use in shape props definition\n * interface MyTextShapeProps {\n * font: typeof DefaultFontStyle\n * // other props...\n * }\n *\n * // Create a text shape with monospace font\n * const textShape = {\n * // ... other properties\n * props: {\n * font: 'mono' as const,\n * // ... other props\n * }\n * }\n * ```\n *\n * @public\n */\nexport const DefaultFontStyle = StyleProp.defineEnum('draw:font', {\n\tdefaultValue: 'draw',\n\tvalues: ['draw', 'sans', 'serif', 'mono'],\n})\n\n/**\n * The names of all available font styles, derived from {@link DrThemeFonts}.\n * Extend {@link DrThemeFonts} to add custom font names.\n *\n * @example\n * ```ts\n * import { DrDefaultFontStyle } from '@ibodr/schema'\n *\n * // Valid font style values\n * const drawFont: DrDefaultFontStyle = 'draw'\n * const sansFont: DrDefaultFontStyle = 'sans'\n * const serifFont: DrDefaultFontStyle = 'serif'\n * const monoFont: DrDefaultFontStyle = 'mono'\n *\n * // Use in a function parameter\n * function setTextFont(font: DrDefaultFontStyle) {\n * // Apply font style to text\n * }\n * ```\n *\n * @public\n */\nexport type DrDefaultFontStyle = keyof DrThemeFonts & string\n\n/**\n * Mapping of font style names to their corresponding CSS font-family declarations.\n * These are the actual CSS font families used when rendering text with each font style.\n *\n * @example\n * ```ts\n * import { DefaultFontFamilies, DrDefaultFontStyle } from '@ibodr/schema'\n *\n * // Get CSS font family for a font style\n * const fontStyle: DrDefaultFontStyle = 'mono'\n * const cssFamily = DefaultFontFamilies[fontStyle] // \"'draw_mono', monospace\"\n *\n * // Apply to DOM element\n * element.style.fontFamily = DefaultFontFamilies.sans\n * ```\n *\n * @public\n */\nexport const DefaultFontFamilies = {\n\tdraw: \"'draw_draw', sans-serif\",\n\tsans: \"'draw_sans', sans-serif\",\n\tserif: \"'draw_serif', serif\",\n\tmono: \"'draw_mono', monospace\",\n}\n\n/** @internal */\nexport function isFontEntry(value: unknown): value is DrThemeFont {\n\treturn typeof value === 'object' && value !== null && 'fontFamily' in value\n}\n\n/**\n * Scan theme definitions and sync font registrations to match.\n * A font entry is any key in `DrThemeFonts` whose value is a {@link DrThemeFont}\n * object (i.e. has a `fontFamily` property).\n *\n * Fonts present in themes but not yet registered will be added.\n * Fonts currently registered but absent from all themes will be removed.\n *\n * @public\n */\nexport function registerFontsFromThemes(definitions: DrThemes): void {\n\tconst fontNames = new Set<string>()\n\tfor (const def of Object.values(definitions)) {\n\t\tif (!def.fonts) continue\n\t\tfor (const [key, value] of Object.entries(def.fonts)) {\n\t\t\tif (isFontEntry(value)) {\n\t\t\t\tfontNames.add(key)\n\t\t\t}\n\t\t}\n\t}\n\n\tconst toAdd = [...fontNames].filter((v) => !DefaultFontStyle.values.includes(v as any))\n\tif (toAdd.length > 0) {\n\t\tDefaultFontStyle.addValues(...(toAdd as any))\n\t}\n\n\tconst toRemove = DefaultFontStyle.values.filter((v) => !fontNames.has(v as string))\n\tif (toRemove.length > 0) {\n\t\tDefaultFontStyle.removeValues(...toRemove)\n\t}\n\n\tif (process.env.NODE_ENV !== 'production') {\n\t\tfor (const def of Object.values(definitions)) {\n\t\t\tfor (const font of fontNames) {\n\t\t\t\tif (!def.fonts || !(font in def.fonts)) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`Theme '${def.id}' is missing font '${font}'. Shapes using this font won't render correctly in this theme.`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n","import { T } from '@ibodr/validate'\nimport { StyleProp } from './StyleProp'\n\n/**\n * Default size style property used by tldraw shapes for scaling visual elements.\n * Controls the relative size of shape elements like stroke width, text size, and other proportional features.\n *\n * Available values:\n * - `s` - Small size\n * - `m` - Medium size (default)\n * - `l` - Large size\n * - `xl` - Extra large size\n *\n * @example\n * ```ts\n * import { DefaultSizeStyle } from '@ibodr/schema'\n *\n * // Use in shape props definition\n * interface MyShapeProps {\n * size: typeof DefaultSizeStyle\n * // other props...\n * }\n *\n * // Create a shape with large size\n * const shape = {\n * // ... other properties\n * props: {\n * size: 'l' as const,\n * // ... other props\n * }\n * }\n * ```\n *\n * @public\n */\nexport const DefaultSizeStyle = StyleProp.defineEnum('draw:size', {\n\tdefaultValue: 'm',\n\tvalues: ['s', 'm', 'l', 'xl'],\n})\n\n/**\n * Type representing a default size style value.\n * This is a union type of all available size options.\n *\n * @example\n * ```ts\n * import { DrDefaultSizeStyle } from '@ibodr/schema'\n *\n * // Valid size values\n * const smallSize: DrDefaultSizeStyle = 's'\n * const mediumSize: DrDefaultSizeStyle = 'm'\n * const largeSize: DrDefaultSizeStyle = 'l'\n * const extraLargeSize: DrDefaultSizeStyle = 'xl'\n *\n * // Use in a function parameter\n * function setShapeSize(size: DrDefaultSizeStyle) {\n * // Apply size style to shape\n * }\n * ```\n *\n * @public\n */\nexport type DrDefaultSizeStyle = T.TypeOf<typeof DefaultSizeStyle>\n","import { createMigrationSequence } from '@ibodr/store'\nimport { structuredClone } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { VecModel, vecModelValidator } from '../misc/geometry-types'\nimport { DrRichText, richTextValidator, toRichText } from '../misc/DrRichText'\nimport { createBindingId } from '../records/DrBinding'\nimport { DrShape, DrShapeId, createShapePropsMigrationIds } from '../records/DrShape'\nimport { RecordProps, DrPropsMigration, createPropsMigration } from '../recordsWithProps'\nimport { StyleProp } from '../styles/StyleProp'\nimport {\n\tDefaultColorStyle,\n\tDefaultLabelColorStyle,\n\tDrDefaultColorStyle,\n} from '../styles/DrColorStyle'\nimport { DefaultDashStyle, DrDefaultDashStyle } from '../styles/DrDashStyle'\nimport { DefaultFillStyle, DrDefaultFillStyle } from '../styles/DrFillStyle'\nimport { DefaultFontStyle, DrDefaultFontStyle } from '../styles/DrFontStyle'\nimport { DefaultSizeStyle, DrDefaultSizeStyle } from '../styles/DrSizeStyle'\nimport { DrBaseShape } from './DrBaseShape'\n\nconst arrowKinds = ['arc', 'elbow'] as const\n/**\n * Style property for arrow shape kind, determining how the arrow is drawn.\n *\n * Arrows can be drawn as arcs (curved) or elbows (angled with straight segments).\n * This affects the visual appearance and behavior of arrow shapes.\n *\n * @example\n * ```ts\n * // Create an arrow with arc style (curved)\n * const arcArrow: DrArrowShape = {\n * // ... other properties\n * props: {\n * kind: 'arc',\n * // ... other props\n * }\n * }\n *\n * // Create an arrow with elbow style (angled)\n * const elbowArrow: DrArrowShape = {\n * // ... other properties\n * props: {\n * kind: 'elbow',\n * // ... other props\n * }\n * }\n * ```\n *\n * @public\n */\nexport const ArrowShapeKindStyle = StyleProp.defineEnum('draw:arrowKind', {\n\tdefaultValue: 'arc',\n\tvalues: arrowKinds,\n})\n\n/**\n * The type representing arrow shape kinds.\n *\n * @public\n */\nexport type DrArrowShapeKind = T.TypeOf<typeof ArrowShapeKindStyle>\n\nconst arrowheadTypes = [\n\t'arrow',\n\t'triangle',\n\t'square',\n\t'dot',\n\t'pipe',\n\t'diamond',\n\t'inverted',\n\t'bar',\n\t'none',\n] as const\n\n/**\n * Style property for the arrowhead at the start of an arrow.\n *\n * Defines the visual style of the arrowhead at the beginning of the arrow path.\n * Can be one of several predefined styles or none for no arrowhead.\n *\n * @example\n * ```ts\n * // Arrow with no start arrowhead but triangle end arrowhead\n * const arrow: DrArrowShape = {\n * // ... other properties\n * props: {\n * arrowheadStart: 'none',\n * arrowheadEnd: 'triangle',\n * // ... other props\n * }\n * }\n * ```\n *\n * @public\n */\nexport const ArrowShapeArrowheadStartStyle = StyleProp.defineEnum('draw:arrowheadStart', {\n\tdefaultValue: 'none',\n\tvalues: arrowheadTypes,\n})\n\n/**\n * Style property for the arrowhead at the end of an arrow.\n *\n * Defines the visual style of the arrowhead at the end of the arrow path.\n * Defaults to 'arrow' style, giving arrows their characteristic pointed appearance.\n *\n * @example\n * ```ts\n * // Arrow with different start and end arrowheads\n * const doubleArrow: DrArrowShape = {\n * // ... other properties\n * props: {\n * arrowheadStart: 'triangle',\n * arrowheadEnd: 'diamond',\n * // ... other props\n * }\n * }\n * ```\n *\n * @public\n */\nexport const ArrowShapeArrowheadEndStyle = StyleProp.defineEnum('draw:arrowheadEnd', {\n\tdefaultValue: 'arrow',\n\tvalues: arrowheadTypes,\n})\n\n/**\n * The type representing arrowhead styles for both start and end of arrows.\n *\n * @public\n */\nexport type DrArrowShapeArrowheadStyle = T.TypeOf<typeof ArrowShapeArrowheadStartStyle>\n\n/**\n * Properties specific to arrow shapes.\n *\n * Defines all the configurable aspects of an arrow shape, including visual styling,\n * geometry, text labeling, and positioning. Arrows can connect two points and\n * optionally display text labels.\n *\n * @example\n * ```ts\n * const arrowProps: DrArrowShapeProps = {\n * kind: 'arc',\n * labelColor: 'black',\n * color: 'blue',\n * fill: 'none',\n * dash: 'solid',\n * size: 'm',\n * arrowheadStart: 'none',\n * arrowheadEnd: 'arrow',\n * font: 'draw',\n * start: { x: 0, y: 0 },\n * end: { x: 100, y: 100 },\n * bend: 0.2,\n * richText: toRichText('Label'),\n * labelPosition: 0.5,\n * scale: 1,\n * elbowMidPoint: 0.5\n * }\n * ```\n *\n * @public\n */\nexport interface DrArrowShapeProps {\n\tkind: DrArrowShapeKind\n\tlabelColor: DrDefaultColorStyle\n\tcolor: DrDefaultColorStyle\n\tfill: DrDefaultFillStyle\n\tdash: DrDefaultDashStyle\n\tsize: DrDefaultSizeStyle\n\tarrowheadStart: DrArrowShapeArrowheadStyle\n\tarrowheadEnd: DrArrowShapeArrowheadStyle\n\tfont: DrDefaultFontStyle\n\tstart: VecModel\n\tend: VecModel\n\tbend: number\n\trichText: DrRichText\n\tlabelPosition: number\n\tscale: number\n\telbowMidPoint: number\n}\n\n/**\n * A complete arrow shape record.\n *\n * Combines the base shape interface with arrow-specific properties to create\n * a full arrow shape that can be stored and manipulated in the editor.\n *\n * @example\n * ```ts\n * const arrowShape: DrArrowShape = {\n * id: 'shape:arrow123',\n * typeName: 'shape',\n * type: 'arrow',\n * x: 100,\n * y: 200,\n * rotation: 0,\n * index: 'a1',\n * parentId: 'page:main',\n * isLocked: false,\n * opacity: 1,\n * props: {\n * kind: 'arc',\n * start: { x: 0, y: 0 },\n * end: { x: 150, y: 100 },\n * // ... other props\n * },\n * meta: {}\n * }\n * ```\n *\n * @public\n */\nexport type DrArrowShape = DrBaseShape<'arrow', DrArrowShapeProps>\n\n/**\n * Validation configuration for arrow shape properties.\n *\n * Defines the validators for each property of an arrow shape, ensuring that\n * arrow shape data is valid and conforms to the expected types and constraints.\n *\n * @example\n * ```ts\n * // The validators ensure proper typing and validation\n * const validator = T.object(arrowShapeProps)\n * const validArrowProps = validator.validate({\n * kind: 'arc',\n * start: { x: 0, y: 0 },\n * end: { x: 100, y: 50 },\n * // ... other required properties\n * })\n * ```\n *\n * @public\n */\nexport const arrowShapeProps: RecordProps<DrArrowShape> = {\n\tkind: ArrowShapeKindStyle,\n\tlabelColor: DefaultLabelColorStyle,\n\tcolor: DefaultColorStyle,\n\tfill: DefaultFillStyle,\n\tdash: DefaultDashStyle,\n\tsize: DefaultSizeStyle,\n\tarrowheadStart: ArrowShapeArrowheadStartStyle,\n\tarrowheadEnd: ArrowShapeArrowheadEndStyle,\n\tfont: DefaultFontStyle,\n\tstart: vecModelValidator,\n\tend: vecModelValidator,\n\tbend: T.number,\n\trichText: richTextValidator,\n\tlabelPosition: T.number,\n\tscale: T.nonZeroNumber,\n\telbowMidPoint: T.number,\n}\n\n/**\n * Migration version identifiers for arrow shape properties.\n *\n * These track the evolution of the arrow shape schema over time, with each\n * version representing a specific change to the arrow shape structure or properties.\n *\n * @example\n * ```ts\n * // Used internally for migration system\n * if (version < arrowShapeVersions.AddLabelColor) {\n * // Apply label color migration\n * }\n * ```\n *\n * @public\n */\nexport const arrowShapeVersions = createShapePropsMigrationIds('arrow', {\n\tAddLabelColor: 1,\n\tAddIsPrecise: 2,\n\tAddLabelPosition: 3,\n\tExtractBindings: 4,\n\tAddScale: 5,\n\tAddElbow: 6,\n\tAddRichText: 7,\n\tAddRichTextAttrs: 8,\n})\n\nfunction propsMigration(migration: DrPropsMigration) {\n\treturn createPropsMigration<DrArrowShape>('shape', 'arrow', migration)\n}\n\n/**\n * Complete migration sequence for arrow shapes.\n *\n * Defines all the migrations needed to transform arrow shape data from older\n * versions to the current version. Each migration handles a specific schema change,\n * ensuring backward compatibility and smooth data evolution.\n *\n * @public\n */\nexport const arrowShapeMigrations = createMigrationSequence({\n\tsequenceId: 'com.draw.shape.arrow',\n\tretroactive: false,\n\tsequence: [\n\t\tpropsMigration({\n\t\t\tid: arrowShapeVersions.AddLabelColor,\n\t\t\tup: (props) => {\n\t\t\t\tprops.labelColor = 'black'\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t}),\n\n\t\tpropsMigration({\n\t\t\tid: arrowShapeVersions.AddIsPrecise,\n\t\t\tup: ({ start, end }) => {\n\t\t\t\tif (start.type === 'binding') {\n\t\t\t\t\tstart.isPrecise = !(start.normalizedAnchor.x === 0.5 && start.normalizedAnchor.y === 0.5)\n\t\t\t\t}\n\t\t\t\tif (end.type === 'binding') {\n\t\t\t\t\tend.isPrecise = !(end.normalizedAnchor.x === 0.5 && end.normalizedAnchor.y === 0.5)\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: ({ start, end }) => {\n\t\t\t\tif (start.type === 'binding') {\n\t\t\t\t\tif (!start.isPrecise) {\n\t\t\t\t\t\tstart.normalizedAnchor = { x: 0.5, y: 0.5 }\n\t\t\t\t\t}\n\t\t\t\t\tdelete start.isPrecise\n\t\t\t\t}\n\t\t\t\tif (end.type === 'binding') {\n\t\t\t\t\tif (!end.isPrecise) {\n\t\t\t\t\t\tend.normalizedAnchor = { x: 0.5, y: 0.5 }\n\t\t\t\t\t}\n\t\t\t\t\tdelete end.isPrecise\n\t\t\t\t}\n\t\t\t},\n\t\t}),\n\n\t\tpropsMigration({\n\t\t\tid: arrowShapeVersions.AddLabelPosition,\n\t\t\tup: (props) => {\n\t\t\t\tprops.labelPosition = 0.5\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.labelPosition\n\t\t\t},\n\t\t}),\n\n\t\t{\n\t\t\tid: arrowShapeVersions.ExtractBindings,\n\t\t\tscope: 'storage',\n\t\t\tup: (storage) => {\n\t\t\t\ttype OldArrowTerminal =\n\t\t\t\t\t| {\n\t\t\t\t\t\t\ttype: 'point'\n\t\t\t\t\t\t\tx: number\n\t\t\t\t\t\t\ty: number\n\t\t\t\t\t }\n\t\t\t\t\t| {\n\t\t\t\t\t\t\ttype: 'binding'\n\t\t\t\t\t\t\tboundShapeId: DrShapeId\n\t\t\t\t\t\t\tnormalizedAnchor: VecModel\n\t\t\t\t\t\t\tisExact: boolean\n\t\t\t\t\t\t\tisPrecise: boolean\n\t\t\t\t\t }\n\t\t\t\t\t// new type:\n\t\t\t\t\t| { type?: undefined; x: number; y: number }\n\n\t\t\t\ttype OldArrow = DrBaseShape<'arrow', { start: OldArrowTerminal; end: OldArrowTerminal }>\n\n\t\t\t\t// Collect all updates during iteration, then apply them after.\n\t\t\t\t// This avoids issues with live iterators (e.g., SQLite) where updating\n\t\t\t\t// records during iteration can cause them to be visited multiple times.\n\t\t\t\tconst updates: [string, unknown][] = []\n\n\t\t\t\tfor (const record of storage.values()) {\n\t\t\t\t\tif (record.typeName !== 'shape' || (record as DrShape).type !== 'arrow') continue\n\t\t\t\t\tconst arrow = record as OldArrow\n\t\t\t\t\tconst newArrow = structuredClone(arrow)\n\t\t\t\t\tconst { start, end } = arrow.props\n\t\t\t\t\tif (start.type === 'binding') {\n\t\t\t\t\t\tconst id = createBindingId()\n\t\t\t\t\t\tconst binding = {\n\t\t\t\t\t\t\ttypeName: 'binding',\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\t\t\tfromId: arrow.id,\n\t\t\t\t\t\t\ttoId: start.boundShapeId,\n\t\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\tterminal: 'start',\n\t\t\t\t\t\t\t\tnormalizedAnchor: start.normalizedAnchor,\n\t\t\t\t\t\t\t\tisExact: start.isExact,\n\t\t\t\t\t\t\t\tisPrecise: start.isPrecise,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tupdates.push([id, binding])\n\t\t\t\t\t\tnewArrow.props.start = { x: 0, y: 0 }\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdelete newArrow.props.start.type\n\t\t\t\t\t}\n\t\t\t\t\tif (end.type === 'binding') {\n\t\t\t\t\t\tconst id = createBindingId()\n\t\t\t\t\t\tconst binding = {\n\t\t\t\t\t\t\ttypeName: 'binding',\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\t\t\tfromId: arrow.id,\n\t\t\t\t\t\t\ttoId: end.boundShapeId,\n\t\t\t\t\t\t\tmeta: {},\n\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\tterminal: 'end',\n\t\t\t\t\t\t\t\tnormalizedAnchor: end.normalizedAnchor,\n\t\t\t\t\t\t\t\tisExact: end.isExact,\n\t\t\t\t\t\t\t\tisPrecise: end.isPrecise,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tupdates.push([id, binding])\n\t\t\t\t\t\tnewArrow.props.end = { x: 0, y: 0 }\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdelete newArrow.props.end.type\n\t\t\t\t\t}\n\t\t\t\t\tupdates.push([arrow.id, newArrow])\n\t\t\t\t}\n\n\t\t\t\tfor (const [id, record] of updates) {\n\t\t\t\t\tstorage.set(id, record as any)\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\tpropsMigration({\n\t\t\tid: arrowShapeVersions.AddScale,\n\t\t\tup: (props) => {\n\t\t\t\tprops.scale = 1\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.scale\n\t\t\t},\n\t\t}),\n\t\tpropsMigration({\n\t\t\tid: arrowShapeVersions.AddElbow,\n\t\t\tup: (props) => {\n\t\t\t\tprops.kind = 'arc'\n\t\t\t\tprops.elbowMidPoint = 0.5\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.kind\n\t\t\t\tdelete props.elbowMidPoint\n\t\t\t},\n\t\t}),\n\t\tpropsMigration({\n\t\t\tid: arrowShapeVersions.AddRichText,\n\t\t\tup: (props) => {\n\t\t\t\tprops.richText = toRichText(props.text)\n\t\t\t\tdelete props.text\n\t\t\t},\n\t\t\t// N.B. Explicitly no down state so that we force clients to update.\n\t\t\t// down: (props) => {\n\t\t\t// \tdelete props.richText\n\t\t\t// },\n\t\t}),\n\t\tpropsMigration({\n\t\t\tid: arrowShapeVersions.AddRichTextAttrs,\n\t\t\tup: (_props) => {\n\t\t\t\t// noop - attrs is optional so old records are valid\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\t// Remove attrs from richText when migrating down\n\t\t\t\tif (props.richText && 'attrs' in props.richText) {\n\t\t\t\t\tdelete props.richText.attrs\n\t\t\t\t}\n\t\t\t},\n\t\t}),\n\t],\n})\n","import { T } from '@ibodr/validate'\nimport { VecModel, vecModelValidator } from '../misc/geometry-types'\nimport {\n\tcreateBindingPropsMigrationIds,\n\tcreateBindingPropsMigrationSequence,\n} from '../records/DrBinding'\nimport { RecordProps } from '../recordsWithProps'\nimport { arrowShapeVersions } from '../shapes/DrArrowShape'\nimport { DrBaseBinding } from './DrBaseBinding'\n\n/**\n * Defines the snapping behavior for elbow-style arrows when binding to shapes.\n * Controls how the arrow segment aligns with the target shape's geometry.\n *\n * @example\n * ```ts\n * const binding: DrArrowBindingProps = {\n * terminal: 'end',\n * normalizedAnchor: { x: 0.5, y: 0.5 },\n * isExact: false,\n * isPrecise: true,\n * snap: 'edge' // Snap to shape edge\n * }\n * ```\n *\n * @public\n */\nexport const ElbowArrowSnap = T.literalEnum('center', 'edge-point', 'edge', 'none')\n/**\n * Type representing the possible elbow arrow snap modes.\n *\n * - `'center'` - Snap to the center of the target shape\n * - `'edge-point'` - Snap to a specific point on the shape's edge\n * - `'edge'` - Snap to the nearest edge of the shape\n * - `'none'` - No snapping behavior\n *\n * @public\n */\nexport type ElbowArrowSnap = T.TypeOf<typeof ElbowArrowSnap>\n\n/**\n * Properties that define how an arrow binds to a target shape.\n * These properties control the visual and behavioral aspects of the arrow-to-shape connection.\n *\n * @example\n * ```ts\n * const arrowBindingProps: DrArrowBindingProps = {\n * terminal: 'end', // Bind the arrow's end point\n * normalizedAnchor: { x: 0.5, y: 0.0 }, // Bind to top center of shape\n * isExact: true, // Arrow head enters the shape\n * isPrecise: true, // Use exact anchor position\n * snap: 'edge' // Snap to shape edge\n * }\n * ```\n *\n * @public\n */\nexport interface DrArrowBindingProps {\n\t/** Which end of the arrow is bound - either 'start' or 'end' */\n\tterminal: 'start' | 'end'\n\t/**\n\t * Normalized anchor point on the target shape (0,0 = top-left, 1,1 = bottom-right).\n\t * Coordinates are relative to the shape's bounding box.\n\t */\n\tnormalizedAnchor: VecModel\n\t/**\n\t * Whether the arrow head 'enters' the bound shape to point directly at the binding\n\t * anchor point. When true, the arrow head will be positioned inside the target shape.\n\t */\n\tisExact: boolean\n\t/**\n\t * Whether to bind to the exact normalizedAnchor position, or to the center of the shape.\n\t * When false, the arrow will connect to the shape's center regardless of anchor position.\n\t */\n\tisPrecise: boolean\n\t/** Snapping behavior for elbow-style arrows */\n\tsnap: ElbowArrowSnap\n}\n\n/**\n * Validation schema for arrow binding properties.\n * Defines the runtime validation rules for each property in DrArrowBindingProps.\n *\n * @example\n * ```ts\n * import { arrowBindingProps } from '@ibodr/schema'\n *\n * // Use in custom shape schema\n * const customSchema = createDrSchema({\n * bindings: {\n * arrow: {\n * props: arrowBindingProps,\n * migrations: arrowBindingMigrations\n * }\n * }\n * })\n * ```\n *\n * @public\n */\nexport const arrowBindingProps: RecordProps<DrArrowBinding> = {\n\tterminal: T.literalEnum('start', 'end'),\n\tnormalizedAnchor: vecModelValidator,\n\tisExact: T.boolean,\n\tisPrecise: T.boolean,\n\tsnap: ElbowArrowSnap,\n}\n\n/**\n * Represents a binding relationship between an arrow shape and another shape.\n * Arrow bindings allow arrows to connect to and follow other shapes, maintaining\n * the connection even when shapes are moved or transformed.\n *\n * @example\n * ```ts\n * const arrowBinding: DrArrowBinding = {\n * id: 'binding:abc123',\n * typeName: 'binding',\n * type: 'arrow',\n * fromId: 'shape:arrow1', // The arrow shape\n * toId: 'shape:rectangle1', // The target shape\n * props: {\n * terminal: 'end',\n * normalizedAnchor: { x: 0.5, y: 0.5 },\n * isExact: false,\n * isPrecise: true,\n * snap: 'edge'\n * },\n * meta: {}\n * }\n * ```\n *\n * @public\n */\nexport type DrArrowBinding = DrBaseBinding<'arrow', DrArrowBindingProps>\n\n/**\n * Version identifiers for arrow binding property migrations.\n * Each version represents a schema change that requires data migration.\n *\n * @example\n * ```ts\n * // Check if migration is needed\n * if (bindingVersion < arrowBindingVersions.AddSnap) {\n * // Apply AddSnap migration\n * }\n * ```\n *\n * @public\n */\nexport const arrowBindingVersions = createBindingPropsMigrationIds('arrow', {\n\tAddSnap: 1,\n})\n\n/**\n * Migration sequence for arrow binding properties.\n * Handles schema evolution over time by defining how to migrate data between versions.\n *\n * The sequence includes:\n * - **AddSnap (v1)**: Adds the `snap` property with default value 'none'\n *\n * @example\n * ```ts\n * import { arrowBindingMigrations } from '@ibodr/schema'\n *\n * // Apply migrations when loading older data\n * const migratedBinding = arrowBindingMigrations.migrate(oldBinding)\n * ```\n *\n * @public\n */\nexport const arrowBindingMigrations = createBindingPropsMigrationSequence({\n\tsequence: [\n\t\t{ dependsOn: [arrowShapeVersions.ExtractBindings] },\n\t\t{\n\t\t\tid: arrowBindingVersions.AddSnap,\n\t\t\tup: (props) => {\n\t\t\t\tprops.snap = 'none'\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.snap\n\t\t\t},\n\t\t},\n\t],\n})\n","import {\n\tBaseRecord,\n\tcreateMigrationIds,\n\tcreateRecordMigrationSequence,\n\tcreateRecordType,\n\tRecordId,\n} from '@ibodr/store'\nimport { JsonObject } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { idValidator } from '../misc/id-validator'\n\n/**\n * A camera record representing the viewport's position and zoom level.\n * The camera defines what portion of the infinite canvas is visible to the user.\n *\n * @example\n * ```ts\n * const camera: DrCamera = {\n * id: 'camera:user1',\n * typeName: 'camera',\n * x: 100, // Camera x position (negative values pan right)\n * y: 50, // Camera y position (negative values pan down)\n * z: 0.5, // Zoom level (1 = 100%, 0.5 = 50%, 2 = 200%)\n * meta: {\n * userId: 'user123',\n * lastUpdated: Date.now()\n * }\n * }\n *\n * // Set camera position and zoom\n * editor.setCamera({ x: -200, y: -100, z: 1.5 })\n * ```\n *\n * @public\n */\nexport interface DrCamera extends BaseRecord<'camera', DrCameraId> {\n\t/** Camera x position. Negative values move the viewport right */\n\tx: number\n\t/** Camera y position. Negative values move the viewport down */\n\ty: number\n\t/** Zoom level. 1 = 100%, 0.5 = 50% zoom, 2 = 200% zoom */\n\tz: number\n\t/** User-defined metadata for the camera */\n\tmeta: JsonObject\n}\n\n/**\n * Branded string type for camera record identifiers.\n * Prevents mixing camera IDs with other types of record IDs at compile time.\n *\n * @example\n * ```ts\n * import { CameraRecordType } from '@ibodr/schema'\n *\n * // Create a camera ID (typically one per user/session)\n * const cameraId: DrCameraId = CameraRecordType.createId()\n *\n * // Use in camera records\n * const camera: DrCamera = {\n * id: cameraId,\n * typeName: 'camera',\n * x: 0, y: 0, z: 1,\n * meta: {}\n * }\n *\n * // Get camera from store\n * const currentCamera = store.get(cameraId)\n * ```\n *\n * @public\n */\nexport type DrCameraId = RecordId<DrCamera>\n\n/**\n * Validator for DrCamera records that ensures runtime type safety.\n * Validates camera position coordinates and zoom level.\n *\n * @example\n * ```ts\n * // Validation happens automatically when cameras are stored\n * try {\n * const validatedCamera = cameraValidator.validate(cameraData)\n * store.put([validatedCamera])\n * } catch (error) {\n * console.error('Camera validation failed:', error.message)\n * }\n * ```\n *\n * @public\n */\nexport const cameraValidator: T.Validator<DrCamera> = T.model(\n\t'camera',\n\tT.object({\n\t\ttypeName: T.literal('camera'),\n\t\tid: idValidator<DrCameraId>('camera'),\n\t\tx: T.number,\n\t\ty: T.number,\n\t\tz: T.number,\n\t\tmeta: T.jsonValue as T.ObjectValidator<JsonObject>,\n\t})\n)\n\n/**\n * Migration version identifiers for camera record schema evolution.\n * Each version represents a breaking change that requires data migration.\n *\n * @example\n * ```ts\n * // Check if a camera needs migration\n * const needsMigration = currentVersion < cameraVersions.AddMeta\n * ```\n *\n * @public\n */\nexport const cameraVersions = createMigrationIds('com.draw.camera', {\n\tAddMeta: 1,\n})\n\n/**\n * Migration sequence for evolving camera record structure over time.\n * Handles converting camera records from older schema versions to current format.\n *\n * @example\n * ```ts\n * // Migration is applied automatically when loading old documents\n * const migratedStore = migrator.migrateStoreSnapshot({\n * schema: oldSchema,\n * store: oldStoreSnapshot\n * })\n * ```\n *\n * @public\n */\nexport const cameraMigrations = createRecordMigrationSequence({\n\tsequenceId: 'com.draw.camera',\n\trecordType: 'camera',\n\tsequence: [\n\t\t{\n\t\t\tid: cameraVersions.AddMeta,\n\t\t\tup: (record) => {\n\t\t\t\t;(record as any).meta = {}\n\t\t\t},\n\t\t},\n\t],\n})\n\n/**\n * Record type definition for DrCamera with validation and default properties.\n * Configures cameras as session-scoped records that don't persist across sessions.\n *\n * @example\n * ```ts\n * // Create a new camera record with defaults\n * const cameraRecord = CameraRecordType.create({\n * id: 'camera:main'\n * // x: 0, y: 0, z: 1, meta: {} are applied as defaults\n * })\n *\n * // Create with custom position and zoom\n * const customCamera = CameraRecordType.create({\n * id: 'camera:user1',\n * x: -100,\n * y: -50,\n * z: 1.5,\n * meta: { userId: 'user123' }\n * })\n *\n * // Store the camera\n * store.put([cameraRecord])\n * ```\n *\n * @public\n */\nexport const CameraRecordType = createRecordType<DrCamera>('camera', {\n\tvalidator: cameraValidator,\n\tscope: 'session',\n}).withDefaultProperties(\n\t(): Omit<DrCamera, 'id' | 'typeName'> => ({\n\t\tx: 0,\n\t\ty: 0,\n\t\tz: 1,\n\t\tmeta: {},\n\t})\n)\n","import { T } from '@ibodr/validate'\nimport { SetValue } from '../util-types'\n\n/**\n * All available cursor types used throughout the tldraw editor.\n *\n * These cursor types correspond to CSS cursor values and are used to indicate\n * different interaction modes and states within the editor. The cursor types\n * cover selection, resizing, rotation, text editing, and various other editor\n * interactions.\n *\n * @example\n * ```ts\n * // Check if a cursor type is valid\n * if (TL_CURSOR_TYPES.has('resize-corner')) {\n * console.log('Valid cursor type')\n * }\n *\n * // Get all available cursor types\n * const allCursors = Array.from(TL_CURSOR_TYPES)\n * ```\n *\n * @public\n */\nexport const TL_CURSOR_TYPES = new Set([\n\t'none',\n\t'default',\n\t'pointer',\n\t'cross',\n\t'grab',\n\t'rotate',\n\t'grabbing',\n\t'resize-edge',\n\t'resize-corner',\n\t'text',\n\t'move',\n\t'ew-resize',\n\t'ns-resize',\n\t'nesw-resize',\n\t'nwse-resize',\n\t'nesw-rotate',\n\t'nwse-rotate',\n\t'swne-rotate',\n\t'senw-rotate',\n\t'zoom-in',\n\t'zoom-out',\n])\n\n/**\n * A union type representing all available cursor types in the tldraw editor.\n *\n * Each cursor type corresponds to a different interaction mode or state,\n * helping users understand what action they can perform at any given moment.\n *\n * @example\n * ```ts\n * const defaultCursor: DrCursorType = 'default'\n * const textCursor: DrCursorType = 'text'\n * const resizeCursor: DrCursorType = 'resize-corner'\n * const rotateCursor: DrCursorType = 'nesw-rotate'\n * ```\n *\n * @public\n */\nexport type DrCursorType = SetValue<typeof TL_CURSOR_TYPES>\n\n/**\n * A validator for cursor types.\n *\n * This validator ensures that cursor type values are one of the valid types\n * defined in {@link TL_CURSOR_TYPES}. It provides runtime type checking for\n * cursor properties throughout the editor.\n *\n * @example\n * ```ts\n * import { cursorTypeValidator } from '@ibodr/schema'\n *\n * // Validate a cursor type\n * try {\n * const validCursor = cursorTypeValidator.validate('pointer')\n * console.log('Valid cursor:', validCursor)\n * } catch (error) {\n * console.error('Invalid cursor:', error.message)\n * }\n * ```\n *\n * @public\n */\nexport const cursorTypeValidator = T.setEnum(TL_CURSOR_TYPES)\n\n/**\n * A cursor object used throughout the tldraw editor.\n *\n * Represents both the cursor type (which determines the visual appearance)\n * and its rotation angle. The rotation is particularly useful for resize\n * and rotation cursors that need to align with the current interaction angle.\n *\n * @example\n * ```ts\n * // Default cursor\n * const defaultCursor: DrCursor = {\n * type: 'default',\n * rotation: 0\n * }\n *\n * // Rotated resize cursor\n * const rotatedResizeCursor: DrCursor = {\n * type: 'resize-corner',\n * rotation: Math.PI / 4 // 45 degrees\n * }\n *\n * // Text editing cursor\n * const textCursor: DrCursor = {\n * type: 'text',\n * rotation: 0\n * }\n * ```\n *\n * @public\n */\nexport interface DrCursor {\n\t/** The cursor type, determining the visual appearance and interaction mode */\n\ttype: DrCursorType\n\t/** The rotation angle in radians, used for rotated cursors like resize handles */\n\trotation: number\n}\n\n/**\n * A validator for DrCursor objects.\n *\n * This validator ensures that cursor objects have valid cursor types and\n * numeric rotation values. It provides runtime validation for cursor\n * properties used throughout the editor.\n *\n * @example\n * ```ts\n * import { cursorValidator } from '@ibodr/schema'\n *\n * // Validate a cursor object\n * try {\n * const validCursor = cursorValidator.validate({\n * type: 'pointer',\n * rotation: 0.5\n * })\n * console.log('Valid cursor:', validCursor)\n * } catch (error) {\n * console.error('Invalid cursor:', error.message)\n * }\n * ```\n *\n * @public\n */\nexport const cursorValidator: T.ObjectValidator<DrCursor> = T.object<DrCursor>({\n\ttype: cursorTypeValidator,\n\trotation: T.number,\n})\n","import { T } from '@ibodr/validate'\nimport { SetValue } from '../util-types'\n\n/**\n * The colors used by tldraw's canvas UI system.\n *\n * These are special color types used for canvas UI elements like selections,\n * accents, and other interface components that overlay the drawing canvas.\n * Unlike shape colors, these are semantic color types that adapt to the\n * current theme.\n *\n * @example\n * ```ts\n * // Check if a color is a canvas UI color\n * if (TL_CANVAS_UI_COLOR_TYPES.has('selection-stroke')) {\n * console.log('This is a valid canvas UI color')\n * }\n * ```\n *\n * @public\n */\nexport const TL_CANVAS_UI_COLOR_TYPES = new Set([\n\t'accent',\n\t'white',\n\t'black',\n\t'selection-stroke',\n\t'selection-fill',\n\t'laser',\n\t'muted-1',\n] as const)\n\n/**\n * A union type representing the available canvas UI color types.\n *\n * Canvas UI colors are semantic color types used for interface elements\n * that overlay the drawing canvas, such as selection indicators, accents,\n * and other UI components.\n *\n * @example\n * ```ts\n * const selectionColor: DrCanvasUiColor = 'selection-stroke'\n * const accentColor: DrCanvasUiColor = 'accent'\n * const backgroundColor: DrCanvasUiColor = 'white'\n * ```\n *\n * @public\n */\nexport type DrCanvasUiColor = SetValue<typeof TL_CANVAS_UI_COLOR_TYPES>\n\n/**\n * A validator for canvas UI color types.\n *\n * This validator ensures that color values are one of the valid canvas UI\n * color types defined in {@link TL_CANVAS_UI_COLOR_TYPES}. It provides\n * runtime type checking for canvas UI color properties.\n *\n * @example\n * ```ts\n * import { canvasUiColorTypeValidator } from '@ibodr/schema'\n *\n * // Validate a color value\n * try {\n * const validColor = canvasUiColorTypeValidator.validate('accent')\n * console.log('Valid color:', validColor)\n * } catch (error) {\n * console.error('Invalid color:', error.message)\n * }\n * ```\n *\n * @public\n */\nexport const canvasUiColorTypeValidator = T.setEnum(TL_CANVAS_UI_COLOR_TYPES)\n","import { T } from '@ibodr/validate'\nimport { SetValue } from '../util-types'\nimport { VecModel, vecModelValidator } from './geometry-types'\nimport { DrCanvasUiColor, canvasUiColorTypeValidator } from './DrColor'\n\n/**\n * All available scribble states used by the tldraw drawing system.\n *\n * Scribble states represent the different phases of a drawing stroke:\n *\n * - `starting`: The scribble is being initiated\n * - `paused`: The scribble is temporarily paused\n * - `active`: The scribble is actively being drawn\n * - `complete`: The scribble is done being drawn but not yet fading\n * - `stopping`: The scribble is being finished\n *\n * These states help manage the drawing lifecycle and apply appropriate\n * visual effects during different phases of the stroke.\n *\n * @example\n * ```ts\n * // Check if a scribble state is valid\n * if (TL_SCRIBBLE_STATES.has('active')) {\n * console.log('Valid scribble state')\n * }\n *\n * // Get all available scribble states\n * const allStates = Array.from(TL_SCRIBBLE_STATES)\n * ```\n *\n * @public\n */\nexport const TL_SCRIBBLE_STATES = new Set([\n\t'starting',\n\t'paused',\n\t'active',\n\t'complete',\n\t'stopping',\n] as const)\n\n/**\n * A scribble object representing a drawing stroke in tldraw.\n *\n * Scribbles are temporary drawing strokes that appear during freehand drawing\n * operations. They provide visual feedback as the user draws and can be styled\n * with various properties like size, color, and effects.\n *\n * @example\n * ```ts\n * // A basic scribble stroke\n * const scribble: DrScribble = {\n * id: 'scribble-123',\n * points: [\n * { x: 0, y: 0, z: 0.5 },\n * { x: 10, y: 5, z: 0.7 },\n * { x: 20, y: 10, z: 0.6 }\n * ],\n * size: 4,\n * color: 'black',\n * opacity: 0.8,\n * state: 'active',\n * delay: 0,\n * shrink: 0.1,\n * taper: true\n * }\n *\n * // A laser pointer scribble\n * const laserScribble: DrScribble = {\n * id: 'laser-pointer',\n * points: [{ x: 50, y: 50, z: 1.0 }],\n * size: 8,\n * color: 'laser',\n * opacity: 1.0,\n * state: 'active',\n * delay: 100,\n * shrink: 0,\n * taper: false\n * }\n * ```\n *\n * @public\n */\nexport interface DrScribble {\n\t/** Unique identifier for the scribble */\n\tid: string\n\t/** Array of points that make up the scribble path */\n\tpoints: VecModel[]\n\t/** The brush size/width of the scribble stroke */\n\tsize: number\n\t/** The color of the scribble using canvas UI color types */\n\tcolor: DrCanvasUiColor\n\t/** The opacity of the scribble (0-1) */\n\topacity: number\n\t/** The current state of the scribble drawing */\n\tstate: SetValue<typeof TL_SCRIBBLE_STATES>\n\t/** Time delay in milliseconds for animation effects */\n\tdelay: number\n\t/** Amount the stroke should shrink over time (0-1) */\n\tshrink: number\n\t/** Whether the stroke should taper at the ends */\n\ttaper: boolean\n}\n\n/**\n * A validator for DrScribble objects.\n *\n * This validator ensures that scribble objects have all required properties\n * with valid types and values. It validates the points array, size constraints,\n * color types, and state values according to the scribble system requirements.\n *\n * @example\n * ```ts\n * import { scribbleValidator } from '@ibodr/schema'\n *\n * // Validate a scribble object\n * try {\n * const validScribble = scribbleValidator.validate({\n * id: 'scribble-1',\n * points: [{ x: 0, y: 0, z: 1 }, { x: 10, y: 10, z: 1 }],\n * size: 3,\n * color: 'black',\n * opacity: 0.8,\n * state: 'active',\n * delay: 0,\n * shrink: 0.05,\n * taper: true\n * })\n * console.log('Valid scribble:', validScribble)\n * } catch (error) {\n * console.error('Invalid scribble:', error.message)\n * }\n * ```\n *\n * @public\n */\nexport const scribbleValidator: T.ObjectValidator<DrScribble> = T.object({\n\tid: T.string,\n\tpoints: T.arrayOf(vecModelValidator),\n\tsize: T.positiveNumber,\n\tcolor: canvasUiColorTypeValidator,\n\topacity: T.number,\n\tstate: T.setEnum(TL_SCRIBBLE_STATES),\n\tdelay: T.number,\n\tshrink: T.number,\n\ttaper: T.boolean,\n})\n","import {\n\tBaseRecord,\n\tcreateMigrationIds,\n\tcreateRecordMigrationSequence,\n\tcreateRecordType,\n\tRecordId,\n} from '@ibodr/store'\nimport { IndexKey, JsonObject } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { idValidator } from '../misc/id-validator'\n\n/**\n * A page within a tldraw document. Pages are containers for shapes and provide\n * a way to organize content into separate canvases. Each document can have multiple\n * pages, and users can navigate between them.\n *\n * Pages have a name for identification, an index for ordering, and can store\n * custom metadata.\n *\n * @example\n * ```ts\n * const page: DrPage = {\n * id: 'page:page1',\n * typeName: 'page',\n * name: 'Page 1',\n * index: 'a1',\n * meta: { description: 'Main design page' }\n * }\n * ```\n *\n * @public\n */\nexport interface DrPage extends BaseRecord<'page', DrPageId> {\n\tname: string\n\tindex: IndexKey\n\tmeta: JsonObject\n}\n\n/**\n * A unique identifier for DrPage records.\n *\n * Page IDs follow the format 'page:' followed by a unique string identifier.\n *\n * @example\n * ```ts\n * const pageId: DrPageId = 'page:main'\n * const pageId2: DrPageId = createShapeId() // generates 'page:abc123'\n * ```\n *\n * @public\n */\nexport type DrPageId = RecordId<DrPage>\n\n/**\n * Validator for DrPageId values. Ensures the ID follows the correct\n * format for page records ('page:' prefix).\n *\n * @example\n * ```ts\n * const isValid = pageIdValidator.isValid('page:main') // true\n * const isValid2 = pageIdValidator.isValid('shape:abc') // false\n * ```\n *\n * @public\n */\nexport const pageIdValidator = idValidator<DrPageId>('page')\n\n/**\n * Runtime validator for DrPage records. Validates the structure and types\n * of all page properties to ensure data integrity.\n *\n * @example\n * ```ts\n * const page = { id: 'page:1', typeName: 'page', name: 'My Page', index: 'a1', meta: {} }\n * const isValid = pageValidator.isValid(page) // true\n * ```\n *\n * @public\n */\nexport const pageValidator: T.Validator<DrPage> = T.model(\n\t'page',\n\tT.object({\n\t\ttypeName: T.literal('page'),\n\t\tid: pageIdValidator,\n\t\tname: T.string,\n\t\tindex: T.indexKey,\n\t\tmeta: T.jsonValue as T.ObjectValidator<JsonObject>,\n\t})\n)\n\n/**\n * Migration version identifiers for DrPage records. Each version represents\n * a schema change that requires data transformation when loading older documents.\n *\n * @public\n */\nexport const pageVersions = createMigrationIds('com.draw.page', {\n\tAddMeta: 1,\n})\n\n/**\n * Migration sequence for DrPage records. Defines how to transform page\n * records between different schema versions, ensuring data compatibility.\n *\n * @example\n * ```ts\n * // Migrations are applied automatically when loading documents\n * const migratedPage = pageMigrations.migrate(oldPage, targetVersion)\n * ```\n *\n * @public\n */\nexport const pageMigrations = createRecordMigrationSequence({\n\tsequenceId: 'com.draw.page',\n\trecordType: 'page',\n\tsequence: [\n\t\t{\n\t\t\tid: pageVersions.AddMeta,\n\t\t\tup: (record: any) => {\n\t\t\t\trecord.meta = {}\n\t\t\t},\n\t\t},\n\t],\n})\n\n/**\n * The RecordType definition for DrPage records. Defines validation, scope,\n * and default properties for page records in the tldraw store.\n *\n * Pages are scoped to the document level, meaning they persist across sessions\n * and are shared in collaborative environments.\n *\n * @example\n * ```ts\n * const page = PageRecordType.create({\n * id: 'page:main',\n * name: 'Main Page',\n * index: 'a1'\n * })\n * ```\n *\n * @public\n */\nexport const PageRecordType = createRecordType<DrPage>('page', {\n\tvalidator: pageValidator,\n\tscope: 'document',\n}).withDefaultProperties(() => ({\n\tmeta: {},\n}))\n\n/**\n * Type guard to check if a string is a valid DrPageId.\n *\n * @param id - The string to check\n * @returns True if the ID is a valid page ID, false otherwise\n *\n * @example\n * ```ts\n * if (isPageId('page:main')) {\n * // TypeScript knows this is a DrPageId\n * console.log('Valid page ID')\n * }\n * ```\n *\n * @public\n */\nexport function isPageId(id: string): id is DrPageId {\n\treturn PageRecordType.isId(id)\n}\n","import {\n\tBaseRecord,\n\tcreateMigrationIds,\n\tcreateRecordMigrationSequence,\n\tcreateRecordType,\n\tRecordId,\n} from '@ibodr/store'\nimport { filterEntries, JsonObject } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { BoxModel, boxModelValidator } from '../misc/geometry-types'\nimport { idValidator } from '../misc/id-validator'\nimport { cursorValidator, DrCursor } from '../misc/DrCursor'\nimport { opacityValidator, DrOpacityType } from '../misc/DrOpacity'\nimport { scribbleValidator, DrScribble } from '../misc/DrScribble'\nimport { StyleProp } from '../styles/StyleProp'\nimport { pageIdValidator, DrPageId } from './DrPage'\nimport { DrShapeId } from './DrShape'\n\n/**\n * State that is particular to a single browser tab. The DrInstance record stores\n * all session-specific state including cursor position, selected tools, UI preferences,\n * and temporary interaction state.\n *\n * Each browser tab has exactly one DrInstance record that persists for the duration\n * of the session and tracks the user's current interaction state.\n *\n * @example\n * ```ts\n * const instance: DrInstance = {\n * id: 'instance:instance',\n * typeName: 'instance',\n * currentPageId: 'page:page1',\n * cursor: { type: 'default', rotation: 0 },\n * screenBounds: { x: 0, y: 0, w: 1920, h: 1080 },\n * isFocusMode: false,\n * isGridMode: true\n * }\n * ```\n *\n * @public\n */\nexport interface DrInstance extends BaseRecord<'instance', DrInstanceId> {\n\tcurrentPageId: DrPageId\n\topacityForNextShape: DrOpacityType\n\tstylesForNextShape: Record<string, unknown>\n\tfollowingUserId: string | null\n\thighlightedUserIds: string[]\n\tbrush: BoxModel | null\n\tcursor: DrCursor\n\tscribbles: DrScribble[]\n\tisFocusMode: boolean\n\tisDebugMode: boolean\n\tisToolLocked: boolean\n\texportBackground: boolean\n\tscreenBounds: BoxModel\n\tinsets: boolean[]\n\tzoomBrush: BoxModel | null\n\tchatMessage: string\n\tisChatting: boolean\n\tisPenMode: boolean\n\tisGridMode: boolean\n\tisFocused: boolean\n\tdevicePixelRatio: number\n\t/**\n\t * This is whether the primary input mechanism includes a pointing device of limited accuracy,\n\t * such as a finger on a touchscreen.\n\t */\n\tisCoarsePointer: boolean\n\t/**\n\t * Will be null if the pointer doesn't support hovering (e.g. touch), but true or false\n\t * otherwise\n\t */\n\tisHoveringCanvas: boolean | null\n\topenMenus: string[]\n\tisChangingStyle: boolean\n\tisReadonly: boolean\n\tmeta: JsonObject\n\tduplicateProps: {\n\t\tshapeIds: DrShapeId[]\n\t\toffset: {\n\t\t\tx: number\n\t\t\ty: number\n\t\t}\n\t} | null\n\t/**\n\t * Whether the camera is currently moving or idle. Used to optimize rendering\n\t * and hit-testing during panning/zooming.\n\t */\n\tcameraState: 'idle' | 'moving'\n}\n\n/**\n * Configuration object defining which DrInstance properties should be preserved\n * when loading snapshots across browser sessions. Properties marked as `true`\n * represent user preferences that should persist, while `false` indicates\n * temporary state that should reset.\n *\n * @internal\n */\nexport const shouldKeyBePreservedBetweenSessions = {\n\t// This object defines keys that should be preserved across calls to loadSnapshot()\n\n\tid: false, // meta\n\ttypeName: false, // meta\n\n\tcurrentPageId: false, // does not preserve because who knows if the page still exists\n\topacityForNextShape: false, // does not preserve because it's a temporary state\n\tstylesForNextShape: false, // does not preserve because it's a temporary state\n\tfollowingUserId: false, // does not preserve because it's a temporary state\n\thighlightedUserIds: false, // does not preserve because it's a temporary state\n\tbrush: false, // does not preserve because it's a temporary state\n\tcursor: false, // does not preserve because it's a temporary state\n\tscribbles: false, // does not preserve because it's a temporary state\n\n\tisFocusMode: true, // preserves because it's a user preference\n\tisDebugMode: true, // preserves because it's a user preference\n\tisToolLocked: true, // preserves because it's a user preference\n\texportBackground: true, // preserves because it's a user preference\n\tscreenBounds: true, // preserves because it's capturing the user's screen state\n\tinsets: true, // preserves because it's capturing the user's screen state\n\n\tzoomBrush: false, // does not preserve because it's a temporary state\n\tchatMessage: false, // does not preserve because it's a temporary state\n\tisChatting: false, // does not preserve because it's a temporary state\n\tisPenMode: false, // does not preserve because it's a temporary state\n\n\tisGridMode: true, // preserves because it's a user preference\n\tisFocused: true, // preserves because obviously\n\tdevicePixelRatio: true, // preserves because it captures the user's screen state\n\tisCoarsePointer: true, // preserves because it captures the user's screen state\n\tisHoveringCanvas: false, // does not preserve because it's a temporary state\n\topenMenus: false, // does not preserve because it's a temporary state\n\tisChangingStyle: false, // does not preserve because it's a temporary state\n\tisReadonly: true, // preserves because it's a config option\n\tmeta: false, // does not preserve because who knows what's in there, leave it up to sdk users to save and reinstate\n\tduplicateProps: false, //\n\tcameraState: false, // does not preserve because it's a temporary state\n} as const satisfies { [K in keyof DrInstance]: boolean }\n\n/**\n * Extracts only the properties from a DrInstance that should be preserved\n * between browser sessions, filtering out temporary state.\n *\n * @param val - The DrInstance to filter, or null/undefined\n * @returns A partial DrInstance containing only preservable properties, or null\n *\n * @internal\n */\nexport function pluckPreservingValues(val?: DrInstance | null): null | Partial<DrInstance> {\n\treturn val\n\t\t? (filterEntries(val, (key) => {\n\t\t\t\treturn shouldKeyBePreservedBetweenSessions[key as keyof DrInstance]\n\t\t\t}) as Partial<DrInstance>)\n\t\t: null\n}\n\n/**\n * A unique identifier for DrInstance records.\n *\n * DrInstance IDs are always the constant 'instance:instance' since there\n * is exactly one instance record per browser tab.\n *\n * @public\n */\nexport type DrInstanceId = RecordId<DrInstance>\n\n/**\n * Validator for DrInstanceId values. Ensures the ID follows the correct\n * format for instance records.\n *\n * @example\n * ```ts\n * const isValid = instanceIdValidator.isValid('instance:instance') // true\n * const isValid2 = instanceIdValidator.isValid('invalid') // false\n * ```\n *\n * @public\n */\nexport const instanceIdValidator = idValidator<DrInstanceId>('instance')\n\n/**\n * Creates the record type definition for DrInstance records, including validation\n * and default properties. The function takes a map of available style properties\n * to configure validation for the stylesForNextShape field.\n *\n * @param stylesById - Map of style property IDs to their corresponding StyleProp definitions\n * @returns A configured RecordType for DrInstance records\n *\n * @example\n * ```ts\n * const stylesMap = new Map([['color', DefaultColorStyle]])\n * const InstanceRecordType = createInstanceRecordType(stylesMap)\n *\n * const instance = InstanceRecordType.create({\n * id: 'instance:instance',\n * currentPageId: 'page:page1'\n * })\n * ```\n *\n * @public\n */\nexport function createInstanceRecordType(stylesById: Map<string, StyleProp<unknown>>) {\n\tconst stylesForNextShapeValidators = {} as Record<string, T.Validator<unknown>>\n\tfor (const [id, style] of stylesById) {\n\t\tstylesForNextShapeValidators[id] = T.optional(style)\n\t}\n\n\tconst instanceTypeValidator: T.Validator<DrInstance> = T.model(\n\t\t'instance',\n\t\tT.object({\n\t\t\ttypeName: T.literal('instance'),\n\t\t\tid: idValidator<DrInstanceId>('instance'),\n\t\t\tcurrentPageId: pageIdValidator,\n\t\t\tfollowingUserId: T.string.nullable(),\n\t\t\tbrush: boxModelValidator.nullable(),\n\t\t\topacityForNextShape: opacityValidator,\n\t\t\tstylesForNextShape: T.object(stylesForNextShapeValidators),\n\t\t\tcursor: cursorValidator,\n\t\t\tscribbles: T.arrayOf(scribbleValidator),\n\t\t\tisFocusMode: T.boolean,\n\t\t\tisDebugMode: T.boolean,\n\t\t\tisToolLocked: T.boolean,\n\t\t\texportBackground: T.boolean,\n\t\t\tscreenBounds: boxModelValidator,\n\t\t\tinsets: T.arrayOf(T.boolean),\n\t\t\tzoomBrush: boxModelValidator.nullable(),\n\t\t\tisPenMode: T.boolean,\n\t\t\tisGridMode: T.boolean,\n\t\t\tchatMessage: T.string,\n\t\t\tisChatting: T.boolean,\n\t\t\thighlightedUserIds: T.arrayOf(T.string),\n\t\t\tisFocused: T.boolean,\n\t\t\tdevicePixelRatio: T.number,\n\t\t\tisCoarsePointer: T.boolean,\n\t\t\tisHoveringCanvas: T.boolean.nullable(),\n\t\t\topenMenus: T.arrayOf(T.string),\n\t\t\tisChangingStyle: T.boolean,\n\t\t\tisReadonly: T.boolean,\n\t\t\tmeta: T.jsonValue as T.ObjectValidator<JsonObject>,\n\t\t\tduplicateProps: T.object({\n\t\t\t\tshapeIds: T.arrayOf(idValidator<DrShapeId>('shape')),\n\t\t\t\toffset: T.object({\n\t\t\t\t\tx: T.number,\n\t\t\t\t\ty: T.number,\n\t\t\t\t}),\n\t\t\t}).nullable(),\n\t\t\tcameraState: T.literalEnum('idle', 'moving'),\n\t\t})\n\t)\n\n\treturn createRecordType<DrInstance>('instance', {\n\t\tvalidator: instanceTypeValidator,\n\t\tscope: 'session',\n\t\tephemeralKeys: {\n\t\t\tcurrentPageId: false,\n\t\t\tmeta: false,\n\n\t\t\tfollowingUserId: true,\n\t\t\topacityForNextShape: true,\n\t\t\tstylesForNextShape: true,\n\t\t\tbrush: true,\n\t\t\tcursor: true,\n\t\t\tscribbles: true,\n\t\t\tisFocusMode: true,\n\t\t\tisDebugMode: true,\n\t\t\tisToolLocked: true,\n\t\t\texportBackground: true,\n\t\t\tscreenBounds: true,\n\t\t\tinsets: true,\n\t\t\tzoomBrush: true,\n\t\t\tisPenMode: true,\n\t\t\tisGridMode: true,\n\t\t\tchatMessage: true,\n\t\t\tisChatting: true,\n\t\t\thighlightedUserIds: true,\n\t\t\tisFocused: true,\n\t\t\tdevicePixelRatio: true,\n\t\t\tisCoarsePointer: true,\n\t\t\tisHoveringCanvas: true,\n\t\t\topenMenus: true,\n\t\t\tisChangingStyle: true,\n\t\t\tisReadonly: true,\n\t\t\tduplicateProps: true,\n\t\t\tcameraState: true,\n\t\t},\n\t}).withDefaultProperties(\n\t\t(): Omit<DrInstance, 'typeName' | 'id' | 'currentPageId'> => ({\n\t\t\tfollowingUserId: null,\n\t\t\topacityForNextShape: 1,\n\t\t\tstylesForNextShape: {},\n\t\t\tbrush: null,\n\t\t\tscribbles: [],\n\t\t\tcursor: {\n\t\t\t\ttype: 'default',\n\t\t\t\trotation: 0,\n\t\t\t},\n\t\t\tisFocusMode: false,\n\t\t\texportBackground: false,\n\t\t\tisDebugMode: false,\n\t\t\tisToolLocked: false,\n\t\t\tscreenBounds: { x: 0, y: 0, w: 1080, h: 720 },\n\t\t\tinsets: [false, false, false, false],\n\t\t\tzoomBrush: null,\n\t\t\tisGridMode: false,\n\t\t\tisPenMode: false,\n\t\t\tchatMessage: '',\n\t\t\tisChatting: false,\n\t\t\thighlightedUserIds: [],\n\t\t\tisFocused: false,\n\t\t\tdevicePixelRatio: typeof window === 'undefined' ? 1 : window.devicePixelRatio,\n\t\t\tisCoarsePointer: false,\n\t\t\tisHoveringCanvas: null,\n\t\t\topenMenus: [] as string[],\n\t\t\tisChangingStyle: false,\n\t\t\tisReadonly: false,\n\t\t\tmeta: {},\n\t\t\tduplicateProps: null,\n\t\t\tcameraState: 'idle',\n\t\t})\n\t)\n}\n\n/**\n * Migration version identifiers for DrInstance records. Each version represents\n * a schema change that requires data transformation when loading older documents.\n *\n * The versions track the evolution of the instance record structure over time,\n * enabling backward and forward compatibility.\n *\n * @public\n */\nexport const instanceVersions = createMigrationIds('com.draw.instance', {\n\tAddTransparentExportBgs: 1,\n\tRemoveDialog: 2,\n\tAddToolLockMode: 3,\n\tRemoveExtraPropsForNextShape: 4,\n\tAddLabelColor: 5,\n\tAddFollowingUserId: 6,\n\tRemoveAlignJustify: 7,\n\tAddZoom: 8,\n\tAddVerticalAlign: 9,\n\tAddScribbleDelay: 10,\n\tRemoveUserId: 11,\n\tAddIsPenModeAndIsGridMode: 12,\n\tHoistOpacity: 13,\n\tAddChat: 14,\n\tAddHighlightedUserIds: 15,\n\tReplacePropsForNextShapeWithStylesForNextShape: 16,\n\tAddMeta: 17,\n\tRemoveCursorColor: 18,\n\tAddLonelyProperties: 19,\n\tReadOnlyReadonly: 20,\n\tAddHoveringCanvas: 21,\n\tAddScribbles: 22,\n\tAddInset: 23,\n\tAddDuplicateProps: 24,\n\tRemoveCanMoveCamera: 25,\n\tAddCameraState: 26,\n} as const)\n\n// TODO: rewrite these to use mutation\n\n/**\n * Migration sequence for DrInstance records. Defines how to transform instance\n * records between different schema versions, ensuring data compatibility when\n * loading documents created with different versions of tldraw.\n *\n * Each migration includes an 'up' function to migrate forward and optionally\n * a 'down' function for reverse migration.\n *\n * @example\n * ```ts\n * // Migrations are applied automatically when loading documents\n * const migratedInstance = instanceMigrations.migrate(oldInstance, targetVersion)\n * ```\n *\n * @public\n */\nexport const instanceMigrations = createRecordMigrationSequence({\n\tsequenceId: 'com.draw.instance',\n\trecordType: 'instance',\n\tsequence: [\n\t\t{\n\t\t\tid: instanceVersions.AddTransparentExportBgs,\n\t\t\tup: (instance) => {\n\t\t\t\treturn { ...instance, exportBackground: true }\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.RemoveDialog,\n\t\t\tup: ({ dialog: _, ...instance }: any) => {\n\t\t\t\treturn instance\n\t\t\t},\n\t\t},\n\n\t\t{\n\t\t\tid: instanceVersions.AddToolLockMode,\n\t\t\tup: (instance) => {\n\t\t\t\treturn { ...instance, isToolLocked: false }\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.RemoveExtraPropsForNextShape,\n\t\t\tup: ({ propsForNextShape, ...instance }: any) => {\n\t\t\t\treturn {\n\t\t\t\t\t...instance,\n\t\t\t\t\tpropsForNextShape: Object.fromEntries(\n\t\t\t\t\t\tObject.entries(propsForNextShape).filter(([key]) =>\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'color',\n\t\t\t\t\t\t\t\t'labelColor',\n\t\t\t\t\t\t\t\t'dash',\n\t\t\t\t\t\t\t\t'fill',\n\t\t\t\t\t\t\t\t'size',\n\t\t\t\t\t\t\t\t'font',\n\t\t\t\t\t\t\t\t'align',\n\t\t\t\t\t\t\t\t'verticalAlign',\n\t\t\t\t\t\t\t\t'icon',\n\t\t\t\t\t\t\t\t'geo',\n\t\t\t\t\t\t\t\t'arrowheadStart',\n\t\t\t\t\t\t\t\t'arrowheadEnd',\n\t\t\t\t\t\t\t\t'spline',\n\t\t\t\t\t\t\t].includes(key)\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.AddLabelColor,\n\t\t\tup: ({ propsForNextShape, ...instance }: any) => {\n\t\t\t\treturn {\n\t\t\t\t\t...instance,\n\t\t\t\t\tpropsForNextShape: {\n\t\t\t\t\t\t...propsForNextShape,\n\t\t\t\t\t\tlabelColor: 'black',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.AddFollowingUserId,\n\t\t\tup: (instance) => {\n\t\t\t\treturn { ...instance, followingUserId: null }\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.RemoveAlignJustify,\n\t\t\tup: (instance: any) => {\n\t\t\t\tlet newAlign = instance.propsForNextShape.align\n\t\t\t\tif (newAlign === 'justify') {\n\t\t\t\t\tnewAlign = 'start'\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...instance,\n\t\t\t\t\tpropsForNextShape: {\n\t\t\t\t\t\t...instance.propsForNextShape,\n\t\t\t\t\t\talign: newAlign,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.AddZoom,\n\t\t\tup: (instance) => {\n\t\t\t\treturn { ...instance, zoomBrush: null }\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.AddVerticalAlign,\n\t\t\tup: (instance: any) => {\n\t\t\t\treturn {\n\t\t\t\t\t...instance,\n\t\t\t\t\tpropsForNextShape: {\n\t\t\t\t\t\t...instance.propsForNextShape,\n\t\t\t\t\t\tverticalAlign: 'middle',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.AddScribbleDelay,\n\t\t\tup: (instance: any) => {\n\t\t\t\tif (instance.scribble !== null) {\n\t\t\t\t\treturn { ...instance, scribble: { ...instance.scribble, delay: 0 } }\n\t\t\t\t}\n\t\t\t\treturn { ...instance }\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.RemoveUserId,\n\t\t\tup: ({ userId: _, ...instance }: any) => {\n\t\t\t\treturn instance\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.AddIsPenModeAndIsGridMode,\n\t\t\tup: (instance) => {\n\t\t\t\treturn { ...instance, isPenMode: false, isGridMode: false }\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.HoistOpacity,\n\t\t\tup: ({ propsForNextShape: { opacity, ...propsForNextShape }, ...instance }: any) => {\n\t\t\t\treturn { ...instance, opacityForNextShape: Number(opacity ?? '1'), propsForNextShape }\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.AddChat,\n\t\t\tup: (instance) => {\n\t\t\t\treturn { ...instance, chatMessage: '', isChatting: false }\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.AddHighlightedUserIds,\n\t\t\tup: (instance) => {\n\t\t\t\treturn { ...instance, highlightedUserIds: [] }\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.ReplacePropsForNextShapeWithStylesForNextShape,\n\t\t\tup: ({ propsForNextShape: _, ...instance }: any) => {\n\t\t\t\treturn { ...instance, stylesForNextShape: {} }\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.AddMeta,\n\t\t\tup: (record) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t\tmeta: {},\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.RemoveCursorColor,\n\t\t\tup: (record: any) => {\n\t\t\t\tconst { color: _, ...cursor } = record.cursor\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t\tcursor,\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.AddLonelyProperties,\n\t\t\tup: (record) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t\tcanMoveCamera: true,\n\t\t\t\t\tisFocused: false,\n\t\t\t\t\tdevicePixelRatio: 1,\n\t\t\t\t\tisCoarsePointer: false,\n\t\t\t\t\topenMenus: [],\n\t\t\t\t\tisChangingStyle: false,\n\t\t\t\t\tisReadOnly: false,\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.ReadOnlyReadonly,\n\t\t\tup: ({ isReadOnly: _isReadOnly, ...record }: any) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t\tisReadonly: _isReadOnly,\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.AddHoveringCanvas,\n\t\t\tup: (record) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t\tisHoveringCanvas: null,\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.AddScribbles,\n\t\t\tup: ({ scribble: _, ...record }: any) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t\tscribbles: [],\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.AddInset,\n\t\t\tup: (record) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t\tinsets: [false, false, false, false],\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: ({ insets: _, ...record }: any) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.AddDuplicateProps,\n\t\t\tup: (record) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t\tduplicateProps: null,\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: ({ duplicateProps: _, ...record }: any) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.RemoveCanMoveCamera,\n\t\t\tup: ({ canMoveCamera: _, ...record }: any) => {\n\t\t\t\treturn {\n\t\t\t\t\t...record,\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (instance) => {\n\t\t\t\treturn { ...instance, canMoveCamera: true }\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instanceVersions.AddCameraState,\n\t\t\tup: (record) => {\n\t\t\t\treturn { ...record, cameraState: 'idle' }\n\t\t\t},\n\t\t\tdown: ({ cameraState: _, ...record }: any) => {\n\t\t\t\treturn record\n\t\t\t},\n\t\t},\n\t],\n})\n\n/**\n * The constant ID used for the singleton DrInstance record.\n *\n * Since each browser tab has exactly one instance, this constant ID\n * is used universally across the application.\n *\n * @example\n * ```ts\n * const instance = store.get(DrINSTANCE_ID)\n * if (instance) {\n * console.log('Current page:', instance.currentPageId)\n * }\n * ```\n *\n * @public\n */\nexport const DrINSTANCE_ID = 'instance:instance' as DrInstanceId\n","import {\n\tBaseRecord,\n\tcreateMigrationIds,\n\tcreateRecordMigrationSequence,\n\tcreateRecordType,\n\tRecordId,\n} from '@ibodr/store'\nimport { JsonObject } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { idValidator } from '../misc/id-validator'\nimport { shapeIdValidator } from '../shapes/DrBaseShape'\nimport { pageIdValidator, DrPage } from './DrPage'\nimport { DrShapeId } from './DrShape'\n\n/**\n * State that is unique to a particular page within a particular browser tab.\n * This record tracks all page-specific interaction state including selected shapes,\n * editing state, hover state, and other transient UI state that is tied to\n * both a specific page and a specific browser session.\n *\n * Each combination of page and browser tab has its own DrInstancePageState record.\n *\n * @example\n * ```ts\n * const pageState: DrInstancePageState = {\n * id: 'instance_page_state:page1',\n * typeName: 'instance_page_state',\n * pageId: 'page:page1',\n * selectedShapeIds: ['shape:rect1', 'shape:circle2'],\n * hoveredShapeId: 'shape:text3',\n * editingShapeId: null,\n * focusedGroupId: null\n * }\n * ```\n *\n * @public\n */\nexport interface DrInstancePageState extends BaseRecord<\n\t'instance_page_state',\n\tDrInstancePageStateId\n> {\n\tpageId: RecordId<DrPage>\n\tselectedShapeIds: DrShapeId[]\n\thintingShapeIds: DrShapeId[]\n\terasingShapeIds: DrShapeId[]\n\thoveredShapeId: DrShapeId | null\n\teditingShapeId: DrShapeId | null\n\tcroppingShapeId: DrShapeId | null\n\tfocusedGroupId: DrShapeId | null\n\tmeta: JsonObject\n}\n\n/**\n * Runtime validator for DrInstancePageState records. Validates the structure\n * and types of all instance page state properties to ensure data integrity.\n *\n * @example\n * ```ts\n * const pageState = {\n * id: 'instance_page_state:page1',\n * typeName: 'instance_page_state',\n * pageId: 'page:page1',\n * selectedShapeIds: ['shape:rect1'],\n * // ... other properties\n * }\n * const isValid = instancePageStateValidator.isValid(pageState) // true\n * ```\n *\n * @public\n */\nexport const instancePageStateValidator: T.Validator<DrInstancePageState> = T.model(\n\t'instance_page_state',\n\tT.object({\n\t\ttypeName: T.literal('instance_page_state'),\n\t\tid: idValidator<DrInstancePageStateId>('instance_page_state'),\n\t\tpageId: pageIdValidator,\n\t\tselectedShapeIds: T.arrayOf(shapeIdValidator),\n\t\thintingShapeIds: T.arrayOf(shapeIdValidator),\n\t\terasingShapeIds: T.arrayOf(shapeIdValidator),\n\t\thoveredShapeId: shapeIdValidator.nullable(),\n\t\teditingShapeId: shapeIdValidator.nullable(),\n\t\tcroppingShapeId: shapeIdValidator.nullable(),\n\t\tfocusedGroupId: shapeIdValidator.nullable(),\n\t\tmeta: T.jsonValue as T.ObjectValidator<JsonObject>,\n\t})\n)\n\n/**\n * Migration version identifiers for DrInstancePageState records. Each version\n * represents a schema change that requires data transformation when loading\n * older documents.\n *\n * @public\n */\nexport const instancePageStateVersions = createMigrationIds('com.draw.instance_page_state', {\n\tAddCroppingId: 1,\n\tRemoveInstanceIdAndCameraId: 2,\n\tAddMeta: 3,\n\tRenameProperties: 4,\n\tRenamePropertiesAgain: 5,\n} as const)\n\n/**\n * Migration sequence for DrInstancePageState records. Defines how to transform\n * instance page state records between different schema versions, ensuring data\n * compatibility when loading documents created with different versions.\n *\n * @example\n * ```ts\n * // Migrations are applied automatically when loading documents\n * const migrated = instancePageStateMigrations.migrate(oldState, targetVersion)\n * ```\n *\n * @public\n */\nexport const instancePageStateMigrations = createRecordMigrationSequence({\n\tsequenceId: 'com.draw.instance_page_state',\n\trecordType: 'instance_page_state',\n\tsequence: [\n\t\t{\n\t\t\tid: instancePageStateVersions.AddCroppingId,\n\t\t\tup(instance: any) {\n\t\t\t\tinstance.croppingShapeId = null\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instancePageStateVersions.RemoveInstanceIdAndCameraId,\n\t\t\tup(instance: any) {\n\t\t\t\tdelete instance.instanceId\n\t\t\t\tdelete instance.cameraId\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instancePageStateVersions.AddMeta,\n\t\t\tup: (record: any) => {\n\t\t\t\trecord.meta = {}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instancePageStateVersions.RenameProperties,\n\t\t\t// this migration is cursed: it was written wrong and doesn't do anything.\n\t\t\t// rather than replace it, I've added another migration below that fixes it.\n\t\t\tup: (_record) => {\n\t\t\t\t// noop\n\t\t\t},\n\t\t\tdown: (_record) => {\n\t\t\t\t// noop\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instancePageStateVersions.RenamePropertiesAgain,\n\t\t\tup: (record: any) => {\n\t\t\t\trecord.selectedShapeIds = record.selectedIds\n\t\t\t\tdelete record.selectedIds\n\t\t\t\trecord.hintingShapeIds = record.hintingIds\n\t\t\t\tdelete record.hintingIds\n\t\t\t\trecord.erasingShapeIds = record.erasingIds\n\t\t\t\tdelete record.erasingIds\n\t\t\t\trecord.hoveredShapeId = record.hoveredId\n\t\t\t\tdelete record.hoveredId\n\t\t\t\trecord.editingShapeId = record.editingId\n\t\t\t\tdelete record.editingId\n\t\t\t\trecord.croppingShapeId = record.croppingShapeId ?? record.croppingId ?? null\n\t\t\t\tdelete record.croppingId\n\t\t\t\trecord.focusedGroupId = record.focusLayerId\n\t\t\t\tdelete record.focusLayerId\n\t\t\t},\n\t\t\tdown: (record: any) => {\n\t\t\t\trecord.selectedIds = record.selectedShapeIds\n\t\t\t\tdelete record.selectedShapeIds\n\t\t\t\trecord.hintingIds = record.hintingShapeIds\n\t\t\t\tdelete record.hintingShapeIds\n\t\t\t\trecord.erasingIds = record.erasingShapeIds\n\t\t\t\tdelete record.erasingShapeIds\n\t\t\t\trecord.hoveredId = record.hoveredShapeId\n\t\t\t\tdelete record.hoveredShapeId\n\t\t\t\trecord.editingId = record.editingShapeId\n\t\t\t\tdelete record.editingShapeId\n\t\t\t\trecord.croppingId = record.croppingShapeId\n\t\t\t\tdelete record.croppingShapeId\n\t\t\t\trecord.focusLayerId = record.focusedGroupId\n\t\t\t\tdelete record.focusedGroupId\n\t\t\t},\n\t\t},\n\t],\n})\n\n/**\n * The RecordType definition for DrInstancePageState records. Defines validation,\n * scope, and default properties for instance page state records.\n *\n * Instance page states are scoped to the session level, meaning they are\n * specific to a browser tab and don't persist across sessions or sync\n * in collaborative environments.\n *\n * @example\n * ```ts\n * const pageState = InstancePageStateRecordType.create({\n * id: 'instance_page_state:page1',\n * pageId: 'page:page1',\n * selectedShapeIds: ['shape:rect1']\n * })\n * ```\n *\n * @public\n */\nexport const InstancePageStateRecordType = createRecordType<DrInstancePageState>(\n\t'instance_page_state',\n\t{\n\t\tvalidator: instancePageStateValidator,\n\t\tscope: 'session',\n\t\tephemeralKeys: {\n\t\t\tpageId: false,\n\t\t\tselectedShapeIds: false,\n\t\t\teditingShapeId: false,\n\t\t\tcroppingShapeId: false,\n\t\t\tmeta: false,\n\n\t\t\thintingShapeIds: true,\n\t\t\terasingShapeIds: true,\n\t\t\thoveredShapeId: true,\n\t\t\tfocusedGroupId: true,\n\t\t},\n\t}\n).withDefaultProperties(\n\t(): Omit<DrInstancePageState, 'id' | 'typeName' | 'pageId'> => ({\n\t\teditingShapeId: null,\n\t\tcroppingShapeId: null,\n\t\tselectedShapeIds: [],\n\t\thoveredShapeId: null,\n\t\terasingShapeIds: [],\n\t\thintingShapeIds: [],\n\t\tfocusedGroupId: null,\n\t\tmeta: {},\n\t})\n)\n\n/**\n * A unique identifier for DrInstancePageState records.\n *\n * Instance page state IDs follow the format 'instance_page_state:' followed\n * by a unique identifier, typically related to the page ID.\n *\n * @example\n * ```ts\n * const stateId: DrInstancePageStateId = 'instance_page_state:page1'\n * ```\n *\n * @public\n */\nexport type DrInstancePageStateId = RecordId<DrInstancePageState>\n","import {\n\tBaseRecord,\n\tcreateMigrationIds,\n\tcreateRecordMigrationSequence,\n\tcreateRecordType,\n\tRecordId,\n} from '@ibodr/store'\nimport { JsonObject } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { idValidator } from '../misc/id-validator'\n\n/**\n * Represents the current pointer/cursor position and activity state.\n * This record tracks the mouse or touch pointer coordinates and when\n * the pointer was last active, useful for cursor synchronization in\n * collaborative environments.\n *\n * There is typically one pointer record per browser tab that gets updated\n * as the user moves their mouse or touches the screen.\n *\n * @example\n * ```ts\n * const pointer: DrPointer = {\n * id: 'pointer:pointer',\n * typeName: 'pointer',\n * x: 150,\n * y: 200,\n * lastActivityTimestamp: Date.now(),\n * meta: {}\n * }\n * ```\n *\n * @public\n */\nexport interface DrPointer extends BaseRecord<'pointer', DrPointerId> {\n\tx: number\n\ty: number\n\tlastActivityTimestamp: number\n\tmeta: JsonObject\n}\n\n/**\n * A unique identifier for DrPointer records.\n *\n * Pointer IDs follow the format 'pointer:' followed by a unique identifier.\n * Typically there is one pointer record with a constant ID per session.\n *\n * @example\n * ```ts\n * const pointerId: DrPointerId = 'pointer:pointer'\n * ```\n *\n * @public\n */\nexport type DrPointerId = RecordId<DrPointer>\n\n/**\n * Runtime validator for DrPointer records. Validates the structure\n * and types of all pointer properties to ensure data integrity.\n *\n * @example\n * ```ts\n * const pointer = {\n * id: 'pointer:pointer',\n * typeName: 'pointer',\n * x: 100,\n * y: 200,\n * lastActivityTimestamp: Date.now(),\n * meta: {}\n * }\n * const isValid = pointerValidator.isValid(pointer) // true\n * ```\n *\n * @public\n */\nexport const pointerValidator: T.Validator<DrPointer> = T.model(\n\t'pointer',\n\tT.object({\n\t\ttypeName: T.literal('pointer'),\n\t\tid: idValidator<DrPointerId>('pointer'),\n\t\tx: T.number,\n\t\ty: T.number,\n\t\tlastActivityTimestamp: T.number,\n\t\tmeta: T.jsonValue as T.ObjectValidator<JsonObject>,\n\t})\n)\n\n/**\n * Migration version identifiers for DrPointer records. Each version\n * represents a schema change that requires data transformation when\n * loading older documents.\n *\n * @public\n */\nexport const pointerVersions = createMigrationIds('com.draw.pointer', {\n\tAddMeta: 1,\n})\n\n/**\n * Migration sequence for DrPointer records. Defines how to transform\n * pointer records between different schema versions, ensuring data\n * compatibility when loading documents created with different versions.\n *\n * @example\n * ```ts\n * // Migrations are applied automatically when loading documents\n * const migratedPointer = pointerMigrations.migrate(oldPointer, targetVersion)\n * ```\n *\n * @public\n */\nexport const pointerMigrations = createRecordMigrationSequence({\n\tsequenceId: 'com.draw.pointer',\n\trecordType: 'pointer',\n\tsequence: [\n\t\t{\n\t\t\tid: pointerVersions.AddMeta,\n\t\t\tup: (record: any) => {\n\t\t\t\trecord.meta = {}\n\t\t\t},\n\t\t},\n\t],\n})\n\n/**\n * The RecordType definition for DrPointer records. Defines validation,\n * scope, and default properties for pointer records in the tldraw store.\n *\n * Pointer records are scoped to the session level, meaning they are\n * specific to a browser tab and don't persist across sessions.\n *\n * @example\n * ```ts\n * const pointer = PointerRecordType.create({\n * id: 'pointer:pointer',\n * x: 0,\n * y: 0\n * })\n * ```\n *\n * @public\n */\nexport const PointerRecordType = createRecordType<DrPointer>('pointer', {\n\tvalidator: pointerValidator,\n\tscope: 'session',\n}).withDefaultProperties(\n\t(): Omit<DrPointer, 'id' | 'typeName'> => ({\n\t\tx: 0,\n\t\ty: 0,\n\t\tlastActivityTimestamp: 0,\n\t\tmeta: {},\n\t})\n)\n\n/**\n * The constant ID used for the singleton DrPointer record.\n *\n * Since each browser tab typically has one pointer, this constant ID\n * is used universally across the application.\n *\n * @example\n * ```ts\n * const pointer = store.get(DrPOINTER_ID)\n * if (pointer) {\n * console.log('Pointer at:', pointer.x, pointer.y)\n * }\n * ```\n *\n * @public\n */\nexport const DrPOINTER_ID = PointerRecordType.createId('pointer')\n","import {\n\tBaseRecord,\n\tcreateMigrationIds,\n\tcreateRecordMigrationSequence,\n\tcreateRecordType,\n\tRecordId,\n} from '@ibodr/store'\nimport { JsonObject } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { BoxModel, boxModelValidator } from '../misc/geometry-types'\nimport { idValidator } from '../misc/id-validator'\nimport { cursorTypeValidator, DrCursor } from '../misc/DrCursor'\nimport { scribbleValidator, DrScribble } from '../misc/DrScribble'\nimport { DrPageId } from './DrPage'\nimport { DrShapeId } from './DrShape'\n\n/**\n * Represents the presence state of a user in a collaborative tldraw session.\n * This record tracks what another user is doing: their cursor position, selected\n * shapes, current page, and other real-time activity indicators.\n *\n * Instance presence records are used in multiplayer environments to show\n * where other collaborators are working and what they're doing.\n *\n * @example\n * ```ts\n * const presence: DrInstancePresence = {\n * id: 'instance_presence:user123',\n * typeName: 'instance_presence',\n * userId: 'user123',\n * userName: 'Alice',\n * color: '#FF6B6B',\n * cursor: { x: 100, y: 150, type: 'default', rotation: 0 },\n * currentPageId: 'page:main',\n * selectedShapeIds: ['shape:rect1']\n * }\n * ```\n *\n * @public\n */\nexport interface DrInstancePresence extends BaseRecord<'instance_presence', DrInstancePresenceID> {\n\tuserId: string\n\tuserName: string\n\tlastActivityTimestamp: number | null\n\tcolor: string // can be any hex color\n\tcamera: { x: number; y: number; z: number } | null\n\tselectedShapeIds: DrShapeId[]\n\tcurrentPageId: DrPageId\n\tbrush: BoxModel | null\n\tscribbles: DrScribble[]\n\tscreenBounds: BoxModel | null\n\tfollowingUserId: string | null\n\tcursor: {\n\t\tx: number\n\t\ty: number\n\t\ttype: DrCursor['type']\n\t\trotation: number\n\t} | null\n\tchatMessage: string\n\tmeta: JsonObject\n}\n\n/**\n * A unique identifier for DrInstancePresence records.\n *\n * Instance presence IDs follow the format 'instance_presence:' followed\n * by a unique identifier, typically the user ID.\n *\n * @example\n * ```ts\n * const presenceId: DrInstancePresenceID = 'instance_presence:user123'\n * ```\n *\n * @public\n */\nexport type DrInstancePresenceID = RecordId<DrInstancePresence>\n\n/**\n * Runtime validator for DrInstancePresence records. Validates the structure\n * and types of all instance presence properties to ensure data integrity.\n *\n * @example\n * ```ts\n * const presence = {\n * id: 'instance_presence:user1',\n * typeName: 'instance_presence',\n * userId: 'user1',\n * userName: 'John',\n * color: '#007AFF',\n * cursor: { x: 0, y: 0, type: 'default', rotation: 0 },\n * currentPageId: 'page:main',\n * selectedShapeIds: []\n * }\n * const isValid = instancePresenceValidator.isValid(presence) // true\n * ```\n *\n * @public\n */\nexport const instancePresenceValidator: T.Validator<DrInstancePresence> = T.model(\n\t'instance_presence',\n\tT.object({\n\t\ttypeName: T.literal('instance_presence'),\n\t\tid: idValidator<DrInstancePresenceID>('instance_presence'),\n\t\tuserId: T.string,\n\t\tuserName: T.string,\n\t\tlastActivityTimestamp: T.number.nullable(),\n\t\tfollowingUserId: T.string.nullable(),\n\t\tcursor: T.object({\n\t\t\tx: T.number,\n\t\t\ty: T.number,\n\t\t\ttype: cursorTypeValidator,\n\t\t\trotation: T.number,\n\t\t}).nullable(),\n\t\tcolor: T.string,\n\t\tcamera: T.object({\n\t\t\tx: T.number,\n\t\t\ty: T.number,\n\t\t\tz: T.number,\n\t\t}).nullable(),\n\t\tscreenBounds: boxModelValidator.nullable(),\n\t\tselectedShapeIds: T.arrayOf(idValidator<DrShapeId>('shape')),\n\t\tcurrentPageId: idValidator<DrPageId>('page'),\n\t\tbrush: boxModelValidator.nullable(),\n\t\tscribbles: T.arrayOf(scribbleValidator),\n\t\tchatMessage: T.string,\n\t\tmeta: T.jsonValue as T.ObjectValidator<JsonObject>,\n\t})\n)\n\n/**\n * Migration version identifiers for DrInstancePresence records. Each version\n * represents a schema change that requires data transformation when loading\n * older documents.\n *\n * @public\n */\nexport const instancePresenceVersions = createMigrationIds('com.draw.instance_presence', {\n\tAddScribbleDelay: 1,\n\tRemoveInstanceId: 2,\n\tAddChatMessage: 3,\n\tAddMeta: 4,\n\tRenameSelectedShapeIds: 5,\n\tNullableCameraCursor: 6,\n} as const)\n\n/**\n * Migration sequence for DrInstancePresence records. Defines how to transform\n * instance presence records between different schema versions, ensuring data\n * compatibility when loading documents created with different versions.\n *\n * @example\n * ```ts\n * // Migrations are applied automatically when loading documents\n * const migrated = instancePresenceMigrations.migrate(oldPresence, targetVersion)\n * ```\n *\n * @public\n */\nexport const instancePresenceMigrations = createRecordMigrationSequence({\n\tsequenceId: 'com.draw.instance_presence',\n\trecordType: 'instance_presence',\n\tsequence: [\n\t\t{\n\t\t\tid: instancePresenceVersions.AddScribbleDelay,\n\t\t\tup: (instance: any) => {\n\t\t\t\tif (instance.scribble !== null) {\n\t\t\t\t\tinstance.scribble.delay = 0\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instancePresenceVersions.RemoveInstanceId,\n\t\t\tup: (instance: any) => {\n\t\t\t\tdelete instance.instanceId\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instancePresenceVersions.AddChatMessage,\n\t\t\tup: (instance: any) => {\n\t\t\t\tinstance.chatMessage = ''\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instancePresenceVersions.AddMeta,\n\t\t\tup: (record: any) => {\n\t\t\t\trecord.meta = {}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instancePresenceVersions.RenameSelectedShapeIds,\n\t\t\tup: (_record) => {\n\t\t\t\t// noop, whoopsie\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: instancePresenceVersions.NullableCameraCursor,\n\t\t\tup: (_record: any) => {\n\t\t\t\t// noop\n\t\t\t},\n\t\t\tdown: (record: any) => {\n\t\t\t\tif (record.camera === null) {\n\t\t\t\t\trecord.camera = { x: 0, y: 0, z: 1 }\n\t\t\t\t}\n\t\t\t\tif (record.lastActivityTimestamp === null) {\n\t\t\t\t\trecord.lastActivityTimestamp = 0\n\t\t\t\t}\n\t\t\t\tif (record.cursor === null) {\n\t\t\t\t\trecord.cursor = { type: 'default', x: 0, y: 0, rotation: 0 }\n\t\t\t\t}\n\t\t\t\tif (record.screenBounds === null) {\n\t\t\t\t\trecord.screenBounds = { x: 0, y: 0, w: 1, h: 1 }\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t],\n})\n\n/**\n * The RecordType definition for DrInstancePresence records. Defines validation,\n * scope, and default properties for instance presence records.\n *\n * Instance presence records are scoped to the presence level, meaning they\n * represent real-time collaborative state that is ephemeral and tied to\n * active user sessions.\n *\n * @example\n * ```ts\n * const presence = InstancePresenceRecordType.create({\n * id: 'instance_presence:user1',\n * userId: 'user1',\n * userName: 'Alice',\n * color: '#FF6B6B',\n * currentPageId: 'page:main'\n * })\n * ```\n *\n * @public\n */\nexport const InstancePresenceRecordType = createRecordType<DrInstancePresence>(\n\t'instance_presence',\n\t{\n\t\tvalidator: instancePresenceValidator,\n\t\tscope: 'presence',\n\t}\n).withDefaultProperties(() => ({\n\tlastActivityTimestamp: null,\n\tfollowingUserId: null,\n\tcolor: '#FF0000',\n\tcamera: null,\n\tcursor: null,\n\tscreenBounds: null,\n\tselectedShapeIds: [],\n\tbrush: null,\n\tscribbles: [],\n\tchatMessage: '',\n\tmeta: {},\n}))\n","import { Signal, computed } from '@ibodr/state'\nimport { CameraRecordType } from './records/DrCamera'\nimport { DrINSTANCE_ID } from './records/DrInstance'\nimport { InstancePageStateRecordType } from './records/DrPageState'\nimport { DrPOINTER_ID } from './records/DrPointer'\nimport { InstancePresenceRecordType, DrInstancePresence } from './records/DrPresence'\nimport { DrUser } from './records/DrUser'\nimport { DrStore } from './DrStore'\n\n/** @public */\nexport interface CreatePresenceStateDerivationOpts {\n\t/** Custom instance ID. If not provided, one is generated from the store ID. */\n\tinstanceId?: DrInstancePresence['id']\n\t/**\n\t * Override how presence state is built from the store and current user.\n\t * Defaults to {@link getDefaultUserPresence}.\n\t */\n\tgetUserPresence?(store: DrStore, user: DrUser): DrPresenceStateInfo | null\n}\n\n/**\n * Creates a derivation that represents the current presence state of the current user.\n *\n * This function returns a derivation factory that, when given a store, creates a computed signal\n * containing the user's current presence state. The presence state includes information like cursor\n * position, selected shapes, camera position, and user metadata that gets synchronized in\n * multiplayer scenarios.\n *\n * @param $user - A reactive signal containing the user information, or `null` when anonymous\n * @param opts - Optional configuration for instance ID and presence derivation\n * @returns A function that takes a store and returns a computed signal of the user's presence state\n *\n * @example\n * ```ts\n * import { createPresenceStateDerivation } from '@ibodr/schema'\n * import { atom } from '@ibodr/state'\n *\n * const userSignal = atom('user', { id: 'user-123', name: 'Alice', color: '#ff0000', meta: {} })\n * const presenceDerivation = createPresenceStateDerivation(userSignal)\n *\n * // Use with a store to get reactive presence state\n * const presenceState = presenceDerivation(store)\n * console.log(presenceState.get()) // Current user presence or null\n * ```\n *\n * @public\n */\nexport function createPresenceStateDerivation(\n\t$user: Signal<DrUser | null>,\n\topts?: CreatePresenceStateDerivationOpts\n) {\n\tconst { instanceId, getUserPresence: _getUserPresence } = opts ?? {}\n\tconst getUserPresence = _getUserPresence ?? getDefaultUserPresence\n\treturn (store: DrStore): Signal<DrInstancePresence | null> => {\n\t\treturn computed('instancePresence', () => {\n\t\t\tconst user = $user.get()\n\t\t\tif (!user) return null\n\n\t\t\tconst state = getUserPresence(store, user)\n\t\t\tif (!state) return null\n\n\t\t\treturn InstancePresenceRecordType.create({\n\t\t\t\t...state,\n\t\t\t\tid: instanceId ?? InstancePresenceRecordType.createId(store.id),\n\t\t\t})\n\t\t})\n\t}\n}\n\n/**\n * The shape of data used to create a presence record.\n *\n * This type represents all the properties needed to construct a DrInstancePresence record.\n * It includes user information, cursor state, camera position, selected shapes, and other\n * presence-related data that gets synchronized across multiplayer clients.\n *\n * @public\n */\nexport type DrPresenceStateInfo = Parameters<(typeof InstancePresenceRecordType)['create']>[0]\n\n/**\n * Creates default presence state information for a user based on the current store state.\n *\n * This function extracts the current state from various store records (instance, page state,\n * camera, pointer) and combines them with user information to create a complete presence\n * state object. This is commonly used as a starting point for custom presence implementations.\n *\n * @param store - The tldraw store containing the current editor state\n * @param user - The user information to include in the presence state\n * @returns The default presence state info, or null if required store records are missing\n *\n * @example\n * ```ts\n * import { getDefaultUserPresence } from '@ibodr/schema'\n *\n * const user = { id: 'user-123', name: 'Alice', color: '#ff0000', meta: {} }\n * const presenceInfo = getDefaultUserPresence(store, user)\n *\n * if (presenceInfo) {\n * console.log('Current cursor:', presenceInfo.cursor)\n * console.log('Selected shapes:', presenceInfo.selectedShapeIds)\n * console.log('Camera position:', presenceInfo.camera)\n * }\n * ```\n *\n * @example\n * ```ts\n * // Common pattern: customize default presence\n * const customPresence = {\n * ...getDefaultUserPresence(store, user),\n * // Remove camera for privacy\n * camera: undefined,\n * // Add custom metadata\n * customField: 'my-data'\n * }\n * ```\n *\n * @public\n */\nexport function getDefaultUserPresence(store: DrStore, user: DrUser) {\n\tconst instance = store.get(DrINSTANCE_ID)\n\tconst pageState = store.get(InstancePageStateRecordType.createId(instance?.currentPageId))\n\tconst camera = store.get(CameraRecordType.createId(instance?.currentPageId))\n\tconst pointer = store.get(DrPOINTER_ID)\n\tif (!pageState || !instance || !camera || !pointer) {\n\t\treturn null\n\t}\n\n\treturn {\n\t\tselectedShapeIds: pageState.selectedShapeIds,\n\t\tbrush: instance.brush,\n\t\tscribbles: instance.scribbles,\n\t\tuserId: user.id,\n\t\tuserName: user.name,\n\t\tfollowingUserId: instance.followingUserId,\n\t\tcamera: {\n\t\t\tx: camera.x,\n\t\t\ty: camera.y,\n\t\t\tz: camera.z,\n\t\t},\n\t\tcolor: user.color || '#FF0000',\n\t\tcurrentPageId: instance.currentPageId,\n\t\tcursor: {\n\t\t\tx: pointer.x,\n\t\t\ty: pointer.y,\n\t\t\trotation: instance.cursor.rotation,\n\t\t\ttype: instance.cursor.type,\n\t\t},\n\t\tlastActivityTimestamp: pointer.lastActivityTimestamp,\n\t\tscreenBounds: instance.screenBounds,\n\t\tchatMessage: instance.chatMessage,\n\t\tmeta: {},\n\t} satisfies DrPresenceStateInfo\n}\n","import {\n\tcreateMigrationIds,\n\tcreateRecordMigrationSequence,\n\tcreateRecordType,\n\tRecordId,\n} from '@ibodr/store'\nimport { mapObjectMapValues } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { createAssetValidator, DrBaseAsset } from '../assets/DrBaseAsset'\nimport { DrBookmarkAsset } from '../assets/DrBookmarkAsset'\nimport { DrImageAsset } from '../assets/DrImageAsset'\nimport { DrVideoAsset } from '../assets/DrVideoAsset'\nimport { SchemaPropsInfo } from '../createDrSchema'\nimport { DrPropsMigrations } from '../recordsWithProps'\nimport { ExtractShapeByProps } from './DrShape'\n\n/**\n * The default set of asset types that are available in the editor.\n *\n * @example\n * ```ts\n * const imageAsset: DrDefaultAsset = {\n * id: 'asset:image123',\n * typeName: 'asset',\n * type: 'image',\n * props: {\n * src: 'https://example.com/image.jpg',\n * w: 800,\n * h: 600,\n * mimeType: 'image/jpeg',\n * isAnimated: false,\n * name: 'image.jpg',\n * },\n * meta: {},\n * }\n * ```\n *\n * @public\n */\nexport type DrDefaultAsset = DrImageAsset | DrVideoAsset | DrBookmarkAsset\n\n/**\n * A type for an asset that is available in the editor but whose type is\n * unknown—either one of the editor's default assets or else a custom asset.\n *\n * @public\n */\nexport type DrUnknownAsset = DrBaseAsset<string, object>\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface DrGlobalAssetPropsMap {}\n\n/** @public */\n// prettier-ignore\nexport type DrIndexedAssets = {\n\t[K in keyof DrGlobalAssetPropsMap | DrDefaultAsset['type'] as K extends DrDefaultAsset['type']\n\t\t? K extends keyof DrGlobalAssetPropsMap\n\t\t\t? DrGlobalAssetPropsMap[K] extends null | undefined\n\t\t\t\t? never\n\t\t\t\t: K\n\t\t\t: K\n\t\t: K]: K extends DrDefaultAsset['type']\n\t\t? K extends keyof DrGlobalAssetPropsMap\n\t\t\t? DrBaseAsset<K, DrGlobalAssetPropsMap[K]>\n\t\t\t: Extract<DrDefaultAsset, { type: K }>\n\t\t: DrBaseAsset<K, DrGlobalAssetPropsMap[K & keyof DrGlobalAssetPropsMap]>\n}\n\n/**\n * The set of all assets that are available in the editor.\n *\n * This is the primary asset type used throughout tldraw. It includes both the\n * built-in default assets and any custom assets registered via\n * {@link DrGlobalAssetPropsMap} augmentation.\n *\n * You can use this type without a type argument to work with any asset, or pass\n * a specific asset type string (e.g., `'image'`, `'video'`, `'bookmark'`) to\n * narrow down to that specific asset type.\n *\n * @example\n * ```ts\n * // Register a custom asset type\n * declare module '@ibodr/schema' {\n * interface DrGlobalAssetPropsMap {\n * file: { name: string; size: number; mimeType: string; src: string | null }\n * }\n * }\n * ```\n *\n * @public\n */\nexport type DrAsset<K extends keyof DrIndexedAssets = keyof DrIndexedAssets> = DrIndexedAssets[K]\n\n/**\n * Migration version identifiers for asset record schema evolution.\n * Each version represents a breaking change that requires data migration.\n *\n * @example\n * ```ts\n * // Check if a migration is needed\n * const needsMigration = currentVersion < assetVersions.AddMeta\n * ```\n *\n * @public\n */\nexport const assetVersions = createMigrationIds('com.draw.asset', {\n\tAddMeta: 1,\n} as const)\n\n/**\n * Migration sequence for evolving asset record structure over time.\n * Handles converting asset records from older schema versions to current format.\n *\n * @example\n * ```ts\n * // Migration is applied automatically when loading old documents\n * const migratedStore = migrator.migrateStoreSnapshot({\n * schema: oldSchema,\n * store: oldStoreSnapshot,\n * })\n * ```\n *\n * @public\n */\nexport const assetMigrations = createRecordMigrationSequence({\n\tsequenceId: 'com.draw.asset',\n\trecordType: 'asset',\n\tsequence: [\n\t\t{\n\t\t\tid: assetVersions.AddMeta,\n\t\t\tup: (record) => {\n\t\t\t\t;(record as any).meta = {}\n\t\t\t},\n\t\t},\n\t],\n})\n\n/**\n * Partial type for DrAsset allowing optional properties except id and type.\n * Useful for creating or updating assets where not all properties need to be specified.\n *\n * @example\n * ```ts\n * // Create a partial asset for updating\n * const partialAsset: DrAssetPartial<DrImageAsset> = {\n * id: 'asset:image123',\n * type: 'image',\n * props: {\n * w: 800, // Only updating width\n * },\n * }\n *\n * // Use in asset updates\n * editor.updateAssets([partialAsset])\n * ```\n *\n * @public\n */\nexport type DrAssetPartial<T extends DrAsset = DrAsset> = T extends T\n\t? {\n\t\t\tid: DrAssetId\n\t\t\ttype: T['type']\n\t\t\tprops?: Partial<T['props']>\n\t\t\tmeta?: Partial<T['meta']>\n\t\t} & Partial<Omit<T, 'type' | 'id' | 'props' | 'meta'>>\n\t: never\n\n/**\n * Creates the record type definition for assets based on registered asset schemas.\n * This function follows the same pattern as `createShapeRecordType` and `createBindingRecordType`.\n *\n * @param assets - Record of asset type names to their schema configuration\n * @returns A configured record type for assets with validation\n *\n * @example\n * ```ts\n * const AssetRecordType = createAssetRecordType({\n * image: { migrations: imageAssetMigrations, props: imageAssetProps },\n * video: { migrations: videoAssetMigrations, props: videoAssetProps },\n * bookmark: { migrations: bookmarkAssetMigrations, props: bookmarkAssetProps },\n * })\n * ```\n *\n * @internal\n */\nexport function createAssetRecordType(assets: Record<string, SchemaPropsInfo>) {\n\treturn createRecordType('asset', {\n\t\tscope: 'document',\n\t\tvalidator: T.model(\n\t\t\t'asset',\n\t\t\tT.union(\n\t\t\t\t'type',\n\t\t\t\tmapObjectMapValues(assets, (type, { props, meta }) =>\n\t\t\t\t\tcreateAssetValidator(type, props, meta)\n\t\t\t\t)\n\t\t\t)\n\t\t),\n\t}).withDefaultProperties(() => ({\n\t\tmeta: {},\n\t}))\n}\n\n/**\n * Record type definition for default DrAsset records with document scope and default metadata.\n *\n * @public\n */\nexport const AssetRecordType = createRecordType<DrAsset>('asset', {\n\tscope: 'document',\n}).withDefaultProperties(() => ({\n\tmeta: {},\n}))\n\n/**\n * Branded string type for asset record identifiers.\n * Prevents mixing asset IDs with other record IDs at compile time.\n *\n * @example\n * ```ts\n * const imageShape = {\n * type: 'image',\n * props: {\n * assetId: 'asset:image123' as DrAssetId,\n * },\n * }\n * ```\n *\n * @public\n */\nexport type DrAssetId = RecordId<DrBaseAsset<any, any>>\n\n/**\n * Union type of all shapes that reference assets through an assetId property.\n * Includes image shapes, video shapes, and any other shapes that depend on external assets.\n *\n * @example\n * ```ts\n * function handleAssetShape(shape: DrAssetShape) {\n * const assetId = shape.props.assetId\n * if (!assetId) return\n * const asset = editor.getAsset(assetId)\n * // Handle the asset...\n * }\n * ```\n *\n * @public\n */\nexport type DrAssetShape = ExtractShapeByProps<{ assetId: DrAssetId }>\n\n/**\n * Creates a migration sequence for asset properties.\n *\n * @example\n * ```ts\n * const migrations = createAssetPropsMigrationSequence({\n * sequence: [\n * { id: 'com.myapp.asset.custom/1', up: (props) => { props.newField = '' } },\n * ],\n * })\n * ```\n *\n * @public\n */\nexport function createAssetPropsMigrationSequence(\n\tmigrations: DrPropsMigrations\n): DrPropsMigrations {\n\treturn migrations\n}\n\n/**\n * Creates properly formatted migration IDs for asset properties.\n *\n * @example\n * ```ts\n * const assetPropsVersions = createAssetPropsMigrationIds('file', {\n * AddFoo: 1,\n * RenameBar: 2,\n * })\n * // => { AddFoo: 'com.draw.asset.file/1', RenameBar: 'com.draw.asset.file/2' }\n * ```\n *\n * @public\n */\nexport function createAssetPropsMigrationIds<S extends string, T extends Record<string, number>>(\n\tassetType: S,\n\tids: T\n): { [k in keyof T]: `com.draw.asset.${S}/${T[k]}` } {\n\treturn mapObjectMapValues(ids, (_k, v) => `com.draw.asset.${assetType}/${v}`) as any\n}\n","import {\n\tMigrationSequence,\n\tRecordId,\n\tRecordScope,\n\tUnknownRecord,\n\tcreateMigrationSequence,\n\tcreateRecordType,\n} from '@ibodr/store'\nimport { assert, mapObjectMapValues, uniqueId } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { DrPropsMigrations } from '../recordsWithProps'\n\n/**\n * Configuration for a custom record type in the schema.\n *\n * Custom record types allow you to add entirely new data types to the tldraw store\n * that don't fit into the existing shape, binding, or asset categories. This is useful\n * for storing domain-specific data like comments, annotations, or application state\n * that needs to participate in persistence and synchronization.\n *\n * @example\n * ```ts\n * const commentRecordConfig: CustomRecordInfo = {\n * scope: 'document',\n * validator: T.object({\n * id: T.string,\n * typeName: T.literal('comment'),\n * text: T.string,\n * shapeId: T.string,\n * authorId: T.string,\n * createdAt: T.number,\n * }),\n * migrations: createRecordMigrationSequence({\n * sequenceId: 'com.myapp.comment',\n * recordType: 'comment',\n * sequence: [],\n * }),\n * }\n * ```\n *\n * @public\n */\nexport interface CustomRecordInfo {\n\t/**\n\t * The scope determines how records of this type are persisted and synchronized:\n\t * - **document**: Persisted and synced across all clients\n\t * - **session**: Local to current session, not synced\n\t * - **presence**: Ephemeral presence data, may be synced but not persisted\n\t */\n\tscope: RecordScope\n\n\t/**\n\t * Validator for the complete record structure.\n\t *\n\t * Should validate the entire record including `id` and `typeName` fields.\n\t * Use validators like T.object, T.string, etc.\n\t */\n\tvalidator: T.Validatable<any>\n\n\t/**\n\t * Optional migration sequence for handling schema evolution over time.\n\t *\n\t * Can be a full MigrationSequence or a simplified DrPropsMigrations format.\n\t * If not provided, an empty migration sequence will be created automatically.\n\t */\n\tmigrations?: MigrationSequence | DrPropsMigrations\n\n\t/**\n\t * Optional factory function that returns default property values for new records.\n\t *\n\t * Called when creating new records to provide initial values for any properties\n\t * not explicitly provided during creation.\n\t */\n\t// eslint-disable-next-line tldraw/method-signature-style\n\tcreateDefaultProperties?: () => Record<string, unknown>\n}\n\n/**\n * Creates a RecordType for a custom record based on its configuration.\n *\n * @param typeName - The unique type name for this record type\n * @param config - Configuration for the custom record type\n * @returns A RecordType instance that can be used to create and manage records\n *\n * @internal\n */\nexport function createCustomRecordType(typeName: string, config: CustomRecordInfo) {\n\treturn createRecordType<UnknownRecord>(typeName, {\n\t\tscope: config.scope,\n\t\tvalidator: config.validator,\n\t}).withDefaultProperties(config.createDefaultProperties ?? (() => ({})))\n}\n\n/**\n * Processes migrations for custom record types.\n *\n * Converts the migration configuration from CustomRecordInfo into proper\n * MigrationSequence objects that can be used by the store system.\n *\n * @param records - Record of type names to their configuration\n * @returns Array of migration sequences for the custom record types\n *\n * @internal\n */\nexport function processCustomRecordMigrations(\n\trecords: Record<string, CustomRecordInfo>\n): MigrationSequence[] {\n\tconst result: MigrationSequence[] = []\n\n\tfor (const [typeName, config] of Object.entries(records)) {\n\t\tconst sequenceId = `com.draw.${typeName}`\n\t\tconst { migrations } = config\n\n\t\tif (!migrations) {\n\t\t\t// Provide empty migration sequence to allow for future migrations\n\t\t\tresult.push(\n\t\t\t\tcreateMigrationSequence({\n\t\t\t\t\tsequenceId,\n\t\t\t\t\tretroactive: true,\n\t\t\t\t\tsequence: [],\n\t\t\t\t})\n\t\t\t)\n\t\t} else if ('sequenceId' in migrations) {\n\t\t\t// Full MigrationSequence provided\n\t\t\tassert(\n\t\t\t\tsequenceId === migrations.sequenceId,\n\t\t\t\t`sequenceId mismatch for ${typeName} custom record migrations. Expected '${sequenceId}', got '${migrations.sequenceId}'`\n\t\t\t)\n\t\t\tresult.push(migrations)\n\t\t} else if ('sequence' in migrations) {\n\t\t\t// DrPropsMigrations format - convert to full MigrationSequence\n\t\t\tresult.push(\n\t\t\t\tcreateMigrationSequence({\n\t\t\t\t\tsequenceId,\n\t\t\t\t\tretroactive: true,\n\t\t\t\t\tsequence: migrations.sequence.map((m) => {\n\t\t\t\t\t\tif (!('id' in m)) return m\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: m.id,\n\t\t\t\t\t\t\tdependsOn: m.dependsOn,\n\t\t\t\t\t\t\tscope: 'record' as const,\n\t\t\t\t\t\t\tfilter: (r: UnknownRecord) => r.typeName === typeName,\n\t\t\t\t\t\t\tup: (record: any) => {\n\t\t\t\t\t\t\t\tconst result = m.up(record)\n\t\t\t\t\t\t\t\tif (result) return result\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdown:\n\t\t\t\t\t\t\t\ttypeof m.down === 'function'\n\t\t\t\t\t\t\t\t\t? (record: any) => {\n\t\t\t\t\t\t\t\t\t\t\tconst result = (m.down as (r: any) => any)(record)\n\t\t\t\t\t\t\t\t\t\t\tif (result) return result\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t}\n\t\t\t\t\t}),\n\t\t\t\t})\n\t\t\t)\n\t\t}\n\t}\n\n\treturn result\n}\n\n/**\n * Creates properly formatted migration IDs for custom record migrations.\n *\n * Generates standardized migration IDs following the convention:\n * `com.draw.{recordType}/{version}`\n *\n * @param recordType - The type name of the custom record\n * @param ids - Record mapping migration names to version numbers\n * @returns Record with the same keys but formatted migration ID values\n *\n * @example\n * ```ts\n * const commentVersions = createCustomRecordMigrationIds('comment', {\n * AddAuthorId: 1,\n * AddCreatedAt: 2,\n * RefactorReactions: 3\n * })\n * // Result: {\n * // AddAuthorId: 'com.draw.comment/1',\n * // AddCreatedAt: 'com.draw.comment/2',\n * // RefactorReactions: 'com.draw.comment/3'\n * // }\n * ```\n *\n * @public\n */\nexport function createCustomRecordMigrationIds<\n\tconst S extends string,\n\tconst T extends Record<string, number>,\n>(recordType: S, ids: T): { [k in keyof T]: `com.draw.${S}/${T[k]}` } {\n\treturn mapObjectMapValues(ids, (_k, v) => `com.draw.${recordType}/${v}`) as any\n}\n\n/**\n * Creates a migration sequence for custom record types.\n *\n * This is a pass-through function that maintains the same structure as the input.\n * It's used for consistency and to provide a clear API for defining custom record migrations.\n *\n * @param migrations - The migration sequence to create\n * @returns The same migration sequence (pass-through)\n *\n * @example\n * ```ts\n * const commentMigrations = createCustomRecordMigrationSequence({\n * sequence: [\n * {\n * id: 'com.myapp.comment/1',\n * up: (record) => ({ ...record, authorId: record.authorId ?? 'unknown' }),\n * down: ({ authorId, ...record }) => record\n * }\n * ]\n * })\n * ```\n *\n * @public\n */\nexport function createCustomRecordMigrationSequence(\n\tmigrations: DrPropsMigrations\n): DrPropsMigrations {\n\treturn migrations\n}\n\n/**\n * Creates a unique ID for a custom record type.\n *\n * @param typeName - The type name of the custom record\n * @param id - Optional custom ID suffix. If not provided, a unique ID will be generated\n * @returns A properly formatted record ID\n *\n * @example\n * ```ts\n * // Create with auto-generated ID\n * const commentId = createCustomRecordId('comment') // 'comment:abc123'\n *\n * // Create with custom ID\n * const customId = createCustomRecordId('comment', 'my-comment') // 'comment:my-comment'\n * ```\n *\n * @public\n */\nexport function createCustomRecordId<T extends string>(\n\ttypeName: T,\n\tid?: string\n): RecordId<UnknownRecord> & `${T}:${string}` {\n\treturn `${typeName}:${id ?? uniqueId()}` as RecordId<UnknownRecord> & `${T}:${string}`\n}\n\n/**\n * Type guard to check if a string is a valid ID for a specific custom record type.\n *\n * @param typeName - The type name to check against\n * @param id - The string to check\n * @returns True if the string is a valid ID for the specified record type\n *\n * @example\n * ```ts\n * const id = 'comment:abc123'\n * if (isCustomRecordId('comment', id)) {\n * // id is now typed as a comment record ID\n * const comment = store.get(id)\n * }\n * ```\n *\n * @public\n */\nexport function isCustomRecordId(typeName: string, id?: string): boolean {\n\tif (!id) return false\n\treturn id.startsWith(`${typeName}:`)\n}\n\n/**\n * Type guard to check if a record is of a specific custom type.\n *\n * @param typeName - The type name to check against\n * @param record - The record to check\n * @returns True if the record is of the specified type\n *\n * @example\n * ```ts\n * function handleRecord(record: DrRecord) {\n * if (isCustomRecord('comment', record)) {\n * // Handle comment record\n * console.log(`Comment: ${record.text}`)\n * }\n * }\n * ```\n *\n * @public\n */\nexport function isCustomRecord(typeName: string, record?: UnknownRecord): boolean {\n\tif (!record) return false\n\treturn record.typeName === typeName\n}\n","import {\n\tBaseRecord,\n\tcreateMigrationIds,\n\tcreateRecordMigrationSequence,\n\tcreateRecordType,\n\tRecordId,\n\tUnknownRecord,\n} from '@ibodr/store'\nimport { JsonObject } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\n\n/**\n * Document record containing global settings and metadata for a tldraw document.\n * There is exactly one document record per tldraw instance with a fixed ID.\n *\n * @example\n * ```ts\n * const document: DrDocument = {\n * id: 'document:document',\n * typeName: 'document',\n * gridSize: 20, // Grid snap size in pixels\n * name: 'My Drawing', // Document name\n * meta: {\n * createdAt: Date.now(),\n * author: 'user123',\n * version: '1.0.0'\n * }\n * }\n *\n * // Update document settings\n * editor.updateDocumentSettings({\n * name: 'Updated Drawing',\n * gridSize: 25\n * })\n * ```\n *\n * @public\n */\nexport interface DrDocument extends BaseRecord<'document', RecordId<DrDocument>> {\n\t/** Grid snap size in pixels. Used for shape positioning and alignment */\n\tgridSize: number\n\t/** Human-readable name of the document */\n\tname: string\n\t/** User-defined metadata for the document */\n\tmeta: JsonObject\n}\n\n/**\n * Validator for DrDocument records that ensures runtime type safety.\n * Enforces the fixed document ID and validates all document properties.\n *\n * @example\n * ```ts\n * // Validation happens automatically when document is stored\n * try {\n * const validatedDocument = documentValidator.validate(documentData)\n * store.put([validatedDocument])\n * } catch (error) {\n * console.error('Document validation failed:', error.message)\n * }\n * ```\n *\n * @public\n */\nexport const documentValidator: T.Validator<DrDocument> = T.model(\n\t'document',\n\tT.object({\n\t\ttypeName: T.literal('document'),\n\t\tid: T.literal('document:document' as RecordId<DrDocument>),\n\t\tgridSize: T.number,\n\t\tname: T.string,\n\t\tmeta: T.jsonValue as T.ObjectValidator<JsonObject>,\n\t})\n)\n\n/**\n * Type guard to check if a record is a DrDocument.\n * Useful for filtering or type narrowing when working with mixed record types.\n *\n * @param record - The record to check\n * @returns True if the record is a document, false otherwise\n *\n * @example\n * ```ts\n * // Type guard usage\n * function processRecord(record: UnknownRecord) {\n * if (isDocument(record)) {\n * // record is now typed as DrDocument\n * console.log(`Document: ${record.name}, Grid: ${record.gridSize}px`)\n * }\n * }\n *\n * // Filter documents from mixed records\n * const allRecords = store.allRecords()\n * const documents = allRecords.filter(isDocument) // Should be exactly one\n * ```\n *\n * @public\n */\nexport function isDocument(record?: UnknownRecord): record is DrDocument {\n\tif (!record) return false\n\treturn record.typeName === 'document'\n}\n\n/**\n * Migration version identifiers for document record schema evolution.\n * Each version represents a breaking change that requires data migration.\n *\n * @example\n * ```ts\n * // Check if document needs migration\n * const needsNameMigration = currentVersion < documentVersions.AddName\n * const needsMetaMigration = currentVersion < documentVersions.AddMeta\n * ```\n *\n * @public\n */\nexport const documentVersions = createMigrationIds('com.draw.document', {\n\tAddName: 1,\n\tAddMeta: 2,\n} as const)\n\n/**\n * Migration sequence for evolving document record structure over time.\n * Handles converting document records from older schema versions to current format.\n *\n * @example\n * ```ts\n * // Migration is applied automatically when loading old documents\n * const migratedStore = migrator.migrateStoreSnapshot({\n * schema: oldSchema,\n * store: oldStoreSnapshot\n * })\n *\n * // The migrations:\n * // v1: Added 'name' property with empty string default\n * // v2: Added 'meta' property with empty object default\n * ```\n *\n * @public\n */\nexport const documentMigrations = createRecordMigrationSequence({\n\tsequenceId: 'com.draw.document',\n\trecordType: 'document',\n\tsequence: [\n\t\t{\n\t\t\tid: documentVersions.AddName,\n\t\t\tup: (document) => {\n\t\t\t\t;(document as any).name = ''\n\t\t\t},\n\t\t\tdown: (document) => {\n\t\t\t\tdelete (document as any).name\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: documentVersions.AddMeta,\n\t\t\tup: (record) => {\n\t\t\t\t;(record as any).meta = {}\n\t\t\t},\n\t\t},\n\t],\n})\n\n/**\n * Record type definition for DrDocument with validation and default properties.\n * Configures the document as a document-scoped record that persists across sessions.\n *\n * @example\n * ```ts\n * // Create a document record (usually done automatically)\n * const documentRecord = DocumentRecordType.create({\n * id: DrDOCUMENT_ID,\n * name: 'My Drawing',\n * gridSize: 20,\n * meta: { createdAt: Date.now() }\n * })\n *\n * // Create with defaults\n * const defaultDocument = DocumentRecordType.create({\n * id: DrDOCUMENT_ID\n * // gridSize: 10, name: '', meta: {} are applied as defaults\n * })\n *\n * // Store the document\n * store.put([documentRecord])\n * ```\n *\n * @public\n */\nexport const DocumentRecordType = createRecordType<DrDocument>('document', {\n\tvalidator: documentValidator,\n\tscope: 'document',\n}).withDefaultProperties(\n\t(): Omit<DrDocument, 'id' | 'typeName'> => ({\n\t\tgridSize: 10,\n\t\tname: '',\n\t\tmeta: {},\n\t})\n)\n\n/**\n * The fixed ID for the singleton document record in every tldraw store.\n * All document records use this same ID: 'document:document'\n *\n * @example\n * ```ts\n * // Get the document from store\n * const document = store.get(DrDOCUMENT_ID)\n *\n * // Update document settings\n * store.put([{\n * ...document,\n * name: 'Updated Name',\n * gridSize: 25\n * }])\n *\n * // Access via editor\n * const documentSettings = editor.getDocumentSettings()\n * editor.updateDocumentSettings({ name: 'New Name' })\n * ```\n *\n * @public\n */\nexport const DrDOCUMENT_ID: RecordId<DrDocument> = DocumentRecordType.createId('document')\n","import {\n\tBaseRecord,\n\tcreateMigrationIds,\n\tcreateRecordMigrationSequence,\n\tcreateRecordType,\n\tRecordId,\n} from '@ibodr/store'\nimport { JsonObject } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { idValidator } from '../misc/id-validator'\n\n/**\n * A user record in a tldraw store. User records are document-scoped and\n * persist alongside shapes, assets, and pages. They are automatically\n * included in snapshots, clipboard content, and `.drawdoc` files so that\n * attribution display names survive across boards and sessions.\n *\n * User records are populated from the {@link @ibodr/schema#DrUserStore}\n * when the editor stamps attribution metadata onto shapes.\n *\n * Extend user records with custom metadata by passing validators to\n * {@link @ibodr/schema#createDrSchema} or {@link createUserRecordType}.\n *\n * @public\n */\nexport interface DrUser extends BaseRecord<'user', DrUserId> {\n\tname: string\n\tcolor: string\n\timageUrl: string\n\tmeta: JsonObject\n}\n\n/** @public */\nexport type DrUserId = RecordId<DrUser>\n\n/** @public */\nexport const userIdValidator = idValidator<DrUserId>('user')\n\n/** @public */\nexport const userVersions = createMigrationIds('com.draw.user', {\n\tInitial: 1,\n})\n\n/** @public */\nexport const userMigrations = createRecordMigrationSequence({\n\tsequenceId: 'com.draw.user',\n\trecordType: 'user',\n\tsequence: [\n\t\t{\n\t\t\tid: userVersions.Initial,\n\t\t\tup: (_record: any) => {\n\t\t\t\t// initial version — nothing to migrate\n\t\t\t},\n\t\t},\n\t],\n})\n\n/**\n * Creates a user record type with optional custom meta validation.\n *\n * When `meta` validators are provided, the user record's `meta` field will\n * validate those specific fields (when present) while still allowing\n * arbitrary additional JSON properties. Custom meta fields are treated as\n * optional so that user records created without them remain valid.\n *\n * @param config - Optional configuration for custom meta validators\n * @returns A configured user record type\n *\n * @example\n * ```ts\n * import { createUserRecordType } from '@ibodr/schema'\n * import { T } from '@ibodr/validate'\n *\n * const CustomUserRecordType = createUserRecordType({\n * meta: {\n * isAdmin: T.boolean,\n * department: T.string,\n * },\n * })\n * ```\n *\n * @public\n */\nexport function createUserRecordType(config?: { meta?: Record<string, T.Validatable<any>> }) {\n\tconst metaConfig = config?.meta\n\n\tconst metaValidator = metaConfig\n\t\t? T.object(\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries(metaConfig).map(([key, v]) => [\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tnew T.Validator((value) => {\n\t\t\t\t\t\t\tif (value === undefined) return undefined\n\t\t\t\t\t\t\treturn (v as T.Validator<unknown>).validate(value)\n\t\t\t\t\t\t}),\n\t\t\t\t\t])\n\t\t\t\t)\n\t\t\t).allowUnknownProperties()\n\t\t: (T.jsonValue as T.ObjectValidator<JsonObject>)\n\n\tconst validator: T.Validator<DrUser> = T.model(\n\t\t'user',\n\t\tT.object({\n\t\t\ttypeName: T.literal('user'),\n\t\t\tid: userIdValidator,\n\t\t\tname: T.string,\n\t\t\tcolor: T.string,\n\t\t\timageUrl: T.string,\n\t\t\tmeta: metaValidator as T.ObjectValidator<JsonObject>,\n\t\t})\n\t)\n\n\treturn createRecordType<DrUser>('user', {\n\t\tvalidator,\n\t\tscope: 'document',\n\t}).withDefaultProperties(() => ({\n\t\tname: '',\n\t\tcolor: '',\n\t\timageUrl: '',\n\t\tmeta: {},\n\t}))\n}\n\n/** @public */\nexport const userValidator: T.Validator<DrUser> = T.model(\n\t'user',\n\tT.object({\n\t\ttypeName: T.literal('user'),\n\t\tid: userIdValidator,\n\t\tname: T.string,\n\t\tcolor: T.string,\n\t\timageUrl: T.string,\n\t\tmeta: T.jsonValue as T.ObjectValidator<JsonObject>,\n\t})\n)\n\n/** @public */\nexport const UserRecordType = createUserRecordType()\n\n/** @public */\nexport function isUserId(id: string): id is DrUserId {\n\treturn UserRecordType.isId(id)\n}\n\n/** @public */\nexport function createUserId(id: string): DrUserId {\n\treturn UserRecordType.createId(id)\n}\n","import { T } from '@ibodr/validate'\nimport { assetIdValidator } from '../assets/DrBaseAsset'\nimport { DrAssetId } from '../records/DrAsset'\nimport { createShapePropsMigrationIds, createShapePropsMigrationSequence } from '../records/DrShape'\nimport { RecordProps } from '../recordsWithProps'\nimport { DrBaseShape } from './DrBaseShape'\n\n/**\n * Properties for the bookmark shape, which displays website bookmarks as interactive cards.\n *\n * @public\n */\nexport interface DrBookmarkShapeProps {\n\t/** Width of the bookmark shape in pixels */\n\tw: number\n\t/** Height of the bookmark shape in pixels */\n\th: number\n\t/** Asset ID for the bookmark's preview image, or null if no image is available */\n\tassetId: DrAssetId | null\n\t/** The URL that this bookmark points to */\n\turl: string\n}\n\n/**\n * A bookmark shape represents a website link with optional preview content.\n * Bookmark shapes display as cards showing the page title, description, and preview image.\n *\n * @public\n * @example\n * ```ts\n * const bookmarkShape: DrBookmarkShape = {\n * id: createShapeId(),\n * typeName: 'shape',\n * type: 'bookmark',\n * x: 100,\n * y: 100,\n * rotation: 0,\n * index: 'a1',\n * parentId: 'page:page1',\n * isLocked: false,\n * opacity: 1,\n * props: {\n * w: 300,\n * h: 320,\n * assetId: 'asset:bookmark123',\n * url: 'https://www.example.com'\n * },\n * meta: {}\n * }\n * ```\n */\nexport type DrBookmarkShape = DrBaseShape<'bookmark', DrBookmarkShapeProps>\n\n/**\n * Validation schema for bookmark shape properties.\n *\n * @public\n * @example\n * ```ts\n * // Validates bookmark shape properties\n * const isValid = bookmarkShapeProps.url.isValid('https://example.com')\n * ```\n */\nexport const bookmarkShapeProps: RecordProps<DrBookmarkShape> = {\n\tw: T.nonZeroNumber,\n\th: T.nonZeroNumber,\n\tassetId: assetIdValidator.nullable(),\n\turl: T.linkUrl,\n}\n\nconst Versions = createShapePropsMigrationIds('bookmark', {\n\tNullAssetId: 1,\n\tMakeUrlsValid: 2,\n})\n\n/**\n * Version identifiers for bookmark shape migrations.\n *\n * @public\n */\nexport { Versions as bookmarkShapeVersions }\n\n/**\n * Migration sequence for bookmark shape properties across different schema versions.\n * Handles backwards compatibility when bookmark shape structure changes.\n *\n * @public\n */\nexport const bookmarkShapeMigrations = createShapePropsMigrationSequence({\n\tsequence: [\n\t\t{\n\t\t\tid: Versions.NullAssetId,\n\t\t\tup: (props) => {\n\t\t\t\tif (props.assetId === undefined) {\n\t\t\t\t\tprops.assetId = null\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.MakeUrlsValid,\n\t\t\tup: (props) => {\n\t\t\t\tif (!T.linkUrl.isValid(props.url)) {\n\t\t\t\t\tprops.url = ''\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (_props) => {\n\t\t\t\t// noop\n\t\t\t},\n\t\t},\n\t],\n})\n","import { assert } from '@ibodr/utils'\nimport { VecModel } from './geometry-types'\n\n// Each point = 3 Float16s = 6 bytes = 8 base64 chars (legacy format)\nconst _POINT_B64_LENGTH = 8\n\n// First point in delta encoding = 3 Float32s = 12 bytes = 16 base64 chars\nconst FIRST_POINT_B64_LENGTH = 16\n\n// O(1) lookup table for base64 decoding (maps char code -> 6-bit value)\nconst BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nconst B64_LOOKUP = new Uint8Array(128)\nfor (let i = 0; i < 64; i++) {\n\tB64_LOOKUP[BASE64_CHARS.charCodeAt(i)] = i\n}\n\n// Precomputed powers of 2 for Float16 exponents (exp - 15, so indices 0-30 map to 2^-15 to 2^15)\nconst POW2 = new Float64Array(31)\nfor (let i = 0; i < 31; i++) {\n\tPOW2[i] = Math.pow(2, i - 15)\n}\nconst POW2_SUBNORMAL = Math.pow(2, -14) / 1024 // For subnormal numbers\n\n// Precomputed mantissa values: 1 + frac/1024 for all 1024 possible frac values\n// Avoids division in hot path\nconst MANTISSA = new Float64Array(1024)\nfor (let i = 0; i < 1024; i++) {\n\tMANTISSA[i] = 1 + i / 1024\n}\n\ndeclare global {\n\tinterface Uint8Array {\n\t\ttoBase64?(): string\n\t}\n\tinterface Uint8ArrayConstructor {\n\t\tfromBase64?(base64: string): Uint8Array\n\t}\n}\n\nfunction nativeGetFloat16(dataView: DataView, offset: number): number {\n\treturn (dataView as any).getFloat16(offset, true)\n}\nfunction fallbackGetFloat16(dataView: DataView, offset: number): number {\n\treturn float16BitsToNumber(dataView.getUint16(offset, true))\n}\n\nconst getFloat16 =\n\ttypeof (DataView.prototype as any).getFloat16 === 'function'\n\t\t? nativeGetFloat16\n\t\t: fallbackGetFloat16\n\nfunction nativeSetFloat16(dataView: DataView, offset: number, value: number): void {\n\t;(dataView as any).setFloat16(offset, value, true)\n}\nfunction fallbackSetFloat16(dataView: DataView, offset: number, value: number): void {\n\tdataView.setUint16(offset, numberToFloat16Bits(value), true)\n}\n\nconst setFloat16 =\n\ttypeof (DataView.prototype as any).setFloat16 === 'function'\n\t\t? nativeSetFloat16\n\t\t: fallbackSetFloat16\n\nfunction nativeBase64ToUint8Array(base64: string): Uint8Array {\n\treturn Uint8Array.fromBase64!(base64)\n}\n\n/** @internal */\nexport function fallbackBase64ToUint8Array(base64: string): Uint8Array {\n\tconst numBytes = Math.floor((base64.length * 3) / 4)\n\tconst bytes = new Uint8Array(numBytes)\n\tlet byteIndex = 0\n\n\tfor (let i = 0; i < base64.length; i += 4) {\n\t\tconst c0 = B64_LOOKUP[base64.charCodeAt(i)]\n\t\tconst c1 = B64_LOOKUP[base64.charCodeAt(i + 1)]\n\t\tconst c2 = B64_LOOKUP[base64.charCodeAt(i + 2)]\n\t\tconst c3 = B64_LOOKUP[base64.charCodeAt(i + 3)]\n\n\t\tconst bitmap = (c0 << 18) | (c1 << 12) | (c2 << 6) | c3\n\n\t\tbytes[byteIndex++] = (bitmap >> 16) & 255\n\t\tbytes[byteIndex++] = (bitmap >> 8) & 255\n\t\tbytes[byteIndex++] = bitmap & 255\n\t}\n\n\treturn bytes\n}\n\nfunction nativeUint8ArrayToBase64(uint8Array: Uint8Array): string {\n\treturn uint8Array.toBase64!()\n}\n\n/** @internal */\nexport function fallbackUint8ArrayToBase64(uint8Array: Uint8Array): string {\n\tassert(uint8Array.length % 3 === 0, 'Uint8Array length must be a multiple of 3')\n\tlet result = ''\n\n\t// Process bytes in groups of 3 -> 4 base64 chars\n\tfor (let i = 0; i < uint8Array.length; i += 3) {\n\t\tconst byte1 = uint8Array[i]\n\t\tconst byte2 = uint8Array[i + 1]\n\t\tconst byte3 = uint8Array[i + 2]\n\n\t\tconst bitmap = (byte1 << 16) | (byte2 << 8) | byte3\n\t\tresult +=\n\t\t\tBASE64_CHARS[(bitmap >> 18) & 63] +\n\t\t\tBASE64_CHARS[(bitmap >> 12) & 63] +\n\t\t\tBASE64_CHARS[(bitmap >> 6) & 63] +\n\t\t\tBASE64_CHARS[bitmap & 63]\n\t}\n\n\treturn result\n}\n\n/**\n * Convert a Uint8Array to base64.\n * Processes bytes in groups of 3 to produce 4 base64 characters.\n *\n * @internal\n */\nconst uint8ArrayToBase64 =\n\ttypeof Uint8Array.prototype.toBase64 === 'function'\n\t\t? nativeUint8ArrayToBase64\n\t\t: fallbackUint8ArrayToBase64\n\n/**\n * Convert a base64 string to Uint8Array.\n *\n * @internal\n */\nconst base64ToUint8Array =\n\ttypeof Uint8Array.fromBase64 === 'function'\n\t\t? nativeBase64ToUint8Array\n\t\t: fallbackBase64ToUint8Array\n\n/**\n * Convert Float16 bits to a number using optimized lookup tables.\n * Handles normal numbers, subnormal numbers, zero, infinity, and NaN.\n *\n * @param bits - The 16-bit Float16 value to decode\n * @returns The decoded number value\n * @internal\n */\nexport function float16BitsToNumber(bits: number): number {\n\tconst sign = bits >> 15\n\tconst exp = (bits >> 10) & 0x1f\n\tconst frac = bits & 0x3ff\n\n\tif (exp === 0) {\n\t\t// Subnormal or zero - rare case\n\t\treturn sign ? -frac * POW2_SUBNORMAL : frac * POW2_SUBNORMAL\n\t}\n\tif (exp === 31) {\n\t\t// Infinity or NaN - very rare\n\t\treturn frac ? NaN : sign ? -Infinity : Infinity\n\t}\n\t// Normal case - two table lookups, one multiply, no division\n\tconst magnitude = POW2[exp] * MANTISSA[frac]\n\treturn sign ? -magnitude : magnitude\n}\n\n/**\n * Convert a number to Float16 bits.\n * Handles normal numbers, subnormal numbers, zero, infinity, and NaN.\n *\n * @param value - The number to encode as Float16\n * @returns The 16-bit Float16 representation of the number\n * @internal\n */\nexport function numberToFloat16Bits(value: number): number {\n\tif (value === 0) return Object.is(value, -0) ? 0x8000 : 0\n\tif (!Number.isFinite(value)) {\n\t\tif (Number.isNaN(value)) return 0x7e00\n\t\treturn value > 0 ? 0x7c00 : 0xfc00\n\t}\n\n\tconst sign = value < 0 ? 1 : 0\n\tvalue = Math.abs(value)\n\n\t// Find exponent and mantissa\n\tconst exp = Math.floor(Math.log2(value))\n\tlet expBiased = exp + 15\n\n\tif (expBiased >= 31) {\n\t\t// Overflow to infinity\n\t\treturn (sign << 15) | 0x7c00\n\t}\n\tif (expBiased <= 0) {\n\t\t// Subnormal or underflow\n\t\tconst frac = Math.round(value * Math.pow(2, 14) * 1024)\n\t\treturn (sign << 15) | (frac & 0x3ff)\n\t}\n\n\t// Normal number\n\tconst mantissa = value / Math.pow(2, exp) - 1\n\tlet frac = Math.round(mantissa * 1024)\n\n\t// Handle rounding overflow: if frac rounds to 1024, increment exponent\n\tif (frac >= 1024) {\n\t\tfrac = 0\n\t\texpBiased++\n\t\tif (expBiased >= 31) {\n\t\t\t// Overflow to infinity\n\t\t\treturn (sign << 15) | 0x7c00\n\t\t}\n\t}\n\n\treturn (sign << 15) | (expBiased << 10) | frac\n}\n\n/**\n * Utilities for encoding and decoding points using base64 and Float16 encoding.\n * Provides functions for converting between VecModel arrays and compact base64 strings,\n * as well as individual point encoding/decoding operations.\n *\n * @public\n */\nexport class b64Vecs {\n\t/**\n\t * Encode a single point (x, y, z) to 8 base64 characters using legacy Float16 encoding.\n\t * Each coordinate is encoded as a Float16 value, resulting in 6 bytes total.\n\t *\n\t * @param x - The x coordinate\n\t * @param y - The y coordinate\n\t * @param z - The z coordinate\n\t * @returns An 8-character base64 string representing the point\n\t * @internal\n\t */\n\tstatic _legacyEncodePoint(x: number, y: number, z: number): string {\n\t\tconst buffer = new Uint8Array(6)\n\t\tconst dataView = new DataView(buffer.buffer)\n\n\t\tsetFloat16(dataView, 0, x)\n\t\tsetFloat16(dataView, 2, y)\n\t\tsetFloat16(dataView, 4, z)\n\n\t\treturn uint8ArrayToBase64(buffer)\n\t}\n\n\t/**\n\t * Convert an array of VecModels to a base64 string using legacy Float16 encoding.\n\t * Uses Float16 encoding for each coordinate (x, y, z). If a point's z value is\n\t * undefined, it defaults to 0.5.\n\t *\n\t * @param points - An array of VecModel objects to encode\n\t * @returns A base64-encoded string containing all points\n\t * @internal Used only for migrations from legacy format\n\t */\n\tstatic _legacyEncodePoints(points: VecModel[]): string {\n\t\tif (points.length === 0) return ''\n\n\t\t// 3 Float16s per point = 6 bytes per point\n\t\tconst buffer = new Uint8Array(points.length * 6)\n\t\tconst dataView = new DataView(buffer.buffer)\n\n\t\tfor (let i = 0; i < points.length; i++) {\n\t\t\tconst p = points[i]\n\t\t\tconst offset = i * 6\n\t\t\tsetFloat16(dataView, offset, p.x)\n\t\t\tsetFloat16(dataView, offset + 2, p.y)\n\t\t\tsetFloat16(dataView, offset + 4, p.z ?? 0.5)\n\t\t}\n\n\t\treturn uint8ArrayToBase64(buffer)\n\t}\n\n\t/**\n\t * Convert a legacy base64 string back to an array of VecModels.\n\t * Decodes Float16-encoded coordinates (x, y, z) from the base64 string.\n\t *\n\t * @param base64 - The base64-encoded string containing point data\n\t * @returns An array of VecModel objects decoded from the string\n\t * @internal Used only for migrations from legacy format\n\t */\n\tstatic _legacyDecodePoints(base64: string): VecModel[] {\n\t\tconst bytes = base64ToUint8Array(base64)\n\t\tconst dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)\n\t\tconst result: VecModel[] = []\n\t\tfor (let offset = 0; offset < bytes.length; offset += 6) {\n\t\t\tresult.push({\n\t\t\t\tx: getFloat16(dataView, offset),\n\t\t\t\ty: getFloat16(dataView, offset + 2),\n\t\t\t\tz: getFloat16(dataView, offset + 4),\n\t\t\t})\n\t\t}\n\t\treturn result\n\t}\n\n\t/**\n\t * Encode an array of VecModels using delta encoding for improved precision.\n\t * The first point is stored as Float32 (high precision for absolute position),\n\t * subsequent points are stored as Float16 deltas from the previous point.\n\t * This provides full precision for the starting position and excellent precision\n\t * for deltas between consecutive points (which are typically small values).\n\t *\n\t * Format:\n\t * - First point: 3 Float32 values = 12 bytes = 16 base64 chars\n\t * - Delta points: 3 Float16 values each = 6 bytes = 8 base64 chars each\n\t *\n\t * @param points - An array of VecModel objects to encode\n\t * @returns A base64-encoded string containing delta-encoded points\n\t * @public\n\t */\n\tstatic encodePoints(points: VecModel[]): string {\n\t\tif (points.length === 0) return ''\n\n\t\t// First point: 3 Float32s = 12 bytes\n\t\t// Remaining points: 3 Float16s each = 6 bytes each\n\t\tconst firstPointBytes = 12\n\t\tconst deltaBytes = (points.length - 1) * 6\n\t\tconst totalBytes = firstPointBytes + deltaBytes\n\n\t\tconst buffer = new Uint8Array(totalBytes)\n\t\tconst dataView = new DataView(buffer.buffer)\n\n\t\t// First point is stored as Float32 for full precision\n\t\tconst first = points[0]\n\t\tdataView.setFloat32(0, first.x, true) // little-endian\n\t\tdataView.setFloat32(4, first.y, true)\n\t\tdataView.setFloat32(8, first.z ?? 0.5, true)\n\n\t\t// Subsequent points are Float16 deltas from the previous point\n\t\tlet prevX = first.x\n\t\tlet prevY = first.y\n\t\tlet prevZ = first.z ?? 0.5\n\n\t\tfor (let i = 1; i < points.length; i++) {\n\t\t\tconst p = points[i]\n\t\t\tconst z = p.z ?? 0.5\n\n\t\t\tconst offset = firstPointBytes + (i - 1) * 6\n\t\t\tsetFloat16(dataView, offset, p.x - prevX)\n\t\t\tsetFloat16(dataView, offset + 2, p.y - prevY)\n\t\t\tsetFloat16(dataView, offset + 4, z - prevZ)\n\n\t\t\tprevX = p.x\n\t\t\tprevY = p.y\n\t\t\tprevZ = z\n\t\t}\n\n\t\treturn uint8ArrayToBase64(buffer)\n\t}\n\n\t/**\n\t * Decode a delta-encoded base64 string back to an array of absolute VecModels.\n\t * The first point is stored as Float32 (high precision), subsequent points are\n\t * Float16 deltas that are accumulated to reconstruct absolute positions.\n\t *\n\t * @param base64 - The base64-encoded string containing delta-encoded point data\n\t * @returns An array of VecModel objects with absolute coordinates\n\t * @public\n\t */\n\tstatic decodePoints(base64: string): VecModel[] {\n\t\tif (base64.length === 0) return []\n\n\t\tconst bytes = base64ToUint8Array(base64)\n\t\tconst dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)\n\t\tconst result: VecModel[] = []\n\n\t\t// First point is Float32 (12 bytes)\n\t\tlet x = dataView.getFloat32(0, true)\n\t\tlet y = dataView.getFloat32(4, true)\n\t\tlet z = dataView.getFloat32(8, true)\n\t\tresult.push({ x, y, z })\n\n\t\t// Subsequent points are Float16 deltas - accumulate to get absolute positions\n\t\tconst firstPointBytes = 12\n\t\tfor (let offset = firstPointBytes; offset < bytes.length; offset += 6) {\n\t\t\tx += getFloat16(dataView, offset)\n\t\t\ty += getFloat16(dataView, offset + 2)\n\t\t\tz += getFloat16(dataView, offset + 4)\n\t\t\tresult.push({ x, y, z })\n\t\t}\n\n\t\treturn result\n\t}\n\n\t/**\n\t * Get the first point from a delta-encoded base64 string.\n\t * The first point is stored as Float32 for full precision.\n\t *\n\t * @param b64Points - The delta-encoded base64 string\n\t * @returns The first point as a VecModel, or null if the string is too short\n\t * @public\n\t */\n\tstatic decodeFirstPoint(b64Points: string): VecModel | null {\n\t\t// First point needs 16 base64 chars (12 bytes as Float32)\n\t\tif (b64Points.length < FIRST_POINT_B64_LENGTH) return null\n\n\t\tconst bytes = base64ToUint8Array(b64Points.slice(0, FIRST_POINT_B64_LENGTH))\n\t\tconst dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)\n\n\t\treturn {\n\t\t\tx: dataView.getFloat32(0, true),\n\t\t\ty: dataView.getFloat32(4, true),\n\t\t\tz: dataView.getFloat32(8, true),\n\t\t}\n\t}\n\n\t/**\n\t * Get the last point from a delta-encoded base64 string.\n\t * Requires decoding all points to accumulate deltas.\n\t *\n\t * @param b64Points - The delta-encoded base64 string\n\t * @returns The last point as a VecModel, or null if the string is too short\n\t * @public\n\t */\n\tstatic decodeLastPoint(b64Points: string): VecModel | null {\n\t\tif (b64Points.length < FIRST_POINT_B64_LENGTH) return null\n\n\t\tconst bytes = base64ToUint8Array(b64Points)\n\t\tconst dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)\n\n\t\t// Start with first point (Float32)\n\t\tlet x = dataView.getFloat32(0, true)\n\t\tlet y = dataView.getFloat32(4, true)\n\t\tlet z = dataView.getFloat32(8, true)\n\n\t\t// Accumulate all Float16 deltas to get the last point\n\t\tconst firstPointBytes = 12\n\t\tfor (let offset = firstPointBytes; offset < bytes.length; offset += 6) {\n\t\t\tx += getFloat16(dataView, offset)\n\t\t\ty += getFloat16(dataView, offset + 2)\n\t\t\tz += getFloat16(dataView, offset + 4)\n\t\t}\n\n\t\treturn { x, y, z }\n\t}\n}\n","import { T } from '@ibodr/validate'\nimport { b64Vecs } from '../misc/b64Vecs'\nimport { VecModel } from '../misc/geometry-types'\nimport { createShapePropsMigrationIds, createShapePropsMigrationSequence } from '../records/DrShape'\nimport { RecordProps } from '../recordsWithProps'\nimport { DefaultColorStyle, DrDefaultColorStyle } from '../styles/DrColorStyle'\nimport { DefaultDashStyle, DrDefaultDashStyle } from '../styles/DrDashStyle'\nimport { DefaultFillStyle, DrDefaultFillStyle } from '../styles/DrFillStyle'\nimport { DefaultSizeStyle, DrDefaultSizeStyle } from '../styles/DrSizeStyle'\nimport { DrBaseShape } from './DrBaseShape'\n\n/**\n * A segment of a draw shape representing either freehand drawing or straight line segments.\n *\n * @public\n */\nexport interface DrDrawShapeSegment {\n\t/** Type of drawing segment - 'free' for freehand curves, 'straight' for line segments */\n\ttype: 'free' | 'straight'\n\t/**\n\t * Delta-encoded base64 path data.\n\t * First point stored as Float32 (12 bytes) for precision, subsequent points as Float16 deltas (6 bytes each).\n\t */\n\tpath: string\n}\n\n/**\n * Validator for draw shape segments ensuring proper structure and data types.\n *\n * @public\n */\nexport const DrawShapeSegment: T.ObjectValidator<DrDrawShapeSegment> = T.object({\n\ttype: T.literalEnum('free', 'straight'),\n\tpath: T.string,\n})\n\n/**\n * Properties for the draw shape, which represents freehand drawing and sketching.\n *\n * @public\n */\nexport interface DrDrawShapeProps {\n\t/** Color style for the drawing stroke */\n\tcolor: DrDefaultColorStyle\n\t/** Fill style for closed drawing shapes */\n\tfill: DrDefaultFillStyle\n\t/** Dash pattern style for the stroke */\n\tdash: DrDefaultDashStyle\n\t/** Size/thickness of the drawing stroke */\n\tsize: DrDefaultSizeStyle\n\t/** Array of segments that make up the complete drawing path */\n\tsegments: DrDrawShapeSegment[]\n\t/** Whether the drawing is complete (user finished drawing) */\n\tisComplete: boolean\n\t/** Whether the drawing path forms a closed shape */\n\tisClosed: boolean\n\t/** Whether this drawing was created with a pen/stylus device */\n\tisPen: boolean\n\t/** Scale factor applied to the drawing */\n\tscale: number\n\t/** Horizontal scale factor for lazy resize */\n\tscaleX: number\n\t/** Vertical scale factor for lazy resize */\n\tscaleY: number\n}\n\n/**\n * A draw shape represents freehand drawing, sketching, and pen input on the canvas.\n * Draw shapes are composed of segments that can be either smooth curves or straight lines.\n *\n * @public\n * @example\n * ```ts\n * const drawShape: DrDrawShape = {\n * id: createShapeId(),\n * typeName: 'shape',\n * type: 'draw',\n * x: 50,\n * y: 50,\n * rotation: 0,\n * index: 'a1',\n * parentId: 'page:page1',\n * isLocked: false,\n * opacity: 1,\n * props: {\n * color: 'black',\n * fill: 'none',\n * dash: 'solid',\n * size: 'm',\n * segments: [{\n * type: 'free',\n * points: [{ x: 0, y: 0, z: 0.5 }, { x: 20, y: 15, z: 0.6 }]\n * }],\n * isComplete: true,\n * isClosed: false,\n * isPen: false,\n * scale: 1\n * },\n * meta: {}\n * }\n * ```\n */\nexport type DrDrawShape = DrBaseShape<'draw', DrDrawShapeProps>\n\n/**\n * Validation schema for draw shape properties.\n *\n * @public\n * @example\n * ```ts\n * // Validate draw shape properties\n * const props = {\n * color: 'red',\n * fill: 'solid',\n * segments: [{ type: 'free', points: [] }],\n * isComplete: true\n * }\n * const isValid = drawShapeProps.color.isValid(props.color)\n * ```\n */\n/** @public */\nexport const drawShapeProps: RecordProps<DrDrawShape> = {\n\tcolor: DefaultColorStyle,\n\tfill: DefaultFillStyle,\n\tdash: DefaultDashStyle,\n\tsize: DefaultSizeStyle,\n\tsegments: T.arrayOf(DrawShapeSegment),\n\tisComplete: T.boolean,\n\tisClosed: T.boolean,\n\tisPen: T.boolean,\n\tscale: T.nonZeroNumber,\n\tscaleX: T.nonZeroFiniteNumber,\n\tscaleY: T.nonZeroFiniteNumber,\n}\n\nconst Versions = createShapePropsMigrationIds('draw', {\n\tAddInPen: 1,\n\tAddScale: 2,\n\tBase64: 3,\n\tLegacyPointsConversion: 4,\n})\n\n/**\n * Version identifiers for draw shape migrations.\n *\n * @public\n */\nexport { Versions as drawShapeVersions }\n\n/**\n * Migration sequence for draw shape properties across different schema versions.\n * Handles adding pen detection and scale properties to existing draw shapes.\n *\n * @public\n */\nexport const drawShapeMigrations = createShapePropsMigrationSequence({\n\tsequence: [\n\t\t{\n\t\t\tid: Versions.AddInPen,\n\t\t\tup: (props) => {\n\t\t\t\t// Rather than checking to see whether the shape is a pen at runtime,\n\t\t\t\t// from now on we're going to use the type of device reported to us\n\t\t\t\t// as well as the pressure data received; but for existing shapes we\n\t\t\t\t// need to check the pressure data to see if it's a pen or not.\n\n\t\t\t\tconst { points } = props.segments[0]\n\n\t\t\t\tif (points.length === 0) {\n\t\t\t\t\tprops.isPen = false\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tlet isPen = !(points[0].z === 0 || points[0].z === 0.5)\n\n\t\t\t\tif (points[1]) {\n\t\t\t\t\t// Double check if we have a second point (we probably should)\n\t\t\t\t\tisPen = isPen && !(points[1].z === 0 || points[1].z === 0.5)\n\t\t\t\t}\n\t\t\t\tprops.isPen = isPen\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddScale,\n\t\t\tup: (props) => {\n\t\t\t\tprops.scale = 1\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.scale\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.Base64,\n\t\t\tup: (props) => {\n\t\t\t\t// Convert VecModel[] arrays directly to delta-encoded base64 in 'path'\n\t\t\t\tprops.segments = props.segments.map((segment: any) => {\n\t\t\t\t\tif (segment.path !== undefined) return segment\n\t\t\t\t\tconst { points, ...rest } = segment\n\t\t\t\t\tconst vecModels = Array.isArray(points) ? points : b64Vecs._legacyDecodePoints(points)\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...rest,\n\t\t\t\t\t\tpath: b64Vecs.encodePoints(vecModels),\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\tprops.scaleX = props.scaleX ?? 1\n\t\t\t\tprops.scaleY = props.scaleY ?? 1\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\t// Convert delta-encoded 'path' back to VecModel[] arrays in 'points'\n\t\t\t\tprops.segments = props.segments.map((segment: any) => {\n\t\t\t\t\tconst { path, ...rest } = segment\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...rest,\n\t\t\t\t\t\tpoints: b64Vecs.decodePoints(path),\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\tdelete props.scaleX\n\t\t\t\tdelete props.scaleY\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.LegacyPointsConversion,\n\t\t\tup: (props) => {\n\t\t\t\t// Handle legacy data that was already migrated to v3 with absolute Float16 in 'points'\n\t\t\t\t// Convert 'points' to delta-encoded 'path'\n\t\t\t\tprops.segments = props.segments.map((segment: any) => {\n\t\t\t\t\t// If segment already has 'path', it's already in the new format\n\t\t\t\t\tif (segment.path !== undefined) return segment\n\n\t\t\t\t\tconst { points, ...rest } = segment\n\t\t\t\t\tconst vecModels = Array.isArray(points) ? points : b64Vecs._legacyDecodePoints(points)\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...rest,\n\t\t\t\t\t\tpath: b64Vecs.encodePoints(vecModels),\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t},\n\t\t\tdown: (_props) => {\n\t\t\t\t// handled by the previous down migration\n\t\t\t},\n\t\t},\n\t],\n})\n\n/**\n * Compress legacy draw shape segments by converting VecModel[] points to delta-encoded base64 format.\n * This function is useful for converting old draw shape data to the new compressed format.\n * Uses delta encoding for improved Float16 precision.\n *\n * @public\n */\nexport function compressLegacySegments(\n\tsegments: {\n\t\ttype: 'free' | 'straight'\n\t\tpoints: VecModel[]\n\t}[]\n): DrDrawShapeSegment[] {\n\treturn segments.map((segment) => ({\n\t\ttype: segment.type,\n\t\tpath: b64Vecs.encodePoints(segment.points),\n\t}))\n}\n","import { safeParseUrl } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { createShapePropsMigrationIds, createShapePropsMigrationSequence } from '../records/DrShape'\nimport { RecordProps } from '../recordsWithProps'\nimport { DrBaseShape } from './DrBaseShape'\n\n// Only allow multiplayer embeds. If we add additional routes later for example '/help' this won't match\nconst DRAW_APP_RE = /(^\\/r\\/[^/]+\\/?$)/\n\nconst EMBED_DEFINITIONS = [\n\t{\n\t\thostnames: ['beta.draw.com', 'tldraw.com', 'localhost:3000'],\n\t\tcanEditWhileLocked: true,\n\t\tfromEmbedUrl: (url: string) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(DRAW_APP_RE)) {\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\thostnames: ['figma.com'],\n\t\tcanEditWhileLocked: true,\n\t\tfromEmbedUrl: (url: string) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/?$/)) {\n\t\t\t\tconst outUrl = urlObj.searchParams.get('url')\n\t\t\t\tif (outUrl) {\n\t\t\t\t\treturn outUrl\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\thostnames: ['google.*'],\n\t\tcanEditWhileLocked: true,\n\t\tfromEmbedUrl: (url: string) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst matches = urlObj.pathname.match(/^\\/maps\\/embed\\/v1\\/view\\/?$/)\n\t\t\tif (matches && urlObj.searchParams.has('center') && urlObj.searchParams.get('zoom')) {\n\t\t\t\tconst zoom = urlObj.searchParams.get('zoom')\n\t\t\t\tconst [lat, lon] = urlObj.searchParams.get('center')!.split(',')\n\t\t\t\treturn `https://www.google.com/maps/@${lat},${lon},${zoom}z`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\thostnames: ['val.town'],\n\t\tcanEditWhileLocked: true,\n\t\tfromEmbedUrl: (url: string) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\t// e.g. extract \"steveruizok/mathFact\" from https://www.val.town/v/steveruizok/mathFact\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/embed\\/(.+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://www.val.town/v/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\thostnames: ['codesandbox.io'],\n\t\tcanEditWhileLocked: true,\n\t\tfromEmbedUrl: (url: string) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/embed\\/([^/]+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://codesandbox.io/s/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\thostnames: ['codepen.io'],\n\t\tcanEditWhileLocked: true,\n\t\tfromEmbedUrl: (url: string) => {\n\t\t\tconst CODEPEN_EMBED_REGEXP = /https:\\/\\/codepen.io\\/([^/]+)\\/embed\\/([^/]+)/\n\t\t\tconst matches = url.match(CODEPEN_EMBED_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, user, id] = matches\n\t\t\t\treturn `https://codepen.io/${user}/pen/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\thostnames: ['scratch.mit.edu'],\n\t\tcanEditWhileLocked: true,\n\t\tfromEmbedUrl: (url: string) => {\n\t\t\tconst SCRATCH_EMBED_REGEXP = /https:\\/\\/scratch.mit.edu\\/projects\\/embed\\/([^/]+)/\n\t\t\tconst matches = url.match(SCRATCH_EMBED_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, id] = matches\n\t\t\t\treturn `https://scratch.mit.edu/projects/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\thostnames: ['*.youtube.com', 'youtube.com', 'youtu.be'],\n\t\tcanEditWhileLocked: true,\n\t\tfromEmbedUrl: (url: string) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst hostname = urlObj.hostname.replace(/^www./, '')\n\t\t\tif (hostname === 'youtube.com') {\n\t\t\t\tconst matches = urlObj.pathname.match(/^\\/embed\\/([^/]+)\\/?/)\n\t\t\t\tif (matches) {\n\t\t\t\t\treturn `https://www.youtube.com/watch?v=${matches[1]}`\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\thostnames: ['calendar.google.*'],\n\t\tcanEditWhileLocked: true,\n\t\tfromEmbedUrl: (url: string) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst srcQs = urlObj?.searchParams.get('src')\n\n\t\t\tif (urlObj?.pathname.match(/\\/calendar\\/embed/) && srcQs) {\n\t\t\t\turlObj.pathname = '/calendar/u/0'\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\turlObj.searchParams.set('cid', srcQs)\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\thostnames: ['docs.google.*'],\n\t\tcanEditWhileLocked: true,\n\t\tfromEmbedUrl: (url: string) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\n\t\t\tif (urlObj?.pathname.match(/^\\/presentation/) && urlObj?.pathname.match(/\\/embed\\/?$/)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/\\/embed$/, '/pub')\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\thostnames: ['gist.github.com'],\n\t\tcanEditWhileLocked: true,\n\t\tfromEmbedUrl: (url: string) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/([^/]+)\\/([^/]+)/)) {\n\t\t\t\tif (!url.split('/').pop()) return\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\thostnames: ['replit.com'],\n\t\tcanEditWhileLocked: true,\n\t\tfromEmbedUrl: (url: string) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.pathname.match(/\\/@([^/]+)\\/([^/]+)/) &&\n\t\t\t\turlObj.searchParams.has('embed')\n\t\t\t) {\n\t\t\t\turlObj.searchParams.delete('embed')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\thostnames: ['felt.com'],\n\t\tcanEditWhileLocked: true,\n\t\tfromEmbedUrl: (url: string) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/map\\//)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/^\\/embed/, '')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\thostnames: ['open.spotify.com'],\n\t\tcanEditWhileLocked: true,\n\t\tfromEmbedUrl: (url: string) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/(artist|album)\\//)) {\n\t\t\t\treturn urlObj.origin + urlObj.pathname.replace(/^\\/embed/, '')\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\thostnames: ['vimeo.com', 'player.vimeo.com'],\n\t\tcanEditWhileLocked: true,\n\t\tfromEmbedUrl: (url: string) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.hostname === 'player.vimeo.com') {\n\t\t\t\tconst matches = urlObj.pathname.match(/^\\/video\\/([^/]+)\\/?$/)\n\t\t\t\tif (matches) {\n\t\t\t\t\treturn 'https://vimeo.com/' + matches[1]\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\thostnames: ['observablehq.com'],\n\t\tcanEditWhileLocked: true,\n\t\tfromEmbedUrl: (url: string) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/@([^/]+)\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}${urlObj.pathname.replace('/embed', '')}#cell-*`\n\t\t\t}\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}${urlObj.pathname.replace('/embed', '/d')}#cell-*`\n\t\t\t}\n\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\thostnames: ['desmos.com'],\n\t\tcanEditWhileLocked: true,\n\t\tfromEmbedUrl: (url: string) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.hostname === 'www.desmos.com' &&\n\t\t\t\turlObj.pathname.match(/^\\/calculator\\/([^/]+)\\/?$/) &&\n\t\t\t\turlObj.search === '?embed' &&\n\t\t\t\turlObj.hash === ''\n\t\t\t) {\n\t\t\t\treturn url.replace('?embed', '')\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n]\n\n/**\n * Properties for the embed shape, which displays embedded content from external services.\n *\n * @public\n */\nexport interface DrEmbedShapeProps {\n\t/** Width of the embed shape in pixels */\n\tw: number\n\t/** Height of the embed shape in pixels */\n\th: number\n\t/** URL of the content to embed (supports YouTube, Figma, CodePen, etc.) */\n\turl: string\n}\n\n/**\n * An embed shape displays external content like YouTube videos, Figma designs, CodePen demos,\n * and other embeddable content within the tldraw canvas.\n *\n * @public\n * @example\n * ```ts\n * const embedShape: DrEmbedShape = {\n * id: createShapeId(),\n * typeName: 'shape',\n * type: 'embed',\n * x: 200,\n * y: 200,\n * rotation: 0,\n * index: 'a1',\n * parentId: 'page:page1',\n * isLocked: false,\n * opacity: 1,\n * props: {\n * w: 560,\n * h: 315,\n * url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'\n * },\n * meta: {}\n * }\n * ```\n */\nexport type DrEmbedShape = DrBaseShape<'embed', DrEmbedShapeProps>\n\n/**\n * Validation schema for embed shape properties.\n *\n * @public\n * @example\n * ```ts\n * // Validate embed shape properties\n * const isValidUrl = embedShapeProps.url.isValid('https://youtube.com/watch?v=abc123')\n * const isValidSize = embedShapeProps.w.isValid(560)\n * ```\n */\nexport const embedShapeProps: RecordProps<DrEmbedShape> = {\n\tw: T.nonZeroNumber,\n\th: T.nonZeroNumber,\n\turl: T.string,\n}\n\nconst Versions = createShapePropsMigrationIds('embed', {\n\tGenOriginalUrlInEmbed: 1,\n\tRemoveDoesResize: 2,\n\tRemoveTmpOldUrl: 3,\n\tRemovePermissionOverrides: 4,\n})\n\n/**\n * Version identifiers for embed shape migrations.\n *\n * @public\n */\nexport { Versions as embedShapeVersions }\n\n/**\n * Migration sequence for embed shape properties across different schema versions.\n * Handles URL transformations and removal of deprecated properties.\n *\n * @public\n */\nexport const embedShapeMigrations = createShapePropsMigrationSequence({\n\tsequence: [\n\t\t{\n\t\t\tid: Versions.GenOriginalUrlInEmbed,\n\t\t\t// add tmpOldUrl property\n\t\t\tup: (props) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst url = props.url\n\t\t\t\t\tconst host = new URL(url).host.replace('www.', '')\n\t\t\t\t\tlet originalUrl\n\t\t\t\t\tfor (const localEmbedDef of EMBED_DEFINITIONS) {\n\t\t\t\t\t\tif (localEmbedDef.hostnames.includes(host)) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\toriginalUrl = localEmbedDef.fromEmbedUrl(url)\n\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\tconsole.warn(err)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tprops.tmpOldUrl = props.url\n\t\t\t\t\tprops.url = originalUrl ?? ''\n\t\t\t\t} catch {\n\t\t\t\t\tprops.url = ''\n\t\t\t\t\tprops.tmpOldUrl = props.url\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.RemoveDoesResize,\n\t\t\tup: (props) => {\n\t\t\t\tdelete props.doesResize\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.RemoveTmpOldUrl,\n\t\t\tup: (props) => {\n\t\t\t\tdelete props.tmpOldUrl\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.RemovePermissionOverrides,\n\t\t\tup: (props) => {\n\t\t\t\tdelete props.overridePermissions\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t],\n})\n","import { T } from '@ibodr/validate'\nimport { createShapePropsMigrationIds, createShapePropsMigrationSequence } from '../records/DrShape'\nimport { RecordProps } from '../recordsWithProps'\nimport { DefaultColorStyle, DrDefaultColorStyle } from '../styles/DrColorStyle'\nimport { DrBaseShape } from './DrBaseShape'\n\n/**\n * Properties for the frame shape, which provides a container for organizing other shapes.\n *\n * @public\n */\nexport interface DrFrameShapeProps {\n\t/** Width of the frame in pixels */\n\tw: number\n\t/** Height of the frame in pixels */\n\th: number\n\t/** Display name for the frame (shown in UI) */\n\tname: string\n\t/** Color style for the frame border and label */\n\tcolor: DrDefaultColorStyle\n}\n\n/**\n * A frame shape provides a container for organizing and grouping other shapes.\n * Frames can be used to create sections, organize content, or define specific areas.\n *\n * @public\n * @example\n * ```ts\n * const frameShape: DrFrameShape = {\n * id: createShapeId(),\n * typeName: 'shape',\n * type: 'frame',\n * x: 0,\n * y: 0,\n * rotation: 0,\n * index: 'a1',\n * parentId: 'page:page1',\n * isLocked: false,\n * opacity: 1,\n * props: {\n * w: 400,\n * h: 300,\n * name: 'Header Section',\n * color: 'blue'\n * },\n * meta: {}\n * }\n * ```\n */\nexport type DrFrameShape = DrBaseShape<'frame', DrFrameShapeProps>\n\n/**\n * Validation schema for frame shape properties.\n *\n * @public\n * @example\n * ```ts\n * // Validate frame properties\n * const isValidName = frameShapeProps.name.isValid('My Frame')\n * const isValidColor = frameShapeProps.color.isValid('red')\n * ```\n */\nexport const frameShapeProps: RecordProps<DrFrameShape> = {\n\tw: T.nonZeroNumber,\n\th: T.nonZeroNumber,\n\tname: T.string,\n\t// because shape colors are an option, we don't want them to be picked up by the editor as a\n\t// style prop by default, so instead of a proper style we just supply an equivalent validator.\n\t// Check `FrameShapeUtil.configure` for how we replace this with the original\n\t// `DefaultColorStyle` style when the option is turned on.\n\t// We delegate to DefaultColorStyle.validate so custom colors from themes are\n\t// picked up automatically.\n\tcolor: { validate: (v: unknown) => DefaultColorStyle.validate(v) as DrDefaultColorStyle },\n}\n\nconst Versions = createShapePropsMigrationIds('frame', {\n\tAddColorProp: 1,\n})\n\n/**\n * Version identifiers for frame shape migrations.\n *\n * @public\n */\nexport { Versions as frameShapeVersions }\n\n/**\n * Migration sequence for frame shape properties across different schema versions.\n * Handles adding color properties to existing frame shapes.\n *\n * @public\n */\nexport const frameShapeMigrations = createShapePropsMigrationSequence({\n\tsequence: [\n\t\t{\n\t\t\tid: Versions.AddColorProp,\n\t\t\tup: (props) => {\n\t\t\t\tprops.color = 'black'\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.color\n\t\t\t},\n\t\t},\n\t],\n})\n","import { T } from '@ibodr/validate'\nimport { StyleProp } from './StyleProp'\n\n/**\n * Default horizontal alignment style property used by tldraw shapes for text positioning.\n * Controls how text content is horizontally aligned within shape boundaries.\n *\n * Available values:\n * - `start` - Align text to the start (left in LTR, right in RTL)\n * - `middle` - Center text horizontally\n * - `end` - Align text to the end (right in LTR, left in RTL)\n * - `start-legacy` - Legacy start alignment (deprecated)\n * - `end-legacy` - Legacy end alignment (deprecated)\n * - `middle-legacy` - Legacy middle alignment (deprecated)\n *\n * @example\n * ```ts\n * import { DefaultHorizontalAlignStyle } from '@ibodr/schema'\n *\n * // Use in shape props definition\n * interface MyTextShapeProps {\n * align: typeof DefaultHorizontalAlignStyle\n * // other props...\n * }\n *\n * // Create a shape with center-aligned text\n * const textShape = {\n * // ... other properties\n * props: {\n * align: 'middle' as const,\n * // ... other props\n * }\n * }\n * ```\n *\n * @public\n */\nexport const DefaultHorizontalAlignStyle = StyleProp.defineEnum('draw:horizontalAlign', {\n\tdefaultValue: 'middle',\n\tvalues: ['start', 'middle', 'end', 'start-legacy', 'end-legacy', 'middle-legacy'],\n})\n\n/**\n * Type representing a default horizontal alignment style value.\n * This is a union type of all available horizontal alignment options.\n *\n * @example\n * ```ts\n * import { DrDefaultHorizontalAlignStyle } from '@ibodr/schema'\n *\n * // Valid horizontal alignment values\n * const leftAlign: DrDefaultHorizontalAlignStyle = 'start'\n * const centerAlign: DrDefaultHorizontalAlignStyle = 'middle'\n * const rightAlign: DrDefaultHorizontalAlignStyle = 'end'\n *\n * // Use in a function parameter\n * function setTextAlignment(align: DrDefaultHorizontalAlignStyle) {\n * // Apply horizontal alignment to text\n * }\n * ```\n *\n * @public\n */\nexport type DrDefaultHorizontalAlignStyle = T.TypeOf<typeof DefaultHorizontalAlignStyle>\n","import { T } from '@ibodr/validate'\nimport { StyleProp } from './StyleProp'\n\n/**\n * Default vertical alignment style property used by tldraw shapes for text positioning.\n * Controls how text content is vertically aligned within shape boundaries.\n *\n * Available values:\n * - `start` - Align text to the top\n * - `middle` - Center text vertically (default)\n * - `end` - Align text to the bottom\n *\n * @example\n * ```ts\n * import { DefaultVerticalAlignStyle } from '@ibodr/schema'\n *\n * // Use in shape props definition\n * interface MyShapeProps {\n * verticalAlign: typeof DefaultVerticalAlignStyle\n * // other props...\n * }\n *\n * // Create a shape with top-aligned text\n * const shape = {\n * // ... other properties\n * props: {\n * verticalAlign: 'start' as const,\n * // ... other props\n * }\n * }\n * ```\n *\n * @public\n */\nexport const DefaultVerticalAlignStyle = StyleProp.defineEnum('draw:verticalAlign', {\n\tdefaultValue: 'middle',\n\tvalues: ['start', 'middle', 'end'],\n})\n\n/**\n * Type representing a default vertical alignment style value.\n * This is a union type of all available vertical alignment options.\n *\n * @example\n * ```ts\n * import { DrDefaultVerticalAlignStyle } from '@ibodr/schema'\n *\n * // Valid vertical alignment values\n * const topAlign: DrDefaultVerticalAlignStyle = 'start'\n * const centerAlign: DrDefaultVerticalAlignStyle = 'middle'\n * const bottomAlign: DrDefaultVerticalAlignStyle = 'end'\n *\n * // Use in a function parameter\n * function setVerticalAlignment(align: DrDefaultVerticalAlignStyle) {\n * // Apply vertical alignment to text\n * }\n * ```\n *\n * @public\n */\nexport type DrDefaultVerticalAlignStyle = T.TypeOf<typeof DefaultVerticalAlignStyle>\n","import { T } from '@ibodr/validate'\nimport { DrRichText, richTextValidator, toRichText } from '../misc/DrRichText'\nimport { createShapePropsMigrationIds, createShapePropsMigrationSequence } from '../records/DrShape'\nimport { RecordProps } from '../recordsWithProps'\nimport { StyleProp } from '../styles/StyleProp'\nimport {\n\tDefaultColorStyle,\n\tDefaultLabelColorStyle,\n\tDrDefaultColorStyle,\n} from '../styles/DrColorStyle'\nimport { DefaultDashStyle, DrDefaultDashStyle } from '../styles/DrDashStyle'\nimport { DefaultFillStyle, DrDefaultFillStyle } from '../styles/DrFillStyle'\nimport { DefaultFontStyle, DrDefaultFontStyle } from '../styles/DrFontStyle'\nimport {\n\tDefaultHorizontalAlignStyle,\n\tDrDefaultHorizontalAlignStyle,\n} from '../styles/DrHorizontalAlignStyle'\nimport { DefaultSizeStyle, DrDefaultSizeStyle } from '../styles/DrSizeStyle'\nimport {\n\tDefaultVerticalAlignStyle,\n\tDrDefaultVerticalAlignStyle,\n} from '../styles/DrVerticalAlignStyle'\nimport { DrBaseShape } from './DrBaseShape'\n\n/**\n * Style property defining the geometric shape type for geo shapes.\n * Provides a variety of built-in geometric forms including basic shapes,\n * polygons, arrows, and special shapes.\n *\n * @public\n * @example\n * ```ts\n * // Use in shape props\n * const props = {\n * geo: 'rectangle', // or 'ellipse', 'triangle', etc.\n * // other properties...\n * }\n * ```\n */\nexport const GeoShapeGeoStyle = StyleProp.defineEnum('draw:geo', {\n\tdefaultValue: 'rectangle',\n\tvalues: [\n\t\t'cloud',\n\t\t'rectangle',\n\t\t'ellipse',\n\t\t'triangle',\n\t\t'diamond',\n\t\t'pentagon',\n\t\t'hexagon',\n\t\t'octagon',\n\t\t'star',\n\t\t'rhombus',\n\t\t'rhombus-2',\n\t\t'oval',\n\t\t'trapezoid',\n\t\t'arrow-right',\n\t\t'arrow-left',\n\t\t'arrow-up',\n\t\t'arrow-down',\n\t\t'x-box',\n\t\t'check-box',\n\t\t'heart',\n\t],\n})\n\n/**\n * Type representing valid geometric shape styles for geo shapes.\n *\n * @public\n */\nexport type DrGeoShapeGeoStyle = T.TypeOf<typeof GeoShapeGeoStyle>\n\n/**\n * Properties for the geo shape, which renders various geometric forms with styling and text.\n *\n * @public\n */\nexport interface DrGeoShapeProps {\n\t/** Geometric shape type (rectangle, ellipse, triangle, etc.) */\n\tgeo: DrGeoShapeGeoStyle\n\t/** Dash pattern style for the shape outline */\n\tdash: DrDefaultDashStyle\n\t/** URL link associated with the shape */\n\turl: string\n\t/** Width of the shape in pixels */\n\tw: number\n\t/** Height of the shape in pixels */\n\th: number\n\t/** Additional vertical growth for text content */\n\tgrowY: number\n\t/** Scale factor applied to the shape */\n\tscale: number\n\n\t/** Color style for text label */\n\tlabelColor: DrDefaultColorStyle\n\t/** Color style for the shape outline */\n\tcolor: DrDefaultColorStyle\n\t/** Fill style for the shape interior */\n\tfill: DrDefaultFillStyle\n\t/** Size/thickness style for outline and text */\n\tsize: DrDefaultSizeStyle\n\t/** Font style for text content */\n\tfont: DrDefaultFontStyle\n\t/** Horizontal alignment for text content */\n\talign: DrDefaultHorizontalAlignStyle\n\t/** Vertical alignment for text content */\n\tverticalAlign: DrDefaultVerticalAlignStyle\n\t/** Rich text content displayed within the shape */\n\trichText: DrRichText\n}\n\n/**\n * A geo shape represents geometric forms like rectangles, ellipses, triangles, and other\n * predefined shapes. Geo shapes support styling, text content, and can act as containers.\n *\n * @public\n * @example\n * ```ts\n * const geoShape: DrGeoShape = {\n * id: createShapeId(),\n * typeName: 'shape',\n * type: 'geo',\n * x: 100,\n * y: 100,\n * rotation: 0,\n * index: 'a1',\n * parentId: 'page:page1',\n * isLocked: false,\n * opacity: 1,\n * props: {\n * geo: 'rectangle',\n * w: 200,\n * h: 100,\n * color: 'black',\n * fill: 'solid',\n * dash: 'solid',\n * size: 'm',\n * font: 'draw',\n * align: 'middle',\n * verticalAlign: 'middle',\n * richText: toRichText('Hello World'),\n * labelColor: 'black',\n * url: '',\n * growY: 0,\n * scale: 1\n * },\n * meta: {}\n * }\n * ```\n */\nexport type DrGeoShape = DrBaseShape<'geo', DrGeoShapeProps>\n\n/**\n * Validation schema for geo shape properties.\n *\n * @public\n * @example\n * ```ts\n * // Validate geo shape properties\n * const isValidGeo = geoShapeProps.geo.isValid('rectangle')\n * const isValidSize = geoShapeProps.w.isValid(100)\n * const isValidText = geoShapeProps.richText.isValid(toRichText('Hello'))\n * ```\n */\nexport const geoShapeProps: RecordProps<DrGeoShape> = {\n\tgeo: GeoShapeGeoStyle,\n\tdash: DefaultDashStyle,\n\turl: T.linkUrl,\n\tw: T.nonZeroNumber,\n\th: T.nonZeroNumber,\n\tgrowY: T.positiveNumber,\n\tscale: T.nonZeroNumber,\n\n\t// Text properties\n\tlabelColor: DefaultLabelColorStyle,\n\tcolor: DefaultColorStyle,\n\tfill: DefaultFillStyle,\n\tsize: DefaultSizeStyle,\n\tfont: DefaultFontStyle,\n\talign: DefaultHorizontalAlignStyle,\n\tverticalAlign: DefaultVerticalAlignStyle,\n\trichText: richTextValidator,\n}\n\nconst geoShapeVersions = createShapePropsMigrationIds('geo', {\n\tAddUrlProp: 1,\n\tAddLabelColor: 2,\n\tRemoveJustify: 3,\n\tAddCheckBox: 4,\n\tAddVerticalAlign: 5,\n\tMigrateLegacyAlign: 6,\n\tAddCloud: 7,\n\tMakeUrlsValid: 8,\n\tAddScale: 9,\n\tAddRichText: 10,\n\tAddRichTextAttrs: 11,\n})\n\n/**\n * Version identifiers for geo shape migrations.\n *\n * @public\n */\nexport { geoShapeVersions }\n\n/**\n * Migration sequence for geo shape properties across different schema versions.\n * Handles evolution of geo shapes including URL support, label colors, alignment changes,\n * the transition from plain text to rich text, and support for attrs property on richText.\n *\n * @public\n */\nexport const geoShapeMigrations = createShapePropsMigrationSequence({\n\tsequence: [\n\t\t{\n\t\t\tid: geoShapeVersions.AddUrlProp,\n\t\t\tup: (props) => {\n\t\t\t\tprops.url = ''\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: geoShapeVersions.AddLabelColor,\n\t\t\tup: (props) => {\n\t\t\t\tprops.labelColor = 'black'\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: geoShapeVersions.RemoveJustify,\n\t\t\tup: (props) => {\n\t\t\t\tif (props.align === 'justify') {\n\t\t\t\t\tprops.align = 'start'\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: geoShapeVersions.AddCheckBox,\n\t\t\tup: (_props) => {\n\t\t\t\t// noop\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: geoShapeVersions.AddVerticalAlign,\n\t\t\tup: (props) => {\n\t\t\t\tprops.verticalAlign = 'middle'\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: geoShapeVersions.MigrateLegacyAlign,\n\t\t\tup: (props) => {\n\t\t\t\tlet newAlign: DrDefaultHorizontalAlignStyle\n\t\t\t\tswitch (props.align) {\n\t\t\t\t\tcase 'start':\n\t\t\t\t\t\tnewAlign = 'start-legacy'\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'end':\n\t\t\t\t\t\tnewAlign = 'end-legacy'\n\t\t\t\t\t\tbreak\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tnewAlign = 'middle-legacy'\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tprops.align = newAlign\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: geoShapeVersions.AddCloud,\n\t\t\tup: (_props) => {\n\t\t\t\t// noop\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: geoShapeVersions.MakeUrlsValid,\n\t\t\tup: (props) => {\n\t\t\t\tif (!T.linkUrl.isValid(props.url)) {\n\t\t\t\t\tprops.url = ''\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (_props) => {\n\t\t\t\t// noop\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: geoShapeVersions.AddScale,\n\t\t\tup: (props) => {\n\t\t\t\tprops.scale = 1\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.scale\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: geoShapeVersions.AddRichText,\n\t\t\tup: (props) => {\n\t\t\t\tprops.richText = toRichText(props.text)\n\t\t\t\tdelete props.text\n\t\t\t},\n\t\t\t// N.B. Explicitly no down state so that we force clients to update.\n\t\t\t// down: (props) => {\n\t\t\t// \tdelete props.richText\n\t\t\t// },\n\t\t},\n\t\t{\n\t\t\tid: geoShapeVersions.AddRichTextAttrs,\n\t\t\tup: (_props) => {\n\t\t\t\t// noop - attrs is optional so old records are valid\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\t// Remove attrs from richText when migrating down\n\t\t\t\tif (props.richText && 'attrs' in props.richText) {\n\t\t\t\t\tdelete props.richText.attrs\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t],\n})\n","import { createShapePropsMigrationSequence } from '../records/DrShape'\nimport { RecordProps } from '../recordsWithProps'\nimport { DrBaseShape } from './DrBaseShape'\n\n/**\n * Properties for a group shape. Group shapes are used to organize and manage collections of shapes as a single unit.\n * Group shapes themselves have no visual properties and serve only as containers.\n *\n * @public\n * @example\n * ```ts\n * const groupProps: DrGroupShapeProps = {}\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface DrGroupShapeProps {}\n\n/**\n * A group shape that acts as a container for organizing multiple shapes into a single logical unit.\n * Groups enable users to move, transform, and manage collections of shapes together while maintaining\n * their relative positions and properties.\n *\n * @public\n * @example\n * ```ts\n * const groupShape: DrGroupShape = {\n * id: 'shape:group1',\n * type: 'group',\n * x: 100,\n * y: 100,\n * rotation: 0,\n * index: 'a1',\n * parentId: 'page:main',\n * isLocked: false,\n * opacity: 1,\n * props: {},\n * meta: {},\n * typeName: 'shape'\n * }\n * ```\n */\nexport type DrGroupShape = DrBaseShape<'group', DrGroupShapeProps>\n\n/**\n * Validation schema for group shape properties. Since group shapes have no visual properties,\n * this is an empty object that serves as a placeholder for the schema system.\n *\n * @public\n * @example\n * ```ts\n * import { groupShapeProps } from '@ibodr/schema'\n *\n * // Used internally by the validation system\n * const validator = T.object(groupShapeProps)\n * ```\n */\nexport const groupShapeProps: RecordProps<DrGroupShape> = {}\n\n/**\n * Migration sequence for group shapes. Currently contains no migrations.\n *\n * @public\n */\nexport const groupShapeMigrations = createShapePropsMigrationSequence({ sequence: [] })\n","import { T } from '@ibodr/validate'\nimport { b64Vecs } from '../misc/b64Vecs'\nimport { createShapePropsMigrationIds, createShapePropsMigrationSequence } from '../records/DrShape'\nimport { RecordProps } from '../recordsWithProps'\nimport { DefaultColorStyle, DrDefaultColorStyle } from '../styles/DrColorStyle'\nimport { DefaultSizeStyle, DrDefaultSizeStyle } from '../styles/DrSizeStyle'\nimport { DrBaseShape } from './DrBaseShape'\nimport { DrawShapeSegment, DrDrawShapeSegment } from './DrDrawShape'\n\n/**\n * Properties for a highlight shape. Highlight shapes represent highlighting strokes made with\n * a highlighting tool, typically used to emphasize or mark up content.\n *\n * @public\n * @example\n * ```ts\n * const highlightProps: DrHighlightShapeProps = {\n * color: 'yellow',\n * size: 'm',\n * segments: [{ type: 'straight', points: [{ x: 0, y: 0, z: 0.5 }] }],\n * isComplete: true,\n * isPen: false,\n * scale: 1\n * }\n * ```\n */\nexport interface DrHighlightShapeProps {\n\t/** The color style of the highlight stroke */\n\tcolor: DrDefaultColorStyle\n\t/** The size style determining the thickness of the highlight stroke */\n\tsize: DrDefaultSizeStyle\n\t/** Array of segments that make up the highlight stroke path */\n\tsegments: DrDrawShapeSegment[]\n\t/** Whether the highlight stroke has been completed by the user */\n\tisComplete: boolean\n\t/** Whether the highlight was drawn with a pen/stylus (affects rendering style) */\n\tisPen: boolean\n\t/** Scale factor applied to the highlight shape for display */\n\tscale: number\n\t/** Horizontal scale factor for lazy resize */\n\tscaleX: number\n\t/** Vertical scale factor for lazy resize */\n\tscaleY: number\n}\n\n/**\n * A highlight shape representing a highlighting stroke drawn by the user. Highlight shapes\n * are typically semi-transparent and used for marking up or emphasizing content on the canvas.\n *\n * @public\n * @example\n * ```ts\n * const highlightShape: DrHighlightShape = {\n * id: 'shape:highlight1',\n * type: 'highlight',\n * x: 100,\n * y: 50,\n * rotation: 0,\n * index: 'a1',\n * parentId: 'page:main',\n * isLocked: false,\n * opacity: 0.7,\n * props: {\n * color: 'yellow',\n * size: 'l',\n * segments: [],\n * isComplete: false,\n * isPen: false,\n * scale: 1\n * },\n * meta: {},\n * typeName: 'shape'\n * }\n * ```\n */\nexport type DrHighlightShape = DrBaseShape<'highlight', DrHighlightShapeProps>\n\n/**\n * Validation schema for highlight shape properties. Defines the runtime validation rules\n * for all properties of highlight shapes.\n *\n * @public\n * @example\n * ```ts\n * import { highlightShapeProps } from '@ibodr/schema'\n *\n * // Used internally by the validation system\n * const validator = T.object(highlightShapeProps)\n * const validatedProps = validator.validate(someHighlightProps)\n * ```\n */\n/** @public */\nexport const highlightShapeProps: RecordProps<DrHighlightShape> = {\n\tcolor: DefaultColorStyle,\n\tsize: DefaultSizeStyle,\n\tsegments: T.arrayOf(DrawShapeSegment),\n\tisComplete: T.boolean,\n\tisPen: T.boolean,\n\tscale: T.nonZeroNumber,\n\tscaleX: T.nonZeroFiniteNumber,\n\tscaleY: T.nonZeroFiniteNumber,\n}\n\nconst Versions = createShapePropsMigrationIds('highlight', {\n\tAddScale: 1,\n\tBase64: 2,\n\tLegacyPointsConversion: 3,\n})\n\n/**\n * Version identifiers for highlight shape migrations. These version numbers track\n * schema changes over time to enable proper data migration.\n *\n * @public\n */\nexport { Versions as highlightShapeVersions }\n\n/**\n * Migration sequence for highlight shapes. Handles schema evolution over time by defining\n * how to upgrade and downgrade highlight shape data between different versions.\n *\n * @public\n */\nexport const highlightShapeMigrations = createShapePropsMigrationSequence({\n\tsequence: [\n\t\t{\n\t\t\tid: Versions.AddScale,\n\t\t\tup: (props) => {\n\t\t\t\tprops.scale = 1\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.scale\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.Base64,\n\t\t\tup: (props) => {\n\t\t\t\t// Convert VecModel[] arrays directly to delta-encoded base64 in 'path'\n\t\t\t\tprops.segments = props.segments.map((segment: any) => {\n\t\t\t\t\tif (segment.path !== undefined) return segment\n\t\t\t\t\tconst { points, ...rest } = segment\n\t\t\t\t\tconst vecModels = Array.isArray(points) ? points : b64Vecs._legacyDecodePoints(points)\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...rest,\n\t\t\t\t\t\tpath: b64Vecs.encodePoints(vecModels),\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\tprops.scaleX = props.scaleX ?? 1\n\t\t\t\tprops.scaleY = props.scaleY ?? 1\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\t// Convert delta-encoded 'path' back to VecModel[] arrays in 'points'\n\t\t\t\tprops.segments = props.segments.map((segment: any) => {\n\t\t\t\t\tconst { path, ...rest } = segment\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...rest,\n\t\t\t\t\t\tpoints: b64Vecs.decodePoints(path),\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\tdelete props.scaleX\n\t\t\t\tdelete props.scaleY\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.LegacyPointsConversion,\n\t\t\tup: (props) => {\n\t\t\t\t// Handle legacy data that was already migrated to v2 with absolute Float16 in 'points'\n\t\t\t\t// Convert 'points' to delta-encoded 'path'\n\t\t\t\tprops.segments = props.segments.map((segment: any) => {\n\t\t\t\t\t// If segment already has 'path', it's already in the new format\n\t\t\t\t\tif (segment.path !== undefined) return segment\n\n\t\t\t\t\tconst { points, ...rest } = segment\n\t\t\t\t\tconst vecModels = Array.isArray(points) ? points : b64Vecs._legacyDecodePoints(points)\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...rest,\n\t\t\t\t\t\tpath: b64Vecs.encodePoints(vecModels),\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t},\n\t\t\tdown: (_props) => {\n\t\t\t\t// handled by the previous down migration\n\t\t\t},\n\t\t},\n\t],\n})\n","import { T } from '@ibodr/validate'\nimport { assetIdValidator } from '../assets/DrBaseAsset'\nimport { vecModelValidator } from '../misc/geometry-types'\nimport { DrAssetId } from '../records/DrAsset'\nimport { createShapePropsMigrationIds, createShapePropsMigrationSequence } from '../records/DrShape'\nimport { RecordProps } from '../recordsWithProps'\nimport { DrShapeCrop } from './ShapeWithCrop'\nimport { DrBaseShape } from './DrBaseShape'\n\n/**\n * Validator for image shape crop data. Defines the structure for cropping an image,\n * specifying the visible region within the original image bounds.\n *\n * @public\n * @example\n * ```ts\n * const cropData: DrShapeCrop = {\n * topLeft: { x: 0.1, y: 0.1 },\n * bottomRight: { x: 0.9, y: 0.9 },\n * isCircle: false\n * }\n *\n * const isValid = ImageShapeCrop.isValid(cropData)\n * ```\n */\nexport const ImageShapeCrop: T.ObjectValidator<DrShapeCrop> = T.object({\n\ttopLeft: vecModelValidator,\n\tbottomRight: vecModelValidator,\n\tisCircle: T.boolean.optional(),\n})\n\n/**\n * Properties for an image shape. Image shapes display raster images on the canvas,\n * with support for cropping, flipping, and asset management.\n *\n * @public\n * @example\n * ```ts\n * const imageProps: DrImageShapeProps = {\n * w: 300,\n * h: 200,\n * playing: true,\n * url: 'https://example.com/image.jpg',\n * assetId: 'asset:image123',\n * crop: null,\n * flipX: false,\n * flipY: false,\n * altText: 'A sample image'\n * }\n * ```\n */\nexport interface DrImageShapeProps {\n\t/** Width of the image shape in canvas units */\n\tw: number\n\t/** Height of the image shape in canvas units */\n\th: number\n\t/** Whether animated images (like GIFs) should play */\n\tplaying: boolean\n\t/** URL of the image resource */\n\turl: string\n\t/** ID of the associated asset record, null if no asset */\n\tassetId: DrAssetId | null\n\t/** Crop data defining visible region of the image, null for no cropping */\n\tcrop: DrShapeCrop | null\n\t/** Whether to flip the image horizontally */\n\tflipX: boolean\n\t/** Whether to flip the image vertically */\n\tflipY: boolean\n\t/** Alternative text for accessibility and when image fails to load */\n\taltText: string\n}\n\n/**\n * An image shape representing a raster image on the canvas. Image shapes can display\n * various image formats and support features like cropping, flipping, and asset management.\n *\n * @public\n * @example\n * ```ts\n * const imageShape: DrImageShape = {\n * id: 'shape:image1',\n * type: 'image',\n * x: 100,\n * y: 100,\n * rotation: 0,\n * index: 'a1',\n * parentId: 'page:main',\n * isLocked: false,\n * opacity: 1,\n * props: {\n * w: 400,\n * h: 300,\n * playing: true,\n * url: '',\n * assetId: 'asset:photo1',\n * crop: null,\n * flipX: false,\n * flipY: false,\n * altText: 'Sample photo'\n * },\n * meta: {},\n * typeName: 'shape'\n * }\n * ```\n */\nexport type DrImageShape = DrBaseShape<'image', DrImageShapeProps>\n\n/**\n * Validation schema for image shape properties. Defines the runtime validation rules\n * for all properties of image shapes, ensuring data integrity and type safety.\n *\n * @public\n * @example\n * ```ts\n * import { imageShapeProps } from '@ibodr/schema'\n *\n * // Used internally by the validation system\n * const validator = T.object(imageShapeProps)\n * const validatedProps = validator.validate(someImageProps)\n * ```\n */\nexport const imageShapeProps: RecordProps<DrImageShape> = {\n\tw: T.nonZeroNumber,\n\th: T.nonZeroNumber,\n\tplaying: T.boolean,\n\turl: T.linkUrl,\n\tassetId: assetIdValidator.nullable(),\n\tcrop: ImageShapeCrop.nullable(),\n\tflipX: T.boolean,\n\tflipY: T.boolean,\n\taltText: T.string,\n}\n\nconst Versions = createShapePropsMigrationIds('image', {\n\tAddUrlProp: 1,\n\tAddCropProp: 2,\n\tMakeUrlsValid: 3,\n\tAddFlipProps: 4,\n\tAddAltText: 5,\n})\n\n/**\n * Version identifiers for image shape migrations. These version numbers track\n * schema changes over time to enable proper data migration between versions.\n *\n * @public\n */\nexport { Versions as imageShapeVersions }\n\n/**\n * Migration sequence for image shapes. Handles schema evolution over time by defining\n * how to upgrade and downgrade image shape data between different versions. Includes\n * migrations for URL properties, crop functionality, flip properties, and accessibility features.\n *\n * @public\n */\nexport const imageShapeMigrations = createShapePropsMigrationSequence({\n\tsequence: [\n\t\t{\n\t\t\tid: Versions.AddUrlProp,\n\t\t\tup: (props) => {\n\t\t\t\tprops.url = ''\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddCropProp,\n\t\t\tup: (props) => {\n\t\t\t\tprops.crop = null\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.crop\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.MakeUrlsValid,\n\t\t\tup: (props) => {\n\t\t\t\tif (!T.linkUrl.isValid(props.url)) {\n\t\t\t\t\tprops.url = ''\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (_props) => {\n\t\t\t\t// noop\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddFlipProps,\n\t\t\tup: (props) => {\n\t\t\t\tprops.flipX = false\n\t\t\t\tprops.flipY = false\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.flipX\n\t\t\t\tdelete props.flipY\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddAltText,\n\t\t\tup: (props) => {\n\t\t\t\tprops.altText = ''\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.altText\n\t\t\t},\n\t\t},\n\t],\n})\n","import { IndexKey, getIndices, objectMapFromEntries, sortByIndex } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { createShapePropsMigrationIds, createShapePropsMigrationSequence } from '../records/DrShape'\nimport { RecordProps } from '../recordsWithProps'\nimport { StyleProp } from '../styles/StyleProp'\nimport { DefaultColorStyle, DrDefaultColorStyle } from '../styles/DrColorStyle'\nimport { DefaultDashStyle, DrDefaultDashStyle } from '../styles/DrDashStyle'\nimport { DefaultSizeStyle, DrDefaultSizeStyle } from '../styles/DrSizeStyle'\nimport { DrBaseShape } from './DrBaseShape'\n\n/**\n * Style property for line shape spline interpolation. Determines how the line is rendered\n * between points - either as straight line segments or smooth cubic curves.\n *\n * @public\n * @example\n * ```ts\n * // Create a shape with cubic spline interpolation\n * const lineProps = {\n * spline: 'cubic' as DrLineShapeSplineStyle,\n * // other props...\n * }\n * ```\n */\nexport const LineShapeSplineStyle = StyleProp.defineEnum('draw:spline', {\n\tdefaultValue: 'line',\n\tvalues: ['cubic', 'line'],\n})\n\n/**\n * Type representing the spline style options for line shapes.\n * - 'line': Straight line segments between points\n * - 'cubic': Smooth cubic bezier curves between points\n *\n * @public\n */\nexport type DrLineShapeSplineStyle = T.TypeOf<typeof LineShapeSplineStyle>\n\n/**\n * Represents a single point in a line shape. Line shapes are made up of multiple points\n * that define the path of the line, with each point having coordinates and ordering information.\n *\n * @public\n * @example\n * ```ts\n * const linePoint: DrLineShapePoint = {\n * id: 'a1',\n * index: 'a1' as IndexKey,\n * x: 100,\n * y: 50\n * }\n * ```\n */\nexport interface DrLineShapePoint {\n\t/** Unique identifier for this point, used for tracking and ordering */\n\tid: string\n\t/** Fractional index key used for ordering points along the line */\n\tindex: IndexKey\n\t/** X coordinate of the point relative to the line shape's origin */\n\tx: number\n\t/** Y coordinate of the point relative to the line shape's origin */\n\ty: number\n}\n\nconst lineShapePointValidator: T.ObjectValidator<DrLineShapePoint> = T.object({\n\tid: T.string,\n\tindex: T.indexKey,\n\tx: T.number,\n\ty: T.number,\n})\n\n/**\n * Properties for a line shape. Line shapes represent multi-point lines or splines\n * that can be drawn by connecting multiple points with either straight segments or curves.\n *\n * @public\n * @example\n * ```ts\n * const lineProps: DrLineShapeProps = {\n * color: 'black',\n * dash: 'solid',\n * size: 'm',\n * spline: 'line',\n * points: {\n * 'a1': { id: 'a1', index: 'a1', x: 0, y: 0 },\n * 'a2': { id: 'a2', index: 'a2', x: 100, y: 50 }\n * },\n * scale: 1\n * }\n * ```\n */\nexport interface DrLineShapeProps {\n\t/** Color style of the line stroke */\n\tcolor: DrDefaultColorStyle\n\t/** Dash pattern style for the line (solid, dashed, dotted) */\n\tdash: DrDefaultDashStyle\n\t/** Size/thickness style of the line stroke */\n\tsize: DrDefaultSizeStyle\n\t/** Interpolation style between points (straight lines or curved splines) */\n\tspline: DrLineShapeSplineStyle\n\t/** Dictionary of points that make up the line, keyed by point ID */\n\tpoints: Record<string, DrLineShapePoint>\n\t/** Scale factor applied to the line shape for display */\n\tscale: number\n}\n\n/**\n * A line shape that represents a multi-point line or spline on the canvas. Line shapes\n * allow users to draw connected paths with multiple points, supporting both straight\n * line segments and smooth curved splines.\n *\n * @public\n * @example\n * ```ts\n * const lineShape: DrLineShape = {\n * id: 'shape:line1',\n * type: 'line',\n * x: 100,\n * y: 100,\n * rotation: 0,\n * index: 'a1',\n * parentId: 'page:main',\n * isLocked: false,\n * opacity: 1,\n * props: {\n * color: 'red',\n * dash: 'dashed',\n * size: 'l',\n * spline: 'cubic',\n * points: {\n * 'start': { id: 'start', index: 'a1', x: 0, y: 0 },\n * 'end': { id: 'end', index: 'a2', x: 200, y: 100 }\n * },\n * scale: 1\n * },\n * meta: {},\n * typeName: 'shape'\n * }\n * ```\n */\nexport type DrLineShape = DrBaseShape<'line', DrLineShapeProps>\n\n/**\n * Validation schema for line shape properties. Defines the runtime validation rules\n * for all properties of line shapes, ensuring data integrity and type safety.\n *\n * @public\n * @example\n * ```ts\n * import { lineShapeProps } from '@ibodr/schema'\n *\n * // Used internally by the validation system\n * const validator = T.object(lineShapeProps)\n * const validatedProps = validator.validate(someLineProps)\n * ```\n */\nexport const lineShapeProps: RecordProps<DrLineShape> = {\n\tcolor: DefaultColorStyle,\n\tdash: DefaultDashStyle,\n\tsize: DefaultSizeStyle,\n\tspline: LineShapeSplineStyle,\n\tpoints: T.dict(T.string, lineShapePointValidator),\n\tscale: T.nonZeroNumber,\n}\n\n/**\n * Version identifiers for line shape migrations. These version numbers track\n * significant schema changes over time, enabling proper data migration between versions.\n *\n * @public\n */\nexport const lineShapeVersions = createShapePropsMigrationIds('line', {\n\tAddSnapHandles: 1,\n\tRemoveExtraHandleProps: 2,\n\tHandlesToPoints: 3,\n\tPointIndexIds: 4,\n\tAddScale: 5,\n})\n\n/**\n * Migration sequence for line shapes. Handles schema evolution over time by defining\n * how to upgrade and downgrade line shape data between different versions. Includes\n * major structural changes like the transition from handles to points and the addition\n * of scaling support.\n *\n * @public\n */\nexport const lineShapeMigrations = createShapePropsMigrationSequence({\n\tsequence: [\n\t\t{\n\t\t\tid: lineShapeVersions.AddSnapHandles,\n\t\t\tup: (props) => {\n\t\t\t\tfor (const handle of Object.values(props.handles)) {\n\t\t\t\t\t;(handle as any).canSnap = true\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: lineShapeVersions.RemoveExtraHandleProps,\n\t\t\tup: (props) => {\n\t\t\t\tprops.handles = objectMapFromEntries(\n\t\t\t\t\tObject.values(props.handles).map((handle: any) => [\n\t\t\t\t\t\thandle.index,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tx: handle.x,\n\t\t\t\t\t\t\ty: handle.y,\n\t\t\t\t\t\t},\n\t\t\t\t\t])\n\t\t\t\t)\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tconst handles = Object.entries(props.handles)\n\t\t\t\t\t.map(([index, handle]: any) => ({ index, ...handle }))\n\t\t\t\t\t.sort(sortByIndex)\n\t\t\t\tprops.handles = Object.fromEntries(\n\t\t\t\t\thandles.map((handle, i) => {\n\t\t\t\t\t\tconst id =\n\t\t\t\t\t\t\ti === 0 ? 'start' : i === handles.length - 1 ? 'end' : `handle:${handle.index}`\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\ttype: 'vertex',\n\t\t\t\t\t\t\t\tcanBind: false,\n\t\t\t\t\t\t\t\tcanSnap: true,\n\t\t\t\t\t\t\t\tindex: handle.index,\n\t\t\t\t\t\t\t\tx: handle.x,\n\t\t\t\t\t\t\t\ty: handle.y,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: lineShapeVersions.HandlesToPoints,\n\t\t\tup: (props) => {\n\t\t\t\tconst sortedHandles = (\n\t\t\t\t\tObject.entries(props.handles) as [IndexKey, { x: number; y: number }][]\n\t\t\t\t)\n\t\t\t\t\t.map(([index, { x, y }]) => ({ x, y, index }))\n\t\t\t\t\t.sort(sortByIndex)\n\n\t\t\t\tprops.points = sortedHandles.map(({ x, y }) => ({ x, y }))\n\t\t\t\tdelete props.handles\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tconst indices = getIndices(props.points.length)\n\n\t\t\t\tprops.handles = Object.fromEntries(\n\t\t\t\t\tprops.points.map((handle: { x: number; y: number }, i: number) => {\n\t\t\t\t\t\tconst index = indices[i]\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tx: handle.x,\n\t\t\t\t\t\t\t\ty: handle.y,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]\n\t\t\t\t\t})\n\t\t\t\t)\n\n\t\t\t\tdelete props.points\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: lineShapeVersions.PointIndexIds,\n\t\t\tup: (props) => {\n\t\t\t\tconst indices = getIndices(props.points.length)\n\n\t\t\t\tprops.points = Object.fromEntries(\n\t\t\t\t\tprops.points.map((point: { x: number; y: number }, i: number) => {\n\t\t\t\t\t\tconst id = indices[i]\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tid: id,\n\t\t\t\t\t\t\t\tindex: id,\n\t\t\t\t\t\t\t\tx: point.x,\n\t\t\t\t\t\t\t\ty: point.y,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tconst sortedHandles = (\n\t\t\t\t\tObject.values(props.points) as { x: number; y: number; index: IndexKey }[]\n\t\t\t\t).sort(sortByIndex)\n\n\t\t\t\tprops.points = sortedHandles.map(({ x, y }) => ({ x, y }))\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: lineShapeVersions.AddScale,\n\t\t\tup: (props) => {\n\t\t\t\tprops.scale = 1\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.scale\n\t\t\t},\n\t\t},\n\t],\n})\n","import { T } from '@ibodr/validate'\nimport { DrRichText, richTextValidator, toRichText } from '../misc/DrRichText'\nimport { createShapePropsMigrationIds, createShapePropsMigrationSequence } from '../records/DrShape'\nimport { RecordProps } from '../recordsWithProps'\nimport {\n\tDefaultColorStyle,\n\tDefaultLabelColorStyle,\n\tDrDefaultColorStyle,\n} from '../styles/DrColorStyle'\nimport { DefaultFontStyle, DrDefaultFontStyle } from '../styles/DrFontStyle'\nimport {\n\tDefaultHorizontalAlignStyle,\n\tDrDefaultHorizontalAlignStyle,\n} from '../styles/DrHorizontalAlignStyle'\nimport { DefaultSizeStyle, DrDefaultSizeStyle } from '../styles/DrSizeStyle'\nimport {\n\tDefaultVerticalAlignStyle,\n\tDrDefaultVerticalAlignStyle,\n} from '../styles/DrVerticalAlignStyle'\nimport { DrBaseShape } from './DrBaseShape'\n\n/**\n * Properties for a note shape. Note shapes represent sticky notes or text annotations\n * with rich formatting capabilities and various styling options.\n *\n * @public\n * @example\n * ```ts\n * const noteProps: DrNoteShapeProps = {\n * color: 'yellow',\n * labelColor: 'black',\n * size: 'm',\n * font: 'draw',\n * fontSizeAdjustment: null,\n * align: 'middle',\n * verticalAlign: 'middle',\n * growY: 0,\n * url: '',\n * richText: toRichText('Hello **world**!'),\n * scale: 1\n * }\n * ```\n */\nexport interface DrNoteShapeProps {\n\t/** Background color style of the note */\n\tcolor: DrDefaultColorStyle\n\t/** Text color style for the note content */\n\tlabelColor: DrDefaultColorStyle\n\t/** Size style determining the font size and note dimensions */\n\tsize: DrDefaultSizeStyle\n\t/** Font family style for the note text */\n\tfont: DrDefaultFontStyle\n\t/** Ratio to scale the base font size when text needs to shrink to fit. Null means needs recomputation, 1 means no adjustment, and values less than 1 indicate shrinkage. */\n\tfontSizeAdjustment: number | null\n\t/** Horizontal alignment of text within the note */\n\talign: DrDefaultHorizontalAlignStyle\n\t/** Vertical alignment of text within the note */\n\tverticalAlign: DrDefaultVerticalAlignStyle\n\t/** Additional height growth for the note beyond its base size */\n\tgrowY: number\n\t/** Optional URL associated with the note for linking */\n\turl: string\n\t/** Rich text content with formatting like bold, italic, etc. */\n\trichText: DrRichText\n\t/** Scale factor applied to the note shape for display */\n\tscale: number\n\t/** User ID of the person who first edited the note text */\n\ttextFirstEditedBy: string | null\n}\n\n/**\n * A note shape representing a sticky note or text annotation on the canvas.\n * Note shapes support rich text formatting, various styling options, and can\n * be used for annotations, reminders, or general text content.\n *\n * @public\n * @example\n * ```ts\n * const noteShape: DrNoteShape = {\n * id: 'shape:note1',\n * type: 'note',\n * x: 100,\n * y: 100,\n * rotation: 0,\n * index: 'a1',\n * parentId: 'page:main',\n * isLocked: false,\n * opacity: 1,\n * props: {\n * color: 'light-blue',\n * labelColor: 'black',\n * size: 's',\n * font: 'sans',\n * fontSizeAdjustment: 0.85,\n * align: 'start',\n * verticalAlign: 'start',\n * growY: 50,\n * url: 'https://example.com',\n * richText: toRichText('Important **note**!'),\n * scale: 1\n * },\n * meta: {},\n * typeName: 'shape'\n * }\n * ```\n */\nexport type DrNoteShape = DrBaseShape<'note', DrNoteShapeProps>\n\n/**\n * Validation schema for note shape properties. Defines the runtime validation rules\n * for all properties of note shapes, ensuring data integrity and type safety.\n *\n * @public\n * @example\n * ```ts\n * import { noteShapeProps } from '@ibodr/schema'\n *\n * // Used internally by the validation system\n * const validator = T.object(noteShapeProps)\n * const validatedProps = validator.validate(someNoteProps)\n * ```\n */\nexport const noteShapeProps: RecordProps<DrNoteShape> = {\n\tcolor: DefaultColorStyle,\n\tlabelColor: DefaultLabelColorStyle,\n\tsize: DefaultSizeStyle,\n\tfont: DefaultFontStyle,\n\tfontSizeAdjustment: T.positiveNumber.nullable(),\n\talign: DefaultHorizontalAlignStyle,\n\tverticalAlign: DefaultVerticalAlignStyle,\n\tgrowY: T.positiveNumber,\n\turl: T.linkUrl,\n\trichText: richTextValidator,\n\tscale: T.nonZeroNumber,\n\ttextFirstEditedBy: T.string.nullable(),\n}\n\nconst Versions = createShapePropsMigrationIds('note', {\n\tAddUrlProp: 1,\n\tRemoveJustify: 2,\n\tMigrateLegacyAlign: 3,\n\tAddVerticalAlign: 4,\n\tMakeUrlsValid: 5,\n\tAddFontSizeAdjustment: 6,\n\tAddScale: 7,\n\tAddLabelColor: 8,\n\tAddRichText: 9,\n\tAddRichTextAttrs: 10,\n\tAddFirstEditedBy: 11,\n\tMakeFontSizeAdjustmentRatio: 12,\n})\n\n/**\n * Version identifiers for note shape migrations. These version numbers track\n * significant schema changes over time, enabling proper data migration between versions.\n *\n * @public\n */\nexport { Versions as noteShapeVersions }\n\n/**\n * Migration sequence for note shapes. Handles schema evolution over time by defining\n * how to upgrade and downgrade note shape data between different versions. Includes\n * migrations for URL properties, text alignment changes, vertical alignment addition,\n * font size adjustments, scaling support, label color, the transition from plain text to rich text,\n * and support for attrs property on richText.\n *\n * @public\n */\nexport const noteShapeMigrations = createShapePropsMigrationSequence({\n\tsequence: [\n\t\t{\n\t\t\tid: Versions.AddUrlProp,\n\t\t\tup: (props) => {\n\t\t\t\tprops.url = ''\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.RemoveJustify,\n\t\t\tup: (props) => {\n\t\t\t\tif (props.align === 'justify') {\n\t\t\t\t\tprops.align = 'start'\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.MigrateLegacyAlign,\n\t\t\tup: (props) => {\n\t\t\t\tswitch (props.align) {\n\t\t\t\t\tcase 'start':\n\t\t\t\t\t\tprops.align = 'start-legacy'\n\t\t\t\t\t\treturn\n\t\t\t\t\tcase 'end':\n\t\t\t\t\t\tprops.align = 'end-legacy'\n\t\t\t\t\t\treturn\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tprops.align = 'middle-legacy'\n\t\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddVerticalAlign,\n\t\t\tup: (props) => {\n\t\t\t\tprops.verticalAlign = 'middle'\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.MakeUrlsValid,\n\t\t\tup: (props) => {\n\t\t\t\tif (!T.linkUrl.isValid(props.url)) {\n\t\t\t\t\tprops.url = ''\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (_props) => {\n\t\t\t\t// noop\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddFontSizeAdjustment,\n\t\t\tup: (props) => {\n\t\t\t\tprops.fontSizeAdjustment = 0\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.fontSizeAdjustment\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddScale,\n\t\t\tup: (props) => {\n\t\t\t\tprops.scale = 1\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.scale\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddLabelColor,\n\t\t\tup: (props) => {\n\t\t\t\tprops.labelColor = 'black'\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.labelColor\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddRichText,\n\t\t\tup: (props) => {\n\t\t\t\tprops.richText = toRichText(props.text)\n\t\t\t\tdelete props.text\n\t\t\t},\n\t\t\t// N.B. Explicitly no down state so that we force clients to update.\n\t\t\t// down: (props) => {\n\t\t\t// \tdelete props.richText\n\t\t\t// },\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddRichTextAttrs,\n\t\t\tup: (_props) => {\n\t\t\t\t// noop - attrs is optional so old records are valid\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\t// Remove attrs from richText when migrating down\n\t\t\t\tif (props.richText && 'attrs' in props.richText) {\n\t\t\t\t\tdelete props.richText.attrs\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddFirstEditedBy,\n\t\t\tup: (props) => {\n\t\t\t\tprops.textFirstEditedBy = null\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.textFirstEditedBy\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.MakeFontSizeAdjustmentRatio,\n\t\t\tup: (props) => {\n\t\t\t\t// Old system stored 0 for \"no adjustment\" or an absolute pixel font size.\n\t\t\t\t// New system stores a ratio (1 = no adjustment, <1 = shrunk).\n\t\t\t\t// We can convert 0 → 1 (no adjustment), but non-zero values need\n\t\t\t\t// recomputation (null) since we don't know the base font size here.\n\t\t\t\tprops.fontSizeAdjustment = props.fontSizeAdjustment === 0 ? 1 : null\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tprops.fontSizeAdjustment = 0\n\t\t\t},\n\t\t},\n\t],\n})\n","import { T } from '@ibodr/validate'\nimport { StyleProp } from './StyleProp'\n\n/**\n * Default text alignment style property used by tldraw text shapes.\n * Controls how text content is aligned within text-based shapes like text boxes and notes.\n *\n * Available values:\n * - `start` - Align text to the start (left in LTR, right in RTL)\n * - `middle` - Center text horizontally\n * - `end` - Align text to the end (right in LTR, left in RTL)\n *\n * @example\n * ```ts\n * import { DefaultTextAlignStyle } from '@ibodr/schema'\n *\n * // Use in text shape props definition\n * interface MyTextShapeProps {\n * textAlign: typeof DefaultTextAlignStyle\n * // other props...\n * }\n *\n * // Create a text shape with center alignment\n * const textShape = {\n * // ... other properties\n * props: {\n * textAlign: 'middle' as const,\n * // ... other props\n * }\n * }\n * ```\n *\n * @public\n */\nexport const DefaultTextAlignStyle = StyleProp.defineEnum('draw:textAlign', {\n\tdefaultValue: 'start',\n\tvalues: ['start', 'middle', 'end'],\n})\n\n/**\n * Type representing a default text alignment style value.\n * This is a union type of all available text alignment options.\n *\n * @example\n * ```ts\n * import { DrDefaultTextAlignStyle } from '@ibodr/schema'\n *\n * // Valid text alignment values\n * const leftAlign: DrDefaultTextAlignStyle = 'start'\n * const centerAlign: DrDefaultTextAlignStyle = 'middle'\n * const rightAlign: DrDefaultTextAlignStyle = 'end'\n *\n * // Use in a function parameter\n * function setTextAlignment(align: DrDefaultTextAlignStyle) {\n * // Apply text alignment to text shape\n * }\n * ```\n *\n * @public\n */\nexport type DrDefaultTextAlignStyle = T.TypeOf<typeof DefaultTextAlignStyle>\n","import { T } from '@ibodr/validate'\nimport { DrRichText, richTextValidator, toRichText } from '../misc/DrRichText'\nimport { createShapePropsMigrationIds, createShapePropsMigrationSequence } from '../records/DrShape'\nimport { RecordProps } from '../recordsWithProps'\nimport { DefaultColorStyle, DrDefaultColorStyle } from '../styles/DrColorStyle'\nimport { DefaultFontStyle, DrDefaultFontStyle } from '../styles/DrFontStyle'\nimport { DefaultSizeStyle, DrDefaultSizeStyle } from '../styles/DrSizeStyle'\nimport { DefaultTextAlignStyle, DrDefaultTextAlignStyle } from '../styles/DrTextAlignStyle'\nimport { DrBaseShape } from './DrBaseShape'\n\n/**\n * Configuration interface defining properties for text shapes in tldraw.\n * Text shapes support rich formatting, styling, and automatic sizing.\n *\n * @public\n * @example\n * ```ts\n * const textProps: DrTextShapeProps = {\n * color: 'black',\n * size: 'm',\n * font: 'draw',\n * textAlign: 'start',\n * w: 200,\n * richText: toRichText('Hello **bold** text'),\n * scale: 1,\n * autoSize: true\n * }\n * ```\n */\nexport interface DrTextShapeProps {\n\tcolor: DrDefaultColorStyle\n\tsize: DrDefaultSizeStyle\n\tfont: DrDefaultFontStyle\n\ttextAlign: DrDefaultTextAlignStyle\n\tw: number\n\trichText: DrRichText\n\tscale: number\n\tautoSize: boolean\n}\n\n/**\n * A text shape that can display formatted text content with various styling options.\n * Text shapes support rich formatting, automatic sizing, and consistent styling through\n * the tldraw style system.\n *\n * @public\n * @example\n * ```ts\n * const textShape: DrTextShape = {\n * id: 'shape:text123',\n * typeName: 'shape',\n * type: 'text',\n * x: 100,\n * y: 200,\n * rotation: 0,\n * index: 'a1',\n * parentId: 'page:main',\n * isLocked: false,\n * opacity: 1,\n * props: {\n * color: 'black',\n * size: 'm',\n * font: 'draw',\n * textAlign: 'start',\n * w: 200,\n * richText: toRichText('Sample text'),\n * scale: 1,\n * autoSize: false\n * },\n * meta: {}\n * }\n * ```\n */\nexport type DrTextShape = DrBaseShape<'text', DrTextShapeProps>\n\n/**\n * Validation schema for text shape properties. This defines the runtime validation\n * rules that ensure text shape data integrity when records are stored or transmitted.\n *\n * @public\n * @example\n * ```ts\n * import { textShapeProps } from '@ibodr/schema'\n *\n * // Validate text shape properties\n * const isValid = textShapeProps.richText.isValid(myRichText)\n * if (isValid) {\n * // Properties are valid, safe to use\n * }\n * ```\n */\nexport const textShapeProps: RecordProps<DrTextShape> = {\n\tcolor: DefaultColorStyle,\n\tsize: DefaultSizeStyle,\n\tfont: DefaultFontStyle,\n\ttextAlign: DefaultTextAlignStyle,\n\tw: T.nonZeroNumber,\n\trichText: richTextValidator,\n\tscale: T.nonZeroNumber,\n\tautoSize: T.boolean,\n}\n\nconst Versions = createShapePropsMigrationIds('text', {\n\tRemoveJustify: 1,\n\tAddTextAlign: 2,\n\tAddRichText: 3,\n\tAddRichTextAttrs: 4,\n})\n\n/**\n * Version identifiers for text shape migrations. These constants track\n * the evolution of the text shape schema over time.\n *\n * @public\n * @example\n * ```ts\n * import { textShapeVersions } from '@ibodr/schema'\n *\n * // Check if shape data needs migration\n * if (shapeVersion < textShapeVersions.AddRichTextAttrs) {\n * // Apply rich text attrs migration\n * }\n * ```\n */\nexport { Versions as textShapeVersions }\n\n/**\n * Migration sequence for text shape schema evolution. This handles transforming\n * text shape data between different versions as the schema evolves over time.\n *\n * Key migrations include:\n * - RemoveJustify: Replaced 'justify' alignment with 'start'\n * - AddTextAlign: Migrated from 'align' to 'textAlign' property\n * - AddRichText: Converted plain text to rich text format\n * - AddRichTextAttrs: Added support for attrs property on richText\n *\n * @public\n */\nexport const textShapeMigrations = createShapePropsMigrationSequence({\n\tsequence: [\n\t\t{\n\t\t\tid: Versions.RemoveJustify,\n\t\t\tup: (props) => {\n\t\t\t\tif (props.align === 'justify') {\n\t\t\t\t\tprops.align = 'start'\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddTextAlign,\n\t\t\tup: (props) => {\n\t\t\t\tprops.textAlign = props.align\n\t\t\t\tdelete props.align\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tprops.align = props.textAlign\n\t\t\t\tdelete props.textAlign\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddRichText,\n\t\t\tup: (props) => {\n\t\t\t\tprops.richText = toRichText(props.text)\n\t\t\t\tdelete props.text\n\t\t\t},\n\t\t\t// N.B. Explicitly no down state so that we force clients to update.\n\t\t\t// down: (props) => {\n\t\t\t// \tdelete props.richText\n\t\t\t// },\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddRichTextAttrs,\n\t\t\tup: (_props) => {\n\t\t\t\t// noop - attrs is optional so old records are valid\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\t// Remove attrs from richText when migrating down\n\t\t\t\tif (props.richText && 'attrs' in props.richText) {\n\t\t\t\t\tdelete props.richText.attrs\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t],\n})\n","import { T } from '@ibodr/validate'\nimport { assetIdValidator } from '../assets/DrBaseAsset'\nimport { DrAssetId } from '../records/DrAsset'\nimport { createShapePropsMigrationIds, createShapePropsMigrationSequence } from '../records/DrShape'\nimport { RecordProps } from '../recordsWithProps'\nimport { DrBaseShape } from './DrBaseShape'\n\n/**\n * Configuration interface defining properties for video shapes in tldraw.\n * Video shapes can display video content from URLs or asset references,\n * with controls for playback state, timing, and accessibility.\n *\n * @public\n * @example\n * ```ts\n * const videoProps: DrVideoShapeProps = {\n * w: 640,\n * h: 480,\n * time: 0,\n * playing: false,\n * autoplay: true,\n * url: 'https://example.com/video.mp4',\n * assetId: 'asset:video123',\n * altText: 'Educational video about shapes'\n * }\n * ```\n */\nexport interface DrVideoShapeProps {\n\tw: number\n\th: number\n\ttime: number\n\tplaying: boolean\n\tautoplay: boolean\n\turl: string\n\tassetId: DrAssetId | null\n\taltText: string\n}\n\n/**\n * A video shape that can display video content with playback controls and timing.\n * Video shapes support both direct URL references and asset-based video storage,\n * with accessibility features and playback state management.\n *\n * @public\n * @example\n * ```ts\n * const videoShape: DrVideoShape = {\n * id: 'shape:video123',\n * typeName: 'shape',\n * type: 'video',\n * x: 100,\n * y: 100,\n * rotation: 0,\n * index: 'a1',\n * parentId: 'page:main',\n * isLocked: false,\n * opacity: 1,\n * props: {\n * w: 640,\n * h: 480,\n * time: 15.5,\n * playing: false,\n * autoplay: false,\n * url: 'https://example.com/video.mp4',\n * assetId: 'asset:video123',\n * altText: 'Product demo video'\n * },\n * meta: {}\n * }\n * ```\n */\nexport type DrVideoShape = DrBaseShape<'video', DrVideoShapeProps>\n\n/**\n * Validation schema for video shape properties. This defines the runtime validation\n * rules that ensure video shape data integrity, including URL validation, numeric\n * constraints, and proper asset ID formatting.\n *\n * @public\n * @example\n * ```ts\n * import { videoShapeProps } from '@ibodr/schema'\n *\n * // Validate video URL\n * const isValidUrl = videoShapeProps.url.isValid('https://example.com/video.mp4')\n * const isValidTime = videoShapeProps.time.isValid(42.5)\n *\n * if (isValidUrl && isValidTime) {\n * // Video properties are valid\n * }\n * ```\n */\nexport const videoShapeProps: RecordProps<DrVideoShape> = {\n\tw: T.nonZeroNumber,\n\th: T.nonZeroNumber,\n\ttime: T.number,\n\tplaying: T.boolean,\n\tautoplay: T.boolean,\n\turl: T.linkUrl,\n\tassetId: assetIdValidator.nullable(),\n\taltText: T.string,\n}\n\nconst Versions = createShapePropsMigrationIds('video', {\n\tAddUrlProp: 1,\n\tMakeUrlsValid: 2,\n\tAddAltText: 3,\n\tAddAutoplay: 4,\n})\n\n/**\n * Version identifiers for video shape migrations. These constants track\n * the evolution of the video shape schema over time.\n *\n * @public\n * @example\n * ```ts\n * import { videoShapeVersions } from '@ibodr/schema'\n *\n * // Check if shape data needs migration\n * if (shapeVersion < videoShapeVersions.AddAltText) {\n * // Apply alt text migration for accessibility\n * }\n * ```\n */\nexport { Versions as videoShapeVersions }\n\n/**\n * Migration sequence for video shape schema evolution. This handles transforming\n * video shape data between different versions as the schema evolves over time.\n *\n * Key migrations include:\n * - AddUrlProp: Added URL property for direct video links\n * - MakeUrlsValid: Ensured all URLs conform to link URL validation\n * - AddAltText: Added accessibility support with alternative text\n * - AddAutoplay: Added autoplay control for video playback\n *\n * @public\n */\nexport const videoShapeMigrations = createShapePropsMigrationSequence({\n\tsequence: [\n\t\t{\n\t\t\tid: Versions.AddUrlProp,\n\t\t\tup: (props) => {\n\t\t\t\tprops.url = ''\n\t\t\t},\n\t\t\tdown: 'retired',\n\t\t},\n\t\t{\n\t\t\tid: Versions.MakeUrlsValid,\n\t\t\tup: (props) => {\n\t\t\t\tif (!T.linkUrl.isValid(props.url)) {\n\t\t\t\t\tprops.url = ''\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: (_props) => {\n\t\t\t\t// noop\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddAltText,\n\t\t\tup: (props) => {\n\t\t\t\tprops.altText = ''\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.altText\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddAutoplay,\n\t\t\tup: (props) => {\n\t\t\t\tprops.autoplay = true\n\t\t\t},\n\t\t\tdown: (props) => {\n\t\t\t\tdelete props.autoplay\n\t\t\t},\n\t\t},\n\t],\n})\n","import { createMigrationIds, createMigrationSequence } from '@ibodr/store'\nimport { IndexKey, objectMapEntries } from '@ibodr/utils'\nimport { DrPage } from './records/DrPage'\nimport { DrShape } from './records/DrShape'\nimport { DrLineShape } from './shapes/DrLineShape'\n\n/**\n * Migration version constants for store-level schema changes.\n * Each version represents a breaking change that requires data transformation.\n *\n * @internal\n */\nconst Versions = createMigrationIds('com.draw.store', {\n\tRemoveCodeAndIconShapeTypes: 1,\n\tAddInstancePresenceType: 2,\n\tRemoveTLUserAndPresenceAndAddPointer: 3,\n\tRemoveUserDocument: 4,\n\tFixIndexKeys: 5,\n} as const)\n\n/**\n * Migration version identifiers for store-level migrations.\n * These versions track changes to the overall store structure and data model.\n *\n * @example\n * ```ts\n * import { storeVersions } from '@ibodr/schema'\n *\n * // Check if a specific migration version exists\n * const hasRemoveCodeShapes = storeVersions.RemoveCodeAndIconShapeTypes\n * ```\n *\n * @public\n */\nexport { Versions as storeVersions }\n\n/**\n * Store-level migration sequence that handles evolution of the tldraw data model.\n * These migrations run when the store schema version changes and ensure backward\n * compatibility by transforming old data structures to new formats.\n *\n * The migrations handle:\n * - Removal of deprecated shape types (code, icon)\n * - Addition of new record types (instance presence)\n * - Cleanup of obsolete user and presence data\n * - Removal of deprecated user document records\n *\n * @example\n * ```ts\n * import { storeMigrations } from '@ibodr/schema'\n * import { migrate } from '@ibodr/store'\n *\n * // Apply store migrations to old data\n * const migratedStore = migrate({\n * store: oldStoreData,\n * migrations: storeMigrations,\n * fromVersion: 0,\n * toVersion: storeMigrations.currentVersion\n * })\n * ```\n *\n * @public\n */\nexport const storeMigrations = createMigrationSequence({\n\tsequenceId: 'com.draw.store',\n\tretroactive: false,\n\tsequence: [\n\t\t{\n\t\t\tid: Versions.RemoveCodeAndIconShapeTypes,\n\t\t\tscope: 'storage',\n\t\t\tup: (storage) => {\n\t\t\t\tfor (const [id, record] of storage.entries()) {\n\t\t\t\t\tif (\n\t\t\t\t\t\trecord.typeName === 'shape' &&\n\t\t\t\t\t\t'type' in record &&\n\t\t\t\t\t\t(record.type === 'icon' || record.type === 'code')\n\t\t\t\t\t) {\n\t\t\t\t\t\tstorage.delete(id)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.AddInstancePresenceType,\n\t\t\tscope: 'storage',\n\t\t\tup(_storage) {\n\t\t\t\t// noop\n\t\t\t\t// there used to be a down migration for this but we made down migrations optional\n\t\t\t\t// and we don't use them on storage-level migrations so we can just remove it\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t// remove user and presence records and add pointer records\n\t\t\tid: Versions.RemoveTLUserAndPresenceAndAddPointer,\n\t\t\tscope: 'storage',\n\t\t\tup: (storage) => {\n\t\t\t\tfor (const [id, record] of storage.entries()) {\n\t\t\t\t\tif (record.typeName.match(/^(user|user_presence)$/)) {\n\t\t\t\t\t\tstorage.delete(id)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t// remove user document records\n\t\t\tid: Versions.RemoveUserDocument,\n\t\t\tscope: 'storage',\n\t\t\tup: (storage) => {\n\t\t\t\tfor (const [id, record] of storage.entries()) {\n\t\t\t\t\tif (record.typeName.match('user_document')) {\n\t\t\t\t\t\tstorage.delete(id)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tid: Versions.FixIndexKeys,\n\t\t\tscope: 'record',\n\t\t\tup: (record) => {\n\t\t\t\tif (['shape', 'page'].includes(record.typeName) && 'index' in record) {\n\t\t\t\t\tconst recordWithIndex = record as DrShape | DrPage\n\t\t\t\t\t// Our newer fractional indexed library (more correctly) validates that indices\n\t\t\t\t\t// do not end with 0. ('a0' being an exception)\n\t\t\t\t\tif (recordWithIndex.index.endsWith('0') && recordWithIndex.index !== 'a0') {\n\t\t\t\t\t\trecordWithIndex.index = (recordWithIndex.index.slice(0, -1) +\n\t\t\t\t\t\t\tgetNRandomBase62Digits(3)) as IndexKey\n\t\t\t\t\t}\n\t\t\t\t\t// Line shapes have 'points' that have indices as well.\n\t\t\t\t\tif (record.typeName === 'shape' && (recordWithIndex as DrShape).type === 'line') {\n\t\t\t\t\t\tconst lineShape = recordWithIndex as DrLineShape\n\t\t\t\t\t\tfor (const [_, point] of objectMapEntries(lineShape.props.points)) {\n\t\t\t\t\t\t\tif (point.index.endsWith('0') && point.index !== 'a0') {\n\t\t\t\t\t\t\t\tpoint.index = (point.index.slice(0, -1) + getNRandomBase62Digits(3)) as IndexKey\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tdown: () => {\n\t\t\t\t// noop\n\t\t\t\t// Enables tlsync to support older clients so as to not force people to refresh immediately after deploying.\n\t\t\t},\n\t\t},\n\t],\n})\n\nconst BASE_62_DIGITS_WITHOUT_ZERO = '123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'\nconst getRandomBase62Digit = () => {\n\treturn BASE_62_DIGITS_WITHOUT_ZERO.charAt(\n\t\tMath.floor(Math.random() * BASE_62_DIGITS_WITHOUT_ZERO.length)\n\t)\n}\n\nconst getNRandomBase62Digits = (n: number) => {\n\treturn Array.from({ length: n }, getRandomBase62Digit).join('')\n}\n","import { Signal, computed } from '@ibodr/state'\nimport {\n\tSerializedStore,\n\tStore,\n\tStoreSchema,\n\tStoreSnapshot,\n\tStoreValidationFailure,\n} from '@ibodr/store'\nimport { IndexKey, JsonObject, annotateError, sortByIndex, structuredClone } from '@ibodr/utils'\nimport { DrAsset, DrAssetId } from './records/DrAsset'\nimport { CameraRecordType, DrCameraId } from './records/DrCamera'\nimport { DocumentRecordType, DrDOCUMENT_ID } from './records/DrDocument'\nimport { DrINSTANCE_ID } from './records/DrInstance'\nimport { PageRecordType, DrPageId } from './records/DrPage'\nimport { InstancePageStateRecordType, DrInstancePageStateId } from './records/DrPageState'\nimport { PointerRecordType, DrPOINTER_ID } from './records/DrPointer'\nimport { DrRecord } from './records/DrRecord'\nimport { DrUser } from './records/DrUser'\n\n/**\n * Redacts the source of an asset record for error reporting.\n *\n * @param record - The asset record to redact\n * @returns The redacted record\n * @internal\n */\nexport function redactRecordForErrorReporting(record: any) {\n\tif (record.typeName === 'asset') {\n\t\tif ('src' in record) {\n\t\t\trecord.src = '<redacted>'\n\t\t}\n\n\t\tif ('src' in record.props) {\n\t\t\trecord.props.src = '<redacted>'\n\t\t}\n\t}\n}\n\n/**\n * The complete schema type for a tldraw store, defining the structure and validation rules\n * for all tldraw records and store properties.\n *\n * @public\n * @example\n * ```ts\n * import { createDrSchema } from '@ibodr/schema'\n *\n * const schema = createDrSchema()\n * const storeSchema: DrStoreSchema = schema\n * ```\n */\nexport type DrStoreSchema = StoreSchema<DrRecord, DrStoreProps>\n\n/**\n * A serialized representation of a tldraw store that can be persisted or transmitted.\n * Contains all store records in a JSON-serializable format.\n *\n * @public\n * @example\n * ```ts\n * // Serialize a store\n * const serializedStore: DrSerializedStore = store.serialize()\n *\n * // Save to localStorage\n * localStorage.setItem('drawing', JSON.stringify(serializedStore))\n * ```\n */\nexport type DrSerializedStore = SerializedStore<DrRecord>\n\n/**\n * A snapshot of a tldraw store at a specific point in time, containing all records\n * and metadata. Used for persistence, synchronization, and creating store backups.\n *\n * @public\n * @example\n * ```ts\n * // Create a snapshot\n * const snapshot: DrStoreSnapshot = store.getSnapshot()\n *\n * // Restore from snapshot\n * store.loadSnapshot(snapshot)\n * ```\n */\nexport type DrStoreSnapshot = StoreSnapshot<DrRecord>\n\n/**\n * Context information provided when resolving asset URLs, containing details about\n * the current rendering environment and user's connection to optimize asset delivery.\n *\n * @public\n * @example\n * ```ts\n * const assetStore: DrAssetStore = {\n * async resolve(asset, context: DrAssetContext) {\n * // Use low resolution for slow connections\n * if (context.networkEffectiveType === 'slow-2g') {\n * return `${asset.props.src}?quality=low`\n * }\n * // Use high DPI version for retina displays\n * if (context.dpr > 1) {\n * return `${asset.props.src}@2x`\n * }\n * return asset.props.src\n * }\n * }\n * ```\n */\nexport interface DrAssetContext {\n\t/**\n\t * The scale at which the asset is being rendered on-screen relative to its native dimensions.\n\t * If the asset is 1000px wide, but it's been resized/zoom so it takes 500px on-screen, this\n\t * will be 0.5.\n\t *\n\t * The scale measures CSS pixels, not device pixels.\n\t */\n\tscreenScale: number\n\t/** The {@link DrAssetContext.screenScale}, stepped to the nearest power-of-2 multiple. */\n\tsteppedScreenScale: number\n\t/** The device pixel ratio - how many CSS pixels are in one device pixel? */\n\tdpr: number\n\t/**\n\t * An alias for\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/effectiveType | `navigator.connection.effectiveType` }\n\t * if it's available in the current browser. Use this to e.g. serve lower-resolution images to\n\t * users on slow connections.\n\t */\n\tnetworkEffectiveType: string | null\n\t/**\n\t * In some circumstances, we need to resolve a URL that points to the original version of a\n\t * particular asset. This is used when the asset will leave the current tldraw instance - e.g.\n\t * for copy/paste, or exports.\n\t */\n\tshouldResolveToOriginal: boolean\n}\n\n/**\n * Interface for storing and managing assets (images, videos, etc.) in tldraw.\n * Provides methods for uploading, resolving, and removing assets from storage.\n *\n * A `DrAssetStore` sits alongside the main {@link DrStore} and is responsible for storing and\n * retrieving large assets such as images. Generally, this should be part of a wider sync system:\n *\n * - By default, the store is in-memory only, so `DrAssetStore` converts images to data URLs\n * - When using\n * {@link @ibodr/editor#DrawEditorWithoutStoreProps.persistenceKey | `persistenceKey`}, the\n * store is synced to the browser's local IndexedDB, so `DrAssetStore` stores images there too\n * - When using a multiplayer sync server, you would implement `DrAssetStore` to upload images to\n * e.g. an S3 bucket.\n *\n * @public\n * @example\n * ```ts\n * // Simple in-memory asset store\n * const assetStore: DrAssetStore = {\n * async upload(asset, file) {\n * const dataUrl = await fileToDataUrl(file)\n * return { src: dataUrl }\n * },\n *\n * async resolve(asset, context) {\n * return asset.props.src\n * },\n *\n * async remove(assetIds) {\n * // Clean up if needed\n * }\n * }\n * ```\n */\nexport interface DrAssetStore {\n\t/**\n\t * Upload an asset to your storage, returning a URL that can be used to refer to the asset\n\t * long-term.\n\t *\n\t * @param asset - Information & metadata about the asset being uploaded\n\t * @param file - The `File` to be uploaded\n\t * @returns A promise that resolves to the URL of the uploaded asset\n\t */\n\tupload(\n\t\tasset: DrAsset,\n\t\tfile: File,\n\t\tabortSignal?: AbortSignal\n\t): Promise<{ src: string; meta?: JsonObject }>\n\t/**\n\t * Resolve an asset to a URL. This is used when rendering the asset in the editor. By default,\n\t * this will just use `asset.props.src`, the URL returned by `upload()`. This can be used to\n\t * rewrite that URL to add access credentials, or optimized the asset for how it's currently\n\t * being displayed using the {@link DrAssetContext | information provided}.\n\t *\n\t * @param asset - the asset being resolved\n\t * @param ctx - information about the current environment and where the asset is being used\n\t * @returns The URL of the resolved asset, or `null` if the asset is not available\n\t */\n\tresolve?(asset: DrAsset, ctx: DrAssetContext): Promise<string | null> | string | null\n\t/**\n\t * Remove an asset from storage. This is called when the asset is no longer needed, e.g. when\n\t * the user deletes it from the editor.\n\t * @param asset - the asset being removed\n\t * @returns A promise that resolves when the asset has been removed\n\t */\n\tremove?(assetIds: DrAssetId[]): Promise<void>\n}\n\n/**\n * Interface for resolving user information in tldraw.\n *\n * A `DrUserStore` sits alongside the main {@link DrStore} and provides user\n * resolution for attribution labels and display names. Implement this interface\n * to connect tldraw to your auth/user system.\n *\n * `currentUser` and `resolve` are reactive {@link @ibodr/state#Signal | Signals}\n * so that the editor can automatically track changes to user data and\n * re-render when a user's name, color, or avatar updates.\n *\n * Implementations should cache signals returned by `resolve` — e.g. return the\n * same `Signal` for repeated calls with the same `userId` — to avoid\n * unnecessary re-computation.\n *\n * @public\n * @example\n * ```ts\n * const currentUser = computed('currentUser', () =>\n * UserRecordType.create({\n * id: createUserId(myAuth.userId),\n * name: myAuth.displayName,\n * color: myAuth.color,\n * })\n * )\n *\n * const userStore: DrUserStore = {\n * currentUser,\n * resolve(userId) {\n * return computed('resolve-' + userId, () =>\n * myUserCache.get(userId) ?? null\n * )\n * },\n * }\n * ```\n */\nexport interface DrUserStore {\n\t/**\n\t * A signal resolving to the currently authenticated user,\n\t * or `null` for anonymous / unknown.\n\t * Read when stamping attribution on shape create/update.\n\t */\n\tcurrentUser: Signal<DrUser | null>\n\n\t/**\n\t * Return a signal resolving an arbitrary user ID to display info.\n\t * Called when rendering attribution labels for shapes that may have been\n\t * created or edited by someone else.\n\t * The signal's value should be `null` if the user cannot be resolved.\n\t */\n\tresolve?(userId: string): Signal<DrUser | null>\n}\n\n/**\n * Create a cached {@link DrUserStore.resolve} implementation.\n *\n * Wraps a reactive lookup function so that each `userId` gets a single\n * stable {@link @ibodr/state#Signal | Signal} that is reused across calls.\n * The `resolveFn` is evaluated inside a `computed`, so any `.get()` calls\n * it makes are automatically tracked.\n *\n * @param resolveFn - A function that resolves a raw user-ID string to a\n * {@link DrUser} or `null`. Called reactively inside a `computed`.\n * @returns A function suitable for use as `DrUserStore.resolve`.\n *\n * @example\n * ```ts\n * const users: DrUserStore = {\n * currentUser: currentUserSignal,\n * resolve: createCachedUserResolve(\n * (userId) => usersAtom.get()[createUserId(userId)] ?? null\n * ),\n * }\n * ```\n *\n * @public\n */\nexport function createCachedUserResolve(\n\tresolveFn: (userId: string) => DrUser | null\n): (userId: string) => Signal<DrUser | null> {\n\tconst cache = new Map<string, Signal<DrUser | null>>()\n\treturn (userId: string) => {\n\t\tlet signal = cache.get(userId)\n\t\tif (!signal) {\n\t\t\tsignal = computed('resolve-user-' + userId, () => resolveFn(userId))\n\t\t\tcache.set(userId, signal)\n\t\t}\n\t\treturn signal\n\t}\n}\n\n/**\n * Configuration properties for a tldraw store, defining its behavior and integrations.\n * These props are passed when creating a new store instance.\n *\n * @public\n * @example\n * ```ts\n * const storeProps: DrStoreProps = {\n * defaultName: 'My Drawing',\n * assets: myAssetStore,\n * onMount: (editor) => {\n * console.log('Editor mounted')\n * return () => console.log('Editor unmounted')\n * },\n * collaboration: {\n * status: statusSignal,\n * mode: modeSignal\n * }\n * }\n *\n * const store = new Store({ schema, props: storeProps })\n * ```\n */\nexport interface DrStoreProps {\n\t/** Default name for new documents created in this store */\n\tdefaultName: string\n\t/** Asset store implementation for handling file uploads and storage */\n\tassets: Required<DrAssetStore>\n\t/** User store implementation for user resolution and attribution */\n\tusers: Required<DrUserStore>\n\t/**\n\t * Called when an {@link @ibodr/editor#Editor} connected to this store is mounted.\n\t * Can optionally return a cleanup function that will be called when unmounted.\n\t *\n\t * @param editor - The editor instance that was mounted\n\t * @returns Optional cleanup function\n\t */\n\tonMount(editor: unknown): void | (() => void)\n\t/** Optional collaboration configuration for multiplayer features */\n\tcollaboration?: {\n\t\t/** Signal indicating online/offline collaboration status */\n\t\tstatus: Signal<'online' | 'offline'> | null\n\t\t/** Signal indicating collaboration mode permissions */\n\t\tmode?: Signal<'readonly' | 'readwrite'> | null\n\t}\n}\n\n/**\n * The main tldraw store type, representing a reactive database of tldraw records\n * with associated store properties. This is the central data structure that holds\n * all shapes, assets, pages, and user state.\n *\n * @public\n * @example\n * ```ts\n * import { Store } from '@ibodr/store'\n * import { createDrSchema } from '@ibodr/schema'\n *\n * const schema = createDrSchema()\n * const store: DrStore = new Store({\n * schema,\n * props: {\n * defaultName: 'Untitled',\n * assets: myAssetStore,\n * onMount: () => console.log('Store mounted')\n * }\n * })\n * ```\n */\nexport type DrStore = Store<DrRecord, DrStoreProps>\n\n/**\n * Default validation failure handler for tldraw stores. This function is called\n * when a record fails validation during store operations. It annotates errors\n * with debugging information and determines whether to allow invalid records\n * during store initialization.\n *\n * @param options - The validation failure details\n * - error - The validation error that occurred\n * - phase - The store operation phase when validation failed\n * - record - The invalid record that caused the failure\n * - recordBefore - The previous state of the record (if applicable)\n * @returns The record to use (typically throws the annotated error)\n * @throws The original validation error with additional debugging context\n *\n * @public\n * @example\n * ```ts\n * const store = new Store({\n * schema,\n * props: storeProps,\n * onValidationFailure // Use this as the validation failure handler\n * })\n *\n * // The handler will be called automatically when validation fails\n * try {\n * store.put([invalidRecord])\n * } catch (error) {\n * // Error will contain debugging information added by onValidationFailure\n * }\n * ```\n */\nexport function onValidationFailure({\n\terror,\n\tphase,\n\trecord,\n\trecordBefore,\n}: StoreValidationFailure<DrRecord>): DrRecord {\n\tconst isExistingValidationIssue =\n\t\t// if we're initializing the store for the first time, we should\n\t\t// allow invalid records so people can load old buggy data:\n\t\tphase === 'initialize'\n\n\tannotateError(error, {\n\t\ttags: {\n\t\t\torigin: 'store.validateRecord',\n\t\t\tstorePhase: phase,\n\t\t\tisExistingValidationIssue,\n\t\t},\n\t\textras: {\n\t\t\trecordBefore: recordBefore\n\t\t\t\t? redactRecordForErrorReporting(structuredClone(recordBefore))\n\t\t\t\t: undefined,\n\t\t\trecordAfter: redactRecordForErrorReporting(structuredClone(record)),\n\t\t},\n\t})\n\n\tthrow error\n}\n\nfunction getDefaultPages() {\n\treturn [\n\t\tPageRecordType.create({\n\t\t\tid: 'page:page' as DrPageId,\n\t\t\tname: 'Page 1',\n\t\t\tindex: 'a1' as IndexKey,\n\t\t\tmeta: {},\n\t\t}),\n\t]\n}\n\n/**\n * Creates an integrity checker function that ensures the tldraw store maintains\n * a consistent and usable state. The checker validates that required records exist\n * and relationships between records are maintained.\n *\n * The integrity checker ensures:\n * - Document and pointer records exist\n * - At least one page exists\n * - Instance state references valid pages\n * - Page states and cameras exist for all pages\n * - Shape references in page states are valid\n *\n * @param store - The tldraw store to check for integrity\n * @returns A function that when called, validates and fixes store integrity\n *\n * @internal\n * @example\n * ```ts\n * const checker = createIntegrityChecker(store)\n *\n * // Run integrity check (typically called automatically)\n * checker()\n *\n * // The checker will create missing records and fix invalid references\n * ```\n */\nexport function createIntegrityChecker(store: Store<DrRecord, DrStoreProps>): () => void {\n\tconst $pageIds = store.query.ids('page')\n\tconst $pageStates = store.query.records('instance_page_state')\n\n\tconst ensureStoreIsUsable = (): void => {\n\t\t// make sure we have exactly one document\n\t\tif (!store.has(DrDOCUMENT_ID)) {\n\t\t\tstore.put([DocumentRecordType.create({ id: DrDOCUMENT_ID, name: store.props.defaultName })])\n\t\t\treturn ensureStoreIsUsable()\n\t\t}\n\n\t\tif (!store.has(DrPOINTER_ID)) {\n\t\t\tstore.put([PointerRecordType.create({ id: DrPOINTER_ID })])\n\t\t\treturn ensureStoreIsUsable()\n\t\t}\n\n\t\t// make sure there is at least one page\n\t\tconst pageIds = $pageIds.get()\n\t\tif (pageIds.size === 0) {\n\t\t\tstore.put(getDefaultPages())\n\t\t\treturn ensureStoreIsUsable()\n\t\t}\n\n\t\tconst getFirstPageId = () => [...pageIds].map((id) => store.get(id)!).sort(sortByIndex)[0].id!\n\n\t\t// make sure we have state for the current user's current tab\n\t\tconst instanceState = store.get(DrINSTANCE_ID)\n\t\tif (!instanceState) {\n\t\t\tstore.put([\n\t\t\t\tstore.schema.types.instance.create({\n\t\t\t\t\tid: DrINSTANCE_ID,\n\t\t\t\t\tcurrentPageId: getFirstPageId(),\n\t\t\t\t\texportBackground: true,\n\t\t\t\t}),\n\t\t\t])\n\n\t\t\treturn ensureStoreIsUsable()\n\t\t} else if (!pageIds.has(instanceState.currentPageId)) {\n\t\t\tstore.put([{ ...instanceState, currentPageId: getFirstPageId() }])\n\t\t\treturn ensureStoreIsUsable()\n\t\t}\n\n\t\t// make sure we have page states and cameras for all the pages\n\t\tconst missingPageStateIds = new Set<DrInstancePageStateId>()\n\t\tconst missingCameraIds = new Set<DrCameraId>()\n\t\tfor (const id of pageIds) {\n\t\t\tconst pageStateId = InstancePageStateRecordType.createId(id)\n\t\t\tconst pageState = store.get(pageStateId)\n\t\t\tif (!pageState) {\n\t\t\t\tmissingPageStateIds.add(pageStateId)\n\t\t\t}\n\t\t\tconst cameraId = CameraRecordType.createId(id)\n\t\t\tif (!store.has(cameraId)) {\n\t\t\t\tmissingCameraIds.add(cameraId)\n\t\t\t}\n\t\t}\n\n\t\tif (missingPageStateIds.size > 0) {\n\t\t\tstore.put(\n\t\t\t\t[...missingPageStateIds].map((id) =>\n\t\t\t\t\tInstancePageStateRecordType.create({\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tpageId: InstancePageStateRecordType.parseId(id) as DrPageId,\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t)\n\t\t}\n\n\t\tif (missingCameraIds.size > 0) {\n\t\t\tstore.put([...missingCameraIds].map((id) => CameraRecordType.create({ id })))\n\t\t}\n\n\t\tconst pageStates = $pageStates.get()\n\t\tfor (const pageState of pageStates) {\n\t\t\tif (!pageIds.has(pageState.pageId)) {\n\t\t\t\tstore.remove([pageState.id])\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (pageState.croppingShapeId && !store.has(pageState.croppingShapeId)) {\n\t\t\t\tstore.put([{ ...pageState, croppingShapeId: null }])\n\t\t\t\treturn ensureStoreIsUsable()\n\t\t\t}\n\t\t\tif (pageState.focusedGroupId && !store.has(pageState.focusedGroupId)) {\n\t\t\t\tstore.put([{ ...pageState, focusedGroupId: null }])\n\t\t\t\treturn ensureStoreIsUsable()\n\t\t\t}\n\t\t\tif (pageState.hoveredShapeId && !store.has(pageState.hoveredShapeId)) {\n\t\t\t\tstore.put([{ ...pageState, hoveredShapeId: null }])\n\t\t\t\treturn ensureStoreIsUsable()\n\t\t\t}\n\t\t\tconst filteredSelectedIds = pageState.selectedShapeIds.filter((id) => store.has(id))\n\t\t\tif (filteredSelectedIds.length !== pageState.selectedShapeIds.length) {\n\t\t\t\tstore.put([{ ...pageState, selectedShapeIds: filteredSelectedIds }])\n\t\t\t\treturn ensureStoreIsUsable()\n\t\t\t}\n\t\t\tconst filteredHintingIds = pageState.hintingShapeIds.filter((id) => store.has(id))\n\t\t\tif (filteredHintingIds.length !== pageState.hintingShapeIds.length) {\n\t\t\t\tstore.put([{ ...pageState, hintingShapeIds: filteredHintingIds }])\n\t\t\t\treturn ensureStoreIsUsable()\n\t\t\t}\n\t\t\tconst filteredErasingIds = pageState.erasingShapeIds.filter((id) => store.has(id))\n\t\t\tif (filteredErasingIds.length !== pageState.erasingShapeIds.length) {\n\t\t\t\tstore.put([{ ...pageState, erasingShapeIds: filteredErasingIds }])\n\t\t\t\treturn ensureStoreIsUsable()\n\t\t\t}\n\t\t}\n\t}\n\n\treturn ensureStoreIsUsable\n}\n","import { LegacyMigrations, MigrationSequence, StoreSchema, StoreValidator } from '@ibodr/store'\nimport { objectMapValues } from '@ibodr/utils'\nimport { T } from '@ibodr/validate'\nimport { DrBaseAsset } from './assets/DrBaseAsset'\nimport { bookmarkAssetMigrations, bookmarkAssetProps } from './assets/DrBookmarkAsset'\nimport { imageAssetMigrations, imageAssetProps } from './assets/DrImageAsset'\nimport { videoAssetMigrations, videoAssetProps } from './assets/DrVideoAsset'\nimport { arrowBindingMigrations, arrowBindingProps } from './bindings/DrArrowBinding'\nimport {\n\tDrDefaultAsset,\n\tDrUnknownAsset,\n\tassetMigrations,\n\tcreateAssetRecordType,\n} from './records/DrAsset'\nimport { DrBinding, DrDefaultBinding, createBindingRecordType } from './records/DrBinding'\nimport { CameraRecordType, cameraMigrations } from './records/DrCamera'\nimport {\n\tCustomRecordInfo,\n\tcreateCustomRecordType,\n\tprocessCustomRecordMigrations,\n} from './records/DrCustomRecord'\nimport { DocumentRecordType, documentMigrations } from './records/DrDocument'\nimport { createInstanceRecordType, instanceMigrations } from './records/DrInstance'\nimport { PageRecordType, pageMigrations } from './records/DrPage'\nimport { InstancePageStateRecordType, instancePageStateMigrations } from './records/DrPageState'\nimport { PointerRecordType, pointerMigrations } from './records/DrPointer'\nimport { InstancePresenceRecordType, instancePresenceMigrations } from './records/DrPresence'\nimport { DrRecord } from './records/DrRecord'\nimport {\n\tDrDefaultShape,\n\tDrShape,\n\tcreateShapeRecordType,\n\tgetShapePropKeysByStyle,\n\trootShapeMigrations,\n} from './records/DrShape'\nimport { UserRecordType, createUserRecordType, userMigrations } from './records/DrUser'\nimport { RecordProps, DrPropsMigrations, processPropsMigrations } from './recordsWithProps'\nimport { arrowShapeMigrations, arrowShapeProps } from './shapes/DrArrowShape'\nimport { DrBaseShape } from './shapes/DrBaseShape'\nimport { bookmarkShapeMigrations, bookmarkShapeProps } from './shapes/DrBookmarkShape'\nimport { drawShapeMigrations, drawShapeProps } from './shapes/DrDrawShape'\nimport { embedShapeMigrations, embedShapeProps } from './shapes/DrEmbedShape'\nimport { frameShapeMigrations, frameShapeProps } from './shapes/DrFrameShape'\nimport { geoShapeMigrations, geoShapeProps } from './shapes/DrGeoShape'\nimport { groupShapeMigrations, groupShapeProps } from './shapes/DrGroupShape'\nimport { highlightShapeMigrations, highlightShapeProps } from './shapes/DrHighlightShape'\nimport { imageShapeMigrations, imageShapeProps } from './shapes/DrImageShape'\nimport { lineShapeMigrations, lineShapeProps } from './shapes/DrLineShape'\nimport { noteShapeMigrations, noteShapeProps } from './shapes/DrNoteShape'\nimport { textShapeMigrations, textShapeProps } from './shapes/DrTextShape'\nimport { videoShapeMigrations, videoShapeProps } from './shapes/DrVideoShape'\nimport { storeMigrations } from './store-migrations'\nimport { StyleProp } from './styles/StyleProp'\nimport { DrStoreProps, createIntegrityChecker, onValidationFailure } from './DrStore'\n\n/**\n * Configuration information for a schema type (shape, binding, or asset), including its properties,\n * metadata, and migration sequences for data evolution over time.\n *\n * @public\n * @example\n * ```ts\n * import { arrowShapeMigrations, arrowShapeProps } from './shapes/DrArrowShape'\n *\n * const myShapeSchema: SchemaPropsInfo = {\n * migrations: arrowShapeMigrations,\n * props: arrowShapeProps,\n * meta: {\n * customField: T.string,\n * },\n * }\n * ```\n */\nexport interface SchemaPropsInfo {\n\t/**\n\t * Migration sequences for handling data evolution over time. Can be legacy migrations,\n\t * props-specific migrations, or general migration sequences.\n\t */\n\tmigrations?: LegacyMigrations | DrPropsMigrations | MigrationSequence\n\n\t/**\n\t * Validation schema for the shape, binding, or asset properties.\n\t */\n\tprops?: Record<string, StoreValidator<any>>\n\n\t/**\n\t * Validation schema for metadata fields.\n\t */\n\tmeta?: Record<string, StoreValidator<any>>\n}\n\n/**\n * The complete schema definition for a tldraw store, encompassing all record types,\n * validation rules, and migration sequences. This schema defines the structure of\n * the persistent data model used by tldraw.\n *\n * @public\n * @example\n * ```ts\n * import { createDrSchema, defaultShapeSchemas } from '@ibodr/schema'\n * import { Store } from '@ibodr/store'\n *\n * const schema: DrSchema = createDrSchema({\n * shapes: defaultShapeSchemas,\n * })\n *\n * const store = new Store({ schema })\n * ```\n */\nexport type DrSchema = StoreSchema<DrRecord, DrStoreProps>\n\n/**\n * Default shape schema configurations for all built-in tldraw shape types.\n * Each shape type includes its validation props and migration sequences.\n *\n * This object contains schema information for:\n * - arrow: Directional lines that can bind to other shapes\n * - bookmark: Website bookmark cards with preview information\n * - draw: Freehand drawing paths created with drawing tools\n * - embed: Embedded content from external services (YouTube, Figma, etc.)\n * - frame: Container shapes for organizing content\n * - geo: Geometric shapes (rectangles, ellipses, triangles, etc.)\n * - group: Logical groupings of multiple shapes\n * - highlight: Highlighting strokes from the highlighter tool\n * - image: Raster image shapes referencing image assets\n * - line: Multi-point lines and splines\n * - note: Sticky note shapes with text content\n * - text: Rich text shapes with formatting support\n * - video: Video shapes referencing video assets\n *\n * @public\n * @example\n * ```ts\n * import { createDrSchema, defaultShapeSchemas } from '@ibodr/schema'\n *\n * // Use all default shapes\n * const schema = createDrSchema({\n * shapes: defaultShapeSchemas,\n * })\n *\n * // Use only specific default shapes\n * const minimalSchema = createDrSchema({\n * shapes: {\n * geo: defaultShapeSchemas.geo,\n * text: defaultShapeSchemas.text,\n * },\n * })\n * ```\n */\nexport const defaultShapeSchemas = {\n\tarrow: { migrations: arrowShapeMigrations, props: arrowShapeProps },\n\tbookmark: { migrations: bookmarkShapeMigrations, props: bookmarkShapeProps },\n\tdraw: { migrations: drawShapeMigrations, props: drawShapeProps },\n\tembed: { migrations: embedShapeMigrations, props: embedShapeProps },\n\tframe: { migrations: frameShapeMigrations, props: frameShapeProps },\n\tgeo: { migrations: geoShapeMigrations, props: geoShapeProps },\n\tgroup: { migrations: groupShapeMigrations, props: groupShapeProps },\n\thighlight: { migrations: highlightShapeMigrations, props: highlightShapeProps },\n\timage: { migrations: imageShapeMigrations, props: imageShapeProps },\n\tline: { migrations: lineShapeMigrations, props: lineShapeProps },\n\tnote: { migrations: noteShapeMigrations, props: noteShapeProps },\n\ttext: { migrations: textShapeMigrations, props: textShapeProps },\n\tvideo: { migrations: videoShapeMigrations, props: videoShapeProps },\n} satisfies {\n\t[T in DrDefaultShape['type']]: {\n\t\tmigrations: SchemaPropsInfo['migrations']\n\t\tprops: RecordProps<DrBaseShape<T, Extract<DrDefaultShape, { type: T }>['props']>>\n\t}\n}\n\n/**\n * Default binding schema configurations for all built-in tldraw binding types.\n * Bindings represent relationships between shapes, such as arrows connected to shapes.\n *\n * Currently includes:\n * - arrow: Bindings that connect arrow shapes to other shapes at specific anchor points\n *\n * @public\n * @example\n * ```ts\n * import { createDrSchema, defaultBindingSchemas } from '@ibodr/schema'\n *\n * // Use default bindings\n * const schema = createDrSchema({\n * bindings: defaultBindingSchemas,\n * })\n *\n * // Add custom binding alongside defaults\n * const customSchema = createDrSchema({\n * bindings: {\n * ...defaultBindingSchemas,\n * myCustomBinding: {\n * props: myCustomBindingProps,\n * migrations: myCustomBindingMigrations,\n * },\n * },\n * })\n * ```\n */\nexport const defaultBindingSchemas = {\n\tarrow: { migrations: arrowBindingMigrations, props: arrowBindingProps },\n} satisfies { [T in DrDefaultBinding['type']]: SchemaPropsInfo }\n\n/**\n * Default asset schema configurations for all built-in tldraw asset types.\n *\n * @public\n * @example\n * ```ts\n * import { createDrSchema, defaultAssetSchemas } from '@ibodr/schema'\n *\n * const schema = createDrSchema({\n * assets: defaultAssetSchemas,\n * })\n * ```\n */\nexport const defaultAssetSchemas = {\n\timage: { migrations: imageAssetMigrations, props: imageAssetProps },\n\tvideo: { migrations: videoAssetMigrations, props: videoAssetProps },\n\tbookmark: { migrations: bookmarkAssetMigrations, props: bookmarkAssetProps },\n} satisfies {\n\t[T in DrDefaultAsset['type']]: {\n\t\tmigrations: SchemaPropsInfo['migrations']\n\t\tprops: RecordProps<DrBaseAsset<T, Extract<DrDefaultAsset, { type: T }>['props']>>\n\t}\n}\n\n/**\n * Configuration for extending the user record type with custom metadata\n * validators and migration sequences.\n *\n * @example\n * ```ts\n * import { T } from '@ibodr/validate'\n *\n * const userSchema: UserSchemaInfo = {\n * meta: {\n * isAdmin: T.boolean,\n * department: T.string,\n * },\n * }\n * ```\n *\n * @public\n */\nexport interface UserSchemaInfo {\n\t/**\n\t * Validators for custom metadata fields on user records. Each field is\n\t * treated as optional — user records without these fields remain valid,\n\t * but when present, values are validated against the provided validators.\n\t */\n\tmeta?: Record<string, T.Validatable<any>>\n\n\t/**\n\t * Additional migration sequences for evolving custom user data over time.\n\t */\n\tmigrations?: readonly MigrationSequence[]\n}\n\n/**\n * Creates a complete DrSchema for use with tldraw stores. This schema defines the structure,\n * validation, and migration sequences for all record types in a tldraw application.\n *\n * The schema includes all core record types (pages, cameras, instances, etc.) plus the\n * shape, binding, asset, and custom record types you specify. Style properties are\n * automatically collected from all shapes to ensure consistency across the application.\n *\n * @param options - Configuration options for the schema\n * - shapes - Shape schema configurations. Defaults to defaultShapeSchemas if not provided\n * - bindings - Binding schema configurations. Defaults to defaultBindingSchemas if not provided\n * - assets - Asset schema configurations. Defaults to defaultAssetSchemas if not provided\n * - user - Custom user record configuration with meta validators and migrations\n * - records - Custom record type configurations. These are additional record types beyond\n * the built-in shapes, bindings, assets, etc.\n * - migrations - Additional migration sequences to include in the schema\n * @returns A complete DrSchema ready for use with Store creation\n *\n * @public\n * @example\n * ```ts\n * import {\n * createDrSchema,\n * defaultShapeSchemas,\n * defaultBindingSchemas,\n * defaultAssetSchemas,\n * } from '@ibodr/schema'\n * import { Store } from '@ibodr/store'\n *\n * // Create schema with all default shapes, bindings, and assets\n * const schema = createDrSchema()\n *\n * // Create schema with custom shapes added\n * const customSchema = createDrSchema({\n * shapes: {\n * ...defaultShapeSchemas,\n * myCustomShape: {\n * props: myCustomShapeProps,\n * migrations: myCustomShapeMigrations,\n * },\n * },\n * bindings: defaultBindingSchemas,\n * assets: defaultAssetSchemas,\n * })\n *\n * // Create schema with custom user metadata\n * const schemaWithCustomUser = createDrSchema({\n * user: {\n * meta: {\n * isAdmin: T.boolean,\n * department: T.string,\n * },\n * },\n * })\n *\n * // Create schema with custom record types\n * const schemaWithCustomRecords = createDrSchema({\n * records: {\n * comment: {\n * scope: 'document',\n * validator: T.object({\n * id: T.string,\n * typeName: T.literal('comment'),\n * text: T.string,\n * shapeId: T.string,\n * }),\n * },\n * },\n * })\n *\n * // Use the schema with a store\n * const store = new Store({\n * schema: customSchema,\n * props: {\n * defaultName: 'My Drawing',\n * },\n * })\n * ```\n */\nexport function createDrSchema({\n\tshapes = defaultShapeSchemas,\n\tbindings = defaultBindingSchemas,\n\tassets = defaultAssetSchemas,\n\tuser,\n\trecords = {},\n\tmigrations,\n}: {\n\tshapes?: Record<string, SchemaPropsInfo>\n\tbindings?: Record<string, SchemaPropsInfo>\n\tassets?: Record<string, SchemaPropsInfo>\n\tuser?: UserSchemaInfo\n\trecords?: Record<string, CustomRecordInfo>\n\tmigrations?: readonly MigrationSequence[]\n} = {}): DrSchema {\n\tconst stylesById = new Map<string, StyleProp<unknown>>()\n\tfor (const shape of objectMapValues(shapes)) {\n\t\tfor (const style of getShapePropKeysByStyle(shape.props ?? {}).keys()) {\n\t\t\tif (stylesById.has(style.id) && stylesById.get(style.id) !== style) {\n\t\t\t\tthrow new Error(`Multiple StyleProp instances with the same id: ${style.id}`)\n\t\t\t}\n\t\t\tstylesById.set(style.id, style)\n\t\t}\n\t}\n\n\tconst ShapeRecordType = createShapeRecordType(shapes)\n\tconst BindingRecordType = createBindingRecordType(bindings)\n\tconst _AssetRecordType = createAssetRecordType(assets)\n\tconst InstanceRecordType = createInstanceRecordType(stylesById)\n\tconst CustomUserRecordType = user ? createUserRecordType(user) : UserRecordType\n\n\t// Create RecordTypes for custom records\n\tconst builtInTypeNames = new Set([\n\t\t'asset',\n\t\t'binding',\n\t\t'camera',\n\t\t'document',\n\t\t'instance',\n\t\t'instance_page_state',\n\t\t'page',\n\t\t'instance_presence',\n\t\t'pointer',\n\t\t'shape',\n\t\t'store',\n\t\t'user',\n\t])\n\tconst customRecordTypes: Record<string, { createId: any }> = {}\n\tfor (const [typeName, config] of Object.entries(records)) {\n\t\tif (builtInTypeNames.has(typeName)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Custom record type name '${typeName}' conflicts with tldraw's built-in record type of that name. Choose a different name instead.`\n\t\t\t)\n\t\t}\n\t\tcustomRecordTypes[typeName] = createCustomRecordType(typeName, config)\n\t}\n\n\treturn StoreSchema.create(\n\t\t{\n\t\t\tasset: _AssetRecordType,\n\t\t\tbinding: BindingRecordType,\n\t\t\tcamera: CameraRecordType,\n\t\t\tdocument: DocumentRecordType,\n\t\t\tinstance: InstanceRecordType,\n\t\t\tinstance_page_state: InstancePageStateRecordType,\n\t\t\tpage: PageRecordType,\n\t\t\tinstance_presence: InstancePresenceRecordType,\n\t\t\tpointer: PointerRecordType,\n\t\t\tshape: ShapeRecordType,\n\t\t\tuser: CustomUserRecordType,\n\t\t\t...customRecordTypes,\n\t\t},\n\t\t{\n\t\t\tmigrations: [\n\t\t\t\tstoreMigrations,\n\t\t\t\tassetMigrations,\n\t\t\t\tcameraMigrations,\n\t\t\t\tdocumentMigrations,\n\t\t\t\tinstanceMigrations,\n\t\t\t\tinstancePageStateMigrations,\n\t\t\t\tpageMigrations,\n\t\t\t\tinstancePresenceMigrations,\n\t\t\t\tpointerMigrations,\n\t\t\t\trootShapeMigrations,\n\n\t\t\t\tuserMigrations,\n\n\t\t\t\t...processPropsMigrations<DrUnknownAsset>('asset', assets),\n\t\t\t\t...processPropsMigrations<DrShape>('shape', shapes),\n\t\t\t\t...processPropsMigrations<DrBinding>('binding', bindings),\n\t\t\t\t...processCustomRecordMigrations(records),\n\n\t\t\t\t...(user?.migrations ?? []),\n\t\t\t\t...(migrations ?? []),\n\t\t\t],\n\t\t\tonValidationFailure,\n\t\t\tcreateIntegrityChecker,\n\t\t}\n\t)\n}\n","import { IndexKey } from '@ibodr/utils'\nimport { SetValue } from '../util-types'\n\n/**\n * All available handle types used by shapes in the tldraw editor.\n *\n * Handles are interactive control points on shapes that allow users to\n * modify the shape's geometry. Different handle types serve different purposes:\n *\n * - `vertex`: A control point that defines a vertex of the shape\n * - `virtual`: A handle that exists between vertices for adding new points\n * - `create`: A handle for creating new geometry (like extending a line)\n * - `clone`: A handle for duplicating or cloning shape elements\n *\n * @example\n * ```ts\n * // Check if a handle type is valid\n * if (TL_HANDLE_TYPES.has('vertex')) {\n * console.log('Valid handle type')\n * }\n *\n * // Get all available handle types\n * const allHandleTypes = Array.from(TL_HANDLE_TYPES)\n * ```\n *\n * @public\n */\nexport const TL_HANDLE_TYPES = new Set(['vertex', 'virtual', 'create', 'clone'] as const)\n\n/**\n * A union type representing all available handle types.\n *\n * Handle types determine how a handle behaves when interacted with and\n * what kind of shape modification it enables.\n *\n * @example\n * ```ts\n * const vertexHandle: DrHandleType = 'vertex'\n * const virtualHandle: DrHandleType = 'virtual'\n * const createHandle: DrHandleType = 'create'\n * const cloneHandle: DrHandleType = 'clone'\n * ```\n *\n * @public\n */\nexport type DrHandleType = SetValue<typeof TL_HANDLE_TYPES>\n\n/**\n * A handle object representing an interactive control point on a shape.\n *\n * Handles allow users to manipulate shape geometry by dragging control points.\n * Each handle has a position, type, and various properties that control its\n * behavior during interactions.\n *\n * @example\n * ```ts\n * // A vertex handle for a line endpoint\n * const lineEndHandle: DrHandle = {\n * id: 'end',\n * label: 'End point',\n * type: 'vertex',\n * canSnap: true,\n * index: 'a1',\n * x: 100,\n * y: 50\n * }\n *\n * // A virtual handle for adding new points\n * const virtualHandle: DrHandle = {\n * id: 'virtual-1',\n * type: 'virtual',\n * canSnap: false,\n * index: 'a1V',\n * x: 75,\n * y: 25\n * }\n *\n * // A create handle for extending geometry\n * const createHandle: DrHandle = {\n * id: 'create',\n * type: 'create',\n * canSnap: true,\n * index: 'a2',\n * x: 200,\n * y: 100\n * }\n * ```\n *\n * @public\n */\nexport interface DrHandle {\n\t/** A unique identifier for the handle within the shape */\n\tid: string\n\t/** Optional human-readable label for the handle */\n\t// TODO(mime): this needs to be required.\n\tlabel?: string\n\t/** The type of handle, determining its behavior and interaction mode */\n\ttype: DrHandleType\n\t/**\n\t * @deprecated Use `snapType` instead. Whether this handle should snap to other geometry during interactions.\n\t */\n\tcanSnap?: boolean\n\t/** The type of snap to use for this handle */\n\tsnapType?: 'point' | 'align'\n\t/** The ID of the handle to use as reference point for shift-modifier angle snapping */\n\tsnapReferenceHandleId?: string\n\t/** The fractional index used for ordering handles */\n\tindex: IndexKey\n\t/** The x-coordinate of the handle in the shape's local coordinate system */\n\tx: number\n\t/** The y-coordinate of the handle in the shape's local coordinate system */\n\ty: number\n}\n","// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\n/** @public */\nexport const LANGUAGES = [\n\t{ locale: 'id', label: 'Bahasa Indonesia' },\n\t{ locale: 'ms', label: 'Bahasa Melayu' },\n\t{ locale: 'ca', label: 'Català' },\n\t{ locale: 'cs', label: 'Čeština' },\n\t{ locale: 'da', label: 'Danish' },\n\t{ locale: 'de', label: 'Deutsch' },\n\t{ locale: 'en', label: 'English' },\n\t{ locale: 'es', label: 'Español' },\n\t{ locale: 'tl', label: 'Filipino' },\n\t{ locale: 'fr', label: 'Français' },\n\t{ locale: 'gl', label: 'Galego' },\n\t{ locale: 'hr', label: 'Hrvatski' },\n\t{ locale: 'it', label: 'Italiano' },\n\t{ locale: 'hu', label: 'Magyar' },\n\t{ locale: 'nl', label: 'Nederlands' },\n\t{ locale: 'no', label: 'Norwegian' },\n\t{ locale: 'pl', label: 'Polski' },\n\t{ locale: 'pt-br', label: 'Português - Brasil' },\n\t{ locale: 'pt-pt', label: 'Português - Europeu' },\n\t{ locale: 'ro', label: 'Română' },\n\t{ locale: 'sl', label: 'Slovenščina' },\n\t{ locale: 'so', label: 'Somali' },\n\t{ locale: 'fi', label: 'Suomi' },\n\t{ locale: 'sv', label: 'Svenska' },\n\t{ locale: 'vi', label: 'Tiếng Việt' },\n\t{ locale: 'tr', label: 'Türkçe' },\n\t{ locale: 'el', label: 'Ελληνικά' },\n\t{ locale: 'ru', label: 'Русский' },\n\t{ locale: 'uk', label: 'Українська' },\n\t{ locale: 'he', label: 'עברית' },\n\t{ locale: 'ur', label: 'اردو' },\n\t{ locale: 'ar', label: 'عربي' },\n\t{ locale: 'fa', label: 'فارسی' },\n\t{ locale: 'ne', label: 'नेपाली' },\n\t{ locale: 'mr', label: 'मराठी' },\n\t{ locale: 'hi-in', label: 'हिन्दी' },\n\t{ locale: 'bn', label: 'বাংলা' },\n\t{ locale: 'pa', label: 'ਪੰਜਾਬੀ' },\n\t{ locale: 'gu-in', label: 'ગુજરાતી' },\n\t{ locale: 'ta', label: 'தமிழ்' },\n\t{ locale: 'te', label: 'తెలుగు' },\n\t{ locale: 'kn', label: 'ಕನ್ನಡ' },\n\t{ locale: 'ml', label: 'മലയാളം' },\n\t{ locale: 'th', label: 'ภาษาไทย' },\n\t{ locale: 'km-kh', label: 'ភាសាខ្មែរ' },\n\t{ locale: 'ko-kr', label: '한국어' },\n\t{ locale: 'ja', label: '日本語' },\n\t{ locale: 'zh-cn', label: '简体中文' },\n\t{ locale: 'zh-tw', label: '繁體中文 (台灣)' },\n] as const\n","import { LANGUAGES } from './languages'\n\n/** @public */\nexport { LANGUAGES }\n\n/**\n * A language definition object representing a supported localization in tldraw.\n *\n * Derived from the LANGUAGES array, this type represents a single language entry\n * containing a locale identifier and human-readable label. The locale follows\n * BCP 47 standards (e.g., 'en', 'fr', 'zh-CN') and the label is in the native language.\n *\n * @example\n * ```ts\n * import { DrLanguage } from '@ibodr/schema'\n *\n * // Using DrLanguage type\n * const currentLanguage: DrLanguage = { locale: 'fr', label: 'Français' }\n *\n * // Access locale and label\n * console.log(currentLanguage.locale) // \"fr\"\n * console.log(currentLanguage.label) // \"Français\"\n * ```\n *\n * @public\n */\nexport type DrLanguage = (typeof LANGUAGES)[number]\n\n/**\n * Gets the default translation locale based on the user's browser language preferences.\n *\n * This function determines the best matching locale from the user's browser language\n * settings, falling back to English if no suitable match is found. It works in both\n * browser and server-side environments, defaulting to English on the server.\n *\n * The function prioritizes exact matches first, then falls back to language-only\n * matches, and finally uses predefined regional defaults for languages like Chinese,\n * Portuguese, Korean, and Hindi.\n *\n * @returns The locale identifier (e.g., 'en', 'fr', 'zh-cn') that best matches the user's preferences\n *\n * @example\n * ```ts\n * import { getDefaultTranslationLocale } from '@ibodr/schema'\n *\n * // Get the user's preferred locale\n * const locale = getDefaultTranslationLocale()\n * console.log(locale) // e.g., \"fr\" or \"en\" or \"zh-cn\"\n *\n * // Use in localization setup\n * const i18n = new I18n({\n * locale,\n * // ... other config\n * })\n * ```\n *\n * @example\n * ```ts\n * // Browser with languages: ['fr-CA', 'en-US']\n * const locale = getDefaultTranslationLocale()\n * console.log(locale) // \"fr\" (if French is supported)\n *\n * // Browser with languages: ['zh']\n * const locale = getDefaultTranslationLocale()\n * console.log(locale) // \"zh-cn\" (default region for Chinese)\n * ```\n *\n * @public\n */\nexport function getDefaultTranslationLocale(): DrLanguage['locale'] {\n\tconst locales =\n\t\ttypeof window !== 'undefined' && window.navigator\n\t\t\t? (window.navigator.languages ?? ['en'])\n\t\t\t: ['en']\n\treturn _getDefaultTranslationLocale(locales)\n}\n\n/**\n * Internal function that determines the default translation locale from a list of locale preferences.\n *\n * This function is the core logic for locale resolution, separated from browser-specific code\n * for easier testing and reuse. It iterates through the provided locales in priority order\n * and returns the first supported locale found, or 'en' as the ultimate fallback.\n *\n * @param locales - Array of locale identifiers in preference order (e.g., from navigator.languages)\n * @returns The best matching supported locale identifier\n *\n * @example\n * ```ts\n *\n * // Test locale resolution\n * const locale = _getDefaultTranslationLocale(['fr-CA', 'en-US', 'es'])\n * console.log(locale) // \"fr\" (if French is supported)\n *\n * // No supported locales\n * const fallback = _getDefaultTranslationLocale(['xx-YY', 'zz-AA'])\n * console.log(fallback) // \"en\"\n * ```\n *\n * @internal\n */\nexport function _getDefaultTranslationLocale(locales: readonly string[]): DrLanguage['locale'] {\n\tfor (const locale of locales) {\n\t\tconst supportedLocale = getSupportedLocale(locale)\n\t\tif (supportedLocale) {\n\t\t\treturn supportedLocale\n\t\t}\n\t}\n\treturn 'en'\n}\n\n/**\n * Default regional variants for languages that have multiple regional versions.\n *\n * When a user's locale contains only a language code (e.g., 'zh', 'pt') but tldraw\n * only supports region-specific variants, this mapping determines which regional\n * variant to use as the default. This ensures users get the most appropriate\n * localization even when their preference doesn't specify a region.\n *\n *\n * @example\n * ```ts\n * // User has locale preference \"zh\" but we only support \"zh-cn\" and \"zh-tw\"\n * const defaultRegion = DEFAULT_LOCALE_REGIONS['zh']\n * console.log(defaultRegion) // \"zh-cn\"\n *\n * // User has locale preference \"pt\" but we support \"pt-br\" and \"pt-pt\"\n * const defaultRegion = DEFAULT_LOCALE_REGIONS['pt']\n * console.log(defaultRegion) // \"pt-br\"\n * ```\n *\n * @public\n */\nconst DEFAULT_LOCALE_REGIONS: { [locale: string]: DrLanguage['locale'] } = {\n\tzh: 'zh-cn',\n\tpt: 'pt-br',\n\tko: 'ko-kr',\n\thi: 'hi-in',\n}\n\n/**\n * Finds a supported locale that matches the given locale identifier.\n *\n * This function implements a flexible locale matching algorithm that tries multiple\n * strategies to find the best available translation:\n *\n * 1. **Exact match**: Looks for an exact locale match (case-insensitive)\n * 2. **Language-only match**: If the input has a region, tries matching just the language\n * 3. **Default region**: If the input lacks a region, uses the default region for that language\n * 4. **No match**: Returns null if no suitable locale is found\n *\n * @param locale - The locale identifier to match (e.g., 'fr-CA', 'pt', 'zh-TW')\n * @returns The matching supported locale identifier, or null if no match is found\n *\n * @example\n * ```ts\n * // Exact matches\n * getSupportedLocale('fr') // \"fr\" (if supported)\n * getSupportedLocale('PT-BR') // \"pt-br\" (case insensitive)\n *\n * // Language-only fallback\n * getSupportedLocale('fr-CA') // \"fr\" (if we only support generic French)\n *\n * // Default region assignment\n * getSupportedLocale('zh') // \"zh-cn\" (default Chinese region)\n *\n * // No match\n * getSupportedLocale('xyz') // null\n * ```\n *\n * @example\n * ```ts\n * // Usage in locale resolution\n * const userLocales = ['es-MX', 'en-US']\n * for (const userLocale of userLocales) {\n * const supported = getSupportedLocale(userLocale)\n * if (supported) {\n * console.log(`Using locale: ${supported}`)\n * break\n * }\n * }\n * ```\n *\n * @public\n */\nfunction getSupportedLocale(locale: string): DrLanguage['locale'] | null {\n\t// If we have an exact match, return it!\n\t// (e.g. if the user has 'fr' and we have 'fr')\n\t// (or if the user has 'pt-BR' and we have 'pt-br')\n\tconst exactMatch = LANGUAGES.find((t) => t.locale === locale.toLowerCase())\n\tif (exactMatch) {\n\t\treturn exactMatch.locale\n\t}\n\n\t// Otherwise, we need to be more flexible...\n\tconst [language, region] = locale.split(/[-_]/).map((s) => s.toLowerCase())\n\n\t// If the user's language has a region...\n\t// let's try to find non-region-specific locale for them\n\t// (e.g. if they have 'fr-CA' but we only have 'fr')\n\tif (region) {\n\t\tconst languageMatch = LANGUAGES.find((t) => t.locale === language)\n\t\tif (languageMatch) {\n\t\t\treturn languageMatch.locale\n\t\t}\n\t}\n\n\t// If the user's language doesn't have a region...\n\t// let's try to find a region-specific locale for them\n\t// (e.g. if they have 'pt' but we only have 'pt-pt' or 'pt-br')\n\t//\n\t// In this case, we choose the hard-coded default region for that language\n\tif (language in DEFAULT_LOCALE_REGIONS) {\n\t\treturn DEFAULT_LOCALE_REGIONS[language]\n\t}\n\n\t// Oh no! We don't have a translation for this language!\n\t// Let's give up...\n\treturn null\n}\n","/**\n * @fileoverview\n * Main entry point for the tldraw schema package. Exports the complete type system,\n * data structures, validation, and migrations for tldraw's persisted data.\n *\n * This package provides:\n * - Schema creation utilities (createDrSchema, defaultShapeSchemas, defaultBindingSchemas)\n * - All built-in shape types (DrGeoShape, DrTextShape, DrArrowShape, etc.)\n * - Asset management types and validators (DrImageAsset, DrVideoAsset, DrBookmarkAsset)\n * - Binding system for shape relationships (DrArrowBinding)\n * - Store integration types (DrStore, DrStoreProps, DrStoreSnapshot)\n * - Style properties for consistent styling (DefaultColorStyle, DefaultSizeStyle, etc.)\n * - Validation utilities and type guards\n * - Migration systems for schema evolution\n * - Geometry and utility types\n *\n * @example\n * ```ts\n * import { createDrSchema, defaultShapeSchemas, DrStore } from '@ibodr/schema'\n *\n * // Create a schema with default shapes\n * const schema = createDrSchema({\n * shapes: defaultShapeSchemas\n * })\n *\n * // Use with a store\n * const store = new Store({ schema })\n * ```\n *\n * @public\n */\n\nimport { registerDrawLibraryVersion } from '@ibodr/utils'\nexport { assetIdValidator, createAssetValidator, type DrBaseAsset } from './assets/DrBaseAsset'\nexport {\n\tbookmarkAssetMigrations,\n\tbookmarkAssetProps,\n\ttype DrBookmarkAsset,\n} from './assets/DrBookmarkAsset'\nexport { imageAssetMigrations, imageAssetProps, type DrImageAsset } from './assets/DrImageAsset'\nexport { videoAssetMigrations, videoAssetProps, type DrVideoAsset } from './assets/DrVideoAsset'\nexport {\n\tarrowBindingMigrations,\n\tarrowBindingProps,\n\tarrowBindingVersions,\n\tElbowArrowSnap,\n\ttype DrArrowBinding,\n\ttype DrArrowBindingProps,\n} from './bindings/DrArrowBinding'\nexport {\n\tbindingIdValidator,\n\tcreateBindingValidator,\n\ttype DrBaseBinding,\n} from './bindings/DrBaseBinding'\nexport {\n\tcreatePresenceStateDerivation,\n\tgetDefaultUserPresence,\n\ttype CreatePresenceStateDerivationOpts,\n\ttype DrPresenceStateInfo,\n} from './createPresenceStateDerivation'\nexport {\n\tcreateDrSchema,\n\tdefaultAssetSchemas,\n\tdefaultBindingSchemas,\n\tdefaultShapeSchemas,\n\ttype SchemaPropsInfo,\n\ttype DrSchema,\n\ttype UserSchemaInfo,\n} from './createDrSchema'\nexport {\n\tboxModelValidator,\n\tvecModelValidator,\n\ttype BoxModel,\n\ttype VecModel,\n} from './misc/geometry-types'\nexport { idValidator } from './misc/id-validator'\nexport {\n\tcanvasUiColorTypeValidator,\n\tTL_CANVAS_UI_COLOR_TYPES,\n\ttype DrCanvasUiColor,\n} from './misc/DrColor'\nexport { TL_CURSOR_TYPES, type DrCursor, type DrCursorType } from './misc/DrCursor'\nexport { TL_HANDLE_TYPES, type DrHandle, type DrHandleType } from './misc/DrHandle'\nexport { opacityValidator, type DrOpacityType } from './misc/DrOpacity'\nexport { richTextValidator, toRichText, type DrRichText } from './misc/DrRichText'\nexport { scribbleValidator, TL_SCRIBBLE_STATES, type DrScribble } from './misc/DrScribble'\nexport {\n\tassetMigrations,\n\tAssetRecordType,\n\tcreateAssetPropsMigrationIds,\n\tcreateAssetPropsMigrationSequence,\n\tcreateAssetRecordType,\n\ttype DrAsset,\n\ttype DrAssetId,\n\ttype DrAssetPartial,\n\ttype DrAssetShape,\n\ttype DrDefaultAsset,\n\ttype DrGlobalAssetPropsMap,\n\ttype DrIndexedAssets,\n\ttype DrUnknownAsset,\n} from './records/DrAsset'\nexport {\n\tcreateBindingId,\n\tcreateBindingPropsMigrationIds,\n\tcreateBindingPropsMigrationSequence,\n\tisBinding,\n\tisBindingId,\n\trootBindingMigrations,\n\ttype DrBinding,\n\ttype DrBindingCreate,\n\ttype DrBindingId,\n\ttype DrBindingUpdate,\n\ttype DrDefaultBinding,\n\ttype DrGlobalBindingPropsMap,\n\ttype DrIndexedBindings,\n\ttype DrUnknownBinding,\n} from './records/DrBinding'\nexport { CameraRecordType, type DrCamera, type DrCameraId } from './records/DrCamera'\nexport {\n\tcreateCustomRecordId,\n\tcreateCustomRecordMigrationIds,\n\tcreateCustomRecordMigrationSequence,\n\tisCustomRecord,\n\tisCustomRecordId,\n\ttype CustomRecordInfo,\n} from './records/DrCustomRecord'\nexport {\n\tDocumentRecordType,\n\tisDocument,\n\tDrDOCUMENT_ID,\n\ttype DrDocument,\n} from './records/DrDocument'\nexport {\n\tpluckPreservingValues,\n\tDrINSTANCE_ID,\n\ttype DrInstance,\n\ttype DrInstanceId,\n} from './records/DrInstance'\nexport {\n\tisPageId,\n\tpageIdValidator,\n\tPageRecordType,\n\ttype DrPage,\n\ttype DrPageId,\n} from './records/DrPage'\nexport {\n\tInstancePageStateRecordType,\n\ttype DrInstancePageState,\n\ttype DrInstancePageStateId,\n} from './records/DrPageState'\nexport {\n\tPointerRecordType,\n\tDrPOINTER_ID,\n\ttype DrPointer,\n\ttype DrPointerId,\n} from './records/DrPointer'\nexport {\n\tInstancePresenceRecordType,\n\ttype DrInstancePresence,\n\ttype DrInstancePresenceID,\n} from './records/DrPresence'\nexport {\n\ttype DrCustomRecord,\n\ttype DrDefaultRecord,\n\ttype DrGlobalRecordPropsMap,\n\ttype DrIndexedRecords,\n\ttype DrRecord,\n} from './records/DrRecord'\nexport {\n\tcreateShapeId,\n\tcreateShapePropsMigrationIds,\n\tcreateShapePropsMigrationSequence,\n\tgetShapePropKeysByStyle,\n\tisShape,\n\tisShapeId,\n\trootShapeMigrations,\n\ttype ExtractShapeByProps,\n\ttype DrCreateShapePartial,\n\ttype DrDefaultShape,\n\ttype DrGlobalShapePropsMap,\n\ttype DrIndexedShapes,\n\ttype DrParentId,\n\ttype DrShape,\n\ttype DrShapeId,\n\ttype DrShapePartial,\n\ttype DrUnknownShape,\n} from './records/DrShape'\nexport {\n\tcreateUserId,\n\tcreateUserRecordType,\n\tisUserId,\n\tuserIdValidator,\n\tUserRecordType,\n\ttype DrUser,\n\ttype DrUserId,\n} from './records/DrUser'\nexport {\n\ttype RecordProps,\n\ttype RecordPropsType,\n\ttype DrPropsMigration,\n\ttype DrPropsMigrations,\n} from './recordsWithProps'\nexport { type ShapeWithCrop, type DrShapeCrop } from './shapes/ShapeWithCrop'\nexport {\n\tArrowShapeArrowheadEndStyle,\n\tArrowShapeArrowheadStartStyle,\n\tArrowShapeKindStyle,\n\tarrowShapeMigrations,\n\tarrowShapeProps,\n\tarrowShapeVersions,\n\ttype DrArrowShape,\n\ttype DrArrowShapeArrowheadStyle,\n\ttype DrArrowShapeKind,\n\ttype DrArrowShapeProps,\n} from './shapes/DrArrowShape'\nexport {\n\tcreateShapeValidator,\n\tparentIdValidator,\n\tshapeIdValidator,\n\ttype DrBaseShape,\n} from './shapes/DrBaseShape'\nexport {\n\tbookmarkShapeMigrations,\n\tbookmarkShapeProps,\n\ttype DrBookmarkShape,\n\ttype DrBookmarkShapeProps,\n} from './shapes/DrBookmarkShape'\nexport {\n\tcompressLegacySegments,\n\tdrawShapeMigrations,\n\tdrawShapeProps,\n\ttype DrDrawShape,\n\ttype DrDrawShapeProps,\n\ttype DrDrawShapeSegment,\n} from './shapes/DrDrawShape'\nexport {\n\tembedShapeMigrations,\n\tembedShapeProps,\n\ttype DrEmbedShape,\n\ttype DrEmbedShapeProps,\n} from './shapes/DrEmbedShape'\nexport {\n\tframeShapeMigrations,\n\tframeShapeProps,\n\ttype DrFrameShape,\n\ttype DrFrameShapeProps,\n} from './shapes/DrFrameShape'\nexport {\n\tGeoShapeGeoStyle,\n\tgeoShapeMigrations,\n\tgeoShapeProps,\n\ttype DrGeoShape,\n\ttype DrGeoShapeGeoStyle,\n\ttype DrGeoShapeProps,\n} from './shapes/DrGeoShape'\nexport {\n\tgroupShapeMigrations,\n\tgroupShapeProps,\n\ttype DrGroupShape,\n\ttype DrGroupShapeProps,\n} from './shapes/DrGroupShape'\nexport {\n\thighlightShapeMigrations,\n\thighlightShapeProps,\n\ttype DrHighlightShape,\n\ttype DrHighlightShapeProps,\n} from './shapes/DrHighlightShape'\nexport {\n\tImageShapeCrop,\n\timageShapeMigrations,\n\timageShapeProps,\n\ttype DrImageShape,\n\ttype DrImageShapeProps,\n} from './shapes/DrImageShape'\nexport {\n\tlineShapeMigrations,\n\tlineShapeProps,\n\tLineShapeSplineStyle,\n\ttype DrLineShape,\n\ttype DrLineShapePoint,\n\ttype DrLineShapeProps,\n\ttype DrLineShapeSplineStyle,\n} from './shapes/DrLineShape'\nexport {\n\tnoteShapeMigrations,\n\tnoteShapeProps,\n\ttype DrNoteShape,\n\ttype DrNoteShapeProps,\n} from './shapes/DrNoteShape'\nexport {\n\ttextShapeMigrations,\n\ttextShapeProps,\n\ttype DrTextShape,\n\ttype DrTextShapeProps,\n} from './shapes/DrTextShape'\nexport {\n\tvideoShapeMigrations,\n\tvideoShapeProps,\n\ttype DrVideoShape,\n\ttype DrVideoShapeProps,\n} from './shapes/DrVideoShape'\nexport { EnumStyleProp, StyleProp, type StylePropValue } from './styles/StyleProp'\nexport {\n\tDefaultColorStyle,\n\tregisterColorsFromThemes,\n\ttype DrDefaultColorStyle,\n} from './styles/DrColorStyle'\nexport { DefaultDashStyle, type DrDefaultDashStyle } from './styles/DrDashStyle'\nexport { DefaultFillStyle, type DrDefaultFillStyle } from './styles/DrFillStyle'\nexport { type DrFontFace, type DrFontFaceSource } from './styles/DrFontFace'\nexport {\n\tDefaultFontFamilies,\n\tDefaultFontStyle,\n\tisFontEntry,\n\tregisterFontsFromThemes,\n\ttype DrDefaultFontStyle,\n} from './styles/DrFontStyle'\nexport {\n\tDefaultHorizontalAlignStyle,\n\ttype DrDefaultHorizontalAlignStyle,\n} from './styles/DrHorizontalAlignStyle'\nexport { DefaultSizeStyle, type DrDefaultSizeStyle } from './styles/DrSizeStyle'\nexport { DefaultTextAlignStyle, type DrDefaultTextAlignStyle } from './styles/DrTextAlignStyle'\nexport {\n\ttype DrDefaultColor,\n\ttype DrRemovedDefaultThemeColors,\n\ttype DrTheme,\n\ttype DrThemeColors,\n\ttype DrThemeDefaultColors,\n\ttype DrThemeFont,\n\ttype DrThemeFonts,\n\ttype DrThemeId,\n\ttype DrThemes,\n\ttype DrThemeUiColorKeys,\n} from './styles/DrTheme'\nexport {\n\tDefaultVerticalAlignStyle,\n\ttype DrDefaultVerticalAlignStyle,\n} from './styles/DrVerticalAlignStyle'\nexport {\n\tcreateCachedUserResolve,\n\ttype DrAssetContext,\n\ttype DrAssetStore,\n\ttype DrSerializedStore,\n\ttype DrStore,\n\ttype DrStoreProps,\n\ttype DrStoreSchema,\n\ttype DrStoreSnapshot,\n\ttype DrUserStore,\n} from './DrStore'\nexport {\n\tgetDefaultTranslationLocale,\n\tLANGUAGES,\n\ttype DrLanguage,\n} from './translations/translations'\nexport { type SetValue } from './util-types'\n\nregisterDrawLibraryVersion(\n\t(globalThis as any).DRAW_LIBRARY_NAME,\n\t(globalThis as any).DRAW_LIBRARY_VERSION,\n\t(globalThis as any).DRAW_LIBRARY_MODULES\n)\n\nexport { b64Vecs } from './misc/b64Vecs'\n"]}