1/**2 * Clone authored data at module boundaries.3 *4 * Runtime pack records use structuredClone when available. Shared payloads5 * use cloneJsonData to materialize the JSON representation before encoding.6 */7export function cloneData(value) {8 return typeof structuredClone === 'function'9 ? structuredClone(value)10 : JSON.parse(JSON.stringify(value));11}1213export function cloneJsonData(value, label = 'data') {14 try {15 return JSON.parse(JSON.stringify(value));16 } catch (error) {17 throw new TypeError(`${label} must contain JSON data: ${error.message}`);18 }19}