{"version":3,"file":"registry-box-DqMHD5YJ.cjs","sources":["../../src/constants.ts","../../src/utils/internal/boxes.ts","../../src/utils/internal/bytes.ts","../../src/utils/nfd.ts","../../src/utils/internal/nfd.ts","../../src/utils/internal/state.ts","../../src/utils/internal/nfd-record.ts","../../src/utils/internal/registry-box.ts"],"sourcesContent":["/** The NFD registry app IDs for each network */\nexport enum NfdRegistryId {\n  MAINNET = 760937186,\n  TESTNET = 84366825,\n}\n\n/** The default sender addresses (fee sinks) for each network */\nexport enum DefaultSender {\n  MAINNET = 'Y76M3MSY6DKBRHBL7C3NNDXGS5IIMQVQVUAB6MP4XEMMGVF2QWNPL226CA',\n  TESTNET = 'A7NMWS3NT3IUDMLVO26ULGXGIIOUQ3ND2TXSER6EBGRZNOBOUIQXHIBGDE',\n}\n\n/** The Algorand zero address (all zeros, used as a placeholder for \"no address\") */\nexport const ALGORAND_ZERO_ADDRESS =\n  'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ'\n\n/**\n * Static fee (in microAlgos) covering an NFD app call and the inner\n * transactions it issues\n */\nexport const APP_CALL_STATIC_FEE = 3000n\n\n/** Static fee (in microAlgos) for an NFD renewal, which issues more inners */\nexport const RENEW_STATIC_FEE = 5000n\n\n/**\n * Additional fee (in microAlgos) per asset in a vault operation, covering the\n * inner transaction the contract issues for each one\n */\nexport const VAULT_FEE_PER_ASSET = 1000n\n\n/**\n * Minimum balance (in microAlgos) the vault needs per asset it opts into\n *\n * `vaultOptIn` verifies that the transaction immediately before it pays the\n * vault exactly this much per asset in the call, and it is charged whether or\n * not the vault is already opted into that asset.\n */\nexport const VAULT_OPT_IN_MBR = 100_000n\n\n/** The base URLs for the NFD API for each network */\nexport enum NfdApiBaseUrl {\n  MAINNET = 'https://api.nf.domains',\n  TESTNET = 'https://api.testnet.nf.domains',\n}\n","import type { Algodv2 } from 'algosdk'\n\n/**\n * An application box, with its name decoded and its value included\n */\nexport interface AppBox {\n  /** The box name, decoded as UTF-8 */\n  name: string\n  /** The box value */\n  value: Uint8Array\n}\n\n/**\n * Get every box for an application, with values included\n *\n * Uses the `include=values` query parameter so that names and values arrive\n * together, which takes one request per page rather than one request per box.\n * Pages after the first are pinned to the round the first page was read at, so\n * a multi-page read is consistent.\n *\n * Requires algosdk >= 3.6.0 and an algod node new enough to honour\n * `include=values`.\n *\n * @param algod - The algod client to read through\n * @param appId - The application ID to read boxes from\n * @returns Every box for the application\n * @throws If the node returns boxes without values, or does not advance the\n * pagination cursor\n */\nexport async function getAllBoxes(\n  algod: Algodv2,\n  appId: bigint,\n): Promise<AppBox[]> {\n  const decoder = new TextDecoder('utf-8')\n  const boxes: AppBox[] = []\n\n  // The algod endpoint is caller-supplied, so the cursor is not trusted to\n  // advance on its own; a repeated token would otherwise loop forever\n  const seenTokens = new Set<string>()\n\n  let nextToken: string | undefined\n  let round: number | undefined\n\n  do {\n    const request = algod.getApplicationBoxes(appId).include('values')\n\n    if (nextToken) {\n      request.next(nextToken)\n    }\n    if (round !== undefined) {\n      request.round(round)\n    }\n\n    const response = await request.do()\n    round ??= response.round\n\n    for (const box of response.boxes) {\n      if (box.value === undefined) {\n        throw new Error(\n          `Box \"${decoder.decode(box.name)}\" of app ${appId} was returned without a value. ` +\n            'The algod node does not support the `include=values` query parameter; ' +\n            'a newer node is required.',\n        )\n      }\n\n      boxes.push({\n        name: decoder.decode(box.name),\n        value: box.value,\n      })\n    }\n\n    nextToken = response.nextToken\n\n    if (nextToken) {\n      if (seenTokens.has(nextToken)) {\n        throw new Error(\n          `Box pagination for app ${appId} did not advance: the algod node repeated a page cursor.`,\n        )\n      }\n      seenTokens.add(nextToken)\n    }\n  } while (nextToken)\n\n  return boxes\n}\n","/**\n * Convert a string to a Uint8Array\n * @param str - The string to convert\n * @returns The string as a Uint8Array\n */\nexport function strToUint8Array(str: string): Uint8Array {\n  return new Uint8Array(str.length).map((_, i) => str.charCodeAt(i))\n}\n\n/**\n * Concatenate any number of Uint8Arrays\n * @param arrays - The arrays to concatenate, in order\n * @returns The concatenated array\n */\nexport function concatUint8Arrays(...arrays: Uint8Array[]): Uint8Array {\n  const totalLength = arrays.reduce((total, array) => total + array.length, 0)\n  const concatenatedArray = new Uint8Array(totalLength)\n\n  // Set each array's values starting from the end of the previous one\n  let offset = 0\n  for (const array of arrays) {\n    concatenatedArray.set(array, offset)\n    offset += array.length\n  }\n\n  return concatenatedArray\n}\n\n/**\n * Check if a Uint8Array contains only zero bytes\n * @param array - The array to check\n * @returns True if all bytes are zero, false otherwise\n */\nexport function isZeroBytes(array: Uint8Array): boolean {\n  return array.every((byte) => byte === 0)\n}\n","import type { Nfd } from '../types'\n\n/**\n * Check if segment minting is unlocked for an NFD\n * @param nfd - The NFD object to check\n * @returns True if segment minting is unlocked, false otherwise\n *\n * Note: By default, segment minting is locked when a root NFD is created.\n * The segmentLocked property is only set to '0' when explicitly unlocked.\n * If the property doesn't exist or is set to any value other than '0',\n * segment minting should be considered locked.\n */\nexport function isSegmentMintingUnlocked(nfd: Nfd | null): boolean {\n  if (!nfd) return false\n  return nfd.properties?.internal?.segmentLocked === '0'\n}\n\n/**\n * Check if the caller is authorized to mint a segment for the given parent NFD\n * @param nfd - The parent NFD object\n * @param callerAddress - The address of the caller attempting to mint a segment\n * @returns True if the caller is authorized to mint a segment, false otherwise\n */\nexport function canMintSegment(\n  nfd: Nfd | null,\n  callerAddress: string,\n): boolean {\n  if (!nfd) return false\n\n  // If segment minting is unlocked, anyone can mint segments\n  if (isSegmentMintingUnlocked(nfd)) return true\n\n  // If segment minting is locked, only the owner can mint segments\n  return nfd.owner === callerAddress\n}\n\n/**\n * Check if name is a valid NFD root/segment\n * @param name - The NFD name to validate\n * @returns True if the name is valid, false otherwise\n */\nexport function isValidName(name: string): boolean {\n  return /^([a-z0-9]{1,27}\\.){0,1}(?<basename>[a-z0-9]{1,27})\\.algo$/g.test(\n    name,\n  )\n}\n\n/**\n * Check if name is a valid NFD segment\n * @param name - The NFD name to validate\n * @returns True if the name is a segment, false otherwise\n */\nexport function isSegmentName(name: string): boolean {\n  return /^[a-z0-9]{1,27}\\.(?<basename>[a-z0-9]{1,27})\\.algo$/g.test(name)\n}\n\n/**\n * Extract the parent NFD name from a segment NFD name\n * @param segmentName - The segment NFD name (e.g., \"xxx.yyy.algo\")\n * @returns The parent NFD name (e.g., \"yyy.algo\")\n * @throws If the segment name is invalid\n */\nexport function extractParentName(segmentName: string): string {\n  if (!isSegmentName(segmentName)) {\n    throw new Error(`Invalid segment name: ${segmentName}`)\n  }\n  return segmentName.split('.')[1] + '.algo'\n}\n\n/**\n * Get the basename of an NFD (e.g., for \"xxx.yyy.algo\" returns \"yyy\")\n * @param name - The NFD name\n * @returns The basename of the NFD\n */\nexport function getNfdBasename(name: string): string {\n  if (!isValidName(name)) return name\n  const parts = name.split('.')\n  return parts[parts.length - 2]\n}\n","import { isValidName, isSegmentName, getNfdBasename } from '../nfd'\n\n/**\n * Determine the state of an NFD based on its properties\n * @param params - Parameters to determine the state\n * @returns The NFD state\n */\nexport function determineNfdState(params: {\n  expired: boolean\n  owner: string\n  nfdAccount: string\n  reservedFor?: string\n  sellAmount: number\n  isMinting: boolean\n}): 'available' | 'minting' | 'reserved' | 'forSale' | 'owned' | 'expired' {\n  // Check expiration first\n  if (params.expired) {\n    return 'expired'\n  }\n\n  // Check if reserved\n  if (params.owner === params.nfdAccount && params.reservedFor) {\n    return 'reserved'\n  }\n\n  // Check if for sale (any non-zero sell amount)\n  if (params.sellAmount !== 0) {\n    return 'forSale'\n  }\n\n  // Check if minting\n  if (params.isMinting) {\n    return 'minting'\n  }\n\n  // Check if owned by someone other than the NFD account\n  if (params.owner !== params.nfdAccount) {\n    return 'owned'\n  }\n\n  // Default to available\n  return 'available'\n}\n\n/**\n * Generate meta tags for an NFD based on its properties\n * @param name - The NFD name\n * @param segmentCount - The number of segments\n * @returns An array of meta tags\n */\nexport function generateMetaTags(name: string, segmentCount: number): string[] {\n  const tags: string[] = []\n\n  // Only process valid NFD names\n  if (isValidName(name)) {\n    // Add character count tag based on basename length\n    const basenameLength = getNfdBasename(name).length\n    if (basenameLength < 10) {\n      tags.push(`${basenameLength}_letters`)\n    } else {\n      tags.push('10+_letters')\n    }\n\n    // Add segment status tags\n    if (isSegmentName(name)) {\n      tags.push('segment')\n    } else if (segmentCount === 0) {\n      tags.push('pristine')\n    }\n  }\n\n  return tags\n}\n","import { Address, decodeUint64 } from 'algosdk'\n\nimport type { AppState } from '@algorandfoundation/algokit-utils/types/app'\n\n/**\n * Parse a string value from global state, returning empty string if not found\n * @param key - The key to parse\n * @param state - The application state\n * @returns The parsed string value\n */\nexport function parseString(key: string, state: AppState): string {\n  if (!state[key]) return ''\n  return state[key].value?.toString() ?? ''\n}\n\n/**\n * Parse a uint64 value from global state, returning 0 if not found\n * @param key - The key to parse\n * @param state - The application state\n * @returns The parsed number value\n */\nexport function parseUint64(key: string, state: AppState): number {\n  if (!state[key]) return 0\n  const value = state[key]\n  // Only process if it has valueRaw (string variant of AppState)\n  if ('valueRaw' in value) {\n    return Number(decodeUint64(value.valueRaw, 'bigint'))\n  }\n  return 0\n}\n\n/**\n * Parse an Algorand address from global state, returning empty string if not found\n * @param key - The key to parse\n * @param state - The application state\n * @returns The parsed address as a string\n */\nexport function parseAddress(key: string, state: AppState): string {\n  if (!state[key]) return ''\n\n  try {\n    const value = state[key]\n    // For raw 32-byte public keys (string variant with valueRaw)\n    if ('valueRaw' in value && value.valueRaw.length === 32) {\n      return new Address(value.valueRaw).toString()\n    }\n\n    // For regular address strings\n    return Address.fromString(value.value.toString()).toString()\n  } catch (error) {\n    console.error(`Failed to parse address for key ${key}:`, error)\n    return ''\n  }\n}\n","import { Address } from 'algosdk'\n\nimport { concatUint8Arrays, isZeroBytes } from './bytes'\nimport { determineNfdState, generateMetaTags } from './nfd'\nimport { parseAddress, parseString, parseUint64 } from './state'\n\nimport type { AppBox } from './boxes'\nimport type { Nfd } from '../../types'\nimport type { AppState } from '@algorandfoundation/algokit-utils/types/app'\n\n/** The view types supported when reading an NFD's box properties */\nexport type NfdView = 'tiny' | 'brief' | 'full'\n\n/**\n * Parameters for building an NFD record from on-chain state.\n */\nexport interface BuildNfdRecordParams {\n  /** The NFD instance application ID */\n  appId: bigint\n  /** The NFD instance application address */\n  appAddress: string\n  /** The instance's global state */\n  globalState: AppState\n  /** The instance's boxes, names and values together */\n  boxes: AppBox[]\n  /** The view type controlling which boxes are parsed */\n  view?: NfdView\n}\n\n/**\n * Build a full {@link Nfd} record from an NFD instance's on-chain global state\n * and boxes. This is the shared parsing logic used by both the full\n * `NfdClient` and the slim `NfdResolver` lookup entry, so the two produce\n * identical records.\n */\nexport function buildNfdRecord({\n  appId,\n  appAddress,\n  globalState,\n  boxes,\n  view = 'brief',\n}: BuildNfdRecordParams): Nfd {\n  // Filter boxes based on view type\n  const filteredBoxes = boxes.filter((box) => {\n    const boxName = box.name\n    if (view === 'tiny') {\n      // Only include caAlgo and url properties\n      return (\n        boxName === 'v.caAlgo.0.as' ||\n        boxName === 'u.caalgo' ||\n        boxName === 'u.url'\n      )\n    }\n    if (view === 'brief') {\n      // Include caAlgo, url, avatar, and reservedFor properties\n      return (\n        boxName === 'v.caAlgo.0.as' ||\n        boxName === 'u.caalgo' ||\n        boxName === 'u.url' ||\n        boxName === 'u.avatar' ||\n        boxName === 'v.avatar' ||\n        boxName === 'v.avatarasaid' ||\n        boxName === 'v.reservedFor'\n      )\n    }\n    // Include all boxes for full view\n    return true\n  })\n\n  const userDefined: Record<string, string> = {}\n  const verified: Record<string, string> = {}\n  const caAlgo: string[] = []\n  const unverifiedCaAlgo: string[] = []\n\n  // Group box values by their base field name to handle split fields\n  const boxGroups: Record<string, Array<Uint8Array | undefined>> = {}\n\n  for (const box of filteredBoxes) {\n    const boxName = box.name\n    if (boxName.startsWith('u.') || boxName.startsWith('v.')) {\n      // Check if this is a split field (has _XX suffix)\n      const splitMatch = boxName.match(/^([uv]\\.[^_]+)_(\\d{2})$/)\n\n      if (splitMatch) {\n        // This is a split field, group it by base name\n        const baseName = splitMatch[1]\n        const index = parseInt(splitMatch[2])\n\n        if (!boxGroups[baseName]) {\n          boxGroups[baseName] = []\n        }\n        // Store the box value at the correct index\n        boxGroups[baseName][index] = box.value\n      } else {\n        // Regular field (not split), add it as a single-item array\n        boxGroups[boxName] = [box.value]\n      }\n    }\n  }\n\n  // Process each group of boxes\n  for (const [baseFieldName, chunks] of Object.entries(boxGroups)) {\n    // Combine the chunks in index order, skipping any gaps\n    const value = concatUint8Arrays(\n      ...chunks.filter((chunk): chunk is Uint8Array => chunk !== undefined),\n    )\n\n    if (value.length === 0) continue\n\n    // Process the combined value based on field type\n    if (baseFieldName === 'v.caAlgo.0.as') {\n      // For verified caAlgo, the value contains concatenated 32-byte public keys\n      try {\n        // Each Algorand address public key is 32 bytes\n        const PUBLIC_KEY_LENGTH = 32\n\n        // Split the value into chunks of 32 bytes\n        for (let i = 0; i < value.length; i += PUBLIC_KEY_LENGTH) {\n          const publicKey = value.slice(i, i + PUBLIC_KEY_LENGTH)\n\n          // Skip zero addresses (all bytes are zero)\n          if (isZeroBytes(publicKey)) {\n            continue\n          }\n\n          try {\n            const address = new Address(publicKey).toString()\n            if (address) {\n              caAlgo.push(address)\n            }\n          } catch (error) {\n            console.error(\n              'Failed to parse Algorand address from caAlgo box at offset',\n              i,\n              ':',\n              error,\n            )\n          }\n        }\n\n        // Set the verified.caAlgo property as a comma-delimited string\n        if (caAlgo.length > 0) {\n          verified.caAlgo = caAlgo.join(',')\n        }\n      } catch (error) {\n        console.error('Failed to parse Algorand addresses from box:', error)\n      }\n    } else if (baseFieldName.startsWith('u.')) {\n      // User-defined field\n      const propertyName = baseFieldName.slice(2) // Remove 'u.'\n      const propertyValue = new TextDecoder('utf-8').decode(value)\n      userDefined[propertyName] = propertyValue\n\n      // Extract unverified Algorand addresses\n      if (propertyName === 'caalgo') {\n        // Split comma-separated addresses and filter out empty strings\n        const addresses = propertyValue\n          .split(',')\n          .map((addr) => addr.trim())\n          .filter(Boolean)\n        unverifiedCaAlgo.push(...addresses)\n      }\n    } else if (baseFieldName.startsWith('v.')) {\n      // Verified field\n      const propertyName = baseFieldName.slice(2) // Remove 'v.'\n      const propertyValue = new TextDecoder('utf-8').decode(value)\n      verified[propertyName] = propertyValue\n    }\n  }\n\n  const expirationTime = parseUint64('i.expirationTime', globalState)\n  const isExpired =\n    expirationTime > 0 && Math.floor(Date.now() / 1000) > expirationTime\n\n  const stateParams = {\n    expired: isExpired,\n    owner: parseAddress('i.owner.a', globalState),\n    nfdAccount: appAddress,\n    reservedFor: parseAddress('i.reservedOwner.a', globalState) || undefined,\n    sellAmount: parseUint64('i.sellamt', globalState),\n    isMinting: parseString('i.minting', globalState) !== '',\n  }\n  const state = determineNfdState(stateParams)\n\n  const name = parseString('i.name', globalState)\n  const segmentCount = parseUint64('i.segmentCount', globalState)\n  const metaTags = generateMetaTags(name, segmentCount)\n\n  // Map the state values to an NFD object\n  const nfd: Nfd = {\n    name,\n    appID: Number(appId),\n    asaID: parseUint64('i.asaid', globalState),\n    ...(globalState['i.parentAppID'] && {\n      parentAppID: parseUint64('i.parentAppID', globalState),\n    }),\n    owner: parseAddress('i.owner.a', globalState),\n    state,\n    ...(isExpired && { expired: true }),\n    ...(state === 'owned' && {\n      depositAccount:\n        caAlgo[0] ??\n        unverifiedCaAlgo[0] ??\n        parseAddress('i.owner.a', globalState),\n    }),\n    ...(parseUint64('i.sellamt', globalState) > 0 && {\n      sellAmount: parseUint64('i.sellamt', globalState),\n    }),\n    seller: parseAddress('i.seller.a', globalState),\n    nfdAccount: appAddress,\n    ...(parseAddress('i.reservedOwner.a', globalState) && {\n      reservedFor: parseAddress('i.reservedOwner.a', globalState),\n    }),\n    metaTags,\n    timeCreated: new Date(\n      parseUint64('i.timeCreated', globalState) * 1000,\n    ).toISOString(),\n    timeChanged: new Date(\n      parseUint64('i.timeChanged', globalState) * 1000,\n    ).toISOString(),\n    timePurchased: new Date(\n      parseUint64('i.timePurchased', globalState) * 1000,\n    ).toISOString(),\n    ...(parseUint64('i.expirationTime', globalState) > 0 && {\n      timeExpires: new Date(\n        parseUint64('i.expirationTime', globalState) * 1000,\n      ).toISOString(),\n    }),\n    properties: {\n      internal: {\n        ver: parseString('i.ver', globalState),\n        contractLocked: parseString('i.contractLocked', globalState),\n        ...(globalState['i.segmentLocked'] && {\n          segmentLocked: parseString('i.segmentLocked', globalState),\n        }),\n        ...(parseUint64('i.segmentCount', globalState) > 0 && {\n          segmentCount: parseUint64('i.segmentCount', globalState).toString(),\n        }),\n        ...(globalState['i.vaultOptInLocked']?.value && {\n          vaultOptInLocked: parseString('i.vaultOptInLocked', globalState),\n        }),\n        ...(parseUint64('i.segmentPriceUsd', globalState) > 0 && {\n          segmentPriceUsd: parseUint64(\n            'i.segmentPriceUsd',\n            globalState,\n          ).toString(),\n        }),\n        highestSoldAmt: parseUint64('i.highestSoldAmt', globalState).toString(),\n        ...(parseAddress('i.segmentAgent', globalState) && {\n          segmentAgent: parseAddress('i.segmentAgent', globalState),\n        }),\n        category: parseString('i.category', globalState),\n        saleType: parseString('i.saleType', globalState),\n        // Mirror top-level properties\n        name: parseString('i.name', globalState),\n        owner: parseAddress('i.owner.a', globalState),\n        seller: parseAddress('i.seller.a', globalState),\n        ...(parseAddress('i.reservedOwner.a', globalState) && {\n          reservedOwner: parseAddress('i.reservedOwner.a', globalState),\n        }),\n        asaid: parseUint64('i.asaid', globalState).toString(),\n        ...(globalState['i.parentAppID'] && {\n          parentAppID: parseUint64('i.parentAppID', globalState).toString(),\n        }),\n        timeChanged: parseUint64('i.timeChanged', globalState).toString(),\n        timeCreated: parseUint64('i.timeCreated', globalState).toString(),\n        timePurchased: parseUint64('i.timePurchased', globalState).toString(),\n        ...(parseUint64('i.expirationTime', globalState) > 0 && {\n          expirationTime: parseUint64(\n            'i.expirationTime',\n            globalState,\n          ).toString(),\n        }),\n      },\n      ...(Object.keys(userDefined).length > 0 && { userDefined }),\n      ...(Object.keys(verified).length > 0 && { verified }),\n    },\n    ...(caAlgo.length > 0 && { caAlgo }),\n    ...(unverifiedCaAlgo.length > 0 && { unverifiedCaAlgo }),\n  }\n\n  return nfd\n}\n","import { Address, decodeUint64 } from 'algosdk'\n\nimport { concatUint8Arrays } from './bytes'\n\nasync function sha256(data: Uint8Array): Promise<Uint8Array> {\n  const digest = await globalThis.crypto.subtle.digest(\n    'SHA-256',\n    data as BufferSource,\n  )\n  return new Uint8Array(digest)\n}\n\n/**\n * Compute the registry box name for an NFD name: SHA-256 of `name/<name>`\n * @param name - The NFD name (e.g. 'example.algo')\n * @returns The 32-byte box name\n */\nexport async function getNameBoxName(name: string): Promise<Uint8Array> {\n  return sha256(new TextEncoder().encode(`name/${name}`))\n}\n\n/**\n * Compute the registry reverse-index box name for an address: SHA-256 of\n * `addr/algo/` concatenated with the address's 32-byte public key\n * @param address - The address to look up\n * @returns The 32-byte box name\n */\nexport async function getAddressBoxName(\n  address: string | Address,\n): Promise<Uint8Array> {\n  const addr =\n    typeof address === 'string' ? Address.fromString(address) : address\n  const prefix = new TextEncoder().encode('addr/algo/')\n  return sha256(concatUint8Arrays(prefix, addr.publicKey))\n}\n\n/**\n * Decode an NFD application ID from a registry name-box value. The box stores\n * the ASA ID in bytes 0-7 and the app ID in bytes 8-15.\n * @param bytes - The raw box value\n * @returns The NFD application ID\n */\nexport function decodeAppIdFromNameBox(bytes: Uint8Array): bigint {\n  return decodeUint64(bytes.slice(8, 16), 'bigint')\n}\n"],"names":["NfdRegistryId","DefaultSender","ALGORAND_ZERO_ADDRESS","APP_CALL_STATIC_FEE","RENEW_STATIC_FEE","VAULT_FEE_PER_ASSET","VAULT_OPT_IN_MBR","NfdApiBaseUrl","getAllBoxes","algod","appId","decoder","boxes","seenTokens","nextToken","round","request","response","box","strToUint8Array","str","_","i","concatUint8Arrays","arrays","totalLength","total","array","concatenatedArray","offset","isZeroBytes","byte","isSegmentMintingUnlocked","nfd","_b","_a","canMintSegment","callerAddress","isValidName","name","isSegmentName","extractParentName","segmentName","getNfdBasename","parts","determineNfdState","params","generateMetaTags","segmentCount","tags","basenameLength","parseString","key","state","parseUint64","value","decodeUint64","parseAddress","Address","error","buildNfdRecord","appAddress","globalState","view","filteredBoxes","boxName","userDefined","verified","caAlgo","unverifiedCaAlgo","boxGroups","splitMatch","baseName","index","baseFieldName","chunks","chunk","publicKey","address","propertyName","propertyValue","addresses","addr","expirationTime","isExpired","stateParams","metaTags","sha256","data","digest","getNameBoxName","getAddressBoxName","prefix","decodeAppIdFromNameBox","bytes"],"mappings":"wCACO,IAAKA,GAAAA,IACVA,EAAAA,EAAA,QAAU,SAAA,EAAV,UACAA,EAAAA,EAAA,QAAU,QAAA,EAAV,UAFUA,IAAAA,GAAA,CAAA,CAAA,EAMAC,GAAAA,IACVA,EAAA,QAAU,6DACVA,EAAA,QAAU,6DAFAA,IAAAA,GAAA,CAAA,CAAA,EAML,MAAMC,EACX,6DAMWC,EAAsB,MAGtBC,EAAmB,MAMnBC,EAAsB,MAStBC,EAAmB,QAGzB,IAAKC,GAAAA,IACVA,EAAA,QAAU,yBACVA,EAAA,QAAU,iCAFAA,IAAAA,GAAA,CAAA,CAAA,ECZZ,eAAsBC,EACpBC,EACAC,EACmB,CACnB,MAAMC,EAAU,IAAI,YAAY,OAAO,EACjCC,EAAkB,CAAA,EAIlBC,MAAiB,IAEvB,IAAIC,EACAC,EAEJ,EAAG,CACD,MAAMC,EAAUP,EAAM,oBAAoBC,CAAK,EAAE,QAAQ,QAAQ,EAE7DI,GACFE,EAAQ,KAAKF,CAAS,EAEpBC,IAAU,QACZC,EAAQ,MAAMD,CAAK,EAGrB,MAAME,EAAW,MAAMD,EAAQ,GAAA,EAC/BD,MAAUE,EAAS,OAEnB,UAAWC,KAAOD,EAAS,MAAO,CAChC,GAAIC,EAAI,QAAU,OAChB,MAAM,IAAI,MACR,QAAQP,EAAQ,OAAOO,EAAI,IAAI,CAAC,YAAYR,CAAK,kIAAA,EAMrDE,EAAM,KAAK,CACT,KAAMD,EAA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