(()=>{"use strict";var e,t={225:(e,t,a)=>{const r=window.wp.blocks,n=window.React,s=window.wp.i18n,o=window.wp.components,i=window.wp.apiFetch;var l=a.n(i);const c=window.wp.element,u=window.wp.blockEditor,d=JSON.parse('{"u2":"jquest-inserter/jquest-inserter"}'),p={save:function({attributes:e}){const{selectedGame:t,organization:a}=e;return(0,n.createElement)("div",{...useBlockProps.save()},(0,n.createElement)("script",{src:"https://files.jquest.fi/jquest/jquest.js",defer:!0,async:!0,type:"module"}),(0,n.createElement)("div",{className:"jquest-app","data-org-id":a,"data-game-id":t}))}};(0,r.registerBlockType)(d.u2,{edit:function({attributes:e,setAttributes:t}){const{selectedGame:a,organization:r}=e,[i,d]=(0,c.useState)([]),[p,m]=(0,c.useState)((0,s.__)("JQUEST Inserter","jquest-inserter"));return(0,c.useEffect)((()=>{l()({path:"/jquest/v1/games"}).then((e=>{e.organization?e.games?(d(e.games.map((e=>({value:e.id,label:e.title})))),a||t({selectedGame:e.games[0].id}),t({organization:e.organization})):m((0,s.__)("No games found for organization","jquest-inserter")):m((0,s.__)("Organization not set. Set organization in JQUEST settings","jquest-inserter"))}))}),[]),(0,n.createElement)(n.Fragment,null,(0,n.createElement)(u.InspectorControls,null,(0,n.createElement)(o.PanelBody,{title:"Settings"},(0,n.createElement)(o.SelectControl,{label:"Select a game",value:a,options:i,onChange:e=>{t({selectedGame:e})}}))),(0,n.createElement)("div",{...(0,u.useBlockProps)()},(0,n.createElement)("div",{className:"jquest-app","data-org-id":r,"data-game-id":a},p)))},save:function({attributes:e}){const{selectedGame:t,organization:a}=e;return(0,n.createElement)("div",{...u.useBlockProps.save()},(0,n.createElement)("script",{"data-cookieconsent":"ignore",src:"https://files.jquest.fi/jquest/jquest.js",type:"module"}),(0,n.createElement)("div",{className:"jquest-app","data-org-id":a,"data-game-id":t}))},deprecated:[p]})}},a={};function r(e){var n=a[e];if(void 0!==n)return n.exports;var s=a[e]={exports:{}};return t[e](s,s.exports,r),s.exports}r.m=t,e=[],r.O=(t,a,n,s)=>{if(!a){var o=1/0;for(u=0;u<e.length;u++){for(var[a,n,s]=e[u],i=!0,l=0;l<a.length;l++)(!1&s||o>=s)&&Object.keys(r.O).every((e=>r.O[e](a[l])))?a.splice(l--,1):(i=!1,s<o&&(o=s));if(i){e.splice(u--,1);var c=n();void 0!==c&&(t=c)}}return t}s=s||0;for(var u=e.length;u>0&&e[u-1][2]>s;u--)e[u]=e[u-1];e[u]=[a,n,s]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var a in t)r.o(t,a)&&!r.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={262:0,228:0};r.O.j=t=>0===e[t];var t=(t,a)=>{var n,s,[o,i,l]=a,c=0;if(o.some((t=>0!==e[t]))){for(n in i)r.o(i,n)&&(r.m[n]=i[n]);if(l)var u=l(r)}for(t&&t(a);c<o.length;c++)s=o[c],r.o(e,s)&&e[s]&&e[s][0](),e[s]=0;return r.O(u)},a=globalThis.webpackChunkjquest_plugin=globalThis.webpackChunkjquest_plugin||[];a.forEach(t.bind(null,0)),a.push=t.bind(null,a.push.bind(a))})();var n=r.O(void 0,[228],(()=>r(225)));n=r.O(n)})();