import{t as e}from"./bundled-dir-U738ay4K-BxbzrJOo.mjs";import{r as t}from"./boundary-file-read-BSd9MXPy-gnNVhPKT.mjs";import{c as n,i as r,n as i,r as a,t as o}from"./jiti-loader-cache-Bat69wam-DNIteTtO.mjs";import{createRequire as s}from"node:module";import c from"node:fs";import l from"node:path";import{fileURLToPath as u}from"node:url";const d=a({modulePath:u(import.meta.url),moduleUrl:import.meta.url})??u(new URL(`../..`,import.meta.url)),f=new Map,p=s(import.meta.url),m=new Map,h=new Map,g=new Map;function _(e){switch(l.extname(e).toLowerCase()){case`.ts`:case`.tsx`:case`.mts`:case`.cts`:case`.mtsx`:case`.ctsx`:return!0;default:return!1}}function v(e){return!e.tryNative&&_(e.modulePath)&&typeof p.extensions?.[`.ts`]==`function`}function y(t){let n=e();return`${t.dirName}::${t.artifactBasename}::${n?l.resolve(n):`<default>`}`}function b(t){let r=e(),i=n({rootDir:d,...r?{bundledPluginsDir:r}:{},dirName:t.dirName,artifactBasename:t.artifactBasename});return i?{modulePath:i,boundaryRoot:r&&i.startsWith(l.resolve(r)+l.sep)?l.resolve(r):d}:null}function x(e){let t=y(e);if(m.has(t))return m.get(t)??null;let n=b(e);return m.set(t,n),n}function S(e){return w(e,r(e,{preferBuiltDist:!0}))||o({cache:h,modulePath:e,importerUrl:import.meta.url,preferBuiltDist:!0,jitiFilename:import.meta.url})}function C(e){return v({modulePath:e,tryNative:r(e,{preferBuiltDist:!0})})?p(e):S(e)(e)}function w(t,n){let r=e();if(!i({modulePath:t,openClawPackageRoot:d,...r?{bundledPluginsDir:r}:{}}))return null;let a=n?`bundled:native`:`bundled:source`;return o({cache:g,modulePath:t,importerUrl:import.meta.url,jitiFilename:import.meta.url,cacheScopeKey:a,tryNative:n})}function T(e){let n=x(e);if(!n)throw Error(`Unable to resolve bundled plugin public surface ${e.dirName}/${e.artifactBasename}`);let r=f.get(n.modulePath);if(r)return r;let i=t({absolutePath:n.modulePath,rootPath:n.boundaryRoot,boundaryLabel:n.boundaryRoot===d?`OpenClaw package root`:`bundled plugin directory`,rejectHardlinks:!1});if(!i.ok)throw Error(`Unable to open bundled plugin public surface ${e.dirName}/${e.artifactBasename}`,{cause:i.error});c.closeSync(i.fd);let a={};f.set(n.modulePath,a);try{let e=C(n.modulePath);return Object.assign(a,e),a}catch(e){throw f.delete(n.modulePath),e}}export{T as t};