import{i,g as d,a as n,b as g}from"./blockUtils-Dh4GyFRv.js";const m=e=>i(e,"led_set")&&n(e,"ledMaterial")==="ALL"&&n(e,"ledState")==="off",_=e=>i(e,"led_rgb_abcd_set")&&n(e,"ledMaterial")==="ALL"&&n(e,"ledColor")==="off";function k(e){if(!e)return!1;const a=g(e);return!a||g(a)?!1:m(e)&&_(a)||_(e)&&m(a)}function p(e){if(!Array.isArray(e))return!1;const a=e.filter(t=>t?.action!=="switchOn"&&t?.action!=="switchOff");if(a.length!==30)return!1;for(let t=0;t<5;t+=1){const s=a.slice(t*6,t*6+6);if(s[5]?.action!=="setTime"||Number(s[5]?.time)!==2)return!1;let f=!1;const o=new Set(["A","B","C","D"]);for(let u=0;u<5;u+=1){const r=s[u];if(r?.action!=="setLED")return!1;if(r.type==="led"){if(r.material==="A"&&r.state===!0&&!f){f=!0;continue}return!1}if(r.type==="led_rgb_abcd"){if(o.has(r.material)&&r.state===!0&&r.color==="random"){o.delete(r.material);continue}return!1}return!1}if(!f||o.size!==0)return!1}return!0}function b(e){if(!i(e,"custom_repeat_ext"))return!1;const a=d(e,"TIMES");if(Number(n(a,"NUM"))!==5)return!1;const t=[];let s=d(e,"DO");for(;s;)t.push(s),s=g(s);if(t.length!==3&&t.length!==6)return!1;const f=t.length===3,o=t[t.length-1];if(!i(o,"time_set")||Number(n(o,"timeValue"))!==2)return!1;if(f){const c=t[0],l=t[1];return!(!i(c,"led_set")||n(c,"ledMaterial")!=="A"||n(c,"ledState")!=="on"||!i(l,"led_rgb_abcd_set")||n(l,"ledMaterial")!=="ALL"||n(l,"ledColor")!=="random")}const u=new Set(["A","B","C","D"]);let r=!1;for(let c=0;c<5;c+=1){const l=t[c];if(i(l,"led_set")){if(n(l,"ledMaterial")==="A"&&n(l,"ledState")==="on"&&!r){r=!0;continue}return!1}if(i(l,"led_rgb_abcd_set")){const h=n(l,"ledMaterial");if(u.has(h)&&n(l,"ledColor")==="random"){u.delete(h);continue}return!1}return!1}return r&&u.size===0}const w={checkpoints:[{id:"checkpoint1",checkCondition:(e,a={})=>{const t=a?.blocklyWorkspaceRef?.current;if(!t)return!1;const s=t.getTopBlocks(!0);if(s?.length!==1||s[0]?.type!=="controls_start")return!1;let f=s[0],o=null;for(;f?.getNextBlock;)if(f=f.getNextBlock(),i(f,"controls_if")){o=f;break}if(!o)return!1;const u=d(o,"IF0");if(!i(u,"switch_condition")||n(u,"switchState")!=="on")return!1;const r=d(o,"DO0");if(!b(r))return!1;const c=g(o);if(!i(c,"controls_if"))return!1;const l=d(c,"IF0"),h=d(c,"DO0");return!i(l,"switch_condition")||n(l,"switchState")!=="off"||!k(h)?!1:p(e)},dialogues:[{speaker:"Rob",message:"Tekan butang 'Switch OFF' untuk mematikan semua lampu dan selesaikan misi!",characterDirection:"left",dialogType:"checkpoint"}]}]};export{w as checkpointConfig};
