hunk.code_window: {
   	"name": "@tldraw/state",
   	"description": "A tiny little drawing app (state).",
   	"version": "2.0.0-beta.0",
   	"packageManager": "yarn@3.5.0",
   	"author": {
   		"name": "tldraw GB Ltd.",
   		"email": "hello@tldraw.com"
   	},
  
hunk.labels: keep keep keep replace keep keep keep keep keep
hunk.after_edit: 	"version": "2.0.0-alpha.17",
  
hunk.file_path: packages/state/package.json
hunk.type: replace
file: import { Editor, getIndexAbove, getIndexBelow, getIndexBetween, TLPageId } from '@tldraw/editor'
  
  export const onMovePage = (editor: Editor, id: TLPageId, from: number, to: number) => {
  	let index: string
  
  	const pages = editor.pages
  
  	const below = from > to ? pages[to - 1] : pages[to]
  	const above = from > to ? pages[to] : pages[to + 1]
  
  	if (below && !above) {
  		index = getIndexAbove(below.index)
  	} else if (!below && above) {
  		index = getIndexBelow(pages[0].index)
  	} else {
  		index = getIndexBetween(below.index, above.index)
  	}
  
  	if (index !== pages[from].index) {
  		editor.mark('moving page')
  		editor.updatePage({
  			id: id as TLPageId,
  			index,
  		})
  	}
  }
  