import{c as a,A as c}from"./CVq-Ik9t.js";function d(e){return e.alt?.trim()||e.title?.trim()||e.filename}function l(e){return`media://${e.path?`${e.path}/${e.filename}`:e.filename}`}function f(e,t=e.filename){return e.type.startsWith("image/")?`![${d(e)}](${t})`:`[${e.filename}](${t})`}function r(e){return e.split("/").map(encodeURIComponent).join("/")}function p(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 m(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 g(e){return a.delete(`/media/${r(e)}`)}async function h(e){return a.post("/media/folders",{path:e})}async function y(e){return a.delete(`/media/folders/${r(e)}`)}async function M(e,t){return a.post("/media/rename",{from:e,to:t})}async function $(e,t){return a.post("/media/folders/rename",{from:e,to:t})}async function R(e,t){return a.post("/media/order",{path:e,order:t})}async function S(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 w(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 E(e){return a.get("/media/meta",{path:e})}async function F(e,t){return a.patch(`/media/meta?path=${encodeURIComponent(e)}`,{fields:t})}async function I(e,t){return a.post("/media/batch/meta",{files:e,fields:t})}const s=Symbol("PAGE_MEDIA_ONLY");async function P(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 s;throw n}}async function _(e){return a.get(`/${e}/media`)}async function b(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 C(e){const t=i(e);return t===null?[]:a.get(`/pages/${t}/media`)}async function v(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 U(e){await a.delete("/blueprint-upload",{path:e})}export{s as BLUEPRINT_FILES_PAGE_MEDIA_ONLY,I as batchSaveSiteMediaMeta,h as createFolder,U as deleteBlueprintFile,y as deleteFolder,b as deleteObjectMedia,v as deletePageMedia,g as deleteSiteMedia,p as encodeMediaFileUrl,P as getBlueprintFiles,_ as getObjectMedia,C as getPageMedia,S as getPageMediaMeta,m as getSiteMedia,E as getSiteMediaMeta,d as mediaAltText,f as mediaMarkdown,$ as renameFolder,M as renameSiteMedia,w as savePageMediaMeta,F as saveSiteMediaMeta,R as setSiteMediaOrder,l as siteMediaStreamPath};
