#!/usr/bin/env node var Pt=Object.defineProperty;var o=(e,t)=>Pt(e,"name",{value:t,configurable:!0});import{readFileSync as ii}from"fs";import{parseArgs as ri}from"util";var d={PUBLIC:"public",EARLY_ACCESS:"earlyAccess",INTERNAL:"internal"},f={GRAPHQL:"graphql",FUNCTIONS:"functions",FUNCTION_GRAPHQL:"function-graphql",UI_FRAMEWORK:"ui-framework",THEME:"theme",CONFIGURATION:"configuration",EXECUTION:"execution",GUIDANCE:"guidance"};function xt(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{name:t,...n}]))}o(xt,"defineApis");var J=xt({flow:{displayName:"Flow workflows",description:"Build and manage Shopify Flow workflows through the Admin GraphQL API: create, list, read, update, activate, deactivate, and delete workflows; parse .flow exports; and discover templates, tasks, and environment fields. Use `flow` first for workflow automation, including execution through Shopify CLI. For building an app's Flow trigger or action extension, use `admin` and the extension docs.",category:f.EXECUTION,visibility:d.PUBLIC,searchable:"unscoped",exampleVectorStoreQuery:{query:"Shopify Flow automationWorkflowCreate",context:"creating Flow workflows through the unstable Admin API"}},"use-shopify-cli":{displayName:"Use Shopify CLI",routingNote:"For Shopify Flow workflow operations, use `flow` first.",description:"Choose when the user needs **Shopify CLI** to run or fix something now: validate app or extension config on disk (`shopify.app.toml`, `shopify.app..toml`, `shopify.extension.toml`); review or audit an app's code for security vulnerabilities; run or troubleshoot store workflows (`shopify store auth`, `shopify store execute`); or perform explicit store-scoped reads/writes on a named store domain (for example, show/list/find the first 10 products on my store at `foo.myshopify.com`, or inventory and product changes by handle, SKU, or location name). Emphasize **commands and operational steps**, not only authoring GraphQL. Skip for API-only understanding or codegen with no CLI execution, and skip for brand-new merchant asks to start a Shopify store or try Shopify before they have an account. Examples: validate configuration before deploy; run an existing query via CLI; show the first 10 products on `foo.myshopify.com`; missing `shopify store execute`.",category:f.EXECUTION,visibility:d.PUBLIC,searchable:!1},ucp:{displayName:"UCP CLI",description:'Use when the user wants to use the UCP CLI to find, compare, buy, or track products from online merchants, or to set up and troubleshoot the local UCP profile required for merchant-scoped operations. Covers global catalog search ("find me X under $Y"), named-merchant transactions ("buy this from Z.com"), order tracking, `ucp profile init`, `ucp doctor`, carts, checkout, orders, and UCP setup/help. Falls back to merchant-hosted handoff when direct in-protocol checkout isn\'t available.',category:f.EXECUTION,visibility:d.PUBLIC,searchable:!1,skillName:"ucp",compatibility:"Requires UCP CLI",frontmatterExtras:{requires_bin:"ucp",command:"ucp"}},admin:{displayName:"Admin API",routingNote:"For Shopify Flow workflow operations, use `flow` first.",versioned:!0,description:"Write or explain **Admin GraphQL** queries and mutations for apps and integrations that extend the Shopify admin. Use when the user wants to **understand, design, or generate** the operation itself\u2014even before deciding how to run it. Do **not** choose `admin` first for **app monetization**\u2014charging merchants for the app itself via app pricing plans, paid app tiers, app subscription charges, or app free trials\u2014use **`app-pricing`** unless the user is maintaining an existing Manual Pricing integration or explicitly needs an Admin Billing API operation. Merchant **product** subscriptions stay with `admin` (selling plans, subscription contracts, try-before-you-buy). Do **not** choose `admin` first for **app or extension config validation** \u2014use **`use-shopify-cli`**. Do **not** choose `admin` first to **execute** Admin GraphQL **now via Shopify CLI** or for CLI setup/troubleshooting on store workflows\u2014use **`use-shopify-cli`** (store auth/execute, handle/SKU/location lookups, inventory changes).",category:f.GRAPHQL,visibility:d.PUBLIC,schemaSource:{shopifyDevPrefix:"admin"},validation:!0,exampleVectorStoreQuery:{query:"productCreate mutation",context:"creating a product"}},shopifyql:{displayName:"ShopifyQL",versioned:!0,description:'Answer a merchant\'s **analytics and reporting** questions with **ShopifyQL** \u2014 Shopify\'s query language for aggregated store metrics that the Admin GraphQL API cannot compute. Choose this (not `admin`) whenever the ask is for **numbers, totals, trends, or breakdowns** rather than fetching or mutating individual records: including but not limited to total/gross/net sales and revenue, order counts, average order value, refunds, quantity sold, sessions, conversion rate, and traffic \u2014 sliced by product, channel, region, or customer, trended over time, or compared period-over-period. Examples: "total sales last 7 days", "orders by sales channel this month", "top products by revenue", "conversion rate this week", "sales this year vs last year". This topic covers writing the ShopifyQL query; if the merchant wants to run it against their store, execution is handed off to `use-shopify-cli`. Not for general Admin GraphQL record operations \u2014 fetching or mutating individual resources (use `admin`).',category:f.GUIDANCE,visibility:d.PUBLIC,exampleVectorStoreQuery:{query:"ShopifyQL total sales over time",context:"querying aggregated store analytics with ShopifyQL"}},"storefront-graphql":{displayName:"Storefront GraphQL API",versioned:!0,description:"Use for custom storefronts requiring direct GraphQL queries/mutations for data fetching and cart operations. Choose this when you need full control over data fetching and rendering your own UI. NOT for Web Components - if the prompt mentions HTML tags like , , use storefront-web-components instead.",category:f.GRAPHQL,visibility:d.PUBLIC,schemaSource:{shopifyDevPrefix:"storefront"},validation:!0,exampleVectorStoreQuery:{query:"predictiveSearch query",context:"storefront search"}},partner:{displayName:"Partner API",versioned:!0,description:"The Partner API lets you programmatically access data about your Partner Dashboard, including your apps, themes, and affiliate referrals.",category:f.GRAPHQL,visibility:d.PUBLIC,schemaSource:{shopifyDevPrefix:"partner"},validation:!0,exampleVectorStoreQuery:{query:"transactions query",context:"partner transaction history"}},customer:{displayName:"Customer Account API",versioned:!0,description:"Write and validate GraphQL operations for developers integrating Shopify's Customer Account API. Generates code for Customer Account API integrations.",category:f.GRAPHQL,visibility:d.PUBLIC,schemaSource:{shopifyDevPrefix:"customer"},validation:!0,exampleVectorStoreQuery:{query:"customer orders query",context:"customer order history"}},"payments-apps":{displayName:"Payments Apps API",versioned:!0,description:"The Payments Apps API enables payment providers to integrate their payment solutions with Shopify's checkout.",category:f.GRAPHQL,visibility:d.PUBLIC,schemaSource:{shopifyDevPrefix:"payments_apps"},validation:!0,exampleVectorStoreQuery:{query:"paymentSessionPending mutation",context:"pending a payment session"}},functions:{displayName:"Shopify Functions",versioned:!0,description:"Shopify Functions allow developers to customize the backend logic that powers parts of Shopify. Available APIs: Discount, Cart and Checkout Validation, Cart Transform, Pickup Point Delivery Option Generator, Delivery Customization, Fulfillment Constraints, Local Pickup Delivery Option Generator, Order Routing Location Rule, Payment Customization",category:f.FUNCTIONS,visibility:d.PUBLIC,validation:!0,exampleVectorStoreQuery:{query:"cart transform function input query",context:"cart transform function inputs"}},functions_cart_checkout_validation:{displayName:"Cart Checkout Validation Function",versioned:!0,description:"GraphQL schema for Cart and Checkout Validation Function input queries",category:f.FUNCTION_GRAPHQL,visibility:d.PUBLIC,schemaSource:{shopifyDevPrefix:"functions_cart_checkout_validation_schema"}},functions_cart_transform:{displayName:"Cart Transform Function",versioned:!0,description:"GraphQL schema for Cart Transform Function input queries",category:f.FUNCTION_GRAPHQL,visibility:d.PUBLIC,schemaSource:{shopifyDevPrefix:"functions_cart_transform_schema"}},functions_delivery_customization:{displayName:"Delivery Customization Function",versioned:!0,description:"GraphQL schema for Delivery Customization Function input queries",category:f.FUNCTION_GRAPHQL,visibility:d.PUBLIC,schemaSource:{shopifyDevPrefix:"functions_delivery_customization_schema"}},functions_discount:{displayName:"Discount Function",versioned:!0,description:"GraphQL schema for Discount Function input queries",category:f.FUNCTION_GRAPHQL,visibility:d.PUBLIC,schemaSource:{shopifyDevPrefix:"functions_discount_schema"}},functions_fulfillment_constraints:{displayName:"Fulfillment Constraints Function",versioned:!0,description:"GraphQL schema for Fulfillment Constraints Function input queries",category:f.FUNCTION_GRAPHQL,visibility:d.PUBLIC,schemaSource:{shopifyDevPrefix:"functions_fulfillment_constraints_schema"}},functions_local_pickup_delivery_option_generator:{displayName:"Local Pickup Delivery Option Generator Function",versioned:!0,description:"GraphQL schema for Local Pickup Delivery Option Generator Function input queries",category:f.FUNCTION_GRAPHQL,visibility:d.PUBLIC,schemaSource:{shopifyDevPrefix:"functions_local_pickup_delivery_option_generator_schema"}},functions_order_discounts:{displayName:"Order Discounts Function",versioned:!0,description:"GraphQL schema for Order Discounts Function input queries",category:f.FUNCTION_GRAPHQL,visibility:d.PUBLIC,schemaSource:{shopifyDevPrefix:"functions_order_discounts_schema"}},functions_order_routing_location_rule:{displayName:"Order Routing Location Rule Function",versioned:!0,description:"GraphQL schema for Order Routing Location Rule Function input queries",category:f.FUNCTION_GRAPHQL,visibility:d.PUBLIC,schemaSource:{shopifyDevPrefix:"functions_order_routing_location_rule_schema"}},functions_payment_customization:{displayName:"Payment Customization Function",versioned:!0,description:"GraphQL schema for Payment Customization Function input queries",category:f.FUNCTION_GRAPHQL,visibility:d.PUBLIC,schemaSource:{shopifyDevPrefix:"functions_payment_customization_schema"}},functions_pickup_point_delivery_option_generator:{displayName:"Pickup Point Delivery Option Generator Function",versioned:!0,description:"GraphQL schema for Pickup Point Delivery Option Generator Function input queries",category:f.FUNCTION_GRAPHQL,visibility:d.PUBLIC,schemaSource:{shopifyDevPrefix:"functions_pickup_point_delivery_option_generator_schema"}},functions_product_discounts:{displayName:"Product Discounts Function",versioned:!0,description:"GraphQL schema for Product Discounts Function input queries",category:f.FUNCTION_GRAPHQL,visibility:d.PUBLIC,schemaSource:{shopifyDevPrefix:"functions_product_discounts_schema"}},functions_shipping_discounts:{displayName:"Shipping Discounts Function",versioned:!0,description:"GraphQL schema for Shipping Discounts Function input queries",category:f.FUNCTION_GRAPHQL,visibility:d.PUBLIC,schemaSource:{shopifyDevPrefix:"functions_shipping_discounts_schema"}},"polaris-app-home":{displayName:"Polaris App Home",versioned:!0,description:"Build your app's primary user interface embedded in the Shopify admin using the **iframe** model \u2014 a web app you host yourself, rendered with `@shopify/polaris-types` and App Bridge. Covers the Intents API (`shopify.intents.invoke`) for launching native workflows from App Home. For the Shopify-hosted `admin.app.home.render` extension target, use **`polaris-admin-extensions`** instead. If the prompt just mentions `Polaris` and you can't tell based off of the context what API they meant, assume they meant this API.",category:f.UI_FRAMEWORK,publicPackages:["@shopify/polaris-types",{name:"@shopify/app-bridge-types",versionIndependent:!0},{name:"@shopify/app-bridge-react",versionIndependent:!0},{name:"@shopify/analytics-ui-types",versionIndependent:!0}],visibility:d.PUBLIC,validation:!0,exampleVectorStoreQuery:{query:"s-page",context:"page layout in app home"}},"polaris-admin-extensions":{displayName:"Polaris Admin Extensions",versioned:!0,description:"Add custom actions and blocks from your app at contextually relevant spots throughout the Shopify Admin, including **App Home UI extensions** \u2014 the Shopify-hosted `admin.app.home.render` target (API version `2026-07` or later) that renders your app's landing page instead of an iframe. Covers the Intents API (`shopify.intents.invoke`) for launching native workflows from an extension. Admin UI Extensions also supports scaffolding new admin extensions using Shopify CLI commands.",category:f.UI_FRAMEWORK,publicPackages:["@shopify/ui-extensions",{name:"@shopify/ui-extensions-react",versions:["2025-07"]}],extensionSurfaceName:"admin",extensionTypeName:"Admin Extensions",extensionSearchContext:"admin UI extensions",visibility:d.PUBLIC,validation:!0,exampleVectorStoreQuery:{query:"admin.product-details.block.render",context:"admin extension target for product details blocks"},exampleExtensionTarget:"admin.product-details.block.render"},"polaris-checkout-extensions":{displayName:"Polaris Checkout Extensions",versioned:!0,description:"Build custom functionality that merchants can install at defined points in the checkout flow, including product information, shipping, payment, order summary, and Shop Pay. Checkout UI Extensions also supports scaffolding new checkout extensions using Shopify CLI commands. This topic covers the extension code only \u2014 when the prompt also needs an app backend (for example storing data in the developer's own database, or verifying session tokens on a server), also learn **`onboarding-dev`** to scaffold the app with Shopify's official backend libraries.",category:f.UI_FRAMEWORK,publicPackages:["@shopify/ui-extensions",{name:"@shopify/ui-extensions-react",versions:["2025-07"]}],extensionSurfaceName:"checkout",extensionTypeName:"Checkout Extensions",extensionSearchContext:"checkout UI extensions",visibility:d.PUBLIC,validation:!0,exampleVectorStoreQuery:{query:"s-button checkout",context:"checkout button"},exampleExtensionTarget:"purchase.checkout.block.render"},"polaris-customer-account-extensions":{displayName:"Polaris Customer Account Extensions",versioned:!0,description:"Build custom functionality that merchants can install at defined points on the Order index, Order status, and Profile pages in customer accounts. Customer Account UI Extensions also supports scaffolding new customer account extensions using Shopify CLI commands.",category:f.UI_FRAMEWORK,publicPackages:["@shopify/ui-extensions",{name:"@shopify/ui-extensions-react",versions:["2025-07"]}],extensionSurfaceName:"customer-account",extensionTypeName:"Customer Account Extensions",extensionSearchContext:"customer account UI extensions",visibility:d.PUBLIC,validation:!0,exampleVectorStoreQuery:{query:"s-card customer-account",context:"customer account card"},exampleExtensionTarget:"customer-account.order-status.block.render"},"pos-ui":{displayName:"POS UI",versioned:!0,description:"Build retail point-of-sale applications using Shopify's POS UI components. These components provide a consistent and familiar interface for POS applications. POS UI Extensions also supports scaffolding new POS extensions using Shopify CLI commands. Keywords: POS, Retail, smart grid",category:f.UI_FRAMEWORK,publicPackages:["@shopify/ui-extensions",{name:"@shopify/ui-extensions-react",versions:["2025-07"]}],extensionSurfaceName:"point-of-sale",extensionTypeName:"POS UI Extensions",extensionSearchContext:"POS UI extensions",visibility:d.PUBLIC,validation:!0,exampleVectorStoreQuery:{query:"pos.home.tile.render",context:"POS home tile extension target"},exampleExtensionTarget:"pos.customer-details.block.render"},hydrogen:{displayName:"Hydrogen",versioned:!0,description:"Hydrogen storefront implementation cookbooks. Some of the available recipes are: B2B Commerce, Bundles, Combined Listings, Custom Cart Method, Dynamic Content with Metaobjects, Express Server, Google Tag Manager Integration, Infinite Scroll, Legacy Customer Account Flow, Markets, Partytown + Google Tag Manager, Subscriptions, Third-party API Queries and Caching. MANDATORY: Use this API for ANY Hydrogen storefront question - do NOT use Storefront GraphQL when 'Hydrogen' is mentioned.",category:f.UI_FRAMEWORK,publicPackages:["@shopify/hydrogen"],visibility:d.PUBLIC,validation:!0,exampleVectorStoreQuery:{query:"CartForm component",context:"cart UI"}},"storefront-web-components":{displayName:"Storefront Web Components",description:"HTML-first web components for building storefronts WITHOUT GraphQL. Choose when prompts mention: Web Components, HTML tags (, , , , ), native , 'HTML-only', 'without JavaScript', or 'no GraphQL'. Components handle data fetching and state internally.",category:f.UI_FRAMEWORK,featureFlag:"storefrontWebComponentsEnabled",visibility:d.EARLY_ACCESS,validation:!0,exampleVectorStoreQuery:{query:"shopify-cart",context:"cart web component"}},liquid:{displayName:"Liquid",description:"Liquid is an open-source templating language created by Shopify. It is the backbone of Shopify themes and is used to load dynamic content on storefronts. Keywords: liquid, theme, shopify-theme, liquid-component, liquid-block, liquid-section, liquid-snippet, liquid-schemas, shopify-theme-schemas",category:f.THEME,visibility:d.PUBLIC,schemaSource:{npmPackage:"@shopify/theme-check-common"},validation:!0,exampleVectorStoreQuery:{query:"product metafields",context:"product metafield access in a theme"}},"custom-data":{displayName:"Custom Data",description:"MUST be used first when prompts mention Metafields or Metaobjects. Use Metafields and Metaobjects to model and store custom data for your app. Metafields extend built-in Shopify data types like products or customers, Metaobjects are custom data types that can be used to store bespoke data structures. Metafield and Metaobject definitions provide a schema and configuration for values to follow.",activationTerms:["metafields or metaobjects"],category:f.CONFIGURATION,visibility:d.PUBLIC,searchable:!1},"app-pricing":{displayName:"Shopify App Pricing",description:"Use first when a developer asks how to configure public-app plans, tiers, recurring or usage-based options, or trials. Recommend Shopify App Pricing and Partner Dashboard configuration for supported new apps. Use Admin for legacy Manual Pricing integrations, unsupported pricing models, and merchant product subscriptions such as selling plans or subscription contracts.",category:f.GUIDANCE,visibility:d.PUBLIC,searchable:"unscoped",exampleVectorStoreQuery:{query:"Shopify App Pricing",context:"choosing and implementing app monetization"}},"app-store-review":{displayName:"App Store Review",description:"Run a pre-submission compliance check against your Shopify app's codebase. Reviews App Store requirements and surfaces likely issues before you submit for official review.",category:f.GUIDANCE,visibility:d.PUBLIC,searchable:!1,compatibility:"Requires Node.js and Shopify CLI"},"onboarding-dev":{displayName:"Developer Onboarding",description:"Get started building on Shopify. Use when a developer asks to build an app, build a theme, create a dev store, set up a partner account, scaffold a project, or get started developing for Shopify \u2014 including building an app in a specific backend language or framework (for example Laravel, Symfony, Django, Flask, Rails, or Express); this topic covers scaffolding the app and choosing Shopify's official library for that language. When the prompt also involves an extension surface (checkout, admin, POS, customer accounts), learn this topic **in addition to** the surface topic. NOT for merchants managing stores.",category:f.GUIDANCE,visibility:d.PUBLIC,searchable:!1,compatibility:"Requires Node.js and Shopify CLI"},"onboarding-merchant":{displayName:"Merchant Onboarding",description:"Set up a Shopify store. Use to make, build, or open a store (e.g. 'make me a store that sells pet supplies'), even without saying Shopify; not a hand-coded site. Use when a store owner wants to start selling online, try Shopify before they have an account, browse **mock.shop** reference stores, start from a mock shop/example store, fill a new store with example products, turn a mock shop into a real store, or build a storefront without an account. Also use when developers explicitly need auth-free mock.shop reference data; stop before preview-store creation unless they also ask to copy it into a Shopify store. Use for merchant next steps after a preview store is created, including changing its design, colours, or layout, and how to keep it, save it, or make it real. Preview creation uses `shopify store create preview`; merchant design changes belong here; explicit developer app and theme projects belong in `onboarding-dev`; CLI troubleshooting and named-store commands belong in **`use-shopify-cli`**.",activationTerms:["make me a store that sells pet supplies","mock.shop reference stores","build a storefront without an account"],category:f.GUIDANCE,visibility:d.PUBLIC,searchable:!1,compatibility:"Requires Node.js and Shopify CLI",frontmatterExtras:{maintainer:"Shopify"}}});function te(e){return typeof e=="string"?e:e.name}o(te,"getPublicPackageName");function ye(e,t){return typeof e=="string"||!e.versions||t===void 0?!0:e.versions.includes(t)}o(ye,"publicPackageAppliesToVersion");var Re={shopifyql:[{name:"2027-01",releaseCandidate:!0},{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"}],admin:[{name:"unstable"},{name:"2027-01",releaseCandidate:!0},{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"}],"storefront-graphql":[{name:"unstable"},{name:"2027-01",releaseCandidate:!0},{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"}],partner:[{name:"unstable"},{name:"2027-01",releaseCandidate:!0},{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"}],customer:[{name:"unstable"},{name:"2027-01",releaseCandidate:!0},{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"}],"payments-apps":[{name:"unstable"},{name:"2027-01",releaseCandidate:!0},{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"}],"polaris-app-home":[{name:"v2.0",latestVersion:!0},{name:"v1.1"},{name:"v1.0"}],"polaris-admin-extensions":[{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"},{name:"2025-07"}],"polaris-checkout-extensions":[{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"},{name:"2025-07"}],"polaris-customer-account-extensions":[{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"},{name:"2025-07"}],"pos-ui":[{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"},{name:"2025-07"}],hydrogen:[{name:"2026-10",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"},{name:"2025-07"}],"storefront-web-components":[],functions_cart_checkout_validation:[{name:"unstable"},{name:"2027-01",releaseCandidate:!0},{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"}],functions_cart_transform:[{name:"unstable"},{name:"2027-01",releaseCandidate:!0},{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"}],functions_delivery_customization:[{name:"unstable"},{name:"2027-01",releaseCandidate:!0},{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"}],functions_discount:[{name:"unstable"},{name:"2027-01",releaseCandidate:!0},{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"}],functions_fulfillment_constraints:[{name:"unstable"},{name:"2027-01",releaseCandidate:!0},{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"}],functions_local_pickup_delivery_option_generator:[{name:"unstable",latestVersion:!0}],functions_order_discounts:[{name:"unstable"},{name:"2027-01",releaseCandidate:!0},{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"}],functions_order_routing_location_rule:[{name:"unstable"},{name:"2027-01",releaseCandidate:!0},{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"}],functions_payment_customization:[{name:"unstable"},{name:"2027-01",releaseCandidate:!0},{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"}],functions_pickup_point_delivery_option_generator:[{name:"unstable",latestVersion:!0}],functions_product_discounts:[{name:"unstable"},{name:"2027-01",releaseCandidate:!0},{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"}],functions_shipping_discounts:[{name:"unstable"},{name:"2027-01",releaseCandidate:!0},{name:"2026-10",latestVersion:!0},{name:"2026-07"},{name:"2026-04"},{name:"2026-01"}]};var Se=Re,we=Object.fromEntries(Object.entries(Se).filter(([e,t])=>t.length>0).map(([e,t])=>[e,t.map(n=>n.name)]));function De(e){return Object.prototype.hasOwnProperty.call(we,e)}o(De,"hasSupportedVersions");function ne(e){return De(e)?we[e]:[]}o(ne,"getSupportedVersions");function _t(e){let t=Se[e];if(t)return t.find(n=>n.latestVersion)?.name??t[0]?.name}o(_t,"getLatestVersion");function Ve(e,t){if(!De(e))throw new Error(`API "${e}" is not in the supported versions catalog. Only call resolveVersion for APIs with entries in SUPPORTED_API_VERSIONS.`);let n=ne(e);if(n.length===0)return{ok:!1,reason:"no_versions",supportedVersions:n};let i=ve(e,t);if(i)return n.includes(i)?{ok:!0,version:i,source:"explicit",supportedVersions:n}:{ok:!1,reason:"unsupported_version",supportedVersions:n};let r=_t(e);return r?{ok:!0,version:r,source:"default",supportedVersions:n}:{ok:!1,reason:"no_versions",supportedVersions:n}}o(Ve,"resolveVersion");function ve(e,t){if(!t||e!=="polaris-app-home")return t;let n=t.replace(/^v/,""),i=/^(\d+)$/.exec(n)?.[1];if(i){let c=Se[e]?.filter(l=>!l.releaseCandidate&&new RegExp("^v?"+i+"\\.\\d+$").test(l.name)).sort((l,p)=>{let S=Number(l.name.replace(/^v/,"").split(".")[1]),b=Number(p.name.replace(/^v/,"").split(".")[1]);return S-b}).at(-1)?.name;if(c)return c}let r=n.replace(/-rc$/,""),s=[t,n,"v"+r,r],a=ne(e);return s.find(c=>a.includes(c))??t}o(ve,"normalizeRequestedVersion");function At(e,t){return e.map(n=>t&&n.includes("@shopify/ui-extensions")?`import '${n}/${t}';`:`import '${n}';`).join(` `)}o(At,"generateMissingImports");function Ct(e,t,n){if(t.includes("@shopify/ui-extensions")&&!n)throw new Error("Invalid input: extensionTarget is required");let i=At(t,n);if(e&&(e.includes("const shopify =")||e.includes("globalThis.shopify")))return i;let r=t.find(a=>a.includes("@shopify/ui-extensions"))&&n?`interface ShopifyApiOverride extends Omit { query: (...args: any[]) => Promise<{ data: any; errors?: any[] }>; } const shopify: ShopifyApiOverride = (globalThis as any).shopify;`:"";return`${i} ${r}`.trim()}o(Ct,"addShopifyImports");function ke(e,t,n){if(e.includes("!DOCTYPE")||e.includes("!html")){let s=e.match(/(.*?)<\/body>/s)?.[1];s&&(e=`<>${s}`)}return` ${Ct(e,t,n)} ${e} `}o(ke,"formatCode");import*as D from"path";import x from"typescript";import{fileURLToPath as Tt}from"url";var Fe=o((e,t,n=x.ModuleResolutionKind.NodeJs)=>({target:x.ScriptTarget.ESNext,module:x.ModuleKind.ESNext,jsx:x.JsxEmit.ReactJSX,jsxImportSource:e||"preact",strict:!0,strictNullChecks:!1,esModuleInterop:!0,skipLibCheck:!0,moduleResolution:n,allowSyntheticDefaultImports:!0,lib:["es2020","dom"],allowJs:!0,checkJs:!1,...t?{baseUrl:t,paths:{"@shopify/ui-extensions/src/surfaces/*":["node_modules/@shopify/ui-extensions/build/ts/surfaces/*"]}}:{}}),"getCompilerOptions");function Nt(){let e=Tt(import.meta.url);return D.resolve(e,"../..")}o(Nt,"getPackageRoot");function Ot(e,t){let n=t.get(e);if(n)return x.ScriptSnapshot.fromString(n);try{let i=x.sys.readFile(e);return i?x.ScriptSnapshot.fromString(i):void 0}catch{return}}o(Ot,"getScriptSnapshot");function Lt(e,t,n,i){return{getScriptFileNames:o(()=>Array.from(e.virtualFiles.keys()),"getScriptFileNames"),getScriptVersion:o(r=>e.fileVersions.get(r)?.toString()||"0","getScriptVersion"),getScriptSnapshot:o(r=>Ot(r,e.virtualFiles),"getScriptSnapshot"),getCurrentDirectory:o(()=>t,"getCurrentDirectory"),getCompilationSettings:o(()=>Fe(n,t,i),"getCompilationSettings"),getDefaultLibFileName:o(r=>x.getDefaultLibFilePath(r),"getDefaultLibFileName"),fileExists:o(r=>e.virtualFiles.has(r)||x.sys.fileExists(r),"fileExists"),readFile:o(r=>e.virtualFiles.get(r)||x.sys.readFile(r),"readFile"),readDirectory:x.sys.readDirectory,getDirectories:x.sys.getDirectories,directoryExists:o(r=>{let s=r.endsWith(D.sep)?r:r+D.sep;for(let a of e.virtualFiles.keys())if(a.startsWith(s))return!0;return x.sys.directoryExists(r)},"directoryExists"),getNewLine:o(()=>` `,"getNewLine")}}o(Lt,"createLanguageServiceHost");function Ue(e,t){let n=new Map,i=new Map,r=Nt(),s=t??(e==="hydrogen"?"react":"preact"),a=Lt({fileVersions:n,virtualFiles:i},r,s,e==="hydrogen"?x.ModuleResolutionKind.Bundler:x.ModuleResolutionKind.NodeJs),c=x.createLanguageService(a,x.createDocumentRegistry()),l=D.dirname(x.getDefaultLibFilePath(Fe(s,r))),p=["lib.es5.d.ts","lib.es2020.d.ts","lib.dom.d.ts"];for(let S of p)try{let b=D.join(l,S),E=x.sys.readFile(b);E&&(i.set(b,E),n.set(b,1))}catch{}return{languageService:c,servicesHost:a,fileVersions:n,virtualFiles:i}}o(Ue,"createVirtualTSEnvironment");function Rt(e,t){let i=(e.get(t)||0)+1;return e.set(t,i),i}o(Rt,"incrementFileVersion");function z(e,t,n){e.virtualFiles.set(t,n),Rt(e.fileVersions,t)}o(z,"addFileToVirtualEnv");var Ie=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","math","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","selectedcontent","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"];import g from"typescript";var Me=["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","animation","audio","canvas","circle","clipPath","color-profile","cursor","defs","desc","discard","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","handler","hkern","iframe","image","line","linearGradient","listener","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","prefetch","radialGradient","rect","script","set","solidColor","stop","style","svg","switch","symbol","tbreak","text","textArea","textPath","title","tref","tspan","unknown","use","video","view","vkern"];var Ge={NAMESPACE_USED_AS_VALUE:2708,TYPE_NOT_ASSIGNABLE:2322,CANNOT_FIND_NAME:2304},C={PROPERTY_NOT_EXIST:/Property '(\w+)' does not exist on type/,TYPE_NOT_ASSIGNABLE:/Type '(.+?)' is not assignable to type '(.+?)'/,PROPERTY:/[Pp]roperty '(\w+)'/,SHOPIFY_MODULE:/@shopify\//,MODULE_NOT_FOUND:/Invalid module name in augmentation/,INTRINSIC_ELEMENT:/does not exist on type 'JSX.IntrinsicElements'/,INVALID_JSX_ELEMENT:/cannot be used as a JSX component|is not a valid JSX element type/,USED_BEFORE_BEING_DEFINED:/is used before being assigned/,IMPLICITLY_HAS_AN_ANY_TYPE:/implicitly has an 'any' type./,PREACT_REACT_COMPAT:/type '(?:VNode|ReactPortal)|not assignable to type '(?:ReactNode|ReactPortal)'/,NEVER_TYPE_CASCADE:/does not exist on type 'never'|is not assignable to type 'never'/,PRIMITIVE_PROPERTY_ACCESS:/does not exist on type '(?:string|number|boolean|undefined|null|void)(?:\s*\|\s*(?:string|number|boolean|undefined|null|void))*'/,CSS_PROPERTIES_COMPAT:/CSSProperties/,OBJECT_IS_UNKNOWN:/Object is of type 'unknown'/},Dt=new Set(["class","style","title","id","slot","role","hidden","lang","dir","tabindex","inert","part","is","nonce","popover","contenteditable","draggable","spellcheck","translate","autocapitalize","autofocus","accesskey","enterkeyhint","inputmode"]),Vt=/^(number|boolean)(\s*\|\s*(number|boolean|undefined|null))*$/;function kt(e){return Dt.has(e)||/^on[a-z]+$/.test(e)}o(kt,"isHtmlGlobalAttribute");function Ft(e){let t=e.match(C.TYPE_NOT_ASSIGNABLE);if(!t)return!1;let n=t[1],i=t[2];return n!=="string"?!1:Vt.test(i.trim())}o(Ft,"isHtmlStringCoercion");function Ut(e){return Ie.includes(e)}o(Ut,"isStandardHTMLElement");function Mt(e){return Me.includes(e)}o(Mt,"isStandardSVGElement");function $t(e){let t=[];function n(i){if(g.isJsxOpeningElement(i)||g.isJsxSelfClosingElement(i)){let r=i.tagName.getText(e),s=i.getStart(e),a=i.getEnd();t.push({tagName:r,node:i,start:s,end:a})}g.forEachChild(i,n)}return o(n,"visit"),g.forEachChild(e,n),t}o($t,"extractJSXElements");function Y(e){return{componentName:e,valid:!0,errors:[],skipped:!0}}o(Y,"createSkippedValidation");function Ee(e,t){let n=t==="custom"?`Custom component '${e}' is not allowed. UI extensions must only use Shopify Polaris web components. If this is a wrapper component, make sure to import it.`:`${t} element '${e}' is not allowed. UI extensions must only use Shopify Polaris web components.`;return{componentName:e,valid:!1,errors:[{property:"element",message:n}]}}o(Ee,"createDisallowedElementValidation");function Gt(e){return e.replace(/\./g,"")}o(Gt,"sanitizeComponentName");function Bt(e,t,n,i,r){let s=Gt(e);return Ut(s)?r?Ee(e,"HTML"):Y(e):Mt(s)?r?Ee(e,"SVG"):Y(e):t.has(s)?null:r?n.has(s)||i.has(s)?Y(e):Ee(e,"custom"):Y(e)}o(Bt,"handleNonShopifyComponent");function jt(e){return!e.startsWith("@shopify/")}o(jt,"isUserDefinedImport");function Qt(e,t){e.name&&t.add(e.name.text)}o(Qt,"collectDefaultImportName");function Ht(e,t){let{namedBindings:n}=e;if(n&&g.isNamedImports(n))for(let i of n.elements)t.add(i.name.text)}o(Ht,"collectNamedImportNames");function qt(e,t){Qt(e,t),Ht(e,t)}o(qt,"collectImportedNames");function Wt(e){let{moduleSpecifier:t}=e;return g.isStringLiteral(t)?t.text:null}o(Wt,"getModulePath");function Jt(e){let t=new Set;function n(i){g.isImportDeclaration(i)&&zt(i,t),g.forEachChild(i,n)}return o(n,"visitNode"),g.forEachChild(e,n),t}o(Jt,"extractUserImportedComponents");function zt(e,t){let n=Wt(e);if(!n||!jt(n))return;let{importClause:i}=e;i&&qt(i,t)}o(zt,"processImportDeclaration");function Pe(e){return/^[A-Z]/.test(e)}o(Pe,"isPascalCase");function Yt(e){let t=new Set;function n(i){if(g.isFunctionDeclaration(i)&&i.name){let r=i.name.text;Pe(r)&&t.add(r)}if(g.isVariableStatement(i)){for(let r of i.declarationList.declarations)if(g.isIdentifier(r.name)&&r.initializer&&(g.isArrowFunction(r.initializer)||g.isFunctionExpression(r.initializer))){let s=r.name.text;Pe(s)&&t.add(s)}}if(g.isClassDeclaration(i)&&i.name){let r=i.name.text;Pe(r)&&t.add(r)}g.forEachChild(i,n)}return o(n,"visitNode"),g.forEachChild(e,n),t}o(Yt,"extractLocallyDefinedComponents");function Kt(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}o(Kt,"hyphenatedToCamelCase");function Xt(e){if(!g.isJsxOpeningElement(e)&&!g.isJsxSelfClosingElement(e))return[];let t=[];for(let n of e.attributes.properties){if(!g.isJsxAttribute(n))continue;let i=g.isIdentifier(n.name)?n.name.text:n.name.getText();if(!i.includes("-")||i.startsWith("aria-")||i.startsWith("data-"))continue;let r=Kt(i);t.push({property:i,message:`Property '${i}' uses a hyphenated name which is not a valid Polaris prop. Use camelCase '${r}' instead.`})}return t}o(Xt,"checkHyphenatedAttributes");function Zt(e,t){let n=e.attributes.properties.find(i=>g.isJsxAttribute(i)&&i.name.getText()===t);if(!(!n||!g.isJsxAttribute(n))){if(!n.initializer)return"";if(g.isStringLiteral(n.initializer))return n.initializer.text;if(g.isJsxExpression(n.initializer)&&n.initializer.expression&&g.isStringLiteral(n.initializer.expression))return n.initializer.expression.text}}o(Zt,"getStaticJsxAttribute");function en(e){return tn(e)?.openingElement}o(en,"getParentOpeningElement");function tn(e){let t=g.isJsxOpeningElement(e)?e.parent:void 0,n=e.parent;for(;n;){if(g.isJsxElement(n)){if(n===t){n=n.parent;continue}return n}n=n.parent}}o(tn,"getContainingJsxElement");function $e(e){return{property:"slot",message:e}}o($e,"slotError");function nn(e,t){let n=new Map;for(let{node:i}of e){let r=Zt(i,"slot");if(r===void 0)continue;let s=en(i);if(!s){n.set(i,[$e("A slotted element must have a parent component.")]);continue}let a=s.tagName.getText(),c=t.get(a);if(c&&!c.has(r)){n.set(i,[$e(`Slot '${r}' is not defined on '${a}'. Allowed slots: ${Array.from(c).map(l=>l===""?"(default)":l).join(", ")}.`)]);continue}}return n}o(nn,"collectSlotValidationErrors");function Be(e,t,n,i={}){let{enforceShopifyOnlyComponents:r=!1,language:s,shopifyWebComponentSlots:a}=i,c=s==="html",l=[],p=new Set,S=g.createSourceFile("temp.tsx",e,g.ScriptTarget.Latest,!0,g.ScriptKind.TSX),b=$t(S),E=a?nn(b,a):new Map,_=r?Jt(S):new Set,P=r?Yt(S):new Set;for(let{tagName:I,node:A,start:T,end:M}of b){let F=Bt(I,n,_,P,r);if(F){l.push(F);continue}let{errors:R,handledDiagnostics:G}=sn(T,M,t,c);G.forEach(H=>p.add(H));let w=Xt(A);R.push(...w),R.push(...E.get(A)??[]),l.push({componentName:I,valid:R.length===0,errors:R})}let y=t.filter(I=>!p.has(I)).filter(I=>je(I,c)).filter(rn).map(I=>({message:g.flattenDiagnosticMessageText(I.messageText,` `),code:I.code,start:I.start,end:I.start!==void 0&&I.length!==void 0?I.start+I.length:void 0}));return{validations:l,genericErrors:y}}o(Be,"extractComponentValidations");function je(e,t=!1){if(e.start===void 0||e.length===void 0)return!1;let n=g.flattenDiagnosticMessageText(e.messageText,` `);if(e.code===Ge.NAMESPACE_USED_AS_VALUE)return!1;if(t){let i=n.match(C.PROPERTY_NOT_EXIST);if(i&&kt(i[1])||Ft(n))return!1}return!(n.includes("Cannot find module")&&!n.match(C.SHOPIFY_MODULE)||n.match(C.MODULE_NOT_FOUND)||n.match(C.USED_BEFORE_BEING_DEFINED)||n.match(C.INVALID_JSX_ELEMENT)||n.match(C.IMPLICITLY_HAS_AN_ANY_TYPE))}o(je,"shouldIncludeDiagnostic");function rn(e){let t=g.flattenDiagnosticMessageText(e.messageText,` `);return!(t.match(C.PREACT_REACT_COMPAT)||t.match(C.NEVER_TYPE_CASCADE)||t.match(C.PRIMITIVE_PROPERTY_ACCESS)||t.match(C.CSS_PROPERTIES_COMPAT)||t.match(C.OBJECT_IS_UNKNOWN))}o(rn,"shouldIncludeGenericDiagnostic");function on(e,t,n,i=!1){if(!je(e,i)||e.code===Ge.CANNOT_FIND_NAME)return!1;let r=e.start,s=e.start+e.length;return r>=t&&s<=n}o(on,"isRelevantDiagnostic");function sn(e,t,n,i=!1){let r=[],s=[],a=n.filter(c=>on(c,e,t,i));for(let c of a){let l=g.flattenDiagnosticMessageText(c.messageText,` `),p=an(c,l);p&&(r.push(p),s.push(c))}return{errors:r,handledDiagnostics:s}}o(sn,"getComponentErrors");function an(e,t){let n="",i,r,s=t.match(C.PROPERTY_NOT_EXIST);if(s)n=s[1];else{let a=t.match(C.TYPE_NOT_ASSIGNABLE),c=t.match(C.PROPERTY);a&&(r=a[1],i=a[2]),c&&(n=c[1])}return{property:n||"unknown",message:t,expected:i,actual:r}}o(an,"parseDiagnostic");function Qe(e,t=[]){let n=[],i=[],r=[];for(let c of e)if(c.valid)c.skipped?r.push(c.componentName):i.push(c.componentName);else for(let l of c.errors)n.push(`${c.componentName} validation failed: Property '${l.property}': ${l.message}`);for(let c of t)n.push(c.message);let s,a;return n.length===0?(a="success",i.length>0?s=`All components validated successfully by TypeScript. Found components: ${Array.from(new Set(i)).join(", ")}.`:s="No components found to validate by TypeScript."):(a="failed",s=`Validation errors: ${n.join(` `)}`),r.length>0&&(s+=` Try and use component from Shopify Polaris components. Non-Shopify components (not validated): ${r.map(c=>` - ${c}`).join(` `)}`),{result:a,resultDetail:s,componentValidationErrors:e.filter(c=>!c.skipped&&!c.valid).flatMap(c=>c.errors.map(l=>({componentName:c.componentName,...l}))),genericErrors:t,unvalidatedComponents:Array.from(new Set(r)),validatedComponents:Array.from(new Set(i))}}o(Qe,"formatValidationResponse");import{existsSync as N,readFileSync as j,readdirSync as Sn}from"fs";import*as m from"path";import{fileURLToPath as Xe}from"url";import{gunzipSync as Ye}from"zlib";import{brotliCompressSync as Fi,brotliDecompressSync as cn,constants as Ui}from"zlib";var xe=4;function He(e){let t=cn(e);if(t.lengtht.length)throw new Error(`Corrupt asset archive: header (${n} bytes) extends past the ${t.length}-byte stream`);let r=JSON.parse(t.subarray(xe,i).toString("utf-8")),s=t.subarray(i),a=new Map;for(let[c,l,p]of r){if(!Number.isInteger(l)||!Number.isInteger(p)||l<0||p<0||l+p>s.length)throw new Error(`Corrupt asset archive: member '${c}' (offset ${l}, length ${p}) is out of bounds for the ${s.length}-byte body`);a.set(c,s.subarray(l,l+p))}return a}o(He,"unpackAssetArchive");function qe(e,t){if(!t)return[];switch(t){case"@shopify/polaris-types":case"@shopify/ui-extensions":return pn(e);case"@shopify/ui-extensions-react":return fn(e);case"@shopify/app-bridge-types":return un(e);case"@shopify/analytics-ui-types":return dn(e);case"@shopify/hydrogen":return mn(e);case"@shopify/app-bridge-react":return ln(e);default:return[]}}o(qe,"extractShopifyComponents");function ln(e){let t=[],n=/(?:export\s+)?declare\s+const\s+(\w+)\s*:\s*React\.(?:ComponentType|ForwardRefExoticComponent)\b/g,i;for(;(i=n.exec(e))!==null;)t.push(i[1]);let r=/export\s+default\s+function\s+([A-Z]\w*)\s*\(/g;for(;(i=r.exec(e))!==null;)t.push(i[1]);let s=/default\s+as\s+([A-Z]\w*)/g;for(;(i=s.exec(e))!==null;)t.push(i[1]);return[...new Set(t)]}o(ln,"extractAppBridgeReactComponents");function pn(e){let t=[],n=/declare\s+const\s+tagName\$?\w*\s*=\s*['"]([^'"]+)['"]/g,i=/\[['"]([a-z]+-[a-z-]+)['"]\]\s*:/g,r;for(;(r=n.exec(e))!==null||(r=i.exec(e))!==null;)t.push(r[1]);return[...new Set(t)]}o(pn,"extractWebComponentTagNames");function We(e,t){let n=[],i=e.match(new RegExp(`interface\\s+${t}\\s*\\{([^}]+)\\}`));if(i){let r=/['"]([a-z]+-[a-z-]+)['"]\s*:/g,s;for(;(s=r.exec(i[1]))!==null;)n.push(s[1])}return n}o(We,"extractQuotedTagKeysFromInterface");function un(e){return We(e,"AppBridgeElements")}o(un,"extractAppBridgeElements");function dn(e){return We(e,"AnalyticsUiIntrinsicElements")}o(dn,"extractAnalyticsUiElements");function fn(e){let t=new Set,n=/export\s+declare\s+const\s+([A-Z]\w*)\s*:\s*"\1"\s*&/g,i;for(;(i=n.exec(e))!==null;)t.add(i[1]);let r=/export\s+(?!type\b)\{([^}]+)\}/g;for(;(i=r.exec(e))!==null;)for(let s of i[1].split(",")){let a=s.trim();if(!a||/^type\s/.test(a))continue;let c=a.split(/\s+as\s+/),l=c[c.length-1].trim();/^[A-Z]\w*$/.test(l)&&t.add(l)}return[...t]}o(fn,"extractReactBindingComponentNames");function mn(e){let t=[],n,i=/declare\s+function\s+(\w+)\s*(?:<[^>]*>)?\s*\([^)]*\)\s*:\s*(?:react_jsx_runtime\.)?JSX\.Element/g;for(;(n=i.exec(e))!==null;)t.push(n[1]);let r=/declare\s+function\s+(\w+)\s*(?:<[^>]*>)?\s*\([^)]*\)\s*:\s*ReturnType/g;for(;(n=r.exec(e))!==null;)t.push(n[1]);let s=/declare\s+function\s+(\w+)\s*(?:<[^>]*>)?\s*\([^)]*\)\s*:\s*react\.FunctionComponentElement/g;for(;(n=s.exec(e))!==null;)t.push(n[1]);let a=/declare\s+function\s+(\w+)\s*(?:<[^>]*>)?\s*\([^)]*\)\s*:\s*(?:React\.)?ReactElement(?:<[^>]*>)?/g;for(;(n=a.exec(e))!==null;)t.push(n[1]);let c=/declare\s+const\s+(\w+)\s*:\s*react\.ForwardRefExoticComponent/g;for(;(n=c.exec(e))!==null;)t.push(n[1]);let l=/declare\s+const\s+(\w+)\s*:\s*react\.Provider/g;for(;(n=l.exec(e))!==null;)t.push(n[1]);return[...new Set(t)]}o(mn,"extractHydrogenComponents");var gn="@shopify/analytics-ui-types",Je=/\ndeclare module ['"]preact['"] \{[\s\S]*?\n\}\n/,hn=` import type * as __preact from 'preact'; /** * Mirrors @shopify/polaris-types' PreactBaseElementPropsWithChildren plus * the global \`id\` attribute. Deliberately not preact's HTMLAttributes: its * surface is wide enough that excess-property checks stop catching typos. */ interface AnalyticsUiPreactBaseProps { key?: __preact.Key; ref?: __preact.Ref; slot?: Lowercase; id?: string; children?: __preact.ComponentChildren; } type ShopifyQLMetricCardPreactProps = Partial & AnalyticsUiPreactBaseProps & { onReportLinkClick?: | ((event: CallbackEvent<'s-shopifyql-metric-card'>) => void) | null; onreportlinkclick?: CallbackEventListener<'s-shopifyql-metric-card'>; }; type MetricsBarPreactProps = Partial & AnalyticsUiPreactBaseProps; type MetricsBarDatePickerPreactProps = Partial< Omit > & AnalyticsUiPreactBaseProps & { value?: MetricsBarDatePickerSetValue; onChange?: | ((event: CallbackEvent<'s-metrics-bar-date-picker'>) => void) | null; onchange?: CallbackEventListener<'s-metrics-bar-date-picker'>; }; declare module 'preact' { namespace createElement.JSX { interface IntrinsicElements { 's-shopifyql-metric-card': ShopifyQLMetricCardPreactProps; 's-metrics-bar': MetricsBarPreactProps; 's-metrics-bar-date-picker': MetricsBarDatePickerPreactProps; } } } `;function yn(e){return Je.test(e)?e.replace(Je,hn):e}o(yn,"patchAnalyticsUiTypesForPreact");function ze(e,t,n){return e===gn&&t.endsWith(".d.ts")?yn(n):n}o(ze,"patchAssetDeclaration");var ie,re,oe;function vn(e){let t=m.resolve(e,"..","assets","types");if(N(Ze(t))||N(m.join(t,"index.json")))return t;if(e.includes("dev-mcp")&&e.includes("dist")&&!e.includes("shopify-dev-tools"))return m.join(e,"data","types");if(e.includes("/dist")||e.includes("\\dist")){let n=e.lastIndexOf(m.sep+"dist");if(n!==-1){let i=e.substring(0,n+5);return m.join(i,"data","types")}return m.join(e,"data","types")}return m.resolve(e,"../data/types")}o(vn,"resolveTypesDataDirectory");function X(){if(re)return re;let e=m.dirname(Xe(import.meta.url));return re=vn(e),re}o(X,"getTypesDataDirectory");function In(){if(ie)return ie;let e=m.join(X(),"index.json"),t=V(e);if(t===void 0)throw new Error(`Types index not found at ${e}`);return ie=JSON.parse(t),ie}o(In,"readIndexJson");var K;function Ze(e){return`${e}.archive.br`}o(Ze,"typesArchivePathFor");function se(){if(K!==void 0)return K;let e=Ze(X());if(!N(e))return K=null,null;let t=He(j(e)),n=new Set([""]);for(let i of t.keys()){let r=i.split("/");for(let s=1;sa.name.localeCompare(c.name))}let n;try{n=Sn(e,{withFileTypes:!0})}catch{return[]}return n.map(i=>({name:i.name,isDirectory:i.isDirectory(),isFile:i.isFile()}))}o(Ae,"assetDirEntries");function En(e,t){if(e)try{let n=JSON.parse(e);for(let i of n.modules??[])for(let r of i.declarations??[])!r.tagName||!r.slots||t.set(r.tagName,new Set(r.slots.map(s=>s.name).filter(s=>typeof s=="string")))}catch{}}o(En,"addCustomElementSlots");function tt(){if(oe)return oe;let e=X(),t=m.join(e,"..","supported-versions-schema.json");return oe=JSON.parse(j(t,"utf-8")),oe}o(tt,"readSupportedVersions");function Pn(e){let t=tt()[e];if(t)return t.find(n=>n.latestVersion)?.name}o(Pn,"resolveLatestVersion");function nt(e,t){return e==="hydrogen"||/^\s*(?:import|export)\b[^'"]*['"]@shopify\/ui-extensions-react(?:\/[^'"]*)?['"]/m.test(t)?"react":"preact"}o(nt,"resolveJsxRuntime");function xn(e){return(tt()[e]??[]).map(t=>t.name)}o(xn,"supportedVersionNames");function bn(e){if(e.endsWith(".gz")){if(N(e))return Ye(j(e)).toString("utf-8");let n=e.slice(0,-3);return N(n)?j(n,"utf-8"):void 0}if(N(e))return j(e,"utf-8");let t=e+".gz";if(N(t))return Ye(j(t)).toString("utf-8")}o(bn,"readAssetFile");function _n(e){return e.endsWith(".d.ts")||e.endsWith(".d.mts")||e.endsWith(".d.cts")}o(_n,"isTypeDeclarationFile");function An(e,t){let n=[];if(!_e(e))return n;function i(r,s){for(let a of Ae(r)){if(a.name.startsWith(".")||a.name==="node_modules")continue;let c=m.join(r,a.name),l=a.name.endsWith(".gz")?a.name.slice(0,-3):a.name,p=s?`${s}/${l}`:l;if(a.isDirectory)i(c,p);else if(a.isFile){if(!(_n(l)||l.endsWith(".ts")&&!l.endsWith(".test.ts")&&!l.endsWith(".spec.ts"))||t&&!t(p))continue;n.push({assetPath:c,relPath:p})}}}return o(i,"walk"),i(e,""),n}o(An,"walkAssetDts");function Cn(e,t,n,i){for(let r of Ae(e)){if(!r.isDirectory||r.name.startsWith(".")||r.name==="node_modules")continue;let s=m.join(e,r.name);if(Ke(m.join(s,"package.json")))continue;let a;for(let p of["src/index.d.ts","src/index.d.mts","src/index.d.cts","index.d.ts","index.d.mts","index.d.cts"])if(Ke(m.join(s,p))){a=`./${p}`;break}if(!a)continue;let c=JSON.stringify({name:`${t}/${r.name}`,types:a}),l=`${r.name}/package.json`;U(n,i,t,l,c)}}o(Cn,"synthesizeNestedPackageJsons");function Tn(e,t,n){return m.join(e,"node_modules",t,n)}o(Tn,"virtualPathFor");function U(e,t,n,i,r,s){let a=Tn(t,n,i),c=ze(n,i,r);if(z(e,a,c),s)for(let l of qe(c,n))s.add(l)}o(U,"addAssetToVirtualEnv");var Nn={"customer-account":["checkout"]};function be(e){let t=[e,...Nn[e]??[]],n=new Set(t.map(s=>`build/ts/surfaces/${s}.d.ts`)),i=t.map(s=>`build/ts/surfaces/${s}/`),r="build/ts/";return s=>!!(n.has(s)||i.some(a=>s.startsWith(a))||s.startsWith(r)&&s.endsWith(".d.ts")&&!s.slice(r.length).includes("/"))}o(be,"surfaceMatcher");function Q(e,t,n,i,r,s){for(let{assetPath:a,relPath:c}of An(e,s)){let l=V(a);l&&U(n,i,t,c,l,r)}}o(Q,"loadDtsTree");function On(e){let t=[],n=/import\s+['"]\.\.\/components\/(\w+)\.d\.ts['"]/g,i;for(;(i=n.exec(e))!==null;)t.push(i[1]);return t}o(On,"extractComponentImports");function Ln(e){let t=new Set;for(let n of Ae(e)){if(!n.isFile)continue;let i=n.name.endsWith(".gz")?n.name.slice(0,-3):n.name;i.endsWith(".d.ts")&&t.add(i.slice(0,-5))}return[...t].sort()}o(Ln,"listAvailableTargets");function Rn(e,t,n,i,r,s,a){let c=`build/ts/surfaces/${r}`,l=m.join(e,c,"targets"),p=`${c}/targets/${s}.d.ts`,S=V(m.join(e,p));if(!S)return _e(l)?{hasTargetSubpath:!1,invalidTarget:{target:s,surface:r,supported:Ln(l)}}:(Q(e,t,n,i,a,be(r)),{hasTargetSubpath:!1});let b=`${c}.d.ts`,E=V(m.join(e,b));E&&U(n,i,t,b,E,a),U(n,i,t,p,S,a);let _=`${c}/components`;for(let P of On(S)){let v=`${_}/${P}.d.ts`,y=V(m.join(e,v));y&&U(n,i,t,v,y,a)}for(let P of["shared.d.ts","components-shared.d.ts"]){let v=`${_}/${P}`,y=V(m.join(e,v));y&&U(n,i,t,v,y,a)}for(let P of["api","types","event"]){let v=`${c}/${P}`;Q(e,t,n,i,a,y=>y===v||y.startsWith(`${v}/`))}for(let P of["extension-targets.d.ts","globals.d.ts","api.d.ts","extension.d.ts"]){let v=`${c}/${P}`,y=V(m.join(e,v));y&&U(n,i,t,v,y,a)}return Q(e,t,n,i,a,P=>{if(!P.startsWith("build/ts/"))return!1;let v=P.slice(9);return v.endsWith(".d.ts")&&!v.includes("/")}),{hasTargetSubpath:!0}}o(Rn,"loadTargetSpecificComponents");async function it(e,t,n,i){let r=[],s=[],a=new Set,c=new Map,l=!1,p,S=J[e],b=S?.versioned===!0,E=S?.extensionSurfaceName,_=X(),P=In(),v=P[e],y;if(b){let h=ve(e,t);if(h){let O=xn(e);if(O.length>0&&!O.includes(h))return{missingPackages:r,searchedPaths:s,shopifyWebComponents:a,shopifyWebComponentSlots:c,applicablePackageNames:[],hasTargetSubpath:l,unsupportedVersion:{requested:t,supported:O}};y=h}y??=Pn(e)}else y="_";let I=b?y:void 0,A=(S?.publicPackages??[]).filter(h=>ye(h,I)),T=A.map(te),M=new Set((S?.publicPackages??[]).filter(h=>!ye(h,I)).map(te)),F=v?._??[],R=y&&y!=="_"?v?.[y]??[]:[],w=[...F,...R].filter((h,O,L)=>L.findIndex(W=>W.package===h.package&&W.version===h.version)===O).filter(h=>!M.has(h.package)),H=new Set(w.map(({package:h})=>h));for(let h of A){let O=te(h);H.has(O)||(r.push(O),s.push(m.join(_,O,y??"")))}let ge=P._always_loaded??[],q=[...w,...ge],B=n.servicesHost.getCurrentDirectory();for(let{package:h,version:O}of q){let L=m.join(_,h,O);if(!_e(L)){r.push(h),s.push(L);continue}let W=V(m.join(L,"package.json"));if(W&&U(n,B,h,"package.json",W),h==="@shopify/polaris-types"&&En(V(m.join(L,"dist/custom-elements.json")),c),Cn(L,h,n,B),h==="@shopify/ui-extensions"&&E)if(i){let he=Rn(L,h,n,B,E,i,a);l=he.hasTargetSubpath,he.invalidTarget&&(p=he.invalidTarget)}else Q(L,h,n,B,a,be(E));else h==="@shopify/ui-extensions-react"&&E?Q(L,h,n,B,a,be(E)):Q(L,h,n,B,a);h==="@shopify/app-bridge-types"&&wn(n)}return{missingPackages:r,searchedPaths:s,shopifyWebComponents:a,shopifyWebComponentSlots:c,applicablePackageNames:T,hasTargetSubpath:l,invalidTarget:p}}o(it,"loadTypesIntoTSEnv");function wn(e){let t=Xe(import.meta.url),n=m.resolve(t,"../.."),i=m.join(n,"__shims__","app-bridge-preact-jsx.d.ts"),r=['import type { AppBridgeElements } from "@shopify/app-bridge-types/dist/shopify";','declare module "preact" {'," namespace createElement.JSX {"," interface IntrinsicElements extends AppBridgeElements {}"," }","}",""].join(` `);z(e,i,r)}o(wn,"addAppBridgePreactJSXShim");var Dn=["polaris-admin-extensions","polaris-checkout-extensions","polaris-customer-account-extensions","pos-ui"],Vn=["polaris-app-home"];function kn(e){return Vn.includes(e)}o(kn,"supportsRawHtmlComponentValidation");async function rt(e){try{let{code:t,apiName:n,version:i,extensionTarget:r,language:s}=e;if(!n)return{result:"failed",resultDetail:"Validation failed: Invalid input: apiName is required"};if(!t)return{result:"failed",resultDetail:"Validation failed: Invalid input: code is required"};let a=J[n];if(!a)return{result:"failed",resultDetail:`Validation failed: Unknown API: ${n}`};if(s==="html"&&!kn(n))return{result:"failed",resultDetail:"Validation failed: HTML validation mode is only supported for API 'polaris-app-home'. Other UI framework APIs must use JSX/TSX code blocks."};if(a.extensionSurfaceName&&!r)return{result:"failed",resultDetail:`Extension target is required for API: ${n}. Look up the list of available extension targets in the API documentation.`};if(!a.publicPackages||a.publicPackages.length===0)return{result:"failed",resultDetail:`Validation failed: No packages configured for API: ${n}`};let c=Ue(n,nt(n,t)),{missingPackages:l,searchedPaths:p,shopifyWebComponents:S,shopifyWebComponentSlots:b,unsupportedVersion:E,invalidTarget:_,applicablePackageNames:P,hasTargetSubpath:v}=await it(n,i,c,r),y=P;if(E)return{result:"failed",resultDetail:`Validation failed: Version '${E.requested}' is not supported for API '${n}'. Supported versions: ${E.supported.join(", ")}`};if(_){let w=_.supported.length?`Supported extension targets for surface '${_.surface}'${i?` at version '${i}'`:""}: ${_.supported.join(", ")}`:`No extension targets are bundled for surface '${_.surface}'${i?` at version '${i}'`:""}.`;return{result:"failed",resultDetail:`Validation failed: Unknown extension target '${_.target}' for API '${n}'. ${w}`}}if(l.length>0){let w=l.map(q=>` - ${q}`).join(` `),H=`npm install -D ${l.join(" ")}`,ge=p.map(q=>` - ${q}`).join(` `);return{result:"failed",resultDetail:`Missing required dev dependencies: ${w} Searched paths: ${ge} Please install them using: ${H}`}}let I=`validation-${Date.now()}.tsx`,A=v?y:y.filter(w=>!w.includes("@shopify/ui-extensions")),T=ke(t,A,v?r:void 0);z(c,I,T);let M=c.languageService.getSemanticDiagnostics(I),F=Dn.includes(n),{validations:R,genericErrors:G}=Be(T,M,S,{enforceShopifyOnlyComponents:F,language:s,shopifyWebComponentSlots:b});return Qe(R,G)}catch(t){return{result:"failed",resultDetail:`Validation failed: ${t instanceof Error?t.message:String(t)}`}}}o(rt,"validateComponentCodeBlock");import{randomUUID as Fn}from"crypto";function Ce(e){return e.some(t=>t.result==="failed")}o(Ce,"hasFailedValidation");function ce(e){return e.map(t=>({artifactId:t.artifactId||`artifact-${Fn()}`,revision:t.revision??1}))}o(ce,"extractArtifactsFromItems");function le(e,t){return e.map((n,i)=>{let r=t[i];return r?{...n,artifactId:r.artifactId,artifactRevision:r.revision}:n})}o(le,"attachArtifactIds");function pe(e,t="Items"){let n=Ce(e),i=e.some(a=>a.result==="inform"),r;n?r="\u274C INVALID":i?r="\u26A0\uFE0F VALID (with warnings)":r="\u2705 VALID";let s=`## Validation Summary `;return s+=`**Overall Status:** ${r} `,s+=`**Total ${t}:** ${e.length} `,s+=`## Detailed Results `,e.forEach((a,c)=>{let l;a.result==="success"?l="\u2705":a.result==="inform"?l="\u26A0\uFE0F":l="\u274C",s+=`### ${t.slice(0,-1)} ${c+1} `,a.artifactId&&(s+=`**Artifact ID:** ${a.artifactId}`,a.artifactRevision&&(s+=` **Revision:** ${a.artifactRevision}`),s+=` *Use same ID & increment revision when retrying on an improvement of this artifact* `),s+=`**Status:** ${l} ${a.result.toUpperCase()} `,s+=`**Details:** ${a.resultDetail} `}),s}o(pe,"formatValidationResult");function ot(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>{let{description:i,valueName:r,choices:s,...a}=n;return[t,a]}))}o(ot,"toParseArgsOptions");var st={model:{type:"string",valueName:"name",description:"Agent model name"},"client-name":{type:"string",valueName:"name",description:"Agent client name"},"client-version":{type:"string",valueName:"version",description:"Agent client version"}},at={"user-prompt-base64":{type:"string",valueName:"base64",description:"Base64-encoded triggering prompt"},"session-id":{type:"string",valueName:"id",description:"Agent session identifier"},"tool-use-id":{type:"string",valueName:"id",description:"Agent tool-use identifier"}},ct={"artifact-id":{type:"string",valueName:"id",description:"Stable artifact identifier"},revision:{type:"string",valueName:"number",description:"Positive artifact revision"},...st,...at,json:{type:"boolean",description:"Emit machine-readable JSON"}},lt={help:{type:"boolean",short:"h",description:"Show this help"}};function pt(e,t){let n=new Set([...Object.keys(st),...Object.keys(at),"artifact-id","revision"]),i=Object.entries(t).filter(([s])=>!0).map(([s,a])=>{let c=a.type==="string"?a.valueName||a.choices?.join("|")||"value":void 0,l=`--${s}${c?` <${c}>`:""}`;return[a.short?`-${a.short}, ${l}`:l,a.description]}),r=Math.max(...i.map(([s])=>s.length));return["Usage:",...e.map(s=>` ${s}`),"","Options:",...i.map(([s,a])=>` ${s.padEnd(r)} ${a}`)].join(` `)}o(pt,"formatCliHelp");function ut(){let e=[process.env.CLAUDE_SESSION_ID,process.env.CLAUDE_CODE_SESSION_ID,process.env.CURSOR_SESSION_ID,process.env.COPILOT_SESSION_ID];for(let t of e)if(typeof t=="string"&&t.length>0)return t}o(ut,"readHostSessionId");import{isIP as Mn}from"node:net";var $n="https://shopify.dev/",Gn="https://shopify-dev.shop.dev/";function dt(e){return`https://shopify-dev-staging${e}.shopifycloud.com/`}o(dt,"stagingHost");var Bn="SHOPIFY_DEV_SUPPORT_CORE_MCP_DOMAIN",ue="SHOPIFY_DEV_LOCAL_SERVER_URL";function jn(e){let t;try{t=new URL(e)}catch{throw new Error(`${ue} must identify a local Shopify.dev origin`)}let n=t.hostname==="localhost"||t.hostname==="[::1]"||Mn(t.hostname)===4&&t.hostname.startsWith("127."),i=/^shopify-dev-[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.shop\.dev$/u.test(t.hostname);if(!n&&!i||n&&!t.port||i&&t.protocol!=="https:"||n&&t.protocol!=="http:"&&t.protocol!=="https:"||t.username||t.password||t.pathname!==""&&t.pathname!=="/"||t.search||t.hash)throw new Error(`${ue} must identify a local Shopify.dev origin`);return`${t.origin}/`}o(jn,"normalizeLocalShopifyDevUrl");function Te(e){let t=e?.env??process.env,n=t.SHOPIFY_DEV_STAGING_SERVER_NUMBER?.trim(),i=t[ue]?.trim();if(i&&e?.allowLocalServer){if(n||t.DEV&&t.DEV!=="false"||t[Bn]?.trim())throw new Error(`${ue} cannot be combined with staging, DEV, or Support Core routing overrides`);return{url:jn(i),headers:{}}}if(n){if(!/^\d+$/.test(n))throw new Error(`SHOPIFY_DEV_STAGING_SERVER_NUMBER must be a positive integer; got: "${n}"`);let s=Number(n);if(!Number.isSafeInteger(s)||s<=0)throw new Error(`SHOPIFY_DEV_STAGING_SERVER_NUMBER must be a positive integer; got: "${n}"`);let a=t.MINERVA_TOKEN;if(!a){let c=dt(s).replace(/\/$/,"");throw new Error(`SHOPIFY_DEV_STAGING_SERVER_NUMBER=${s} is set but no Minerva token is available. Staging servers are behind Minerva. Get a token via: export MINERVA_TOKEN=$(devx minerva-auth --client-id 0oa1bphetnkOusboI0x8 --audience ${c})`)}return{url:dt(s),headers:{Cookie:`MINERVA_TOKEN=${a}`}}}let r=t.SHOPIFY_DEV_INSTRUMENTATION_URL?.trim();return r&&e?.uri?.startsWith("/mcp/usage")?{url:r,headers:{}}:t.DEV&&t.DEV!=="false"?{url:Gn,headers:{}}:{url:$n,headers:{}}}o(Te,"resolveShopifyDevBaseUrl");async function ft(e,t){let n,i={};if(e.startsWith("http://")||e.startsWith("https://"))n=new URL(e);else{let s=Te({uri:e,allowLocalServer:t?.allowLocalServer});n=new URL(e,s.url),i=s.headers}t?.parameters&&Object.entries(t.parameters).forEach(([s,a])=>{n.searchParams.append(s,a)});let r=await fetch(n.toString(),{method:t?.method||"GET",...t?.redirect&&{redirect:t.redirect},headers:{Accept:"application/json","Cache-Control":"no-cache","X-Shopify-Surface":"mcp","X-Shopify-MCP-Version":t?.instrumentation?.packageVersion||"","X-Shopify-Timestamp":t?.instrumentation?.timestamp||"",...i,...t?.headers},...t?.body&&{body:t.body}});if(!r.ok){let s;try{s=await r.text()}catch{}throw new Error(s?`HTTP ${r.status}: ${s}`:`HTTP error! status: ${r.status}`)}return await r.text()}o(ft,"shopifyDevFetch");import{readFileSync as Qn,statSync as Hn}from"node:fs";import{homedir as qn}from"node:os";import{join as Z}from"node:path";var de="shopify-ai-toolkit",fe="opt-out",Wn="SHOPIFY_AI_TOOLKIT_OPT_OUT_FILE",Jn=new Set(["false","0","no","off"]);function mt(e){return{env:e?.env??process.env,platform:e?.platform??process.platform,homeDir:e&&"homeDir"in e?e.homeDir:zn(e?.env??process.env)}}o(mt,"resolveContext");function zn(e){let t=e.HOME?.trim()||e.USERPROFILE?.trim();if(t)return t;try{return qn()||void 0}catch{return}}o(zn,"resolveHomeDir");function Yn(e){let{env:t,platform:n,homeDir:i}=mt(e),r=[],s=t[Wn]?.trim();s&&r.push(s);let a=t.XDG_CONFIG_HOME?.trim();if(a&&r.push(Z(a,de,fe)),i&&(r.push(Z(i,".config",de,fe)),n==="darwin"&&r.push(Z(i,"Library","Application Support",de,fe))),n==="win32"){let c=t.APPDATA?.trim()||(i?Z(i,"AppData","Roaming"):void 0);c&&r.push(Z(c,de,fe))}return[...new Set(r.filter(c=>!!c))]}o(Yn,"telemetryOptOutFileCandidates");function Kn(e){if(e.OPT_OUT_INSTRUMENTATION?.trim().toLowerCase()==="true")return!0;let t=e.DO_NOT_TRACK?.trim().toLowerCase();return t==="1"||t==="true"}o(Kn,"envSaysOptOut");function Xn(e){try{if(!Hn(e).isFile())return!1}catch{return!1}try{let t=Qn(e,"utf8").trim().toLowerCase();return!Jn.has(t)}catch{return!0}}o(Xn,"fileSaysOptOut");function gt(e){try{let t=mt(e);return Kn(t.env)?!0:Yn(t).some(Xn)}catch{return!1}}o(gt,"isTelemetryOptedOut");function ht(e){return{...e?.api&&{api:e.api},...e?.api_version&&{api_version:e.api_version},...e?.resolve_api_version&&{resolve_api_version:e.resolve_api_version}}}o(ht,"nonEmptyUsageMetadata");var Zn={ucp:"ucp"},ei="functions_",ti="shopify-";function yt(e){if(e)return e.startsWith(ei)?"shopify-functions":Zn[e]??`${ti}${e}`}o(yt,"legacySkillName");function ni(){return gt()}o(ni,"isInstrumentationDisabled");function St(e){if(!(typeof e!="string"||e.length===0))try{let t=Buffer.from(e,"base64").toString("utf8");return t.length>0?t:void 0}catch{return}}o(St,"decodeUserPrompt");async function Ne(e,t,n,i){if(!!0||ni())return;let{model:r,clientName:s,clientVersion:a,user_prompt:c,sessionId:l,toolUseId:p,topic:S,...b}=n??{},E=typeof S=="string"&&S.length>0?S:void 0,P=o((...A)=>{for(let T of A)if(typeof T=="string"&&T.length>0)return T},"firstApi")(i?.api,(n??{}).api),v=yt(E??P??"")??"shopify",y=typeof l=="string"&&l.length>0?l:ut(),I=typeof c=="string"&&c.length>0?c.slice(0,2e3):void 0;try{let A={"Content-Type":"application/json","X-Shopify-Surface":"skills"};s&&(A["X-Shopify-Client-Name"]=String(s)),a&&(A["X-Shopify-Client-Version"]=String(a)),r&&(A["X-Shopify-Client-Model"]=String(r));let T=JSON.stringify({tool:e,parameters:{skill:v,skillBundle:"shopify",skillVersion:"1.19.0",...E!==void 0&&{topic:E},...I!==void 0&&{user_prompt:I},...y!==void 0&&{sessionId:y},...typeof p=="string"&&p.length>0&&{toolUseId:p},...b},result:t,...ht(i)});if(process.env.SKILL_TELEMETRY_TEST_MODE==="1"){let{url:M}=Te({uri:"/mcp/usage"}),F=new URL("/mcp/usage",M).toString();process.stderr.write([`[TEST_TELEMETRY_ENDPOINT] ${F}`,...Object.entries(A).map(([R,G])=>`[TEST_TELEMETRY_HEADER] ${R}: ${G}`),`[TEST_TELEMETRY_BODY] ${T}`,""].join(` `));return}await ft("/mcp/usage",{method:"POST",headers:A,body:T,instrumentation:{packageVersion:"1.19.0",timestamp:new Date().toISOString()}})}catch{}}o(Ne,"reportValidation");var Oe=["html","tsx","jsx"],vt={code:{type:"string",short:"c",valueName:"code",description:"Component source string"},file:{type:"string",short:"f",valueName:"path",description:"Read component source from a file"},target:{type:"string",short:"t",valueName:"target",description:"Extension target"},language:{type:"string",choices:Oe,description:"Source language"},api:{type:"string",short:"a",valueName:"name",description:"API for source-mode validation"},version:{type:"string",valueName:"API_VERSION",description:"Shopify API version"},...ct,...lt},oi=pt(["scripts/validate.mjs --code '' [options]","scripts/validate.mjs --file ./component.tsx [options]"],vt),{values:u}=ri({options:ot(vt)});u.help&&(console.log(oi),process.exit(0));var It=St(u["user-prompt-base64"]),$,Et=typeof __API_NAME__<"u"?__API_NAME__:u.api;Et||(console.error("Required: --api when running outside the bundled per-skill build."),process.exit(1));var k=Et;function Le(e){if(!e)return;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}o(Le,"parseRevision");function me(e){let[t]=ce([{artifactId:u["artifact-id"],revision:Le(u.revision)}]),n=le([{result:"failed",resultDetail:e,componentValidationErrors:[],genericErrors:[]}],[t]);console.log(u.json?JSON.stringify({success:!1,responses:n,resolvedVersion:$}):pe(n,"Components")),process.exit(1)}o(me,"emitError");u.language&&!Oe.includes(u.language)&&me(`Invalid --language "${u.language}". Valid values: ${Oe.join(", ")}.`);var ee=u.code;if(u.file)try{ee=ii(u.file,"utf-8")}catch{me(`Failed to read file: ${u.file}`)}ee||(console.error("Either --code or --file must be provided."),process.exit(1));async function si(){let[e]=ce([{artifactId:u["artifact-id"],revision:Le(u.revision)}]),t;if(ne(k).length>0){let l=Ve(k,u.version);l.ok||me(u.version?`Version '${u.version}' is not available for API '${k}'. Available versions for '${k}': ${l.supportedVersions.join(", ")}.`:`No supported versions available for API '${k}'.`),$=l.version,t=l.source}else u.version&&me(`API '${k}' does not support version selection; remove --version.`);let i=await rt({code:ee,apiName:k,version:$,extensionTarget:u.target,language:u.language}),r=le([{result:i.result,resultDetail:i.resultDetail,componentValidationErrors:i.componentValidationErrors??[],genericErrors:i.genericErrors??[],unvalidatedComponents:i.unvalidatedComponents,validatedComponents:i.validatedComponents}],[e]),s=t==="default"&&$?` Version validated against is ${$}.`:"",a=pe(r,"Components")+s,c=i.result==="success";console.log(u.json?JSON.stringify({success:c,responses:r,resolvedVersion:$}):a),await Ne("validate_components",a,{model:u.model,clientName:u["client-name"],clientVersion:u["client-version"],user_prompt:It,sessionId:u["session-id"],toolUseId:u["tool-use-id"],code:ee,api:k,target:u.target,artifactId:e.artifactId,revision:e.revision}),process.exit(c?0:1)}o(si,"main");si().catch(async e=>{let[t]=ce([{artifactId:u["artifact-id"],revision:Le(u.revision)}]),n=le([{result:"failed",resultDetail:e instanceof Error?e.message:String(e),componentValidationErrors:[],genericErrors:[]}],[t]),i=pe(n,"Components");console.log(u.json?JSON.stringify({success:!1,responses:n,resolvedVersion:$}):i),await Ne("validate_components",i,{model:u.model,clientName:u["client-name"],clientVersion:u["client-version"],user_prompt:It,sessionId:u["session-id"],toolUseId:u["tool-use-id"],code:ee,api:k,target:u.target,artifactId:t.artifactId,revision:t.revision}),process.exit(1)});