{"version":3,"file":"runtime-queries-D5EGaCrH.mjs","names":["getDefaultState"],"sources":["../../editors/workflow-editor/ui/forms.ts","../../../pieces-framework/dist/workflow.js","../../editors/workflow-editor/ui/blocks.ts","../../editors/workflow-editor/runtime-client.ts","../../../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/subscribable.js","../../../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/timeoutManager.js","../../../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/utils.js","../../../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/focusManager.js","../../../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/thenable.js","../../../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/notifyManager.js","../../../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/onlineManager.js","../../../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/retryer.js","../../../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/removable.js","../../../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/query.js","../../../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js","../../../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/mutation.js","../../../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/mutationCache.js","../../../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/queryCache.js","../../../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/queryClient.js","../../../../node_modules/.pnpm/@tanstack+react-query@5.90.21_react@19.2.6/node_modules/@tanstack/react-query/build/modern/queryOptions.js","../../../../node_modules/.pnpm/@tanstack+react-query@5.90.21_react@19.2.6/node_modules/@tanstack/react-query/build/modern/infiniteQueryOptions.js","../../editors/workflow-editor/run-kinds.ts","../../editors/workflow-editor/ui/query-keys.ts","../../editors/workflow-editor/runtime-queries.ts"],"sourcesContent":["// Form descriptors driving property panels; pure data, mirrors the\n// ConnectorPropDescriptor shape from the workflow runtime.\nimport type { BlockRef } from \"@powerhousedao/pieces-framework/block-type\";\nimport type { TriggerDelivery } from \"@powerhousedao/pieces-framework/workflow\";\n\nexport interface BlockFormProp {\n  name: string;\n  displayName: string;\n  type: string;\n  required: boolean;\n  defaultValue?: unknown;\n  staticOptions?: FormOption[];\n  // A STATIC_DROPDOWN's own state, beside its options.\n  staticDisabled?: boolean;\n  staticPlaceholder?: string;\n  hasDynamicResolver?: boolean;\n  description?: string;\n  placeholder?: string;\n  // Sibling prop names whose values feed the resolver; a change re-runs it.\n  refreshers?: string[];\n  // Nested shape: ARRAY item fields, or what a DYNAMIC resolver produced.\n  properties?: BlockFormProp[];\n  // Folded behind \"Advanced\": fields with a working default, so the common\n  // case is short. Opens expanded when set, else live config would be hidden.\n  advanced?: boolean;\n  // Shown only while a sibling prop holds one of these values; data, not a\n  // predicate, so a form arriving as JSON can express it.\n  showWhen?: { prop: string; oneOf: unknown[] };\n  // Activepieces layout and control hints, as the piece declared them.\n  width?: \"half\" | \"full\";\n  icon?: string;\n  // CHECKBOX: sibling props shown only while it is checked.\n  reveals?: string[];\n  // MARKDOWN: BORDERLESS | INFO | WARNING | TIP.\n  variant?: string;\n  // STATIC_DROPDOWN \"cards\", NUMBER \"stepper\", DATE_RANGE \"dropdown\",\n  // LONG_TEXT \"code\" (monospace).\n  display?: string;\n  min?: number;\n  max?: number;\n  step?: number;\n  // DROPDOWN: options() is re-run with what the author types.\n  refreshOnSearch?: boolean;\n  // RICH_TEXT: the sibling whose value picks plain, markdown or html.\n  formatProperty?: string;\n  // SHORT_TEXT: a checkbox with this label that stores \"\" on purpose.\n  emptyChoice?: string;\n}\n\nexport interface FormOption {\n  label: string;\n  value: unknown;\n  description?: string;\n  icon?: string;\n}\n\nexport interface PropertyGroup {\n  key: string;\n  // tabs | section | summary | builder | footer\n  display: string;\n  label?: string;\n  description?: string;\n  icon?: string;\n  props: string[];\n}\n\nexport interface ErrorHandlingDefaults {\n  retryOnFailure?: { defaultValue?: boolean; hide?: boolean };\n  continueOnFailure?: { defaultValue?: boolean; hide?: boolean };\n}\n\nexport interface BlockForm {\n  title: string;\n  requireAuth: boolean;\n  // Whether the block takes a connection: none hides the field entirely.\n  auth?: \"none\" | \"optional\" | \"required\";\n  props: BlockFormProp[];\n  // Output ports the block declares; edges on any other are never taken.\n  ports?: readonly string[];\n  // A form drawn instead of the props, e.g. \"schedule\" for the builder.\n  display?: string;\n  // Triggers only, from checkTriggerStrategy. A webhook trigger is fed by a\n  // request, so the panel shows its endpoint URL.\n  triggerDelivery?: TriggerDelivery;\n  // What the step does, as the piece describes it.\n  description?: string;\n  propertyGroups?: PropertyGroup[];\n  // READ | SEARCH | WRITE | DESTRUCTIVE\n  classification?: string;\n  errorHandling?: ErrorHandlingDefaults;\n}\n\nexport interface ConnectionSummary {\n  id: string;\n  name: string;\n  connectorId: string;\n  authType: string;\n  status: string;\n  accountLabel: string | null;\n}\n\nexport interface SecretStat {\n  ref: string;\n  label: string | null;\n  version: number;\n  status: string;\n  createdAt: string;\n  updatedAt: string;\n}\n\n// Minting seam for PH_SECRET_REF props: the field takes a value and the\n// document only ever receives the ref that comes back.\nexport interface SecretFormService {\n  save: (input: {\n    ref?: string;\n    value: string;\n    label: string;\n  }) => Promise<SecretStat>;\n  stat: (ref: string) => Promise<SecretStat | null>;\n}\n\nexport interface WebhookEndpoint {\n  workflowId: string;\n  url: string;\n  // False when `url` is a bare path because the reactor has no public origin.\n  absoluteUrl: boolean;\n  armed: boolean;\n  createdAt: string;\n}\n\nexport interface DesignTimeService {\n  getBlockForm: (block: BlockRef) => Promise<BlockForm | null>;\n  loadOptions: (\n    block: BlockRef,\n    propName: string,\n    input: Record<string, unknown>,\n    connectionId?: string,\n    searchValue?: string,\n  ) => Promise<unknown>;\n  // Runs the current workflow's piece trigger test hook; sample items back.\n  testTrigger?: () => Promise<unknown>;\n  // Runs one draft step against the last tests of the blocks it reads.\n  testStep?: (stepId: string) => Promise<StepTestOutcome>;\n  // The current workflow's webhook endpoint, for the core webhook trigger.\n  webhookEndpoint?: () => Promise<WebhookEndpoint | null>;\n  // Backs PH_SECRET_REF props; absent when the runtime refuses secret writes.\n  secrets?: SecretFormService;\n  // powerhouse/connection documents for the connection picker.\n  listConnections?: () => Promise<ConnectionSummary[]>;\n  // Tells apart listings narrowed differently, e.g. per drive; part of the key.\n  connectionScope?: string;\n  // The workflow being edited; keys its run and endpoint queries.\n  workflowId?: string;\n  // The current workflow's most recent run, for a step's \"Last run\" preview.\n  latestRun?: () => Promise<LatestRun | null>;\n  // One journaled run by id, e.g. the trigger's last test.\n  fetchRun?: (runId: string) => Promise<LatestRun | null>;\n  // The piece version each draft block runs, trigger first.\n  blockResolutions?: () => Promise<BlockResolutionView[]>;\n}\n\nexport type BlockMatchView =\n  | \"exact\"\n  | \"compatible\"\n  | \"fallback\"\n  | \"installed\"\n  | \"missing\";\n\n// A draft block as the runtime would run it; host-bound pieces are \"installed\".\nexport interface BlockResolutionView {\n  stepId: string;\n  pieceName: string;\n  // The version the block pins.\n  pieceVersion: string;\n  name: string;\n  kind: \"action\" | \"trigger\";\n  resolvedVersion: string | null;\n  source: string | null;\n  match: BlockMatchView;\n  note: string | null;\n  latestVersion: string | null;\n}\n\nexport interface StepTestOutcome {\n  // Null when nothing ran, e.g. `Test \"fetch\" first`.\n  runId: string | null;\n  status: \"SUCCEEDED\" | \"FAILED\";\n  output?: unknown;\n  error: string | null;\n  durationMs: number;\n}\n\nexport interface LatestRun {\n  id?: string;\n  status: string;\n  error?: string | null;\n  startedAt: string;\n  triggerPayload: unknown;\n  steps: {\n    stepKey: string;\n    status: string;\n    input: unknown;\n    output: unknown;\n    error: string | null;\n  }[];\n}\n\n// Ours, not the piece's: the reactor's poll cadence for a piece trigger.\n// Appended to every piece trigger's form; see splitPollInterval in the runtime.\nexport const POLL_INTERVAL_PROP: BlockFormProp = {\n  name: \"pollEverySeconds\",\n  displayName: \"Poll every (seconds)\",\n  type: \"NUMBER\",\n  required: false,\n  description:\n    \"How often the reactor checks this trigger; 60 at the least. Omit to follow the piece's own cadence.\",\n};\n","//#region src/workflow/strategy.ts\nconst DELIVERIES = {\n\tPOLLING: \"poll\",\n\tWEBHOOK: \"webhook\",\n\tMANUAL: \"manual\"\n};\nconst APP_WEBHOOK_UNSUPPORTED = \"TriggerStrategy.APP_WEBHOOK (app-level webhooks) is not supported\";\nvar TriggerStrategyError = class extends Error {\n\tstrategy;\n\tconstructor(strategy, issue) {\n\t\tsuper(issue);\n\t\tthis.name = \"TriggerStrategyError\";\n\t\tthis.strategy = strategy;\n\t}\n};\nfunction checkTriggerStrategy(strategy) {\n\tif (typeof strategy === \"string\" && Object.hasOwn(DELIVERIES, strategy)) return { delivery: DELIVERIES[strategy] };\n\tif (strategy === \"APP_WEBHOOK\") return { issue: APP_WEBHOOK_UNSUPPORTED };\n\treturn { issue: strategy === void 0 || strategy === null || strategy === \"\" ? \"The trigger declares no strategy\" : `Unknown trigger strategy ${JSON.stringify(strategy)}` };\n}\nfunction triggerDelivery(strategy) {\n\tconst check = checkTriggerStrategy(strategy);\n\tif (\"issue\" in check) throw new TriggerStrategyError(strategy, check.issue);\n\treturn check.delivery;\n}\n\n//#endregion\n//#region src/workflow/schedule.ts\nconst DEFAULT_TIMEZONE = \"UTC\";\nconst SCHEDULE_UNIT_MS = {\n\tminutes: 6e4,\n\thours: 36e5,\n\tdays: 864e5\n};\nconst SCHEDULE_MODES = [\"cron\", \"interval\"];\nvar ScheduleConfigError = class extends Error {\n\tconstructor(message) {\n\t\tsuper(`Schedule: ${message}`);\n\t\tthis.name = \"ScheduleConfigError\";\n\t}\n};\nconst CRON_FIELD = /^[\\d*?A-Za-z]+(?:[-/][\\dA-Za-z]+)*(?:,[\\d*?A-Za-z]+(?:[-/][\\dA-Za-z]+)*)*$/;\nfunction isRecord(value) {\n\treturn value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\nfunction parseTimezone(value) {\n\tif (value === void 0 || value === null || value === \"\") return \"UTC\";\n\tif (typeof value !== \"string\") throw new ScheduleConfigError(\"\\\"timezone\\\" must be an IANA name\");\n\ttry {\n\t\tnew Intl.DateTimeFormat(\"en-US\", { timeZone: value });\n\t} catch {\n\t\tthrow new ScheduleConfigError(`unknown timezone \"${value}\" (use an IANA name such as Europe/Lisbon)`);\n\t}\n\treturn value;\n}\nfunction parseCronText(cron) {\n\tif (typeof cron !== \"string\" || cron.trim() === \"\") throw new ScheduleConfigError(\"\\\"cron\\\" is required in cron mode\");\n\tconst pattern = cron.trim().replace(/\\s+/g, \" \");\n\tconst fields = pattern.split(\" \");\n\tif (fields.length !== 5) throw new ScheduleConfigError(`cron \"${pattern}\" must have exactly five fields (minute hour day month weekday)`);\n\tconst bad = fields.find((field) => !CRON_FIELD.test(field));\n\tif (bad !== void 0) throw new ScheduleConfigError(`cron \"${pattern}\" has an invalid field \"${bad}\"`);\n\treturn pattern;\n}\nfunction parseInterval(record) {\n\tconst { every, unit } = record;\n\tif (typeof every !== \"number\" || !Number.isInteger(every) || every < 1) throw new ScheduleConfigError(\"\\\"every\\\" must be a whole number of at least 1 in interval mode\");\n\tif (typeof unit !== \"string\" || !Object.hasOwn(SCHEDULE_UNIT_MS, unit)) throw new ScheduleConfigError(`\"unit\" must be one of ${Object.keys(SCHEDULE_UNIT_MS).join(\", \")}`);\n\tconst key = unit;\n\treturn {\n\t\tevery,\n\t\tunit: key,\n\t\teveryMs: every * SCHEDULE_UNIT_MS[key]\n\t};\n}\nfunction parseScheduleConfig(config) {\n\tif (!isRecord(config)) throw new ScheduleConfigError(\"the config must be an object\");\n\tconst timezone = parseTimezone(config.timezone);\n\tif (config.mode === \"cron\") return {\n\t\tmode: \"cron\",\n\t\tcron: parseCronText(config.cron),\n\t\ttimezone\n\t};\n\tif (config.mode === \"interval\") return {\n\t\tmode: \"interval\",\n\t\t...parseInterval(config),\n\t\ttimezone\n\t};\n\tthrow new ScheduleConfigError(config.mode === void 0 ? \"\\\"mode\\\" is required (\\\"cron\\\" or \\\"interval\\\")\" : `\"mode\" must be \"cron\" or \"interval\", not ${JSON.stringify(config.mode)}`);\n}\nfunction scheduleConfigIssue(config) {\n\ttry {\n\t\tparseScheduleConfig(config);\n\t\treturn;\n\t} catch (error) {\n\t\treturn error instanceof Error ? error.message : String(error);\n\t}\n}\n\n//#endregion\n//#region src/workflow/ports.ts\nconst NEXT_PORT = \"next\";\nconst ERROR_PORT = \"error\";\nconst PIECE_ACTION_PORTS = [NEXT_PORT, ERROR_PORT];\nconst TRIGGER_PORTS = [NEXT_PORT];\nfunction flowPorts(ports) {\n\treturn ports.filter((port) => port !== ERROR_PORT);\n}\nfunction undeclaredPortEdges(edges, portsOf) {\n\treturn edges.filter((edge) => {\n\t\tconst ports = portsOf(edge.from);\n\t\treturn ports !== void 0 && !ports.includes(edge.port);\n\t});\n}\n\n//#endregion\n//#region src/workflow/core.ts\nconst CORE_PIECE_NAME = \"@powerhousedao/piece-core\";\nconst BRANCH_PORTS = [\n\t\"true\",\n\t\"false\",\n\tERROR_PORT\n];\nfunction knownPorts(block) {\n\tif (block.kind === \"trigger\") return TRIGGER_PORTS;\n\treturn block.pieceName === \"@powerhousedao/piece-core\" && block.name === \"branch\" ? BRANCH_PORTS : PIECE_ACTION_PORTS;\n}\n\n//#endregion\nexport { APP_WEBHOOK_UNSUPPORTED, BRANCH_PORTS, CORE_PIECE_NAME, DEFAULT_TIMEZONE, ERROR_PORT, NEXT_PORT, PIECE_ACTION_PORTS, SCHEDULE_MODES, SCHEDULE_UNIT_MS, ScheduleConfigError, TRIGGER_PORTS, TriggerStrategyError, checkTriggerStrategy, flowPorts, knownPorts, parseCronText, parseScheduleConfig, scheduleConfigIssue, triggerDelivery, undeclaredPortEdges };\n//# sourceMappingURL=workflow.js.map","// Block helpers and palette presets; pure data used by the UI to seed new\n// triggers and steps.\nimport {\n  blockKey,\n  type BlockIdentity,\n  type BlockKind,\n  type BlockRef,\n} from \"@powerhousedao/pieces-framework/block-type\";\nimport { CORE_PIECE_NAME } from \"@powerhousedao/pieces-framework/workflow\";\n\nexport type { BlockIdentity, BlockKind, BlockRef };\n\nexport const CORE_PIECE = CORE_PIECE_NAME;\n\n// The reactor piece this package ships, named as pieces/index.ts declares it.\nexport const REACTOR_PIECE = \"@powerhousedao/piece-reactor\";\n\nconst core = (kind: BlockKind, name: string): BlockIdentity => ({\n  pieceName: CORE_PIECE,\n  kind,\n  name,\n});\n\nexport const MANUAL_TRIGGER = core(\"trigger\", \"manual\");\nexport const SCHEDULE_TRIGGER = core(\"trigger\", \"schedule\");\nexport const WEBHOOK_TRIGGER = core(\"trigger\", \"webhook\");\nexport const BRANCH_BLOCK = core(\"action\", \"branch\");\nexport const ASSERT_BLOCK = core(\"action\", \"assert\");\n\n// A block to add: pinned already, or pinned to the installed version on pick.\nexport type BlockPick = BlockIdentity & { pieceVersion?: string };\n\nexport function sameBlock(\n  a: BlockIdentity | undefined | null,\n  b: BlockIdentity | undefined | null,\n): boolean {\n  return Boolean(a && b && blockKey(a) === blockKey(b));\n}\n\nexport function isCoreBlock(block: { pieceName: string }): boolean {\n  return block.pieceName === CORE_PIECE;\n}\n\n// The document blocks live in the reactor piece, and are offered here too:\n// they are what most workflows on a reactor are built from.\nexport function isReactorPieceBlock(block: { pieceName: string }): boolean {\n  return block.pieceName === REACTOR_PIECE;\n}\n\nexport function stepBlock(step: {\n  pieceName: string;\n  pieceVersion: string;\n  actionName: string;\n}): BlockRef {\n  return {\n    pieceName: step.pieceName,\n    pieceVersion: step.pieceVersion,\n    kind: \"action\",\n    name: step.actionName,\n  };\n}\n\nexport function triggerBlock(trigger: {\n  pieceName: string;\n  pieceVersion: string;\n  triggerName: string;\n}): BlockRef {\n  return {\n    pieceName: trigger.pieceName,\n    pieceVersion: trigger.pieceVersion,\n    kind: \"trigger\",\n    name: trigger.triggerName,\n  };\n}\n\n// The fields a step or the trigger stores for a block.\nexport function stepFields(block: BlockRef) {\n  return {\n    pieceName: block.pieceName,\n    pieceVersion: block.pieceVersion,\n    actionName: block.name,\n  };\n}\n\nexport function triggerFields(block: BlockRef) {\n  return {\n    pieceName: block.pieceName,\n    pieceVersion: block.pieceVersion,\n    triggerName: block.name,\n  };\n}\n\n// A pinned pick passes through; an unpinned one takes the installed version,\n// and undefined means the piece isn't installed.\nexport function pinBlock(\n  pick: BlockPick,\n  installedVersion: (piece: string) => string | undefined,\n): BlockRef | undefined {\n  const pieceVersion = pick.pieceVersion ?? installedVersion(pick.pieceName);\n  if (!pieceVersion) return undefined;\n  return {\n    pieceName: pick.pieceName,\n    pieceVersion,\n    kind: pick.kind,\n    name: pick.name,\n  };\n}\n\nexport interface BlockPreset {\n  label: string;\n  block: BlockPick;\n  description: string;\n  defaultConfig: unknown;\n  // Which section of the picker it belongs to: \"core\" is the core piece,\n  // \"powerhouse\" the reactor piece, listed right after it.\n\n  // Optional because a pick built from a search hit or an existing step is\n  // the same shape but belongs to no section.\n  group?: \"core\" | \"powerhouse\";\n}\n\nconst reactor = (kind: BlockKind, name: string): BlockIdentity => ({\n  pieceName: REACTOR_PIECE,\n  kind,\n  name,\n});\n\nexport const TRIGGER_PRESETS: BlockPreset[] = [\n  {\n    label: \"Manual\",\n    block: MANUAL_TRIGGER,\n    group: \"core\",\n    description: \"Fired on demand with a payload.\",\n    defaultConfig: {},\n  },\n  {\n    label: \"Schedule\",\n    block: SCHEDULE_TRIGGER,\n    group: \"core\",\n    description: \"Fires on a cron expression or fixed interval.\",\n    defaultConfig: { mode: \"cron\", cron: \"0 9 * * 1-5\", timezone: \"UTC\" },\n  },\n  {\n    label: \"Webhook\",\n    block: WEBHOOK_TRIGGER,\n    group: \"core\",\n    description: \"Fires when a provider POSTs to this workflow's URL.\",\n    defaultConfig: { methods: \"POST\", scheme: \"none\", responseMode: \"async\" },\n  },\n  {\n    label: \"Document event\",\n    block: reactor(\"trigger\", \"document-event\"),\n    group: \"powerhouse\",\n    description: \"Fires when a matching document operation lands.\",\n    defaultConfig: {},\n  },\n  {\n    label: \"Document created\",\n    block: reactor(\"trigger\", \"document-created\"),\n    group: \"powerhouse\",\n    description: \"Fires when a document is added to a drive.\",\n    defaultConfig: {},\n  },\n  {\n    label: \"Document deleted\",\n    block: reactor(\"trigger\", \"document-deleted\"),\n    group: \"powerhouse\",\n    description: \"Fires when a document is removed from a drive.\",\n    defaultConfig: {},\n  },\n];\n\nexport const STEP_PRESETS: BlockPreset[] = [\n  {\n    label: \"Branch\",\n    block: BRANCH_BLOCK,\n    group: \"core\",\n    description: \"Routes true/false on a condition.\",\n    defaultConfig: {},\n  },\n  {\n    label: \"Assert\",\n    block: ASSERT_BLOCK,\n    group: \"core\",\n    description:\n      \"Fails the run when a value is blank, rejected or not allowed.\",\n    defaultConfig: { value: \"\", allowValues: [] },\n  },\n  {\n    label: \"Create document\",\n    block: reactor(\"action\", \"document-create\"),\n    group: \"powerhouse\",\n    description: \"Creates a Powerhouse document.\",\n    defaultConfig: { documentType: \"\", name: \"\" },\n  },\n  {\n    label: \"Dispatch actions\",\n    block: reactor(\"action\", \"document-dispatch\"),\n    group: \"powerhouse\",\n    description: \"Sends actions to a document.\",\n    defaultConfig: { documentId: \"\" },\n  },\n  {\n    label: \"Get document\",\n    block: reactor(\"action\", \"document-get\"),\n    group: \"powerhouse\",\n    description: \"Reads a document's current state.\",\n    defaultConfig: { documentId: \"\" },\n  },\n  {\n    label: \"Find documents\",\n    block: reactor(\"action\", \"document-find\"),\n    group: \"powerhouse\",\n    description: \"Lists documents by type and name.\",\n    defaultConfig: { documentType: \"\" },\n  },\n  {\n    label: \"List document types\",\n    block: reactor(\"action\", \"document-types\"),\n    group: \"powerhouse\",\n    description: \"Document models installed on this reactor.\",\n    defaultConfig: {},\n  },\n  {\n    label: \"Get document schema\",\n    block: reactor(\"action\", \"document-schema\"),\n    group: \"powerhouse\",\n    description: \"Action and state schemas of a document type.\",\n    defaultConfig: { documentType: \"\" },\n  },\n];\n\n// A preset as the picker hands it over: pinned to a version.\nexport interface PickedPreset extends BlockPreset {\n  block: BlockRef;\n}\n","// Design-time channel to the workflow-runtime subgraph: piece descriptors,\n// option resolution, runs and secrets. Not document-model coupled.\nimport { ambientRenownTokenProvider } from \"@powerhousedao/reactor-browser/graphql-client\";\nimport {\n  POLL_INTERVAL_PROP,\n  type BlockForm,\n  type BlockFormProp,\n  type ErrorHandlingDefaults,\n  type PropertyGroup,\n} from \"./ui/forms.js\";\nimport {\n  isCoreBlock,\n  isReactorPieceBlock,\n  type BlockRef,\n} from \"./ui/blocks.js\";\nimport { checkTriggerStrategy } from \"@powerhousedao/pieces-framework/workflow\";\n\nexport const DEFAULT_RUNTIME_URL =\n  \"http://localhost:4001/graphql/workflow-runtime\";\n\nexport interface Transport {\n  url: string;\n  gql: <T>(query: string, variables: Record<string, unknown>) => Promise<T>;\n}\n\nexport interface RuntimeClientOptions {\n  fetch?: typeof fetch;\n  // Bearer token source; defaults to the ambient Renown token.\n  token?: () => Promise<string | null | undefined>;\n}\n\nfunction createTransport(\n  url: string,\n  options: RuntimeClientOptions,\n): Transport {\n  const doFetch = options.fetch ?? ((input, init) => fetch(input, init));\n  const tokenOf = options.token ?? ambientRenownTokenProvider;\n  return {\n    url,\n    gql: (query, variables) => gql(url, doFetch, tokenOf, query, variables),\n  };\n}\n\n// A runtime error with its GraphQL extension code, when the server sent one.\nexport class RuntimeRequestError extends Error {\n  constructor(\n    message: string,\n    readonly code?: string,\n  ) {\n    super(message);\n    this.name = \"RuntimeRequestError\";\n  }\n}\n\n// The workflow document hasn't reached the runtime yet; the call can be retried.\nexport function isSyncingError(error: unknown): boolean {\n  return (\n    error instanceof RuntimeRequestError && error.code === \"WORKFLOW_SYNCING\"\n  );\n}\n\nasync function gql<T>(\n  url: string,\n  doFetch: typeof fetch,\n  tokenOf: () => Promise<string | null | undefined>,\n  query: string,\n  variables: Record<string, unknown>,\n): Promise<T> {\n  // Mirrors the reactor-browser switchboard AI tool's auth: attach the\n  // Renown bearer token when one is available, else go out anonymously.\n  const token = await tokenOf();\n  const response = await doFetch(url, {\n    method: \"POST\",\n    headers: {\n      \"content-type\": \"application/json\",\n      ...(token ? { authorization: `Bearer ${token}` } : {}),\n    },\n    body: JSON.stringify({ query, variables }),\n  });\n  const body = (await response.json()) as {\n    data?: T;\n    errors?: { message: string; extensions?: { code?: unknown } }[];\n  };\n  const first = body.errors?.[0];\n  if (first) {\n    const code = first.extensions?.code;\n    throw new RuntimeRequestError(\n      first.message,\n      typeof code === \"string\" ? code : undefined,\n    );\n  }\n  if (!body.data) throw new Error(\"Empty GraphQL response\");\n  return body.data;\n}\n\ninterface BlockEntryDescriptor {\n  displayName: string;\n  description?: string;\n  requireAuth: boolean;\n  props: BlockFormProp[];\n  ports?: string[];\n  // Triggers only; read through checkTriggerStrategy.\n  strategy?: string;\n  display?: string;\n  propertyGroups?: PropertyGroup[];\n  classification?: string;\n  errorHandlingOptions?: ErrorHandlingDefaults;\n}\n\ninterface BlockDescriptorResult {\n  workflowRuntime: {\n    blockDescriptor: {\n      displayName: string;\n      auth?: unknown;\n      action?: BlockEntryDescriptor;\n      trigger?: BlockEntryDescriptor;\n    } | null;\n  };\n}\n\n// The GraphQL BlockInput for a block.\nexport function blockInput(block: BlockRef) {\n  return {\n    pieceName: block.pieceName,\n    pieceVersion: block.pieceVersion,\n    name: block.name,\n    kind: block.kind,\n  };\n}\n\nexport function getBlockForm(\n  t: Transport,\n  block: BlockRef,\n): Promise<BlockForm | null> {\n  return t\n    .gql<BlockDescriptorResult>(\n      `query Descriptor($block: BlockInput!) {\n        workflowRuntime { blockDescriptor(block: $block) }\n      }`,\n      { block: blockInput(block) },\n    )\n    .then((data) => {\n      const descriptor = data.workflowRuntime.blockDescriptor;\n      const entry = descriptor?.action ?? descriptor?.trigger;\n      if (!descriptor || !entry) return null;\n      const isTrigger = !descriptor.action && Boolean(descriptor.trigger);\n      const strategy = isTrigger\n        ? checkTriggerStrategy(entry.strategy)\n        : undefined;\n      // The runtime refuses it too, so no form is drawn for it.\n      if (strategy && \"issue\" in strategy) throw new Error(strategy.issue);\n      const delivery = strategy?.delivery;\n      // A poll cadence only means something for a piece trigger the reactor\n      // polls; the reactor piece's are fed by the host, core ones fire themselves.\n      const polled =\n        delivery === \"poll\" &&\n        !isCoreBlock(block) &&\n        !isReactorPieceBlock(block);\n      const props = entry.props;\n      return {\n        // A core block belongs to no piece worth naming.\n        title: isCoreBlock(block)\n          ? entry.displayName\n          : `${descriptor.displayName} · ${entry.displayName}`,\n        requireAuth: entry.requireAuth,\n        auth: !descriptor.auth\n          ? (\"none\" as const)\n          : entry.requireAuth\n            ? (\"required\" as const)\n            : (\"optional\" as const),\n        props: polled ? [...props, POLL_INTERVAL_PROP] : props,\n        ...(entry.ports ? { ports: entry.ports } : {}),\n        ...(delivery ? { triggerDelivery: delivery } : {}),\n        ...(entry.display ? { display: entry.display } : {}),\n        ...(entry.description ? { description: entry.description } : {}),\n        ...(entry.propertyGroups\n          ? { propertyGroups: entry.propertyGroups }\n          : {}),\n        ...(entry.classification\n          ? { classification: entry.classification }\n          : {}),\n        ...(entry.errorHandlingOptions\n          ? { errorHandling: entry.errorHandlingOptions }\n          : {}),\n      };\n    });\n}\n\nexport interface PieceSummary {\n  name: string;\n  displayName: string;\n  description: string;\n  logoUrl: string;\n  version: string;\n  actionCount: number;\n  triggerCount: number;\n  // Activepieces category ids, e.g. ARTIFICIAL_INTELLIGENCE, SALES_AND_CRM.\n  categories: string[];\n  // PieceAuth descriptor, verbatim from the piece; null when authless.\n  auth?: unknown;\n  // Why none of the piece's blocks can run on this reactor.\n  unsupported?: string | null;\n  deprecated?: boolean;\n  // A package piece shadowing a published one: the version published.\n  publishedVersion?: string;\n}\n\n// One action of a piece, at the version the listing answered with.\nexport interface PieceActionEntry {\n  pieceName: string;\n  pieceVersion: string;\n  name: string;\n  displayName: string;\n  description: string;\n  unsupported?: string | null;\n}\n\ninterface PieceListing<T> {\n  name: string;\n  version: string;\n  entries: T[];\n}\n\nfunction atVersion<T>(listing: PieceListing<T>) {\n  return listing.entries.map((entry) => ({\n    ...entry,\n    pieceName: listing.name,\n    pieceVersion: listing.version,\n  }));\n}\n\nexport function fetchPieceCatalog(t: Transport): Promise<PieceSummary[]> {\n  return t\n    .gql<{\n      workflowRuntime: { pieceCatalog: PieceSummary[] };\n    }>(`query Catalog { workflowRuntime { pieceCatalog } }`, {})\n    .then((data) => data.workflowRuntime.pieceCatalog);\n}\n\nexport async function fetchPieceActions(\n  t: Transport,\n  packageName: string,\n): Promise<PieceActionEntry[]> {\n  const data = await t.gql<{\n    workflowRuntime: {\n      pieceActions: {\n        name: string;\n        version: string;\n        actions: Omit<PieceActionEntry, \"pieceName\" | \"pieceVersion\">[];\n      };\n    };\n  }>(\n    `query Actions($packageName: String!) {\n      workflowRuntime { pieceActions(packageName: $packageName) }\n    }`,\n    { packageName },\n  );\n  const listing = data.workflowRuntime.pieceActions;\n  return atVersion({ ...listing, entries: listing.actions });\n}\n\nexport interface PieceTriggerEntry {\n  pieceName: string;\n  pieceVersion: string;\n  name: string;\n  displayName: string;\n  description: string;\n  strategy: string;\n  unsupported?: string | null;\n}\n\nexport async function fetchPieceTriggers(\n  t: Transport,\n  packageName: string,\n): Promise<PieceTriggerEntry[]> {\n  const data = await t.gql<{\n    workflowRuntime: {\n      pieceTriggers: {\n        name: string;\n        version: string;\n        triggers: Omit<PieceTriggerEntry, \"pieceName\" | \"pieceVersion\">[];\n      };\n    };\n  }>(\n    `query Triggers($packageName: String!) {\n      workflowRuntime { pieceTriggers(packageName: $packageName) }\n    }`,\n    { packageName },\n  );\n  const listing = data.workflowRuntime.pieceTriggers;\n  return atVersion({ ...listing, entries: listing.triggers });\n}\n\nexport interface BlockSearchHit {\n  pieceName: string;\n  pieceVersion: string;\n  // The action or trigger name.\n  name: string;\n  pieceDisplayName: string;\n  logoUrl: string;\n  displayName: string;\n  description: string;\n  kind: \"action\" | \"trigger\";\n  strategy: string | null;\n  unsupported: string | null;\n}\n\nexport interface BlockSearchResult {\n  status: \"ready\" | \"indexing\" | \"error\";\n  hits: BlockSearchHit[];\n  indexedPieces: number;\n  error: string | null;\n}\n\n// Catalog-wide action/trigger search; \"indexing\" on the very first calls.\nexport async function searchBlocks(\n  t: Transport,\n  query: string,\n  limit = 30,\n): Promise<BlockSearchResult> {\n  const data = await t.gql<{\n    workflowRuntime: { searchBlocks: BlockSearchResult };\n  }>(\n    `query SearchBlocks($query: String!, $limit: Int) {\n      workflowRuntime { searchBlocks(query: $query, limit: $limit) {\n        status indexedPieces error\n        hits { pieceName pieceVersion name pieceDisplayName logoUrl displayName description kind strategy unsupported }\n      } }\n    }`,\n    { query, limit },\n  );\n  return data.workflowRuntime.searchBlocks;\n}\n\nexport interface OutputTreeNode {\n  name: string;\n  type: string;\n  description?: string;\n  children?: OutputTreeNode[];\n}\n\nexport interface OutputTree {\n  source: \"schema\" | \"sample\" | \"static\" | \"none\" | \"test\";\n  nodes: OutputTreeNode[];\n  // source \"test\" only: the last test's output and when it ran.\n  sample?: unknown;\n  testedAt?: string;\n  runId?: string;\n}\n\nexport function fetchBlockOutputTree(\n  t: Transport,\n  block: BlockRef,\n  config: unknown,\n): Promise<OutputTree> {\n  return t\n    .gql<{ workflowRuntime: { blockOutputTree: OutputTree } }>(\n      `query OutputTree($block: BlockInput!, $config: Unknown) {\n        workflowRuntime { blockOutputTree(block: $block, config: $config) }\n      }`,\n      { block: blockInput(block), config: config ?? {} },\n    )\n    .then((data) => data.workflowRuntime.blockOutputTree);\n}\n\n// A draft step's or trigger's tree: its last test output, else its shape.\nexport function fetchStepOutputTree(\n  t: Transport,\n  workflowId: string,\n  stepId: string,\n): Promise<OutputTree> {\n  return t\n    .gql<{ workflowRuntime: { stepOutputTree: OutputTree } }>(\n      `query StepOutputTree($workflowId: String!, $stepId: String!) {\n        workflowRuntime { stepOutputTree(workflowId: $workflowId, stepId: $stepId) }\n      }`,\n      { workflowId, stepId },\n    )\n    .then((data) => data.workflowRuntime.stepOutputTree);\n}\n\nexport interface ConnectionSummary {\n  id: string;\n  name: string;\n  connectorId: string;\n  authType: string;\n  status: string;\n  accountLabel: string | null;\n}\n\n// Never persisted: the server scopes this list to the caller's read access.\nexport function fetchConnections(t: Transport): Promise<ConnectionSummary[]> {\n  return t\n    .gql<{\n      workflowRuntime: { connections: ConnectionSummary[] };\n    }>(\n      `query Connections { workflowRuntime { connections { id name connectorId authType status accountLabel } } }`,\n      {},\n    )\n    .then((data) => data.workflowRuntime.connections);\n}\n\nexport interface ConnectionCheckResult {\n  ok: boolean;\n  detail: string;\n  accountLabel: string | null;\n}\n\n// Runs the piece's own connection check against a document's stored credentials.\n// No secrets cross this boundary: the subgraph resolves refs server-side.\nexport function checkConnection(\n  t: Transport,\n  connectionId: string,\n): Promise<ConnectionCheckResult> {\n  return t\n    .gql<{\n      workflowRuntime: { checkConnection: ConnectionCheckResult };\n    }>(\n      `mutation CheckConnection($connectionId: String!) {\n      workflowRuntime {\n        checkConnection(connectionId: $connectionId) {\n          ok\n          detail\n          accountLabel\n        }\n      }\n    }`,\n      { connectionId },\n    )\n    .then((data) => data.workflowRuntime.checkConnection);\n}\n\nexport interface OAuthStart {\n  state: string;\n  authorizationUrl: string;\n  redirectUri: string;\n  expiresAt: string;\n}\n\nexport interface OAuthAttempt {\n  connectionId: string;\n  status: \"PENDING\" | \"EXCHANGING\" | \"OK\" | \"ERROR\";\n  error: string | null;\n}\n\n// The redirect an OAuth2 app registers, absolute: a bare path from a host\n// that doesn't know its origin is resolved against the URL it is reached at.\nexport async function fetchOAuthRedirectUri(\n  t: Transport,\n): Promise<string | null> {\n  const data = await t.gql<{\n    workflowRuntime: { oauthRedirectUri: string | null };\n  }>(`query OAuthRedirectUri { workflowRuntime { oauthRedirectUri } }`, {});\n  const uri = data.workflowRuntime.oauthRedirectUri;\n  return uri === null ? null : new URL(uri, t.url).href;\n}\n\nexport async function startOAuth(\n  t: Transport,\n  connectionId: string,\n  options: { redirectUri?: string; returnUrl?: string } = {},\n): Promise<OAuthStart> {\n  const data = await t.gql<{ workflowRuntime: { startOAuth: OAuthStart } }>(\n    `mutation StartOAuth($connectionId: String!, $redirectUri: String, $returnUrl: String) {\n      workflowRuntime {\n        startOAuth(connectionId: $connectionId, redirectUri: $redirectUri, returnUrl: $returnUrl) {\n          state authorizationUrl redirectUri expiresAt\n        }\n      }\n    }`,\n    {\n      connectionId,\n      redirectUri: options.redirectUri ?? null,\n      returnUrl: options.returnUrl ?? null,\n    },\n  );\n  return data.workflowRuntime.startOAuth;\n}\n\nexport async function fetchOAuthAttempt(\n  t: Transport,\n  state: string,\n): Promise<OAuthAttempt | null> {\n  const data = await t.gql<{\n    workflowRuntime: { oauthAttempt: OAuthAttempt | null };\n  }>(\n    `query OAuthAttempt($state: String!) {\n      workflowRuntime { oauthAttempt(state: $state) { connectionId status error } }\n    }`,\n    { state },\n  );\n  return data.workflowRuntime.oauthAttempt;\n}\n\nexport interface SecretStat {\n  ref: string;\n  label: string | null;\n  version: number;\n  status: \"ACTIVE\" | \"DELETED\";\n  createdAt: string;\n  updatedAt: string;\n}\n\nconst SECRET_FIELDS = \"ref label version status createdAt updatedAt\";\n\n// Mints a managed secret; only the returned ref ever enters a document.\nexport async function createSecret(\n  t: Transport,\n  value: string,\n  label?: string,\n): Promise<SecretStat> {\n  const data = await t.gql<{ workflowRuntime: { createSecret: SecretStat } }>(\n    `mutation CreateSecret($value: String!, $label: String) {\n      workflowRuntime { createSecret(value: $value, label: $label) { ${SECRET_FIELDS} } }\n    }`,\n    { value, label: label ?? null },\n  );\n  return data.workflowRuntime.createSecret;\n}\n\n// Same ref, version+1; referencing documents stay untouched.\nexport async function rotateSecret(\n  t: Transport,\n  ref: string,\n  value: string,\n): Promise<SecretStat> {\n  const data = await t.gql<{ workflowRuntime: { rotateSecret: SecretStat } }>(\n    `mutation RotateSecret($ref: String!, $value: String!) {\n      workflowRuntime { rotateSecret(ref: $ref, value: $value) { ${SECRET_FIELDS} } }\n    }`,\n    { ref, value },\n  );\n  return data.workflowRuntime.rotateSecret;\n}\n\n// Metadata only; null for unknown or legacy refs.\nexport async function fetchSecretStat(\n  t: Transport,\n  ref: string,\n): Promise<SecretStat | null> {\n  const data = await t.gql<{ workflowRuntime: { secret: SecretStat | null } }>(\n    `query Secret($ref: String!) {\n      workflowRuntime { secret(ref: $ref) { ${SECRET_FIELDS} } }\n    }`,\n    { ref },\n  );\n  return data.workflowRuntime.secret;\n}\n\nexport interface WebhookEndpointRecord {\n  workflowId: string;\n  url: string;\n  // False when `url` is a bare path because the reactor has no public origin.\n  absoluteUrl: boolean;\n  armed: boolean;\n  createdAt: string;\n}\n\n// Never cached: the runtime mints the endpoint on the first call and `armed`\n// tracks the workflow's status.\nexport async function fetchWebhookEndpoint(\n  t: Transport,\n  workflowId: string,\n  driveId?: string,\n): Promise<WebhookEndpointRecord | null> {\n  const data = await t.gql<{\n    workflowRuntime: { webhookEndpoint: WebhookEndpointRecord | null };\n  }>(\n    `query WebhookEndpoint($workflowId: String!, $driveId: String) {\n      workflowRuntime {\n        webhookEndpoint(workflowId: $workflowId, driveId: $driveId) {\n          workflowId url absoluteUrl armed createdAt\n        }\n      }\n    }`,\n    { workflowId, driveId: driveId ?? null },\n  );\n  return data.workflowRuntime.webhookEndpoint;\n}\n\nexport async function testTrigger(\n  t: Transport,\n  workflowId: string,\n  driveId?: string,\n): Promise<unknown> {\n  const data = await t.gql<{ workflowRuntime: { testTrigger: unknown } }>(\n    `mutation TestTrigger($workflowId: String!, $driveId: String) {\n      workflowRuntime { testTrigger(workflowId: $workflowId, driveId: $driveId) }\n    }`,\n    { workflowId, driveId: driveId ?? null },\n  );\n  return data.workflowRuntime.testTrigger;\n}\n\nexport interface CoreTriggerTestOptions {\n  // The manual trigger: the sample payload.\n  payload?: unknown;\n  // The webhook trigger: how long to wait for a delivery (default and cap 300).\n  timeoutSeconds?: number;\n  // Lets the runtime wait for a workflow that hasn't synced yet.\n  driveId?: string;\n}\n\n// Tests the draft trigger, core ones included: manual saves `payload`, schedule\n// samples a fire now, webhook resolves with the next delivery to its endpoint.\nexport async function testCoreTrigger(\n  t: Transport,\n  workflowId: string,\n  options: CoreTriggerTestOptions = {},\n): Promise<unknown> {\n  const data = await t.gql<{ workflowRuntime: { testTrigger: unknown } }>(\n    `mutation TestCoreTrigger($workflowId: String!, $payload: Unknown, $timeoutSeconds: Int, $driveId: String) {\n      workflowRuntime {\n        testTrigger(workflowId: $workflowId, payload: $payload, timeoutSeconds: $timeoutSeconds, driveId: $driveId)\n      }\n    }`,\n    {\n      workflowId,\n      payload: options.payload ?? null,\n      timeoutSeconds: options.timeoutSeconds ?? null,\n      driveId: options.driveId ?? null,\n    },\n  );\n  return data.workflowRuntime.testTrigger;\n}\n\n// Stops a waiting webhook test; false when none was waiting.\nexport async function cancelTriggerTest(\n  t: Transport,\n  workflowId: string,\n): Promise<boolean> {\n  const data = await t.gql<{ workflowRuntime: { cancelTriggerTest: boolean } }>(\n    `mutation CancelTriggerTest($workflowId: String!) {\n      workflowRuntime { cancelTriggerTest(workflowId: $workflowId) }\n    }`,\n    { workflowId },\n  );\n  return data.workflowRuntime.cancelTriggerTest;\n}\n\nexport interface StepTestResult {\n  // Null when the test never started, e.g. `Test \"fetch\" first`.\n  runId: string | null;\n  status: \"SUCCEEDED\" | \"FAILED\";\n  output: unknown;\n  error: string | null;\n  durationMs: number;\n}\n\n// Runs one draft step against the latest test outputs of the blocks it reads.\nexport async function testStep(\n  t: Transport,\n  workflowId: string,\n  stepId: string,\n  driveId?: string,\n): Promise<StepTestResult> {\n  const data = await t.gql<{ workflowRuntime: { testStep: StepTestResult } }>(\n    `mutation TestStep($workflowId: String!, $stepId: String!, $driveId: String) {\n      workflowRuntime {\n        testStep(workflowId: $workflowId, stepId: $stepId, driveId: $driveId) {\n          runId status output error durationMs\n        }\n      }\n    }`,\n    { workflowId, stepId, driveId: driveId ?? null },\n  );\n  return data.workflowRuntime.testStep;\n}\n\nexport type BlockMatch =\n  | \"exact\"\n  | \"compatible\"\n  | \"fallback\"\n  | \"installed\"\n  | \"missing\";\n\nexport interface BlockResolution {\n  // The trigger's or step's id.\n  stepId: string;\n  pieceName: string;\n  // The version the block pins.\n  pieceVersion: string;\n  name: string;\n  kind: \"action\" | \"trigger\";\n  // Null when nothing resolves.\n  resolvedVersion: string | null;\n  source: \"local\" | \"registry\" | \"activepieces\" | \"npm\" | null;\n  match: BlockMatch;\n  // Why the version that runs differs from the pin, or why nothing resolves.\n  note: string | null;\n  // Newest version any source offers.\n  latestVersion: string | null;\n}\n\n// Every block of the draft, trigger first, as the runtime would run it.\nexport async function blockResolutions(\n  t: Transport,\n  workflowId: string,\n): Promise<BlockResolution[]> {\n  const data = await t.gql<{\n    workflowRuntime: { blockResolutions: BlockResolution[] };\n  }>(\n    `query BlockResolutions($workflowId: String!) {\n      workflowRuntime {\n        blockResolutions(workflowId: $workflowId) {\n          stepId pieceName pieceVersion name kind resolvedVersion source match note latestVersion\n        }\n      }\n    }`,\n    { workflowId },\n  );\n  return data.workflowRuntime.blockResolutions;\n}\n\nexport interface RunStepRecord {\n  stepId: string;\n  stepKey: string;\n  pieceName: string;\n  // The action the step ran, or the trigger a trigger test sampled.\n  blockName: string;\n  status: string;\n  // Undefined on a listing row (fetchRunsPage); fetchRun reads them.\n  input: unknown;\n  output: unknown;\n  port: string | null;\n  error: string | null;\n  // Null for skipped and replayed steps, and for runs journaled before timings.\n  startedAt: string | null;\n  endedAt: string | null;\n}\n\nexport interface RunRecord {\n  id: string;\n  workflowId: string;\n  workflowName: string;\n  workflowVersion: number;\n  triggerKind: string;\n  triggerPayload: unknown;\n  status: string;\n  error: string | null;\n  startedAt: string;\n  endedAt: string | null;\n  rerunOf: string | null;\n  // Why a finished run is not a plain success, e.g. an edge nothing takes.\n  warningNotes: string[];\n  steps: RunStepRecord[];\n}\n\nconst RUN_ROW_FIELDS = `id workflowId workflowName workflowVersion triggerKind\n  triggerPayload status error startedAt endedAt rerunOf warningNotes`;\nconst STEP_ROW_FIELDS =\n  \"stepId stepKey pieceName blockName status port error startedAt endedAt\";\nconst RUN_FIELDS = `${RUN_ROW_FIELDS} steps { ${STEP_ROW_FIELDS} input output }`;\n// A listing row: the steps without their input and output.\nconst RUN_LIST_FIELDS = `${RUN_ROW_FIELDS} steps { ${STEP_ROW_FIELDS} }`;\n\nexport interface RunsScope {\n  workflowId?: string;\n  // Scopes runs to the workflows the drive holds; ignored alongside workflowId.\n  driveId?: string;\n  limit?: number;\n  // Left out by the runtime, so they never cost a page its rows.\n  excludeTriggerKinds?: string[];\n}\n\nfunction scopeVariables(scope: RunsScope, limit: number) {\n  return {\n    workflowId: scope.workflowId ?? null,\n    driveId: scope.driveId ?? null,\n    excludeTriggerKinds: scope.excludeTriggerKinds ?? null,\n    limit: scope.limit ?? limit,\n  };\n}\n\nexport async function fetchRuns(\n  t: Transport,\n  scope: RunsScope = {},\n): Promise<RunRecord[]> {\n  const data = await t.gql<{ workflowRuntime: { runs: RunRecord[] } }>(\n    `query Runs($workflowId: String, $driveId: String, $limit: Int, $excludeTriggerKinds: [String!]) {\n      workflowRuntime { runs(workflowId: $workflowId, driveId: $driveId, limit: $limit, excludeTriggerKinds: $excludeTriggerKinds) { ${RUN_FIELDS} } }\n    }`,\n    scopeVariables(scope, 30),\n  );\n  return data.workflowRuntime.runs;\n}\n\n// Steps come without input and output; fetchRun has them.\nexport interface RunPage {\n  items: RunRecord[];\n  hasNextPage: boolean;\n  cursor: string | null;\n}\n\nexport async function fetchRunsPage(\n  t: Transport,\n  scope: RunsScope = {},\n  cursor: string | null = null,\n): Promise<RunPage> {\n  const { limit, ...rest } = scopeVariables(scope, 30);\n  const data = await t.gql<{ workflowRuntime: { runsPage: RunPage } }>(\n    `query RunsPage($workflowId: String, $driveId: String, $excludeTriggerKinds: [String!], $paging: WorkflowRunsPagingInput) {\n      workflowRuntime {\n        runsPage(workflowId: $workflowId, driveId: $driveId, excludeTriggerKinds: $excludeTriggerKinds, paging: $paging) {\n          items { ${RUN_LIST_FIELDS} } hasNextPage cursor\n        }\n      }\n    }`,\n    { ...rest, paging: { limit, cursor } },\n  );\n  return data.workflowRuntime.runsPage;\n}\n\nexport async function fetchRun(\n  t: Transport,\n  runId: string,\n): Promise<RunRecord | null> {\n  const data = await t.gql<{ workflowRuntime: { run: RunRecord | null } }>(\n    `query Run($id: String!) { workflowRuntime { run(id: $id) { ${RUN_FIELDS} } } }`,\n    { id: runId },\n  );\n  return data.workflowRuntime.run;\n}\n\nexport interface FireResult {\n  runId: string | null;\n  status: string;\n  error: string | null;\n}\n\nexport async function fireWorkflow(\n  t: Transport,\n  workflowId: string,\n  payload?: unknown,\n): Promise<FireResult> {\n  const data = await t.gql<{ workflowRuntime: { fire: FireResult } }>(\n    `mutation Fire($workflowId: String!, $payload: Unknown) {\n      workflowRuntime { fire(workflowId: $workflowId, payload: $payload) { runId status error } }\n    }`,\n    { workflowId, payload: payload ?? {} },\n  );\n  return data.workflowRuntime.fire;\n}\n\n// Resume a FAILED run: succeeded steps replay, execution restarts at the\n// failure. Returns the new run.\nexport async function rerunRun(\n  t: Transport,\n  runId: string,\n): Promise<FireResult> {\n  const data = await t.gql<{ workflowRuntime: { rerun: FireResult } }>(\n    `mutation Rerun($runId: String!) {\n      workflowRuntime { rerun(runId: $runId) { runId status error } }\n    }`,\n    { runId },\n  );\n  return data.workflowRuntime.rerun;\n}\n\ninterface BlockOptionsResult {\n  workflowRuntime: { blockOptions: unknown };\n}\n\nexport async function loadBlockOptions(\n  t: Transport,\n  block: BlockRef,\n  propName: string,\n  input: Record<string, unknown>,\n  connectionId?: string,\n  searchValue?: string,\n): Promise<unknown> {\n  const data = await t.gql<BlockOptionsResult>(\n    `query Options($block: BlockInput!, $propName: String!, $input: Unknown, $connectionId: String, $searchValue: String) {\n      workflowRuntime { blockOptions(block: $block, propName: $propName, input: $input, connectionId: $connectionId, searchValue: $searchValue) }\n    }`,\n    {\n      block: blockInput(block),\n      propName,\n      input,\n      connectionId: connectionId ?? null,\n      searchValue: searchValue ?? null,\n    },\n  );\n  return data.workflowRuntime.blockOptions;\n}\n\nconst operations = {\n  getBlockForm,\n  fetchPieceCatalog,\n  fetchPieceActions,\n  fetchPieceTriggers,\n  searchBlocks,\n  fetchBlockOutputTree,\n  fetchStepOutputTree,\n  fetchConnections,\n  checkConnection,\n  fetchOAuthRedirectUri,\n  startOAuth,\n  fetchOAuthAttempt,\n  createSecret,\n  rotateSecret,\n  fetchSecretStat,\n  fetchWebhookEndpoint,\n  testTrigger,\n  testCoreTrigger,\n  cancelTriggerTest,\n  testStep,\n  blockResolutions,\n  fetchRuns,\n  fetchRunsPage,\n  fetchRun,\n  fireWorkflow,\n  rerunRun,\n  loadBlockOptions,\n};\n\ntype Operations = typeof operations;\ntype Bound<F> = F extends (t: Transport, ...args: infer A) => infer R\n  ? (...args: A) => R\n  : never;\ntype BoundOperations = { [K in keyof Operations]: Bound<Operations[K]> };\n\n// Every workflow-runtime call, bound to one subgraph URL. Holds no cache.\nexport type RuntimeClient = Transport & BoundOperations;\n\nexport function createRuntimeClient(\n  url: string,\n  options: RuntimeClientOptions = {},\n): RuntimeClient {\n  const transport = createTransport(url, options);\n  const bound = Object.fromEntries(\n    Object.entries(operations).map(([name, operation]) => [\n      name,\n      (...args: unknown[]) =>\n        (operation as (t: Transport, ...rest: unknown[]) => unknown)(\n          transport,\n          ...args,\n        ),\n    ]),\n  ) as BoundOperations;\n  return { ...transport, ...bound };\n}\n","// src/subscribable.ts\nvar Subscribable = class {\n  constructor() {\n    this.listeners = /* @__PURE__ */ new Set();\n    this.subscribe = this.subscribe.bind(this);\n  }\n  subscribe(listener) {\n    this.listeners.add(listener);\n    this.onSubscribe();\n    return () => {\n      this.listeners.delete(listener);\n      this.onUnsubscribe();\n    };\n  }\n  hasListeners() {\n    return this.listeners.size > 0;\n  }\n  onSubscribe() {\n  }\n  onUnsubscribe() {\n  }\n};\nexport {\n  Subscribable\n};\n//# sourceMappingURL=subscribable.js.map","// src/timeoutManager.ts\nvar defaultTimeoutProvider = {\n  // We need the wrapper function syntax below instead of direct references to\n  // global setTimeout etc.\n  //\n  // BAD: `setTimeout: setTimeout`\n  // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`\n  //\n  // If we use direct references here, then anything that wants to spy on or\n  // replace the global setTimeout (like tests) won't work since we'll already\n  // have a hard reference to the original implementation at the time when this\n  // file was imported.\n  setTimeout: (callback, delay) => setTimeout(callback, delay),\n  clearTimeout: (timeoutId) => clearTimeout(timeoutId),\n  setInterval: (callback, delay) => setInterval(callback, delay),\n  clearInterval: (intervalId) => clearInterval(intervalId)\n};\nvar TimeoutManager = class {\n  // We cannot have TimeoutManager<T> as we must instantiate it with a concrete\n  // type at app boot; and if we leave that type, then any new timer provider\n  // would need to support ReturnType<typeof setTimeout>, which is infeasible.\n  //\n  // We settle for type safety for the TimeoutProvider type, and accept that\n  // this class is unsafe internally to allow for extension.\n  #provider = defaultTimeoutProvider;\n  #providerCalled = false;\n  setTimeoutProvider(provider) {\n    if (process.env.NODE_ENV !== \"production\") {\n      if (this.#providerCalled && provider !== this.#provider) {\n        console.error(\n          `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,\n          { previous: this.#provider, provider }\n        );\n      }\n    }\n    this.#provider = provider;\n    if (process.env.NODE_ENV !== \"production\") {\n      this.#providerCalled = false;\n    }\n  }\n  setTimeout(callback, delay) {\n    if (process.env.NODE_ENV !== \"production\") {\n      this.#providerCalled = true;\n    }\n    return this.#provider.setTimeout(callback, delay);\n  }\n  clearTimeout(timeoutId) {\n    this.#provider.clearTimeout(timeoutId);\n  }\n  setInterval(callback, delay) {\n    if (process.env.NODE_ENV !== \"production\") {\n      this.#providerCalled = true;\n    }\n    return this.#provider.setInterval(callback, delay);\n  }\n  clearInterval(intervalId) {\n    this.#provider.clearInterval(intervalId);\n  }\n};\nvar timeoutManager = new TimeoutManager();\nfunction systemSetTimeoutZero(callback) {\n  setTimeout(callback, 0);\n}\nexport {\n  TimeoutManager,\n  defaultTimeoutProvider,\n  systemSetTimeoutZero,\n  timeoutManager\n};\n//# sourceMappingURL=timeoutManager.js.map","// src/utils.ts\nimport { timeoutManager } from \"./timeoutManager.js\";\nvar isServer = typeof window === \"undefined\" || \"Deno\" in globalThis;\nfunction noop() {\n}\nfunction functionalUpdate(updater, input) {\n  return typeof updater === \"function\" ? updater(input) : updater;\n}\nfunction isValidTimeout(value) {\n  return typeof value === \"number\" && value >= 0 && value !== Infinity;\n}\nfunction timeUntilStale(updatedAt, staleTime) {\n  return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);\n}\nfunction resolveStaleTime(staleTime, query) {\n  return typeof staleTime === \"function\" ? staleTime(query) : staleTime;\n}\nfunction resolveEnabled(enabled, query) {\n  return typeof enabled === \"function\" ? enabled(query) : enabled;\n}\nfunction matchQuery(filters, query) {\n  const {\n    type = \"all\",\n    exact,\n    fetchStatus,\n    predicate,\n    queryKey,\n    stale\n  } = filters;\n  if (queryKey) {\n    if (exact) {\n      if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {\n        return false;\n      }\n    } else if (!partialMatchKey(query.queryKey, queryKey)) {\n      return false;\n    }\n  }\n  if (type !== \"all\") {\n    const isActive = query.isActive();\n    if (type === \"active\" && !isActive) {\n      return false;\n    }\n    if (type === \"inactive\" && isActive) {\n      return false;\n    }\n  }\n  if (typeof stale === \"boolean\" && query.isStale() !== stale) {\n    return false;\n  }\n  if (fetchStatus && fetchStatus !== query.state.fetchStatus) {\n    return false;\n  }\n  if (predicate && !predicate(query)) {\n    return false;\n  }\n  return true;\n}\nfunction matchMutation(filters, mutation) {\n  const { exact, status, predicate, mutationKey } = filters;\n  if (mutationKey) {\n    if (!mutation.options.mutationKey) {\n      return false;\n    }\n    if (exact) {\n      if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {\n        return false;\n      }\n    } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {\n      return false;\n    }\n  }\n  if (status && mutation.state.status !== status) {\n    return false;\n  }\n  if (predicate && !predicate(mutation)) {\n    return false;\n  }\n  return true;\n}\nfunction hashQueryKeyByOptions(queryKey, options) {\n  const hashFn = options?.queryKeyHashFn || hashKey;\n  return hashFn(queryKey);\n}\nfunction hashKey(queryKey) {\n  return JSON.stringify(\n    queryKey,\n    (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {\n      result[key] = val[key];\n      return result;\n    }, {}) : val\n  );\n}\nfunction partialMatchKey(a, b) {\n  if (a === b) {\n    return true;\n  }\n  if (typeof a !== typeof b) {\n    return false;\n  }\n  if (a && b && typeof a === \"object\" && typeof b === \"object\") {\n    return Object.keys(b).every((key) => partialMatchKey(a[key], b[key]));\n  }\n  return false;\n}\nvar hasOwn = Object.prototype.hasOwnProperty;\nfunction replaceEqualDeep(a, b, depth = 0) {\n  if (a === b) {\n    return a;\n  }\n  if (depth > 500) return b;\n  const array = isPlainArray(a) && isPlainArray(b);\n  if (!array && !(isPlainObject(a) && isPlainObject(b))) return b;\n  const aItems = array ? a : Object.keys(a);\n  const aSize = aItems.length;\n  const bItems = array ? b : Object.keys(b);\n  const bSize = bItems.length;\n  const copy = array ? new Array(bSize) : {};\n  let equalItems = 0;\n  for (let i = 0; i < bSize; i++) {\n    const key = array ? i : bItems[i];\n    const aItem = a[key];\n    const bItem = b[key];\n    if (aItem === bItem) {\n      copy[key] = aItem;\n      if (array ? i < aSize : hasOwn.call(a, key)) equalItems++;\n      continue;\n    }\n    if (aItem === null || bItem === null || typeof aItem !== \"object\" || typeof bItem !== \"object\") {\n      copy[key] = bItem;\n      continue;\n    }\n    const v = replaceEqualDeep(aItem, bItem, depth + 1);\n    copy[key] = v;\n    if (v === aItem) equalItems++;\n  }\n  return aSize === bSize && equalItems === aSize ? a : copy;\n}\nfunction shallowEqualObjects(a, b) {\n  if (!b || Object.keys(a).length !== Object.keys(b).length) {\n    return false;\n  }\n  for (const key in a) {\n    if (a[key] !== b[key]) {\n      return false;\n    }\n  }\n  return true;\n}\nfunction isPlainArray(value) {\n  return Array.isArray(value) && value.length === Object.keys(value).length;\n}\nfunction isPlainObject(o) {\n  if (!hasObjectPrototype(o)) {\n    return false;\n  }\n  const ctor = o.constructor;\n  if (ctor === void 0) {\n    return true;\n  }\n  const prot = ctor.prototype;\n  if (!hasObjectPrototype(prot)) {\n    return false;\n  }\n  if (!prot.hasOwnProperty(\"isPrototypeOf\")) {\n    return false;\n  }\n  if (Object.getPrototypeOf(o) !== Object.prototype) {\n    return false;\n  }\n  return true;\n}\nfunction hasObjectPrototype(o) {\n  return Object.prototype.toString.call(o) === \"[object Object]\";\n}\nfunction sleep(timeout) {\n  return new Promise((resolve) => {\n    timeoutManager.setTimeout(resolve, timeout);\n  });\n}\nfunction replaceData(prevData, data, options) {\n  if (typeof options.structuralSharing === \"function\") {\n    return options.structuralSharing(prevData, data);\n  } else if (options.structuralSharing !== false) {\n    if (process.env.NODE_ENV !== \"production\") {\n      try {\n        return replaceEqualDeep(prevData, data);\n      } catch (error) {\n        console.error(\n          `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`\n        );\n        throw error;\n      }\n    }\n    return replaceEqualDeep(prevData, data);\n  }\n  return data;\n}\nfunction keepPreviousData(previousData) {\n  return previousData;\n}\nfunction addToEnd(items, item, max = 0) {\n  const newItems = [...items, item];\n  return max && newItems.length > max ? newItems.slice(1) : newItems;\n}\nfunction addToStart(items, item, max = 0) {\n  const newItems = [item, ...items];\n  return max && newItems.length > max ? newItems.slice(0, -1) : newItems;\n}\nvar skipToken = /* @__PURE__ */ Symbol();\nfunction ensureQueryFn(options, fetchOptions) {\n  if (process.env.NODE_ENV !== \"production\") {\n    if (options.queryFn === skipToken) {\n      console.error(\n        `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'`\n      );\n    }\n  }\n  if (!options.queryFn && fetchOptions?.initialPromise) {\n    return () => fetchOptions.initialPromise;\n  }\n  if (!options.queryFn || options.queryFn === skipToken) {\n    return () => Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`));\n  }\n  return options.queryFn;\n}\nfunction shouldThrowError(throwOnError, params) {\n  if (typeof throwOnError === \"function\") {\n    return throwOnError(...params);\n  }\n  return !!throwOnError;\n}\nfunction addConsumeAwareSignal(object, getSignal, onCancelled) {\n  let consumed = false;\n  let signal;\n  Object.defineProperty(object, \"signal\", {\n    enumerable: true,\n    get: () => {\n      signal ??= getSignal();\n      if (consumed) {\n        return signal;\n      }\n      consumed = true;\n      if (signal.aborted) {\n        onCancelled();\n      } else {\n        signal.addEventListener(\"abort\", onCancelled, { once: true });\n      }\n      return signal;\n    }\n  });\n  return object;\n}\nexport {\n  addConsumeAwareSignal,\n  addToEnd,\n  addToStart,\n  ensureQueryFn,\n  functionalUpdate,\n  hashKey,\n  hashQueryKeyByOptions,\n  isPlainArray,\n  isPlainObject,\n  isServer,\n  isValidTimeout,\n  keepPreviousData,\n  matchMutation,\n  matchQuery,\n  noop,\n  partialMatchKey,\n  replaceData,\n  replaceEqualDeep,\n  resolveEnabled,\n  resolveStaleTime,\n  shallowEqualObjects,\n  shouldThrowError,\n  skipToken,\n  sleep,\n  timeUntilStale\n};\n//# sourceMappingURL=utils.js.map","// src/focusManager.ts\nimport { Subscribable } from \"./subscribable.js\";\nimport { isServer } from \"./utils.js\";\nvar FocusManager = class extends Subscribable {\n  #focused;\n  #cleanup;\n  #setup;\n  constructor() {\n    super();\n    this.#setup = (onFocus) => {\n      if (!isServer && window.addEventListener) {\n        const listener = () => onFocus();\n        window.addEventListener(\"visibilitychange\", listener, false);\n        return () => {\n          window.removeEventListener(\"visibilitychange\", listener);\n        };\n      }\n      return;\n    };\n  }\n  onSubscribe() {\n    if (!this.#cleanup) {\n      this.setEventListener(this.#setup);\n    }\n  }\n  onUnsubscribe() {\n    if (!this.hasListeners()) {\n      this.#cleanup?.();\n      this.#cleanup = void 0;\n    }\n  }\n  setEventListener(setup) {\n    this.#setup = setup;\n    this.#cleanup?.();\n    this.#cleanup = setup((focused) => {\n      if (typeof focused === \"boolean\") {\n        this.setFocused(focused);\n      } else {\n        this.onFocus();\n      }\n    });\n  }\n  setFocused(focused) {\n    const changed = this.#focused !== focused;\n    if (changed) {\n      this.#focused = focused;\n      this.onFocus();\n    }\n  }\n  onFocus() {\n    const isFocused = this.isFocused();\n    this.listeners.forEach((listener) => {\n      listener(isFocused);\n    });\n  }\n  isFocused() {\n    if (typeof this.#focused === \"boolean\") {\n      return this.#focused;\n    }\n    return globalThis.document?.visibilityState !== \"hidden\";\n  }\n};\nvar focusManager = new FocusManager();\nexport {\n  FocusManager,\n  focusManager\n};\n//# sourceMappingURL=focusManager.js.map","// src/thenable.ts\nimport { noop } from \"./utils.js\";\nfunction pendingThenable() {\n  let resolve;\n  let reject;\n  const thenable = new Promise((_resolve, _reject) => {\n    resolve = _resolve;\n    reject = _reject;\n  });\n  thenable.status = \"pending\";\n  thenable.catch(() => {\n  });\n  function finalize(data) {\n    Object.assign(thenable, data);\n    delete thenable.resolve;\n    delete thenable.reject;\n  }\n  thenable.resolve = (value) => {\n    finalize({\n      status: \"fulfilled\",\n      value\n    });\n    resolve(value);\n  };\n  thenable.reject = (reason) => {\n    finalize({\n      status: \"rejected\",\n      reason\n    });\n    reject(reason);\n  };\n  return thenable;\n}\nfunction tryResolveSync(promise) {\n  let data;\n  promise.then((result) => {\n    data = result;\n    return result;\n  }, noop)?.catch(noop);\n  if (data !== void 0) {\n    return { data };\n  }\n  return void 0;\n}\nexport {\n  pendingThenable,\n  tryResolveSync\n};\n//# sourceMappingURL=thenable.js.map","// src/notifyManager.ts\nimport { systemSetTimeoutZero } from \"./timeoutManager.js\";\nvar defaultScheduler = systemSetTimeoutZero;\nfunction createNotifyManager() {\n  let queue = [];\n  let transactions = 0;\n  let notifyFn = (callback) => {\n    callback();\n  };\n  let batchNotifyFn = (callback) => {\n    callback();\n  };\n  let scheduleFn = defaultScheduler;\n  const schedule = (callback) => {\n    if (transactions) {\n      queue.push(callback);\n    } else {\n      scheduleFn(() => {\n        notifyFn(callback);\n      });\n    }\n  };\n  const flush = () => {\n    const originalQueue = queue;\n    queue = [];\n    if (originalQueue.length) {\n      scheduleFn(() => {\n        batchNotifyFn(() => {\n          originalQueue.forEach((callback) => {\n            notifyFn(callback);\n          });\n        });\n      });\n    }\n  };\n  return {\n    batch: (callback) => {\n      let result;\n      transactions++;\n      try {\n        result = callback();\n      } finally {\n        transactions--;\n        if (!transactions) {\n          flush();\n        }\n      }\n      return result;\n    },\n    /**\n     * All calls to the wrapped function will be batched.\n     */\n    batchCalls: (callback) => {\n      return (...args) => {\n        schedule(() => {\n          callback(...args);\n        });\n      };\n    },\n    schedule,\n    /**\n     * Use this method to set a custom notify function.\n     * This can be used to for example wrap notifications with `React.act` while running tests.\n     */\n    setNotifyFunction: (fn) => {\n      notifyFn = fn;\n    },\n    /**\n     * Use this method to set a custom function to batch notifications together into a single tick.\n     * By default React Query will use the batch function provided by ReactDOM or React Native.\n     */\n    setBatchNotifyFunction: (fn) => {\n      batchNotifyFn = fn;\n    },\n    setScheduler: (fn) => {\n      scheduleFn = fn;\n    }\n  };\n}\nvar notifyManager = createNotifyManager();\nexport {\n  createNotifyManager,\n  defaultScheduler,\n  notifyManager\n};\n//# sourceMappingURL=notifyManager.js.map","// src/onlineManager.ts\nimport { Subscribable } from \"./subscribable.js\";\nimport { isServer } from \"./utils.js\";\nvar OnlineManager = class extends Subscribable {\n  #online = true;\n  #cleanup;\n  #setup;\n  constructor() {\n    super();\n    this.#setup = (onOnline) => {\n      if (!isServer && window.addEventListener) {\n        const onlineListener = () => onOnline(true);\n        const offlineListener = () => onOnline(false);\n        window.addEventListener(\"online\", onlineListener, false);\n        window.addEventListener(\"offline\", offlineListener, false);\n        return () => {\n          window.removeEventListener(\"online\", onlineListener);\n          window.removeEventListener(\"offline\", offlineListener);\n        };\n      }\n      return;\n    };\n  }\n  onSubscribe() {\n    if (!this.#cleanup) {\n      this.setEventListener(this.#setup);\n    }\n  }\n  onUnsubscribe() {\n    if (!this.hasListeners()) {\n      this.#cleanup?.();\n      this.#cleanup = void 0;\n    }\n  }\n  setEventListener(setup) {\n    this.#setup = setup;\n    this.#cleanup?.();\n    this.#cleanup = setup(this.setOnline.bind(this));\n  }\n  setOnline(online) {\n    const changed = this.#online !== online;\n    if (changed) {\n      this.#online = online;\n      this.listeners.forEach((listener) => {\n        listener(online);\n      });\n    }\n  }\n  isOnline() {\n    return this.#online;\n  }\n};\nvar onlineManager = new OnlineManager();\nexport {\n  OnlineManager,\n  onlineManager\n};\n//# sourceMappingURL=onlineManager.js.map","// src/retryer.ts\nimport { focusManager } from \"./focusManager.js\";\nimport { onlineManager } from \"./onlineManager.js\";\nimport { pendingThenable } from \"./thenable.js\";\nimport { isServer, sleep } from \"./utils.js\";\nfunction defaultRetryDelay(failureCount) {\n  return Math.min(1e3 * 2 ** failureCount, 3e4);\n}\nfunction canFetch(networkMode) {\n  return (networkMode ?? \"online\") === \"online\" ? onlineManager.isOnline() : true;\n}\nvar CancelledError = class extends Error {\n  constructor(options) {\n    super(\"CancelledError\");\n    this.revert = options?.revert;\n    this.silent = options?.silent;\n  }\n};\nfunction isCancelledError(value) {\n  return value instanceof CancelledError;\n}\nfunction createRetryer(config) {\n  let isRetryCancelled = false;\n  let failureCount = 0;\n  let continueFn;\n  const thenable = pendingThenable();\n  const isResolved = () => thenable.status !== \"pending\";\n  const cancel = (cancelOptions) => {\n    if (!isResolved()) {\n      const error = new CancelledError(cancelOptions);\n      reject(error);\n      config.onCancel?.(error);\n    }\n  };\n  const cancelRetry = () => {\n    isRetryCancelled = true;\n  };\n  const continueRetry = () => {\n    isRetryCancelled = false;\n  };\n  const canContinue = () => focusManager.isFocused() && (config.networkMode === \"always\" || onlineManager.isOnline()) && config.canRun();\n  const canStart = () => canFetch(config.networkMode) && config.canRun();\n  const resolve = (value) => {\n    if (!isResolved()) {\n      continueFn?.();\n      thenable.resolve(value);\n    }\n  };\n  const reject = (value) => {\n    if (!isResolved()) {\n      continueFn?.();\n      thenable.reject(value);\n    }\n  };\n  const pause = () => {\n    return new Promise((continueResolve) => {\n      continueFn = (value) => {\n        if (isResolved() || canContinue()) {\n          continueResolve(value);\n        }\n      };\n      config.onPause?.();\n    }).then(() => {\n      continueFn = void 0;\n      if (!isResolved()) {\n        config.onContinue?.();\n      }\n    });\n  };\n  const run = () => {\n    if (isResolved()) {\n      return;\n    }\n    let promiseOrValue;\n    const initialPromise = failureCount === 0 ? config.initialPromise : void 0;\n    try {\n      promiseOrValue = initialPromise ?? config.fn();\n    } catch (error) {\n      promiseOrValue = Promise.reject(error);\n    }\n    Promise.resolve(promiseOrValue).then(resolve).catch((error) => {\n      if (isResolved()) {\n        return;\n      }\n      const retry = config.retry ?? (isServer ? 0 : 3);\n      const retryDelay = config.retryDelay ?? defaultRetryDelay;\n      const delay = typeof retryDelay === \"function\" ? retryDelay(failureCount, error) : retryDelay;\n      const shouldRetry = retry === true || typeof retry === \"number\" && failureCount < retry || typeof retry === \"function\" && retry(failureCount, error);\n      if (isRetryCancelled || !shouldRetry) {\n        reject(error);\n        return;\n      }\n      failureCount++;\n      config.onFail?.(failureCount, error);\n      sleep(delay).then(() => {\n        return canContinue() ? void 0 : pause();\n      }).then(() => {\n        if (isRetryCancelled) {\n          reject(error);\n        } else {\n          run();\n        }\n      });\n    });\n  };\n  return {\n    promise: thenable,\n    status: () => thenable.status,\n    cancel,\n    continue: () => {\n      continueFn?.();\n      return thenable;\n    },\n    cancelRetry,\n    continueRetry,\n    canStart,\n    start: () => {\n      if (canStart()) {\n        run();\n      } else {\n        pause().then(run);\n      }\n      return thenable;\n    }\n  };\n}\nexport {\n  CancelledError,\n  canFetch,\n  createRetryer,\n  isCancelledError\n};\n//# sourceMappingURL=retryer.js.map","// src/removable.ts\nimport { timeoutManager } from \"./timeoutManager.js\";\nimport { isServer, isValidTimeout } from \"./utils.js\";\nvar Removable = class {\n  #gcTimeout;\n  destroy() {\n    this.clearGcTimeout();\n  }\n  scheduleGc() {\n    this.clearGcTimeout();\n    if (isValidTimeout(this.gcTime)) {\n      this.#gcTimeout = timeoutManager.setTimeout(() => {\n        this.optionalRemove();\n      }, this.gcTime);\n    }\n  }\n  updateGcTime(newGcTime) {\n    this.gcTime = Math.max(\n      this.gcTime || 0,\n      newGcTime ?? (isServer ? Infinity : 5 * 60 * 1e3)\n    );\n  }\n  clearGcTimeout() {\n    if (this.#gcTimeout) {\n      timeoutManager.clearTimeout(this.#gcTimeout);\n      this.#gcTimeout = void 0;\n    }\n  }\n};\nexport {\n  Removable\n};\n//# sourceMappingURL=removable.js.map","// src/query.ts\nimport {\n  ensureQueryFn,\n  noop,\n  replaceData,\n  resolveEnabled,\n  resolveStaleTime,\n  skipToken,\n  timeUntilStale\n} from \"./utils.js\";\nimport { notifyManager } from \"./notifyManager.js\";\nimport { CancelledError, canFetch, createRetryer } from \"./retryer.js\";\nimport { Removable } from \"./removable.js\";\nvar Query = class extends Removable {\n  #initialState;\n  #revertState;\n  #cache;\n  #client;\n  #retryer;\n  #defaultOptions;\n  #abortSignalConsumed;\n  constructor(config) {\n    super();\n    this.#abortSignalConsumed = false;\n    this.#defaultOptions = config.defaultOptions;\n    this.setOptions(config.options);\n    this.observers = [];\n    this.#client = config.client;\n    this.#cache = this.#client.getQueryCache();\n    this.queryKey = config.queryKey;\n    this.queryHash = config.queryHash;\n    this.#initialState = getDefaultState(this.options);\n    this.state = config.state ?? this.#initialState;\n    this.scheduleGc();\n  }\n  get meta() {\n    return this.options.meta;\n  }\n  get promise() {\n    return this.#retryer?.promise;\n  }\n  setOptions(options) {\n    this.options = { ...this.#defaultOptions, ...options };\n    this.updateGcTime(this.options.gcTime);\n    if (this.state && this.state.data === void 0) {\n      const defaultState = getDefaultState(this.options);\n      if (defaultState.data !== void 0) {\n        this.setState(\n          successState(defaultState.data, defaultState.dataUpdatedAt)\n        );\n        this.#initialState = defaultState;\n      }\n    }\n  }\n  optionalRemove() {\n    if (!this.observers.length && this.state.fetchStatus === \"idle\") {\n      this.#cache.remove(this);\n    }\n  }\n  setData(newData, options) {\n    const data = replaceData(this.state.data, newData, this.options);\n    this.#dispatch({\n      data,\n      type: \"success\",\n      dataUpdatedAt: options?.updatedAt,\n      manual: options?.manual\n    });\n    return data;\n  }\n  setState(state, setStateOptions) {\n    this.#dispatch({ type: \"setState\", state, setStateOptions });\n  }\n  cancel(options) {\n    const promise = this.#retryer?.promise;\n    this.#retryer?.cancel(options);\n    return promise ? promise.then(noop).catch(noop) : Promise.resolve();\n  }\n  destroy() {\n    super.destroy();\n    this.cancel({ silent: true });\n  }\n  reset() {\n    this.destroy();\n    this.setState(this.#initialState);\n  }\n  isActive() {\n    return this.observers.some(\n      (observer) => resolveEnabled(observer.options.enabled, this) !== false\n    );\n  }\n  isDisabled() {\n    if (this.getObserversCount() > 0) {\n      return !this.isActive();\n    }\n    return this.options.queryFn === skipToken || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;\n  }\n  isStatic() {\n    if (this.getObserversCount() > 0) {\n      return this.observers.some(\n        (observer) => resolveStaleTime(observer.options.staleTime, this) === \"static\"\n      );\n    }\n    return false;\n  }\n  isStale() {\n    if (this.getObserversCount() > 0) {\n      return this.observers.some(\n        (observer) => observer.getCurrentResult().isStale\n      );\n    }\n    return this.state.data === void 0 || this.state.isInvalidated;\n  }\n  isStaleByTime(staleTime = 0) {\n    if (this.state.data === void 0) {\n      return true;\n    }\n    if (staleTime === \"static\") {\n      return false;\n    }\n    if (this.state.isInvalidated) {\n      return true;\n    }\n    return !timeUntilStale(this.state.dataUpdatedAt, staleTime);\n  }\n  onFocus() {\n    const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus());\n    observer?.refetch({ cancelRefetch: false });\n    this.#retryer?.continue();\n  }\n  onOnline() {\n    const observer = this.observers.find((x) => x.shouldFetchOnReconnect());\n    observer?.refetch({ cancelRefetch: false });\n    this.#retryer?.continue();\n  }\n  addObserver(observer) {\n    if (!this.observers.includes(observer)) {\n      this.observers.push(observer);\n      this.clearGcTimeout();\n      this.#cache.notify({ type: \"observerAdded\", query: this, observer });\n    }\n  }\n  removeObserver(observer) {\n    if (this.observers.includes(observer)) {\n      this.observers = this.observers.filter((x) => x !== observer);\n      if (!this.observers.length) {\n        if (this.#retryer) {\n          if (this.#abortSignalConsumed) {\n            this.#retryer.cancel({ revert: true });\n          } else {\n            this.#retryer.cancelRetry();\n          }\n        }\n        this.scheduleGc();\n      }\n      this.#cache.notify({ type: \"observerRemoved\", query: this, observer });\n    }\n  }\n  getObserversCount() {\n    return this.observers.length;\n  }\n  invalidate() {\n    if (!this.state.isInvalidated) {\n      this.#dispatch({ type: \"invalidate\" });\n    }\n  }\n  async fetch(options, fetchOptions) {\n    if (this.state.fetchStatus !== \"idle\" && // If the promise in the retryer is already rejected, we have to definitely\n    // re-start the fetch; there is a chance that the query is still in a\n    // pending state when that happens\n    this.#retryer?.status() !== \"rejected\") {\n      if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) {\n        this.cancel({ silent: true });\n      } else if (this.#retryer) {\n        this.#retryer.continueRetry();\n        return this.#retryer.promise;\n      }\n    }\n    if (options) {\n      this.setOptions(options);\n    }\n    if (!this.options.queryFn) {\n      const observer = this.observers.find((x) => x.options.queryFn);\n      if (observer) {\n        this.setOptions(observer.options);\n      }\n    }\n    if (process.env.NODE_ENV !== \"production\") {\n      if (!Array.isArray(this.options.queryKey)) {\n        console.error(\n          `As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']`\n        );\n      }\n    }\n    const abortController = new AbortController();\n    const addSignalProperty = (object) => {\n      Object.defineProperty(object, \"signal\", {\n        enumerable: true,\n        get: () => {\n          this.#abortSignalConsumed = true;\n          return abortController.signal;\n        }\n      });\n    };\n    const fetchFn = () => {\n      const queryFn = ensureQueryFn(this.options, fetchOptions);\n      const createQueryFnContext = () => {\n        const queryFnContext2 = {\n          client: this.#client,\n          queryKey: this.queryKey,\n          meta: this.meta\n        };\n        addSignalProperty(queryFnContext2);\n        return queryFnContext2;\n      };\n      const queryFnContext = createQueryFnContext();\n      this.#abortSignalConsumed = false;\n      if (this.options.persister) {\n        return this.options.persister(\n          queryFn,\n          queryFnContext,\n          this\n        );\n      }\n      return queryFn(queryFnContext);\n    };\n    const createFetchContext = () => {\n      const context2 = {\n        fetchOptions,\n        options: this.options,\n        queryKey: this.queryKey,\n        client: this.#client,\n        state: this.state,\n        fetchFn\n      };\n      addSignalProperty(context2);\n      return context2;\n    };\n    const context = createFetchContext();\n    this.options.behavior?.onFetch(context, this);\n    this.#revertState = this.state;\n    if (this.state.fetchStatus === \"idle\" || this.state.fetchMeta !== context.fetchOptions?.meta) {\n      this.#dispatch({ type: \"fetch\", meta: context.fetchOptions?.meta });\n    }\n    this.#retryer = createRetryer({\n      initialPromise: fetchOptions?.initialPromise,\n      fn: context.fetchFn,\n      onCancel: (error) => {\n        if (error instanceof CancelledError && error.revert) {\n          this.setState({\n            ...this.#revertState,\n            fetchStatus: \"idle\"\n          });\n        }\n        abortController.abort();\n      },\n      onFail: (failureCount, error) => {\n        this.#dispatch({ type: \"failed\", failureCount, error });\n      },\n      onPause: () => {\n        this.#dispatch({ type: \"pause\" });\n      },\n      onContinue: () => {\n        this.#dispatch({ type: \"continue\" });\n      },\n      retry: context.options.retry,\n      retryDelay: context.options.retryDelay,\n      networkMode: context.options.networkMode,\n      canRun: () => true\n    });\n    try {\n      const data = await this.#retryer.start();\n      if (data === void 0) {\n        if (process.env.NODE_ENV !== \"production\") {\n          console.error(\n            `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`\n          );\n        }\n        throw new Error(`${this.queryHash} data is undefined`);\n      }\n      this.setData(data);\n      this.#cache.config.onSuccess?.(data, this);\n      this.#cache.config.onSettled?.(\n        data,\n        this.state.error,\n        this\n      );\n      return data;\n    } catch (error) {\n      if (error instanceof CancelledError) {\n        if (error.silent) {\n          return this.#retryer.promise;\n        } else if (error.revert) {\n          if (this.state.data === void 0) {\n            throw error;\n          }\n          return this.state.data;\n        }\n      }\n      this.#dispatch({\n        type: \"error\",\n        error\n      });\n      this.#cache.config.onError?.(\n        error,\n        this\n      );\n      this.#cache.config.onSettled?.(\n        this.state.data,\n        error,\n        this\n      );\n      throw error;\n    } finally {\n      this.scheduleGc();\n    }\n  }\n  #dispatch(action) {\n    const reducer = (state) => {\n      switch (action.type) {\n        case \"failed\":\n          return {\n            ...state,\n            fetchFailureCount: action.failureCount,\n            fetchFailureReason: action.error\n          };\n        case \"pause\":\n          return {\n            ...state,\n            fetchStatus: \"paused\"\n          };\n        case \"continue\":\n          return {\n            ...state,\n            fetchStatus: \"fetching\"\n          };\n        case \"fetch\":\n          return {\n            ...state,\n            ...fetchState(state.data, this.options),\n            fetchMeta: action.meta ?? null\n          };\n        case \"success\":\n          const newState = {\n            ...state,\n            ...successState(action.data, action.dataUpdatedAt),\n            dataUpdateCount: state.dataUpdateCount + 1,\n            ...!action.manual && {\n              fetchStatus: \"idle\",\n              fetchFailureCount: 0,\n              fetchFailureReason: null\n            }\n          };\n          this.#revertState = action.manual ? newState : void 0;\n          return newState;\n        case \"error\":\n          const error = action.error;\n          return {\n            ...state,\n            error,\n            errorUpdateCount: state.errorUpdateCount + 1,\n            errorUpdatedAt: Date.now(),\n            fetchFailureCount: state.fetchFailureCount + 1,\n            fetchFailureReason: error,\n            fetchStatus: \"idle\",\n            status: \"error\",\n            // flag existing data as invalidated if we get a background error\n            // note that \"no data\" always means stale so we can set unconditionally here\n            isInvalidated: true\n          };\n        case \"invalidate\":\n          return {\n            ...state,\n            isInvalidated: true\n          };\n        case \"setState\":\n          return {\n            ...state,\n            ...action.state\n          };\n      }\n    };\n    this.state = reducer(this.state);\n    notifyManager.batch(() => {\n      this.observers.forEach((observer) => {\n        observer.onQueryUpdate();\n      });\n      this.#cache.notify({ query: this, type: \"updated\", action });\n    });\n  }\n};\nfunction fetchState(data, options) {\n  return {\n    fetchFailureCount: 0,\n    fetchFailureReason: null,\n    fetchStatus: canFetch(options.networkMode) ? \"fetching\" : \"paused\",\n    ...data === void 0 && {\n      error: null,\n      status: \"pending\"\n    }\n  };\n}\nfunction successState(data, dataUpdatedAt) {\n  return {\n    data,\n    dataUpdatedAt: dataUpdatedAt ?? Date.now(),\n    error: null,\n    isInvalidated: false,\n    status: \"success\"\n  };\n}\nfunction getDefaultState(options) {\n  const data = typeof options.initialData === \"function\" ? options.initialData() : options.initialData;\n  const hasData = data !== void 0;\n  const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === \"function\" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;\n  return {\n    data,\n    dataUpdateCount: 0,\n    dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0,\n    error: null,\n    errorUpdateCount: 0,\n    errorUpdatedAt: 0,\n    fetchFailureCount: 0,\n    fetchFailureReason: null,\n    fetchMeta: null,\n    isInvalidated: false,\n    status: hasData ? \"success\" : \"pending\",\n    fetchStatus: \"idle\"\n  };\n}\nexport {\n  Query,\n  fetchState\n};\n//# sourceMappingURL=query.js.map","// src/infiniteQueryBehavior.ts\nimport {\n  addConsumeAwareSignal,\n  addToEnd,\n  addToStart,\n  ensureQueryFn\n} from \"./utils.js\";\nfunction infiniteQueryBehavior(pages) {\n  return {\n    onFetch: (context, query) => {\n      const options = context.options;\n      const direction = context.fetchOptions?.meta?.fetchMore?.direction;\n      const oldPages = context.state.data?.pages || [];\n      const oldPageParams = context.state.data?.pageParams || [];\n      let result = { pages: [], pageParams: [] };\n      let currentPage = 0;\n      const fetchFn = async () => {\n        let cancelled = false;\n        const addSignalProperty = (object) => {\n          addConsumeAwareSignal(\n            object,\n            () => context.signal,\n            () => cancelled = true\n          );\n        };\n        const queryFn = ensureQueryFn(context.options, context.fetchOptions);\n        const fetchPage = async (data, param, previous) => {\n          if (cancelled) {\n            return Promise.reject();\n          }\n          if (param == null && data.pages.length) {\n            return Promise.resolve(data);\n          }\n          const createQueryFnContext = () => {\n            const queryFnContext2 = {\n              client: context.client,\n              queryKey: context.queryKey,\n              pageParam: param,\n              direction: previous ? \"backward\" : \"forward\",\n              meta: context.options.meta\n            };\n            addSignalProperty(queryFnContext2);\n            return queryFnContext2;\n          };\n          const queryFnContext = createQueryFnContext();\n          const page = await queryFn(queryFnContext);\n          const { maxPages } = context.options;\n          const addTo = previous ? addToStart : addToEnd;\n          return {\n            pages: addTo(data.pages, page, maxPages),\n            pageParams: addTo(data.pageParams, param, maxPages)\n          };\n        };\n        if (direction && oldPages.length) {\n          const previous = direction === \"backward\";\n          const pageParamFn = previous ? getPreviousPageParam : getNextPageParam;\n          const oldData = {\n            pages: oldPages,\n            pageParams: oldPageParams\n          };\n          const param = pageParamFn(options, oldData);\n          result = await fetchPage(oldData, param, previous);\n        } else {\n          const remainingPages = pages ?? oldPages.length;\n          do {\n            const param = currentPage === 0 ? oldPageParams[0] ?? options.initialPageParam : getNextPageParam(options, result);\n            if (currentPage > 0 && param == null) {\n              break;\n            }\n            result = await fetchPage(result, param);\n            currentPage++;\n          } while (currentPage < remainingPages);\n        }\n        return result;\n      };\n      if (context.options.persister) {\n        context.fetchFn = () => {\n          return context.options.persister?.(\n            fetchFn,\n            {\n              client: context.client,\n              queryKey: context.queryKey,\n              meta: context.options.meta,\n              signal: context.signal\n            },\n            query\n          );\n        };\n      } else {\n        context.fetchFn = fetchFn;\n      }\n    }\n  };\n}\nfunction getNextPageParam(options, { pages, pageParams }) {\n  const lastIndex = pages.length - 1;\n  return pages.length > 0 ? options.getNextPageParam(\n    pages[lastIndex],\n    pages,\n    pageParams[lastIndex],\n    pageParams\n  ) : void 0;\n}\nfunction getPreviousPageParam(options, { pages, pageParams }) {\n  return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : void 0;\n}\nfunction hasNextPage(options, data) {\n  if (!data) return false;\n  return getNextPageParam(options, data) != null;\n}\nfunction hasPreviousPage(options, data) {\n  if (!data || !options.getPreviousPageParam) return false;\n  return getPreviousPageParam(options, data) != null;\n}\nexport {\n  hasNextPage,\n  hasPreviousPage,\n  infiniteQueryBehavior\n};\n//# sourceMappingURL=infiniteQueryBehavior.js.map","// src/mutation.ts\nimport { notifyManager } from \"./notifyManager.js\";\nimport { Removable } from \"./removable.js\";\nimport { createRetryer } from \"./retryer.js\";\nvar Mutation = class extends Removable {\n  #client;\n  #observers;\n  #mutationCache;\n  #retryer;\n  constructor(config) {\n    super();\n    this.#client = config.client;\n    this.mutationId = config.mutationId;\n    this.#mutationCache = config.mutationCache;\n    this.#observers = [];\n    this.state = config.state || getDefaultState();\n    this.setOptions(config.options);\n    this.scheduleGc();\n  }\n  setOptions(options) {\n    this.options = options;\n    this.updateGcTime(this.options.gcTime);\n  }\n  get meta() {\n    return this.options.meta;\n  }\n  addObserver(observer) {\n    if (!this.#observers.includes(observer)) {\n      this.#observers.push(observer);\n      this.clearGcTimeout();\n      this.#mutationCache.notify({\n        type: \"observerAdded\",\n        mutation: this,\n        observer\n      });\n    }\n  }\n  removeObserver(observer) {\n    this.#observers = this.#observers.filter((x) => x !== observer);\n    this.scheduleGc();\n    this.#mutationCache.notify({\n      type: \"observerRemoved\",\n      mutation: this,\n      observer\n    });\n  }\n  optionalRemove() {\n    if (!this.#observers.length) {\n      if (this.state.status === \"pending\") {\n        this.scheduleGc();\n      } else {\n        this.#mutationCache.remove(this);\n      }\n    }\n  }\n  continue() {\n    return this.#retryer?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before\n    this.execute(this.state.variables);\n  }\n  async execute(variables) {\n    const onContinue = () => {\n      this.#dispatch({ type: \"continue\" });\n    };\n    const mutationFnContext = {\n      client: this.#client,\n      meta: this.options.meta,\n      mutationKey: this.options.mutationKey\n    };\n    this.#retryer = createRetryer({\n      fn: () => {\n        if (!this.options.mutationFn) {\n          return Promise.reject(new Error(\"No mutationFn found\"));\n        }\n        return this.options.mutationFn(variables, mutationFnContext);\n      },\n      onFail: (failureCount, error) => {\n        this.#dispatch({ type: \"failed\", failureCount, error });\n      },\n      onPause: () => {\n        this.#dispatch({ type: \"pause\" });\n      },\n      onContinue,\n      retry: this.options.retry ?? 0,\n      retryDelay: this.options.retryDelay,\n      networkMode: this.options.networkMode,\n      canRun: () => this.#mutationCache.canRun(this)\n    });\n    const restored = this.state.status === \"pending\";\n    const isPaused = !this.#retryer.canStart();\n    try {\n      if (restored) {\n        onContinue();\n      } else {\n        this.#dispatch({ type: \"pending\", variables, isPaused });\n        if (this.#mutationCache.config.onMutate) {\n          await this.#mutationCache.config.onMutate(\n            variables,\n            this,\n            mutationFnContext\n          );\n        }\n        const context = await this.options.onMutate?.(\n          variables,\n          mutationFnContext\n        );\n        if (context !== this.state.context) {\n          this.#dispatch({\n            type: \"pending\",\n            context,\n            variables,\n            isPaused\n          });\n        }\n      }\n      const data = await this.#retryer.start();\n      await this.#mutationCache.config.onSuccess?.(\n        data,\n        variables,\n        this.state.context,\n        this,\n        mutationFnContext\n      );\n      await this.options.onSuccess?.(\n        data,\n        variables,\n        this.state.context,\n        mutationFnContext\n      );\n      await this.#mutationCache.config.onSettled?.(\n        data,\n        null,\n        this.state.variables,\n        this.state.context,\n        this,\n        mutationFnContext\n      );\n      await this.options.onSettled?.(\n        data,\n        null,\n        variables,\n        this.state.context,\n        mutationFnContext\n      );\n      this.#dispatch({ type: \"success\", data });\n      return data;\n    } catch (error) {\n      try {\n        await this.#mutationCache.config.onError?.(\n          error,\n          variables,\n          this.state.context,\n          this,\n          mutationFnContext\n        );\n      } catch (e) {\n        void Promise.reject(e);\n      }\n      try {\n        await this.options.onError?.(\n          error,\n          variables,\n          this.state.context,\n          mutationFnContext\n        );\n      } catch (e) {\n        void Promise.reject(e);\n      }\n      try {\n        await this.#mutationCache.config.onSettled?.(\n          void 0,\n          error,\n          this.state.variables,\n          this.state.context,\n          this,\n          mutationFnContext\n        );\n      } catch (e) {\n        void Promise.reject(e);\n      }\n      try {\n        await this.options.onSettled?.(\n          void 0,\n          error,\n          variables,\n          this.state.context,\n          mutationFnContext\n        );\n      } catch (e) {\n        void Promise.reject(e);\n      }\n      this.#dispatch({ type: \"error\", error });\n      throw error;\n    } finally {\n      this.#mutationCache.runNext(this);\n    }\n  }\n  #dispatch(action) {\n    const reducer = (state) => {\n      switch (action.type) {\n        case \"failed\":\n          return {\n            ...state,\n            failureCount: action.failureCount,\n            failureReason: action.error\n          };\n        case \"pause\":\n          return {\n            ...state,\n            isPaused: true\n          };\n        case \"continue\":\n          return {\n            ...state,\n            isPaused: false\n          };\n        case \"pending\":\n          return {\n            ...state,\n            context: action.context,\n            data: void 0,\n            failureCount: 0,\n            failureReason: null,\n            error: null,\n            isPaused: action.isPaused,\n            status: \"pending\",\n            variables: action.variables,\n            submittedAt: Date.now()\n          };\n        case \"success\":\n          return {\n            ...state,\n            data: action.data,\n            failureCount: 0,\n            failureReason: null,\n            error: null,\n            status: \"success\",\n            isPaused: false\n          };\n        case \"error\":\n          return {\n            ...state,\n            data: void 0,\n            error: action.error,\n            failureCount: state.failureCount + 1,\n            failureReason: action.error,\n            isPaused: false,\n            status: \"error\"\n          };\n      }\n    };\n    this.state = reducer(this.state);\n    notifyManager.batch(() => {\n      this.#observers.forEach((observer) => {\n        observer.onMutationUpdate(action);\n      });\n      this.#mutationCache.notify({\n        mutation: this,\n        type: \"updated\",\n        action\n      });\n    });\n  }\n};\nfunction getDefaultState() {\n  return {\n    context: void 0,\n    data: void 0,\n    error: null,\n    failureCount: 0,\n    failureReason: null,\n    isPaused: false,\n    status: \"idle\",\n    variables: void 0,\n    submittedAt: 0\n  };\n}\nexport {\n  Mutation,\n  getDefaultState\n};\n//# sourceMappingURL=mutation.js.map","// src/mutationCache.ts\nimport { notifyManager } from \"./notifyManager.js\";\nimport { Mutation } from \"./mutation.js\";\nimport { matchMutation, noop } from \"./utils.js\";\nimport { Subscribable } from \"./subscribable.js\";\nvar MutationCache = class extends Subscribable {\n  constructor(config = {}) {\n    super();\n    this.config = config;\n    this.#mutations = /* @__PURE__ */ new Set();\n    this.#scopes = /* @__PURE__ */ new Map();\n    this.#mutationId = 0;\n  }\n  #mutations;\n  #scopes;\n  #mutationId;\n  build(client, options, state) {\n    const mutation = new Mutation({\n      client,\n      mutationCache: this,\n      mutationId: ++this.#mutationId,\n      options: client.defaultMutationOptions(options),\n      state\n    });\n    this.add(mutation);\n    return mutation;\n  }\n  add(mutation) {\n    this.#mutations.add(mutation);\n    const scope = scopeFor(mutation);\n    if (typeof scope === \"string\") {\n      const scopedMutations = this.#scopes.get(scope);\n      if (scopedMutations) {\n        scopedMutations.push(mutation);\n      } else {\n        this.#scopes.set(scope, [mutation]);\n      }\n    }\n    this.notify({ type: \"added\", mutation });\n  }\n  remove(mutation) {\n    if (this.#mutations.delete(mutation)) {\n      const scope = scopeFor(mutation);\n      if (typeof scope === \"string\") {\n        const scopedMutations = this.#scopes.get(scope);\n        if (scopedMutations) {\n          if (scopedMutations.length > 1) {\n            const index = scopedMutations.indexOf(mutation);\n            if (index !== -1) {\n              scopedMutations.splice(index, 1);\n            }\n          } else if (scopedMutations[0] === mutation) {\n            this.#scopes.delete(scope);\n          }\n        }\n      }\n    }\n    this.notify({ type: \"removed\", mutation });\n  }\n  canRun(mutation) {\n    const scope = scopeFor(mutation);\n    if (typeof scope === \"string\") {\n      const mutationsWithSameScope = this.#scopes.get(scope);\n      const firstPendingMutation = mutationsWithSameScope?.find(\n        (m) => m.state.status === \"pending\"\n      );\n      return !firstPendingMutation || firstPendingMutation === mutation;\n    } else {\n      return true;\n    }\n  }\n  runNext(mutation) {\n    const scope = scopeFor(mutation);\n    if (typeof scope === \"string\") {\n      const foundMutation = this.#scopes.get(scope)?.find((m) => m !== mutation && m.state.isPaused);\n      return foundMutation?.continue() ?? Promise.resolve();\n    } else {\n      return Promise.resolve();\n    }\n  }\n  clear() {\n    notifyManager.batch(() => {\n      this.#mutations.forEach((mutation) => {\n        this.notify({ type: \"removed\", mutation });\n      });\n      this.#mutations.clear();\n      this.#scopes.clear();\n    });\n  }\n  getAll() {\n    return Array.from(this.#mutations);\n  }\n  find(filters) {\n    const defaultedFilters = { exact: true, ...filters };\n    return this.getAll().find(\n      (mutation) => matchMutation(defaultedFilters, mutation)\n    );\n  }\n  findAll(filters = {}) {\n    return this.getAll().filter((mutation) => matchMutation(filters, mutation));\n  }\n  notify(event) {\n    notifyManager.batch(() => {\n      this.listeners.forEach((listener) => {\n        listener(event);\n      });\n    });\n  }\n  resumePausedMutations() {\n    const pausedMutations = this.getAll().filter((x) => x.state.isPaused);\n    return notifyManager.batch(\n      () => Promise.all(\n        pausedMutations.map((mutation) => mutation.continue().catch(noop))\n      )\n    );\n  }\n};\nfunction scopeFor(mutation) {\n  return mutation.options.scope?.id;\n}\nexport {\n  MutationCache\n};\n//# sourceMappingURL=mutationCache.js.map","// src/queryCache.ts\nimport { hashQueryKeyByOptions, matchQuery } from \"./utils.js\";\nimport { Query } from \"./query.js\";\nimport { notifyManager } from \"./notifyManager.js\";\nimport { Subscribable } from \"./subscribable.js\";\nvar QueryCache = class extends Subscribable {\n  constructor(config = {}) {\n    super();\n    this.config = config;\n    this.#queries = /* @__PURE__ */ new Map();\n  }\n  #queries;\n  build(client, options, state) {\n    const queryKey = options.queryKey;\n    const queryHash = options.queryHash ?? hashQueryKeyByOptions(queryKey, options);\n    let query = this.get(queryHash);\n    if (!query) {\n      query = new Query({\n        client,\n        queryKey,\n        queryHash,\n        options: client.defaultQueryOptions(options),\n        state,\n        defaultOptions: client.getQueryDefaults(queryKey)\n      });\n      this.add(query);\n    }\n    return query;\n  }\n  add(query) {\n    if (!this.#queries.has(query.queryHash)) {\n      this.#queries.set(query.queryHash, query);\n      this.notify({\n        type: \"added\",\n        query\n      });\n    }\n  }\n  remove(query) {\n    const queryInMap = this.#queries.get(query.queryHash);\n    if (queryInMap) {\n      query.destroy();\n      if (queryInMap === query) {\n        this.#queries.delete(query.queryHash);\n      }\n      this.notify({ type: \"removed\", query });\n    }\n  }\n  clear() {\n    notifyManager.batch(() => {\n      this.getAll().forEach((query) => {\n        this.remove(query);\n      });\n    });\n  }\n  get(queryHash) {\n    return this.#queries.get(queryHash);\n  }\n  getAll() {\n    return [...this.#queries.values()];\n  }\n  find(filters) {\n    const defaultedFilters = { exact: true, ...filters };\n    return this.getAll().find(\n      (query) => matchQuery(defaultedFilters, query)\n    );\n  }\n  findAll(filters = {}) {\n    const queries = this.getAll();\n    return Object.keys(filters).length > 0 ? queries.filter((query) => matchQuery(filters, query)) : queries;\n  }\n  notify(event) {\n    notifyManager.batch(() => {\n      this.listeners.forEach((listener) => {\n        listener(event);\n      });\n    });\n  }\n  onFocus() {\n    notifyManager.batch(() => {\n      this.getAll().forEach((query) => {\n        query.onFocus();\n      });\n    });\n  }\n  onOnline() {\n    notifyManager.batch(() => {\n      this.getAll().forEach((query) => {\n        query.onOnline();\n      });\n    });\n  }\n};\nexport {\n  QueryCache\n};\n//# sourceMappingURL=queryCache.js.map","// src/queryClient.ts\nimport {\n  functionalUpdate,\n  hashKey,\n  hashQueryKeyByOptions,\n  noop,\n  partialMatchKey,\n  resolveStaleTime,\n  skipToken\n} from \"./utils.js\";\nimport { QueryCache } from \"./queryCache.js\";\nimport { MutationCache } from \"./mutationCache.js\";\nimport { focusManager } from \"./focusManager.js\";\nimport { onlineManager } from \"./onlineManager.js\";\nimport { notifyManager } from \"./notifyManager.js\";\nimport { infiniteQueryBehavior } from \"./infiniteQueryBehavior.js\";\nvar QueryClient = class {\n  #queryCache;\n  #mutationCache;\n  #defaultOptions;\n  #queryDefaults;\n  #mutationDefaults;\n  #mountCount;\n  #unsubscribeFocus;\n  #unsubscribeOnline;\n  constructor(config = {}) {\n    this.#queryCache = config.queryCache || new QueryCache();\n    this.#mutationCache = config.mutationCache || new MutationCache();\n    this.#defaultOptions = config.defaultOptions || {};\n    this.#queryDefaults = /* @__PURE__ */ new Map();\n    this.#mutationDefaults = /* @__PURE__ */ new Map();\n    this.#mountCount = 0;\n  }\n  mount() {\n    this.#mountCount++;\n    if (this.#mountCount !== 1) return;\n    this.#unsubscribeFocus = focusManager.subscribe(async (focused) => {\n      if (focused) {\n        await this.resumePausedMutations();\n        this.#queryCache.onFocus();\n      }\n    });\n    this.#unsubscribeOnline = onlineManager.subscribe(async (online) => {\n      if (online) {\n        await this.resumePausedMutations();\n        this.#queryCache.onOnline();\n      }\n    });\n  }\n  unmount() {\n    this.#mountCount--;\n    if (this.#mountCount !== 0) return;\n    this.#unsubscribeFocus?.();\n    this.#unsubscribeFocus = void 0;\n    this.#unsubscribeOnline?.();\n    this.#unsubscribeOnline = void 0;\n  }\n  isFetching(filters) {\n    return this.#queryCache.findAll({ ...filters, fetchStatus: \"fetching\" }).length;\n  }\n  isMutating(filters) {\n    return this.#mutationCache.findAll({ ...filters, status: \"pending\" }).length;\n  }\n  /**\n   * Imperative (non-reactive) way to retrieve data for a QueryKey.\n   * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.\n   *\n   * Hint: Do not use this function inside a component, because it won't receive updates.\n   * Use `useQuery` to create a `QueryObserver` that subscribes to changes.\n   */\n  getQueryData(queryKey) {\n    const options = this.defaultQueryOptions({ queryKey });\n    return this.#queryCache.get(options.queryHash)?.state.data;\n  }\n  ensureQueryData(options) {\n    const defaultedOptions = this.defaultQueryOptions(options);\n    const query = this.#queryCache.build(this, defaultedOptions);\n    const cachedData = query.state.data;\n    if (cachedData === void 0) {\n      return this.fetchQuery(options);\n    }\n    if (options.revalidateIfStale && query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query))) {\n      void this.prefetchQuery(defaultedOptions);\n    }\n    return Promise.resolve(cachedData);\n  }\n  getQueriesData(filters) {\n    return this.#queryCache.findAll(filters).map(({ queryKey, state }) => {\n      const data = state.data;\n      return [queryKey, data];\n    });\n  }\n  setQueryData(queryKey, updater, options) {\n    const defaultedOptions = this.defaultQueryOptions({ queryKey });\n    const query = this.#queryCache.get(\n      defaultedOptions.queryHash\n    );\n    const prevData = query?.state.data;\n    const data = functionalUpdate(updater, prevData);\n    if (data === void 0) {\n      return void 0;\n    }\n    return this.#queryCache.build(this, defaultedOptions).setData(data, { ...options, manual: true });\n  }\n  setQueriesData(filters, updater, options) {\n    return notifyManager.batch(\n      () => this.#queryCache.findAll(filters).map(({ queryKey }) => [\n        queryKey,\n        this.setQueryData(queryKey, updater, options)\n      ])\n    );\n  }\n  getQueryState(queryKey) {\n    const options = this.defaultQueryOptions({ queryKey });\n    return this.#queryCache.get(\n      options.queryHash\n    )?.state;\n  }\n  removeQueries(filters) {\n    const queryCache = this.#queryCache;\n    notifyManager.batch(() => {\n      queryCache.findAll(filters).forEach((query) => {\n        queryCache.remove(query);\n      });\n    });\n  }\n  resetQueries(filters, options) {\n    const queryCache = this.#queryCache;\n    return notifyManager.batch(() => {\n      queryCache.findAll(filters).forEach((query) => {\n        query.reset();\n      });\n      return this.refetchQueries(\n        {\n          type: \"active\",\n          ...filters\n        },\n        options\n      );\n    });\n  }\n  cancelQueries(filters, cancelOptions = {}) {\n    const defaultedCancelOptions = { revert: true, ...cancelOptions };\n    const promises = notifyManager.batch(\n      () => this.#queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions))\n    );\n    return Promise.all(promises).then(noop).catch(noop);\n  }\n  invalidateQueries(filters, options = {}) {\n    return notifyManager.batch(() => {\n      this.#queryCache.findAll(filters).forEach((query) => {\n        query.invalidate();\n      });\n      if (filters?.refetchType === \"none\") {\n        return Promise.resolve();\n      }\n      return this.refetchQueries(\n        {\n          ...filters,\n          type: filters?.refetchType ?? filters?.type ?? \"active\"\n        },\n        options\n      );\n    });\n  }\n  refetchQueries(filters, options = {}) {\n    const fetchOptions = {\n      ...options,\n      cancelRefetch: options.cancelRefetch ?? true\n    };\n    const promises = notifyManager.batch(\n      () => this.#queryCache.findAll(filters).filter((query) => !query.isDisabled() && !query.isStatic()).map((query) => {\n        let promise = query.fetch(void 0, fetchOptions);\n        if (!fetchOptions.throwOnError) {\n          promise = promise.catch(noop);\n        }\n        return query.state.fetchStatus === \"paused\" ? Promise.resolve() : promise;\n      })\n    );\n    return Promise.all(promises).then(noop);\n  }\n  fetchQuery(options) {\n    const defaultedOptions = this.defaultQueryOptions(options);\n    if (defaultedOptions.retry === void 0) {\n      defaultedOptions.retry = false;\n    }\n    const query = this.#queryCache.build(this, defaultedOptions);\n    return query.isStaleByTime(\n      resolveStaleTime(defaultedOptions.staleTime, query)\n    ) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);\n  }\n  prefetchQuery(options) {\n    return this.fetchQuery(options).then(noop).catch(noop);\n  }\n  fetchInfiniteQuery(options) {\n    options.behavior = infiniteQueryBehavior(options.pages);\n    return this.fetchQuery(options);\n  }\n  prefetchInfiniteQuery(options) {\n    return this.fetchInfiniteQuery(options).then(noop).catch(noop);\n  }\n  ensureInfiniteQueryData(options) {\n    options.behavior = infiniteQueryBehavior(options.pages);\n    return this.ensureQueryData(options);\n  }\n  resumePausedMutations() {\n    if (onlineManager.isOnline()) {\n      return this.#mutationCache.resumePausedMutations();\n    }\n    return Promise.resolve();\n  }\n  getQueryCache() {\n    return this.#queryCache;\n  }\n  getMutationCache() {\n    return this.#mutationCache;\n  }\n  getDefaultOptions() {\n    return this.#defaultOptions;\n  }\n  setDefaultOptions(options) {\n    this.#defaultOptions = options;\n  }\n  setQueryDefaults(queryKey, options) {\n    this.#queryDefaults.set(hashKey(queryKey), {\n      queryKey,\n      defaultOptions: options\n    });\n  }\n  getQueryDefaults(queryKey) {\n    const defaults = [...this.#queryDefaults.values()];\n    const result = {};\n    defaults.forEach((queryDefault) => {\n      if (partialMatchKey(queryKey, queryDefault.queryKey)) {\n        Object.assign(result, queryDefault.defaultOptions);\n      }\n    });\n    return result;\n  }\n  setMutationDefaults(mutationKey, options) {\n    this.#mutationDefaults.set(hashKey(mutationKey), {\n      mutationKey,\n      defaultOptions: options\n    });\n  }\n  getMutationDefaults(mutationKey) {\n    const defaults = [...this.#mutationDefaults.values()];\n    const result = {};\n    defaults.forEach((queryDefault) => {\n      if (partialMatchKey(mutationKey, queryDefault.mutationKey)) {\n        Object.assign(result, queryDefault.defaultOptions);\n      }\n    });\n    return result;\n  }\n  defaultQueryOptions(options) {\n    if (options._defaulted) {\n      return options;\n    }\n    const defaultedOptions = {\n      ...this.#defaultOptions.queries,\n      ...this.getQueryDefaults(options.queryKey),\n      ...options,\n      _defaulted: true\n    };\n    if (!defaultedOptions.queryHash) {\n      defaultedOptions.queryHash = hashQueryKeyByOptions(\n        defaultedOptions.queryKey,\n        defaultedOptions\n      );\n    }\n    if (defaultedOptions.refetchOnReconnect === void 0) {\n      defaultedOptions.refetchOnReconnect = defaultedOptions.networkMode !== \"always\";\n    }\n    if (defaultedOptions.throwOnError === void 0) {\n      defaultedOptions.throwOnError = !!defaultedOptions.suspense;\n    }\n    if (!defaultedOptions.networkMode && defaultedOptions.persister) {\n      defaultedOptions.networkMode = \"offlineFirst\";\n    }\n    if (defaultedOptions.queryFn === skipToken) {\n      defaultedOptions.enabled = false;\n    }\n    return defaultedOptions;\n  }\n  defaultMutationOptions(options) {\n    if (options?._defaulted) {\n      return options;\n    }\n    return {\n      ...this.#defaultOptions.mutations,\n      ...options?.mutationKey && this.getMutationDefaults(options.mutationKey),\n      ...options,\n      _defaulted: true\n    };\n  }\n  clear() {\n    this.#queryCache.clear();\n    this.#mutationCache.clear();\n  }\n};\nexport {\n  QueryClient\n};\n//# sourceMappingURL=queryClient.js.map","// src/queryOptions.ts\nfunction queryOptions(options) {\n  return options;\n}\nexport {\n  queryOptions\n};\n//# sourceMappingURL=queryOptions.js.map","// src/infiniteQueryOptions.ts\nfunction infiniteQueryOptions(options) {\n  return options;\n}\nexport {\n  infiniteQueryOptions\n};\n//# sourceMappingURL=infiniteQueryOptions.js.map","// Design-time tests are journaled as runs of this kind.\nexport const TEST_TRIGGER_KIND = \"test\";\n\n// Runs as the author sees them: tests aren't executions of the workflow.\nexport function realRuns<T extends { triggerKind: string }>(runs: T[]): T[] {\n  return runs.filter((run) => run.triggerKind !== TEST_TRIGGER_KIND);\n}\n","// Query keys for runtime data. Every key starts with the runtime URL (the\n// \"scope\"), so two runtimes never share an entry.\nimport type { BlockRef } from \"@powerhousedao/pieces-framework/block-type\";\n\n// A block as a key part: every field, the version included.\nexport function blockPart(block: BlockRef) {\n  return [block.pieceName, block.pieceVersion, block.kind, block.name] as const;\n}\n\n// The same, as one string for a Map key.\nexport function blockRefKey(block: BlockRef): string {\n  return blockPart(block).join(\" \");\n}\n\nexport type RuntimeQueryKind =\n  | \"catalog\"\n  | \"form\"\n  | \"pieceActions\"\n  | \"pieceTriggers\"\n  | \"searchBlocks\"\n  | \"outputTree\"\n  | \"options\"\n  | \"dynamic\"\n  | \"connections\"\n  | \"webhook\"\n  | \"latestRun\"\n  | \"runs\"\n  | \"run\"\n  | \"secret\"\n  | \"blockResolutions\";\n\nexport interface ResolverKeyInput {\n  block: BlockRef;\n  propName: string;\n  // Values of the prop's refreshers, in declaration order.\n  refreshers: unknown[];\n  connectionId?: string | null;\n  searchValue?: string | null;\n}\n\nfunction resolverKey(\n  scope: string,\n  kind: \"options\" | \"dynamic\",\n  input: ResolverKeyInput,\n) {\n  return [\n    scope,\n    kind,\n    blockPart(input.block),\n    input.propName,\n    input.refreshers,\n    input.connectionId ?? null,\n    input.searchValue ?? null,\n  ] as const;\n}\n\nexport const runtimeKeys = {\n  all: (scope: string) => [scope] as const,\n  catalog: (scope: string) => [scope, \"catalog\"] as const,\n  form: (scope: string, block: BlockRef) =>\n    [scope, \"form\", blockPart(block)] as const,\n  pieceActions: (scope: string, packageName: string) =>\n    [scope, \"pieceActions\", packageName] as const,\n  pieceTriggers: (scope: string, packageName: string) =>\n    [scope, \"pieceTriggers\", packageName] as const,\n  searchBlocks: (scope: string, query: string, limit: number) =>\n    [scope, \"searchBlocks\", query, limit] as const,\n  outputTrees: (scope: string) => [scope, \"outputTree\"] as const,\n  outputTree: (scope: string, block: BlockRef, config: unknown) =>\n    [scope, \"outputTree\", blockPart(block), config ?? {}] as const,\n  // Keyed by the test it reads, so a new test is a new entry.\n  stepOutputTree: (\n    scope: string,\n    workflowId: string,\n    stepId: string,\n    testedAt: string | null,\n  ) => [scope, \"outputTree\", \"step\", workflowId, stepId, testedAt] as const,\n  options: (scope: string, input: ResolverKeyInput) =>\n    resolverKey(scope, \"options\", input),\n  dynamic: (scope: string, input: ResolverKeyInput) =>\n    resolverKey(scope, \"dynamic\", input),\n  // `filter` tells apart listings a caller narrows, e.g. to one drive.\n  connections: (scope: string, filter?: string | null) =>\n    filter === undefined\n      ? ([scope, \"connections\"] as const)\n      : ([scope, \"connections\", filter] as const),\n  webhook: (scope: string, workflowId: string) =>\n    [scope, \"webhook\", workflowId] as const,\n  latestRun: (scope: string, workflowId: string) =>\n    [scope, \"latestRun\", workflowId] as const,\n  allRuns: (scope: string) => [scope, \"runs\"] as const,\n  runs: (\n    scope: string,\n    runsScope: { workflowId?: string; driveId?: string; limit?: number },\n  ) =>\n    [\n      scope,\n      \"runs\",\n      {\n        workflowId: runsScope.workflowId ?? null,\n        driveId: runsScope.driveId ?? null,\n        limit: runsScope.limit ?? null,\n      },\n    ] as const,\n  // Under allRuns, so every invalidation of the listing reaches the pages.\n  runPages: (\n    scope: string,\n    runsScope: { workflowId?: string; driveId?: string; limit?: number },\n  ) =>\n    [\n      scope,\n      \"runs\",\n      \"pages\",\n      {\n        workflowId: runsScope.workflowId ?? null,\n        driveId: runsScope.driveId ?? null,\n        limit: runsScope.limit ?? null,\n      },\n    ] as const,\n  run: (scope: string, runId: string) => [scope, \"run\", runId] as const,\n  secret: (scope: string, ref: string) => [scope, \"secret\", ref] as const,\n  allBlockResolutions: (scope: string, workflowId: string) =>\n    [scope, \"blockResolutions\", workflowId] as const,\n  // `blocks` is the draft's, trigger first, so an edit is a new entry.\n  blockResolutions: (\n    scope: string,\n    workflowId: string,\n    blocks: readonly BlockRef[],\n  ) => [scope, \"blockResolutions\", workflowId, blocks.map(blockPart)] as const,\n};\n\nexport function queryKind(key: readonly unknown[]): string | undefined {\n  return typeof key[1] === \"string\" ? key[1] : undefined;\n}\n\n// Piece metadata that is the same for every caller of one runtime.\nexport const SHARED_STALE_MS = 30 * 60_000;\n// Resolver answers depend on the caller's connection; kept briefly.\nexport const RESOLVER_STALE_MS = 5 * 60_000;\n","// Query options over a RuntimeClient. Keys come from ui/query-keys, so the\n// editor's hooks and these factories address the same cache entries.\nimport {\n  infiniteQueryOptions,\n  mutationOptions,\n  QueryClient,\n  queryOptions,\n  useMutation,\n} from \"@tanstack/react-query\";\nimport type { BlockRef } from \"@powerhousedao/pieces-framework/block-type\";\nimport type {\n  RunPage,\n  RunRecord,\n  RunsScope,\n  RuntimeClient,\n  StepTestResult,\n} from \"./runtime-client.js\";\nimport { realRuns, TEST_TRIGGER_KIND } from \"./run-kinds.js\";\nimport { runtimeKeys, SHARED_STALE_MS } from \"./ui/query-keys.js\";\n\nexport function createRuntimeQueryClient(): QueryClient {\n  return new QueryClient({\n    defaultOptions: {\n      // Callers surface failures themselves, with their own retry buttons.\n      queries: { retry: false, refetchOnWindowFocus: false },\n      mutations: { retry: false },\n    },\n  });\n}\n\nexport const catalogQuery = (client: RuntimeClient) =>\n  queryOptions({\n    queryKey: runtimeKeys.catalog(client.url),\n    queryFn: () => client.fetchPieceCatalog(),\n    staleTime: SHARED_STALE_MS,\n  });\n\nexport const blockFormQuery = (client: RuntimeClient, block: BlockRef) =>\n  queryOptions({\n    queryKey: runtimeKeys.form(client.url, block),\n    queryFn: () => client.getBlockForm(block),\n    staleTime: SHARED_STALE_MS,\n  });\n\nexport const pieceActionsQuery = (client: RuntimeClient, packageName: string) =>\n  queryOptions({\n    queryKey: runtimeKeys.pieceActions(client.url, packageName),\n    queryFn: () => client.fetchPieceActions(packageName),\n    staleTime: SHARED_STALE_MS,\n  });\n\nexport const pieceTriggersQuery = (\n  client: RuntimeClient,\n  packageName: string,\n) =>\n  queryOptions({\n    queryKey: runtimeKeys.pieceTriggers(client.url, packageName),\n    queryFn: () => client.fetchPieceTriggers(packageName),\n    staleTime: SHARED_STALE_MS,\n  });\n\n// Kept until a test trigger could have changed the sample it derives from.\nexport const outputTreeQuery = (\n  client: RuntimeClient,\n  block: BlockRef,\n  config: unknown,\n) =>\n  queryOptions({\n    queryKey: runtimeKeys.outputTree(client.url, block, config),\n    queryFn: () => client.fetchBlockOutputTree(block, config),\n    staleTime: Infinity,\n  });\n\n// A given test's sample never changes; the key moves on with lastTest.\nexport const stepOutputTreeQuery = (\n  client: RuntimeClient,\n  workflowId: string,\n  stepId: string,\n  testedAt: string | null,\n) =>\n  queryOptions({\n    queryKey: runtimeKeys.stepOutputTree(\n      client.url,\n      workflowId,\n      stepId,\n      testedAt,\n    ),\n    queryFn: () => client.fetchStepOutputTree(workflowId, stepId),\n    staleTime: Infinity,\n  });\n\n// Test runs are left out: they belong to the trigger's test, not the history.\nconst REAL_RUNS = [TEST_TRIGGER_KIND];\n\nexport const runsQuery = (client: RuntimeClient, scope: RunsScope) =>\n  queryOptions({\n    queryKey: runtimeKeys.runs(client.url, scope),\n    queryFn: () =>\n      client\n        .fetchRuns({ ...scope, excludeTriggerKinds: REAL_RUNS })\n        .then(realRuns),\n    staleTime: 0,\n  });\n\n// Tests are left out by the runtime, so the newest row is the latest real run.\nexport const LATEST_RUN_WINDOW = 1;\n\n// The runs views' listing, a page at a time, without step input and output.\nexport const runPagesQuery = (client: RuntimeClient, scope: RunsScope) =>\n  infiniteQueryOptions({\n    queryKey: runtimeKeys.runPages(client.url, scope),\n    queryFn: ({ pageParam }) =>\n      client.fetchRunsPage(\n        { ...scope, excludeTriggerKinds: REAL_RUNS },\n        pageParam,\n      ),\n    initialPageParam: null as string | null,\n    getNextPageParam: (page: RunPage) =>\n      page.hasNextPage && page.cursor ? page.cursor : undefined,\n    staleTime: 0,\n  });\n\n// Pages flattened, once each: a run that starts moves up past a page break.\nexport function runsOfPages(pages: readonly RunPage[]): RunRecord[] {\n  const seen = new Set<string>();\n  return realRuns(pages.flatMap((page) => page.items)).filter((run) => {\n    if (seen.has(run.id)) return false;\n    seen.add(run.id);\n    return true;\n  });\n}\n\nconst FINISHED = new Set([\"SUCCEEDED\", \"FAILED\"]);\n\nexport const runQuery = (client: RuntimeClient, runId: string) =>\n  queryOptions({\n    queryKey: runtimeKeys.run(client.url, runId),\n    queryFn: () => client.fetchRun(runId),\n    // A finished run never changes.\n    staleTime: (query) =>\n      query.state.data && FINISHED.has(query.state.data.status) ? Infinity : 0,\n  });\n\nexport const connectionsQuery = (client: RuntimeClient) =>\n  queryOptions({\n    queryKey: runtimeKeys.connections(client.url),\n    queryFn: () => client.fetchConnections(),\n    staleTime: 0,\n  });\n\nexport const secretStatQuery = (client: RuntimeClient, ref: string) =>\n  queryOptions({\n    queryKey: runtimeKeys.secret(client.url, ref),\n    queryFn: () => client.fetchSecretStat(ref),\n    staleTime: 0,\n  });\n\nexport interface TestStepVariables {\n  workflowId: string;\n  stepId: string;\n}\n\n// A step test is a new run and a new sample for the output trees.\nexport const testStepMutation = (\n  client: RuntimeClient,\n  queryClient: QueryClient,\n) =>\n  mutationOptions<StepTestResult, Error, TestStepVariables>({\n    mutationFn: ({ workflowId, stepId }) => client.testStep(workflowId, stepId),\n    onSettled: () =>\n      Promise.all(\n        [\n          runtimeKeys.allRuns(client.url),\n          [client.url, \"latestRun\"],\n          runtimeKeys.outputTrees(client.url),\n        ].map((queryKey) => queryClient.invalidateQueries({ queryKey })),\n      ),\n  });\n\nexport function useTestStep(client: RuntimeClient, queryClient: QueryClient) {\n  return useMutation(testStepMutation(client, queryClient), queryClient);\n}\n"],"x_google_ignoreList":[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],"mappings":";;;AAiNA,MAAa,qBAAoC;CAC/C,MAAM;CACN,aAAa;CACb,MAAM;CACN,UAAU;CACV,aACE;AACJ;;;ACvNA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