1var g=Object.defineProperty;var N=(r,e,t)=>e in r?g(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var n=(r,e,t)=>N(r,typeof e!="symbol"?e+"":e,t);var f=["bottom","height","left","right","top","width"],I=function(e,t){return e===void 0&&(e={}),t===void 0&&(t={}),f.some(function(s){return e[s]!==t[s]})},m=new Map,C,O=function r(){var e=[];m.forEach(function(t,s){var a=s.getBoundingClientRect();I(a,t.rect)&&(t.rect=a,e.push(t))}),e.forEach(function(t){t.callbacks.forEach(function(s){return s(t.rect)})}),C=window.requestAnimationFrame(r)};function p(r,e){return{observe:function(){var s=m.size===0;m.has(r)?m.get(r).callbacks.push(e):m.set(r,{rect:void 0,hasRectChanged:!1,callbacks:[e]}),s&&O()},unobserve:function(){var s=m.get(r);if(s){var a=s.callbacks.indexOf(e);a>=0&&s.callbacks.splice(a,1),s.callbacks.length||m.delete(r),m.size||cancelAnimationFrame(C)}}}}var i,h=(i=class{static getGlobalOverlay(){let e=document.getElementById(i.OVERLAY_ID);if(e)return e;let t=document.createElement("div");return t.id=i.OVERLAY_ID,document.body.insertAdjacentElement("afterend",t),t}static addStyles(){if(document.getElementById(i.STYLE_ID))return;let e=document.createElement("style");e.id=i.STYLE_ID;let t=28,s=`var(${i.CSS_VAR_BORDER_SPACING}, ${Math.round(t*.333)}px)`,a=`var(${i.CSS_VAR_BORDER_WIDTH}, 2px)`;e.appendChild(document.createTextNode(` 2 #${i.OVERLAY_ID} { 3 display: contents; 4 } 5 .${i.CONTAINER_RECT_CLASS_NAME} { 6 pointer-events: none; 7 position: fixed; 8 top: 0; 9 left: 0; 10 right: 0; 11 bottom: 0; 12 z-index: var(${i.CSS_VAR_Z_INDEX}, 999999999); 13 } 14 .${i.RECT_CLASS_NAME} { 15 position: absolute; 16 } 17 .${i.RECT_INNER_CLASS_NAME} { 18 position: absolute; 19 box-sizing: border-box; 20 top: calc(-1 * ${s}); 21 left: calc(-1 * ${s}); 22 right: calc(-1 * ${s}); 23 bottom: calc(-1 * ${s}); 24 border: ${a} solid var(${i.CSS_VAR_BORDER_COLOR}, #6644ff); 25 border-radius: var(${i.CSS_VAR_BORDER_RADIUS}, 6px); 26 opacity: 0; 27 } 28 .${i.RECT_CLASS_NAME}.${i.RECT_HOVER_CLASS_NAME} .${i.RECT_INNER_CLASS_NAME} { 29 --hover-opacity: var(${i.CSS_VAR_HOVER_OPACITY}, 0.333); 30 opacity: var(--hover-opacity); 31 } 32 .${i.RECT_CLASS_NAME}.${i.RECT_PARENT_HOVER_CLASS_NAME} .${i.RECT_INNER_CLASS_NAME} { 33 opacity: calc(var(--hover-opacity) / 3); 34 } 35 .${i.RECT_HIGHLIGHT_CLASS_NAME} { 36 pointer-events: all; 37 cursor: pointer; 38 } 39 .${i.RECT_HIGHLIGHT_CLASS_NAME} .${i.RECT_INNER_CLASS_NAME} { 40 opacity: var(${i.CSS_VAR_HIGHLIGHT_OPACITY}, 0.333); 41 } 42 .${i.RECT_EDIT_BUTTON_CLASS_NAME}:visited, 43 .${i.RECT_EDIT_BUTTON_CLASS_NAME}:active, 44 .${i.RECT_EDIT_BUTTON_CLASS_NAME}:hover, 45 .${i.RECT_EDIT_BUTTON_CLASS_NAME}:focus, 46 .${i.RECT_EDIT_BUTTON_CLASS_NAME} { 47 all: initial; 48 pointer-events: all; 49 cursor: pointer; 50 position: absolute; 51 z-index: 1; 52 top: calc(-1 * ${s} + ${a} / 2); 53 left: calc(-1 * ${s} + ${a} / 2); 54 transform: translate(-50%, -50%); 55 width: var(${i.CSS_VAR_BUTTON_WIDTH}, ${t}px); 56 height: var(${i.CSS_VAR_BUTTON_HEIGHT}, ${t}px); 57 border-radius: var(${i.CSS_VAR_BUTTON_RADIUS}, 50%); 58 background-color: var(${i.CSS_VAR_BUTTON_BG_COLOR}, #6644ff); 59 background-image: var(${i.CSS_VAR_BUTTON_ICON_BG_IMAGE}, ${i.ICON_EDIT}); 60 background-size: var(${i.CSS_VAR_BUTTON_ICON_BG_SIZE}, 66.6%); 61 background-position: center; 62 background-repeat: no-repeat; 63 opacity: 0; 64 } 65 .${i.RECT_EDIT_BUTTON_CLASS_NAME}:hover, 66 .${i.RECT_CLASS_NAME}.${i.RECT_HOVER_CLASS_NAME}:not(.${i.RECT_PARENT_HOVER_CLASS_NAME}) .${i.RECT_EDIT_BUTTON_CLASS_NAME}, 67 .${i.RECT_HIGHLIGHT_CLASS_NAME}:hover .${i.RECT_EDIT_BUTTON_CLASS_NAME} { 68 opacity: 1; 69 } 70 .${i.RECT_EDIT_BUTTON_CLASS_NAME}:hover ~ .${i.RECT_INNER_CLASS_NAME}, 71 .${i.RECT_HIGHLIGHT_CLASS_NAME}:hover .${i.RECT_INNER_CLASS_NAME} { 72 opacity: 1; 73 } 74 `)),document.head.appendChild(e)}},n(i,"CSS_VAR_Z_INDEX","--directus-visual-editing--overlay--z-index"),n(i,"CSS_VAR_BORDER_SPACING","--directus-visual-editing--rect--border-spacing"),n(i,"CSS_VAR_BORDER_WIDTH","--directus-visual-editing--rect--border-width"),n(i,"CSS_VAR_BORDER_COLOR","--directus-visual-editing--rect--border-color"),n(i,"CSS_VAR_BORDER_RADIUS","--directus-visual-editing--rect--border-radius"),n(i,"CSS_VAR_HOVER_OPACITY","--directus-visual-editing--rect-hover--opacity"),n(i,"CSS_VAR_HIGHLIGHT_OPACITY","--directus-visual-editing--rect-highlight--opacity"),n(i,"CSS_VAR_BUTTON_WIDTH","--directus-visual-editing--edit-btn--width"),n(i,"CSS_VAR_BUTTON_HEIGHT","--directus-visual-editing--edit-btn--height"),n(i,"CSS_VAR_BUTTON_RADIUS","--directus-visual-editing--edit-btn--radius"),n(i,"CSS_VAR_BUTTON_BG_COLOR","--directus-visual-editing--edit-btn--bg-color"),n(i,"CSS_VAR_BUTTON_ICON_BG_IMAGE","--directus-visual-editing--edit-btn--icon-bg-image"),n(i,"CSS_VAR_BUTTON_ICON_BG_SIZE","--directus-visual-editing--edit-btn--icon-bg-size"),n(i,"ICON_EDIT",`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="%23ffffff"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M14.06 9.02l.92.92L5.92 19H5v-.92l9.06-9.06M17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29zm-3.6 3.19L3 17.25V21h3.75L17.81 9.94l-3.75-3.75z"/></svg>')`),n(i,"OVERLAY_ID","directus-visual-editing"),n(i,"STYLE_ID","directus-visual-editing-style"),n(i,"CONTAINER_RECT_CLASS_NAME","directus-visual-editing-overlay"),n(i,"RECT_CLASS_NAME","directus-visual-editing-rect"),n(i,"RECT_HIGHLIGHT_CLASS_NAME","directus-visual-editing-rect-highlight"),n(i,"RECT_PARENT_HOVER_CLASS_NAME","directus-visual-editing-rect-parent-hover"),n(i,"RECT_HOVER_CLASS_NAME","directus-visual-editing-rect-hover"),n(i,"RECT_INNER_CLASS_NAME","directus-visual-editing-rect-inner"),n(i,"RECT_EDIT_BUTTON_CLASS_NAME","directus-visual-editing-edit-button"),i),L=class{constructor(){n(this,"hasNoDimensions",!1);n(this,"element");n(this,"container");n(this,"editButton");this.container=this.createContainer(),this.element=this.createElement(),this.editButton=this.createEditButton(),this.createRectElement(),h.getGlobalOverlay().appendChild(this.container),u.highlightOverlayElements&&this.toggleHighlight(!0),this.element.addEventListener("click",()=>this.editButton.click())}createContainer(){let r=document.createElement("div");return r.classList.add(h.CONTAINER_RECT_CLASS_NAME),r}createElement(){let r=document.createElement("div");return r.classList.add(h.RECT_CLASS_NAME),this.container.appendChild(r),r}createRectElement(){let r=document.createElement("div");r.classList.add(h.RECT_INNER_CLASS_NAME),this.element.appendChild(r)}createEditButton(){let r=document.createElement("button");return r.type="button",r.classList.add(h.RECT_EDIT_BUTTON_CLASS_NAME),this.element.appendChild(r),r}updateRect(r){let e=r.width!==0&&r.height!==0;if(!this.hasNoDimensions&&!e){this.hasNoDimensions=!0,this.disable();return}this.hasNoDimensions&&e&&(this.hasNoDimensions=!1,this.enable()),this.element.style.width=`${r.width}px`,this.element.style.height=`${r.height}px`,this.element.style.transform=`translate(${r.left}px,${r.top}
74px)`}setCustomClass(r){r!==void 0&&/^[a-zA-Z_][\w-]*$/.test(r)&&this.container.classList.add(r)}toggleHover(r){r?this.element.classList.add(h.RECT_HOVER_CLASS_NAME):this.element.classList.remove(h.RECT_HOVER_CLASS_NAME)}toggleParentHover(r){r?this.element.classList.add(h.RECT_PARENT_HOVER_CLASS_NAME):this.element.classList.remove(h.RECT_PARENT_HOVER_CLASS_NAME)}toggleHighlight(r){r?this.element.classList.add(h.RECT_HIGHLIGHT_CLASS_NAME):this.element.classList.remove(h.RECT_HIGHLIGHT_CLASS_NAME)}disable(){this.element.style.display="none"}enable(){this.element.style.removeProperty("display")}remove(){this.container.remove()}},d,T=(d=class{constructor(e){n(this,"optionsWritable",!0);n(this,"element");n(this,"key");n(this,"editConfig");n(this,"rectObserver");n(this,"overlayElement");n(this,"rect");n(this,"hover",!1);n(this,"disabled",!1);n(this,"onSaved");this.element=e,this.element.addEventListener("mouseover",this.onMouseenter.bind(this)),this.element.addEventListener("mouseleave",this.onMouseleave.bind(this)),this.key=crypto.randomUUID(),this.editConfig=d.editAttrToObject(this.element.dataset[d.DATASET]),this.rect=this.element.getBoundingClientRect(),this.overlayElement=new L,this.overlayElement.updateRect(this.rect),this.overlayElement.editButton.addEventListener("click",this.onClickEdit.bind(this)),this.rectObserver=p(this.element,this.onObserveRect.bind(this)),this.rectObserver.observe()}static query(e){return e?(Array.isArray(e)?e:[e]).filter(t=>t instanceof HTMLElement).flatMap(t=>t.dataset[d.DATASET]!==void 0?t:Array.from(t.querySelectorAll(`[data-${d.DATASET}]`))).filter(t=>t!==null):Array.from(document.querySelectorAll(`[data-${d.DATASET}]`))}static objectToEditAttr(e){let t=[];for(let[s,a]of Object.entries(e))d.validEditConfigKey(s)&&(s==="fields"&&Array.isArray(a)?t.push(`${s}:${a.join(",")}`):t.push(`${s}:${a}`));return t.join(";")}static editAttrToObject(e){let t=e.split(";"),s={};return t.forEach(a=>{let l=a.split(":");if(l[0]===void 0||(l==null?void 0:l[1])===void 0)return;let c=l[0].trim();if(!d.validEditConfigKey(c))return;let E=l[1];if(c==="fields"){s.fields=E.split(",").map(_=>_.trim());return}s[c]=E.trim()}),s}static validEditConfigKey(e){return d.DATA_ATTRIBUTE_VALID_KEYS.includes(e)}applyOptions({customClass:e,onSaved:t},s=!1){this.optionsWritable&&(s&&(this.optionsWritable=!1),this.overlayElement.setCustomClass(e),t!==void 0&&(this.onSaved=t))}removeHoverListener(){this.element.removeEventListener("mouseenter",this.onMouseenter.bind(this)),this.element.removeEventListener("mouseleave",this.onMouseleave.bind(this))}onClickEdit(){new R().send("edit",{key:this.key,editConfig:this.editConfig,rect:this.rect})}onMouseenter(e){this.toggleItemHover(!0,e)}onMouseleave(e){this.toggleItemHover(!1,e)}toggleItemHover(e,t){this.element!==t.currentTarget||this.hover===e||(this.hover=e,this.setParentsHover(),this.overlayElement.toggleHover(e))}setParentsHover(){let e=u.getHoveredItems();e.forEach(t=>{let s=e.filter(a=>a.element!==t.element).some(a=>t.element.contains(a.element));t.overlayElement.toggleParentHover(s)})}onObserveRect(e){this.disabled||(this.rect=e,this.overlayElement.updateRect(e))}},n(d,"DATASET","directus"),n(d,"DATA_ATTRIBUTE_VALID_KEYS",["collection","item","fields","mode"]),d),o,u=(o=class{static getItem(e){return o.items.find(t=>t.element===e)}static getItemByKey(e){return o.items.find(t=>t.key===e)}static getHoveredItems(){return o.items.filter(e=>e.hover)}static addItem(e){o.items.push(e)}static enableItems(e){(e??o.items).forEach(t=>{t.disabled=!1,t.rectObserver.observe(),t.overlayElement.enable()})}static disableItems(e){let t=e??o.items.filter(s=>!s.disabled);return t.forEach(s=>{s.disabled=!0,s.hover=!1,s.rectObserver.unobserve(),s.overlayElement.disable()}),[...t]}static removeItems(e){let t=e??o.items;t.forEach(s=>{s.rectObserver.unobserve(),s.overlayElement.remove(),s.removeHoverListener()}),o.items=o.items.filter(s=>!t.includes(s))}static highlightItems(e){this.highlightOverlayElements!==e&&(this.highlightOverlayElements=e,o.items.forEach(t=>{t.overlayElement.toggleHighlight(e)}))}},n(o,"items",[]),n(o,"highlightOverlayElements",!1),o),v,R=(v=class{constructor(){n(this,"origin",null);n(this,"confirmed",!1);if(v.SINGLETON)return v.SINGLETON;v.SINGLETON=this,window==null||window.addEventListener("message",this.receive.bind(this))}connect(e){return this.origin=e,this.send("connect")}send(e,t){try{if(!this.origin)throw new Error;return window.parent.postMessage({action:e,data:t},this.origin),!0}catch(s){return console.error(v.ERROR_PARENT_NOT_FOUND,s),!1}}sameOrigin(e,t){try{return e===new URL(t).origin}catch{return!1}}receive(e){if(!this.origin||!this.sameOrigin(e.origin,this.origin))return;let{action:t,data:s}=e.data;t==="confirm"&&(this.confirmed=!0),t==="showEditableElements"&&this.receiveShowEditableElements(s),t==="saved"&&this.receiveSaved(s)}receiveConfirm(){let e=0,t=10,s=100;return new Promise(a=>{let l=()=>{if(e>=t)return a(!1);e++,this.confirmed?a(!0):setTimeout(l,s)};l()})}receiveShowEditableElements(e){let t=!!e;u.highlightItems(t)}receiveSaved(e){let{key:t="",collection:s="",item:a=null,payload:l={}}=e,c=u.getItemByKey(t);if(c&&s&&typeof c.onSaved=="function"){c.onSaved({collection:s,item:a,payload:l});return}window.location.reload()}},n(v,"SINGLETON"),n(v,"ERROR_PARENT_NOT_FOUND","Error sending message to Directus in parent frame:"),v),S,b=(S=class{static onNavigation(e){if(S.navigationInitialized)return;let t="",s="",a,l=E=>{clearTimeout(a),a=setTimeout(E,100)},c=()=>{let E=window.location.href,_=document.title,A=t!==E||s!==_;A&&(l(()=>e({url:E,title:_})),t=E,s=_),setTimeout(c,A?50:200)};c(),S.navigationInitialized=!0}},n(S,"navigationInitialized",!1),S);async function H({directusUrl:r,elements:e=void 0,customClass:t=void 0,onSaved:s=void 0}){let a=new R;if(!a.connect(r)||!await a.receiveConfirm())return;b.onNavigation(E=>a.send("navigation",E)),h.addStyles();let l=T.query(e),c=[];return l.forEach(E=>{let _=u.getItem(E),A=_??new T(E);A.applyOptions({customClass:t,onSaved:s},!!e),c.push(A),_||u.addItem(A)}),{remove(){u.removeItems(c)},enable(){u.enableItems(c)},disable(){u.disableItems(c)}}}function $(r){return T.objectToEditAttr(r)}export{$ as P,H 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.