diff --git a/build/gutenberg/blocks/item-template/view.asset.php b/build/gutenberg/blocks/item-template/view.asset.php index 4ba7cdd1..c60ce881 100644 --- a/build/gutenberg/blocks/item-template/view.asset.php +++ b/build/gutenberg/blocks/item-template/view.asset.php @@ -1 +1 @@ - array('@wordpress/interactivity'), 'version' => 'b6a71a3124d02dbe0a5d', 'type' => 'module'); + array('@wordpress/interactivity'), 'version' => 'c46118e43cbc7dc1b71d', 'type' => 'module'); diff --git a/build/gutenberg/blocks/item-template/view.js b/build/gutenberg/blocks/item-template/view.js index 8dfa1ed9..ec0da18a 100644 --- a/build/gutenberg/blocks/item-template/view.js +++ b/build/gutenberg/blocks/item-template/view.js @@ -1 +1 @@ -import{getElement as e,store as t}from"@wordpress/interactivity";const o="--vp-layout-current-columns";function n(e,t=()=>{}){const n=e.ownerDocument.defaultView||window,r=e.classList.contains("vp-layout-auto-columns");let s=0;const a=()=>{const n=r?function(e){const t=(e.ownerDocument.defaultView||window).getComputedStyle(e),o=e.clientWidth,n=parseFloat(t.columnGap)||0,r=function(e){const t=e.ownerDocument.createElement("div");t.style.cssText="position:absolute;visibility:hidden;pointer-events:none;width:var(--vp-layout-min-column-width,16rem)",e.appendChild(t);const o=t.offsetWidth;return t.remove(),o}(e);if(!o||!r)return 1;const s=parseInt(t.getPropertyValue("--vp-layout-columns"),10),a=Math.floor((o+n)/(r+n));return Math.max(1,s>0?Math.min(a,s):a)}(e):function(e){const t=(e.ownerDocument.defaultView||window).getComputedStyle(e);return Math.max(1,parseInt(t.getPropertyValue(o),10)||1)}(e);n!==s&&(s=n,r&&e.style.setProperty(o,String(n)),t(n))};a();const i=new n.ResizeObserver(a);return i.observe(e),r||i.observe(e.ownerDocument.documentElement),()=>{i.disconnect(),r&&e.style.removeProperty(o)}}const r=".wp-block-visual-portfolio-item-template__item",s=".wp-block-visual-portfolio-item-image";function a(e){const t=e.querySelector("img");return null!=t&&t.naturalWidth&&null!=t&&t.naturalHeight?t.naturalWidth/t.naturalHeight:1}function i(e){const t=e.ownerDocument.createComment("");e.appendChild(t),t.remove()}const l=".wp-block-visual-portfolio-item-template",c=".wp-block-visual-portfolio-item-template__item",u=".vp-block-loop",d=".vp-block-loop-carousel-indicator--dots",p=".vp-block-loop-carousel-dot",h="[data-vp-slide]",f="vp-block-loop-carousel-dot-worm",v=`.${f}`,m="is-collapsed",w="is-edge",y="is-edge-far",g="--vp-carousel-dots-shift",E='[data-vp-carousel-control="autoplay"]',b="vp-carousel-is-scrubbing",L=".vp-block-loop-carousel-thumbnails",S="vp-carousel-control-idle",M="vp-carousel-is-playing",A="vp-carousel-moved-round",x="--vp-carousel-copy-cover",q="--vp-carousel-copy-contain",P="vp-layout-masonry",W="vp-relayout",F="vp-carousel-go-to",I="vp-carousel-autoplay",k="vp-carousel-place",C="vp-carousel-autoplay-take",T="vp-carousel-step",N=()=>{},V=new WeakMap,O=new WeakMap,$=new WeakSet,R=new WeakSet,D=new WeakMap,H=new WeakSet,_=new WeakMap,z=new WeakMap,G=new WeakMap,X="--vp-carousel-seam-shift",Y="vp-carousel-pointer-focus",J=new Set(["Alt","AltGraph","CapsLock","Control","Fn","Meta","NumLock","OS","ScrollLock","Shift","Symbol"]),j="--snap-type";function B(e){return"true"===e.dataset.vpCarouselRepeat}function U(e,t){return!ve(e)&&e.querySelectorAll(c).length>Math.max(1,t)}function K(e){const t=e.querySelectorAll(c),o=t.length>1?Math.abs(t[1].offsetLeft-t[0].offsetLeft):e.scrollWidth-e.clientWidth,n=t.length?t.length*o:0;let r=0;if(t.length){const o=window.getComputedStyle(e),n=window.getComputedStyle(t[0]).scrollSnapAlign.startsWith("center"),s=parseFloat(o.paddingInlineStart)||0;r=n?s+(t[0].offsetWidth-e.clientWidth)/2:s-(parseFloat(o.scrollPaddingInlineStart)||0)}return{count:t.length,step:o,period:n,origin:r}}function Q(e,t){return t>0?(e%t+t)%t:0}function Z(e,t=K(e)){const{count:o,step:n,period:r,origin:s}=t;return o&&n?Math.round(Q(we(e)-s,r)/n)%o:0}function ee(e,t,o=0,n=0){const r=K(e),{count:s,step:a,period:l,origin:c}=r;if(!s||!a)return;const u=(t%s+s)%s,d=we(e),p=c+u*a;let h=p;if(o>0){for(;h-l>d+1;)h-=l;for(;h<=d+1;)h+=l}else if(o<0){for(;h+l=d-1;)h-=l}else h=[p-l,p,p+l].reduce((e,t)=>Math.abs(t-d)oe(e,t,n),l=()=>{te.delete(e),s?e.style.setProperty(j,s):e.style.removeProperty(j),i(e),e.dispatchEvent(new window.CustomEvent("vp-carousel-travel-end"))},c=Math.abs(o-t),u=c>0&&Math.sign(o-t)===Math.sign(r),d=Math.min(700,Math.max(120,3*c/Math.abs(r)));let p=u?d:450;"auto"===me()&&(p=0);const h=window.performance.now();let f=0;const v=e=>{const n=p?Math.min(1,(e-h)/p):1,r=1-n,s=u?1-r*r*r:.5-Math.cos(Math.PI*n)/2;a(t+(o-t)*s),f=n<1?window.requestAnimationFrame(v):window.requestAnimationFrame(()=>{f=window.requestAnimationFrame(l)})};te.set(e,()=>{window.cancelAnimationFrame(f),l()}),e.dispatchEvent(new window.CustomEvent("vp-carousel-travel-start")),a(t),f=window.requestAnimationFrame(v)}(e,d,h,l,n)}const te=new WeakMap;function oe(e,t,o){const n=function(e,t){const o=t-4,n=Q(e,t);return n>=4&&n<=o?n:n+t<=o?n+t:4}(t,o),r=n!==we(e);e.scrollTo({left:ve(e)?-n:n,behavior:"instant"}),r&&e.dispatchEvent(new window.Event("scroll"))}function ne(e){var t;null===(t=te.get(e))||void 0===t||t()}function re(e,t){const{count:o,step:n,origin:r}=K(e),s=r+(o?t%o:0)*n;e.scrollTo({left:ve(e)?-s:s,behavior:"instant"}),ye(e)}function se(e,t,o=me()){e.scrollTo({left:ve(e)?-t:t,behavior:o})}const ae=!(null===(ie=window.CSS)||void 0===ie||null===(le=ie.supports)||void 0===le||!le.call(ie,"display","grid-lanes"));var ie,le;function ce(e){return function(e,t){const o=e.ownerDocument.defaultView||window,a=()=>t(e),i=n(e,a);a(),e.addEventListener("load",a,!0);const l=new o.ResizeObserver(a);return l.observe(e),()=>{i(),e.removeEventListener("load",a,!0),l.disconnect(),e.style.height="",Array.from(e.querySelectorAll(r)).forEach(e=>{!function(e){e.style.position="",e.style.left="",e.style.top="",e.style.width="",e.style.height="";const t=e.querySelector(s);t&&(t.style.height="")}(e),e.dataset.vpLayoutHidden&&(delete e.dataset.vpLayoutHidden,e.style.display="")})}}(e,e=>function(e,t){const{width:o,gap:n,rowGap:i,rowHeight:l}=function(e){const t=(e.ownerDocument.defaultView||window).getComputedStyle(e),o=e.clientWidth,n=e=>e.endsWith("%")?parseFloat(e)/100*o:parseFloat(e),r=n(t.columnGap)||0,s=n(t.rowGap);return{width:o,gap:r,rowGap:Number.isNaN(s)?r:s,columns:Math.max(1,parseInt(t.getPropertyValue("--vp-layout-current-columns"),10)||1),rowHeight:parseFloat(t.getPropertyValue("--vp-layout-row-height"))||320}}(e),c=function(e){const t=e.ownerDocument.defaultView||window;return Array.from(e.querySelectorAll(r)).filter(e=>"true"===e.dataset.vpLayoutHidden||"none"!==t.getComputedStyle(e).display)}(e);if(!c.length||!o)return;const u=c.map(a),d=[];let p=[],h=0;const f=l*(1+Math.max(0,t.rowHeightTolerance||0));c.forEach((e,t)=>{p.push(t),h+=u[t];const r=(o-n*(p.length-1))/h;r<=f&&(d.push({items:p,height:r,isFull:!0}),p=[],h=0)}),p.length&&d.push({items:p,height:l,isFull:!1});const v=t.maxRowsCount?d.slice(0,t.maxRowsCount):d;let m=0;v.forEach(e=>{const r=e.items.reduce((t,o)=>t+u[o]*e.height,0)+n*(e.items.length-1);let a=0;e.isFull||("center"===t.lastRow?a=(o-r)/2:"right"===t.lastRow&&(a=o-r));let l=0;e.items.forEach(t=>{const o=c[t],r=u[t]*e.height,i=o.querySelector(s);o.style.position="absolute",o.style.left=`${a}px`,o.style.top=`${m}px`,o.style.width=`${r}px`,i&&(i.style.height=`${e.height}px`),l=Math.max(l,o.offsetHeight),a+=r+n}),m+=l+i}),d.forEach((e,o)=>{const n=o>=v.length||!e.isFull&&"hide"===t.lastRow;e.items.forEach(e=>{const t=c[e];n?(t.dataset.vpLayoutHidden="true",t.style.display="none"):t.dataset.vpLayoutHidden&&(delete t.dataset.vpLayoutHidden,t.style.display="")})}),e.style.height=`${Math.max(0,m-i)}px`}(e,function(e){const t=e.dataset;return{rowHeight:parseFloat(t.vpJustifiedRowHeight)||320,rowHeightTolerance:parseFloat(t.vpJustifiedTolerance)||0,maxRowsCount:parseInt(t.vpJustifiedMaxRows,10)||0,lastRow:t.vpJustifiedLastRow||"left"}}(e)))}function ue(e){return e.closest(".wp-block-visual-portfolio-item-template__carousel-frame")}function de(e){return e.closest(u)||ue(e)||e}function pe(e){return Array.from(de(e).querySelectorAll("[data-vp-carousel-control]"))}function he(e){const t=Array.from(e.querySelectorAll(c));if(!t.length)return[];const o=ve(e),n=Math.max(0,e.scrollWidth-e.clientWidth),r=window.getComputedStyle(t[0]).scrollSnapAlign.startsWith("center"),s=r?0:parseFloat(window.getComputedStyle(e).scrollPaddingInlineStart)||0;return t.map(t=>{const a=o?e.clientWidth-t.offsetLeft-t.offsetWidth:t.offsetLeft,i=r?(e.clientWidth-t.offsetWidth)/2:s,l=Math.max(0,Math.min(n,a-i));return n-l<2?n:l})}function fe(e,t=he(e)){if(B(e))return Z(e);const o=we(e);let n=0,r=Number.POSITIVE_INFINITY;return t.forEach((e,t)=>{const s=Math.abs(e-o);s=n;if(t.querySelectorAll(".vp-block-loop-carousel-previous").forEach(e=>{e.disabled=s}),t.querySelectorAll(".vp-block-loop-carousel-next").forEach(e=>{e.disabled=a}),e.classList.contains("vp-carousel-edge-fade")){const t=ve(e);be(e,"left",t?a:s),be(e,"right",t?s:a)}!function(e,t=de(e)){const o=ge(e),n=e.querySelectorAll(c).length;t.querySelectorAll(h).forEach(e=>{const t=parseInt(e.dataset.vpSlide,10);e.setAttribute("aria-current",t===o?"true":"false")});const r=Ae(e);t.querySelectorAll(d).forEach(e=>{!function(e,t,o){const n=e.querySelectorAll(p);if(!n.length)return;let r=0;o.forEach((e,o)=>{e<=t&&(r=o)}),n.forEach((e,t)=>{e.setAttribute("aria-current",t===r?"true":"false")});const s=parseInt(e.dataset.vpMaxDots,10)||0,a=s>0&&n.length>s,i=Se(e,n.length,r);if(function(e,t,o){const n=e.querySelector(v);if(!n)return;const r={left:Math.round(t.centreOf(t.index)-t.grown/2),width:t.grown},s=_.get(e);if(s&&s.left===r.left&&s.width===r.width)return;_.set(e,r);const a=(e,t)=>{n.style.insetInlineStart=`${Math.round(e)}px`,n.style.width=`${Math.round(t)}px`};if(!s||"auto"===me())return z.delete(e),void a(r.left,r.width);const i=z.get(e)||{tail:s.left,head:s.left+s.width,frame:0};if(i.tailFrom=i.tail,i.headFrom=i.head,i.tailTo=r.left,i.headTo=r.left+r.width,i.onwards=i.tailTo>=i.tailFrom,i.reach=o,i.started=window.performance.now(),z.set(e,i),i.frame)return;const l=()=>{if(!n.isConnected||z.get(e)!==i)return void(i.frame=0);const t=Math.min(1,(window.performance.now()-i.started)/420),o=(e=>1-(1-e)**3)(Math.min(1,t/.55)),r=(e=>e*e*(3-2*e))(Math.max(0,(t-.32)/.6799999999999999)),s=i.onwards?o:r,c=i.onwards?r:o;i.head=i.headFrom+(i.headTo-i.headFrom)*s,i.tail=i.tailFrom+(i.tailTo-i.tailFrom)*c,i.head-i.tail>i.reach&&(i.onwards?i.tail=i.head-i.reach:i.head=i.tail+i.reach),a(i.tail,Math.max(1,i.head-i.tail)),i.frame=t<1?window.requestAnimationFrame(l):0};i.frame=window.requestAnimationFrame(l)}(e,i,a?3*i.slot:Number.POSITIVE_INFINITY),!a)return e.classList.remove(m),e.style.removeProperty(g),n.forEach(e=>{e.classList.remove(w,y)}),void D.delete(e);e.classList.add(m);const l=e.querySelector(`${p}:focus-visible`),c=l?Array.prototype.indexOf.call(n,l):r;H.has(e)||(H.add(e),e.addEventListener("focusin",t=>{const o=t.target.closest(p);if(null==o||!o.matches(":focus-visible"))return;const n=e.querySelectorAll(p),r=Math.max(0,Array.prototype.findIndex.call(n,e=>"true"===e.getAttribute("aria-current")));xe(e,Se(e,n.length,r),Array.prototype.indexOf.call(n,o))})),xe(e,i,c)}(e,o,r)}),t.querySelectorAll(L).forEach(e=>{!function(e,t){if(D.get(e)===t)return;D.set(e,t);const o=e.querySelectorAll(".vp-block-loop-carousel-thumb")[t];if(!o||e.scrollWidth<=e.clientWidth)return;const n=o.offsetLeft+o.offsetWidth/2,r=e.scrollWidth-e.clientWidth,s=n-e.clientWidth/2,a=ve(e)?Math.max(-r,Math.min(0,s)):Math.max(0,Math.min(r,s));e.scrollTo({left:a,behavior:me()})}(e,o)}),t.querySelectorAll(".vp-block-loop-carousel-indicator--counter").forEach(e=>{Ee(e,".vp-block-loop-carousel-counter-current",o+1),Ee(e,".vp-block-loop-carousel-counter-total",n)});const s=function(e){if(B(e)){const t=e.querySelectorAll(c).length;return t>1?ge(e)/(t-1):1}const t=e.scrollWidth-e.clientWidth;return t>0?Math.min(1,Math.max(0,we(e)/t)):1}(e);t.querySelectorAll(".vp-block-loop-carousel-indicator--progress").forEach(e=>{e.style.setProperty("--vp-carousel-progress",100*s+"%"),e.setAttribute("aria-valuenow",String(Math.round(100*s)));const t=e.dataset.vpPositionLabel;t&&e.setAttribute("aria-valuetext",t.replace("%1$d",String(o+1)).replace("%2$d",String(n)))})}(e,t)}function ge(e){const t=O.get(e);return t&&window.performance.now()-t.time<1200?t.index:fe(e)}function Ee(e,t,o){const n=e.querySelector(t),r=String(o);n&&n.textContent!==r&&(n.textContent=r)}function be(e,t,o){const n=`--vp-carousel-fade-${t}`;o!==("0px"===e.style.getPropertyValue(n))&&(o?e.style.setProperty(n,"0px"):e.style.removeProperty(n))}function Le(e){const t=Ae(e);de(e).querySelectorAll(d).forEach(e=>{!function(e,t){const o=e.querySelectorAll(p),n=e.dataset.vpDotLabel||"",r=t.length;for(let e=o.length-1;e>=r;e-=1)o[e].remove();for(let t=o.length;t{const r=t[o];e.dataset.vpSlide=String(r),e.setAttribute("aria-label",n.replace("%d",String(r+1)))}),r&&!e.querySelector(v)){const t=document.createElement("span");t.className=f,t.setAttribute("aria-hidden","true"),t.innerHTML='',e.prepend(t)}}(e,t)})}function Se(e,t,o){const n=window.getComputedStyle(e),r=parseFloat(n.getPropertyValue("--vp-carousel-dot-slot"))||18,s=parseFloat(n.getPropertyValue("--vp-carousel-dot-size"))||6,a=parseFloat(n.getPropertyValue("--vp-carousel-dot-active-size"))||r,i=Math.max(0,(a-s)/2),l=parseFloat(n.paddingInlineStart)||0,c=Math.min(Math.max(o,0),Math.max(0,t-1));return{slot:r,grown:a,index:c,centreOf:e=>l+e*r+r/2+(e=>e===c?0:e{const i=0===t%n||!r&&t===s;e.classList.toggle("vp-carousel-no-snap",n>1&&!i);const l=a[a.length-1];i&&(r||1===n||void 0===l||o[t]!==o[l])&&a.push(t)}),G.set(e,a)}function Ae(e){return G.get(e)||Array.from(e.querySelectorAll(c),(e,t)=>t)}function xe(e,t,o){const n=e.querySelectorAll(p),r=e.clientWidth;if(!r||D.get(e)===o)return;D.set(e,o);const{centreOf:s,content:a}=t,i=Math.round(Math.min(0,Math.max(r-a,r/2-s(o))));e.style.setProperty(g,`${i}px`);const l=[i<0,i>r-a],c=[];n.forEach((e,t)=>{const o=s(t)+i;o>=0&&o<=r&&c.push(t)}),n.forEach((e,t)=>{const n=c.indexOf(t),r=t===o||n<0?n<0?-1:Number.POSITIVE_INFINITY:Math.min(l[0]?n:Number.POSITIVE_INFINITY,l[1]?c.length-1-n:Number.POSITIVE_INFINITY);e.classList.toggle(w,1===r),e.classList.toggle(y,r<=0)})}function qe(e,t,o){let n=t+o;for(;n>=0&&n=1)return n;if(!Number.isInteger(n))return 1;const r=e.clientWidth;if(B(e)){const{step:t}=K(e);return t>0?Math.max(1,Math.round(r/t)):1}const s=t[Math.max(0,Math.min(t.length-1,o))];for(let e=o+1;e=r)return e-o;return Math.max(1,t.length-1-o)}function We(e,t,o){if(!e.length)return t;let n=t,r=Number.POSITIVE_INFINITY;return e.forEach(e=>{[e-o,e,e+o].forEach(e=>{const o=Math.abs(e-t);o0?null!==(r=e.find(e=>e>t))&&void 0!==r?r:e[0]:null!==(n=[...e].reverse().find(e=>e0&&t>=e.length-1||o<0&&t<=0)return r;const s=Math.max(0,Math.min(e.length-1,r));return e[s]===e[t]?qe(e,t,o):s}(r,s,t,a),r)}function Ie(e,t,o=he(e)){if(B(e))return void ee(e,t);const n=Math.max(0,Math.min(o.length-1,t));o.length&&n===t&&(O.set(e,{index:n,time:window.performance.now()}),se(e,o[n]))}function ke(e,t=de(e)){const o=!$.has(e);t.classList.toggle("vp-carousel-is-stopped",!o),t.querySelectorAll(E).forEach(e=>{const t=o?e.dataset.vpPauseLabel:e.dataset.vpPlayLabel;t&&e.setAttribute("aria-label",t)})}function Ce(e,t){const o=()=>ye(e),r=t=>{var o;return Ie(e,null===(o=t.detail)||void 0===o?void 0:o.index)},s=t=>{var o;const{period:n}=K(e);B(e)&&n&&Number.isFinite(null===(o=t.detail)||void 0===o?void 0:o.position)&&(oe(e,t.detail.position,n),t.detail.position=we(e))};let a;B(e)&&R.add(e);let l=0;const u=n(e,t=>{l=t,void 0!==a&&R.has(e)&&U(e,t)!==a?e.dispatchEvent(new window.Event(W)):(Me(e),Le(e),ye(e),V.has(e)&&i(e))});a=R.has(e)&&U(e,l),a?e.dataset.vpCarouselRepeat="true":delete e.dataset.vpCarouselRepeat;const d=!!parseFloat(e.dataset.vpCarouselAutoplay)&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches,p=function(e,t){const o=pe(e).filter(e=>t||!e.matches(E));return o.forEach(e=>{e.classList.remove(S)}),()=>{o.forEach(e=>{e.classList.add(S)})}}(e,d);Me(e),Le(e),ye(e),e.addEventListener("scroll",o,{passive:!0}),e.addEventListener(F,r),e.addEventListener(k,s);const h=function(e,t){const o=new window.MutationObserver(e=>{const o=e.flatMap(e=>Array.from(e.addedNodes)).filter(e=>{var t;return 1===e.nodeType&&(null===(t=e.matches)||void 0===t?void 0:t.call(e,c))});o.length&&t()});return o.observe(e,{childList:!0}),()=>o.disconnect()}(e,()=>{Me(e),Le(e),ye(e)}),f=a?function(e){const t=e.ownerDocument.defaultView||window,o=()=>{const t=parseFloat(e.style.getPropertyValue(X))||0,{count:o,step:n,period:r,origin:s}=K(e);if(!o||!n)return;const a=((s-t)%n+n)%n,l=a<5||a>n-5?10:0;l!==t&&(l?e.style.setProperty(X,`${l}px`):e.style.removeProperty(X),r&&oe(e,we(e)+(l-t),r),V.has(e)&&i(e))};o();const n=new t.ResizeObserver(o);return n.observe(e),()=>{n.disconnect(),e.style.removeProperty(X)}}(e):N;a&&re(e,null!=t?t:0);const v=window.matchMedia("(hover: hover) and (pointer: fine)").matches,m=e.dataset.vpCarouselSrc,w=t=>{0===t.button&&(t.preventDefault(),e.classList.add(Y),e.focus({preventScroll:!0}))},y=()=>e.classList.remove(Y),g=e=>{J.has(e.key)||y()};v&&(e.addEventListener("mousedown",w),e.addEventListener("keydown",g),e.addEventListener("blur",y));const P=a?function(e){let t=[],o=0;const n=e=>{o+=Math.abs(e.clientX-t[t.length-1].x),t.push({x:e.clientX,time:e.timeStamp})},r=()=>{window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",s),window.removeEventListener("pointercancel",s)};function s(n){if(r(),o<=10||"true"!==e.getAttribute("has-overflow"))return;const{count:s,step:a,origin:i}=K(e);if(!s||!a)return;const l=n.clientX,c=n.timeStamp,u=t.find(e=>c-e.time<=80)||t[t.length-1],d=Math.max(1,c-u.time),p=(l-u.x)/d*(ve(e)?1:-1),h=we(e)+290*p;ee(e,We(Ae(e),Math.round((h-i)/a),s),0,p)}const a=r=>{ne(e),t=[{x:r.clientX,time:r.timeStamp}],o=0,window.addEventListener("pointermove",n),window.addEventListener("pointerup",s),window.addEventListener("pointercancel",s)};return e.addEventListener("pointerdown",a),()=>{e.removeEventListener("pointerdown",a),r()}}(e):N,D=a?function(e){const t=Object.getOwnPropertyDescriptor(Element.prototype,"scrollWidth");return null!=t&&t.get?(Object.defineProperty(e,"scrollWidth",{configurable:!0,get(){const o=e.querySelectorAll(c);return o.length<2?t.get.call(e):e.clientWidth+o.length*Math.abs(o[1].offsetLeft-o[0].offsetLeft)}}),()=>{delete e.scrollWidth}):N}(e):N;let H=!1;(v||a)&&m&&import(m).then(({Blossom:o})=>{if(H||!e.isConnected||V.has(e))return;const n=o(e,{repeat:a});V.set(e,n),n.init(),a&&(i(e),re(e,null!=t?t:0),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{V.has(e)&&i(e)})}))}).catch(()=>{});const _=function(e){const t=1e3*parseFloat(e.dataset.vpCarouselAutoplay);if(!t||window.matchMedia("(prefers-reduced-motion: reduce)").matches)return N;const o=de(e),n=[ue(e)||e,...pe(e)];let r=0,s=0,a=0;const i=new Set,l=new Set;let c=!1,u=!0,d=-1,p=!1;const h=e=>{o.style.setProperty("--vp-carousel-autoplay-progress",100*e+"%")},f=()=>{r=0,h(0)},v=o=>{a=window.requestAnimationFrame(v);const n=o-s;if(s=o,[i,l].forEach(e=>{e.forEach(t=>{t.isConnected||e.delete(t)})}),p)return void e.dispatchEvent(new window.CustomEvent("vp-carousel-autoplay-frame",{detail:{elapsed:n,held:!!(l.size||c||u||$.has(e)),pointer:i.size>0,keyboard:l.size>0}}));if(i.size||l.size||c||u||$.has(e))return;const m=ge(e);m!==d&&(d=m,f()),r+=n,h(Math.min(1,r/t)),r=e.scrollWidth-e.clientWidth-1?e.scrollTo({left:0,behavior:me()}):Fe(e,1))},m=e=>i.add(e.currentTarget),w=e=>i.delete(e.currentTarget),y=e=>{var t,o;null!==(t=(o=e.target).matches)&&void 0!==t&&t.call(o,":focus-visible")&&!e.target.classList.contains(Y)&&l.add(e.currentTarget)},g=e=>l.delete(e.currentTarget),E=e=>{var t,o;"visitor"!==(null===(t=e.detail)||void 0===t?void 0:t.source)&&(c=!1===(null===(o=e.detail)||void 0===o?void 0:o.playing))},b=ue(e)||e,L=new(b.ownerDocument.defaultView||window).IntersectionObserver(e=>{e.forEach(e=>{u=!e.isIntersecting})},{threshold:.5});L.observe(b),o.classList.add(M),n.forEach(e=>{e.addEventListener("pointerenter",m),e.addEventListener("pointerleave",w),e.addEventListener("focusin",y),e.addEventListener("focusout",g)}),e.addEventListener(I,E);const S=()=>{p=!0,h(0)};return e.addEventListener(T,f),e.addEventListener(C,S),ke(e,o),a=window.requestAnimationFrame(e=>{s=e,v(e)}),()=>{window.cancelAnimationFrame(a),L.disconnect(),o.classList.remove(M),n.forEach(e=>{e.removeEventListener("pointerenter",m),e.removeEventListener("pointerleave",w),e.removeEventListener("focusin",y),e.removeEventListener("focusout",g)}),e.removeEventListener(I,E),e.removeEventListener(T,f),e.removeEventListener(C,S),o.style.removeProperty("--vp-carousel-autoplay-progress")}}(e),z=function(e){const t=de(e),o=Array.from(t.querySelectorAll(".vp-block-loop-carousel-indicator--progress.is-draggable"));if(!o.length)return N;let n=null,r=null,s=0,a=!1;const i=()=>{n?e.style.setProperty(j,n):e.style.removeProperty(j),n=null,e.classList.remove(b)},l=(t,o)=>{const n=t.getBoundingClientRect(),r=ve(e)?n.right-o:o-n.left;return n.width>0?Math.min(1,Math.max(0,r/n.width)):0},u=(t,o)=>We(Ae(e),Math.round(t*Math.max(0,o-1)),o),d=t=>{if(r){if(!a){if(Math.abs(t.clientX-s)<3)return;a=!0,n=e.style.getPropertyValue(j),e.style.setProperty(j,"none"),e.classList.add(b),O.delete(e)}(t=>{if(B(e)){const{count:o,step:n,origin:r,period:s}=K(e);return void oe(e,r+t*Math.max(0,o-1)*n,s)}se(e,t*(e.scrollWidth-e.clientWidth),"instant")})(l(r,t.clientX))}},p=t=>{if(!r)return;const o=l(r,t.clientX),n=a;r=null,a=!1,window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),n?(t=>{if(i(),!B(e))return;const o=e.querySelectorAll(c).length;ee(e,u(t,o),0)})(o):(t=>{const o=e.querySelectorAll(c).length;e.dispatchEvent(new window.CustomEvent(T)),B(e)?ee(e,u(t,o),0):se(e,t*(e.scrollWidth-e.clientWidth))})(o)},h=t=>{ne(e),r=t.currentTarget,s=t.clientX,a=!1,window.addEventListener("pointermove",d),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p)},f=t=>{const o=ve(e),n=e.querySelectorAll(c).length,r=o?"ArrowRight":"ArrowLeft",s=o?"ArrowLeft":"ArrowRight";switch(t.key){case r:case"ArrowDown":case"PageDown":Fe(e,-1);break;case s:case"ArrowUp":case"PageUp":Fe(e,1);break;case"Home":Ie(e,0);break;case"End":Ie(e,n-1);break;default:return}t.preventDefault()};return o.forEach(e=>{e.addEventListener("pointerdown",h),e.addEventListener("keydown",f)}),()=>{o.forEach(e=>{e.removeEventListener("pointerdown",h),e.removeEventListener("keydown",f)}),window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),i()}}(e),G=function(e,t){const o=Array.from(de(e).querySelectorAll(L)),n=e.dataset.vpCarouselSrc;if(!o.length||!n||!t)return N;const r=[];let s=!1;return import(n).then(({Blossom:e})=>{s||o.forEach(t=>{if(!t.isConnected||V.has(t))return;const o=e(t,{repeat:!1});V.set(t,o),o.init(),r.push(t)})}).catch(()=>{}),()=>{s=!0,r.forEach(e=>{var t;null===(t=V.get(e))||void 0===t||t.destroy(),V.delete(e)})}}(e,v),Q=a?function(e){const t=t=>{const o=parseFloat(t.style.translate)||0;if(t.classList.toggle(A,!!o),!o)return t.style.removeProperty(x),void t.style.removeProperty(q);const n=parseFloat(window.getComputedStyle(t).viewTimelineInset)||0,r=t.offsetLeft+o,s=r+t.offsetWidth,a=e.clientWidth;t.style.setProperty(x,`${r-a+n}px ${s-n}px`),t.style.setProperty(q,`${s-a+n}px ${r-n}px`)},o=new window.MutationObserver(e=>{e.forEach(e=>{t(e.target)})});return e.querySelectorAll(c).forEach(t),o.observe(e,{attributes:!0,attributeFilter:["style"],subtree:!0}),()=>{o.disconnect(),e.querySelectorAll(c).forEach(e=>{e.classList.remove(A),e.style.removeProperty(x),e.style.removeProperty(q)})}}(e):N;return e.dispatchEvent(new window.CustomEvent("vp-carousel-start",{bubbles:!0})),()=>{H=!0,e.dispatchEvent(new window.CustomEvent("vp-carousel-stop",{bubbles:!0})),Q(),_(),z(),G(),u(),p(),e.removeEventListener("scroll",o),e.removeEventListener(F,r),e.removeEventListener(k,s),e.removeEventListener("mousedown",w),e.removeEventListener("keydown",g),e.removeEventListener("blur",y),y(),f(),P(),ne(e),D(),h();const t=V.get(e);t&&(V.delete(e),t.destroy(),e.querySelectorAll(c).forEach(e=>{e.style.removeProperty("translate")}))}}function Te(e){var t;return(null===(t=e.closest(u))||void 0===t?void 0:t.querySelector(l))||null}function Ne(e,t){return"justified"===e.dataset.vpLayout?ce(e):"carousel"===e.dataset.vpLayout?Ce(e,t):void 0}ae&&"undefined"!=typeof document&&document.querySelectorAll(`${l}.${P}`).forEach(e=>{e.classList.remove(P),e.classList.add("vp-layout-masonry-native")}),t("visual-portfolio/item-template",{state:{hasScript:!0,useJsMasonry:!ae,useNativeMasonry:ae},actions:{carouselPrev(){const t=Te(e().ref);t&&Fe(t,-1)},carouselNext(){const t=Te(e().ref);t&&Fe(t,1)},carouselAutoplayToggle(){const{ref:t}=e(),o=Te(t);if(!o)return;const n=$.has(o);n?$.delete(o):$.add(o),ke(o),o.dispatchEvent(new window.CustomEvent(I,{detail:{playing:n,source:"visitor"}}))},carouselGoTo(t){const{ref:o}=e(),n=t.target.closest(h),r=Te(o),s=n?parseInt(n.dataset.vpSlide,10):-1;!r||s<0||(r.dispatchEvent(new window.CustomEvent(T)),Ie(r,s))}},callbacks:{initLayout(){const{ref:t}=e();let o=Ne(t);if(!o)return;const n=()=>{const e="carousel"===t.dataset.vpLayout?fe(t):void 0;o(),o=Ne(t,e)||N};return t.addEventListener(W,n),()=>{t.removeEventListener(W,n),o()}}}}); \ No newline at end of file +import{getElement as e,store as t}from"@wordpress/interactivity";const o="--vp-layout-current-columns";function n(e,t=()=>{}){const n=e.ownerDocument.defaultView||window,r=e.classList.contains("vp-layout-auto-columns");let s=0;const a=()=>{const n=r?function(e){const t=(e.ownerDocument.defaultView||window).getComputedStyle(e),o=e.clientWidth,n=parseFloat(t.columnGap)||0,r=function(e){const t=e.ownerDocument.createElement("div");t.style.cssText="position:absolute;visibility:hidden;pointer-events:none;width:var(--vp-layout-min-column-width,16rem)",e.appendChild(t);const o=t.offsetWidth;return t.remove(),o}(e);if(!o||!r)return 1;const s=parseInt(t.getPropertyValue("--vp-layout-columns"),10),a=Math.floor((o+n)/(r+n));return Math.max(1,s>0?Math.min(a,s):a)}(e):function(e){const t=(e.ownerDocument.defaultView||window).getComputedStyle(e);return Math.max(1,parseInt(t.getPropertyValue(o),10)||1)}(e);n!==s&&(s=n,r&&e.style.setProperty(o,String(n)),t(n))};a();const i=new n.ResizeObserver(a);return i.observe(e),r||i.observe(e.ownerDocument.documentElement),()=>{i.disconnect(),r&&e.style.removeProperty(o)}}const r=".wp-block-visual-portfolio-item-template__item",s=".wp-block-visual-portfolio-item-image";function a(e){const t=e.querySelector("img");return null!=t&&t.naturalWidth&&null!=t&&t.naturalHeight?t.naturalWidth/t.naturalHeight:1}function i(e){const t=e.ownerDocument.createComment("");e.appendChild(t),t.remove()}const l=".wp-block-visual-portfolio-item-template",c=".wp-block-visual-portfolio-item-template__item",u=".vp-block-loop",d=".vp-block-loop-carousel-indicator--dots",p=".vp-block-loop-carousel-dot",h="[data-vp-slide]",f="vp-block-loop-carousel-dot-worm",v=`.${f}`,m="is-collapsed",w="is-edge",y="is-edge-far",g="--vp-carousel-dots-shift",E='[data-vp-carousel-control="autoplay"]',b="vp-carousel-is-scrubbing",L=".vp-block-loop-carousel-thumbnails",S="vp-carousel-control-idle",M="vp-carousel-is-playing",A="vp-carousel-moved-round",x="--vp-carousel-copy-cover",P="--vp-carousel-copy-contain",q="vp-layout-masonry",W="vp-relayout",F="vp-carousel-go-to",I="vp-carousel-autoplay",k="vp-carousel-place",C="vp-carousel-autoplay-take",T="vp-carousel-step",N=()=>{},V=new WeakMap,O=new WeakMap,R=new WeakSet,$=new WeakSet,D=new WeakMap,H=new WeakSet,_=new WeakMap,z=new WeakMap,G=new WeakMap,X="--vp-carousel-seam-shift",Y="vp-carousel-pointer-focus",J=new Set(["Alt","AltGraph","CapsLock","Control","Fn","Meta","NumLock","OS","ScrollLock","Shift","Symbol"]),j="--snap-type";function B(e){return"true"===e.dataset.vpCarouselRepeat}function K(e,t){return!ve(e)&&e.querySelectorAll(c).length>Math.max(1,t)}function U(e){const t=e.querySelectorAll(c),o=t.length>1?Math.abs(t[1].offsetLeft-t[0].offsetLeft):e.scrollWidth-e.clientWidth,n=t.length?t.length*o:0;let r=0;if(t.length){const o=window.getComputedStyle(e),n=window.getComputedStyle(t[0]).scrollSnapAlign.startsWith("center"),s=parseFloat(o.paddingInlineStart)||0;r=n?s+(t[0].offsetWidth-e.clientWidth)/2:s-(parseFloat(o.scrollPaddingInlineStart)||0)}return{count:t.length,step:o,period:n,origin:r}}function Q(e,t){return t>0?(e%t+t)%t:0}function Z(e,t=U(e)){const{count:o,step:n,period:r,origin:s}=t;return o&&n?Math.round(Q(we(e)-s,r)/n)%o:0}function ee(e,t,o=0,n=0){const r=U(e),{count:s,step:a,period:l,origin:c}=r;if(!s||!a)return;const u=(t%s+s)%s,d=we(e),p=c+u*a;let h=p;if(o>0){for(;h-l>d+1;)h-=l;for(;h<=d+1;)h+=l}else if(o<0){for(;h+l=d-1;)h-=l}else h=[p-l,p,p+l].reduce((e,t)=>Math.abs(t-d)oe(e,t,n),l=()=>{te.delete(e),s?e.style.setProperty(j,s):e.style.removeProperty(j),i(e),e.dispatchEvent(new window.CustomEvent("vp-carousel-travel-end"))},c=Math.abs(o-t),u=c>0&&Math.sign(o-t)===Math.sign(r),d=Math.min(700,Math.max(120,3*c/Math.abs(r)));let p=u?d:450;"auto"===me()&&(p=0);const h=window.performance.now();let f=0;const v=e=>{const n=p?Math.min(1,(e-h)/p):1,r=1-n,s=u?1-r*r*r:.5-Math.cos(Math.PI*n)/2;a(t+(o-t)*s),f=n<1?window.requestAnimationFrame(v):window.requestAnimationFrame(()=>{f=window.requestAnimationFrame(l)})};te.set(e,()=>{window.cancelAnimationFrame(f),l()}),e.dispatchEvent(new window.CustomEvent("vp-carousel-travel-start")),a(t),f=window.requestAnimationFrame(v)}(e,d,h,l,n)}const te=new WeakMap;function oe(e,t,o){const n=function(e,t){const o=t-4,n=Q(e,t);return n>=4&&n<=o?n:n+t<=o?n+t:4}(t,o),r=n!==we(e);e.scrollTo({left:ve(e)?-n:n,behavior:"instant"}),r&&e.dispatchEvent(new window.Event("scroll"))}function ne(e){var t;null===(t=te.get(e))||void 0===t||t()}function re(e,t){const{count:o,step:n,origin:r}=U(e),s=r+(o?t%o:0)*n;e.scrollTo({left:ve(e)?-s:s,behavior:"instant"}),ye(e)}function se(e,t,o=me()){e.scrollTo({left:ve(e)?-t:t,behavior:o})}const ae=!(null===(ie=window.CSS)||void 0===ie||null===(le=ie.supports)||void 0===le||!le.call(ie,"display","grid-lanes"));var ie,le;function ce(e){return function(e,t){const o=e.ownerDocument.defaultView||window,a=()=>t(e),i=n(e,a);a(),e.addEventListener("load",a,!0);const l=new o.ResizeObserver(a);return l.observe(e),()=>{i(),e.removeEventListener("load",a,!0),l.disconnect(),e.style.height="",Array.from(e.querySelectorAll(r)).forEach(e=>{!function(e){e.style.position="",e.style.left="",e.style.top="",e.style.width="",e.style.height="";const t=e.querySelector(s);t&&(t.style.height="")}(e),e.dataset.vpLayoutHidden&&(delete e.dataset.vpLayoutHidden,e.style.display="")})}}(e,e=>function(e,t){const{width:o,gap:n,rowGap:i,rowHeight:l}=function(e){const t=(e.ownerDocument.defaultView||window).getComputedStyle(e),o=e.clientWidth,n=e=>e.endsWith("%")?parseFloat(e)/100*o:parseFloat(e),r=n(t.columnGap)||0,s=n(t.rowGap);return{width:o,gap:r,rowGap:Number.isNaN(s)?r:s,columns:Math.max(1,parseInt(t.getPropertyValue("--vp-layout-current-columns"),10)||1),rowHeight:parseFloat(t.getPropertyValue("--vp-layout-row-height"))||320}}(e),c=function(e){const t=e.ownerDocument.defaultView||window;return Array.from(e.querySelectorAll(r)).filter(e=>"true"===e.dataset.vpLayoutHidden||"none"!==t.getComputedStyle(e).display)}(e);if(!c.length||!o)return;const u=c.map(a),d=[];let p=[],h=0;const f=l*(1+Math.max(0,t.rowHeightTolerance||0));c.forEach((e,t)=>{p.push(t),h+=u[t];const r=(o-n*(p.length-1))/h;r<=f&&(d.push({items:p,height:r,isFull:!0}),p=[],h=0)}),p.length&&d.push({items:p,height:l,isFull:!1});const v=t.maxRowsCount?d.slice(0,t.maxRowsCount):d;let m=0;v.forEach(e=>{const r=e.items.reduce((t,o)=>t+u[o]*e.height,0)+n*(e.items.length-1);let a=0;e.isFull||("center"===t.lastRow?a=(o-r)/2:"right"===t.lastRow&&(a=o-r));let l=0;e.items.forEach(t=>{const o=c[t],r=u[t]*e.height,i=o.querySelector(s);o.style.position="absolute",o.style.left=`${a}px`,o.style.top=`${m}px`,o.style.width=`${r}px`,i&&(i.style.height=`${e.height}px`),l=Math.max(l,o.offsetHeight),a+=r+n}),m+=l+i}),d.forEach((e,o)=>{const n=o>=v.length||!e.isFull&&"hide"===t.lastRow;e.items.forEach(e=>{const t=c[e];n?(t.dataset.vpLayoutHidden="true",t.style.display="none"):t.dataset.vpLayoutHidden&&(delete t.dataset.vpLayoutHidden,t.style.display="")})}),e.style.height=`${Math.max(0,m-i)}px`}(e,function(e){const t=e.dataset;return{rowHeight:parseFloat(t.vpJustifiedRowHeight)||320,rowHeightTolerance:parseFloat(t.vpJustifiedTolerance)||0,maxRowsCount:parseInt(t.vpJustifiedMaxRows,10)||0,lastRow:t.vpJustifiedLastRow||"left"}}(e)))}function ue(e){return e.closest(".wp-block-visual-portfolio-item-template__carousel-frame")}function de(e){return e.closest(u)||ue(e)||e}function pe(e){return Array.from(de(e).querySelectorAll("[data-vp-carousel-control]"))}function he(e){const t=Array.from(e.querySelectorAll(c));if(!t.length)return[];const o=ve(e),n=Math.max(0,e.scrollWidth-e.clientWidth),r=window.getComputedStyle(t[0]).scrollSnapAlign.startsWith("center"),s=r?0:parseFloat(window.getComputedStyle(e).scrollPaddingInlineStart)||0;return t.map(t=>{const a=o?e.clientWidth-t.offsetLeft-t.offsetWidth:t.offsetLeft,i=r?(e.clientWidth-t.offsetWidth)/2:s,l=Math.max(0,Math.min(n,a-i));return n-l<2?n:l})}function fe(e,t=he(e)){if(B(e))return Z(e);const o=we(e);let n=0,r=Number.POSITIVE_INFINITY;return t.forEach((e,t)=>{const s=Math.abs(e-o);s=n;if(t.querySelectorAll(".vp-block-loop-carousel-previous").forEach(e=>{e.disabled=s}),t.querySelectorAll(".vp-block-loop-carousel-next").forEach(e=>{e.disabled=a}),e.classList.contains("vp-carousel-edge-fade")){const t=ve(e);be(e,"left",t?a:s),be(e,"right",t?s:a)}!function(e,t=de(e)){const o=ge(e),n=e.querySelectorAll(c).length;t.querySelectorAll(h).forEach(e=>{const t=parseInt(e.dataset.vpSlide,10);e.setAttribute("aria-current",t===o?"true":"false")});const r=Ae(e);t.querySelectorAll(d).forEach(e=>{!function(e,t,o){const n=e.querySelectorAll(p);if(!n.length)return;let r=0;o.forEach((e,o)=>{e<=t&&(r=o)}),n.forEach((e,t)=>{e.setAttribute("aria-current",t===r?"true":"false")});const s=parseInt(e.dataset.vpMaxDots,10)||0,a=s>0&&n.length>s,i=Se(e,n.length,r);if(function(e,t,o){const n=e.querySelector(v);if(!n)return;const r={left:Math.round(t.centreOf(t.index)-t.grown/2),width:t.grown},s=_.get(e);if(s&&s.left===r.left&&s.width===r.width)return;_.set(e,r);const a=(e,t)=>{n.style.insetInlineStart=`${Math.round(e)}px`,n.style.width=`${Math.round(t)}px`};if(!s||"auto"===me())return z.delete(e),void a(r.left,r.width);const i=z.get(e)||{tail:s.left,head:s.left+s.width,frame:0};if(i.tailFrom=i.tail,i.headFrom=i.head,i.tailTo=r.left,i.headTo=r.left+r.width,i.onwards=i.tailTo>=i.tailFrom,i.reach=o,i.started=window.performance.now(),z.set(e,i),i.frame)return;const l=()=>{if(!n.isConnected||z.get(e)!==i)return void(i.frame=0);const t=Math.min(1,(window.performance.now()-i.started)/420),o=(e=>1-(1-e)**3)(Math.min(1,t/.55)),r=(e=>e*e*(3-2*e))(Math.max(0,(t-.32)/.6799999999999999)),s=i.onwards?o:r,c=i.onwards?r:o;i.head=i.headFrom+(i.headTo-i.headFrom)*s,i.tail=i.tailFrom+(i.tailTo-i.tailFrom)*c,i.head-i.tail>i.reach&&(i.onwards?i.tail=i.head-i.reach:i.head=i.tail+i.reach),a(i.tail,Math.max(1,i.head-i.tail)),i.frame=t<1?window.requestAnimationFrame(l):0};i.frame=window.requestAnimationFrame(l)}(e,i,a?3*i.slot:Number.POSITIVE_INFINITY),!a)return e.classList.remove(m),e.style.removeProperty(g),n.forEach(e=>{e.classList.remove(w,y)}),void D.delete(e);e.classList.add(m);const l=e.querySelector(`${p}:focus-visible`),c=l?Array.prototype.indexOf.call(n,l):r;H.has(e)||(H.add(e),e.addEventListener("focusin",t=>{const o=t.target.closest(p);if(null==o||!o.matches(":focus-visible"))return;const n=e.querySelectorAll(p),r=Math.max(0,Array.prototype.findIndex.call(n,e=>"true"===e.getAttribute("aria-current")));xe(e,Se(e,n.length,r),Array.prototype.indexOf.call(n,o))})),xe(e,i,c)}(e,o,r)}),t.querySelectorAll(L).forEach(e=>{!function(e,t){if(D.get(e)===t)return;D.set(e,t);const o=e.querySelectorAll(".vp-block-loop-carousel-thumb")[t];if(!o||e.scrollWidth<=e.clientWidth)return;const n=o.offsetLeft+o.offsetWidth/2,r=e.scrollWidth-e.clientWidth,s=n-e.clientWidth/2,a=ve(e)?Math.max(-r,Math.min(0,s)):Math.max(0,Math.min(r,s));e.scrollTo({left:a,behavior:me()})}(e,o)}),t.querySelectorAll(".vp-block-loop-carousel-indicator--counter").forEach(e=>{Ee(e,".vp-block-loop-carousel-counter-current",o+1),Ee(e,".vp-block-loop-carousel-counter-total",n)});const s=function(e){if(B(e)){const t=e.querySelectorAll(c).length;return t>1?ge(e)/(t-1):1}const t=e.scrollWidth-e.clientWidth;return t>0?Math.min(1,Math.max(0,we(e)/t)):1}(e);t.querySelectorAll(".vp-block-loop-carousel-indicator--progress").forEach(e=>{e.style.setProperty("--vp-carousel-progress",100*s+"%"),e.setAttribute("aria-valuenow",String(Math.round(100*s)));const t=e.dataset.vpPositionLabel;t&&e.setAttribute("aria-valuetext",t.replace("%1$d",String(o+1)).replace("%2$d",String(n)))})}(e,t)}function ge(e){const t=O.get(e);return t&&window.performance.now()-t.time<1200?t.index:fe(e)}function Ee(e,t,o){const n=e.querySelector(t),r=String(o);n&&n.textContent!==r&&(n.textContent=r)}function be(e,t,o){const n=`--vp-carousel-fade-${t}`;o!==("0px"===e.style.getPropertyValue(n))&&(o?e.style.setProperty(n,"0px"):e.style.removeProperty(n))}function Le(e){const t=Ae(e);de(e).querySelectorAll(d).forEach(e=>{!function(e,t){const o=e.querySelectorAll(p),n=e.dataset.vpDotLabel||"",r=t.length;for(let e=o.length-1;e>=r;e-=1)o[e].remove();for(let t=o.length;t{const r=t[o];e.dataset.vpSlide=String(r),e.setAttribute("aria-label",n.replace("%d",String(r+1)))}),r&&!e.querySelector(v)){const t=document.createElement("span");t.className=f,t.setAttribute("aria-hidden","true"),t.innerHTML='',e.prepend(t)}}(e,t)})}function Se(e,t,o){const n=window.getComputedStyle(e),r=parseFloat(n.getPropertyValue("--vp-carousel-dot-slot"))||18,s=parseFloat(n.getPropertyValue("--vp-carousel-dot-size"))||6,a=parseFloat(n.getPropertyValue("--vp-carousel-dot-active-size"))||r,i=Math.max(0,(a-s)/2),l=parseFloat(n.paddingInlineStart)||0,c=Math.min(Math.max(o,0),Math.max(0,t-1));return{slot:r,grown:a,index:c,centreOf:e=>l+e*r+r/2+(e=>e===c?0:e{const i=0===t%n||!r&&t===s;e.classList.toggle("vp-carousel-no-snap",n>1&&!i);const l=a[a.length-1];i&&(r||1===n||void 0===l||o[t]!==o[l])&&a.push(t)}),G.set(e,a)}function Ae(e){return G.get(e)||Array.from(e.querySelectorAll(c),(e,t)=>t)}function xe(e,t,o){const n=e.querySelectorAll(p),r=e.clientWidth;if(!r||D.get(e)===o)return;D.set(e,o);const{centreOf:s,content:a}=t,i=Math.round(Math.min(0,Math.max(r-a,r/2-s(o))));e.style.setProperty(g,`${i}px`);const l=[i<0,i>r-a],c=[];n.forEach((e,t)=>{const o=s(t)+i;o>=0&&o<=r&&c.push(t)}),n.forEach((e,t)=>{const n=c.indexOf(t),r=t===o||n<0?n<0?-1:Number.POSITIVE_INFINITY:Math.min(l[0]?n:Number.POSITIVE_INFINITY,l[1]?c.length-1-n:Number.POSITIVE_INFINITY);e.classList.toggle(w,1===r),e.classList.toggle(y,r<=0)})}function Pe(e,t,o){let n=t+o;for(;n>=0&&n=1)return n;if(!Number.isInteger(n))return 1;const r=e.clientWidth;if(B(e)){const{step:t}=U(e);return t>0?Math.max(1,Math.round(r/t)):1}const s=t[Math.max(0,Math.min(t.length-1,o))];for(let e=o+1;e=r)return e-o;return Math.max(1,t.length-1-o)}function We(e,t,o){if(!e.length)return t;let n=t,r=Number.POSITIVE_INFINITY;return e.forEach(e=>{[e-o,e,e+o].forEach(e=>{const o=Math.abs(e-t);o0?null!==(r=e.find(e=>e>t))&&void 0!==r?r:e[0]:null!==(n=[...e].reverse().find(e=>e0&&t>=e.length-1||o<0&&t<=0)return r;const s=Math.max(0,Math.min(e.length-1,r));return e[s]===e[t]?Pe(e,t,o):s}(r,s,t,a),r)}function Ie(e,t,o=he(e)){if(B(e))return void ee(e,t);const n=Math.max(0,Math.min(o.length-1,t));o.length&&n===t&&(O.set(e,{index:n,time:window.performance.now()}),se(e,o[n]))}function ke(e,t=de(e)){const o=!R.has(e);t.classList.toggle("vp-carousel-is-stopped",!o),t.querySelectorAll(E).forEach(e=>{const t=o?e.dataset.vpPauseLabel:e.dataset.vpPlayLabel;t&&e.setAttribute("aria-label",t)})}function Ce(e,t){const o=()=>ye(e),r=t=>{var o;return Ie(e,null===(o=t.detail)||void 0===o?void 0:o.index)},s=t=>{var o;const{period:n}=U(e);B(e)&&n&&Number.isFinite(null===(o=t.detail)||void 0===o?void 0:o.position)&&(oe(e,t.detail.position,n),t.detail.position=we(e))};let a;B(e)&&$.add(e);let l=0;const u=n(e,t=>{l=t,void 0!==a&&$.has(e)&&K(e,t)!==a?e.dispatchEvent(new window.Event(W)):(Me(e),Le(e),ye(e),V.has(e)&&i(e))});a=$.has(e)&&K(e,l),a?e.dataset.vpCarouselRepeat="true":delete e.dataset.vpCarouselRepeat;const d=!!parseFloat(e.dataset.vpCarouselAutoplay)&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches,p=function(e,t){const o=pe(e).filter(e=>t||!e.matches(E));return o.forEach(e=>{e.classList.remove(S)}),()=>{o.forEach(e=>{e.classList.add(S)})}}(e,d);Me(e),Le(e),ye(e),e.addEventListener("scroll",o,{passive:!0}),e.addEventListener(F,r),e.addEventListener(k,s);const h=function(e,t){const o=new window.MutationObserver(e=>{const o=e.flatMap(e=>Array.from(e.addedNodes)).filter(e=>{var t;return 1===e.nodeType&&(null===(t=e.matches)||void 0===t?void 0:t.call(e,c))});o.length&&t()});return o.observe(e,{childList:!0}),()=>o.disconnect()}(e,()=>{Me(e),Le(e),ye(e)}),f=a?function(e){const t=e.ownerDocument.defaultView||window,o=()=>{const t=parseFloat(e.style.getPropertyValue(X))||0,{count:o,step:n,period:r,origin:s}=U(e);if(!o||!n)return;const a=((s-t)%n+n)%n,l=a<5||a>n-5?10:0;l!==t&&(l?e.style.setProperty(X,`${l}px`):e.style.removeProperty(X),r&&oe(e,we(e)+(l-t),r),V.has(e)&&i(e))};o();const n=new t.ResizeObserver(o);return n.observe(e),()=>{n.disconnect(),e.style.removeProperty(X)}}(e):N;a&&re(e,null!=t?t:0);const v=window.matchMedia("(hover: hover) and (pointer: fine)").matches,m=e.dataset.vpCarouselSrc,w=t=>{0===t.button&&(t.preventDefault(),e.classList.add(Y),e.focus({preventScroll:!0}))},y=()=>e.classList.remove(Y),g=e=>{J.has(e.key)||y()};v&&(e.addEventListener("mousedown",w),e.addEventListener("keydown",g),e.addEventListener("blur",y));const q=t=>{const o={ArrowLeft:-1,ArrowRight:1}[t.key];!o||t.defaultPrevented||t.altKey||t.ctrlKey||t.metaKey||(t.preventDefault(),Fe(e,o))};a&&e.addEventListener("keydown",q);const D=a?function(e){let t=[],o=0;const n=e=>{o+=Math.abs(e.clientX-t[t.length-1].x),t.push({x:e.clientX,time:e.timeStamp})},r=()=>{window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",s),window.removeEventListener("pointercancel",s)};function s(n){if(r(),o<=10||"true"!==e.getAttribute("has-overflow"))return;const{count:s,step:a,origin:i}=U(e);if(!s||!a)return;const l=n.clientX,c=n.timeStamp,u=t.find(e=>c-e.time<=80)||t[t.length-1],d=Math.max(1,c-u.time),p=(l-u.x)/d*(ve(e)?1:-1),h=we(e)+290*p;ee(e,We(Ae(e),Math.round((h-i)/a),s),0,p)}const a=r=>{ne(e),t=[{x:r.clientX,time:r.timeStamp}],o=0,window.addEventListener("pointermove",n),window.addEventListener("pointerup",s),window.addEventListener("pointercancel",s)};return e.addEventListener("pointerdown",a),()=>{e.removeEventListener("pointerdown",a),r()}}(e):N,H=a?function(e){const t=Object.getOwnPropertyDescriptor(Element.prototype,"scrollWidth");return null!=t&&t.get?(Object.defineProperty(e,"scrollWidth",{configurable:!0,get(){const o=e.querySelectorAll(c);return o.length<2?t.get.call(e):e.clientWidth+o.length*Math.abs(o[1].offsetLeft-o[0].offsetLeft)}}),()=>{delete e.scrollWidth}):N}(e):N;let _=!1;(v||a)&&m&&import(m).then(({Blossom:o})=>{if(_||!e.isConnected||V.has(e))return;const n=o(e,{repeat:a});V.set(e,n),n.init(),a&&(i(e),re(e,null!=t?t:0),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{V.has(e)&&i(e)})}))}).catch(()=>{});const z=function(e){const t=1e3*parseFloat(e.dataset.vpCarouselAutoplay);if(!t||window.matchMedia("(prefers-reduced-motion: reduce)").matches)return N;const o=de(e),n=[ue(e)||e,...pe(e)];let r=0,s=0,a=0;const i=new Set,l=new Set;let c=!1,u=!0,d=-1,p=!1;const h=e=>{o.style.setProperty("--vp-carousel-autoplay-progress",100*e+"%")},f=()=>{r=0,h(0)},v=o=>{a=window.requestAnimationFrame(v);const n=o-s;if(s=o,[i,l].forEach(e=>{e.forEach(t=>{t.isConnected||e.delete(t)})}),p)return void e.dispatchEvent(new window.CustomEvent("vp-carousel-autoplay-frame",{detail:{elapsed:n,held:!!(l.size||c||u||R.has(e)),pointer:i.size>0,keyboard:l.size>0}}));if(i.size||l.size||c||u||R.has(e))return;const m=ge(e);m!==d&&(d=m,f()),r+=n,h(Math.min(1,r/t)),r=e.scrollWidth-e.clientWidth-1?e.scrollTo({left:0,behavior:me()}):Fe(e,1))},m=e=>i.add(e.currentTarget),w=e=>i.delete(e.currentTarget),y=e=>{var t,o;null!==(t=(o=e.target).matches)&&void 0!==t&&t.call(o,":focus-visible")&&!e.target.classList.contains(Y)&&l.add(e.currentTarget)},g=e=>l.delete(e.currentTarget),E=e=>{var t,o;"visitor"!==(null===(t=e.detail)||void 0===t?void 0:t.source)&&(c=!1===(null===(o=e.detail)||void 0===o?void 0:o.playing))},b=ue(e)||e,L=new(b.ownerDocument.defaultView||window).IntersectionObserver(e=>{e.forEach(e=>{u=!e.isIntersecting})},{threshold:.5});L.observe(b),o.classList.add(M),n.forEach(e=>{e.addEventListener("pointerenter",m),e.addEventListener("pointerleave",w),e.addEventListener("focusin",y),e.addEventListener("focusout",g)}),e.addEventListener(I,E);const S=()=>{p=!0,h(0)};return e.addEventListener(T,f),e.addEventListener(C,S),ke(e,o),a=window.requestAnimationFrame(e=>{s=e,v(e)}),()=>{window.cancelAnimationFrame(a),L.disconnect(),o.classList.remove(M),n.forEach(e=>{e.removeEventListener("pointerenter",m),e.removeEventListener("pointerleave",w),e.removeEventListener("focusin",y),e.removeEventListener("focusout",g)}),e.removeEventListener(I,E),e.removeEventListener(T,f),e.removeEventListener(C,S),o.style.removeProperty("--vp-carousel-autoplay-progress")}}(e),G=function(e){const t=de(e),o=Array.from(t.querySelectorAll(".vp-block-loop-carousel-indicator--progress.is-draggable"));if(!o.length)return N;let n=null,r=null,s=0,a=!1;const i=()=>{n?e.style.setProperty(j,n):e.style.removeProperty(j),n=null,e.classList.remove(b)},l=(t,o)=>{const n=t.getBoundingClientRect(),r=ve(e)?n.right-o:o-n.left;return n.width>0?Math.min(1,Math.max(0,r/n.width)):0},u=(t,o)=>We(Ae(e),Math.round(t*Math.max(0,o-1)),o),d=t=>{if(r){if(!a){if(Math.abs(t.clientX-s)<3)return;a=!0,n=e.style.getPropertyValue(j),e.style.setProperty(j,"none"),e.classList.add(b),O.delete(e)}(t=>{if(B(e)){const{count:o,step:n,origin:r,period:s}=U(e);return void oe(e,r+t*Math.max(0,o-1)*n,s)}se(e,t*(e.scrollWidth-e.clientWidth),"instant")})(l(r,t.clientX))}},p=t=>{if(!r)return;const o=l(r,t.clientX),n=a;r=null,a=!1,window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),n?(t=>{if(i(),!B(e))return;const o=e.querySelectorAll(c).length;ee(e,u(t,o),0)})(o):(t=>{const o=e.querySelectorAll(c).length;e.dispatchEvent(new window.CustomEvent(T)),B(e)?ee(e,u(t,o),0):se(e,t*(e.scrollWidth-e.clientWidth))})(o)},h=t=>{ne(e),r=t.currentTarget,s=t.clientX,a=!1,window.addEventListener("pointermove",d),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p)},f=t=>{const o=ve(e),n=e.querySelectorAll(c).length,r=o?"ArrowRight":"ArrowLeft",s=o?"ArrowLeft":"ArrowRight";switch(t.key){case r:case"ArrowDown":case"PageDown":Fe(e,-1);break;case s:case"ArrowUp":case"PageUp":Fe(e,1);break;case"Home":Ie(e,0);break;case"End":Ie(e,n-1);break;default:return}t.preventDefault()};return o.forEach(e=>{e.addEventListener("pointerdown",h),e.addEventListener("keydown",f)}),()=>{o.forEach(e=>{e.removeEventListener("pointerdown",h),e.removeEventListener("keydown",f)}),window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),i()}}(e),Q=function(e,t){const o=Array.from(de(e).querySelectorAll(L)),n=e.dataset.vpCarouselSrc;if(!o.length||!n||!t)return N;const r=[];let s=!1;return import(n).then(({Blossom:e})=>{s||o.forEach(t=>{if(!t.isConnected||V.has(t))return;const o=e(t,{repeat:!1});V.set(t,o),o.init(),r.push(t)})}).catch(()=>{}),()=>{s=!0,r.forEach(e=>{var t;null===(t=V.get(e))||void 0===t||t.destroy(),V.delete(e)})}}(e,v),Z=a?function(e){const t=t=>{const o=parseFloat(t.style.translate)||0;if(t.classList.toggle(A,!!o),!o)return t.style.removeProperty(x),void t.style.removeProperty(P);const n=parseFloat(window.getComputedStyle(t).viewTimelineInset)||0,r=t.offsetLeft+o,s=r+t.offsetWidth,a=e.clientWidth;t.style.setProperty(x,`${r-a+n}px ${s-n}px`),t.style.setProperty(P,`${s-a+n}px ${r-n}px`)},o=new window.MutationObserver(e=>{e.forEach(e=>{t(e.target)})});return e.querySelectorAll(c).forEach(t),o.observe(e,{attributes:!0,attributeFilter:["style"],subtree:!0}),()=>{o.disconnect(),e.querySelectorAll(c).forEach(e=>{e.classList.remove(A),e.style.removeProperty(x),e.style.removeProperty(P)})}}(e):N;return e.dispatchEvent(new window.CustomEvent("vp-carousel-start",{bubbles:!0})),()=>{_=!0,e.dispatchEvent(new window.CustomEvent("vp-carousel-stop",{bubbles:!0})),Z(),z(),G(),Q(),u(),p(),e.removeEventListener("scroll",o),e.removeEventListener(F,r),e.removeEventListener(k,s),e.removeEventListener("mousedown",w),e.removeEventListener("keydown",g),e.removeEventListener("keydown",q),e.removeEventListener("blur",y),y(),f(),D(),ne(e),H(),h();const t=V.get(e);t&&(V.delete(e),t.destroy(),e.querySelectorAll(c).forEach(e=>{e.style.removeProperty("translate")}))}}function Te(e){var t;return(null===(t=e.closest(u))||void 0===t?void 0:t.querySelector(l))||null}function Ne(e,t){return"justified"===e.dataset.vpLayout?ce(e):"carousel"===e.dataset.vpLayout?Ce(e,t):void 0}ae&&"undefined"!=typeof document&&document.querySelectorAll(`${l}.${q}`).forEach(e=>{e.classList.remove(q),e.classList.add("vp-layout-masonry-native")}),t("visual-portfolio/item-template",{state:{hasScript:!0,useJsMasonry:!ae,useNativeMasonry:ae},actions:{carouselPrev(){const t=Te(e().ref);t&&Fe(t,-1)},carouselNext(){const t=Te(e().ref);t&&Fe(t,1)},carouselAutoplayToggle(){const{ref:t}=e(),o=Te(t);if(!o)return;const n=R.has(o);n?R.delete(o):R.add(o),ke(o),o.dispatchEvent(new window.CustomEvent(I,{detail:{playing:n,source:"visitor"}}))},carouselGoTo(t){const{ref:o}=e(),n=t.target.closest(h),r=Te(o),s=n?parseInt(n.dataset.vpSlide,10):-1;!r||s<0||(r.dispatchEvent(new window.CustomEvent(T)),Ie(r,s))}},callbacks:{initLayout(){const{ref:t}=e();let o=Ne(t);if(!o)return;const n=()=>{const e="carousel"===t.dataset.vpLayout?fe(t):void 0;o(),o=Ne(t,e)||N};return t.addEventListener(W,n),()=>{t.removeEventListener(W,n),o()}}}}); \ No newline at end of file diff --git a/gutenberg/blocks/item-template/view.js b/gutenberg/blocks/item-template/view.js index f90d8cca..eb811392 100644 --- a/gutenberg/blocks/item-template/view.js +++ b/gutenberg/blocks/item-template/view.js @@ -2998,6 +2998,30 @@ function initCarousel(list, restore) { list.addEventListener('blur', unmarkFocus); } + // The browser's own arrow-key scroll stops at the end of the range Blossom + // keeps a repeating carousel in, so it never reaches the seam. The arrows + // step the way the buttons do instead. A loop never runs right to left. + const onArrowKey = (event) => { + const direction = { ArrowLeft: -1, ArrowRight: 1 }[event.key]; + + if ( + !direction || + event.defaultPrevented || + event.altKey || + event.ctrlKey || + event.metaKey + ) { + return; + } + + event.preventDefault(); + slide(list, direction); + }; + + if (repeats) { + list.addEventListener('keydown', onArrowKey); + } + // A drag of a repeating carousel takes over from a step the module is // still drawing, and is landed on a slide by the module as well. const stopLanding = repeats ? landDrags(list) : noop; @@ -3070,6 +3094,7 @@ function initCarousel(list, restore) { list.removeEventListener(PLACE_EVENT, onPlace); list.removeEventListener('mousedown', onMouseDown); list.removeEventListener('keydown', onKeyDown); + list.removeEventListener('keydown', onArrowKey); list.removeEventListener('blur', unmarkFocus); unmarkFocus(); stopShifting(); diff --git a/tests/e2e/specs/gallery-layouts.spec.js b/tests/e2e/specs/gallery-layouts.spec.js index 23d01df7..c76d006c 100644 --- a/tests/e2e/specs/gallery-layouts.spec.js +++ b/tests/e2e/specs/gallery-layouts.spec.js @@ -950,6 +950,55 @@ test.describe('Gallery Item Template layouts', () => { } }); + test('the arrow keys step a repeating carousel one slide across its seam', async ({ + page, + requestUtils, + }) => { + await publishLoop(requestUtils, page, { + title: 'Layouts - carousel repeat keyboard', + blockId: 'e2e-carousel-repeat-keyboard', + images, + layout: { + layoutType: 'carousel', + layoutColumnsMode: 'manual', + layoutColumnCount: 4, + carouselRepeat: true, + }, + carousel: ['loop-carousel-previous', 'loop-carousel-next'], + }); + + const list = page.locator(LIST); + + await expect(list).toHaveAttribute('has-repeat', 'true', { + timeout: 15000, + }); + await expect + .poll(() => getRestingSlide(list), { timeout: 10000 }) + .toBe(0); + + // The browser's own arrow scroll stopped at the end of the range the + // library keeps the loop in: the last slide was never reached. Each + // press waits for the last to come to rest, which is when the + // browser's scroll would have taken it. + await list.focus(); + + const press = async (key, expected) => { + await page.keyboard.press(key); + await expect + .poll(() => getRestingSlide(list), { timeout: 10000 }) + .toBe(expected); + await settle(list); + }; + + for (const expected of [1, 2, 3, 4, 5, 0, 1]) { + await press('ArrowRight', expected); + } + + for (const expected of [0, 5, 4]) { + await press('ArrowLeft', expected); + } + }); + test('a repeating carousel steps its frames round the loop', async ({ page, requestUtils,