(()=>{"use strict";var e={1020(e,t,s){var r=s(1609),n=Symbol.for("react.element"),a=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,s){var r,c={},l=null,u=null;for(r in void 0!==s&&(l=""+s),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(u=t.ref),t)a.call(t,r)&&!o.hasOwnProperty(r)&&(c[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===c[r]&&(c[r]=t[r]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:i.current}}},4848(e,t,s){e.exports=s(1020)},1609(e){e.exports=window.React}},t={};function s(r){var n=t[r];if(void 0!==n)return n.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,s),a.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r=s(1609);const n=window.wp.element,a=window.wp.components,i=window.wp.i18n,o=window.wp.htmlEntities,c=window.wp.date,l=window.wp.primitives,u=(0,n.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"-2 -2 24 24"},(0,n.createElement)(l.Path,{d:"M10 2c4.42 0 8 3.58 8 8s-3.58 8-8 8-8-3.58-8-8 3.58-8 8-8zm1.13 9.38l.35-6.46H8.52l.35 6.46h2.26zm-.09 3.36c.24-.23.37-.55.37-.96 0-.42-.12-.74-.36-.97s-.59-.35-1.06-.35-.82.12-1.07.35-.37.55-.37.97c0 .41.13.73.38.96.26.23.61.34 1.06.34s.8-.11 1.05-.34z"})),d=(0,n.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,n.createElement)(l.Path,{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})),h=window.gbp.components;var p=s(4848),m=r.createContext(void 0),f=e=>{const t=r.useContext(m);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},g=({client:e,children:t})=>(r.useEffect((()=>(e.mount(),()=>{e.unmount()})),[e]),(0,p.jsx)(m.Provider,{value:e,children:t}));const b=window.wp.apiFetch;var y=s.n(b),v="undefined"==typeof window||"Deno"in globalThis;function _(){}function w(e){return"number"==typeof e&&e>=0&&e!==1/0}function E(e,t){return Math.max(e+(t||0)-Date.now(),0)}function k(e,t){return"function"==typeof e?e(t):e}function S(e,t){return"function"==typeof e?e(t):e}function C(e,t){const{type:s="all",exact:r,fetchStatus:n,predicate:a,queryKey:i,stale:o}=e;if(i)if(r){if(t.queryHash!==R(i,t.options))return!1}else if(!P(t.queryKey,i))return!1;if("all"!==s){const e=t.isActive();if("active"===s&&!e)return!1;if("inactive"===s&&e)return!1}return!("boolean"==typeof o&&t.isStale()!==o||n&&n!==t.state.fetchStatus||a&&!a(t))}function O(e,t){const{exact:s,status:r,predicate:n,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(s){if(x(t.options.mutationKey)!==x(a))return!1}else if(!P(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||n&&!n(t))}function R(e,t){return(t?.queryKeyHashFn||x)(e)}function x(e){return JSON.stringify(e,((e,t)=>Q(t)?Object.keys(t).sort().reduce(((e,s)=>(e[s]=t[s],e)),{}):t))}function P(e,t){return e===t||typeof e==typeof t&&!(!e||!t||"object"!=typeof e||"object"!=typeof t)&&Object.keys(t).every((s=>P(e[s],t[s])))}function q(e,t){if(e===t)return e;const s=D(e)&&D(t);if(s||Q(e)&&Q(t)){const r=s?e:Object.keys(e),n=r.length,a=s?t:Object.keys(t),i=a.length,o=s?[]:{};let c=0;for(let n=0;ns?r.slice(1):r}function N(e,t,s=0){const r=[t,...e];return s&&r.length>s?r.slice(0,-1):r}var U=Symbol();function j(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:e.queryFn&&e.queryFn!==U?e.queryFn:()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`))}function B(e,t){return"function"==typeof e?e(...t):!!e}var K=e=>setTimeout(e,0),L=function(){let e=[],t=0,s=e=>{e()},r=e=>{e()},n=K;const a=r=>{t?e.push(r):n((()=>{s(r)}))};return{batch:a=>{let i;t++;try{i=a()}finally{t--,t||(()=>{const t=e;e=[],t.length&&n((()=>{r((()=>{t.forEach((e=>{s(e)}))}))}))})()}return i},batchCalls:e=>(...t)=>{a((()=>{e(...t)}))},schedule:a,setNotifyFunction:e=>{s=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{n=e}}}(),$=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 ${#e;#t;#s;constructor(){super(),this.#s=e=>{if(!v&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#s=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 ${#r=!0;#t;#s;constructor(){super(),this.#s=e=>{if(!v&&window.addEventListener){const t=()=>e(!0),s=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",s)}}}}onSubscribe(){this.#t||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#s=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 G(){let e,t;const s=new Promise(((s,r)=>{e=s,t=r}));function r(e){Object.assign(s,e),delete s.resolve,delete s.reject}return s.status="pending",s.catch((()=>{})),s.resolve=t=>{r({status:"fulfilled",value:t}),e(t)},s.reject=e=>{r({status:"rejected",reason:e}),t(e)},s}function V(e){return Math.min(1e3*2**e,3e4)}function W(e){return"online"!==(e??"online")||H.isOnline()}var Z=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Y(e){return e instanceof Z}function J(e){let t,s=!1,r=0,n=!1;const a=G(),i=()=>z.isFocused()&&("always"===e.networkMode||H.isOnline())&&e.canRun(),o=()=>W(e.networkMode)&&e.canRun(),c=s=>{n||(n=!0,e.onSuccess?.(s),t?.(),a.resolve(s))},l=s=>{n||(n=!0,e.onError?.(s),t?.(),a.reject(s))},u=()=>new Promise((s=>{t=e=>{(n||i())&&s(e)},e.onPause?.()})).then((()=>{t=void 0,n||e.onContinue?.()})),d=()=>{if(n)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(c).catch((t=>{if(n)return;const a=e.retry??(v?0:3),o=e.retryDelay??V,c="function"==typeof o?o(r,t):o,h=!0===a||"number"==typeof a&&r{setTimeout(e,p)}))).then((()=>i()?void 0:u())).then((()=>{s?l(t):d()}))):l(t)}))};return{promise:a,cancel:t=>{n||(l(new Z(t)),e.abort?.())},continue:()=>(t?.(),a),cancelRetry:()=>{s=!0},continueRetry:()=>{s=!1},canStart:o,start:()=>(o()?d():u().then(d),a)}}var X=class{#n;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),w(this.gcTime)&&(this.#n=setTimeout((()=>{this.optionalRemove()}),this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(v?1/0:3e5))}clearGcTimeout(){this.#n&&(clearTimeout(this.#n),this.#n=void 0)}},ee=class extends X{#a;#i;#o;#c;#l;#u;#d;constructor(e){super(),this.#d=!1,this.#u=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#c=e.client,this.#o=this.#c.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#a=function(e){const t="function"==typeof e.initialData?e.initialData():e.initialData,s=void 0!==t,r=s?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}(this.options),this.state=e.state??this.#a,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#l?.promise}setOptions(e){this.options={...this.#u,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#o.remove(this)}setData(e,t){const s=T(this.state.data,e,this.options);return this.#h({data:s,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),s}setState(e,t){this.#h({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#l?.promise;return this.#l?.cancel(e),t?t.then(_).catch(_):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#a)}isActive(){return this.observers.some((e=>!1!==S(e.options.enabled,this)))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===U||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||!E(this.state.dataUpdatedAt,e)}onFocus(){const e=this.observers.find((e=>e.shouldFetchOnWindowFocus()));e?.refetch({cancelRefetch:!1}),this.#l?.continue()}onOnline(){const e=this.observers.find((e=>e.shouldFetchOnReconnect()));e?.refetch({cancelRefetch:!1}),this.#l?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#o.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.#l&&(this.#d?this.#l.cancel({revert:!0}):this.#l.cancelRetry()),this.scheduleGc()),this.#o.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#h({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.#l)return this.#l.continueRetry(),this.#l.promise;if(e&&this.setOptions(e),!this.options.queryFn){const e=this.observers.find((e=>e.options.queryFn));e&&this.setOptions(e.options)}const s=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#d=!0,s.signal)})},n={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#c,state:this.state,fetchFn:()=>{const e=j(this.options,t),s={client:this.#c,queryKey:this.queryKey,meta:this.meta};return r(s),this.#d=!1,this.options.persister?this.options.persister(e,s,this):e(s)}};r(n),this.options.behavior?.onFetch(n,this),this.#i=this.state,"idle"!==this.state.fetchStatus&&this.state.fetchMeta===n.fetchOptions?.meta||this.#h({type:"fetch",meta:n.fetchOptions?.meta});const a=e=>{Y(e)&&e.silent||this.#h({type:"error",error:e}),Y(e)||(this.#o.config.onError?.(e,this),this.#o.config.onSettled?.(this.state.data,e,this)),this.scheduleGc()};return this.#l=J({initialPromise:t?.initialPromise,fn:n.fetchFn,abort:s.abort.bind(s),onSuccess:e=>{if(void 0!==e){try{this.setData(e)}catch(e){return void a(e)}this.#o.config.onSuccess?.(e,this),this.#o.config.onSettled?.(e,this.state.error,this),this.scheduleGc()}else a(new Error(`${this.queryHash} data is undefined`))},onError:a,onFail:(e,t)=>{this.#h({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#h({type:"pause"})},onContinue:()=>{this.#h({type:"continue"})},retry:n.options.retry,retryDelay:n.options.retryDelay,networkMode:n.options.networkMode,canRun:()=>!0}),this.#l.start()}#h(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,...te(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 s=e.error;return Y(s)&&s.revert&&this.#i?{...this.#i,fetchStatus:"idle"}:{...t,error:s,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error"};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}})(this.state),L.batch((()=>{this.observers.forEach((e=>{e.onQueryUpdate()})),this.#o.notify({query:this,type:"updated",action:e})}))}};function te(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:W(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}var se=class extends ${constructor(e={}){super(),this.config=e,this.#p=new Map}#p;build(e,t,s){const r=t.queryKey,n=t.queryHash??R(r,t);let a=this.get(n);return a||(a=new ee({client:e,queryKey:r,queryHash:n,options:e.defaultQueryOptions(t),state:s,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#p.has(e.queryHash)||(this.#p.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#p.get(e.queryHash);t&&(e.destroy(),t===e&&this.#p.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){L.batch((()=>{this.getAll().forEach((e=>{this.remove(e)}))}))}get(e){return this.#p.get(e)}getAll(){return[...this.#p.values()]}find(e){const t={exact:!0,...e};return this.getAll().find((e=>C(t,e)))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter((t=>C(e,t))):t}notify(e){L.batch((()=>{this.listeners.forEach((t=>{t(e)}))}))}onFocus(){L.batch((()=>{this.getAll().forEach((e=>{e.onFocus()}))}))}onOnline(){L.batch((()=>{this.getAll().forEach((e=>{e.onOnline()}))}))}},re=class extends X{#m;#f;#l;constructor(e){super(),this.mutationId=e.mutationId,this.#f=e.mutationCache,this.#m=[],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.#m.includes(e)||(this.#m.push(e),this.clearGcTimeout(),this.#f.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#m=this.#m.filter((t=>t!==e)),this.scheduleGc(),this.#f.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#m.length||("pending"===this.state.status?this.scheduleGc():this.#f.remove(this))}continue(){return this.#l?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#h({type:"continue"})};this.#l=J({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(e,t)=>{this.#h({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#h({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#f.canRun(this)});const s="pending"===this.state.status,r=!this.#l.canStart();try{if(s)t();else{this.#h({type:"pending",variables:e,isPaused:r}),await(this.#f.config.onMutate?.(e,this));const t=await(this.options.onMutate?.(e));t!==this.state.context&&this.#h({type:"pending",context:t,variables:e,isPaused:r})}const n=await this.#l.start();return await(this.#f.config.onSuccess?.(n,e,this.state.context,this)),await(this.options.onSuccess?.(n,e,this.state.context)),await(this.#f.config.onSettled?.(n,null,this.state.variables,this.state.context,this)),await(this.options.onSettled?.(n,null,e,this.state.context)),this.#h({type:"success",data:n}),n}catch(t){try{throw await(this.#f.config.onError?.(t,e,this.state.context,this)),await(this.options.onError?.(t,e,this.state.context)),await(this.#f.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.#h({type:"error",error:t})}}finally{this.#f.runNext(this)}}#h(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),L.batch((()=>{this.#m.forEach((t=>{t.onMutationUpdate(e)})),this.#f.notify({mutation:this,type:"updated",action:e})}))}},ne=class extends ${constructor(e={}){super(),this.config=e,this.#g=new Set,this.#b=new Map,this.#y=0}#g;#b;#y;build(e,t,s){const r=new re({mutationCache:this,mutationId:++this.#y,options:e.defaultMutationOptions(t),state:s});return this.add(r),r}add(e){this.#g.add(e);const t=ae(e);if("string"==typeof t){const s=this.#b.get(t);s?s.push(e):this.#b.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#g.delete(e)){const t=ae(e);if("string"==typeof t){const s=this.#b.get(t);if(s)if(s.length>1){const t=s.indexOf(e);-1!==t&&s.splice(t,1)}else s[0]===e&&this.#b.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=ae(e);if("string"==typeof t){const s=this.#b.get(t),r=s?.find((e=>"pending"===e.state.status));return!r||r===e}return!0}runNext(e){const t=ae(e);if("string"==typeof t){const s=this.#b.get(t)?.find((t=>t!==e&&t.state.isPaused));return s?.continue()??Promise.resolve()}return Promise.resolve()}clear(){L.batch((()=>{this.#g.forEach((e=>{this.notify({type:"removed",mutation:e})})),this.#g.clear(),this.#b.clear()}))}getAll(){return Array.from(this.#g)}find(e){const t={exact:!0,...e};return this.getAll().find((e=>O(t,e)))}findAll(e={}){return this.getAll().filter((t=>O(e,t)))}notify(e){L.batch((()=>{this.listeners.forEach((t=>{t(e)}))}))}resumePausedMutations(){const e=this.getAll().filter((e=>e.state.isPaused));return L.batch((()=>Promise.all(e.map((e=>e.continue().catch(_))))))}};function ae(e){return e.options.scope?.id}function ie(e){return{onFetch:(t,s)=>{const r=t.options,n=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],i=t.state.data?.pageParams||[];let o={pages:[],pageParams:[]},c=0;const l=async()=>{let s=!1;const l=j(t.options,t.fetchOptions),u=async(e,r,n)=>{if(s)return Promise.reject();if(null==r&&e.pages.length)return Promise.resolve(e);const a={client:t.client,queryKey:t.queryKey,pageParam:r,direction:n?"backward":"forward",meta:t.options.meta};var i;i=a,Object.defineProperty(i,"signal",{enumerable:!0,get:()=>(t.signal.aborted?s=!0:t.signal.addEventListener("abort",(()=>{s=!0})),t.signal)});const o=await l(a),{maxPages:c}=t.options,u=n?N:A;return{pages:u(e.pages,o,c),pageParams:u(e.pageParams,r,c)}};if(n&&a.length){const e="backward"===n,t={pages:a,pageParams:i},s=(e?ce:oe)(r,t);o=await u(t,s,e)}else{const t=e??a.length;do{const e=0===c?i[0]??r.initialPageParam:oe(r,o);if(c>0&&null==e)break;o=await u(o,e),c++}while(ct.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s):t.fetchFn=l}}}function oe(e,{pages:t,pageParams:s}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,s[r],s):void 0}function ce(e,{pages:t,pageParams:s}){return t.length>0?e.getPreviousPageParam?.(t[0],t,s[0],s):void 0}var le=class{#v;#f;#u;#_;#w;#E;#k;#S;constructor(e={}){this.#v=e.queryCache||new se,this.#f=e.mutationCache||new ne,this.#u=e.defaultOptions||{},this.#_=new Map,this.#w=new Map,this.#E=0}mount(){this.#E++,1===this.#E&&(this.#k=z.subscribe((async e=>{e&&(await this.resumePausedMutations(),this.#v.onFocus())})),this.#S=H.subscribe((async e=>{e&&(await this.resumePausedMutations(),this.#v.onOnline())})))}unmount(){this.#E--,0===this.#E&&(this.#k?.(),this.#k=void 0,this.#S?.(),this.#S=void 0)}isFetching(e){return this.#v.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#f.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#v.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),s=this.#v.build(this,t),r=s.state.data;return void 0===r?this.fetchQuery(e):(e.revalidateIfStale&&s.isStaleByTime(k(t.staleTime,s))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#v.findAll(e).map((({queryKey:e,state:t})=>[e,t.data]))}setQueryData(e,t,s){const r=this.defaultQueryOptions({queryKey:e}),n=this.#v.get(r.queryHash),a=n?.state.data,i=function(e,t){return"function"==typeof e?e(t):e}(t,a);if(void 0!==i)return this.#v.build(this,r).setData(i,{...s,manual:!0})}setQueriesData(e,t,s){return L.batch((()=>this.#v.findAll(e).map((({queryKey:e})=>[e,this.setQueryData(e,t,s)]))))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#v.get(t.queryHash)?.state}removeQueries(e){const t=this.#v;L.batch((()=>{t.findAll(e).forEach((e=>{t.remove(e)}))}))}resetQueries(e,t){const s=this.#v;return L.batch((()=>(s.findAll(e).forEach((e=>{e.reset()})),this.refetchQueries({type:"active",...e},t))))}cancelQueries(e,t={}){const s={revert:!0,...t},r=L.batch((()=>this.#v.findAll(e).map((e=>e.cancel(s)))));return Promise.all(r).then(_).catch(_)}invalidateQueries(e,t={}){return L.batch((()=>(this.#v.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 s={...t,cancelRefetch:t.cancelRefetch??!0},r=L.batch((()=>this.#v.findAll(e).filter((e=>!e.isDisabled())).map((e=>{let t=e.fetch(void 0,s);return s.throwOnError||(t=t.catch(_)),"paused"===e.state.fetchStatus?Promise.resolve():t}))));return Promise.all(r).then(_)}fetchQuery(e){const t=this.defaultQueryOptions(e);void 0===t.retry&&(t.retry=!1);const s=this.#v.build(this,t);return s.isStaleByTime(k(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(_).catch(_)}fetchInfiniteQuery(e){return e.behavior=ie(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(_).catch(_)}ensureInfiniteQueryData(e){return e.behavior=ie(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return H.isOnline()?this.#f.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#v}getMutationCache(){return this.#f}getDefaultOptions(){return this.#u}setDefaultOptions(e){this.#u=e}setQueryDefaults(e,t){this.#_.set(x(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#_.values()],s={};return t.forEach((t=>{P(e,t.queryKey)&&Object.assign(s,t.defaultOptions)})),s}setMutationDefaults(e,t){this.#w.set(x(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#w.values()],s={};return t.forEach((t=>{P(e,t.mutationKey)&&Object.assign(s,t.defaultOptions)})),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#u.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=R(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===U&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#u.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#v.clear(),this.#f.clear()}};let ue=null;var de=class extends ${constructor(e,t){super(),this.options=t,this.#c=e,this.#C=null,this.#O=G(),this.options.experimental_prefetchInRender||this.#O.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(t)}#c;#R=void 0;#x=void 0;#P=void 0;#q;#F;#O;#C;#D;#Q;#M;#T;#I;#A;#N=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#R.addObserver(this),he(this.#R,this.options)?this.#U():this.updateResult(),this.#j())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return pe(this.#R,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return pe(this.#R,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#B(),this.#K(),this.#R.removeObserver(this)}setOptions(e){const t=this.options,s=this.#R;if(this.options=this.#c.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof S(this.options.enabled,this.#R))throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#L(),this.#R.setOptions(this.options),t._defaulted&&!F(this.options,t)&&this.#c.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#R,observer:this});const r=this.hasListeners();r&&me(this.#R,s,this.options,t)&&this.#U(),this.updateResult(),!r||this.#R===s&&S(this.options.enabled,this.#R)===S(t.enabled,this.#R)&&k(this.options.staleTime,this.#R)===k(t.staleTime,this.#R)||this.#$();const n=this.#z();!r||this.#R===s&&S(this.options.enabled,this.#R)===S(t.enabled,this.#R)&&n===this.#A||this.#H(n)}getOptimisticResult(e){const t=this.#c.getQueryCache().build(this.#c,e),s=this.createResult(t,e);return r=s,!F(this.getCurrentResult(),r)&&(this.#P=s,this.#F=this.options,this.#q=this.#R.state),s;var r}getCurrentResult(){return this.#P}trackResult(e,t){return new Proxy(e,{get:(e,s)=>(this.trackProp(s),t?.(s),Reflect.get(e,s))})}trackProp(e){this.#N.add(e)}getCurrentQuery(){return this.#R}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#c.defaultQueryOptions(e),s=this.#c.getQueryCache().build(this.#c,t);return s.fetch().then((()=>this.createResult(s,t)))}fetch(e){return this.#U({...e,cancelRefetch:e.cancelRefetch??!0}).then((()=>(this.updateResult(),this.#P)))}#U(e){this.#L();let t=this.#R.fetch(this.options,e);return e?.throwOnError||(t=t.catch(_)),t}#$(){this.#B();const e=k(this.options.staleTime,this.#R);if(v||this.#P.isStale||!w(e))return;const t=E(this.#P.dataUpdatedAt,e)+1;this.#T=setTimeout((()=>{this.#P.isStale||this.updateResult()}),t)}#z(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#R):this.options.refetchInterval)??!1}#H(e){this.#K(),this.#A=e,!v&&!1!==S(this.options.enabled,this.#R)&&w(this.#A)&&0!==this.#A&&(this.#I=setInterval((()=>{(this.options.refetchIntervalInBackground||z.isFocused())&&this.#U()}),this.#A))}#j(){this.#$(),this.#H(this.#z())}#B(){this.#T&&(clearTimeout(this.#T),this.#T=void 0)}#K(){this.#I&&(clearInterval(this.#I),this.#I=void 0)}createResult(e,t){const s=this.#R,r=this.options,n=this.#P,a=this.#q,i=this.#F,o=e!==s?e.state:this.#x,{state:c}=e;let l,u={...c},d=!1;if(t._optimisticResults){const n=this.hasListeners(),a=!n&&he(e,t),i=n&&me(e,s,t,r);(a||i)&&(u={...u,...te(c.data,e.options)}),"isRestoring"===t._optimisticResults&&(u.fetchStatus="idle")}let{error:h,errorUpdatedAt:p,status:m}=u;l=u.data;let f=!1;if(void 0!==t.placeholderData&&void 0===l&&"pending"===m){let e;n?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(e=n.data,f=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#M?.state.data,this.#M):t.placeholderData,void 0!==e&&(m="success",l=T(n?.data,e,t),d=!0)}if(t.select&&void 0!==l&&!f)if(n&&l===a?.data&&t.select===this.#D)l=this.#Q;else try{this.#D=t.select,l=t.select(l),l=T(n?.data,l,t),this.#Q=l,this.#C=null}catch(e){this.#C=e}this.#C&&(h=this.#C,l=this.#Q,p=Date.now(),m="error");const g="fetching"===u.fetchStatus,b="pending"===m,y="error"===m,v=b&&g,_=void 0!==l,w={status:m,fetchStatus:u.fetchStatus,isPending:b,isSuccess:"success"===m,isError:y,isInitialLoading:v,isLoading:v,data:l,dataUpdatedAt:u.dataUpdatedAt,error:h,errorUpdatedAt:p,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>o.dataUpdateCount||u.errorUpdateCount>o.errorUpdateCount,isFetching:g,isRefetching:g&&!b,isLoadingError:y&&!_,isPaused:"paused"===u.fetchStatus,isPlaceholderData:d,isRefetchError:y&&_,isStale:fe(e,t),refetch:this.refetch,promise:this.#O};if(this.options.experimental_prefetchInRender){const t=e=>{"error"===w.status?e.reject(w.error):void 0!==w.data&&e.resolve(w.data)},r=()=>{const e=this.#O=w.promise=G();t(e)},n=this.#O;switch(n.status){case"pending":e.queryHash===s.queryHash&&t(n);break;case"fulfilled":"error"!==w.status&&w.data===n.value||r();break;case"rejected":"error"===w.status&&w.error===n.reason||r()}}return w}updateResult(){const e=this.#P,t=this.createResult(this.#R,this.options);this.#q=this.#R.state,this.#F=this.options,void 0!==this.#q.data&&(this.#M=this.#R),F(t,e)||(this.#P=t,this.#G({listeners:(()=>{if(!e)return!0;const{notifyOnChangeProps:t}=this.options,s="function"==typeof t?t():t;if("all"===s||!s&&!this.#N.size)return!0;const r=new Set(s??this.#N);return this.options.throwOnError&&r.add("error"),Object.keys(this.#P).some((t=>{const s=t;return this.#P[s]!==e[s]&&r.has(s)}))})()}))}#L(){const e=this.#c.getQueryCache().build(this.#c,this.options);if(e===this.#R)return;const t=this.#R;this.#R=e,this.#x=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#j()}#G(e){L.batch((()=>{e.listeners&&this.listeners.forEach((e=>{e(this.#P)})),this.#c.getQueryCache().notify({query:this.#R,type:"observerResultsUpdated"})}))}};function he(e,t){return function(e,t){return!1!==S(t.enabled,e)&&void 0===e.state.data&&!("error"===e.state.status&&!1===t.retryOnMount)}(e,t)||void 0!==e.state.data&&pe(e,t,t.refetchOnMount)}function pe(e,t,s){if(!1!==S(t.enabled,e)){const r="function"==typeof s?s(e):s;return"always"===r||!1!==r&&fe(e,t)}return!1}function me(e,t,s,r){return(e!==t||!1===S(r.enabled,e))&&(!s.suspense||"error"!==e.state.status)&&fe(e,s)}function fe(e,t){return!1!==S(t.enabled,e)&&e.isStaleByTime(k(t.staleTime,e))}var ge=r.createContext(function(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}()),be=r.createContext(!1),ye=(be.Provider,(e,t,s)=>t.fetchOptimistic(e).catch((()=>{s.clearReset()})));function ve(e,t){return function(e,t,s){const n=f(s),a=r.useContext(be),i=r.useContext(ge),o=n.defaultQueryOptions(e);n.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._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)))})(o),((e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))})(o,i),(e=>{r.useEffect((()=>{e.clearReset()}),[e])})(i);const c=!n.getQueryCache().get(o.queryHash),[l]=r.useState((()=>new t(n,o))),u=l.getOptimisticResult(o),d=!a&&!1!==e.subscribed;if(r.useSyncExternalStore(r.useCallback((e=>{const t=d?l.subscribe(L.batchCalls(e)):_;return l.updateResult(),t}),[l,d]),(()=>l.getCurrentResult()),(()=>l.getCurrentResult())),r.useEffect((()=>{l.setOptions(o)}),[o,l]),((e,t)=>e?.suspense&&t.isPending)(o,u))throw ye(o,l,i);if((({result:e,errorResetBoundary:t,throwOnError:s,query:r,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(n&&void 0===e.data||B(s,[e.error,r])))({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:n.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw u.error;if(n.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!v&&((e,t)=>e.isLoading&&e.isFetching&&!t)(u,a)){const e=c?ye(o,l,i):n.getQueryCache().get(o.queryHash)?.promise;e?.catch(_).finally((()=>{l.updateResult()}))}return o.notifyOnChangeProps?u:l.trackResult(u)}(e,de,t)}var _e=class extends ${#c;#P=void 0;#V;#W;constructor(e,t){super(),this.#c=e,this.setOptions(t),this.bindMethods(),this.#Z()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const t=this.options;this.options=this.#c.defaultMutationOptions(e),F(this.options,t)||this.#c.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#V,observer:this}),t?.mutationKey&&this.options.mutationKey&&x(t.mutationKey)!==x(this.options.mutationKey)?this.reset():"pending"===this.#V?.state.status&&this.#V.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#V?.removeObserver(this)}onMutationUpdate(e){this.#Z(),this.#G(e)}getCurrentResult(){return this.#P}reset(){this.#V?.removeObserver(this),this.#V=void 0,this.#Z(),this.#G()}mutate(e,t){return this.#W=t,this.#V?.removeObserver(this),this.#V=this.#c.getMutationCache().build(this.#c,this.options),this.#V.addObserver(this),this.#V.execute(e)}#Z(){const e=this.#V?.state??{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0};this.#P={...e,isPending:"pending"===e.status,isSuccess:"success"===e.status,isError:"error"===e.status,isIdle:"idle"===e.status,mutate:this.mutate,reset:this.reset}}#G(e){L.batch((()=>{if(this.#W&&this.hasListeners()){const t=this.#P.variables,s=this.#P.context;"success"===e?.type?(this.#W.onSuccess?.(e.data,t,s),this.#W.onSettled?.(e.data,null,t,s)):"error"===e?.type&&(this.#W.onError?.(e.error,t,s),this.#W.onSettled?.(void 0,e.error,t,s))}this.listeners.forEach((e=>{e(this.#P)}))}))}};function we(e,t){const s=f(t),[n]=r.useState((()=>new _e(s,e)));r.useEffect((()=>{n.setOptions(e)}),[n,e]);const a=r.useSyncExternalStore(r.useCallback((e=>n.subscribe(L.batchCalls(e))),[n]),(()=>n.getCurrentResult()),(()=>n.getCurrentResult())),i=r.useCallback(((e,t)=>{n.mutate(e,t).catch(_)}),[n]);if(a.error&&B(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}const Ee="gb-submissions",ke="gb-forms";function Se(e,t){return`/wp/v2/gblocks-forms?${new URLSearchParams({per_page:String(t),page:String(e),status:"publish,draft,private",orderby:"modified",order:"desc",_fields:"id,title,status,modified_gmt,_gb_form_meta"}).toString()}`}function Ce(e,t,s){return`/generateblocks-pro/v1/admin/forms/${e}/submissions?${new URLSearchParams({page:String(t),per_page:String(s)}).toString()}`}const Oe=(0,n.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,n.createElement)(l.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 Re({form:e,onClose:t}){const[s,l]=(0,n.useState)(!1),[u,d]=(0,n.useState)(""),[h,p]=(0,n.useState)(1),m=e?.id,g=(0,o.decodeEntities)(e?.title?.rendered||(0,i.__)("(untitled)","generateblocks-pro")),{data:b,isLoading:v,isFetching:_,isPlaceholderData:w,error:E}=function(e,{page:t=1,perPage:s=25}={}){return ve({enabled:!!e,queryKey:[Ee,e,{page:t,perPage:s}],queryFn:async()=>{const r=await y()({path:Ce(e,t,s)});return{items:r.items||[],total:r.total||0,totalPages:r.totalPages||1,page:r.page||t,perPage:r.perPage||s,storageEnabled:!!r.storageEnabled,storageError:r.storageError||"",maxRecords:r.maxRecords||0,retentionDays:r.retentionDays||0}},placeholderData:I})}(m,{page:h,perPage:25}),k=function(){const e=f();return we({mutationFn:async({formId:e,submissionId:t})=>y()({path:`/generateblocks-pro/v1/admin/forms/${e}/submissions/${t}`,method:"DELETE"}),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:[Ee,s.formId]}),e.invalidateQueries({queryKey:[ke]})}})}(),S=function(){const e=f();return we({mutationFn:async e=>y()({path:`/generateblocks-pro/v1/admin/forms/${e}/submissions`,method:"DELETE"}),onSuccess:(t,s)=>{e.invalidateQueries({queryKey:[Ee,s]}),e.invalidateQueries({queryKey:[ke]})}})}(),C=function(){const e=f();return we({mutationFn:async({id:e,enabled:t})=>y()({path:`/generateblocks-pro/v1/admin/forms/${e}/storage`,method:"POST",data:{enabled:t}}),onSuccess:()=>{e.invalidateQueries({queryKey:[ke]}),e.invalidateQueries({queryKey:[Ee]})}})}(),O=b?.items||[],R=b?.total||0,x=b?.page||h,P=b?.totalPages||1,q=b?.maxRecords||0,F=b?.retentionDays||0,D=function({data:e,isLoading:t,items:s,total:r}){const n=!!e&&!t,a=!!e?.storageEnabled,i=(Number(r)||0)>0||Array.isArray(s)&&s.length>0,o=n&&!a;return{storageEnabled:a,isStorageOff:o,hasStoredSubmissions:i,showStorageOffPanel:o,showSubmissionsBody:!o||i}}({data:b,isLoading:v,items:O,total:R}),{storageEnabled:Q}=D,M=e?._gb_form_meta?.health||{},T="failing"===M.status,A=M.last_failure_gmt?(0,c.dateI18n)((0,i.__)("M j, Y @ g:i a","generateblocks-pro"),M.last_failure_gmt+"Z"):"",N=M.last_error_code||"",U=F?(0,i.sprintf)(/* translators: %d: number of days stored submissions are retained */ /* translators: %d: number of days stored submissions are retained */ (0,i._n)("%d day","%d days",F,"generateblocks-pro"),F):"",j=(0,i.sprintf)(/* translators: %s: form name */ /* translators: %s: form name */ (0,i.__)("Submissions — %s","generateblocks-pro"),g),B=(0,n.useRef)(null),K=(0,n.useRef)(null);return(0,n.useEffect)((()=>(K.current="undefined"!=typeof document?document.activeElement:null,B.current&&"function"==typeof B.current.focus&&B.current.focus(),()=>{const e=K.current;e&&"function"==typeof e.focus&&document.contains(e)&&e.focus()})),[]),(0,n.useEffect)((()=>{p(1),l(!1),d("")}),[m]),(0,n.useEffect)((()=>{!w&&b?.page&&b.page!==h&&p(b.page)}),[b?.page,w,h]),(0,r.createElement)("aside",{className:"gb-forms-dashboard__drawer",role:"dialog","aria-modal":"false","aria-label":j,onKeyDown:function(e){"Escape"===e.key&&(e.preventDefault(),t())}},(0,r.createElement)("div",{className:"gb-forms-dashboard__drawer-header"},(0,r.createElement)("div",null,(0,r.createElement)("h2",{className:"gb-forms-dashboard__drawer-title"},(0,i.__)("Submissions","generateblocks-pro")),(0,r.createElement)("div",{className:"gb-forms-dashboard__drawer-subtitle"},g)),(0,r.createElement)("button",{ref:B,type:"button",className:"gb-forms-dashboard__drawer-close",onClick:t,"aria-label":(0,i.__)("Close","generateblocks-pro")},(0,r.createElement)(a.Icon,{icon:Oe,size:16}))),(0,r.createElement)("div",{className:"gb-forms-dashboard__drawer-body"},Q&&(0,r.createElement)("p",{className:"gb-forms-dashboard__drawer-help"},q&&U?(0,i.sprintf)(/* translators: 1: maximum number of stored submissions, 2: retention period such as "30 days" */ /* translators: 1: maximum number of stored submissions, 2: retention period such as "30 days" */ (0,i.__)("Stores up to %1$d submissions per form. Submissions older than %2$s are automatically removed.","generateblocks-pro"),q,U):(0,i.__)("Recent submissions stored for this form. Successful and failed delivery attempts appear here while the form keeps submission storage enabled.","generateblocks-pro")),u&&(0,r.createElement)(a.Notice,{status:"error",isDismissible:!0,onRemove:()=>d("")},u),E&&(0,r.createElement)(a.Notice,{status:"error",isDismissible:!1},(0,i.__)("Failed to load submissions.","generateblocks-pro")),T&&(0,r.createElement)(a.Notice,{status:"warning",isDismissible:!1},A?(0,i.sprintf)(/* translators: %s: failure date */ /* translators: %s: failure date */ (0,i.__)("Last delivery failed %s.","generateblocks-pro"),A):(0,i.__)("Recent deliveries have been failing.","generateblocks-pro"),N?" "+(0,i.sprintf)(/* translators: %s: non-PII error code */ /* translators: %s: non-PII error code */ (0,i.__)("Error code: %s.","generateblocks-pro"),N):""),b?.storageError&&(0,r.createElement)(a.Notice,{status:"warning",isDismissible:!1},b.storageError),D.showStorageOffPanel&&(0,r.createElement)(qe,{failing:T,hasStoredSubmissions:D.hasStoredSubmissions,isEnabling:C.isPending||_,onEnable:async function(){d("");try{await C.mutateAsync({id:m,enabled:!0})}catch(e){d(e?.message||(0,i.__)("Could not enable storage. Try again.","generateblocks-pro"))}}}),D.showSubmissionsBody?function({isLoading:e,isFetching:t,items:s,total:n,currentPage:o,totalPages:c,onPageChange:l,onClearAll:u,onDeleteRow:d}){return e?(0,r.createElement)(a.Spinner,null):0===s.length?(0,r.createElement)("p",{className:"gb-forms-dashboard__drawer-empty"},(0,i.__)("No stored submissions for this form.","generateblocks-pro")):(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"gb-forms-dashboard__drawer-actions"},(0,r.createElement)(a.Button,{variant:"secondary",isDestructive:!0,onClick:u},(0,i.__)("Clear all","generateblocks-pro"))),(0,r.createElement)(xe,{currentPage:o,totalPages:c,total:n,isFetching:t,onPageChange:l}),(0,r.createElement)("ul",{className:"gb-forms-dashboard__drawer-list"},s.map((e=>(0,r.createElement)(Pe,{key:e.id,item:e,onDelete:()=>d(e)})))),(0,r.createElement)(xe,{currentPage:o,totalPages:c,total:n,isFetching:t,onPageChange:l}))}({isLoading:v,isFetching:_,items:O,total:R,currentPage:x,totalPages:P,onPageChange:p,onClearAll:()=>{l(!0),d("")},onDeleteRow:async e=>{d("");try{await k.mutateAsync({formId:m,submissionId:e.id})}catch(e){d(e?.message||(0,i.__)("Could not delete record. Try again.","generateblocks-pro"))}}}):null),s&&(0,r.createElement)("div",{className:"gb-forms-dashboard__drawer-confirm"},(0,r.createElement)("p",null,(0,i.sprintf)(/* translators: %d: number of records that will be cleared */ /* translators: %d: number of records that will be cleared */ (0,i.__)("Permanently clear all %d stored submissions for this form?","generateblocks-pro"),R)),(0,r.createElement)("div",{className:"gb-forms-dashboard__drawer-confirm-actions"},(0,r.createElement)(a.Button,{variant:"primary",isDestructive:!0,isBusy:S.isPending,onClick:async()=>{d("");try{await S.mutateAsync(m),p(1),l(!1)}catch(e){d(e?.message||(0,i.__)("Could not clear records. Try again.","generateblocks-pro")),l(!1)}}},(0,i.__)("I'm sure","generateblocks-pro")),(0,r.createElement)(a.Button,{variant:"tertiary",onClick:()=>l(!1)},(0,i.__)("Cancel","generateblocks-pro")))))}function xe({currentPage:e,totalPages:t,total:s,isFetching:n,onPageChange:o}){return t<=1?null:(0,r.createElement)("div",{className:"gb-forms-dashboard__drawer-pagination"},(0,r.createElement)(a.Button,{variant:"secondary",disabled:e<=1||n,onClick:()=>o(e-1)},(0,i.__)("Previous","generateblocks-pro")),(0,r.createElement)("span",null,(0,i.sprintf)(/* translators: 1: current page, 2: total pages, 3: total submissions */ /* translators: 1: current page, 2: total pages, 3: total submissions */ (0,i.__)("Page %1$d of %2$d (%3$d total)","generateblocks-pro"),e,t,s)),(0,r.createElement)(a.Button,{variant:"secondary",disabled:e>=t||n,onClick:()=>o(e+1)},(0,i.__)("Next","generateblocks-pro")))}function Pe({item:e,onDelete:t}){const[s,o]=(0,n.useState)(!1),l=e.submittedAtGmt,u=l?(0,c.dateI18n)((0,i.__)("M j, Y @ g:i a","generateblocks-pro"),l+"Z"):"",d=function(e){switch(e){case"processed":return(0,i.__)("Processed","generateblocks-pro");case"failed":return(0,i.__)("Failed","generateblocks-pro");default:return(0,i.__)("Received","generateblocks-pro")}}(e.status),h=e.errors?.[0]||"",p=e.fields||{},m=Object.values(p),f=m.find((e=>"email"===e?.type&&e?.value)),g=f?.value||m.find((e=>{var t;return e&&""!==(null!==(t=e.value)&&void 0!==t?t:"")}))?.value||"",b=String(g||""),y=b.length>50?b.slice(0,50)+"…":b;return(0,r.createElement)("li",{className:"gb-forms-dashboard__drawer-row"},(0,r.createElement)("div",{className:"gb-forms-dashboard__drawer-row-summary"},(0,r.createElement)("div",null,(0,r.createElement)("div",{className:"gb-forms-dashboard__drawer-row-date"},u),(0,r.createElement)("div",{className:`gb-forms-dashboard__drawer-row-status gb-forms-dashboard__drawer-row-status--${e.status}`},h?(0,i.sprintf)(/* translators: 1: submission status, 2: error message */ /* translators: 1: submission status, 2: error message */ (0,i.__)("%1$s: %2$s","generateblocks-pro"),d,h):d),y&&(0,r.createElement)("div",{className:"gb-forms-dashboard__drawer-row-preview"},y)),(0,r.createElement)("div",{className:"gb-forms-dashboard__drawer-row-actions"},(0,r.createElement)(a.Button,{variant:"link",onClick:()=>o((e=>!e))},s?(0,i.__)("Hide","generateblocks-pro"):(0,i.__)("View","generateblocks-pro")),(0,r.createElement)(a.Button,{variant:"link",isDestructive:!0,onClick:t},(0,i.__)("Delete","generateblocks-pro")))),s&&(0,r.createElement)("dl",{className:"gb-forms-dashboard__drawer-row-detail"},Object.entries(p).map((([e,t])=>{var s;return(0,r.createElement)("div",{key:e},(0,r.createElement)("dt",null,t?.label||e),(0,r.createElement)("dd",null,String(null!==(s=t?.value)&&void 0!==s?s:"")||(0,r.createElement)("em",null,(0,i.__)("(empty)","generateblocks-pro"))))})),(e.errors||[]).length>0&&(0,r.createElement)("div",null,(0,r.createElement)("dt",null,(0,i.__)("Errors","generateblocks-pro")),(0,r.createElement)("dd",null,(0,r.createElement)("ul",null,e.errors.map(((e,t)=>(0,r.createElement)("li",{key:t},e))))))))}function qe({failing:e,hasStoredSubmissions:t,isEnabling:s,onEnable:n}){let o=(0,i.__)("Submission storage is off for this form. Nothing is being recorded.","generateblocks-pro");return t?o=(0,i.__)("Submission storage is off for this form. Existing stored submissions are still available below, but new submissions will not be recorded until storage is turned back on.","generateblocks-pro"):e&&(o=(0,i.__)("Submission storage is off for this form, so the submitted data wasn’t kept and can’t be recovered.","generateblocks-pro")),(0,r.createElement)("div",{className:"gb-forms-dashboard__drawer-storage-off"},(0,r.createElement)("p",{className:"gb-forms-dashboard__drawer-empty"},o),(0,r.createElement)(a.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,i.__)("Store future submissions","generateblocks-pro"),help:(0,i.__)("Keep new submissions — including failed deliveries — in this dashboard as a recovery safety net. Submissions already lost can’t be recovered.","generateblocks-pro"),checked:!1,disabled:s,onChange:()=>n()}))}const Fe=(0,n.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,n.createElement)(l.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"})),De=(0,n.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,n.createElement)(l.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})),Qe=(0,n.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,n.createElement)(l.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"}));function Me({usageData:e,loading:t,error:s,emptyMessage:n,onRetry:o,formatUsageType:c}){const l=c||(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=e&&e.usage&&0d.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.__)("Only the most recent %1$d of %2$d eligible posts were scanned. Older content may still reference this item — verify before deleting.","generateblocks-pro"),d.scanned_posts,d.total_posts):(0,i.__)("Usage search was limited for performance. Older content may still reference this item — verify before deleting.","generateblocks-pro"))):(0,r.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,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"gb-modal-usage-summary"},(0,r.createElement)("p",{style:{fontSize:"14px",color:"#666",margin:"0"}},(0,i.__)("Found usage in","generateblocks-pro")," ",(0,r.createElement)("strong",null,e.total),e.has_more&&"+"," ",1===e.total?(0,i.__)("location","generateblocks-pro"):(0,i.__)("locations","generateblocks-pro"))),e.cached&&e.cached_at&&(0,r.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,r.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 s=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",s,"generateblocks-pro"),s)})(e.cached_at))),(0,r.createElement)(a.Button,{variant:"secondary",size:"compact",onClick:o,icon:Fe},(0,i.__)("Refresh","generateblocks-pro"))),h&&(0,r.createElement)("div",{style:{background:"#f0f6fc",border:"1px solid #0969da",padding:"12px",borderRadius:"4px",marginBottom:"16px"}},(0,r.createElement)("p",{style:{margin:"0",fontSize:"13px",color:"#0969da"}},(0,r.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))),p&&(0,r.createElement)("div",{style:{background:"#f0f6fc",border:"1px solid #0969da",padding:"12px",borderRadius:"4px",marginBottom:"16px"}},(0,r.createElement)("p",{style:{margin:"0",fontSize:"13px",color:"#0969da"}},(0,r.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,r.createElement)("div",{className:"gb-modal-usage-sections"},Object.entries(e.usage).map((([e,t])=>(0,r.createElement)("div",{key:e,className:"gb-modal-usage-section"},(0,r.createElement)("h4",{className:"gb-modal-usage-section-title"},t.label,(0,r.createElement)("span",{className:"gb-modal-usage-count"},"(",t.items.length,t.has_more&&"+",")")),(0,r.createElement)("div",{className:"gb-modal-usage-items"},t.items.map((e=>(0,r.createElement)("div",{key:`${e.type}-${e.id}`,className:"gb-modal-usage-item"},(0,r.createElement)("div",{className:"gb-modal-usage-item-main"},(0,r.createElement)("div",{className:"gb-modal-usage-item-title"},(0,r.createElement)("strong",null,e.title),e.status&&(e=>{const t={publish:(0,i.__)("Published","generateblocks-pro"),draft:(0,i.__)("Draft","generateblocks-pro"),private:(0,i.__)("Private","generateblocks-pro")},s={publish:{bg:"#d1fae5",color:"#065f46",border:"#a7f3d0"},draft:{bg:"#fef3c7",color:"#92400e",border:"#fcd34d"},private:{bg:"#e0e7ff",color:"#3730a3",border:"#c7d2fe"}},n=s[e]||s.draft;return(0,r.createElement)("span",{style:{background:n.bg,color:n.color,border:`1px solid ${n.border}`,padding:"2px 6px",borderRadius:"4px",fontSize:"11px",fontWeight:"500",textTransform:"uppercase"}},t[e]||e)})(e.status)),(0,r.createElement)("div",{className:"gb-modal-usage-item-meta"},(0,r.createElement)("span",{className:"gb-modal-usage-item-type"},e.type_label),(0,r.createElement)("span",{className:"gb-modal-usage-item-usage-type"},l(e.usage_type),e.block_count>1&&(0,r.createElement)("span",{style:{marginLeft:"5px",opacity:.7}},"(",e.block_count," ",(0,i.__)("blocks","generateblocks-pro"),")")))),(0,r.createElement)("div",{className:"gb-modal-usage-item-actions"},e.edit_url&&(0,r.createElement)(a.Button,{variant:"secondary",size:"compact",icon:De,href:e.edit_url,target:"_blank",iconSize:"14"},(0,i.__)("Edit","generateblocks-pro")),e.view_url&&(0,r.createElement)(a.Button,{variant:"tertiary",size:"compact",icon:Qe,href:e.view_url,target:"_blank",iconSize:"14"},(0,i.__)("View","generateblocks-pro"))))))))))))))}const Te=e=>({form_render_block:(0,i.__)("Form embed","generateblocks-pro")}[e]||e);function Ie({form:e,onClose:t}){const s=(0,o.decodeEntities)(function(e){return"string"==typeof e?e:e&&"object"==typeof e?"string"==typeof e.rendered?e.rendered:"string"==typeof e.raw?e.raw:"":""}(e?.title)||(0,i.__)("Untitled Form","generateblocks-pro")),{usageData:c,loading:l,error:u,reload:d}=function(e,t=50){const[s,r]=(0,n.useState)(null),[a,o]=(0,n.useState)(!0),[c,l]=(0,n.useState)(null),u=(0,n.useRef)(null),d=(0,n.useCallback)((async(s=!1)=>{u.current&&u.current.abort(),u.current=new AbortController;const n=u.current;try{o(!0),l(null);const a=e.includes("?")?"&":"?",c=s?"&refresh=true":"",u=await y()({path:`${e}${a}limit=${t}${c}`,signal:n.signal});if(!u.success)return void l(u.response||(0,i.__)("Failed to load usage data","generateblocks-pro"));const d=u.response.data||u.response;r(d)}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");l(t)}finally{o(!1)}}),[e,t]);return(0,n.useEffect)((()=>(d(!1),()=>{u.current&&u.current.abort()})),[d]),{usageData:s,loading:a,error:c,reload:(0,n.useCallback)((()=>{d(!0)}),[d])}}(`/generateblocks-pro/v1/admin/forms/${e.id}/usage`);return(0,r.createElement)(a.Modal,{title:s,onRequestClose:t,className:"gb-modal-form-usage",size:"medium"},(0,r.createElement)(Me,{usageData:c,loading:l,error:u,emptyMessage:(0,i.__)("This form is not currently embedded anywhere on your site.","generateblocks-pro"),onRetry:d,formatUsageType:Te}))}const Ae=window.wp.url;function Ne(e="",t={}){const s=`${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,s=t.indexOf("/wp-admin");return-1!==s?`${e}${t.substring(0,s)}/wp-admin/`:`${e}/wp-admin/`}().replace(/\/+$/,"/")}${e.replace(/^\/+/,"")}`;return t&&0!==Object.keys(t).length?(0,Ae.addQueryArgs)(s,t):s}function Ue({isModalMode:e=!1,onItemSelect:t=null,onCreateItem:s=null}){const[l,p]=(0,n.useState)(1),[m,g]=(0,n.useState)(null),[b,v]=(0,n.useState)(null),[_,w]=(0,n.useState)(null),[E,k]=(0,n.useState)(!1),[S,C]=(0,n.useState)(!1),[O,R]=(0,n.useState)(null),[x,P]=(0,n.useState)(null),[q,F]=(0,n.useState)(null),D=(0,n.useRef)(0),Q=(0,n.useRef)(null),{data:M,isLoading:T,error:A}=function({page:e=1,perPage:t=50}={}){return ve({queryKey:[ke,{page:e,perPage:t}],queryFn:async()=>{const s=await async function(e){const t={...e,parse:!1};try{return await y()(t)}catch(e){if(!await async function(e){if("rest_cookie_invalid_nonce"===e?.code)return!0;if(403!==e?.status||"function"!=typeof e.clone)return!1;try{const t=await e.clone().json();return"rest_cookie_invalid_nonce"===t?.code}catch{return!1}}(e))throw e;if(!await async function(){if(!y()?.nonceEndpoint||!y()?.nonceMiddleware||"undefined"==typeof window||"function"!=typeof window.fetch)return!1;let e,t;try{e=await window.fetch(y().nonceEndpoint,{credentials:"include"})}catch{return!1}if(!e?.ok||"function"!=typeof e.text)return!1;try{t=await e.text()}catch{return!1}return!!t&&(y().nonceMiddleware.nonce=t,"object"==typeof window.wpApiSettings&&window.wpApiSettings&&(window.wpApiSettings.nonce=t),!0)}())throw e;return y()(t)}}({path:Se(e,t)}),r=await s.json(),n=parseInt(s.headers.get("X-WP-TotalPages"),10)||1;return{forms:Array.isArray(r)?r:[],totalPages:n}},placeholderData:I})}({page:l}),N=function(){const e=f();return we({mutationFn:async e=>{const{id:t,force:s=!1}="object"==typeof e&&null!==e?e:{id:e},r=s?`/generateblocks-pro/v1/admin/forms/${t}?force=true`:`/generateblocks-pro/v1/admin/forms/${t}`;try{return await y()({path:r,method:"DELETE"})}catch(e){if(e&&"form_in_use"===e.code){const t=new Error(e.message);throw t.code="form_in_use",t.usage=e.data?.usage||null,t}throw e}},onSuccess:()=>{e.invalidateQueries({queryKey:[ke]})}})}(),U=function(){const e=f();return we({mutationFn:async({id:e,status:t})=>y()({path:`/wp/v2/gblocks-forms/${e}`,method:"POST",data:{status:t}}),onSuccess:()=>{e.invalidateQueries({queryKey:[ke]})}})}(),j=function(){const e=f();return we({mutationFn:async e=>y()({path:`/generateblocks-pro/v1/admin/forms/${e}/duplicate`,method:"POST"}),onSuccess:()=>{e.invalidateQueries({queryKey:[ke]})}})}(),B=M?.forms||[],K=M?.totalPages||1,L=()=>{Q.current&&(Q.current.abort(),Q.current=null),D.current++,g(null),v(null),w(null),k(!1),R(null)},$=(0,n.useMemo)((()=>{const s=[];return s.push({id:"name",header:(0,i.__)("Form","generateblocks-pro"),cell:s=>{const n=s.row.original,c=(0,o.decodeEntities)(n?.title?.rendered||(0,i.__)("(untitled)","generateblocks-pro")),l="draft"===n?.status,u=e&&t?(0,r.createElement)(a.Button,{variant:"link",onClick:()=>t(n),style:{padding:0,minHeight:"auto",textDecoration:"none"}},c):(0,r.createElement)("a",{href:Ne("post.php",{post:n.id,action:"edit"})},c);return(0,r.createElement)("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},u,l&&(0,r.createElement)("span",{style:{color:"#999",fontSize:"0.9em"}},"(",(0,i.__)("draft","generateblocks-pro"),")"))}}),e||s.push({id:"submissions",header:(0,i.__)("Submissions","generateblocks-pro"),cell:e=>{var t,s;const n=e.row.original,o=n?._gb_form_meta||{},c=null!==(t=o.submission_count)&&void 0!==t?t:0,l=null!==(s=o.failed_submission_count)&&void 0!==s?s:0,d=!!o.storage_enabled;if("failing"===o.health?.status||l>0){const e=l>0?(0,i.sprintf)(/* translators: %d: number of failed submissions */ /* translators: %d: number of failed submissions */ (0,i._n)("%d failed","%d failed",l,"generateblocks-pro"),l):(0,i.__)("Delivery failing","generateblocks-pro"),t=l>0?(0,i.sprintf)(/* translators: %d: number of failed submissions */ /* translators: %d: number of failed submissions */ (0,i._n)("View %d failed submission","View %d failed submissions",l,"generateblocks-pro"),l):(0,i.__)("A delivery failed. Open for details.","generateblocks-pro");return(0,r.createElement)(a.Button,{className:"gb-form-submissions-pill gb-form-submissions-pill--failure",onClick:()=>F(n),label:t,showTooltip:!0},(0,r.createElement)(a.Icon,{icon:u,size:16}),e)}if(c>0){const e=(0,i.sprintf)(/* translators: %d: number of stored submissions */ /* translators: %d: number of stored submissions */ (0,i._n)("View %d stored submission","View %d stored submissions",c,"generateblocks-pro"),c);return(0,r.createElement)(a.Button,{className:"gb-form-submissions-pill gb-form-submissions-pill--ok",onClick:()=>F(n),label:e,showTooltip:!0},(0,i.sprintf)(/* translators: %d: number of stored submissions */ /* translators: %d: number of stored submissions */ (0,i._n)("%d submission","%d submissions",c,"generateblocks-pro"),c))}return d?(0,r.createElement)(a.Button,{className:"gb-form-submissions-pill gb-form-submissions-pill--ok",onClick:()=>F(n),label:(0,i.__)("View stored submissions","generateblocks-pro"),showTooltip:!0},(0,i.__)("No submissions yet","generateblocks-pro")):(0,r.createElement)(a.Button,{className:"gb-form-submissions-pill gb-form-submissions-pill--off",onClick:()=>F(n),label:(0,i.__)("Submission storage is off. Open to enable.","generateblocks-pro"),showTooltip:!0},(0,i.__)("Storage off","generateblocks-pro"))}}),s.push({id:"modified",header:(0,i.__)("Modified","generateblocks-pro"),cell:e=>{const t=e.row.original.modified_gmt;return t?(0,c.dateI18n)((0,i.__)("M j, Y @ g:i a","generateblocks-pro"),t+"Z"):""}}),e&&t?(s.push({id:"actions",header:null,cell:e=>(0,r.createElement)(a.Button,{variant:"link",onClick:()=>t(e.row.original)},(0,i.__)("Edit","generateblocks-pro"))}),s):(s.push({id:"actions",header:null,cell:e=>{const t=e.row.original,{id:s,status:n}=t;return(0,r.createElement)(a.DropdownMenu,{icon:d,label:(0,i.__)("More options","generateblocks-pro")},(({onClose:e})=>(0,r.createElement)(r.Fragment,null,(0,r.createElement)(a.MenuGroup,null,(0,r.createElement)(a.MenuItem,{href:Ne("post.php",{post:s,action:"edit"})},(0,i.__)("Edit Form","generateblocks-pro")),(0,r.createElement)(a.MenuItem,{onClick:()=>{j.mutateAsync(s).catch((()=>{})),e()}},(0,i.__)("Duplicate","generateblocks-pro"))),(0,r.createElement)(a.MenuGroup,null,(0,r.createElement)(a.MenuItem,{onClick:()=>{P(t),e()}},(0,i.__)("Check Usage","generateblocks-pro"))),(0,r.createElement)(a.MenuGroup,null,(0,r.createElement)(a.MenuItem,{onClick:()=>{const t="publish"===n?"draft":"publish";U.mutateAsync({id:s,status:t}).catch((()=>{})),e()}},"publish"===n?(0,i.__)("Set as Draft","generateblocks-pro"):(0,i.__)("Publish","generateblocks-pro")),(0,r.createElement)(a.MenuItem,{isDestructive:!0,onClick:()=>{(e=>{g(e),v(null),w(null),k(!1),R(null),(async e=>{Q.current&&Q.current.abort();const t=++D.current,s=new AbortController;Q.current=s,C(!0),k(!1);try{const r=await y()({path:`/generateblocks-pro/v1/admin/forms/${e}/usage?refresh=true`,signal:s.signal});if(t!==D.current)return;r?.success?w(r.response):k(!0)}catch(e){if("AbortError"===e?.name)return;if(t!==D.current)return;k(!0)}finally{t===D.current&&C(!1)}})(e.id)})(t),e()}},(0,i.__)("Delete Form","generateblocks-pro"))))))}}),s)}),[e,t,j,U,F]);return T?(0,r.createElement)("div",{className:"gb-dashboard-admin"},(0,r.createElement)(a.Spinner,null)):(0,r.createElement)("div",{className:"gb-dashboard-admin gb-forms-dashboard"},(0,r.createElement)("div",{className:"gb-dashboard-admin__header"},(0,r.createElement)(a.Button,{variant:"primary",onClick:()=>{e&&s?s():window.location.href=Ne("post-new.php",{post_type:"gblocks_form"})}},(0,i.__)("Add New","generateblocks-pro"))),A&&(0,r.createElement)(a.Notice,{status:"error",isDismissible:!1},(0,i.__)("Failed to load forms.","generateblocks-pro")),(0,r.createElement)("div",{className:"gb-dashboard-admin__inner"},0===B.length?(0,r.createElement)("div",{className:"gb-forms-dashboard__empty"},(0,r.createElement)("p",null,(0,r.createElement)("strong",null,(0,i.__)("No forms yet.","generateblocks-pro"))),(0,r.createElement)("p",null,(0,i.__)("Add a Form block to a page to create your first one, or click Add New above.","generateblocks-pro"))):(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"gb-dashboard-table-wrapper"},(0,r.createElement)(h.Table,{className:"gb-dashboard-table table-view-list gb-forms-table",columns:$,data:B,"aria-label":(0,i.__)("Forms","generateblocks-pro")})),K>1&&(0,r.createElement)("div",{className:"gb-dashboard__pagination"},(0,r.createElement)(a.Button,{disabled:1===l,onClick:()=>p(l-1),variant:"secondary"},(0,i.__)("Previous","generateblocks-pro")),(0,r.createElement)("span",null,(0,i.sprintf)(/* translators: %1$s: current; %2$s: total */ /* translators: %1$s: current; %2$s: total */ (0,i.__)("Page %1$s of %2$s","generateblocks-pro"),l,K)),(0,r.createElement)(a.Button,{disabled:l>=K,onClick:()=>p(l+1),variant:"secondary"},(0,i.__)("Next","generateblocks-pro"))))),q&&!e&&(0,r.createElement)(Re,{form:q,onClose:()=>F(null)}),!!m&&(0,r.createElement)(a.Modal,{title:(0,i.__)("Confirm Delete","generateblocks-pro"),onRequestClose:L,className:"gb-styles-table-modal",size:"small",focusOnMount:"firstContentElement"},(()=>{const e=O||_,t=!!e&&e.total>0,s=e?.limited||!!e?.limitations?.recent_post_scan,n=!!e?.has_more,c=O||t||E||s||n?(0,i.__)("Delete anyway","generateblocks-pro"):(0,i.__)("I'm sure","generateblocks-pro"),l=!!O||t;return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"gb-styles-table-modal__content"},S&&(0,r.createElement)("p",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"16px"}},(0,r.createElement)(a.Spinner,null),(0,i.__)("Checking usage…","generateblocks-pro")),!S&&t&&(0,r.createElement)("div",{style:{background:"#fee",border:"1px solid #dc3232",padding:"12px",borderRadius:"4px",marginBottom:"16px"}},(0,r.createElement)("p",{style:{margin:"0 0 8px 0"}},(0,r.createElement)("strong",null,(0,i.__)("Warning:","generateblocks-pro"))," ",e.has_more?(0,i.sprintf)(/* translators: %s: number of locations where the form is used */ /* translators: %s: number of locations where the form is used */ (0,i.__)("This form is currently embedded in at least %s locations:","generateblocks-pro"),e.total):(0,i.sprintf)(/* translators: %s: number of locations where the form is used */ /* translators: %s: number of locations where the form is used */ (0,i.__)("This form is currently embedded in %s locations:","generateblocks-pro"),e.total)),Object.entries(e.usage).slice(0,2).map((([e,t])=>(0,r.createElement)("div",{key:e,style:{marginTop:"8px"}},(0,r.createElement)("strong",null,t.label,":"),(0,r.createElement)("ul",{style:{margin:"4px 0 0 20px",padding:0}},t.items.slice(0,3).map((e=>(0,r.createElement)("li",{key:e.id},e.title))),t.items.length>3&&(0,r.createElement)("li",null,(0,i.sprintf)(/* translators: %s: number of additional items */ /* translators: %s: number of additional items */ (0,i.__)("…and %s more","generateblocks-pro"),t.items.length-3)))))),(0,r.createElement)("p",{style:{margin:"8px 0 0 0",fontSize:"13px"}},(0,i.__)("Deleting this form removes the submission UI — pages that embed it will render nothing on the frontend until the embed is removed.","generateblocks-pro"))),!S&&!t&&s&&(0,r.createElement)("div",{style:{background:"#fff8e1",border:"1px solid #f0b849",padding:"12px",borderRadius:"4px",marginBottom:"16px"}},(0,r.createElement)("p",{style:{margin:0,fontSize:"13px"}},(0,r.createElement)("strong",null,(0,i.__)("Heads up:","generateblocks-pro"))," ",(0,i.__)("Usage search was limited for performance and may not have checked every post. This form may still be embedded in older content.","generateblocks-pro"))),!S&&!t&&!s&&n&&(0,r.createElement)("div",{style:{background:"#fff8e1",border:"1px solid #f0b849",padding:"12px",borderRadius:"4px",marginBottom:"16px"}},(0,r.createElement)("p",{style:{margin:0,fontSize:"13px"}},(0,r.createElement)("strong",null,(0,i.__)("Heads up:","generateblocks-pro"))," ",(0,i.__)("Additional usage may exist beyond what was returned. Proceed with caution.","generateblocks-pro"))),!S&&E&&(0,r.createElement)("div",{style:{background:"#fff8e1",border:"1px solid #f0b849",padding:"12px",borderRadius:"4px",marginBottom:"16px"}},(0,r.createElement)("p",{style:{margin:0,fontSize:"13px"}},(0,r.createElement)("strong",null,(0,i.__)("Heads up:","generateblocks-pro"))," ",(0,i.__)("Could not verify whether this form is in use. Deletion will still be checked server-side before it is removed.","generateblocks-pro"))),(0,r.createElement)("p",null,(0,i.sprintf)(/* translators: %s: form title being deleted */ /* translators: %s: form title being deleted */ (0,i.__)("Are you sure you want to delete %s?","generateblocks-pro"),`"${(0,o.decodeEntities)(m?.title?.rendered||(0,i.__)("this form","generateblocks-pro"))}"`)),(0,r.createElement)("p",null,(0,i.__)("Any stored submissions attached to this form will also be removed.","generateblocks-pro")," ",(0,r.createElement)("strong",null,(0,i.__)("This cannot be undone","generateblocks-pro")),"."),!!b&&(0,r.createElement)("p",{style:{color:"#d63638"}},b)),(0,r.createElement)("div",{className:"gb-styles-table-modal__actions"},(0,r.createElement)(a.Button,{variant:"tertiary",onClick:L,disabled:N.isPending},(0,i.__)("Cancel","generateblocks-pro")),(0,r.createElement)(a.Button,{variant:"primary",isDestructive:!0,disabled:S||N.isPending,onClick:async()=>{v(null);try{await N.mutateAsync({id:m.id,force:l}),L()}catch(e){if(e&&"form_in_use"===e.code&&e.usage)return void R(e.usage);v(e?.message||(0,i.__)("Failed to delete form.","generateblocks-pro"))}}},c)))})()),!!x&&(0,r.createElement)(Ie,{form:x,onClose:()=>P(null)}))}function je(e){return(0,r.createElement)(g,{client:(ue||(ue=new le({defaultOptions:{queries:{staleTime:3e4,gcTime:3e5,retry:1,refetchOnWindowFocus:!0}}})),ue)},(0,r.createElement)(Ue,{...e}))}document.addEventListener("DOMContentLoaded",(()=>{const e=document.getElementById("gb-forms-dashboard");e&&function(e,t){void 0!==n.createRoot?(0,n.createRoot)(t).render(e):(0,n.render)(e,t)}((0,r.createElement)(je,null),e)}))})();