AlkantarClanX12
Current Path : /home/thanudqk/siamfreetour.com/wp-content/plugins/generateblocks/dist/ |
Current File : //home/thanudqk/siamfreetour.com/wp-content/plugins/generateblocks/dist/pattern-library.js |
!function(){var e={184:function(e,t){var n;!function(){"use strict";var r={}.hasOwnProperty;function a(){for(var e=[],t=0;t<arguments.length;t++){var n=arguments[t];if(n){var i=typeof n;if("string"===i||"number"===i)e.push(n);else if(Array.isArray(n)){if(n.length){var o=a.apply(null,n);o&&e.push(o)}}else if("object"===i){if(n.toString!==Object.prototype.toString&&!n.toString.toString().includes("[native code]")){e.push(n.toString());continue}for(var s in n)r.call(n,s)&&n[s]&&e.push(s)}}}return e.join(" ")}e.exports?(a.default=a,e.exports=a):void 0===(n=function(){return a}.apply(t,[]))||(e.exports=n)}()},158:function(e){var t,n;t="undefined"!=typeof window?window:this,n=function(){function e(){}let t=e.prototype;return t.on=function(e,t){if(!e||!t)return this;let n=this._events=this._events||{},r=n[e]=n[e]||[];return r.includes(t)||r.push(t),this},t.once=function(e,t){if(!e||!t)return this;this.on(e,t);let n=this._onceEvents=this._onceEvents||{};return(n[e]=n[e]||{})[t]=!0,this},t.off=function(e,t){let n=this._events&&this._events[e];if(!n||!n.length)return this;let r=n.indexOf(t);return-1!=r&&n.splice(r,1),this},t.emitEvent=function(e,t){let n=this._events&&this._events[e];if(!n||!n.length)return this;n=n.slice(0),t=t||[];let r=this._onceEvents&&this._onceEvents[e];for(let a of n)r&&r[a]&&(this.off(e,a),delete r[a]),a.apply(this,t);return this},t.allOff=function(){return delete this._events,delete this._onceEvents,this},e},e.exports?e.exports=n():t.EvEmitter=n()},564:function(e,t,n){!function(t,r){e.exports?e.exports=r(t,n(158)):t.imagesLoaded=r(t,t.EvEmitter)}("undefined"!=typeof window?window:this,(function(e,t){let n=e.jQuery,r=e.console;function a(e,t,i){if(!(this instanceof a))return new a(e,t,i);let o=e;var s;"string"==typeof e&&(o=document.querySelectorAll(e)),o?(this.elements=(s=o,Array.isArray(s)?s:"object"==typeof s&&"number"==typeof s.length?[...s]:[s]),this.options={},"function"==typeof t?i=t:Object.assign(this.options,t),i&&this.on("always",i),this.getImages(),n&&(this.jqDeferred=new n.Deferred),setTimeout(this.check.bind(this))):r.error(`Bad element for imagesLoaded ${o||e}`)}a.prototype=Object.create(t.prototype),a.prototype.getImages=function(){this.images=[],this.elements.forEach(this.addElementImages,this)};const i=[1,9,11];a.prototype.addElementImages=function(e){"IMG"===e.nodeName&&this.addImage(e),!0===this.options.background&&this.addElementBackgroundImages(e);let{nodeType:t}=e;if(!t||!i.includes(t))return;let n=e.querySelectorAll("img");for(let e of n)this.addImage(e);if("string"==typeof this.options.background){let t=e.querySelectorAll(this.options.background);for(let e of t)this.addElementBackgroundImages(e)}};const o=/url\((['"])?(.*?)\1\)/gi;function s(e){this.img=e}function l(e,t){this.url=e,this.element=t,this.img=new Image}return a.prototype.addElementBackgroundImages=function(e){let t=getComputedStyle(e);if(!t)return;let n=o.exec(t.backgroundImage);for(;null!==n;){let r=n&&n[2];r&&this.addBackground(r,e),n=o.exec(t.backgroundImage)}},a.prototype.addImage=function(e){let t=new s(e);this.images.push(t)},a.prototype.addBackground=function(e,t){let n=new l(e,t);this.images.push(n)},a.prototype.check=function(){if(this.progressedCount=0,this.hasAnyBroken=!1,!this.images.length)return void this.complete();let e=(e,t,n)=>{setTimeout((()=>{this.progress(e,t,n)}))};this.images.forEach((function(t){t.once("progress",e),t.check()}))},a.prototype.progress=function(e,t,n){this.progressedCount++,this.hasAnyBroken=this.hasAnyBroken||!e.isLoaded,this.emitEvent("progress",[this,e,t]),this.jqDeferred&&this.jqDeferred.notify&&this.jqDeferred.notify(this,e),this.progressedCount===this.images.length&&this.complete(),this.options.debug&&r&&r.log(`progress: ${n}`,e,t)},a.prototype.complete=function(){let e=this.hasAnyBroken?"fail":"done";if(this.isComplete=!0,this.emitEvent(e,[this]),this.emitEvent("always",[this]),this.jqDeferred){let e=this.hasAnyBroken?"reject":"resolve";this.jqDeferred[e](this)}},s.prototype=Object.create(t.prototype),s.prototype.check=function(){this.getIsImageComplete()?this.confirm(0!==this.img.naturalWidth,"naturalWidth"):(this.proxyImage=new Image,this.img.crossOrigin&&(this.proxyImage.crossOrigin=this.img.crossOrigin),this.proxyImage.addEventListener("load",this),this.proxyImage.addEventListener("error",this),this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.proxyImage.src=this.img.currentSrc||this.img.src)},s.prototype.getIsImageComplete=function(){return this.img.complete&&this.img.naturalWidth},s.prototype.confirm=function(e,t){this.isLoaded=e;let{parentNode:n}=this.img,r="PICTURE"===n.nodeName?n:this.img;this.emitEvent("progress",[this,r,t])},s.prototype.handleEvent=function(e){let t="on"+e.type;this[t]&&this[t](e)},s.prototype.onload=function(){this.confirm(!0,"onload"),this.unbindEvents()},s.prototype.onerror=function(){this.confirm(!1,"onerror"),this.unbindEvents()},s.prototype.unbindEvents=function(){this.proxyImage.removeEventListener("load",this),this.proxyImage.removeEventListener("error",this),this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},l.prototype=Object.create(s.prototype),l.prototype.check=function(){this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.img.src=this.url,this.getIsImageComplete()&&(this.confirm(0!==this.img.naturalWidth,"naturalWidth"),this.unbindEvents())},l.prototype.unbindEvents=function(){this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},l.prototype.confirm=function(e,t){this.isLoaded=e,this.emitEvent("progress",[this,this.element,t])},a.makeJQueryPlugin=function(t){(t=t||e.jQuery)&&(n=t,n.fn.imagesLoaded=function(e,t){return new a(this,e,t).jqDeferred.promise(n(this))})},a.makeJQueryPlugin(),a}))}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";var e=window.React,t=n.n(e),r=window.wp.components,a=window.wp.element,i=window.wp.i18n,o=window.wp.apiFetch,s=n.n(o),l=window.wp.url;const c=(0,a.createContext)(void 0);async function d(e=!0){return await s()({path:(0,l.addQueryArgs)("/generateblocks/v1/pattern-library/libraries",{is_enabled:e}),method:"GET"})}function u({children:t}){const[n,r]=(0,a.useState)([]),[i,o]=(0,a.useState)([]),[u,g]=(0,a.useState)([]),[h,p]=(0,a.useState)(""),[f,m]=(0,a.useState)(""),[v,b]=(0,a.useState)(""),[y,w]=(0,a.useState)(!1),[E,x]=(0,a.useState)(""),[C,k]=(0,a.useState)(""),[S,D]=(0,a.useState)(""),[I,R]=(0,a.useState)(!1),[L,_]=(0,a.useState)("100%"),[M,N]=(0,a.useState)(15),[P,B]=(0,a.useState)(0),[T,A]=(0,a.useReducer)((function(e,t){switch(t.type){case"ADD":return[...e,t.pattern];case"REMOVE":return e.filter((e=>e.id!==t.pattern.id));case"SET":return t.patterns;default:return e}}),[]),O={libraries:n,search:h,setSearch:p,activeLibrary:f,setActiveLibrary:m,activeCategory:E,setActiveCategory:x,activePatternId:C,setActivePatternId:k,selectedPatterns:T,selectedPatternsDispatch:A,categories:i,hoverPattern:S,setHoverPattern:D,patterns:u,isLocal:y,setIsLocal:w,setPublicKey:b,loading:I,setLoading:R,previewIframeWidth:L,setPreviewIframeWidth:_,setLibraryCategories:z,setLibraryPatterns:H,setLibraries:V,itemsPerPage:15,itemCount:M,setItemCount:N,scrollPosition:P,setScrollPosition:B};async function z(){var e,t;const{data:n}=await async function(e,t,n){const r=t?"-pro":"";try{var a;const i=await s()({path:(0,l.addQueryArgs)(`/generateblocks${r}/v1/pattern-library/categories`,{libraryId:e,isLocal:t}),method:"GET",headers:{"X-GB-Public-Key":n}});return null!==(a=i?.response)&&void 0!==a?a:[]}catch(e){return[]}}(f?.id,y,v),r=new Set(u.flatMap((e=>e.categories))),a=n.filter((e=>r.has(e.id)));o(null!=a?a:[]);const i=null!==(e=a.find((e=>generateBlocksPatternLibrary.defaultOpenCategory===e.name)))&&void 0!==e?e:"";x(null!==(t=i?.id)&&void 0!==t?t:"")}async function H(){R(!0),g([]);const{data:e}=await async function(e,t,n,r,a){const i=r?"-pro":"";try{var o;const t=await s()({path:(0,l.addQueryArgs)(`/generateblocks${i}/v1/pattern-library/patterns`,{libraryId:e,categoryId:"",search:"",isLocal:r}),method:"GET",headers:{"X-GB-Public-Key":a}});return null!==(o=t?.response)&&void 0!==o?o:[]}catch(e){return[]}}(f?.id,0,0,y,v);g(null!=e?e:[]),N(15),B(0),R(!1)}async function V(){var e,t,n,a;const{data:i}=await d();r(null!=i?i:[]);const o=null!==(e=null!==(t=i.find((e=>generateBlocksPatternLibrary.defaultOpenLibrary===e.id)))&&void 0!==t?t:i[0])&&void 0!==e?e:{};m(null!=o&&o),b(null!==(n=o?.publicKey)&&void 0!==n?n:""),w(null!==(a=o?.isLocal)&&void 0!==a&&a)}return(0,a.useEffect)((()=>{!async function(){V()}()}),[]),(0,a.useEffect)((()=>{f.id?z():o([])}),[f?.id,u]),(0,a.useEffect)((()=>{f.id?H():g([])}),[f?.id,v]),(0,e.createElement)(c.Provider,{value:O},t)}function g(){const e=(0,a.useContext)(c);if(!e)throw new Error((0,i.__)("useLibrary hook must be wrapped by a LibraryProvider.","generateblocks"));return e}var h=window.wp.primitives,p=(0,e.createElement)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,e.createElement)(h.Path,{d:"M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"})),f=(0,e.createElement)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,e.createElement)(h.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})),m=(0,e.createElement)(h.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)(h.Path,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})),v=(0,e.createElement)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,e.createElement)(h.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"}));function b({bulkInsertEnabled:t}){const{categories:n,activeCategory:a,setActiveCategory:o}=g();return(0,e.createElement)("div",{className:"pattern-category-list",style:{background:t?"none":""}},t?(0,e.createElement)(r.DropdownMenu,{className:"pattern-category-dropdown",icon:m,toggleProps:{variant:"secondary",children:(0,i.sprintf)(/* translators: %s: category name */ (0,i.__)("Category: %s","generateblocks"),(e=>{const t=n.find((t=>t.id===e));return t?t.name:null})(a)||(0,i.__)("All","generateblocks"))}},(({onClose:t})=>(0,e.createElement)(r.MenuGroup,null,(0,e.createElement)(r.MenuItem,{isPressed:""===a,onClick:()=>{o(""),t()}},(0,i.__)("All","generateblocks")),n&&n.map((n=>(0,e.createElement)(r.MenuItem,{key:n.id,icon:n.id===a?v:null,onClick:()=>{o(n.id),t()}},n.name)))))):(0,e.createElement)(e.Fragment,null,(0,e.createElement)(r.Button,{id:"pattern-category-all",isPressed:""===a,onClick:()=>o("")},(0,i.__)("All","generateblocks")),n&&n.map((t=>(0,e.createElement)(r.Button,{id:`pattern-category-${t.id}`,key:t.id,isPressed:t.id===a,onClick:()=>o(t.id)},t.name)))))}var y=(0,e.createElement)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,e.createElement)(h.Path,{d:"M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"})),w=window.wp.hooks;function E({setShowAddLibrary:t,setLibraries:n}){const r=(0,e.createElement)(e.Fragment,null,(0,e.createElement)("p",null,(0,i.__)("This feature requires GenerateBlocks Pro.","generateblocks")));return(0,w.applyFilters)("generateblocks.patternLibrary.addLibraryContent",r,{setShowAddLibrary:t,setLibraries:n})}function x(){const[t,n]=(0,a.useState)(!1),{setLibraries:o}=g();return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(r.Button,{variant:"secondary",icon:y,onClick:()=>n(!0),label:(0,i.__)("Add Library","generateblocks")}),!!t&&(0,e.createElement)(r.Modal,{title:(0,i.__)("Add Library","generateblocks"),onRequestClose:()=>n(!1),className:"gblocks-patterns-add-library"},(0,e.createElement)(E,{setShowAddLibrary:n,setLibraries:o})))}function C(){const{libraries:t,activeLibrary:n,setActiveLibrary:a,setIsLocal:i,setPublicKey:o,setActiveCategory:s,loading:l}=g();return(0,e.createElement)("div",{className:"pattern-library-selector"},(0,e.createElement)(r.ButtonGroup,null,t.map((t=>(0,e.createElement)(r.Button,{key:t.id,isPressed:t.id===n.id,variant:"secondary",onClick:()=>{a(t),i(!!t.isLocal),o(t.publicKey),s("")},style:{pointerEvents:l?"none":""}},t.name))),(0,e.createElement)(x,null)))}var k=n(564),S=n.n(k);function D({pattern:t,isLoading:n,isActive:i=!1,globalStyleCSS:o}){const{id:s,preview:l,label:c,scripts:d=[]}=t,u=(0,a.useRef)(),h=(0,a.useRef)(),[p,f]=(0,a.useState)(0),[m,v]=(0,a.useState)(!1),[b,y]=(0,a.useState)({}),[w,E]=(0,a.useState)(!1),[x,C]=(0,a.useState)(0),[k,D]=(0,a.useState)(!1),{previewIframeWidth:I}=g(),R=x,L=1280,_=document?.querySelector(".editor-styles-wrapper");(0,a.useEffect)((()=>{let e;const t=()=>{D(!0),clearTimeout(e),e=setTimeout((()=>{D(!1)}),500)};return window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}}),[]),(0,a.useEffect)((()=>{h.current?.clientWidth&&!k&&C(h.current?.clientWidth)}),[h.current?.clientWidth,k]),(0,a.useEffect)((()=>{if(!m)return;const e=u.current.contentWindow.document;d.forEach((t=>{const n=e.createElement("script");n.defer=!0,n.src=t,e.head.appendChild(n)})),e.body.innerHTML=l,e.head.innerHTML+='<style id="block-active"></style>',e.head.innerHTML+='<style id="pattern-styles"></style>';const t=e.createElement("style");t.innerHTML=o;const n=e.querySelector("head style");e.head.insertBefore(t,n),S()(e.body,(()=>{f(e.body.scrollHeight),E(!0)}))}),[m]),(0,a.useEffect)((()=>{if(!_)return;const e=getComputedStyle(_);e&&y({background:e.backgroundColor,text:e.color})}),[_?.style]),(0,a.useLayoutEffect)((()=>{const e=u.current?.contentWindow?.document;e&&e.querySelector&&e.querySelector("#pattern-styles")&&(e.querySelector("#pattern-styles").innerHTML=`body{background-color:${b?.background};color:${b?.text};}`)}),[b,p]),(0,a.useEffect)((()=>{if(!i)return;const e=u?.current?.contentWindow?.document;S()(e?.body,(()=>{f(e?.body?.scrollHeight)}))}),[I]),(0,a.useEffect)((()=>{const e=u.current.contentWindow.document.body;if(!e)return;const t=Array.from(e.querySelectorAll("*")),n=t?.find((e=>{const{display:t}=getComputedStyle(e);return"none"!==t}));if(n){const t=n.parentElement.clientWidth;n.offsetWidth===t||(e.style.padding="100px",n.style.marginLeft="auto",n.style.marginRight="auto")}}),[x,m]);const M=Math.round(p*(R/L)),N={opacity:n?0:1,height:"350px",display:"flex",flexDirection:"column",justifyContent:M+40<350?"center":""},P=["allow-same-origin"];return i&&P.push("allow-scripts"),(0,e.createElement)("div",{className:"gb-pattern-frame",style:i?{backgroundColor:"none",padding:0}:{}},(0,e.createElement)("div",{ref:h,className:"gb-pattern",style:i?{minHeight:"200px"}:N},!w&&(0,e.createElement)(r.Spinner,null),(0,e.createElement)("div",{style:i?{}:{width:`${R}px`,height:`${M}px`}},(0,e.createElement)("div",{style:i?{}:{height:p+"px",width:L/R*100+"%",transformOrigin:"0 0",transform:`scale( ${R/L} )`}},(0,e.createElement)("iframe",{id:s,onLoad:()=>{v(!0);const e=u.current.contentDocument||u.current.contentWindow.document;e.addEventListener("click",(t=>{const n=t.target;if("A"===n.tagName){const e=n.getAttribute("href");e&&!e.startsWith("#")&&(t.preventDefault(),t.stopPropagation())}i&&f(e.body.scrollHeight)}))},title:c,src:generateBlocksPatternLibrary.patternPreviewUrl,ref:u,style:{height:p+"px",border:"0",pointerEvents:i?"":"none",width:i?I:"1280px",opacity:w?1:0,display:i&&"100%"!==I?"block":"",margin:i&&"100%"!==I?"0 auto":""},tabIndex:"-1",loading:"lazy",sandbox:P.join(" ")})))))}var I=(0,e.createElement)(h.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)(h.Path,{d:"M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z"})),R=window.wp.data,L=window.wp.blockEditor,_=window.wp.blocks,M=window.wp.htmlEntities;function N({label:t,onClick:n,patterns:a,globalStyleData:i,className:o,disabled:s}){return(0,w.applyFilters)("generateblocks.patterns.insertPatternButton",(0,e.createElement)(r.Button,{className:o,variant:"primary",icon:y,onClick:n,disabled:s},t),{label:t,onClick:n,patterns:a,globalStyleData:i,className:o,disabled:s})}function P(e){return e.map((e=>{if(e.attributes&&e.attributes.uniqueId){const t=e.clientId.substr(2,9).replace("-","");e.attributes.uniqueId=t}return e.innerBlocks&&e.innerBlocks.length>0&&(e.innerBlocks=P(e.innerBlocks)),e}))}function B(e){if("core/paragraph"===e?.name){const t=e?.attributes?.content;if("string"==typeof t)return!t.trim();if("object"==typeof t)return!t?.text.trim()}return!1}function T({pattern:t,patternRef:n=null,children:a,showPreview:o=!0,bulkInsertEnabled:s,showTitle:l=!0,globalStyleData:c,closeModal:d}){const{setActivePatternId:u,setScrollPosition:h}=g(),{insertBlocks:p,replaceBlock:f}=(0,R.useDispatch)(L.store),{getBlockInsertionPoint:m,getSelectedBlock:v}=(0,R.useSelect)((e=>e(L.store)),[]),{updateBlockAttributes:b}=(0,R.useDispatch)(L.store);return(0,e.createElement)("div",{className:"gb-pattern-details"},!!l&&(0,e.createElement)("h3",null,(0,M.decodeEntities)(t.label)),(0,e.createElement)("div",{className:"gb-pattern-details__actions"},!s&&(0,e.createElement)(N,{label:(0,i.__)("Insert","generateblocks"),onClick:async e=>{e.stopPropagation();const n=m(),r=v(),a=P((0,_.parse)(t.pattern));var i,o;a.forEach((e=>{e.attributes&&e.clientId&&b(e.clientId,e.attributes)})),B(r)?await f(r.clientId,a):await p(a,null!==(i=n?.index)&&void 0!==i?i:0,null!==(o=n.rootClientId)&&void 0!==o?o:""),d()},patterns:[t],globalStyleData:c}),o&&!s&&(0,e.createElement)(r.Button,{variant:"tertiary",icon:I,label:(0,i.__)("Preview","generateblocks"),showTooltip:!0,onClick:e=>{if(e.stopPropagation(),u(t.id),n){const e=n.current.closest(".gb-pattern-library__content");e&&h(e.scrollTop)}}}),a))}var A=n(184),O=n.n(A);function z({bulkInsertEnabled:t=!1,patterns:n=[],closeModal:o,globalStyleCSS:s,globalStyleData:l}){const c=(0,a.useRef)(),d=(0,a.useRef)(),{activePatternId:u,loading:h,itemsPerPage:p,itemCount:f,setItemCount:m,scrollPosition:v,selectedPatterns:b,selectedPatternsDispatch:y}=g(),w=(0,a.useMemo)((()=>n.filter((e=>e.id===u))[0]||void 0),[u]),E=h?{opacity:0}:{},[x,C]=(0,a.useState)([]),[k,S]=(0,a.useState)(!1);(0,a.useEffect)((()=>{C(n.slice(0,f))}),[f,n]),(0,a.useEffect)((()=>{const e=new IntersectionObserver((e=>{e.forEach((e=>{e.isIntersecting&&S(!0)}))}),{root:null,rootMargin:"0px",threshold:.01});return d.current&&e.observe(d.current),()=>{e&&e.disconnect()}}),[]),(0,a.useEffect)((()=>{k&&(w||m(f+p),S(!1))}),[k]),(0,a.useEffect)((()=>{if(c.current&&!w){const e=c.current.closest(".gb-pattern-library__content");e&&(e.scrollTop=v)}}),[v,w]);const I=(0,a.memo)(T);return(0,e.createElement)(e.Fragment,null,h&&!u&&(0,e.createElement)("div",{className:"loading-library"},(0,e.createElement)(r.Spinner,null),(0,i.__)("Loading library","generateblocks")),!h&&!n.length&&!u&&(0,e.createElement)("div",{className:"loading-library"},(0,i.__)("No patterns found.","generateblocks")),!!w&&(0,e.createElement)(D,{isLoading:h,isActive:!0,pattern:w,globalStyleCSS:s}),(0,e.createElement)("ul",{ref:c,className:O()("patterns-wrapper",t&&"gb-bulk-insert"),style:{...E,display:w?"none":""}},x.map((n=>{var a;const d=null!==(a=b.some((({id:e})=>e===n.id)))&&void 0!==a&&a;return(0,e.createElement)("li",{key:n.id,className:O()("gb-pattern-wrapper","gb-selectable",d&&t&&"is-selected")},t&&(0,e.createElement)(r.Button,{className:"gb-selectable__toggle",label:d?(0,i.__)("Deselect this pattern","generateblocks"):(0,i.__)("Select this pattern","generate-blocks"),onClick:e=>{e.stopPropagation(),y({type:d?"REMOVE":"ADD",pattern:n})}}),(t||d)&&(0,e.createElement)(r.Button,{className:"check",onClick:e=>{e.stopPropagation(),y({type:"REMOVE",pattern:n})},onBlur:e=>e.stopPropagation(),tabIndex:"-1"},(0,e.createElement)("span",{className:"media-modal-icon"}),(0,e.createElement)("span",{className:"screen-reader-text"},(0,i.__)("Deselect","generateblocks"))),(0,e.createElement)(D,{isLoading:h,pattern:n,globalStyleCSS:s}),(0,e.createElement)(I,{pattern:n,patternRef:c,bulkInsertEnabled:t,globalStyleData:l,closeModal:o}))}))),(0,e.createElement)("div",{ref:d,style:{marginTop:"10px"},className:"gblocks-patterns-load-more"}))}var H=window.wp.compose;function V({onChange:t}){const{setSearch:n,activeLibrary:i}=g(),[o,s]=(0,a.useState)(""),l=(0,H.useDebounce)(n,500);return(0,a.useEffect)((()=>{l(o)}),[o]),(0,a.useEffect)((()=>{s("")}),[i?.id]),(0,e.createElement)(r.SearchControl,{value:o,onChange:e=>{t(e),s(e)}})}var j=(0,e.createElement)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,e.createElement)(h.Path,{d:"M5 11.25h14v1.5H5z"})),F=window.ReactDOM;const W="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function G(e){const t=Object.prototype.toString.call(e);return"[object Window]"===t||"[object global]"===t}function q(e){return"nodeType"in e}function K(e){var t,n;return e?G(e)?e:q(e)&&null!=(t=null==(n=e.ownerDocument)?void 0:n.defaultView)?t:window:window}function U(e){const{Document:t}=K(e);return e instanceof t}function X(e){return!G(e)&&e instanceof K(e).HTMLElement}function Y(e){return e instanceof K(e).SVGElement}function $(e){return e?G(e)?e.document:q(e)?U(e)?e:X(e)||Y(e)?e.ownerDocument:document:document:document}const J=W?e.useLayoutEffect:e.useEffect;function Q(t){const n=(0,e.useRef)(t);return J((()=>{n.current=t})),(0,e.useCallback)((function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return null==n.current?void 0:n.current(...t)}),[])}function Z(t,n){void 0===n&&(n=[t]);const r=(0,e.useRef)(t);return J((()=>{r.current!==t&&(r.current=t)}),n),r}function ee(t,n){const r=(0,e.useRef)();return(0,e.useMemo)((()=>{const e=t(r.current);return r.current=e,e}),[...n])}function te(t){const n=Q(t),r=(0,e.useRef)(null),a=(0,e.useCallback)((e=>{e!==r.current&&(null==n||n(e,r.current)),r.current=e}),[]);return[r,a]}function ne(t){const n=(0,e.useRef)();return(0,e.useEffect)((()=>{n.current=t}),[t]),n.current}let re={};function ae(t,n){return(0,e.useMemo)((()=>{if(n)return n;const e=null==re[t]?0:re[t]+1;return re[t]=e,t+"-"+e}),[t,n])}function ie(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return r.reduce(((t,n)=>{const r=Object.entries(n);for(const[n,a]of r){const r=t[n];null!=r&&(t[n]=r+e*a)}return t}),{...t})}}const oe=ie(1),se=ie(-1);function le(e){if(!e)return!1;const{KeyboardEvent:t}=K(e.target);return t&&e instanceof t}function ce(e){if(function(e){if(!e)return!1;const{TouchEvent:t}=K(e.target);return t&&e instanceof t}(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return function(e){return"clientX"in e&&"clientY"in e}(e)?{x:e.clientX,y:e.clientY}:null}const de=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[de.Translate.toString(e),de.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),ue="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function ge(e){return e.matches(ue)?e:e.querySelector(ue)}const he={display:"none"};function pe(e){let{id:n,value:r}=e;return t().createElement("div",{id:n,style:he},r)}function fe(e){let{id:n,announcement:r,ariaLiveType:a="assertive"}=e;return t().createElement("div",{id:n,style:{position:"fixed",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":a,"aria-atomic":!0},r)}const me=(0,e.createContext)(null),ve={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},be={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function ye(n){let{announcements:r=be,container:a,hiddenTextDescribedById:i,screenReaderInstructions:o=ve}=n;const{announce:s,announcement:l}=function(){const[t,n]=(0,e.useState)("");return{announce:(0,e.useCallback)((e=>{null!=e&&n(e)}),[]),announcement:t}}(),c=ae("DndLiveRegion"),[d,u]=(0,e.useState)(!1);if((0,e.useEffect)((()=>{u(!0)}),[]),function(t){const n=(0,e.useContext)(me);(0,e.useEffect)((()=>{if(!n)throw new Error("useDndMonitor must be used within a children of <DndContext>");return n(t)}),[t,n])}((0,e.useMemo)((()=>({onDragStart(e){let{active:t}=e;s(r.onDragStart({active:t}))},onDragMove(e){let{active:t,over:n}=e;r.onDragMove&&s(r.onDragMove({active:t,over:n}))},onDragOver(e){let{active:t,over:n}=e;s(r.onDragOver({active:t,over:n}))},onDragEnd(e){let{active:t,over:n}=e;s(r.onDragEnd({active:t,over:n}))},onDragCancel(e){let{active:t,over:n}=e;s(r.onDragCancel({active:t,over:n}))}})),[s,r])),!d)return null;const g=t().createElement(t().Fragment,null,t().createElement(pe,{id:i,value:o.draggable}),t().createElement(fe,{id:c,announcement:l}));return a?(0,F.createPortal)(g,a):g}var we;function Ee(){}function xe(t,n){return(0,e.useMemo)((()=>({sensor:t,options:null!=n?n:{}})),[t,n])}!function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"}(we||(we={}));const Ce=Object.freeze({x:0,y:0});function ke(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Se(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function De(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Ie(e){let{left:t,top:n,height:r,width:a}=e;return[{x:t,y:n},{x:t+a,y:n},{x:t,y:n+r},{x:t+a,y:n+r}]}function Re(e,t){if(!e||0===e.length)return null;const[n]=e;return t?n[t]:n}function Le(e,t,n){return void 0===t&&(t=e.left),void 0===n&&(n=e.top),{x:t+.5*e.width,y:n+.5*e.height}}const _e=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const a=Le(t,t.left,t.top),i=[];for(const e of r){const{id:t}=e,r=n.get(t);if(r){const n=ke(Le(r),a);i.push({id:t,data:{droppableContainer:e,value:n}})}}return i.sort(Se)};function Me(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),a=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),o=a-r,s=i-n;if(r<a&&n<i){const n=t.width*t.height,r=e.width*e.height,a=o*s;return Number((a/(n+r-a)).toFixed(4))}return 0}const Ne=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const a=[];for(const e of r){const{id:r}=e,i=n.get(r);if(i){const n=Me(i,t);n>0&&a.push({id:r,data:{droppableContainer:e,value:n}})}}return a.sort(De)};function Pe(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Ce}function Be(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return r.reduce(((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x})),{...t})}}const Te=Be(1);const Ae={ignoreTransform:!1};function Oe(e,t){void 0===t&&(t=Ae);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:r}=K(e).getComputedStyle(e);t&&(n=function(e,t,n){const r=function(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}(t);if(!r)return e;const{scaleX:a,scaleY:i,x:o,y:s}=r,l=e.left-o-(1-a)*parseFloat(n),c=e.top-s-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),d=a?e.width/a:e.width,u=i?e.height/i:e.height;return{width:d,height:u,top:c,right:l+d,bottom:c+u,left:l}}(n,t,r))}const{top:r,left:a,width:i,height:o,bottom:s,right:l}=n;return{top:r,left:a,width:i,height:o,bottom:s,right:l}}function ze(e){return Oe(e,{ignoreTransform:!0})}function He(e,t){const n=[];return e?function r(a){if(null!=t&&n.length>=t)return n;if(!a)return n;if(U(a)&&null!=a.scrollingElement&&!n.includes(a.scrollingElement))return n.push(a.scrollingElement),n;if(!X(a)||Y(a))return n;if(n.includes(a))return n;const i=K(e).getComputedStyle(a);return a!==e&&function(e,t){void 0===t&&(t=K(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some((e=>{const r=t[e];return"string"==typeof r&&n.test(r)}))}(a,i)&&n.push(a),function(e,t){return void 0===t&&(t=K(e).getComputedStyle(e)),"fixed"===t.position}(a,i)?n:r(a.parentNode)}(e):n}function Ve(e){const[t]=He(e,1);return null!=t?t:null}function je(e){return W&&e?G(e)?e:q(e)?U(e)||e===$(e).scrollingElement?window:X(e)?e:null:null:null}function Fe(e){return G(e)?e.scrollX:e.scrollLeft}function We(e){return G(e)?e.scrollY:e.scrollTop}function Ge(e){return{x:Fe(e),y:We(e)}}var qe;function Ke(e){return!(!W||!e)&&e===document.scrollingElement}function Ue(e){const t={x:0,y:0},n=Ke(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}!function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"}(qe||(qe={}));const Xe={x:.2,y:.2};function Ye(e,t,n,r,a){let{top:i,left:o,right:s,bottom:l}=n;void 0===r&&(r=10),void 0===a&&(a=Xe);const{isTop:c,isBottom:d,isLeft:u,isRight:g}=Ue(e),h={x:0,y:0},p={x:0,y:0},f=t.height*a.y,m=t.width*a.x;return!c&&i<=t.top+f?(h.y=qe.Backward,p.y=r*Math.abs((t.top+f-i)/f)):!d&&l>=t.bottom-f&&(h.y=qe.Forward,p.y=r*Math.abs((t.bottom-f-l)/f)),!g&&s>=t.right-m?(h.x=qe.Forward,p.x=r*Math.abs((t.right-m-s)/m)):!u&&o<=t.left+m&&(h.x=qe.Backward,p.x=r*Math.abs((t.left+m-o)/m)),{direction:h,speed:p}}function $e(e){if(e===document.scrollingElement){const{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}const{top:t,left:n,right:r,bottom:a}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:a,width:e.clientWidth,height:e.clientHeight}}function Je(e){return e.reduce(((e,t)=>oe(e,Ge(t))),Ce)}const Qe=[["x",["left","right"],function(e){return e.reduce(((e,t)=>e+Fe(t)),0)}],["y",["top","bottom"],function(e){return e.reduce(((e,t)=>e+We(t)),0)}]];class Ze{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=He(t),r=Je(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[e,t,a]of Qe)for(const i of t)Object.defineProperty(this,i,{get:()=>{const t=a(n),o=r[e]-t;return this.rect[i]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class et{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach((e=>{var t;return null==(t=this.target)?void 0:t.removeEventListener(...e)}))},this.target=e}add(e,t,n){var r;null==(r=this.target)||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function tt(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return"number"==typeof t?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t&&r>t.y}var nt,rt;function at(e){e.preventDefault()}function it(e){e.stopPropagation()}!function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"}(nt||(nt={})),function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter"}(rt||(rt={}));const ot={start:[rt.Space,rt.Enter],cancel:[rt.Esc],end:[rt.Space,rt.Enter]},st=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case rt.Right:return{...n,x:n.x+25};case rt.Left:return{...n,x:n.x-25};case rt.Down:return{...n,y:n.y+25};case rt.Up:return{...n,y:n.y-25}}};class lt{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:t}}=e;this.props=e,this.listeners=new et($(t)),this.windowListeners=new et(K(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(nt.Resize,this.handleCancel),this.windowListeners.add(nt.VisibilityChange,this.handleCancel),setTimeout((()=>this.listeners.add(nt.Keydown,this.handleKeyDown)))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&function(e,t){if(void 0===t&&(t=Oe),!e)return;const{top:n,left:r,bottom:a,right:i}=t(e);Ve(e)&&(a<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}(n),t(Ce)}handleKeyDown(e){if(le(e)){const{active:t,context:n,options:r}=this.props,{keyboardCodes:a=ot,coordinateGetter:i=st,scrollBehavior:o="smooth"}=r,{code:s}=e;if(a.end.includes(s))return void this.handleEnd(e);if(a.cancel.includes(s))return void this.handleCancel(e);const{collisionRect:l}=n.current,c=l?{x:l.left,y:l.top}:Ce;this.referenceCoordinates||(this.referenceCoordinates=c);const d=i(e,{active:t,context:n.current,currentCoordinates:c});if(d){const t=se(d,c),r={x:0,y:0},{scrollableAncestors:a}=n.current;for(const n of a){const a=e.code,{isTop:i,isRight:s,isLeft:l,isBottom:c,maxScroll:u,minScroll:g}=Ue(n),h=$e(n),p={x:Math.min(a===rt.Right?h.right-h.width/2:h.right,Math.max(a===rt.Right?h.left:h.left+h.width/2,d.x)),y:Math.min(a===rt.Down?h.bottom-h.height/2:h.bottom,Math.max(a===rt.Down?h.top:h.top+h.height/2,d.y))},f=a===rt.Right&&!s||a===rt.Left&&!l,m=a===rt.Down&&!c||a===rt.Up&&!i;if(f&&p.x!==d.x){const e=n.scrollLeft+t.x,i=a===rt.Right&&e<=u.x||a===rt.Left&&e>=g.x;if(i&&!t.y)return void n.scrollTo({left:e,behavior:o});r.x=i?n.scrollLeft-e:a===rt.Right?n.scrollLeft-u.x:n.scrollLeft-g.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}if(m&&p.y!==d.y){const e=n.scrollTop+t.y,i=a===rt.Down&&e<=u.y||a===rt.Up&&e>=g.y;if(i&&!t.x)return void n.scrollTo({top:e,behavior:o});r.y=i?n.scrollTop-e:a===rt.Down?n.scrollTop-u.y:n.scrollTop-g.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,oe(se(d,this.referenceCoordinates),r))}}}handleMove(e,t){const{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){const{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){const{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function ct(e){return Boolean(e&&"distance"in e)}function dt(e){return Boolean(e&&"delay"in e)}lt.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=ot,onActivation:a}=t,{active:i}=n;const{code:o}=e.nativeEvent;if(r.start.includes(o)){const t=i.activatorNode.current;return!(t&&e.target!==t||(e.preventDefault(),null==a||a({event:e.nativeEvent}),0))}return!1}}];class ut{constructor(e,t,n){var r;void 0===n&&(n=function(e){const{EventTarget:t}=K(e);return e instanceof t?e:$(e)}(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;const{event:a}=e,{target:i}=a;this.props=e,this.events=t,this.document=$(i),this.documentListeners=new et(this.document),this.listeners=new et(n),this.windowListeners=new et(K(i)),this.initialCoordinates=null!=(r=ce(a))?r:Ce,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),this.windowListeners.add(nt.Resize,this.handleCancel),this.windowListeners.add(nt.DragStart,at),this.windowListeners.add(nt.VisibilityChange,this.handleCancel),this.windowListeners.add(nt.ContextMenu,at),this.documentListeners.add(nt.Keydown,this.handleKeydown),t){if(null!=n&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(dt(t))return void(this.timeoutId=setTimeout(this.handleStart,t.delay));if(ct(t))return}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(nt.Click,it,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(nt.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:r,props:a}=this,{onMove:i,options:{activationConstraint:o}}=a;if(!r)return;const s=null!=(t=ce(e))?t:Ce,l=se(r,s);if(!n&&o){if(ct(o)){if(null!=o.tolerance&&tt(l,o.tolerance))return this.handleCancel();if(tt(l,o.distance))return this.handleStart()}return dt(o)&&tt(l,o.tolerance)?this.handleCancel():void 0}e.cancelable&&e.preventDefault(),i(s)}handleEnd(){const{onEnd:e}=this.props;this.detach(),e()}handleCancel(){const{onCancel:e}=this.props;this.detach(),e()}handleKeydown(e){e.code===rt.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const gt={move:{name:"pointermove"},end:{name:"pointerup"}};class ht extends ut{constructor(e){const{event:t}=e,n=$(t.target);super(e,gt,n)}}ht.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!(!n.isPrimary||0!==n.button||(null==r||r({event:n}),0))}}];const pt={move:{name:"mousemove"},end:{name:"mouseup"}};var ft;!function(e){e[e.RightClick=2]="RightClick"}(ft||(ft={})),class extends ut{constructor(e){super(e,pt,$(e.event.target))}}.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==ft.RightClick&&(null==r||r({event:n}),!0)}}];const mt={move:{name:"touchmove"},end:{name:"touchend"}};var vt,bt;(class extends ut{constructor(e){super(e,mt)}static setup(){return window.addEventListener(mt.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(mt.move.name,e)};function e(){}}}).activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:a}=n;return!(a.length>1||(null==r||r({event:n}),0))}}],function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"}(vt||(vt={})),function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"}(bt||(bt={}));const yt={x:{[qe.Backward]:!1,[qe.Forward]:!1},y:{[qe.Backward]:!1,[qe.Forward]:!1}};var wt,Et;!function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"}(wt||(wt={})),function(e){e.Optimized="optimized"}(Et||(Et={}));const xt=new Map;function Ct(e,t){return ee((n=>e?n||("function"==typeof t?t(e):e):null),[t,e])}function kt(t){let{callback:n,disabled:r}=t;const a=Q(n),i=(0,e.useMemo)((()=>{if(r||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(a)}),[r]);return(0,e.useEffect)((()=>()=>null==i?void 0:i.disconnect()),[i]),i}function St(e){return new Ze(Oe(e),e)}function Dt(t,n,r){void 0===n&&(n=St);const[a,i]=(0,e.useReducer)((function(e){if(!t)return null;var a;if(!1===t.isConnected)return null!=(a=null!=e?e:r)?a:null;const i=n(t);return JSON.stringify(e)===JSON.stringify(i)?e:i}),null),o=function(t){let{callback:n,disabled:r}=t;const a=Q(n),i=(0,e.useMemo)((()=>{if(r||"undefined"==typeof window||void 0===window.MutationObserver)return;const{MutationObserver:e}=window;return new e(a)}),[a,r]);return(0,e.useEffect)((()=>()=>null==i?void 0:i.disconnect()),[i]),i}({callback(e){if(t)for(const n of e){const{type:e,target:r}=n;if("childList"===e&&r instanceof HTMLElement&&r.contains(t)){i();break}}}}),s=kt({callback:i});return J((()=>{i(),t?(null==s||s.observe(t),null==o||o.observe(document.body,{childList:!0,subtree:!0})):(null==s||s.disconnect(),null==o||o.disconnect())}),[t]),a}const It=[];function Rt(t,n){void 0===n&&(n=[]);const r=(0,e.useRef)(null);return(0,e.useEffect)((()=>{r.current=null}),n),(0,e.useEffect)((()=>{const e=t!==Ce;e&&!r.current&&(r.current=t),!e&&r.current&&(r.current=null)}),[t]),r.current?se(t,r.current):Ce}function Lt(t){return(0,e.useMemo)((()=>t?function(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}(t):null),[t])}const _t=[];const Mt=[{sensor:ht,options:{}},{sensor:lt,options:{}}],Nt={current:{}},Pt={draggable:{measure:ze},droppable:{measure:ze,strategy:wt.WhileDragging,frequency:Et.Optimized},dragOverlay:{measure:Oe}};class Bt extends Map{get(e){var t;return null!=e&&null!=(t=super.get(e))?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter((e=>{let{disabled:t}=e;return!t}))}getNodeFor(e){var t,n;return null!=(t=null==(n=this.get(e))?void 0:n.node.current)?t:void 0}}const Tt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Bt,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Ee},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Pt,measureDroppableContainers:Ee,windowRect:null,measuringScheduled:!1},At={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Ee,draggableNodes:new Map,over:null,measureDroppableContainers:Ee},Ot=(0,e.createContext)(At),zt=(0,e.createContext)(Tt);function Ht(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Bt}}}function Vt(e,t){switch(t.type){case we.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case we.DragMove:return e.draggable.active?{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}}:e;case we.DragEnd:case we.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case we.RegisterDroppable:{const{element:n}=t,{id:r}=n,a=new Bt(e.droppable.containers);return a.set(r,n),{...e,droppable:{...e.droppable,containers:a}}}case we.SetDroppableDisabled:{const{id:n,key:r,disabled:a}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const o=new Bt(e.droppable.containers);return o.set(n,{...i,disabled:a}),{...e,droppable:{...e.droppable,containers:o}}}case we.UnregisterDroppable:{const{id:n,key:r}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;const i=new Bt(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function jt(t){let{disabled:n}=t;const{active:r,activatorEvent:a,draggableNodes:i}=(0,e.useContext)(Ot),o=ne(a),s=ne(null==r?void 0:r.id);return(0,e.useEffect)((()=>{if(!n&&!a&&o&&null!=s){if(!le(o))return;if(document.activeElement===o.target)return;const e=i.get(s);if(!e)return;const{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame((()=>{for(const e of[t.current,n.current]){if(!e)continue;const t=ge(e);if(t){t.focus();break}}}))}}),[a,n,i,s,o]),null}const Ft=(0,e.createContext)({...Ce,scaleX:1,scaleY:1});var Wt;!function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"}(Wt||(Wt={}));const Gt=(0,e.memo)((function(n){var r,a,i,o;let{id:s,accessibility:l,autoScroll:c=!0,children:d,sensors:u=Mt,collisionDetection:g=Ne,measuring:h,modifiers:p,...f}=n;const m=(0,e.useReducer)(Vt,void 0,Ht),[v,b]=m,[y,w]=function(){const[t]=(0,e.useState)((()=>new Set)),n=(0,e.useCallback)((e=>(t.add(e),()=>t.delete(e))),[t]);return[(0,e.useCallback)((e=>{let{type:n,event:r}=e;t.forEach((e=>{var t;return null==(t=e[n])?void 0:t.call(e,r)}))}),[t]),n]}(),[E,x]=(0,e.useState)(Wt.Uninitialized),C=E===Wt.Initialized,{draggable:{active:k,nodes:S,translate:D},droppable:{containers:I}}=v,R=k?S.get(k):null,L=(0,e.useRef)({initial:null,translated:null}),_=(0,e.useMemo)((()=>{var e;return null!=k?{id:k,data:null!=(e=null==R?void 0:R.data)?e:Nt,rect:L}:null}),[k,R]),M=(0,e.useRef)(null),[N,P]=(0,e.useState)(null),[B,T]=(0,e.useState)(null),A=Z(f,Object.values(f)),O=ae("DndDescribedBy",s),z=(0,e.useMemo)((()=>I.getEnabled()),[I]),H=(V=h,(0,e.useMemo)((()=>({draggable:{...Pt.draggable,...null==V?void 0:V.draggable},droppable:{...Pt.droppable,...null==V?void 0:V.droppable},dragOverlay:{...Pt.dragOverlay,...null==V?void 0:V.dragOverlay}})),[null==V?void 0:V.draggable,null==V?void 0:V.droppable,null==V?void 0:V.dragOverlay]));var V;const{droppableRects:j,measureDroppableContainers:G,measuringScheduled:q}=function(t,n){let{dragging:r,dependencies:a,config:i}=n;const[o,s]=(0,e.useState)(null),{frequency:l,measure:c,strategy:d}=i,u=(0,e.useRef)(t),g=function(){switch(d){case wt.Always:return!1;case wt.BeforeDragging:return r;default:return!r}}(),h=Z(g),p=(0,e.useCallback)((function(e){void 0===e&&(e=[]),h.current||s((t=>null===t?e:t.concat(e.filter((e=>!t.includes(e))))))}),[h]),f=(0,e.useRef)(null),m=ee((e=>{if(g&&!r)return xt;if(!e||e===xt||u.current!==t||null!=o){const e=new Map;for(let n of t){if(!n)continue;if(o&&o.length>0&&!o.includes(n.id)&&n.rect.current){e.set(n.id,n.rect.current);continue}const t=n.node.current,r=t?new Ze(c(t),t):null;n.rect.current=r,r&&e.set(n.id,r)}return e}return e}),[t,o,r,g,c]);return(0,e.useEffect)((()=>{u.current=t}),[t]),(0,e.useEffect)((()=>{g||p()}),[r,g]),(0,e.useEffect)((()=>{o&&o.length>0&&s(null)}),[JSON.stringify(o)]),(0,e.useEffect)((()=>{g||"number"!=typeof l||null!==f.current||(f.current=setTimeout((()=>{p(),f.current=null}),l))}),[l,g,p,...a]),{droppableRects:m,measureDroppableContainers:p,measuringScheduled:null!=o}}(z,{dragging:C,dependencies:[D.x,D.y],config:H.droppable}),U=function(e,t){const n=null!==t?e.get(t):void 0,r=n?n.node.current:null;return ee((e=>{var n;return null===t?null:null!=(n=null!=r?r:e)?n:null}),[r,t])}(S,k),Y=(0,e.useMemo)((()=>B?ce(B):null),[B]),$=function(){const e=!1===(null==N?void 0:N.autoScrollEnabled),t="object"==typeof c?!1===c.enabled:!1===c,n=C&&!e&&!t;return"object"==typeof c?{...c,enabled:n}:{enabled:n}}(),Q=function(e,t){return Ct(e,t)}(U,H.draggable.measure);!function(t){let{activeNode:n,measure:r,initialRect:a,config:i=!0}=t;const o=(0,e.useRef)(!1),{x:s,y:l}="boolean"==typeof i?{x:i,y:i}:i;J((()=>{if(!s&&!l||!n)return void(o.current=!1);if(o.current||!a)return;const e=null==n?void 0:n.node.current;if(!e||!1===e.isConnected)return;const t=Pe(r(e),a);if(s||(t.x=0),l||(t.y=0),o.current=!0,Math.abs(t.x)>0||Math.abs(t.y)>0){const n=Ve(e);n&&n.scrollBy({top:t.y,left:t.x})}}),[n,s,l,a,r])}({activeNode:k?S.get(k):null,config:$.layoutShiftCompensation,initialRect:Q,measure:H.draggable.measure});const re=Dt(U,H.draggable.measure,Q),ie=Dt(U?U.parentElement:null),se=(0,e.useRef)({activatorEvent:null,active:null,activeNode:U,collisionRect:null,collisions:null,droppableRects:j,draggableNodes:S,draggingNode:null,draggingNodeRect:null,droppableContainers:I,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),le=I.getNodeFor(null==(r=se.current.over)?void 0:r.id),de=function(t){let{measure:n}=t;const[r,a]=(0,e.useState)(null),i=kt({callback:(0,e.useCallback)((e=>{for(const{target:t}of e)if(X(t)){a((e=>{const r=n(t);return e?{...e,width:r.width,height:r.height}:r}));break}}),[n])}),o=(0,e.useCallback)((e=>{const t=function(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return X(t)?t:e}(e);null==i||i.disconnect(),t&&(null==i||i.observe(t)),a(t?n(t):null)}),[n,i]),[s,l]=te(o);return(0,e.useMemo)((()=>({nodeRef:s,rect:r,setRef:l})),[r,s,l])}({measure:H.dragOverlay.measure}),ue=null!=(a=de.nodeRef.current)?a:U,ge=C?null!=(i=de.rect)?i:re:null,he=Boolean(de.nodeRef.current&&de.rect),pe=Pe(fe=he?null:re,Ct(fe));var fe;const ve=Lt(ue?K(ue):null),be=function(t){const n=(0,e.useRef)(t),r=ee((e=>t?e&&e!==It&&t&&n.current&&t.parentNode===n.current.parentNode?e:He(t):It),[t]);return(0,e.useEffect)((()=>{n.current=t}),[t]),r}(C?null!=le?le:U:null),Ee=function(t,n){void 0===n&&(n=Oe);const[r]=t,a=Lt(r?K(r):null),[i,o]=(0,e.useReducer)((function(){return t.length?t.map((e=>Ke(e)?a:new Ze(n(e),e))):_t}),_t),s=kt({callback:o});return t.length>0&&i===_t&&o(),J((()=>{t.length?t.forEach((e=>null==s?void 0:s.observe(e))):(null==s||s.disconnect(),o())}),[t]),i}(be),xe=function(e,t){let{transform:n,...r}=t;return null!=e&&e.length?e.reduce(((e,t)=>t({transform:e,...r})),n):n}(p,{transform:{x:D.x-pe.x,y:D.y-pe.y,scaleX:1,scaleY:1},activatorEvent:B,active:_,activeNodeRect:re,containerNodeRect:ie,draggingNodeRect:ge,over:se.current.over,overlayNodeRect:de.rect,scrollableAncestors:be,scrollableAncestorRects:Ee,windowRect:ve}),ke=Y?oe(Y,D):null,Se=function(t){const[n,r]=(0,e.useState)(null),a=(0,e.useRef)(t),i=(0,e.useCallback)((e=>{const t=je(e.target);t&&r((e=>e?(e.set(t,Ge(t)),new Map(e)):null))}),[]);return(0,e.useEffect)((()=>{const e=a.current;if(t!==e){n(e);const o=t.map((e=>{const t=je(e);return t?(t.addEventListener("scroll",i,{passive:!0}),[t,Ge(t)]):null})).filter((e=>null!=e));r(o.length?new Map(o):null),a.current=t}return()=>{n(t),n(e)};function n(e){e.forEach((e=>{const t=je(e);null==t||t.removeEventListener("scroll",i)}))}}),[i,t]),(0,e.useMemo)((()=>t.length?n?Array.from(n.values()).reduce(((e,t)=>oe(e,t)),Ce):Je(t):Ce),[t,n])}(be),De=Rt(Se),Ie=Rt(Se,[re]),Le=oe(xe,De),_e=ge?Te(ge,xe):null,Me=_&&_e?g({active:_,collisionRect:_e,droppableRects:j,droppableContainers:z,pointerCoordinates:ke}):null,Be=Re(Me,"id"),[Ae,ze]=(0,e.useState)(null),Fe=function(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}(he?xe:oe(xe,Ie),null!=(o=null==Ae?void 0:Ae.rect)?o:null,re),We=(0,e.useCallback)(((e,t)=>{let{sensor:n,options:r}=t;if(null==M.current)return;const a=S.get(M.current);if(!a)return;const i=e.nativeEvent,o=new n({active:M.current,activeNode:a,event:i,options:r,context:se,onStart(e){const t=M.current;if(null==t)return;const n=S.get(t);if(!n)return;const{onDragStart:r}=A.current,a={active:{id:t,data:n.data,rect:L}};(0,F.unstable_batchedUpdates)((()=>{null==r||r(a),x(Wt.Initializing),b({type:we.DragStart,initialCoordinates:e,active:t}),y({type:"onDragStart",event:a})}))},onMove(e){b({type:we.DragMove,coordinates:e})},onEnd:s(we.DragEnd),onCancel:s(we.DragCancel)});function s(e){return async function(){const{active:t,collisions:n,over:r,scrollAdjustedTranslate:a}=se.current;let o=null;if(t&&a){const{cancelDrop:s}=A.current;o={activatorEvent:i,active:t,collisions:n,delta:a,over:r},e===we.DragEnd&&"function"==typeof s&&await Promise.resolve(s(o))&&(e=we.DragCancel)}M.current=null,(0,F.unstable_batchedUpdates)((()=>{b({type:e}),x(Wt.Uninitialized),ze(null),P(null),T(null);const t=e===we.DragEnd?"onDragEnd":"onDragCancel";if(o){const e=A.current[t];null==e||e(o),y({type:t,event:o})}}))}}(0,F.unstable_batchedUpdates)((()=>{P(o),T(e.nativeEvent)}))}),[S]),Ue=(0,e.useCallback)(((e,t)=>(n,r)=>{const a=n.nativeEvent,i=S.get(r);if(null!==M.current||!i||a.dndKit||a.defaultPrevented)return;const o={active:i};!0===e(n,t.options,o)&&(a.dndKit={capturedBy:t.sensor},M.current=r,We(n,t))}),[S,We]),Xe=function(t,n){return(0,e.useMemo)((()=>t.reduce(((e,t)=>{const{sensor:r}=t;return[...e,...r.activators.map((e=>({eventName:e.eventName,handler:n(e.handler,t)})))]}),[])),[t,n])}(u,Ue);!function(t){(0,e.useEffect)((()=>{if(!W)return;const e=t.map((e=>{let{sensor:t}=e;return null==t.setup?void 0:t.setup()}));return()=>{for(const t of e)null==t||t()}}),t.map((e=>{let{sensor:t}=e;return t})))}(u),J((()=>{re&&E===Wt.Initializing&&x(Wt.Initialized)}),[re,E]),(0,e.useEffect)((()=>{const{onDragMove:e}=A.current,{active:t,activatorEvent:n,collisions:r,over:a}=se.current;if(!t||!n)return;const i={active:t,activatorEvent:n,collisions:r,delta:{x:Le.x,y:Le.y},over:a};(0,F.unstable_batchedUpdates)((()=>{null==e||e(i),y({type:"onDragMove",event:i})}))}),[Le.x,Le.y]),(0,e.useEffect)((()=>{const{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:a}=se.current;if(!e||null==M.current||!t||!a)return;const{onDragOver:i}=A.current,o=r.get(Be),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,l={active:e,activatorEvent:t,collisions:n,delta:{x:a.x,y:a.y},over:s};(0,F.unstable_batchedUpdates)((()=>{ze(s),null==i||i(l),y({type:"onDragOver",event:l})}))}),[Be]),J((()=>{se.current={activatorEvent:B,active:_,activeNode:U,collisionRect:_e,collisions:Me,droppableRects:j,draggableNodes:S,draggingNode:ue,draggingNodeRect:ge,droppableContainers:I,over:Ae,scrollableAncestors:be,scrollAdjustedTranslate:Le},L.current={initial:ge,translated:_e}}),[_,U,Me,_e,S,ue,ge,j,I,Ae,be,Le]),function(t){let{acceleration:n,activator:r=vt.Pointer,canScroll:a,draggingRect:i,enabled:o,interval:s=5,order:l=bt.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:u,delta:g,threshold:h}=t;const p=function(e){let{delta:t,disabled:n}=e;const r=ne(t);return ee((e=>{if(n||!r||!e)return yt;const a=Math.sign(t.x-r.x),i=Math.sign(t.y-r.y);return{x:{[qe.Backward]:e.x[qe.Backward]||-1===a,[qe.Forward]:e.x[qe.Forward]||1===a},y:{[qe.Backward]:e.y[qe.Backward]||-1===i,[qe.Forward]:e.y[qe.Forward]||1===i}}}),[n,t,r])}({delta:g,disabled:!o}),[f,m]=function(){const t=(0,e.useRef)(null);return[(0,e.useCallback)(((e,n)=>{t.current=setInterval(e,n)}),[]),(0,e.useCallback)((()=>{null!==t.current&&(clearInterval(t.current),t.current=null)}),[])]}(),v=(0,e.useRef)({x:0,y:0}),b=(0,e.useRef)({x:0,y:0}),y=(0,e.useMemo)((()=>{switch(r){case vt.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case vt.DraggableRect:return i}}),[r,i,c]),w=(0,e.useRef)(null),E=(0,e.useCallback)((()=>{const e=w.current;if(!e)return;const t=v.current.x*b.current.x,n=v.current.y*b.current.y;e.scrollBy(t,n)}),[]),x=(0,e.useMemo)((()=>l===bt.TreeOrder?[...d].reverse():d),[l,d]);(0,e.useEffect)((()=>{if(o&&d.length&&y){for(const e of x){if(!1===(null==a?void 0:a(e)))continue;const t=d.indexOf(e),r=u[t];if(!r)continue;const{direction:i,speed:o}=Ye(e,r,y,n,h);for(const e of["x","y"])p[e][i[e]]||(o[e]=0,i[e]=0);if(o.x>0||o.y>0)return m(),w.current=e,f(E,s),v.current=o,void(b.current=i)}v.current={x:0,y:0},b.current={x:0,y:0},m()}else m()}),[n,E,a,m,o,s,JSON.stringify(y),JSON.stringify(p),f,d,x,u,JSON.stringify(h)])}({...$,delta:D,draggingRect:_e,pointerCoordinates:ke,scrollableAncestors:be,scrollableAncestorRects:Ee});const $e=(0,e.useMemo)((()=>({active:_,activeNode:U,activeNodeRect:re,activatorEvent:B,collisions:Me,containerNodeRect:ie,dragOverlay:de,draggableNodes:S,droppableContainers:I,droppableRects:j,over:Ae,measureDroppableContainers:G,scrollableAncestors:be,scrollableAncestorRects:Ee,measuringConfiguration:H,measuringScheduled:q,windowRect:ve})),[_,U,re,B,Me,ie,de,S,I,j,Ae,G,be,Ee,H,q,ve]),Qe=(0,e.useMemo)((()=>({activatorEvent:B,activators:Xe,active:_,activeNodeRect:re,ariaDescribedById:{draggable:O},dispatch:b,draggableNodes:S,over:Ae,measureDroppableContainers:G})),[B,Xe,_,re,b,O,S,Ae,G]);return t().createElement(me.Provider,{value:w},t().createElement(Ot.Provider,{value:Qe},t().createElement(zt.Provider,{value:$e},t().createElement(Ft.Provider,{value:Fe},d)),t().createElement(jt,{disabled:!1===(null==l?void 0:l.restoreFocus)})),t().createElement(ye,{...l,hiddenTextDescribedById:O}))})),qt=(0,e.createContext)(null),Kt="button",Ut="Droppable";const Xt="Droppable",Yt={timeout:25};function $t(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function Jt(e,t){return e.reduce(((e,n,r)=>{const a=t.get(n);return a&&(e[r]=a),e}),Array(e.length))}function Qt(e){return null!==e&&e>=0}const Zt=e=>{let{rects:t,activeIndex:n,overIndex:r,index:a}=e;const i=$t(t,r,n),o=t[a],s=i[a];return s&&o?{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}:null},en={scaleX:1,scaleY:1},tn=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:a,rects:i,overIndex:o}=e;const s=null!=(t=i[n])?t:r;if(!s)return null;if(a===n){const e=i[o];return e?{x:0,y:n<o?e.top+e.height-(s.top+s.height):e.top-s.top,...en}:null}const l=function(e,t,n){const r=e[t],a=e[t-1],i=e[t+1];return r?n<t?a?r.top-(a.top+a.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):a?r.top-(a.top+a.height):0:0}(i,a,n);return a>n&&a<=o?{x:0,y:-s.height-l,...en}:a<n&&a>=o?{x:0,y:s.height+l,...en}:{x:0,y:0,...en}},nn="Sortable",rn=t().createContext({activeIndex:-1,containerId:nn,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Zt,disabled:{draggable:!1,droppable:!1}});function an(n){let{children:r,id:a,items:i,strategy:o=Zt,disabled:s=!1}=n;const{active:l,dragOverlay:c,droppableRects:d,over:u,measureDroppableContainers:g}=(0,e.useContext)(zt),h=ae(nn,a),p=Boolean(null!==c.rect),f=(0,e.useMemo)((()=>i.map((e=>"object"==typeof e&&"id"in e?e.id:e))),[i]),m=null!=l,v=l?f.indexOf(l.id):-1,b=u?f.indexOf(u.id):-1,y=(0,e.useRef)(f),w=!function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(f,y.current),E=-1!==b&&-1===v||w,x=function(e){return"boolean"==typeof e?{draggable:e,droppable:e}:e}(s);J((()=>{w&&m&&g(f)}),[w,f,m,g]),(0,e.useEffect)((()=>{y.current=f}),[f]);const C=(0,e.useMemo)((()=>({activeIndex:v,containerId:h,disabled:x,disableTransforms:E,items:f,overIndex:b,useDragOverlay:p,sortedRects:Jt(f,d),strategy:o})),[v,h,x.draggable,x.droppable,E,f,b,d,p,o]);return t().createElement(rn.Provider,{value:C},r)}const on=e=>{let{id:t,items:n,activeIndex:r,overIndex:a}=e;return $t(n,r,a).indexOf(t)},sn=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:a,items:i,newIndex:o,previousItems:s,previousContainerId:l,transition:c}=e;return!(!c||!r||s!==i&&a===o||!n&&(o===a||t!==l))},ln={duration:200,easing:"ease"},cn="transform",dn=de.Transition.toString({property:cn,duration:0,easing:"linear"}),un={roleDescription:"sortable"};function gn(t){let{animateLayoutChanges:n=sn,attributes:r,disabled:a,data:i,getNewIndex:o=on,id:s,strategy:l,resizeObserverConfig:c,transition:d=ln}=t;const{items:u,containerId:g,activeIndex:h,disabled:p,disableTransforms:f,sortedRects:m,overIndex:v,useDragOverlay:b,strategy:y}=(0,e.useContext)(rn),w=function(e,t){var n,r;return"boolean"==typeof e?{draggable:e,droppable:!1}:{draggable:null!=(n=null==e?void 0:e.draggable)?n:t.draggable,droppable:null!=(r=null==e?void 0:e.droppable)?r:t.droppable}}(a,p),E=u.indexOf(s),x=(0,e.useMemo)((()=>({sortable:{containerId:g,index:E,items:u},...i})),[g,i,E,u]),C=(0,e.useMemo)((()=>u.slice(u.indexOf(s))),[u,s]),{rect:k,node:S,isOver:D,setNodeRef:I}=function(t){let{data:n,disabled:r=!1,id:a,resizeObserverConfig:i}=t;const o=ae(Xt),{active:s,dispatch:l,over:c,measureDroppableContainers:d}=(0,e.useContext)(Ot),u=(0,e.useRef)({disabled:r}),g=(0,e.useRef)(!1),h=(0,e.useRef)(null),p=(0,e.useRef)(null),{disabled:f,updateMeasurementsFor:m,timeout:v}={...Yt,...i},b=Z(null!=m?m:a),y=kt({callback:(0,e.useCallback)((()=>{g.current?(null!=p.current&&clearTimeout(p.current),p.current=setTimeout((()=>{d(Array.isArray(b.current)?b.current:[b.current]),p.current=null}),v)):g.current=!0}),[v]),disabled:f||!s}),w=(0,e.useCallback)(((e,t)=>{y&&(t&&(y.unobserve(t),g.current=!1),e&&y.observe(e))}),[y]),[E,x]=te(w),C=Z(n);return(0,e.useEffect)((()=>{y&&E.current&&(y.disconnect(),g.current=!1,y.observe(E.current))}),[E,y]),J((()=>(l({type:we.RegisterDroppable,element:{id:a,key:o,disabled:r,node:E,rect:h,data:C}}),()=>l({type:we.UnregisterDroppable,key:o,id:a}))),[a]),(0,e.useEffect)((()=>{r!==u.current.disabled&&(l({type:we.SetDroppableDisabled,id:a,key:o,disabled:r}),u.current.disabled=r)}),[a,o,r,l]),{active:s,rect:h,isOver:(null==c?void 0:c.id)===a,node:E,over:c,setNodeRef:x}}({id:s,data:x,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:R,activatorEvent:L,activeNodeRect:_,attributes:M,setNodeRef:N,listeners:P,isDragging:B,over:T,setActivatorNodeRef:A,transform:O}=function(t){let{id:n,data:r,disabled:a=!1,attributes:i}=t;const o=ae(Ut),{activators:s,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:u,draggableNodes:g,over:h}=(0,e.useContext)(Ot),{role:p=Kt,roleDescription:f="draggable",tabIndex:m=0}=null!=i?i:{},v=(null==c?void 0:c.id)===n,b=(0,e.useContext)(v?Ft:qt),[y,w]=te(),[E,x]=te(),C=function(t,n){return(0,e.useMemo)((()=>t.reduce(((e,t)=>{let{eventName:r,handler:a}=t;return e[r]=e=>{a(e,n)},e}),{})),[t,n])}(s,n),k=Z(r);return J((()=>(g.set(n,{id:n,key:o,node:y,activatorNode:E,data:k}),()=>{const e=g.get(n);e&&e.key===o&&g.delete(n)})),[g,n]),{active:c,activatorEvent:l,activeNodeRect:d,attributes:(0,e.useMemo)((()=>({role:p,tabIndex:m,"aria-disabled":a,"aria-pressed":!(!v||p!==Kt)||void 0,"aria-roledescription":f,"aria-describedby":u.draggable})),[a,p,m,v,f,u.draggable]),isDragging:v,listeners:a?void 0:C,node:y,over:h,setNodeRef:w,setActivatorNodeRef:x,transform:b}}({id:s,data:x,attributes:{...un,...r},disabled:w.draggable}),z=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(0,e.useMemo)((()=>e=>{n.forEach((t=>t(e)))}),n)}(I,N),H=Boolean(R),V=H&&!f&&Qt(h)&&Qt(v),j=!b&&B,F=j&&V?O:null,W=V?null!=F?F:(null!=l?l:y)({rects:m,activeNodeRect:_,activeIndex:h,overIndex:v,index:E}):null,G=Qt(h)&&Qt(v)?o({id:s,items:u,activeIndex:h,overIndex:v}):E,q=null==R?void 0:R.id,K=(0,e.useRef)({activeId:q,items:u,newIndex:G,containerId:g}),U=u!==K.current.items,X=n({active:R,containerId:g,isDragging:B,isSorting:H,id:s,index:E,items:u,newIndex:K.current.newIndex,previousItems:K.current.items,previousContainerId:K.current.containerId,transition:d,wasDragging:null!=K.current.activeId}),Y=function(t){let{disabled:n,index:r,node:a,rect:i}=t;const[o,s]=(0,e.useState)(null),l=(0,e.useRef)(r);return J((()=>{if(!n&&r!==l.current&&a.current){const e=i.current;if(e){const t=Oe(a.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&s(n)}}r!==l.current&&(l.current=r)}),[n,r,a,i]),(0,e.useEffect)((()=>{o&&s(null)}),[o]),o}({disabled:!X,index:E,node:S,rect:k});return(0,e.useEffect)((()=>{H&&K.current.newIndex!==G&&(K.current.newIndex=G),g!==K.current.containerId&&(K.current.containerId=g),u!==K.current.items&&(K.current.items=u)}),[H,G,g,u]),(0,e.useEffect)((()=>{if(q===K.current.activeId)return;if(q&&!K.current.activeId)return void(K.current.activeId=q);const e=setTimeout((()=>{K.current.activeId=q}),50);return()=>clearTimeout(e)}),[q]),{active:R,activeIndex:h,attributes:M,data:x,rect:k,index:E,newIndex:G,items:u,isOver:D,isSorting:H,isDragging:B,listeners:P,node:S,overIndex:v,over:T,setNodeRef:z,setActivatorNodeRef:A,setDroppableNodeRef:I,setDraggableNodeRef:N,transform:null!=Y?Y:W,transition:Y||U&&K.current.newIndex===E?dn:j&&!le(L)||!d?void 0:H||X?de.Transition.toString({...d,property:cn}):void 0}}function hn(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&"object"==typeof t.sortable&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const pn=[rt.Down,rt.Right,rt.Up,rt.Left],fn=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:a,droppableContainers:i,over:o,scrollableAncestors:s}}=t;if(pn.includes(e.code)){if(e.preventDefault(),!n||!r)return;const t=[];i.getEnabled().forEach((n=>{if(!n||null!=n&&n.disabled)return;const i=a.get(n.id);if(i)switch(e.code){case rt.Down:r.top<i.top&&t.push(n);break;case rt.Up:r.top>i.top&&t.push(n);break;case rt.Left:r.left>i.left&&t.push(n);break;case rt.Right:r.left<i.left&&t.push(n)}}));const d=(e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const a=Ie(t),i=[];for(const e of r){const{id:t}=e,r=n.get(t);if(r){const n=Ie(r),o=a.reduce(((e,t,r)=>e+ke(n[r],t)),0),s=Number((o/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:s}})}}return i.sort(Se)})({active:n,collisionRect:r,droppableRects:a,droppableContainers:t,pointerCoordinates:null});let u=Re(d,"id");if(u===(null==o?void 0:o.id)&&d.length>1&&(u=d[1].id),null!=u){const e=i.get(n.id),t=i.get(u),o=t?a.get(t.id):null,d=null==t?void 0:t.node.current;if(d&&o&&e&&t){const n=He(d).some(((e,t)=>s[t]!==e)),a=mn(e,t),i=(c=t,!(!hn(l=e)||!hn(c))&&!!mn(l,c)&&l.data.current.sortable.index<c.data.current.sortable.index),u=n||!a?{x:0,y:0}:{x:i?r.width-o.width:0,y:i?r.height-o.height:0},g={x:o.left,y:o.top};return u.x&&u.y?g:se(g,u)}}}var l,c};function mn(e,t){return!(!hn(e)||!hn(t))&&e.data.current.sortable.containerId===t.data.current.sortable.containerId}const vn=e=>{let{containerNodeRect:t,draggingNodeRect:n,transform:r}=e;return n&&t?function(e,t,n){const r={...e};return t.top+e.y<=n.top?r.y=n.top-t.top:t.bottom+e.y>=n.top+n.height&&(r.y=n.top+n.height-t.bottom),t.left+e.x<=n.left?r.x=n.left-t.left:t.right+e.x>=n.left+n.width&&(r.x=n.left+n.width-t.right),r}(r,n,t):r},bn=e=>{let{transform:t}=e;return{...t,x:0}},yn=(0,e.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256"},(0,e.createElement)("rect",{width:"256",height:"256",fill:"none"}),(0,e.createElement)("circle",{cx:"91",cy:"60",r:"16"}),(0,e.createElement)("circle",{cx:"91",cy:"128",r:"16"}),(0,e.createElement)("circle",{cx:"91",cy:"196",r:"16"}),(0,e.createElement)("circle",{cx:"161",cy:"60",r:"16"}),(0,e.createElement)("circle",{cx:"161",cy:"128",r:"16"}),(0,e.createElement)("circle",{cx:"161",cy:"196",r:"16"}));function wn({children:t,id:n,dragHandle:a=!0,dragHandleLabel:o=(0,i.__)("Reorder Item","generateblocks"),as:s="li",className:l="",disabled:c=!1}){const{active:d,attributes:u,listeners:g,setNodeRef:h,transform:p,transition:f,isDragging:m}=gn({id:n,disabled:c,data:{disabled:c}}),v={transform:de.Transform.toString(p),transition:f};d&&d.id===n&&(v.zIndex=1);const b=s,y=a?{ref:h,style:v}:{ref:h,style:v,...u,...g};return(0,e.createElement)(b,{className:O()("gb-sortable-listitem",l,m&&"is-dragging"),...y},a&&(0,e.createElement)(r.Button,{className:"gb-sortable-listitem__handle",variant:"tertiary",showTooltip:!1,icon:yn,label:o,...u,...g}),t)}const En=(0,a.forwardRef)((function({itemComponent:t,onDragStart:n,onDragEnd:r,items:o,setItems:s,dragHandle:l=!0,dragHandleLabel:c=(0,i.__)("Reorder Item","generateblocks"),className:d=""},u){const[g,h]=(0,a.useState)(!1),[p,f]=(0,a.useState)(null),m=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(0,e.useMemo)((()=>[...n].filter((e=>null!=e))),[...n])}(xe(ht),xe(lt,{coordinateGetter:fn})),v=t;return(0,e.createElement)(Gt,{modifiers:[bn,vn],sensors:m,collisionDetection:_e,onDragStart:e=>{const{active:t}=e;h(!0),f(t),n&&n(e)},onDragEnd:e=>{h(!1),function(e){var t;const{active:n,over:r}=e,a=null!==(t=r.data.current?.disabled)&&void 0!==t&&t;if(n.id!==r.id&&!a){const e=o.findIndex((e=>e.id===n.id)),t=o.findIndex((e=>e.id===r.id));s($t(o,e,t))}}(e),f(null),r&&r(e,p)}},(0,e.createElement)("ul",{className:O()("gb-sortable-list",d,g&&"is-dragging"),ref:u},(0,e.createElement)(an,{items:o,strategy:tn},o.map((t=>{var n;return(0,e.createElement)(wn,{key:t.id,id:t.id,dragHandle:l,dragHandleLabel:c,className:"gb-sortable-list__item",disabled:null!==(n=t.disabled)&&void 0!==n&&n},(0,e.createElement)(v,{item:t}))})))))}));function xn({closeModal:t,globalStyleData:n,setBulkInsertEnabled:o,filteredPatterns:s}){const{insertBlocks:l,replaceBlock:c}=(0,R.useDispatch)(L.store),{selectedPatterns:d=[],selectedPatternsDispatch:u,setActivePatternId:h,setScrollPosition:p}=g(),{getBlockInsertionPoint:f,getSelectedBlock:m}=(0,R.useSelect)((e=>e(L.store)),[]),{updateBlockAttributes:v}=(0,R.useDispatch)(L.store),b=()=>(0,e.createElement)(e.Fragment,null,"");return(0,e.createElement)("aside",{className:"gb-selected-patterns"},(0,e.createElement)("h3",{className:"gb-selected-patterns__headline"},(0,i.__)("Bulk Insert","generateblocks")),!d.length&&(0,e.createElement)("p",null,(0,i.__)("Select patterns to insert.","generateblocks")),(0,e.createElement)(En,{className:"gb-selected-patterns__list",items:d,dragHandleLabel:(0,i.__)("Reorder Pattern","generateblocks"),setItems:e=>{u({type:"SET",patterns:e})},itemComponent:function({item:t}){const n=(0,a.useRef)(null);return(0,e.createElement)("div",{id:`selected-pattern-${t.id}`,className:"gb-selected-pattern",ref:n},(0,e.createElement)("span",{className:"gb-selected-pattern__label",title:t.label},t.label),(0,e.createElement)("div",{className:"gb-selected-pattern__actions"},(0,e.createElement)(b,null),(0,e.createElement)(r.Button,{variant:"tertiary",icon:j,label:(0,i.__)("Remove Pattern","generateblocks"),onClick:()=>{u({type:"REMOVE",pattern:t})}}),(0,e.createElement)(r.Button,{variant:"tertiary",icon:I,label:(0,i.__)("Preview Pattern","generateblocks"),showTooltip:!0,disabled:!s.find((({id:e})=>e===t.id)),onClick:()=>{h(t.id);const e=n.current.closest(".gb-pattern-library__content");e&&p(e.scrollTop)}})))},dragHandle:!0}),(0,e.createElement)("div",{style:{display:"flex",gap:"5px",justifyContent:"space-between",marginTop:"1em"}},(0,e.createElement)(N,{label:(0,i.__)("Insert All","generateblocks"),patterns:d,globalStyleData:n,disabled:!d.length,onClick:async()=>{const e=d.reduce(((e,t)=>e+t.pattern),""),n=f(),r=P((0,_.parse)(e)),a=m();var i,o;r.forEach((e=>{e.attributes&&e.clientId&&v(e.clientId,e.attributes)})),B(a)?await c(a.clientId,r):await l(r,null!==(i=n?.index)&&void 0!==i?i:0,null!==(o=n.rootClientId)&&void 0!==o?o:""),t()}}),(0,e.createElement)(r.Button,{variant:"secondary",onClick:()=>o(!1),isDestructive:!0},(0,i.__)("Cancel","generateblocks"))))}var Cn=(0,e.createElement)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,e.createElement)(h.Path,{d:"M20.5 16h-.7V8c0-1.1-.9-2-2-2H6.2c-1.1 0-2 .9-2 2v8h-.7c-.8 0-1.5.7-1.5 1.5h20c0-.8-.7-1.5-1.5-1.5zM5.7 8c0-.3.2-.5.5-.5h11.6c.3 0 .5.2.5.5v7.6H5.7V8z"})),kn=(0,e.createElement)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,e.createElement)(h.Path,{d:"M17 4H7c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H7c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h10c.3 0 .5.2.5.5v12zm-7.5-.5h4V16h-4v1.5z"})),Sn=(0,e.createElement)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,e.createElement)(h.Path,{d:"M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z"}));function Dn({pattern:t,isSelected:n,bulkInsertEnabled:a,globalStyleData:o,closeModal:s}){const{activePatternId:l,previewIframeWidth:c,setPreviewIframeWidth:d}=g();return(0,e.createElement)(T,{pattern:t,showPreview:!1,isSelected:n,showTitle:!1,bulkInsertEnabled:a,globalStyleData:o,closeModal:s},!!l&&(0,e.createElement)(r.ButtonGroup,null,(0,e.createElement)(r.Button,{isPressed:"100%"===c,variant:"tertiary",icon:Cn,label:(0,i.__)("Desktop","generateblocks"),showTooltip:!0,onClick:()=>d("100%")}),(0,e.createElement)(r.Button,{isPressed:"900px"===c,variant:"tertiary",icon:kn,label:(0,i.__)("Tablet","generateblocks"),showTooltip:!0,onClick:()=>d("900px")}),(0,e.createElement)(r.Button,{isPressed:"400px"===c,variant:"tertiary",icon:Sn,label:(0,i.__)("Mobile","generateblocks"),showTooltip:!0,onClick:()=>d("400px")})))}var In=window.lodash,Rn=(0,e.createElement)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,e.createElement)(h.Path,{d:"M5.5 12h1.75l-2.5 3-2.5-3H4a8 8 0 113.134 6.35l.907-1.194A6.5 6.5 0 105.5 12zm9.53 1.97l-2.28-2.28V8.5a.75.75 0 00-1.5 0V12a.747.747 0 00.218.529l1.282-.84-1.28.842 2.5 2.5a.75.75 0 101.06-1.061z"}));function Ln({setCacheIsClearing:t,cacheIsClearing:n}){const{activeLibrary:o,setLibraryCategories:c,setLibraryPatterns:d,isLocal:u}=g(),[h,p]=(0,a.useState)(!1);async function f(){if(u)return void p({});const e=await s()({path:(0,l.addQueryArgs)("/generateblocks/v1/pattern-library/get-cache-data",{id:o.id}),method:"GET"});var t;e.success?p(null!==(t=e?.response?.data)&&void 0!==t?t:{}):p({})}return(0,a.useEffect)((()=>{!async function(){o?.id&&f()}()}),[o?.id]),(0,In.isEmpty)(h)?null:(0,e.createElement)(r.Button,{className:"has-icon",variant:"tertiary",size:"compact",disabled:!h.can_clear||n,label:(0,i.__)("Refresh patterns","generateblocks"),showTooltip:!0,onClick:async()=>{t(!0),(await s()({path:"/generateblocks/v1/pattern-library/clear-cache",data:{id:o?.id},method:"POST"})).success&&(await c(),await d(),await f()),t(!1)}},n?(0,e.createElement)(r.Spinner,null):(0,e.createElement)(r.Icon,{icon:Rn}))}var Mn=(0,e.createElement)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,e.createElement)(h.Path,{d:"M20 5h-5.7c0-1.3-1-2.3-2.3-2.3S9.7 3.7 9.7 5H4v2h1.5v.3l1.7 11.1c.1 1 1 1.7 2 1.7h5.7c1 0 1.8-.7 2-1.7l1.7-11.1V7H20V5zm-3.2 2l-1.7 11.1c0 .1-.1.2-.3.2H9.1c-.1 0-.3-.1-.3-.2L7.2 7h9.6z"})),Nn=(0,e.createElement)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,e.createElement)(h.Path,{d:"m19 7.5h-7.628c-.3089-.87389-1.1423-1.5-2.122-1.5-.97966 0-1.81309.62611-2.12197 1.5h-2.12803v1.5h2.12803c.30888.87389 1.14231 1.5 2.12197 1.5.9797 0 1.8131-.62611 2.122-1.5h7.628z"}),(0,e.createElement)(h.Path,{d:"m19 15h-2.128c-.3089-.8739-1.1423-1.5-2.122-1.5s-1.8131.6261-2.122 1.5h-7.628v1.5h7.628c.3089.8739 1.1423 1.5 2.122 1.5s1.8131-.6261 2.122-1.5h2.128z"}));async function Pn(e){return await s()({path:"generateblocks/v1/pattern-library/libraries/save",method:"POST",data:{data:e}})}function Bn({library:t,librariesToManage:n,setLibrariesToManage:a,isRemote:o}){const{setLibraries:s}=g();return(0,e.createElement)("div",{key:t.id,className:"gblocks-manage-libraries__library"},(0,e.createElement)("div",{className:"gblocks-manage-libraries__library-name"},o?(0,e.createElement)(r.Tooltip,{text:t.domain},(0,e.createElement)("span",null,t.name)):t.name,!!o&&(0,e.createElement)(r.Button,{size:"small",isDestructive:!0,variant:"secondary",onClick:async()=>{const e=[...n],r=e.findIndex((e=>e.id===t.id));e.splice(r,1),a(e);const i=await Pn(e);i.success&&i?.response?.data.length&&s(i?.response?.data.length)},icon:Mn,label:(0,i.__)("Delete library","generateblocks"),showTooltip:!0})),(0,e.createElement)("div",{className:"gblocks-manage-libraries__library-actions"},(0,e.createElement)(r.ToggleControl,{checked:!!t.isEnabled,label:(0,i.__)("Enabled","generateblocks"),onChange:async()=>{const e=[...n],r=e.findIndex((e=>e.id===t.id));e[r]={...e[r],isEnabled:!n[r].isEnabled},a(e);const i=await Pn(e);i.success&&i?.response?.data.length&&s()}})))}function Tn(){const[t,n]=(0,a.useState)(!1),[o,s]=(0,a.useState)([]);(0,a.useEffect)((()=>{!async function(){if(!t)return;const{data:e}=await d(!1);s(e)}()}),[t]);const l=o.filter((e=>e.isDefault)),c=o.filter((e=>e.isLocal)),u=o.filter((e=>!e.isLocal&&!e.isDefault));return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(r.Button,{variant:"tertiary",size:"compact",icon:Nn,label:(0,i.__)("Manage Libraries","generateblocks"),showTooltip:!0,onClick:n}),!!t&&(0,e.createElement)(r.Modal,{title:(0,i.__)("Manage Libraries","generateblocks"),onRequestClose:()=>n(!1)},(0,e.createElement)("div",{className:"gblocks-manage-libraries"},!!l.length&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("h4",null,(0,i.__)("Default","generateblocks")),(0,e.createElement)("div",{className:"gblocks-manage-libraries__table"},l.map((t=>(0,e.createElement)(Bn,{key:t.id,library:t,librariesToManage:o,setLibrariesToManage:s}))))),!!c.length&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("h4",null,(0,i.__)("Local","generateblocks")),(0,e.createElement)("div",{className:"gblocks-manage-libraries__table"},c.map((t=>(0,e.createElement)(Bn,{key:t.id,library:t,librariesToManage:o,setLibrariesToManage:s}))))),!!u.length&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("h4",null,(0,i.__)("Remote","generateblocks")),(0,e.createElement)("div",{className:"gblocks-manage-libraries__table"},u.map((t=>(0,e.createElement)(Bn,{key:t.id,library:t,librariesToManage:o,setLibrariesToManage:s,isRemote:!0}))))))))}const An=wp.element.createElement,On={};function zn({closeModal:t}){const{activePatternId:n,setActivePatternId:o,patterns:s,setScrollPosition:l,scrollPosition:c,activeCategory:d,search:u,setSearch:h,isLocal:m,activeLibrary:v,selectedPatterns:y}=g(),[E,x]=(0,a.useState)(!1),[k,S]=(0,a.useState)(s),[D,I]=(0,a.useState)(""),[R,L]=(0,a.useState)([]),[_,M]=(0,a.useState)(!1),N=s.find((e=>n===e.id)),P=(0,a.useRef)();function B(e){return s.filter((t=>{const n=""===d,r=t.label.toLowerCase().includes(e.toLowerCase()),a=t.categories.includes(d);return n?r:r&&a}))}(0,a.useEffect)((()=>{S(""===d?s:B(u)),P.current&&(P.current.scrollTop=0)}),[s,d]);const T={};return n&&(T.gridColumn="1 / -1"),(0,w.doAction)("generateblocks.patterns.patternsList",{activeLibrary:v,setGlobalStyleCSS:I,setGlobalStyleData:L,isLocal:m,cacheIsClearing:_}),(0,e.createElement)("div",{className:"gb-pattern-library"},(0,e.createElement)("div",{className:"gb-pattern-library__header"},(0,e.createElement)("div",{className:"gb-pattern-library__header-title"},n?(0,e.createElement)("h1",null,N.label):(0,e.createElement)("h1",null,"tabs-desktop"=="generateblocks"?An("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none"},An("path",{d:"M18.95 4H4.55C3.55589 4 2.75 4.76751 2.75 5.71429V14.2857C2.75 15.2325 3.55589 16 4.55 16H18.95C19.9441 16 20.75 15.2325 20.75 14.2857V5.71429C20.75 4.76751 19.9441 4 18.95 4Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),An("path",{d:"M1.75 18C1.19772 18 0.75 18.4477 0.75 19C0.75 19.5523 1.19772 20 1.75 20H21.75C22.3023 20 22.75 19.5523 22.75 19C22.75 18.4477 22.3023 18 21.75 18H1.75ZM9 18.8C8.86193 18.8 8.75 18.9119 8.75 19.05C8.75 19.1881 8.86193 19.3 9 19.3H14.5C14.6381 19.3 14.75 19.1881 14.75 19.05C14.75 18.9119 14.6381 18.8 14.5 18.8H9Z",stroke:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})):(0,e.createElement)("svg",{viewBox:"0 0 50 60.12",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)("path",{d:"M6.686 31.622V18.918a.077.077 0 0 1 .05-.072l6.5-2.313 6.5-2.313 9.682-3.445L39.1 7.33a.067.067 0 0 0 .036-.028.074.074 0 0 0 .014-.044V.076a.077.077 0 0 0-.032-.062.076.076 0 0 0-.069-.009l-13 4.625-13 4.625-6.5 2.313-6.5 2.313a.067.067 0 0 0-.036.028.097.097 0 0 0-.013.046V52.067c0 .026.013.048.032.062s.044.018.069.009l3.267-1.163 3.267-1.163c.015-.005.028-.015.036-.028s.014-.028.014-.044V37.999l.001-6.377c-.001 0 0 0 0 0z"}),(0,e.createElement)("path",{d:"m23.949 29.976 13-4.625 13-4.625c.015-.005.028-.015.036-.028s.015-.028.015-.044V8.056a.077.077 0 0 0-.032-.062.076.076 0 0 0-.069-.009l-13 4.625-13 4.625-6.5 2.313-6.5 2.313a.067.067 0 0 0-.036.028.074.074 0 0 0-.014.044V60.045c0 .026.013.048.032.062a.076.076 0 0 0 .069.009l6.475-2.304 6.475-2.304 6.525-2.322 6.525-2.322 6.5-2.313 6.5-2.313c.015-.005.028-.015.036-.028s.014-.025.014-.041V27.193a.077.077 0 0 0-.032-.062.076.076 0 0 0-.069-.009l-6.45 2.295L37 31.711a.067.067 0 0 0-.036.028.074.074 0 0 0-.014.044v6.272a.077.077 0 0 1-.05.072l-6.45 2.295L24 42.715a.075.075 0 0 1-.101-.071V30.046c0-.016.005-.031.014-.044a.08.08 0 0 1 .036-.026z"}))," ",(0,i.__)("Pattern Library","generateblocks"))),(0,e.createElement)("div",{className:"gb-pattern-library__header-action"},n?(0,e.createElement)(Dn,{pattern:N,bulkInsertEnabled:E,globalStyleData:R,closeModal:t}):(0,e.createElement)(C,null)),(0,e.createElement)("div",{className:"gb-pattern-library__header-close"},n?(0,e.createElement)(r.Button,{icon:f,onClick:()=>{o(""),l(c)}},(0,i.__)("Return to library")):(0,e.createElement)(e.Fragment,null,(0,e.createElement)(Ln,{setCacheIsClearing:M,cacheIsClearing:_}),(0,e.createElement)(Tn,null),(0,e.createElement)(r.Button,{variant:"tertiary",icon:p,label:(0,i.__)("Close Pattern Library","generateblocks"),showTooltip:!0,onClick:t})))),(0,e.createElement)("div",{className:"gb-pattern-library__sidebar"},!n&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(V,{onChange:e=>{h(e);const t=""===d?"all":d,n=function(e){const t=""===d?"all":d,n=v?.id||"";return On[n]&&On[n][t]||(On[n]=On[n]||{},On[n][t]=On[n][t]||{}),!!On[n][t][e]&&On[n][t][e]}(e);if(n)return void S(n);const r=B(e),a=v?.id;a&&(On[a][t][e]=r),S(r)}}),(0,e.createElement)(b,{bulkInsertEnabled:E,selectedPatterns:y}),E?(0,e.createElement)(xn,{closeModal:t,globalStyleData:R,setBulkInsertEnabled:x,filteredPatterns:k}):(0,e.createElement)(r.Button,{variant:"primary",onClick:()=>x(!0)},(0,i.__)("Bulk Insert","generateblocks")))),(0,e.createElement)("div",{className:"gb-pattern-library__content",style:T,ref:P},(0,e.createElement)(z,{patterns:k,bulkInsertEnabled:E,closeModal:t,globalStyleCSS:D,globalStyleData:R})))}(0,w.addFilter)("generateblocks.editor.sidebar","generateblocks/pattern-library",(function(t,{activePanel:n}){const[o,s]=(0,a.useState)(!1);return n?t:(0,e.createElement)(e.Fragment,null,(0,e.createElement)(r.PanelBody,null,(0,e.createElement)("h2",{className:"gblocks-editor-sidebar__panel-title"},(0,i.__)("Pattern Library","generateblocks")),(0,e.createElement)(r.Button,{className:"gblocks-pattern-library-button",variant:"secondary",onClick:()=>s(!0),isPressed:o},(0,i.__)("Open Pattern Library","generateblocks"))),t,!!o&&(0,e.createElement)(r.Modal,{className:"gblocks-pattern-library-modal",isFullScreen:!0,onRequestClose:()=>s(!1)},(0,e.createElement)(u,null,(0,e.createElement)(zn,{closeModal:()=>s(!1)}))))}))}()}();