Changeset 3327590
- Timestamp:
- 07/14/2025 02:53:17 PM (9 months ago)
- Location:
- maps-block-apple
- Files:
-
- 8 edited
- 1 copied
-
tags/1.1.5 (copied) (copied from maps-block-apple/trunk)
-
tags/1.1.5/build/index.asset.php (modified) (1 diff)
-
tags/1.1.5/build/index.js (modified) (1 diff)
-
tags/1.1.5/maps-block-apple.php (modified) (2 diffs)
-
tags/1.1.5/readme.txt (modified) (3 diffs)
-
trunk/build/index.asset.php (modified) (1 diff)
-
trunk/build/index.js (modified) (1 diff)
-
trunk/maps-block-apple.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
maps-block-apple/tags/1.1.5/build/index.asset.php
r3139952 r3327590 1 <?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => ' 2a9cd3c45a01541aab07');1 <?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'df4efdfcfc810d0c567c'); -
maps-block-apple/tags/1.1.5/build/index.js
r3139952 r3327590 1 (()=>{"use strict";var e={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var o in a)e.o(a,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:a[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{isAuthenticated:()=>n});var a={};e.r(a),e.d(a,{updateAuthenticationStatus:()=>s});const o=window.wp.blocks,l=window.wp.data,i=(0,l.combineReducers)({authenticationReducer:function(e,t){return"UPDATE_AUTHENTICATION"===t.type?{...e,authenticated:t.isAuthenticated}:e}});function n(e){return Boolean(e?.authenticationReducer?.authenticated)}function s(e){return{type:"UPDATE_AUTHENTICATION",isAuthenticated:e}}const r=(0,l.createReduxStore)("tenup/maps-block-apple",{reducer:i,selectors:t,actions:a});(0,l.register)(r);const p=window.React,c=window.wp.components,m=window.wp.i18n,d=window.wp.element,u=window.wp.compose,h=window.wp.blockEditor,b=window.wp.apiFetch;var g=e.n(b);class y{constructor(e){this.element=e,this.mapOptions={},this.markerElements=this.element.querySelectorAll(".marker-annotation"),this.markers=[...this.markerElements].map((e=>{const{latitude:t,longitude:a,title:o,subtitle:l,color:i,glyphColor:n,glyphImage:s}=e.dataset;return{latitude:Number(t),longitude:Number(a),title:o||"",subtitle:l||"",color:i||null,glyphColor:n||null,glyphImage:s||null}})),this.mapkit=e.ownerDocument.defaultView.mapkit,this.mapkit&&this.init()}init(){this.createMap(),this.addMarkers(this.markers)}createMap(){const{mapType:e,latitude:t,longitude:a,rotation:o,zoom:l,showsMapTypeControl:i=!0,isRotationEnabled:n=!0,showsCompass:s,isZoomEnabled:r=!0,showsZoomControl:p=!0,isScrollEnabled:c=!0,showsScale:m}=this.element.dataset,d=new this.mapkit.Coordinate(Number(t)||51.48762585296625,Number(a)||-.1326724377053381);this.mapOptions={center:d,rotation:Number(o)||0,mapType:e||this.mapkit.Map.MapTypes.Satellite,showsMapTypeControl:"true"===i,isRotationEnabled:"true"===n,isZoomEnabled:"true"===r,showsZoomControl:"true"===p,isScrollEnabled:"true"===c,showsScale:m||this.mapkit.FeatureVisibility.Adaptive},this.mapOptions.isRotationEnabled&&(this.mapOptions.showsCompass=s||this.mapkit.FeatureVisibility.Adaptive),this.map=new this.mapkit.Map(this.element,this.mapOptions),this.map._impl.zoomLevel=Number(l)||15}addMarkers(e){this.clearMarkers();const t=[];e.forEach(((a,o)=>{const{latitude:l,longitude:i,title:n,subtitle:s,titleVisibility:r,subtitleVisibility:p,color:c,glyphColor:m,glyphText:d,glyphImage:u}=a,h=new this.mapkit.Coordinate(Number(l),Number(i)),b={title:n,subtitle:s||null,titleVisibility:r||this.mapkit.FeatureVisibility.Visible,subtitleVisibility:p||this.mapkit.FeatureVisibility.Visible,color:c||"green",glyphColor:m||"white",glyphText:d||"",draggable:!!this.isEditor};u&&(b.glyphImage={1:u});const g=new this.mapkit.MarkerAnnotation(h,b);this.setAttributes&&g.addEventListener("drag-end",(t=>{const{target:{coordinate:a}}=t,l=[...e];l[o].latitude=a.latitude,l[o].longitude=a.longitude,this.setAttributes({markers:l})})),t.push(g)})),this.map.addAnnotations(t)}clearMarkers(){this.map.removeAnnotations(this.map.annotations)}static authenticateMap(e){g()({path:"MapsBlockApple/v1/GetJWT/"}).then((()=>{e.init({authorizationCallback(e){g()({path:"MapsBlockApple/v1/GetJWT/"}).then(e)}})})).catch((t=>{(0,l.dispatch)("core/notices").createErrorNotice(t.message,{isDismissible:!0,type:"snackbar"}),e.dispatchEvent(new Event("error"))}))}}class k extends y{constructor(e,t,a){super(e),this.isEditor=!0,this.clientId=t,this.setAttributes=a,this.initEdit()}initEdit(){this.addListeners(),this.addMarkers(this.markers)}destroy(){this.map&&this.map.destroy()}addListeners(){this.map.element.addEventListener("click",(()=>{(0,l.dispatch)("core/block-editor").selectBlock(this.clientId)})),this.map.addEventListener("map-type-change",(()=>{this.setAttributes({mapType:this.map.mapType})})),this.map.addEventListener("region-change-end",(()=>{this.setAttributes({rotation:this.map.rotation,latitude:this.map.center.latitude,longitude:this.map.center.longitude,zoom:this.map._impl.zoomLevel})}))}update(e){const{mapType:t,latitude:a,longitude:o,rotation:l,zoom:i,showsMapTypeControl:n,isRotationEnabled:s,showsCompass:r,isZoomEnabled:p,showsZoomControl:c,isScrollEnabled:m,showsScale:d,region:u,height:h}=e;h&&(this.element.style.height=`${h}px`),this.map&&(u&&""!==u&&this.map.setRegionAnimated(u,!0),t&&t!==this?.map?.mapType&&(this.map.mapType=e.mapType),i&&i!==this.map?._impl?.zoomLevel&&(this.map._impl.zoomLevel=i),l&&l!==this?.map?.rotation&&this.map.setRotationAnimated(Number(l)),a&&o&&(a!==this?.map?.center?.latitude||o!==this?.map?.center?.longitude)&&this.map.setCenterAnimated(new this.mapkit.Coordinate(a,o)),void 0!==n&&n!==this?.map?.showsMapTypeControl&&(this.map.showsMapTypeControl=!!n),void 0!==s&&s!==this?.map?.isRotationEnabled&&(this.map.isRotationEnabled=!!s),r!==this?.map?.showsCompass&&this.map.isRotationEnabled&&(this.map.showsCompass=r||this.mapkit.FeatureVisibility.Adaptive),void 0!==p&&p!==this?.map?.isZoomEnabled&&(this.map.isZoomEnabled=!!p),void 0!==c&&c!==this?.map?.showsZoomControl&&(this.map.showsZoomControl=!!c),void 0!==m&&m!==this?.map?.isScrollEnabled&&(this.map.isScrollEnabled=!!m),d!==this?.map?.showsScale&&(this.map.showsScale=d||this.mapkit.FeatureVisibility.Adaptive))}}const E=Object.keys(mapkit.Map.MapTypes).map((e=>({label:"MutedStandard"===e?(0,m.__)("Muted","maps-block-apple"):e,value:mapkit.Map.MapTypes[e]}))),_=Object.keys(mapkit.FeatureVisibility).map((e=>({label:e,value:mapkit.FeatureVisibility[e]})));function w(){const[e,t]=(0,d.useState)(""),[a,o]=(0,d.useState)(""),[i,n]=(0,d.useState)(""),[s,r]=(0,d.useState)(!1),u=(0,l.useSelect)((e=>e("core").getEntityRecord("root","site")),[]);return(0,d.useEffect)((()=>{if(u){const{maps_block_apple:{private_key:e,team_id:a,key_id:l}}=u;t(e),o(l),n(a)}}),[u]),(0,p.createElement)(p.Fragment,null,(0,p.createElement)(c.TextareaControl,{label:(0,m.__)("Please enter your Private Key","maps-block-apple"),readOnly:s,name:"private_key",value:e,onChange:e=>t(e)}),(0,p.createElement)(c.TextControl,{label:(0,m.__)("Please enter your Key ID","maps-block-apple"),readOnly:s,name:"key_id",value:a,onChange:e=>o(e)}),(0,p.createElement)(c.TextControl,{label:(0,m.__)("Please enter your Team ID","maps-block-apple"),readOnly:s,name:"team_id",value:i,onChange:e=>n(e)}),(0,p.createElement)(c.Button,{isPrimary:!0,disabled:s,isBusy:s,onClick:()=>{r(!0),(0,l.dispatch)("core").saveEntityRecord("root","site",{maps_block_apple:{private_key:e,team_id:i,key_id:a}}).then((({maps_block_apple:{private_key:e,team_id:a,key_id:l}})=>{t(e),o(l),n(a),r(!1),mapkit.dispatchEvent(new CustomEvent("reinitialize"))})).catch((e=>{(0,l.dispatch)("core/notices").createErrorNotice(e.message,{isDismissible:!0,type:"snackbar"}),r(!1)}))}},(0,m.__)("Confirm MapKit Credentials","maps-block-apple")))}function v(e){const{attributes:{mapType:t,height:a,zoom:o,showsMapTypeControl:l,isRotationEnabled:i,showsCompass:n,isZoomEnabled:s,showsZoomControl:r,isScrollEnabled:d,showsScale:u},setAttributes:h}=e;return(0,p.createElement)(c.PanelBody,{title:(0,m.__)("Display Settings","maps-block-apple")},(0,p.createElement)(c.__experimentalToggleGroupControl,{label:(0,m.__)("Map Type","maps-block-apple"),isBlock:!0,isAdaptiveWidth:!0,value:t,onChange:e=>h({mapType:e})},E.map((e=>(0,p.createElement)(c.__experimentalToggleGroupControlOption,{...e,key:e.value})))),(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Show Map Type Control","maps-block-apple"),checked:l,onChange:e=>h({showsMapTypeControl:e})}),(0,p.createElement)(c.RangeControl,{label:(0,m.__)("Zoom","maps-block-apple"),value:o,onChange:e=>h({zoom:e}),min:0,max:20,step:.5}),(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Zoom Enabled","maps-block-apple"),checked:s,onChange:e=>h({isZoomEnabled:e})}),s&&(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Show Zoom Control","maps-block-apple"),checked:r,onChange:e=>h({showsZoomControl:e})}),(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Rotation Enabled","maps-block-apple"),checked:i,onChange:e=>h({isRotationEnabled:e})}),i&&(0,p.createElement)(c.__experimentalToggleGroupControl,{label:(0,m.__)("Compass Visibility","maps-block-apple"),isBlock:!0,value:n,onChange:e=>h({showsCompass:e})},_.map((e=>(0,p.createElement)(c.__experimentalToggleGroupControlOption,{...e,key:e.value})))),(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Scroll Enabled","maps-block-apple"),checked:d,onChange:e=>h({isScrollEnabled:e})}),(0,p.createElement)(c.__experimentalToggleGroupControl,{label:(0,m.__)("Scale Visibility","maps-block-apple"),value:u,isBlock:!0,onChange:e=>h({showsScale:e})},_.map((e=>(0,p.createElement)(c.__experimentalToggleGroupControlOption,{...e,key:e.value})))),(0,p.createElement)(c.TextControl,{label:(0,m.__)("Height ( pixels )","maps-block-apple"),value:a,onChange:e=>h({height:e})}))}function C(e){const{searchResults:t,setSearchResults:a,setAttributes:o,map:l}=e;if(0===t.length)return null;const i=e=>{const i=t[e];o({address:i.formattedAddress}),l.update({region:i.region}),a([])};return(0,p.createElement)(c.Popover,{focusOnMount:!1,noArrow:!1,position:"bottom right"},(0,p.createElement)(c.NavigableMenu,{style:{width:"250px",margin:"6px"},onNavigate:i},(0,p.createElement)("ul",null,t.map(((e,t)=>(0,p.createElement)("li",{key:e.muid},(0,p.createElement)(c.Button,{onClick:()=>i(t),style:{borderRadius:"4px",textAlign:"start",width:"100%"}},e.formattedAddress)))))))}function f({latitude:e,longitude:t}){return(0,p.createElement)(p.Fragment,null,(0,p.createElement)("p",null,(0,m.__)("Coordinates: ","maps-block-apple"),`${e.toFixed(4)}, ${t.toFixed(4)}`))}function S(e){const{map:t,mapkit:a,attributes:{latitude:o,longitude:l,address:i},setAttributes:n}=e,[s,r]=(0,d.useState)([]),[u,h]=(0,d.useState)([]);if((0,d.useEffect)((()=>{r("")}),[i]),!a)return null;const b=new a.Geocoder,g=(e,t)=>{t.results&&h(t.results)};return(0,p.createElement)(c.PanelBody,{title:(0,m.__)("Location Settings","maps-block-apple")},(0,p.createElement)("div",null,(0,p.createElement)(c.SearchControl,{label:(0,m.__)("Search for a Location","maps-block-apple"),value:s,onChange:e=>{e?b.lookup(e,g):h([]),r(e)}}),(0,p.createElement)(C,{map:t,setAttributes:n,searchResults:u,setSearchResults:h})),(0,p.createElement)(f,{latitude:o,longitude:l}))}function T(e){const{marker:t,update:a}=e,o=["image"],l=e=>{a({...t,glyphImageId:e.id,glyphImage:e.url})};return(0,p.createElement)("div",{className:"maps-block-apple-marker-uploader"},(0,p.createElement)(c.BaseControl,{id:"marker-icon-control",label:(0,m.__)("Marker Icon","maps-block-apple")},(0,p.createElement)(h.MediaUploadCheck,null,(0,p.createElement)(h.MediaUpload,{allowedTypes:o,render:({open:e})=>(0,p.createElement)(c.Button,{className:t.glyphImageId?"editor-post-featured-image__preview":"editor-post-featured-image__toggle",onClick:e},!t.glyphImageId&&(0,m.__)("Choose an icon","maps-block-apple"),t.glyphImageId&&t.glyphImage&&(0,p.createElement)("img",{src:t.glyphImage,alt:(0,m.__)("Marker icon","maps-block-apple")})),onSelect:l,value:t.glyphImageId})),!!t.glyphImageId&&(0,p.createElement)(h.MediaUploadCheck,null,t.glyphImage&&(0,p.createElement)(h.MediaUpload,{onSelect:l,allowedTypes:o,render:({open:e})=>(0,p.createElement)(c.Button,{onClick:e,variant:"secondary",className:"replace-marker-icon"},(0,m.__)("Replace icon","maps-block-apple"))}),(0,p.createElement)(c.Button,{className:"remove-marker-icon",onClick:()=>{a({...t,glyphImageId:void 0,glyphImage:void 0})},variant:"link",isDestructive:!0},(0,m.__)("Remove icon","maps-block-apple")))))}function M(e){const{marker:t,remove:a,update:o}=e,i=(0,l.useSelect)((e=>e("core/block-editor").getSettings().colors));return(0,p.createElement)(c.PanelBody,{title:t.title,className:"marker-edit",icon:"location",initialOpen:!1},(0,p.createElement)(c.TextControl,{label:(0,m.__)("Title","maps-block-apple"),value:t.title,onChange:e=>o({...t,title:e})}),(0,p.createElement)(c.TextControl,{label:(0,m.__)("Subtitle","maps-block-apple"),value:t.subtitle,onChange:e=>o({...t,subtitle:e})}),(0,p.createElement)(c.PanelRow,null,(0,p.createElement)("label",{htmlFor:"marker-color-control"},(0,m.__)("Marker Color","maps-block-apple")),(0,p.createElement)(c.ColorIndicator,{id:"marker-color-control",colorValue:t.color})),(0,p.createElement)(c.ColorPalette,{value:t.color,colors:i,onChange:e=>o({...t,color:e})}),(0,p.createElement)(c.PanelRow,null,(0,p.createElement)("label",{htmlFor:"glyph-color-control"},(0,m.__)("Icon Color","maps-block-apple")),(0,p.createElement)(c.ColorIndicator,{id:"glyph-color-control",colorValue:t.glyphColor})),(0,p.createElement)(c.ColorPalette,{value:t.glyphColor,colors:i,onChange:e=>o({...t,glyphColor:e})}),(0,p.createElement)(T,{marker:t,update:o}),(0,p.createElement)(c.PanelRow,null,(0,p.createElement)(f,{latitude:t.latitude,longitude:t.longitude})),(0,p.createElement)(c.PanelRow,null,(0,p.createElement)(c.Button,{isLink:!0,icon:"no",isDestructive:!0,onClick:a},(0,m.__)("Remove Marker","maps-block-apple"))))}function A(e){const{attributes:{markers:t},setAttributes:a}=e,o=e=>o=>{const l=[...t];l[e]=o,a({markers:l})},l=e=>()=>{const o=[...t];o.splice(e,1),a({markers:o})};return t.length?(0,p.createElement)(c.PanelBody,{title:(0,m.__)("Marker Settings","apple-maps-wordpress")},t.map(((e,t)=>(0,p.createElement)(M,{key:t,marker:e,update:o(t),remove:l(t)}))),(0,p.createElement)(c.Tip,null,(0,m.__)("You can move a marker by long pressing on it.","maps-block-apple"))):null}function R(e){const{isAuthenticated:t}=e;return t?(0,p.createElement)(h.InspectorControls,null,(0,p.createElement)(S,{...e}),(0,p.createElement)(v,{...e}),(0,p.createElement)(A,{...e})):(0,p.createElement)(h.InspectorControls,null,(0,p.createElement)(c.PanelBody,null,(0,p.createElement)("p",null,(0,m.__)("You need to confirm your access to Apple Maps before you can continue.","maps-block-apple"))))}function I({children:e,fallback:t}){return(0,l.useSelect)((e=>e("core").canUser("update","settings")))?e:t||null}const z=function(){return(0,p.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"none",viewBox:"0 0 40 52"},(0,p.createElement)("path",{fill:"#333",fillRule:"evenodd",d:"M37.15 9.802c0 4.936-3.698 9.05-8.46 9.709v11.854l-1.304 3.92-1.303-3.92V19.521c-4.8-.626-8.536-4.757-8.536-9.72 0-5.39 4.41-9.801 9.802-9.801 5.39 0 9.801 4.41 9.801 9.802zm-15.224-2.38c.74.633 2.088.274 3.01-.802.922-1.077 1.068-2.464.327-3.098-.74-.634-2.088-.275-3.01.802-.921 1.076-1.068 2.463-.327 3.097z",clipRule:"evenodd"}),(0,p.createElement)("path",{fill:"#333",d:"M12.85 25l11.277 3.776v2.589l3.26 8.821 3.258-8.821v-2.483L40 25v21.736l-12.124 4.93-15.026-4.93L0 51.666V30.032L12.85 25z"}))},x={top:!1,right:!1,bottom:!0,left:!1,topRight:!1,bottomRight:!1,bottomLeft:!1,topLeft:!1};function B({onResizeStart:e,onResize:t,onResizeStop:a,...o}){const[l,i]=(0,d.useState)(!1);return(0,p.createElement)(c.ResizableBox,{style:{position:"absolute",top:0,left:0,right:0,bottom:0},className:"apple-maps-block__resize-container "+(l?"is-resizing":""),enable:x,onResizeStart:(a,o,l)=>{e(l.clientHeight),t(l.clientHeight)},onResize:(e,a,o)=>{t(o.clientHeight),l||i(!0)},onResizeStop:(e,t,o)=>{a(o.clientHeight),i(!1)},minHeight:100,...o})}const P=(0,d.memo)((e=>{const{map:t,isAuthenticated:a,clientId:o,setAttributes:l,setMap:i,mapkit:n}=e,s=!!t,r=(0,u.useRefEffect)((e=>{if(n)return a&&!s&&i(new k(e,o,l)),()=>{s&&(t.destroy(),i(null))}}),[n,a,t,o,l]);return(0,p.createElement)("div",{ref:r})})),N=JSON.parse('{"name":"tenup/maps-block-apple","title":"Apple Maps","category":"embed","description":"Add an Apple Map to your site.","apiVersion":3,"keywords":["apple","map","apple map"],"attributes":{"address":{"type":"string","default":""},"height":{"type":"string","default":"450"},"latitude":{"type":"number","default":51.48762585296625},"longitude":{"type":"number","default":-0.1326724377053381},"rotation":{"type":"number","default":0},"zoom":{"type":"number","default":15},"mapType":{"type":"string","default":"standard"},"showsMapTypeControl":{"type":"boolean","default":true},"isRotationEnabled":{"type":"boolean","default":true},"showsCompass":{"type":"string","default":"adaptive"},"isZoomEnabled":{"type":"boolean","default":true},"showsZoomControl":{"type":"boolean","default":true},"isScrollEnabled":{"type":"boolean","default":true},"showsScale":{"type":"string","default":"adaptive"},"markers":{"type":"array","default":[]}},"example":{"attributes":{"latitude":51.48762585296625,"longitude":-0.1326724377053381}},"supports":{"align":["wide","full"],"spacing":{"margin":true},"html":false},"editorScript":"maps-block-apple-block","viewScript":"maps-block-apple-frontend","editorStyle":"file:build/index.css"}'),{Map:L,FeatureVisibility:V}=mapkit,O=[{attributes:{...N.attributes,mapType:{type:"string",default:L.MapTypes.Standard},showsCompass:{type:"string",default:V.Adaptive},showsScale:{type:"string",default:V.Adaptive}},save(e){const{attributes:{mapType:t,height:a,latitude:o,longitude:l,rotation:i,zoom:n,showsMapTypeControl:s,isRotationEnabled:r,showsCompass:c,isZoomEnabled:m,showsZoomControl:d,isScrollEnabled:u,showsScale:b,markers:g}}=e,y=h.useBlockProps.save();return(0,p.createElement)("div",{...y,"data-map-type":t,"data-latitude":o,"data-longitude":l,"data-rotation":i,"data-zoom":n,"data-shows-map-type-control":s,"data-is-rotation-enabled":r,"data-shows-compass":c,"data-is-zoom-enabled":m,"data-shows-zoom-control":d,"data-is-scroll-enabled":u,"data-shows-scale":b,style:{height:`${a}px`}},g.map(((e,t)=>(0,p.createElement)("div",{key:t,className:"marker-annotation","data-latitude":e.latitude,"data-longitude":e.longitude,"data-title":e.title,"data-subtitle":e.subtitle,"data-color":e.color,"data-glyph-color":e.glyphColor}))))}}],{Map:Z,FeatureVisibility:F}=mapkit;(0,o.registerBlockType)(N,{icon:z,attributes:{...N.attributes,mapType:{type:"string",default:Z.MapTypes.Standard},showsCompass:{type:"string",default:F.Adaptive},showsScale:{type:"string",default:F.Adaptive}},edit:function(e){const{attributes:t,setAttributes:a,clientId:o,isSelected:i}=e,{height:n,latitude:s,longitude:b,markers: g}=t,[y,E]=(0,d.useState)(null),[_,v]=(0,d.useState)(null),C=!!y,f=(0,l.useSelect)((e=>e(r).isAuthenticated())),[S,T]=(0,d.useState)(!0),{updateAuthenticationStatus:M}=(0,l.useDispatch)(r),{toggleSelection:A}=(0,l.useDispatch)(h.store),x=(0,u.useRefEffect)((e=>{const t=e.ownerDocument.defaultView.mapkit;if(!t)return void v(null);v(t);const a=({status:e})=>{switch(e){case"Initialized":case"Refreshed":T(!1),M(!0)}};t.addEventListener("configuration-change",a);const o=()=>{T(!1),M(!1)};t.addEventListener("error",o);const l=()=>{k.authenticateMap(t)};return t.addEventListener("reinitialize",l),f||l(),()=>{t.removeEventListener("configuration-change",a),t.removeEventListener("error",o),t.removeEventListener("reinitialize",l),v(null)}}));(0,d.useEffect)((()=>{f&&T(!1)}),[f]),(0,d.useEffect)((()=>{f&&C&&y.update(t)}),[t,f,y]);const N=(0,u.useDebounce)((e=>{C&&y.addMarkers(e)}),300);(0,d.useEffect)((()=>N(g)),[g]);const L=(0,h.useBlockProps)({ref:x});return S?(0,p.createElement)("div",{...L},(0,p.createElement)(c.Placeholder,{style:{height:`${n}px`},label:(0,m.__)("Block for Apple Maps","maps-block-apple"),icon:z},(0,p.createElement)(c.Spinner,null))):f?(0,p.createElement)(p.Fragment,null,(0,p.createElement)(h.BlockControls,null,(0,p.createElement)(c.ToolbarGroup,null,(0,p.createElement)(c.ToolbarButton,{icon:"location",title:(0,m.__)("Add Marker","apple-maps-wordpress"),onClick:()=>{a({markers:[...g,{latitude:s,longitude:b,title:"Title",id:Symbol("identifier for the marker")}]})}}))),(0,p.createElement)(R,{...e,isAuthenticated:f,map:y,mapkit:_}),(0,p.createElement)("div",{...L},(0,p.createElement)(B,{onResizeStart:()=>{A(!1)},onResize:e=>{y.update({height:e})},onResizeStop:e=>{a({height:e}),A(!0)},showHandle:i,size:{height:n}}),(0,p.createElement)(P,{map:y,setMap:E,isAuthenticated:f,clientId:o,setAttributes:a,mapkit:_}))):(0,p.createElement)(p.Fragment,null,(0,p.createElement)(R,{...e,isAuthenticated:f,map:y,mapkit:_}),(0,p.createElement)("div",{...L},(0,p.createElement)(c.Placeholder,{style:{minHeight:`${n}px`},label:(0,m.__)("Confirm access to Apple Maps","maps-block-apple"),icon:z,isColumnLayout:!0},(0,p.createElement)(I,{fallback:(0,m.__)("Sorry, you are not allowed to do that. Please talk to your Administrator.","maps-block-apple")},(0,p.createElement)("div",{style:{marginBottom:"1em"}},(0,m.__)("In order to include an Apple Map on your website you need to confirm your MapKit credentials below. Here is documentation on how to get those credentials: ","maps-block-apple"),(0,p.createElement)("a",{href:"https://developer.apple.com/documentation/mapkitjs/setting_up_mapkit_js",target:"_blank",rel:"noopener noreferrer"},(0,m.__)("Instructions for creating your MapKit credentials.","maps-block-apple"))),(0,p.createElement)(w,null)))))},save:function(e){const{attributes:{mapType:t,height:a,latitude:o,longitude:l,rotation:i,zoom:n,showsMapTypeControl:s,isRotationEnabled:r,showsCompass:c,isZoomEnabled:m,showsZoomControl:d,isScrollEnabled:u,showsScale:b,markers:g}}=e,y=h.useBlockProps.save({style:{height:`${a}px`}});return(0,p.createElement)("div",{...y,"data-map-type":t,"data-latitude":o,"data-longitude":l,"data-rotation":i,"data-zoom":n,"data-shows-map-type-control":s,"data-is-rotation-enabled":r,"data-shows-compass":c,"data-is-zoom-enabled":m,"data-shows-zoom-control":d,"data-is-scroll-enabled":u,"data-shows-scale":b},g.map(((e,t)=>(0,p.createElement)("div",{key:t,className:"marker-annotation","data-latitude":e.latitude,"data-longitude":e.longitude,"data-title":e.title,"data-subtitle":e.subtitle,"data-color":e.color,"data-glyph-color":e.glyphColor,"data-glyph-image":e.glyphImage}))))},deprecated:O})})();1 (()=>{"use strict";var e={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var o in a)e.o(a,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:a[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{isAuthenticated:()=>n});var a={};e.r(a),e.d(a,{updateAuthenticationStatus:()=>s});const o=window.wp.blocks,l=window.wp.data,i=(0,l.combineReducers)({authenticationReducer:function(e,t){return"UPDATE_AUTHENTICATION"===t.type?{...e,authenticated:t.isAuthenticated}:e}});function n(e){return Boolean(e?.authenticationReducer?.authenticated)}function s(e){return{type:"UPDATE_AUTHENTICATION",isAuthenticated:e}}const r=(0,l.createReduxStore)("tenup/maps-block-apple",{reducer:i,selectors:t,actions:a});(0,l.register)(r);const p=window.React,c=window.wp.components,m=window.wp.i18n,d=window.wp.element,u=window.wp.compose,h=window.wp.blockEditor,b=window.wp.apiFetch;var g=e.n(b);class y{constructor(e){this.element=e,this.mapOptions={},this.markerElements=this.element.querySelectorAll(".marker-annotation"),this.markers=[...this.markerElements].map((e=>{const{latitude:t,longitude:a,title:o,subtitle:l,color:i,glyphColor:n,glyphImage:s}=e.dataset;return{latitude:Number(t),longitude:Number(a),title:o||"",subtitle:l||"",color:i||null,glyphColor:n||null,glyphImage:s||null}})),this.mapkit=e.ownerDocument.defaultView.mapkit,this.mapkit&&this.init()}init(){this.createMap(),this.addMarkers(this.markers)}createMap(){const{mapType:e,latitude:t,longitude:a,rotation:o,zoom:l,showsMapTypeControl:i=!0,isRotationEnabled:n=!0,showsCompass:s,isZoomEnabled:r=!0,showsZoomControl:p=!0,isScrollEnabled:c=!0,showsScale:m}=this.element.dataset,d=new this.mapkit.Coordinate(Number(t)||51.48762585296625,Number(a)||-.1326724377053381);this.mapOptions={center:d,rotation:Number(o)||0,mapType:e||this.mapkit.Map.MapTypes.Satellite,showsMapTypeControl:"true"===i,isRotationEnabled:"true"===n,isZoomEnabled:"true"===r,showsZoomControl:"true"===p,isScrollEnabled:"true"===c,showsScale:m||this.mapkit.FeatureVisibility.Adaptive},this.mapOptions.isRotationEnabled&&(this.mapOptions.showsCompass=s||this.mapkit.FeatureVisibility.Adaptive),this.map=new this.mapkit.Map(this.element,this.mapOptions),this.map._impl.zoomLevel=Number(l)||15}addMarkers(e){this.clearMarkers();const t=[];e.forEach(((a,o)=>{const{latitude:l,longitude:i,title:n,subtitle:s,titleVisibility:r,subtitleVisibility:p,color:c,glyphColor:m,glyphText:d,glyphImage:u}=a,h=new this.mapkit.Coordinate(Number(l),Number(i)),b={title:n,subtitle:s||null,titleVisibility:r||this.mapkit.FeatureVisibility.Visible,subtitleVisibility:p||this.mapkit.FeatureVisibility.Visible,color:c||"green",glyphColor:m||"white",glyphText:d||"",draggable:!!this.isEditor};u&&(b.glyphImage={1:u});const g=new this.mapkit.MarkerAnnotation(h,b);this.setAttributes&&g.addEventListener("drag-end",(t=>{const{target:{coordinate:a}}=t,l=[...e];l[o].latitude=a.latitude,l[o].longitude=a.longitude,this.setAttributes({markers:l})})),t.push(g)})),this.map.addAnnotations(t)}clearMarkers(){this.map.removeAnnotations(this.map.annotations)}static authenticateMap(e){g()({path:"MapsBlockApple/v1/GetJWT/"}).then((()=>{e.init({authorizationCallback(e){g()({path:"MapsBlockApple/v1/GetJWT/"}).then(e)}})})).catch((t=>{(0,l.dispatch)("core/notices").createErrorNotice(t.message,{isDismissible:!0,type:"snackbar"}),e.dispatchEvent(new Event("error"))}))}}class k extends y{constructor(e,t,a){super(e),this.isEditor=!0,this.clientId=t,this.setAttributes=a,this.initEdit()}initEdit(){this.addListeners(),this.addMarkers(this.markers)}destroy(){this.map&&this.map.destroy()}addListeners(){this.map.element.addEventListener("click",(()=>{(0,l.dispatch)("core/block-editor").selectBlock(this.clientId)})),this.map.addEventListener("map-type-change",(()=>{this.setAttributes({mapType:this.map.mapType})})),this.map.addEventListener("region-change-end",(()=>{this.setAttributes({rotation:this.map.rotation,latitude:this.map.center.latitude,longitude:this.map.center.longitude,zoom:this.map._impl.zoomLevel})}))}update(e){const{mapType:t,latitude:a,longitude:o,rotation:l,zoom:i,showsMapTypeControl:n,isRotationEnabled:s,showsCompass:r,isZoomEnabled:p,showsZoomControl:c,isScrollEnabled:m,showsScale:d,region:u,height:h}=e;h&&(this.element.style.height=`${h}px`),this.map&&(u&&""!==u&&this.map.setRegionAnimated(u,!0),t&&t!==this?.map?.mapType&&(this.map.mapType=e.mapType),i&&i!==this.map?._impl?.zoomLevel&&(this.map._impl.zoomLevel=i),l&&l!==this?.map?.rotation&&this.map.setRotationAnimated(Number(l)),a&&o&&(a!==this?.map?.center?.latitude||o!==this?.map?.center?.longitude)&&this.map.setCenterAnimated(new this.mapkit.Coordinate(a,o)),void 0!==n&&n!==this?.map?.showsMapTypeControl&&(this.map.showsMapTypeControl=!!n),void 0!==s&&s!==this?.map?.isRotationEnabled&&(this.map.isRotationEnabled=!!s),r!==this?.map?.showsCompass&&this.map.isRotationEnabled&&(this.map.showsCompass=r||this.mapkit.FeatureVisibility.Adaptive),void 0!==p&&p!==this?.map?.isZoomEnabled&&(this.map.isZoomEnabled=!!p),void 0!==c&&c!==this?.map?.showsZoomControl&&(this.map.showsZoomControl=!!c),void 0!==m&&m!==this?.map?.isScrollEnabled&&(this.map.isScrollEnabled=!!m),d!==this?.map?.showsScale&&(this.map.showsScale=d||this.mapkit.FeatureVisibility.Adaptive))}}const E=Object.keys(mapkit.Map.MapTypes).map((e=>({label:"MutedStandard"===e?(0,m.__)("Muted","maps-block-apple"):e,value:mapkit.Map.MapTypes[e]}))),_=Object.keys(mapkit.FeatureVisibility).map((e=>({label:e,value:mapkit.FeatureVisibility[e]})));function w(){const[e,t]=(0,d.useState)(""),[a,o]=(0,d.useState)(""),[i,n]=(0,d.useState)(""),[s,r]=(0,d.useState)(!1),u=(0,l.useSelect)((e=>e("core").getEntityRecord("root","site")),[]);return(0,d.useEffect)((()=>{if(u){const{maps_block_apple:{private_key:e,team_id:a,key_id:l}}=u;t(e),o(l),n(a)}}),[u]),(0,p.createElement)(p.Fragment,null,(0,p.createElement)(c.TextareaControl,{label:(0,m.__)("Please enter your Private Key","maps-block-apple"),readOnly:s,name:"private_key",value:e,onChange:e=>t(e)}),(0,p.createElement)(c.TextControl,{label:(0,m.__)("Please enter your Key ID","maps-block-apple"),readOnly:s,name:"key_id",value:a,onChange:e=>o(e)}),(0,p.createElement)(c.TextControl,{label:(0,m.__)("Please enter your Team ID","maps-block-apple"),readOnly:s,name:"team_id",value:i,onChange:e=>n(e)}),(0,p.createElement)(c.Button,{isPrimary:!0,disabled:s,isBusy:s,onClick:()=>{r(!0),(0,l.dispatch)("core").saveEntityRecord("root","site",{maps_block_apple:{private_key:e,team_id:i,key_id:a}}).then((({maps_block_apple:{private_key:e,team_id:a,key_id:l}})=>{t(e),o(l),n(a),r(!1),mapkit.dispatchEvent(new CustomEvent("reinitialize"))})).catch((e=>{(0,l.dispatch)("core/notices").createErrorNotice(e.message,{isDismissible:!0,type:"snackbar"}),r(!1)}))}},(0,m.__)("Confirm MapKit Credentials","maps-block-apple")))}function v(e){const{attributes:{mapType:t,height:a,zoom:o,showsMapTypeControl:l,isRotationEnabled:i,showsCompass:n,isZoomEnabled:s,showsZoomControl:r,isScrollEnabled:d,showsScale:u},setAttributes:h}=e;return(0,p.createElement)(c.PanelBody,{title:(0,m.__)("Display Settings","maps-block-apple")},(0,p.createElement)(c.__experimentalToggleGroupControl,{label:(0,m.__)("Map Type","maps-block-apple"),isBlock:!0,isAdaptiveWidth:!0,value:t,onChange:e=>h({mapType:e})},E.map((e=>(0,p.createElement)(c.__experimentalToggleGroupControlOption,{...e,key:e.value})))),(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Show Map Type Control","maps-block-apple"),checked:l,onChange:e=>h({showsMapTypeControl:e})}),(0,p.createElement)(c.RangeControl,{label:(0,m.__)("Zoom","maps-block-apple"),value:o,onChange:e=>h({zoom:e}),min:0,max:20,step:.5}),(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Zoom Enabled","maps-block-apple"),checked:s,onChange:e=>h({isZoomEnabled:e})}),s&&(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Show Zoom Control","maps-block-apple"),checked:r,onChange:e=>h({showsZoomControl:e})}),(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Rotation Enabled","maps-block-apple"),checked:i,onChange:e=>h({isRotationEnabled:e})}),i&&(0,p.createElement)(c.__experimentalToggleGroupControl,{label:(0,m.__)("Compass Visibility","maps-block-apple"),isBlock:!0,value:n,onChange:e=>h({showsCompass:e})},_.map((e=>(0,p.createElement)(c.__experimentalToggleGroupControlOption,{...e,key:e.value})))),(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Scroll Enabled","maps-block-apple"),checked:d,onChange:e=>h({isScrollEnabled:e})}),(0,p.createElement)(c.__experimentalToggleGroupControl,{label:(0,m.__)("Scale Visibility","maps-block-apple"),value:u,isBlock:!0,onChange:e=>h({showsScale:e})},_.map((e=>(0,p.createElement)(c.__experimentalToggleGroupControlOption,{...e,key:e.value})))),(0,p.createElement)(c.TextControl,{label:(0,m.__)("Height ( pixels )","maps-block-apple"),value:a,onChange:e=>h({height:e})}))}function C(e){const{searchResults:t,setSearchResults:a,setAttributes:o,map:l}=e;if(0===t.length)return null;const i=e=>{const i=t[e];o({address:i.formattedAddress}),l.update({region:i.region}),a([])};return(0,p.createElement)(c.Popover,{focusOnMount:!1,noArrow:!1,position:"bottom right"},(0,p.createElement)(c.NavigableMenu,{style:{width:"250px",margin:"6px"},onNavigate:i},(0,p.createElement)("ul",null,t.map(((e,t)=>(0,p.createElement)("li",{key:e.muid},(0,p.createElement)(c.Button,{onClick:()=>i(t),style:{borderRadius:"4px",textAlign:"start",width:"100%"}},e.formattedAddress)))))))}function f({latitude:e,longitude:t}){return(0,p.createElement)(p.Fragment,null,(0,p.createElement)("p",null,(0,m.__)("Coordinates: ","maps-block-apple"),`${e.toFixed(4)}, ${t.toFixed(4)}`))}function S(e){const{map:t,mapkit:a,attributes:{latitude:o,longitude:l,address:i},setAttributes:n}=e,[s,r]=(0,d.useState)([]),[u,h]=(0,d.useState)([]);if((0,d.useEffect)((()=>{r("")}),[i]),!a)return null;const b=new a.Geocoder,g=(e,t)=>{t.results&&h(t.results)};return(0,p.createElement)(c.PanelBody,{title:(0,m.__)("Location Settings","maps-block-apple")},(0,p.createElement)("div",null,(0,p.createElement)(c.SearchControl,{label:(0,m.__)("Search for a Location","maps-block-apple"),value:s,onChange:e=>{e?b.lookup(e,g):h([]),r(e)}}),(0,p.createElement)(C,{map:t,setAttributes:n,searchResults:u,setSearchResults:h})),(0,p.createElement)(f,{latitude:o,longitude:l}))}function T(e){const{marker:t,update:a}=e,o=["image"],l=e=>{a({...t,glyphImageId:e.id,glyphImage:e.url})};return(0,p.createElement)("div",{className:"maps-block-apple-marker-uploader"},(0,p.createElement)(c.BaseControl,{id:"marker-icon-control",label:(0,m.__)("Marker Icon","maps-block-apple")},(0,p.createElement)(h.MediaUploadCheck,null,(0,p.createElement)(h.MediaUpload,{allowedTypes:o,render:({open:e})=>(0,p.createElement)(c.Button,{className:t.glyphImageId?"editor-post-featured-image__preview":"editor-post-featured-image__toggle",onClick:e},!t.glyphImageId&&(0,m.__)("Choose an icon","maps-block-apple"),t.glyphImageId&&t.glyphImage&&(0,p.createElement)("img",{src:t.glyphImage,alt:(0,m.__)("Marker icon","maps-block-apple")})),onSelect:l,value:t.glyphImageId})),!!t.glyphImageId&&(0,p.createElement)(h.MediaUploadCheck,null,t.glyphImage&&(0,p.createElement)(h.MediaUpload,{onSelect:l,allowedTypes:o,render:({open:e})=>(0,p.createElement)(c.Button,{onClick:e,variant:"secondary",className:"replace-marker-icon"},(0,m.__)("Replace icon","maps-block-apple"))}),(0,p.createElement)(c.Button,{className:"remove-marker-icon",onClick:()=>{a({...t,glyphImageId:void 0,glyphImage:void 0})},variant:"link",isDestructive:!0},(0,m.__)("Remove icon","maps-block-apple")))))}function M(e){const{marker:t,remove:a,update:o}=e,i=(0,l.useSelect)((e=>e("core/block-editor").getSettings().colors));return(0,p.createElement)(c.PanelBody,{title:t.title,className:"marker-edit",icon:"location",initialOpen:!1},(0,p.createElement)(c.TextControl,{label:(0,m.__)("Title","maps-block-apple"),value:t.title,onChange:e=>o({...t,title:e})}),(0,p.createElement)(c.TextControl,{label:(0,m.__)("Subtitle","maps-block-apple"),value:t.subtitle,onChange:e=>o({...t,subtitle:e})}),(0,p.createElement)(c.PanelRow,null,(0,p.createElement)("label",{htmlFor:"marker-color-control"},(0,m.__)("Marker Color","maps-block-apple")),(0,p.createElement)(c.ColorIndicator,{id:"marker-color-control",colorValue:t.color})),(0,p.createElement)(c.ColorPalette,{value:t.color,colors:i,onChange:e=>o({...t,color:e})}),(0,p.createElement)(c.PanelRow,null,(0,p.createElement)("label",{htmlFor:"glyph-color-control"},(0,m.__)("Icon Color","maps-block-apple")),(0,p.createElement)(c.ColorIndicator,{id:"glyph-color-control",colorValue:t.glyphColor})),(0,p.createElement)(c.ColorPalette,{value:t.glyphColor,colors:i,onChange:e=>o({...t,glyphColor:e})}),(0,p.createElement)(T,{marker:t,update:o}),(0,p.createElement)(c.PanelRow,null,(0,p.createElement)(f,{latitude:t.latitude,longitude:t.longitude})),(0,p.createElement)(c.PanelRow,null,(0,p.createElement)(c.Button,{isLink:!0,icon:"no",isDestructive:!0,onClick:a},(0,m.__)("Remove Marker","maps-block-apple"))))}function A(e){const{attributes:{markers:t},setAttributes:a}=e,o=e=>o=>{const l=[...t];l[e]=o,a({markers:l})},l=e=>()=>{const o=[...t];o.splice(e,1),a({markers:o})};return t.length?(0,p.createElement)(c.PanelBody,{title:(0,m.__)("Marker Settings","apple-maps-wordpress")},t.map(((e,t)=>(0,p.createElement)(M,{key:t,marker:e,update:o(t),remove:l(t)}))),(0,p.createElement)(c.Tip,null,(0,m.__)("You can move a marker by long pressing on it.","maps-block-apple"))):null}function R(e){const{isAuthenticated:t}=e;return t?(0,p.createElement)(h.InspectorControls,null,(0,p.createElement)(S,{...e}),(0,p.createElement)(v,{...e}),(0,p.createElement)(A,{...e})):(0,p.createElement)(h.InspectorControls,null,(0,p.createElement)(c.PanelBody,null,(0,p.createElement)("p",null,(0,m.__)("You need to confirm your access to Apple Maps before you can continue.","maps-block-apple"))))}function I({children:e,fallback:t}){return(0,l.useSelect)((e=>e("core").canUser("update","settings")))?e:t||null}const z=function(){return(0,p.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"none",viewBox:"0 0 40 52"},(0,p.createElement)("path",{fill:"#333",fillRule:"evenodd",d:"M37.15 9.802c0 4.936-3.698 9.05-8.46 9.709v11.854l-1.304 3.92-1.303-3.92V19.521c-4.8-.626-8.536-4.757-8.536-9.72 0-5.39 4.41-9.801 9.802-9.801 5.39 0 9.801 4.41 9.801 9.802zm-15.224-2.38c.74.633 2.088.274 3.01-.802.922-1.077 1.068-2.464.327-3.098-.74-.634-2.088-.275-3.01.802-.921 1.076-1.068 2.463-.327 3.097z",clipRule:"evenodd"}),(0,p.createElement)("path",{fill:"#333",d:"M12.85 25l11.277 3.776v2.589l3.26 8.821 3.258-8.821v-2.483L40 25v21.736l-12.124 4.93-15.026-4.93L0 51.666V30.032L12.85 25z"}))},x={top:!1,right:!1,bottom:!0,left:!1,topRight:!1,bottomRight:!1,bottomLeft:!1,topLeft:!1};function B({onResizeStart:e,onResize:t,onResizeStop:a,...o}){const[l,i]=(0,d.useState)(!1);return(0,p.createElement)(c.ResizableBox,{style:{position:"absolute",top:0,left:0,right:0,bottom:0},className:"apple-maps-block__resize-container "+(l?"is-resizing":""),enable:x,onResizeStart:(a,o,l)=>{e(l.clientHeight),t(l.clientHeight)},onResize:(e,a,o)=>{t(o.clientHeight),l||i(!0)},onResizeStop:(e,t,o)=>{a(o.clientHeight),i(!1)},minHeight:100,...o})}const P=(0,d.memo)((e=>{const{map:t,isAuthenticated:a,clientId:o,setAttributes:l,setMap:i,mapkit:n}=e,s=!!t,r=(0,u.useRefEffect)((e=>{if(n)return a&&!s&&i(new k(e,o,l)),()=>{s&&(t.destroy(),i(null))}}),[n,a,t,o,l]);return(0,p.createElement)("div",{ref:r})})),N=JSON.parse('{"name":"tenup/maps-block-apple","title":"Apple Maps","category":"embed","description":"Add an Apple Map to your site.","apiVersion":3,"keywords":["apple","map","apple map"],"attributes":{"address":{"type":"string","default":""},"height":{"type":"string","default":"450"},"latitude":{"type":"number","default":51.48762585296625},"longitude":{"type":"number","default":-0.1326724377053381},"rotation":{"type":"number","default":0},"zoom":{"type":"number","default":15},"mapType":{"type":"string","default":"standard"},"showsMapTypeControl":{"type":"boolean","default":true},"isRotationEnabled":{"type":"boolean","default":true},"showsCompass":{"type":"string","default":"adaptive"},"isZoomEnabled":{"type":"boolean","default":true},"showsZoomControl":{"type":"boolean","default":true},"isScrollEnabled":{"type":"boolean","default":true},"showsScale":{"type":"string","default":"adaptive"},"markers":{"type":"array","default":[]}},"example":{"attributes":{"latitude":51.48762585296625,"longitude":-0.1326724377053381}},"supports":{"align":["wide","full"],"spacing":{"margin":true},"html":false},"editorScript":"maps-block-apple-block","viewScript":"maps-block-apple-frontend","editorStyle":"file:build/index.css"}'),{Map:L,FeatureVisibility:V}=mapkit,O=[{attributes:{...N.attributes,mapType:{type:"string",default:L.MapTypes.Standard},showsCompass:{type:"string",default:V.Adaptive},showsScale:{type:"string",default:V.Adaptive}},save(e){const{attributes:{mapType:t,height:a,latitude:o,longitude:l,rotation:i,zoom:n,showsMapTypeControl:s,isRotationEnabled:r,showsCompass:c,isZoomEnabled:m,showsZoomControl:d,isScrollEnabled:u,showsScale:b,markers:g}}=e,y=h.useBlockProps.save();return(0,p.createElement)("div",{...y,"data-map-type":t,"data-latitude":o,"data-longitude":l,"data-rotation":i,"data-zoom":n,"data-shows-map-type-control":s,"data-is-rotation-enabled":r,"data-shows-compass":c,"data-is-zoom-enabled":m,"data-shows-zoom-control":d,"data-is-scroll-enabled":u,"data-shows-scale":b,style:{height:`${a}px`}},g.map(((e,t)=>(0,p.createElement)("div",{key:t,className:"marker-annotation","data-latitude":e.latitude,"data-longitude":e.longitude,"data-title":e.title,"data-subtitle":e.subtitle,"data-color":e.color,"data-glyph-color":e.glyphColor}))))}}],{Map:Z,FeatureVisibility:F}=mapkit;(0,o.registerBlockType)(N,{icon:z,attributes:{...N.attributes,mapType:{type:"string",default:Z.MapTypes.Standard},showsCompass:{type:"string",default:F.Adaptive},showsScale:{type:"string",default:F.Adaptive}},edit:function(e){const{attributes:t,setAttributes:a,clientId:o,isSelected:i}=e,{height:n,latitude:s,longitude:b,markers:y}=t,[E,_]=(0,d.useState)(null),[v,C]=(0,d.useState)(null),f=!!E,S=(0,l.useSelect)((e=>e(r).isAuthenticated())),[T,M]=(0,d.useState)(!0),{updateAuthenticationStatus:A}=(0,l.useDispatch)(r),{toggleSelection:x}=(0,l.useDispatch)(h.store),N=(0,u.useRefEffect)((e=>{const t=e.ownerDocument.defaultView.mapkit;if(!t)return void C(null);C(t);const a=({status:e})=>{switch(e){case"Initialized":case"Refreshed":M(!1),A(!0)}};t.addEventListener("configuration-change",a);const o=()=>{M(!1),A(!1)};t.addEventListener("error",o);const l=async()=>{await(async()=>{try{return!!await g()({path:"MapsBlockApple/v1/GetJWT"})||(M(!1),A(!1),!1)}catch(e){return M(!1),A(!1),!1}})()&&k.authenticateMap(t)};return t.addEventListener("reinitialize",l),S||l(),()=>{t.removeEventListener("configuration-change",a),t.removeEventListener("error",o),t.removeEventListener("reinitialize",l),C(null)}}));(0,d.useEffect)((()=>{S&&M(!1)}),[S]),(0,d.useEffect)((()=>{S&&f&&E.update(t)}),[t,S,E]);const L=(0,u.useDebounce)((e=>{f&&E.addMarkers(e)}),300);(0,d.useEffect)((()=>L(y)),[y]);const V=(0,h.useBlockProps)({ref:N});return T?(0,p.createElement)("div",{...V},(0,p.createElement)(c.Placeholder,{style:{height:`${n}px`},label:(0,m.__)("Block for Apple Maps","maps-block-apple"),icon:z},(0,p.createElement)(c.Spinner,null))):S?(0,p.createElement)(p.Fragment,null,(0,p.createElement)(h.BlockControls,null,(0,p.createElement)(c.ToolbarGroup,null,(0,p.createElement)(c.ToolbarButton,{icon:"location",title:(0,m.__)("Add Marker","apple-maps-wordpress"),onClick:()=>{a({markers:[...y,{latitude:s,longitude:b,title:"Title",id:Symbol("identifier for the marker")}]})}}))),(0,p.createElement)(R,{...e,isAuthenticated:S,map:E,mapkit:v}),(0,p.createElement)("div",{...V},(0,p.createElement)(B,{onResizeStart:()=>{x(!1)},onResize:e=>{E.update({height:e})},onResizeStop:e=>{a({height:e}),x(!0)},showHandle:i,size:{height:n}}),(0,p.createElement)(P,{map:E,setMap:_,isAuthenticated:S,clientId:o,setAttributes:a,mapkit:v}))):(0,p.createElement)(p.Fragment,null,(0,p.createElement)(R,{...e,isAuthenticated:S,map:E,mapkit:v}),(0,p.createElement)("div",{...V},(0,p.createElement)(c.Placeholder,{style:{minHeight:`${n}px`},label:(0,m.__)("Confirm access to Apple Maps","maps-block-apple"),icon:z,isColumnLayout:!0},(0,p.createElement)(I,{fallback:(0,m.__)("Sorry, you are not allowed to do that. Please talk to your Administrator.","maps-block-apple")},(0,p.createElement)("div",{style:{marginBottom:"1em"}},(0,m.__)("In order to include an Apple Map on your website you need to confirm your MapKit credentials below. Here is documentation on how to get those credentials: ","maps-block-apple"),(0,p.createElement)("a",{href:"https://developer.apple.com/documentation/mapkitjs/setting_up_mapkit_js",target:"_blank",rel:"noopener noreferrer"},(0,m.__)("Instructions for creating your MapKit credentials.","maps-block-apple"))),(0,p.createElement)(w,null)))))},save:function(e){const{attributes:{mapType:t,height:a,latitude:o,longitude:l,rotation:i,zoom:n,showsMapTypeControl:s,isRotationEnabled:r,showsCompass:c,isZoomEnabled:m,showsZoomControl:d,isScrollEnabled:u,showsScale:b,markers:g}}=e,y=h.useBlockProps.save({style:{height:`${a}px`}});return(0,p.createElement)("div",{...y,"data-map-type":t,"data-latitude":o,"data-longitude":l,"data-rotation":i,"data-zoom":n,"data-shows-map-type-control":s,"data-is-rotation-enabled":r,"data-shows-compass":c,"data-is-zoom-enabled":m,"data-shows-zoom-control":d,"data-is-scroll-enabled":u,"data-shows-scale":b},g.map(((e,t)=>(0,p.createElement)("div",{key:t,className:"marker-annotation","data-latitude":e.latitude,"data-longitude":e.longitude,"data-title":e.title,"data-subtitle":e.subtitle,"data-color":e.color,"data-glyph-color":e.glyphColor,"data-glyph-image":e.glyphImage}))))},deprecated:O})})(); -
maps-block-apple/tags/1.1.5/maps-block-apple.php
r3139952 r3327590 4 4 * Plugin URI: https://github.com/10up/maps-block-apple 5 5 * Description: An Apple Maps block for the WordPress block editor (Gutenberg). 6 * Version: 1.1. 47 * Requires at least: 6. 46 * Version: 1.1.5 7 * Requires at least: 6.6 8 8 * Requires PHP: 7.4 9 9 * Author: 10up … … 19 19 20 20 // Useful global constants. 21 define( 'MAPS_BLOCK_APPLE_VERSION', '1.1. 4' );21 define( 'MAPS_BLOCK_APPLE_VERSION', '1.1.5' ); 22 22 define( 'MAPS_BLOCK_APPLE_URL', plugin_dir_url( __FILE__ ) ); 23 23 define( 'MAPS_BLOCK_APPLE_PATH', dirname( __FILE__ ) . '/' ); -
maps-block-apple/tags/1.1.5/readme.txt
r3280004 r3327590 2 2 Contributors: 10up, helen, welcher, fabiankaegy, dinhtungdu, jeffpaul 3 3 Tags: apple maps, map block, block 4 Requires at least: 6.65 4 Tested up to: 6.8 6 Stable tag: 1.1. 45 Stable tag: 1.1.5 7 6 License: GPL-2.0-or-later 8 7 License URI: https://spdx.org/licenses/GPL-2.0-or-later.html … … 72 71 == Changelog == 73 72 73 = 1.1.5 - 2025-07-14 = 74 * **Note that this release bumps the WordPress minimum version from 6.4 to 6.6.** 75 76 * **Changed:** Bump WordPress "tested up to" version 6.8 (props [@sudip-md](https://github.com/sudip-md), [@mehidi258](https://github.com/mehidi258), [@jeffpaul](https://github.com/jeffpaul), [@dkotter](https://github.com/dkotter), [@peterwilsoncc](https://github.com/peterwilsoncc), [@Rishabh-fueled](https://github.com/@Rishabh-fueled) via [#229](https://github.com/10up/maps-block-apple/pull/229), [#230](https://github.com/10up/maps-block-apple/pull/230), [#237](https://github.com/10up/maps-block-apple/pull/237), [#238](https://github.com/10up/maps-block-apple/pull/238)). 77 * **Changed:** Bump WordPress minimum supported version to 6.6 (props [@sudip-md](https://github.com/sudip-md), [@mehidi258](https://github.com/mehidi258), [@jeffpaul](https://github.com/jeffpaul), [@dkotter](https://github.com/dkotter), [@peterwilsoncc](https://github.com/peterwilsoncc), [@Rishabh-fueled](https://github.com/@Rishabh-fueled) via [#229](https://github.com/10up/maps-block-apple/pull/229), [#230](https://github.com/10up/maps-block-apple/pull/230), [#238](https://github.com/10up/maps-block-apple/pull/238)). 78 * **Fixed:** Block crash when no Apple Maps credentials are configured (props [@elvismdev](https://github.com/elvismdev), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#233](https://github.com/10up/maps-block-apple/pull/233)). 79 * **Security:** Bump `braces` from 3.0.2 to 3.0.3, `express` from 4.18.2 to 4.19.2, `webpack` from 5.89.0 to 5.94.0 and `webpack-dev-middleware` from 5.3.3 to 5.3.4 (props [@dependabot](https://github.com/apps/dependabot), [@faisal-alvi](https://github.com/faisal-alvi) via [#224](https://github.com/10up/maps-block-apple/pull/224)). 80 * **Security:** Bump `@wordpress/scripts` from 27.9.0 to 30.6.0, `body-parser` from 1.20.2 to 1.20.3, `express` from 4.19.2 to 4.21.1, `ws` from 7.5.9 to 8.18.0, `send` from 0.18.0 to 0.19.0 and `serve-static` from 1.15.0 to 1.16.2 (props [@dependabot](https://github.com/apps/dependabot), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#231](https://github.com/10up/maps-block-apple/pull/231)). 81 * **Security:** Bump `@wordpress/e2e-test-utils-playwright` from 1.13.0 to 1.18.0, `serialize-javascript` from 6.0.1 to 6.0.2, `mocha` from 10.2.0 to 11.1.0 and removes `cookie` (props [@dependabot](https://github.com/apps/dependabot), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#234](https://github.com/10up/maps-block-apple/pull/234)). 82 * **Security:** Bump `axios` from 1.7.4 to 1.9.0 and `http-proxy-middleware` from 2.0.6 to 2.0.9 (props [@dependabot](https://github.com/apps/dependabot), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#241](https://github.com/10up/maps-block-apple/pull/241)). 83 74 84 = 1.1.4 - 2024-08-22 = 75 85 * **Note that this release bumps the WordPress minimum version from 5.8 to 6.4.** … … 85 95 * **Developer:** Support for the WordPress.org plugin preview (props [@dkotter](https://github.com/dkotter), [@jeffpaul](https://github.com/jeffpaul) via [#196](https://github.com/10up/maps-block-apple/pull/196)). 86 96 87 = 1.1.3 - 2023-11-16 =88 * **Changed:** Bump WordPress "tested up to" version to 6.4 (props [@QAharshalkadu](https://github.com/QAharshalkadu), [@jeffpaul](https://github.com/jeffpaul) via [#190](https://github.com/10up/maps-block-apple/pull/190), [#191](https://github.com/10up/maps-block-apple/pull/191)).89 90 = 1.1.2 - 2023-10-16 =91 * **Changed:** Bump WordPress "tested up to" version to 6.3 (props [@QAharshalkadu](https://github.com/QAharshalkadu), [@jeffpaul](https://github.com/jeffpaul) via [#179](https://github.com/10up/maps-block-apple/pull/179)).92 * **Fixed:** Ensure our Mapkit JS only loads when a Map block is in place (props [@jayedul](https://github.com/jayedul), [@fabiankaegy](https://github.com/fabiankaegy), [@faisal-alvi](https://github.com/faisal-alvi) via [#161](https://github.com/10up/maps-block-apple/pull/161)).93 * **Fixed:** Better error handling for environments that don't match our minimum PHP version (props [@rahulsprajapati](https://github.com/rahulsprajapati), [@dkotter](https://github.com/dkotter), [@ravinderk](https://github.com/ravinderk) via [#174](https://github.com/10up/maps-block-apple/pull/174)).94 * **Fixed:** Ensure that the Apple Maps block works fine in WordPress 6.4 (props [@iamdharmesh](https://github.com/iamdharmesh), [@fabiankaegy](https://github.com/fabiankaegy), [@faisal-alvi](https://github.com/faisal-alvi) via [#183](https://github.com/10up/maps-block-apple/pull/183)).95 * **Fixed:** Ensure that our Cypress E2E tests pass (props [@iamdharmesh](https://github.com/iamdharmesh), [@Sidsector9](https://github.com/Sidsector9) via [#181](https://github.com/10up/maps-block-apple/pull/181)).96 * **Security:** Bump `word-wrap` from 1.2.3 to 1.2.4 (props [@dependabot](https://github.com/apps/dependabot), [@ravinderk](https://github.com/ravinderk) via [#173](https://github.com/10up/maps-block-apple/pull/173)).97 * **Security:** Bump `tough-cookie` from 4.1.2 to 4.1.3 (props [@dependabot](https://github.com/apps/dependabot), [@faisal-alvi](https://github.com/faisal-alvi) via [#176](https://github.com/10up/maps-block-apple/pull/176)).98 * **Security:** Bump `cypress` from 11.2.0 to 13.2.0 and `@cypress/request` from 2.88.11 to 3.0.0 (props [@dependabot](https://github.com/apps/dependabot), [@ravinderk](https://github.com/ravinderk), [@faisal-alvi](https://github.com/faisal-alvi), [@iamdharmesh](https://github.com/iamdharmesh), [@Sidsector9](https://github.com/Sidsector9) via [#176](https://github.com/10up/maps-block-apple/pull/176), [#180](https://github.com/10up/maps-block-apple/pull/180), [#181](https://github.com/10up/maps-block-apple/pull/181)).99 * **Security:** Bump `postcss` from 8.4.23 to 8.4.31 (props [@dependabot](https://github.com/apps/dependabot), [@ravinderk](https://github.com/ravinderk) via [#184](https://github.com/10up/maps-block-apple/pull/184)).100 * **Security:** Bump `@10up/cypress-wp-utils` from 0.1.0 to 0.2.0, `@wordpress/env` from 5.6.0 to 8.7.0 and `cypress-mochawesome-reporter` from 3.4.0 to 3.6.0 (props [@iamdharmesh](https://github.com/iamdharmesh), [@Sidsector9](https://github.com/Sidsector9) via [#181](https://github.com/10up/maps-block-apple/pull/181)).101 102 = 1.1.1 - 2023-06-21 =103 * **Note that this release bumps the PHP minimum supported version from 5.6 to 7.4.**104 105 * **Added:** Mochawesome reporter added for Cypress test report (props [@jayedul](https://github.com/jayedul), [@iamdharmesh](https://github.com/iamdharmesh) via [#168](https://github.com/10up/maps-block-apple/pull/168)).106 * **Changed:** Bump PHP minimum supported version from 5.6 to 7.4 (props [@jayedul](https://github.com/jayedul), [@csloisel](https://github.com/csloisel), [@faisal-alvi](https://github.com/faisal-alvi), [@dkotter](https://github.com/dkotter) via [#133](https://github.com/10up/maps-block-apple/pull/133)).107 * **Changed:** Run E2E tests on the zip generated by "Build release zip" action (props [@jayedul](https://github.com/jayedul), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#163](https://github.com/10up/maps-block-apple/pull/163)).108 * **Changed:** Bump WordPress "tested up to" version to 6.2 (props [@jayedul](https://github.com/jayedul), [@peterwilsoncc](https://github.com/peterwilsoncc), [@Sidsector9](https://github.com/Sidsector9) via [#165](https://github.com/10up/maps-block-apple/pull/165), [#167](https://github.com/10up/maps-block-apple/pull/167)).109 * **Changed:** Update Cypress E2E and Dependency Review GitHub Actions (props [@jayedul](https://github.com/jayedul), [@jeffpaul](https://github.com/jeffpaul), [@Sidsector9](https://github.com/Sidsector9) via [#166](https://github.com/10up/maps-block-apple/pull/166), [#169](https://github.com/10up/maps-block-apple/pull/169)).110 * **Security:** Bump `simple-git` from 3.15.1 to 3.16.0 (props [@dependabot](https://github.com/apps/dependabot) via [#158](https://github.com/10up/maps-block-apple/pull/158)).111 * **Security:** Bump `http-cache-semantics` from 4.1.0 to 4.1.1 (props [@dependabot](https://github.com/apps/dependabot) via [#159](https://github.com/10up/maps-block-apple/pull/159)).112 * **Security:** Bump `@sideway/formula` from 3.0.0 to 3.0.1 (props [@dependabot](https://github.com/apps/dependabot) via [#160](https://github.com/10up/maps-block-apple/pull/160)).113 * **Security:** Bump `webpack` from 5.73.0 to 5.76.1 (props [@dependabot](https://github.com/apps/dependabot) via [#162](https://github.com/10up/maps-block-apple/pull/162)).114 115 = 1.1.0 - 2023-01-23 =116 * **Note that this release bumps the WordPress minimum version from 5.2 to 5.8.**117 118 * **Added:** Support for custom marker icons (props [@iamdharmesh](https://github.com/iamdharmesh), [@dinhtungdu](https://github.com/dinhtungdu), [@fabiankaegy](https://github.com/fabiankaegy) via [#136](https://github.com/10up/maps-block-apple/pull/136)).119 * **Added:** Ability to control margin of map (props [@fabiankaegy](https://github.com/fabiankaegy), [@dkotter](https://github.com/dkotter) via [#157](https://github.com/10up/maps-block-apple/pull/157)).120 * **Added:** End-to-end testing setup with Cypress (props [@cadic](https://github.com/cadic), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#126](https://github.com/10up/maps-block-apple/pull/126)).121 * **Changed:** Bump minimum WordPress version from 5.2 to 5.8 (props [@cadic](https://github.com/cadic), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#126](https://github.com/10up/maps-block-apple/pull/126)).122 * **Changed:** Update linting workflows to take advantage of GitHub Actions summaries (props [@dinhtungdu](https://github.com/dinhtungdu), [@fabiankaegy](https://github.com/fabiankaegy) via [#128](https://github.com/10up/maps-block-apple/pull/128)).123 * **Changed:** Update Support Level from `Active` to `Stable` (props [@jeffpaul](https://github.com/jeffpaul), [@dkotter](https://github.com/dkotter) via [#135](https://github.com/10up/maps-block-apple/pull/135)).124 * **Changed:** Update composer dependencies to avoid conflict (props [@peterwilsoncc](https://github.com/peterwilsoncc), [@iamdharmesh](https://github.com/iamdharmesh) via [#145](https://github.com/10up/maps-block-apple/pull/145)).125 * **Changed:** Bump WordPress "tested up to" version to 6.1 (props [@iamdharmesh](https://github.com/iamdharmesh), [@cadic](https://github.com/cadic) via [#148](https://github.com/10up/maps-block-apple/pull/148)).126 * **Security:** Bump `terser` from 5.14.1 to 5.14.2 (props [@dependabot](https://github.com/apps/dependabot) via [#132](https://github.com/10up/maps-block-apple/pull/132)).127 * **Security:** Bump `markdown-it` from 12.0.4 to 12.3.2 and `@wordpress/scripts` from 20.0.2 to 24.5.0 (props [@dependabot](https://github.com/apps/dependabot) via [#138](https://github.com/10up/maps-block-apple/pull/138)).128 * **Security:** Bump `loader-utils` from 2.0.2 to 2.0.4 (props [@dependabot](https://github.com/apps/dependabot) via [#146](https://github.com/10up/maps-block-apple/pull/146)).129 * **Security:** Bump `simple-git` from 3.10.0 to 3.15.1 (props [@dependabot](https://github.com/apps/dependabot) via [#149](https://github.com/10up/maps-block-apple/pull/149)).130 * **Security:** Bump `json5` from 1.0.1 to 1.0.2 (props [@dependabot](https://github.com/apps/dependabot) via [#153](https://github.com/10up/maps-block-apple/pull/153)).131 132 97 = Earlier versions = 133 98 For the changelog of earlier versions, please refer to the [changelog on github.com](https://github.com/10up/maps-block-apple/blob/develop/CHANGELOG.md). 134 99 135 100 == Upgrade Notice == 101 102 = 1.1.5 = 103 104 * Note that this version bumps the minimum WordPress version from 6.4 to 6.6. 136 105 137 106 = 1.1.4 = -
maps-block-apple/trunk/build/index.asset.php
r3139952 r3327590 1 <?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => ' 2a9cd3c45a01541aab07');1 <?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'df4efdfcfc810d0c567c'); -
maps-block-apple/trunk/build/index.js
r3139952 r3327590 1 (()=>{"use strict";var e={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var o in a)e.o(a,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:a[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{isAuthenticated:()=>n});var a={};e.r(a),e.d(a,{updateAuthenticationStatus:()=>s});const o=window.wp.blocks,l=window.wp.data,i=(0,l.combineReducers)({authenticationReducer:function(e,t){return"UPDATE_AUTHENTICATION"===t.type?{...e,authenticated:t.isAuthenticated}:e}});function n(e){return Boolean(e?.authenticationReducer?.authenticated)}function s(e){return{type:"UPDATE_AUTHENTICATION",isAuthenticated:e}}const r=(0,l.createReduxStore)("tenup/maps-block-apple",{reducer:i,selectors:t,actions:a});(0,l.register)(r);const p=window.React,c=window.wp.components,m=window.wp.i18n,d=window.wp.element,u=window.wp.compose,h=window.wp.blockEditor,b=window.wp.apiFetch;var g=e.n(b);class y{constructor(e){this.element=e,this.mapOptions={},this.markerElements=this.element.querySelectorAll(".marker-annotation"),this.markers=[...this.markerElements].map((e=>{const{latitude:t,longitude:a,title:o,subtitle:l,color:i,glyphColor:n,glyphImage:s}=e.dataset;return{latitude:Number(t),longitude:Number(a),title:o||"",subtitle:l||"",color:i||null,glyphColor:n||null,glyphImage:s||null}})),this.mapkit=e.ownerDocument.defaultView.mapkit,this.mapkit&&this.init()}init(){this.createMap(),this.addMarkers(this.markers)}createMap(){const{mapType:e,latitude:t,longitude:a,rotation:o,zoom:l,showsMapTypeControl:i=!0,isRotationEnabled:n=!0,showsCompass:s,isZoomEnabled:r=!0,showsZoomControl:p=!0,isScrollEnabled:c=!0,showsScale:m}=this.element.dataset,d=new this.mapkit.Coordinate(Number(t)||51.48762585296625,Number(a)||-.1326724377053381);this.mapOptions={center:d,rotation:Number(o)||0,mapType:e||this.mapkit.Map.MapTypes.Satellite,showsMapTypeControl:"true"===i,isRotationEnabled:"true"===n,isZoomEnabled:"true"===r,showsZoomControl:"true"===p,isScrollEnabled:"true"===c,showsScale:m||this.mapkit.FeatureVisibility.Adaptive},this.mapOptions.isRotationEnabled&&(this.mapOptions.showsCompass=s||this.mapkit.FeatureVisibility.Adaptive),this.map=new this.mapkit.Map(this.element,this.mapOptions),this.map._impl.zoomLevel=Number(l)||15}addMarkers(e){this.clearMarkers();const t=[];e.forEach(((a,o)=>{const{latitude:l,longitude:i,title:n,subtitle:s,titleVisibility:r,subtitleVisibility:p,color:c,glyphColor:m,glyphText:d,glyphImage:u}=a,h=new this.mapkit.Coordinate(Number(l),Number(i)),b={title:n,subtitle:s||null,titleVisibility:r||this.mapkit.FeatureVisibility.Visible,subtitleVisibility:p||this.mapkit.FeatureVisibility.Visible,color:c||"green",glyphColor:m||"white",glyphText:d||"",draggable:!!this.isEditor};u&&(b.glyphImage={1:u});const g=new this.mapkit.MarkerAnnotation(h,b);this.setAttributes&&g.addEventListener("drag-end",(t=>{const{target:{coordinate:a}}=t,l=[...e];l[o].latitude=a.latitude,l[o].longitude=a.longitude,this.setAttributes({markers:l})})),t.push(g)})),this.map.addAnnotations(t)}clearMarkers(){this.map.removeAnnotations(this.map.annotations)}static authenticateMap(e){g()({path:"MapsBlockApple/v1/GetJWT/"}).then((()=>{e.init({authorizationCallback(e){g()({path:"MapsBlockApple/v1/GetJWT/"}).then(e)}})})).catch((t=>{(0,l.dispatch)("core/notices").createErrorNotice(t.message,{isDismissible:!0,type:"snackbar"}),e.dispatchEvent(new Event("error"))}))}}class k extends y{constructor(e,t,a){super(e),this.isEditor=!0,this.clientId=t,this.setAttributes=a,this.initEdit()}initEdit(){this.addListeners(),this.addMarkers(this.markers)}destroy(){this.map&&this.map.destroy()}addListeners(){this.map.element.addEventListener("click",(()=>{(0,l.dispatch)("core/block-editor").selectBlock(this.clientId)})),this.map.addEventListener("map-type-change",(()=>{this.setAttributes({mapType:this.map.mapType})})),this.map.addEventListener("region-change-end",(()=>{this.setAttributes({rotation:this.map.rotation,latitude:this.map.center.latitude,longitude:this.map.center.longitude,zoom:this.map._impl.zoomLevel})}))}update(e){const{mapType:t,latitude:a,longitude:o,rotation:l,zoom:i,showsMapTypeControl:n,isRotationEnabled:s,showsCompass:r,isZoomEnabled:p,showsZoomControl:c,isScrollEnabled:m,showsScale:d,region:u,height:h}=e;h&&(this.element.style.height=`${h}px`),this.map&&(u&&""!==u&&this.map.setRegionAnimated(u,!0),t&&t!==this?.map?.mapType&&(this.map.mapType=e.mapType),i&&i!==this.map?._impl?.zoomLevel&&(this.map._impl.zoomLevel=i),l&&l!==this?.map?.rotation&&this.map.setRotationAnimated(Number(l)),a&&o&&(a!==this?.map?.center?.latitude||o!==this?.map?.center?.longitude)&&this.map.setCenterAnimated(new this.mapkit.Coordinate(a,o)),void 0!==n&&n!==this?.map?.showsMapTypeControl&&(this.map.showsMapTypeControl=!!n),void 0!==s&&s!==this?.map?.isRotationEnabled&&(this.map.isRotationEnabled=!!s),r!==this?.map?.showsCompass&&this.map.isRotationEnabled&&(this.map.showsCompass=r||this.mapkit.FeatureVisibility.Adaptive),void 0!==p&&p!==this?.map?.isZoomEnabled&&(this.map.isZoomEnabled=!!p),void 0!==c&&c!==this?.map?.showsZoomControl&&(this.map.showsZoomControl=!!c),void 0!==m&&m!==this?.map?.isScrollEnabled&&(this.map.isScrollEnabled=!!m),d!==this?.map?.showsScale&&(this.map.showsScale=d||this.mapkit.FeatureVisibility.Adaptive))}}const E=Object.keys(mapkit.Map.MapTypes).map((e=>({label:"MutedStandard"===e?(0,m.__)("Muted","maps-block-apple"):e,value:mapkit.Map.MapTypes[e]}))),_=Object.keys(mapkit.FeatureVisibility).map((e=>({label:e,value:mapkit.FeatureVisibility[e]})));function w(){const[e,t]=(0,d.useState)(""),[a,o]=(0,d.useState)(""),[i,n]=(0,d.useState)(""),[s,r]=(0,d.useState)(!1),u=(0,l.useSelect)((e=>e("core").getEntityRecord("root","site")),[]);return(0,d.useEffect)((()=>{if(u){const{maps_block_apple:{private_key:e,team_id:a,key_id:l}}=u;t(e),o(l),n(a)}}),[u]),(0,p.createElement)(p.Fragment,null,(0,p.createElement)(c.TextareaControl,{label:(0,m.__)("Please enter your Private Key","maps-block-apple"),readOnly:s,name:"private_key",value:e,onChange:e=>t(e)}),(0,p.createElement)(c.TextControl,{label:(0,m.__)("Please enter your Key ID","maps-block-apple"),readOnly:s,name:"key_id",value:a,onChange:e=>o(e)}),(0,p.createElement)(c.TextControl,{label:(0,m.__)("Please enter your Team ID","maps-block-apple"),readOnly:s,name:"team_id",value:i,onChange:e=>n(e)}),(0,p.createElement)(c.Button,{isPrimary:!0,disabled:s,isBusy:s,onClick:()=>{r(!0),(0,l.dispatch)("core").saveEntityRecord("root","site",{maps_block_apple:{private_key:e,team_id:i,key_id:a}}).then((({maps_block_apple:{private_key:e,team_id:a,key_id:l}})=>{t(e),o(l),n(a),r(!1),mapkit.dispatchEvent(new CustomEvent("reinitialize"))})).catch((e=>{(0,l.dispatch)("core/notices").createErrorNotice(e.message,{isDismissible:!0,type:"snackbar"}),r(!1)}))}},(0,m.__)("Confirm MapKit Credentials","maps-block-apple")))}function v(e){const{attributes:{mapType:t,height:a,zoom:o,showsMapTypeControl:l,isRotationEnabled:i,showsCompass:n,isZoomEnabled:s,showsZoomControl:r,isScrollEnabled:d,showsScale:u},setAttributes:h}=e;return(0,p.createElement)(c.PanelBody,{title:(0,m.__)("Display Settings","maps-block-apple")},(0,p.createElement)(c.__experimentalToggleGroupControl,{label:(0,m.__)("Map Type","maps-block-apple"),isBlock:!0,isAdaptiveWidth:!0,value:t,onChange:e=>h({mapType:e})},E.map((e=>(0,p.createElement)(c.__experimentalToggleGroupControlOption,{...e,key:e.value})))),(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Show Map Type Control","maps-block-apple"),checked:l,onChange:e=>h({showsMapTypeControl:e})}),(0,p.createElement)(c.RangeControl,{label:(0,m.__)("Zoom","maps-block-apple"),value:o,onChange:e=>h({zoom:e}),min:0,max:20,step:.5}),(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Zoom Enabled","maps-block-apple"),checked:s,onChange:e=>h({isZoomEnabled:e})}),s&&(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Show Zoom Control","maps-block-apple"),checked:r,onChange:e=>h({showsZoomControl:e})}),(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Rotation Enabled","maps-block-apple"),checked:i,onChange:e=>h({isRotationEnabled:e})}),i&&(0,p.createElement)(c.__experimentalToggleGroupControl,{label:(0,m.__)("Compass Visibility","maps-block-apple"),isBlock:!0,value:n,onChange:e=>h({showsCompass:e})},_.map((e=>(0,p.createElement)(c.__experimentalToggleGroupControlOption,{...e,key:e.value})))),(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Scroll Enabled","maps-block-apple"),checked:d,onChange:e=>h({isScrollEnabled:e})}),(0,p.createElement)(c.__experimentalToggleGroupControl,{label:(0,m.__)("Scale Visibility","maps-block-apple"),value:u,isBlock:!0,onChange:e=>h({showsScale:e})},_.map((e=>(0,p.createElement)(c.__experimentalToggleGroupControlOption,{...e,key:e.value})))),(0,p.createElement)(c.TextControl,{label:(0,m.__)("Height ( pixels )","maps-block-apple"),value:a,onChange:e=>h({height:e})}))}function C(e){const{searchResults:t,setSearchResults:a,setAttributes:o,map:l}=e;if(0===t.length)return null;const i=e=>{const i=t[e];o({address:i.formattedAddress}),l.update({region:i.region}),a([])};return(0,p.createElement)(c.Popover,{focusOnMount:!1,noArrow:!1,position:"bottom right"},(0,p.createElement)(c.NavigableMenu,{style:{width:"250px",margin:"6px"},onNavigate:i},(0,p.createElement)("ul",null,t.map(((e,t)=>(0,p.createElement)("li",{key:e.muid},(0,p.createElement)(c.Button,{onClick:()=>i(t),style:{borderRadius:"4px",textAlign:"start",width:"100%"}},e.formattedAddress)))))))}function f({latitude:e,longitude:t}){return(0,p.createElement)(p.Fragment,null,(0,p.createElement)("p",null,(0,m.__)("Coordinates: ","maps-block-apple"),`${e.toFixed(4)}, ${t.toFixed(4)}`))}function S(e){const{map:t,mapkit:a,attributes:{latitude:o,longitude:l,address:i},setAttributes:n}=e,[s,r]=(0,d.useState)([]),[u,h]=(0,d.useState)([]);if((0,d.useEffect)((()=>{r("")}),[i]),!a)return null;const b=new a.Geocoder,g=(e,t)=>{t.results&&h(t.results)};return(0,p.createElement)(c.PanelBody,{title:(0,m.__)("Location Settings","maps-block-apple")},(0,p.createElement)("div",null,(0,p.createElement)(c.SearchControl,{label:(0,m.__)("Search for a Location","maps-block-apple"),value:s,onChange:e=>{e?b.lookup(e,g):h([]),r(e)}}),(0,p.createElement)(C,{map:t,setAttributes:n,searchResults:u,setSearchResults:h})),(0,p.createElement)(f,{latitude:o,longitude:l}))}function T(e){const{marker:t,update:a}=e,o=["image"],l=e=>{a({...t,glyphImageId:e.id,glyphImage:e.url})};return(0,p.createElement)("div",{className:"maps-block-apple-marker-uploader"},(0,p.createElement)(c.BaseControl,{id:"marker-icon-control",label:(0,m.__)("Marker Icon","maps-block-apple")},(0,p.createElement)(h.MediaUploadCheck,null,(0,p.createElement)(h.MediaUpload,{allowedTypes:o,render:({open:e})=>(0,p.createElement)(c.Button,{className:t.glyphImageId?"editor-post-featured-image__preview":"editor-post-featured-image__toggle",onClick:e},!t.glyphImageId&&(0,m.__)("Choose an icon","maps-block-apple"),t.glyphImageId&&t.glyphImage&&(0,p.createElement)("img",{src:t.glyphImage,alt:(0,m.__)("Marker icon","maps-block-apple")})),onSelect:l,value:t.glyphImageId})),!!t.glyphImageId&&(0,p.createElement)(h.MediaUploadCheck,null,t.glyphImage&&(0,p.createElement)(h.MediaUpload,{onSelect:l,allowedTypes:o,render:({open:e})=>(0,p.createElement)(c.Button,{onClick:e,variant:"secondary",className:"replace-marker-icon"},(0,m.__)("Replace icon","maps-block-apple"))}),(0,p.createElement)(c.Button,{className:"remove-marker-icon",onClick:()=>{a({...t,glyphImageId:void 0,glyphImage:void 0})},variant:"link",isDestructive:!0},(0,m.__)("Remove icon","maps-block-apple")))))}function M(e){const{marker:t,remove:a,update:o}=e,i=(0,l.useSelect)((e=>e("core/block-editor").getSettings().colors));return(0,p.createElement)(c.PanelBody,{title:t.title,className:"marker-edit",icon:"location",initialOpen:!1},(0,p.createElement)(c.TextControl,{label:(0,m.__)("Title","maps-block-apple"),value:t.title,onChange:e=>o({...t,title:e})}),(0,p.createElement)(c.TextControl,{label:(0,m.__)("Subtitle","maps-block-apple"),value:t.subtitle,onChange:e=>o({...t,subtitle:e})}),(0,p.createElement)(c.PanelRow,null,(0,p.createElement)("label",{htmlFor:"marker-color-control"},(0,m.__)("Marker Color","maps-block-apple")),(0,p.createElement)(c.ColorIndicator,{id:"marker-color-control",colorValue:t.color})),(0,p.createElement)(c.ColorPalette,{value:t.color,colors:i,onChange:e=>o({...t,color:e})}),(0,p.createElement)(c.PanelRow,null,(0,p.createElement)("label",{htmlFor:"glyph-color-control"},(0,m.__)("Icon Color","maps-block-apple")),(0,p.createElement)(c.ColorIndicator,{id:"glyph-color-control",colorValue:t.glyphColor})),(0,p.createElement)(c.ColorPalette,{value:t.glyphColor,colors:i,onChange:e=>o({...t,glyphColor:e})}),(0,p.createElement)(T,{marker:t,update:o}),(0,p.createElement)(c.PanelRow,null,(0,p.createElement)(f,{latitude:t.latitude,longitude:t.longitude})),(0,p.createElement)(c.PanelRow,null,(0,p.createElement)(c.Button,{isLink:!0,icon:"no",isDestructive:!0,onClick:a},(0,m.__)("Remove Marker","maps-block-apple"))))}function A(e){const{attributes:{markers:t},setAttributes:a}=e,o=e=>o=>{const l=[...t];l[e]=o,a({markers:l})},l=e=>()=>{const o=[...t];o.splice(e,1),a({markers:o})};return t.length?(0,p.createElement)(c.PanelBody,{title:(0,m.__)("Marker Settings","apple-maps-wordpress")},t.map(((e,t)=>(0,p.createElement)(M,{key:t,marker:e,update:o(t),remove:l(t)}))),(0,p.createElement)(c.Tip,null,(0,m.__)("You can move a marker by long pressing on it.","maps-block-apple"))):null}function R(e){const{isAuthenticated:t}=e;return t?(0,p.createElement)(h.InspectorControls,null,(0,p.createElement)(S,{...e}),(0,p.createElement)(v,{...e}),(0,p.createElement)(A,{...e})):(0,p.createElement)(h.InspectorControls,null,(0,p.createElement)(c.PanelBody,null,(0,p.createElement)("p",null,(0,m.__)("You need to confirm your access to Apple Maps before you can continue.","maps-block-apple"))))}function I({children:e,fallback:t}){return(0,l.useSelect)((e=>e("core").canUser("update","settings")))?e:t||null}const z=function(){return(0,p.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"none",viewBox:"0 0 40 52"},(0,p.createElement)("path",{fill:"#333",fillRule:"evenodd",d:"M37.15 9.802c0 4.936-3.698 9.05-8.46 9.709v11.854l-1.304 3.92-1.303-3.92V19.521c-4.8-.626-8.536-4.757-8.536-9.72 0-5.39 4.41-9.801 9.802-9.801 5.39 0 9.801 4.41 9.801 9.802zm-15.224-2.38c.74.633 2.088.274 3.01-.802.922-1.077 1.068-2.464.327-3.098-.74-.634-2.088-.275-3.01.802-.921 1.076-1.068 2.463-.327 3.097z",clipRule:"evenodd"}),(0,p.createElement)("path",{fill:"#333",d:"M12.85 25l11.277 3.776v2.589l3.26 8.821 3.258-8.821v-2.483L40 25v21.736l-12.124 4.93-15.026-4.93L0 51.666V30.032L12.85 25z"}))},x={top:!1,right:!1,bottom:!0,left:!1,topRight:!1,bottomRight:!1,bottomLeft:!1,topLeft:!1};function B({onResizeStart:e,onResize:t,onResizeStop:a,...o}){const[l,i]=(0,d.useState)(!1);return(0,p.createElement)(c.ResizableBox,{style:{position:"absolute",top:0,left:0,right:0,bottom:0},className:"apple-maps-block__resize-container "+(l?"is-resizing":""),enable:x,onResizeStart:(a,o,l)=>{e(l.clientHeight),t(l.clientHeight)},onResize:(e,a,o)=>{t(o.clientHeight),l||i(!0)},onResizeStop:(e,t,o)=>{a(o.clientHeight),i(!1)},minHeight:100,...o})}const P=(0,d.memo)((e=>{const{map:t,isAuthenticated:a,clientId:o,setAttributes:l,setMap:i,mapkit:n}=e,s=!!t,r=(0,u.useRefEffect)((e=>{if(n)return a&&!s&&i(new k(e,o,l)),()=>{s&&(t.destroy(),i(null))}}),[n,a,t,o,l]);return(0,p.createElement)("div",{ref:r})})),N=JSON.parse('{"name":"tenup/maps-block-apple","title":"Apple Maps","category":"embed","description":"Add an Apple Map to your site.","apiVersion":3,"keywords":["apple","map","apple map"],"attributes":{"address":{"type":"string","default":""},"height":{"type":"string","default":"450"},"latitude":{"type":"number","default":51.48762585296625},"longitude":{"type":"number","default":-0.1326724377053381},"rotation":{"type":"number","default":0},"zoom":{"type":"number","default":15},"mapType":{"type":"string","default":"standard"},"showsMapTypeControl":{"type":"boolean","default":true},"isRotationEnabled":{"type":"boolean","default":true},"showsCompass":{"type":"string","default":"adaptive"},"isZoomEnabled":{"type":"boolean","default":true},"showsZoomControl":{"type":"boolean","default":true},"isScrollEnabled":{"type":"boolean","default":true},"showsScale":{"type":"string","default":"adaptive"},"markers":{"type":"array","default":[]}},"example":{"attributes":{"latitude":51.48762585296625,"longitude":-0.1326724377053381}},"supports":{"align":["wide","full"],"spacing":{"margin":true},"html":false},"editorScript":"maps-block-apple-block","viewScript":"maps-block-apple-frontend","editorStyle":"file:build/index.css"}'),{Map:L,FeatureVisibility:V}=mapkit,O=[{attributes:{...N.attributes,mapType:{type:"string",default:L.MapTypes.Standard},showsCompass:{type:"string",default:V.Adaptive},showsScale:{type:"string",default:V.Adaptive}},save(e){const{attributes:{mapType:t,height:a,latitude:o,longitude:l,rotation:i,zoom:n,showsMapTypeControl:s,isRotationEnabled:r,showsCompass:c,isZoomEnabled:m,showsZoomControl:d,isScrollEnabled:u,showsScale:b,markers:g}}=e,y=h.useBlockProps.save();return(0,p.createElement)("div",{...y,"data-map-type":t,"data-latitude":o,"data-longitude":l,"data-rotation":i,"data-zoom":n,"data-shows-map-type-control":s,"data-is-rotation-enabled":r,"data-shows-compass":c,"data-is-zoom-enabled":m,"data-shows-zoom-control":d,"data-is-scroll-enabled":u,"data-shows-scale":b,style:{height:`${a}px`}},g.map(((e,t)=>(0,p.createElement)("div",{key:t,className:"marker-annotation","data-latitude":e.latitude,"data-longitude":e.longitude,"data-title":e.title,"data-subtitle":e.subtitle,"data-color":e.color,"data-glyph-color":e.glyphColor}))))}}],{Map:Z,FeatureVisibility:F}=mapkit;(0,o.registerBlockType)(N,{icon:z,attributes:{...N.attributes,mapType:{type:"string",default:Z.MapTypes.Standard},showsCompass:{type:"string",default:F.Adaptive},showsScale:{type:"string",default:F.Adaptive}},edit:function(e){const{attributes:t,setAttributes:a,clientId:o,isSelected:i}=e,{height:n,latitude:s,longitude:b,markers: g}=t,[y,E]=(0,d.useState)(null),[_,v]=(0,d.useState)(null),C=!!y,f=(0,l.useSelect)((e=>e(r).isAuthenticated())),[S,T]=(0,d.useState)(!0),{updateAuthenticationStatus:M}=(0,l.useDispatch)(r),{toggleSelection:A}=(0,l.useDispatch)(h.store),x=(0,u.useRefEffect)((e=>{const t=e.ownerDocument.defaultView.mapkit;if(!t)return void v(null);v(t);const a=({status:e})=>{switch(e){case"Initialized":case"Refreshed":T(!1),M(!0)}};t.addEventListener("configuration-change",a);const o=()=>{T(!1),M(!1)};t.addEventListener("error",o);const l=()=>{k.authenticateMap(t)};return t.addEventListener("reinitialize",l),f||l(),()=>{t.removeEventListener("configuration-change",a),t.removeEventListener("error",o),t.removeEventListener("reinitialize",l),v(null)}}));(0,d.useEffect)((()=>{f&&T(!1)}),[f]),(0,d.useEffect)((()=>{f&&C&&y.update(t)}),[t,f,y]);const N=(0,u.useDebounce)((e=>{C&&y.addMarkers(e)}),300);(0,d.useEffect)((()=>N(g)),[g]);const L=(0,h.useBlockProps)({ref:x});return S?(0,p.createElement)("div",{...L},(0,p.createElement)(c.Placeholder,{style:{height:`${n}px`},label:(0,m.__)("Block for Apple Maps","maps-block-apple"),icon:z},(0,p.createElement)(c.Spinner,null))):f?(0,p.createElement)(p.Fragment,null,(0,p.createElement)(h.BlockControls,null,(0,p.createElement)(c.ToolbarGroup,null,(0,p.createElement)(c.ToolbarButton,{icon:"location",title:(0,m.__)("Add Marker","apple-maps-wordpress"),onClick:()=>{a({markers:[...g,{latitude:s,longitude:b,title:"Title",id:Symbol("identifier for the marker")}]})}}))),(0,p.createElement)(R,{...e,isAuthenticated:f,map:y,mapkit:_}),(0,p.createElement)("div",{...L},(0,p.createElement)(B,{onResizeStart:()=>{A(!1)},onResize:e=>{y.update({height:e})},onResizeStop:e=>{a({height:e}),A(!0)},showHandle:i,size:{height:n}}),(0,p.createElement)(P,{map:y,setMap:E,isAuthenticated:f,clientId:o,setAttributes:a,mapkit:_}))):(0,p.createElement)(p.Fragment,null,(0,p.createElement)(R,{...e,isAuthenticated:f,map:y,mapkit:_}),(0,p.createElement)("div",{...L},(0,p.createElement)(c.Placeholder,{style:{minHeight:`${n}px`},label:(0,m.__)("Confirm access to Apple Maps","maps-block-apple"),icon:z,isColumnLayout:!0},(0,p.createElement)(I,{fallback:(0,m.__)("Sorry, you are not allowed to do that. Please talk to your Administrator.","maps-block-apple")},(0,p.createElement)("div",{style:{marginBottom:"1em"}},(0,m.__)("In order to include an Apple Map on your website you need to confirm your MapKit credentials below. Here is documentation on how to get those credentials: ","maps-block-apple"),(0,p.createElement)("a",{href:"https://developer.apple.com/documentation/mapkitjs/setting_up_mapkit_js",target:"_blank",rel:"noopener noreferrer"},(0,m.__)("Instructions for creating your MapKit credentials.","maps-block-apple"))),(0,p.createElement)(w,null)))))},save:function(e){const{attributes:{mapType:t,height:a,latitude:o,longitude:l,rotation:i,zoom:n,showsMapTypeControl:s,isRotationEnabled:r,showsCompass:c,isZoomEnabled:m,showsZoomControl:d,isScrollEnabled:u,showsScale:b,markers:g}}=e,y=h.useBlockProps.save({style:{height:`${a}px`}});return(0,p.createElement)("div",{...y,"data-map-type":t,"data-latitude":o,"data-longitude":l,"data-rotation":i,"data-zoom":n,"data-shows-map-type-control":s,"data-is-rotation-enabled":r,"data-shows-compass":c,"data-is-zoom-enabled":m,"data-shows-zoom-control":d,"data-is-scroll-enabled":u,"data-shows-scale":b},g.map(((e,t)=>(0,p.createElement)("div",{key:t,className:"marker-annotation","data-latitude":e.latitude,"data-longitude":e.longitude,"data-title":e.title,"data-subtitle":e.subtitle,"data-color":e.color,"data-glyph-color":e.glyphColor,"data-glyph-image":e.glyphImage}))))},deprecated:O})})();1 (()=>{"use strict";var e={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var o in a)e.o(a,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:a[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{isAuthenticated:()=>n});var a={};e.r(a),e.d(a,{updateAuthenticationStatus:()=>s});const o=window.wp.blocks,l=window.wp.data,i=(0,l.combineReducers)({authenticationReducer:function(e,t){return"UPDATE_AUTHENTICATION"===t.type?{...e,authenticated:t.isAuthenticated}:e}});function n(e){return Boolean(e?.authenticationReducer?.authenticated)}function s(e){return{type:"UPDATE_AUTHENTICATION",isAuthenticated:e}}const r=(0,l.createReduxStore)("tenup/maps-block-apple",{reducer:i,selectors:t,actions:a});(0,l.register)(r);const p=window.React,c=window.wp.components,m=window.wp.i18n,d=window.wp.element,u=window.wp.compose,h=window.wp.blockEditor,b=window.wp.apiFetch;var g=e.n(b);class y{constructor(e){this.element=e,this.mapOptions={},this.markerElements=this.element.querySelectorAll(".marker-annotation"),this.markers=[...this.markerElements].map((e=>{const{latitude:t,longitude:a,title:o,subtitle:l,color:i,glyphColor:n,glyphImage:s}=e.dataset;return{latitude:Number(t),longitude:Number(a),title:o||"",subtitle:l||"",color:i||null,glyphColor:n||null,glyphImage:s||null}})),this.mapkit=e.ownerDocument.defaultView.mapkit,this.mapkit&&this.init()}init(){this.createMap(),this.addMarkers(this.markers)}createMap(){const{mapType:e,latitude:t,longitude:a,rotation:o,zoom:l,showsMapTypeControl:i=!0,isRotationEnabled:n=!0,showsCompass:s,isZoomEnabled:r=!0,showsZoomControl:p=!0,isScrollEnabled:c=!0,showsScale:m}=this.element.dataset,d=new this.mapkit.Coordinate(Number(t)||51.48762585296625,Number(a)||-.1326724377053381);this.mapOptions={center:d,rotation:Number(o)||0,mapType:e||this.mapkit.Map.MapTypes.Satellite,showsMapTypeControl:"true"===i,isRotationEnabled:"true"===n,isZoomEnabled:"true"===r,showsZoomControl:"true"===p,isScrollEnabled:"true"===c,showsScale:m||this.mapkit.FeatureVisibility.Adaptive},this.mapOptions.isRotationEnabled&&(this.mapOptions.showsCompass=s||this.mapkit.FeatureVisibility.Adaptive),this.map=new this.mapkit.Map(this.element,this.mapOptions),this.map._impl.zoomLevel=Number(l)||15}addMarkers(e){this.clearMarkers();const t=[];e.forEach(((a,o)=>{const{latitude:l,longitude:i,title:n,subtitle:s,titleVisibility:r,subtitleVisibility:p,color:c,glyphColor:m,glyphText:d,glyphImage:u}=a,h=new this.mapkit.Coordinate(Number(l),Number(i)),b={title:n,subtitle:s||null,titleVisibility:r||this.mapkit.FeatureVisibility.Visible,subtitleVisibility:p||this.mapkit.FeatureVisibility.Visible,color:c||"green",glyphColor:m||"white",glyphText:d||"",draggable:!!this.isEditor};u&&(b.glyphImage={1:u});const g=new this.mapkit.MarkerAnnotation(h,b);this.setAttributes&&g.addEventListener("drag-end",(t=>{const{target:{coordinate:a}}=t,l=[...e];l[o].latitude=a.latitude,l[o].longitude=a.longitude,this.setAttributes({markers:l})})),t.push(g)})),this.map.addAnnotations(t)}clearMarkers(){this.map.removeAnnotations(this.map.annotations)}static authenticateMap(e){g()({path:"MapsBlockApple/v1/GetJWT/"}).then((()=>{e.init({authorizationCallback(e){g()({path:"MapsBlockApple/v1/GetJWT/"}).then(e)}})})).catch((t=>{(0,l.dispatch)("core/notices").createErrorNotice(t.message,{isDismissible:!0,type:"snackbar"}),e.dispatchEvent(new Event("error"))}))}}class k extends y{constructor(e,t,a){super(e),this.isEditor=!0,this.clientId=t,this.setAttributes=a,this.initEdit()}initEdit(){this.addListeners(),this.addMarkers(this.markers)}destroy(){this.map&&this.map.destroy()}addListeners(){this.map.element.addEventListener("click",(()=>{(0,l.dispatch)("core/block-editor").selectBlock(this.clientId)})),this.map.addEventListener("map-type-change",(()=>{this.setAttributes({mapType:this.map.mapType})})),this.map.addEventListener("region-change-end",(()=>{this.setAttributes({rotation:this.map.rotation,latitude:this.map.center.latitude,longitude:this.map.center.longitude,zoom:this.map._impl.zoomLevel})}))}update(e){const{mapType:t,latitude:a,longitude:o,rotation:l,zoom:i,showsMapTypeControl:n,isRotationEnabled:s,showsCompass:r,isZoomEnabled:p,showsZoomControl:c,isScrollEnabled:m,showsScale:d,region:u,height:h}=e;h&&(this.element.style.height=`${h}px`),this.map&&(u&&""!==u&&this.map.setRegionAnimated(u,!0),t&&t!==this?.map?.mapType&&(this.map.mapType=e.mapType),i&&i!==this.map?._impl?.zoomLevel&&(this.map._impl.zoomLevel=i),l&&l!==this?.map?.rotation&&this.map.setRotationAnimated(Number(l)),a&&o&&(a!==this?.map?.center?.latitude||o!==this?.map?.center?.longitude)&&this.map.setCenterAnimated(new this.mapkit.Coordinate(a,o)),void 0!==n&&n!==this?.map?.showsMapTypeControl&&(this.map.showsMapTypeControl=!!n),void 0!==s&&s!==this?.map?.isRotationEnabled&&(this.map.isRotationEnabled=!!s),r!==this?.map?.showsCompass&&this.map.isRotationEnabled&&(this.map.showsCompass=r||this.mapkit.FeatureVisibility.Adaptive),void 0!==p&&p!==this?.map?.isZoomEnabled&&(this.map.isZoomEnabled=!!p),void 0!==c&&c!==this?.map?.showsZoomControl&&(this.map.showsZoomControl=!!c),void 0!==m&&m!==this?.map?.isScrollEnabled&&(this.map.isScrollEnabled=!!m),d!==this?.map?.showsScale&&(this.map.showsScale=d||this.mapkit.FeatureVisibility.Adaptive))}}const E=Object.keys(mapkit.Map.MapTypes).map((e=>({label:"MutedStandard"===e?(0,m.__)("Muted","maps-block-apple"):e,value:mapkit.Map.MapTypes[e]}))),_=Object.keys(mapkit.FeatureVisibility).map((e=>({label:e,value:mapkit.FeatureVisibility[e]})));function w(){const[e,t]=(0,d.useState)(""),[a,o]=(0,d.useState)(""),[i,n]=(0,d.useState)(""),[s,r]=(0,d.useState)(!1),u=(0,l.useSelect)((e=>e("core").getEntityRecord("root","site")),[]);return(0,d.useEffect)((()=>{if(u){const{maps_block_apple:{private_key:e,team_id:a,key_id:l}}=u;t(e),o(l),n(a)}}),[u]),(0,p.createElement)(p.Fragment,null,(0,p.createElement)(c.TextareaControl,{label:(0,m.__)("Please enter your Private Key","maps-block-apple"),readOnly:s,name:"private_key",value:e,onChange:e=>t(e)}),(0,p.createElement)(c.TextControl,{label:(0,m.__)("Please enter your Key ID","maps-block-apple"),readOnly:s,name:"key_id",value:a,onChange:e=>o(e)}),(0,p.createElement)(c.TextControl,{label:(0,m.__)("Please enter your Team ID","maps-block-apple"),readOnly:s,name:"team_id",value:i,onChange:e=>n(e)}),(0,p.createElement)(c.Button,{isPrimary:!0,disabled:s,isBusy:s,onClick:()=>{r(!0),(0,l.dispatch)("core").saveEntityRecord("root","site",{maps_block_apple:{private_key:e,team_id:i,key_id:a}}).then((({maps_block_apple:{private_key:e,team_id:a,key_id:l}})=>{t(e),o(l),n(a),r(!1),mapkit.dispatchEvent(new CustomEvent("reinitialize"))})).catch((e=>{(0,l.dispatch)("core/notices").createErrorNotice(e.message,{isDismissible:!0,type:"snackbar"}),r(!1)}))}},(0,m.__)("Confirm MapKit Credentials","maps-block-apple")))}function v(e){const{attributes:{mapType:t,height:a,zoom:o,showsMapTypeControl:l,isRotationEnabled:i,showsCompass:n,isZoomEnabled:s,showsZoomControl:r,isScrollEnabled:d,showsScale:u},setAttributes:h}=e;return(0,p.createElement)(c.PanelBody,{title:(0,m.__)("Display Settings","maps-block-apple")},(0,p.createElement)(c.__experimentalToggleGroupControl,{label:(0,m.__)("Map Type","maps-block-apple"),isBlock:!0,isAdaptiveWidth:!0,value:t,onChange:e=>h({mapType:e})},E.map((e=>(0,p.createElement)(c.__experimentalToggleGroupControlOption,{...e,key:e.value})))),(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Show Map Type Control","maps-block-apple"),checked:l,onChange:e=>h({showsMapTypeControl:e})}),(0,p.createElement)(c.RangeControl,{label:(0,m.__)("Zoom","maps-block-apple"),value:o,onChange:e=>h({zoom:e}),min:0,max:20,step:.5}),(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Zoom Enabled","maps-block-apple"),checked:s,onChange:e=>h({isZoomEnabled:e})}),s&&(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Show Zoom Control","maps-block-apple"),checked:r,onChange:e=>h({showsZoomControl:e})}),(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Rotation Enabled","maps-block-apple"),checked:i,onChange:e=>h({isRotationEnabled:e})}),i&&(0,p.createElement)(c.__experimentalToggleGroupControl,{label:(0,m.__)("Compass Visibility","maps-block-apple"),isBlock:!0,value:n,onChange:e=>h({showsCompass:e})},_.map((e=>(0,p.createElement)(c.__experimentalToggleGroupControlOption,{...e,key:e.value})))),(0,p.createElement)(c.ToggleControl,{label:(0,m.__)("Scroll Enabled","maps-block-apple"),checked:d,onChange:e=>h({isScrollEnabled:e})}),(0,p.createElement)(c.__experimentalToggleGroupControl,{label:(0,m.__)("Scale Visibility","maps-block-apple"),value:u,isBlock:!0,onChange:e=>h({showsScale:e})},_.map((e=>(0,p.createElement)(c.__experimentalToggleGroupControlOption,{...e,key:e.value})))),(0,p.createElement)(c.TextControl,{label:(0,m.__)("Height ( pixels )","maps-block-apple"),value:a,onChange:e=>h({height:e})}))}function C(e){const{searchResults:t,setSearchResults:a,setAttributes:o,map:l}=e;if(0===t.length)return null;const i=e=>{const i=t[e];o({address:i.formattedAddress}),l.update({region:i.region}),a([])};return(0,p.createElement)(c.Popover,{focusOnMount:!1,noArrow:!1,position:"bottom right"},(0,p.createElement)(c.NavigableMenu,{style:{width:"250px",margin:"6px"},onNavigate:i},(0,p.createElement)("ul",null,t.map(((e,t)=>(0,p.createElement)("li",{key:e.muid},(0,p.createElement)(c.Button,{onClick:()=>i(t),style:{borderRadius:"4px",textAlign:"start",width:"100%"}},e.formattedAddress)))))))}function f({latitude:e,longitude:t}){return(0,p.createElement)(p.Fragment,null,(0,p.createElement)("p",null,(0,m.__)("Coordinates: ","maps-block-apple"),`${e.toFixed(4)}, ${t.toFixed(4)}`))}function S(e){const{map:t,mapkit:a,attributes:{latitude:o,longitude:l,address:i},setAttributes:n}=e,[s,r]=(0,d.useState)([]),[u,h]=(0,d.useState)([]);if((0,d.useEffect)((()=>{r("")}),[i]),!a)return null;const b=new a.Geocoder,g=(e,t)=>{t.results&&h(t.results)};return(0,p.createElement)(c.PanelBody,{title:(0,m.__)("Location Settings","maps-block-apple")},(0,p.createElement)("div",null,(0,p.createElement)(c.SearchControl,{label:(0,m.__)("Search for a Location","maps-block-apple"),value:s,onChange:e=>{e?b.lookup(e,g):h([]),r(e)}}),(0,p.createElement)(C,{map:t,setAttributes:n,searchResults:u,setSearchResults:h})),(0,p.createElement)(f,{latitude:o,longitude:l}))}function T(e){const{marker:t,update:a}=e,o=["image"],l=e=>{a({...t,glyphImageId:e.id,glyphImage:e.url})};return(0,p.createElement)("div",{className:"maps-block-apple-marker-uploader"},(0,p.createElement)(c.BaseControl,{id:"marker-icon-control",label:(0,m.__)("Marker Icon","maps-block-apple")},(0,p.createElement)(h.MediaUploadCheck,null,(0,p.createElement)(h.MediaUpload,{allowedTypes:o,render:({open:e})=>(0,p.createElement)(c.Button,{className:t.glyphImageId?"editor-post-featured-image__preview":"editor-post-featured-image__toggle",onClick:e},!t.glyphImageId&&(0,m.__)("Choose an icon","maps-block-apple"),t.glyphImageId&&t.glyphImage&&(0,p.createElement)("img",{src:t.glyphImage,alt:(0,m.__)("Marker icon","maps-block-apple")})),onSelect:l,value:t.glyphImageId})),!!t.glyphImageId&&(0,p.createElement)(h.MediaUploadCheck,null,t.glyphImage&&(0,p.createElement)(h.MediaUpload,{onSelect:l,allowedTypes:o,render:({open:e})=>(0,p.createElement)(c.Button,{onClick:e,variant:"secondary",className:"replace-marker-icon"},(0,m.__)("Replace icon","maps-block-apple"))}),(0,p.createElement)(c.Button,{className:"remove-marker-icon",onClick:()=>{a({...t,glyphImageId:void 0,glyphImage:void 0})},variant:"link",isDestructive:!0},(0,m.__)("Remove icon","maps-block-apple")))))}function M(e){const{marker:t,remove:a,update:o}=e,i=(0,l.useSelect)((e=>e("core/block-editor").getSettings().colors));return(0,p.createElement)(c.PanelBody,{title:t.title,className:"marker-edit",icon:"location",initialOpen:!1},(0,p.createElement)(c.TextControl,{label:(0,m.__)("Title","maps-block-apple"),value:t.title,onChange:e=>o({...t,title:e})}),(0,p.createElement)(c.TextControl,{label:(0,m.__)("Subtitle","maps-block-apple"),value:t.subtitle,onChange:e=>o({...t,subtitle:e})}),(0,p.createElement)(c.PanelRow,null,(0,p.createElement)("label",{htmlFor:"marker-color-control"},(0,m.__)("Marker Color","maps-block-apple")),(0,p.createElement)(c.ColorIndicator,{id:"marker-color-control",colorValue:t.color})),(0,p.createElement)(c.ColorPalette,{value:t.color,colors:i,onChange:e=>o({...t,color:e})}),(0,p.createElement)(c.PanelRow,null,(0,p.createElement)("label",{htmlFor:"glyph-color-control"},(0,m.__)("Icon Color","maps-block-apple")),(0,p.createElement)(c.ColorIndicator,{id:"glyph-color-control",colorValue:t.glyphColor})),(0,p.createElement)(c.ColorPalette,{value:t.glyphColor,colors:i,onChange:e=>o({...t,glyphColor:e})}),(0,p.createElement)(T,{marker:t,update:o}),(0,p.createElement)(c.PanelRow,null,(0,p.createElement)(f,{latitude:t.latitude,longitude:t.longitude})),(0,p.createElement)(c.PanelRow,null,(0,p.createElement)(c.Button,{isLink:!0,icon:"no",isDestructive:!0,onClick:a},(0,m.__)("Remove Marker","maps-block-apple"))))}function A(e){const{attributes:{markers:t},setAttributes:a}=e,o=e=>o=>{const l=[...t];l[e]=o,a({markers:l})},l=e=>()=>{const o=[...t];o.splice(e,1),a({markers:o})};return t.length?(0,p.createElement)(c.PanelBody,{title:(0,m.__)("Marker Settings","apple-maps-wordpress")},t.map(((e,t)=>(0,p.createElement)(M,{key:t,marker:e,update:o(t),remove:l(t)}))),(0,p.createElement)(c.Tip,null,(0,m.__)("You can move a marker by long pressing on it.","maps-block-apple"))):null}function R(e){const{isAuthenticated:t}=e;return t?(0,p.createElement)(h.InspectorControls,null,(0,p.createElement)(S,{...e}),(0,p.createElement)(v,{...e}),(0,p.createElement)(A,{...e})):(0,p.createElement)(h.InspectorControls,null,(0,p.createElement)(c.PanelBody,null,(0,p.createElement)("p",null,(0,m.__)("You need to confirm your access to Apple Maps before you can continue.","maps-block-apple"))))}function I({children:e,fallback:t}){return(0,l.useSelect)((e=>e("core").canUser("update","settings")))?e:t||null}const z=function(){return(0,p.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"none",viewBox:"0 0 40 52"},(0,p.createElement)("path",{fill:"#333",fillRule:"evenodd",d:"M37.15 9.802c0 4.936-3.698 9.05-8.46 9.709v11.854l-1.304 3.92-1.303-3.92V19.521c-4.8-.626-8.536-4.757-8.536-9.72 0-5.39 4.41-9.801 9.802-9.801 5.39 0 9.801 4.41 9.801 9.802zm-15.224-2.38c.74.633 2.088.274 3.01-.802.922-1.077 1.068-2.464.327-3.098-.74-.634-2.088-.275-3.01.802-.921 1.076-1.068 2.463-.327 3.097z",clipRule:"evenodd"}),(0,p.createElement)("path",{fill:"#333",d:"M12.85 25l11.277 3.776v2.589l3.26 8.821 3.258-8.821v-2.483L40 25v21.736l-12.124 4.93-15.026-4.93L0 51.666V30.032L12.85 25z"}))},x={top:!1,right:!1,bottom:!0,left:!1,topRight:!1,bottomRight:!1,bottomLeft:!1,topLeft:!1};function B({onResizeStart:e,onResize:t,onResizeStop:a,...o}){const[l,i]=(0,d.useState)(!1);return(0,p.createElement)(c.ResizableBox,{style:{position:"absolute",top:0,left:0,right:0,bottom:0},className:"apple-maps-block__resize-container "+(l?"is-resizing":""),enable:x,onResizeStart:(a,o,l)=>{e(l.clientHeight),t(l.clientHeight)},onResize:(e,a,o)=>{t(o.clientHeight),l||i(!0)},onResizeStop:(e,t,o)=>{a(o.clientHeight),i(!1)},minHeight:100,...o})}const P=(0,d.memo)((e=>{const{map:t,isAuthenticated:a,clientId:o,setAttributes:l,setMap:i,mapkit:n}=e,s=!!t,r=(0,u.useRefEffect)((e=>{if(n)return a&&!s&&i(new k(e,o,l)),()=>{s&&(t.destroy(),i(null))}}),[n,a,t,o,l]);return(0,p.createElement)("div",{ref:r})})),N=JSON.parse('{"name":"tenup/maps-block-apple","title":"Apple Maps","category":"embed","description":"Add an Apple Map to your site.","apiVersion":3,"keywords":["apple","map","apple map"],"attributes":{"address":{"type":"string","default":""},"height":{"type":"string","default":"450"},"latitude":{"type":"number","default":51.48762585296625},"longitude":{"type":"number","default":-0.1326724377053381},"rotation":{"type":"number","default":0},"zoom":{"type":"number","default":15},"mapType":{"type":"string","default":"standard"},"showsMapTypeControl":{"type":"boolean","default":true},"isRotationEnabled":{"type":"boolean","default":true},"showsCompass":{"type":"string","default":"adaptive"},"isZoomEnabled":{"type":"boolean","default":true},"showsZoomControl":{"type":"boolean","default":true},"isScrollEnabled":{"type":"boolean","default":true},"showsScale":{"type":"string","default":"adaptive"},"markers":{"type":"array","default":[]}},"example":{"attributes":{"latitude":51.48762585296625,"longitude":-0.1326724377053381}},"supports":{"align":["wide","full"],"spacing":{"margin":true},"html":false},"editorScript":"maps-block-apple-block","viewScript":"maps-block-apple-frontend","editorStyle":"file:build/index.css"}'),{Map:L,FeatureVisibility:V}=mapkit,O=[{attributes:{...N.attributes,mapType:{type:"string",default:L.MapTypes.Standard},showsCompass:{type:"string",default:V.Adaptive},showsScale:{type:"string",default:V.Adaptive}},save(e){const{attributes:{mapType:t,height:a,latitude:o,longitude:l,rotation:i,zoom:n,showsMapTypeControl:s,isRotationEnabled:r,showsCompass:c,isZoomEnabled:m,showsZoomControl:d,isScrollEnabled:u,showsScale:b,markers:g}}=e,y=h.useBlockProps.save();return(0,p.createElement)("div",{...y,"data-map-type":t,"data-latitude":o,"data-longitude":l,"data-rotation":i,"data-zoom":n,"data-shows-map-type-control":s,"data-is-rotation-enabled":r,"data-shows-compass":c,"data-is-zoom-enabled":m,"data-shows-zoom-control":d,"data-is-scroll-enabled":u,"data-shows-scale":b,style:{height:`${a}px`}},g.map(((e,t)=>(0,p.createElement)("div",{key:t,className:"marker-annotation","data-latitude":e.latitude,"data-longitude":e.longitude,"data-title":e.title,"data-subtitle":e.subtitle,"data-color":e.color,"data-glyph-color":e.glyphColor}))))}}],{Map:Z,FeatureVisibility:F}=mapkit;(0,o.registerBlockType)(N,{icon:z,attributes:{...N.attributes,mapType:{type:"string",default:Z.MapTypes.Standard},showsCompass:{type:"string",default:F.Adaptive},showsScale:{type:"string",default:F.Adaptive}},edit:function(e){const{attributes:t,setAttributes:a,clientId:o,isSelected:i}=e,{height:n,latitude:s,longitude:b,markers:y}=t,[E,_]=(0,d.useState)(null),[v,C]=(0,d.useState)(null),f=!!E,S=(0,l.useSelect)((e=>e(r).isAuthenticated())),[T,M]=(0,d.useState)(!0),{updateAuthenticationStatus:A}=(0,l.useDispatch)(r),{toggleSelection:x}=(0,l.useDispatch)(h.store),N=(0,u.useRefEffect)((e=>{const t=e.ownerDocument.defaultView.mapkit;if(!t)return void C(null);C(t);const a=({status:e})=>{switch(e){case"Initialized":case"Refreshed":M(!1),A(!0)}};t.addEventListener("configuration-change",a);const o=()=>{M(!1),A(!1)};t.addEventListener("error",o);const l=async()=>{await(async()=>{try{return!!await g()({path:"MapsBlockApple/v1/GetJWT"})||(M(!1),A(!1),!1)}catch(e){return M(!1),A(!1),!1}})()&&k.authenticateMap(t)};return t.addEventListener("reinitialize",l),S||l(),()=>{t.removeEventListener("configuration-change",a),t.removeEventListener("error",o),t.removeEventListener("reinitialize",l),C(null)}}));(0,d.useEffect)((()=>{S&&M(!1)}),[S]),(0,d.useEffect)((()=>{S&&f&&E.update(t)}),[t,S,E]);const L=(0,u.useDebounce)((e=>{f&&E.addMarkers(e)}),300);(0,d.useEffect)((()=>L(y)),[y]);const V=(0,h.useBlockProps)({ref:N});return T?(0,p.createElement)("div",{...V},(0,p.createElement)(c.Placeholder,{style:{height:`${n}px`},label:(0,m.__)("Block for Apple Maps","maps-block-apple"),icon:z},(0,p.createElement)(c.Spinner,null))):S?(0,p.createElement)(p.Fragment,null,(0,p.createElement)(h.BlockControls,null,(0,p.createElement)(c.ToolbarGroup,null,(0,p.createElement)(c.ToolbarButton,{icon:"location",title:(0,m.__)("Add Marker","apple-maps-wordpress"),onClick:()=>{a({markers:[...y,{latitude:s,longitude:b,title:"Title",id:Symbol("identifier for the marker")}]})}}))),(0,p.createElement)(R,{...e,isAuthenticated:S,map:E,mapkit:v}),(0,p.createElement)("div",{...V},(0,p.createElement)(B,{onResizeStart:()=>{x(!1)},onResize:e=>{E.update({height:e})},onResizeStop:e=>{a({height:e}),x(!0)},showHandle:i,size:{height:n}}),(0,p.createElement)(P,{map:E,setMap:_,isAuthenticated:S,clientId:o,setAttributes:a,mapkit:v}))):(0,p.createElement)(p.Fragment,null,(0,p.createElement)(R,{...e,isAuthenticated:S,map:E,mapkit:v}),(0,p.createElement)("div",{...V},(0,p.createElement)(c.Placeholder,{style:{minHeight:`${n}px`},label:(0,m.__)("Confirm access to Apple Maps","maps-block-apple"),icon:z,isColumnLayout:!0},(0,p.createElement)(I,{fallback:(0,m.__)("Sorry, you are not allowed to do that. Please talk to your Administrator.","maps-block-apple")},(0,p.createElement)("div",{style:{marginBottom:"1em"}},(0,m.__)("In order to include an Apple Map on your website you need to confirm your MapKit credentials below. Here is documentation on how to get those credentials: ","maps-block-apple"),(0,p.createElement)("a",{href:"https://developer.apple.com/documentation/mapkitjs/setting_up_mapkit_js",target:"_blank",rel:"noopener noreferrer"},(0,m.__)("Instructions for creating your MapKit credentials.","maps-block-apple"))),(0,p.createElement)(w,null)))))},save:function(e){const{attributes:{mapType:t,height:a,latitude:o,longitude:l,rotation:i,zoom:n,showsMapTypeControl:s,isRotationEnabled:r,showsCompass:c,isZoomEnabled:m,showsZoomControl:d,isScrollEnabled:u,showsScale:b,markers:g}}=e,y=h.useBlockProps.save({style:{height:`${a}px`}});return(0,p.createElement)("div",{...y,"data-map-type":t,"data-latitude":o,"data-longitude":l,"data-rotation":i,"data-zoom":n,"data-shows-map-type-control":s,"data-is-rotation-enabled":r,"data-shows-compass":c,"data-is-zoom-enabled":m,"data-shows-zoom-control":d,"data-is-scroll-enabled":u,"data-shows-scale":b},g.map(((e,t)=>(0,p.createElement)("div",{key:t,className:"marker-annotation","data-latitude":e.latitude,"data-longitude":e.longitude,"data-title":e.title,"data-subtitle":e.subtitle,"data-color":e.color,"data-glyph-color":e.glyphColor,"data-glyph-image":e.glyphImage}))))},deprecated:O})})(); -
maps-block-apple/trunk/maps-block-apple.php
r3139952 r3327590 4 4 * Plugin URI: https://github.com/10up/maps-block-apple 5 5 * Description: An Apple Maps block for the WordPress block editor (Gutenberg). 6 * Version: 1.1. 47 * Requires at least: 6. 46 * Version: 1.1.5 7 * Requires at least: 6.6 8 8 * Requires PHP: 7.4 9 9 * Author: 10up … … 19 19 20 20 // Useful global constants. 21 define( 'MAPS_BLOCK_APPLE_VERSION', '1.1. 4' );21 define( 'MAPS_BLOCK_APPLE_VERSION', '1.1.5' ); 22 22 define( 'MAPS_BLOCK_APPLE_URL', plugin_dir_url( __FILE__ ) ); 23 23 define( 'MAPS_BLOCK_APPLE_PATH', dirname( __FILE__ ) . '/' ); -
maps-block-apple/trunk/readme.txt
r3280004 r3327590 2 2 Contributors: 10up, helen, welcher, fabiankaegy, dinhtungdu, jeffpaul 3 3 Tags: apple maps, map block, block 4 Requires at least: 6.65 4 Tested up to: 6.8 6 Stable tag: 1.1. 45 Stable tag: 1.1.5 7 6 License: GPL-2.0-or-later 8 7 License URI: https://spdx.org/licenses/GPL-2.0-or-later.html … … 72 71 == Changelog == 73 72 73 = 1.1.5 - 2025-07-14 = 74 * **Note that this release bumps the WordPress minimum version from 6.4 to 6.6.** 75 76 * **Changed:** Bump WordPress "tested up to" version 6.8 (props [@sudip-md](https://github.com/sudip-md), [@mehidi258](https://github.com/mehidi258), [@jeffpaul](https://github.com/jeffpaul), [@dkotter](https://github.com/dkotter), [@peterwilsoncc](https://github.com/peterwilsoncc), [@Rishabh-fueled](https://github.com/@Rishabh-fueled) via [#229](https://github.com/10up/maps-block-apple/pull/229), [#230](https://github.com/10up/maps-block-apple/pull/230), [#237](https://github.com/10up/maps-block-apple/pull/237), [#238](https://github.com/10up/maps-block-apple/pull/238)). 77 * **Changed:** Bump WordPress minimum supported version to 6.6 (props [@sudip-md](https://github.com/sudip-md), [@mehidi258](https://github.com/mehidi258), [@jeffpaul](https://github.com/jeffpaul), [@dkotter](https://github.com/dkotter), [@peterwilsoncc](https://github.com/peterwilsoncc), [@Rishabh-fueled](https://github.com/@Rishabh-fueled) via [#229](https://github.com/10up/maps-block-apple/pull/229), [#230](https://github.com/10up/maps-block-apple/pull/230), [#238](https://github.com/10up/maps-block-apple/pull/238)). 78 * **Fixed:** Block crash when no Apple Maps credentials are configured (props [@elvismdev](https://github.com/elvismdev), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#233](https://github.com/10up/maps-block-apple/pull/233)). 79 * **Security:** Bump `braces` from 3.0.2 to 3.0.3, `express` from 4.18.2 to 4.19.2, `webpack` from 5.89.0 to 5.94.0 and `webpack-dev-middleware` from 5.3.3 to 5.3.4 (props [@dependabot](https://github.com/apps/dependabot), [@faisal-alvi](https://github.com/faisal-alvi) via [#224](https://github.com/10up/maps-block-apple/pull/224)). 80 * **Security:** Bump `@wordpress/scripts` from 27.9.0 to 30.6.0, `body-parser` from 1.20.2 to 1.20.3, `express` from 4.19.2 to 4.21.1, `ws` from 7.5.9 to 8.18.0, `send` from 0.18.0 to 0.19.0 and `serve-static` from 1.15.0 to 1.16.2 (props [@dependabot](https://github.com/apps/dependabot), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#231](https://github.com/10up/maps-block-apple/pull/231)). 81 * **Security:** Bump `@wordpress/e2e-test-utils-playwright` from 1.13.0 to 1.18.0, `serialize-javascript` from 6.0.1 to 6.0.2, `mocha` from 10.2.0 to 11.1.0 and removes `cookie` (props [@dependabot](https://github.com/apps/dependabot), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#234](https://github.com/10up/maps-block-apple/pull/234)). 82 * **Security:** Bump `axios` from 1.7.4 to 1.9.0 and `http-proxy-middleware` from 2.0.6 to 2.0.9 (props [@dependabot](https://github.com/apps/dependabot), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#241](https://github.com/10up/maps-block-apple/pull/241)). 83 74 84 = 1.1.4 - 2024-08-22 = 75 85 * **Note that this release bumps the WordPress minimum version from 5.8 to 6.4.** … … 85 95 * **Developer:** Support for the WordPress.org plugin preview (props [@dkotter](https://github.com/dkotter), [@jeffpaul](https://github.com/jeffpaul) via [#196](https://github.com/10up/maps-block-apple/pull/196)). 86 96 87 = 1.1.3 - 2023-11-16 =88 * **Changed:** Bump WordPress "tested up to" version to 6.4 (props [@QAharshalkadu](https://github.com/QAharshalkadu), [@jeffpaul](https://github.com/jeffpaul) via [#190](https://github.com/10up/maps-block-apple/pull/190), [#191](https://github.com/10up/maps-block-apple/pull/191)).89 90 = 1.1.2 - 2023-10-16 =91 * **Changed:** Bump WordPress "tested up to" version to 6.3 (props [@QAharshalkadu](https://github.com/QAharshalkadu), [@jeffpaul](https://github.com/jeffpaul) via [#179](https://github.com/10up/maps-block-apple/pull/179)).92 * **Fixed:** Ensure our Mapkit JS only loads when a Map block is in place (props [@jayedul](https://github.com/jayedul), [@fabiankaegy](https://github.com/fabiankaegy), [@faisal-alvi](https://github.com/faisal-alvi) via [#161](https://github.com/10up/maps-block-apple/pull/161)).93 * **Fixed:** Better error handling for environments that don't match our minimum PHP version (props [@rahulsprajapati](https://github.com/rahulsprajapati), [@dkotter](https://github.com/dkotter), [@ravinderk](https://github.com/ravinderk) via [#174](https://github.com/10up/maps-block-apple/pull/174)).94 * **Fixed:** Ensure that the Apple Maps block works fine in WordPress 6.4 (props [@iamdharmesh](https://github.com/iamdharmesh), [@fabiankaegy](https://github.com/fabiankaegy), [@faisal-alvi](https://github.com/faisal-alvi) via [#183](https://github.com/10up/maps-block-apple/pull/183)).95 * **Fixed:** Ensure that our Cypress E2E tests pass (props [@iamdharmesh](https://github.com/iamdharmesh), [@Sidsector9](https://github.com/Sidsector9) via [#181](https://github.com/10up/maps-block-apple/pull/181)).96 * **Security:** Bump `word-wrap` from 1.2.3 to 1.2.4 (props [@dependabot](https://github.com/apps/dependabot), [@ravinderk](https://github.com/ravinderk) via [#173](https://github.com/10up/maps-block-apple/pull/173)).97 * **Security:** Bump `tough-cookie` from 4.1.2 to 4.1.3 (props [@dependabot](https://github.com/apps/dependabot), [@faisal-alvi](https://github.com/faisal-alvi) via [#176](https://github.com/10up/maps-block-apple/pull/176)).98 * **Security:** Bump `cypress` from 11.2.0 to 13.2.0 and `@cypress/request` from 2.88.11 to 3.0.0 (props [@dependabot](https://github.com/apps/dependabot), [@ravinderk](https://github.com/ravinderk), [@faisal-alvi](https://github.com/faisal-alvi), [@iamdharmesh](https://github.com/iamdharmesh), [@Sidsector9](https://github.com/Sidsector9) via [#176](https://github.com/10up/maps-block-apple/pull/176), [#180](https://github.com/10up/maps-block-apple/pull/180), [#181](https://github.com/10up/maps-block-apple/pull/181)).99 * **Security:** Bump `postcss` from 8.4.23 to 8.4.31 (props [@dependabot](https://github.com/apps/dependabot), [@ravinderk](https://github.com/ravinderk) via [#184](https://github.com/10up/maps-block-apple/pull/184)).100 * **Security:** Bump `@10up/cypress-wp-utils` from 0.1.0 to 0.2.0, `@wordpress/env` from 5.6.0 to 8.7.0 and `cypress-mochawesome-reporter` from 3.4.0 to 3.6.0 (props [@iamdharmesh](https://github.com/iamdharmesh), [@Sidsector9](https://github.com/Sidsector9) via [#181](https://github.com/10up/maps-block-apple/pull/181)).101 102 = 1.1.1 - 2023-06-21 =103 * **Note that this release bumps the PHP minimum supported version from 5.6 to 7.4.**104 105 * **Added:** Mochawesome reporter added for Cypress test report (props [@jayedul](https://github.com/jayedul), [@iamdharmesh](https://github.com/iamdharmesh) via [#168](https://github.com/10up/maps-block-apple/pull/168)).106 * **Changed:** Bump PHP minimum supported version from 5.6 to 7.4 (props [@jayedul](https://github.com/jayedul), [@csloisel](https://github.com/csloisel), [@faisal-alvi](https://github.com/faisal-alvi), [@dkotter](https://github.com/dkotter) via [#133](https://github.com/10up/maps-block-apple/pull/133)).107 * **Changed:** Run E2E tests on the zip generated by "Build release zip" action (props [@jayedul](https://github.com/jayedul), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#163](https://github.com/10up/maps-block-apple/pull/163)).108 * **Changed:** Bump WordPress "tested up to" version to 6.2 (props [@jayedul](https://github.com/jayedul), [@peterwilsoncc](https://github.com/peterwilsoncc), [@Sidsector9](https://github.com/Sidsector9) via [#165](https://github.com/10up/maps-block-apple/pull/165), [#167](https://github.com/10up/maps-block-apple/pull/167)).109 * **Changed:** Update Cypress E2E and Dependency Review GitHub Actions (props [@jayedul](https://github.com/jayedul), [@jeffpaul](https://github.com/jeffpaul), [@Sidsector9](https://github.com/Sidsector9) via [#166](https://github.com/10up/maps-block-apple/pull/166), [#169](https://github.com/10up/maps-block-apple/pull/169)).110 * **Security:** Bump `simple-git` from 3.15.1 to 3.16.0 (props [@dependabot](https://github.com/apps/dependabot) via [#158](https://github.com/10up/maps-block-apple/pull/158)).111 * **Security:** Bump `http-cache-semantics` from 4.1.0 to 4.1.1 (props [@dependabot](https://github.com/apps/dependabot) via [#159](https://github.com/10up/maps-block-apple/pull/159)).112 * **Security:** Bump `@sideway/formula` from 3.0.0 to 3.0.1 (props [@dependabot](https://github.com/apps/dependabot) via [#160](https://github.com/10up/maps-block-apple/pull/160)).113 * **Security:** Bump `webpack` from 5.73.0 to 5.76.1 (props [@dependabot](https://github.com/apps/dependabot) via [#162](https://github.com/10up/maps-block-apple/pull/162)).114 115 = 1.1.0 - 2023-01-23 =116 * **Note that this release bumps the WordPress minimum version from 5.2 to 5.8.**117 118 * **Added:** Support for custom marker icons (props [@iamdharmesh](https://github.com/iamdharmesh), [@dinhtungdu](https://github.com/dinhtungdu), [@fabiankaegy](https://github.com/fabiankaegy) via [#136](https://github.com/10up/maps-block-apple/pull/136)).119 * **Added:** Ability to control margin of map (props [@fabiankaegy](https://github.com/fabiankaegy), [@dkotter](https://github.com/dkotter) via [#157](https://github.com/10up/maps-block-apple/pull/157)).120 * **Added:** End-to-end testing setup with Cypress (props [@cadic](https://github.com/cadic), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#126](https://github.com/10up/maps-block-apple/pull/126)).121 * **Changed:** Bump minimum WordPress version from 5.2 to 5.8 (props [@cadic](https://github.com/cadic), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#126](https://github.com/10up/maps-block-apple/pull/126)).122 * **Changed:** Update linting workflows to take advantage of GitHub Actions summaries (props [@dinhtungdu](https://github.com/dinhtungdu), [@fabiankaegy](https://github.com/fabiankaegy) via [#128](https://github.com/10up/maps-block-apple/pull/128)).123 * **Changed:** Update Support Level from `Active` to `Stable` (props [@jeffpaul](https://github.com/jeffpaul), [@dkotter](https://github.com/dkotter) via [#135](https://github.com/10up/maps-block-apple/pull/135)).124 * **Changed:** Update composer dependencies to avoid conflict (props [@peterwilsoncc](https://github.com/peterwilsoncc), [@iamdharmesh](https://github.com/iamdharmesh) via [#145](https://github.com/10up/maps-block-apple/pull/145)).125 * **Changed:** Bump WordPress "tested up to" version to 6.1 (props [@iamdharmesh](https://github.com/iamdharmesh), [@cadic](https://github.com/cadic) via [#148](https://github.com/10up/maps-block-apple/pull/148)).126 * **Security:** Bump `terser` from 5.14.1 to 5.14.2 (props [@dependabot](https://github.com/apps/dependabot) via [#132](https://github.com/10up/maps-block-apple/pull/132)).127 * **Security:** Bump `markdown-it` from 12.0.4 to 12.3.2 and `@wordpress/scripts` from 20.0.2 to 24.5.0 (props [@dependabot](https://github.com/apps/dependabot) via [#138](https://github.com/10up/maps-block-apple/pull/138)).128 * **Security:** Bump `loader-utils` from 2.0.2 to 2.0.4 (props [@dependabot](https://github.com/apps/dependabot) via [#146](https://github.com/10up/maps-block-apple/pull/146)).129 * **Security:** Bump `simple-git` from 3.10.0 to 3.15.1 (props [@dependabot](https://github.com/apps/dependabot) via [#149](https://github.com/10up/maps-block-apple/pull/149)).130 * **Security:** Bump `json5` from 1.0.1 to 1.0.2 (props [@dependabot](https://github.com/apps/dependabot) via [#153](https://github.com/10up/maps-block-apple/pull/153)).131 132 97 = Earlier versions = 133 98 For the changelog of earlier versions, please refer to the [changelog on github.com](https://github.com/10up/maps-block-apple/blob/develop/CHANGELOG.md). 134 99 135 100 == Upgrade Notice == 101 102 = 1.1.5 = 103 104 * Note that this version bumps the minimum WordPress version from 6.4 to 6.6. 136 105 137 106 = 1.1.4 =
Note: See TracChangeset
for help on using the changeset viewer.