HamroKhanpin/hamrokhaanpaan/wp-includes/js/dist/widgets.min.js
2024-04-29 13:12:44 +05:45

7 lines
19 KiB
JavaScript

/*! This file is auto-generated */
this.wp=this.wp||{},this.wp.widgets=function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="4g8P")}({"1ZqX":function(e,t){e.exports=window.wp.data},"4g8P":function(e,t,n){"use strict";n.r(t),n.d(t,"MoveToWidgetArea",(function(){return R})),n.d(t,"getWidgetIdFromBlock",(function(){return G})),n.d(t,"addWidgetIdToBlock",(function(){return Z})),n.d(t,"registerLegacyWidgetBlock",(function(){return U})),n.d(t,"registerLegacyWidgetVariations",(function(){return z}));var i={};n.r(i),n.d(i,"metadata",(function(){return W})),n.d(i,"name",(function(){return N})),n.d(i,"settings",(function(){return A}));var r=n("HSyU"),o=n("GRId"),a=n("Tqx9");var s=Object(o.createElement)(a.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(o.createElement)(a.Path,{d:"M6 3H8V5H16V3H18V5C19.1046 5 20 5.89543 20 7V19C20 20.1046 19.1046 21 18 21H6C4.89543 21 4 20.1046 4 19V7C4 5.89543 4.89543 5 6 5V3ZM18 6.5H6C5.72386 6.5 5.5 6.72386 5.5 7V8H18.5V7C18.5 6.72386 18.2761 6.5 18 6.5ZM18.5 9.5H5.5V19C5.5 19.2761 5.72386 19.5 6 19.5H18C18.2761 19.5 18.5 19.2761 18.5 19V9.5ZM11 11H13V13H11V11ZM7 11V13H9V11H7ZM15 13V11H17V13H15Z"})),c=n("TSYQ"),l=n.n(c),d=n("axFQ"),u=n("tI+e");var m=Object(o.createElement)(a.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(o.createElement)(a.Path,{d:"M4 20h8v-1.5H4V20zM18.9 3.5c-.6-.6-1.5-.6-2.1 0l-7.2 7.2c-.4-.1-.7 0-1.1.1-.5.2-1.5.7-1.9 2.2-.4 1.7-.8 2.2-1.1 2.7-.1.1-.2.3-.3.4l-.6 1.1H6c2 0 3.4-.4 4.7-1.4.8-.6 1.2-1.4 1.3-2.3 0-.3 0-.5-.1-.7L19 5.7c.5-.6.5-1.6-.1-2.2zM9.7 14.7c-.7.5-1.5.8-2.4 1 .2-.5.5-1.2.8-2.3.2-.6.4-1 .8-1.1.5-.1 1 .1 1.3.3.2.2.3.5.2.8 0 .3-.1.9-.7 1.3z"})),h=n("l3Sj"),w=n("1ZqX"),b=n("jZUy");function g({selectedId:e,onSelect:t}){const n=Object(w.useSelect)(e=>{var t,n,i;const r=null!==(t=null===(n=e(d.store).getSettings())||void 0===n?void 0:n.widgetTypesToHideFromLegacyWidgetBlock)&&void 0!==t?t:[];return null===(i=e(b.store).getWidgetTypes({per_page:-1}))||void 0===i?void 0:i.filter(e=>!r.includes(e.id))},[]);return n?0===n.length?Object(h.__)("There are no widgets available."):Object(o.createElement)(u.SelectControl,{label:Object(h.__)("Select a legacy widget to display:"),value:null!=e?e:"",options:[{value:"",label:Object(h.__)("Select widget")},...n.map(e=>({value:e.id,label:e.name}))],onChange:e=>{if(e){const i=n.find(t=>t.id===e);t({selectedId:i.id,isMulti:i.is_multi})}else t({selectedId:null})}}):Object(o.createElement)(u.Spinner,null)}function p({name:e,description:t}){return Object(o.createElement)("div",{className:"wp-block-legacy-widget-inspector-card"},Object(o.createElement)("h3",{className:"wp-block-legacy-widget-inspector-card__name"},e),Object(o.createElement)("span",null,t))}var f=n("onLe"),v=n("K9lf"),y=n("YLtl"),j=n("ywyh"),O=n.n(j);class _{constructor({id:e,idBase:t,instance:n,onChangeInstance:i,onChangeHasPreview:r,onError:o}){this.id=e,this.idBase=t,this._instance=n,this._hasPreview=null,this.onChangeInstance=i,this.onChangeHasPreview=r,this.onError=o,this.number=++E,this.handleFormChange=Object(y.debounce)(this.handleFormChange.bind(this),200),this.handleFormSubmit=this.handleFormSubmit.bind(this),this.initDOM(),this.bindEvents(),this.loadContent()}destroy(){this.unbindEvents(),this.element.remove()}initDOM(){var e,t;this.element=k("div",{class:"widget open"},[k("div",{class:"widget-inside"},[this.form=k("form",{class:"form",method:"post"},[k("input",{class:"widget-id",type:"hidden",name:"widget-id",value:null!==(e=this.id)&&void 0!==e?e:`${this.idBase}-${this.number}`}),k("input",{class:"id_base",type:"hidden",name:"id_base",value:null!==(t=this.idBase)&&void 0!==t?t:this.id}),k("input",{class:"widget-width",type:"hidden",name:"widget-width",value:"250"}),k("input",{class:"widget-height",type:"hidden",name:"widget-height",value:"200"}),k("input",{class:"widget_number",type:"hidden",name:"widget_number",value:this.idBase?this.number.toString():""}),this.content=k("div",{class:"widget-content"}),this.id&&k("button",{class:"button is-primary",type:"submit"},Object(h.__)("Save"))])])])}bindEvents(){if(window.jQuery){const{jQuery:e}=window;e(this.form).on("change",null,this.handleFormChange),e(this.form).on("input",null,this.handleFormChange),e(this.form).on("submit",this.handleFormSubmit)}else this.form.addEventListener("change",this.handleFormChange),this.form.addEventListener("input",this.handleFormChange),this.form.addEventListener("submit",this.handleFormSubmit)}unbindEvents(){if(window.jQuery){const{jQuery:e}=window;e(this.form).off("change",null,this.handleFormChange),e(this.form).off("input",null,this.handleFormChange),e(this.form).off("submit",this.handleFormSubmit)}else this.form.removeEventListener("change",this.handleFormChange),this.form.removeEventListener("input",this.handleFormChange),this.form.removeEventListener("submit",this.handleFormSubmit)}async loadContent(){try{if(this.id){const{form:e}=await S(this.id);this.content.innerHTML=e}else if(this.idBase){const{form:e,preview:t}=await C({idBase:this.idBase,instance:this.instance,number:this.number});if(this.content.innerHTML=e,this.hasPreview=!B(t),!this.instance.hash){const{instance:e}=await C({idBase:this.idBase,instance:this.instance,number:this.number,formData:M(this.form)});this.instance=e}}if(window.jQuery){const{jQuery:e}=window;e(document).trigger("widget-added",[e(this.element)])}}catch(e){this.onError(e)}}handleFormChange(){this.idBase&&this.saveForm()}handleFormSubmit(e){e.preventDefault(),this.saveForm()}async saveForm(){const e=M(this.form);try{if(this.id){const{form:t}=await S(this.id,e);if(this.content.innerHTML=t,window.jQuery){const{jQuery:e}=window;e(document).trigger("widget-updated",[e(this.element)])}}else if(this.idBase){const{instance:t,preview:n}=await C({idBase:this.idBase,instance:this.instance,number:this.number,formData:e});this.instance=t,this.hasPreview=!B(n)}}catch(e){this.onError(e)}}get instance(){return this._instance}set instance(e){this._instance!==e&&(this._instance=e,this.onChangeInstance(e))}get hasPreview(){return this._hasPreview}set hasPreview(e){this._hasPreview!==e&&(this._hasPreview=e,this.onChangeHasPreview(e))}}let E=0;function k(e,t={},n=null){const i=document.createElement(e);for(const[e,n]of Object.entries(t))i.setAttribute(e,n);if(Array.isArray(n))for(const e of n)e&&i.appendChild(e);else"string"==typeof n&&(i.innerText=n);return i}async function S(e,t=null){let n;return n=t?await O()({path:`/wp/v2/widgets/${e}?context=edit`,method:"PUT",data:{form_data:t}}):await O()({path:`/wp/v2/widgets/${e}?context=edit`,method:"GET"}),{form:n.rendered_form}}async function C({idBase:e,instance:t,number:n,formData:i=null}){const r=await O()({path:`/wp/v2/widget-types/${e}/encode`,method:"POST",data:{instance:t,number:n,form_data:i}});return{instance:r.instance,form:r.form,preview:r.preview}}function B(e){const t=document.createElement("div");return t.innerHTML=e,T(t)}function T(e){switch(e.nodeType){case e.TEXT_NODE:return""===e.nodeValue.trim();case e.ELEMENT_NODE:return!["AUDIO","CANVAS","EMBED","IFRAME","IMG","MATH","OBJECT","SVG","VIDEO"].includes(e.tagName)&&(!e.hasChildNodes()||Array.from(e.childNodes).every(T));default:return!0}}function M(e){return new window.URLSearchParams(Array.from(new window.FormData(e))).toString()}function x({title:e,isVisible:t,id:n,idBase:i,instance:r,isWide:a,onChangeInstance:s,onChangeHasPreview:c}){const d=Object(o.useRef)(),m=Object(v.useViewportMatch)("small"),b=Object(o.useRef)(new Set),g=Object(o.useRef)(new Set),{createNotice:p}=Object(w.useDispatch)(f.store);return Object(o.useEffect)(()=>{if(g.current.has(r))return void g.current.delete(r);const e=new _({id:n,idBase:i,instance:r,onChangeInstance(e){b.current.add(r),g.current.add(e),s(e)},onChangeHasPreview:c,onError(e){window.console.error(e),p("error",Object(h.sprintf)(Object(h.__)('The "%s" block was affected by errors and may not function properly. Check the developer tools for more details.'),i||n))}});return d.current.appendChild(e.element),()=>{b.current.has(r)?b.current.delete(r):e.destroy()}},[n,i,r,s,c,m]),a&&m?Object(o.createElement)("div",{className:l()({"wp-block-legacy-widget__container":t})},t&&Object(o.createElement)("h3",{className:"wp-block-legacy-widget__edit-form-title"},e),Object(o.createElement)(u.Popover,{focusOnMount:!1,position:"middle right",__unstableForceXAlignment:!0},Object(o.createElement)("div",{ref:d,className:"wp-block-legacy-widget__edit-form",hidden:!t}))):Object(o.createElement)("div",{ref:d,className:"wp-block-legacy-widget__edit-form",hidden:!t},Object(o.createElement)("h3",{className:"wp-block-legacy-widget__edit-form-title"},e))}var P=n("Mmq9");function H({idBase:e,instance:t,isVisible:n}){const[i,r]=Object(o.useState)(!1),a=Object(v.useRefEffect)(e=>{if(i){function t(){const t=Math.max(e.contentDocument.documentElement.offsetHeight,e.contentDocument.body.offsetHeight);e.style.height=t+"px"}const{IntersectionObserver:n}=e.ownerDocument.defaultView,i=new n(([e])=>{e.isIntersecting&&t()},{threshold:1});return i.observe(e),e.addEventListener("load",t),()=>{i.disconnect(),e.removeEventListener("load",t)}}},[i]);return Object(o.createElement)(o.Fragment,null,n&&!i&&Object(o.createElement)(u.Placeholder,null,Object(o.createElement)(u.Spinner,null)),Object(o.createElement)("div",{className:l()("wp-block-legacy-widget__edit-preview",{"is-offscreen":!n||!i})},Object(o.createElement)(u.Disabled,null,Object(o.createElement)("iframe",{ref:a,className:"wp-block-legacy-widget__edit-preview-iframe",title:Object(h.__)("Legacy Widget Preview"),src:Object(P.addQueryArgs)("widgets.php",{"legacy-widget-preview":{idBase:e,instance:t}}),onLoad:e=>{e.target.contentDocument.body.style.overflow="hidden",r(!0)},height:100}))))}function I({name:e}){return Object(o.createElement)("div",{className:"wp-block-legacy-widget__edit-no-preview"},e&&Object(o.createElement)("h3",null,e),Object(o.createElement)("p",null,Object(h.__)("No preview available.")))}function V({clientId:e,rawInstance:t}){const{replaceBlocks:n}=Object(w.useDispatch)(d.store);return Object(o.createElement)(u.ToolbarButton,{onClick:()=>{t.title?n(e,[Object(r.createBlock)("core/heading",{content:t.title}),...Object(r.rawHandler)({HTML:t.text})]):n(e,Object(r.rawHandler)({HTML:t.text}))}},Object(h.__)("Convert to blocks"))}function F({attributes:{id:e,idBase:t},setAttributes:n}){return Object(o.createElement)(u.Placeholder,{icon:Object(o.createElement)(d.BlockIcon,{icon:m}),label:Object(h.__)("Legacy Widget")},Object(o.createElement)(g,{selectedId:null!=e?e:t,onSelect:({selectedId:e,isMulti:t})=>{n(e?t?{id:null,idBase:e,instance:{}}:{id:e,idBase:null,instance:null}:{id:null,idBase:null,instance:null})}}))}function L({attributes:{id:e,idBase:t,instance:n},setAttributes:i,clientId:r,isSelected:a,isWide:s=!1}){const[c,l]=Object(o.useState)(null),{widgetType:g,hasResolvedWidgetType:f,isNavigationMode:v}=Object(w.useSelect)(n=>{const i=null!=e?e:t;return{widgetType:n(b.store).getWidgetType(i),hasResolvedWidgetType:n(b.store).hasFinishedResolution("getWidgetType",[i]),isNavigationMode:n(d.store).isNavigationMode()}},[e,t]),y=Object(o.useCallback)(e=>{i({instance:e})},[]);if(!g&&f)return Object(o.createElement)(u.Placeholder,{icon:Object(o.createElement)(d.BlockIcon,{icon:m}),label:Object(h.__)("Legacy Widget")},Object(h.__)("Widget is missing."));if(!f)return Object(o.createElement)(u.Placeholder,null,Object(o.createElement)(u.Spinner,null));const j=!t||!v&&a?"edit":"preview";return Object(o.createElement)(o.Fragment,null,"text"===t&&Object(o.createElement)(d.BlockControls,{group:"other"},Object(o.createElement)(V,{clientId:r,rawInstance:n.raw})),Object(o.createElement)(d.InspectorControls,null,Object(o.createElement)(p,{name:g.name,description:g.description})),Object(o.createElement)(x,{title:g.name,isVisible:"edit"===j,id:e,idBase:t,instance:n,isWide:s,onChangeInstance:y,onChangeHasPreview:l}),t&&Object(o.createElement)(o.Fragment,null,null===c&&"preview"===j&&Object(o.createElement)(u.Placeholder,null,Object(o.createElement)(u.Spinner,null)),!0===c&&Object(o.createElement)(H,{idBase:t,instance:n,isVisible:"preview"===j}),!1===c&&"preview"===j&&Object(o.createElement)(I,{name:g.name})))}var D={to:[{block:"core/calendar",widget:"calendar"},{block:"core/search",widget:"search"},{block:"core/html",widget:"custom_html",transform:({content:e})=>({content:e})},{block:"core/archives",widget:"archives",transform:({count:e,dropdown:t})=>({displayAsDropdown:!!t,showPostCounts:!!e})},{block:"core/latest-posts",widget:"recent-posts",transform:({show_date:e,number:t})=>({displayPostDate:!!e,postsToShow:t})},{block:"core/latest-comments",widget:"recent-comments",transform:({number:e})=>({commentsToShow:e})},{block:"core/tag-cloud",widget:"tag_cloud",transform:({taxonomy:e,count:t})=>({showTagCounts:!!t,taxonomy:e})},{block:"core/categories",widget:"categories",transform:({count:e,dropdown:t,hierarchical:n})=>({displayAsDropdown:!!t,showPostCounts:!!e,showHierarchy:!!n})},{block:"core/audio",widget:"media_audio",transform:({url:e,preload:t,loop:n,attachment_id:i})=>({src:e,id:i,preload:t,loop:n})},{block:"core/video",widget:"media_video",transform:({url:e,preload:t,loop:n,attachment_id:i})=>({src:e,id:i,preload:t,loop:n})},{block:"core/image",widget:"media_image",transform:({alt:e,attachment_id:t,caption:n,height:i,link_classes:r,link_rel:o,link_target_blank:a,link_type:s,link_url:c,size:l,url:d,width:u})=>({alt:e,caption:n,height:i,id:t,link:c,linkClass:r,linkDestination:s,linkTarget:a?"_blank":void 0,rel:o,sizeSlug:l,url:d,width:u})},{block:"core/gallery",widget:"media_gallery",transform:({ids:e,link_type:t,size:n,number:i})=>({ids:e,columns:i,linkTo:t,sizeSlug:n,images:e.map(e=>({id:e}))})},{block:"core/rss",widget:"rss",transform:({url:e,show_author:t,show_date:n,show_summary:i,items:r})=>({feedURL:e,displayAuthor:!!t,displayDate:!!n,displayExcerpt:!!i,itemsToShow:r})}].map(({block:e,widget:t,transform:n})=>({type:"block",blocks:[e],isMatch:({idBase:e,instance:n})=>e===t&&!(null==n||!n.raw),transform:({instance:t})=>{var i;const o=Object(r.createBlock)(e,n?n(t.raw):void 0);return null!==(i=t.raw)&&void 0!==i&&i.title?[Object(r.createBlock)("core/heading",{content:t.raw.title}),o]:o}}))};const W={apiVersion:2,name:"core/legacy-widget",title:"Legacy Widget",category:"widgets",description:"Display a legacy widget.",textdomain:"default",attributes:{id:{type:"string",default:null},idBase:{type:"string",default:null},instance:{type:"object",default:null}},supports:{html:!1,customClassName:!1,reusable:!1},editorStyle:"wp-block-legacy-widget-editor"},{name:N}=W,A={icon:s,edit:function(e){const{id:t,idBase:n}=e.attributes,{isWide:i=!1}=e,r=Object(d.useBlockProps)({className:l()({"is-wide-widget":i})});return Object(o.createElement)("div",r,t||n?Object(o.createElement)(L,e):Object(o.createElement)(F,e))},transforms:D};var Q=Object(o.createElement)(a.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(o.createElement)(a.Path,{d:"M19.75 9c0-1.257-.565-2.197-1.39-2.858-.797-.64-1.827-1.017-2.815-1.247-1.802-.42-3.703-.403-4.383-.396L11 4.5V6l.177-.001c.696-.006 2.416-.02 4.028.356.887.207 1.67.518 2.216.957.52.416.829.945.829 1.688 0 .592-.167.966-.407 1.23-.255.281-.656.508-1.236.674-1.19.34-2.82.346-4.607.346h-.077c-1.692 0-3.527 0-4.942.404-.732.209-1.424.545-1.935 1.108-.526.579-.796 1.33-.796 2.238 0 1.257.565 2.197 1.39 2.858.797.64 1.827 1.017 2.815 1.247 1.802.42 3.703.403 4.383.396L13 19.5h.714V22L18 18.5 13.714 15v3H13l-.177.001c-.696.006-2.416.02-4.028-.356-.887-.207-1.67-.518-2.216-.957-.52-.416-.829-.945-.829-1.688 0-.592.167-.966.407-1.23.255-.281.656-.508 1.237-.674 1.189-.34 2.819-.346 4.606-.346h.077c1.692 0 3.527 0 4.941-.404.732-.209 1.425-.545 1.936-1.108.526-.579.796-1.33.796-2.238z"}));function R({currentWidgetAreaId:e,widgetAreas:t,onSelect:n}){return Object(o.createElement)(u.ToolbarGroup,null,Object(o.createElement)(u.ToolbarItem,null,i=>Object(o.createElement)(u.DropdownMenu,{icon:Q,label:Object(h.__)("Move to widget area"),toggleProps:i},({onClose:i})=>Object(o.createElement)(u.MenuGroup,{label:Object(h.__)("Move to")},Object(o.createElement)(u.MenuItemsChoice,{choices:t.map(e=>({value:e.id,label:e.name,info:e.description})),value:e,onSelect:e=>{n(e),i()}})))))}function G(e){return e.attributes.__internalWidgetId}function Z(e,t){return{...e,attributes:{...e.attributes||{},__internalWidgetId:t}}}function z(e){const t=Object(w.subscribe)(()=>{var n,i;const o=null!==(n=null==e?void 0:e.widgetTypesToHideFromLegacyWidgetBlock)&&void 0!==n?n:[],a=null===(i=Object(w.select)(b.store).getWidgetTypes({per_page:-1}))||void 0===i?void 0:i.filter(e=>!o.includes(e.id));a&&(t(),Object(w.dispatch)(r.store).addBlockVariations("core/legacy-widget",a.map(e=>({name:e.id,title:e.name,description:e.description,attributes:e.is_multi?{idBase:e.id,instance:{}}:{id:e.id}}))))})}function U(){const{metadata:e,settings:t,name:n}=i;Object(r.registerBlockType)({name:n,...e},t)}},GRId:function(e,t){e.exports=window.wp.element},HSyU:function(e,t){e.exports=window.wp.blocks},K9lf:function(e,t){e.exports=window.wp.compose},Mmq9:function(e,t){e.exports=window.wp.url},TSYQ:function(e,t,n){var i;
/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var e=[],t=0;t<arguments.length;t++){var i=arguments[t];if(i){var o=typeof i;if("string"===o||"number"===o)e.push(i);else if(Array.isArray(i)){if(i.length){var a=r.apply(null,i);a&&e.push(a)}}else if("object"===o)if(i.toString===Object.prototype.toString)for(var s in i)n.call(i,s)&&i[s]&&e.push(s);else e.push(i.toString())}}return e.join(" ")}e.exports?(r.default=r,e.exports=r):void 0===(i=function(){return r}.apply(t,[]))||(e.exports=i)}()},Tqx9:function(e,t){e.exports=window.wp.primitives},YLtl:function(e,t){e.exports=window.lodash},axFQ:function(e,t){e.exports=window.wp.blockEditor},jZUy:function(e,t){e.exports=window.wp.coreData},l3Sj:function(e,t){e.exports=window.wp.i18n},onLe:function(e,t){e.exports=window.wp.notices},"tI+e":function(e,t){e.exports=window.wp.components},ywyh:function(e,t){e.exports=window.wp.apiFetch}});