📁 File Manager Pro
v10.0.3 | PHP: 8.1.34
Server: LiteSpeed
2026-06-28 20:16:33
📂
/ (Root)
/
home
/
apkbfjox
/
2jbet.net.pk
/
wp-content
/
plugins
/
generateblocks-pro
/
dist
📍 /home/apkbfjox/2jbet.net.pk/wp-content/plugins/generateblocks-pro/dist
🔄 Refresh
✏️
Editing: overlay-editor.js
Writable
(()=>{var e={2694:(e,t,n)=>{"use strict";var r=n(6925);function o(){}function a(){}a.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,a,s){if(s!==r){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:a,resetWarningCache:o};return n.PropTypes=n,n}},5556:(e,t,n)=>{e.exports=n(2694)()},6925:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},21020:(e,t,n)=>{"use strict";var r=n(51609),o=Symbol.for("react.element"),a=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),s=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,n){var r,l={},c=null,u=null;for(r in void 0!==n&&(c=""+n),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)a.call(t,r)&&!i.hasOwnProperty(r)&&(l[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===l[r]&&(l[r]=t[r]);return{$$typeof:o,type:e,key:c,ref:u,props:l,_owner:s.current}}},22799:(e,t)=>{"use strict";Symbol.for("react.element"),Symbol.for("react.portal"),Symbol.for("react.fragment"),Symbol.for("react.strict_mode"),Symbol.for("react.profiler"),Symbol.for("react.provider"),Symbol.for("react.context"),Symbol.for("react.server_context"),Symbol.for("react.forward_ref"),Symbol.for("react.suspense"),Symbol.for("react.suspense_list"),Symbol.for("react.memo"),Symbol.for("react.lazy"),Symbol.for("react.offscreen");Symbol.for("react.module.reference")},44363:(e,t,n)=>{"use strict";n(22799)},51609:e=>{"use strict";e.exports=window.React},74848:(e,t,n)=>{"use strict";e.exports=n(21020)}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(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=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=n(51609),t=n.n(e);const r=window.wp.data,o=window.wp.editor,a=window.wp.plugins,s=window.wp.components,i=window.wp.i18n,l=window.wp.element,c=window.wp.apiFetch;var u=n.n(c);const d=window.gbp.stylesBuilder;var p=n(74848),h=e.createContext(void 0),g=t=>{const n=e.useContext(h);if(t)return t;if(!n)throw new Error("No QueryClient set, use QueryClientProvider to set one");return n},m=({client:t,children:n})=>(e.useEffect((()=>(t.mount(),()=>{t.unmount()})),[t]),(0,p.jsx)(h.Provider,{value:t,children:n})),b="undefined"==typeof window||"Deno"in globalThis;function f(){}function _(e){return"number"==typeof e&&e>=0&&e!==1/0}function y(e,t){return Math.max(e+(t||0)-Date.now(),0)}function v(e,t){return"function"==typeof e?e(t):e}function k(e,t){return"function"==typeof e?e(t):e}function w(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:a,queryKey:s,stale:i}=e;if(s)if(r){if(t.queryHash!==C(s,t.options))return!1}else if(!x(t.queryKey,s))return!1;if("all"!==n){const e=t.isActive();if("active"===n&&!e)return!1;if("inactive"===n&&e)return!1}return!("boolean"==typeof i&&t.isStale()!==i||o&&o!==t.state.fetchStatus||a&&!a(t))}function E(e,t){const{exact:n,status:r,predicate:o,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(S(t.options.mutationKey)!==S(a))return!1}else if(!x(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function C(e,t){return(t?.queryKeyHashFn||S)(e)}function S(e){return JSON.stringify(e,((e,t)=>T(t)?Object.keys(t).sort().reduce(((e,n)=>(e[n]=t[n],e)),{}):t))}function x(e,t){return e===t||typeof e==typeof t&&!(!e||!t||"object"!=typeof e||"object"!=typeof t)&&Object.keys(t).every((n=>x(e[n],t[n])))}function I(e,t){if(e===t)return e;const n=N(e)&&N(t);if(n||T(e)&&T(t)){const r=n?e:Object.keys(e),o=r.length,a=n?t:Object.keys(t),s=a.length,i=n?[]:{};let l=0;for(let o=0;o<s;o++){const s=n?o:a[o];(!n&&r.includes(s)||n)&&void 0===e[s]&&void 0===t[s]?(i[s]=void 0,l++):(i[s]=I(e[s],t[s]),i[s]===e[s]&&void 0!==e[s]&&l++)}return o===s&&l===o?e:i}return t}function O(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function N(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function T(e){if(!R(e))return!1;const t=e.constructor;if(void 0===t)return!0;const n=t.prototype;return!!R(n)&&!!n.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype}function R(e){return"[object Object]"===Object.prototype.toString.call(e)}function D(e,t,n){return"function"==typeof n.structuralSharing?n.structuralSharing(e,t):!1!==n.structuralSharing?I(e,t):t}function M(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function P(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var A=Symbol();function B(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:e.queryFn&&e.queryFn!==A?e.queryFn:()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`))}function F(e,t){return"function"==typeof e?e(...t):!!e}var $=e=>setTimeout(e,0),q=function(){let e=[],t=0,n=e=>{e()},r=e=>{e()},o=$;const a=r=>{t?e.push(r):o((()=>{n(r)}))};return{batch:a=>{let s;t++;try{s=a()}finally{t--,t||(()=>{const t=e;e=[],t.length&&o((()=>{r((()=>{t.forEach((e=>{n(e)}))}))}))})()}return s},batchCalls:e=>(...t)=>{a((()=>{e(...t)}))},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{o=e}}}(),L=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},z=new class extends L{#e;#t;#n;constructor(){super(),this.#n=e=>{if(!b&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e((e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()}))}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach((t=>{t(e)}))}isFocused(){return"boolean"==typeof this.#e?this.#e:"hidden"!==globalThis.document?.visibilityState}},H=new class extends L{#r=!0;#t;#n;constructor(){super(),this.#n=e=>{if(!b&&window.addEventListener){const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#r!==e&&(this.#r=e,this.listeners.forEach((t=>{t(e)})))}isOnline(){return this.#r}};function U(){let e,t;const n=new Promise(((n,r)=>{e=n,t=r}));function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.status="pending",n.catch((()=>{})),n.resolve=t=>{r({status:"fulfilled",value:t}),e(t)},n.reject=e=>{r({status:"rejected",reason:e}),t(e)},n}function V(e){return Math.min(1e3*2**e,3e4)}function j(e){return"online"!==(e??"online")||H.isOnline()}var Q=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function K(e){return e instanceof Q}function W(e){let t,n=!1,r=0,o=!1;const a=U(),s=()=>z.isFocused()&&("always"===e.networkMode||H.isOnline())&&e.canRun(),i=()=>j(e.networkMode)&&e.canRun(),l=n=>{o||(o=!0,e.onSuccess?.(n),t?.(),a.resolve(n))},c=n=>{o||(o=!0,e.onError?.(n),t?.(),a.reject(n))},u=()=>new Promise((n=>{t=e=>{(o||s())&&n(e)},e.onPause?.()})).then((()=>{t=void 0,o||e.onContinue?.()})),d=()=>{if(o)return;let t;const a=0===r?e.initialPromise:void 0;try{t=a??e.fn()}catch(e){t=Promise.reject(e)}Promise.resolve(t).then(l).catch((t=>{if(o)return;const a=e.retry??(b?0:3),i=e.retryDelay??V,l="function"==typeof i?i(r,t):i,p=!0===a||"number"==typeof a&&r<a||"function"==typeof a&&a(r,t);var h;!n&&p?(r++,e.onFail?.(r,t),(h=l,new Promise((e=>{setTimeout(e,h)}))).then((()=>s()?void 0:u())).then((()=>{n?c(t):d()}))):c(t)}))};return{promise:a,cancel:t=>{o||(c(new Q(t)),e.abort?.())},continue:()=>(t?.(),a),cancelRetry:()=>{n=!0},continueRetry:()=>{n=!1},canStart:i,start:()=>(i()?d():u().then(d),a)}}var G=class{#o;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),_(this.gcTime)&&(this.#o=setTimeout((()=>{this.optionalRemove()}),this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(b?1/0:3e5))}clearGcTimeout(){this.#o&&(clearTimeout(this.#o),this.#o=void 0)}},Y=class extends G{#a;#s;#i;#l;#c;#u;#d;constructor(e){super(),this.#d=!1,this.#u=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#l=e.client,this.#i=this.#l.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#a=function(e){const t="function"==typeof e.initialData?e.initialData():e.initialData,n=void 0!==t,r=n?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}(this.options),this.state=e.state??this.#a,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#c?.promise}setOptions(e){this.options={...this.#u,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#i.remove(this)}setData(e,t){const n=D(this.state.data,e,this.options);return this.#p({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#p({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#c?.promise;return this.#c?.cancel(e),t?t.then(f).catch(f):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#a)}isActive(){return this.observers.some((e=>!1!==k(e.options.enabled,this)))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===A||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return!!this.state.isInvalidated||(this.getObserversCount()>0?this.observers.some((e=>e.getCurrentResult().isStale)):void 0===this.state.data)}isStaleByTime(e=0){return this.state.isInvalidated||void 0===this.state.data||!y(this.state.dataUpdatedAt,e)}onFocus(){const e=this.observers.find((e=>e.shouldFetchOnWindowFocus()));e?.refetch({cancelRefetch:!1}),this.#c?.continue()}onOnline(){const e=this.observers.find((e=>e.shouldFetchOnReconnect()));e?.refetch({cancelRefetch:!1}),this.#c?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#i.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter((t=>t!==e)),this.observers.length||(this.#c&&(this.#d?this.#c.cancel({revert:!0}):this.#c.cancelRetry()),this.scheduleGc()),this.#i.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#p({type:"invalidate"})}fetch(e,t){if("idle"!==this.state.fetchStatus)if(void 0!==this.state.data&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#c)return this.#c.continueRetry(),this.#c.promise;if(e&&this.setOptions(e),!this.options.queryFn){const e=this.observers.find((e=>e.options.queryFn));e&&this.setOptions(e.options)}const n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#d=!0,n.signal)})},o={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#l,state:this.state,fetchFn:()=>{const e=B(this.options,t),n={client:this.#l,queryKey:this.queryKey,meta:this.meta};return r(n),this.#d=!1,this.options.persister?this.options.persister(e,n,this):e(n)}};r(o),this.options.behavior?.onFetch(o,this),this.#s=this.state,"idle"!==this.state.fetchStatus&&this.state.fetchMeta===o.fetchOptions?.meta||this.#p({type:"fetch",meta:o.fetchOptions?.meta});const a=e=>{K(e)&&e.silent||this.#p({type:"error",error:e}),K(e)||(this.#i.config.onError?.(e,this),this.#i.config.onSettled?.(this.state.data,e,this)),this.scheduleGc()};return this.#c=W({initialPromise:t?.initialPromise,fn:o.fetchFn,abort:n.abort.bind(n),onSuccess:e=>{if(void 0!==e){try{this.setData(e)}catch(e){return void a(e)}this.#i.config.onSuccess?.(e,this),this.#i.config.onSettled?.(e,this.state.error,this),this.scheduleGc()}else a(new Error(`${this.queryHash} data is undefined`))},onError:a,onFail:(e,t)=>{this.#p({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#p({type:"pause"})},onContinue:()=>{this.#p({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}),this.#c.start()}#p(e){this.state=(t=>{switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,...J(t.data,this.options),fetchMeta:e.meta??null};case"success":return{...t,data:e.data,dataUpdateCount:t.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const n=e.error;return K(n)&&n.revert&&this.#s?{...this.#s,fetchStatus:"idle"}:{...t,error:n,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}})(this.state),q.batch((()=>{this.observers.forEach((e=>{e.onQueryUpdate()})),this.#i.notify({query:this,type:"updated",action:e})}))}};function J(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:j(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}var Z=class extends L{constructor(e={}){super(),this.config=e,this.#h=new Map}#h;build(e,t,n){const r=t.queryKey,o=t.queryHash??C(r,t);let a=this.get(o);return a||(a=new Y({client:e,queryKey:r,queryHash:o,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#h.has(e.queryHash)||(this.#h.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#h.get(e.queryHash);t&&(e.destroy(),t===e&&this.#h.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){q.batch((()=>{this.getAll().forEach((e=>{this.remove(e)}))}))}get(e){return this.#h.get(e)}getAll(){return[...this.#h.values()]}find(e){const t={exact:!0,...e};return this.getAll().find((e=>w(t,e)))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter((t=>w(e,t))):t}notify(e){q.batch((()=>{this.listeners.forEach((t=>{t(e)}))}))}onFocus(){q.batch((()=>{this.getAll().forEach((e=>{e.onFocus()}))}))}onOnline(){q.batch((()=>{this.getAll().forEach((e=>{e.onOnline()}))}))}},X=class extends G{#g;#m;#c;constructor(e){super(),this.mutationId=e.mutationId,this.#m=e.mutationCache,this.#g=[],this.state=e.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#g.includes(e)||(this.#g.push(e),this.clearGcTimeout(),this.#m.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#g=this.#g.filter((t=>t!==e)),this.scheduleGc(),this.#m.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#g.length||("pending"===this.state.status?this.scheduleGc():this.#m.remove(this))}continue(){return this.#c?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#p({type:"continue"})};this.#c=W({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(e,t)=>{this.#p({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#p({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#m.canRun(this)});const n="pending"===this.state.status,r=!this.#c.canStart();try{if(n)t();else{this.#p({type:"pending",variables:e,isPaused:r}),await(this.#m.config.onMutate?.(e,this));const t=await(this.options.onMutate?.(e));t!==this.state.context&&this.#p({type:"pending",context:t,variables:e,isPaused:r})}const o=await this.#c.start();return await(this.#m.config.onSuccess?.(o,e,this.state.context,this)),await(this.options.onSuccess?.(o,e,this.state.context)),await(this.#m.config.onSettled?.(o,null,this.state.variables,this.state.context,this)),await(this.options.onSettled?.(o,null,e,this.state.context)),this.#p({type:"success",data:o}),o}catch(t){try{throw await(this.#m.config.onError?.(t,e,this.state.context,this)),await(this.options.onError?.(t,e,this.state.context)),await(this.#m.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this)),await(this.options.onSettled?.(void 0,t,e,this.state.context)),t}finally{this.#p({type:"error",error:t})}}finally{this.#m.runNext(this)}}#p(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),q.batch((()=>{this.#g.forEach((t=>{t.onMutationUpdate(e)})),this.#m.notify({mutation:this,type:"updated",action:e})}))}},ee=class extends L{constructor(e={}){super(),this.config=e,this.#b=new Set,this.#f=new Map,this.#_=0}#b;#f;#_;build(e,t,n){const r=new X({mutationCache:this,mutationId:++this.#_,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#b.add(e);const t=te(e);if("string"==typeof t){const n=this.#f.get(t);n?n.push(e):this.#f.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#b.delete(e)){const t=te(e);if("string"==typeof t){const n=this.#f.get(t);if(n)if(n.length>1){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}else n[0]===e&&this.#f.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=te(e);if("string"==typeof t){const n=this.#f.get(t),r=n?.find((e=>"pending"===e.state.status));return!r||r===e}return!0}runNext(e){const t=te(e);if("string"==typeof t){const n=this.#f.get(t)?.find((t=>t!==e&&t.state.isPaused));return n?.continue()??Promise.resolve()}return Promise.resolve()}clear(){q.batch((()=>{this.#b.forEach((e=>{this.notify({type:"removed",mutation:e})})),this.#b.clear(),this.#f.clear()}))}getAll(){return Array.from(this.#b)}find(e){const t={exact:!0,...e};return this.getAll().find((e=>E(t,e)))}findAll(e={}){return this.getAll().filter((t=>E(e,t)))}notify(e){q.batch((()=>{this.listeners.forEach((t=>{t(e)}))}))}resumePausedMutations(){const e=this.getAll().filter((e=>e.state.isPaused));return q.batch((()=>Promise.all(e.map((e=>e.continue().catch(f))))))}};function te(e){return e.options.scope?.id}function ne(e){return{onFetch:(t,n)=>{const r=t.options,o=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],s=t.state.data?.pageParams||[];let i={pages:[],pageParams:[]},l=0;const c=async()=>{let n=!1;const c=B(t.options,t.fetchOptions),u=async(e,r,o)=>{if(n)return Promise.reject();if(null==r&&e.pages.length)return Promise.resolve(e);const a={client:t.client,queryKey:t.queryKey,pageParam:r,direction:o?"backward":"forward",meta:t.options.meta};var s;s=a,Object.defineProperty(s,"signal",{enumerable:!0,get:()=>(t.signal.aborted?n=!0:t.signal.addEventListener("abort",(()=>{n=!0})),t.signal)});const i=await c(a),{maxPages:l}=t.options,u=o?P:M;return{pages:u(e.pages,i,l),pageParams:u(e.pageParams,r,l)}};if(o&&a.length){const e="backward"===o,t={pages:a,pageParams:s},n=(e?oe:re)(r,t);i=await u(t,n,e)}else{const t=e??a.length;do{const e=0===l?s[0]??r.initialPageParam:re(r,i);if(l>0&&null==e)break;i=await u(i,e),l++}while(l<t)}return i};t.options.persister?t.fetchFn=()=>t.options.persister?.(c,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=c}}}function re(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function oe(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var ae=class{#y;#m;#u;#v;#k;#w;#E;#C;constructor(e={}){this.#y=e.queryCache||new Z,this.#m=e.mutationCache||new ee,this.#u=e.defaultOptions||{},this.#v=new Map,this.#k=new Map,this.#w=0}mount(){this.#w++,1===this.#w&&(this.#E=z.subscribe((async e=>{e&&(await this.resumePausedMutations(),this.#y.onFocus())})),this.#C=H.subscribe((async e=>{e&&(await this.resumePausedMutations(),this.#y.onOnline())})))}unmount(){this.#w--,0===this.#w&&(this.#E?.(),this.#E=void 0,this.#C?.(),this.#C=void 0)}isFetching(e){return this.#y.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#m.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#y.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#y.build(this,t),r=n.state.data;return void 0===r?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(v(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#y.findAll(e).map((({queryKey:e,state:t})=>[e,t.data]))}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=this.#y.get(r.queryHash),a=o?.state.data,s=function(e,t){return"function"==typeof e?e(t):e}(t,a);if(void 0!==s)return this.#y.build(this,r).setData(s,{...n,manual:!0})}setQueriesData(e,t,n){return q.batch((()=>this.#y.findAll(e).map((({queryKey:e})=>[e,this.setQueryData(e,t,n)]))))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#y.get(t.queryHash)?.state}removeQueries(e){const t=this.#y;q.batch((()=>{t.findAll(e).forEach((e=>{t.remove(e)}))}))}resetQueries(e,t){const n=this.#y;return q.batch((()=>(n.findAll(e).forEach((e=>{e.reset()})),this.refetchQueries({type:"active",...e},t))))}cancelQueries(e,t={}){const n={revert:!0,...t},r=q.batch((()=>this.#y.findAll(e).map((e=>e.cancel(n)))));return Promise.all(r).then(f).catch(f)}invalidateQueries(e,t={}){return q.batch((()=>(this.#y.findAll(e).forEach((e=>{e.invalidate()})),"none"===e?.refetchType?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t))))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=q.batch((()=>this.#y.findAll(e).filter((e=>!e.isDisabled())).map((e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(f)),"paused"===e.state.fetchStatus?Promise.resolve():t}))));return Promise.all(r).then(f)}fetchQuery(e){const t=this.defaultQueryOptions(e);void 0===t.retry&&(t.retry=!1);const n=this.#y.build(this,t);return n.isStaleByTime(v(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(f).catch(f)}fetchInfiniteQuery(e){return e.behavior=ne(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(f).catch(f)}ensureInfiniteQueryData(e){return e.behavior=ne(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return H.isOnline()?this.#m.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#y}getMutationCache(){return this.#m}getDefaultOptions(){return this.#u}setDefaultOptions(e){this.#u=e}setQueryDefaults(e,t){this.#v.set(S(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#v.values()],n={};return t.forEach((t=>{x(e,t.queryKey)&&Object.assign(n,t.defaultOptions)})),n}setMutationDefaults(e,t){this.#k.set(S(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#k.values()],n={};return t.forEach((t=>{x(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)})),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#u.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=C(t.queryKey,t)),void 0===t.refetchOnReconnect&&(t.refetchOnReconnect="always"!==t.networkMode),void 0===t.throwOnError&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===A&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#u.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#y.clear(),this.#m.clear()}};let se=null;function ie(){return se||(se=new ae({defaultOptions:{queries:{staleTime:3e5,cacheTime:6e5,retry:1,refetchOnWindowFocus:!0}}})),se}function le(){const e=ie();if(e.invalidateQueries({queryKey:["conditions"]}),e.invalidateQueries({queryKey:["condition"]}),window.dispatchEvent(new CustomEvent("gb-invalidate-conditions")),window.parent&&window.parent!==window)try{window.parent.postMessage({type:"gb_invalidate_conditions"},"*")}catch(e){}}"undefined"!=typeof window&&(window.addEventListener("gb-invalidate-conditions",(()=>{ie().invalidateQueries({queryKey:["conditions"]})})),window.addEventListener("message",(e=>{"gb_invalidate_conditions"===e.data?.type&&ie().invalidateQueries({queryKey:["conditions"]})})),window.addEventListener("gb-overlay-saved-global",(e=>{const t=ie();t.invalidateQueries({queryKey:["overlays"]}),e.detail?.overlayId&&t.invalidateQueries({queryKey:["overlay",e.detail.overlayId]})})));const ce=window.wp.primitives,ue=(0,l.createElement)(ce.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,l.createElement)(ce.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})),de=(0,l.createElement)(ce.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,l.createElement)(ce.Path,{d:"M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"})),pe=window.wp.htmlEntities;var he=class extends L{constructor(e,t){super(),this.options=t,this.#l=e,this.#S=null,this.#x=U(),this.options.experimental_prefetchInRender||this.#x.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(t)}#l;#I=void 0;#O=void 0;#N=void 0;#T;#R;#x;#S;#D;#M;#P;#A;#B;#F;#$=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#I.addObserver(this),ge(this.#I,this.options)?this.#q():this.updateResult(),this.#L())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return me(this.#I,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return me(this.#I,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#z(),this.#H(),this.#I.removeObserver(this)}setOptions(e){const t=this.options,n=this.#I;if(this.options=this.#l.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof k(this.options.enabled,this.#I))throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#U(),this.#I.setOptions(this.options),t._defaulted&&!O(this.options,t)&&this.#l.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#I,observer:this});const r=this.hasListeners();r&&be(this.#I,n,this.options,t)&&this.#q(),this.updateResult(),!r||this.#I===n&&k(this.options.enabled,this.#I)===k(t.enabled,this.#I)&&v(this.options.staleTime,this.#I)===v(t.staleTime,this.#I)||this.#V();const o=this.#j();!r||this.#I===n&&k(this.options.enabled,this.#I)===k(t.enabled,this.#I)&&o===this.#F||this.#Q(o)}getOptimisticResult(e){const t=this.#l.getQueryCache().build(this.#l,e),n=this.createResult(t,e);return r=n,!O(this.getCurrentResult(),r)&&(this.#N=n,this.#R=this.options,this.#T=this.#I.state),n;var r}getCurrentResult(){return this.#N}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#$.add(e)}getCurrentQuery(){return this.#I}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#l.defaultQueryOptions(e),n=this.#l.getQueryCache().build(this.#l,t);return n.fetch().then((()=>this.createResult(n,t)))}fetch(e){return this.#q({...e,cancelRefetch:e.cancelRefetch??!0}).then((()=>(this.updateResult(),this.#N)))}#q(e){this.#U();let t=this.#I.fetch(this.options,e);return e?.throwOnError||(t=t.catch(f)),t}#V(){this.#z();const e=v(this.options.staleTime,this.#I);if(b||this.#N.isStale||!_(e))return;const t=y(this.#N.dataUpdatedAt,e)+1;this.#A=setTimeout((()=>{this.#N.isStale||this.updateResult()}),t)}#j(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#I):this.options.refetchInterval)??!1}#Q(e){this.#H(),this.#F=e,!b&&!1!==k(this.options.enabled,this.#I)&&_(this.#F)&&0!==this.#F&&(this.#B=setInterval((()=>{(this.options.refetchIntervalInBackground||z.isFocused())&&this.#q()}),this.#F))}#L(){this.#V(),this.#Q(this.#j())}#z(){this.#A&&(clearTimeout(this.#A),this.#A=void 0)}#H(){this.#B&&(clearInterval(this.#B),this.#B=void 0)}createResult(e,t){const n=this.#I,r=this.options,o=this.#N,a=this.#T,s=this.#R,i=e!==n?e.state:this.#O,{state:l}=e;let c,u={...l},d=!1;if(t._optimisticResults){const o=this.hasListeners(),a=!o&&ge(e,t),s=o&&be(e,n,t,r);(a||s)&&(u={...u,...J(l.data,e.options)}),"isRestoring"===t._optimisticResults&&(u.fetchStatus="idle")}let{error:p,errorUpdatedAt:h,status:g}=u;c=u.data;let m=!1;if(void 0!==t.placeholderData&&void 0===c&&"pending"===g){let e;o?.isPlaceholderData&&t.placeholderData===s?.placeholderData?(e=o.data,m=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#P?.state.data,this.#P):t.placeholderData,void 0!==e&&(g="success",c=D(o?.data,e,t),d=!0)}if(t.select&&void 0!==c&&!m)if(o&&c===a?.data&&t.select===this.#D)c=this.#M;else try{this.#D=t.select,c=t.select(c),c=D(o?.data,c,t),this.#M=c,this.#S=null}catch(e){this.#S=e}this.#S&&(p=this.#S,c=this.#M,h=Date.now(),g="error");const b="fetching"===u.fetchStatus,f="pending"===g,_="error"===g,y=f&&b,v=void 0!==c,k={status:g,fetchStatus:u.fetchStatus,isPending:f,isSuccess:"success"===g,isError:_,isInitialLoading:y,isLoading:y,data:c,dataUpdatedAt:u.dataUpdatedAt,error:p,errorUpdatedAt:h,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>i.dataUpdateCount||u.errorUpdateCount>i.errorUpdateCount,isFetching:b,isRefetching:b&&!f,isLoadingError:_&&!v,isPaused:"paused"===u.fetchStatus,isPlaceholderData:d,isRefetchError:_&&v,isStale:fe(e,t),refetch:this.refetch,promise:this.#x};if(this.options.experimental_prefetchInRender){const t=e=>{"error"===k.status?e.reject(k.error):void 0!==k.data&&e.resolve(k.data)},r=()=>{const e=this.#x=k.promise=U();t(e)},o=this.#x;switch(o.status){case"pending":e.queryHash===n.queryHash&&t(o);break;case"fulfilled":"error"!==k.status&&k.data===o.value||r();break;case"rejected":"error"===k.status&&k.error===o.reason||r()}}return k}updateResult(){const e=this.#N,t=this.createResult(this.#I,this.options);this.#T=this.#I.state,this.#R=this.options,void 0!==this.#T.data&&(this.#P=this.#I),O(t,e)||(this.#N=t,this.#K({listeners:(()=>{if(!e)return!0;const{notifyOnChangeProps:t}=this.options,n="function"==typeof t?t():t;if("all"===n||!n&&!this.#$.size)return!0;const r=new Set(n??this.#$);return this.options.throwOnError&&r.add("error"),Object.keys(this.#N).some((t=>{const n=t;return this.#N[n]!==e[n]&&r.has(n)}))})()}))}#U(){const e=this.#l.getQueryCache().build(this.#l,this.options);if(e===this.#I)return;const t=this.#I;this.#I=e,this.#O=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#L()}#K(e){q.batch((()=>{e.listeners&&this.listeners.forEach((e=>{e(this.#N)})),this.#l.getQueryCache().notify({query:this.#I,type:"observerResultsUpdated"})}))}};function ge(e,t){return function(e,t){return!1!==k(t.enabled,e)&&void 0===e.state.data&&!("error"===e.state.status&&!1===t.retryOnMount)}(e,t)||void 0!==e.state.data&&me(e,t,t.refetchOnMount)}function me(e,t,n){if(!1!==k(t.enabled,e)){const r="function"==typeof n?n(e):n;return"always"===r||!1!==r&&fe(e,t)}return!1}function be(e,t,n,r){return(e!==t||!1===k(r.enabled,e))&&(!n.suspense||"error"!==e.state.status)&&fe(e,n)}function fe(e,t){return!1!==k(t.enabled,e)&&e.isStaleByTime(v(t.staleTime,e))}var _e=e.createContext(function(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}()),ye=e.createContext(!1),ve=(ye.Provider,(e,t,n)=>t.fetchOptimistic(e).catch((()=>{n.clearReset()})));function ke(t,n){return function(t,n,r){const o=g(r),a=e.useContext(ye),s=e.useContext(_e),i=o.defaultQueryOptions(t);o.getDefaultOptions().queries?._experimental_beforeQuery?.(i),i._optimisticResults=a?"isRestoring":"optimistic",(e=>{const t=e.staleTime;e.suspense&&(e.staleTime="function"==typeof t?(...e)=>Math.max(t(...e),1e3):Math.max(t??1e3,1e3),"number"==typeof e.gcTime&&(e.gcTime=Math.max(e.gcTime,1e3)))})(i),((e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))})(i,s),(t=>{e.useEffect((()=>{t.clearReset()}),[t])})(s);const l=!o.getQueryCache().get(i.queryHash),[c]=e.useState((()=>new n(o,i))),u=c.getOptimisticResult(i),d=!a&&!1!==t.subscribed;if(e.useSyncExternalStore(e.useCallback((e=>{const t=d?c.subscribe(q.batchCalls(e)):f;return c.updateResult(),t}),[c,d]),(()=>c.getCurrentResult()),(()=>c.getCurrentResult())),e.useEffect((()=>{c.setOptions(i)}),[i,c]),((e,t)=>e?.suspense&&t.isPending)(i,u))throw ve(i,c,s);if((({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&void 0===e.data||F(n,[e.error,r])))({result:u,errorResetBoundary:s,throwOnError:i.throwOnError,query:o.getQueryCache().get(i.queryHash),suspense:i.suspense}))throw u.error;if(o.getDefaultOptions().queries?._experimental_afterQuery?.(i,u),i.experimental_prefetchInRender&&!b&&((e,t)=>e.isLoading&&e.isFetching&&!t)(u,a)){const e=l?ve(i,c,s):o.getQueryCache().get(i.queryHash)?.promise;e?.catch(f).finally((()=>{c.updateResult()}))}return i.notifyOnChangeProps?u:c.trackResult(u)}(t,he,n)}var we=class extends L{#l;#N=void 0;#W;#G;constructor(e,t){super(),this.#l=e,this.setOptions(t),this.bindMethods(),this.#Y()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const t=this.options;this.options=this.#l.defaultMutationOptions(e),O(this.options,t)||this.#l.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#W,observer:this}),t?.mutationKey&&this.options.mutationKey&&S(t.mutationKey)!==S(this.options.mutationKey)?this.reset():"pending"===this.#W?.state.status&&this.#W.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#W?.removeObserver(this)}onMutationUpdate(e){this.#Y(),this.#K(e)}getCurrentResult(){return this.#N}reset(){this.#W?.removeObserver(this),this.#W=void 0,this.#Y(),this.#K()}mutate(e,t){return this.#G=t,this.#W?.removeObserver(this),this.#W=this.#l.getMutationCache().build(this.#l,this.options),this.#W.addObserver(this),this.#W.execute(e)}#Y(){const e=this.#W?.state??{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0};this.#N={...e,isPending:"pending"===e.status,isSuccess:"success"===e.status,isError:"error"===e.status,isIdle:"idle"===e.status,mutate:this.mutate,reset:this.reset}}#K(e){q.batch((()=>{if(this.#G&&this.hasListeners()){const t=this.#N.variables,n=this.#N.context;"success"===e?.type?(this.#G.onSuccess?.(e.data,t,n),this.#G.onSettled?.(e.data,null,t,n)):"error"===e?.type&&(this.#G.onError?.(e.error,t,n),this.#G.onSettled?.(void 0,e.error,t,n))}this.listeners.forEach((e=>{e(this.#N)}))}))}};function Ee(t,n){const r=g(n),[o]=e.useState((()=>new we(r,t)));e.useEffect((()=>{o.setOptions(t)}),[o,t]);const a=e.useSyncExternalStore(e.useCallback((e=>o.subscribe(q.batchCalls(e))),[o]),(()=>o.getCurrentResult()),(()=>o.getCurrentResult())),s=e.useCallback(((e,t)=>{o.mutate(e,t).catch(f)}),[o]);if(a.error&&F(o.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:s,mutateAsync:a.mutate}}async function Ce(){return await u()({path:"/wp/v2/condition-categories"})}function Se(e=100,t=1){return ke({queryKey:["conditions",{perPage:e,page:t}],queryFn:()=>async function({perPage:e=100,page:t=1}){const n=await u()({path:`/generateblocks-pro/advanced-conditions/v1/conditions/?page=${t}&per_page=${e}`});if(n.success)return n.response;throw new Error("Failed to fetch conditions")}({perPage:e,page:t}),select:e=>({conditions:e?.conditions||[],total:e?.total||0,pages:e?.pages||1})})}function xe(){const e=ke({queryKey:["condition-metadata","types"],queryFn:async()=>{const e=await u()({path:"/generateblocks-pro/advanced-conditions/v1/get_condition_types"});if(e.success)return e.response;throw new Error("Failed to fetch condition types")},staleTime:6e5}),t=(0,l.useCallback)((async e=>{if(!e)return[];const t=await u()({path:`/generateblocks-pro/advanced-conditions/v1/get_condition_rules?type=${e}`});if(t.success)return t.response;throw new Error("Failed to fetch condition rules")}),[]),n=(0,l.useCallback)((async(e,t)=>{if(!e||!t)return[];const n=await u()({path:`/generateblocks-pro/advanced-conditions/v1/get_condition_operators?type=${e}&rule=${t}`});if(n.success)return n.response;throw new Error("Failed to fetch condition operators")}),[]);return{conditionTypes:e.data||{},loading:e.isLoading,error:e.error,getRulesForType:t,getOperatorsForType:n}}const Ie=(0,l.createElement)(ce.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,l.createElement)(ce.Path,{d:"M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z"})),Oe=(0,l.createElement)(ce.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,l.createElement)(ce.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"}));function Ne({currentView:t,views:n={},className:r="",minHeight:o=400,viewOrder:a=[]}){const[s,i]=(0,l.useState)(t),[c,u]=(0,l.useState)(!1),[d,p]=(0,l.useState)(!1),[h,g]=(0,l.useState)("forward");(0,l.useEffect)((()=>{d||p(!0)}),[]),(0,l.useEffect)((()=>{if(d&&s!==t){const e=a.indexOf(t),n=a.indexOf(s);g(-1!==e&&-1!==n?e>n?"forward":"backward":"forward"),u(!0);const r=setTimeout((()=>{u(!1),i(t)}),260);return()=>clearTimeout(r)}}),[t,s,d,a]);const m=["gb-navigator",r,c?"gb-navigator--transitioning":"",c?`gb-navigator--${h}`:""].filter(Boolean).join(" ");return(0,e.createElement)("div",{className:m,style:{minHeight:`${o}px`}},Object.entries(n).map((([n,r])=>{const o=n===t,a=["gb-navigator-view",`gb-navigator-view--${n}`,o?"gb-navigator-view--active":"gb-navigator-view--inactive"].join(" ");return(0,e.createElement)("div",{key:n,className:a,"aria-hidden":!o},(o||c)&&r)})))}function Te({trigger:t,itemId:n=null,itemType:r="item",dashboardView:o,editorView:a,onItemSelect:c=null,getNewTabUrl:u,modalProps:d={},labels:p={},className:h="",confirmMessages:g}){const m={backButton:(0,i.__)("Back to Dashboard","generateblocks-pro"),createNew:(0,i.__)("Create New Item","generateblocks-pro"),edit:(0,i.__)("Edit Item","generateblocks-pro"),dashboard:(0,i.__)("Dashboard","generateblocks-pro"),openInNewTab:(0,i.__)("Open in new tab","generateblocks-pro"),close:(0,i.__)("Close","generateblocks-pro"),unsavedChanges:(0,i.__)("Unsaved changes","generateblocks-pro"),...p},{isOpen:b,setIsOpen:f,currentView:_,contentHeight:y,selectedItemId:v,selectedItemTitle:k,selectedItemData:w,hasUnsavedChanges:E,setHasUnsavedChanges:C,headerRef:S,modalRef:x,handleItemSelect:I,handleBackToDashboard:O,handleBackToDashboardAfterSave:N,handleOpenInNewTab:T,handleClose:R}=function({itemId:e=null,onItemSelect:t=null,getNewTabUrl:n,confirmMessages:r={unsavedBack:(0,i.__)("You have unsaved changes. Are you sure you want to go back?","generateblocks-pro"),unsavedClose:(0,i.__)("You have unsaved changes. Are you sure you want to close?","generateblocks-pro")}}){const[o,a]=(0,l.useState)(!1),[s,c]=(0,l.useState)(e?"editor":"dashboard"),[u,d]=(0,l.useState)(0),[p,h]=(0,l.useState)(e),[g,m]=(0,l.useState)(""),[b,f]=(0,l.useState)(null),[_,y]=(0,l.useState)(!1),v=(0,l.useRef)(null),k=(0,l.useRef)(null),w=(0,l.useRef)(!1);(0,l.useEffect)((()=>{w.current||(h(e),c(e?"editor":"dashboard")),w.current=!1}),[e]);const E=(0,l.useCallback)(((e,n,r)=>{h(e),m(n||""),f(r||null),c("editor"),t&&t(e,n,r)}),[t]),C=(0,l.useCallback)((()=>{_&&!window.confirm(r.unsavedBack)||(w.current=!0,c("dashboard"),h(null),m(""),f(null),y(!1))}),[_,r.unsavedBack]),S=(0,l.useCallback)((()=>{w.current=!0,c("dashboard"),h(null),m(""),f(null),y(!1)}),[]),x=(0,l.useCallback)((()=>{if("editor"===s&&p&&n){const e=n(p,b);e&&window.open(e,"_blank")}}),[s,p,b,n]),I=(0,l.useCallback)((()=>{"editor"===s&&_&&!window.confirm(r.unsavedClose)||(a(!1),setTimeout((()=>{c(e?"editor":"dashboard"),h(e),m(""),y(!1)}),300))}),[s,_,r.unsavedClose,e]);return(0,l.useEffect)((()=>{const e=()=>{if(!k.current||!v.current||!o)return;const e=k.current.querySelector(".components-modal__content"),t=v.current;if(e&&t){const n=e.clientHeight,r=t.offsetHeight;d(n-r)}};if(o){e();const t=new ResizeObserver(e);return k.current&&t.observe(k.current),v.current&&t.observe(v.current),window.addEventListener("resize",e),()=>{t.disconnect(),window.removeEventListener("resize",e)}}}),[o]),(0,l.useEffect)((()=>{const e=e=>{"Escape"===e.key&&o&&(e.preventDefault(),I())};return o&&document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}}),[o,I]),{isOpen:o,setIsOpen:a,currentView:s,setCurrentView:c,contentHeight:u,selectedItemId:p,selectedItemTitle:g,selectedItemData:b,hasUnsavedChanges:_,setHasUnsavedChanges:y,headerRef:v,modalRef:k,handleItemSelect:E,handleBackToDashboard:C,handleBackToDashboardAfterSave:S,handleOpenInNewTab:x,handleClose:I}}({itemId:n,onItemSelect:c,getNewTabUrl:u,confirmMessages:g}),D={dashboard:o&&(0,l.cloneElement)(o,{isModalMode:!0,isIframeMode:!0,onItemSelect:e=>{"object"==typeof e&&e.id&&I(e.id,e.title?.rendered||e.title||"")},onCreateItem:()=>I("new",m.createNew),onConditionSelect:e=>{I(e.id,e.title?.rendered||"",e)},onCreateCondition:()=>I("new",m.createNew),onModalSelect:(e,t)=>{I(e,t)},onCreateOverlay:(e,t)=>I(e||"new",m.createNew,{overlayType:t})}),editor:a&&v&&(0,l.cloneElement)(a,{embedded:!0,onUnsavedChanges:C,conditionId:"new"===v?null:v,isNew:"new"===v,onNavigateBack:O,onSave:N,overlayId:v,overlayTitle:k,overlayType:w?.overlayType,onClose:O})},M={title:"",className:`gb-dashboard-trigger-modal ${h}`,isFullScreen:!0,isDismissible:!1,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,showHeader:!1,...d};return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{onClick:()=>f(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),f(!0))}},t),b&&(0,e.createElement)(s.Modal,{...M,onRequestClose:()=>{},ref:x},(0,e.createElement)("div",{className:"gb-dashboard-custom-header",ref:S,"data-item-type":r},(0,e.createElement)("div",{className:"gb-dashboard-header-left"},"editor"===_&&(0,e.createElement)(s.Button,{icon:"arrow-left-alt2",size:"compact",variant:"tertiary",onClick:O,label:m.backButton}),(0,e.createElement)("h2",{className:"gb-dashboard-custom-title"},(()=>{if("editor"===_){const e="new"===v?m.createNew:m.edit;return k&&"new"!==v?`${e}: ${k}`:e}return m.dashboard})())),(0,e.createElement)("div",{className:"gb-dashboard-header-actions"},E&&"editor"===_&&(0,e.createElement)("span",{className:"gb-dashboard-unsaved-indicator"},m.unsavedChanges),"editor"===_&&u&&(0,e.createElement)(s.Button,{icon:Ie,size:"compact",variant:"tertiary",onClick:T,label:m.openInNewTab}),(0,e.createElement)(s.Button,{icon:Oe,size:"compact",variant:"tertiary",onClick:R,label:m.close}))),(0,e.createElement)("div",{className:"gb-dashboard-content-wrapper",style:{height:y>0?`${y}px`:"auto",minHeight:y>0?`${y}px`:"auto"}},(0,e.createElement)(Ne,{currentView:_,views:D,className:"gb-dashboard-navigator",minHeight:0,viewOrder:["dashboard","editor"]}))))}const Re=(0,l.createElement)(ce.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,l.createElement)(ce.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"})),De=(0,l.createElement)(ce.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,l.createElement)(ce.Path,{d:"M20.2 8v11c0 .7-.6 1.2-1.2 1.2H6v1.5h13c1.5 0 2.7-1.2 2.7-2.8V8zM18 16.4V4.6c0-.9-.7-1.6-1.6-1.6H4.6C3.7 3 3 3.7 3 4.6v11.8c0 .9.7 1.6 1.6 1.6h11.8c.9 0 1.6-.7 1.6-1.6zm-13.5 0V4.6c0-.1.1-.1.1-.1h11.8c.1 0 .1.1.1.1v11.8c0 .1-.1.1-.1.1H4.6l-.1-.1z"})),Me=(0,l.createElement)(ce.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,l.createElement)(ce.Path,{d:"M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z"})),Pe=(0,l.createElement)(ce.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,l.createElement)(ce.Path,{d:"M18 11.3l-1-1.1-4 4V3h-1.5v11.3L7 10.2l-1 1.1 6.2 5.8 5.8-5.8zm.5 3.7v3.5h-13V15H4v5h16v-5h-1.5z"}));function Ae({conditions:t,onConditionsImport:n}){const[r,o]=(0,l.useState)(!1),[a,c]=(0,l.useState)(""),[u,d]=(0,l.useState)(!1),[p,h]=(0,l.useState)(!1),g=()=>{if(!t.groups||0===t.groups.length)return"";const e={logic:t.logic,groups:t.groups.map((e=>({logic:e.logic,conditions:e.conditions.filter((e=>e.type&&e.rule&&e.operator)).map((e=>({type:e.type,rule:e.rule,operator:e.operator,value:e.value||""})))}))).filter((e=>0<e.conditions.length))};return JSON.stringify(e,null,2)},m=t.groups&&0<t.groups.length;return(0,e.createElement)("div",{className:"gb-conditions-preview"},u?(0,e.createElement)("div",{className:"gb-import-section"},(0,e.createElement)(s.TextareaControl,{label:(0,i.__)("Import Conditions (JSON format)","generateblocks-pro"),value:a,onChange:c,rows:8,placeholder:(0,i.__)("Paste exported conditions here…","generateblocks-pro")}),(0,e.createElement)(s.Button,{variant:"primary",onClick:()=>{if(a.trim())try{const e=JSON.parse(a);if(!e.groups||!Array.isArray(e.groups))throw new Error("Invalid format: missing groups array");e.groups.forEach(((e,t)=>{if(!e.logic||!["AND","OR"].includes(e.logic))throw new Error(`Invalid logic operator in group ${t+1}`);if(!e.conditions||!Array.isArray(e.conditions))throw new Error(`Invalid conditions in group ${t+1}`);e.conditions.forEach(((e,n)=>{if(!e.type||!e.rule||!e.operator)throw new Error(`Incomplete condition ${n+1} in group ${t+1}`)}))}));const t={logic:e.logic||"OR",groups:e.groups};n(t),c(""),d(!1),alert((0,i.__)("Conditions imported successfully!","generateblocks-pro"))}catch(e){alert((0,i.__)("Import failed: ","generateblocks-pro")+e.message)}else alert((0,i.__)("Please enter conditions to import.","generateblocks-pro"))},disabled:!a.trim()},(0,i.__)("Import Conditions","generateblocks-pro"))):(0,e.createElement)(e.Fragment,null,r&&m&&(0,e.createElement)("div",{className:"gb-preview-text"},(0,e.createElement)("pre",{className:"gb-export-format"},g()||(0,i.__)("No conditions to export","generateblocks-pro")))),(0,e.createElement)("div",{className:"gb-preview-footer"},m&&(0,e.createElement)(s.ToggleControl,{label:(0,i.__)("Show JSON Format","generateblocks-pro"),checked:r,onChange:o,help:(0,i.__)("View the raw JSON format for advanced users","generateblocks-pro")}),(0,e.createElement)("div",{className:"gb-preview-actions"},m&&r&&(0,e.createElement)(s.Button,{variant:"secondary",size:"compact",icon:De,onClick:async()=>{const e=g();try{await navigator.clipboard.writeText(e),h(!0),setTimeout((()=>h(!1)),2e3)}catch(t){const n=document.createElement("textarea");n.value=e,document.body.appendChild(n),n.focus(),n.select(),document.execCommand("copy"),document.body.removeChild(n),h(!0),setTimeout((()=>h(!1)),2e3)}},className:"gb-copy-button"},p?(0,i.__)("Copied!","generateblocks-pro"):(0,i.__)("Copy JSON","generateblocks-pro")),(0,e.createElement)(s.Button,{variant:"secondary",size:"compact",icon:u?Me:Pe,onClick:()=>d(!u)},u?(0,i.__)("Cancel Import","generateblocks-pro"):(0,i.__)("Import","generateblocks-pro")))))}function Be({isOpen:t,onClose:n,onCreateCategory:r}){const[o,a]=(0,l.useState)(""),[c,u]=(0,l.useState)(!1),d=async()=>{if(o.trim()){u(!0);try{const e=o.toLowerCase().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-");await r({name:o.trim(),slug:e}),a(""),n()}catch(e){}finally{u(!1)}}},p=()=>{a(""),n()};return t?(0,e.createElement)(s.Modal,{title:(0,i.__)("Create New Category","generateblocks-pro"),onRequestClose:p,className:"gb-create-category-modal"},(0,e.createElement)("div",{className:"gb-modal-content"},(0,e.createElement)(s.TextControl,{label:(0,i.__)("Category Name","generateblocks-pro"),value:o,onChange:a,placeholder:(0,i.__)("Enter category name…","generateblocks-pro"),disabled:c,onKeyDown:e=>{"Enter"===e.key&&d()}}),(0,e.createElement)("div",{className:"gb-modal-actions",style:{display:"flex",gap:"5px",justifyContent:"space-between"}},(0,e.createElement)(s.Button,{variant:"secondary",onClick:p,disabled:c},(0,i.__)("Cancel","generateblocks-pro")),(0,e.createElement)(s.Button,{variant:"primary",onClick:d,disabled:!o.trim()||c,isBusy:c},(0,i.__)("Create Category","generateblocks-pro"))))):null}const Fe=(0,l.createElement)(ce.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,l.createElement)(ce.Path,{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm.5 16c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V7h15v12zM9 10H7v2h2v-2zm0 4H7v2h2v-2zm4-4h-2v2h2v-2zm4 0h-2v2h2v-2zm-4 4h-2v2h2v-2zm4 0h-2v2h2v-2z"}));function $e({currentDate:t,onChange:n,placeholder:r=(0,i.__)("Select date and time","generateblocks-pro")}){const[o,a]=(0,l.useState)(!1),[c,u]=(0,l.useState)(t),d=()=>{u(t),a(!1)};return(0,e.createElement)("div",{className:"gb-datetime-popover-wrapper"},(0,e.createElement)(s.Button,{variant:"secondary",icon:Fe,onClick:()=>{u(t),a(!0)},className:"gb-datetime-trigger",__next40pxDefaultSize:!0},(p=t)?p.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}):r),o&&(0,e.createElement)(s.Popover,{position:"bottom left",onClose:d,className:"gb-datetime-popover"},(0,e.createElement)("div",{className:"gb-datetime-popover-content"},(0,e.createElement)(s.DateTimePicker,{currentDate:c,onChange:u,is12Hour:!0}),(0,e.createElement)("div",{className:"gb-datetime-popover-actions"},t&&(0,e.createElement)(s.Button,{variant:"link",onClick:()=>{u(null),n(null),a(!1)},isDestructive:!0},(0,i.__)("Clear","generateblocks-pro")),(0,e.createElement)("div",{className:"gb-datetime-popover-main-actions"},(0,e.createElement)(s.Button,{variant:"tertiary",onClick:d},(0,i.__)("Cancel","generateblocks-pro")),(0,e.createElement)(s.Button,{variant:"primary",onClick:()=>{n(c),a(!1)}},(0,i.__)("Apply","generateblocks-pro")))))));var p}function qe({currentTime:t,onChange:n,placeholder:r=(0,i.__)("Select time","generateblocks-pro")}){const[o,a]=(0,l.useState)(!1),[c,u]=(0,l.useState)(t||""),[d,p]=(0,l.useState)(null),h=()=>!(!c||!/^\d{2}:\d{2}$/.test(c))||!(d&&!d.validity.valid)&&(!c&&!t||!(!c&&t)||!!d&&d.validity.valid),g=()=>{a(!1)};return(0,e.createElement)("div",{className:"gb-datetime-popover-wrapper"},(0,e.createElement)(s.Button,{variant:"secondary",icon:Fe,onClick:()=>{u(t||""),a(!0)},className:"gb-datetime-trigger",__next40pxDefaultSize:!0},(e=>{if(!e)return r;const[t,n]=e.split(":").map(Number);if(isNaN(t)||isNaN(n))return e;const o=new Date;return o.setHours(t,n,0,0),o.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})})(t)),o&&(0,e.createElement)(s.Popover,{position:"bottom left",onClose:g,className:"gb-datetime-popover gb-time-only-popover"},(0,e.createElement)("div",{className:"gb-datetime-popover-content"},(0,e.createElement)("div",{className:"gb-time-input-wrapper"},(0,e.createElement)("label",{htmlFor:"gb-time-input",className:"gb-time-input-label"},(0,i.__)("Time","generateblocks-pro")),(0,e.createElement)("input",{id:"gb-time-input",type:"time",value:c,onChange:e=>u(e.target.value),className:"gb-time-input",ref:p}),(0,e.createElement)("small",{className:"gb-time-input-help"},(0,i.__)("Enter time in HH:MM format","generateblocks-pro"))),(0,e.createElement)("div",{className:"gb-datetime-popover-actions"},t&&(0,e.createElement)(s.Button,{variant:"link",onClick:()=>{u(""),n(""),a(!1)},isDestructive:!0},(0,i.__)("Clear","generateblocks-pro")),(0,e.createElement)("div",{className:"gb-datetime-popover-main-actions"},(0,e.createElement)(s.Button,{variant:"tertiary",onClick:g},(0,i.__)("Cancel","generateblocks-pro")),(0,e.createElement)(s.Button,{variant:"primary",onClick:()=>{h()&&(n(c),a(!1))},disabled:!h()},(0,i.__)("Apply","generateblocks-pro")))))))}function Le(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function ze(){return ze=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ze.apply(null,arguments)}var He=n(5556),Ue=n.n(He);n(44363);const Ve=e=>"object"==typeof e&&null!=e&&1===e.nodeType,je=(e,t)=>(!t||"hidden"!==e)&&"visible"!==e&&"clip"!==e,Qe=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return je(n.overflowY,t)||je(n.overflowX,t)||(e=>{const t=(e=>{if(!e.ownerDocument||!e.ownerDocument.defaultView)return null;try{return e.ownerDocument.defaultView.frameElement}catch(e){return null}})(e);return!!t&&(t.clientHeight<e.scrollHeight||t.clientWidth<e.scrollWidth)})(e)}return!1},Ke=(e,t,n,r,o,a,s,i)=>a<e&&s>t||a>e&&s<t?0:a<=e&&i<=n||s>=t&&i>=n?a-e-r:s>t&&i<n||a<e&&i>n?s-t+o:0,We=e=>{const t=e.parentElement;return null==t?e.getRootNode().host||null:t};var Ge=function(){return Ge=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ge.apply(this,arguments)};Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var Ye=0;function Je(){}function Ze(e,t,n){return e===t||t instanceof n.Node&&e.contains&&e.contains(t)}function Xe(e,t){var n;function r(){n&&clearTimeout(n)}function o(){for(var o=arguments.length,a=new Array(o),s=0;s<o;s++)a[s]=arguments[s];r(),n=setTimeout((function(){n=null,e.apply(void 0,a)}),t)}return o.cancel=r,o}function et(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return t.some((function(t){return t&&t.apply(void 0,[e].concat(r)),e.preventDownshiftDefault||e.hasOwnProperty("nativeEvent")&&e.nativeEvent.preventDownshiftDefault}))}}function tt(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){t.forEach((function(t){"function"==typeof t?t(e):t&&(t.current=e)}))}}function nt(e,t){return e&&t?Object.keys(e).reduce((function(n,r){return n[r]=rt(t,r)?t[r]:e[r],n}),{}):e}function rt(e,t){return void 0!==e[t]}function ot(e,t,n,r,o){void 0===o&&(o=!1);var a=n.length;if(0===a)return-1;var s=a-1;("number"!=typeof e||e<0||e>s)&&(e=t>0?-1:s+1);var i=e+t;i<0?i=o?s:0:i>s&&(i=o?0:s);var l=at(i,t<0,n,r,o);return-1===l?e>=a?-1:e:l}function at(e,t,n,r,o){void 0===o&&(o=!1);var a=n.length;if(t){for(var s=e;s>=0;s--)if(!r(n[s],s))return s}else for(var i=e;i<a;i++)if(!r(n[i],i))return i;return o?at(t?a-1:0,t,n,r):-1}function st(e,t,n,r){return void 0===r&&(r=!0),n&&t.some((function(t){return t&&(Ze(t,e,n)||r&&Ze(t,n.document.activeElement,n))}))}var it=Xe((function(e){lt(e).textContent=""}),500);function lt(e){var t=e.getElementById("a11y-status-message");return t||((t=e.createElement("div")).setAttribute("id","a11y-status-message"),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions text"),Object.assign(t.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),e.body.appendChild(t),t)}var ct={highlightedIndex:-1,isOpen:!1,selectedItem:null,inputValue:""};var ut=Xe((function(e,t){!function(e,t){e&&t&&(lt(t).textContent=e,it(t))}(e,t)}),200),dt="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?e.useLayoutEffect:e.useEffect,pt="useId"in t()?function(n){var r=n.id,o=n.labelId,a=n.menuId,s=n.getItemId,i=n.toggleButtonId,l=n.inputId,c="downshift-"+t().useId();return r||(r=c),(0,e.useRef)({labelId:o||r+"-label",menuId:a||r+"-menu",getItemId:s||function(e){return r+"-item-"+e},toggleButtonId:i||r+"-toggle-button",inputId:l||r+"-input"}).current}:function(t){var n=t.id,r=void 0===n?"downshift-"+String(Ye++):n,o=t.labelId,a=t.menuId,s=t.getItemId,i=t.toggleButtonId,l=t.inputId;return(0,e.useRef)({labelId:o||r+"-label",menuId:a||r+"-menu",getItemId:s||function(e){return r+"-item-"+e},toggleButtonId:i||r+"-toggle-button",inputId:l||r+"-input"}).current};function ht(e){return""+e.slice(0,1).toUpperCase()+e.slice(1)}function gt(t){var n=(0,e.useRef)(t);return n.current=t,n}function mt(t,n,r,o){var a=(0,e.useRef)(),s=(0,e.useRef)(),i=(0,e.useCallback)((function(e,n){s.current=n,e=nt(e,n.props);var r=t(e,n);return n.props.stateReducer(e,ze({},n,{changes:r}))}),[t]),l=(0,e.useReducer)(i,n,r),c=l[0],u=l[1],d=gt(n),p=(0,e.useCallback)((function(e){return u(ze({props:d.current},e))}),[d]),h=s.current;return(0,e.useEffect)((function(){var e=nt(a.current,null==h?void 0:h.props);h&&a.current&&!o(e,c)&&function(e,t,n){var r=e.props,o=e.type,a={};Object.keys(t).forEach((function(r){!function(e,t,n,r){var o=t.props,a=t.type,s="on"+ht(e)+"Change";o[s]&&void 0!==r[e]&&r[e]!==n[e]&&o[s](ze({type:a},r))}(r,e,t,n),n[r]!==t[r]&&(a[r]=n[r])})),r.onStateChange&&Object.keys(a).length&&r.onStateChange(ze({type:o},a))}(h,e,c),a.current=c}),[c,h,o]),[c,p]}var bt={itemToString:function(e){return e?String(e):""},itemToKey:function(e){return e},stateReducer:function(e,t){return t.changes},scrollIntoView:function(e,t){if(e){var n=((e,t)=>{var n,r,o,a;if("undefined"==typeof document)return[];const{scrollMode:s,block:i,inline:l,boundary:c,skipOverflowHiddenElements:u}=t,d="function"==typeof c?c:e=>e!==c;if(!Ve(e))throw new TypeError("Invalid target");const p=document.scrollingElement||document.documentElement,h=[];let g=e;for(;Ve(g)&&d(g);){if(g=We(g),g===p){h.push(g);break}null!=g&&g===document.body&&Qe(g)&&!Qe(document.documentElement)||null!=g&&Qe(g,u)&&h.push(g)}const m=null!=(r=null==(n=window.visualViewport)?void 0:n.width)?r:innerWidth,b=null!=(a=null==(o=window.visualViewport)?void 0:o.height)?a:innerHeight,{scrollX:f,scrollY:_}=window,{height:y,width:v,top:k,right:w,bottom:E,left:C}=e.getBoundingClientRect(),{top:S,right:x,bottom:I,left:O}=(e=>{const t=window.getComputedStyle(e);return{top:parseFloat(t.scrollMarginTop)||0,right:parseFloat(t.scrollMarginRight)||0,bottom:parseFloat(t.scrollMarginBottom)||0,left:parseFloat(t.scrollMarginLeft)||0}})(e);let N="start"===i||"nearest"===i?k-S:"end"===i?E+I:k+y/2-S+I,T="center"===l?C+v/2-O+x:"end"===l?w+x:C-O;const R=[];for(let e=0;e<h.length;e++){const t=h[e],{height:n,width:r,top:o,right:a,bottom:c,left:u}=t.getBoundingClientRect();if("if-needed"===s&&k>=0&&C>=0&&E<=b&&w<=m&&(t===p&&!Qe(t)||k>=o&&E<=c&&C>=u&&w<=a))return R;const d=getComputedStyle(t),g=parseInt(d.borderLeftWidth,10),S=parseInt(d.borderTopWidth,10),x=parseInt(d.borderRightWidth,10),I=parseInt(d.borderBottomWidth,10);let O=0,D=0;const M="offsetWidth"in t?t.offsetWidth-t.clientWidth-g-x:0,P="offsetHeight"in t?t.offsetHeight-t.clientHeight-S-I:0,A="offsetWidth"in t?0===t.offsetWidth?0:r/t.offsetWidth:0,B="offsetHeight"in t?0===t.offsetHeight?0:n/t.offsetHeight:0;if(p===t)O="start"===i?N:"end"===i?N-b:"nearest"===i?Ke(_,_+b,b,S,I,_+N,_+N+y,y):N-b/2,D="start"===l?T:"center"===l?T-m/2:"end"===l?T-m:Ke(f,f+m,m,g,x,f+T,f+T+v,v),O=Math.max(0,O+_),D=Math.max(0,D+f);else{O="start"===i?N-o-S:"end"===i?N-c+I+P:"nearest"===i?Ke(o,c,n,S,I+P,N,N+y,y):N-(o+n/2)+P/2,D="start"===l?T-u-g:"center"===l?T-(u+r/2)+M/2:"end"===l?T-a+x+M:Ke(u,a,r,g,x+M,T,T+v,v);const{scrollLeft:e,scrollTop:s}=t;O=0===B?0:Math.max(0,Math.min(s+O/B,t.scrollHeight-n/B+P)),D=0===A?0:Math.max(0,Math.min(e+D/A,t.scrollWidth-r/A+M)),N+=s-O,T+=e-D}R.push({el:t,top:O,left:D})}return R})(e,{boundary:t,block:"nearest",scrollMode:"if-needed"});n.forEach((function(e){var t=e.el,n=e.top,r=e.left;t.scrollTop=n,t.scrollLeft=r}))}},environment:"undefined"==typeof window?void 0:window};function ft(e,t,n){void 0===n&&(n=ct);var r=e["default"+ht(t)];return void 0!==r?r:n[t]}function _t(e,t,n){void 0===n&&(n=ct);var r=e[t];if(void 0!==r)return r;var o=e["initial"+ht(t)];return void 0!==o?o:ft(e,t,n)}function yt(e,t,n){var r=e.items,o=e.initialHighlightedIndex,a=e.defaultHighlightedIndex,s=e.isItemDisabled,i=e.itemToKey,l=t.selectedItem,c=t.highlightedIndex;return 0===r.length?-1:void 0===o||c!==o||s(r[o],o)?void 0===a||s(r[a],a)?l?r.findIndex((function(e){return i(l)===i(e)})):n<0&&!s(r[r.length-1],r.length-1)?r.length-1:n>0&&!s(r[0],0)?0:-1:a:o}var vt=Je;function kt(e,t,n){var r;return void 0===n&&(n=!0),ze({isOpen:!1,highlightedIndex:-1},(null==(r=e.items)?void 0:r.length)&&t>=0&&ze({selectedItem:e.items[t],isOpen:ft(e,"isOpen"),highlightedIndex:ft(e,"highlightedIndex")},n&&{inputValue:e.itemToString(e.items[t])}))}function wt(e,t){return e.isOpen===t.isOpen&&e.inputValue===t.inputValue&&e.highlightedIndex===t.highlightedIndex&&e.selectedItem===t.selectedItem}function Et(){var e=t().useRef(!0);return t().useEffect((function(){return e.current=!1,function(){e.current=!0}}),[]),e.current}function Ct(e){var t=ft(e,"highlightedIndex");return t>-1&&e.isItemDisabled(e.items[t],t)?-1:t}var St=ze({},{environment:Ue().shape({addEventListener:Ue().func.isRequired,removeEventListener:Ue().func.isRequired,document:Ue().shape({createElement:Ue().func.isRequired,getElementById:Ue().func.isRequired,activeElement:Ue().any.isRequired,body:Ue().any.isRequired}).isRequired,Node:Ue().func.isRequired}),itemToString:Ue().func,itemToKey:Ue().func,stateReducer:Ue().func},{getA11yStatusMessage:Ue().func,highlightedIndex:Ue().number,defaultHighlightedIndex:Ue().number,initialHighlightedIndex:Ue().number,isOpen:Ue().bool,defaultIsOpen:Ue().bool,initialIsOpen:Ue().bool,selectedItem:Ue().any,initialSelectedItem:Ue().any,defaultSelectedItem:Ue().any,id:Ue().string,labelId:Ue().string,menuId:Ue().string,getItemId:Ue().func,toggleButtonId:Ue().string,onSelectedItemChange:Ue().func,onHighlightedIndexChange:Ue().func,onStateChange:Ue().func,onIsOpenChange:Ue().func,scrollIntoView:Ue().func});Ge(Ge({},St),{items:Ue().array.isRequired,isItemDisabled:Ue().func}),Ge(Ge({},bt),{isItemDisabled:function(){return!1}});var xt=Object.freeze({__proto__:null,ControlledPropUpdatedSelectedItem:22,FunctionCloseMenu:17,FunctionOpenMenu:16,FunctionReset:21,FunctionSelectItem:19,FunctionSetHighlightedIndex:18,FunctionSetInputValue:20,FunctionToggleMenu:15,InputBlur:9,InputChange:8,InputClick:10,InputKeyDownArrowDown:0,InputKeyDownArrowUp:1,InputKeyDownEnd:4,InputKeyDownEnter:7,InputKeyDownEscape:2,InputKeyDownHome:3,InputKeyDownPageDown:6,InputKeyDownPageUp:5,ItemClick:13,ItemMouseMove:12,MenuMouseLeave:11,ToggleButtonClick:14});function It(e){var t=function(e){var t=_t(e,"selectedItem"),n=_t(e,"isOpen"),r=function(e){var t=_t(e,"highlightedIndex");return t>-1&&e.isItemDisabled(e.items[t],t)?-1:t}(e),o=_t(e,"inputValue");return{highlightedIndex:r<0&&t&&n?e.items.findIndex((function(n){return e.itemToKey(n)===e.itemToKey(t)})):r,isOpen:n,selectedItem:t,inputValue:o}}(e),n=t.selectedItem,r=t.inputValue;return""===r&&n&&void 0===e.defaultInputValue&&void 0===e.initialInputValue&&void 0===e.inputValue&&(r=e.itemToString(n)),ze({},t,{inputValue:r})}ze({},St,{items:Ue().array.isRequired,isItemDisabled:Ue().func,inputValue:Ue().string,defaultInputValue:Ue().string,initialInputValue:Ue().string,inputId:Ue().string,onInputValueChange:Ue().func});var Ot=Je,Nt=ze({},bt,{isItemDisabled:function(){return!1}});function Tt(e,t){var n,r,o=t.type,a=t.props,s=t.altKey;switch(o){case 13:r={isOpen:ft(a,"isOpen"),highlightedIndex:Ct(a),selectedItem:a.items[t.index],inputValue:a.itemToString(a.items[t.index])};break;case 0:r=e.isOpen?{highlightedIndex:ot(e.highlightedIndex,1,a.items,a.isItemDisabled,!0)}:{highlightedIndex:s&&null==e.selectedItem?-1:yt(a,e,1),isOpen:a.items.length>=0};break;case 1:r=e.isOpen?s?kt(a,e.highlightedIndex):{highlightedIndex:ot(e.highlightedIndex,-1,a.items,a.isItemDisabled,!0)}:{highlightedIndex:yt(a,e,-1),isOpen:a.items.length>=0};break;case 7:r=kt(a,e.highlightedIndex);break;case 2:r=ze({isOpen:!1,highlightedIndex:-1},!e.isOpen&&{selectedItem:null,inputValue:""});break;case 5:r={highlightedIndex:ot(e.highlightedIndex,-10,a.items,a.isItemDisabled,!0)};break;case 6:r={highlightedIndex:ot(e.highlightedIndex,10,a.items,a.isItemDisabled,!0)};break;case 3:r={highlightedIndex:at(0,!1,a.items,a.isItemDisabled)};break;case 4:r={highlightedIndex:at(a.items.length-1,!0,a.items,a.isItemDisabled)};break;case 9:r=ze({isOpen:!1,highlightedIndex:-1},e.highlightedIndex>=0&&(null==(n=a.items)?void 0:n.length)&&t.selectItem&&{selectedItem:a.items[e.highlightedIndex],inputValue:a.itemToString(a.items[e.highlightedIndex])});break;case 8:r={isOpen:!0,highlightedIndex:Ct(a),inputValue:t.inputValue};break;case 10:r={isOpen:!e.isOpen,highlightedIndex:e.isOpen?-1:yt(a,e,0)};break;case 19:r={selectedItem:t.selectedItem,inputValue:a.itemToString(t.selectedItem)};break;case 22:r={inputValue:t.inputValue};break;default:return function(e,t,n){var r,o=t.type,a=t.props;switch(o){case n.ItemMouseMove:r={highlightedIndex:t.disabled?-1:t.index};break;case n.MenuMouseLeave:r={highlightedIndex:-1};break;case n.ToggleButtonClick:case n.FunctionToggleMenu:r={isOpen:!e.isOpen,highlightedIndex:e.isOpen?-1:yt(a,e,0)};break;case n.FunctionOpenMenu:r={isOpen:!0,highlightedIndex:yt(a,e,0)};break;case n.FunctionCloseMenu:r={isOpen:!1};break;case n.FunctionSetHighlightedIndex:r={highlightedIndex:a.isItemDisabled(a.items[t.highlightedIndex],t.highlightedIndex)?-1:t.highlightedIndex};break;case n.FunctionSetInputValue:r={inputValue:t.inputValue};break;case n.FunctionReset:r={highlightedIndex:Ct(a),isOpen:ft(a,"isOpen"),selectedItem:ft(a,"selectedItem"),inputValue:ft(a,"inputValue")};break;default:throw new Error("Reducer called without proper action type.")}return ze({},e,r)}(e,t,xt)}return ze({},e,r)}var Rt=["onMouseLeave","refKey","ref"],Dt=["item","index","refKey","ref","onMouseMove","onMouseDown","onClick","onPress","disabled"],Mt=["onClick","onPress","refKey","ref"],Pt=["onKeyDown","onChange","onInput","onBlur","onChangeText","onClick","refKey","ref"];function At(t){void 0===t&&(t={}),Ot(t,At);var n=ze({},Nt,t),r=n.items,o=n.scrollIntoView,a=n.environment,s=n.getA11yStatusMessage,i=function(t,n,r,o){var a=(0,e.useRef)(),s=mt(t,n,r,o),i=s[0],l=s[1],c=Et();return(0,e.useEffect)((function(){rt(n,"selectedItem")&&(c||n.itemToKey(n.selectedItem)!==n.itemToKey(a.current)&&l({type:22,inputValue:n.itemToString(n.selectedItem)}),a.current=i.selectedItem===a.current?n.selectedItem:i.selectedItem)}),[i.selectedItem,n.selectedItem]),[nt(i,n),l]}(Tt,n,It,wt),l=i[0],c=i[1],u=l.isOpen,d=l.highlightedIndex,p=l.selectedItem,h=l.inputValue,g=(0,e.useRef)(null),m=(0,e.useRef)({}),b=(0,e.useRef)(null),f=(0,e.useRef)(null),_=Et(),y=pt(n),v=(0,e.useRef)(),k=gt({state:l,props:n}),w=(0,e.useCallback)((function(e){return m.current[y.getItemId(e)]}),[y]);!function(t,n,r,o){void 0===o&&(o={});var a=o.document,s=Et();(0,e.useEffect)((function(){if(t&&!s&&a){var e=t(n);ut(e,a)}}),r),(0,e.useEffect)((function(){return function(){var e,t;ut.cancel(),(t=null==(e=a)?void 0:e.getElementById("a11y-status-message"))&&t.remove()}}),[a])}(s,l,[u,d,p,h],a);var E=function(t){var n=t.highlightedIndex,r=t.isOpen,o=t.itemRefs,a=t.getItemNodeFromIndex,s=t.menuElement,i=t.scrollIntoView,l=(0,e.useRef)(!0);return dt((function(){n<0||!r||!Object.keys(o.current).length||(!1===l.current?l.current=!0:i(a(n),s))}),[n]),l}({menuElement:g.current,highlightedIndex:d,isOpen:u,itemRefs:m,scrollIntoView:o,getItemNodeFromIndex:w});vt({props:n,state:l}),(0,e.useEffect)((function(){_t(n,"isOpen")&&b.current&&b.current.focus()}),[]),(0,e.useEffect)((function(){_||(v.current=r.length)}));var C=function(t,n,r){var o=(0,e.useRef)({isMouseDown:!1,isTouchMove:!1,isTouchEnd:!1});return(0,e.useEffect)((function(){if(!t)return Je;var e=r.map((function(e){return e.current}));function a(){o.current.isTouchEnd=!1,o.current.isMouseDown=!0}function s(r){o.current.isMouseDown=!1,st(r.target,e,t)||n()}function i(){o.current.isTouchEnd=!1,o.current.isTouchMove=!1}function l(){o.current.isTouchMove=!0}function c(r){o.current.isTouchEnd=!0,o.current.isTouchMove||st(r.target,e,t,!1)||n()}return t.addEventListener("mousedown",a),t.addEventListener("mouseup",s),t.addEventListener("touchstart",i),t.addEventListener("touchmove",l),t.addEventListener("touchend",c),function(){t.removeEventListener("mousedown",a),t.removeEventListener("mouseup",s),t.removeEventListener("touchstart",i),t.removeEventListener("touchmove",l),t.removeEventListener("touchend",c)}}),[r,t,n]),o.current}(a,(0,e.useCallback)((function(){k.current.state.isOpen&&c({type:9,selectItem:!1})}),[c,k]),(0,e.useMemo)((function(){return[g,f,b]}),[g.current,f.current,b.current])),S=Je;(0,e.useEffect)((function(){u||(m.current={})}),[u]),(0,e.useEffect)((function(){var e;u&&null!=a&&a.document&&null!=b&&null!=(e=b.current)&&e.focus&&a.document.activeElement!==b.current&&b.current.focus()}),[u,a]);var x=(0,e.useMemo)((function(){return{ArrowDown:function(e){e.preventDefault(),c({type:0,altKey:e.altKey})},ArrowUp:function(e){e.preventDefault(),c({type:1,altKey:e.altKey})},Home:function(e){k.current.state.isOpen&&(e.preventDefault(),c({type:3}))},End:function(e){k.current.state.isOpen&&(e.preventDefault(),c({type:4}))},Escape:function(e){var t=k.current.state;(t.isOpen||t.inputValue||t.selectedItem||t.highlightedIndex>-1)&&(e.preventDefault(),c({type:2}))},Enter:function(e){k.current.state.isOpen&&229!==e.which&&(e.preventDefault(),c({type:7}))},PageUp:function(e){k.current.state.isOpen&&(e.preventDefault(),c({type:5}))},PageDown:function(e){k.current.state.isOpen&&(e.preventDefault(),c({type:6}))}}}),[c,k]),I=(0,e.useCallback)((function(e){return ze({id:y.labelId,htmlFor:y.inputId},e)}),[y]),O=(0,e.useCallback)((function(e,t){var n,r=void 0===e?{}:e,o=r.onMouseLeave,a=r.refKey,s=void 0===a?"ref":a,i=r.ref,l=Le(r,Rt),u=(void 0===t?{}:t).suppressRefError;return S("getMenuProps",void 0!==u&&u,s,g),ze(((n={})[s]=tt(i,(function(e){g.current=e})),n.id=y.menuId,n.role="listbox",n["aria-labelledby"]=l&&l["aria-label"]?void 0:""+y.labelId,n.onMouseLeave=et(o,(function(){c({type:11})})),n),l)}),[c,S,y]),N=(0,e.useCallback)((function(e){var t,n,r=void 0===e?{}:e,o=r.item,a=r.index,s=r.refKey,i=void 0===s?"ref":s,l=r.ref,u=r.onMouseMove,d=r.onMouseDown,p=r.onClick;r.onPress;var h=r.disabled,g=Le(r,Dt);void 0!==h&&console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useCombobox.');var b=k.current,f=b.props,_=b.state,v=function(e,t,n,r){var o,a;if(void 0===e){if(void 0===t)throw new Error(r);o=n[t],a=t}else a=void 0===t?n.indexOf(e):t,o=e;return[o,a]}(o,a,f.items,"Pass either item or index to getItemProps!"),w=v[0],S=v[1],x=f.isItemDisabled(w,S),I=p;return ze(((t={})[i]=tt(l,(function(e){e&&(m.current[y.getItemId(S)]=e)})),t["aria-disabled"]=x,t["aria-selected"]=S===_.highlightedIndex,t.id=y.getItemId(S),t.role="option",t),!x&&((n={}).onClick=et(I,(function(){c({type:13,index:S})})),n),{onMouseMove:et(u,(function(){C.isTouchEnd||S===_.highlightedIndex||(E.current=!1,c({type:12,index:S,disabled:x}))})),onMouseDown:et(d,(function(e){return e.preventDefault()}))},g)}),[c,y,k,C,E]),T=(0,e.useCallback)((function(e){var t,n=void 0===e?{}:e,r=n.onClick;n.onPress;var o=n.refKey,a=void 0===o?"ref":o,s=n.ref,i=Le(n,Mt),l=k.current.state;return ze(((t={})[a]=tt(s,(function(e){f.current=e})),t["aria-controls"]=y.menuId,t["aria-expanded"]=l.isOpen,t.id=y.toggleButtonId,t.tabIndex=-1,t),!i.disabled&&ze({},{onClick:et(r,(function(){c({type:14})}))}),i)}),[c,k,y]),R=(0,e.useCallback)((function(e,t){var n,r=void 0===e?{}:e,o=r.onKeyDown,s=r.onChange,i=r.onInput,l=r.onBlur;r.onChangeText;var u=r.onClick,d=r.refKey,p=void 0===d?"ref":d,h=r.ref,g=Le(r,Pt),m=(void 0===t?{}:t).suppressRefError;S("getInputProps",void 0!==m&&m,p,b);var f,_=k.current.state,v={};return g.disabled||((f={}).onChange=et(s,i,(function(e){c({type:8,inputValue:e.target.value})})),f.onKeyDown=et(o,(function(e){var t=function(e){var t=e.key,n=e.keyCode;return n>=37&&n<=40&&0!==t.indexOf("Arrow")?"Arrow"+t:t}(e);t&&x[t]&&x[t](e)})),f.onBlur=et(l,(function(e){if(null!=a&&a.document&&_.isOpen&&!C.isMouseDown){var t=null===e.relatedTarget&&a.document.activeElement!==a.document.body;c({type:9,selectItem:!t})}})),f.onClick=et(u,(function(){c({type:10})})),v=f),ze(((n={})[p]=tt(h,(function(e){b.current=e})),n["aria-activedescendant"]=_.isOpen&&_.highlightedIndex>-1?y.getItemId(_.highlightedIndex):"",n["aria-autocomplete"]="list",n["aria-controls"]=y.menuId,n["aria-expanded"]=_.isOpen,n["aria-labelledby"]=g&&g["aria-label"]?void 0:y.labelId,n.autoComplete="off",n.id=y.inputId,n.role="combobox",n.value=_.inputValue,n),v,g)}),[c,y,a,x,k,C,S]),D=(0,e.useCallback)((function(){c({type:15})}),[c]),M=(0,e.useCallback)((function(){c({type:17})}),[c]),P=(0,e.useCallback)((function(){c({type:16})}),[c]),A=(0,e.useCallback)((function(e){c({type:18,highlightedIndex:e})}),[c]),B=(0,e.useCallback)((function(e){c({type:19,selectedItem:e})}),[c]);return{getItemProps:N,getLabelProps:I,getMenuProps:O,getInputProps:R,getToggleButtonProps:T,toggleMenu:D,openMenu:P,closeMenu:M,setHighlightedIndex:A,setInputValue:(0,e.useCallback)((function(e){c({type:20,inputValue:e})}),[c]),selectItem:B,reset:(0,e.useCallback)((function(){c({type:21})}),[c]),highlightedIndex:d,isOpen:u,selectedItem:p,inputValue:h}}At.stateChangeTypes=xt,Ue().array,Ue().array,Ue().array,Ue().func,Ue().number,Ue().number,Ue().number,Ue().func,Ue().func,Ue().string,Ue().string;const Bt=(0,l.createElement)(ce.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,l.createElement)(ce.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"})),Ft=(0,l.createElement)(ce.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,l.createElement)(ce.Path,{d:"M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"})),$t=(0,l.createElement)(ce.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,l.createElement)(ce.Path,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"}));function qt({rule:t,ruleMetadata:n,searchContent:r,searchResults:o,recentItems:a,isSearching:c,value:u,onSelect:d,placeholder:p,isMultiValue:h=!1,readOnly:g=!1,className:m="",currentSelectedValues:b=[]}){const[f,_]=(0,l.useState)([]),[y,v]=(0,l.useState)(!1),[k,w]=(0,l.useState)(!1),E=(0,l.useRef)(u),C=(0,l.useRef)(t);(0,l.useEffect)((()=>{u!==E.current&&(E.current=u,w(!1))}),[u]);const S=(0,l.useCallback)((e=>{const t=e.id.toString();return b.map((e=>e.toString())).includes(t)}),[b]),x=(0,l.useCallback)((e=>{if(!e)return"";const t=e.title||e.name||"";return""!==e.id&&e.id&&"searching"!==e.type?`${t} (ID: ${e.id})`:t}),[]),I=(0,l.useCallback)((()=>{if(h)return null;if("object_selector"!==n.value_type&&"hierarchical_object_selector"!==n.value_type)return null;if("author_id"===t)return null;let e=(0,i.__)("All Items","generateblocks-pro");if(t.startsWith("post:")){const n=t.replace("post:","");switch(n){case"post":e=(0,i.__)("All Posts","generateblocks-pro");break;case"page":e=(0,i.__)("All Pages","generateblocks-pro");break;default:const t=n.charAt(0).toUpperCase()+n.slice(1);e=`${(0,i.__)("All","generateblocks-pro")} ${t}`}}else t.startsWith("taxonomy:")||t.startsWith("post_terms:")?e=(0,i.__)("All Terms","generateblocks-pro"):"child_of"===t?e=(0,i.__)("Any Parent","generateblocks-pro"):"parent_of"===t&&(e=(0,i.__)("Any Child","generateblocks-pro"));return{id:"",title:e,name:e}}),[t,n.value_type,h]),O=(0,l.useCallback)((e=>{const t=I();return t&&e===(t.title||t.name)}),[I]),N=(0,l.useCallback)((()=>h?0<b.length:u&&u.trim()&&!O(u)),[h,b,u,O]),T=(0,l.useCallback)((e=>{g||(O(e)&&!k||!k?v(!1):(v(!0),r(e)))}),[r,g,O,k]),{isOpen:R,getMenuProps:D,getInputProps:M,highlightedIndex:P,getItemProps:A,selectItem:B,setHighlightedIndex:F,closeMenu:$,openMenu:q,setInputValue:L}=At({items:f,itemToString:e=>e?x(e):"",defaultInputValue:h?"":u,onInputValueChange:({inputValue:e,type:t})=>{t===At.stateChangeTypes.InputChange&&w(!0),T(e||"")},onSelectedItemChange:({selectedItem:e})=>{e&&"searching"!==e.type&&(w(!1),d(e))},onIsOpenChange:({isOpen:e})=>{e&&(v(!1),w(!1))},stateReducer:(e,t)=>{const{type:n,changes:r}=t;switch(n){case At.stateChangeTypes.InputKeyDownEnter:case At.stateChangeTypes.ItemClick:return r.selectedItem&&"searching"===r.selectedItem.type?e:{...r,inputValue:h?"":x(r.selectedItem),isOpen:h};case At.stateChangeTypes.InputBlur:return{...r,isOpen:!!g&&e.isOpen};case At.stateChangeTypes.MenuKeyDownEscape:return{...r,isOpen:!1};case At.stateChangeTypes.InputClick:case At.stateChangeTypes.InputFocus:return w(!1),v(!1),r;default:return r}}});(0,l.useEffect)((()=>{!k&&L&&L((h?"":u)||"")}),[u,k,h,L]);const z=(0,l.useCallback)((e=>{if(e.preventDefault(),e.stopPropagation(),g||h)return;const t=I();t?B(t):d({id:"",title:"",name:""})}),[g,h,I,B,d]);(0,l.useEffect)((()=>{if(t!==C.current&&(C.current=t,!h&&(!u||O(u)))){const e=I();e&&B&&setTimeout((()=>{B(e)}),0)}}),[t,h,u,I,B,O]),(0,l.useEffect)((()=>{const e=I(),t=[];c&&y&&k&&t.push({id:"searching",title:(0,i.__)("Searching…","generateblocks-pro"),name:(0,i.__)("Searching…","generateblocks-pro"),type:"searching"}),e&&t.push(e),y&&k&&0<o.length?t.push(...o):0<a.length&&t.push(...a),_(t)}),[o,a,y,k,I,c]);const H=(0,l.useCallback)((e=>{if(!g||" "!==e.key||(e.preventDefault(),R)){if(R)switch(e.key){case"Tab":if(e.preventDefault(),e.shiftKey){const e=0>=P?f.length-1:P-1;F(e)}else{const e=f.length-1<=P?0:P+1;F(e)}break;case"Enter":e.preventDefault(),0<=P&&f[P]&&"searching"!==f[P].type&&B(f[P]);break;case"Escape":e.preventDefault(),$();break;case" ":g&&R&&(e.preventDefault(),0<=P&&f[P]&&"searching"!==f[P].type&&B(f[P]));break;case"ArrowDown":case"ArrowUp":break;default:g&&1===e.key.length&&e.preventDefault()}}else q()}),[R,P,f,F,B,$,q,g]);return(0,e.createElement)("div",{className:`gb-object-selector ${m}`},(0,e.createElement)("div",{className:"gb-combobox-container"},(0,e.createElement)("div",{className:"gb-input-wrapper"},(0,e.createElement)("input",{...M({placeholder:p,className:"components-text-control__input gb-object-search",onKeyDown:H,"aria-expanded":R,"aria-haspopup":"listbox",tabIndex:0}),style:{cursor:g?"pointer":"text",userSelect:g?"none":"text"}}),(0,e.createElement)("div",{className:"gb-input-icons"},N()&&!g&&(0,e.createElement)(s.Button,{icon:Bt,onClick:z,className:"gb-clear-button",size:"compact",label:(0,i.__)("Clear selection","generateblocks-pro"),iconSize:"16"}),0<f.length&&(0,e.createElement)("span",{className:"gb-dropdown-indicator "+(R?"gb-dropdown-indicator--open":""),"aria-hidden":"true"},R?Ft:$t))),(0,e.createElement)("ul",{...D({className:"gb-search-results",role:"listbox","aria-label":(0,i.__)("Search results","generateblocks-pro"),style:{display:R&&0<f.length?"block":"none"}})},R&&0<f.length&&(0,e.createElement)(e.Fragment,null,!g&&!y&&0<a.length&&!c&&(0,e.createElement)("li",{className:"gb-search-results-header",role:"presentation"},(0,i.__)("Recent Items","generateblocks-pro")),f.map(((t,n)=>{const r=S(t),o=P===n,a="searching"===t.type;return(0,e.createElement)("li",{key:`${t.id}-${n}`,...A({item:t,index:n,role:"option","aria-selected":r}),className:`gb-search-result-item ${o?"gb-search-result-item--highlighted":""} ${r?"gb-search-result-item--selected":""} ${a?"gb-search-result-item--searching":""}`,style:{cursor:a?"default":"pointer"}},a?(0,e.createElement)("div",{className:"gb-search-result-item__searching"},(0,e.createElement)(s.Spinner,{size:"16"}),(0,e.createElement)("span",{className:"gb-search-result-item__text"},t.title||t.name)):(0,e.createElement)(e.Fragment,null,(0,e.createElement)("span",{className:"gb-search-result-item__text"},x(t)),r&&(0,e.createElement)("span",{className:"gb-search-result-item__check","aria-hidden":"true"},"✓")))}))))))}const Lt=({condition:t,groupIndex:n,conditionIndex:r,onUpdate:o,onRemove:a,conditionTypes:c,logicOperator:d="AND",selectedObjectTitles:p,setSelectedObjectTitles:h})=>{const{getRulesForType:g,getOperatorsForType:m}=xe(),[b,f]=(0,l.useState)({}),[_,y]=(0,l.useState)({}),[v,k]=(0,l.useState)({}),[w,E]=(0,l.useState)(!1),[C,S]=(0,l.useState)([]),[x,I]=(0,l.useState)([]),[O,N]=(0,l.useState)(""),[T,R]=(0,l.useState)(!1),[D,M]=(0,l.useState)(!1),P=()=>t.type&&t.operator&&t.rule;(0,l.useEffect)((()=>{t.type&&t.operator&&t.rule&&!D&&M(!0)}),[t.type,t.operator,t.rule,D]),(0,l.useEffect)((()=>{t.type&&(async()=>{try{E(!0);const e=await g(t.type);let a;if(f(e),a=t.rule?await m(t.type,t.rule):await m(t.type),y(a),t.operator&&t.rule){const e=await m(t.type,t.rule);if(e&&!e[t.operator]){const a=Object.keys(e)[0];if(a){const e={...t,operator:a};o(n,r,e)}}}}catch(e){console.error("Error loading condition data:",e)}finally{E(!1)}})()}),[t.type,t.rule,g,m]),(0,l.useEffect)((()=>{if(t.type&&t.rule&&t.operator&&0!==Object.keys(_).length&&!_[t.operator]){const e=Object.keys(_)[0];if(e){const a={...t,operator:e};o(n,r,a)}else{const e={...t,operator:""};o(n,r,e)}}}),[t.operator,_]),(0,l.useEffect)((()=>{t.type&&t.rule?(async()=>{try{const e=await u()({path:`/generateblocks-pro/advanced-conditions/v1/get_rule_metadata?type=${t.type}&rule=${encodeURIComponent(t.rule)}`});e.success&&k(e.response)}catch(e){console.error("Error loading rule metadata:",e),k({needs_value:!0,value_type:"text",supports_multi:!1})}})():k({})}),[t.type,t.rule]),(0,l.useEffect)((()=>{B()?I(A()):ee()&&t.rule?(async()=>{try{let e;if("hierarchical_object_selector"===v.value_type)e=await u()({path:"/generateblocks-pro/advanced-conditions/v1/search_hierarchical_posts"});else if("author_id"===t.rule)e=await u()({path:"/generateblocks-pro/advanced-conditions/v1/search_users"});else if(t.rule.startsWith("post:")){const n=t.rule.replace("post:","");e=await u()({path:`/generateblocks-pro/advanced-conditions/v1/search_posts?post_type=${n}`})}else if(t.rule.startsWith("taxonomy:")){const n=t.rule.replace("taxonomy:","");e=await u()({path:`/generateblocks-pro/advanced-conditions/v1/search_terms?taxonomy=${n}`})}else if(t.rule.startsWith("post_terms:")){const n=t.rule.replace("post_terms:","");e=await u()({path:`/generateblocks-pro/advanced-conditions/v1/search_terms?taxonomy=${n}`})}e?.success&&I(e.response)}catch(e){console.error("Error loading recent items:",e)}})():I([])}),[t.rule,v.value_type]);const A=()=>[{id:"1",name:(0,i.__)("Monday","generateblocks-pro")},{id:"2",name:(0,i.__)("Tuesday","generateblocks-pro")},{id:"3",name:(0,i.__)("Wednesday","generateblocks-pro")},{id:"4",name:(0,i.__)("Thursday","generateblocks-pro")},{id:"5",name:(0,i.__)("Friday","generateblocks-pro")},{id:"6",name:(0,i.__)("Saturday","generateblocks-pro")},{id:"7",name:(0,i.__)("Sunday","generateblocks-pro")}],B=()=>"day_selector"===v.value_type,F=()=>"datetime"===v.value_type,$=()=>"time"===v.value_type,q=()=>F()&&"between"===t.operator,L=()=>$()&&"between"===t.operator,z=()=>!!t.operator&&(G()&&Y()||ee()&&H()||q()||L()),H=()=>["includes_any","includes_all","excludes_any","excludes_all"].includes(t.operator),U=()=>(e=>{if(!e)return[];if(Array.isArray(e))return e;try{const t=JSON.parse(e);if(Array.isArray(t))return t}catch(e){}return[e]})(t.value),V=e=>{if(!e)return null;const t=new Date(e);return isNaN(t.getTime())?null:t},j=e=>e?("string"==typeof e&&(e=new Date(e)),isNaN(e.getTime())?"":`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}T${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`):"",Q=()=>{if(!q()||!t.value)return null;const e=t.value.split(",").map((e=>e.trim()));return V(e[0])},K=()=>{if(!q()||!t.value)return null;const e=t.value.split(",").map((e=>e.trim()));return V(e[1])},W=(e,t)=>{const n=[e?j(e):"",t?j(t):""].filter((e=>e)).join(", ");re("value",n)},G=()=>"custom_field"===v.value_type,Y=()=>!!G()&&["equals","contains","not_contains","starts_with","ends_with","greater_than","less_than"].includes(t.operator),J=()=>G()&&t.value?t.value.includes("|")?t.value.split("|")[0]:t.value:"",Z=()=>G()&&t.value&&t.value.includes("|")&&t.value.split("|")[1]||"",X=(e,t="")=>{let n=e;t&&Y()&&(n=`${e}|${t}`),re("value",n)},ee=()=>"object_selector"===v.value_type||"hierarchical_object_selector"===v.value_type||"day_selector"===v.value_type,te=()=>{switch(v.value_type){case"custom_field":return"query_arg"===t.type?(0,i.__)("Parameter name","generateblocks-pro"):"post_meta"===t.type?(0,i.__)("Meta key","generateblocks-pro"):(0,i.__)("Field name","generateblocks-pro");case"datetime":return(0,i.__)("Select date and time","generateblocks-pro");case"time":return(0,i.__)("Select time","generateblocks-pro");case"day_selector":return H()?(0,i.__)("Select days…","generateblocks-pro"):(0,i.__)("Select day…","generateblocks-pro");case"hierarchical_object_selector":return"child_of"===t.rule?H()?(0,i.__)("Select parent posts (or leave empty for any parent)","generateblocks-pro"):(0,i.__)("Any Parent (or search for specific)","generateblocks-pro"):"parent_of"===t.rule?H()?(0,i.__)("Select child posts (or leave empty for any child)","generateblocks-pro"):(0,i.__)("Any Child (or search for specific)","generateblocks-pro"):H()?(0,i.__)("Select multiple…","generateblocks-pro"):(0,i.__)("Search or select…","generateblocks-pro");case"object_selector":if("author_id"===t.rule)return H()?(0,i.__)("Select multiple authors…","generateblocks-pro"):(0,i.__)("Select author…","generateblocks-pro");if("location"===t.type&&t.rule.startsWith("post:")){const e=t.rule.replace("post:","");switch(e){case"post":return H()?(0,i.__)("Select multiple posts…","generateblocks-pro"):(0,i.__)("All Posts (or search for specific)","generateblocks-pro");case"page":return H()?(0,i.__)("Select multiple pages…","generateblocks-pro"):(0,i.__)("All Pages (or search for specific)","generateblocks-pro");default:const t=e.charAt(0).toUpperCase()+e.slice(1);return H()?`${(0,i.__)("Select multiple","generateblocks-pro")} ${t}...`:`${(0,i.__)("All","generateblocks-pro")} ${t} (${(0,i.__)("or search for specific","generateblocks-pro")})`}}return H()?(0,i.__)("Select multiple…","generateblocks-pro"):(0,i.__)("Search or select…","generateblocks-pro");default:return"referrer"===t.type?(0,i.__)("Referrer URL or domain","generateblocks-pro"):(0,i.__)("Value","generateblocks-pro")}},ne=(0,l.useCallback)((async e=>{if(B())return S([]),void R(!1);if(!t.rule||!e)return S([]),void R(!1);try{let n;R(!0);const r=/^\d+$/.test(e.trim()),o=new URLSearchParams;if("hierarchical_object_selector"===v.value_type)r?o.set("id",e.trim()):o.set("search",e),n=await u()({path:`/generateblocks-pro/advanced-conditions/v1/search_hierarchical_posts?${o.toString()}`});else if("author_id"===t.rule)r?o.set("id",e.trim()):o.set("search",e),n=await u()({path:`/generateblocks-pro/advanced-conditions/v1/search_users?${o.toString()}`});else if(t.rule.startsWith("post:")){const a=t.rule.replace("post:","");o.set("post_type",a),r?o.set("id",e.trim()):o.set("search",e),n=await u()({path:`/generateblocks-pro/advanced-conditions/v1/search_posts?${o.toString()}`})}else if(t.rule.startsWith("taxonomy:")){const a=t.rule.replace("taxonomy:","");o.set("taxonomy",a),r?o.set("id",e.trim()):o.set("search",e),n=await u()({path:`/generateblocks-pro/advanced-conditions/v1/search_terms?${o.toString()}`})}else if(t.rule.startsWith("post_terms:")){const a=t.rule.replace("post_terms:","");o.set("taxonomy",a),r?o.set("id",e.trim()):o.set("search",e),n=await u()({path:`/generateblocks-pro/advanced-conditions/v1/search_terms?${o.toString()}`})}n?.success&&S(n.response)}catch(e){console.error("Error searching content:",e)}finally{R(!1)}}),[t.rule,v.value_type]),re=(e,a)=>{M(!0);const s={...t,[e]:a};if("type"===e){if(s.rule="",s.operator="",s.value="",a){const e={location:{operator:"is",rule:"general:front_page"},user_role:{operator:"is",rule:"general:logged_in"},date_time:{operator:"after",rule:"current_date"},device:{operator:"is",rule:"mobile"},query_arg:{operator:"exists",rule:"custom"},referrer:{operator:"contains",rule:"custom"},post_meta:{operator:"exists",rule:"custom"},user_meta:{operator:"exists",rule:"custom"},cookie:{operator:"exists",rule:"custom"},language:{operator:"is",rule:"locale"},options:{operator:"equals",rule:"custom"},author:{operator:"is",rule:"author_id"}}[a]||{operator:null,rule:null};e.operator&&(s.operator=e.operator),e.rule&&(s.rule=e.rule)}}else"operator"===e?H()!==["includes_any","includes_all","excludes_any","excludes_all"].includes(a)&&(s.value=""):"rule"===e&&(s.value="",h((e=>{const t={...e};return delete t[`${n}-${r}`],Object.keys(t).forEach((e=>{e.startsWith(`${n}-${r}-`)&&delete t[e]})),t})));o(n,r,s)};return(0,e.createElement)("div",{className:(()=>{let e="gb-condition-row";return D&&P()?e+=" gb-condition-complete":D&&!P()&&(e+=" gb-condition-incomplete"),e})()},(0,e.createElement)("div",{className:"gb-condition-row-main"},0===r?(0,e.createElement)("div",{className:"gb-logic-label"},(0,e.createElement)("span",{className:`gb-logic-operator gb-logic-${d.toLowerCase()}`},"IF")):(0,e.createElement)("div",{className:"gb-logic-label"},(0,e.createElement)("span",{className:`gb-logic-operator gb-logic-${d.toLowerCase()}`},d)),(0,e.createElement)("div",{className:"gb-condition-fields"},(0,e.createElement)(s.SelectControl,{value:t.type,onChange:e=>re("type",e),options:[{label:(0,i.__)("Select type…","generateblocks-pro"),value:""},...Object.entries(c).sort((([,e],[,t])=>e.label.localeCompare(t.label))).map((([e,t])=>({label:t.label,value:e})))],className:"gb-condition-type",__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),w&&(0,e.createElement)(s.Spinner,null),t.type&&!w&&(0,e.createElement)(s.SelectControl,{value:t.operator,onChange:e=>re("operator",e),options:[{label:(0,i.__)("Select operator…","generateblocks-pro"),value:""},...Object.entries(_).map((([e,t])=>({label:t,value:e})))],className:"gb-condition-operator",disabled:w,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),t.type&&!w&&(0,e.createElement)(s.SelectControl,{value:t.rule,onChange:e=>re("rule",e),options:[{label:(0,i.__)("Select rule…","generateblocks-pro"),value:""},...Object.entries(b).filter((([e])=>"date_time"!==t.type||"time_of_day"!==e||"time_of_day"===t.rule)).map((([e,t])=>({label:t,value:e})))],className:"gb-condition-rule",__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),t.rule&&t.operator&&!z()&&(0,e.createElement)(e.Fragment,null,G()&&!Y()&&(0,e.createElement)(s.TextControl,{value:J(),onChange:e=>X(e),placeholder:te(),className:"gb-condition-value",__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),!(!t.operator||["exists","not_exists"].includes(t.operator))&&(void 0===v.needs_value||v.needs_value)&&!G()&&!ee()&&!F()&&!$()&&(0,e.createElement)(s.TextControl,{value:t.value||"",onChange:e=>re("value",e),placeholder:te(),className:"gb-condition-value",__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),F()&&!q()&&(0,e.createElement)($e,{currentDate:F()&&t.value&&!q()?V(t.value):null,onChange:e=>{const t=j(e);re("value",t)},placeholder:te()}),$()&&!L()&&(0,e.createElement)(qe,{currentTime:t.value||"",onChange:e=>re("value",e),placeholder:te()}),ee()&&!H()&&(0,e.createElement)(qt,{rule:t.rule,ruleMetadata:v,searchContent:ne,searchResults:C,recentItems:x,isSearching:T,value:(()=>{let e=p[`${n}-${r}`];if(!e&&t.value&&t.value.trim()){const o=`${n}-${r}-${t.value.trim()}`;e=p[o]}if(e)return t.value&&t.value.trim()&&!e.startsWith("ID: ")?`${e} (ID: ${t.value.trim()})`:e;if(!t.value||""===t.value){if("author_id"===t.rule)return"";if(t.rule.startsWith("post:")){const e=t.rule.replace("post:","");switch(e){case"post":return(0,i.__)("All Posts","generateblocks-pro");case"page":return(0,i.__)("All Pages","generateblocks-pro");default:const t=e.charAt(0).toUpperCase()+e.slice(1);return`${(0,i.__)("All","generateblocks-pro")} ${t}`}}else{if(t.rule.startsWith("taxonomy:")||t.rule.startsWith("post_terms:"))return(0,i.__)("All Terms","generateblocks-pro");if("child_of"===t.rule)return(0,i.__)("Any Parent","generateblocks-pro");if("parent_of"===t.rule)return(0,i.__)("Any Child","generateblocks-pro")}return(0,i.__)("All Items","generateblocks-pro")}return t.value&&t.value.trim()?`ID: ${t.value.trim()}`:""})(),onSelect:e=>{re("value",e.id.toString()),h((t=>({...t,[`${n}-${r}`]:e.title||e.name}))),S([])},placeholder:te(),isMultiValue:!1,readOnly:B(),className:"gb-inline-selector",currentSelectedValues:[t.value||""]}))),(0,e.createElement)(s.Button,{isDestructive:!0,variant:"tertiary",icon:Re,onClick:()=>a(n,r),className:"gb-remove-condition",label:(0,i.__)("Remove condition","generateblocks-pro"),size:"compact",iconSize:"16"})),t.rule&&t.operator&&z()&&(0,e.createElement)("div",{className:"gb-condition-expansion"},G()&&Y()&&(0,e.createElement)("div",{className:"gb-custom-field-expansion"},(0,e.createElement)("div",{className:"gb-custom-field-inputs"},(0,e.createElement)(s.TextControl,{value:J(),onChange:e=>X(e,Z()),label:te(),className:"gb-condition-custom-field"}),(0,e.createElement)(s.TextControl,{value:Z(),onChange:e=>X(J(),e),label:(0,i.__)("Value to compare","generateblocks-pro"),className:"gb-condition-comparison-value"}))),q()&&(0,e.createElement)("div",{className:"gb-date-range-expansion"},(0,e.createElement)("div",{className:"gb-date-range-inputs"},(0,e.createElement)("div",{className:"gb-datetime-picker-field"},(0,e.createElement)("div",{className:"components-base-control__label"},(0,i.__)("Start Date & Time","generateblocks-pro")),(0,e.createElement)($e,{currentDate:Q(),onChange:e=>W(e,K()),placeholder:(0,i.__)("Select start date…","generateblocks-pro")})),(0,e.createElement)("div",{className:"gb-datetime-picker-field"},(0,e.createElement)("div",{className:"components-base-control__label"},(0,i.__)("End Date & Time","generateblocks-pro")),(0,e.createElement)($e,{currentDate:K(),onChange:e=>W(Q(),e),placeholder:(0,i.__)("Select end date…","generateblocks-pro")})))),L()&&(0,e.createElement)("div",{className:"gb-time-range-expansion"},(0,e.createElement)("div",{className:"gb-time-range-inputs"},(0,e.createElement)("div",{className:"gb-time-picker-field"},(0,e.createElement)("div",{className:"components-base-control__label"},(0,i.__)("Start Time","generateblocks-pro")),(0,e.createElement)(qe,{currentTime:t.value?t.value.split(",")[0]?.trim():"",onChange:e=>{const n=t.value?t.value.split(",")[1]?.trim():"";re("value",e&&n?`${e}, ${n}`:e||"")},placeholder:(0,i.__)("Select start time…","generateblocks-pro")})),(0,e.createElement)("div",{className:"gb-time-picker-field"},(0,e.createElement)("div",{className:"components-base-control__label"},(0,i.__)("End Time","generateblocks-pro")),(0,e.createElement)(qe,{currentTime:t.value?t.value.split(",")[1]?.trim():"",onChange:e=>{const n=t.value?t.value.split(",")[0]?.trim():"";re("value",n&&e?`${n}, ${e}`:e||"")},placeholder:(0,i.__)("Select end time…","generateblocks-pro")})))),ee()&&H()&&(0,e.createElement)("div",{className:"gb-multi-select-expansion"},(0,e.createElement)("div",{className:"gb-multi-object-selector"},(0,e.createElement)("div",{className:"gb-selected-items"},0===U().length?(0,e.createElement)("div",{className:"gb-empty-selection"},(0,e.createElement)("span",null,(0,i.__)("No items selected","generateblocks-pro"))):U().map((t=>{const o=p[`${n}-${r}-${t}`]||`ID: ${t}`;return(0,e.createElement)("div",{key:t,className:"gb-selected-item"},(0,e.createElement)("span",null,o),(0,e.createElement)(s.Button,{icon:Oe,onClick:()=>(e=>{const t=U().filter((t=>t!==e));re("value",t.length>0?JSON.stringify(t):""),h((t=>{const o={...t};return delete o[`${n}-${r}-${e}`],o}))})(t),className:"gb-remove-selected-item",size:"compact",iconSize:"12",label:(0,i.__)("Remove item","generateblocks-pro")}))}))),(0,e.createElement)(qt,{rule:t.rule,ruleMetadata:v,searchContent:ne,searchResults:C,recentItems:x,isSearching:T,value:O,onSelect:e=>{const t=U(),o=e.id.toString();if(!t.includes(o)){const a=[...t,o];re("value",JSON.stringify(a)),h((t=>({...t,[`${n}-${r}-${o}`]:e.title||e.name})))}N(""),S([])},placeholder:B()?(0,i.__)("Click to select days…","generateblocks-pro"):(0,i.__)("Search to add items…","generateblocks-pro"),isMultiValue:!0,readOnly:B(),className:"",currentSelectedValues:U()})))))};function zt(e){if(null===e||"object"!=typeof e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(zt);if("object"==typeof e){const t={};for(const n in e)e.hasOwnProperty(n)&&(t[n]=zt(e[n]));return t}return e}function Ht(e,t){if(e===t)return!0;if(null===e||null===t||"object"!=typeof e||"object"!=typeof t)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){if(!r.includes(o))return!1;if(!Ht(e[o],t[o]))return!1}return!0}function Ut({onNavigateBack:t,onSave:n=null,initialConditions:r=null,initialTitle:o="",conditionId:a=null,isNew:c=!1,onUnsavedChanges:d=null}){const{conditionTypes:p,loading:h}=xe(),g=Ee({mutationFn:async({title:e,conditions:t,category:n,status:r})=>{let o;o=n?Array.isArray(n)?n:[n]:[];const a=await u()({path:"/generateblocks-pro/advanced-conditions/v1/conditions/",method:"POST",data:{title:e,conditions:t||{logic:"OR",groups:[]},category:o.length>0?o:"",status:r||"publish"}});if(a.success)return a.response;throw new Error("Failed to create condition")},onSuccess:()=>{le()}}),m=Ee({mutationFn:async({id:e,title:t,conditions:n,category:r,status:o})=>{let a;a=r?Array.isArray(r)?r:[r]:[];const s=await u()({path:`/generateblocks-pro/advanced-conditions/v1/conditions/${e}`,method:"PUT",data:{title:t,category:a.length>0?a:"",conditions:n,status:o}});if(s.success)return s.response;throw new Error("Failed to update condition")},onSuccess:()=>{le()}}),b=(0,l.useRef)(null),f=!!a&&!c,_=(0,l.useMemo)((()=>({conditions:r?.groups?.length>0?zt(r):{logic:"OR",groups:[{logic:"AND",conditions:[{type:"",rule:"",operator:"",value:""}]}]},conditionTitle:o||"",selectedObjectTitles:{},isSaving:!1})),[r,o]),[y,v]=(0,l.useState)(_.conditions),[k,w]=(0,l.useState)(_.conditionTitle),[E,C]=(0,l.useState)(""),[S,x]=(0,l.useState)("publish"),[I,O]=(0,l.useState)([]),[N,T]=(0,l.useState)(!1),[R,D]=(0,l.useState)(_.selectedObjectTitles),[M,P]=(0,l.useState)(_.isSaving),[A,B]=(0,l.useState)(null),[F,$]=(0,l.useState)(null);(0,l.useEffect)((()=>{v(r?.groups?.length>0?zt(r):{logic:"OR",groups:[{logic:"AND",conditions:[{type:"",rule:"",operator:"",value:""}]}]}),w(o||""),D({})}),[r,o]),(0,l.useEffect)((()=>{f&&a&&(async()=>{try{const e=await u()({path:`/generateblocks-pro/advanced-conditions/v1/conditions/${a}`});if(e?.success){if(e.response?.gblocks_condition_cat?.length>0){const t=e.response.gblocks_condition_cat[0],n=await u()({path:`/wp/v2/condition-categories/${t}`});n&&n.slug&&C(n.slug)}e.response?.status&&(x(e.response.status),$((t=>({...t,conditionStatus:e.response.status}))))}}catch(e){}})()}),[f,a]),(0,l.useEffect)((()=>{(async()=>{try{const e=await u()({path:"/wp/v2/condition-categories"});e&&O(e)}catch(e){}})()}),[]),(0,l.useEffect)((()=>{v(_.conditions),w(_.conditionTitle),D(_.selectedObjectTitles),P(_.isSaving),B(null),$({conditions:zt(_.conditions),conditionTitle:_.conditionTitle,conditionStatus:"publish"})}),[_]);const q=(0,l.useMemo)((()=>!!F&&!Ht({conditions:y,conditionTitle:k,conditionStatus:S},F)),[y,k,S,F]);(0,l.useEffect)((()=>{d&&d(q);const e=new CustomEvent("gb-conditions-unsaved-changes",{detail:{hasUnsavedChanges:q}});window.dispatchEvent(e)}),[q,d]),(0,l.useEffect)((()=>{if(!q)return;const e=e=>(e.preventDefault(),e.returnValue=(0,i.__)("You have unsaved changes. Are you sure you want to leave?","generateblocks-pro"),e.returnValue);return window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e)}}),[q]),(0,l.useEffect)((()=>{y.groups&&(b.current&&b.current.abort(),(async()=>{b.current=new AbortController;try{await L(b.current.signal)}catch(e){"AbortError"!==e.name&&console.debug("Title loading failed:",e)}})())}),[y.groups]),(0,l.useEffect)((()=>()=>{b.current&&b.current.abort()}),[]);const L=async e=>{const t={};for(let n=0;n<y.groups.length;n++){const r=y.groups[n];for(let o=0;o<r.conditions.length;o++){const a=r.conditions[o];if(e?.aborted)throw new Error("AbortError");if(!a.rule||!a.value)continue;const s=z(a.value);if(0!==s.length)if("date_time"!==a.type||"day_of_week"!==a.rule){if(a.rule.startsWith("post:")||a.rule.startsWith("taxonomy:")||a.rule.startsWith("post_terms:")||"child_of"===a.rule||"parent_of"===a.rule||"author_id"===a.rule)for(const r of s){if(!r)continue;if(e?.aborted)throw new Error("AbortError");const s=["includes_any","includes_all","excludes_any","excludes_all"].includes(a.operator)?`${n}-${o}-${r}`:`${n}-${o}`;if(t[s])continue;let i=null;if("author_id"===a.rule)i=await Q(r,e);else if("child_of"===a.rule||"parent_of"===a.rule)i=await j(r,e);else if(a.rule.startsWith("post:")){const t=a.rule.replace("post:","");i=await U(r,t,e)}else if(a.rule.startsWith("taxonomy:")||a.rule.startsWith("post_terms:")){let t;t=a.rule.startsWith("taxonomy:")?a.rule.replace("taxonomy:",""):a.rule.replace("post_terms:",""),i=await V(r,t,e)}t[s]=i||`ID: ${r}`}}else for(const e of s)t[["includes_any","includes_all","excludes_any","excludes_all"].includes(a.operator)?`${n}-${o}-${e}`:`${n}-${o}`]=H(e)}}D(t)},z=e=>{if(!e)return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t}catch(e){}return[e]},H=e=>({1:(0,i.__)("Monday","generateblocks-pro"),2:(0,i.__)("Tuesday","generateblocks-pro"),3:(0,i.__)("Wednesday","generateblocks-pro"),4:(0,i.__)("Thursday","generateblocks-pro"),5:(0,i.__)("Friday","generateblocks-pro"),6:(0,i.__)("Saturday","generateblocks-pro"),7:(0,i.__)("Sunday","generateblocks-pro")}[e]||e),U=async(e,t,n=null)=>{try{const r=await u()({path:`/generateblocks-pro/advanced-conditions/v1/search_posts?post_type=${t}`,signal:n});if(r?.success&&r.response){const t=r.response.find((t=>t.id.toString()===e.toString()));if(t)return t.title}const o=await u()({path:`/generateblocks-pro/advanced-conditions/v1/search_posts?post_type=${t}&id=${encodeURIComponent(e)}`,signal:n});if(o?.success&&o.response){const t=o.response.find((t=>t.id.toString()===e.toString()));if(t)return t.title}}catch(n){if("AbortError"===n.name)throw n;console.debug("Could not fetch post title for ID:",e,"Type:",t,n)}return null},V=async(e,t,n=null)=>{try{const r=await u()({path:`/generateblocks-pro/advanced-conditions/v1/search_terms?taxonomy=${t}`,signal:n});if(r?.success&&r.response){const t=r.response.find((t=>t.id.toString()===e.toString()));if(t)return t.name}const o=await u()({path:`/generateblocks-pro/advanced-conditions/v1/search_terms?taxonomy=${t}&id=${encodeURIComponent(e)}`,signal:n});if(o?.success&&o.response){const t=o.response.find((t=>t.id.toString()===e.toString()));if(t)return t.name}}catch(n){if("AbortError"===n.name)throw n;console.debug("Could not fetch term name for ID:",e,"Taxonomy:",t,n)}return null},j=async(e,t=null)=>{try{const n=await u()({path:"/generateblocks-pro/advanced-conditions/v1/search_hierarchical_posts",signal:t});if(n?.success&&n.response){const t=n.response.find((t=>t.id.toString()===e.toString()));if(t)return t.title.replace(/^(—\s*)+/,"")}const r=await u()({path:`/generateblocks-pro/advanced-conditions/v1/search_hierarchical_posts?id=${encodeURIComponent(e)}`,signal:t});if(r?.success&&r.response){const t=r.response.find((t=>t.id.toString()===e.toString()));if(t)return t.title.replace(/^(—\s*)+/,"")}}catch(t){if("AbortError"===t.name)throw t;console.debug("Could not fetch hierarchical post title for ID:",e,t)}return null},Q=async(e,t=null)=>{try{const n=await u()({path:"/generateblocks-pro/advanced-conditions/v1/search_users",signal:t});if(n?.success&&n.response){const t=n.response.find((t=>t.id.toString()===e.toString()));if(t)return t.name||t.title}const r=await u()({path:`/generateblocks-pro/advanced-conditions/v1/search_users?id=${encodeURIComponent(e)}`,signal:t});if(r?.success&&r.response){const t=r.response.find((t=>t.id.toString()===e.toString()));if(t)return t.name||t.title}}catch(t){if("AbortError"===t.name)throw t;console.debug("Could not fetch user name for ID:",e,t)}return null},K=(e,t,n)=>{v((r=>{const o={...r};return o.groups[e].conditions[t]=n,o}))},W=(e,t)=>{v((n=>({...n,groups:n.groups.map(((n,r)=>{if(r!==e)return n;const o=n.conditions.filter(((e,n)=>n!==t));return{...n,conditions:o}})).filter((e=>0<e.conditions.length))})))},G=async(e,t)=>{try{let r;if(r=f?await m.mutateAsync({id:a,title:e,conditions:t,category:E,status:S}):await g.mutateAsync({title:e,conditions:t,category:E,status:S}),!r)throw new Error("Failed to save condition");n&&n({id:r.id||a,title:e,conditions:t,isNew:!f})}catch(e){throw console.error("Error saving condition:",e),B((0,i.__)("Failed to save condition. Please try again.","generateblocks-pro")),e}},Y=!c||k.trim();return(0,e.createElement)("div",{className:"gb-conditions-editor"},(0,e.createElement)("div",{className:"gb-conditions-editor-header"},(0,e.createElement)("div",{className:"gb-conditions-title-section"},(0,e.createElement)(s.TextControl,{label:(0,i.__)("Condition Name","generateblocks-pro"),value:k,onChange:w,placeholder:(0,i.__)("Enter condition name…","generateblocks-pro"),className:"gb-condition-title-input",disabled:M,hideLabelFromVision:!0}),(0,e.createElement)(s.SelectControl,{label:(0,i.__)("Category","generateblocks-pro"),value:E,onChange:e=>{"new"===e?T(!0):C(e)},options:[{label:(0,i.__)("No category","generateblocks-pro"),value:""},...I.map((e=>({label:(0,pe.decodeEntities)(e.name),value:e.slug}))),{label:(0,i.__)("+ Add new category","generateblocks-pro"),value:"new"}],className:"gb-condition-category-select",disabled:M,hideLabelFromVision:!0,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})),(0,e.createElement)("div",{className:"gb-conditions-header-actions"},(0,e.createElement)(s.SelectControl,{label:(0,i.__)("Status","generateblocks-pro"),value:S,onChange:x,options:[{label:(0,i.__)("Published","generateblocks-pro"),value:"publish"},{label:(0,i.__)("Draft","generateblocks-pro"),value:"draft"}],className:"gb-condition-status-select",disabled:M,hideLabelFromVision:!0,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,e.createElement)(s.Button,{variant:"secondary",onClick:()=>{if(q){const e=(0,i.__)("You have unsaved changes. Are you sure you want to go back without saving?","generateblocks-pro");if(!window.confirm(e))return}t()},disabled:M},(0,i.__)("Cancel","generateblocks-pro")),(0,e.createElement)(s.Button,{variant:"primary",onClick:async()=>{try{if(B(null),!k.trim())return void B((0,i.__)("Please enter a condition name.","generateblocks-pro"));const e=(e=>{const t=[];return e.groups&&0!==e.groups.length?(e.groups.forEach(((e,n)=>{e.conditions&&0!==e.conditions.length?e.conditions.filter((e=>e.type)).forEach((r=>{const o=e.conditions.indexOf(r)+1,a=(0,i.sprintf)( // translators: %1$s is the condition number (1-based index), %2$s is the group number (1-based index). // translators: %1$s is the condition number (1-based index), %2$s is the group number (1-based index). (0,i.__)("Condition %1$s in Group %2$s","generateblocks-pro"),o,n+1);r.operator||t.push(`${a}: ${(0,i.__)("Please select an operator.","generateblocks-pro")}`),r.rule||t.push(`${a}: ${(0,i.__)("Please select a rule.","generateblocks-pro")}`)})):t.push((0,i.sprintf)( // translators: %d is the group number (1-based index). // translators: %d is the group number (1-based index). (0,i.__)("Group %d has no conditions.","generateblocks-pro"),n+1))})),{isValid:0===t.length,errors:t}):{isValid:!0,errors:[]}})(y);if(!e.isValid){const t=(0,i.__)("Please complete the following:","generateblocks-pro")+"\n\n"+e.errors.join("\n");return void B(t)}if(!y.groups||0===y.groups.length)return void await G(k,{logic:"OR",groups:[]});P(!0);const t=(e=>{if(!e.groups)return e;const t=e.groups.map((e=>({...e,conditions:e.conditions.filter((e=>!!(e.type&&e.operator&&e.rule)||(e.type||e.operator||e.rule||e.value,!1)))}))).filter((e=>e.conditions.length>0));return{...e,groups:t}})(y);if(!(await u()({path:"/generateblocks-pro/advanced-conditions/v1/validate_conditions",method:"POST",data:{conditions:t}})).success)return void B((0,i.__)("Condition validation failed. Please check your configuration and try again.","generateblocks-pro"));await G(k,t)}catch(e){console.error("Error saving condition:",e);let t=(0,i.__)("Failed to save condition. Please try again.","generateblocks-pro");e.message&&e.message.includes("validation")&&(t=(0,i.__)("Condition validation failed. Please check that all fields are properly filled out.","generateblocks-pro")),B(t)}finally{P(!1)}},disabled:!k.trim()||M,isBusy:M},M?(0,i.__)("Saving…","generateblocks-pro"):(0,i.__)("Save Conditions","generateblocks-pro")))),(0,e.createElement)("div",{className:"gb-conditions-content"},q&&(0,e.createElement)(s.Notice,{status:"info",isDismissible:!1,className:"gb-conditions-unsaved-notice"},(0,i.__)("You have unsaved changes.","generateblocks-pro")),!!A&&(0,e.createElement)(s.Notice,{status:"error",isDismissible:!1,className:"gb-conditions-error-notice"},(0,e.createElement)("div",{style:{whiteSpace:"pre-line"}},A)),h?(0,e.createElement)("div",{className:"gb-loading"},(0,e.createElement)(s.Spinner,null),(0,e.createElement)("p",null,(0,i.__)("Loading condition types…","generateblocks-pro"))):(0,e.createElement)(e.Fragment,null,Y&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"gb-conditions-groups"},y.groups&&0<y.groups.length?y.groups.map(((t,n)=>(0,e.createElement)("div",{key:n,className:"gb-condition-group"},(0,e.createElement)("div",{className:"gb-group-header"},(0,e.createElement)("div",{className:"gb-group-logic"},(0,e.createElement)("span",{className:"gb-group-label"},(0,i.__)("Group Logic","generateblocks-pro")),(0,e.createElement)(s.SelectControl,{value:t.logic,onChange:e=>((e,t)=>{v((n=>{const r={...n};return r.groups[e].logic=t,r}))})(n,e),options:[{label:(0,i.__)("AND","generateblocks-pro"),value:"AND"},{label:(0,i.__)("OR","generateblocks-pro"),value:"OR"}],className:"gb-group-logic-select",disabled:M,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})),1<y.groups.length&&(0,e.createElement)(s.Button,{isDestructive:!0,variant:"tertiary",icon:Re,onClick:()=>(e=>{v((t=>({...t,groups:t.groups.filter(((t,n)=>n!==e))})))})(n),className:"gb-remove-group",label:(0,i.__)("Remove group","generateblocks-pro"),size:"compact",iconSize:"16",disabled:M})),(0,e.createElement)("div",{className:"gb-group-conditions"},t.conditions.map(((r,o)=>(0,e.createElement)(Lt,{key:o,condition:r,groupIndex:n,conditionIndex:o,onUpdate:K,onRemove:W,conditionTypes:p,logicOperator:t.logic,selectedObjectTitles:R,setSelectedObjectTitles:D})))),(0,e.createElement)(s.Button,{variant:"secondary",icon:de,onClick:()=>(e=>{v((t=>({...t,groups:t.groups.map(((t,n)=>n===e?{...t,conditions:[...t.conditions,{type:"",rule:"",operator:"",value:""}]}:t))})))})(n),className:"gb-add-condition",disabled:M},(0,i.__)("Add","generateblocks-pro")," ",t.logic.toUpperCase()," ",(0,i.__)("condition","generateblocks-pro"))))):(0,e.createElement)("div",{className:"gb-no-conditions"},(0,e.createElement)("p",null,(0,i.__)("No conditions set","generateblocks-pro")),(0,e.createElement)(s.Button,{variant:"primary",icon:de,onClick:()=>{v({logic:"OR",groups:[{logic:"AND",conditions:[{type:"",rule:"",operator:"",value:""}]}]})},disabled:M},(0,i.__)("Add first condition","generateblocks-pro")))),y.groups&&0===y.groups.length&&Y&&(0,e.createElement)("div",{className:"gb-conditions-help-text"},(0,e.createElement)("p",null,(0,i.__)("Create your first condition to control when this content should appear.","generateblocks-pro"))),y.groups&&0<y.groups.length&&(0,e.createElement)(s.Button,{variant:"tertiary",icon:de,onClick:()=>{v((e=>({...e,logic:e.logic||"OR",groups:[...e.groups,{logic:"AND",conditions:[{type:"",rule:"",operator:"",value:""}]}]})))},className:"gb-add-group",disabled:M},"AND"===(y.logic||"OR")?(0,i.__)("Add AND condition group","generateblocks-pro"):(0,i.__)("Add OR condition group","generateblocks-pro")),y.groups&&1<y.groups.length&&(0,e.createElement)("div",{className:"gb-top-level-logic"},(0,e.createElement)(s.SelectControl,{label:(0,i.__)("How should these condition groups be combined?","generateblocks-pro"),value:y.logic||"OR",onChange:e=>{v((t=>({...t,logic:e})))},options:[{label:(0,i.__)("OR - Show if ANY group matches","generateblocks-pro"),value:"OR"},{label:(0,i.__)("AND - Show only if ALL groups match","generateblocks-pro"),value:"AND"}],help:"OR"===(y.logic||"OR")?(0,i.__)("Content will show if any condition group is satisfied.","generateblocks-pro"):(0,i.__)("Content will show only if all condition groups are satisfied.","generateblocks-pro"),disabled:M,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})),(0,e.createElement)(Ae,{conditions:y,onConditionsImport:e=>{v(e)}})),c&&!k.trim()&&(0,e.createElement)("div",{className:"gb-conditions-help-text"},(0,e.createElement)("p",null,(0,i.__)("Enter a condition name above to start building your conditions.","generateblocks-pro"))))),(0,e.createElement)(Be,{isOpen:N,onClose:()=>T(!1),onCreateCategory:async({name:e,slug:t})=>{try{await u()({path:"/wp/v2/condition-categories",method:"POST",data:{name:e,slug:t}})&&(O([...I,{name:e,slug:t}]),C(t))}catch(e){throw e}}}))}function Vt(t){return(0,e.createElement)(m,{client:ie()},(0,e.createElement)(Ut,{...t}))}const jt=(0,l.createElement)(ce.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,l.createElement)(ce.Path,{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})),Qt=window.gbp.components;function Kt({condition:t,onClose:n}){const{conditionTypes:r,getRulesForType:o,getOperatorsForType:a}=xe(),{loadObjectTitles:c}=function(){const e=ie();return{loadObjectTitles:(0,l.useCallback)((async t=>{if(!t||0===t.length)return{};const n=[],r={};if(t.forEach((t=>{const o=["object-title",t.type,t.id],a=e.getQueryData(o);a?r[`${t.type}-${t.id}`]=a:n.push(t)})),0===n.length)return r;const o=await u()({path:"/generateblocks-pro/advanced-conditions/v1/batch_object_titles",method:"POST",data:{requests:n}});return o.success&&o.response?(Object.entries(o.response).forEach((([t,n])=>{const[r,o]=t.split("-");e.setQueryData(["object-title",r,o],n)})),{...r,...o.response}):r}),[e])}}(),[d,p]=(0,l.useState)({}),[h,g]=(0,l.useState)({}),[m,b]=(0,l.useState)({}),[f,_]=(0,l.useState)(!0);(0,l.useEffect)((()=>{(async()=>{try{_(!0);const e=t.gbConditions||{groups:[]},n=new Set,r={},s={};e.groups?.forEach((e=>{e.conditions?.forEach((e=>{e.type&&n.add(e.type)}))}));for(const e of n)try{const t=await o(e);r[e]=t;const n=await a(e);s[e]=n}catch(t){console.error(`Error loading data for type ${e}:`,t)}g(r),b(s),await y(e)}catch(e){console.error("Error loading condition data:",e)}finally{_(!1)}})()}),[t,o,a,c]);const y=async e=>{const t=[];if(e.groups?.forEach((e=>{e.conditions?.forEach((e=>{if(!e.rule||!e.value)return;const n=v(e.value);0!==n.length&&(e.rule.startsWith("post:")||e.rule.startsWith("taxonomy:")||e.rule.startsWith("post_terms:")||"child_of"===e.rule||"parent_of"===e.rule||"date_time"===e.type&&"day_of_week"===e.rule)&&n.forEach((n=>{n&&t.push({type:e.type,rule:e.rule,value:n})}))}))})),t.length>0){const e=t.map((e=>{let t;return t=e.rule.startsWith("post:")?"post":e.rule.startsWith("taxonomy:")||e.rule.startsWith("post_terms:")?"term":"author_id"===e.rule?"user":e.type,{type:t,id:e.value}})),n=await c(e);p(n)}},v=e=>{if(!e)return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t}catch(e){}return[e]},k=t.gbConditions||{groups:[]},w=k.groups&&0<k.groups.length;return(0,e.createElement)(s.Modal,{title:t.title?.rendered||t.title||(0,i.__)("Untitled Condition","generateblocks-pro"),onRequestClose:n,className:"gb-modal-condition-details",size:"medium"},(0,e.createElement)("div",{className:"gb-modal-details-content"},f?(0,e.createElement)("div",{className:"gb-modal-loading"},(0,e.createElement)(s.Spinner,null),(0,e.createElement)("p",null,(0,i.__)("Loading condition details…","generateblocks-pro"))):(0,e.createElement)("div",{className:"gb-modal-details-body"},w?(0,e.createElement)(e.Fragment,null,1<k.groups.length&&(0,e.createElement)("div",{className:"gb-modal-main-logic"},(0,e.createElement)("strong",null,(0,i.__)("Overall Logic:","generateblocks-pro"))," ","AND"===k.logic?(0,i.__)("ALL condition groups must match","generateblocks-pro"):(0,i.__)("ANY condition group can match","generateblocks-pro")),(0,e.createElement)("div",{className:"gb-modal-condition-groups"},k.groups.map(((t,n)=>(0,e.createElement)("div",{key:n,className:"gb-modal-condition-group"},(0,e.createElement)("div",{className:"gb-modal-group-header"},(0,e.createElement)("h4",null,1<k.groups.length?`${(0,i.__)("Group","generateblocks-pro")} ${n+1}`:(0,i.__)("Conditions","generateblocks-pro")),1<t.conditions.length&&(0,e.createElement)("span",{className:"gb-modal-group-logic-badge"},"AND"===t.logic?(0,i.__)("ALL must match","generateblocks-pro"):(0,i.__)("ANY can match","generateblocks-pro"))),(0,e.createElement)("div",{className:"gb-modal-condition-list"},t.conditions.filter((e=>e.type&&e.rule&&e.operator)).map(((t,n)=>{return(0,e.createElement)("div",{key:n,className:"gb-modal-condition-item"},(0,e.createElement)("div",{className:"gb-modal-condition-summary"},(0,e.createElement)("span",{className:"gb-modal-condition-type-badge"},(s=t.type,r[s]?.label||s)),(0,e.createElement)("span",{className:"gb-modal-condition-rule-badge"},((e,t)=>h[e]?.[t]||t)(t.type,t.rule)),(0,e.createElement)("span",{className:"gb-modal-condition-operator-badge"},((e,t)=>m[e]?.[t]||t)(t.type,t.operator))),(!(!(o=t).value||!o.value.trim())||(a=o.operator,!["exists","not_exists"].includes(a)))&&(0,e.createElement)("div",{className:"gb-modal-condition-value"},(0,e.createElement)("strong",null,(0,i.__)("Value:","generateblocks-pro"))," ",(t=>{if(!t.value)return(0,i.__)("(no value)","generateblocks-pro");if("date_time"===t.type&&"day_of_week"===t.rule){const e=v(t.value);return 0===e.length?(0,i.__)("(no days selected)","generateblocks-pro"):e.map((e=>e)).join(", ")}if(t.value.includes("|")){const n=t.value.split("|",2);return(0,e.createElement)("div",{className:"gb-modal-custom-field-value"},(0,e.createElement)("div",null,(0,e.createElement)("strong",null,(0,i.__)("Field:","generateblocks-pro"))," ",n[0]),n[1]&&(0,e.createElement)("div",null,(0,e.createElement)("strong",null,(0,i.__)("Value:","generateblocks-pro"))," ",n[1]))}if(t.value.includes(",")&&"between"===t.operator){const n=t.value.split(",").map((e=>e.trim()));return(0,e.createElement)("div",{className:"gb-modal-date-range-value"},(0,e.createElement)("div",null,(0,e.createElement)("strong",null,(0,i.__)("From:","generateblocks-pro"))," ",n[0]),(0,e.createElement)("div",null,(0,e.createElement)("strong",null,(0,i.__)("To:","generateblocks-pro"))," ",n[1]||(0,i.__)("(not set)","generateblocks-pro")))}const n=v(t.value);if(0===n.length)return t.value;const r=n.map((e=>{let n;return n=t.rule.startsWith("post:")?"post":t.rule.startsWith("taxonomy:")||t.rule.startsWith("post_terms:")?"term":"author_id"===t.rule?"user":t.type,d[`${n}-${e}`]||e}));return 1===r.length?r[0]:r.join(", ")})(t)));var o,a,s})))))))):(0,e.createElement)("div",{className:"gb-modal-no-conditions"},(0,e.createElement)("p",null,(0,i.__)("This condition has no rules configured.","generateblocks-pro"))))))}const Wt=(0,l.createElement)(ce.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,l.createElement)(ce.Path,{d:"m11.3 17.2-5-5c-.1-.1-.1-.3 0-.4l2.3-2.3-1.1-1-2.3 2.3c-.7.7-.7 1.8 0 2.5l5 5H7.5v1.5h5.3v-5.2h-1.5v2.6zm7.5-6.4-5-5h2.7V4.2h-5.2v5.2h1.5V6.8l5 5c.1.1.1.3 0 .4l-2.3 2.3 1.1 1.1 2.3-2.3c.6-.7.6-1.9-.1-2.5z"}));function Gt({usageData:t,loading:n,error:r,emptyMessage:o,onRetry:a,formatUsageType:l}){const c=l||(e=>({global_style_usage:(0,i.__)("Global Style Usage","generateblocks-pro"),manual_class_usage:(0,i.__)("Manual Class Usage","generateblocks-pro"),overlay_display_condition:(0,i.__)("Overlay Display Condition","generateblocks-pro"),block_conditions:(0,i.__)("Block Conditions","generateblocks-pro"),menu_item_conditions:(0,i.__)("Menu Item Conditions","generateblocks-pro")}[e]||e)),u=t&&t.usage&&0<Object.keys(t.usage).length,d=t?.limitations?.recent_post_scan,p=!!d,h=t?.has_more&&!p;return(0,e.createElement)("div",{className:"gb-modal-usage-content"},n&&(0,e.createElement)("div",{className:"gb-modal-loading"},(0,e.createElement)(s.Spinner,null),(0,e.createElement)("p",null,(0,i.__)("Searching for usage…","generateblocks-pro"))),!n&&r&&(0,e.createElement)("div",{className:"gb-modal-error"},(0,e.createElement)("p",{style:{color:"#d63638"}},r),(0,e.createElement)(s.Button,{variant:"secondary",onClick:a},(0,i.__)("Try Again","generateblocks-pro"))),t&&!r&&(0,e.createElement)("div",{className:"gb-modal-usage-body"},!u&&(0,e.createElement)("div",{className:"gb-modal-no-usage"},(0,e.createElement)("p",{style:{fontSize:"16px",textAlign:"center",color:"#666"}},o),(0,e.createElement)("p",{style:{fontSize:"14px",textAlign:"center",color:"#999"}},(0,i.__)("You can safely delete it, or keep it for future use.","generateblocks-pro"))),u&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"gb-modal-usage-summary"},(0,e.createElement)("p",{style:{fontSize:"14px",color:"#666",margin:"0"}},(0,i.__)("Found usage in","generateblocks-pro")," ",(0,e.createElement)("strong",null,t.total),t.has_more&&"+"," ",1===t.total?(0,i.__)("location","generateblocks-pro"):(0,i.__)("locations","generateblocks-pro"))),t.cached&&t.cached_at&&(0,e.createElement)("div",{style:{background:"#f0f6fc",border:"1px solid #0969da",padding:"12px 16px",borderRadius:"4px",marginBottom:"16px",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"5px"}},(0,e.createElement)("span",{style:{fontSize:"13px",color:"#0969da"}},(0,i.sprintf)(/* translators: %s: time ago (e.g., "5 minutes") */ /* translators: %s: time ago (e.g., "5 minutes") */ (0,i.__)("Showing cached results from %s ago.","generateblocks-pro"),(e=>{const t=Math.floor(Date.now()/1e3)-e;if(t<60)return(0,i.__)("less than a minute","generateblocks-pro");if(t<3600){const e=Math.max(1,Math.floor(t/60));return(0,i.sprintf)(/* translators: %d: number of minutes */ /* translators: %d: number of minutes */ (0,i._n)("%d minute","%d minutes",e,"generateblocks-pro"),e)}const n=Math.max(1,Math.floor(t/3600));return(0,i.sprintf)(/* translators: %d: number of hours */ /* translators: %d: number of hours */ (0,i._n)("%d hour","%d hours",n,"generateblocks-pro"),n)})(t.cached_at))),(0,e.createElement)(s.Button,{variant:"secondary",size:"compact",onClick:a,icon:Wt},(0,i.__)("Refresh","generateblocks-pro"))),p&&(0,e.createElement)("div",{style:{background:"#f0f6fc",border:"1px solid #0969da",padding:"12px",borderRadius:"4px",marginBottom:"16px"}},(0,e.createElement)("p",{style:{margin:"0",fontSize:"13px",color:"#0969da"}},(0,e.createElement)("strong",null,(0,i.__)("Heads up:","generateblocks-pro"))," ",d.total_posts&&d.total_posts>d.scanned_posts?(0,i.sprintf)(/* translators: 1: number of posts scanned, 2: total eligible posts */ /* translators: 1: number of posts scanned, 2: total eligible posts */ (0,i.__)("For performance, only the most recent %1$d of %2$d eligible posts were scanned. Older content may still reference this item.","generateblocks-pro"),d.scanned_posts,d.total_posts):(0,i.sprintf)(/* translators: %d: number of posts scanned */ /* translators: %d: number of posts scanned */ (0,i.__)("For performance, the search was limited to the most recent %d posts. Older content may still reference this item.","generateblocks-pro"),d.scanned_posts||d.max_posts))),h&&(0,e.createElement)("div",{style:{background:"#f0f6fc",border:"1px solid #0969da",padding:"12px",borderRadius:"4px",marginBottom:"16px"}},(0,e.createElement)("p",{style:{margin:"0",fontSize:"13px",color:"#0969da"}},(0,e.createElement)("strong",null,(0,i.__)("Note:","generateblocks-pro"))," ",(0,i.__)("Results limited to most recent posts for performance. There may be additional usage in older content.","generateblocks-pro"))),(0,e.createElement)("div",{className:"gb-modal-usage-sections"},Object.entries(t.usage).map((([t,n])=>(0,e.createElement)("div",{key:t,className:"gb-modal-usage-section"},(0,e.createElement)("h4",{className:"gb-modal-usage-section-title"},n.label,(0,e.createElement)("span",{className:"gb-modal-usage-count"},"(",n.items.length,n.has_more&&"+",")")),(0,e.createElement)("div",{className:"gb-modal-usage-items"},n.items.map((t=>(0,e.createElement)("div",{key:`${t.type}-${t.id}`,className:"gb-modal-usage-item"},(0,e.createElement)("div",{className:"gb-modal-usage-item-main"},(0,e.createElement)("div",{className:"gb-modal-usage-item-title"},(0,e.createElement)("strong",null,t.title),t.status&&(t=>{const n={publish:(0,i.__)("Published","generateblocks-pro"),draft:(0,i.__)("Draft","generateblocks-pro"),private:(0,i.__)("Private","generateblocks-pro")},r={publish:{bg:"#d1fae5",color:"#065f46",border:"#a7f3d0"},draft:{bg:"#fef3c7",color:"#92400e",border:"#fcd34d"},private:{bg:"#e0e7ff",color:"#3730a3",border:"#c7d2fe"}},o=r[t]||r.draft;return(0,e.createElement)("span",{style:{background:o.bg,color:o.color,border:`1px solid ${o.border}`,padding:"2px 6px",borderRadius:"4px",fontSize:"11px",fontWeight:"500",textTransform:"uppercase"}},n[t]||t)})(t.status)),(0,e.createElement)("div",{className:"gb-modal-usage-item-meta"},(0,e.createElement)("span",{className:"gb-modal-usage-item-type"},t.type_label),(0,e.createElement)("span",{className:"gb-modal-usage-item-usage-type"},c(t.usage_type),t.block_count>1&&(0,e.createElement)("span",{style:{marginLeft:"5px",opacity:.7}},"(",t.block_count," ",(0,i.__)("blocks","generateblocks-pro"),")")))),(0,e.createElement)("div",{className:"gb-modal-usage-item-actions"},t.edit_url&&(0,e.createElement)(s.Button,{variant:"secondary",size:"compact",icon:ue,href:t.edit_url,target:"_blank",iconSize:"14"},(0,i.__)("Edit","generateblocks-pro")),t.view_url&&(0,e.createElement)(s.Button,{variant:"tertiary",size:"compact",icon:Ie,href:t.view_url,target:"_blank",iconSize:"14"},(0,i.__)("View","generateblocks-pro"))))))))))))))}function Yt({condition:t,onClose:n}){const{usageData:r,loading:o,error:a,reload:c}=function(e,t=50){const[n,r]=(0,l.useState)(null),[o,a]=(0,l.useState)(!0),[s,c]=(0,l.useState)(null),d=(0,l.useRef)(null),p=(0,l.useCallback)((async(n=!1)=>{d.current&&d.current.abort(),d.current=new AbortController;const o=d.current;try{a(!0),c(null);const s=e.includes("?")?"&":"?",l=n?"&refresh=true":"",d=await u()({path:`${e}${s}limit=${t}${l}`,signal:o.signal});if(!d.success)return void c(d.response||(0,i.__)("Failed to load usage data","generateblocks-pro"));const p=d.response.data||d.response;r(p)}catch(e){if("AbortError"===e.name)return;console.error("Error loading usage data:",e);const t=e?.message||(0,i.__)("Error loading usage data. Please try again.","generateblocks-pro");c(t)}finally{a(!1)}}),[e,t]);return(0,l.useEffect)((()=>(p(!1),()=>{d.current&&d.current.abort()})),[p]),{usageData:n,loading:o,error:s,reload:(0,l.useCallback)((()=>{p(!0)}),[p])}}(`/generateblocks-pro/advanced-conditions/v1/conditions/${t.id}/usage`);return(0,e.createElement)(s.Modal,{title:t.title?.rendered||t.title||(0,i.__)("Untitled Condition","generateblocks-pro"),onRequestClose:n,className:"gb-modal-condition-usage",size:"medium"},(0,e.createElement)(Gt,{usageData:r,loading:o,error:a,emptyMessage:(0,i.__)("This condition is not currently being used anywhere on your site.","generateblocks-pro"),onRetry:c}))}function Jt({conditions:t,onEditCondition:n,refreshKey:r}){const o=Ee({mutationFn:async e=>{const t=await u()({path:`/generateblocks-pro/advanced-conditions/v1/conditions/${e}`,method:"DELETE"});if(t.success)return t.response;throw new Error("Failed to delete condition")},onSuccess:()=>{le()}}),a=Ee({mutationFn:async({id:e,status:t})=>{const n=await u()({path:`/generateblocks-pro/advanced-conditions/v1/conditions/${e}`,method:"PUT",data:{status:t}});if(n.success)return n.response;throw new Error("Failed to update condition status")},onSuccess:()=>{le()}}),c=Ee({mutationFn:async e=>{const t=await u()({path:`/generateblocks-pro/advanced-conditions/v1/conditions/${e}`});if(!t?.success)throw new Error("Failed to fetch condition for duplication");const n=t.response;let r=n.title;"object"==typeof r&&r?.rendered&&(r=r.rendered);let o=n.gblocks_condition_cat||n.category||[];Array.isArray(o)||(o=o?[o]:[]);let a=[];if(o.length>0){const e=await u()({path:"/wp/v2/condition-categories?include="+o.join(",")});e&&Array.isArray(e)&&(a=e.map((e=>e.slug)))}const s=n.gbConditions||n.conditions||{logic:"OR",groups:[]},i=await u()({path:"/generateblocks-pro/advanced-conditions/v1/conditions/",method:"POST",data:{title:r+" (Copy)",conditions:s,category:a,status:n.status||"publish"}});if(i.success)return i.response;throw new Error("Failed to duplicate condition")},onSuccess:()=>{le(),ie().invalidateQueries({queryKey:["condition-categories"]})}}),[d,p]=(0,l.useState)(null),[h,g]=(0,l.useState)(null),[m,b]=(0,l.useState)(null),[f,_]=(0,l.useState)([]),y=ie();(0,l.useEffect)((()=>{(async()=>{try{const e=await u()({path:"/wp/v2/condition-categories"});e&&_(e)}catch(e){}})()}),[r]);const v=(0,l.useMemo)((()=>[{id:"name",header:(0,i.__)("Name","generateblocks-pro"),accessorKey:"title.rendered",cell:t=>{const r=t.row.original,o="draft"===r.status;return(0,e.createElement)("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},(0,e.createElement)(s.Button,{variant:"link",onClick:()=>n(r)},t.getValue()),o&&(0,e.createElement)("span",{style:{color:"#999",fontSize:"0.9em"}},"(",(0,i.__)("draft","generateblocks-pro"),")"))}},{id:"category",header:(0,i.__)("Category","generateblocks-pro"),cell:t=>{const n=t.row.original,r=n.gblocks_condition_cat?.[0];if(!r)return(0,e.createElement)("span",{className:"gb-condition-category gb-condition-category--uncategorized"},(0,i.__)("Uncategorized","generateblocks-pro"));const o=f.find((e=>e.id===r)),a=o?(0,pe.decodeEntities)(o.name):`ID: ${r}`;return(0,e.createElement)("span",{className:"gb-condition-category"},a)}},{id:"conditions_count",header:(0,i.__)("Conditions","generateblocks-pro"),cell:t=>{const n=t.row.original,r=n.gbConditions||{groups:[]},o=r.groups?.reduce(((e,t)=>e+(t.conditions?.filter((e=>e.type&&e.rule&&e.operator)).length||0)),0)||0;return 0===o?(0,e.createElement)(e.Fragment,null,(0,i.__)("No conditions","generateblocks-pro")):(0,e.createElement)(s.Button,{variant:"link",iconSize:"14",onClick:()=>g(n),className:"gb-conditions-details-button"},o," ",1===o?(0,i.__)("condition","generateblocks-pro"):(0,i.__)("conditions","generateblocks-pro"))}},{id:"actions",header:null,cell:t=>{const{status:r,id:o}=t.row.original;return(0,e.createElement)(s.DropdownMenu,{icon:jt,label:(0,i.__)("More options","generateblocks-pro"),className:"gb-cloud-public-keys__dropdown",popoverProps:{placement:"left"}},(({onClose:l})=>(0,e.createElement)(e.Fragment,null,(0,e.createElement)(s.MenuGroup,null,(0,e.createElement)(s.MenuItem,{onClick:()=>{n(t.row.original),l()}},(0,i.__)("Edit Condition","generateblocks-pro")),(0,e.createElement)(s.MenuItem,{onClick:()=>{c.mutateAsync(o).then((e=>{y.invalidateQueries({queryKey:["conditions"]}),e&&n(e)})),l()}},(0,i.__)("Duplicate","generateblocks-pro"))),(0,e.createElement)(s.MenuGroup,null,(0,e.createElement)(s.MenuItem,{onClick:()=>{b(t.row.original),l()}},(0,i.__)("Check Usage","generateblocks-pro"))),(0,e.createElement)(s.MenuGroup,null,(0,e.createElement)(s.MenuItem,{onClick:()=>{const e="publish"===r?"draft":"publish";a.mutateAsync({id:o,status:e}).then((()=>{y.invalidateQueries({queryKey:["conditions"]})})),l()}},"publish"===r?(0,i.__)("Set as Draft","generateblocks-pro"):(0,i.__)("Publish","generateblocks-pro")),(0,e.createElement)(s.MenuItem,{isDestructive:!0,onClick:()=>{p(o),l()}},(0,i.__)("Delete Condition","generateblocks-pro"))))))}}]),[n,f]);return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"gb-dashboard-table-wrapper"},t.length?(0,e.createElement)(Qt.Table,{className:"gb-dashboard-table table-view-list",columns:v,data:t,"aria-labelledby":"conditions-table-header"}):(0,e.createElement)("p",{style:{marginTop:"0"}},(0,i.__)("No conditions found.","generateblocks-pro"))),!!d&&(0,e.createElement)(s.Modal,{title:(0,i.__)("Confirm","generateblocks-pro"),isDismissible:!1,onRequestClose:()=>null,style:{maxWidth:"300px"}},(0,e.createElement)("div",{style:{marginBottom:"1em"}},(0,i.__)("This will permanently delete this condition. You cannot undo this action.","generateblocks-pro")),(0,e.createElement)(s.Button,{variant:"primary",onClick:async()=>{await o.mutateAsync(d),y.invalidateQueries({queryKey:["conditions"]}),p(null)}},(0,i.__)("OK","generateblocks-pro")),(0,e.createElement)(s.Button,{variant:"tertiary",onClick:()=>p(null)},(0,i.__)("Cancel","generateblocks-pro"))),h&&(0,e.createElement)(Kt,{condition:h,onClose:()=>g(null)}),m&&(0,e.createElement)(Yt,{condition:m,onClose:()=>b(null)}))}function Zt({category:t,updateCategory:n,saving:r}){const[o,a]=(0,l.useState)(!1),[c,u]=(0,l.useState)((0,pe.decodeEntities)(t.name)),[d,p]=(0,l.useState)(!1),h=async()=>{p(!0),await n(t.id,c),p(!1),a(!1)},g=()=>{a(!1),u((0,pe.decodeEntities)(t.name))};return o&&!t.isUncategorized?(0,e.createElement)("div",{className:"gb-edit-taxonomy-form"},(0,e.createElement)(s.TextControl,{value:c,onChange:u,disabled:d||r,onKeyDown:e=>{"Enter"===e.key?h():"Escape"===e.key&&g()},__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,e.createElement)("div",{className:"gb-edit-actions"},(0,e.createElement)(s.Button,{variant:"primary",size:"small",onClick:h,disabled:!c.trim()||d||r,isBusy:d||r,__next40pxDefaultSize:!0},(0,i.__)("Save","generateblocks-pro")),(0,e.createElement)(s.Button,{variant:"secondary",size:"small",onClick:g,disabled:d||r,__next40pxDefaultSize:!0},(0,i.__)("Cancel","generateblocks-pro")))):(0,e.createElement)("div",{style:{display:"flex",alignItems:"center",gap:"10px"}},(0,e.createElement)("strong",{className:t.isUncategorized?"gb-uncategorized-label":""},(0,pe.decodeEntities)(t.name)),!t.isUncategorized&&(0,e.createElement)(s.Button,{icon:ue,size:"small",onClick:()=>{a(!0),u((0,pe.decodeEntities)(t.name))},label:(0,i.__)("Edit category name","generateblocks-pro"),style:{visibility:"hidden"},className:"gb-taxonomy-edit-button"}))}function Xt({taxonomyConfig:t={slug:"",restBase:"",labels:{singular:"Category",plural:"Categories",uncategorized:"Uncategorized",itemsCount:"items"}},itemsEndpoint:n,itemsTaxonomyField:r,manageEndpoint:o,onNavigateBack:a,onTaxonomyChange:c}){const[d,p]=(0,l.useState)([]),[h,g]=(0,l.useState)(!1),[m,b]=(0,l.useState)(!1),[f,_]=(0,l.useState)(null),[y,v]=(0,l.useState)(""),{labels:k={},restBase:w}=t;(0,l.useEffect)((()=>{E()}),[]);const E=async()=>{g(!0),_(null);try{const e=[u()({path:`/wp/v2/${w}`})];n&&e.push(u()({path:`${n}?per_page=100`}));const t=await Promise.all(e),o=t[0],a=t[1];if(o){let e=[...o];if(a?.success&&r){const t=(a.response?.[Object.keys(a.response)[0]]||[]).filter((e=>!e[r]||0===e[r].length)).length;e=[{id:"uncategorized",name:k.uncategorized||(0,i.__)("Uncategorized","generateblocks-pro"),slug:"",count:t,isUncategorized:!0},...o]}p(e)}}catch(e){_((0,i.__)("Failed to load categories.","generateblocks-pro"))}finally{g(!1)}},C=async()=>{if(y.trim()){b(!0),_(null);try{const e=y.toLowerCase().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-");(await u()({path:o,method:"POST",data:{name:y.trim(),slug:e}})).success&&(await E(),v(""),c&&c())}catch(e){_((0,i.__)("Failed to create category.","generateblocks-pro"))}finally{b(!1)}}},S=async(e,t)=>{if(t.trim()){b(!0),_(null);try{(await u()({path:`${o}/${e}`,method:"POST",data:{name:t.trim()}})).success&&(await E(),c&&c())}catch(e){_((0,i.__)("Failed to update category.","generateblocks-pro"))}finally{b(!1)}}},x=async e=>{const t=k.singular?.toLowerCase()||"category",n=(0,i.sprintf)(/* translators: %1$s: singular taxonomy label, %2$s: singular taxonomy label */ /* translators: %1$s: singular taxonomy label, %2$s: singular taxonomy label */ (0,i.__)("Are you sure you want to delete this %1$s? Items using this %2$s will become uncategorized.","generateblocks-pro"),t,t);if(confirm(n)){b(!0),_(null);try{(await u()({path:`${o}/${e}`,method:"DELETE"})).success&&(await E(),c&&c())}catch(e){_((0,i.__)("Failed to delete category.","generateblocks-pro"))}finally{b(!1)}}},I=(0,l.useMemo)((()=>[{id:"name",header:(0,i.sprintf)(/* translators: %s: singular taxonomy label */ /* translators: %s: singular taxonomy label */ (0,i.__)("%s Name","generateblocks-pro"),k.singular||"Category"),accessorKey:"name",cell:t=>{const n=t.row.original;return(0,e.createElement)(Zt,{category:n,updateCategory:S,saving:m})}},{id:"items",header:k.itemsCount?k.itemsCount.charAt(0).toUpperCase()+k.itemsCount.slice(1):(0,i.__)("Items","generateblocks-pro"),cell:e=>`${e.row.original.count||0} ${k.itemsCount||"items"}`},{id:"actions",header:(0,i.__)("Actions","generateblocks-pro"),cell:t=>{const n=t.row.original;return n.isUncategorized?(0,e.createElement)("span",{className:"gb-uncategorized-actions"},(0,i.__)("Built-in","generateblocks-pro")):(0,e.createElement)(s.DropdownMenu,{icon:jt,label:(0,i.sprintf)(/* translators: %s: singular taxonomy label */ /* translators: %s: singular taxonomy label */ (0,i.__)("%s actions","generateblocks-pro"),k.singular||"Category"),className:"gb-taxonomy-actions",popoverProps:{placement:"left"}},(({onClose:t})=>(0,e.createElement)(s.MenuGroup,null,(0,e.createElement)(s.MenuItem,{icon:Re,onClick:()=>{x(n.id),t()},isDestructive:!0},(0,i.sprintf)(/* translators: %s: singular taxonomy label */ /* translators: %s: singular taxonomy label */ (0,i.__)("Delete %s","generateblocks-pro"),k.singular||"Category")))))}}]),[k,S,x,m]);return(0,e.createElement)("div",{className:"gb-taxonomy-manager"},(0,e.createElement)("div",{className:"gb-taxonomy-manager-header"},(0,e.createElement)("div",{className:"gb-taxonomy-title-section"},(0,e.createElement)("h2",null,(0,i.sprintf)(/* translators: %s: plural taxonomy label */ /* translators: %s: plural taxonomy label */ (0,i.__)("Manage %s","generateblocks-pro"),k.plural||"Categories"))),(0,e.createElement)("div",{className:"gb-taxonomy-header-actions"},(0,e.createElement)(s.Button,{variant:"secondary",onClick:()=>{a()},disabled:m},(0,i.__)("Back","generateblocks-pro")))),(0,e.createElement)("div",{className:"gb-taxonomy-content"},!!f&&(0,e.createElement)(s.Notice,{status:"error",isDismissible:!1,className:"gb-taxonomy-error-notice"},f),(0,e.createElement)("div",{className:"gb-create-taxonomy-section"},(0,e.createElement)("h3",null,(0,i.sprintf)(/* translators: %s: singular taxonomy label */ /* translators: %s: singular taxonomy label */ (0,i.__)("Create New %s","generateblocks-pro"),k.singular||"Category")),(0,e.createElement)("div",{className:"gb-create-taxonomy-form"},(0,e.createElement)(s.TextControl,{label:(0,i.sprintf)(/* translators: %s: singular taxonomy label */ /* translators: %s: singular taxonomy label */ (0,i.__)("%s Name","generateblocks-pro"),k.singular||"Category"),value:y,onChange:v,placeholder:(0,i.sprintf)(/* translators: %s: singular taxonomy label */ /* translators: %s: singular taxonomy label */ (0,i.__)("Enter %s name…","generateblocks-pro"),k.singular?.toLowerCase()||"category"),disabled:m,onKeyDown:e=>{"Enter"===e.key&&C()},__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,e.createElement)(s.Button,{variant:"primary",icon:de,onClick:C,disabled:!y.trim()||m,isBusy:m,__next40pxDefaultSize:!0},(0,i.sprintf)(/* translators: %s: singular taxonomy label */ /* translators: %s: singular taxonomy label */ (0,i.__)("Create %s","generateblocks-pro"),k.singular||"Category")))),(0,e.createElement)("div",{className:"gb-taxonomy-list-section"},(0,e.createElement)("h3",null,(0,i.sprintf)(/* translators: %s: plural taxonomy label */ /* translators: %s: plural taxonomy label */ (0,i.__)("Existing %s","generateblocks-pro"),k.plural||"Categories")),h?(0,e.createElement)("div",{className:"gb-taxonomy-loading"},(0,e.createElement)(s.Spinner,null),(0,e.createElement)("span",null,(0,i.sprintf)(/* translators: %s: plural taxonomy label */ /* translators: %s: plural taxonomy label */ (0,i.__)("Loading %s…","generateblocks-pro"),k.plural?.toLowerCase()||"categories"))):(0,e.createElement)("div",{className:"gb-dashboard-table-wrapper"},0===d.length?(0,e.createElement)("p",{style:{marginTop:"0"}},(0,i.sprintf)(/* translators: %s: plural taxonomy label */ /* translators: %s: plural taxonomy label */ (0,i.__)("No %s created yet.","generateblocks-pro"),k.plural?.toLowerCase()||"categories")):(0,e.createElement)(Qt.Table,{className:"gb-dashboard-table table-view-list",columns:I,data:d,"aria-labelledby":"taxonomy-table-header"})))))}const en={taxonomyConfig:{slug:"gblocks_condition_cat",restBase:"condition-categories",labels:{singular:(0,i.__)("Category","generateblocks-pro"),plural:(0,i.__)("Categories","generateblocks-pro"),uncategorized:(0,i.__)("Uncategorized","generateblocks-pro"),itemsCount:"conditions"}},itemsEndpoint:"/generateblocks-pro/advanced-conditions/v1/conditions",itemsTaxonomyField:"gblocks_condition_cat",manageEndpoint:"/generateblocks-pro/advanced-conditions/v1/manage_category"};function tn({onNavigateBack:t,onCategoriesChange:n}){return(0,e.createElement)("div",{className:"gb-categories-manager"},(0,e.createElement)(Xt,{...en,onNavigateBack:t,onTaxonomyChange:n}))}function nn({isModalMode:t=!1,onConditionSelect:n=null,onCreateCondition:r=null}={}){const[o,a]=(0,l.useState)((()=>{const e=new URLSearchParams(window.location.search);return parseInt(e.get("conditionPage")||"1",10)})),[c,u]=(0,l.useState)("list"),[d,p]=(0,l.useState)({conditionId:null,initialConditions:null,initialTitle:"",isNew:!1}),{data:h,isLoading:g}=Se(20,o),m=h?.conditions||[],b=h?.pages||1,[f,_]=(0,l.useState)(0),y=ie(),v=(0,l.useMemo)((()=>m&&m.length>0?m.map((e=>{const t=e.title?.rendered||e.title||"Untitled";return{...e,title:{...e.title,rendered:t}}})):[]),[m]);(0,l.useEffect)((()=>{if(t)return;const e=new URLSearchParams(window.location.search),n=e.get("edit");if(e.get("categories"))u("categories");else if(n&&"new"!==n){const e=v.find((e=>e.id.toString()===n));e&&(p({conditionId:e.id,initialConditions:e.gbConditions||{logic:"OR",groups:[]},initialTitle:e.title?.rendered||"",isNew:!1}),u("edit"))}else"new"===n?(p({conditionId:null,initialConditions:{logic:"OR",groups:[]},initialTitle:"",isNew:!0}),u("edit")):u("list")}),[v,t]);const k=(e,n=null)=>{if(t)return;const r=new URL(window.location);"edit"===e?(n?r.searchParams.set("edit",n):r.searchParams.set("edit","new"),r.searchParams.delete("categories")):"categories"===e?(r.searchParams.set("categories","manage"),r.searchParams.delete("edit")):(r.searchParams.delete("edit"),r.searchParams.delete("categories")),window.history.pushState({},"",r)};(0,l.useEffect)((()=>{if(t)return;const e=new URL(window.location);e.searchParams.set("conditionPage",o),window.history.replaceState({},"",e)}),[o,t]);const w=e=>{a(e)},E=()=>{u("list"),k("list"),p({conditionId:null,initialConditions:null,initialTitle:"",isNew:!1})};if((0,l.useEffect)((()=>{if(t)return;const e=()=>{const e=new URLSearchParams(window.location.search),t=e.get("edit");if(e.get("categories"))u("categories");else if(t&&"new"!==t){const e=v.find((e=>e.id.toString()===t));e&&(p({conditionId:e.id,initialConditions:e.gbConditions||{logic:"OR",groups:[]},initialTitle:e.title?.rendered||"",isNew:!1}),u("edit"))}else"new"===t?(p({conditionId:null,initialConditions:{logic:"OR",groups:[]},initialTitle:"",isNew:!0}),u("edit")):u("list")};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)}),[v,t]),g)return(0,e.createElement)("div",{className:"gb-dashboard-admin"},(0,e.createElement)(s.Spinner,null));const C={list:(0,e.createElement)("div",{className:"gb-dashboard-admin"},(0,e.createElement)("div",{className:"gb-dashboard-admin__header"},(0,e.createElement)("div",{className:"gb-dashboard-admin__header-buttons"},(0,e.createElement)(s.Button,{variant:"primary",onClick:()=>{t&&r?r():(p({conditionId:null,initialConditions:{logic:"OR",groups:[]},initialTitle:"",isNew:!0}),u("edit"),k("edit"))}},(0,i.__)("Add New","generateblocks-pro"))),(0,e.createElement)("div",{className:"gb-dashboard-admin__header-buttons-right"},(0,e.createElement)(s.Button,{variant:"secondary",onClick:()=>{u("categories"),k("categories")}},(0,i.__)("Manage Categories","generateblocks-pro")))),(0,e.createElement)("div",{className:"gb-dashboard-admin__inner"},(0,e.createElement)(Jt,{conditions:v,onEditCondition:e=>{t&&n?n(e):(p({conditionId:e.id,initialConditions:e.gbConditions||{logic:"OR",groups:[]},initialTitle:e.title?.rendered||"",isNew:!1}),u("edit"),k("edit",e.id))},refreshKey:f}),b>1&&(0,e.createElement)("div",{className:"gb-dashboard__pagination"},(0,e.createElement)(s.Button,{disabled:1===o,onClick:()=>w(o-1),variant:"secondary"},(0,i.__)("Previous","generateblocks-pro")),(0,e.createElement)("span",null,(0,i.sprintf)( // translators: %1$s: current page, %2$s: total pages // translators: %1$s: current page, %2$s: total pages (0,i.__)("Page %1$s of %2$s","generateblocks-pro"),o,b)),(0,e.createElement)(s.Button,{disabled:o===b,onClick:()=>w(o+1),variant:"secondary"},(0,i.__)("Next","generateblocks-pro"))))),edit:(0,e.createElement)("div",{className:"gb-dashboard-admin"},(0,e.createElement)(Vt,{onNavigateBack:E,onSave:async()=>{y.invalidateQueries({queryKey:["conditions"]}),E()},conditionId:d.conditionId,initialConditions:d.initialConditions,initialTitle:d.initialTitle,isNew:d.isNew})),categories:(0,e.createElement)("div",{className:"gb-dashboard-admin"},(0,e.createElement)(tn,{onNavigateBack:()=>{u("list"),k("list")},onCategoriesChange:()=>{_((e=>e+1))}}))},S=t?{list:C.list,categories:C.categories}:C,x=t?["list","categories"]:["list","edit","categories"];return(0,e.createElement)(Ne,{currentView:c,views:S,viewOrder:x,className:"gb-conditions-dashboard",minHeight:400})}function rn(t){return(0,e.createElement)(m,{client:ie()},(0,e.createElement)(nn,{...t}))}const on=window.wp.url;function an({trigger:t,conditionId:n=null,modalProps:r={}}){var o;const[a,s]=(0,l.useState)(n),c=ie(),{data:d,isLoading:p}=function(e){return ke({queryKey:["condition",e],queryFn:async()=>{const t=await u()({path:`/generateblocks-pro/advanced-conditions/v1/conditions/${e}`});if(t?.success)return t.response;throw new Error("Failed to fetch condition")},enabled:!!e&&"new"!==e,staleTime:12e4,cacheTime:3e5})}(a),h={backButton:(0,i.__)("Back to Conditions","generateblocks-pro"),createNew:(0,i.__)("Create New Condition","generateblocks-pro"),edit:(0,i.__)("Edit Condition","generateblocks-pro"),dashboard:(0,i.__)("Conditions","generateblocks-pro")},g=(0,e.createElement)(rn,null),m=a&&("new"===a?(0,e.createElement)(Vt,{conditionId:null,initialConditions:{logic:"OR",groups:[]},initialTitle:""}):!p&&d&&(0,e.createElement)(Vt,{conditionId:d.id,initialConditions:d?.gbConditions||{logic:"OR",groups:[]},initialTitle:d?.title?.rendered?.replace(` (${(0,i.__)("inactive","generateblocks-pro")})`,"")||""}));return(0,l.useEffect)((()=>{s(n)}),[n]),null!==(o=window.gbConditionsPermissions?.canManageConditions)&&void 0!==o&&o?(0,e.createElement)(Te,{trigger:t,itemId:a,itemType:"condition",dashboardView:g,editorView:m,modalProps:r,labels:h,className:"gb-conditions-dashboard-fullscreen",getNewTabUrl:e=>function(e="",t={}){const n=`${function(){if("undefined"==typeof window)return"/wp-admin/";if(window.ajaxurl)try{const e=new URL(window.ajaxurl,window.location.origin),t=e.pathname.replace(/admin-ajax\.php$/,"");return`${e.origin}${t}`}catch(e){}const{origin:e,pathname:t}=window.location,n=t.indexOf("/wp-admin");return-1!==n?`${e}${t.substring(0,n)}/wp-admin/`:`${e}/wp-admin/`}().replace(/\/+$/,"/")}${e.replace(/^\/+/,"")}`;return t&&0!==Object.keys(t).length?(0,on.addQueryArgs)(n,t):n}("admin.php",{page:"generateblocks-conditions",edit:e}),onItemSelect:e=>{s(e),e&&"new"!==e&&c.invalidateQueries({queryKey:["condition",e]})}}):null}function sn({label:t,help:n,value:r="",onChange:o,options:a=[],emptyLabel:c=(0,i.__)("None","generateblocks-pro"),className:u="",disabled:d=!1,editButton:p=null,emptyMessage:h="",uncategorizedLabel:g=(0,i.__)("Uncategorized","generateblocks-pro")}){const[m]=(0,l.useState)((()=>`gb-select-control-${Math.random().toString(36).substr(2,9)}`)),b=a&&"object"==typeof a&&!Array.isArray(a),f=b?Object.keys(a).length>0:a.length>0;return(0,e.createElement)(s.BaseControl,{id:m,label:t,help:n,htmlFor:m,className:`gb-select-group-control ${u}`,__nextHasNoMarginBottom:!0},(0,e.createElement)("div",{className:"gb-select-group-control__container"},(0,e.createElement)(s.SelectControl,{id:m,className:"gb-select-group-control__select",value:r,onChange:e=>o(e),disabled:d,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0},(0,e.createElement)("option",{value:""},c),b?Object.entries(a).map((([t,n])=>{const r="uncategorized"===t?n:n.items||[],o="uncategorized"===t?g:n.label;return"uncategorized"===t&&1===Object.keys(a).length?r.map((t=>(0,e.createElement)("option",{key:t.value,value:t.value},t.label))):(0,e.createElement)("optgroup",{key:t,label:o},r.map((t=>(0,e.createElement)("option",{key:t.value,value:t.value},t.label))))})):a.map((t=>(0,e.createElement)("option",{key:t.value,value:t.value},t.label)))),p&&("object"==typeof p&&p.show?(0,e.createElement)(s.Button,{variant:"tertiary",icon:p.icon,onClick:p.onClick,label:p.label||(0,i.__)("Edit","generateblocks-pro"),__next40pxDefaultSize:!0}):p)),!f&&h&&(0,e.createElement)("p",{className:"gb-select-group-control__empty"},h))}function ln({value:t="",onChange:n,label:r=(0,i.__)("Display Conditions","generateblocks-pro"),help:o=""}){const{data:a,isLoading:c}=Se(100,1),{data:u=[],isLoading:d}=ke({queryKey:["condition-categories"],queryFn:Ce}),p=c||d,[h,g]=(0,l.useState)({});(0,l.useEffect)((()=>{!p&&a?.conditions&&t&&(a.conditions.some((e=>e.id.toString()===t.toString()))||setTimeout((()=>{n("")}),0))}),[t,a?.conditions,p,n]),(0,l.useEffect)((()=>{if(!p&&a?.conditions&&u){const e=a.conditions,t={},n=e.filter((e=>!e.gblocks_condition_cat||0===e.gblocks_condition_cat.length));n.length>0&&(t.uncategorized=n.map((e=>{let t=(0,i.__)("Untitled","generateblocks-pro");return"string"==typeof e.title?t=e.title:e.title?.rendered&&(t=e.title.rendered),"draft"===e.status&&(t=(0,i.__)("[Draft]","generateblocks-pro")+" "+t),{value:e.id.toString(),label:(0,pe.decodeEntities)(t)}}))),u.forEach((n=>{const r=e.filter((e=>e.gblocks_condition_cat?.includes(n.id)));r.length>0&&(t[n.slug]={label:(0,pe.decodeEntities)(n.name),items:r.map((e=>{let t=(0,i.__)("Untitled","generateblocks-pro");return"string"==typeof e.title?t=e.title:e.title?.rendered&&(t=e.title.rendered),"draft"===e.status&&(t=(0,i.__)("[Draft]","generateblocks-pro")+" "+t),{value:e.id.toString(),label:(0,pe.decodeEntities)(t)}}))})})),g(t)}}),[a?.conditions,u,p]);const m=t?parseInt(t,10):null,b=m&&m>0,f=!b;let _=null;b?_=(0,e.createElement)(an,{trigger:(0,e.createElement)(s.Button,{variant:"tertiary",icon:ue}),conditionId:m}):f&&(_=(0,e.createElement)(an,{trigger:(0,e.createElement)(s.Button,{variant:"tertiary",icon:de}),conditionId:"new"}));const y=p?[]:h;return(0,e.createElement)(sn,{label:r,help:o,value:t,onChange:n,options:y,emptyLabel:p?(0,i.__)("Loading conditions…","generateblocks-pro"):(0,i.__)("No condition","generateblocks-pro"),editButton:_,emptyMessage:"",disabled:p})}function cn({value:t="",onChange:n,label:r=(0,i.__)("Display Conditions","generateblocks-pro"),help:o=""}){return(0,e.createElement)(m,{client:ie()},(0,e.createElement)(ln,{value:t,onChange:n,label:r,help:o}))}function un({isOpen:t,onClose:n,onConfirm:r,isCreating:o=!1}){const[a,c]=(0,l.useState)(""),u=()=>{a.trim()&&r(a.trim())};return t?(0,e.createElement)(s.Modal,{title:(0,i.__)("Create New Category","generateblocks-pro"),onRequestClose:n,className:"gb-create-category-modal"},(0,e.createElement)(s.TextControl,{label:(0,i.__)("Category Name","generateblocks-pro"),value:a,onChange:c,onKeyDown:e=>{"Enter"===e.key&&a.trim()&&u()},disabled:o}),(0,e.createElement)("div",{className:"gb-create-category-modal__actions",style:{display:"flex",justifyContent:"space-between"}},(0,e.createElement)(s.Button,{variant:"secondary",onClick:n,disabled:o},(0,i.__)("Cancel","generateblocks-pro")),(0,e.createElement)(s.Button,{variant:"primary",onClick:u,disabled:!a.trim()||o,isBusy:o},o?(0,i.__)("Creating…","generateblocks-pro"):(0,i.__)("Create Category","generateblocks-pro")))):null}const dn=[{label:(0,i.__)("None","generateblocks-pro"),value:""},{label:(0,i.__)("Fade In","generateblocks-pro"),value:"fadeIn"},{label:(0,i.__)("Fade In Up","generateblocks-pro"),value:"fadeInUp"},{label:(0,i.__)("Fade In Down","generateblocks-pro"),value:"fadeInDown"},{label:(0,i.__)("Fade In Left","generateblocks-pro"),value:"fadeInLeft"},{label:(0,i.__)("Fade In Right","generateblocks-pro"),value:"fadeInRight"},{label:(0,i.__)("Slide In Up","generateblocks-pro"),value:"slideInUp"},{label:(0,i.__)("Slide In Down","generateblocks-pro"),value:"slideInDown"},{label:(0,i.__)("Slide In Left","generateblocks-pro"),value:"slideInLeft"},{label:(0,i.__)("Slide In Right","generateblocks-pro"),value:"slideInRight"},{label:(0,i.__)("Scale In","generateblocks-pro"),value:"scaleIn"}],pn=[{label:(0,i.__)("None","generateblocks-pro"),value:""},{label:(0,i.__)("Fade Out","generateblocks-pro"),value:"fadeOut"},{label:(0,i.__)("Fade Out Up","generateblocks-pro"),value:"fadeOutUp"},{label:(0,i.__)("Fade Out Down","generateblocks-pro"),value:"fadeOutDown"},{label:(0,i.__)("Fade Out Left","generateblocks-pro"),value:"fadeOutLeft"},{label:(0,i.__)("Fade Out Right","generateblocks-pro"),value:"fadeOutRight"},{label:(0,i.__)("Slide Out Up","generateblocks-pro"),value:"slideOutUp"},{label:(0,i.__)("Slide Out Down","generateblocks-pro"),value:"slideOutDown"},{label:(0,i.__)("Slide Out Left","generateblocks-pro"),value:"slideOutLeft"},{label:(0,i.__)("Slide Out Right","generateblocks-pro"),value:"slideOutRight"},{label:(0,i.__)("Scale Out","generateblocks-pro"),value:"scaleOut"}];(0,a.registerPlugin)("generateblocks-pro-overlay-options",{render:function(){const{editPost:t}=(0,r.useDispatch)(o.store),[n,a]=(0,l.useState)([]),[c,p]=(0,l.useState)(!1),[h,g]=(0,l.useState)(!1),[m,b]=(0,l.useState)(!0),{updateSettings:f}=function(){const e=(0,on.getPath)(window.location.href)?.includes("site-editor.php"),t=(0,r.useDispatch)(e?"core/edit-site":"core/editor");return{updateSettings:e?t.updateSettings:t.updateEditorSettings}}(),{getSettings:_}=(0,r.useSelect)((()=>{const e=(0,on.getPath)(window.location.href)?.includes("site-editor.php"),t=(0,r.select)(e?"core/edit-site":"core/editor");return{getSettings:e?t.getSettings:t.getEditorSettings}}),[]),y=(0,r.useSelect)((e=>e(o.store).getEditedPostAttribute("meta"))),v=(0,r.useSelect)((e=>e(o.store).getEditedPostAttribute("gblocks_overlay_cat")||[])),{_gb_overlay_display_condition:k,_gb_overlay_display_condition_invert:w,_gb_overlay_type:E,_gb_overlay_placement:C,_gb_overlay_backdrop:S,_gb_overlay_backdrop_color:x,_gb_overlay_backdrop_blur:I,_gb_overlay_animation_in:O,_gb_overlay_animation_out:N,_gb_overlay_animation_duration:T,_gb_overlay_animation_distance:R,_gb_overlay_trigger_type:D,_gb_overlay_scroll_percent:M,_gb_overlay_time_delay:P,_gb_overlay_cookie_duration:A,_gb_overlay_close_on_esc:B,_gb_overlay_close_on_click_outside:F,_gb_overlay_disable_page_scroll:$,_gb_overlay_position:q,_gb_overlay_custom_event:L,_gb_overlay_hide_if_cookies_disabled:z,_gb_overlay_position_to_parent:H,_gb_overlay_hover_buffer:U,_gb_overlay_width_mode:V}=y,j=e=>{t({meta:{...y,...e}})},Q=(0,r.useSelect)((e=>e(o.store).getCurrentPostId()));(0,l.useEffect)((()=>{b(!0),u()({path:"/wp/v2/overlay-categories?per_page=100"}).then((e=>{a(e)})).catch((e=>{console.error("Error loading categories:",e)})).finally((()=>{b(!1)}))}),[]),(0,l.useEffect)((()=>{const e=new URLSearchParams(window.location.search),t=e.get("overlay_type");if(t&&(!E||"standard"===E)&&["standard","anchored","mega-menu"].includes(t)){j({_gb_overlay_type:t}),e.delete("overlay_type");const n=window.location.pathname+(e.toString()?"?"+e.toString():"")+window.location.hash;window.history.replaceState({},"",n)}}),[E]);const K=[{label:(0,i.__)("Click","generateblocks-pro"),value:"click"},{label:(0,i.__)("Hover","generateblocks-pro"),value:"hover"},{label:(0,i.__)("Click or Hover","generateblocks-pro"),value:"both"}],W=["click","hover","both"].includes(D),G=["exit-intent","scroll","time","custom"].includes(D),Y=A&&""!==A&&"0"!==A;return"standard"===E&&K.push({label:(0,i.__)("Exit Intent","generateblocks-pro"),value:"exit-intent"},{label:(0,i.__)("Percentage Scrolled","generateblocks-pro"),value:"scroll"},{label:(0,i.__)("Time Delay","generateblocks-pro"),value:"time"},{label:(0,i.__)("Custom Event","generateblocks-pro"),value:"custom"}),(0,e.createElement)(o.PluginDocumentSettingPanel,{title:(0,i.__)("Overlay Panel Options","generateblocks-pro"),name:"generateblocks-overlay-options",className:"generateblocks-overlay-options-panel"},(0,e.createElement)("div",{className:"generateblocks-overlay-options"},(0,e.createElement)(s.SelectControl,{label:(0,i.__)("Overlay Panel Type","generateblocks-pro"),value:E||"standard",options:[{label:(0,i.__)("Standard","generateblocks-pro"),value:"standard"},{label:(0,i.__)("Anchored","generateblocks-pro"),value:"anchored"},{label:(0,i.__)("Mega Menu","generateblocks-pro"),value:"mega-menu"}],onChange:e=>j({_gb_overlay_type:e}),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,e.createElement)(s.SelectControl,{label:(0,i.__)("Category","generateblocks-pro"),value:v.length>0?v[0]:"",onChange:e=>{"new"===e?p(!0):t(e?{gblocks_overlay_cat:[parseInt(e,10)]}:{gblocks_overlay_cat:[]})},options:m?[{label:(0,i.__)("Loading categories…","generateblocks-pro"),value:""}]:[{label:(0,i.__)("No category","generateblocks-pro"),value:""},...n.map((e=>({label:e.name,value:e.id}))),{label:(0,i.__)("+ Add new category","generateblocks-pro"),value:"new"}],disabled:m,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,e.createElement)(cn,{value:k||"",onChange:e=>j({_gb_overlay_display_condition:e}),label:(0,i.__)("Display Condition","generateblocks-pro"),help:(0,i.__)('Choose a condition to control when this overlay panel appears. Leave as "no condition" to display everywhere.',"generateblocks-pro")}),k&&(0,e.createElement)(s.CheckboxControl,{label:(0,i.__)("Invert condition","generateblocks-pro"),help:(0,i.__)("Show the overlay panel when the condition is false instead of true.","generateblocks-pro"),checked:null!=w&&w,onChange:e=>j({_gb_overlay_display_condition_invert:e}),__nextHasNoMarginBottom:!0}),"mega-menu"!==E&&(0,e.createElement)(s.SelectControl,{label:(0,i.__)("Trigger Type","generateblocks-pro"),value:D||"click",options:K,onChange:e=>j({_gb_overlay_trigger_type:e}),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),"standard"===E&&(0,e.createElement)(e.Fragment,null,"scroll"===D&&(0,e.createElement)(s.TextControl,{label:(0,i.__)("Scroll Percentage (%)","generateblocks-pro"),type:"text",value:null!=M?M:"",min:"0",max:"100",onChange:e=>{const t=""===e?"":parseInt(e,10).toString();j({_gb_overlay_scroll_percent:t})},help:(0,i.__)("Percentage of page scrolled to trigger the overlay panel (0-100).","generateblocks-pro"),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),"time"===D&&(0,e.createElement)(s.TextControl,{label:(0,i.__)("Time Delay (ms)","generateblocks-pro"),type:"text",value:null!=P?P:"",min:"0",onChange:e=>{const t=""===e?"":parseInt(e,10).toString();j({_gb_overlay_time_delay:t})},help:(0,i.__)("Delay in milliseconds before the overlay panel opens.","generateblocks-pro"),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),"custom"===D&&(0,e.createElement)(s.TextControl,{label:(0,i.__)("Event Name","generateblocks-pro"),type:"text",value:L||"",onChange:e=>j({_gb_overlay_custom_event:e}),help:(0,i.__)('Enter the custom event name to listen for (e.g., "wc-blocks_added_to_cart").',"generateblocks-pro"),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),G&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(s.TextControl,{label:(0,i.__)("Keep Closed Duration (hours)","generateblocks-pro"),type:"number",value:null!=A?A:"",min:"0",onChange:e=>{const t=""===e?"":parseInt(e,10).toString();j({_gb_overlay_cookie_duration:t})},help:(0,i.__)("Number of hours to prevent overlay panel reopening after closing (0 for session-only).","generateblocks-pro"),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),!!Y&&(0,e.createElement)(s.CheckboxControl,{label:(0,i.__)("Hide if cookies disabled","generateblocks-pro"),checked:null!=z&&z,onChange:e=>j({_gb_overlay_hide_if_cookies_disabled:e}),help:(0,i.__)("Prevent overlay panel from showing when cookies are disabled in browser.","generateblocks-pro"),__nextHasNoMarginBottom:!0})),(0,e.createElement)(s.CheckboxControl,{label:(0,i.__)("Show Backdrop","generateblocks-pro"),checked:null!=S&&S,onChange:e=>j({_gb_overlay_backdrop:e}),__nextHasNoMarginBottom:!0}),!!S&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(d.ColorPicker,{label:(0,i.__)("Backdrop Color","generateblocks-pro"),value:null!=x?x:"",onChange:e=>j({_gb_overlay_backdrop_color:e}),__nextHasNoMarginBottom:!0}),(0,e.createElement)(s.TextControl,{label:(0,i.__)("Backdrop Blur","generateblocks-pro"),value:null!=I?I:"",onChange:e=>j({_gb_overlay_backdrop_blur:e}),help:(0,i.__)("Enter a blur value in pixels (e.g., 5).","generateblocks-pro"),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})),(0,e.createElement)(s.SelectControl,{label:(0,i.__)("Position","generateblocks-pro"),value:q||"center",options:[{label:(0,i.__)("Center","generateblocks-pro"),value:"center"},{label:(0,i.__)("Top Left","generateblocks-pro"),value:"top-left"},{label:(0,i.__)("Top Center","generateblocks-pro"),value:"top-center"},{label:(0,i.__)("Top Right","generateblocks-pro"),value:"top-right"},{label:(0,i.__)("Center Left","generateblocks-pro"),value:"center-left"},{label:(0,i.__)("Center Right","generateblocks-pro"),value:"center-right"},{label:(0,i.__)("Bottom Left","generateblocks-pro"),value:"bottom-left"},{label:(0,i.__)("Bottom Center","generateblocks-pro"),value:"bottom-center"},{label:(0,i.__)("Bottom Right","generateblocks-pro"),value:"bottom-right"}],onChange:e=>j({_gb_overlay_position:e}),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,e.createElement)(s.CheckboxControl,{label:(0,i.__)("Close on ESC key","generateblocks-pro"),checked:null==B||B,onChange:e=>j({_gb_overlay_close_on_esc:e}),__nextHasNoMarginBottom:!0}),(0,e.createElement)(s.CheckboxControl,{label:(0,i.__)("Close on click outside","generateblocks-pro"),checked:null==F||F,onChange:e=>j({_gb_overlay_close_on_click_outside:e}),__nextHasNoMarginBottom:!0}),(0,e.createElement)(s.CheckboxControl,{label:(0,i.__)("Disable page scroll","generateblocks-pro"),checked:null!=$&&$,onChange:e=>j({_gb_overlay_disable_page_scroll:e}),help:(0,i.__)("Prevent scrolling the page when the overlay panel is open.","generateblocks-pro"),__nextHasNoMarginBottom:!0})),("anchored"===E||"mega-menu"===E)&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(s.SelectControl,{label:(0,i.__)("Placement","generateblocks-pro"),value:C||"bottom-start",options:[{label:(0,i.__)("Bottom Left","generateblocks-pro"),value:"bottom-start"},{label:(0,i.__)("Bottom Center","generateblocks-pro"),value:"bottom"},{label:(0,i.__)("Bottom Right","generateblocks-pro"),value:"bottom-end"},{label:(0,i.__)("Top Left","generateblocks-pro"),value:"top-start"},{label:(0,i.__)("Top Center","generateblocks-pro"),value:"top"},{label:(0,i.__)("Top Right","generateblocks-pro"),value:"top-end"},{label:(0,i.__)("Right Side","generateblocks-pro"),value:"right"},{label:(0,i.__)("Left Side","generateblocks-pro"),value:"left"}],onChange:e=>j({_gb_overlay_placement:e}),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,e.createElement)(s.TextControl,{label:(0,i.__)("Position to Parent","generateblocks-pro"),value:H||"",onChange:e=>j({_gb_overlay_position_to_parent:e}),help:(0,i.__)('CSS selector to position the overlay panel relative to (e.g., ".gb-site-header", ".gb-navigation").',"generateblocks-pro"),placeholder:(0,i.__)("e.g., .gb-site-header","generateblocks-pro"),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})),(0,e.createElement)(s.SelectControl,{label:(0,i.__)("Animation In","generateblocks-pro"),value:O||"",options:dn,onChange:e=>j({_gb_overlay_animation_in:e}),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,e.createElement)(s.SelectControl,{label:(0,i.__)("Animation Out","generateblocks-pro"),value:N||"",options:pn,onChange:e=>j({_gb_overlay_animation_out:e}),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,e.createElement)(s.TextControl,{label:(0,i.__)("Animation Duration (ms)","generateblocks-pro"),type:"text",value:null!=T?T:"",min:"0",onChange:e=>{const t=""===e?"":parseInt(e,10).toString();j({_gb_overlay_animation_duration:t})},__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),["Up","Down","Left","Right"].some((e=>O&&O.includes(e)||N&&N.includes(e)))&&(0,e.createElement)(s.TextControl,{label:(0,i.__)("Animation Distance","generateblocks-pro"),type:"text",value:null!=R?R:"",placeholder:"1rem",onChange:e=>j({_gb_overlay_animation_distance:e}),help:(0,i.__)("Distance for slide/fade animations (e.g., 1rem, 20px, 100%).","generateblocks-pro"),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),!!W&&(0,e.createElement)(s.TextControl,{label:(0,i.__)("Hover Buffer (px)","generateblocks-pro"),type:"number",value:null!=U?U:"",min:"0",max:"100",onChange:e=>{const t=""===e?"":parseInt(e,10).toString();j({_gb_overlay_hover_buffer:t})},help:(0,i.__)("Invisible buffer zone around overlay panel for hover detection. Useful for hover-triggered overlay panels.","generateblocks-pro"),placeholder:"20",__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,e.createElement)(s.SelectControl,{label:(0,i.__)("Width Mode","generateblocks-pro"),value:V||"",options:[{label:(0,i.__)("Max Content","generateblocks-pro"),value:""},{label:(0,i.__)("Full Width","generateblocks-pro"),value:"full"}],onChange:e=>{j({_gb_overlay_width_mode:e});const t=_(),n=t?.styles?.find((e=>"gb_overlay_editor_width"===e.source)),r="full"===e?".is-root-container { width: 100%; }":".is-root-container { width: max-content; }";f(n?{...t,styles:t?.styles.map((e=>"gb_overlay_editor_width"!==e.source?e:{...e,css:r}))}:{...t,styles:[...t?.styles,{css:r,source:"gb_overlay_editor_width"}]})},__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),!!W&&navigator?.clipboard&&(0,e.createElement)(s.BaseControl,{label:(0,i.__)("Data Attribute","generateblocks-pro"),id:"generateblocks-overlay-data-attribute",help:(0,i.__)("Use this data attribute to trigger the overlay panel from other elements.","generateblocks-pro"),__nextHasNoMarginBottom:!0},(0,e.createElement)(s.Button,{variant:"secondary",size:"compact",className:"generateblocks-copy-data-attribute-button",disabled:!Q,onClick:()=>{const e='data-gb-overlay="gb-overlay-'+Q+'"';navigator.clipboard.writeText(e).then((()=>{const e=document.querySelector(".generateblocks-copy-data-attribute-button");if(e){const t=e.textContent;e.textContent=(0,i.__)("Copied!","generateblocks-pro"),setTimeout((()=>{e.textContent=t}),2e3)}})).catch((e=>{console.error("Failed to copy text: ",e)}))},__next40pxDefaultSize:!0},(0,i.__)("Copy Data Attribute","generateblocks-pro")))),(0,e.createElement)(un,{isOpen:c,onClose:()=>p(!1),onConfirm:async e=>{g(!0);try{const r=await u()({path:"/wp/v2/overlay-categories",method:"POST",data:{name:e}});a([...n,r]),t({gblocks_overlay_cat:[r.id]}),p(!1)}catch(e){console.error("Error creating category:",e)}finally{g(!1)}},isCreating:h}))},icon:null})})()})();
💾 Save Changes
❌ Cancel