2 lines
19 KiB
JavaScript
2 lines
19 KiB
JavaScript
/*! This file is auto-generated */
|
|
this.wp=this.wp||{},this.wp.mediaUtils=function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=362)}({0:function(t,e){!function(){t.exports=this.wp.element}()},1:function(t,e){!function(){t.exports=this.wp.i18n}()},10:function(t,e,r){"use strict";function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}r.d(e,"a",(function(){return n}))},11:function(t,e,r){"use strict";function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function o(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}r.d(e,"a",(function(){return o}))},12:function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}r.d(e,"a",(function(){return n}))},13:function(t,e,r){"use strict";r.d(e,"a",(function(){return i}));var n=r(31),o=r(5);function i(t,e){return!e||"object"!==Object(n.a)(e)&&"function"!=typeof e?Object(o.a)(t):e}},14:function(t,e,r){"use strict";function n(t){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}r.d(e,"a",(function(){return n}))},15:function(t,e,r){"use strict";function n(t,e){return(n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)}r.d(e,"a",(function(){return o}))},17:function(t,e,r){"use strict";var n=r(30);function o(t){return function(t){if(Array.isArray(t)){for(var e=0,r=new Array(t.length);e<t.length;e++)r[e]=t[e];return r}}(t)||Object(n.a)(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}r.d(e,"a",(function(){return o}))},2:function(t,e){!function(){t.exports=this.lodash}()},20:function(t,e,r){t.exports=r(47)},23:function(t,e,r){"use strict";var n=r(38);var o=r(39);function i(t,e){return Object(n.a)(t)||function(t,e){var r=[],n=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(n=(a=c.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(t){o=!0,i=t}finally{try{n||null==c.return||c.return()}finally{if(o)throw i}}return r}(t,e)||Object(o.a)()}r.d(e,"a",(function(){return i}))},30:function(t,e,r){"use strict";function n(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}r.d(e,"a",(function(){return n}))},31:function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t){return(o="function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?function(t){return n(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":n(t)})(t)}r.d(e,"a",(function(){return o}))},34:function(t,e){!function(){t.exports=this.wp.apiFetch}()},35:function(t,e){!function(){t.exports=this.wp.blob}()},362:function(t,e,r){"use strict";r.r(e);var n=r(12),o=r(11),i=r(13),a=r(14),c=r(5),u=r(15),l=r(2),s=r(0),f=r(1),p=window.wp,h=function(t){return Object(l.pick)(t,["sizes","mime","type","subtype","id","url","alt","link","caption"])},d=function(t){return p.media.query({order:"ASC",orderby:"post__in",post__in:t,posts_per_page:-1,query:!0,type:"image"})},y=function(t){function e(t){var r,o=t.allowedTypes,u=t.gallery,l=void 0!==u&&u,s=t.unstableFeaturedImageFlow,h=void 0!==s&&s,d=t.modalClass,y=t.multiple,m=void 0!==y&&y,b=t.title,v=void 0===b?Object(f.__)("Select or Upload Media"):b;if(Object(n.a)(this,e),(r=Object(i.a)(this,Object(a.a)(e).apply(this,arguments))).openModal=r.openModal.bind(Object(c.a)(r)),r.onOpen=r.onOpen.bind(Object(c.a)(r)),r.onSelect=r.onSelect.bind(Object(c.a)(r)),r.onUpdate=r.onUpdate.bind(Object(c.a)(r)),r.onClose=r.onClose.bind(Object(c.a)(r)),l)r.buildAndSetGalleryFrame();else{var g={title:v,multiple:m};o&&(g.library={type:o}),r.frame=p.media(g)}return d&&r.frame.$el.addClass(d),h&&r.buildAndSetFeatureImageFrame(),r.initializeListeners(),r}return Object(u.a)(e,t),Object(o.a)(e,[{key:"initializeListeners",value:function(){this.frame.on("select",this.onSelect),this.frame.on("update",this.onUpdate),this.frame.on("open",this.onOpen),this.frame.on("close",this.onClose)}},{key:"buildAndSetGalleryFrame",value:function(){var t=this.props,e=t.addToGallery,r=void 0!==e&&e,n=t.allowedTypes,o=t.multiple,i=void 0!==o&&o,a=t.value,c=void 0===a?null:a;if(c!==this.lastGalleryValue){var u;this.lastGalleryValue=c,this.frame&&this.frame.remove(),u=r?"gallery-library":c?"gallery-edit":"gallery",this.GalleryDetailsMediaFrame||(this.GalleryDetailsMediaFrame=p.media.view.MediaFrame.Post.extend({createStates:function(){this.states.add([new p.media.controller.Library({id:"gallery",title:p.media.view.l10n.createGalleryTitle,priority:40,toolbar:"main-gallery",filterable:"uploaded",multiple:"add",editable:!1,library:p.media.query(Object(l.defaults)({type:"image"},this.options.library))}),new p.media.controller.GalleryEdit({library:this.options.selection,editing:this.options.editing,menu:"gallery",displaySettings:!1,multiple:!0}),new p.media.controller.GalleryAdd])}}));var s=d(c),f=new p.media.model.Selection(s.models,{props:s.props.toJSON(),multiple:i});this.frame=new this.GalleryDetailsMediaFrame({mimeType:n,state:u,multiple:i,selection:f,editing:!!c}),p.media.frame=this.frame,this.initializeListeners()}}},{key:"buildAndSetFeatureImageFrame",value:function(){var t=p.media.view.MediaFrame.Select.extend({featuredImageToolbar:function(t){this.createSelectToolbar(t,{text:p.media.view.l10n.setFeaturedImage,state:this.options.state})},createStates:function(){this.on("toolbar:create:featured-image",this.featuredImageToolbar,this),this.states.add([new p.media.controller.FeaturedImage])}}),e=d(this.props.value),r=new p.media.model.Selection(e.models,{props:e.props.toJSON()});this.frame=new t({mimeType:this.props.allowedTypes,state:"featured-image",multiple:this.props.multiple,selection:r,editing:!!this.props.value}),p.media.frame=this.frame}},{key:"componentWillUnmount",value:function(){this.frame.remove()}},{key:"onUpdate",value:function(t){var e=this.props,r=e.onSelect,n=e.multiple,o=void 0!==n&&n,i=this.frame.state(),a=t||i.get("selection");a&&a.models.length&&r(o?a.models.map((function(t){return h(t.toJSON())})):h(a.models[0].toJSON()))}},{key:"onSelect",value:function(){var t=this.props,e=t.onSelect,r=t.multiple,n=void 0!==r&&r,o=this.frame.state().get("selection").toJSON();e(n?o:o[0])}},{key:"onOpen",value:function(){if(this.updateCollection(),this.props.value){if(!this.props.gallery){var t=this.frame.state().get("selection");Object(l.castArray)(this.props.value).forEach((function(e){t.add(p.media.attachment(e))}))}d(Object(l.castArray)(this.props.value)).more()}}},{key:"onClose",value:function(){var t=this.props.onClose;t&&t()}},{key:"updateCollection",value:function(){var t=this.frame.content.get();if(t&&t.collection){var e=t.collection;e.toArray().forEach((function(t){return t.trigger("destroy",t)})),e.mirroring._hasMore=!0,e.more()}}},{key:"openModal",value:function(){this.props.gallery&&this.props.value&&this.props.value.length>0&&this.buildAndSetGalleryFrame(),this.frame.open()}},{key:"render",value:function(){return this.props.render({open:this.openModal})}}]),e}(s.Component),m=r(20),b=r.n(m),v=r(7),g=r(43),w=r(17),O=r(23),j=r(34),_=r.n(j),x=r(35);function S(t){return E.apply(this,arguments)}function E(){return(E=Object(g.a)(b.a.mark((function t(e){var r,n,o,i,a,c,u,p,h,d,y,m,g,j,_,S,E,k,T,P,F,M,A,G,I,N,C,U,R;return b.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=e.allowedTypes,n=e.additionalData,o=void 0===n?{}:n,i=e.filesList,a=e.maxUploadFileSize,c=e.onError,u=void 0===c?l.noop:c,p=e.onFileChange,h=e.wpAllowedMimeTypes,d=void 0===h?null:h,y=Object(w.a)(i),m=[],g=function(t,e){Object(x.revokeBlobURL)(Object(l.get)(m,[t,"url"])),m[t]=e,p(Object(l.compact)(m))},j=function(t){return!r||Object(l.some)(r,(function(e){return Object(l.includes)(e,"/")?e===t:Object(l.startsWith)(t,"".concat(e,"/"))}))},_=(b=d)?Object(l.flatMap)(b,(function(t,e){var r=t.split("/"),n=Object(O.a)(r,1)[0],o=e.split("|");return[t].concat(Object(w.a)(Object(l.map)(o,(function(t){return"".concat(n,"/").concat(t)}))))})):b,S=function(t){return Object(l.includes)(_,t)},E=function(t){t.message=[Object(s.createElement)("strong",{key:"filename"},t.file.name),": ",t.message],u(t)},k=[],T=!0,P=!1,F=void 0,t.prev=12,M=y[Symbol.iterator]();case 14:if(T=(A=M.next()).done){t.next=34;break}if(G=A.value,!_||S(G.type)){t.next=19;break}return E({code:"MIME_TYPE_NOT_ALLOWED_FOR_USER",message:Object(f.__)("Sorry, this file type is not permitted for security reasons."),file:G}),t.abrupt("continue",31);case 19:if(j(G.type)){t.next=22;break}return E({code:"MIME_TYPE_NOT_SUPPORTED",message:Object(f.__)("Sorry, this file type is not supported here."),file:G}),t.abrupt("continue",31);case 22:if(!(a&&G.size>a)){t.next=25;break}return E({code:"SIZE_ABOVE_LIMIT",message:Object(f.__)("This file exceeds the maximum upload size for this site."),file:G}),t.abrupt("continue",31);case 25:if(!(G.size<=0)){t.next=28;break}return E({code:"EMPTY_FILE",message:Object(f.__)("This file is empty."),file:G}),t.abrupt("continue",31);case 28:k.push(G),m.push({url:Object(x.createBlobURL)(G)}),p(m);case 31:T=!0,t.next=14;break;case 34:t.next=40;break;case 36:t.prev=36,t.t0=t.catch(12),P=!0,F=t.t0;case 40:t.prev=40,t.prev=41,T||null==M.return||M.return();case 43:if(t.prev=43,!P){t.next=46;break}throw F;case 46:return t.finish(43);case 47:return t.finish(40);case 48:I=0;case 49:if(!(I<k.length)){t.next=68;break}return N=k[I],t.prev=51,t.next=54,L(N,o);case 54:C=t.sent,U=Object(v.a)({},Object(l.omit)(C,["alt_text","source_url"]),{alt:C.alt_text,caption:Object(l.get)(C,["caption","raw"],""),title:C.title.raw,url:C.source_url}),g(I,U),t.next=65;break;case 59:t.prev=59,t.t1=t.catch(51),g(I,null),R=void 0,R=Object(l.has)(t.t1,["message"])?Object(l.get)(t.t1,["message"]):Object(f.sprintf)(Object(f.__)("Error while uploading file %s to the media library."),N.name),u({code:"GENERAL",message:R,file:N});case 65:++I,t.next=49;break;case 68:case"end":return t.stop()}var b}),t,null,[[12,36,40,48],[41,,43,47],[51,59]])})))).apply(this,arguments)}function L(t,e){var r=new window.FormData;return r.append("file",t,t.name||t.type.replace("/",".")),Object(l.forEach)(e,(function(t,e){return r.append(e,t)})),_()({path:"/wp/v2/media",body:r,method:"POST"})}r.d(e,"MediaUpload",(function(){return y})),r.d(e,"uploadMedia",(function(){return S}))},38:function(t,e,r){"use strict";function n(t){if(Array.isArray(t))return t}r.d(e,"a",(function(){return n}))},39:function(t,e,r){"use strict";function n(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}r.d(e,"a",(function(){return n}))},43:function(t,e,r){"use strict";function n(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function o(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function c(t){n(a,o,i,c,u,"next",t)}function u(t){n(a,o,i,c,u,"throw",t)}c(void 0)}))}}r.d(e,"a",(function(){return o}))},47:function(t,e,r){var n=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r,n){var o=e&&e.prototype instanceof y?e:y,i=Object.create(o.prototype),a=new L(n||[]);return i._invoke=function(t,e,r){var n=s;return function(o,i){if(n===p)throw new Error("Generator is already running");if(n===h){if("throw"===o)throw i;return T()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===d)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===s)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var u=l(t,e,r);if("normal"===u.type){if(n=r.done?h:f,u.arg===d)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=h,r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var s="suspendedStart",f="suspendedYield",p="executing",h="completed",d={};function y(){}function m(){}function b(){}var v={};v[i]=function(){return this};var g=Object.getPrototypeOf,w=g&&g(g(k([])));w&&w!==r&&n.call(w,i)&&(v=w);var O=b.prototype=y.prototype=Object.create(v);function j(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function _(t){var e;this._invoke=function(r,o){function i(){return new Promise((function(e,i){!function e(r,o,i,a){var c=l(t[r],t,o);if("throw"!==c.type){var u=c.arg,s=u.value;return s&&"object"==typeof s&&n.call(s,"__await")?Promise.resolve(s.__await).then((function(t){e("next",t,i,a)}),(function(t){e("throw",t,i,a)})):Promise.resolve(s).then((function(t){u.value=t,i(u)}),(function(t){return e("throw",t,i,a)}))}a(c.arg)}(r,o,e,i)}))}return e=e?e.then(i,i):i()}}function x(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,x(t,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var o=l(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,d;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,d):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function k(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:T}}function T(){return{value:e,done:!0}}return m.prototype=O.constructor=b,b.constructor=m,b[c]=m.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,c in t||(t[c]="GeneratorFunction")),t.prototype=Object.create(O),t},t.awrap=function(t){return{__await:t}},j(_.prototype),_.prototype[a]=function(){return this},t.AsyncIterator=_,t.async=function(e,r,n,o){var i=new _(u(e,r,n,o));return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},j(O),O[c]="Generator",O[i]=function(){return this},O.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(E),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(u&&l){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:k(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),d}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},5:function(t,e,r){"use strict";function n(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}r.d(e,"a",(function(){return n}))},7:function(t,e,r){"use strict";r.d(e,"a",(function(){return o}));var n=r(10);function o(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),o.forEach((function(e){Object(n.a)(t,e,r[e])}))}return t}}}); |