import{Da as b,Ea as k,Fa as E,G as v,Ga as A,Ha as I,Ia as L,Ja as x,Ua as s,Wa as B,Xa as O}from"./chunk-IHUCBI6L.js";import"./chunk-VSZS3FAJ.js";import"./chunk-MQXSMZQZ.js";import"./chunk-VDN6MEYI.js";import"./chunk-VJEKDBGZ.js";import"./chunk-2HZMOK4U.js";import"./chunk-ZDF5N422.js";import"./chunk-MPW2YJWU.js";import"./chunk-VRRDIXFQ.js";import"./chunk-LUG2BZJP.js";import"./chunk-J3KRY2SD.js";import"./chunk-ODH2U44N.js";import"./chunk-T7KHS6RF.js";import"./chunk-4TC4M4RC.js";import"./chunk-IDKUJQIG.js";import"./chunk-WW7TENNA.js";import"./chunk-5C7HDTHJ.js";import{v as w}from"./chunk-E24W34C4.js";import"./chunk-EJDWYASP.js";import"./chunk-RJ5VF3QY.js";import"./chunk-7UNQOKZW.js";import"./chunk-GB3YC4TI.js";import"./chunk-7USHLXEN.js";import"./chunk-3QVXHF6I.js";import{d as R}from"./chunk-ELIH6GCC.js";import{Ka as g,Rb as q,ma as y}from"./chunk-EYDNSYYE.js";import{u as N}from"./chunk-A4SBXDZB.js";import"./chunk-NJOO5XJV.js";import"./chunk-ZG7BVVT2.js";import"./chunk-2O22LZKV.js";import"./chunk-JCNRQYRP.js";import"./chunk-NNOSZ447.js";import{f as h,i as f}from"./chunk-773TIA5M.js";import"./chunk-636CTEW7.js";import"./chunk-T6CC5WUU.js";import"./chunk-UQWFDL3F.js";import"./chunk-I5A6BPCP.js";import"./chunk-CX5CC6P5.js";import"./chunk-ET2CGROE.js";import"./chunk-TOLPNBZK.js";import"./chunk-CRALWNNO.js";import{g as p}from"./chunk-VKWPEFWQ.js";p();import{createRequire as C}from"node:module";async function ee({root:c,appPort:D,inspectorPort:P,assetsPort:S,debug:U=!1,watch:W=!1,buildPathWorkerFile:$,buildPathClient:M,env:l}){let{createMiniOxygen:F,Response:u}=await v("@shopify/mini-oxygen",c).catch(L);k({Response:u});async function _(){let r=C(import.meta.url).resolve("@shopify/hydrogen/customer-account.schema.json");return new u(g(r),{headers:{"Content-Type":"application/json"}})}let t="hydrogen",o=h(c,$),m=()=>y(o).catch(e=>{throw new R(`Could not read worker file.

`+e.stack,"Did you build the project?")}),i=F({debug:U,port:D,host:"localhost",liveReload:W,requestHook:x,inspectorPort:P,inspectWorkerName:t,assets:{port:S,directory:M},workers:[{name:"hydrogen:middleware",modules:!0,script:`export default { fetch: (request, env) => {
          const url = new URL(request.url);
          if (url.hostname.endsWith('${s.ORIGINAL}')) {
            url.hostname = url.hostname.replace(
              '${s.ORIGINAL}',
              '${s.REBRANDED}',
            );
          }

          return url.pathname === '${I}'
            ? env.profiler.fetch(url, request)
            : url.pathname === '/graphiql/customer-account.schema.json'
            ? env.assets.fetch(url, request)
            : env.next.fetch(url, request)
          }
        }`,serviceBindings:{profiler:A,assets:_,next:t}},{name:t,modulesRoot:f(o),modules:[{type:"ESModule",path:o,contents:await m()}],bindings:{...l},serviceBindings:{[b]:E({transformLocation:()=>o})}}]}),{workerUrl:a,inspectorUrl:d}=await i.ready;return{port:Number(a.port),listeningAt:a.origin,reload(e){return i.reload(async({workers:r})=>{let n=r.find(({name:j})=>j===t);return Array.isArray(n.modules)&&n.modules[0]&&(n.modules[0].contents=await m()),e&&(n.bindings={...e?.env??l}),{workers:r}})},showBanner(e){q();let r=[];e?.host&&r.push({body:O(e.host)}),d&&r.push({body:{warn:B(Number(d.port))}}),w({headline:`${e?.headlinePrefix??""}MiniOxygen (Worker Runtime) ${e?.mode??"development"} server running.`,body:[`View ${e?.appName?N.cyan(e?.appName):"Hydrogen"} app:`,{link:{url:e?.host||a.origin}}],customSections:r}),console.log("")},async close(){await i.dispose()}}}export{ee as startWorkerdServer};
