1import{Z as L,bc as S,az as R,bd as C,be as E,bf as x,bg as D}from"./Bcc8-a-q.js";function b(t,l){return Array.isArray(t)?t.map(r=>b(r,l)):t&&typeof t=="object"?Object.fromEntries(Object.entries(t).map(([r,c])=>[r,b(c,l)])):typeof t!="string"||!t.includes("<")?t:t.replace(/(<a\b[^>]*?\bhref\s*=\s*)(["'])(.*?)\2/gi,(r,c,e,a)=>{let s=a.replace(/&/g,"&");if(/^https?:\/\//i.test(s))try{const n=new URL(s);if(!["xmacna.ai","www.xmacna.ai"].includes(n.hostname))return r;s=n.pathname+n.search+n.hash}catch{return r}if(!s.startsWith("/")||s.startsWith("//"))return r;const i=l(s).replace(/&/g,"&").replace(e==='"'?/"/g:/'/g,e==='"'?""":"'");return c+e+i+e})}function y(t,l,r=[]){const c={...t};for(const e of Object.keys(t)){if(["id","status","slug","permalink","date_created","date_updated","date_published","translations",...r].includes(e)||!(e in l))continue;const a=l[e];if(Array.isArray(t[e])&&Array.isArray(a)){const s=e==="schema"?"name":e==="social_links"?"service":"id";c[e]=t[e].map((i,n)=>{const f=i&&typeof i=="object"&&i[s]?a.find(u=>(u==null?void 0:u[s])===i[s]):a[n];return i&&typeof i=="object"&&f&&typeof f=="object"?y(i,f,e==="schema"?["name","type","validation","required","input","width"]:e==="social_links"?["service","url"]:[]):f??i})}else t[e]&&typeof t[e]=="object"&&a&&typeof a=="object"?c[e]=y(t[e],a):c[e]=a}return c}const O=new Set(["posts","pages","categories","pages_blog","pages_projects","globals","navigation","forms"]),P=new Set(["posts","pages","navigation","forms"]);function U(){const t=L(),l=R(),r=S(String(l.public.directus.rest.baseUrl)).with(C({credentials:"omit"}));return async function(e){var q,j,w,k;const a=e(),s=a.path.split("/")[2];if(!O.has(s))return r.request(e);const i=E(t.path),n=x(t.path),f=(n==null?void 0:n.sourcePath)??(t.path.replace(/^\/(en|es)(?=\/|$)/,"")||"/"),u=f.split("/").at(-1),o={...a.params},p=structuredClone(o.filter||{});(q=p.permalink)!=null&&q._eq&&(p.permalink._eq=f),(j=p.slug)!=null&&j._eq&&u&&(p.slug._eq=u),(k=(w=p.category)==null?void 0:w.slug)!=null&&k._eq&&u&&(p.category.slug._eq=u),o.filter=P.has(s)?{_and:[p,{status:{_eq:"published"}}]}:p,Array.isArray(o.fields)&&!o.fields.includes("*")&&!o.fields.includes("id")&&(o.fields=["id",...o.fields]),s==="pages_blog"&&(o.deep={...o.deep,featured_post:{_filter:{status:{_eq:"published"}}}});const d=await r.request(()=>({...a,params:o}));if(i==="pt-br"||!d)return d;const m=Array.isArray(d)?d:[d];if(!m.length)return d;const z=await r.request(()=>({path:`/items/${s}_translations`,method:"GET",params:{fields:["item_id","languages_code","status","content"],filter:{...m.length<=50?{item_id:{_in:m.map(h=>h.id)}}:{},languages_code:{_eq:i},status:{_eq:"published"}},limit:-1}})),A=m.flatMap(h=>{const _=z.find(g=>g.status==="published"&&g.languages_code===i&&(typeof g.item_id=="string"?g.item_id:g.item_id.id)===h.id);return _!=null&&_.content?[b(y(h,_.content),g=>D(g,i))]:[]});return Array.isArray(d)?A:A[0]??null}}export{U as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.