1import{r as F,m as q,W as L,X as H,Y as z,x as V,Z as N,$ as M,M as U,j as J,u as K,K as v,c as O,a as k,t as j,g as S,v as Q,L as X,y as Y,o as D}from"./entry.Yh3GnwLp.js";const m=/^[\u0009\u0020-\u007E\u0080-\u00FF]+$/;function W(e,r){if(typeof e!="string")throw new TypeError("argument str must be a string");const t={},a=(r||{}).decode||ee;let s=0;for(;s<e.length;){const n=e.indexOf("=",s);if(n===-1)break;let o=e.indexOf(";",s);if(o===-1)o=e.length;else if(o<n){s=e.lastIndexOf(";",n-1)+1;continue}const u=e.slice(s,n).trim();if(t[u]===void 0){let c=e.slice(n+1,o).trim();c.codePointAt(0)===34&&(c=c.slice(1,-1)),t[u]=G(c,a)}s=o+1}return t}function R(e,r,t){const i=t||{},a=i.encode||te;if(typeof a!="function")throw new TypeError("option encode is invalid");if(!m.test(e))throw new TypeError("argument name is invalid");const s=a(r);if(s&&!m.test(s))throw new TypeError("argument val is invalid");let n=e+"="+s;if(i.maxAge!==void 0&&i.maxAge!==null){const o=i.maxAge-0;if(Number.isNaN(o)||!Number.isFinite(o))throw new TypeError("option maxAge is invalid");n+="; Max-Age="+Math.floor(o)}if(i.domain){if(!m.test(i.domain))throw new TypeError("option domain is invalid");n+="; Domain="+i.domain}if(i.path){if(!m.test(i.path))throw new TypeError("option path is invalid");n+="; Path="+i.path}if(i.expires){if(!Z(i.expires)||Number.isNaN(i.expires.valueOf()))throw new TypeError("option expires is invali
1d");n+="; Expires="+i.expires.toUTCString()}if(i.httpOnly&&(n+="; HttpOnly"),i.secure&&(n+="; Secure"),i.priority)switch(typeof i.priority=="string"?i.priority.toLowerCase():i.priority){case"low":n+="; Priority=Low";break;case"medium":n+="; Priority=Medium";break;case"high":n+="; Priority=High";break;default:throw new TypeError("option priority is invalid")}if(i.sameSite)switch(typeof i.sameSite=="string"?i.sameSite.toLowerCase():i.sameSite){case!0:n+="; SameSite=Strict";break;case"lax":n+="; SameSite=Lax";break;case"strict":n+="; SameSite=Strict";break;case"none":n+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return n}function Z(e){return Object.prototype.toString.call(e)==="[object Date]"||e instanceof Date}function G(e,r){try{return r(e)}catch{return e}}function ee(e){return e.includes("%")?decodeURIComponent(e):e}function te(e){return encodeURIComponent(e)}function l(e){if(typeof e!="object")return e;var r,t,i=Object.prototype.toString.call(e);if(i==="[object Object]"){if(e.constructor!==Object&&typeof e.constructor=="function"){t=new e.constructor;for(r in e)e.hasOwnProperty(r)&&t[r]!==e[r]&&(t[r]=l(e[r]))}else{t={};for(r in e)r==="__proto__"?Object.defineProperty(t,r,{value:l(e[r]),configurable:!0,enumerable:!0,writable:!0}):t[r]=l(e[r])}return t}if(i==="[object Array]"){for(r=e.length,t=Array(r);r--;)t[r]=l(e[r]);return t}return i==="[object Set]"?(t=new Set,e.forEach(function(a){t.add(l(a))}),t):i==="[object Map]"?(t=new Map,e.forEach(function(a,s){t.set(l(s),l(a))}),t):i==="[object Date]"?new Date(+e):i==="[object RegExp]"?(t=new RegExp(e.source,e.flags),t.lastIndex=e.lastIndex,t):i==="[object DataView]"?new e.constructor(l(e.buffer)):i==="[object ArrayBuffer]"?e.slice(0):i.slice(-6)==="Array]"?new e.constructor(e):e}const ie={path:"/",watch:!0,decode:e=>H(decodeURIComponent(e)),encode:e=>encodeURIComponent(typeof e=="string"?e:JSON.stringify(e))};function $(e,r){var u;const t={...ie,...r},i=I(t)||{};let a;t.maxAge!==void 0?a=t.maxAge*1e3:t.expires&&(a=t.expires.getTime()-Date.now());const s=a!==void 0&&a<=0,n=l(s?void 0:i[e]??((u=t.default)==null?void 0:u.call(t))),o=a&&!s?ne(n,a):F(n);{const c=typeof BroadcastChannel>"u"?null:new BroadcastChannel(`nuxt:cookies:${e}`),p=()=>{t.readonly||z(o.value,i[e])||(oe(e,o.value,t),i[e]=l(o.value),c==null||c.postMessage(t.encode(o.value)))},g=d=>{var b;const x=d.refresh?(b=I(t))==null?void 0:b[e]:t.decode(d.value);h=!0,i[e]=o.value=x,V(()=>{h=!1})};let h=!1;N()&&M(()=>{h=!0,p(),c==null||c.close()}),c&&(c.onmessage=({data:d})=>g(d)),t.watch?q(o,()=>{h||p()},{deep:t.watch!=="shallow"}):p()}return o}function I(e={}){return W(document.cookie,e)}function re(e,r,t={}){return r==null?R(e,r,{...t,maxAge:-1}):R(e,r,t)}function oe(e,r,t={}){document.cookie=re(e,r,t)}const P=2147483647;function ne(e,r){let t,i=0;return N()&&M(()=>{clearTimeout(t)}),L((a,s)=>{function n(){clearTimeout(t);const o=r-i,u=o<P?o:P;t=setTimeout(()=>{if(i+=u,i<r)return n();e=void 0,s()},u)}return{get(){return a(),e},set(o){n(),e=o,s()}}})}const ae=()=>{const e=U();async function r(i){const a=e.faustSecretKey;if(!a)throw new Error("The apiClientSecret must be specified to use the auth middleware");return await(await fetch(`${e.public.wordpressUrl}/wp-json/faustwp/v1/authorize`,{headers:{"Content-Type":"application/json","x-faustwp-secret":a},method:"POST",body:JSON.stringify({code:i})})).json()}async function t(i){const a=e.faustSecretKey;if(!a)throw new Error("The apiClientSecret must be specified to use the auth middleware");return await(await fetch(`${e.public.wordpressUrl}/wp-json/faustwp/v1/authorize`,{headers:{"Content-Type":"application/json","x-faustwp-secret":a},method:"POST",body:JSON.stringify({refreshToken:i})})).json()}return{getTokensFromCode:r,getTokensFromRefreshToken:t}},se={class:"relative top-[300px]"},ce={class:"text-4xl"},ue={key:0,class:"text-4xl"},le=k("div",{class:"mt-4 text-2xl"},null,-1),de={__name:"index",async setup(e){let r,t;const i=J(),a=U();let{code:s,preview_id:n,post_type:o,slug:u}=i.query,c;
1K({title:"AHC Exhibitions: Preview"});const p=$(`${a.public.frontendSiteUrl}-rt`,{httpOnly:!0,maxAge:3600});if(p.value){console.log("COOKIE FOUND");const f=p.value;c=([r,t]=v(()=>ae().getTokensFromRefreshToken(f)),r=await r,t(),r),p.value=c.refreshToken}const g=$(`${a.public.frontendSiteUrl}-at`,{httpOnly:!0,maxAge:3600});g.value=c.accessToken;const h=B(o),{data:d,pending:x,refresh:b,error:C}=([r,t]=v(()=>X(`${a.public.wordpressUrl}/wp/graphql`,{method:"post",body:JSON.stringify({query:h,variables:{id:n}}),headers:{Authorization:`Bearer ${c.accessToken}`},transform(f){return console.log(f.data),o==="exhibition-matrix"?f.data.exhibitionMatrix:f.data.artifact}},"$cuh4uBgifp")),r=await r,t(),r);C.value&&console.log("ERROR: ",C.value);let T="",E="";const y=d.value.fields;o==="artifact"?(E=y.artifactType==="object"?"artifacts":"articles",y.artifactType==="article"&&(u=y.artifactArticle.slug),T=`/${y.artifactMatrixes[0].slug}/${E}/${u}`):T=`/${u}`,[r,t]=v(()=>Y({path:T,query:{asPreview:!0}})),await r,t();function B(f){let w="";return f==="exhibition-matrix"?w=`query DraftQuery($id: ID!) { 2 exhibitionMatrix(id: $id, idType: DATABASE_ID, asPreview: true) { 3 id 4 title 5 date 6 slug 7 fields { 8 headline: artifactHeadline 9 } 10 } 11 }`:w=`query DraftQuery($id: ID!) { 12 artifact(id: $id, idType: DATABASE_ID, asPreview: true) { 13 id 14 title 15 date 16 slug 17 fields { 18 headline: artifactHeadline 19 artifactType 20 artifactArticle { 21 ... on Post { 22 id 23 slug 24 } 25 } 26 artifactMatrixes { 27 ... on ExhibitionMatrix { 28 slug 29 } 30 } 31 } 32 } 33 }`,w}return(f,w)=>{var _,A;return D(),O("div",null,[k("div",se,[k("h1",ce,"Preview "+j(S(o))+":",1),S(d)?(D(),O("h2",ue,j((A=(_=S(d))==null?void 0:_.fields)==null?void 0:A.headline),1)):Q("",!0),le])])}}};export{de as default};
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.