-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
1 lines (1 loc) · 62.2 KB
/
index.js
1
(()=>{"use strict";var e={338:(e,t,n)=>{var r=n(795);t.H=r.createRoot,r.hydrateRoot},20:(e,t,n)=>{var r=n(609),a=Symbol.for("react.element"),o=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var r,o={},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)s.call(t,r)&&!l.hasOwnProperty(r)&&(o[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===o[r]&&(o[r]=t[r]);return{$$typeof:a,type:e,key:c,ref:u,props:o,_owner:i.current}}t.Fragment=o,t.jsx=c,t.jsxs=c},848:(e,t,n)=>{e.exports=n(20)},609:e=>{e.exports=window.React},795:e=>{e.exports=window.ReactDOM}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}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),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};n.r(r),n.d(r,{hasBrowserEnv:()=>pe,hasStandardBrowserEnv:()=>fe,hasStandardBrowserWebWorkerEnv:()=>me,origin:()=>ge});var a=n(609),o=n(338);const s=window.wp.plugins,i=window.wp.editPost,l=window.wp.components;function c(e,t){return function(){return e.apply(t,arguments)}}const{toString:u}=Object.prototype,{getPrototypeOf:d}=Object,p=(f=Object.create(null),e=>{const t=u.call(e);return f[t]||(f[t]=t.slice(8,-1).toLowerCase())});var f;const h=e=>(e=e.toLowerCase(),t=>p(t)===e),m=e=>t=>typeof t===e,{isArray:g}=Array,y=m("undefined"),E=h("ArrayBuffer"),b=m("string"),w=m("function"),x=m("number"),S=e=>null!==e&&"object"==typeof e,v=e=>{if("object"!==p(e))return!1;const t=d(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},C=h("Date"),R=h("File"),O=h("Blob"),L=h("FileList"),T=h("URLSearchParams"),[_,j,A,k]=["ReadableStream","Request","Response","Headers"].map(h);function P(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,a;if("object"!=typeof e&&(e=[e]),g(e))for(r=0,a=e.length;r<a;r++)t.call(null,e[r],r,e);else{const a=n?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length;let s;for(r=0;r<o;r++)s=a[r],t.call(null,e[s],s,e)}}function N(e,t){t=t.toLowerCase();const n=Object.keys(e);let r,a=n.length;for(;a-- >0;)if(r=n[a],t===r.toLowerCase())return r;return null}const B="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,F=e=>!y(e)&&e!==B,D=(U="undefined"!=typeof Uint8Array&&d(Uint8Array),e=>U&&e instanceof U);var U;const I=h("HTMLFormElement"),M=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),q=h("RegExp"),H=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};P(n,((n,a)=>{let o;!1!==(o=t(n,a,e))&&(r[a]=o||n)})),Object.defineProperties(e,r)},z="abcdefghijklmnopqrstuvwxyz",$="0123456789",W={DIGIT:$,ALPHA:z,ALPHA_DIGIT:z+z.toUpperCase()+$},V=h("AsyncFunction"),J={isArray:g,isArrayBuffer:E,isBuffer:function(e){return null!==e&&!y(e)&&null!==e.constructor&&!y(e.constructor)&&w(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||w(e.append)&&("formdata"===(t=p(e))||"object"===t&&w(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&E(e.buffer),t},isString:b,isNumber:x,isBoolean:e=>!0===e||!1===e,isObject:S,isPlainObject:v,isReadableStream:_,isRequest:j,isResponse:A,isHeaders:k,isUndefined:y,isDate:C,isFile:R,isBlob:O,isRegExp:q,isFunction:w,isStream:e=>S(e)&&w(e.pipe),isURLSearchParams:T,isTypedArray:D,isFileList:L,forEach:P,merge:function e(){const{caseless:t}=F(this)&&this||{},n={},r=(r,a)=>{const o=t&&N(n,a)||a;v(n[o])&&v(r)?n[o]=e(n[o],r):v(r)?n[o]=e({},r):g(r)?n[o]=r.slice():n[o]=r};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&P(arguments[e],r);return n},extend:(e,t,n,{allOwnKeys:r}={})=>(P(t,((t,r)=>{n&&w(t)?e[r]=c(t,n):e[r]=t}),{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let a,o,s;const i={};if(t=t||{},null==e)return t;do{for(a=Object.getOwnPropertyNames(e),o=a.length;o-- >0;)s=a[o],r&&!r(s,e,t)||i[s]||(t[s]=e[s],i[s]=!0);e=!1!==n&&d(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:p,kindOfTest:h,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(g(e))return e;let t=e.length;if(!x(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:I,hasOwnProperty:M,hasOwnProp:M,reduceDescriptors:H,freezeMethods:e=>{H(e,((t,n)=>{if(w(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];w(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach((e=>{n[e]=!0}))};return g(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:N,global:B,isContextDefined:F,ALPHABET:W,generateString:(e=16,t=W.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n},isSpecCompliantForm:function(e){return!!(e&&w(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(S(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[r]=e;const a=g(e)?[]:{};return P(e,((e,t)=>{const o=n(e,r+1);!y(o)&&(a[t]=o)})),t[r]=void 0,a}}return e};return n(e,0)},isAsyncFn:V,isThenable:e=>e&&(S(e)||w(e))&&w(e.then)&&w(e.catch)};function K(e,t,n,r,a){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),a&&(this.response=a)}J.inherits(K,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:J.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const G=K.prototype,X={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{X[e]={value:e}})),Object.defineProperties(K,X),Object.defineProperty(G,"isAxiosError",{value:!0}),K.from=(e,t,n,r,a,o)=>{const s=Object.create(G);return J.toFlatObject(e,s,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),K.call(s,e.message,t,n,r,a),s.cause=e,s.name=e.name,o&&Object.assign(s,o),s};const Z=K;function Y(e){return J.isPlainObject(e)||J.isArray(e)}function Q(e){return J.endsWith(e,"[]")?e.slice(0,-2):e}function ee(e,t,n){return e?e.concat(t).map((function(e,t){return e=Q(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}const te=J.toFlatObject(J,{},null,(function(e){return/^is[A-Z]/.test(e)})),ne=function(e,t,n){if(!J.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=J.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!J.isUndefined(t[e])}))).metaTokens,a=n.visitor||c,o=n.dots,s=n.indexes,i=(n.Blob||"undefined"!=typeof Blob&&Blob)&&J.isSpecCompliantForm(t);if(!J.isFunction(a))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(J.isDate(e))return e.toISOString();if(!i&&J.isBlob(e))throw new Z("Blob is not supported. Use a Buffer instead.");return J.isArrayBuffer(e)||J.isTypedArray(e)?i&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function c(e,n,a){let i=e;if(e&&!a&&"object"==typeof e)if(J.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(J.isArray(e)&&function(e){return J.isArray(e)&&!e.some(Y)}(e)||(J.isFileList(e)||J.endsWith(n,"[]"))&&(i=J.toArray(e)))return n=Q(n),i.forEach((function(e,r){!J.isUndefined(e)&&null!==e&&t.append(!0===s?ee([n],r,o):null===s?n:n+"[]",l(e))})),!1;return!!Y(e)||(t.append(ee(a,n,o),l(e)),!1)}const u=[],d=Object.assign(te,{defaultVisitor:c,convertValue:l,isVisitable:Y});if(!J.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!J.isUndefined(n)){if(-1!==u.indexOf(n))throw Error("Circular reference detected in "+r.join("."));u.push(n),J.forEach(n,(function(n,o){!0===(!(J.isUndefined(n)||null===n)&&a.call(t,n,J.isString(o)?o.trim():o,r,d))&&e(n,r?r.concat(o):[o])})),u.pop()}}(e),t};function re(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function ae(e,t){this._pairs=[],e&&ne(e,this,t)}const oe=ae.prototype;oe.append=function(e,t){this._pairs.push([e,t])},oe.toString=function(e){const t=e?function(t){return e.call(this,t,re)}:re;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};const se=ae;function ie(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function le(e,t,n){if(!t)return e;const r=n&&n.encode||ie,a=n&&n.serialize;let o;if(o=a?a(t,n):J.isURLSearchParams(t)?t.toString():new se(t,n).toString(r),o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}const ce=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){J.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},ue={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},de={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:se,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},pe="undefined"!=typeof window&&"undefined"!=typeof document,fe=(he="undefined"!=typeof navigator&&navigator.product,pe&&["ReactNative","NativeScript","NS"].indexOf(he)<0);var he;const me="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,ge=pe&&window.location.href||"http://localhost",ye={...r,...de},Ee=function(e){function t(e,n,r,a){let o=e[a++];if("__proto__"===o)return!0;const s=Number.isFinite(+o),i=a>=e.length;return o=!o&&J.isArray(r)?r.length:o,i?(J.hasOwnProp(r,o)?r[o]=[r[o],n]:r[o]=n,!s):(r[o]&&J.isObject(r[o])||(r[o]=[]),t(e,n,r[o],a)&&J.isArray(r[o])&&(r[o]=function(e){const t={},n=Object.keys(e);let r;const a=n.length;let o;for(r=0;r<a;r++)o=n[r],t[o]=e[o];return t}(r[o])),!s)}if(J.isFormData(e)&&J.isFunction(e.entries)){const n={};return J.forEachEntry(e,((e,r)=>{t(function(e){return J.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),r,n,0)})),n}return null},be={transitional:ue,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,a=J.isObject(e);if(a&&J.isHTMLForm(e)&&(e=new FormData(e)),J.isFormData(e))return r?JSON.stringify(Ee(e)):e;if(J.isArrayBuffer(e)||J.isBuffer(e)||J.isStream(e)||J.isFile(e)||J.isBlob(e)||J.isReadableStream(e))return e;if(J.isArrayBufferView(e))return e.buffer;if(J.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return ne(e,new ye.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return ye.isNode&&J.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((o=J.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return ne(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return a||r?(t.setContentType("application/json",!1),function(e,t,n){if(J.isString(e))try{return(0,JSON.parse)(e),J.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||be.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(J.isResponse(e)||J.isReadableStream(e))return e;if(e&&J.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw Z.from(e,Z.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ye.classes.FormData,Blob:ye.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};J.forEach(["delete","get","head","post","put","patch"],(e=>{be.headers[e]={}}));const we=be,xe=J.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Se=Symbol("internals");function ve(e){return e&&String(e).trim().toLowerCase()}function Ce(e){return!1===e||null==e?e:J.isArray(e)?e.map(Ce):String(e)}function Re(e,t,n,r,a){return J.isFunction(r)?r.call(this,t,n):(a&&(t=n),J.isString(t)?J.isString(r)?-1!==t.indexOf(r):J.isRegExp(r)?r.test(t):void 0:void 0)}class Oe{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function a(e,t,n){const a=ve(t);if(!a)throw new Error("header name must be a non-empty string");const o=J.findKey(r,a);(!o||void 0===r[o]||!0===n||void 0===n&&!1!==r[o])&&(r[o||t]=Ce(e))}const o=(e,t)=>J.forEach(e,((e,n)=>a(e,n,t)));if(J.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(J.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o((e=>{const t={};let n,r,a;return e&&e.split("\n").forEach((function(e){a=e.indexOf(":"),n=e.substring(0,a).trim().toLowerCase(),r=e.substring(a+1).trim(),!n||t[n]&&xe[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)})),t})(e),t);else if(J.isHeaders(e))for(const[t,r]of e.entries())a(r,t,n);else null!=e&&a(t,e,n);return this}get(e,t){if(e=ve(e)){const n=J.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(J.isFunction(t))return t.call(this,e,n);if(J.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=ve(e)){const n=J.findKey(this,e);return!(!n||void 0===this[n]||t&&!Re(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function a(e){if(e=ve(e)){const a=J.findKey(n,e);!a||t&&!Re(0,n[a],a,t)||(delete n[a],r=!0)}}return J.isArray(e)?e.forEach(a):a(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const a=t[n];e&&!Re(0,this[a],a,e,!0)||(delete this[a],r=!0)}return r}normalize(e){const t=this,n={};return J.forEach(this,((r,a)=>{const o=J.findKey(n,a);if(o)return t[o]=Ce(r),void delete t[a];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,n)=>t.toUpperCase()+n))}(a):String(a).trim();s!==a&&delete t[a],t[s]=Ce(r),n[s]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return J.forEach(this,((n,r)=>{null!=n&&!1!==n&&(t[r]=e&&J.isArray(n)?n.join(", "):n)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach((e=>n.set(e))),n}static accessor(e){const t=(this[Se]=this[Se]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=ve(e);t[r]||(function(e,t){const n=J.toCamelCase(" "+t);["get","set","has"].forEach((r=>{Object.defineProperty(e,r+n,{value:function(e,n,a){return this[r].call(this,t,e,n,a)},configurable:!0})}))}(n,e),t[r]=!0)}return J.isArray(e)?e.forEach(r):r(e),this}}Oe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),J.reduceDescriptors(Oe.prototype,(({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}})),J.freezeMethods(Oe);const Le=Oe;function Te(e,t){const n=this||we,r=t||n,a=Le.from(r.headers);let o=r.data;return J.forEach(e,(function(e){o=e.call(n,o,a.normalize(),t?t.status:void 0)})),a.normalize(),o}function _e(e){return!(!e||!e.__CANCEL__)}function je(e,t,n){Z.call(this,null==e?"canceled":e,Z.ERR_CANCELED,t,n),this.name="CanceledError"}J.inherits(je,Z,{__CANCEL__:!0});const Ae=je;function ke(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new Z("Request failed with status code "+n.status,[Z.ERR_BAD_REQUEST,Z.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}const Pe=(e,t,n=3)=>{let r=0;const a=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let a,o=0,s=0;return t=void 0!==t?t:1e3,function(i){const l=Date.now(),c=r[s];a||(a=l),n[o]=i,r[o]=l;let u=s,d=0;for(;u!==o;)d+=n[u++],u%=e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),l-a<t)return;const p=c&&l-c;return p?Math.round(1e3*d/p):void 0}}(50,250);return function(e,t){let n=0;const r=1e3/t;let a=null;return function(){const t=!0===this,o=Date.now();if(t||o-n>r)return a&&(clearTimeout(a),a=null),n=o,e.apply(null,arguments);a||(a=setTimeout((()=>(a=null,n=Date.now(),e.apply(null,arguments))),r-(o-n)))}}((n=>{const o=n.loaded,s=n.lengthComputable?n.total:void 0,i=o-r,l=a(i);r=o;const c={loaded:o,total:s,progress:s?o/s:void 0,bytes:i,rate:l||void 0,estimated:l&&s&&o<=s?(s-o)/l:void 0,event:n,lengthComputable:null!=s};c[t?"download":"upload"]=!0,e(c)}),n)},Ne=ye.hasStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let n;function r(n){let r=n;return e&&(t.setAttribute("href",r),r=t.href),t.setAttribute("href",r),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return n=r(window.location.href),function(e){const t=J.isString(e)?r(e):e;return t.protocol===n.protocol&&t.host===n.host}}():function(){return!0},Be=ye.hasStandardBrowserEnv?{write(e,t,n,r,a,o){const s=[e+"="+encodeURIComponent(t)];J.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),J.isString(r)&&s.push("path="+r),J.isString(a)&&s.push("domain="+a),!0===o&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Fe(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const De=e=>e instanceof Le?{...e}:e;function Ue(e,t){t=t||{};const n={};function r(e,t,n){return J.isPlainObject(e)&&J.isPlainObject(t)?J.merge.call({caseless:n},e,t):J.isPlainObject(t)?J.merge({},t):J.isArray(t)?t.slice():t}function a(e,t,n){return J.isUndefined(t)?J.isUndefined(e)?void 0:r(void 0,e,n):r(e,t,n)}function o(e,t){if(!J.isUndefined(t))return r(void 0,t)}function s(e,t){return J.isUndefined(t)?J.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function i(n,a,o){return o in t?r(n,a):o in e?r(void 0,n):void 0}const l={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:i,headers:(e,t)=>a(De(e),De(t),!0)};return J.forEach(Object.keys(Object.assign({},e,t)),(function(r){const o=l[r]||a,s=o(e[r],t[r],r);J.isUndefined(s)&&o!==i||(n[r]=s)})),n}const Ie=e=>{const t=Ue({},e);let n,{data:r,withXSRFToken:a,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:l}=t;if(t.headers=i=Le.from(i),t.url=le(Fe(t.baseURL,t.url),e.params,e.paramsSerializer),l&&i.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),J.isFormData(r))if(ye.hasStandardBrowserEnv||ye.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(!1!==(n=i.getContentType())){const[e,...t]=n?n.split(";").map((e=>e.trim())).filter(Boolean):[];i.setContentType([e||"multipart/form-data",...t].join("; "))}if(ye.hasStandardBrowserEnv&&(a&&J.isFunction(a)&&(a=a(t)),a||!1!==a&&Ne(t.url))){const e=o&&s&&Be.read(s);e&&i.set(o,e)}return t},Me="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){const r=Ie(e);let a=r.data;const o=Le.from(r.headers).normalize();let s,{responseType:i}=r;function l(){r.cancelToken&&r.cancelToken.unsubscribe(s),r.signal&&r.signal.removeEventListener("abort",s)}let c=new XMLHttpRequest;function u(){if(!c)return;const r=Le.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders());ke((function(e){t(e),l()}),(function(e){n(e),l()}),{data:i&&"text"!==i&&"json"!==i?c.response:c.responseText,status:c.status,statusText:c.statusText,headers:r,config:e,request:c}),c=null}c.open(r.method.toUpperCase(),r.url,!0),c.timeout=r.timeout,"onloadend"in c?c.onloadend=u:c.onreadystatechange=function(){c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&setTimeout(u)},c.onabort=function(){c&&(n(new Z("Request aborted",Z.ECONNABORTED,r,c)),c=null)},c.onerror=function(){n(new Z("Network Error",Z.ERR_NETWORK,r,c)),c=null},c.ontimeout=function(){let e=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const t=r.transitional||ue;r.timeoutErrorMessage&&(e=r.timeoutErrorMessage),n(new Z(e,t.clarifyTimeoutError?Z.ETIMEDOUT:Z.ECONNABORTED,r,c)),c=null},void 0===a&&o.setContentType(null),"setRequestHeader"in c&&J.forEach(o.toJSON(),(function(e,t){c.setRequestHeader(t,e)})),J.isUndefined(r.withCredentials)||(c.withCredentials=!!r.withCredentials),i&&"json"!==i&&(c.responseType=r.responseType),"function"==typeof r.onDownloadProgress&&c.addEventListener("progress",Pe(r.onDownloadProgress,!0)),"function"==typeof r.onUploadProgress&&c.upload&&c.upload.addEventListener("progress",Pe(r.onUploadProgress)),(r.cancelToken||r.signal)&&(s=t=>{c&&(n(!t||t.type?new Ae(null,e,c):t),c.abort(),c=null)},r.cancelToken&&r.cancelToken.subscribe(s),r.signal&&(r.signal.aborted?s():r.signal.addEventListener("abort",s)));const d=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);d&&-1===ye.protocols.indexOf(d)?n(new Z("Unsupported protocol "+d+":",Z.ERR_BAD_REQUEST,e)):c.send(a||null)}))},qe=(e,t)=>{let n,r=new AbortController;const a=function(e){if(!n){n=!0,s();const t=e instanceof Error?e:this.reason;r.abort(t instanceof Z?t:new Ae(t instanceof Error?t.message:t))}};let o=t&&setTimeout((()=>{a(new Z(`timeout ${t} of ms exceeded`,Z.ETIMEDOUT))}),t);const s=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach((e=>{e&&(e.removeEventListener?e.removeEventListener("abort",a):e.unsubscribe(a))})),e=null)};e.forEach((e=>e&&e.addEventListener&&e.addEventListener("abort",a)));const{signal:i}=r;return i.unsubscribe=s,[i,()=>{o&&clearTimeout(o),o=null}]},He=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let r,a=0;for(;a<n;)r=a+t,yield e.slice(a,r),a=r},ze=(e,t,n,r,a)=>{const o=async function*(e,t,n){for await(const r of e)yield*He(ArrayBuffer.isView(r)?r:await n(String(r)),t)}(e,t,a);let s=0;return new ReadableStream({type:"bytes",async pull(e){const{done:t,value:a}=await o.next();if(t)return e.close(),void r();let i=a.byteLength;n&&n(s+=i),e.enqueue(new Uint8Array(a))},cancel:e=>(r(e),o.return())},{highWaterMark:2})},$e=(e,t)=>{const n=null!=e;return r=>setTimeout((()=>t({lengthComputable:n,total:e,loaded:r})))},We="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,Ve=We&&"function"==typeof ReadableStream,Je=We&&("function"==typeof TextEncoder?(Ke=new TextEncoder,e=>Ke.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var Ke;const Ge=Ve&&(()=>{let e=!1;const t=new Request(ye.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})(),Xe=Ve&&!!(()=>{try{return J.isReadableStream(new Response("").body)}catch(e){}})(),Ze={stream:Xe&&(e=>e.body)};var Ye;We&&(Ye=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!Ze[e]&&(Ze[e]=J.isFunction(Ye[e])?t=>t[e]():(t,n)=>{throw new Z(`Response type '${e}' is not supported`,Z.ERR_NOT_SUPPORT,n)})})));const Qe=We&&(async e=>{let{url:t,method:n,data:r,signal:a,cancelToken:o,timeout:s,onDownloadProgress:i,onUploadProgress:l,responseType:c,headers:u,withCredentials:d="same-origin",fetchOptions:p}=Ie(e);c=c?(c+"").toLowerCase():"text";let f,h,[m,g]=a||o||s?qe([a,o],s):[];const y=()=>{!f&&setTimeout((()=>{m&&m.unsubscribe()})),f=!0};let E;try{if(l&&Ge&&"get"!==n&&"head"!==n&&0!==(E=await(async(e,t)=>{const n=J.toFiniteNumber(e.getContentLength());return null==n?(async e=>null==e?0:J.isBlob(e)?e.size:J.isSpecCompliantForm(e)?(await new Request(e).arrayBuffer()).byteLength:J.isArrayBufferView(e)?e.byteLength:(J.isURLSearchParams(e)&&(e+=""),J.isString(e)?(await Je(e)).byteLength:void 0))(t):n})(u,r))){let e,n=new Request(t,{method:"POST",body:r,duplex:"half"});J.isFormData(r)&&(e=n.headers.get("content-type"))&&u.setContentType(e),n.body&&(r=ze(n.body,65536,$e(E,Pe(l)),null,Je))}J.isString(d)||(d=d?"cors":"omit"),h=new Request(t,{...p,signal:m,method:n.toUpperCase(),headers:u.normalize().toJSON(),body:r,duplex:"half",withCredentials:d});let a=await fetch(h);const o=Xe&&("stream"===c||"response"===c);if(Xe&&(i||o)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=a[t]}));const t=J.toFiniteNumber(a.headers.get("content-length"));a=new Response(ze(a.body,65536,i&&$e(t,Pe(i,!0)),o&&y,Je),e)}c=c||"text";let s=await Ze[J.findKey(Ze,c)||"text"](a,e);return!o&&y(),g&&g(),await new Promise(((t,n)=>{ke(t,n,{data:s,headers:Le.from(a.headers),status:a.status,statusText:a.statusText,config:e,request:h})}))}catch(t){if(y(),t&&"TypeError"===t.name&&/fetch/i.test(t.message))throw Object.assign(new Z("Network Error",Z.ERR_NETWORK,e,h),{cause:t.cause||t});throw Z.from(t,t&&t.code,e,h)}}),et={http:null,xhr:Me,fetch:Qe};J.forEach(et,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const tt=e=>`- ${e}`,nt=e=>J.isFunction(e)||null===e||!1===e,rt=e=>{e=J.isArray(e)?e:[e];const{length:t}=e;let n,r;const a={};for(let o=0;o<t;o++){let t;if(n=e[o],r=n,!nt(n)&&(r=et[(t=String(n)).toLowerCase()],void 0===r))throw new Z(`Unknown adapter '${t}'`);if(r)break;a[t||"#"+o]=r}if(!r){const e=Object.entries(a).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));let n=t?e.length>1?"since :\n"+e.map(tt).join("\n"):" "+tt(e[0]):"as no adapter specified";throw new Z("There is no suitable adapter to dispatch the request "+n,"ERR_NOT_SUPPORT")}return r};function at(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Ae(null,e)}function ot(e){return at(e),e.headers=Le.from(e.headers),e.data=Te.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),rt(e.adapter||we.adapter)(e).then((function(t){return at(e),t.data=Te.call(e,e.transformResponse,t),t.headers=Le.from(t.headers),t}),(function(t){return _e(t)||(at(e),t&&t.response&&(t.response.data=Te.call(e,e.transformResponse,t.response),t.response.headers=Le.from(t.response.headers))),Promise.reject(t)}))}const st={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{st[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));const it={};st.transitional=function(e,t,n){function r(e,t){return"[Axios v1.7.2] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,a,o)=>{if(!1===e)throw new Z(r(a," has been removed"+(t?" in "+t:"")),Z.ERR_DEPRECATED);return t&&!it[a]&&(it[a]=!0,console.warn(r(a," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,a,o)}};const lt={assertOptions:function(e,t,n){if("object"!=typeof e)throw new Z("options must be an object",Z.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let a=r.length;for(;a-- >0;){const o=r[a],s=t[o];if(s){const t=e[o],n=void 0===t||s(t,o,e);if(!0!==n)throw new Z("option "+o+" must be "+n,Z.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new Z("Unknown option "+o,Z.ERR_BAD_OPTION)}},validators:st},ct=lt.validators;class ut{constructor(e){this.defaults=e,this.interceptors={request:new ce,response:new ce}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t;Error.captureStackTrace?Error.captureStackTrace(t={}):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Ue(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:a}=t;void 0!==n&<.assertOptions(n,{silentJSONParsing:ct.transitional(ct.boolean),forcedJSONParsing:ct.transitional(ct.boolean),clarifyTimeoutError:ct.transitional(ct.boolean)},!1),null!=r&&(J.isFunction(r)?t.paramsSerializer={serialize:r}:lt.assertOptions(r,{encode:ct.function,serialize:ct.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=a&&J.merge(a.common,a[t.method]);a&&J.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete a[e]})),t.headers=Le.concat(o,a);const s=[];let i=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(i=i&&e.synchronous,s.unshift(e.fulfilled,e.rejected))}));const l=[];let c;this.interceptors.response.forEach((function(e){l.push(e.fulfilled,e.rejected)}));let u,d=0;if(!i){const e=[ot.bind(this),void 0];for(e.unshift.apply(e,s),e.push.apply(e,l),u=e.length,c=Promise.resolve(t);d<u;)c=c.then(e[d++],e[d++]);return c}u=s.length;let p=t;for(d=0;d<u;){const e=s[d++],t=s[d++];try{p=e(p)}catch(e){t.call(this,e);break}}try{c=ot.call(this,p)}catch(e){return Promise.reject(e)}for(d=0,u=l.length;d<u;)c=c.then(l[d++],l[d++]);return c}getUri(e){return le(Fe((e=Ue(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}J.forEach(["delete","get","head","options"],(function(e){ut.prototype[e]=function(t,n){return this.request(Ue(n||{},{method:e,url:t,data:(n||{}).data}))}})),J.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,a){return this.request(Ue(a||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}ut.prototype[e]=t(),ut.prototype[e+"Form"]=t(!0)}));const dt=ut;class pt{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const n=this;this.promise.then((e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null})),this.promise.then=e=>{let t;const r=new Promise((e=>{n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e,r,a){n.reason||(n.reason=new Ae(e,r,a),t(n.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}static source(){let e;return{token:new pt((function(t){e=t})),cancel:e}}}const ft=pt,ht={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ht).forEach((([e,t])=>{ht[t]=e}));const mt=ht,gt=function e(t){const n=new dt(t),r=c(dt.prototype.request,n);return J.extend(r,dt.prototype,n,{allOwnKeys:!0}),J.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(Ue(t,n))},r}(we);gt.Axios=dt,gt.CanceledError=Ae,gt.CancelToken=ft,gt.isCancel=_e,gt.VERSION="1.7.2",gt.toFormData=ne,gt.AxiosError=Z,gt.Cancel=gt.CanceledError,gt.all=function(e){return Promise.all(e)},gt.spread=function(e){return function(t){return e.apply(null,t)}},gt.isAxiosError=function(e){return J.isObject(e)&&!0===e.isAxiosError},gt.mergeConfig=Ue,gt.AxiosHeaders=Le,gt.formToJSON=e=>Ee(J.isHTMLForm(e)?new FormData(e):e),gt.getAdapter=rt,gt.HttpStatusCode=mt,gt.default=gt;const yt=gt,Et=window.lodash,bt=(e,t="")=>(0,Et.has)(window,`UBB.${e}`)?(0,Et.get)(window.UBB,e):t;yt.interceptors.response.use((e=>(window.wpApiSettings.nonce=(0,Et.has)(e,"headers.x-wp-nonce")?e.headers["x-wp-nonce"]:window.wpApiSettings.nonce,e)));const wt=async e=>{if(!1===bt("api_root",!1))throw new Error("No root available.");const t={baseURL:bt("api_root"),headers:{"Content-Type":"application/json","X-WP-Nonce":window.wpApiSettings.nonce||0}};return yt((0,Et.merge)(t,e))},xt=async(e,t)=>await wt({method:"patch",url:`/edit/post/${e}/translation/${t}/link`});var St=n(848);const vt=(0,a.createContext)({currentLang:"",postId:"",languages:[],translations:[],translatedLangs:[],untranslatedLangs:[],refetchLangs:()=>{}}),Ct=e=>t=>(0,St.jsx)(vt.Consumer,{children:n=>(0,St.jsx)(e,{...t,...n})}),Rt=vt,Ot=Ct((({untranslatedLangs:e,postId:t,languagesInfo:n,refetchLangs:r})=>{const[o,s]=(0,a.useState)(e[0]),[i,c]=(0,a.useState)(!1),[u,d]=(0,a.useState)(!1),{mutate:p,data:f,isLoading:h,isError:m}=((e,t)=>{const[n,r]=(0,a.useState)(),[o,s]=(0,a.useState)(!1),[i,l]=(0,a.useState)(!1);return{mutate:async()=>{return s(!0),(n=e,a=t,wt({method:"post",url:`/edit/post/${n}/translation/${a}/copy`})).then((e=>r(e))).catch((()=>l(!0))).then((()=>s(!1)));var n,a},data:n,isLoading:o,isError:i}})(t,o);let g={ubb_source:t,lang:o};const y=bt("post_type","");y&&(g.post_type=y);const E=new URLSearchParams(g),b=`${bt("admin_url","")}/post-new.php?${E.toString()}`,w=()=>d(!1),x=()=>p().then((()=>r())),S=e.map((e=>({label:`${n[e].native_name} (${e})`,value:e}))),v=wp?.data?.select("core/editor").isEditedPostDirty()||!1;return(0,a.createElement)(a.Fragment,null,(0,a.createElement)(l.Flex,{direction:"column",style:{width:"100%"}},(0,a.createElement)(l.SelectControl,{label:"Create Translations",onChange:e=>s(e),value:o,options:S}),(0,a.createElement)(l.CheckboxControl,{label:"Copy content",help:"When creating the translation, copy the content of this post.",checked:i,onChange:()=>c((e=>!e))}),(0,a.createElement)(l.Flex,{justify:"end"},(0,a.createElement)(l.Button,{variant:"secondary",onClick:()=>{i?v?d(!0):x():window.location.href=b}},"Create")),m&&"ERROR!!!!",f&&JSON.stringify(f)),u&&(0,a.createElement)(l.Modal,{title:"Unsaved changes",onRequestClose:w},(0,a.createElement)("p",null,"The current post has unsaved changes."),(0,a.createElement)("p",null,"Copying with unsaved changes will not copy those changes to the new translation post."),(0,a.createElement)("div",{style:{display:"flex",justifyContent:"end",gap:"10px",paddingTop:"20px"}},(0,a.createElement)(l.Button,{variant:"secondary",onClick:w},"Cancel"),(0,a.createElement)(l.Button,{variant:"primary",onClick:x},"Copy"))))})),Lt=Ct((({postLanguage:e,currentLang:t,languages:n,languagesInfo:r,translatedLangs:o,refetchLangs:s,postId:i,allowActions:c})=>{const[u,d]=(0,a.useState)(!1),[p,f]=(0,a.useState)(null!==e&&n.includes(e)?e:null),{mutate:h,isLoading:m,isError:g}=(e=>{const[t,n]=(0,a.useState)(!1),[r,o]=(0,a.useState)(!1);return{mutate:async t=>(n(!0),((e,t)=>wt({method:"patch",url:`/edit/post/${e}/language/${t}`}))(e,t).catch((()=>o(!0))).then((()=>n(!1)))),isLoading:t,isError:r}})(i),y=()=>d(!1);if(m)return"Loading...";let E=n.map((t=>({label:`${r[t].native_name} (${t})`,value:t,disabled:(null===e||t!==e)&&void 0!==o.find((e=>e.language===t))}))),b=null,w=!1;return null===e?(E=[{label:"Select a language",value:"",disabled:!1},...E],b="Select a language"):n.includes(e)||(E=[{label:"Select a language",value:"",disabled:!1},...E],b=`Unknown language ${e}`,w=!0),null===b&&(b=`${r[e].native_name} (${e})`),(0,a.createElement)(l.PanelRow,null,!u&&(0,a.createElement)("div",{style:{display:"grid",justifyContent:"space-between",width:"100%"}},(0,a.createElement)("span",{style:{gridColumn:"1/2"}},w&&(0,a.createElement)("span",{style:{marginRight:"4px"}},(0,a.createElement)(l.Tooltip,{text:"This language is not set in the Unbabble options. Please select a correct language.",delay:"500"},(0,a.createElement)("span",{className:"dashicons dashicons-warning",style:{color:"FireBrick"}}))),b),c&&(0,a.createElement)(l.Button,{style:{gridColumn:"2/2"},variant:"link",onClick:()=>d(!0)},"Edit")),c&&u&&(0,a.createElement)(a.Fragment,null,(0,a.createElement)(l.FlexItem,{isBlock:!0},(0,a.createElement)(l.Flex,{direction:"column",align:"stretch"},(0,a.createElement)(l.SelectControl,{style:{width:"100%"},value:null===p?"":p,options:E,onChange:e=>f(e),__nextHasNoMarginBottom:!0}),(0,a.createElement)(l.Flex,{gap:"2",justify:"end"},(0,a.createElement)(l.Button,{style:{boxSizing:"border-box"},variant:"tertiary",onClick:y},"Cancel"),(0,a.createElement)(l.Button,{style:{boxSizing:"border-box"},variant:"primary",onClick:()=>{p!==e?h(p).then((()=>s())):y()}},"Save"))))))})),Tt=({translation:e,isDuplicate:t,languagesInfo:n})=>{const r=`${n[e.language].native_name} (${e.language})`;return(0,St.jsxs)(St.Fragment,{children:[(0,St.jsxs)("span",{style:{gridColumn:"1/2"},children:[(0,St.jsx)("span",{children:r}),t&&(0,St.jsx)("span",{style:{marginLeft:"4px"},children:(0,St.jsx)(l.Tooltip,{text:"Another post with the same language already exists in the translation group.",delay:"500",children:(0,St.jsx)("span",{className:"dashicons dashicons-warning",style:{color:"FireBrick"}})})})]}),(0,St.jsxs)("span",{style:{gridColumn:"2/2",gap:"10px",display:"flex"},children:[(0,St.jsx)("a",{href:e.edit,children:"Edit"}),(0,St.jsx)("a",{href:e.view,children:"View"})]})]})},_t=Ct((({currentLang:e,translatedLangs:t,postId:n,languagesInfo:r})=>(0,St.jsx)(l.PanelRow,{style:{flexDirection:"column"},children:(0,St.jsxs)(l.Flex,{direction:"column",style:{width:"100%"},children:[(0,St.jsx)("span",{style:{textTransform:"uppercase",fontSize:11,fontWeight:500},children:"translations"}),t.length>0&&t.map((a=>(0,St.jsx)("div",{style:{display:"grid",marginBottom:4,justifyContent:"space-between"},children:(0,St.jsx)(Tt,{translation:a,postId:n,isDuplicate:e===a.language||0!==t.filter((({ID:e,language:t})=>a.language===t&&a.ID!==e)).length,languagesInfo:r})},`ubb-link-translation-${a.language}`))),0===t.length&&(0,St.jsx)("p",{children:"No translations available."})]})}))),jt=Ct((({postId:e,refetchLangs:t})=>{const{mutate:n,isLoading:r}=(e=>{const[t,n]=(0,a.useState)(),[r,o]=(0,a.useState)(!1),[s,i]=(0,a.useState)(!1);return{mutate:()=>{return o(!0),(t=e,wt({method:"patch",url:`/edit/post/${t}/translation/unlink`})).then((e=>n(e))).catch((()=>i(!0))).then((()=>o(!1)));var t},data:t,isLoading:r,isError:s}})(e),[o,s]=(0,a.useState)(!1),i=()=>s(!1);return(0,St.jsxs)(St.Fragment,{children:[(0,St.jsx)(l.Button,{style:{boxSizing:"border-box"},variant:"secondary",isDestructive:!0,onClick:()=>s(!0),disabled:r,children:"Unlink from translations"}),o&&(0,St.jsxs)(l.Modal,{title:"Unlink from translations",onRequestClose:i,children:[(0,St.jsx)("p",{children:"Unlinking will detach this post from all of its translations."}),(0,St.jsx)("p",{children:"The rest of the translations will continue linked to each other."}),(0,St.jsxs)("div",{style:{display:"flex",justifyContent:"end",gap:"10px",paddingTop:"20px"},children:[(0,St.jsx)(l.Button,{variant:"secondary",onClick:i,children:"Cancel"}),(0,St.jsx)(l.Button,{variant:"primary",isDestructive:!0,onClick:()=>n().then((()=>t())),children:"Unlink"})]})]})]})})),At=({children:e,title:t})=>(0,St.jsxs)("details",{children:[(0,St.jsx)("summary",{children:t}),(0,St.jsx)("div",{className:"components-panel__row",style:{marginTop:"1em"},children:e})]}),kt=({overlay:e=!1,size:t="md"})=>(0,a.createElement)("div",{style:{...e?{alignItems:"center",backgroundColor:"rgba(255, 255, 255, 0.8)",bottom:0,display:"flex",height:"100%",justifyContent:"center",left:0,position:"absolute",right:0,top:0,width:"100%",zIndex:1e3}:{}}},(0,a.createElement)(l.Spinner,{style:{...{sm:{width:"20px",height:"20px"},md:{width:"40px",height:"40px"},lg:{width:"60px",height:"60px"}}[t]}})),Pt=({postId:e,refetchLangs:t,posts:n,source:r})=>{const{mutate:o,isLoading:s,isSuccess:i,isError:c}=((e,t)=>{const[n,r]=(0,a.useState)(!1),[o,s]=(0,a.useState)(!1),[i,l]=(0,a.useState)(!1);return{mutate:()=>(r(!0),s(!1),xt(e,t).then((()=>s(!0))).catch((()=>l(!0))).then((()=>r(!1)))),isSuccess:o,isLoading:n,isError:i}})(e,r),u=n[0];return(0,a.createElement)("div",{style:{display:"flex",justifyContent:"space-between",border:"1px solid #e0e0e0",padding:"8px"}},(0,a.createElement)("div",{style:{display:"grid",gridTemplateColumns:"repeat(1, 1fr)",alignContent:"center"}},1===n.length&&(0,a.createElement)("summary",null,"("+u.lang+") "+u.title),n.length>1&&(0,a.createElement)(At,{title:"("+u.lang+") "+u.title},(0,a.createElement)("div",{style:{display:"flex",flexWrap:"wrap",marginLeft:20}},(0,a.createElement)("h4",{style:{marginTop:0}},"Other translations in the group:"),n.slice(1).map((({title:e,ID:t,lang:n})=>(0,a.createElement)("div",{key:`link-other-${t}`,style:{width:"100%",justifyContent:"space-between"}},(0,a.createElement)("span",null,"(",n,") "),(0,a.createElement)("span",null,e," "))))))),(0,a.createElement)(l.Button,{variant:"secondary",onClick:()=>o().then((()=>t())),disabled:s||i,style:{height:"min-content",margin:"auto 0 auto 32px"}},!i&&"Link",i&&"Linked"))},Nt=({search:e,setSearch:t,refetch:n,disabled:r})=>(0,a.createElement)("form",{onSubmit:e=>(e.preventDefault(),n(),!1)},(0,a.createElement)("div",{style:{display:"flex",width:"100%"}},(0,a.createElement)("input",{type:"text",value:e,onChange:e=>t(e.target.value),style:{width:"100%"},disabled:r}),(0,a.createElement)(l.Button,{style:{marginLeft:"8px"},variant:"primary",onClick:()=>n(),disabled:r,type:"submit"},"Search"))),Bt=({postId:e,refetchLangs:t,close:n})=>{const{data:r,refetch:o,isLoading:s,isError:i}=((e,t)=>{const[n,r]=(0,a.useState)(),[o,s]=(0,a.useState)(!0),[i,l]=(0,a.useState)(!1),c=async(t,n="")=>(l(!1),s(!0),((e,t,n="")=>wt({url:`/edit/post/${e}/translation/link?page=${t}&s=${n}`}))(e,t,n).then((({data:e})=>r(e))).catch((()=>l(!0))).then((()=>s(!1))));return(0,a.useEffect)((()=>{c(t)}),[e,t]),{data:n,refetch:c,isLoading:o,isError:i}})(e,1),[c,u]=(0,a.useState)(1),[d,p]=(0,a.useState)(r?.pages||1),[f,h]=(0,a.useState)("");return s||d===(r?.pages||1)||p(r?.pages||1),(0,a.createElement)(l.Modal,{title:"Link to existing posts:",onRequestClose:n,size:"large"},(0,a.createElement)("div",{style:{display:"grid",flexWrap:"wrap",gap:"8px"}},(0,a.createElement)(l.Notice,{status:"warning",isDismissible:!1,politeness:"polite"}," ","You will unlink from the post's current translations if you link to another."),(0,a.createElement)(Nt,{search:f,setSearch:h,refetch:()=>{u(1),o(1,f)},disabled:s}),(0,a.createElement)("div",{style:{position:"relative",minHeight:"50px"}},r?.options&&0!==r.options.length&&(0,a.createElement)(l.__experimentalVStack,{expanded:!0},r.options.map((n=>(0,a.createElement)(Pt,{key:`link-option-${n.source}`,...n,postId:e,refetchLangs:t})))),s&&(0,a.createElement)(kt,{overlay:!0}),!s&&r?.options&&0===r.options.length&&(0,a.createElement)("div",null,"No results found."),i&&"ERROR!!!")),(0,a.createElement)("div",{style:{position:"sticky",display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",marginTop:20}},(0,a.createElement)(l.Button,{variant:"secondary",onClick:()=>{c<=1||(u(c-1),o(c-1,f))},disabled:c<2},"Previous Page"),(0,a.createElement)("span",{style:{display:"flex",gap:5}},(0,a.createElement)("strong",null,c),(0,a.createElement)("span",null,"/"),(0,a.createElement)("span",null,d)),(0,a.createElement)(l.Button,{variant:"secondary",onClick:()=>{c>=d||(u(c+1),o(c+1,f))},disabled:c>=d},"Next Page")))},Ft=Ct((({postId:e,refetchLangs:t})=>{const[n,r]=(0,a.useState)(!1);return(0,a.createElement)(a.Fragment,null,n&&(0,a.createElement)(Bt,{close:()=>{r(!1)},postId:e,refetchLangs:t}),(0,a.createElement)(l.Button,{style:{boxSizing:"border-box"},variant:"secondary",onClick:()=>{r(!0)}},"Link translations"))}));let Dt=new URLSearchParams(window.location.search).get("ubb_source"),Ut=null;const It=()=>{var e,t;const n=null!==(e=wp?.data?.select("core/editor")?.getCurrentPostId())&&void 0!==e?e:((e,t)=>{const n=new URLSearchParams(window.location.search);return n.has(e)?n.get(e):void 0})("post"),{data:r,refetch:o,isLoading:s,isError:i,setIsLoading:l,setIsError:c}=(e=>{const[t,n]=(0,a.useState)(),[r,o]=(0,a.useState)(!0),[s,i]=(0,a.useState)(!1),l=()=>{return isNaN(e)?(o(!1),i(!1),void n([])):(o(!0),i(!1),(t=e,wt({url:`/edit/post/${t}`})).then((({data:e})=>n(e))).catch((()=>i(!0))).then((()=>o(!1))));var t};return(0,a.useEffect)((()=>{l()}),[]),{data:{...t,postId:e},refetch:l,isLoading:r,isError:s,setIsLoading:o,setIsError:i}})(n),u=bt("post_metabox_allow_actions",!0);if((0,a.useEffect)((()=>{if(void 0!==n&&Dt)return Ut=wp.data.subscribe((()=>{if(!Dt)return;const e=wp.data.select("core/editor").didPostSaveRequestSucceed(),t=wp.data.select("core/editor").isEditedPostNew();e&&!t&&(l(!0),xt(wp.data.select("core/editor").getCurrentPostId(),Dt).then((()=>{o()})).catch((()=>{c(!0)})).then((()=>{l(!1)})),Dt=null,Ut())})),Ut}),[]),s)return"Loading...";if(i)return"Error fetching post language data.";if(null!==(t=wp?.data?.select("core/editor")?.isEditedPostNew())&&void 0!==t&&t||!r||!r.translations){const e=new URL(window.location.href).searchParams.get("ubb_source"),t=bt("source_title",""),n=bt("source_edit_url","");return(0,a.createElement)(a.Fragment,null,(0,a.createElement)("input",{hidden:!0,readOnly:!0,id:"ubb_lang",name:"ubb_lang",value:bt("current_lang","")}),(0,a.createElement)("span",null,"Post has no language data."),e&&(0,a.createElement)(a.Fragment,null,(0,a.createElement)("br",null),(0,a.createElement)("br",null),(0,a.createElement)("span",null,'Post is being linked as a translation to post "',(0,a.createElement)("a",{href:n,target:"_blank"},t),'".')))}const{language:d,translations:p}=r,f=bt("current_lang",""),h=bt("languages",{}),m=bt("languagesInfo",{}),g=h.filter((e=>(null===d||e!==d)&&!p.map((e=>e.language)).includes(e))),y=null!==d&&!h.includes(d);return(0,a.createElement)(Rt.Provider,{value:{currentLang:f,postId:r.postId,postLanguage:r.language,languages:h,languagesInfo:m,translatedLangs:p,untranslatedLangs:g,refetchLangs:o}},(0,a.createElement)(Lt,{allowActions:u}),(0,a.createElement)(_t,{allowActions:u}),u&&!y&&g.length>0&&(0,a.createElement)(a.Fragment,null,(0,a.createElement)("hr",null),(0,a.createElement)(Ot,null)),u&&!y&&p.length<1&&(0,a.createElement)(a.Fragment,null,(0,a.createElement)("hr",null),(0,a.createElement)("p",{style:{textTransform:"uppercase",fontSize:11,fontWeight:500}},"linking"),(0,a.createElement)("p",null,"This post currently has no translation group. You can link it to existing posts in other languages."),(0,a.createElement)(Ft,null)),u&&p.length>0&&(0,a.createElement)(a.Fragment,null,(0,a.createElement)("hr",null),(0,a.createElement)("p",{style:{textTransform:"uppercase",fontSize:11,fontWeight:500}},"linking"),(0,a.createElement)("p",null,"This post is currently in a translation group. If you wish to change, you must first unlink from the current group."),(0,a.createElement)(jt,null)))},Mt=({isClassic:e=!1})=>(0,St.jsxs)(St.Fragment,{children:[!e&&(0,St.jsx)(i.PluginDocumentSettingPanel,{name:"ubb-lang-panel",title:"Language",children:(0,St.jsx)(It,{})}),e&&(0,St.jsx)(It,{})]}),qt=window.wp.primitives,Ht=(0,St.jsx)(qt.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,St.jsx)(qt.Path,{d:"M5 5v1.5h14V5H5zm0 7.8h14v-1.5H5v1.5zM5 19h14v-1.5H5V19z"})}),zt=(0,St.jsx)(qt.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,St.jsx)(qt.Path,{d:"M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z"})}),$t=(0,St.jsx)(qt.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,St.jsx)(qt.Path,{d:"M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"})}),Wt=(0,St.jsx)(qt.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,St.jsx)(qt.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"})}),Vt=({languages:e,setLanguages:t,defaultLanguage:n,setDefaultLanguage:r,readOnly:o})=>{const[s,i]=(0,a.useState)(!1),[c,u]=(0,a.useState)(!1),[d,p]=(0,a.useState)(""),[f,h]=(0,a.useState)(""),m=()=>{u(!1),h("")},g=n=>{const r=e.concat(),a=r.find((e=>e.language===n));r.find((e=>e.language===n)).hidden=!a.hidden,t(r)};return(0,a.createElement)(a.Fragment,null,(0,a.createElement)("div",{style:{display:"grid",flexWrap:"wrap",paddingBottom:"20px",gap:"8px"}},(0,a.createElement)(l.Flex,{direction:"row"},(0,a.createElement)("div",null,(0,a.createElement)("div",{style:{display:"grid",flexWrap:"wrap",gap:"8px",maxHeight:"312px",overflow:"scroll",padding:"20px",background:"white",border:"2px solid #ccc",borderRadius:"5px"}},(0,a.createElement)("table",null,(0,a.createElement)("tbody",null,e.length>0&&e.sort(((e,t)=>e.language===n?-1:t.language===n?1:0)).map((({language:t,hidden:s})=>{const i=bt("wpLanguages",[]).find((e=>e.code===t))?.label,c=t===n;return(0,a.createElement)("tr",{key:t},(0,a.createElement)("td",null,i),(0,a.createElement)("td",{style:{paddingLeft:"20px",color:"#888"}},c&&(0,a.createElement)("p",{style:{margin:0}},"Default language")),(0,a.createElement)("td",{style:{paddingLeft:"20px"}},s&&(0,a.createElement)("p",{style:{color:"rgb(230, 74, 74)"}},"Hidden")),(0,a.createElement)("td",{style:{paddingLeft:"20px"}},(o||c)&&(0,a.createElement)(l.Button,{icon:Ht,style:{padding:6,fill:"#d5d5d5"},disabled:!0}),!o&&!c&&(0,a.createElement)(l.DropdownMenu,{icon:Ht},(({onClose:n})=>(0,a.createElement)(a.Fragment,null,(0,a.createElement)(l.MenuGroup,null,(0,a.createElement)(l.MenuItem,{icon:zt,onClick:()=>g(t)},s?"Show":"Hide"),(0,a.createElement)(l.MenuItem,{icon:$t,onClick:()=>{var a;r(a=t),e.find((({language:e})=>e===a)).hidden&&g(a),n()}},"Set as default")),(0,a.createElement)(l.MenuGroup,null,(0,a.createElement)(l.MenuItem,{icon:Wt,onClick:()=>{(e=>{u(!0),h(e)})(t),n()}},"Remove")))))))})))))),(0,a.createElement)("div",{style:{display:"grid",gap:8,alignSelf:"baseline"}},(0,a.createElement)(l.Button,{variant:"secondary",onClick:()=>{i(!0),p("")},disabled:o},"Add language")),s&&(0,a.createElement)(l.Modal,{title:"Add new Language",onRequestClose:()=>{i(!1),p("")}},(0,a.createElement)(l.SelectControl,{value:d,onChange:e=>{p(e)}},(0,a.createElement)("option",{value:""},"Select a language:"),bt("wpLanguages",[]).filter((t=>!e.includes(t.code))).map((e=>(0,a.createElement)("option",{value:e.code,key:e.code},e.label)))),d&&(0,a.createElement)(l.Button,{variant:"secondary",onClick:()=>{t(e.concat([{language:d,hidden:!1}])),i(!1),p("")}},"Add Selected Language")),c&&f&&(0,a.createElement)(l.Modal,{title:"Removing Language",onRequestClose:m},(0,a.createElement)("p",null,"Are you sure you want to remove"," ",(0,a.createElement)("b",null,bt("wpLanguages",[]).find((e=>e.code===f))?.label),"?"),(0,a.createElement)(l.Button,{variant:"secondary",onClick:()=>{t(e.filter((e=>e.language!==f))),u(!1),h("")}},"Remove"),(0,a.createElement)(l.Button,{variant:"secondary",onClick:m},"Cancel")))))},Jt=({languages:e,setLanguages:t,defaultLanguage:n,setDefaultLanguage:r,readOnly:o=!1})=>(0,a.createElement)(a.Fragment,null,(0,a.createElement)("h3",null,"Languages"),(0,a.createElement)(l.Flex,{direction:"row",style:{width:"100%",justifyContent:"normal"}},(0,a.createElement)(Vt,{languages:e,setLanguages:t,defaultLanguage:n,setDefaultLanguage:r,readOnly:o}))),Kt=({languages:e,defaultLanguage:t,routing:n,setRouting:r,readOnly:o})=>(0,a.createElement)(a.Fragment,null,(0,a.createElement)("h3",null,"Routing"),(0,a.createElement)(l.Flex,{direction:"column",style:{width:"fit-content",marginBottom:24}},(0,a.createElement)(l.SelectControl,{value:n.router,onChange:e=>{var t;t=e,r({...n,router:t})},label:"Routing type",__nextHasNoMarginBottom:!0,disabled:o},(0,a.createElement)("option",{value:"directory"},"Directory"),(0,a.createElement)("option",{value:"query_var"},"Query Var")),"directory"===n.router&&(0,a.createElement)(a.Fragment,null,(0,a.createElement)("h4",null,"Directory settings"),(0,a.createElement)("div",{style:{display:"grid",flexWrap:"wrap",gap:"8px",maxHeight:"312px",overflow:"scroll",padding:"20px",background:"white",border:"2px solid #ccc",borderRadius:"5px"}},e.map((({language:e})=>{var s;const i=bt("wpLanguages",[]).find((t=>t.code===e))?.label,c=e===t;return(0,a.createElement)(l.Flex,{direction:"row",style:{justifyContent:"end",gap:32},key:e},(0,a.createElement)("div",null,i),(0,a.createElement)(l.TextControl,{value:c?"/":null!==(s=n.router_options.directories[e])&&void 0!==s?s:"",onChange:t=>((e,t)=>{r({...n,router_options:{...n.router_options,directories:{...n.router_options.directories,[e]:t}}})})(e,t),placeholder:c?"/":e,disabled:o||c,__nextHasNoMarginBottom:!0}))})))))),Gt=({title:e,types:t,setTypes:n,allTypes:r,addLabel:o,selectLabel:s,addSelectedLabel:i,readOnly:c})=>{const[u,d]=(0,a.useState)(!1),[p,f]=(0,a.useState)(!1),[h,m]=(0,a.useState)(""),[g,y]=(0,a.useState)(""),E=()=>{f(!1),y("")};return(0,a.createElement)(a.Fragment,null,(0,a.createElement)("h3",null,e),(0,a.createElement)(l.Flex,{direction:"row",style:{width:"100%",justifyContent:"normal"}},(0,a.createElement)("div",{style:{display:"grid",flexWrap:"wrap",gap:"8px",maxHeight:"472px",overflow:"scroll",padding:"20px",background:"white",border:"2px solid #ccc",borderRadius:"5px"}},t.map((e=>(0,a.createElement)(l.Flex,{direction:"row",style:{gap:32},key:e},(0,a.createElement)("span",null,e),!c&&(0,a.createElement)(l.Button,{variant:"tertiary",onClick:()=>(e=>{f(!0),y(e)})(e),isSmall:!0,isDestructive:!0},"Remove")))),0===t.length&&(0,a.createElement)("span",null,"None selected.")),(0,a.createElement)("div",{style:{display:"grid",gap:8,alignSelf:"baseline"}},(0,a.createElement)(l.Button,{variant:"secondary",onClick:()=>{d(!0),m("")},disabled:c},o)),u&&(0,a.createElement)(l.Modal,{title:o,onRequestClose:()=>{d(!1),m("")}},(0,a.createElement)(l.SelectControl,{value:h,onChange:e=>{m(e)}},(0,a.createElement)("option",{value:""},s),r.filter((e=>!t.includes(e))).map((e=>(0,a.createElement)("option",{value:e,key:e},e)))),h&&(0,a.createElement)(l.Button,{variant:"secondary",onClick:()=>{n(t.concat([h])),d(!1)}},i)),p&&g&&(0,a.createElement)(l.Modal,{title:"Removing Language",onRequestClose:E},(0,a.createElement)("p",null,"Are you sure you want to remove"," ",(0,a.createElement)("b",null,g),"?"),(0,a.createElement)(l.Button,{style:{marginRight:10},variant:"secondary",onClick:()=>{n(t.filter((e=>e!==g))),y("")}},"Remove"),(0,a.createElement)(l.Button,{variant:"secondary",onClick:E},"Cancel"))))},Xt=({isDirty:e,submit:t,update:n,hasFilterSettings:r,hasManualChanges:o})=>(0,a.createElement)(a.Fragment,null,(0,a.createElement)(l.Button,{className:"button button-primary",onClick:t,disabled:!e},"Save"),r&&(0,a.createElement)(l.Button,{className:"button button-primary",onClick:n,disabled:!o||!r},"Reset to filter options")),Zt=({text:e})=>(0,a.createElement)("span",{style:{backgroundColor:"rgb(235,235,235)",padding:"2px 3px"}},e),Yt=({})=>{const[e,t]=(0,a.useState)(bt("options",[])),[n,r]=(0,a.useState)(e?.post_types),[o,s]=(0,a.useState)(e?.taxonomies),[i,c]=(0,a.useState)(e?.allowed_languages.map((t=>({language:t,hidden:e?.hidden_languages?.includes(t)})))),[u,d]=(0,a.useState)(e?.default_language),[p,f]=(0,a.useState)({router:e?.router,router_options:e?.router_options}),[h,m]=(0,a.useState)(!1),[g,y]=(0,a.useState)(null),E=bt("settings_read_only",!1),[b,w]=(0,a.useState)(bt("settings_manual_changes",!1)),x=bt("settings_has_filter",!1),S=e=>{r(e?.post_types),s(e?.taxonomies),c(e?.allowed_languages.map((t=>({language:t,hidden:e?.hidden_languages?.includes(t)})))),d(e?.default_language),f({router:e?.router,router_options:e?.router_options})},v=()=>{var e;y(""),(e={languages:i,defaultLanguage:u,routing:p,postTypes:n,taxonomies:o},wt({method:"post",url:"/options",data:e})).then((e=>{void 0!==e?.data?.options&&(t(e.data.options),S(e.data.options)),void 0!==e?.data?.has_manual_changes&&w(e.data.has_manual_changes),y("success"),m(!1)})).catch((e=>y(e.response.data.errors))).then((()=>window.scrollTo(0,0)))},C=()=>{y(""),wt({method:"post",url:"/options/update"}).then((e=>{void 0!==e?.data?.options&&(t(e.data.options),S(e.data.options)),void 0!==e?.data?.has_manual_changes&&w(e.data.has_manual_changes),y("success"),m(!1)})).catch((e=>y(e.response.data.errors))).then((()=>window.scrollTo(0,0)))},R=e=>t=>{e(t),m(!0)};return(0,a.createElement)(a.Fragment,null,(0,a.createElement)("form",{action:"options.php",method:"post"},(0,a.createElement)(l.Flex,{direction:"row",style:{width:"100%",justifyContent:"normal"}},(0,a.createElement)("h1",null,"Unbabble Settings"),!E&&(0,a.createElement)(Xt,{isDirty:h,submit:v,update:C,hasFilterSettings:x,hasManualChanges:b})),(0,a.createElement)("div",{style:{display:"grid",gap:"10px"}},E&&(0,a.createElement)(l.Notice,{status:"info",isDismissible:!1},"The settings are read-only due to the constant"," ",(0,a.createElement)(Zt,{text:"UBB_SETTINGS_READONLY"}),"."),!b&&x&&(0,a.createElement)(l.Notice,{status:"info",isDismissible:!1},"Settings are being automatically updated via the filter ",(0,a.createElement)(Zt,{text:"ubb_options"}),"."),b&&x&&(0,a.createElement)(l.Notice,{status:"info",isDismissible:!1},"Settings have been manually edited and are no longer being automatically updated."),"success"===g&&(0,a.createElement)(l.Notice,{status:"success",onRemove:()=>y("")},"Settings have been updated."),null!==g&&"object"==typeof g&&(0,a.createElement)(l.Notice,{status:"error",onRemove:()=>y("")},"An error has occured while trying to update.")),(0,a.createElement)(Jt,{languages:i,setLanguages:R(c),defaultLanguage:u,setDefaultLanguage:R(d),readOnly:E}),(0,a.createElement)(Kt,{languages:i,defaultLanguage:u,routing:p,setRouting:R(f),readOnly:E}),(0,a.createElement)(Gt,{title:"Post Types",addLabel:"Add post type",selectLabel:"Select a post type",addSelectedLabel:"Add selected post type",types:n,setTypes:R(r),allTypes:bt("wpPostTypes",[]),readOnly:E}),(0,a.createElement)(Gt,{title:"Taxonomies",addLabel:"Add taxonomy",selectLabel:"Select a taxonomy",addSelectedLabel:"Add selected taxonomy",types:o,setTypes:R(s),allTypes:bt("wpTaxonomies",[]),readOnly:E}),!E&&(0,a.createElement)(Xt,{isDirty:h,submit:v,update:C,hasFilterSettings:x,hasManualChanges:b})))};window.addEventListener("load",(()=>{const e=document.getElementById("ubb-language");e&&(0,o.H)(e).render((0,a.createElement)(Mt,{isClassic:!0}))})),(0,s.registerPlugin)("ubb-language-panel",{render:Mt,icon:"airplane"}),window.addEventListener("load",(()=>{const e=document.getElementById("ubb-options-page");e&&(0,o.H)(e).render((0,a.createElement)(Yt,null))}))})();