1#!/usr/bin/env node2var yt=Object.defineProperty;var r=(e,t)=>yt(e,"name",{value:t,configurable:!0});import{readFileSync as Gn}from"fs";import{parseArgs as jn}from"util";var d={PUBLIC:"public",EARLY_ACCESS:
n}]))}r(St,"defineApis");var J=St({"use-shopify-cli":{displayName:"Use Shopify CLI",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.<name>.toml`, `shopify.extension.toml`); 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",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 <shopify-store>, <shopify-cart>, 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_discounts_allocator:{displayName:"Discounts Allocator Function",versioned:!0,description:"GraphQL schema for Discounts Allocator Function input queries",category:f.FUNCTION_GRAPHQL,visibility:d.PUBLIC,schemaSource:{shopifyDevPrefix:"functions_discounts_allocator_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}],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 (<shopify-store>, <shopify-context>, <shopify-cart>, <shopify-variant-selector>, <shopify-money>), native <dialog>, '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.",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 whenever someone asks to make, build, open, or set up a store or shop that sells something (e.g. "make me a store that sells pet supplies"), even without saying Shopify: that means a Shopify store, 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 how to keep it, save it, or make it real. Preview creation belongs here via `shopify store create preview`; app and theme development belongs in `onboarding-dev`; CLI troubleshooting and named-store commands belong in **`use-shopify-cli`**.',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}r(te,"getPublicPackageName");function he(e,t){return typeof e=="string"||!e.versions||t===void 0?!0:e.versions.includes(t)}r(he,"publicPackageAppliesToVersion");var Re={shopifyql:[{name:"2026-10",releaseCandidate:!0},{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"}],admin:[{name:"unstable"},{name:"2026-10",releaseCandidate:!0},{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"}],"storefront-graphql":[{name:"unstable"},{name:"2026-10",releaseCandidate:!0},{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"}],partner:[{name:"unstable"},{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"},{name:"2025-07"}],customer:[{name:"unstable"},{name:"2026-10",releaseCandidate:!0},{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"}],"payments-apps":[{name:"unstable"},{name:"2026-10",releaseCandidate:!0},{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"}],"polaris-app-home":[{name:"v1.1",releaseCandidate:!0},{name:"v1.0",latestVersion:!0}],"polaris-admin-extensions":[{name:"2026-10",releaseCandidate:!0},{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"},{name:"2025-07"}],"polaris-checkout-extensions":[{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"},{name:"2025-07"}],"polaris-customer-account-extensions":[{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"},{name:"2025-07"}],"pos-ui":[{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"},{name:"2025-07"}],hydrogen:[{name:"2026-04",latestVersion:!0},{name:"2026-01"},{name:"2025-10"},{name:"2025-07"}],"storefront-web-components":[],functions_cart_checkout_validation:[{name:"unstable"},{name:"2026-10",releaseCandidate:!0},{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"}],functions_cart_transform:[{name:"unstable"},{name:"2026-10",releaseCandidate:!0},{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"}],functions_delivery_customization:[{name:"unstable"},{name:"2026-10",releaseCandidate:!0},{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"}],functions_discount:[{name:"unstable"},{name:"2026-10",releaseCandidate:!0},{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"}],functions_discounts_allocator:[{name:"unstable",latestVersion:!0}],functions_fulfillment_constraints:[{name:"unstable"},{name:"2026-10",releaseCandidate:!0},{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"}],functions_local_pickup_delivery_option_generator:[{name:"unstable",latestVersion:!0}],functions_order_discounts:[{name:"unstable"},{name:"2026-10",releaseCandidate:!0},{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"}],functions_order_routing_location_rule:[{name:"unstable"},{name:"2026-10",releaseCandidate:!0},{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"}],functions_payment_customization:[{name:"unstable"},{name:"2026-10",releaseCandidate:!0},{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"}],functions_pickup_point_delivery_option_generator:[{name:"unstable",latestVersion:!0}],functions_product_discounts:[{name:"unstable"},{name:"2026-10",releaseCandidate:!0},{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"}],functions_shipping_discounts:[{name:"unstable"},{name:"2026-10",releaseCandidate:!0},{name:"2026-07",latestVersion:!0},{name:"2026-04"},{name:"2026-01"},{name:"2025-10"}]};var ye=Re,De=Object.fromEntries(Object.entries(ye).filter(([e,t])=>t.length>0).map(([e,t])=>[e,t.map(n=>n.name)]));function Ve(e){return Object.prototype.hasOwnProperty.call(De,e)}r(Ve,"hasSupportedVersions");function ne(e){return Ve(e)?De[e]:[]}r(ne,"getSupportedVersions");function It(e){let t=ye[e];if(t)return t.find(n=>n.latestVersion)?.name??t[0]?.name}r(It,"getLatestVersion");function we(e,t){if(!Ve(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=Se(e,t);if(i)return n.includes(i)?{ok:!0,version:i,source:"explicit",supportedVersions:n}:{ok:!1,reason:"unsupported_version",supportedVersions:n};let o=It(e);return o?{ok:!0,version:o,source:"default",supportedVersions:n}:{ok:!1,reason:"no_versions",supportedVersions:n}}r(we,"resolveVersion");function Se(e,t){if(!t||e!=="polaris-app-home")return t;let n=t.replace(/^v/,""),i=/^(\d+)$/.exec(n)?.[1];if(i){let c=ye[e]?.filter(p=>!p.releaseCandidate&&new RegExp("^v?"+i+"\\.\\d+$").test(p.name)).sort((p,u)=>{let I=Number(p.name.replace(/^v/,"").split(".")[1]),E=Number(u.name.replace(/^v/,"").split(".")[1]);return I-E}).at(-1)?.name;if(c)return c}let o=n.replace(/-rc$/,""),s=[t,n,"v"+o,o],a=ne(e);return s.find(c=>a.includes(c))??t}r(Se,"normalizeRequestedVersion");function xt(e,t){return e.map(n=>t&&n.includes("@shopify/ui-extensions")?`import '${n}/${t}';`:`import '${n}';`).join(`
7`}r(ke,"formatCode");import*as R from"path";import _ from"typescript";import{fileURLToPath as Pt}from"url";var Fe=r((e,t)=>({target:_.ScriptTarget.ESNext,module:_.ModuleKind.ESNext,jsx:_.JsxEmit.ReactJSX,jsxImportSource:e||"preact",strict:!0,strictNullChecks:!1,esModuleInterop:!0,skipLibCheck:!0,moduleResolution:_.ModuleResolutionKind.NodeJs,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 Et(){let e=Pt(import.meta.url);return R.resolve(e,"../..")}r(Et,"getPackageRoot");function _t(e,t){let n=t.get(e);if(n)return _.ScriptSnapshot.fromString(n);try{let i=_.sys.readFile(e);return i?_.ScriptSnapshot.fromString(i):void 0}catch{return}}r(_t,"getScriptSnapshot");function At(e,t,n){return{getScriptFileNames:r(()=>Array.from(e.virtualFiles.keys()),"getScriptFileNames"),getScriptVersion:r(i=>e.fileVersions.get(i)?.toString()||"0","getScriptVersion"),getScriptSnapshot:r(i=>_t(i,e.virtualFiles),"getScriptSnapshot"),getCurrentDirectory:r(()=>t,"getCurrentDirectory"),getCompilationSettings:r(()=>Fe(n,t),"getCompilationSettings"),getDefaultLibFileName:r(i=>_.getDefaultLibFilePath(i),"getDefaultLibFileName"),fileExists:r(i=>e.virtualFiles.has(i)||_.sys.fileExists(i),"fileExists"),readFile:r(i=>e.virtualFiles.get(i)||_.sys.readFile(i),"readFile"),readDirectory:_.sys.readDirectory,getDirectories:_.sys.getDirectories,directoryExists:r(i=>{let o=i.endsWith(R.sep)?i:i+R.sep;for(let s of e.virtualFiles.keys())if(s.startsWith(o))return!0;return _.sys.directoryExists(i)},"directoryExists"),getNewLine:r(()=>`
8`,"getNewLine")}}r(At,"createLanguageServiceHost");function Ue(e,t){let n=new Map,i=new Map,o=Et(),s=t??(e==="hydrogen"?"react":"preact"),a=At({fileVersions:n,virtualFiles:i},o,s),c=_.createLanguageService(a,_.createDocumentRegistry()),p=R.dirname(_.getDefaultLibFilePath(Fe(s,o))),u=["lib.es5.d.ts","lib.es2020.d.ts","lib.dom.d.ts"];for(let I of u)try{let E=R.join(p,I),x=_.sys.readFile(E);x&&(i.set(E,x),n.set(E,1))}catch{}return{languageService:c,servicesHost:a,fileVersions:n,virtualFiles:i}}r(Ue,"createVirtualTSEnvironment");function Ct(e,t){let i=(e.get(t)||0)+1;return e.set(t,i),i}r(Ct,"incrementFileVersion");function W(e,t,n){e.virtualFiles.set(t,n),Ct(e.fileVersions,t)}r(W,"addFileToVirtualEnv");var ve=["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},A={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'/},Ot=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"]),Nt=/^(number|boolean)(\s*\|\s*(number|boolean|undefined|null))*$/;function Lt(e){return Ot.has(e)||/^on[a-z]+$/.test(e)}r(Lt,"isHtmlGlobalAttribute");function Rt(e){let t=e.match(A.TYPE_NOT_ASSIGNABLE);if(!t)return!1;let n=t[1],i=t[2];return n!=="string"?!1:Nt.test(i.trim())}r(Rt,"isHtmlStringCoercion");function Dt(e){return ve.includes(e)}r(Dt,"isStandardHTMLElement");function Vt(e){return Me.includes(e)}r(Vt,"isStandardSVGElement");function wt(e){let t=[];function n(i){if(g.isJsxOpeningElement(i)||g.isJsxSelfClosingElement(i)){let o=i.tagName.getText(e),s=i.getStart(e),a=i.getEnd();t.push({tagName:o,node:i,start:s,end:a})}g.forEachChild(i,n)}return r(n,"visit"),g.forEachChild(e,n),t}r(wt,"extractJSXElements");function z(e){return{componentName:e,valid:!0,errors:[],skipped:!0}}r(z,"createSkippedValidation");function Ie(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}]}}r(Ie,"createDisallowedElementValidation");function kt(e){return e.replace(/\./g,"")}r(kt,"sanitizeComponentName");function Ft(e,t,n,i,o){let s=kt(e);return Dt(s)?o?Ie(e,"HTML"):z(e):Vt(s)?o?Ie(e,"SVG"):z(e):t.has(s)?null:o?n.has(s)||i.has(s)?z(e):Ie(e,"custom"):z(e)}r(Ft,"handleNonShopifyComponent");function Ut(e){return!e.startsWith("@shopify/")}r(Ut,"isUserDefinedImport");function Mt(e,t){e.name&&t.add(e.name.text)}r(Mt,"collectDefaultImportName");function $t(e,t){let{namedBindings:n}=e;if(n&&g.isNamedImports(n))for(let i of n.elements)t.add(i.name.text)}r($t,"collectNamedImportNames");function Gt(e,t){Mt(e,t),$t(e,t)}r(Gt,"collectImportedNames");function jt(e){let{moduleSpecifier:t}=e;return g.isStringLiteral(t)?t.text:null}r(jt,"getModulePath");function Bt(e){let t=new Set;function n(i){g.isImportDeclaration(i)&&Qt(i,t),g.forEachChild(i,n)}return r(n,"visitNode"),g.forEachChild(e,n),t}r(Bt,"extractUserImportedComponents");function Qt(e,t){let n=jt(e);if(!n||!Ut(n))return;let{importClause:i}=e;i&&Gt(i,t)}r(Qt,"processImportDeclaration");function xe(e){return/^[A-Z]/.test(e)}r(xe,"isPascalCase");function Ht(e){let t=new Set;function n(i){if(g.isFunctionDeclaration(i)&&i.name){let o=i.name.text;xe(o)&&t.add(o)}if(g.isVariableStatement(i)){for(let o of i.declarationList.declarations)if(g.isIdentifier(o.name)&&o.initializer&&(g.isArrowFunction(o.initializer)||g.isFunctionExpression(o.initializer))){let s=o.name.text;xe(s)&&t.add(s)}}if(g.isClassDeclaration(i)&&i.name){let o=i.name.text;xe(o)&&t.add(o)}g.forEachChild(i,n)}return r(n,"visitNode"),g.forEachChild(e,n),t}r(Ht,"extractLocallyDefinedComponents");function qt(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}r(qt,"hyphenatedToCamelCase");function Jt(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 o=qt(i);t.push({property:i,message:`Property '${i}' uses a hyphenated name which is not a valid Polaris prop. Use camelCase '${o}' instead.`})}return t}r(Jt,"checkHyphenatedAttributes");function Wt(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}}r(Wt,"getStaticJsxAttribute");function zt(e){return Yt(e)?.openingElement}r(zt,"getParentOpeningElement");function Yt(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}}r(Yt,"getContainingJsxElement");function $e(e){return{property:"slot",message:e}}r($e,"slotError");function Kt(e,t){let n=new Map;for(let{node:i}of e){let o=Wt(i,"slot");if(o===void 0)continue;let s=zt(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(o)){n.set(i,[$e(`Slot '${o}' is not defined on '${a}'. Allowed slots: ${Array.from(c).map(p=>p===""?"(default)":p).join(", ")}.`)]);continue}}return n}r(Kt,"collectSlotValidationErrors");function je(e,t,n,i={}){let{enforceShopifyOnlyComponents:o=!1,language:s,shopifyWebComponentSlots:a}=i,c=s==="html",p=[],u=new Set,I=g.createSourceFile("temp.tsx",e,g.ScriptTarget.Latest,!0,g.ScriptKind.TSX),E=wt(I),x=a?Kt(E,a):new Map,b=o?Bt(I):new Set,P=o?Ht(I):new Set;for(let{tagName:v,node:L,start:U,end:B}of E){let M=Ft(v,n,b,P,o);if(M){p.push(M);continue}let{errors:V,handledDiagnostics:ee}=en(U,B,t,c);ee.forEach(Q=>u.add(Q));let N=Jt(L);V.push(...N),V.push(...x.get(L)??[]),p.push({componentName:v,valid:V.length===0,errors:V})}let y=t.filter(v=>!u.has(v)).filter(v=>Be(v,c)).filter(Xt).map(v=>({message:g.flattenDiagnosticMessageText(v.messageText,`
11`);return!(t.match(A.PREACT_REACT_COMPAT)||t.match(A.NEVER_TYPE_CASCADE)||t.match(A.PRIMITIVE_PROPERTY_ACCESS)||t.match(A.CSS_PROPERTIES_COMPAT)||t.match(A.OBJECT_IS_UNKNOWN))}r(Xt,"shouldIncludeGenericDiagnostic");function Zt(e,t,n,i=!1){if(!Be(e,i)||e.code===Ge.CANNOT_FIND_NAME)return!1;let o=e.start,s=e.start+e.length;return o>=t&&s<=n}r(Zt,"isRelevantDiagnostic");function en(e,t,n,i=!1){let o=[],s=[],a=n.filter(c=>Zt(c,e,t,i));for(let c of a){let p=g.flattenDiagnosticMessageText(c.messageText,`
12`),u=tn(c,p);u&&(o.push(u),s.push(c))}return{errors:o,handledDiagnostics:s}}r(en,"getComponentErrors");function tn(e,t){let n="",i,o,s=t.match(A.PROPERTY_NOT_EXIST);if(s)n=s[1];else{let a=t.match(A.TYPE_NOT_ASSIGNABLE),c=t.match(A.PROPERTY);a&&(o=a[1],i=a[2]),c&&(n=c[1])}return{property:n||"unknown",message:t,expected:i,actual:o}}r(tn,"parseDiagnostic");function Qe(e,t=[]){let n=[],i=[],o=[];for(let c of e)if(c.valid)c.skipped?o.push(c.componentName):i.push(c.componentName);else for(let p of c.errors)n.push(`${c.componentName} validation failed: Property '${p.property}': ${p.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:
13${n.join(`
14`)}`),o.length>0&&(s+=`
15
16Try and use component from Shopify Polaris components. Non-Shopify components (not validated):
17${o.map(c=>` - ${c}`).join(`
18`)}`),{result:a,resultDetail:s,componentValidationErrors:e.filter(c=>!c.skipped&&!c.valid).flatMap(c=>c.errors.map(p=>({componentName:c.componentName,...p}))),genericErrors:t,unvalidatedComponents:Array.from(new Set(o)),validatedComponents:Array.from(new Set(i))}}r(Qe,"formatValidationResponse");import{existsSync as C,readFileSync as G,readdirSync as pn}from"fs";import*as l from"path";import{fileURLToPath as We}from"url";import{gunzipSync as Je}from"zlib";import{brotliCompressSync as xi,brotliDecompressSync as nn,constants as bi}from"zlib";var be=4;function He(e){let t=nn(e);if(t.length<be)throw new Error(`Corrupt asset archive: ${t.length}-byte stream is shorter than the header-length field`);let n=t.readUInt32LE(0),i=be+n;if(i>t.length)throw new Error(`Corrupt asset archive: header (${n} bytes) extends past the ${t.length}-byte stream`);let o=JSON.parse(t.subarray(be,i).toString("utf-8")),s=t.subarray(i),a=new Map;for(let[c,p,u]of o){if(!Number.isInteger(p)||!Number.isInteger(u)||p<0||u<0||p+u>s.length)throw new Error(`Corrupt asset archive: member '${c}' (offset ${p}, length ${u}) is out of bounds for the ${s.length}-byte body`);a.set(c,s.subarray(p,p+u))}return a}r(He,"unpackAssetArchive");function qe(e,t){if(!t)return[];switch(t){case"@shopify/polaris-types":case"@shopify/ui-extensions":return rn(e);case"@shopify/ui-extensions-react":return an(e);case"@shopify/app-bridge-types":return sn(e);case"@shopify/hydrogen":return cn(e);case"@shopify/app-bridge-react":return on(e);default:return[]}}r(qe,"extractShopifyComponents");function on(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]);return[...new Set(t)]}r(on,"extractAppBridgeReactComponents");function rn(e){let t=[],n=/declare\s+const\s+tagName\$?\w*\s*=\s*['"]([^'"]+)['"]/g,i=/\[['"]([a-z]+-[a-z-]+)['"]\]\s*:/g,o;for(;(o=n.exec(e))!==null||(o=i.exec(e))!==null;)t.push(o[1]);return[...new Set(t)]}r(rn,"extractWebComponentTagNames");function sn(e){let t=[],n=e.match(/interface\s+AppBridgeElements\s*\{([^}]+)\}/);if(n){let i=/['"]([a-z]+-[a-z-]+)['"]\s*:/g,o;for(;(o=i.exec(n[1]))!==null;)t.push(o[1])}return t}r(sn,"extractAppBridgeElements");function an(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 o=/export\s+(?!type\b)\{([^}]+)\}/g;for(;(i=o.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+/),p=c[c.length-1].trim();/^[A-Z]\w*$/.test(p)&&t.add(p)}return[...t]}r(an,"extractReactBindingComponentNames");function cn(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 o=/declare\s+function\s+(\w+)\s*(?:<[^>]*>)?\s*\([^)]*\)\s*:\s*ReturnType<FC>/g;for(;(n=o.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+const\s+(\w+)\s*:\s*react\.ForwardRefExoticComponent/g;for(;(n=a.exec(e))!==null;)t.push(n[1]);let c=/declare\s+const\s+(\w+)\s*:\s*react\.Provider/g;for(;(n=c.exec(e))!==null;)t.push(n[1]);return[...new Set(t)]}r(cn,"extractHydrogenComponents");var ie,oe,re;function ln(e){let t=l.resolve(e,"..","assets","types");if(C(ze(t))||C(l.join(t,"index.json")))return t;if(e.includes("dev-mcp")&&e.includes("dist")&&!e.includes("shopify-dev-tools"))return l.join(e,"data","types");if(e.includes("/dist")||e.includes("\\dist")){let n=e.lastIndexOf(l.sep+"dist");if(n!==-1){let i=e.substring(0,n+5);return l.join(i,"data","types")}return l.join(e,"data","types")}return l.resolve(e,"../data/types")}r(ln,"resolveTypesDataDirectory");function K(){if(oe)return oe;let e=l.dirname(We(import.meta.url));return oe=ln(e),oe}r(K,"getTypesDataDirectory");function un(){if(ie)return ie;let e=l.join(K(),"index.json"),t=D(e);if(t===void 0)throw new Error(`Types index not found at ${e}`);return ie=JSON.parse(t),ie}r(un,"readIndexJson");var Y;function ze(e){return`${e}.archive.br`}r(ze,"typesArchivePathFor");function se(){if(Y!==void 0)return Y;let e=ze(K());if(!C(e))return Y=null,null;let t=He(G(e)),n=new Set([""]);for(let i of t.keys()){let o=i.split("/");for(let s=1;s<o.length;s++)n.add(o.slice(0,s).join("/"))}return Y={files:t,dirs:n},Y}r(se,"getArchiveStore");function ae(e){let t=l.relative(K(),e).split(l.sep).join("/");if(!(t===".."||t.startsWith("../")||l.isAbsolute(t)))return t}r(ae,"archiveRel");function Ye(e){return e.endsWith(".gz")?e.slice(0,-3):e}r(Ye,"logicalRel");function D(e){let t=se();if(t){let n=ae(e);return n===void 0?void 0:t.files.get(Ye(n))?.toString("utf-8")}return gn(e)}r(D,"assetFileContent");function Pe(e){let t=se();if(t){let n=ae(e);return n!==void 0&&t.files.has(Ye(n))}return e.endsWith(".gz")?C(e)||C(e.slice(0,-3)):C(e)||C(`${e}.gz`)}r(Pe,"assetFileExists");function _e(e){let t=se();if(t){let n=ae(e);return n!==void 0&&t.dirs.has(n)}return C(e)}r(_e,"assetDirExists");function Ae(e){let t=se();if(t){let i=ae(e);if(i===void 0||!t.dirs.has(i))return[];let o=i===""?"":`${i}/`,s=new Map;for(let a of t.files.keys()){if(!a.startsWith(o))continue;let c=a.slice(o.length),p=c.indexOf("/");if(p===-1)s.set(c,{name:c,isDirectory:!1,isFile:!0});else{let u=c.slice(0,p);s.has(u)||s.set(u,{name:u,isDirectory:!0,isFile:!1})}}return[...s.values()].sort((a,c)=>a.name.localeCompare(c.name))}let n;try{n=pn(e,{withFileTypes:!0})}catch{return[]}return n.map(i=>({name:i.name,isDirectory:i.isDirectory(),isFile:i.isFile()}))}r(Ae,"assetDirEntries");function dn(e,t){if(e)try{let n=JSON.parse(e);for(let i of n.modules??[])for(let o of i.declarations??[])!o.tagName||!o.slots||t.set(o.tagName,new Set(o.slots.map(s=>s.name).filter(s=>typeof s=="string")))}catch{}}r(dn,"addCustomElementSlots");function Ke(){if(re)return re;let e=K(),t=l.join(e,"..","supported-versions-schema.json");return re=JSON.parse(G(t,"utf-8")),re}r(Ke,"readSupportedVersions");function fn(e){let t=Ke()[e];if(t)return t.find(n=>n.latestVersion)?.name}r(fn,"resolveLatestVersion");function Xe(e,t){return e==="hydrogen"||/^\s*(?:import|export)\b[^'"]*['"]@shopify\/ui-extensions-react(?:\/[^'"]*)?['"]/m.test(t)?"react":"preact"}r(Xe,"resolveJsxRuntime");function mn(e){return(Ke()[e]??[]).map(t=>t.name)}r(mn,"supportedVersionNames");function gn(e){if(e.endsWith(".gz")){if(C(e))return Je(G(e)).toString("utf-8");let n=e.slice(0,-3);return C(n)?G(n,"utf-8"):void 0}if(C(e))return G(e,"utf-8");let t=e+".gz";if(C(t))return Je(G(t)).toString("utf-8")}r(gn,"readAssetFile");function hn(e,t){let n=[];if(!_e(e))return n;function i(o,s){for(let a of Ae(o)){if(a.name.startsWith(".")||a.name==="node_modules")continue;let c=l.join(o,a.name),p=a.name.endsWith(".gz")?a.name.slice(0,-3):a.name,u=s?`${s}/${p}`:p;if(a.isDirectory)i(c,u);else if(a.isFile){if(!(p.endsWith(".d.ts")||p.endsWith(".ts")&&!p.endsWith(".test.ts")&&!p.endsWith(".spec.ts"))||t&&!t(u))continue;n.push({assetPath:c,relPath:u})}}}return r(i,"walk"),i(e,""),n}r(hn,"walkAssetDts");function yn(e,t,n,i){for(let o of Ae(e)){if(!o.isDirectory||o.name.startsWith(".")||o.name==="node_modules")continue;let s=l.join(e,o.name);if(Pe(l.join(s,"package.json")))continue;let a;if(Pe(l.join(s,"src","index.d.ts"))?a="./src/index.d.ts":Pe(l.join(s,"index.d.ts"))&&(a="./index.d.ts"),!a)continue;let c=JSON.stringify({name:`${t}/${o.name}`,types:a}),p=`${o.name}/package.json`;w(n,i,t,p,c)}}r(yn,"synthesizeNestedPackageJsons");function Sn(e,t,n){return l.join(e,"node_modules",t,n)}r(Sn,"virtualPathFor");function w(e,t,n,i,o,s){let a=Sn(t,n,i);if(W(e,a,o),s)for(let c of qe(o,n))s.add(c)}r(w,"addAssetToVirtualEnv");var vn={"customer-account":["checkout"]};function Ee(e){let t=[e,...vn[e]??[]],n=new Set(t.map(s=>`build/ts/surfaces/${s}.d.ts`)),i=t.map(s=>`build/ts/surfaces/${s}/`),o="build/ts/";return s=>!!(n.has(s)||i.some(a=>s.startsWith(a))||s.startsWith(o)&&s.endsWith(".d.ts")&&!s.slice(o.length).includes("/"))}r(Ee,"surfaceMatcher");function j(e,t,n,i,o,s){for(let{assetPath:a,relPath:c}of hn(e,s)){let p=D(a);p&&w(n,i,t,c,p,o)}}r(j,"loadDtsTree");function In(e){let t=[],n=/import\s+['"]\.\.\/components\/(\w+)\.d\.ts['"]/g,i;for(;(i=n.exec(e))!==null;)t.push(i[1]);return t}r(In,"extractComponentImports");function xn(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()}r(xn,"listAvailableTargets");function bn(e,t,n,i,o,s,a){let c=`build/ts/surfaces/${o}`,p=l.join(e,c,"targets"),u=`${c}/targets/${s}.d.ts`,I=D(l.join(e,u));if(!I)return _e(p)?{hasTargetSubpath:!1,invalidTarget:{target:s,surface:o,supported:xn(p)}}:(j(e,t,n,i,a,Ee(o)),{hasTargetSubpath:!1});let E=`${c}.d.ts`,x=D(l.join(e,E));x&&w(n,i,t,E,x,a),w(n,i,t,u,I,a);let b=`${c}/components`;for(let P of In(I)){let S=`${b}/${P}.d.ts`,y=D(l.join(e,S));y&&w(n,i,t,S,y,a)}for(let P of["shared.d.ts","components-shared.d.ts"]){let S=`${b}/${P}`,y=D(l.join(e,S));y&&w(n,i,t,S,y,a)}for(let P of["api","types","event"]){let S=`${c}/${P}`;j(e,t,n,i,a,y=>y===S||y.startsWith(`${S}/`))}for(let P of["extension-targets.d.ts","globals.d.ts","api.d.ts","extension.d.ts"]){let S=`${c}/${P}`,y=D(l.join(e,S));y&&w(n,i,t,S,y,a)}return j(e,t,n,i,a,P=>{if(!P.startsWith("build/ts/"))return!1;let S=P.slice(9);return S.endsWith(".d.ts")&&!S.includes("/")}),{hasTargetSubpath:!0}}r(bn,"loadTargetSpecificComponents");async function Ze(e,t,n,i){let o=[],s=[],a=new Set,c=new Map,p=!1,u,I=J[e],E=I?.versioned===!0,x=I?.extensionSurfaceName,b=K(),P=un(),S=P[e],y;if(E){let h=Se(e,t);if(h){let T=mn(e);if(T.length>0&&!T.includes(h))return{missingPackages:o,searchedPaths:s,shopifyWebComponents:a,shopifyWebComponentSlots:c,applicablePackageNames:[],hasTargetSubpath:p,unsupportedVersion:{requested:t,supported:T}};y=h}y??=fn(e)}else y="_";let v=E?y:void 0,L=(I?.publicPackages??[]).filter(h=>he(h,v)),U=L.map(te),B=new Set((I?.publicPackages??[]).filter(h=>!he(h,v)).map(te)),M=S?._??[],V=y&&y!=="_"?S?.[y]??[]:[],N=[...M,...V].filter((h,T,O)=>O.findIndex(q=>q.package===h.package&&q.version===h.version)===T).filter(h=>!B.has(h.package)),Q=new Set(N.map(({package:h})=>h));for(let h of L){let T=te(h);Q.has(T)||(o.push(T),s.push(l.join(b,T,y??"<unknown-version>")))}let me=P._always_loaded??[],H=[...N,...me],$=n.servicesHost.getCurrentDirectory();for(let{package:h,version:T}of H){let O=l.join(b,h,T);if(!_e(O)){o.push(h),s.push(O);continue}let q=D(l.join(O,"package.json"));if(q&&w(n,$,h,"package.json",q),h==="@shopify/polaris-types"&&dn(D(l.join(O,"dist/custom-elements.json")),c),yn(O,h,n,$),h==="@shopify/ui-extensions"&&x)if(i){let ge=bn(O,h,n,$,x,i,a);p=ge.hasTargetSubpath,ge.invalidTarget&&(u=ge.invalidTarget)}else j(O,h,n,$,a,Ee(x));else h==="@shopify/ui-extensions-react"&&x?j(O,h,n,$,a,Ee(x)):j(O,h,n,$,a);h==="@shopify/app-bridge-types"&&Pn(n)}return{missingPackages:o,searchedPaths:s,shopifyWebComponents:a,shopifyWebComponentSlots:c,applicablePackageNames:U,hasTargetSubpath:p,invalidTarget:u}}r(Ze,"loadTypesIntoTSEnv");function Pn(e){let t=We(import.meta.url),n=l.resolve(t,"../.."),i=l.join(n,"__shims__","app-bridge-preact-jsx.d.ts"),o=['import type { AppBridgeElements } from "@shopify/app-bridge-types/dist/shopify";','declare module "preact" {'," namespace createElement.JSX {"," interface IntrinsicElements extends AppBridgeElements {}"," }","}",""].join(`
19`);W(e,i,o)}r(Pn,"addAppBridgePreactJSXShim");var En=["polaris-admin-extensions","polaris-checkout-extensions","polaris-customer-account-extensions","pos-ui"],_n=["polaris-app-home"];function An(e){return _n.includes(e)}r(An,"supportsRawHtmlComponentValidation");async function et(e){try{let{code:t,apiName:n,version:i,extensionTarget:o,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"&&!An(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&&!o)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,Xe(n,t)),{missingPackages:p,searchedPaths:u,shopifyWebComponents:I,shopifyWebComponentSlots:E,unsupportedVersion:x,invalidTarget:b,applicablePackageNames:P,hasTargetSubpath:S}=await Ze(n,i,c,o),y=P;if(x)return{result:"failed",resultDetail:`Validation failed: Version '${x.requested}' is not supported for API '${n}'. Supported versions: ${x.supported.join(", ")}`};if(b){let N=b.supported.length?`Supported extension targets for surface '${b.surface}'${i?` at version '${i}'`:""}: ${b.supported.join(", ")}`:`No extension targets are bundled for surface '${b.surface}'${i?` at version '${i}'`:""}.`;return{result:"failed",resultDetail:`Validation failed: Unknown extension target '${b.target}' for API '${n}'. ${N}`}}if(p.length>0){let N=p.map(H=>` - ${H}`).join(`
44`)}r(st,"formatCliHelp");function at(){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}r(at,"readHostSessionId");var On="https://shopify.dev/",Nn="https://shopify-dev.shop.dev/";function ct(e){return`https://shopify-dev-staging${e}.shopifycloud.com/`}r(ct,"stagingHost");function Te(e){let t=e?.env??process.env,n=t.SHOPIFY_DEV_STAGING_SERVER_NUMBER?.trim();if(n){if(!/^\d+$/.test(n))throw new Error(`SHOPIFY_DEV_STAGING_SERVER_NUMBER must be a positive integer; got: "${n}"`);let o=Number(n);if(!Number.isSafeInteger(o)||o<=0)throw new Error(`SHOPIFY_DEV_STAGING_SERVER_NUMBER must be a positive integer; got: "${n}"`);let s=t.MINERVA_TOKEN;if(!s){let a=ct(o).replace(/\/$/,"");throw new Error(`SHOPIFY_DEV_STAGING_SERVER_NUMBER=${o} is set but no Minerva token is available. Staging servers are behind Minerva. Get a token via:
46`));return}await pt("/mcp/usage",{method:"POST",headers:b,body:P,instrumentation:{packageVersion:"1.16.0",timestamp:new Date().toISOString()}})}catch{}}r(Oe,"reportValidation");var Ne=["html","tsx","jsx"],mt={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:Ne,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"},...ot,...rt},Bn=st(["scripts/validate.mjs --code '<tsx-or-html>' [options]","scripts/validate.mjs --file ./component.tsx [options]"],mt),{values:m}=jn({options:tt(mt)});m.help&&(console.log(Bn),process.exit(0));var gt=ft(m["user-prompt-base64"]),F,ht="pos-ui";ht||(console.error("Required: --api <name> when running outside the bundled per-skill build."),process.exit(1));var k=ht;function Le(e){if(!e)return;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}r(Le,"parseRevision");function fe(e){let[t]=ce([{artifactId:m["artifact-id"],revision:Le(m.revision)}]),n=pe([{result:"failed",resultDetail:e,componentValidationErrors:[],genericErrors:[]}],[t]);console.log(m.json?JSON.stringify({success:!1,responses:n,resolvedVersion:F}):le(n,"Components")),process.exit(1)}r(fe,"emitError");m.language&&!Ne.includes(m.language)&&fe(`Invalid --language "${m.language}". Valid values: ${Ne.join(", ")}.`);var Z=m.code;if(m.file)try{Z=Gn(m.file,"utf-8")}catch{fe(`Failed to read file: ${m.file}`)}Z||(console.error("Either --code or --file must be provided."),process.exit(1));async function Qn(){let[e]=ce([{artifactId:m["artifact-id"],revision:Le(m.revision)}]),t;if(ne(k).length>0){let p=we(k,m.version);p.ok||fe(m.version?`Version '${m.version}' is not available for API '${k}'. Available versions for '${k}': ${p.supportedVersions.join(", ")}.`:`No supported versions available for API '${k}'.`),F=p.version,t=p.source}else m.version&&fe(`API '${k}' does not support version selection; remove --version.`);let i=await et({code:Z,apiName:k,version:F,extensionTarget:m.target,language:m.language}),o=pe([{result:i.result,resultDetail:i.resultDetail,componentValidationErrors:i.componentValidationErrors??[],genericErrors:i.genericErrors??[],unvalidatedComponents:i.unvalidatedComponents,validatedComponents:i.validatedComponents}],[e]),s=t==="default"&&F?`
47Version validated against is ${F}.`:"",a=le(o,"Components")+s,c=i.result==="success";console.log(m.json?JSON.stringify({success:c,responses:o,resolvedVersion:F}):a),await Oe("validate_components",a,{model:m.model,clientName:m["client-name"],clientVersion:m["client-version"],user_prompt:gt,sessionId:m["session-id"],toolUseId:m["tool-use-id"],code:Z,target:m.target,artifactId:e.artifactId,revision:e.revision}),process.exit(c?0:1)}r(Qn,"main");Qn().catch(async e=>{let[t]=ce([{artifactId:m["artifact-id"],revision:Le(m.revision)}]),n=pe([{result:"failed",resultDetail:e instanceof Error?e.message:String(e),componentValidationErrors:[],genericErrors:[]}],[t]),i=le(n,"Components");console.log(m.json?JSON.stringify({success:!1,responses:n,resolvedVersion:F}):i),await Oe("validate_components",i,{model:m.model,clientName:m["client-name"],clientVersion:m["client-version"],user_prompt:gt,sessionId:m["session-id"],toolUseId:m["tool-use-id"],code:Z,target:m.target,artifactId:t.artifactId,revision:t.revision}),process.exit(1)});