import{c as a,A as c}from"./dc0o8kHW.js";function d(e){return e.alt?.trim()||e.title?.trim()||e.filename}function f(e){return`media://${e.path?`${e.path}/${e.filename}`:e.filename}`}function s(e){return!e||e.startsWith("<")?e:/\s/.test(e)?`<${e}>`:e}function p(e,t=e.filename){const n=s(t);return e.type.startsWith("image/")?`![${d(e)}](${n})`:`[${e.filename}](${n})`}function r(e){return e.split("/").map(encodeURIComponent).join("/")}function m(e){const t=e.match(/\?\d+$/),n=t?t[0]:"";return(n?e.slice(0,-n.length):e).replace(/#/g,"%23").replace(/\?/g,"%3F")+n}async function g(e={}){const t={};e.path&&(t.path=e.path),e.search&&(t.search=e.search),e.type&&(t.type=e.type),e.page&&(t.page=String(e.page)),e.per_page&&(t.per_page=String(e.per_page));const n=await a.getFullBody("/media",t);return{items:n.data,folders:n.meta.folders,path:n.meta.path,pagination:n.meta.pagination,search:n.meta.search,ordered:n.meta.ordered??!1}}async function y(e){return a.delete(`/media/${r(e)}`)}async function h(e){return a.post("/media/folders",{path:e})}async function M(e){return a.delete(`/media/folders/${r(e)}`)}async function $(e,t){return a.post("/media/rename",{from:e,to:t})}async function R(e,t){return a.post("/media/folders/rename",{from:e,to:t})}async function S(e,t){return a.post("/media/order",{path:e,order:t})}async function w(e,t){const n=i(e);if(n===null)throw new Error("Cannot read media metadata: route is not resolved yet.");return a.get(`/pages/${n}/media/${encodeURIComponent(t)}/meta`)}async function E(e,t,n){const o=i(e);if(o===null)throw new Error("Cannot save media metadata: route is not resolved yet.");return a.patch(`/pages/${o}/media/${encodeURIComponent(t)}/meta`,{fields:n})}async function F(e){return a.get("/media/meta",{path:e})}async function I(e,t){return a.patch(`/media/meta?path=${encodeURIComponent(e)}`,{fields:t})}async function P(e,t){return a.post("/media/batch/meta",{files:e,fields:t})}const u=Symbol("PAGE_MEDIA_ONLY");async function _(e){const t={folder:e.folder};e.scope&&(t.scope=e.scope),e.accept&&e.accept.length>0&&(t.accept=e.accept.join(",")),t.preview_images="1";try{const n=await a.getFullBody("/blueprint-files",t);return{items:n.data,folder:n.meta.folder,scope:n.meta.scope,exists:n.meta.exists}}catch(n){if(n instanceof c&&n.status===422)return u;throw n}}async function b(e){return a.get(`/${e}/media`)}async function C(e,t){return a.delete(`/${e}/media/${encodeURIComponent(t)}`)}function i(e){const t=e.startsWith("/")?e.slice(1):e;return t===""?null:t}async function v(e){const t=i(e);return t===null?[]:a.get(`/pages/${t}/media`)}async function U(e,t){const n=i(e);if(n===null)throw new Error("Cannot delete page media: route is not resolved yet.");return a.delete(`/pages/${n}/media/${encodeURIComponent(t)}`)}async function A(e){await a.delete("/blueprint-upload",{path:e})}export{u as BLUEPRINT_FILES_PAGE_MEDIA_ONLY,P as batchSaveSiteMediaMeta,h as createFolder,A as deleteBlueprintFile,M as deleteFolder,C as deleteObjectMedia,U as deletePageMedia,y as deleteSiteMedia,m as encodeMediaFileUrl,_ as getBlueprintFiles,b as getObjectMedia,v as getPageMedia,w as getPageMediaMeta,g as getSiteMedia,F as getSiteMediaMeta,s as mdDestination,d as mediaAltText,p as mediaMarkdown,R as renameFolder,$ as renameSiteMedia,E as savePageMediaMeta,I as saveSiteMediaMeta,S as setSiteMediaOrder,f as siteMediaStreamPath};
