const e=require(`./paths-Bcdg3ma0.cjs`),t=require(`./paths-BkeI_nI_.cjs`),n=require(`./model-auth-BEMdAUrd.cjs`);let r=require(`node:fs/promises`);r=e.p(r);var i=class extends Error{constructor(e){super(e),this.status=400,this.name=`ToolInputError`}},a=class extends i{constructor(e){super(e),this.status=403,this.name=`ToolAuthorizationError`}};function o(e){return(t,n=!0)=>{let r=e?.[t];return r===void 0?n:r!==!1}}function s(e){return e.replace(/([A-Z]+)([A-Z][a-z])/g,`$1_$2`).replace(/([a-z0-9])([A-Z])/g,`$1_$2`).toLowerCase()}function c(e,t){if(Object.hasOwn(e,t))return e[t];let n=s(t);if(n!==t&&Object.hasOwn(e,n))return e[n]}function l(e,t,n={}){let{required:r=!1,trim:a=!0,label:o=t,allowEmpty:s=!1}=n,l=c(e,t);if(typeof l!=`string`){if(r)throw new i(`${o} required`);return}let u=a?l.trim():l;if(!u&&!s){if(r)throw new i(`${o} required`);return}return u}function u(e,t,n={}){let{required:r=!1,label:a=t}=n,o=c(e,t);if(typeof o==`number`&&Number.isFinite(o))return String(o);if(typeof o==`string`){let e=o.trim();if(e)return e}if(r)throw new i(`${a} required`)}function d(e,t,n={}){let{required:r=!1,label:a=t,integer:o=!1,strict:s=!1}=n,l=c(e,t),u;if(typeof l==`number`&&Number.isFinite(l))u=l;else if(typeof l==`string`){let e=l.trim();if(e){let t=s?Number(e):Number.parseFloat(e);Number.isFinite(t)&&(u=t)}}if(u===void 0){if(r)throw new i(`${a} required`);return}return o?Math.trunc(u):u}function f(e,t,n={}){let{required:r=!1,label:a=t}=n,o=c(e,t);if(Array.isArray(o)){let e=o.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean);if(e.length===0){if(r)throw new i(`${a} required`);return}return e}if(typeof o==`string`){let e=o.trim();if(!e){if(r)throw new i(`${a} required`);return}return[e]}if(r)throw new i(`${a} required`)}function p(e,t){let n=t.emojiKey??`emoji`,r=t.removeKey??`remove`,a=typeof e[r]==`boolean`?e[r]:!1,o=l(e,n,{required:!0,allowEmpty:!0});if(a&&!o)throw new i(t.removeErrorMessage);return{emoji:o,remove:a,isEmpty:!o}}function m(e){return{content:[{type:`text`,text:JSON.stringify(e,null,2)}],details:e}}async function h(e){return await n.L({content:[{type:`text`,text:e.extraText??`MEDIA:${e.path}`},{type:`image`,data:e.base64,mimeType:e.mimeType}],details:{path:e.path,...e.details}},e.label,e.imageSanitization)}async function g(e){let n=await r.default.readFile(e.path),i=await t.u({buffer:n.slice(0,256)})??`image/png`;return await h({label:e.label,path:e.path,base64:n.toString(`base64`),mimeType:i,extraText:e.extraText,details:e.details,imageSanitization:e.imageSanitization})}function _(e){if(e==null||!Array.isArray(e))return;let t=e.filter(e=>typeof e==`object`&&!!e&&typeof e.name==`string`).map(e=>({...e.id!==void 0&&typeof e.id==`string`?{id:e.id}:{},name:e.name,...typeof e.moderated==`boolean`?{moderated:e.moderated}:{},...e.emoji_id===null||typeof e.emoji_id==`string`?{emoji_id:e.emoji_id}:{},...e.emoji_name===null||typeof e.emoji_name==`string`?{emoji_name:e.emoji_name}:{}}));return t.length?t:void 0}function v(e,t){return`Delivering to ${e} requires target${w(t)}`}function y(e,t){return Error(v(e,t))}function b(e,t,n){return`Ambiguous target "${t}" for ${e}. Provide a unique name or an explicit id.${w(n,!0)}`}function x(e,t,n){return Error(b(e,t,n))}function S(e,t,n){return`Unknown target "${t}" for ${e}.${w(n,!0)}`}function C(e,t,n){return Error(S(e,t,n))}function w(e,t=!1){return e?t?` Hint: ${e}`:` ${e}`:``}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return _}});
